diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index fd945b0f2a..5429f3eb95 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -109,8 +109,25 @@ jobs: steps: + - name: Check out the PR + uses: actions/checkout@v2 + + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Cache PlatformIO + uses: actions/cache@v2 + with: + path: ~/.platformio + key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + - name: Select Python 3.7 - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax. architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified @@ -120,9 +137,6 @@ jobs: pip install -U https://github.com/platformio/platformio-core/archive/develop.zip platformio update - - name: Check out the PR - uses: actions/checkout@v2 - - name: Run ${{ matrix.test-platform }} Tests run: | make tests-single-ci TEST_TARGET=${{ matrix.test-platform }} diff --git a/.gitignore b/.gitignore index ac2c9b5591..bc603ba38b 100755 --- a/.gitignore +++ b/.gitignore @@ -143,7 +143,11 @@ vc-fileutils.settings .vscode/launch.json .vscode/*.db -# cmake +#Simulation +imgui.ini +eeprom.dat + +#cmake CMakeLists.txt src/CMakeLists.txt CMakeListsPrivate.txt diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 601f1e83a8..21fb99b53b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -44,7 +44,7 @@ * Advanced settings can be found in Configuration_adv.h * */ -#define CONFIGURATION_H_VERSION 02000900 +#define CONFIGURATION_H_VERSION 02000901 //=========================================================================== //============================= Getting Started ============================= @@ -75,14 +75,6 @@ // //=========================================================================== -//=========================================================================== -//=========================== FOAMCUTTER_XYUV ============================== -//=========================================================================== -// For a hot wire cutter with parallel horizontal axes X, I where the hights -// of the two wire ends are controlled by parallel axes Y, J. -// -//#define FOAMCUTTER_XYUV - // @section info // Author info of this build printed to the host during boot and M115 @@ -416,7 +408,9 @@ //#define PSU_NAME "Power Supply" #if ENABLED(PSU_CONTROL) - #define PSU_ACTIVE_HIGH false // Set 'false' for ATX, 'true' for X-Box + //#define PS_OFF_CONFIRM // Confirm dialog when power off + //#define PS_OFF_SOUND // Beep 1s when power off + #define PSU_ACTIVE_STATE LOW // Set 'LOW' for ATX, 'HIGH' for X-Box //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80 //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power @@ -445,69 +439,93 @@ // @section temperature /** - * --NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table + * --NORMAL IS 4.7kΩ PULLUP!-- 1kΩ pullup can be used on hotend sensor, using correct resistor and table * * Temperature sensors available: * - * -5 : PT100 / PT1000 with MAX31865 (only for sensors 0-1) - * -3 : thermocouple with MAX31855 (only for sensors 0-1) - * -2 : thermocouple with MAX6675 (only for sensors 0-1) - * -4 : thermocouple with AD8495 - * -1 : thermocouple with AD595 + * SPI RTD/Thermocouple Boards - IMPORTANT: Read the NOTE below! + * ------- + * -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-1) + * NOTE: You must uncomment/set the MAX31865_*_OHMS_n defines below. + * -3 : MAX31855 with Thermocouple, -200°C to +700°C (only for sensors 0-1) + * -2 : MAX6675 with Thermocouple, 0°C to +700°C (only for sensors 0-1) + * + * NOTE: Ensure TEMP_n_CS_PIN is set in your pins file for each TEMP_SENSOR_n using an SPI Thermocouple. By default, + * Hardware SPI on the default serial bus is used. If you have also set TEMP_n_SCK_PIN and TEMP_n_MISO_PIN, + * Software SPI will be used on those ports instead. You can force Hardware SPI on the default bus in the + * Configuration_adv.h file. At this time, separate Hardware SPI buses for sensors are not supported. + * + * Analog Themocouple Boards + * ------- + * -4 : AD8495 with Thermocouple + * -1 : AD595 with Thermocouple + * + * Analog Thermistors - 4.7kΩ pullup - Normal + * ------- + * 1 : 100kΩ EPCOS - Best choice for EPCOS thermistors + * 331 : 100kΩ Same as #1, but 3.3V scaled for MEGA + * 332 : 100kΩ Same as #1, but 3.3V scaled for DUE + * 2 : 200kΩ ATC Semitec 204GT-2 + * 202 : 200kΩ Copymaster 3D + * 3 : ???Ω Mendel-parts thermistor + * 4 : 10kΩ Generic Thermistor !! DO NOT use for a hotend - it gives bad resolution at high temp. !! + * 5 : 100kΩ ATC Semitec 104GT-2/104NT-4-R025H42G - Used in ParCan, J-Head, and E3D, SliceEngineering 300°C + * 501 : 100kΩ Zonestar - Tronxy X3A + * 502 : 100kΩ Zonestar - used by hot bed in Zonestar Průša P802M + * 512 : 100kΩ RPW-Ultra hotend + * 6 : 100kΩ EPCOS - Not as accurate as table #1 (created using a fluke thermocouple) + * 7 : 100kΩ Honeywell 135-104LAG-J01 + * 71 : 100kΩ Honeywell 135-104LAF-J01 + * 8 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT + * 9 : 100kΩ GE Sensing AL03006-58.2K-97-G1 + * 10 : 100kΩ RS PRO 198-961 + * 11 : 100kΩ Keenovo AC silicone mats, most Wanhao i3 machines - beta 3950, 1% + * 12 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT (#8) - calibrated for Makibox hot bed + * 13 : 100kΩ Hisens up to 300°C - for "Simple ONE" & "All In ONE" hotend - beta 3950, 1% + * 15 : 100kΩ Calibrated for JGAurora A5 hotend + * 18 : 200kΩ ATC Semitec 204GT-2 Dagoma.Fr - MKS_Base_DKU001327 + * 22 : 100kΩ GTM32 Pro vB - hotend - 4.7kΩ pullup to 3.3V and 220Ω to analog input + * 23 : 100kΩ GTM32 Pro vB - bed - 4.7kΩ pullup to 3.3v and 220Ω to analog input + * 30 : 100kΩ Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K - beta 3950 + * 60 : 100kΩ Maker's Tool Works Kapton Bed Thermistor - beta 3950 + * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950 + * 66 : 4.7MΩ Dyze Design High Temperature Thermistor + * 67 : 500kΩ SliceEngineering 450°C Thermistor + * 70 : 100kΩ bq Hephestos 2 + * 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32 + * 2000 : 100kΩ Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor + * + * Analog Thermistors - 1kΩ pullup - Atypical, and requires changing out the 4.7kΩ pullup for 1kΩ. + * ------- (but gives greater accuracy and more stable PID) + * 51 : 100kΩ EPCOS (1kΩ pullup) + * 52 : 200kΩ ATC Semitec 204GT-2 (1kΩ pullup) + * 55 : 100kΩ ATC Semitec 104GT-2 - Used in ParCan & J-Head (1kΩ pullup) + * + * Analog Thermistors - 10kΩ pullup - Atypical + * ------- + * 99 : 100kΩ Found on some Wanhao i3 machines with a 10kΩ pull-up resistor + * + * Analog RTDs (Pt100/Pt1000) + * ------- + * 110 : Pt100 with 1kΩ pullup (atypical) + * 147 : Pt100 with 4.7kΩ pullup + * 1010 : Pt1000 with 1kΩ pullup (atypical) + * 1047 : Pt1000 with 4.7kΩ pullup (E3D) + * 20 : Pt100 with circuit in the Ultimainboard V2.x with mainboard ADC reference voltage = INA826 amplifier-board supply voltage. + * NOTE: (1) Must use an ADC input with no pullup. (2) Some INA826 amplifiers are unreliable at 3.3V so consider using sensor 147, 110, or 21. + * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v ADC reference voltage (STM32, LPC176x....) and 5V INA826 amplifier board supply. + * NOTE: ADC pins are not 5V tolerant. Not recommended because it's possible to damage the CPU by going over 500°C. + * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x + * + * Custom/Dummy/Other Thermal Sensors + * ------ * 0 : not used - * 1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup) - * 331 : (3.3V scaled thermistor 1 table for MEGA) - * 332 : (3.3V scaled thermistor 1 table for DUE) - * 2 : 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup) - * 202 : 200k thermistor - Copymaster 3D - * 3 : Mendel-parts thermistor (4.7k pullup) - * 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! - * 5 : 100K thermistor - ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan, J-Head, and E3D) (4.7k pullup) - * 501 : 100K Zonestar (Tronxy X3A) Thermistor - * 502 : 100K Zonestar Thermistor used by hot bed in Zonestar Prusa P802M - * 512 : 100k RPW-Ultra hotend thermistor (4.7k pullup) - * 6 : 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) - * 7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) - * 71 : 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) - * 8 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) - * 9 : 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) - * 10 : 100k RS thermistor 198-961 (4.7k pullup) - * 11 : 100k beta 3950 1% thermistor (Used in Keenovo AC silicone mats and most Wanhao i3 machines) (4.7k pullup) - * 12 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) - * 13 : 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" - * 15 : 100k thermistor calibration for JGAurora A5 hotend - * 18 : ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327 - * 20 : Pt100 with circuit in the Ultimainboard V2.x with mainboard ADC reference voltage = INA826 amplifier-board supply voltage. - * NOTES: (1) Must use an ADC input with no pullup. (2) Some INA826 amplifiers are unreliable at 3.3V so consider using sensor 147, 110, or 21. - * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v ADC reference voltage (STM32, LPC176x....) and 5V INA826 amplifier board supply. - * NOTE: ADC pins are not 5V tolerant. Not recommended because it's possible to damage the CPU by going over 500°C. - * 22 : 100k (hotend) with 4.7k pullup to 3.3V and 220R to analog input (as in GTM32 Pro vB) - * 23 : 100k (bed) with 4.7k pullup to 3.3v and 220R to analog input (as in GTM32 Pro vB) - * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x - * 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 - * 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup - * 66 : 4.7M High Temperature thermistor from Dyze Design - * 67 : 450C thermistor from SliceEngineering - * 70 : the 100K thermistor found in the bq Hephestos 2 - * 75 : 100k Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor - * 99 : 100k thermistor with a 10K pull-up resistor (found on some Wanhao i3 machines) - * - * 1k ohm pullup tables - This is atypical, and requires changing out the 4.7k pullup for 1k. - * (but gives greater accuracy and more stable PID) - * 51 : 100k thermistor - EPCOS (1k pullup) - * 52 : 200k thermistor - ATC Semitec 204GT-2 (1k pullup) - * 55 : 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) - * - * 1047 : Pt1000 with 4k7 pullup (E3D) - * 1010 : Pt1000 with 1k pullup (non standard) - * 147 : Pt100 with 4k7 pullup - * 110 : Pt100 with 1k pullup (non standard) - * * 1000 : Custom - Specify parameters in Configuration_adv.h * - * Use these for Testing or Development purposes. NEVER for production machine. + * !!! Use these for Testing or Development purposes. NEVER for production machine. !!! * 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below. * 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below. + * */ #define TEMP_SENSOR_0 5 #if ENABLED(TazPro) @@ -523,6 +541,8 @@ #define TEMP_SENSOR_PROBE 0 #define TEMP_SENSOR_CHAMBER 0 #define TEMP_SENSOR_COOLER 0 +#define TEMP_SENSOR_BOARD 0 +#define TEMP_SENSOR_REDUNDANT 0 // Dummy thermistor constant temperature readings, for use with 998 and 999 #define DUMMY_THERMISTOR_998_VALUE 25 @@ -530,27 +550,38 @@ // Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1 //#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000) -//#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for AdaFruit PT100; 4300 for AdaFruit PT1000 +//#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000 //#define MAX31865_SENSOR_OHMS_1 100 //#define MAX31865_CALIBRATION_OHMS_1 430 -// Use temp sensor 1 as a redundant sensor with sensor 0. If the readings -// from the two sensors differ too much the print will be aborted. -//#define TEMP_SENSOR_1_AS_REDUNDANT -#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 +#define TEMP_RESIDENCY_TIME 5 // (seconds) Time to wait for hotend to "settle" in M109 +#define TEMP_WINDOW 3 // (°C) Temperature proximity for the "temperature reached" timer +#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target -#define TEMP_RESIDENCY_TIME 2 // (seconds) Time to wait for hotend to "settle" in M109 -#define TEMP_WINDOW 5 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_HYSTERESIS 5 // (°C) Temperature proximity considered "close enough" to the target - -#define TEMP_BED_RESIDENCY_TIME 3 // (seconds) Time to wait for bed to "settle" in M190 -#define TEMP_BED_WINDOW 3 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_BED_HYSTERESIS 5 // (°C) Temperature proximity considered "close enough" to the target +#define TEMP_BED_RESIDENCY_TIME 5 // (seconds) Time to wait for bed to "settle" in M190 +#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer +#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target #define TEMP_CHAMBER_RESIDENCY_TIME 10 // (seconds) Time to wait for chamber to "settle" in M191 #define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer #define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +/** + * Redundant Temperature Sensor (TEMP_SENSOR_REDUNDANT) + * + * Use a temp sensor as a redundant sensor for another reading. Select an unused temperature sensor, and another + * sensor you'd like it to be redundant for. If the two thermistors differ by TEMP_SENSOR_REDUNDANT_MAX_DIFF (°C), + * the print will be aborted. Whichever sensor is selected will have its normal functions disabled; i.e. selecting + * the Bed sensor (-1) will disable bed heating/monitoring. + * + * For selecting source/target use: COOLER, PROBE, BOARD, CHAMBER, BED, E0, E1, E2, E3, E4, E5, E6, E7 + */ +#if TEMP_SENSOR_REDUNDANT + #define TEMP_SENSOR_REDUNDANT_SOURCE E1 // The sensor that will provide the redundant reading. + #define TEMP_SENSOR_REDUNDANT_TARGET E0 // The sensor that we are providing a redundant reading for. + #define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 // (°C) Temperature difference that will trigger a print abort. +#endif + // Below this temperature the heater will be switched off // because it probably indicates a broken thermistor wire. #define HEATER_0_MINTEMP 5 @@ -882,6 +913,7 @@ #define Y_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #endif #define Z_MIN_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop. + #define I_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define J_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define K_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. @@ -934,7 +966,6 @@ //#define I_DRIVER_TYPE A4988 //#define J_DRIVER_TYPE A4988 //#define K_DRIVER_TYPE A4988 -//#define E0_DRIVER_TYPE A4988 //#define E1_DRIVER_TYPE A4988 //#define E2_DRIVER_TYPE A4988 //#define E3_DRIVER_TYPE A4988 @@ -1075,7 +1106,7 @@ #define DEFAULT_YJERK 8.0 #endif #define DEFAULT_ZJERK 0.4 - //#define DEFAULT_IJERK 0.3 + //#define DEFAULT_IJERK 0.3 //#define DEFAULT_JJERK 0.3 //#define DEFAULT_KJERK 0.3 @@ -1296,7 +1327,7 @@ #define PROBING_MARGIN 0 // X and Y axis travel speed (mm/min) between probes -#define XY_PROBE_FEEDRATE (133*60) +#define XY_PROBE_FEEDRATE (100*60) // Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2) #define Z_PROBE_FEEDRATE_FAST (8*60) @@ -1390,7 +1421,8 @@ //#define WAIT_FOR_HOTEND // Wait for hotend to heat back up between probes (to improve accuracy & prevent cold extrude) #endif //#define PROBING_FANS_OFF // Turn fans off when probing -//#define PROBING_STEPPERS_OFF // Turn steppers off (unless needed to hold position) when probing +//#define PROBING_ESTEPPERS_OFF // Turn all extruder steppers off when probing +//#define PROBING_STEPPERS_OFF // Turn all steppers off (unless needed to hold position) when probing (including extruders) //#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors // Require minimum nozzle and/or bed temperature for probing @@ -1483,7 +1515,6 @@ #else #define Z_HOME_DIR -1 #endif - //#define I_HOME_DIR -1 //#define J_HOME_DIR -1 //#define K_HOME_DIR -1 @@ -1548,7 +1579,6 @@ #define Y_MAX_POS 292 // <-- changed #define Z_MAX_POS 292 // <-- changed #endif - //#define I_MIN_POS 0 //#define I_MAX_POS 50 //#define J_MIN_POS 0 @@ -1650,9 +1680,10 @@ //#define FIL_RUNOUT8_PULLUP //#define FIL_RUNOUT8_PULLDOWN - // Set one or more commands to execute on filament runout. - // (After 'M412 H' Marlin will ask the host to handle the process.) - #define FILAMENT_RUNOUT_SCRIPT "M25P2" + // Commands to execute on filament runout. + // With multiple runout sensors use the %c placeholder for the current tool in commands (e.g., "M600 T%c") + // NOTE: After 'M412 H1' the host handles filament runout and this script does not apply. + #define FILAMENT_RUNOUT_SCRIPT "M600" // After a runout is detected, continue printing this length of filament // before executing the runout script. Useful for a sensor at the end of @@ -1902,15 +1933,13 @@ //#define MANUAL_J_HOME_POS 0 //#define MANUAL_K_HOME_POS 0 -// Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area. -// -// With this feature enabled: -// -// - Allow Z homing only after X and Y homing AND stepper drivers still enabled. -// - If stepper drivers time out, it will need X and Y homing again before Z homing. -// - Move the Z probe (or nozzle) to a defined XY point before Z Homing. -// - Prevent Z homing when the Z probe is outside bed area. -// +/** + * Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area. + * + * - Moves the Z probe (or nozzle) to a defined XY point before Z homing. + * - Allows Z homing only when XY positions are known and trusted. + * - If stepper drivers sleep, XY homing may be required again before Z homing. + */ #if ENABLED(Taz6) #define Z_SAFE_HOMING #endif @@ -2039,7 +2068,7 @@ // Preheat Constants - Up to 5 are supported without changes // #define PREHEAT_1_LABEL "PLA" -#define PREHEAT_1_TEMP_HOTEND 180 +#define PREHEAT_1_TEMP_HOTEND 200 #define PREHEAT_1_TEMP_BED 70 #define PREHEAT_1_TEMP_CHAMBER 35 #define PREHEAT_1_FAN_SPEED 0 // Value from 0 to 255 @@ -2624,6 +2653,11 @@ // //#define MKS_MINI_12864 +// +// MKS MINI12864 V3 is an alias for FYSETC_MINI_12864_2_1. Type A/B. NeoPixel RGB Backlight. +// +//#define MKS_MINI_12864_V3 + // // MKS LCD12864A/B with graphic controller and SD support. Follows MKS_MINI_12864 pinout. // https://www.aliexpress.com/item/33018110072.html @@ -2744,11 +2778,33 @@ // DGUS Touch Display with DWIN OS. (Choose one.) // ORIGIN : https://www.aliexpress.com/item/32993409517.html // FYSETC : https://www.aliexpress.com/item/32961471929.html +// MKS : https://www.aliexpress.com/item/1005002008179262.html +// +// Flash display with DGUS Displays for Marlin: +// - Format the SD card to FAT32 with an allocation size of 4kb. +// - Download files as specified for your type of display. +// - Plug the microSD card into the back of the display. +// - Boot the display and wait for the update to complete. +// +// ORIGIN (Marlin DWIN_SET) +// - Download https://github.com/coldtobi/Marlin_DGUS_Resources +// - Copy the downloaded DWIN_SET folder to the SD card. +// +// FYSETC (Supplier default) +// - Download https://github.com/FYSETC/FYSTLCD-2.0 +// - Copy the downloaded SCREEN folder to the SD card. +// +// HIPRECY (Supplier default) +// - Download https://github.com/HiPrecy/Touch-Lcd-LEO +// - Copy the downloaded DWIN_SET folder to the SD card. +// +// MKS (MKS-H43) (Supplier default) +// - Download https://github.com/makerbase-mks/MKS-H43 +// - Copy the downloaded DWIN_SET folder to the SD card. // //#define DGUS_LCD_UI_ORIGIN //#define DGUS_LCD_UI_FYSETC //#define DGUS_LCD_UI_HIPRECY - //#define DGUS_LCD_UI_MKS #if ENABLED(DGUS_LCD_UI_MKS) #define USE_MKS_GREEN_UI diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2d2f27187a..1676ae274b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -31,7 +31,7 @@ * Basic settings can be found in Configuration.h * */ -#define CONFIGURATION_ADV_H_VERSION 02000900 +#define CONFIGURATION_ADV_H_VERSION 02000901 // @section temperature @@ -127,10 +127,33 @@ #define PROBE_BETA 3950 // Beta value #endif -// -// Hephestos 2 24V heated bed upgrade kit. -// https://store.bq.com/en/heated-bed-kit-hephestos2 -// +#if TEMP_SENSOR_BOARD == 1000 + #define BOARD_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define BOARD_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define BOARD_BETA 3950 // Beta value +#endif + +#if TEMP_SENSOR_REDUNDANT == 1000 + #define REDUNDANT_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define REDUNDANT_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define REDUNDANT_BETA 3950 // Beta value +#endif + +/** + * Configuration options for MAX Thermocouples (-2, -3, -5). + * FORCE_HW_SPI: Ignore SCK/MOSI/MISO pins and just use the CS pin & default SPI bus. + * MAX31865_WIRES: Set the number of wires for the probe connected to a MAX31865 board, 2-4. Default: 2 + * MAX31865_50HZ: Enable 50Hz filter instead of the default 60Hz. + */ +//#define TEMP_SENSOR_FORCE_HW_SPI +//#define MAX31865_SENSOR_WIRES_0 2 +//#define MAX31865_SENSOR_WIRES_1 2 +//#define MAX31865_50HZ_FILTER + +/** + * Hephestos 2 24V heated bed upgrade kit. + * https://store.bq.com/en/heated-bed-kit-hephestos2 + */ //#define HEPHESTOS2_HEATED_BED_KIT #if ENABLED(HEPHESTOS2_HEATED_BED_KIT) #undef TEMP_SENSOR_BED @@ -198,7 +221,7 @@ #define COOLER_MAXTEMP 26 // (°C) #define COOLER_DEFAULT_TEMP 16 // (°C) #define TEMP_COOLER_HYSTERESIS 1 // (°C) Temperature proximity considered "close enough" to the target - #define COOLER_PIN 8 // Laser cooler on/off pin used to control power to the cooling element e.g. TEC, External chiller via relay + #define COOLER_PIN 8 // Laser cooler on/off pin used to control power to the cooling element (e.g., TEC, External chiller via relay) #define COOLER_INVERTING false #define TEMP_COOLER_PIN 15 // Laser/Cooler temperature sensor pin. ADC is required. #define COOLER_FAN // Enable a fan on the cooler, Fan# 0,1,2,3 etc. @@ -209,6 +232,18 @@ #endif #endif +// +// Motherboard Sensor options +// +#if TEMP_SENSOR_BOARD + #define THERMAL_PROTECTION_BOARD // Halt the printer if the board sensor leaves the temp range below. + #define BOARD_MINTEMP 8 // (°C) + #define BOARD_MAXTEMP 70 // (°C) + #ifndef TEMP_BOARD_PIN + //#define TEMP_BOARD_PIN -1 // Board temp sensor pin, if not set in pins file. + #endif +#endif + // // Laser Coolant Flow Meter // @@ -260,8 +295,8 @@ * and/or decrease WATCH_TEMP_INCREASE. WATCH_TEMP_INCREASE should not be set * below 2. */ - #define WATCH_TEMP_PERIOD 20 // Seconds - #define WATCH_TEMP_INCREASE 3 // Degrees Celsius + #define WATCH_TEMP_PERIOD 50 // Seconds + #define WATCH_TEMP_INCREASE 5 // Degrees Celsius #endif /** @@ -478,9 +513,13 @@ #define CONTROLLERFAN_SPEED_ACTIVE 255 // (0-255) Active speed, used when any motor is enabled #define CONTROLLERFAN_SPEED_IDLE 120 // (0-255) Idle speed, used when motors are disabled #define CONTROLLERFAN_IDLE_TIME 60 // (seconds) Extra time to keep the fan running after disabling motors + + // Use TEMP_SENSOR_BOARD as a trigger for enabling the controller fan + //#define CONTROLLER_FAN_MIN_BOARD_TEMP 40 // (°C) Turn on the fan if the board reaches this temperature + #define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings #if ENABLED(CONTROLLER_FAN_EDITABLE) - #define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu + #define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu #endif #endif @@ -534,6 +573,11 @@ //#define USE_OCR2A_AS_TOP #endif +/** + * Use one of the PWM fans as a redundant part-cooling fan + */ +//#define REDUNDANT_PART_COOLING_FAN 2 // Index of the fan to sync with FAN 0. + // @section extruder /** @@ -683,6 +727,12 @@ #endif #endif +// Drive the E axis with two synchronized steppers +//#define E_DUAL_STEPPER_DRIVERS +#if ENABLED(E_DUAL_STEPPER_DRIVERS) + //#define INVERT_E1_VS_E0_DIR // Enable if the E motors need opposite DIR states +#endif + /** * Dual X Carriage * @@ -950,7 +1000,7 @@ #if ANY(TazPro, MiniV2) #define DISABLE_INACTIVE_Z true // Set to false if the nozzle will fall down on your printed part when print has finished. #endif -fine DISABLE_INACTIVE_I true +#define DISABLE_INACTIVE_I true #define DISABLE_INACTIVE_J true #define DISABLE_INACTIVE_K true #define DISABLE_INACTIVE_E true @@ -962,6 +1012,10 @@ fine DISABLE_INACTIVE_I true #define HOME_AFTER_DEACTIVATE // Require rehoming after steppers are deactivated #endif +// Default Minimum Feedrates for printing and travel moves +#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s) Minimum feedrate. Set with M205 S. +#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s) Minimum travel feedrate. Set with M205 T. + // Minimum time that a segment needs to take as the buffer gets emptied #define DEFAULT_MINSEGMENTTIME 20000 // (µs) Set with M205 B. @@ -1007,6 +1061,10 @@ fine DISABLE_INACTIVE_I true #define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm) #define BACKLASH_CORRECTION 0.0 // 0.0 = no correction; 1.0 = full correction #endif + + // 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) @@ -1308,11 +1366,14 @@ fine DISABLE_INACTIVE_I true //#define LCD_SHOW_E_TOTAL #endif -#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, EXTENSIBLE_UI) - //#define SHOW_REMAINING_TIME // Display estimated time to completion - #if ENABLED(SHOW_REMAINING_TIME) - //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation - //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time +// LCD Print Progress options +#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) + #if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) + //#define SHOW_REMAINING_TIME // Display estimated time to completion + #if ENABLED(SHOW_REMAINING_TIME) + //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation + //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time + #endif #endif #if EITHER(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI) @@ -1635,7 +1696,7 @@ fine DISABLE_INACTIVE_I true */ //#define STATUS_COMBINE_HEATERS // Use combined heater images instead of separate ones //#define STATUS_HOTEND_NUMBERLESS // Use plain hotend icons instead of numbered ones (with 2+ hotends) - #define STATUS_HOTEND_INVERTED // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM) + #define STATUS_HOTEND_INVERTED // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM for numbered hotends) #define STATUS_HOTEND_ANIM // Use a second bitmap to indicate hotend heating #define STATUS_BED_ANIM // Use a second bitmap to indicate bed heating #define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating @@ -2043,30 +2104,30 @@ fine DISABLE_INACTIVE_I true //#define USE_TEMP_EXT_COMPENSATION // Probe temperature calibration generates a table of values starting at PTC_SAMPLE_START - // (e.g. 30), in steps of PTC_SAMPLE_RES (e.g. 5) with PTC_SAMPLE_COUNT (e.g. 10) samples. + // (e.g., 30), in steps of PTC_SAMPLE_RES (e.g., 5) with PTC_SAMPLE_COUNT (e.g., 10) samples. - //#define PTC_SAMPLE_START 30.0f - //#define PTC_SAMPLE_RES 5.0f - //#define PTC_SAMPLE_COUNT 10U + //#define PTC_SAMPLE_START 30 // (°C) + //#define PTC_SAMPLE_RES 5 // (°C) + //#define PTC_SAMPLE_COUNT 10 // Bed temperature calibration builds a similar table. - //#define BTC_SAMPLE_START 60.0f - //#define BTC_SAMPLE_RES 5.0f - //#define BTC_SAMPLE_COUNT 10U + //#define BTC_SAMPLE_START 60 // (°C) + //#define BTC_SAMPLE_RES 5 // (°C) + //#define BTC_SAMPLE_COUNT 10 // The temperature the probe should be at while taking measurements during bed temperature // calibration. - //#define BTC_PROBE_TEMP 30.0f + //#define BTC_PROBE_TEMP 30 // (°C) - // Height above Z=0.0f to raise the nozzle. Lowering this can help the probe to heat faster. - // Note: the Z=0.0f offset is determined by the probe offset which can be set using M851. - //#define PTC_PROBE_HEATING_OFFSET 0.5f + // Height above Z=0.0 to raise the nozzle. Lowering this can help the probe to heat faster. + // Note: the Z=0.0 offset is determined by the probe offset which can be set using M851. + //#define PTC_PROBE_HEATING_OFFSET 0.5 // Height to raise the Z-probe between heating and taking the next measurement. Some probes // may fail to untrigger if they have been triggered for a long time, which can be solved by // increasing the height the probe is raised to. - //#define PTC_PROBE_RAISE 15U + //#define PTC_PROBE_RAISE 15 // If the probe is outside of the defined range, use linear extrapolation using the closest // point and the PTC_LINEAR_EXTRAPOLATION'th next point. E.g. if set to 4 it will use data[0] @@ -2180,7 +2241,7 @@ fine DISABLE_INACTIVE_I true // @section motion // The number of linear moves that can be in the planner at once. -// The value of BLOCK_BUFFER_SIZE must be a power of 2 (e.g. 8, 16, 32) +// The value of BLOCK_BUFFER_SIZE must be a power of 2 (e.g., 8, 16, 32) #if BOTH(SDSUPPORT, DIRECT_STEPPING) #define BLOCK_BUFFER_SIZE 8 #elif ENABLED(SDSUPPORT) @@ -2341,7 +2402,7 @@ fine DISABLE_INACTIVE_I true * Extra G-code to run while executing tool-change commands. Can be used to use an additional * stepper motor (I axis, see option LINEAR_AXES in Configuration.h) to drive the tool-changer. */ - //#define EVENT_GCODE_TOOLCHANGE_T0 "G28 A\nG1 I0" // Extra G-code to run while executing tool-change command T0 + //#define EVENT_GCODE_TOOLCHANGE_T0 "G28 A\nG1 A0" // Extra G-code to run while executing tool-change command T0 //#define EVENT_GCODE_TOOLCHANGE_T1 "G1 A10" // Extra G-code to run while executing tool-change command T1 /** @@ -2969,7 +3030,7 @@ fine DISABLE_INACTIVE_I true * * It is recommended to set HOMING_BUMP_MM to { 0, 0, 0 }. * - * SPI_ENDSTOPS *** Beta feature! *** TMC2130 Only *** + * SPI_ENDSTOPS *** Beta feature! *** TMC2130/TMC5160 Only *** * Poll the driver through SPI to determine load when homing. * Removes the need for a wire from DIAG1 to an endstop pin. * @@ -3519,8 +3580,18 @@ fine DISABLE_INACTIVE_I true #define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop #endif + + // + // Laser I2C Ammeter (High precision INA226 low/high side module) + // + //#define I2C_AMMETER + #if ENABLED(I2C_AMMETER) + #define I2C_AMMETER_IMAX 0.1 // (Amps) Calibration value for the expected current range + #define I2C_AMMETER_SHUNT_RESISTOR 0.1 // (Ohms) Calibration shunt resistor value + #endif + #endif -#endif +#endif // SPINDLE_FEATURE || LASER_FEATURE /** * Synchronous Laser Control with M106/M107 @@ -3755,18 +3826,17 @@ fine DISABLE_INACTIVE_I true * User-defined menu items to run custom G-code. * Up to 25 may be defined, but the actual number is LCD-dependent. */ - -// Custom Menu: Main Menu -#if DISABLED)TazPro) +#if DISABLED(TazPro) #define CUSTOM_MENU_MAIN #endif #if ENABLED(CUSTOM_MENU_MAIN) #define CUSTOM_MENU_MAIN_TITLE "Tool Heads" - #define CUSTOM_MENU_MAIN_SCRIPT_DONE "M117 Tool Change Done" + #define CUSTOM_MENU_MAIN_SCRIPT_DONE "M117 Toolhead Changed" #define CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK #define CUSTOM_MENU_MAIN_SCRIPT_RETURN // Return to status screen after a script #define CUSTOM_MENU_MAIN_ONLY_IDLE // Only show custom menu when the machine is idle + #if ANY(Taz6, Mini) #define DEFAULT_PID "P28.79I1.91D108.51" #else @@ -3801,16 +3871,12 @@ fine DISABLE_INACTIVE_I true #if NONE(Workhorse, MiniV2) #define MAIN_MENU_ITEM_3_DESC "Standard" #define MAIN_MENU_ITEM_3_GCODE "M92E814\nM206X0Y0\nM301" DEFAULT_PID "\nM907E" E_CURRENT_Std "\nM500" + #define MAIN_MENU_ITEM_3_CONFIRM #endif - #define MAIN_MENU_ITEM_2_CONFIRM #define MAIN_MENU_ITEM_4_DESC "Mosquito BMG-M" - #define MAIN_MENU_ITEM_4_GCODE "M92E415\nM206X-5Y-12\nM301P148.07I26.58D206.21\nM907E" E_CURRENT_BMG "\nM500" + #define USER_GCOMAIN_MENU_ITEM_4_GCODEDE_4 "M92E415\nM206X-5Y-12\nM301P148.07I26.58D206.21\nM907E" E_CURRENT_BMG "\nM500" #define MAIN_MENU_ITEM_4_CONFIRM - - //#define MAIN_MENU_ITEM_5_DESC "Home & Info" - //#define MAIN_MENU_ITEM_5_GCODE "G28\nM503" - //#define MAIN_MENU_ITEM_5_CONFIRM #endif // Custom Menu: Configuration Menu @@ -3890,7 +3956,9 @@ fine DISABLE_INACTIVE_I true */ #define HOST_ACTION_COMMANDS #if ENABLED(HOST_ACTION_COMMANDS) + //#define HOST_PAUSE_M76 #define HOST_PROMPT_SUPPORT + #define HOST_START_MENU_ITEM // Add a menu item that tells the host to start #endif /** @@ -4029,7 +4097,7 @@ fine DISABLE_INACTIVE_I true #define GANTRY_CALIBRATION_FEEDRATE 500 // Feedrate for correction move - #define GANTRY_CALIBRATION_SAFE_POSITION {X_CENTER, Y_MIN} // Safe position for nozzle + #define GANTRY_CALIBRATION_SAFE_POSITION {X_CENTER, Y_MIN_POS} // Safe position for nozzle #define GANTRY_CALIBRATION_XY_PARK_FEEDRATE 3000 // XY Park Feedrate - MMM //#define GANTRY_CALIBRATION_COMMANDS_PRE "" #define GANTRY_CALIBRATION_COMMANDS_POST "G28" @@ -4252,6 +4320,14 @@ fine DISABLE_INACTIVE_I true // Enable Marlin dev mode which adds some special commands //#define MARLIN_DEV_MODE +#if ENABLED(MARLIN_DEV_MODE) + /** + * D576 - Buffer Monitoring + * To help diagnose print quality issues stemming from empty command buffers. + */ + //#define BUFFER_MONITORING +#endif + /** * Postmortem Debugging captures misbehavior and outputs the CPU status and backtrace to serial. * When running in the debugger it will break for debugging. This is useful to help understand diff --git a/Marlin/Version.h b/Marlin/Version.h index 25f84c9848..2ef9f536bd 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -#define STRING_DISTRIBUTION_DATE "2020-08-09" +#define STRING_DISTRIBUTION_DATE "2021-08-01" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index e24b923ef0..a5896a0e97 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -186,7 +186,7 @@ inline void HAL_adc_init() { #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -#define HAL_SENSITIVE_PINS 0, 1 +#define HAL_SENSITIVE_PINS 0, 1, #ifdef __AVR_AT90USB1286__ #define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0) diff --git a/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp b/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp index cb95a48ccc..9d928e7af3 100644 --- a/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp +++ b/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp @@ -62,7 +62,7 @@ #include "../shared/Marduino.h" #include "../shared/Delay.h" -#include +#include uint8_t u8g_bitData, u8g_bitNotData, u8g_bitClock, u8g_bitNotClock; volatile uint8_t *u8g_outData, *u8g_outClock; diff --git a/Marlin/src/HAL/DUE/HAL_SPI.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp index f42e8a9802..758640285b 100644 --- a/Marlin/src/HAL/DUE/HAL_SPI.cpp +++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp @@ -240,7 +240,7 @@ } // all the others - static uint32_t spiDelayCyclesX4 = 4 * (F_CPU) / 1000000; // 4µs => 125khz + static uint16_t spiDelayNS = 4000; // 4000ns => 125khz static uint8_t spiTransferX(uint8_t b) { // using Mode 0 int bits = 8; @@ -249,12 +249,12 @@ b <<= 1; // little setup time WRITE(SD_SCK_PIN, HIGH); - DELAY_CYCLES(spiDelayCyclesX4); + DELAY_NS(spiDelayNS); b |= (READ(SD_MISO_PIN) != 0); WRITE(SD_SCK_PIN, LOW); - DELAY_CYCLES(spiDelayCyclesX4); + DELAY_NS(spiDelayNS); } while (--bits); return b; } @@ -510,7 +510,7 @@ spiRxBlock = (pfnSpiRxBlock)spiRxBlockX; break; default: - spiDelayCyclesX4 = ((F_CPU) / 1000000) >> (6 - spiRate) << 2; // spiRate of 2 gives the maximum error with current CPU + spiDelayNS = 4000 >> (6 - spiRate); // spiRate of 2 gives the maximum error with current CPU spiTransferTx = (pfnSpiTransfer)spiTransferX; spiTransferRx = (pfnSpiTransfer)spiTransferX; spiTxBlock = (pfnSpiTxBlock)spiTxBlockX; diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp index d07da15ad8..fcfcef88be 100644 --- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp +++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp @@ -60,7 +60,7 @@ #if HAS_MARLINUI_U8GLIB -#include +#include #include "../../../MarlinCore.h" diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp index d01cd4dd6b..65bfd4f4e2 100644 --- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp +++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp @@ -62,7 +62,7 @@ #include "../../../inc/MarlinConfig.h" #include "../../shared/Delay.h" -#include +#include #include "u8g_com_HAL_DUE_sw_spi_shared.h" diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp index 890546af58..2b13c182d0 100644 --- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp +++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp @@ -64,7 +64,7 @@ #include "../../shared/Marduino.h" #include "../../shared/Delay.h" -#include +#include #if ENABLED(FYSETC_MINI_12864) #define SPISEND_SW_DUE u8g_spiSend_sw_DUE_mode_3 diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp index 4fb7a6e2c3..904924793b 100644 --- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp +++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp @@ -62,7 +62,7 @@ #include "../../../inc/MarlinConfig.h" #include "../../shared/Delay.h" -#include +#include #include "u8g_com_HAL_DUE_sw_spi_shared.h" diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.h b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.h index f076c503ca..45231fd091 100644 --- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.h +++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.h @@ -23,7 +23,7 @@ #include "../../../inc/MarlinConfigPre.h" #include "../../shared/Marduino.h" -#include +#include void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index); void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level); diff --git a/Marlin/src/HAL/LINUX/hardware/Gpio.h b/Marlin/src/HAL/LINUX/hardware/Gpio.h index 2d9b1f29eb..f946be6484 100644 --- a/Marlin/src/HAL/LINUX/hardware/Gpio.h +++ b/Marlin/src/HAL/LINUX/hardware/Gpio.h @@ -40,7 +40,7 @@ struct GpioEvent { pin_type pin_id; GpioEvent::Type event; - GpioEvent(uint64_t timestamp, pin_type pin_id, GpioEvent::Type event){ + GpioEvent(uint64_t timestamp, pin_type pin_id, GpioEvent::Type event) { this->timestamp = timestamp; this->pin_id = pin_id; this->event = event; diff --git a/Marlin/src/HAL/LINUX/hardware/LinearAxis.cpp b/Marlin/src/HAL/LINUX/hardware/LinearAxis.cpp index c5b3ccc986..e122ef3666 100644 --- a/Marlin/src/HAL/LINUX/hardware/LinearAxis.cpp +++ b/Marlin/src/HAL/LINUX/hardware/LinearAxis.cpp @@ -51,7 +51,7 @@ void LinearAxis::update() { } void LinearAxis::interrupt(GpioEvent ev) { - if (ev.pin_id == step_pin && !Gpio::pin_map[enable_pin].value){ + if (ev.pin_id == step_pin && !Gpio::pin_map[enable_pin].value) { if (ev.event == GpioEvent::RISE) { last_update = ev.timestamp; position += -1 + 2 * Gpio::pin_map[dir_pin].value; diff --git a/Marlin/src/HAL/LINUX/hardware/Timer.h b/Marlin/src/HAL/LINUX/hardware/Timer.h index 757efdcdbd..1b3b800dca 100644 --- a/Marlin/src/HAL/LINUX/hardware/Timer.h +++ b/Marlin/src/HAL/LINUX/hardware/Timer.h @@ -52,7 +52,7 @@ public: return (*(intptr_t*)timerid); } - static void handler(int sig, siginfo_t *si, void *uc){ + static void handler(int sig, siginfo_t *si, void *uc) { Timer* _this = (Timer*)si->si_value.sival_ptr; _this->avg_error += (Clock::nanos() - _this->start_time) - _this->period; //high_resolution_clock is also limited in precision, but best we have _this->avg_error /= 2; //very crude precision analysis (actually within +-500ns usually) diff --git a/Marlin/src/HAL/LINUX/include/pinmapping.cpp b/Marlin/src/HAL/LINUX/include/pinmapping.cpp index 870ab3a96e..5823668cd5 100644 --- a/Marlin/src/HAL/LINUX/include/pinmapping.cpp +++ b/Marlin/src/HAL/LINUX/include/pinmapping.cpp @@ -25,43 +25,6 @@ #include "../../../gcode/parser.h" -uint8_t analog_offset = NUM_DIGITAL_PINS - NUM_ANALOG_INPUTS; - -// Get the digital pin for an analog index -pin_t analogInputToDigitalPin(const int8_t p) { - return (WITHIN(p, 0, NUM_ANALOG_INPUTS) ? analog_offset + p : P_NC); -} - -// Return the index of a pin number -int16_t GET_PIN_MAP_INDEX(const pin_t pin) { - return pin; -} - -// Test whether the pin is valid -bool VALID_PIN(const pin_t p) { - return WITHIN(p, 0, NUM_DIGITAL_PINS); -} - -// Get the analog index for a digital pin -int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p) { - return (WITHIN(p, analog_offset, NUM_DIGITAL_PINS) ? p - analog_offset : P_NC); -} - -// Test whether the pin is PWM -bool PWM_PIN(const pin_t p) { - return false; -} - -// Test whether the pin is interruptable -bool INTERRUPT_PIN(const pin_t p) { - return false; -} - -// Get the pin number at the given index -pin_t GET_PIN_MAP_PIN(const int16_t ind) { - return ind; -} - int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { return parser.intval(code, dval); } diff --git a/Marlin/src/HAL/LINUX/include/pinmapping.h b/Marlin/src/HAL/LINUX/include/pinmapping.h index 98f4b812e8..3751ae0027 100644 --- a/Marlin/src/HAL/LINUX/include/pinmapping.h +++ b/Marlin/src/HAL/LINUX/include/pinmapping.h @@ -34,26 +34,32 @@ constexpr uint8_t NUM_ANALOG_INPUTS = 16; #define HAL_SENSITIVE_PINS +constexpr uint8_t analog_offset = NUM_DIGITAL_PINS - NUM_ANALOG_INPUTS; + // Get the digital pin for an analog index -pin_t analogInputToDigitalPin(const int8_t p); - -// Return the index of a pin number -int16_t GET_PIN_MAP_INDEX(const pin_t pin); - -// Test whether the pin is valid -bool VALID_PIN(const pin_t p); +constexpr pin_t analogInputToDigitalPin(const int8_t p) { + return (WITHIN(p, 0, NUM_ANALOG_INPUTS) ? analog_offset + p : P_NC); +} // Get the analog index for a digital pin -int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p); +constexpr int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p) { + return (WITHIN(p, analog_offset, NUM_DIGITAL_PINS) ? p - analog_offset : P_NC); +} + +// Return the index of a pin number +constexpr int16_t GET_PIN_MAP_INDEX(const pin_t pin) { return pin; } + +// Test whether the pin is valid +constexpr bool VALID_PIN(const pin_t p) { return WITHIN(p, 0, NUM_DIGITAL_PINS); } // Test whether the pin is PWM -bool PWM_PIN(const pin_t p); +constexpr bool PWM_PIN(const pin_t p) { return false; } // Test whether the pin is interruptable -bool INTERRUPT_PIN(const pin_t p); +constexpr bool INTERRUPT_PIN(const pin_t p) { return false; } // Get the pin number at the given index -pin_t GET_PIN_MAP_PIN(const int16_t ind); +constexpr pin_t GET_PIN_MAP_PIN(const int16_t ind) { return ind; } // Parse a G-code word into a pin index int16_t PARSED_PIN_INDEX(const char code, const int16_t dval); diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 85e8933920..3f9cd2dfbd 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -198,7 +198,7 @@ constexpr pin_t GET_PIN_MAP_PIN(const int16_t index) { // Parse a G-code word into a pin index int16_t PARSED_PIN_INDEX(const char code, const int16_t dval); // P0.6 thru P0.9 are for the onboard SD card -#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09 +#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, #define HAL_IDLETASK 1 void HAL_idletask(); diff --git a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp index 99db15f6e9..29f9b43afe 100644 --- a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp +++ b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp @@ -66,11 +66,7 @@ #include - #ifndef HAL_SPI_SPEED - #define HAL_SPI_SPEED SPI_FULL_SPEED - #endif - - static uint8_t SPI_speed = HAL_SPI_SPEED; + static uint8_t SPI_speed = SPI_FULL_SPEED; static uint8_t spiTransfer(uint8_t b) { return swSpiTransfer(b, SPI_speed, SD_SCK_PIN, SD_MISO_PIN, SD_MOSI_PIN); @@ -106,15 +102,13 @@ #else - #ifndef HAL_SPI_SPEED - #ifdef SD_SPI_SPEED - #define HAL_SPI_SPEED SD_SPI_SPEED - #else - #define HAL_SPI_SPEED SPI_FULL_SPEED - #endif + #ifdef SD_SPI_SPEED + #define INIT_SPI_SPEED SD_SPI_SPEED + #else + #define INIT_SPI_SPEED SPI_FULL_SPEED #endif - void spiBegin() { spiInit(HAL_SPI_SPEED); } // Set up SCK, MOSI & MISO pins for SSP0 + void spiBegin() { spiInit(INIT_SPI_SPEED); } // Set up SCK, MOSI & MISO pins for SSP0 void spiInit(uint8_t spiRate) { #if SD_MISO_PIN == BOARD_SPI1_MISO_PIN diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 46a876a836..23d797b2ab 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -146,7 +146,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "Serial port pins (2) conflict with other pins!" #elif Y_HOME_TO_MIN && IS_TX2(Y_STOP_PIN) #error "Serial port pins (2) conflict with Y endstop pin!" - #elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN) + #elif USES_Z_MIN_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN) #error "Serial port pins (2) conflict with probe pin!" #elif ANY_TX(2, X_ENABLE_PIN, Y_ENABLE_PIN) || ANY_RX(2, X_DIR_PIN, Y_DIR_PIN) #error "Serial port pins (2) conflict with X/Y stepper pins!" @@ -237,7 +237,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #define PIN_IS_SCL2(P) (P##_PIN == P0_11) #if PIN_IS_SDA2(Y_STOP) #error "i2c SDA2 overlaps with Y endstop pin!" - #elif HAS_CUSTOM_PROBE_PIN && PIN_IS_SDA2(Z_MIN_PROBE) + #elif USES_Z_MIN_PROBE_PIN && PIN_IS_SDA2(Z_MIN_PROBE) #error "i2c SDA2 overlaps with Z probe pin!" #elif PIN_IS_SDA2(X_ENABLE) || PIN_IS_SDA2(Y_ENABLE) #error "i2c SDA2 overlaps with X/Y ENABLE pin!" diff --git a/Marlin/src/HAL/LPC1768/tft/xpt2046.h b/Marlin/src/HAL/LPC1768/tft/xpt2046.h index 65602bda0f..aba0799e44 100644 --- a/Marlin/src/HAL/LPC1768/tft/xpt2046.h +++ b/Marlin/src/HAL/LPC1768/tft/xpt2046.h @@ -54,7 +54,7 @@ enum XPTCoordinate : uint8_t { XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE, }; -#if !defined(XPT2046_Z1_THRESHOLD) +#ifndef XPT2046_Z1_THRESHOLD #define XPT2046_Z1_THRESHOLD 10 #endif diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp index b1eea13d57..0118f92847 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp @@ -59,7 +59,7 @@ #if HAS_MARLINUI_U8GLIB -#include +#include #include "../../shared/HAL_SPI.h" #ifndef LCD_SPI_SPEED diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp index 6f7efba4ae..bf76eaf0f4 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp @@ -79,7 +79,7 @@ #if HAS_MARLINUI_U8GLIB -#include +#include #define I2C_SLA (0x3C*2) //#define I2C_CMD_MODE 0x080 diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp index 0b0626de79..ce7b338019 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp @@ -59,7 +59,7 @@ #if HAS_MARLINUI_U8GLIB -#include +#include #include "../../shared/HAL_SPI.h" #include "../../shared/Delay.h" diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp index 61211d9d88..039fa6769b 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp @@ -59,7 +59,7 @@ #if ENABLED(U8GLIB_ST7920) -#include +#include #include #include "../../shared/Delay.h" #include "../../shared/HAL_SPI.h" diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp index 7f38ec54af..3308d03e79 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp @@ -71,7 +71,7 @@ #include #include -#include +#include uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) { diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h new file mode 100644 index 0000000000..d5c5782c36 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -0,0 +1,217 @@ +/** + * Marlin 3D Printer Firmware + * + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com + * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define CPU_32_BIT +#define HAL_IDLETASK +void HAL_idletask(); + +#define F_CPU 100000000 +#define SystemCoreClock F_CPU +#include +#include + +#undef min +#undef max + +#include +#include "pinmapping.h" + +void _printf (const char *format, ...); +void _putc(uint8_t c); +uint8_t _getc(); + +//extern "C" volatile uint32_t _millis; + +//arduino: Print.h +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 +//arduino: binary.h (weird defines) +#define B01 1 +#define B10 2 + +#include "../shared/Marduino.h" +#include "../shared/math_32bit.h" +#include "../shared/HAL_SPI.h" +#include "fastio.h" +#include "watchdog.h" +#include "serial.h" + +#define SHARED_SERVOS HAS_SERVOS + +extern MSerialT serial_stream_0; +extern MSerialT serial_stream_1; +extern MSerialT serial_stream_2; +extern MSerialT serial_stream_3; + +#define _MSERIAL(X) serial_stream_##X +#define MSERIAL(X) _MSERIAL(X) + +#if WITHIN(SERIAL_PORT, 0, 3) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) +#else + #error "SERIAL_PORT must be from 0 to 3. Please update your configuration." +#endif + +#ifdef SERIAL_PORT_2 + #if WITHIN(SERIAL_PORT_2, 0, 3) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) + #else + #error "SERIAL_PORT_2 must be from 0 to 3. Please update your configuration." + #endif +#endif + +#ifdef MMU2_SERIAL_PORT + #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." + #endif +#endif + +#ifdef LCD_SERIAL_PORT + #if WITHIN(LCD_SERIAL_PORT, 0, 3) + #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) + #else + #error "LCD_SERIAL_PORT must be from 0 to 3. Please update your configuration." + #endif +#endif + + +#define ST7920_DELAY_1 DELAY_NS(600) +#define ST7920_DELAY_2 DELAY_NS(750) +#define ST7920_DELAY_3 DELAY_NS(750) + +// +// Interrupts +// +#define CRITICAL_SECTION_START() +#define CRITICAL_SECTION_END() +#define ISRS_ENABLED() +#define ENABLE_ISRS() +#define DISABLE_ISRS() + +inline void HAL_init() {} + +// Utility functions +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" +int freeMemory(); +#pragma GCC diagnostic pop + +// ADC +#define HAL_ADC_VREF 5.0 +#define HAL_ADC_RESOLUTION 10 +#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) +#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) +#define HAL_READ_ADC() HAL_adc_get_result() +#define HAL_ADC_READY() true + +void HAL_adc_init(); +void HAL_adc_enable_channel(const uint8_t ch); +void HAL_adc_start_conversion(const uint8_t ch); +uint16_t HAL_adc_get_result(); + +// Reset source +inline void HAL_clear_reset_source(void) {} +inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } + +/* ---------------- Delay in cycles */ + +#define DELAY_CYCLES(x) Kernel::delayCycles(x) +#define SYSTEM_YIELD() Kernel::yield() + +// Maple Compatibility +typedef void (*systickCallback_t)(void); +void systick_attach_callback(systickCallback_t cb); +extern volatile uint32_t systick_uptime_millis; + +// Marlin uses strstr in constexpr context, this is not supported, workaround by defining constexpr versions of the required functions. +#define strstr(a, b) strstr_constexpr((a), (b)) + +constexpr inline std::size_t strlen_constexpr(const char* str) { + // https://github.com/gcc-mirror/gcc/blob/5c7634a0e5f202935aa6c11b6ea953b8bf80a00a/libstdc%2B%2B-v3/include/bits/char_traits.h#L329 + if (str != nullptr) { + std::size_t i = 0; + while (str[i] != '\0') { + ++i; + } + + return i; + } + + return 0; +} + +constexpr inline int strncmp_constexpr(const char* lhs, const char* rhs, std::size_t count) { + // https://github.com/gcc-mirror/gcc/blob/13b9cbfc32fe3ac4c81c4dd9c42d141c8fb95db4/libstdc%2B%2B-v3/include/bits/char_traits.h#L655 + if (lhs == nullptr || rhs == nullptr) { + return rhs != nullptr ? -1 : 1; + } + + for (std::size_t i = 0; i < count; ++i) { + if (lhs[i] != rhs[i]) { + return lhs[i] < rhs[i] ? -1 : 1; + } else if (lhs[i] == '\0') { + return 0; + } + } + + return 0; +} + +constexpr inline const char* strstr_constexpr(const char* str, const char* target) { + // https://github.com/freebsd/freebsd/blob/master/sys/libkern/strstr.c + if (char c = target != nullptr ? *target++ : '\0'; c != '\0' && str != nullptr) { + std::size_t len = strlen_constexpr(target); + do { + char sc = {}; + do { + if ((sc = *str++) == '\0') { + return nullptr; + } + } while (sc != c); + } while (strncmp_constexpr(str, target, len) != 0); + --str; + } + + return str; +} + +constexpr inline char* strstr_constexpr(char* str, const char* target) { + // https://github.com/freebsd/freebsd/blob/master/sys/libkern/strstr.c + if (char c = target != nullptr ? *target++ : '\0'; c != '\0' && str != nullptr) { + std::size_t len = strlen_constexpr(target); + do { + char sc = {}; + do { + if ((sc = *str++) == '\0') { + return nullptr; + } + } while (sc != c); + } while (strncmp_constexpr(str, target, len) != 0); + --str; + } + return str; +} diff --git a/Marlin/src/HAL/NATIVE_SIM/MarlinSPI.h b/Marlin/src/HAL/NATIVE_SIM/MarlinSPI.h new file mode 100644 index 0000000000..b5cc6f02a4 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/MarlinSPI.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com + * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com + * + * 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 + +using MarlinSPI = SPIClass; diff --git a/Marlin/src/HAL/NATIVE_SIM/fastio.h b/Marlin/src/HAL/NATIVE_SIM/fastio.h new file mode 100644 index 0000000000..de8013b1e5 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/fastio.h @@ -0,0 +1,111 @@ +/** + * 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 + +/** + * Fast I/O Routines for X86_64 + */ + +#include "../shared/Marduino.h" +#include + +#define SET_DIR_INPUT(IO) Gpio::setDir(IO, 1) +#define SET_DIR_OUTPUT(IO) Gpio::setDir(IO, 0) + +#define SET_MODE(IO, mode) Gpio::setMode(IO, mode) + +#define WRITE_PIN_SET(IO) Gpio::set(IO) +#define WRITE_PIN_CLR(IO) Gpio::clear(IO) + +#define READ_PIN(IO) Gpio::get(IO) +#define WRITE_PIN(IO,V) Gpio::set(IO, V) + +/** + * Magic I/O routines + * + * Now you can simply SET_OUTPUT(STEP); WRITE(STEP, HIGH); WRITE(STEP, LOW); + * + * Why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html + */ + +/// Read a pin +#define _READ(IO) READ_PIN(IO) + +/// Write to a pin +#define _WRITE(IO,V) WRITE_PIN(IO,V) + +/// toggle a pin +#define _TOGGLE(IO) _WRITE(IO, !READ(IO)) + +/// set pin as input +#define _SET_INPUT(IO) SET_DIR_INPUT(IO) + +/// set pin as output +#define _SET_OUTPUT(IO) SET_DIR_OUTPUT(IO) + +/// set pin as input with pullup mode +#define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT) + +/// set pin as input with pulldown mode +#define _PULLDOWN(IO,V) pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT) + +// hg42: all pins can be input or output (I hope) +// hg42: undefined pins create compile error (IO, is no pin) +// hg42: currently not used, but was used by pinsDebug + +/// check if pin is an input +#define _IS_INPUT(IO) (IO >= 0) + +/// check if pin is an output +#define _IS_OUTPUT(IO) (IO >= 0) + +/// Read a pin wrapper +#define READ(IO) _READ(IO) + +/// Write to a pin wrapper +#define WRITE(IO,V) _WRITE(IO,V) + +/// toggle a pin wrapper +#define TOGGLE(IO) _TOGGLE(IO) + +/// set pin as input wrapper +#define SET_INPUT(IO) _SET_INPUT(IO) +/// set pin as input with pullup wrapper +#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0) +/// set pin as input with pulldown wrapper +#define SET_INPUT_PULLDOWN(IO) do{ _SET_INPUT(IO); _PULLDOWN(IO, HIGH); }while(0) +/// set pin as output wrapper - reads the pin and sets the output to that value +#define SET_OUTPUT(IO) do{ _WRITE(IO, _READ(IO)); _SET_OUTPUT(IO); }while(0) +// set pin as PWM +#define SET_PWM(IO) SET_OUTPUT(IO) + +/// check if pin is an input wrapper +#define IS_INPUT(IO) _IS_INPUT(IO) +/// check if pin is an output wrapper +#define IS_OUTPUT(IO) _IS_OUTPUT(IO) + +// Shorthand +#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0) + +// digitalRead/Write wrappers +#define extDigitalRead(IO) digitalRead(IO) +#define extDigitalWrite(IO,V) digitalWrite(IO,V) diff --git a/Marlin/src/HAL/NATIVE_SIM/inc/Conditionals_LCD.h b/Marlin/src/HAL/NATIVE_SIM/inc/Conditionals_LCD.h new file mode 100644 index 0000000000..1ac02f1182 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/inc/Conditionals_LCD.h @@ -0,0 +1,22 @@ +/** + * 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 diff --git a/Marlin/src/HAL/NATIVE_SIM/inc/Conditionals_adv.h b/Marlin/src/HAL/NATIVE_SIM/inc/Conditionals_adv.h new file mode 100644 index 0000000000..69b6b4848f --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/inc/Conditionals_adv.h @@ -0,0 +1,31 @@ +/** + * 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 + +// Add strcmp_P if missing +#ifndef strcmp_P + #define strcmp_P(a, b) strcmp((a), (b)) +#endif + +#ifndef strcat_P + #define strcat_P(dest, src) strcat((dest), (src)) +#endif diff --git a/Marlin/src/HAL/NATIVE_SIM/inc/Conditionals_post.h b/Marlin/src/HAL/NATIVE_SIM/inc/Conditionals_post.h new file mode 100644 index 0000000000..1ac02f1182 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/inc/Conditionals_post.h @@ -0,0 +1,22 @@ +/** + * 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 diff --git a/Marlin/src/HAL/NATIVE_SIM/inc/SanityCheck.h b/Marlin/src/HAL/NATIVE_SIM/inc/SanityCheck.h new file mode 100644 index 0000000000..104af9af5b --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/inc/SanityCheck.h @@ -0,0 +1,43 @@ +/** + * 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 + +/** + * Test X86_64-specific configuration values for errors at compile-time. + */ + +// Emulating RAMPS +#if ENABLED(SPINDLE_LASER_PWM) && !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11) + #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector" +#endif + +#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY + #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on LINUX." +#endif + +#if HAS_TMC_SW_SERIAL + #error "TMC220x Software Serial is not supported on LINUX." +#endif + +#if ENABLED(POSTMORTEM_DEBUGGING) + #error "POSTMORTEM_DEBUGGING is not yet supported on LINUX." +#endif diff --git a/Marlin/src/HAL/NATIVE_SIM/pinsDebug.h b/Marlin/src/HAL/NATIVE_SIM/pinsDebug.h new file mode 100644 index 0000000000..2aeeb52e92 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/pinsDebug.h @@ -0,0 +1,59 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * 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 . + * + */ + +/** + * Support routines for X86_64 + */ + +/** + * Translation of routines & variables used by pinsDebug.h + */ + +#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS +#define pwm_details(pin) pin = pin // do nothing // print PWM details +#define pwm_status(pin) false //Print a pin's PWM status. Return true if it's currently a PWM pin. +#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0) +#define digitalRead_mod(p) digitalRead(p) +#define PRINT_PORT(p) +#define GET_ARRAY_PIN(p) pin_array[p].pin +#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) +#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0) +#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin + +// active ADC function/mode/code values for PINSEL registers +constexpr int8_t ADC_pin_mode(pin_t pin) { + return (-1); +} + +int8_t get_pin_mode(pin_t pin) { + if (!VALID_PIN(pin)) return -1; + return 0; +} + +bool GET_PINMODE(pin_t pin) { + int8_t pin_mode = get_pin_mode(pin); + if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // found an invalid pin or active analog pin + return false; + + return (Gpio::getMode(pin) != 0); //input/output state +} + +bool GET_ARRAY_IS_DIGITAL(pin_t pin) { + return (!IS_ANALOG(pin) || get_pin_mode(pin) != ADC_pin_mode(pin)); +} diff --git a/Marlin/src/HAL/NATIVE_SIM/servo_private.h b/Marlin/src/HAL/NATIVE_SIM/servo_private.h new file mode 100644 index 0000000000..06be1893f6 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/servo_private.h @@ -0,0 +1,80 @@ +/** + * 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 + +/** + * servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 + * Copyright (c) 2009 Michael Margolis. All right reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * Based on "servo.h - Interrupt driven Servo library for Arduino using 16 bit timers - + * Version 2 Copyright (c) 2009 Michael Margolis. All right reserved. + * + * The only modification was to update/delete macros to match the LPC176x. + * + */ + +#include + +// Macros +//values in microseconds +#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo +#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo +#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached +#define REFRESH_INTERVAL 20000 // minimum time to refresh servos in microseconds + +#define MAX_SERVOS 4 + +#define INVALID_SERVO 255 // flag indicating an invalid servo index + + +// Types + +typedef struct { + uint8_t nbr : 8 ; // a pin number from 0 to 254 (255 signals invalid pin) + uint8_t isActive : 1 ; // true if this channel is enabled, pin not pulsed if false +} ServoPin_t; + +typedef struct { + ServoPin_t Pin; + unsigned int pulse_width; // pulse width in microseconds +} ServoInfo_t; + +// Global variables + +extern uint8_t ServoCount; +extern ServoInfo_t servo_info[MAX_SERVOS]; diff --git a/Marlin/src/HAL/NATIVE_SIM/spi_pins.h b/Marlin/src/HAL/NATIVE_SIM/spi_pins.h new file mode 100644 index 0000000000..a5138e0ccb --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/spi_pins.h @@ -0,0 +1,55 @@ +/** + * 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 "../../core/macros.h" +#include "../../inc/MarlinConfigPre.h" + +#if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN) + #define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently + // needed due to the speed and mode required for communicating with each device being different. + // This requirement can be removed if the SPI access to these devices is updated to use + // spiBeginTransaction. +#endif + +// Onboard SD +//#define SD_SCK_PIN P0_07 +//#define SD_MISO_PIN P0_08 +//#define SD_MOSI_PIN P0_09 +//#define SD_SS_PIN P0_06 + +// External SD +#ifndef SD_SCK_PIN + #define SD_SCK_PIN 50 +#endif +#ifndef SD_MISO_PIN + #define SD_MISO_PIN 51 +#endif +#ifndef SD_MOSI_PIN + #define SD_MOSI_PIN 52 +#endif +#ifndef SD_SS_PIN + #define SD_SS_PIN 53 +#endif +#ifndef SDSS + #define SDSS SD_SS_PIN +#endif diff --git a/Marlin/src/HAL/NATIVE_SIM/tft/tft_spi.h b/Marlin/src/HAL/NATIVE_SIM/tft/tft_spi.h new file mode 100644 index 0000000000..b3e622f19a --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/tft/tft_spi.h @@ -0,0 +1,64 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "../../../inc/MarlinConfig.h" + +#ifndef LCD_READ_ID + #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341) +#endif +#ifndef LCD_READ_ID4 + #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341) +#endif + +#define DATASIZE_8BIT 8 +#define DATASIZE_16BIT 16 +#define TFT_IO_DRIVER TFT_SPI + +#define DMA_MINC_ENABLE 1 +#define DMA_MINC_DISABLE 0 + +class TFT_SPI { +private: + static uint32_t ReadID(uint16_t Reg); + static void Transmit(uint16_t Data); + static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); + +public: + // static SPIClass SPIx; + + static void Init(); + static uint32_t GetID(); + static bool isBusy(); + static void Abort(); + + static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT); + static void DataTransferEnd(); + static void DataTransferAbort(); + + static void WriteData(uint16_t Data); + static void WriteReg(uint16_t Reg); + + static void WriteSequence(uint16_t *Data, uint16_t Count); + // static void WriteMultiple(uint16_t Color, uint16_t Count); + static void WriteMultiple(uint16_t Color, uint32_t Count); +}; diff --git a/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h new file mode 100644 index 0000000000..9ef1816c7b --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h @@ -0,0 +1,80 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "../../../inc/MarlinConfig.h" + +#if ENABLED(TOUCH_BUTTONS_HW_SPI) + #include +#endif + +#ifndef TOUCH_MISO_PIN + #define TOUCH_MISO_PIN SD_MISO_PIN +#endif +#ifndef TOUCH_MOSI_PIN + #define TOUCH_MOSI_PIN SD_MOSI_PIN +#endif +#ifndef TOUCH_SCK_PIN + #define TOUCH_SCK_PIN SD_SCK_PIN +#endif +#ifndef TOUCH_CS_PIN + #define TOUCH_CS_PIN SD_SS_PIN +#endif +#ifndef TOUCH_INT_PIN + #define TOUCH_INT_PIN -1 +#endif + +#define XPT2046_DFR_MODE 0x00 +#define XPT2046_SER_MODE 0x04 +#define XPT2046_CONTROL 0x80 + +enum XPTCoordinate : uint8_t { + XPT2046_X = 0x10 | XPT2046_CONTROL | XPT2046_DFR_MODE, + XPT2046_Y = 0x50 | XPT2046_CONTROL | XPT2046_DFR_MODE, + XPT2046_Z1 = 0x30 | XPT2046_CONTROL | XPT2046_DFR_MODE, + XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE, +}; + +#if !defined(XPT2046_Z1_THRESHOLD) + #define XPT2046_Z1_THRESHOLD 10 +#endif + +class XPT2046 { +private: + static bool isBusy() { return false; } + + static uint16_t getRawData(const XPTCoordinate coordinate); + static bool isTouched(); + + static inline void DataTransferBegin(); + static inline void DataTransferEnd(); + #if ENABLED(TOUCH_BUTTONS_HW_SPI) + static uint16_t HardwareIO(uint16_t data); + #endif + static uint16_t SoftwareIO(uint16_t data); + static uint16_t IO(uint16_t data = 0); + +public: + #if ENABLED(TOUCH_BUTTONS_HW_SPI) + static SPIClass SPIx; + #endif + + static void Init(); + static bool getRawPoint(int16_t *x, int16_t *y); +}; diff --git a/Marlin/src/HAL/NATIVE_SIM/timers.h b/Marlin/src/HAL/NATIVE_SIM/timers.h new file mode 100644 index 0000000000..c61eb29e76 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/timers.h @@ -0,0 +1,91 @@ +/** + * Marlin 3D Printer Firmware + * + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com + * + * 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 + +/** + * HAL timers for Linux X86_64 + */ + +#include + +// ------------------------ +// Defines +// ------------------------ + +#define FORCE_INLINE __attribute__((always_inline)) inline + +typedef uint64_t hal_timer_t; +#define HAL_TIMER_TYPE_MAX 0xFFFFFFFFFFFFFFFF + +#define HAL_TIMER_RATE ((SystemCoreClock) / 4) // frequency of timers peripherals + +#ifndef STEP_TIMER_NUM + #define STEP_TIMER_NUM 0 // Timer Index for Stepper +#endif +#ifndef PULSE_TIMER_NUM + #define PULSE_TIMER_NUM STEP_TIMER_NUM +#endif +#ifndef TEMP_TIMER_NUM + #define TEMP_TIMER_NUM 1 // Timer Index for Temperature +#endif +#ifndef SYSTICK_TIMER_NUM + #define SYSTICK_TIMER_NUM 2 // Timer Index for Systick +#endif +#define SYSTICK_TIMER_FREQUENCY 1000 + +#define TEMP_TIMER_RATE 1000000 +#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency + +#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs +#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) + +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US + +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) + +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) + +#ifndef HAL_STEP_TIMER_ISR + #define HAL_STEP_TIMER_ISR() extern "C" void TIMER0_IRQHandler() +#endif +#ifndef HAL_TEMP_TIMER_ISR + #define HAL_TEMP_TIMER_ISR() extern "C" void TIMER1_IRQHandler() +#endif + +void HAL_timer_init(); +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); + +void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare); +hal_timer_t HAL_timer_get_compare(const uint8_t timer_num); +hal_timer_t HAL_timer_get_count(const uint8_t timer_num); + +void HAL_timer_enable_interrupt(const uint8_t timer_num); +void HAL_timer_disable_interrupt(const uint8_t timer_num); +bool HAL_timer_interrupt_enabled(const uint8_t timer_num); + +#define HAL_timer_isr_prologue(TIMER_NUM) +#define HAL_timer_isr_epilogue(TIMER_NUM) diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_I2C_routines.cpp b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_I2C_routines.cpp new file mode 100644 index 0000000000..745454394a --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_I2C_routines.cpp @@ -0,0 +1,52 @@ +/** + * 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 . + * + */ + +// adapted from I2C/master/master.c example +// https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html + +#ifdef __PLAT_NATIVE_SIM__ + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +uint8_t u8g_i2c_start(const uint8_t sla) { + return 1; +} + +void u8g_i2c_init(const uint8_t clock_option) { +} + +uint8_t u8g_i2c_send_byte(uint8_t data) { + return 1; +} + +void u8g_i2c_stop() { +} + +#ifdef __cplusplus + } +#endif + +#endif // __PLAT_NATIVE_SIM__ diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_I2C_routines.h b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_I2C_routines.h new file mode 100644 index 0000000000..6d5f91d3ba --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_I2C_routines.h @@ -0,0 +1,37 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { +#endif + +void u8g_i2c_init(const uint8_t clock_options); +//uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos); +uint8_t u8g_i2c_start(uint8_t sla); +uint8_t u8g_i2c_send_byte(uint8_t data); +void u8g_i2c_stop(); + +#ifdef __cplusplus + } +#endif + diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h new file mode 100644 index 0000000000..44ffbfeb90 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h @@ -0,0 +1,44 @@ +/** + * 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 + +void usleep(uint64_t microsec); +// The following are optional depending on the platform. + +// definitions of HAL specific com and device drivers. +uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + +// connect U8g com generic com names to the desired driver +#define U8G_COM_SW_SPI u8g_com_sw_spi_fn +#define U8G_COM_ST7920_SW_SPI u8g_com_ST7920_sw_spi_fn + +// let these default for now +#define U8G_COM_HW_SPI u8g_com_null_fn +#define U8G_COM_ST7920_HW_SPI u8g_com_null_fn +#define U8G_COM_SSD_I2C u8g_com_null_fn +#define U8G_COM_PARALLEL u8g_com_null_fn +#define U8G_COM_T6963 u8g_com_null_fn +#define U8G_COM_FAST_PARALLEL u8g_com_null_fn +#define U8G_COM_UC_I2C u8g_com_null_fn + + diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_delay.h b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_delay.h new file mode 100644 index 0000000000..297361cd44 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_delay.h @@ -0,0 +1,43 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * LCD delay routines - used by all the drivers. + * + * These are based on the LPC1768 routines. + * + * Couldn't just call exact copies because the overhead + * results in a one microsecond delay taking about 4µS. + */ + +#ifdef __cplusplus + extern "C" { +#endif + +void U8g_delay(int msec); +void u8g_MicroDelay(); +void u8g_10MicroDelay(); + +#ifdef __cplusplus + } +#endif diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.cpp b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.cpp new file mode 100644 index 0000000000..3b5acc1656 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.cpp @@ -0,0 +1,52 @@ +/** + * 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 . + * + */ + +/** + * Low level pin manipulation routines - used by all the drivers. + * + * These are based on the LPC1768 pinMode, digitalRead & digitalWrite routines. + * + * Couldn't just call exact copies because the overhead killed the LCD update speed + * With an intermediate level the softspi was running in the 10-20kHz range which + * resulted in using about about 25% of the CPU's time. + */ + +#ifdef __PLAT_NATIVE_SIM__ + +#include "../fastio.h" +#include "LCD_pin_routines.h" + +#ifdef __cplusplus + extern "C" { +#endif +void u8g_SetPinOutput(uint8_t internal_pin_number){SET_DIR_OUTPUT(internal_pin_number);} +void u8g_SetPinInput(uint8_t internal_pin_number){SET_DIR_INPUT(internal_pin_number);} +void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status){WRITE_PIN(pin, pin_status);} +uint8_t u8g_GetPinLevel(uint8_t pin){return READ_PIN(pin);} +void usleep(uint64_t microsec){ +assert(false); // why we here? +} +#ifdef __cplusplus + } +#endif + +#endif // __PLAT_NATIVE_SIM__ diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.h b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.h new file mode 100644 index 0000000000..c27c84e8c3 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.h @@ -0,0 +1,46 @@ +/** + * 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 + +/** + * Low level pin manipulation routines - used by all the drivers. + * + * These are based on the LPC1768 pinMode, digitalRead & digitalWrite routines. + * + * Couldn't just call exact copies because the overhead killed the LCD update speed + * With an intermediate level the softspi was running in the 10-20kHz range which + * resulted in using about about 25% of the CPU's time. + */ + + +#ifdef __cplusplus + extern "C" { +#endif + +void u8g_SetPinOutput(uint8_t internal_pin_number); +void u8g_SetPinInput(uint8_t internal_pin_number); +void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status); +uint8_t u8g_GetPinLevel(uint8_t pin); + +#ifdef __cplusplus + } +#endif diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp new file mode 100644 index 0000000000..e95c6ebfbd --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.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 . + * + */ + +/** + * Based on u8g_com_st7920_hw_spi.c + * + * Universal 8bit Graphics Library + * + * Copyright (c) 2011, olikraus@gmail.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * * 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. + * + * 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. + */ + +#ifdef __PLAT_NATIVE_SIM__ + +#include "../../../inc/MarlinConfig.h" + +#if ENABLED(U8GLIB_ST7920) + +#include +#include "../../shared/Delay.h" + +#undef SPI_SPEED +#define SPI_SPEED 6 +#define SPI_DELAY_CYCLES (1 + SPI_SPEED * 10) + +static pin_t SCK_pin_ST7920_HAL, MOSI_pin_ST7920_HAL_HAL; +static uint8_t SPI_speed = 0; + +static uint8_t swSpiTransfer(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin) { + for (uint8_t i = 0; i < 8; i++) { + WRITE_PIN(mosi_pin, !!(b & 0x80)); + DELAY_CYCLES(SPI_SPEED); + WRITE_PIN(sck_pin, HIGH); + DELAY_CYCLES(SPI_SPEED); + b <<= 1; + if (miso_pin >= 0 && READ_PIN(miso_pin)) b |= 1; + WRITE_PIN(sck_pin, LOW); + DELAY_CYCLES(SPI_SPEED); + } + return b; +} + +static uint8_t swSpiInit(const uint8_t spiRate, const pin_t sck_pin, const pin_t mosi_pin) { + WRITE_PIN(mosi_pin, HIGH); + WRITE_PIN(sck_pin, LOW); + return spiRate; +} + +static void u8g_com_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) { + static uint8_t rs_last_state = 255; + if (rs != rs_last_state) { + // Transfer Data (FA) or Command (F8) + swSpiTransfer(rs ? 0x0FA : 0x0F8, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL); + rs_last_state = rs; + DELAY_US(40); // Give the controller time to process the data: 20 is bad, 30 is OK, 40 is safe + } + swSpiTransfer(val & 0x0F0, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL); + swSpiTransfer(val << 4, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL); +} +#ifdef __cplusplus + extern "C" { +#endif + +uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { + switch (msg) { + case U8G_COM_MSG_INIT: + SCK_pin_ST7920_HAL = u8g->pin_list[U8G_PI_SCK]; + MOSI_pin_ST7920_HAL_HAL = u8g->pin_list[U8G_PI_MOSI]; + + u8g_SetPIOutput(u8g, U8G_PI_CS); + u8g_SetPIOutput(u8g, U8G_PI_SCK); + u8g_SetPIOutput(u8g, U8G_PI_MOSI); + u8g_Delay(5); + + SPI_speed = swSpiInit(SPI_SPEED, SCK_pin_ST7920_HAL, MOSI_pin_ST7920_HAL_HAL); + + u8g_SetPILevel(u8g, U8G_PI_CS, 0); + u8g_SetPILevel(u8g, U8G_PI_SCK, 0); + u8g_SetPILevel(u8g, U8G_PI_MOSI, 0); + + u8g->pin_list[U8G_PI_A0_STATE] = 0; /* initial RS state: command mode */ + break; + + case U8G_COM_MSG_STOP: + break; + + case U8G_COM_MSG_RESET: + if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); + break; + + case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */ + u8g->pin_list[U8G_PI_A0_STATE] = arg_val; + break; + + case U8G_COM_MSG_CHIP_SELECT: + if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_CS]) u8g_SetPILevel(u8g, U8G_PI_CS, arg_val); //note: the st7920 has an active high chip select + break; + + case U8G_COM_MSG_WRITE_BYTE: + u8g_com_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val); + break; + + case U8G_COM_MSG_WRITE_SEQ: { + uint8_t *ptr = (uint8_t*) arg_ptr; + while (arg_val > 0) { + u8g_com_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++); + arg_val--; + } + } + break; + + case U8G_COM_MSG_WRITE_SEQ_P: { + uint8_t *ptr = (uint8_t*) arg_ptr; + while (arg_val > 0) { + u8g_com_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++); + arg_val--; + } + } + break; + } + return 1; +} +#ifdef __cplusplus + } +#endif + +#endif // U8GLIB_ST7920 +#endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp new file mode 100644 index 0000000000..8e0ac9c7df --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp @@ -0,0 +1,215 @@ +/** + * 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 . + * + */ + +/** + * Based on u8g_com_std_sw_spi.c + * + * Universal 8bit Graphics Library + * + * Copyright (c) 2015, olikraus@gmail.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * * 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. + * + * 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. + */ + +#ifdef __PLAT_NATIVE_SIM__ + +#include "../../../inc/MarlinConfig.h" + +#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920) + +#undef SPI_SPEED +#define SPI_SPEED 2 // About 2 MHz + +#include +#include + +#ifdef __cplusplus + extern "C" { +#endif + +uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) { + LOOP_L_N(i, 8) { + if (spi_speed == 0) { + WRITE_PIN(mosi_pin, !!(b & 0x80)); + WRITE_PIN(sck_pin, HIGH); + b <<= 1; + if (miso_pin >= 0 && READ_PIN(miso_pin)) b |= 1; + WRITE_PIN(sck_pin, LOW); + } + else { + const uint8_t state = (b & 0x80) ? HIGH : LOW; + LOOP_L_N(j, spi_speed) + WRITE_PIN(mosi_pin, state); + + LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1)) + WRITE_PIN(sck_pin, HIGH); + + b <<= 1; + if (miso_pin >= 0 && READ_PIN(miso_pin)) b |= 1; + + LOOP_L_N(j, spi_speed) + WRITE_PIN(sck_pin, LOW); + } + } + + return b; +} + +uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) { + + LOOP_L_N(i, 8) { + const uint8_t state = (b & 0x80) ? HIGH : LOW; + if (spi_speed == 0) { + WRITE_PIN(sck_pin, LOW); + WRITE_PIN(mosi_pin, state); + WRITE_PIN(mosi_pin, state); // need some setup time + WRITE_PIN(sck_pin, HIGH); + } + else { + LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1)) + WRITE_PIN(sck_pin, LOW); + + LOOP_L_N(j, spi_speed) + WRITE_PIN(mosi_pin, state); + + LOOP_L_N(j, spi_speed) + WRITE_PIN(sck_pin, HIGH); + } + b <<= 1; + if (miso_pin >= 0 && READ_PIN(miso_pin)) b |= 1; + } + + return b; +} + +static uint8_t SPI_speed = 0; + +static uint8_t swSpiInit(const uint8_t spi_speed, const uint8_t clk_pin, const uint8_t mosi_pin) { + return spi_speed; +} + +static void u8g_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) { + #if EITHER(FYSETC_MINI_12864, MKS_MINI_12864) + swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin); + #else + swSpiTransfer_mode_0(val, SPI_speed, clockPin, -1, dataPin); + #endif +} + +uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { + switch (msg) { + case U8G_COM_MSG_INIT: + u8g_SetPIOutput(u8g, U8G_PI_SCK); + u8g_SetPIOutput(u8g, U8G_PI_MOSI); + u8g_SetPIOutput(u8g, U8G_PI_CS); + u8g_SetPIOutput(u8g, U8G_PI_A0); + if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPIOutput(u8g, U8G_PI_RESET); + SPI_speed = swSpiInit(SPI_SPEED, u8g->pin_list[U8G_PI_SCK], u8g->pin_list[U8G_PI_MOSI]); + u8g_SetPILevel(u8g, U8G_PI_SCK, 0); + u8g_SetPILevel(u8g, U8G_PI_MOSI, 0); + break; + + case U8G_COM_MSG_STOP: + break; + + case U8G_COM_MSG_RESET: + if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); + break; + + case U8G_COM_MSG_CHIP_SELECT: + #if EITHER(FYSETC_MINI_12864, MKS_MINI_12864) // LCD SPI is running mode 3 while SD card is running mode 0 + if (arg_val) { // SCK idle state needs to be set to the proper idle state before + // the next chip select goes active + u8g_SetPILevel(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active + u8g_SetPILevel(u8g, U8G_PI_CS, LOW); + } + else { + u8g_SetPILevel(u8g, U8G_PI_CS, HIGH); + u8g_SetPILevel(u8g, U8G_PI_SCK, 0); // Set SCK to mode 0 idle state after CS goes inactive + } + #else + u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val); + #endif + break; + + case U8G_COM_MSG_WRITE_BYTE: + u8g_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val); + break; + + case U8G_COM_MSG_WRITE_SEQ: { + uint8_t *ptr = (uint8_t *)arg_ptr; + while (arg_val > 0) { + u8g_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++); + arg_val--; + } + } + break; + + case U8G_COM_MSG_WRITE_SEQ_P: { + uint8_t *ptr = (uint8_t *)arg_ptr; + while (arg_val > 0) { + u8g_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr)); + ptr++; + arg_val--; + } + } + break; + + case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */ + u8g_SetPILevel(u8g, U8G_PI_A0, arg_val); + break; + } + return 1; +} + +#ifdef __cplusplus + } +#endif + +#elif !ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI, HAS_MARLINUI_HD44780) && HAS_MARLINUI_U8GLIB + #include + uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {return 0;} +#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920 +#endif // __PLAT_NATIVE_SIM__ diff --git a/Marlin/src/HAL/NATIVE_SIM/watchdog.h b/Marlin/src/HAL/NATIVE_SIM/watchdog.h new file mode 100644 index 0000000000..4e404c3887 --- /dev/null +++ b/Marlin/src/HAL/NATIVE_SIM/watchdog.h @@ -0,0 +1,27 @@ +/** + * 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 + +#define WDT_TIMEOUT 4000000 // 4 second timeout + +void watchdog_init(); +void HAL_watchdog_refresh(); diff --git a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h index 2a4bde98e6..38c6dd9e08 100644 --- a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h +++ b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h @@ -31,7 +31,8 @@ #error "No custom SD drive cable defined for this board." #endif -#if defined(MAX6675_SCK_PIN) && defined(MAX6675_DO_PIN) && (MAX6675_SCK_PIN == SCK1 || MAX6675_DO_PIN == MISO1) +#if (defined(TEMP_0_SCK_PIN) && defined(TEMP_0_MISO_PIN) && (TEMP_0_SCK_PIN == SCK1 || TEMP_0_MISO_PIN == MISO1)) || \ + (defined(TEMP_1_SCK_PIN) && defined(TEMP_1_MISO_PIN) && (TEMP_1_SCK_PIN == SCK1 || TEMP_1_MISO_PIN == MISO1)) #error "OnBoard SPI BUS can't be shared with other devices." #endif diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index e09b52f7db..d8035a979d 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "HAL.h" #include "usb_serial.h" @@ -91,15 +91,13 @@ void HAL_init() { USB_Hook_init(); #endif - TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler + TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler - #if HAS_SD_HOST_DRIVE - MSC_SD_init(); // Enable USB SD card access - #endif + TERN_(HAS_SD_HOST_DRIVE, MSC_SD_init()); // Enable USB SD card access #if PIN_EXISTS(USB_CONNECT) - OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection - delay(1000); // Give OS time to notice + OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection + delay(1000); // Give OS time to notice WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING); #endif } @@ -167,4 +165,4 @@ void HAL_SYSTICK_Callback() { if (systick_user_callback) systick_user_callback(); } -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 2441c46eab..02bee57ba3 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -195,6 +195,7 @@ uint16_t HAL_adc_get_result(); #ifdef STM32F1xx #define JTAG_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_JTAGDISABLE) #define JTAGSWD_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_DISABLE) + #define JTAGSWD_RESET() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_RESET); // Reset: FULL SWD+JTAG #endif #define PLATFORM_M997_SUPPORT diff --git a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp index 7268eed591..44fb93337d 100644 --- a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index 80347e115d..ba8e6bef19 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" @@ -163,11 +163,9 @@ static SPISettings spiConfig; } spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0); - #if ENABLED(CUSTOM_SPI_PINS) - SPI.setMISO(SD_MISO_PIN); - SPI.setMOSI(SD_MOSI_PIN); - SPI.setSCLK(SD_SCK_PIN); - #endif + SPI.setMISO(SD_MISO_PIN); + SPI.setMOSI(SD_MOSI_PIN); + SPI.setSCLK(SD_SCK_PIN); SPI.begin(); } @@ -226,4 +224,4 @@ static SPISettings spiConfig; #endif // SOFTWARE_SPI -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/MarlinSPI.cpp b/Marlin/src/HAL/STM32/MarlinSPI.cpp index 896ec1433f..41081dfb80 100644 --- a/Marlin/src/HAL/STM32/MarlinSPI.cpp +++ b/Marlin/src/HAL/STM32/MarlinSPI.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(STM32H7xx) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) && !defined(STM32H7xx) #include "MarlinSPI.h" @@ -165,4 +165,4 @@ uint8_t MarlinSPI::dmaSend(const void * transmitBuf, uint16_t length, bool minc) return 1; } -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 && !STM32H7xx diff --git a/Marlin/src/HAL/STM32/MarlinSerial.cpp b/Marlin/src/HAL/STM32/MarlinSerial.cpp index 265e8b5ab6..d990d2f428 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32/MarlinSerial.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" #include "MarlinSerial.h" @@ -101,4 +101,4 @@ void MarlinSerial::_rx_complete_irq(serial_t *obj) { } } -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp index 3353f8c36b..55e807f94e 100644 --- a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp +++ b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" @@ -28,319 +28,296 @@ #include #include -#if NONE(STM32F103xE, STM32F103xG, STM32F4xx, STM32F7xx) - #error "ERROR - Only STM32F103xE, STM32F103xG, STM32F4xx or STM32F7xx CPUs supported" +// use local drivers +#if defined(STM32F103xE) || defined(STM32F103xG) + #include + #include +#elif defined(STM32F4xx) + #include + #include + #include + #include +#elif defined(STM32F7xx) + #include + #include + #include + #include +#else + #error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, or STM32F7xx." #endif -#if HAS_SD_HOST_DRIVE +// Fixed +#define SDIO_D0_PIN PC8 +#define SDIO_D1_PIN PC9 +#define SDIO_D2_PIN PC10 +#define SDIO_D3_PIN PC11 +#define SDIO_CK_PIN PC12 +#define SDIO_CMD_PIN PD2 - // use USB drivers +SD_HandleTypeDef hsd; // create SDIO structure +// F4 supports one DMA for RX and another for TX, but Marlin will never +// do read and write at same time, so we use the same DMA for both. +DMA_HandleTypeDef hdma_sdio; - extern "C" { - int8_t SD_MSC_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); - int8_t SD_MSC_Write(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); - extern SD_HandleTypeDef hsd; - } +/* + SDIO_INIT_CLK_DIV is 118 + SDIO clock frequency is 48MHz / (TRANSFER_CLOCK_DIV + 2) + SDIO init clock frequency should not exceed 400KHz = 48MHz / (118 + 2) - bool SDIO_Init() { - return hsd.State == HAL_SD_STATE_READY; // return pass/fail status - } + Default TRANSFER_CLOCK_DIV is 2 (118 / 40) + Default SDIO clock frequency is 48MHz / (2 + 2) = 12 MHz + This might be too fast for stable SDIO operations - bool SDIO_ReadBlock(uint32_t block, uint8_t *src) { - int8_t status = SD_MSC_Read(0, (uint8_t*)src, block, 1); // read one 512 byte block - return (bool) status; - } + MKS Robin board seems to have stable SDIO with BusWide 1bit and ClockDiv 8 i.e. 4.8MHz SDIO clock frequency + Additional testing is required as there are clearly some 4bit initialization problems +*/ - bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { - int8_t status = SD_MSC_Write(0, (uint8_t*)src, block, 1); // write one 512 byte block - return (bool) status; - } +#ifndef USBD_OK + #define USBD_OK 0 +#endif -#else // !USBD_USE_CDC_COMPOSITE +// Target Clock, configurable. Default is 18MHz, from STM32F1 +#ifndef SDIO_CLOCK + #define SDIO_CLOCK 18000000 // 18 MHz +#endif - // use local drivers - #if defined(STM32F103xE) || defined(STM32F103xG) - #include - #include - #elif defined(STM32F4xx) - #include - #include - #include - #include - #elif defined(STM32F7xx) - #include - #include - #include - #include - #else - #error "ERROR - Only STM32F103xE, STM32F103xG, STM32F4xx or STM32F7xx CPUs supported" +// SDIO retries, configurable. Default is 3, from STM32F1 +#ifndef SDIO_READ_RETRIES + #define SDIO_READ_RETRIES 3 +#endif + +// SDIO Max Clock (naming from STM Manual, don't change) +#define SDIOCLK 48000000 + +static uint32_t clock_to_divider(uint32_t clk) { + // limit the SDIO master clock to 8/3 of PCLK2. See STM32 Manuals + // Also limited to no more than 48Mhz (SDIOCLK). + const uint32_t pclk2 = HAL_RCC_GetPCLK2Freq(); + clk = min(clk, (uint32_t)(pclk2 * 8 / 3)); + clk = min(clk, (uint32_t)SDIOCLK); + // Round up divider, so we don't run the card over the speed supported, + // and subtract by 2, because STM32 will add 2, as written in the manual: + // SDIO_CK frequency = SDIOCLK / [CLKDIV + 2] + return pclk2 / clk + (pclk2 % clk != 0) - 2; +} + +void go_to_transfer_speed() { + /* Default SDIO peripheral configuration for SD card initialization */ + hsd.Init.ClockEdge = hsd.Init.ClockEdge; + hsd.Init.ClockBypass = hsd.Init.ClockBypass; + hsd.Init.ClockPowerSave = hsd.Init.ClockPowerSave; + hsd.Init.BusWide = hsd.Init.BusWide; + hsd.Init.HardwareFlowControl = hsd.Init.HardwareFlowControl; + hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK); + + /* Initialize SDIO peripheral interface with default configuration */ + SDIO_Init(hsd.Instance, hsd.Init); +} + +void SD_LowLevel_Init(void) { + uint32_t tempreg; + + __HAL_RCC_GPIOC_CLK_ENABLE(); //enable GPIO clocks + __HAL_RCC_GPIOD_CLK_ENABLE(); //enable GPIO clocks + + GPIO_InitTypeDef GPIO_InitStruct; + + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = 1; //GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + + #if DISABLED(STM32F1xx) + GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; #endif - // Fixed - #define SDIO_D0_PIN PC8 - #define SDIO_D1_PIN PC9 - #define SDIO_D2_PIN PC10 - #define SDIO_D3_PIN PC11 - #define SDIO_CK_PIN PC12 - #define SDIO_CMD_PIN PD2 + GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_12; // D0 & SCK + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - SD_HandleTypeDef hsd; // create SDIO structure - // F4 supports one DMA for RX and another for TX, but Marlin will never - // do read and write at same time, so we use the same DMA for both. - DMA_HandleTypeDef hdma_sdio; - - /* - SDIO_INIT_CLK_DIV is 118 - SDIO clock frequency is 48MHz / (TRANSFER_CLOCK_DIV + 2) - SDIO init clock frequency should not exceed 400KHz = 48MHz / (118 + 2) - - Default TRANSFER_CLOCK_DIV is 2 (118 / 40) - Default SDIO clock frequency is 48MHz / (2 + 2) = 12 MHz - This might be too fast for stable SDIO operations - - MKS Robin board seems to have stable SDIO with BusWide 1bit and ClockDiv 8 i.e. 4.8MHz SDIO clock frequency - Additional testing is required as there are clearly some 4bit initialization problems - */ - - #ifndef USBD_OK - #define USBD_OK 0 - #endif - - // Target Clock, configurable. Default is 18MHz, from STM32F1 - #ifndef SDIO_CLOCK - #define SDIO_CLOCK 18000000 // 18 MHz - #endif - - // SDIO retries, configurable. Default is 3, from STM32F1 - #ifndef SDIO_READ_RETRIES - #define SDIO_READ_RETRIES 3 - #endif - - // SDIO Max Clock (naming from STM Manual, don't change) - #define SDIOCLK 48000000 - - static uint32_t clock_to_divider(uint32_t clk) { - // limit the SDIO master clock to 8/3 of PCLK2. See STM32 Manuals - // Also limited to no more than 48Mhz (SDIOCLK). - const uint32_t pclk2 = HAL_RCC_GetPCLK2Freq(); - clk = min(clk, (uint32_t)(pclk2 * 8 / 3)); - clk = min(clk, (uint32_t)SDIOCLK); - // Round up divider, so we don't run the card over the speed supported, - // and subtract by 2, because STM32 will add 2, as written in the manual: - // SDIO_CK frequency = SDIOCLK / [CLKDIV + 2] - return pclk2 / clk + (pclk2 % clk != 0) - 2; - } - - void go_to_transfer_speed() { - /* Default SDIO peripheral configuration for SD card initialization */ - hsd.Init.ClockEdge = hsd.Init.ClockEdge; - hsd.Init.ClockBypass = hsd.Init.ClockBypass; - hsd.Init.ClockPowerSave = hsd.Init.ClockPowerSave; - hsd.Init.BusWide = hsd.Init.BusWide; - hsd.Init.HardwareFlowControl = hsd.Init.HardwareFlowControl; - hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK); - - /* Initialize SDIO peripheral interface with default configuration */ - SDIO_Init(hsd.Instance, hsd.Init); - } - - void SD_LowLevel_Init(void) { - uint32_t tempreg; - - __HAL_RCC_GPIOC_CLK_ENABLE(); //enable GPIO clocks - __HAL_RCC_GPIOD_CLK_ENABLE(); //enable GPIO clocks - - GPIO_InitTypeDef GPIO_InitStruct; - - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = 1; //GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - - #if DISABLED(STM32F1xx) - GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; - #endif - - GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_12; // D0 & SCK + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus + GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; // D1-D3 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + #endif - #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus - GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; // D1-D3 - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - #endif + // Configure PD.02 CMD line + GPIO_InitStruct.Pin = GPIO_PIN_2; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - // Configure PD.02 CMD line - GPIO_InitStruct.Pin = GPIO_PIN_2; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + // Setup DMA + #if defined(STM32F1xx) + hdma_sdio.Init.Mode = DMA_NORMAL; + hdma_sdio.Instance = DMA2_Channel4; + HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn); + #elif defined(STM32F4xx) + hdma_sdio.Init.Mode = DMA_PFCTRL; + hdma_sdio.Instance = DMA2_Stream3; + hdma_sdio.Init.Channel = DMA_CHANNEL_4; + hdma_sdio.Init.FIFOMode = DMA_FIFOMODE_ENABLE; + hdma_sdio.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; + hdma_sdio.Init.MemBurst = DMA_MBURST_INC4; + hdma_sdio.Init.PeriphBurst = DMA_PBURST_INC4; + HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); + #endif + HAL_NVIC_EnableIRQ(SDIO_IRQn); + hdma_sdio.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sdio.Init.MemInc = DMA_MINC_ENABLE; + hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sdio.Init.Priority = DMA_PRIORITY_LOW; + __HAL_LINKDMA(&hsd, hdmarx, hdma_sdio); + __HAL_LINKDMA(&hsd, hdmatx, hdma_sdio); - // Setup DMA - #if defined(STM32F1xx) - hdma_sdio.Init.Mode = DMA_NORMAL; - hdma_sdio.Instance = DMA2_Channel4; - HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn); - #elif defined(STM32F4xx) - hdma_sdio.Init.Mode = DMA_PFCTRL; - hdma_sdio.Instance = DMA2_Stream3; - hdma_sdio.Init.Channel = DMA_CHANNEL_4; - hdma_sdio.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_sdio.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_sdio.Init.MemBurst = DMA_MBURST_INC4; - hdma_sdio.Init.PeriphBurst = DMA_PBURST_INC4; - HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); - #endif - HAL_NVIC_EnableIRQ(SDIO_IRQn); - hdma_sdio.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sdio.Init.MemInc = DMA_MINC_ENABLE; - hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_sdio.Init.Priority = DMA_PRIORITY_LOW; - __HAL_LINKDMA(&hsd, hdmarx, hdma_sdio); - __HAL_LINKDMA(&hsd, hdmatx, hdma_sdio); + #if defined(STM32F1xx) + __HAL_RCC_SDIO_CLK_ENABLE(); + __HAL_RCC_DMA2_CLK_ENABLE(); + #else + __HAL_RCC_SDIO_FORCE_RESET(); + delay(2); + __HAL_RCC_SDIO_RELEASE_RESET(); + delay(2); + __HAL_RCC_SDIO_CLK_ENABLE(); - #if defined(STM32F1xx) - __HAL_RCC_SDIO_CLK_ENABLE(); - __HAL_RCC_DMA2_CLK_ENABLE(); - #else - __HAL_RCC_SDIO_FORCE_RESET(); - delay(2); - __HAL_RCC_SDIO_RELEASE_RESET(); - delay(2); - __HAL_RCC_SDIO_CLK_ENABLE(); + __HAL_RCC_DMA2_FORCE_RESET(); + delay(2); + __HAL_RCC_DMA2_RELEASE_RESET(); + delay(2); + __HAL_RCC_DMA2_CLK_ENABLE(); + #endif - __HAL_RCC_DMA2_FORCE_RESET(); - delay(2); - __HAL_RCC_DMA2_RELEASE_RESET(); - delay(2); - __HAL_RCC_DMA2_CLK_ENABLE(); - #endif + //Initialize the SDIO (with initial <400Khz Clock) + tempreg = 0; //Reset value + tempreg |= SDIO_CLKCR_CLKEN; // Clock enabled + tempreg |= SDIO_INIT_CLK_DIV; // Clock Divider. Clock = 48000 / (118 + 2) = 400Khz + // Keep the rest at 0 => HW_Flow Disabled, Rising Clock Edge, Disable CLK ByPass, Bus Width = 0, Power save Disable + SDIO->CLKCR = tempreg; - //Initialize the SDIO (with initial <400Khz Clock) - tempreg = 0; //Reset value - tempreg |= SDIO_CLKCR_CLKEN; // Clock enabled - tempreg |= SDIO_INIT_CLK_DIV; // Clock Divider. Clock = 48000 / (118 + 2) = 400Khz - // Keep the rest at 0 => HW_Flow Disabled, Rising Clock Edge, Disable CLK ByPass, Bus Width = 0, Power save Disable - SDIO->CLKCR = tempreg; + // Power up the SDIO + SDIO_PowerState_ON(SDIO); + hsd.Instance = SDIO; +} - // Power up the SDIO - SDIO_PowerState_ON(SDIO); - hsd.Instance = SDIO; +void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { // application specific init + UNUSED(hsd); // Prevent unused argument(s) compilation warning + __HAL_RCC_SDIO_CLK_ENABLE(); // turn on SDIO clock +} + +bool SDIO_Init() { + uint8_t retryCnt = SDIO_READ_RETRIES; + + bool status; + hsd.Instance = SDIO; + hsd.State = HAL_SD_STATE_RESET; + + SD_LowLevel_Init(); + + uint8_t retry_Cnt = retryCnt; + for (;;) { + TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); + status = (bool) HAL_SD_Init(&hsd); + if (!status) break; + if (!--retry_Cnt) return false; // return failing status if retries are exhausted } - void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { // application specific init - UNUSED(hsd); // Prevent unused argument(s) compilation warning - __HAL_RCC_SDIO_CLK_ENABLE(); // turn on SDIO clock - } + go_to_transfer_speed(); - bool SDIO_Init() { - uint8_t retryCnt = SDIO_READ_RETRIES; - - bool status; - hsd.Instance = SDIO; - hsd.State = HAL_SD_STATE_RESET; - - SD_LowLevel_Init(); - - uint8_t retry_Cnt = retryCnt; + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined + retry_Cnt = retryCnt; for (;;) { TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); - status = (bool) HAL_SD_Init(&hsd); - if (!status) break; - if (!--retry_Cnt) return false; // return failing status if retries are exhausted + if (!HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B)) break; // some cards are only 1 bit wide so a pass here is not required + if (!--retry_Cnt) break; } - - go_to_transfer_speed(); - - #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined + if (!retry_Cnt) { // wide bus failed, go back to one bit wide mode + hsd.State = (HAL_SD_StateTypeDef) 0; // HAL_SD_STATE_RESET + SD_LowLevel_Init(); retry_Cnt = retryCnt; for (;;) { TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); - if (!HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B)) break; // some cards are only 1 bit wide so a pass here is not required - if (!--retry_Cnt) break; + status = (bool) HAL_SD_Init(&hsd); + if (!status) break; + if (!--retry_Cnt) return false; // return failing status if retries are exhausted } - if (!retry_Cnt) { // wide bus failed, go back to one bit wide mode - hsd.State = (HAL_SD_StateTypeDef) 0; // HAL_SD_STATE_RESET - SD_LowLevel_Init(); - retry_Cnt = retryCnt; - for (;;) { - TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); - status = (bool) HAL_SD_Init(&hsd); - if (!status) break; - if (!--retry_Cnt) return false; // return failing status if retries are exhausted - } - go_to_transfer_speed(); - } - #endif + go_to_transfer_speed(); + } + #endif - return true; + return true; +} + +static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) { + if (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false; + + TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); + + HAL_StatusTypeDef ret; + if (src) { + hdma_sdio.Init.Direction = DMA_MEMORY_TO_PERIPH; + HAL_DMA_Init(&hdma_sdio); + ret = HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)src, block, 1); + } + else { + hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY; + HAL_DMA_Init(&hdma_sdio); + ret = HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)dst, block, 1); } - static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) { - if (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false; + if (ret != HAL_OK) { + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); + return false; + } - TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); - - HAL_StatusTypeDef ret; - if (src) { - hdma_sdio.Init.Direction = DMA_MEMORY_TO_PERIPH; - HAL_DMA_Init(&hdma_sdio); - ret = HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)src, block, 1); - } - else { - hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY; - HAL_DMA_Init(&hdma_sdio); - ret = HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)dst, block, 1); - } - - if (ret != HAL_OK) { + millis_t timeout = millis() + 500; + // Wait the transfer + while (hsd.State != HAL_SD_STATE_READY) { + if (ELAPSED(millis(), timeout)) { HAL_DMA_Abort_IT(&hdma_sdio); HAL_DMA_DeInit(&hdma_sdio); return false; } - - millis_t timeout = millis() + 500; - // Wait the transfer - while (hsd.State != HAL_SD_STATE_READY) { - if (ELAPSED(millis(), timeout)) { - HAL_DMA_Abort_IT(&hdma_sdio); - HAL_DMA_DeInit(&hdma_sdio); - return false; - } - } - - while (__HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TC_FLAG_INDEX(&hdma_sdio)) != 0 - || __HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TE_FLAG_INDEX(&hdma_sdio)) != 0) { /* nada */ } - - HAL_DMA_Abort_IT(&hdma_sdio); - HAL_DMA_DeInit(&hdma_sdio); - - timeout = millis() + 500; - while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) if (ELAPSED(millis(), timeout)) return false; - - return true; } - bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { - uint8_t retries = SDIO_READ_RETRIES; - while (retries--) if (SDIO_ReadWriteBlock_DMA(block, NULL, dst)) return true; - return false; - } + while (__HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TC_FLAG_INDEX(&hdma_sdio)) != 0 + || __HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TE_FLAG_INDEX(&hdma_sdio)) != 0) { /* nada */ } - bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { - uint8_t retries = SDIO_READ_RETRIES; - while (retries--) if (SDIO_ReadWriteBlock_DMA(block, src, NULL)) return true; - return false; - } + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); - #if defined(STM32F1xx) - #define DMA_IRQ_HANDLER DMA2_Channel4_5_IRQHandler - #elif defined(STM32F4xx) - #define DMA_IRQ_HANDLER DMA2_Stream3_IRQHandler - #else - #error "Unknown STM32 architecture." - #endif + timeout = millis() + 500; + while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) if (ELAPSED(millis(), timeout)) return false; - extern "C" void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } - extern "C" void DMA_IRQ_HANDLER(void) { HAL_DMA_IRQHandler(&hdma_sdio); } + return true; +} + +bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { + uint8_t retries = SDIO_READ_RETRIES; + while (retries--) if (SDIO_ReadWriteBlock_DMA(block, nullptr, dst)) return true; + return false; +} + +bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { + uint8_t retries = SDIO_READ_RETRIES; + while (retries--) if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true; + return false; +} + +bool SDIO_IsReady() { + return hsd.State == HAL_SD_STATE_READY; +} + +uint32_t SDIO_GetCardSize() { + return (uint32_t)(hsd.SdCard.BlockNbr) * (hsd.SdCard.BlockSize); +} + +#if defined(STM32F1xx) + #define DMA_IRQ_HANDLER DMA2_Channel4_5_IRQHandler +#elif defined(STM32F4xx) + #define DMA_IRQ_HANDLER DMA2_Stream3_IRQHandler +#else + #error "Unknown STM32 architecture." +#endif + +extern "C" void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } +extern "C" void DMA_IRQ_HANDLER(void) { HAL_DMA_IRQHandler(&hdma_sdio); } -#endif // !USBD_USE_CDC_COMPOSITE #endif // SDIO_SUPPORT -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/Servo.cpp b/Marlin/src/HAL/STM32/Servo.cpp index 1cf117a056..c0a64c5ea9 100644 --- a/Marlin/src/HAL/STM32/Servo.cpp +++ b/Marlin/src/HAL/STM32/Servo.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" @@ -107,4 +107,4 @@ void libServo::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriori } #endif // HAS_SERVOS -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 5862090f1b..05e0d4c420 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" @@ -28,6 +28,10 @@ #include "../shared/eeprom_api.h" +// Better: "utility/stm32_eeprom.h", but only after updating stm32duino to 2.0.0 +// Use EEPROM.h for compatibility, for now. +#include + /** * The STM32 HAL supports chips that deal with "pages" and some with "sectors" and some that * even have multiple "banks" of flash. @@ -266,4 +270,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t } #endif // FLASH_EEPROM_EMULATION -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp index f811468fb4..9cab90f109 100644 --- a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) /** * Implementation of EEPROM settings in SD Card @@ -88,4 +88,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uin } #endif // SDCARD_EEPROM_EMULATION -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/eeprom_sram.cpp b/Marlin/src/HAL/STM32/eeprom_sram.cpp index 135bcabde9..c391785234 100644 --- a/Marlin/src/HAL/STM32/eeprom_sram.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sram.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" @@ -65,4 +65,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t } #endif // SRAM_EEPROM_EMULATION -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/eeprom_wired.cpp b/Marlin/src/HAL/STM32/eeprom_wired.cpp index 6aa2f1d360..3346abbe4a 100644 --- a/Marlin/src/HAL/STM32/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32/eeprom_wired.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" @@ -75,4 +75,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t } #endif // USE_WIRED_EEPROM -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/fast_pwm.cpp b/Marlin/src/HAL/STM32/fast_pwm.cpp index 42eecb5e1a..eaffb8cfa4 100644 --- a/Marlin/src/HAL/STM32/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32/fast_pwm.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfigPre.h" @@ -56,4 +56,4 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255 } #endif // NEEDS_HARDWARE_PWM -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/fastio.cpp b/Marlin/src/HAL/STM32/fastio.cpp index 0d55579d88..5056e99d35 100644 --- a/Marlin/src/HAL/STM32/fastio.cpp +++ b/Marlin/src/HAL/STM32/fastio.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" @@ -31,4 +31,4 @@ void FastIO_init() { FastIOPortMap[STM_PORT(digitalPin[i])] = get_GPIO_Port(STM_PORT(digitalPin[i])); } -#endif +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/inc/Conditionals_adv.h b/Marlin/src/HAL/STM32/inc/Conditionals_adv.h index d71a5c61b9..451c94f25d 100644 --- a/Marlin/src/HAL/STM32/inc/Conditionals_adv.h +++ b/Marlin/src/HAL/STM32/inc/Conditionals_adv.h @@ -30,3 +30,6 @@ #undef F_CPU #define F_CPU BOARD_F_CPU #endif + +// The Sensitive Pins array is not optimizable +#define RUNTIME_ONLY_ANALOG_TO_DIGITAL diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/msc_sd.cpp index cbfb837875..70a719d665 100644 --- a/Marlin/src/HAL/STM32/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/msc_sd.cpp @@ -13,29 +13,32 @@ * along with this program. If not, see . * */ +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) + #include "../../inc/MarlinConfigPre.h" -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && HAS_SD_HOST_DRIVE +#if HAS_SD_HOST_DRIVE -#include "msc_sd.h" #include "../shared/Marduino.h" +#include "msc_sd.h" #include "usbd_core.h" + +#include "../../sd/cardreader.h" + #include #include #define BLOCK_SIZE 512 #define PRODUCT_ID 0x29 -#include "../../sd/cardreader.h" - class Sd2CardUSBMscHandler : public USBMscHandler { public: DiskIODriver* diskIODriver() { #if ENABLED(MULTI_VOLUME) #if SHARED_VOLUME_IS(SD_ONBOARD) - return &card.media_sd_spi; + return &card.media_driver_sdcard; #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) - return &card.media_usbFlashDrive; + return &card.media_driver_usbFlash; #endif #else return card.diskIODriver(); @@ -121,4 +124,5 @@ void MSC_SD_init() { USBDevice.begin(); } -#endif // __STM32F1__ && HAS_SD_HOST_DRIVE +#endif // HAS_SD_HOST_DRIVE +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/tft/gt911.cpp b/Marlin/src/HAL/STM32/tft/gt911.cpp index f99fa46e19..8c59a60f92 100644 --- a/Marlin/src/HAL/STM32/tft/gt911.cpp +++ b/Marlin/src/HAL/STM32/tft/gt911.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../../inc/MarlinConfig.h" @@ -199,4 +199,4 @@ bool GT911::getPoint(int16_t *x, int16_t *y) { } #endif // TFT_TOUCH_DEVICE_GT911 -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp index 87ca2dbbe1..f349eacac3 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../../inc/MarlinConfig.h" @@ -178,4 +178,4 @@ void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou } #endif // HAS_FSMC_TFT -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp index f2509ce5e4..53e5bd83e0 100644 --- a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../../inc/MarlinConfig.h" @@ -384,4 +384,4 @@ void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou } #endif // HAS_LTDC_TFT -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 32af67d158..4e3f894a52 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../../inc/MarlinConfig.h" @@ -125,12 +125,20 @@ void TFT_SPI::DataTransferBegin(uint16_t DataSize) { WRITE(TFT_CS_PIN, LOW); } +#ifdef TFT_DEFAULT_DRIVER + #include "../../../lcd/tft_io/tft_ids.h" +#endif + uint32_t TFT_SPI::GetID() { uint32_t id; id = ReadID(LCD_READ_ID); - - if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) + if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) { id = ReadID(LCD_READ_ID4); + #ifdef TFT_DEFAULT_DRIVER + if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) + id = TFT_DEFAULT_DRIVER; + #endif + } return id; } @@ -232,4 +240,4 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun } #endif // HAS_SPI_TFT -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.cpp b/Marlin/src/HAL/STM32/tft/xpt2046.cpp index dffeb6aaf7..d50c24d177 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.cpp +++ b/Marlin/src/HAL/STM32/tft/xpt2046.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../../inc/MarlinConfig.h" @@ -167,4 +167,4 @@ uint16_t XPT2046::SoftwareIO(uint16_t data) { } #endif // HAS_TFT_XPT2046 -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.h b/Marlin/src/HAL/STM32/tft/xpt2046.h index 5b8acf4b87..2cff3e29d0 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.h +++ b/Marlin/src/HAL/STM32/tft/xpt2046.h @@ -56,7 +56,7 @@ enum XPTCoordinate : uint8_t { XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE, }; -#if !defined(XPT2046_Z1_THRESHOLD) +#ifndef XPT2046_Z1_THRESHOLD #define XPT2046_Z1_THRESHOLD 10 #endif diff --git a/Marlin/src/HAL/STM32/timers.cpp b/Marlin/src/HAL/STM32/timers.cpp index 03353c2ca3..7806198180 100644 --- a/Marlin/src/HAL/STM32/timers.cpp +++ b/Marlin/src/HAL/STM32/timers.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" @@ -319,4 +319,4 @@ static constexpr bool verify_no_timer_conflicts() { // when hovering over it, making it easy to identify the conflicting timers. static_assert(verify_no_timer_conflicts(), "One or more timer conflict detected. Examine \"timers_in_use\" to help identify conflict."); -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp index 8fa49ccbcc..e45ab560e6 100644 --- a/Marlin/src/HAL/STM32/usb_host.cpp +++ b/Marlin/src/HAL/STM32/usb_host.cpp @@ -20,7 +20,7 @@ * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfig.h" @@ -114,4 +114,4 @@ uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t b } #endif // USE_OTG_USB_HOST && USBHOST -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/usb_serial.cpp b/Marlin/src/HAL/STM32/usb_serial.cpp index 705d649ff5..0e23175fc0 100644 --- a/Marlin/src/HAL/STM32/usb_serial.cpp +++ b/Marlin/src/HAL/STM32/usb_serial.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfigPre.h" @@ -51,4 +51,4 @@ void USB_Hook_init() { } #endif // EMERGENCY_PARSER && USBD_USE_CDC -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32/watchdog.cpp b/Marlin/src/HAL/STM32/watchdog.cpp index aad0a79a0c..09b403e7f2 100644 --- a/Marlin/src/HAL/STM32/watchdog.cpp +++ b/Marlin/src/HAL/STM32/watchdog.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #include "../../inc/MarlinConfigPre.h" @@ -46,4 +46,4 @@ void HAL_watchdog_refresh() { } #endif // USE_WATCHDOG -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 diff --git a/Marlin/src/HAL/STM32F1/SPI.h b/Marlin/src/HAL/STM32F1/SPI.h index 828644f1dd..2467432e07 100644 --- a/Marlin/src/HAL/STM32F1/SPI.h +++ b/Marlin/src/HAL/STM32F1/SPI.h @@ -138,8 +138,8 @@ private: spi_dev *spi_d; dma_channel spiRxDmaChannel, spiTxDmaChannel; dma_dev* spiDmaDev; - void (*receiveCallback)() = NULL; - void (*transmitCallback)() = NULL; + void (*receiveCallback)() = nullptr; + void (*transmitCallback)() = nullptr; friend class SPIClass; }; diff --git a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp b/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp index 784a80c29f..f1cd6b3730 100644 --- a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp +++ b/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp @@ -22,7 +22,7 @@ #if BOTH(HAS_MARLINUI_U8GLIB, FORCE_SOFT_SPI) -#include +#include #include "../../shared/HAL_SPI.h" #ifndef LCD_SPI_SPEED diff --git a/Marlin/src/HAL/STM32F1/inc/SanityCheck.h b/Marlin/src/HAL/STM32F1/inc/SanityCheck.h index 89ee66d646..2846155c35 100644 --- a/Marlin/src/HAL/STM32F1/inc/SanityCheck.h +++ b/Marlin/src/HAL/STM32F1/inc/SanityCheck.h @@ -39,7 +39,7 @@ #error "SERIAL_STATS_DROPPED_RX is not supported on the STM32F1 platform." #endif -#if ENABLED(NEOPIXEL_LED) +#if ENABLED(NEOPIXEL_LED) && DISABLED(MKS_MINI_12864_V3) #error "NEOPIXEL_LED (Adafruit NeoPixel) is not supported for HAL/STM32F1. Comment out this line to proceed at your own risk!" #endif diff --git a/Marlin/src/HAL/STM32F1/msc_sd.cpp b/Marlin/src/HAL/STM32F1/msc_sd.cpp index 7725b2c324..f490c83ed8 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.cpp +++ b/Marlin/src/HAL/STM32F1/msc_sd.cpp @@ -13,9 +13,11 @@ * along with this program. If not, see . * */ +#ifdef __STM32F1__ + #include "../../inc/MarlinConfigPre.h" -#if defined(__STM32F1__) && HAS_SD_HOST_DRIVE +#if HAS_SD_HOST_DRIVE #include "msc_sd.h" #include "SPI.h" @@ -92,4 +94,5 @@ void MSC_SD_init() { #endif } -#endif // __STM32F1__ && HAS_SD_HOST_DRIVE +#endif // HAS_SD_HOST_DRIVE +#endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/onboard_sd.cpp b/Marlin/src/HAL/STM32F1/onboard_sd.cpp index 6092aea320..e26947145d 100644 --- a/Marlin/src/HAL/STM32F1/onboard_sd.cpp +++ b/Marlin/src/HAL/STM32F1/onboard_sd.cpp @@ -38,8 +38,8 @@ #define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_2 #endif -#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) /* Set OnboardSPI cs low */ -#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) /* Set OnboardSPI cs high */ +#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low +#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high #define FCLK_FAST() ONBOARD_SD_SPI.setClockDivider(SPI_CLOCK_MAX) #define FCLK_SLOW() ONBOARD_SD_SPI.setClockDivider(SPI_BAUD_PCLK_DIV_256) @@ -49,32 +49,32 @@ ---------------------------------------------------------------------------*/ /* MMC/SD command */ -#define CMD0 (0) /* GO_IDLE_STATE */ -#define CMD1 (1) /* SEND_OP_COND (MMC) */ -#define ACMD41 (0x80+41) /* SEND_OP_COND (SDC) */ -#define CMD8 (8) /* SEND_IF_COND */ -#define CMD9 (9) /* SEND_CSD */ -#define CMD10 (10) /* SEND_CID */ -#define CMD12 (12) /* STOP_TRANSMISSION */ -#define ACMD13 (0x80+13) /* SD_STATUS (SDC) */ -#define CMD16 (16) /* SET_BLOCKLEN */ -#define CMD17 (17) /* READ_SINGLE_BLOCK */ -#define CMD18 (18) /* READ_MULTIPLE_BLOCK */ -#define CMD23 (23) /* SET_BLOCK_COUNT (MMC) */ -#define ACMD23 (0x80+23) /* SET_WR_BLK_ERASE_COUNT (SDC) */ -#define CMD24 (24) /* WRITE_BLOCK */ -#define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */ -#define CMD32 (32) /* ERASE_ER_BLK_START */ -#define CMD33 (33) /* ERASE_ER_BLK_END */ -#define CMD38 (38) /* ERASE */ -#define CMD48 (48) /* READ_EXTR_SINGLE */ -#define CMD49 (49) /* WRITE_EXTR_SINGLE */ -#define CMD55 (55) /* APP_CMD */ -#define CMD58 (58) /* READ_OCR */ +#define CMD0 (0) // GO_IDLE_STATE +#define CMD1 (1) // SEND_OP_COND (MMC) +#define ACMD41 (0x80+41) // SEND_OP_COND (SDC) +#define CMD8 (8) // SEND_IF_COND +#define CMD9 (9) // SEND_CSD +#define CMD10 (10) // SEND_CID +#define CMD12 (12) // STOP_TRANSMISSION +#define ACMD13 (0x80+13) // SD_STATUS (SDC) +#define CMD16 (16) // SET_BLOCKLEN +#define CMD17 (17) // READ_SINGLE_BLOCK +#define CMD18 (18) // READ_MULTIPLE_BLOCK +#define CMD23 (23) // SET_BLOCK_COUNT (MMC) +#define ACMD23 (0x80+23) // SET_WR_BLK_ERASE_COUNT (SDC) +#define CMD24 (24) // WRITE_BLOCK +#define CMD25 (25) // WRITE_MULTIPLE_BLOCK +#define CMD32 (32) // ERASE_ER_BLK_START +#define CMD33 (33) // ERASE_ER_BLK_END +#define CMD38 (38) // ERASE +#define CMD48 (48) // READ_EXTR_SINGLE +#define CMD49 (49) // WRITE_EXTR_SINGLE +#define CMD55 (55) // APP_CMD +#define CMD58 (58) // READ_OCR -static volatile DSTATUS Stat = STA_NOINIT; /* Physical drive status */ +static volatile DSTATUS Stat = STA_NOINIT; // Physical drive status static volatile UINT timeout; -static BYTE CardType; /* Card type flags */ +static BYTE CardType; // Card type flags /*-----------------------------------------------------------------------*/ /* Send/Receive data to the MMC (Platform dependent) */ @@ -82,7 +82,7 @@ static BYTE CardType; /* Card type flags */ /* Exchange a byte */ static BYTE xchg_spi ( - BYTE dat /* Data to send */ + BYTE dat // Data to send ) { BYTE returnByte = ONBOARD_SD_SPI.transfer(dat); return returnByte; @@ -90,18 +90,18 @@ static BYTE xchg_spi ( /* Receive multiple byte */ static void rcvr_spi_multi ( - BYTE *buff, /* Pointer to data buffer */ - UINT btr /* Number of bytes to receive (16, 64 or 512) */ + BYTE *buff, // Pointer to data buffer + UINT btr // Number of bytes to receive (16, 64 or 512) ) { ONBOARD_SD_SPI.dmaTransfer(0, const_cast(buff), btr); } #if _DISKIO_WRITE - /* Send multiple bytes */ + // Send multiple bytes static void xmit_spi_multi ( - const BYTE *buff, /* Pointer to the data */ - UINT btx /* Number of bytes to send (multiple of 16) */ + const BYTE *buff, // Pointer to the data + UINT btx // Number of bytes to send (multiple of 16) ) { ONBOARD_SD_SPI.dmaSend(const_cast(buff), btx); } @@ -112,16 +112,15 @@ static void rcvr_spi_multi ( /* Wait for card ready */ /*-----------------------------------------------------------------------*/ -static int wait_ready ( /* 1:Ready, 0:Timeout */ - UINT wt /* Timeout [ms] */ +static int wait_ready ( // 1:Ready, 0:Timeout + UINT wt // Timeout [ms] ) { BYTE d; - timeout = millis() + wt; do { d = xchg_spi(0xFF); - /* This loop takes a while. Insert rot_rdq() here for multitask environment. */ - } while (d != 0xFF && (timeout > millis())); /* Wait for card goes ready or timeout */ + // This loop takes a while. Insert rot_rdq() here for multitask environment. + } while (d != 0xFF && (timeout > millis())); // Wait for card goes ready or timeout return (d == 0xFF) ? 1 : 0; } @@ -131,21 +130,21 @@ static int wait_ready ( /* 1:Ready, 0:Timeout */ /*-----------------------------------------------------------------------*/ static void deselect() { - CS_HIGH(); /* CS = H */ - xchg_spi(0xFF); /* Dummy clock (force DO hi-z for multiple slave SPI) */ + CS_HIGH(); // CS = H + xchg_spi(0xFF); // Dummy clock (force DO hi-z for multiple slave SPI) } /*-----------------------------------------------------------------------*/ /* Select card and wait for ready */ /*-----------------------------------------------------------------------*/ -static int select() { /* 1:OK, 0:Timeout */ - CS_LOW(); /* CS = L */ - xchg_spi(0xFF); /* Dummy clock (force DO enabled) */ +static int select() { // 1:OK, 0:Timeout + CS_LOW(); // CS = L + xchg_spi(0xFF); // Dummy clock (force DO enabled) - if (wait_ready(500)) return 1; /* Leading busy check: Wait for card ready */ + if (wait_ready(500)) return 1; // Leading busy check: Wait for card ready - deselect(); /* Timeout */ + deselect(); // Timeout return 0; } @@ -153,16 +152,18 @@ static int select() { /* 1:OK, 0:Timeout */ /* Control SPI module (Platform dependent) */ /*-----------------------------------------------------------------------*/ -static void power_on() { /* Enable SSP module and attach it to I/O pads */ +// Enable SSP module and attach it to I/O pads +static void sd_power_on() { ONBOARD_SD_SPI.setModule(ONBOARD_SPI_DEVICE); ONBOARD_SD_SPI.begin(); ONBOARD_SD_SPI.setBitOrder(MSBFIRST); ONBOARD_SD_SPI.setDataMode(SPI_MODE0); - OUT_WRITE(ONBOARD_SD_CS_PIN, HIGH); /* Set CS# high */ + OUT_WRITE(ONBOARD_SD_CS_PIN, HIGH); // Set CS# high } -static void power_off() { /* Disable SPI function */ - select(); /* Wait for card ready */ +// Disable SPI function +static void sd_power_off() { + select(); // Wait for card ready deselect(); } @@ -170,23 +171,23 @@ static void power_off() { /* Disable SPI function */ /* Receive a data packet from the MMC */ /*-----------------------------------------------------------------------*/ -static int rcvr_datablock ( /* 1:OK, 0:Error */ - BYTE *buff, /* Data buffer */ - UINT btr /* Data block length (byte) */ +static int rcvr_datablock ( // 1:OK, 0:Error + BYTE *buff, // Data buffer + UINT btr // Data block length (byte) ) { BYTE token; timeout = millis() + 200; - do { /* Wait for DataStart token in timeout of 200ms */ + do { // Wait for DataStart token in timeout of 200ms token = xchg_spi(0xFF); - /* This loop will take a while. Insert rot_rdq() here for multitask environment. */ + // This loop will take a while. Insert rot_rdq() here for multitask environment. } while ((token == 0xFF) && (timeout > millis())); - if (token != 0xFE) return 0; /* Function fails if invalid DataStart token or timeout */ + if (token != 0xFE) return 0; // Function fails if invalid DataStart token or timeout - rcvr_spi_multi(buff, btr); /* Store trailing data to the buffer */ - xchg_spi(0xFF); xchg_spi(0xFF); /* Discard CRC */ + rcvr_spi_multi(buff, btr); // Store trailing data to the buffer + xchg_spi(0xFF); xchg_spi(0xFF); // Discard CRC - return 1; /* Function succeeded */ + return 1; // Function succeeded } /*-----------------------------------------------------------------------*/ @@ -195,25 +196,25 @@ static int rcvr_datablock ( /* 1:OK, 0:Error */ #if _DISKIO_WRITE - static int xmit_datablock ( /* 1:OK, 0:Failed */ - const BYTE *buff, /* Ponter to 512 byte data to be sent */ - BYTE token /* Token */ + static int xmit_datablock( // 1:OK, 0:Failed + const BYTE *buff, // Pointer to 512 byte data to be sent + BYTE token // Token ) { BYTE resp; - if (!wait_ready(500)) return 0; /* Leading busy check: Wait for card ready to accept data block */ + if (!wait_ready(500)) return 0; // Leading busy check: Wait for card ready to accept data block - xchg_spi(token); /* Send token */ - if (token == 0xFD) return 1; /* Do not send data if token is StopTran */ + xchg_spi(token); // Send token + if (token == 0xFD) return 1; // Do not send data if token is StopTran - xmit_spi_multi(buff, 512); /* Data */ - xchg_spi(0xFF); xchg_spi(0xFF); /* Dummy CRC */ + xmit_spi_multi(buff, 512); // Data + xchg_spi(0xFF); xchg_spi(0xFF); // Dummy CRC - resp = xchg_spi(0xFF); /* Receive data resp */ + resp = xchg_spi(0xFF); // Receive data resp - return (resp & 0x1F) == 0x05 ? 1 : 0; /* Data was accepted or not */ + return (resp & 0x1F) == 0x05 ? 1 : 0; // Data was accepted or not - /* Busy check is done at next transmission */ + // Busy check is done at next transmission } #endif // _DISKIO_WRITE @@ -222,43 +223,43 @@ static int rcvr_datablock ( /* 1:OK, 0:Error */ /* Send a command packet to the MMC */ /*-----------------------------------------------------------------------*/ -static BYTE send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */ - BYTE cmd, /* Command index */ - DWORD arg /* Argument */ +static BYTE send_cmd( // Return value: R1 resp (bit7==1:Failed to send) + BYTE cmd, // Command index + DWORD arg // Argument ) { BYTE n, res; - if (cmd & 0x80) { /* Send a CMD55 prior to ACMD */ + if (cmd & 0x80) { // Send a CMD55 prior to ACMD cmd &= 0x7F; res = send_cmd(CMD55, 0); if (res > 1) return res; } - /* Select the card and wait for ready except to stop multiple block read */ + // Select the card and wait for ready except to stop multiple block read if (cmd != CMD12) { deselect(); if (!select()) return 0xFF; } - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */ + // Send command packet + xchg_spi(0x40 | cmd); // Start + command index + xchg_spi((BYTE)(arg >> 24)); // Argument[31..24] + xchg_spi((BYTE)(arg >> 16)); // Argument[23..16] + xchg_spi((BYTE)(arg >> 8)); // Argument[15..8] + xchg_spi((BYTE)arg); // Argument[7..0] + n = 0x01; // Dummy CRC + Stop + if (cmd == CMD0) n = 0x95; // Valid CRC for CMD0(0) + if (cmd == CMD8) n = 0x87; // Valid CRC for CMD8(0x1AA) xchg_spi(n); - /* Receive command resp */ - if (cmd == CMD12) xchg_spi(0xFF); /* Diacard following one byte when CMD12 */ - n = 10; /* Wait for response (10 bytes max) */ + // Receive command response + if (cmd == CMD12) xchg_spi(0xFF); // Discard the following byte when CMD12 + n = 10; // Wait for response (10 bytes max) do res = xchg_spi(0xFF); while ((res & 0x80) && --n); - return res; /* Return received response */ + return res; // Return received response } /*-------------------------------------------------------------------------- @@ -270,49 +271,52 @@ static BYTE send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */ /*-----------------------------------------------------------------------*/ DSTATUS disk_initialize ( - BYTE drv /* Physical drive number (0) */ + BYTE drv // Physical drive number (0) ) { BYTE n, cmd, ty, ocr[4]; - if (drv) return STA_NOINIT; /* Supports only drive 0 */ - power_on(); /* Initialize SPI */ + if (drv) return STA_NOINIT; // Supports only drive 0 + sd_power_on(); // Initialize SPI - if (Stat & STA_NODISK) return Stat; /* Is a card existing in the soket? */ + if (Stat & STA_NODISK) return Stat; // Is a card existing in the soket? FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* Send 80 dummy clocks */ + for (n = 10; n; n--) xchg_spi(0xFF); // Send 80 dummy clocks ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Put the card SPI state */ - timeout = millis() + 1000; /* Initialization timeout = 1 sec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* Is the catd SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get 32 bit return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* Does the card support 2.7-3.6V? */ - while ((timeout > millis()) && send_cmd(ACMD41, 1UL << 30)) ; /* Wait for end of initialization with ACMD41(HCS) */ - if ((timeout > millis()) && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ + if (send_cmd(CMD0, 0) == 1) { // Put the card SPI state + timeout = millis() + 1000; // Initialization timeout = 1 sec + if (send_cmd(CMD8, 0x1AA) == 1) { // Is the catd SDv2? + for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); // Get 32 bit return value of R7 resp + if (ocr[2] == 0x01 && ocr[3] == 0xAA) { // Does the card support 2.7-3.6V? + while ((timeout > millis()) && send_cmd(ACMD41, 1UL << 30)); // Wait for end of initialization with ACMD41(HCS) + if ((timeout > millis()) && send_cmd(CMD58, 0) == 0) { // Check CCS bit in the OCR for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* Check if the card is SDv2 */ + ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; // Check if the card is SDv2 } } - } else { /* Not an SDv2 card */ - if (send_cmd(ACMD41, 0) <= 1) { /* SDv1 or MMCv3? */ - ty = CT_SD1; cmd = ACMD41; /* SDv1 (ACMD41(0)) */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 (CMD1(0)) */ + } + else { // Not an SDv2 card + if (send_cmd(ACMD41, 0) <= 1) { // SDv1 or MMCv3? + ty = CT_SD1; cmd = ACMD41; // SDv1 (ACMD41(0)) } - while ((timeout > millis()) && send_cmd(cmd, 0)) ; /* Wait for the card leaves idle state */ - if (!(timeout > millis()) || send_cmd(CMD16, 512) != 0) /* Set block length: 512 */ + else { + ty = CT_MMC; cmd = CMD1; // MMCv3 (CMD1(0)) + } + while ((timeout > millis()) && send_cmd(cmd, 0)); // Wait for the card leaves idle state + if (!(timeout > millis()) || send_cmd(CMD16, 512) != 0) // Set block length: 512 ty = 0; } } - CardType = ty; /* Card type */ + CardType = ty; // Card type deselect(); - if (ty) { /* OK */ - FCLK_FAST(); /* Set fast clock */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT flag */ - } else { /* Failed */ - power_off(); + if (ty) { // OK + FCLK_FAST(); // Set fast clock + Stat &= ~STA_NOINIT; // Clear STA_NOINIT flag + } + else { // Failed + sd_power_off(); Stat = STA_NOINIT; } @@ -324,10 +328,10 @@ DSTATUS disk_initialize ( /*-----------------------------------------------------------------------*/ DSTATUS disk_status ( - BYTE drv /* Physical drive number (0) */ + BYTE drv // Physical drive number (0) ) { - if (drv) return STA_NOINIT; /* Supports only drive 0 */ - return Stat; /* Return disk status */ + if (drv) return STA_NOINIT; // Supports only drive 0 + return Stat; // Return disk status } /*-----------------------------------------------------------------------*/ @@ -335,28 +339,28 @@ DSTATUS disk_status ( /*-----------------------------------------------------------------------*/ DRESULT disk_read ( - BYTE drv, /* Physical drive number (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Number of sectors to read (1..128) */ + BYTE drv, // Physical drive number (0) + BYTE *buff, // Pointer to the data buffer to store read data + DWORD sector, // Start sector number (LBA) + UINT count // Number of sectors to read (1..128) ) { BYTE cmd; - if (drv || !count) return RES_PARERR; /* Check parameter */ - if (Stat & STA_NOINIT) return RES_NOTRDY; /* Check if drive is ready */ - if (!(CardType & CT_BLOCK)) sector *= 512; /* LBA ot BA conversion (byte addressing cards) */ + if (drv || !count) return RES_PARERR; // Check parameter + if (Stat & STA_NOINIT) return RES_NOTRDY; // Check if drive is ready + if (!(CardType & CT_BLOCK)) sector *= 512; // LBA ot BA conversion (byte addressing cards) FCLK_FAST(); - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ + cmd = count > 1 ? CMD18 : CMD17; // READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK if (send_cmd(cmd, sector) == 0) { do { if (!rcvr_datablock(buff, 512)) break; buff += 512; } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ + if (cmd == CMD18) send_cmd(CMD12, 0); // STOP_TRANSMISSION } deselect(); - return count ? RES_ERROR : RES_OK; /* Return result */ + return count ? RES_ERROR : RES_OK; // Return result } /*-----------------------------------------------------------------------*/ @@ -366,36 +370,36 @@ DRESULT disk_read ( #if _DISKIO_WRITE DRESULT disk_write( - BYTE drv, /* Physical drive number (0) */ - const BYTE *buff, /* Ponter to the data to write */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Number of sectors to write (1..128) */ + BYTE drv, // Physical drive number (0) + const BYTE *buff, // Pointer to the data to write + DWORD sector, // Start sector number (LBA) + UINT count // Number of sectors to write (1..128) ) { - if (drv || !count) return RES_PARERR; /* Check parameter */ - if (Stat & STA_NOINIT) return RES_NOTRDY; /* Check drive status */ - if (Stat & STA_PROTECT) return RES_WRPRT; /* Check write protect */ + if (drv || !count) return RES_PARERR; // Check parameter + if (Stat & STA_NOINIT) return RES_NOTRDY; // Check drive status + if (Stat & STA_PROTECT) return RES_WRPRT; // Check write protect FCLK_FAST(); - if (!(CardType & CT_BLOCK)) sector *= 512; /* LBA ==> BA conversion (byte addressing cards) */ + if (!(CardType & CT_BLOCK)) sector *= 512; // LBA ==> BA conversion (byte addressing cards) - if (count == 1) { /* Single sector write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ + if (count == 1) { // Single sector write + if ((send_cmd(CMD24, sector) == 0) // WRITE_BLOCK && xmit_datablock(buff, 0xFE)) { count = 0; } } - else { /* Multiple sector write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); /* Predefine number of sectors */ - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ + else { // Multiple sector write + if (CardType & CT_SDC) send_cmd(ACMD23, count); // Predefine number of sectors + if (send_cmd(CMD25, sector) == 0) { // WRITE_MULTIPLE_BLOCK do { if (!xmit_datablock(buff, 0xFC)) break; buff += 512; } while (--count); - if (!xmit_datablock(0, 0xFD)) count = 1; /* STOP_TRAN token */ + if (!xmit_datablock(0, 0xFD)) count = 1; // STOP_TRAN token } } deselect(); - return count ? RES_ERROR : RES_OK; /* Return result */ + return count ? RES_ERROR : RES_OK; // Return result } #endif // _DISKIO_WRITE @@ -407,9 +411,9 @@ DRESULT disk_read ( #if _DISKIO_IOCTL DRESULT disk_ioctl ( - BYTE drv, /* Physical drive number (0) */ - BYTE cmd, /* Control command code */ - void *buff /* Pointer to the conrtol data */ + BYTE drv, // Physical drive number (0) + BYTE cmd, // Control command code + void *buff // Pointer to the conrtol data ) { DRESULT res; BYTE n, csd[16], *ptr = (BYTE *)buff; @@ -420,22 +424,23 @@ DRESULT disk_read ( UINT dc; #endif - if (drv) return RES_PARERR; /* Check parameter */ - if (Stat & STA_NOINIT) return RES_NOTRDY; /* Check if drive is ready */ + if (drv) return RES_PARERR; // Check parameter + if (Stat & STA_NOINIT) return RES_NOTRDY; // Check if drive is ready res = RES_ERROR; FCLK_FAST(); switch (cmd) { - case CTRL_SYNC: /* Wait for end of internal write process of the drive */ + case CTRL_SYNC: // Wait for end of internal write process of the drive if (select()) res = RES_OK; break; - case GET_SECTOR_COUNT: /* Get drive capacity in unit of sector (DWORD) */ + case GET_SECTOR_COUNT: // Get drive capacity in unit of sector (DWORD) if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ + if ((csd[0] >> 6) == 1) { // SDC ver 2.00 csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC ver 3 */ + } + else { // SDC ver 1.XX or MMC ver 3 n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; *(DWORD*)buff = csize << (n - 9); @@ -444,21 +449,23 @@ DRESULT disk_read ( } break; - case GET_BLOCK_SIZE: /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDC ver 2.00 */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ + case GET_BLOCK_SIZE: // Get erase block size in unit of sector (DWORD) + if (CardType & CT_SD2) { // SDC ver 2.00 + if (send_cmd(ACMD13, 0) == 0) { // Read SD status xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ + if (rcvr_datablock(csd, 16)) { // Read partial block + for (n = 64 - 16; n; n--) xchg_spi(0xFF); // Purge trailing data *(DWORD*)buff = 16UL << (csd[10] >> 4); res = RES_OK; } } - } else { /* SDC ver 1.XX or MMC */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDC ver 1.XX */ + } + else { // SDC ver 1.XX or MMC + if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { // Read CSD + if (CardType & CT_SD1) { // SDC ver 1.XX *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMC */ + } + else { // MMC *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); } res = RES_OK; @@ -466,47 +473,47 @@ DRESULT disk_read ( } break; - case CTRL_TRIM: /* Erase a block of sectors (used when _USE_TRIM in ffconf.h is 1) */ - if (!(CardType & CT_SDC)) break; /* Check if the card is SDC */ - if (disk_ioctl(drv, MMC_GET_CSD, csd)) break; /* Get CSD */ - if (!(csd[0] >> 6) && !(csd[10] & 0x40)) break; /* Check if sector erase can be applied to the card */ - dp = (DWORD *)buff; st = dp[0]; ed = dp[1]; /* Load sector block */ + case CTRL_TRIM: // Erase a block of sectors (used when _USE_TRIM in ffconf.h is 1) + if (!(CardType & CT_SDC)) break; // Check if the card is SDC + if (disk_ioctl(drv, MMC_GET_CSD, csd)) break; // Get CSD + if (!(csd[0] >> 6) && !(csd[10] & 0x40)) break; // Check if sector erase can be applied to the card + dp = (DWORD *)buff; st = dp[0]; ed = dp[1]; // Load sector block if (!(CardType & CT_BLOCK)) { st *= 512; ed *= 512; } - if (send_cmd(CMD32, st) == 0 && send_cmd(CMD33, ed) == 0 && send_cmd(CMD38, 0) == 0 && wait_ready(30000)) { /* Erase sector block */ - res = RES_OK; /* FatFs does not check result of this command */ + if (send_cmd(CMD32, st) == 0 && send_cmd(CMD33, ed) == 0 && send_cmd(CMD38, 0) == 0 && wait_ready(30000)) { // Erase sector block + res = RES_OK; // FatFs does not check result of this command } break; - /* Following commands are never used by FatFs module */ + // The following commands are never used by FatFs module - case MMC_GET_TYPE: /* Get MMC/SDC type (BYTE) */ + case MMC_GET_TYPE: // Get MMC/SDC type (BYTE) *ptr = CardType; res = RES_OK; break; - case MMC_GET_CSD: /* Read CSD (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 && rcvr_datablock(ptr, 16)) { /* READ_CSD */ + case MMC_GET_CSD: // Read CSD (16 bytes) + if (send_cmd(CMD9, 0) == 0 && rcvr_datablock(ptr, 16)) { res = RES_OK; } break; - case MMC_GET_CID: /* Read CID (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 && rcvr_datablock(ptr, 16)) { /* READ_CID */ + case MMC_GET_CID: // Read CID (16 bytes) + if (send_cmd(CMD10, 0) == 0 && rcvr_datablock(ptr, 16)) { res = RES_OK; } break; - case MMC_GET_OCR: /* Read OCR (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ + case MMC_GET_OCR: // Read OCR (4 bytes) + if (send_cmd(CMD58, 0) == 0) { for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); res = RES_OK; } break; - case MMC_GET_SDSTAT: /* Read SD status (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ + case MMC_GET_SDSTAT: // Read SD status (64 bytes) + if (send_cmd(ACMD13, 0) == 0) { xchg_spi(0xFF); if (rcvr_datablock(ptr, 64)) res = RES_OK; } diff --git a/Marlin/src/HAL/STM32F1/sdio.cpp b/Marlin/src/HAL/STM32F1/sdio.cpp index ffa6db1206..6e41d2cbf1 100644 --- a/Marlin/src/HAL/STM32F1/sdio.cpp +++ b/Marlin/src/HAL/STM32F1/sdio.cpp @@ -184,6 +184,10 @@ bool SDIO_WriteBlock(uint32_t blockAddress, const uint8_t *data) { inline uint32_t SDIO_GetCardState() { return SDIO_CmdSendStatus(SdCard.RelCardAdd << 16U) ? (SDIO_GetResponse(SDIO_RESP1) >> 9U) & 0x0FU : SDIO_CARD_ERROR; } +// No F1 board with SDIO + MSC using Maple, that I aware of... +bool SDIO_IsReady() { return true; } +uint32_t SDIO_GetCardSize() { return 0; } + // ------------------------ // SD Commands and Responses // ------------------------ diff --git a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp index 1095389946..5edf96fe56 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp @@ -90,12 +90,20 @@ void TFT_SPI::DataTransferBegin(uint16_t DataSize) { TFT_CS_L; } +#ifdef TFT_DEFAULT_DRIVER + #include "../../../lcd/tft_io/tft_ids.h" +#endif + uint32_t TFT_SPI::GetID() { uint32_t id; id = ReadID(LCD_READ_ID); - - if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) + if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) { id = ReadID(LCD_READ_ID4); + #ifdef TFT_DEFAULT_DRIVER + if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) + id = TFT_DEFAULT_DRIVER; + #endif + } return id; } diff --git a/Marlin/src/HAL/STM32F1/tft/xpt2046.h b/Marlin/src/HAL/STM32F1/tft/xpt2046.h index 65602bda0f..aba0799e44 100644 --- a/Marlin/src/HAL/STM32F1/tft/xpt2046.h +++ b/Marlin/src/HAL/STM32F1/tft/xpt2046.h @@ -54,7 +54,7 @@ enum XPTCoordinate : uint8_t { XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE, }; -#if !defined(XPT2046_Z1_THRESHOLD) +#ifndef XPT2046_Z1_THRESHOLD #define XPT2046_Z1_THRESHOLD 10 #endif diff --git a/Marlin/src/HAL/platforms.h b/Marlin/src/HAL/platforms.h index e0617bdf7f..0b1b305f6d 100644 --- a/Marlin/src/HAL/platforms.h +++ b/Marlin/src/HAL/platforms.h @@ -43,6 +43,8 @@ #define HAL_PATH(PATH, NAME) XSTR(PATH/ESP32/NAME) #elif defined(__PLAT_LINUX__) #define HAL_PATH(PATH, NAME) XSTR(PATH/LINUX/NAME) +#elif defined(__PLAT_NATIVE_SIM__) + #define HAL_PATH(PATH, NAME) XSTR(PATH/NATIVE_SIM/NAME) #elif defined(__SAMD51__) #define HAL_PATH(PATH, NAME) XSTR(PATH/SAMD51/NAME) #else diff --git a/Marlin/src/HAL/shared/Delay.h b/Marlin/src/HAL/shared/Delay.h index f7e01ad25c..04df35d88d 100644 --- a/Marlin/src/HAL/shared/Delay.h +++ b/Marlin/src/HAL/shared/Delay.h @@ -97,48 +97,70 @@ void calibrate_delay_loop(); #define DELAY_US(x) DelayCycleFnc((x) * ((F_CPU) / 1000000UL)) #elif defined(__AVR__) - - #define nop() __asm__ __volatile__("nop;\n\t":::) - - FORCE_INLINE static void __delay_4cycles(uint8_t cy) { - __asm__ __volatile__( - L("1") - A("dec %[cnt]") - A("nop") - A("brne 1b") - : [cnt] "+r"(cy) // output: +r means input+output - : // input: - : "cc" // clobbers: - ); + FORCE_INLINE static void __delay_up_to_3c(uint8_t cycles) { + switch (cycles) { + case 3: + __asm__ __volatile__(A("RJMP .+0") A("NOP")); + break; + case 2: + __asm__ __volatile__(A("RJMP .+0")); + break; + case 1: + __asm__ __volatile__(A("NOP")); + break; + } } // Delay in cycles - FORCE_INLINE static void DELAY_CYCLES(uint16_t x) { - - if (__builtin_constant_p(x)) { - #define MAXNOPS 4 - - if (x <= (MAXNOPS)) { - switch (x) { case 4: nop(); case 3: nop(); case 2: nop(); case 1: nop(); } + FORCE_INLINE static void DELAY_CYCLES(uint16_t cycles) { + if (__builtin_constant_p(cycles)) { + if (cycles <= 3) { + __delay_up_to_3c(cycles); + } + else if (cycles == 4) { + __delay_up_to_3c(2); + __delay_up_to_3c(2); } else { - const uint32_t rem = (x) % (MAXNOPS); - switch (rem) { case 3: nop(); case 2: nop(); case 1: nop(); } - if ((x = (x) / (MAXNOPS))) - __delay_4cycles(x); // if need more then 4 nop loop is more optimal - } + cycles -= 1 + 4; // Compensate for the first LDI (1) and the first round (4) + __delay_up_to_3c(cycles % 4); - #undef MAXNOPS + cycles /= 4; + // The following code burns [1 + 4 * (rounds+1)] cycles + uint16_t dummy; + __asm__ __volatile__( + // "manually" load counter from constants, otherwise the compiler may optimize this part away + A("LDI %A[rounds], %[l]") // 1c + A("LDI %B[rounds], %[h]") // 1c (compensating the non branching BRCC) + L("1") + A("SBIW %[rounds], 1") // 2c + A("BRCC 1b") // 2c when branching, else 1c (end of loop) + : // Outputs ... + [rounds] "=w" (dummy) // Restrict to a wo (=) 16 bit register pair (w) + : // Inputs ... + [l] "M" (cycles%256), // Restrict to 0..255 constant (M) + [h] "M" (cycles/256) // Restrict to 0..255 constant (M) + :// Clobbers ... + "cc" // Indicate we are modifying flags like Carry (cc) + ); + } + } + else { + __asm__ __volatile__( + L("1") + A("SBIW %[cycles], 4") // 2c + A("BRCC 1b") // 2c when branching, else 1c (end of loop) + : [cycles] "+w" (cycles) // output: Restrict to a rw (+) 16 bit register pair (w) + : // input: - + : "cc" // clobbers: We are modifying flags like Carry (cc) + ); } - else if ((x >>= 2)) - __delay_4cycles(x); } - #undef nop // Delay in microseconds #define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL)) -#elif defined(__PLAT_LINUX__) || defined(ESP32) +#elif defined(ESP32) || defined(__PLAT_LINUX__) || defined(__PLAT_NATIVE_SIM__) // DELAY_CYCLES specified inside platform diff --git a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp index 27f0233562..6b559e234b 100644 --- a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp +++ b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp @@ -61,11 +61,24 @@ static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(EEPROM_DEVICE_ADDRE // Public functions // ------------------------ +#define SMALL_EEPROM (MARLIN_EEPROM_SIZE <= 2048) + +// Combine Address high bits into the device address on <=16Kbit (2K) and >512Kbit (64K) EEPROMs. +// Note: MARLIN_EEPROM_SIZE is specified in bytes, whereas EEPROM model numbers refer to bits. +// e.g., The "16" in BL24C16 indicates a 16Kbit (2KB) size. +static uint8_t _eeprom_calc_device_address(uint8_t * const pos) { + const unsigned eeprom_address = (unsigned)pos; + return (SMALL_EEPROM || MARLIN_EEPROM_SIZE > 65536) + ? uint8_t(eeprom_device_address | ((eeprom_address >> (SMALL_EEPROM ? 8 : 16)) & 0x07)) + : eeprom_device_address; +} + static void _eeprom_begin(uint8_t * const pos) { const unsigned eeprom_address = (unsigned)pos; - Wire.beginTransmission(eeprom_device_address); - Wire.write(int(eeprom_address >> 8)); // Address High - Wire.write(int(eeprom_address & 0xFF)); // Address Low + Wire.beginTransmission(_eeprom_calc_device_address(pos)); + if (!SMALL_EEPROM) + Wire.write(uint8_t((eeprom_address >> 8) & 0xFF)); // Address High, if needed + Wire.write(uint8_t(eeprom_address & 0xFF)); // Address Low } void eeprom_write_byte(uint8_t *pos, uint8_t value) { @@ -81,7 +94,7 @@ void eeprom_write_byte(uint8_t *pos, uint8_t value) { uint8_t eeprom_read_byte(uint8_t *pos) { _eeprom_begin(pos); Wire.endTransmission(); - Wire.requestFrom(eeprom_device_address, (byte)1); + Wire.requestFrom(_eeprom_calc_device_address(pos), (byte)1); return Wire.available() ? Wire.read() : 0xFF; } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 18bee54009..6134699aa1 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -70,13 +70,13 @@ #if HAS_TFT_LVGL_UI #include "lcd/extui/mks_ui/tft_lvgl_configuration.h" #include "lcd/extui/mks_ui/draw_ui.h" - #include "lcd/extui/mks_ui/mks_hardware_test.h" + #include "lcd/extui/mks_ui/mks_hardware.h" #include #endif #if ENABLED(DWIN_CREALITY_LCD) - #include "lcd/dwin/e3v2/dwin.h" - #include "lcd/dwin/e3v2/rotary_encoder.h" + #include "lcd/e3v2/creality/dwin.h" + #include "lcd/e3v2/creality/rotary_encoder.h" #endif #if ENABLED(EXTENSIBLE_UI) @@ -135,7 +135,7 @@ #include "module/servo.h" #endif -#if ENABLED(HAS_MOTOR_CURRENT_DAC) +#if HAS_MOTOR_CURRENT_DAC #include "feature/dac/stepper_dac.h" #endif @@ -236,6 +236,10 @@ #include "feature/stepper_driver_safety.h" #endif +#if ENABLED(PSU_CONTROL) + #include "feature/power.h" +#endif + PGMSTR(M112_KILL_STR, "M112 Shutdown"); MarlinState marlin_state = MF_INITIALIZING; @@ -282,12 +286,22 @@ bool wait_for_heatup = true; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnarrowing" +#ifndef RUNTIME_ONLY_ANALOG_TO_DIGITAL + template + constexpr pin_t OnlyPins<_SP_END, D...>::table[sizeof...(D)]; +#endif + bool pin_is_protected(const pin_t pin) { - static const pin_t sensitive_pins[] PROGMEM = SENSITIVE_PINS; - LOOP_L_N(i, COUNT(sensitive_pins)) { - pin_t sensitive_pin; - memcpy_P(&sensitive_pin, &sensitive_pins[i], sizeof(pin_t)); - if (pin == sensitive_pin) return true; + #ifdef RUNTIME_ONLY_ANALOG_TO_DIGITAL + static const pin_t sensitive_pins[] PROGMEM = { SENSITIVE_PINS }; + const size_t pincount = COUNT(sensitive_pins); + #else + static constexpr size_t pincount = OnlyPins::size; + static const pin_t (&sensitive_pins)[pincount] PROGMEM = OnlyPins::table; + #endif + LOOP_L_N(i, pincount) { + const pin_t * const pptr = &sensitive_pins[i]; + if (pin == (sizeof(pin_t) == 2 ? (pin_t)pgm_read_word(pptr) : (pin_t)pgm_read_byte(pptr))) return true; } return false; } @@ -414,19 +428,18 @@ void startOrResumeJob() { * - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT) * - Pulse FET_SAFETY_PIN if it exists */ -inline void manage_inactivity(const bool ignore_stepper_queue=false) { +inline void manage_inactivity(const bool no_stepper_sleep=false) { queue.get_available_commands(); const millis_t ms = millis(); - // Prevent steppers timing-out in the middle of M600 - // unless PAUSE_PARK_NO_STEPPER_TIMEOUT is disabled - const bool parked_or_ignoring = ignore_stepper_queue + // Prevent steppers timing-out + const bool do_reset_timeout = no_stepper_sleep || TERN0(PAUSE_PARK_NO_STEPPER_TIMEOUT, did_pause_print); // Reset both the M18/M84 activity timeout and the M85 max 'kill' timeout - if (parked_or_ignoring) gcode.reset_stepper_timeout(ms); + if (do_reset_timeout) gcode.reset_stepper_timeout(ms); if (gcode.stepper_max_timed_out(ms)) { SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr); @@ -442,7 +455,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { // activity timeout and the M85 max 'kill' timeout if (planner.has_blocks_queued()) gcode.reset_stepper_timeout(ms); - else if (!parked_or_ignoring && gcode.stepper_inactive_timeout()) { + else if (!do_reset_timeout && gcode.stepper_inactive_timeout()) { if (!already_shutdown_steppers) { already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this @@ -501,7 +514,6 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL; static millis_t next_home_key_ms; // = 0 if (!IS_SD_PRINTING() && !READ(HOME_PIN)) { // HOME_PIN goes LOW when pressed - const millis_t ms = millis(); if (ELAPSED(ms, next_home_key_ms)) { next_home_key_ms = ms + HOME_DEBOUNCE_DELAY; LCD_MESSAGEPGM(MSG_AUTO_HOME); @@ -513,102 +525,154 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { #if ENABLED(CUSTOM_USER_BUTTONS) // Handle a custom user button if defined const bool printer_not_busy = !printingIsActive(); - #define HAS_CUSTOM_USER_BUTTON(N) (PIN_EXISTS(BUTTON##N) && defined(BUTTON##N##_HIT_STATE) && defined(BUTTON##N##_GCODE) && defined(BUTTON##N##_DESC)) - #define CHECK_CUSTOM_USER_BUTTON(N) do{ \ + #define HAS_CUSTOM_USER_BUTTON(N) (PIN_EXISTS(BUTTON##N) && defined(BUTTON##N##_HIT_STATE) && defined(BUTTON##N##_GCODE)) + #define HAS_BETTER_USER_BUTTON(N) HAS_CUSTOM_USER_BUTTON(N) && defined(BUTTON##N##_DESC) + #define _CHECK_CUSTOM_USER_BUTTON(N, CODE) do{ \ constexpr millis_t CUB_DEBOUNCE_DELAY_##N = 250UL; \ static millis_t next_cub_ms_##N; \ if (BUTTON##N##_HIT_STATE == READ(BUTTON##N##_PIN) \ && (ENABLED(BUTTON##N##_WHEN_PRINTING) || printer_not_busy)) { \ - const millis_t ms = millis(); \ if (ELAPSED(ms, next_cub_ms_##N)) { \ next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \ - if (strlen(BUTTON##N##_DESC)) \ - LCD_MESSAGEPGM_P(PSTR(BUTTON##N##_DESC)); \ + CODE; \ queue.inject_P(PSTR(BUTTON##N##_GCODE)); \ } \ } \ }while(0) - #if HAS_CUSTOM_USER_BUTTON(1) + #define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP) + #define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGEPGM_P(PSTR(BUTTON##N##_DESC))) + + #if HAS_BETTER_USER_BUTTON(1) + CHECK_BETTER_USER_BUTTON(1); + #elif HAS_CUSTOM_USER_BUTTON(1) CHECK_CUSTOM_USER_BUTTON(1); #endif - #if HAS_CUSTOM_USER_BUTTON(2) + #if HAS_BETTER_USER_BUTTON(2) + CHECK_BETTER_USER_BUTTON(2); + #elif HAS_CUSTOM_USER_BUTTON(2) CHECK_CUSTOM_USER_BUTTON(2); #endif - #if HAS_CUSTOM_USER_BUTTON(3) + #if HAS_BETTER_USER_BUTTON(3) + CHECK_BETTER_USER_BUTTON(3); + #elif HAS_CUSTOM_USER_BUTTON(3) CHECK_CUSTOM_USER_BUTTON(3); #endif - #if HAS_CUSTOM_USER_BUTTON(4) + #if HAS_BETTER_USER_BUTTON(4) + CHECK_BETTER_USER_BUTTON(4); + #elif HAS_CUSTOM_USER_BUTTON(4) CHECK_CUSTOM_USER_BUTTON(4); #endif - #if HAS_CUSTOM_USER_BUTTON(5) + #if HAS_BETTER_USER_BUTTON(5) + CHECK_BETTER_USER_BUTTON(5); + #elif HAS_CUSTOM_USER_BUTTON(5) CHECK_CUSTOM_USER_BUTTON(5); #endif - #if HAS_CUSTOM_USER_BUTTON(6) + #if HAS_BETTER_USER_BUTTON(6) + CHECK_BETTER_USER_BUTTON(6); + #elif HAS_CUSTOM_USER_BUTTON(6) CHECK_CUSTOM_USER_BUTTON(6); #endif - #if HAS_CUSTOM_USER_BUTTON(7) + #if HAS_BETTER_USER_BUTTON(7) + CHECK_BETTER_USER_BUTTON(7); + #elif HAS_CUSTOM_USER_BUTTON(7) CHECK_CUSTOM_USER_BUTTON(7); #endif - #if HAS_CUSTOM_USER_BUTTON(8) + #if HAS_BETTER_USER_BUTTON(8) + CHECK_BETTER_USER_BUTTON(8); + #elif HAS_CUSTOM_USER_BUTTON(8) CHECK_CUSTOM_USER_BUTTON(8); #endif - #if HAS_CUSTOM_USER_BUTTON(9) + #if HAS_BETTER_USER_BUTTON(9) + CHECK_BETTER_USER_BUTTON(9); + #elif HAS_CUSTOM_USER_BUTTON(9) CHECK_CUSTOM_USER_BUTTON(9); #endif - #if HAS_CUSTOM_USER_BUTTON(10) + #if HAS_BETTER_USER_BUTTON(10) + CHECK_BETTER_USER_BUTTON(10); + #elif HAS_CUSTOM_USER_BUTTON(10) CHECK_CUSTOM_USER_BUTTON(10); #endif - #if HAS_CUSTOM_USER_BUTTON(11) + #if HAS_BETTER_USER_BUTTON(11) + CHECK_BETTER_USER_BUTTON(11); + #elif HAS_CUSTOM_USER_BUTTON(11) CHECK_CUSTOM_USER_BUTTON(11); #endif - #if HAS_CUSTOM_USER_BUTTON(12) + #if HAS_BETTER_USER_BUTTON(12) + CHECK_BETTER_USER_BUTTON(12); + #elif HAS_CUSTOM_USER_BUTTON(12) CHECK_CUSTOM_USER_BUTTON(12); #endif - #if HAS_CUSTOM_USER_BUTTON(13) + #if HAS_BETTER_USER_BUTTON(13) + CHECK_BETTER_USER_BUTTON(13); + #elif HAS_CUSTOM_USER_BUTTON(13) CHECK_CUSTOM_USER_BUTTON(13); #endif - #if HAS_CUSTOM_USER_BUTTON(14) + #if HAS_BETTER_USER_BUTTON(14) + CHECK_BETTER_USER_BUTTON(14); + #elif HAS_CUSTOM_USER_BUTTON(14) CHECK_CUSTOM_USER_BUTTON(14); #endif - #if HAS_CUSTOM_USER_BUTTON(15) + #if HAS_BETTER_USER_BUTTON(15) + CHECK_BETTER_USER_BUTTON(15); + #elif HAS_CUSTOM_USER_BUTTON(15) CHECK_CUSTOM_USER_BUTTON(15); #endif - #if HAS_CUSTOM_USER_BUTTON(16) + #if HAS_BETTER_USER_BUTTON(16) + CHECK_BETTER_USER_BUTTON(16); + #elif HAS_CUSTOM_USER_BUTTON(16) CHECK_CUSTOM_USER_BUTTON(16); #endif - #if HAS_CUSTOM_USER_BUTTON(17) + #if HAS_BETTER_USER_BUTTON(17) + CHECK_BETTER_USER_BUTTON(17); + #elif HAS_CUSTOM_USER_BUTTON(17) CHECK_CUSTOM_USER_BUTTON(17); #endif - #if HAS_CUSTOM_USER_BUTTON(18) + #if HAS_BETTER_USER_BUTTON(18) + CHECK_BETTER_USER_BUTTON(18); + #elif HAS_CUSTOM_USER_BUTTON(18) CHECK_CUSTOM_USER_BUTTON(18); #endif - #if HAS_CUSTOM_USER_BUTTON(19) + #if HAS_BETTER_USER_BUTTON(19) + CHECK_BETTER_USER_BUTTON(19); + #elif HAS_CUSTOM_USER_BUTTON(19) CHECK_CUSTOM_USER_BUTTON(19); #endif - #if HAS_CUSTOM_USER_BUTTON(20) + #if HAS_BETTER_USER_BUTTON(20) + CHECK_BETTER_USER_BUTTON(20); + #elif HAS_CUSTOM_USER_BUTTON(20) CHECK_CUSTOM_USER_BUTTON(20); #endif - #if HAS_CUSTOM_USER_BUTTON(21) + #if HAS_BETTER_USER_BUTTON(21) + CHECK_BETTER_USER_BUTTON(21); + #elif HAS_CUSTOM_USER_BUTTON(21) CHECK_CUSTOM_USER_BUTTON(21); #endif - #if HAS_CUSTOM_USER_BUTTON(22) + #if HAS_BETTER_USER_BUTTON(22) + CHECK_BETTER_USER_BUTTON(22); + #elif HAS_CUSTOM_USER_BUTTON(22) CHECK_CUSTOM_USER_BUTTON(22); #endif - #if HAS_CUSTOM_USER_BUTTON(23) + #if HAS_BETTER_USER_BUTTON(23) + CHECK_BETTER_USER_BUTTON(23); + #elif HAS_CUSTOM_USER_BUTTON(23) CHECK_CUSTOM_USER_BUTTON(23); #endif - #if HAS_CUSTOM_USER_BUTTON(24) + #if HAS_BETTER_USER_BUTTON(24) + CHECK_BETTER_USER_BUTTON(24); + #elif HAS_CUSTOM_USER_BUTTON(24) CHECK_CUSTOM_USER_BUTTON(24); #endif - #if HAS_CUSTOM_USER_BUTTON(25) + #if HAS_BETTER_USER_BUTTON(25) + CHECK_BETTER_USER_BUTTON(25); + #elif HAS_CUSTOM_USER_BUTTON(25) CHECK_CUSTOM_USER_BUTTON(25); #endif #endif TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down - TERN_(AUTO_POWER_CONTROL, powerManager.check()); + TERN_(AUTO_POWER_CONTROL, powerManager.check(!ui.on_status_screen() || printJobOngoing() || printingIsPaused())); TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check()); @@ -725,14 +789,14 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { * - Update the Průša MMU2 * - Handle Joystick jogging */ -void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { +void idle(bool no_stepper_sleep/*=false*/) { #if ENABLED(MARLIN_DEV_MODE) static uint16_t idle_depth = 0; if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", idle_depth); #endif // Core Marlin activities - manage_inactivity(TERN_(ADVANCED_PAUSE_FEATURE, no_stepper_sleep)); + manage_inactivity(no_stepper_sleep); // Manage Heaters (and Watchdog) thermalManager.manage_heater(); @@ -762,10 +826,8 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { // Run StallGuard endstop checks #if ENABLED(SPI_ENDSTOPS) - if (endstops.tmc_spi_homing.any - && TERN1(IMPROVE_HOMING_RELIABILITY, ELAPSED(millis(), sg_guard_period)) - ) LOOP_L_N(i, 4) // Read SGT 4 times per idle loop - if (endstops.tmc_spi_homing_check()) break; + if (endstops.tmc_spi_homing.any && TERN1(IMPROVE_HOMING_RELIABILITY, ELAPSED(millis(), sg_guard_period))) + LOOP_L_N(i, 4) if (endstops.tmc_spi_homing_check()) break; // Read SGT 4 times per idle loop #endif // Handle SD Card insert / remove @@ -806,6 +868,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick()); TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick()); TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick()); + TERN_(BUFFER_MONITORING, queue.auto_report_buffer_statistics()); } #endif @@ -874,18 +937,18 @@ void minkill(const bool steppers_off/*=false*/) { // Power off all steppers (for M112) or just the E steppers steppers_off ? disable_all_steppers() : disable_e_steppers(); - TERN_(PSU_CONTROL, PSU_OFF()); + TERN_(PSU_CONTROL, powerManager.power_off()); TERN_(HAS_SUICIDE, suicide()); #if EITHER(HAS_KILL, SOFT_RESET_ON_KILL) // Wait for both KILL and ENC to be released - while (TERN0(HAS_KILL, !kill_state()) || TERN0(SOFT_RESET_ON_KILL, !ui.button_pressed())) + while (TERN0(HAS_KILL, kill_state()) || TERN0(SOFT_RESET_ON_KILL, ui.button_pressed())) watchdog_refresh(); - // Wait for either KILL or ENC press - while (TERN1(HAS_KILL, kill_state()) && TERN1(SOFT_RESET_ON_KILL, ui.button_pressed())) + // Wait for either KILL or ENC to be pressed again + while (TERN1(HAS_KILL, !kill_state()) && TERN1(SOFT_RESET_ON_KILL, !ui.button_pressed())) watchdog_refresh(); // Reboot the board @@ -1119,6 +1182,7 @@ void setup() { #endif #if HAS_FREEZE_PIN + SETUP_LOG("FREEZE_PIN"); SET_INPUT_PULLUP(FREEZE_PIN); #endif @@ -1127,34 +1191,35 @@ void setup() { OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING); #endif + #ifdef JTAGSWD_RESET + SETUP_LOG("JTAGSWD_RESET"); + JTAGSWD_RESET(); + #endif + #if EITHER(DISABLE_DEBUG, DISABLE_JTAG) + delay(10); // Disable any hardware debug to free up pins for IO #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE) + SETUP_LOG("JTAGSWD_DISABLE"); JTAGSWD_DISABLE(); #elif defined(JTAG_DISABLE) + SETUP_LOG("JTAG_DISABLE"); JTAG_DISABLE(); #else #error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board." #endif #endif - #if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE) - mks_esp_wifi_init(); - WIFISERIAL.begin(WIFI_BAUDRATE); - serial_connect_timeout = millis() + 1000UL; - while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ } - #endif - TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime SETUP_RUN(HAL_init()); // Init and disable SPI thermocouples; this is still needed - #if TEMP_SENSOR_0_IS_MAX_TC - OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable + #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0)) + OUT_WRITE(TEMP_0_CS_PIN, HIGH); // Disable #endif - #if TEMP_SENSOR_1_IS_MAX_TC - OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable + #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + OUT_WRITE(TEMP_1_CS_PIN, HIGH); #endif #if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) @@ -1171,8 +1236,7 @@ void setup() { #if ENABLED(PSU_CONTROL) SETUP_LOG("PSU_CONTROL"); - powersupply_on = ENABLED(PSU_DEFAULT_OFF); - if (ENABLED(PSU_DEFAULT_OFF)) PSU_OFF(); else PSU_ON(); + powerManager.init(); #endif #if ENABLED(POWER_LOSS_RECOVERY) @@ -1210,9 +1274,7 @@ void setup() { if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); HAL_clear_reset_source(); - SERIAL_ECHOPGM_P(GET_TEXT(MSG_MARLIN)); - SERIAL_CHAR(' '); - SERIAL_ECHOLNPGM(SHORT_BUILD_VERSION); + SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION); SERIAL_EOL(); #if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR) SERIAL_ECHO_MSG( @@ -1248,11 +1310,7 @@ void setup() { // (because EEPROM code calls the UI). #if ENABLED(DWIN_CREALITY_LCD) - delay(800); // Required delay (since boot?) - SERIAL_ECHOPGM("\nDWIN handshake "); - if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error."); - DWIN_Frame_SetDir(1); // Orientation 90° - DWIN_UpdateLCD(); // Show bootscreen (first image) + SETUP_RUN(DWIN_Startup()); #else SETUP_RUN(ui.init()); #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN) @@ -1337,7 +1395,7 @@ void setup() { SETUP_RUN(digipot_i2c.init()); #endif - #if ENABLED(HAS_MOTOR_CURRENT_DAC) + #if HAS_MOTOR_CURRENT_DAC SETUP_RUN(stepper_dac.init()); #endif @@ -1531,7 +1589,7 @@ void setup() { HMI_Init(); DWIN_JPG_CacheTo1(Language_English); HMI_StartFrame(true); - DWIN_StatusChanged(GET_TEXT(WELCOME_MSG)); + DWIN_StatusChanged_P(GET_TEXT(WELCOME_MSG)); #endif #if HAS_SERVICE_INTERVALS && DISABLED(DWIN_CREALITY_LCD) diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index ce1b106bfa..d7ab11d046 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -34,8 +34,8 @@ void stop(); // Pass true to keep steppers from timing out -void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep=false)); -inline void idle_no_sleep() { idle(TERN_(ADVANCED_PAUSE_FEATURE, true)); } +void idle(bool no_stepper_sleep=false); +inline void idle_no_sleep() { idle(true); } #if ENABLED(G38_PROBE_TARGET) extern uint8_t G38_move; // Flag to tell the ISR that G38 is in progress, and the type @@ -81,21 +81,6 @@ extern bool wait_for_heatup; void wait_for_user_response(millis_t ms=0, const bool no_sleep=false); #endif -#if ENABLED(PSU_CONTROL) - extern bool powersupply_on; - #define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_STATE); powersupply_on = true; }while(0) - #define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_STATE); powersupply_on = false; }while(0) - #if ENABLED(AUTO_POWER_CONTROL) - #define PSU_ON() powerManager.power_on() - #define PSU_OFF() powerManager.power_off() - #define PSU_OFF_SOON() powerManager.power_off_soon() - #else - #define PSU_ON() PSU_PIN_ON() - #define PSU_OFF() PSU_PIN_OFF() - #define PSU_OFF_SOON PSU_OFF - #endif -#endif - bool pin_is_protected(const pin_t pin); #if HAS_SUICIDE diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 651df5aedf..ba3c9f978c 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -249,7 +249,7 @@ #define BOARD_BTT_SKR_V1_4_TURBO 2508 // BigTreeTech SKR v1.4 TURBO (Power outputs: Hotend0, Hotend1, Fan, Bed) #define BOARD_MKS_SGEN_L_V2 2509 // MKS SGEN_L V2 (Power outputs: Hotend0, Hotend1, Bed, Fan) #define BOARD_BTT_SKR_E3_TURBO 2510 // BigTreeTech SKR E3 Turbo (Power outputs: Hotend0, Hotend1, Bed, Fan0, Fan1) -#define BOARD_FLY_CDY 2511 // FLY_CDY (Power outputs: Hotend0, Hotend1, Hotend2, Bed, Fan0, Fan1, Fan2) +#define BOARD_FLY_CDY 2511 // FLYmaker FLY CDY (Power outputs: Hotend0, Hotend1, Hotend2, Bed, Fan0, Fan1, Fan2) // // SAM3X8E ARM Cortex M3 @@ -321,7 +321,7 @@ #define BOARD_BTT_SKR_MINI_V1_1 4023 // BigTreeTech SKR Mini v1.1 (STM32F103RC) #define BOARD_BTT_SKR_MINI_E3_V1_0 4024 // BigTreeTech SKR Mini E3 (STM32F103RC) #define BOARD_BTT_SKR_MINI_E3_V1_2 4025 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC) -#define BOARD_BTT_SKR_MINI_E3_V2_0 4026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V2_0 4026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE) #define BOARD_BTT_SKR_MINI_MZ_V1_0 4027 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC) #define BOARD_BTT_SKR_E3_DIP 4028 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) #define BOARD_BTT_SKR_CR6 4029 // BigTreeTech SKR CR6 v1.0 (STM32F103RE) @@ -333,18 +333,19 @@ #define BOARD_CCROBOT_MEEB_3DP 4035 // ccrobot-online.com MEEB_3DP (STM32F103RC) #define BOARD_CHITU3D_V5 4036 // Chitu3D TronXY X5SA V5 Board #define BOARD_CHITU3D_V6 4037 // Chitu3D TronXY X5SA V6 Board -#define BOARD_CREALITY_V4 4038 // Creality v4.x (STM32F103RE) -#define BOARD_CREALITY_V427 4039 // Creality v4.2.7 (STM32F103RE) -#define BOARD_CREALITY_V4210 4040 // Creality v4.2.10 (STM32F103RE) as found in the CR-30 -#define BOARD_CREALITY_V431 4041 // Creality v4.3.1 (STM32F103RE) -#define BOARD_CREALITY_V452 4042 // Creality v4.5.2 (STM32F103RE) -#define BOARD_CREALITY_V453 4043 // Creality v4.5.3 (STM32F103RE) -#define BOARD_TRIGORILLA_PRO 4044 // Trigorilla Pro (STM32F103ZET6) -#define BOARD_FLY_MINI 4045 // FLY MINI (STM32F103RCT6) -#define BOARD_FLSUN_HISPEED 4046 // FLSUN HiSpeedV1 (STM32F103VET6) -#define BOARD_BEAST 4047 // STM32F103RET6 Libmaple-based controller -#define BOARD_MINGDA_MPX_ARM_MINI 4048 // STM32F103ZET6 Mingda MD-16 -#define BOARD_GTM32_PRO_VD 4049 // STM32F103VET6 controller +#define BOARD_CHITU3D_V9 4038 // Chitu3D TronXY X5SA V9 Board +#define BOARD_CREALITY_V4 4039 // Creality v4.x (STM32F103RE) +#define BOARD_CREALITY_V427 4040 // Creality v4.2.7 (STM32F103RE) +#define BOARD_CREALITY_V4210 4041 // Creality v4.2.10 (STM32F103RE) as found in the CR-30 +#define BOARD_CREALITY_V431 4042 // Creality v4.3.1 (STM32F103RE) +#define BOARD_CREALITY_V452 4043 // Creality v4.5.2 (STM32F103RE) +#define BOARD_CREALITY_V453 4044 // Creality v4.5.3 (STM32F103RE) +#define BOARD_TRIGORILLA_PRO 4045 // Trigorilla Pro (STM32F103ZET6) +#define BOARD_FLY_MINI 4046 // FLYmaker FLY MINI (STM32F103RCT6) +#define BOARD_FLSUN_HISPEED 4047 // FLSUN HiSpeedV1 (STM32F103VET6) +#define BOARD_BEAST 4048 // STM32F103RET6 Libmaple-based controller +#define BOARD_MINGDA_MPX_ARM_MINI 4049 // STM32F103ZET6 Mingda MD-16 +#define BOARD_GTM32_PRO_VD 4050 // STM32F103VET6 controller // // ARM Cortex-M4F @@ -380,14 +381,14 @@ #define BOARD_FYSETC_S6 4220 // FYSETC S6 (STM32F446VET6) #define BOARD_FYSETC_S6_V2_0 4221 // FYSETC S6 v2.0 (STM32F446VET6) #define BOARD_FYSETC_SPIDER 4222 // FYSETC Spider (STM32F446VET6) -#define BOARD_FLYF407ZG 4223 // FLYF407ZG (STM32F407ZG) +#define BOARD_FLYF407ZG 4223 // FLYmaker FLYF407ZG (STM32F407ZG) #define BOARD_MKS_ROBIN2 4224 // MKS_ROBIN2 (STM32F407ZE) #define BOARD_MKS_ROBIN_PRO_V2 4225 // MKS Robin Pro V2 (STM32F407VE) #define BOARD_MKS_ROBIN_NANO_V3 4226 // MKS Robin Nano V3 (STM32F407VG) -#define BOARD_ANET_ET4 4227 // ANET ET4 V1.x (STM32F407VGT6) -#define BOARD_ANET_ET4P 4228 // ANET ET4P V1.x (STM32F407VGT6) -#define BOARD_FYSETC_CHEETAH_V20 4229 // FYSETC Cheetah V2.0 - +#define BOARD_MKS_MONSTER8 4227 // MKS Monster8 (STM32F407VGT6) +#define BOARD_ANET_ET4 4228 // ANET ET4 V1.x (STM32F407VGT6) +#define BOARD_ANET_ET4P 4229 // ANET ET4P V1.x (STM32F407VGT6) +#define BOARD_FYSETC_CHEETAH_V20 4230 // FYSETC Cheetah V2.0 // // ARM Cortex M7 diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 8e97ec66a9..8de8397593 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -231,6 +231,9 @@ #define STR_HEATER_BED "bed" #define STR_HEATER_CHAMBER "chamber" #define STR_COOLER "cooler" +#define STR_MOTHERBOARD "motherboard" +#define STR_PROBE "probe" +#define STR_REDUNDANT "redundant " #define STR_LASER_TEMP "laser temperature" #define STR_STOPPED_HEATER ", system stopped! Heater_ID: " diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index dc6147adb0..abcd7b9480 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -36,15 +36,15 @@ #define _XMIN_ 100 #define _YMIN_ 200 #define _ZMIN_ 300 -#define _IMIN_ 400 -#define _JMIN_ 500 -#define _KMIN_ 600 +#define _IMIN_ 500 +#define _JMIN_ 600 +#define _KMIN_ 700 #define _XMAX_ 101 #define _YMAX_ 201 #define _ZMAX_ 301 -#define _IMAX_ 401 -#define _JMAX_ 501 -#define _KMAX_ 601 +#define _IMAX_ 501 +#define _JMAX_ 601 +#define _KMAX_ 701 #define _XDIAG_ 102 #define _YDIAG_ 202 #define _ZDIAG_ 302 @@ -204,8 +204,8 @@ #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. -#define _OPTARG(A) , A -#define OPTARG(O,A) TERN_(O,DEFER4(_OPTARG)(A)) +#define _OPTARG(A...) , A +#define OPTARG(O,A...) TERN_(O,DEFER4(_OPTARG)(A)) #define _OPTCODE(A) A; #define OPTCODE(O,A) TERN_(O,DEFER4(_OPTCODE)(A)) @@ -442,7 +442,7 @@ return contains(str, '/') ? findLastPos(findStringEnd(str), '/') : str; } - // Find the first occurence of a character in a string (or return the last position in the string) + // Find the first occurrence of a character in a string (or return the last position in the string) constexpr const char* findFirst(const char *str, const char ch) { return *str == ch || *str == 0 ? (str + 1) : findFirst(str + 1, ch); } diff --git a/Marlin/src/core/multi_language.h b/Marlin/src/core/multi_language.h index 5a26edf8d4..1eaef69305 100644 --- a/Marlin/src/core/multi_language.h +++ b/Marlin/src/core/multi_language.h @@ -42,15 +42,12 @@ typedef const char Language_Str[]; #ifndef LCD_LANGUAGE_2 #define LCD_LANGUAGE_2 LCD_LANGUAGE #endif - #ifndef LCD_LANGUAGE_3 #define LCD_LANGUAGE_3 LCD_LANGUAGE_2 #endif - #ifndef LCD_LANGUAGE_4 #define LCD_LANGUAGE_4 LCD_LANGUAGE_3 #endif - #ifndef LCD_LANGUAGE_5 #define LCD_LANGUAGE_5 LCD_LANGUAGE_4 #endif diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index a5afb9d895..7ceb70c22c 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -67,7 +67,7 @@ extern uint8_t marlin_debug_flags; // Serial redirection // // Step 1: Find out what the first serial leaf is -#if BOTH(HAS_MULTI_SERIAL, SERIAL_CATCHALL) +#if HAS_MULTI_SERIAL && defined(SERIAL_CATCHALL) #define _SERIAL_LEAF_1 MYSERIAL #else #define _SERIAL_LEAF_1 MYSERIAL1 @@ -304,6 +304,9 @@ void serial_echopair_PGM(PGM_P const s_P, unsigned int v); void serial_echopair_PGM(PGM_P const s_P, unsigned long v); inline void serial_echopair_PGM(PGM_P const s_P, bool v) { serial_echopair_PGM(s_P, (int)v); } inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (uintptr_t)v); } +#if __INTPTR_WIDTH__ != __SIZE_WIDTH__ + inline void serial_echopair_PGM(PGM_P const s_P, size_t v) { serial_echopair_PGM(s_P, (long int)v); } +#endif void serial_echo_start(); void serial_error_start(); diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index f8b5cef77b..833167a7a1 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -83,7 +83,7 @@ enum AxisEnum : uint8_t { #undef _EN_ITEM // Core also keeps toolhead directions - #if IS_CORE + #if EITHER(IS_CORE, MARKFORGED_XY) , X_HEAD, Y_HEAD, Z_HEAD #endif diff --git a/Marlin/src/feature/ammeter.cpp b/Marlin/src/feature/ammeter.cpp new file mode 100644 index 0000000000..71b84f1121 --- /dev/null +++ b/Marlin/src/feature/ammeter.cpp @@ -0,0 +1,54 @@ +/** + * 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(I2C_AMMETER) + +#include "ammeter.h" + +#ifndef I2C_AMMETER_IMAX + #define I2C_AMMETER_IMAX 0.500 // Calibration range 500 Milliamps +#endif + +INA226 ina; + +Ammeter ammeter; + +float Ammeter::scale; +float Ammeter::current; + +void Ammeter::init() { + ina.begin(); + ina.configure(INA226_AVERAGES_16, INA226_BUS_CONV_TIME_1100US, INA226_SHUNT_CONV_TIME_1100US, INA226_MODE_SHUNT_BUS_CONT); + ina.calibrate(I2C_AMMETER_SHUNT_RESISTOR, I2C_AMMETER_IMAX); +} + +float Ammeter::read() { + scale = 1; + current = ina.readShuntCurrent(); + if (current <= 0.0001f) current = 0; // Clean up least-significant-bit amplification errors + if (current < 0.1f) scale = 1000; + return current * scale; +} + +#endif // I2C_AMMETER diff --git a/Marlin/src/feature/ammeter.h b/Marlin/src/feature/ammeter.h new file mode 100644 index 0000000000..86f09bb9a1 --- /dev/null +++ b/Marlin/src/feature/ammeter.h @@ -0,0 +1,39 @@ +/** + * 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" + +#include +#include + +class Ammeter { +private: + static float scale; + +public: + static float current; + static void init(); + static float read(); +}; + +extern Ammeter ammeter; diff --git a/Marlin/src/feature/bedlevel/bedlevel.h b/Marlin/src/feature/bedlevel/bedlevel.h index 9bab2fbd2f..63f032eee8 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.h +++ b/Marlin/src/feature/bedlevel/bedlevel.h @@ -24,7 +24,7 @@ #include "../../inc/MarlinConfigPre.h" #if EITHER(RESTORE_LEVELING_AFTER_G28, ENABLE_LEVELING_AFTER_G28) - #define G28_L0_ENSURES_LEVELING_OFF 1 + #define CAN_SET_LEVELING_AFTER_G28 1 #endif #if ENABLED(PROBE_MANUALLY) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index b7a2c380ce..37c8be5bd8 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -164,7 +164,7 @@ static void serial_echo_column_labels(const uint8_t sp) { * 2: TODO: Display on Graphical LCD * 4: Compact Human-Readable */ -void unified_bed_leveling::display_map(const int map_type) { +void unified_bed_leveling::display_map(const uint8_t map_type) { const bool was = gcode.set_autoreport_paused(true); constexpr uint8_t eachsp = 1 + 6 + 1, // [-3.567] @@ -263,7 +263,7 @@ bool unified_bed_leveling::sanity_check() { void GcodeSuite::M1004() { #define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34", "") - #define PROBE_GCODE TERN(HAS_BED_PROBE, "G29P1\nG29P3", "G29P4R255") + #define PROBE_GCODE TERN(HAS_BED_PROBE, "G29P1\nG29P3", "G29P4R") #if HAS_HOTEND if (parser.seenval('H')) { // Handle H# parameter to set Hotend temp diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index 562f15f74b..cf00a282cf 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -47,10 +47,10 @@ struct mesh_index_pair; typedef struct { bool C_seen; - int8_t V_verbosity, + int8_t KLS_storage_slot; + uint8_t R_repetition, + V_verbosity, P_phase, - R_repetition, - KLS_storage_slot, T_map_type; float B_shim_thickness, C_constant; @@ -98,7 +98,7 @@ public: static void report_state(); static void save_ubl_active_state_and_disable(); static void restore_ubl_active_state_and_leave(); - static void display_map(const int) _O0; + static void display_map(const uint8_t) _O0; static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0; static mesh_index_pair find_furthest_invalid_mesh_point() _O0; static void reset(); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index b5773b0d46..f8e446cf81 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -305,9 +305,9 @@ void unified_bed_leveling::G29() { bool probe_deployed = false; if (G29_parse_parameters()) return; // Abort on parameter error - const int8_t p_val = parser.intval('P', -1); + const uint8_t p_val = parser.byteval('P'); const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen_test('J'); - #if ENABLED(HAS_MULTI_HOTEND) + #if HAS_MULTI_HOTEND const uint8_t old_tool_index = active_extruder; #endif @@ -321,7 +321,7 @@ void unified_bed_leveling::G29() { // Invalidate one or more nearby mesh points, possibly all. if (parser.seen('I')) { - int16_t count = parser.has_value() ? parser.value_int() : 1; + uint8_t count = parser.has_value() ? parser.value_byte() : 1; bool invalidate_all = count >= GRID_MAX_POINTS; if (!invalidate_all) { while (count--) { @@ -345,7 +345,7 @@ void unified_bed_leveling::G29() { } if (parser.seen('Q')) { - const int test_pattern = parser.has_value() ? parser.value_int() : -99; + const int16_t test_pattern = parser.has_value() ? parser.value_int() : -99; if (!WITHIN(test_pattern, -1, 2)) { SERIAL_ECHOLNPGM("Invalid test_pattern value. (-1 to 2)\n"); return; @@ -592,7 +592,7 @@ void unified_bed_leveling::G29() { // if (parser.seen('L')) { // Load Current Mesh Data - param.KLS_storage_slot = parser.has_value() ? parser.value_int() : storage_slot; + param.KLS_storage_slot = parser.has_value() ? (int8_t)parser.value_int() : storage_slot; int16_t a = settings.calc_num_meshes(); @@ -617,10 +617,10 @@ void unified_bed_leveling::G29() { // if (parser.seen('S')) { // Store (or Save) Current Mesh Data - param.KLS_storage_slot = parser.has_value() ? parser.value_int() : storage_slot; + param.KLS_storage_slot = parser.has_value() ? (int8_t)parser.value_int() : storage_slot; - if (param.KLS_storage_slot == -1) // Special case, the user wants to 'Export' the mesh to the - return report_current_mesh(); // host program to be saved on the user's computer + if (param.KLS_storage_slot == -1) // Special case: 'Export' the mesh to the + return report_current_mesh(); // host so it can be saved in a file. int16_t a = settings.calc_num_meshes(); @@ -673,7 +673,7 @@ void unified_bed_leveling::G29() { */ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t offset) { float sum = 0; - int n = 0; + uint8_t n = 0; GRID_LOOP(x, y) if (!isnan(z_values[x][y])) { sum += z_values[x][y]; @@ -734,7 +734,7 @@ void unified_bed_leveling::shift_mesh_height() { do { if (do_ubl_mesh_map) display_map(param.T_map_type); - const int point_num = (GRID_MAX_POINTS) - count + 1; + const uint8_t point_num = (GRID_MAX_POINTS - count) + 1; SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, "."); TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS))); @@ -916,11 +916,11 @@ void set_message_with_feedback(PGM_P const msg_P) { if (do_ubl_mesh_map) display_map(param.T_map_type); // Show user where we're probing if (parser.seen_test('B')) { - SERIAL_ECHOPGM_P(GET_TEXT(MSG_UBL_BC_INSERT)); + SERIAL_ECHOPGM("Place Shim & Measure"); LCD_MESSAGEPGM(MSG_UBL_BC_INSERT); } else { - SERIAL_ECHOPGM_P(GET_TEXT(MSG_UBL_BC_INSERT2)); + SERIAL_ECHOPGM("Measure"); LCD_MESSAGEPGM(MSG_UBL_BC_INSERT2); } @@ -1025,7 +1025,7 @@ void set_message_with_feedback(PGM_P const msg_P) { SET_SOFT_ENDSTOP_LOOSE(true); do { - idle(); + idle_no_sleep(); new_z = ui.ubl_mesh_value(); TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited SERIAL_FLUSH(); // Prevent host M105 buffer overrun. @@ -1083,7 +1083,7 @@ bool unified_bed_leveling::G29_parse_parameters() { param.R_repetition = 0; if (parser.seen('R')) { - param.R_repetition = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS; + param.R_repetition = parser.has_value() ? parser.value_byte() : GRID_MAX_POINTS; NOMORE(param.R_repetition, GRID_MAX_POINTS); if (param.R_repetition < 1) { SERIAL_ECHOLNPGM("?(R)epetition count invalid (1+).\n"); @@ -1091,14 +1091,14 @@ bool unified_bed_leveling::G29_parse_parameters() { } } - param.V_verbosity = parser.intval('V'); + param.V_verbosity = parser.byteval('V'); if (!WITHIN(param.V_verbosity, 0, 4)) { SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).\n"); err_flag = true; } if (parser.seen('P')) { - const int pv = parser.value_int(); + const uint8_t pv = parser.value_byte(); #if !HAS_BED_PROBE if (pv == 1) { SERIAL_ECHOLNPGM("G29 P1 requires a probe.\n"); @@ -1181,7 +1181,7 @@ bool unified_bed_leveling::G29_parse_parameters() { } #endif - param.T_map_type = parser.intval('T'); + param.T_map_type = parser.byteval('T'); if (!WITHIN(param.T_map_type, 0, 2)) { SERIAL_ECHOLNPGM("Invalid map type.\n"); return UBL_ERR; @@ -1833,7 +1833,7 @@ void unified_bed_leveling::smart_fill_mesh() { return; } - param.KLS_storage_slot = parser.value_int(); + param.KLS_storage_slot = (int8_t)parser.value_int(); float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; settings.load_mesh(param.KLS_storage_slot, &tmp_z_values); diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index 9eb151b27f..2ad7f236a1 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -24,9 +24,11 @@ #include "../inc/MarlinConfig.h" #define BINARY_STREAM_COMPRESSION - #if ENABLED(BINARY_STREAM_COMPRESSION) #include "../libs/heatshrink/heatshrink_decoder.h" + // STM32 (and others?) require a word-aligned buffer for SD card transfers via DMA + static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {}; + static heatshrink_decoder hsd; #endif inline bool bs_serial_data_available(const serial_index_t index) { @@ -37,16 +39,6 @@ inline int bs_read_serial(const serial_index_t index) { return SERIAL_IMPL.read(index); } -#if ENABLED(BINARY_STREAM_COMPRESSION) - static heatshrink_decoder hsd; - #if BOTH(ARDUINO_ARCH_STM32F1, SDIO_SUPPORT) - // STM32 requires a word-aligned buffer for SD card transfers via DMA - static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {}; - #else - static uint8_t decode_buffer[512] = {}; - #endif -#endif - class SDFileTransferProtocol { private: struct Packet { diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 0206467752..35f567fa8f 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -76,9 +76,14 @@ void ControllerFan::update() { ) ); - // If any of the drivers or the heated bed are enabled... - if (motor_on || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0)) - lastMotorOn = ms; //... set time to NOW so the fan will turn on + // If any triggers for the controller fan are true... + // - At least one stepper driver is enabled + // - The heated bed is enabled + // - TEMP_SENSOR_BOARD is reporting >= CONTROLLER_FAN_MIN_BOARD_TEMP + if ( motor_on + || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0) + || TERN0(HAS_CONTROLLER_FAN_MIN_BOARD_TEMP, thermalManager.wholeDegBoard() >= CONTROLLER_FAN_MIN_BOARD_TEMP) + ) lastMotorOn = ms; //... set time to NOW so the fan will turn on // Fan Settings. Set fan > 0: // - If AutoMode is on and steppers have been enabled for CONTROLLERFAN_IDLE_TIME seconds. diff --git a/Marlin/src/feature/cooler.cpp b/Marlin/src/feature/cooler.cpp index a1f25c5fad..e0f99777d1 100644 --- a/Marlin/src/feature/cooler.cpp +++ b/Marlin/src/feature/cooler.cpp @@ -22,26 +22,27 @@ #include "../inc/MarlinConfig.h" -#if HAS_COOLER +#if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER) #include "cooler.h" Cooler cooler; -uint8_t Cooler::mode = 0; -uint16_t Cooler::capacity; -uint16_t Cooler::load; -bool Cooler::enabled = false; +#if HAS_COOLER + uint8_t Cooler::mode = 0; + uint16_t Cooler::capacity; + uint16_t Cooler::load; + bool Cooler::enabled = false; +#endif #if ENABLED(LASER_COOLANT_FLOW_METER) bool Cooler::flowmeter = false; millis_t Cooler::flowmeter_next_ms; // = 0 volatile uint16_t Cooler::flowpulses; float Cooler::flowrate; + #if ENABLED(FLOWMETER_SAFETY) + bool Cooler::flowsafety_enabled = true; + bool Cooler::flowfault = false; + #endif #endif -#if ENABLED(FLOWMETER_SAFETY) - bool Cooler::flowsafety_enabled = true; - bool Cooler::fault = false; -#endif - -#endif // HAS_COOLER +#endif // HAS_COOLER || LASER_COOLANT_FLOW_METER diff --git a/Marlin/src/feature/cooler.h b/Marlin/src/feature/cooler.h index 9bd98d0b10..9891514e23 100644 --- a/Marlin/src/feature/cooler.h +++ b/Marlin/src/feature/cooler.h @@ -94,12 +94,12 @@ public: } #if ENABLED(FLOWMETER_SAFETY) - static bool fault; // Flag that the cooler is in a fault state - static bool flowsafety_enabled; // Flag to disable the cutter if flow rate is too low + static bool flowfault; // Flag that the cooler is in a fault state + static bool flowsafety_enabled; // Flag to disable the cutter if flow rate is too low static void flowsafety_toggle() { flowsafety_enabled = !flowsafety_enabled; } static bool check_flow_too_low() { const bool too_low = flowsafety_enabled && flowrate < (FLOWMETER_MIN_LITERS_PER_MINUTE); - if (too_low) fault = true; + flowfault = too_low; return too_low; } #endif diff --git a/Marlin/src/feature/dac/dac_mcp4728.cpp b/Marlin/src/feature/dac/dac_mcp4728.cpp index ddbaced086..1278d1bec8 100644 --- a/Marlin/src/feature/dac/dac_mcp4728.cpp +++ b/Marlin/src/feature/dac/dac_mcp4728.cpp @@ -32,7 +32,7 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(HAS_MOTOR_CURRENT_DAC) +#if HAS_MOTOR_CURRENT_DAC #include "dac_mcp4728.h" diff --git a/Marlin/src/feature/dac/stepper_dac.cpp b/Marlin/src/feature/dac/stepper_dac.cpp index 1cb0813daa..6d03808b82 100644 --- a/Marlin/src/feature/dac/stepper_dac.cpp +++ b/Marlin/src/feature/dac/stepper_dac.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(HAS_MOTOR_CURRENT_DAC) +#if HAS_MOTOR_CURRENT_DAC #include "stepper_dac.h" #include "../../MarlinCore.h" // for SP_X_LBL... @@ -85,10 +85,16 @@ void StepperDAC::print_values() { if (!dac_present) return; SERIAL_ECHO_MSG("Stepper current values in % (Amps):"); SERIAL_ECHO_START(); - SERIAL_ECHOPAIR_P( SP_X_LBL, dac_perc(X_AXIS), PSTR(" ("), dac_amps(X_AXIS), PSTR(")")); - SERIAL_ECHOPAIR_P( SP_Y_LBL, dac_perc(Y_AXIS), PSTR(" ("), dac_amps(Y_AXIS), PSTR(")")); - SERIAL_ECHOPAIR_P( SP_Z_LBL, dac_perc(Z_AXIS), PSTR(" ("), dac_amps(Z_AXIS), PSTR(")")); - SERIAL_ECHOLNPAIR_P(SP_E_LBL, dac_perc(E_AXIS), PSTR(" ("), dac_amps(E_AXIS), PSTR(")")); + SERIAL_ECHOPAIR_P(SP_X_LBL, dac_perc(X_AXIS), PSTR(" ("), dac_amps(X_AXIS), PSTR(")")); + #if HAS_Y_AXIS + SERIAL_ECHOPAIR_P(SP_Y_LBL, dac_perc(Y_AXIS), PSTR(" ("), dac_amps(Y_AXIS), PSTR(")")); + #endif + #if HAS_Z_AXIS + SERIAL_ECHOPAIR_P(SP_Z_LBL, dac_perc(Z_AXIS), PSTR(" ("), dac_amps(Z_AXIS), PSTR(")")); + #endif + #if HAS_EXTRUDERS + SERIAL_ECHOLNPAIR_P(SP_E_LBL, dac_perc(E_AXIS), PSTR(" ("), dac_amps(E_AXIS), PSTR(")")); + #endif } void StepperDAC::commit_eeprom() { diff --git a/Marlin/src/feature/joystick.h b/Marlin/src/feature/joystick.h index d1c4fbd314..91bf6bdc00 100644 --- a/Marlin/src/feature/joystick.h +++ b/Marlin/src/feature/joystick.h @@ -32,13 +32,13 @@ class Joystick { friend class Temperature; private: - #if ENABLED(HAS_JOY_ADC_X) + #if HAS_JOY_ADC_X static temp_info_t x; #endif - #if ENABLED(HAS_JOY_ADC_Y) + #if HAS_JOY_ADC_Y static temp_info_t y; #endif - #if ENABLED(HAS_JOY_ADC_Z) + #if HAS_JOY_ADC_Z static temp_info_t z; #endif public: diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index e577948cd8..b2c16459f5 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -114,7 +114,6 @@ public: #if CONJOINED_NEOPIXEL adaneo2.show(); #else - IF_DISABLED(NEOPIXEL2_SEPARATE, adaneo1.setPin(NEOPIXEL2_PIN)); adaneo1.show(); adaneo1.setPin(NEOPIXEL_PIN); #endif diff --git a/Marlin/src/feature/leds/pca9533.cpp b/Marlin/src/feature/leds/pca9533.cpp index 0fd4d66757..914db21ba3 100644 --- a/Marlin/src/feature/leds/pca9533.cpp +++ b/Marlin/src/feature/leds/pca9533.cpp @@ -36,7 +36,7 @@ void PCA9533_init() { PCA9533_reset(); } -static void PCA9533_writeAllRegisters(uint8_t psc0, uint8_t pwm0, uint8_t psc1, uint8_t pwm1, uint8_t ls0){ +static void PCA9533_writeAllRegisters(uint8_t psc0, uint8_t pwm0, uint8_t psc1, uint8_t pwm1, uint8_t ls0) { uint8_t data[6] = { PCA9533_REG_PSC0 | PCA9533_REGM_AI, psc0, pwm0, psc1, pwm1, ls0 }; Wire.beginTransmission(PCA9533_Addr >> 1); Wire.write(data, 6); @@ -44,7 +44,7 @@ static void PCA9533_writeAllRegisters(uint8_t psc0, uint8_t pwm0, uint8_t psc1, delayMicroseconds(1); } -static void PCA9533_writeRegister(uint8_t reg, uint8_t val){ +static void PCA9533_writeRegister(uint8_t reg, uint8_t val) { uint8_t data[2] = { reg, val }; Wire.beginTransmission(PCA9533_Addr >> 1); Wire.write(data, 2); diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 8a4f5ae071..1acd26f331 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -75,7 +75,7 @@ MMU2 mmu2; #define MMU2_NO_TOOL 99 #define MMU_BAUD 115200 -bool MMU2::enabled, MMU2::ready, MMU2::mmu_print_saved; +bool MMU2::_enabled, MMU2::ready, MMU2::mmu_print_saved; #if HAS_PRUSA_MMU2S bool MMU2::mmu2s_triggered; #endif @@ -219,7 +219,7 @@ void MMU2::mmu_loop() { DEBUG_ECHOLNPAIR("MMU => ", finda, "\nMMU - ENABLED"); - enabled = true; + _enabled = true; state = 1; TERN_(HAS_PRUSA_MMU2S, mmu2s_triggered = false); } @@ -480,7 +480,7 @@ static void mmu2_not_responding() { */ void MMU2::tool_change(const uint8_t index) { - if (!enabled) return; + if (!_enabled) return; set_runout_valid(false); @@ -512,7 +512,7 @@ static void mmu2_not_responding() { * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ void MMU2::tool_change(const char *special) { - if (!enabled) return; + if (!_enabled) return; set_runout_valid(false); @@ -561,7 +561,7 @@ static void mmu2_not_responding() { * Handle tool change */ void MMU2::tool_change(const uint8_t index) { - if (!enabled) return; + if (!_enabled) return; set_runout_valid(false); @@ -599,7 +599,7 @@ static void mmu2_not_responding() { * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ void MMU2::tool_change(const char *special) { - if (!enabled) return; + if (!_enabled) return; set_runout_valid(false); @@ -665,7 +665,7 @@ static void mmu2_not_responding() { * Handle tool change */ void MMU2::tool_change(const uint8_t index) { - if (!enabled) return; + if (!_enabled) return; set_runout_valid(false); @@ -693,7 +693,7 @@ static void mmu2_not_responding() { * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ void MMU2::tool_change(const char *special) { - if (!enabled) return; + if (!_enabled) return; set_runout_valid(false); @@ -744,7 +744,7 @@ static void mmu2_not_responding() { * Set next command */ void MMU2::command(const uint8_t mmu_cmd) { - if (!enabled) return; + if (!_enabled) return; cmd = mmu_cmd; ready = false; } @@ -833,7 +833,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { } void MMU2::set_filament_type(const uint8_t index, const uint8_t filamentType) { - if (!enabled) return; + if (!_enabled) return; cmd_arg = filamentType; command(MMU_CMD_F0 + index); @@ -892,7 +892,7 @@ void MMU2::filament_runout() { // Load filament into MMU2 void MMU2::load_filament(const uint8_t index) { - if (!enabled) return; + if (!_enabled) return; command(MMU_CMD_L0 + index); manage_response(false, false); @@ -904,7 +904,7 @@ void MMU2::load_filament(const uint8_t index) { */ bool MMU2::load_filament_to_nozzle(const uint8_t index) { - if (!enabled) return false; + if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { BUZZ(200, 404); @@ -940,7 +940,7 @@ void MMU2::load_to_nozzle() { bool MMU2::eject_filament(const uint8_t index, const bool recover) { - if (!enabled) return false; + if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { BUZZ(200, 404); @@ -989,7 +989,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { */ bool MMU2::unload() { - if (!enabled) return false; + if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { BUZZ(200, 404); diff --git a/Marlin/src/feature/mmu/mmu2.h b/Marlin/src/feature/mmu/mmu2.h index 079a6ef79a..95338a5184 100644 --- a/Marlin/src/feature/mmu/mmu2.h +++ b/Marlin/src/feature/mmu/mmu2.h @@ -43,6 +43,7 @@ public: static void init(); static void reset(); + static inline bool enabled() { return _enabled; } static void mmu_loop(); static void tool_change(const uint8_t index); static void tool_change(const char *special); @@ -88,7 +89,7 @@ private: static void mmu_continue_loading(); #endif - static bool enabled, ready, mmu_print_saved; + static bool _enabled, ready, mmu_print_saved; static uint8_t cmd, cmd_arg, last_cmd, extruder; static int8_t state; diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 2bd3033808..94c564a9aa 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -535,8 +535,8 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT); HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), CONTINUE_STR)); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Reheat finished."))); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_REHEATDONE), CONTINUE_STR)); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_REHEATDONE))); wait_for_user = true; nozzle_timed_out = false; diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index fb2f1312e0..b86249fbc0 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -26,123 +26,195 @@ #include "../inc/MarlinConfig.h" -#if ENABLED(AUTO_POWER_CONTROL) - #include "power.h" -#include "../module/temperature.h" #include "../module/stepper/indirection.h" #include "../MarlinCore.h" +#if ENABLED(PS_OFF_SOUND) + #include "../libs/buzzer.h" +#endif + #if defined(PSU_POWERUP_GCODE) || defined(PSU_POWEROFF_GCODE) #include "../gcode/gcode.h" #endif -#if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN) - #include "controllerfan.h" -#endif +#if EITHER(PSU_CONTROL, AUTO_POWER_CONTROL) Power powerManager; +bool Power::psu_on; -millis_t Power::lastPowerOn; - -bool Power::is_power_needed() { - #if ENABLED(AUTO_POWER_FANS) - FANS_LOOP(i) if (thermalManager.fan_speed[i]) return true; - #endif - - #if ENABLED(AUTO_POWER_E_FANS) - HOTEND_LOOP() if (thermalManager.autofan_speed[e]) return true; - #endif +#if ENABLED(AUTO_POWER_CONTROL) + #include "../module/temperature.h" #if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN) - if (controllerFan.state()) return true; + #include "controllerfan.h" #endif - if (TERN0(AUTO_POWER_CHAMBER_FAN, thermalManager.chamberfan_speed)) - return true; - - if (TERN0(AUTO_POWER_COOLER_FAN, thermalManager.coolerfan_speed)) - return true; - - // If any of the drivers or the bed are enabled... - if (X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON || Z_ENABLE_READ() == Z_ENABLE_ON - #if HAS_X2_ENABLE - || X2_ENABLE_READ() == X_ENABLE_ON - #endif - #if HAS_Y2_ENABLE - || Y2_ENABLE_READ() == Y_ENABLE_ON - #endif - #if HAS_Z2_ENABLE - || Z2_ENABLE_READ() == Z_ENABLE_ON - #endif - #if E_STEPPERS - #define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == E_ENABLE_ON - REPEAT(E_STEPPERS, _OR_ENABLED_E) - #endif - ) return true; - - HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0 || thermalManager.temp_hotend[e].soft_pwm_amount > 0) return true; - 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; - #endif - - #if HAS_HEATED_CHAMBER && AUTO_POWER_CHAMBER_TEMP - if (thermalManager.degChamber() >= (AUTO_POWER_CHAMBER_TEMP)) return true; - #endif - - #if HAS_COOLER && AUTO_POWER_COOLER_TEMP - if (thermalManager.degCooler() >= (AUTO_POWER_COOLER_TEMP)) return true; - #endif - - return false; -} - -#ifndef POWER_TIMEOUT - #define POWER_TIMEOUT 0 + millis_t Power::lastPowerOn; #endif -void Power::check() { - static millis_t nextPowerCheck = 0; - millis_t ms = millis(); - if (ELAPSED(ms, nextPowerCheck)) { - nextPowerCheck = ms + 2500UL; - if (is_power_needed()) - power_on(); - else if (!lastPowerOn || (POWER_TIMEOUT > 0 && ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT)))) - power_off(); - } +/** + * Initialize pins & state for the power manager. + * + */ +void Power::init() { + psu_on = ENABLED(PSU_DEFAULT_OFF); // Set opposite state to get full power_off/on + TERN(PSU_DEFAULT_OFF, power_off(), power_on()); } +/** + * Power on if the power is currently off. + * Restores stepper drivers and processes any PSU_POWERUP_GCODE. + * + */ void Power::power_on() { - lastPowerOn = millis(); - if (!powersupply_on) { - PSU_PIN_ON(); - safe_delay(PSU_POWERUP_DELAY); - restore_stepper_drivers(); - TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY)); - #ifdef PSU_POWERUP_GCODE - GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWERUP_GCODE)); - #endif - } -} + #if ENABLED(AUTO_POWER_CONTROL) + const millis_t now = millis(); + lastPowerOn = now + !now; + #endif -void Power::power_off() { - if (powersupply_on) { - #ifdef PSU_POWEROFF_GCODE - GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWEROFF_GCODE)); - #endif - PSU_PIN_OFF(); - } -} + if (psu_on) return; -void Power::power_off_soon() { - #if POWER_OFF_DELAY - lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY); - #else - power_off(); + OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_STATE); + psu_on = true; + safe_delay(PSU_POWERUP_DELAY); + restore_stepper_drivers(); + TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY)); + + #ifdef PSU_POWERUP_GCODE + GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWERUP_GCODE)); #endif } +/** + * Power off if the power is currently on. + * Processes any PSU_POWEROFF_GCODE and makes a PS_OFF_SOUND if enabled. + * + */ +void Power::power_off() { + if (!psu_on) return; + + #ifdef PSU_POWEROFF_GCODE + GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWEROFF_GCODE)); + #endif + + #if ENABLED(PS_OFF_SOUND) + BUZZ(1000, 659); + #endif + + OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_STATE); + psu_on = false; +} + + +#if ENABLED(AUTO_POWER_CONTROL) + + #ifndef POWER_TIMEOUT + #define POWER_TIMEOUT 0 + #endif + + /** + * Check all conditions that would signal power needing to be on. + * + * @returns bool if power is needed + */ + bool Power::is_power_needed() { + + if (printJobOngoing() || printingIsPaused()) return true; + + #if ENABLED(AUTO_POWER_FANS) + FANS_LOOP(i) if (thermalManager.fan_speed[i]) return true; + #endif + + #if ENABLED(AUTO_POWER_E_FANS) + HOTEND_LOOP() if (thermalManager.autofan_speed[e]) return true; + #endif + + #if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN) + if (controllerFan.state()) return true; + #endif + + if (TERN0(AUTO_POWER_CHAMBER_FAN, thermalManager.chamberfan_speed)) + return true; + + if (TERN0(AUTO_POWER_COOLER_FAN, thermalManager.coolerfan_speed)) + return true; + + // If any of the drivers or the bed are enabled... + if (X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON || Z_ENABLE_READ() == Z_ENABLE_ON + #if HAS_X2_ENABLE + || X2_ENABLE_READ() == X_ENABLE_ON + #endif + #if HAS_Y2_ENABLE + || Y2_ENABLE_READ() == Y_ENABLE_ON + #endif + #if HAS_Z2_ENABLE + || Z2_ENABLE_READ() == Z_ENABLE_ON + #endif + #if E_STEPPERS + #define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == E_ENABLE_ON + REPEAT(E_STEPPERS, _OR_ENABLED_E) + #endif + ) return true; + + #if HAS_HOTEND + HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0 || thermalManager.temp_hotend[e].soft_pwm_amount > 0) return true; + #endif + + 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; + #endif + + #if HAS_HEATED_CHAMBER && AUTO_POWER_CHAMBER_TEMP + if (thermalManager.degChamber() >= (AUTO_POWER_CHAMBER_TEMP)) return true; + #endif + + #if HAS_COOLER && AUTO_POWER_COOLER_TEMP + if (thermalManager.degCooler() >= (AUTO_POWER_COOLER_TEMP)) return true; + #endif + + return false; + } + + /** + * Check if we should power off automatically (POWER_TIMEOUT elapsed, !is_power_needed). + * + * @param pause pause the 'timer' + */ + void Power::check(const bool pause) { + static millis_t nextPowerCheck = 0; + const millis_t now = millis(); + #if POWER_TIMEOUT > 0 + static bool _pause = false; + if (pause != _pause) { + lastPowerOn = now + !now; + _pause = pause; + } + if (pause) return; + #endif + if (ELAPSED(now, nextPowerCheck)) { + nextPowerCheck = now + 2500UL; + if (is_power_needed()) + power_on(); + else if (!lastPowerOn || (POWER_TIMEOUT > 0 && ELAPSED(now, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT)))) + power_off(); + } + } + + #if POWER_OFF_DELAY > 0 + + /** + * Power off with a delay. Power off is triggered by check() after the delay. + * + */ + void Power::power_off_soon() { + lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY); + } + + #endif + #endif // AUTO_POWER_CONTROL + +#endif // PSU_CONTROL || AUTO_POWER_CONTROL diff --git a/Marlin/src/feature/power.h b/Marlin/src/feature/power.h index 2462b9231b..7f5a97e6df 100644 --- a/Marlin/src/feature/power.h +++ b/Marlin/src/feature/power.h @@ -25,17 +25,32 @@ * power.h - power control */ -#include "../core/millis_t.h" +#if ENABLED(AUTO_POWER_CONTROL) + #include "../core/millis_t.h" +#endif class Power { public: - static void check(); + static bool psu_on; + + static void init(); static void power_on(); static void power_off(); + + #if ENABLED(AUTO_POWER_CONTROL) && POWER_OFF_DELAY > 0 static void power_off_soon(); - private: - static millis_t lastPowerOn; - static bool is_power_needed(); + #else + static inline void power_off_soon() { power_off(); } + #endif + + #if ENABLED(AUTO_POWER_CONTROL) + static void check(const bool pause); + + private: + static millis_t lastPowerOn; + static bool is_power_needed(); + + #endif }; extern Power powerManager; diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 0fa9172fcf..d3ecc6c9cc 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -64,13 +64,13 @@ typedef struct { Repeat stored_repeat; #endif - #if ENABLED(HAS_HOME_OFFSET) + #if HAS_HOME_OFFSET xyz_pos_t home_offset; #endif - #if ENABLED(HAS_POSITION_SHIFT) + #if HAS_POSITION_SHIFT xyz_pos_t position_shift; #endif - #if ENABLED(HAS_MULTI_EXTRUDER) + #if HAS_MULTI_EXTRUDER uint8_t active_extruder; #endif @@ -78,17 +78,17 @@ typedef struct { float filament_size[EXTRUDERS]; #endif - #if ENABLED(HAS_HOTEND) + #if HAS_HOTEND celsius_t target_temperature[HOTENDS]; #endif - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED celsius_t target_temperature_bed; #endif - #if ENABLED(HAS_FAN) + #if HAS_FAN uint8_t fan_speed[FAN_COUNT]; #endif - #if ENABLED(HAS_LEVELING) + #if HAS_LEVELING float fade; #endif @@ -120,7 +120,7 @@ typedef struct { bool raised:1; // Raised before saved bool dryrun:1; // M111 S8 bool allow_cold_extrusion:1; // M302 P1 - #if ENABLED(HAS_LEVELING) + #if HAS_LEVELING bool leveling:1; // M420 S #endif #if DISABLED(NO_VOLUMETRICS) diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index c9d6c6cb3f..e39896d4dc 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -143,13 +143,13 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { // Sanity check for (calib_idx = 0; calib_idx < measurements; ++calib_idx) { // Restrict the max. offset - if (abs(data[calib_idx]) > 2000) { + if (ABS(data[calib_idx]) > 2000) { SERIAL_ECHOLNPGM("!Invalid Z-offset detected (0-2)."); clear_offsets(tsi); return false; } // Restrict the max. offset difference between two probings - if (calib_idx > 0 && abs(data[calib_idx - 1] - data[calib_idx]) > 800) { + if (calib_idx > 0 && ABS(data[calib_idx - 1] - data[calib_idx]) > 800) { SERIAL_ECHOLNPGM("!Invalid Z-offset between two probings detected (0-0.8)."); clear_offsets(TSI_PROBE); return false; diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 2e5ae85a43..f5f922410c 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -47,7 +47,7 @@ typedef struct { // Probe temperature calibration constants #ifndef PTC_SAMPLE_COUNT - #define PTC_SAMPLE_COUNT 10U + #define PTC_SAMPLE_COUNT 10 #endif #ifndef PTC_SAMPLE_RES #define PTC_SAMPLE_RES 5 @@ -55,14 +55,14 @@ typedef struct { #ifndef PTC_SAMPLE_START #define PTC_SAMPLE_START 30 #endif -#define PTC_SAMPLE_END ((PTC_SAMPLE_START) + (PTC_SAMPLE_COUNT) * (PTC_SAMPLE_RES)) +#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 #endif #ifndef BTC_SAMPLE_COUNT - #define BTC_SAMPLE_COUNT 10U + #define BTC_SAMPLE_COUNT 10 #endif #ifndef BTC_SAMPLE_RES #define BTC_SAMPLE_RES 5 @@ -70,7 +70,7 @@ typedef struct { #ifndef BTC_SAMPLE_START #define BTC_SAMPLE_START 60 #endif -#define BTC_SAMPLE_END ((BTC_SAMPLE_START) + (BTC_SAMPLE_COUNT) * (BTC_SAMPLE_RES)) +#define BTC_SAMPLE_END (BTC_SAMPLE_START + (BTC_SAMPLE_COUNT) * BTC_SAMPLE_RES) #ifndef PTC_PROBE_HEATING_OFFSET #define PTC_PROBE_HEATING_OFFSET 0.5f diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 100b7c4b26..539fafeb34 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -34,6 +34,10 @@ #include "../module/servo.h" #endif +#if ENABLED(I2C_AMMETER) + #include "../feature/ammeter.h" +#endif + SpindleLaser cutter; uint8_t SpindleLaser::power; #if ENABLED(LASER_FEATURE) @@ -74,6 +78,9 @@ void SpindleLaser::init() { #if ENABLED(AIR_ASSIST) OUT_WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_ACTIVE); // Init Air Assist OFF #endif + #if ENABLED(I2C_AMMETER) + ammeter.init(); // Init I2C Ammeter + #endif } #if ENABLED(SPINDLE_LASER_PWM) diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 3a856b3af8..c878d86fae 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -360,13 +360,6 @@ void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true)); #if ENABLED(IMPROVE_HOMING_RELIABILITY) extern millis_t sg_guard_period; constexpr uint16_t default_sg_guard_duration = 400; - - struct slow_homing_t { - xy_ulong_t acceleration; - #if ENABLED(HAS_CLASSIC_JERK) - xy_float_t jerk_xy; - #endif - }; #endif bool tmc_enable_stallguard(TMC2130Stepper &st); diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 616f16a58a..882197139e 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -291,7 +291,7 @@ typedef struct { if (p2.x < 0 || p2.x >= (GRID_MAX_POINTS_X)) return; if (p2.y < 0 || p2.y >= (GRID_MAX_POINTS_Y)) return; - if(circle_flags.marked(p1.x, p1.y) && circle_flags.marked(p2.x, p2.y)) { + if (circle_flags.marked(p1.x, p1.y) && circle_flags.marked(p2.x, p2.y)) { xyz_pos_t s, e; s.x = _GET_MESH_X(p1.x) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dx; e.x = _GET_MESH_X(p2.x) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dx; diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index ad2cc67db0..3d75a76915 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -91,8 +91,8 @@ void GcodeSuite::G35() { // Disable duplication mode on homing TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false)); - // Home all before this procedure - home_all_axes(); + // Home only Z axis when X and Y is trusted, otherwise all axes, if needed before this procedure + if (!all_axes_trusted()) process_subcommands_now_P(PSTR("G28Z")); bool err_break = false; @@ -106,7 +106,7 @@ void GcodeSuite::G35() { const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { - SERIAL_ECHOPAIR("G35 failed at point ", i, " ("); + SERIAL_ECHOPAIR("G35 failed at point ", i + 1, " ("); SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i])); SERIAL_CHAR(')'); SERIAL_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y); @@ -115,7 +115,7 @@ void GcodeSuite::G35() { } if (DEBUGGING(LEVELING)) { - DEBUG_ECHOPAIR("Probing point ", i, " ("); + DEBUG_ECHOPAIR("Probing point ", i + 1, " ("); DEBUG_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i])); DEBUG_CHAR(')'); DEBUG_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y, SP_Z_STR, z_probed_height); @@ -130,7 +130,7 @@ void GcodeSuite::G35() { // Calculate adjusts LOOP_S_L_N(i, 1, G35_PROBE_COUNT) { const float diff = z_measured[0] - z_measured[i], - adjust = abs(diff) < 0.001f ? 0 : diff / threads_factor[(screw_thread - 30) / 10]; + adjust = ABS(diff) < 0.001f ? 0 : diff / threads_factor[(screw_thread - 30) / 10]; const int full_turns = trunc(adjust); const float decimal_part = adjust - float(full_turns); @@ -138,8 +138,8 @@ void GcodeSuite::G35() { SERIAL_ECHOPGM("Turn "); SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i])); - SERIAL_ECHOPAIR(" ", (screw_thread & 1) == (adjust > 0) ? "CCW" : "CW", " by ", abs(full_turns), " turns"); - if (minutes) SERIAL_ECHOPAIR(" and ", abs(minutes), " minutes"); + SERIAL_ECHOPAIR(" ", (screw_thread & 1) == (adjust > 0) ? "CCW" : "CW", " by ", ABS(full_turns), " turns"); + if (minutes) SERIAL_ECHOPAIR(" and ", ABS(minutes), " minutes"); if (ENABLED(REPORT_TRAMMING_MM)) SERIAL_ECHOPAIR(" (", -diff, "mm)"); SERIAL_EOL(); } diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 5760667bed..29009c6e2d 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -61,7 +61,7 @@ #endif #if ENABLED(DWIN_CREALITY_LCD) - #include "../../../lcd/dwin/e3v2/dwin.h" + #include "../../../lcd/e3v2/creality/dwin.h" #endif #if HAS_MULTI_HOTEND @@ -217,6 +217,8 @@ public: * There's no extra effect if you have a fixed Z probe. */ G29_TYPE GcodeSuite::G29() { + DEBUG_SECTION(log_G29, "G29", DEBUGGING(LEVELING)); + TERN_(PROBE_MANUALLY, static) G29_State abl; TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); @@ -227,11 +229,7 @@ G29_TYPE GcodeSuite::G29() { // G29 Q is also available if debugging #if ENABLED(DEBUG_LEVELING_FEATURE) - const uint8_t old_debug_flags = marlin_debug_flags; - if (seenQ) marlin_debug_flags |= MARLIN_DEBUG_LEVELING; - DEBUG_SECTION(log_G29, "G29", DEBUGGING(LEVELING)); - if (DEBUGGING(LEVELING)) log_machine_info(); - marlin_debug_flags = old_debug_flags; + if (seenQ || DEBUGGING(LEVELING)) log_machine_info(); if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false); #endif @@ -246,7 +244,7 @@ G29_TYPE GcodeSuite::G29() { // Send 'N' to force homing before G29 (internal only) if (parser.seen_test('N')) - process_subcommands_now_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR)); + process_subcommands_now_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR)); // Don't allow auto-leveling without homing first if (homing_needed_error()) G29_RETURN(false); @@ -472,10 +470,8 @@ G29_TYPE GcodeSuite::G29() { // Query G29 status if (abl.verbose_level || seenQ) { SERIAL_ECHOPGM("Manual G29 "); - if (g29_in_progress) { - SERIAL_ECHOPAIR("point ", _MIN(abl.abl_probe_index + 1, abl.abl_points)); - SERIAL_ECHOLNPAIR(" of ", abl.abl_points); - } + if (g29_in_progress) + SERIAL_ECHOLNPAIR("point ", _MIN(abl.abl_probe_index + 1, abl.abl_points), " of ", abl.abl_points); else SERIAL_ECHOLNPGM("idle"); } @@ -568,7 +564,7 @@ G29_TYPE GcodeSuite::G29() { // Probe at 3 arbitrary points if (abl.abl_probe_index < abl.abl_points) { - abl.probePos = points[abl.abl_probe_index]; + abl.probePos = xy_pos_t(points[abl.abl_probe_index]); _manual_goto_xy(abl.probePos); // Disable software endstops to allow manual adjustment // If G29 is not completed, they will not be re-enabled diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 07721330ba..984e008d27 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -42,6 +42,9 @@ #include "../../../lcd/extui/ui_api.h" #endif +#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) +#include "../../../core/debug_out.h" + // Save 130 bytes with non-duplication of PSTR inline void echo_not_entered(const char c) { SERIAL_CHAR(c); SERIAL_ECHOLNPGM(" not entered."); } @@ -59,6 +62,16 @@ inline void echo_not_entered(const char c) { SERIAL_CHAR(c); SERIAL_ECHOLNPGM(" * S5 Reset and disable mesh */ void GcodeSuite::G29() { + DEBUG_SECTION(log_G29, "G29", true); + + // G29 Q is also available if debugging + #if ENABLED(DEBUG_LEVELING_FEATURE) + const bool seenQ = parser.seen_test('Q'); + if (seenQ || DEBUGGING(LEVELING)) { + log_machine_info(); + if (seenQ) return; + } + #endif TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); @@ -71,6 +84,7 @@ void GcodeSuite::G29() { } int8_t ix, iy; + ix = iy = 0; switch (state) { case MeshReport: @@ -87,7 +101,8 @@ void GcodeSuite::G29() { mbl.reset(); mbl_probe_index = 0; if (!ui.wait_for_move) { - queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2")); + queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : PSTR("G29S2")); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); return; } state = MeshNext; @@ -109,6 +124,7 @@ void GcodeSuite::G29() { else { // Save Z for the previous mesh position mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, current_position.z)); SET_SOFT_ENDSTOP_LOOSE(false); } // If there's another point to sample, move there with optional lift. diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 2eca66c3b0..89ad20d906 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -47,7 +47,7 @@ #include "../../lcd/marlinui.h" #if ENABLED(DWIN_CREALITY_LCD) - #include "../../lcd/dwin/e3v2/dwin.h" + #include "../../lcd/e3v2/creality/dwin.h" #endif #if ENABLED(EXTENSIBLE_UI) @@ -164,24 +164,28 @@ #if ENABLED(IMPROVE_HOMING_RELIABILITY) - slow_homing_t begin_slow_homing() { - slow_homing_t slow_homing{0}; - slow_homing.acceleration.set(planner.settings.max_acceleration_mm_per_s2[X_AXIS], - planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); + motion_state_t begin_slow_homing() { + motion_state_t motion_state{0}; + motion_state.acceleration.set(planner.settings.max_acceleration_mm_per_s2[X_AXIS], + planner.settings.max_acceleration_mm_per_s2[Y_AXIS] + OPTARG(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS]) + ); planner.settings.max_acceleration_mm_per_s2[X_AXIS] = 100; planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = 100; + TERN_(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = 100); #if HAS_CLASSIC_JERK - slow_homing.jerk_xy = planner.max_jerk; - planner.max_jerk.set(0, 0); + motion_state.jerk_state = planner.max_jerk; + planner.max_jerk.set(0, 0 OPTARG(DELTA, 0)); #endif planner.reset_acceleration_rates(); - return slow_homing; + return motion_state; } - void end_slow_homing(const slow_homing_t &slow_homing) { - planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x; - planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y; - TERN_(HAS_CLASSIC_JERK, planner.max_jerk = slow_homing.jerk_xy); + void end_slow_homing(const motion_state_t &motion_state) { + planner.settings.max_acceleration_mm_per_s2[X_AXIS] = motion_state.acceleration.x; + planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = motion_state.acceleration.y; + TERN_(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = motion_state.acceleration.z); + TERN_(HAS_CLASSIC_JERK, planner.max_jerk = motion_state.jerk_state); planner.reset_acceleration_rates(); } @@ -195,9 +199,9 @@ * None Home to all axes with no parameters. * With QUICK_HOME enabled XY will home together, then Z. * - * O Home only if position is unknown - * - * Rn Raise by n mm/inches before homing + * L Force leveling state ON (if possible) or OFF after homing (Requires RESTORE_LEVELING_AFTER_G28 or ENABLE_LEVELING_AFTER_G28) + * O Home only if the position is not known and trusted + * R Raise by n mm/inches before homing * * Cartesian/SCARA parameters * @@ -229,7 +233,7 @@ void GcodeSuite::G28() { #endif // Home (O)nly if position is unknown - if (!axes_should_home() && parser.boolval('O')) { + if (!axes_should_home() && parser.seen_test('O')) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> homing not needed, skip"); return; } @@ -242,12 +246,16 @@ void GcodeSuite::G28() { SET_SOFT_ENDSTOP_LOOSE(false); // Reset a leftover 'loose' motion state // Disable the leveling matrix before homing - #if HAS_LEVELING - const bool leveling_restore_state = parser.boolval('L', TERN(RESTORE_LEVELING_AFTER_G28, planner.leveling_active, ENABLED(ENABLE_LEVELING_AFTER_G28))); - IF_ENABLED(PROBE_MANUALLY, g29_in_progress = false); // Cancel the active G29 session - set_bed_leveling_enabled(false); + #if CAN_SET_LEVELING_AFTER_G28 + const bool leveling_restore_state = parser.boolval('L', TERN1(RESTORE_LEVELING_AFTER_G28, planner.leveling_active)); #endif + // Cancel any prior G29 session + TERN_(PROBE_MANUALLY, g29_in_progress = false); + + // Disable leveling before homing + TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); + // Reset to the XY plane TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY); @@ -255,12 +263,12 @@ void GcodeSuite::G28() { reset_stepper_timeout(); #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) + #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) #define HAS_HOMING_CURRENT 1 #endif #if HAS_HOMING_CURRENT - auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b){ + auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b) { DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPAIR(" current: ", a, " -> ", b); }; #if HAS_CURRENT_HOME(X) @@ -283,9 +291,16 @@ void GcodeSuite::G28() { stepperY2.rms_current(Y2_CURRENT_HOME); if (DEBUGGING(LEVELING)) debug_current(PSTR("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME); #endif + #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA) + const int16_t tmc_save_current_Z = stepperZ.getMilliamps(); + stepperZ.rms_current(Z_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(PSTR("Z"), tmc_save_current_Z, Z_CURRENT_HOME); + #endif #endif - TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing_t slow_homing = begin_slow_homing()); + #if ENABLED(IMPROVE_HOMING_RELIABILITY) + motion_state_t saved_motion_state = begin_slow_homing(); + #endif // Always home with tool 0 active #if HAS_MULTI_HOTEND @@ -311,7 +326,7 @@ void GcodeSuite::G28() { home_delta(); - TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing)); + TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state)); #elif ENABLED(AXEL_TPARA) @@ -353,13 +368,14 @@ void GcodeSuite::G28() { const float z_homing_height = parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT; - if (z_homing_height && (0 LINEAR_AXIS_GANG(|| doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) { + if (z_homing_height && (LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) { // Raise Z before homing any other axes and z is not already high enough (never lower z) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height); do_z_clearance(z_homing_height); TERN_(BLTOUCH, bltouch.init()); } + // Diagonal move first if both are homing TERN_(QUICK_HOME, if (doX && doY) quick_home_xy()); // Home Y (before X) @@ -396,7 +412,7 @@ void GcodeSuite::G28() { if (DISABLED(HOME_Y_BEFORE_X) && doY) homeaxis(Y_AXIS); - TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing)); + TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state)); // Home Z last if homing towards the bed #if HAS_Z_AXIS && DISABLED(HOME_Z_FIRST) @@ -435,7 +451,7 @@ void GcodeSuite::G28() { if (idex_is_duplicating()) { - TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing = begin_slow_homing()); + TERN_(IMPROVE_HOMING_RELIABILITY, saved_motion_state = begin_slow_homing()); // Always home the 2nd (right) extruder first active_extruder = 1; @@ -454,7 +470,7 @@ void GcodeSuite::G28() { dual_x_carriage_mode = IDEX_saved_mode; set_duplication_enabled(IDEX_saved_duplication_state); - TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing)); + TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state)); } #endif // DUAL_X_CARRIAGE @@ -464,12 +480,10 @@ void GcodeSuite::G28() { // Clear endstop state for polled stallGuard endstops TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state()); - #if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE) - // move to a height where we can use the full xy-area - do_blocking_move_to_z(delta_clip_start_height); - #endif + // Move to a height where we can use the full xy-area + TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height)); - TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_restore_state)); + TERN_(CAN_SET_LEVELING_AFTER_G28, if (leveling_restore_state) set_bed_leveling_enabled()); restore_feedrate_and_scaling(); @@ -492,6 +506,9 @@ void GcodeSuite::G28() { #if HAS_CURRENT_HOME(Y2) stepperY2.rms_current(tmc_save_current_Y2); #endif + #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA) + stepperZ.rms_current(tmc_save_current_Z); + #endif #if HAS_CURRENT_HOME(I) stepperI.rms_current(tmc_save_current_I); #endif diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 14ac53aeba..a897a10115 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -63,7 +63,7 @@ enum CalEnum : char { // the 7 main calibration points - #define LOOP_CAL_RAD(VAR) LOOP_CAL_PT(VAR, __A, _7P_STEP) #define LOOP_CAL_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP) -#if ENABLED(HAS_MULTI_HOTEND) +#if HAS_MULTI_HOTEND const uint8_t old_tool_index = active_extruder; #endif @@ -71,7 +71,9 @@ float lcd_probe_pt(const xy_pos_t &xy); void ac_home() { endstops.enable(true); + TERN_(SENSORLESS_HOMING, probe.set_homing_current(true)); home_delta(); + TERN_(SENSORLESS_HOMING, probe.set_homing_current(false)); endstops.not_homing(); } @@ -384,6 +386,12 @@ static float auto_tune_a() { * V3 Report settings and probe results * * E Engage the probe for each point + * + * With SENSORLESS_PROBING: + * Use these flags to calibrate stall sensitivity: (e.g., `G33 P1 Y Z` to calibrate X only.) + * X Don't activate stallguard on X. + * Y Don't activate stallguard on Y. + * Z Don't activate stallguard on Z. */ void GcodeSuite::G33() { @@ -417,6 +425,12 @@ void GcodeSuite::G33() { const bool stow_after_each = parser.seen_test('E'); + #if ENABLED(SENSORLESS_PROBING) + probe.test_sensitivity.x = !parser.seen_test('X'); + TERN_(HAS_Y_AXIS, probe.test_sensitivity.y = !parser.seen_test('Y')); + TERN_(HAS_Z_AXIS, probe.test_sensitivity.z = !parser.seen_test('Z')); + #endif + const bool _0p_calibration = probe_points == 0, _1p_calibration = probe_points == 1 || probe_points == -1, _4p_calibration = probe_points == 2, @@ -587,7 +601,7 @@ void GcodeSuite::G33() { // print report - if (verbose_level == 3) + if (verbose_level == 3 || verbose_level == 0) print_calibration_results(z_at_pt, _tower_results, _opposite_results); if (verbose_level != 0) { // !dry run diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index bcca00dd42..f335a12311 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -39,7 +39,7 @@ void GcodeSuite::G34() { // Home before the alignment procedure - if (!all_axes_trusted()) home_all_axes(); + home_if_needed(); TERN_(HAS_LEVELING, TEMPORARY_BED_LEVELING_STATE(false)); @@ -81,11 +81,11 @@ void GcodeSuite::G34() { const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS]; stepper.set_digipot_current(1, target_current); - #elif ENABLED(HAS_MOTOR_CURRENT_DAC) + #elif HAS_MOTOR_CURRENT_DAC const float target_current = parser.floatval('S', GANTRY_CALIBRATION_CURRENT); const float previous_current = dac_amps(Z_AXIS, target_current); stepper_dac.set_current_value(Z_AXIS, target_current); - #elif ENABLED(HAS_MOTOR_CURRENT_I2C) + #elif HAS_MOTOR_CURRENT_I2C const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); previous_current = dac_amps(Z_AXIS); digipot_i2c.set_current(Z_AXIS, target_current) @@ -127,9 +127,9 @@ void GcodeSuite::G34() { stepper.set_digipot_current(Z_AXIS, previous_current); #elif HAS_MOTOR_CURRENT_PWM stepper.set_digipot_current(1, previous_current); - #elif ENABLED(HAS_MOTOR_CURRENT_DAC) + #elif HAS_MOTOR_CURRENT_DAC stepper_dac.set_current_value(Z_AXIS, previous_current); - #elif ENABLED(HAS_MOTOR_CURRENT_I2C) + #elif HAS_MOTOR_CURRENT_I2C digipot_i2c.set_current(Z_AXIS, previous_current) #elif HAS_TRINAMIC_CONFIG #if AXIS_IS_TMC(Z) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 1803933d16..50f3419c89 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -167,7 +167,7 @@ void GcodeSuite::G34() { )); // Home before the alignment procedure - if (!all_axes_trusted()) home_all_axes(); + home_if_needed(); // Move the Z coordinate realm towards the positive - dirty trick current_position.z += z_probe * 0.5f; @@ -314,11 +314,13 @@ void GcodeSuite::G34() { sprintf_P(msg, PSTR("1:2=%s" TERN_(TRIPLE_Z, " 3-2=%s 3-1=%s") TERN_(QUAD_Z, " 4-3=%s 4-2=%s 4-1=%s")), dtostrf(ABS(z_measured[1] - z_measured[0]), 1, 3, fstr1) - OPTARG(TRIPLE_Z, dtostrf(ABS(z_measured[2] - z_measured[1]), 1, 3, fstr2)) - OPTARG(TRIPLE_Z, dtostrf(ABS(z_measured[2] - z_measured[0]), 1, 3, fstr3)) - OPTARG(QUAD_Z, dtostrf(ABS(z_measured[3] - z_measured[2]), 1, 3, fstr4)) - OPTARG(QUAD_Z, dtostrf(ABS(z_measured[3] - z_measured[1]), 1, 3, fstr5)) - OPTARG(QUAD_Z, dtostrf(ABS(z_measured[3] - z_measured[0]), 1, 3, fstr6)) + OPTARG(TRIPLE_Z, + dtostrf(ABS(z_measured[2] - z_measured[1]), 1, 3, fstr2), + dtostrf(ABS(z_measured[2] - z_measured[0]), 1, 3, fstr3)) + OPTARG(QUAD_Z, + dtostrf(ABS(z_measured[3] - z_measured[2]), 1, 3, fstr4), + dtostrf(ABS(z_measured[3] - z_measured[1]), 1, 3, fstr5), + dtostrf(ABS(z_measured[3] - z_measured[0]), 1, 3, fstr6)) ); ui.set_status(msg); #endif diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 56b1555fc4..c8efea858c 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -439,7 +439,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { #if HAS_Z_AXIS && AXIS_CAN_CALIBRATE(Z) SERIAL_ECHOLNPAIR(" Top: ", m.backlash[TOP]); #endif - #if LINEAR_AXES >= 4 AXIS_CAN_CALIBRATE(I) + #if LINEAR_AXES >= 4 && AXIS_CAN_CALIBRATE(I) #if ENABLED(CALIBRATION_MEASURE_IMIN) SERIAL_ECHOLNPAIR(" " STR_I_MIN ": ", m.backlash[IMINIMUM]); #endif @@ -447,7 +447,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPAIR(" " STR_I_MAX ": ", m.backlash[IMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 5 AXIS_CAN_CALIBRATE(J) + #if LINEAR_AXES >= 5 && AXIS_CAN_CALIBRATE(J) #if ENABLED(CALIBRATION_MEASURE_JMIN) SERIAL_ECHOLNPAIR(" " STR_J_MIN ": ", m.backlash[JMINIMUM]); #endif @@ -455,7 +455,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPAIR(" " STR_J_MAX ": ", m.backlash[JMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 6 AXIS_CAN_CALIBRATE(K) + #if LINEAR_AXES >= 6 && AXIS_CAN_CALIBRATE(K) #if ENABLED(CALIBRATION_MEASURE_KMIN) SERIAL_ECHOLNPAIR(" " STR_K_MIN ": ", m.backlash[KMINIMUM]); #endif diff --git a/Marlin/src/gcode/calibrate/M666.cpp b/Marlin/src/gcode/calibrate/M666.cpp index a3a48cd3fc..872344e4e9 100644 --- a/Marlin/src/gcode/calibrate/M666.cpp +++ b/Marlin/src/gcode/calibrate/M666.cpp @@ -27,30 +27,72 @@ #include "../gcode.h" #if ENABLED(DELTA) - #include "../../module/delta.h" #include "../../module/motion.h" +#else + #include "../../module/endstops.h" +#endif - #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) - #include "../../core/debug_out.h" +#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) +#include "../../core/debug_out.h" + +void M666_report(const bool forReplay=true) { + if (!forReplay) { SERIAL_ECHOLNPGM("; Endstop adjustment:"); SERIAL_ECHO_START(); } + #if ENABLED(DELTA) + SERIAL_ECHOLNPAIR_P( + PSTR(" M666 X"), LINEAR_UNIT(delta_endstop_adj.a) + , SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b) + , SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c) + ); + #else + SERIAL_ECHOPGM(" M666"); + #if ENABLED(X_DUAL_ENDSTOPS) + SERIAL_ECHOLNPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj)); + #endif + #if ENABLED(Y_DUAL_ENDSTOPS) + SERIAL_ECHOLNPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj)); + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) + #if NUM_Z_STEPPER_DRIVERS >= 3 + SERIAL_ECHOPAIR(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); + if (!forReplay) SERIAL_ECHO_START(); + SERIAL_ECHOPAIR(" M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); + #if NUM_Z_STEPPER_DRIVERS >= 4 + if (!forReplay) SERIAL_ECHO_START(); + SERIAL_ECHOPAIR(" M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj)); + #endif + #else + SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj)); + #endif + #endif + #endif +} + +#if ENABLED(DELTA) /** * M666: Set delta endstop adjustment */ void GcodeSuite::M666() { DEBUG_SECTION(log_M666, "M666", DEBUGGING(LEVELING)); + bool is_err = false, is_set = false; LOOP_LINEAR_AXES(i) { if (parser.seen(AXIS_CHAR(i))) { + is_set = true; const float v = parser.value_linear_units(); - if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", AS_CHAR(AXIS_CHAR(i)), "] = ", delta_endstop_adj[i]); + if (v > 0) + is_err = true; + else { + delta_endstop_adj[i] = v; + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", AS_CHAR(AXIS_CHAR(i)), "] = ", v); + } } } + if (is_err) SERIAL_ECHOLNPAIR("?M666 offsets must be <= 0"); + if (!is_set) M666_report(); } -#elif HAS_EXTRA_ENDSTOPS - - #include "../../module/endstops.h" +#else /** * M666: Set Dual Endstops offsets for X, Y, and/or Z. @@ -71,33 +113,17 @@ #endif #if ENABLED(Z_MULTI_ENDSTOPS) if (parser.seenval('Z')) { - #if NUM_Z_STEPPER_DRIVERS >= 3 - const float z_adj = parser.value_linear_units(); - const int ind = parser.intval('S'); - if (!ind || ind == 2) endstops.z2_endstop_adj = z_adj; - if (!ind || ind == 3) endstops.z3_endstop_adj = z_adj; - #if NUM_Z_STEPPER_DRIVERS >= 4 - if (!ind || ind == 4) endstops.z4_endstop_adj = z_adj; - #endif + const float z_adj = parser.value_linear_units(); + #if NUM_Z_STEPPER_DRIVERS == 2 + endstops.z2_endstop_adj = z_adj; #else - endstops.z2_endstop_adj = parser.value_linear_units(); + const int ind = parser.intval('S'); + #define _SET_ZADJ(N) if (!ind || ind == N) endstops.z##N##_endstop_adj = z_adj; + REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _SET_ZADJ) #endif } #endif - if (!parser.seen("XYZ")) { - SERIAL_ECHOPGM("Dual Endstop Adjustment (mm): "); - #if ENABLED(X_DUAL_ENDSTOPS) - SERIAL_ECHOPAIR(" X2:", endstops.x2_endstop_adj); - #endif - #if ENABLED(Y_DUAL_ENDSTOPS) - SERIAL_ECHOPAIR(" Y2:", endstops.y2_endstop_adj); - #endif - #if ENABLED(Z_MULTI_ENDSTOPS) - #define _ECHO_ZADJ(N) SERIAL_ECHOPAIR(" Z" STRINGIFY(N) ":", endstops.z##N##_endstop_adj); - REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _ECHO_ZADJ) - #endif - SERIAL_EOL(); - } + if (!parser.seen("XYZ")) M666_report(); } #endif // HAS_EXTRA_ENDSTOPS diff --git a/Marlin/src/gcode/calibrate/M852.cpp b/Marlin/src/gcode/calibrate/M852.cpp index 6f1e984bc3..73b18ad466 100644 --- a/Marlin/src/gcode/calibrate/M852.cpp +++ b/Marlin/src/gcode/calibrate/M852.cpp @@ -93,7 +93,7 @@ void GcodeSuite::M852() { if (!ijk) { SERIAL_ECHO_START(); - SERIAL_ECHOPGM_P(GET_TEXT(MSG_SKEW_FACTOR)); + SERIAL_ECHOPGM("Skew Factor"); SERIAL_ECHOPAIR_F(" XY: ", planner.skew_factor.xy, 6); #if ENABLED(SKEW_CORRECTION_FOR_Z) SERIAL_ECHOPAIR_F(" XZ: ", planner.skew_factor.xz, 6); diff --git a/Marlin/src/gcode/control/M7-M9.cpp b/Marlin/src/gcode/control/M7-M9.cpp index ae112fc372..ccde4f552c 100644 --- a/Marlin/src/gcode/control/M7-M9.cpp +++ b/Marlin/src/gcode/control/M7-M9.cpp @@ -20,9 +20,9 @@ * */ -#include "../../inc/MarlinConfig.h" +#include "../../inc/MarlinConfigPre.h" -#if ENABLED(COOLANT_CONTROL) +#if ANY(COOLANT_MIST, COOLANT_FLOOD, AIR_ASSIST) #include "../gcode.h" #include "../../module/planner.h" @@ -37,51 +37,41 @@ } #endif -#if ENABLED(COOLANT_FLOOD) +#if EITHER(COOLANT_FLOOD, AIR_ASSIST) + + #if ENABLED(AIR_ASSIST) + #include "../../feature/spindle_laser.h" + #endif + /** - * M8: Flood Coolant On + * M8: Flood Coolant / Air Assist ON */ void GcodeSuite::M8() { - planner.synchronize(); // Wait for move to arrive - WRITE(COOLANT_FLOOD_PIN, !(COOLANT_FLOOD_INVERT)); // Turn on Flood coolant + planner.synchronize(); // Wait for move to arrive + #if ENABLED(COOLANT_FLOOD) + WRITE(COOLANT_FLOOD_PIN, !(COOLANT_FLOOD_INVERT)); // Turn on Flood coolant + #endif + #if ENABLED(AIR_ASSIST) + cutter.air_assist_enable(); // Turn on Air Assist + #endif } + #endif /** - * M9: Coolant OFF + * M9: Coolant / Air Assist OFF */ void GcodeSuite::M9() { - planner.synchronize(); // Wait for move to arrive + planner.synchronize(); // Wait for move to arrive #if ENABLED(COOLANT_MIST) - WRITE(COOLANT_MIST_PIN, COOLANT_MIST_INVERT); // Turn off Mist coolant + WRITE(COOLANT_MIST_PIN, COOLANT_MIST_INVERT); // Turn off Mist coolant #endif #if ENABLED(COOLANT_FLOOD) - WRITE(COOLANT_FLOOD_PIN, COOLANT_FLOOD_INVERT); // Turn off Flood coolant + WRITE(COOLANT_FLOOD_PIN, COOLANT_FLOOD_INVERT); // Turn off Flood coolant + #endif + #if ENABLED(AIR_ASSIST) + cutter.air_assist_disable(); // Turn off Air Assist #endif } -#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 +#endif // COOLANT_MIST | COOLANT_FLOOD | AIR_ASSIST diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index 1b5ea2f7ef..9640c72006 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -29,25 +29,17 @@ #include "../../inc/MarlinConfig.h" +#if ENABLED(PSU_CONTROL) + #include "../queue.h" + #include "../../feature/power.h" +#endif + #if HAS_SUICIDE #include "../../MarlinCore.h" #endif #if ENABLED(PSU_CONTROL) - #if ENABLED(AUTO_POWER_CONTROL) - #include "../../feature/power.h" - #else - void restore_stepper_drivers(); - #endif - - // Could be moved to a feature, but this is all the data - bool powersupply_on; - - #if HAS_TRINAMIC_CONFIG - #include "../../feature/tmc_util.h" - #endif - /** * M80 : Turn on the Power Supply * M80 S : Report the current state and exit @@ -56,11 +48,11 @@ // S: Report the current power supply state and exit if (parser.seen('S')) { - SERIAL_ECHOPGM_P(powersupply_on ? PSTR("PS:1\n") : PSTR("PS:0\n")); + SERIAL_ECHOPGM_P(powerManager.psu_on ? PSTR("PS:1\n") : PSTR("PS:0\n")); return; } - PSU_ON(); + powerManager.power_on(); /** * If you have a switch on suicide pin, this is useful @@ -71,12 +63,6 @@ OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING); #endif - #if DISABLED(AUTO_POWER_CONTROL) - safe_delay(PSU_POWERUP_DELAY); - restore_stepper_drivers(); - TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY)); - #endif - TERN_(HAS_LCD_MENU, ui.reset_status()); } @@ -106,7 +92,7 @@ void GcodeSuite::M81() { #if HAS_SUICIDE suicide(); #elif ENABLED(PSU_CONTROL) - PSU_OFF_SOON(); + powerManager.power_off_soon(); #endif LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF ".")); diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp index 90fd6c487e..dddf7f8aee 100644 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ b/Marlin/src/gcode/feature/L6470/M906.cpp @@ -32,31 +32,6 @@ #define DEBUG_OUT ENABLED(L6470_CHITCHAT) #include "../../../core/debug_out.h" -/** - * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the - * PWMs to the steppers - * - * On L6474 this sets the TVAL register (same address). - * - * I - select which driver(s) to change on multi-driver axis - * 0 - (default) all drivers on the axis or E0 - * 1 - monitor only X, Y, Z or E1 - * 2 - monitor only X2, Y2, Z2 or E2 - * 3 - monitor only Z3 or E3 - * 4 - monitor only Z4 or E4 - * 5 - monitor only E5 - * Xxxx, Yxxx, Zxxx, Exxx - axis to change (optional) - * L6474 - current in mA (4A max) - * All others - 0-255 - */ - -/** - * Sets KVAL_HOLD wich affects the current being driven through the stepper. - * - * L6470 is used in the STEP-CLOCK mode. KVAL_HOLD is the only KVAL_xxx - * that affects the effective voltage seen by the stepper. - */ - /** * MACRO to fetch information on the items associated with current limiting * and maximum voltage output. @@ -220,6 +195,28 @@ void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) { } } +/** + * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the + * PWMs to the steppers + * + * On L6474 this sets the TVAL register (same address). + * + * I - select which driver(s) to change on multi-driver axis + * 0 - (default) all drivers on the axis or E0 + * 1 - monitor only X, Y, Z or E1 + * 2 - monitor only X2, Y2, Z2 or E2 + * 3 - monitor only Z3 or E3 + * 4 - monitor only Z4 or E4 + * 5 - monitor only E5 + * Xxxx, Yxxx, Zxxx, Exxx - axis to change (optional) + * L6474 - current in mA (4A max) + * All others - 0-255 + * + * Sets KVAL_HOLD wich affects the current being driven through the stepper. + * + * L6470 is used in the STEP-CLOCK mode. KVAL_HOLD is the only KVAL_xxx + * that affects the effective voltage seen by the stepper. + */ void GcodeSuite::M906() { L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status @@ -281,11 +278,11 @@ void GcodeSuite::M906() { break; #endif - #if HAS_EXTRUDERS + #if E_STEPPERS case E_AXIS: { - const int8_t target_extruder = get_target_extruder_from_command(); - if (target_extruder < 0) return; - switch (target_extruder) { + const int8_t target_e_stepper = get_target_e_stepper_from_command(); + if (target_e_stepper < 0) return; + switch (target_e_stepper) { #if AXIS_IS_L64XX(E0) case 0: L6470_SET_KVAL_HOLD(E0); break; #endif diff --git a/Marlin/src/gcode/feature/clean/G12.cpp b/Marlin/src/gcode/feature/clean/G12.cpp index 216db5bae3..b19932eb98 100644 --- a/Marlin/src/gcode/feature/clean/G12.cpp +++ b/Marlin/src/gcode/feature/clean/G12.cpp @@ -42,6 +42,7 @@ * P0 S : Stroke cleaning with S strokes * P1 Sn T : Zigzag cleaning with S repeats and T zigzags * P2 Sn R : Circle cleaning with S repeats and R radius + * X, Y, Z : Specify axes to move during cleaning. Default: ALL. */ void GcodeSuite::G12() { // Don't allow nozzle cleaning without homing first diff --git a/Marlin/src/gcode/feature/controllerfan/M710.cpp b/Marlin/src/gcode/feature/controllerfan/M710.cpp index cc450732ba..aa382a3ea9 100644 --- a/Marlin/src/gcode/feature/controllerfan/M710.cpp +++ b/Marlin/src/gcode/feature/controllerfan/M710.cpp @@ -27,7 +27,7 @@ #include "../../gcode.h" #include "../../../feature/controllerfan.h" -void M710_report(const bool forReplay) { +void M710_report(const bool forReplay=true) { if (!forReplay) { SERIAL_ECHOLNPGM("; Controller Fan"); SERIAL_ECHO_START(); } SERIAL_ECHOLNPAIR(" M710" " S", int(controllerFan.settings.active_speed), @@ -75,7 +75,7 @@ void GcodeSuite::M710() { if (seenD) controllerFan.settings.duration = parser.value_ushort(); if (!(seenR || seenS || seenI || seenA || seenD)) - M710_report(false); + M710_report(); } #endif // CONTROLLER_FAN_EDITABLE diff --git a/Marlin/src/gcode/feature/digipot/M907-M910.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp index ee9801eda9..bd741f8a64 100644 --- a/Marlin/src/gcode/feature/digipot/M907-M910.cpp +++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp @@ -34,7 +34,7 @@ #include "../../../feature/digipot/digipot.h" #endif -#if ENABLED(HAS_MOTOR_CURRENT_DAC) +#if HAS_MOTOR_CURRENT_DAC #include "../../../feature/dac/stepper_dac.h" #endif @@ -67,11 +67,13 @@ void GcodeSuite::M907() { LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) digipot_i2c.set_current(i, parser.value_float()); // Additional extruders use B,C,D for channels 4,5,6. // TODO: Change these parameters because 'E' is used. B? - for (uint8_t i = E_AXIS + 1; i < DIGIPOT_I2C_NUM_CHANNELS; i++) - if (parser.seenval('B' + i - (E_AXIS + 1))) digipot_i2c.set_current(i, parser.value_float()); + #if HAS_EXTRUDERS + for (uint8_t i = E_AXIS + 1; i < DIGIPOT_I2C_NUM_CHANNELS; i++) + if (parser.seenval('B' + i - (E_AXIS + 1))) digipot_i2c.set_current(i, parser.value_float()); + #endif #endif - #if ENABLED(HAS_MOTOR_CURRENT_DAC) + #if HAS_MOTOR_CURRENT_DAC if (parser.seenval('S')) { const float dac_percent = parser.value_float(); LOOP_LE_N(i, 4) stepper_dac.set_current_percent(i, dac_percent); @@ -90,7 +92,7 @@ void GcodeSuite::M907() { TERN_(HAS_MOTOR_CURRENT_DAC, stepper_dac.set_current_value(parser.byteval('P', -1), parser.ushortval('S', 0))); } - #if ENABLED(HAS_MOTOR_CURRENT_DAC) + #if HAS_MOTOR_CURRENT_DAC void GcodeSuite::M909() { stepper_dac.print_values(); } void GcodeSuite::M910() { stepper_dac.commit_eeprom(); } diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 5d175ea8f7..4d271007e5 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -52,14 +52,16 @@ * M150 I1 R ; Set NEOPIXEL index 1 to red * M150 S1 I1 R ; Set SEPARATE index 1 to red */ - void GcodeSuite::M150() { #if ENABLED(NEOPIXEL_LED) - const uint8_t index = parser.intval('I', -1); + const int8_t index = parser.intval('I', -1); #if ENABLED(NEOPIXEL2_SEPARATE) - const uint8_t unit = parser.intval('S'), - brightness = unit ? neo2.brightness() : neo.brightness(); - *(unit ? &neo2.neoindex : &neo.neoindex) = index; + int8_t brightness, unit = parser.intval('S', -1); + switch (unit) { + case -1: neo2.neoindex = index; // fall-thru + case 0: neo.neoindex = index; brightness = neo.brightness(); break; + case 1: neo2.neoindex = index; brightness = neo2.brightness(); break; + } #else const uint8_t brightness = neo.brightness(); neo.neoindex = index; @@ -75,10 +77,15 @@ void GcodeSuite::M150() { ); #if ENABLED(NEOPIXEL2_SEPARATE) - if (unit == 1) { leds2.set_color(color); return; } + switch (unit) { + case 0: leds.set_color(color); return; + case 1: leds2.set_color(color); return; + } #endif + // If 'S' is not specified use both leds.set_color(color); + TERN_(NEOPIXEL2_SEPARATE, leds2.set_color(color)); } #endif // HAS_COLOR_LEDS diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index 2eb4ceea41..bc31e1225d 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -56,7 +56,7 @@ */ void GcodeSuite::M125() { // Initial retract before move to filament change position - const float retract = -ABS(parser.axisunitsval('L', E_AXIS, PAUSE_PARK_RETRACT_LENGTH)); + const float retract = TERN0(HAS_EXTRUDERS, -ABS(parser.axisunitsval('L', E_AXIS, PAUSE_PARK_RETRACT_LENGTH))); xyz_pos_t park_point = NOZZLE_PARK_POINT; diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 2daa7d999a..541fa08350 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -99,7 +99,7 @@ void GcodeSuite::M600() { #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE) // If needed, home before parking for filament change - if (!all_axes_trusted()) home_all_axes(true); + home_if_needed(true); #endif #if HAS_MULTI_EXTRUDER diff --git a/Marlin/src/gcode/feature/runout/M412.cpp b/Marlin/src/gcode/feature/runout/M412.cpp index 540a160623..9a06357132 100644 --- a/Marlin/src/gcode/feature/runout/M412.cpp +++ b/Marlin/src/gcode/feature/runout/M412.cpp @@ -54,10 +54,15 @@ void GcodeSuite::M412() { else { SERIAL_ECHO_START(); SERIAL_ECHOPGM("Filament runout "); - serialprintln_onoff(runout.enabled); + serialprint_onoff(runout.enabled); #if HAS_FILAMENT_RUNOUT_DISTANCE - SERIAL_ECHOLNPAIR("Filament runout distance (mm): ", runout.runout_distance()); + SERIAL_ECHOPAIR(" ; Distance ", runout.runout_distance(), "mm"); #endif + #if ENABLED(HOST_ACTION_COMMANDS) + SERIAL_ECHOPGM(" ; Host handling "); + serialprint_onoff(runout.host_handling); + #endif + SERIAL_EOL(); } } diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index a3fb07df13..9a7f1fbce9 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -40,7 +40,7 @@ void tmc_set_stealthChop(TMC &st, const bool enable) { st.refresh_stepping_mode(); } -static void set_stealth_status(const bool enable, const int8_t target_extruder) { +static void set_stealth_status(const bool enable, const int8_t target_e_stepper) { #define TMC_SET_STEALTH(Q) tmc_set_stealthChop(stepper##Q, enable) #if X_HAS_STEALTHCHOP || Y_HAS_STEALTHCHOP || Z_HAS_STEALTHCHOP \ @@ -82,17 +82,19 @@ static void set_stealth_status(const bool enable, const int8_t target_extruder) case K_AXIS: TMC_SET_STEALTH(K); break; #endif - #if HAS_EXTRUDERS + #if E_STEPPERS case E_AXIS: { - if (target_extruder < 0) return; - OPTCODE(E0_HAS_STEALTHCHOP, else if (target_extruder == 0) TMC_SET_STEALTH(E0)) - OPTCODE(E1_HAS_STEALTHCHOP, else if (target_extruder == 1) TMC_SET_STEALTH(E1)) - OPTCODE(E2_HAS_STEALTHCHOP, else if (target_extruder == 2) TMC_SET_STEALTH(E2)) - OPTCODE(E3_HAS_STEALTHCHOP, else if (target_extruder == 3) TMC_SET_STEALTH(E3)) - OPTCODE(E4_HAS_STEALTHCHOP, else if (target_extruder == 4) TMC_SET_STEALTH(E4)) - OPTCODE(E5_HAS_STEALTHCHOP, else if (target_extruder == 5) TMC_SET_STEALTH(E5)) - OPTCODE(E6_HAS_STEALTHCHOP, else if (target_extruder == 6) TMC_SET_STEALTH(E6)) - OPTCODE(E7_HAS_STEALTHCHOP, else if (target_extruder == 7) TMC_SET_STEALTH(E7)) + if (target_e_stepper < 0) return; + switch (target_e_stepper) { + TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_STEALTH(E0); break;) + TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_STEALTH(E1); break;) + TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_STEALTH(E2); break;) + TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_STEALTH(E3); break;) + TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_STEALTH(E4); break;) + TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_STEALTH(E5); break;) + TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_STEALTH(E6); break;) + TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_STEALTH(E7); break;) + } } break; #endif } @@ -131,7 +133,7 @@ static void say_stealth_status() { */ void GcodeSuite::M569() { if (parser.seen('S')) - set_stealth_status(parser.value_bool(), get_target_extruder_from_command()); + set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command()); else say_stealth_status(); } diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index 70e6a00b36..9e56e51358 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -102,11 +102,11 @@ void GcodeSuite::M906() { case K_AXIS: TMC_SET_CURRENT(K); break; #endif - #if HAS_EXTRUDERS + #if E_STEPPERS case E_AXIS: { - const int8_t target_extruder = get_target_extruder_from_command(); - if (target_extruder < 0) return; - switch (target_extruder) { + const int8_t target_e_stepper = get_target_e_stepper_from_command(); + if (target_e_stepper < 0) return; + switch (target_e_stepper) { #if AXIS_IS_TMC(E0) case 0: TMC_SET_CURRENT(E0); break; #endif diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 747f1c9516..fca16c0630 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -260,25 +260,27 @@ #endif case Z_AXIS: - TERN_(Z_HAS_STEALTCHOP, if (index < 2) TMC_SET_PWMTHRS(Z,Z)); - TERN_(Z2_HAS_STEALTCHOP, if (index == 0 || index == 2) TMC_SET_PWMTHRS(Z,Z2)); - TERN_(Z3_HAS_STEALTCHOP, if (index == 0 || index == 3) TMC_SET_PWMTHRS(Z,Z3)); - TERN_(Z4_HAS_STEALTCHOP, if (index == 0 || index == 4) TMC_SET_PWMTHRS(Z,Z4)); + TERN_(Z_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Z,Z)); + TERN_(Z2_HAS_STEALTHCHOP, if (index == 0 || index == 2) TMC_SET_PWMTHRS(Z,Z2)); + TERN_(Z3_HAS_STEALTHCHOP, if (index == 0 || index == 3) TMC_SET_PWMTHRS(Z,Z3)); + TERN_(Z4_HAS_STEALTHCHOP, if (index == 0 || index == 4) TMC_SET_PWMTHRS(Z,Z4)); break; - case E_AXIS: { - #if E_STEPPERS - const int8_t target_extruder = get_target_extruder_from_command(); - if (target_extruder < 0) return; - TERN_(E0_HAS_STEALTHCHOP, else if (target_extruder == 0) TMC_SET_PWMTHRS_E(0)); - TERN_(E1_HAS_STEALTHCHOP, else if (target_extruder == 1) TMC_SET_PWMTHRS_E(1)); - TERN_(E2_HAS_STEALTHCHOP, else if (target_extruder == 2) TMC_SET_PWMTHRS_E(2)); - TERN_(E3_HAS_STEALTHCHOP, else if (target_extruder == 3) TMC_SET_PWMTHRS_E(3)); - TERN_(E4_HAS_STEALTHCHOP, else if (target_extruder == 4) TMC_SET_PWMTHRS_E(4)); - TERN_(E5_HAS_STEALTHCHOP, else if (target_extruder == 5) TMC_SET_PWMTHRS_E(5)); - TERN_(E6_HAS_STEALTHCHOP, else if (target_extruder == 6) TMC_SET_PWMTHRS_E(6)); - TERN_(E7_HAS_STEALTHCHOP, else if (target_extruder == 7) TMC_SET_PWMTHRS_E(7)); - #endif // E_STEPPERS - } break; + #if E_STEPPERS + case E_AXIS: { + const int8_t target_e_stepper = get_target_e_stepper_from_command(); + if (target_e_stepper < 0) return; + switch (target_e_stepper) { + TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_PWMTHRS_E(0); break;) + TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_PWMTHRS_E(1); break;) + TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_PWMTHRS_E(2); break;) + TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_PWMTHRS_E(3); break;) + TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_PWMTHRS_E(4); break;) + TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_PWMTHRS_E(5); break;) + TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_PWMTHRS_E(6); break;) + TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_PWMTHRS_E(7); break;) + } + } break; + #endif // E_STEPPERS } } diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index eb650851f8..7933c3141a 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -292,7 +292,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #endif #if ENABLED(FLOWMETER_SAFETY) - if (cooler.fault) { + if (cooler.flowfault) { SERIAL_ECHO_MSG(STR_FLOWMETER_FAULT); return; } @@ -441,20 +441,23 @@ 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) - #if ENABLED(COOLANT_MIST) - case 7: M7(); break; // M7: Mist coolant ON - #endif - #if ENABLED(COOLANT_FLOOD) - case 8: M8(); break; // M8: Flood coolant ON - #endif - case 9: M9(); break; // M9: Coolant OFF + #if ENABLED(COOLANT_MIST) + case 7: M7(); break; // M7: Coolant Mist ON + #endif + + #if EITHER(AIR_ASSIST, COOLANT_FLOOD) + case 8: M8(); break; // M8: Air Assist / Coolant Flood ON + #endif + + #if EITHER(AIR_ASSIST, COOLANT_CONTROL) + case 9: M9(); break; // M9: Air Assist / Coolant OFF + #endif + + #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 #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) @@ -726,6 +729,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 250: M250(); break; // M250: Set LCD contrast #endif + #if HAS_LCD_BRIGHTNESS + case 256: M256(); break; // M256: Set LCD brightness + #endif + #if ENABLED(EXPERIMENTAL_I2CBUS) case 260: M260(); break; // M260: Send data to an i2c slave case 261: M261(); break; // M261: Request data from an i2c slave @@ -905,7 +912,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 907: M907(); break; // M907: Set digital trimpot motor current using axis codes. #if EITHER(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC) case 908: M908(); break; // M908: Control digital trimpot directly. - #if ENABLED(HAS_MOTOR_CURRENT_DAC) + #if HAS_MOTOR_CURRENT_DAC case 909: M909(); break; // M909: Print digipot/DAC current value case 910: M910(); break; // M910: Commit digipot/DAC value to external EEPROM #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index abd7f07916..ccbeda6474 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -191,6 +191,7 @@ * M226 - Wait until a pin is in a given state: "M226 P S" (Requires DIRECT_PIN_CONTROL) * M240 - Trigger a camera to take a photograph. (Requires PHOTO_GCODE) * M250 - Set LCD contrast: "M250 C" (0-63). (Requires LCD support) + * M256 - Set LCD brightness: "M256 B" (0-255). (Requires an LCD with brightness control) * M260 - i2c Send Data (Requires EXPERIMENTAL_I2CBUS) * M261 - i2c Request Data (Requires EXPERIMENTAL_I2CBUS) * M280 - Set servo position absolute: "M280 P S". (Requires servos) @@ -241,6 +242,7 @@ * M553 - Get or set IP netmask. (Requires enabled Ethernet port) * M554 - Get or set IP gateway. (Requires enabled Ethernet port) * M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160) + * M575 - Change the serial baud rate. (Requires BAUD_RATE_GCODE) * M600 - Pause for filament change: "M600 X Y Z E L". (Requires ADVANCED_PAUSE_FEATURE) * M603 - Configure filament change: "M603 T U L". (Requires ADVANCED_PAUSE_FEATURE) * M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) @@ -297,6 +299,7 @@ * M997 - Perform in-application firmware update * M999 - Restart after being stopped by error * D... - Custom Development G-code. Add hooks to 'gcode_D.cpp' for developers to test features. (Requires MARLIN_DEV_MODE) + * D576 - Set buffer monitoring options. (Requires BUFFER_MONITORING) * * "T" Codes * @@ -392,7 +395,7 @@ public: static void process_subcommands_now(char * gcode); static inline void home_all_axes(const bool keep_leveling=false) { - process_subcommands_now_P(keep_leveling ? G28_STR : TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR)); + process_subcommands_now_P(keep_leveling ? G28_STR : TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR)); } #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) @@ -424,6 +427,7 @@ public: static uint8_t host_keepalive_interval; static void host_keepalive(); + static inline bool host_keepalive_is_paused() { return busy_state >= PAUSED_FOR_USER; } #define KEEPALIVE_STATE(N) REMEMBER(_KA_, gcode.busy_state, gcode.N) #else @@ -524,7 +528,7 @@ private: static void G38(const int8_t subcode); #endif - #if ENABLED(HAS_MESH) + #if HAS_MESH static void G42(); #endif @@ -557,29 +561,32 @@ private: static void G425(); #endif - #if ENABLED(HAS_RESUME_CONTINUE) + #if HAS_RESUME_CONTINUE static void M0_M1(); #endif #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) - #if ENABLED(COOLANT_MIST) - static void M7(); - #endif - #if ENABLED(COOLANT_FLOOD) - static void M8(); - #endif + #if ENABLED(COOLANT_MIST) + static void M7(); + #endif + + #if EITHER(AIR_ASSIST, COOLANT_FLOOD) + static void M8(); + #endif + + #if EITHER(AIR_ASSIST, COOLANT_CONTROL) static void M9(); #endif + #if ENABLED(AIR_EVACUATION) + static void M10(); + static void M11(); + #endif + #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) static void M12(); #endif @@ -609,7 +616,7 @@ private: static void M31(); #if ENABLED(SDSUPPORT) - #if ENABLED(HAS_MEDIA_SUBCALLS) + #if HAS_MEDIA_SUBCALLS static void M32(); #endif #if ENABLED(LONG_FILENAME_HOST_SUPPORT) @@ -740,7 +747,7 @@ private: static void M149(); #endif - #if ENABLED(HAS_COLOR_LEDS) + #if HAS_COLOR_LEDS static void M150(); #endif @@ -774,7 +781,7 @@ private: static void M204(); static void M205(); - #if ENABLED(HAS_M206_COMMAND) + #if HAS_M206_COMMAND static void M206(); #endif @@ -788,11 +795,11 @@ private: static void M211(); - #if ENABLED(HAS_MULTI_EXTRUDER) + #if HAS_MULTI_EXTRUDER static void M217(); #endif - #if ENABLED(HAS_HOTEND_OFFSET) + #if HAS_HOTEND_OFFSET static void M218(); #endif @@ -810,10 +817,14 @@ private: static void M240(); #endif - #if ENABLED(HAS_LCD_CONTRAST) + #if HAS_LCD_CONTRAST static void M250(); #endif + #if HAS_LCD_BRIGHTNESS + static void M256(); + #endif + #if ENABLED(EXPERIMENTAL_I2CBUS) static void M260(); static void M261(); @@ -830,7 +841,7 @@ private: static void M290(); #endif - #if ENABLED(HAS_BUZZER) + #if HAS_BUZZER static void M300(); #endif @@ -842,7 +853,7 @@ private: static void M302(); #endif - #if ENABLED(HAS_PID_HEATING) + #if HAS_PID_HEATING static void M303(); #endif @@ -850,7 +861,7 @@ private: static void M304(); #endif - #if ENABLED(HAS_USER_THERMISTORS) + #if HAS_USER_THERMISTORS static void M305(); #endif @@ -891,7 +902,7 @@ private: static void M402(); #endif - #if ENABLED(HAS_PRUSA_MMU2) + #if HAS_PRUSA_MMU2 static void M403(); #endif @@ -902,11 +913,11 @@ private: static void M407(); #endif - #if ENABLED(HAS_FILAMENT_SENSOR) + #if HAS_FILAMENT_SENSOR static void M412(); #endif - #if ENABLED(HAS_MULTI_LANGUAGE) + #if HAS_MULTI_LANGUAGE static void M414(); #endif @@ -919,11 +930,11 @@ private: static void M425(); #endif - #if ENABLED(HAS_M206_COMMAND) + #if HAS_M206_COMMAND static void M428(); #endif - #if ENABLED(HAS_POWER_MONITOR) + #if HAS_POWER_MONITOR static void M430(); #endif @@ -974,11 +985,11 @@ private: static void M603(); #endif - #if ENABLED(HAS_DUPLICATION_MODE) + #if HAS_DUPLICATION_MODE static void M605(); #endif - #if ENABLED(IS_KINEMATIC) + #if IS_KINEMATIC static void M665(); #endif @@ -1003,7 +1014,7 @@ private: static void M810_819(); #endif - #if ENABLED(HAS_BED_PROBE) + #if HAS_BED_PROBE static void M851(); #endif @@ -1036,7 +1047,7 @@ private: #if HAS_TRINAMIC_CONFIG static void M122(); static void M906(); - #if ENABLED(HAS_STEALTHCHOP) + #if HAS_STEALTHCHOP static void M569(); #endif #if ENABLED(MONITOR_DRIVER_STATUS) @@ -1063,7 +1074,7 @@ private: static void M907(); #if EITHER(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC) static void M908(); - #if ENABLED(HAS_MOTOR_CURRENT_DAC) + #if HAS_MOTOR_CURRENT_DAC static void M909(); static void M910(); #endif diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 52a273964a..b317a17815 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -23,248 +23,279 @@ #if ENABLED(MARLIN_DEV_MODE) - #include "gcode.h" - #include "../module/settings.h" - #include "../module/temperature.h" - #include "../libs/hex_print.h" - #include "../HAL/shared/eeprom_if.h" - #include "../HAL/shared/Delay.h" - #include "../sd/cardreader.h" - #include "../MarlinCore.h" // for kill +#include "gcode.h" - extern void dump_delay_accuracy_check(); +#if ENABLED(BUFFER_MONITORING) + #include "queue.h" +#endif - /** - * Dn: G-code for development and testing - * - * See https://reprap.org/wiki/G-code#D:_Debug_codes - * - * Put whatever else you need here to test ongoing development. - */ - void GcodeSuite::D(const int16_t dcode) { - switch (dcode) { +#include "../module/settings.h" +#include "../module/temperature.h" +#include "../libs/hex_print.h" +#include "../HAL/shared/eeprom_if.h" +#include "../HAL/shared/Delay.h" +#include "../sd/cardreader.h" +#include "../MarlinCore.h" // for kill - case -1: - for (;;) { /* loop forever (watchdog reset) */ } +extern void dump_delay_accuracy_check(); - case 0: - HAL_reboot(); - break; +/** + * Dn: G-code for development and testing + * + * See https://reprap.org/wiki/G-code#D:_Debug_codes + * + * Put whatever else you need here to test ongoing development. + */ +void GcodeSuite::D(const int16_t dcode) { + switch (dcode) { - case 10: - kill(PSTR("D10"), PSTR("KILL TEST"), parser.seen_test('P')); - break; + case -1: + for (;;) { /* loop forever (watchdog reset) */ } - case 1: { - // Zero or pattern-fill the EEPROM data - #if ENABLED(EEPROM_SETTINGS) - persistentStore.access_start(); - size_t total = persistentStore.capacity(); - int pos = 0; - const uint8_t value = 0x0; - while (total--) persistentStore.write_data(pos, &value, 1); - persistentStore.access_finish(); - #else - settings.reset(); - settings.save(); - #endif - HAL_reboot(); - } break; + case 0: + HAL_reboot(); + break; - case 2: { // D2 Read / Write SRAM - #define SRAM_SIZE 8192 - uint8_t *pointer = parser.hex_adr_val('A'); - uint16_t len = parser.ushortval('C', 1); - uintptr_t addr = (uintptr_t)pointer; - NOMORE(addr, size_t(SRAM_SIZE - 1)); - NOMORE(len, SRAM_SIZE - addr); - if (parser.seenval('X')) { - // Write the hex bytes after the X - uint16_t val = parser.hex_val('X'); - while (len--) { - *pointer = val; - pointer++; - } - } - else { - while (len--) print_hex_byte(*(pointer++)); - SERIAL_EOL(); - } - } break; + case 10: + kill(PSTR("D10"), PSTR("KILL TEST"), parser.seen_test('P')); + break; + case 1: { + // Zero or pattern-fill the EEPROM data #if ENABLED(EEPROM_SETTINGS) - case 3: { // D3 Read / Write EEPROM - uint8_t *pointer = parser.hex_adr_val('A'); - uint16_t len = parser.ushortval('C', 1); - uintptr_t addr = (uintptr_t)pointer; - NOMORE(addr, size_t(persistentStore.capacity() - 1)); - NOMORE(len, persistentStore.capacity() - addr); - if (parser.seenval('X')) { - uint16_t val = parser.hex_val('X'); - #if ENABLED(EEPROM_SETTINGS) - persistentStore.access_start(); - while (len--) { - int pos = 0; - persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val)); - } - SERIAL_EOL(); - persistentStore.access_finish(); - #else - SERIAL_ECHOLNPGM("NO EEPROM"); - #endif - } - else { - // Read bytes from EEPROM - #if ENABLED(EEPROM_SETTINGS) - persistentStore.access_start(); - int pos = 0; - uint8_t val; - while (len--) if (!persistentStore.read_data(pos, &val, 1)) print_hex_byte(val); - SERIAL_EOL(); - persistentStore.access_finish(); - #else - SERIAL_ECHOLNPGM("NO EEPROM"); - len = 0; - #endif - SERIAL_EOL(); - } - } break; + persistentStore.access_start(); + size_t total = persistentStore.capacity(); + int pos = 0; + const uint8_t value = 0x0; + while (total--) persistentStore.write_data(pos, &value, 1); + persistentStore.access_finish(); + #else + settings.reset(); + settings.save(); #endif + HAL_reboot(); + } break; - case 4: { // D4 Read / Write PIN - //const bool is_out = parser.boolval('F'); - //const uint8_t pin = parser.byteval('P'), - // val = parser.byteval('V', LOW); - if (parser.seenval('X')) { - // TODO: Write the hex bytes after the X - //while (len--) { - //} + case 2: { // D2 Read / Write SRAM + #define SRAM_SIZE 8192 + uint8_t *pointer = parser.hex_adr_val('A'); + uint16_t len = parser.ushortval('C', 1); + uintptr_t addr = (uintptr_t)pointer; + NOMORE(addr, size_t(SRAM_SIZE - 1)); + NOMORE(len, SRAM_SIZE - addr); + if (parser.seenval('X')) { + // Write the hex bytes after the X + uint16_t val = parser.hex_val('X'); + while (len--) { + *pointer = val; + pointer++; } - else { - //while (len--) { - //// TODO: Read bytes from EEPROM - // print_hex_byte(eeprom_read_byte(adr++)); - //} - SERIAL_EOL(); - } - } break; + } + else { + while (len--) print_hex_byte(*(pointer++)); + SERIAL_EOL(); + } + } break; - case 5: { // D5 Read / Write onboard Flash - #define FLASH_SIZE 1024 + #if ENABLED(EEPROM_SETTINGS) + case 3: { // D3 Read / Write EEPROM uint8_t *pointer = parser.hex_adr_val('A'); uint16_t len = parser.ushortval('C', 1); uintptr_t addr = (uintptr_t)pointer; - NOMORE(addr, size_t(FLASH_SIZE - 1)); - NOMORE(len, FLASH_SIZE - addr); + NOMORE(addr, size_t(persistentStore.capacity() - 1)); + NOMORE(len, persistentStore.capacity() - addr); if (parser.seenval('X')) { - // TODO: Write the hex bytes after the X - //while (len--) {} + uint16_t val = parser.hex_val('X'); + #if ENABLED(EEPROM_SETTINGS) + persistentStore.access_start(); + while (len--) { + int pos = 0; + persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val)); + } + SERIAL_EOL(); + persistentStore.access_finish(); + #else + SERIAL_ECHOLNPGM("NO EEPROM"); + #endif } else { - //while (len--) { - //// TODO: Read bytes from EEPROM - // print_hex_byte(eeprom_read_byte(adr++)); - //} + // Read bytes from EEPROM + #if ENABLED(EEPROM_SETTINGS) + persistentStore.access_start(); + int pos = 0; + uint8_t val; + while (len--) if (!persistentStore.read_data(pos, &val, 1)) print_hex_byte(val); + SERIAL_EOL(); + persistentStore.access_finish(); + #else + SERIAL_ECHOLNPGM("NO EEPROM"); + len = 0; + #endif SERIAL_EOL(); } } break; + #endif - case 6: // D6 Check delay loop accuracy - dump_delay_accuracy_check(); - break; + case 4: { // D4 Read / Write PIN + //const bool is_out = parser.boolval('F'); + //const uint8_t pin = parser.byteval('P'), + // val = parser.byteval('V', LOW); + if (parser.seenval('X')) { + // TODO: Write the hex bytes after the X + //while (len--) { + //} + } + else { + //while (len--) { + //// TODO: Read bytes from EEPROM + // print_hex_byte(eeprom_read_byte(adr++)); + //} + SERIAL_EOL(); + } + } break; - case 7: // D7 dump the current serial port type (hence configuration) - SERIAL_ECHOLNPAIR("Current serial configuration RX_BS:", RX_BUFFER_SIZE, ", TX_BS:", TX_BUFFER_SIZE); - SERIAL_ECHOLN(gtn(&SERIAL_IMPL)); - break; + case 5: { // D5 Read / Write onboard Flash + #define FLASH_SIZE 1024 + uint8_t *pointer = parser.hex_adr_val('A'); + uint16_t len = parser.ushortval('C', 1); + uintptr_t addr = (uintptr_t)pointer; + NOMORE(addr, size_t(FLASH_SIZE - 1)); + NOMORE(len, FLASH_SIZE - addr); + if (parser.seenval('X')) { + // TODO: Write the hex bytes after the X + //while (len--) {} + } + else { + //while (len--) { + //// TODO: Read bytes from EEPROM + // print_hex_byte(eeprom_read_byte(adr++)); + //} + SERIAL_EOL(); + } + } break; - case 100: { // D100 Disable heaters and attempt a hard hang (Watchdog Test) - SERIAL_ECHOLNPGM("Disabling heaters and attempting to trigger Watchdog"); - SERIAL_ECHOLNPGM("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")"); - thermalManager.disable_all_heaters(); - delay(1000); // Allow time to print - DISABLE_ISRS(); - // Use a low-level delay that does not rely on interrupts to function - // Do not spin forever, to avoid thermal risks if heaters are enabled and - // watchdog does not work. - for (int i = 10000; i--;) DELAY_US(1000UL); - ENABLE_ISRS(); - SERIAL_ECHOLNPGM("FAILURE: Watchdog did not trigger board reset."); + case 6: // D6 Check delay loop accuracy + dump_delay_accuracy_check(); + break; + + case 7: // D7 dump the current serial port type (hence configuration) + SERIAL_ECHOLNPAIR("Current serial configuration RX_BS:", RX_BUFFER_SIZE, ", TX_BS:", TX_BUFFER_SIZE); + SERIAL_ECHOLN(gtn(&SERIAL_IMPL)); + break; + + case 100: { // D100 Disable heaters and attempt a hard hang (Watchdog Test) + SERIAL_ECHOLNPGM("Disabling heaters and attempting to trigger Watchdog"); + SERIAL_ECHOLNPGM("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")"); + thermalManager.disable_all_heaters(); + delay(1000); // Allow time to print + DISABLE_ISRS(); + // Use a low-level delay that does not rely on interrupts to function + // Do not spin forever, to avoid thermal risks if heaters are enabled and + // watchdog does not work. + for (int i = 10000; i--;) DELAY_US(1000UL); + ENABLE_ISRS(); + SERIAL_ECHOLNPGM("FAILURE: Watchdog did not trigger board reset."); + } break; + + #if ENABLED(SDSUPPORT) + + case 101: { // D101 Test SD Write + card.openFileWrite("test.gco"); + if (!card.isFileOpen()) { + SERIAL_ECHOLNPAIR("Failed to open test.gco to write."); + return; + } + __attribute__((aligned(sizeof(size_t)))) uint8_t buf[512]; + + uint16_t c; + for (c = 0; c < COUNT(buf); c++) + buf[c] = 'A' + (c % ('Z' - 'A')); + + c = 1024 * 4; + while (c--) { + TERN_(USE_WATCHDOG, watchdog_refresh()); + card.write(buf, COUNT(buf)); + } + SERIAL_ECHOLNPGM(" done"); + card.closefile(); } break; - #if ENABLED(SDSUPPORT) - - case 101: { // D101 Test SD Write - card.openFileWrite("test.gco"); - if (!card.isFileOpen()) { - SERIAL_ECHOLNPAIR("Failed to open test.gco to write."); - return; - } - __attribute__((aligned(sizeof(size_t)))) uint8_t buf[512]; - - uint16_t c; - for (c = 0; c < COUNT(buf); c++) - buf[c] = 'A' + (c % ('Z' - 'A')); - - c = 1024 * 4; - while (c--) { - TERN_(USE_WATCHDOG, watchdog_refresh()); - card.write(buf, COUNT(buf)); - } - SERIAL_ECHOLNPGM(" done"); - card.closefile(); - } break; - - case 102: { // D102 Test SD Read - char testfile[] = "test.gco"; - card.openFileRead(testfile); - if (!card.isFileOpen()) { - SERIAL_ECHOLNPAIR("Failed to open test.gco to read."); - return; - } - __attribute__((aligned(sizeof(size_t)))) uint8_t buf[512]; - uint16_t c = 1024 * 4; - while (c--) { - TERN_(USE_WATCHDOG, watchdog_refresh()); - card.read(buf, COUNT(buf)); - bool error = false; - for (uint16_t i = 0; i < COUNT(buf); i++) { - if (buf[i] != ('A' + (i % ('Z' - 'A')))) { - error = true; - break; - } - } - if (error) { - SERIAL_ECHOLNPGM(" Read error!"); + case 102: { // D102 Test SD Read + char testfile[] = "test.gco"; + card.openFileRead(testfile); + if (!card.isFileOpen()) { + SERIAL_ECHOLNPAIR("Failed to open test.gco to read."); + return; + } + __attribute__((aligned(sizeof(size_t)))) uint8_t buf[512]; + uint16_t c = 1024 * 4; + while (c--) { + TERN_(USE_WATCHDOG, watchdog_refresh()); + card.read(buf, COUNT(buf)); + bool error = false; + for (uint16_t i = 0; i < COUNT(buf); i++) { + if (buf[i] != ('A' + (i % ('Z' - 'A')))) { + error = true; break; } } - SERIAL_ECHOLNPGM(" done"); - card.closefile(); - } break; - - #endif // SDSUPPORT - - #if ENABLED(POSTMORTEM_DEBUGGING) - - case 451: { // Trigger all kind of faults to test exception catcher - SERIAL_ECHOLNPGM("Disabling heaters"); - thermalManager.disable_all_heaters(); - delay(1000); // Allow time to print - volatile uint8_t type[5] = { parser.byteval('T', 1) }; - - // The code below is obviously wrong and it's full of quirks to fool the compiler from optimizing away the code - switch (type[0]) { - case 1: default: *(int*)0 = 451; break; // Write at bad address - case 2: { volatile int a = 0; volatile int b = 452 / a; *(int*)&a = b; } break; // Divide by zero (some CPUs accept this, like ARM) - case 3: { *(uint32_t*)&type[1] = 453; volatile int a = *(int*)&type[1]; type[0] = a / 255; } break; // Unaligned access (some CPUs accept this) - case 4: { volatile void (*func)() = (volatile void (*)()) 0xE0000000; func(); } break; // Invalid instruction + if (error) { + SERIAL_ECHOLNPGM(" Read error!"); + break; } - break; } + SERIAL_ECHOLNPGM(" done"); + card.closefile(); + } break; - #endif - } + #endif // SDSUPPORT + + #if ENABLED(POSTMORTEM_DEBUGGING) + + case 451: { // Trigger all kind of faults to test exception catcher + SERIAL_ECHOLNPGM("Disabling heaters"); + thermalManager.disable_all_heaters(); + delay(1000); // Allow time to print + volatile uint8_t type[5] = { parser.byteval('T', 1) }; + + // The code below is obviously wrong and it's full of quirks to fool the compiler from optimizing away the code + switch (type[0]) { + case 1: default: *(int*)0 = 451; break; // Write at bad address + case 2: { volatile int a = 0; volatile int b = 452 / a; *(int*)&a = b; } break; // Divide by zero (some CPUs accept this, like ARM) + case 3: { *(uint32_t*)&type[1] = 453; volatile int a = *(int*)&type[1]; type[0] = a / 255; } break; // Unaligned access (some CPUs accept this) + case 4: { volatile void (*func)() = (volatile void (*)()) 0xE0000000; func(); } break; // Invalid instruction + } + break; + } + + #endif + + #if ENABLED(BUFFER_MONITORING) + + /** + * D576: Return buffer stats or set the auto-report interval. + * Usage: D576 [S] + * + * With no parameters emits the following output: + * "D576 P B PU PD BU BD" + * Where: + * P : Planner buffers free + * B : Command buffers free + * PU: Planner buffer underruns (since the last report) + * PD: Longest duration (ms) the planner buffer was empty (since the last report) + * BU: Command buffer underruns (since the last report) + * BD: Longest duration (ms) command buffer was empty (since the last report) + */ + case 576: { + if (parser.seenval('S')) + queue.set_auto_report_interval((uint8_t)parser.value_byte()); + else + queue.report_buffer_statistics(); + break; + } + + #endif // BUFFER_MONITORING } +} -#endif +#endif // MARLIN_DEV_MODE diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index 2fdce1edfd..7d69033319 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -216,10 +216,12 @@ void GcodeSuite::M114() { report_current_position_detail(); return; } - if (parser.seen_test('E')) { - SERIAL_ECHOLNPAIR("Count E:", stepper.position(E_AXIS)); - return; - } + #if HAS_EXTRUDERS + if (parser.seen_test('E')) { + SERIAL_ECHOLNPAIR("Count E:", stepper.position(E_AXIS)); + return; + } + #endif #endif #if ENABLED(M114_REALTIME) diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 49bb806377..3b88c6905e 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -54,6 +54,9 @@ void GcodeSuite::M115() { "PROTOCOL_VERSION:" PROTOCOL_VERSION " " "MACHINE_TYPE:" MACHINE_NAME " " "EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " " + #if LINEAR_AXES != XYZ + "AXIS_COUNT:" STRINGIFY(LINEAR_AXES) " " + #endif #ifdef MACHINE_UUID "UUID:" MACHINE_UUID #endif diff --git a/Marlin/src/gcode/lcd/M256.cpp b/Marlin/src/gcode/lcd/M256.cpp new file mode 100644 index 0000000000..e292acc4ed --- /dev/null +++ b/Marlin/src/gcode/lcd/M256.cpp @@ -0,0 +1,37 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include "../../inc/MarlinConfig.h" + +#if HAS_LCD_BRIGHTNESS + +#include "../gcode.h" +#include "../../lcd/marlinui.h" + +/** + * M256: Set the LCD brightness + */ +void GcodeSuite::M256() { + if (parser.seenval('B')) ui.set_brightness(parser.value_int()); + SERIAL_ECHOLNPAIR("LCD Brightness: ", ui.brightness); +} + +#endif // HAS_LCD_BRIGHTNESS diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index 5b135bdff8..e94a2825f7 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -35,13 +35,13 @@ * M73 P25 ; Set progress to 25% */ void GcodeSuite::M73() { - if (parser.seen('P')) + if (parser.seenval('P')) ui.set_progress((PROGRESS_SCALE) > 1 ? parser.value_float() * (PROGRESS_SCALE) : parser.value_byte() ); #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) - if (parser.seen('R')) ui.set_remaining_time(60 * parser.value_ulong()); + if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong()); #endif } diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index 170789d827..094afdb70e 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -83,12 +83,13 @@ void plan_arc( #endif // Angle of rotation between position and target from the circle center. - float angular_travel; + float angular_travel, abs_angular_travel; // Do a full circle if starting and ending positions are "identical" if (NEAR(current_position[p_axis], cart[p_axis]) && NEAR(current_position[q_axis], cart[q_axis])) { // Preserve direction for circles angular_travel = clockwise ? -RADIANS(360) : RADIANS(360); + abs_angular_travel = RADIANS(360); } else { // Calculate the angle @@ -103,8 +104,10 @@ void plan_arc( case 2: angular_travel += RADIANS(360); break; // Negative but CCW? Reverse direction. } + abs_angular_travel = ABS(angular_travel); + #ifdef MIN_ARC_SEGMENTS - min_segments = CEIL(min_segments * ABS(angular_travel) / RADIANS(360)); + min_segments = CEIL(min_segments * abs_angular_travel / RADIANS(360)); NOLESS(min_segments, 1U); #endif } @@ -117,8 +120,8 @@ void plan_arc( #endif // If circling around... - if (ENABLED(ARC_P_CIRCLES) && circles) { - const float total_angular = angular_travel + circles * RADIANS(360), // Total rotation with all circles and remainder + if (TERN0(ARC_P_CIRCLES, circles)) { + const float total_angular = abs_angular_travel + circles * RADIANS(360), // Total rotation with all circles and remainder part_per_circle = RADIANS(360) / total_angular; // Each circle's part of the total #if HAS_Z_AXIS @@ -138,8 +141,8 @@ void plan_arc( TERN_(HAS_EXTRUDERS, extruder_travel = cart.e - current_position.e); } - const float flat_mm = radius * angular_travel, - mm_of_travel = TERN_(HAS_Z_AXIS, linear_travel ? HYPOT(flat_mm, linear_travel) :) ABS(flat_mm); + const float flat_mm = radius * abs_angular_travel, + mm_of_travel = TERN_(HAS_Z_AXIS, linear_travel ? HYPOT(flat_mm, linear_travel) :) flat_mm; if (mm_of_travel < 0.001f) return; const feedRate_t scaled_fr_mm_s = MMS_SCALED(feedrate_mm_s); diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 5a1748cc4d..08cf10004a 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -311,7 +311,13 @@ public: } static inline float axis_unit_factor(const AxisEnum axis) { - return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); + return ( + #if HAS_EXTRUDERS + axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor + #else + linear_unit_factor + #endif + ); } static inline float linear_value_to_mm(const_float_t v) { return v * linear_unit_factor; } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 09755fbf21..fa83c82ddc 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -67,6 +67,23 @@ GCodeQueue::RingBuffer GCodeQueue::ring_buffer = { 0 }; static millis_t last_command_time = 0; #endif +/** + * Track buffer underruns + */ +#if ENABLED(BUFFER_MONITORING) + uint32_t GCodeQueue::command_buffer_underruns = 0, + GCodeQueue::planner_buffer_underruns = 0; + bool GCodeQueue::command_buffer_empty = false, + GCodeQueue::planner_buffer_empty = false; + millis_t GCodeQueue::max_command_buffer_empty_duration = 0, + GCodeQueue::max_planner_buffer_empty_duration = 0, + GCodeQueue::command_buffer_empty_at = 0, + GCodeQueue::planner_buffer_empty_at = 0; + + uint8_t GCodeQueue::auto_buffer_report_interval; + millis_t GCodeQueue::next_buffer_report_ms; +#endif + /** * Serial command injection */ @@ -82,7 +99,6 @@ PGM_P GCodeQueue::injected_commands_P; // = nullptr */ char GCodeQueue::injected_commands[64]; // = { 0 } - void GCodeQueue::RingBuffer::commit_command(bool skip_ok OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/) ) { @@ -621,7 +637,24 @@ void GCodeQueue::advance() { if (process_injected_command_P() || process_injected_command()) return; // Return if the G-code buffer is empty - if (ring_buffer.empty()) return; + if (ring_buffer.empty()) { + #if ENABLED(BUFFER_MONITORING) + if (!command_buffer_empty) { + command_buffer_empty = true; + command_buffer_underruns++; + command_buffer_empty_at = millis(); + } + #endif + return; + } + + #if ENABLED(BUFFER_MONITORING) + if (command_buffer_empty) { + command_buffer_empty = false; + const millis_t command_buffer_empty_duration = millis() - command_buffer_empty_at; + NOLESS(max_command_buffer_empty_duration, command_buffer_empty_duration); + } + #endif #if ENABLED(SDSUPPORT) @@ -664,3 +697,41 @@ void GCodeQueue::advance() { // The queue may be reset by a command handler or by code invoked by idle() within a handler ring_buffer.advance_pos(ring_buffer.index_r, -1); } + +#if ENABLED(BUFFER_MONITORING) + + void GCodeQueue::report_buffer_statistics() { + SERIAL_ECHOLNPAIR("D576" + " P:", planner.moves_free(), " ", -queue.planner_buffer_underruns, " (", queue.max_planner_buffer_empty_duration, ")" + " B:", BUFSIZE - ring_buffer.length, " ", -queue.command_buffer_underruns, " (", queue.max_command_buffer_empty_duration, ")" + ); + command_buffer_underruns = planner_buffer_underruns = 0; + max_command_buffer_empty_duration = max_planner_buffer_empty_duration = 0; + } + + void GCodeQueue::auto_report_buffer_statistics() { + // Bit of a hack to try to catch planner buffer underruns without having logic + // running inside Stepper::block_phase_isr + const millis_t ms = millis(); + if (planner.movesplanned() == 0) { + if (!planner_buffer_empty) { // the planner buffer wasn't empty, but now it is + planner_buffer_empty = true; + planner_buffer_underruns++; + planner_buffer_empty_at = ms; + } + } + else if (planner_buffer_empty) { // the planner buffer was empty, but now it's not + planner_buffer_empty = false; + const millis_t planner_buffer_empty_duration = ms - planner_buffer_empty_at; + NOLESS(max_planner_buffer_empty_duration, planner_buffer_empty_duration); // if it's longer than the currently tracked max duration, replace it + } + + if (queue.auto_buffer_report_interval && ELAPSED(ms, queue.next_buffer_report_ms)) { + queue.next_buffer_report_ms = ms + 1000UL * queue.auto_buffer_report_interval; + PORT_REDIRECT(SERIAL_BOTH); + report_buffer_statistics(); + PORT_RESTORE(); + } + } + +#endif // BUFFER_MONITORING diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index ea99ce7a2d..6bcf4a97e4 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -59,7 +59,7 @@ public: struct CommandLine { char buffer[MAX_CMD_SIZE]; //!< The command buffer bool skip_ok; //!< Skip sending ok when command is processed? - #if ENABLED(HAS_MULTI_SERIAL) + #if HAS_MULTI_SERIAL serial_index_t port; //!< Serial port the command was received on #endif }; @@ -197,6 +197,46 @@ public: */ static inline void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; } + #if ENABLED(BUFFER_MONITORING) + + private: + + /** + * Track buffer underruns + */ + static uint32_t command_buffer_underruns, planner_buffer_underruns; + static bool command_buffer_empty, planner_buffer_empty; + static millis_t max_command_buffer_empty_duration, max_planner_buffer_empty_duration, + command_buffer_empty_at, planner_buffer_empty_at; + + /** + * Report buffer statistics to the host to be able to detect buffer underruns + * + * Returns "D576 " followed by: + * P Planner space remaining + * B Command buffer space remaining + * PU Number of planner buffer underruns since last report + * PD Max time in ms the planner buffer was empty since last report + * BU Number of command buffer underruns since last report + * BD Max time in ms the command buffer was empty since last report + */ + static void report_buffer_statistics(); + + static uint8_t auto_buffer_report_interval; + static millis_t next_buffer_report_ms; + + public: + + static void auto_report_buffer_statistics(); + + static inline void set_auto_report_interval(uint8_t v) { + NOMORE(v, 60); + auto_buffer_report_interval = v; + next_buffer_report_ms = millis() + 1000UL * v; + } + + #endif // BUFFER_MONITORING + private: static void get_serial_commands(); diff --git a/Marlin/src/gcode/sd/M20.cpp b/Marlin/src/gcode/sd/M20.cpp index 7ac4affdae..5731838338 100644 --- a/Marlin/src/gcode/sd/M20.cpp +++ b/Marlin/src/gcode/sd/M20.cpp @@ -33,7 +33,7 @@ void GcodeSuite::M20() { if (card.flag.mounted) { SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST); - card.ls(); + card.ls(TERN_(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L'))); SERIAL_ECHOLNPGM(STR_END_FILE_LIST); } else diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 568d9b0e27..f74d9204bd 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -23,6 +23,9 @@ #include "../gcode.h" #include "../../module/printcounter.h" #include "../../lcd/marlinui.h" +#if ENABLED(HOST_PAUSE_M76) + #include "../../feature/host_actions.h" +#endif #include "../../MarlinCore.h" // for startOrResumeJob @@ -38,6 +41,7 @@ void GcodeSuite::M75() { */ void GcodeSuite::M76() { print_job_timer.pause(); + TERN_(HOST_PAUSE_M76, host_action_pause()); } /** diff --git a/Marlin/src/gcode/temp/M105.cpp b/Marlin/src/gcode/temp/M105.cpp index eefc3ae9f1..4de5ba8eef 100644 --- a/Marlin/src/gcode/temp/M105.cpp +++ b/Marlin/src/gcode/temp/M105.cpp @@ -35,11 +35,7 @@ void GcodeSuite::M105() { #if HAS_TEMP_SENSOR - thermalManager.print_heater_states(target_extruder - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - , parser.boolval('R') - #endif - ); + thermalManager.print_heater_states(target_extruder OPTARG(HAS_TEMP_REDUNDANT, parser.boolval('R'))); SERIAL_EOL(); diff --git a/Marlin/src/gcode/temp/M106_M107.cpp b/Marlin/src/gcode/temp/M106_M107.cpp index dcb0d34ffe..3f85c53d78 100644 --- a/Marlin/src/gcode/temp/M106_M107.cpp +++ b/Marlin/src/gcode/temp/M106_M107.cpp @@ -60,39 +60,40 @@ */ void GcodeSuite::M106() { const uint8_t pfan = parser.byteval('P', _ALT_P); + if (pfan >= _CNT_P) return; + #if REDUNDANT_PART_COOLING_FAN + if (pfan == REDUNDANT_PART_COOLING_FAN) return; + #endif - if (pfan < _CNT_P) { + #if ENABLED(EXTRA_FAN_SPEED) + const uint16_t t = parser.intval('T'); + if (t > 0) return thermalManager.set_temp_fan_speed(pfan, t); + #endif - #if ENABLED(EXTRA_FAN_SPEED) - const uint16_t t = parser.intval('T'); - if (t > 0) return thermalManager.set_temp_fan_speed(pfan, t); - #endif + const uint16_t dspeed = parser.seen_test('A') ? thermalManager.fan_speed[active_extruder] : 255; - const uint16_t dspeed = parser.seen_test('A') ? thermalManager.fan_speed[active_extruder] : 255; + uint16_t speed = dspeed; - uint16_t speed = dspeed; + // Accept 'I' if temperature presets are defined + #if PREHEAT_COUNT + const bool got_preset = parser.seenval('I'); + if (got_preset) speed = ui.material_preset[_MIN(parser.value_byte(), PREHEAT_COUNT - 1)].fan_speed; + #else + constexpr bool got_preset = false; + #endif - // Accept 'I' if temperature presets are defined - #if PREHEAT_COUNT - const bool got_preset = parser.seenval('I'); - if (got_preset) speed = ui.material_preset[_MIN(parser.value_byte(), PREHEAT_COUNT - 1)].fan_speed; - #else - constexpr bool got_preset = false; - #endif + if (!got_preset && parser.seenval('S')) + speed = parser.value_ushort(); - if (!got_preset && parser.seenval('S')) - speed = parser.value_ushort(); + TERN_(FOAMCUTTER_XYUV, speed *= 2.55); // Get command in % of max heat - TERN_(FOAMCUTTER_XYUV, speed *= 2.55); // Get command in % of max heat + // Set speed, with constraint + thermalManager.set_fan_speed(pfan, speed); - // Set speed, with constraint - thermalManager.set_fan_speed(pfan, speed); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); - TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); - - if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating - thermalManager.set_fan_speed(1 - pfan, speed); - } + if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating + thermalManager.set_fan_speed(1 - pfan, speed); } /** @@ -101,6 +102,9 @@ void GcodeSuite::M106() { void GcodeSuite::M107() { const uint8_t pfan = parser.byteval('P', _ALT_P); if (pfan >= _CNT_P) return; + #if REDUNDANT_PART_COOLING_FAN + if (pfan == REDUNDANT_PART_COOLING_FAN) return; + #endif thermalManager.set_fan_speed(pfan, 0); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 07c0439e28..1025a8153b 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -31,6 +31,11 @@ #define MKS_MINI_12864 #endif +// MKS_MINI_12864_V3 is simply identical to FYSETC_MINI_12864_2_1 +#if ENABLED(MKS_MINI_12864_V3) + #define FYSETC_MINI_12864_2_1 +#endif + /** * General Flags that may be set below by specific LCDs * @@ -136,6 +141,13 @@ #define IS_RRD_SC 1 #define IS_U8GLIB_SSD1306 +#elif ENABLED(SAV_3DGLCD) + + #ifdef U8GLIB_SSD1306 + #define IS_U8GLIB_SSD1306 + #endif + #define IS_NEWPANEL 1 + #elif ENABLED(FYSETC_242_OLED_12864) #define IS_RRD_SC 1 @@ -208,7 +220,7 @@ #define LCD_PROGRESS_BAR #endif #if ENABLED(TFTGLCD_PANEL_I2C) - #define LCD_I2C_ADDRESS 0x27 // Must be equal to panel's I2C slave addres + #define LCD_I2C_ADDRESS 0x33 // Must be 0x33 for STM32 main boards and equal to panel's I2C slave addres #endif #define LCD_USE_I2C_BUZZER // Enable buzzer on LCD, used for both I2C and SPI buses (LiquidTWI2 not required) #define STD_ENCODER_PULSES_PER_STEP 2 @@ -405,6 +417,10 @@ #endif +#if EITHER(LCD_I2C_TYPE_MCP23017, LCD_I2C_TYPE_MCP23008) && DISABLED(NO_LCD_DETECT) + #define DETECT_I2C_LCD_DEVICE 1 +#endif + #ifndef STD_ENCODER_PULSES_PER_STEP #if ENABLED(TOUCH_SCREEN) #define STD_ENCODER_PULSES_PER_STEP 2 @@ -466,10 +482,6 @@ #endif // Aliases for LCD features -#if EITHER(IS_ULTRA_LCD, EXTENSIBLE_UI) - #define HAS_DISPLAY 1 -#endif - #if IS_ULTRA_LCD #define HAS_WIRED_LCD 1 #if ENABLED(DOGLCD) @@ -481,6 +493,10 @@ #endif #endif +#if EITHER(HAS_WIRED_LCD, EXTENSIBLE_UI) + #define HAS_DISPLAY 1 +#endif + #if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD, GLOBAL_STATUS_MESSAGE) #define HAS_STATUS_MESSAGE 1 #endif @@ -554,7 +570,12 @@ #undef DISABLE_E #endif -#if ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS +#if ENABLED(E_DUAL_STEPPER_DRIVERS) // E0/E1 steppers act in tandem as E0 + + #define E_STEPPERS 2 + +#elif ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS + #if EXTRUDERS > 4 #define E_STEPPERS 3 #elif EXTRUDERS > 2 @@ -565,17 +586,24 @@ #if DISABLED(SWITCHING_NOZZLE) #define HOTENDS E_STEPPERS #endif -#elif ENABLED(MIXING_EXTRUDER) + +#elif ENABLED(MIXING_EXTRUDER) // Multiple feeds are mixed proportionally + #define E_STEPPERS MIXING_STEPPERS #define E_MANUAL 1 #if MIXING_STEPPERS == 2 #define HAS_DUAL_MIXING 1 #endif -#elif ENABLED(SWITCHING_TOOLHEAD) + +#elif ENABLED(SWITCHING_TOOLHEAD) // Toolchanger + #define E_STEPPERS EXTRUDERS #define E_MANUAL EXTRUDERS -#elif HAS_PRUSA_MMU2 + +#elif HAS_PRUSA_MMU2 // Průša Multi-Material Unit v2 + #define E_STEPPERS 1 + #endif // No inactive extruders with SWITCHING_NOZZLE or Průša MMU1 @@ -713,14 +741,19 @@ #ifndef Z_PROBE_SERVO_NR #define Z_PROBE_SERVO_NR 0 #endif - #undef DEACTIVATE_SERVOS_AFTER_MOVE + #ifdef DEACTIVATE_SERVOS_AFTER_MOVE + #error "BLTOUCH requires DEACTIVATE_SERVOS_AFTER_MOVE to be to disabled. Please update your Configuration.h file." + #endif // Always disable probe pin inverting for BLTouch - #undef Z_MIN_PROBE_ENDSTOP_INVERTING - #define Z_MIN_PROBE_ENDSTOP_INVERTING false + #if Z_MIN_PROBE_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_PROBE_ENDSTOP_INVERTING set to false. Please update your Configuration.h file." + #endif + #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) - #undef Z_MIN_ENDSTOP_INVERTING - #define Z_MIN_ENDSTOP_INVERTING false + #if Z_MIN_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_ENDSTOP_INVERTING set to false. Please update your Configuration.h file." + #endif #endif #endif @@ -738,7 +771,7 @@ #endif /** - * Set flags for enabled probes + * Set a flag for any type of bed probe, including the paper-test */ #if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE) #define HAS_BED_PROBE 1 @@ -878,9 +911,9 @@ #define HAS_PROBE_XY_OFFSET 1 #endif #if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && !BOTH(DELTA, SENSORLESS_PROBING) - #define HAS_CUSTOM_PROBE_PIN 1 + #define USES_Z_MIN_PROBE_PIN 1 #endif - #if Z_HOME_TO_MIN && (!HAS_CUSTOM_PROBE_PIN || ENABLED(USE_PROBE_FOR_Z_HOMING)) + #if Z_HOME_TO_MIN && TERN1(USES_Z_MIN_PROBE_PIN, ENABLED(USE_PROBE_FOR_Z_HOMING)) #define HOMING_Z_WITH_PROBE 1 #endif #ifndef Z_PROBE_LOW_POINT @@ -1013,6 +1046,10 @@ #endif #endif +#if DISABLED(DELTA) + #undef DELTA_HOME_TO_SAFE_ZONE +#endif + // This flag indicates some kind of jerk storage is needed #if EITHER(CLASSIC_JERK, IS_KINEMATIC) #define HAS_CLASSIC_JERK 1 @@ -1023,7 +1060,7 @@ #endif // E jerk exists with JD disabled (of course) but also when Linear Advance is disabled on Delta/SCARA -#if ENABLED(CLASSIC_JERK) || (IS_KINEMATIC && DISABLED(LIN_ADVANCE)) +#if HAS_EXTRUDERS && (ENABLED(CLASSIC_JERK) || (IS_KINEMATIC && DISABLED(LIN_ADVANCE))) #define HAS_CLASSIC_E_JERK 1 #endif @@ -1053,7 +1090,11 @@ #if ENABLED(DWIN_CREALITY_LCD) #define SERIAL_CATCHALL 0 #ifndef LCD_SERIAL_PORT - #define LCD_SERIAL_PORT 3 // Creality 4.x board + #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO) + #define LCD_SERIAL_PORT 1 + #else + #define LCD_SERIAL_PORT 3 // Creality 4.x board + #endif #endif #endif @@ -1166,29 +1207,38 @@ * - TFT_COLOR * - GRAPHICAL_TFT_UPSCALE */ -#if ENABLED(MKS_TS35_V2_0) // Most common: ST7796 +#if ENABLED(MKS_TS35_V2_0) // ST7796 + #define TFT_DEFAULT_DRIVER ST7796 #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY) #define TFT_RES_480x320 #define TFT_INTERFACE_SPI -#elif ENABLED(MKS_ROBIN_TFT24) // Most common: ST7789 +#elif ENABLED(ANET_ET5_TFT35) // ST7796 + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY) + #define TFT_RES_480x320 + #define TFT_INTERFACE_FSMC +#elif ENABLED(ANET_ET4_TFT28) // ST7789 #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y) #define TFT_RES_320x240 #define TFT_INTERFACE_FSMC -#elif ENABLED(MKS_ROBIN_TFT28) // Most common: ST7789 +#elif ENABLED(MKS_ROBIN_TFT24) // ST7789 #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y) #define TFT_RES_320x240 #define TFT_INTERFACE_FSMC -#elif ENABLED(MKS_ROBIN_TFT32) // Most common: ST7789 +#elif ENABLED(MKS_ROBIN_TFT28) // ST7789 #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y) #define TFT_RES_320x240 #define TFT_INTERFACE_FSMC -#elif ENABLED(MKS_ROBIN_TFT35) // Most common: ILI9488 +#elif ENABLED(MKS_ROBIN_TFT32) // ST7789 + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y) + #define TFT_RES_320x240 + #define TFT_INTERFACE_FSMC +#elif ENABLED(MKS_ROBIN_TFT35) // ILI9488 #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) #define TFT_RES_480x320 #define TFT_INTERFACE_FSMC #elif ENABLED(MKS_ROBIN_TFT43) - #define TFT_DEFAULT_ORIENTATION 0 #define TFT_DRIVER SSD1963 + #define TFT_DEFAULT_ORIENTATION 0 #define TFT_RES_480x272 #define TFT_INTERFACE_FSMC #elif ENABLED(MKS_ROBIN_TFT_V1_1R) // ILI9328 or R61505 @@ -1196,22 +1246,14 @@ #define TFT_RES_320x240 #define TFT_INTERFACE_FSMC #elif EITHER(TFT_TRONXY_X5SA, ANYCUBIC_TFT35) // ILI9488 - #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) #define TFT_DRIVER ILI9488 + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) #define TFT_RES_480x320 #define TFT_INTERFACE_FSMC #elif ENABLED(LONGER_LK_TFT28) #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) #define TFT_RES_320x240 #define TFT_INTERFACE_FSMC -#elif ENABLED(ANET_ET4_TFT28) // ST7789 - #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y) - #define TFT_RES_320x240 - #define TFT_INTERFACE_FSMC -#elif ENABLED(ANET_ET5_TFT35) // ST7796 - #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY) - #define TFT_RES_480x320 - #define TFT_INTERFACE_FSMC #elif ENABLED(BIQU_BX_TFT70) // RGB #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY) #define TFT_RES_1024x600 diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index f88d28e1a1..c259750c6f 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -112,17 +112,419 @@ #undef STEALTHCHOP_E #endif -#if TEMP_SENSOR_BED == 0 +/** + * Temperature Sensors; define what sensor(s) we have. + */ + +// Temperature sensor IDs +#define HID_REDUNDANT -6 +#define HID_COOLER -5 +#define HID_PROBE -4 +#define HID_BOARD -3 +#define HID_CHAMBER -2 +#define HID_BED -1 +#define HID_E0 0 +#define HID_E1 1 +#define HID_E2 2 +#define HID_E3 3 +#define HID_E4 4 +#define HID_E5 5 +#define HID_E6 6 +#define HID_E7 7 + +#define ANY_TEMP_SENSOR_IS(n) (n == TEMP_SENSOR_0 || n == TEMP_SENSOR_1 || n == TEMP_SENSOR_2 || n == TEMP_SENSOR_3 \ + || n == TEMP_SENSOR_4 || n == TEMP_SENSOR_5 || n == TEMP_SENSOR_6 || n == TEMP_SENSOR_7 \ + || n == TEMP_SENSOR_BED \ + || n == TEMP_SENSOR_PROBE \ + || n == TEMP_SENSOR_CHAMBER \ + || n == TEMP_SENSOR_COOLER \ + || n == TEMP_SENSOR_REDUNDANT ) +#if ANY_TEMP_SENSOR_IS(1000) + #define HAS_USER_THERMISTORS 1 +#endif +#undef ANY_TEMP_SENSOR_IS + +#if TEMP_SENSOR_REDUNDANT + #define _HEATER_ID(M) HID_##M + #define HEATER_ID(M) _HEATER_ID(M) + #define REDUNDANT_TEMP_MATCH(M,N) (HEATER_ID(TEMP_SENSOR_REDUNDANT_##M) == _HEATER_ID(N)) +#else + #define REDUNDANT_TEMP_MATCH(...) 0 +#endif + +#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2 + #define TEMP_SENSOR_0_IS_MAX_TC 1 + #if TEMP_SENSOR_0 == -5 + #define TEMP_SENSOR_0_IS_MAX31865 1 + #define TEMP_SENSOR_0_MAX_TC_TMIN 0 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1024 + #ifndef MAX31865_SENSOR_WIRES_0 + #define MAX31865_SENSOR_WIRES_0 2 + #endif + #elif TEMP_SENSOR_0 == -3 + #define TEMP_SENSOR_0_IS_MAX31855 1 + #define TEMP_SENSOR_0_MAX_TC_TMIN -270 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1800 + #elif TEMP_SENSOR_0 == -2 + #define TEMP_SENSOR_0_IS_MAX6675 1 + #define TEMP_SENSOR_0_MAX_TC_TMIN 0 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1024 + #endif +#elif TEMP_SENSOR_0 == -4 + #define TEMP_SENSOR_0_IS_AD8495 1 +#elif TEMP_SENSOR_0 == -1 + #define TEMP_SENSOR_0_IS_AD595 1 +#elif TEMP_SENSOR_0 > 0 + #define TEMP_SENSOR_0_IS_THERMISTOR 1 + #if TEMP_SENSOR_0 == 1000 + #define TEMP_SENSOR_0_IS_CUSTOM 1 + #elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999 + #define TEMP_SENSOR_0_IS_DUMMY 1 + #endif +#else + #undef HEATER_0_MINTEMP + #undef HEATER_0_MAXTEMP +#endif + +#if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2 + #define TEMP_SENSOR_1_IS_MAX_TC 1 + #if TEMP_SENSOR_1 == -5 + #define TEMP_SENSOR_1_IS_MAX31865 1 + #define TEMP_SENSOR_1_MAX_TC_TMIN 0 + #define TEMP_SENSOR_1_MAX_TC_TMAX 1024 + #ifndef MAX31865_SENSOR_WIRES_1 + #define MAX31865_SENSOR_WIRES_1 2 + #endif + #elif TEMP_SENSOR_1 == -3 + #define TEMP_SENSOR_1_IS_MAX31855 1 + #define TEMP_SENSOR_1_MAX_TC_TMIN -270 + #define TEMP_SENSOR_1_MAX_TC_TMAX 1800 + #elif TEMP_SENSOR_1 == -2 + #define TEMP_SENSOR_1_IS_MAX6675 1 + #define TEMP_SENSOR_1_MAX_TC_TMIN 0 + #define TEMP_SENSOR_1_MAX_TC_TMAX 1024 + #endif + + #if TEMP_SENSOR_1 != TEMP_SENSOR_0 + #if TEMP_SENSOR_1 == -5 + #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match." + #elif TEMP_SENSOR_1 == -3 + #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match." + #elif TEMP_SENSOR_1 == -2 + #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match." + #endif + #endif +#elif TEMP_SENSOR_1 == -4 + #define TEMP_SENSOR_1_IS_AD8495 1 +#elif TEMP_SENSOR_1 == -1 + #define TEMP_SENSOR_1_IS_AD595 1 +#elif TEMP_SENSOR_1 > 0 + #define TEMP_SENSOR_1_IS_THERMISTOR 1 + #if TEMP_SENSOR_1 == 1000 + #define TEMP_SENSOR_1_IS_CUSTOM 1 + #elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999 + #define TEMP_SENSOR_1_IS_DUMMY 1 + #endif +#else + #undef HEATER_1_MINTEMP + #undef HEATER_1_MAXTEMP +#endif + +#if TEMP_SENSOR_REDUNDANT == -5 || TEMP_SENSOR_REDUNDANT == -3 || TEMP_SENSOR_REDUNDANT == -2 + #define TEMP_SENSOR_REDUNDANT_IS_MAX_TC 1 + + #if TEMP_SENSOR_REDUNDANT == -5 + #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) + #error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." + #endif + + #define TEMP_SENSOR_REDUNDANT_IS_MAX31865 1 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN 0 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024 + #elif TEMP_SENSOR_REDUNDANT == -3 + #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." + #endif + + #define TEMP_SENSOR_REDUNDANT_IS_MAX31855 1 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN -270 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1800 + #elif TEMP_SENSOR_REDUNDANT == -2 + #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." + #endif + + #define TEMP_SENSOR_REDUNDANT_IS_MAX6675 1 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN 0 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024 + #endif + + // mimic setting up the source TEMP_SENSOR + #if REDUNDANT_TEMP_MATCH(SOURCE, E0) + #define TEMP_SENSOR_0_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + #define TEMP_SENSOR_0_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX + #ifndef MAX31865_SENSOR_WIRES_0 + #define MAX31865_SENSOR_WIRES_0 2 + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E1) + #define TEMP_SENSOR_1_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + #define TEMP_SENSOR_1_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX + #ifndef MAX31865_SENSOR_WIRES_1 + #define MAX31865_SENSOR_WIRES_1 2 + #endif + #endif + + #if (TEMP_SENSOR_0_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_1_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) + #if TEMP_SENSOR_REDUNDANT == -5 + #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match." + #elif TEMP_SENSOR_REDUNDANT == -3 + #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match." + #elif TEMP_SENSOR_REDUNDANT == -2 + #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match." + #endif + #endif +#elif TEMP_SENSOR_REDUNDANT == -4 + #define TEMP_SENSOR_REDUNDANT_IS_AD8495 1 +#elif TEMP_SENSOR_REDUNDANT == -1 + #define TEMP_SENSOR_REDUNDANT_IS_AD595 1 +#elif TEMP_SENSOR_REDUNDANT > 0 + #define TEMP_SENSOR_REDUNDANT_IS_THERMISTOR 1 + #if TEMP_SENSOR_REDUNDANT == 1000 + #define TEMP_SENSOR_REDUNDANT_IS_CUSTOM 1 + #elif TEMP_SENSOR_REDUNDANT == 998 || TEMP_SENSOR_REDUNDANT == 999 + #error "Dummy sensors are not supported for TEMP_SENSOR_REDUNDANT." + #endif +#endif + +#if TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC || TEMP_SENSOR_REDUNDANT_IS_MAX_TC + #define HAS_MAX_TC 1 +#endif +#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675 + #define HAS_MAX6675 1 +#endif +#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855 + #define HAS_MAX31855 1 +#endif +#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865 + #define HAS_MAX31865 1 +#endif + +#if TEMP_SENSOR_2 == -4 + #define TEMP_SENSOR_2_IS_AD8495 1 +#elif TEMP_SENSOR_2 == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2." +#elif TEMP_SENSOR_2 == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2." +#elif TEMP_SENSOR_2 == -1 + #define TEMP_SENSOR_2_IS_AD595 1 +#elif TEMP_SENSOR_2 > 0 + #define TEMP_SENSOR_2_IS_THERMISTOR 1 + #if TEMP_SENSOR_2 == 1000 + #define TEMP_SENSOR_2_IS_CUSTOM 1 + #elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999 + #define TEMP_SENSOR_2_IS_DUMMY 1 + #endif +#else + #undef HEATER_2_MINTEMP + #undef HEATER_2_MAXTEMP +#endif + +#if TEMP_SENSOR_3 == -4 + #define TEMP_SENSOR_3_IS_AD8495 1 +#elif TEMP_SENSOR_3 == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3." +#elif TEMP_SENSOR_3 == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3." +#elif TEMP_SENSOR_3 == -1 + #define TEMP_SENSOR_3_IS_AD595 1 +#elif TEMP_SENSOR_3 > 0 + #define TEMP_SENSOR_3_IS_THERMISTOR 1 + #if TEMP_SENSOR_3 == 1000 + #define TEMP_SENSOR_3_IS_CUSTOM 1 + #elif TEMP_SENSOR_3 == 998 || TEMP_SENSOR_3 == 999 + #define TEMP_SENSOR_3_IS_DUMMY 1 + #endif +#else + #undef HEATER_3_MINTEMP + #undef HEATER_3_MAXTEMP +#endif + +#if TEMP_SENSOR_4 == -4 + #define TEMP_SENSOR_4_IS_AD8495 1 +#elif TEMP_SENSOR_4 == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4." +#elif TEMP_SENSOR_4 == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4." +#elif TEMP_SENSOR_4 == -1 + #define TEMP_SENSOR_4_IS_AD595 1 +#elif TEMP_SENSOR_4 > 0 + #define TEMP_SENSOR_4_IS_THERMISTOR 1 + #if TEMP_SENSOR_4 == 1000 + #define TEMP_SENSOR_4_IS_CUSTOM 1 + #elif TEMP_SENSOR_4 == 998 || TEMP_SENSOR_4 == 999 + #define TEMP_SENSOR_4_IS_DUMMY 1 + #endif +#else + #undef HEATER_4_MINTEMP + #undef HEATER_4_MAXTEMP +#endif + +#if TEMP_SENSOR_5 == -4 + #define TEMP_SENSOR_5_IS_AD8495 1 +#elif TEMP_SENSOR_5 == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5." +#elif TEMP_SENSOR_5 == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_5." +#elif TEMP_SENSOR_5 == -1 + #define TEMP_SENSOR_5_IS_AD595 1 +#elif TEMP_SENSOR_5 > 0 + #define TEMP_SENSOR_5_IS_THERMISTOR 1 + #if TEMP_SENSOR_5 == 1000 + #define TEMP_SENSOR_5_IS_CUSTOM 1 + #elif TEMP_SENSOR_5 == 998 || TEMP_SENSOR_5 == 999 + #define TEMP_SENSOR_5_IS_DUMMY 1 + #endif +#else + #undef HEATER_5_MINTEMP + #undef HEATER_5_MAXTEMP +#endif + +#if TEMP_SENSOR_6 == -4 + #define TEMP_SENSOR_6_IS_AD8495 1 +#elif TEMP_SENSOR_6 == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_6." +#elif TEMP_SENSOR_6 == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_6." +#elif TEMP_SENSOR_6 == -1 + #define TEMP_SENSOR_6_IS_AD595 1 +#elif TEMP_SENSOR_6 > 0 + #define TEMP_SENSOR_6_IS_THERMISTOR 1 + #if TEMP_SENSOR_6 == 1000 + #define TEMP_SENSOR_6_IS_CUSTOM 1 + #elif TEMP_SENSOR_6 == 998 || TEMP_SENSOR_6 == 999 + #define TEMP_SENSOR_6_IS_DUMMY 1 + #endif +#else + #undef HEATER_6_MINTEMP + #undef HEATER_6_MAXTEMP +#endif + +#if TEMP_SENSOR_7 == -4 + #define TEMP_SENSOR_7_IS_AD8495 1 +#elif TEMP_SENSOR_7 == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_7." +#elif TEMP_SENSOR_7 == -2 + #error "MAX7775 Thermocouples (-2) not supported for TEMP_SENSOR_7." +#elif TEMP_SENSOR_7 == -1 + #define TEMP_SENSOR_7_IS_AD595 1 +#elif TEMP_SENSOR_7 > 0 + #define TEMP_SENSOR_7_IS_THERMISTOR 1 + #if TEMP_SENSOR_7 == 1000 + #define TEMP_SENSOR_7_IS_CUSTOM 1 + #elif TEMP_SENSOR_7 == 998 || TEMP_SENSOR_7 == 999 + #define TEMP_SENSOR_7_IS_DUMMY 1 + #endif +#else + #undef HEATER_7_MINTEMP + #undef HEATER_7_MAXTEMP +#endif + +#if TEMP_SENSOR_BED == -4 + #define TEMP_SENSOR_BED_IS_AD8495 1 +#elif TEMP_SENSOR_BED == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED." +#elif TEMP_SENSOR_BED == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED." +#elif TEMP_SENSOR_BED == -1 + #define TEMP_SENSOR_BED_IS_AD595 1 +#elif TEMP_SENSOR_BED > 0 + #define TEMP_SENSOR_BED_IS_THERMISTOR 1 + #if TEMP_SENSOR_BED == 1000 + #define TEMP_SENSOR_BED_IS_CUSTOM 1 + #elif TEMP_SENSOR_BED == 998 || TEMP_SENSOR_BED == 999 + #define TEMP_SENSOR_BED_IS_DUMMY 1 + #endif +#else #undef THERMAL_PROTECTION_BED #undef THERMAL_PROTECTION_BED_PERIOD + #undef BED_MINTEMP + #undef BED_MAXTEMP #endif -#if TEMP_SENSOR_CHAMBER == 0 +#if TEMP_SENSOR_CHAMBER == -4 + #define TEMP_SENSOR_CHAMBER_IS_AD8495 1 +#elif TEMP_SENSOR_CHAMBER == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER." +#elif TEMP_SENSOR_CHAMBER == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER." +#elif TEMP_SENSOR_CHAMBER == -1 + #define TEMP_SENSOR_CHAMBER_IS_AD595 1 +#elif TEMP_SENSOR_CHAMBER > 0 + #define TEMP_SENSOR_CHAMBER_IS_THERMISTOR 1 + #if TEMP_SENSOR_CHAMBER == 1000 + #define TEMP_SENSOR_CHAMBER_IS_CUSTOM 1 + #elif TEMP_SENSOR_CHAMBER == 998 || TEMP_SENSOR_CHAMBER == 999 + #define TEMP_SENSOR_CHAMBER_IS_DUMMY 1 + #endif +#else #undef THERMAL_PROTECTION_CHAMBER + #undef CHAMBER_MINTEMP + #undef CHAMBER_MAXTEMP #endif -#if TEMP_SENSOR_COOLER == 0 +#if TEMP_SENSOR_COOLER == -4 + #define TEMP_SENSOR_COOLER_IS_AD8495 1 +#elif TEMP_SENSOR_COOLER == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_COOLER." +#elif TEMP_SENSOR_COOLER == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_COOLER." +#elif TEMP_SENSOR_COOLER == -1 + #define TEMP_SENSOR_COOLER_IS_AD595 1 +#elif TEMP_SENSOR_COOLER > 0 + #define TEMP_SENSOR_COOLER_IS_THERMISTOR 1 + #if TEMP_SENSOR_COOLER == 1000 + #define TEMP_SENSOR_COOLER_IS_CUSTOM 1 + #elif TEMP_SENSOR_COOLER == 998 || TEMP_SENSOR_COOLER == 999 + #define TEMP_SENSOR_COOLER_IS_DUMMY 1 + #endif +#else #undef THERMAL_PROTECTION_COOLER + #undef COOLER_MINTEMP + #undef COOLER_MAXTEMP +#endif + +#if TEMP_SENSOR_PROBE == -4 + #define TEMP_SENSOR_PROBE_IS_AD8495 1 +#elif TEMP_SENSOR_PROBE == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_PROBE." +#elif TEMP_SENSOR_PROBE == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_PROBE." +#elif TEMP_SENSOR_PROBE == -1 + #define TEMP_SENSOR_PROBE_IS_AD595 1 +#elif TEMP_SENSOR_PROBE > 0 + #define TEMP_SENSOR_PROBE_IS_THERMISTOR 1 + #if TEMP_SENSOR_PROBE == 1000 + #define TEMP_SENSOR_PROBE_IS_CUSTOM 1 + #elif TEMP_SENSOR_PROBE == 998 || TEMP_SENSOR_PROBE == 999 + #define TEMP_SENSOR_PROBE_IS_DUMMY 1 + #endif +#endif + +#if TEMP_SENSOR_BOARD == -4 + #define TEMP_SENSOR_BOARD_IS_AD8495 1 +#elif TEMP_SENSOR_BOARD == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BOARD." +#elif TEMP_SENSOR_BOARD == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BOARD." +#elif TEMP_SENSOR_BOARD == -1 + #define TEMP_SENSOR_BOARD_IS_AD595 1 +#elif TEMP_SENSOR_BOARD > 0 + #define TEMP_SENSOR_BOARD_IS_THERMISTOR 1 + #if TEMP_SENSOR_BOARD == 1000 + #define TEMP_SENSOR_BOARD_IS_CUSTOM 1 + #elif TEMP_SENSOR_BOARD == 998 || TEMP_SENSOR_BOARD == 999 + #define TEMP_SENSOR_BOARD_IS_DUMMY 1 + #endif #endif #if ENABLED(MIXING_EXTRUDER) && (ENABLED(RETRACT_SYNC_MIXING) || BOTH(FILAMENT_LOAD_UNLOAD_GCODES, FILAMENT_UNLOAD_ALL_EXTRUDERS)) @@ -567,7 +969,7 @@ #endif #if BOTH(HAS_TFT_LVGL_UI, CUSTOM_MENU_MAIN) - #define _HAS_1(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N)) + #define _HAS_1(N) (defined(MAIN_MENU_ITEM_##N##_DESC) && defined(MAIN_MENU_ITEM_##N##_GCODE)) #define HAS_USER_ITEM(V...) DO(HAS,||,V) #else #define HAS_USER_ITEM(N) 0 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 9f3150199b..0241b1f0eb 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -369,6 +369,10 @@ #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) #define _LCD_CONTRAST_MIN 120 #define _LCD_CONTRAST_INIT 195 +#elif ENABLED(MKS_MINI_12864_V3) + #define _LCD_CONTRAST_MIN 255 + #define _LCD_CONTRAST_INIT 255 + #define _LCD_CONTRAST_MAX 255 #elif ENABLED(FYSETC_MINI_12864) #define _LCD_CONTRAST_INIT 220 #elif ENABLED(ULTI_CONTROLLER) @@ -509,392 +513,260 @@ #endif /** - * Temp Sensor defines + * Temp Sensor defines; set up pins as needed. */ -#define ANY_TEMP_SENSOR_IS(n) (TEMP_SENSOR_0 == (n) || TEMP_SENSOR_1 == (n) || TEMP_SENSOR_2 == (n) || TEMP_SENSOR_3 == (n) || TEMP_SENSOR_4 == (n) || TEMP_SENSOR_5 == (n) || TEMP_SENSOR_6 == (n) || TEMP_SENSOR_7 == (n) || TEMP_SENSOR_BED == (n) || TEMP_SENSOR_PROBE == (n) || TEMP_SENSOR_CHAMBER == (n) || TEMP_SENSOR_COOLER == (n)) - -#if ANY_TEMP_SENSOR_IS(1000) - #define HAS_USER_THERMISTORS 1 -#endif - -#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2 - #define TEMP_SENSOR_0_IS_MAX_TC 1 - #define HAS_MAX_TC 1 - #if TEMP_SENSOR_0 == -3 - #define TEMP_SENSOR_0_MAX_TC_TMIN -270 - #define TEMP_SENSOR_0_MAX_TC_TMAX 1800 - #else - #define TEMP_SENSOR_0_MAX_TC_TMIN 0 - #define TEMP_SENSOR_0_MAX_TC_TMAX 1024 +// Usurp a sensor to do redundant readings +#if TEMP_SENSOR_REDUNDANT + #ifndef TEMP_SENSOR_REDUNDANT_SOURCE + #define TEMP_SENSOR_REDUNDANT_SOURCE E1 #endif - #if TEMP_SENSOR_0 == -5 - #define TEMP_SENSOR_0_IS_MAX31865 1 - #elif TEMP_SENSOR_0 == -3 - #define TEMP_SENSOR_0_IS_MAX31855 1 - #elif TEMP_SENSOR_0 == -2 - #define TEMP_SENSOR_0_IS_MAX6675 1 + #ifndef TEMP_SENSOR_REDUNDANT_TARGET + #define TEMP_SENSOR_REDUNDANT_TARGET E0 #endif -#elif TEMP_SENSOR_0 == -4 - #define TEMP_SENSOR_0_IS_AD8495 1 -#elif TEMP_SENSOR_0 == -1 - #define TEMP_SENSOR_0_IS_AD595 1 -#elif TEMP_SENSOR_0 > 0 - #define TEMP_SENSOR_0_THERMISTOR_ID TEMP_SENSOR_0 - #define TEMP_SENSOR_0_IS_THERMISTOR 1 - #if TEMP_SENSOR_0 == 1000 - #define TEMP_SENSOR_0_IS_CUSTOM 1 - #elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999 - #define TEMP_SENSOR_0_IS_DUMMY 1 - #endif -#else - #undef HEATER_0_MINTEMP - #undef HEATER_0_MAXTEMP -#endif - -#if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2 - #define TEMP_SENSOR_1_IS_MAX_TC 1 - #define HAS_MAX_TC 1 - #if TEMP_SENSOR_1 == -3 - #define TEMP_SENSOR_1_MAX_TC_TMIN -270 - #define TEMP_SENSOR_1_MAX_TC_TMAX 1800 - #else - #define TEMP_SENSOR_1_MAX_TC_TMIN 0 - #define TEMP_SENSOR_1_MAX_TC_TMAX 1024 - #endif - #if TEMP_SENSOR_1 == -5 - #define TEMP_SENSOR_1_IS_MAX31865 1 - #elif TEMP_SENSOR_1 == -3 - #define TEMP_SENSOR_1_IS_MAX31855 1 - #elif TEMP_SENSOR_1 == -2 - #define TEMP_SENSOR_1_IS_MAX6675 1 - #endif - #if TEMP_SENSOR_1 != TEMP_SENSOR_0 - #if TEMP_SENSOR_1 == -5 - #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match." - #elif TEMP_SENSOR_1 == -3 - #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match." - #elif TEMP_SENSOR_1 == -2 - #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match." + #if !PIN_EXISTS(TEMP_REDUNDANT) + #ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF + #define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 + #endif + #if REDUNDANT_TEMP_MATCH(SOURCE, COOLER) + #if !PIN_EXISTS(TEMP_COOLER) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_COOLER_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, PROBE) + #if !PIN_EXISTS(TEMP_PROBE) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to PROBE requires TEMP_PROBE_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_PROBE_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, CHAMBER) + #if !PIN_EXISTS(TEMP_CHAMBER) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to CHAMBER requires TEMP_CHAMBER_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_CHAMBER_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, BED) + #if !PIN_EXISTS(TEMP_BED) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to BED requires TEMP_BED_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_BED_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E0) + #if !PIN_EXISTS(TEMP_0) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E0 requires TEMP_0_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_0_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E1) + #if !PIN_EXISTS(TEMP_1) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E1 requires TEMP_1_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_1_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E2) + #if !PIN_EXISTS(TEMP_2) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E2 requires TEMP_2_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_2_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E3) + #if !PIN_EXISTS(TEMP_3) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E3 requires TEMP_3_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_3_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E4) + #if !PIN_EXISTS(TEMP_4) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E4 requires TEMP_4_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_4_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E5) + #if !PIN_EXISTS(TEMP_5) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E5 requires TEMP_5_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_5_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E6) + #if !PIN_EXISTS(TEMP_6) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E6 requires TEMP_6_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_6_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E7) + #if !PIN_EXISTS(TEMP_7) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to E7 requires TEMP_7_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_7_PIN + #endif #endif #endif -#elif TEMP_SENSOR_1 == -4 - #define TEMP_SENSOR_1_IS_AD8495 1 -#elif TEMP_SENSOR_1 == -1 - #define TEMP_SENSOR_1_IS_AD595 1 -#elif TEMP_SENSOR_1 > 0 - #define TEMP_SENSOR_1_THERMISTOR_ID TEMP_SENSOR_1 - #define TEMP_SENSOR_1_IS_THERMISTOR 1 - #if TEMP_SENSOR_1 == 1000 - #define TEMP_SENSOR_1_IS_CUSTOM 1 - #elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999 - #define TEMP_SENSOR_1_IS_DUMMY 1 +#endif + +/** + * Compatibility layer for MAX (SPI) temp boards + */ +#if HAS_MAX_TC + + // Translate old _SS, _CS, _SCK, _DO, _DI, _MISO, and _MOSI PIN defines. + #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + + #if !PIN_EXISTS(TEMP_0_CS) // SS, CS + #if PIN_EXISTS(MAX6675_SS) + #define TEMP_0_CS_PIN MAX6675_SS_PIN + #elif PIN_EXISTS(MAX6675_CS) + #define TEMP_0_CS_PIN MAX6675_CS_PIN + #elif PIN_EXISTS(MAX31855_SS) + #define TEMP_0_CS_PIN MAX31855_SS_PIN + #elif PIN_EXISTS(MAX31855_CS) + #define TEMP_0_CS_PIN MAX31855_CS_PIN + #elif PIN_EXISTS(MAX31865_SS) + #define TEMP_0_CS_PIN MAX31865_SS_PIN + #elif PIN_EXISTS(MAX31865_CS) + #define TEMP_0_CS_PIN MAX31865_CS_PIN + #endif + #endif + + #if TEMP_SENSOR_0_IS_MAX6675 + #if !PIN_EXISTS(TEMP_0_MISO) // DO + #if PIN_EXISTS(MAX6675_MISO) + #define TEMP_0_MISO_PIN MAX6675_MISO_PIN + #elif PIN_EXISTS(MAX6675_DO) + #define TEMP_0_MISO_PIN MAX6675_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_0_SCK) && PIN_EXISTS(MAX6675_SCK) + #define TEMP_0_SCK_PIN MAX6675_SCK_PIN + #endif + + #elif TEMP_SENSOR_0_IS_MAX31855 + #if !PIN_EXISTS(TEMP_0_MISO) // DO + #if PIN_EXISTS(MAX31855_MISO) + #define TEMP_0_MISO_PIN MAX31855_MISO_PIN + #elif PIN_EXISTS(MAX31855_DO) + #define TEMP_0_MISO_PIN MAX31855_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_0_SCK) && PIN_EXISTS(MAX31855_SCK) + #define TEMP_0_SCK_PIN MAX31855_SCK_PIN + #endif + + #elif TEMP_SENSOR_1_IS_MAX31865 + #if !PIN_EXISTS(TEMP_1_MISO) // DO + #if PIN_EXISTS(MAX31865_MISO) + #define TEMP_1_MISO_PIN MAX31865_MISO_PIN + #elif PIN_EXISTS(MAX31865_DO) + #define TEMP_1_MISO_PIN MAX31865_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX31865_SCK) + #define TEMP_1_SCK_PIN MAX31865_SCK_PIN + #endif + #if !PIN_EXISTS(TEMP_1_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only + #define TEMP_1_MOSI_PIN MAX31865_MOSI_PIN + #endif + #endif + + // Software SPI - enable if MISO/SCK are defined. + #if PIN_EXISTS(TEMP_0_MISO) && PIN_EXISTS(TEMP_0_SCK) && DISABLED(TEMP_SENSOR_0_FORCE_HW_SPI) + #if TEMP_SENSOR_0_IS_MAX31865 && !PIN_EXISTS(TEMP_0_MOSI) + #error "TEMP_SENSOR_0 MAX31865 requires TEMP_0_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_0_FORCE_HW_SPI." + #else + #define TEMP_SENSOR_0_HAS_SPI_PINS 1 + #endif + #endif + + #endif // TEMP_SENSOR_0_IS_MAX_TC + + #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + + #if !PIN_EXISTS(TEMP_1_CS) // SS2, CS2 + #if PIN_EXISTS(MAX6675_SS2) + #define TEMP_1_CS_PIN MAX6675_SS2_PIN + #elif PIN_EXISTS(MAX6675_CS) + #define TEMP_1_CS_PIN MAX6675_CS2_PIN + #elif PIN_EXISTS(MAX31855_SS2) + #define TEMP_1_CS_PIN MAX31855_SS2_PIN + #elif PIN_EXISTS(MAX31855_CS2) + #define TEMP_1_CS_PIN MAX31855_CS2_PIN + #elif PIN_EXISTS(MAX31865_SS2) + #define TEMP_1_CS_PIN MAX31865_SS2_PIN + #elif PIN_EXISTS(MAX31865_CS2) + #define TEMP_1_CS_PIN MAX31865_CS2_PIN + #endif + #endif + + #if TEMP_SENSOR_1_IS_MAX6675 + #if !PIN_EXISTS(TEMP_1_MISO) // DO + #if PIN_EXISTS(MAX6675_MISO) + #define TEMP_1_MISO_PIN MAX6675_MISO_PIN + #elif PIN_EXISTS(MAX6675_DO) + #define TEMP_1_MISO_PIN MAX6675_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX6675_SCK) + #define TEMP_1_SCK_PIN MAX6675_SCK_PIN + #endif + + #elif TEMP_SENSOR_1_IS_MAX31855 + #if !PIN_EXISTS(TEMP_1_MISO) // DO + #if PIN_EXISTS(MAX31855_MISO) + #define TEMP_1_MISO_PIN MAX31855_MISO_PIN + #elif PIN_EXISTS(MAX31855_DO) + #define TEMP_1_MISO_PIN MAX31855_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX31855_SCK) + #define TEMP_1_SCK_PIN MAX31855_SCK_PIN + #endif + + #elif TEMP_SENSOR_1_IS_MAX31865 + #if !PIN_EXISTS(TEMP_1_MISO) // DO + #if PIN_EXISTS(MAX31865_MISO) + #define TEMP_1_MISO_PIN MAX31865_MISO_PIN + #elif PIN_EXISTS(MAX31865_DO) + #define TEMP_1_MISO_PIN MAX31865_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX31865_SCK) + #define TEMP_1_SCK_PIN MAX31865_SCK_PIN + #endif + #if !PIN_EXISTS(TEMP_1_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only + #define TEMP_1_MOSI_PIN MAX31865_MOSI_PIN + #endif + #endif + + // Software SPI - enable if MISO/SCK are defined. + #if PIN_EXISTS(TEMP_1_MISO) && PIN_EXISTS(TEMP_1_SCK) && DISABLED(TEMP_SENSOR_1_FORCE_HW_SPI) + #if TEMP_SENSOR_1_IS_MAX31865 && !PIN_EXISTS(TEMP_1_MOSI) + #error "TEMP_SENSOR_1 MAX31865 requires TEMP_1_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_1_FORCE_HW_SPI." + #else + #define TEMP_SENSOR_1_HAS_SPI_PINS 1 + #endif + #endif + + #endif // TEMP_SENSOR_1_IS_MAX_TC + + // + // User-defined thermocouple libraries + // + // Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags + // to select a USER library for MAX6675, MAX31855, MAX31865 + // + #if BOTH(HAS_MAX6675, LIB_MAX6675) + #define LIB_USR_MAX6675 1 #endif -#else - #undef HEATER_1_MINTEMP - #undef HEATER_1_MAXTEMP -#endif - -#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 - #define HAS_MAX31855 1 -#endif -#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 - #define HAS_MAX31865 1 -#endif -#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 - #define HAS_MAX6675 1 -#endif - -// -// Compatibility layer for MAX (SPI) temp boards -// -#if PIN_EXISTS(MAX6675_SS) - #if TEMP_SENSOR_0_IS_MAX31855 - #define MAX31855_CS_PIN MAX6675_SS_PIN - #elif TEMP_SENSOR_0_IS_MAX31865 - #define MAX31865_CS_PIN MAX6675_SS_PIN - #elif TEMP_SENSOR_0_IS_MAX6675 - #define MAX6675_CS_PIN MAX6675_SS_PIN + #if BOTH(HAS_MAX31855, LIB_MAX31855) + #define LIB_USR_MAX31855 1 #endif -#endif - -#if PIN_EXISTS(MAX6675_SS2) - #if TEMP_SENSOR_1_IS_MAX31855 - #define MAX31855_CS2_PIN MAX6675_SS2_PIN - #elif TEMP_SENSOR_1_IS_MAX31865 - #define MAX31865_CS2_PIN MAX6675_SS2_PIN - #elif TEMP_SENSOR_1_IS_MAX6675 - #define MAX6675_CS2_PIN MAX6675_SS2_PIN - #endif -#endif - -#if PIN_EXISTS(MAX6675_DO) - #if HAS_MAX31855 - #define MAX31855_MISO_PIN MAX6675_DO_PIN - #elif HAS_MAX31865 - #define MAX31865_MISO_PIN MAX6675_DO_PIN - #elif HAS_MAX6675 - #define MAX6675_MISO_PIN MAX6675_DO_PIN - #endif -#endif - -#if PIN_EXISTS(MAX6675_SCK) - #if HAS_MAX31855 - #define MAX31855_SCK_PIN MAX6675_SCK_PIN - #elif HAS_MAX31865 - #define MAX31865_SCK_PIN MAX6675_SCK_PIN - #endif -#endif - -// Compatibility Layer for use when HAL manipulates PINS for MAX31855 and MAX6675 -#if PIN_EXISTS(MAX31855_CS) && !PIN_EXISTS(MAX6675_SS) - #define MAX6675_SS_PIN MAX31855_CS_PIN -#endif -#if PIN_EXISTS(MAX31855_CS2) && !PIN_EXISTS(MAX6675_SS2) - #define MAX6675_SS2_PIN MAX31855_CS2_PIN -#endif -#if PIN_EXISTS(MAX6675_CS) && !PIN_EXISTS(MAX6675_SS) - #define MAX6675_SS_PIN MAX6675_CS_PIN -#endif -#if PIN_EXISTS(MAX6675_CS2) && !PIN_EXISTS(MAX6675_SS2) - #define MAX6675_SS2_PIN MAX6675_CS2_PIN -#endif -#if PIN_EXISTS(MAX31855_MISO) && !PIN_EXISTS(MAX6675_DO) - #define MAX6675_DO_PIN MAX31855_MISO_PIN -#endif -#if PIN_EXISTS(MAX6675_MISO) && !PIN_EXISTS(MAX6675_DO) - #define MAX6675_DO_PIN MAX6675_MISO_PIN -#endif -#if PIN_EXISTS(MAX31855_SCK) && !PIN_EXISTS(MAX6675_SCK) - #define MAX6675_SCK_PIN MAX31855_SCK_PIN -#endif - -// -// User-defined thermocouple libraries -// -// Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags -// to select a USER library for MAX6675, MAX31855, MAX31865 -// -#if BOTH(HAS_MAX6675, LIB_MAX6675) - #define LIB_USR_MAX6675 1 -#endif -#if BOTH(HAS_MAX31855, LIB_MAX31855) - #define LIB_USR_MAX31855 1 -#endif -#if HAS_MAX31865 - #if ENABLED(LIB_MAX31865) + #if BOTH(HAS_MAX31865, LIB_MAX31865) #define LIB_USR_MAX31865 1 - #else - #define LIB_ADAFRUIT_MAX31865 1 + #elif HAS_MAX31865 + #define LIB_INTERNAL_MAX31865 1 #endif -#endif -#if TEMP_SENSOR_2 == -4 - #define TEMP_SENSOR_2_IS_AD8495 1 -#elif TEMP_SENSOR_2 == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2." -#elif TEMP_SENSOR_2 == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2." -#elif TEMP_SENSOR_2 == -1 - #define TEMP_SENSOR_2_IS_AD595 1 -#elif TEMP_SENSOR_2 > 0 - #define TEMP_SENSOR_2_THERMISTOR_ID TEMP_SENSOR_2 - #define TEMP_SENSOR_2_IS_THERMISTOR 1 - #if TEMP_SENSOR_2 == 1000 - #define TEMP_SENSOR_2_IS_CUSTOM 1 - #elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999 - #define TEMP_SENSOR_2_IS_DUMMY 1 - #endif -#else - #undef HEATER_2_MINTEMP - #undef HEATER_2_MAXTEMP -#endif - -#if TEMP_SENSOR_3 == -4 - #define TEMP_SENSOR_3_IS_AD8495 1 -#elif TEMP_SENSOR_3 == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3." -#elif TEMP_SENSOR_3 == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3." -#elif TEMP_SENSOR_3 == -1 - #define TEMP_SENSOR_3_IS_AD595 1 -#elif TEMP_SENSOR_3 > 0 - #define TEMP_SENSOR_3_THERMISTOR_ID TEMP_SENSOR_3 - #define TEMP_SENSOR_3_IS_THERMISTOR 1 - #if TEMP_SENSOR_3 == 1000 - #define TEMP_SENSOR_3_IS_CUSTOM 1 - #elif TEMP_SENSOR_3 == 998 || TEMP_SENSOR_3 == 999 - #define TEMP_SENSOR_3_IS_DUMMY 1 - #endif -#else - #undef HEATER_3_MINTEMP - #undef HEATER_3_MAXTEMP -#endif - -#if TEMP_SENSOR_4 == -4 - #define TEMP_SENSOR_4_IS_AD8495 1 -#elif TEMP_SENSOR_4 == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4." -#elif TEMP_SENSOR_4 == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4." -#elif TEMP_SENSOR_4 == -1 - #define TEMP_SENSOR_4_IS_AD595 1 -#elif TEMP_SENSOR_4 > 0 - #define TEMP_SENSOR_4_THERMISTOR_ID TEMP_SENSOR_4 - #define TEMP_SENSOR_4_IS_THERMISTOR 1 - #if TEMP_SENSOR_4 == 1000 - #define TEMP_SENSOR_4_IS_CUSTOM 1 - #elif TEMP_SENSOR_4 == 998 || TEMP_SENSOR_4 == 999 - #define TEMP_SENSOR_4_IS_DUMMY 1 - #endif -#else - #undef HEATER_4_MINTEMP - #undef HEATER_4_MAXTEMP -#endif - -#if TEMP_SENSOR_5 == -4 - #define TEMP_SENSOR_5_IS_AD8495 1 -#elif TEMP_SENSOR_5 == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5." -#elif TEMP_SENSOR_5 == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_5." -#elif TEMP_SENSOR_5 == -1 - #define TEMP_SENSOR_5_IS_AD595 1 -#elif TEMP_SENSOR_5 > 0 - #define TEMP_SENSOR_5_THERMISTOR_ID TEMP_SENSOR_5 - #define TEMP_SENSOR_5_IS_THERMISTOR 1 - #if TEMP_SENSOR_5 == 1000 - #define TEMP_SENSOR_5_IS_CUSTOM 1 - #elif TEMP_SENSOR_5 == 998 || TEMP_SENSOR_5 == 999 - #define TEMP_SENSOR_5_IS_DUMMY 1 - #endif -#else - #undef HEATER_5_MINTEMP - #undef HEATER_5_MAXTEMP -#endif - -#if TEMP_SENSOR_6 == -4 - #define TEMP_SENSOR_6_IS_AD8495 1 -#elif TEMP_SENSOR_6 == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_6." -#elif TEMP_SENSOR_6 == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_6." -#elif TEMP_SENSOR_6 == -1 - #define TEMP_SENSOR_6_IS_AD595 1 -#elif TEMP_SENSOR_6 > 0 - #define TEMP_SENSOR_6_THERMISTOR_ID TEMP_SENSOR_6 - #define TEMP_SENSOR_6_IS_THERMISTOR 1 - #if TEMP_SENSOR_6 == 1000 - #define TEMP_SENSOR_6_IS_CUSTOM 1 - #elif TEMP_SENSOR_6 == 998 || TEMP_SENSOR_6 == 999 - #define TEMP_SENSOR_6_IS_DUMMY 1 - #endif -#else - #undef HEATER_6_MINTEMP - #undef HEATER_6_MAXTEMP -#endif - -#if TEMP_SENSOR_7 == -4 - #define TEMP_SENSOR_7_IS_AD8495 1 -#elif TEMP_SENSOR_7 == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_7." -#elif TEMP_SENSOR_7 == -2 - #error "MAX7775 Thermocouples (-2) not supported for TEMP_SENSOR_7." -#elif TEMP_SENSOR_7 == -1 - #define TEMP_SENSOR_7_IS_AD595 1 -#elif TEMP_SENSOR_7 > 0 - #define TEMP_SENSOR_7_THERMISTOR_ID TEMP_SENSOR_7 - #define TEMP_SENSOR_7_IS_THERMISTOR 1 - #if TEMP_SENSOR_7 == 1000 - #define TEMP_SENSOR_7_IS_CUSTOM 1 - #elif TEMP_SENSOR_7 == 998 || TEMP_SENSOR_7 == 999 - #define TEMP_SENSOR_7_IS_DUMMY 1 - #endif -#else - #undef HEATER_7_MINTEMP - #undef HEATER_7_MAXTEMP -#endif - -#if TEMP_SENSOR_BED == -4 - #define TEMP_SENSOR_BED_IS_AD8495 1 -#elif TEMP_SENSOR_BED == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED." -#elif TEMP_SENSOR_BED == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED." -#elif TEMP_SENSOR_BED == -1 - #define TEMP_SENSOR_BED_IS_AD595 1 -#elif TEMP_SENSOR_BED > 0 - #define TEMP_SENSOR_BED_THERMISTOR_ID TEMP_SENSOR_BED - #define TEMP_SENSOR_BED_IS_THERMISTOR 1 - #if TEMP_SENSOR_BED == 1000 - #define TEMP_SENSOR_BED_IS_CUSTOM 1 - #elif TEMP_SENSOR_BED == 998 || TEMP_SENSOR_BED == 999 - #define TEMP_SENSOR_BED_IS_DUMMY 1 - #endif -#else - #undef BED_MINTEMP - #undef BED_MAXTEMP -#endif - -#if TEMP_SENSOR_CHAMBER == -4 - #define TEMP_SENSOR_CHAMBER_IS_AD8495 1 -#elif TEMP_SENSOR_CHAMBER == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER." -#elif TEMP_SENSOR_CHAMBER == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER." -#elif TEMP_SENSOR_CHAMBER == -1 - #define TEMP_SENSOR_CHAMBER_IS_AD595 1 -#elif TEMP_SENSOR_CHAMBER > 0 - #define TEMP_SENSOR_CHAMBER_THERMISTOR_ID TEMP_SENSOR_CHAMBER - #define TEMP_SENSOR_CHAMBER_IS_THERMISTOR 1 - #if TEMP_SENSOR_CHAMBER == 1000 - #define TEMP_SENSOR_CHAMBER_IS_CUSTOM 1 - #elif TEMP_SENSOR_CHAMBER == 998 || TEMP_SENSOR_CHAMBER == 999 - #define TEMP_SENSOR_CHAMBER_IS_DUMMY 1 - #endif -#else - #undef CHAMBER_MINTEMP - #undef CHAMBER_MAXTEMP -#endif - -#if TEMP_SENSOR_COOLER == -4 - #define COOLER_USES_AD8495 1 -#elif TEMP_SENSOR_COOLER == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_COOLER." -#elif TEMP_SENSOR_COOLER == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_COOLER." -#elif TEMP_SENSOR_COOLER == -1 - #define COOLER_USES_AD595 1 -#elif TEMP_SENSOR_COOLER > 0 - #define TEMP_SENSOR_COOLER_THERMISTOR_ID TEMP_SENSOR_COOLER - #define TEMP_SENSOR_COOLER_IS_THERMISTOR 1 - #if TEMP_SENSOR_COOLER == 1000 - #define COOLER_USER_THERMISTOR 1 - #elif TEMP_SENSOR_COOLER == 998 || TEMP_SENSOR_COOLER == 999 - #define COOLER_DUMMY_THERMISTOR 1 - #endif -#else - #undef COOLER_MINTEMP - #undef COOLER_MAXTEMP -#endif - -#if TEMP_SENSOR_PROBE == -4 - #define TEMP_SENSOR_PROBE_IS_AD8495 1 -#elif TEMP_SENSOR_PROBE == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_PROBE." -#elif TEMP_SENSOR_PROBE == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_PROBE." -#elif TEMP_SENSOR_PROBE == -1 - #define TEMP_SENSOR_PROBE_IS_AD595 1 -#elif TEMP_SENSOR_PROBE > 0 - #define TEMP_SENSOR_PROBE_THERMISTOR_ID TEMP_SENSOR_PROBE - #define TEMP_SENSOR_PROBE_IS_THERMISTOR 1 - #if TEMP_SENSOR_PROBE == 1000 - #define TEMP_SENSOR_PROBE_IS_CUSTOM 1 - #elif TEMP_SENSOR_PROBE == 998 || TEMP_SENSOR_PROBE == 999 - #define TEMP_SENSOR_PROBE_IS_DUMMY 1 - #endif -#endif +#endif //HAS_MAX_TC /** * X_DUAL_ENDSTOPS endstop reassignment @@ -2220,7 +2092,7 @@ // // Is an endstop plug used for extra Z endstops or the probe? -#define IS_PROBE_PIN(A,M) (HAS_CUSTOM_PROBE_PIN && Z_MIN_PROBE_PIN == A##_##M##_PIN) +#define IS_PROBE_PIN(A,M) (USES_Z_MIN_PROBE_PIN && Z_MIN_PROBE_PIN == A##_##M##_PIN) #define IS_X2_ENDSTOP(A,M) (ENABLED(X_DUAL_ENDSTOPS) && X2_USE_ENDSTOP == _##A##M##_) #define IS_Y2_ENDSTOP(A,M) (ENABLED(Y_DUAL_ENDSTOPS) && Y2_USE_ENDSTOP == _##A##M##_) #define IS_Z2_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && Z2_USE_ENDSTOP == _##A##M##_) @@ -2294,7 +2166,7 @@ #if PIN_EXISTS(Z4_MAX) #define HAS_Z4_MAX 1 #endif -#if BOTH(HAS_BED_PROBE, HAS_CUSTOM_PROBE_PIN) && PIN_EXISTS(Z_MIN_PROBE) +#if HAS_BED_PROBE && PIN_EXISTS(Z_MIN_PROBE) #define HAS_Z_MIN_PROBE_PIN 1 #endif @@ -2345,6 +2217,12 @@ #if HAS_ADC_TEST(COOLER) #define HAS_TEMP_ADC_COOLER 1 #endif +#if HAS_ADC_TEST(BOARD) + #define HAS_TEMP_ADC_BOARD 1 +#endif +#if HAS_ADC_TEST(REDUNDANT) + #define HAS_TEMP_ADC_REDUNDANT 1 +#endif #define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_MAX_TC, TEMP_SENSOR_##N##_IS_DUMMY) #if HAS_HOTEND && HAS_TEMP(0) @@ -2362,6 +2240,12 @@ #if HAS_TEMP(COOLER) #define HAS_TEMP_COOLER 1 #endif +#if HAS_TEMP(BOARD) + #define HAS_TEMP_BOARD 1 +#endif +#if HAS_TEMP(REDUNDANT) + #define HAS_TEMP_REDUNDANT 1 +#endif #if ENABLED(JOYSTICK) #if PIN_EXISTS(JOY_X) @@ -2430,7 +2314,8 @@ #if HAS_HEATED_BED || HAS_TEMP_CHAMBER #define BED_OR_CHAMBER 1 #endif -#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER + +#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER || HAS_TEMP_BOARD #define HAS_TEMP_SENSOR 1 #endif @@ -2568,14 +2453,103 @@ #endif #undef _NOT_E_AUTO #undef _HAS_FAN -#if PIN_EXISTS(CONTROLLER_FAN) - #define HAS_CONTROLLER_FAN 1 -#endif #if BED_OR_CHAMBER || HAS_FAN0 #define BED_OR_CHAMBER_OR_FAN 1 #endif +/** + * Up to 3 PWM fans + */ +#ifndef FAN_INVERTING + #define FAN_INVERTING false +#endif + +#if HAS_FAN7 + #define FAN_COUNT 8 +#elif HAS_FAN6 + #define FAN_COUNT 7 +#elif HAS_FAN5 + #define FAN_COUNT 6 +#elif HAS_FAN4 + #define FAN_COUNT 5 +#elif HAS_FAN3 + #define FAN_COUNT 4 +#elif HAS_FAN2 + #define FAN_COUNT 3 +#elif HAS_FAN1 + #define FAN_COUNT 2 +#elif HAS_FAN0 + #define FAN_COUNT 1 +#else + #define FAN_COUNT 0 +#endif + +#if FAN_COUNT > 0 + #define HAS_FAN 1 +#endif + +/** + * Part Cooling fan multipliexer + */ +#if PIN_EXISTS(FANMUX0) + #define HAS_FANMUX 1 +#endif + +/** + * MIN/MAX fan PWM scaling + */ +#ifndef FAN_OFF_PWM + #define FAN_OFF_PWM 0 +#endif +#ifndef FAN_MIN_PWM + #if FAN_OFF_PWM > 0 + #define FAN_MIN_PWM (FAN_OFF_PWM + 1) + #else + #define FAN_MIN_PWM 0 + #endif +#endif +#ifndef FAN_MAX_PWM + #define FAN_MAX_PWM 255 +#endif +#if FAN_MIN_PWM < 0 || FAN_MIN_PWM > 255 + #error "FAN_MIN_PWM must be a value from 0 to 255." +#elif FAN_MAX_PWM < 0 || FAN_MAX_PWM > 255 + #error "FAN_MAX_PWM must be a value from 0 to 255." +#elif FAN_MIN_PWM > FAN_MAX_PWM + #error "FAN_MIN_PWM must be less than or equal to FAN_MAX_PWM." +#elif FAN_OFF_PWM > FAN_MIN_PWM + #error "FAN_OFF_PWM must be less than or equal to FAN_MIN_PWM." +#endif + +/** + * FAST PWM FAN Settings + */ +#if ENABLED(FAST_PWM_FAN) && !defined(FAST_PWM_FAN_FREQUENCY) + #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) // Fan frequency default +#endif + +/** + * Controller Fan Settings + */ +#if PIN_EXISTS(CONTROLLER_FAN) + #define HAS_CONTROLLER_FAN 1 + #if CONTROLLER_FAN_MIN_BOARD_TEMP + #define HAS_CONTROLLER_FAN_MIN_BOARD_TEMP 1 + #endif +#endif + +#if HAS_CONTROLLER_FAN + #if ENABLED(CONTROLLER_FAN_USE_BOARD_TEMP) + #define HAS_CONTROLLER_FAN_BOARD_TEMP_TRIGGER 1 + #ifndef CONTROLLER_FAN_TRIGGER_TEMP + #define CONTROLLER_FAN_TRIGGER_TEMP 30 + #endif + #else + #undef CONTROLLER_FAN_TRIGGER_TEMP + #endif +#endif + // Servos #if PIN_EXISTS(SERVO0) && NUM_SERVOS > 0 #define HAS_SERVO_0 1 @@ -2850,77 +2824,6 @@ #undef PREHEAT_SHORTCUT_MENU_ITEM #endif -/** - * Up to 3 PWM fans - */ -#ifndef FAN_INVERTING - #define FAN_INVERTING false -#endif - -#if HAS_FAN7 - #define FAN_COUNT 8 -#elif HAS_FAN6 - #define FAN_COUNT 7 -#elif HAS_FAN5 - #define FAN_COUNT 6 -#elif HAS_FAN4 - #define FAN_COUNT 5 -#elif HAS_FAN3 - #define FAN_COUNT 4 -#elif HAS_FAN2 - #define FAN_COUNT 3 -#elif HAS_FAN1 - #define FAN_COUNT 2 -#elif HAS_FAN0 - #define FAN_COUNT 1 -#else - #define FAN_COUNT 0 -#endif - -#if FAN_COUNT > 0 - #define HAS_FAN 1 -#endif - -/** - * Part Cooling fan multipliexer - */ -#if PIN_EXISTS(FANMUX0) - #define HAS_FANMUX 1 -#endif - -/** - * MIN/MAX fan PWM scaling - */ -#ifndef FAN_OFF_PWM - #define FAN_OFF_PWM 0 -#endif -#ifndef FAN_MIN_PWM - #if FAN_OFF_PWM > 0 - #define FAN_MIN_PWM (FAN_OFF_PWM + 1) - #else - #define FAN_MIN_PWM 0 - #endif -#endif -#ifndef FAN_MAX_PWM - #define FAN_MAX_PWM 255 -#endif -#if FAN_MIN_PWM < 0 || FAN_MIN_PWM > 255 - #error "FAN_MIN_PWM must be a value from 0 to 255." -#elif FAN_MAX_PWM < 0 || FAN_MAX_PWM > 255 - #error "FAN_MAX_PWM must be a value from 0 to 255." -#elif FAN_MIN_PWM > FAN_MAX_PWM - #error "FAN_MIN_PWM must be less than or equal to FAN_MAX_PWM." -#elif FAN_OFF_PWM > FAN_MIN_PWM - #error "FAN_OFF_PWM must be less than or equal to FAN_MIN_PWM." -#endif - -/** - * FAST PWM FAN Settings - */ -#if ENABLED(FAST_PWM_FAN) && !defined(FAST_PWM_FAN_FREQUENCY) - #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) // Fan frequency default -#endif - /** * MIN/MAX case light PWM scaling */ @@ -2953,6 +2856,7 @@ #endif #else #undef NOZZLE_TO_PROBE_OFFSET + #undef PROBING_STEPPERS_OFF #endif /** @@ -2995,24 +2899,32 @@ /** * Heater, Fan, and Probe interactions */ -#if FAN_COUNT == 0 - #undef PROBING_FANS_OFF +#if !HAS_FAN #undef ADAPTIVE_FAN_SLOWING #undef NO_FAN_SLOWING_IN_PID_TUNING #endif - -#if HAS_BED_PROBE && (EITHER(PROBING_HEATERS_OFF, PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0) - #define HAS_QUIET_PROBING 1 +#if !BOTH(HAS_BED_PROBE, HAS_FAN) + #undef PROBING_FANS_OFF +#endif +#if !BOTH(HAS_BED_PROBE, HAS_EXTRUDERS) + #undef PROBING_ESTEPPERS_OFF +#endif +#if BOTH(PROBING_STEPPERS_OFF, PROBING_ESTEPPERS_OFF) + #undef PROBING_ESTEPPERS_OFF + #warning "PROBING_STEPPERS_OFF includes PROBING_ESTEPPERS_OFF. Disabling PROBING_ESTEPPERS_OFF." #endif #if EITHER(ADVANCED_PAUSE_FEATURE, PROBING_HEATERS_OFF) #define HEATER_IDLE_HANDLER 1 #endif +#if HAS_BED_PROBE && (ANY(PROBING_HEATERS_OFF, PROBING_STEPPERS_OFF, PROBING_ESTEPPERS_OFF, PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0) + #define HAS_QUIET_PROBING 1 +#endif /** * Advanced Pause - Filament Change */ #if ENABLED(ADVANCED_PAUSE_FEATURE) - #if HAS_LCD_MENU || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) + #if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) #define M600_PURGE_MORE_RESUMABLE 1 #endif #ifndef FILAMENT_CHANGE_SLOW_LOAD_LENGTH @@ -3242,9 +3154,14 @@ #endif #endif -// LCD timeout to status screen default is 15s -#ifndef LCD_TIMEOUT_TO_STATUS - #define LCD_TIMEOUT_TO_STATUS 15000 +#if HAS_LCD_MENU + // LCD timeout to status screen default is 15s + #ifndef LCD_TIMEOUT_TO_STATUS + #define LCD_TIMEOUT_TO_STATUS 15000 + #endif + #if LCD_TIMEOUT_TO_STATUS + #define SCREENS_CAN_TIME_OUT 1 + #endif #endif // Add commands that need sub-codes to this list diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ee6fae0976..612a2da064 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -416,8 +416,19 @@ #error "MBL_Z_STEP is now MESH_EDIT_Z_STEP." #elif defined(CHDK) #error "CHDK is now CHDK_PIN." -#elif defined(MAX6675_SS) || defined(MAX6675_SS2) - #error "MAX6675_SS / MAX6675_SS2 is now MAX6675_SS_PIN / MAX6675_SS2_PIN." +#elif ANY_PIN( \ + MAX6675_SS, MAX6675_SS2, MAX6675_CS, MAX6675_CS2, \ + MAX31855_SS, MAX31855_SS2, MAX31855_CS, MAX31855_CS2, \ + MAX31865_SS, MAX31865_SS2, MAX31865_CS, MAX31865_CS2) + #warning "MAX*_SS_PIN, MAX*_SS2_PIN, MAX*_CS_PIN, and MAX*_CS2_PIN are deprecated and will be removed in a future version. Please use TEMP_0_CS_PIN/TEMP_1_CS_PIN instead." +#elif ANY_PIN(MAX6675_SCK, MAX31855_SCK, MAX31865_SCK) + #warning "MAX*_SCK_PIN is deprecated and will be removed in a future version. Please use TEMP_0_SCK_PIN/TEMP_1_SCK_PIN instead." +#elif ANY_PIN(MAX6675_MISO, MAX6675_DO, MAX31855_MISO, MAX31855_DO, MAX31865_MISO, MAX31865_DO) + #warning "MAX*_MISO_PIN and MAX*_DO_PIN are deprecated and will be removed in a future version. Please use TEMP_0_MISO_PIN/TEMP_1_MISO_PIN instead." +#elif PIN_EXISTS(MAX31865_MOSI) + #warning "MAX31865_MOSI_PIN is deprecated and will be removed in a future version. Please use TEMP_0_MOSI_PIN/TEMP_1_MOSI_PIN instead." +#elif ANY_PIN(THERMO_CS1_PIN, THERMO_CS2_PIN, THERMO_DO_PIN, THERMO_SCK_PIN) + #error "THERMO_*_PIN is now TEMP_n_CS_PIN, TEMP_n_SCK_PIN, TEMP_n_MOSI_PIN, TEMP_n_MISO_PIN." #elif defined(MAX31865_SENSOR_OHMS) #error "MAX31865_SENSOR_OHMS is now MAX31865_SENSOR_OHMS_0." #elif defined(MAX31865_CALIBRATION_OHMS) @@ -568,14 +579,23 @@ #error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B." #elif defined(NEOPIXEL_BKGD_LED_INDEX) #error "NEOPIXEL_BKGD_LED_INDEX is now NEOPIXEL_BKGD_INDEX_FIRST." +#elif defined(TEMP_SENSOR_1_AS_REDUNDANT) + #error "TEMP_SENSOR_1_AS_REDUNDANT is now TEMP_SENSOR_REDUNDANT, with associated TEMP_SENSOR_REDUNDANT_* config." +#elif defined(MAX_REDUNDANT_TEMP_SENSOR_DIFF) + #error "MAX_REDUNDANT_TEMP_SENSOR_DIFF is now TEMP_SENSOR_REDUNDANT_MAX_DIFF" +#elif MOTHERBOARD == BOARD_DUE3DOM_MINI && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) + #warning "Onboard temperature sensor for BOARD_DUE3DOM_MINI has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." +#elif MOTHERBOARD == BOARD_BTT_SKR_E3_TURBO && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) + #warning "Onboard temperature sensor for BOARD_BTT_SKR_E3_TURBO has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." #endif -constexpr float sbm[] = AXIS_RELATIVE_MODES; -static_assert(COUNT(sbm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _LOGICAL_AXES_STR "elements."); +constexpr float arm[] = AXIS_RELATIVE_MODES; +static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _LOGICAL_AXES_STR "elements."); /** * Probe temp compensation requirements */ + #if ENABLED(PROBE_TEMP_COMPENSATION) #if defined(PTC_PARK_POS_X) || defined(PTC_PARK_POS_Y) || defined(PTC_PARK_POS_Z) #error "PTC_PARK_POS_[XYZ] is now PTC_PARK_POS (array)." @@ -586,6 +606,32 @@ static_assert(COUNT(sbm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #elif !defined(PTC_PROBE_POS) #error "PROBE_TEMP_COMPENSATION requires PTC_PROBE_POS." #endif + + #ifdef PTC_SAMPLE_START + constexpr auto _ptc_sample_start = PTC_SAMPLE_START; + constexpr decltype(_ptc_sample_start) _test_ptc_sample_start = 12.3f; + static_assert(_test_ptc_sample_start != 12.3f, "PTC_SAMPLE_START must be a whole number."); + #endif + #ifdef PTC_SAMPLE_RES + constexpr auto _ptc_sample_res = PTC_SAMPLE_RES; + constexpr decltype(_ptc_sample_res) _test_ptc_sample_res = 12.3f; + static_assert(_test_ptc_sample_res != 12.3f, "PTC_SAMPLE_RES must be a whole number."); + #endif + #ifdef BTC_SAMPLE_START + constexpr auto _btc_sample_start = BTC_SAMPLE_START; + constexpr decltype(_btc_sample_start) _test_btc_sample_start = 12.3f; + static_assert(_test_btc_sample_start != 12.3f, "BTC_SAMPLE_START must be a whole number."); + #endif + #ifdef BTC_SAMPLE_RES + constexpr auto _btc_sample_res = BTC_SAMPLE_RES; + constexpr decltype(_btc_sample_res) _test_btc_sample_res = 12.3f; + static_assert(_test_btc_sample_res != 12.3f, "BTC_SAMPLE_RES must be a whole number."); + #endif + #ifdef BTC_PROBE_TEMP + constexpr auto _btc_probe_temp = BTC_PROBE_TEMP; + constexpr decltype(_btc_probe_temp) _test_btc_probe_temp = 12.3f; + static_assert(_test_btc_probe_temp != 12.3f, "BTC_PROBE_TEMP must be a whole number."); + #endif #endif /** @@ -1013,6 +1059,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "EXTRUDERS must be 1 with HEATERS_PARALLEL." #endif + #if ENABLED(STATUS_HOTEND_INVERTED) && NONE(STATUS_HOTEND_NUMBERLESS, STATUS_HOTEND_ANIM) + #error "With multiple hotends STATUS_HOTEND_INVERTED requires STATUS_HOTEND_ANIM or STATUS_HOTEND_NUMBERLESS." + #endif + #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) #ifndef TOOLCHANGE_FS_LENGTH #error "TOOLCHANGE_FILAMENT_SWAP requires TOOLCHANGE_FS_LENGTH." @@ -1135,6 +1185,19 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif +/** + * Dual E Steppers requirements + */ +#if ENABLED(E_DUAL_STEPPER_DRIVERS) + #if EXTRUDERS > 1 + #error "E_DUAL_STEPPER_DRIVERS can only be used with EXTRUDERS set to 1." + #elif ENABLED(MIXING_EXTRUDER) + #error "E_DUAL_STEPPER_DRIVERS is incompatible with MIXING_EXTRUDER." + #elif ENABLED(SWITCHING_EXTRUDER) + #error "E_DUAL_STEPPER_DRIVERS is incompatible with SWITCHING_EXTRUDER." + #endif +#endif + /** * Linear Advance 1.5 - Check K value range */ @@ -1206,23 +1269,28 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif /** - * (Electro)magnetic Switching Toolhead requirements + * Magnetic / Electromagnetic Switching Toolhead requirements */ #if EITHER(MAGNETIC_SWITCHING_TOOLHEAD, ELECTROMAGNETIC_SWITCHING_TOOLHEAD) #ifndef SWITCHING_TOOLHEAD_Y_POS - #error "(ELECTRO)MAGNETIC_SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_Y_POS" + #error "(ELECTRO)?MAGNETIC_SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_Y_POS" #elif !defined(SWITCHING_TOOLHEAD_X_POS) - #error "(ELECTRO)MAGNETIC_SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_X_POS" - #elif !defined(SWITCHING_TOOLHEAD_Z_HOP) - #error "(ELECTRO)MAGNETIC_SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_Z_HOP." + #error "(ELECTRO)?MAGNETIC_SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_X_POS" #elif !defined(SWITCHING_TOOLHEAD_Y_CLEAR) - #error "(ELECTRO)MAGNETIC_SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_Y_CLEAR." - #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) - #if ENABLED(EXT_SOLENOID) - #error "(ELECTRO)MAGNETIC_SWITCHING_TOOLHEAD and EXT_SOLENOID are incompatible. (Pins are used twice.)" - #elif !PIN_EXISTS(SOL0) - #error "(ELECTRO)MAGNETIC_SWITCHING_TOOLHEAD requires SOL0_PIN." - #endif + #error "(ELECTRO)?MAGNETIC_SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_Y_CLEAR." + #endif +#endif + +/** + * Electromagnetic Switching Toolhead requirements + */ +#if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) + #if ENABLED(EXT_SOLENOID) + #error "ELECTROMAGNETIC_SWITCHING_TOOLHEAD and EXT_SOLENOID are incompatible. (Pins are used twice.)" + #elif !PIN_EXISTS(SOL0) + #error "ELECTROMAGNETIC_SWITCHING_TOOLHEAD requires SOL0_PIN." + #elif !defined(SWITCHING_TOOLHEAD_Z_HOP) + #error "ELECTROMAGNETIC_SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_Z_HOP." #endif #endif @@ -1631,12 +1699,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "MESH_EDIT_GFX_OVERLAY requires AUTO_BED_LEVELING_UBL and a Graphical LCD." #endif -#if ENABLED(G29_RETRY_AND_RECOVER) - #if ENABLED(AUTO_BED_LEVELING_UBL) - #error "G29_RETRY_AND_RECOVER is not compatible with UBL." - #elif ENABLED(MESH_BED_LEVELING) - #error "G29_RETRY_AND_RECOVER is not compatible with MESH_BED_LEVELING." - #endif +#if ENABLED(G29_RETRY_AND_RECOVER) && NONE(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR) + #error "G29_RETRY_AND_RECOVER requires AUTO_BED_LEVELING_3POINT, LINEAR, or BILINEAR." #endif /** @@ -1699,16 +1763,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #ifdef SENSORLESS_BACKOFF_MM - constexpr float sbm[] = SENSORLESS_BACKOFF_MM; - static_assert(COUNT(sbm) == LINEAR_AXES, "SENSORLESS_BACKOFF_MM must have " _LINEAR_AXES_STR "elements (and no others)."); - LINEAR_AXIS_CODE( - static_assert(sbm[X_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.X must be greater than or equal to 0."), - static_assert(sbm[Y_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.Y must be greater than or equal to 0."), - static_assert(sbm[Z_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.Z must be greater than or equal to 0."), - static_assert(sbm[I_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.I must be greater than or equal to 0."), - static_assert(sbm[J_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.J must be greater than or equal to 0."), - static_assert(sbm[K_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.K must be greater than or equal to 0.") - ); + //constexpr float sbm[] = SENSORLESS_BACKOFF_MM; + //static_assert(COUNT(sbm) == LINEAR_AXES, "SENSORLESS_BACKOFF_MM must have " _LINEAR_AXES_STR "elements (and no others)."); + //LINEAR_AXIS_CODE( + // static_assert(sbm[X_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.X must be greater than or equal to 0."), + // static_assert(sbm[Y_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.Y must be greater than or equal to 0."), + // static_assert(sbm[Z_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.Z must be greater than or equal to 0."), + // static_assert(sbm[I_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.I must be greater than or equal to 0."), + // static_assert(sbm[J_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.J must be greater than or equal to 0."), + // static_assert(sbm[K_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.K must be greater than or equal to 0.") + //); #endif #if ENABLED(CODEPENDENT_XY_HOMING) @@ -1855,6 +1919,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif +#ifdef REDUNDANT_PART_COOLING_FAN + #if FAN_COUNT < 2 + #error "REDUNDANT_PART_COOLING_FAN requires a board with at least two PWM fans." + #else + static_assert(WITHIN(REDUNDANT_PART_COOLING_FAN, 1, FAN_COUNT - 1), "REDUNDANT_PART_COOLING_FAN must be between 1 and " STRINGIFY(DECREMENT(FAN_COUNT)) "."); + #endif +#endif + /** * Case Light requirements */ @@ -1891,13 +1963,103 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_CHAMBER 1000 requires CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS and CHAMBER_BETA in Configuration_adv.h." #elif TEMP_SENSOR_PROBE_IS_CUSTOM && !(defined(PROBE_PULLUP_RESISTOR_OHMS) && defined(PROBE_RESISTANCE_25C_OHMS) && defined(PROBE_BETA)) #error "TEMP_SENSOR_PROBE 1000 requires PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS and PROBE_BETA in Configuration_adv.h." +#elif TEMP_SENSOR_BOARD_IS_CUSTOM && !(defined(BOARD_PULLUP_RESISTOR_OHMS) && defined(BOARD_RESISTANCE_25C_OHMS) && defined(BOARD_BETA)) + #error "TEMP_SENSOR_BOARD 1000 requires BOARD_PULLUP_RESISTOR_OHMS, BOARD_RESISTANCE_25C_OHMS and BOARD_BETA in Configuration_adv.h." +#elif TEMP_SENSOR_REDUNDANT_IS_CUSTOM && !(defined(REDUNDANT_PULLUP_RESISTOR_OHMS) && defined(REDUNDANT_RESISTANCE_25C_OHMS) && defined(REDUNDANT_BETA)) + #error "TEMP_SENSOR_REDUNDANT 1000 requires REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS and REDUNDANT_BETA in Configuration_adv.h." #endif /** + * Required MAX31865 settings + */ +#if TEMP_SENSOR_0_IS_MAX31865 || (TEMP_SENSOR_REDUNDANT_IS_MAX31865 && REDUNDANT_TEMP_MATCH(SOURCE, E0)) + #if !defined(MAX31865_SENSOR_WIRES_0) || !WITHIN(MAX31865_SENSOR_WIRES_0, 2, 4) + #error "MAX31865_SENSOR_WIRES_0 must be defined as an integer between 2 and 4." + #elif !defined(MAX31865_SENSOR_OHMS_0) || !defined(MAX31865_CALIBRATION_OHMS_0) + #error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0/TEMP_SENSOR_REDUNDANT is MAX31865." + #endif +#endif +#if TEMP_SENSOR_1_IS_MAX31865 || (TEMP_SENSOR_REDUNDANT_IS_MAX31865 && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + #if !defined(MAX31865_SENSOR_WIRES_1) || !WITHIN(MAX31865_SENSOR_WIRES_1, 2, 4) + #error "MAX31865_SENSOR_WIRES_1 must be defined as an integer between 2 and 4." + #elif !defined(MAX31865_SENSOR_OHMS_1) || !defined(MAX31865_CALIBRATION_OHMS_1) + #error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1/TEMP_SENSOR_REDUNDANT is MAX31865." + #endif +#endif + +/** + * Redundant temperature sensor config + */ +#if HAS_TEMP_REDUNDANT + #if !defined(TEMP_SENSOR_REDUNDANT_SOURCE) + #error "TEMP_SENSOR_REDUNDANT requires TEMP_SENSOR_REDUNDANT_SOURCE." + #elif !defined(TEMP_SENSOR_REDUNDANT_TARGET) + #error "TEMP_SENSOR_REDUNDANT requires TEMP_SENSOR_REDUNDANT_TARGET." + #elif REDUNDANT_TEMP_MATCH(SOURCE, TEMP_SENSOR_REDUNDANT_TARGET) + #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be the same as TEMP_SENSOR_REDUNDANT_TARGET." + #elif HAS_MULTI_HOTEND && TEMP_SENSOR_REDUNDANT_SOURCE < HOTENDS + #error "TEMP_SENSOR_REDUNDANT_SOURCE must be after the last used hotend TEMP_SENSOR." + #endif + + #if REDUNDANT_TEMP_MATCH(SOURCE, E0) && HAS_HOTEND + #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be 0 if a hotend is used. E0 always uses TEMP_SENSOR_0." + #elif REDUNDANT_TEMP_MATCH(SOURCE, COOLER) && HAS_TEMP_COOLER + #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be COOLER. TEMP_SENSOR_COOLER is in use." + #elif REDUNDANT_TEMP_MATCH(SOURCE, PROBE) && HAS_TEMP_PROBE + #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be PROBE. TEMP_SENSOR_PROBE is in use." + #elif REDUNDANT_TEMP_MATCH(SOURCE, BOARD) && HAS_TEMP_BOARD + #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be BOARD. TEMP_SENSOR_BOARD is in use." + #elif REDUNDANT_TEMP_MATCH(SOURCE, CHAMBER) && HAS_TEMP_CHAMBER + #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be CHAMBER. TEMP_SENSOR_CHAMBER is in use." + #elif REDUNDANT_TEMP_MATCH(SOURCE, BED) && HAS_TEMP_BED + #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be BED. TEMP_SENSOR_BED is in use." + #endif + + #if REDUNDANT_TEMP_MATCH(TARGET, E0) && !PIN_EXISTS(TEMP_0) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E0 without TEMP_0_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, E1) && !PIN_EXISTS(TEMP_1) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E1 without TEMP_1_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, E2) && !PIN_EXISTS(TEMP_2) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E2 without TEMP_2_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, E3) && !PIN_EXISTS(TEMP_3) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E3 without TEMP_3_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, E4) && !PIN_EXISTS(TEMP_4) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E4 without TEMP_4_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, E5) && !PIN_EXISTS(TEMP_5) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E5 without TEMP_5_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, E6) && !PIN_EXISTS(TEMP_6) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E6 without TEMP_6_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, E7) && !PIN_EXISTS(TEMP_7) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E7 without TEMP_7_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, BED) && !PIN_EXISTS(TEMP_BED) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be BED without TEMP_BED_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, CHAMBER) && !PIN_EXISTS(TEMP_CHAMBER) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be CHAMBER without TEMP_CHAMBER_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, BOARD) && !PIN_EXISTS(TEMP_BOARD) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be BOARD without TEMP_BOARD_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, PROBE) && !PIN_EXISTS(TEMP_PROBE) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be PROBE without TEMP_PROBE_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, COOLER) && !PIN_EXISTS(TEMP_COOLER) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be COOLER without TEMP_COOLER_PIN defined." + #endif + + #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0) && !PIN_EXISTS(TEMP_0_CS) + #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE E0 requires TEMP_0_CS_PIN." + #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1) && !PIN_EXISTS(TEMP_1_CS) + #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE E1 requires TEMP_1_CS_PIN." + #endif +#endif + +/** + * Test Sensor & Heater pin combos. * Pins and Sensor IDs must be set for each heater */ -#if TEMP_SENSOR_0_IS_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS) - #error "TEMP_SENSOR_0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN." +#if !ANY_PIN(TEMP_0, TEMP_0_CS) + #error "TEMP_0_PIN or TEMP_0_CS_PIN not defined for this board." +#elif !HAS_HEATER_0 && EXTRUDERS + #error "HEATER_0_PIN not defined for this board." +#elif TEMP_SENSOR_0_IS_MAX_TC && !PIN_EXISTS(TEMP_0_CS) + #error "TEMP_SENSOR_0 MAX thermocouple requires TEMP_0_CS_PIN." #elif HAS_HOTEND && !HAS_TEMP_HOTEND && !TEMP_SENSOR_0_IS_DUMMY #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." #elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1 @@ -1905,14 +2067,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #if HAS_MULTI_HOTEND - #if TEMP_SENSOR_1_IS_MAX6675 && !ANY_PIN(MAX6675_SS2, MAX31855_CS2, MAX31865_CS2, MAX6675_CS2) - #error "TEMP_SENSOR_1 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." + #if TEMP_SENSOR_1_IS_MAX_TC && !PIN_EXISTS(TEMP_1_CS) + #error "TEMP_SENSOR_1 MAX thermocouple requires TEMP_1_CS_PIN." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." - #elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !TEMP_SENSOR_1_IS_DUMMY - #error "TEMP_1_PIN or MAX6675_SS2_PIN not defined for this board." - #elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - #error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT." + #elif !ANY_PIN(TEMP_1, TEMP_1_CS) && !TEMP_SENSOR_1_IS_DUMMY + #error "TEMP_1_PIN or TEMP_1_CS_PIN not defined for this board." #endif #if HOTENDS > 2 #if TEMP_SENSOR_2 == 0 @@ -2010,7 +2170,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif TEMP_SENSOR_7 != 0 #error "TEMP_SENSOR_7 shouldn't be set with only 2 HOTENDS." #endif -#elif TEMP_SENSOR_1 != 0 && DISABLED(TEMP_SENSOR_1_AS_REDUNDANT) +#elif TEMP_SENSOR_1 != 0 #error "TEMP_SENSOR_1 shouldn't be set with only 1 HOTEND." #elif TEMP_SENSOR_2 != 0 #error "TEMP_SENSOR_2 shouldn't be set with only 1 HOTEND." @@ -2024,14 +2184,53 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_6 shouldn't be set with only 1 HOTEND." #elif TEMP_SENSOR_7 != 0 #error "TEMP_SENSOR_7 shouldn't be set with only 1 HOTEND." -#endif +#endif // HAS_MULTI_HOTEND +/** + * Pins must be set for temp sensors, with some other feature requirements. + */ #if TEMP_SENSOR_CHAMBER && !PIN_EXISTS(TEMP_CHAMBER) #error "TEMP_SENSOR_CHAMBER requires TEMP_CHAMBER_PIN." #endif -#if TEMP_SENSOR_COOLER && !(PIN_EXISTS(TEMP_COOLER) && ENABLED(LASER_FEATURE)) - #error "TEMP_SENSOR_COOLER requires LASER_FEATURE and TEMP_COOLER_PIN." +#if TEMP_SENSOR_COOLER + #if !PIN_EXISTS(TEMP_COOLER) + #error "TEMP_SENSOR_COOLER requires TEMP_COOLER_PIN." + #elif DISABLED(LASER_FEATURE) + #error "TEMP_SENSOR_COOLER requires LASER_FEATURE." + #endif +#endif + +#if TEMP_SENSOR_PROBE + #if !PIN_EXISTS(TEMP_PROBE) + #error "TEMP_SENSOR_PROBE requires TEMP_PROBE_PIN." + #elif !HAS_TEMP_ADC_PROBE + #error "TEMP_PROBE_PIN must be an ADC pin." + #elif DISABLED(FIX_MOUNTED_PROBE) + #error "TEMP_SENSOR_PROBE shouldn't be set without FIX_MOUNTED_PROBE." + #endif +#endif + +#if TEMP_SENSOR_PROBE + #if !PIN_EXISTS(TEMP_PROBE) + #error "TEMP_SENSOR_PROBE requires TEMP_PROBE_PIN." + #elif !HAS_TEMP_ADC_PROBE + #error "TEMP_PROBE_PIN must be an ADC pin." + #elif DISABLED(FIX_MOUNTED_PROBE) + #error "TEMP_SENSOR_PROBE shouldn't be set without FIX_MOUNTED_PROBE." + #endif +#endif + +#if TEMP_SENSOR_BOARD + #if !PIN_EXISTS(TEMP_BOARD) + #error "TEMP_SENSOR_BOARD requires TEMP_BOARD_PIN." + #elif !HAS_TEMP_ADC_BOARD + #error "TEMP_BOARD_PIN must be an ADC pin." + #elif ENABLED(THERMAL_PROTECTION_BOARD) && (!defined(BOARD_MINTEMP) || !defined(BOARD_MAXTEMP)) + #error "THERMAL_PROTECTION_BOARD requires BOARD_MINTEMP and BOARD_MAXTEMP." + #endif +#elif CONTROLLER_FAN_MIN_BOARD_TEMP + #error "CONTROLLER_FAN_MIN_BOARD_TEMP requires TEMP_SENSOR_BOARD." #endif #if ENABLED(LASER_COOLANT_FLOW_METER) && !(PIN_EXISTS(FLOWMETER) && ENABLED(LASER_FEATURE)) @@ -2062,45 +2261,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if TEMP_SENSOR_PROBE - #if !PIN_EXISTS(TEMP_PROBE) - #error "TEMP_SENSOR_PROBE requires TEMP_PROBE_PIN." - #elif !HAS_TEMP_ADC_PROBE - #error "TEMP_PROBE_PIN must be an ADC pin." - #elif DISABLED(FIX_MOUNTED_PROBE) - #error "TEMP_SENSOR_PROBE shouldn't be set without FIX_MOUNTED_PROBE." - #endif -#endif - -#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) && TEMP_SENSOR_1 == 0 - #error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT." -#endif - -#if TEMP_SENSOR_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0)) - #error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0 is MAX31865." -#elif TEMP_SENSOR_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1)) - #error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1 is MAX31865." -#endif - -/** - * Test Heater, Temp Sensor, and Extruder Pins - */ -#if !HAS_HEATER_0 && EXTRUDERS - #error "HEATER_0_PIN not defined for this board." -#elif !ANY_PIN(TEMP_0, MAX6675_SS) - #error "TEMP_0_PIN or MAX6675_SS not defined for this board." -#endif - -#if HAS_EXTRUDERS - #if ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) - #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." - #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) - #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." - #elif EXTRUDERS && TEMP_SENSOR_0 == 0 - #error "TEMP_SENSOR_0 is required if there are any extruders." - #endif -#endif - /** * Temperature status LEDs */ @@ -2142,6 +2302,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Test Extruder Stepper Pins */ +#if HAS_EXTRUDERS + #if ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) + #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." + #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) + #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." + #elif EXTRUDERS && TEMP_SENSOR_0 == 0 + #error "TEMP_SENSOR_0 is required if there are any extruders." + #endif +#endif + #if E_STEPPERS #if !(PINS_EXIST(E0_STEP, E0_DIR) && HAS_E0_ENABLE) #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." @@ -3468,6 +3638,13 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #error "Either enable MEATPACK_ON_SERIAL_PORT_* or BINARY_FILE_TRANSFER, not both." #endif +/** + * Sanity Check for Slim LCD Menus and Probe Offset Wizard + */ +#if BOTH(SLIM_LCD_MENUS, PROBE_OFFSET_WIZARD) + #error "SLIM_LCD_MENUS disables \"Advanced Settings > Probe Offsets > PROBE_OFFSET_WIZARD.\"" +#endif + /** * Sanity check for unique start and stop values in NOZZLE_CLEAN_FEATURE */ diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 722c63e117..ee17e8d71c 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-06-05" + #define STRING_DISTRIBUTION_DATE "2021-08-01" #endif /** @@ -52,7 +52,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 02000900 +#define MARLIN_HEX_VERSION 02000901 #ifndef REQUIRED_CONFIGURATION_H_VERSION #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION #endif diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 50c80c9fa0..0c87c3dc3f 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -50,6 +50,10 @@ #include "../../feature/cooler.h" #endif +#if ENABLED(I2C_AMMETER) + #include "../../feature/ammeter.h" +#endif + #if ENABLED(AUTO_BED_LEVELING_UBL) #include "../../feature/bedlevel/bedlevel.h" #endif @@ -64,11 +68,7 @@ #elif EITHER(LCD_I2C_TYPE_MCP23017, LCD_I2C_TYPE_MCP23008) - LCD_CLASS lcd(LCD_I2C_ADDRESS - #ifdef DETECT_DEVICE - , 1 - #endif - ); + LCD_CLASS lcd(LCD_I2C_ADDRESS OPTARG(DETECT_I2C_LCD_DEVICE, 1)); #elif ENABLED(LCD_I2C_TYPE_PCA8574) @@ -376,11 +376,7 @@ void MarlinUI::init_lcd() { } bool MarlinUI::detected() { - return (true - #if EITHER(LCD_I2C_TYPE_MCP23017, LCD_I2C_TYPE_MCP23008) && defined(DETECT_DEVICE) - && lcd.LcdDetected() == 1 - #endif - ); + return TERN1(DETECT_I2C_LCD_DEVICE, lcd.LcdDetected() == 1); } #if HAS_SLOW_BUTTONS @@ -588,12 +584,27 @@ FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { #if ENABLED(LASER_COOLANT_FLOW_METER) FORCE_INLINE void _draw_flowmeter_status() { - lcd_put_u8str("~ "); + lcd_put_u8str("~"); lcd_put_u8str(ftostr11ns(cooler.flowrate)); lcd_put_wchar('L'); } #endif +#if ENABLED(I2C_AMMETER) + FORCE_INLINE void _draw_ammeter_status() { + lcd_put_u8str(" "); + ammeter.read(); + if (ammeter.current <= 0.999f) { + lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); + lcd_put_u8str("mA"); + } + else { + lcd_put_u8str(ftostr12ns(ammeter.current)); + lcd_put_wchar('A'); + } + } +#endif + FORCE_INLINE void _draw_bed_status(const bool blink) { _draw_heater_status(H_BED, TERN0(HAS_LEVELING, blink && planner.leveling_active) ? '_' : LCD_STR_BEDTEMP[0], blink); } @@ -829,12 +840,9 @@ void MarlinUI::draw_status_screen() { #endif #endif - #if HAS_COOLER - _draw_cooler_status('*', blink); - #endif - #if ENABLED(LASER_COOLANT_FLOW_METER) - _draw_flowmeter_status(); - #endif + TERN_(HAS_COOLER, _draw_cooler_status('*', blink)); + TERN_(LASER_COOLANT_FLOW_METER, _draw_flowmeter_status()); + TERN_(I2C_AMMETER, _draw_ammeter_status()); #endif // LCD_WIDTH >= 20 diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index edb17b69c0..5991fc3b8b 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -57,6 +57,18 @@ #include "../../gcode/parser.h" #endif +#if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER) + #include "../../feature/cooler.h" +#endif + +#if ENABLED(I2C_AMMETER) + #include "../../feature/ammeter.h" +#endif + +#if HAS_CUTTER + #include "../../feature/spindle_laser.h" +#endif + #if ENABLED(AUTO_BED_LEVELING_UBL) #include "../../feature/bedlevel/bedlevel.h" #endif @@ -64,12 +76,12 @@ TFTGLCD lcd; #define ICON_LOGO B00000001 -#define ICON_TEMP1 B00000010 //hotend 1 -#define ICON_TEMP2 B00000100 //hotend 2 -#define ICON_TEMP3 B00001000 //hotend 3 +#define ICON_TEMP1 B00000010 // Hotend 1 +#define ICON_TEMP2 B00000100 // Hotend 2 +#define ICON_TEMP3 B00001000 // Hotend 3 #define ICON_BED B00010000 #define ICON_FAN B00100000 -#define ICON_HOT B01000000 //when any T > 50deg +#define ICON_HOT B01000000 // When any T > 50deg #define PIC_MASK 0x7F // LEDs not used, for compatibility with Smoothieware @@ -433,69 +445,161 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const lcd_put_u8str(value); } -FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *prefix, const bool blink) { - uint8_t pic_hot_bits; - #if HAS_HEATED_BED - const bool isBed = heater_id < 0; - 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.wholeDegHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); - #endif +#if HAS_HOTEND || HAS_HEATED_BED - #if HOTENDS < 2 - if (heater_id == H_E0) { - lcd.setCursor(2, 5); lcd.print(prefix); //HE - lcd.setCursor(1, 6); lcd.print(i16tostr3rj(t1)); - lcd.setCursor(1, 7); - } - else { - lcd.setCursor(6, 5); lcd.print(prefix); //BED - lcd.setCursor(6, 6); lcd.print(i16tostr3rj(t1)); - lcd.setCursor(6, 7); - } - #else - if (heater_id > H_BED) { - lcd.setCursor(heater_id * 4, 5); lcd.print(prefix); // HE1 or HE2 or HE3 - lcd.setCursor(heater_id * 4, 6); lcd.print(i16tostr3rj(t1)); - lcd.setCursor(heater_id * 4, 7); - } - else { - lcd.setCursor(13, 5); lcd.print(prefix); //BED - lcd.setCursor(13, 6); lcd.print(i16tostr3rj(t1)); - lcd.setCursor(13, 7); - } - #endif // HOTENDS <= 1 + FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *prefix, const bool blink) { + uint8_t pic_hot_bits; + #if HAS_HEATED_BED + const bool isBed = heater_id < 0; + 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.wholeDegHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); + #endif - #if !HEATER_IDLE_HANDLER - UNUSED(blink); - #else - if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd.write(' '); - if (t2 >= 10) lcd.write(' '); - if (t2 >= 100) lcd.write(' '); - } - else - #endif // !HEATER_IDLE_HANDLER - lcd.print(i16tostr3rj(t2)); + #if HOTENDS < 2 + if (heater_id == H_E0) { + lcd.setCursor(2, 5); lcd.print(prefix); //HE + lcd.setCursor(1, 6); lcd.print(i16tostr3rj(t1)); + lcd.setCursor(1, 7); + } + else { + lcd.setCursor(6, 5); lcd.print(prefix); //BED + lcd.setCursor(6, 6); lcd.print(i16tostr3rj(t1)); + lcd.setCursor(6, 7); + } + #else + if (heater_id > H_BED) { + lcd.setCursor(heater_id * 4, 5); lcd.print(prefix); // HE1 or HE2 or HE3 + lcd.setCursor(heater_id * 4, 6); lcd.print(i16tostr3rj(t1)); + lcd.setCursor(heater_id * 4, 7); + } + else { + lcd.setCursor(13, 5); lcd.print(prefix); //BED + lcd.setCursor(13, 6); lcd.print(i16tostr3rj(t1)); + lcd.setCursor(13, 7); + } + #endif // HOTENDS <= 1 - switch (heater_id) { - case H_BED: pic_hot_bits = ICON_BED; break; - case H_E0: pic_hot_bits = ICON_TEMP1; break; - case H_E1: pic_hot_bits = ICON_TEMP2; break; - case H_E2: pic_hot_bits = ICON_TEMP3; - default: break; + #if !HEATER_IDLE_HANDLER + UNUSED(blink); + #else + if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { + lcd.write(' '); + if (t2 >= 10) lcd.write(' '); + if (t2 >= 100) lcd.write(' '); + } + else + #endif // !HEATER_IDLE_HANDLER + lcd.print(i16tostr3rj(t2)); + + switch (heater_id) { + case H_BED: pic_hot_bits = ICON_BED; break; + case H_E0: pic_hot_bits = ICON_TEMP1; break; + case H_E1: pic_hot_bits = ICON_TEMP2; break; + case H_E2: pic_hot_bits = ICON_TEMP3; + default: break; + } + + if (t2) picBits |= pic_hot_bits; + else picBits &= ~pic_hot_bits; + + if (t1 > 50) hotBits |= pic_hot_bits; + else hotBits &= ~pic_hot_bits; + + if (hotBits) picBits |= ICON_HOT; + else picBits &= ~ICON_HOT; } - if (t2) picBits |= pic_hot_bits; - else picBits &= ~pic_hot_bits; +#endif // HAS_HOTEND || HAS_HEATED_BED - if (t1 > 50) hotBits |= pic_hot_bits; - else hotBits &= ~pic_hot_bits; +#if HAS_COOLER - if (hotBits) picBits |= ICON_HOT; - else picBits &= ~ICON_HOT; -} + FORCE_INLINE void _draw_cooler_status(const bool blink) { + const celsius_t t2 = thermalManager.degTargetCooler(); + + lcd.setCursor(0, 5); lcd_put_u8str_P(PSTR("COOL")); + lcd.setCursor(1, 6); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); + lcd.setCursor(1, 7); + + #if !HEATER_IDLE_HANDLER + UNUSED(blink); + #else + if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { + lcd_put_wchar(' '); + if (t2 >= 10) lcd_put_wchar(' '); + if (t2 >= 100) lcd_put_wchar(' '); + } + else + #endif + lcd_put_u8str(i16tostr3left(t2)); + + lcd_put_wchar(' '); + if (t2 < 10) lcd_put_wchar(' '); + + if (t2) picBits |= ICON_TEMP1; + else picBits &= ~ICON_TEMP1; + } + +#endif // HAS_COOLER + +#if ENABLED(LASER_COOLANT_FLOW_METER) + + FORCE_INLINE void _draw_flowmeter_status() { + lcd.setCursor(5, 5); lcd_put_u8str_P(PSTR("FLOW")); + lcd.setCursor(7, 6); lcd_put_wchar('L'); + lcd.setCursor(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate)); + + if (cooler.flowrate) picBits |= ICON_FAN; + else picBits &= ~ICON_FAN; + } + +#endif + +#if ENABLED(I2C_AMMETER) + + FORCE_INLINE void _draw_ammeter_status() { + lcd.setCursor(10, 5); lcd_put_u8str_P(PSTR("ILAZ")); + ammeter.read(); + lcd.setCursor(11, 6); + if (ammeter.current <= 0.999f) + { + lcd_put_u8str("mA"); + lcd.setCursor(10, 7); + lcd_put_wchar(' '); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); + } + else { + lcd_put_u8str(" A"); + lcd.setCursor(10, 7); + lcd_put_u8str(ftostr12ns(ammeter.current)); + } + + if (ammeter.current) picBits |= ICON_BED; + else picBits &= ~ICON_BED; + } + +#endif // I2C_AMMETER + +#if HAS_CUTTER + + FORCE_INLINE void _draw_cutter_status() { + lcd.setCursor(15, 5); lcd_put_u8str_P(PSTR("CUTT")); + #if CUTTER_UNIT_IS(RPM) + lcd.setCursor(16, 6); lcd_put_u8str_P(PSTR("RPM")); + lcd.setCursor(15, 7); lcd_put_u8str(ftostr31ns(float(cutter.unitPower) / 1000)); + lcd_put_wchar('K'); + #elif CUTTER_UNIT_IS(PERCENT) + lcd.setCursor(17, 6); lcd_put_wchar('%'); + lcd.setCursor(18, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); + #else + lcd.setCursor(17, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); + #endif + + if (cutter.unitPower) picBits |= ICON_HOT; + else picBits &= ~ICON_HOT; + } + +#endif // HAS_CUTTER #if HAS_PRINT_PROGRESS @@ -533,7 +637,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p } } -#endif +#endif // LCD_PROGRESS_BAR void MarlinUI::draw_status_message(const bool blink) { if (!PanelDetected) return; @@ -648,6 +752,19 @@ or or +|X 000 Y 000 Z 000.00| +|FR100% SD100% C--:--| +| Progress bar line | +|Status message | +| | +|COOL FLOW ILAZ CUTT | +| ttc L mA RPM | +| tts f.f aaa rr.rK| +| ICO ICO ICO ICO | +| ICO ICO ICO ICO | + +or + Equal to 24x10 text LCD |X 000 Y 000 Z 000.00 | @@ -674,9 +791,10 @@ void MarlinUI::draw_status_screen() { // lcd.setCursor(0, 0); - _draw_axis_value(X_AXIS, ftostr4sign(LOGICAL_X_POSITION(current_position.x)), blink); lcd.write(' '); - _draw_axis_value(Y_AXIS, ftostr4sign(LOGICAL_Y_POSITION(current_position.y)), blink); lcd.write(' '); - _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink); + const xyz_pos_t lpos = current_position.asLogical(); + _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink); lcd.write(' '); + _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink); lcd.write(' '); + _draw_axis_value(Z_AXIS, ftostr52sp(lpos.z), blink); #if HAS_LEVELING && !HAS_HEATED_BED lcd.write(planner.leveling_active || blink ? '_' : ' '); @@ -745,50 +863,61 @@ void MarlinUI::draw_status_screen() { #endif // - // Line 6..8 Temperatures, FAN + // Line 6..8 Temperatures, FAN for printer or Cooler, Flowmetter, Ampermeter, Cutter for laser/spindle // - #if HOTENDS < 2 - _draw_heater_status(H_E0, "HE", blink); // Hotend Temperature - #else - _draw_heater_status(H_E0, "HE1", blink); // Hotend 1 Temperature - _draw_heater_status(H_E1, "HE2", blink); // Hotend 2 Temperature - #if HOTENDS > 2 - _draw_heater_status(H_E2, "HE3", blink); // Hotend 3 Temperature - #endif - #endif - - #if HAS_HEATED_BED - #if HAS_LEVELING - _draw_heater_status(H_BED, (planner.leveling_active && blink ? "___" : "BED"), blink); - #else - _draw_heater_status(H_BED, "BED", blink); - #endif - #endif - - #if HAS_FAN - uint16_t spd = thermalManager.fan_speed[0]; - #if ENABLED(ADAPTIVE_FAN_SLOWING) - if (!blink) spd = thermalManager.scaledFanSpeed(0, spd); - #endif - uint16_t per = thermalManager.pwmToPercent(spd); + #if HAS_HOTEND #if HOTENDS < 2 - #define FANX 11 + _draw_heater_status(H_E0, "HE", blink); // Hotend Temperature #else - #define FANX 17 + _draw_heater_status(H_E0, "HE1", blink); // Hotend 1 Temperature + _draw_heater_status(H_E1, "HE2", blink); // Hotend 2 Temperature + #if HOTENDS > 2 + _draw_heater_status(H_E2, "HE3", blink); // Hotend 3 Temperature + #endif #endif - lcd.setCursor(FANX, 5); lcd_put_u8str_P(PSTR("FAN")); - lcd.setCursor(FANX + 1, 6); lcd.write('%'); - lcd.setCursor(FANX, 7); - lcd.print(i16tostr3rj(per)); - if (TERN0(HAS_FAN0, thermalManager.fan_speed[0]) || TERN0(HAS_FAN1, thermalManager.fan_speed[1]) || TERN0(HAS_FAN2, thermalManager.fan_speed[2])) - picBits |= ICON_FAN; - else - picBits &= ~ICON_FAN; + #if HAS_HEATED_BED + #if HAS_LEVELING + _draw_heater_status(H_BED, (planner.leveling_active && blink ? "___" : "BED"), blink); + #else + _draw_heater_status(H_BED, "BED", blink); + #endif + #endif - #endif // HAS_FAN + #if HAS_FAN + uint16_t spd = thermalManager.fan_speed[0]; + #if ENABLED(ADAPTIVE_FAN_SLOWING) + if (!blink) spd = thermalManager.scaledFanSpeed(0, spd); + #endif + uint16_t per = thermalManager.pwmToPercent(spd); + + #if HOTENDS < 2 + #define FANX 11 + #else + #define FANX 17 + #endif + lcd.setCursor(FANX, 5); lcd_put_u8str_P(PSTR("FAN")); + lcd.setCursor(FANX + 1, 6); lcd.write('%'); + lcd.setCursor(FANX, 7); + lcd.print(i16tostr3rj(per)); + + if (TERN0(HAS_FAN0, thermalManager.fan_speed[0]) || TERN0(HAS_FAN1, thermalManager.fan_speed[1]) || TERN0(HAS_FAN2, thermalManager.fan_speed[2])) + picBits |= ICON_FAN; + else + picBits &= ~ICON_FAN; + + #endif // HAS_FAN + + #else + + TERN_(HAS_COOLER, _draw_cooler_status(blink)); + TERN_(LASER_COOLANT_FLOW_METER, _draw_flowmeter_status()); + TERN_(I2C_AMMETER, _draw_ammeter_status()); + TERN_(HAS_CUTTER, _draw_cutter_status()); + + #endif // // Line 9, 10 - icons diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index 8a707ab41a..a30dd4ca17 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -23,7 +23,7 @@ // Use this file to select the com driver for device drivers that are NOT in the U8G library -#include +#include #ifndef U8G_HAL_LINKS // Defined by LPC1768/9 environments in platform.ini @@ -97,6 +97,11 @@ #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_HAL_LPC1768_ST7920_hw_spi_fn #define U8G_COM_SSD_I2C_HAL u8g_com_HAL_LPC1768_ssd_hw_i2c_fn +#elif defined(__PLAT_NATIVE_SIM__) + uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + #define U8G_COM_HAL_SW_SPI_FN u8g_com_sw_spi_fn + #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_ST7920_sw_spi_fn #endif #ifndef U8G_COM_HAL_SW_SPI_FN diff --git a/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin/src/lcd/dogm/dogm_Statusscreen.h index 61d22a28ec..dfbf7b4291 100644 --- a/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -107,7 +107,17 @@ #define STATUS_FLOWMETER_BYTEWIDTH BW(STATUS_FLOWMETER_WIDTH) #endif - +// +// Laser Ammeter +// +#if ENABLED(I2C_AMMETER) + #if !STATUS_AMMETER_WIDTH + #include "status/ammeter.h" + #endif + #ifndef STATUS_AMMETER_WIDTH + #define STATUS_AMMETER_WIDTH 0 + #endif +#endif // // Bed @@ -603,6 +613,31 @@ #endif #endif +// +// I2C Laser Ammeter +// +#if ENABLED(I2C_AMMETER) && STATUS_AMMETER_WIDTH + #ifndef STATUS_AMMETER_BYTEWIDTH + #define STATUS_AMMETER_BYTEWIDTH BW(STATUS_AMMETER_WIDTH) + #endif + #ifndef STATUS_AMMETER_X + #define STATUS_AMMETER_X (LCD_PIXEL_WIDTH - (STATUS_AMMETER_BYTEWIDTH + STATUS_FLOWMETER_BYTEWIDTH + STATUS_FAN_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH + STATUS_COOLER_BYTEWIDTH) * 8) + #endif + #ifndef STATUS_AMMETER_HEIGHT + #define STATUS_AMMETER_HEIGHT(S) (sizeof(status_ammeter_bmp_mA) / (STATUS_AMMETER_BYTEWIDTH)) + #endif + #ifndef STATUS_AMMETER_Y + #define STATUS_AMMETER_Y(S) (18 - STATUS_AMMETER_HEIGHT(S)) + #endif + #ifndef STATUS_AMMETER_TEXT_X + #define STATUS_AMMETER_TEXT_X (STATUS_AMMETER_X + 7) + #endif + static_assert( + sizeof(status_ammeter_bmp_mA) == (STATUS_AMMETER_BYTEWIDTH) * STATUS_AMMETER_HEIGHT(0), + "Status ammeter bitmap (status_ammeter_bmp_mA) dimensions don't match data." + ); +#endif + // // Bed Bitmap Properties // @@ -696,6 +731,9 @@ #if ENABLED(LASER_COOLANT_FLOW_METER) #define DO_DRAW_FLOWMETER 1 #endif +#if ENABLED(I2C_AMMETER) + #define DO_DRAW_AMMETER 1 +#endif #if HAS_TEMP_CHAMBER && STATUS_CHAMBER_WIDTH && HOTENDS <= 4 #define DO_DRAW_CHAMBER 1 diff --git a/Marlin/src/lcd/dogm/fontdata/fontdata_6x9_marlin.h b/Marlin/src/lcd/dogm/fontdata/fontdata_6x9_marlin.h index cd9cb3cdc9..524ff18778 100644 --- a/Marlin/src/lcd/dogm/fontdata/fontdata_6x9_marlin.h +++ b/Marlin/src/lcd/dogm/fontdata/fontdata_6x9_marlin.h @@ -32,7 +32,7 @@ X Font ascent = 6 descent=-2 Max Font ascent = 7 descent=-2 */ -#include +#include const u8g_fntpgm_uint8_t u8g_font_6x9[2434] U8G_FONT_SECTION(".progmem.u8g_font_6x9") = { 0x00,0x06,0x09,0x00,0xFE,0x06,0x02,0x0F,0x03,0x84,0x01,0xFF,0xFE,0x07,0xFE,0x06, 0xFE,0x05,0x07,0x07,0x00,0x00,0x00,0x40,0xF0,0xC8,0x88,0x98,0x78,0x10,0x05,0x07, diff --git a/Marlin/src/lcd/dogm/fontdata/fontdata_ISO10646_1.h b/Marlin/src/lcd/dogm/fontdata/fontdata_ISO10646_1.h index b4b615da4d..0a7ece8601 100644 --- a/Marlin/src/lcd/dogm/fontdata/fontdata_ISO10646_1.h +++ b/Marlin/src/lcd/dogm/fontdata/fontdata_ISO10646_1.h @@ -16,7 +16,7 @@ * along with this program. If not, see . * */ -#include +#include #if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7) // reduced font (only symbols 1 - 127) - saves about 1278 bytes of FLASH diff --git a/Marlin/src/lcd/dogm/fontdata/langdata.h b/Marlin/src/lcd/dogm/fontdata/langdata.h new file mode 100644 index 0000000000..746a3bd0b4 --- /dev/null +++ b/Marlin/src/lcd/dogm/fontdata/langdata.h @@ -0,0 +1,23 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include + +#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_an.h b/Marlin/src/lcd/dogm/fontdata/langdata_an.h index ffda82764f..fb0fdcf893 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_an.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_an.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_an[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_bg.h b/Marlin/src/lcd/dogm/fontdata/langdata_bg.h index c506f87933..20cd7b9ed7 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_bg.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_bg.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_8_144_149[96] U8G_FONT_SECTION("fontpage_8_144_149") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x90,0x95,0x00,0x07,0xFF,0x00, @@ -64,14 +66,13 @@ const u8g_fntpgm_uint8_t fontpage_8_206_207[39] U8G_FONT_SECTION("fontpage_8_206 0x00,0x05,0x05,0x05,0x06,0x00,0x00,0x90,0xA8,0xE8,0xA8,0x90,0x04,0x05,0x05,0x06, 0x01,0x00,0x70,0x90,0x70,0x50,0x90}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(8, 144, 149, fontpage_8_144_149), // 'А' -- 'Е' - FONTDATA_ITEM(8, 151, 152, fontpage_8_151_152), // 'З' -- 'И' - FONTDATA_ITEM(8, 154, 164, fontpage_8_154_164), // 'К' -- 'Ф' - FONTDATA_ITEM(8, 166, 166, fontpage_8_166_166), // 'Ц' -- 'Ц' - FONTDATA_ITEM(8, 175, 195, fontpage_8_175_195), // 'Я' -- 'у' - FONTDATA_ITEM(8, 197, 200, fontpage_8_197_200), // 'х' -- 'ш' - FONTDATA_ITEM(8, 202, 202, fontpage_8_202_202), // 'ъ' -- 'ъ' - FONTDATA_ITEM(8, 206, 207, fontpage_8_206_207), // 'ю' -- 'я' +static const uxg_fontinfo_t g_fontinfo_bg[] PROGMEM = { + FONTDATA_ITEM(8, 144, 149, fontpage_8_144_149), // 'А' -- 'Е' + FONTDATA_ITEM(8, 151, 152, fontpage_8_151_152), // 'З' -- 'И' + FONTDATA_ITEM(8, 154, 164, fontpage_8_154_164), // 'К' -- 'Ф' + FONTDATA_ITEM(8, 166, 166, fontpage_8_166_166), // 'Ц' -- 'Ц' + FONTDATA_ITEM(8, 175, 195, fontpage_8_175_195), // 'Я' -- 'у' + FONTDATA_ITEM(8, 197, 200, fontpage_8_197_200), // 'х' -- 'ш' + FONTDATA_ITEM(8, 202, 202, fontpage_8_202_202), // 'ъ' -- 'ъ' + FONTDATA_ITEM(8, 206, 207, fontpage_8_206_207), // 'ю' -- 'я' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_ca.h b/Marlin/src/lcd/dogm/fontdata/langdata_ca.h index ffda82764f..deac3678b5 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_ca.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_ca.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_ca[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_cz.h b/Marlin/src/lcd/dogm/fontdata/langdata_cz.h index 754459d9af..39f03f3a97 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_cz.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_cz.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_2_140_141[47] U8G_FONT_SECTION("fontpage_2_140_141") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x8C,0x8D,0x00,0x0A,0x00,0x00, @@ -40,15 +42,14 @@ const u8g_fntpgm_uint8_t fontpage_2_253_254[47] U8G_FONT_SECTION("fontpage_2_253 0x00,0x05,0x0A,0x0A,0x06,0x00,0x00,0x50,0x20,0x00,0xF8,0x08,0x10,0x20,0x40,0x80, 0xF8,0x05,0x08,0x08,0x06,0x00,0x00,0x50,0x20,0x00,0xF8,0x10,0x20,0x40,0xF8}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(2, 140, 141, fontpage_2_140_141), // 'Č' -- 'č' - FONTDATA_ITEM(2, 143, 143, fontpage_2_143_143), // 'ď' -- 'ď' - FONTDATA_ITEM(2, 154, 155, fontpage_2_154_155), // 'Ě' -- 'ě' - FONTDATA_ITEM(2, 200, 200, fontpage_2_200_200), // 'ň' -- 'ň' - FONTDATA_ITEM(2, 216, 217, fontpage_2_216_217), // 'Ř' -- 'ř' - FONTDATA_ITEM(2, 224, 225, fontpage_2_224_225), // 'Š' -- 'š' - FONTDATA_ITEM(2, 229, 229, fontpage_2_229_229), // 'ť' -- 'ť' - FONTDATA_ITEM(2, 239, 239, fontpage_2_239_239), // 'ů' -- 'ů' - FONTDATA_ITEM(2, 253, 254, fontpage_2_253_254), // 'Ž' -- 'ž' +static const uxg_fontinfo_t g_fontinfo_cz[] PROGMEM = { + FONTDATA_ITEM(2, 140, 141, fontpage_2_140_141), // 'Č' -- 'č' + FONTDATA_ITEM(2, 143, 143, fontpage_2_143_143), // 'ď' -- 'ď' + FONTDATA_ITEM(2, 154, 155, fontpage_2_154_155), // 'Ě' -- 'ě' + FONTDATA_ITEM(2, 200, 200, fontpage_2_200_200), // 'ň' -- 'ň' + FONTDATA_ITEM(2, 216, 217, fontpage_2_216_217), // 'Ř' -- 'ř' + FONTDATA_ITEM(2, 224, 225, fontpage_2_224_225), // 'Š' -- 'š' + FONTDATA_ITEM(2, 229, 229, fontpage_2_229_229), // 'ť' -- 'ť' + FONTDATA_ITEM(2, 239, 239, fontpage_2_239_239), // 'ů' -- 'ů' + FONTDATA_ITEM(2, 253, 254, fontpage_2_253_254), // 'Ž' -- 'ž' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_da.h b/Marlin/src/lcd/dogm/fontdata/langdata_da.h index ffda82764f..ad8df9a429 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_da.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_da.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_da[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_de.h b/Marlin/src/lcd/dogm/fontdata/langdata_de.h index ffda82764f..44230fa302 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_de.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_de.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_de[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_el.h b/Marlin/src/lcd/dogm/fontdata/langdata_el.h index 4b545f2284..6fefab9c61 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_el.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_el.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_7_136_136[33] U8G_FONT_SECTION("fontpage_7_136_136") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x00,0x0A,0x00,0x00, @@ -75,16 +77,15 @@ const u8g_fntpgm_uint8_t fontpage_64_166_166[24] U8G_FONT_SECTION("fontpage_64_1 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xA6,0xA6,0x00,0x01,0x00,0x00, 0x00,0x05,0x01,0x01,0x06,0x00,0x00,0xA8}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(7, 136, 136, fontpage_7_136_136), // 'Έ' -- 'Έ' - FONTDATA_ITEM(7, 145, 157, fontpage_7_145_157), // 'Α' -- 'Ν' - FONTDATA_ITEM(7, 159, 161, fontpage_7_159_161), // 'Ο' -- 'Ρ' - FONTDATA_ITEM(7, 163, 167, fontpage_7_163_167), // 'Σ' -- 'Χ' - FONTDATA_ITEM(7, 172, 175, fontpage_7_172_175), // 'ά' -- 'ί' - FONTDATA_ITEM(7, 177, 181, fontpage_7_177_181), // 'α' -- 'ε' - FONTDATA_ITEM(7, 183, 199, fontpage_7_183_199), // 'η' -- 'χ' - FONTDATA_ITEM(7, 201, 201, fontpage_7_201_201), // 'ω' -- 'ω' - FONTDATA_ITEM(7, 204, 206, fontpage_7_204_206), // 'ό' -- 'ώ' - FONTDATA_ITEM(64, 166, 166, fontpage_64_166_166), // '…' -- '…' +static const uxg_fontinfo_t g_fontinfo_el[] PROGMEM = { + FONTDATA_ITEM(7, 136, 136, fontpage_7_136_136), // 'Έ' -- 'Έ' + FONTDATA_ITEM(7, 145, 157, fontpage_7_145_157), // 'Α' -- 'Ν' + FONTDATA_ITEM(7, 159, 161, fontpage_7_159_161), // 'Ο' -- 'Ρ' + FONTDATA_ITEM(7, 163, 167, fontpage_7_163_167), // 'Σ' -- 'Χ' + FONTDATA_ITEM(7, 172, 175, fontpage_7_172_175), // 'ά' -- 'ί' + FONTDATA_ITEM(7, 177, 181, fontpage_7_177_181), // 'α' -- 'ε' + FONTDATA_ITEM(7, 183, 199, fontpage_7_183_199), // 'η' -- 'χ' + FONTDATA_ITEM(7, 201, 201, fontpage_7_201_201), // 'ω' -- 'ω' + FONTDATA_ITEM(7, 204, 206, fontpage_7_204_206), // 'ό' -- 'ώ' + FONTDATA_ITEM(64, 166, 166, fontpage_64_166_166), // '…' -- '…' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_el_gr.h b/Marlin/src/lcd/dogm/fontdata/langdata_el_gr.h index 4b545f2284..8d7cba8615 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_el_gr.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_el_gr.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_7_136_136[33] U8G_FONT_SECTION("fontpage_7_136_136") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x00,0x0A,0x00,0x00, @@ -75,16 +77,15 @@ const u8g_fntpgm_uint8_t fontpage_64_166_166[24] U8G_FONT_SECTION("fontpage_64_1 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xA6,0xA6,0x00,0x01,0x00,0x00, 0x00,0x05,0x01,0x01,0x06,0x00,0x00,0xA8}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(7, 136, 136, fontpage_7_136_136), // 'Έ' -- 'Έ' - FONTDATA_ITEM(7, 145, 157, fontpage_7_145_157), // 'Α' -- 'Ν' - FONTDATA_ITEM(7, 159, 161, fontpage_7_159_161), // 'Ο' -- 'Ρ' - FONTDATA_ITEM(7, 163, 167, fontpage_7_163_167), // 'Σ' -- 'Χ' - FONTDATA_ITEM(7, 172, 175, fontpage_7_172_175), // 'ά' -- 'ί' - FONTDATA_ITEM(7, 177, 181, fontpage_7_177_181), // 'α' -- 'ε' - FONTDATA_ITEM(7, 183, 199, fontpage_7_183_199), // 'η' -- 'χ' - FONTDATA_ITEM(7, 201, 201, fontpage_7_201_201), // 'ω' -- 'ω' - FONTDATA_ITEM(7, 204, 206, fontpage_7_204_206), // 'ό' -- 'ώ' - FONTDATA_ITEM(64, 166, 166, fontpage_64_166_166), // '…' -- '…' +static const uxg_fontinfo_t g_fontinfo_el_gr[] PROGMEM = { + FONTDATA_ITEM(7, 136, 136, fontpage_7_136_136), // 'Έ' -- 'Έ' + FONTDATA_ITEM(7, 145, 157, fontpage_7_145_157), // 'Α' -- 'Ν' + FONTDATA_ITEM(7, 159, 161, fontpage_7_159_161), // 'Ο' -- 'Ρ' + FONTDATA_ITEM(7, 163, 167, fontpage_7_163_167), // 'Σ' -- 'Χ' + FONTDATA_ITEM(7, 172, 175, fontpage_7_172_175), // 'ά' -- 'ί' + FONTDATA_ITEM(7, 177, 181, fontpage_7_177_181), // 'α' -- 'ε' + FONTDATA_ITEM(7, 183, 199, fontpage_7_183_199), // 'η' -- 'χ' + FONTDATA_ITEM(7, 201, 201, fontpage_7_201_201), // 'ω' -- 'ω' + FONTDATA_ITEM(7, 204, 206, fontpage_7_204_206), // 'ό' -- 'ώ' + FONTDATA_ITEM(64, 166, 166, fontpage_64_166_166), // '…' -- '…' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_en.h b/Marlin/src/lcd/dogm/fontdata/langdata_en.h index ffda82764f..a69161b562 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_en.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_en.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_en[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_es.h b/Marlin/src/lcd/dogm/fontdata/langdata_es.h index ffda82764f..a8ddb44ce8 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_es.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_es.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_es[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_eu.h b/Marlin/src/lcd/dogm/fontdata/langdata_eu.h index ffda82764f..3fdc0253bc 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_eu.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_eu.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_eu[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_fi.h b/Marlin/src/lcd/dogm/fontdata/langdata_fi.h index ffda82764f..25e1927537 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_fi.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_fi.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_fi[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_fr.h b/Marlin/src/lcd/dogm/fontdata/langdata_fr.h index ffda82764f..a3cc160c97 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_fr.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_fr.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_fr[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_gl.h b/Marlin/src/lcd/dogm/fontdata/langdata_gl.h index ffda82764f..2f93d05dbe 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_gl.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_gl.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_gl[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_hr.h b/Marlin/src/lcd/dogm/fontdata/langdata_hr.h index cdb2cc7d1a..b5e4d544cc 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_hr.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_hr.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_2_135_135[31] U8G_FONT_SECTION("fontpage_2_135_135") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x87,0x87,0x00,0x08,0x00,0x00, @@ -22,11 +24,10 @@ const u8g_fntpgm_uint8_t fontpage_2_254_254[31] U8G_FONT_SECTION("fontpage_2_254 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xFE,0xFE,0x00,0x08,0x00,0x00, 0x00,0x05,0x08,0x08,0x06,0x00,0x00,0x50,0x20,0x00,0xF8,0x10,0x20,0x40,0xF8}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(2, 135, 135, fontpage_2_135_135), // 'ć' -- 'ć' - FONTDATA_ITEM(2, 140, 141, fontpage_2_140_141), // 'Č' -- 'č' - FONTDATA_ITEM(2, 145, 145, fontpage_2_145_145), // 'đ' -- 'đ' - FONTDATA_ITEM(2, 225, 225, fontpage_2_225_225), // 'š' -- 'š' - FONTDATA_ITEM(2, 254, 254, fontpage_2_254_254), // 'ž' -- 'ž' +static const uxg_fontinfo_t g_fontinfo_hr[] PROGMEM = { + FONTDATA_ITEM(2, 135, 135, fontpage_2_135_135), // 'ć' -- 'ć' + FONTDATA_ITEM(2, 140, 141, fontpage_2_140_141), // 'Č' -- 'č' + FONTDATA_ITEM(2, 145, 145, fontpage_2_145_145), // 'đ' -- 'đ' + FONTDATA_ITEM(2, 225, 225, fontpage_2_225_225), // 'š' -- 'š' + FONTDATA_ITEM(2, 254, 254, fontpage_2_254_254), // 'ž' -- 'ž' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_hu.h b/Marlin/src/lcd/dogm/fontdata/langdata_hu.h index 8c15a3890a..450662a8c9 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_hu.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_hu.h @@ -3,13 +3,14 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_2_241_241[31] U8G_FONT_SECTION("fontpage_2_241_241") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xF1,0xF1,0x00,0x08,0x00,0x00, 0x00,0x05,0x08,0x08,0x06,0x00,0x00,0x48,0x90,0x00,0x88,0x88,0x88,0x88,0x70}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(2, 241, 241, fontpage_2_241_241), // 'ű' -- 'ű' +static const uxg_fontinfo_t g_fontinfo_hu[] PROGMEM = { + FONTDATA_ITEM(2, 241, 241, fontpage_2_241_241), // 'ű' -- 'ű' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_it.h b/Marlin/src/lcd/dogm/fontdata/langdata_it.h index ffda82764f..1a41a794fa 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_it.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_it.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_it[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_jp_kana.h b/Marlin/src/lcd/dogm/fontdata/langdata_jp_kana.h index 01316d4c13..dc483b7d2b 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_jp_kana.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_jp_kana.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_97_161_164[65] U8G_FONT_SECTION("fontpage_97_161_164") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xA1,0xA4,0x00,0x07,0x00,0x00, @@ -94,18 +96,17 @@ const u8g_fntpgm_uint8_t fontpage_97_252_252[25] U8G_FONT_SECTION("fontpage_97_2 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0x00,0x05,0x00,0x00, 0x00,0x05,0x02,0x02,0x06,0x00,0x03,0x80,0x78}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(97, 161, 164, fontpage_97_161_164), // 'ァ' -- 'イ' - FONTDATA_ITEM(97, 166, 166, fontpage_97_166_166), // 'ウ' -- 'ウ' - FONTDATA_ITEM(97, 168, 168, fontpage_97_168_168), // 'エ' -- 'エ' - FONTDATA_ITEM(97, 170, 187, fontpage_97_170_187), // 'オ' -- 'セ' - FONTDATA_ITEM(97, 189, 193, fontpage_97_189_193), // 'ソ' -- 'チ' - FONTDATA_ITEM(97, 195, 211, fontpage_97_195_211), // 'ッ' -- 'ビ' - FONTDATA_ITEM(97, 213, 217, fontpage_97_213_217), // 'フ' -- 'ベ' - FONTDATA_ITEM(97, 219, 220, fontpage_97_219_220), // 'ホ' -- 'ボ' - FONTDATA_ITEM(97, 222, 223, fontpage_97_222_223), // 'マ' -- 'ミ' - FONTDATA_ITEM(97, 225, 237, fontpage_97_225_237), // 'メ' -- 'ロ' - FONTDATA_ITEM(97, 242, 243, fontpage_97_242_243), // 'ヲ' -- 'ン' - FONTDATA_ITEM(97, 252, 252, fontpage_97_252_252), // 'ー' -- 'ー' +static const uxg_fontinfo_t g_fontinfo_jp_kana[] PROGMEM = { + FONTDATA_ITEM(97, 161, 164, fontpage_97_161_164), // 'ァ' -- 'イ' + FONTDATA_ITEM(97, 166, 166, fontpage_97_166_166), // 'ウ' -- 'ウ' + FONTDATA_ITEM(97, 168, 168, fontpage_97_168_168), // 'エ' -- 'エ' + FONTDATA_ITEM(97, 170, 187, fontpage_97_170_187), // 'オ' -- 'セ' + FONTDATA_ITEM(97, 189, 193, fontpage_97_189_193), // 'ソ' -- 'チ' + FONTDATA_ITEM(97, 195, 211, fontpage_97_195_211), // 'ッ' -- 'ビ' + FONTDATA_ITEM(97, 213, 217, fontpage_97_213_217), // 'フ' -- 'ベ' + FONTDATA_ITEM(97, 219, 220, fontpage_97_219_220), // 'ホ' -- 'ボ' + FONTDATA_ITEM(97, 222, 223, fontpage_97_222_223), // 'マ' -- 'ミ' + FONTDATA_ITEM(97, 225, 237, fontpage_97_225_237), // 'メ' -- 'ロ' + FONTDATA_ITEM(97, 242, 243, fontpage_97_242_243), // 'ヲ' -- 'ン' + FONTDATA_ITEM(97, 252, 252, fontpage_97_252_252), // 'ー' -- 'ー' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_ko_KR.h b/Marlin/src/lcd/dogm/fontdata/langdata_ko_KR.h index 6b48434a6f..31cc0bca36 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_ko_KR.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_ko_KR.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_344_240_240[34] U8G_FONT_SECTION("fontpage_344_240_240") = { 0x00,0x0B,0x0D,0x00,0xFD,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0x00,0x09,0xFE,0x00, @@ -436,112 +438,111 @@ const u8g_fntpgm_uint8_t fontpage_431_136_136[34] U8G_FONT_SECTION("fontpage_431 0x00,0x08,0x0B,0x0B,0x0A,0x01,0xFE,0x71,0x01,0xFD,0x01,0x71,0x49,0x89,0x49,0x71, 0x01,0x01}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(344, 240, 240, fontpage_344_240_240), // '거' -- '거' - FONTDATA_ITEM(345, 224, 224, fontpage_345_224_224), // '고' -- '고' - FONTDATA_ITEM(347, 248, 248, fontpage_347_248_248), // '그' -- '그' - FONTDATA_ITEM(348, 137, 137, fontpage_348_137_137), // '급' -- '급' - FONTDATA_ITEM(348, 176, 176, fontpage_348_176_176), // '기' -- '기' - FONTDATA_ITEM(348, 197, 197, fontpage_348_197_197), // '깅' -- '깅' - FONTDATA_ITEM(352, 196, 196, fontpage_352_196_196), // '끄' -- '끄' - FONTDATA_ITEM(353, 180, 180, fontpage_353_180_180), // '내' -- '내' - FONTDATA_ITEM(354, 248, 248, fontpage_354_248_248), // '노' -- '노' - FONTDATA_ITEM(356, 132, 132, fontpage_356_132_132), // '누' -- '누' - FONTDATA_ITEM(356, 244, 244, fontpage_356_244_244), // '뉴' -- '뉴' - FONTDATA_ITEM(357, 200, 200, fontpage_357_200_200), // '니' -- '니' - FONTDATA_ITEM(357, 228, 228, fontpage_357_228_228), // '다' -- '다' - FONTDATA_ITEM(357, 249, 249, fontpage_357_249_249), // '당' -- '당' - FONTDATA_ITEM(359, 196, 196, fontpage_359_196_196), // '도' -- '도' - FONTDATA_ITEM(359, 204, 204, fontpage_359_204_204), // '돌' -- '돌' - FONTDATA_ITEM(359, 217, 217, fontpage_359_217_217), // '동' -- '동' - FONTDATA_ITEM(360, 152, 152, fontpage_360_152_152), // '되' -- '되' - FONTDATA_ITEM(360, 156, 156, fontpage_360_156_156), // '된' -- '된' - FONTDATA_ITEM(360, 168, 168, fontpage_360_168_168), // '됨' -- '됨' - FONTDATA_ITEM(361, 164, 164, fontpage_361_164_164), // '뒤' -- '뒤' - FONTDATA_ITEM(361, 220, 220, fontpage_361_220_220), // '드' -- '드' - FONTDATA_ITEM(362, 148, 148, fontpage_362_148_148), // '디' -- '디' - FONTDATA_ITEM(366, 252, 252, fontpage_366_252_252), // '라' -- '라' - FONTDATA_ITEM(367, 236, 236, fontpage_367_236_236), // '러' -- '러' - FONTDATA_ITEM(368, 136, 136, fontpage_368_136_136), // '레' -- '레' - FONTDATA_ITEM(368, 165, 165, fontpage_368_165_165), // '력' -- '력' - FONTDATA_ITEM(368, 220, 220, fontpage_368_220_220), // '로' -- '로' - FONTDATA_ITEM(369, 204, 204, fontpage_369_204_204), // '료' -- '료' - FONTDATA_ITEM(370, 244, 244, fontpage_370_244_244), // '르' -- '르' - FONTDATA_ITEM(371, 172, 172, fontpage_371_172_172), // '리' -- '리' - FONTDATA_ITEM(371, 176, 176, fontpage_371_176_176), // '린' -- '린' - FONTDATA_ITEM(371, 189, 189, fontpage_371_189_189), // '립' -- '립' - FONTDATA_ITEM(371, 193, 193, fontpage_371_193_193), // '링' -- '링' - FONTDATA_ITEM(372, 200, 200, fontpage_372_200_200), // '멈' -- '멈' - FONTDATA_ITEM(372, 212, 212, fontpage_372_212_212), // '메' -- '메' - FONTDATA_ITEM(372, 244, 244, fontpage_372_244_244), // '면' -- '면' - FONTDATA_ITEM(373, 168, 168, fontpage_373_168_168), // '모' -- '모' - FONTDATA_ITEM(373, 187, 187, fontpage_373_187_187), // '못' -- '못' - FONTDATA_ITEM(375, 248, 248, fontpage_375_248_248), // '미' -- '미' - FONTDATA_ITEM(376, 128, 128, fontpage_376_128_128), // '밀' -- '밀' - FONTDATA_ITEM(376, 148, 148, fontpage_376_148_148), // '바' -- '바' - FONTDATA_ITEM(377, 132, 132, fontpage_377_132_132), // '버' -- '버' - FONTDATA_ITEM(377, 160, 160, fontpage_377_160_160), // '베' -- '베' - FONTDATA_ITEM(377, 168, 168, fontpage_377_168_168), // '벨' -- '벨' - FONTDATA_ITEM(377, 248, 248, fontpage_377_248_248), // '본' -- '본' - FONTDATA_ITEM(380, 196, 196, fontpage_380_196_196), // '비' -- '비' - FONTDATA_ITEM(385, 172, 172, fontpage_385_172_172), // '사' -- '사' - FONTDATA_ITEM(385, 189, 189, fontpage_385_189_189), // '삽' -- '삽' - FONTDATA_ITEM(385, 200, 200, fontpage_385_200_200), // '새' -- '새' - FONTDATA_ITEM(386, 164, 164, fontpage_386_164_164), // '설' -- '설' - FONTDATA_ITEM(387, 140, 141, fontpage_387_140_141), // '소' -- '속' - FONTDATA_ITEM(389, 164, 164, fontpage_389_164_164), // '스' -- '스' - FONTDATA_ITEM(389, 172, 172, fontpage_389_172_172), // '슬' -- '슬' - FONTDATA_ITEM(389, 220, 221, fontpage_389_220_221), // '시' -- '식' - FONTDATA_ITEM(395, 180, 180, fontpage_395_180_180), // '어' -- '어' - FONTDATA_ITEM(395, 198, 198, fontpage_395_198_198), // '없' -- '없' - FONTDATA_ITEM(395, 209, 209, fontpage_395_209_209), // '엑' -- '엑' - FONTDATA_ITEM(395, 212, 212, fontpage_395_212_212), // '엔' -- '엔' - FONTDATA_ITEM(395, 244, 244, fontpage_395_244_244), // '열' -- '열' - FONTDATA_ITEM(396, 136, 136, fontpage_396_136_136), // '예' -- '예' - FONTDATA_ITEM(396, 164, 164, fontpage_396_164_164), // '오' -- '오' - FONTDATA_ITEM(396, 168, 168, fontpage_396_168_168), // '온' -- '온' - FONTDATA_ITEM(396, 196, 196, fontpage_396_196_196), // '완' -- '완' - FONTDATA_ITEM(397, 208, 208, fontpage_397_208_208), // '원' -- '원' - FONTDATA_ITEM(398, 132, 132, fontpage_398_132_132), // '위' -- '위' - FONTDATA_ITEM(398, 188, 188, fontpage_398_188_188), // '으' -- '으' - FONTDATA_ITEM(398, 204, 204, fontpage_398_204_204), // '음' -- '음' - FONTDATA_ITEM(398, 244, 244, fontpage_398_244_244), // '이' -- '이' - FONTDATA_ITEM(398, 252, 253, fontpage_398_252_253), // '일' -- '읽' - FONTDATA_ITEM(399, 133, 133, fontpage_399_133_133), // '입' -- '입' - FONTDATA_ITEM(399, 144, 145, fontpage_399_144_145), // '자' -- '작' - FONTDATA_ITEM(399, 152, 152, fontpage_399_152_152), // '잘' -- '잘' - FONTDATA_ITEM(399, 165, 165, fontpage_399_165_165), // '장' -- '장' - FONTDATA_ITEM(399, 172, 172, fontpage_399_172_172), // '재' -- '재' - FONTDATA_ITEM(400, 128, 128, fontpage_400_128_128), // '저' -- '저' - FONTDATA_ITEM(400, 132, 132, fontpage_400_132_132), // '전' -- '전' - FONTDATA_ITEM(400, 149, 149, fontpage_400_149_149), // '정' -- '정' - FONTDATA_ITEM(400, 156, 156, fontpage_400_156_156), // '제' -- '제' - FONTDATA_ITEM(401, 253, 253, fontpage_401_253_253), // '죽' -- '죽' - FONTDATA_ITEM(402, 128, 128, fontpage_402_128_128), // '준' -- '준' - FONTDATA_ITEM(402, 145, 145, fontpage_402_145_145), // '중' -- '중' - FONTDATA_ITEM(403, 144, 144, fontpage_403_144_144), // '즐' -- '즐' - FONTDATA_ITEM(403, 192, 192, fontpage_403_192_192), // '지' -- '지' - FONTDATA_ITEM(409, 152, 152, fontpage_409_152_152), // '처' -- '처' - FONTDATA_ITEM(410, 136, 136, fontpage_410_136_136), // '초' -- '초' - FONTDATA_ITEM(411, 149, 149, fontpage_411_149_149), // '축' -- '축' - FONTDATA_ITEM(411, 156, 156, fontpage_411_156_156), // '출' -- '출' - FONTDATA_ITEM(411, 164, 164, fontpage_411_164_164), // '춤' -- '춤' - FONTDATA_ITEM(411, 232, 232, fontpage_411_232_232), // '취' -- '취' - FONTDATA_ITEM(412, 216, 216, fontpage_412_216_216), // '치' -- '치' - FONTDATA_ITEM(412, 232, 232, fontpage_412_232_232), // '침' -- '침' - FONTDATA_ITEM(412, 244, 244, fontpage_412_244_244), // '카' -- '카' - FONTDATA_ITEM(414, 156, 156, fontpage_414_156_156), // '켜' -- '켜' - FONTDATA_ITEM(417, 209, 209, fontpage_417_209_209), // '탑' -- '탑' - FONTDATA_ITEM(418, 176, 176, fontpage_418_176_176), // '터' -- '터' - FONTDATA_ITEM(418, 204, 204, fontpage_418_204_204), // '테' -- '테' - FONTDATA_ITEM(419, 160, 160, fontpage_419_160_160), // '토' -- '토' - FONTDATA_ITEM(421, 184, 184, fontpage_421_184_184), // '트' -- '트' - FONTDATA_ITEM(423, 156, 156, fontpage_423_156_156), // '펜' -- '펜' - FONTDATA_ITEM(426, 132, 132, fontpage_426_132_132), // '프' -- '프' - FONTDATA_ITEM(426, 216, 216, fontpage_426_216_216), // '하' -- '하' - FONTDATA_ITEM(426, 233, 233, fontpage_426_233_233), // '합' -- '합' - FONTDATA_ITEM(428, 200, 200, fontpage_428_200_200), // '홈' -- '홈' - FONTDATA_ITEM(428, 212, 212, fontpage_428_212_212), // '화' -- '화' - FONTDATA_ITEM(431, 136, 136, fontpage_431_136_136), // '히' -- '히' +static const uxg_fontinfo_t g_fontinfo_ko_KR[] PROGMEM = { + FONTDATA_ITEM(344, 240, 240, fontpage_344_240_240), // '거' -- '거' + FONTDATA_ITEM(345, 224, 224, fontpage_345_224_224), // '고' -- '고' + FONTDATA_ITEM(347, 248, 248, fontpage_347_248_248), // '그' -- '그' + FONTDATA_ITEM(348, 137, 137, fontpage_348_137_137), // '급' -- '급' + FONTDATA_ITEM(348, 176, 176, fontpage_348_176_176), // '기' -- '기' + FONTDATA_ITEM(348, 197, 197, fontpage_348_197_197), // '깅' -- '깅' + FONTDATA_ITEM(352, 196, 196, fontpage_352_196_196), // '끄' -- '끄' + FONTDATA_ITEM(353, 180, 180, fontpage_353_180_180), // '내' -- '내' + FONTDATA_ITEM(354, 248, 248, fontpage_354_248_248), // '노' -- '노' + FONTDATA_ITEM(356, 132, 132, fontpage_356_132_132), // '누' -- '누' + FONTDATA_ITEM(356, 244, 244, fontpage_356_244_244), // '뉴' -- '뉴' + FONTDATA_ITEM(357, 200, 200, fontpage_357_200_200), // '니' -- '니' + FONTDATA_ITEM(357, 228, 228, fontpage_357_228_228), // '다' -- '다' + FONTDATA_ITEM(357, 249, 249, fontpage_357_249_249), // '당' -- '당' + FONTDATA_ITEM(359, 196, 196, fontpage_359_196_196), // '도' -- '도' + FONTDATA_ITEM(359, 204, 204, fontpage_359_204_204), // '돌' -- '돌' + FONTDATA_ITEM(359, 217, 217, fontpage_359_217_217), // '동' -- '동' + FONTDATA_ITEM(360, 152, 152, fontpage_360_152_152), // '되' -- '되' + FONTDATA_ITEM(360, 156, 156, fontpage_360_156_156), // '된' -- '된' + FONTDATA_ITEM(360, 168, 168, fontpage_360_168_168), // '됨' -- '됨' + FONTDATA_ITEM(361, 164, 164, fontpage_361_164_164), // '뒤' -- '뒤' + FONTDATA_ITEM(361, 220, 220, fontpage_361_220_220), // '드' -- '드' + FONTDATA_ITEM(362, 148, 148, fontpage_362_148_148), // '디' -- '디' + FONTDATA_ITEM(366, 252, 252, fontpage_366_252_252), // '라' -- '라' + FONTDATA_ITEM(367, 236, 236, fontpage_367_236_236), // '러' -- '러' + FONTDATA_ITEM(368, 136, 136, fontpage_368_136_136), // '레' -- '레' + FONTDATA_ITEM(368, 165, 165, fontpage_368_165_165), // '력' -- '력' + FONTDATA_ITEM(368, 220, 220, fontpage_368_220_220), // '로' -- '로' + FONTDATA_ITEM(369, 204, 204, fontpage_369_204_204), // '료' -- '료' + FONTDATA_ITEM(370, 244, 244, fontpage_370_244_244), // '르' -- '르' + FONTDATA_ITEM(371, 172, 172, fontpage_371_172_172), // '리' -- '리' + FONTDATA_ITEM(371, 176, 176, fontpage_371_176_176), // '린' -- '린' + FONTDATA_ITEM(371, 189, 189, fontpage_371_189_189), // '립' -- '립' + FONTDATA_ITEM(371, 193, 193, fontpage_371_193_193), // '링' -- '링' + FONTDATA_ITEM(372, 200, 200, fontpage_372_200_200), // '멈' -- '멈' + FONTDATA_ITEM(372, 212, 212, fontpage_372_212_212), // '메' -- '메' + FONTDATA_ITEM(372, 244, 244, fontpage_372_244_244), // '면' -- '면' + FONTDATA_ITEM(373, 168, 168, fontpage_373_168_168), // '모' -- '모' + FONTDATA_ITEM(373, 187, 187, fontpage_373_187_187), // '못' -- '못' + FONTDATA_ITEM(375, 248, 248, fontpage_375_248_248), // '미' -- '미' + FONTDATA_ITEM(376, 128, 128, fontpage_376_128_128), // '밀' -- '밀' + FONTDATA_ITEM(376, 148, 148, fontpage_376_148_148), // '바' -- '바' + FONTDATA_ITEM(377, 132, 132, fontpage_377_132_132), // '버' -- '버' + FONTDATA_ITEM(377, 160, 160, fontpage_377_160_160), // '베' -- '베' + FONTDATA_ITEM(377, 168, 168, fontpage_377_168_168), // '벨' -- '벨' + FONTDATA_ITEM(377, 248, 248, fontpage_377_248_248), // '본' -- '본' + FONTDATA_ITEM(380, 196, 196, fontpage_380_196_196), // '비' -- '비' + FONTDATA_ITEM(385, 172, 172, fontpage_385_172_172), // '사' -- '사' + FONTDATA_ITEM(385, 189, 189, fontpage_385_189_189), // '삽' -- '삽' + FONTDATA_ITEM(385, 200, 200, fontpage_385_200_200), // '새' -- '새' + FONTDATA_ITEM(386, 164, 164, fontpage_386_164_164), // '설' -- '설' + FONTDATA_ITEM(387, 140, 141, fontpage_387_140_141), // '소' -- '속' + FONTDATA_ITEM(389, 164, 164, fontpage_389_164_164), // '스' -- '스' + FONTDATA_ITEM(389, 172, 172, fontpage_389_172_172), // '슬' -- '슬' + FONTDATA_ITEM(389, 220, 221, fontpage_389_220_221), // '시' -- '식' + FONTDATA_ITEM(395, 180, 180, fontpage_395_180_180), // '어' -- '어' + FONTDATA_ITEM(395, 198, 198, fontpage_395_198_198), // '없' -- '없' + FONTDATA_ITEM(395, 209, 209, fontpage_395_209_209), // '엑' -- '엑' + FONTDATA_ITEM(395, 212, 212, fontpage_395_212_212), // '엔' -- '엔' + FONTDATA_ITEM(395, 244, 244, fontpage_395_244_244), // '열' -- '열' + FONTDATA_ITEM(396, 136, 136, fontpage_396_136_136), // '예' -- '예' + FONTDATA_ITEM(396, 164, 164, fontpage_396_164_164), // '오' -- '오' + FONTDATA_ITEM(396, 168, 168, fontpage_396_168_168), // '온' -- '온' + FONTDATA_ITEM(396, 196, 196, fontpage_396_196_196), // '완' -- '완' + FONTDATA_ITEM(397, 208, 208, fontpage_397_208_208), // '원' -- '원' + FONTDATA_ITEM(398, 132, 132, fontpage_398_132_132), // '위' -- '위' + FONTDATA_ITEM(398, 188, 188, fontpage_398_188_188), // '으' -- '으' + FONTDATA_ITEM(398, 204, 204, fontpage_398_204_204), // '음' -- '음' + FONTDATA_ITEM(398, 244, 244, fontpage_398_244_244), // '이' -- '이' + FONTDATA_ITEM(398, 252, 253, fontpage_398_252_253), // '일' -- '읽' + FONTDATA_ITEM(399, 133, 133, fontpage_399_133_133), // '입' -- '입' + FONTDATA_ITEM(399, 144, 145, fontpage_399_144_145), // '자' -- '작' + FONTDATA_ITEM(399, 152, 152, fontpage_399_152_152), // '잘' -- '잘' + FONTDATA_ITEM(399, 165, 165, fontpage_399_165_165), // '장' -- '장' + FONTDATA_ITEM(399, 172, 172, fontpage_399_172_172), // '재' -- '재' + FONTDATA_ITEM(400, 128, 128, fontpage_400_128_128), // '저' -- '저' + FONTDATA_ITEM(400, 132, 132, fontpage_400_132_132), // '전' -- '전' + FONTDATA_ITEM(400, 149, 149, fontpage_400_149_149), // '정' -- '정' + FONTDATA_ITEM(400, 156, 156, fontpage_400_156_156), // '제' -- '제' + FONTDATA_ITEM(401, 253, 253, fontpage_401_253_253), // '죽' -- '죽' + FONTDATA_ITEM(402, 128, 128, fontpage_402_128_128), // '준' -- '준' + FONTDATA_ITEM(402, 145, 145, fontpage_402_145_145), // '중' -- '중' + FONTDATA_ITEM(403, 144, 144, fontpage_403_144_144), // '즐' -- '즐' + FONTDATA_ITEM(403, 192, 192, fontpage_403_192_192), // '지' -- '지' + FONTDATA_ITEM(409, 152, 152, fontpage_409_152_152), // '처' -- '처' + FONTDATA_ITEM(410, 136, 136, fontpage_410_136_136), // '초' -- '초' + FONTDATA_ITEM(411, 149, 149, fontpage_411_149_149), // '축' -- '축' + FONTDATA_ITEM(411, 156, 156, fontpage_411_156_156), // '출' -- '출' + FONTDATA_ITEM(411, 164, 164, fontpage_411_164_164), // '춤' -- '춤' + FONTDATA_ITEM(411, 232, 232, fontpage_411_232_232), // '취' -- '취' + FONTDATA_ITEM(412, 216, 216, fontpage_412_216_216), // '치' -- '치' + FONTDATA_ITEM(412, 232, 232, fontpage_412_232_232), // '침' -- '침' + FONTDATA_ITEM(412, 244, 244, fontpage_412_244_244), // '카' -- '카' + FONTDATA_ITEM(414, 156, 156, fontpage_414_156_156), // '켜' -- '켜' + FONTDATA_ITEM(417, 209, 209, fontpage_417_209_209), // '탑' -- '탑' + FONTDATA_ITEM(418, 176, 176, fontpage_418_176_176), // '터' -- '터' + FONTDATA_ITEM(418, 204, 204, fontpage_418_204_204), // '테' -- '테' + FONTDATA_ITEM(419, 160, 160, fontpage_419_160_160), // '토' -- '토' + FONTDATA_ITEM(421, 184, 184, fontpage_421_184_184), // '트' -- '트' + FONTDATA_ITEM(423, 156, 156, fontpage_423_156_156), // '펜' -- '펜' + FONTDATA_ITEM(426, 132, 132, fontpage_426_132_132), // '프' -- '프' + FONTDATA_ITEM(426, 216, 216, fontpage_426_216_216), // '하' -- '하' + FONTDATA_ITEM(426, 233, 233, fontpage_426_233_233), // '합' -- '합' + FONTDATA_ITEM(428, 200, 200, fontpage_428_200_200), // '홈' -- '홈' + FONTDATA_ITEM(428, 212, 212, fontpage_428_212_212), // '화' -- '화' + FONTDATA_ITEM(431, 136, 136, fontpage_431_136_136), // '히' -- '히' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_nl.h b/Marlin/src/lcd/dogm/fontdata/langdata_nl.h index ffda82764f..e76eff3348 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_nl.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_nl.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_nl[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_pl.h b/Marlin/src/lcd/dogm/fontdata/langdata_pl.h index 926f075295..e89a6c159a 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_pl.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_pl.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_2_132_133[45] U8G_FONT_SECTION("fontpage_2_132_133") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x84,0x85,0x00,0x07,0xFE,0x00, @@ -29,12 +31,11 @@ const u8g_fntpgm_uint8_t fontpage_2_252_252[30] U8G_FONT_SECTION("fontpage_2_252 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0x00,0x07,0x00,0x00, 0x00,0x05,0x07,0x07,0x06,0x00,0x00,0x20,0x00,0xF8,0x10,0x20,0x40,0xF8}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(2, 132, 133, fontpage_2_132_133), // 'Ą' -- 'ą' - FONTDATA_ITEM(2, 135, 135, fontpage_2_135_135), // 'ć' -- 'ć' - FONTDATA_ITEM(2, 153, 153, fontpage_2_153_153), // 'ę' -- 'ę' - FONTDATA_ITEM(2, 193, 196, fontpage_2_193_196), // 'Ł' -- 'ń' - FONTDATA_ITEM(2, 218, 219, fontpage_2_218_219), // 'Ś' -- 'ś' - FONTDATA_ITEM(2, 252, 252, fontpage_2_252_252), // 'ż' -- 'ż' +static const uxg_fontinfo_t g_fontinfo_pl[] PROGMEM = { + FONTDATA_ITEM(2, 132, 133, fontpage_2_132_133), // 'Ą' -- 'ą' + FONTDATA_ITEM(2, 135, 135, fontpage_2_135_135), // 'ć' -- 'ć' + FONTDATA_ITEM(2, 153, 153, fontpage_2_153_153), // 'ę' -- 'ę' + FONTDATA_ITEM(2, 193, 196, fontpage_2_193_196), // 'Ł' -- 'ń' + FONTDATA_ITEM(2, 218, 219, fontpage_2_218_219), // 'Ś' -- 'ś' + FONTDATA_ITEM(2, 252, 252, fontpage_2_252_252), // 'ż' -- 'ż' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_pt.h b/Marlin/src/lcd/dogm/fontdata/langdata_pt.h index ffda82764f..61f857e587 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_pt.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_pt.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_pt[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_pt_br.h b/Marlin/src/lcd/dogm/fontdata/langdata_pt_br.h index ffda82764f..b0ed5ad5cf 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_pt_br.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_pt_br.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_pt_br[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_ro.h b/Marlin/src/lcd/dogm/fontdata/langdata_ro.h index ffda82764f..6be4863553 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_ro.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_ro.h @@ -3,7 +3,8 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {}; +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_ro[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_ru.h b/Marlin/src/lcd/dogm/fontdata/langdata_ru.h index 4edd6e74e3..3f857a1b3f 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_ru.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_ru.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_8_144_168[348] U8G_FONT_SECTION("fontpage_8_144_168") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x90,0xA8,0x00,0x0A,0xFE,0x00, @@ -64,10 +66,9 @@ const u8g_fntpgm_uint8_t fontpage_8_209_209[30] U8G_FONT_SECTION("fontpage_8_209 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xD1,0xD1,0x00,0x07,0x00,0x00, 0x00,0x05,0x07,0x07,0x06,0x00,0x00,0x50,0x00,0x70,0x88,0xF0,0x80,0x70}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(8, 144, 168, fontpage_8_144_168), // 'А' -- 'Ш' - FONTDATA_ITEM(8, 171, 173, fontpage_8_171_173), // 'Ы' -- 'Э' - FONTDATA_ITEM(8, 175, 207, fontpage_8_175_207), // 'Я' -- 'я' - FONTDATA_ITEM(8, 209, 209, fontpage_8_209_209), // 'ё' -- 'ё' +static const uxg_fontinfo_t g_fontinfo_ru[] PROGMEM = { + FONTDATA_ITEM(8, 144, 168, fontpage_8_144_168), // 'А' -- 'Ш' + FONTDATA_ITEM(8, 171, 173, fontpage_8_171_173), // 'Ы' -- 'Э' + FONTDATA_ITEM(8, 175, 207, fontpage_8_175_207), // 'Я' -- 'я' + FONTDATA_ITEM(8, 209, 209, fontpage_8_209_209), // 'ё' -- 'ё' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_sk.h b/Marlin/src/lcd/dogm/fontdata/langdata_sk.h index 491006e05a..4580ce5b7b 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_sk.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_sk.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_2_140_143[79] U8G_FONT_SECTION("fontpage_2_140_143") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x8C,0x8F,0x00,0x0A,0x00,0x00, @@ -37,13 +39,12 @@ const u8g_fntpgm_uint8_t fontpage_2_253_254[47] U8G_FONT_SECTION("fontpage_2_253 0x00,0x05,0x0A,0x0A,0x06,0x00,0x00,0x50,0x20,0x00,0xF8,0x08,0x10,0x20,0x40,0x80, 0xF8,0x05,0x08,0x08,0x06,0x00,0x00,0x50,0x20,0x00,0xF8,0x10,0x20,0x40,0xF8}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(2, 140, 143, fontpage_2_140_143), // 'Č' -- 'ď' - FONTDATA_ITEM(2, 186, 186, fontpage_2_186_186), // 'ĺ' -- 'ĺ' - FONTDATA_ITEM(2, 189, 190, fontpage_2_189_190), // 'Ľ' -- 'ľ' - FONTDATA_ITEM(2, 199, 200, fontpage_2_199_200), // 'Ň' -- 'ň' - FONTDATA_ITEM(2, 224, 225, fontpage_2_224_225), // 'Š' -- 'š' - FONTDATA_ITEM(2, 229, 229, fontpage_2_229_229), // 'ť' -- 'ť' - FONTDATA_ITEM(2, 253, 254, fontpage_2_253_254), // 'Ž' -- 'ž' +static const uxg_fontinfo_t g_fontinfo_sk[] PROGMEM = { + FONTDATA_ITEM(2, 140, 143, fontpage_2_140_143), // 'Č' -- 'ď' + FONTDATA_ITEM(2, 186, 186, fontpage_2_186_186), // 'ĺ' -- 'ĺ' + FONTDATA_ITEM(2, 189, 190, fontpage_2_189_190), // 'Ľ' -- 'ľ' + FONTDATA_ITEM(2, 199, 200, fontpage_2_199_200), // 'Ň' -- 'ň' + FONTDATA_ITEM(2, 224, 225, fontpage_2_224_225), // 'Š' -- 'š' + FONTDATA_ITEM(2, 229, 229, fontpage_2_229_229), // 'ť' -- 'ť' + FONTDATA_ITEM(2, 253, 254, fontpage_2_253_254), // 'Ž' -- 'ž' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_test.h b/Marlin/src/lcd/dogm/fontdata/langdata_test.h index c397d8b4b9..da76a31041 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_test.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_test.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_8_128_255[1677] U8G_FONT_SECTION("fontpage_8_128_255") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x00,0x0A,0xFE,0x00, @@ -223,9 +225,8 @@ const u8g_fntpgm_uint8_t fontpage_97_193_255[822] U8G_FONT_SECTION("fontpage_97_ 0x06,0x00,0x02,0x28,0x28,0x00,0x80,0x60,0x10,0x08,0x05,0x06,0x06,0x06,0x00,0x00, 0xF8,0x08,0x08,0x08,0x08,0x08}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(8, 128, 255, fontpage_8_128_255), // 'Ѐ' -- 'ѿ' - FONTDATA_ITEM(97, 129, 191, fontpage_97_129_191), // 'め' -- 'タ' - FONTDATA_ITEM(97, 193, 255, fontpage_97_193_255), // 'チ' -- 'ヿ' +static const uxg_fontinfo_t g_fontinfo_test[] PROGMEM = { + FONTDATA_ITEM(8, 128, 255, fontpage_8_128_255), // 'Ѐ' -- 'ѿ' + FONTDATA_ITEM(97, 129, 191, fontpage_97_129_191), // 'め' -- 'タ' + FONTDATA_ITEM(97, 193, 255, fontpage_97_193_255), // 'チ' -- 'ヿ' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_tr.h b/Marlin/src/lcd/dogm/fontdata/langdata_tr.h index a4068e10d0..0ac02435a5 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_tr.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_tr.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_2_158_159[49] U8G_FONT_SECTION("fontpage_2_158_159") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x9E,0x9F,0x00,0x0A,0xFE,0x00, @@ -19,9 +21,8 @@ const u8g_fntpgm_uint8_t fontpage_2_222_223[45] U8G_FONT_SECTION("fontpage_2_222 0x00,0x05,0x09,0x09,0x06,0x00,0xFE,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x10,0x60, 0x05,0x07,0x07,0x06,0x00,0xFE,0x78,0x80,0x70,0x08,0xF0,0x10,0x60}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(2, 158, 159, fontpage_2_158_159), // 'Ğ' -- 'ğ' - FONTDATA_ITEM(2, 176, 177, fontpage_2_176_177), // 'İ' -- 'ı' - FONTDATA_ITEM(2, 222, 223, fontpage_2_222_223), // 'Ş' -- 'ş' +static const uxg_fontinfo_t g_fontinfo_tr[] PROGMEM = { + FONTDATA_ITEM(2, 158, 159, fontpage_2_158_159), // 'Ğ' -- 'ğ' + FONTDATA_ITEM(2, 176, 177, fontpage_2_176_177), // 'İ' -- 'ı' + FONTDATA_ITEM(2, 222, 223, fontpage_2_222_223), // 'Ş' -- 'ş' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_uk.h b/Marlin/src/lcd/dogm/fontdata/langdata_uk.h index 47ec93992f..b25e2f6db4 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_uk.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_uk.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_8_134_134[30] U8G_FONT_SECTION("fontpage_8_134_134") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x86,0x86,0x00,0x07,0x00,0x00, @@ -72,14 +74,13 @@ const u8g_fntpgm_uint8_t fontpage_8_214_215[41] U8G_FONT_SECTION("fontpage_8_214 0x00,0x03,0x06,0x06,0x06,0x01,0x00,0x40,0x00,0xC0,0x40,0x40,0xE0,0x03,0x06,0x06, 0x06,0x01,0x00,0xA0,0x00,0xC0,0x40,0x40,0xE0}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(8, 134, 134, fontpage_8_134_134), // 'І' -- 'І' - FONTDATA_ITEM(8, 144, 169, fontpage_8_144_169), // 'А' -- 'Щ' - FONTDATA_ITEM(8, 172, 172, fontpage_8_172_172), // 'Ь' -- 'Ь' - FONTDATA_ITEM(8, 175, 201, fontpage_8_175_201), // 'Я' -- 'щ' - FONTDATA_ITEM(8, 204, 204, fontpage_8_204_204), // 'ь' -- 'ь' - FONTDATA_ITEM(8, 206, 207, fontpage_8_206_207), // 'ю' -- 'я' - FONTDATA_ITEM(8, 212, 212, fontpage_8_212_212), // 'є' -- 'є' - FONTDATA_ITEM(8, 214, 215, fontpage_8_214_215), // 'і' -- 'ї' +static const uxg_fontinfo_t g_fontinfo_uk[] PROGMEM = { + FONTDATA_ITEM(8, 134, 134, fontpage_8_134_134), // 'І' -- 'І' + FONTDATA_ITEM(8, 144, 169, fontpage_8_144_169), // 'А' -- 'Щ' + FONTDATA_ITEM(8, 172, 172, fontpage_8_172_172), // 'Ь' -- 'Ь' + FONTDATA_ITEM(8, 175, 201, fontpage_8_175_201), // 'Я' -- 'щ' + FONTDATA_ITEM(8, 204, 204, fontpage_8_204_204), // 'ь' -- 'ь' + FONTDATA_ITEM(8, 206, 207, fontpage_8_206_207), // 'ю' -- 'я' + FONTDATA_ITEM(8, 212, 212, fontpage_8_212_212), // 'є' -- 'є' + FONTDATA_ITEM(8, 214, 215, fontpage_8_214_215), // 'і' -- 'ї' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_vi.h b/Marlin/src/lcd/dogm/fontdata/langdata_vi.h index a8a0c5c121..303c4c66d6 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_vi.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_vi.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_2_131_131[31] U8G_FONT_SECTION("fontpage_2_131_131") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x83,0x83,0x00,0x08,0x00,0x00, @@ -177,51 +179,50 @@ const u8g_fntpgm_uint8_t fontpage_61_241_241[32] U8G_FONT_SECTION("fontpage_61_2 0x00,0x06,0x09,0x09,0x07,0x00,0xFE,0x0C,0x04,0x88,0x88,0x88,0x88,0x70,0x00,0x20 }; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(2, 131, 131, fontpage_2_131_131), // 'ă' -- 'ă' - FONTDATA_ITEM(2, 144, 145, fontpage_2_144_145), // 'Đ' -- 'đ' - FONTDATA_ITEM(2, 169, 169, fontpage_2_169_169), // 'ĩ' -- 'ĩ' - FONTDATA_ITEM(3, 161, 161, fontpage_3_161_161), // 'ơ' -- 'ơ' - FONTDATA_ITEM(3, 175, 176, fontpage_3_175_176), // 'Ư' -- 'ư' - FONTDATA_ITEM(6, 131, 131, fontpage_6_131_131), // '̃' -- '̃' - FONTDATA_ITEM(6, 137, 137, fontpage_6_137_137), // '̉' -- '̉' - FONTDATA_ITEM(6, 163, 163, fontpage_6_163_163), // '̣' -- '̣' - FONTDATA_ITEM(6, 192, 193, fontpage_6_192_193), // '̀' -- '́' - FONTDATA_ITEM(61, 161, 161, fontpage_61_161_161), // 'ạ' -- 'ạ' - FONTDATA_ITEM(61, 163, 163, fontpage_61_163_163), // 'ả' -- 'ả' - FONTDATA_ITEM(61, 165, 165, fontpage_61_165_165), // 'ấ' -- 'ấ' - FONTDATA_ITEM(61, 167, 167, fontpage_61_167_167), // 'ầ' -- 'ầ' - FONTDATA_ITEM(61, 169, 169, fontpage_61_169_169), // 'ẩ' -- 'ẩ' - FONTDATA_ITEM(61, 173, 173, fontpage_61_173_173), // 'ậ' -- 'ậ' - FONTDATA_ITEM(61, 175, 175, fontpage_61_175_175), // 'ắ' -- 'ắ' - FONTDATA_ITEM(61, 177, 177, fontpage_61_177_177), // 'ằ' -- 'ằ' - FONTDATA_ITEM(61, 179, 179, fontpage_61_179_179), // 'ẳ' -- 'ẳ' - FONTDATA_ITEM(61, 181, 181, fontpage_61_181_181), // 'ẵ' -- 'ẵ' - FONTDATA_ITEM(61, 183, 183, fontpage_61_183_183), // 'ặ' -- 'ặ' - FONTDATA_ITEM(61, 191, 191, fontpage_61_191_191), // 'ế' -- 'ế' - FONTDATA_ITEM(61, 193, 193, fontpage_61_193_193), // 'ề' -- 'ề' - FONTDATA_ITEM(61, 195, 195, fontpage_61_195_195), // 'ể' -- 'ể' - FONTDATA_ITEM(61, 199, 199, fontpage_61_199_199), // 'ệ' -- 'ệ' - FONTDATA_ITEM(61, 201, 201, fontpage_61_201_201), // 'ỉ' -- 'ỉ' - FONTDATA_ITEM(61, 203, 203, fontpage_61_203_203), // 'ị' -- 'ị' - FONTDATA_ITEM(61, 205, 205, fontpage_61_205_205), // 'ọ' -- 'ọ' - FONTDATA_ITEM(61, 207, 207, fontpage_61_207_207), // 'ỏ' -- 'ỏ' - FONTDATA_ITEM(61, 209, 209, fontpage_61_209_209), // 'ố' -- 'ố' - FONTDATA_ITEM(61, 211, 211, fontpage_61_211_211), // 'ồ' -- 'ồ' - FONTDATA_ITEM(61, 213, 213, fontpage_61_213_213), // 'ổ' -- 'ổ' - FONTDATA_ITEM(61, 215, 215, fontpage_61_215_215), // 'ỗ' -- 'ỗ' - FONTDATA_ITEM(61, 217, 217, fontpage_61_217_217), // 'ộ' -- 'ộ' - FONTDATA_ITEM(61, 219, 219, fontpage_61_219_219), // 'ớ' -- 'ớ' - FONTDATA_ITEM(61, 221, 221, fontpage_61_221_221), // 'ờ' -- 'ờ' - FONTDATA_ITEM(61, 223, 223, fontpage_61_223_223), // 'ở' -- 'ở' - FONTDATA_ITEM(61, 225, 225, fontpage_61_225_225), // 'ỡ' -- 'ỡ' - FONTDATA_ITEM(61, 227, 227, fontpage_61_227_227), // 'ợ' -- 'ợ' - FONTDATA_ITEM(61, 229, 229, fontpage_61_229_229), // 'ụ' -- 'ụ' - FONTDATA_ITEM(61, 231, 231, fontpage_61_231_231), // 'ủ' -- 'ủ' - FONTDATA_ITEM(61, 233, 233, fontpage_61_233_233), // 'ứ' -- 'ứ' - FONTDATA_ITEM(61, 235, 235, fontpage_61_235_235), // 'ừ' -- 'ừ' - FONTDATA_ITEM(61, 237, 237, fontpage_61_237_237), // 'ử' -- 'ử' - FONTDATA_ITEM(61, 239, 239, fontpage_61_239_239), // 'ữ' -- 'ữ' - FONTDATA_ITEM(61, 241, 241, fontpage_61_241_241), // 'ự' -- 'ự' +static const uxg_fontinfo_t g_fontinfo_vi[] PROGMEM = { + FONTDATA_ITEM(2, 131, 131, fontpage_2_131_131), // 'ă' -- 'ă' + FONTDATA_ITEM(2, 144, 145, fontpage_2_144_145), // 'Đ' -- 'đ' + FONTDATA_ITEM(2, 169, 169, fontpage_2_169_169), // 'ĩ' -- 'ĩ' + FONTDATA_ITEM(3, 161, 161, fontpage_3_161_161), // 'ơ' -- 'ơ' + FONTDATA_ITEM(3, 175, 176, fontpage_3_175_176), // 'Ư' -- 'ư' + FONTDATA_ITEM(6, 131, 131, fontpage_6_131_131), // '̃' -- '̃' + FONTDATA_ITEM(6, 137, 137, fontpage_6_137_137), // '̉' -- '̉' + FONTDATA_ITEM(6, 163, 163, fontpage_6_163_163), // '̣' -- '̣' + FONTDATA_ITEM(6, 192, 193, fontpage_6_192_193), // '̀' -- '́' + FONTDATA_ITEM(61, 161, 161, fontpage_61_161_161), // 'ạ' -- 'ạ' + FONTDATA_ITEM(61, 163, 163, fontpage_61_163_163), // 'ả' -- 'ả' + FONTDATA_ITEM(61, 165, 165, fontpage_61_165_165), // 'ấ' -- 'ấ' + FONTDATA_ITEM(61, 167, 167, fontpage_61_167_167), // 'ầ' -- 'ầ' + FONTDATA_ITEM(61, 169, 169, fontpage_61_169_169), // 'ẩ' -- 'ẩ' + FONTDATA_ITEM(61, 173, 173, fontpage_61_173_173), // 'ậ' -- 'ậ' + FONTDATA_ITEM(61, 175, 175, fontpage_61_175_175), // 'ắ' -- 'ắ' + FONTDATA_ITEM(61, 177, 177, fontpage_61_177_177), // 'ằ' -- 'ằ' + FONTDATA_ITEM(61, 179, 179, fontpage_61_179_179), // 'ẳ' -- 'ẳ' + FONTDATA_ITEM(61, 181, 181, fontpage_61_181_181), // 'ẵ' -- 'ẵ' + FONTDATA_ITEM(61, 183, 183, fontpage_61_183_183), // 'ặ' -- 'ặ' + FONTDATA_ITEM(61, 191, 191, fontpage_61_191_191), // 'ế' -- 'ế' + FONTDATA_ITEM(61, 193, 193, fontpage_61_193_193), // 'ề' -- 'ề' + FONTDATA_ITEM(61, 195, 195, fontpage_61_195_195), // 'ể' -- 'ể' + FONTDATA_ITEM(61, 199, 199, fontpage_61_199_199), // 'ệ' -- 'ệ' + FONTDATA_ITEM(61, 201, 201, fontpage_61_201_201), // 'ỉ' -- 'ỉ' + FONTDATA_ITEM(61, 203, 203, fontpage_61_203_203), // 'ị' -- 'ị' + FONTDATA_ITEM(61, 205, 205, fontpage_61_205_205), // 'ọ' -- 'ọ' + FONTDATA_ITEM(61, 207, 207, fontpage_61_207_207), // 'ỏ' -- 'ỏ' + FONTDATA_ITEM(61, 209, 209, fontpage_61_209_209), // 'ố' -- 'ố' + FONTDATA_ITEM(61, 211, 211, fontpage_61_211_211), // 'ồ' -- 'ồ' + FONTDATA_ITEM(61, 213, 213, fontpage_61_213_213), // 'ổ' -- 'ổ' + FONTDATA_ITEM(61, 215, 215, fontpage_61_215_215), // 'ỗ' -- 'ỗ' + FONTDATA_ITEM(61, 217, 217, fontpage_61_217_217), // 'ộ' -- 'ộ' + FONTDATA_ITEM(61, 219, 219, fontpage_61_219_219), // 'ớ' -- 'ớ' + FONTDATA_ITEM(61, 221, 221, fontpage_61_221_221), // 'ờ' -- 'ờ' + FONTDATA_ITEM(61, 223, 223, fontpage_61_223_223), // 'ở' -- 'ở' + FONTDATA_ITEM(61, 225, 225, fontpage_61_225_225), // 'ỡ' -- 'ỡ' + FONTDATA_ITEM(61, 227, 227, fontpage_61_227_227), // 'ợ' -- 'ợ' + FONTDATA_ITEM(61, 229, 229, fontpage_61_229_229), // 'ụ' -- 'ụ' + FONTDATA_ITEM(61, 231, 231, fontpage_61_231_231), // 'ủ' -- 'ủ' + FONTDATA_ITEM(61, 233, 233, fontpage_61_233_233), // 'ứ' -- 'ứ' + FONTDATA_ITEM(61, 235, 235, fontpage_61_235_235), // 'ừ' -- 'ừ' + FONTDATA_ITEM(61, 237, 237, fontpage_61_237_237), // 'ử' -- 'ử' + FONTDATA_ITEM(61, 239, 239, fontpage_61_239_239), // 'ữ' -- 'ữ' + FONTDATA_ITEM(61, 241, 241, fontpage_61_241_241), // 'ự' -- 'ự' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_zh_CN.h b/Marlin/src/lcd/dogm/fontdata/langdata_zh_CN.h index 491d480a01..664fa5f4bf 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_zh_CN.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_zh_CN.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_64_157_157[26] U8G_FONT_SECTION("fontpage_64_157_157") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x9D,0x9D,0x00,0x07,0x00,0x00, @@ -1462,362 +1464,361 @@ const u8g_fntpgm_uint8_t fontpage_510_154_154[30] U8G_FONT_SECTION("fontpage_510 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x9A,0x9A,0x00,0x08,0x00,0x00, 0x00,0x02,0x07,0x07,0x0C,0x06,0x01,0xC0,0xC0,0x00,0x00,0x00,0xC0,0xC0}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(64, 157, 157, fontpage_64_157_157), // '”' -- '”' - FONTDATA_ITEM(69, 191, 191, fontpage_69_191_191), // '⊿' -- '⊿' - FONTDATA_ITEM(156, 128, 128, fontpage_156_128_128), // '一' -- '一' - FONTDATA_ITEM(156, 137, 139, fontpage_156_137_139), // '三' -- '下' - FONTDATA_ITEM(156, 141, 141, fontpage_156_141_141), // '不' -- '不' - FONTDATA_ITEM(156, 147, 147, fontpage_156_147_147), // '专' -- '专' - FONTDATA_ITEM(156, 157, 157, fontpage_156_157_157), // '丝' -- '丝' - FONTDATA_ITEM(156, 170, 170, fontpage_156_170_170), // '个' -- '个' - FONTDATA_ITEM(156, 173, 173, fontpage_156_173_173), // '中' -- '中' - FONTDATA_ITEM(156, 186, 187, fontpage_156_186_187), // '为' -- '主' - FONTDATA_ITEM(156, 201, 201, fontpage_156_201_201), // '义' -- '义' - FONTDATA_ITEM(156, 203, 203, fontpage_156_203_203), // '之' -- '之' - FONTDATA_ITEM(157, 134, 134, fontpage_157_134_134), // '了' -- '了' - FONTDATA_ITEM(157, 140, 140, fontpage_157_140_140), // '二' -- '二' - FONTDATA_ITEM(157, 142, 142, fontpage_157_142_142), // '于' -- '于' - FONTDATA_ITEM(157, 164, 164, fontpage_157_164_164), // '交' -- '交' - FONTDATA_ITEM(157, 174, 174, fontpage_157_174_174), // '亮' -- '亮' - FONTDATA_ITEM(157, 206, 206, fontpage_157_206_206), // '从' -- '从' - FONTDATA_ITEM(157, 228, 229, fontpage_157_228_229), // '令' -- '以' - FONTDATA_ITEM(157, 246, 246, fontpage_157_246_246), // '件' -- '件' - FONTDATA_ITEM(157, 253, 253, fontpage_157_253_253), // '份' -- '份' - FONTDATA_ITEM(158, 145, 145, fontpage_158_145_145), // '休' -- '休' - FONTDATA_ITEM(158, 160, 160, fontpage_158_160_160), // '传' -- '传' - FONTDATA_ITEM(158, 205, 206, fontpage_158_205_206), // '位' -- '低' - FONTDATA_ITEM(158, 211, 211, fontpage_158_211_211), // '体' -- '体' - FONTDATA_ITEM(158, 217, 217, fontpage_158_217_217), // '余' -- '余' - FONTDATA_ITEM(158, 220, 220, fontpage_158_220_220), // '作' -- '作' - FONTDATA_ITEM(158, 255, 255, fontpage_158_255_255), // '使' -- '使' - FONTDATA_ITEM(159, 155, 155, fontpage_159_155_155), // '供' -- '供' - FONTDATA_ITEM(159, 181, 181, fontpage_159_181_181), // '侵' -- '侵' - FONTDATA_ITEM(159, 221, 221, fontpage_159_221_221), // '保' -- '保' - FONTDATA_ITEM(159, 225, 225, fontpage_159_225_225), // '信' -- '信' - FONTDATA_ITEM(160, 188, 188, fontpage_160_188_188), // '值' -- '值' - FONTDATA_ITEM(160, 190, 190, fontpage_160_190_190), // '倾' -- '倾' - FONTDATA_ITEM(160, 207, 207, fontpage_160_207_207), // '偏' -- '偏' - FONTDATA_ITEM(160, 220, 220, fontpage_160_220_220), // '停' -- '停' - FONTDATA_ITEM(161, 168, 168, fontpage_161_168_168), // '储' -- '储' - FONTDATA_ITEM(161, 207, 207, fontpage_161_207_207), // '像' -- '像' - FONTDATA_ITEM(162, 197, 197, fontpage_162_197_197), // '充' -- '充' - FONTDATA_ITEM(162, 200, 201, fontpage_162_200_201), // '先' -- '光' - FONTDATA_ITEM(162, 229, 229, fontpage_162_229_229), // '入' -- '入' - FONTDATA_ITEM(162, 232, 232, fontpage_162_232_232), // '全' -- '全' - FONTDATA_ITEM(162, 241, 241, fontpage_162_241_241), // '共' -- '共' - FONTDATA_ITEM(162, 243, 243, fontpage_162_243_243), // '关' -- '关' - FONTDATA_ITEM(162, 247, 247, fontpage_162_247_247), // '具' -- '具' - FONTDATA_ITEM(163, 151, 151, fontpage_163_151_151), // '冗' -- '冗' - FONTDATA_ITEM(163, 183, 183, fontpage_163_183_183), // '冷' -- '冷' - FONTDATA_ITEM(163, 198, 198, fontpage_163_198_198), // '准' -- '准' - FONTDATA_ITEM(163, 250, 251, fontpage_163_250_251), // '出' -- '击' - FONTDATA_ITEM(164, 134, 135, fontpage_164_134_135), // '分' -- '切' - FONTDATA_ITEM(164, 155, 155, fontpage_164_155_155), // '创' -- '创' - FONTDATA_ITEM(164, 157, 157, fontpage_164_157_157), // '初' -- '初' - FONTDATA_ITEM(164, 171, 171, fontpage_164_171_171), // '别' -- '别' - FONTDATA_ITEM(164, 176, 176, fontpage_164_176_176), // '到' -- '到' - FONTDATA_ITEM(164, 182, 183, fontpage_164_182_183), // '制' -- '刷' - FONTDATA_ITEM(164, 242, 242, fontpage_164_242_242), // '割' -- '割' - FONTDATA_ITEM(165, 155, 155, fontpage_165_155_155), // '力' -- '力' - FONTDATA_ITEM(165, 159, 160, fontpage_165_159_160), // '功' -- '加' - FONTDATA_ITEM(165, 168, 168, fontpage_165_168_168), // '动' -- '动' - FONTDATA_ITEM(166, 150, 150, fontpage_166_150_150), // '化' -- '化' - FONTDATA_ITEM(166, 199, 199, fontpage_166_199_199), // '升' -- '升' - FONTDATA_ITEM(166, 202, 202, fontpage_166_202_202), // '半' -- '半' - FONTDATA_ITEM(166, 207, 207, fontpage_166_207_207), // '协' -- '协' - FONTDATA_ITEM(166, 213, 213, fontpage_166_213_213), // '单' -- '单' - FONTDATA_ITEM(166, 225, 225, fontpage_166_225_225), // '卡' -- '卡' - FONTDATA_ITEM(166, 240, 241, fontpage_166_240_241), // '印' -- '危' - FONTDATA_ITEM(166, 244, 244, fontpage_166_244_244), // '却' -- '却' - FONTDATA_ITEM(166, 248, 248, fontpage_166_248_248), // '卸' -- '卸' - FONTDATA_ITEM(167, 139, 139, fontpage_167_139_139), // '压' -- '压' - FONTDATA_ITEM(167, 159, 159, fontpage_167_159_159), // '原' -- '原' - FONTDATA_ITEM(167, 204, 205, fontpage_167_204_205), // '双' -- '反' - FONTDATA_ITEM(167, 214, 214, fontpage_167_214_214), // '取' -- '取' - FONTDATA_ITEM(167, 216, 216, fontpage_167_216_216), // '变' -- '变' - FONTDATA_ITEM(167, 240, 240, fontpage_167_240_240), // '台' -- '台' - FONTDATA_ITEM(168, 131, 131, fontpage_168_131_131), // '吃' -- '吃' - FONTDATA_ITEM(168, 136, 136, fontpage_168_136_136), // '合' -- '合' - FONTDATA_ITEM(168, 141, 142, fontpage_168_141_142), // '名' -- '后' - FONTDATA_ITEM(168, 145, 145, fontpage_168_145_145), // '向' -- '向' - FONTDATA_ITEM(168, 166, 166, fontpage_168_166_166), // '否' -- '否' - FONTDATA_ITEM(168, 175, 175, fontpage_168_175_175), // '启' -- '启' - FONTDATA_ITEM(168, 202, 202, fontpage_168_202_202), // '告' -- '告' - FONTDATA_ITEM(168, 232, 232, fontpage_168_232_232), // '周' -- '周' - FONTDATA_ITEM(168, 253, 253, fontpage_168_253_253), // '命' -- '命' - FONTDATA_ITEM(169, 140, 140, fontpage_169_140_140), // '和' -- '和' - FONTDATA_ITEM(169, 205, 205, fontpage_169_205_205), // '响' -- '响' - FONTDATA_ITEM(171, 183, 183, fontpage_171_183_183), // '喷' -- '喷' - FONTDATA_ITEM(172, 180, 180, fontpage_172_180_180), // '嘴' -- '嘴' - FONTDATA_ITEM(172, 232, 232, fontpage_172_232_232), // '器' -- '器' - FONTDATA_ITEM(172, 244, 244, fontpage_172_244_244), // '噴' -- '噴' - FONTDATA_ITEM(173, 222, 222, fontpage_173_222_222), // '回' -- '回' - FONTDATA_ITEM(173, 224, 224, fontpage_173_224_224), // '因' -- '因' - FONTDATA_ITEM(173, 250, 250, fontpage_173_250_250), // '固' -- '固' - FONTDATA_ITEM(173, 254, 254, fontpage_173_254_254), // '图' -- '图' - FONTDATA_ITEM(174, 168, 168, fontpage_174_168_168), // '在' -- '在' - FONTDATA_ITEM(174, 207, 207, fontpage_174_207_207), // '坏' -- '坏' - FONTDATA_ITEM(174, 215, 215, fontpage_174_215_215), // '块' -- '块' - FONTDATA_ITEM(175, 139, 139, fontpage_175_139_139), // '型' -- '型' - FONTDATA_ITEM(175, 171, 171, fontpage_175_171_171), // '垫' -- '垫' - FONTDATA_ITEM(176, 235, 235, fontpage_176_235_235), // '填' -- '填' - FONTDATA_ITEM(177, 243, 243, fontpage_177_243_243), // '壳' -- '壳' - FONTDATA_ITEM(178, 135, 135, fontpage_178_135_135), // '备' -- '备' - FONTDATA_ITEM(178, 141, 141, fontpage_178_141_141), // '复' -- '复' - FONTDATA_ITEM(178, 150, 150, fontpage_178_150_150), // '外' -- '外' - FONTDATA_ITEM(178, 154, 154, fontpage_178_154_154), // '多' -- '多' - FONTDATA_ITEM(178, 167, 167, fontpage_178_167_167), // '大' -- '大' - FONTDATA_ITEM(178, 169, 170, fontpage_178_169_170), // '天' -- '太' - FONTDATA_ITEM(178, 177, 177, fontpage_178_177_177), // '失' -- '失' - FONTDATA_ITEM(178, 180, 180, fontpage_178_180_180), // '头' -- '头' - FONTDATA_ITEM(178, 253, 253, fontpage_178_253_253), // '好' -- '好' - FONTDATA_ITEM(179, 203, 203, fontpage_179_203_203), // '始' -- '始' - FONTDATA_ITEM(182, 208, 208, fontpage_182_208_208), // '子' -- '子' - FONTDATA_ITEM(182, 216, 216, fontpage_182_216_216), // '存' -- '存' - FONTDATA_ITEM(183, 137, 137, fontpage_183_137_137), // '安' -- '安' - FONTDATA_ITEM(183, 140, 140, fontpage_183_140_140), // '完' -- '完' - FONTDATA_ITEM(183, 154, 154, fontpage_183_154_154), // '定' -- '定' - FONTDATA_ITEM(183, 162, 162, fontpage_183_162_162), // '客' -- '客' - FONTDATA_ITEM(183, 171, 171, fontpage_183_171_171), // '宫' -- '宫' - FONTDATA_ITEM(183, 249, 249, fontpage_183_249_249), // '对' -- '对' - FONTDATA_ITEM(184, 134, 134, fontpage_184_134_134), // '将' -- '将' - FONTDATA_ITEM(184, 143, 143, fontpage_184_143_143), // '小' -- '小' - FONTDATA_ITEM(184, 177, 177, fontpage_184_177_177), // '就' -- '就' - FONTDATA_ITEM(184, 207, 207, fontpage_184_207_207), // '屏' -- '屏' - FONTDATA_ITEM(187, 229, 229, fontpage_187_229_229), // '工' -- '工' - FONTDATA_ITEM(187, 238, 238, fontpage_187_238_238), // '差' -- '差' - FONTDATA_ITEM(187, 242, 242, fontpage_187_242_242), // '已' -- '已' - FONTDATA_ITEM(188, 243, 243, fontpage_188_243_243), // '平' -- '平' - FONTDATA_ITEM(188, 246, 246, fontpage_188_246_246), // '并' -- '并' - FONTDATA_ITEM(189, 138, 138, fontpage_189_138_138), // '床' -- '床' - FONTDATA_ITEM(189, 148, 148, fontpage_189_148_148), // '应' -- '应' - FONTDATA_ITEM(189, 159, 159, fontpage_189_159_159), // '废' -- '废' - FONTDATA_ITEM(189, 166, 166, fontpage_189_166_166), // '度' -- '度' - FONTDATA_ITEM(190, 128, 128, fontpage_190_128_128), // '开' -- '开' - FONTDATA_ITEM(190, 131, 131, fontpage_190_131_131), // '弃' -- '弃' - FONTDATA_ITEM(190, 143, 143, fontpage_190_143_143), // '式' -- '式' - FONTDATA_ITEM(190, 149, 149, fontpage_190_149_149), // '引' -- '引' - FONTDATA_ITEM(190, 185, 185, fontpage_190_185_185), // '弹' -- '弹' - FONTDATA_ITEM(190, 210, 210, fontpage_190_210_210), // '归' -- '归' - FONTDATA_ITEM(191, 132, 133, fontpage_191_132_133), // '径' -- '待' - FONTDATA_ITEM(191, 170, 170, fontpage_191_170_170), // '循' -- '循' - FONTDATA_ITEM(191, 174, 174, fontpage_191_174_174), // '微' -- '微' - FONTDATA_ITEM(191, 195, 195, fontpage_191_195_195), // '心' -- '心' - FONTDATA_ITEM(191, 253, 253, fontpage_191_253_253), // '忽' -- '忽' - FONTDATA_ITEM(192, 167, 167, fontpage_192_167_167), // '性' -- '性' - FONTDATA_ITEM(192, 187, 187, fontpage_192_187_187), // '总' -- '总' - FONTDATA_ITEM(192, 226, 226, fontpage_192_226_226), // '恢' -- '恢' - FONTDATA_ITEM(192, 239, 239, fontpage_192_239_239), // '息' -- '息' - FONTDATA_ITEM(194, 159, 159, fontpage_194_159_159), // '感' -- '感' - FONTDATA_ITEM(196, 143, 144, fontpage_196_143_144), // '戏' -- '成' - FONTDATA_ITEM(196, 183, 183, fontpage_196_183_183), // '户' -- '户' - FONTDATA_ITEM(196, 192, 192, fontpage_196_192_192), // '所' -- '所' - FONTDATA_ITEM(196, 199, 199, fontpage_196_199_199), // '扇' -- '扇' - FONTDATA_ITEM(196, 203, 203, fontpage_196_203_203), // '手' -- '手' - FONTDATA_ITEM(196, 211, 211, fontpage_196_211_211), // '打' -- '打' - FONTDATA_ITEM(196, 231, 231, fontpage_196_231_231), // '执' -- '执' - FONTDATA_ITEM(196, 249, 249, fontpage_196_249_249), // '批' -- '批' - FONTDATA_ITEM(197, 150, 150, fontpage_197_150_150), // '抖' -- '抖' - FONTDATA_ITEM(197, 165, 165, fontpage_197_165_165), // '报' -- '报' - FONTDATA_ITEM(197, 172, 172, fontpage_197_172_172), // '抬' -- '抬' - FONTDATA_ITEM(197, 189, 189, fontpage_197_189_189), // '抽' -- '抽' - FONTDATA_ITEM(197, 212, 212, fontpage_197_212_212), // '拔' -- '拔' - FONTDATA_ITEM(197, 233, 233, fontpage_197_233_233), // '择' -- '择' - FONTDATA_ITEM(198, 137, 137, fontpage_198_137_137), // '按' -- '按' - FONTDATA_ITEM(198, 161, 161, fontpage_198_161_161), // '挡' -- '挡' - FONTDATA_ITEM(198, 164, 164, fontpage_198_164_164), // '挤' -- '挤' - FONTDATA_ITEM(198, 223, 223, fontpage_198_223_223), // '损' -- '损' - FONTDATA_ITEM(198, 226, 226, fontpage_198_226_226), // '换' -- '换' - FONTDATA_ITEM(199, 137, 137, fontpage_199_137_137), // '掉' -- '掉' - FONTDATA_ITEM(199, 162, 162, fontpage_199_162_162), // '探' -- '探' - FONTDATA_ITEM(199, 165, 165, fontpage_199_165_165), // '接' -- '接' - FONTDATA_ITEM(199, 167, 167, fontpage_199_167_167), // '控' -- '控' - FONTDATA_ITEM(199, 208, 208, fontpage_199_208_208), // '提' -- '提' - FONTDATA_ITEM(199, 210, 210, fontpage_199_210_210), // '插' -- '插' - FONTDATA_ITEM(202, 182, 182, fontpage_202_182_182), // '收' -- '收' - FONTDATA_ITEM(202, 190, 190, fontpage_202_190_190), // '放' -- '放' - FONTDATA_ITEM(202, 240, 240, fontpage_202_240_240), // '数' -- '数' - FONTDATA_ITEM(202, 242, 242, fontpage_202_242_242), // '敲' -- '敲' - FONTDATA_ITEM(202, 244, 244, fontpage_202_244_244), // '整' -- '整' - FONTDATA_ITEM(203, 135, 135, fontpage_203_135_135), // '文' -- '文' - FONTDATA_ITEM(203, 153, 153, fontpage_203_153_153), // '料' -- '料' - FONTDATA_ITEM(203, 156, 156, fontpage_203_156_156), // '斜' -- '斜' - FONTDATA_ITEM(203, 173, 173, fontpage_203_173_173), // '断' -- '断' - FONTDATA_ITEM(203, 176, 176, fontpage_203_176_176), // '新' -- '新' - FONTDATA_ITEM(203, 185, 185, fontpage_203_185_185), // '方' -- '方' - FONTDATA_ITEM(203, 224, 224, fontpage_203_224_224), // '无' -- '无' - FONTDATA_ITEM(203, 246, 246, fontpage_203_246_246), // '时' -- '时' - FONTDATA_ITEM(204, 142, 142, fontpage_204_142_142), // '明' -- '明' - FONTDATA_ITEM(204, 175, 175, fontpage_204_175_175), // '是' -- '是' - FONTDATA_ITEM(205, 130, 130, fontpage_205_130_130), // '暂' -- '暂' - FONTDATA_ITEM(205, 171, 171, fontpage_205_171_171), // '暫' -- '暫' - FONTDATA_ITEM(205, 244, 244, fontpage_205_244_244), // '更' -- '更' - FONTDATA_ITEM(206, 128, 128, fontpage_206_128_128), // '最' -- '最' - FONTDATA_ITEM(206, 137, 137, fontpage_206_137_137), // '有' -- '有' - FONTDATA_ITEM(206, 159, 159, fontpage_206_159_159), // '期' -- '期' - FONTDATA_ITEM(206, 186, 186, fontpage_206_186_186), // '机' -- '机' - FONTDATA_ITEM(206, 192, 192, fontpage_206_192_192), // '杀' -- '杀' - FONTDATA_ITEM(206, 223, 223, fontpage_206_223_223), // '束' -- '束' - FONTDATA_ITEM(206, 225, 225, fontpage_206_225_225), // '条' -- '条' - FONTDATA_ITEM(206, 229, 229, fontpage_206_229_229), // '来' -- '来' - FONTDATA_ITEM(206, 255, 255, fontpage_206_255_255), // '板' -- '板' - FONTDATA_ITEM(207, 151, 151, fontpage_207_151_151), // '林' -- '林' - FONTDATA_ITEM(207, 241, 241, fontpage_207_241_241), // '柱' -- '柱' - FONTDATA_ITEM(208, 161, 161, fontpage_208_161_161), // '校' -- '校' - FONTDATA_ITEM(208, 188, 188, fontpage_208_188_188), // '格' -- '格' - FONTDATA_ITEM(209, 175, 175, fontpage_209_175_175), // '梯' -- '梯' - FONTDATA_ITEM(209, 192, 192, fontpage_209_192_192), // '检' -- '检' - FONTDATA_ITEM(211, 253, 253, fontpage_211_253_253), // '槽' -- '槽' - FONTDATA_ITEM(212, 161, 161, fontpage_212_161_161), // '模' -- '模' - FONTDATA_ITEM(212, 217, 217, fontpage_212_217_217), // '橙' -- '橙' - FONTDATA_ITEM(214, 226, 227, fontpage_214_226_227), // '止' -- '正' - FONTDATA_ITEM(214, 229, 229, fontpage_214_229_229), // '步' -- '步' - FONTDATA_ITEM(215, 212, 212, fontpage_215_212_212), // '比' -- '比' - FONTDATA_ITEM(217, 161, 161, fontpage_217_161_161), // '没' -- '没' - FONTDATA_ITEM(217, 226, 226, fontpage_217_226_226), // '波' -- '波' - FONTDATA_ITEM(217, 232, 232, fontpage_217_232_232), // '注' -- '注' - FONTDATA_ITEM(218, 151, 151, fontpage_218_151_151), // '洗' -- '洗' - FONTDATA_ITEM(218, 187, 187, fontpage_218_187_187), // '活' -- '活' - FONTDATA_ITEM(218, 193, 193, fontpage_218_193_193), // '流' -- '流' - FONTDATA_ITEM(218, 203, 203, fontpage_218_203_203), // '测' -- '测' - FONTDATA_ITEM(219, 136, 136, fontpage_219_136_136), // '消' -- '消' - FONTDATA_ITEM(219, 225, 225, fontpage_219_225_225), // '淡' -- '淡' - FONTDATA_ITEM(219, 247, 247, fontpage_219_247_247), // '混' -- '混' - FONTDATA_ITEM(220, 133, 133, fontpage_220_133_133), // '清' -- '清' - FONTDATA_ITEM(220, 169, 169, fontpage_220_169_169), // '温' -- '温' - FONTDATA_ITEM(220, 184, 184, fontpage_220_184_184), // '游' -- '游' - FONTDATA_ITEM(221, 144, 144, fontpage_221_144_144), // '源' -- '源' - FONTDATA_ITEM(221, 162, 162, fontpage_221_162_162), // '溢' -- '溢' - FONTDATA_ITEM(221, 209, 209, fontpage_221_209_209), // '滑' -- '滑' - FONTDATA_ITEM(222, 143, 143, fontpage_222_143_143), // '漏' -- '漏' - FONTDATA_ITEM(223, 192, 192, fontpage_223_192_192), // '激' -- '激' - FONTDATA_ITEM(224, 239, 239, fontpage_224_239_239), // '灯' -- '灯' - FONTDATA_ITEM(225, 185, 185, fontpage_225_185_185), // '点' -- '点' - FONTDATA_ITEM(225, 237, 237, fontpage_225_237_237), // '热' -- '热' - FONTDATA_ITEM(228, 199, 199, fontpage_228_199_199), // '片' -- '片' - FONTDATA_ITEM(228, 233, 233, fontpage_228_233_233), // '物' -- '物' - FONTDATA_ITEM(228, 249, 249, fontpage_228_249_249), // '特' -- '特' - FONTDATA_ITEM(231, 135, 135, fontpage_231_135_135), // '率' -- '率' - FONTDATA_ITEM(231, 175, 175, fontpage_231_175_175), // '环' -- '环' - FONTDATA_ITEM(234, 168, 168, fontpage_234_168_168), // '用' -- '用' - FONTDATA_ITEM(234, 181, 181, fontpage_234_181_181), // '电' -- '电' - FONTDATA_ITEM(234, 229, 229, fontpage_234_229_229), // '略' -- '略' - FONTDATA_ITEM(236, 253, 253, fontpage_236_253_253), // '白' -- '白' - FONTDATA_ITEM(237, 132, 132, fontpage_237_132_132), // '的' -- '的' - FONTDATA_ITEM(237, 209, 209, fontpage_237_209_209), // '监' -- '监' - FONTDATA_ITEM(237, 244, 244, fontpage_237_244_244), // '直' -- '直' - FONTDATA_ITEM(238, 129, 129, fontpage_238_129_129), // '省' -- '省' - FONTDATA_ITEM(238, 160, 160, fontpage_238_160_160), // '眠' -- '眠' - FONTDATA_ITEM(240, 238, 238, fontpage_240_238_238), // '确' -- '确' - FONTDATA_ITEM(243, 187, 187, fontpage_243_187_187), // '离' -- '离' - FONTDATA_ITEM(243, 251, 251, fontpage_243_251_251), // '移' -- '移' - FONTDATA_ITEM(244, 250, 250, fontpage_244_250_250), // '空' -- '空' - FONTDATA_ITEM(245, 239, 239, fontpage_245_239_239), // '端' -- '端' - FONTDATA_ITEM(246, 172, 172, fontpage_246_172_172), // '第' -- '第' - FONTDATA_ITEM(246, 201, 201, fontpage_246_201_201), // '等' -- '等' - FONTDATA_ITEM(247, 128, 128, fontpage_247_128_128), // '简' -- '简' - FONTDATA_ITEM(247, 177, 177, fontpage_247_177_177), // '箱' -- '箱' - FONTDATA_ITEM(248, 251, 251, fontpage_248_251_251), // '类' -- '类' - FONTDATA_ITEM(250, 162, 162, fontpage_250_162_162), // '索' -- '索' - FONTDATA_ITEM(250, 171, 171, fontpage_250_171_171), // '紫' -- '紫' - FONTDATA_ITEM(253, 162, 162, fontpage_253_162_162), // '红' -- '红' - FONTDATA_ITEM(253, 167, 167, fontpage_253_167_167), // '级' -- '级' - FONTDATA_ITEM(253, 191, 191, fontpage_253_191_191), // '线' -- '线' - FONTDATA_ITEM(253, 198, 198, fontpage_253_198_198), // '细' -- '细' - FONTDATA_ITEM(253, 200, 200, fontpage_253_200_200), // '终' -- '终' - FONTDATA_ITEM(253, 211, 211, fontpage_253_211_211), // '结' -- '结' - FONTDATA_ITEM(253, 217, 217, fontpage_253_217_217), // '给' -- '给' - FONTDATA_ITEM(253, 223, 223, fontpage_253_223_223), // '统' -- '统' - FONTDATA_ITEM(253, 231, 231, fontpage_253_231_231), // '继' -- '继' - FONTDATA_ITEM(253, 234, 234, fontpage_253_234_234), // '绪' -- '绪' - FONTDATA_ITEM(253, 237, 237, fontpage_253_237_237), // '续' -- '续' - FONTDATA_ITEM(253, 255, 255, fontpage_253_255_255), // '绿' -- '绿' - FONTDATA_ITEM(254, 150, 150, fontpage_254_150_150), // '编' -- '编' - FONTDATA_ITEM(254, 186, 186, fontpage_254_186_186), // '缺' -- '缺' - FONTDATA_ITEM(254, 209, 209, fontpage_254_209_209), // '网' -- '网' - FONTDATA_ITEM(254, 238, 238, fontpage_254_238_238), // '置' -- '置' - FONTDATA_ITEM(254, 242, 242, fontpage_254_242_242), // '署' -- '署' - FONTDATA_ITEM(256, 133, 133, fontpage_256_133_133), // '者' -- '者' - FONTDATA_ITEM(256, 234, 234, fontpage_256_234_234), // '聪' -- '聪' - FONTDATA_ITEM(257, 253, 253, fontpage_257_253_253), // '能' -- '能' - FONTDATA_ITEM(259, 234, 234, fontpage_259_234_234), // '自' -- '自' - FONTDATA_ITEM(259, 243, 243, fontpage_259_243_243), // '至' -- '至' - FONTDATA_ITEM(263, 220, 220, fontpage_263_220_220), // '菜' -- '菜' - FONTDATA_ITEM(265, 221, 221, fontpage_265_221_221), // '蓝' -- '蓝' - FONTDATA_ITEM(269, 199, 199, fontpage_269_199_199), // '蛇' -- '蛇' - FONTDATA_ITEM(272, 204, 204, fontpage_272_204_204), // '行' -- '行' - FONTDATA_ITEM(273, 171, 171, fontpage_273_171_171), // '被' -- '被' - FONTDATA_ITEM(273, 197, 197, fontpage_273_197_197), // '装' -- '装' - FONTDATA_ITEM(275, 129, 129, fontpage_275_129_129), // '要' -- '要' - FONTDATA_ITEM(275, 210, 210, fontpage_275_210_210), // '角' -- '角' - FONTDATA_ITEM(279, 161, 161, fontpage_279_161_161), // '计' -- '计' - FONTDATA_ITEM(279, 174, 174, fontpage_279_174_174), // '议' -- '议' - FONTDATA_ITEM(279, 190, 190, fontpage_279_190_190), // '设' -- '设' - FONTDATA_ITEM(279, 213, 213, fontpage_279_213_213), // '试' -- '试' - FONTDATA_ITEM(279, 239, 239, fontpage_279_239_239), // '误' -- '误' - FONTDATA_ITEM(279, 247, 247, fontpage_279_247_247), // '请' -- '请' - FONTDATA_ITEM(279, 251, 251, fontpage_279_251_251), // '读' -- '读' - FONTDATA_ITEM(280, 131, 131, fontpage_280_131_131), // '调' -- '调' - FONTDATA_ITEM(282, 165, 165, fontpage_282_165_165), // '败' -- '败' - FONTDATA_ITEM(282, 170, 170, fontpage_282_170_170), // '贪' -- '贪' - FONTDATA_ITEM(282, 247, 247, fontpage_282_247_247), // '起' -- '起' - FONTDATA_ITEM(283, 133, 133, fontpage_283_133_133), // '超' -- '超' - FONTDATA_ITEM(283, 221, 221, fontpage_283_221_221), // '距' -- '距' - FONTDATA_ITEM(286, 236, 236, fontpage_286_236_236), // '转' -- '转' - FONTDATA_ITEM(286, 239, 239, fontpage_286_239_239), // '软' -- '软' - FONTDATA_ITEM(286, 244, 244, fontpage_286_244_244), // '轴' -- '轴' - FONTDATA_ITEM(286, 253, 253, fontpage_286_253_253), // '载' -- '载' - FONTDATA_ITEM(287, 145, 145, fontpage_287_145_145), // '辑' -- '辑' - FONTDATA_ITEM(287, 147, 147, fontpage_287_147_147), // '输' -- '输' - FONTDATA_ITEM(287, 185, 185, fontpage_287_185_185), // '边' -- '边' - FONTDATA_ITEM(287, 193, 193, fontpage_287_193_193), // '迁' -- '迁' - FONTDATA_ITEM(287, 208, 209, fontpage_287_208_209), // '运' -- '近' - FONTDATA_ITEM(287, 212, 212, fontpage_287_212_212), // '返' -- '返' - FONTDATA_ITEM(287, 216, 216, fontpage_287_216_216), // '还' -- '还' - FONTDATA_ITEM(287, 219, 219, fontpage_287_219_219), // '进' -- '进' - FONTDATA_ITEM(287, 222, 222, fontpage_287_222_222), // '连' -- '连' - FONTDATA_ITEM(287, 247, 247, fontpage_287_247_247), // '迷' -- '迷' - FONTDATA_ITEM(288, 128, 128, fontpage_288_128_128), // '退' -- '退' - FONTDATA_ITEM(288, 137, 137, fontpage_288_137_137), // '选' -- '选' - FONTDATA_ITEM(288, 159, 159, fontpage_288_159_159), // '速' -- '速' - FONTDATA_ITEM(289, 232, 232, fontpage_289_232_232), // '部' -- '部' - FONTDATA_ITEM(290, 205, 205, fontpage_290_205_205), // '配' -- '配' - FONTDATA_ITEM(291, 202, 202, fontpage_291_202_202), // '释' -- '释' - FONTDATA_ITEM(291, 205, 205, fontpage_291_205_205), // '重' -- '重' - FONTDATA_ITEM(291, 207, 207, fontpage_291_207_207), // '量' -- '量' - FONTDATA_ITEM(297, 136, 136, fontpage_297_136_136), // '针' -- '针' - FONTDATA_ITEM(297, 174, 174, fontpage_297_174_174), // '钮' -- '钮' - FONTDATA_ITEM(298, 153, 153, fontpage_298_153_153), // '错' -- '错' - FONTDATA_ITEM(298, 220, 220, fontpage_298_220_220), // '镜' -- '镜' - FONTDATA_ITEM(298, 255, 255, fontpage_298_255_255), // '长' -- '长' - FONTDATA_ITEM(299, 237, 237, fontpage_299_237_237), // '闭' -- '闭' - FONTDATA_ITEM(299, 242, 242, fontpage_299_242_242), // '闲' -- '闲' - FONTDATA_ITEM(299, 244, 244, fontpage_299_244_244), // '间' -- '间' - FONTDATA_ITEM(300, 136, 136, fontpage_300_136_136), // '阈' -- '阈' - FONTDATA_ITEM(300, 205, 205, fontpage_300_205_205), // '降' -- '降' - FONTDATA_ITEM(300, 208, 208, fontpage_300_208_208), // '限' -- '限' - FONTDATA_ITEM(300, 228, 228, fontpage_300_228_228), // '除' -- '除' - FONTDATA_ITEM(300, 233, 233, fontpage_300_233_233), // '险' -- '险' - FONTDATA_ITEM(301, 246, 246, fontpage_301_246_246), // '零' -- '零' - FONTDATA_ITEM(302, 128, 128, fontpage_302_128_128), // '需' -- '需' - FONTDATA_ITEM(302, 210, 210, fontpage_302_210_210), // '青' -- '青' - FONTDATA_ITEM(302, 222, 222, fontpage_302_222_222), // '非' -- '非' - FONTDATA_ITEM(302, 224, 224, fontpage_302_224_224), // '靠' -- '靠' - FONTDATA_ITEM(302, 226, 226, fontpage_302_226_226), // '面' -- '面' - FONTDATA_ITEM(304, 245, 245, fontpage_304_245_245), // '页' -- '页' - FONTDATA_ITEM(304, 249, 249, fontpage_304_249_249), // '项' -- '项' - FONTDATA_ITEM(305, 132, 132, fontpage_305_132_132), // '预' -- '预' - FONTDATA_ITEM(305, 145, 145, fontpage_305_145_145), // '频' -- '频' - FONTDATA_ITEM(305, 157, 157, fontpage_305_157_157), // '额' -- '额' - FONTDATA_ITEM(305, 206, 206, fontpage_305_206_206), // '风' -- '风' - FONTDATA_ITEM(306, 241, 241, fontpage_306_241_241), // '饱' -- '饱' - FONTDATA_ITEM(308, 236, 236, fontpage_308_236_236), // '马' -- '马' - FONTDATA_ITEM(308, 241, 241, fontpage_308_241_241), // '驱' -- '驱' - FONTDATA_ITEM(309, 216, 216, fontpage_309_216_216), // '高' -- '高' - FONTDATA_ITEM(317, 196, 196, fontpage_317_196_196), // '黄' -- '黄' - FONTDATA_ITEM(317, 222, 222, fontpage_317_222_222), // '點' -- '點' - FONTDATA_ITEM(318, 208, 208, fontpage_318_208_208), // '齐' -- '齐' - FONTDATA_ITEM(510, 154, 154, fontpage_510_154_154), // ':' -- ':' +static const uxg_fontinfo_t g_fontinfo_zh_CN[] PROGMEM = { + FONTDATA_ITEM(64, 157, 157, fontpage_64_157_157), // '”' -- '”' + FONTDATA_ITEM(69, 191, 191, fontpage_69_191_191), // '⊿' -- '⊿' + FONTDATA_ITEM(156, 128, 128, fontpage_156_128_128), // '一' -- '一' + FONTDATA_ITEM(156, 137, 139, fontpage_156_137_139), // '三' -- '下' + FONTDATA_ITEM(156, 141, 141, fontpage_156_141_141), // '不' -- '不' + FONTDATA_ITEM(156, 147, 147, fontpage_156_147_147), // '专' -- '专' + FONTDATA_ITEM(156, 157, 157, fontpage_156_157_157), // '丝' -- '丝' + FONTDATA_ITEM(156, 170, 170, fontpage_156_170_170), // '个' -- '个' + FONTDATA_ITEM(156, 173, 173, fontpage_156_173_173), // '中' -- '中' + FONTDATA_ITEM(156, 186, 187, fontpage_156_186_187), // '为' -- '主' + FONTDATA_ITEM(156, 201, 201, fontpage_156_201_201), // '义' -- '义' + FONTDATA_ITEM(156, 203, 203, fontpage_156_203_203), // '之' -- '之' + FONTDATA_ITEM(157, 134, 134, fontpage_157_134_134), // '了' -- '了' + FONTDATA_ITEM(157, 140, 140, fontpage_157_140_140), // '二' -- '二' + FONTDATA_ITEM(157, 142, 142, fontpage_157_142_142), // '于' -- '于' + FONTDATA_ITEM(157, 164, 164, fontpage_157_164_164), // '交' -- '交' + FONTDATA_ITEM(157, 174, 174, fontpage_157_174_174), // '亮' -- '亮' + FONTDATA_ITEM(157, 206, 206, fontpage_157_206_206), // '从' -- '从' + FONTDATA_ITEM(157, 228, 229, fontpage_157_228_229), // '令' -- '以' + FONTDATA_ITEM(157, 246, 246, fontpage_157_246_246), // '件' -- '件' + FONTDATA_ITEM(157, 253, 253, fontpage_157_253_253), // '份' -- '份' + FONTDATA_ITEM(158, 145, 145, fontpage_158_145_145), // '休' -- '休' + FONTDATA_ITEM(158, 160, 160, fontpage_158_160_160), // '传' -- '传' + FONTDATA_ITEM(158, 205, 206, fontpage_158_205_206), // '位' -- '低' + FONTDATA_ITEM(158, 211, 211, fontpage_158_211_211), // '体' -- '体' + FONTDATA_ITEM(158, 217, 217, fontpage_158_217_217), // '余' -- '余' + FONTDATA_ITEM(158, 220, 220, fontpage_158_220_220), // '作' -- '作' + FONTDATA_ITEM(158, 255, 255, fontpage_158_255_255), // '使' -- '使' + FONTDATA_ITEM(159, 155, 155, fontpage_159_155_155), // '供' -- '供' + FONTDATA_ITEM(159, 181, 181, fontpage_159_181_181), // '侵' -- '侵' + FONTDATA_ITEM(159, 221, 221, fontpage_159_221_221), // '保' -- '保' + FONTDATA_ITEM(159, 225, 225, fontpage_159_225_225), // '信' -- '信' + FONTDATA_ITEM(160, 188, 188, fontpage_160_188_188), // '值' -- '值' + FONTDATA_ITEM(160, 190, 190, fontpage_160_190_190), // '倾' -- '倾' + FONTDATA_ITEM(160, 207, 207, fontpage_160_207_207), // '偏' -- '偏' + FONTDATA_ITEM(160, 220, 220, fontpage_160_220_220), // '停' -- '停' + FONTDATA_ITEM(161, 168, 168, fontpage_161_168_168), // '储' -- '储' + FONTDATA_ITEM(161, 207, 207, fontpage_161_207_207), // '像' -- '像' + FONTDATA_ITEM(162, 197, 197, fontpage_162_197_197), // '充' -- '充' + FONTDATA_ITEM(162, 200, 201, fontpage_162_200_201), // '先' -- '光' + FONTDATA_ITEM(162, 229, 229, fontpage_162_229_229), // '入' -- '入' + FONTDATA_ITEM(162, 232, 232, fontpage_162_232_232), // '全' -- '全' + FONTDATA_ITEM(162, 241, 241, fontpage_162_241_241), // '共' -- '共' + FONTDATA_ITEM(162, 243, 243, fontpage_162_243_243), // '关' -- '关' + FONTDATA_ITEM(162, 247, 247, fontpage_162_247_247), // '具' -- '具' + FONTDATA_ITEM(163, 151, 151, fontpage_163_151_151), // '冗' -- '冗' + FONTDATA_ITEM(163, 183, 183, fontpage_163_183_183), // '冷' -- '冷' + FONTDATA_ITEM(163, 198, 198, fontpage_163_198_198), // '准' -- '准' + FONTDATA_ITEM(163, 250, 251, fontpage_163_250_251), // '出' -- '击' + FONTDATA_ITEM(164, 134, 135, fontpage_164_134_135), // '分' -- '切' + FONTDATA_ITEM(164, 155, 155, fontpage_164_155_155), // '创' -- '创' + FONTDATA_ITEM(164, 157, 157, fontpage_164_157_157), // '初' -- '初' + FONTDATA_ITEM(164, 171, 171, fontpage_164_171_171), // '别' -- '别' + FONTDATA_ITEM(164, 176, 176, fontpage_164_176_176), // '到' -- '到' + FONTDATA_ITEM(164, 182, 183, fontpage_164_182_183), // '制' -- '刷' + FONTDATA_ITEM(164, 242, 242, fontpage_164_242_242), // '割' -- '割' + FONTDATA_ITEM(165, 155, 155, fontpage_165_155_155), // '力' -- '力' + FONTDATA_ITEM(165, 159, 160, fontpage_165_159_160), // '功' -- '加' + FONTDATA_ITEM(165, 168, 168, fontpage_165_168_168), // '动' -- '动' + FONTDATA_ITEM(166, 150, 150, fontpage_166_150_150), // '化' -- '化' + FONTDATA_ITEM(166, 199, 199, fontpage_166_199_199), // '升' -- '升' + FONTDATA_ITEM(166, 202, 202, fontpage_166_202_202), // '半' -- '半' + FONTDATA_ITEM(166, 207, 207, fontpage_166_207_207), // '协' -- '协' + FONTDATA_ITEM(166, 213, 213, fontpage_166_213_213), // '单' -- '单' + FONTDATA_ITEM(166, 225, 225, fontpage_166_225_225), // '卡' -- '卡' + FONTDATA_ITEM(166, 240, 241, fontpage_166_240_241), // '印' -- '危' + FONTDATA_ITEM(166, 244, 244, fontpage_166_244_244), // '却' -- '却' + FONTDATA_ITEM(166, 248, 248, fontpage_166_248_248), // '卸' -- '卸' + FONTDATA_ITEM(167, 139, 139, fontpage_167_139_139), // '压' -- '压' + FONTDATA_ITEM(167, 159, 159, fontpage_167_159_159), // '原' -- '原' + FONTDATA_ITEM(167, 204, 205, fontpage_167_204_205), // '双' -- '反' + FONTDATA_ITEM(167, 214, 214, fontpage_167_214_214), // '取' -- '取' + FONTDATA_ITEM(167, 216, 216, fontpage_167_216_216), // '变' -- '变' + FONTDATA_ITEM(167, 240, 240, fontpage_167_240_240), // '台' -- '台' + FONTDATA_ITEM(168, 131, 131, fontpage_168_131_131), // '吃' -- '吃' + FONTDATA_ITEM(168, 136, 136, fontpage_168_136_136), // '合' -- '合' + FONTDATA_ITEM(168, 141, 142, fontpage_168_141_142), // '名' -- '后' + FONTDATA_ITEM(168, 145, 145, fontpage_168_145_145), // '向' -- '向' + FONTDATA_ITEM(168, 166, 166, fontpage_168_166_166), // '否' -- '否' + FONTDATA_ITEM(168, 175, 175, fontpage_168_175_175), // '启' -- '启' + FONTDATA_ITEM(168, 202, 202, fontpage_168_202_202), // '告' -- '告' + FONTDATA_ITEM(168, 232, 232, fontpage_168_232_232), // '周' -- '周' + FONTDATA_ITEM(168, 253, 253, fontpage_168_253_253), // '命' -- '命' + FONTDATA_ITEM(169, 140, 140, fontpage_169_140_140), // '和' -- '和' + FONTDATA_ITEM(169, 205, 205, fontpage_169_205_205), // '响' -- '响' + FONTDATA_ITEM(171, 183, 183, fontpage_171_183_183), // '喷' -- '喷' + FONTDATA_ITEM(172, 180, 180, fontpage_172_180_180), // '嘴' -- '嘴' + FONTDATA_ITEM(172, 232, 232, fontpage_172_232_232), // '器' -- '器' + FONTDATA_ITEM(172, 244, 244, fontpage_172_244_244), // '噴' -- '噴' + FONTDATA_ITEM(173, 222, 222, fontpage_173_222_222), // '回' -- '回' + FONTDATA_ITEM(173, 224, 224, fontpage_173_224_224), // '因' -- '因' + FONTDATA_ITEM(173, 250, 250, fontpage_173_250_250), // '固' -- '固' + FONTDATA_ITEM(173, 254, 254, fontpage_173_254_254), // '图' -- '图' + FONTDATA_ITEM(174, 168, 168, fontpage_174_168_168), // '在' -- '在' + FONTDATA_ITEM(174, 207, 207, fontpage_174_207_207), // '坏' -- '坏' + FONTDATA_ITEM(174, 215, 215, fontpage_174_215_215), // '块' -- '块' + FONTDATA_ITEM(175, 139, 139, fontpage_175_139_139), // '型' -- '型' + FONTDATA_ITEM(175, 171, 171, fontpage_175_171_171), // '垫' -- '垫' + FONTDATA_ITEM(176, 235, 235, fontpage_176_235_235), // '填' -- '填' + FONTDATA_ITEM(177, 243, 243, fontpage_177_243_243), // '壳' -- '壳' + FONTDATA_ITEM(178, 135, 135, fontpage_178_135_135), // '备' -- '备' + FONTDATA_ITEM(178, 141, 141, fontpage_178_141_141), // '复' -- '复' + FONTDATA_ITEM(178, 150, 150, fontpage_178_150_150), // '外' -- '外' + FONTDATA_ITEM(178, 154, 154, fontpage_178_154_154), // '多' -- '多' + FONTDATA_ITEM(178, 167, 167, fontpage_178_167_167), // '大' -- '大' + FONTDATA_ITEM(178, 169, 170, fontpage_178_169_170), // '天' -- '太' + FONTDATA_ITEM(178, 177, 177, fontpage_178_177_177), // '失' -- '失' + FONTDATA_ITEM(178, 180, 180, fontpage_178_180_180), // '头' -- '头' + FONTDATA_ITEM(178, 253, 253, fontpage_178_253_253), // '好' -- '好' + FONTDATA_ITEM(179, 203, 203, fontpage_179_203_203), // '始' -- '始' + FONTDATA_ITEM(182, 208, 208, fontpage_182_208_208), // '子' -- '子' + FONTDATA_ITEM(182, 216, 216, fontpage_182_216_216), // '存' -- '存' + FONTDATA_ITEM(183, 137, 137, fontpage_183_137_137), // '安' -- '安' + FONTDATA_ITEM(183, 140, 140, fontpage_183_140_140), // '完' -- '完' + FONTDATA_ITEM(183, 154, 154, fontpage_183_154_154), // '定' -- '定' + FONTDATA_ITEM(183, 162, 162, fontpage_183_162_162), // '客' -- '客' + FONTDATA_ITEM(183, 171, 171, fontpage_183_171_171), // '宫' -- '宫' + FONTDATA_ITEM(183, 249, 249, fontpage_183_249_249), // '对' -- '对' + FONTDATA_ITEM(184, 134, 134, fontpage_184_134_134), // '将' -- '将' + FONTDATA_ITEM(184, 143, 143, fontpage_184_143_143), // '小' -- '小' + FONTDATA_ITEM(184, 177, 177, fontpage_184_177_177), // '就' -- '就' + FONTDATA_ITEM(184, 207, 207, fontpage_184_207_207), // '屏' -- '屏' + FONTDATA_ITEM(187, 229, 229, fontpage_187_229_229), // '工' -- '工' + FONTDATA_ITEM(187, 238, 238, fontpage_187_238_238), // '差' -- '差' + FONTDATA_ITEM(187, 242, 242, fontpage_187_242_242), // '已' -- '已' + FONTDATA_ITEM(188, 243, 243, fontpage_188_243_243), // '平' -- '平' + FONTDATA_ITEM(188, 246, 246, fontpage_188_246_246), // '并' -- '并' + FONTDATA_ITEM(189, 138, 138, fontpage_189_138_138), // '床' -- '床' + FONTDATA_ITEM(189, 148, 148, fontpage_189_148_148), // '应' -- '应' + FONTDATA_ITEM(189, 159, 159, fontpage_189_159_159), // '废' -- '废' + FONTDATA_ITEM(189, 166, 166, fontpage_189_166_166), // '度' -- '度' + FONTDATA_ITEM(190, 128, 128, fontpage_190_128_128), // '开' -- '开' + FONTDATA_ITEM(190, 131, 131, fontpage_190_131_131), // '弃' -- '弃' + FONTDATA_ITEM(190, 143, 143, fontpage_190_143_143), // '式' -- '式' + FONTDATA_ITEM(190, 149, 149, fontpage_190_149_149), // '引' -- '引' + FONTDATA_ITEM(190, 185, 185, fontpage_190_185_185), // '弹' -- '弹' + FONTDATA_ITEM(190, 210, 210, fontpage_190_210_210), // '归' -- '归' + FONTDATA_ITEM(191, 132, 133, fontpage_191_132_133), // '径' -- '待' + FONTDATA_ITEM(191, 170, 170, fontpage_191_170_170), // '循' -- '循' + FONTDATA_ITEM(191, 174, 174, fontpage_191_174_174), // '微' -- '微' + FONTDATA_ITEM(191, 195, 195, fontpage_191_195_195), // '心' -- '心' + FONTDATA_ITEM(191, 253, 253, fontpage_191_253_253), // '忽' -- '忽' + FONTDATA_ITEM(192, 167, 167, fontpage_192_167_167), // '性' -- '性' + FONTDATA_ITEM(192, 187, 187, fontpage_192_187_187), // '总' -- '总' + FONTDATA_ITEM(192, 226, 226, fontpage_192_226_226), // '恢' -- '恢' + FONTDATA_ITEM(192, 239, 239, fontpage_192_239_239), // '息' -- '息' + FONTDATA_ITEM(194, 159, 159, fontpage_194_159_159), // '感' -- '感' + FONTDATA_ITEM(196, 143, 144, fontpage_196_143_144), // '戏' -- '成' + FONTDATA_ITEM(196, 183, 183, fontpage_196_183_183), // '户' -- '户' + FONTDATA_ITEM(196, 192, 192, fontpage_196_192_192), // '所' -- '所' + FONTDATA_ITEM(196, 199, 199, fontpage_196_199_199), // '扇' -- '扇' + FONTDATA_ITEM(196, 203, 203, fontpage_196_203_203), // '手' -- '手' + FONTDATA_ITEM(196, 211, 211, fontpage_196_211_211), // '打' -- '打' + FONTDATA_ITEM(196, 231, 231, fontpage_196_231_231), // '执' -- '执' + FONTDATA_ITEM(196, 249, 249, fontpage_196_249_249), // '批' -- '批' + FONTDATA_ITEM(197, 150, 150, fontpage_197_150_150), // '抖' -- '抖' + FONTDATA_ITEM(197, 165, 165, fontpage_197_165_165), // '报' -- '报' + FONTDATA_ITEM(197, 172, 172, fontpage_197_172_172), // '抬' -- '抬' + FONTDATA_ITEM(197, 189, 189, fontpage_197_189_189), // '抽' -- '抽' + FONTDATA_ITEM(197, 212, 212, fontpage_197_212_212), // '拔' -- '拔' + FONTDATA_ITEM(197, 233, 233, fontpage_197_233_233), // '择' -- '择' + FONTDATA_ITEM(198, 137, 137, fontpage_198_137_137), // '按' -- '按' + FONTDATA_ITEM(198, 161, 161, fontpage_198_161_161), // '挡' -- '挡' + FONTDATA_ITEM(198, 164, 164, fontpage_198_164_164), // '挤' -- '挤' + FONTDATA_ITEM(198, 223, 223, fontpage_198_223_223), // '损' -- '损' + FONTDATA_ITEM(198, 226, 226, fontpage_198_226_226), // '换' -- '换' + FONTDATA_ITEM(199, 137, 137, fontpage_199_137_137), // '掉' -- '掉' + FONTDATA_ITEM(199, 162, 162, fontpage_199_162_162), // '探' -- '探' + FONTDATA_ITEM(199, 165, 165, fontpage_199_165_165), // '接' -- '接' + FONTDATA_ITEM(199, 167, 167, fontpage_199_167_167), // '控' -- '控' + FONTDATA_ITEM(199, 208, 208, fontpage_199_208_208), // '提' -- '提' + FONTDATA_ITEM(199, 210, 210, fontpage_199_210_210), // '插' -- '插' + FONTDATA_ITEM(202, 182, 182, fontpage_202_182_182), // '收' -- '收' + FONTDATA_ITEM(202, 190, 190, fontpage_202_190_190), // '放' -- '放' + FONTDATA_ITEM(202, 240, 240, fontpage_202_240_240), // '数' -- '数' + FONTDATA_ITEM(202, 242, 242, fontpage_202_242_242), // '敲' -- '敲' + FONTDATA_ITEM(202, 244, 244, fontpage_202_244_244), // '整' -- '整' + FONTDATA_ITEM(203, 135, 135, fontpage_203_135_135), // '文' -- '文' + FONTDATA_ITEM(203, 153, 153, fontpage_203_153_153), // '料' -- '料' + FONTDATA_ITEM(203, 156, 156, fontpage_203_156_156), // '斜' -- '斜' + FONTDATA_ITEM(203, 173, 173, fontpage_203_173_173), // '断' -- '断' + FONTDATA_ITEM(203, 176, 176, fontpage_203_176_176), // '新' -- '新' + FONTDATA_ITEM(203, 185, 185, fontpage_203_185_185), // '方' -- '方' + FONTDATA_ITEM(203, 224, 224, fontpage_203_224_224), // '无' -- '无' + FONTDATA_ITEM(203, 246, 246, fontpage_203_246_246), // '时' -- '时' + FONTDATA_ITEM(204, 142, 142, fontpage_204_142_142), // '明' -- '明' + FONTDATA_ITEM(204, 175, 175, fontpage_204_175_175), // '是' -- '是' + FONTDATA_ITEM(205, 130, 130, fontpage_205_130_130), // '暂' -- '暂' + FONTDATA_ITEM(205, 171, 171, fontpage_205_171_171), // '暫' -- '暫' + FONTDATA_ITEM(205, 244, 244, fontpage_205_244_244), // '更' -- '更' + FONTDATA_ITEM(206, 128, 128, fontpage_206_128_128), // '最' -- '最' + FONTDATA_ITEM(206, 137, 137, fontpage_206_137_137), // '有' -- '有' + FONTDATA_ITEM(206, 159, 159, fontpage_206_159_159), // '期' -- '期' + FONTDATA_ITEM(206, 186, 186, fontpage_206_186_186), // '机' -- '机' + FONTDATA_ITEM(206, 192, 192, fontpage_206_192_192), // '杀' -- '杀' + FONTDATA_ITEM(206, 223, 223, fontpage_206_223_223), // '束' -- '束' + FONTDATA_ITEM(206, 225, 225, fontpage_206_225_225), // '条' -- '条' + FONTDATA_ITEM(206, 229, 229, fontpage_206_229_229), // '来' -- '来' + FONTDATA_ITEM(206, 255, 255, fontpage_206_255_255), // '板' -- '板' + FONTDATA_ITEM(207, 151, 151, fontpage_207_151_151), // '林' -- '林' + FONTDATA_ITEM(207, 241, 241, fontpage_207_241_241), // '柱' -- '柱' + FONTDATA_ITEM(208, 161, 161, fontpage_208_161_161), // '校' -- '校' + FONTDATA_ITEM(208, 188, 188, fontpage_208_188_188), // '格' -- '格' + FONTDATA_ITEM(209, 175, 175, fontpage_209_175_175), // '梯' -- '梯' + FONTDATA_ITEM(209, 192, 192, fontpage_209_192_192), // '检' -- '检' + FONTDATA_ITEM(211, 253, 253, fontpage_211_253_253), // '槽' -- '槽' + FONTDATA_ITEM(212, 161, 161, fontpage_212_161_161), // '模' -- '模' + FONTDATA_ITEM(212, 217, 217, fontpage_212_217_217), // '橙' -- '橙' + FONTDATA_ITEM(214, 226, 227, fontpage_214_226_227), // '止' -- '正' + FONTDATA_ITEM(214, 229, 229, fontpage_214_229_229), // '步' -- '步' + FONTDATA_ITEM(215, 212, 212, fontpage_215_212_212), // '比' -- '比' + FONTDATA_ITEM(217, 161, 161, fontpage_217_161_161), // '没' -- '没' + FONTDATA_ITEM(217, 226, 226, fontpage_217_226_226), // '波' -- '波' + FONTDATA_ITEM(217, 232, 232, fontpage_217_232_232), // '注' -- '注' + FONTDATA_ITEM(218, 151, 151, fontpage_218_151_151), // '洗' -- '洗' + FONTDATA_ITEM(218, 187, 187, fontpage_218_187_187), // '活' -- '活' + FONTDATA_ITEM(218, 193, 193, fontpage_218_193_193), // '流' -- '流' + FONTDATA_ITEM(218, 203, 203, fontpage_218_203_203), // '测' -- '测' + FONTDATA_ITEM(219, 136, 136, fontpage_219_136_136), // '消' -- '消' + FONTDATA_ITEM(219, 225, 225, fontpage_219_225_225), // '淡' -- '淡' + FONTDATA_ITEM(219, 247, 247, fontpage_219_247_247), // '混' -- '混' + FONTDATA_ITEM(220, 133, 133, fontpage_220_133_133), // '清' -- '清' + FONTDATA_ITEM(220, 169, 169, fontpage_220_169_169), // '温' -- '温' + FONTDATA_ITEM(220, 184, 184, fontpage_220_184_184), // '游' -- '游' + FONTDATA_ITEM(221, 144, 144, fontpage_221_144_144), // '源' -- '源' + FONTDATA_ITEM(221, 162, 162, fontpage_221_162_162), // '溢' -- '溢' + FONTDATA_ITEM(221, 209, 209, fontpage_221_209_209), // '滑' -- '滑' + FONTDATA_ITEM(222, 143, 143, fontpage_222_143_143), // '漏' -- '漏' + FONTDATA_ITEM(223, 192, 192, fontpage_223_192_192), // '激' -- '激' + FONTDATA_ITEM(224, 239, 239, fontpage_224_239_239), // '灯' -- '灯' + FONTDATA_ITEM(225, 185, 185, fontpage_225_185_185), // '点' -- '点' + FONTDATA_ITEM(225, 237, 237, fontpage_225_237_237), // '热' -- '热' + FONTDATA_ITEM(228, 199, 199, fontpage_228_199_199), // '片' -- '片' + FONTDATA_ITEM(228, 233, 233, fontpage_228_233_233), // '物' -- '物' + FONTDATA_ITEM(228, 249, 249, fontpage_228_249_249), // '特' -- '特' + FONTDATA_ITEM(231, 135, 135, fontpage_231_135_135), // '率' -- '率' + FONTDATA_ITEM(231, 175, 175, fontpage_231_175_175), // '环' -- '环' + FONTDATA_ITEM(234, 168, 168, fontpage_234_168_168), // '用' -- '用' + FONTDATA_ITEM(234, 181, 181, fontpage_234_181_181), // '电' -- '电' + FONTDATA_ITEM(234, 229, 229, fontpage_234_229_229), // '略' -- '略' + FONTDATA_ITEM(236, 253, 253, fontpage_236_253_253), // '白' -- '白' + FONTDATA_ITEM(237, 132, 132, fontpage_237_132_132), // '的' -- '的' + FONTDATA_ITEM(237, 209, 209, fontpage_237_209_209), // '监' -- '监' + FONTDATA_ITEM(237, 244, 244, fontpage_237_244_244), // '直' -- '直' + FONTDATA_ITEM(238, 129, 129, fontpage_238_129_129), // '省' -- '省' + FONTDATA_ITEM(238, 160, 160, fontpage_238_160_160), // '眠' -- '眠' + FONTDATA_ITEM(240, 238, 238, fontpage_240_238_238), // '确' -- '确' + FONTDATA_ITEM(243, 187, 187, fontpage_243_187_187), // '离' -- '离' + FONTDATA_ITEM(243, 251, 251, fontpage_243_251_251), // '移' -- '移' + FONTDATA_ITEM(244, 250, 250, fontpage_244_250_250), // '空' -- '空' + FONTDATA_ITEM(245, 239, 239, fontpage_245_239_239), // '端' -- '端' + FONTDATA_ITEM(246, 172, 172, fontpage_246_172_172), // '第' -- '第' + FONTDATA_ITEM(246, 201, 201, fontpage_246_201_201), // '等' -- '等' + FONTDATA_ITEM(247, 128, 128, fontpage_247_128_128), // '简' -- '简' + FONTDATA_ITEM(247, 177, 177, fontpage_247_177_177), // '箱' -- '箱' + FONTDATA_ITEM(248, 251, 251, fontpage_248_251_251), // '类' -- '类' + FONTDATA_ITEM(250, 162, 162, fontpage_250_162_162), // '索' -- '索' + FONTDATA_ITEM(250, 171, 171, fontpage_250_171_171), // '紫' -- '紫' + FONTDATA_ITEM(253, 162, 162, fontpage_253_162_162), // '红' -- '红' + FONTDATA_ITEM(253, 167, 167, fontpage_253_167_167), // '级' -- '级' + FONTDATA_ITEM(253, 191, 191, fontpage_253_191_191), // '线' -- '线' + FONTDATA_ITEM(253, 198, 198, fontpage_253_198_198), // '细' -- '细' + FONTDATA_ITEM(253, 200, 200, fontpage_253_200_200), // '终' -- '终' + FONTDATA_ITEM(253, 211, 211, fontpage_253_211_211), // '结' -- '结' + FONTDATA_ITEM(253, 217, 217, fontpage_253_217_217), // '给' -- '给' + FONTDATA_ITEM(253, 223, 223, fontpage_253_223_223), // '统' -- '统' + FONTDATA_ITEM(253, 231, 231, fontpage_253_231_231), // '继' -- '继' + FONTDATA_ITEM(253, 234, 234, fontpage_253_234_234), // '绪' -- '绪' + FONTDATA_ITEM(253, 237, 237, fontpage_253_237_237), // '续' -- '续' + FONTDATA_ITEM(253, 255, 255, fontpage_253_255_255), // '绿' -- '绿' + FONTDATA_ITEM(254, 150, 150, fontpage_254_150_150), // '编' -- '编' + FONTDATA_ITEM(254, 186, 186, fontpage_254_186_186), // '缺' -- '缺' + FONTDATA_ITEM(254, 209, 209, fontpage_254_209_209), // '网' -- '网' + FONTDATA_ITEM(254, 238, 238, fontpage_254_238_238), // '置' -- '置' + FONTDATA_ITEM(254, 242, 242, fontpage_254_242_242), // '署' -- '署' + FONTDATA_ITEM(256, 133, 133, fontpage_256_133_133), // '者' -- '者' + FONTDATA_ITEM(256, 234, 234, fontpage_256_234_234), // '聪' -- '聪' + FONTDATA_ITEM(257, 253, 253, fontpage_257_253_253), // '能' -- '能' + FONTDATA_ITEM(259, 234, 234, fontpage_259_234_234), // '自' -- '自' + FONTDATA_ITEM(259, 243, 243, fontpage_259_243_243), // '至' -- '至' + FONTDATA_ITEM(263, 220, 220, fontpage_263_220_220), // '菜' -- '菜' + FONTDATA_ITEM(265, 221, 221, fontpage_265_221_221), // '蓝' -- '蓝' + FONTDATA_ITEM(269, 199, 199, fontpage_269_199_199), // '蛇' -- '蛇' + FONTDATA_ITEM(272, 204, 204, fontpage_272_204_204), // '行' -- '行' + FONTDATA_ITEM(273, 171, 171, fontpage_273_171_171), // '被' -- '被' + FONTDATA_ITEM(273, 197, 197, fontpage_273_197_197), // '装' -- '装' + FONTDATA_ITEM(275, 129, 129, fontpage_275_129_129), // '要' -- '要' + FONTDATA_ITEM(275, 210, 210, fontpage_275_210_210), // '角' -- '角' + FONTDATA_ITEM(279, 161, 161, fontpage_279_161_161), // '计' -- '计' + FONTDATA_ITEM(279, 174, 174, fontpage_279_174_174), // '议' -- '议' + FONTDATA_ITEM(279, 190, 190, fontpage_279_190_190), // '设' -- '设' + FONTDATA_ITEM(279, 213, 213, fontpage_279_213_213), // '试' -- '试' + FONTDATA_ITEM(279, 239, 239, fontpage_279_239_239), // '误' -- '误' + FONTDATA_ITEM(279, 247, 247, fontpage_279_247_247), // '请' -- '请' + FONTDATA_ITEM(279, 251, 251, fontpage_279_251_251), // '读' -- '读' + FONTDATA_ITEM(280, 131, 131, fontpage_280_131_131), // '调' -- '调' + FONTDATA_ITEM(282, 165, 165, fontpage_282_165_165), // '败' -- '败' + FONTDATA_ITEM(282, 170, 170, fontpage_282_170_170), // '贪' -- '贪' + FONTDATA_ITEM(282, 247, 247, fontpage_282_247_247), // '起' -- '起' + FONTDATA_ITEM(283, 133, 133, fontpage_283_133_133), // '超' -- '超' + FONTDATA_ITEM(283, 221, 221, fontpage_283_221_221), // '距' -- '距' + FONTDATA_ITEM(286, 236, 236, fontpage_286_236_236), // '转' -- '转' + FONTDATA_ITEM(286, 239, 239, fontpage_286_239_239), // '软' -- '软' + FONTDATA_ITEM(286, 244, 244, fontpage_286_244_244), // '轴' -- '轴' + FONTDATA_ITEM(286, 253, 253, fontpage_286_253_253), // '载' -- '载' + FONTDATA_ITEM(287, 145, 145, fontpage_287_145_145), // '辑' -- '辑' + FONTDATA_ITEM(287, 147, 147, fontpage_287_147_147), // '输' -- '输' + FONTDATA_ITEM(287, 185, 185, fontpage_287_185_185), // '边' -- '边' + FONTDATA_ITEM(287, 193, 193, fontpage_287_193_193), // '迁' -- '迁' + FONTDATA_ITEM(287, 208, 209, fontpage_287_208_209), // '运' -- '近' + FONTDATA_ITEM(287, 212, 212, fontpage_287_212_212), // '返' -- '返' + FONTDATA_ITEM(287, 216, 216, fontpage_287_216_216), // '还' -- '还' + FONTDATA_ITEM(287, 219, 219, fontpage_287_219_219), // '进' -- '进' + FONTDATA_ITEM(287, 222, 222, fontpage_287_222_222), // '连' -- '连' + FONTDATA_ITEM(287, 247, 247, fontpage_287_247_247), // '迷' -- '迷' + FONTDATA_ITEM(288, 128, 128, fontpage_288_128_128), // '退' -- '退' + FONTDATA_ITEM(288, 137, 137, fontpage_288_137_137), // '选' -- '选' + FONTDATA_ITEM(288, 159, 159, fontpage_288_159_159), // '速' -- '速' + FONTDATA_ITEM(289, 232, 232, fontpage_289_232_232), // '部' -- '部' + FONTDATA_ITEM(290, 205, 205, fontpage_290_205_205), // '配' -- '配' + FONTDATA_ITEM(291, 202, 202, fontpage_291_202_202), // '释' -- '释' + FONTDATA_ITEM(291, 205, 205, fontpage_291_205_205), // '重' -- '重' + FONTDATA_ITEM(291, 207, 207, fontpage_291_207_207), // '量' -- '量' + FONTDATA_ITEM(297, 136, 136, fontpage_297_136_136), // '针' -- '针' + FONTDATA_ITEM(297, 174, 174, fontpage_297_174_174), // '钮' -- '钮' + FONTDATA_ITEM(298, 153, 153, fontpage_298_153_153), // '错' -- '错' + FONTDATA_ITEM(298, 220, 220, fontpage_298_220_220), // '镜' -- '镜' + FONTDATA_ITEM(298, 255, 255, fontpage_298_255_255), // '长' -- '长' + FONTDATA_ITEM(299, 237, 237, fontpage_299_237_237), // '闭' -- '闭' + FONTDATA_ITEM(299, 242, 242, fontpage_299_242_242), // '闲' -- '闲' + FONTDATA_ITEM(299, 244, 244, fontpage_299_244_244), // '间' -- '间' + FONTDATA_ITEM(300, 136, 136, fontpage_300_136_136), // '阈' -- '阈' + FONTDATA_ITEM(300, 205, 205, fontpage_300_205_205), // '降' -- '降' + FONTDATA_ITEM(300, 208, 208, fontpage_300_208_208), // '限' -- '限' + FONTDATA_ITEM(300, 228, 228, fontpage_300_228_228), // '除' -- '除' + FONTDATA_ITEM(300, 233, 233, fontpage_300_233_233), // '险' -- '险' + FONTDATA_ITEM(301, 246, 246, fontpage_301_246_246), // '零' -- '零' + FONTDATA_ITEM(302, 128, 128, fontpage_302_128_128), // '需' -- '需' + FONTDATA_ITEM(302, 210, 210, fontpage_302_210_210), // '青' -- '青' + FONTDATA_ITEM(302, 222, 222, fontpage_302_222_222), // '非' -- '非' + FONTDATA_ITEM(302, 224, 224, fontpage_302_224_224), // '靠' -- '靠' + FONTDATA_ITEM(302, 226, 226, fontpage_302_226_226), // '面' -- '面' + FONTDATA_ITEM(304, 245, 245, fontpage_304_245_245), // '页' -- '页' + FONTDATA_ITEM(304, 249, 249, fontpage_304_249_249), // '项' -- '项' + FONTDATA_ITEM(305, 132, 132, fontpage_305_132_132), // '预' -- '预' + FONTDATA_ITEM(305, 145, 145, fontpage_305_145_145), // '频' -- '频' + FONTDATA_ITEM(305, 157, 157, fontpage_305_157_157), // '额' -- '额' + FONTDATA_ITEM(305, 206, 206, fontpage_305_206_206), // '风' -- '风' + FONTDATA_ITEM(306, 241, 241, fontpage_306_241_241), // '饱' -- '饱' + FONTDATA_ITEM(308, 236, 236, fontpage_308_236_236), // '马' -- '马' + FONTDATA_ITEM(308, 241, 241, fontpage_308_241_241), // '驱' -- '驱' + FONTDATA_ITEM(309, 216, 216, fontpage_309_216_216), // '高' -- '高' + FONTDATA_ITEM(317, 196, 196, fontpage_317_196_196), // '黄' -- '黄' + FONTDATA_ITEM(317, 222, 222, fontpage_317_222_222), // '點' -- '點' + FONTDATA_ITEM(318, 208, 208, fontpage_318_208_208), // '齐' -- '齐' + FONTDATA_ITEM(510, 154, 154, fontpage_510_154_154), // ':' -- ':' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_zh_TW.h b/Marlin/src/lcd/dogm/fontdata/langdata_zh_TW.h index 8eee544ec8..093629cd16 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_zh_TW.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_zh_TW.h @@ -3,7 +3,9 @@ * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#pragma once + +#include "langdata.h" const u8g_fntpgm_uint8_t fontpage_69_191_191[28] U8G_FONT_SECTION("fontpage_69_191_191") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xBF,0xBF,0x00,0x05,0x00,0x00, @@ -1217,305 +1219,304 @@ const u8g_fntpgm_uint8_t fontpage_510_154_154[30] U8G_FONT_SECTION("fontpage_510 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x9A,0x9A,0x00,0x08,0x00,0x00, 0x00,0x02,0x07,0x07,0x0C,0x06,0x01,0xC0,0xC0,0x00,0x00,0x00,0xC0,0xC0}; -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = { - FONTDATA_ITEM(69, 191, 191, fontpage_69_191_191), // '⊿' -- '⊿' - FONTDATA_ITEM(156, 128, 128, fontpage_156_128_128), // '一' -- '一' - FONTDATA_ITEM(156, 137, 139, fontpage_156_137_139), // '三' -- '下' - FONTDATA_ITEM(156, 141, 141, fontpage_156_141_141), // '不' -- '不' - FONTDATA_ITEM(156, 166, 166, fontpage_156_166_166), // '並' -- '並' - FONTDATA_ITEM(156, 173, 173, fontpage_156_173_173), // '中' -- '中' - FONTDATA_ITEM(156, 187, 187, fontpage_156_187_187), // '主' -- '主' - FONTDATA_ITEM(156, 203, 203, fontpage_156_203_203), // '之' -- '之' - FONTDATA_ITEM(157, 164, 164, fontpage_157_164_164), // '交' -- '交' - FONTDATA_ITEM(157, 174, 174, fontpage_157_174_174), // '亮' -- '亮' - FONTDATA_ITEM(157, 228, 228, fontpage_157_228_228), // '令' -- '令' - FONTDATA_ITEM(157, 246, 246, fontpage_157_246_246), // '件' -- '件' - FONTDATA_ITEM(157, 253, 253, fontpage_157_253_253), // '份' -- '份' - FONTDATA_ITEM(158, 145, 145, fontpage_158_145_145), // '休' -- '休' - FONTDATA_ITEM(158, 205, 206, fontpage_158_205_206), // '位' -- '低' - FONTDATA_ITEM(158, 220, 220, fontpage_158_220_220), // '作' -- '作' - FONTDATA_ITEM(159, 155, 155, fontpage_159_155_155), // '供' -- '供' - FONTDATA_ITEM(159, 221, 221, fontpage_159_221_221), // '保' -- '保' - FONTDATA_ITEM(159, 225, 225, fontpage_159_225_225), // '信' -- '信' - FONTDATA_ITEM(160, 139, 139, fontpage_160_139_139), // '個' -- '個' - FONTDATA_ITEM(160, 188, 188, fontpage_160_188_188), // '值' -- '值' - FONTDATA_ITEM(160, 207, 207, fontpage_160_207_207), // '偏' -- '偏' - FONTDATA_ITEM(160, 220, 220, fontpage_160_220_220), // '停' -- '停' - FONTDATA_ITEM(160, 245, 245, fontpage_160_245_245), // '偵' -- '偵' - FONTDATA_ITEM(161, 153, 153, fontpage_161_153_153), // '備' -- '備' - FONTDATA_ITEM(161, 179, 179, fontpage_161_179_179), // '傳' -- '傳' - FONTDATA_ITEM(161, 190, 190, fontpage_161_190_190), // '傾' -- '傾' - FONTDATA_ITEM(162, 178, 178, fontpage_162_178_178), // '儲' -- '儲' - FONTDATA_ITEM(162, 197, 197, fontpage_162_197_197), // '充' -- '充' - FONTDATA_ITEM(162, 200, 201, fontpage_162_200_201), // '先' -- '光' - FONTDATA_ITEM(162, 229, 229, fontpage_162_229_229), // '入' -- '入' - FONTDATA_ITEM(162, 232, 232, fontpage_162_232_232), // '全' -- '全' - FONTDATA_ITEM(162, 241, 241, fontpage_162_241_241), // '共' -- '共' - FONTDATA_ITEM(162, 247, 247, fontpage_162_247_247), // '具' -- '具' - FONTDATA_ITEM(163, 151, 151, fontpage_163_151_151), // '冗' -- '冗' - FONTDATA_ITEM(163, 183, 183, fontpage_163_183_183), // '冷' -- '冷' - FONTDATA_ITEM(163, 198, 198, fontpage_163_198_198), // '准' -- '准' - FONTDATA_ITEM(163, 250, 250, fontpage_163_250_250), // '出' -- '出' - FONTDATA_ITEM(164, 134, 134, fontpage_164_134_134), // '分' -- '分' - FONTDATA_ITEM(164, 151, 151, fontpage_164_151_151), // '列' -- '列' - FONTDATA_ITEM(164, 157, 157, fontpage_164_157_157), // '初' -- '初' - FONTDATA_ITEM(164, 176, 176, fontpage_164_176_176), // '到' -- '到' - FONTDATA_ITEM(164, 182, 183, fontpage_164_182_183), // '制' -- '刷' - FONTDATA_ITEM(164, 245, 245, fontpage_164_245_245), // '創' -- '創' - FONTDATA_ITEM(165, 155, 155, fontpage_165_155_155), // '力' -- '力' - FONTDATA_ITEM(165, 160, 160, fontpage_165_160_160), // '加' -- '加' - FONTDATA_ITEM(165, 213, 213, fontpage_165_213_213), // '動' -- '動' - FONTDATA_ITEM(166, 150, 150, fontpage_166_150_150), // '化' -- '化' - FONTDATA_ITEM(166, 202, 202, fontpage_166_202_202), // '半' -- '半' - FONTDATA_ITEM(166, 212, 212, fontpage_166_212_212), // '協' -- '協' - FONTDATA_ITEM(166, 225, 225, fontpage_166_225_225), // '卡' -- '卡' - FONTDATA_ITEM(166, 240, 240, fontpage_166_240_240), // '印' -- '印' - FONTDATA_ITEM(166, 248, 248, fontpage_166_248_248), // '卸' -- '卸' - FONTDATA_ITEM(166, 251, 251, fontpage_166_251_251), // '卻' -- '卻' - FONTDATA_ITEM(167, 159, 159, fontpage_167_159_159), // '原' -- '原' - FONTDATA_ITEM(167, 205, 205, fontpage_167_205_205), // '反' -- '反' - FONTDATA_ITEM(167, 214, 214, fontpage_167_214_214), // '取' -- '取' - FONTDATA_ITEM(167, 240, 240, fontpage_167_240_240), // '台' -- '台' - FONTDATA_ITEM(168, 136, 136, fontpage_168_136_136), // '合' -- '合' - FONTDATA_ITEM(168, 166, 166, fontpage_168_166_166), // '否' -- '否' - FONTDATA_ITEM(168, 202, 202, fontpage_168_202_202), // '告' -- '告' - FONTDATA_ITEM(168, 253, 253, fontpage_168_253_253), // '命' -- '命' - FONTDATA_ITEM(169, 140, 140, fontpage_169_140_140), // '和' -- '和' - FONTDATA_ITEM(170, 223, 223, fontpage_170_223_223), // '啟' -- '啟' - FONTDATA_ITEM(171, 174, 174, fontpage_171_174_174), // '單' -- '單' - FONTDATA_ITEM(172, 180, 180, fontpage_172_180_180), // '嘴' -- '嘴' - FONTDATA_ITEM(172, 232, 232, fontpage_172_232_232), // '器' -- '器' - FONTDATA_ITEM(172, 244, 244, fontpage_172_244_244), // '噴' -- '噴' - FONTDATA_ITEM(173, 222, 222, fontpage_173_222_222), // '回' -- '回' - FONTDATA_ITEM(173, 224, 224, fontpage_173_224_224), // '因' -- '因' - FONTDATA_ITEM(173, 250, 250, fontpage_173_250_250), // '固' -- '固' - FONTDATA_ITEM(174, 150, 150, fontpage_174_150_150), // '圖' -- '圖' - FONTDATA_ITEM(174, 168, 168, fontpage_174_168_168), // '在' -- '在' - FONTDATA_ITEM(175, 139, 139, fontpage_175_139_139), // '型' -- '型' - FONTDATA_ITEM(175, 247, 247, fontpage_175_247_247), // '執' -- '執' - FONTDATA_ITEM(176, 202, 202, fontpage_176_202_202), // '塊' -- '塊' - FONTDATA_ITEM(176, 235, 235, fontpage_176_235_235), // '填' -- '填' - FONTDATA_ITEM(177, 138, 138, fontpage_177_138_138), // '墊' -- '墊' - FONTDATA_ITEM(178, 150, 150, fontpage_178_150_150), // '外' -- '外' - FONTDATA_ITEM(178, 154, 154, fontpage_178_154_154), // '多' -- '多' - FONTDATA_ITEM(178, 160, 160, fontpage_178_160_160), // '夠' -- '夠' - FONTDATA_ITEM(178, 167, 167, fontpage_178_167_167), // '大' -- '大' - FONTDATA_ITEM(178, 169, 170, fontpage_178_169_170), // '天' -- '太' - FONTDATA_ITEM(178, 177, 177, fontpage_178_177_177), // '失' -- '失' - FONTDATA_ITEM(179, 203, 203, fontpage_179_203_203), // '始' -- '始' - FONTDATA_ITEM(181, 146, 146, fontpage_181_146_146), // '媒' -- '媒' - FONTDATA_ITEM(182, 208, 208, fontpage_182_208_208), // '子' -- '子' - FONTDATA_ITEM(182, 216, 216, fontpage_182_216_216), // '存' -- '存' - FONTDATA_ITEM(183, 137, 137, fontpage_183_137_137), // '安' -- '安' - FONTDATA_ITEM(183, 140, 140, fontpage_183_140_140), // '完' -- '完' - FONTDATA_ITEM(183, 154, 154, fontpage_183_154_154), // '定' -- '定' - FONTDATA_ITEM(183, 162, 162, fontpage_183_162_162), // '客' -- '客' - FONTDATA_ITEM(183, 185, 185, fontpage_183_185_185), // '容' -- '容' - FONTDATA_ITEM(184, 141, 141, fontpage_184_141_141), // '對' -- '對' - FONTDATA_ITEM(184, 143, 143, fontpage_184_143_143), // '小' -- '小' - FONTDATA_ITEM(184, 177, 177, fontpage_184_177_177), // '就' -- '就' - FONTDATA_ITEM(187, 229, 229, fontpage_187_229_229), // '工' -- '工' - FONTDATA_ITEM(187, 238, 238, fontpage_187_238_238), // '差' -- '差' - FONTDATA_ITEM(187, 242, 242, fontpage_187_242_242), // '已' -- '已' - FONTDATA_ITEM(188, 243, 243, fontpage_188_243_243), // '平' -- '平' - FONTDATA_ITEM(189, 138, 138, fontpage_189_138_138), // '床' -- '床' - FONTDATA_ITEM(189, 166, 166, fontpage_189_166_166), // '度' -- '度' - FONTDATA_ITEM(189, 226, 226, fontpage_189_226_226), // '廢' -- '廢' - FONTDATA_ITEM(189, 250, 250, fontpage_189_250_250), // '建' -- '建' - FONTDATA_ITEM(190, 149, 149, fontpage_190_149_149), // '引' -- '引' - FONTDATA_ITEM(191, 133, 133, fontpage_191_133_133), // '待' -- '待' - FONTDATA_ITEM(191, 140, 140, fontpage_191_140_140), // '後' -- '後' - FONTDATA_ITEM(191, 145, 145, fontpage_191_145_145), // '徑' -- '徑' - FONTDATA_ITEM(191, 158, 158, fontpage_191_158_158), // '從' -- '從' - FONTDATA_ITEM(191, 169, 169, fontpage_191_169_169), // '復' -- '復' - FONTDATA_ITEM(191, 174, 174, fontpage_191_174_174), // '微' -- '微' - FONTDATA_ITEM(191, 195, 195, fontpage_191_195_195), // '心' -- '心' - FONTDATA_ITEM(192, 167, 167, fontpage_192_167_167), // '性' -- '性' - FONTDATA_ITEM(192, 226, 226, fontpage_192_226_226), // '恢' -- '恢' - FONTDATA_ITEM(192, 239, 239, fontpage_192_239_239), // '息' -- '息' - FONTDATA_ITEM(195, 182, 182, fontpage_195_182_182), // '憶' -- '憶' - FONTDATA_ITEM(195, 201, 201, fontpage_195_201_201), // '應' -- '應' - FONTDATA_ITEM(196, 144, 144, fontpage_196_144_144), // '成' -- '成' - FONTDATA_ITEM(196, 182, 182, fontpage_196_182_182), // '戶' -- '戶' - FONTDATA_ITEM(196, 192, 192, fontpage_196_192_192), // '所' -- '所' - FONTDATA_ITEM(196, 199, 199, fontpage_196_199_199), // '扇' -- '扇' - FONTDATA_ITEM(196, 203, 203, fontpage_196_203_203), // '手' -- '手' - FONTDATA_ITEM(196, 211, 211, fontpage_196_211_211), // '打' -- '打' - FONTDATA_ITEM(196, 249, 249, fontpage_196_249_249), // '批' -- '批' - FONTDATA_ITEM(197, 150, 150, fontpage_197_150_150), // '抖' -- '抖' - FONTDATA_ITEM(197, 189, 189, fontpage_197_189_189), // '抽' -- '抽' - FONTDATA_ITEM(197, 212, 212, fontpage_197_212_212), // '拔' -- '拔' - FONTDATA_ITEM(198, 137, 137, fontpage_198_137_137), // '按' -- '按' - FONTDATA_ITEM(199, 137, 137, fontpage_199_137_137), // '掉' -- '掉' - FONTDATA_ITEM(199, 162, 162, fontpage_199_162_162), // '探' -- '探' - FONTDATA_ITEM(199, 165, 165, fontpage_199_165_165), // '接' -- '接' - FONTDATA_ITEM(199, 167, 167, fontpage_199_167_167), // '控' -- '控' - FONTDATA_ITEM(199, 208, 208, fontpage_199_208_208), // '提' -- '提' - FONTDATA_ITEM(199, 210, 210, fontpage_199_210_210), // '插' -- '插' - FONTDATA_ITEM(199, 219, 219, fontpage_199_219_219), // '換' -- '換' - FONTDATA_ITEM(201, 199, 199, fontpage_201_199_199), // '擇' -- '擇' - FONTDATA_ITEM(201, 202, 203, fontpage_201_202_203), // '擊' -- '擋' - FONTDATA_ITEM(201, 224, 224, fontpage_201_224_224), // '擠' -- '擠' - FONTDATA_ITEM(202, 182, 182, fontpage_202_182_182), // '收' -- '收' - FONTDATA_ITEM(202, 190, 190, fontpage_202_190_190), // '放' -- '放' - FONTDATA_ITEM(202, 215, 215, fontpage_202_215_215), // '敗' -- '敗' - FONTDATA_ITEM(202, 244, 244, fontpage_202_244_244), // '整' -- '整' - FONTDATA_ITEM(202, 248, 248, fontpage_202_248_248), // '數' -- '數' - FONTDATA_ITEM(203, 153, 153, fontpage_203_153_153), // '料' -- '料' - FONTDATA_ITEM(203, 156, 156, fontpage_203_156_156), // '斜' -- '斜' - FONTDATA_ITEM(203, 176, 176, fontpage_203_176_176), // '新' -- '新' - FONTDATA_ITEM(203, 183, 183, fontpage_203_183_183), // '斷' -- '斷' - FONTDATA_ITEM(203, 188, 188, fontpage_203_188_188), // '於' -- '於' - FONTDATA_ITEM(204, 135, 135, fontpage_204_135_135), // '昇' -- '昇' - FONTDATA_ITEM(204, 142, 142, fontpage_204_142_142), // '明' -- '明' - FONTDATA_ITEM(204, 175, 175, fontpage_204_175_175), // '是' -- '是' - FONTDATA_ITEM(204, 194, 194, fontpage_204_194_194), // '時' -- '時' - FONTDATA_ITEM(205, 171, 171, fontpage_205_171_171), // '暫' -- '暫' - FONTDATA_ITEM(205, 244, 244, fontpage_205_244_244), // '更' -- '更' - FONTDATA_ITEM(206, 128, 128, fontpage_206_128_128), // '最' -- '最' - FONTDATA_ITEM(206, 137, 137, fontpage_206_137_137), // '有' -- '有' - FONTDATA_ITEM(206, 255, 255, fontpage_206_255_255), // '板' -- '板' - FONTDATA_ITEM(207, 241, 241, fontpage_207_241_241), // '柱' -- '柱' - FONTDATA_ITEM(208, 161, 161, fontpage_208_161_161), // '校' -- '校' - FONTDATA_ITEM(208, 188, 188, fontpage_208_188_188), // '格' -- '格' - FONTDATA_ITEM(209, 157, 157, fontpage_209_157_157), // '條' -- '條' - FONTDATA_ITEM(209, 196, 196, fontpage_209_196_196), // '棄' -- '棄' - FONTDATA_ITEM(211, 253, 253, fontpage_211_253_253), // '槽' -- '槽' - FONTDATA_ITEM(212, 217, 217, fontpage_212_217_217), // '橙' -- '橙' - FONTDATA_ITEM(212, 223, 223, fontpage_212_223_223), // '機' -- '機' - FONTDATA_ITEM(213, 162, 162, fontpage_213_162_162), // '檢' -- '檢' - FONTDATA_ITEM(214, 226, 227, fontpage_214_226_227), // '止' -- '正' - FONTDATA_ITEM(214, 229, 229, fontpage_214_229_229), // '步' -- '步' - FONTDATA_ITEM(214, 248, 248, fontpage_214_248_248), // '歸' -- '歸' - FONTDATA_ITEM(215, 188, 188, fontpage_215_188_188), // '殼' -- '殼' - FONTDATA_ITEM(215, 212, 212, fontpage_215_212_212), // '比' -- '比' - FONTDATA_ITEM(217, 146, 146, fontpage_217_146_146), // '沒' -- '沒' - FONTDATA_ITEM(219, 136, 136, fontpage_219_136_136), // '消' -- '消' - FONTDATA_ITEM(219, 225, 225, fontpage_219_225_225), // '淡' -- '淡' - FONTDATA_ITEM(220, 133, 133, fontpage_220_133_133), // '清' -- '清' - FONTDATA_ITEM(220, 172, 172, fontpage_220_172_172), // '測' -- '測' - FONTDATA_ITEM(221, 144, 144, fontpage_221_144_144), // '源' -- '源' - FONTDATA_ITEM(221, 150, 150, fontpage_221_150_150), // '準' -- '準' - FONTDATA_ITEM(221, 171, 171, fontpage_221_171_171), // '溫' -- '溫' - FONTDATA_ITEM(223, 192, 192, fontpage_223_192_192), // '激' -- '激' - FONTDATA_ITEM(226, 161, 161, fontpage_226_161_161), // '無' -- '無' - FONTDATA_ITEM(227, 177, 177, fontpage_227_177_177), // '熱' -- '熱' - FONTDATA_ITEM(227, 200, 200, fontpage_227_200_200), // '燈' -- '燈' - FONTDATA_ITEM(228, 199, 199, fontpage_228_199_199), // '片' -- '片' - FONTDATA_ITEM(228, 233, 233, fontpage_228_233_233), // '物' -- '物' - FONTDATA_ITEM(231, 135, 135, fontpage_231_135_135), // '率' -- '率' - FONTDATA_ITEM(234, 168, 168, fontpage_234_168_168), // '用' -- '用' - FONTDATA_ITEM(234, 204, 204, fontpage_234_204_204), // '界' -- '界' - FONTDATA_ITEM(236, 253, 253, fontpage_236_253_253), // '白' -- '白' - FONTDATA_ITEM(237, 132, 132, fontpage_237_132_132), // '的' -- '的' - FONTDATA_ITEM(237, 227, 227, fontpage_237_227_227), // '監' -- '監' - FONTDATA_ITEM(237, 244, 244, fontpage_237_244_244), // '直' -- '直' - FONTDATA_ITEM(238, 160, 160, fontpage_238_160_160), // '眠' -- '眠' - FONTDATA_ITEM(240, 141, 141, fontpage_240_141_141), // '砍' -- '砍' - FONTDATA_ITEM(241, 186, 186, fontpage_241_186_186), // '確' -- '確' - FONTDATA_ITEM(243, 251, 251, fontpage_243_251_251), // '移' -- '移' - FONTDATA_ITEM(244, 205, 205, fontpage_244_205_205), // '積' -- '積' - FONTDATA_ITEM(245, 239, 239, fontpage_245_239_239), // '端' -- '端' - FONTDATA_ITEM(246, 201, 201, fontpage_246_201_201), // '等' -- '等' - FONTDATA_ITEM(247, 161, 161, fontpage_247_161_161), // '管' -- '管' - FONTDATA_ITEM(247, 177, 177, fontpage_247_177_177), // '箱' -- '箱' - FONTDATA_ITEM(249, 251, 251, fontpage_249_251_251), // '系' -- '系' - FONTDATA_ITEM(250, 133, 133, fontpage_250_133_133), // '紅' -- '紅' - FONTDATA_ITEM(250, 162, 162, fontpage_250_162_162), // '索' -- '索' - FONTDATA_ITEM(250, 171, 171, fontpage_250_171_171), // '紫' -- '紫' - FONTDATA_ITEM(250, 176, 176, fontpage_250_176_176), // '細' -- '細' - FONTDATA_ITEM(250, 194, 194, fontpage_250_194_194), // '終' -- '終' - FONTDATA_ITEM(250, 241, 242, fontpage_250_241_242), // '統' -- '絲' - FONTDATA_ITEM(251, 160, 160, fontpage_251_160_160), // '綠' -- '綠' - FONTDATA_ITEM(251, 178, 178, fontpage_251_178_178), // '網' -- '網' - FONTDATA_ITEM(251, 210, 210, fontpage_251_210_210), // '緒' -- '緒' - FONTDATA_ITEM(251, 218, 218, fontpage_251_218_218), // '線' -- '線' - FONTDATA_ITEM(251, 232, 232, fontpage_251_232_232), // '編' -- '編' - FONTDATA_ITEM(252, 174, 174, fontpage_252_174_174), // '縮' -- '縮' - FONTDATA_ITEM(252, 189, 189, fontpage_252_189_189), // '總' -- '總' - FONTDATA_ITEM(252, 252, 252, fontpage_252_252_252), // '繼' -- '繼' - FONTDATA_ITEM(253, 140, 140, fontpage_253_140_140), // '續' -- '續' - FONTDATA_ITEM(253, 162, 162, fontpage_253_162_162), // '红' -- '红' - FONTDATA_ITEM(254, 238, 238, fontpage_254_238_238), // '置' -- '置' - FONTDATA_ITEM(254, 242, 242, fontpage_254_242_242), // '署' -- '署' - FONTDATA_ITEM(256, 240, 240, fontpage_256_240_240), // '聰' -- '聰' - FONTDATA_ITEM(259, 234, 234, fontpage_259_234_234), // '自' -- '自' - FONTDATA_ITEM(267, 205, 205, fontpage_267_205_205), // '藍' -- '藍' - FONTDATA_ITEM(272, 204, 204, fontpage_272_204_204), // '行' -- '行' - FONTDATA_ITEM(272, 232, 232, fontpage_272_232_232), // '表' -- '表' - FONTDATA_ITEM(273, 171, 171, fontpage_273_171_171), // '被' -- '被' - FONTDATA_ITEM(273, 197, 197, fontpage_273_197_197), // '装' -- '装' - FONTDATA_ITEM(273, 221, 221, fontpage_273_221_221), // '裝' -- '裝' - FONTDATA_ITEM(274, 135, 135, fontpage_274_135_135), // '複' -- '複' - FONTDATA_ITEM(275, 210, 210, fontpage_275_210_210), // '角' -- '角' - FONTDATA_ITEM(276, 136, 136, fontpage_276_136_136), // '計' -- '計' - FONTDATA_ITEM(276, 138, 138, fontpage_276_138_138), // '訊' -- '訊' - FONTDATA_ITEM(276, 152, 152, fontpage_276_152_152), // '記' -- '記' - FONTDATA_ITEM(276, 173, 173, fontpage_276_173_173), // '設' -- '設' - FONTDATA_ITEM(276, 230, 230, fontpage_276_230_230), // '試' -- '試' - FONTDATA_ITEM(277, 141, 141, fontpage_277_141_141), // '認' -- '認' - FONTDATA_ITEM(277, 164, 164, fontpage_277_164_164), // '誤' -- '誤' - FONTDATA_ITEM(277, 191, 191, fontpage_277_191_191), // '調' -- '調' - FONTDATA_ITEM(277, 203, 203, fontpage_277_203_203), // '請' -- '請' - FONTDATA_ITEM(278, 240, 240, fontpage_278_240_240), // '議' -- '議' - FONTDATA_ITEM(279, 128, 128, fontpage_279_128_128), // '讀' -- '讀' - FONTDATA_ITEM(279, 138, 138, fontpage_279_138_138), // '變' -- '變' - FONTDATA_ITEM(281, 199, 199, fontpage_281_199_199), // '資' -- '資' - FONTDATA_ITEM(283, 221, 221, fontpage_283_221_221), // '距' -- '距' - FONTDATA_ITEM(285, 202, 202, fontpage_285_202_202), // '車' -- '車' - FONTDATA_ITEM(285, 223, 223, fontpage_285_223_223), // '軟' -- '軟' - FONTDATA_ITEM(285, 248, 248, fontpage_285_248_248), // '軸' -- '軸' - FONTDATA_ITEM(286, 137, 137, fontpage_286_137_137), // '載' -- '載' - FONTDATA_ITEM(286, 175, 175, fontpage_286_175_175), // '輯' -- '輯' - FONTDATA_ITEM(286, 184, 184, fontpage_286_184_184), // '輸' -- '輸' - FONTDATA_ITEM(286, 201, 201, fontpage_286_201_201), // '轉' -- '轉' - FONTDATA_ITEM(287, 209, 209, fontpage_287_209_209), // '近' -- '近' - FONTDATA_ITEM(287, 212, 212, fontpage_287_212_212), // '返' -- '返' - FONTDATA_ITEM(288, 128, 128, fontpage_288_128_128), // '退' -- '退' - FONTDATA_ITEM(288, 159, 159, fontpage_288_159_159), // '速' -- '速' - FONTDATA_ITEM(288, 163, 163, fontpage_288_163_163), // '連' -- '連' - FONTDATA_ITEM(288, 178, 178, fontpage_288_178_178), // '進' -- '進' - FONTDATA_ITEM(288, 203, 203, fontpage_288_203_203), // '運' -- '運' - FONTDATA_ITEM(288, 212, 212, fontpage_288_212_212), // '達' -- '達' - FONTDATA_ITEM(288, 248, 248, fontpage_288_248_248), // '選' -- '選' - FONTDATA_ITEM(289, 132, 132, fontpage_289_132_132), // '還' -- '還' - FONTDATA_ITEM(289, 138, 138, fontpage_289_138_138), // '邊' -- '邊' - FONTDATA_ITEM(289, 232, 232, fontpage_289_232_232), // '部' -- '部' - FONTDATA_ITEM(291, 203, 203, fontpage_291_203_203), // '釋' -- '釋' - FONTDATA_ITEM(291, 205, 205, fontpage_291_205_205), // '重' -- '重' - FONTDATA_ITEM(291, 207, 207, fontpage_291_207_207), // '量' -- '量' - FONTDATA_ITEM(291, 221, 221, fontpage_291_221_221), // '針' -- '針' - FONTDATA_ITEM(292, 149, 149, fontpage_292_149_149), // '鈕' -- '鈕' - FONTDATA_ITEM(294, 175, 175, fontpage_294_175_175), // '錯' -- '錯' - FONTDATA_ITEM(294, 245, 245, fontpage_294_245_245), // '鍵' -- '鍵' - FONTDATA_ITEM(298, 247, 247, fontpage_298_247_247), // '長' -- '長' - FONTDATA_ITEM(299, 137, 137, fontpage_299_137_137), // '閉' -- '閉' - FONTDATA_ITEM(299, 139, 139, fontpage_299_139_139), // '開' -- '開' - FONTDATA_ITEM(299, 147, 147, fontpage_299_147_147), // '間' -- '間' - FONTDATA_ITEM(299, 220, 220, fontpage_299_220_220), // '關' -- '關' - FONTDATA_ITEM(300, 205, 205, fontpage_300_205_205), // '降' -- '降' - FONTDATA_ITEM(300, 228, 228, fontpage_300_228_228), // '除' -- '除' - FONTDATA_ITEM(301, 142, 142, fontpage_301_142_142), // '階' -- '階' - FONTDATA_ITEM(301, 217, 217, fontpage_301_217_217), // '雙' -- '雙' - FONTDATA_ITEM(301, 226, 226, fontpage_301_226_226), // '離' -- '離' - FONTDATA_ITEM(301, 251, 251, fontpage_301_251_251), // '電' -- '電' - FONTDATA_ITEM(302, 210, 210, fontpage_302_210_210), // '青' -- '青' - FONTDATA_ITEM(302, 222, 222, fontpage_302_222_222), // '非' -- '非' - FONTDATA_ITEM(302, 226, 226, fontpage_302_226_226), // '面' -- '面' - FONTDATA_ITEM(304, 133, 133, fontpage_304_133_133), // '項' -- '項' - FONTDATA_ITEM(304, 144, 144, fontpage_304_144_144), // '預' -- '預' - FONTDATA_ITEM(304, 205, 205, fontpage_304_205_205), // '額' -- '額' - FONTDATA_ITEM(304, 222, 222, fontpage_304_222_222), // '類' -- '類' - FONTDATA_ITEM(305, 168, 168, fontpage_305_168_168), // '風' -- '風' - FONTDATA_ITEM(305, 253, 253, fontpage_305_253_253), // '飽' -- '飽' - FONTDATA_ITEM(306, 152, 152, fontpage_306_152_152), // '餘' -- '餘' - FONTDATA_ITEM(307, 172, 172, fontpage_307_172_172), // '馬' -- '馬' - FONTDATA_ITEM(308, 197, 197, fontpage_308_197_197), // '驅' -- '驅' - FONTDATA_ITEM(309, 212, 212, fontpage_309_212_212), // '體' -- '體' - FONTDATA_ITEM(309, 216, 216, fontpage_309_216_216), // '高' -- '高' - FONTDATA_ITEM(317, 195, 195, fontpage_317_195_195), // '黃' -- '黃' - FONTDATA_ITEM(317, 222, 222, fontpage_317_222_222), // '點' -- '點' - FONTDATA_ITEM(318, 202, 202, fontpage_318_202_202), // '齊' -- '齊' - FONTDATA_ITEM(510, 154, 154, fontpage_510_154_154), // ':' -- ':' +static const uxg_fontinfo_t g_fontinfo_zh_TW[] PROGMEM = { + FONTDATA_ITEM(69, 191, 191, fontpage_69_191_191), // '⊿' -- '⊿' + FONTDATA_ITEM(156, 128, 128, fontpage_156_128_128), // '一' -- '一' + FONTDATA_ITEM(156, 137, 139, fontpage_156_137_139), // '三' -- '下' + FONTDATA_ITEM(156, 141, 141, fontpage_156_141_141), // '不' -- '不' + FONTDATA_ITEM(156, 166, 166, fontpage_156_166_166), // '並' -- '並' + FONTDATA_ITEM(156, 173, 173, fontpage_156_173_173), // '中' -- '中' + FONTDATA_ITEM(156, 187, 187, fontpage_156_187_187), // '主' -- '主' + FONTDATA_ITEM(156, 203, 203, fontpage_156_203_203), // '之' -- '之' + FONTDATA_ITEM(157, 164, 164, fontpage_157_164_164), // '交' -- '交' + FONTDATA_ITEM(157, 174, 174, fontpage_157_174_174), // '亮' -- '亮' + FONTDATA_ITEM(157, 228, 228, fontpage_157_228_228), // '令' -- '令' + FONTDATA_ITEM(157, 246, 246, fontpage_157_246_246), // '件' -- '件' + FONTDATA_ITEM(157, 253, 253, fontpage_157_253_253), // '份' -- '份' + FONTDATA_ITEM(158, 145, 145, fontpage_158_145_145), // '休' -- '休' + FONTDATA_ITEM(158, 205, 206, fontpage_158_205_206), // '位' -- '低' + FONTDATA_ITEM(158, 220, 220, fontpage_158_220_220), // '作' -- '作' + FONTDATA_ITEM(159, 155, 155, fontpage_159_155_155), // '供' -- '供' + FONTDATA_ITEM(159, 221, 221, fontpage_159_221_221), // '保' -- '保' + FONTDATA_ITEM(159, 225, 225, fontpage_159_225_225), // '信' -- '信' + FONTDATA_ITEM(160, 139, 139, fontpage_160_139_139), // '個' -- '個' + FONTDATA_ITEM(160, 188, 188, fontpage_160_188_188), // '值' -- '值' + FONTDATA_ITEM(160, 207, 207, fontpage_160_207_207), // '偏' -- '偏' + FONTDATA_ITEM(160, 220, 220, fontpage_160_220_220), // '停' -- '停' + FONTDATA_ITEM(160, 245, 245, fontpage_160_245_245), // '偵' -- '偵' + FONTDATA_ITEM(161, 153, 153, fontpage_161_153_153), // '備' -- '備' + FONTDATA_ITEM(161, 179, 179, fontpage_161_179_179), // '傳' -- '傳' + FONTDATA_ITEM(161, 190, 190, fontpage_161_190_190), // '傾' -- '傾' + FONTDATA_ITEM(162, 178, 178, fontpage_162_178_178), // '儲' -- '儲' + FONTDATA_ITEM(162, 197, 197, fontpage_162_197_197), // '充' -- '充' + FONTDATA_ITEM(162, 200, 201, fontpage_162_200_201), // '先' -- '光' + FONTDATA_ITEM(162, 229, 229, fontpage_162_229_229), // '入' -- '入' + FONTDATA_ITEM(162, 232, 232, fontpage_162_232_232), // '全' -- '全' + FONTDATA_ITEM(162, 241, 241, fontpage_162_241_241), // '共' -- '共' + FONTDATA_ITEM(162, 247, 247, fontpage_162_247_247), // '具' -- '具' + FONTDATA_ITEM(163, 151, 151, fontpage_163_151_151), // '冗' -- '冗' + FONTDATA_ITEM(163, 183, 183, fontpage_163_183_183), // '冷' -- '冷' + FONTDATA_ITEM(163, 198, 198, fontpage_163_198_198), // '准' -- '准' + FONTDATA_ITEM(163, 250, 250, fontpage_163_250_250), // '出' -- '出' + FONTDATA_ITEM(164, 134, 134, fontpage_164_134_134), // '分' -- '分' + FONTDATA_ITEM(164, 151, 151, fontpage_164_151_151), // '列' -- '列' + FONTDATA_ITEM(164, 157, 157, fontpage_164_157_157), // '初' -- '初' + FONTDATA_ITEM(164, 176, 176, fontpage_164_176_176), // '到' -- '到' + FONTDATA_ITEM(164, 182, 183, fontpage_164_182_183), // '制' -- '刷' + FONTDATA_ITEM(164, 245, 245, fontpage_164_245_245), // '創' -- '創' + FONTDATA_ITEM(165, 155, 155, fontpage_165_155_155), // '力' -- '力' + FONTDATA_ITEM(165, 160, 160, fontpage_165_160_160), // '加' -- '加' + FONTDATA_ITEM(165, 213, 213, fontpage_165_213_213), // '動' -- '動' + FONTDATA_ITEM(166, 150, 150, fontpage_166_150_150), // '化' -- '化' + FONTDATA_ITEM(166, 202, 202, fontpage_166_202_202), // '半' -- '半' + FONTDATA_ITEM(166, 212, 212, fontpage_166_212_212), // '協' -- '協' + FONTDATA_ITEM(166, 225, 225, fontpage_166_225_225), // '卡' -- '卡' + FONTDATA_ITEM(166, 240, 240, fontpage_166_240_240), // '印' -- '印' + FONTDATA_ITEM(166, 248, 248, fontpage_166_248_248), // '卸' -- '卸' + FONTDATA_ITEM(166, 251, 251, fontpage_166_251_251), // '卻' -- '卻' + FONTDATA_ITEM(167, 159, 159, fontpage_167_159_159), // '原' -- '原' + FONTDATA_ITEM(167, 205, 205, fontpage_167_205_205), // '反' -- '反' + FONTDATA_ITEM(167, 214, 214, fontpage_167_214_214), // '取' -- '取' + FONTDATA_ITEM(167, 240, 240, fontpage_167_240_240), // '台' -- '台' + FONTDATA_ITEM(168, 136, 136, fontpage_168_136_136), // '合' -- '合' + FONTDATA_ITEM(168, 166, 166, fontpage_168_166_166), // '否' -- '否' + FONTDATA_ITEM(168, 202, 202, fontpage_168_202_202), // '告' -- '告' + FONTDATA_ITEM(168, 253, 253, fontpage_168_253_253), // '命' -- '命' + FONTDATA_ITEM(169, 140, 140, fontpage_169_140_140), // '和' -- '和' + FONTDATA_ITEM(170, 223, 223, fontpage_170_223_223), // '啟' -- '啟' + FONTDATA_ITEM(171, 174, 174, fontpage_171_174_174), // '單' -- '單' + FONTDATA_ITEM(172, 180, 180, fontpage_172_180_180), // '嘴' -- '嘴' + FONTDATA_ITEM(172, 232, 232, fontpage_172_232_232), // '器' -- '器' + FONTDATA_ITEM(172, 244, 244, fontpage_172_244_244), // '噴' -- '噴' + FONTDATA_ITEM(173, 222, 222, fontpage_173_222_222), // '回' -- '回' + FONTDATA_ITEM(173, 224, 224, fontpage_173_224_224), // '因' -- '因' + FONTDATA_ITEM(173, 250, 250, fontpage_173_250_250), // '固' -- '固' + FONTDATA_ITEM(174, 150, 150, fontpage_174_150_150), // '圖' -- '圖' + FONTDATA_ITEM(174, 168, 168, fontpage_174_168_168), // '在' -- '在' + FONTDATA_ITEM(175, 139, 139, fontpage_175_139_139), // '型' -- '型' + FONTDATA_ITEM(175, 247, 247, fontpage_175_247_247), // '執' -- '執' + FONTDATA_ITEM(176, 202, 202, fontpage_176_202_202), // '塊' -- '塊' + FONTDATA_ITEM(176, 235, 235, fontpage_176_235_235), // '填' -- '填' + FONTDATA_ITEM(177, 138, 138, fontpage_177_138_138), // '墊' -- '墊' + FONTDATA_ITEM(178, 150, 150, fontpage_178_150_150), // '外' -- '外' + FONTDATA_ITEM(178, 154, 154, fontpage_178_154_154), // '多' -- '多' + FONTDATA_ITEM(178, 160, 160, fontpage_178_160_160), // '夠' -- '夠' + FONTDATA_ITEM(178, 167, 167, fontpage_178_167_167), // '大' -- '大' + FONTDATA_ITEM(178, 169, 170, fontpage_178_169_170), // '天' -- '太' + FONTDATA_ITEM(178, 177, 177, fontpage_178_177_177), // '失' -- '失' + FONTDATA_ITEM(179, 203, 203, fontpage_179_203_203), // '始' -- '始' + FONTDATA_ITEM(181, 146, 146, fontpage_181_146_146), // '媒' -- '媒' + FONTDATA_ITEM(182, 208, 208, fontpage_182_208_208), // '子' -- '子' + FONTDATA_ITEM(182, 216, 216, fontpage_182_216_216), // '存' -- '存' + FONTDATA_ITEM(183, 137, 137, fontpage_183_137_137), // '安' -- '安' + FONTDATA_ITEM(183, 140, 140, fontpage_183_140_140), // '完' -- '完' + FONTDATA_ITEM(183, 154, 154, fontpage_183_154_154), // '定' -- '定' + FONTDATA_ITEM(183, 162, 162, fontpage_183_162_162), // '客' -- '客' + FONTDATA_ITEM(183, 185, 185, fontpage_183_185_185), // '容' -- '容' + FONTDATA_ITEM(184, 141, 141, fontpage_184_141_141), // '對' -- '對' + FONTDATA_ITEM(184, 143, 143, fontpage_184_143_143), // '小' -- '小' + FONTDATA_ITEM(184, 177, 177, fontpage_184_177_177), // '就' -- '就' + FONTDATA_ITEM(187, 229, 229, fontpage_187_229_229), // '工' -- '工' + FONTDATA_ITEM(187, 238, 238, fontpage_187_238_238), // '差' -- '差' + FONTDATA_ITEM(187, 242, 242, fontpage_187_242_242), // '已' -- '已' + FONTDATA_ITEM(188, 243, 243, fontpage_188_243_243), // '平' -- '平' + FONTDATA_ITEM(189, 138, 138, fontpage_189_138_138), // '床' -- '床' + FONTDATA_ITEM(189, 166, 166, fontpage_189_166_166), // '度' -- '度' + FONTDATA_ITEM(189, 226, 226, fontpage_189_226_226), // '廢' -- '廢' + FONTDATA_ITEM(189, 250, 250, fontpage_189_250_250), // '建' -- '建' + FONTDATA_ITEM(190, 149, 149, fontpage_190_149_149), // '引' -- '引' + FONTDATA_ITEM(191, 133, 133, fontpage_191_133_133), // '待' -- '待' + FONTDATA_ITEM(191, 140, 140, fontpage_191_140_140), // '後' -- '後' + FONTDATA_ITEM(191, 145, 145, fontpage_191_145_145), // '徑' -- '徑' + FONTDATA_ITEM(191, 158, 158, fontpage_191_158_158), // '從' -- '從' + FONTDATA_ITEM(191, 169, 169, fontpage_191_169_169), // '復' -- '復' + FONTDATA_ITEM(191, 174, 174, fontpage_191_174_174), // '微' -- '微' + FONTDATA_ITEM(191, 195, 195, fontpage_191_195_195), // '心' -- '心' + FONTDATA_ITEM(192, 167, 167, fontpage_192_167_167), // '性' -- '性' + FONTDATA_ITEM(192, 226, 226, fontpage_192_226_226), // '恢' -- '恢' + FONTDATA_ITEM(192, 239, 239, fontpage_192_239_239), // '息' -- '息' + FONTDATA_ITEM(195, 182, 182, fontpage_195_182_182), // '憶' -- '憶' + FONTDATA_ITEM(195, 201, 201, fontpage_195_201_201), // '應' -- '應' + FONTDATA_ITEM(196, 144, 144, fontpage_196_144_144), // '成' -- '成' + FONTDATA_ITEM(196, 182, 182, fontpage_196_182_182), // '戶' -- '戶' + FONTDATA_ITEM(196, 192, 192, fontpage_196_192_192), // '所' -- '所' + FONTDATA_ITEM(196, 199, 199, fontpage_196_199_199), // '扇' -- '扇' + FONTDATA_ITEM(196, 203, 203, fontpage_196_203_203), // '手' -- '手' + FONTDATA_ITEM(196, 211, 211, fontpage_196_211_211), // '打' -- '打' + FONTDATA_ITEM(196, 249, 249, fontpage_196_249_249), // '批' -- '批' + FONTDATA_ITEM(197, 150, 150, fontpage_197_150_150), // '抖' -- '抖' + FONTDATA_ITEM(197, 189, 189, fontpage_197_189_189), // '抽' -- '抽' + FONTDATA_ITEM(197, 212, 212, fontpage_197_212_212), // '拔' -- '拔' + FONTDATA_ITEM(198, 137, 137, fontpage_198_137_137), // '按' -- '按' + FONTDATA_ITEM(199, 137, 137, fontpage_199_137_137), // '掉' -- '掉' + FONTDATA_ITEM(199, 162, 162, fontpage_199_162_162), // '探' -- '探' + FONTDATA_ITEM(199, 165, 165, fontpage_199_165_165), // '接' -- '接' + FONTDATA_ITEM(199, 167, 167, fontpage_199_167_167), // '控' -- '控' + FONTDATA_ITEM(199, 208, 208, fontpage_199_208_208), // '提' -- '提' + FONTDATA_ITEM(199, 210, 210, fontpage_199_210_210), // '插' -- '插' + FONTDATA_ITEM(199, 219, 219, fontpage_199_219_219), // '換' -- '換' + FONTDATA_ITEM(201, 199, 199, fontpage_201_199_199), // '擇' -- '擇' + FONTDATA_ITEM(201, 202, 203, fontpage_201_202_203), // '擊' -- '擋' + FONTDATA_ITEM(201, 224, 224, fontpage_201_224_224), // '擠' -- '擠' + FONTDATA_ITEM(202, 182, 182, fontpage_202_182_182), // '收' -- '收' + FONTDATA_ITEM(202, 190, 190, fontpage_202_190_190), // '放' -- '放' + FONTDATA_ITEM(202, 215, 215, fontpage_202_215_215), // '敗' -- '敗' + FONTDATA_ITEM(202, 244, 244, fontpage_202_244_244), // '整' -- '整' + FONTDATA_ITEM(202, 248, 248, fontpage_202_248_248), // '數' -- '數' + FONTDATA_ITEM(203, 153, 153, fontpage_203_153_153), // '料' -- '料' + FONTDATA_ITEM(203, 156, 156, fontpage_203_156_156), // '斜' -- '斜' + FONTDATA_ITEM(203, 176, 176, fontpage_203_176_176), // '新' -- '新' + FONTDATA_ITEM(203, 183, 183, fontpage_203_183_183), // '斷' -- '斷' + FONTDATA_ITEM(203, 188, 188, fontpage_203_188_188), // '於' -- '於' + FONTDATA_ITEM(204, 135, 135, fontpage_204_135_135), // '昇' -- '昇' + FONTDATA_ITEM(204, 142, 142, fontpage_204_142_142), // '明' -- '明' + FONTDATA_ITEM(204, 175, 175, fontpage_204_175_175), // '是' -- '是' + FONTDATA_ITEM(204, 194, 194, fontpage_204_194_194), // '時' -- '時' + FONTDATA_ITEM(205, 171, 171, fontpage_205_171_171), // '暫' -- '暫' + FONTDATA_ITEM(205, 244, 244, fontpage_205_244_244), // '更' -- '更' + FONTDATA_ITEM(206, 128, 128, fontpage_206_128_128), // '最' -- '最' + FONTDATA_ITEM(206, 137, 137, fontpage_206_137_137), // '有' -- '有' + FONTDATA_ITEM(206, 255, 255, fontpage_206_255_255), // '板' -- '板' + FONTDATA_ITEM(207, 241, 241, fontpage_207_241_241), // '柱' -- '柱' + FONTDATA_ITEM(208, 161, 161, fontpage_208_161_161), // '校' -- '校' + FONTDATA_ITEM(208, 188, 188, fontpage_208_188_188), // '格' -- '格' + FONTDATA_ITEM(209, 157, 157, fontpage_209_157_157), // '條' -- '條' + FONTDATA_ITEM(209, 196, 196, fontpage_209_196_196), // '棄' -- '棄' + FONTDATA_ITEM(211, 253, 253, fontpage_211_253_253), // '槽' -- '槽' + FONTDATA_ITEM(212, 217, 217, fontpage_212_217_217), // '橙' -- '橙' + FONTDATA_ITEM(212, 223, 223, fontpage_212_223_223), // '機' -- '機' + FONTDATA_ITEM(213, 162, 162, fontpage_213_162_162), // '檢' -- '檢' + FONTDATA_ITEM(214, 226, 227, fontpage_214_226_227), // '止' -- '正' + FONTDATA_ITEM(214, 229, 229, fontpage_214_229_229), // '步' -- '步' + FONTDATA_ITEM(214, 248, 248, fontpage_214_248_248), // '歸' -- '歸' + FONTDATA_ITEM(215, 188, 188, fontpage_215_188_188), // '殼' -- '殼' + FONTDATA_ITEM(215, 212, 212, fontpage_215_212_212), // '比' -- '比' + FONTDATA_ITEM(217, 146, 146, fontpage_217_146_146), // '沒' -- '沒' + FONTDATA_ITEM(219, 136, 136, fontpage_219_136_136), // '消' -- '消' + FONTDATA_ITEM(219, 225, 225, fontpage_219_225_225), // '淡' -- '淡' + FONTDATA_ITEM(220, 133, 133, fontpage_220_133_133), // '清' -- '清' + FONTDATA_ITEM(220, 172, 172, fontpage_220_172_172), // '測' -- '測' + FONTDATA_ITEM(221, 144, 144, fontpage_221_144_144), // '源' -- '源' + FONTDATA_ITEM(221, 150, 150, fontpage_221_150_150), // '準' -- '準' + FONTDATA_ITEM(221, 171, 171, fontpage_221_171_171), // '溫' -- '溫' + FONTDATA_ITEM(223, 192, 192, fontpage_223_192_192), // '激' -- '激' + FONTDATA_ITEM(226, 161, 161, fontpage_226_161_161), // '無' -- '無' + FONTDATA_ITEM(227, 177, 177, fontpage_227_177_177), // '熱' -- '熱' + FONTDATA_ITEM(227, 200, 200, fontpage_227_200_200), // '燈' -- '燈' + FONTDATA_ITEM(228, 199, 199, fontpage_228_199_199), // '片' -- '片' + FONTDATA_ITEM(228, 233, 233, fontpage_228_233_233), // '物' -- '物' + FONTDATA_ITEM(231, 135, 135, fontpage_231_135_135), // '率' -- '率' + FONTDATA_ITEM(234, 168, 168, fontpage_234_168_168), // '用' -- '用' + FONTDATA_ITEM(234, 204, 204, fontpage_234_204_204), // '界' -- '界' + FONTDATA_ITEM(236, 253, 253, fontpage_236_253_253), // '白' -- '白' + FONTDATA_ITEM(237, 132, 132, fontpage_237_132_132), // '的' -- '的' + FONTDATA_ITEM(237, 227, 227, fontpage_237_227_227), // '監' -- '監' + FONTDATA_ITEM(237, 244, 244, fontpage_237_244_244), // '直' -- '直' + FONTDATA_ITEM(238, 160, 160, fontpage_238_160_160), // '眠' -- '眠' + FONTDATA_ITEM(240, 141, 141, fontpage_240_141_141), // '砍' -- '砍' + FONTDATA_ITEM(241, 186, 186, fontpage_241_186_186), // '確' -- '確' + FONTDATA_ITEM(243, 251, 251, fontpage_243_251_251), // '移' -- '移' + FONTDATA_ITEM(244, 205, 205, fontpage_244_205_205), // '積' -- '積' + FONTDATA_ITEM(245, 239, 239, fontpage_245_239_239), // '端' -- '端' + FONTDATA_ITEM(246, 201, 201, fontpage_246_201_201), // '等' -- '等' + FONTDATA_ITEM(247, 161, 161, fontpage_247_161_161), // '管' -- '管' + FONTDATA_ITEM(247, 177, 177, fontpage_247_177_177), // '箱' -- '箱' + FONTDATA_ITEM(249, 251, 251, fontpage_249_251_251), // '系' -- '系' + FONTDATA_ITEM(250, 133, 133, fontpage_250_133_133), // '紅' -- '紅' + FONTDATA_ITEM(250, 162, 162, fontpage_250_162_162), // '索' -- '索' + FONTDATA_ITEM(250, 171, 171, fontpage_250_171_171), // '紫' -- '紫' + FONTDATA_ITEM(250, 176, 176, fontpage_250_176_176), // '細' -- '細' + FONTDATA_ITEM(250, 194, 194, fontpage_250_194_194), // '終' -- '終' + FONTDATA_ITEM(250, 241, 242, fontpage_250_241_242), // '統' -- '絲' + FONTDATA_ITEM(251, 160, 160, fontpage_251_160_160), // '綠' -- '綠' + FONTDATA_ITEM(251, 178, 178, fontpage_251_178_178), // '網' -- '網' + FONTDATA_ITEM(251, 210, 210, fontpage_251_210_210), // '緒' -- '緒' + FONTDATA_ITEM(251, 218, 218, fontpage_251_218_218), // '線' -- '線' + FONTDATA_ITEM(251, 232, 232, fontpage_251_232_232), // '編' -- '編' + FONTDATA_ITEM(252, 174, 174, fontpage_252_174_174), // '縮' -- '縮' + FONTDATA_ITEM(252, 189, 189, fontpage_252_189_189), // '總' -- '總' + FONTDATA_ITEM(252, 252, 252, fontpage_252_252_252), // '繼' -- '繼' + FONTDATA_ITEM(253, 140, 140, fontpage_253_140_140), // '續' -- '續' + FONTDATA_ITEM(253, 162, 162, fontpage_253_162_162), // '红' -- '红' + FONTDATA_ITEM(254, 238, 238, fontpage_254_238_238), // '置' -- '置' + FONTDATA_ITEM(254, 242, 242, fontpage_254_242_242), // '署' -- '署' + FONTDATA_ITEM(256, 240, 240, fontpage_256_240_240), // '聰' -- '聰' + FONTDATA_ITEM(259, 234, 234, fontpage_259_234_234), // '自' -- '自' + FONTDATA_ITEM(267, 205, 205, fontpage_267_205_205), // '藍' -- '藍' + FONTDATA_ITEM(272, 204, 204, fontpage_272_204_204), // '行' -- '行' + FONTDATA_ITEM(272, 232, 232, fontpage_272_232_232), // '表' -- '表' + FONTDATA_ITEM(273, 171, 171, fontpage_273_171_171), // '被' -- '被' + FONTDATA_ITEM(273, 197, 197, fontpage_273_197_197), // '装' -- '装' + FONTDATA_ITEM(273, 221, 221, fontpage_273_221_221), // '裝' -- '裝' + FONTDATA_ITEM(274, 135, 135, fontpage_274_135_135), // '複' -- '複' + FONTDATA_ITEM(275, 210, 210, fontpage_275_210_210), // '角' -- '角' + FONTDATA_ITEM(276, 136, 136, fontpage_276_136_136), // '計' -- '計' + FONTDATA_ITEM(276, 138, 138, fontpage_276_138_138), // '訊' -- '訊' + FONTDATA_ITEM(276, 152, 152, fontpage_276_152_152), // '記' -- '記' + FONTDATA_ITEM(276, 173, 173, fontpage_276_173_173), // '設' -- '設' + FONTDATA_ITEM(276, 230, 230, fontpage_276_230_230), // '試' -- '試' + FONTDATA_ITEM(277, 141, 141, fontpage_277_141_141), // '認' -- '認' + FONTDATA_ITEM(277, 164, 164, fontpage_277_164_164), // '誤' -- '誤' + FONTDATA_ITEM(277, 191, 191, fontpage_277_191_191), // '調' -- '調' + FONTDATA_ITEM(277, 203, 203, fontpage_277_203_203), // '請' -- '請' + FONTDATA_ITEM(278, 240, 240, fontpage_278_240_240), // '議' -- '議' + FONTDATA_ITEM(279, 128, 128, fontpage_279_128_128), // '讀' -- '讀' + FONTDATA_ITEM(279, 138, 138, fontpage_279_138_138), // '變' -- '變' + FONTDATA_ITEM(281, 199, 199, fontpage_281_199_199), // '資' -- '資' + FONTDATA_ITEM(283, 221, 221, fontpage_283_221_221), // '距' -- '距' + FONTDATA_ITEM(285, 202, 202, fontpage_285_202_202), // '車' -- '車' + FONTDATA_ITEM(285, 223, 223, fontpage_285_223_223), // '軟' -- '軟' + FONTDATA_ITEM(285, 248, 248, fontpage_285_248_248), // '軸' -- '軸' + FONTDATA_ITEM(286, 137, 137, fontpage_286_137_137), // '載' -- '載' + FONTDATA_ITEM(286, 175, 175, fontpage_286_175_175), // '輯' -- '輯' + FONTDATA_ITEM(286, 184, 184, fontpage_286_184_184), // '輸' -- '輸' + FONTDATA_ITEM(286, 201, 201, fontpage_286_201_201), // '轉' -- '轉' + FONTDATA_ITEM(287, 209, 209, fontpage_287_209_209), // '近' -- '近' + FONTDATA_ITEM(287, 212, 212, fontpage_287_212_212), // '返' -- '返' + FONTDATA_ITEM(288, 128, 128, fontpage_288_128_128), // '退' -- '退' + FONTDATA_ITEM(288, 159, 159, fontpage_288_159_159), // '速' -- '速' + FONTDATA_ITEM(288, 163, 163, fontpage_288_163_163), // '連' -- '連' + FONTDATA_ITEM(288, 178, 178, fontpage_288_178_178), // '進' -- '進' + FONTDATA_ITEM(288, 203, 203, fontpage_288_203_203), // '運' -- '運' + FONTDATA_ITEM(288, 212, 212, fontpage_288_212_212), // '達' -- '達' + FONTDATA_ITEM(288, 248, 248, fontpage_288_248_248), // '選' -- '選' + FONTDATA_ITEM(289, 132, 132, fontpage_289_132_132), // '還' -- '還' + FONTDATA_ITEM(289, 138, 138, fontpage_289_138_138), // '邊' -- '邊' + FONTDATA_ITEM(289, 232, 232, fontpage_289_232_232), // '部' -- '部' + FONTDATA_ITEM(291, 203, 203, fontpage_291_203_203), // '釋' -- '釋' + FONTDATA_ITEM(291, 205, 205, fontpage_291_205_205), // '重' -- '重' + FONTDATA_ITEM(291, 207, 207, fontpage_291_207_207), // '量' -- '量' + FONTDATA_ITEM(291, 221, 221, fontpage_291_221_221), // '針' -- '針' + FONTDATA_ITEM(292, 149, 149, fontpage_292_149_149), // '鈕' -- '鈕' + FONTDATA_ITEM(294, 175, 175, fontpage_294_175_175), // '錯' -- '錯' + FONTDATA_ITEM(294, 245, 245, fontpage_294_245_245), // '鍵' -- '鍵' + FONTDATA_ITEM(298, 247, 247, fontpage_298_247_247), // '長' -- '長' + FONTDATA_ITEM(299, 137, 137, fontpage_299_137_137), // '閉' -- '閉' + FONTDATA_ITEM(299, 139, 139, fontpage_299_139_139), // '開' -- '開' + FONTDATA_ITEM(299, 147, 147, fontpage_299_147_147), // '間' -- '間' + FONTDATA_ITEM(299, 220, 220, fontpage_299_220_220), // '關' -- '關' + FONTDATA_ITEM(300, 205, 205, fontpage_300_205_205), // '降' -- '降' + FONTDATA_ITEM(300, 228, 228, fontpage_300_228_228), // '除' -- '除' + FONTDATA_ITEM(301, 142, 142, fontpage_301_142_142), // '階' -- '階' + FONTDATA_ITEM(301, 217, 217, fontpage_301_217_217), // '雙' -- '雙' + FONTDATA_ITEM(301, 226, 226, fontpage_301_226_226), // '離' -- '離' + FONTDATA_ITEM(301, 251, 251, fontpage_301_251_251), // '電' -- '電' + FONTDATA_ITEM(302, 210, 210, fontpage_302_210_210), // '青' -- '青' + FONTDATA_ITEM(302, 222, 222, fontpage_302_222_222), // '非' -- '非' + FONTDATA_ITEM(302, 226, 226, fontpage_302_226_226), // '面' -- '面' + FONTDATA_ITEM(304, 133, 133, fontpage_304_133_133), // '項' -- '項' + FONTDATA_ITEM(304, 144, 144, fontpage_304_144_144), // '預' -- '預' + FONTDATA_ITEM(304, 205, 205, fontpage_304_205_205), // '額' -- '額' + FONTDATA_ITEM(304, 222, 222, fontpage_304_222_222), // '類' -- '類' + FONTDATA_ITEM(305, 168, 168, fontpage_305_168_168), // '風' -- '風' + FONTDATA_ITEM(305, 253, 253, fontpage_305_253_253), // '飽' -- '飽' + FONTDATA_ITEM(306, 152, 152, fontpage_306_152_152), // '餘' -- '餘' + FONTDATA_ITEM(307, 172, 172, fontpage_307_172_172), // '馬' -- '馬' + FONTDATA_ITEM(308, 197, 197, fontpage_308_197_197), // '驅' -- '驅' + FONTDATA_ITEM(309, 212, 212, fontpage_309_212_212), // '體' -- '體' + FONTDATA_ITEM(309, 216, 216, fontpage_309_216_216), // '高' -- '高' + FONTDATA_ITEM(317, 195, 195, fontpage_317_195_195), // '黃' -- '黃' + FONTDATA_ITEM(317, 222, 222, fontpage_317_222_222), // '點' -- '點' + FONTDATA_ITEM(318, 202, 202, fontpage_318_202_202), // '齊' -- '齊' + FONTDATA_ITEM(510, 154, 154, fontpage_510_154_154), // ':' -- ':' }; diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 1a07b7ab75..25e943a14d 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -79,6 +79,18 @@ U8G_CLASS u8g; #include LANGUAGE_DATA_INCL(LCD_LANGUAGE) +#ifdef LCD_LANGUAGE_2 + #include LANGUAGE_DATA_INCL(LCD_LANGUAGE_2) +#endif +#ifdef LCD_LANGUAGE_3 + #include LANGUAGE_DATA_INCL(LCD_LANGUAGE_3) +#endif +#ifdef LCD_LANGUAGE_4 + #include LANGUAGE_DATA_INCL(LCD_LANGUAGE_4) +#endif +#ifdef LCD_LANGUAGE_5 + #include LANGUAGE_DATA_INCL(LCD_LANGUAGE_5) +#endif #if HAS_LCD_CONTRAST @@ -293,7 +305,29 @@ void MarlinUI::init_lcd() { TERN_(LCD_SCREEN_ROT_180, u8g.setRot180()); TERN_(LCD_SCREEN_ROT_270, u8g.setRot270()); - uxg_SetUtf8Fonts(g_fontinfo, COUNT(g_fontinfo)); + update_language_font(); +} + +void MarlinUI::update_language_font() { + #if HAS_MULTI_LANGUAGE + switch (language) { + default: uxg_SetUtf8Fonts(LANG_FONT_INFO(LCD_LANGUAGE), COUNT(LANG_FONT_INFO(LCD_LANGUAGE))); break; + #ifdef LCD_LANGUAGE_2 + case 1: uxg_SetUtf8Fonts(LANG_FONT_INFO(LCD_LANGUAGE_2), COUNT(LANG_FONT_INFO(LCD_LANGUAGE_2))); break; + #endif + #ifdef LCD_LANGUAGE_3 + case 2: uxg_SetUtf8Fonts(LANG_FONT_INFO(LCD_LANGUAGE_3), COUNT(LANG_FONT_INFO(LCD_LANGUAGE_3))); break; + #endif + #ifdef LCD_LANGUAGE_4 + case 3: uxg_SetUtf8Fonts(LANG_FONT_INFO(LCD_LANGUAGE_4), COUNT(LANG_FONT_INFO(LCD_LANGUAGE_4))); break; + #endif + #ifdef LCD_LANGUAGE_5 + case 4: uxg_SetUtf8Fonts(LANG_FONT_INFO(LCD_LANGUAGE_5), COUNT(LANG_FONT_INFO(LCD_LANGUAGE_5))); break; + #endif + } + #else + uxg_SetUtf8Fonts(LANG_FONT_INFO(LCD_LANGUAGE), COUNT(LANG_FONT_INFO(LCD_LANGUAGE))); + #endif } // The kill screen is displayed for unrecoverable conditions @@ -369,13 +403,12 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { if (mark_as_selected(row, style & SS_INVERT)) { - pixel_len_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed - const int8_t plen = pstr ? utf8_strlen_P(pstr) : 0, - vlen = vstr ? utf8_strlen(vstr) : 0; + const int plen = pstr ? calculateWidth(pstr) : 0, + vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { - int8_t pad = (LCD_WIDTH - plen - vlen) / 2; + int pad = (LCD_PIXEL_WIDTH - plen - vlen * MENU_FONT_WIDTH) / MENU_FONT_WIDTH / 2; while (--pad >= 0) n -= lcd_put_wchar(' '); } @@ -400,8 +433,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (mark_as_selected(row, sel)) { const uint8_t vallen = (pgm ? utf8_strlen_P(inStr) : utf8_strlen((char*)inStr)), pixelwidth = (pgm ? uxg_GetUtf8StrPixelWidthP(u8g.getU8g(), inStr) : uxg_GetUtf8StrPixelWidth(u8g.getU8g(), (char*)inStr)); + const u8g_uint_t prop = USE_WIDE_GLYPH ? 2 : 1; - pixel_len_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH); + pixel_len_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2 - vallen * prop) * (MENU_FONT_WIDTH); if (vallen) { lcd_put_wchar(':'); while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); @@ -414,15 +448,16 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); + const u8g_uint_t prop = USE_WIDE_GLYPH ? 2 : 1; const u8g_uint_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value); - bool extra_row = labellen > LCD_WIDTH - 2 - vallen; + bool extra_row = labellen * prop > LCD_WIDTH - 2 - vallen * prop; #if ENABLED(USE_BIG_EDIT_FONT) // Use the menu font if the label won't fit on a single line constexpr u8g_uint_t lcd_edit_width = (LCD_PIXEL_WIDTH) / (EDIT_FONT_WIDTH); u8g_uint_t lcd_chr_fit, one_chr_width; - if (labellen <= lcd_edit_width - 1) { - if (labellen + vallen + 1 > lcd_edit_width) extra_row = true; + if (labellen * prop <= lcd_edit_width - 1) { + if (labellen * prop + vallen * prop + 1 > lcd_edit_width) extra_row = true; lcd_chr_fit = lcd_edit_width + 1; one_chr_width = EDIT_FONT_WIDTH; ui.set_font(FONT_EDIT); @@ -454,7 +489,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline); } if (onpage) { - lcd_put_wchar(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space + lcd_put_wchar(((lcd_chr_fit - 1) - (vallen * prop + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space lcd_put_u8str(value); } } @@ -468,7 +503,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop const pixel_len_t bw = len * prop * (MENU_FONT_WIDTH), bx = x * prop * (MENU_FONT_WIDTH); if (inv) { u8g.setColorIndex(1); - u8g.drawBox(bx / prop - 1, by - (MENU_FONT_ASCENT) + 1, bw / prop + 2, MENU_FONT_HEIGHT - 1); + u8g.drawBox(bx / prop - 1, by - (MENU_FONT_ASCENT), bw + 2, MENU_FONT_HEIGHT); u8g.setColorIndex(0); } lcd_put_u8str_P(bx / prop, by, pstr); @@ -478,8 +513,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { ui.draw_select_screen_prompt(pref, string, suff); draw_boxed_string(1, LCD_HEIGHT - 1, no, !yesno); - const u8g_uint_t xpos = (LCD_WIDTH) / (USE_WIDE_GLYPH ? 2 : 1); - draw_boxed_string(xpos - (utf8_strlen_P(yes) + 1), LCD_HEIGHT - 1, yes, yesno); + draw_boxed_string(LCD_WIDTH - (utf8_strlen_P(yes) * (USE_WIDE_GLYPH ? 2 : 1) + 1), LCD_HEIGHT - 1, yes, yesno); } #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.h b/Marlin/src/lcd/dogm/marlinui_DOGM.h index e3ceb63f96..328b69b93b 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.h +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.h @@ -27,7 +27,7 @@ #include "../../inc/MarlinConfigPre.h" -#include +#include #include "HAL_LCD_class_defines.h" //#define ALTERNATIVE_LCD diff --git a/Marlin/src/lcd/dogm/status/ammeter.h b/Marlin/src/lcd/dogm/status/ammeter.h new file mode 100644 index 0000000000..d99ea6949a --- /dev/null +++ b/Marlin/src/lcd/dogm/status/ammeter.h @@ -0,0 +1,68 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +// +// lcd/dogm/status/ammeter.h - Status Screen Laser Ammeter bitmaps +// + +#define STATUS_AMMETER_WIDTH 20 + +const unsigned char status_ammeter_bmp_mA[] PROGMEM = { + B00000000,B11111100,B00000000, + B00000011,B00000011,B00000000, + B00000100,B00000000,B10000000, + B00001000,B00000000,B01000000, + B00010000,B00000110,B00100000, + B00010000,B00001001,B00100000, + B00100000,B00001001,B00010000, + B00100011,B01001111,B00010000, + B11100010,B10101001,B00011100, + B00100010,B10101001,B00010000, + B00100010,B10101001,B00010000, + B00010000,B00000000,B00100000, + B00010000,B00000000,B00100000, + B00001000,B00000000,B01000000, + B00000100,B00000000,B10000000, + B00000011,B00000011,B00000000, + B00000000,B11111100,B00000000 +}; + +const unsigned char status_ammeter_bmp_A[] PROGMEM = { + B00000000,B11111100,B00000000, + B00000011,B00000011,B00000000, + B00000100,B00000000,B10000000, + B00001000,B00000000,B01000000, + B00010000,B00000000,B00100000, + B00010000,B00110000,B00100000, + B00100000,B01001000,B00010000, + B00100000,B01001000,B00010000, + B11100000,B01111000,B00011100, + B00100000,B01001000,B00010000, + B00100000,B01001000,B00010000, + B00010000,B01001000,B00100000, + B00010000,B00000000,B00100000, + B00001000,B00000000,B01000000, + B00000100,B00000000,B10000000, + B00000011,B00000011,B00000000, + B00000000,B11111100,B00000000, +}; diff --git a/Marlin/src/lcd/dogm/status/cooler.h b/Marlin/src/lcd/dogm/status/cooler.h index 6cf67a4b62..65c28ec28e 100644 --- a/Marlin/src/lcd/dogm/status/cooler.h +++ b/Marlin/src/lcd/dogm/status/cooler.h @@ -29,40 +29,40 @@ #define STATUS_COOLER_WIDTH 22 const unsigned char status_cooler_bmp2[] PROGMEM = { - B00000100,B00000010,B00000000, - B00000100,B10010010,B01000000, - B00010101,B00001010,B10000000, - B00001110,B00000111,B00000000, - B00111111,B10111111,B11000000, - B00001110,B00000111,B00000000, - B00010101,B00001010,B10000000, - B00100100,B00100010,B01000000, - B00000100,B00100000,B00000000, - B00000001,B00100100,B00000000, - B00000000,B10101000,B00000000, - B00000000,B01110000,B00000000, - B00000111,B11111111,B00000000, - B00000000,B01110000,B00000000, - B00000000,B10101000,B00000000, - B00000001,B00100100,B00000000 + B00000001,B00000000,B10000000, + B00000001,B00100100,B10010000, + B00000101,B01000010,B10100000, + B00000011,B10000001,B11000000, + B00001111,B11101111,B11110000, + B00000011,B10000001,B11000000, + B00000101,B01000010,B10100000, + B00001001,B00001000,B10010000, + B00000001,B00001000,B00000000, + B00000000,B01001001,B00000000, + B00000000,B00101010,B00000000, + B00000000,B00011100,B00000000, + B00000001,B11111111,B11000000, + B00000000,B00011100,B00000000, + B00000000,B00101010,B00000000, + B00000000,B01001001,B00000000 }; const unsigned char status_cooler_bmp1[] PROGMEM = { - B00000100,B00000010,B00000000, - B00000100,B10010010,B01000000, - B00010101,B00001010,B10000000, - B00001010,B00000101,B00000000, - B00110001,B11011000,B11000000, - B00001010,B00000101,B00000000, - B00010101,B00001010,B10000000, - B00100100,B00100010,B01000000, - B00000100,B00100000,B00000000, - B00000001,B00100100,B00000000, - B00000000,B10101000,B00000000, - B00000000,B01010000,B00000000, - B00000111,B10001111,B00000000, - B00000000,B01010000,B00000000, - B00000000,B10101000,B00000000, - B00000001,B00100100,B00000000 + B00000001,B00000000,B10000000, + B00000001,B00100100,B10010000, + B00000101,B01000010,B10100000, + B00000010,B10000001,B01000000, + B00001100,B01110110,B00110000, + B00000010,B10000001,B01000000, + B00000101,B01000010,B10100000, + B00001001,B00001000,B10010000, + B00000001,B00001000,B00000000, + B00000000,B01001001,B00000000, + B00000000,B00101010,B00000000, + B00000000,B00010100,B00000000, + B00000001,B11100011,B11000000, + B00000000,B00010100,B00000000, + B00000000,B00101010,B00000000, + B00000000,B01001001,B00000000 }; #endif diff --git a/Marlin/src/lcd/dogm/status/hotend.h b/Marlin/src/lcd/dogm/status/hotend.h index 3a6e02acb6..aac29da451 100644 --- a/Marlin/src/lcd/dogm/status/hotend.h +++ b/Marlin/src/lcd/dogm/status/hotend.h @@ -39,20 +39,33 @@ #define STATUS_HOTEND1_WIDTH 16 -#if STATUS_HOTEND_BITMAPS == 1 || ENABLED(STATUS_HOTEND_NUMBERLESS) +#if STATUS_HOTEND_BITMAPS == 1 || defined(STATUS_HOTEND_NUMBERLESS) const unsigned char status_hotend_a_bmp[] PROGMEM = { B00011111,B11100000, - B00111111,B11110000, - B00111111,B11110000, - B00111111,B11110000, - B00011111,B11100000, - B00011111,B11100000, - B00111111,B11110000, - B00111111,B11110000, - B00111111,B11110000, - B00001111,B11000000, - B00000111,B10000000, + #if defined(STATUS_HOTEND_INVERTED) && !defined(STATUS_HOTEND_ANIM) + B00100000,B00010000, + B00100000,B00010000, + B00100000,B00010000, + B00010000,B00100000, + B00010000,B00100000, + B00100000,B00010000, + B00100000,B00010000, + B00110000,B00110000, + B00001000,B01000000, + B00000100,B10000000, + #else + B00111111,B11110000, + B00111111,B11110000, + B00111111,B11110000, + B00011111,B11100000, + B00011111,B11100000, + B00111111,B11110000, + B00111111,B11110000, + B00111111,B11110000, + B00001111,B11000000, + B00000111,B10000000, + #endif B00000011,B00000000 }; diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index f05958e675..5fe8b61bf4 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -57,6 +57,10 @@ #include "../../feature/cooler.h" #endif +#if ENABLED(I2C_AMMETER) + #include "../../feature/ammeter.h" +#endif + #if HAS_POWER_MONITOR #include "../../feature/power_monitor.h" #endif @@ -205,6 +209,14 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co } #endif +#if DO_DRAW_AMMETER + FORCE_INLINE void _draw_centered_current(const float current, const uint8_t tx, const uint8_t ty) { + const char *str = ftostr31ns(current); + 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]); + } +#endif + #if DO_DRAW_HOTENDS // Draw hotend bitmap with current and target temperatures @@ -228,18 +240,12 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co #define HOTEND_DOT false #endif - #if ANIM_HOTEND && BOTH(STATUS_HOTEND_INVERTED, STATUS_HOTEND_NUMBERLESS) - #define OFF_BMP(N) status_hotend_b_bmp - #define ON_BMP(N) status_hotend_a_bmp - #elif ANIM_HOTEND && DISABLED(STATUS_HOTEND_INVERTED) && ENABLED(STATUS_HOTEND_NUMBERLESS) - #define OFF_BMP(N) status_hotend_a_bmp - #define ON_BMP(N) status_hotend_b_bmp - #elif BOTH(ANIM_HOTEND, STATUS_HOTEND_INVERTED) - #define OFF_BMP(N) status_hotend##N##_b_bmp - #define ON_BMP(N) status_hotend##N##_a_bmp + #if ENABLED(STATUS_HOTEND_NUMBERLESS) + #define OFF_BMP(N) TERN(STATUS_HOTEND_INVERTED, status_hotend_b_bmp, status_hotend_a_bmp) + #define ON_BMP(N) TERN(STATUS_HOTEND_INVERTED, status_hotend_a_bmp, status_hotend_b_bmp) #else - #define OFF_BMP(N) status_hotend##N##_a_bmp - #define ON_BMP(N) status_hotend##N##_b_bmp + #define OFF_BMP(N) TERN(STATUS_HOTEND_INVERTED, status_hotend##N##_b_bmp, status_hotend##N##_a_bmp) + #define ON_BMP(N) TERN(STATUS_HOTEND_INVERTED, status_hotend##N##_a_bmp, status_hotend##N##_b_bmp) #endif #if STATUS_HOTEND_BITMAPS > 1 @@ -258,16 +264,17 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co #define HOTEND_BITMAP(N,S) status_hotend_a_bmp #endif - if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_BOT)) { + #if DISABLED(STATUS_COMBINE_HEATERS) - #define BAR_TALL (STATUS_HEATERS_HEIGHT - 2) + if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_BOT)) { - const float prop = target - 20, - perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0; - uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f); - NOMORE(tall, BAR_TALL); + #define BAR_TALL (STATUS_HEATERS_HEIGHT - 2) + + const float prop = target - 20, + perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0; + uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f); + NOMORE(tall, BAR_TALL); - #if ANIM_HOTEND // Draw hotend bitmap, either whole or split by the heating percent const uint8_t hx = STATUS_HOTEND_X(heater_id), bw = STATUS_HOTEND_BYTEWIDTH(heater_id); @@ -280,9 +287,10 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co else #endif u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(TERN(HAS_MMU, active_extruder, heater_id), isHeat)); - #endif - } // PAGE_CONTAINS + } // PAGE_CONTAINS + + #endif // !STATUS_COMBINE_HEATERS if (PAGE_UNDER(7)) { #if HEATER_IDLE_HANDLER @@ -404,6 +412,13 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co } #endif +#if DO_DRAW_AMMETER + FORCE_INLINE void _draw_ammeter_status() { + if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) + _draw_centered_current(ammeter.read(), STATUS_AMMETER_TEXT_X, 28); + } +#endif + // // Before homing, blink '123' <-> '???'. // Homed but unknown... '123' <-> ' '. @@ -677,6 +692,13 @@ void MarlinUI::draw_status_screen() { u8g.drawBitmapP(STATUS_FLOWMETER_X, flowmetery, STATUS_FLOWMETER_BYTEWIDTH, flowmeterh, blink && cooler.flowpulses ? status_flowmeter_bmp2 : status_flowmeter_bmp1); #endif + // Laser Ammeter + #if DO_DRAW_AMMETER + const uint8_t ammetery = STATUS_AMMETER_Y(status_ammeter_bmp_mA), + ammeterh = STATUS_AMMETER_HEIGHT(status_ammeter_bmp_mA); + if (PAGE_CONTAINS(ammetery, ammetery + ammeterh - 1)) + u8g.drawBitmapP(STATUS_AMMETER_X, ammetery, STATUS_AMMETER_BYTEWIDTH, ammeterh, (ammeter.current < 0.1f) ? status_ammeter_bmp_mA : status_ammeter_bmp_A); + #endif // Heated Bed TERN_(DO_DRAW_BED, _draw_bed_status(blink)); @@ -690,6 +712,9 @@ void MarlinUI::draw_status_screen() { // Flowmeter TERN_(DO_DRAW_FLOWMETER, _draw_flowmeter_status()); + // Flowmeter + TERN_(DO_DRAW_AMMETER, _draw_ammeter_status()); + // Fan, if a bitmap was provided #if DO_DRAW_FAN if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) { diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index 2f8b5f67e2..c76857b6bb 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -536,7 +536,7 @@ void ST7920_Lite_Status_Screen::draw_heat_icon(const bool whichIcon, const bool static struct { bool E1_show_target : 1; bool E2_show_target : 1; - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED bool bed_show_target : 1; #endif } display_state = { diff --git a/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp b/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp index 7b4c470afe..2a21bd67ca 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp @@ -24,7 +24,7 @@ #if HAS_MARLINUI_U8GLIB #include "HAL_LCD_com_defines.h" -#include +#include #define WIDTH 128 #define HEIGHT 64 diff --git a/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp index 84c10dbb4d..fda090338c 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp @@ -57,7 +57,7 @@ #if HAS_MARLINUI_U8GLIB -#include +#include #include "HAL_LCD_com_defines.h" #define WIDTH 128 diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.h b/Marlin/src/lcd/dogm/u8g_fontutf8.h index 34e365cf95..9760ef106b 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.h +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.h @@ -8,7 +8,7 @@ */ #pragma once -#include +#include #include "../fontutils.h" // the macro to indicate a UTF-8 string @@ -35,3 +35,6 @@ int uxg_GetUtf8StrPixelWidth(u8g_t *pu8g, const char *utf8_msg); int uxg_GetUtf8StrPixelWidthP(u8g_t *pu8g, PGM_P utf8_msg); #define uxg_GetFont(puxg) ((puxg)->font) + +#define _LANG_FONT_INFO(L) g_fontinfo_##L +#define LANG_FONT_INFO(L) _LANG_FONT_INFO(L) diff --git a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.h b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.h index e8a48299cb..446bfcfd42 100644 --- a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.h +++ b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.h @@ -35,7 +35,7 @@ #define PAGE_HEIGHT 16 // 256 byte framebuffer //#define PAGE_HEIGHT 32 // 512 byte framebuffer -#include +#include void ST7920_SWSPI_SND_8BIT(uint8_t val); diff --git a/Marlin/src/lcd/dwin/e3v2/README.md b/Marlin/src/lcd/e3v2/creality/README.md similarity index 100% rename from Marlin/src/lcd/dwin/e3v2/README.md rename to Marlin/src/lcd/e3v2/creality/README.md diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp similarity index 96% rename from Marlin/src/lcd/dwin/e3v2/dwin.cpp rename to Marlin/src/lcd/e3v2/creality/dwin.cpp index 777b56ac0e..05da343f9e 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -42,10 +42,6 @@ #define JUST_BABYSTEP 1 #endif -#include -#include -#include - #include "../../fontutils.h" #include "../../marlinui.h" @@ -85,6 +81,10 @@ #include "../../../feature/powerloss.h" #endif +#include +#include +#include + #ifndef MACHINE_SIZE #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #endif @@ -97,10 +97,6 @@ #define USE_STRING_HEADINGS //#define USE_STRING_TITLES -#define DWIN_FONT_MENU font8x16 -#define DWIN_FONT_STAT font10x20 -#define DWIN_FONT_HEAD font10x20 - #define MENU_CHAR_LIMIT 24 #define STATUS_Y 360 @@ -135,6 +131,9 @@ constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, // Total rows, and other #define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, dwin_zoffset) +#define DWIN_BOTTOM (DWIN_HEIGHT-1) +#define DWIN_RIGHT (DWIN_WIDTH-1) + /* Value Init */ HMI_value_t HMI_ValueStruct; HMI_Flag_t HMI_flag{0}; @@ -182,10 +181,10 @@ static uint8_t _card_percent = 0; static uint16_t _remain_time = 0; #if ENABLED(PAUSE_HEAT) - #if ENABLED(HAS_HOTEND) + #if HAS_HOTEND uint16_t resume_hotend_temp = 0; #endif - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED uint16_t resume_bed_temp = 0; #endif #endif @@ -220,11 +219,11 @@ void HMI_ToggleLanguage() { void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) { if (value < 0) { - DWIN_Draw_String(false, true, size, Color_White, bColor, x - 6, y, F("-")); + DWIN_Draw_String(true, size, Color_White, bColor, x - 6, y, F("-")); DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, -value); } else { - DWIN_Draw_String(false, true, size, Color_White, bColor, x - 6, y, F(" ")); + DWIN_Draw_String(true, size, Color_White, bColor, x - 6, y, F(" ")); DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, value); } } @@ -391,20 +390,20 @@ void ICON_Stop() { } } -void Clear_Title_Bar() { - DWIN_Draw_Rectangle(1, Color_Bg_Blue, 0, 0, DWIN_WIDTH, 30); +inline void Clear_Title_Bar() { + DWIN_Draw_Box(1, Color_Bg_Blue, 0, 0, DWIN_WIDTH, TITLE_HEIGHT); } void Draw_Title(const char * const title) { - DWIN_Draw_String(false, false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title); + DWIN_Draw_String(false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title); } void Draw_Title(const __FlashStringHelper * title) { - DWIN_Draw_String(false, false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title); + DWIN_Draw_String(false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title); } -void Clear_Menu_Area() { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y - 1); +inline void Clear_Menu_Area() { + DWIN_Draw_Box(1, Color_Bg_Black, 0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - TITLE_HEIGHT); } void Clear_Main_Window() { @@ -465,7 +464,7 @@ void Erase_Menu_Text(const uint8_t line) { } 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 (label) DWIN_Draw_String(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); } @@ -494,7 +493,8 @@ void Draw_Back_First(const bool is_sel=true) { if (is_sel) Draw_Menu_Cursor(0); } -inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valref) { +template +inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, T &valref) { if (encoder_diffState == ENCODER_DIFF_CW) valref += EncoderRate.encoderMoveValue; else if (encoder_diffState == ENCODER_DIFF_CCW) @@ -563,7 +563,7 @@ inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valr // void DWIN_Draw_Label(const uint16_t y, char *string) { - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, y, string); + DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, LBLX, y, string); } void DWIN_Draw_Label(const uint16_t y, const __FlashStringHelper *title) { DWIN_Draw_Label(y, (char*)title); @@ -577,7 +577,9 @@ void draw_move_en(const uint16_t line) { #endif } -void DWIN_Frame_TitleCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { DWIN_Frame_AreaCopy(id, x1, y1, x2, y2, 14, 8); } +inline void DWIN_Frame_TitleCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { + DWIN_Frame_AreaCopy(id, x1, y1, x2, y2, 14, 8); +} void Item_Prepare_Move(const uint8_t row) { if (HMI_IsChinese()) @@ -703,7 +705,7 @@ void Item_Prepare_Lang(const uint8_t row) { DWIN_Frame_AreaCopy(1, 0, 194, 121, 207, LBLX, MBASE(row)); // "Language selection" #endif } - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 226, MBASE(row), HMI_IsChinese() ? F("CN") : F("EN")); + DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Black, 226, MBASE(row), HMI_IsChinese() ? F("CN") : F("EN")); Draw_Menu_Icon(row, ICON_Language); } @@ -849,7 +851,7 @@ void Draw_Tune_Menu() { Clear_Main_Window(); if (HMI_IsChinese()) { - DWIN_Frame_AreaCopy(1, 73, 2, 100, 13, 14, 9); + DWIN_Frame_TitleCopy(1, 73, 2, 100, 13); DWIN_Frame_AreaCopy(1, 116, 164, 171, 176, LBLX, MBASE(TUNE_CASE_SPEED)); #if HAS_HOTEND DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(TUNE_CASE_TEMP)); @@ -883,6 +885,7 @@ void Draw_Tune_Menu() { #endif DWIN_Draw_Label(MBASE(TUNE_CASE_ZOFF), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); #else + DWIN_Frame_TitleCopy(1, 94, 2, 126, 12); DWIN_Frame_AreaCopy(1, 1, 179, 92, 190, LBLX, MBASE(TUNE_CASE_SPEED)); // Print speed #if HAS_HOTEND DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(TUNE_CASE_TEMP)); // Hotend... @@ -1008,6 +1011,7 @@ void Draw_Motion_Menu() { // // Draw Popup Windows // + #if HAS_HOTEND || HAS_HEATED_BED void DWIN_Popup_Temperature(const bool toohigh) { @@ -1021,8 +1025,8 @@ void Draw_Motion_Menu() { DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } else { - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 36, 300, F("Nozzle or Bed temperature")); - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 92, 300, F("is too high")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, 36, 300, F("Nozzle or Bed temperature")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, 92, 300, F("is too high")); } } else { @@ -1032,8 +1036,8 @@ void Draw_Motion_Menu() { DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } else { - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 36, 300, F("Nozzle or Bed temperature")); - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 92, 300, F("is too low")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, 36, 300, F("Nozzle or Bed temperature")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, 92, 300, F("is too low")); } } } @@ -1052,11 +1056,11 @@ void Draw_Popup_Bkgd_60() { DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 105); if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, 103, 371, 136, 386, 69, 240); - DWIN_Frame_AreaCopy(1, 170, 371, 270, 386, 102, 240); + DWIN_Frame_AreaCopy(1, 170, 371, 270, 386, 69 + 33, 240); DWIN_ICON_Show(ICON, ICON_Confirm_C, 86, 280); } else { - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 20, 235, F("Nozzle is too cold")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, 20, 235, F("Nozzle is too cold")); DWIN_ICON_Show(ICON, ICON_Confirm_E, 86, 280); } } @@ -1073,9 +1077,9 @@ void Popup_Window_Resume() { DWIN_ICON_Show(ICON, ICON_Continue_C, 146, 307); } else { - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 14) / 2, 115, F("Continue Print")); - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 192, F("It looks like the last")); - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 212, F("file was interrupted.")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 14) / 2, 115, F("Continue Print")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 192, F("It looks like the last")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 212, F("file was interrupted.")); DWIN_ICON_Show(ICON, ICON_Cancel_E, 26, 307); DWIN_ICON_Show(ICON, ICON_Continue_E, 146, 307); } @@ -1091,8 +1095,8 @@ void Popup_Window_Home(const bool parking/*=false*/) { DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); } else { - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * (parking ? 7 : 10)) / 2, 230, parking ? F("Parking") : F("Homing XYZ")); - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * (parking ? 7 : 10)) / 2, 230, parking ? F("Parking") : F("Homing XYZ")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); } } @@ -1107,8 +1111,8 @@ void Popup_Window_Home(const bool parking/*=false*/) { DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); } else { - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 13) / 2, 230, GET_TEXT_F(MSG_BED_LEVELING)); - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 13) / 2, 230, GET_TEXT_F(MSG_BED_LEVELING)); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); } } @@ -1135,8 +1139,8 @@ void Popup_window_PauseOrStop() { DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 280); } else { - if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 11) / 2, 150, GET_TEXT_F(MSG_PAUSE_PRINT)); - else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 10) / 2, 150, GET_TEXT_F(MSG_STOP_PRINT)); + if (select_print.now == 1) DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 11) / 2, 150, GET_TEXT_F(MSG_PAUSE_PRINT)); + else if (select_print.now == 2) DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 10) / 2, 150, GET_TEXT_F(MSG_STOP_PRINT)); DWIN_ICON_Show(ICON, ICON_Confirm_E, 26, 280); DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 280); } @@ -1160,19 +1164,19 @@ void Draw_Print_ProgressBar() { DWIN_ICON_Show(ICON, ICON_Bar, 15, 93); DWIN_Draw_Rectangle(1, BarFill_Color, 16 + _card_percent * 240 / 100, 93, 256, 113); DWIN_Draw_IntValue(true, true, 0, font8x16, Percent_Color, Color_Bg_Black, 2, 117, 133, _card_percent); - DWIN_Draw_String(false, false, font8x16, Percent_Color, Color_Bg_Black, 133, 133, F("%")); + DWIN_Draw_String(false, font8x16, Percent_Color, Color_Bg_Black, 133, 133, F("%")); } void Draw_Print_ProgressElapsed() { duration_t elapsed = print_job_timer.duration(); // print timer DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 42, 212, elapsed.value / 3600); - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 58, 212, F(":")); + DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Black, 58, 212, F(":")); DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 66, 212, (elapsed.value % 3600) / 60); } void Draw_Print_ProgressRemain() { DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 176, 212, _remain_time / 3600); - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 192, 212, F(":")); + DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Black, 192, 212, F(":")); DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 200, 212, (_remain_time % 3600) / 60); } @@ -1189,7 +1193,7 @@ void Goto_PrintProcess() { // Copy into filebuf string before entry char * const name = card.longest_filename(); const int8_t npos = _MAX(0U, DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, npos, 60, name); + DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Black, npos, 60, name); DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193); DWIN_ICON_Show(ICON, ICON_RemainTime, 150, 191); @@ -1204,14 +1208,13 @@ void Goto_MainMenu() { Clear_Main_Window(); - if (HMI_IsChinese()) { - DWIN_Frame_AreaCopy(1, 2, 2, 27, 14, 14, 9); // "Home" - } + if (HMI_IsChinese()) + DWIN_Frame_TitleCopy(1, 2, 2, 27, 14); // "Home" else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_MAIN)); #else - DWIN_Frame_AreaCopy(1, 0, 2, 39, 12, 14, 9); + DWIN_Frame_TitleCopy(1, 0, 2, 39, 12); #endif } @@ -1588,9 +1591,9 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, if (force || changed || draw_qmark || draw_empty) { if (blink && draw_qmark) - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F("???.?")); + DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, x, y, F("???.?")); else if (blink && draw_empty) - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F(" ")); + DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, x, y, F(" ")); else DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, x, y, p * 10); } @@ -1706,11 +1709,11 @@ void update_variable() { _offset = BABY_Z_VAR; if (BABY_Z_VAR < 0) { DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -_offset * 100); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F("-")); + DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, 205, 419, F("-")); } else { DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, _offset * 100); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F(" ")); + DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, 205, 419, F(" ")); } } @@ -1853,7 +1856,7 @@ void Redraw_SD_List() { } else { DWIN_Draw_Rectangle(1, Color_Bg_Red, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); - DWIN_Draw_String(false, false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), F("No Media")); + DWIN_Draw_String(false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), F("No Media")); } } @@ -1911,24 +1914,24 @@ 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.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_String(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)); DWIN_ICON_Show(ICON, ICON_StepE, 112, 417); DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%")); + DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%")); #endif #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.wholeDegBed()); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); + DWIN_Draw_String(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 DWIN_ICON_Show(ICON, ICON_Speed, 113, 383); DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%")); + DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%")); #if HAS_FAN DWIN_ICON_Show(ICON, ICON_FanSpeed, 187, 383); @@ -1941,11 +1944,11 @@ void Draw_Status_Area(const bool with_update) { if (BABY_Z_VAR < 0) { DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -BABY_Z_VAR * 100); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F("-")); + DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, 205, 419, F("-")); } else { DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, BABY_Z_VAR * 100); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F(" ")); + DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, 205, 419, F(" ")); } DWIN_Draw_Rectangle(1, Line_Color, 0, 449, DWIN_WIDTH, 451); @@ -1969,8 +1972,8 @@ void HMI_StartFrame(const bool with_update) { void Draw_Info_Menu() { Clear_Main_Window(); - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(MACHINE_SIZE) * MENU_CHR_W) / 2, 122, F(MACHINE_SIZE)); - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(SHORT_BUILD_VERSION) * MENU_CHR_W) / 2, 195, F(SHORT_BUILD_VERSION)); + DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(MACHINE_SIZE) * MENU_CHR_W) / 2, 122, F(MACHINE_SIZE)); + DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(SHORT_BUILD_VERSION) * MENU_CHR_W) / 2, 195, F(SHORT_BUILD_VERSION)); if (HMI_IsChinese()) { DWIN_Frame_TitleCopy(1, 30, 17, 57, 29); // "Info" @@ -1990,7 +1993,7 @@ void Draw_Info_Menu() { DWIN_Frame_AreaCopy(1, 146, 151, 254, 161, 82, 175); DWIN_Frame_AreaCopy(1, 0, 165, 94, 175, 89, 248); } - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE) * MENU_CHR_W) / 2, 268, F(CORP_WEBSITE)); + DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE) * MENU_CHR_W) / 2, 268, F(CORP_WEBSITE)); Draw_Back_First(); LOOP_L_N(i, 3) { @@ -2417,13 +2420,15 @@ void Draw_HomeOff_Menu() { #include "../../../libs/buzzer.h" void HMI_AudioFeedback(const bool success=true) { - if (success) { - buzzer.tone(100, 659); - buzzer.tone(10, 0); - buzzer.tone(100, 698); - } - else - buzzer.tone(40, 440); + #if HAS_BUZZER + if (success) { + buzzer.tone(100, 659); + buzzer.tone(10, 0); + buzzer.tone(100, 698); + } + else + buzzer.tone(40, 440); + #endif } /* Prepare */ @@ -4005,7 +4010,7 @@ void EachMomentUpdate() { //(void)recovery.interrupted_file_exists(); char * const name = card.longest_filename(); const int8_t npos = _MAX(0U, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2; - DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name); + DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name); DWIN_UpdateLCD(); while (recovery_flag) { @@ -4031,7 +4036,7 @@ void EachMomentUpdate() { Goto_PrintProcess(); Draw_Status_Area(true); } - #endif + #endif // POWER_LOSS_RECOVERY DWIN_UpdateLCD(); } @@ -4122,14 +4127,20 @@ void DWIN_CompletedLeveling() { void DWIN_StatusChanged(const char *text) { DWIN_Draw_Rectangle(1, Color_Bg_Blue, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(text) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Blue, x, STATUS_Y + 2, F(text)); + DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Blue, x, STATUS_Y + 2, F(text)); DWIN_UpdateLCD(); } +void DWIN_StatusChanged_P(PGM_P const pstr) { + char str[strlen_P((const char*)pstr) + 1]; + strcpy_P(str, (const char*)pstr); + DWIN_StatusChanged(str); +} + // 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); + DWIN_Draw_String(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/e3v2/creality/dwin.h similarity index 53% rename from Marlin/src/lcd/dwin/e3v2/dwin.h rename to Marlin/src/lcd/e3v2/creality/dwin.h index ad210db27d..36948678aa 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/e3v2/creality/dwin.h @@ -25,7 +25,7 @@ * DWIN by Creality3D */ -#include "../dwin_lcd.h" +#include "dwin_lcd.h" #include "rotary_encoder.h" #include "../../../libs/BL24CXX.h" @@ -103,151 +103,6 @@ enum processID : uint8_t { Popup_Window }; -// Picture ID -#define Start_Process 0 -#define Language_English 1 -#define Language_Chinese 2 - -// ICON ID -#define ICON 0x09 -#define ICON_LOGO 0 -#define ICON_Print_0 1 -#define ICON_Print_1 2 -#define ICON_Prepare_0 3 -#define ICON_Prepare_1 4 -#define ICON_Control_0 5 -#define ICON_Control_1 6 -#define ICON_Leveling_0 7 -#define ICON_Leveling_1 8 -#define ICON_HotendTemp 9 -#define ICON_BedTemp 10 -#define ICON_Speed 11 -#define ICON_Zoffset 12 -#define ICON_Back 13 -#define ICON_File 14 -#define ICON_PrintTime 15 -#define ICON_RemainTime 16 -#define ICON_Setup_0 17 -#define ICON_Setup_1 18 -#define ICON_Pause_0 19 -#define ICON_Pause_1 20 -#define ICON_Continue_0 21 -#define ICON_Continue_1 22 -#define ICON_Stop_0 23 -#define ICON_Stop_1 24 -#define ICON_Bar 25 -#define ICON_More 26 - -#define ICON_Axis 27 -#define ICON_CloseMotor 28 -#define ICON_Homing 29 -#define ICON_SetHome 30 -#define ICON_PLAPreheat 31 -#define ICON_ABSPreheat 32 -#define ICON_Cool 33 -#define ICON_Language 34 - -#define ICON_MoveX 35 -#define ICON_MoveY 36 -#define ICON_MoveZ 37 -#define ICON_Extruder 38 - -#define ICON_Temperature 40 -#define ICON_Motion 41 -#define ICON_WriteEEPROM 42 -#define ICON_ReadEEPROM 43 -#define ICON_ResumeEEPROM 44 -#define ICON_Info 45 - -#define ICON_SetEndTemp 46 -#define ICON_SetBedTemp 47 -#define ICON_FanSpeed 48 -#define ICON_SetPLAPreheat 49 -#define ICON_SetABSPreheat 50 - -#define ICON_MaxSpeed 51 -#define ICON_MaxAccelerated 52 -#define ICON_MaxJerk 53 -#define ICON_Step 54 -#define ICON_PrintSize 55 -#define ICON_Version 56 -#define ICON_Contact 57 -#define ICON_StockConfiguraton 58 -#define ICON_MaxSpeedX 59 -#define ICON_MaxSpeedY 60 -#define ICON_MaxSpeedZ 61 -#define ICON_MaxSpeedE 62 -#define ICON_MaxAccX 63 -#define ICON_MaxAccY 64 -#define ICON_MaxAccZ 65 -#define ICON_MaxAccE 66 -#define ICON_MaxSpeedJerkX 67 -#define ICON_MaxSpeedJerkY 68 -#define ICON_MaxSpeedJerkZ 69 -#define ICON_MaxSpeedJerkE 70 -#define ICON_StepX 71 -#define ICON_StepY 72 -#define ICON_StepZ 73 -#define ICON_StepE 74 -#define ICON_Setspeed 75 -#define ICON_SetZOffset 76 -#define ICON_Rectangle 77 -#define ICON_BLTouch 78 -#define ICON_TempTooLow 79 -#define ICON_AutoLeveling 80 -#define ICON_TempTooHigh 81 -#define ICON_NoTips_C 82 -#define ICON_NoTips_E 83 -#define ICON_Continue_C 84 -#define ICON_Continue_E 85 -#define ICON_Cancel_C 86 -#define ICON_Cancel_E 87 -#define ICON_Confirm_C 88 -#define ICON_Confirm_E 89 -#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 - * 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64 - */ -#define font6x12 0x00 -#define font8x16 0x01 -#define font10x20 0x02 -#define font12x24 0x03 -#define font14x28 0x04 -#define font16x32 0x05 -#define font20x40 0x06 -#define font24x48 0x07 -#define font28x56 0x08 -#define font32x64 0x09 - -// Color -#define Color_White 0xFFFF -#define Color_Yellow 0xFF0F -#define Color_Bg_Window 0x31E8 // Popup background color -#define Color_Bg_Blue 0x1125 // Dark blue background color -#define Color_Bg_Black 0x0841 // Black background color -#define Color_Bg_Red 0xF00F // Red background color -#define Popup_Text_Color 0xD6BA // Popup font background color -#define Line_Color 0x3A6A // Split line color -#define Rectangle_Color 0xEE2F // Blue square cursor color -#define Percent_Color 0xFE29 // Percentage color -#define BarFill_Color 0x10E4 // Fill color of progress bar -#define Select_Color 0x33BB // Selected color - extern uint8_t checkkey; extern float zprobe_zoffset; extern char print_filename[16]; @@ -255,13 +110,13 @@ extern char print_filename[16]; extern millis_t dwin_heat_time; typedef struct { - #if ENABLED(HAS_HOTEND) + #if HAS_HOTEND celsius_t E_Temp = 0; #endif - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED celsius_t Bed_Temp = 0; #endif - #if ENABLED(HAS_FAN) + #if HAS_FAN int16_t Fan_speed = 0; #endif int16_t print_speed = 100; @@ -344,13 +199,13 @@ void HMI_Move_E(); void HMI_Zoffset(); -#if ENABLED(HAS_HOTEND) +#if HAS_HOTEND void HMI_ETemp(); #endif -#if ENABLED(HAS_HEATED_BED) +#if HAS_HEATED_BED void HMI_BedTemp(); #endif -#if ENABLED(HAS_FAN) +#if HAS_FAN void HMI_FanSpeed(); #endif @@ -404,6 +259,7 @@ void DWIN_Update(); void EachMomentUpdate(); void DWIN_HandleScreen(); void DWIN_StatusChanged(const char *text); +void DWIN_StatusChanged_P(PGM_P const pstr); 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/dwin/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp similarity index 93% rename from Marlin/src/lcd/dwin/dwin_lcd.cpp rename to Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp index 59bc46925a..1ce95bd729 100644 --- a/Marlin/src/lcd/dwin/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp @@ -21,24 +21,24 @@ */ /******************************************************************************** - * @file dwin_lcd.cpp + * @file lcd/e3v2/creality/dwin_lcd.cpp * @author LEO / Creality3D * @date 2019/07/18 * @version 2.0.1 * @brief DWIN screen control functions ********************************************************************************/ -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if ENABLED(DWIN_CREALITY_LCD) -#include "../../inc/MarlinConfig.h" +#include "../../../inc/MarlinConfig.h" #include "dwin_lcd.h" #include // for memset //#define DEBUG_OUT 1 -#include "../../core/debug_out.h" +#include "../../../core/debug_out.h" // Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail. // Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters. @@ -122,6 +122,17 @@ bool DWIN_Handshake(void) { && databuf[3] == 'K' ); } +void DWIN_Startup(void) { + DEBUG_ECHOPGM("\r\nDWIN handshake "); + delay(750); // Delay here or init later in the boot process + if (DWIN_Handshake()) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error."); + DWIN_Frame_SetDir(1); + #if DISABLED(SHOW_BOOTSCREEN) + DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here + #endif + DWIN_UpdateLCD(); +} + // Set the backlight luminance // luminance: (0x00-0xFF) void DWIN_Backlight_SetLuminance(const uint8_t luminance) { @@ -164,9 +175,10 @@ void DWIN_Frame_Clear(const uint16_t color) { // width: point width 0x01-0x0F // height: point height 0x01-0x0F // x,y: upper left point -void DWIN_Draw_Point(uint8_t width, uint8_t height, uint16_t x, uint16_t y) { +void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) { size_t i = 0; DWIN_Byte(i, 0x02); + DWIN_Word(i, color); DWIN_Byte(i, width); DWIN_Byte(i, height); DWIN_Word(i, x); @@ -238,8 +250,8 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // bColor: Background color // x/y: Upper-left coordinate of the string // *string: The string -void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, - uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) { +void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) { + uint8_t widthAdjust = 0; size_t i = 0; DWIN_Byte(i, 0x11); // Bit 7: widthAdjust @@ -356,6 +368,7 @@ void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) { DWIN_Word(i, x); DWIN_Word(i, y); DWIN_Byte(i, 0x80 | libID); + //DWIN_Byte(i, libID); DWIN_Byte(i, picID); DWIN_Send(i); } @@ -421,7 +434,7 @@ void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t pi // state: 16 bits, each bit is the state of an animation id void DWIN_ICON_AnimationControl(uint16_t state) { size_t i = 0; - DWIN_Byte(i, 0x28); + DWIN_Byte(i, 0x29); DWIN_Word(i, state); DWIN_Send(i); } diff --git a/Marlin/src/lcd/dwin/dwin_lcd.h b/Marlin/src/lcd/e3v2/creality/dwin_lcd.h similarity index 55% rename from Marlin/src/lcd/dwin/dwin_lcd.h rename to Marlin/src/lcd/e3v2/creality/dwin_lcd.h index 9ae6d076d5..e5e79df0fd 100644 --- a/Marlin/src/lcd/dwin/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/creality/dwin_lcd.h @@ -42,6 +42,163 @@ #define DWIN_WIDTH 272 #define DWIN_HEIGHT 480 +// Character matrix width x height +//#define LCD_WIDTH ((DWIN_WIDTH) / 8) +//#define LCD_HEIGHT ((DWIN_HEIGHT) / 12) + +// Picture ID +#define DWIN_Boot_Screen 0 +#define Language_English 1 +#define Language_Chinese 2 + +// ICON ID +#define ICON 0x09 + +#define ICON_LOGO 0 +#define ICON_Print_0 1 +#define ICON_Print_1 2 +#define ICON_Prepare_0 3 +#define ICON_Prepare_1 4 +#define ICON_Control_0 5 +#define ICON_Control_1 6 +#define ICON_Leveling_0 7 +#define ICON_Leveling_1 8 +#define ICON_HotendTemp 9 +#define ICON_BedTemp 10 +#define ICON_Speed 11 +#define ICON_Zoffset 12 +#define ICON_Back 13 +#define ICON_File 14 +#define ICON_PrintTime 15 +#define ICON_RemainTime 16 +#define ICON_Setup_0 17 +#define ICON_Setup_1 18 +#define ICON_Pause_0 19 +#define ICON_Pause_1 20 +#define ICON_Continue_0 21 +#define ICON_Continue_1 22 +#define ICON_Stop_0 23 +#define ICON_Stop_1 24 +#define ICON_Bar 25 +#define ICON_More 26 + +#define ICON_Axis 27 +#define ICON_CloseMotor 28 +#define ICON_Homing 29 +#define ICON_SetHome 30 +#define ICON_PLAPreheat 31 +#define ICON_ABSPreheat 32 +#define ICON_Cool 33 +#define ICON_Language 34 + +#define ICON_MoveX 35 +#define ICON_MoveY 36 +#define ICON_MoveZ 37 +#define ICON_Extruder 38 + +#define ICON_Temperature 40 +#define ICON_Motion 41 +#define ICON_WriteEEPROM 42 +#define ICON_ReadEEPROM 43 +#define ICON_ResumeEEPROM 44 +#define ICON_Info 45 + +#define ICON_SetEndTemp 46 +#define ICON_SetBedTemp 47 +#define ICON_FanSpeed 48 +#define ICON_SetPLAPreheat 49 +#define ICON_SetABSPreheat 50 + +#define ICON_MaxSpeed 51 +#define ICON_MaxAccelerated 52 +#define ICON_MaxJerk 53 +#define ICON_Step 54 +#define ICON_PrintSize 55 +#define ICON_Version 56 +#define ICON_Contact 57 +#define ICON_StockConfiguraton 58 +#define ICON_MaxSpeedX 59 +#define ICON_MaxSpeedY 60 +#define ICON_MaxSpeedZ 61 +#define ICON_MaxSpeedE 62 +#define ICON_MaxAccX 63 +#define ICON_MaxAccY 64 +#define ICON_MaxAccZ 65 +#define ICON_MaxAccE 66 +#define ICON_MaxSpeedJerkX 67 +#define ICON_MaxSpeedJerkY 68 +#define ICON_MaxSpeedJerkZ 69 +#define ICON_MaxSpeedJerkE 70 +#define ICON_StepX 71 +#define ICON_StepY 72 +#define ICON_StepZ 73 +#define ICON_StepE 74 +#define ICON_Setspeed 75 +#define ICON_SetZOffset 76 +#define ICON_Rectangle 77 +#define ICON_BLTouch 78 +#define ICON_TempTooLow 79 +#define ICON_AutoLeveling 80 +#define ICON_TempTooHigh 81 +#define ICON_NoTips_C 82 +#define ICON_NoTips_E 83 +#define ICON_Continue_C 84 +#define ICON_Continue_E 85 +#define ICON_Cancel_C 86 +#define ICON_Cancel_E 87 +#define ICON_Confirm_C 88 +#define ICON_Confirm_E 89 +#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 + * 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64 + */ +#define font6x12 0x00 +#define font8x16 0x01 +#define font10x20 0x02 +#define font12x24 0x03 +#define font14x28 0x04 +#define font16x32 0x05 +#define font20x40 0x06 +#define font24x48 0x07 +#define font28x56 0x08 +#define font32x64 0x09 + +#define DWIN_FONT_MENU font10x20 +#define DWIN_FONT_STAT font10x20 +#define DWIN_FONT_HEAD font10x20 +#define DWIN_FONT_ALERT font14x28 + +// Color +#define Color_White 0xFFFF +#define Color_Yellow 0xFF0F +#define Color_Error_Red 0xB000 // Error! +#define Color_Bg_Red 0xF00F // Red background color +#define Color_Bg_Window 0x31E8 // Popup background color +#define Color_Bg_Blue 0x1125 // Dark blue background color +#define Color_Bg_Black 0x0841 // Black background color +#define Color_IconBlue 0x45FA // Lighter blue that matches icons/accents +#define Popup_Text_Color 0xD6BA // Popup font background color +#define Line_Color 0x3A6A // Split line color +#define Rectangle_Color 0xEE2F // Blue square cursor color +#define Percent_Color 0xFE29 // Percentage color +#define BarFill_Color 0x10E4 // Fill color of progress bar +#define Select_Color 0x33BB // Selected color + /*-------------------------------------- System variable function --------------------------------------*/ // Handshake (1: Success, 0: Fail) @@ -68,10 +225,11 @@ void DWIN_UpdateLCD(void); void DWIN_Frame_Clear(const uint16_t color); // Draw a point +// color: point color // width: point width 0x01-0x0F // height: point height 0x01-0x0F // x,y: upper left point -void DWIN_Draw_Point(uint8_t width, uint8_t height, uint16_t x, uint16_t y); +void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y); // Draw a line // color: Line segment color @@ -125,20 +283,18 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, /*---------------------------------------- Text related functions ----------------------------------------*/ // Draw a string -// widthAdjust: true=self-adjust character width; false=no adjustment // bShow: true=display background color; false=don't display background color // size: Font size // color: Character color // bColor: Background color // x/y: Upper-left coordinate of the string // *string: The string -void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, - uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string); +void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string); class __FlashStringHelper; -inline void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) { - DWIN_Draw_String(widthAdjust, bShow, size, color, bColor, x, y, (char *)title); +inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) { + DWIN_Draw_String(bShow, size, color, bColor, x, y, (char *)title); } // Draw a positive integer diff --git a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp b/Marlin/src/lcd/e3v2/creality/rotary_encoder.cpp similarity index 98% rename from Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp rename to Marlin/src/lcd/e3v2/creality/rotary_encoder.cpp index 6c229b7aca..4fc10393b9 100644 --- a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp +++ b/Marlin/src/lcd/e3v2/creality/rotary_encoder.cpp @@ -21,7 +21,7 @@ */ /***************************************************************************** - * @file rotary_encoder.cpp + * @file lcd/e3v2/creality/rotary_encoder.cpp * @author LEO / Creality3D * @date 2019/07/06 * @version 2.0.1 @@ -121,7 +121,7 @@ ENCODER_DiffState Encoder_ReceiveAnalyze() { lastEncoderBits = newbutton; } - if (abs(temp_diff) >= ENCODER_PULSES_PER_STEP) { + if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) { if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW; else temp_diffState = ENCODER_DIFF_CCW; diff --git a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h b/Marlin/src/lcd/e3v2/creality/rotary_encoder.h similarity index 98% rename from Marlin/src/lcd/dwin/e3v2/rotary_encoder.h rename to Marlin/src/lcd/e3v2/creality/rotary_encoder.h index 7de80dfe01..f73577b3b0 100644 --- a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h +++ b/Marlin/src/lcd/e3v2/creality/rotary_encoder.h @@ -22,7 +22,7 @@ #pragma once /***************************************************************************** - * @file rotary_encoder.h + * @file lcd/e3v2/creality/rotary_encoder.h * @author LEO / Creality3D * @date 2019/07/06 * @version 2.0.1 diff --git a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h index f1071f6b0a..ed8178449d 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h @@ -108,14 +108,14 @@ private: static bool Initialized, no_reentrance; }; -#define GET_VARIABLE(f, t, V...) (&DGUSDisplay::GetVariable) -#define SET_VARIABLE(f, t, V...) (&DGUSDisplay::SetVariable) - extern DGUSDisplay dgusdisplay; // compile-time x^y constexpr float cpow(const float x, const int y) { return y == 0 ? 1.0 : x * cpow(x, y - 1); } +/// +const uint16_t* DGUSLCD_FindScreenVPMapList(uint8_t screen); + /// Find the flash address of a DGUS_VP_Variable for the VP. const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp); diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index a1de499f46..5c108d0709 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -180,7 +180,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) { float valuesend = 0; switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_PID_P: valuesend = value; break; case VP_E0_PID_I: valuesend = unscalePID_i(value); break; case VP_E0_PID_D: valuesend = unscalePID_d(value); break; @@ -393,7 +393,7 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_T_E0_Set: NOMORE(newvalue, HEATER_0_MAXTEMP); thermalManager.setTargetHotend(newvalue, 0); @@ -427,10 +427,8 @@ void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_p uint8_t target_extruder; switch (var.VP) { default: return; - #if HOTENDS >= 1 - case VP_Flowrate_E0: target_extruder = 0; break; - #endif - #if HOTENDS >= 2 + case VP_Flowrate_E0: target_extruder = 0; break; + #if HAS_MULTI_EXTRUDER case VP_Flowrate_E1: target_extruder = 1; break; #endif } @@ -450,11 +448,11 @@ void DGUSScreenHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr ExtUI::extruder_t target_extruder; switch (var.VP) { - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_MOVE_E0: target_extruder = ExtUI::extruder_t::E0; break; - #endif - #if HOTENDS >= 2 - case VP_MOVE_E1: target_extruder = ExtUI::extruder_t::E1; break; + #if HAS_MULTI_EXTRUDER + case VP_MOVE_E1: target_extruder = ExtUI::extruder_t::E1; break; + #endif #endif default: return; } @@ -526,11 +524,11 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo ExtUI::extruder_t extruder; switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_EXTRUDERS case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break; - #endif - #if HOTENDS >= 2 - case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; + #if HAS_MULTI_EXTRUDER + case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; + #endif #endif } DEBUG_ECHOLNPAIR_F("value:", value); @@ -548,7 +546,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo switch (var.VP) { default: break; #if ENABLED(PIDTEMP) - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_PID_AUTOTUNE_E0: // Autotune Extruder 0 sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E0); break; @@ -561,7 +559,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo #endif #if ENABLED(PIDTEMPBED) case VP_PID_AUTOTUNE_BED: - sprintf_P(buf, PSTR("M303 E-1 C5 S70 U1")); + strcpy_P(buf, PSTR("M303 E-1 C5 S70 U1")); break; #endif } @@ -598,17 +596,17 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr uint8_t preheat_temp = 0; switch (var.VP) { - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_CONTROL: + #if HOTENDS >= 2 + case VP_E1_CONTROL: + #if HOTENDS >= 3 + case VP_E2_CONTROL: + #endif + #endif + preheat_temp = PREHEAT_1_TEMP_HOTEND; + break; #endif - #if HOTENDS >= 2 - case VP_E1_CONTROL: - #endif - #if HOTENDS >= 3 - case VP_E2_CONTROL: - #endif - preheat_temp = PREHEAT_1_TEMP_HOTEND; - break; case VP_BED_CONTROL: preheat_temp = PREHEAT_1_TEMP_BED; @@ -624,7 +622,7 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr DEBUG_ECHOLNPGM("HandlePreheat"); uint8_t e_temp = 0; - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED uint8_t bed_temp = 0; #endif const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); @@ -660,7 +658,7 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_BED_PREHEAT: thermalManager.setTargetHotend(e_temp, 0); TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp)); diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h index 9aeb5b73b1..8ee2761c89 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h @@ -56,3 +56,21 @@ inline uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (v #endif extern DGUSScreenHandler ScreenHandler; + +// Helper to define a DGUS_VP_Variable for common use-cases. +#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR) { \ + .VP = VPADR, \ + .memadr = VPADRVAR, \ + .size = sizeof(VPADRVAR), \ + .set_by_display_handler = RXFPTR, \ + .send_to_display_handler = TXFPTR \ +} + +// Helper to define a DGUS_VP_Variable when the size of the var cannot be determined automatically (e.g., a string) +#define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR) { \ + .VP = VPADR, \ + .memadr = VPADRVAR, \ + .size = STRLEN, \ + .set_by_display_handler = RXFPTR, \ + .send_to_display_handler = TXFPTR \ +} diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp index 5e164d289e..39cb6e2bef 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp @@ -47,8 +47,8 @@ const uint16_t VPList_Boot[] PROGMEM = { }; const uint16_t VPList_Main[] PROGMEM = { - /* VP_M117, for completeness, but it cannot be auto-uploaded. */ - #if HOTENDS >= 1 + // VP_M117, for completeness, but it cannot be auto-uploaded. + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, VP_E0_STATUS, #endif #if HOTENDS >= 2 @@ -70,7 +70,7 @@ const uint16_t VPList_Main[] PROGMEM = { }; const uint16_t VPList_Temp[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif #if HOTENDS >= 2 @@ -83,8 +83,8 @@ const uint16_t VPList_Temp[] PROGMEM = { }; const uint16_t VPList_Status[] PROGMEM = { - /* VP_M117, for completeness, but it cannot be auto-uploaded */ - #if HOTENDS >= 1 + // VP_M117, for completeness, but it cannot be auto-uploaded + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif #if HOTENDS >= 2 @@ -104,12 +104,12 @@ const uint16_t VPList_Status[] PROGMEM = { }; const uint16_t VPList_Status2[] PROGMEM = { - /* VP_M117, for completeness, but it cannot be auto-uploaded */ - #if HOTENDS >= 1 + // VP_M117, for completeness, but it cannot be auto-uploaded + #if HAS_HOTEND VP_Flowrate_E0, - #endif - #if HOTENDS >= 2 - VP_Flowrate_E1, + #if HAS_MULTI_EXTRUDER + VP_Flowrate_E1, + #endif #endif VP_PrintProgress_Percentage, VP_PrintTime, @@ -117,7 +117,7 @@ const uint16_t VPList_Status2[] PROGMEM = { }; const uint16_t VPList_Preheat[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif #if HOTENDS >= 2 @@ -135,11 +135,11 @@ const uint16_t VPList_ManualMove[] PROGMEM = { }; const uint16_t VPList_ManualExtrude[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HAS_MULTI_EXTRUDER + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif VP_EPos, 0x0000 @@ -156,23 +156,23 @@ const uint16_t VPList_SD_FlowRates[] PROGMEM = { }; const uint16_t VPList_Filament_heating[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, VP_E0_FILAMENT_LOAD_UNLOAD, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, - VP_E1_FILAMENT_LOAD_UNLOAD, + #if HAS_MULTI_EXTRUDER + VP_T_E1_Is, VP_T_E1_Set, + VP_E1_FILAMENT_LOAD_UNLOAD, + #endif #endif 0x0000 }; const uint16_t VPList_Filament_load_unload[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_E0_FILAMENT_LOAD_UNLOAD, - #endif - #if HOTENDS >= 2 - VP_E1_FILAMENT_LOAD_UNLOAD, + #if HAS_MULTI_EXTRUDER + VP_E1_FILAMENT_LOAD_UNLOAD, + #endif #endif 0x0000 }; @@ -184,7 +184,7 @@ const uint16_t VPList_SDFileList[] PROGMEM = { const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { VP_PrintProgress_Percentage, VP_PrintTime, - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif #if HOTENDS >= 2 @@ -204,11 +204,11 @@ const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { }; const uint16_t VPList_SDPrintTune[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, VP_Flowrate_E0, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, VP_Flowrate_E1, + #if HAS_MULTI_EXTRUDER + VP_T_E1_Is, VP_T_E1_Set, VP_Flowrate_E1, // ERROR: Flowrate is per-extruder, not per-hotend + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, @@ -222,11 +222,11 @@ const uint16_t VPList_StepPerMM[] PROGMEM = { VP_X_STEP_PER_MM, VP_Y_STEP_PER_MM, VP_Z_STEP_PER_MM, - #if HOTENDS >= 1 + #if HAS_EXTRUDERS VP_E0_STEP_PER_MM, - #endif - #if HOTENDS >= 2 - VP_E1_STEP_PER_MM, + #if HAS_MULTI_EXTRUDER + VP_E1_STEP_PER_MM, + #endif #endif 0x0000 }; @@ -265,7 +265,7 @@ const uint16_t VPList_PIDTuningWaiting[] PROGMEM = { }; const uint16_t VPList_FLCPreheat[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif #if HAS_HEATED_BED @@ -275,55 +275,47 @@ const uint16_t VPList_FLCPreheat[] PROGMEM = { }; const uint16_t VPList_FLCPrinting[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_SD_Print_ProbeOffsetZ, #endif 0x0000 }; const uint16_t VPList_Z_Offset[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_SD_Print_ProbeOffsetZ, #endif 0x0000 }; const struct VPMapping VPMap[] PROGMEM = { - { DGUSLCD_SCREEN_BOOT, VPList_Boot }, - { DGUSLCD_SCREEN_MAIN, VPList_Main }, - { DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp }, - { DGUSLCD_SCREEN_STATUS, VPList_Status }, - { DGUSLCD_SCREEN_STATUS2, VPList_Status2 }, - { DGUSLCD_SCREEN_PREHEAT, VPList_Preheat }, - { DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove }, - { DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude }, - { DGUSLCD_SCREEN_FILAMENT_HEATING, VPList_Filament_heating }, - { DGUSLCD_SCREEN_FILAMENT_LOADING, VPList_Filament_load_unload }, - { DGUSLCD_SCREEN_FILAMENT_UNLOADING, VPList_Filament_load_unload }, + { DGUSLCD_SCREEN_BOOT, VPList_Boot }, + { DGUSLCD_SCREEN_MAIN, VPList_Main }, + { DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp }, + { DGUSLCD_SCREEN_STATUS, VPList_Status }, + { DGUSLCD_SCREEN_STATUS2, VPList_Status2 }, + { DGUSLCD_SCREEN_PREHEAT, VPList_Preheat }, + { DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove }, + { DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude }, + { DGUSLCD_SCREEN_FILAMENT_HEATING, VPList_Filament_heating }, + { DGUSLCD_SCREEN_FILAMENT_LOADING, VPList_Filament_load_unload }, + { DGUSLCD_SCREEN_FILAMENT_UNLOADING, VPList_Filament_load_unload }, { DGUSLCD_SCREEN_SDPRINTMANIPULATION, VPList_SD_PrintManipulation }, - { DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList }, - { DGUSLCD_SCREEN_SDPRINTTUNE, VPList_SDPrintTune }, - { DGUSLCD_SCREEN_WAITING, VPList_PIDTuningWaiting }, - { DGUSLCD_SCREEN_FLC_PREHEAT, VPList_FLCPreheat }, - { DGUSLCD_SCREEN_FLC_PRINTING, VPList_FLCPrinting }, - { DGUSLCD_SCREEN_Z_OFFSET, VPList_Z_Offset }, - { DGUSLCD_SCREEN_STEPPERMM, VPList_StepPerMM }, - { DGUSLCD_SCREEN_PID_E, VPList_PIDE0 }, - { DGUSLCD_SCREEN_PID_BED, VPList_PIDBED }, - { DGUSLCD_SCREEN_INFOS, VPList_Infos }, + { DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList }, + { DGUSLCD_SCREEN_SDPRINTTUNE, VPList_SDPrintTune }, + { DGUSLCD_SCREEN_WAITING, VPList_PIDTuningWaiting }, + { DGUSLCD_SCREEN_FLC_PREHEAT, VPList_FLCPreheat }, + { DGUSLCD_SCREEN_FLC_PRINTING, VPList_FLCPrinting }, + { DGUSLCD_SCREEN_Z_OFFSET, VPList_Z_Offset }, + { DGUSLCD_SCREEN_STEPPERMM, VPList_StepPerMM }, + { DGUSLCD_SCREEN_PID_E, VPList_PIDE0 }, + { DGUSLCD_SCREEN_PID_BED, VPList_PIDBED }, + { DGUSLCD_SCREEN_INFOS, VPList_Infos }, { 0 , nullptr } // List is terminated with an nullptr as table entry. }; const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION; -// Helper to define a DGUS_VP_Variable for common use cases. -#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=sizeof(VPADRVAR), \ - .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR } - -// Helper to define a DGUS_VP_Variable when the sizeo of the var cannot be determined automaticalyl (eg. a string) -#define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=STRLEN, \ - .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR } - const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Helper to detect touch events VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr), @@ -333,96 +325,96 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr), - VPHELPER(VP_TEMP_ALL_OFF, nullptr, &ScreenHandler.HandleAllHeatersOff, nullptr), + VPHELPER(VP_TEMP_ALL_OFF, nullptr, ScreenHandler.HandleAllHeatersOff, nullptr), #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_OPTION, &distanceToMove, &ScreenHandler.HandleManualMoveOption, nullptr), + VPHELPER(VP_MOVE_OPTION, &distanceToMove, ScreenHandler.HandleManualMoveOption, nullptr), #endif #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_X, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), #else - VPHELPER(VP_MOVE_X, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, nullptr, ScreenHandler.HandleManualMove, nullptr), #endif - VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleMotorLockUnlock, nullptr), + VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, ScreenHandler.HandleMotorLockUnlock, nullptr), #if ENABLED(POWER_LOSS_RECOVERY) - VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr), + VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, ScreenHandler.HandlePowerLossRecovery, nullptr), #endif - VPHELPER(VP_SETTINGS, nullptr, &ScreenHandler.HandleSettings, nullptr), + VPHELPER(VP_SETTINGS, nullptr, ScreenHandler.HandleSettings, nullptr), #if ENABLED(SINGLE_Z_CALIBRATION) - VPHELPER(VP_Z_CALIBRATE, nullptr, &ScreenHandler.HandleZCalibration, nullptr), + VPHELPER(VP_Z_CALIBRATE, nullptr, ScreenHandler.HandleZCalibration, nullptr), #endif #if ENABLED(FIRST_LAYER_CAL) - VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr), + VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, ScreenHandler.HandleFirstLayerCal, nullptr), #endif - { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr - { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay }, + { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay }, // Temperature Data - #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + #if HAS_HOTEND + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_MOVE_E0, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), - VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_MOVE_E0, nullptr, ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(DGUS_PREHEAT_UI) - VPHELPER(VP_E0_BED_PREHEAT, nullptr, &ScreenHandler.HandlePreheat, nullptr), + VPHELPER(VP_E0_BED_PREHEAT, nullptr, ScreenHandler.HandlePreheat, nullptr), #endif #if ENABLED(PIDTEMP) VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), + VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload), #endif #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), - VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), // ERROR: Flow is per-extruder, not per-hotend + VPHELPER(VP_MOVE_E1, nullptr, ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMP) - VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif - VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), + VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload), #endif #if HAS_HEATED_BED VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMPBED) VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif // Fan Data #if HAS_FAN #define FAN_VPHELPER(N) \ - VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, &ScreenHandler.DGUSLCD_SendPercentageToDisplay), \ - VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &ScreenHandler.HandleFanControl, nullptr), \ - VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &ScreenHandler.DGUSLCD_SendFanStatusToDisplay), + VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, ScreenHandler.DGUSLCD_SendPercentageToDisplay), \ + VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], ScreenHandler.HandleFanControl, nullptr), \ + VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay), REPEAT(FAN_COUNT, FAN_VPHELPER) #endif // Feedrate - VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ), + VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, ScreenHandler.DGUSLCD_SendWordValueToDisplay), // Position Data VPHELPER(VP_XPos, ¤t_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), @@ -430,7 +422,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_ZPos, ¤t_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), // Print Progress - VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay ), + VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay), // Print Time VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay), @@ -442,11 +434,11 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), - #if HOTENDS >= 1 + #if HAS_EXTRUDERS VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), - #endif - #if HOTENDS >= 2 - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + #if HAS_MULTI_EXTRUDER + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + #endif #endif // SDCard File listing. @@ -463,7 +455,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr), #if HAS_BED_PROBE - VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), #if ENABLED(BABYSTEPPING) VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr), #endif @@ -475,10 +467,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif // Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content. - { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, VPHELPER(0, 0, 0, 0) // must be last entry. }; diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.h b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.h index 910f5f7791..79aee9a576 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.h @@ -51,7 +51,7 @@ enum DGUSLCD_Screens : uint8_t { 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_UNUSED = 255 }; // Display Memory layout used (T5UID) diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp index 8b97003f6f..0012a0e5e0 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/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; @@ -83,7 +85,7 @@ case 1: // Pause - GotoScreen(MKSLCD_SCREEN_PAUSE); + GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION); if (!ExtUI::isPrintingFromMediaPaused()) { ExtUI::pausePrint(); //ExtUI::mks_pausePrint(); @@ -249,7 +251,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_PID_P: newvalue = value; break; case VP_E0_PID_I: newvalue = scalePID_i(value); break; case VP_E0_PID_D: newvalue = scalePID_d(value); break; @@ -329,7 +331,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } if (filament_data.action == 0) { // Go back to utility screen - #if HOTENDS >= 1 + #if HAS_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); #endif #if HOTENDS >= 2 @@ -340,13 +342,13 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { else { // Go to the preheat screen to show the heating progress switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_FILAMENT_LOAD_UNLOAD: filament_data.extruder = ExtUI::extruder_t::E0; thermalManager.setTargetHotend(e_temp, filament_data.extruder); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_EXTRUDER case VP_E1_FILAMENT_LOAD_UNLOAD: filament_data.extruder = ExtUI::extruder_t::E1; thermalManager.setTargetHotend(e_temp, filament_data.extruder); @@ -409,8 +411,15 @@ bool DGUSScreenHandler::loop() { if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid())) booted = true; - if (!booted && ELAPSED(ms, TERN(USE_MKS_GREEN_UI, 1000, BOOTSCREEN_TIMEOUT))) + if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) { booted = true; + + if (TERN0(POWER_LOSS_RECOVERY, recovery.valid())) + GotoScreen(DGUSLCD_SCREEN_POWER_LOSS); + else + GotoScreen(DGUSLCD_SCREEN_MAIN); + } + #endif return IsScreenComplete(); } diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp index a9fa407dd3..f1f4308d22 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp @@ -47,12 +47,12 @@ const uint16_t VPList_Boot[] PROGMEM = { }; const uint16_t VPList_Main[] PROGMEM = { - /* VP_M117, for completeness, but it cannot be auto-uploaded. */ - #if HOTENDS >= 1 + // VP_M117, for completeness, but it cannot be auto-uploaded. + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, VP_E0_STATUS, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, VP_BED_STATUS, @@ -70,11 +70,11 @@ const uint16_t VPList_Main[] PROGMEM = { }; const uint16_t VPList_Temp[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, @@ -83,12 +83,12 @@ const uint16_t VPList_Temp[] PROGMEM = { }; const uint16_t VPList_Status[] PROGMEM = { - /* VP_M117, for completeness, but it cannot be auto-uploaded */ - #if HOTENDS >= 1 + // VP_M117, for completeness, but it cannot be auto-uploaded + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, @@ -104,12 +104,12 @@ const uint16_t VPList_Status[] PROGMEM = { }; const uint16_t VPList_Status2[] PROGMEM = { - /* VP_M117, for completeness, but it cannot be auto-uploaded */ - #if HOTENDS >= 1 + // VP_M117, for completeness, but it cannot be auto-uploaded + #if HAS_HOTEND VP_Flowrate_E0, - #endif - #if HOTENDS >= 2 - VP_Flowrate_E1, + #if HOTENDS >= 2 + VP_Flowrate_E1, + #endif #endif VP_PrintProgress_Percentage, VP_PrintTime, @@ -117,11 +117,11 @@ const uint16_t VPList_Status2[] PROGMEM = { }; const uint16_t VPList_Preheat[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, @@ -135,11 +135,11 @@ const uint16_t VPList_ManualMove[] PROGMEM = { }; const uint16_t VPList_ManualExtrude[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif VP_EPos, 0x0000 @@ -156,22 +156,22 @@ const uint16_t VPList_SD_FlowRates[] PROGMEM = { }; const uint16_t VPList_Filament_heating[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, VP_E0_FILAMENT_LOAD_UNLOAD, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif 0x0000 }; const uint16_t VPList_Filament_load_unload[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_E0_FILAMENT_LOAD_UNLOAD, - #endif - #if HOTENDS >= 2 - VP_E1_FILAMENT_LOAD_UNLOAD, + #if HOTENDS >= 2 + VP_E1_FILAMENT_LOAD_UNLOAD, + #endif #endif 0x0000 }; @@ -183,11 +183,11 @@ const uint16_t VPList_SDFileList[] PROGMEM = { const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { VP_PrintProgress_Percentage, VP_PrintTime, - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, @@ -203,11 +203,11 @@ const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { }; const uint16_t VPList_SDPrintTune[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, @@ -225,11 +225,11 @@ const uint16_t VPList_StepPerMM[] PROGMEM = { VP_X_STEP_PER_MM, VP_Y_STEP_PER_MM, VP_Z_STEP_PER_MM, - #if HOTENDS >= 1 + #if HAS_HOTEND VP_E0_STEP_PER_MM, - #endif - #if HOTENDS >= 2 - VP_E1_STEP_PER_MM, + #if HOTENDS >= 2 + VP_E1_STEP_PER_MM, + #endif #endif 0x0000 }; @@ -268,7 +268,7 @@ const uint16_t VPList_PIDTuningWaiting[] PROGMEM = { }; const uint16_t VPList_FLCPreheat[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif #if HAS_HEATED_BED @@ -278,55 +278,47 @@ const uint16_t VPList_FLCPreheat[] PROGMEM = { }; const uint16_t VPList_FLCPrinting[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_SD_Print_ProbeOffsetZ, #endif 0x0000 }; const uint16_t VPList_Z_Offset[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_SD_Print_ProbeOffsetZ, #endif 0x0000 }; const struct VPMapping VPMap[] PROGMEM = { - { DGUSLCD_SCREEN_BOOT, VPList_Boot }, - { DGUSLCD_SCREEN_MAIN, VPList_Main }, - { DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp }, - { DGUSLCD_SCREEN_STATUS, VPList_Status }, - { DGUSLCD_SCREEN_STATUS2, VPList_Status2 }, - { DGUSLCD_SCREEN_PREHEAT, VPList_Preheat }, - { DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove }, - { DGUSLCD_SCREEN_Z_OFFSET, VPList_Z_Offset }, - { DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude }, - { DGUSLCD_SCREEN_FILAMENT_HEATING, VPList_Filament_heating }, - { DGUSLCD_SCREEN_FILAMENT_LOADING, VPList_Filament_load_unload }, - { DGUSLCD_SCREEN_FILAMENT_UNLOADING, VPList_Filament_load_unload }, + { DGUSLCD_SCREEN_BOOT, VPList_Boot }, + { DGUSLCD_SCREEN_MAIN, VPList_Main }, + { DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp }, + { DGUSLCD_SCREEN_STATUS, VPList_Status }, + { DGUSLCD_SCREEN_STATUS2, VPList_Status2 }, + { DGUSLCD_SCREEN_PREHEAT, VPList_Preheat }, + { DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove }, + { DGUSLCD_SCREEN_Z_OFFSET, VPList_Z_Offset }, + { DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude }, + { DGUSLCD_SCREEN_FILAMENT_HEATING, VPList_Filament_heating }, + { DGUSLCD_SCREEN_FILAMENT_LOADING, VPList_Filament_load_unload }, + { DGUSLCD_SCREEN_FILAMENT_UNLOADING, VPList_Filament_load_unload }, { DGUSLCD_SCREEN_SDPRINTMANIPULATION, VPList_SD_PrintManipulation }, - { DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList }, - { DGUSLCD_SCREEN_SDPRINTTUNE, VPList_SDPrintTune }, - { DGUSLCD_SCREEN_WAITING, VPList_PIDTuningWaiting }, - { DGUSLCD_SCREEN_FLC_PREHEAT, VPList_FLCPreheat }, - { DGUSLCD_SCREEN_FLC_PRINTING, VPList_FLCPrinting }, - { DGUSLCD_SCREEN_STEPPERMM, VPList_StepPerMM }, - { DGUSLCD_SCREEN_PID_E, VPList_PIDE0 }, - { DGUSLCD_SCREEN_PID_BED, VPList_PIDBED }, - { DGUSLCD_SCREEN_INFOS, VPList_Infos }, + { DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList }, + { DGUSLCD_SCREEN_SDPRINTTUNE, VPList_SDPrintTune }, + { DGUSLCD_SCREEN_WAITING, VPList_PIDTuningWaiting }, + { DGUSLCD_SCREEN_FLC_PREHEAT, VPList_FLCPreheat }, + { DGUSLCD_SCREEN_FLC_PRINTING, VPList_FLCPrinting }, + { DGUSLCD_SCREEN_STEPPERMM, VPList_StepPerMM }, + { DGUSLCD_SCREEN_PID_E, VPList_PIDE0 }, + { DGUSLCD_SCREEN_PID_BED, VPList_PIDBED }, + { DGUSLCD_SCREEN_INFOS, VPList_Infos }, { 0 , nullptr } // List is terminated with an nullptr as table entry. }; const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION; -// Helper to define a DGUS_VP_Variable for common use cases. -#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=sizeof(VPADRVAR), \ - .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR } - -// Helper to define a DGUS_VP_Variable when the sizeo of the var cannot be determined automaticalyl (eg. a string) -#define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=STRLEN, \ - .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR } - const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Helper to detect touch events VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr), @@ -336,92 +328,92 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr), - VPHELPER(VP_TEMP_ALL_OFF, nullptr, &ScreenHandler.HandleAllHeatersOff, nullptr), + VPHELPER(VP_TEMP_ALL_OFF, nullptr, ScreenHandler.HandleAllHeatersOff, nullptr), #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_OPTION, &distanceToMove, &ScreenHandler.HandleManualMoveOption, nullptr), + VPHELPER(VP_MOVE_OPTION, &distanceToMove, ScreenHandler.HandleManualMoveOption, nullptr), #endif #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_X, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), #else - VPHELPER(VP_MOVE_X, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, nullptr, ScreenHandler.HandleManualMove, nullptr), #endif - VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleMotorLockUnlock, nullptr), + VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, ScreenHandler.HandleMotorLockUnlock, nullptr), #if ENABLED(POWER_LOSS_RECOVERY) - VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr), + VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, ScreenHandler.HandlePowerLossRecovery, nullptr), #endif - VPHELPER(VP_SETTINGS, nullptr, &ScreenHandler.HandleSettings, nullptr), + VPHELPER(VP_SETTINGS, nullptr, ScreenHandler.HandleSettings, nullptr), #if ENABLED(SINGLE_Z_CALIBRATION) - VPHELPER(VP_Z_CALIBRATE, nullptr, &ScreenHandler.HandleZCalibration, nullptr), + VPHELPER(VP_Z_CALIBRATE, nullptr, ScreenHandler.HandleZCalibration, nullptr), #endif #if ENABLED(FIRST_LAYER_CAL) - VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr), + VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, ScreenHandler.HandleFirstLayerCal, nullptr), #endif - { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr - { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay }, + { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay }, // Temperature Data - #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + #if HAS_HOTEND + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_MOVE_E0, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), - VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_MOVE_E0, nullptr, ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(DGUS_PREHEAT_UI) - VPHELPER(VP_E0_BED_PREHEAT, nullptr, &ScreenHandler.HandlePreheat, nullptr), + VPHELPER(VP_E0_BED_PREHEAT, nullptr, ScreenHandler.HandlePreheat, nullptr), #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), + VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload), #endif #if ENABLED(PIDTEMP) VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), - VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_MOVE_E1, nullptr, ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #endif #if HAS_HEATED_BED VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), - #if ENABLED(PIDTEMP) + VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + #if ENABLED(PIDTEMPBED) VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif // Fan Data #if HAS_FAN #define FAN_VPHELPER(N) \ - VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, &ScreenHandler.DGUSLCD_SendPercentageToDisplay), \ - VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &ScreenHandler.HandleFanControl, nullptr), \ - VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &ScreenHandler.DGUSLCD_SendFanStatusToDisplay), + VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, ScreenHandler.DGUSLCD_SendPercentageToDisplay), \ + VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], ScreenHandler.HandleFanControl, nullptr), \ + VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay), REPEAT(FAN_COUNT, FAN_VPHELPER) #endif // Feedrate - VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ), + VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, ScreenHandler.DGUSLCD_SendWordValueToDisplay), // Position Data VPHELPER(VP_XPos, ¤t_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), @@ -429,23 +421,23 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_ZPos, ¤t_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), // Print Progress - VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay ), + VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay), // Print Time - VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay ), + VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay), #if ENABLED(PRINTCOUNTER) - VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay ), - VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay ), + VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay), + VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay), #endif VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), - #if HOTENDS >= 1 + #if HAS_HOTEND VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), - #endif - #if HOTENDS >= 2 - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + #if HOTENDS >= 2 + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + #endif #endif // SDCard File listing. @@ -453,16 +445,16 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr), VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr), - VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), VPHELPER(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr), VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr), #if HAS_BED_PROBE - VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), #if ENABLED(BABYSTEPPING) VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr), #endif @@ -474,10 +466,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif // Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content. - { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, VPHELPER(0, 0, 0, 0) // must be last entry. }; diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.h b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.h index d18989a48b..0c3a6aa352 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.h @@ -51,7 +51,7 @@ enum DGUSLCD_Screens : uint8_t { 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_UNUSED = 255 }; // Display Memory layout used (T5UID) diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp index f3729d1253..2100febc32 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp @@ -22,7 +22,7 @@ #include "../../../../inc/MarlinConfigPre.h" -#if ENABLED(DGUS_LCD_UI_HYPRECY) +#if ENABLED(DGUS_LCD_UI_HIPRECY) #include "../DGUSScreenHandler.h" @@ -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; @@ -249,7 +251,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_PID_P: newvalue = value; break; case VP_E0_PID_I: newvalue = scalePID_i(value); break; case VP_E0_PID_D: newvalue = scalePID_d(value); break; @@ -329,18 +331,18 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } if (filament_data.action == 0) { // Go back to utility screen - #if HOTENDS >= 1 + #if HAS_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); - #endif - #if HOTENDS >= 2 - thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); + #if HOTENDS >= 2 + thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); + #endif #endif GotoScreen(DGUSLCD_SCREEN_UTILITY); } else { // Go to the preheat screen to show the heating progress switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_FILAMENT_LOAD_UNLOAD: filament_data.extruder = ExtUI::extruder_t::E0; thermalManager.setTargetHotend(e_temp, filament_data.extruder); @@ -415,4 +417,4 @@ bool DGUSScreenHandler::loop() { return IsScreenComplete(); } -#endif // DGUS_LCD_UI_HYPRECY +#endif // DGUS_LCD_UI_HIPRECY diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index a18fcb14fa..c60d6e8bc4 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -35,7 +35,7 @@ #include "../../ui_api.h" #include "../../../marlinui.h" -#if ENABLED(HAS_STEALTHCHOP) +#if HAS_STEALTHCHOP #include "../../../../module/stepper/trinamic.h" #endif @@ -120,11 +120,11 @@ const uint16_t VPList_Boot[] PROGMEM = { const uint16_t VPList_Main[] PROGMEM = { // VP_M117, for completeness, but it cannot be auto-uploaded. - #if HOTENDS >= 1 + #if HAS_HOTEND MKSLIST_E_ITEM(0) VP_E0_STATUS, - #endif - #if HOTENDS >= 2 - MKSLIST_E_ITEM(1) + #if HOTENDS >= 2 + MKSLIST_E_ITEM(1) VP_E1_STATUS, + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, VP_BED_STATUS, @@ -498,20 +498,6 @@ const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION; const char H43Version[] PROGMEM = "MKS H43_V1.30"; const char Updata_Time[] PROGMEM = STRING_DISTRIBUTION_DATE; -// Helper to define a DGUS_VP_Variable for common use cases. -#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR) \ - { \ - .VP = VPADR, .memadr = VPADRVAR, .size = sizeof(VPADRVAR), \ - .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR \ - } - -// Helper to define a DGUS_VP_Variable when the sizeo of the var cannot be determined automaticalyl (eg. a string) -#define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR) \ - { \ - .VP = VPADR, .memadr = VPADRVAR, .size = STRLEN, \ - .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR \ - } - const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Helper to detect touch events VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr), @@ -522,109 +508,109 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr), // Back Button - VPHELPER(VP_BACK_PAGE, nullptr, &ScreenHandler.ScreenBackChange, nullptr), - VPHELPER(VP_TEMP_ALL_OFF, nullptr, &ScreenHandler.HandleAllHeatersOff, nullptr), + VPHELPER(VP_BACK_PAGE, nullptr, ScreenHandler.ScreenBackChange, nullptr), + VPHELPER(VP_TEMP_ALL_OFF, nullptr, ScreenHandler.HandleAllHeatersOff, nullptr), - VPHELPER(VP_MOVE_X, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, nullptr, ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_X_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_Y_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_Z_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_X_HOME, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_Y_HOME, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_Z_HOME, nullptr, ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_DISTANCE, &manualMoveStep, &ScreenHandler.GetManualMovestep, nullptr), + VPHELPER(VP_MOVE_DISTANCE, &manualMoveStep, ScreenHandler.GetManualMovestep, nullptr), - VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_LEVEL_POINT, nullptr, &ScreenHandler.ManualAssistLeveling, nullptr), + VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_LEVEL_POINT, nullptr, ScreenHandler.ManualAssistLeveling, nullptr), #if ENABLED(POWER_LOSS_RECOVERY) - VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr), + VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, ScreenHandler.HandlePowerLossRecovery, nullptr), #endif - VPHELPER(VP_SETTINGS, nullptr, &ScreenHandler.HandleSettings, nullptr), + VPHELPER(VP_SETTINGS, nullptr, ScreenHandler.HandleSettings, nullptr), #if ENABLED(SINGLE_Z_CALIBRATION) - VPHELPER(VP_Z_CALIBRATE, nullptr, &ScreenHandler.HandleZCalibration, nullptr), + VPHELPER(VP_Z_CALIBRATE, nullptr, ScreenHandler.HandleZCalibration, nullptr), #endif #if ENABLED(FIRST_LAYER_CAL) - VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr), + VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, ScreenHandler.HandleFirstLayerCal, nullptr), #endif - {.VP = VP_MARLIN_VERSION, .memadr = (void *)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, + {.VP = VP_MARLIN_VERSION, .memadr = (void *)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr - {.VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay}, - {.VP = VP_MKS_H43_VERSION, .memadr = (void *)H43Version, .size = VP_MKS_H43_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, - {.VP = VP_MKS_H43_UpdataVERSION, .memadr = (void *)Updata_Time, .size = VP_MKS_H43_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, + {.VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay}, + {.VP = VP_MKS_H43_VERSION, .memadr = (void *)H43Version, .size = VP_MKS_H43_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, + {.VP = VP_MKS_H43_UpdataVERSION, .memadr = (void *)Updata_Time, .size = VP_MKS_H43_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, // Temperature Data - #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + #if HAS_HOTEND + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_MOVE_E0, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), - VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_MOVE_E0, nullptr, ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(DGUS_PREHEAT_UI) - VPHELPER(VP_E0_BED_PREHEAT, nullptr, &ScreenHandler.HandlePreheat, nullptr), + VPHELPER(VP_E0_BED_PREHEAT, nullptr, ScreenHandler.HandlePreheat, nullptr), #endif #if ENABLED(PIDTEMP) VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - VPHELPER(VP_LOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentLoad, nullptr), - VPHELPER(VP_UNLOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentUnLoad, nullptr), - VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_LOAD_Filament, nullptr, ScreenHandler.MKS_FilamentLoad, nullptr), + VPHELPER(VP_UNLOAD_Filament, nullptr, ScreenHandler.MKS_FilamentUnLoad, nullptr), + VPHELPER(VP_Filament_distance, &distanceFilament, ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), - VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_MOVE_E1, nullptr, ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Filament_distance, &distanceFilament, ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #if ENABLED(PIDTEMP) - VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif - VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), + VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload), #endif #if HAS_HEATED_BED - VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMPBED) VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif // Fan Data #if HAS_FAN #define FAN_VPHELPER(N) \ - VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_SetUint8, &ScreenHandler.DGUSLCD_SendFanToDisplay), \ - VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &ScreenHandler.HandleFanControl, nullptr), \ - VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &ScreenHandler.DGUSLCD_SendFanStatusToDisplay), + VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_SetUint8, ScreenHandler.DGUSLCD_SendFanToDisplay), \ + VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], ScreenHandler.HandleFanControl, nullptr), \ + VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay), REPEAT(FAN_COUNT, FAN_VPHELPER) #endif // Feedrate - VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, ScreenHandler.DGUSLCD_SendWordValueToDisplay), // Position Data VPHELPER(VP_XPos, ¤t_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), @@ -646,8 +632,11 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Print Progress VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay), - //LCD Control - VPHELPER(VP_LCD_BLK, &lcd_default_light, &ScreenHandler.LCD_BLK_Adjust, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + // LCD Control + VPHELPER(VP_LCD_BLK, &lcd_default_light, ScreenHandler.LCD_BLK_Adjust, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + + // SD File - Back + VPHELPER(VP_SD_FileSelect_Back, nullptr, ScreenHandler.SD_FileBack, nullptr), // Print Time VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay_MKS), @@ -665,22 +654,22 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_Y_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Y_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), VPHELPER(VP_Z_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Z_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - #if HOTENDS >= 1 + #if HAS_HOTEND VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(0)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - #endif - #if HOTENDS >= 2 - VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + #if HOTENDS >= 2 + VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + #endif #endif VPHELPER(VP_X_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[X_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Y_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Z_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - #if HOTENDS >= 1 + #if HAS_HOTEND VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(0)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - #endif - #if HOTENDS >= 2 - VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + #if HOTENDS >= 2 + VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + #endif #endif VPHELPER(VP_TRAVEL_SPEED, (uint16_t *)&planner.settings.travel_acceleration, ScreenHandler.HandleTravelAccChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), @@ -748,18 +737,17 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_MESH_LEVEL_POINT,nullptr, ScreenHandler.MeshLevel,nullptr), #if ENABLED(PREVENT_COLD_EXTRUSION) - VPHELPER(VP_Min_EX_T_E, &thermalManager.extrude_min_temp, &ScreenHandler.GetMinExtrudeTemp, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Min_EX_T_E, &thermalManager.extrude_min_temp, ScreenHandler.GetMinExtrudeTemp, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif - VPHELPER(VP_AutoTurnOffSw, nullptr, &ScreenHandler.GetTurnOffCtrl, nullptr), + VPHELPER(VP_AutoTurnOffSw, nullptr, ScreenHandler.GetTurnOffCtrl, nullptr), - #if HOTENDS >= 1 + #if HAS_HOTEND VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + #if HOTENDS >= 2 + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + #endif #endif - #if HOTENDS >= 2 - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - #endif - // SDCard File listing @@ -781,8 +769,8 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr), #if ENABLED(BABYSTEPPING) - VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), - VPHELPER(VP_ZOffset_DE_DIS, &z_offset_add, nullptr, &ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_ZOffset_DE_DIS, &z_offset_add, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), #endif #if HAS_BED_PROBE VPHELPER(VP_OFFSET_X, &probe.offset.x, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), @@ -798,15 +786,15 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif // Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content. - //{.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, - //{.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, - //{.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, - //{.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, + //{.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, + //{.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, + //{.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, + //{.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, - {.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, - {.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, - {.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, - {.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, + {.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, + {.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, + {.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, + {.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, VPHELPER(0, 0, 0, 0) // must be last entry. }; diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h index fef7002ad8..5c9ff02bfe 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h @@ -238,194 +238,14 @@ enum DGUSLCD_Screens : uint8_t { 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_UNUSED = 255 }; -// Display Memory layout used (T5UID) -// Except system variables this is arbitrary, just to organize stuff.... - -// 0x0000 .. 0x0FFF -- System variables and reserved by the display -// 0x1000 .. 0x1FFF -- Variables to never change location, regardless of UI Version -// 0x2000 .. 0x2FFF -- Controls (VPs that will trigger some action) -// 0x3000 .. 0x4FFF -- Marlin Data to be displayed -// 0x5000 .. -- SPs (if we want to modify display elements, e.g change color or like) -- currently unused - -// As there is plenty of space (at least most displays have >8k RAM), we do not pack them too tight, -// so that we can keep variables nicely together in the address space. - -// UI Version always on 0x1000...0x1002 so that the firmware can check this and bail out. - -// constexpr uint16_t VP_UI_VERSION_MAJOR = 0x1000; // Major -- incremented when incompatible -// constexpr uint16_t VP_UI_VERSION_MINOR = 0x1001; // Minor -- incremented on new features, but compatible -// constexpr uint16_t VP_UI_VERSION_PATCH = 0x1002; // Patch -- fixed which do not change functionality. -// constexpr uint16_t VP_UI_FLAVOUR = 0x1010; // lets reserve 16 bytes here to determine if UI is suitable for this Marlin. tbd. - -// Storage space for the Killscreen messages. 0x1100 - 0x1200 . Reused for the popup. -// constexpr uint16_t VP_MSGSTR1 = 0x1100; -// constexpr uint8_t VP_MSGSTR1_LEN = 0x20; // might be more place for it... -// constexpr uint16_t VP_MSGSTR2 = 0x1140; -// constexpr uint8_t VP_MSGSTR2_LEN = 0x20; -// constexpr uint16_t VP_MSGSTR3 = 0x1180; -// constexpr uint8_t VP_MSGSTR3_LEN = 0x20; -// constexpr uint16_t VP_MSGSTR4 = 0x11C0; -// constexpr uint8_t VP_MSGSTR4_LEN = 0x20; - -// Screenchange request for screens that only make sense when printer is idle. -// e.g movement is only allowed if printer is not printing. -// Marlin must confirm by setting the screen manually. -// constexpr uint16_t VP_SCREENCHANGE_ASK = 0x2000; -// constexpr uint16_t VP_SCREENCHANGE = 0x2001; // Key-Return button to new menu pressed. Data contains target screen in low byte and info in high byte. -// constexpr uint16_t VP_TEMP_ALL_OFF = 0x2002; // Turn all heaters off. Value arbitrary ;)= -// constexpr uint16_t VP_SCREENCHANGE_WHENSD = 0x2003; // "Print" Button touched -- go only there if there is an SD Card. -// constexpr uint16_t VP_CONFIRMED = 0x2010; // OK on confirm screen. - -// // Buttons on the SD-Card File listing. -// constexpr uint16_t VP_SD_ScrollEvent = 0x2020; // Data: 0 for "up a directory", numbers are the amount to scroll, e.g -1 one up, 1 one down -// constexpr uint16_t VP_SD_FileSelected = 0x2022; // Number of file field selected. -// constexpr uint16_t VP_SD_FileSelectConfirm = 0x2024; // (This is a virtual VP and emulated by the Confirm Screen when a file has been confirmed) - -// constexpr uint16_t VP_SD_ResumePauseAbort = 0x2026; // Resume(Data=0), Pause(Data=1), Abort(Data=2) SD Card prints -// constexpr uint16_t VP_SD_AbortPrintConfirmed = 0x2028; // Abort print confirmation (virtual, will be injected by the confirm dialog) -// constexpr uint16_t VP_SD_Print_Setting = 0x2040; -// constexpr uint16_t VP_SD_Print_LiveAdjustZ = 0x2050; // Data: 0 down, 1 up - -// Controls for movement (we can't use the incremental / decremental feature of the display at this feature works only with 16 bit values -// (which would limit us to 655.35mm, which is likely not a problem for common setups, but i don't want to rule out hangprinters support) -// A word about the coding: The VP will be per axis and the return code will be an signed 16 bit value in 0.01 mm resolution, telling us -// the relative travel amount t he user wants to do. So eg. if the display sends us VP=2100 with value 100, the user wants us to move X by +1 mm. -// constexpr uint16_t VP_MOVE_X = 0x2100; -// constexpr uint16_t VP_MOVE_Y = 0x2102; -// constexpr uint16_t VP_MOVE_Z = 0x2104; -// constexpr uint16_t VP_MOVE_E0 = 0x2110; -// constexpr uint16_t VP_MOVE_E1 = 0x2112; -// //constexpr uint16_t VP_MOVE_E2 = 0x2114; -// //constexpr uint16_t VP_MOVE_E3 = 0x2116; -// //constexpr uint16_t VP_MOVE_E4 = 0x2118; -// //constexpr uint16_t VP_MOVE_E5 = 0x211A; -// constexpr uint16_t VP_HOME_ALL = 0x2120; -// constexpr uint16_t VP_MOTOR_LOCK_UNLOK = 0x2130; -// constexpr uint16_t VP_XYZ_HOME = 0x2132; - -// Power loss recovery -// constexpr uint16_t VP_POWER_LOSS_RECOVERY = 0x2180; - -// // Fan Control Buttons , switch between "off" and "on" -// constexpr uint16_t VP_FAN0_CONTROL = 0x2200; -// constexpr uint16_t VP_FAN1_CONTROL = 0x2202; -// constexpr uint16_t VP_FAN2_CONTROL = 0x2204; -// constexpr uint16_t VP_FAN3_CONTROL = 0x2206; - -// // Heater Control Buttons , triged between "cool down" and "heat PLA" state -// constexpr uint16_t VP_E0_CONTROL = 0x2210; -// constexpr uint16_t VP_E1_CONTROL = 0x2212; -// //constexpr uint16_t VP_E2_CONTROL = 0x2214; -// //constexpr uint16_t VP_E3_CONTROL = 0x2216; -// //constexpr uint16_t VP_E4_CONTROL = 0x2218; -// //constexpr uint16_t VP_E5_CONTROL = 0x221A; -// constexpr uint16_t VP_BED_CONTROL = 0x221C; - -// // Preheat -// constexpr uint16_t VP_E0_BED_PREHEAT = 0x2220; -// constexpr uint16_t VP_E1_BED_PREHEAT = 0x2222; -// //constexpr uint16_t VP_E2_BED_PREHEAT = 0x2224; -// //constexpr uint16_t VP_E3_BED_PREHEAT = 0x2226; -// //constexpr uint16_t VP_E4_BED_PREHEAT = 0x2228; -// //constexpr uint16_t VP_E5_BED_PREHEAT = 0x222A; - -// // Filament load and unload -// // constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD = 0x2300; -// // constexpr uint16_t VP_E1_FILAMENT_LOAD_UNLOAD = 0x2302; - -// // Settings store , reset - -// // PID autotune -// constexpr uint16_t VP_PID_AUTOTUNE_E0 = 0x2410; -// constexpr uint16_t VP_PID_AUTOTUNE_E1 = 0x2412; -// //constexpr uint16_t VP_PID_AUTOTUNE_E2 = 0x2414; -// //constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x2416; -// //constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x2418; -// //constexpr uint16_t VP_PID_AUTOTUNE_E5 = 0x241A; -// constexpr uint16_t VP_PID_AUTOTUNE_BED = 0x2420; -// // Calibrate Z -// constexpr uint16_t VP_Z_CALIBRATE = 0x2430; - -// First layer cal -// constexpr uint16_t VP_Z_FIRST_LAYER_CAL = 0x2500; // Data: 0 - Cancel first layer cal progress, >0 filament type have loaded - -// Firmware version on the boot screen. -// constexpr uint16_t VP_MARLIN_VERSION = 0x3000; -// constexpr uint8_t VP_MARLIN_VERSION_LEN = 16; // there is more space on the display, if needed. // Place for status messages. constexpr uint16_t VP_M117 = 0x7020; constexpr uint8_t VP_M117_LEN = 0x20; -// // Temperatures. -// constexpr uint16_t VP_T_E0_Is = 0x3060; // 4 Byte Integer -// constexpr uint16_t VP_T_E0_Set = 0x3062; // 2 Byte Integer -// constexpr uint16_t VP_T_E1_Is = 0x3064; // 4 Byte Integer -// // reserved to support up to 6 Extruders: -// constexpr uint16_t VP_T_E1_Set = 0x3066; // 2 Byte Integer -// constexpr uint16_t VP_T_E2_Is = 0x3068; // 4 Byte Integer -// constexpr uint16_t VP_T_E2_Set = 0x306A; // 2 Byte Integer -// constexpr uint16_t VP_T_E3_Is = 0x306C; // 4 Byte Integer -// constexpr uint16_t VP_T_E3_Set = 0x306E; // 2 Byte Integer -// constexpr uint16_t VP_T_E4_Is = 0x3070; // 4 Byte Integer -// constexpr uint16_t VP_T_E4_Set = 0x3072; // 2 Byte Integer -// constexpr uint16_t VP_T_E5_Is = 0x3074; // 4 Byte Integer -// constexpr uint16_t VP_T_E5_Set = 0x3076; // 2 Byte Integer -// constexpr uint16_t VP_T_E6_Is = 0x3078; // 4 Byte Integer -// constexpr uint16_t VP_T_E6_Set = 0x307A; // 2 Byte Integer -// constexpr uint16_t VP_T_E7_Is = 0x3078; // 4 Byte Integer -// constexpr uint16_t VP_T_E7_Set = 0x307A; // 2 Byte Integer - - -// constexpr uint16_t VP_T_Bed_Is = 0x3080; // 4 Byte Integer -// constexpr uint16_t VP_T_Bed_Set = 0x3082; // 2 Byte Integer - -// constexpr uint16_t VP_Flowrate_E0 = 0x3090; // 2 Byte Integer -// constexpr uint16_t VP_Flowrate_E1 = 0x3092; // 2 Byte Integer -// // reserved for up to 6 Extruders: -// constexpr uint16_t VP_Flowrate_E2 = 0x3094; -// constexpr uint16_t VP_Flowrate_E3 = 0x3096; -// constexpr uint16_t VP_Flowrate_E4 = 0x3098; -// constexpr uint16_t VP_Flowrate_E5 = 0x309A; - -// constexpr uint16_t VP_Fan0_Percentage = 0x3100; // 2 Byte Integer (0..100) -// constexpr uint16_t VP_Fan1_Percentage = 0x3102; // 2 Byte Integer (0..100) -// constexpr uint16_t VP_Fan2_Percentage = 0x3104; // 2 Byte Integer (0..100) -// constexpr uint16_t VP_Fan3_Percentage = 0x3106; // 2 Byte Integer (0..100) -// constexpr uint16_t VP_Feedrate_Percentage = 0x3108; // 2 Byte Integer (0..100) - -// Actual Position -// constexpr uint16_t VP_XPos = 0x3110; // 4 Byte Fixed point number; format xxx.yy -// constexpr uint16_t VP_YPos = 0x3112; // 4 Byte Fixed point number; format xxx.yy -// constexpr uint16_t VP_ZPos = 0x3114; // 4 Byte Fixed point number; format xxx.yy -// constexpr uint16_t VP_EPos = 0x3120; // 4 Byte Fixed point number; format xxx.yy - -// constexpr uint16_t VP_PrintProgress_Percentage = 0x3130; // 2 Byte Integer (0..100) - -// constexpr uint16_t VP_PrintTime = 0x3140; -// constexpr uint16_t VP_PrintTime_LEN = 32; - -// constexpr uint16_t VP_PrintAccTime = 0x3160; -// constexpr uint16_t VP_PrintAccTime_LEN = 32; - -// constexpr uint16_t VP_PrintsTotal = 0x3180; -// constexpr uint16_t VP_PrintsTotal_LEN = 16; - -// // SDCard File Listing -// constexpr uint16_t VP_SD_FileName_LEN = 32; // LEN is shared for all entries. -// constexpr uint16_t DGUS_SD_FILESPERSCREEN = 8; // FIXME move that info to the display and read it from there. -// constexpr uint16_t VP_SD_FileName0 = 0x3200; -// constexpr uint16_t VP_SD_FileName1 = 0x3220; -// constexpr uint16_t VP_SD_FileName2 = 0x3240; -// constexpr uint16_t VP_SD_FileName3 = 0x3260; -// constexpr uint16_t VP_SD_FileName4 = 0x3280; -// constexpr uint16_t VP_SD_FileName5 = 0x32A0; -// constexpr uint16_t VP_SD_FileName6 = 0x32C0; -// constexpr uint16_t VP_SD_FileName7 = 0x32E0; - // Heater status constexpr uint16_t VP_E0_STATUS = 0x3410; constexpr uint16_t VP_E1_STATUS = 0x3412; @@ -635,6 +455,7 @@ constexpr uint16_t SP_T_Bed_Set = 0x5040; constexpr uint16_t VP_SD_Print_LiveAdjustZ_Confirm = 0x3060; constexpr uint16_t VP_ZOffset_Distance = 0x3070; constexpr uint16_t VP_ZOffset_DE_DIS = 0x3080; + constexpr uint16_t VP_SD_FileSelect_Back = 0x3082; // SDCard File Listing constexpr uint16_t VP_SD_FileName_LEN = 32; // LEN is shared for all entries. constexpr uint16_t DGUS_SD_FILESPERSCREEN = 10; // FIXME move that info to the display and read it from there. diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index c648d06218..0c022d3e88 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -37,7 +37,7 @@ #include "../../../../gcode/gcode.h" -#if ENABLED(HAS_STEALTHCHOP) +#if HAS_STEALTHCHOP #include "../../../../module/stepper/trinamic.h" #include "../../../../module/stepper/indirection.h" #endif @@ -396,7 +396,7 @@ void DGUSScreenHandler::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenHandler::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) { - #if ENABLED(HAS_BED_PROBE) + #if HAS_BED_PROBE int32_t value = swap32(*(int32_t *)val_ptr); float Offset = value / 100.0f; DEBUG_ECHOLNPAIR_F("\nget int6 offset >> ", value, 6); @@ -575,7 +575,6 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { settings.save(); } else if (mesh_point_count == 0) { - mesh_point_count = GRID_MAX_POINTS; soft_endstop._enabled = true; settings.save(); @@ -589,6 +588,10 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { #endif // MESH_BED_LEVELING } +void DGUSScreenHandler::SD_FileBack(DGUS_VP_Variable&, void*) { + GotoScreen(MKSLCD_SCREEN_HOME); +} + void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) { const uint16_t lcd_value = swap16(*(uint16_t *)val_ptr); @@ -621,25 +624,25 @@ void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_pt switch (point_value) { case 0x0001: - enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[0].x), - Y_MIN_POS + abs(mks_corner_offsets[0].y), level_speed); + enqueue_corner_move(X_MIN_POS + ABS(mks_corner_offsets[0].x), + Y_MIN_POS + ABS(mks_corner_offsets[0].y), level_speed); queue.enqueue_now_P(PSTR("G28Z")); break; case 0x0002: - enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[1].x), - Y_MIN_POS + abs(mks_corner_offsets[1].y), level_speed); + enqueue_corner_move(X_MAX_POS - ABS(mks_corner_offsets[1].x), + Y_MIN_POS + ABS(mks_corner_offsets[1].y), level_speed); break; case 0x0003: - enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[2].x), - Y_MAX_POS - abs(mks_corner_offsets[2].y), level_speed); + enqueue_corner_move(X_MAX_POS - ABS(mks_corner_offsets[2].x), + Y_MAX_POS - ABS(mks_corner_offsets[2].y), level_speed); break; case 0x0004: - enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[3].x), - Y_MAX_POS - abs(mks_corner_offsets[3].y), level_speed); + enqueue_corner_move(X_MIN_POS + ABS(mks_corner_offsets[3].x), + Y_MAX_POS - ABS(mks_corner_offsets[3].y), level_speed); break; case 0x0005: - enqueue_corner_move(abs(mks_corner_offsets[4].x), - abs(mks_corner_offsets[4].y), level_speed); + enqueue_corner_move(ABS(mks_corner_offsets[4].x), + ABS(mks_corner_offsets[4].y), level_speed); break; } diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h index 4a67b4afda..7d5263c6b8 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h @@ -93,6 +93,7 @@ public: static void DGUS_RunoutInit(void); static void DGUS_ExtrudeLoadInit(void); static void LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr); + static void SD_FileBack(DGUS_VP_Variable &var, void *val_ptr); // Hook for manual move. static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr); @@ -189,12 +190,12 @@ public: static void PrintReturn(DGUS_VP_Variable &var, void *val_ptr); #endif - // OK Button the Confirm screen. + // OK Button on the Confirm screen. static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr); - // Update data after went to new screen (by display or by GotoScreen) - // remember: store the last-displayed screen, so it can get returned to. - // (e.g for pop up messages) + // Update data after going to a new screen (by display or by GotoScreen) + // remember: store the last-displayed screen, so it can be returned to. + // (e.g for popup messages) static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false); // Recall the remembered screen. diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp index 1c2944bb4f..39d89fc174 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp @@ -50,16 +50,16 @@ const uint16_t VPList_Boot[] PROGMEM = { }; const uint16_t VPList_Main[] PROGMEM = { - /* VP_M117, for completeness, but it cannot be auto-uploaded. */ + // VP_M117, for completeness, but it cannot be auto-uploaded. 0x0000 }; const uint16_t VPList_Temp[] PROGMEM = { - #if HOTENDS >= 1 + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, @@ -68,12 +68,12 @@ const uint16_t VPList_Temp[] PROGMEM = { }; const uint16_t VPList_Status[] PROGMEM = { - /* VP_M117, for completeness, but it cannot be auto-uploaded */ - #if HOTENDS >= 1 + // VP_M117, for completeness, but it cannot be auto-uploaded + #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #endif - #if HOTENDS >= 2 - VP_T_E1_Is, VP_T_E1_Set, + #if HOTENDS >= 2 + VP_T_E1_Is, VP_T_E1_Set, + #endif #endif #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, @@ -90,72 +90,40 @@ const uint16_t VPList_Status[] PROGMEM = { const uint16_t VPList_Status2[] PROGMEM = { // VP_M117, for completeness, but it cannot be auto-uploaded - #if HOTENDS >= 1 + #if HAS_HOTEND VP_Flowrate_E0, - #endif - #if HOTENDS >= 2 - VP_Flowrate_E1, + #if HOTENDS >= 2 + VP_Flowrate_E1, + #endif #endif VP_PrintProgress_Percentage, VP_PrintTime, 0x0000 }; - -const uint16_t VPList_ManualMove[] PROGMEM = { - VP_XPos, VP_YPos, VP_ZPos, - 0x0000 -}; - -const uint16_t VPList_ManualExtrude[] PROGMEM = { - VP_EPos, - 0x0000 -}; - -const uint16_t VPList_FanAndFeedrate[] PROGMEM = { - VP_Feedrate_Percentage, VP_Fan0_Percentage, - 0x0000 -}; - -const uint16_t VPList_SD_FlowRates[] PROGMEM = { - VP_Flowrate_E0, VP_Flowrate_E1, - 0x0000 -}; - -const uint16_t VPList_SDFileList[] PROGMEM = { - VP_SD_FileName0, VP_SD_FileName1, VP_SD_FileName2, VP_SD_FileName3, VP_SD_FileName4, - 0x0000 -}; - -const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { - VP_PrintProgress_Percentage, VP_PrintTime, - 0x0000 -}; +const uint16_t VPList_ManualMove[] PROGMEM = { VP_XPos, VP_YPos, VP_ZPos, 0x0000 }; +const uint16_t VPList_ManualExtrude[] PROGMEM = { VP_EPos, 0x0000 }; +const uint16_t VPList_FanAndFeedrate[] PROGMEM = { VP_Feedrate_Percentage, VP_Fan0_Percentage, 0x0000 }; +const uint16_t VPList_SD_FlowRates[] PROGMEM = { VP_Flowrate_E0, VP_Flowrate_E1, 0x0000 }; +const uint16_t VPList_SDFileList[] PROGMEM = { VP_SD_FileName0, VP_SD_FileName1, VP_SD_FileName2, VP_SD_FileName3, VP_SD_FileName4, 0x0000 }; +const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { VP_PrintProgress_Percentage, VP_PrintTime, 0x0000 }; const struct VPMapping VPMap[] PROGMEM = { - { DGUSLCD_SCREEN_BOOT, VPList_Boot }, - { DGUSLCD_SCREEN_MAIN, VPList_Main }, - { DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp }, - { DGUSLCD_SCREEN_STATUS, VPList_Status }, - { DGUSLCD_SCREEN_STATUS2, VPList_Status2 }, - { DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove }, - { DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude }, - { DGUSLCD_SCREEN_FANANDFEEDRATE, VPList_FanAndFeedrate }, - { DGUSLCD_SCREEN_FLOWRATES, VPList_SD_FlowRates }, + { DGUSLCD_SCREEN_BOOT, VPList_Boot }, + { DGUSLCD_SCREEN_MAIN, VPList_Main }, + { DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp }, + { DGUSLCD_SCREEN_STATUS, VPList_Status }, + { DGUSLCD_SCREEN_STATUS2, VPList_Status2 }, + { DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove }, + { DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude }, + { DGUSLCD_SCREEN_FANANDFEEDRATE, VPList_FanAndFeedrate }, + { DGUSLCD_SCREEN_FLOWRATES, VPList_SD_FlowRates }, { DGUSLCD_SCREEN_SDPRINTMANIPULATION, VPList_SD_PrintManipulation }, - { DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList }, + { DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList }, { 0 , nullptr } // List is terminated with an nullptr as table entry. }; const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION; -// Helper to define a DGUS_VP_Variable for common use cases. -#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=sizeof(VPADRVAR), \ - .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR } - -// Helper to define a DGUS_VP_Variable when the sizeo of the var cannot be determined automaticalyl (eg. a string) -#define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=STRLEN, \ - .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR } - const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Helper to detect touch events VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr), @@ -165,72 +133,71 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr), - VPHELPER(VP_TEMP_ALL_OFF, nullptr, &ScreenHandler.HandleAllHeatersOff, nullptr), + VPHELPER(VP_TEMP_ALL_OFF, nullptr, ScreenHandler.HandleAllHeatersOff, nullptr), #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_OPTION, &distanceToMove, &ScreenHandler.HandleManualMoveOption, nullptr), + VPHELPER(VP_MOVE_OPTION, &distanceToMove, ScreenHandler.HandleManualMoveOption, nullptr), #endif #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_X, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, &distanceToMove, ScreenHandler.HandleManualMove, nullptr), #else - VPHELPER(VP_MOVE_X, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, nullptr, ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, nullptr, ScreenHandler.HandleManualMove, nullptr), #endif - VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleMotorLockUnlock, nullptr), + VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, ScreenHandler.HandleMotorLockUnlock, nullptr), #if ENABLED(POWER_LOSS_RECOVERY) - VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr), + VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, ScreenHandler.HandlePowerLossRecovery, nullptr), #endif - VPHELPER(VP_SETTINGS, nullptr, &ScreenHandler.HandleSettings, nullptr), + VPHELPER(VP_SETTINGS, nullptr, ScreenHandler.HandleSettings, nullptr), - { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr - { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay }, + { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay }, // Temperature Data - #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, nullptr, nullptr, SET_VARIABLE(getActualTemp_celsius, E0, long)), - VPHELPER(VP_T_E0_Set, nullptr, GET_VARIABLE(setTargetTemp_celsius, E0), - SET_VARIABLE(getTargetTemp_celsius, E0)), - VPHELPER(VP_Flowrate_E0, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + #if HAS_HOTEND + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E0, nullptr, ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_MOVE_E0, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), - VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_MOVE_E0, nullptr, ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(DGUS_PREHEAT_UI) - VPHELPER(VP_E0_BED_PREHEAT, nullptr, &ScreenHandler.HandlePreheat, nullptr), + VPHELPER(VP_E0_BED_PREHEAT, nullptr, ScreenHandler.HandlePreheat, nullptr), #endif #if ENABLED(PIDTEMP) VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), + VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload), #endif #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), - VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_MOVE_E1, nullptr, ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMP) - VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif #if HAS_HEATED_BED - VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), - VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMPBED) VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), @@ -241,14 +208,14 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Fan Data #if HAS_FAN #define FAN_VPHELPER(N) \ - VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, &ScreenHandler.DGUSLCD_SendPercentageToDisplay), \ - VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &ScreenHandler.HandleFanControl, nullptr), \ - VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &ScreenHandler.DGUSLCD_SendFanStatusToDisplay), + VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, ScreenHandler.DGUSLCD_SendPercentageToDisplay), \ + VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], ScreenHandler.HandleFanControl, nullptr), \ + VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay), REPEAT(FAN_COUNT, FAN_VPHELPER) #endif // Feedrate - VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ), + VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, ScreenHandler.DGUSLCD_SendWordValueToDisplay), // Position Data VPHELPER(VP_XPos, ¤t_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), @@ -256,23 +223,23 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_ZPos, ¤t_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), // Print Progress - VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay ), + VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay), // Print Time - VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay ), + VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay), #if ENABLED(PRINTCOUNTER) - VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay ), - VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay ), + VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay), + VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay), #endif VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), - #if HOTENDS >= 1 + #if HAS_HOTEND VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), - #endif - #if HOTENDS >= 2 - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + #if HOTENDS >= 2 + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + #endif #endif // SDCard File listing. @@ -280,16 +247,16 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr), VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr), - VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), VPHELPER(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr), VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr), #if HAS_BED_PROBE - VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), #if ENABLED(BABYSTEPPING) VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr), #endif @@ -301,10 +268,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif // Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content. - { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, VPHELPER(0, 0, 0, 0) // must be last entry. }; diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.h b/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.h index c1890c7c28..06f0dcf001 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.h @@ -24,17 +24,17 @@ #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_SDPRINTMANIPULATION = 52, + 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, @@ -46,7 +46,7 @@ enum DGUSLCD_Screens : uint8_t { 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_UNUSED = 255 }; // Display Memory layout used (T5UID) diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp index f05dfc6f70..827d74967a 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp @@ -85,7 +85,7 @@ case 1: // Pause - GotoScreen(MKSLCD_SCREEN_PAUSE); + GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION); if (!ExtUI::isPrintingFromMediaPaused()) { ExtUI::pausePrint(); //ExtUI::mks_pausePrint(); @@ -251,7 +251,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_PID_P: newvalue = value; break; case VP_E0_PID_I: newvalue = scalePID_i(value); break; case VP_E0_PID_D: newvalue = scalePID_d(value); break; @@ -331,18 +331,18 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } if (filament_data.action == 0) { // Go back to utility screen - #if HOTENDS >= 1 + #if HAS_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); - #endif - #if HOTENDS >= 2 - thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); + #if HOTENDS >= 2 + thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); + #endif #endif GotoScreen(DGUSLCD_SCREEN_UTILITY); } else { // Go to the preheat screen to show the heating progress switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_FILAMENT_LOAD_UNLOAD: filament_data.extruder = ExtUI::extruder_t::E0; thermalManager.setTargetHotend(e_temp, filament_data.extruder); @@ -411,9 +411,12 @@ bool DGUSScreenHandler::loop() { if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid())) booted = true; - if (!booted && ELAPSED(ms, TERN(USE_MKS_GREEN_UI, 1000, BOOTSCREEN_TIMEOUT))) + if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) { booted = true; + GotoScreen(TERN0(POWER_LOSS_RECOVERY, recovery.valid()) ? DGUSLCD_SCREEN_POWER_LOSS : DGUSLCD_SCREEN_MAIN); + } #endif + return IsScreenComplete(); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp index a64c237fa1..1d4711c0e2 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp @@ -20,7 +20,7 @@ * location: . * ****************************************************************************/ -#include "../compat.h" +#include "../config.h" #if ENABLED(TOUCH_UI_FTDI_EVE) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp index ab60579700..b4165a742a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp @@ -20,16 +20,14 @@ * location: . * ****************************************************************************/ -#include "../compat.h" +#include "../config.h" #if ENABLED(TOUCH_UI_FTDI_EVE) #include "media_file_reader.h" #if ENABLED(SDSUPPORT) bool MediaFileReader::open(const char *filename) { - card.init(SD_SPI_SPEED, SDSS); - volume.init(&card); - root.openRoot(&volume); + root = CardReader::getroot(); return file.open(&root, filename, O_READ); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h index 249c57b9c6..eb76bb9b2b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h @@ -32,9 +32,7 @@ class MediaFileReader { private: #if ENABLED(SDSUPPORT) - DiskIODriver_SPI_SD card; - SdVolume volume; - SdFile root, file; + SdFile root, file; #endif public: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_advanced_settings.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_advanced_settings.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp index 16b2891e27..40ec16a9df 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_advanced_settings.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BIO_ADVANCED_SETTINGS_MENU @@ -87,7 +87,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { .tag(13) .button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_INTERFACE)) .tag(14) .button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_RESTORE_DEFAULTS)) .colors(action_btn) - .tag(1). button( BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK)); + .tag(1). button( BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE)); #undef GRID_COLS #undef GRID_ROWS } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_advanced_settings.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_advanced_settings.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_e.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.cpp similarity index 96% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_e.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.cpp index 3b55551375..a5511f94b9 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_e.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BIO_CONFIRM_HOME_E @@ -36,7 +36,7 @@ bool BioConfirmHomeE::onTouchEnd(uint8_t tag) { switch (tag) { case 1: #if defined(AXIS_LEVELING_COMMANDS) && defined(PARK_AND_RELEASE_COMMANDS) - SpinnerDialogBox::enqueueAndWait_P(F( + SpinnerDialogBox::enqueueAndWait(F( "G28 E\n" AXIS_LEVELING_COMMANDS "\n" PARK_AND_RELEASE_COMMANDS diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_e.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_e.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.cpp similarity index 96% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.cpp index f1abd2e76a..e34df42b84 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BIO_CONFIRM_HOME_XYZ @@ -36,7 +36,7 @@ bool BioConfirmHomeXYZ::onTouchEnd(uint8_t tag) { switch (tag) { case 1: #ifdef PARK_AND_RELEASE_COMMANDS - SpinnerDialogBox::enqueueAndWait_P(F( + SpinnerDialogBox::enqueueAndWait(F( "G28\n" PARK_AND_RELEASE_COMMANDS )); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_main_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.cpp similarity index 88% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_main_menu.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.cpp index 6897ceb914..adc84dfa25 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_main_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BIO_MAIN_MENU @@ -54,7 +54,7 @@ void MainMenu::onRedraw(draw_mode_t what) { .tag(8).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_ADVANCED_SETTINGS)) .tag(9).button(BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_INFO_MENU)) .colors(action_btn) - .tag(1).button(BTN_POS(1,10), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK)); + .tag(1).button(BTN_POS(1,10), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE)); } #undef GRID_COLS @@ -67,17 +67,17 @@ bool MainMenu::onTouchEnd(uint8_t tag) { const bool e_homed = isAxisPositionKnown(E0); switch (tag) { - case 1: SaveSettingsDialogBox::promptToSaveSettings(); break; - case 2: GOTO_SCREEN(BioConfirmHomeXYZ); break; - case 3: SpinnerDialogBox::enqueueAndWait_P(e_homed ? F("G0 E0 F120") : F("G112")); break; - case 4: StatusScreen::unlockMotors(); break; + case 1: SaveSettingsDialogBox::promptToSaveSettings(); break; + case 2: GOTO_SCREEN(BioConfirmHomeXYZ); break; + case 3: SpinnerDialogBox::enqueueAndWait(e_homed ? F("G0 E0 F120") : F("G112")); break; + case 4: StatusScreen::unlockMotors(); break; #ifdef AXIS_LEVELING_COMMANDS - case 5: SpinnerDialogBox::enqueueAndWait_P(F(AXIS_LEVELING_COMMANDS)); break; + case 5: SpinnerDialogBox::enqueueAndWait(F(AXIS_LEVELING_COMMANDS)); break; #endif - case 6: GOTO_SCREEN(TemperatureScreen); break; - case 7: GOTO_SCREEN(InterfaceSettingsScreen); break; - case 8: GOTO_SCREEN(AdvancedSettingsMenu); break; - case 9: GOTO_SCREEN(AboutScreen); break; + case 6: GOTO_SCREEN(TemperatureScreen); break; + case 7: GOTO_SCREEN(InterfaceSettingsScreen); break; + case 8: GOTO_SCREEN(AdvancedSettingsMenu); break; + case 9: GOTO_SCREEN(AboutScreen); break; default: return false; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_main_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_main_menu.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp index 10ed6eb14a..86c700f235 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BIO_PRINTING_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/screens.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/screens.h new file mode 100644 index 0000000000..7294c4aa0b --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/screens.h @@ -0,0 +1,105 @@ +/************* + * screens.h * + *************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +/********************************* DL CACHE SLOTS ******************************/ + +// In order to reduce SPI traffic, we cache display lists (DL) in RAMG. This +// is done using the CLCD::DLCache class, which takes a unique ID for each +// cache location. These IDs are defined here: + +enum { + STATUS_SCREEN_CACHE, + MENU_SCREEN_CACHE, + TUNE_SCREEN_CACHE, + ALERT_BOX_CACHE, + SPINNER_CACHE, + ADVANCED_SETTINGS_SCREEN_CACHE, + TEMPERATURE_SCREEN_CACHE, + STEPS_SCREEN_CACHE, + MAX_FEEDRATE_SCREEN_CACHE, + MAX_VELOCITY_SCREEN_CACHE, + MAX_ACCELERATION_SCREEN_CACHE, + DEFAULT_ACCELERATION_SCREEN_CACHE, + FLOW_PERCENT_SCREEN_CACHE, + ZOFFSET_SCREEN_CACHE, + STEPPER_CURRENT_SCREEN_CACHE, + STEPPER_BUMP_SENSITIVITY_SCREEN_CACHE, + PRINTING_SCREEN_CACHE, + FILES_SCREEN_CACHE, + INTERFACE_SETTINGS_SCREEN_CACHE, + INTERFACE_SOUNDS_SCREEN_CACHE, + LOCK_SCREEN_CACHE, + DISPLAY_TIMINGS_SCREEN_CACHE +}; + +// To save MCU RAM, the status message is "baked" in to the status screen +// cache, so we reserve a large chunk of memory for the DL cache + +#define STATUS_SCREEN_DL_SIZE 4096 +#define ALERT_BOX_DL_SIZE 3072 +#define SPINNER_DL_SIZE 3072 +#define FILE_SCREEN_DL_SIZE 4160 +#define PRINTING_SCREEN_DL_SIZE 2048 + +/************************* MENU SCREEN DECLARATIONS *************************/ + +#include "../generic/base_screen.h" +#include "../generic/base_numeric_adjustment_screen.h" +#include "../generic/dialog_box_base_class.h" +#include "../generic/boot_screen.h" +#include "../generic/about_screen.h" +#include "../generic/kill_screen.h" +#include "../generic/alert_dialog_box.h" +#include "../generic/spinner_dialog_box.h" +#include "../generic/restore_failsafe_dialog_box.h" +#include "../generic/save_settings_dialog_box.h" +#include "../generic/confirm_start_print_dialog_box.h" +#include "../generic/confirm_abort_print_dialog_box.h" +#include "../generic/confirm_user_request_alert_box.h" +#include "../generic/touch_calibration_screen.h" +#include "../generic/move_axis_screen.h" +#include "../generic/steps_screen.h" +#include "../generic/feedrate_percent_screen.h" +#include "../generic/max_velocity_screen.h" +#include "../generic/max_acceleration_screen.h" +#include "../generic/default_acceleration_screen.h" +#include "../generic/temperature_screen.h" +#include "../generic/interface_sounds_screen.h" +#include "../generic/interface_settings_screen.h" +#include "../generic/lock_screen.h" +#include "../generic/endstop_state_screen.h" +#include "../generic/display_tuning_screen.h" +#include "../generic/media_player_screen.h" +#include "../generic/statistics_screen.h" +#include "../generic/stepper_current_screen.h" +#include "../generic/stepper_bump_sensitivity_screen.h" +#include "../generic/leveling_menu.h" +#include "../generic/z_offset_screen.h" +#include "../generic/files_screen.h" + +#include "bio_status_screen.h" +#include "bio_main_menu.h" +#include "bio_tune_menu.h" +#include "bio_advanced_settings.h" +#include "bio_printing_dialog_box.h" +#include "bio_confirm_home_xyz.h" +#include "bio_confirm_home_e.h" diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp similarity index 98% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_status_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp index c66e4d94d8..1382a13bf8 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp @@ -22,14 +22,14 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BIO_STATUS_SCREEN #if ENABLED(TOUCH_UI_PORTRAIT) - #include "bio_printer_ui_portrait.h" + #include "ui_portrait.h" #else - #include "bio_printer_ui_landscape.h" + #include "ui_landscape.h" #endif #define GRID_COLS 2 @@ -316,7 +316,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) { case 9: GOTO_SCREEN(FilesScreen); break; case 10: GOTO_SCREEN(MainMenu); break; case 13: GOTO_SCREEN(BioConfirmHomeE); break; - case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break; + case 14: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break; case 15: GOTO_SCREEN(TemperatureScreen); break; case 16: fine_motion = !fine_motion; break; default: return false; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_status_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_status_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_tune_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.cpp similarity index 96% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_tune_menu.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.cpp index 806f7bd1af..48eff0a661 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_tune_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BIO_TUNE_MENU @@ -54,7 +54,7 @@ void TuneMenu::onRedraw(draw_mode_t what) { .enabled(!isPrinting()).tag(5).button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_MOVE_TO_HOME)) .enabled(!isPrinting()).tag(6).button(BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_RAISE_PLUNGER)) .enabled(!isPrinting()).tag(7).button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_RELEASE_XY_AXIS)) - .colors(action_btn) .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK)); + .colors(action_btn) .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE)); } #undef GRID_COLS #undef GRID_ROWS @@ -67,7 +67,7 @@ bool TuneMenu::onTouchEnd(uint8_t tag) { case 3: GOTO_SCREEN(TemperatureScreen); break; case 4: GOTO_SCREEN(NudgeNozzleScreen); break; case 5: GOTO_SCREEN(BioConfirmHomeXYZ); break; - case 6: SpinnerDialogBox::enqueueAndWait_P(F("G0 E0 F120")); break; + case 6: SpinnerDialogBox::enqueueAndWait(F("G0 E0 F120")); break; case 7: StatusScreen::unlockMotors(); break; default: return false; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_tune_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_tune_menu.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_printer_ui_landscape.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_landscape.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_printer_ui_landscape.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_landscape.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_printer_ui_portrait.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_portrait.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bio_printer_ui_portrait.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_portrait.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.cpp similarity index 95% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.cpp index 7bd149bd46..7549e8d54e 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.cpp @@ -1,5 +1,5 @@ /***************************************** - * cocoa_press_advance_settings_menu.cpp * + * cocoa_press/advance_settings_menu.cpp * *****************************************/ /**************************************************************************** @@ -21,9 +21,9 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" -#ifdef FTDI_COCOA_ADVANCED_SETTINGS_MENU +#ifdef COCOA_ADVANCED_SETTINGS_MENU using namespace FTDI; using namespace ExtUI; @@ -67,7 +67,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { .tag(10).button(DISPLAY_POS, GET_TEXT_F(MSG_DISPLAY_MENU)) .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)); + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } } @@ -92,4 +92,4 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) { } return true; } -#endif // FTDI_COCOA_ADVANCED_SETTINGS_MENU +#endif // COCOA_ADVANCED_SETTINGS_MENU diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.h similarity index 91% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.h index 08c0745321..02f65572a2 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.h @@ -1,5 +1,5 @@ /*************************************** - * cocoa_press_advance_settings_menu.h * + * cocoa_press/advance_settings_menu.h * ***************************************/ /**************************************************************************** @@ -22,8 +22,8 @@ #pragma once -#define FTDI_COCOA_ADVANCED_SETTINGS_MENU -#define FTDI_COCOA_ADVANCED_SETTINGS_MENU_CLASS AdvancedSettingsMenu +#define COCOA_ADVANCED_SETTINGS_MENU +#define COCOA_ADVANCED_SETTINGS_MENU_CLASS AdvancedSettingsMenu class AdvancedSettingsMenu : public BaseScreen, public CachedScreen { public: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_ui.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/cocoa_press_ui.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_ui.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/cocoa_press_ui.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp new file mode 100644 index 0000000000..2e3472987e --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp @@ -0,0 +1,91 @@ +/********************************* + * cocoa_press/leveling_menu.cpp * + *********************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#include "../config.h" +#include "../screens.h" + +#if ENABLED(COCOA_LEVELING_MENU) + +#if BOTH(HAS_BED_PROBE, BLTOUCH) + #include "../../../../feature/bltouch.h" +#endif + +using namespace FTDI; +using namespace ExtUI; +using namespace Theme; + +#define GRID_ROWS 5 +#define GRID_COLS 3 +#define BED_MESH_TITLE_POS BTN_POS(1,1), BTN_SIZE(3,1) +#define PROBE_BED_POS BTN_POS(1,2), BTN_SIZE(1,1) +#define SHOW_MESH_POS BTN_POS(2,2), BTN_SIZE(1,1) +#define EDIT_MESH_POS BTN_POS(3,2), BTN_SIZE(1,1) +#define BLTOUCH_TITLE_POS BTN_POS(1,3), BTN_SIZE(3,1) +#define BLTOUCH_RESET_POS BTN_POS(1,4), BTN_SIZE(1,1) +#define BLTOUCH_TEST_POS BTN_POS(2,4), BTN_SIZE(1,1) +#define BACK_POS BTN_POS(1,5), BTN_SIZE(3,1) + +void LevelingMenu::onRedraw(draw_mode_t what) { + if (what & BACKGROUND) { + CommandProcessor cmd; + cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color)) + .cmd(CLEAR(true,true,true)) + .tag(0); + } + + if (what & FOREGROUND) { + CommandProcessor cmd; + cmd.font(font_large) + .cmd(COLOR_RGB(bg_text_enabled)) + .text(BED_MESH_TITLE_POS, GET_TEXT_F(MSG_BED_LEVELING)) + .text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH)) + .font(font_medium).colors(normal_btn) + .tag(2).button(PROBE_BED_POS, GET_TEXT_F(MSG_PROBE_BED)) + .enabled(ENABLED(HAS_MESH)) + .tag(3).button(SHOW_MESH_POS, GET_TEXT_F(MSG_SHOW_MESH)) + .enabled(ENABLED(HAS_MESH)) + .tag(4).button(EDIT_MESH_POS, GET_TEXT_F(MSG_EDIT_MESH)) + #undef GRID_COLS + #define GRID_COLS 2 + .tag(5).button(BLTOUCH_RESET_POS, GET_TEXT_F(MSG_BLTOUCH_RESET)) + .tag(6).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST)) + #undef GRID_COLS + #define GRID_COLS 3 + .colors(action_btn) + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); + } +} + +bool LevelingMenu::onTouchEnd(uint8_t tag) { + switch (tag) { + case 1: GOTO_PREVIOUS(); break; + case 2: BedMeshViewScreen::doProbe(); break; + case 3: BedMeshViewScreen::show(); break; + case 4: BedMeshEditScreen::show(); break; + case 5: injectCommands_P(PSTR("M280 P0 S60")); break; + case 6: SpinnerDialogBox::enqueueAndWait(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break; + default: return false; + } + return true; +} + +#endif // COCOA_LEVELING_MENU diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.h new file mode 100644 index 0000000000..8275380249 --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.h @@ -0,0 +1,32 @@ +/******************************* + * cocoa_press/leveling_menu.h * + ******************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#pragma once + +#define COCOA_LEVELING_MENU +#define COCOA_LEVELING_MENU_CLASS LevelingMenu + +class LevelingMenu : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.cpp similarity index 96% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.cpp index ac49df0916..d40b3be354 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.cpp @@ -1,6 +1,6 @@ -/************************************ - * cocoa_press_unload_cartridge.cpp * - ************************************/ +/********************************** + * cocoa_press/load_chocolate.cpp * + **********************************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * @@ -22,10 +22,10 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" -#ifdef FTDI_COCOA_LOAD_CHOCOLATE_SCREEN +#ifdef COCOA_LOAD_CHOCOLATE_SCREEN #include "cocoa_press_ui.h" @@ -90,7 +90,7 @@ void LoadChocolateScreen::draw_buttons(draw_mode_t what) { cmd.tag(3).button(x, y, h, v, GET_TEXT_F(MSG_FULL_LOAD)); ui.bounds(POLY(load_screen_back_btn), x, y, h, v); - cmd.tag(1).colors(action_btn).button(x, y, h, v, GET_TEXT_F(MSG_BACK)); + cmd.tag(1).colors(action_btn).button(x, y, h, v, GET_TEXT_F(MSG_BUTTON_DONE)); } void LoadChocolateScreen::draw_text(draw_mode_t what) { @@ -215,4 +215,4 @@ void LoadChocolateScreen::onIdle() { } BaseScreen::onIdle(); } -#endif // FTDI_COCOA_LOAD_CHOCOLATE_SCREEN +#endif // COCOA_LOAD_CHOCOLATE_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.h similarity index 93% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.h index 819464495b..4a582f0212 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.h @@ -1,5 +1,5 @@ /******************************** - * cocoa_press_load_chocolate.h * + * cocoa_press/load_chocolate.h * ********************************/ /**************************************************************************** @@ -23,8 +23,8 @@ #pragma once -#define FTDI_COCOA_LOAD_CHOCOLATE_SCREEN -#define FTDI_COCOA_LOAD_CHOCOLATE_SCREEN_CLASS LoadChocolateScreen +#define COCOA_LOAD_CHOCOLATE_SCREEN +#define COCOA_LOAD_CHOCOLATE_SCREEN_CLASS LoadChocolateScreen struct LoadChocolateScreenData { uint8_t repeat_tag; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp similarity index 94% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp index 7708b38eca..3fe17b72d5 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp @@ -1,5 +1,5 @@ /***************************** - * cocoa_press_main_menu.cpp * + * cocoa_press/main_menu.cpp * *****************************/ /**************************************************************************** @@ -22,9 +22,9 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" -#ifdef FTDI_COCOA_MAIN_MENU +#ifdef COCOA_MAIN_MENU using namespace FTDI; using namespace Theme; @@ -68,7 +68,7 @@ void MainMenu::onRedraw(draw_mode_t what) { .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)); + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } } @@ -88,7 +88,7 @@ bool MainMenu::onTouchEnd(uint8_t tag) { case 8: GOTO_SCREEN(AdvancedSettingsMenu); break; case 9: injectCommands_P(PSTR("M84")); break; #if HAS_LEVELING - case 10: GOTO_SCREEN(LevelingMenu); break; + case 10: GOTO_SCREEN(LevelingMenu); break; #endif case 11: GOTO_SCREEN(AboutScreen); break; default: @@ -97,4 +97,4 @@ bool MainMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // FTDI_COCOA_MAIN_MENU +#endif // COCOA_MAIN_MENU diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.h similarity index 94% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.h index 7c2bb5039a..460bb4b81a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.h @@ -1,5 +1,5 @@ /*************************** - * cocoa_press_main_menu.h * + * cocoa_press/main_menu.h * ***************************/ /**************************************************************************** @@ -23,8 +23,8 @@ #pragma once -#define FTDI_COCOA_MAIN_MENU -#define FTDI_COCOA_MAIN_MENU_CLASS MainMenu +#define COCOA_MAIN_MENU +#define COCOA_MAIN_MENU_CLASS MainMenu class MainMenu : public BaseScreen, public CachedScreen { public: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_e_screen.cpp similarity index 94% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_e_screen.cpp index 2621ef64fe..f7dbc466c7 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_e_screen.cpp @@ -1,5 +1,5 @@ /********************************* - * cocoa_press_move_e_screen.cpp * + * cocoa_press/move_e_screen.cpp * *********************************/ /**************************************************************************** @@ -22,10 +22,10 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" -#ifdef FTDI_COCOA_MOVE_E_SCREEN +#ifdef COCOA_MOVE_E_SCREEN using namespace FTDI; using namespace ExtUI; @@ -60,4 +60,4 @@ void MoveEScreen::onIdle() { } BaseScreen::onIdle(); } -#endif // FTDI_COCOA_MOVE_E_SCREEN +#endif // COCOA_MOVE_E_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_e_screen.h similarity index 93% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_e_screen.h index e86a91a529..0cede6f0c5 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_e_screen.h @@ -1,5 +1,5 @@ /******************************* - * cocoa_press_move_e_screen.h * + * cocoa_press/move_e_screen.h * *******************************/ /**************************************************************************** @@ -23,8 +23,8 @@ #pragma once -#define FTDI_COCOA_MOVE_E_SCREEN -#define FTDI_COCOA_MOVE_E_SCREEN_CLASS MoveEScreen +#define COCOA_MOVE_E_SCREEN +#define COCOA_MOVE_E_SCREEN_CLASS MoveEScreen class MoveEScreen : public BaseMoveAxisScreen, public CachedScreen { public: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_xyz_screen.cpp similarity index 93% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_xyz_screen.cpp index c9442c9322..8e80bd53a9 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_xyz_screen.cpp @@ -1,5 +1,5 @@ /*********************************** - * cocoa_press_move_xyz_screen.cpp * + * cocoa_press/move_xyz_screen.cpp * ***********************************/ /**************************************************************************** @@ -22,10 +22,10 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" -#ifdef FTDI_COCOA_MOVE_XYZ_SCREEN +#ifdef COCOA_MOVE_XYZ_SCREEN using namespace FTDI; using namespace ExtUI; @@ -49,4 +49,4 @@ void MoveXYZScreen::onIdle() { } BaseScreen::onIdle(); } -#endif // FTDI_COCOA_MOVE_XYZ_SCREEN +#endif // COCOA_MOVE_XYZ_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_xyz_screen.h similarity index 93% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_xyz_screen.h index 9cbec113e6..015f5b30e4 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/move_xyz_screen.h @@ -1,5 +1,5 @@ /********************************* - * cocoa_press_move_xyz_screen.h * + * cocoa_press/move_xyz_screen.h * *********************************/ /**************************************************************************** @@ -23,8 +23,8 @@ #pragma once -#define FTDI_COCOA_MOVE_XYZ_SCREEN -#define FTDI_COCOA_MOVE_XYZ_SCREEN_CLASS MoveXYZScreen +#define COCOA_MOVE_XYZ_SCREEN +#define COCOA_MOVE_XYZ_SCREEN_CLASS MoveXYZScreen class MoveXYZScreen : public BaseMoveAxisScreen, public CachedScreen { public: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp similarity index 97% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp index 92d1522360..424e0afa76 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp @@ -1,5 +1,5 @@ /******************************** - * cocoa_press_preheat_menu.cpp * + * cocoa_press/preheat_menu.cpp * ********************************/ /**************************************************************************** @@ -20,9 +20,9 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" -#ifdef FTDI_COCOA_PREHEAT_MENU +#ifdef COCOA_PREHEAT_MENU using namespace FTDI; using namespace ExtUI; @@ -65,7 +65,7 @@ void PreheatMenu::onRedraw(draw_mode_t what) { } #endif cmd.colors(action_btn) - .tag(1) .button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK)); + .tag(1) .button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE)); } } @@ -113,4 +113,4 @@ bool PreheatMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // FTDI_COCOA_PREHEAT_MENU +#endif // COCOA_PREHEAT_MENU diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.h similarity index 92% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.h index a109e42111..46bded7df4 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.h @@ -1,5 +1,5 @@ /****************************** - * cocoa_press_preheat_menu.h * + * cocoa_press/preheat_menu.h * ******************************/ /**************************************************************************** @@ -21,8 +21,8 @@ #pragma once -#define FTDI_COCOA_PREHEAT_MENU -#define FTDI_COCOA_PREHEAT_MENU_CLASS PreheatMenu +#define COCOA_PREHEAT_MENU +#define COCOA_PREHEAT_MENU_CLASS PreheatMenu class PreheatMenu : public BaseScreen, public CachedScreen { public: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_screen.cpp similarity index 87% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_screen.cpp index a8a172b3da..300878670e 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_screen.cpp @@ -1,6 +1,6 @@ -/**************************** - * preheat_timer_screen.cpp * - ****************************/ +/*************************************** + * cocoapress/preheat_timer_screen.cpp * + ***************************************/ /**************************************************************************** * Written By Marcio Teixeira 2019 - Cocoa Press * @@ -20,10 +20,10 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" -#ifdef FTDI_COCOA_PREHEAT_SCREEN +#ifdef COCOA_PREHEAT_SCREEN using namespace FTDI; using namespace ExtUI; @@ -77,23 +77,13 @@ void PreheatTimerScreen::draw_interaction_buttons(draw_mode_t what) { CommandProcessor cmd; cmd.colors(normal_btn) .font(font_medium) - .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } } void PreheatTimerScreen::draw_adjuster(draw_mode_t what, uint8_t tag, progmem_str label, float value, int16_t x, int16_t y, int16_t w, int16_t h) { #define SUB_COLS 9 #define SUB_ROWS 2 - #define SUB_GRID_W(W) ((W)*w/SUB_COLS) - #define SUB_GRID_H(H) ((H)*h/SUB_ROWS) - #define SUB_GRID_X(X) (SUB_GRID_W((X)-1) + x) - #define SUB_GRID_Y(Y) (SUB_GRID_H((Y)-1) + y) - #define SUB_X(X) (SUB_GRID_X(X) + MARGIN_L) - #define SUB_Y(Y) (SUB_GRID_Y(Y) + MARGIN_T) - #define SUB_W(W) (SUB_GRID_W(W) - MARGIN_L - MARGIN_R) - #define SUB_H(H) (SUB_GRID_H(H) - MARGIN_T - MARGIN_B) - #define SUB_POS(X,Y) SUB_X(X), SUB_Y(Y) - #define SUB_SIZE(W,H) SUB_W(W), SUB_H(H) CommandProcessor cmd; cmd.tag(0) @@ -168,4 +158,4 @@ void PreheatTimerScreen::onIdle() { BaseScreen::onIdle(); } -#endif // FTDI_COCOA_PREHEAT_SCREEN +#endif // COCOA_PREHEAT_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_screen.h similarity index 94% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_screen.h index e91340a3aa..9b8e2620dc 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_screen.h @@ -1,5 +1,5 @@ /********************************* - * cocoapress_preheat_screen.cpp * + * cocoapress/preheat_screen.cpp * *********************************/ /**************************************************************************** @@ -21,8 +21,8 @@ #pragma once -#define FTDI_COCOA_PREHEAT_SCREEN -#define FTDI_COCOA_PREHEAT_SCREEN_CLASS PreheatTimerScreen +#define COCOA_PREHEAT_SCREEN +#define COCOA_PREHEAT_SCREEN_CLASS PreheatTimerScreen struct PreheatTimerScreenData { uint32_t start_ms; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h new file mode 100644 index 0000000000..8481e446c4 --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h @@ -0,0 +1,134 @@ +/************* + * screens.h * + *************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#pragma once + + +/********************************* DL CACHE SLOTS ******************************/ + +// In order to reduce SPI traffic, we cache display lists (DL) in RAMG. This +// is done using the CLCD::DLCache class, which takes a unique ID for each +// cache location. These IDs are defined here: + +enum { + STATUS_SCREEN_CACHE, + MENU_SCREEN_CACHE, + TUNE_SCREEN_CACHE, + ALERT_BOX_CACHE, + SPINNER_CACHE, + ADVANCED_SETTINGS_SCREEN_CACHE, + MOVE_AXIS_SCREEN_CACHE, + TEMPERATURE_SCREEN_CACHE, + STEPS_SCREEN_CACHE, + MAX_FEEDRATE_SCREEN_CACHE, + MAX_VELOCITY_SCREEN_CACHE, + MAX_ACCELERATION_SCREEN_CACHE, + DEFAULT_ACCELERATION_SCREEN_CACHE, + FLOW_PERCENT_SCREEN_CACHE, + LEVELING_SCREEN_CACHE, + ZOFFSET_SCREEN_CACHE, + BED_MESH_VIEW_SCREEN_CACHE, + BED_MESH_EDIT_SCREEN_CACHE, + STEPPER_CURRENT_SCREEN_CACHE, + #if HAS_JUNCTION_DEVIATION + JUNC_DEV_SCREEN_CACHE, + #else + JERK_SCREEN_CACHE, + #endif + CASE_LIGHT_SCREEN_CACHE, + FILAMENT_MENU_CACHE, + LINEAR_ADVANCE_SCREEN_CACHE, + PREHEAT_MENU_CACHE, + PREHEAT_TIMER_SCREEN_CACHE, + LOAD_CHOCOLATE_SCREEN_CACHE, + MOVE_XYZ_SCREEN_CACHE, + MOVE_E_SCREEN_CACHE, + FILES_SCREEN_CACHE, + INTERFACE_SETTINGS_SCREEN_CACHE, + INTERFACE_SOUNDS_SCREEN_CACHE, + LOCK_SCREEN_CACHE, + DISPLAY_TIMINGS_SCREEN_CACHE +}; + +// To save MCU RAM, the status message is "baked" in to the status screen +// cache, so we reserve a large chunk of memory for the DL cache + +#define STATUS_SCREEN_DL_SIZE 4096 +#define ALERT_BOX_DL_SIZE 3072 +#define SPINNER_DL_SIZE 3072 +#define FILE_SCREEN_DL_SIZE 4160 +#define PRINTING_SCREEN_DL_SIZE 2048 + +/************************* MENU SCREEN DECLARATIONS *************************/ + +#include "../generic/base_screen.h" +#include "../generic/base_numeric_adjustment_screen.h" +#include "../generic/dialog_box_base_class.h" +#include "../generic/boot_screen.h" +#include "../generic/about_screen.h" +#include "../generic/kill_screen.h" +#include "../generic/alert_dialog_box.h" +#include "../generic/spinner_dialog_box.h" +#include "../generic/restore_failsafe_dialog_box.h" +#include "../generic/save_settings_dialog_box.h" +#include "../generic/confirm_start_print_dialog_box.h" +#include "../generic/confirm_abort_print_dialog_box.h" +#include "../generic/confirm_user_request_alert_box.h" +#include "../generic/touch_calibration_screen.h" +#include "../generic/move_axis_screen.h" +#include "../generic/steps_screen.h" +#include "../generic/feedrate_percent_screen.h" +#include "../generic/max_velocity_screen.h" +#include "../generic/max_acceleration_screen.h" +#include "../generic/default_acceleration_screen.h" +#include "../generic/temperature_screen.h" +#include "../generic/interface_sounds_screen.h" +#include "../generic/interface_settings_screen.h" +#include "../generic/lock_screen.h" +#include "../generic/endstop_state_screen.h" +#include "../generic/display_tuning_screen.h" +#include "../generic/statistics_screen.h" +#include "../generic/stepper_current_screen.h" +#include "../generic/z_offset_screen.h" +#include "../generic/bed_mesh_base.h" +#include "../generic/bed_mesh_view_screen.h" +#include "../generic/bed_mesh_edit_screen.h" +#include "../generic/case_light_screen.h" +#include "../generic/linear_advance_screen.h" +#include "../generic/files_screen.h" +#include "../generic/move_axis_screen.h" +#include "../generic/flow_percent_screen.h" +#if HAS_JUNCTION_DEVIATION + #include "../generic/junction_deviation_screen.h" +#else + #include "../generic/jerk_screen.h" +#endif + +#include "status_screen.h" +#include "main_menu.h" +#include "advanced_settings_menu.h" +#include "preheat_menu.h" +#include "preheat_screen.h" +#include "load_chocolate.h" +#include "leveling_menu.h" +#include "move_xyz_screen.h" +#include "move_e_screen.h" diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp similarity index 94% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp index a0c8914589..af3875967d 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp @@ -1,5 +1,5 @@ /********************************* - * cocoa_press_status_screen.cpp * + * cocoa_press/status_screen.cpp * *********************************/ /**************************************************************************** @@ -22,9 +22,9 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" -#ifdef FTDI_COCOA_STATUS_SCREEN +#ifdef COCOA_STATUS_SCREEN #include "cocoa_press_ui.h" @@ -233,7 +233,7 @@ bool StatusScreen::onTouchStart(uint8_t) { bool StatusScreen::onTouchEnd(uint8_t tag) { switch (tag) { - case 1: SpinnerDialogBox::enqueueAndWait_P(F("G28 O\nG27")); break; + case 1: SpinnerDialogBox::enqueueAndWait(F("G28 O\nG27")); break; case 2: GOTO_SCREEN(LoadChocolateScreen); break; case 3: GOTO_SCREEN(PreheatMenu); break; case 4: GOTO_SCREEN(MainMenu); break; @@ -294,4 +294,14 @@ void StatusScreen::onIdle() { } } -#endif // FTDI_COCOA_STATUS_SCREEN +void StatusScreen::onMediaInserted() { + if (AT_SCREEN(StatusScreen)) + setStatusMessage(GET_TEXT_F(MSG_MEDIA_INSERTED)); +} + +void StatusScreen::onMediaRemoved() { + if (AT_SCREEN(StatusScreen) || ExtUI::isPrintingFromMedia()) + setStatusMessage(GET_TEXT_F(MSG_MEDIA_REMOVED)); +} + +#endif // COCOA_STATUS_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h similarity index 93% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h index b22bceac14..75b4333351 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h @@ -1,5 +1,5 @@ /******************************* - * cocoa_press_status_screen.h * + * cocoa_press/status_screen.h * *******************************/ /**************************************************************************** @@ -23,8 +23,8 @@ #pragma once -#define FTDI_COCOA_STATUS_SCREEN -#define FTDI_COCOA_STATUS_SCREEN_CLASS StatusScreen +#define COCOA_STATUS_SCREEN +#define COCOA_STATUS_SCREEN_CLASS StatusScreen class StatusScreen : public BaseScreen, public CachedScreen { private: @@ -52,4 +52,6 @@ class StatusScreen : public BaseScreen, public CachedScreen static bool onTouchHeld(uint8_t tag); static bool onTouchEnd(uint8_t tag); static void onIdle(); + static void onMediaInserted(); + static void onMediaRemoved(); }; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/config.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/config.h index 76b231536b..05e19b20e4 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/config.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/config.h @@ -21,6 +21,10 @@ #pragma once +// Configure this display with options in Configuration_adv.h +#include "../../../inc/MarlinConfigPre.h" +#if ENABLED(TOUCH_UI_FTDI_EVE) + #include "compat.h" -// Configure this display with options in Configuration_adv.h +#endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp index 08faaa3b6a..9faedae711 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp @@ -28,7 +28,7 @@ #if ENABLED(TOUCH_UI_FTDI_EVE) -#include "screens/screens.h" +#include "screens.h" namespace ExtUI { using namespace Theme; @@ -45,24 +45,23 @@ namespace ExtUI { } void onMediaInserted() { - if (AT_SCREEN(StatusScreen)) - StatusScreen::setStatusMessage(GET_TEXT_F(MSG_MEDIA_INSERTED)); - sound.play(media_inserted, PLAY_ASYNCHRONOUS); + #if ENABLED(SDSUPPORT) + sound.play(media_inserted, PLAY_ASYNCHRONOUS); + StatusScreen::onMediaInserted(); + #endif } void onMediaRemoved() { - if (isPrintingFromMedia()) { - stopPrint(); - InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED); - } - else - sound.play(media_removed, PLAY_ASYNCHRONOUS); - - if (AT_SCREEN(StatusScreen) || isPrintingFromMedia()) - StatusScreen::setStatusMessage(GET_TEXT_F(MSG_MEDIA_REMOVED)); - #if ENABLED(SDSUPPORT) - if (AT_SCREEN(FilesScreen)) GOTO_SCREEN(StatusScreen); + if (isPrintingFromMedia()) { + stopPrint(); + InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED); + } + else + sound.play(media_removed, PLAY_ASYNCHRONOUS); + + StatusScreen::onMediaRemoved(); + FilesScreen::onMediaRemoved(); #endif } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp index 47ce1c700d..48d60a37ac 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp @@ -902,6 +902,7 @@ bool CLCD::CommandFifo::has_fault() { } #if FTDI_API_LEVEL == 800 + void CLCD::CommandFifo::start() { if (command_write_ptr == 0xFFFFFFFFul) { command_write_ptr = mem_read_32(REG::CMD_WRITE) & 0x0FFF; @@ -979,12 +980,13 @@ template bool CLCD::CommandFifo::_write_unaligned(T data, uint16_t len template bool CLCD::CommandFifo::write(T data, uint16_t len) { const uint8_t padding = MULTIPLE_OF_4(len) - len; - - uint8_t pad_bytes[] = {0, 0, 0, 0}; + const uint8_t pad_bytes[] = { 0, 0, 0, 0 }; return _write_unaligned(data, len) && _write_unaligned(pad_bytes, padding); } -#else + +#else // FTDI_API_LEVEL != 800 ... + void CLCD::CommandFifo::start() { } @@ -1042,13 +1044,29 @@ template bool CLCD::CommandFifo::write(T data, uint16_t len) { mem_write_bulk(REG::CMDB_WRITE, data, len, padding); return true; } -#endif + +#endif // ... FTDI_API_LEVEL != 800 template bool CLCD::CommandFifo::write(const void*, uint16_t); template bool CLCD::CommandFifo::write(progmem_str, uint16_t); // CO_PROCESSOR COMMANDS +void CLCD::CommandFifo::str(const char * data, size_t maxlen) { + // Write the string without the terminating '\0' + const size_t len = strnlen(data, maxlen); + write(data, len); + + // If padding was added by the previous write, then + // the string is terminated. Otherwise write four + // more zeros. + const uint8_t padding = MULTIPLE_OF_4(len) - len; + if (padding == 0) { + const uint8_t pad_bytes[] = {0, 0, 0, 0}; + write(pad_bytes, 4); + } +} + void CLCD::CommandFifo::str(const char * data) { write(data, strlen(data)+1); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h index eea24b06bd..5ce628fd36 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h @@ -248,6 +248,7 @@ class CLCD::CommandFifo { void keys (int16_t x, int16_t y, int16_t w, int16_t h, int16_t font, uint16_t options); // Sends the string portion of text, button, toggle and keys. + void str (const char * data, size_t maxlen); void str (const char * data); void str (progmem_str data); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h index 8ae7a150f8..339b337e55 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h @@ -288,7 +288,7 @@ // Remove compiler warning on an unused variable #ifndef UNUSED - #if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) + #if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) #define UNUSED(X) (void)X #else #define UNUSED(x) ((void)(x)) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp index 26be9f4e59..3ef71f573f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp @@ -42,7 +42,7 @@ namespace FTDI { strcat_P(str, (const char*) units); } - cmd.text(VAL_POS, str); + cmd.tag(0).text(VAL_POS, str); } void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h index 8561eb05a2..9a83e9ee09 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h @@ -209,11 +209,25 @@ class CommandProcessor : public CLCD::CommandFifo { inline CommandProcessor& rectangle(int16_t x, int16_t y, int16_t w, int16_t h) { using namespace FTDI; CLCD::CommandFifo::cmd(BEGIN(RECTS)); - CLCD::CommandFifo::cmd(VERTEX2F(x * 16, y * 16)); + CLCD::CommandFifo::cmd(VERTEX2F( x * 16, y * 16)); CLCD::CommandFifo::cmd(VERTEX2F((x + w) * 16, (y + h) * 16)); return *this; } + inline CommandProcessor& border(int16_t x, int16_t y, int16_t w, int16_t h) { + using namespace FTDI; + CLCD::CommandFifo::cmd(BEGIN(LINES)); + CLCD::CommandFifo::cmd(VERTEX2F( x * 16, y * 16)); + CLCD::CommandFifo::cmd(VERTEX2F((x + w) * 16, y * 16)); + CLCD::CommandFifo::cmd(VERTEX2F((x + w) * 16, y * 16)); + CLCD::CommandFifo::cmd(VERTEX2F((x + w) * 16, (y + h) * 16)); + CLCD::CommandFifo::cmd(VERTEX2F((x + w) * 16, (y + h) * 16)); + CLCD::CommandFifo::cmd(VERTEX2F( x * 16, (y + h) * 16)); + CLCD::CommandFifo::cmd(VERTEX2F( x * 16, (y + h) * 16)); + CLCD::CommandFifo::cmd(VERTEX2F( x * 16, y * 16)); + return *this; + } + template FORCEDINLINE CommandProcessor& toggle(int16_t x, int16_t y, int16_t w, int16_t h, T text, bool state, uint16_t options = FTDI::OPT_3D) { CLCD::FontMetrics fm(_font); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h index ba41650f2f..2e74ec3a47 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h @@ -239,9 +239,11 @@ class DeduplicatedPolyReader : public POLY_READER { */ template> class GenericPolyUI { - private: + protected: CommandProcessor &cmd; + draw_mode_t mode; + private: // Attributes used to paint buttons uint32_t btn_fill_color = 0x000000; @@ -250,8 +252,6 @@ class GenericPolyUI { uint32_t btn_stroke_color = 0x000000; uint8_t btn_stroke_width = 28; - draw_mode_t mode; - public: enum ButtonStyle : uint8_t { FILL = 1, diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp index 6d53d00bb8..0701e7d682 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp @@ -29,24 +29,29 @@ namespace FTDI { * be broken so that the display width is less than w. The line will also * be broken after a '\n'. Returns the display width of the line. */ - static uint16_t find_line_break(const FontMetrics &fm, uint16_t w, const char *str, const char *&end) { - w -= fm.get_char_width(' '); - const char *p = str; - end = str; + static uint16_t find_line_break(const FontMetrics &utf8_fm, const CLCD::FontMetrics &clcd_fm, const uint16_t w, const char *start, const char *&end, bool use_utf8) { + const char *p = start; + end = start; uint16_t lw = 0, result = 0; for (;;) { - utf8_char_t c = get_utf8_char_and_inc(p); - if (c == ' ' || c == '\n' || c == '\0') { - if (lw < w || end == str) { - end = (c == '\0') ? p-1 : p; - result = lw; - } - if (c == '\0' || c == '\n') break; + const char *next = p; + const utf8_char_t c = get_utf8_char_and_inc(next); + // Decide whether to break the string at this location + if (c == '\n' || c == '\0' || c == ' ') { + end = p; + result = lw; } - lw += fm.get_char_width(c); + if (c == '\n' || c == '\0') break; + // Measure the next character + const uint16_t cw = use_utf8 ? utf8_fm.get_char_width(c) : clcd_fm.char_widths[(uint8_t)c]; + // Stop processing once string exceeds the display width + if (lw + cw > w) break; + // Now add the length of the current character to the tally. + lw += cw; + p = next; } - if (end == str) { - end = p-1; + if (end == start) { + end = p; result = lw; } return result; @@ -55,17 +60,19 @@ namespace FTDI { /** * This function returns a measurements of the word-wrapped text box. */ - static void measure_text_box(const FontMetrics &fm, const char *str, uint16_t &width, uint16_t &height) { + static void measure_text_box(const FontMetrics &utf8_fm, const CLCD::FontMetrics &clcd_fm, const char *str, uint16_t &width, uint16_t &height, bool use_utf8) { const char *line_start = (const char*)str; const char *line_end; const uint16_t wrap_width = width; width = height = 0; for (;;) { - uint16_t line_width = find_line_break(fm, wrap_width, line_start, line_end); + const uint16_t line_width = find_line_break(utf8_fm, clcd_fm, wrap_width, line_start, line_end, use_utf8); if (line_end == line_start) break; width = max(width, line_width); - height += fm.get_height(); + height += utf8_fm.get_height(); line_start = line_end; + if (*line_start == '\n' || *line_start == ' ') line_start++; + if (*line_start == '\0') break; } } @@ -73,51 +80,54 @@ namespace FTDI { * This function draws text inside a bounding box, doing word wrapping and using the largest font that will fit. */ void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, const char *str, uint16_t options, uint8_t font) { + #if ENABLED(TOUCH_UI_USE_UTF8) + const bool use_utf8 = has_utf8_chars(str); + #else + constexpr bool use_utf8 = false; + #endif uint16_t box_width, box_height; - FontMetrics fm(font); + FontMetrics utf8_fm(font); + CLCD::FontMetrics clcd_fm; + clcd_fm.load(font); // Shrink the font until we find a font that fits for (;;) { box_width = w; - measure_text_box(fm, str, box_width, box_height); + measure_text_box(utf8_fm, clcd_fm, str, box_width, box_height, use_utf8); if (box_width <= (uint16_t)w && box_height <= (uint16_t)h) break; - fm.load(--font); if (font == 26) break; + utf8_fm.load(--font); + clcd_fm.load(font); } const uint16_t dx = (options & OPT_RIGHTX) ? w : - (options & OPT_CENTERX) ? w/2 : 0; - const uint16_t dy = (options & OPT_BOTTOMY) ? (h - box_height) : - (options & OPT_CENTERY) ? (h - box_height)/2 : 0; + (options & OPT_CENTERX) ? w / 2 : 0, + dy = (options & OPT_BOTTOMY) ? (h - box_height) : + (options & OPT_CENTERY) ? (h - box_height) / 2 : 0; - const char *line_start = str; - const char *line_end; + const char *line_start = str, *line_end; for (;;) { - find_line_break(fm, w, line_start, line_end); + find_line_break(utf8_fm, clcd_fm, w, line_start, line_end, use_utf8); if (line_end == line_start) break; const size_t line_len = line_end - line_start; if (line_len) { - char line[line_len + 1]; - strncpy(line, line_start, line_len); - line[line_len] = 0; - if (line[line_len - 1] == '\n' || line[line_len - 1] == ' ') - line[line_len - 1] = 0; - #if ENABLED(TOUCH_UI_USE_UTF8) - if (has_utf8_chars(line)) { - draw_utf8_text(cmd, x + dx, y + dy, line, fm.fs, options & ~(OPT_CENTERY | OPT_BOTTOMY)); - } else + if (use_utf8) + draw_utf8_text(cmd, x + dx, y + dy, line_start, utf8_fm.fs, options & ~(OPT_CENTERY | OPT_BOTTOMY), line_len); + else #endif { cmd.CLCD::CommandFifo::text(x + dx, y + dy, font, options & ~(OPT_CENTERY | OPT_BOTTOMY)); - cmd.CLCD::CommandFifo::str(line); + cmd.CLCD::CommandFifo::str(line_start, line_len); } } - y += fm.get_height(); + y += utf8_fm.get_height(); line_start = line_end; + if (*line_start == '\n' || *line_start == ' ') line_start++; + if (*line_start == '\0') break; } } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp index 55dd496e1c..2da5d55ff0 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp @@ -68,15 +68,17 @@ utf8_char_t FTDI::get_utf8_char_and_inc(const char *&c) { utf8_char_t val = *(uint8_t*)c++; - while ((*c & 0xC0) == 0x80) - val = (val << 8) | *(uint8_t*)c++; + if ((val & 0xC0) == 0xC0) + while ((*c & 0xC0) == 0x80) + val = (val << 8) | *(uint8_t*)c++; return val; } utf8_char_t FTDI::get_utf8_char_and_inc(char *&c) { utf8_char_t val = *(uint8_t*)c++; - while ((*c & 0xC0) == 0x80) - val = (val << 8) | *(uint8_t*)c++; + if ((val & 0xC0) == 0xC0) + while ((*c & 0xC0) == 0x80) + val = (val << 8) | *(uint8_t*)c++; return val; } @@ -95,9 +97,9 @@ * fs - A scaling object used to specify the font size. */ - static uint16_t render_utf8_text(CommandProcessor* cmd, int x, int y, const char *str, font_size_t fs) { + static uint16_t render_utf8_text(CommandProcessor* cmd, int x, int y, const char *str, font_size_t fs, size_t maxlen=SIZE_MAX) { const int start_x = x; - while (*str) { + while (*str && maxlen--) { const utf8_char_t c = get_utf8_char_and_inc(str); #ifdef TOUCH_UI_UTF8_CYRILLIC_CHARSET CyrillicCharSet::render_glyph(cmd, x, y, fs, c) || @@ -185,8 +187,8 @@ * Returns: A width in pixels */ - uint16_t FTDI::get_utf8_text_width(const char *str, font_size_t fs) { - return render_utf8_text(nullptr, 0, 0, str, fs); + uint16_t FTDI::get_utf8_text_width(const char *str, font_size_t fs, size_t maxlen) { + return render_utf8_text(nullptr, 0, 0, str, fs, maxlen); } uint16_t FTDI::get_utf8_text_width(progmem_str pstr, font_size_t fs) { @@ -210,9 +212,10 @@ * * options - Text alignment options (i.e. OPT_CENTERX, OPT_CENTERY, OPT_CENTER or OPT_RIGHTX) * + * maxlen - Maximum characters to draw */ - void FTDI::draw_utf8_text(CommandProcessor& cmd, int x, int y, const char *str, font_size_t fs, uint16_t options) { + void FTDI::draw_utf8_text(CommandProcessor& cmd, int x, int y, const char *str, font_size_t fs, uint16_t options, size_t maxlen) { cmd.cmd(SAVE_CONTEXT()); cmd.cmd(BITMAP_TRANSFORM_A(fs.get_coefficient())); cmd.cmd(BITMAP_TRANSFORM_E(fs.get_coefficient())); @@ -220,14 +223,14 @@ // Apply alignment options if (options & OPT_CENTERX) - x -= get_utf8_text_width(str, fs) / 2; + x -= get_utf8_text_width(str, fs, maxlen) / 2; else if (options & OPT_RIGHTX) - x -= get_utf8_text_width(str, fs); + x -= get_utf8_text_width(str, fs, maxlen); if (options & OPT_CENTERY) y -= fs.get_height()/2; // Render the text - render_utf8_text(&cmd, x, y, str, fs); + render_utf8_text(&cmd, x, y, str, fs, maxlen); cmd.cmd(RESTORE_CONTEXT()); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.h index 5bb87d9684..3ca6dfd563 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.h @@ -67,10 +67,10 @@ namespace FTDI { uint16_t get_utf8_char_width(utf8_char_t, font_size_t); uint16_t get_utf8_text_width(progmem_str, font_size_t); - uint16_t get_utf8_text_width(const char *, font_size_t); + uint16_t get_utf8_text_width(const char *, font_size_t, size_t maxlen=SIZE_MAX); void draw_utf8_text(CommandProcessor&, int x, int y, progmem_str, font_size_t, uint16_t options = 0); - void draw_utf8_text(CommandProcessor&, int x, int y, const char *, font_size_t, uint16_t options = 0); + void draw_utf8_text(CommandProcessor&, int x, int y, const char *, font_size_t, uint16_t options = 0, size_t maxlen=SIZE_MAX); // Similar to CLCD::FontMetrics, but can be used with UTF8 encoded strings. diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py new file mode 100755 index 0000000000..6aa8947b98 --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py @@ -0,0 +1,47 @@ +#!/usr/bin/python + +# Written By Marcio Teixeira 2021 - SynDaver Labs, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# To view a copy of the GNU General Public License, go to the following +# location: . + +from __future__ import print_function +import argparse +import textwrap +import os +import zlib + +def deflate(data): + return zlib.compress(data) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Converts a file into a packed C array for use as data') + parser.add_argument("input") + parser.add_argument("-d", "--deflate", action="store_true", help="Packs the data using the deflate algorithm") + args = parser.parse_args() + + varname = os.path.splitext(os.path.basename(args.input))[0]; + + with open(args.input, "rb") as in_file: + data = in_file.read() + if args.deflate: + data = deflate(data) + data = bytearray(data) + data = list(map(lambda a: "0x" + format(a, '02x'), data)) + nElements = len(data) + data = ', '.join(data) + data = textwrap.fill(data, 75, initial_indent = ' ', subsequent_indent = ' ') + + print("const unsigned char " + varname + "[" + format(nElements) + "] PROGMEM = {") + print(data) + print("};") diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py new file mode 100755 index 0000000000..0c4499e9aa --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py @@ -0,0 +1,108 @@ +#!/usr/bin/python + +# Written By Marcio Teixeira 2019 - Aleph Objects, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# To view a copy of the GNU General Public License, go to the following +# location: . + +from __future__ import print_function +from PIL import Image +import argparse +import textwrap + +def pack_rle(data): + """Use run-length encoding to pack the bytes""" + rle = [] + value = data[0] + count = 0 + for i in data: + if i != value or count == 255: + rle.append(count) + rle.append(value) + value = i + count = 1 + else: + count += 1 + rle.append(count) + rle.append(value) + return rle + +class WriteSource: + def __init__(self, lines_in_blocks): + self.blocks = [] + self.values = [] + self.block_size = lines_in_blocks + self.rows = 0 + + def add_pixel(self, value): + self.values.append(value) + + def convert_to_4bpp(self, data, chunk_size = 0): + # Invert the image + data = list(map(lambda i: 255 - i, data)) + # Quanitize 8-bit values into 4-bits + data = list(map(lambda i: i >> 4, data)) + # Make sure there is an even number of elements + if (len(data) & 1) == 1: + data.append(0) + # Combine each two adjacent values into one + i = iter(data) + data = list(map(lambda a, b: a << 4 | b, i ,i)) + # Pack the data + data = pack_rle(data) + # Convert values into hex strings + return list(map(lambda a: "0x" + format(a, '02x'), data)) + + def end_row(self, y): + # Pad each row into even number of values + if len(self.values) & 1: + self.values.append(0) + + self.rows += 1 + if self.block_size and (self.rows % self.block_size) == 0: + self.blocks.append(self.values) + self.values = [] + + def write(self): + if len(self.values): + self.blocks.append(self.values) + + block_strs = []; + for b in self.blocks: + data = self.convert_to_4bpp(b) + data = ', '.join(data) + data = textwrap.fill(data, 75, initial_indent = ' ', subsequent_indent = ' ') + block_strs.append(data) + + print("const unsigned char font[] PROGMEM = {") + for i, b in enumerate(block_strs): + if i: + print(',') + print('\n /* {} */'.format(i)) + print(b, end='') + print("\n};") + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Converts a grayscale bitmap into a 16-level RLE packed C array for use as font data') + parser.add_argument("input") + parser.add_argument('--char_height', help='Adds a separator every so many lines', type=int) + args = parser.parse_args() + + writer = WriteSource(args.char_height) + + img = Image.open(args.input).convert('L') + for y in range(img.height): + for x in range(img.width): + writer.add_pixel(img.getpixel((x,y))) + writer.end_row(y) + writer.write() diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py new file mode 100755 index 0000000000..74be574300 --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py @@ -0,0 +1,113 @@ +#!/usr/bin/python + +# Written By Marcio Teixeira 2021 - SynDaver Labs, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# To view a copy of the GNU General Public License, go to the following +# location: . + +from __future__ import print_function +from PIL import Image +import argparse +import textwrap +import os +import sys +import zlib + +class WriteSource: + def __init__(self, mode): + self.values = [] + self.mode = mode + self.offset = 8 + self.byte = 0 + + def finish_byte(self): + if self.offset != 8: + self.values.append(self.byte) + self.offset = 8 + self.byte = 0 + + def add_bits_to_byte(self, value, size = 1): + self.offset -= size + self.byte = self.byte | value << self.offset + if self.offset == 0: + self.finish_byte() + + def append_rgb565(self, color): + value = ((color[0] & 0xF8) << 8) + ((color[1] & 0xFC) << 3) + ((color[2] & 0xF8) >> 3) + self.values.append((value & 0x00FF) >> 0); + self.values.append((value & 0xFF00) >> 8); + + def append_rgb332(self, color): + value = (color[0] & 0xE0) + ((color[1] & 0xE0) >> 3) + ((color[2] & 0xC0) >> 6) + self.values.append(value); + + def append_grayscale(self, color, bits): + luminance = int(0.2126 * color[0] + 0.7152 * color[1] + 0.0722 * color[2]) + self.add_bits_to_byte(luminance >> (8 - bits), bits) + + def deflate(self, data): + return zlib.compress(data) + + def add_pixel(self, color): + if self.mode == "l1": + self.append_grayscale(color, 1) + elif self.mode == "l2": + self.append_grayscale(color, 2) + elif self.mode == "l4": + self.append_grayscale(color, 4) + elif self.mode == "l8": + self.append_grayscale(color, 8) + elif self.mode == "rgb565": + self.append_rgb565(color) + elif self.mode == "rgb332": + self.append_rgb332(color) + + def end_row(self, y): + if self.mode in ["l1", "l2", "l3"]: + self.finish_byte() + + def write(self, varname, deflate): + print("Length of uncompressed data: ", len(self.values), file=sys.stderr) + data = bytes(bytearray(self.values)) + if deflate: + data = self.deflate(data) + print("Length of data after compression: ", len(data), file=sys.stderr) + data = bytearray(data) + data = list(map(lambda a: "0x" + format(a, '02x'), data)) + nElements = len(data) + data = ', '.join(data) + data = textwrap.fill(data, 75, initial_indent = ' ', subsequent_indent = ' ') + + print("const unsigned char " + varname + "[" + format(nElements) + "] PROGMEM = {") + print(data) + print("};") + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Converts a bitmap into a C array') + parser.add_argument("input") + parser.add_argument("-d", "--deflate", action="store_true", help="Packs the data using the deflate algorithm") + parser.add_argument("-m", "--mode", default="l1", help="Mode, can be l1, l2, l4, l8, rgb332 or rgb565") + args = parser.parse_args() + + varname = os.path.splitext(os.path.basename(args.input))[0]; + + writer = WriteSource(args.mode) + + img = Image.open(args.input) + print("Image height: ", img.height, file=sys.stderr) + print("Image width: ", img.width, file=sys.stderr) + for y in range(img.height): + for x in range(img.width): + writer.add_pixel(img.getpixel((x,y))) + writer.end_row(y) + writer.write(varname, args.deflate) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/about_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp similarity index 80% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/about_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp index 1d8db12ef9..d2aec0baf7 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/about_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp @@ -21,12 +21,12 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_ABOUT_SCREEN #define GRID_COLS 4 -#define GRID_ROWS 7 +#define GRID_ROWS 8 using namespace FTDI; using namespace Theme; @@ -44,15 +44,12 @@ void AboutScreen::onRedraw(draw_mode_t) { .cmd(COLOR_RGB(bg_text_enabled)) .tag(0); - #define HEADING_POS BTN_POS(1,2), BTN_SIZE(4,1) + #define HEADING_POS BTN_POS(1,1), BTN_SIZE(4,2) #define FW_VERS_POS BTN_POS(1,3), BTN_SIZE(4,1) #define FW_INFO_POS BTN_POS(1,4), BTN_SIZE(4,1) - #define LICENSE_POS BTN_POS(1,5), BTN_SIZE(4,2) - #define STATS_POS BTN_POS(1,7), BTN_SIZE(2,1) - #define BACK_POS BTN_POS(3,7), BTN_SIZE(2,1) - - #define _INSET_POS(x,y,w,h) x + w/10, y, w - w/5, h - #define INSET_POS(pos) _INSET_POS(pos) + #define LICENSE_POS BTN_POS(1,5), BTN_SIZE(4,3) + #define STATS_POS BTN_POS(1,8), BTN_SIZE(2,1) + #define BACK_POS BTN_POS(3,8), BTN_SIZE(2,1) char about_str[1 + strlen_P(GET_TEXT(MSG_ABOUT_TOUCH_PANEL_2)) @@ -79,7 +76,9 @@ void AboutScreen::onRedraw(draw_mode_t) { #endif , OPT_CENTER, font_xlarge ); - cmd.tag(3); + #if BOTH(TOUCH_UI_DEVELOPER_MENU, FTDI_DEVELOPER_MENU) + cmd.tag(3); + #endif draw_text_box(cmd, FW_VERS_POS, #ifdef TOUCH_UI_VERSION F(TOUCH_UI_VERSION) @@ -89,22 +88,24 @@ void AboutScreen::onRedraw(draw_mode_t) { , OPT_CENTER, font_medium); cmd.tag(0); draw_text_box(cmd, FW_INFO_POS, about_str, OPT_CENTER, font_medium); - draw_text_box(cmd, INSET_POS(LICENSE_POS), GET_TEXT_F(MSG_LICENSE), OPT_CENTER, font_tiny); + draw_text_box(cmd, LICENSE_POS, GET_TEXT_F(MSG_LICENSE), OPT_CENTER, font_tiny); - cmd.font(font_medium) - .colors(normal_btn) - .tag(2).button(STATS_POS, GET_TEXT_F(MSG_INFO_STATS_MENU)) - .colors(action_btn) - .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); + cmd.font(font_medium); + #if BOTH(PRINTCOUNTER, FTDI_STATISTICS_SCREEN) + cmd.colors(normal_btn) + .tag(2).button(STATS_POS, GET_TEXT_F(MSG_INFO_STATS_MENU)); + #endif + cmd.colors(action_btn) + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } bool AboutScreen::onTouchEnd(uint8_t tag) { switch (tag) { case 1: GOTO_PREVIOUS(); break; - #if ENABLED(PRINTCOUNTER) + #if BOTH(PRINTCOUNTER, FTDI_STATISTICS_SCREEN) case 2: GOTO_SCREEN(StatisticsScreen); break; #endif - #if ENABLED(TOUCH_UI_DEVELOPER_MENU) + #if BOTH(TOUCH_UI_DEVELOPER_MENU, FTDI_DEVELOPER_MENU) case 3: GOTO_SCREEN(DeveloperMenu); break; #endif default: return false; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/about_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/about_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/advanced_settings_menu.cpp similarity index 98% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/advanced_settings_menu.cpp index b9255c11b9..a83cc07515 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/advanced_settings_menu.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_ADVANCED_SETTINGS_MENU @@ -111,7 +111,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { .enabled(ENABLED(BACKLASH_GCODE)) .tag(8).button(BACKLASH_POS, GET_TEXT_F(MSG_BACKLASH)) .colors(action_btn) - .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } } @@ -122,7 +122,7 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) { case 2: GOTO_SCREEN(ZOffsetScreen); break; #endif case 3: GOTO_SCREEN(StepsScreen); break; - #if ENABLED(HAS_MULTI_HOTEND) + #if HAS_MULTI_HOTEND case 4: GOTO_SCREEN(NozzleOffsetScreen); break; #endif case 5: GOTO_SCREEN(MaxVelocityScreen); break; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/advanced_settings_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/advanced_settings_menu.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/advanced_settings_menu.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/advanced_settings_menu.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/alert_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/alert_dialog_box.cpp similarity index 89% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/alert_dialog_box.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/alert_dialog_box.cpp index bbe922ad5d..0d309bff75 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/alert_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/alert_dialog_box.cpp @@ -21,8 +21,8 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_ALERT_DIALOG_BOX @@ -43,7 +43,7 @@ void AlertDialogBox::onRedraw(draw_mode_t what) { } template -void AlertDialogBox::show(const T message) { +void AlertDialogBox::show(T message) { drawMessage(message); storeBackground(); mydata.isError = false; @@ -51,7 +51,7 @@ void AlertDialogBox::show(const T message) { } template -void AlertDialogBox::showError(const T message) { +void AlertDialogBox::showError(T message) { drawMessage(message); storeBackground(); mydata.isError = true; @@ -64,8 +64,8 @@ void AlertDialogBox::hide() { } template void AlertDialogBox::show(const char *); -template void AlertDialogBox::show(const progmem_str); +template void AlertDialogBox::show(progmem_str); template void AlertDialogBox::showError(const char *); -template void AlertDialogBox::showError(const progmem_str); +template void AlertDialogBox::showError(progmem_str); #endif // FTDI_ALERT_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/alert_dialog_box.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/alert_dialog_box.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/alert_dialog_box.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/alert_dialog_box.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/backlash_compensation_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/backlash_compensation_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/backlash_compensation_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/backlash_compensation_screen.cpp index 11fb72b5a8..c3fcb25f43 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/backlash_compensation_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/backlash_compensation_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BACKLASH_COMP_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/backlash_compensation_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/backlash_compensation_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/backlash_compensation_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/backlash_compensation_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp index 747e632d8f..d0ba74721c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp @@ -21,8 +21,8 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_BASE_NUMERIC_ADJ_SCREEN @@ -61,7 +61,7 @@ BaseNumericAdjustmentScreen::widgets_t::widgets_t(draw_mode_t what) : _what(what #else BTN_POS(15,7), BTN_SIZE(4,1), #endif - GET_TEXT_F(MSG_BACK), true, true + GET_TEXT_F(MSG_BUTTON_DONE), true, true ); _line = 1; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp similarity index 93% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp index 139a3100cf..0a8bebea3c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BASE_SCREEN @@ -45,7 +45,7 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t return false; } - #if LCD_TIMEOUT_TO_STATUS > 0 + #if SCREENS_CAN_TIME_OUT if (EventLoop::get_pressed_tag() != 0) { reset_menu_timeout(); } @@ -65,7 +65,7 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t } void BaseScreen::onIdle() { - #if LCD_TIMEOUT_TO_STATUS > 0 + #if SCREENS_CAN_TIME_OUT if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) { reset_menu_timeout(); #if ENABLED(TOUCH_UI_DEBUG) @@ -77,12 +77,10 @@ void BaseScreen::onIdle() { } void BaseScreen::reset_menu_timeout() { - #if LCD_TIMEOUT_TO_STATUS > 0 - last_interaction = millis(); - #endif + TERN_(SCREENS_CAN_TIME_OUT, last_interaction = millis()); } -#if LCD_TIMEOUT_TO_STATUS > 0 +#if SCREENS_CAN_TIME_OUT uint32_t BaseScreen::last_interaction; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.h similarity index 98% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.h index cbeea1f750..030fa51a2a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/base_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.h @@ -27,7 +27,7 @@ class BaseScreen : public UIScreen { protected: - #if LCD_TIMEOUT_TO_STATUS > 0 + #if SCREENS_CAN_TIME_OUT static uint32_t last_interaction; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_base.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_base.cpp index 83b0825802..14f2196453 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_base.cpp @@ -20,7 +20,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BED_MESH_BASE diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_base.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_base.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_base.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_base.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp similarity index 93% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp index 31c6ab8fcb..c7d0cc3f73 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp @@ -20,8 +20,8 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_BED_MESH_EDIT_SCREEN @@ -136,7 +136,7 @@ void BedMeshEditScreen::drawHighlightedPointValue() { if (mydata.highlight.x != NONE) draw_adjuster(cmd, Z_VALUE_POS, 3, getHighlightedValue(), GET_TEXT_F(MSG_UNITS_MM), 4, 3); cmd.colors(mydata.needSave ? normal_btn : action_btn) - .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_BACK)) + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)) .colors(mydata.needSave ? action_btn : normal_btn) .enabled(mydata.needSave) .tag(2).button(SAVE_POS, GET_TEXT_F(MSG_TOUCHMI_SAVE)); @@ -190,17 +190,11 @@ bool BedMeshEditScreen::onTouchEnd(uint8_t tag) { } void BedMeshEditScreen::show() { - // On entry, home if needed and save current mesh - if (!ExtUI::isMachineHomed()) { - SpinnerDialogBox::enqueueAndWait_P(F("G28\nG29 S1")); - // After the spinner, go to this screen. - current_screen.forget(); - PUSH_SCREEN(BedMeshEditScreen); - } - else { - injectCommands_P(PSTR("G29 S1")); - GOTO_SCREEN(BedMeshEditScreen); - } + // On entry, always home (to account for possible Z offset changes) and save current mesh + SpinnerDialogBox::enqueueAndWait(F("G28\nG29 S1")); + // After the spinner, go to this screen. + current_screen.forget(); + PUSH_SCREEN(BedMeshEditScreen); } #endif // FTDI_BED_MESH_EDIT_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp similarity index 96% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp index 1a00e10ca9..552cd831ea 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp @@ -20,8 +20,8 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_BED_MESH_VIEW_SCREEN @@ -69,7 +69,7 @@ void BedMeshViewScreen::onEntry() { void BedMeshViewScreen::drawHighlightedPointValue() { CommandProcessor cmd; cmd.font(Theme::font_medium) - .colors(normal_btn) + .cmd(COLOR_RGB(bg_text_enabled)) .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z)) .font(font_small); @@ -132,7 +132,6 @@ void BedMeshViewScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI mydata.count = GRID_MAX_POINTS; break; case ExtUI::G26_START: - GOTO_SCREEN(BedMeshViewScreen); mydata.message = nullptr; mydata.count = 0; break; @@ -161,7 +160,7 @@ void BedMeshViewScreen::doProbe() { void BedMeshViewScreen::doMeshValidation() { mydata.count = 0; GOTO_SCREEN(StatusScreen); - injectCommands_P(PSTR("G28 O\nM117 Heating...\nG26 R X0 Y0")); + injectCommands_P(PSTR("G28\nM117 Heating...\nG26 R X0 Y0\nG27")); } void BedMeshViewScreen::show() { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/boot_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/boot_screen.cpp similarity index 96% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/boot_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/boot_screen.cpp index c8c7cdb5a5..c0940bed5c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/boot_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/boot_screen.cpp @@ -22,7 +22,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_BOOT_SCREEN @@ -83,8 +83,10 @@ void BootScreen::onIdle() { if (UIData::animations_enabled()) { // If there is a startup video in the flash SPI, play // that, otherwise show a static splash screen. - if (!MediaPlayerScreen::playBootMedia()) - showSplashScreen(); + #ifdef FTDI_MEDIA_PLAYER_SCREEN + if (!MediaPlayerScreen::playBootMedia()) + #endif + showSplashScreen(); } #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/boot_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/boot_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/boot_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/boot_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/case_light_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/case_light_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/case_light_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/case_light_screen.cpp index 04327128ab..8fbb400a68 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/case_light_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/case_light_screen.cpp @@ -20,7 +20,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_CASE_LIGHT_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/case_light_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/case_light_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/case_light_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/case_light_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/change_filament_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp similarity index 98% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/change_filament_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp index e9fa8a66d4..fa0748c17b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/change_filament_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp @@ -21,8 +21,8 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_CHANGE_FILAMENT_SCREEN @@ -76,7 +76,7 @@ constexpr static ChangeFilamentScreenData &mydata = screen_data.ChangeFilamentSc /****************** COLOR SCALE ***********************/ -uint32_t getWarmColor(uint16_t temp, uint16_t cool, uint16_t low, uint16_t med, uint16_t high) { +uint32_t ChangeFilamentScreen::getWarmColor(uint16_t temp, uint16_t cool, uint16_t low, uint16_t med, uint16_t high) { rgb_t R0, R1, mix; float t; @@ -224,7 +224,7 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) { .tag(6) .enabled(t_ok).button (LOAD_MOMN_POS, GET_TEXT_F(MSG_MOMENTARY)) .tag(7).TOG_STYLE(tog7).enabled(t_ok).button (UNLD_CONT_POS, GET_TEXT_F(MSG_CONTINUOUS)) .tag(8).TOG_STYLE(tog8).enabled(t_ok).button (LOAD_CONT_POS, GET_TEXT_F(MSG_CONTINUOUS)) - .tag(1).colors(action_btn) .button (BACK_POS, GET_TEXT_F(MSG_BACK)); + .tag(1).colors(action_btn) .button (BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/change_filament_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.h similarity index 95% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/change_filament_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.h index 43a4bae6e0..42eaf25f4a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/change_filament_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.h @@ -38,9 +38,9 @@ class ChangeFilamentScreen : public BaseScreen, public CachedScreen -void DialogBoxBaseClass::drawMessage(const T message, int16_t font) { +void DialogBoxBaseClass::drawMessage(T message, int16_t font) { CommandProcessor cmd; cmd.cmd(CMD_DLSTART) .cmd(CLEAR_COLOR_RGB(bg_color)) @@ -59,12 +59,16 @@ void DialogBoxBaseClass::drawOkayButton() { .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_OKAY)); } -void DialogBoxBaseClass::drawButton(const progmem_str label) { +template +void DialogBoxBaseClass::drawButton(T label) { CommandProcessor cmd; cmd.font(font_medium) .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), label); } +template void DialogBoxBaseClass::drawButton(const char *); +template void DialogBoxBaseClass::drawButton(progmem_str); + void DialogBoxBaseClass::drawSpinner() { CommandProcessor cmd; cmd.cmd(COLOR_RGB(bg_text_enabled)) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/dialog_box_base_class.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/dialog_box_base_class.h similarity index 93% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/dialog_box_base_class.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/dialog_box_base_class.h index ef5e6b569b..d48f3a03b3 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/dialog_box_base_class.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/dialog_box_base_class.h @@ -27,11 +27,11 @@ class DialogBoxBaseClass : public BaseScreen { protected: - template static void drawMessage(const T, int16_t font = 0); + template static void drawMessage(T, int16_t font = 0); + template static void drawButton(T); static void drawYesNoButtons(uint8_t default_btn = 0); static void drawOkayButton(); static void drawSpinner(); - static void drawButton(const progmem_str); static void onRedraw(draw_mode_t) {}; public: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/display_tuning_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/display_tuning_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/display_tuning_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/display_tuning_screen.cpp index 62a329e907..504ebde169 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/display_tuning_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/display_tuning_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_DISPLAY_TUNING_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/display_tuning_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/display_tuning_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/display_tuning_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/display_tuning_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp index e79e88b6b0..c7042e760e 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_ENDSTOP_STATE_SCREEN @@ -120,7 +120,7 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { cmd.font(font_medium) .colors(action_btn) - .tag(1).button(BTN_POS(1,7), BTN_SIZE(6,1), GET_TEXT_F(MSG_BACK)); + .tag(1).button(BTN_POS(1,7), BTN_SIZE(6,1), GET_TEXT_F(MSG_BUTTON_DONE)); #undef GRID_COLS #undef GRID_ROWS } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/endstop_state_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/endstop_state_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/feedrate_percent_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/feedrate_percent_screen.cpp similarity index 98% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/feedrate_percent_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/feedrate_percent_screen.cpp index 8b3984aa01..80eb295f64 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/feedrate_percent_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/feedrate_percent_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_FEEDRATE_PERCENT_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/feedrate_percent_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/feedrate_percent_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/feedrate_percent_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/feedrate_percent_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_menu.cpp similarity index 97% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_menu.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_menu.cpp index cf63a1a124..9c9e70cebf 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_menu.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_FILAMENT_MENU @@ -63,7 +63,7 @@ void FilamentMenu::onRedraw(draw_mode_t what) { .enabled(ENABLED(LIN_ADVANCE)) .tag(3).button(LIN_ADVANCE_POS, GET_TEXT_F(MSG_LINEAR_ADVANCE)) .colors(action_btn) - .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_menu.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_menu.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_menu.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_runout_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_runout_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp index 069686b541..37ab70f7ac 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_runout_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_FILAMENT_RUNOUT_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_runout_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/filament_runout_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/files_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp similarity index 97% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/files_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp index f9057ae88e..aa54e88967 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/files_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp @@ -21,8 +21,8 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_FILES_SCREEN @@ -168,7 +168,7 @@ void FilesScreen::drawFooter() { cmd.colors(normal_btn) .font(font_medium) .colors(has_selection ? normal_btn : action_btn) - .tag(back_tag).button(BTN_POS(4,y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BACK)) + .tag(back_tag).button(BTN_POS(4,y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_DONE)) .enabled(has_selection) .colors(has_selection ? action_btn : normal_btn); @@ -262,4 +262,8 @@ void FilesScreen::onIdle() { #endif } +void FilesScreen::onMediaRemoved() { + if (AT_SCREEN(FilesScreen)) GOTO_SCREEN(StatusScreen); +} + #endif // FTDI_FILES_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/files_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.h similarity index 98% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/files_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.h index 06ae88a45a..be75684ceb 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/files_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.h @@ -72,4 +72,5 @@ class FilesScreen : public BaseScreen, public CachedScreen { static void enable(); static void disable(); - static void set_hash(uint16_t pass) {passcode = pass;}; - static uint16_t get_hash() {return passcode;}; + static void set_hash(uint16_t pass) { passcode = pass; } + static uint16_t get_hash() { return passcode; } static void onEntry(); static void onRedraw(draw_mode_t); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/main_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp similarity index 97% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/main_menu.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp index 53d6306175..a6c39db796 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/main_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp @@ -22,7 +22,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_MAIN_MENU @@ -95,7 +95,7 @@ void MainMenu::onRedraw(draw_mode_t what) { .tag(11).button(CUSTOM_MENU_POS, GET_TEXT_F(MSG_CUSTOM_COMMANDS)) #endif .colors(action_btn) - .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } } @@ -104,7 +104,7 @@ bool MainMenu::onTouchEnd(uint8_t tag) { switch (tag) { case 1: SaveSettingsDialogBox::promptToSaveSettings(); break; - case 2: SpinnerDialogBox::enqueueAndWait_P(F("G28")); break; + case 2: SpinnerDialogBox::enqueueAndWait(F("G28")); break; #if ENABLED(NOZZLE_CLEAN_FEATURE) case 3: injectCommands_P(PSTR("G12")); GOTO_SCREEN(StatusScreen); break; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/main_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/main_menu.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_acceleration_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_acceleration_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp index d4d14d6331..be3a244380 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_acceleration_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_MAX_ACCELERATION_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_acceleration_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_acceleration_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp index 4de3e33360..bca533c94f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_MAX_VELOCITY_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_velocity_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/max_velocity_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/media_player_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/media_player_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/media_player_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/media_player_screen.cpp index 38e8b0b5c7..061c8555df 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/media_player_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/media_player_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" /** * The MediaPlayerScreen allows an AVI to be played. diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/media_player_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/media_player_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/media_player_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/media_player_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp similarity index 93% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp index 9406572c33..a3c3b503d8 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp @@ -21,8 +21,8 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_MOVE_AXIS_SCREEN @@ -98,10 +98,10 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) { case 14: UI_DECREMENT_AXIS(E3); mydata.e_rel[3] -= increment; break; case 15: UI_INCREMENT_AXIS(E3); mydata.e_rel[3] += increment; break; #endif - case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28X")); break; - case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28Y")); break; - case 22: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break; - case 23: SpinnerDialogBox::enqueueAndWait_P(F("G28")); break; + case 20: SpinnerDialogBox::enqueueAndWait(F("G28X")); break; + case 21: SpinnerDialogBox::enqueueAndWait(F("G28Y")); break; + case 22: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break; + case 23: SpinnerDialogBox::enqueueAndWait(F("G28")); break; case 24: raiseZtoTop(); break; default: return false; @@ -121,7 +121,7 @@ float BaseMoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) { // being held down, this allows enough margin for the planner to // connect segments and even out the motion. constexpr xyze_feedrate_t max_manual_feedrate = MANUAL_FEEDRATE; - return min(max_manual_feedrate[axis] / 60.0f, abs(increment_mm * (TOUCH_REPEATS_PER_SECOND) * 0.80f)); + return min(max_manual_feedrate[axis] / 60.0f, ABS(increment_mm * (TOUCH_REPEATS_PER_SECOND) * 0.80f)); } void BaseMoveAxisScreen::setManualFeedrate(ExtUI::axis_t axis, float increment_mm) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nozzle_offsets_screen.cpp similarity index 99% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nozzle_offsets_screen.cpp index a444a07cfc..288d06ea8e 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nozzle_offsets_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_NOZZLE_OFFSETS_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nozzle_offsets_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nozzle_offsets_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nudge_nozzle_screen.cpp similarity index 98% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nudge_nozzle_screen.cpp index 96ad833b14..c1611100a9 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nudge_nozzle_screen.cpp @@ -21,8 +21,8 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_NUDGE_NOZZLE_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nudge_nozzle_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/nudge_nozzle_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/restore_failsafe_dialog_box.cpp similarity index 98% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/restore_failsafe_dialog_box.cpp index 8dce1a259c..2dfd64fa5b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/restore_failsafe_dialog_box.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_RESTORE_FAILSAFE_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/restore_failsafe_dialog_box.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/restore_failsafe_dialog_box.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/save_settings_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.cpp similarity index 94% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/save_settings_dialog_box.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.cpp index a475a9863c..5d92052ace 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/save_settings_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_SAVE_SETTINGS_DIALOG_BOX @@ -60,4 +60,8 @@ void SaveSettingsDialogBox::promptToSaveSettings() { GOTO_PREVIOUS(); // No save needed. } +void SaveSettingsDialogBox::promptToSaveAndStay() { + if (needs_save) GOTO_SCREEN(SaveSettingsDialogBox); +} + #endif // FTDI_SAVE_SETTINGS_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/save_settings_dialog_box.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.h similarity index 97% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/save_settings_dialog_box.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.h index 8985a974fe..0cbadfbbe6 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/save_settings_dialog_box.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.h @@ -34,5 +34,6 @@ class SaveSettingsDialogBox : public DialogBoxBaseClass, public UncachedScreen { static bool onTouchEnd(uint8_t tag); static void promptToSaveSettings(); + static void promptToSaveAndStay(); static void settingsChanged() {needs_save = true;} }; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/screens.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/screens.h similarity index 80% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/screens.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/screens.h index 316896c360..b88e517576 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/screens.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/screens.h @@ -22,21 +22,6 @@ #pragma once -#include "../compat.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - -#include "../ftdi_eve_lib/ftdi_eve_lib.h" -#include "../language/language.h" -#include "../theme/theme.h" -#include "string_format.h" - -#ifndef BED_LEVELING_COMMANDS - #define BED_LEVELING_COMMANDS "G29" -#endif - -extern tiny_timer_t refresh_timer; - /********************************* DL CACHE SLOTS ******************************/ // In order to reduce SPI traffic, we cache display lists (DL) in RAMG. This @@ -98,16 +83,6 @@ enum { #if ENABLED(FILAMENT_RUNOUT_SENSOR) FILAMENT_RUNOUT_SCREEN_CACHE, #endif - #if ENABLED(TOUCH_UI_LULZBOT_BIO) - PRINTING_SCREEN_CACHE, - #endif - #if ENABLED(TOUCH_UI_COCOA_PRESS) - PREHEAT_MENU_CACHE, - PREHEAT_TIMER_SCREEN_CACHE, - LOAD_CHOCOLATE_SCREEN_CACHE, - MOVE_XYZ_SCREEN_CACHE, - MOVE_E_SCREEN_CACHE, - #endif #if ENABLED(SDSUPPORT) FILES_SCREEN_CACHE, #endif @@ -135,36 +110,10 @@ enum { #include "base_screen.h" #include "base_numeric_adjustment_screen.h" #include "dialog_box_base_class.h" - -#if ENABLED(TOUCH_UI_LULZBOT_BIO) - #include "bio_status_screen.h" - #include "bio_main_menu.h" - #include "bio_tune_menu.h" - #include "bio_advanced_settings.h" - #include "bio_printing_dialog_box.h" - #include "bio_confirm_home_xyz.h" - #include "bio_confirm_home_e.h" - -#elif ENABLED(TOUCH_UI_COCOA_PRESS) - #include "cocoa_press_status_screen.h" - #include "cocoa_press_main_menu.h" - #include "cocoa_press_advanced_settings_menu.h" - #include "cocoa_press_preheat_menu.h" - #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" - -#else - #include "status_screen.h" - #include "main_menu.h" - #include "advanced_settings_menu.h" - #include "tune_menu.h" -#endif - +#include "status_screen.h" +#include "main_menu.h" +#include "advanced_settings_menu.h" +#include "tune_menu.h" #include "boot_screen.h" #include "about_screen.h" #include "kill_screen.h" @@ -206,7 +155,11 @@ enum { #endif #if HAS_LEVELING - #include "leveling_menu.h" + #if ENABLED(TOUCH_UI_SYNDAVER_LEVEL) + #include "syndaver_level/leveling_menu.h" + #else + #include "leveling_menu.h" + #endif #if HAS_BED_PROBE #include "z_offset_screen.h" #endif @@ -269,5 +222,3 @@ enum { #if NUM_LANGUAGES > 1 #include "language_menu.h" #endif - -#endif // TOUCH_UI_FTDI_EVE diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/spinner_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp similarity index 54% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/spinner_dialog_box.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp index 7483261e3c..830a0238fe 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/spinner_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp @@ -21,48 +21,87 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_SPINNER_DIALOG_BOX +#define GRID_COLS 2 +#define GRID_ROWS 8 + using namespace FTDI; using namespace ExtUI; +using namespace Theme; constexpr static SpinnerDialogBoxData &mydata = screen_data.SpinnerDialogBox; -void SpinnerDialogBox::onRedraw(draw_mode_t) { +void SpinnerDialogBox::onEntry() { + UIScreen::onEntry(); + mydata.auto_hide = true; } -void SpinnerDialogBox::show(const progmem_str message) { - drawMessage(message); - drawSpinner(); - storeBackground(); - mydata.auto_hide = false; -} - -void SpinnerDialogBox::hide() { +void SpinnerDialogBox::onExit() { CommandProcessor cmd; cmd.stop().execute(); } -void SpinnerDialogBox::enqueueAndWait_P(const progmem_str commands) { - enqueueAndWait_P(GET_TEXT_F(MSG_PLEASE_WAIT), commands); +void SpinnerDialogBox::onRefresh() { + using namespace FTDI; + DLCache dlcache(SPINNER_CACHE); + CommandProcessor cmd; + cmd.cmd(CMD_DLSTART); + if (dlcache.has_data()) + dlcache.append(); + else + dlcache.store(SPINNER_DL_SIZE); + cmd.spinner(BTN_POS(1,4), BTN_SIZE(2,3)).execute(); } -void SpinnerDialogBox::enqueueAndWait_P(const progmem_str message, const progmem_str commands) { +void SpinnerDialogBox::onRedraw(draw_mode_t) { +} + +void SpinnerDialogBox::show(progmem_str message) { + CommandProcessor cmd; + if (AT_SCREEN(SpinnerDialogBox)) cmd.stop().execute(); + cmd.cmd(CMD_DLSTART) + .cmd(CLEAR_COLOR_RGB(bg_color)) + .cmd(CLEAR(true,true,true)) + .cmd(COLOR_RGB(bg_text_enabled)) + .tag(0); + draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,3), message, OPT_CENTER, font_large); + DLCache dlcache(SPINNER_CACHE); + if (!dlcache.store(SPINNER_DL_SIZE)) { + SERIAL_ECHO_MSG("CachedScreen::storeBackground() failed: not enough DL cache space"); + cmd.cmd(CMD_DLSTART).cmd(CLEAR(true,true,true)); + dlcache.store(SPINNER_DL_SIZE); + } + if (AT_SCREEN(SpinnerDialogBox)) + cmd.spinner(BTN_POS(1,4), BTN_SIZE(2,3)).execute(); + else + GOTO_SCREEN(SpinnerDialogBox); + mydata.auto_hide = false; +} + +void SpinnerDialogBox::hide() { + GOTO_PREVIOUS(); +} + +void SpinnerDialogBox::enqueueAndWait(progmem_str message, progmem_str commands) { show(message); - GOTO_SCREEN(SpinnerDialogBox); ExtUI::injectCommands_P((const char*)commands); mydata.auto_hide = true; } +void SpinnerDialogBox::enqueueAndWait(progmem_str message, char *commands) { + show(message); + ExtUI::injectCommands(commands); + mydata.auto_hide = true; +} + void SpinnerDialogBox::onIdle() { - reset_menu_timeout(); - if (mydata.auto_hide && !commandsInQueue()) { + if (mydata.auto_hide && !commandsInQueue() && TERN1(HOST_KEEPALIVE_FEATURE, GcodeSuite::busy_state == GcodeSuite::NOT_BUSY)) { mydata.auto_hide = false; hide(); - GOTO_PREVIOUS(); } } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/spinner_dialog_box.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.h similarity index 79% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/spinner_dialog_box.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.h index c5f0ae8e9f..23e31d1a91 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/spinner_dialog_box.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.h @@ -29,13 +29,20 @@ struct SpinnerDialogBoxData { bool auto_hide; }; -class SpinnerDialogBox : public DialogBoxBaseClass, public CachedScreen { +class SpinnerDialogBox : public UIScreen { public: + static void onEntry(); + static void onExit(); static void onRedraw(draw_mode_t); + static void onRefresh(); static void onIdle(); - static void show(const progmem_str); + static void show(progmem_str); static void hide(); - static void enqueueAndWait_P(const progmem_str commands); - static void enqueueAndWait_P(const progmem_str message, const progmem_str commands); + + template + static void enqueueAndWait(T commands) {enqueueAndWait(GET_TEXT_F(MSG_PLEASE_WAIT), commands);} + + static void enqueueAndWait(progmem_str message, char *commands); + static void enqueueAndWait(progmem_str message, progmem_str commands); }; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/statistics_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/statistics_screen.cpp similarity index 98% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/statistics_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/statistics_screen.cpp index 2d62d5349b..b6d9770e9d 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/statistics_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/statistics_screen.cpp @@ -21,7 +21,7 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" +#include "../screens.h" #ifdef FTDI_STATISTICS_SCREEN @@ -63,7 +63,7 @@ void StatisticsScreen::onRedraw(draw_mode_t what) { if (what & FOREGROUND) { cmd.font(Theme::font_medium) .colors(action_btn) - .tag(1).button(BTN_POS(1,7), BTN_SIZE(4,1), GET_TEXT_F(MSG_BACK)); + .tag(1).button(BTN_POS(1,7), BTN_SIZE(4,1), GET_TEXT_F(MSG_BUTTON_DONE)); } } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/statistics_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/statistics_screen.h similarity index 100% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/statistics_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/statistics_screen.h diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp similarity index 97% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/status_screen.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp index f61136e396..23ac90107b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp @@ -21,8 +21,8 @@ ****************************************************************************/ #include "../config.h" -#include "screens.h" -#include "screen_data.h" +#include "../screens.h" +#include "../screen_data.h" #ifdef FTDI_STATUS_SCREEN @@ -461,4 +461,14 @@ bool StatusScreen::onTouchEnd(uint8_t tag) { return true; } +void StatusScreen::onMediaInserted() { + if (AT_SCREEN(StatusScreen)) + setStatusMessage(GET_TEXT_F(MSG_MEDIA_INSERTED)); +} + +void StatusScreen::onMediaRemoved() { + if (AT_SCREEN(StatusScreen) || ExtUI::isPrintingFromMedia()) + setStatusMessage(GET_TEXT_F(MSG_MEDIA_REMOVED)); +} + #endif // FTDI_STATUS_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/status_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.h similarity index 96% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/status_screen.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.h index 3a2ba1746c..6033ba1ad9 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/status_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.h @@ -42,4 +42,6 @@ class StatusScreen : public BaseScreen, public CachedScreen { private: - static void move(float inc); + static void move(float mm, int16_t steps); static void runWizard(); + static bool wizardRunning(); public: static void onEntry(); + static void onExit(); static void onRedraw(draw_mode_t); static bool onTouchHeld(uint8_t tag); }; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h index 9de9623e19..0d883d8d02 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h @@ -70,7 +70,7 @@ namespace Language_en { PROGMEM Language_Str MSG_ABOUT_TOUCH_PANEL_2 = WEBSITE_URL; PROGMEM Language_Str MSG_LICENSE = u8"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.\n\nTo view a copy of the GNU General " + "of the License, or (at your option) any later version. To view a copy of the GNU General " "Public License, go to the following location: https://www.gnu.org/licenses."; PROGMEM Language_Str MSG_RUNOUT_1 = u8"Runout 1"; PROGMEM Language_Str MSG_RUNOUT_2 = u8"Runout 2"; @@ -130,7 +130,7 @@ namespace Language_en { PROGMEM Language_Str MSG_EEPROM_RESTORED = u8"Settings restored from backup"; PROGMEM Language_Str MSG_EEPROM_RESET = u8"Settings restored to default"; PROGMEM Language_Str MSG_EEPROM_SAVED = u8"Settings saved!"; - PROGMEM Language_Str MSG_EEPROM_SAVE_PROMPT = u8"Do you wish to save these settings as defaults?"; + PROGMEM Language_Str MSG_EEPROM_SAVE_PROMPT = u8"Settings applied. Save these settings for next power-on?"; PROGMEM Language_Str MSG_EEPROM_RESET_WARNING = u8"Are you sure? Customizations will be lost."; PROGMEM Language_Str MSG_PASSCODE_REJECTED = u8"Wrong passcode!"; @@ -146,7 +146,7 @@ namespace Language_en { PROGMEM Language_Str MSG_AXIS_LEVELING = u8"Axis Leveling"; PROGMEM Language_Str MSG_PROBE_BED = u8"Probe Mesh"; PROGMEM Language_Str MSG_SHOW_MESH = u8"View Mesh"; - PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test"; + PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test (PLA)"; PROGMEM Language_Str MSG_MOVE_Z_TO_TOP = u8"Raise Z to Top"; #if ENABLED(TOUCH_UI_LULZBOT_BIO) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/screen_data.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screen_data.h similarity index 94% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/screen_data.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/screen_data.h index 17e445fe4d..057054a6af 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/screen_data.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screen_data.h @@ -22,7 +22,7 @@ #pragma once -#include "../ftdi_eve_lib/ftdi_eve_lib.h" +#include "ftdi_eve_lib/ftdi_eve_lib.h" // To save RAM, store state information related to a particular screen // in a union. The values should be initialized in the onEntry method. @@ -58,12 +58,12 @@ union screen_data_t { DECL_DATA_IF_INCLUDED(FTDI_BED_MESH_VIEW_SCREEN) DECL_DATA_IF_INCLUDED(FTDI_BED_MESH_EDIT_SCREEN) DECL_DATA_IF_INCLUDED(FTDI_STRESS_TEST_SCREEN) - DECL_DATA_IF_INCLUDED(FTDI_COCOA_PREHEAT_SCREEN) - DECL_DATA_IF_INCLUDED(FTDI_COCOA_LOAD_CHOCOLATE_SCREEN) DECL_DATA_IF_INCLUDED(FTDI_NUDGE_NOZZLE_SCREEN) DECL_DATA_IF_INCLUDED(FTDI_Z_OFFSET_SCREEN) DECL_DATA_IF_INCLUDED(FTDI_BASE_NUMERIC_ADJ_SCREEN) DECL_DATA_IF_INCLUDED(FTDI_ALERT_DIALOG_BOX) + DECL_DATA_IF_INCLUDED(COCOA_PREHEAT_SCREEN) + DECL_DATA_IF_INCLUDED(COCOA_LOAD_CHOCOLATE_SCREEN) }; extern screen_data_t screen_data; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/screens.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.cpp similarity index 90% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/screens.cpp rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.cpp index c3e015d75c..ec627e313b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/screens.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.cpp @@ -20,7 +20,7 @@ * location: . * ****************************************************************************/ -#include "../config.h" +#include "config.h" #if ENABLED(TOUCH_UI_FTDI_EVE) #include "screens.h" @@ -100,15 +100,6 @@ SCREEN_TABLE { DECL_SCREEN_IF_INCLUDED(FTDI_BIO_PRINTING_DIALOG_BOX) DECL_SCREEN_IF_INCLUDED(FTDI_BIO_CONFIRMOME_XYZ) DECL_SCREEN_IF_INCLUDED(FTDI_BIO_CONFIRMOME_E) - DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_STATUS_SCREEN) - DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_MAIN_MENU) - DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_ADVANCED_SETTINGS_MENU) - DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_PREHEAT_MENU) - DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_PREHEAT_SCREEN) - DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN) - DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_LOAD_CHOCOLATE_SCREEN) - DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_MOVE_XYZ_SCREEN) - DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_MOVE_E_SCREEN) DECL_SCREEN_IF_INCLUDED(FTDI_DEVELOPER_MENU) DECL_SCREEN_IF_INCLUDED(FTDI_CONFIRM_ERASE_FLASH_DIALOG_BOX) DECL_SCREEN_IF_INCLUDED(FTDI_WIDGET_DEMO_SCREEN) @@ -116,6 +107,15 @@ SCREEN_TABLE { DECL_SCREEN_IF_INCLUDED(FTDI_STRESS_TEST_SCREEN) DECL_SCREEN_IF_INCLUDED(FTDI_MEDIA_PLAYER_SCREEN) DECL_SCREEN_IF_INCLUDED(FTDI_DISPLAY_TUNING_SCREEN) + DECL_SCREEN_IF_INCLUDED(COCOA_STATUS_SCREEN) + DECL_SCREEN_IF_INCLUDED(COCOA_MAIN_MENU) + DECL_SCREEN_IF_INCLUDED(COCOA_ADVANCED_SETTINGS_MENU) + DECL_SCREEN_IF_INCLUDED(COCOA_PREHEAT_MENU) + DECL_SCREEN_IF_INCLUDED(COCOA_PREHEAT_SCREEN) + DECL_SCREEN_IF_INCLUDED(COCOA_LOAD_CHOCOLATE_SCREEN) + DECL_SCREEN_IF_INCLUDED(COCOA_LEVELING_MENU) + DECL_SCREEN_IF_INCLUDED(COCOA_MOVE_XYZ_SCREEN) + DECL_SCREEN_IF_INCLUDED(COCOA_MOVE_E_SCREEN) }; SCREEN_TABLE_POST diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.h similarity index 68% rename from Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.h rename to Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.h index 95a9ee47ec..fb3e909d2f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.h @@ -1,11 +1,10 @@ -/********************************** - * cocoa_press_unload_cartridge.h * - **********************************/ +/************* + * screens.h * + *************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * - * Written By Marcio Teixeira 2020 - Cocoa Press * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -18,17 +17,34 @@ * GNU General Public License for more details. * * * * To view a copy of the GNU General Public License, go to the following * - * location: . * + * location: . * ****************************************************************************/ #pragma once -#define FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN -#define FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN_CLASS UnloadCartridgeScreen +#include "config.h" -class UnloadCartridgeScreen : public BaseScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - static bool onTouchHeld(uint8_t tag); -}; +#if ENABLED(TOUCH_UI_FTDI_EVE) + +#include "ftdi_eve_lib/ftdi_eve_lib.h" +#include "language/language.h" +#include "theme/theme.h" +#include "generic/string_format.h" + +#ifndef BED_LEVELING_COMMANDS + #define BED_LEVELING_COMMANDS "G29" +#endif + +extern tiny_timer_t refresh_timer; + +#if ENABLED(TOUCH_UI_LULZBOT_BIO) + #include "bioprinter/screens.h" +#elif ENABLED(TOUCH_UI_COCOA_PRESS) + #include "cocoa_press/screens.h" +#elif ENABLED(TOUCH_UI_SYNDAVER_LEVEL) + #include "syndaver_level/screens.h" +#else + #include "generic/screens.h" +#endif + +#endif // TOUCH_UI_FTDI_EVE diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.cpp deleted file mode 100644 index 3428c38bb1..0000000000 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/************************************ - * cocoa_press_unload_cartridge.cpp * - ************************************/ - -/**************************************************************************** - * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * - * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * - * Written By Marcio Teixeira 2020 - Cocoa Press * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * To view a copy of the GNU General Public License, go to the following * - * location: . * - ****************************************************************************/ - -#include "../config.h" -#include "screens.h" -#include "screen_data.h" - -#ifdef FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN - -using namespace ExtUI; -using namespace FTDI; -using namespace Theme; - -#define GRID_COLS 2 -#define GRID_ROWS 6 - -#define TITLE_POS BTN_POS(1,1), BTN_SIZE(2,1) -#define DESCRIPTION_POS BTN_POS(1,2), BTN_SIZE(2,3) -#define CARTRIDGE_OUT_BTN_POS BTN_POS(1,5), BTN_SIZE(1,1) -#define CARTRIDGE_IN_BTN_POS BTN_POS(2,5), BTN_SIZE(1,1) -#define BACK_BTN_POS BTN_POS(1,6), BTN_SIZE(2,1) - -void UnloadCartridgeScreen::onRedraw(draw_mode_t what) { - CommandProcessor cmd; - - if (what & BACKGROUND) { - cmd.cmd(CLEAR_COLOR_RGB(bg_color)) - .cmd(CLEAR(true,true,true)) - .cmd(COLOR_RGB(bg_text_enabled)) - .tag(0) - .font(font_large) - .text(TITLE_POS, GET_TEXT_F(MSG_UNLOAD_CARTRIDGE)); - draw_text_box(cmd, DESCRIPTION_POS, F( - "Press and hold the buttons below to help " - "you unlock the cartridge. After unlocking, " - "press and hold the Cartridge Out button " - "until the cartridge is sticking out of the " - "extruder enough to grip and remove. After " - "removing the cartridge, continue holding the " - "Cartridge Out button until the plunger adapter is " - "visible at the bottom of the extruder." - ), - OPT_CENTERY, font_medium); - } - - if (what & FOREGROUND) { - cmd.font(font_medium) - .colors(normal_btn) - .tag(2).button(CARTRIDGE_OUT_BTN_POS, GET_TEXT_F(MSG_CARTRIDGE_OUT)) - .tag(3).button(CARTRIDGE_IN_BTN_POS, GET_TEXT_F(MSG_CARTRIDGE_IN)) - .colors(action_btn) - .tag(1).button(BACK_BTN_POS, GET_TEXT_F(MSG_BACK)); - } -} - -bool UnloadCartridgeScreen::onTouchEnd(uint8_t tag) { - using namespace ExtUI; - switch (tag) { - case 1: GOTO_PREVIOUS(); break; - } - return true; -} - -bool UnloadCartridgeScreen::onTouchHeld(uint8_t tag) { - if (ExtUI::isMoving()) return false; // Don't allow moves to accumulate - constexpr float increment = 0.25; - MoveAxisScreen::setManualFeedrate(E0, increment); - #define UI_INCREMENT_AXIS(axis) UI_INCREMENT(AxisPosition_mm, axis); - #define UI_DECREMENT_AXIS(axis) UI_DECREMENT(AxisPosition_mm, axis); - switch (tag) { - case 2: UI_DECREMENT_AXIS(E0); break; - case 3: UI_INCREMENT_AXIS(E0); break; - default: return false; - } - #undef UI_DECREMENT_AXIS - #undef UI_INCREMENT_AXIS - return false; -} - -#endif // FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h index 8c0366ebeb..f7cb63125f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h @@ -36,7 +36,7 @@ namespace Theme { .height = 23, }; - constexpr PROGMEM unsigned char Extruder_Icon[] = { + constexpr PROGMEM unsigned char Extruder_Icon[69] = { 0x3F, 0xFF, 0xFC, 0x7F, 0xFF, 0xFE, 0xC0, 0x00, 0x03, @@ -68,12 +68,12 @@ namespace Theme { .filter = BILINEAR, .wrapx = BORDER, .wrapy = BORDER, - .RAMG_offset = 8100, + .RAMG_offset = 8069, .width = 32, .height = 23, }; - constexpr PROGMEM unsigned char Bed_Heat_Icon[] = { + constexpr PROGMEM unsigned char Bed_Heat_Icon[92] = { 0x01, 0x81, 0x81, 0x80, 0x01, 0x81, 0x81, 0x80, 0x00, 0xC0, 0xC0, 0xC0, @@ -105,12 +105,12 @@ namespace Theme { .filter = BILINEAR, .wrapx = BORDER, .wrapy = BORDER, - .RAMG_offset = 8300, + .RAMG_offset = 8161, .width = 32, .height = 32, }; - constexpr PROGMEM unsigned char Fan_Icon[] = { + constexpr PROGMEM unsigned char Fan_Icon[128] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x1F, @@ -151,12 +151,12 @@ namespace Theme { .filter = BILINEAR, .wrapx = BORDER, .wrapy = BORDER, - .RAMG_offset = 9000, + .RAMG_offset = 8289, .width = 50, .height = 20, }; - constexpr PROGMEM unsigned char TD_Icon[] = { + constexpr PROGMEM unsigned char TD_Icon[140] = { 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, // Thumb Drive Widget 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x03, 0x80, @@ -179,5 +179,55 @@ namespace Theme { 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFC, 0x00 }; - constexpr PROGMEM uint32_t UTF8_FONT_OFFSET = 10000; + constexpr PROGMEM bitmap_info_t File_Icon_Info = { + .format = L1, + .linestride = 4, + .filter = BILINEAR, + .wrapx = BORDER, + .wrapy = BORDER, + .RAMG_offset = 8429, + .width = 25, + .height = 32, + }; + + const unsigned char File_Icon[128] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x00, 0x40, 0x03, 0x00, 0x00, + 0x40, 0x02, 0x80, 0x00, 0x40, 0x02, 0x40, 0x00, 0x40, 0x02, 0x20, 0x00, + 0x40, 0x02, 0x10, 0x00, 0x40, 0x02, 0x08, 0x00, 0x40, 0x02, 0x04, 0x00, + 0x40, 0x02, 0x02, 0x00, 0x40, 0x03, 0xFF, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x7F, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + constexpr PROGMEM bitmap_info_t Clock_Icon_Info = { + .format = L1, + .linestride = 4, + .filter = BILINEAR, + .wrapx = BORDER, + .wrapy = BORDER, + .RAMG_offset = 8557, + .width = 32, + .height = 32, + }; + + const unsigned char Clock_Icon[128] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x7E, 0x7E, 0x00, + 0x00, 0xE0, 0x07, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x07, 0x01, 0x00, 0xE0, + 0x0C, 0x01, 0x80, 0x70, 0x0C, 0x01, 0x80, 0x30, 0x18, 0x01, 0x80, 0x18, + 0x30, 0x01, 0x80, 0x08, 0x30, 0x01, 0x80, 0x0C, 0x20, 0x01, 0x80, 0x0C, + 0x60, 0x01, 0x80, 0x04, 0x60, 0x01, 0x80, 0x06, 0x60, 0x01, 0x80, 0x06, + 0x60, 0x01, 0xFF, 0x06, 0x60, 0x01, 0xFF, 0x06, 0x60, 0x00, 0x00, 0x06, + 0x60, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x0C, + 0x30, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x08, 0x18, 0x00, 0x00, 0x18, + 0x0C, 0x00, 0x00, 0x30, 0x0E, 0x00, 0x00, 0x70, 0x07, 0x00, 0x00, 0xE0, + 0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x7F, 0xFE, 0x00, + 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + constexpr PROGMEM uint32_t UTF8_FONT_OFFSET = 10000; }; // namespace Theme diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h index 1649675122..995379fcda 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h @@ -108,6 +108,7 @@ namespace Theme { constexpr uint32_t bed_mesh_lines_rgb = accent_color_6; constexpr uint32_t bed_mesh_shadow_rgb = 0x444444; + #define BED_MESH_POINTS_GRAY #else constexpr uint32_t theme_darkest = gray_color_1; constexpr uint32_t theme_dark = gray_color_2; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/fonts.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/fonts.h index 7cc4e078ad..63ecdfcb3c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/fonts.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/fonts.h @@ -55,7 +55,7 @@ namespace Theme { constexpr int16_t font_small = 27; constexpr int16_t font_medium = 28; constexpr int16_t font_large = 30; - constexpr int16_t font_xlarge = 31; + constexpr int16_t font_xlarge = 30; constexpr float icon_scale = 0.6; #endif #elif defined(TOUCH_UI_320x240) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/sounds.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/sounds.cpp index afbed0cab1..1ed712ded1 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/sounds.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/sounds.cpp @@ -20,7 +20,7 @@ * location: . * ****************************************************************************/ -#include "../compat.h" +#include "../config.h" #if ENABLED(TOUCH_UI_FTDI_EVE) diff --git a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp index 312353f47e..3165190579 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp @@ -93,9 +93,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { has_adjust_z = 1; break; case ID_BABY_STEP_DIST: - if (abs((int)(100 * babystep_dist)) == 1) + if (ABS((int)(100 * babystep_dist)) == 1) babystep_dist = 0.05; - else if (abs((int)(100 * babystep_dist)) == 5) + else if (ABS((int)(100 * babystep_dist)) == 5) babystep_dist = 0.1; else babystep_dist = 0.01; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp b/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp index 55cfe4491d..56b0e8f5ca 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp @@ -33,8 +33,8 @@ extern lv_group_t * g; static lv_obj_t * scr; -static lv_obj_t *button_bind_or_not = NULL, *label_bind_or_not = NULL; -static lv_obj_t *buttonReleaseBind = NULL, *label_ReleaseBind = NULL; +static lv_obj_t *button_bind_or_not = nullptr, *label_bind_or_not = nullptr; +static lv_obj_t *buttonReleaseBind = nullptr, *label_ReleaseBind = nullptr; static lv_obj_t * text_id; static uint8_t unbinding_flag = 0; @@ -61,29 +61,29 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } void lv_draw_cloud_bind() { - lv_obj_t *buttonBack = NULL, *label_Back = NULL; + lv_obj_t *buttonBack = nullptr, *label_Back = nullptr; scr = lv_screen_create(BIND_UI); - button_bind_or_not = lv_btn_create(scr, NULL); + button_bind_or_not = lv_btn_create(scr, nullptr); lv_obj_set_pos(button_bind_or_not, TFT_WIDTH - 130, TFT_HEIGHT - 80 * 3); lv_obj_set_size(button_bind_or_not, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15); - lv_obj_set_event_cb_mks(button_bind_or_not, event_handler, ID_CLOUD_BIND_OR_NOT, NULL, 0); + lv_obj_set_event_cb_mks(button_bind_or_not, event_handler, ID_CLOUD_BIND_OR_NOT, nullptr, 0); lv_btn_set_style(button_bind_or_not, LV_BTN_STYLE_REL, &style_para_value); lv_btn_set_style(button_bind_or_not, LV_BTN_STYLE_PR, &style_para_value); label_bind_or_not = lv_label_create_empty(button_bind_or_not); - buttonReleaseBind = lv_btn_create(scr, NULL); + buttonReleaseBind = lv_btn_create(scr, nullptr); lv_obj_set_pos(buttonReleaseBind, TFT_WIDTH - 130, TFT_HEIGHT - 80 * 2); lv_obj_set_size(buttonReleaseBind, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15); - lv_obj_set_event_cb_mks(buttonReleaseBind, event_handler, ID_CLOUD_RELEASE_BIND, NULL, 0); + lv_obj_set_event_cb_mks(buttonReleaseBind, event_handler, ID_CLOUD_RELEASE_BIND, nullptr, 0); label_ReleaseBind = lv_label_create_empty(buttonReleaseBind); lv_label_set_text(label_ReleaseBind, cloud_menu.unbind); lv_obj_align(label_ReleaseBind, buttonReleaseBind, LV_ALIGN_CENTER, 0, 0); - buttonBack = lv_btn_create(scr, NULL); + buttonBack = lv_btn_create(scr, nullptr); lv_obj_set_pos(buttonBack, TFT_WIDTH - 130, TFT_HEIGHT - 80); lv_obj_set_size(buttonBack, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_CLOUD_BIND_RETURN, NULL, 0); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_CLOUD_BIND_RETURN, nullptr, 0); lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); label_Back = lv_label_create_empty(buttonBack); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp index 6d207b86a7..638d0c5ec3 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp @@ -61,7 +61,7 @@ static lv_obj_t *scr, *tempText1, *filament_bar; extern uint8_t sel_id; extern bool once_flag, gcode_preview_over; extern int upload_result; -extern uint32_t upload_time; +extern uint32_t upload_time_sec; extern uint32_t upload_size; extern bool temps_update_flag; @@ -238,7 +238,7 @@ void lv_draw_dialog(uint8_t type) { lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text } - else if (DIALOG_IS(PAUSE_MESSAGE_PAUSING, PAUSE_MESSAGE_CHANGING, PAUSE_MESSAGE_UNLOAD, PAUSE_MESSAGE_LOAD, PAUSE_MESSAGE_PURGE, PAUSE_MESSAGE_RESUME, PAUSE_MESSAGE_HEATING)) { + else if (DIALOG_IS(PAUSE_MESSAGE_PARKING, PAUSE_MESSAGE_CHANGING, PAUSE_MESSAGE_UNLOAD, PAUSE_MESSAGE_LOAD, PAUSE_MESSAGE_PURGE, PAUSE_MESSAGE_RESUME, PAUSE_MESSAGE_HEATING)) { // nothing to do } else if (DIALOG_IS(WIFI_ENABLE_TIPS)) { @@ -324,7 +324,7 @@ void lv_draw_dialog(uint8_t type) { lv_label_set_text(labelDialog, print_file_dialog_menu.print_finish); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); } - else if (DIALOG_IS(PAUSE_MESSAGE_PAUSING)) { + else if (DIALOG_IS(PAUSE_MESSAGE_PARKING)) { lv_label_set_text(labelDialog, pause_msg_menu.pausing); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); } @@ -406,28 +406,24 @@ void lv_draw_dialog(uint8_t type) { char buf[200]; int _index = 0; - strcpy(buf, DIALOG_UPLOAD_FINISH_EN); + strcpy_P(buf, PSTR(DIALOG_UPLOAD_FINISH_EN)); _index = strlen(buf); - buf[_index] = '\n'; - _index++; - strcat(buf, DIALOG_UPLOAD_SIZE_EN); + buf[_index++] = '\n'; + strcat_P(buf, PSTR(DIALOG_UPLOAD_SIZE_EN)); _index = strlen(buf); - buf[_index] = ':'; - _index++; - sprintf(&buf[_index], " %d KBytes\n", (int)(upload_size / 1024)); + buf[_index++] = ':'; + sprintf_P(&buf[_index], PSTR(" %d KBytes\n"), (int)(upload_size / 1024)); - strcat(buf, DIALOG_UPLOAD_TIME_EN); + strcat_P(buf, PSTR(DIALOG_UPLOAD_TIME_EN)); _index = strlen(buf); - buf[_index] = ':'; - _index++; - sprintf(&buf[_index], " %d s\n", (int)upload_time); + buf[_index++] = ':'; + sprintf_P(&buf[_index], PSTR(" %d s\n"), (int)upload_time_sec); - strcat(buf, DIALOG_UPLOAD_SPEED_EN); + strcat_P(buf, PSTR(DIALOG_UPLOAD_SPEED_EN)); _index = strlen(buf); - buf[_index] = ':'; - _index++; - sprintf(&buf[_index], " %d KBytes/s\n", (int)(upload_size / upload_time / 1024)); + buf[_index++] = ':'; + sprintf_P(&buf[_index], PSTR(" %d KBytes/s\n"), (int)(upload_size / upload_time_sec / 1024)); lv_label_set_text(labelDialog, buf); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); @@ -435,7 +431,7 @@ void lv_draw_dialog(uint8_t type) { } else if (DIALOG_IS(TYPE_UPDATE_ESP_FIRMWARE)) { lv_label_set_text(labelDialog, DIALOG_UPDATE_WIFI_FIRMWARE_EN); - lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); } #endif // MKS_WIFI_MODULE else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT)) { @@ -473,7 +469,7 @@ void lv_draw_dialog(uint8_t type) { #if ENABLED(MKS_WIFI_MODULE) else if (DIALOG_IS(TYPE_UNBIND)) { lv_label_set_text(labelDialog, common_menu.unbind_printer_tips); - lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70); + lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70); } #endif #if HAS_ROTARY_ENCODER @@ -523,7 +519,7 @@ void filament_dialog_handle() { if (uiCfg.filament_load_heat_flg) { const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; - if (abs(diff) < 2 || diff > 0) { + if (ABS(diff) < 2 || diff > 0) { uiCfg.filament_load_heat_flg = false; lv_clear_dialog(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); @@ -539,7 +535,7 @@ void filament_dialog_handle() { if (uiCfg.filament_unload_heat_flg) { const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; - if (abs(diff) < 2 || diff > 0) { + if (ABS(diff) < 2 || diff > 0) { uiCfg.filament_unload_heat_flg = false; lv_clear_dialog(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_dialog.h b/Marlin/src/lcd/extui/mks_ui/draw_dialog.h index e53d48a2b8..7e98a80c0a 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.h @@ -54,7 +54,7 @@ enum { DIALOG_WIFI_ENABLE_TIPS, - DIALOG_PAUSE_MESSAGE_PAUSING, + DIALOG_PAUSE_MESSAGE_PARKING, DIALOG_PAUSE_MESSAGE_CHANGING, DIALOG_PAUSE_MESSAGE_UNLOAD, DIALOG_PAUSE_MESSAGE_WAITING, diff --git a/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp b/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp index 3297b9da27..48ff56253b 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp @@ -25,12 +25,10 @@ #include "draw_ui.h" #include - #include "tft_lvgl_configuration.h" - #include "SPI_TFT.h" -#include "mks_hardware_test.h" #include "../../../inc/MarlinConfig.h" +#include "mks_hardware.h" static lv_obj_t *scr; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp index d070d249f3..2f9009bcdb 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp @@ -89,7 +89,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { disp_extru_amount(); break; case ID_E_STEP: - switch (abs(uiCfg.extruStep)) { + switch (ABS(uiCfg.extruStep)) { case 1: uiCfg.extruStep = 5; break; case 5: uiCfg.extruStep = 10; break; case 10: uiCfg.extruStep = 1; break; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp index a3da638be6..311894825d 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp @@ -50,7 +50,7 @@ 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.wholeDegHotend(uiCfg.extruderIndex)) <= 1 + 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,7 +67,7 @@ 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(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1 + && (ABS(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1 || thermalManager.wholeDegHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp) ) { lv_clear_filament_change(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp b/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp index 6fa5cefef0..81c82dc02d 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp @@ -39,17 +39,17 @@ enum { }; #if ENABLED(MKS_TEST) - extern uint8_t curent_disp_ui; + extern uint8_t current_disp_ui; #endif static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; lv_clear_media_select(); switch (obj->mks_obj_id) { - case ID_T_USB_DISK: card.changeMedia(&card.media_usbFlashDrive); break; - case ID_T_SD_DISK: card.changeMedia(&card.media_sd_spi); break; + case ID_T_USB_DISK: card.changeMedia(&card.media_driver_usbFlash); break; + case ID_T_SD_DISK: card.changeMedia(&card.media_driver_sdcard); break; case ID_T_RETURN: - TERN_(MKS_TEST, curent_disp_ui = 1); + TERN_(MKS_TEST, current_disp_ui = 1); lv_draw_ready_print(); return; } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_more.cpp b/Marlin/src/lcd/extui/mks_ui/draw_more.cpp index d6f1c9ccca..e89e2f3e8a 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_more.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_more.cpp @@ -61,22 +61,22 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_GCODE: lv_clear_more(); lv_draw_gcode(true); break; #if HAS_USER_ITEM(1) - case ID_CUSTOM_1: queue.inject_P(PSTR(USER_GCODE_1)); break; + case ID_CUSTOM_1: queue.inject_P(PSTR(MAIN_MENU_ITEM_1_GCODE)); break; #endif #if HAS_USER_ITEM(2) - case ID_CUSTOM_2: queue.inject_P(PSTR(USER_GCODE_2)); break; + case ID_CUSTOM_2: queue.inject_P(PSTR(MAIN_MENU_ITEM_2_GCODE)); break; #endif #if HAS_USER_ITEM(3) - case ID_CUSTOM_3: queue.inject_P(PSTR(USER_GCODE_3)); break; + case ID_CUSTOM_3: queue.inject_P(PSTR(MAIN_MENU_ITEM_3_GCODE)); break; #endif #if HAS_USER_ITEM(4) - case ID_CUSTOM_4: queue.inject_P(PSTR(USER_GCODE_4)); break; + case ID_CUSTOM_4: queue.inject_P(PSTR(MAIN_MENU_ITEM_4_GCODE)); break; #endif #if HAS_USER_ITEM(5) - case ID_CUSTOM_5: queue.inject_P(PSTR(USER_GCODE_5)); break; + case ID_CUSTOM_5: queue.inject_P(PSTR(MAIN_MENU_ITEM_5_GCODE)); break; #endif #if HAS_USER_ITEM(6) - case ID_CUSTOM_6: queue.inject_P(PSTR(USER_GCODE_6)); break; + case ID_CUSTOM_6: queue.inject_P(PSTR(MAIN_MENU_ITEM_6_GCODE)); break; #endif case ID_M_RETURN: lv_clear_more(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp index 4b413c5c62..7a37dc6a15 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp @@ -75,7 +75,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_M_STEP: - if (abs(10 * (int)uiCfg.move_dist) == 100) + if (ABS(10 * (int)uiCfg.move_dist) == 100) uiCfg.move_dist = 0.1; else uiCfg.move_dist *= 10.0f; @@ -119,10 +119,10 @@ void lv_draw_move_motor() { lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN); // We need to patch the title to leave some space on the right for displaying the status - lv_obj_t * title = lv_obj_get_child_back(scr, NULL); - if (title != NULL) lv_obj_set_width(title, TFT_WIDTH - 101); + lv_obj_t * title = lv_obj_get_child_back(scr, nullptr); + if (title != nullptr) lv_obj_set_width(title, TFT_WIDTH - 101); labelP = lv_label_create(scr, TFT_WIDTH - 100, TITLE_YPOS, "Z:0.0mm"); - if (labelP != NULL) + if (labelP != nullptr) updatePosTask = lv_task_create(refresh_pos, 300, LV_TASK_PRIO_LOWEST, 0); disp_move_dist(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_pause_message.cpp b/Marlin/src/lcd/extui/mks_ui/draw_pause_message.cpp index 608b3366b1..485e010251 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_pause_message.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_pause_message.cpp @@ -31,7 +31,7 @@ void lv_draw_pause_message(const PauseMessage msg) { switch (msg) { - case PAUSE_MESSAGE_PAUSING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_PAUSING); break; + case PAUSE_MESSAGE_PARKING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_PARKING); break; case PAUSE_MESSAGE_CHANGING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_CHANGING); break; case PAUSE_MESSAGE_UNLOAD: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_UNLOAD); break; case PAUSE_MESSAGE_WAITING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_WAITING); break; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp b/Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp index 6b973241fe..5e1dfae5d1 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp @@ -360,7 +360,7 @@ void disp_gcode_icon(uint8_t file_num) { uint32_t lv_open_gcode_file(char *path) { #if ENABLED(SDSUPPORT) uint32_t *ps4; - uint32_t pre_sread_cnt = UINT32_MAX; + uintptr_t pre_sread_cnt = UINTPTR_MAX; char *cur_name; cur_name = strrchr(path, '/'); @@ -370,7 +370,7 @@ uint32_t lv_open_gcode_file(char *path) { ps4 = (uint32_t *)strstr((char *)public_buf, ";simage:"); // Ignore the beginning message of gcode file if (ps4) { - pre_sread_cnt = (uint32_t)ps4 - (uint32_t)((uint32_t *)(&public_buf[0])); + pre_sread_cnt = (uintptr_t)ps4 - (uintptr_t)((uint32_t *)(&public_buf[0])); card.setIndex(pre_sread_cnt); } return pre_sread_cnt; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp index c9172d5887..e3915adeb0 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp @@ -47,14 +47,16 @@ static lv_obj_t *scr; static lv_obj_t *labelExt1, *labelFan, *labelZpos, *labelTime; static lv_obj_t *labelPause, *labelStop, *labelOperat; static lv_obj_t *bar1, *bar1ValueText; -static lv_obj_t *buttonPause, *buttonOperat, *buttonStop, *buttonExt1, *buttonExt2, *buttonBedstate, *buttonFanstate, *buttonZpos; +static lv_obj_t *buttonPause, *buttonOperat, *buttonStop, *buttonExt1, *buttonFanstate, *buttonZpos; -#if ENABLED(HAS_MULTI_EXTRUDER) +#if HAS_MULTI_EXTRUDER static lv_obj_t *labelExt2; + static lv_obj_t *buttonExt2; #endif #if HAS_HEATED_BED static lv_obj_t* labelBed; + static lv_obj_t* buttonBedstate; #endif enum { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp index 18f125b57d..d324d8d7be 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp @@ -27,7 +27,6 @@ #include "draw_tool.h" #include #include "tft_lvgl_configuration.h" -#include "mks_hardware_test.h" #include "draw_ui.h" #include @@ -40,6 +39,7 @@ #include "draw_touch_calibration.h" #endif +#include "mks_hardware.h" #include #define ICON_POS_Y 38 @@ -48,18 +48,20 @@ extern lv_group_t* g; static lv_obj_t *scr; -static lv_obj_t *labelExt1, *labelExt1Target, *labelFan; +static lv_obj_t *buttonExt1, *labelExt1, *buttonFanstate, *labelFan; -#if HAS_MULTI_EXTRUDER - static lv_obj_t *labelExt2, *labelExt2Target; +#if HAS_MULTI_HOTEND + static lv_obj_t *labelExt2; + static lv_obj_t *buttonExt2; #endif #if HAS_HEATED_BED - static lv_obj_t *labelBed, *labelBedTarget; + static lv_obj_t* labelBed; + static lv_obj_t* buttonBedstate; #endif #if ENABLED(MKS_TEST) - uint8_t curent_disp_ui = 0; + uint8_t current_disp_ui = 0; #endif enum { ID_TOOL = 1, ID_SET, ID_PRINT, ID_INFO_EXT, ID_INFO_BED, ID_INFO_FAN }; @@ -104,8 +106,10 @@ void disp_det_error() { lv_obj_t *e1, *e2, *e3, *bed; void mks_disp_test() { char buf[30] = {0}; - sprintf_P(buf, PSTR("e1:%d"), thermalManager.wholeDegHotend(0)); - lv_label_set_text(e1, buf); + #if HAS_HOTEND + sprintf_P(buf, PSTR("e1:%d"), thermalManager.wholeDegHotend(0)); + lv_label_set_text(e1, buf); + #endif #if HAS_MULTI_HOTEND sprintf_P(buf, PSTR("e2:%d"), thermalManager.wholeDegHotend(1)); lv_label_set_text(e2, buf); @@ -136,18 +140,18 @@ void lv_draw_ready_print() { lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } - e1 = lv_label_create_empty(scr); - lv_obj_set_pos(e1, 20, 20); - sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(0)); - lv_label_set_text(e1, buf); - + #if HAS_HOTEND + e1 = lv_label_create_empty(scr); + lv_obj_set_pos(e1, 20, 20); + sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(0)); + lv_label_set_text(e1, buf); + #endif #if HAS_MULTI_HOTEND e2 = lv_label_create_empty(scr); lv_obj_set_pos(e2, 20, 45); - sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(1)); + sprintf_P(buf, PSTR("e2: %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); @@ -178,72 +182,27 @@ void lv_draw_ready_print() { lv_label_set_text(det_info, " "); } else { - lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 180, event_handler, ID_TOOL); - lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 180, event_handler, ID_SET); - lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 180, event_handler, ID_PRINT); + lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 150, event_handler, ID_TOOL); + lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 150, event_handler, ID_SET); + lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 150, event_handler, ID_PRINT); // Monitoring - lv_obj_t *buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT); - #if HAS_MULTI_EXTRUDER - lv_obj_t *buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 163, ICON_POS_Y, event_handler, ID_INFO_EXT); - #if HAS_HEATED_BED - lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 271, ICON_POS_Y, event_handler, ID_INFO_BED); - #endif - #else - #if HAS_HEATED_BED - lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 210, ICON_POS_Y, event_handler, ID_INFO_BED); - #endif + #if HAS_HOTEND + buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT); #endif - - lv_obj_t *buttonFanstate = lv_big_button_create(scr, "F:/bmp_fan_state.bin", " ", 380, ICON_POS_Y, event_handler, ID_INFO_FAN); - - labelExt1 = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); - labelExt1Target = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); - - #if HAS_MULTI_EXTRUDER - labelExt2 = lv_label_create(scr, 163, LABEL_MOD_Y, nullptr); - labelExt2Target = lv_label_create(scr, 163, LABEL_MOD_Y, nullptr); - #if HAS_HEATED_BED - labelBed = lv_label_create(scr, 271, LABEL_MOD_Y, nullptr); - labelBedTarget = lv_label_create(scr, 271, LABEL_MOD_Y, nullptr); - #endif - #else - #if HAS_HEATED_BED - labelBed = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr); - labelBedTarget = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr); - #endif + #if HAS_MULTI_HOTEND + buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 163, ICON_POS_Y, event_handler, ID_INFO_EXT); #endif - - labelFan = lv_label_create(scr, 380, 80, nullptr); - - 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"), thermalManager.degTargetHotend(0)); - lv_label_set_text(labelExt1Target, buf); - lv_obj_align(labelExt1Target, buttonExt1, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); - - #if HAS_MULTI_EXTRUDER - 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"), thermalManager.degTargetHotend(1)); - lv_label_set_text(labelExt2Target, buf); - lv_obj_align(labelExt2Target, buttonExt2, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); - #endif - #if HAS_HEATED_BED - 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"), thermalManager.degTargetBed()); - lv_label_set_text(labelBedTarget, buf); - lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); + buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", TERN(HAS_MULTI_HOTEND, 271, 210), ICON_POS_Y, event_handler, ID_INFO_BED); #endif - sprintf_P(buf, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0)); - lv_label_set_text(labelFan, buf); - lv_obj_align(labelFan, buttonFanstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); + TERN_(HAS_HOTEND, labelExt1 = lv_label_create_empty(scr)); + TERN_(HAS_MULTI_HOTEND, labelExt2 = lv_label_create_empty(scr)); + TERN_(HAS_HEATED_BED, labelBed = lv_label_create_empty(scr)); + TERN_(HAS_FAN, labelFan = lv_label_create_empty(scr)); + + lv_temp_refr(); } #if ENABLED(TOUCH_SCREEN_CALIBRATION) @@ -256,17 +215,25 @@ void lv_draw_ready_print() { } void lv_temp_refr() { + #if HAS_HOTEND + sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0)); + lv_label_set_text(labelExt1, public_buf_l); + lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); + #endif + #if HAS_MULTI_HOTEND + sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1)); + lv_label_set_text(labelExt2, public_buf_l); + lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); + #endif #if HAS_HEATED_BED sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.wholeDegBed(), thermalManager.degTargetBed()); lv_label_set_text(labelBed, public_buf_l); + lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); #endif - - 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, thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1)); - lv_label_set_text(labelExt2, public_buf_l); + #if HAS_FAN + sprintf_P(public_buf_l, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0)); + lv_label_set_text(labelFan, public_buf_l); + lv_obj_align(labelFan, buttonFanstate, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); #endif } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_tool.cpp b/Marlin/src/lcd/extui/mks_ui/draw_tool.cpp index 16c1448b3c..8b9747972d 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_tool.cpp @@ -45,7 +45,7 @@ enum { }; #if ENABLED(MKS_TEST) - extern uint8_t curent_disp_ui; + extern uint8_t current_disp_ui; #endif static void event_handler(lv_obj_t *obj, lv_event_t event) { @@ -75,7 +75,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { lv_draw_more(); break; case ID_T_RETURN: - TERN_(MKS_TEST, curent_disp_ui = 1); + TERN_(MKS_TEST, current_disp_ui = 1); lv_draw_ready_print(); break; } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp b/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp index a4470a4c87..e10a07c6de 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp @@ -34,6 +34,10 @@ static lv_obj_t *scr; static lv_obj_t *status_label; +#if ENABLED(MKS_TEST) + extern uint8_t current_disp_ui; +#endif + static void event_handler(lv_obj_t *obj, lv_event_t event); enum { @@ -93,7 +97,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; switch (obj->mks_obj_id) { case ID_TC_RETURN: - TERN_(MKS_TEST, curent_disp_ui = 1); + TERN_(MKS_TEST, current_disp_ui = 1); lv_clear_touch_calibration_screen(); draw_return_ui(); break; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 727120c183..aae6e62a66 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -30,7 +30,6 @@ #include "pic_manager.h" #include "draw_ui.h" -#include "mks_hardware_test.h" #include @@ -52,6 +51,10 @@ #include "draw_touch_calibration.h" #endif +#if ENABLED(MKS_TEST) + #include "mks_hardware.h" +#endif + CFG_ITMES gCfgItems; UI_CFG uiCfg; DISP_STATE_STACK disp_state_stack; @@ -202,27 +205,27 @@ void ui_cfg_init() { #if ENABLED(MKS_WIFI_MODULE) memset(&wifiPara, 0, sizeof(wifiPara)); memset(&ipPara, 0, sizeof(ipPara)); - strcpy(wifiPara.ap_name, WIFI_AP_NAME); - strcpy(wifiPara.keyCode, WIFI_KEY_CODE); + strcpy_P(wifiPara.ap_name, PSTR(WIFI_AP_NAME)); + strcpy_P(wifiPara.keyCode, PSTR(WIFI_KEY_CODE)); //client - strcpy(ipPara.ip_addr, IP_ADDR); - strcpy(ipPara.mask, IP_MASK); - strcpy(ipPara.gate, IP_GATE); - strcpy(ipPara.dns, IP_DNS); + strcpy_P(ipPara.ip_addr, PSTR(IP_ADDR)); + strcpy_P(ipPara.mask, PSTR(IP_MASK)); + strcpy_P(ipPara.gate, PSTR(IP_GATE)); + strcpy_P(ipPara.dns, PSTR(IP_DNS)); ipPara.dhcp_flag = IP_DHCP_FLAG; //AP - strcpy(ipPara.dhcpd_ip, AP_IP_ADDR); - strcpy(ipPara.dhcpd_mask, AP_IP_MASK); - strcpy(ipPara.dhcpd_gate, AP_IP_GATE); - strcpy(ipPara.dhcpd_dns, AP_IP_DNS); - strcpy(ipPara.start_ip_addr, IP_START_IP); - strcpy(ipPara.end_ip_addr, IP_END_IP); + strcpy_P(ipPara.dhcpd_ip, PSTR(AP_IP_ADDR)); + strcpy_P(ipPara.dhcpd_mask, PSTR(AP_IP_MASK)); + strcpy_P(ipPara.dhcpd_gate, PSTR(AP_IP_GATE)); + strcpy_P(ipPara.dhcpd_dns, PSTR(AP_IP_DNS)); + strcpy_P(ipPara.start_ip_addr, PSTR(IP_START_IP)); + strcpy_P(ipPara.end_ip_addr, PSTR(IP_END_IP)); ipPara.dhcpd_flag = AP_IP_DHCP_FLAG; - strcpy((char*)uiCfg.cloud_hostUrl, "baizhongyun.cn"); + strcpy_P((char*)uiCfg.cloud_hostUrl, PSTR("baizhongyun.cn")); uiCfg.cloud_port = 10086; #endif @@ -557,11 +560,11 @@ char *creat_title_text() { #if HAS_GCODE_PREVIEW - uint32_t gPicturePreviewStart = 0; + uintptr_t gPicturePreviewStart = 0; void preview_gcode_prehandle(char *path) { #if ENABLED(SDSUPPORT) - uint32_t pre_read_cnt = 0; + uintptr_t pre_read_cnt = 0; uint32_t *p1; char *cur_name; @@ -572,7 +575,7 @@ char *creat_title_text() { p1 = (uint32_t *)strstr((char *)public_buf, ";simage:"); if (p1) { - pre_read_cnt = (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0])); + pre_read_cnt = (uintptr_t)p1 - (uintptr_t)((uint32_t *)(&public_buf[0])); To_pre_view = pre_read_cnt; gcode_preview_over = true; @@ -603,7 +606,7 @@ char *creat_title_text() { uint32_t br = card.read(public_buf, 400); uint32_t *p1 = (uint32_t *)strstr((char *)public_buf, ";gimage:"); if (p1) { - gPicturePreviewStart += (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0])); + gPicturePreviewStart += (uintptr_t)p1 - (uintptr_t)((uint32_t *)(&public_buf[0])); break; } else { @@ -1362,7 +1365,10 @@ void print_time_count() { void LV_TASK_HANDLER() { lv_task_handler(); - if (mks_test_flag == 0x1E) mks_hardware_test(); + + #if BOTH(MKS_TEST, SDSUPPORT) + if (mks_test_flag == 0x1E) mks_hardware_test(); + #endif TERN_(HAS_GCODE_PREVIEW, disp_pre_gcode(2, 36)); diff --git a/Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp b/Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp index df48cbec0a..f3c87c03c4 100644 --- a/Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp +++ b/Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp @@ -19,14 +19,14 @@ * along with this program. If not, see . * */ +#ifdef __STM32F1__ + #include "../../../inc/MarlinConfigPre.h" -#if HAS_TFT_LVGL_UI +#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE) #include "tft_lvgl_configuration.h" -#if ENABLED(MKS_WIFI_MODULE) - #include "draw_ui.h" #include "wifiSerial.h" @@ -46,15 +46,15 @@ #define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW); void __irq_usart1() { - if ((USART1_BASE->CR1 & USART_CR1_RXNEIE) && (USART1_BASE->SR & USART_SR_RXNE)) - WRITE(WIFI_IO1_PIN, HIGH); + if ((USART1_BASE->CR1 & USART_CR1_RXNEIE) && (USART1_BASE->SR & USART_SR_RXNE)) + WRITE(WIFI_IO1_PIN, HIGH); - WIFISERIAL.wifi_usart_irq(USART1_BASE); + WIFISERIAL.wifi_usart_irq(USART1_BASE); } #ifdef __cplusplus } /* C-declarations for C++ */ #endif -#endif // MKS_WIFI_MODULE -#endif // HAS_TFT_LVGL_UI +#endif // HAS_TFT_LVGL_UI && MKS_WIFI_MODULE +#endif // __STM32F1__ diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware_test.cpp b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp similarity index 78% rename from Marlin/src/lcd/extui/mks_ui/mks_hardware_test.cpp rename to Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp index bcb3cdb6a2..5cd1a4c525 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware_test.cpp +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp @@ -27,7 +27,6 @@ #include "tft_lvgl_configuration.h" #include "draw_ready_print.h" -#include "mks_hardware_test.h" #include "draw_ui.h" #include "pic_manager.h" #include @@ -36,85 +35,161 @@ #include "../../../module/temperature.h" #include "../../../sd/cardreader.h" -uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det3_sta; -#if PIN_EXISTS(MT_DET_2) - uint8_t mt_det2_sta; -#endif -uint8_t endstopx1_sta, endstopx2_sta, endstopy1_sta, endstopy2_sta, endstopz1_sta, endstopz2_sta; -void test_gpio_readlevel_L() { - #if ENABLED(MKS_TEST) - volatile uint32_t itest; +#if ENABLED(MKS_TEST) + + #include "mks_hardware.h" + #include "../../../module/endstops.h" + + bool pw_det_sta, pw_off_sta, mt_det_sta; + #if PIN_EXISTS(MT_DET_2) + bool mt_det2_sta; + #endif + #if HAS_X_MIN || HAS_X_MAX + bool endstopx1_sta; + #else + constexpr static bool endstopx1_sta = true; + #endif + #if HAS_X2_MIN || HAS_X2_MAX + bool endstopx2_sta; + #else + constexpr static bool endstopx2_sta = true; + #endif + #if HAS_Y_MIN || HAS_Y_MAX + bool endstopy1_sta; + #else + constexpr static bool endstopy1_sta = true; + #endif + #if HAS_Y2_MIN || HAS_Y2_MAX + bool endstopy2_sta; + #else + constexpr static bool endstopy2_sta = true; + #endif + #if HAS_Z_MIN || HAS_Z_MAX + bool endstopz1_sta; + #else + constexpr static bool endstopz1_sta = true; + #endif + #if HAS_Z2_MIN || HAS_Z2_MAX + bool endstopz2_sta; + #else + constexpr static bool endstopz2_sta = true; + #endif + + #define ESTATE(S) (READ(S##_PIN) != S##_ENDSTOP_INVERTING) + + void test_gpio_readlevel_L() { WRITE(WIFI_IO0_PIN, HIGH); - itest = 10000; - while (itest--); - pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 0); - pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 0); - mt_det_sta = (READ(MT_DET_1_PIN) == 0); + delay(10); + pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == LOW); + pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == LOW); + mt_det_sta = (READ(MT_DET_1_PIN) == LOW); #if PIN_EXISTS(MT_DET_2) - mt_det2_sta = (READ(MT_DET_2_PIN) == 0); + mt_det2_sta = (READ(MT_DET_2_PIN) == LOW); #endif - endstopx1_sta = (READ(X_MIN_PIN) == 0); - endstopy1_sta = (READ(Y_MIN_PIN) == 0); - endstopz1_sta = (READ(Z_MIN_PIN) == 0); - endstopz2_sta = (READ(Z_MAX_PIN) == 0); - #endif -} + #if HAS_X_MIN + endstopx1_sta = ESTATE(X_MIN); + #elif HAS_X_MAX + endstopx1_sta = ESTATE(X_MAX); + #endif + #if HAS_X2_MIN + endstopx2_sta = ESTATE(X2_MIN); + #elif HAS_X2_MAX + endstopx2_sta = ESTATE(X2_MAX); + #endif + #if HAS_Y_MIN + endstopy1_sta = ESTATE(Y_MIN); + #elif HAS_Y_MAX + endstopy1_sta = ESTATE(Y_MAX); + #endif + #if HAS_Y2_MIN + endstopy2_sta = ESTATE(Y2_MIN); + #elif HAS_Y2_MAX + endstopy2_sta = ESTATE(Y2_MAX); + #endif + #if HAS_Z_MIN + endstopz1_sta = ESTATE(Z_MIN); + #elif HAS_Z_MAX + endstopz1_sta = ESTATE(Z_MAX); + #endif + #if HAS_Z2_MIN + endstopz2_sta = ESTATE(Z2_MIN); + #elif HAS_Z2_MAX + endstopz2_sta = ESTATE(Z2_MAX); + #endif + } -void test_gpio_readlevel_H() { - #if ENABLED(MKS_TEST) - volatile uint32_t itest; + void test_gpio_readlevel_H() { WRITE(WIFI_IO0_PIN, LOW); - itest = 10000; - while (itest--); - pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 1); - pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 1); - mt_det_sta = (READ(MT_DET_1_PIN) == 1); + delay(10); + pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == HIGH); + pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == HIGH); + mt_det_sta = (READ(MT_DET_1_PIN) == HIGH); #if PIN_EXISTS(MT_DET_2) - mt_det2_sta = (READ(MT_DET_2_PIN) == 1); + mt_det2_sta = (READ(MT_DET_2_PIN) == HIGH); #endif - endstopx1_sta = (READ(X_MIN_PIN) == 1); - endstopy1_sta = (READ(Y_MIN_PIN) == 1); - endstopz1_sta = (READ(Z_MIN_PIN) == 1); - endstopz2_sta = (READ(Z_MAX_PIN) == 1); - #endif -} + #if HAS_X_MIN + endstopx1_sta = !ESTATE(X_MIN); + #elif HAS_X_MAX + endstopx1_sta = !ESTATE(X_MAX); + #endif + #if HAS_X2_MIN + endstopx2_sta = !ESTATE(X2_MIN); + #elif HAS_X2_MAX + endstopx2_sta = !ESTATE(X2_MAX); + #endif + #if HAS_Y_MIN + endstopy1_sta = !ESTATE(Y_MIN); + #elif HAS_Y_MAX + endstopy1_sta = !ESTATE(Y_MAX); + #endif + #if HAS_Y2_MIN + endstopy2_sta = !ESTATE(Y2_MIN); + #elif HAS_Y2_MAX + endstopy2_sta = !ESTATE(Y2_MAX); + #endif + #if HAS_Z_MIN + endstopz1_sta = !ESTATE(Z_MIN); + #elif HAS_Z_MAX + endstopz1_sta = !ESTATE(Z_MAX); + #endif + #if HAS_Z2_MIN + endstopz2_sta = !ESTATE(Z2_MIN); + #elif HAS_Z2_MAX + endstopz2_sta = !ESTATE(Z2_MAX); + #endif + } -void init_test_gpio() { - #ifdef MKS_TEST - SET_INPUT_PULLUP(X_MIN_PIN); - SET_INPUT_PULLUP(Y_MIN_PIN); - SET_INPUT_PULLUP(Z_MIN_PIN); - SET_INPUT_PULLUP(Z_MAX_PIN); + void init_test_gpio() { + endstops.init(); SET_OUTPUT(WIFI_IO0_PIN); - SET_INPUT_PULLUP(MT_DET_1_PIN); + #if PIN_EXISTS(MT_DET_1) + SET_INPUT_PULLUP(MT_DET_1_PIN); + #endif #if PIN_EXISTS(MT_DET_2) SET_INPUT_PULLUP(MT_DET_2_PIN); #endif SET_INPUT_PULLUP(MKS_TEST_POWER_LOSS_PIN); SET_INPUT_PULLUP(MKS_TEST_PS_ON_PIN); - SET_INPUT_PULLUP(SERVO0_PIN); - SET_OUTPUT(X_ENABLE_PIN); - SET_OUTPUT(Y_ENABLE_PIN); - SET_OUTPUT(Z_ENABLE_PIN); - SET_OUTPUT(E0_ENABLE_PIN); - #if !MB(MKS_ROBIN_E3P) - SET_OUTPUT(E1_ENABLE_PIN); + OUT_WRITE(X_ENABLE_PIN, LOW); + #if HAS_Y_AXIS + OUT_WRITE(Y_ENABLE_PIN, LOW); + #endif + #if HAS_Z_AXIS + OUT_WRITE(Z_ENABLE_PIN, LOW); + #endif + #if HAS_EXTRUDERS + OUT_WRITE(E0_ENABLE_PIN, LOW); + #endif + #if HAS_MULTI_EXTRUDER && DISABLED(MKS_HARDWARE_TEST_ONLY_E0) + OUT_WRITE(E1_ENABLE_PIN, LOW); #endif - WRITE(X_ENABLE_PIN, LOW); - WRITE(Y_ENABLE_PIN, LOW); - WRITE(Z_ENABLE_PIN, LOW); - WRITE(E0_ENABLE_PIN, LOW); - #if !MB(MKS_ROBIN_E3P) - WRITE(E1_ENABLE_PIN, LOW); - #endif - - #if MB(MKS_ROBIN_E3P) + #if ENABLED(MKS_HARDWARE_TEST_ONLY_E0) SET_INPUT_PULLUP(PA1); SET_INPUT_PULLUP(PA3); SET_INPUT_PULLUP(PC2); @@ -123,103 +198,112 @@ void init_test_gpio() { SET_INPUT_PULLUP(PE6); SET_INPUT_PULLUP(PE7); #endif - #endif -} + } -void mks_test_beeper() { - #ifdef MKS_TEST + void mks_test_beeper() { WRITE(BEEPER_PIN, HIGH); delay(100); WRITE(BEEPER_PIN, LOW); delay(100); - #endif -} + } -void mks_gpio_test() { - #if ENABLED(MKS_TEST) - init_test_gpio(); + #if ENABLED(SDSUPPORT) - test_gpio_readlevel_L(); - test_gpio_readlevel_H(); - test_gpio_readlevel_L(); - if ((pw_det_sta == 1) - && (pw_off_sta == 1) - && (mt_det_sta == 1) - #if PIN_EXISTS(MT_DET_2) - && (mt_det2_sta == 1) - #endif - #if MB(MKS_ROBIN_E3P) - && (READ(PA1) == 0) - && (READ(PA3) == 0) - && (READ(PC2) == 0) - && (READ(PD8) == 0) - && (READ(PE5) == 0) - && (READ(PE6) == 0) - && (READ(PE7) == 0) - #endif - ) - disp_det_ok(); - else - disp_det_error(); + void mks_gpio_test() { + init_test_gpio(); - if ( (endstopx1_sta == 1) - && (endstopy1_sta == 1) - && (endstopz1_sta == 1) - && (endstopz2_sta == 1) - ) - disp_Limit_ok(); - else - disp_Limit_error(); - #endif -} + test_gpio_readlevel_L(); + test_gpio_readlevel_H(); + test_gpio_readlevel_L(); + if (pw_det_sta && pw_off_sta && mt_det_sta + #if PIN_EXISTS(MT_DET_2) + && mt_det2_sta + #endif + #if ENABLED(MKS_HARDWARE_TEST_ONLY_E0) + && (READ(PA1) == LOW) + && (READ(PA3) == LOW) + && (READ(PC2) == LOW) + && (READ(PD8) == LOW) + && (READ(PE5) == LOW) + && (READ(PE6) == LOW) + && (READ(PE7) == LOW) + #endif + ) + disp_det_ok(); + else + disp_det_error(); -void mks_hardware_test() { - #if ENABLED(MKS_TEST) - if (millis() % 2000 < 1000) { - WRITE(X_DIR_PIN, LOW); - WRITE(Y_DIR_PIN, LOW); - WRITE(Z_DIR_PIN, LOW); - WRITE(E0_DIR_PIN, LOW); - #if !MB(MKS_ROBIN_E3P) - WRITE(E1_DIR_PIN, LOW); - #endif - thermalManager.fan_speed[0] = 255; - #if !MB(MKS_ROBIN_E3P) - WRITE(HEATER_1_PIN, HIGH); // HE1 - #endif - WRITE(HEATER_0_PIN, HIGH); // HE0 - WRITE(HEATER_BED_PIN, HIGH); // HOT-BED - } - else { - WRITE(X_DIR_PIN, HIGH); - WRITE(Y_DIR_PIN, HIGH); - WRITE(Z_DIR_PIN, HIGH); - WRITE(E0_DIR_PIN, HIGH); - #if !MB(MKS_ROBIN_E3P) - WRITE(E1_DIR_PIN, HIGH); - #endif - thermalManager.fan_speed[0] = 0; - #if !MB(MKS_ROBIN_E3P) - WRITE(HEATER_1_PIN, LOW); // HE1 - #endif - WRITE(HEATER_0_PIN, LOW); // HE0 - WRITE(HEATER_BED_PIN, LOW); // HOT-BED + if (endstopx1_sta && endstopy1_sta && endstopz1_sta && endstopz2_sta) + disp_Limit_ok(); + else + disp_Limit_error(); } - if ( (endstopx1_sta == 1) && (endstopx2_sta == 1) - && (endstopy1_sta == 1) && (endstopy2_sta == 1) - && (endstopz1_sta == 1) && (endstopz2_sta == 1) - ) { - // nothing here - } - else { - } + void mks_hardware_test() { + if (millis() % 2000 < 1000) { + thermalManager.fan_speed[0] = 255; + WRITE(X_DIR_PIN, LOW); + #if HAS_Y_AXIS + WRITE(Y_DIR_PIN, LOW); + #endif + #if HAS_Z_AXIS + WRITE(Z_DIR_PIN, LOW); + #endif + #if HAS_EXTRUDERS + WRITE(E0_DIR_PIN, LOW); + #endif + #if HAS_MULTI_EXTRUDER && DISABLED(MKS_HARDWARE_TEST_ONLY_E0) + WRITE(E1_DIR_PIN, LOW); + #endif + #if HAS_MULTI_HOTEND && DISABLED(MKS_HARDWARE_TEST_ONLY_E0) + WRITE(HEATER_1_PIN, HIGH); // HE1 + #endif + #if HAS_HOTEND + WRITE(HEATER_0_PIN, HIGH); // HE0 + #endif + #if HAS_HEATED_BED + WRITE(HEATER_BED_PIN, HIGH); // HOT-BED + #endif + } + else { + thermalManager.fan_speed[0] = 0; + WRITE(X_DIR_PIN, HIGH); + #if HAS_Y_AXIS + WRITE(Y_DIR_PIN, HIGH); + #endif + #if HAS_Y_AXIS + WRITE(Z_DIR_PIN, HIGH); + #endif + #if HAS_EXTRUDERS + WRITE(E0_DIR_PIN, HIGH); + #endif + #if HAS_MULTI_EXTRUDER && DISABLED(MKS_HARDWARE_TEST_ONLY_E0) + WRITE(E1_DIR_PIN, HIGH); + #endif + #if HAS_MULTI_HOTEND && DISABLED(MKS_HARDWARE_TEST_ONLY_E0) + WRITE(HEATER_1_PIN, LOW); // HE1 + #endif + #if HAS_HOTEND + WRITE(HEATER_0_PIN, LOW); // HE0 + #endif + #if HAS_HEATED_BED + WRITE(HEATER_BED_PIN, LOW); // HOT-BED + #endif + } - if (disp_state == PRINT_READY_UI) - mks_disp_test(); + if (endstopx1_sta && endstopx2_sta && endstopy1_sta && endstopy2_sta && endstopz1_sta && endstopz2_sta) { + // nothing here + } + else { + } + + if (disp_state == PRINT_READY_UI) + mks_disp_test(); + } #endif -} + +#endif // MKS_TEST static const uint16_t ASCII_Table_16x24[] PROGMEM = { // Space ' ' @@ -633,10 +717,9 @@ void disp_assets_update_progress(const char *msg) { disp_string(100, 165, buf, 0xFFFF, 0x0000); } -uint8_t mks_test_flag = 0; -const char *MKSTestPath = "MKS_TEST"; - -#if ENABLED(SDSUPPORT) +#if BOTH(MKS_TEST, SDSUPPORT) + uint8_t mks_test_flag = 0; + const char *MKSTestPath = "MKS_TEST"; void mks_test_get() { SdFile dir, root = card.getroot(); if (dir.open(&root, MKSTestPath, O_RDONLY)) diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware_test.h b/Marlin/src/lcd/extui/mks_ui/mks_hardware.h similarity index 79% rename from Marlin/src/lcd/extui/mks_ui/mks_hardware_test.h rename to Marlin/src/lcd/extui/mks_ui/mks_hardware.h index 0e2d8096ba..5313265662 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware_test.h +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.h @@ -21,13 +21,21 @@ */ #pragma once +#include "../../../inc/MarlinConfigPre.h" + #include -void mks_gpio_test(); -void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint16_t bkColor); +// Functions for MKS_TEST +#if BOTH(MKS_TEST, SDSUPPORT) + void mks_hardware_test(); + void mks_test_get(); + void mks_gpio_test(); + extern uint8_t mks_test_flag; +#else + #define mks_test_flag 0 +#endif + +// String display and assets void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor, uint16_t bkColor); -void mks_hardware_test(); void disp_assets_update(); void disp_assets_update_progress(const char *msg); -void mks_test_get(); -extern uint8_t mks_test_flag; diff --git a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp index da7b1929ce..68344e770c 100644 --- a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp @@ -27,11 +27,9 @@ #include "draw_ui.h" #include "pic_manager.h" #include "draw_ready_print.h" -#include "mks_hardware_test.h" - +#include "mks_hardware.h" #include "SPIFlashStorage.h" #include "../../../libs/W25Qxx.h" - #include "../../../sd/cardreader.h" #include "../../../MarlinCore.h" diff --git a/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp b/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp index b618a01957..5e359c4091 100644 --- a/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp +++ b/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp @@ -158,19 +158,12 @@ void filament_pin_setup() { } void filament_check() { - const int FIL_DELAY = 20; + #if ANY_PIN(MT_DET_1, MT_DET_2, MT_DET_3) + const int FIL_DELAY = 20; + #endif #if PIN_EXISTS(MT_DET_1) static int fil_det_count_1 = 0; - if (!READ(MT_DET_1_PIN) && !MT_DET_PIN_INVERTING) - fil_det_count_1++; - else if (READ(MT_DET_1_PIN) && MT_DET_PIN_INVERTING) - fil_det_count_1++; - else if (fil_det_count_1 > 0) - fil_det_count_1--; - - if (!READ(MT_DET_1_PIN) && !MT_DET_PIN_INVERTING) - fil_det_count_1++; - else if (READ(MT_DET_1_PIN) && MT_DET_PIN_INVERTING) + if (READ(MT_DET_1_PIN) == MT_DET_PIN_INVERTING) fil_det_count_1++; else if (fil_det_count_1 > 0) fil_det_count_1--; @@ -178,16 +171,7 @@ void filament_check() { #if PIN_EXISTS(MT_DET_2) static int fil_det_count_2 = 0; - if (!READ(MT_DET_2_PIN) && !MT_DET_PIN_INVERTING) - fil_det_count_2++; - else if (READ(MT_DET_2_PIN) && MT_DET_PIN_INVERTING) - fil_det_count_2++; - else if (fil_det_count_2 > 0) - fil_det_count_2--; - - if (!READ(MT_DET_2_PIN) && !MT_DET_PIN_INVERTING) - fil_det_count_2++; - else if (READ(MT_DET_2_PIN) && MT_DET_PIN_INVERTING) + if (READ(MT_DET_2_PIN) == MT_DET_PIN_INVERTING) fil_det_count_2++; else if (fil_det_count_2 > 0) fil_det_count_2--; @@ -195,16 +179,7 @@ void filament_check() { #if PIN_EXISTS(MT_DET_3) static int fil_det_count_3 = 0; - if (!READ(MT_DET_3_PIN) && !MT_DET_PIN_INVERTING) - fil_det_count_3++; - else if (READ(MT_DET_3_PIN) && MT_DET_PIN_INVERTING) - fil_det_count_3++; - else if (fil_det_count_3 > 0) - fil_det_count_3--; - - if (!READ(MT_DET_3_PIN) && !MT_DET_PIN_INVERTING) - fil_det_count_3++; - else if (READ(MT_DET_3_PIN) && MT_DET_PIN_INVERTING) + if (READ(MT_DET_3_PIN) == MT_DET_PIN_INVERTING) fil_det_count_3++; else if (fil_det_count_3 > 0) fil_det_count_3--; diff --git a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp index 84e3040e84..cfd6db15fd 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -29,7 +29,7 @@ #include "draw_ready_print.h" #include "pic_manager.h" -#include "mks_hardware_test.h" +#include "mks_hardware.h" #include "draw_ui.h" #include "SPIFlashStorage.h" #include @@ -45,6 +45,14 @@ XPT2046 touch; #include "../../../feature/powerloss.h" #endif +#if HAS_SERVOS + #include "../../../module/servo.h" +#endif + +#if EITHER(PROBE_TARE, HAS_Z_SERVO_PROBE) + #include "../../../module/probe.h" +#endif + #if ENABLED(TOUCH_SCREEN_CALIBRATION) #include "../../tft_io/touch_calibration.h" #include "draw_touch_calibration.h" @@ -131,10 +139,9 @@ void tft_lvgl_init() { #if ENABLED(SDSUPPORT) UpdateAssets(); watchdog_refresh(); // LVGL init takes time + TERN_(MKS_TEST, mks_test_get()); #endif - mks_test_get(); - touch.Init(); lv_init(); @@ -193,8 +200,12 @@ void tft_lvgl_init() { filament_pin_setup(); lv_encoder_pin_init(); - TERN_(MKS_WIFI_MODULE, mks_wifi_firmware_update()); - + #if ENABLED(MKS_WIFI_MODULE) + mks_esp_wifi_init(); + mks_wifi_firmware_update(); + #endif + TERN_(HAS_SERVOS, servo_init()); + TERN_(HAS_Z_SERVO_PROBE, probe.servo_probe_init()); bool ready = true; #if ENABLED(POWER_LOSS_RECOVERY) recovery.load(); @@ -207,16 +218,22 @@ void tft_lvgl_init() { uiCfg.print_state = REPRINTING; - strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m)); - card.printLongPath(public_buf_m); - strncpy(list_file.long_name[sel_id], card.longFilename, sizeof(list_file.long_name[0])); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m)); + card.printLongPath(public_buf_m); + strncpy(list_file.long_name[sel_id], card.longFilename, sizeof(list_file.long_name[0])); + #else + strncpy(list_file.long_name[sel_id], recovery.info.sd_filename, sizeof(list_file.long_name[0])); + #endif lv_draw_printing(); } #endif if (ready) lv_draw_ready_print(); - if (mks_test_flag == 0x1E) mks_gpio_test(); + #if BOTH(MKS_TEST, SDSUPPORT) + if (mks_test_flag == 0x1E) mks_gpio_test(); + #endif } void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) { @@ -381,7 +398,7 @@ lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_ // find small image size card.read(public_buf, 512); public_buf[511] = '\0'; - char* eol = strpbrk((const char*)public_buf, "\n\r"); + const char* eol = strpbrk((const char*)public_buf, "\n\r"); small_image_size = (uintptr_t)eol - (uintptr_t)((uint32_t *)(&public_buf[0])) + 1; return LV_FS_RES_OK; } @@ -513,4 +530,10 @@ void lv_encoder_pin_init() { #endif // HAS_ENCODER_ACTION +#if __PLAT_NATIVE_SIM__ + #include + typedef void (*lv_log_print_g_cb_t)(lv_log_level_t level, const char *, uint32_t, const char *); + extern "C" void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb) {} +#endif + #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp index b34942303a..0771a31cb4 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp @@ -58,6 +58,8 @@ pause_msg_def pause_msg_menu; eeprom_def eeprom_menu; media_select_menu_def media_select_menu; +// TODO: Make all strings PSTR and update accessors for the benefit of AVR + machine_common_def machine_menu; void machine_setting_disp() { if (gCfgItems.language == LANG_SIMPLE_CHINESE) { @@ -1093,8 +1095,8 @@ void disp_language_init() { eeprom_menu.read = EEPROM_SETTINGS_READ_CN; eeprom_menu.revert = EEPROM_SETTINGS_REVERT_CN; eeprom_menu.storeTips = EEPROM_STORE_TIPS_CN; - eeprom_menu.readTips = EEPROM_READ_TIPS_CN; - eeprom_menu.revertTips = EEPROM_REVERT_TIPS_CN; + eeprom_menu.readTips = EEPROM_READ_TIPS_CN; + eeprom_menu.revertTips = EEPROM_REVERT_TIPS_CN; break; #if 1 @@ -1337,8 +1339,8 @@ void disp_language_init() { eeprom_menu.read = EEPROM_SETTINGS_READ_T_CN; eeprom_menu.revert = EEPROM_SETTINGS_REVERT_T_CN; eeprom_menu.storeTips = EEPROM_STORE_TIPS_T_CN; - eeprom_menu.readTips = EEPROM_READ_TIPS_T_CN; - eeprom_menu.revertTips = EEPROM_REVERT_TIPS_T_CN; + eeprom_menu.readTips = EEPROM_READ_TIPS_T_CN; + eeprom_menu.revertTips = EEPROM_REVERT_TIPS_T_CN; break; case LANG_ENGLISH: common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_EN; @@ -1571,8 +1573,8 @@ void disp_language_init() { eeprom_menu.read = EEPROM_SETTINGS_READ_EN; eeprom_menu.revert = EEPROM_SETTINGS_REVERT_EN; eeprom_menu.storeTips = EEPROM_STORE_TIPS_EN; - eeprom_menu.readTips = EEPROM_READ_TIPS_EN; - eeprom_menu.revertTips = EEPROM_REVERT_TIPS_EN; + eeprom_menu.readTips = EEPROM_READ_TIPS_EN; + eeprom_menu.revertTips = EEPROM_REVERT_TIPS_EN; break; case LANG_RUSSIAN: common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_RU; @@ -1896,8 +1898,8 @@ void disp_language_init() { eeprom_menu.read = EEPROM_SETTINGS_READ_RU; eeprom_menu.revert = EEPROM_SETTINGS_REVERT_RU; eeprom_menu.storeTips = EEPROM_STORE_TIPS_RU; - eeprom_menu.readTips = EEPROM_READ_TIPS_RU; - eeprom_menu.revertTips = EEPROM_REVERT_TIPS_RU; + eeprom_menu.readTips = EEPROM_READ_TIPS_RU; + eeprom_menu.revertTips = EEPROM_REVERT_TIPS_RU; break; case LANG_SPANISH: common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_SP; @@ -2133,8 +2135,8 @@ void disp_language_init() { eeprom_menu.read = EEPROM_SETTINGS_READ_SP; eeprom_menu.revert = EEPROM_SETTINGS_REVERT_SP; eeprom_menu.storeTips = EEPROM_STORE_TIPS_SP; - eeprom_menu.readTips = EEPROM_READ_TIPS_SP; - eeprom_menu.revertTips = EEPROM_REVERT_TIPS_SP; + eeprom_menu.readTips = EEPROM_READ_TIPS_SP; + eeprom_menu.revertTips = EEPROM_REVERT_TIPS_SP; break; #endif // if 1 @@ -2367,8 +2369,8 @@ void disp_language_init() { eeprom_menu.read = EEPROM_SETTINGS_READ_FR; eeprom_menu.revert = EEPROM_SETTINGS_REVERT_FR; eeprom_menu.storeTips = EEPROM_STORE_TIPS_FR; - eeprom_menu.readTips = EEPROM_READ_TIPS_FR; - eeprom_menu.revertTips = EEPROM_REVERT_TIPS_FR; + eeprom_menu.readTips = EEPROM_READ_TIPS_FR; + eeprom_menu.revertTips = EEPROM_REVERT_TIPS_FR; break; case LANG_ITALY: @@ -2600,8 +2602,8 @@ void disp_language_init() { eeprom_menu.read = EEPROM_SETTINGS_READ_IT; eeprom_menu.revert = EEPROM_SETTINGS_REVERT_IT; eeprom_menu.storeTips = EEPROM_STORE_TIPS_IT; - eeprom_menu.readTips = EEPROM_READ_TIPS_IT; - eeprom_menu.revertTips = EEPROM_REVERT_TIPS_IT; + eeprom_menu.readTips = EEPROM_READ_TIPS_IT; + eeprom_menu.revertTips = EEPROM_REVERT_TIPS_IT; break; #endif // if 1 @@ -2836,8 +2838,8 @@ void disp_language_init() { eeprom_menu.read = EEPROM_SETTINGS_READ_EN; eeprom_menu.revert = EEPROM_SETTINGS_REVERT_EN; eeprom_menu.storeTips = EEPROM_STORE_TIPS_EN; - eeprom_menu.readTips = EEPROM_READ_TIPS_EN; - eeprom_menu.revertTips = EEPROM_REVERT_TIPS_EN; + eeprom_menu.readTips = EEPROM_READ_TIPS_EN; + eeprom_menu.revertTips = EEPROM_REVERT_TIPS_EN; break; } } diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial.h b/Marlin/src/lcd/extui/mks_ui/wifiSerial.h index fcc35a6a65..1a3e9aae9b 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifiSerial.h +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial.h @@ -21,10 +21,6 @@ */ #pragma once -#include "tft_lvgl_configuration.h" - -#if ENABLED(MKS_WIFI_MODULE) - #ifdef SERIAL_PORT_2 #error "SERIAL_PORT_2 must be disabled with TFT_LVGL_UI* and MKS_WIFI_MODULE." #endif @@ -33,70 +29,16 @@ #define WIFI_UPLOAD_BAUDRATE 1958400 #define USART_SAFE_INSERT -#define WIFI_RX_BUF_SIZE (1024+1) +#define WIFI_RX_BUF_SIZE (1024) +#define WIFI_TX_BUF_SIZE (64) -#include -#include -#include -#include -#include -#include +#include "tft_lvgl_configuration.h" -#define DEFINE_WFSERIAL(name, n)\ - WifiSerial name(USART##n, \ - BOARD_USART##n##_TX_PIN, \ - BOARD_USART##n##_RX_PIN) - -class WifiSerial { - public: - uint8 wifiRxBuf[WIFI_RX_BUF_SIZE]; - - public: - WifiSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin); - - /* Set up/tear down */ - void begin(uint32 baud); - void begin(uint32 baud,uint8_t config); - void end(); - int available(); - int read(); - int write(uint8_t); - inline void wifi_usart_irq(usart_reg_map *regs) { - /* Handling RXNEIE and TXEIE interrupts. - * RXNE signifies availability of a byte in DR. - * - * See table 198 (sec 27.4, p809) in STM document RM0008 rev 15. - * We enable RXNEIE. - */ - if ((regs->CR1 & USART_CR1_RXNEIE) && (regs->SR & USART_SR_RXNE)) { - #ifdef USART_SAFE_INSERT - /* If the buffer is full and the user defines USART_SAFE_INSERT, - * ignore new bytes. */ - rb_safe_insert(this->usart_device->rb, (uint8)regs->DR); - #else - /* By default, push bytes around in the ring buffer. */ - rb_push_insert(this->usart_device->rb, (uint8)regs->DR); - #endif - } - /* TXE signifies readiness to send a byte to DR. */ - if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) { - if (!rb_is_empty(this->usart_device->wb)) - regs->DR=rb_remove(this->usart_device->wb); - else - regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE - } - } - - int wifi_rb_is_full(); - - struct usart_dev *usart_device; - private: - uint8 tx_pin; - uint8 rx_pin; -}; +#ifdef __STM32F1__ + #include "wifiSerial_STM32F1.h" +#else + #include "wifiSerial_STM32.h" +#endif extern WifiSerial WifiSerial1; - -#define WIFISERIAL WifiSerial1 - -#endif // MKS_WIFI_MODULE +#define WIFISERIAL WifiSerial1 diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp new file mode 100644 index 0000000000..39d8562676 --- /dev/null +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp @@ -0,0 +1,352 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) + +#include "../../../inc/MarlinConfigPre.h" + +#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE) + +#include "tft_lvgl_configuration.h" + +#include "draw_ui.h" +#include "wifiSerial.h" + +WifiSerial WifiSerial1(USART1); + +void WifiSerial::setRx(uint32_t _rx) { _serial.pin_rx = digitalPinToPinName(_rx); } +void WifiSerial::setTx(uint32_t _tx) { _serial.pin_tx = digitalPinToPinName(_tx); } +void WifiSerial::setRx(PinName _rx) { _serial.pin_rx = _rx; } +void WifiSerial::setTx(PinName _tx) { _serial.pin_tx = _tx; } + +void WifiSerial::init(PinName _rx, PinName _tx) { + _serial.pin_rx = (_rx == _tx) ? NC : _rx; + _serial.pin_tx = _tx; + _serial.rx_buff = wifiRxBuf; + _serial.rx_head = 0; + _serial.rx_tail = 0; + _serial.tx_buff = wifiTxBuf; + _serial.tx_head = 0; + _serial.tx_tail = 0; +} + +WifiSerial::WifiSerial(void *peripheral) { + // If PIN_SERIALy_RX is not defined assume half-duplex + _serial.pin_rx = NC; + // If Serial is defined in variant set + // the Rx/Tx pins for com port if defined + #if defined(Serial) && defined(PIN_SERIAL_TX) + if ((void *)this == (void *)&Serial) { + #ifdef PIN_SERIAL_RX + setRx(PIN_SERIAL_RX); + #endif + setTx(PIN_SERIAL_TX); + } else + #endif + #if defined(PIN_SERIAL1_TX) && defined(USART1_BASE) + if (peripheral == USART1) { + #ifdef PIN_SERIAL1_RX + setRx(PIN_SERIAL1_RX); + #endif + setTx(PIN_SERIAL1_TX); + } else + #endif + #if defined(PIN_SERIAL2_TX) && defined(USART2_BASE) + if (peripheral == USART2) { + #ifdef PIN_SERIAL2_RX + setRx(PIN_SERIAL2_RX); + #endif + setTx(PIN_SERIAL2_TX); + } else + #endif + #if defined(PIN_SERIAL3_TX) && defined(USART3_BASE) + if (peripheral == USART3) { + #ifdef PIN_SERIAL3_RX + setRx(PIN_SERIAL3_RX); + #endif + setTx(PIN_SERIAL3_TX); + } else + #endif + #ifdef PIN_SERIAL4_TX + if (false + #ifdef USART4_BASE + || peripheral == USART4 + #elif defined(UART4_BASE) + || peripheral == UART4 + #endif + ) { + #ifdef PIN_SERIAL4_RX + setRx(PIN_SERIAL4_RX); + #endif + setTx(PIN_SERIAL4_TX); + } else + #endif + #ifdef PIN_SERIAL5_TX + if (false + #ifdef USART5_BASE + || peripheral == USART5 + #elif defined(UART5_BASE) + || peripheral == UART5 + #endif + ) { + #ifdef PIN_SERIAL5_RX + setRx(PIN_SERIAL5_RX); + #endif + setTx(PIN_SERIAL5_TX); + } else + #endif + #if defined(PIN_SERIAL6_TX) && defined(USART6_BASE) + if (peripheral == USART6) { + #ifdef PIN_SERIAL6_RX + setRx(PIN_SERIAL6_RX); + #endif + setTx(PIN_SERIAL6_TX); + } else + #endif + #ifdef PIN_SERIAL7_TX + if (false + #ifdef USART7_BASE + || peripheral == USART7 + #elif defined(UART7_BASE) + || peripheral == UART7 + #endif + ) { + #ifdef PIN_SERIAL7_RX + setRx(PIN_SERIAL7_RX); + #endif + setTx(PIN_SERIAL7_TX); + } else + #endif + #ifdef PIN_SERIAL8_TX + if (false + #ifdef USART8_BASE + || peripheral == USART8 + #elif defined(UART8_BASE) + || peripheral == UART8 + #endif + ) { + #ifdef PIN_SERIAL8_RX + setRx(PIN_SERIAL8_RX); + #endif + setTx(PIN_SERIAL8_TX); + } else + #endif + #if defined(PIN_SERIAL9_TX) && defined(UART9_BASE) + if (peripheral == UART9) { + #ifdef PIN_SERIAL9_RX + setRx(PIN_SERIAL9_RX); + #endif + setTx(PIN_SERIAL9_TX); + } else + #endif + #ifdef PIN_SERIAL10_TX + if (false + #ifdef USART10_BASE + || peripheral == USART10 + #elif defined(UART10_BASE) + || peripheral == UART10 + #endif + ) { + #ifdef PIN_SERIAL10_RX + setRx(PIN_SERIAL10_RX); + #endif + setTx(PIN_SERIAL10_TX); + } else + #endif + #if defined(PIN_SERIALLP1_TX) && defined(LPUART1_BASE) + if (peripheral == LPUART1) { + #ifdef PIN_SERIALLP1_RX + setRx(PIN_SERIALLP1_RX); + #endif + setTx(PIN_SERIALLP1_TX); + } else + #endif + // else get the pins of the first peripheral occurrence in PinMap + { + _serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX); + _serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX); + } + //if (halfDuplex == HALF_DUPLEX_ENABLED) _serial.pin_rx = NC; + init(_serial.pin_rx, _serial.pin_tx); +} + +void WifiSerial::flush() { + // If we have never written a byte, no need to flush. This special + // case is needed since there is no way to force the TXC (transmit + // complete) bit to 1 during initialization + if (!_written) return; + + while ((_serial.tx_head != _serial.tx_tail)) { + // nop, the interrupt handler will free up space for us + } + // If we get here, nothing is queued anymore (DRIE is disabled) and + // the hardware finished tranmission (TXC is set). +} + +bool WifiSerial::isHalfDuplex() const { return _serial.pin_rx == NC; } + +void WifiSerial::enableHalfDuplexRx() { + if (isHalfDuplex()) { + // In half-duplex mode we have to wait for all TX characters to + // be transmitted before we can receive data. + flush(); + if (!_rx_enabled) { + _rx_enabled = true; + uart_enable_rx(&_serial); + } + } +} + +// Actual interrupt handlers ////////////////////////////////////////////////////////////// + +void WifiSerial::_rx_complete_irq(serial_t *obj) { + // No Parity error, read byte and store it in the buffer if there is room + unsigned char c; + + if (uart_getc(obj, &c) == 0) { + + WRITE(WIFI_IO1_PIN, HIGH); + + rx_buffer_index_t i = (unsigned int)(obj->rx_head + 1) % WIFI_RX_BUF_SIZE; + + // if we should be storing the received character into the location + // just before the tail (meaning that the head would advance to the + // current location of the tail), we're about to overflow the buffer + // and so we don't write the character or advance the head. + if (i != obj->rx_tail) { + obj->rx_buff[obj->rx_head] = c; + obj->rx_head = i; + } + } +} + +// Actual interrupt handlers ////////////////////////////////////////////////////////////// + +int WifiSerial::_tx_complete_irq(serial_t *obj) { + // If interrupts are enabled, there must be more data in the output + // buffer. Send the next byte + obj->tx_tail = (obj->tx_tail + 1) % WIFI_TX_BUF_SIZE; + + return (obj->tx_head == obj->tx_tail) ? -1 : 0; +} + +void WifiSerial::begin(unsigned long baud) { begin(baud, SERIAL_8N1); } + +void WifiSerial::begin(unsigned long baud, byte config) { + uint32_t databits = 0, stopbits = 0, parity = 0; + + _baud = baud; + _config = config; + + // Manage databits + switch (config & 0x07) { + case 0x02: databits = 6; break; + case 0x04: databits = 7; break; + case 0x06: databits = 8; break; + default: databits = 0; break; + } + + if ((config & 0x30) == 0x30) { + parity = UART_PARITY_ODD; + databits++; + } + else if ((config & 0x20) == 0x20) { + parity = UART_PARITY_EVEN; + databits++; + } + else + parity = UART_PARITY_NONE; + + stopbits = ((config & 0x08) == 0x08) ? UART_STOPBITS_2 : UART_STOPBITS_1; + + switch (databits) { + #ifdef UART_WORDLENGTH_7B + case 7: databits = UART_WORDLENGTH_7B; break; + #endif + case 8: databits = UART_WORDLENGTH_8B; break; + case 9: databits = UART_WORDLENGTH_9B; break; + default: + case 0: Error_Handler(); break; + } + + uart_init(&_serial, (uint32_t)baud, databits, parity, stopbits); + enableHalfDuplexRx(); + if (baud == WIFI_BAUDRATE) + uart_attach_rx_callback(&_serial, _rx_complete_irq); + else + USART1->CR1 |= USART_CR1_RE; // Preserve word length, etc. Use 'or' to preserve USART_CR1_M_8N1 +} + +void WifiSerial::end() { + // wait for transmission of outgoing data + flush(); + + uart_deinit(&_serial); + + // clear any received data + _serial.rx_head = _serial.rx_tail; +} + +int WifiSerial::available() { + return ((unsigned int)(WIFI_RX_BUF_SIZE + _serial.rx_head - _serial.rx_tail)) % WIFI_RX_BUF_SIZE; +} + +// +// I/O +// +int WifiSerial::read() { + enableHalfDuplexRx(); + // if the head isn't ahead of the tail, we don't have any characters + if (_serial.rx_head == _serial.rx_tail) return -1; + + unsigned char c = _serial.rx_buff[_serial.rx_tail]; + _serial.rx_tail = (rx_buffer_index_t)(_serial.rx_tail + 1) % WIFI_RX_BUF_SIZE; + return c; +} + +int WifiSerial::write(uint8_t c) { + _written = true; + if (isHalfDuplex()) { + if (_rx_enabled) { + _rx_enabled = false; + uart_enable_tx(&_serial); + } + } + + tx_buffer_index_t i = (_serial.tx_head + 1) % WIFI_TX_BUF_SIZE; + + // If the output buffer is full, there's nothing for it other than to + // wait for the interrupt handler to empty it a bit + while (i == _serial.tx_tail) { + // nop, the interrupt handler will free up space for us + } + + _serial.tx_buff[_serial.tx_head] = c; + _serial.tx_head = i; + + if (!serial_tx_active(&_serial)) + uart_attach_tx_callback(&_serial, _tx_complete_irq); + + return 1; +} + +#endif // HAS_TFT_LVGL_UI && MKS_WIFI_MODULE +#endif // !__STM32F1__ diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h new file mode 100644 index 0000000000..87de27c044 --- /dev/null +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h @@ -0,0 +1,63 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include +#include "Stream.h" +#include "uart.h" + +class WifiSerial { + protected: + // Has any byte been written to the UART since begin() + bool _written; + serial_t _serial; + public: + uint8_t wifiRxBuf[WIFI_RX_BUF_SIZE]; + uint8_t wifiTxBuf[WIFI_TX_BUF_SIZE]; + WifiSerial(void *peripheral); + + // Set up / tear down + void begin(uint32_t baud); + void begin(uint32_t baud,uint8_t config); + void end(); + int available(void); + int read(void); + int write(uint8_t); + + // Interrupt handlers + static int _tx_complete_irq(serial_t *obj); + static void _rx_complete_irq(serial_t *obj); + + void flush(void); + bool isHalfDuplex(void) const; + void enableHalfDuplexRx(void); + + private: + void setRx(uint32_t _rx); + void setTx(uint32_t _tx); + void setRx(PinName _rx); + void setTx(PinName _tx); + void init(PinName _rx, PinName _tx); + bool _rx_enabled; + uint8_t _config; + unsigned long _baud; +}; diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial.cpp b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.cpp similarity index 88% rename from Marlin/src/lcd/extui/mks_ui/wifiSerial.cpp rename to Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.cpp index d00fd269d8..75830ce1bd 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifiSerial.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.cpp @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm @@ -19,14 +19,14 @@ * along with this program. If not, see . * */ +#ifdef __STM32F1__ + #include "../../../inc/MarlinConfigPre.h" -#if HAS_TFT_LVGL_UI +#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE) #include "tft_lvgl_configuration.h" -#if ENABLED(MKS_WIFI_MODULE) - #include "draw_ui.h" #include "wifiSerial.h" @@ -59,19 +59,19 @@ WifiSerial::WifiSerial(usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) { if (with_irq) usart_enable(usart_device); else { usart_reg_map *regs = usart_device->regs; - regs->CR1 |= (USART_CR1_TE | USART_CR1_RE); // don't change the word length etc, and 'or' in the pattern not overwrite |USART_CR1_M_8N1); + regs->CR1 |= (USART_CR1_TE | USART_CR1_RE); // Preserve word length, etc. Use 'or' to preserve USART_CR1_M_8N1 regs->CR1 |= USART_CR1_UE; } } #elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4 - #define disable_timer_if_necessary(dev, ch) ((void)0) + #define disable_timer_if_necessary(dev, ch) NOOP static void usart_enable_no_irq(usart_dev *usart_device, bool with_irq) { if (with_irq) usart_enable(usart_device); else { usart_reg_map *regs = usart_device->regs; - regs->CR1 |= (USART_CR1_TE | USART_CR1_RE); // don't change the word length etc, and 'or' in the pattern not overwrite |USART_CR1_M_8N1); + regs->CR1 |= (USART_CR1_TE | USART_CR1_RE); // Preserve word length, etc. Use 'or' to preserve USART_CR1_M_8N1 regs->CR1 |= USART_CR1_UE; } } @@ -137,5 +137,5 @@ int WifiSerial::wifi_rb_is_full() { return rb_is_full(this->usart_device->rb); } -#endif // MKS_WIFI_MODULE -#endif // HAS_TFT_LVGL_UI +#endif // HAS_TFT_LVGL_UI && MKS_WIFI_MODULE +#endif // __STM32F1__ diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.h b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.h new file mode 100644 index 0000000000..6af2f9743b --- /dev/null +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.h @@ -0,0 +1,77 @@ +/** + * 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 +#include +#include +#include +#include +#include + +#define DEFINE_WFSERIAL(name, n) WifiSerial name(USART##n, BOARD_USART##n##_TX_PIN, BOARD_USART##n##_RX_PIN) + +class WifiSerial { + public: + uint8 wifiRxBuf[WIFI_RX_BUF_SIZE]; + + public: + WifiSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin); + + /* Set up/tear down */ + void begin(uint32 baud); + void begin(uint32 baud,uint8_t config); + void end(); + int available(); + int read(); + int write(uint8_t); + inline void wifi_usart_irq(usart_reg_map *regs) { + /* Handling RXNEIE and TXEIE interrupts. + * RXNE signifies availability of a byte in DR. + * + * See table 198 (sec 27.4, p809) in STM document RM0008 rev 15. + * We enable RXNEIE. + */ + if ((regs->CR1 & USART_CR1_RXNEIE) && (regs->SR & USART_SR_RXNE)) { + #ifdef USART_SAFE_INSERT + /* If the buffer is full and the user defines USART_SAFE_INSERT, + * ignore new bytes. */ + rb_safe_insert(this->usart_device->rb, (uint8)regs->DR); + #else + /* By default, push bytes around in the ring buffer. */ + rb_push_insert(this->usart_device->rb, (uint8)regs->DR); + #endif + } + /* TXE signifies readiness to send a byte to DR. */ + if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) { + if (!rb_is_empty(this->usart_device->wb)) + regs->DR=rb_remove(this->usart_device->wb); + else + regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE + } + } + int wifi_rb_is_full(); + struct usart_dev *usart_device; + private: + uint8 tx_pin; + uint8 rx_pin; +}; diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index 52a877031f..1d136a4075 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -51,17 +51,13 @@ #define WIFI_SET() WRITE(WIFI_RESET_PIN, HIGH); #define WIFI_RESET() WRITE(WIFI_RESET_PIN, LOW); -#define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH); -#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW); +#define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH); +#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW); extern uint8_t Explore_Disk (char *path , uint8_t recu_level); extern uint8_t commands_in_queue; extern uint8_t sel_id; - -int usartFifoAvailable(SZ_USART_FIFO *fifo); -int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len); -int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len); extern unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick); volatile SZ_USART_FIFO WifiRxFifo; @@ -79,12 +75,12 @@ extern uint8_t pause_resum; uint8_t wifi_connect_flg = 0; extern volatile uint8_t get_temp_flag; -#define WIFI_MODE 2 +#define WIFI_MODE 2 #define WIFI_AP_MODE 3 int upload_result = 0; -uint32_t upload_time = 0; +uint32_t upload_time_sec = 0; uint32_t upload_size = 0; volatile WIFI_STATE wifi_link_state; @@ -120,29 +116,19 @@ extern bool flash_dma_mode; uint32_t getWifiTick() { return millis(); } uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick) { - if (lastTick <= curTick) - return (curTick - lastTick) * TICK_CYCLE; - else - return (0xFFFFFFFF - lastTick + curTick) * TICK_CYCLE; + return (lastTick <= curTick ? curTick - lastTick : 0xFFFFFFFF - lastTick + curTick) * TICK_CYCLE; } void wifi_delay(int n) { - uint32_t begin = getWifiTick(); - uint32_t end = begin; - while (getWifiTickDiff(begin, end) < (uint32_t)n) { + const uint32_t start = getWifiTick(); + while (getWifiTickDiff(start, getWifiTick()) < (uint32_t)n) watchdog_refresh(); - end = getWifiTick(); - } } void wifi_reset() { - uint32_t start, now; - start = getWifiTick(); - now = start; + uint32_t start = getWifiTick(); WIFI_RESET(); - while (getWifiTickDiff(start, now) < 500) - now = getWifiTick(); - + while (getWifiTickDiff(start, getWifiTick()) < 500) { /* nada */ } WIFI_SET(); } @@ -154,82 +140,83 @@ void mount_file_sys(uint8_t disk_type) { } } -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -void changeFlashMode(const bool dmaMode) { - if (flash_dma_mode != dmaMode) { - flash_dma_mode = dmaMode; - if (!flash_dma_mode) { - dma_disable(DMA1, DMA_CH5); - dma_clear_isr_bits(DMA1, DMA_CH4); - } - } -} - static bool longName2DosName(const char *longName, char *dosName) { - uint8_t i; - for (i = FILENAME_LENGTH; i--;) dosName[i] = '\0'; + uint8_t i = FILENAME_LENGTH; + while (i) dosName[--i] = '\0'; + while (*longName) { uint8_t c = *longName++; if (c == '.') { // For a dot... if (i == 0) return false; strcat_P(dosName, PSTR(".GCO")); - break; + return dosName[0] != '\0'; } else { - if (c < 0x21 || c == 0x7F) return false; // Check size, non-printable characters // Fail for illegal characters PGM_P p = PSTR("|<>^+=?/[];,*\"\\"); - while (const uint8_t b = pgm_read_byte(p++)) if (b == c) return false; - dosName[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name + while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; + if (c < 0x21 || c == 0x7F) return false; // Check size, non-printable characters + dosName[i++] = (c < 'a' || c > 'z') ? (c) : (c + ('A' - 'a')); // Uppercase required for 8.3 name } if (i >= 5) { strcat_P(dosName, PSTR("~1.GCO")); - break; + return dosName[0] != '\0'; } } return dosName[0] != '\0'; // Return true if any name was set } -static int storeRcvData(volatile uint8_t *bufToCpy, int32_t len) { - unsigned char tmpW = wifiDmaRcvFifo.write_cur; +#ifdef __STM32F1__ - if (len > UDISKBUFLEN) return 0; + #include + #include + #include - if (wifiDmaRcvFifo.state[tmpW] == udisk_buf_empty) { - memcpy((unsigned char *) wifiDmaRcvFifo.bufferAddr[tmpW], (uint8_t *)bufToCpy, len); - wifiDmaRcvFifo.state[tmpW] = udisk_buf_full; - wifiDmaRcvFifo.write_cur = (tmpW + 1) % TRANS_RCV_FIFO_BLOCK_NUM; - return 1; + #include + #include + + #include + #include + + #include + #include + #include + #include + + void changeFlashMode(const bool dmaMode) { + if (flash_dma_mode != dmaMode) { + flash_dma_mode = dmaMode; + if (!flash_dma_mode) { + dma_disable(DMA1, DMA_CH5); + dma_clear_isr_bits(DMA1, DMA_CH4); + } + } } - return 0; -} -static void esp_dma_pre() { - dma_channel_reg_map *channel_regs = dma_tube_regs(DMA1, DMA_CH5); + static int storeRcvData(volatile uint8_t *bufToCpy, int32_t len) { + unsigned char tmpW = wifiDmaRcvFifo.write_cur; + if (len > UDISKBUFLEN) return 0; + if (wifiDmaRcvFifo.state[tmpW] == udisk_buf_empty) { + memcpy((unsigned char *) wifiDmaRcvFifo.bufferAddr[tmpW], (uint8_t *)bufToCpy, len); + wifiDmaRcvFifo.state[tmpW] = udisk_buf_full; + wifiDmaRcvFifo.write_cur = (tmpW + 1) % TRANS_RCV_FIFO_BLOCK_NUM; + return 1; + } + return 0; + } - CBI32(channel_regs->CCR, 0); - channel_regs->CMAR = (uint32_t)WIFISERIAL.usart_device->rb->buf; - channel_regs->CNDTR = 0x0000; - channel_regs->CNDTR = UART_RX_BUFFER_SIZE; - DMA1->regs->IFCR = 0xF0000; - SBI32(channel_regs->CCR, 0); -} + static void esp_dma_pre() { + dma_channel_reg_map *channel_regs = dma_tube_regs(DMA1, DMA_CH5); -static void dma_ch5_irq_handle() { + CBI32(channel_regs->CCR, 0); + channel_regs->CMAR = (uint32_t)WIFISERIAL.usart_device->rb->buf; + channel_regs->CNDTR = 0x0000; + channel_regs->CNDTR = UART_RX_BUFFER_SIZE; + DMA1->regs->IFCR = 0xF0000; + SBI32(channel_regs->CCR, 0); + } + + static void dma_ch5_irq_handle() { uint8 status_bits = dma_get_isr_bits(DMA1, DMA_CH5); dma_clear_isr_bits(DMA1, DMA_CH5); if (status_bits & 0x8) { @@ -254,74 +241,329 @@ static void dma_ch5_irq_handle() { // DMA transmit half WIFI_IO1_SET(); } -} - -static void wifi_usart_dma_init() { - dma_init(DMA1); - uint32_t flags = ( DMA_MINC_MODE | DMA_TRNS_CMPLT | DMA_HALF_TRNS | DMA_TRNS_ERR); - dma_xfer_size dma_bit_size = DMA_SIZE_8BITS; - dma_setup_transfer(DMA1, DMA_CH5, &USART1_BASE->DR, dma_bit_size, - (volatile void*)WIFISERIAL.usart_device->rb->buf, dma_bit_size, flags);// Transmit buffer DMA - dma_set_priority(DMA1, DMA_CH5, DMA_PRIORITY_LOW); - dma_attach_interrupt(DMA1, DMA_CH5, &dma_ch5_irq_handle); - - dma_clear_isr_bits(DMA1, DMA_CH5); - dma_set_num_transfers(DMA1, DMA_CH5, UART_RX_BUFFER_SIZE); - - bb_peri_set_bit(&USART1_BASE->CR3, USART_CR3_DMAR_BIT, 1); - dma_enable(DMA1, DMA_CH5); // enable transmit - - for (uint8_t i = 0; i < TRANS_RCV_FIFO_BLOCK_NUM; i++) { - wifiDmaRcvFifo.bufferAddr[i] = &bmp_public_buf[1024 * i]; - wifiDmaRcvFifo.state[i] = udisk_buf_empty; } - memset(wifiDmaRcvFifo.bufferAddr[0], 0, 1024 * TRANS_RCV_FIFO_BLOCK_NUM); - wifiDmaRcvFifo.read_cur = 0; - wifiDmaRcvFifo.write_cur = 0; -} + static void wifi_usart_dma_init() { + dma_init(DMA1); + uint32_t flags = ( DMA_MINC_MODE | DMA_TRNS_CMPLT | DMA_HALF_TRNS | DMA_TRNS_ERR); + dma_xfer_size dma_bit_size = DMA_SIZE_8BITS; + dma_setup_transfer(DMA1, DMA_CH5, &USART1_BASE->DR, dma_bit_size, + (volatile void*)WIFISERIAL.usart_device->rb->buf, dma_bit_size, flags);// Transmit buffer DMA + dma_set_priority(DMA1, DMA_CH5, DMA_PRIORITY_LOW); + dma_attach_interrupt(DMA1, DMA_CH5, &dma_ch5_irq_handle); -void esp_port_begin(uint8_t interrupt) { - WifiRxFifo.uart_read_point = 0; - WifiRxFifo.uart_write_point = 0; + dma_clear_isr_bits(DMA1, DMA_CH5); + dma_set_num_transfers(DMA1, DMA_CH5, UART_RX_BUFFER_SIZE); - #if 1 + bb_peri_set_bit(&USART1_BASE->CR3, USART_CR3_DMAR_BIT, 1); + dma_enable(DMA1, DMA_CH5); // enable transmit + for (uint8_t i = 0; i < TRANS_RCV_FIFO_BLOCK_NUM; i++) { + wifiDmaRcvFifo.bufferAddr[i] = &bmp_public_buf[1024 * i]; + wifiDmaRcvFifo.state[i] = udisk_buf_empty; + } + + memset(wifiDmaRcvFifo.bufferAddr[0], 0, 1024 * TRANS_RCV_FIFO_BLOCK_NUM); + wifiDmaRcvFifo.read_cur = 0; + wifiDmaRcvFifo.write_cur = 0; + } + + void esp_port_begin(uint8_t interrupt) { + WifiRxFifo.uart_read_point = 0; + WifiRxFifo.uart_write_point = 0; #if ENABLED(MKS_WIFI_MODULE) - WIFISERIAL.end(); if (interrupt) { + WIFISERIAL.end(); for (uint16_t i = 0; i < 65535; i++) { /*nada*/ } WIFISERIAL.begin(WIFI_BAUDRATE); millis_t serial_connect_timeout = millis() + 1000UL; while (PENDING(millis(), serial_connect_timeout)) { /*nada*/ } } else { + WIFISERIAL.end(); WIFISERIAL.usart_device->regs->CR1 &= ~USART_CR1_RXNEIE; WIFISERIAL.begin(WIFI_UPLOAD_BAUDRATE); wifi_usart_dma_init(); } #endif + } - #else +#else // !__STM32F1__ - #if MKS_WIFI_MODULE - WIFISERIAL.end(); - for (uint16_t i = 0; i < 65535; i++) { /*nada*/ } - WIFISERIAL.begin(interrupt ? WIFI_BAUDRATE : WIFI_UPLOAD_BAUDRATE); - millis_t serial_connect_timeout = millis() + 1000UL; - while (PENDING(millis(), serial_connect_timeout)) { /*nada*/ } - #endif - if (!interrupt) wifi_usart_dma_init(); + DMA_HandleTypeDef wifiUsartDMArx; + void changeFlashMode(const bool dmaMode) { + if (flash_dma_mode != dmaMode) { + flash_dma_mode = dmaMode; + if (flash_dma_mode == 1) { + } + else { + } + } + } + + #ifdef STM32F1xx + + HAL_StatusTypeDef HAL_DMA_PollForTransferCustomize(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout) { + uint32_t temp; + uint32_t tickstart = 0U; + + if (HAL_DMA_STATE_BUSY != hdma->State) { // No transfer ongoing + hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER; + __HAL_UNLOCK(hdma); + return HAL_ERROR; + } + + // Polling mode not supported in circular mode + if (RESET != (hdma->Instance->CCR & DMA_CCR_CIRC)) { + hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED; + return HAL_ERROR; + } + + // Get the level transfer complete flag + temp = (CompleteLevel == HAL_DMA_FULL_TRANSFER + ? __HAL_DMA_GET_TC_FLAG_INDEX(hdma) // Transfer Complete flag + : __HAL_DMA_GET_HT_FLAG_INDEX(hdma) // Half Transfer Complete flag + ); + + // Get tick + tickstart = HAL_GetTick(); + + while (__HAL_DMA_GET_FLAG(hdma, temp) == RESET) { + if ((__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)) != RESET)) { + __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); // Clear the half transfer complete flag + WIFI_IO1_SET(); + } + + if ((__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)) != RESET)) { + /** + * When a DMA transfer error occurs + * A hardware clear of its EN bits is performed + * Clear all flags + */ + hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << hdma->ChannelIndex); + + SET_BIT(hdma->ErrorCode, HAL_DMA_ERROR_TE); // Update error code + hdma->State= HAL_DMA_STATE_READY; // Change the DMA state + __HAL_UNLOCK(hdma); // Process Unlocked + return HAL_ERROR; + } + + // Check for the Timeout + if (Timeout != HAL_MAX_DELAY && (!Timeout || (HAL_GetTick() - tickstart) > Timeout)) { + SET_BIT(hdma->ErrorCode, HAL_DMA_ERROR_TIMEOUT); // Update error code + hdma->State = HAL_DMA_STATE_READY; // Change the DMA state + __HAL_UNLOCK(hdma); // Process Unlocked + return HAL_ERROR; + } + } + + if (CompleteLevel == HAL_DMA_FULL_TRANSFER) { + // Clear the transfer complete flag + __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)); + + /* The selected Channelx EN bit is cleared (DMA is disabled and + all transfers are complete) */ + hdma->State = HAL_DMA_STATE_READY; + } + else + __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); // Clear the half transfer complete flag + + __HAL_UNLOCK(hdma); // Process unlocked + + return HAL_OK; + } + + #else // !STM32F1xx + + typedef struct { + __IO uint32_t ISR; //!< DMA interrupt status register + __IO uint32_t Reserved0; + __IO uint32_t IFCR; //!< DMA interrupt flag clear register + } MYDMA_Base_Registers; + + HAL_StatusTypeDef HAL_DMA_PollForTransferCustomize(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout) { + HAL_StatusTypeDef status = HAL_OK; + uint32_t mask_cpltlevel; + uint32_t tickstart = HAL_GetTick(); + uint32_t tmpisr; + + MYDMA_Base_Registers *regs; // Calculate DMA base and stream number + + if (HAL_DMA_STATE_BUSY != hdma->State) { // No transfer ongoing + hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER; + __HAL_UNLOCK(hdma); + return HAL_ERROR; + } + + // Polling mode not supported in circular mode and double buffering mode + if ((hdma->Instance->CR & DMA_SxCR_CIRC) != RESET) { + hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED; + return HAL_ERROR; + } + + // Get the level transfer complete flag + mask_cpltlevel = (CompleteLevel == HAL_DMA_FULL_TRANSFER + ? DMA_FLAG_TCIF0_4 << hdma->StreamIndex // Transfer Complete flag + : DMA_FLAG_HTIF0_4 << hdma->StreamIndex // Half Transfer Complete flag + ); + + regs = (MYDMA_Base_Registers *)hdma->StreamBaseAddress; + tmpisr = regs->ISR; + + while (((tmpisr & mask_cpltlevel) == RESET) && ((hdma->ErrorCode & HAL_DMA_ERROR_TE) == RESET)) { + // Check for the Timeout (Not applicable in circular mode) + if (Timeout != HAL_MAX_DELAY) { + if (!Timeout || (HAL_GetTick() - tickstart) > Timeout) { + hdma->ErrorCode = HAL_DMA_ERROR_TIMEOUT; // Update error code + __HAL_UNLOCK(hdma); // Process Unlocked + hdma->State = HAL_DMA_STATE_READY; // Change the DMA state + return HAL_TIMEOUT; + } + } + + tmpisr = regs->ISR; // Get the ISR register value + + if ((tmpisr & (DMA_FLAG_HTIF0_4 << hdma->StreamIndex)) != RESET) { + regs->IFCR = DMA_FLAG_HTIF0_4 << hdma->StreamIndex; // Clear the Direct Mode error flag + WIFI_IO1_SET(); + } + + if ((tmpisr & (DMA_FLAG_TEIF0_4 << hdma->StreamIndex)) != RESET) { + hdma->ErrorCode |= HAL_DMA_ERROR_TE; // Update error code + regs->IFCR = DMA_FLAG_TEIF0_4 << hdma->StreamIndex; // Clear the transfer error flag + } + + if ((tmpisr & (DMA_FLAG_FEIF0_4 << hdma->StreamIndex)) != RESET) { + hdma->ErrorCode |= HAL_DMA_ERROR_FE; // Update error code + regs->IFCR = DMA_FLAG_FEIF0_4 << hdma->StreamIndex; // Clear the FIFO error flag + } + + if ((tmpisr & (DMA_FLAG_DMEIF0_4 << hdma->StreamIndex)) != RESET) { + hdma->ErrorCode |= HAL_DMA_ERROR_DME; // Update error code + regs->IFCR = DMA_FLAG_DMEIF0_4 << hdma->StreamIndex; // Clear the Direct Mode error flag + } + } + + if (hdma->ErrorCode != HAL_DMA_ERROR_NONE && (hdma->ErrorCode & HAL_DMA_ERROR_TE) != RESET) { + HAL_DMA_Abort(hdma); + regs->IFCR = (DMA_FLAG_HTIF0_4 | DMA_FLAG_TCIF0_4) << hdma->StreamIndex; // Clear the half transfer and transfer complete flags + __HAL_UNLOCK(hdma); // Process Unlocked + hdma->State= HAL_DMA_STATE_READY; // Change the DMA state + return HAL_ERROR; + } + + // Get the level transfer complete flag + if (CompleteLevel == HAL_DMA_FULL_TRANSFER) { + regs->IFCR = (DMA_FLAG_HTIF0_4 | DMA_FLAG_TCIF0_4) << hdma->StreamIndex; // Clear the half transfer and transfer complete flags + __HAL_UNLOCK(hdma); // Process Unlocked + hdma->State = HAL_DMA_STATE_READY; + } + else + regs->IFCR = (DMA_FLAG_HTIF0_4) << hdma->StreamIndex; // Clear the half transfer and transfer complete flags + + return status; + } #endif -} + + static void dmaTransmitBegin() { + wifiUsartDMArx.Init.MemInc = DMA_MINC_ENABLE; + if (HAL_DMA_Init((DMA_HandleTypeDef *)&wifiUsartDMArx) != HAL_OK) + Error_Handler(); + + if (HAL_DMA_Start(&wifiUsartDMArx, (uint32_t)&(USART1->DR), (uint32_t)WIFISERIAL.wifiRxBuf, UART_RX_BUFFER_SIZE)) + Error_Handler(); + + USART1->CR1 |= USART_CR1_UE; + + SET_BIT(USART1->CR3, USART_CR3_DMAR); + WIFI_IO1_RESET(); + } + + static int storeRcvData(volatile uint8_t *bufToCpy, int32_t len) { + unsigned char tmpW = wifiDmaRcvFifo.write_cur; + + if (len > UDISKBUFLEN) return 0; + + if (wifiDmaRcvFifo.state[tmpW] == udisk_buf_empty) { + const int timeOut = 2000; //millisecond + dmaTransmitBegin(); + if (HAL_DMA_PollForTransferCustomize(&wifiUsartDMArx, HAL_DMA_FULL_TRANSFER, timeOut) == HAL_OK) { + memcpy((unsigned char *) wifiDmaRcvFifo.bufferAddr[tmpW], (uint8_t *)bufToCpy, len); + wifiDmaRcvFifo.state[tmpW] = udisk_buf_full; + wifiDmaRcvFifo.write_cur = (tmpW + 1) % TRANS_RCV_FIFO_BLOCK_NUM; + return 1; + } + } + return 0; + } + + static void wifi_usart_dma_init() { + #ifdef STM32F1xx + __HAL_RCC_DMA1_CLK_ENABLE(); + wifiUsartDMArx.Instance = DMA1_Channel5; + #else + __HAL_RCC_DMA2_CLK_ENABLE(); + wifiUsartDMArx.Instance = DMA2_Stream2; + wifiUsartDMArx.Init.Channel = DMA_CHANNEL_4; + #endif + wifiUsartDMArx.Init.Direction = DMA_PERIPH_TO_MEMORY; + wifiUsartDMArx.Init.PeriphInc = DMA_PINC_DISABLE; + wifiUsartDMArx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + wifiUsartDMArx.Init.MemDataAlignment = DMA_PDATAALIGN_BYTE; + wifiUsartDMArx.Init.Mode = DMA_NORMAL; + #ifdef STM32F4xx + wifiUsartDMArx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + #endif + wifiUsartDMArx.Init.MemInc = DMA_MINC_ENABLE; + if (HAL_DMA_Init((DMA_HandleTypeDef *)&wifiUsartDMArx) != HAL_OK) + Error_Handler(); + + if (HAL_DMA_Start(&wifiUsartDMArx, (uint32_t)&(USART1->DR), (uint32_t)WIFISERIAL.wifiRxBuf, UART_RX_BUFFER_SIZE)) + Error_Handler(); + + USART1->CR1 |= USART_CR1_UE; + + SET_BIT(USART1->CR3, USART_CR3_DMAR); // Enable Rx DMA Request + + for (uint8_t i = 0; i < TRANS_RCV_FIFO_BLOCK_NUM; i++) { + wifiDmaRcvFifo.bufferAddr[i] = &bmp_public_buf[1024 * i]; + wifiDmaRcvFifo.state[i] = udisk_buf_empty; + } + + memset(wifiDmaRcvFifo.bufferAddr[0], 0, 1024 * TRANS_RCV_FIFO_BLOCK_NUM); + wifiDmaRcvFifo.read_cur = 0; + wifiDmaRcvFifo.write_cur = 0; + } + + void esp_port_begin(uint8_t interrupt) { + WifiRxFifo.uart_read_point = 0; + WifiRxFifo.uart_write_point = 0; + + #if ENABLED(MKS_WIFI_MODULE) + if (interrupt) { + WIFISERIAL.end(); + for (uint16_t i = 0; i < 65535; i++) { /*nada*/ } + WIFISERIAL.begin(WIFI_BAUDRATE); + uint32_t serial_connect_timeout = millis() + 1000UL; + while (PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + } + else { + WIFISERIAL.end(); + USART1->CR1 &= ~USART_CR1_RXNEIE; + WIFISERIAL.begin(WIFI_UPLOAD_BAUDRATE); + wifi_usart_dma_init(); + } + #endif + } + +#endif // !__STM32F1__ #if ENABLED(MKS_WIFI_MODULE) int raw_send_to_wifi(uint8_t *buf, int len) { if (buf == 0 || len <= 0) return 0; - for (int i = 0; i < len; i++) - WIFISERIAL.write(*(buf + i)); + for (int i = 0; i < len; i++) WIFISERIAL.write(*(buf + i)); return len; } @@ -336,9 +578,9 @@ int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len) { uint8_t wifi_ret_tail = 0xFC; if (type == WIFI_PARA_SET) { - int data_offset = 4; - int apLen = strlen((const char *)uiCfg.wifi_name); - int keyLen = strlen((const char *)uiCfg.wifi_key); + int data_offset = 4, + apLen = strlen((const char *)uiCfg.wifi_name), + keyLen = strlen((const char *)uiCfg.wifi_key); ZERO(buf_to_wifi); index_to_wifi = 0; @@ -378,9 +620,9 @@ int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len) { if (buf_to_wifi[index_to_wifi + 3] == '\n') { // mask "wait" "busy" "X:" - if (((buf_to_wifi[4] == 'w') && (buf_to_wifi[5] == 'a') && (buf_to_wifi[6] == 'i') && (buf_to_wifi[7] == 't') ) - || ((buf_to_wifi[4] == 'b') && (buf_to_wifi[5] == 'u') && (buf_to_wifi[6] == 's') && (buf_to_wifi[7] == 'y') ) - || ((buf_to_wifi[4] == 'X') && (buf_to_wifi[5] == ':') ) + if ( ((buf_to_wifi[4] == 'w') && (buf_to_wifi[5] == 'a') && (buf_to_wifi[6] == 'i') && (buf_to_wifi[7] == 't')) + || ((buf_to_wifi[4] == 'b') && (buf_to_wifi[5] == 'u') && (buf_to_wifi[6] == 's') && (buf_to_wifi[7] == 'y')) + || ((buf_to_wifi[4] == 'X') && (buf_to_wifi[5] == ':')) ) { ZERO(buf_to_wifi); index_to_wifi = 0; @@ -458,6 +700,7 @@ int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len) { return 1; } + #define SEND_OK_TO_WIFI send_to_wifi((uint8_t *)"ok\r\n", strlen("ok\r\n")) int send_to_wifi(uint8_t *buf, int len) { return package_to_wifi(WIFI_TRANS_INF, buf, len); } @@ -530,15 +773,15 @@ int write_to_file(char *buf, int len) { return 0; } -#define ESP_PROTOC_HEAD (uint8_t)0xA5 -#define ESP_PROTOC_TAIL (uint8_t)0xFC +#define ESP_PROTOC_HEAD (uint8_t)0xA5 +#define ESP_PROTOC_TAIL (uint8_t)0xFC -#define ESP_TYPE_NET (uint8_t)0x0 -#define ESP_TYPE_GCODE (uint8_t)0x1 +#define ESP_TYPE_NET (uint8_t)0x0 +#define ESP_TYPE_GCODE (uint8_t)0x1 #define ESP_TYPE_FILE_FIRST (uint8_t)0x2 -#define ESP_TYPE_FILE_FRAGMENT (uint8_t)0x3 +#define ESP_TYPE_FILE_FRAGMENT (uint8_t)0x3 -#define ESP_TYPE_WIFI_LIST (uint8_t)0x4 +#define ESP_TYPE_WIFI_LIST (uint8_t)0x4 uint8_t esp_msg_buf[UART_RX_BUFFER_SIZE] = { 0 }; uint16_t esp_msg_index = 0; @@ -651,13 +894,10 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { } break; - case 21: - /*init sd card*/ - SEND_OK_TO_WIFI; - break; + case 21: SEND_OK_TO_WIFI; break; // Init SD card case 23: - /*select the file*/ + // Select the file if (uiCfg.print_state == IDLE) { int index = 0; while (tmpStr[index] == ' ') index++; @@ -747,8 +987,10 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { if (card.isFileOpen()) { //saved_feedrate_percentage = feedrate_percentage; feedrate_percentage = 100; - planner.flow_percentage[0] = 100; - planner.e_factor[0] = planner.flow_percentage[0] * 0.01f; + #if EXTRUDERS + planner.flow_percentage[0] = 100; + planner.e_factor[0] = planner.flow_percentage[0] * 0.01f; + #endif #if EXTRUDERS == 2 planner.flow_percentage[1] = 100; planner.e_factor[1] = planner.flow_percentage[1] * 0.01f; @@ -786,7 +1028,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { break; case 25: - /*pause print file*/ + // Pause print file if (uiCfg.print_state == WORKING) { stop_print_time(); @@ -806,7 +1048,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { break; case 26: - /*stop print file*/ + // Stop print file if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED) || (uiCfg.print_state == REPRINTING)) { stop_print_time(); @@ -823,7 +1065,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { break; case 27: - /*report print rate*/ + // Report print rate if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) { print_rate = uiCfg.totalSend; ZERO(tempBuf); @@ -833,7 +1075,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { break; case 28: - /*begin to transfer file to filesys*/ + // Begin to transfer file to filesys if (uiCfg.print_state == IDLE) { int index = 0; @@ -887,7 +1129,6 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { sprintf_P(tbuf, PSTR("%d /%d"), thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0)); const int tlen = strlen(tbuf); - sprintf_P(outBuf, PSTR("T:%s"), tbuf); outBuf += 2 + tlen; @@ -909,7 +1150,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { #if HAS_MULTI_HOTEND sprintf_P(outBuf, PSTR("%d /%d"), thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1)); #else - strcat_P(outBuf, PSTR("0 /0")); + strcpy_P(outBuf, PSTR("0 /0")); #endif outBuf += 4; @@ -918,17 +1159,11 @@ 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.wholeDegHotend(0), thermalManager.degTargetHotend(0), - #if HAS_HEATED_BED - thermalManager.wholeDegBed(), thermalManager.degTargetBed(), - #else - 0, 0, - #endif + TERN0(HAS_HEATED_BED, thermalManager.wholeDegBed()), + TERN0(HAS_HEATED_BED, thermalManager.degTargetBed()), thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0), - #if HAS_MULTI_HOTEND - thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1) - #else - 0, 0 - #endif + TERN0(HAS_MULTI_HOTEND, thermalManager.wholeDegHotend(1)), + TERN0(HAS_MULTI_HOTEND, thermalManager.degTargetHotend(1)) ); } @@ -977,11 +1212,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { case 998: if (uiCfg.print_state == IDLE) { - int v = atoi((char *)tmpStr); - if (v == 0) - set_cur_file_sys(0); - else if (v == 1) - set_cur_file_sys(1); + const int v = atoi((char *)tmpStr); + if (v == 0 || v == 1) set_cur_file_sys(v); wifi_ret_ack(); } break; @@ -996,18 +1228,14 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcat_P((char *)cmd_line, PSTR("\n")); if (espGcodeFifo.wait_tick > 5) { - uint32_t left; - if (espGcodeFifo.r > espGcodeFifo.w) - left = espGcodeFifo.r - espGcodeFifo.w - 1; - else - left = WIFI_GCODE_BUFFER_SIZE + espGcodeFifo.r - espGcodeFifo.w - 1; + const uint32_t left = espGcodeFifo.r > espGcodeFifo.w + ? espGcodeFifo.r - espGcodeFifo.w - 1 + : WIFI_GCODE_BUFFER_SIZE + espGcodeFifo.r - espGcodeFifo.w - 1; if (left >= strlen((const char *)cmd_line)) { - uint32_t index = 0; - while (index < strlen((const char *)cmd_line)) { + for (uint32_t index = 0; index < strlen((const char *)cmd_line); index++) { espGcodeFifo.Buffer[espGcodeFifo.w] = cmd_line[index] ; espGcodeFifo.w = (espGcodeFifo.w + 1) % WIFI_GCODE_BUFFER_SIZE; - index++; } if (left - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line)) SEND_OK_TO_WIFI; @@ -1022,18 +1250,14 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcat_P((char *)cmd_line, PSTR("\n")); if (espGcodeFifo.wait_tick > 5) { - uint32_t left_g; - if (espGcodeFifo.r > espGcodeFifo.w) - left_g = espGcodeFifo.r - espGcodeFifo.w - 1; - else - left_g = WIFI_GCODE_BUFFER_SIZE + espGcodeFifo.r - espGcodeFifo.w - 1; + const uint32_t left_g = espGcodeFifo.r > espGcodeFifo.w + ? espGcodeFifo.r - espGcodeFifo.w - 1 + : WIFI_GCODE_BUFFER_SIZE + espGcodeFifo.r - espGcodeFifo.w - 1; if (left_g >= strlen((const char *)cmd_line)) { - uint32_t index = 0; - while (index < strlen((const char *)cmd_line)) { + for (uint32_t index = 0; index < strlen((const char *)cmd_line); index++) { espGcodeFifo.Buffer[espGcodeFifo.w] = cmd_line[index] ; espGcodeFifo.w = (espGcodeFifo.w + 1) % WIFI_GCODE_BUFFER_SIZE; - index++; } if (left_g - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line)) SEND_OK_TO_WIFI; @@ -1061,11 +1285,10 @@ static void net_msg_handle(uint8_t * msg, uint16_t msgLen) { if (msgLen <= 0) return; - // ip + // IP address sprintf_P(ipPara.ip_addr, PSTR("%d.%d.%d.%d"), msg[0], msg[1], msg[2], msg[3]); - // port - // connect state + // port connect state switch (msg[6]) { case 0x0A: wifi_link_state = WIFI_CONNECTED; break; case 0x0E: wifi_link_state = WIFI_EXCEPTION; break; @@ -1075,7 +1298,7 @@ static void net_msg_handle(uint8_t * msg, uint16_t msgLen) { // mode wifiPara.mode = msg[7]; - // wifi name + // WiFi name wifiNameLen = msg[8]; wifiKeyLen = msg[9 + wifiNameLen]; if (wifiNameLen < 32) { @@ -1085,7 +1308,7 @@ static void net_msg_handle(uint8_t * msg, uint16_t msgLen) { memset(&wifi_list.wifiConnectedName, 0, sizeof(wifi_list.wifiConnectedName)); memcpy(&wifi_list.wifiConnectedName, &msg[9], wifiNameLen); - // wifi key + // WiFi key if (wifiKeyLen < 64) { ZERO(wifiPara.keyCode); memcpy(wifiPara.keyCode, &msg[10 + wifiNameLen], wifiKeyLen); @@ -1102,7 +1325,7 @@ static void net_msg_handle(uint8_t * msg, uint16_t msgLen) { cloud_para.port = msg[12 + wifiNameLen + wifiKeyLen + hostLen] + (msg[13 + wifiNameLen + wifiKeyLen + hostLen] << 8); } - // id + // ID id_len = msg[14 + wifiNameLen + wifiKeyLen + hostLen]; if (id_len == 20) { ZERO(cloud_para.id); @@ -1125,10 +1348,10 @@ static void net_msg_handle(uint8_t * msg, uint16_t msgLen) { if (cfg_cloud_flag == 1) { if (((cloud_para.state >> 4) != (char)gCfgItems.cloud_enable) || (strncmp(cloud_para.hostUrl, (const char *)uiCfg.cloud_hostUrl, 96) != 0) - || (cloud_para.port != uiCfg.cloud_port)) { - package_to_wifi(WIFI_CLOUD_CFG, (uint8_t *)0, 0); - } - else cfg_cloud_flag = 0; + || (cloud_para.port != uiCfg.cloud_port) + ) package_to_wifi(WIFI_CLOUD_CFG, (uint8_t *)0, 0); + else + cfg_cloud_flag = 0; } } @@ -1366,6 +1589,7 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) { lastFragment = frag; if ((frag & (~FRAG_MASK)) != 0) { + wifiDmaRcvFifo.receiveEspData = false; int res = upload_file.write(public_buf, file_writer.write_index); if (res == -1) { upload_file.close(); @@ -1392,7 +1616,7 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) { ZERO(public_buf); file_writer.write_index = 0; file_writer.tick_end = getWifiTick(); - upload_time = getWifiTickDiff(file_writer.tick_begin, file_writer.tick_end) / 1000; + upload_time_sec = getWifiTickDiff(file_writer.tick_begin, file_writer.tick_end) / 1000; upload_size = gCfgItems.curFilesize; wifi_link_state = WIFI_CONNECTED; upload_result = 3; @@ -1540,9 +1764,16 @@ void stopEspTransfer() { WIFI_IO1_SET(); // disable dma - dma_clear_isr_bits(DMA1, DMA_CH5); - bb_peri_set_bit(&USART1_BASE->CR3, USART_CR3_DMAR_BIT, 0); - dma_disable(DMA1, DMA_CH5); + #ifdef __STM32F1__ + dma_clear_isr_bits(DMA1, DMA_CH5); + bb_peri_set_bit(&USART1_BASE->CR3, USART_CR3_DMAR_BIT, 0); + dma_disable(DMA1, DMA_CH5); + #else + // First, abort any running dma + HAL_DMA_Abort(&wifiUsartDMArx); + // DeInit objects + HAL_DMA_DeInit(&wifiUsartDMArx); + #endif wifi_delay(200); changeFlashMode(true); // Set SPI flash to use DMA mode @@ -1571,6 +1802,9 @@ void wifi_rcv_handle() { } } #else + #ifndef __STM32F1__ + if (wifiDmaRcvFifo.receiveEspData) storeRcvData(WIFISERIAL.wifiRxBuf, UART_RX_BUFFER_SIZE); + #endif len = readWifiFifo(ucStr, UART_RX_BUFFER_SIZE); #endif if (len > 0) { @@ -1582,15 +1816,16 @@ void wifi_rcv_handle() { } getDataF = 1; } - if (esp_state == TRANSFER_STORE) { - if (storeRcvData(WIFISERIAL.usart_device->rb->buf, UART_RX_BUFFER_SIZE)) { - esp_state = TRANSFERING; - esp_dma_pre(); - if (wifiTransError.flag != 0x1) WIFI_IO1_RESET(); + #ifdef __STM32F1__ + if (esp_state == TRANSFER_STORE) { + if (storeRcvData(WIFISERIAL.wifiRxBuf, UART_RX_BUFFER_SIZE)) { + esp_state = TRANSFERING; + esp_dma_pre(); + if (wifiTransError.flag != 0x1) WIFI_IO1_RESET(); + } + else WIFI_IO1_SET(); } - else - WIFI_IO1_SET(); - } + #endif } else { len = readWifiBuf((int8_t *)ucStr, UART_RX_BUFFER_SIZE); @@ -1602,6 +1837,10 @@ void wifi_rcv_handle() { esp_port_begin(0); wifi_delay(10); tick_net_time1 = 0; + #ifndef __STM32F1__ + wifiDmaRcvFifo.receiveEspData = true; + return; + #endif } if (wifiTransError.flag != 0x1) WIFI_IO1_RESET(); getDataF = 1; @@ -1612,9 +1851,8 @@ void wifi_rcv_handle() { } } - if (getDataF == 1) { + if (getDataF == 1) tick_net_time1 = getWifiTick(); - } else { tick_net_time2 = getWifiTick(); @@ -1664,74 +1902,68 @@ void mks_esp_wifi_init() { esp_state = TRANSFER_IDLE; esp_port_begin(1); - + watchdog_refresh(); wifi_reset(); #if 0 if (update_flag == 0) { res = f_open(&esp_upload.uploadFile, ESP_WEB_FIRMWARE_FILE, FA_OPEN_EXISTING | FA_READ); + if (res == FR_OK) { + f_close(&esp_upload.uploadFile); - if (res == FR_OK) { - f_close(&esp_upload.uploadFile); + wifi_delay(2000); - wifi_delay(2000); + if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) return; - if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) { - return; - } + clear_cur_ui(); - clear_cur_ui(); - - draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMWARE); - if (wifi_upload(1) >= 0) { - - f_unlink("1:/MKS_WIFI_CUR"); - f_rename(ESP_WEB_FIRMWARE_FILE,"/MKS_WIFI_CUR"); - } - draw_return_ui(); - update_flag = 1; + draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMWARE); + if (wifi_upload(1) >= 0) { + f_unlink("1:/MKS_WIFI_CUR"); + f_rename(ESP_WEB_FIRMWARE_FILE,"/MKS_WIFI_CUR"); } - + draw_return_ui(); + update_flag = 1; } - if (update_flag == 0) { - res = f_open(&esp_upload.uploadFile, ESP_WEB_FILE, FA_OPEN_EXISTING | FA_READ); - if (res == FR_OK) { - f_close(&esp_upload.uploadFile); + } - wifi_delay(2000); + if (update_flag == 0) { + res = f_open(&esp_upload.uploadFile, ESP_WEB_FILE, FA_OPEN_EXISTING | FA_READ); + if (res == FR_OK) { + f_close(&esp_upload.uploadFile); - if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) { - return; - } + wifi_delay(2000); - clear_cur_ui(); + if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) return; - draw_dialog(DIALOG_TYPE_UPDATE_ESP_DATA); + clear_cur_ui(); - if (wifi_upload(2) >= 0) { + draw_dialog(DIALOG_TYPE_UPDATE_ESP_DATA); - f_unlink("1:/MKS_WEB_CONTROL_CUR"); - f_rename(ESP_WEB_FILE,"/MKS_WEB_CONTROL_CUR"); - } - draw_return_ui(); + if (wifi_upload(2) >= 0) { + f_unlink("1:/MKS_WEB_CONTROL_CUR"); + f_rename(ESP_WEB_FILE,"/MKS_WEB_CONTROL_CUR"); } + draw_return_ui(); } + } #endif + wifiPara.decodeType = WIFI_DECODE_TYPE; wifiPara.baud = 115200; wifi_link_state = WIFI_NOT_CONFIG; } void mks_wifi_firmware_update() { + watchdog_refresh(); card.openFileRead((char *)ESP_FIRMWARE_FILE); if (card.isFileOpen()) { card.closefile(); wifi_delay(2000); - - if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) - return; + watchdog_refresh(); + if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) return; clear_cur_ui(); @@ -1753,12 +1985,6 @@ void mks_wifi_firmware_update() { } } -#define BUF_INC_POINTER(p) ((p + 1 == UART_FIFO_BUFFER_SIZE) ? 0:(p + 1)) - -int usartFifoAvailable(SZ_USART_FIFO *fifo) { - return WIFISERIAL.available(); -} - void get_wifi_commands() { static char wifi_line_buffer[MAX_CMD_SIZE]; static bool wifi_comment_mode = false; @@ -1836,4 +2062,6 @@ int readWifiBuf(int8_t *buf, int32_t len) { return i; } +int usartFifoAvailable(SZ_USART_FIFO *fifo) { return WIFISERIAL.available(); } + #endif // HAS_TFT_LVGL_UI && MKS_WIFI_MODULE diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.h b/Marlin/src/lcd/extui/mks_ui/wifi_module.h index 8f64613417..709d3d1719 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.h +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.h @@ -64,6 +64,7 @@ typedef enum{ #define TRANS_RCV_FIFO_BLOCK_NUM 14 typedef struct { + bool receiveEspData; unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM]; unsigned char *p; UDISK_DATA_BUFFER_STATE state[TRANS_RCV_FIFO_BLOCK_NUM]; @@ -191,6 +192,9 @@ void get_wifi_list_command_send(); void get_wifi_commands(); int readWifiBuf(int8_t *buf, int32_t len); void mks_wifi_firmware_update(); +int usartFifoAvailable(SZ_USART_FIFO *fifo); +int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len); +void esp_port_begin(uint8_t interrupt); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp index 4a8e473a5c..4a5f08edaa 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp @@ -40,7 +40,6 @@ extern SZ_USART_FIFO WifiRxFifo; extern int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len); extern int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len); void esp_port_begin(uint8_t interrupt); -extern int usartFifoAvailable(SZ_USART_FIFO *fifo); void wifi_delay(int n); #define ARRAY_SIZE(a) sizeof(a) / sizeof((a)[0]) @@ -280,7 +279,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t switch (state) { case begin: // expecting frame start c = uploadPort_read(); - if (c == (uint8_t)0xC0) break; + if (c != (uint8_t)0xC0) break; state = header; needBytes = 2; break; @@ -644,10 +643,7 @@ static const uint32_t FirmwareAddress = 0x00000000, WebFilesAddress = 0x00100000 void ResetWiFiForUpload(int begin_or_end) { //#if 0 - uint32_t start, now; - - start = getWifiTick(); - now = start; + uint32_t start = getWifiTick(); if (begin_or_end == 0) { SET_OUTPUT(WIFI_IO0_PIN); @@ -657,7 +653,7 @@ void ResetWiFiForUpload(int begin_or_end) { SET_INPUT_PULLUP(WIFI_IO0_PIN); WIFI_RESET(); - while (getWifiTickDiff(start, now) < 500) now = getWifiTick(); + while (getWifiTickDiff(start, getWifiTick()) < 500) { /* nada */ } WIFI_SET(); //#endif } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index fff31f099b..4ef96251bc 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -47,6 +47,7 @@ #include "../marlinui.h" #include "../../gcode/queue.h" +#include "../../gcode/gcode.h" #include "../../module/motion.h" #include "../../module/planner.h" #include "../../module/probe.h" @@ -101,6 +102,10 @@ #include "../../feature/host_actions.h" #endif +#if M600_PURGE_MORE_RESUMABLE + #include "../../feature/pause.h" +#endif + namespace ExtUI { static struct { uint8_t printer_killed : 1; @@ -177,10 +182,10 @@ namespace ExtUI { #if HAS_HEATED_BED case BED: thermalManager.reset_bed_idle_timer(); return; #endif - #if ENABLED(HAS_HEATED_CHAMBER) + #if HAS_HEATED_CHAMBER case CHAMBER: return; // Chamber has no idle timer #endif - #if ENABLED(HAS_COOLER) + #if HAS_COOLER case COOLER: return; // Cooler has no idle timer #endif default: @@ -240,10 +245,10 @@ namespace ExtUI { bool isHeaterIdle(const heater_t heater) { #if HEATER_IDLE_HANDLER switch (heater) { - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED case BED: return thermalManager.heater_idle[thermalManager.IDLE_INDEX_BED].timed_out; #endif - #if ENABLED(HAS_HEATED_CHAMBER) + #if HAS_HEATED_CHAMBER case CHAMBER: return false; // Chamber has no idle timer #endif default: @@ -263,10 +268,10 @@ namespace ExtUI { celsius_float_t getActualTemp_celsius(const heater_t heater) { switch (heater) { - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degBed()); #endif - #if ENABLED(HAS_HEATED_CHAMBER) + #if HAS_HEATED_CHAMBER case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degChamber()); #endif default: return GET_TEMP_ADJUSTMENT(thermalManager.degHotend(heater - H0)); @@ -279,10 +284,10 @@ namespace ExtUI { celsius_float_t getTargetTemp_celsius(const heater_t heater) { switch (heater) { - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetBed()); #endif - #if ENABLED(HAS_HEATED_CHAMBER) + #if HAS_HEATED_CHAMBER case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetChamber()); #endif default: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetHotend(heater - H0)); @@ -304,7 +309,7 @@ namespace ExtUI { } float getAxisPosition_mm(const axis_t axis) { - return TERN0(JOYSTICK, flags.jogging) ? destination[axis] : current_position[axis]; + return current_position[axis]; } float getAxisPosition_mm(const extruder_t extruder) { @@ -353,14 +358,9 @@ namespace ExtUI { extruder_t getTool(const uint8_t extruder) { switch (extruder) { - case 7: return E7; - case 6: return E6; - case 5: return E5; - case 4: return E4; - case 3: return E3; - case 2: return E2; - case 1: return E1; - default: return E0; + default: + case 0: return E0; case 1: return E1; case 2: return E2; case 3: return E3; + case 4: return E4; case 5: return E5; case 6: return E6; case 7: return E7; } } @@ -372,8 +372,8 @@ namespace ExtUI { switch (axis) { #if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING) case X: return axis_should_home(X_AXIS); - case Y: return axis_should_home(Y_AXIS); - case Z: return axis_should_home(Z_AXIS); + OPTCODE(HAS_Y_AXIS, case Y: return axis_should_home(Y_AXIS)) + OPTCODE(HAS_Z_AXIS, case Z: return axis_should_home(Z_AXIS)) #else case X: case Y: case Z: return true; #endif @@ -385,6 +385,9 @@ namespace ExtUI { return !thermalManager.tooColdToExtrude(extruder - E0); } + GcodeSuite::MarlinBusyState getHostKeepaliveState() { return TERN0(HOST_KEEPALIVE_FEATURE, gcode.busy_state); } + bool getHostKeepaliveIsPaused() { return TERN0(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive_is_paused()); } + #if HAS_SOFTWARE_ENDSTOPS bool getSoftEndstopState() { return soft_endstop._enabled; } void setSoftEndstopState(const bool value) { soft_endstop._enabled = value; } @@ -396,18 +399,27 @@ namespace ExtUI { #if AXIS_IS_TMC(X) case X: return stepperX.getMilliamps(); #endif - #if AXIS_IS_TMC(X2) - case X2: return stepperX2.getMilliamps(); - #endif #if AXIS_IS_TMC(Y) case Y: return stepperY.getMilliamps(); #endif - #if AXIS_IS_TMC(Y2) - case Y2: return stepperY2.getMilliamps(); - #endif #if AXIS_IS_TMC(Z) case Z: return stepperZ.getMilliamps(); #endif + #if AXIS_IS_TMC(I) + case I: return stepperI.getMilliamps(); + #endif + #if AXIS_IS_TMC(J) + case J: return stepperJ.getMilliamps(); + #endif + #if AXIS_IS_TMC(K) + case K: return stepperK.getMilliamps(); + #endif + #if AXIS_IS_TMC(X2) + case X2: return stepperX2.getMilliamps(); + #endif + #if AXIS_IS_TMC(Y2) + case Y2: return stepperY2.getMilliamps(); + #endif #if AXIS_IS_TMC(Z2) case Z2: return stepperZ2.getMilliamps(); #endif @@ -450,18 +462,27 @@ namespace ExtUI { #if AXIS_IS_TMC(X) case X: stepperX.rms_current(constrain(mA, 400, 1500)); break; #endif - #if AXIS_IS_TMC(X2) - case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break; - #endif #if AXIS_IS_TMC(Y) case Y: stepperY.rms_current(constrain(mA, 400, 1500)); break; #endif - #if AXIS_IS_TMC(Y2) - case Y2: stepperY2.rms_current(constrain(mA, 400, 1500)); break; - #endif #if AXIS_IS_TMC(Z) case Z: stepperZ.rms_current(constrain(mA, 400, 1500)); break; #endif + #if AXIS_IS_TMC(I) + case I: stepperI.rms_current(constrain(mA, 400, 1500)); break; + #endif + #if AXIS_IS_TMC(J) + case J: stepperJ.rms_current(constrain(mA, 400, 1500)); break; + #endif + #if AXIS_IS_TMC(K) + case K: stepperK.rms_current(constrain(mA, 400, 1500)); break; + #endif + #if AXIS_IS_TMC(X2) + case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break; + #endif + #if AXIS_IS_TMC(Y2) + case Y2: stepperY2.rms_current(constrain(mA, 400, 1500)); break; + #endif #if AXIS_IS_TMC(Z2) case Z2: stepperZ2.rms_current(constrain(mA, 400, 1500)); break; #endif @@ -501,66 +522,59 @@ namespace ExtUI { int getTMCBumpSensitivity(const axis_t axis) { switch (axis) { - #if ENABLED(X_SENSORLESS) - case X: return stepperX.homing_threshold(); - #endif - #if ENABLED(X2_SENSORLESS) - case X2: return stepperX2.homing_threshold(); - #endif - #if ENABLED(Y_SENSORLESS) - case Y: return stepperY.homing_threshold(); - #endif - #if ENABLED(Y2_SENSORLESS) - case Y2: return stepperY2.homing_threshold(); - #endif - #if ENABLED(Z_SENSORLESS) - case Z: return stepperZ.homing_threshold(); - #endif - #if ENABLED(Z2_SENSORLESS) - case Z2: return stepperZ2.homing_threshold(); - #endif - #if ENABLED(Z3_SENSORLESS) - case Z3: return stepperZ3.homing_threshold(); - #endif - #if ENABLED(Z4_SENSORLESS) - case Z4: return stepperZ4.homing_threshold(); - #endif + OPTCODE(X_SENSORLESS, case X: return stepperX.homing_threshold()) + OPTCODE(Y_SENSORLESS, case Y: return stepperY.homing_threshold()) + OPTCODE(Z_SENSORLESS, case Z: return stepperZ.homing_threshold()) + OPTCODE(I_SENSORLESS, case I: return stepperI.homing_threshold()) + OPTCODE(J_SENSORLESS, case J: return stepperJ.homing_threshold()) + OPTCODE(K_SENSORLESS, case K: return stepperK.homing_threshold()) + OPTCODE(X2_SENSORLESS, case X2: return stepperX2.homing_threshold()) + OPTCODE(Y2_SENSORLESS, case Y2: return stepperY2.homing_threshold()) + OPTCODE(Z2_SENSORLESS, case Z2: return stepperZ2.homing_threshold()) + OPTCODE(Z3_SENSORLESS, case Z3: return stepperZ3.homing_threshold()) + OPTCODE(Z4_SENSORLESS, case Z4: return stepperZ4.homing_threshold()) default: return 0; } } void setTMCBumpSensitivity(const_float_t value, const axis_t axis) { switch (axis) { - #if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS - #if X_SENSORLESS - case X: stepperX.homing_threshold(value); break; - #endif - #if X2_SENSORLESS - case X2: stepperX2.homing_threshold(value); break; - #endif - #if Y_SENSORLESS - case Y: stepperY.homing_threshold(value); break; - #endif - #if Y2_SENSORLESS - case Y2: stepperY2.homing_threshold(value); break; - #endif - #if Z_SENSORLESS - case Z: stepperZ.homing_threshold(value); break; - #endif - #if Z2_SENSORLESS - case Z2: stepperZ2.homing_threshold(value); break; - #endif - #if Z3_SENSORLESS - case Z3: stepperZ3.homing_threshold(value); break; - #endif - #if Z4_SENSORLESS - case Z4: stepperZ4.homing_threshold(value); break; - #endif - #else - UNUSED(value); + #if X_SENSORLESS + case X: stepperX.homing_threshold(value); break; + #endif + #if Y_SENSORLESS + case Y: stepperY.homing_threshold(value); break; + #endif + #if Z_SENSORLESS + case Z: stepperZ.homing_threshold(value); break; + #endif + #if I_SENSORLESS + case I: stepperI.homing_threshold(value); break; + #endif + #if J_SENSORLESS + case J: stepperJ.homing_threshold(value); break; + #endif + #if K_SENSORLESS + case K: stepperK.homing_threshold(value); break; + #endif + #if X2_SENSORLESS + case X2: stepperX2.homing_threshold(value); break; + #endif + #if Y2_SENSORLESS + case Y2: stepperY2.homing_threshold(value); break; + #endif + #if Z2_SENSORLESS + case Z2: stepperZ2.homing_threshold(value); break; + #endif + #if Z3_SENSORLESS + case Z3: stepperZ3.homing_threshold(value); break; + #endif + #if Z4_SENSORLESS + case Z4: stepperZ4.homing_threshold(value); break; #endif default: break; } + UNUSED(value); } #endif @@ -661,9 +675,7 @@ namespace ExtUI { #if HAS_JUNCTION_DEVIATION - float getJunctionDeviation_mm() { - return planner.junction_deviation_mm; - } + float getJunctionDeviation_mm() { return planner.junction_deviation_mm; } void setJunctionDeviation_mm(const_float_t value) { planner.junction_deviation_mm = constrain(value, 0.001, 0.3); @@ -682,7 +694,7 @@ namespace ExtUI { #endif #if PREHEAT_COUNT - uint16_t getMaterial_preset_E(const uint16_t index) { return ui.material_preset[index].hotend_temp; } + uint16_t getMaterial_preset_E(const uint16_t index) { return ui.material_preset[index].hotend_temp; } #if HAS_HEATED_BED uint16_t getMaterial_preset_B(const uint16_t index) { return ui.material_preset[index].bed_temp; } #endif @@ -709,9 +721,13 @@ namespace ExtUI { switch (axis) { #if ENABLED(BABYSTEP_XY) case X: babystep.add_steps(X_AXIS, steps); break; - case Y: babystep.add_steps(Y_AXIS, steps); break; + #if HAS_Y_AXIS + case Y: babystep.add_steps(Y_AXIS, steps); break; + #endif + #endif + #if HAS_Z_AXIS + case Z: babystep.add_steps(Z_AXIS, steps); break; #endif - case Z: babystep.add_steps(Z_AXIS, steps); break; default: return false; }; return true; @@ -750,8 +766,8 @@ namespace ExtUI { hotend_offset[e][axis] += mm; normalizeNozzleOffset(X); - normalizeNozzleOffset(Y); - normalizeNozzleOffset(Z); + TERN_(HAS_Y_AXIS, normalizeNozzleOffset(Y)); + TERN_(HAS_Z_AXIS, normalizeNozzleOffset(Z)); } #else UNUSED(linked_nozzles); @@ -767,6 +783,10 @@ namespace ExtUI { return steps > 0 ? CEIL(steps) : FLOOR(steps); } + float mmFromWholeSteps(int16_t steps, const axis_t axis) { + return steps * planner.steps_to_mm[axis]; + } + #endif // BABYSTEPPING float getZOffset_mm() { @@ -1010,19 +1030,24 @@ namespace ExtUI { TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); } - bool awaitingUserConfirm() { return wait_for_user; } - + bool awaitingUserConfirm() { + return TERN0(HAS_RESUME_CONTINUE, wait_for_user) || getHostKeepaliveIsPaused(); + } void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); } + #if M600_PURGE_MORE_RESUMABLE + void setPauseMenuResponse(PauseMenuResponse response) { pause_menu_response = response; } + #endif + void printFile(const char *filename) { TERN(SDSUPPORT, card.openAndPrintFile(filename), UNUSED(filename)); } bool isPrintingFromMediaPaused() { - return TERN0(SDSUPPORT, isPrintingFromMedia() && printingIsPaused()); + return TERN0(SDSUPPORT, IS_SD_PAUSED()); } - bool isPrintingFromMedia() { return IS_SD_PRINTING(); } + bool isPrintingFromMedia() { return TERN0(SDSUPPORT, IS_SD_PRINTING() || IS_SD_PAUSED()); } bool isPrinting() { return commandsInQueue() || isPrintingFromMedia() || printJobOngoing() || printingIsPaused(); @@ -1032,11 +1057,11 @@ namespace ExtUI { return isPrinting() && (isPrintingFromMediaPaused() || print_job_timer.isPaused()); } - bool isMediaInserted() { return TERN0(SDSUPPORT, IS_SD_INSERTED() && card.isMounted()); } + bool isMediaInserted() { return TERN0(SDSUPPORT, IS_SD_INSERTED()); } - void pausePrint() { ui.pause_print(); } + void pausePrint() { ui.pause_print(); } void resumePrint() { ui.resume_print(); } - void stopPrint() { ui.abort_print(); } + void stopPrint() { ui.abort_print(); } void onUserConfirmRequired_P(PGM_P const pstr) { char msg[strlen_P(pstr) + 1]; diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 5603169626..faa6c8f41a 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -44,6 +44,10 @@ #include "../../inc/MarlinConfig.h" #include "../marlinui.h" +#include "../../gcode/gcode.h" +#if M600_PURGE_MORE_RESUMABLE + #include "../../feature/pause.h" +#endif namespace ExtUI { @@ -53,7 +57,7 @@ namespace ExtUI { static constexpr size_t eeprom_data_size = 48; - enum axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4 }; + enum axis_t : uint8_t { X, Y, Z, I, J, K, X2, Y2, Z2, Z3, Z4 }; enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 }; enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER, COOLER }; enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 }; @@ -78,6 +82,9 @@ namespace ExtUI { void injectCommands(char * const); bool commandsInQueue(); + GcodeSuite::MarlinBusyState getHostKeepaliveState(); + bool getHostKeepaliveIsPaused(); + bool isHeaterIdle(const heater_t); bool isHeaterIdle(const extruder_t); void enableHeater(const heater_t); @@ -125,6 +132,7 @@ namespace ExtUI { float getAxisMaxAcceleration_mm_s2(const extruder_t); feedRate_t getMinFeedrate_mm_s(); feedRate_t getMinTravelFeedrate_mm_s(); + feedRate_t getFeedrate_mm_s(); float getPrintingAcceleration_mm_s2(); float getRetractAcceleration_mm_s2(); float getTravelAcceleration_mm_s2(); @@ -186,6 +194,12 @@ namespace ExtUI { void setHostResponse(const uint8_t); #endif + inline void simulateUserClick() { + #if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) + ui.lcd_clicked = true; + #endif + } + #if ENABLED(PRINTCOUNTER) char* getFailedPrints_str(char buffer[21]); char* getTotalPrints_str(char buffer[21]); @@ -210,14 +224,18 @@ namespace ExtUI { void setFeedrate_mm_s(const feedRate_t); void setMinFeedrate_mm_s(const feedRate_t); void setMinTravelFeedrate_mm_s(const feedRate_t); - void setPrintingAcceleration_mm_s2(const_float_t ); - void setRetractAcceleration_mm_s2(const_float_t ); - void setTravelAcceleration_mm_s2(const_float_t ); - void setFeedrate_percent(const_float_t ); + void setPrintingAcceleration_mm_s2(const_float_t); + void setRetractAcceleration_mm_s2(const_float_t); + void setTravelAcceleration_mm_s2(const_float_t); + void setFeedrate_percent(const_float_t); void setFlow_percent(const int16_t, const extruder_t); bool awaitingUserConfirm(); void setUserConfirmed(); + #if M600_PURGE_MORE_RESUMABLE + void setPauseMenuResponse(PauseMenuResponse); + #endif + #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t); void setLinearAdvance_mm_mm_s(const_float_t, const extruder_t); @@ -225,7 +243,7 @@ namespace ExtUI { #if HAS_JUNCTION_DEVIATION float getJunctionDeviation_mm(); - void setJunctionDeviation_mm(const_float_t ); + void setJunctionDeviation_mm(const_float_t); #else float getAxisMaxJerk_mm_s(const axis_t); float getAxisMaxJerk_mm_s(const extruder_t); @@ -239,6 +257,7 @@ namespace ExtUI { #if ENABLED(BABYSTEPPING) int16_t mmToWholeSteps(const_float_t mm, const axis_t axis); + float mmFromWholeSteps(int16_t steps, const axis_t axis); bool babystepAxis_steps(const int16_t steps, const axis_t axis); void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles); @@ -251,7 +270,7 @@ namespace ExtUI { #endif float getZOffset_mm(); - void setZOffset_mm(const_float_t ); + void setZOffset_mm(const_float_t); #if HAS_BED_PROBE float getProbeOffset_mm(const axis_t); @@ -263,11 +282,11 @@ namespace ExtUI { void setAxisBacklash_mm(const_float_t, const axis_t); float getBacklashCorrection_percent(); - void setBacklashCorrection_percent(const_float_t ); + void setBacklashCorrection_percent(const_float_t); #ifdef BACKLASH_SMOOTHING_MM float getBacklashSmoothing_mm(); - void setBacklashSmoothing_mm(const_float_t ); + void setBacklashSmoothing_mm(const_float_t); #endif #endif @@ -279,7 +298,7 @@ namespace ExtUI { #if HAS_FILAMENT_RUNOUT_DISTANCE float getFilamentRunoutDistance_mm(); - void setFilamentRunoutDistance_mm(const_float_t ); + void setFilamentRunoutDistance_mm(const_float_t); #endif #endif @@ -289,7 +308,7 @@ namespace ExtUI { #if DISABLED(CASE_LIGHT_NO_BRIGHTNESS) float getCaseLightBrightness_percent(); - void setCaseLightBrightness_percent(const_float_t ); + void setCaseLightBrightness_percent(const_float_t); #endif #endif @@ -298,15 +317,15 @@ namespace ExtUI { 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 startPIDTune(const celsius_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 startBedPIDTune(const_float_t ); + void setBedPIDValues(const_float_t, const_float_t , const_float_t); + void startBedPIDTune(const celsius_t); #endif /** diff --git a/Marlin/src/lcd/fontutils.cpp b/Marlin/src/lcd/fontutils.cpp index 65c8c06409..90fcb2ae7c 100644 --- a/Marlin/src/lcd/fontutils.cpp +++ b/Marlin/src/lcd/fontutils.cpp @@ -149,7 +149,7 @@ uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t static inline uint8_t utf8_strlen_cb(const char *pstart, read_byte_cb_t cb_read_byte) { uint8_t cnt = 0; uint8_t *p = (uint8_t *)pstart; - for (;;) { + if (p) for (;;) { const uint8_t b = cb_read_byte(p); if (!b) break; if (utf8_is_start_byte_of_char(b)) cnt++; diff --git a/Marlin/src/lcd/language/language_an.h b/Marlin/src/lcd/language/language_an.h index 0513de7f7d..787096994f 100644 --- a/Marlin/src/lcd/language/language_an.h +++ b/Marlin/src/lcd/language/language_an.h @@ -89,6 +89,7 @@ namespace Language_an { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Mover 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Mover 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Mover 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Velocidat"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Base Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Boquilla"); diff --git a/Marlin/src/lcd/language/language_bg.h b/Marlin/src/lcd/language/language_bg.h index 5964652156..0d4291b835 100644 --- a/Marlin/src/lcd/language/language_bg.h +++ b/Marlin/src/lcd/language/language_bg.h @@ -79,6 +79,7 @@ namespace Language_bg { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Премести с 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Премести с 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Премести с 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Премести с 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Скорост"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Bed Z"); PROGMEM Language_Str MSG_NOZZLE = " " LCD_STR_THERMOMETER _UxGT(" Дюза"); diff --git a/Marlin/src/lcd/language/language_ca.h b/Marlin/src/lcd/language/language_ca.h index 6709a0ce55..f97a783d01 100644 --- a/Marlin/src/lcd/language/language_ca.h +++ b/Marlin/src/lcd/language/language_ca.h @@ -89,6 +89,7 @@ namespace Language_ca { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Mou 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Mou 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Mou 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Mou 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Velocitat"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Llit Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Nozzle"); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index c434f5493b..fa6a8e21a3 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -109,7 +109,7 @@ namespace Language_cz { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Posunout osy"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Vyrovnat podložku"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Vyrovnat podložku"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Vyrovnat rohy"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Vyrovnat rohy"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Další roh"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Editor sítě"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Upravit síť bodů"); @@ -241,6 +241,7 @@ namespace Language_cz { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Posunout o 0,1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Posunout o 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Posunout o 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Posunout o 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Rychlost"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Výška podl."); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Tryska"); diff --git a/Marlin/src/lcd/language/language_da.h b/Marlin/src/lcd/language/language_da.h index 9258812843..95c2573ae1 100644 --- a/Marlin/src/lcd/language/language_da.h +++ b/Marlin/src/lcd/language/language_da.h @@ -79,6 +79,7 @@ namespace Language_da { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Flyt 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Flyt 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Flyt 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Flyt 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Hastighed"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Plade Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Dyse"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index ebc2445b11..f06370078a 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -62,7 +62,6 @@ namespace Language_de { PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Home Y"); PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Home Z"); PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Z-Achsen ausgleichen"); - PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Bett ausrichten"); // Bettausrichtung PROGMEM Language_Str MSG_LEVEL_BED_HOMING = _UxGT("XYZ homen"); PROGMEM Language_Str MSG_LEVEL_BED_WAITING = _UxGT("Klick zum Starten"); PROGMEM Language_Str MSG_LEVEL_BED_NEXT_POINT = _UxGT("Nächste Koordinate"); @@ -103,7 +102,7 @@ namespace Language_de { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Achsen bewegen"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Bett-Nivellierung"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Bett nivellieren"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Ecken nivellieren"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Bett ausrichten"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Nächste Ecke"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Netz Editor"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Netz bearbeiten"); @@ -231,9 +230,10 @@ namespace Language_de { PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Bewege Extruder *"); PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("Hotend zu kalt"); PROGMEM Language_Str MSG_MOVE_N_MM = _UxGT(" %s mm"); - PROGMEM Language_Str MSG_MOVE_01MM = _UxGT(" 0,1 mm"); - PROGMEM Language_Str MSG_MOVE_1MM = _UxGT(" 1,0 mm"); - PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("10,0 mm"); + PROGMEM Language_Str MSG_MOVE_01MM = _UxGT(" 0,1 mm"); + PROGMEM Language_Str MSG_MOVE_1MM = _UxGT(" 1,0 mm"); + PROGMEM Language_Str MSG_MOVE_10MM = _UxGT(" 10,0 mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("100,0 mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Geschw."); PROGMEM Language_Str MSG_BED_Z = _UxGT("Bett Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Düse"); diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index ebe27fecbd..b69b4695d3 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -87,6 +87,7 @@ namespace Language_el { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Μετακίνηση 0,1 μμ"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Μετακίνηση 1 μμ"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Μετακίνηση 10 μμ"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Μετακίνηση 100 μμ"); PROGMEM Language_Str MSG_SPEED = _UxGT("Ταχύτητα"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Επ. Εκτύπωσης Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Ακροφύσιο"); diff --git a/Marlin/src/lcd/language/language_el_gr.h b/Marlin/src/lcd/language/language_el_gr.h index e6909ad5bf..208d7c2363 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -88,6 +88,7 @@ namespace Language_el_gr { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Μετακίνηση 0,1 μμ"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Μετακίνηση 1 μμ"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Μετακίνηση 10 μμ"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Μετακίνηση 100 μμ"); PROGMEM Language_Str MSG_SPEED = _UxGT("Ταχύτητα"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Κλίνη Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Ακροφύσιο"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 33f11c9ffd..cd204eef59 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -93,7 +93,6 @@ namespace Language_en { PROGMEM Language_Str MSG_HOME_OFFSET_K = _UxGT("Home Offset ") LCD_STR_K; 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"); PROGMEM Language_Str MSG_TRAMMING_WIZARD = _UxGT("Tramming Wizard"); PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Select Origin"); PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Last value "); @@ -139,11 +138,11 @@ namespace Language_en { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Move Axis"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Bed Leveling"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Level Bed"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Level Corners"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Raise Bed Until Probe Triggered"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("All Corners Within Tolerance. Level Bed"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_GOOD_POINTS = _UxGT("Good Points: "); - PROGMEM Language_Str MSG_LEVEL_CORNERS_LAST_Z = _UxGT("Last Z: "); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Bed Tramming"); + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Raise Bed Until Probe Triggered"); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("All Corners Within Tolerance. Level Bed"); + PROGMEM Language_Str MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Good Points: "); + PROGMEM Language_Str MSG_BED_TRAMMING_LAST_Z = _UxGT("Last Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Next Corner"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Mesh Editor"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Edit Mesh"); @@ -281,9 +280,11 @@ namespace Language_en { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Move 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Move 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Move 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Move 100mm"); PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Move 0.001in"); PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Move 0.01in"); PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Move 0.1in"); + PROGMEM Language_Str MSG_MOVE_1IN = _UxGT("Move 1.0in"); PROGMEM Language_Str MSG_SPEED = _UxGT("Speed"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Bed Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Nozzle"); @@ -590,9 +591,9 @@ namespace Language_en { PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X Driver %"); PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Y Driver %"); PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Z Driver %"); - PROGMEM Language_Str MSG_DAC_PERCENT_I = _UxGT("I Driver %"); - PROGMEM Language_Str MSG_DAC_PERCENT_J = _UxGT("J Driver %"); - PROGMEM Language_Str MSG_DAC_PERCENT_K = _UxGT("K Driver %"); + PROGMEM Language_Str MSG_DAC_PERCENT_I = AXIS4_STR _UxGT(" Driver %"); + PROGMEM Language_Str MSG_DAC_PERCENT_J = AXIS5_STR _UxGT(" Driver %"); + PROGMEM Language_Str MSG_DAC_PERCENT_K = AXIS6_STR _UxGT(" Driver %"); PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("E Driver %"); PROGMEM Language_Str MSG_ERROR_TMC = _UxGT("TMC CONNECTION ERROR"); PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Write"); @@ -725,6 +726,7 @@ namespace Language_en { #endif PROGMEM Language_Str MSG_REHEAT = _UxGT("Reheat"); PROGMEM Language_Str MSG_REHEATING = _UxGT("Reheating..."); + PROGMEM Language_Str MSG_REHEATDONE = _UxGT("Reheat Done"); PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z Probe Wizard"); PROGMEM Language_Str MSG_PROBE_WIZARD_PROBING = _UxGT("Probing Z Reference"); @@ -740,6 +742,9 @@ namespace Language_en { PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Calibration Failed"); PROGMEM Language_Str MSG_DRIVER_BACKWARD = _UxGT(" driver backward"); + + PROGMEM Language_Str MSG_SD_CARD = _UxGT("SD Card"); + PROGMEM Language_Str MSG_USB_DISK = _UxGT("USB Disk"); } #if FAN_COUNT == 1 diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index b2d83aa05b..8fdf0bd47e 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -62,7 +62,6 @@ namespace Language_es { PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Origen Y"); PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Origen Z"); PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Auto alineado Z"); - PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Recorrido asistido"); PROGMEM Language_Str MSG_ITERATION = _UxGT("G34 Iteración: %i"); PROGMEM Language_Str MSG_DECREASING_ACCURACY = _UxGT("¡Precisión disminuyendo!"); PROGMEM Language_Str MSG_ACCURACY_ACHIEVED = _UxGT("Precisión conseguida"); @@ -106,7 +105,7 @@ namespace Language_es { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Mover ejes"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Nivelando Cama"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Nivelar Cama"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Nivelar Esquinas"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Recorrido asistido"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Siguente Esquina"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Editor Mallado"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Editar Mallado"); @@ -236,6 +235,7 @@ namespace Language_es { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Mover 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Mover 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Mover 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Velocidad"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Cama Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Boquilla"); diff --git a/Marlin/src/lcd/language/language_eu.h b/Marlin/src/lcd/language/language_eu.h index 1c1c9e423d..530742d6d3 100644 --- a/Marlin/src/lcd/language/language_eu.h +++ b/Marlin/src/lcd/language/language_eu.h @@ -82,7 +82,7 @@ namespace Language_eu { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Ardatzak mugitu"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Ohe berdinketa"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Ohea berdindu"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Ertzak berdindu"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Ertzak berdindu"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Hurrengo ertza"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Sarea editatu"); @@ -143,6 +143,7 @@ namespace Language_eu { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Mugitu 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Mugitu 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Mugitu 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Mugitu 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Abiadura"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Z Ohea"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Pita"); diff --git a/Marlin/src/lcd/language/language_fi.h b/Marlin/src/lcd/language/language_fi.h index 9954f1dd8a..0d3b97cc44 100644 --- a/Marlin/src/lcd/language/language_fi.h +++ b/Marlin/src/lcd/language/language_fi.h @@ -76,6 +76,7 @@ namespace Language_fi { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Liikuta 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Liikuta 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Liikuta 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Liikuta 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Nopeus"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Suutin"); PROGMEM Language_Str MSG_NOZZLE_N = _UxGT("Suutin ~"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index bdd91d3b29..6032937e0f 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -60,6 +60,9 @@ namespace Language_fr { PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("Origine X auto"); PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Origine Y auto"); PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Origine Z auto"); + PROGMEM Language_Str MSG_AUTO_HOME_I = _UxGT("Origine ") LCD_STR_I _UxGT(" auto"); + PROGMEM Language_Str MSG_AUTO_HOME_J = _UxGT("Origine ") LCD_STR_J _UxGT(" auto"); + PROGMEM Language_Str MSG_AUTO_HOME_K = _UxGT("Origine ") LCD_STR_K _UxGT(" auto"); PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Align. Z auto"); PROGMEM Language_Str MSG_LEVEL_BED_HOMING = _UxGT("Origine XYZ..."); PROGMEM Language_Str MSG_LEVEL_BED_WAITING = _UxGT("Clic pour commencer"); @@ -67,9 +70,14 @@ namespace Language_fr { PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Mise à niveau OK!"); PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Hauteur lissée"); PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Régl. décal origine"); + PROGMEM Language_Str MSG_HOME_OFFSET_X = _UxGT("Décal. origine X"); + PROGMEM Language_Str MSG_HOME_OFFSET_Y = _UxGT("Décal. origine Y"); + PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Décal. origine Z"); + PROGMEM Language_Str MSG_HOME_OFFSET_I = _UxGT("Décal. origine ") LCD_STR_I; + PROGMEM Language_Str MSG_HOME_OFFSET_J = _UxGT("Décal. origine ") LCD_STR_J; + PROGMEM Language_Str MSG_HOME_OFFSET_K = _UxGT("Décal. origine ") LCD_STR_K; PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Décalages appliqués"); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Régler origine"); - PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Assistant Molettes"); PROGMEM Language_Str MSG_TRAMMING_WIZARD = _UxGT("Assistant Molettes"); PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Molette du lit"); // Not a selection of the origin PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Ecart origine "); @@ -102,9 +110,9 @@ namespace Language_fr { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Déplacer un axe"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Régler Niv. lit"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Niveau du lit"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Niveau des coins"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Relever le coin jusqu'à la sonde"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("Coins dans la tolérance. Niveau lit "); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Assistant Molettes"); + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Relever le coin jusqu'à la sonde"); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("Coins dans la tolérance. Niveau lit "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Coin suivant"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Modif. maille"); // 13 car. max PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Modifier grille"); @@ -228,13 +236,21 @@ namespace Language_fr { PROGMEM Language_Str MSG_MOVE_X = _UxGT("Déplacer X"); PROGMEM Language_Str MSG_MOVE_Y = _UxGT("Déplacer Y"); PROGMEM Language_Str MSG_MOVE_Z = _UxGT("Déplacer Z"); - PROGMEM Language_Str MSG_MOVE_E = _UxGT("Extrudeur"); - PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Extrudeur *"); + PROGMEM Language_Str MSG_MOVE_I = _UxGT("Déplacer ") LCD_STR_I; + PROGMEM Language_Str MSG_MOVE_J = _UxGT("Déplacer ") LCD_STR_J; + PROGMEM Language_Str MSG_MOVE_K = _UxGT("Déplacer ") LCD_STR_K; + PROGMEM Language_Str MSG_MOVE_E = _UxGT("Extruder"); + PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Extruder *"); PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("Buse trop froide"); PROGMEM Language_Str MSG_MOVE_N_MM = _UxGT("Déplacer %smm"); PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Déplacer 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Déplacer 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Déplacer 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Déplacer 100mm"); + PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Déplacer 0.001\""); + PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Déplacer 0.01\""); + PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Déplacer 0.1\""); + PROGMEM Language_Str MSG_MOVE_1IN = _UxGT("Déplacer 1\""); PROGMEM Language_Str MSG_SPEED = _UxGT("Vitesse"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Lit Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Buse"); @@ -269,11 +285,31 @@ namespace Language_fr { PROGMEM Language_Str MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT(" jerk"); PROGMEM Language_Str MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT(" jerk"); PROGMEM Language_Str MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT(" jerk"); + PROGMEM Language_Str MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT(" jerk"); + PROGMEM Language_Str MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT(" jerk"); + PROGMEM Language_Str MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT(" jerk"); PROGMEM Language_Str MSG_VE_JERK = _UxGT("Ve jerk"); PROGMEM Language_Str MSG_VELOCITY = _UxGT("Vélocité"); + PROGMEM Language_Str MSG_VMAX_A = _UxGT("Vit. Max ") LCD_STR_A; + PROGMEM Language_Str MSG_VMAX_B = _UxGT("Vit. Max ") LCD_STR_B; + PROGMEM Language_Str MSG_VMAX_C = _UxGT("Vit. Max ") LCD_STR_C; + PROGMEM Language_Str MSG_VMAX_I = _UxGT("Vit. Max ") LCD_STR_I; + PROGMEM Language_Str MSG_VMAX_J = _UxGT("Vit. Max ") LCD_STR_J; + PROGMEM Language_Str MSG_VMAX_K = _UxGT("Vit. Max ") LCD_STR_K; + PROGMEM Language_Str MSG_VMAX_E = _UxGT("Vit. Max ") LCD_STR_E; + PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Vit. Max *"); PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Déviat. jonct."); + PROGMEM Language_Str MSG_VMIN = _UxGT("Vit. Min"); PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Vmin course"); PROGMEM Language_Str MSG_ACCELERATION = _UxGT("Accélération"); + PROGMEM Language_Str MSG_AMAX_A = _UxGT("Max Accél. ") LCD_STR_A; + PROGMEM Language_Str MSG_AMAX_B = _UxGT("Max Accél. ") LCD_STR_B; + PROGMEM Language_Str MSG_AMAX_C = _UxGT("Max Accél. ") LCD_STR_C; + PROGMEM Language_Str MSG_AMAX_I = _UxGT("Max Accél. ") LCD_STR_I; + PROGMEM Language_Str MSG_AMAX_J = _UxGT("Max Accél. ") LCD_STR_J; + PROGMEM Language_Str MSG_AMAX_K = _UxGT("Max Accél. ") LCD_STR_K; + PROGMEM Language_Str MSG_AMAX_E = _UxGT("Max Accél. ") LCD_STR_E; + PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Max Accél. *"); PROGMEM Language_Str MSG_A_RETRACT = _UxGT("Acc.rétraction"); PROGMEM Language_Str MSG_A_TRAVEL = _UxGT("Acc.course"); PROGMEM Language_Str MSG_XY_FREQUENCY_LIMIT = _UxGT("Fréquence max"); @@ -282,6 +318,9 @@ namespace Language_fr { PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" pas/mm"); PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" pas/mm"); PROGMEM Language_Str MSG_C_STEPS = LCD_STR_C _UxGT(" pas/mm"); + PROGMEM Language_Str MSG_I_STEPS = LCD_STR_I _UxGT(" pas/mm"); + PROGMEM Language_Str MSG_J_STEPS = LCD_STR_J _UxGT(" pas/mm"); + PROGMEM Language_Str MSG_K_STEPS = LCD_STR_K _UxGT(" pas/mm"); PROGMEM Language_Str MSG_E_STEPS = _UxGT("E pas/mm"); PROGMEM Language_Str MSG_EN_STEPS = _UxGT("* pas/mm"); PROGMEM Language_Str MSG_TEMPERATURE = _UxGT("Température"); @@ -401,6 +440,12 @@ namespace Language_fr { PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("Décalage X"); PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Décalage Y"); PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Décalage Z"); + PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Babystep X"); + PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Babystep Y"); + PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Babystep Z"); + PROGMEM Language_Str MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; + PROGMEM Language_Str MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; + PROGMEM Language_Str MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Total"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Butée abandon"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Err de chauffe"); @@ -443,6 +488,7 @@ namespace Language_fr { PROGMEM Language_Str MSG_BILINEAR_LEVELING = _UxGT("Niveau bilinéaire"); PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Niveau lit unifié"); PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Niveau par grille"); + PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Niveau terminé"); PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Stats. imprimante"); PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Infos carte"); PROGMEM Language_Str MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistances"); @@ -475,10 +521,13 @@ namespace Language_fr { PROGMEM Language_Str MSG_INFO_MAX_TEMP = _UxGT("Temp Max"); PROGMEM Language_Str MSG_INFO_PSU = _UxGT("Alim."); PROGMEM Language_Str MSG_DRIVE_STRENGTH = _UxGT("Puiss. moteur "); - PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X Driver %"); - PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Y Driver %"); - PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Z Driver %"); - PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("E Driver %"); + PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("Driver X %"); + PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Driver Y %"); + PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Driver Z %"); + PROGMEM Language_Str MSG_DAC_PERCENT_I = _UxGT("Driver " AXIS4_STR " %"); + PROGMEM Language_Str MSG_DAC_PERCENT_J = _UxGT("Driver " AXIS5_STR " %"); + PROGMEM Language_Str MSG_DAC_PERCENT_K = _UxGT("Driver " AXIS6_STR " %"); + PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("Driver E %"); PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM sauv."); PROGMEM Language_Str MSG_ERROR_TMC = _UxGT("ERREUR CONNEXION TMC"); @@ -575,6 +624,12 @@ namespace Language_fr { PROGMEM Language_Str MSG_TMC_STEALTH_ENABLED = _UxGT("StealthChop activé"); PROGMEM Language_Str MSG_SERVICE_RESET = _UxGT("Réinit."); PROGMEM Language_Str MSG_SERVICE_IN = _UxGT(" dans:"); + PROGMEM Language_Str MSG_BACKLASH_A = LCD_STR_A; + PROGMEM Language_Str MSG_BACKLASH_B = LCD_STR_B; + PROGMEM Language_Str MSG_BACKLASH_C = LCD_STR_C; + PROGMEM Language_Str MSG_BACKLASH_I = LCD_STR_I; + PROGMEM Language_Str MSG_BACKLASH_J = LCD_STR_J; + PROGMEM Language_Str MSG_BACKLASH_K = LCD_STR_K; PROGMEM Language_Str MSG_BACKLASH_CORRECTION = _UxGT("Correction"); PROGMEM Language_Str MSG_BACKLASH_SMOOTHING = _UxGT("Lissage"); @@ -600,4 +655,7 @@ namespace Language_fr { PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Coin bas droit"); PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Calibration terminée"); PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Échec de l'étalonnage"); + + PROGMEM Language_Str MSG_SD_CARD = _UxGT("Carte SD"); + PROGMEM Language_Str MSG_USB_DISK = _UxGT("Clé USB"); } diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index 5745ce1eb8..8defd2b01f 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -103,7 +103,7 @@ namespace Language_gl { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Mover eixe"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Nivelando Cama"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Nivelar Cama"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Nivelar Cantos"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Nivelar Cantos"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Seguinte Canto"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Editor Mallado"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Editar Mallado"); @@ -233,6 +233,7 @@ namespace Language_gl { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Mover 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Mover 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Mover 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Velocidade"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Cama Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Bico"); diff --git a/Marlin/src/lcd/language/language_hr.h b/Marlin/src/lcd/language/language_hr.h index 1684ad0e1b..e4cbdaed6c 100644 --- a/Marlin/src/lcd/language/language_hr.h +++ b/Marlin/src/lcd/language/language_hr.h @@ -83,6 +83,7 @@ namespace Language_hr { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Miči 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Miči 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Miči 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Miči 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Brzina"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Bed Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Dizna"); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index b2c1d30f33..6fb41f90ff 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -26,11 +26,11 @@ * * LCD Menu Messages. See also https://marlinfw.org/docs/development/lcd_language.html * Hungarian translation by AntoszHUN. I am constantly improving and updating the translation. - * Translation last updated: 21/03/2021 - 21:00 + * Translation last updated: 07/07/2021 - 11:20 * * LCD Menü Üzenetek. Lásd még https://marlinfw.org/docs/development/lcd_language.html * A Magyar fordítást készítette: AntoszHUN. A fordítást folyamatosan javítom és frissítem. - * A Fordítás utolsó frissítése: 2021.03.21. - 21:00 + * A Fordítás utolsó frissítése: 2021.07.07. - 11:20 */ namespace Language_hu { @@ -66,6 +66,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("X kezdöpont"); PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Y kezdöpont"); PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Z kezdöpont"); + PROGMEM Language_Str MSG_AUTO_HOME_I = _UxGT("Kezdö ") LCD_STR_I; + PROGMEM Language_Str MSG_AUTO_HOME_J = _UxGT("Kezdö ") LCD_STR_J; + PROGMEM Language_Str MSG_AUTO_HOME_K = _UxGT("Kezdö ") LCD_STR_K; PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Auto Z-igazítás"); PROGMEM Language_Str MSG_ITERATION = _UxGT("G34 Ismétlés: %i"); PROGMEM Language_Str MSG_DECREASING_ACCURACY = _UxGT("Pontosság csökken!"); @@ -76,9 +79,14 @@ namespace Language_hu { PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Szintezés kész!"); PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Szint csökkentés"); PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Kezdöpont eltolás"); + PROGMEM Language_Str MSG_HOME_OFFSET_X = _UxGT("X Kezdö eltol."); + PROGMEM Language_Str MSG_HOME_OFFSET_Y = _UxGT("Y Kezdö eltol."); + PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Z Kezdö eltol."); + PROGMEM Language_Str MSG_HOME_OFFSET_I = _UxGT("Kezdö eltol. ") LCD_STR_I; + PROGMEM Language_Str MSG_HOME_OFFSET_J = _UxGT("Kezdö eltol. ") LCD_STR_J; + PROGMEM Language_Str MSG_HOME_OFFSET_K = _UxGT("Kezdö eltol. ") LCD_STR_K; PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Eltolás beállítva."); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Eredeti Be"); - PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Elektromos segéd"); PROGMEM Language_Str MSG_TRAMMING_WIZARD = _UxGT("Elektromos varázsló"); PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Eredeti választása"); PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Utolsó érték "); @@ -108,12 +116,15 @@ namespace Language_hu { PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Lézer telj."); PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Orsó telj."); PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Lézer váltás"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Hütés váltás"); + PROGMEM Language_Str MSG_LASER_ASSIST_TOGGLE = _UxGT("Levegö segéd"); PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Impulzus teszt ms"); PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Tüz impulzus"); + PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Áramlási hiba"); PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Orsóváltás"); - PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Orsó előre"); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Vákuum váltás"); + PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Orsó elöre"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Orsó hátra"); - PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Bekapcsolás"); PROGMEM Language_Str MSG_SWITCH_PS_OFF = _UxGT("Kikapcsolás"); PROGMEM Language_Str MSG_EXTRUDE = _UxGT("Adagol"); @@ -121,11 +132,11 @@ namespace Language_hu { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Tengelyek mozgatása"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Ágy szintezés"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Ágy szintezése"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Sarok szint"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Ágy emelése a szonda váltásig"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("Minden sarok tolerancián belül. Szint jó."); - PROGMEM Language_Str MSG_LEVEL_CORNERS_GOOD_POINTS = _UxGT("Jó pontok: "); - PROGMEM Language_Str MSG_LEVEL_CORNERS_LAST_Z = _UxGT("Utolsó Z: "); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Elektromos segéd"); + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Ágy emelése a szonda váltásig"); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("Minden sarok tolerancián belül. Szint jó."); + PROGMEM Language_Str MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Jó pontok: "); + PROGMEM Language_Str MSG_BED_TRAMMING_LAST_Z = _UxGT("Utolsó Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Következö sarok"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Háló szerkesztö"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Háló szerkesztése"); @@ -134,7 +145,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_MESH_X = _UxGT("Index X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Index Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Z érték"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Egyéni parancs"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Egyéni parancs"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Szonda teszt"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Pont"); PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Szonda határon kívül"); @@ -154,6 +165,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Egységes ágy szint"); PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Döntési pont"); PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Kézi háló építés"); + PROGMEM Language_Str MSG_UBL_MESH_WIZARD = _UxGT("UBL Háló varázsló"); PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Tégy alátétet és mérj"); PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Mérés"); PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Üres ágyat mérj"); @@ -161,9 +173,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_UBL_ACTIVATE_MESH = _UxGT("UBL aktívál"); PROGMEM Language_Str MSG_UBL_DEACTIVATE_MESH = _UxGT("UBL deaktívál"); PROGMEM Language_Str MSG_UBL_SET_TEMP_BED = _UxGT("Ágy höfok"); - PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Ágy höfok"); - PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = _UxGT("Fej höfok"); - PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Fej höfok"); + PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Egyéni ágy höfok"); + PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = _UxGT("Fejhöfok"); + PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Egyéni fejhöfok"); PROGMEM Language_Str MSG_UBL_MESH_EDIT = _UxGT("Háló szerkesztés"); PROGMEM Language_Str MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Egyéni háló szerkesztés"); PROGMEM Language_Str MSG_UBL_FINE_TUNE_MESH = _UxGT("Finomított háló"); @@ -239,7 +251,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_LED_CHANNEL_N = _UxGT("Csatorna ="); PROGMEM Language_Str MSG_LEDS2 = _UxGT("LED-ek #2"); PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Fény #2 megadott"); - PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Fényerő"); + PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Fényerö"); PROGMEM Language_Str MSG_CUSTOM_LEDS = _UxGT("Egyéni szín"); PROGMEM Language_Str MSG_INTENSITY_R = _UxGT("Piros intenzitás"); PROGMEM Language_Str MSG_INTENSITY_G = _UxGT("Zöld intenzitás"); @@ -252,6 +264,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_MOVE_X = _UxGT("X mozgás"); PROGMEM Language_Str MSG_MOVE_Y = _UxGT("Y mozgás"); PROGMEM Language_Str MSG_MOVE_Z = _UxGT("Z mozgás"); + PROGMEM Language_Str MSG_MOVE_I = _UxGT("Mozgás ") LCD_STR_I; + PROGMEM Language_Str MSG_MOVE_J = _UxGT("Mozgás ") LCD_STR_J; + PROGMEM Language_Str MSG_MOVE_K = _UxGT("Mozgás ") LCD_STR_K; PROGMEM Language_Str MSG_MOVE_E = _UxGT("Adagoló"); PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Adagoló *"); PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("A fej túl hideg"); @@ -259,9 +274,11 @@ namespace Language_hu { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Mozgás 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Mozgás 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Mozgás 10mm"); - PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Mozgás 0.001mm"); - PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Mozgás 0.01mm"); - PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Mozgás 0.1mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Mozgás 100mm"); + PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Mozgás 0.025mm"); + PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Mozgás 0.254mm"); + PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Mozgás 2.54mm"); + PROGMEM Language_Str MSG_MOVE_1IN = _UxGT("Mozgáá 25.4mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Sebesség"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Z ágy"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Fej"); @@ -272,6 +289,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_CHAMBER = _UxGT("Burkolat"); PROGMEM Language_Str MSG_COOLER = _UxGT("Lézer hütövíz"); PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Hütö kapcsoló"); + PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Áramlásbiztonság"); PROGMEM Language_Str MSG_LASER = _UxGT("Lézer"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Hütés sebesség"); PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Hütés sebesség ="); @@ -298,20 +316,36 @@ namespace Language_hu { PROGMEM Language_Str MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Hangolási hiba. Rossz adagoló."); PROGMEM Language_Str MSG_PID_TEMP_TOO_HIGH = _UxGT("Hangolási hiba. Magas hömérséklet."); PROGMEM Language_Str MSG_PID_TIMEOUT = _UxGT("Hangolási hiba! Idötúllépés."); + PROGMEM Language_Str MSG_PID_P = _UxGT("PID-P"); + PROGMEM Language_Str MSG_PID_P_E = _UxGT("PID-P *"); + PROGMEM Language_Str MSG_PID_I = _UxGT("PID-I"); + PROGMEM Language_Str MSG_PID_I_E = _UxGT("PID-I *"); + PROGMEM Language_Str MSG_PID_D = _UxGT("PID-D"); + PROGMEM Language_Str MSG_PID_D_E = _UxGT("PID-D *"); + PROGMEM Language_Str MSG_PID_C = _UxGT("PID-C"); + PROGMEM Language_Str MSG_PID_C_E = _UxGT("PID-C *"); + PROGMEM Language_Str MSG_PID_F = _UxGT("PID-F"); + PROGMEM Language_Str MSG_PID_F_E = _UxGT("PID-F *"); PROGMEM Language_Str MSG_SELECT = _UxGT("Kiválaszt"); PROGMEM Language_Str MSG_SELECT_E = _UxGT("Kiválaszt *"); PROGMEM Language_Str MSG_ACC = _UxGT("Gyorsítás"); PROGMEM Language_Str MSG_JERK = _UxGT("Rántás"); - PROGMEM Language_Str MSG_VA_JERK = LCD_STR_A _UxGT(" Ránt. seb."); - PROGMEM Language_Str MSG_VB_JERK = LCD_STR_B _UxGT(" Ránt. seb."); - PROGMEM Language_Str MSG_VC_JERK = LCD_STR_C _UxGT(" Ránt. seb."); + PROGMEM Language_Str MSG_VA_JERK = _UxGT("Seb.") LCD_STR_A _UxGT("-Rántás"); + PROGMEM Language_Str MSG_VB_JERK = _UxGT("Seb.") LCD_STR_B _UxGT("-Rántás"); + PROGMEM Language_Str MSG_VC_JERK = _UxGT("Seb.") LCD_STR_C _UxGT("-Rántás"); + PROGMEM Language_Str MSG_VI_JERK = _UxGT("Seb.") LCD_STR_I _UxGT("-Rántás"); + PROGMEM Language_Str MSG_VJ_JERK = _UxGT("Seb.") LCD_STR_J _UxGT("-Rántás"); + PROGMEM Language_Str MSG_VK_JERK = _UxGT("Seb.") LCD_STR_K _UxGT("-Rántás"); PROGMEM Language_Str MSG_VE_JERK = _UxGT("E ránt. seb."); PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Csomopont eltérés"); PROGMEM Language_Str MSG_VELOCITY = _UxGT("Sebesség"); - PROGMEM Language_Str MSG_VMAX_A = _UxGT("Max sebesség ") LCD_STR_A; - PROGMEM Language_Str MSG_VMAX_B = _UxGT("Max sebesség ") LCD_STR_B; - PROGMEM Language_Str MSG_VMAX_C = _UxGT("Max sebesség ") LCD_STR_C; - PROGMEM Language_Str MSG_VMAX_E = _UxGT("Max sebesség ") LCD_STR_E; + PROGMEM Language_Str MSG_VMAX_A = _UxGT("Max Seb. ") LCD_STR_A; + PROGMEM Language_Str MSG_VMAX_B = _UxGT("Max Seb. ") LCD_STR_B; + PROGMEM Language_Str MSG_VMAX_C = _UxGT("Max Seb. ") LCD_STR_C; + PROGMEM Language_Str MSG_VMAX_I = _UxGT("Max Seb. ") LCD_STR_I; + PROGMEM Language_Str MSG_VMAX_J = _UxGT("Max Seb. ") LCD_STR_J; + PROGMEM Language_Str MSG_VMAX_K = _UxGT("Max Seb. ") LCD_STR_K; + PROGMEM Language_Str MSG_VMAX_E = _UxGT("Max Seb. ") LCD_STR_E; PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Max sebesség *"); PROGMEM Language_Str MSG_VMIN = _UxGT("Min sebesség"); PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Min utazó.seb."); @@ -319,6 +353,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_AMAX_A = _UxGT("Max gyors. ") LCD_STR_A; PROGMEM Language_Str MSG_AMAX_B = _UxGT("Max gyors. ") LCD_STR_B; PROGMEM Language_Str MSG_AMAX_C = _UxGT("Max gyors. ") LCD_STR_C; + PROGMEM Language_Str MSG_AMAX_I = _UxGT("Max gyors. ") LCD_STR_I; + PROGMEM Language_Str MSG_AMAX_J = _UxGT("Max gyors. ") LCD_STR_J; + PROGMEM Language_Str MSG_AMAX_K = _UxGT("Max gyors. ") LCD_STR_K; PROGMEM Language_Str MSG_AMAX_E = _UxGT("Max gyors. ") LCD_STR_E; PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Max gyorsulás *"); PROGMEM Language_Str MSG_A_RETRACT = _UxGT("Visszahúzás"); @@ -326,11 +363,14 @@ namespace Language_hu { PROGMEM Language_Str MSG_XY_FREQUENCY_LIMIT = _UxGT("Max frekvencia"); PROGMEM Language_Str MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min elötolás"); PROGMEM Language_Str MSG_STEPS_PER_MM = _UxGT("Lépés/mm"); - PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" lépés/mm"); - PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" lépés/mm"); - PROGMEM Language_Str MSG_C_STEPS = LCD_STR_C _UxGT(" lépés/mm"); + PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" Lépés/mm"); + PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" Lépés/mm"); + PROGMEM Language_Str MSG_C_STEPS = LCD_STR_C _UxGT(" Lépés/mm"); + PROGMEM Language_Str MSG_I_STEPS = LCD_STR_I _UxGT(" Lépés/mm"); + PROGMEM Language_Str MSG_J_STEPS = LCD_STR_J _UxGT(" Lépés/mm"); + PROGMEM Language_Str MSG_K_STEPS = LCD_STR_K _UxGT(" Lépés/mm"); PROGMEM Language_Str MSG_E_STEPS = _UxGT("E lépés/mm"); - PROGMEM Language_Str MSG_EN_STEPS = _UxGT("*lépés/mm"); + PROGMEM Language_Str MSG_EN_STEPS = _UxGT("*Lépés/mm"); PROGMEM Language_Str MSG_TEMPERATURE = _UxGT("Höfok"); PROGMEM Language_Str MSG_MOTION = _UxGT("Mozgatások"); PROGMEM Language_Str MSG_FILAMENT = _UxGT("Nyomtatószál"); @@ -462,6 +502,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Mikrolépés X"); PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Mikrolépés Y"); PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Mikrolépés Z"); + PROGMEM Language_Str MSG_BABYSTEP_I = _UxGT("Mikrolépés ") LCD_STR_I; + PROGMEM Language_Str MSG_BABYSTEP_J = _UxGT("Mikrolépés ") LCD_STR_J; + PROGMEM Language_Str MSG_BABYSTEP_K = _UxGT("Mikrolépés ") LCD_STR_K; PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Teljes"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Végállás megszakítva!"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Fütés hiba!"); @@ -506,6 +549,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_BILINEAR_LEVELING = _UxGT("Bilineáris szintezés"); PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Egységes ágy szintezés"); PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Háló szintezés"); + PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Háló szintezés kész"); PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Statisztikák"); PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Alaplap infó"); PROGMEM Language_Str MSG_INFO_THERMISTOR_MENU = _UxGT("Termisztorok"); @@ -541,6 +585,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X meghajtó %"); PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Y meghajtó %"); PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Z meghajtó %"); + PROGMEM Language_Str MSG_DAC_PERCENT_I = AXIS4_STR _UxGT(" Meghajtó %"); + PROGMEM Language_Str MSG_DAC_PERCENT_J = AXIS5_STR _UxGT(" Meghajtó %"); + PROGMEM Language_Str MSG_DAC_PERCENT_K = AXIS6_STR _UxGT(" Meghajtó %"); PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("E meghajtó %"); PROGMEM Language_Str MSG_ERROR_TMC = _UxGT("TMC CSATLAKOZÁSI HIBA"); PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM írása"); @@ -566,17 +613,17 @@ namespace Language_hu { PROGMEM Language_Str MSG_MMU2_LOAD_FILAMENT = _UxGT("Szál betöltése"); PROGMEM Language_Str MSG_MMU2_LOAD_ALL = _UxGT("Összes betöltése"); PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("Fej betöltése"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("Szál kiadása"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("Szál kiadása ~"); + PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("Szál kidobás"); + PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("Szál kidobás ~"); PROGMEM Language_Str MSG_MMU2_UNLOAD_FILAMENT = _UxGT("Kiadja a szálat"); PROGMEM Language_Str MSG_MMU2_LOADING_FILAMENT = _UxGT("Szál betölt. %i..."); - PROGMEM Language_Str MSG_MMU2_EJECTING_FILAMENT = _UxGT("Szál kiadás...."); + PROGMEM Language_Str MSG_MMU2_EJECTING_FILAMENT = _UxGT("Szál kidobás. ..."); PROGMEM Language_Str MSG_MMU2_UNLOADING_FILAMENT = _UxGT("Szál kiadása...."); PROGMEM Language_Str MSG_MMU2_ALL = _UxGT("Mind"); PROGMEM Language_Str MSG_MMU2_FILAMENT_N = _UxGT("Nyomtatószál ~"); PROGMEM Language_Str MSG_MMU2_RESET = _UxGT("MMU újraindítás"); PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("MMU újraindul..."); - PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Eltávolít, kattint"); + PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Kidob, kattint"); PROGMEM Language_Str MSG_MIX = _UxGT("Kever"); PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Összetevö ="); @@ -632,7 +679,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_FILAMENT_CHANGE_LOAD = _UxGT(MSG_2_LINE("Várj a", "szál betöltésére")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_PURGE = _UxGT(MSG_2_LINE("Várj a", "szál tisztításra")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_CONT_PURGE = _UxGT(MSG_2_LINE("Kattints a készre", "szál tiszta")); - PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_2_LINE("Várj a nyomtatóra", "majd foltyat...")); + PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_2_LINE("Várj a nyomtatóra", "majd folytat...")); #else PROGMEM Language_Str MSG_ADVANCED_PAUSE_WAITING = _UxGT(MSG_1_LINE("Katt a folytatáshoz")); PROGMEM Language_Str MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_1_LINE("Parkolás...")); @@ -658,6 +705,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_BACKLASH_A = LCD_STR_A; PROGMEM Language_Str MSG_BACKLASH_B = LCD_STR_B; PROGMEM Language_Str MSG_BACKLASH_C = LCD_STR_C; + PROGMEM Language_Str MSG_BACKLASH_I = LCD_STR_I; + PROGMEM Language_Str MSG_BACKLASH_J = LCD_STR_J; + PROGMEM Language_Str MSG_BACKLASH_K = LCD_STR_K; PROGMEM Language_Str MSG_BACKLASH_CORRECTION = _UxGT("Korrekció"); PROGMEM Language_Str MSG_BACKLASH_SMOOTHING = _UxGT("Simítás"); @@ -683,6 +733,11 @@ namespace Language_hu { PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Jobb alsó"); PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Kalibrálás befejezve"); PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Kalibrálási hiba"); + + PROGMEM Language_Str MSG_DRIVER_BACKWARD = _UxGT(" meghajtók hátra"); + + PROGMEM Language_Str MSG_SD_CARD = _UxGT("SD Kártya"); + PROGMEM Language_Str MSG_USB_DISK = _UxGT("USB Lemez"); } #if FAN_COUNT == 1 diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index d359354932..32bc7ff7c7 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -67,9 +67,12 @@ namespace Language_it { PROGMEM Language_Str MSG_DEBUG_MENU = _UxGT("Menu di debug"); PROGMEM Language_Str MSG_PROGRESS_BAR_TEST = _UxGT("Test barra avanzam."); PROGMEM Language_Str MSG_AUTO_HOME = _UxGT("Auto Home"); - PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("Home asse X"); - PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Home asse Y"); - PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Home asse Z"); + PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("Home X"); + PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Home Y"); + PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Home Z"); + PROGMEM Language_Str MSG_AUTO_HOME_I = _UxGT("Home ") LCD_STR_I; + PROGMEM Language_Str MSG_AUTO_HOME_J = _UxGT("Home ") LCD_STR_J; + PROGMEM Language_Str MSG_AUTO_HOME_K = _UxGT("Home ") LCD_STR_K; PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Allineam.automat. Z"); PROGMEM Language_Str MSG_ITERATION = _UxGT("Iterazione G34: %i"); PROGMEM Language_Str MSG_DECREASING_ACCURACY = _UxGT("Precisione in calo!"); @@ -80,9 +83,14 @@ namespace Language_it { PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Livel. terminato!"); PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Fade Height"); PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Imp. offset home"); + PROGMEM Language_Str MSG_HOME_OFFSET_X = _UxGT("Offset home X"); + PROGMEM Language_Str MSG_HOME_OFFSET_Y = _UxGT("Offset home Y"); + PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Offset home Z"); + PROGMEM Language_Str MSG_HOME_OFFSET_I = _UxGT("Offset home ") LCD_STR_I; + PROGMEM Language_Str MSG_HOME_OFFSET_J = _UxGT("Offset home ") LCD_STR_J; + PROGMEM Language_Str MSG_HOME_OFFSET_K = _UxGT("Offset home ") LCD_STR_K; PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Offset applicato"); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Imposta Origine"); - PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Tramming assistito"); PROGMEM Language_Str MSG_TRAMMING_WIZARD = _UxGT("Wizard Tramming"); PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Selez. origine"); PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Ultimo valore "); @@ -112,10 +120,13 @@ namespace Language_it { PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Potenza laser"); PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Potenza mandrino"); PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Alterna Laser"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Alterna soffiatore"); + PROGMEM Language_Str MSG_LASER_ASSIST_TOGGLE = _UxGT("Alterna aria supp."); PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("ms impulso di test"); PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Spara impulso"); PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Err.flusso refrig."); PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Alterna mandrino"); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Alterna vuoto"); PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Mandrino in avanti"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Inverti mandrino"); PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Accendi aliment."); @@ -125,11 +136,11 @@ namespace Language_it { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Muovi Asse"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Livella piano"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Livella piano"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Calibra piano"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Regola la vite finche' la sonda non rileva il piano."); - PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("Tolleranza raggiunta su tutti gli angoli. Piano livellato!"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_GOOD_POINTS = _UxGT("Punti buoni: "); - PROGMEM Language_Str MSG_LEVEL_CORNERS_LAST_Z = _UxGT("Ultimo Z: "); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Tramming piano"); + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Regola la vite finche' la sonda non rileva il piano."); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("Tolleranza raggiunta su tutti gli angoli. Piano livellato!"); + PROGMEM Language_Str MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Punti buoni: "); + PROGMEM Language_Str MSG_BED_TRAMMING_LAST_Z = _UxGT("Ultimo Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Prossimo punto"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Editor Mesh"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Modifica Mesh"); @@ -158,6 +169,7 @@ namespace Language_it { PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Livel.letto unificato"); PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Punto inclinaz."); PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Mesh Manuale"); + PROGMEM Language_Str MSG_UBL_MESH_WIZARD = _UxGT("Creaz.guid.mesh UBL"); PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Metti spes. e misura"); PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Misura"); PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Rimuovi e mis.piatto"); @@ -258,6 +270,9 @@ namespace Language_it { PROGMEM Language_Str MSG_MOVE_X = _UxGT("Muovi X"); PROGMEM Language_Str MSG_MOVE_Y = _UxGT("Muovi Y"); PROGMEM Language_Str MSG_MOVE_Z = _UxGT("Muovi Z"); + PROGMEM Language_Str MSG_MOVE_I = _UxGT("Muovi ") LCD_STR_I; + PROGMEM Language_Str MSG_MOVE_J = _UxGT("Muovi ") LCD_STR_J; + PROGMEM Language_Str MSG_MOVE_K = _UxGT("Muovi ") LCD_STR_K; PROGMEM Language_Str MSG_MOVE_E = _UxGT("Estrusore"); PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Estrusore *"); PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("Ugello freddo"); @@ -265,9 +280,11 @@ namespace Language_it { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Muovi di 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Muovi di 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Muovi di 10mm"); - PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Muovi di 0.001in"); - PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Muovi di 0.01in"); - PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Muovi di 0.1in"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Muovi di 100mm"); + PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Muovi di 0.001\""); + PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Muovi di 0.01\""); + PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Muovi di 0.1\""); + PROGMEM Language_Str MSG_MOVE_1IN = _UxGT("Muovi di 1\""); PROGMEM Language_Str MSG_SPEED = _UxGT("Velocità"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Piatto Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Ugello"); @@ -312,12 +329,18 @@ namespace Language_it { PROGMEM Language_Str MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-jerk"); PROGMEM Language_Str MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-jerk"); PROGMEM Language_Str MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-jerk"); + PROGMEM Language_Str MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-jerk"); + PROGMEM Language_Str MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-jerk"); + PROGMEM Language_Str MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-jerk"); PROGMEM Language_Str MSG_VE_JERK = _UxGT("Ve-jerk"); PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Deviaz. giunzioni"); PROGMEM Language_Str MSG_VELOCITY = _UxGT("Velocità"); PROGMEM Language_Str MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; PROGMEM Language_Str MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; PROGMEM Language_Str MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; + PROGMEM Language_Str MSG_VMAX_I = _UxGT("Vmax ") LCD_STR_I; + PROGMEM Language_Str MSG_VMAX_J = _UxGT("Vmax ") LCD_STR_J; + PROGMEM Language_Str MSG_VMAX_K = _UxGT("Vmax ") LCD_STR_K; PROGMEM Language_Str MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Vmax *"); PROGMEM Language_Str MSG_VMIN = _UxGT("Vmin"); @@ -326,6 +349,9 @@ namespace Language_it { PROGMEM Language_Str MSG_AMAX_A = _UxGT("Amax ") LCD_STR_A; PROGMEM Language_Str MSG_AMAX_B = _UxGT("Amax ") LCD_STR_B; PROGMEM Language_Str MSG_AMAX_C = _UxGT("Amax ") LCD_STR_C; + PROGMEM Language_Str MSG_AMAX_I = _UxGT("Amax ") LCD_STR_I; + PROGMEM Language_Str MSG_AMAX_J = _UxGT("Amax ") LCD_STR_J; + PROGMEM Language_Str MSG_AMAX_K = _UxGT("Amax ") LCD_STR_K; PROGMEM Language_Str MSG_AMAX_E = _UxGT("Amax ") LCD_STR_E; PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Amax *"); PROGMEM Language_Str MSG_A_RETRACT = _UxGT("A-Ritrazione"); @@ -333,11 +359,14 @@ namespace Language_it { PROGMEM Language_Str MSG_XY_FREQUENCY_LIMIT = _UxGT("Frequenza max"); PROGMEM Language_Str MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min"); PROGMEM Language_Str MSG_STEPS_PER_MM = _UxGT("Passi/mm"); - PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT("passi/mm"); - PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT("passi/mm"); - PROGMEM Language_Str MSG_C_STEPS = LCD_STR_C _UxGT("passi/mm"); - PROGMEM Language_Str MSG_E_STEPS = _UxGT("Epassi/mm"); - PROGMEM Language_Str MSG_EN_STEPS = _UxGT("*passi/mm"); + PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" passi/mm"); + PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" passi/mm"); + PROGMEM Language_Str MSG_C_STEPS = LCD_STR_C _UxGT(" passi/mm"); + PROGMEM Language_Str MSG_I_STEPS = LCD_STR_I _UxGT(" passi/mm"); + PROGMEM Language_Str MSG_J_STEPS = LCD_STR_J _UxGT(" passi/mm"); + PROGMEM Language_Str MSG_K_STEPS = LCD_STR_K _UxGT(" passi/mm"); + PROGMEM Language_Str MSG_E_STEPS = _UxGT("E passi/mm"); + PROGMEM Language_Str MSG_EN_STEPS = _UxGT("* passi/mm"); PROGMEM Language_Str MSG_TEMPERATURE = _UxGT("Temperatura"); PROGMEM Language_Str MSG_MOTION = _UxGT("Movimento"); PROGMEM Language_Str MSG_FILAMENT = _UxGT("Filamento"); @@ -469,6 +498,9 @@ namespace Language_it { PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Babystep X"); PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Babystep Y"); PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Babystep Z"); + PROGMEM Language_Str MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; + PROGMEM Language_Str MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; + PROGMEM Language_Str MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Totali"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Finecorsa annullati"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Risc.Fallito"); // Max 12 caratteri @@ -545,10 +577,13 @@ namespace Language_it { PROGMEM Language_Str MSG_INFO_MAX_TEMP = _UxGT("Temp max"); PROGMEM Language_Str MSG_INFO_PSU = _UxGT("Alimentatore"); PROGMEM Language_Str MSG_DRIVE_STRENGTH = _UxGT("Potenza Drive"); - PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X Driver %"); - PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Y Driver %"); - PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Z Driver %"); - PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("E Driver %"); + PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("Driver X %"); + PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Driver Y %"); + PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Driver Z %"); + PROGMEM Language_Str MSG_DAC_PERCENT_I = _UxGT("Driver ") AXIS4_STR _UxGT(" %"); + PROGMEM Language_Str MSG_DAC_PERCENT_J = _UxGT("Driver ") AXIS5_STR _UxGT(" %"); + PROGMEM Language_Str MSG_DAC_PERCENT_K = _UxGT("Driver ") AXIS6_STR _UxGT(" %"); + PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("Driver E %"); PROGMEM Language_Str MSG_ERROR_TMC = _UxGT("ERR.CONNESSIONE TMC"); PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("Scrivi DAC EEPROM"); PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEADER = _UxGT("CAMBIO FILAMENTO"); @@ -681,10 +716,15 @@ namespace Language_it { PROGMEM Language_Str MSG_SOUND = _UxGT("Suoni"); - PROGMEM Language_Str MSG_TOP_LEFT = _UxGT("Alto sinistra"); + PROGMEM Language_Str MSG_TOP_LEFT = _UxGT("Alto sinistra"); PROGMEM Language_Str MSG_BOTTOM_LEFT = _UxGT("Basso sinistra"); PROGMEM Language_Str MSG_TOP_RIGHT = _UxGT("Alto destra"); PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Basso destra"); PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Calibrazione completata"); PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Calibrazione fallita"); + + PROGMEM Language_Str MSG_DRIVER_BACKWARD = _UxGT(" driver invertito"); + + PROGMEM Language_Str MSG_SD_CARD = _UxGT("Scheda SD"); + PROGMEM Language_Str MSG_USB_DISK = _UxGT("Disco USB"); } diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index e0028e22a2..61740e3b40 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -98,6 +98,7 @@ namespace Language_jp_kana { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("0.1mm イドウ"); // "Move 0.1mm" PROGMEM Language_Str MSG_MOVE_1MM = _UxGT(" 1mm イドウ"); // "Move 1mm" PROGMEM Language_Str MSG_MOVE_10MM = _UxGT(" 10mm イドウ"); // "Move 10mm" + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT(" 100mm イドウ"); // "Move 100mm" PROGMEM Language_Str MSG_SPEED = _UxGT("ソクド"); // "Speed" PROGMEM Language_Str MSG_BED_Z = _UxGT("Zオフセット"); // "Bed Z" PROGMEM Language_Str MSG_NOZZLE = _UxGT("ノズル"); // "Nozzle" diff --git a/Marlin/src/lcd/language/language_nl.h b/Marlin/src/lcd/language/language_nl.h index 82e5c292c6..1eef4ca424 100644 --- a/Marlin/src/lcd/language/language_nl.h +++ b/Marlin/src/lcd/language/language_nl.h @@ -91,6 +91,7 @@ namespace Language_nl { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Verplaats 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Verplaats 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Verplaats 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Verplaats 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Snelheid"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Bed Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Nozzle"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index 7b4733b7ba..e467178f6a 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -85,7 +85,6 @@ namespace Language_pl { //PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Home Offset Z"); PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Poz. zerowa ust."); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Ustaw punkt zero"); - //PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Assisted Tramming"); //PROGMEM Language_Str MSG_TRAMMING_WIZARD = _UxGT("Tramming Wizard"); PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Wybierz punkt zero"); PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Poprzednia wartość "); @@ -131,11 +130,11 @@ namespace Language_pl { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Ruch osi"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Poziomowanie stołu"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Wypoziomuj stół"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Narożniki poziomowania"); - //PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Raise Bed Until Probe Triggered"); - //PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("All Corners Within Tolerance. Level Bed"); - //PROGMEM Language_Str MSG_LEVEL_CORNERS_GOOD_POINTS = _UxGT("Good Points: "); - //PROGMEM Language_Str MSG_LEVEL_CORNERS_LAST_Z = _UxGT("Last Z: "); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Narożniki poziomowania"); + //PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Raise Bed Until Probe Triggered"); + //PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("All Corners Within Tolerance. Level Bed"); + //PROGMEM Language_Str MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Good Points: "); + //PROGMEM Language_Str MSG_BED_TRAMMING_LAST_Z = _UxGT("Last Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Nastepny narożnik"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Edytor siatki"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Edycja siatki"); @@ -270,6 +269,7 @@ namespace Language_pl { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Przesuń co .1 mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Przesuń co 1 mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Przesuń co 10 mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Przesuń co 100 mm"); PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Przesuń co 0.001 cala"); PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Przesuń co 0.01 cala"); PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Przesuń co 0.1 cala"); diff --git a/Marlin/src/lcd/language/language_pt.h b/Marlin/src/lcd/language/language_pt.h index 60b0c55056..4bec74558e 100644 --- a/Marlin/src/lcd/language/language_pt.h +++ b/Marlin/src/lcd/language/language_pt.h @@ -85,6 +85,7 @@ namespace Language_pt { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Mover 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Mover 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Mover 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Velocidade"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Base Z"); PROGMEM Language_Str MSG_NOZZLE = " " LCD_STR_THERMOMETER _UxGT(" Bico"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index 642a7d9203..12904aa7ea 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -94,7 +94,7 @@ namespace Language_pt_br { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Mover eixo"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Nivelação Mesa"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Nivelar Mesa"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Nivelar Cantos"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Nivelar Cantos"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Próximo Canto"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Editor de Malha"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Editar Malha"); @@ -218,6 +218,7 @@ namespace Language_pt_br { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Mover 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Mover 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Mover 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Velocidade"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Base Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Bocal"); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index a34717acb5..3d21e1a58d 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -102,7 +102,7 @@ namespace Language_ro { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Muta Axa"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Nivelarea Patului"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Niveleaza Patul"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Niveleaza Colturile"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Niveleaza Colturile"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Urmatorul Colt"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Editor Mesh"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Editeaza Mesh"); @@ -232,6 +232,7 @@ namespace Language_ro { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Move 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Move 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Move 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Move 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Speed"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Bed Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Nozzle"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index a10f47ef8e..6ccfe5f47a 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -69,6 +69,9 @@ namespace Language_ru { PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("Парковка X"); PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Парковка Y"); PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Парковка Z"); + PROGMEM Language_Str MSG_AUTO_HOME_I = _UxGT("Парковка ") LCD_STR_I; + PROGMEM Language_Str MSG_AUTO_HOME_J = _UxGT("Парковка ") LCD_STR_J; + PROGMEM Language_Str MSG_AUTO_HOME_K = _UxGT("Парковка ") LCD_STR_K; PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Авто Z-выравнивание"); PROGMEM Language_Str MSG_ITERATION = _UxGT("G34 Итерация: %i"); PROGMEM Language_Str MSG_DECREASING_ACCURACY = _UxGT("Уменьшение точности!"); @@ -80,11 +83,29 @@ namespace Language_ru { PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Высота спада"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Установ. смещения дома"); + PROGMEM Language_Str MSG_HOME_OFFSET_X = _UxGT("Смещение дома X"); + PROGMEM Language_Str MSG_HOME_OFFSET_Y = _UxGT("Смещение дома Y"); + PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Смещение дома Z"); + PROGMEM Language_Str MSG_HOME_OFFSET_I = _UxGT("Смещение дома ") LCD_STR_I; + PROGMEM Language_Str MSG_HOME_OFFSET_J = _UxGT("Смещение дома ") LCD_STR_J; + PROGMEM Language_Str MSG_HOME_OFFSET_K = _UxGT("Смещение дома ") LCD_STR_K; #else PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Установ.смещ.дома"); + PROGMEM Language_Str MSG_HOME_OFFSET_X = _UxGT("Смещ. дома X"); + PROGMEM Language_Str MSG_HOME_OFFSET_Y = _UxGT("Смещ. дома Y"); + PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Смещ. дома Z"); + PROGMEM Language_Str MSG_HOME_OFFSET_I = _UxGT("Смещ. дома ") LCD_STR_I; + PROGMEM Language_Str MSG_HOME_OFFSET_J = _UxGT("Смещ. дома ") LCD_STR_J; + PROGMEM Language_Str MSG_HOME_OFFSET_K = _UxGT("Смещ. дома ") LCD_STR_K; #endif PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Смещения применены"); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Установить ноль"); + PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Выберите ноль"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Последнее знач. "); + #else + PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Послед. знач. "); + #endif #if PREHEAT_COUNT PROGMEM Language_Str MSG_PREHEAT_1 = _UxGT("Преднагрев ") PREHEAT_1_LABEL; PROGMEM Language_Str MSG_PREHEAT_1_H = _UxGT("Нагрев ") PREHEAT_1_LABEL " ~"; @@ -106,15 +127,28 @@ namespace Language_ru { PROGMEM Language_Str MSG_COOLDOWN = _UxGT("Охлаждение"); PROGMEM Language_Str MSG_CUTTER_FREQUENCY = _UxGT("Частота"); PROGMEM Language_Str MSG_LASER_MENU = _UxGT("Управление лазером"); - PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Переключить лазер"); - PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Мощность лазера"); - PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Управление шпинделем"); - PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Переключить шпиндель"); #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Управление шпинделем"); + PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Переключить лазер"); + PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Переключ.шпиндель"); PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Мощность шпинделя"); + PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Мощность лазера"); + PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Тестовый импульс мс"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Переключить обдув"); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Переключить вакуум"); #else + PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Управление шпинд."); + PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Переключ.лазер"); + PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Переключ.шпинд"); PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Мощн.шпинделя"); + PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Мощн. лазера"); + PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Тест. имп. мс"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Переключ. обдув"); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Переключ. вакуум"); #endif + PROGMEM Language_Str MSG_LASER_ASSIST_TOGGLE = _UxGT("Управление обдувом"); + PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Ошибка обдува"); + PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Импульс лазера"); PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Шпиндель вперёд"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Инверсия шпинделя"); @@ -125,8 +159,17 @@ namespace Language_ru { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Движение по осям"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Выравнивание стола"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Выровнять стол"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Выровнять углы"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Выровнять углы"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Следующий угол"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Вверх до срабатыв. зонда"); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("Углы в норме. Вырав.стола"); + #else + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Вверх до сраб. зонда"); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("Углы в норме. Вырав."); + #endif + PROGMEM Language_Str MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Хорошие точки: "); + PROGMEM Language_Str MSG_BED_TRAMMING_LAST_Z = _UxGT("Последняя Z: "); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Смещение по Z"); PROGMEM Language_Str MSG_EDITING_STOPPED = _UxGT("Правка сетки окончена"); @@ -164,12 +207,13 @@ namespace Language_ru { PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Точка разворота"); PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Ручной ввод сетки"); #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Разместить шайбу и измерить"); + PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Разместить шайбу,измерить"); PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Убрать и замерить стол"); #else - PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Разм.шайбу,измерить"); + PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Разм.шайбу, измерить"); PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Убрать, измер. стол"); #endif + PROGMEM Language_Str MSG_UBL_MESH_WIZARD = _UxGT("Мастер сеток UBL"); PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Измерение"); PROGMEM Language_Str MSG_UBL_MOVING_TO_NEXT = _UxGT("Двигаемся дальше"); PROGMEM Language_Str MSG_UBL_ACTIVATE_MESH = _UxGT("Активировать UBL"); @@ -185,17 +229,15 @@ namespace Language_ru { PROGMEM Language_Str MSG_UBL_DONE_EDITING_MESH = _UxGT("Правка сетки завершена"); #else PROGMEM Language_Str MSG_UBL_SET_TEMP_BED = LCD_STR_THERMOMETER _UxGT(" стола, ") LCD_STR_DEGREE "C"; - PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = LCD_STR_THERMOMETER _UxGT(" стола, ") LCD_STR_DEGREE "C"; + PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" стола,") LCD_STR_DEGREE "C"; PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE "C"; - PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE "C"; + PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" сопла,") LCD_STR_DEGREE "C"; PROGMEM Language_Str MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Построить свою"); PROGMEM Language_Str MSG_UBL_DONE_EDITING_MESH = _UxGT("Правка завершена"); #endif PROGMEM Language_Str MSG_UBL_FINE_TUNE_MESH = _UxGT("Точная правка сетки"); PROGMEM Language_Str MSG_UBL_BUILD_MESH_MENU = _UxGT("Построить сетку"); - #if PREHEAT_COUNT - PROGMEM Language_Str MSG_UBL_BUILD_MESH_M = _UxGT("Построить сетку $"); - #endif + PROGMEM Language_Str MSG_UBL_BUILD_MESH_M = _UxGT("Построить сетку $"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_UBL_BUILD_COLD_MESH = _UxGT("Построить холодную сетку"); #else @@ -205,14 +247,10 @@ namespace Language_ru { PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Высота"); PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Проверить сетку"); #if LCD_WIDTH > 21 - #if PREHEAT_COUNT - PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Проверить сетку $"); - #endif + PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Проверить сетку $"); PROGMEM Language_Str MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Проверить свою сетку"); #else - #if PREHEAT_COUNT - PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Провер. сетку $"); - #endif + PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Провер. сетку $"); PROGMEM Language_Str MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Провер. свою сетку"); #endif PROGMEM Language_Str MSG_G26_HEATING_BED = _UxGT("G26 нагрев стола"); @@ -239,11 +277,12 @@ namespace Language_ru { #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Сохранить сетку снаружи"); PROGMEM Language_Str MSG_UBL_INFO_UBL = _UxGT("Вывод информации UBL"); + PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Кол-во заполнителя"); #else PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Сохранить снаружи"); PROGMEM Language_Str MSG_UBL_INFO_UBL = _UxGT("Информация UBL"); + PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Кол-во заполн."); #endif - PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Кол-во заполнителя"); PROGMEM Language_Str MSG_UBL_MANUAL_FILLIN = _UxGT("Ручное заполнение"); PROGMEM Language_Str MSG_UBL_SMART_FILLIN = _UxGT("Умное заполнение"); PROGMEM Language_Str MSG_UBL_FILLIN_MESH = _UxGT("Заполнить сетку"); @@ -303,6 +342,9 @@ namespace Language_ru { PROGMEM Language_Str MSG_MOVE_X = _UxGT("Движение по X"); PROGMEM Language_Str MSG_MOVE_Y = _UxGT("Движение по Y"); PROGMEM Language_Str MSG_MOVE_Z = _UxGT("Движение по Z"); + PROGMEM Language_Str MSG_MOVE_I = _UxGT("Движение по ") LCD_STR_I; + PROGMEM Language_Str MSG_MOVE_J = _UxGT("Движение по ") LCD_STR_J; + PROGMEM Language_Str MSG_MOVE_K = _UxGT("Движение по ") LCD_STR_K; PROGMEM Language_Str MSG_MOVE_E = _UxGT("Экструдер"); PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Экструдер *"); PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("Сопло не нагрето"); @@ -310,6 +352,7 @@ namespace Language_ru { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Движение 0.1мм"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Движение 1мм"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Движение 10мм"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Движение 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Скорость"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Z стола"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Сопло, ") LCD_STR_DEGREE "C"; @@ -318,6 +361,16 @@ namespace Language_ru { PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Сопло ожидает"); PROGMEM Language_Str MSG_BED = _UxGT("Стол, ") LCD_STR_DEGREE "C"; PROGMEM Language_Str MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_COOLER = _UxGT("Охлаждение лазера"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Переключ. охлажд."); + PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Безопасн. потока"); + #else + PROGMEM Language_Str MSG_COOLER = _UxGT("Охлажд. лазера"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Переключ. охл."); + PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Безопас.потока"); + #endif + PROGMEM Language_Str MSG_LASER = _UxGT("Лазер"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Кулер"); PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Кулер ~"); PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Сохранённый кулер ~"); @@ -352,6 +405,9 @@ namespace Language_ru { PROGMEM Language_Str MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-рывок"); PROGMEM Language_Str MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-рывок"); PROGMEM Language_Str MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-рывок"); + PROGMEM Language_Str MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-рывок"); + PROGMEM Language_Str MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-рывок"); + PROGMEM Language_Str MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-рывок"); PROGMEM Language_Str MSG_VE_JERK = _UxGT("Ve-рывок"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Отклонение узла"); @@ -362,6 +418,9 @@ namespace Language_ru { PROGMEM Language_Str MSG_VMAX_A = _UxGT("Скор.макс ") LCD_STR_A; PROGMEM Language_Str MSG_VMAX_B = _UxGT("Скор.макс ") LCD_STR_B; PROGMEM Language_Str MSG_VMAX_C = _UxGT("Скор.макс ") LCD_STR_C; + PROGMEM Language_Str MSG_VMAX_I = _UxGT("Скор.макс ") LCD_STR_I; + PROGMEM Language_Str MSG_VMAX_J = _UxGT("Скор.макс ") LCD_STR_J; + PROGMEM Language_Str MSG_VMAX_K = _UxGT("Скор.макс ") LCD_STR_K; PROGMEM Language_Str MSG_VMAX_E = _UxGT("Скор.макс ") LCD_STR_E; PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Скор.макс *"); PROGMEM Language_Str MSG_VMIN = _UxGT("Скор.мин"); @@ -370,6 +429,9 @@ namespace Language_ru { PROGMEM Language_Str MSG_AMAX_A = _UxGT("Ускор.макс ") LCD_STR_A; PROGMEM Language_Str MSG_AMAX_B = _UxGT("Ускор.макс ") LCD_STR_B; PROGMEM Language_Str MSG_AMAX_C = _UxGT("Ускор.макс ") LCD_STR_C; + PROGMEM Language_Str MSG_AMAX_I = _UxGT("Ускор.макс ") LCD_STR_I; + PROGMEM Language_Str MSG_AMAX_J = _UxGT("Ускор.макс ") LCD_STR_J; + PROGMEM Language_Str MSG_AMAX_K = _UxGT("Ускор.макс ") LCD_STR_K; PROGMEM Language_Str MSG_AMAX_E = _UxGT("Ускор.макс ") LCD_STR_E; PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Ускор.макс *"); PROGMEM Language_Str MSG_A_RETRACT = _UxGT("Ускор.втягив."); @@ -380,6 +442,9 @@ namespace Language_ru { PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" шаг/мм"); PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" шаг/мм"); PROGMEM Language_Str MSG_C_STEPS = LCD_STR_C _UxGT(" шаг/мм"); + PROGMEM Language_Str MSG_I_STEPS = LCD_STR_I _UxGT(" шаг/мм"); + PROGMEM Language_Str MSG_J_STEPS = LCD_STR_J _UxGT(" шаг/мм"); + PROGMEM Language_Str MSG_K_STEPS = LCD_STR_K _UxGT(" шаг/мм"); PROGMEM Language_Str MSG_E_STEPS = _UxGT("E шаг/мм"); PROGMEM Language_Str MSG_EN_STEPS = _UxGT("* шаг/мм"); PROGMEM Language_Str MSG_TEMPERATURE = _UxGT("Температура"); @@ -402,10 +467,11 @@ namespace Language_ru { PROGMEM Language_Str MSG_CONTRAST = _UxGT("Контраст экрана"); PROGMEM Language_Str MSG_STORE_EEPROM = _UxGT("Сохранить настройки"); PROGMEM Language_Str MSG_LOAD_EEPROM = _UxGT("Загрузить настройки"); - PROGMEM Language_Str MSG_RESTORE_DEFAULTS = _UxGT("На базовые параметры"); #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_RESTORE_DEFAULTS = _UxGT("На базовые параметры"); PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("Инициализация EEPROM"); #else + PROGMEM Language_Str MSG_RESTORE_DEFAULTS = _UxGT("На базовые парам."); PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("Инициализ. EEPROM"); #endif PROGMEM Language_Str MSG_ERR_EEPROM_CRC = _UxGT("Сбой EEPROM: CRC"); @@ -414,7 +480,7 @@ namespace Language_ru { PROGMEM Language_Str MSG_SETTINGS_STORED = _UxGT("Параметры сохранены"); PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Обновление прошивки"); PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Сброс принтера"); - PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT(" Обновить"); + PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT(" Обновить"); PROGMEM Language_Str MSG_INFO_SCREEN = _UxGT("Главный экран"); PROGMEM Language_Str MSG_PREPARE = _UxGT("Подготовить"); PROGMEM Language_Str MSG_TUNE = _UxGT("Настроить"); @@ -541,10 +607,17 @@ namespace Language_ru { PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("Смещение X"); PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Смещение Y"); PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Смещение Z"); - PROGMEM Language_Str MSG_MOVE_NOZZLE_TO_BED = _UxGT("Двигать сопло к столу"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_MOVE_NOZZLE_TO_BED = _UxGT("Двигать сопло к столу"); + #else + PROGMEM Language_Str MSG_MOVE_NOZZLE_TO_BED = _UxGT("Двиг. сопло к столу"); + #endif PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Микрошаг X"); PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Микрошаг Y"); PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Микрошаг Z"); + PROGMEM Language_Str MSG_BABYSTEP_I = _UxGT("Микрошаг ") LCD_STR_I; + PROGMEM Language_Str MSG_BABYSTEP_J = _UxGT("Микрошаг ") LCD_STR_J; + PROGMEM Language_Str MSG_BABYSTEP_K = _UxGT("Микрошаг ") LCD_STR_K; PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Сумарно"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Сработал концевик"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Разогрев не удался"); @@ -552,6 +625,8 @@ namespace Language_ru { PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("УТЕЧКА ТЕПЛА"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("УТЕЧКА ТЕПЛА СТОЛА"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("УТЕЧКА ТЕПЛА КАМЕРЫ"); + PROGMEM Language_Str MSG_THERMAL_RUNAWAY_COOLER = _UxGT("УТЕЧКА ОХЛАЖДЕНИЯ"); + PROGMEM Language_Str MSG_COOLING_FAILED = _UxGT("ОХЛАДИТЬ НЕ УДАЛОСЬ"); PROGMEM Language_Str MSG_ERR_MAXTEMP = _UxGT("Ошибка: Т макс."); PROGMEM Language_Str MSG_ERR_MINTEMP = _UxGT("Ошибка: Т мин."); PROGMEM Language_Str MSG_HALTED = _UxGT("ПРИНТЕР ОСТАНОВЛЕН"); @@ -567,6 +642,7 @@ namespace Language_ru { PROGMEM Language_Str MSG_PROBE_COOLING = _UxGT("Охлаждение зонда..."); PROGMEM Language_Str MSG_CHAMBER_HEATING = _UxGT("Нагрев камеры..."); PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Охладжение камеры..."); + PROGMEM Language_Str MSG_LASER_COOLING = _UxGT("Охлаждение лазера..."); PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Калибровка Delta"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("Калибровать X"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Калибровать Y"); @@ -575,13 +651,12 @@ namespace Language_ru { PROGMEM Language_Str MSG_DELTA_SETTINGS = _UxGT("Настройки Delta"); PROGMEM Language_Str MSG_DELTA_AUTO_CALIBRATE = _UxGT("Авто калибровка"); PROGMEM Language_Str MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Высота Delta"); - #if LCD_WIDTH >= 20 - PROGMEM Language_Str MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Зондировать Z-смещение"); - PROGMEM Language_Str MSG_DELTA_DIAG_ROD = _UxGT("Стержень диагонали"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Зондировать Z-смещения"); #else PROGMEM Language_Str MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Зондир. Z-смещения"); - PROGMEM Language_Str MSG_DELTA_DIAG_ROD = _UxGT("Стержень диаг."); #endif + PROGMEM Language_Str MSG_DELTA_DIAG_ROD = _UxGT("Стержень диаг."); PROGMEM Language_Str MSG_DELTA_HEIGHT = _UxGT("Высота"); PROGMEM Language_Str MSG_DELTA_RADIUS = _UxGT("Радиус"); PROGMEM Language_Str MSG_INFO_MENU = _UxGT("О принтере"); @@ -597,6 +672,11 @@ namespace Language_ru { #endif PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Управление UBL"); PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Выравнивание сетки"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Зондирование выполнено"); + #else + PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Зондиров. выполнено"); + #endif PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Статистика принтера"); PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Данные платы"); @@ -617,14 +697,14 @@ namespace Language_ru { PROGMEM Language_Str MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Яркость подсветки"); PROGMEM Language_Str MSG_KILL_EXPECTED_PRINTER = _UxGT("Неверный принтер"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_INFO_PRINT_COUNT = _UxGT("Счётчик печати"); PROGMEM Language_Str MSG_INFO_PRINT_TIME = _UxGT("Общее время печати"); PROGMEM Language_Str MSG_INFO_PRINT_LONGEST = _UxGT("Наидольшее задание"); PROGMEM Language_Str MSG_INFO_PRINT_FILAMENT = _UxGT("Длина филамента"); #else - PROGMEM Language_Str MSG_INFO_PRINT_COUNT = _UxGT("Отпечатков"); - PROGMEM Language_Str MSG_INFO_PRINT_TIME = _UxGT("Всего"); + PROGMEM Language_Str MSG_INFO_PRINT_COUNT = _UxGT("Напечатано"); + PROGMEM Language_Str MSG_INFO_PRINT_TIME = _UxGT("Общее время"); PROGMEM Language_Str MSG_INFO_PRINT_LONGEST = _UxGT("Наидольшее"); PROGMEM Language_Str MSG_INFO_PRINT_FILAMENT = _UxGT("Выдавлено"); #endif @@ -637,6 +717,9 @@ namespace Language_ru { PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X Привод, %"); PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Y Привод, %"); PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Z Привод, %"); + PROGMEM Language_Str MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Привод, %"); + PROGMEM Language_Str MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Привод, %"); + PROGMEM Language_Str MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Привод, %"); PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("E Привод, %"); PROGMEM Language_Str MSG_ERROR_TMC = _UxGT("СБОЙ СВЯЗИ С TMC"); PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("Запись DAC в EEPROM"); @@ -749,11 +832,11 @@ namespace Language_ru { #endif PROGMEM Language_Str MSG_PASSWORD_REMOVED = _UxGT("Пароль удалён"); - PROGMEM Language_Str MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_1_LINE("Парковка...")); // // Filament Change screens show up to 3 lines on a 4-line display // ...or up to 2 lines on a 3-line display // + PROGMEM Language_Str MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_1_LINE("Парковка...")); #if LCD_HEIGHT >= 4 PROGMEM Language_Str MSG_ADVANCED_PAUSE_WAITING = _UxGT(MSG_3_LINE("Нажмите кнопку", "для продолжения", "печати")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_INIT = _UxGT(MSG_2_LINE("Ожидайте начала", "смены филамента")); @@ -803,8 +886,8 @@ namespace Language_ru { PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Мастер Z-зонда"); #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_PROBE_WIZARD_PROBING = _UxGT("Зондиров. контрольной точки Z"); - PROGMEM Language_Str MSG_PROBE_WIZARD_MOVING = _UxGT("Движение к точке зондирования"); + PROGMEM Language_Str MSG_PROBE_WIZARD_PROBING = _UxGT("Зондиров. контр. точки Z"); + PROGMEM Language_Str MSG_PROBE_WIZARD_MOVING = _UxGT("Движение к точке зондиров."); #else PROGMEM Language_Str MSG_PROBE_WIZARD_PROBING = _UxGT("Зондир.контр.точки Z"); PROGMEM Language_Str MSG_PROBE_WIZARD_MOVING = _UxGT("Движ. к точке зондир."); @@ -818,6 +901,11 @@ namespace Language_ru { PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Нижний правый"); PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Калибровка успешна"); PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Ошибка калибровки"); + + PROGMEM Language_Str MSG_DRIVER_BACKWARD = _UxGT(" драйвер назад"); + + PROGMEM Language_Str MSG_SD_CARD = _UxGT("SD Карта"); + PROGMEM Language_Str MSG_USB_DISK = _UxGT("USB Диск"); } #if FAN_COUNT == 1 diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index 4b3ce5aa96..717fa49b33 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -87,7 +87,6 @@ namespace Language_sk { PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Z Ofset"); PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Ofsety nastavené"); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Nastaviť začiatok"); - PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Asist. vyrovnanie"); PROGMEM Language_Str MSG_TRAMMING_WIZARD = _UxGT("Spriev. vyrovn."); PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Vyberte začiatok"); PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Posl. hodnota "); @@ -133,11 +132,11 @@ namespace Language_sk { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Posunúť osy"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Vyrovnanie podložky"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Vyrovnať podložku"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Vyrovnať rohy"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Zdvyhnite podl., kým sa nezopne sonda"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("Rohy sú vrámci odchyl. Vyrovnajte podl."); - PROGMEM Language_Str MSG_LEVEL_CORNERS_GOOD_POINTS = _UxGT("Dobré body: "); - PROGMEM Language_Str MSG_LEVEL_CORNERS_LAST_Z = _UxGT("Posl. Z: "); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Asist. vyrovnanie"); + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Zdvyhnite podl., kým sa nezopne sonda"); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("Rohy sú vrámci odchyl. Vyrovnajte podl."); + PROGMEM Language_Str MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Dobré body: "); + PROGMEM Language_Str MSG_BED_TRAMMING_LAST_Z = _UxGT("Posl. Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Ďalší roh"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Editor sieťe bodov"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Upraviť sieť bodov"); @@ -272,6 +271,7 @@ namespace Language_sk { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Posunúť o 0,1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Posunúť o 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Posunúť o 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Posunúť o 100mm"); PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Posunúť o 0,001in"); PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Posunúť o 0,01in"); PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Posunúť o 0,1in"); diff --git a/Marlin/src/lcd/language/language_sv.h b/Marlin/src/lcd/language/language_sv.h index 722443fb21..baa0f64506 100644 --- a/Marlin/src/lcd/language/language_sv.h +++ b/Marlin/src/lcd/language/language_sv.h @@ -75,7 +75,6 @@ namespace Language_sv { PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Sätt Hem Offset"); PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Offset Tillämpad"); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Sätt Origo"); - PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Assisterad justering"); PROGMEM Language_Str MSG_TRAMMING_WIZARD = _UxGT("Justerings Wizard"); PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Välj Origo"); PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Senaste värde "); @@ -122,11 +121,11 @@ namespace Language_sv { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Flytta Axel"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Bädd Nivellering"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Nivellera Bädd"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Nivellera Hörn"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Höj Bädd tills nästa Sond Triggad"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("Alla Hörn inom Tolerans. Nivellering Bädd"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_GOOD_POINTS = _UxGT("Bra Punkter: "); - PROGMEM Language_Str MSG_LEVEL_CORNERS_LAST_Z = _UxGT("Senaste Z: "); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Bädd Justering"); + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Höj Bädd tills nästa Sond Triggad"); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("Alla Hörn inom Tolerans. Nivellering Bädd"); + PROGMEM Language_Str MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Bra Punkter: "); + PROGMEM Language_Str MSG_BED_TRAMMING_LAST_Z = _UxGT("Senaste Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Nästa Hörn"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Nät Redigerare"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Redigera Nät"); @@ -260,6 +259,7 @@ namespace Language_sv { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Flytta 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Flytta 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Flytta 10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Flytta 100mm"); PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Flytta 0.001tum"); PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Flytta 0.01tum"); PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Flytta 0.1tum"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index 9d711ff376..bf218f136f 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -105,7 +105,7 @@ namespace Language_tr { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Eksen Hareketleri"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Tabla Hizalama"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Tabla Hizası"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Hizalama Köşeleri"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Hizalama Köşeleri"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Sonraki Köşe"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Mesh Editörü"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Mesh Düzenle"); @@ -235,6 +235,7 @@ namespace Language_tr { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("10mm"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Hız"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Z Mesafesi"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Nozul"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index be0e420a42..2e4a1b068c 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -34,7 +34,7 @@ namespace Language_uk { using namespace Language_en; // Inherit undefined strings from English constexpr uint8_t CHARSIZE = 2; - PROGMEM Language_Str LANGUAGE = _UxGT("Ukranian"); + PROGMEM Language_Str LANGUAGE = _UxGT("Ukrainian"); PROGMEM Language_Str WELCOME_MSG = MACHINE_NAME _UxGT(" Готовий."); PROGMEM Language_Str MSG_YES = _UxGT("ТАК"); @@ -71,6 +71,9 @@ namespace Language_uk { PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("Паркування X"); PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Паркування Y"); PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Паркування Z"); + PROGMEM Language_Str MSG_AUTO_HOME_I = _UxGT("Паркування ") LCD_STR_I; + PROGMEM Language_Str MSG_AUTO_HOME_J = _UxGT("Паркування ") LCD_STR_J; + PROGMEM Language_Str MSG_AUTO_HOME_K = _UxGT("Паркування ") LCD_STR_K; PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Авто Z-вирівнювання"); PROGMEM Language_Str MSG_ITERATION = _UxGT("G34 Ітерація: %i"); PROGMEM Language_Str MSG_DECREASING_ACCURACY = _UxGT("Зменьшення точності!"); @@ -82,11 +85,29 @@ namespace Language_uk { PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Висота спаду"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Встанов. зміщення дому"); + PROGMEM Language_Str MSG_HOME_OFFSET_X = _UxGT("Зміщення дому X"); + PROGMEM Language_Str MSG_HOME_OFFSET_Y = _UxGT("Зміщення дому Y"); + PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Зміщення дому Z"); + PROGMEM Language_Str MSG_HOME_OFFSET_I = _UxGT("Зміщення дому ") LCD_STR_I; + PROGMEM Language_Str MSG_HOME_OFFSET_J = _UxGT("Зміщення дому ") LCD_STR_J; + PROGMEM Language_Str MSG_HOME_OFFSET_K = _UxGT("Зміщення дому ") LCD_STR_K; #else - PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Встанов. зміщ. дому"); + PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Встан. зміщ. дому"); + PROGMEM Language_Str MSG_HOME_OFFSET_X = _UxGT("Зміщ. дому X"); + PROGMEM Language_Str MSG_HOME_OFFSET_Y = _UxGT("Зміщ. дому Y"); + PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Зміщ. дому Z"); + PROGMEM Language_Str MSG_HOME_OFFSET_I = _UxGT("Зміщ. дому ") LCD_STR_I; + PROGMEM Language_Str MSG_HOME_OFFSET_J = _UxGT("Зміщ. дому ") LCD_STR_J; + PROGMEM Language_Str MSG_HOME_OFFSET_K = _UxGT("Зміщ. дому ") LCD_STR_K; #endif PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Зміщення прийняті"); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Встановити нуль"); + PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Оберіть нуль"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Останнє значення "); + #else + PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Останнє знач. "); + #endif #if PREHEAT_COUNT PROGMEM Language_Str MSG_PREHEAT_1 = _UxGT("Нагрів ") PREHEAT_1_LABEL; PROGMEM Language_Str MSG_PREHEAT_1_H = _UxGT("Нагрів ") PREHEAT_1_LABEL " ~"; @@ -106,22 +127,30 @@ namespace Language_uk { #endif PROGMEM Language_Str MSG_PREHEAT_CUSTOM = _UxGT("Нагрів свого"); PROGMEM Language_Str MSG_COOLDOWN = _UxGT("Вимкнути нагрів"); + PROGMEM Language_Str MSG_CUTTER_FREQUENCY = _UxGT("Частота"); PROGMEM Language_Str MSG_LASER_MENU = _UxGT("Керування лазером"); + PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Керування шпінделем"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Потужність лазера"); - PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Керування шпінделем"); + PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Перемкн. шпіндель"); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Перемкнути вакуум"); + PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Перемкнути лазер"); + PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Потужн. шпінделя"); + PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Тестовий імпульс мс"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Перемкнути обдув"); #else - PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Потуж.лазера"); - PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Керув. шпінделем"); - #endif - PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Перемкнути шпіндель"); - PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Перемкнути лазер"); - #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Потуж. шпінделя"); - #else - PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Потуж. шпінд."); + PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Потужн. лазера"); + PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Перемк. шпінд."); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Перемк. вакуум"); + PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Перемкн. лазер"); + PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Потужн. шпінд."); + PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Тест. імп., мс"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Перемкн. обдув"); #endif + PROGMEM Language_Str MSG_LASER_ASSIST_TOGGLE = _UxGT("Керування обдувом"); + PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Помилка обдуву"); + PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Імпульс лазеру"); PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Шпіндель вперед"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Шпіндель назад"); @@ -132,13 +161,16 @@ namespace Language_uk { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Рух по осям"); PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Вирівнювання столу"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Вирівняти стіл"); - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Вирівняти кути"); + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Вирівняти кути"); #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Вгору до спрацювання зонду"); // not sure about this one + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Вгору до спрацюв. зонду"); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("Кути в межах. Вирів.столу"); #else - PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Вгору до спрацюв. зонду"); + PROGMEM Language_Str MSG_BED_TRAMMING_RAISE = _UxGT("Вгору до спрац.зонду"); + PROGMEM Language_Str MSG_BED_TRAMMING_IN_RANGE = _UxGT("Кути в межах. Вирівн"); #endif - PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("Кути в межах. Вирівнювання столу"); // Too long? + PROGMEM Language_Str MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Хороші точки: "); + PROGMEM Language_Str MSG_BED_TRAMMING_LAST_Z = _UxGT("Остання Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Наступний кут"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Зміщення по Z"); @@ -181,24 +213,25 @@ namespace Language_uk { PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Ручне введ. сітки"); PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Розм. шайбу і вимір."); #endif + PROGMEM Language_Str MSG_UBL_MESH_WIZARD = _UxGT("Майстер сіток UBL"); PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Вимірювання"); - PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Видалити і виміряти стіл"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Видалити і виміряти стіл"); + #else + PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Видали і вимір. стіл"); + #endif PROGMEM Language_Str MSG_UBL_MOVING_TO_NEXT = _UxGT("Рух до наступної"); PROGMEM Language_Str MSG_UBL_ACTIVATE_MESH = _UxGT("Активувати UBL"); PROGMEM Language_Str MSG_UBL_DEACTIVATE_MESH = _UxGT("Деактивувати UBL"); + PROGMEM Language_Str MSG_UBL_SET_TEMP_BED = LCD_STR_THERMOMETER _UxGT(" столу, ") LCD_STR_DEGREE "C"; + PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" столу,") LCD_STR_DEGREE "C"; + PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE "C"; + PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" сопла,") LCD_STR_DEGREE "C"; #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_UBL_SET_TEMP_BED = _UxGT("Температура столу"); - PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Температура свого столу"); - PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = _UxGT("Температура сопла"); - PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Температура свого сопла"); PROGMEM Language_Str MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Редагувати свою сітку"); PROGMEM Language_Str MSG_UBL_FINE_TUNE_MESH = _UxGT("Точне редагування сітки"); PROGMEM Language_Str MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Будувати свою сітку"); #else - PROGMEM Language_Str MSG_UBL_SET_TEMP_BED = LCD_STR_THERMOMETER _UxGT(" столу, ") LCD_STR_DEGREE "C"; - PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = LCD_STR_THERMOMETER _UxGT(" столу, ") LCD_STR_DEGREE "C"; - PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE "C"; - PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE "C"; PROGMEM Language_Str MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Редагувати свою"); PROGMEM Language_Str MSG_UBL_FINE_TUNE_MESH = _UxGT("Точне редаг. сітки"); PROGMEM Language_Str MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Будувати свою"); @@ -206,10 +239,8 @@ namespace Language_uk { PROGMEM Language_Str MSG_UBL_MESH_EDIT = _UxGT("Редагування сітки"); PROGMEM Language_Str MSG_UBL_DONE_EDITING_MESH = _UxGT("Сітка побудована"); PROGMEM Language_Str MSG_UBL_BUILD_MESH_MENU = _UxGT("Будувати сітку"); - #if PREHEAT_COUNT - PROGMEM Language_Str MSG_UBL_BUILD_MESH_M = _UxGT("Будувати сітку ($)"); - PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Підтвердити ($)"); - #endif + PROGMEM Language_Str MSG_UBL_BUILD_MESH_M = _UxGT("Будувати сітку ($)"); + PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Підтвердити ($)"); PROGMEM Language_Str MSG_UBL_BUILD_COLD_MESH = _UxGT("Буд. холодну сітку"); PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Встан.висоту сітки"); PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Висота"); @@ -219,7 +250,7 @@ namespace Language_uk { PROGMEM Language_Str MSG_G26_HEATING_BED = _UxGT("G26 нагрів столу"); PROGMEM Language_Str MSG_G26_HEATING_NOZZLE = _UxGT("G26 нагрів сопла"); PROGMEM Language_Str MSG_G26_MANUAL_PRIME = _UxGT("Ручне грунтування"); - PROGMEM Language_Str MSG_G26_FIXED_LENGTH = _UxGT("Фікс. довж. грунт."); // ґ is not supported + PROGMEM Language_Str MSG_G26_FIXED_LENGTH = _UxGT("Фікс. довж. грунт."); PROGMEM Language_Str MSG_G26_PRIME_DONE = _UxGT("Грунтув. виконане"); PROGMEM Language_Str MSG_G26_CANCELED = _UxGT("G26 скасовано"); PROGMEM Language_Str MSG_G26_LEAVING = _UxGT("Вийти з G26"); @@ -240,7 +271,7 @@ namespace Language_uk { PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Зберегти зовні"); PROGMEM Language_Str MSG_UBL_INFO_UBL = _UxGT("Інформація по UBL"); #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Обсяг заповнювача"); + PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Обсяг заповнюв."); #else PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Обсяг заповн."); #endif @@ -251,12 +282,9 @@ namespace Language_uk { PROGMEM Language_Str MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Анулювати найближчу"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_UBL_FINE_TUNE_ALL = _UxGT("Точно налаштувати все"); - #else - PROGMEM Language_Str MSG_UBL_FINE_TUNE_ALL = _UxGT("Точно налашт. все"); - #endif - #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_UBL_FINE_TUNE_CLOSEST = _UxGT("Точно налашт.найближчу"); #else + PROGMEM Language_Str MSG_UBL_FINE_TUNE_ALL = _UxGT("Точно налашт. все"); PROGMEM Language_Str MSG_UBL_FINE_TUNE_CLOSEST = _UxGT("Точно найближчу"); #endif PROGMEM Language_Str MSG_UBL_STORAGE_MESH_MENU = _UxGT("Збереження сітки"); @@ -300,7 +328,7 @@ namespace Language_uk { #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Передустановка світла #2"); #else - PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Передустан. світла #2"); + PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Передуст. світла #2"); #endif PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Яскравість"); PROGMEM Language_Str MSG_CUSTOM_LEDS = _UxGT("Своє світло"); @@ -315,6 +343,9 @@ namespace Language_uk { PROGMEM Language_Str MSG_MOVE_X = _UxGT("Рух по X"); PROGMEM Language_Str MSG_MOVE_Y = _UxGT("Рух по Y"); PROGMEM Language_Str MSG_MOVE_Z = _UxGT("Рух по Z"); + PROGMEM Language_Str MSG_MOVE_I = _UxGT("Рух по ") LCD_STR_I; + PROGMEM Language_Str MSG_MOVE_J = _UxGT("Рух по ") LCD_STR_J; + PROGMEM Language_Str MSG_MOVE_K = _UxGT("Рух по ") LCD_STR_K; PROGMEM Language_Str MSG_MOVE_E = _UxGT("Екструдер"); PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Екструдер *"); PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("Сопло дуже холодне"); @@ -322,6 +353,7 @@ namespace Language_uk { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Рух 0.1мм"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Рух 1мм"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Рух 10мм"); + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Рух 100mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Швидкість"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Z Столу"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Сопло, ") LCD_STR_DEGREE "C"; @@ -330,17 +362,26 @@ namespace Language_uk { PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Сопло очікує"); PROGMEM Language_Str MSG_BED = _UxGT("Стіл, ") LCD_STR_DEGREE "C"; PROGMEM Language_Str MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_COOLER = _UxGT("Охолодження лазеру"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Перемк. охолодж."); + #else + PROGMEM Language_Str MSG_COOLER = _UxGT("Охолодж. лазеру"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Перемк.охолод"); + #endif + PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Безпека потоку"); + PROGMEM Language_Str MSG_LASER = _UxGT("Лазер"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Швидк. вент."); PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Швидк. вент. ~"); #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Збереж. швидк. вент. ~"); + PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Збереж.швидк.вент. ~"); PROGMEM Language_Str MSG_EXTRA_FAN_SPEED_N = _UxGT("Дод. швидк. вент. ~"); #else PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Збереж. вент. ~"); PROGMEM Language_Str MSG_EXTRA_FAN_SPEED_N = _UxGT("Додат.вент. ~"); #endif - PROGMEM Language_Str MSG_CONTROLLER_FAN = _UxGT("Вент. контролера"); PROGMEM Language_Str MSG_EXTRA_FAN_SPEED = _UxGT("Дод. швидк. вент."); + PROGMEM Language_Str MSG_CONTROLLER_FAN = _UxGT("Вент. контролера"); PROGMEM Language_Str MSG_CONTROLLER_FAN_IDLE_SPEED = _UxGT("Холості оберти"); PROGMEM Language_Str MSG_CONTROLLER_FAN_AUTO_ON = _UxGT("Авто-режим"); PROGMEM Language_Str MSG_CONTROLLER_FAN_SPEED = _UxGT("Робочі оберти"); @@ -352,8 +393,8 @@ namespace Language_uk { PROGMEM Language_Str MSG_MAX = " " LCD_STR_THERMOMETER ", " LCD_STR_DEGREE _UxGT("С макс"); PROGMEM Language_Str MSG_FACTOR = " " LCD_STR_THERMOMETER _UxGT(" Фактор"); PROGMEM Language_Str MSG_AUTOTEMP = _UxGT("Автотемпер."); - PROGMEM Language_Str MSG_LCD_ON = _UxGT("Увімк"); - PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Вимк."); + PROGMEM Language_Str MSG_LCD_ON = _UxGT("Увім"); + PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Вимк"); PROGMEM Language_Str MSG_PID_AUTOTUNE = _UxGT("Автопідбір PID"); PROGMEM Language_Str MSG_PID_AUTOTUNE_E = _UxGT("Автопідбір PID *"); @@ -369,6 +410,9 @@ namespace Language_uk { PROGMEM Language_Str MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-ривок"); PROGMEM Language_Str MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-ривок"); PROGMEM Language_Str MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-ривок"); + PROGMEM Language_Str MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-ривок"); + PROGMEM Language_Str MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-ривок"); + PROGMEM Language_Str MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-ривок"); PROGMEM Language_Str MSG_VE_JERK = _UxGT("Ve-ривок"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Відхилення вузла"); @@ -379,14 +423,24 @@ namespace Language_uk { PROGMEM Language_Str MSG_VMAX_A = _UxGT("Швидк.макс ") LCD_STR_A; PROGMEM Language_Str MSG_VMAX_B = _UxGT("Швидк.макс ") LCD_STR_B; PROGMEM Language_Str MSG_VMAX_C = _UxGT("Швидк.макс ") LCD_STR_C; + PROGMEM Language_Str MSG_VMAX_I = _UxGT("Швидк.макс ") LCD_STR_I; + PROGMEM Language_Str MSG_VMAX_J = _UxGT("Швидк.макс ") LCD_STR_J; + PROGMEM Language_Str MSG_VMAX_K = _UxGT("Швидк.макс ") LCD_STR_K; PROGMEM Language_Str MSG_VMAX_E = _UxGT("Швидк.макс ") LCD_STR_E; PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Швидк.макс *"); - PROGMEM Language_Str MSG_VMIN = _UxGT("Швидк.мін"); - PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Переміщення мін"); + PROGMEM Language_Str MSG_VMIN = _UxGT("Швидк. мін"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Переміщення мін"); + #else + PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Переміщ. мін"); + #endif PROGMEM Language_Str MSG_ACCELERATION = _UxGT("Прискорення, мм/с2"); PROGMEM Language_Str MSG_AMAX_A = _UxGT("Приск.макс ") LCD_STR_A; PROGMEM Language_Str MSG_AMAX_B = _UxGT("Приск.макс ") LCD_STR_B; PROGMEM Language_Str MSG_AMAX_C = _UxGT("Приск.макс ") LCD_STR_C; + PROGMEM Language_Str MSG_AMAX_I = _UxGT("Приск.макс ") LCD_STR_I; + PROGMEM Language_Str MSG_AMAX_J = _UxGT("Приск.макс ") LCD_STR_J; + PROGMEM Language_Str MSG_AMAX_K = _UxGT("Приск.макс ") LCD_STR_K; PROGMEM Language_Str MSG_AMAX_E = _UxGT("Приск.макс ") LCD_STR_E; PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Приск.макс *"); PROGMEM Language_Str MSG_A_RETRACT = _UxGT("Приск.втягув."); @@ -397,6 +451,9 @@ namespace Language_uk { PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" кроків/мм"); PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" кроків/мм"); PROGMEM Language_Str MSG_C_STEPS = LCD_STR_C _UxGT(" кроків/мм"); + PROGMEM Language_Str MSG_I_STEPS = LCD_STR_I _UxGT(" кроків/мм"); + PROGMEM Language_Str MSG_J_STEPS = LCD_STR_J _UxGT(" кроків/мм"); + PROGMEM Language_Str MSG_K_STEPS = LCD_STR_K _UxGT(" кроків/мм"); PROGMEM Language_Str MSG_E_STEPS = _UxGT("E кроків/мм"); PROGMEM Language_Str MSG_EN_STEPS = _UxGT("* кроків/мм"); PROGMEM Language_Str MSG_TEMPERATURE = _UxGT("Температура"); @@ -426,7 +483,7 @@ namespace Language_uk { PROGMEM Language_Str MSG_SETTINGS_STORED = _UxGT("Параметри збережені"); PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Оновити SD-картку"); PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Зкинути принтер"); - PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT(" Поновити"); + PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT(" Поновити"); PROGMEM Language_Str MSG_INFO_SCREEN = _UxGT("Головний екран"); PROGMEM Language_Str MSG_PREPARE = _UxGT("Підготувати"); PROGMEM Language_Str MSG_TUNE = _UxGT("Підлаштування"); @@ -472,8 +529,6 @@ namespace Language_uk { #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_CONTROL_RETRACT = _UxGT("Втягування, мм"); PROGMEM Language_Str MSG_CONTROL_RETRACT_SWAP = _UxGT("Зміна втягув.,мм"); - PROGMEM Language_Str MSG_CONTROL_RETRACTF = _UxGT("Ретракт V"); - PROGMEM Language_Str MSG_CONTROL_RETRACT_ZHOP = _UxGT("Стрибок, мм"); PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER = _UxGT("Повернення, мм"); PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAP = _UxGT("Поверн.зміни, мм"); PROGMEM Language_Str MSG_AUTORETRACT = _UxGT("Автовтягування"); @@ -556,6 +611,9 @@ namespace Language_uk { PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Мікрокрок X"); PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Мікрокрок Y"); PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Мікрокрок Z"); + PROGMEM Language_Str MSG_BABYSTEP_I = _UxGT("Мікрокрок ") LCD_STR_I; + PROGMEM Language_Str MSG_BABYSTEP_J = _UxGT("Мікрокрок ") LCD_STR_J; + PROGMEM Language_Str MSG_BABYSTEP_K = _UxGT("Мікрокрок ") LCD_STR_K; PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Сумарно"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Кінцевик спрацював"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Збій нагріву"); @@ -563,7 +621,13 @@ namespace Language_uk { PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("ВИТІК ТЕПЛА"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("ВИТІК ТЕПЛА СТОЛУ"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("ВИТІК ТЕПЛА КАМЕРИ"); - PROGMEM Language_Str MSG_ERR_MAXTEMP = _UxGT("МАКСИМАЛЬНА Т"); + PROGMEM Language_Str MSG_THERMAL_RUNAWAY_COOLER = _UxGT("ВИТІК ОХОЛОДЖЕННЯ"); + #if LCD_WIDTH >= 20 + PROGMEM Language_Str MSG_COOLING_FAILED = _UxGT("ОХОЛОДЖЕННЯ НЕ ВДАЛОСЬ"); + #else + PROGMEM Language_Str MSG_COOLING_FAILED = _UxGT("ОХОЛОДЖ. НЕ ВДАЛОСЬ"); + #endif + PROGMEM Language_Str MSG_ERR_MAXTEMP = _UxGT("МАКСИМАЛЬНА Т") LCD_STR_DEGREE; PROGMEM Language_Str MSG_ERR_MINTEMP = _UxGT("МІНІМАЛЬНА Т") LCD_STR_DEGREE; PROGMEM Language_Str MSG_HALTED = _UxGT("ПРИНТЕР ЗУПИНЕНО"); PROGMEM Language_Str MSG_PLEASE_RESET = _UxGT("Перезавантажте"); @@ -573,18 +637,20 @@ namespace Language_uk { PROGMEM Language_Str MSG_HEATING = _UxGT("Нагрівання..."); PROGMEM Language_Str MSG_COOLING = _UxGT("Охолодження..."); PROGMEM Language_Str MSG_BED_HEATING = _UxGT("Нагрів столу..."); - PROGMEM Language_Str MSG_CHAMBER_HEATING = _UxGT("Нагрів камери..."); PROGMEM Language_Str MSG_PROBE_HEATING = _UxGT("Нагрів зонду..."); - PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Калібрування Delta"); + PROGMEM Language_Str MSG_CHAMBER_HEATING = _UxGT("Нагрів камери..."); #if LCD_WIDTH >= 20 PROGMEM Language_Str MSG_BED_COOLING = _UxGT("Охолодження столу..."); - PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Охолодження камери..."); PROGMEM Language_Str MSG_PROBE_COOLING = _UxGT("Охолодження зонду..."); + PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Охолодження камери..."); + PROGMEM Language_Str MSG_LASER_COOLING = _UxGT("Охолодження лазеру..."); #else - PROGMEM Language_Str MSG_BED_COOLING = _UxGT("Охол. столу..."); - PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Охол. камери..."); - PROGMEM Language_Str MSG_PROBE_COOLING = _UxGT("Охол. зонду..."); + PROGMEM Language_Str MSG_BED_COOLING = _UxGT("Охолодж. столу..."); + PROGMEM Language_Str MSG_PROBE_COOLING = _UxGT("Охолодж. зонду..."); + PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Охолодж. камери..."); + PROGMEM Language_Str MSG_LASER_COOLING = _UxGT("Охолодж. лазеру..."); #endif + PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Калібрування Delta"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("Калібрувати X"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Калібрувати Y"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_Z = _UxGT("Калібрувати Z"); @@ -611,6 +677,11 @@ namespace Language_uk { #endif PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("UBL"); PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Вирівнювання сітки"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Зондування сітки виконано"); + #else + PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Зондування виконано"); + #endif PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Статистика принтера"); PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Про плату"); @@ -651,6 +722,9 @@ namespace Language_uk { PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("Драйвер X, %"); PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Драйвер Y, %"); PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Драйвер Z, %"); + PROGMEM Language_Str MSG_DAC_PERCENT_I = _UxGT("Драйвер ") AXIS4_STR _UxGT(", %"); + PROGMEM Language_Str MSG_DAC_PERCENT_J = _UxGT("Драйвер ") AXIS5_STR _UxGT(", %"); + PROGMEM Language_Str MSG_DAC_PERCENT_K = _UxGT("Драйвер ") AXIS6_STR _UxGT(", %"); PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("Драйвер E, %"); PROGMEM Language_Str MSG_ERROR_TMC = _UxGT("ЗБІЙ ЗВ'ЯЗКУ З TMC"); PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("Запис ЦАП у EEPROM"); @@ -687,19 +761,19 @@ namespace Language_uk { #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Завантажити в сопло"); #else - PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Завантаж. в сопло"); + PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Завант. в сопло"); #endif PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("MMU Звільнити"); PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("MMU Звільнити ~"); PROGMEM Language_Str MSG_MMU2_UNLOAD_FILAMENT = _UxGT("MMU Вивантажити"); - PROGMEM Language_Str MSG_MMU2_LOADING_FILAMENT = _UxGT("MMU Завантаж. %i..."); - PROGMEM Language_Str MSG_MMU2_EJECTING_FILAMENT = _UxGT("MMU Звільнення..."); - PROGMEM Language_Str MSG_MMU2_UNLOADING_FILAMENT = _UxGT("MMU Вивантаження..."); - PROGMEM Language_Str MSG_MMU2_ALL = _UxGT("MMU Все"); - PROGMEM Language_Str MSG_MMU2_FILAMENT_N = _UxGT("MMU Пруток ~"); - PROGMEM Language_Str MSG_MMU2_RESET = _UxGT("MMU Перезапуск"); + PROGMEM Language_Str MSG_MMU2_LOADING_FILAMENT = _UxGT("Завантаж. %i..."); + PROGMEM Language_Str MSG_MMU2_EJECTING_FILAMENT = _UxGT("Викидання прутка..."); + PROGMEM Language_Str MSG_MMU2_UNLOADING_FILAMENT = _UxGT("Вивантаження..."); + PROGMEM Language_Str MSG_MMU2_ALL = _UxGT("Все"); + PROGMEM Language_Str MSG_MMU2_FILAMENT_N = _UxGT("Пруток ~"); + PROGMEM Language_Str MSG_MMU2_RESET = _UxGT("Перезапуск MMU"); PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("MMU Перезапуск..."); - PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("MMU Видаліть, натисніть"); + PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Видаліть, натисніть"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_MIX = _UxGT("Змішування"); @@ -710,7 +784,11 @@ namespace Language_uk { PROGMEM Language_Str MSG_MIXER = _UxGT("Змішувач"); PROGMEM Language_Str MSG_GRADIENT = _UxGT("Градієнт"); PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Повний градієнт"); - PROGMEM Language_Str MSG_TOGGLE_MIX = _UxGT("Змішування переключ."); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_TOGGLE_MIX = _UxGT("Переключити змішування"); + #else + PROGMEM Language_Str MSG_TOGGLE_MIX = _UxGT("Переключ.змішування"); + #endif PROGMEM Language_Str MSG_CYCLE_MIX = _UxGT("Циклічне змішування"); PROGMEM Language_Str MSG_GRADIENT_MIX = _UxGT("Градієнт змішування"); PROGMEM Language_Str MSG_REVERSE_GRADIENT = _UxGT("Змінити градієнт"); @@ -721,14 +799,13 @@ namespace Language_uk { PROGMEM Language_Str MSG_RESET_VTOOLS = _UxGT("Зкидання В-інструментів"); #else PROGMEM Language_Str MSG_ACTIVE_VTOOL = _UxGT("Актив. В-інструм."); - PROGMEM Language_Str MSG_GRADIENT_ALIAS = _UxGT("Псевдонім В-інструм."); + PROGMEM Language_Str MSG_GRADIENT_ALIAS = _UxGT("Псевдонім В-інструм"); PROGMEM Language_Str MSG_RESET_VTOOLS = _UxGT("Зкидання В-інструм."); #endif PROGMEM Language_Str MSG_START_VTOOL = _UxGT("Початок В-інструменту"); PROGMEM Language_Str MSG_END_VTOOL = _UxGT("Кінець В-інструменту"); PROGMEM Language_Str MSG_COMMIT_VTOOL = _UxGT("Змішати В-інструменти"); PROGMEM Language_Str MSG_VTOOLS_RESET = _UxGT("В-інструменти зкинуті"); - PROGMEM Language_Str MSG_START_Z = _UxGT("Початок Z:"); PROGMEM Language_Str MSG_END_Z = _UxGT(" Кінець Z:"); @@ -756,12 +833,12 @@ namespace Language_uk { PROGMEM Language_Str MSG_REMINDER_SAVE_SETTINGS = _UxGT("Не забудь зберегти!"); PROGMEM Language_Str MSG_PASSWORD_REMOVED = _UxGT("Пароль видалений"); - PROGMEM Language_Str MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_1_LINE("Паркування...")); // // Filament Change screens show up to 3 lines on a 4-line display // ...or up to 2 lines on a 3-line display // + PROGMEM Language_Str MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_1_LINE("Паркування...")); #if LCD_HEIGHT >= 4 // Up to 3 lines allowed PROGMEM Language_Str MSG_ADVANCED_PAUSE_WAITING = _UxGT(MSG_3_LINE("Натисніть кнопку", "для продовження", "друку")); @@ -828,6 +905,11 @@ namespace Language_uk { PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Нижній правий"); PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Калібрування успішне"); PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Збій калібрування"); + + PROGMEM Language_Str MSG_DRIVER_BACKWARD = _UxGT(" драйвер назад"); + + PROGMEM Language_Str MSG_SD_CARD = _UxGT("SD Картка"); + PROGMEM Language_Str MSG_USB_DISK = _UxGT("USB Диск"); } #if FAN_COUNT == 1 diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index f0b7f732ed..013a915921 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -90,7 +90,7 @@ namespace Language_vi { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Di chuyển trục"); // Move axis PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("San Lấp Bàn"); // Bed Leveling PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Làm bằng mặt bàn"); // Level bed - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Làm bằng góc bàn"); // Level corners + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("Làm bằng góc bàn"); // Level corners PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Góc tiếp theo"); // Next corner PROGMEM Language_Str MSG_EDITING_STOPPED = _UxGT("Chỉnh lưới đã dừng"); // Mesh Editing Stopped PROGMEM Language_Str MSG_MESH_X = _UxGT("Mục lục X"); // Index X @@ -205,6 +205,7 @@ namespace Language_vi { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Di chuyển 0.1mm"); // Move 0.1mm PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Di chuyển 1mm"); // Move 1mm PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Di chuyển 10mm"); // Move 10mm + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("Di chuyển 100mm"); // Move 100mm PROGMEM Language_Str MSG_SPEED = _UxGT("Tốc độ"); // Speed PROGMEM Language_Str MSG_BED_Z = _UxGT("Z Bàn"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Đầu phun"); // Nozzle diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index 98f7704efc..31d2623604 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -31,7 +31,7 @@ namespace Language_zh_CN { using namespace Language_en; // Inherit undefined strings from English constexpr uint8_t CHARSIZE = 3; - PROGMEM Language_Str LANGUAGE = _UxGT("简体中文"); + PROGMEM Language_Str LANGUAGE = _UxGT("Simplified Chinese"); PROGMEM Language_Str WELCOME_MSG = MACHINE_NAME _UxGT("已就绪."); //" ready." PROGMEM Language_Str MSG_MARLIN = _UxGT("马林"); @@ -100,7 +100,7 @@ namespace Language_zh_CN { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("移动轴"); //"Move axis" PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("调平热床"); //"Bed leveling" PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("调平热床"); //"Level bed" - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("调平边角"); // "Level corners" + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("调平边角"); // "Bed Tramming" PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("下个边角"); // "Next corner" PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("网格编辑器"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("编辑网格"); // "Edit Mesh" @@ -230,6 +230,7 @@ namespace Language_zh_CN { PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("移动 0.1 mm"); //"Move 0.1mm" PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("移动 1 mm"); //"Move 1mm" PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("移动 10 mm"); //"Move 10mm" + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("移动 100 mm"); //"Move 100mm" PROGMEM Language_Str MSG_SPEED = _UxGT("速率"); //"Speed" PROGMEM Language_Str MSG_BED_Z = _UxGT("热床Z"); //"Bed Z" PROGMEM Language_Str MSG_NOZZLE = _UxGT("喷嘴"); //"Nozzle" 噴嘴 diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 0ada34a476..f162536132 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -98,7 +98,7 @@ namespace Language_zh_TW { PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("移動軸"); //"Move axis" PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("調平熱床"); //"Bed leveling" PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("調平熱床"); //"Level bed" - PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("調平邊角"); // "Level corners" + PROGMEM Language_Str MSG_BED_TRAMMING = _UxGT("調平邊角"); // "Bed Tramming" PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("下個邊角"); // "Next corner" PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("網格編輯器"); //"Mesh Editor" PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("編輯網格"); // "Edit Mesh" @@ -223,11 +223,12 @@ namespace Language_zh_TW { PROGMEM Language_Str MSG_MOVE_Z = _UxGT("移動Z"); //"Move Z" PROGMEM Language_Str MSG_MOVE_E = _UxGT("擠出機"); //"Extruder" PROGMEM Language_Str MSG_MOVE_EN = _UxGT("擠出機 *"); //"Extruder *" - PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("噴嘴溫度不夠"); //"Hotend too cold" + PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("噴嘴溫度不夠"); //"Hotend too cold" PROGMEM Language_Str MSG_MOVE_N_MM = _UxGT("移動 %s mm"); //"Move 0.025mm" - PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("移動 0.1 mm"); //"Move 0.1mm" - PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("移動 1 mm"); //"Move 1mm" + PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("移動 0.1 mm"); //"Move 0.1mm" + PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("移動 1 mm"); //"Move 1mm" PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("移動 10 mm"); //"Move 10mm" + PROGMEM Language_Str MSG_MOVE_100MM = _UxGT("移動 100 mm"); //"Move 100mm" PROGMEM Language_Str MSG_SPEED = _UxGT("速率"); //"Speed" PROGMEM Language_Str MSG_BED_Z = _UxGT("熱床Z"); //"Bed Z" PROGMEM Language_Str MSG_NOZZLE = " " LCD_STR_THERMOMETER _UxGT(" 噴嘴"); //"Nozzle" 噴嘴 diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index 32f425168f..eef27dbdb4 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -41,6 +41,7 @@ * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) */ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) { + const uint8_t prop = USE_WIDE_GLYPH ? 2 : 1; uint8_t *p = (uint8_t*)pstr; int8_t n = maxlen; while (n > 0) { @@ -73,10 +74,27 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const i } else { lcd_put_wchar(ch); - n--; + n -= ch > 255 ? prop : 1; } } return n; } +// Calculate UTF8 width with a simple check +int calculateWidth(PGM_P const pstr) { + if (!USE_WIDE_GLYPH) return utf8_strlen_P(pstr) * MENU_FONT_WIDTH; + const uint8_t prop = 2; + uint8_t *p = (uint8_t*)pstr; + int n = 0; + + do { + wchar_t ch; + p = get_utf8_value_cb(p, read_byte_rom, &ch); + if (!ch) break; + n += (ch > 255) ? prop : 1; + } while (1); + + return n * MENU_FONT_WIDTH; +} + #endif // HAS_WIRED_LCD diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index fe856535b0..8bfd72e9f5 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -76,8 +76,10 @@ #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT) #define INFO_FONT_WIDTH 6 + // Graphical LCD uses the menu font size for cursor positioning #define LCD_COL_X(col) (( (col)) * (MENU_FONT_WIDTH)) - #define LCD_ROW_Y(row) ((1 + (row)) * (MENU_FONT_HEIGHT)) + #define LCD_ROW_Y(row) ((1 + (row)) * (MENU_LINE_HEIGHT)) + #define LCD_COL_X_RJ(len) (LCD_WIDTH - LCD_COL_X(len)) #else @@ -94,13 +96,17 @@ #define LCD_PIXEL_WIDTH LCD_WIDTH #define LCD_PIXEL_HEIGHT LCD_HEIGHT + // Character LCD uses direct cursor positioning #define LCD_COL_X(col) (col) #define LCD_ROW_Y(row) (row) + #define LCD_COL_X_RJ(len) (LCD_PIXEL_WIDTH - LCD_COL_X(len)) #endif -#define LCD_COL_X_RJ(len) (LCD_PIXEL_WIDTH - LCD_COL_X(len)) -#define LCD_BOTTOM_ROW (LCD_PIXEL_HEIGHT - 1) +#ifndef MENU_LINE_HEIGHT + #define MENU_LINE_HEIGHT MENU_FONT_HEIGHT +#endif + #define SETCURSOR(col, row) lcd_moveto(LCD_COL_X(col), LCD_ROW_Y(row)) #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_COL_X_RJ(len), LCD_ROW_Y(row)) #define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr) @@ -172,3 +178,5 @@ inline int lcd_put_wchar(const lcd_uint_t col, const lcd_uint_t row, const wchar lcd_moveto(col, row); return lcd_put_wchar(c); } + +int calculateWidth(PGM_P const pstr); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index cff6e19354..cf8d7343c6 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -47,7 +47,7 @@ MarlinUI ui; #endif #if ENABLED(DWIN_CREALITY_LCD) - #include "dwin/e3v2/dwin.h" + #include "e3v2/creality/dwin.h" #endif #if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL @@ -65,15 +65,8 @@ MarlinUI ui; constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_STATUS_MESSAGE - #if HAS_WIRED_LCD - #if ENABLED(STATUS_MESSAGE_SCROLLING) - uint8_t MarlinUI::status_scroll_offset; // = 0 - constexpr uint8_t MAX_MESSAGE_LENGTH = _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH)); - #else - constexpr uint8_t MAX_MESSAGE_LENGTH = MAX_LANG_CHARSIZE * (LCD_WIDTH); - #endif - #else - constexpr uint8_t MAX_MESSAGE_LENGTH = 63; + #if BOTH(HAS_WIRED_LCD, STATUS_MESSAGE_SCROLLING) + uint8_t MarlinUI::status_scroll_offset; // = 0 #endif char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1]; uint8_t MarlinUI::alert_level; // = 0 @@ -88,6 +81,25 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_MULTI_LANGUAGE uint8_t MarlinUI::language; // Initialized by settings.load() + void MarlinUI::set_language(const uint8_t lang) { + if (lang < NUM_LANGUAGES) { + language = lang; + TERN_(HAS_MARLINUI_U8GLIB, update_language_font()); + return_to_status(); + refresh(); + } + } +#endif + +#if HAS_LCD_BRIGHTNESS + uint8_t MarlinUI::brightness = DEFAULT_LCD_BRIGHTNESS; + bool MarlinUI::backlight = true; + + void MarlinUI::set_brightness(const uint8_t value) { + backlight = !!value; + if (backlight) brightness = constrain(value, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS); + // Set brightness on enabled LCD here + } #endif #if ENABLED(SOUND_MENU_ITEM) @@ -120,1181 +132,1173 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; } #endif +#if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) + bool MarlinUI::lcd_clicked; +#endif + #if HAS_WIRED_LCD -#if HAS_MARLINUI_U8GLIB - #include "dogm/marlinui_DOGM.h" -#endif - -#include "lcdprint.h" - -#include "../sd/cardreader.h" - -#include "../module/temperature.h" -#include "../module/planner.h" -#include "../module/motion.h" - -#if HAS_LCD_MENU - #include "../module/settings.h" -#endif - -#if ENABLED(AUTO_BED_LEVELING_UBL) - #include "../feature/bedlevel/bedlevel.h" -#endif - -#if HAS_TRINAMIC_CONFIG - #include "../feature/tmc_util.h" -#endif - -#if HAS_ADC_BUTTONS - #include "../module/thermistor/thermistors.h" -#endif - -#if HAS_POWER_MONITOR - #include "../feature/power_monitor.h" -#endif - -#if HAS_ENCODER_ACTION - volatile uint8_t MarlinUI::buttons; - #if HAS_SLOW_BUTTONS - volatile uint8_t MarlinUI::slow_buttons; + #if HAS_MARLINUI_U8GLIB + #include "dogm/marlinui_DOGM.h" #endif - #if HAS_TOUCH_BUTTONS - #include "touch/touch_buttons.h" - bool MarlinUI::on_edit_screen = false; - #endif -#endif -#if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS > 0 - bool MarlinUI::defer_return_to_status; -#endif - -uint8_t MarlinUI::lcd_status_update_delay = 1; // First update one loop delayed - -#if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) - millis_t MarlinUI::next_filament_display; // = 0 -#endif - -millis_t MarlinUI::next_button_update_ms; // = 0 - -#if HAS_MARLINUI_U8GLIB - bool MarlinUI::drawing_screen, MarlinUI::first_page; // = false -#endif - -// Encoder Handling -#if HAS_ENCODER_ACTION - uint32_t MarlinUI::encoderPosition; - volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update -#endif - -#if ENABLED(SDSUPPORT) + #include "lcdprint.h" #include "../sd/cardreader.h" - #if MARLINUI_SCROLL_NAME - uint8_t MarlinUI::filename_scroll_pos, MarlinUI::filename_scroll_max; + #include "../module/temperature.h" + #include "../module/planner.h" + #include "../module/motion.h" + + #if HAS_LCD_MENU + #include "../module/settings.h" #endif - const char * MarlinUI::scrolled_filename(CardReader &theCard, const uint8_t maxlen, uint8_t hash, const bool doScroll) { - const char *outstr = theCard.longest_filename(); - if (theCard.longFilename[0]) { - #if MARLINUI_SCROLL_NAME - if (doScroll) { - for (uint8_t l = FILENAME_LENGTH; l--;) - hash = ((hash << 1) | (hash >> 7)) ^ theCard.filename[l]; // rotate, xor - static uint8_t filename_scroll_hash; - if (filename_scroll_hash != hash) { // If the hash changed... - filename_scroll_hash = hash; // Save the new hash - filename_scroll_max = _MAX(0, utf8_strlen(theCard.longFilename) - maxlen); // Update the scroll limit - filename_scroll_pos = 0; // Reset scroll to the start - lcd_status_update_delay = 8; // Don't scroll right away - } - // Advance byte position corresponding to filename_scroll_pos char position - outstr += TERN(UTF_FILENAME_SUPPORT, utf8_byte_pos_by_char_num(outstr, filename_scroll_pos), filename_scroll_pos); - } - #else - theCard.longFilename[ - TERN(UTF_FILENAME_SUPPORT, utf8_byte_pos_by_char_num(theCard.longFilename, maxlen), maxlen) - ] = '\0'; // cutoff at screen edge - #endif - } - return outstr; - } - -#endif - -#if HAS_LCD_MENU - #include "menu/menu.h" - - screenFunc_t MarlinUI::currentScreen; // Initialized in CTOR - bool MarlinUI::screen_changed; - - #if ENABLED(ENCODER_RATE_MULTIPLIER) - bool MarlinUI::encoderRateMultiplierEnabled; - millis_t MarlinUI::lastEncoderMovementMillis = 0; - void MarlinUI::enable_encoder_multiplier(const bool onoff) { - encoderRateMultiplierEnabled = onoff; - lastEncoderMovementMillis = 0; - } + #if ENABLED(AUTO_BED_LEVELING_UBL) + #include "../feature/bedlevel/bedlevel.h" #endif - #if EITHER(REVERSE_MENU_DIRECTION, REVERSE_SELECT_DIRECTION) - int8_t MarlinUI::encoderDirection = ENCODERBASE; + #if HAS_TRINAMIC_CONFIG + #include "../feature/tmc_util.h" #endif - #if HAS_TOUCH_BUTTONS - uint8_t MarlinUI::touch_buttons; - uint8_t MarlinUI::repeat_delay; + #if HAS_ADC_BUTTONS + #include "../module/thermistor/thermistors.h" #endif - bool MarlinUI::lcd_clicked; - - bool MarlinUI::use_click() { - const bool click = lcd_clicked; - lcd_clicked = false; - return click; - } - - #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) - - bool MarlinUI::external_control; // = false - - void MarlinUI::wait_for_release() { - while (button_pressed()) safe_delay(50); - safe_delay(50); - } - + #if HAS_POWER_MONITOR + #include "../feature/power_monitor.h" #endif - #if !HAS_GRAPHICAL_TFT + #if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT) + #include "../feature/power.h" + #endif - void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) { - SETCURSOR(col, row); - if (!string) return; + #if HAS_ENCODER_ACTION + volatile uint8_t MarlinUI::buttons; + #if HAS_SLOW_BUTTONS + volatile uint8_t MarlinUI::slow_buttons; + #endif + #if HAS_TOUCH_BUTTONS + #include "touch/touch_buttons.h" + bool MarlinUI::on_edit_screen = false; + #endif + #endif - auto _newline = [&col, &row]{ - col = 0; row++; // Move col to string len (plus space) - SETCURSOR(0, row); // Simulate carriage return - }; + #if SCREENS_CAN_TIME_OUT + bool MarlinUI::defer_return_to_status; + millis_t MarlinUI::return_to_status_ms = 0; + #endif - uint8_t *p = (uint8_t*)string; - wchar_t ch; - if (wordwrap) { - uint8_t *wrd = nullptr, c = 0; - // find the end of the part - for (;;) { - if (!wrd) wrd = p; // Get word start /before/ advancing - p = get_utf8_value_cb(p, cb_read_byte, &ch); - const bool eol = !ch; // zero ends the string - // End or a break between phrases? - if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') { - if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces - // Past the right and the word is not too long? - if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap? - c += !eol; // +1 so the space will be printed - col += c; // advance col to new position - while (c) { // character countdown - --c; // count down to zero - wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again - lcd_put_wchar(ch); // character to the LCD + uint8_t MarlinUI::lcd_status_update_delay = 1; // First update one loop delayed + + #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) + millis_t MarlinUI::next_filament_display; // = 0 + #endif + + millis_t MarlinUI::next_button_update_ms; // = 0 + + #if HAS_MARLINUI_U8GLIB + bool MarlinUI::drawing_screen, MarlinUI::first_page; // = false + #endif + + // Encoder Handling + #if HAS_ENCODER_ACTION + uint32_t MarlinUI::encoderPosition; + volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update + #endif + + #if ENABLED(SDSUPPORT) + + #include "../sd/cardreader.h" + + #if MARLINUI_SCROLL_NAME + uint8_t MarlinUI::filename_scroll_pos, MarlinUI::filename_scroll_max; + #endif + + const char * MarlinUI::scrolled_filename(CardReader &theCard, const uint8_t maxlen, uint8_t hash, const bool doScroll) { + const char *outstr = theCard.longest_filename(); + if (theCard.longFilename[0]) { + #if MARLINUI_SCROLL_NAME + if (doScroll) { + for (uint8_t l = FILENAME_LENGTH; l--;) + hash = ((hash << 1) | (hash >> 7)) ^ theCard.filename[l]; // rotate, xor + static uint8_t filename_scroll_hash; + if (filename_scroll_hash != hash) { // If the hash changed... + filename_scroll_hash = hash; // Save the new hash + filename_scroll_max = _MAX(0, utf8_strlen(theCard.longFilename) - maxlen); // Update the scroll limit + filename_scroll_pos = 0; // Reset scroll to the start + lcd_status_update_delay = 8; // Don't scroll right away } - if (eol) break; // all done! - wrd = nullptr; // set up for next word - } - else c++; // count word characters - } - } - else { - for (;;) { - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - lcd_put_wchar(ch); - col++; - if (col >= LCD_WIDTH) _newline(); - } - } - } - - void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { - const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0; - uint8_t col = 0, row = 0; - if (!string && plen + slen <= LCD_WIDTH) { - col = (LCD_WIDTH - plen - slen) / 2; - row = LCD_HEIGHT > 3 ? 1 : 0; - } - wrap_string_P(col, row, pref, true); - if (string) { - if (col) { col = 0; row++; } // Move to the start of the next line - wrap_string(col, row, string); - } - if (suff) wrap_string_P(col, row, suff); - } - - #endif // !HAS_GRAPHICAL_TFT - -#endif // HAS_LCD_MENU - -void MarlinUI::init() { - - init_lcd(); - - #if HAS_DIGITAL_BUTTONS - #if BUTTON_EXISTS(EN1) - SET_INPUT_PULLUP(BTN_EN1); - #endif - #if BUTTON_EXISTS(EN2) - SET_INPUT_PULLUP(BTN_EN2); - #endif - #if BUTTON_EXISTS(ENC) - SET_INPUT_PULLUP(BTN_ENC); - #endif - #if BUTTON_EXISTS(ENC_EN) - SET_INPUT_PULLUP(BTN_ENC_EN); - #endif - #if BUTTON_EXISTS(BACK) - SET_INPUT_PULLUP(BTN_BACK); - #endif - #if BUTTON_EXISTS(UP) - SET_INPUT(BTN_UP); - #endif - #if BUTTON_EXISTS(DWN) - SET_INPUT(BTN_DWN); - #endif - #if BUTTON_EXISTS(LFT) - SET_INPUT(BTN_LFT); - #endif - #if BUTTON_EXISTS(RT) - SET_INPUT(BTN_RT); - #endif - #endif - - #if HAS_SHIFT_ENCODER - - #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register - - SET_OUTPUT(SR_DATA_PIN); - SET_OUTPUT(SR_CLK_PIN); - - #elif PIN_EXISTS(SHIFT_CLK) - - SET_OUTPUT(SHIFT_CLK_PIN); - OUT_WRITE(SHIFT_LD_PIN, HIGH); - #if PIN_EXISTS(SHIFT_EN) - OUT_WRITE(SHIFT_EN_PIN, LOW); - #endif - SET_INPUT_PULLUP(SHIFT_OUT_PIN); - - #endif - - #endif // HAS_SHIFT_ENCODER - - #if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS) - slow_buttons = 0; - #endif - - update_buttons(); - - TERN_(HAS_ENCODER_ACTION, encoderDiff = 0); -} - -bool MarlinUI::get_blink() { - static uint8_t blink = 0; - static millis_t next_blink_ms = 0; - millis_t ms = millis(); - if (ELAPSED(ms, next_blink_ms)) { - blink ^= 0xFF; - next_blink_ms = ms + 1000 - (LCD_UPDATE_INTERVAL) / 2; - } - return blink != 0; -} - -//////////////////////////////////////////// -///////////// Keypad Handling ////////////// -//////////////////////////////////////////// - -#if IS_RRW_KEYPAD && HAS_ENCODER_ACTION - - volatile uint8_t MarlinUI::keypad_buttons; - - #if HAS_LCD_MENU && !HAS_ADC_BUTTONS - - void lcd_move_x(); - void lcd_move_y(); - void lcd_move_z(); - - void _reprapworld_keypad_move(const AxisEnum axis, const int16_t dir) { - ui.manual_move.menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; - ui.encoderPosition = dir; - switch (axis) { - case X_AXIS: lcd_move_x(); break; - case Y_AXIS: lcd_move_y(); break; - case Z_AXIS: lcd_move_z(); - default: break; - } - } - - #endif - - bool MarlinUI::handle_keypad() { - - #if HAS_ADC_BUTTONS - - #define ADC_MIN_KEY_DELAY 100 - if (keypad_buttons) { - #if HAS_ENCODER_ACTION - refresh(LCDVIEW_REDRAW_NOW); - #if HAS_LCD_MENU - if (encoderDirection == -(ENCODERBASE)) { // HAS_ADC_BUTTONS forces REVERSE_MENU_DIRECTION, so this indicates menu navigation - if (RRK(EN_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; - else if (RRK(EN_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM; - else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); } - else if (RRK(EN_KEYPAD_RIGHT)) { return_to_status(); quick_feedback(); } - } - else - #endif - { - #if HAS_LCD_MENU - if (RRK(EN_KEYPAD_UP)) encoderPosition -= epps; - else if (RRK(EN_KEYPAD_DOWN)) encoderPosition += epps; - else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); } - else if (RRK(EN_KEYPAD_RIGHT)) encoderPosition = 0; - #else - if (RRK(EN_KEYPAD_UP) || RRK(EN_KEYPAD_LEFT)) encoderPosition -= epps; - else if (RRK(EN_KEYPAD_DOWN) || RRK(EN_KEYPAD_RIGHT)) encoderPosition += epps; - #endif + // Advance byte position corresponding to filename_scroll_pos char position + outstr += TERN(UTF_FILENAME_SUPPORT, utf8_byte_pos_by_char_num(outstr, filename_scroll_pos), filename_scroll_pos); } + #else + theCard.longFilename[ + TERN(UTF_FILENAME_SUPPORT, utf8_byte_pos_by_char_num(theCard.longFilename, maxlen), maxlen) + ] = '\0'; // cutoff at screen edge #endif - next_button_update_ms = millis() + ADC_MIN_KEY_DELAY; - return true; } + return outstr; + } - #else // !HAS_ADC_BUTTONS - - static uint8_t keypad_debounce = 0; - - if (!RRK( EN_KEYPAD_F1 | EN_KEYPAD_F2 - | EN_KEYPAD_F3 | EN_KEYPAD_DOWN - | EN_KEYPAD_RIGHT | EN_KEYPAD_MIDDLE - | EN_KEYPAD_UP | EN_KEYPAD_LEFT ) - ) { - if (keypad_debounce > 0) keypad_debounce--; - } - else if (!keypad_debounce) { - keypad_debounce = 2; - - const bool homed = all_axes_homed(); - - #if HAS_LCD_MENU - - if (RRK(EN_KEYPAD_MIDDLE)) goto_screen(menu_move); - - #if NONE(DELTA, Z_HOME_TO_MAX) - if (RRK(EN_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1); - #endif - - if (homed) { - #if EITHER(DELTA, Z_HOME_TO_MAX) - if (RRK(EN_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1); - #endif - if (RRK(EN_KEYPAD_F3)) _reprapworld_keypad_move(Z_AXIS, -1); - if (RRK(EN_KEYPAD_LEFT)) _reprapworld_keypad_move(X_AXIS, -1); - if (RRK(EN_KEYPAD_RIGHT)) _reprapworld_keypad_move(X_AXIS, 1); - if (RRK(EN_KEYPAD_DOWN)) _reprapworld_keypad_move(Y_AXIS, 1); - if (RRK(EN_KEYPAD_UP)) _reprapworld_keypad_move(Y_AXIS, -1); - } - - #endif // HAS_LCD_MENU - - if (!homed && RRK(EN_KEYPAD_F1)) queue.inject_P(G28_STR); - return true; - } - - #endif // !HAS_ADC_BUTTONS - - return false; - } - -#endif // IS_RRW_KEYPAD && HAS_ENCODER_ACTION - -/** - * Status Screen - * - * This is very display-dependent, so the lcd implementation draws this. - */ - -#if BASIC_PROGRESS_BAR - millis_t MarlinUI::progress_bar_ms; // = 0 - #if PROGRESS_MSG_EXPIRE > 0 - millis_t MarlinUI::expire_status_ms; // = 0 #endif -#endif -void MarlinUI::status_screen() { + #if HAS_LCD_MENU + #include "menu/menu.h" - TERN_(HAS_LCD_MENU, ENCODER_RATE_MULTIPLY(false)); + screenFunc_t MarlinUI::currentScreen; // Initialized in CTOR + bool MarlinUI::screen_changed; - #if BASIC_PROGRESS_BAR - - // - // HD44780 implements the following message blinking and - // message expiration because Status Line and Progress Bar - // share the same line on the display. - // - - #if DISABLED(PROGRESS_MSG_ONCE) || (PROGRESS_MSG_EXPIRE > 0) - #define GOT_MS - const millis_t ms = millis(); + #if ENABLED(ENCODER_RATE_MULTIPLIER) + bool MarlinUI::encoderRateMultiplierEnabled; + millis_t MarlinUI::lastEncoderMovementMillis = 0; + void MarlinUI::enable_encoder_multiplier(const bool onoff) { + encoderRateMultiplierEnabled = onoff; + lastEncoderMovementMillis = 0; + } #endif - // If the message will blink rather than expire... - #if DISABLED(PROGRESS_MSG_ONCE) - if (ELAPSED(ms, progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME)) - progress_bar_ms = ms; + #if EITHER(REVERSE_MENU_DIRECTION, REVERSE_SELECT_DIRECTION) + int8_t MarlinUI::encoderDirection = ENCODERBASE; #endif - #if PROGRESS_MSG_EXPIRE > 0 + #if HAS_TOUCH_BUTTONS + uint8_t MarlinUI::touch_buttons; + uint8_t MarlinUI::repeat_delay; + #endif - // Handle message expire - if (expire_status_ms) { + #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) - // Expire the message if a job is active and the bar has ticks - if (get_progress_percent() > 2 && !print_job_timer.isPaused()) { - if (ELAPSED(ms, expire_status_ms)) { - status_message[0] = '\0'; - expire_status_ms = 0; + bool MarlinUI::external_control; // = false + + void MarlinUI::wait_for_release() { + while (button_pressed()) safe_delay(50); + safe_delay(50); + } + + #endif + + #if !HAS_GRAPHICAL_TFT + + void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) { + SETCURSOR(col, row); + if (!string) return; + + auto _newline = [&col, &row]{ + col = 0; row++; // Move col to string len (plus space) + SETCURSOR(0, row); // Simulate carriage return + }; + + uint8_t *p = (uint8_t*)string; + wchar_t ch; + if (wordwrap) { + uint8_t *wrd = nullptr, c = 0; + // find the end of the part + for (;;) { + if (!wrd) wrd = p; // Get word start /before/ advancing + p = get_utf8_value_cb(p, cb_read_byte, &ch); + const bool eol = !ch; // zero ends the string + // End or a break between phrases? + if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') { + if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces + // Past the right and the word is not too long? + if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap? + c += !eol; // +1 so the space will be printed + col += c; // advance col to new position + while (c) { // character countdown + --c; // count down to zero + wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again + lcd_put_wchar(ch); // character to the LCD + } + if (eol) break; // all done! + wrd = nullptr; // set up for next word + } + else c++; // count word characters } } else { - // Defer message expiration before bar appears - // and during any pause (not just SD) - expire_status_ms += LCD_UPDATE_INTERVAL; - } - } - - #endif // PROGRESS_MSG_EXPIRE - - #endif // BASIC_PROGRESS_BAR - - #if HAS_LCD_MENU - if (use_click()) { - #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) - next_filament_display = millis() + 5000UL; // Show status message for 5s - #endif - goto_screen(menu_main); - #if DISABLED(NO_LCD_REINIT) - init_lcd(); // May revive the LCD if static electricity killed it - #endif - return; - } - - #endif - - #if ENABLED(ULTIPANEL_FEEDMULTIPLY) - - const int16_t old_frm = feedrate_percentage; - int16_t new_frm = old_frm + int16_t(encoderPosition); - - // Dead zone at 100% feedrate - if (old_frm == 100) { - if (int16_t(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) - new_frm -= ENCODER_FEEDRATE_DEADZONE; - else if (int16_t(encoderPosition) < -(ENCODER_FEEDRATE_DEADZONE)) - new_frm += ENCODER_FEEDRATE_DEADZONE; - else - new_frm = old_frm; - } - else if ((old_frm < 100 && new_frm > 100) || (old_frm > 100 && new_frm < 100)) - new_frm = 100; - - LIMIT(new_frm, 10, 999); - - if (old_frm != new_frm) { - feedrate_percentage = new_frm; - encoderPosition = 0; - #if BOTH(HAS_BUZZER, BEEP_ON_FEEDRATE_CHANGE) - static millis_t next_beep; - #ifndef GOT_MS - const millis_t ms = millis(); - #endif - if (ELAPSED(ms, next_beep)) { - buzz(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY); - next_beep = ms + 500UL; - } - #endif - } - - #endif // ULTIPANEL_FEEDMULTIPLY - - draw_status_screen(); -} - -void MarlinUI::kill_screen(PGM_P lcd_error, PGM_P lcd_component) { - init(); - status_printf_P(1, PSTR(S_FMT ": " S_FMT), lcd_error, lcd_component); - TERN_(HAS_LCD_MENU, return_to_status()); - - // RED ALERT. RED ALERT. - #ifdef LED_BACKLIGHT_TIMEOUT - leds.set_color(LEDColorRed()); - #ifdef NEOPIXEL_BKGD_INDEX_FIRST - neo.set_background_color(255, 0, 0, 0); - neo.show(); - #endif - #endif - - draw_kill_screen(); -} - -void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { - - TERN_(HAS_LCD_MENU, refresh()); - - #if HAS_ENCODER_ACTION - if (clear_buttons) buttons = 0; - next_button_update_ms = millis() + 500; - #else - UNUSED(clear_buttons); - #endif - - #if HAS_CHIRP - 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 -} - -//////////////////////////////////////////// -/////////////// Manual Move //////////////// -//////////////////////////////////////////// - -#if HAS_LCD_MENU - - ManualMove MarlinUI::manual_move{}; - - millis_t ManualMove::start_time = 0; - float ManualMove::menu_scale = 1; - #if IS_KINEMATIC - float ManualMove::offset = 0; - xyze_pos_t ManualMove::all_axes_destination = { 0 }; - bool ManualMove::processing = false; - #endif - #if MULTI_E_MANUAL - int8_t ManualMove::e_index = 0; - #endif - AxisEnum ManualMove::axis = NO_AXIS_ENUM; - - /** - * If a manual move has been posted and its time has arrived, and if the planner - * has a space for it, then add a linear move to current_position the planner. - * - * If any manual move needs to be interrupted, make sure to force a manual move - * by setting manual_move.start_time to millis() after updating current_position. - * - * To post a manual move: - * - Update current_position to the new place you want to go. - * - Set manual_move.axis to an axis like X_AXIS. Use ALL_AXES_ENUM for diagonal moves. - * - Set manual_move.start_time to a point in the future (in ms) when the move should be done. - * - * For kinematic machines: - * - Set manual_move.offset to modify one axis and post the move. - * This is used to achieve more rapid stepping on kinematic machines. - * - * Currently used by the _lcd_move_xyz function in menu_motion.cpp - * and the ubl_map_move_to_xy funtion in menu_ubl.cpp. - */ - void ManualMove::task() { - - if (processing) return; // Prevent re-entry from idle() calls - - // Add a manual move to the queue? - if (axis != NO_AXIS_ENUM && ELAPSED(millis(), start_time) && !planner.is_full()) { - - const feedRate_t fr_mm_s = (axis <= LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; - - #if IS_KINEMATIC - - #if HAS_MULTI_EXTRUDER - REMEMBER(ae, active_extruder); - #if MULTI_E_MANUAL - if (axis == E_AXIS) active_extruder = e_index; - #endif - #endif - - // Apply a linear offset to a single axis - if (axis == ALL_AXES_ENUM) - destination = all_axes_destination; - else if (axis <= XYZE) { - destination = current_position; - destination[axis] += offset; - } - - // Reset for the next move - offset = 0; - axis = NO_AXIS_ENUM; - - // DELTA and SCARA machines use segmented moves, which could fill the planner during the call to - // move_to_destination. This will cause idle() to be called, which can then call this function while the - // previous invocation is being blocked. Modifications to offset shouldn't be made while - // processing is true or the planner will get out of sync. - processing = true; - prepare_internal_move_to_destination(fr_mm_s); // will set current_position from destination - processing = false; - - #else - - // For Cartesian / Core motion simply move to the current_position - planner.buffer_line(current_position, fr_mm_s, - TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder - ); - - //SERIAL_ECHOLNPAIR("Add planner.move with Axis ", AS_CHAR(axis_codes[axis]), " at FR ", fr_mm_s); - - axis = NO_AXIS_ENUM; - - #endif - } - } - - // - // Tell ui.update() to start a move to current_position after a short delay. - // - void ManualMove::soon(const AxisEnum move_axis - OPTARG(MULTI_E_MANUAL, const int8_t eindex/*=active_extruder*/) - ) { - TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex); - start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves - axis = move_axis; - //SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon."); - } - - #if ENABLED(AUTO_BED_LEVELING_UBL) - - void MarlinUI::external_encoder() { - if (external_control && encoderDiff) { - ubl.encoder_diff += encoderDiff; // Encoder for UBL G29 mesh editing - encoderDiff = 0; // Hide encoder events from the screen handler - refresh(LCDVIEW_REDRAW_NOW); // ...but keep the refresh. - } - } - - #endif - -#endif // HAS_LCD_MENU - -/** - * Update the LCD, read encoder buttons, etc. - * - Read button states - * - Check the SD Card slot state - * - Act on RepRap World keypad input - * - Update the encoder position - * - Apply acceleration to the encoder position - * - Do refresh(LCDVIEW_CALL_REDRAW_NOW) on controller events - * - Reset the Info Screen timeout if there's any input - * - Update status indicators, if any - * - * Run the current LCD menu handler callback function: - * - Call the handler only if lcdDrawUpdate != LCDVIEW_NONE - * - Before calling the handler, LCDVIEW_CALL_NO_REDRAW => LCDVIEW_NONE - * - Call the menu handler. Menu handlers should do the following: - * - If a value changes, set lcdDrawUpdate to LCDVIEW_REDRAW_NOW and draw the value - * (Encoder events automatically set lcdDrawUpdate for you.) - * - if (should_draw()) { redraw } - * - Before exiting the handler set lcdDrawUpdate to: - * - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT. - * - LCDVIEW_REDRAW_NOW to draw now (including remaining stripes). - * - LCDVIEW_CALL_REDRAW_NEXT to draw now and get LCDVIEW_REDRAW_NOW on the next loop. - * - LCDVIEW_CALL_NO_REDRAW to draw now and get LCDVIEW_NONE on the next loop. - * - NOTE: For graphical displays menu handlers may be called 2 or more times per loop, - * so don't change lcdDrawUpdate without considering this. - * - * After the menu handler callback runs (or not): - * - Clear the LCD if lcdDrawUpdate == LCDVIEW_CLEAR_CALL_REDRAW - * - Update lcdDrawUpdate for the next loop (i.e., move one state down, usually) - * - * This function is only called from the main thread. - */ - -LCDViewAction MarlinUI::lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; -millis_t next_lcd_update_ms; -#if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS - millis_t MarlinUI::return_to_status_ms = 0; -#endif - -inline bool can_encode() { - return !BUTTON_PRESSED(ENC_EN); // Update encoder only when ENC_EN is not LOW (pressed) -} - -void MarlinUI::update() { - - static uint16_t max_display_update_time = 0; - millis_t ms = millis(); - - #if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS > 0 - #define RESET_STATUS_TIMEOUT() (return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS) - #else - #define RESET_STATUS_TIMEOUT() NOOP - #endif - - #ifdef LED_BACKLIGHT_TIMEOUT - leds.update_timeout(powersupply_on); - #endif - - #if HAS_LCD_MENU - - // Handle any queued Move Axis motion - manual_move.task(); - - // Update button states for button_pressed(), etc. - // If the state changes the next update may be delayed 300-500ms. - update_buttons(); - - // If the action button is pressed... - static bool wait_for_unclick; // = false - - auto do_click = [&]{ - 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 - }; - - #if HAS_TOUCH_BUTTONS - if (touch_buttons) { - RESET_STATUS_TIMEOUT(); - if (touch_buttons & (EN_A | EN_B)) { // Menu arrows, in priority - if (ELAPSED(ms, next_button_update_ms)) { - encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * epps * encoderDirection; - if (touch_buttons & EN_A) encoderDiff *= -1; - TERN_(AUTO_BED_LEVELING_UBL, external_encoder()); - next_button_update_ms = ms + repeat_delay; // Assume the repeat delay - if (!wait_for_unclick) { - next_button_update_ms += 250; // Longer delay on first press - wait_for_unclick = true; // Avoid Back/Select click while repeating - chirp(); - } + for (;;) { + p = get_utf8_value_cb(p, cb_read_byte, &ch); + if (!ch) break; + lcd_put_wchar(ch); + col++; + if (col >= LCD_WIDTH) _newline(); } } - else if (!wait_for_unclick && (buttons & EN_C)) // OK button, if not waiting for a debounce release: - do_click(); } - // keep wait_for_unclick value - #endif - if (!touch_buttons) { - // Integrated LCD click handling via button_pressed - if (!external_control && button_pressed()) { - if (!wait_for_unclick) do_click(); // Handle the click + void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { + const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0; + uint8_t col = 0, row = 0; + if (!string && plen + slen <= LCD_WIDTH) { + col = (LCD_WIDTH - plen - slen) / 2; + row = LCD_HEIGHT > 3 ? 1 : 0; + } + wrap_string_P(col, row, pref, true); + if (string) { + if (col) { col = 0; row++; } // Move to the start of the next line + wrap_string(col, row, string); + } + if (suff) wrap_string_P(col, row, suff); } - else - wait_for_unclick = false; - } - if (LCD_BACK_CLICKED()) { - quick_feedback(); - goto_previous_screen(); - } + #endif // !HAS_GRAPHICAL_TFT #endif // HAS_LCD_MENU - if (ELAPSED(ms, next_lcd_update_ms) || TERN0(HAS_MARLINUI_U8GLIB, drawing_screen)) { + void MarlinUI::init() { - next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; + init_lcd(); - #if HAS_TOUCH_BUTTONS + #if HAS_DIGITAL_BUTTONS + #if BUTTON_EXISTS(EN1) + SET_INPUT_PULLUP(BTN_EN1); + #endif + #if BUTTON_EXISTS(EN2) + SET_INPUT_PULLUP(BTN_EN2); + #endif + #if BUTTON_EXISTS(ENC) + SET_INPUT_PULLUP(BTN_ENC); + #endif + #if BUTTON_EXISTS(ENC_EN) + SET_INPUT_PULLUP(BTN_ENC_EN); + #endif + #if BUTTON_EXISTS(BACK) + SET_INPUT_PULLUP(BTN_BACK); + #endif + #if BUTTON_EXISTS(UP) + SET_INPUT(BTN_UP); + #endif + #if BUTTON_EXISTS(DWN) + SET_INPUT(BTN_DWN); + #endif + #if BUTTON_EXISTS(LFT) + SET_INPUT(BTN_LFT); + #endif + #if BUTTON_EXISTS(RT) + SET_INPUT(BTN_RT); + #endif + #endif - if (on_status_screen()) next_lcd_update_ms += (LCD_UPDATE_INTERVAL) * 2; + #if HAS_SHIFT_ENCODER - TERN_(HAS_ENCODER_ACTION, touch_buttons = touch.read_buttons()); + #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register + + SET_OUTPUT(SR_DATA_PIN); + SET_OUTPUT(SR_CLK_PIN); + + #elif PIN_EXISTS(SHIFT_CLK) + + SET_OUTPUT(SHIFT_CLK_PIN); + OUT_WRITE(SHIFT_LD_PIN, HIGH); + #if PIN_EXISTS(SHIFT_EN) + OUT_WRITE(SHIFT_EN_PIN, LOW); + #endif + SET_INPUT_PULLUP(SHIFT_OUT_PIN); + + #endif + + #endif // HAS_SHIFT_ENCODER + + #if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS) + slow_buttons = 0; + #endif + + update_buttons(); + + TERN_(HAS_ENCODER_ACTION, encoderDiff = 0); + } + + bool MarlinUI::get_blink() { + static uint8_t blink = 0; + static millis_t next_blink_ms = 0; + millis_t ms = millis(); + if (ELAPSED(ms, next_blink_ms)) { + blink ^= 0xFF; + next_blink_ms = ms + 1000 - (LCD_UPDATE_INTERVAL) / 2; + } + return blink != 0; + } + + //////////////////////////////////////////// + ///////////// Keypad Handling ////////////// + //////////////////////////////////////////// + + #if IS_RRW_KEYPAD && HAS_ENCODER_ACTION + + volatile uint8_t MarlinUI::keypad_buttons; + + #if HAS_LCD_MENU && !HAS_ADC_BUTTONS + + void lcd_move_x(); + void lcd_move_y(); + void lcd_move_z(); + + void _reprapworld_keypad_move(const AxisEnum axis, const int16_t dir) { + ui.manual_move.menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; + ui.encoderPosition = dir; + switch (axis) { + case X_AXIS: lcd_move_x(); break; + case Y_AXIS: lcd_move_y(); break; + case Z_AXIS: lcd_move_z(); + default: break; + } + } #endif - TERN_(LCD_HAS_STATUS_INDICATORS, update_indicators()); + bool MarlinUI::handle_keypad() { - #if HAS_ENCODER_ACTION + #if HAS_ADC_BUTTONS - TERN_(HAS_SLOW_BUTTONS, slow_buttons = read_slow_buttons()); // Buttons that take too long to read in interrupt context - - if (TERN0(IS_RRW_KEYPAD, handle_keypad())) - RESET_STATUS_TIMEOUT(); - - uint8_t abs_diff = ABS(encoderDiff); - - #if ENCODER_PULSES_PER_STEP > 1 - // When reversing the encoder direction, a movement step can be missed because - // encoderDiff has a non-zero residual value, making the controller unresponsive. - // The fix clears the residual value when the encoder is idle. - // Also check if past half the threshold to compensate for missed single steps. - static int8_t lastEncoderDiff; - - // Timeout? No decoder change since last check. 10 or 20 times per second. - if (encoderDiff == lastEncoderDiff && abs_diff <= epps / 2) // Same direction & size but not over a half-step? - encoderDiff = 0; // Clear residual pulses. - else if (WITHIN(abs_diff, epps / 2 + 1, epps - 1)) { // Past half of threshold? - abs_diff = epps; // Treat as a full step size - encoderDiff = (encoderDiff < 0 ? -1 : 1) * abs_diff; // ...in the spin direction. + #define ADC_MIN_KEY_DELAY 100 + if (keypad_buttons) { + #if HAS_ENCODER_ACTION + refresh(LCDVIEW_REDRAW_NOW); + #if HAS_LCD_MENU + if (encoderDirection == -(ENCODERBASE)) { // HAS_ADC_BUTTONS forces REVERSE_MENU_DIRECTION, so this indicates menu navigation + if (RRK(EN_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; + else if (RRK(EN_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM; + else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); } + else if (RRK(EN_KEYPAD_RIGHT)) { return_to_status(); quick_feedback(); } + } + else + #endif + { + #if HAS_LCD_MENU + if (RRK(EN_KEYPAD_UP)) encoderPosition -= epps; + else if (RRK(EN_KEYPAD_DOWN)) encoderPosition += epps; + else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); } + else if (RRK(EN_KEYPAD_RIGHT)) encoderPosition = 0; + #else + if (RRK(EN_KEYPAD_UP) || RRK(EN_KEYPAD_LEFT)) encoderPosition -= epps; + else if (RRK(EN_KEYPAD_DOWN) || RRK(EN_KEYPAD_RIGHT)) encoderPosition += epps; + #endif + } + #endif + next_button_update_ms = millis() + ADC_MIN_KEY_DELAY; + return true; } - lastEncoderDiff = encoderDiff; + + #else // !HAS_ADC_BUTTONS + + static uint8_t keypad_debounce = 0; + + if (!RRK( EN_KEYPAD_F1 | EN_KEYPAD_F2 + | EN_KEYPAD_F3 | EN_KEYPAD_DOWN + | EN_KEYPAD_RIGHT | EN_KEYPAD_MIDDLE + | EN_KEYPAD_UP | EN_KEYPAD_LEFT ) + ) { + if (keypad_debounce > 0) keypad_debounce--; + } + else if (!keypad_debounce) { + keypad_debounce = 2; + + const bool homed = all_axes_homed(); + + #if HAS_LCD_MENU + + if (RRK(EN_KEYPAD_MIDDLE)) goto_screen(menu_move); + + #if NONE(DELTA, Z_HOME_TO_MAX) + if (RRK(EN_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1); + #endif + + if (homed) { + #if EITHER(DELTA, Z_HOME_TO_MAX) + if (RRK(EN_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1); + #endif + if (RRK(EN_KEYPAD_F3)) _reprapworld_keypad_move(Z_AXIS, -1); + if (RRK(EN_KEYPAD_LEFT)) _reprapworld_keypad_move(X_AXIS, -1); + if (RRK(EN_KEYPAD_RIGHT)) _reprapworld_keypad_move(X_AXIS, 1); + if (RRK(EN_KEYPAD_DOWN)) _reprapworld_keypad_move(Y_AXIS, 1); + if (RRK(EN_KEYPAD_UP)) _reprapworld_keypad_move(Y_AXIS, -1); + } + + #endif // HAS_LCD_MENU + + if (!homed && RRK(EN_KEYPAD_F1)) queue.inject_P(G28_STR); + return true; + } + + #endif // !HAS_ADC_BUTTONS + + return false; + } + + #endif // IS_RRW_KEYPAD && HAS_ENCODER_ACTION + + /** + * Status Screen + * + * This is very display-dependent, so the lcd implementation draws this. + */ + + #if BASIC_PROGRESS_BAR + millis_t MarlinUI::progress_bar_ms; // = 0 + #if PROGRESS_MSG_EXPIRE > 0 + millis_t MarlinUI::expire_status_ms; // = 0 + #endif + #endif + + void MarlinUI::status_screen() { + + TERN_(HAS_LCD_MENU, ENCODER_RATE_MULTIPLY(false)); + + #if BASIC_PROGRESS_BAR + + // + // HD44780 implements the following message blinking and + // message expiration because Status Line and Progress Bar + // share the same line on the display. + // + + #if DISABLED(PROGRESS_MSG_ONCE) || (PROGRESS_MSG_EXPIRE > 0) + #define GOT_MS + const millis_t ms = millis(); #endif - const bool encoderPastThreshold = (abs_diff >= epps); - if (encoderPastThreshold || lcd_clicked) { - if (encoderPastThreshold && TERN1(IS_TFTGLCD_PANEL, !external_control)) { + // If the message will blink rather than expire... + #if DISABLED(PROGRESS_MSG_ONCE) + if (ELAPSED(ms, progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME)) + progress_bar_ms = ms; + #endif - #if BOTH(HAS_LCD_MENU, ENCODER_RATE_MULTIPLIER) + #if PROGRESS_MSG_EXPIRE > 0 - int32_t encoderMultiplier = 1; + // Handle message expire + if (expire_status_ms) { - if (encoderRateMultiplierEnabled) { - const float encoderMovementSteps = float(abs_diff) / epps; - - if (lastEncoderMovementMillis) { - // Note that the rate is always calculated between two passes through the - // loop and that the abs of the encoderDiff value is tracked. - const float encoderStepRate = encoderMovementSteps / float(ms - lastEncoderMovementMillis) * 1000; - - if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100; - else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10; - - // Enable to output the encoder steps per second value - //#define ENCODER_RATE_MULTIPLIER_DEBUG - #if ENABLED(ENCODER_RATE_MULTIPLIER_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOPAIR("Enc Step Rate: ", encoderStepRate); - SERIAL_ECHOPAIR(" Multiplier: ", encoderMultiplier); - SERIAL_ECHOPAIR(" ENCODER_10X_STEPS_PER_SEC: ", ENCODER_10X_STEPS_PER_SEC); - SERIAL_ECHOPAIR(" ENCODER_100X_STEPS_PER_SEC: ", ENCODER_100X_STEPS_PER_SEC); - SERIAL_EOL(); - #endif - } - - lastEncoderMovementMillis = ms; - } // encoderRateMultiplierEnabled - - #else - - constexpr int32_t encoderMultiplier = 1; - - #endif // ENCODER_RATE_MULTIPLIER - - if (can_encode()) encoderPosition += (encoderDiff * encoderMultiplier) / epps; - - encoderDiff = 0; + // Expire the message if a job is active and the bar has ticks + if (get_progress_percent() > 2 && !print_job_timer.isPaused()) { + if (ELAPSED(ms, expire_status_ms)) { + status_message[0] = '\0'; + expire_status_ms = 0; + } + } + else { + // Defer message expiration before bar appears + // and during any pause (not just SD) + expire_status_ms += LCD_UPDATE_INTERVAL; + } } - RESET_STATUS_TIMEOUT(); + #endif // PROGRESS_MSG_EXPIRE - refresh(LCDVIEW_REDRAW_NOW); + #endif // BASIC_PROGRESS_BAR - #ifdef LED_BACKLIGHT_TIMEOUT - if (!powersupply_on) leds.reset_timeout(ms); + #if HAS_LCD_MENU + if (use_click()) { + #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) + next_filament_display = millis() + 5000UL; // Show status message for 5s + #endif + goto_screen(menu_main); + #if DISABLED(NO_LCD_REINIT) + init_lcd(); // May revive the LCD if static electricity killed it + #endif + return; + } + + #endif + + #if ENABLED(ULTIPANEL_FEEDMULTIPLY) + + const int16_t old_frm = feedrate_percentage; + int16_t new_frm = old_frm + int16_t(encoderPosition); + + // Dead zone at 100% feedrate + if (old_frm == 100) { + if (int16_t(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) + new_frm -= ENCODER_FEEDRATE_DEADZONE; + else if (int16_t(encoderPosition) < -(ENCODER_FEEDRATE_DEADZONE)) + new_frm += ENCODER_FEEDRATE_DEADZONE; + else + new_frm = old_frm; + } + else if ((old_frm < 100 && new_frm > 100) || (old_frm > 100 && new_frm < 100)) + new_frm = 100; + + LIMIT(new_frm, 10, 999); + + if (old_frm != new_frm) { + feedrate_percentage = new_frm; + encoderPosition = 0; + #if BOTH(HAS_BUZZER, BEEP_ON_FEEDRATE_CHANGE) + static millis_t next_beep; + #ifndef GOT_MS + const millis_t ms = millis(); + #endif + if (ELAPSED(ms, next_beep)) { + buzz(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY); + next_beep = ms + 500UL; + } #endif } + #endif // ULTIPANEL_FEEDMULTIPLY + + draw_status_screen(); + } + + void MarlinUI::kill_screen(PGM_P lcd_error, PGM_P lcd_component) { + init(); + status_printf_P(1, PSTR(S_FMT ": " S_FMT), lcd_error, lcd_component); + TERN_(HAS_LCD_MENU, return_to_status()); + + // RED ALERT. RED ALERT. + #ifdef LED_BACKLIGHT_TIMEOUT + leds.set_color(LEDColorRed()); + #ifdef NEOPIXEL_BKGD_INDEX_FIRST + neo.set_background_color(255, 0, 0, 0); + neo.show(); + #endif #endif - // This runs every ~100ms when idling often enough. - // Instead of tracking changes just redraw the Status Screen once per second. - if (on_status_screen() && !lcd_status_update_delay--) { - lcd_status_update_delay = TERN(HAS_MARLINUI_U8GLIB, 12, 9); - if (max_display_update_time) max_display_update_time--; // Be sure never go to a very big number - refresh(LCDVIEW_REDRAW_NOW); + draw_kill_screen(); + } + + void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { + + TERN_(HAS_LCD_MENU, refresh()); + + #if HAS_ENCODER_ACTION + if (clear_buttons) buttons = 0; + next_button_update_ms = millis() + 500; + #else + UNUSED(clear_buttons); + #endif + + #if HAS_CHIRP + 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 + } + + //////////////////////////////////////////// + /////////////// Manual Move //////////////// + //////////////////////////////////////////// + + #if HAS_LCD_MENU + + ManualMove MarlinUI::manual_move{}; + + millis_t ManualMove::start_time = 0; + float ManualMove::menu_scale = 1; + #if IS_KINEMATIC + float ManualMove::offset = 0; + xyze_pos_t ManualMove::all_axes_destination = { 0 }; + bool ManualMove::processing = false; + #endif + #if MULTI_E_MANUAL + int8_t ManualMove::e_index = 0; + #endif + AxisEnum ManualMove::axis = NO_AXIS_ENUM; + + /** + * If a manual move has been posted and its time has arrived, and if the planner + * has a space for it, then add a linear move to current_position the planner. + * + * If any manual move needs to be interrupted, make sure to force a manual move + * by setting manual_move.start_time to millis() after updating current_position. + * + * To post a manual move: + * - Update current_position to the new place you want to go. + * - Set manual_move.axis to an axis like X_AXIS. Use ALL_AXES_ENUM for diagonal moves. + * - Set manual_move.start_time to a point in the future (in ms) when the move should be done. + * + * For kinematic machines: + * - Set manual_move.offset to modify one axis and post the move. + * This is used to achieve more rapid stepping on kinematic machines. + * + * Currently used by the _lcd_move_xyz function in menu_motion.cpp + * and the ubl_map_move_to_xy funtion in menu_ubl.cpp. + */ + void ManualMove::task() { + + if (processing) return; // Prevent re-entry from idle() calls + + // Add a manual move to the queue? + if (axis != NO_AXIS_ENUM && ELAPSED(millis(), start_time) && !planner.is_full()) { + + const feedRate_t fr_mm_s = (axis <= LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; + + #if IS_KINEMATIC + + #if HAS_MULTI_EXTRUDER + REMEMBER(ae, active_extruder); + #if MULTI_E_MANUAL + if (axis == E_AXIS) active_extruder = e_index; + #endif + #endif + + // Apply a linear offset to a single axis + if (axis == ALL_AXES_ENUM) + destination = all_axes_destination; + else if (axis <= XYZE) { + destination = current_position; + destination[axis] += offset; + } + + // Reset for the next move + offset = 0; + axis = NO_AXIS_ENUM; + + // DELTA and SCARA machines use segmented moves, which could fill the planner during the call to + // move_to_destination. This will cause idle() to be called, which can then call this function while the + // previous invocation is being blocked. Modifications to offset shouldn't be made while + // processing is true or the planner will get out of sync. + processing = true; + prepare_internal_move_to_destination(fr_mm_s); // will set current_position from destination + processing = false; + + #else + + // For Cartesian / Core motion simply move to the current_position + planner.buffer_line(current_position, fr_mm_s, + TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder + ); + + //SERIAL_ECHOLNPAIR("Add planner.move with Axis ", AS_CHAR(axis_codes[axis]), " at FR ", fr_mm_s); + + axis = NO_AXIS_ENUM; + + #endif + } } - #if BOTH(HAS_LCD_MENU, SCROLL_LONG_FILENAMES) - // If scrolling of long file names is enabled and we are in the sd card menu, - // cause a refresh to occur until all the text has scrolled into view. - if (currentScreen == menu_media && !lcd_status_update_delay--) { - lcd_status_update_delay = ++filename_scroll_pos >= filename_scroll_max ? 12 : 4; // Long delay at end and start - if (filename_scroll_pos > filename_scroll_max) filename_scroll_pos = 0; - refresh(LCDVIEW_REDRAW_NOW); - RESET_STATUS_TIMEOUT(); + // + // Tell ui.update() to start a move to current_position after a short delay. + // + void ManualMove::soon(const AxisEnum move_axis + OPTARG(MULTI_E_MANUAL, const int8_t eindex/*=active_extruder*/) + ) { + TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex); + start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves + axis = move_axis; + //SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon."); + } + + #if ENABLED(AUTO_BED_LEVELING_UBL) + + void MarlinUI::external_encoder() { + if (external_control && encoderDiff) { + ubl.encoder_diff += encoderDiff; // Encoder for UBL G29 mesh editing + encoderDiff = 0; // Hide encoder events from the screen handler + refresh(LCDVIEW_REDRAW_NOW); // ...but keep the refresh. + } } + #endif - // Then we want to use only 50% of the time - const uint16_t bbr2 = planner.block_buffer_runtime() >> 1; + #endif // HAS_LCD_MENU - if ((should_draw() || drawing_screen) && (!bbr2 || bbr2 > max_display_update_time)) { + /** + * Update the LCD, read encoder buttons, etc. + * - Read button states + * - Check the SD Card slot state + * - Act on RepRap World keypad input + * - Update the encoder position + * - Apply acceleration to the encoder position + * - Do refresh(LCDVIEW_CALL_REDRAW_NOW) on controller events + * - Reset the Info Screen timeout if there's any input + * - Update status indicators, if any + * + * Run the current LCD menu handler callback function: + * - Call the handler only if lcdDrawUpdate != LCDVIEW_NONE + * - Before calling the handler, LCDVIEW_CALL_NO_REDRAW => LCDVIEW_NONE + * - Call the menu handler. Menu handlers should do the following: + * - If a value changes, set lcdDrawUpdate to LCDVIEW_REDRAW_NOW and draw the value + * (Encoder events automatically set lcdDrawUpdate for you.) + * - if (should_draw()) { redraw } + * - Before exiting the handler set lcdDrawUpdate to: + * - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT. + * - LCDVIEW_REDRAW_NOW to draw now (including remaining stripes). + * - LCDVIEW_CALL_REDRAW_NEXT to draw now and get LCDVIEW_REDRAW_NOW on the next loop. + * - LCDVIEW_CALL_NO_REDRAW to draw now and get LCDVIEW_NONE on the next loop. + * - NOTE: For graphical displays menu handlers may be called 2 or more times per loop, + * so don't change lcdDrawUpdate without considering this. + * + * After the menu handler callback runs (or not): + * - Clear the LCD if lcdDrawUpdate == LCDVIEW_CLEAR_CALL_REDRAW + * - Update lcdDrawUpdate for the next loop (i.e., move one state down, usually) + * + * This function is only called from the main thread. + */ + + LCDViewAction MarlinUI::lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; + millis_t next_lcd_update_ms; + + inline bool can_encode() { + return !BUTTON_PRESSED(ENC_EN); // Update encoder only when ENC_EN is not LOW (pressed) + } + + void MarlinUI::update() { + + static uint16_t max_display_update_time = 0; + millis_t ms = millis(); + + #if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT) + leds.update_timeout(powerManager.psu_on); + #endif + + #if HAS_LCD_MENU + + // Handle any queued Move Axis motion + manual_move.task(); + + // Update button states for button_pressed(), etc. + // If the state changes the next update may be delayed 300-500ms. + update_buttons(); + + // If the action button is pressed... + static bool wait_for_unclick; // = false + + auto do_click = [&]{ + 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 + }; + + #if HAS_TOUCH_BUTTONS + if (touch_buttons) { + reset_status_timeout(ms); + if (touch_buttons & (EN_A | EN_B)) { // Menu arrows, in priority + if (ELAPSED(ms, next_button_update_ms)) { + encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * epps * encoderDirection; + if (touch_buttons & EN_A) encoderDiff *= -1; + TERN_(AUTO_BED_LEVELING_UBL, external_encoder()); + next_button_update_ms = ms + repeat_delay; // Assume the repeat delay + if (!wait_for_unclick) { + next_button_update_ms += 250; // Longer delay on first press + wait_for_unclick = true; // Avoid Back/Select click while repeating + chirp(); + } + } + } + else if (!wait_for_unclick && (buttons & EN_C)) // OK button, if not waiting for a debounce release: + do_click(); + } + // keep wait_for_unclick value + #endif + + if (!touch_buttons) { + // Integrated LCD click handling via button_pressed + if (!external_control && button_pressed()) { + if (!wait_for_unclick) do_click(); // Handle the click + } + else + wait_for_unclick = false; + } + + if (LCD_BACK_CLICKED()) { + quick_feedback(); + goto_previous_screen(); + } + + #endif // HAS_LCD_MENU + + if (ELAPSED(ms, next_lcd_update_ms) || TERN0(HAS_MARLINUI_U8GLIB, drawing_screen)) { + + next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; + + #if HAS_TOUCH_BUTTONS + + if (on_status_screen()) next_lcd_update_ms += (LCD_UPDATE_INTERVAL) * 2; + + TERN_(HAS_ENCODER_ACTION, touch_buttons = touch.read_buttons()); + + #endif + + TERN_(LCD_HAS_STATUS_INDICATORS, update_indicators()); + + #if HAS_ENCODER_ACTION + + TERN_(HAS_SLOW_BUTTONS, slow_buttons = read_slow_buttons()); // Buttons that take too long to read in interrupt context + + if (TERN0(IS_RRW_KEYPAD, handle_keypad())) + reset_status_timeout(ms); + + uint8_t abs_diff = ABS(encoderDiff); + + #if ENCODER_PULSES_PER_STEP > 1 + // When reversing the encoder direction, a movement step can be missed because + // encoderDiff has a non-zero residual value, making the controller unresponsive. + // The fix clears the residual value when the encoder is idle. + // Also check if past half the threshold to compensate for missed single steps. + static int8_t lastEncoderDiff; + + // Timeout? No decoder change since last check. 10 or 20 times per second. + if (encoderDiff == lastEncoderDiff && abs_diff <= epps / 2) // Same direction & size but not over a half-step? + encoderDiff = 0; // Clear residual pulses. + else if (WITHIN(abs_diff, epps / 2 + 1, epps - 1)) { // Past half of threshold? + abs_diff = epps; // Treat as a full step size + encoderDiff = (encoderDiff < 0 ? -1 : 1) * abs_diff; // ...in the spin direction. + } + lastEncoderDiff = encoderDiff; + #endif + + const bool encoderPastThreshold = (abs_diff >= epps); + if (encoderPastThreshold || lcd_clicked) { + if (encoderPastThreshold && TERN1(IS_TFTGLCD_PANEL, !external_control)) { + + #if BOTH(HAS_LCD_MENU, ENCODER_RATE_MULTIPLIER) + + int32_t encoderMultiplier = 1; + + if (encoderRateMultiplierEnabled) { + const float encoderMovementSteps = float(abs_diff) / epps; + + if (lastEncoderMovementMillis) { + // Note that the rate is always calculated between two passes through the + // loop and that the abs of the encoderDiff value is tracked. + const float encoderStepRate = encoderMovementSteps / float(ms - lastEncoderMovementMillis) * 1000; + + if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100; + else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10; + + // Enable to output the encoder steps per second value + //#define ENCODER_RATE_MULTIPLIER_DEBUG + #if ENABLED(ENCODER_RATE_MULTIPLIER_DEBUG) + SERIAL_ECHO_START(); + SERIAL_ECHOPAIR("Enc Step Rate: ", encoderStepRate); + SERIAL_ECHOPAIR(" Multiplier: ", encoderMultiplier); + SERIAL_ECHOPAIR(" ENCODER_10X_STEPS_PER_SEC: ", ENCODER_10X_STEPS_PER_SEC); + SERIAL_ECHOPAIR(" ENCODER_100X_STEPS_PER_SEC: ", ENCODER_100X_STEPS_PER_SEC); + SERIAL_EOL(); + #endif + } + + lastEncoderMovementMillis = ms; + } // encoderRateMultiplierEnabled + + #else + + constexpr int32_t encoderMultiplier = 1; + + #endif // ENCODER_RATE_MULTIPLIER + + if (can_encode()) encoderPosition += (encoderDiff * encoderMultiplier) / epps; + + encoderDiff = 0; + } + + reset_status_timeout(ms); + + refresh(LCDVIEW_REDRAW_NOW); + + #if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT) + if (!powerManager.psu_on) leds.reset_timeout(ms); + #endif + } + + #endif + + // This runs every ~100ms when idling often enough. + // Instead of tracking changes just redraw the Status Screen once per second. + if (on_status_screen() && !lcd_status_update_delay--) { + lcd_status_update_delay = TERN(HAS_MARLINUI_U8GLIB, 12, 9); + if (max_display_update_time) max_display_update_time--; // Be sure never go to a very big number + refresh(LCDVIEW_REDRAW_NOW); + } + + #if BOTH(HAS_LCD_MENU, SCROLL_LONG_FILENAMES) + // If scrolling of long file names is enabled and we are in the sd card menu, + // cause a refresh to occur until all the text has scrolled into view. + if (currentScreen == menu_media && !lcd_status_update_delay--) { + lcd_status_update_delay = ++filename_scroll_pos >= filename_scroll_max ? 12 : 4; // Long delay at end and start + if (filename_scroll_pos > filename_scroll_max) filename_scroll_pos = 0; + refresh(LCDVIEW_REDRAW_NOW); + reset_status_timeout(ms); + } + #endif + + // Then we want to use only 50% of the time + const uint16_t bbr2 = planner.block_buffer_runtime() >> 1; + + if ((should_draw() || drawing_screen) && (!bbr2 || bbr2 > max_display_update_time)) { + + // Change state of drawing flag between screen updates + if (!drawing_screen) switch (lcdDrawUpdate) { + case LCDVIEW_CALL_NO_REDRAW: + refresh(LCDVIEW_NONE); + break; + case LCDVIEW_CLEAR_CALL_REDRAW: + case LCDVIEW_CALL_REDRAW_NEXT: + refresh(LCDVIEW_REDRAW_NOW); + case LCDVIEW_REDRAW_NOW: // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT + case LCDVIEW_NONE: + break; + } // switch + + TERN_(HAS_ADC_BUTTONS, keypad_buttons = 0); + + #if HAS_MARLINUI_U8GLIB + + #if ENABLED(LIGHTWEIGHT_UI) + const bool in_status = on_status_screen(), + do_u8g_loop = !in_status; + lcd_in_status(in_status); + if (in_status) status_screen(); + #else + constexpr bool do_u8g_loop = true; + #endif + + if (do_u8g_loop) { + if (!drawing_screen) { // If not already drawing pages + u8g.firstPage(); // Start the first page + drawing_screen = first_page = true; // Flag as drawing pages + } + set_font(FONT_MENU); // Setup font for every page draw + u8g.setColorIndex(1); // And reset the color + run_current_screen(); // Draw and process the current screen + first_page = false; + + // The screen handler can clear drawing_screen for an action that changes the screen. + // If still drawing and there's another page, update max-time and return now. + // The nextPage will already be set up on the next call. + if (drawing_screen && (drawing_screen = u8g.nextPage())) { + if (on_status_screen()) + NOLESS(max_display_update_time, millis() - ms); + return; + } + } + + #else + + run_current_screen(); + + #endif + + TERN_(HAS_LCD_MENU, lcd_clicked = false); + + // Keeping track of the longest time for an individual LCD update. + // Used to do screen throttling when the planner starts to fill up. + if (on_status_screen()) + NOLESS(max_display_update_time, millis() - ms); + } + + #if SCREENS_CAN_TIME_OUT + // Return to Status Screen after a timeout + if (on_status_screen() || defer_return_to_status) + reset_status_timeout(ms); + else if (ELAPSED(ms, return_to_status_ms)) + return_to_status(); + #endif // Change state of drawing flag between screen updates if (!drawing_screen) switch (lcdDrawUpdate) { - case LCDVIEW_CALL_NO_REDRAW: - refresh(LCDVIEW_NONE); - break; case LCDVIEW_CLEAR_CALL_REDRAW: - case LCDVIEW_CALL_REDRAW_NEXT: - refresh(LCDVIEW_REDRAW_NOW); - case LCDVIEW_REDRAW_NOW: // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT + clear_lcd(); break; + case LCDVIEW_REDRAW_NOW: + refresh(LCDVIEW_NONE); case LCDVIEW_NONE: - break; + case LCDVIEW_CALL_REDRAW_NEXT: + case LCDVIEW_CALL_NO_REDRAW: + default: break; } // switch - TERN_(HAS_ADC_BUTTONS, keypad_buttons = 0); + } // ELAPSED(ms, next_lcd_update_ms) - #if HAS_MARLINUI_U8GLIB + TERN_(HAS_GRAPHICAL_TFT, tft_idle()); + } - #if ENABLED(LIGHTWEIGHT_UI) - const bool in_status = on_status_screen(), - do_u8g_loop = !in_status; - lcd_in_status(in_status); - if (in_status) status_screen(); - #else - constexpr bool do_u8g_loop = true; - #endif + #if HAS_ADC_BUTTONS - if (do_u8g_loop) { - if (!drawing_screen) { // If not already drawing pages - u8g.firstPage(); // Start the first page - drawing_screen = first_page = true; // Flag as drawing pages - } - set_font(FONT_MENU); // Setup font for every page draw - u8g.setColorIndex(1); // And reset the color - run_current_screen(); // Draw and process the current screen - first_page = false; + typedef struct { + uint16_t ADCKeyValueMin, ADCKeyValueMax; + uint8_t ADCKeyNo; + } _stADCKeypadTable_; - // The screen handler can clear drawing_screen for an action that changes the screen. - // If still drawing and there's another page, update max-time and return now. - // The nextPage will already be set up on the next call. - if (drawing_screen && (drawing_screen = u8g.nextPage())) { - if (on_status_screen()) - NOLESS(max_display_update_time, millis() - ms); - return; - } - } - - #else - - run_current_screen(); - - #endif - - TERN_(HAS_LCD_MENU, lcd_clicked = false); - - // Keeping track of the longest time for an individual LCD update. - // Used to do screen throttling when the planner starts to fill up. - if (on_status_screen()) - NOLESS(max_display_update_time, millis() - ms); - } - - #if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS > 0 - // Return to Status Screen after a timeout - if (on_status_screen() || defer_return_to_status) - RESET_STATUS_TIMEOUT(); - else if (ELAPSED(ms, return_to_status_ms)) - return_to_status(); + #ifndef ADC_BUTTONS_VALUE_SCALE + #define ADC_BUTTONS_VALUE_SCALE 1.0 // for the power voltage equal to the reference voltage + #endif + #ifndef ADC_BUTTONS_R_PULLUP + #define ADC_BUTTONS_R_PULLUP 4.7 // common pull-up resistor in the voltage divider + #endif + #ifndef ADC_BUTTONS_LEFT_R_PULLDOWN + #define ADC_BUTTONS_LEFT_R_PULLDOWN 0.47 // pull-down resistor for LEFT button voltage divider + #endif + #ifndef ADC_BUTTONS_RIGHT_R_PULLDOWN + #define ADC_BUTTONS_RIGHT_R_PULLDOWN 4.7 // pull-down resistor for RIGHT button voltage divider + #endif + #ifndef ADC_BUTTONS_UP_R_PULLDOWN + #define ADC_BUTTONS_UP_R_PULLDOWN 1.0 // pull-down resistor for UP button voltage divider + #endif + #ifndef ADC_BUTTONS_DOWN_R_PULLDOWN + #define ADC_BUTTONS_DOWN_R_PULLDOWN 10.0 // pull-down resistor for DOWN button voltage divider + #endif + #ifndef ADC_BUTTONS_MIDDLE_R_PULLDOWN + #define ADC_BUTTONS_MIDDLE_R_PULLDOWN 2.2 // pull-down resistor for MIDDLE button voltage divider #endif - // Change state of drawing flag between screen updates - if (!drawing_screen) switch (lcdDrawUpdate) { - case LCDVIEW_CLEAR_CALL_REDRAW: - clear_lcd(); break; - case LCDVIEW_REDRAW_NOW: - refresh(LCDVIEW_NONE); - case LCDVIEW_NONE: - case LCDVIEW_CALL_REDRAW_NEXT: - case LCDVIEW_CALL_NO_REDRAW: - default: break; - } // switch + // Calculate the ADC value for the voltage divider with specified pull-down resistor value + #define ADC_BUTTON_VALUE(r) int(HAL_ADC_RANGE * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)) - } // ELAPSED(ms, next_lcd_update_ms) + static constexpr uint16_t adc_button_tolerance = HAL_ADC_RANGE * 25 / 1024, + adc_other_button = HAL_ADC_RANGE * 1000 / 1024; + static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = { + // VALUE_MIN, VALUE_MAX, KEY + { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F1 }, // F1 + { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F2 }, // F2 + { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F3 }, // F3 + { ADC_BUTTON_VALUE(ADC_BUTTONS_LEFT_R_PULLDOWN) - adc_button_tolerance, + ADC_BUTTON_VALUE(ADC_BUTTONS_LEFT_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_LEFT }, // LEFT ( 272 ... 472) + { ADC_BUTTON_VALUE(ADC_BUTTONS_RIGHT_R_PULLDOWN) - adc_button_tolerance, + ADC_BUTTON_VALUE(ADC_BUTTONS_RIGHT_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_RIGHT }, // RIGHT (1948 ... 2148) + { ADC_BUTTON_VALUE(ADC_BUTTONS_UP_R_PULLDOWN) - adc_button_tolerance, + ADC_BUTTON_VALUE(ADC_BUTTONS_UP_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_UP }, // UP ( 618 ... 818) + { ADC_BUTTON_VALUE(ADC_BUTTONS_DOWN_R_PULLDOWN) - adc_button_tolerance, + ADC_BUTTON_VALUE(ADC_BUTTONS_DOWN_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_DOWN }, // DOWN (2686 ... 2886) + { ADC_BUTTON_VALUE(ADC_BUTTONS_MIDDLE_R_PULLDOWN) - adc_button_tolerance, + ADC_BUTTON_VALUE(ADC_BUTTONS_MIDDLE_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_MIDDLE }, // ENTER (1205 ... 1405) + }; - TERN_(HAS_GRAPHICAL_TFT, tft_idle()); -} - -#if HAS_ADC_BUTTONS - - typedef struct { - uint16_t ADCKeyValueMin, ADCKeyValueMax; - uint8_t ADCKeyNo; - } _stADCKeypadTable_; - - #ifndef ADC_BUTTONS_VALUE_SCALE - #define ADC_BUTTONS_VALUE_SCALE 1.0 // for the power voltage equal to the reference voltage - #endif - #ifndef ADC_BUTTONS_R_PULLUP - #define ADC_BUTTONS_R_PULLUP 4.7 // common pull-up resistor in the voltage divider - #endif - #ifndef ADC_BUTTONS_LEFT_R_PULLDOWN - #define ADC_BUTTONS_LEFT_R_PULLDOWN 0.47 // pull-down resistor for LEFT button voltage divider - #endif - #ifndef ADC_BUTTONS_RIGHT_R_PULLDOWN - #define ADC_BUTTONS_RIGHT_R_PULLDOWN 4.7 // pull-down resistor for RIGHT button voltage divider - #endif - #ifndef ADC_BUTTONS_UP_R_PULLDOWN - #define ADC_BUTTONS_UP_R_PULLDOWN 1.0 // pull-down resistor for UP button voltage divider - #endif - #ifndef ADC_BUTTONS_DOWN_R_PULLDOWN - #define ADC_BUTTONS_DOWN_R_PULLDOWN 10.0 // pull-down resistor for DOWN button voltage divider - #endif - #ifndef ADC_BUTTONS_MIDDLE_R_PULLDOWN - #define ADC_BUTTONS_MIDDLE_R_PULLDOWN 2.2 // pull-down resistor for MIDDLE button voltage divider - #endif - - // Calculate the ADC value for the voltage divider with specified pull-down resistor value - #define ADC_BUTTON_VALUE(r) int(HAL_ADC_RANGE * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)) - - static constexpr uint16_t adc_button_tolerance = HAL_ADC_RANGE * 25 / 1024, - adc_other_button = HAL_ADC_RANGE * 1000 / 1024; - static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = { - // VALUE_MIN, VALUE_MAX, KEY - { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F1 }, // F1 - { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F2 }, // F2 - { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F3 }, // F3 - { ADC_BUTTON_VALUE(ADC_BUTTONS_LEFT_R_PULLDOWN) - adc_button_tolerance, - ADC_BUTTON_VALUE(ADC_BUTTONS_LEFT_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_LEFT }, // LEFT ( 272 ... 472) - { ADC_BUTTON_VALUE(ADC_BUTTONS_RIGHT_R_PULLDOWN) - adc_button_tolerance, - ADC_BUTTON_VALUE(ADC_BUTTONS_RIGHT_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_RIGHT }, // RIGHT (1948 ... 2148) - { ADC_BUTTON_VALUE(ADC_BUTTONS_UP_R_PULLDOWN) - adc_button_tolerance, - ADC_BUTTON_VALUE(ADC_BUTTONS_UP_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_UP }, // UP ( 618 ... 818) - { ADC_BUTTON_VALUE(ADC_BUTTONS_DOWN_R_PULLDOWN) - adc_button_tolerance, - ADC_BUTTON_VALUE(ADC_BUTTONS_DOWN_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_DOWN }, // DOWN (2686 ... 2886) - { ADC_BUTTON_VALUE(ADC_BUTTONS_MIDDLE_R_PULLDOWN) - adc_button_tolerance, - ADC_BUTTON_VALUE(ADC_BUTTONS_MIDDLE_R_PULLDOWN) + adc_button_tolerance, 1 + BLEN_KEYPAD_MIDDLE }, // ENTER (1205 ... 1405) - }; - - uint8_t get_ADC_keyValue() { - if (thermalManager.ADCKey_count >= 16) { - const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw; - thermalManager.current_ADCKey_raw = HAL_ADC_RANGE; - thermalManager.ADCKey_count = 0; - if (currentkpADCValue < adc_other_button) - LOOP_L_N(i, ADC_KEY_NUM) { - const uint16_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin), - hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax); - if (WITHIN(currentkpADCValue, lo, hi)) return pgm_read_byte(&stADCKeyTable[i].ADCKeyNo); - } - } - return 0; - } - -#endif // HAS_ADC_BUTTONS - -#if HAS_ENCODER_ACTION - - /** - * Read encoder buttons from the hardware registers - * Warning: This function is called from interrupt context! - */ - void MarlinUI::update_buttons() { - const millis_t now = millis(); - if (ELAPSED(now, next_button_update_ms)) { - - #if HAS_DIGITAL_BUTTONS - - #if ANY_BUTTON(EN1, EN2, ENC, BACK) - - uint8_t newbutton = 0; - if (BUTTON_PRESSED(EN1)) newbutton |= EN_A; - if (BUTTON_PRESSED(EN2)) newbutton |= EN_B; - if (can_encode() && BUTTON_PRESSED(ENC)) newbutton |= EN_C; - if (BUTTON_PRESSED(BACK)) newbutton |= EN_D; - - #else - - constexpr uint8_t newbutton = 0; - - #endif - - // - // Directional buttons - // - #if ANY_BUTTON(UP, DWN, LFT, RT) - - const int8_t pulses = epps * encoderDirection; - - if (BUTTON_PRESSED(UP)) { - encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * pulses; - next_button_update_ms = now + 300; + uint8_t get_ADC_keyValue() { + if (thermalManager.ADCKey_count >= 16) { + const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw; + thermalManager.current_ADCKey_raw = HAL_ADC_RANGE; + thermalManager.ADCKey_count = 0; + if (currentkpADCValue < adc_other_button) + LOOP_L_N(i, ADC_KEY_NUM) { + const uint16_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin), + hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax); + if (WITHIN(currentkpADCValue, lo, hi)) return pgm_read_byte(&stADCKeyTable[i].ADCKeyNo); } - else if (BUTTON_PRESSED(DWN)) { - encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * pulses; - next_button_update_ms = now + 300; - } - else if (BUTTON_PRESSED(LFT)) { - encoderDiff = -pulses; - next_button_update_ms = now + 300; - } - else if (BUTTON_PRESSED(RT)) { - encoderDiff = pulses; - next_button_update_ms = now + 300; - } - - #endif // UP || DWN || LFT || RT - - buttons = (newbutton | TERN0(HAS_SLOW_BUTTONS, slow_buttons) - #if BOTH(HAS_TOUCH_BUTTONS, HAS_ENCODER_ACTION) - | (touch_buttons & TERN(HAS_ENCODER_WHEEL, ~(EN_A | EN_B), 0xFF)) - #endif - ); - - #elif HAS_ADC_BUTTONS - - buttons = 0; - - #endif - - #if HAS_ADC_BUTTONS - if (keypad_buttons == 0) { - const uint8_t b = get_ADC_keyValue(); - if (WITHIN(b, 1, 8)) keypad_buttons = _BV(b - 1); - } - #endif - - #if HAS_SHIFT_ENCODER - /** - * Set up Rotary Encoder bit values (for two pin encoders to indicate movement). - * These values are independent of which pins are used for EN_A / EN_B indications. - * The rotary encoder part is also independent of the LCD chipset. - */ - uint8_t val = 0; - WRITE(SHIFT_LD_PIN, LOW); - WRITE(SHIFT_LD_PIN, HIGH); - LOOP_L_N(i, 8) { - val >>= 1; - if (READ(SHIFT_OUT_PIN)) SBI(val, 7); - WRITE(SHIFT_CLK_PIN, HIGH); - WRITE(SHIFT_CLK_PIN, LOW); - } - TERN(REPRAPWORLD_KEYPAD, keypad_buttons, buttons) = ~val; - #endif - - #if IS_TFTGLCD_PANEL - next_button_update_ms = now + (LCD_UPDATE_INTERVAL / 2); - buttons = slow_buttons; - TERN_(AUTO_BED_LEVELING_UBL, external_encoder()); - #endif - - } // next_button_update_ms - - #if HAS_ENCODER_WHEEL - static uint8_t lastEncoderBits; - - // Manage encoder rotation - #define ENCODER_SPIN(_E1, _E2) switch (lastEncoderBits) { case _E1: encoderDiff += encoderDirection; break; case _E2: encoderDiff -= encoderDirection; } - - uint8_t enc = 0; - if (buttons & EN_A) enc |= B01; - if (buttons & EN_B) enc |= B10; - if (enc != lastEncoderBits) { - switch (enc) { - case ENCODER_PHASE_0: ENCODER_SPIN(ENCODER_PHASE_3, ENCODER_PHASE_1); break; - case ENCODER_PHASE_1: ENCODER_SPIN(ENCODER_PHASE_0, ENCODER_PHASE_2); break; - case ENCODER_PHASE_2: ENCODER_SPIN(ENCODER_PHASE_1, ENCODER_PHASE_3); break; - case ENCODER_PHASE_3: ENCODER_SPIN(ENCODER_PHASE_2, ENCODER_PHASE_0); break; - } - #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL) - external_encoder(); - #endif - lastEncoderBits = enc; } + return 0; + } - #endif // HAS_ENCODER_WHEEL - } + #endif // HAS_ADC_BUTTONS -#endif // HAS_ENCODER_ACTION + #if HAS_ENCODER_ACTION + + /** + * Read encoder buttons from the hardware registers + * Warning: This function is called from interrupt context! + */ + void MarlinUI::update_buttons() { + const millis_t now = millis(); + if (ELAPSED(now, next_button_update_ms)) { + + #if HAS_DIGITAL_BUTTONS + + #if ANY_BUTTON(EN1, EN2, ENC, BACK) + + uint8_t newbutton = 0; + if (BUTTON_PRESSED(EN1)) newbutton |= EN_A; + if (BUTTON_PRESSED(EN2)) newbutton |= EN_B; + if (can_encode() && BUTTON_PRESSED(ENC)) newbutton |= EN_C; + if (BUTTON_PRESSED(BACK)) newbutton |= EN_D; + + #else + + constexpr uint8_t newbutton = 0; + + #endif + + // + // Directional buttons + // + #if ANY_BUTTON(UP, DWN, LFT, RT) + + const int8_t pulses = epps * encoderDirection; + + if (BUTTON_PRESSED(UP)) { + encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * pulses; + next_button_update_ms = now + 300; + } + else if (BUTTON_PRESSED(DWN)) { + encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * pulses; + next_button_update_ms = now + 300; + } + else if (BUTTON_PRESSED(LFT)) { + encoderDiff = -pulses; + next_button_update_ms = now + 300; + } + else if (BUTTON_PRESSED(RT)) { + encoderDiff = pulses; + next_button_update_ms = now + 300; + } + + #endif // UP || DWN || LFT || RT + + buttons = (newbutton | TERN0(HAS_SLOW_BUTTONS, slow_buttons) + #if BOTH(HAS_TOUCH_BUTTONS, HAS_ENCODER_ACTION) + | (touch_buttons & TERN(HAS_ENCODER_WHEEL, ~(EN_A | EN_B), 0xFF)) + #endif + ); + + #elif HAS_ADC_BUTTONS + + buttons = 0; + + #endif + + #if HAS_ADC_BUTTONS + if (keypad_buttons == 0) { + const uint8_t b = get_ADC_keyValue(); + if (WITHIN(b, 1, 8)) keypad_buttons = _BV(b - 1); + } + #endif + + #if HAS_SHIFT_ENCODER + /** + * Set up Rotary Encoder bit values (for two pin encoders to indicate movement). + * These values are independent of which pins are used for EN_A / EN_B indications. + * The rotary encoder part is also independent of the LCD chipset. + */ + uint8_t val = 0; + WRITE(SHIFT_LD_PIN, LOW); + WRITE(SHIFT_LD_PIN, HIGH); + LOOP_L_N(i, 8) { + val >>= 1; + if (READ(SHIFT_OUT_PIN)) SBI(val, 7); + WRITE(SHIFT_CLK_PIN, HIGH); + WRITE(SHIFT_CLK_PIN, LOW); + } + TERN(REPRAPWORLD_KEYPAD, keypad_buttons, buttons) = ~val; + #endif + + #if IS_TFTGLCD_PANEL + next_button_update_ms = now + (LCD_UPDATE_INTERVAL / 2); + buttons = slow_buttons; + TERN_(AUTO_BED_LEVELING_UBL, external_encoder()); + #endif + + } // next_button_update_ms + + #if HAS_ENCODER_WHEEL + static uint8_t lastEncoderBits; + + // Manage encoder rotation + #define ENCODER_SPIN(_E1, _E2) switch (lastEncoderBits) { case _E1: encoderDiff += encoderDirection; break; case _E2: encoderDiff -= encoderDirection; } + + uint8_t enc = 0; + if (buttons & EN_A) enc |= B01; + if (buttons & EN_B) enc |= B10; + if (enc != lastEncoderBits) { + switch (enc) { + case ENCODER_PHASE_0: ENCODER_SPIN(ENCODER_PHASE_3, ENCODER_PHASE_1); break; + case ENCODER_PHASE_1: ENCODER_SPIN(ENCODER_PHASE_0, ENCODER_PHASE_2); break; + case ENCODER_PHASE_2: ENCODER_SPIN(ENCODER_PHASE_1, ENCODER_PHASE_3); break; + case ENCODER_PHASE_3: ENCODER_SPIN(ENCODER_PHASE_2, ENCODER_PHASE_0); break; + } + #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL) + external_encoder(); + #endif + lastEncoderBits = enc; + } + + #endif // HAS_ENCODER_WHEEL + } + + #endif // HAS_ENCODER_ACTION #endif // HAS_WIRED_LCD @@ -1498,6 +1502,13 @@ void MarlinUI::update() { TERN_(HAS_LCD_MENU, return_to_status()); } + #if BOTH(PSU_CONTROL, PS_OFF_CONFIRM) + void MarlinUI::poweroff() { + queue.inject_P(PSTR("M81")); + goto_previous_screen(); + } + #endif + void MarlinUI::flow_fault() { LCD_ALERTMESSAGEPGM(MSG_FLOWMETER_FAULT); TERN_(HAS_BUZZER, buzz(1000, 440)); @@ -1613,8 +1624,9 @@ void MarlinUI::update() { if (status) { if (old_status < 2) { - TERN_(EXTENSIBLE_UI, ExtUI::onMediaInserted()); // ExtUI response - #if ENABLED(BROWSE_MEDIA_ON_INSERT) + #if ENABLED(EXTENSIBLE_UI) + ExtUI::onMediaInserted(); + #elif ENABLED(BROWSE_MEDIA_ON_INSERT) clear_menu_history(); quick_feedback(); goto_screen(MEDIA_MENU_GATEWAY); @@ -1625,8 +1637,9 @@ void MarlinUI::update() { } else { if (old_status < 2) { - TERN_(EXTENSIBLE_UI, ExtUI::onMediaRemoved()); // ExtUI response - #if PIN_EXISTS(SD_DETECT) + #if ENABLED(EXTENSIBLE_UI) + ExtUI::onMediaRemoved(); + #elif PIN_EXISTS(SD_DETECT) LCD_MESSAGEPGM(MSG_MEDIA_REMOVED); #if HAS_LCD_MENU if (!defer_return_to_status) return_to_status(); @@ -1664,6 +1677,40 @@ void MarlinUI::update() { } #endif +#if BOTH(EXTENSIBLE_UI, ADVANCED_PAUSE_FEATURE) + + void MarlinUI::pause_show_message( + const PauseMessage message, + const PauseMode mode/*=PAUSE_MODE_SAME*/, + const uint8_t extruder/*=active_extruder*/ + ) { + if (mode == PAUSE_MODE_SAME) + return; + pause_mode = mode; + switch (message) { + case PAUSE_MESSAGE_PARKING: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PAUSE_PRINT_PARKING)); + case PAUSE_MESSAGE_CHANGING: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_INIT)); + case PAUSE_MESSAGE_UNLOAD: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_UNLOAD)); + case PAUSE_MESSAGE_WAITING: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_ADVANCED_PAUSE_WAITING)); + case PAUSE_MESSAGE_INSERT: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_INSERT)); + case PAUSE_MESSAGE_LOAD: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_LOAD)); + case PAUSE_MESSAGE_PURGE: + #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE) + ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_CONT_PURGE)); + #else + ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_PURGE)); + #endif + case PAUSE_MESSAGE_RESUME: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_RESUME)); + case PAUSE_MESSAGE_HEAT: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_HEAT)); + case PAUSE_MESSAGE_HEATING: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_HEATING)); + case PAUSE_MESSAGE_OPTION: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_OPTION_HEADER)); + case PAUSE_MESSAGE_STATUS: + default: break; + } + } + +#endif + #if ENABLED(EEPROM_SETTINGS) #if HAS_LCD_MENU diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 766e46c66b..9930796a01 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -55,7 +55,7 @@ #include "../module/printcounter.h" #endif -#if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE) +#if ENABLED(ADVANCED_PAUSE_FEATURE) && EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) #include "../feature/pause.h" #include "../module/motion.h" // for active_extruder #endif @@ -111,13 +111,13 @@ #if PREHEAT_COUNT typedef struct { - #if ENABLED(HAS_HOTEND) + #if HAS_HOTEND celsius_t hotend_temp; #endif - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED celsius_t bed_temp; #endif - #if ENABLED(HAS_FAN) + #if HAS_FAN uint16_t fan_speed; #endif } preheat_t; @@ -135,12 +135,12 @@ static int8_t constexpr e_index = 0; #endif static millis_t start_time; - #if ENABLED(IS_KINEMATIC) + #if IS_KINEMATIC static xyze_pos_t all_axes_destination; #endif public: static float menu_scale; - #if ENABLED(IS_KINEMATIC) + #if IS_KINEMATIC static float offset; #endif template @@ -200,13 +200,11 @@ public: #if HAS_MULTI_LANGUAGE static uint8_t language; - static inline void set_language(const uint8_t lang) { - if (lang < NUM_LANGUAGES) { - language = lang; - return_to_status(); - refresh(); - } - } + static void set_language(const uint8_t lang); + #endif + + #if HAS_MARLINUI_U8GLIB + static void update_language_font(); #endif #if ENABLED(SOUND_MENU_ITEM) @@ -241,6 +239,22 @@ public: static void media_changed(const uint8_t old_stat, const uint8_t stat); #endif + #if HAS_LCD_BRIGHTNESS + #ifndef MIN_LCD_BRIGHTNESS + #define MIN_LCD_BRIGHTNESS 1 + #endif + #ifndef MAX_LCD_BRIGHTNESS + #define MAX_LCD_BRIGHTNESS 255 + #endif + #ifndef DEFAULT_LCD_BRIGHTNESS + #define DEFAULT_LCD_BRIGHTNESS MAX_LCD_BRIGHTNESS + #endif + static uint8_t brightness; + static bool backlight; + static void set_brightness(const uint8_t value); + FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); } + #endif + #if ENABLED(DWIN_CREALITY_LCD) static void refresh(); #else @@ -298,6 +312,17 @@ public: #endif #if HAS_STATUS_MESSAGE + + #if HAS_WIRED_LCD + #if ENABLED(STATUS_MESSAGE_SCROLLING) + #define MAX_MESSAGE_LENGTH _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH)) + #else + #define MAX_MESSAGE_LENGTH (MAX_LANG_CHARSIZE * (LCD_WIDTH)) + #endif + #else + #define MAX_MESSAGE_LENGTH 63 + #endif + static char status_message[]; static uint8_t alert_level; // Higher levels block lower levels @@ -334,6 +359,10 @@ public: static void resume_print(); static void flow_fault(); + #if BOTH(PSU_CONTROL, PS_OFF_CONFIRM) + static void poweroff(); + #endif + #if HAS_WIRED_LCD static millis_t next_button_update_ms; @@ -445,10 +474,13 @@ public: static PGM_P get_preheat_label(const uint8_t m); #endif + #if SCREENS_CAN_TIME_OUT + static inline void reset_status_timeout(const millis_t ms) { return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; } + #else + static inline void reset_status_timeout(const millis_t) {} + #endif + #if HAS_LCD_MENU - #if LCD_TIMEOUT_TO_STATUS - static millis_t return_to_status_ms; - #endif #if HAS_TOUCH_BUTTONS static uint8_t touch_buttons; @@ -474,15 +506,12 @@ public: static void set_selection(const bool sel) { selection = sel; } static bool update_selection(); - static bool lcd_clicked; - static bool use_click(); - static void synchronize(PGM_P const msg=nullptr); static screenFunc_t currentScreen; static bool screen_changed; static void goto_screen(const screenFunc_t screen, const uint16_t encoder=0, const uint8_t top=0, const uint8_t items=0); - static void save_previous_screen(); + static void push_current_screen(); // goto_previous_screen and go_back may also be used as menu item callbacks static void _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back)); @@ -497,12 +526,12 @@ public: static void lcd_in_status(const bool inStatus); #endif + FORCE_INLINE static bool screen_is_sticky() { + return TERN1(SCREENS_CAN_TIME_OUT, defer_return_to_status); + } + FORCE_INLINE static void defer_status_screen(const bool defer=true) { - #if LCD_TIMEOUT_TO_STATUS > 0 - defer_return_to_status = defer; - #else - UNUSED(defer); - #endif + TERN(SCREENS_CAN_TIME_OUT, defer_return_to_status = defer, UNUSED(defer)); } static inline void goto_previous_screen_no_defer() { @@ -525,15 +554,29 @@ public: static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr); - #elif HAS_WIRED_LCD + #else - static constexpr bool lcd_clicked = false; static constexpr bool on_status_screen() { return true; } - FORCE_INLINE static void run_current_screen() { status_screen(); } + + #if HAS_WIRED_LCD + FORCE_INLINE static void run_current_screen() { status_screen(); } + #endif #endif - #if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE) + #if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) + static bool lcd_clicked; + static inline bool use_click() { + const bool click = lcd_clicked; + lcd_clicked = false; + return click; + } + #else + static constexpr bool lcd_clicked = false; + static inline bool use_click() { return false; } + #endif + + #if ENABLED(ADVANCED_PAUSE_FEATURE) && EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) static void pause_show_message(const PauseMessage message, const PauseMode mode=PAUSE_MODE_SAME, const uint8_t extruder=active_extruder); #else static inline void _pause_show_message() {} @@ -643,16 +686,18 @@ public: private: + #if SCREENS_CAN_TIME_OUT + static millis_t return_to_status_ms; + static bool defer_return_to_status; + #else + static constexpr bool defer_return_to_status = false; + #endif + #if HAS_STATUS_MESSAGE static void finish_status(const bool persist); #endif #if HAS_WIRED_LCD - #if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS > 0 - static bool defer_return_to_status; - #else - static constexpr bool defer_return_to_status = false; - #endif static void draw_status_screen(); #if HAS_GRAPHICAL_TFT static void tft_idle(); diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 6143e8da1e..01c8bb80c0 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -50,9 +50,12 @@ int8_t encoderTopLine, encoderLine, screen_items; typedef struct { - screenFunc_t menu_function; - uint32_t encoder_position; - int8_t top_line, items; + screenFunc_t menu_function; // The screen's function + uint32_t encoder_position; // The position of the encoder + int8_t top_line, items; // The amount of scroll, and the number of items + #if SCREENS_CAN_TIME_OUT + bool sticky; // The screen is sticky + #endif } menuPosition; menuPosition screen_history[6]; uint8_t screen_history_depth = 0; @@ -75,9 +78,9 @@ bool MenuEditItemBase::liveEdit; void MarlinUI::return_to_status() { goto_screen(status_screen); } -void MarlinUI::save_previous_screen() { +void MarlinUI::push_current_screen() { if (screen_history_depth < COUNT(screen_history)) - screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items }; + screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items OPTARG(SCREENS_CAN_TIME_OUT, screen_is_sticky()) }; } void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) { @@ -90,6 +93,7 @@ void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_b is_back ? 0 : sh.top_line, sh.items ); + defer_status_screen(TERN_(SCREENS_CAN_TIME_OUT, sh.sticky)); } else return_to_status(); @@ -147,7 +151,7 @@ void MenuEditItemBase::goto_edit_screen( ) { TERN_(HAS_TOUCH_BUTTONS, ui.on_edit_screen = true); ui.screen_changed = true; - ui.save_previous_screen(); + ui.push_current_screen(); ui.refresh(); editLabel = el; editValue = ev; @@ -237,7 +241,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co // void MarlinUI::synchronize(PGM_P const msg/*=nullptr*/) { static PGM_P sync_message = msg ?: GET_TEXT(MSG_MOVING); - save_previous_screen(); + push_current_screen(); goto_screen([]{ if (should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, sync_message); }); @@ -371,6 +375,7 @@ void MenuItem_confirm::select_screen( selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/ ) { + ui.defer_status_screen(); const bool ui_selection = ui.update_selection(), got_click = ui.use_click(); if (got_click || ui.should_draw()) { draw_select_screen(yes, no, ui_selection, pref, string, suff); @@ -378,7 +383,6 @@ void MenuItem_confirm::select_screen( selectFunc_t callFunc = ui_selection ? yesFunc : noFunc; if (callFunc) callFunc(); else ui.goto_previous_screen(); } - ui.defer_status_screen(); } } diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 290832c49c..28d377da0c 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -132,14 +132,15 @@ class MenuItem_confirm : public MenuItemBase { // The Menu Edit shadow value typedef union { - bool state; - float decimal; - int8_t int8; - int16_t int16; - int32_t int32; - uint8_t uint8; - uint16_t uint16; - uint32_t uint32; + bool state; + float decimal; + int8_t int8; + int16_t int16; + int32_t int32; + uint8_t uint8; + uint16_t uint16; + uint32_t uint32; + celsius_t celsius; } chimera_t; extern chimera_t editable; diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index a6719f1847..4ae38edf24 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -58,7 +58,7 @@ void menu_tmc(); void menu_backlash(); -#if ENABLED(HAS_MOTOR_CURRENT_DAC) +#if HAS_MOTOR_CURRENT_DAC #include "../../feature/dac/stepper_dac.h" @@ -590,7 +590,7 @@ void menu_advanced_settings() { SUBMENU(MSG_BACKLASH, menu_backlash); #endif - #if ENABLED(HAS_MOTOR_CURRENT_DAC) + #if HAS_MOTOR_CURRENT_DAC SUBMENU(MSG_DRIVE_STRENGTH, menu_dac); #endif #if HAS_MOTOR_CURRENT_PWM diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 0ab82a9b16..82f25ea6f3 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -87,7 +87,7 @@ constexpr int lco[] = LEVEL_CORNERS_LEVELING_ORDER; constexpr bool level_corners_3_points = COUNT(lco) == 2; static_assert(level_corners_3_points || COUNT(lco) == 4, "LEVEL_CORNERS_LEVELING_ORDER must have exactly 2 or 4 corners."); -constexpr int lcodiff = abs(lco[0] - lco[1]); +constexpr int lcodiff = ABS(lco[0] - lco[1]); static_assert(COUNT(lco) == 4 || lcodiff == 1 || lcodiff == 3, "The first two LEVEL_CORNERS_LEVELING_ORDER corners must be on the same edge."); constexpr int nr_edge_points = level_corners_3_points ? 3 : 4; @@ -179,7 +179,7 @@ static void _lcd_level_bed_corners_get_next_position() { // Display # of good points found vs total needed if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) { SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy); - lcd_put_u8str_P(GET_TEXT(MSG_LEVEL_CORNERS_GOOD_POINTS)); + lcd_put_u8str_P(GET_TEXT(MSG_BED_TRAMMING_GOOD_POINTS)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, cy)); lcd_put_u8str(GOOD_POINTS_TO_STR(good_points)); lcd_put_wchar('/'); @@ -187,12 +187,12 @@ static void _lcd_level_bed_corners_get_next_position() { } --cy; - y -= MENU_FONT_HEIGHT; + y -= MENU_LINE_HEIGHT; // Display the Last Z value if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) { SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy); - lcd_put_u8str_P(GET_TEXT(MSG_LEVEL_CORNERS_LAST_Z)); + lcd_put_u8str_P(GET_TEXT(MSG_BED_TRAMMING_LAST_Z)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, 2)); lcd_put_u8str(LAST_Z_TO_STR(last_z)); } @@ -201,10 +201,10 @@ static void _lcd_level_bed_corners_get_next_position() { void _lcd_draw_raise() { if (!ui.should_draw()) return; MenuItem_confirm::select_screen( - GET_TEXT(MSG_BUTTON_DONE), GET_TEXT(MSG_BUTTON_SKIP) + GET_TEXT(MSG_BUTTON_DONE), GET_TEXT(MSG_BUTTON_SKIP) , []{ corner_probing_done = true; wait_for_probe = false; } , []{ wait_for_probe = false; } - , GET_TEXT(MSG_LEVEL_CORNERS_RAISE) + , GET_TEXT(MSG_BED_TRAMMING_RAISE) , (const char*)nullptr, NUL_STR ); } @@ -212,11 +212,9 @@ static void _lcd_level_bed_corners_get_next_position() { void _lcd_draw_level_prompt() { if (!ui.should_draw()) return; MenuItem_confirm::confirm_screen( - []{ queue.inject_P(TERN(HAS_LEVELING, PSTR("G29N"), G28_STR)); - ui.return_to_status(); - } + []{ queue.inject_P(TERN(HAS_LEVELING, PSTR("G29N"), G28_STR)); ui.return_to_status(); } , []{ ui.goto_previous_screen_no_defer(); } - , GET_TEXT(MSG_LEVEL_CORNERS_IN_RANGE) + , GET_TEXT(MSG_BED_TRAMMING_IN_RANGE) , (const char*)nullptr, PSTR("?") ); } diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 62cf8cf1c1..f01c7899fb 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -278,7 +278,12 @@ void menu_bed_leveling() { // Mesh Bed Leveling Z-Offset // #if ENABLED(MESH_BED_LEVELING) - EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1); + #if WITHIN(Z_PROBE_OFFSET_RANGE_MIN, -9, 9) + #define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000 + #else + #define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99 + #endif + EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_BED_Z, &mbl.z_offset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); #endif #if ENABLED(BABYSTEP_ZPROBE_OFFSET) @@ -288,7 +293,7 @@ void menu_bed_leveling() { #endif #if ENABLED(LEVEL_BED_CORNERS) - SUBMENU(MSG_LEVEL_CORNERS, _lcd_level_bed_corners); + SUBMENU(MSG_BED_TRAMMING, _lcd_level_bed_corners); #endif #if ENABLED(EEPROM_SETTINGS) diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index 195afecc1b..810f376f82 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -31,6 +31,7 @@ #include "menu_item.h" #include "../../module/delta.h" #include "../../module/motion.h" +#include "../../module/planner.h" #if HAS_LEVELING #include "../../feature/bedlevel/bedlevel.h" @@ -46,7 +47,7 @@ void _man_probe_pt(const xy_pos_t &xy) { do_blocking_move_to_xy_z(xy, Z_CLEARANCE_BETWEEN_PROBES); ui.wait_for_move = false; ui.synchronize(); - ui.manual_move.menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT)); + ui.manual_move.menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / planner.settings.axis_steps_per_mm[0]); // Use first axis as for delta XYZ should always match ui.goto_screen(lcd_move_z); } } @@ -105,7 +106,7 @@ void lcd_delta_settings() { START_MENU(); BACK_ITEM(MSG_DELTA_CALIBRATE); EDIT_ITEM(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings); - #define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_endstop_adj.N, -5, 5, _recalc_delta_settings) + #define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_endstop_adj.N, -5, 0, _recalc_delta_settings) EDIT_ENDSTOP_ADJ("Ex", a); EDIT_ENDSTOP_ADJ("Ey", b); EDIT_ENDSTOP_ADJ("Ez", c); diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index c6b8568085..53fd67dbb2 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -106,10 +106,11 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) { * "Change Filament" submenu */ #if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - bool printingIsPaused(); +#endif - void menu_change_filament() { +void menu_change_filament() { + #if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) // Say "filament change" when no print is active editable.int8 = printingIsPaused() ? PAUSE_MODE_PAUSE_PRINT : PAUSE_MODE_CHANGE_FILAMENT; @@ -204,8 +205,16 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) { #endif END_MENU(); - } -#endif + + #else + + if (thermalManager.targetHotEnoughToExtrude(active_extruder)) + queue.inject_P(PSTR("M600B0")); + else + ui.goto_screen([]{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); }); + + #endif +} static uint8_t hotend_status_extruder = 0; diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index bcd93e11f8..0a4f4bb7d1 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -39,7 +39,7 @@ class MenuItem_submenu : public MenuItemBase { FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]); } - static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); } + static inline void action(PGM_P const, const screenFunc_t func) { ui.push_current_screen(); ui.goto_screen(func); } }; // Any menu item that invokes an immediate action @@ -406,7 +406,7 @@ class MenuItem_bool : public MenuEditItemBase { #define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do { \ if (encoderLine == _thisItemNr && ui.use_click()) { \ - ui.save_previous_screen(); \ + ui.push_current_screen(); \ ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \ return; \ } \ @@ -434,23 +434,23 @@ class MenuItem_bool : public MenuEditItemBase { }while(0) // Indexed items set a global index value -#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V) +#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V) -#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) -#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V) +#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) +#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V) -#define YESNO_ITEM_P(PLABEL, V...) _CONFIRM_ITEM_P(PLABEL, ##V) -#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V) +#define YESNO_ITEM_P(PLABEL, V...) CONFIRM_ITEM_P(PLABEL, MSG_YES, MSG_NO, ##V) +#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V) #define CONFIRM_ITEM_N_S_P(N,S,PLABEL,A,B,V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) #define CONFIRM_ITEM_N_S(N,S,LABEL,V...) CONFIRM_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) #define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...) _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) #define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V) -#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, ##V) -#define YESNO_ITEM_N_S(N,S,LABEL, V...) YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) -#define YESNO_ITEM_N_P(N,PLABEL, V...) _CONFIRM_ITEM_N_P(N, PLABEL, ##V) -#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V) +#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, MSG_YES, MSG_NO, ##V) +#define YESNO_ITEM_N_S(N,S,LABEL, V...) YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) +#define YESNO_ITEM_N_P(N,PLABEL, V...) CONFIRM_ITEM_N_P(N, PLABEL, MSG_YES, MSG_NO, ##V) +#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V) #if ENABLED(LEVEL_BED_CORNERS) void _lcd_level_bed_corners(); diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 284e80c931..3261ecc658 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -30,6 +30,10 @@ #include "menu_item.h" +#if ENABLED(PSU_CONTROL) + #include "../../feature/power.h" +#endif + #if ENABLED(LED_CONTROL_MENU) #include "../../feature/leds/leds.h" @@ -125,12 +129,7 @@ void menu_led() { BACK_ITEM(MSG_MAIN); #if ENABLED(LED_CONTROL_MENU) - #if ENABLED(PSU_CONTROL) - extern bool powersupply_on; - #else - constexpr bool powersupply_on = true; - #endif - if (powersupply_on) { + if (TERN1(PSU_CONTROL, powerManager.psu_on)) { editable.state = leds.lights_on; EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle); } diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 921c2435b5..8fce2038a3 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -35,6 +35,10 @@ #include "../../module/stepper.h" #include "../../sd/cardreader.h" +#if ENABLED(PSU_CONTROL) + #include "../../feature/power.h" +#endif + #if HAS_GAMES && DISABLED(LCD_INFO_MENU) #include "game/game.h" #endif @@ -77,7 +81,6 @@ void menu_configuration(); #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) - void _menu_temp_filament_op(const PauseMode, const int8_t); void menu_change_filament(); #endif @@ -365,10 +368,10 @@ void menu_main() { #if ENABLED(ADVANCED_PAUSE_FEATURE) #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) - if (thermalManager.targetHotEnoughToExtrude(active_extruder)) - GCODES_ITEM(MSG_FILAMENTCHANGE, PSTR("M600 B0")); - else - SUBMENU(MSG_FILAMENTCHANGE, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); }); + YESNO_ITEM(MSG_FILAMENTCHANGE, + menu_change_filament, ui.goto_previous_screen, + GET_TEXT(MSG_FILAMENTCHANGE), (const char *)nullptr, PSTR("?") + ); #else SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament); #endif @@ -386,8 +389,16 @@ void menu_main() { // Switch power on/off // #if ENABLED(PSU_CONTROL) - if (powersupply_on) - GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81")); + if (powerManager.psu_on) + #if ENABLED(PS_OFF_CONFIRM) + CONFIRM_ITEM(MSG_SWITCH_PS_OFF, + MSG_YES, MSG_NO, + ui.poweroff, ui.goto_previous_screen, + GET_TEXT(MSG_SWITCH_PS_OFF), (const char *)nullptr, PSTR("?") + ); + #else + GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81")); + #endif else GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80")); #endif diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index 7a525d06b5..8630f48b37 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -104,7 +104,7 @@ class MenuItem_sdfolder : public MenuItem_sdbase { } }; -void menu_media() { +void menu_media_filelist() { ui.encoder_direction_menus(); #if HAS_MARLINUI_U8GLIB @@ -115,7 +115,11 @@ void menu_media() { #endif START_MENU(); - BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK)); + #if ENABLED(MULTI_VOLUME) + ACTION_ITEM(MSG_BACK, []{ ui.goto_screen(menu_media); }); + #else + BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK)); + #endif if (card.flag.workDirIsRoot) { #if !PIN_EXISTS(SD_DETECT) ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); }); @@ -138,4 +142,22 @@ void menu_media() { END_MENU(); } +#if ENABLED(MULTI_VOLUME) + void menu_media_select() { + START_MENU(); + BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK)); + #if ENABLED(VOLUME_SD_ONBOARD) + ACTION_ITEM(MSG_SD_CARD, []{ card.changeMedia(&card.media_driver_sdcard); card.mount(); ui.goto_screen(menu_media_filelist); }); + #endif + #if ENABLED(VOLUME_USB_FLASH_DRIVE) + ACTION_ITEM(MSG_USB_DISK, []{ card.changeMedia(&card.media_driver_usbFlash); card.mount(); ui.goto_screen(menu_media_filelist); }); + #endif + END_MENU(); + } +#endif + +void menu_media() { + TERN(MULTI_VOLUME, menu_media_select, menu_media_filelist)(); +} + #endif // HAS_LCD_MENU && SDSUPPORT diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 076ece33b0..45e751e29a 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -28,6 +28,8 @@ #if HAS_LCD_MENU +#define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || (Y_BED_SIZE) >= 1000 || (Z_MAX_POS) >= 1000) + #include "menu_item.h" #include "menu_addon.h" @@ -85,7 +87,7 @@ static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) { MenuEditItemBase::draw_edit_screen(name, ftostr63(imp_pos)); } else - MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr63(pos)); + MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? (LARGE_AREA_TEST ? ftostr51sign(pos) : ftostr41sign(pos)) : ftostr63(pos)); } } void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); } @@ -165,11 +167,13 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int BACK_ITEM(MSG_MOVE_AXIS); if (parser.using_inch_units()) { + if (LARGE_AREA_TEST) SUBMENU(MSG_MOVE_1IN, []{ _goto_manual_move(IN_TO_MM(1.000f)); }); SUBMENU(MSG_MOVE_01IN, []{ _goto_manual_move(IN_TO_MM(0.100f)); }); SUBMENU(MSG_MOVE_001IN, []{ _goto_manual_move(IN_TO_MM(0.010f)); }); SUBMENU(MSG_MOVE_0001IN, []{ _goto_manual_move(IN_TO_MM(0.001f)); }); } else { + if (LARGE_AREA_TEST) SUBMENU(MSG_MOVE_100MM, []{ _goto_manual_move(100); }); SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10); }); SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move( 1); }); SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); }); @@ -180,7 +184,6 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int PGM_P const label = GET_TEXT(MSG_MOVE_N_MM); char tmp[strlen_P(label) + 10 + 1], numstr[10]; sprintf_P(tmp, label, dtostrf(FINE_MANUAL_MOVE, 1, digs, numstr)); - #if DISABLED(HAS_GRAPHICAL_TFT) SUBMENU_P(NUL_STR, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); }); MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780)); @@ -416,7 +419,7 @@ void menu_motion() { #endif #if ENABLED(LEVEL_BED_CORNERS) && DISABLED(LCD_BED_LEVELING) - SUBMENU(MSG_LEVEL_CORNERS, _lcd_level_bed_corners); + SUBMENU(MSG_BED_TRAMMING, _lcd_level_bed_corners); #endif #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index 590ce48d59..d3a35abff2 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -177,7 +177,7 @@ void Password::menu_password() { START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); SUBMENU(MSG_CHANGE_PASSWORD, screen_set_password); - ACTION_ITEM(MSG_REMOVE_PASSWORD, []{ ui.save_previous_screen(); remove_password(); } ); + ACTION_ITEM(MSG_REMOVE_PASSWORD, []{ ui.push_current_screen(); remove_password(); } ); #if ENABLED(EEPROM_SETTINGS) ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings); #endif diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index 008db6a8b8..5ed217131a 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -42,7 +42,7 @@ // Global storage float z_offset_backup, calculated_z_offset, z_offset_ref; -#if ENABLED(HAS_LEVELING) +#if HAS_LEVELING bool leveling_was_active; #endif diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 33a3d2f445..65cef5b76d 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -57,8 +57,14 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp); #endif #if HAS_FAN - if (indh >= 0) - set_fan_speed(active_extruder < (FAN_COUNT) ? active_extruder : 0, ui.material_preset[indh].fan_speed); + if (indh >= 0) { + const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0; + if (true + #if REDUNDANT_PART_COOLING_FAN + && fan_index != REDUNDANT_PART_COOLING_FAN + #endif + ) set_fan_speed(fan_index, ui.material_preset[indh].fan_speed); + } #endif ui.return_to_status(); } @@ -163,10 +169,13 @@ void menu_temperature() { // Nozzle [1-5]: // #if HOTENDS == 1 - EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); }); + editable.celsius = thermalManager.temp_hotend[0].target; + EDIT_ITEM_FAST(int3, MSG_NOZZLE, &editable.celsius, 0, thermalManager.hotend_max_target(0), []{ thermalManager.setTargetHotend(editable.celsius, 0); }); #elif HAS_MULTI_HOTEND - HOTEND_LOOP() - EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.hotend_max_target(e), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); + HOTEND_LOOP() { + editable.celsius = thermalManager.temp_hotend[e].target; + EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &editable.celsius, 0, thermalManager.hotend_max_target(e), []{ thermalManager.setTargetHotend(editable.celsius, MenuItemBase::itemIndex); }); + } #endif #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) @@ -215,37 +224,37 @@ void menu_temperature() { #if HAS_FAN0 _FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED); #endif - #if HAS_FAN1 + #if HAS_FAN1 && REDUNDANT_PART_COOLING_FAN != 1 FAN_EDIT_ITEMS(1); #elif SNFAN(1) singlenozzle_item(1); #endif - #if HAS_FAN2 + #if HAS_FAN2 && REDUNDANT_PART_COOLING_FAN != 2 FAN_EDIT_ITEMS(2); #elif SNFAN(2) singlenozzle_item(2); #endif - #if HAS_FAN3 + #if HAS_FAN3 && REDUNDANT_PART_COOLING_FAN != 3 FAN_EDIT_ITEMS(3); #elif SNFAN(3) singlenozzle_item(3); #endif - #if HAS_FAN4 + #if HAS_FAN4 && REDUNDANT_PART_COOLING_FAN != 4 FAN_EDIT_ITEMS(4); #elif SNFAN(4) singlenozzle_item(4); #endif - #if HAS_FAN5 + #if HAS_FAN5 && REDUNDANT_PART_COOLING_FAN != 5 FAN_EDIT_ITEMS(5); #elif SNFAN(5) singlenozzle_item(5); #endif - #if HAS_FAN6 + #if HAS_FAN6 && REDUNDANT_PART_COOLING_FAN != 6 FAN_EDIT_ITEMS(6); #elif SNFAN(6) singlenozzle_item(6); #endif - #if HAS_FAN7 + #if HAS_FAN7 && REDUNDANT_PART_COOLING_FAN != 7 FAN_EDIT_ITEMS(7); #elif SNFAN(7) singlenozzle_item(7); diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index da7afd86ef..b5868f4056 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -61,7 +61,7 @@ static void _menu_single_probe(const uint8_t point) { tram_index = point; DEBUG_ECHOLNPAIR("Screen: single probe screen Arg:", point); START_MENU(); - STATIC_ITEM(MSG_LEVEL_CORNERS, SS_LEFT); + STATIC_ITEM(MSG_BED_TRAMMING, SS_LEFT); STATIC_ITEM(MSG_LAST_VALUE_SP, SS_LEFT, ftostr42_52(z_measured[0] - z_measured[point])); // Print diff ACTION_ITEM(MSG_UBL_BC_INSERT2, []{ if (probe_single_point()) ui.refresh(); }); ACTION_ITEM(MSG_BUTTON_DONE, []{ ui.goto_previous_screen(); }); // Back @@ -92,7 +92,7 @@ void goto_tramming_wizard() { // Inject G28, wait for homing to complete, set_all_unhomed(); - queue.inject_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR)); + queue.inject_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR)); ui.goto_screen([]{ _lcd_draw_homing(); diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 880b76ff76..467bd81acf 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -176,7 +176,7 @@ void _menu_ubl_height_adjust() { void _lcd_ubl_edit_mesh() { START_MENU(); BACK_ITEM(MSG_UBL_TOOLS); - GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29P4R999T")); + GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29P4RT")); GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29P4T")); SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); @@ -594,9 +594,9 @@ void _menu_ubl_tools() { GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G29NP1")); GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29P3T0")); SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); - GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29P4R999T")); + GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29P4RT")); SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); - GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29P4R999T")); + GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29P4RT")); ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd); END_MENU(); } diff --git a/Marlin/src/lcd/tft/tft_queue.h b/Marlin/src/lcd/tft/tft_queue.h index 7eaa0c01c1..51387254c5 100644 --- a/Marlin/src/lcd/tft/tft_queue.h +++ b/Marlin/src/lcd/tft/tft_queue.h @@ -134,7 +134,7 @@ class TFT_Queue { public: static void reset(); static void async(); - static void sync() { while (current_task != NULL) async(); } + static void sync() { while (current_task != nullptr) async(); } static void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color); static void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height); diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 3d4e0a40e1..64dfaa5755 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -93,9 +93,7 @@ void Touch::idle() { } #endif - #if LCD_TIMEOUT_TO_STATUS - ui.return_to_status_ms = last_touch_ms + LCD_TIMEOUT_TO_STATUS; - #endif + ui.reset_status_timeout(last_touch_ms); if (touch_time) { #if ENABLED(TOUCH_SCREEN_CALIBRATION) diff --git a/Marlin/src/lcd/tft/touch.h b/Marlin/src/lcd/tft/touch.h index 8d6001b8d8..54dfb420d8 100644 --- a/Marlin/src/lcd/tft/touch.h +++ b/Marlin/src/lcd/tft/touch.h @@ -109,7 +109,7 @@ class Touch { public: static void init(); - static void reset() { controls_count = 0; touch_time = 0; current_control = NULL; } + static void reset() { controls_count = 0; touch_time = 0; current_control = nullptr; } static void clear() { controls_count = 0; } static void idle(); static bool is_clicked() { diff --git a/Marlin/src/lcd/tft_io/tft_ids.h b/Marlin/src/lcd/tft_io/tft_ids.h new file mode 100644 index 0000000000..c4f6127c68 --- /dev/null +++ b/Marlin/src/lcd/tft_io/tft_ids.h @@ -0,0 +1,35 @@ +/** + * 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 + +#define LTDC_RGB 0xABAB +#define SSD1963 0x5761 +#define ST7735 0x89F0 +#define ST7789 0x8552 +#define ST7796 0x7796 +#define R61505 0x1505 +#define ILI9328 0x9328 +#define ILI9341 0x9341 +#define ILI9488 0x9488 +#define ILI9488_ID1 0x8066 // Some ILI9488 have 0x8066 in the 0x04 +#define LERDGE_ST7796 0xFFFE +#define AUTO 0xFFFF diff --git a/Marlin/src/lcd/tft_io/tft_io.cpp b/Marlin/src/lcd/tft_io/tft_io.cpp index fa81d95a4d..29c7da235c 100644 --- a/Marlin/src/lcd/tft_io/tft_io.cpp +++ b/Marlin/src/lcd/tft_io/tft_io.cpp @@ -20,18 +20,34 @@ * */ -#include "tft_io.h" +#include "../../inc/MarlinConfigPre.h" #if HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT -#include "st7735.h" -#include "st7789v.h" -#include "st7796s.h" -#include "r65105.h" -#include "ili9328.h" +#include "tft_io.h" +#include "tft_ids.h" + +#if TFT_DRIVER == ST7735 || TFT_DRIVER == AUTO + #include "st7735.h" +#endif +#if TFT_DRIVER == ST7789 || TFT_DRIVER == AUTO + #include "st7789v.h" +#endif +#if TFT_DRIVER == ST7796 || TFT_DRIVER == AUTO + #include "st7796s.h" +#endif +#if TFT_DRIVER == R61505 || TFT_DRIVER == AUTO + #include "r65105.h" +#endif +#if TFT_DRIVER == ILI9488 || TFT_DRIVER == ILI9488_ID1 || TFT_DRIVER == AUTO + #include "ili9488.h" +#endif +#if TFT_DRIVER == SSD1963 || TFT_DRIVER == AUTO + #include "ssd1963.h" +#endif + #include "ili9341.h" -#include "ili9488.h" -#include "ssd1963.h" +#include "ili9328.h" #define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT) #include "../../core/debug_out.h" @@ -236,4 +252,4 @@ void TFT_IO::write_esc_sequence(const uint16_t *Sequence) { io.DataTransferEnd(); } -#endif // HAS_SPI_TFT || HAS_FSMC_TFT +#endif // HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index 846b45e8e0..0e4322f0d7 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -23,8 +23,6 @@ #include "../../inc/MarlinConfig.h" -#if HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT - #if HAS_SPI_TFT #include HAL_PATH(../../HAL, tft/tft_spi.h) #elif HAS_FSMC_TFT @@ -35,9 +33,9 @@ #error "TFT IO only supports SPI, FSMC or LTDC interface" #endif -#define TFT_EXCHANGE_XY (1UL << 1) -#define TFT_INVERT_X (1UL << 2) -#define TFT_INVERT_Y (1UL << 3) +#define TFT_EXCHANGE_XY _BV32(1) +#define TFT_INVERT_X _BV32(2) +#define TFT_INVERT_Y _BV32(3) #define TFT_NO_ROTATION (0x00) #define TFT_ROTATE_90 (TFT_EXCHANGE_XY | TFT_INVERT_X) @@ -65,8 +63,8 @@ // TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION #define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION)) -#define TFT_COLOR_RGB (1UL << 3) -#define TFT_COLOR_BGR (1UL << 4) +#define TFT_COLOR_RGB _BV32(3) +#define TFT_COLOR_BGR _BV32(4) // Each TFT Driver is responsible for its default color mode. // #ifndef TFT_COLOR @@ -93,27 +91,14 @@ #define TOUCH_ORIENTATION TOUCH_LANDSCAPE #endif -#define LTDC_RGB 0xABAB -#define SSD1963 0x5761 -#define ST7735 0x89F0 -#define ST7789 0x8552 -#define ST7796 0x7796 -#define R61505 0x1505 -#define ILI9328 0x9328 -#define ILI9341 0x9341 -#define ILI9488 0x9488 -#define ILI9488_ID1 0x8066 //Some ILI9488 have 0x8066 in the 0x04 -#define LERDGE_ST7796 0xFFFE -#define AUTO 0xFFFF - #ifndef TFT_DRIVER #define TFT_DRIVER AUTO #endif -#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x -#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF) -#define ESC_END 0xFFFF, 0x7FFF -#define ESC_FFFF 0xFFFF, 0xFFFF +#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x +#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF) +#define ESC_END 0xFFFF, 0x7FFF +#define ESC_FFFF 0xFFFF, 0xFFFF class TFT_IO { public: @@ -143,5 +128,3 @@ public: protected: static uint32_t lcd_id; }; - -#endif // HAS_SPI_TFT || HAS_FSMC_TFT diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index f9f91ac49a..4f6dd23ece 100644 --- a/Marlin/src/lcd/thermistornames.h +++ b/Marlin/src/lcd/thermistornames.h @@ -128,6 +128,8 @@ #define THERMISTOR_NAME "Pt100 1K" #elif THERMISTOR_ID == 666 #define THERMISTOR_NAME "Einstart S" +#elif THERMISTOR_ID == 2000 + #define THERMISTOR_NAME "TDK NTCG104LH104JT1" // High Temperature thermistors #elif THERMISTOR_ID == 61 diff --git a/Marlin/src/libs/MAX31865.cpp b/Marlin/src/libs/MAX31865.cpp new file mode 100644 index 0000000000..590dea5ca5 --- /dev/null +++ b/Marlin/src/libs/MAX31865.cpp @@ -0,0 +1,500 @@ +/** + * 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 . + * + */ + +/** + * Based on Based on Adafruit MAX31865 library: + * + * This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865 + * Designed specifically to work with the Adafruit RTD Sensor + * https://www.adafruit.com/products/3328 + * + * This sensor uses SPI to communicate, 4 pins are required to interface. + * + * Adafruit invests time and resources providing this open source code, + * please support Adafruit and open-source hardware by purchasing + * products from Adafruit! + * + * Written by Limor Fried/Ladyada for Adafruit Industries. + * + * Modifications by JoAnn Manges (@GadgetAngel) + * Copyright (c) 2020, JoAnn Manges + * All rights reserved. + */ + +// Useful for RTD debugging. +//#define MAX31865_DEBUG +//#define MAX31865_DEBUG_SPI + +//TODO: switch to SPIclass/SoftSPI + +#include "../inc/MarlinConfig.h" + +#if HAS_MAX31865 && !LIB_USR_MAX31865 + +#include "MAX31865.h" + +// The maximum speed the MAX31865 can do is 5 MHz +SPISettings MAX31865::spiConfig = SPISettings( + #if defined(TARGET_LPC1768) + SPI_QUARTER_SPEED + #elif defined(ARDUINO_ARCH_STM32) + SPI_CLOCK_DIV4 + #else + 500000 + #endif + , MSBFIRST + , SPI_MODE_1 // CPOL0 CPHA1 +); + +#ifndef LARGE_PINMAP + + /** + * Create the interface object using software (bitbang) SPI for PIN values + * less than or equal to 127. + * + * @param spi_cs the SPI CS pin to use + * @param spi_mosi the SPI MOSI pin to use + * @param spi_miso the SPI MISO pin to use + * @param spi_clk the SPI clock pin to use + */ + MAX31865::MAX31865(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, int8_t spi_clk) { + _cs = spi_cs; + _mosi = spi_mosi; + _miso = spi_miso; + _sclk = spi_clk; + } + + /** + * Create the interface object using hardware SPI for PIN for PIN values less + * than or equal to 127. + * + * @param spi_cs the SPI CS pin to use along with the default SPI device + */ + MAX31865::MAX31865(int8_t spi_cs) { + _cs = spi_cs; + _sclk = _miso = _mosi = -1; + } + +#else + + /** + * Create the interface object using software (bitbang) SPI for PIN values + * which are larger than 127. If you have PIN values less than or equal to + * 127 use the other call for SW SPI. + * + * @param spi_cs the SPI CS pin to use + * @param spi_mosi the SPI MOSI pin to use + * @param spi_miso the SPI MISO pin to use + * @param spi_clk the SPI clock pin to use + * @param pin_mapping set to 1 for positive pin values + */ + MAX31865::MAX31865(uint32_t spi_cs, uint32_t spi_mosi, + uint32_t spi_miso, uint32_t spi_clk, + uint8_t pin_mapping) { + _cs = spi_cs; + _mosi = spi_mosi; + _miso = spi_miso; + _sclk = spi_clk; + } + + /** + * Create the interface object using hardware SPI for PIN values which are + * larger than 127. If you have PIN values less than or equal to 127 use + * the other call for HW SPI. + * + * @param spi_cs the SPI CS pin to use along with the default SPI device + * @param pin_mapping set to 1 for positive pin values + */ + MAX31865::MAX31865(uint32_t spi_cs, uint8_t pin_mapping) { + _cs = spi_cs; + _sclk = _miso = _mosi = -1UL; //-1UL or 0xFFFFFFFF or 4294967295 + } + +#endif // LARGE_PINMAP + + +/** + * + * Instance & Class methods + * + */ + + +/** + * Initialize the SPI interface and set the number of RTD wires used + * + * @param wires The number of wires in enum format. Can be MAX31865_2WIRE, MAX31865_3WIRE, or MAX31865_4WIRE. + * @param zero The resistance of the RTD at 0 degC, in ohms. + * @param ref The resistance of the reference resistor, in ohms. + */ +void MAX31865::begin(max31865_numwires_t wires, float zero, float ref) { + Rzero = zero; + Rref = ref; + + OUT_WRITE(_cs, HIGH); + + if (_sclk != TERN(LARGE_PINMAP, -1UL, -1)) { + // define pin modes for Software SPI + #ifdef MAX31865_DEBUG + SERIAL_ECHOLN("Initializing MAX31865 Software SPI"); + #endif + + OUT_WRITE(_sclk, LOW); + SET_OUTPUT(_mosi); + SET_INPUT(_miso); + } else { + // start and configure hardware SPI + #ifdef MAX31865_DEBUG + SERIAL_ECHOLN("Initializing MAX31865 Hardware SPI"); + #endif + + SPI.begin(); + } + + setWires(wires); + enableBias(false); + autoConvert(false); + clearFault(); + + #ifdef MAX31865_DEBUG_SPI + #ifndef LARGE_PINMAP + SERIAL_ECHOLNPAIR( + "Regular begin call with _cs: ", _cs, + " _miso: ", _miso, + " _sclk: ", _sclk, + " _mosi: ", _mosi + ); + #else + SERIAL_ECHOLNPAIR( + "LARGE_PINMAP begin call with _cs: ", _cs, + " _miso: ", _miso, + " _sclk: ", _sclk, + " _mosi: ", _mosi + ); + #endif // LARGE_PINMAP + + SERIAL_ECHOLNPAIR("config: ", readRegister8(MAX31856_CONFIG_REG)); + SERIAL_EOL(); + #endif // MAX31865_DEBUG_SPI +} + +/** + * Read the raw 8-bit FAULTSTAT register + * + * @return The raw unsigned 8-bit FAULT status register + */ +uint8_t MAX31865::readFault() { + return readRegister8(MAX31856_FAULTSTAT_REG); +} + +/** + * Clear all faults in FAULTSTAT. + */ +void MAX31865::clearFault() { + setConfig(MAX31856_CONFIG_FAULTSTAT, 1); +} + +/** + * Whether we want to have continuous conversions (50/60 Hz) + * + * @param b If true, auto conversion is enabled + */ +void MAX31865::autoConvert(bool b) { + setConfig(MAX31856_CONFIG_MODEAUTO, b); +} + +/** + * Whether we want filter out 50Hz noise or 60Hz noise + * + * @param b If true, 50Hz noise is filtered, else 60Hz(default) + */ +void MAX31865::enable50HzFilter(bool b) { + setConfig(MAX31856_CONFIG_FILT50HZ, b); +} + +/** + * Enable the bias voltage on the RTD sensor + * + * @param b If true bias is enabled, else disabled + */ +void MAX31865::enableBias(bool b) { + setConfig(MAX31856_CONFIG_BIAS, b); + + // From the datasheet: + // Note that if VBIAS is off (to reduce supply current between conversions), any filter + // capacitors at the RTDIN inputs need to charge before an accurate conversion can be + // performed. Therefore, enable VBIAS and wait at least 10.5 time constants of the input + // RC network plus an additional 1ms before initiating the conversion. + if (b) + DELAY_US(11500); //11.5ms +} + +/** + * Start a one-shot temperature reading. + */ +void MAX31865::oneShot() { + setConfig(MAX31856_CONFIG_1SHOT, 1); + + // From the datasheet: + // Note that a single conversion requires approximately 52ms in 60Hz filter + // mode or 62.5ms in 50Hz filter mode to complete. 1-Shot is a self-clearing bit. + // TODO: switch this out depeding on the filter mode. + DELAY_US(65000); // 65ms +} + +/** + * How many wires we have in our RTD setup, can be MAX31865_2WIRE, + * MAX31865_3WIRE, or MAX31865_4WIRE + * + * @param wires The number of wires in enum format + */ +void MAX31865::setWires(max31865_numwires_t wires) { + uint8_t t = readRegister8(MAX31856_CONFIG_REG); + if (wires == MAX31865_3WIRE) + t |= MAX31856_CONFIG_3WIRE; + else // 2 or 4 wire + t &= ~MAX31856_CONFIG_3WIRE; + writeRegister8(MAX31856_CONFIG_REG, t); +} + +/** + * Read the raw 16-bit value from the RTD_REG in one shot mode. This will include + * the fault bit, D0. + * + * @return The raw unsigned 16-bit register value with ERROR bit attached, NOT temperature! + */ +uint16_t MAX31865::readRaw() { + clearFault(); + enableBias(true); + + oneShot(); + uint16_t rtd = readRegister16(MAX31856_RTDMSB_REG); + + #ifdef MAX31865_DEBUG + SERIAL_ECHOLNPAIR("RTD MSB:", (rtd >> 8), " RTD LSB:", (rtd & 0x00FF)); + #endif + + // Disable the bias to lower power dissipation between reads. + // If the ref resistor heats up, the temperature reading will be skewed. + enableBias(false); + + return rtd; +} + +/** + * Calulate and return the resistance value of the connected RTD. + * + * @param refResistor The value of the matching reference resistor, usually 430 or 4300 + * @return The raw RTD resistance value, NOT temperature! + */ +float MAX31865::readResistance() { + // Strip the error bit (D0) and convert to a float ratio. + // less precise method: (readRaw() * Rref) >> 16 + return (((readRaw() >> 1) / 32768.0f) * Rref); +} + +/** + * Read the RTD and pass it to temperature(float) for calculation. + * + * @return Temperature in C + */ +float MAX31865::temperature() { + return temperature(readResistance()); +} + +/** + * Given the 15-bit ADC value, calculate the resistance and pass it to temperature(float) for calculation. + * + * @return Temperature in C + */ +float MAX31865::temperature(uint16_t adcVal) { + return temperature(((adcVal) / 32768.0f) * Rref); +} + +/** + * Calculate the temperature in C from the RTD resistance. + * Uses the technique outlined in this PDF: + * http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf + * + * @param Rrtd the resistance value in ohms + * @return the temperature in degC + */ +float MAX31865::temperature(float Rrtd) { + float temp = (RTD_Z1 + sqrt(RTD_Z2 + (RTD_Z3 * Rrtd))) / RTD_Z4; + + // From the PDF... + // + // The previous equation is valid only for temperatures of 0°C and above. + // The equation for RRTD(t) that defines negative temperature behavior is a + // fourth-order polynomial (after expanding the third term) and is quite + // impractical to solve for a single expression of temperature as a function + // of resistance. + // + if (temp < 0) { + Rrtd = (Rrtd / Rzero) * 100; // normalize to 100 ohm + float rpoly = Rrtd; + + temp = -242.02 + (2.2228 * rpoly); + rpoly *= Rrtd; // square + temp += 2.5859e-3 * rpoly; + rpoly *= Rrtd; // ^3 + temp -= 4.8260e-6 * rpoly; + rpoly *= Rrtd; // ^4 + temp -= 2.8183e-8 * rpoly; + rpoly *= Rrtd; // ^5 + temp += 1.5243e-10 * rpoly; + } + + return temp; +} + +// +// private: +// + + +/** + * Set a value in the configuration register. + * + * @param config 8-bit value for the config item + * @param enable whether to enable or disable the value + */ +void MAX31865::setConfig(uint8_t config, bool enable) { + uint8_t t = readRegister8(MAX31856_CONFIG_REG); + if (enable) + t |= config; + else + t &= ~config; // disable + writeRegister8(MAX31856_CONFIG_REG, t); +} + +/** + * Read a single byte from the specified register address. + * + * @param addr the register address + * @return the register contents + */ +uint8_t MAX31865::readRegister8(uint8_t addr) { + uint8_t ret = 0; + readRegisterN(addr, &ret, 1); + + return ret; +} + +/** + * Read two bytes: 1 from the specified register address, and 1 from the next address. + * + * @param addr the first register address + * @return both register contents as a single 16-bit int + */ +uint16_t MAX31865::readRegister16(uint8_t addr) { + uint8_t buffer[2] = {0, 0}; + readRegisterN(addr, buffer, 2); + + uint16_t ret = buffer[0]; + ret <<= 8; + ret |= buffer[1]; + + return ret; +} + +/** + * Read +n+ bytes from a specified address into +buffer+. Set D7 to 0 to specify a read. + * + * @param addr the first register address + * @param buffer storage for the read bytes + * @param n the number of bytes to read + */ +void MAX31865::readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n) { + addr &= 0x7F; // make sure top bit is not set + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + SPI.beginTransaction(spiConfig); + else + WRITE(_sclk, LOW); + + WRITE(_cs, LOW); + spixfer(addr); + + while (n--) { + buffer[0] = spixfer(0xFF); + #ifdef MAX31865_DEBUG_SPI + SERIAL_ECHOLNPAIR("buffer read ", n, " data: ", buffer[0]); + #endif + buffer++; + } + + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + SPI.endTransaction(); + + WRITE(_cs, HIGH); +} + +/** + * Write an 8-bit value to a register. Set D7 to 1 to specify a write. + * + * @param addr the address to write to + * @param data the data to write + */ +void MAX31865::writeRegister8(uint8_t addr, uint8_t data) { + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + SPI.beginTransaction(spiConfig); + else + WRITE(_sclk, LOW); + + WRITE(_cs, LOW); + + spixfer(addr | 0x80); // make sure top bit is set + spixfer(data); + + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + SPI.endTransaction(); + + WRITE(_cs, HIGH); +} + +/** + * Transfer SPI data +x+ and read the response. From the datasheet... + * Input data (SDI) is latched on the internal strobe edge and output data (SDO) is + * shifted out on the shift edge. There is one clock for each bit transferred. + * Address and data bits are transferred in groups of eight, MSB first. + * + * @param x an 8-bit chunk of data to write + * @return the 8-bit response + */ +uint8_t MAX31865::spixfer(uint8_t x) { + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + return SPI.transfer(x); + + uint8_t reply = 0; + for (int i = 7; i >= 0; i--) { + reply <<= 1; + WRITE(_sclk, HIGH); + WRITE(_mosi, x & (1 << i)); + WRITE(_sclk, LOW); + if (READ(_miso)) + reply |= 1; + } + + return reply; +} + +#endif // HAS_MAX31865 && !LIB_USR_MAX31865 diff --git a/Marlin/src/libs/MAX31865.h b/Marlin/src/libs/MAX31865.h new file mode 100644 index 0000000000..2ab78ecbe8 --- /dev/null +++ b/Marlin/src/libs/MAX31865.h @@ -0,0 +1,131 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Based on Adafruit MAX31865 library: + * + * This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865 + * Designed specifically to work with the Adafruit RTD Sensor + * https://www.adafruit.com/products/3328 + * + * This sensor uses SPI to communicate, 4 pins are required to interface. + * + * Adafruit invests time and resources providing this open source code, + * please support Adafruit and open-source hardware by purchasing + * products from Adafruit! + * + * Written by Limor Fried/Ladyada for Adafruit Industries. + * + * Modifications by JoAnn Manges (@GadgetAngel) + * Copyright (c) 2020, JoAnn Manges + * All rights reserved. + */ +#pragma once + +#include "../inc/MarlinConfig.h" +#include "../HAL/shared/Delay.h" +#include HAL_PATH(../HAL, MarlinSPI.h) + +#define MAX31856_CONFIG_REG 0x00 +#define MAX31856_CONFIG_BIAS 0x80 +#define MAX31856_CONFIG_MODEAUTO 0x40 +#define MAX31856_CONFIG_MODEOFF 0x00 +#define MAX31856_CONFIG_1SHOT 0x20 +#define MAX31856_CONFIG_3WIRE 0x10 +#define MAX31856_CONFIG_24WIRE 0x00 +#define MAX31856_CONFIG_FAULTSTAT 0x02 +#define MAX31856_CONFIG_FILT50HZ 0x01 +#define MAX31856_CONFIG_FILT60HZ 0x00 + +#define MAX31856_RTDMSB_REG 0x01 +#define MAX31856_RTDLSB_REG 0x02 +#define MAX31856_HFAULTMSB_REG 0x03 +#define MAX31856_HFAULTLSB_REG 0x04 +#define MAX31856_LFAULTMSB_REG 0x05 +#define MAX31856_LFAULTLSB_REG 0x06 +#define MAX31856_FAULTSTAT_REG 0x07 + +#define MAX31865_FAULT_HIGHTHRESH 0x80 // D7 +#define MAX31865_FAULT_LOWTHRESH 0x40 // D6 +#define MAX31865_FAULT_REFINLOW 0x20 // D5 +#define MAX31865_FAULT_REFINHIGH 0x10 // D4 +#define MAX31865_FAULT_RTDINLOW 0x08 // D3 +#define MAX31865_FAULT_OVUV 0x04 // D2 + +// http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf +// constants for calulating temperature from the measured RTD resistance. +#define RTD_Z1 -0.0039083 +#define RTD_Z2 0.00001758480889 +#define RTD_Z3 -0.0000000231 +#define RTD_Z4 -0.000001155 + +typedef enum max31865_numwires { + MAX31865_2WIRE = 0, + MAX31865_3WIRE = 1, + MAX31865_4WIRE = 0 +} max31865_numwires_t; + +/* Interface class for the MAX31865 RTD Sensor reader */ +class MAX31865 { +private: + static SPISettings spiConfig; + + TERN(LARGE_PINMAP, uint32_t, uint8_t) _sclk, _miso, _mosi, _cs; + float Rzero, Rref; + + void setConfig(uint8_t config, bool enable); + + void readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n); + uint8_t readRegister8(uint8_t addr); + uint16_t readRegister16(uint8_t addr); + + void writeRegister8(uint8_t addr, uint8_t reg); + uint8_t spixfer(uint8_t addr); + +public: + #ifdef LARGE_PINMAP + MAX31865(uint32_t spi_cs, uint8_t pin_mapping); + MAX31865(uint32_t spi_cs, uint32_t spi_mosi, uint32_t spi_miso, + uint32_t spi_clk, uint8_t pin_mapping); + #else + MAX31865(int8_t spi_cs); + MAX31865(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, + int8_t spi_clk); + #endif + + void begin(max31865_numwires_t wires, float zero, float ref); + + uint8_t readFault(); + void clearFault(); + + void setWires(max31865_numwires_t wires); + void autoConvert(bool b); + void enable50HzFilter(bool b); + void enableBias(bool b); + void oneShot(); + + uint16_t readRaw(); + float readResistance(); + float temperature(); + float temperature(uint16_t adcVal); + float temperature(float Rrtd); +}; diff --git a/Marlin/src/libs/hex_print.cpp b/Marlin/src/libs/hex_print.cpp index 0f746d6284..1958084abb 100644 --- a/Marlin/src/libs/hex_print.cpp +++ b/Marlin/src/libs/hex_print.cpp @@ -80,7 +80,7 @@ void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); } void print_hex_long(const uint32_t w, const char delimiter) { SERIAL_ECHOPGM("0x"); - for (int B = 24; B >= 8; B -= 8){ + for (int B = 24; B >= 8; B -= 8) { print_hex_byte(w >> B); SERIAL_CHAR(delimiter); } diff --git a/Marlin/src/libs/vector_3.cpp b/Marlin/src/libs/vector_3.cpp index b8202217dd..4db8fb5f2e 100644 --- a/Marlin/src/libs/vector_3.cpp +++ b/Marlin/src/libs/vector_3.cpp @@ -104,9 +104,9 @@ matrix_3x3 matrix_3x3::create_from_rows(const vector_3 &row_0, const vector_3 &r //row_1.debug(PSTR("row_1")); //row_2.debug(PSTR("row_2")); matrix_3x3 new_matrix; - new_matrix.vectors[0].x = row_0.x; new_matrix.vectors[1].y = row_0.y; new_matrix.vectors[2].z = row_0.z; - new_matrix.vectors[3].x = row_1.x; new_matrix.vectors[4].y = row_1.y; new_matrix.vectors[5].z = row_1.z; - new_matrix.vectors[6].x = row_2.x; new_matrix.vectors[7].y = row_2.y; new_matrix.vectors[8].z = row_2.z; + new_matrix.vectors[0] = row_0; + new_matrix.vectors[1] = row_1; + new_matrix.vectors[2] = row_2; //new_matrix.debug(PSTR("new_matrix")); return new_matrix; } diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 96d8841f13..992c3a09b4 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -254,6 +254,7 @@ void home_delta() { current_position.z = DIFF_TERN(HAS_BED_PROBE, delta_height + 10, probe.offset.z); line_to_current_position(homing_feedrate(Z_AXIS)); planner.synchronize(); + TERN_(SENSORLESS_PROBING,endstops.report_states()); // Re-enable stealthChop if used. Disable diag1 pin on driver. #if ENABLED(SENSORLESS_HOMING) && DISABLED(ENDSTOPS_ALWAYS_ON_DEFAULT) diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index c750d56713..25c26aa7b5 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -329,7 +329,7 @@ void Endstops::init() { #endif #endif - #if HAS_CUSTOM_PROBE_PIN + #if USES_Z_MIN_PROBE_PIN #if ENABLED(ENDSTOPPULLUP_ZMIN_PROBE) SET_INPUT_PULLUP(Z_MIN_PROBE_PIN); #elif ENABLED(ENDSTOPPULLDOWN_ZMIN_PROBE) @@ -453,7 +453,7 @@ void Endstops::event_handler() { _ENDSTOP_HIT_TEST(K,'K') ); - #if HAS_CUSTOM_PROBE_PIN + #if USES_Z_MIN_PROBE_PIN #define P_AXIS Z_AXIS if (TEST(hit_state, Z_MIN_PROBE)) _ENDSTOP_HIT_ECHO(P, 'P'); #endif @@ -566,7 +566,7 @@ void _O2 Endstops::report_states() { #if BOTH(MARLIN_DEV_MODE, PROBE_ACTIVATION_SWITCH) print_es_state(probe_switch_activated(), PSTR(STR_PROBE_EN)); #endif - #if HAS_CUSTOM_PROBE_PIN + #if USES_Z_MIN_PROBE_PIN print_es_state(PROBE_TRIGGERED(), PSTR(STR_Z_PROBE)); #endif #if MULTI_FILAMENT_SENSOR @@ -595,9 +595,16 @@ void _O2 Endstops::report_states() { // The following routines are called from an ISR context. It could be the temperature ISR, the // endstop ISR or the Stepper ISR. -#define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX -#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN -#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING +#if BOTH(DELTA, SENSORLESS_PROBING) + #define __ENDSTOP(AXIS, ...) AXIS ##_MAX + #define _ENDSTOP_PIN(AXIS, ...) AXIS ##_MAX_PIN + #define _ENDSTOP_INVERTING(AXIS, ...) AXIS ##_MAX_ENDSTOP_INVERTING +#else + #define __ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX + #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN + #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING +#endif +#define _ENDSTOP(AXIS, MINMAX) __ENDSTOP(AXIS, MINMAX) // Check endstops - Could be called from Temperature ISR! void Endstops::update() { @@ -609,9 +616,10 @@ void Endstops::update() { #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) #define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT)) - #if BOTH(G38_PROBE_TARGET, HAS_Z_MIN_PROBE_PIN) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) - // If G38 command is active check Z_MIN_PROBE for ALL movement - if (G38_move) UPDATE_ENDSTOP_BIT(Z, MIN_PROBE); + #if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) + #define HAS_G38_PROBE 1 + // For G38 moves check the probe's pin for ALL movement + if (G38_move) UPDATE_ENDSTOP_BIT(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN)); #endif // With Dual X, endstops are only checked in the homing direction for the active extruder @@ -714,7 +722,7 @@ void Endstops::update() { #if HAS_BED_PROBE // When closing the gap check the enabled probe if (probe_switch_activated()) - UPDATE_ENDSTOP_BIT(Z, TERN(HAS_CUSTOM_PROBE_PIN, MIN_PROBE, MIN)); + UPDATE_ENDSTOP_BIT(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN)); #endif #if HAS_Z_MAX && !Z_SPI_SENSORLESS @@ -740,7 +748,7 @@ void Endstops::update() { COPY_LIVE_STATE(Z_MAX, Z4_MAX); #endif #endif - #elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN + #elif TERN1(USES_Z_MIN_PROBE_PIN, Z_MAX_PIN != Z_MIN_PROBE_PIN) // If this pin isn't the bed probe it's the Z endstop UPDATE_ENDSTOP_BIT(Z, MAX); #endif @@ -924,17 +932,17 @@ void Endstops::update() { #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX) #endif - #if BOTH(G38_PROBE_TARGET, HAS_Z_MIN_PROBE_PIN) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) - #if ENABLED(G38_PROBE_AWAY) - #define _G38_OPEN_STATE (G38_move >= 4) - #else - #define _G38_OPEN_STATE LOW - #endif - // If G38 command is active check Z_MIN_PROBE for ALL movement - if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE)) != _G38_OPEN_STATE) { - if (stepper.axis_is_moving(X_AXIS)) { _ENDSTOP_HIT(X, MIN); planner.endstop_triggered(X_AXIS); } - else if (stepper.axis_is_moving(Y_AXIS)) { _ENDSTOP_HIT(Y, MIN); planner.endstop_triggered(Y_AXIS); } - else if (stepper.axis_is_moving(Z_AXIS)) { _ENDSTOP_HIT(Z, MIN); planner.endstop_triggered(Z_AXIS); } + #if HAS_G38_PROBE + #define _G38_OPEN_STATE TERN(G38_PROBE_AWAY, (G38_move >= 4), LOW) + // For G38 moves check the probe's pin for ALL movement + if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN))) != _G38_OPEN_STATE) { + if (stepper.axis_is_moving(X_AXIS)) { _ENDSTOP_HIT(X, TERN(X_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(X_AXIS); } + #if HAS_Y_AXIS + else if (stepper.axis_is_moving(Y_AXIS)) { _ENDSTOP_HIT(Y, TERN(Y_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(Y_AXIS); } + #endif + #if HAS_Z_AXIS + else if (stepper.axis_is_moving(Z_AXIS)) { _ENDSTOP_HIT(Z, TERN(Z_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(Z_AXIS); } + #endif G38_did_trigger = true; } #endif @@ -1011,7 +1019,7 @@ void Endstops::update() { #if HAS_Z_MIN || (Z_SPI_SENSORLESS && Z_HOME_TO_MIN) if ( TERN1(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, z_probe_enabled) - && TERN1(HAS_CUSTOM_PROBE_PIN, !z_probe_enabled) + && TERN1(USES_Z_MIN_PROBE_PIN, !z_probe_enabled) ) PROCESS_ENDSTOP_Z(MIN); #if CORE_DIAG(XZ, X, MIN) PROCESS_CORE_ENDSTOP(X,MIN,Z,MIN); @@ -1025,7 +1033,7 @@ void Endstops::update() { #endif // When closing the gap check the enabled probe - #if HAS_CUSTOM_PROBE_PIN + #if USES_Z_MIN_PROBE_PIN if (z_probe_enabled) PROCESS_ENDSTOP(Z, MIN_PROBE); #endif } @@ -1033,7 +1041,7 @@ void Endstops::update() { #if HAS_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_TO_MAX) #if ENABLED(Z_MULTI_ENDSTOPS) PROCESS_ENDSTOP_Z(MAX); - #elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN // No probe or probe is Z_MIN || Probe is not Z_MAX + #elif TERN1(USES_Z_MIN_PROBE_PIN, Z_MAX_PIN != Z_MIN_PROBE_PIN) // No probe or probe is Z_MIN || Probe is not Z_MAX PROCESS_ENDSTOP(Z, MAX); #endif #if CORE_DIAG(XZ, X, MIN) diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index 01f33099e9..f4532ca1a0 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -69,7 +69,7 @@ enum EndstopEnum : char { #endif // Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop) - _ES_ITEM(HAS_BED_PROBE, Z_MIN_PROBE IF_DISABLED(HAS_CUSTOM_PROBE_PIN, = Z_MIN)) + _ES_ITEM(HAS_BED_PROBE, Z_MIN_PROBE IF_DISABLED(USES_Z_MIN_PROBE_PIN, = Z_MIN)) // The total number of states NUM_ENDSTOP_STATES @@ -81,7 +81,7 @@ enum EndstopEnum : char { #if HAS_Y_MIN || HAS_Y_MAX , Y_ENDSTOP = TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN) #endif - #if HAS_Z_MIN || HAS_Z_MAX + #if HAS_Z_MIN || HAS_Z_MAX || HOMING_Z_WITH_PROBE , Z_ENDSTOP = TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN)) #endif }; @@ -223,7 +223,7 @@ class Endstops { typedef struct { union { bool any; - struct { bool x:1, y:1, z:1; }; + struct { bool LINEAR_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1); }; }; } tmc_spi_homing_t; static tmc_spi_homing_t tmc_spi_homing; diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 1d40d3a253..eb6dc6597c 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -266,7 +266,18 @@ void report_current_position_projected() { get_cartesian_from_steppers(); const xyz_pos_t lpos = cartes.asLogical(); - SERIAL_ECHOPAIR("X:", lpos.x, " Y:", lpos.y, " Z:", lpos.z, " E:", current_position.e); + SERIAL_ECHOPAIR( + "X:", lpos.x + #if HAS_Y_AXIS + , " Y:", lpos.y + #endif + #if HAS_Z_AXIS + , " Z:", lpos.z + #endif + #if HAS_EXTRUDERS + , " E:", current_position.e + #endif + ); stepper.report_positions(); #if IS_SCARA @@ -294,6 +305,10 @@ void report_current_position_projected() { #endif +void home_if_needed(const bool keeplev/*=false*/) { + if (!all_axes_trusted()) gcode.home_all_axes(keeplev); +} + /** * Run out the planner buffer and re-sync the current * position from the last-updated stepper positions. @@ -588,27 +603,27 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } #endif -#if LINEAR_AXES == 4 +#if LINEAR_AXES >= 4 void do_blocking_move_to_i(const_float_t ri, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xyz_i(current_position, ri, fr_mm_s); } void do_blocking_move_to_xyz_i(const xyze_pos_t &raw, const_float_t i, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, raw.z, i, fr_mm_s); + do_blocking_move_to( + LINEAR_AXIS_LIST(raw.x, raw.y, raw.z, i, raw.j, raw.k), + fr_mm_s + ); } #endif #if LINEAR_AXES >= 5 - void do_blocking_move_to_i(const_float_t ri, const_feedRate_t fr_mm_s/*=0.0*/) { - do_blocking_move_to_xyz_i(current_position, ri, fr_mm_s); - } - void do_blocking_move_to_xyz_i(const xyze_pos_t &raw, const_float_t i, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, raw.z, i, raw.j, fr_mm_s); - } void do_blocking_move_to_j(const_float_t rj, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xyzi_j(current_position, rj, fr_mm_s); } void do_blocking_move_to_xyzi_j(const xyze_pos_t &raw, const_float_t j, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, raw.z, raw.i, j, fr_mm_s); + do_blocking_move_to( + LINEAR_AXIS_LIST(raw.x, raw.y, raw.z, raw.i, j, raw.k), + fr_mm_s + ); } #endif @@ -617,7 +632,10 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xyzij_k(current_position, rk, fr_mm_s); } void do_blocking_move_to_xyzij_k(const xyze_pos_t &raw, const_float_t k, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, raw.z, raw.i, raw.j, k, fr_mm_s); + do_blocking_move_to( + LINEAR_AXIS_LIST(raw.x, raw.y, raw.z, raw.i, raw.j, k), + fr_mm_s + ); } #endif @@ -685,8 +703,7 @@ void restore_feedrate_and_scaling() { * at the same positions relative to the machine. */ void update_software_endstops(const AxisEnum axis - OPTARG(HAS_HOTEND_OFFSET, const uint8_t old_tool_index/*=0*/) - OPTARG(HAS_HOTEND_OFFSET, const uint8_t new_tool_index/*=0*/) + OPTARG(HAS_HOTEND_OFFSET, const uint8_t old_tool_index/*=0*/, const uint8_t new_tool_index/*=0*/) ) { #if ENABLED(DUAL_X_CARRIAGE) @@ -822,7 +839,7 @@ void restore_feedrate_and_scaling() { #endif } #endif - #if LINEAR_AXES >= 4 // TODO (DerAndere): Find out why this was missing / removed + #if LINEAR_AXES >= 4 if (axis_was_homed(I_AXIS)) { #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_I) NOLESS(target.i, soft_endstop.min.i); @@ -922,7 +939,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { float cartesian_mm = diff.magnitude(); // If the move is very short, check the E move distance - if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e); + TERN_(HAS_EXTRUDERS, if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e)); // No E move either? Game over. if (UNEAR_ZERO(cartesian_mm)) return true; @@ -1001,7 +1018,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { // If the move is very short, check the E move distance // No E move either? Game over. float cartesian_mm = diff.magnitude(); - if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e); + TERN_(HAS_EXTRUDERS, if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e)); if (UNEAR_ZERO(cartesian_mm)) return; // The length divided by the segment size @@ -1295,7 +1312,7 @@ void prepare_line_to_destination() { bool homing_needed_error(linear_axis_bits_t axis_bits/*=linear_bits*/) { if ((axis_bits = axes_should_home(axis_bits))) { - PGM_P home_first = GET_TEXT(MSG_HOME_FIRST); // TODO: (DerAndere) Set this up for extra axes + PGM_P home_first = GET_TEXT(MSG_HOME_FIRST); char msg[strlen_P(home_first)+1]; sprintf_P(msg, home_first, LINEAR_AXIS_LIST( @@ -1390,8 +1407,21 @@ void prepare_line_to_destination() { #if ENABLED(SPI_ENDSTOPS) switch (axis) { case X_AXIS: if (ENABLED(X_SPI_SENSORLESS)) endstops.tmc_spi_homing.x = true; break; - case Y_AXIS: if (ENABLED(Y_SPI_SENSORLESS)) endstops.tmc_spi_homing.y = true; break; - case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = true; break; + #if HAS_Y_AXIS + case Y_AXIS: if (ENABLED(Y_SPI_SENSORLESS)) endstops.tmc_spi_homing.y = true; break; + #endif + #if HAS_Z_AXIS + case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = true; break; + #endif + #if LINEAR_AXES >= 4 + case I_AXIS: if (ENABLED(I_SPI_SENSORLESS)) endstops.tmc_spi_homing.i = true; break; + #endif + #if LINEAR_AXES >= 5 + case J_AXIS: if (ENABLED(J_SPI_SENSORLESS)) endstops.tmc_spi_homing.j = true; break; + #endif + #if LINEAR_AXES >= 6 + case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = true; break; + #endif default: break; } #endif @@ -1454,11 +1484,21 @@ void prepare_line_to_destination() { #if ENABLED(SPI_ENDSTOPS) switch (axis) { case X_AXIS: if (ENABLED(X_SPI_SENSORLESS)) endstops.tmc_spi_homing.x = false; break; - case Y_AXIS: if (ENABLED(Y_SPI_SENSORLESS)) endstops.tmc_spi_homing.y = false; break; - case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = false; break; - case I_AXIS: if (ENABLED(I_SPI_SENSORLESS)) endstops.tmc_spi_homing.i = false; break; - case J_AXIS: if (ENABLED(J_SPI_SENSORLESS)) endstops.tmc_spi_homing.j = false; break; - case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = false; break; + #if HAS_Y_AXIS + case Y_AXIS: if (ENABLED(Y_SPI_SENSORLESS)) endstops.tmc_spi_homing.y = false; break; + #endif + #if HAS_Z_AXIS + case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = false; break; + #endif + #if LINEAR_AXES >= 4 + case I_AXIS: if (ENABLED(I_SPI_SENSORLESS)) endstops.tmc_spi_homing.i = false; break; + #endif + #if LINEAR_AXES >= 5 + case J_AXIS: if (ENABLED(J_SPI_SENSORLESS)) endstops.tmc_spi_homing.j = false; break; + #endif + #if LINEAR_AXES >= 6 + case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = false; break; + #endif default: break; } #endif @@ -1734,11 +1774,11 @@ void prepare_line_to_destination() { #endif // - // Back away to prevent an early X/Y sensorless trigger + // Back away to prevent an early sensorless trigger // #if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM) - const xy_float_t backoff = SENSORLESS_BACKOFF_MM; - if ((TERN0(X_SENSORLESS, axis == X_AXIS) || TERN0(Y_SENSORLESS, axis == Y_AXIS)) && backoff[axis]) { + const xyz_float_t backoff = SENSORLESS_BACKOFF_MM; + if ((TERN0(X_SENSORLESS, axis == X_AXIS) || TERN0(Y_SENSORLESS, axis == Y_AXIS) || TERN0(Z_SENSORLESS, axis == Z_AXIS) || TERN0(I_SENSORLESS, axis == I_AXIS) || TERN0(J_SENSORLESS, axis == J_AXIS) || TERN0(K_SENSORLESS, axis == K_AXIS)) && backoff[axis]) { const float backoff_length = -ABS(backoff[axis]) * axis_home_dir; if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Sensorless backoff: ", backoff_length, "mm"); do_homing_move(axis, backoff_length, homing_feedrate(axis)); @@ -1777,6 +1817,15 @@ void prepare_line_to_destination() { case X_AXIS: es = X_ENDSTOP; break; case Y_AXIS: es = Y_ENDSTOP; break; case Z_AXIS: es = Z_ENDSTOP; break; + #if LINEAR_AXES >= 4 + case I_AXIS: es = I_ENDSTOP; break; + #endif + #if LINEAR_AXES >= 5 + case J_AXIS: es = J_ENDSTOP; break; + #endif + #if LINEAR_AXES >= 6 + case K_AXIS: es = K_ENDSTOP; break; + #endif } if (TEST(endstops.state(), es)) { SERIAL_ECHO_MSG("Bad ", AS_CHAR(AXIS_CHAR(axis)), " Endstop?"); diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 9095290cc7..c41738a5ab 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -180,7 +180,7 @@ inline float home_bump_mm(const AxisEnum axis) { TERN_(MAX_SOFTWARE_ENDSTOP_Z, amax = max.z); break; #endif - #if LINEAR_AXES >= 4 // TODO (DerAndere): Test for LINEAR_AXES >= 4 + #if LINEAR_AXES >= 4 case I_AXIS: TERN_(MIN_SOFTWARE_ENDSTOP_I, amin = min.i); TERN_(MIN_SOFTWARE_ENDSTOP_I, amax = max.i); @@ -392,33 +392,35 @@ void set_axis_is_at_home(const AxisEnum axis); void set_axis_never_homed(const AxisEnum axis); linear_axis_bits_t axes_should_home(linear_axis_bits_t axis_bits=linear_bits); bool homing_needed_error(linear_axis_bits_t axis_bits=linear_bits); - FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) { CBI(axis_homed, axis); } - FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); } - FORCE_INLINE void set_all_unhomed() { axis_homed = axis_trusted = 0; } - FORCE_INLINE void set_axis_homed(const AxisEnum axis) { SBI(axis_homed, axis); } - FORCE_INLINE void set_axis_trusted(const AxisEnum axis) { SBI(axis_trusted, axis); } - FORCE_INLINE void set_all_homed() { axis_homed = axis_trusted = linear_bits; } + inline void set_axis_unhomed(const AxisEnum axis) { CBI(axis_homed, axis); } + inline void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); } + inline void set_all_unhomed() { axis_homed = axis_trusted = 0; } + inline void set_axis_homed(const AxisEnum axis) { SBI(axis_homed, axis); } + inline void set_axis_trusted(const AxisEnum axis) { SBI(axis_trusted, axis); } + inline void set_all_homed() { axis_homed = axis_trusted = linear_bits; } #else constexpr linear_axis_bits_t axis_homed = linear_bits, axis_trusted = linear_bits; // Zero-endstop machines are always homed and trusted - FORCE_INLINE void homeaxis(const AxisEnum axis) {} - FORCE_INLINE void set_axis_never_homed(const AxisEnum) {} - FORCE_INLINE linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; } - FORCE_INLINE bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; } - FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) {} - FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) {} - FORCE_INLINE void set_all_unhomed() {} - FORCE_INLINE void set_axis_homed(const AxisEnum axis) {} - FORCE_INLINE void set_axis_trusted(const AxisEnum axis) {} - FORCE_INLINE void set_all_homed() {} + inline void homeaxis(const AxisEnum axis) {} + inline void set_axis_never_homed(const AxisEnum) {} + inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; } + inline bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; } + inline void set_axis_unhomed(const AxisEnum axis) {} + inline void set_axis_untrusted(const AxisEnum axis) {} + inline void set_all_unhomed() {} + inline void set_axis_homed(const AxisEnum axis) {} + inline void set_axis_trusted(const AxisEnum axis) {} + inline void set_all_homed() {} #endif -FORCE_INLINE bool axis_was_homed(const AxisEnum axis) { return TEST(axis_homed, axis); } -FORCE_INLINE bool axis_is_trusted(const AxisEnum axis) { return TEST(axis_trusted, axis); } -FORCE_INLINE bool axis_should_home(const AxisEnum axis) { return (axes_should_home() & _BV(axis)) != 0; } -FORCE_INLINE bool no_axes_homed() { return !axis_homed; } -FORCE_INLINE bool all_axes_homed() { return linear_bits == (axis_homed & linear_bits); } -FORCE_INLINE bool homing_needed() { return !all_axes_homed(); } -FORCE_INLINE bool all_axes_trusted() { return linear_bits == (axis_trusted & linear_bits); } +inline bool axis_was_homed(const AxisEnum axis) { return TEST(axis_homed, axis); } +inline bool axis_is_trusted(const AxisEnum axis) { return TEST(axis_trusted, axis); } +inline bool axis_should_home(const AxisEnum axis) { return (axes_should_home() & _BV(axis)) != 0; } +inline bool no_axes_homed() { return !axis_homed; } +inline bool all_axes_homed() { return linear_bits == (axis_homed & linear_bits); } +inline bool homing_needed() { return !all_axes_homed(); } +inline bool all_axes_trusted() { return linear_bits == (axis_trusted & linear_bits); } + +void home_if_needed(const bool keeplev=false); #if ENABLED(NO_MOTION_BEFORE_HOMING) #define MOTION_CONDITIONS (IsRunning() && !homing_needed_error()) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index eb0d204cb0..52ca76308c 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1451,7 +1451,7 @@ void Planner::check_axes_activity() { float high = 0.0; for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { block_t *block = &block_buffer[b]; - if (LINEAR_AXIS_GANG(block->steps.x, || block->steps.y, || block->steps.z, block->steps.i, || block->steps.j, || block->steps.k)) { + if (LINEAR_AXIS_GANG(block->steps.x, || block->steps.y, || block->steps.z, || block->steps.i, || block->steps.j, || block->steps.k)) { const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec; NOLESS(high, se); } @@ -1527,6 +1527,34 @@ void Planner::check_axes_activity() { } #endif +#if ENABLED(IMPROVE_HOMING_RELIABILITY) + + void Planner::enable_stall_prevention(const bool onoff) { + static motion_state_t saved_motion_state; + if (onoff) { + saved_motion_state.acceleration.x = settings.max_acceleration_mm_per_s2[X_AXIS]; + saved_motion_state.acceleration.y = settings.max_acceleration_mm_per_s2[Y_AXIS]; + settings.max_acceleration_mm_per_s2[X_AXIS] = settings.max_acceleration_mm_per_s2[Y_AXIS] = 100; + #if ENABLED(DELTA) + saved_motion_state.acceleration.z = settings.max_acceleration_mm_per_s2[Z_AXIS]; + settings.max_acceleration_mm_per_s2[Z_AXIS] = 100; + #endif + #if HAS_CLASSIC_JERK + saved_motion_state.jerk_state = max_jerk; + max_jerk.set(0, 0 OPTARG(DELTA, 0)); + #endif + } + else { + settings.max_acceleration_mm_per_s2[X_AXIS] = saved_motion_state.acceleration.x; + settings.max_acceleration_mm_per_s2[Y_AXIS] = saved_motion_state.acceleration.y; + TERN_(DELTA, settings.max_acceleration_mm_per_s2[Z_AXIS] = saved_motion_state.acceleration.z); + TERN_(HAS_CLASSIC_JERK, max_jerk = saved_motion_state.jerk_state); + } + reset_acceleration_rates(); + } + +#endif + #if HAS_LEVELING constexpr xy_pos_t level_fulcrum = { @@ -2656,7 +2684,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #ifndef TRAVEL_EXTRA_XYJERK #define TRAVEL_EXTRA_XYJERK 0 #endif - const float extra_xyjerk = (de <= 0) ? TRAVEL_EXTRA_XYJERK : 0; + const float extra_xyjerk = TERN0(HAS_EXTRUDERS, de <= 0) ? TRAVEL_EXTRA_XYJERK : 0; uint8_t limited = 0; TERN(HAS_LINEAR_E_JERK, LOOP_LINEAR_AXES, LOOP_LOGICAL_AXES)(i) { @@ -2852,7 +2880,7 @@ bool Planner::buffer_segment(const abce_pos_t &abce int32_t(LROUND(abce.a * settings.axis_steps_per_mm[A_AXIS])), int32_t(LROUND(abce.b * settings.axis_steps_per_mm[B_AXIS])), int32_t(LROUND(abce.c * settings.axis_steps_per_mm[C_AXIS])), - int32_t(LROUND(abce.i * settings.axis_steps_per_mm[I_AXIS])), // FIXME (DerAndere): Multiplication by 4.0 is a work-around for issue with wrong internal steps per mm + int32_t(LROUND(abce.i * settings.axis_steps_per_mm[I_AXIS])), int32_t(LROUND(abce.j * settings.axis_steps_per_mm[J_AXIS])), int32_t(LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS])) ) @@ -2893,7 +2921,7 @@ bool Planner::buffer_segment(const abce_pos_t &abce #endif #if LINEAR_AXES >= 4 SERIAL_ECHOPAIR_P(SP_I_LBL, abce.i); - SERIAL_ECHOPAIR(" (", position.i, "->", target.i); // FIXME (DerAndere): Introduce work-around for issue with wrong internal steps per mm and feedrate for I_AXIS + SERIAL_ECHOPAIR(" (", position.i, "->", target.i); SERIAL_CHAR(')'); #endif #if LINEAR_AXES >= 5 diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 10114ebfc6..9b104615f6 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -281,6 +281,15 @@ typedef struct { min_travel_feedrate_mm_s; // (mm/s) M205 T - Minimum travel feedrate } planner_settings_t; +#if ENABLED(IMPROVE_HOMING_RELIABILITY) + struct motion_state_t { + TERN(DELTA, xyz_ulong_t, xy_ulong_t) acceleration; + #if HAS_CLASSIC_JERK + TERN(DELTA, xyz_float_t, xy_float_t) jerk_state; + #endif + }; +#endif + #if DISABLED(SKEW_CORRECTION) #define XY_SKEW_FACTOR 0 #define XZ_SKEW_FACTOR 0 @@ -532,6 +541,10 @@ class Planner { } #endif + #if ENABLED(IMPROVE_HOMING_RELIABILITY) + void enable_stall_prevention(const bool onoff); + #endif + #if DISABLED(NO_VOLUMETRICS) // Update multipliers based on new diameter measurements diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 0042302fc7..d0f32a32c0 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -68,7 +68,7 @@ #include "servo.h" #endif -#if ENABLED(SENSORLESS_PROBING) +#if EITHER(SENSORLESS_PROBING, SENSORLESS_HOMING) #include "stepper.h" #include "../feature/tmc_util.h" #endif @@ -92,6 +92,10 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() const xy_pos_t &Probe::offset_xy = Probe::offset; #endif +#if ENABLED(SENSORLESS_PROBING) + Probe::sense_bool_t Probe::test_sensitivity; +#endif + #if ENABLED(Z_PROBE_SLED) #ifndef SLED_DOCKING_OFFSET @@ -245,6 +249,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() void Probe::set_probing_paused(const bool dopause) { TERN_(PROBING_HEATERS_OFF, thermalManager.pause_heaters(dopause)); TERN_(PROBING_FANS_OFF, thermalManager.set_fans_paused(dopause)); + TERN_(PROBING_ESTEPPERS_OFF, if (dopause) disable_e_steppers()); #if ENABLED(PROBING_STEPPERS_OFF) IF_DISABLED(DELTA, static uint8_t old_trusted); if (dopause) { @@ -253,7 +258,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() DISABLE_AXIS_X(); DISABLE_AXIS_Y(); #endif - disable_e_steppers(); + IF_DISABLED(PROBING_ESTEPPERS_OFF, disable_e_steppers()); } else { #if DISABLED(DELTA) @@ -282,7 +287,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #if ENABLED(PAUSE_BEFORE_DEPLOY_STOW) do { #if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED) - if (deploy == PROBE_TRIGGERED()) break; + if (deploy != PROBE_TRIGGERED()) break; #endif BUZZ(100, 659); @@ -384,7 +389,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { DEBUG_EOL(); 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()); + TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating()); } #endif @@ -492,11 +497,12 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if ENABLED(SENSORLESS_PROBING) sensorless_t stealth_states { false }; #if ENABLED(DELTA) - stealth_states.x = tmc_enable_stallguard(stepperX); - stealth_states.y = tmc_enable_stallguard(stepperY); + if (probe.test_sensitivity.x) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall + if (probe.test_sensitivity.y) stealth_states.y = tmc_enable_stallguard(stepperY); #endif - stealth_states.z = tmc_enable_stallguard(stepperZ); + if (probe.test_sensitivity.z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall endstops.enable(true); + set_homing_current(true); // The "homing" current also applies to probing #endif TERN_(HAS_QUIET_PROBING, set_probing_paused(true)); @@ -519,10 +525,11 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if ENABLED(SENSORLESS_PROBING) endstops.not_homing(); #if ENABLED(DELTA) - tmc_disable_stallguard(stepperX, stealth_states.x); - tmc_disable_stallguard(stepperY, stealth_states.y); + if (probe.test_sensitivity.x) tmc_disable_stallguard(stepperX, stealth_states.x); + if (probe.test_sensitivity.y) tmc_disable_stallguard(stepperY, stealth_states.y); #endif - tmc_disable_stallguard(stepperZ, stealth_states.z); + if (probe.test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z); + set_homing_current(false); #endif if (probe_triggered && TERN0(BLTOUCH_SLOW_MODE, bltouch.stow())) // Stow in LOW SPEED MODE on every trigger @@ -814,4 +821,95 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai #endif // HAS_Z_SERVO_PROBE +#if EITHER(SENSORLESS_PROBING, SENSORLESS_HOMING) + + sensorless_t stealth_states { false }; + + /** + * Disable stealthChop if used. Enable diag1 pin on driver. + */ + void Probe::enable_stallguard_diag1() { + #if ENABLED(SENSORLESS_PROBING) + #if ENABLED(DELTA) + stealth_states.x = tmc_enable_stallguard(stepperX); + stealth_states.y = tmc_enable_stallguard(stepperY); + #endif + stealth_states.z = tmc_enable_stallguard(stepperZ); + endstops.enable(true); + #endif + } + + /** + * Re-enable stealthChop if used. Disable diag1 pin on driver. + */ + void Probe::disable_stallguard_diag1() { + #if ENABLED(SENSORLESS_PROBING) + endstops.not_homing(); + #if ENABLED(DELTA) + tmc_disable_stallguard(stepperX, stealth_states.x); + tmc_disable_stallguard(stepperY, stealth_states.y); + #endif + tmc_disable_stallguard(stepperZ, stealth_states.z); + #endif + } + + /** + * Change the current in the TMC drivers to N##_CURRENT_HOME. And we save the current configuration of each TMC driver. + */ + void Probe::set_homing_current(const bool onoff) { + #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) + #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Z) + #if ENABLED(DELTA) + static int16_t saved_current_X, saved_current_Y; + #endif + #if HAS_CURRENT_HOME(Z) + static int16_t saved_current_Z; + #endif + #if ((ENABLED(DELTA) && (HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(Y))) || HAS_CURRENT_HOME(Z)) + auto debug_current_on = [](PGM_P const s, const int16_t a, const int16_t b) { + if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPAIR(" current: ", a, " -> ", b); } + }; + #endif + if (onoff) { + #if ENABLED(DELTA) + #if HAS_CURRENT_HOME(X) + saved_current_X = stepperX.getMilliamps(); + stepperX.rms_current(X_CURRENT_HOME); + debug_current_on(PSTR("X"), saved_current_X, X_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(Y) + saved_current_Y = stepperY.getMilliamps(); + stepperY.rms_current(Y_CURRENT_HOME); + debug_current_on(PSTR("Y"), saved_current_Y, Y_CURRENT_HOME); + #endif + #endif + #if HAS_CURRENT_HOME(Z) + saved_current_Z = stepperZ.getMilliamps(); + stepperZ.rms_current(Z_CURRENT_HOME); + debug_current_on(PSTR("Z"), saved_current_Z, Z_CURRENT_HOME); + #endif + TERN_(IMPROVE_HOMING_RELIABILITY, planner.enable_stall_prevention(true)); + } + else { + #if ENABLED(DELTA) + #if HAS_CURRENT_HOME(X) + stepperX.rms_current(saved_current_X); + debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_X); + #endif + #if HAS_CURRENT_HOME(Y) + stepperY.rms_current(saved_current_Y); + debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_Y); + #endif + #endif + #if HAS_CURRENT_HOME(Z) + stepperZ.rms_current(saved_current_Z); + debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_Z); + #endif + TERN_(IMPROVE_HOMING_RELIABILITY, planner.enable_stall_prevention(false)); + } + #endif + } + +#endif // SENSORLESS_PROBING + #endif // HAS_BED_PROBE diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index da46c830f6..ce690593f2 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -38,7 +38,7 @@ }; #endif -#if HAS_CUSTOM_PROBE_PIN +#if USES_Z_MIN_PROBE_PIN #define PROBE_TRIGGERED() (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) #else #define PROBE_TRIGGERED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) @@ -56,6 +56,11 @@ class Probe { public: + #if ENABLED(SENSORLESS_PROBING) + typedef struct { bool x:1, y:1, z:1; } sense_bool_t; + static sense_bool_t test_sensitivity; + #endif + #if HAS_BED_PROBE static xyz_pos_t offset; @@ -256,6 +261,13 @@ public: static bool tare(); #endif + // Basic functions for Sensorless Homing and Probing + #if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING) + static void enable_stallguard_diag1(); + static void disable_stallguard_diag1(); + static void set_homing_current(const bool onoff); + #endif + private: static bool probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s); static void do_z_raise(const float z_raise); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index aae0f97361..b30c82260f 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V83" +#define EEPROM_VERSION "V84" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -130,7 +130,7 @@ #include "../feature/controllerfan.h" #if ENABLED(CONTROLLER_FAN_EDITABLE) - void M710_report(const bool forReplay); + void M710_report(const bool forReplay=true); #endif #if ENABLED(CASE_LIGHT_ENABLE) @@ -168,6 +168,10 @@ void M554_report(); #endif +#if EITHER(DELTA, HAS_EXTRA_ENDSTOPS) + void M666_report(const bool forReplay=true); +#endif + #define _EN_ITEM(N) , E##N typedef struct { uint16_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stepper_current_t; @@ -349,6 +353,11 @@ typedef struct SettingsDataStruct { // int16_t lcd_contrast; // M250 C + // + // HAS_LCD_BRIGHTNESS + // + uint8_t lcd_brightness; // M256 B + // // Controller fan settings // @@ -995,17 +1004,19 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(lcd_contrast); - - const int16_t lcd_contrast = - #if HAS_LCD_CONTRAST - ui.contrast - #else - 127 - #endif - ; + const int16_t lcd_contrast = TERN(HAS_LCD_CONTRAST, ui.contrast, 127); EEPROM_WRITE(lcd_contrast); } + // + // LCD Brightness + // + { + _FIELD_TEST(lcd_brightness); + const uint8_t lcd_brightness = TERN(HAS_LCD_BRIGHTNESS, ui.brightness, 255); + EEPROM_WRITE(lcd_brightness); + } + // // Controller Fan // @@ -1175,7 +1186,7 @@ void MarlinSettings::postprocess() { const tmc_hybrid_threshold_t tmc_hybrid_threshold = { LINEAR_AXIS_LIST(.X = 100, .Y = 100, .Z = 3, .I = 3, .J = 3, .K = 3), .X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3, .Z4 = 3 - REPEAT(EXTRUDERS, _EN_ITEM) + REPEAT(E_STEPPERS, _EN_ITEM) }; #undef _EN_ITEM #endif @@ -1327,12 +1338,12 @@ void MarlinSettings::postprocess() { // Extensible UI User Data // #if ENABLED(EXTENSIBLE_UI) - { - char extui_data[ExtUI::eeprom_data_size] = { 0 }; - ExtUI::onStoreSettings(extui_data); - _FIELD_TEST(extui_data); - EEPROM_WRITE(extui_data); - } + { + char extui_data[ExtUI::eeprom_data_size] = { 0 }; + ExtUI::onStoreSettings(extui_data); + _FIELD_TEST(extui_data); + EEPROM_WRITE(extui_data); + } #endif // @@ -1842,6 +1853,16 @@ void MarlinSettings::postprocess() { } } + // + // LCD Brightness + // + { + _FIELD_TEST(lcd_brightness); + uint8_t lcd_brightness; + EEPROM_READ(lcd_brightness); + TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.set_brightness(lcd_brightness)); + } + // // Controller Fan // @@ -2196,13 +2217,12 @@ void MarlinSettings::postprocess() { // Extensible UI User Data // #if ENABLED(EXTENSIBLE_UI) - // This is a significant hardware change; don't reserve EEPROM space when not present - { - const char extui_data[ExtUI::eeprom_data_size] = { 0 }; - _FIELD_TEST(extui_data); - EEPROM_READ(extui_data); - if (!validating) ExtUI::onLoadSettings(extui_data); - } + { // This is a significant hardware change; don't reserve EEPROM space when not present + const char extui_data[ExtUI::eeprom_data_size] = { 0 }; + _FIELD_TEST(extui_data); + EEPROM_READ(extui_data); + if (!validating) ExtUI::onLoadSettings(extui_data); + } #endif // @@ -2826,6 +2846,11 @@ void MarlinSettings::reset() { // TERN_(HAS_LCD_CONTRAST, ui.set_contrast(DEFAULT_LCD_CONTRAST)); + // + // LCD Brightness + // + TERN_(HAS_LCD_BRIGHTNESS, ui.set_brightness(DEFAULT_LCD_BRIGHTNESS)); + // // Controller Fan // @@ -3163,7 +3188,7 @@ void MarlinSettings::reset() { CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( #if IS_CARTESIAN - LIST_N(LINEAR_AXES, + LIST_N(DOUBLE(LINEAR_AXES), PSTR(" M206 X"), LINEAR_UNIT(home_offset.x), SP_Y_STR, LINEAR_UNIT(home_offset.y), SP_Z_STR, LINEAR_UNIT(home_offset.z), @@ -3302,14 +3327,6 @@ void MarlinSettings::reset() { #elif ENABLED(DELTA) - CONFIG_ECHO_HEADING("Endstop adjustment:"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M666 X"), LINEAR_UNIT(delta_endstop_adj.a) - , SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b) - , SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c) - ); - CONFIG_ECHO_HEADING("Delta settings: L R H S XYZ ABC"); CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( @@ -3325,32 +3342,11 @@ void MarlinSettings::reset() { , PSTR(" C"), LINEAR_UNIT(delta_diagonal_rod_trim.c) ); - #elif HAS_EXTRA_ENDSTOPS + #endif - CONFIG_ECHO_HEADING("Endstop adjustment:"); - CONFIG_ECHO_START(); - SERIAL_ECHOPGM(" M666"); - #if ENABLED(X_DUAL_ENDSTOPS) - SERIAL_ECHOLNPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj)); - #endif - #if ENABLED(Y_DUAL_ENDSTOPS) - SERIAL_ECHOLNPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj)); - #endif - #if ENABLED(Z_MULTI_ENDSTOPS) - #if NUM_Z_STEPPER_DRIVERS >= 3 - SERIAL_ECHOPAIR(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); - CONFIG_ECHO_START(); - SERIAL_ECHOPAIR(" M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); - #if NUM_Z_STEPPER_DRIVERS >= 4 - CONFIG_ECHO_START(); - SERIAL_ECHOPAIR(" M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj)); - #endif - #else - SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj)); - #endif - #endif - - #endif // [XYZ]_DUAL_ENDSTOPS + #if EITHER(DELTA, HAS_EXTRA_ENDSTOPS) + M666_report(forReplay); + #endif #if PREHEAT_COUNT @@ -3432,6 +3428,11 @@ void MarlinSettings::reset() { CONFIG_ECHO_MSG(" M250 C", ui.contrast); #endif + #if HAS_LCD_BRIGHTNESS + CONFIG_ECHO_HEADING("LCD Brightness:"); + CONFIG_ECHO_MSG(" M256 B", ui.brightness); + #endif + TERN_(CONTROLLER_FAN_EDITABLE, M710_report(forReplay)); #if ENABLED(POWER_LOSS_RECOVERY) @@ -3818,10 +3819,10 @@ void MarlinSettings::reset() { SERIAL_CHAR(' ', 'B'); // B (maps to E1 by default) SERIAL_ECHOLN(stepper.motor_current_setting[4]); #endif - #elif ENABLED(HAS_MOTOR_CURRENT_I2C) // i2c-based has any number of values + #elif HAS_MOTOR_CURRENT_I2C // i2c-based has any number of values // Values sent over i2c are not stored. // Indexes map directly to drivers, not axes. - #elif ENABLED(HAS_MOTOR_CURRENT_DAC) // DAC-based has 4 values, for X Y Z (I J K) E + #elif HAS_MOTOR_CURRENT_DAC // DAC-based has 4 values, for X Y Z (I J K) E // Values sent over i2c are not stored. Uses indirect mapping. #endif diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 062049ec77..0ff909d7cc 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -314,26 +314,18 @@ xyze_int8_t Stepper::count_direction{0}; A##3_STEP_WRITE(V); \ } -#define QUAD_ENDSTOP_APPLY_STEP(A,V) \ - if (separate_multi_axis) { \ - if (ENABLED(A##_HOME_TO_MIN)) { \ - if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ - if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ - if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ - if (!(TEST(endstops.state(), A##4_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##4_motor) A##4_STEP_WRITE(V); \ - } \ - else { \ - if (!(TEST(endstops.state(), A##_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ - if (!(TEST(endstops.state(), A##2_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ - if (!(TEST(endstops.state(), A##3_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ - if (!(TEST(endstops.state(), A##4_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##4_motor) A##4_STEP_WRITE(V); \ - } \ - } \ - else { \ - A##_STEP_WRITE(V); \ - A##2_STEP_WRITE(V); \ - A##3_STEP_WRITE(V); \ - A##4_STEP_WRITE(V); \ +#define QUAD_ENDSTOP_APPLY_STEP(A,V) \ + if (separate_multi_axis) { \ + if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##_MIN, A##_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ + if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##2_MIN, A##2_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ + if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##3_MIN, A##3_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ + if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##4_MIN, A##4_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##4_motor) A##4_STEP_WRITE(V); \ + } \ + else { \ + A##_STEP_WRITE(V); \ + A##2_STEP_WRITE(V); \ + A##3_STEP_WRITE(V); \ + A##4_STEP_WRITE(V); \ } #define QUAD_SEPARATE_APPLY_STEP(A,V) \ diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 4770fd4dc1..beba03699e 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -44,7 +44,7 @@ #include "trinamic.h" #endif -void restore_stepper_drivers(); // Called by PSU_ON +void restore_stepper_drivers(); // Called by powerManager.power_on() void reset_stepper_drivers(); // Called by settings.load / settings.reset // X Stepper @@ -645,6 +645,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif +#elif ENABLED(E_DUAL_STEPPER_DRIVERS) + #define E_STEP_WRITE(E,V) do{ E0_STEP_WRITE(V); E1_STEP_WRITE(V); }while(0) + #define NORM_E_DIR(E) do{ E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E0_DIR ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) + #define REV_E_DIR(E) do{ E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E0_DIR ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) + #elif E_STEPPERS #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) @@ -1013,6 +1018,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset // #if ENABLED(MIXING_EXTRUDER) + /** * Mixing steppers keep all their enable (and direction) states synchronized */ @@ -1020,6 +1026,12 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define _CALL_DIS_E(N) DISABLE_STEPPER_E##N () ; #define ENABLE_AXIS_E0() { RREPEAT(MIXING_STEPPERS, _CALL_ENA_E) } #define DISABLE_AXIS_E0() { RREPEAT(MIXING_STEPPERS, _CALL_DIS_E) } + +#elif ENABLED(E_DUAL_STEPPER_DRIVERS) + + #define ENABLE_AXIS_E0() do{ ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); }while(0) + #define DISABLE_AXIS_E0() do{ DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); }while(0) + #endif #ifndef ENABLE_AXIS_E0 diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index dbde6a5a04..f9ed43acbf 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -766,11 +766,7 @@ enum StealthIndex : uint8_t { pwmconf.pwm_ofs = 36; st.PWMCONF(pwmconf.sr); - #if ENABLED(HYBRID_THRESHOLD) - st.set_pwm_thrs(hyb_thrs); - #else - UNUSED(hyb_thrs); - #endif + TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); st.GSTAT(); // Clear GSTAT } #endif // TMC5160 @@ -971,11 +967,12 @@ void reset_trinamic_drivers() { // Using a fixed-length character array for the port name allows this to be constexpr compatible. struct SanityHwSerialDetails { const char port[20]; uint32_t address; }; #define TMC_HW_DETAIL_ARGS(A) TERN(A##_HAS_HW_SERIAL, STRINGIFY(A##_HARDWARE_SERIAL), ""), TERN0(A##_HAS_HW_SERIAL, A##_SLAVE_ADDRESS) - #define TMC_HW_DETAIL(A) {TMC_HW_DETAIL_ARGS(A)} + #define TMC_HW_DETAIL(A) { TMC_HW_DETAIL_ARGS(A) } constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = { TMC_HW_DETAIL(X), TMC_HW_DETAIL(X2), TMC_HW_DETAIL(Y), TMC_HW_DETAIL(Y2), TMC_HW_DETAIL(Z), TMC_HW_DETAIL(Z2), TMC_HW_DETAIL(Z3), TMC_HW_DETAIL(Z4), + TMC_HW_DETAIL(I), TMC_HW_DETAIL(J), TMC_HW_DETAIL(K), TMC_HW_DETAIL(E0), TMC_HW_DETAIL(E1), TMC_HW_DETAIL(E2), TMC_HW_DETAIL(E3), TMC_HW_DETAIL(E4), TMC_HW_DETAIL(E5), TMC_HW_DETAIL(E6), TMC_HW_DETAIL(E7) }; @@ -995,10 +992,11 @@ void reset_trinamic_drivers() { #define TMC_HWSERIAL_CONFLICT_MSG(A) STRINGIFY(A) "_SLAVE_ADDRESS conflicts with another driver using the same " STRINGIFY(A) "_HARDWARE_SERIAL" #define SA_NO_TMC_HW_C(A) static_assert(1 >= count_tmc_hw_serial_matches(TMC_HW_DETAIL_ARGS(A), 0, COUNT(sanity_tmc_hw_details)), TMC_HWSERIAL_CONFLICT_MSG(A)); - SA_NO_TMC_HW_C(X);SA_NO_TMC_HW_C(X2); - SA_NO_TMC_HW_C(Y);SA_NO_TMC_HW_C(Y2); - SA_NO_TMC_HW_C(Z);SA_NO_TMC_HW_C(Z2);SA_NO_TMC_HW_C(Z3);SA_NO_TMC_HW_C(Z4); - SA_NO_TMC_HW_C(E0);SA_NO_TMC_HW_C(E1);SA_NO_TMC_HW_C(E2);SA_NO_TMC_HW_C(E3);SA_NO_TMC_HW_C(E4);SA_NO_TMC_HW_C(E5);SA_NO_TMC_HW_C(E6);SA_NO_TMC_HW_C(E7); + SA_NO_TMC_HW_C(X); SA_NO_TMC_HW_C(X2); + SA_NO_TMC_HW_C(Y); SA_NO_TMC_HW_C(Y2); + SA_NO_TMC_HW_C(Z); SA_NO_TMC_HW_C(Z2); SA_NO_TMC_HW_C(Z3); SA_NO_TMC_HW_C(Z4); + SA_NO_TMC_HW_C(I); SA_NO_TMC_HW_C(J); SA_NO_TMC_HW_C(K); + SA_NO_TMC_HW_C(E0); SA_NO_TMC_HW_C(E1); SA_NO_TMC_HW_C(E2); SA_NO_TMC_HW_C(E3); SA_NO_TMC_HW_C(E4); SA_NO_TMC_HW_C(E5); SA_NO_TMC_HW_C(E6); SA_NO_TMC_HW_C(E7); #endif #if ANY_AXIS_HAS(SW_SERIAL) @@ -1009,6 +1007,7 @@ void reset_trinamic_drivers() { TMC_SW_DETAIL(X), TMC_SW_DETAIL(X2), TMC_SW_DETAIL(Y), TMC_SW_DETAIL(Y2), TMC_SW_DETAIL(Z), TMC_SW_DETAIL(Z2), TMC_SW_DETAIL(Z3), TMC_SW_DETAIL(Z4), + TMC_SW_DETAIL(I), TMC_SW_DETAIL(J), TMC_SW_DETAIL(K), TMC_SW_DETAIL(E0), TMC_SW_DETAIL(E1), TMC_SW_DETAIL(E2), TMC_SW_DETAIL(E3), TMC_SW_DETAIL(E4), TMC_SW_DETAIL(E5), TMC_SW_DETAIL(E6), TMC_SW_DETAIL(E7) }; @@ -1023,10 +1022,11 @@ void reset_trinamic_drivers() { #define TMC_SWSERIAL_CONFLICT_MSG(A) STRINGIFY(A) "_SLAVE_ADDRESS conflicts with another driver using the same " STRINGIFY(A) "_SERIAL_RX_PIN or " STRINGIFY(A) "_SERIAL_TX_PIN" #define SA_NO_TMC_SW_C(A) static_assert(1 >= count_tmc_sw_serial_matches(TMC_SW_DETAIL_ARGS(A), 0, COUNT(sanity_tmc_sw_details)), TMC_SWSERIAL_CONFLICT_MSG(A)); - SA_NO_TMC_SW_C(X);SA_NO_TMC_SW_C(X2); - SA_NO_TMC_SW_C(Y);SA_NO_TMC_SW_C(Y2); - SA_NO_TMC_SW_C(Z);SA_NO_TMC_SW_C(Z2);SA_NO_TMC_SW_C(Z3);SA_NO_TMC_SW_C(Z4); - SA_NO_TMC_SW_C(E0);SA_NO_TMC_SW_C(E1);SA_NO_TMC_SW_C(E2);SA_NO_TMC_SW_C(E3);SA_NO_TMC_SW_C(E4);SA_NO_TMC_SW_C(E5);SA_NO_TMC_SW_C(E6);SA_NO_TMC_SW_C(E7); + SA_NO_TMC_SW_C(X); SA_NO_TMC_SW_C(X2); + SA_NO_TMC_SW_C(Y); SA_NO_TMC_SW_C(Y2); + SA_NO_TMC_SW_C(Z); SA_NO_TMC_SW_C(Z2); SA_NO_TMC_SW_C(Z3); SA_NO_TMC_SW_C(Z4); + SA_NO_TMC_SW_C(I); SA_NO_TMC_SW_C(J); SA_NO_TMC_SW_C(K); + SA_NO_TMC_SW_C(E0); SA_NO_TMC_SW_C(E1); SA_NO_TMC_SW_C(E2); SA_NO_TMC_SW_C(E3); SA_NO_TMC_SW_C(E4); SA_NO_TMC_SW_C(E5); SA_NO_TMC_SW_C(E6); SA_NO_TMC_SW_C(E7); #endif #endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e2a1899202..20b070e712 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -34,6 +34,7 @@ #include "temperature.h" #include "endstops.h" #include "planner.h" +#include "printcounter.h" #if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER) #include "../feature/cooler.h" @@ -45,7 +46,7 @@ #endif #if ENABLED(DWIN_CREALITY_LCD) - #include "../lcd/dwin/e3v2/dwin.h" + #include "../lcd/e3v2/creality/dwin.h" #endif #if ENABLED(EXTENSIBLE_UI) @@ -56,110 +57,74 @@ #include "../feature/host_actions.h" #endif -// LIB_MAX31855 can be added to the build_flags in platformio.ini to use a user-defined library -#if LIB_USR_MAX31855 - #include - #if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK) - #define MAX31855_USES_SW_SPI 1 - #endif - #if TEMP_SENSOR_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) - #define HAS_MAX31855_TEMP 1 - Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN - #if MAX31855_USES_SW_SPI - , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK - #endif - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif - #if TEMP_SENSOR_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) - #define HAS_MAX31855_TEMP 1 - Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN - #if MAX31855_USES_SW_SPI - , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK - #endif - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif -#endif - -// LIB_MAX31865 can be added to the build_flags in platformio.ini to use a user-defined library. -// If LIB_MAX31865 is not on the build_flags then the Adafruit MAX31865 V1.1.0 library is used. -#if HAS_MAX31865 - #include - #ifndef MAX31865_MOSI_PIN - #define MAX31865_MOSI_PIN SD_MOSI_PIN - #endif - #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) - #define MAX31865_USES_SW_SPI 1 - #endif - #if TEMP_SENSOR_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) - #define HAS_MAX31865_TEMP 1 - Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN - #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) - , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK - #endif - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif - #if TEMP_SENSOR_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) - #define HAS_MAX31865_TEMP 1 - Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN - #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) - , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK - #endif - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif -#endif +// MAX TC related macros +#define TEMP_SENSOR_IS_MAX(n, M) (ENABLED(TEMP_SENSOR_##n##_IS_MAX##M) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX##M) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) +#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) // LIB_MAX6675 can be added to the build_flags in platformio.ini to use a user-defined library -#if LIB_USR_MAX6675 +// If LIB_MAX6675 is not on the build_flags then raw SPI reads will be used. +#if HAS_MAX6675 && LIB_USR_MAX6675 #include - #if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) - #define MAX6675_USES_SW_SPI 1 - #endif - #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) - #define HAS_MAX6675_TEMP 1 - MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN - #if MAX6675_USES_SW_SPI - , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK - #endif - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif - #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) - #define HAS_MAX6675_TEMP 1 - MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN - #if MAX6675_USES_SW_SPI - , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK - #endif - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); + #define HAS_MAX6675_LIBRARY 1 +#endif + +// LIB_MAX31855 can be added to the build_flags in platformio.ini to use a user-defined library. +// If LIB_MAX31855 is not on the build_flags then raw SPI reads will be used. +#if HAS_MAX31855 && LIB_USR_MAX31855 + #include + #define HAS_MAX31855_LIBRARY 1 + typedef Adafruit_MAX31855 MAX31855; +#endif + +#if HAS_MAX31865 + #if LIB_USR_MAX31865 + #include + typedef Adafruit_MAX31865 MAX31865; + #else + #include "../libs/MAX31865.h" #endif #endif -#if !HAS_MAX6675_TEMP && !HAS_MAX31855_TEMP && !HAS_MAX31865_TEMP - #define NO_THERMO_TEMPS 1 +#if HAS_MAX6675_LIBRARY || HAS_MAX31855_LIBRARY || HAS_MAX31865 + #define HAS_MAXTC_LIBRARIES 1 #endif -#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS - #define THERMO_SEPARATE_SPI 1 +// If we have a MAX TC with SCK and MISO pins defined, it's either on a separate/dedicated Hardware +// SPI bus, or some pins for Software SPI. Alternate Hardware SPI buses are not supported yet, so +// your SPI options are: +// +// 1. Only CS pin(s) defined: Hardware SPI on the default bus (usually the SD card SPI). +// 2. CS, MISO, and SCK pins defined: Software SPI on a separate bus, as defined by MISO, SCK. +// 3. CS, MISO, and SCK pins w/ FORCE_HW_SPI: Hardware SPI on the default bus, ignoring MISO, SCK. +// +#if TEMP_SENSOR_IS_ANY_MAX_TC(0) && TEMP_SENSOR_0_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI) + #define TEMP_SENSOR_0_USES_SW_SPI 1 +#endif +#if TEMP_SENSOR_IS_ANY_MAX_TC(1) && TEMP_SENSOR_1_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI) + #define TEMP_SENSOR_1_USES_SW_SPI 1 #endif -#if THERMO_SEPARATE_SPI +#if (TEMP_SENSOR_0_USES_SW_SPI || TEMP_SENSOR_1_USES_SW_SPI) && !HAS_MAXTC_LIBRARIES #include "../libs/private_spi.h" + #define HAS_MAXTC_SW_SPI 1 + + // Define pins for SPI-based sensors + #if TEMP_SENSOR_0_USES_SW_SPI + #define SW_SPI_SCK_PIN TEMP_0_SCK_PIN + #define SW_SPI_MISO_PIN TEMP_0_MISO_PIN + #if PIN_EXISTS(TEMP_0_MOSI) + #define SW_SPI_MOSI_PIN TEMP_0_MOSI_PIN + #endif + #else + #define SW_SPI_SCK_PIN TEMP_1_SCK_PIN + #define SW_SPI_MISO_PIN TEMP_1_MISO_PIN + #if PIN_EXISTS(TEMP_1_MOSI) + #define SW_SPI_MOSI_PIN TEMP_1_MOSI_PIN + #endif + #endif + #ifndef SW_SPI_MOSI_PIN + #define SW_SPI_MOSI_PIN SD_MOSI_PIN + #endif #endif #if ENABLED(PID_EXTRUSION_SCALING) @@ -170,8 +135,6 @@ #include "../feature/babystep.h" #endif -#include "printcounter.h" - #if ENABLED(FILAMENT_WIDTH_SENSOR) #include "../feature/filwidth.h" #endif @@ -210,15 +173,10 @@ #endif #if HAS_HOTEND_THERMISTOR - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - static const temp_entry_t* heater_ttbl_map[2] = { TEMPTABLE_0, TEMPTABLE_1 }; - static constexpr uint8_t heater_ttbllen_map[2] = { TEMPTABLE_0_LEN, TEMPTABLE_1_LEN }; - #else - #define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N - #define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN - static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); - static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN)); - #endif + #define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N + #define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN + static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); + static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN)); #endif Temperature thermalManager; @@ -249,7 +207,68 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #define _E_PSTR(h,N) ((HOTENDS) > N && (h) == N) ? PSTR(LCD_STR_E##N) : #define HEATER_PSTR(h) _BED_PSTR(h) _CHAMBER_PSTR(h) _COOLER_PSTR(h) _E_PSTR(h,1) _E_PSTR(h,2) _E_PSTR(h,3) _E_PSTR(h,4) _E_PSTR(h,5) PSTR(LCD_STR_E0) -// public: +// +// Initialize MAX TC objects/SPI +// +#if HAS_MAX_TC + + #if HAS_MAXTC_SW_SPI + // Initialize SoftSPI for non-lib Software SPI; Libraries take care of it themselves. + template + SoftSPI SPIclass::softSPI; + SPIclass max_tc_spi; + + #endif + + #define MAXTC_INIT(n, M) \ + MAX##M max##M##_##n = MAX##M( \ + TEMP_##n##_CS_PIN \ + OPTARG(_MAX31865_##n##_SW, TEMP_##n##_MOSI_PIN) \ + OPTARG(TEMP_SENSOR_##n##_USES_SW_SPI, TEMP_##n##_MISO_PIN, TEMP_##n##_SCK_PIN) \ + OPTARG(LARGE_PINMAP, HIGH) \ + ) + + #if HAS_MAX6675_LIBRARY + #if TEMP_SENSOR_IS_MAX(0, 6675) + MAXTC_INIT(0, 6675); + #endif + #if TEMP_SENSOR_IS_MAX(1, 6675) + MAXTC_INIT(1, 6675); + #endif + #endif + + #if HAS_MAX31855_LIBRARY + #if TEMP_SENSOR_IS_MAX(0, 31855) + MAXTC_INIT(0, 31855); + #endif + #if TEMP_SENSOR_IS_MAX(1, 31855) + MAXTC_INIT(1, 31855); + #endif + #endif + + // MAX31865 always uses a library, unlike '55 & 6675 + #if HAS_MAX31865 + #define _MAX31865_0_SW TEMP_SENSOR_0_USES_SW_SPI + #define _MAX31865_1_SW TEMP_SENSOR_1_USES_SW_SPI + + #if TEMP_SENSOR_IS_MAX(0, 31865) + MAXTC_INIT(0, 31865); + #endif + #if TEMP_SENSOR_IS_MAX(1, 31865) + MAXTC_INIT(1, 31865); + #endif + + #undef _MAX31865_0_SW + #undef _MAX31865_1_SW + #endif + + #undef MAXTC_INIT + +#endif + +/** + * public: + */ #if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING) bool Temperature::adaptive_fan_slowing = true; @@ -257,13 +276,14 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #if HAS_HOTEND 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 +#if HAS_TEMP_REDUNDANT + redundant_info_t Temperature::temp_redundant; +#endif + #if ENABLED(AUTO_POWER_E_FANS) uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 } #endif @@ -276,6 +296,25 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, uint8_t Temperature::coolerfan_speed; // = 0 #endif +// Init fans according to whether they're native PWM or Software PWM +#ifdef BOARD_OPENDRAIN_MOSFETS + #define _INIT_SOFT_FAN(P) OUT_WRITE_OD(P, FAN_INVERTING ? LOW : HIGH) +#else + #define _INIT_SOFT_FAN(P) OUT_WRITE(P, FAN_INVERTING ? LOW : HIGH) +#endif +#if ENABLED(FAN_SOFT_PWM) + #define _INIT_FAN_PIN(P) _INIT_SOFT_FAN(P) +#else + #define _INIT_FAN_PIN(P) do{ if (PWM_PIN(P)) SET_PWM(P); else _INIT_SOFT_FAN(P); }while(0) +#endif +#if ENABLED(FAST_PWM_FAN) + #define SET_FAST_PWM_FREQ(P) set_pwm_frequency(P, FAST_PWM_FAN_FREQUENCY) +#else + #define SET_FAST_PWM_FREQ(P) NOOP +#endif +#define INIT_FAN_PIN(P) do{ _INIT_FAN_PIN(P); SET_FAST_PWM_FREQ(P); }while(0) + +// HAS_FAN does not include CONTROLLER_FAN #if HAS_FAN uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 } @@ -335,6 +374,9 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, if (fan >= FAN_COUNT) return; fan_speed[fan] = speed; + #if REDUNDANT_PART_COOLING_FAN + if (fan == 0) fan_speed[REDUNDANT_PART_COOLING_FAN] = speed; + #endif TERN_(REPORT_FAN_CHANGE, report_fan_speed(fan)); } @@ -413,12 +455,31 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, probe_info_t Temperature::temp_probe; // = { 0 } #endif +#if HAS_TEMP_BOARD + board_info_t Temperature::temp_board; // = { 0 } + #if ENABLED(THERMAL_PROTECTION_BOARD) + int16_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, + Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; + #endif +#endif + #if ENABLED(PREVENT_COLD_EXTRUSION) bool Temperature::allow_cold_extrude = false; celsius_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP; #endif -// private: +#if HAS_ADC_BUTTONS + uint32_t Temperature::current_ADCKey_raw = HAL_ADC_RANGE; + uint16_t Temperature::ADCKey_count = 0; +#endif + +#if ENABLED(PID_EXTRUSION_SCALING) + int16_t Temperature::lpq_len; // Initialized in settings.cpp +#endif + +/** + * private: + */ volatile bool Temperature::raw_temps_ready = false; @@ -471,16 +532,10 @@ volatile bool Temperature::raw_temps_ready = false; bool Temperature::paused_for_probing; #endif -// public: - -#if HAS_ADC_BUTTONS - uint32_t Temperature::current_ADCKey_raw = HAL_ADC_RANGE; - uint16_t Temperature::ADCKey_count = 0; -#endif - -#if ENABLED(PID_EXTRUSION_SCALING) - int16_t Temperature::lpq_len; // Initialized in settings.cpp -#endif +/** + * public: + * Class and Instance Methods + */ #if HAS_PID_HEATING @@ -757,10 +812,6 @@ volatile bool Temperature::raw_temps_ready = false; #endif // HAS_PID_HEATING -/** - * Class and Instance Methods - */ - int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { switch (heater_id) { #if HAS_HEATED_BED @@ -780,6 +831,16 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { #define _EFANOVERLAP(A,B) _FANOVERLAP(E##A,B) #if HAS_AUTO_FAN + #if EXTRUDER_AUTO_FAN_SPEED != 255 + #define INIT_E_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) + #else + #define INIT_E_AUTO_FAN_PIN(P) SET_OUTPUT(P) + #endif + #if CHAMBER_AUTO_FAN_SPEED != 255 + #define INIT_CHAMBER_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) + #else + #define INIT_CHAMBER_AUTO_FAN_PIN(P) SET_OUTPUT(P) + #endif #define CHAMBER_FAN_INDEX HOTENDS @@ -903,14 +964,26 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms SERIAL_ERROR_START(); SERIAL_ECHOPGM_P(serial_msg); SERIAL_ECHOPGM(STR_STOPPED_HEATER); - if (heater_id >= 0) - SERIAL_ECHO(heater_id); - else if (TERN0(HAS_HEATED_CHAMBER, heater_id == H_CHAMBER)) - SERIAL_ECHOPGM(STR_HEATER_CHAMBER); - else if (TERN0(HAS_COOLER, heater_id == H_COOLER)) - SERIAL_ECHOPGM(STR_COOLER); - else - SERIAL_ECHOPGM(STR_HEATER_BED); + + heater_id_t real_heater_id = heater_id; + + #if HAS_TEMP_REDUNDANT + if (heater_id == H_REDUNDANT) { + SERIAL_ECHOPGM(STR_REDUNDANT); // print redundant and cascade to print target, too. + real_heater_id = (heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET); + } + #endif + + switch (real_heater_id) { + OPTCODE(HAS_TEMP_COOLER, case H_COOLER: SERIAL_ECHOPGM(STR_COOLER); break) + OPTCODE(HAS_TEMP_PROBE, case H_PROBE: SERIAL_ECHOPGM(STR_PROBE); break) + OPTCODE(HAS_TEMP_BOARD, case H_BOARD: SERIAL_ECHOPGM(STR_MOTHERBOARD); break) + OPTCODE(HAS_TEMP_CHAMBER, case H_CHAMBER: SERIAL_ECHOPGM(STR_HEATER_CHAMBER); break) + OPTCODE(HAS_TEMP_BED, case H_BED: SERIAL_ECHOPGM(STR_HEATER_BED); break) + default: + if (real_heater_id >= 0) + SERIAL_ECHOLNPAIR("E", real_heater_id); + } SERIAL_EOL(); } @@ -1202,6 +1275,10 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { void Temperature::manage_heater() { if (marlin_state == MF_INITIALIZING) return watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! + static bool no_reentry = false; // Prevent recursion + if (no_reentry) return; + REMEMBER(mh, no_reentry, true); + #if ENABLED(EMERGENCY_PARSER) if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true); @@ -1219,8 +1296,12 @@ void Temperature::manage_heater() { 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 (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); + if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); + if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); + #endif + #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC + if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT); + if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT); #endif #endif @@ -1254,16 +1335,16 @@ void Temperature::manage_heater() { } #endif - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - // Make sure measured temperatures are close together - if (ABS(degHotend(0) - degHotendRedundant()) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) - _temp_error(H_E0, PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP)); - #endif - } // HOTEND_LOOP #endif // HAS_HOTEND + #if HAS_TEMP_REDUNDANT + // Make sure measured temperatures are close together + if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF) + _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP)); + #endif + #if HAS_AUTO_FAN if (ELAPSED(ms, next_auto_fan_check_ms)) { // only need to check fan state very infrequently checkExtruderAutoFans(); @@ -1546,7 +1627,7 @@ void Temperature::manage_heater() { #if ENABLED(FLOWMETER_SAFETY) if (cutter.enabled() && cooler.check_flow_too_low()) { cutter.disable(); - ui.flow_fault(); + TERN_(HAS_DISPLAY, ui.flow_fault()); } #endif #endif @@ -1613,13 +1694,19 @@ void Temperature::manage_heater() { { true, 0, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 }, #endif #if TEMP_SENSOR_CHAMBER_IS_CUSTOM - { true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 } + { true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 }, #endif #if TEMP_SENSOR_COOLER_IS_CUSTOM - { true, 0, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 } + { true, 0, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 }, #endif #if TEMP_SENSOR_PROBE_IS_CUSTOM - { true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 } + { true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 }, + #endif + #if TEMP_SENSOR_BOARD_IS_CUSTOM + { true, 0, 0, BOARD_PULLUP_RESISTOR_OHMS, BOARD_RESISTANCE_25C_OHMS, 0, 0, BOARD_BETA, 0 }, + #endif + #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM + { true, 0, 0, REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS, 0, 0, REDUNDANT_BETA, 0 }, #endif }; COPY(user_thermistor, default_user_thermistor); @@ -1653,17 +1740,14 @@ void Temperature::manage_heater() { TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :) TERN_(TEMP_SENSOR_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? PSTR("COOLER") :) TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :) + TERN_(TEMP_SENSOR_BOARD_IS_CUSTOM, t_index == CTI_BOARD ? PSTR("BOARD") :) + TERN_(TEMP_SENSOR_REDUNDANT_IS_CUSTOM, t_index == CTI_REDUNDANT ? PSTR("REDUNDANT") :) nullptr ); SERIAL_EOL(); } 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; - // uint32_t tcnt5 = TCNT5; - //#endif if (!WITHIN(t_index, 0, COUNT(user_thermistor) - 1)) return 25; @@ -1691,14 +1775,6 @@ void Temperature::manage_heater() { value += t.sh_c_coeff * cu(log_resistance); value = 1.0f / value; - //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB) - // int32_t clocks = TCNT5 - tcnt5; - // if (clocks >= 0) { - // clocks_total += clocks; - // calls++; - // } - //#endif - // Return degrees C (up to 999, as the LCD only displays 3 digits) return _MIN(value + THERMISTOR_ABS_ZERO_C, 999); } @@ -1708,7 +1784,7 @@ void Temperature::manage_heater() { // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. 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)) { + if (e >= HOTENDS) { SERIAL_ERROR_START(); SERIAL_ECHO(e); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM); @@ -1721,7 +1797,14 @@ void Temperature::manage_heater() { #if TEMP_SENSOR_0_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_0, raw); #elif TEMP_SENSOR_0_IS_MAX_TC - return TERN(TEMP_SENSOR_0_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25); + #if TEMP_SENSOR_0_IS_MAX31865 + return TERN(LIB_INTERNAL_MAX31865, + max31865_0.temperature((uint16_t)raw), + max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) + ); + #else + return raw * 0.25; + #endif #elif TEMP_SENSOR_0_IS_AD595 return TEMP_AD595(raw); #elif TEMP_SENSOR_0_IS_AD8495 @@ -1733,7 +1816,14 @@ void Temperature::manage_heater() { #if TEMP_SENSOR_1_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_1, raw); #elif TEMP_SENSOR_1_IS_MAX_TC - return TERN(TEMP_SENSOR_1_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25); + #if TEMP_SENSOR_0_IS_MAX31865 + return TERN(LIB_INTERNAL_MAX31865, + max31865_1.temperature((uint16_t)raw), + max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) + ); + #else + return raw * 0.25; + #endif #elif TEMP_SENSOR_1_IS_AD595 return TEMP_AD595(raw); #elif TEMP_SENSOR_1_IS_AD8495 @@ -1886,6 +1976,46 @@ void Temperature::manage_heater() { } #endif // HAS_TEMP_PROBE +#if HAS_TEMP_BOARD + // For motherboard temperature measurement. + celsius_float_t Temperature::analog_to_celsius_board(const int16_t raw) { + #if TEMP_SENSOR_BOARD_IS_CUSTOM + return user_thermistor_to_deg_c(CTI_BOARD, raw); + #elif TEMP_SENSOR_BOARD_IS_THERMISTOR + SCAN_THERMISTOR_TABLE(TEMPTABLE_BOARD, TEMPTABLE_BOARD_LEN); + #elif TEMP_SENSOR_BOARD_IS_AD595 + return TEMP_AD595(raw); + #elif TEMP_SENSOR_BOARD_IS_AD8495 + return TEMP_AD8495(raw); + #else + UNUSED(raw); + return 0; + #endif + } +#endif // HAS_TEMP_BOARD + +#if HAS_TEMP_REDUNDANT + // For redundant temperature measurement. + celsius_float_t Temperature::analog_to_celsius_redundant(const int16_t raw) { + #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM + return user_thermistor_to_deg_c(CTI_REDUNDANT, raw); + #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0) + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature((uint16_t)raw), raw * 0.25); + #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1) + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature((uint16_t)raw), raw * 0.25); + #elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR + SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN); + #elif TEMP_SENSOR_REDUNDANT_IS_AD595 + return TEMP_AD595(raw); + #elif TEMP_SENSOR_REDUNDANT_IS_AD8495 + return TEMP_AD8495(raw); + #else + UNUSED(raw); + return 0; + #endif + } +#endif // HAS_TEMP_REDUNDANT + /** * Convert the raw sensor readings into actual Celsius temperatures and * validate raw temperatures. Bad readings generate min/maxtemp errors. @@ -1903,26 +2033,36 @@ void Temperature::updateTemperaturesFromRawValues() { watchdog_refresh(); // Reset because raw_temps_ready was set by the interrupt TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0)); - TERN_(TEMP_SENSOR_1_IS_MAX_TC, TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, temp_hotend[1]).raw = READ_MAX_TC(1)); + TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1)); + TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE))); + #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_(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_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.raw)); + TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.raw)); TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); #if HAS_HOTEND - static constexpr int8_t temp_dir[] = { - TERN(TEMP_SENSOR_0_IS_MAX_TC, 0, TEMPDIR(0)) + #if TEMP_SENSOR_IS_ANY_MAX_TC(0) + 0 + #else + TEMPDIR(0) + #endif #if HAS_MULTI_HOTEND - , TERN(TEMP_SENSOR_1_IS_MAX_TC, 0, TEMPDIR(1)) + #if TEMP_SENSOR_IS_ANY_MAX_TC(1) + , 0 + #else + , TEMPDIR(1) + #endif #if HOTENDS > 2 #define _TEMPDIR(N) , TEMPDIR(N) REPEAT_S(2, HOTENDS, _TEMPDIR) @@ -1952,57 +2092,29 @@ void Temperature::updateTemperaturesFromRawValues() { #endif // HAS_HOTEND + #define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) #if ENABLED(THERMAL_PROTECTION_BED) - #define BEDCMP(A,B) (TEMPDIR(BED) < 0 ? ((A)<(B)) : ((A)>(B))) - if (BEDCMP(temp_bed.raw, maxtemp_raw_BED)) max_temp_error(H_BED); - if (temp_bed.target > 0 && BEDCMP(mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_BED); + if (TP_CMP(BED, temp_bed.raw, maxtemp_raw_BED)) max_temp_error(H_BED); + if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_BED); #endif #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) - #define CHAMBERCMP(A,B) (TEMPDIR(CHAMBER) < 0 ? ((A)<(B)) : ((A)>(B))) - if (CHAMBERCMP(temp_chamber.raw, maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); - if (temp_chamber.target > 0 && CHAMBERCMP(mintemp_raw_CHAMBER, temp_chamber.raw)) min_temp_error(H_CHAMBER); + if (TP_CMP(CHAMBER, temp_chamber.raw, maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); + if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.raw)) min_temp_error(H_CHAMBER); #endif #if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) - #define COOLERCMP(A,B) (TEMPDIR(COOLER) < 0 ? ((A)<(B)) : ((A)>(B))) - if (cutter.unitPower > 0 && COOLERCMP(temp_cooler.raw, maxtemp_raw_COOLER)) max_temp_error(H_COOLER); - if (COOLERCMP(mintemp_raw_COOLER, temp_cooler.raw)) min_temp_error(H_COOLER); + if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.raw, maxtemp_raw_COOLER)) max_temp_error(H_COOLER); + if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.raw)) min_temp_error(H_COOLER); #endif -} -#if THERMO_SEPARATE_SPI - template SoftSPI SPIclass::softSPI; - SPIclass max_tc_spi; -#endif + #if BOTH(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) + if (TP_CMP(BOARD, temp_board.raw, maxtemp_raw_BOARD)) max_temp_error(H_BOARD); + if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.raw)) min_temp_error(H_BOARD); + #endif + #undef TP_CMP -// Init fans according to whether they're native PWM or Software PWM -#ifdef BOARD_OPENDRAIN_MOSFETS - #define _INIT_SOFT_FAN(P) OUT_WRITE_OD(P, FAN_INVERTING ? LOW : HIGH) -#else - #define _INIT_SOFT_FAN(P) OUT_WRITE(P, FAN_INVERTING ? LOW : HIGH) -#endif -#if ENABLED(FAN_SOFT_PWM) - #define _INIT_FAN_PIN(P) _INIT_SOFT_FAN(P) -#else - #define _INIT_FAN_PIN(P) do{ if (PWM_PIN(P)) SET_PWM(P); else _INIT_SOFT_FAN(P); }while(0) -#endif -#if ENABLED(FAST_PWM_FAN) - #define SET_FAST_PWM_FREQ(P) set_pwm_frequency(P, FAST_PWM_FAN_FREQUENCY) -#else - #define SET_FAST_PWM_FREQ(P) NOOP -#endif -#define INIT_FAN_PIN(P) do{ _INIT_FAN_PIN(P); SET_FAST_PWM_FREQ(P); }while(0) -#if EXTRUDER_AUTO_FAN_SPEED != 255 - #define INIT_E_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) -#else - #define INIT_E_AUTO_FAN_PIN(P) SET_OUTPUT(P) -#endif -#if CHAMBER_AUTO_FAN_SPEED != 255 - #define INIT_CHAMBER_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) -#else - #define INIT_CHAMBER_AUTO_FAN_PIN(P) SET_OUTPUT(P) -#endif +} // Temperature::updateTemperaturesFromRawValues /** * Initialize the temperature manager @@ -2031,42 +2143,53 @@ void Temperature::init() { #endif // Init (and disable) SPI thermocouples - #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) - OUT_WRITE(MAX6675_CS_PIN, HIGH); + #if TEMP_SENSOR_IS_ANY_MAX_TC(0) && PIN_EXISTS(TEMP_0_CS) + OUT_WRITE(TEMP_0_CS_PIN, HIGH); #endif - #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) - OUT_WRITE(MAX6675_CS2_PIN, HIGH); - #endif - #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31855_CS) - OUT_WRITE(MAX31855_CS_PIN, HIGH); - #endif - #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31855_CS2) - OUT_WRITE(MAX31855_CS2_PIN, HIGH); - #endif - #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31865_CS) - OUT_WRITE(MAX31865_CS_PIN, HIGH); - #endif - #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31865_CS2) - OUT_WRITE(MAX31865_CS2_PIN, HIGH); + #if TEMP_SENSOR_IS_ANY_MAX_TC(1) && PIN_EXISTS(TEMP_1_CS) + OUT_WRITE(TEMP_1_CS_PIN, HIGH); #endif - #if HAS_MAX31865_TEMP - TERN_(TEMP_SENSOR_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE - TERN_(TEMP_SENSOR_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); - #endif - #if HAS_MAX31855_TEMP - TERN_(TEMP_SENSOR_0_IS_MAX31855, max31855_0.begin()); - TERN_(TEMP_SENSOR_1_IS_MAX31855, max31855_1.begin()); - #endif - #if HAS_MAX6675_TEMP - TERN_(TEMP_SENSOR_0_IS_MAX6675, max6675_0.begin()); - TERN_(TEMP_SENSOR_1_IS_MAX6675, max6675_1.begin()); + // Setup objects for library-based polling of MAX TCs + #if HAS_MAXTC_LIBRARIES + #define _MAX31865_WIRES(n) MAX31865_##n##WIRE + #define MAX31865_WIRES(n) _MAX31865_WIRES(n) + + #if TEMP_SENSOR_IS_MAX(0, 6675) && HAS_MAX6675_LIBRARY + max6675_0.begin(); + #elif TEMP_SENSOR_IS_MAX(0, 31855) && HAS_MAX31855_LIBRARY + max31855_0.begin(); + #elif TEMP_SENSOR_IS_MAX(0, 31865) + max31865_0.begin( + MAX31865_WIRES(MAX31865_SENSOR_WIRES_0) // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) + ); + #if defined(LIB_INTERNAL_MAX31865) && ENABLED(MAX31865_50HZ_FILTER) + max31865_0.enable50HzFilter(1); + #endif + #endif + + #if TEMP_SENSOR_IS_MAX(1, 6675) && HAS_MAX6675_LIBRARY + max6675_1.begin(); + #elif TEMP_SENSOR_IS_MAX(1, 31855) && HAS_MAX31855_LIBRARY + max31855_1.begin(); + #elif TEMP_SENSOR_IS_MAX(1, 31865) + max31865_1.begin( + MAX31865_WIRES(MAX31865_SENSOR_WIRES_1) // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) + ); + #if defined(LIB_INTERNAL_MAX31865) && ENABLED(MAX31865_50HZ_FILTER) + max31865_1.enable50HzFilter(1); + #endif + #endif + #undef MAX31865_WIRES + #undef _MAX31865_WIRES #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) - #if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER) + #if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER) || _AD(REDUNDANT) MCUCR = _BV(JTD); MCUCR = _BV(JTD); #endif @@ -2074,10 +2197,22 @@ void Temperature::init() { // Thermistor activation by MCU pin #if PIN_EXISTS(TEMP_0_TR_ENABLE) - OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_0_IS_MAX_TC)); + OUT_WRITE(TEMP_0_TR_ENABLE_PIN, + #if TEMP_SENSOR_IS_ANY_MAX_TC(0) + 1 + #else + 0 + #endif + ); #endif #if PIN_EXISTS(TEMP_1_TR_ENABLE) - OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_1_IS_MAX_TC)); + OUT_WRITE(TEMP_1_TR_ENABLE_PIN, + #if TEMP_SENSOR_IS_ANY_MAX_TC(1) + 1 + #else + 0 + #endif + ); #endif #if HAS_HEATER_0 @@ -2087,7 +2222,6 @@ void Temperature::init() { OUT_WRITE(HEATER_0_PIN, HEATER_0_INVERTING); #endif #endif - #if HAS_HEATER_1 OUT_WRITE(HEATER_1_PIN, HEATER_1_INVERTING); #endif @@ -2154,7 +2288,9 @@ void Temperature::init() { INIT_FAN_PIN(CONTROLLER_FAN_PIN); #endif - TERN_(THERMO_SEPARATE_SPI, max_tc_spi.init()); + #if HAS_MAXTC_SW_SPI + max_tc_spi.init(); + #endif HAL_adc_init(); @@ -2206,6 +2342,12 @@ void Temperature::init() { #if HAS_TEMP_ADC_PROBE HAL_ANALOG_SELECT(TEMP_PROBE_PIN); #endif + #if HAS_TEMP_ADC_BOARD + HAL_ANALOG_SELECT(TEMP_BOARD_PIN); + #endif + #if HAS_TEMP_ADC_REDUNDANT + HAL_ANALOG_SELECT(TEMP_REDUNDANT_PIN); + #endif #if ENABLED(FILAMENT_WIDTH_SENSOR) HAL_ANALOG_SELECT(FILWIDTH_PIN); #endif @@ -2250,11 +2392,7 @@ void Temperature::init() { INIT_CHAMBER_AUTO_FAN_PIN(CHAMBER_AUTO_FAN_PIN); #endif - // Wait for temperature measurement to settle - //delay(250); - #if HAS_HOTEND - #define _TEMP_MIN_E(NR) do{ \ const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \ temp_range[NR].mintemp = tmin; \ @@ -2268,7 +2406,7 @@ void Temperature::init() { temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) - #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N## _THERMISTOR_ID && TEMP_SENSOR_ ##N## _THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## _THERMISTOR_ID != 999 && defined(HEATER_##N##_##M##TEMP)) + #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_##N > 0 && TEMP_SENSOR_##N != 998 && TEMP_SENSOR_##N != 999 && defined(HEATER_##N##_##M##TEMP)) #if _MINMAX_TEST(0, MIN) _TEMP_MIN_E(0); @@ -2318,9 +2456,9 @@ void Temperature::init() { #if _MINMAX_TEST(7, MAX) _TEMP_MAX_E(7); #endif - #endif // HAS_HOTEND + // TODO: combine these into the macros above #if HAS_HEATED_BED while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR); while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR); @@ -2335,6 +2473,29 @@ 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 + + #if BOTH(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) + while (analog_to_celsius_board(mintemp_raw_BOARD) < BOARD_MINTEMP) mintemp_raw_BOARD += TEMPDIR(BOARD) * (OVERSAMPLENR); + while (analog_to_celsius_board(maxtemp_raw_BOARD) > BOARD_MAXTEMP) maxtemp_raw_BOARD -= TEMPDIR(BOARD) * (OVERSAMPLENR); + #endif + + #if HAS_TEMP_REDUNDANT + temp_redundant.target = &( + #if REDUNDANT_TEMP_MATCH(TARGET, COOLER) && HAS_TEMP_COOLER + temp_cooler + #elif REDUNDANT_TEMP_MATCH(TARGET, PROBE) && HAS_TEMP_PROBE + temp_probe + #elif REDUNDANT_TEMP_MATCH(TARGET, BOARD) && HAS_TEMP_BOARD + temp_board + #elif REDUNDANT_TEMP_MATCH(TARGET, CHAMBER) && HAS_TEMP_CHAMBER + temp_chamber + #elif REDUNDANT_TEMP_MATCH(TARGET, BED) && HAS_TEMP_BED + temp_bed + #else + temp_hotend[HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET)] + #endif + ); + #endif } #if HAS_THERMAL_PROTECTION @@ -2373,7 +2534,7 @@ void Temperature::init() { , " ; Idle Timeout:", heater_idle[idle_index].timed_out #endif ); - //*/ + */ #if HEATER_IDLE_HANDLER // If the heater idle timeout expires, restart @@ -2436,9 +2597,8 @@ void Temperature::init() { void Temperature::disable_all_heaters() { + // Disable autotemp, unpause and reset everything TERN_(AUTOTEMP, planner.autotemp_enabled = false); - - // Unpause and reset everything TERN_(PROBING_HEATERS_OFF, pause_heaters(false)); #if HAS_HOTEND @@ -2474,8 +2634,6 @@ void Temperature::disable_all_heaters() { #if ENABLED(PRINTJOB_TIMER_AUTOSTART) - #include "printcounter.h" - bool Temperature::auto_job_over_threshold() { #if HAS_HOTEND HOTEND_LOOP() if (degTargetHotend(e) > (EXTRUDE_MINTEMP) / 2) return true; @@ -2494,7 +2652,7 @@ void Temperature::disable_all_heaters() { } } -#endif +#endif // PRINTJOB_TIMER_AUTOSTART #if ENABLED(PROBING_HEATERS_OFF) @@ -2532,7 +2690,7 @@ void Temperature::disable_all_heaters() { #endif } -#endif +#endif // SINGLENOZZLE_STANDBY_TEMP || SINGLENOZZLE_STANDBY_FAN #if HAS_MAX_TC @@ -2540,113 +2698,114 @@ void Temperature::disable_all_heaters() { #define THERMOCOUPLE_MAX_ERRORS 15 #endif - int Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { - #define MAX6675_HEAT_INTERVAL 250UL + /** + * @brief Read MAX Thermocouple temperature. + * + * Reads the thermocouple board via HW or SW SPI, using a library (LIB_USR_x) or raw SPI reads. + * Doesn't strictly return a temperature; returns an "ADC Value" (i.e. raw register content). + * + * @param hindex the hotend we're referencing (if MULTI_MAX_TC) + * @return integer representing the board's buffer, to be converted later if needed + */ + int16_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { + #define MAXTC_HEAT_INTERVAL 250UL - #if HAS_MAX31855_TEMP - static uint32_t max_tc_temp = 2000; - #define MAX_TC_ERROR_MASK 7 - #define MAX_TC_DISCARD_BITS 18 - #define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 - #elif HAS_MAX31865_TEMP - static uint16_t max_tc_temp = 2000; // From datasheet 16 bits D15-D0 - #define MAX_TC_ERROR_MASK 1 // D0 Bit not used + #if HAS_MAX31855 + #define MAX_TC_ERROR_MASK 7 // D2-0: SCV, SCG, OC + #define MAX_TC_DISCARD_BITS 18 // Data D31-18; sign bit D31 + #define MAX_TC_SPEED_BITS 3 // ~1MHz + #elif HAS_MAX31865 + #define MAX_TC_ERROR_MASK 1 // D0 Bit on fault only #define MAX_TC_DISCARD_BITS 1 // Data is in D15-D1 - #define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 - #else - static uint16_t max_tc_temp = 2000; - #define MAX_TC_ERROR_MASK 4 - #define MAX_TC_DISCARD_BITS 3 - #define MAX_TC_SPEED_BITS 2 // (_BV(SPR0)) // clock ÷ 16 + #define MAX_TC_SPEED_BITS 3 // ~1MHz + #else // MAX6675 + #define MAX_TC_ERROR_MASK 3 // D2 only; 1 = open circuit + #define MAX_TC_DISCARD_BITS 3 // Data D15-D1 + #define MAX_TC_SPEED_BITS 2 // ~2MHz #endif #if HAS_MULTI_MAX_TC // Needed to return the correct temp when this is called between readings - static celsius_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; + static int16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; #define THERMO_TEMP(I) max_tc_temp_previous[I] #define THERMO_SEL(A,B) (hindex ? (B) : (A)) - #define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0) - #define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0) + #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) #else + // When we have only 1 max tc, THERMO_SEL will pick the appropriate sensor + // variable, and MAXTC_*() macros will be hardcoded to the correct CS pin. constexpr uint8_t hindex = 0; #define THERMO_TEMP(I) max_tc_temp - #if TEMP_SENSOR_1_IS_MAX31865 - #define THERMO_SEL(A,B) B - #else + #if TEMP_SENSOR_IS_ANY_MAX_TC(0) #define THERMO_SEL(A,B) A - #endif - #if TEMP_SENSOR_0_IS_MAX6675 - #define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V) - #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN) + #define MAXTC_CS_WRITE(V) WRITE(TEMP_0_CS_PIN, V) #else - #define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V) - #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN) + #define THERMO_SEL(A,B) B + #define MAXTC_CS_WRITE(V) WRITE(TEMP_1_CS_PIN, V) #endif - #endif + static TERN(HAS_MAX31855, uint32_t, uint16_t) max_tc_temp = THERMO_SEL( + TEMP_SENSOR_0_MAX_TC_TMAX, + TEMP_SENSOR_1_MAX_TC_TMAX + ); + static uint8_t max_tc_errors[MAX_TC_COUNT] = { 0 }; + static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 }; // Return last-read value between readings - static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 }; millis_t ms = millis(); - if (PENDING(ms, next_max_tc_ms[hindex])) return int(THERMO_TEMP(hindex)); - next_max_tc_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; + if (PENDING(ms, next_max_tc_ms[hindex])) + return (int16_t)THERMO_TEMP(hindex); - // - // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. - // - #if !THERMO_SEPARATE_SPI && NO_THERMO_TEMPS - spiBegin(); - spiInit(MAX_TC_SPEED_BITS); - #endif + next_max_tc_ms[hindex] = ms + MAXTC_HEAT_INTERVAL; - #if NO_THERMO_TEMPS - MAX6675_WRITE(LOW); // enable TT_MAX6675 - DELAY_NS(100); // Ensure 100ns delay - #endif + #if !HAS_MAXTC_LIBRARIES + max_tc_temp = 0; - max_tc_temp = 0; + #if !HAS_MAXTC_SW_SPI + // Initialize SPI using the default Hardware SPI bus. + // FIXME: spiBegin, spiRec and spiInit doesn't work when soft spi is used. + spiBegin(); + spiInit(MAX_TC_SPEED_BITS); + #endif - // Read a big-endian temperature value - #if NO_THERMO_TEMPS + MAXTC_CS_WRITE(LOW); // enable MAXTC + DELAY_NS(100); // Ensure 100ns delay + + // Read a big-endian temperature value without using a library for (uint8_t i = sizeof(max_tc_temp); i--;) { - max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max_tc_spi.receive(), spiRec()); + max_tc_temp |= TERN(HAS_MAXTC_SW_SPI, max_tc_spi.receive(), spiRec()); if (i > 0) max_tc_temp <<= 8; // shift left if not the last byte } - MAX6675_WRITE(HIGH); // disable TT_MAX6675 - #endif - #if HAS_MAX31855_TEMP - Adafruit_MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1); - max_tc_temp = max855ref.readRaw32(); - #endif + MAXTC_CS_WRITE(HIGH); // disable MAXTC + #else + #if HAS_MAX6675_LIBRARY + MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1); + max_tc_temp = max6675ref.readRaw16(); + #endif - #if HAS_MAX31865_TEMP - Adafruit_MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1); - #if ENABLED(LIB_USR_MAX31865) - max_tc_temp = max865ref.readRTD_with_Fault(); + #if HAS_MAX31855_LIBRARY + MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1); + max_tc_temp = max855ref.readRaw32(); + #endif + + #if HAS_MAX31865 + MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1); + max_tc_temp = TERN(LIB_INTERNAL_MAX31865, max865ref.readRaw(), max865ref.readRTD_with_Fault()); #endif #endif - #if HAS_MAX6675_TEMP - MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1); - max_tc_temp = max6675ref.readRaw16(); - #endif - - #if ENABLED(LIB_ADAFRUIT_MAX31865) - const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; - #endif - - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) - && TERN(LIB_ADAFRUIT_MAX31865, fault_31865, (max_tc_temp & MAX_TC_ERROR_MASK)) - ) { + // Handle an error. If there have been more than THERMOCOUPLE_MAX_ERRORS, send an error over serial. + // Either way, return the TMAX for the thermocouple to trigger a max_temp_error() + if (max_tc_temp & MAX_TC_ERROR_MASK) { max_tc_errors[hindex]++; + if (max_tc_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { SERIAL_ERROR_START(); SERIAL_ECHOPGM("Temp measurement error! "); - #if MAX_TC_ERROR_MASK == 7 - SERIAL_ECHOPGM("MAX31855 Fault : (", max_tc_temp & 0x7, ") >> "); + #if HAS_MAX31855 + SERIAL_ECHOPAIR("MAX31855 Fault: (", max_tc_temp & 0x7, ") >> "); if (max_tc_temp & 0x1) SERIAL_ECHOLNPGM("Open Circuit"); else if (max_tc_temp & 0x2) @@ -2654,59 +2813,46 @@ void Temperature::disable_all_heaters() { else if (max_tc_temp & 0x4) SERIAL_ECHOLNPGM("Short to VCC"); #elif HAS_MAX31865 - #if ENABLED(LIB_USR_MAX31865) - // At the present time we do not have the ability to set the MAX31865 HIGH threshold - // or thr LOW threshold, so no need to check for them, zero these bits out - const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; - #endif + const uint8_t fault_31865 = max865ref.readFault(); max865ref.clearFault(); if (fault_31865) { SERIAL_EOL(); - SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); + SERIAL_ECHOLNPAIR("\nMAX31865 Fault: (", fault_31865, ") >>"); if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) SERIAL_ECHOLNPGM("RTD High Threshold"); if (fault_31865 & MAX31865_FAULT_LOWTHRESH) SERIAL_ECHOLNPGM("RTD Low Threshold"); if (fault_31865 & MAX31865_FAULT_REFINLOW) - SERIAL_ECHOLNPGM("REFIN- > 0.85 x Bias"); + SERIAL_ECHOLNPGM("REFIN- > 0.85 x V bias"); if (fault_31865 & MAX31865_FAULT_REFINHIGH) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + SERIAL_ECHOLNPGM("REFIN- < 0.85 x V bias (FORCE- open)"); if (fault_31865 & MAX31865_FAULT_RTDINLOW) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + SERIAL_ECHOLNPGM("REFIN- < 0.85 x V bias (FORCE- open)"); if (fault_31865 & MAX31865_FAULT_OVUV) SERIAL_ECHOLNPGM("Under/Over voltage"); } - #else - SERIAL_ECHOLNPGM("MAX6675 Open Circuit"); + #else // MAX6675 + SERIAL_ECHOLNPGM("MAX6675 Fault: Open Circuit"); #endif - // Thermocouple open - max_tc_temp = 4 * THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX); + // Set thermocouple above max temperature (TMAX) + max_tc_temp = THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX) << (MAX_TC_DISCARD_BITS + 1); } - else - max_tc_temp >>= MAX_TC_DISCARD_BITS; } else { - max_tc_temp >>= MAX_TC_DISCARD_BITS; - max_tc_errors[hindex] = 0; + max_tc_errors[hindex] = 0; // No error bit, reset error count } - #if HAS_MAX31855 - if (max_tc_temp & 0x00002000) max_tc_temp |= 0xFFFFC000; // Support negative temperature - #endif + max_tc_temp >>= MAX_TC_DISCARD_BITS; - // Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES - #if HAS_MAX31865_TEMP - #if ENABLED(LIB_ADAFRUIT_MAX31865) - max_tc_temp = (uint32_t(max865ref.readRTD()) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; - #elif ENABLED(LIB_USR_MAX31865) - max_tc_temp = (uint32_t(max_tc_temp) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; - #endif + #if HAS_MAX31855 + // Support negative temperature for MAX38155 + if (max_tc_temp & 0x00002000) max_tc_temp |= 0xFFFFC000; #endif THERMO_TEMP(hindex) = max_tc_temp; - return int(max_tc_temp); + return (int16_t)max_tc_temp; } #endif // HAS_MAX_TC @@ -2719,28 +2865,30 @@ void Temperature::disable_all_heaters() { */ void Temperature::update_raw_temperatures() { + // TODO: can this be collapsed into a HOTEND_LOOP()? #if HAS_TEMP_ADC_0 && !TEMP_SENSOR_0_IS_MAX_TC temp_hotend[0].update(); #endif - #if HAS_TEMP_ADC_1 - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - temp_redundant.update(); - #elif !TEMP_SENSOR_1_IS_MAX_TC - temp_hotend[1].update(); - #endif + #if HAS_TEMP_ADC_1 && !TEMP_SENSOR_1_IS_MAX_TC + temp_hotend[1].update(); #endif - TERN_(HAS_TEMP_ADC_2, temp_hotend[2].update()); - TERN_(HAS_TEMP_ADC_3, temp_hotend[3].update()); - TERN_(HAS_TEMP_ADC_4, temp_hotend[4].update()); - TERN_(HAS_TEMP_ADC_5, temp_hotend[5].update()); - TERN_(HAS_TEMP_ADC_6, temp_hotend[6].update()); - TERN_(HAS_TEMP_ADC_7, temp_hotend[7].update()); - TERN_(HAS_TEMP_ADC_BED, temp_bed.update()); + #if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_REDUNDANT_IS_MAX_TC + temp_redundant.update(); + #endif + + TERN_(HAS_TEMP_ADC_2, temp_hotend[2].update()); + TERN_(HAS_TEMP_ADC_3, temp_hotend[3].update()); + TERN_(HAS_TEMP_ADC_4, temp_hotend[4].update()); + TERN_(HAS_TEMP_ADC_5, temp_hotend[5].update()); + TERN_(HAS_TEMP_ADC_6, temp_hotend[6].update()); + TERN_(HAS_TEMP_ADC_7, temp_hotend[7].update()); + TERN_(HAS_TEMP_ADC_BED, temp_bed.update()); TERN_(HAS_TEMP_ADC_CHAMBER, temp_chamber.update()); - TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update()); - TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update()); + TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update()); + TERN_(HAS_TEMP_ADC_BOARD, temp_board.update()); + TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update()); TERN_(HAS_JOY_ADC_X, joystick.x.update()); TERN_(HAS_JOY_ADC_Y, joystick.y.update()); @@ -2764,13 +2912,14 @@ void Temperature::readings_ready() { #if HAS_HOTEND HOTEND_LOOP() temp_hotend[e].reset(); - TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant.reset()); #endif - TERN_(HAS_HEATED_BED, temp_bed.reset()); - TERN_(HAS_TEMP_CHAMBER, temp_chamber.reset()); - TERN_(HAS_TEMP_PROBE, temp_probe.reset()); - TERN_(HAS_TEMP_COOLER, temp_cooler.reset()); + TERN_(HAS_HEATED_BED, temp_bed.reset()); + TERN_(HAS_TEMP_CHAMBER, temp_chamber.reset()); + TERN_(HAS_TEMP_PROBE, temp_probe.reset()); + TERN_(HAS_TEMP_COOLER, temp_cooler.reset()); + TERN_(HAS_TEMP_BOARD, temp_board.reset()); + TERN_(HAS_TEMP_REDUNDANT, temp_redundant.reset()); TERN_(HAS_JOY_ADC_X, joystick.x.reset()); TERN_(HAS_JOY_ADC_Y, joystick.y.reset()); @@ -3196,9 +3345,19 @@ void Temperature::isr() { case MeasureTemp_PROBE: ACCUMULATE_ADC(temp_probe); break; #endif + #if HAS_TEMP_ADC_BOARD + case PrepareTemp_BOARD: HAL_START_ADC(TEMP_BOARD_PIN); break; + case MeasureTemp_BOARD: ACCUMULATE_ADC(temp_board); break; + #endif + + #if HAS_TEMP_ADC_REDUNDANT + case PrepareTemp_REDUNDANT: HAL_START_ADC(TEMP_REDUNDANT_PIN); break; + case MeasureTemp_REDUNDANT: ACCUMULATE_ADC(temp_redundant); break; + #endif + #if HAS_TEMP_ADC_1 case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break; - case MeasureTemp_1: ACCUMULATE_ADC(TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, temp_hotend[1])); break; + case MeasureTemp_1: ACCUMULATE_ADC(temp_hotend[1]); break; #endif #if HAS_TEMP_ADC_2 @@ -3332,6 +3491,7 @@ void Temperature::isr() { * Chamber: " C:nnn.nn /nnn.nn" * Probe: " P:nnn.nn /nnn.nn" * Cooler: " L:nnn.nn /nnn.nn" + * Redundant: " R:nnn.nn /nnn.nn" * Extruder: " T0:nnn.nn /nnn.nn" * With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)" */ @@ -3356,7 +3516,10 @@ void Temperature::isr() { #if HAS_TEMP_COOLER case H_COOLER: k = 'L'; break; #endif - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + #if HAS_TEMP_BOARD + case H_BOARD: k = 'M'; break; + #endif + #if HAS_TEMP_REDUNDANT case H_REDUNDANT: k = 'R'; break; #endif } @@ -3375,20 +3538,17 @@ void Temperature::isr() { SERIAL_PRINT(t, SFP); #if ENABLED(SHOW_TEMP_ADC_VALUES) // Temperature MAX SPI boards do not have an OVERSAMPLENR defined - SERIAL_ECHOPAIR(" (", TERN(NO_THERMO_TEMPS, false, k == 'T') ? r : r * RECIPROCAL(OVERSAMPLENR)); + SERIAL_ECHOPAIR(" (", TERN(HAS_MAXTC_LIBRARIES, k == 'T', false) ? r : r * RECIPROCAL(OVERSAMPLENR)); SERIAL_CHAR(')'); #endif delay(2); } void Temperature::print_heater_states(const uint8_t target_extruder - OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r/*=false*/) + OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/) ) { #if HAS_TEMP_HOTEND - print_heater_state(H_NONE, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder))); - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - if (include_r) print_heater_state(H_REDUNDANT, degHotendRedundant(), degTargetHotend(0) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTempRedundant())); - #endif + print_heater_state(H_E0, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder))); #endif #if HAS_HEATED_BED print_heater_state(H_BED, degBed(), degTargetBed() OPTARG(SHOW_TEMP_ADC_VALUES, rawBedTemp())); @@ -3400,7 +3560,13 @@ void Temperature::isr() { print_heater_state(H_COOLER, degCooler(), TERN0(HAS_COOLER, degTargetCooler()) OPTARG(SHOW_TEMP_ADC_VALUES, rawCoolerTemp())); #endif #if HAS_TEMP_PROBE - print_heater_state(H_PROBE, degProbe(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawProbeTemp()) ); + print_heater_state(H_PROBE, degProbe(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawProbeTemp())); + #endif + #if HAS_TEMP_BOARD + print_heater_state(H_BOARD, degBoard(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawBoardTemp())); + #endif + #if HAS_TEMP_REDUNDANT + if (include_r) print_heater_state(H_REDUNDANT, degRedundant(), degRedundantTarget() OPTARG(SHOW_TEMP_ADC_VALUES, rawRedundantTemp())); #endif #if HAS_MULTI_HOTEND HOTEND_LOOP() print_heater_state((heater_id_t)e, degHotend(e), degTargetHotend(e) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(e))); @@ -3548,7 +3714,7 @@ void Temperature::isr() { #if G26_CLICK_CAN_CANCEL if (click_to_cancel && ui.use_click()) { wait_for_heatup = false; - ui.quick_feedback(); + TERN_(HAS_LCD_MENU, ui.quick_feedback()); } #endif @@ -3682,7 +3848,7 @@ void Temperature::isr() { #if G26_CLICK_CAN_CANCEL if (click_to_cancel && ui.use_click()) { wait_for_heatup = false; - ui.quick_feedback(); + TERN_(HAS_LCD_MENU, ui.quick_feedback()); } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 660fde8af6..c78dfa9372 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -46,9 +46,13 @@ // Element identifiers. Positive values are hotends. Negative values are other heaters or coolers. typedef enum : int8_t { - H_NONE = -6, - H_COOLER, H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED, - H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7 + H_REDUNDANT = HID_REDUNDANT, + H_COOLER = HID_COOLER, + H_PROBE = HID_PROBE, + H_BOARD = HID_BOARD, + H_CHAMBER = HID_CHAMBER, + H_BED = HID_BED, + H_E0 = HID_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7 } heater_id_t; // PID storage @@ -105,6 +109,12 @@ enum ADCSensorState : char { #if HAS_TEMP_ADC_PROBE PrepareTemp_PROBE, MeasureTemp_PROBE, #endif + #if HAS_TEMP_ADC_BOARD + PrepareTemp_BOARD, MeasureTemp_BOARD, + #endif + #if HAS_TEMP_ADC_REDUNDANT + PrepareTemp_REDUNDANT, MeasureTemp_REDUNDANT, + #endif #if HAS_TEMP_ADC_1 PrepareTemp_1, MeasureTemp_1, #endif @@ -171,7 +181,7 @@ enum ADCSensorState : char { #define unscalePID_d(d) ( float(d) * PID_dT ) #endif -#if BOTH(HAS_LCD_MENU, G26_MESH_VALIDATION) +#if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) #define G26_CLICK_CAN_CANCEL 1 #endif @@ -185,6 +195,13 @@ typedef struct TempInfo { inline void update() { raw = acc; } } temp_info_t; +#if HAS_TEMP_REDUNDANT + // A redundant temperature sensor + typedef struct RedundantTempInfo : public TempInfo { + temp_info_t* target; + } redundant_info_t; +#endif + // A PWM heater with temperature sensor typedef struct HeaterInfo : public TempInfo { celsius_t target; @@ -221,6 +238,9 @@ struct PIDHeaterInfo : public HeaterInfo { #elif HAS_TEMP_CHAMBER typedef temp_info_t chamber_info_t; #endif +#if HAS_TEMP_BOARD + typedef temp_info_t board_info_t; +#endif #if EITHER(HAS_COOLER, HAS_TEMP_COOLER) typedef heater_info_t cooler_info_t; #endif @@ -299,9 +319,15 @@ typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_ra #if TEMP_SENSOR_CHAMBER_IS_CUSTOM CTI_CHAMBER, #endif - #if COOLER_USER_THERMISTOR + #if TEMP_SENSOR_COOLER_IS_CUSTOM CTI_COOLER, #endif + #if TEMP_SENSOR_BOARD_IS_CUSTOM + CTI_BOARD, + #endif + #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM + CTI_REDUNDANT, + #endif USER_THERMISTORS }; @@ -323,25 +349,28 @@ class Temperature { public: #if HAS_HOTEND - #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 - #if ENABLED(HAS_HEATED_BED) + #if HAS_HEATED_BED static bed_info_t temp_bed; #endif - #if ENABLED(HAS_TEMP_PROBE) + #if HAS_TEMP_PROBE static probe_info_t temp_probe; #endif - #if ENABLED(HAS_TEMP_CHAMBER) + #if HAS_TEMP_CHAMBER static chamber_info_t temp_chamber; #endif - #if ENABLED(HAS_TEMP_COOLER) + #if HAS_TEMP_COOLER static cooler_info_t temp_cooler; #endif + #if HAS_TEMP_BOARD + static board_info_t temp_board; + #endif + #if HAS_TEMP_REDUNDANT + static redundant_info_t temp_redundant; + #endif #if ENABLED(AUTO_POWER_E_FANS) static uint8_t autofan_speed[HOTENDS]; @@ -415,6 +444,15 @@ class Temperature { static heater_idle_t heater_idle[NR_HEATER_IDLE]; + #endif // HEATER_IDLE_TIMER + + #if HAS_ADC_BUTTONS + static uint32_t current_ADCKey_raw; + static uint16_t ADCKey_count; + #endif + + #if ENABLED(PID_EXTRUSION_SCALING) + static int16_t lpq_len; #endif private: @@ -428,7 +466,7 @@ class Temperature { static lpq_ptr_t lpq_ptr; #endif - #if ENABLED(HAS_HOTEND) + #if HAS_HOTEND static temp_range_t temp_range[HOTENDS]; #endif @@ -456,6 +494,10 @@ class Temperature { static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER; #endif + #if HAS_TEMP_BOARD && ENABLED(THERMAL_PROTECTION_BOARD) + static int16_t mintemp_raw_BOARD, maxtemp_raw_BOARD; + #endif + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 static uint8_t consecutive_low_temperature_error[HOTENDS]; #endif @@ -464,7 +506,7 @@ class Temperature { static millis_t preheat_end_time[HOTENDS]; #endif - #if ENABLED(HAS_AUTO_FAN) + #if HAS_AUTO_FAN static millis_t next_auto_fan_check_ms; #endif @@ -473,15 +515,6 @@ class Temperature { #endif public: - #if HAS_ADC_BUTTONS - static uint32_t current_ADCKey_raw; - static uint16_t ADCKey_count; - #endif - - #if ENABLED(PID_EXTRUSION_SCALING) - static int16_t lpq_len; - #endif - /** * Instance Methods */ @@ -538,6 +571,12 @@ class Temperature { #if HAS_TEMP_COOLER static celsius_float_t analog_to_celsius_cooler(const int16_t raw); #endif + #if HAS_TEMP_BOARD + static celsius_float_t analog_to_celsius_board(const int16_t raw); + #endif + #if HAS_TEMP_REDUNDANT + static celsius_float_t analog_to_celsius_redundant(const int16_t raw); + #endif #if HAS_FAN @@ -626,10 +665,6 @@ 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)); } @@ -638,9 +673,6 @@ 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) { @@ -778,6 +810,25 @@ class Temperature { #endif #endif + #if HAS_TEMP_BOARD + #if ENABLED(SHOW_TEMP_ADC_VALUES) + static inline int16_t rawBoardTemp() { return temp_board.raw; } + #endif + static inline celsius_float_t degBoard() { return temp_board.celsius; } + static inline celsius_t wholeDegBoard() { return static_cast(temp_board.celsius + 0.5f); } + #endif + + #if HAS_TEMP_REDUNDANT + #if ENABLED(SHOW_TEMP_ADC_VALUES) + static inline int16_t rawRedundantTemp() { return temp_redundant.raw; } + static inline int16_t rawRedundanTargetTemp() { return (*temp_redundant.target).raw; } + #endif + static inline celsius_float_t degRedundant() { return temp_redundant.celsius; } + static inline celsius_float_t degRedundantTarget() { return (*temp_redundant.target).celsius; } + static inline celsius_t wholeDegRedundant() { return static_cast(temp_redundant.celsius + 0.5f); } + static inline celsius_t wholeDegRedundantTarget() { return static_cast((*temp_redundant.target).celsius + 0.5f); } + #endif + #if HAS_COOLER static inline void setTargetCooler(const celsius_t celsius) { temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET); @@ -855,7 +906,7 @@ class Temperature { #if HAS_TEMP_SENSOR static void print_heater_states(const uint8_t target_extruder - OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r=false) + OPTARG(HAS_TEMP_REDUNDANT, const bool include_r=false) ); #if ENABLED(AUTO_REPORT_TEMPERATURES) struct AutoReportTemp { static void report(); }; @@ -888,19 +939,19 @@ class Temperature { // MAX Thermocouples #if HAS_MAX_TC - #define MAX_TC_COUNT 1 + BOTH(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC) + #define MAX_TC_COUNT COUNT_ENABLED(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC, TEMP_SENSOR_REDUNDANT_IS_MAX_TC) #if MAX_TC_COUNT > 1 #define HAS_MULTI_MAX_TC 1 #define READ_MAX_TC(N) read_max_tc(N) #else #define READ_MAX_TC(N) read_max_tc() #endif - static int read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); + static int16_t read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); #endif static void checkExtruderAutoFans(); - #if ENABLED(HAS_HOTEND) + #if HAS_HOTEND static float get_pid_output_hotend(const uint8_t e); #endif #if ENABLED(PIDTEMPBED) diff --git a/Marlin/src/module/thermistor/thermistor_1.h b/Marlin/src/module/thermistor/thermistor_1.h index fad7908375..2ebf8da550 100644 --- a/Marlin/src/module/thermistor/thermistor_1.h +++ b/Marlin/src/module/thermistor/thermistor_1.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor -const temp_entry_t temptable_1[] PROGMEM = { +constexpr temp_entry_t temptable_1[] PROGMEM = { { OV( 23), 300 }, { OV( 25), 295 }, { OV( 27), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_10.h b/Marlin/src/module/thermistor/thermistor_10.h index c24ad40bf4..9f2285c3fd 100644 --- a/Marlin/src/module/thermistor/thermistor_10.h +++ b/Marlin/src/module/thermistor/thermistor_10.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3960 K, 4.7 kOhm pull-up, RS thermistor 198-961 -const temp_entry_t temptable_10[] PROGMEM = { +constexpr temp_entry_t temptable_10[] PROGMEM = { { OV( 1), 929 }, { OV( 36), 299 }, { OV( 71), 246 }, diff --git a/Marlin/src/module/thermistor/thermistor_1010.h b/Marlin/src/module/thermistor/thermistor_1010.h index 8ab5e3b364..6f2e3ab318 100644 --- a/Marlin/src/module/thermistor/thermistor_1010.h +++ b/Marlin/src/module/thermistor/thermistor_1010.h @@ -24,7 +24,7 @@ #define REVERSE_TEMP_SENSOR_RANGE_1010 1 // Pt1000 with 1k0 pullup -const temp_entry_t temptable_1010[] PROGMEM = { +constexpr temp_entry_t temptable_1010[] PROGMEM = { PtLine( 0, 1000, 1000), PtLine( 25, 1000, 1000), PtLine( 50, 1000, 1000), diff --git a/Marlin/src/module/thermistor/thermistor_1047.h b/Marlin/src/module/thermistor/thermistor_1047.h index 6e1b61f9d0..fb901d0a8d 100644 --- a/Marlin/src/module/thermistor/thermistor_1047.h +++ b/Marlin/src/module/thermistor/thermistor_1047.h @@ -24,7 +24,7 @@ #define REVERSE_TEMP_SENSOR_RANGE_1047 1 // Pt1000 with 4k7 pullup -const temp_entry_t temptable_1047[] PROGMEM = { +constexpr temp_entry_t temptable_1047[] PROGMEM = { // only a few values are needed as the curve is very flat PtLine( 0, 1000, 4700), PtLine( 50, 1000, 4700), diff --git a/Marlin/src/module/thermistor/thermistor_11.h b/Marlin/src/module/thermistor/thermistor_11.h index 345d009a64..52f89814e7 100644 --- a/Marlin/src/module/thermistor/thermistor_11.h +++ b/Marlin/src/module/thermistor/thermistor_11.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3950 K, 4.7 kOhm pull-up, QU-BD silicone bed QWG-104F-3950 thermistor -const temp_entry_t temptable_11[] PROGMEM = { +constexpr temp_entry_t temptable_11[] PROGMEM = { { OV( 1), 938 }, { OV( 31), 314 }, { OV( 41), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_110.h b/Marlin/src/module/thermistor/thermistor_110.h index 215495e2c6..5d76d1ee1b 100644 --- a/Marlin/src/module/thermistor/thermistor_110.h +++ b/Marlin/src/module/thermistor/thermistor_110.h @@ -24,7 +24,7 @@ #define REVERSE_TEMP_SENSOR_RANGE_110 1 // Pt100 with 1k0 pullup -const temp_entry_t temptable_110[] PROGMEM = { +constexpr temp_entry_t temptable_110[] PROGMEM = { // only a few values are needed as the curve is very flat PtLine( 0, 100, 1000), PtLine( 50, 100, 1000), diff --git a/Marlin/src/module/thermistor/thermistor_12.h b/Marlin/src/module/thermistor/thermistor_12.h index d1ee23b2b7..c0cbd254cf 100644 --- a/Marlin/src/module/thermistor/thermistor_12.h +++ b/Marlin/src/module/thermistor/thermistor_12.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4700 K, 4.7 kOhm pull-up, (personal calibration for Makibox hot bed) -const temp_entry_t temptable_12[] PROGMEM = { +constexpr temp_entry_t temptable_12[] PROGMEM = { { OV( 35), 180 }, // top rating 180C { OV( 211), 140 }, { OV( 233), 135 }, diff --git a/Marlin/src/module/thermistor/thermistor_13.h b/Marlin/src/module/thermistor/thermistor_13.h index bb622240c8..7e87373948 100644 --- a/Marlin/src/module/thermistor/thermistor_13.h +++ b/Marlin/src/module/thermistor/thermistor_13.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4100 K, 4.7 kOhm pull-up, Hisens thermistor -const temp_entry_t temptable_13[] PROGMEM = { +constexpr temp_entry_t temptable_13[] PROGMEM = { { OV( 20.04), 300 }, { OV( 23.19), 290 }, { OV( 26.71), 280 }, diff --git a/Marlin/src/module/thermistor/thermistor_147.h b/Marlin/src/module/thermistor/thermistor_147.h index 6d846ad5be..542e4844ec 100644 --- a/Marlin/src/module/thermistor/thermistor_147.h +++ b/Marlin/src/module/thermistor/thermistor_147.h @@ -24,7 +24,7 @@ #define REVERSE_TEMP_SENSOR_RANGE_147 1 // Pt100 with 4k7 pullup -const temp_entry_t temptable_147[] PROGMEM = { +constexpr temp_entry_t temptable_147[] PROGMEM = { // only a few values are needed as the curve is very flat PtLine( 0, 100, 4700), PtLine( 50, 100, 4700), diff --git a/Marlin/src/module/thermistor/thermistor_15.h b/Marlin/src/module/thermistor/thermistor_15.h index 46dcce8c1e..ce98248793 100644 --- a/Marlin/src/module/thermistor/thermistor_15.h +++ b/Marlin/src/module/thermistor/thermistor_15.h @@ -22,7 +22,7 @@ #pragma once // 100k bed thermistor in JGAurora A5. Calibrated by Sam Pinches 21st Jan 2018 using cheap k-type thermocouple inserted into heater block, using TM-902C meter. -const temp_entry_t temptable_15[] PROGMEM = { +constexpr temp_entry_t temptable_15[] PROGMEM = { { OV( 31), 275 }, { OV( 33), 270 }, { OV( 35), 260 }, diff --git a/Marlin/src/module/thermistor/thermistor_17.h b/Marlin/src/module/thermistor/thermistor_17.h index 32b5bb77a8..55d3bc39d0 100644 --- a/Marlin/src/module/thermistor/thermistor_17.h +++ b/Marlin/src/module/thermistor/thermistor_17.h @@ -22,7 +22,7 @@ #pragma once // Dagoma NTC 100k white thermistor -const temp_entry_t temptable_17[] PROGMEM = { +constexpr temp_entry_t temptable_17[] PROGMEM = { { OV( 16), 309 }, { OV( 18), 307 }, { OV( 20), 300 }, diff --git a/Marlin/src/module/thermistor/thermistor_18.h b/Marlin/src/module/thermistor/thermistor_18.h index 9c2d81b3e6..061cf78129 100644 --- a/Marlin/src/module/thermistor/thermistor_18.h +++ b/Marlin/src/module/thermistor/thermistor_18.h @@ -22,7 +22,7 @@ #pragma once // ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327 - version (measured/tested/approved) -const temp_entry_t temptable_18[] PROGMEM = { +constexpr temp_entry_t temptable_18[] PROGMEM = { { OV( 1), 713 }, { OV( 17), 284 }, { OV( 20), 275 }, diff --git a/Marlin/src/module/thermistor/thermistor_2.h b/Marlin/src/module/thermistor/thermistor_2.h index d0e1e4f3df..a899fd17ee 100644 --- a/Marlin/src/module/thermistor/thermistor_2.h +++ b/Marlin/src/module/thermistor/thermistor_2.h @@ -26,7 +26,7 @@ // Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance // -const temp_entry_t temptable_2[] PROGMEM = { +constexpr temp_entry_t temptable_2[] PROGMEM = { { OV( 1), 848 }, { OV( 30), 300 }, // top rating 300C { OV( 34), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_20.h b/Marlin/src/module/thermistor/thermistor_20.h index 73094f1460..a8267e93e4 100644 --- a/Marlin/src/module/thermistor/thermistor_20.h +++ b/Marlin/src/module/thermistor/thermistor_20.h @@ -24,7 +24,7 @@ #define REVERSE_TEMP_SENSOR_RANGE_20 1 // Pt100 with INA826 amp on Ultimaker v2.0 electronics -const temp_entry_t temptable_20[] PROGMEM = { +constexpr temp_entry_t temptable_20[] PROGMEM = { { OV( 0), 0 }, { OV(227), 1 }, { OV(236), 10 }, diff --git a/Marlin/src/module/thermistor/thermistor_2000.h b/Marlin/src/module/thermistor/thermistor_2000.h new file mode 100644 index 0000000000..3815a6f256 --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_2000.h @@ -0,0 +1,60 @@ +/** + * 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 + +// R25 = 100 KOhm, beta25 = 4550 K, 4.7 kOhm pull-up, TDK NTCG104LH104KT1 https://product.tdk.com/en/search/sensor/ntc/chip-ntc-thermistor/info?part_no=NTCG104LH104KT1 +constexpr temp_entry_t temptable_2000[] PROGMEM = { +{ OV(313), 125 }, +{ OV(347), 120 }, +{ OV(383), 115 }, +{ OV(422), 110 }, +{ OV(463), 105 }, +{ OV(506), 100 }, +{ OV(549), 95 }, +{ OV(594), 90 }, +{ OV(638), 85 }, +{ OV(681), 80 }, +{ OV(722), 75 }, +{ OV(762), 70 }, +{ OV(799), 65 }, +{ OV(833), 60 }, +{ OV(863), 55 }, +{ OV(890), 50 }, +{ OV(914), 45 }, +{ OV(934), 40 }, +{ OV(951), 35 }, +{ OV(966), 30 }, +{ OV(978), 25 }, +{ OV(988), 20 }, +{ OV(996), 15 }, +{ OV(1002), 10 }, +{ OV(1007), 5 }, +{ OV(1012), 0 }, +{ OV(1015), -5 }, +{ OV(1017), -10 }, +{ OV(1019), -15 }, +{ OV(1020), -20 }, +{ OV(1021), -25 }, +{ OV(1022), -30 }, +{ OV(1023), -35 }, +{ OV(1023), -40 } +}; diff --git a/Marlin/src/module/thermistor/thermistor_201.h b/Marlin/src/module/thermistor/thermistor_201.h index 44d5280681..9c083a2d1b 100644 --- a/Marlin/src/module/thermistor/thermistor_201.h +++ b/Marlin/src/module/thermistor/thermistor_201.h @@ -24,7 +24,7 @@ #define REVERSE_TEMP_SENSOR_RANGE_201 1 // Pt100 with LMV324 amp on Overlord v1.1 electronics -const temp_entry_t temptable_201[] PROGMEM = { +constexpr temp_entry_t temptable_201[] PROGMEM = { { OV( 0), 0 }, { OV( 8), 1 }, { OV( 23), 6 }, diff --git a/Marlin/src/module/thermistor/thermistor_202.h b/Marlin/src/module/thermistor/thermistor_202.h index c5229607ae..e1b0ee258e 100644 --- a/Marlin/src/module/thermistor/thermistor_202.h +++ b/Marlin/src/module/thermistor/thermistor_202.h @@ -3,7 +3,7 @@ // Temptable sent from dealer technologyoutlet.co.uk // -const temp_entry_t temptable_202[] PROGMEM = { +constexpr temp_entry_t temptable_202[] PROGMEM = { { OV( 1), 864 }, { OV( 35), 300 }, { OV( 38), 295 }, diff --git a/Marlin/src/module/thermistor/thermistor_21.h b/Marlin/src/module/thermistor/thermistor_21.h index 2ca705b950..f8a5de2e15 100644 --- a/Marlin/src/module/thermistor/thermistor_21.h +++ b/Marlin/src/module/thermistor/thermistor_21.h @@ -28,7 +28,7 @@ // Pt100 with INA826 amplifier board with 5v supply based on Thermistor 20, with 3v3 ADC reference on the mainboard. // If the ADC reference and INA826 board supply voltage are identical, Thermistor 20 instead. -const temp_entry_t temptable_21[] PROGMEM = { +constexpr temp_entry_t temptable_21[] PROGMEM = { { OV( 0), 0 }, { OV(227), 1 }, { OV(236), 10 }, diff --git a/Marlin/src/module/thermistor/thermistor_22.h b/Marlin/src/module/thermistor/thermistor_22.h index 6f4a31050a..90e1af8c1a 100644 --- a/Marlin/src/module/thermistor/thermistor_22.h +++ b/Marlin/src/module/thermistor/thermistor_22.h @@ -21,7 +21,7 @@ */ // 100k hotend thermistor with 4.7k pull up to 3.3v and 220R to analog input as in GTM32 Pro vB -const temp_entry_t temptable_22[] PROGMEM = { +constexpr temp_entry_t temptable_22[] PROGMEM = { { OV( 1), 352 }, { OV( 6), 341 }, { OV( 11), 330 }, diff --git a/Marlin/src/module/thermistor/thermistor_23.h b/Marlin/src/module/thermistor/thermistor_23.h index 02ff9fb2b6..9b806af5b7 100644 --- a/Marlin/src/module/thermistor/thermistor_23.h +++ b/Marlin/src/module/thermistor/thermistor_23.h @@ -21,7 +21,7 @@ */ // 100k hotbed thermistor with 4.7k pull up to 3.3v and 220R to analog input as in GTM32 Pro vB -const temp_entry_t temptable_23[] PROGMEM = { +constexpr temp_entry_t temptable_23[] PROGMEM = { { OV( 1), 938 }, { OV( 11), 423 }, { OV( 21), 351 }, diff --git a/Marlin/src/module/thermistor/thermistor_3.h b/Marlin/src/module/thermistor/thermistor_3.h index 74e00e2ba4..cb6d75738e 100644 --- a/Marlin/src/module/thermistor/thermistor_3.h +++ b/Marlin/src/module/thermistor/thermistor_3.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4120 K, 4.7 kOhm pull-up, mendel-parts -const temp_entry_t temptable_3[] PROGMEM = { +constexpr temp_entry_t temptable_3[] PROGMEM = { { OV( 1), 864 }, { OV( 21), 300 }, { OV( 25), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_30.h b/Marlin/src/module/thermistor/thermistor_30.h index bc1781b135..daf4d29aa7 100644 --- a/Marlin/src/module/thermistor/thermistor_30.h +++ b/Marlin/src/module/thermistor/thermistor_30.h @@ -28,7 +28,7 @@ // B Value Tolerance + / - 1% // Kis3d Silicone Heater 24V 200W/300W with 6mm Precision cast plate (EN AW 5083) // Temperature setting time 10 min to determine the 12Bit ADC value on the surface. (le3tspeak) -const temp_entry_t temptable_30[] PROGMEM = { +constexpr temp_entry_t temptable_30[] PROGMEM = { { OV( 1), 938 }, { OV( 298), 125 }, // 1193 - 125° { OV( 321), 121 }, // 1285 - 121° diff --git a/Marlin/src/module/thermistor/thermistor_331.h b/Marlin/src/module/thermistor/thermistor_331.h index ccb0f6b62d..847dbc30a0 100644 --- a/Marlin/src/module/thermistor/thermistor_331.h +++ b/Marlin/src/module/thermistor/thermistor_331.h @@ -24,7 +24,7 @@ #define OVM(V) OV((V)*(0.327/0.5)) // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor -const temp_entry_t temptable_331[] PROGMEM = { +constexpr temp_entry_t temptable_331[] PROGMEM = { { OVM( 23), 300 }, { OVM( 25), 295 }, { OVM( 27), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_332.h b/Marlin/src/module/thermistor/thermistor_332.h index 9502f1bdae..83a5d39f0f 100644 --- a/Marlin/src/module/thermistor/thermistor_332.h +++ b/Marlin/src/module/thermistor/thermistor_332.h @@ -24,7 +24,7 @@ #define OVM(V) OV((V)*(0.327/0.327)) // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor -const temp_entry_t temptable_332[] PROGMEM = { +constexpr temp_entry_t temptable_332[] PROGMEM = { { OVM( 268), 150 }, { OVM( 293), 145 }, { OVM( 320), 141 }, diff --git a/Marlin/src/module/thermistor/thermistor_4.h b/Marlin/src/module/thermistor/thermistor_4.h index 92d907249b..98192a1124 100644 --- a/Marlin/src/module/thermistor/thermistor_4.h +++ b/Marlin/src/module/thermistor/thermistor_4.h @@ -22,7 +22,7 @@ #pragma once // R25 = 10 kOhm, beta25 = 3950 K, 4.7 kOhm pull-up, Generic 10k thermistor -const temp_entry_t temptable_4[] PROGMEM = { +constexpr temp_entry_t temptable_4[] PROGMEM = { { OV( 1), 430 }, { OV( 54), 137 }, { OV( 107), 107 }, diff --git a/Marlin/src/module/thermistor/thermistor_5.h b/Marlin/src/module/thermistor/thermistor_5.h index 1d5fa2fec7..69ef99fae1 100644 --- a/Marlin/src/module/thermistor/thermistor_5.h +++ b/Marlin/src/module/thermistor/thermistor_5.h @@ -26,7 +26,7 @@ // ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan) // Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance -const temp_entry_t temptable_5[] PROGMEM = { +constexpr temp_entry_t temptable_5[] PROGMEM = { { OV( 1), 713 }, { OV( 17), 300 }, // top rating 300C { OV( 20), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_501.h b/Marlin/src/module/thermistor/thermistor_501.h index d40e341f7e..0e142628ec 100644 --- a/Marlin/src/module/thermistor/thermistor_501.h +++ b/Marlin/src/module/thermistor/thermistor_501.h @@ -22,7 +22,7 @@ #pragma once // 100k Zonestar thermistor. Adjusted By Hally -const temp_entry_t temptable_501[] PROGMEM = { +constexpr temp_entry_t temptable_501[] PROGMEM = { { OV( 1), 713 }, { OV( 14), 300 }, // Top rating 300C { OV( 16), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_502.h b/Marlin/src/module/thermistor/thermistor_502.h index 69cee2431c..3ddbf30d47 100644 --- a/Marlin/src/module/thermistor/thermistor_502.h +++ b/Marlin/src/module/thermistor/thermistor_502.h @@ -23,7 +23,7 @@ // Unknown thermistor for the Zonestar P802M hot bed. Adjusted By Nerseth // These were the shipped settings from Zonestar in original firmware: P802M_8_Repetier_V1.6_Zonestar.zip -const temp_entry_t temptable_502[] PROGMEM = { +constexpr temp_entry_t temptable_502[] PROGMEM = { { OV( 56.0 / 4), 300 }, { OV( 187.0 / 4), 250 }, { OV( 615.0 / 4), 190 }, diff --git a/Marlin/src/module/thermistor/thermistor_503.h b/Marlin/src/module/thermistor/thermistor_503.h index fc4bffffdb..6ffe4b4a66 100644 --- a/Marlin/src/module/thermistor/thermistor_503.h +++ b/Marlin/src/module/thermistor/thermistor_503.h @@ -23,7 +23,7 @@ // Zonestar (Z8XM2) Heated Bed thermistor. Added By AvanOsch // These are taken from the Zonestar settings in original Repetier firmware: Z8XM2_ZRIB_LCD12864_V51.zip -const temp_entry_t temptable_503[] PROGMEM = { +constexpr temp_entry_t temptable_503[] PROGMEM = { { OV( 12), 300 }, { OV( 27), 270 }, { OV( 47), 250 }, diff --git a/Marlin/src/module/thermistor/thermistor_51.h b/Marlin/src/module/thermistor/thermistor_51.h index d02dd47ba5..ee63a0e61b 100644 --- a/Marlin/src/module/thermistor/thermistor_51.h +++ b/Marlin/src/module/thermistor/thermistor_51.h @@ -26,7 +26,7 @@ // Verified by linagee. // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance // Advantage: Twice the resolution and better linearity from 150C to 200C -const temp_entry_t temptable_51[] PROGMEM = { +constexpr temp_entry_t temptable_51[] PROGMEM = { { OV( 1), 350 }, { OV( 190), 250 }, // top rating 250C { OV( 203), 245 }, diff --git a/Marlin/src/module/thermistor/thermistor_512.h b/Marlin/src/module/thermistor/thermistor_512.h index e8021e1e48..e380b4a16b 100644 --- a/Marlin/src/module/thermistor/thermistor_512.h +++ b/Marlin/src/module/thermistor/thermistor_512.h @@ -22,7 +22,7 @@ // 100k thermistor supplied with RPW-Ultra hotend, 4.7k pullup -const temp_entry_t temptable_512[] PROGMEM = { +constexpr temp_entry_t temptable_512[] PROGMEM = { { OV(26), 300 }, { OV(28), 295 }, { OV(30), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_52.h b/Marlin/src/module/thermistor/thermistor_52.h index 5c9cb9dc4d..f3bb75d462 100644 --- a/Marlin/src/module/thermistor/thermistor_52.h +++ b/Marlin/src/module/thermistor/thermistor_52.h @@ -26,7 +26,7 @@ // Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance // Advantage: More resolution and better linearity from 150C to 200C -const temp_entry_t temptable_52[] PROGMEM = { +constexpr temp_entry_t temptable_52[] PROGMEM = { { OV( 1), 500 }, { OV( 125), 300 }, // top rating 300C { OV( 142), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_55.h b/Marlin/src/module/thermistor/thermistor_55.h index 707b7d420a..41004a97ef 100644 --- a/Marlin/src/module/thermistor/thermistor_55.h +++ b/Marlin/src/module/thermistor/thermistor_55.h @@ -26,7 +26,7 @@ // Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance // Advantage: More resolution and better linearity from 150C to 200C -const temp_entry_t temptable_55[] PROGMEM = { +constexpr temp_entry_t temptable_55[] PROGMEM = { { OV( 1), 500 }, { OV( 76), 300 }, { OV( 87), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_6.h b/Marlin/src/module/thermistor/thermistor_6.h index 68113419e5..b5e79a9b0e 100644 --- a/Marlin/src/module/thermistor/thermistor_6.h +++ b/Marlin/src/module/thermistor/thermistor_6.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4092 K, 8.2 kOhm pull-up, 100k Epcos (?) thermistor -const temp_entry_t temptable_6[] PROGMEM = { +constexpr temp_entry_t temptable_6[] PROGMEM = { { OV( 1), 350 }, { OV( 28), 250 }, // top rating 250C { OV( 31), 245 }, diff --git a/Marlin/src/module/thermistor/thermistor_60.h b/Marlin/src/module/thermistor/thermistor_60.h index a3fe50559f..a057080e45 100644 --- a/Marlin/src/module/thermistor/thermistor_60.h +++ b/Marlin/src/module/thermistor/thermistor_60.h @@ -31,7 +31,7 @@ // beta: 3950 // min adc: 1 at 0.0048828125 V // max adc: 1023 at 4.9951171875 V -const temp_entry_t temptable_60[] PROGMEM = { +constexpr temp_entry_t temptable_60[] PROGMEM = { { OV( 51), 272 }, { OV( 61), 258 }, { OV( 71), 247 }, diff --git a/Marlin/src/module/thermistor/thermistor_61.h b/Marlin/src/module/thermistor/thermistor_61.h index ed4c4c8859..deeec356a1 100644 --- a/Marlin/src/module/thermistor/thermistor_61.h +++ b/Marlin/src/module/thermistor/thermistor_61.h @@ -30,7 +30,7 @@ // Resistance Tolerance + / -1% // B Value 3950K at 25/50 deg. C // B Value Tolerance + / - 1% -const temp_entry_t temptable_61[] PROGMEM = { +constexpr temp_entry_t temptable_61[] PROGMEM = { { OV( 2.00), 420 }, // Guestimate to ensure we dont lose a reading and drop temps to -50 when over { OV( 12.07), 350 }, { OV( 12.79), 345 }, diff --git a/Marlin/src/module/thermistor/thermistor_66.h b/Marlin/src/module/thermistor/thermistor_66.h index 0ad5994ea8..3b057ac696 100644 --- a/Marlin/src/module/thermistor/thermistor_66.h +++ b/Marlin/src/module/thermistor/thermistor_66.h @@ -22,7 +22,7 @@ #pragma once // R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign 500 °C Thermistor -const temp_entry_t temptable_66[] PROGMEM = { +constexpr temp_entry_t temptable_66[] PROGMEM = { { OV( 17.5), 850 }, { OV( 17.9), 500 }, { OV( 21.7), 480 }, diff --git a/Marlin/src/module/thermistor/thermistor_666.h b/Marlin/src/module/thermistor/thermistor_666.h index 490dbd5f3e..bba3e606fc 100644 --- a/Marlin/src/module/thermistor/thermistor_666.h +++ b/Marlin/src/module/thermistor/thermistor_666.h @@ -33,7 +33,7 @@ * B: 0.00031362 * C: -2.03978e-07 */ -const temp_entry_t temptable_666[] PROGMEM = { +constexpr temp_entry_t temptable_666[] PROGMEM = { { OV( 1), 794 }, { OV( 18), 288 }, { OV( 35), 234 }, diff --git a/Marlin/src/module/thermistor/thermistor_67.h b/Marlin/src/module/thermistor/thermistor_67.h index 7d6d7f697d..10fa9310b1 100644 --- a/Marlin/src/module/thermistor/thermistor_67.h +++ b/Marlin/src/module/thermistor/thermistor_67.h @@ -22,7 +22,7 @@ #pragma once // R25 = 500 KOhm, beta25 = 3800 K, 4.7 kOhm pull-up, SliceEngineering 450 °C Thermistor -const temp_entry_t temptable_67[] PROGMEM = { +constexpr temp_entry_t temptable_67[] PROGMEM = { { OV( 22 ), 500 }, { OV( 23 ), 490 }, { OV( 25 ), 480 }, diff --git a/Marlin/src/module/thermistor/thermistor_7.h b/Marlin/src/module/thermistor/thermistor_7.h index 7a73755984..964897859e 100644 --- a/Marlin/src/module/thermistor/thermistor_7.h +++ b/Marlin/src/module/thermistor/thermistor_7.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3974 K, 4.7 kOhm pull-up, Honeywell 135-104LAG-J01 -const temp_entry_t temptable_7[] PROGMEM = { +constexpr temp_entry_t temptable_7[] PROGMEM = { { OV( 1), 941 }, { OV( 19), 362 }, { OV( 37), 299 }, // top rating 300C diff --git a/Marlin/src/module/thermistor/thermistor_70.h b/Marlin/src/module/thermistor/thermistor_70.h index 466b925553..f0163dcabc 100644 --- a/Marlin/src/module/thermistor/thermistor_70.h +++ b/Marlin/src/module/thermistor/thermistor_70.h @@ -26,7 +26,7 @@ // ANENG AN8009 DMM with a K-type probe used for measurements. // R25 = 100 kOhm, beta25 = 4100 K, 4.7 kOhm pull-up, bqh2 stock thermistor -const temp_entry_t temptable_70[] PROGMEM = { +constexpr temp_entry_t temptable_70[] PROGMEM = { { OV( 18), 270 }, { OV( 27), 248 }, { OV( 34), 234 }, diff --git a/Marlin/src/module/thermistor/thermistor_71.h b/Marlin/src/module/thermistor/thermistor_71.h index abd7fc5b98..c94b4d5bbc 100644 --- a/Marlin/src/module/thermistor/thermistor_71.h +++ b/Marlin/src/module/thermistor/thermistor_71.h @@ -27,7 +27,7 @@ // Beta = 3974 // R1 = 0 Ohm // R2 = 4700 Ohm -const temp_entry_t temptable_71[] PROGMEM = { +constexpr temp_entry_t temptable_71[] PROGMEM = { { OV( 35), 300 }, { OV( 51), 269 }, { OV( 59), 258 }, diff --git a/Marlin/src/module/thermistor/thermistor_75.h b/Marlin/src/module/thermistor/thermistor_75.h index 79800d2e40..bb2ecce7dc 100644 --- a/Marlin/src/module/thermistor/thermistor_75.h +++ b/Marlin/src/module/thermistor/thermistor_75.h @@ -34,7 +34,7 @@ //#define HIGH_TEMP_RANGE_75 -const temp_entry_t temptable_75[] PROGMEM = { // Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor +constexpr temp_entry_t temptable_75[] PROGMEM = { // Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor { OV(111.06), 200 }, // v=0.542 r=571.747 res=0.501 degC/count #ifdef HIGH_TEMP_RANGE_75 diff --git a/Marlin/src/module/thermistor/thermistor_8.h b/Marlin/src/module/thermistor/thermistor_8.h index 9e19168fed..4b0f791f16 100644 --- a/Marlin/src/module/thermistor/thermistor_8.h +++ b/Marlin/src/module/thermistor/thermistor_8.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3950 K, 10 kOhm pull-up, NTCS0603E3104FHT -const temp_entry_t temptable_8[] PROGMEM = { +constexpr temp_entry_t temptable_8[] PROGMEM = { { OV( 1), 704 }, { OV( 54), 216 }, { OV( 107), 175 }, diff --git a/Marlin/src/module/thermistor/thermistor_9.h b/Marlin/src/module/thermistor/thermistor_9.h index 29097420ec..3830a7dfcc 100644 --- a/Marlin/src/module/thermistor/thermistor_9.h +++ b/Marlin/src/module/thermistor/thermistor_9.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3960 K, 4.7 kOhm pull-up, GE Sensing AL03006-58.2K-97-G1 -const temp_entry_t temptable_9[] PROGMEM = { +constexpr temp_entry_t temptable_9[] PROGMEM = { { OV( 1), 936 }, { OV( 36), 300 }, { OV( 71), 246 }, diff --git a/Marlin/src/module/thermistor/thermistor_99.h b/Marlin/src/module/thermistor/thermistor_99.h index 839a511c09..f813abae69 100644 --- a/Marlin/src/module/thermistor/thermistor_99.h +++ b/Marlin/src/module/thermistor/thermistor_99.h @@ -24,7 +24,7 @@ // 100k bed thermistor with a 10K pull-up resistor - made by $ buildroot/share/scripts/createTemperatureLookupMarlin.py --rp=10000 -const temp_entry_t temptable_99[] PROGMEM = { +constexpr temp_entry_t temptable_99[] PROGMEM = { { OV( 5.81), 350 }, // v=0.028 r= 57.081 res=13.433 degC/count { OV( 6.54), 340 }, // v=0.032 r= 64.248 res=11.711 degC/count { OV( 7.38), 330 }, // v=0.036 r= 72.588 res=10.161 degC/count diff --git a/Marlin/src/module/thermistor/thermistor_998.h b/Marlin/src/module/thermistor/thermistor_998.h index e4cfbbaa0d..753cdd40bc 100644 --- a/Marlin/src/module/thermistor/thermistor_998.h +++ b/Marlin/src/module/thermistor/thermistor_998.h @@ -27,7 +27,7 @@ #define DUMMY_THERMISTOR_998_VALUE 25 #endif -const temp_entry_t temptable_998[] PROGMEM = { +constexpr temp_entry_t temptable_998[] PROGMEM = { { OV( 1), DUMMY_THERMISTOR_998_VALUE }, { OV(1023), DUMMY_THERMISTOR_998_VALUE } }; diff --git a/Marlin/src/module/thermistor/thermistor_999.h b/Marlin/src/module/thermistor/thermistor_999.h index 0271c47f85..41e44ef631 100644 --- a/Marlin/src/module/thermistor/thermistor_999.h +++ b/Marlin/src/module/thermistor/thermistor_999.h @@ -27,7 +27,7 @@ #define DUMMY_THERMISTOR_999_VALUE 25 #endif -const temp_entry_t temptable_999[] PROGMEM = { +constexpr temp_entry_t temptable_999[] PROGMEM = { { OV( 1), DUMMY_THERMISTOR_999_VALUE }, { OV(1023), DUMMY_THERMISTOR_999_VALUE } }; diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 97d268c303..28a1e2f90f 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -42,7 +42,17 @@ #define OV_SCALE(N) (N) #define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) -#define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_COOLER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n) +#define TEMP_SENSOR_IS(n,H) (n == TEMP_SENSOR_##H) +#define ANY_THERMISTOR_IS(n) ( TEMP_SENSOR_IS(n, 0) || TEMP_SENSOR_IS(n, 1) \ + || TEMP_SENSOR_IS(n, 2) || TEMP_SENSOR_IS(n, 3) \ + || TEMP_SENSOR_IS(n, 4) || TEMP_SENSOR_IS(n, 5) \ + || TEMP_SENSOR_IS(n, 6) || TEMP_SENSOR_IS(n, 7) \ + || TEMP_SENSOR_IS(n, BED) \ + || TEMP_SENSOR_IS(n, CHAMBER) \ + || TEMP_SENSOR_IS(n, COOLER) \ + || TEMP_SENSOR_IS(n, PROBE) \ + || TEMP_SENSOR_IS(n, BOARD) \ + || TEMP_SENSOR_IS(n, REDUNDANT) ) typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; @@ -191,6 +201,9 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #if ANY_THERMISTOR_IS(1047) // Pt1000 with 4k7 pullup #include "thermistor_1047.h" #endif +#if ANY_THERMISTOR_IS(2000) // "Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor" https://product.tdk.com/en/search/sensor/ntc/chip-ntc-thermistor/info?part_no=NTCG104LH104KT1 + #include "thermistor_2000.h" +#endif #if ANY_THERMISTOR_IS(998) // User-defined table 1 #include "thermistor_998.h" #endif @@ -198,146 +211,136 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #include "thermistor_999.h" #endif #if ANY_THERMISTOR_IS(1000) // Custom - const temp_entry_t temptable_1000[] PROGMEM = { { 0, 0 } }; + constexpr temp_entry_t temptable_1000[] PROGMEM = { { 0, 0 } }; #endif #define _TT_NAME(_N) temptable_ ## _N #define TT_NAME(_N) _TT_NAME(_N) - -#if TEMP_SENSOR_0_THERMISTOR_ID - #define TEMPTABLE_0 TT_NAME(TEMP_SENSOR_0_THERMISTOR_ID) +#if TEMP_SENSOR_0 > 0 + #define TEMPTABLE_0 TT_NAME(TEMP_SENSOR_0) #define TEMPTABLE_0_LEN COUNT(TEMPTABLE_0) -#elif TEMP_SENSOR_0_IS_THERMISTOR - #error "No heater 0 thermistor table specified" #else #define TEMPTABLE_0 nullptr #define TEMPTABLE_0_LEN 0 #endif -#if TEMP_SENSOR_1_THERMISTOR_ID - #define TEMPTABLE_1 TT_NAME(TEMP_SENSOR_1_THERMISTOR_ID) +#if TEMP_SENSOR_1 > 0 + #define TEMPTABLE_1 TT_NAME(TEMP_SENSOR_1) #define TEMPTABLE_1_LEN COUNT(TEMPTABLE_1) -#elif TEMP_SENSOR_1_IS_THERMISTOR - #error "No heater 1 thermistor table specified" #else #define TEMPTABLE_1 nullptr #define TEMPTABLE_1_LEN 0 #endif -#if TEMP_SENSOR_2_THERMISTOR_ID - #define TEMPTABLE_2 TT_NAME(TEMP_SENSOR_2_THERMISTOR_ID) +#if TEMP_SENSOR_2 > 0 + #define TEMPTABLE_2 TT_NAME(TEMP_SENSOR_2) #define TEMPTABLE_2_LEN COUNT(TEMPTABLE_2) -#elif TEMP_SENSOR_2_IS_THERMISTOR - #error "No heater 2 thermistor table specified" #else #define TEMPTABLE_2 nullptr #define TEMPTABLE_2_LEN 0 #endif -#if TEMP_SENSOR_3_THERMISTOR_ID - #define TEMPTABLE_3 TT_NAME(TEMP_SENSOR_3_THERMISTOR_ID) +#if TEMP_SENSOR_3 > 0 + #define TEMPTABLE_3 TT_NAME(TEMP_SENSOR_3) #define TEMPTABLE_3_LEN COUNT(TEMPTABLE_3) -#elif TEMP_SENSOR_3_IS_THERMISTOR - #error "No heater 3 thermistor table specified" #else #define TEMPTABLE_3 nullptr #define TEMPTABLE_3_LEN 0 #endif -#if TEMP_SENSOR_4_THERMISTOR_ID - #define TEMPTABLE_4 TT_NAME(TEMP_SENSOR_4_THERMISTOR_ID) +#if TEMP_SENSOR_4 > 0 + #define TEMPTABLE_4 TT_NAME(TEMP_SENSOR_4) #define TEMPTABLE_4_LEN COUNT(TEMPTABLE_4) -#elif TEMP_SENSOR_4_IS_THERMISTOR - #error "No heater 4 thermistor table specified" #else #define TEMPTABLE_4 nullptr #define TEMPTABLE_4_LEN 0 #endif -#if TEMP_SENSOR_5_THERMISTOR_ID - #define TEMPTABLE_5 TT_NAME(TEMP_SENSOR_5_THERMISTOR_ID) +#if TEMP_SENSOR_5 > 0 + #define TEMPTABLE_5 TT_NAME(TEMP_SENSOR_5) #define TEMPTABLE_5_LEN COUNT(TEMPTABLE_5) -#elif TEMP_SENSOR_5_IS_THERMISTOR - #error "No heater 5 thermistor table specified" #else #define TEMPTABLE_5 nullptr #define TEMPTABLE_5_LEN 0 #endif -#if TEMP_SENSOR_6_THERMISTOR_ID - #define TEMPTABLE_6 TT_NAME(TEMP_SENSOR_6_THERMISTOR_ID) +#if TEMP_SENSOR_6 > 0 + #define TEMPTABLE_6 TT_NAME(TEMP_SENSOR_6) #define TEMPTABLE_6_LEN COUNT(TEMPTABLE_6) -#elif TEMP_SENSOR_6_IS_THERMISTOR - #error "No heater 6 thermistor table specified" #else #define TEMPTABLE_6 nullptr #define TEMPTABLE_6_LEN 0 #endif -#if TEMP_SENSOR_7_THERMISTOR_ID - #define TEMPTABLE_7 TT_NAME(TEMP_SENSOR_7_THERMISTOR_ID) +#if TEMP_SENSOR_7 > 0 + #define TEMPTABLE_7 TT_NAME(TEMP_SENSOR_7) #define TEMPTABLE_7_LEN COUNT(TEMPTABLE_7) -#elif TEMP_SENSOR_7_IS_THERMISTOR - #error "No heater 7 thermistor table specified" #else #define TEMPTABLE_7 nullptr #define TEMPTABLE_7_LEN 0 #endif -#ifdef TEMP_SENSOR_BED_THERMISTOR_ID - #define TEMPTABLE_BED TT_NAME(TEMP_SENSOR_BED_THERMISTOR_ID) +#if TEMP_SENSOR_BED > 0 + #define TEMPTABLE_BED TT_NAME(TEMP_SENSOR_BED) #define TEMPTABLE_BED_LEN COUNT(TEMPTABLE_BED) -#elif TEMP_SENSOR_BED_IS_THERMISTOR - #error "No bed thermistor table specified" #else #define TEMPTABLE_BED_LEN 0 #endif -#ifdef TEMP_SENSOR_CHAMBER_THERMISTOR_ID - #define TEMPTABLE_CHAMBER TT_NAME(TEMP_SENSOR_CHAMBER_THERMISTOR_ID) +#if TEMP_SENSOR_CHAMBER > 0 + #define TEMPTABLE_CHAMBER TT_NAME(TEMP_SENSOR_CHAMBER) #define TEMPTABLE_CHAMBER_LEN COUNT(TEMPTABLE_CHAMBER) -#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR - #error "No chamber thermistor table specified" #else #define TEMPTABLE_CHAMBER_LEN 0 #endif -#ifdef TEMP_SENSOR_COOLER_THERMISTOR_ID - #define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER_THERMISTOR_ID) +#if TEMP_SENSOR_COOLER > 0 + #define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER) #define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER) -#elif TEMP_SENSOR_COOLER_IS_THERMISTOR - #error "No cooler thermistor table specified" #else #define TEMPTABLE_COOLER_LEN 0 #endif -#ifdef TEMP_SENSOR_PROBE_THERMISTOR_ID - #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE_THERMISTOR_ID) + +#if TEMP_SENSOR_PROBE > 0 + #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE) #define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE) -#elif TEMP_SENSOR_PROBE_IS_THERMISTOR - #error "No probe thermistor table specified" #else #define TEMPTABLE_PROBE_LEN 0 #endif +#if TEMP_SENSOR_BOARD > 0 + #define TEMPTABLE_BOARD TT_NAME(TEMP_SENSOR_BOARD) + #define TEMPTABLE_BOARD_LEN COUNT(TEMPTABLE_BOARD) +#else + #define TEMPTABLE_BOARD_LEN 0 +#endif + +#if TEMP_SENSOR_REDUNDANT > 0 + #define TEMPTABLE_REDUNDANT TT_NAME(TEMP_SENSOR_REDUNDANT) + #define TEMPTABLE_REDUNDANT_LEN COUNT(TEMPTABLE_REDUNDANT) +#else + #define TEMPTABLE_REDUNDANT_LEN 0 +#endif + // The SCAN_THERMISTOR_TABLE macro needs alteration? -static_assert( - TEMPTABLE_0_LEN < 256 && TEMPTABLE_1_LEN < 256 - && TEMPTABLE_2_LEN < 256 && TEMPTABLE_3_LEN < 256 - && TEMPTABLE_4_LEN < 256 && TEMPTABLE_5_LEN < 256 - && TEMPTABLE_6_LEN < 256 && TEMPTABLE_7_LEN < 256 - && TEMPTABLE_BED_LEN < 256 && TEMPTABLE_CHAMBER_LEN < 256 - && TEMPTABLE_COOLER_LEN < 256 && TEMPTABLE_PROBE_LEN < 256, - "Temperature conversion tables over 255 entries need special consideration." +static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_2_LEN || 255 > TEMPTABLE_3_LEN + || 255 > TEMPTABLE_4_LEN || 255 > TEMPTABLE_5_LEN || 255 > TEMPTABLE_6_LEN || 255 > TEMPTABLE_7_LEN + || 255 > TEMPTABLE_BED_LEN + || 255 > TEMPTABLE_CHAMBER_LEN + || 255 > TEMPTABLE_COOLER_LEN + || 255 > TEMPTABLE_PROBE_LEN + || 255 > TEMPTABLE_BOARD_LEN + || 255 > TEMPTABLE_REDUNDANT_LEN + , "Temperature conversion tables over 255 entries need special consideration." ); // Set the high and low raw values for the heaters // For thermistors the highest temperature results in the lowest ADC value // For thermocouples the highest temperature results in the highest ADC value -#define __TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N -#define _TT_REV(N) __TT_REV(N) -#define TT_REV(N) _TT_REV(TEMP_SENSOR_##N##_THERMISTOR_ID) +#define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N +#define TT_REV(N) TERN0(TEMP_SENSOR_##N##_IS_THERMISTOR, DEFER4(_TT_REV)(TEMP_SENSOR_##N)) #define _TT_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR #define TT_REVRAW(N) (TT_REV(N) || _TT_REVRAW(N)) @@ -522,6 +525,24 @@ static_assert( #define TEMP_SENSOR_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif +#ifndef TEMP_SENSOR_BOARD_RAW_HI_TEMP + #if TT_REVRAW(BOARD) + #define TEMP_SENSOR_BOARD_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_BOARD_RAW_LO_TEMP 0 + #else + #define TEMP_SENSOR_BOARD_RAW_HI_TEMP 0 + #define TEMP_SENSOR_BOARD_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #endif +#endif +#ifndef TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP + #if TT_REVRAW(REDUNDANT) + #define TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_REDUNDANT_RAW_LO_TEMP 0 + #else + #define TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP 0 + #define TEMP_SENSOR_REDUNDANT_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #endif +#endif #undef __TT_REV #undef _TT_REV diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index ab1446f07c..a0f8c1648c 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -49,6 +49,10 @@ #define BOARD_INFO_NAME "RAMPS 1.4" #endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "SimRap 1.4" +#endif + #ifndef MARLIN_EEPROM_SIZE #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif @@ -133,11 +137,11 @@ #define TEMP_1_PIN 1 // Analog Input #define TEMP_BED_PIN 2 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // @@ -192,7 +196,7 @@ #else // Non-specific are "EFB" (i.e., "EFBF" or "EFBE") #define FAN_PIN RAMPS_D9_PIN #define HEATER_BED_PIN RAMPS_D8_PIN - #if HOTENDS == 1 + #if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) #define FAN1_PIN MOSFET_D_PIN #else #define HEATER_1_PIN MOSFET_D_PIN @@ -208,6 +212,7 @@ // #define SDSS 53 #define LED_PIN 13 +#define NEOPIXEL_PIN 71 #ifndef FILWIDTH_PIN #define FILWIDTH_PIN 5 // Analog Input on AUX2 @@ -215,7 +220,7 @@ // define digital pin 4 for the filament runout sensor. Use the RAMPS 1.4 digital input 4 on the servos connector #ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN 4 + #define FIL_RUNOUT_PIN 21 #endif #ifndef PS_ON_PIN @@ -389,7 +394,54 @@ // LCDs and Controllers // ////////////////////////// -#if HAS_WIRED_LCD +#if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI) + + #define TFT_A0_PIN 43 + #define TFT_CS_PIN 49 + #define TFT_DC_PIN 43 + #define TFT_SCK_PIN SD_SCK_PIN + #define TFT_MOSI_PIN SD_MOSI_PIN + #define TFT_MISO_PIN SD_MISO_PIN + #define LCD_USE_DMA_SPI + + #define BTN_EN1 40 + #define BTN_EN2 63 + #define BTN_ENC 59 + #define BEEPER_PIN 42 + + #define TOUCH_CS_PIN 33 + #define SD_DETECT_PIN 41 + + #define HAS_SPI_FLASH 1 + #if HAS_SPI_FLASH + #define SPI_DEVICE 1 + #define SPI_FLASH_SIZE 0x1000000 // 16MB + #define W25QXX_CS_PIN 31 + #define W25QXX_MOSI_PIN SD_MOSI_PIN + #define W25QXX_MISO_PIN SD_MISO_PIN + #define W25QXX_SCK_PIN SD_SCK_PIN + #endif + + #define TFT_BUFFER_SIZE 0xFFFF + #ifndef TFT_DRIVER + #define TFT_DRIVER ST7796 + #endif + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION 63934 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION 63598 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET -1 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET -20 + #endif + + #define BTN_BACK 70 + +#elif HAS_WIRED_LCD // // LCD Display output pins @@ -622,14 +674,18 @@ #define BTN_EN1 37 #define BTN_EN2 35 #define BTN_ENC 31 + #define SD_DETECT_PIN 41 #endif #if ENABLED(G3D_PANEL) #define SD_DETECT_PIN 49 #define KILL_PIN 41 #endif - #endif + + // CUSTOM SIMULATOR INPUTS + #define BTN_BACK 70 + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD 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 0508c5b5a9..73b4d3e63d 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -31,6 +31,20 @@ #define BOARD_CUSTOM_BUILD_FLAGS -DLPC_PINCFG_UART3_P4_28 #endif +// +// EEPROM +// +#if NO_EEPROM_SELECTED + //#define I2C_EEPROM // EEPROM on I2C-0 + //#define SDCARD_EEPROM_EMULATION +#endif + +#if ENABLED(I2C_EEPROM) + #define MARLIN_EEPROM_SIZE 0x8000 // 32Kb +#elif ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800 // 2Kb +#endif + // // Servos // diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index 01f2303a35..bb4c0e8000 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -65,7 +65,7 @@ #define TEMP_BED_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_BED_PIN #endif -#if HOTENDS == 1 +#if HOTENDS == 1 && !REDUNDANT_TEMP_MATCH(SOURCE, E1) #if TEMP_SENSOR_PROBE #define TEMP_PROBE_PIN TEMP_1_PIN #elif TEMP_SENSOR_CHAMBER @@ -73,13 +73,26 @@ #endif #endif +// CS, MISO, MOSI, and SCK for MAX Thermocouple SPI +#if HAS_MAX_TC + //#define TEMP_0_CS_PIN P... + //#define TEMP_0_MISO_PIN P... + //#define TEMP_0_MOSI_PIN P... + //#define TEMP_0_SCK_PIN P... + + //#define TEMP_1_CS_PIN P... + //#define TEMP_1_MISO_PIN P... + //#define TEMP_1_MOSI_PIN P... + //#define TEMP_1_SCK_PIN P... +#endif + // // Heaters / Fans // #ifndef HEATER_0_PIN #define HEATER_0_PIN P2_07 #endif -#if HOTENDS == 1 +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) #ifndef FAN1_PIN #define FAN1_PIN P2_04 #endif @@ -139,14 +152,14 @@ #endif #if ENABLED(BTT_MOTOR_EXPANSION) - /** _____ _____ - * NC | . . | GND NC | . . | GND - * NC | . . | M1EN M2EN | . . | M3EN - * M1STP | . . M1DIR M1RX | . . M1DIAG - * M2DIR | . . | M2STP M2RX | . . | M2DIAG - * M3DIR | . . | M3STP M3RX | . . | M3DIAG - * ----- ----- - * EXP2 EXP1 + /** ______ ______ + * NC | 1 2 | GND NC | 1 2 | GND + * NC | 3 4 | M1EN M2EN | 3 4 | M3EN + * M1STP | 5 6 M1DIR M1RX | 5 6 M1DIAG + * M2DIR | 7 8 | M2STP M2RX | 7 8 | M2DIAG + * M3DIR | 9 10 | M3STP M3RX | 9 10 | M3DIAG + * ------ ------ + * EXP2 EXP1 * * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN */ diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index f998ecde4e..68e1389841 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -202,7 +202,7 @@ // #define HEATER_BED_PIN P2_05 #define HEATER_0_PIN P2_07 -#if HOTENDS == 1 +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) #ifndef FAN1_PIN #define FAN1_PIN P2_06 #endif diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index 83fcf36e4e..fe7daa8cda 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -217,7 +217,7 @@ #define FAN1_PIN RAMPS_D8_PIN #elif DISABLED(IS_RAMPS_SF) // Not Spindle, Fan (i.e., "EFBF" or "EFBE") #define HEATER_BED_PIN RAMPS_D8_PIN - #if HOTENDS == 1 + #if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) #define FAN1_PIN MOSFET_D_PIN #else #define HEATER_1_PIN MOSFET_D_PIN @@ -248,8 +248,8 @@ #define PS_ON_PIN P2_12 // (12) -#if !defined(MAX6675_SS_PIN) && DISABLED(USE_ZMAX_PLUG) - #define MAX6675_SS_PIN P1_28 +#if !defined(TEMP_0_CS_PIN) && DISABLED(USE_ZMAX_PLUG) + #define TEMP_0_CS_PIN P1_28 #endif #if ENABLED(CASE_LIGHT_ENABLE) && !PIN_EXISTS(CASE_LIGHT) && !defined(SPINDLE_LASER_ENA_PIN) diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h index 2e1e02f991..d648b25efb 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -165,8 +165,8 @@ // #define TEMP_0_PIN P0_24 #define TEMP_1_PIN P0_23 -//#define TEMP_2_PIN P1_30 // Onboard thermistor #define TEMP_BED_PIN P0_25 +#define TEMP_BOARD_PIN P1_30 // Onboard thermistor, NTC100K // // Heaters / Fans @@ -182,13 +182,13 @@ #endif /** - * _____ - * 5V | 1 2 | GND - * (LCD_EN) P0_18 | 3 4 | P0_17 (LCD_RS) - * (LCD_D4) P0_15 | 5 6 P0_20 (BTN_EN2) - * RESET | 7 8 | P0_19 (BTN_EN1) - * (BTN_ENC) P0_16 | 9 10| P2_08 (BEEPER) - * ----- + * ______ + * 5V | 1 2 | GND + * (LCD_EN) P0_18 | 3 4 | P0_17 (LCD_RS) + * (LCD_D4) P0_15 | 5 6 P0_20 (BTN_EN2) + * RESET | 7 8 | P0_19 (BTN_EN1) + * (BTN_ENC) P0_16 | 9 10 | P2_08 (BEEPER) + * ------ * EXP */ @@ -201,7 +201,26 @@ #define EXP1_09_PIN P0_16 #define EXP1_10_PIN P2_08 -#if HAS_WIRED_LCD +#if ENABLED(DWIN_CREALITY_LCD) + #error "DWIN_CREALITY_LCD requires a custom cable with TX = P0_15, RX = P0_16. Comment out this line to continue." + + /** + * Ender 3 V2 display SKR E3 Turbo (EXP1) Ender 3 V2 display --> SKR E3 Turbo + * ______ ______ RX 8 --> 5 P0_15 + * 5V | 1 2 | GND 5V | 1 2 | GND TX 7 --> 9 P0_16 + * (BTN_E1) A | 3 4 | B (BTN_E2) (LCD_EN) P0_18 | 3 4 | P0_17 (LCD_RS) BEEPER 5 --> 10 P2_08 + * BEEPER | 5 6 ENT (BTN_ENC) (LCD_D4) P0_15 | 5 6 P0_20 (BTN_EN2) + * (SKR_RX1) TX | 7 8 | RX (SKR_TX1) Reset | 7 8 | P0_19 (BTN_EN1) + * NC | 9 10 | NC (BTN_ENC) P0_16 | 9 10 | P2_08 (BEEPER) + * ------ ------ + */ + + #define BEEPER_PIN EXP1_10_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_04_PIN + #define BTN_ENC EXP1_06_PIN + +#elif HAS_WIRED_LCD #if ENABLED(CR10_STOCKDISPLAY) @@ -264,5 +283,3 @@ #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "SD CUSTOM_CABLE is not compatible with SKR E3 Turbo." #endif - -#define ON_BOARD_SPI_DEVICE 1 // SPI1 diff --git a/Marlin/src/pins/mega/env_validate.h b/Marlin/src/pins/mega/env_validate.h index fe4a39a612..97c52d4e5e 100644 --- a/Marlin/src/pins/mega/env_validate.h +++ b/Marlin/src/pins/mega/env_validate.h @@ -21,10 +21,12 @@ */ #pragma once -#if ENABLED(ALLOW_MEGA1280) && NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) - #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560 or 1280' in 'Tools > Board.'" -#elif NOT_TARGET(__AVR_ATmega2560__) - #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" +#if NOT_TARGET(__AVR_ATmega2560__) + #if DISABLED(ALLOW_MEGA1280) + #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" + #elif NOT_TARGET(__AVR_ATmega1280__) + #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560 or 1280' in 'Tools > Board.'" + #endif #endif #undef ALLOW_MEGA1280 diff --git a/Marlin/src/pins/mega/pins_MALYAN_M180.h b/Marlin/src/pins/mega/pins_MALYAN_M180.h index e244d294f1..19095a5379 100644 --- a/Marlin/src/pins/mega/pins_MALYAN_M180.h +++ b/Marlin/src/pins/mega/pins_MALYAN_M180.h @@ -72,17 +72,17 @@ #define TEMP_BED_PIN 15 // Analog Input // Extruder thermocouples 0 and 1 are read out by two separate ICs using -// SPI for Max6675 Thermocouple +// SPI for MAX Thermocouple // Uses a separate SPI bus -#define THERMO_SCK_PIN 78 // E2 - SCK -#define THERMO_DO_PIN 3 // E5 - DO -#define THERMO_CS1_PIN 5 // E3 - CS0 -#define THERMO_CS2_PIN 2 // E4 - CS1 +#define TEMP_0_CS_PIN 5 // E3 - CS0 +#define TEMP_0_SCK_PIN 78 // E2 - SCK +#define TEMP_0_MISO_PIN 3 // E5 - MISO +//#define TEMP_0_MOSI_PIN ... // For MAX31865 -#define MAX6675_SS_PIN THERMO_CS1_PIN -#define MAX6675_SS2_PIN THERMO_CS2_PIN -#define MAX6675_SCK_PIN THERMO_SCK_PIN -#define MAX6675_DO_PIN THERMO_DO_PIN +#define TEMP_1_CS_PIN 2 // E4 - CS1 +#define TEMP_1_SCK_PIN TEMP_0_SCK_PIN +#define TEMP_1_MISO_PIN TEMP_0_MISO_PIN +//#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN // // Heaters / Fans diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index 2531f10a7a..aea05134a8 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -125,7 +125,7 @@ // K7 - 69 / ADC15 - 15 #define TEMP_BED_PIN 15 -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple // Uses a separate SPI bus // // 3 E5 DO (SO) @@ -133,15 +133,15 @@ // 2 E4 CS2 // 78 E2 SCK // -#define THERMO_SCK_PIN 78 // E2 -#define THERMO_DO_PIN 3 // E5 -#define THERMO_CS1_PIN 5 // E3 -#define THERMO_CS2_PIN 2 // E4 +#define TEMP_0_CS_PIN 5 // E3 +#define TEMP_0_SCK_PIN 78 // E2 +#define TEMP_0_MISO_PIN 3 // E5 +//#define TEMP_0_MOSI_PIN ... // For MAX31865 -#define MAX6675_SS_PIN THERMO_CS1_PIN -#define MAX6675_SS2_PIN THERMO_CS2_PIN -#define MAX6675_SCK_PIN THERMO_SCK_PIN -#define MAX6675_DO_PIN THERMO_DO_PIN +#define TEMP_1_CS_PIN 2 // E4 +#define TEMP_1_SCK_PIN TEMP_0_SCK_PIN +#define TEMP_1_MISO_PIN TEMP_0_MISO_PIN +//#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN // // Augmentation for auto-assigning plugs diff --git a/Marlin/src/pins/mega/pins_PICA.h b/Marlin/src/pins/mega/pins_PICA.h index 81f6319377..47c101711c 100644 --- a/Marlin/src/pins/mega/pins_PICA.h +++ b/Marlin/src/pins/mega/pins_PICA.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * Arduino Mega with PICA pin assignments @@ -117,11 +118,11 @@ #define SSR_PIN 6 -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/mega/pins_PICAOLD.h b/Marlin/src/pins/mega/pins_PICAOLD.h index f53a4cdcd2..e19ea744e5 100644 --- a/Marlin/src/pins/mega/pins_PICAOLD.h +++ b/Marlin/src/pins/mega/pins_PICAOLD.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once #define HEATER_0_PIN 9 // E0 #define HEATER_1_PIN 10 // E1 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index b0463d4498..b3e1605613 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -216,7 +216,7 @@ #elif MB(CNCONTROLS_15) #include "mega/pins_CNCONTROLS_15.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 #elif MB(MIGHTYBOARD_REVE) - #include "mega/pins_MIGHTYBOARD_REVE.h" // ATmega2560, ATmega1280 env:mega2560ext env:mega1280 + #include "mega/pins_MIGHTYBOARD_REVE.h" // ATmega2560, ATmega1280 env:mega2560ext env:mega1280 env:MightyBoard1280 env:MightyBoard2560 #elif MB(CHEAPTRONIC) #include "mega/pins_CHEAPTRONIC.h" // ATmega2560 env:mega2560 #elif MB(CHEAPTRONIC_V2) @@ -466,7 +466,7 @@ #elif MB(STM32F103RE) #include "stm32f1/pins_STM32F1R.h" // STM32F103RE env:STM32F103RE env:STM32F103RE_maple #elif MB(MALYAN_M200) - #include "stm32f1/pins_MALYAN_M200.h" // STM32F103CB env:STM32F103CB_malyan + #include "stm32f1/pins_MALYAN_M200.h" // STM32F103CB env:STM32F103CB_malyan env:STM32F103CB_malyan_maple #elif MB(STM3R_MINI) #include "stm32f1/pins_STM3R_MINI.h" // STM32F103VE? env:STM32F103VE env:STM32F103RE_maple #elif MB(GTM32_PRO_VB) @@ -486,17 +486,17 @@ #elif MB(MKS_ROBIN) #include "stm32f1/pins_MKS_ROBIN.h" // STM32F1 env:mks_robin env:mks_robin_maple #elif MB(MKS_ROBIN_MINI) - #include "stm32f1/pins_MKS_ROBIN_MINI.h" // STM32F1 env:mks_robin_mini + #include "stm32f1/pins_MKS_ROBIN_MINI.h" // STM32F1 env:mks_robin_mini env:mks_robin_mini_maple #elif MB(MKS_ROBIN_NANO) #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano35 env:mks_robin_nano35_maple #elif MB(MKS_ROBIN_NANO_V2) #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano35 env:mks_robin_nano35_maple #elif MB(MKS_ROBIN_LITE) - #include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite + #include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite env:mks_robin_lite_maple #elif MB(MKS_ROBIN_LITE3) - #include "stm32f1/pins_MKS_ROBIN_LITE3.h" // STM32F1 env:mks_robin_lite3 + #include "stm32f1/pins_MKS_ROBIN_LITE3.h" // STM32F1 env:mks_robin_lite3 env:mks_robin_lite3_maple #elif MB(MKS_ROBIN_PRO) - #include "stm32f1/pins_MKS_ROBIN_PRO.h" // STM32F1 env:mks_robin_pro + #include "stm32f1/pins_MKS_ROBIN_PRO.h" // STM32F1 env:mks_robin_pro env:mks_robin_pro_maple #elif MB(MKS_ROBIN_E3) #include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3 env:mks_robin_e3_maple #elif MB(MKS_ROBIN_E3_V1_1) @@ -506,37 +506,39 @@ #elif MB(MKS_ROBIN_E3D_V1_1) #include "stm32f1/pins_MKS_ROBIN_E3D_V1_1.h" // STM32F1 env:mks_robin_e3 #elif MB(MKS_ROBIN_E3P) - #include "stm32f1/pins_MKS_ROBIN_E3P.h" // STM32F1 env:mks_robin_e3p + #include "stm32f1/pins_MKS_ROBIN_E3P.h" // STM32F1 env:mks_robin_e3p env:mks_robin_e3p_maple #elif MB(BTT_SKR_MINI_V1_1) - #include "stm32f1/pins_BTT_SKR_MINI_V1_1.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple + #include "stm32f1/pins_BTT_SKR_MINI_V1_1.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple #elif MB(BTT_SKR_MINI_E3_V1_0) - #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple + #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple #elif MB(BTT_SKR_MINI_E3_V1_2) - #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple + #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple #elif MB(BTT_SKR_MINI_E3_V2_0) - #include "stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple + #include "stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple #elif MB(BTT_SKR_MINI_MZ_V1_0) - #include "stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple + #include "stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple #elif MB(BTT_SKR_E3_DIP) - #include "stm32f1/pins_BTT_SKR_E3_DIP.h" // STM32F1 env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple env:STM32F103RC_btt env:STM32F103RC_btt_512K + #include "stm32f1/pins_BTT_SKR_E3_DIP.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple #elif MB(BTT_SKR_CR6) #include "stm32f1/pins_BTT_SKR_CR6.h" // STM32F1 env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple #elif MB(JGAURORA_A5S_A1) - #include "stm32f1/pins_JGAURORA_A5S_A1.h" // STM32F1 env:jgaurora_a5s_a1 + #include "stm32f1/pins_JGAURORA_A5S_A1.h" // STM32F1 env:jgaurora_a5s_a1 env:jgaurora_a5s_a1_maple #elif MB(FYSETC_AIO_II) - #include "stm32f1/pins_FYSETC_AIO_II.h" // STM32F1 env:STM32F103RC_fysetc + #include "stm32f1/pins_FYSETC_AIO_II.h" // STM32F1 env:STM32F103RC_fysetc env:STM32F103RC_fysetc_maple #elif MB(FYSETC_CHEETAH) - #include "stm32f1/pins_FYSETC_CHEETAH.h" // STM32F1 env:STM32F103RC_fysetc + #include "stm32f1/pins_FYSETC_CHEETAH.h" // STM32F1 env:STM32F103RC_fysetc env:STM32F103RC_fysetc_maple #elif MB(FYSETC_CHEETAH_V12) - #include "stm32f1/pins_FYSETC_CHEETAH_V12.h" // STM32F1 env:STM32F103RC_fysetc + #include "stm32f1/pins_FYSETC_CHEETAH_V12.h" // STM32F1 env:STM32F103RC_fysetc env:STM32F103RC_fysetc_maple #elif MB(LONGER3D_LK) - #include "stm32f1/pins_LONGER3D_LK.h" // STM32F1 env:STM32F103VE_longer + #include "stm32f1/pins_LONGER3D_LK.h" // STM32F1 env:STM32F103VE_longer env:STM32F103VE_longer_maple #elif MB(CCROBOT_MEEB_3DP) #include "stm32f1/pins_CCROBOT_MEEB_3DP.h" // STM32F1 env:STM32F103RC_meeb #elif MB(CHITU3D_V5) - #include "stm32f1/pins_CHITU3D_V5.h" // STM32F1 env:chitu_f103 env:chitu_v5_gpio_init + #include "stm32f1/pins_CHITU3D_V5.h" // STM32F1 env:chitu_f103 env:chitu_f103_maple env:chitu_v5_gpio_init env:chitu_v5_gpio_init_maple #elif MB(CHITU3D_V6) - #include "stm32f1/pins_CHITU3D_V6.h" // STM32F1 env:chitu_f103 + #include "stm32f1/pins_CHITU3D_V6.h" // STM32F1 env:chitu_f103 env:chitu_f103_maple +#elif MB(CHITU3D_V9) + #include "stm32f1/pins_CHITU3D_V9.h" // STM32F1 env:chitu_f103 env:chitu_f103_maple #elif MB(CREALITY_V4) #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple #elif MB(CREALITY_V4210) @@ -550,9 +552,9 @@ #elif MB(CREALITY_V453) #include "stm32f1/pins_CREALITY_V453.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple #elif MB(TRIGORILLA_PRO) - #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro + #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro env:trigorilla_pro_maple #elif MB(FLY_MINI) - #include "stm32f1/pins_FLY_MINI.h" // STM32F1 env:FLY_MINI + #include "stm32f1/pins_FLY_MINI.h" // STM32F1 env:FLY_MINI env:FLY_MINI_maple #elif MB(FLSUN_HISPEED) #include "stm32f1/pins_FLSUN_HISPEED.h" // STM32F1 env:flsun_hispeedv1 #elif MB(BEAST) @@ -594,9 +596,9 @@ #elif MB(BTT_E3_RRF) #include "stm32f4/pins_BTT_E3_RRF.h" // STM32F4 env:BIGTREE_E3_RRF #elif MB(BTT_SKR_V2_0_REV_A) - #include "stm32f4/pins_BTT_SKR_V2_0_REV_A.h" // STM32F4 env:BIGTREE_SKR_2 + #include "stm32f4/pins_BTT_SKR_V2_0_REV_A.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB #elif MB(BTT_SKR_V2_0_REV_B) - #include "stm32f4/pins_BTT_SKR_V2_0_REV_B.h" // STM32F4 env:BIGTREE_SKR_2 + #include "stm32f4/pins_BTT_SKR_V2_0_REV_B.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB #elif MB(BTT_OCTOPUS_V1_0) #include "stm32f4/pins_BTT_OCTOPUS_V1_0.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB #elif MB(BTT_OCTOPUS_V1_1) @@ -610,11 +612,11 @@ #elif MB(VAKE403D) #include "stm32f4/pins_VAKE403D.h" // STM32F4 #elif MB(FYSETC_S6) - #include "stm32f4/pins_FYSETC_S6.h" // STM32F4 env:FYSETC_S6 + #include "stm32f4/pins_FYSETC_S6.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 #elif MB(FYSETC_S6_V2_0) - #include "stm32f4/pins_FYSETC_S6_V2_0.h" // STM32F4 env:FYSETC_S6 + #include "stm32f4/pins_FYSETC_S6_V2_0.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 #elif MB(FYSETC_SPIDER) - #include "stm32f4/pins_FYSETC_SPIDER.h" // STM32F4 env:FYSETC_S6 + #include "stm32f4/pins_FYSETC_SPIDER.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 #elif MB(FLYF407ZG) #include "stm32f4/pins_FLYF407ZG.h" // STM32F4 env:FLYF407ZG #elif MB(MKS_ROBIN2) @@ -629,6 +631,8 @@ #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_OpenBLT #elif MB(FYSETC_CHEETAH_V20) #include "stm32f4/pins_FYSETC_CHEETAH_V20.h" // STM32F4 env:FYSETC_CHEETAH_V20 +#elif MB(MKS_MONSTER8) + #include "stm32f4/pins_MKS_MONSTER8.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc // // ARM Cortex M7 @@ -679,7 +683,7 @@ // #elif MB(LINUX_RAMPS) - #include "linux/pins_RAMPS_LINUX.h" // Linux env:linux_native + #include "linux/pins_RAMPS_LINUX.h" // Native or Simulation lin:linux_native mac:simulator_macos_debug mac:simulator_macos_release win:simulator_windows lin:simulator_linux_debug lin:simulator_linux_release #else diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 1ab7188b70..8b1cad3a7c 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -760,17 +760,29 @@ #if PIN_EXISTS(LED_RED) REPORT_NAME_DIGITAL(__LINE__, LED_RED_PIN) #endif -#if PIN_EXISTS(MAX6675_DO) - REPORT_NAME_DIGITAL(__LINE__, MAX6675_DO_PIN) +#if PIN_EXISTS(TEMP_0_CS) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_CS_PIN) #endif -#if PIN_EXISTS(MAX6675_SCK) - REPORT_NAME_DIGITAL(__LINE__, MAX6675_SCK_PIN) +#if PIN_EXISTS(TEMP_0_SCK) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_SCK_PIN) #endif -#if PIN_EXISTS(MAX6675_SS) - REPORT_NAME_DIGITAL(__LINE__, MAX6675_SS_PIN) +#if PIN_EXISTS(TEMP_0_MOSI) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_MOSI_PIN) #endif -#if PIN_EXISTS(MAX6675_SS2) - REPORT_NAME_DIGITAL(__LINE__, MAX6675_SS2_PIN) +#if PIN_EXISTS(TEMP_0_MISO) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_MISO_PIN) +#endif +#if PIN_EXISTS(TEMP_1_CS) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_CS_PIN) +#endif +#if PIN_EXISTS(TEMP_1_SCK) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_SCK_PIN) +#endif +#if PIN_EXISTS(TEMP_1_MOSI) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_MOSI_PIN) +#endif +#if PIN_EXISTS(TEMP_1_MISO) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_MISO_PIN) #endif #if PIN_EXISTS(MAX7219_CLK) REPORT_NAME_DIGITAL(__LINE__, MAX7219_CLK_PIN) @@ -1010,18 +1022,6 @@ #if PIN_EXISTS(SUICIDE) REPORT_NAME_DIGITAL(__LINE__, SUICIDE_PIN) #endif -#if PIN_EXISTS(THERMO_CS1) - REPORT_NAME_DIGITAL(__LINE__, THERMO_CS1_PIN) -#endif -#if PIN_EXISTS(THERMO_CS2) - REPORT_NAME_DIGITAL(__LINE__, THERMO_CS2_PIN) -#endif -#if PIN_EXISTS(THERMO_DO) - REPORT_NAME_DIGITAL(__LINE__, THERMO_DO_PIN) -#endif -#if PIN_EXISTS(THERMO_SCK) - REPORT_NAME_DIGITAL(__LINE__, THERMO_SCK_PIN) -#endif #if PIN_EXISTS(TLC_BLANK) REPORT_NAME_DIGITAL(__LINE__, TLC_BLANK_PIN) #endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index 31031c9589..f7152770e5 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -212,6 +212,15 @@ #if !AXIS_HAS_SPI(Z) #undef Z_CS_PIN #endif +#if !AXIS_HAS_SPI(I) + #undef I_CS_PIN +#endif +#if !AXIS_HAS_SPI(J) + #undef J_CS_PIN +#endif +#if !AXIS_HAS_SPI(K) + #undef K_CS_PIN +#endif #if E_STEPPERS && !AXIS_HAS_SPI(E0) #undef E0_CS_PIN #endif @@ -246,6 +255,15 @@ #ifndef Z_CS_PIN #define Z_CS_PIN -1 #endif +#ifndef I_CS_PIN + #define I_CS_PIN -1 +#endif +#ifndef J_CS_PIN + #define J_CS_PIN -1 +#endif +#ifndef K_CS_PIN + #define K_CS_PIN -1 +#endif #ifndef E0_CS_PIN #define E0_CS_PIN -1 #endif @@ -525,9 +543,17 @@ #define _EPIN(p,q) __EPIN(p,q) #define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN) -// The X2 axis, if any, should be the next open extruder port -#define X2_E_INDEX E_STEPPERS +// The E0/E1 steppers are always used for Dual E +#if ENABLED(E_DUAL_STEPPER_DRIVERS) + #ifndef E1_STEP_PIN + #error "No E1 stepper available for E_DUAL_STEPPER_DRIVERS!" + #endif + #define X2_E_INDEX INCREMENT(E_STEPPERS) +#else + #define X2_E_INDEX E_STEPPERS +#endif +// The X2 axis, if any, should be the next open extruder port #if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS) #ifndef X2_STEP_PIN #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP) @@ -791,6 +817,8 @@ #undef Z3_DIAG_PIN #endif #define Z4_E_INDEX INCREMENT(Z3_E_INDEX) +#else + #define Z4_E_INDEX Z3_E_INDEX #endif #ifndef Z3_CS_PIN @@ -858,6 +886,9 @@ #endif #undef Z4_DIAG_PIN #endif + #define I_E_INDEX INCREMENT(Z4_E_INDEX) +#else + #define I_E_INDEX Z4_E_INDEX #endif #ifndef Z4_CS_PIN @@ -873,6 +904,213 @@ #define Z4_MS3_PIN -1 #endif +#if LINEAR_AXES >= 4 + #ifndef I_STEP_PIN + #define I_STEP_PIN _EPIN(I_E_INDEX, STEP) + #define I_DIR_PIN _EPIN(I_E_INDEX, DIR) + #define I_ENABLE_PIN _EPIN(I_E_INDEX, ENABLE) + #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(I_STEP) + #error "No E stepper plug left for I!" + #endif + #endif + #if AXIS_HAS_SPI(I) + #ifndef I_CS_PIN + #define I_CS_PIN _EPIN(I_E_INDEX, CS) + #endif + #endif + #ifndef I_MS1_PIN + #define I_MS1_PIN _EPIN(I_E_INDEX, MS1) + #endif + #ifndef I_MS2_PIN + #define I_MS2_PIN _EPIN(I_E_INDEX, MS2) + #endif + #ifndef I_MS3_PIN + #define I_MS3_PIN _EPIN(I_E_INDEX, MS3) + #endif + #if AXIS_HAS_UART(I) + #ifndef I_SERIAL_TX_PIN + #define I_SERIAL_TX_PIN _EPIN(I_E_INDEX, SERIAL_TX) + #endif + #ifndef I_SERIAL_RX_PIN + #define I_SERIAL_RX_PIN _EPIN(I_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG) + #define I_DIAG_PIN _EPIN(I_E_INDEX, DIAG) + #if DIAG_REMAPPED(I, X_MIN) + #define I_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(I, Y_MIN) + #define I_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(I, Z_MIN) + #define I_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(I, X_MAX) + #define I_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(I, Y_MAX) + #define I_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(I, Z_MAX) + #define I_USE_ENDSTOP _ZMAX_ + #else + #define _I_USE_ENDSTOP(P) _E##P##_DIAG_ + #define I_USE_ENDSTOP _I_USE_ENDSTOP(I_E_INDEX) + #endif + #undef I_DIAG_PIN + #endif + #define J_E_INDEX INCREMENT(I_E_INDEX) +#else + #define J_E_INDEX I_E_INDEX +#endif + +#ifndef I_CS_PIN + #define I_CS_PIN -1 +#endif +#ifndef I_MS1_PIN + #define I_MS1_PIN -1 +#endif +#ifndef I_MS2_PIN + #define I_MS2_PIN -1 +#endif +#ifndef I_MS3_PIN + #define I_MS3_PIN -1 +#endif + +#if LINEAR_AXES >= 5 + #ifndef J_STEP_PIN + #define J_STEP_PIN _EPIN(J_E_INDEX, STEP) + #define J_DIR_PIN _EPIN(J_E_INDEX, DIR) + #define J_ENABLE_PIN _EPIN(J_E_INDEX, ENABLE) + #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(J_STEP) + #error "No E stepper plug left for J!" + #endif + #endif + #if AXIS_HAS_SPI(J) + #ifndef J_CS_PIN + #define J_CS_PIN _EPIN(J_E_INDEX, CS) + #endif + #endif + #ifndef J_MS1_PIN + #define J_MS1_PIN _EPIN(J_E_INDEX, MS1) + #endif + #ifndef J_MS2_PIN + #define J_MS2_PIN _EPIN(J_E_INDEX, MS2) + #endif + #ifndef J_MS3_PIN + #define J_MS3_PIN _EPIN(J_E_INDEX, MS3) + #endif + #if AXIS_HAS_UART(J) + #ifndef J_SERIAL_TX_PIN + #define J_SERIAL_TX_PIN _EPIN(J_E_INDEX, SERIAL_TX) + #endif + #ifndef J_SERIAL_RX_PIN + #define J_SERIAL_RX_PIN _EPIN(J_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG) + #define J_DIAG_PIN _EPIN(J_E_INDEX, DIAG) + #if DIAG_REMAPPED(J, X_MIN) + #define J_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(J, Y_MIN) + #define J_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(J, Z_MIN) + #define J_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(J, X_MAX) + #define J_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(J, Y_MAX) + #define J_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(I, Z_MAX) + #define J_USE_ENDSTOP _ZMAX_ + #else + #define _J_USE_ENDSTOP(P) _E##P##_DIAG_ + #define J_USE_ENDSTOP _J_USE_ENDSTOP(J_E_INDEX) + #endif + #undef J_DIAG_PIN + #endif + #define K_E_INDEX INCREMENT(J_E_INDEX) +#else + #define K_E_INDEX J_E_INDEX +#endif + +#ifndef J_CS_PIN + #define J_CS_PIN -1 +#endif +#ifndef J_MS1_PIN + #define J_MS1_PIN -1 +#endif +#ifndef J_MS2_PIN + #define J_MS2_PIN -1 +#endif +#ifndef J_MS3_PIN + #define J_MS3_PIN -1 +#endif + +#if LINEAR_AXES >= 6 + #ifndef K_STEP_PIN + #define K_STEP_PIN _EPIN(K_E_INDEX, STEP) + #define K_DIR_PIN _EPIN(K_E_INDEX, DIR) + #define K_ENABLE_PIN _EPIN(K_E_INDEX, ENABLE) + #if K_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(K_STEP) + #error "No E stepper plug left for K!" + #endif + #endif + #if AXIS_HAS_SPI(K) + #ifndef K_CS_PIN + #define K_CS_PIN _EPIN(K_E_INDEX, CS) + #endif + #endif + #ifndef K_MS1_PIN + #define K_MS1_PIN _EPIN(K_E_INDEX, MS1) + #endif + #ifndef K_MS2_PIN + #define K_MS2_PIN _EPIN(K_E_INDEX, MS2) + #endif + #ifndef K_MS3_PIN + #define K_MS3_PIN _EPIN(K_E_INDEX, MS3) + #endif + #if AXIS_HAS_UART(K) + #ifndef K_SERIAL_TX_PIN + #define K_SERIAL_TX_PIN _EPIN(K_E_INDEX, SERIAL_TX) + #endif + #ifndef K_SERIAL_RX_PIN + #define K_SERIAL_RX_PIN _EPIN(K_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG) + #define K_DIAG_PIN _EPIN(K_E_INDEX, DIAG) + #if DIAG_REMAPPED(K, X_MIN) + #define K_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(K, Y_MIN) + #define K_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(K, Z_MIN) + #define K_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(K, X_MAX) + #define K_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(K, Y_MAX) + #define K_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(K, Z_MAX) + #define K_USE_ENDSTOP _ZMAX_ + #else + #define _K_USE_ENDSTOP(P) _E##P##_DIAG_ + #define K_USE_ENDSTOP _K_USE_ENDSTOP(K_E_INDEX) + #endif + #undef K_DIAG_PIN + #endif +#endif + +#ifndef K_CS_PIN + #define K_CS_PIN -1 +#endif +#ifndef K_MS1_PIN + #define K_MS1_PIN -1 +#endif +#ifndef K_MS2_PIN + #define K_MS2_PIN -1 +#endif +#ifndef K_MS3_PIN + #define K_MS3_PIN -1 +#endif + // // Disable unused endstop / probe pins // @@ -896,47 +1134,59 @@ #define USE_ZMIN_PLUG #endif #undef _STOP_IN_USE -#if !HAS_CUSTOM_PROBE_PIN +#if !USES_Z_MIN_PROBE_PIN #undef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN -1 #endif +#if DISABLED(USE_XMIN_PLUG) + #undef X_MIN_PIN + #define X_MIN_PIN -1 +#endif #if DISABLED(USE_XMAX_PLUG) #undef X_MAX_PIN #define X_MAX_PIN -1 #endif +#if DISABLED(USE_YMIN_PLUG) + #undef Y_MIN_PIN + #define Y_MIN_PIN -1 +#endif #if DISABLED(USE_YMAX_PLUG) #undef Y_MAX_PIN #define Y_MAX_PIN -1 #endif +#if DISABLED(USE_ZMIN_PLUG) + #undef Z_MIN_PIN + #define Z_MIN_PIN -1 +#endif #if DISABLED(USE_ZMAX_PLUG) #undef Z_MAX_PIN #define Z_MAX_PIN -1 #endif +#if DISABLED(USE_IMIN_PLUG) + #undef I_MIN_PIN + #define I_MIN_PIN -1 +#endif #if DISABLED(USE_IMAX_PLUG) #undef I_MAX_PIN #define I_MAX_PIN -1 #endif +#if DISABLED(USE_JMIN_PLUG) + #undef J_MIN_PIN + #define J_MIN_PIN -1 +#endif #if DISABLED(USE_JMAX_PLUG) #undef J_MAX_PIN #define J_MAX_PIN -1 #endif +#if DISABLED(USE_KMIN_PLUG) + #undef K_MIN_PIN + #define K_MIN_PIN -1 +#endif #if DISABLED(USE_KMAX_PLUG) #undef K_MAX_PIN #define K_MAX_PIN -1 #endif -#if DISABLED(USE_XMIN_PLUG) - #undef X_MIN_PIN - #define X_MIN_PIN -1 -#endif -#if DISABLED(USE_YMIN_PLUG) - #undef Y_MIN_PIN - #define Y_MIN_PIN -1 -#endif -#if DISABLED(USE_ZMIN_PLUG) - #undef Z_MIN_PIN - #define Z_MIN_PIN -1 -#endif #if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MAX #undef X2_MIN_PIN #endif @@ -968,19 +1218,6 @@ #undef Z4_MAX_PIN #endif -#if DISABLED(USE_IMIN_PLUG) - #undef I_MIN_PIN - #define I_MIN_PIN -1 -#endif -#if DISABLED(USE_JMIN_PLUG) - #undef J_MIN_PIN - #define J_MIN_PIN -1 -#endif -#if DISABLED(USE_KMIN_PLUG) - #undef K_MIN_PIN - #define K_MIN_PIN -1 -#endif - // // Default DOGLCD SPI delays // diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index fb7743605f..78465dd7a8 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -114,10 +114,11 @@ // // Temperature Sensors // -#define TEMP_0_PIN 0 // Analog Input -#define TEMP_1_PIN 1 // Analog Input -#define TEMP_BED_PIN 2 // Analog Input -#define TEMP_PROBE_PIN 3 // Analog Input +#define TEMP_0_PIN 0 // Analog Input, Header J2 +#define TEMP_1_PIN 1 // Analog Input, Header J3 +#define TEMP_BOARD_PIN 91 // Onboard thermistor, 100k TDK NTCG104LH104JT1 +#define TEMP_BED_PIN 2 // Analog Input, Header J6 +#define TEMP_PROBE_PIN 3 // Analog Input, Header J15 // // Heaters / Fans @@ -135,9 +136,9 @@ #ifndef FAN1_PIN #ifdef MK3_FAN_PINS - #define FAN_PIN -1 + #define FAN1_PIN -1 #else - #define FAN_PIN 6 + #define FAN1_PIN 6 #endif #endif diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 5d6f9c1fd0..f2d34dc00d 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -171,10 +171,10 @@ #define SPINDLE_DIR_PIN 32 // -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple // -#ifndef MAX6675_SS_PIN - #define MAX6675_SS_PIN 32 // SPINDLE_DIR_PIN / STAT_LED_BLUE_PIN +#ifndef TEMP_0_CS_PIN + #define TEMP_0_CS_PIN 32 // SPINDLE_DIR_PIN / STAT_LED_BLUE_PIN #endif // diff --git a/Marlin/src/pins/ramps/pins_DAGOMA_F5.h b/Marlin/src/pins/ramps/pins_DAGOMA_F5.h index 07e46acfe7..8dc93c833b 100644 --- a/Marlin/src/pins/ramps/pins_DAGOMA_F5.h +++ b/Marlin/src/pins/ramps/pins_DAGOMA_F5.h @@ -51,7 +51,7 @@ // // DAC steppers // -#define HAS_MOTOR_CURRENT_DAC +#define HAS_MOTOR_CURRENT_DAC 1 #define DAC_STEPPER_ORDER { 0, 1, 2, 3 } diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h index 383501caaa..34a4ceb27d 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h @@ -114,11 +114,11 @@ #define TEMP_1_PIN 15 // Analog Input #define TEMP_BED_PIN 14 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h index ac0b7428f4..5f645e5d95 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h @@ -111,11 +111,11 @@ #define TEMP_1_PIN 15 // Analog Input #define TEMP_BED_PIN 3 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h index 76a9fbe628..c953cff3d0 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h @@ -111,11 +111,11 @@ #define TEMP_1_PIN 15 // Analog Input #define TEMP_BED_PIN 14 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_K8600.h b/Marlin/src/pins/ramps/pins_K8600.h index c2d91ad7ee..47b52e75e8 100644 --- a/Marlin/src/pins/ramps/pins_K8600.h +++ b/Marlin/src/pins/ramps/pins_K8600.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * VERTEX NANO Arduino Mega with RAMPS EFB v1.4 pin assignments. diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index c2d4dbeb3f..2c271408b0 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -167,10 +167,10 @@ #endif // -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple // -#ifndef MAX6675_SS_PIN - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card (SDSS) or 49 (SD_DETECT_PIN) +#ifndef TEMP_0_CS_PIN + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card (SDSS) or 49 (SD_DETECT_PIN) #endif // @@ -219,7 +219,7 @@ #define FAN1_PIN RAMPS_D8_PIN #elif DISABLED(IS_RAMPS_SF) // Not Spindle, Fan (i.e., "EFBF" or "EFBE") #define HEATER_BED_PIN RAMPS_D8_PIN - #if HOTENDS == 1 + #if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) #define FAN1_PIN MOSFET_D_PIN #else #define HEATER_1_PIN MOSFET_D_PIN @@ -655,7 +655,9 @@ #define BEEPER_PIN EXP1_10_PIN #define BTN_ENC EXP1_09_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_04_PIN + #endif #ifndef KILL_PIN #define KILL_PIN EXP2_03_PIN diff --git a/Marlin/src/pins/ramps/pins_RAMPS_OLD.h b/Marlin/src/pins/ramps/pins_RAMPS_OLD.h index a43ee3c6ca..9747666235 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_OLD.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_OLD.h @@ -74,11 +74,11 @@ #define TEMP_0_PIN 2 // Analog Input #define TEMP_BED_PIN 1 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h index 345c51d5de..203af5e081 100644 --- a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h +++ b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h @@ -75,12 +75,12 @@ #define TEMP_1_PIN 13 // Analog Input #define TEMP_BED_PIN 15 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple -#undef MAX6675_SS_PIN +// SPI for MAX Thermocouple +#undef TEMP_0_CS_PIN #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 // Don't use pin 53 if there is even the remote possibility of using Display/SD card + #define TEMP_0_CS_PIN 53 // Don't use pin 53 if there is even the remote possibility of using Display/SD card #else - #define MAX6675_SS_PIN 49 // Don't use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present + #define TEMP_0_CS_PIN 49 // Don't use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present #endif // diff --git a/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h b/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h index 1428de31a2..5a6bba3c08 100644 --- a/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h +++ b/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h @@ -34,7 +34,7 @@ // // I2C based DAC like on the Printrboard REVF -#define HAS_MOTOR_CURRENT_DAC +#define HAS_MOTOR_CURRENT_DAC 1 // Channels available for DAC, For Rigidboard there are 4 #define DAC_STEPPER_ORDER { 0, 1, 2, 3 } diff --git a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h index 53e419af00..de8db60847 100644 --- a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h +++ b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h @@ -123,11 +123,11 @@ #define TEMP_1_PIN 15 // Analog Input #define TEMP_BED_PIN 14 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN -1 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN -1 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN -1 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN -1 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index 18d0f1770e..57a9a560d3 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once #include "env_validate.h" @@ -180,11 +181,11 @@ #define TEMP_4_PIN 12 #endif -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple //#if DISABLED(SDSUPPORT) -// #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card +// #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card //#else -// #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) +// #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) //#endif // diff --git a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h index a63c337880..d44f6490da 100644 --- a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h +++ b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * CNControls V15 for HMS434 with DUE pin assignments diff --git a/Marlin/src/pins/sam/pins_DUE3DOM.h b/Marlin/src/pins/sam/pins_DUE3DOM.h index de3cb33e8d..81eca3e4b1 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM.h @@ -82,11 +82,11 @@ #define TEMP_2_PIN 5 // Analog Input (unused) #define TEMP_BED_PIN 1 // Analog Input (BED thermistor) -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN -1 + #define TEMP_0_CS_PIN -1 #else - #define MAX6675_SS_PIN -1 + #define TEMP_0_CS_PIN -1 #endif // diff --git a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h index c52199a54d..7754fa9329 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h @@ -68,14 +68,14 @@ // #define TEMP_0_PIN 0 // Analog Input (HOTEND0 thermistor) #define TEMP_1_PIN 2 // Analog Input (unused) -#define TEMP_2_PIN 5 // Analog Input (OnBoard thermistor beta 3950) #define TEMP_BED_PIN 1 // Analog Input (BED thermistor) +#define TEMP_BOARD_PIN 5 // Analog Input (OnBoard thermistor beta 3950) -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #endif // diff --git a/Marlin/src/pins/sam/pins_RADDS.h b/Marlin/src/pins/sam/pins_RADDS.h index 7b0ec5ab68..7a865b4ad8 100644 --- a/Marlin/src/pins/sam/pins_RADDS.h +++ b/Marlin/src/pins/sam/pins_RADDS.h @@ -179,11 +179,11 @@ #define TEMP_4_PIN 5 // dummy so will compile when PINS_DEBUGGING is enabled #define TEMP_BED_PIN 4 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 49 + #define TEMP_0_CS_PIN 49 #endif // diff --git a/Marlin/src/pins/sam/pins_RAMPS_DUO.h b/Marlin/src/pins/sam/pins_RAMPS_DUO.h index b1a6680c50..5b2b2f0b66 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_DUO.h +++ b/Marlin/src/pins/sam/pins_RAMPS_DUO.h @@ -60,12 +60,12 @@ #undef TEMP_BED_PIN #define TEMP_BED_PIN 10 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple -#undef MAX6675_SS_PIN +// SPI for MAX Thermocouple +#undef TEMP_0_CS_PIN #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 69 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 69 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 69 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 69 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h index e4c53530f7..30f209ad37 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h +++ b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h @@ -109,11 +109,11 @@ #define TEMP_2_PIN 3 // Analog Input #define TEMP_BED_PIN 0 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 49 + #define TEMP_0_CS_PIN 49 #endif // diff --git a/Marlin/src/pins/sam/pins_RAMPS_SMART.h b/Marlin/src/pins/sam/pins_RAMPS_SMART.h index 3882dfb944..96d0c9e1cc 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_SMART.h +++ b/Marlin/src/pins/sam/pins_RAMPS_SMART.h @@ -94,12 +94,12 @@ #undef TEMP_BED_PIN #define TEMP_BED_PIN 11 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple -#undef MAX6675_SS_PIN +// SPI for MAX Thermocouple +#undef TEMP_0_CS_PIN #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 67 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 67 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 67 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 67 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index 908bbc6b22..b5569c810d 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -20,6 +20,7 @@ * * Ported sys0724 & Vynt */ +#pragma once /** * Arduino Mega? or Due with RuRAMPS4DUE pin assignments @@ -116,7 +117,7 @@ //#define E3_MS2_PIN ? //#define E3_MS3_PIN ? -#if HAS_CUSTOM_PROBE_PIN +#if USES_Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN 49 #endif @@ -155,12 +156,12 @@ #define TEMP_5_PIN 6 // A6 (Marlin 2.0 not support) #endif -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple /* #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 49 + #define TEMP_0_CS_PIN 49 #endif */ diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h index 3e73c33acb..b06de1bc69 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -20,6 +20,7 @@ * * Ported sys0724 & Vynt */ +#pragma once /** * Arduino Mega? or Due with RuRAMPS4DUE pin assignments @@ -104,7 +105,7 @@ #define E2_CS_PIN 61 #endif -#if HAS_CUSTOM_PROBE_PIN +#if USES_Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN 49 #endif @@ -141,12 +142,12 @@ #define TEMP_5_PIN 6 // A6 (Marlin 2.0 not support) #endif -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple /* #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 49 + #define TEMP_0_CS_PIN 49 #endif */ diff --git a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h index e567b0f5e1..a655d0121c 100644 --- a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h +++ b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h @@ -149,12 +149,11 @@ #define SD_MISO_PIN 74 #define SD_MOSI_PIN 75 -// SPI for Max6675 or Max31855 Thermocouple -#define MAX6675_SS_PIN 65 -#define MAX31855_SS0 65 -#define MAX31855_SS1 52 -#define MAX31855_SS2 50 -#define MAX31855_SS3 51 +// SPI for MAX Thermocouple +#define TEMP_0_CS_PIN 65 +#define TEMP_1_CS_PIN 52 +#define TEMP_2_CS_PIN 50 +#define TEMP_3_CS_PIN 51 #define ENC424_SS 61 diff --git a/Marlin/src/pins/sensitive_pins.h b/Marlin/src/pins/sensitive_pins.h index de0f65c596..7ccb0339b2 100644 --- a/Marlin/src/pins/sensitive_pins.h +++ b/Marlin/src/pins/sensitive_pins.h @@ -167,7 +167,7 @@ #else #define _I_MAX #endif - #if PIN_EXISTS(I_CS) + #if PIN_EXISTS(I_CS) && AXIS_HAS_SPI(I) #define _I_CS I_CS_PIN, #else #define _I_CS @@ -187,8 +187,13 @@ #else #define _I_MS3 #endif + #if PIN_EXISTS(I_ENABLE) + #define _I_ENABLE_PIN I_ENABLE_PIN, + #else + #define _I_ENABLE_PIN + #endif - #define _I_PINS I_STEP_PIN, I_DIR_PIN, I_ENABLE_PIN, _I_MIN _I_MAX _I_MS1 _I_MS2 _I_MS3 _I_CS + #define _I_PINS I_STEP_PIN, I_DIR_PIN, _I_ENABLE_PIN _I_MIN _I_MAX _I_MS1 _I_MS2 _I_MS3 _I_CS #else @@ -208,7 +213,7 @@ #else #define _J_MAX #endif - #if PIN_EXISTS(J_CS) + #if PIN_EXISTS(J_CS) && AXIS_HAS_SPI(J) #define _J_CS J_CS_PIN, #else #define _J_CS @@ -228,8 +233,13 @@ #else #define _J_MS3 #endif + #if PIN_EXISTS(J_ENABLE) + #define _J_ENABLE_PIN J_ENABLE_PIN, + #else + #define _J_ENABLE_PIN + #endif - #define _J_PINS J_STEP_PIN, J_DIR_PIN, J_ENABLE_PIN, _J_MIN _J_MAX _J_MS1 _J_MS2 _J_MS3 _J_CS + #define _J_PINS J_STEP_PIN, J_DIR_PIN, _J_ENABLE_PIN _J_MIN _J_MAX _J_MS1 _J_MS2 _J_MS3 _J_CS #else @@ -249,7 +259,7 @@ #else #define _K_MAX #endif - #if PIN_EXISTS(K_CS) + #if PIN_EXISTS(K_CS) && AXIS_HAS_SPI(K) #define _K_CS K_CS_PIN, #else #define _K_CS @@ -269,8 +279,13 @@ #else #define _K_MS3 #endif + #if PIN_EXISTS(K_ENABLE) + #define _K_ENABLE_PIN K_ENABLE_PIN, + #else + #define _K_ENABLE_PIN + #endif - #define _K_PINS K_STEP_PIN, K_DIR_PIN, K_ENABLE_PIN, _K_MIN _K_MAX _K_MS1 _K_MS2 _K_MS3 _K_CS + #define _K_PINS K_STEP_PIN, K_DIR_PIN, _K_ENABLE_PIN _K_MIN _K_MAX _K_MS1 _K_MS2 _K_MS3 _K_CS #else @@ -577,30 +592,32 @@ #define _H6_PINS #define _H7_PINS +#define DIO_PIN(P) TERN(TARGET_LPC1768, P, analogInputToDigitalPin(P)) + #if HAS_HOTEND #undef _H0_PINS - #define _H0_PINS HEATER_0_PIN, E0_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_0_PIN), + #define _H0_PINS HEATER_0_PIN, E0_AUTO_FAN_PIN, DIO_PIN(TEMP_0_PIN), #if HAS_MULTI_HOTEND #undef _H1_PINS - #define _H1_PINS HEATER_1_PIN, E1_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_1_PIN), + #define _H1_PINS HEATER_1_PIN, E1_AUTO_FAN_PIN, DIO_PIN(TEMP_1_PIN), #if HOTENDS > 2 #undef _H2_PINS - #define _H2_PINS HEATER_2_PIN, E2_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_2_PIN), + #define _H2_PINS HEATER_2_PIN, E2_AUTO_FAN_PIN, DIO_PIN(TEMP_2_PIN), #if HOTENDS > 3 #undef _H3_PINS - #define _H3_PINS HEATER_3_PIN, E3_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_3_PIN), + #define _H3_PINS HEATER_3_PIN, E3_AUTO_FAN_PIN, DIO_PIN(TEMP_3_PIN), #if HOTENDS > 4 #undef _H4_PINS - #define _H4_PINS HEATER_4_PIN, E4_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_4_PIN), + #define _H4_PINS HEATER_4_PIN, E4_AUTO_FAN_PIN, DIO_PIN(TEMP_4_PIN), #if HOTENDS > 5 #undef _H5_PINS - #define _H5_PINS HEATER_5_PIN, E5_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_5_PIN), + #define _H5_PINS HEATER_5_PIN, E5_AUTO_FAN_PIN, DIO_PIN(TEMP_5_PIN), #if HOTENDS > 6 #undef _H6_PINS - #define _H6_PINS HEATER_6_PIN, E6_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_6_PIN), + #define _H6_PINS HEATER_6_PIN, E6_AUTO_FAN_PIN, DIO_PIN(TEMP_6_PIN), #if HOTENDS > 7 #undef _H7_PINS - #define _H7_PINS HEATER_7_PIN, E7_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_7_PIN), + #define _H7_PINS HEATER_7_PIN, E7_AUTO_FAN_PIN, DIO_PIN(TEMP_7_PIN), #endif // HOTENDS > 7 #endif // HOTENDS > 6 #endif // HOTENDS > 5 @@ -809,13 +826,13 @@ #endif #if TEMP_SENSOR_BED && PINS_EXIST(TEMP_BED, HEATER_BED) - #define _BED_PINS HEATER_BED_PIN, analogInputToDigitalPin(TEMP_BED_PIN), + #define _BED_PINS HEATER_BED_PIN, DIO_PIN(TEMP_BED_PIN), #else #define _BED_PINS #endif #if TEMP_SENSOR_CHAMBER && PIN_EXISTS(TEMP_CHAMBER) - #define _CHAMBER_TEMP analogInputToDigitalPin(TEMP_CHAMBER_PIN), + #define _CHAMBER_TEMP DIO_PIN(TEMP_CHAMBER_PIN), #else #define _CHAMBER_TEMP #endif @@ -831,17 +848,15 @@ #endif #if TEMP_SENSOR_COOLER && PIN_EXISTS(TEMP_COOLER) - #define _COOLER_TEMP analogInputToDigitalPin(TEMP_COOLER_PIN), + #define _COOLER_TEMP DIO_PIN(TEMP_COOLER_PIN), #else #define _COOLER_TEMP #endif - #if TEMP_SENSOR_COOLER && PIN_EXISTS(COOLER) #define _COOLER COOLER_PIN, #else #define _COOLER #endif - #if TEMP_SENSOR_COOLER && PINS_EXIST(TEMP_COOLER, COOLER_AUTO_FAN) #define _COOLER_FAN COOLER_AUTO_FAN_PIN, #else @@ -852,11 +867,30 @@ #define HAL_SENSITIVE_PINS #endif -#define SENSITIVE_PINS { \ +#ifdef RUNTIME_ONLY_ANALOG_TO_DIGITAL + #define _SP_END +#else + #define _SP_END -2 + + // Move a regular pin in front to the end + template + struct OnlyPins : OnlyPins { }; + + // Remove a -1 from the front + template + struct OnlyPins<-1, D...> : OnlyPins { }; + + // Remove -2 from the front, emit the rest, cease propagation + template + struct OnlyPins<_SP_END, D...> { static constexpr size_t size = sizeof...(D); static constexpr pin_t table[sizeof...(D)] PROGMEM = { D... }; }; +#endif + +#define SENSITIVE_PINS \ _X_PINS _Y_PINS _Z_PINS _I_PINS _J_PINS _K_PINS \ _X2_PINS _Y2_PINS _Z2_PINS _Z3_PINS _Z4_PINS _Z_PROBE \ _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS _E5_PINS _E6_PINS _E7_PINS \ _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS _H5_PINS _H6_PINS _H7_PINS \ _PS_ON _FAN0 _FAN1 _FAN2 _FAN3 _FAN4 _FAN5 _FAN6 _FAN7 _FANC \ - _BED_PINS _COOLER _CHAMBER_TEMP _CHAMBER_HEATER _CHAMBER_FAN HAL_SENSITIVE_PINS \ -} + _BED_PINS _CHAMBER_TEMP _CHAMBER_HEATER _CHAMBER_FAN \ + _COOLER_TEMP _COOLER _COOLER_FAN HAL_SENSITIVE_PINS \ + _SP_END diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h index e76c77e706..63ad06dc57 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h @@ -166,16 +166,19 @@ #if SD_CONNECTION_IS(ONBOARD) #define SD_DETECT_PIN PC4 - - #define ON_BOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card #endif // // Misc. Functions // -#define LED_CONTROL_PIN PA13 +#define CASE_LIGHT_PIN PA13 #ifndef NEOPIXEL_PIN #define NEOPIXEL_PIN PA8 #endif + +#define SUICIDE_PIN PC13 +#ifndef SUICIDE_PIN_INVERTING + #define SUICIDE_PIN_INVERTING false +#endif diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index 35224ebdd0..9b71570b08 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -276,6 +276,9 @@ #if SD_CONNECTION_IS(ONBOARD) #define SD_DETECT_PIN PC4 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 #elif SD_CONNECTION_IS(LCD) && BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) #define SD_DETECT_PIN PA15 #define SD_SS_PIN PA10 @@ -285,3 +288,4 @@ #define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card +#define SDSS ONBOARD_SD_CS_PIN diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index bb356485cb..8f305542a9 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -117,14 +117,14 @@ /** * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 - * _____ _____ - * 5V | 1 2 | GND 5V | 1 2 | GND - * (LCD_EN) PB7 | 3 4 | PB8 (LCD_RS) (LCD_EN) PB15 | 3 4 | PB8 (LCD_RS) - * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) - * RESET | 7 8 | PA9 (BTN_EN1) RESET | 7 8 | PA9 (BTN_EN1) - * (BTN_ENC) PB6 | 9 10| PB5 (BEEPER) (BTN_ENC) PA15 | 9 10| PB5 (BEEPER) - * ----- ----- - * EXP1 EXP1 + * ______ ______ + * 5V | 1 2 | GND 5V | 1 2 | GND + * (LCD_EN) PB7 | 3 4 | PB8 (LCD_RS) (LCD_EN) PB15 | 3 4 | PB8 (LCD_RS) + * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) + * RESET | 7 8 | PA9 (BTN_EN1) RESET | 7 8 | PA9 (BTN_EN1) + * (BTN_ENC) PB6 | 9 10 | PB5 (BEEPER) (BTN_ENC) PA15 | 9 10 | PB5 (BEEPER) + * ------ ------ + * EXP1 EXP1 */ #ifdef SKR_MINI_E3_V2 #define EXP1_9 PA15 @@ -134,7 +134,28 @@ #define EXP1_3 PB7 #endif -#if HAS_WIRED_LCD +#if ENABLED(DWIN_CREALITY_LCD) + /** + * ------ ------ ------ + * VCC | 1 2 | GND VCC | 1 2 | GND GND | 2 1 | VCC + * A | 3 4 | B A | 3 4 | B B | 4 3 | A + * | 5 6 TX BEEP | 5 6 ENT ENT | 6 5 | BEEP + * | 7 8 | RX TX | 7 8 | RX RX | 8 7 | TX + * BEEP | 9 10 | ENT | 9 10 | | 10 9 | + * ------ ------ ------ + * EXP1 DWIN DWIN (plug) + * + * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on. + */ + + #error "DWIN_CREALITY_LCD requires a custom cable, see diagram above this line. Comment out this line to continue." + + #define BEEPER_PIN EXP1_9 + #define BTN_EN1 EXP1_3 + #define BTN_EN2 PB8 + #define BTN_ENC PB5 + +#elif HAS_WIRED_LCD #if ENABLED(CR10_STOCKDISPLAY) @@ -184,19 +205,19 @@ * TFTGLCD_PANEL_SPI display pinout * * Board Display - * _____ _____ - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) LCD_CS | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 | PA10 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | (FREE) - * (BEEPER) PB6 | 9 10| PB5 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * ______ ______ + * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) LCD_CS | 3 4 | SD_CS (PA10) + * (FREE) PB9 | 5 6 | PA10 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) + * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | (FREE) + * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * - * Board Adapter Display - * _________ + * Board Display + * * EXP1-1 ----------- EXP1-10 * EXP1-2 ----------- EXP1-9 * SPI1-4 ----------- EXP1-6 @@ -223,17 +244,18 @@ #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." - /** FYSETC TFT TFT81050 display pinout + /** + * FYSETC TFT TFT81050 display pinout * * Board Display - * _____ _____ - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 | PA10 (SD_CS) (PB8) LCD_CS | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | RESET - * (BEEPER) PB6 | 9 10| PB5 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * ______ ______ + * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) + * (FREE) PB9 | 5 6 | PA10 (SD_CS) (PB8) LCD_CS | 5 6 | MOSI (SPI1-MOSI) + * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | RESET + * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * @@ -280,11 +302,8 @@ #define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1... #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card -#define CUSTOM_SPI_PINS // TODO: needed because is the only way to set SPI for SD on STM32 (for now) -#if ENABLED(CUSTOM_SPI_PINS) - #define ENABLE_SPI1 - #define SDSS ONBOARD_SD_CS_PIN - #define SD_SCK_PIN PA5 - #define SD_MISO_PIN PA6 - #define SD_MOSI_PIN PA7 -#endif +#define ENABLE_SPI1 +#define SDSS ONBOARD_SD_CS_PIN +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D.h b/Marlin/src/pins/stm32f1/pins_CHITU3D.h index c2025ba8c0..2d33fb9f2c 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D.h @@ -81,12 +81,7 @@ // Heaters / Fans // #define HEATER_0_PIN PD12 // HOT-END -#define HEATER_1_PIN -1 -#define HEATER_2_PIN -1 - #define HEATER_BED_PIN PG11 // HOT-BED -#define HEATER_BED2_PIN -1 // BED2 -#define HEATER_BED3_PIN -1 // BED3 #ifndef FAN_PIN #define FAN_PIN PG14 // MAIN BOARD FAN @@ -97,8 +92,8 @@ // // Temperature Sensors // -#define TEMP_BED_PIN PA0 // Analog Input #define TEMP_0_PIN PA1 // Analog Input +#define TEMP_BED_PIN PA0 // Analog Input // // LCD Pins diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h index d25a1f34f9..afe58df803 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h @@ -21,167 +21,8 @@ */ #pragma once -#include "env_validate.h" +#define BOARD_INFO_NAME "Chitu3D V5" -/** - * 2017 Victor Perez Marlin for stm32f1 test - */ +#define Z_STOP_PIN PG9 -#define BOARD_INFO_NAME "Chitu3D V5" -#define DEFAULT_MACHINE_NAME "STM32F103ZET6" - -#define BOARD_NO_NATIVE_USB - -#define DISABLE_JTAG - -// -// EEPROM -// -#define FLASH_EEPROM_EMULATION -#if ENABLED(FLASH_EEPROM_EMULATION) - // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) - #define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE) - #define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE -#else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM -#endif - -// -// Limit Switches -// -#define X_STOP_PIN PG10 -#define Y_STOP_PIN PA12 -#define Z_STOP_PIN PA14 - -// -// Steppers -// -#define X_ENABLE_PIN PC13 -#define X_STEP_PIN PE5 -#define X_DIR_PIN PE6 - -#define Y_ENABLE_PIN PE4 -#define Y_STEP_PIN PE2 -#define Y_DIR_PIN PE3 - -#define Z_ENABLE_PIN PE1 -#define Z_STEP_PIN PB9 -#define Z_DIR_PIN PE0 - -#define E0_ENABLE_PIN PB8 -#define E0_STEP_PIN PB4 -#define E0_DIR_PIN PB5 - -#define E1_ENABLE_PIN PG8 -#define E1_STEP_PIN PC7 -#define E1_DIR_PIN PC6 - -// -// Temperature Sensors -// -#define TEMP_0_PIN PA1 // TH1 -#define TEMP_BED_PIN PA0 // TB1 - -// -// Heaters -// -#define HEATER_0_PIN PG12 // HEATER1 -#define HEATER_BED_PIN PG11 // HOT BED - -// -// Fans -// -#define CONTROLLER_FAN_PIN PD6 // BOARD FAN -#define FAN_PIN PG13 // FAN -#define FAN2_PIN PG14 - -// -// Misc -// -#define BEEPER_PIN PB0 -//#define LED_PIN -1 -//#define POWER_LOSS_PIN -1 -#define FIL_RUNOUT_PIN PA15 - -// SPI Flash -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH - #define SPI_FLASH_SIZE 0x200000 // 2MB -#endif - -// SPI 2 -#define W25QXX_CS_PIN PB12 -#define W25QXX_MOSI_PIN PB15 -#define W25QXX_MISO_PIN PB14 -#define W25QXX_SCK_PIN PB13 - -// -// TronXY TFT Support -// - -#if HAS_FSMC_TFT - - // Shared FSMC - - #define TOUCH_CS_PIN PB7 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - - #define TFT_RESET_PIN PF11 - #define TFT_BACKLIGHT_PIN PD13 - - #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT - #define FSMC_CS_PIN PD7 - #define FSMC_RS_PIN PD11 - #define FSMC_DMA_DEV DMA2 - #define FSMC_DMA_CHANNEL DMA_CH5 - -#endif - -#if ENABLED(TFT_LVGL_UI) - // LVGL - #define HAS_SPI_FLASH_FONT 1 - #define HAS_GCODE_PREVIEW 1 - #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0 - #define HAS_LANG_SELECT_SCREEN 1 - #define HAS_BAK_VIEW_IN_FLASH 0 - #define HAS_LOGO_IN_FLASH 0 -#elif ENABLED(TFT_COLOR_UI) - // Color UI - #define TFT_DRIVER ILI9488 - #define TFT_BUFFER_SIZE 14400 -#endif - -// XPT2046 Touch Screen calibration -#if ANY(TFT_LVGL_UI, TFT_COLOR_UI, TFT_CLASSIC_UI) - #ifndef TOUCH_CALIBRATION_X - #define TOUCH_CALIBRATION_X -17181 - #endif - #ifndef TOUCH_CALIBRATION_Y - #define TOUCH_CALIBRATION_Y 11434 - #endif - #ifndef TOUCH_OFFSET_X - #define TOUCH_OFFSET_X 501 - #endif - #ifndef TOUCH_OFFSET_Y - #define TOUCH_OFFSET_Y -9 - #endif -#endif - -// SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available -// Needs to use SPI2 -#define SPI_DEVICE 2 -#define SD_SCK_PIN PB13 -#define SD_MISO_PIN PB14 -#define SD_MOSI_PIN PB15 -#define SD_SS_PIN PB12 - -// -// SD Card -// -#define SDIO_SUPPORT -#define SD_DETECT_PIN -1 // PF0, but it isn't connected -#define SDIO_CLOCK 4500000 -#define SDIO_READ_RETRIES 16 +#include "pins_CHITU3D_common.h" diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h index 5afa653117..b76ef52c42 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h @@ -21,182 +21,14 @@ */ #pragma once -#include "env_validate.h" - -/** - * 2017 Victor Perez Marlin for stm32f1 test - */ - -#define BOARD_INFO_NAME "Chitu3D" -#define DEFAULT_MACHINE_NAME "STM32F103ZET6" - -#define BOARD_NO_NATIVE_USB - -#define DISABLE_JTAG - -// -// EEPROM -// - -#if NO_EEPROM_SELECTED - #define FLASH_EEPROM_EMULATION -#endif - -#if ENABLED(FLASH_EEPROM_EMULATION) - // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) - #define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE) - #define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE -#else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM -#endif - -// -// Limit Switches -// -#define X_STOP_PIN PG10 -#define Y_STOP_PIN PA12 -#define Z_STOP_PIN PG9 - -// -// Steppers -// -#define X_ENABLE_PIN PC13 -#define X_STEP_PIN PE5 -#define X_DIR_PIN PE6 - -#define Y_ENABLE_PIN PE4 -#define Y_STEP_PIN PE2 -#define Y_DIR_PIN PE3 - -#define Z_ENABLE_PIN PE1 -#define Z_STEP_PIN PB9 -#define Z_DIR_PIN PE0 +#define BOARD_INFO_NAME "Chitu3D V6" #define Z2_ENABLE_PIN PF3 #define Z2_STEP_PIN PF5 #define Z2_DIR_PIN PF1 -#define E0_ENABLE_PIN PB8 -#define E0_STEP_PIN PB4 -#define E0_DIR_PIN PB5 - -#define E1_ENABLE_PIN PG8 -#define E1_STEP_PIN PC7 -#define E1_DIR_PIN PC6 - -// -// Temperature Sensors -// -#define TEMP_0_PIN PA1 // TH1 -#define TEMP_BED_PIN PA0 // TB1 - -// -// Heaters -// -#define HEATER_0_PIN PG12 // HEATER1 -#define HEATER_BED_PIN PG11 // HOT BED -//#define HEATER_BED_INVERTING true - -// -// Fans -// -#define CONTROLLER_FAN_PIN PD6 // BOARD FAN -#define FAN_PIN PG13 // FAN -#define FAN2_PIN PG14 - -// -// Misc -// -#define BEEPER_PIN PB0 -//#define LED_PIN PD3 -//#define POWER_LOSS_PIN PG2 // PG4 PW_DET - -#ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN PA15 // MT_DET -#endif #ifndef FIL_RUNOUT2_PIN #define FIL_RUNOUT2_PIN PF13 #endif -// SPI Flash -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH - #define SPI_FLASH_SIZE 0x200000 // 2MB -#endif - -// SPI 2 -#define W25QXX_CS_PIN PB12 -#define W25QXX_MOSI_PIN PB15 -#define W25QXX_MISO_PIN PB14 -#define W25QXX_SCK_PIN PB13 - -// -// TronXY TFT Support -// - -#if HAS_FSMC_TFT - - // Shared FSMC - - #define TOUCH_CS_PIN PB7 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - - #define TFT_RESET_PIN PF11 - #define TFT_BACKLIGHT_PIN PD13 - - #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT - #define FSMC_CS_PIN PD7 - #define FSMC_RS_PIN PD11 - #define FSMC_DMA_DEV DMA2 - #define FSMC_DMA_CHANNEL DMA_CH5 - -#endif - -#if ENABLED(TFT_LVGL_UI) - // LVGL - #define HAS_SPI_FLASH_FONT 1 - #define HAS_GCODE_PREVIEW 1 - #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0 - #define HAS_LANG_SELECT_SCREEN 1 - #define HAS_BAK_VIEW_IN_FLASH 0 - #define HAS_LOGO_IN_FLASH 0 -#elif ENABLED(TFT_COLOR_UI) - // Color UI - #define TFT_DRIVER ILI9488 - #define TFT_BUFFER_SIZE 14400 -#endif - -// XPT2046 Touch Screen calibration -#if ANY(TFT_LVGL_UI, TFT_COLOR_UI, TFT_CLASSIC_UI) - #ifndef TOUCH_CALIBRATION_X - #define TOUCH_CALIBRATION_X -17181 - #endif - #ifndef TOUCH_CALIBRATION_Y - #define TOUCH_CALIBRATION_Y 11434 - #endif - #ifndef TOUCH_OFFSET_X - #define TOUCH_OFFSET_X 501 - #endif - #ifndef TOUCH_OFFSET_Y - #define TOUCH_OFFSET_Y -9 - #endif -#endif - -// SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available -// so SPI2 is required. -#define SPI_DEVICE 2 -#define SD_SCK_PIN PB13 -#define SD_MISO_PIN PB14 -#define SD_MOSI_PIN PB15 -#define SD_SS_PIN PB12 - -// -// SD Card -// -#define SDIO_SUPPORT -#define SD_DETECT_PIN -1 // PF0, but it isn't connected -#define SDIO_CLOCK 4500000 -#define SDIO_READ_RETRIES 16 +#include "pins_CHITU3D_common.h" diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V9.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V9.h new file mode 100755 index 0000000000..eb7f91deab --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V9.h @@ -0,0 +1,36 @@ +/** + * 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 + +#define BOARD_INFO_NAME "Chitu3D V9" + +#define Z_STOP_PIN PA14 + +#define Z2_ENABLE_PIN PF3 +#define Z2_STEP_PIN PF5 +#define Z2_DIR_PIN PF1 + +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN PF13 +#endif + +#include "pins_CHITU3D_common.h" diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h new file mode 100644 index 0000000000..b638589388 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h @@ -0,0 +1,177 @@ +/** + * 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" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Chitu3D" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "STM32F103ZET6" +#endif + +#define BOARD_NO_NATIVE_USB +#define DISABLE_JTAG + +// +// EEPROM +// + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) + #define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE) + #define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#else + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PG10 +#define Y_STOP_PIN PA12 +#ifndef Z_STOP_PIN + #define Z_STOP_PIN PG9 +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC13 +#define X_STEP_PIN PE5 +#define X_DIR_PIN PE6 + +#define Y_ENABLE_PIN PE4 +#define Y_STEP_PIN PE2 +#define Y_DIR_PIN PE3 + +#define Z_ENABLE_PIN PE1 +#define Z_STEP_PIN PB9 +#define Z_DIR_PIN PE0 + +#define E0_ENABLE_PIN PB8 +#define E0_STEP_PIN PB4 +#define E0_DIR_PIN PB5 + +#define E1_ENABLE_PIN PG8 +#define E1_STEP_PIN PC7 +#define E1_DIR_PIN PC6 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA1 // TH1 Analog Input +#define TEMP_BED_PIN PA0 // TB1 Analog Input + +// +// Heaters +// +#define HEATER_0_PIN PG12 // HEATER1 +#define HEATER_BED_PIN PG11 // HOT BED +//#define HEATER_BED_INVERTING true + +// +// Fans +// +#define CONTROLLER_FAN_PIN PD6 // BOARD FAN +#define FAN_PIN PG13 // FAN +#define FAN2_PIN PG14 + +// +// Misc +// +#define BEEPER_PIN PB0 +//#define LED_PIN PD3 +//#define POWER_LOSS_PIN PG2 // PG4 PW_DET + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA15 // MT_DET +#endif + +// SPI Flash +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x200000 // 2MB +#endif + +// SPI 2 +#define W25QXX_CS_PIN PB12 +#define W25QXX_MOSI_PIN PB15 +#define W25QXX_MISO_PIN PB14 +#define W25QXX_SCK_PIN PB13 + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #define TOUCH_CS_PIN PB7 // SPI1_NSS + #define TOUCH_SCK_PIN PA5 // SPI1_SCK + #define TOUCH_MISO_PIN PA6 // SPI1_MISO + #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI + + #define TFT_RESET_PIN PF11 + #define TFT_BACKLIGHT_PIN PD13 + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PD7 + #define FSMC_RS_PIN PD11 + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN +#endif + +#if ENABLED(TFT_LVGL_UI) + // LVGL + #define HAS_SPI_FLASH_FONT 1 + #define HAS_GCODE_PREVIEW 1 + #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0 + #define HAS_LANG_SELECT_SCREEN 1 + #define HAS_BAK_VIEW_IN_FLASH 0 + #define HAS_LOGO_IN_FLASH 0 +#elif ENABLED(TFT_COLOR_UI) + // Color UI + #define TFT_BUFFER_SIZE 14400 +#endif + +// SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available +// so SPI2 is required. +#define SPI_DEVICE 2 +#define SD_SCK_PIN PB13 +#define SD_MISO_PIN PB14 +#define SD_MOSI_PIN PB15 +#define SD_SS_PIN PB12 + +// +// SD Card +// +#define SDIO_SUPPORT +#define SD_DETECT_PIN -1 // PF0, but it isn't connected +#define SDIO_CLOCK 4500000 +#define SDIO_READ_RETRIES 16 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index 421e339058..6b3c4ed8fa 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * Creality 4.2.x (STM32F103RET6) board pin assignments diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h index 6585d40d45..d106c98e13 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * CREALITY 4.2.10 (STM32F103) board pin assignments diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h index 64ef046bd3..c327abee77 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * CREALITY v4.2.7 (STM32F103) board pin assignments diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h index ff9f76054e..e8ae84da8f 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * CREALITY v4.3.1 (STM32F103) board pin assignments diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h index 9acbb42a88..64e07a0bc8 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * Creality v4.5.2 (STM32F103RET6) board pin assignments @@ -28,7 +29,7 @@ #error "Creality v4.5.2 only supports one hotend / E-stepper. Comment out this line to continue." #endif -#define BOARD_NAME "Creality v4.5.2" +#define BOARD_INFO_NAME "Creality v4.5.2" #define HEATER_0_PIN PA1 // HEATER1 #define HEATER_BED_PIN PA2 // HOT BED diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h index f990b2f7b4..ca437312c8 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * Creality v4.5.3 (STM32F103RET6) board pin assignments @@ -28,7 +29,7 @@ #error "Creality v4.5.3 only supports one hotend / E-stepper. Comment out this line to continue." #endif -#define BOARD_NAME "Creality v4.5.3" +#define BOARD_INFO_NAME "Creality v4.5.3" #define HEATER_0_PIN PB14 // HEATER1 #define HEATER_BED_PIN PB13 // HOT BED diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h index c73c92080e..39dccf1271 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once /** * Creality v4.5.2 and v4.5.3 (STM32F103RET6) board pin assignments diff --git a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h index c49c31e741..31b03f6b07 100644 --- a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h +++ b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h @@ -41,7 +41,7 @@ #define BOARD_NO_NATIVE_USB // Avoid conflict with TIMER_SERVO when using the STM32 HAL -#define TEMP_TIMER 5 +#define TEMP_TIMER 5 // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role @@ -65,7 +65,7 @@ #define SD_SCK_PIN PB13 // SPI2 #define SD_MISO_PIN PB14 // SPI2 #define SD_MOSI_PIN PB15 // SPI2 -#define SPI_DEVICE 2 +#define SPI_DEVICE 2 // SPI Flash #define HAS_SPI_FLASH 1 @@ -271,11 +271,9 @@ #error "FLSun HiSpeed default BEEPER_PIN is not a SPEAKER." #endif -#if HAS_FSMC_TFT || HAS_GRAPHICAL_TFT - #define TFT_CS_PIN PD7 // NE4 - #define TFT_RS_PIN PD11 // A0 -#endif - +// +// TFT with FSMC interface +// #if HAS_FSMC_TFT /** * Note: MKS Robin TFT screens use various TFT controllers @@ -291,12 +289,16 @@ */ //#define TFT_RESET_PIN PC6 // FSMC_RST #define TFT_BACKLIGHT_PIN PD13 - #define FSMC_CS_PIN TFT_CS_PIN // NE4 - #define FSMC_RS_PIN TFT_RS_PIN // A0 #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PD7 // NE4 + #define FSMC_RS_PIN PD11 // A0 #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN TFT_CS_PIN + #define TFT_RS_PIN TFT_RS_PIN + #ifdef TFT_CLASSIC_UI #define TFT_MARLINBG_COLOR 0x3186 // Grey #define TFT_MARLINUI_COLOR 0xC7B6 // Green @@ -307,6 +309,8 @@ #elif HAS_GRAPHICAL_TFT #define TFT_RESET_PIN PC6 #define TFT_BACKLIGHT_PIN PD13 + #define TFT_CS_PIN PD7 // NE4 + #define TFT_RS_PIN PD11 // A0 #endif #if NEED_TOUCH_PINS diff --git a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h index b94ec0c7f3..be0a622b1d 100644 --- a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h @@ -24,7 +24,7 @@ #include "env_validate.h" #define BOARD_INFO_NAME "FLY_MINI" -#define BOARD_WEBSITE_URL "github.com/FLYmaker" +#define BOARD_WEBSITE_URL "github.com/FLYmaker/FLY-MINI" #define DISABLE_JTAG // diff --git a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h index 9f08f18bf7..bded0edd3a 100644 --- a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -26,6 +26,8 @@ * ║║ ╦╠═╣│ │├┬┘│ │├┬┘├─┤╠╣ │ │├┬┘│ ││││ │ │ ││││ * ╚╝╚═╝╩ ╩└─┘┴└─└─┘┴└─┴ ┴╚ └─┘┴└─└─┘┴ ┴o└─┘└─┘┴ ┴ * Pin assignments for 32-bit JGAurora A5S & A1 + * + * https://jgaurorawiki.com/_media/jgaurora_a5s_a1_pinout.png */ #include "env_validate.h" @@ -102,15 +104,20 @@ #define FIL_RUNOUT_PIN PC7 // -// LCD +// TFT with FSMC interface // -#define LCD_BACKLIGHT_PIN PF11 -#define FSMC_CS_PIN PD7 -#define FSMC_RS_PIN PG0 +#if HAS_FSMC_TFT + #define LCD_BACKLIGHT_PIN PF11 + #define FSMC_CS_PIN PD7 + #define FSMC_RS_PIN PG0 -#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT -#define FSMC_DMA_DEV DMA2 -#define FSMC_DMA_CHANNEL DMA_CH5 + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN +#endif // // SD Card @@ -129,4 +136,7 @@ #if NEED_TOUCH_PINS #define TOUCH_CS_PIN PA4 #define TOUCH_INT_PIN PC4 + #define TOUCH_MISO_PIN PA6 + #define TOUCH_MOSI_PIN PA7 + #define TOUCH_SCK_PIN PA5 #endif diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index fa708b248e..f9ec42b68e 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -117,20 +117,32 @@ //#undef Z_MAX_PIN // Uncomment if using ZMAX connector (PE5) #endif -#define TFT_RESET_PIN PC4 // pin 33 -#define TFT_BACKLIGHT_PIN PD12 // pin 59 -#define FSMC_CS_PIN PD7 // pin 88 = FSMC_NE1 -#define FSMC_RS_PIN PD11 // pin 58 A16 Register. Only one address needed +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PD7 // pin 88 = FSMC_NE1 + #define FSMC_RS_PIN PD11 // pin 58 A16 Register. Only one address needed + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 -#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT -#define FSMC_DMA_DEV DMA2 -#define FSMC_DMA_CHANNEL DMA_CH5 + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN -#define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h -#define DOGLCD_SCK -1 + #define TFT_RESET_PIN PC4 // pin 33 + #define TFT_BACKLIGHT_PIN PD12 // pin 59 -// Buffer for Color UI -#define TFT_BUFFER_SIZE 3200 + #define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h + #define DOGLCD_SCK -1 + + // Buffer for Color UI + #define TFT_BUFFER_SIZE 3200 +#endif + +#if ENABLED(SDIO_SUPPORT) + #define SD_SS_PIN -1 // else SDSS set to PA4 in M43 (spi_pins.h) +#endif /** * Note: Alfawise U20/U30 boards DON'T use SPI2, as the hardware designer @@ -140,7 +152,7 @@ #if NEED_TOUCH_PINS #define TOUCH_CS_PIN PB12 // pin 51 SPI2_NSS #define TOUCH_SCK_PIN PB13 // pin 52 - #define TOUCH_MOSI_PIN PB14 // pin 53 + #define TOUCH_MOSI_PIN PB14 // pin 53 (Inverted MOSI/MISO = No HW SPI2) #define TOUCH_MISO_PIN PB15 // pin 54 #define TOUCH_INT_PIN PC6 // pin 63 (PenIRQ coming from ADS7843) #endif @@ -151,6 +163,7 @@ // #if NO_EEPROM_SELECTED //#define SPI_EEPROM + //#define HAS_SPI_FLASH 1 // need MARLIN_DEV_MODE for M993/M994 eeprom backup tests #define FLASH_EEPROM_EMULATION #endif @@ -163,6 +176,12 @@ #define EEPROM_MOSI BOARD_SPI1_MOSI_PIN // PA7 pin 32 #define EEPROM_PAGE_SIZE 0x1000U // 4KB (from datasheet) #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64KB for now... +#elif HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x40000U // limit to 256KB (M993 will reboot with 512) + #define W25QXX_CS_PIN PC5 + #define W25QXX_MOSI_PIN PA7 + #define W25QXX_MISO_PIN PA6 + #define W25QXX_SCK_PIN PA5 #elif ENABLED(FLASH_EEPROM_EMULATION) // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) #define EEPROM_PAGE_SIZE (0x800U) // 2KB diff --git a/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h b/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h index 429cf14ac5..14f2ad981a 100644 --- a/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h @@ -100,10 +100,10 @@ //#define TEMP_0_PIN PB3 // E0 K+ #define TEMP_BED_PIN PF7 // THERM_BED -#define MAX6675_SS_PIN PB5 -#define MAX6675_SCK_PIN PB3 -#define MAX6675_DO_PIN PB4 -#define MAX6675_MOSI_PIN PA14 +#define TEMP_0_CS_PIN PB5 +#define TEMP_0_SCK_PIN PB3 +#define TEMP_0_MISO_PIN PB4 +#define TEMP_0_MOSI_PIN PA14 // // Heaters / Fans @@ -133,11 +133,9 @@ // #define BEEPER_PIN PE4 -/** - * Note: MKS Robin TFT screens use various TFT controllers. - * If the screen stays white, disable 'LCD_RESET_PIN' - * to let the bootloader init the screen. - */ +// +// TFT with FSMC interface +// #if HAS_FSMC_TFT /** * Note: MKS Robin TFT screens use various TFT controllers @@ -151,18 +149,17 @@ * Setting an 'TFT_RESET_PIN' may cause a flicker when entering the LCD menu * because Marlin uses the reset as a failsafe to revive a glitchy LCD. */ - #define TFT_CS_PIN PD7 // NE4 - #define TFT_RS_PIN PG0 // A0 - - #define FSMC_CS_PIN TFT_CS_PIN - #define FSMC_RS_PIN TFT_RS_PIN + #define TFT_RESET_PIN PF15 + #define TFT_BACKLIGHT_PIN PF11 #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PD7 // NE4 + #define FSMC_RS_PIN PG0 // A0 #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 - #define TFT_RESET_PIN PF15 - #define TFT_BACKLIGHT_PIN PF11 + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index b9f1074c7a..f912978051 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -121,8 +121,8 @@ // // Thermocouples // -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PE6 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // // Filament runout sensor @@ -155,7 +155,7 @@ #define WIFI_IO0_PIN PG1 // -// LCD screen +// TFT with FSMC interface // #if HAS_FSMC_TFT /** @@ -170,18 +170,17 @@ * Setting an 'TFT_RESET_PIN' may cause a flicker when entering the LCD menu * because Marlin uses the reset as a failsafe to revive a glitchy LCD. */ - #define TFT_CS_PIN PG12 // NE4 - #define TFT_RS_PIN PF0 // A0 - - #define FSMC_CS_PIN TFT_CS_PIN - #define FSMC_RS_PIN TFT_RS_PIN + #define TFT_RESET_PIN PF6 + #define TFT_BACKLIGHT_PIN PG11 #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PG12 // NE4 + #define FSMC_RS_PIN PF0 // A0 #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 - #define TFT_RESET_PIN PF6 - #define TFT_BACKLIGHT_PIN PG11 + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index 14664bda39..b32d0aa0b8 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -36,6 +36,10 @@ #define BOARD_INFO_NAME "MKS Robin E3P" #define BOARD_NO_NATIVE_USB +#define MKS_HARDWARE_TEST_ONLY_E0 + +// Avoid conflict with TIMER_SERVO when using the STM32 HAL +#define TEMP_TIMER 5 // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role @@ -213,17 +217,23 @@ #define SDCARD_CONNECTION ONBOARD #endif -#define SDIO_SUPPORT -#define SDIO_CLOCK 4500000 // 4.5 MHz -#define SD_DETECT_PIN PD12 -#define ONBOARD_SD_CS_PIN PC11 +#if SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT + #define SDIO_CLOCK 4500000 // 4.5 MHz + #define SD_DETECT_PIN PD12 + #define ONBOARD_SD_CS_PIN PC11 +#elif SD_CONNECTION_IS(LCD) + #define ENABLE_SPI1 + #define SDSS PE10 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_DETECT_PIN PE12 +#endif // // LCD / Controller // -#ifndef BEEPER_PIN - #define BEEPER_PIN PC5 -#endif /** * Note: MKS Robin TFT screens use various TFT controllers. @@ -260,33 +270,29 @@ #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 - #ifndef TFT_WIDTH - #define TFT_WIDTH 480 - #endif - #ifndef TFT_HEIGHT - #define TFT_HEIGHT 320 - #endif - - #define LCD_READ_ID 0xD3 #define LCD_USE_DMA_SPI #endif -#if HAS_SPI_GRAPHICAL_TFT +#if ENABLED(TFT_CLASSIC_UI) // Emulated DOGM SPI #define LCD_PINS_ENABLE PD13 #define LCD_PINS_RS PC6 #define BTN_ENC PE13 #define BTN_EN1 PE8 #define BTN_EN2 PE11 -#elif ENABLED(TFT_480x320_SPI) - #define TFT_DRIVER ST7796 +#elif ENABLED(TFT_COLOR_UI) #define TFT_BUFFER_SIZE 14400 #endif #if HAS_WIRED_LCD && !HAS_SPI_TFT - - // NON TFT Displays + #define BEEPER_PIN PC5 + #define BTN_ENC PE13 + #define LCD_PINS_ENABLE PD13 + #define LCD_PINS_RS PC6 + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 + #define LCD_BACKLIGHT_PIN -1 #if ENABLED(MKS_MINI_12864) @@ -300,9 +306,32 @@ #define DOGLCD_SCK PA5 #define DOGLCD_MOSI PA7 - // Required for MKS_MINI_12864 with this board - #define MKS_LCD12864B - #undef SHOW_BOOTSCREEN + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define PIN_SPI_SCK PA5 + #define PIN_TFT_MISO PA6 + #define PIN_TFT_MOSI PA7 + #define TFTGLCD_CS PE8 + #endif + + #ifndef BEEPER_PIN + #define BEEPER_PIN -1 + #endif + + #elif ENABLED(MKS_MINI_12864_V3) + #define DOGLCD_CS PD13 + #define DOGLCD_A0 PC6 + #define LCD_PINS_DC DOGLCD_A0 + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN PE14 + #define NEOPIXEL_PIN PE15 + #define DOGLCD_MOSI PA7 + #define DOGLCD_SCK PA5 + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + //#define LCD_SCREEN_ROT_180 #else // !MKS_MINI_12864 @@ -341,6 +370,10 @@ #define W25QXX_SCK_PIN PB13 #endif +#ifndef BEEPER_PIN + #define BEEPER_PIN PC5 +#endif + #if ENABLED(SPEAKER) && BEEPER_PIN == PC5 #error "MKS Robin nano default BEEPER_PIN is not a SPEAKER." #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h index 6369fcd31b..44c35b9d04 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -155,6 +155,19 @@ #define DOGLCD_SCK PB13 #define DOGLCD_MOSI PB15 + #elif ENABLED(MKS_MINI_12864_V3) + #define DOGLCD_CS PA4 + #define DOGLCD_A0 PA5 + #define LCD_PINS_DC DOGLCD_A0 + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN PA6 + #define NEOPIXEL_PIN PA7 + #define DOGLCD_MOSI PB15 + #define DOGLCD_SCK PB13 + #define FORCE_SOFT_SPI + #define SOFTWARE_SPI + //#define LCD_SCREEN_ROT_180 + #else #define LCD_PINS_D4 PA6 @@ -186,7 +199,6 @@ // TODO: This is the only way to set SPI for SD on STM32 (for now) #define ENABLE_SPI2 -#define CUSTOM_SPI_PINS #define SD_SCK_PIN PB13 #define SD_MISO_PIN PB14 #define SD_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index fad36e8384..73c77d092a 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -143,6 +143,6 @@ // #define SPI_DEVICE 2 #define SD_SCK_PIN PB13 -#define SD_MISO_PIN P1B4 -#define SD_MOSI_PIN P1B5 +#define SD_MISO_PIN PB14 +#define SD_MOSI_PIN PB15 #define SD_SS_PIN PA15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index ea3a7a1eea..147aec5e9f 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -37,7 +37,7 @@ #define BOARD_NO_NATIVE_USB // Avoid conflict with TIMER_SERVO when using the STM32 HAL -#define TEMP_TIMER 5 +#define TEMP_TIMER 5 // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role @@ -105,7 +105,7 @@ #ifndef HEATER_0_PIN #define HEATER_0_PIN PC3 #endif -#if HOTENDS == 1 +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) #ifndef FAN1_PIN #define FAN1_PIN PB0 #endif @@ -124,8 +124,8 @@ // // Thermocouples // -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PE6 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // // Misc. Functions @@ -172,13 +172,18 @@ // #define BEEPER_PIN PC5 -/** - * Note: MKS Robin TFT screens use various TFT controllers. - * If the screen stays white, disable 'TFT_RESET_PIN' - * to let the bootloader init the screen. - */ -// Shared FSMC Configs +// +// TFT with FSMC interface +// #if HAS_FSMC_TFT + /** + * Note: MKS Robin TFT screens use various TFT controllers. + * If the screen stays white, disable 'TFT_RESET_PIN' + * to let the bootloader init the screen. + */ + #define TFT_RESET_PIN PC6 // FSMC_RST + #define TFT_BACKLIGHT_PIN PD13 + #define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h #define DOGLCD_SCK -1 @@ -187,9 +192,6 @@ #define TOUCH_MISO_PIN PB14 // SPI2_MISO #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI - #define TFT_RESET_PIN PC6 // FSMC_RST - #define TFT_BACKLIGHT_PIN PD13 - #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT #define FSMC_CS_PIN PD7 #define FSMC_RS_PIN PD11 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 6ef3a08043..4b0ba2fdab 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -38,7 +38,7 @@ #define BOARD_NO_NATIVE_USB // Avoid conflict with TIMER_SERVO when using the STM32 HAL -#define TEMP_TIMER 5 +#define TEMP_TIMER 5 // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role @@ -188,8 +188,8 @@ // // Thermocouples // -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PE6 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // // Misc. Functions @@ -231,10 +231,19 @@ #define SDCARD_CONNECTION ONBOARD #endif -#define SDIO_SUPPORT -#define SDIO_CLOCK 4500000 // 4.5 MHz -#define SD_DETECT_PIN PD12 -#define ONBOARD_SD_CS_PIN PC11 +#if SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT + #define SDIO_CLOCK 4500000 // 4.5 MHz + #define SD_DETECT_PIN PD12 + #define ONBOARD_SD_CS_PIN PC11 +#elif SD_CONNECTION_IS(LCD) + #define ENABLE_SPI1 + #define SDSS PE10 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_DETECT_PIN PE12 +#endif // // LCD / Controller @@ -291,8 +300,13 @@ #endif #if HAS_WIRED_LCD && !HAS_SPI_TFT - - // NON TFT Displays + #define BEEPER_PIN PC5 + #define BTN_ENC PE13 + #define LCD_PINS_ENABLE PD13 + #define LCD_PINS_RS PC6 + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 + #define LCD_BACKLIGHT_PIN -1 #if ENABLED(MKS_MINI_12864) @@ -319,6 +333,20 @@ #define BEEPER_PIN -1 #endif + #elif ENABLED(MKS_MINI_12864_V3) + #define DOGLCD_CS PD13 + #define DOGLCD_A0 PC6 + #define LCD_PINS_DC DOGLCD_A0 + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN PE14 + #define NEOPIXEL_PIN PE15 + #define DOGLCD_MOSI PA7 + #define DOGLCD_SCK PA5 + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + //#define LCD_SCREEN_ROT_180 + #else // !MKS_MINI_12864 #define LCD_PINS_D4 PE14 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index b56971c7a3..7ff22cc1ce 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -175,8 +175,8 @@ /** * Note: MKS Robin Pro board is using SPI2 interface. Make sure your stm32duino library is configured accordingly */ -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PF11 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PF11 // TC2 - CS2 #define POWER_LOSS_PIN PA2 // PW_DET #define PS_ON_PIN PG11 // PW_OFF @@ -205,12 +205,18 @@ #error "No custom SD drive cable defined for this board." #endif -/** - * Note: MKS Robin TFT screens use various TFT controllers. - * If the screen stays white, disable 'LCD_RESET_PIN' - * to let the bootloader init the screen. - */ +// +// TFT with FSMC interface +// #if HAS_FSMC_TFT + /** + * Note: MKS Robin TFT screens use various TFT controllers. + * If the screen stays white, disable 'LCD_RESET_PIN' + * to let the bootloader init the screen. + */ + #define TFT_RESET_PIN LCD_RESET_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 #define FSMC_DMA_DEV DMA2 @@ -221,8 +227,6 @@ #define LCD_RESET_PIN PF6 #define LCD_BACKLIGHT_PIN PD13 - #define TFT_RESET_PIN LCD_RESET_PIN - #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TFT_BUFFER_SIZE 14400 diff --git a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h index 5eefedb141..1de3729dcc 100644 --- a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h @@ -126,20 +126,24 @@ //#define POWER_LOSS_PIN PG2 // PG4 PW_DET #define FIL_RUNOUT_PIN PA15 // MT_DET -/** - * Note: MKS Robin TFT screens use various TFT controllers - * Supported screens are based on the ILI9341, ST7789V and ILI9328 (320x240) - * ILI9488 is not supported. - * Define init sequences for other screens in u8g_dev_tft_320x240_upscale_from_128x64.cpp - * - * If the screen stays white, disable 'LCD_RESET_PIN' to let the bootloader init the screen. - * - * Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu - * because Marlin uses the reset as a failsafe to revive a glitchy LCD. - */ +// +// TFT with FSMC interface +// #if HAS_FSMC_TFT + /** + * Note: MKS Robin TFT screens use various TFT controllers + * Supported screens are based on the ILI9341, ST7789V and ILI9328 (320x240) + * ILI9488 is not supported. + * Define init sequences for other screens in u8g_dev_tft_320x240_upscale_from_128x64.cpp + * + * If the screen stays white, disable 'LCD_RESET_PIN' to let the bootloader init the screen. + * + * Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu + * because Marlin uses the reset as a failsafe to revive a glitchy LCD. + */ #define TFT_RESET_PIN PF11 #define TFT_BACKLIGHT_PIN PD13 + #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 diff --git a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h index 1e1f5251c1..d2ee2e013c 100644 --- a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h +++ b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h @@ -136,14 +136,18 @@ // // LCD / Controller // -#define TFT_RESET_PIN PE6 -#define TFT_CS_PIN PD7 -#define TFT_RS_PIN PD13 -#define TFT_INTERFACE_FSMC_8BIT +#if HAS_SPI_TFT || HAS_FSMC_TFT + #define TFT_RESET_PIN PE6 + #define TFT_CS_PIN PD7 + #define TFT_RS_PIN PD13 -#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT -#define FSMC_CS_PIN TFT_CS_PIN -#define FSMC_RS_PIN TFT_RS_PIN + #if HAS_FSMC_TFT + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN TFT_CS_PIN + #define FSMC_RS_PIN TFT_RS_PIN + #define TFT_INTERFACE_FSMC_8BIT + #endif +#endif // // Touch Screen diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index 9fb13c84fe..2bfbb19427 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -161,6 +161,7 @@ // #define TEMP_0_PIN PA2 // T0 <-> E0 #define TEMP_1_PIN PA0 // T1 <-> E1 +#define TEMP_BOARD_PIN PC2 // Onboard thermistor, NTC100K #define TEMP_BED_PIN PA1 // T2 <-> Bed #define TEMP_PROBE_PIN PC3 // Shares J4 connector with PD1 @@ -205,13 +206,10 @@ #define EXP2_10_PIN PA6 // HAL SPI1 pins -#define CUSTOM_SPI_PINS -#if ENABLED(CUSTOM_SPI_PINS) - #define SD_SCK_PIN EXP2_09_PIN // SPI1 SCLK - #define SD_SS_PIN EXP2_07_PIN // SPI1 SSEL - #define SD_MISO_PIN EXP2_10_PIN // SPI1 MISO - #define SD_MOSI_PIN EXP2_05_PIN // SPI1 MOSI -#endif +#define SD_SCK_PIN EXP2_09_PIN // SPI1 SCLK +#define SD_SS_PIN EXP2_07_PIN // SPI1 SSEL +#define SD_MISO_PIN EXP2_10_PIN // SPI1 MISO +#define SD_MOSI_PIN EXP2_05_PIN // SPI1 MOSI #define SDSS EXP2_07_PIN diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index 8f19b1915d..3151a38ae8 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -298,19 +298,19 @@ #define TEMP_BED_PIN PC0 // T0 <-> Bed -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple // Uses a separate SPI bus -// If you have a two-way thermocouple, you can customize two THERMO_CSx_PIN pins (x:1~2) +// If you have a two-way thermocouple, you can customize two TEMP_x_CS_PIN pins (x:0~1) -#define THERMO_SCK_PIN PI1 // SCK -#define THERMO_DO_PIN PI2 // MISO -#define THERMO_CS1_PIN PH9 // GTR K-TEMP -#define THERMO_CS2_PIN PH2 // M5 K-TEMP +#define TEMP_0_CS_PIN PH9 // GTR K-TEMP +#define TEMP_0_SCK_PIN PI1 // SCK +#define TEMP_0_MISO_PIN PI2 // MISO +//#define TEMP_0_MOSI_PIN ... // For MAX31865 -#define MAX6675_SS_PIN THERMO_CS1_PIN -#define MAX6675_SS2_PIN THERMO_CS2_PIN -#define MAX6675_SCK_PIN THERMO_SCK_PIN -#define MAX6675_DO_PIN THERMO_DO_PIN +#define TEMP_1_CS_PIN PH2 // M5 K-TEMP +#define TEMP_1_SCK_PIN TEMP_0_SCK_PIN +#define TEMP_1_MISO_PIN TEMP_0_MISO_PIN +//#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN // // Heaters / Fans @@ -357,8 +357,6 @@ #elif SD_CONNECTION_IS(ONBOARD) - // Instruct the STM32 HAL to override the default SPI pins from the variant.h file - #define CUSTOM_SPI_PINS #define SDSS PA4 #define SD_SS_PIN SDSS #define SD_SCK_PIN PA5 @@ -413,6 +411,7 @@ #define TOUCH_MOSI_PIN EXP1_08_PIN #define TOUCH_SCK_PIN EXP1_06_PIN #define TOUCH_CS_PIN EXP1_07_PIN + #define BTN_ENC EXP1_09_PIN #define BTN_EN1 EXP2_08_PIN #define BTN_EN2 EXP2_06_PIN diff --git a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h index cce21fbe8f..25622bc62d 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -356,7 +356,6 @@ #define SD_DETECT_PIN PC14 #elif SD_CONNECTION_IS(LCD) - #define CUSTOM_SPI_PINS #define SDSS PA4 #define SD_SS_PIN SDSS #define SD_SCK_PIN PA5 @@ -501,6 +500,24 @@ #endif #endif +#if HAS_SPI_TFT + #define TFT_CS_PIN EXP2_07_PIN + #define TFT_A0_PIN EXP2_04_PIN + #define TFT_SCK_PIN EXP2_09_PIN + #define TFT_MISO_PIN EXP2_10_PIN + #define TFT_MOSI_PIN EXP2_05_PIN + + #define TOUCH_INT_PIN EXP1_04_PIN + #define TOUCH_MISO_PIN EXP1_05_PIN + #define TOUCH_MOSI_PIN EXP1_08_PIN + #define TOUCH_SCK_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_07_PIN + + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_09_PIN +#endif + // // WIFI // diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index fe6d8740bd..231dd9f594 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -231,27 +231,81 @@ // // Temperature Sensors +// Use ADC pins without pullup for sensors that don't need a pullup. // -#define TEMP_0_PIN PF4 // T1 <-> E0 -#define TEMP_1_PIN PF5 // T2 <-> E1 -#define TEMP_2_PIN PF6 // T3 <-> E2 -#define TEMP_BED_PIN PF3 // T0 <-> Bed +#if TEMP_SENSOR_0_IS_AD8495 || TEMP_SENSOR_0 == 20 + #define TEMP_0_PIN PF8 +#else + #define TEMP_0_PIN PF4 // T1 <-> E0 +#endif +#if TEMP_SENSOR_1_IS_AD8495 || TEMP_SENSOR_1 == 20 + #define TEMP_1_PIN PF9 +#else + #define TEMP_1_PIN PF5 // T2 <-> E1 +#endif +#if TEMP_SENSOR_2_IS_AD8495 || TEMP_SENSOR_2 == 20 + #define TEMP_2_PIN PF10 +#else + #define TEMP_2_PIN PF6 // T3 <-> E2 +#endif +#if TEMP_SENSOR_BED_IS_AD8495 || TEMP_SENSOR_BED == 20 + #define TEMP_BED_PIN PF7 +#else + #define TEMP_BED_PIN PF3 // T0 <-> Bed +#endif + +#if TEMP_SENSOR_PROBE && !defined(TEMP_PROBE_PIN) + #if TEMP_SENSOR_PROBE_IS_AD8495 || TEMP_SENSOR_PROBE == 20 + #if HOTENDS == 2 + #define TEMP_PROBE_PIN PF10 + #elif HOTENDS < 2 + #define TEMP_PROBE_PIN PF9 + #endif + #else + #if HOTENDS == 2 + #define TEMP_PROBE_PIN TEMP_2_PIN + #elif HOTENDS < 2 + #define TEMP_PROBE_PIN TEMP_1_PIN + #endif + #endif +#endif + +#if TEMP_SENSOR_CHAMBER && !defined(TEMP_CHAMBER_PIN) + #if TEMP_SENSOR_CHAMBER_IS_AD8495 || TEMP_SENSOR_CHAMBER == 20 + #define TEMP_CHAMBER_PIN PF10 + #else + #define TEMP_CHAMBER_PIN TEMP_2_PIN + #endif +#endif // -// Heaters / Fans +// Heaters // #define HEATER_0_PIN PB1 // Heater0 #define HEATER_1_PIN PD14 // Heater1 -#define HEATER_2_PIN PB0 // Heater1 +#if TEMP_SENSOR_CHAMBER && HOTENDS < 3 + #define HEATER_CHAMBER_PIN PB0 // Heater2 +#else + #define HEATER_2_PIN PB0 // Heater2 +#endif #define HEATER_BED_PIN PD12 // Hotbed + +// +// Fans +// #define FAN_PIN PC8 // Fan0 #define FAN1_PIN PE5 // Fan1 -#define FAN2_PIN PE6 // Fan2 #ifndef E0_AUTO_FAN_PIN #define E0_AUTO_FAN_PIN FAN1_PIN #endif +#if ENABLED(USE_CONTROLLER_FAN) && HOTENDS < 2 + #define CONTROLLER_FAN_PIN PE6 // Fan2 +#else + #define FAN2_PIN PE6 // Fan2 +#endif + // // Misc. Functions // diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h index c46e0f03f0..a9dfc367bf 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h @@ -210,7 +210,7 @@ #define TEMP_0_PIN PA2 // TH0 #define TEMP_1_PIN PA3 // TH1 -#if HOTENDS == 1 +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) #if TEMP_SENSOR_PROBE #define TEMP_PROBE_PIN TEMP_1_PIN #elif TEMP_SENSOR_CHAMBER @@ -348,7 +348,6 @@ #elif SD_CONNECTION_IS(LCD) - #define CUSTOM_SPI_PINS #define SDSS PA4 #define SD_SS_PIN SDSS #define SD_SCK_PIN PA5 diff --git a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h index 34124a9b02..77257f818a 100644 --- a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h +++ b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h @@ -33,8 +33,8 @@ #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME // Avoid conflict with fans and TIMER_TONE -#define TEMP_TIMER 3 -#define STEP_TIMER 5 +#define TEMP_TIMER 3 +#define STEP_TIMER 5 // // EEPROM Emulation diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 7aeab0196a..492383048e 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -50,13 +50,15 @@ // 128 kB sector allocated for EEPROM emulation. #define FLASH_EEPROM_LEVELING #elif ENABLED(I2C_EEPROM) - #define MARLIN_EEPROM_SIZE 0x0800 // 2KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // // Servos // -#define SERVO0_PIN PA3 +#ifndef SERVO0_PIN + #define SERVO0_PIN PA3 +#endif // // Limit Switches diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h index a33f35bd55..e90ac552ae 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h @@ -68,6 +68,12 @@ // #define X_ENABLE_PIN PE9 +// +// Servos +// Z_MAX_PIN only works in input mode +// +#define SERVO0_PIN PA2 + #if HAS_TMC_UART #define X_SERIAL_TX_PIN PE7 #define X_SERIAL_RX_PIN PE7 diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h index b92056ea86..3b75e7072a 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h @@ -230,9 +230,8 @@ #define BEEPER_PIN PC7 // -// LCD / Controller +// TFT with FSMC interface // - #if HAS_FSMC_TFT //#define TFT_DRIVER LERDGE_ST7796 diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h index 105d0d6f60..65db99025c 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h @@ -104,16 +104,16 @@ // MAX6675 Cold-Junction-Compensated K-Thermocouple to Digital Converter (0°C to +1024°C) // https://datasheets.maximintegrated.com/en/ds/MAX6675.pdf -#define MAX6675_SCK_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested -#define MAX6675_DO_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested -#define MAX6675_SS_PIN PC4 // max6675 datasheet: /CS pin, found with multimeter, not tested and likely wrong +#define TEMP_0_CS_PIN PC4 // max6675 datasheet: /CS pin, found with multimeter, not tested and likely wrong +#define TEMP_0_SCK_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested +#define TEMP_0_MISO_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested // Expansion board with second max6675 // Warning: Some boards leave the slot unpopulated. -//#define MAX6675_SCK2_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested -//#define MAX6675_DO2_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested -//#define MAX6675_SS2_PIN PF1 // max6675 datasheet: /CS pin, found with multimeter, not tested +//#define TEMP_1_CS_PIN PF1 // max6675 datasheet: /CS pin, found with multimeter, not tested +//#define TEMP_1_SCK_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested +//#define TEMP_1_MISO_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested // // Heaters / Fans diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h new file mode 100644 index 0000000000..939edc6052 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h @@ -0,0 +1,372 @@ +/** + * 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 + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 3 || E_STEPPERS > 5 + #error "MKS Monster supports up to 3 hotends and 5 E-steppers." +#elif HAS_FSMC_TFT + #error "MKS Monster doesn't support FSMC-based TFT displays." +#endif + +#define BOARD_INFO_NAME "MKS Monster8 V1.x" + +// USB Flash Drive support +#define HAS_OTG_USB_HOST_SUPPORT + +//#define DISABLE_DEBUG + +// Avoid conflict with TIMER_TONE +#define STEP_TIMER 10 + +// Use one of these or SDCard-based Emulation will be used +//#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation +//#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#define I2C_EEPROM // Need use jumpers set i2c for EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#define I2C_SCL_PIN PB8 // I2C_SCL and CAN_RX +#define I2C_SDA_PIN PB9 // I2C_SDA and CAN_TX + +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + +// +// Limit Switches for diag signal +// +#define X_DIAG_PIN PA14 // Driver0 diag signal is connect to X- +#define Y_DIAG_PIN PA15 // Driver1 diag signal is connect to Y- +#define Z_DIAG_PIN PB13 // Driver2 diag signal is connect to Z- +#define E0_DIAG_PIN PA13 // Driver3 diag signal is connect to X+ +#define E1_DIAG_PIN PC5 // Driver4 diag signal is connect to Y+ +#define E2_DIAG_PIN PB12 // Driver5 diag signal is connect to Z+ +#define E3_DIAG_PIN -1 // Driver6 diag signal is not connect +#define E4_DIAG_PIN -1 // Driver7 diag signal is not connect + +// Limit Switches for endstop +#define X_MIN_PIN PA14 +#define X_MAX_PIN PA13 +#define Y_MIN_PIN PA15 +#define Y_MAX_PIN PC5 +#define Z_MIN_PIN PB13 +#define Z_MAX_PIN PB12 + +// +// Steppers +// Driver 0 1 2 3 4 5 6 7 +// For X Y Z E0 E1 E2 E3 E4(default pin settings) +// +//Driver0 +#define X_ENABLE_PIN PC15 +#define X_STEP_PIN PC14 +#define X_DIR_PIN PC13 +#ifndef X_CS_PIN + #define X_CS_PIN PE6 +#endif +//Driver1 +#define Y_ENABLE_PIN PC15 +#define Y_STEP_PIN PE5 +#define Y_DIR_PIN PE4 +#ifndef Y_CS_PIN + #define Y_CS_PIN PE3 +#endif +//Driver2 +#define Z_ENABLE_PIN PE2 +#define Z_STEP_PIN PE1 +#define Z_DIR_PIN PE0 +#ifndef Z_CS_PIN + #define Z_CS_PIN PB7 +#endif +//Driver3 +#define E0_ENABLE_PIN PB6 +#define E0_STEP_PIN PB5 +#define E0_DIR_PIN PB4 +#ifndef E0_CS_PIN + #define E0_CS_PIN PB3 +#endif +//Driver4 +#define E1_ENABLE_PIN PD7 +#define E1_STEP_PIN PD6 +#define E1_DIR_PIN PD5 +#ifndef E1_CS_PIN + #define E1_CS_PIN PD4 +#endif +//Driver5 +#define E2_ENABLE_PIN PD3 +#define E2_STEP_PIN PD2 +#define E2_DIR_PIN PD1 +#ifndef E2_CS_PIN + #define E2_CS_PIN PD0 +#endif +//Driver6 +#define E3_ENABLE_PIN PC8 +#define E3_STEP_PIN PC7 +#define E3_DIR_PIN PC6 +#ifndef E3_CS_PIN + #define E3_CS_PIN PD15 +#endif +//Driver7 +#define E4_ENABLE_PIN PD14 +#define E4_STEP_PIN PD13 +#define E4_DIR_PIN PD12 +#ifndef E4_CS_PIN + #define E4_CS_PIN PD11 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// This board only supports SW SPI for stepper drivers +// +#if HAS_TMC_SPI + #define TMC_USE_SW_SPI +#endif +#if ENABLED(TMC_USE_SW_SPI) + #if !defined(TMC_SW_MOSI) || TMC_SW_MOSI == -1 + #define TMC_SW_MOSI PE14 + #endif + #if !defined(TMC_SW_MISO) || TMC_SW_MISO == -1 + #define TMC_SW_MISO PE13 + #endif + #if !defined(TMC_SW_SCK) || TMC_SW_SCK == -1 + #define TMC_SW_SCK PE12 + #endif +#endif + +#if HAS_TMC_UART + // + // Software serial + // No Hardware serial for steppers + // + #define X_SERIAL_TX_PIN PE6 + #define X_SERIAL_RX_PIN PE6 + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN PE3 + + #define Z_SERIAL_TX_PIN PB7 + #define Z_SERIAL_RX_PIN PB7 + + #define E0_SERIAL_TX_PIN PB3 + #define E0_SERIAL_RX_PIN PB3 + + #define E1_SERIAL_TX_PIN PD4 + #define E1_SERIAL_RX_PIN PD4 + + #define E2_SERIAL_TX_PIN PD0 + #define E2_SERIAL_RX_PIN PD0 + + #define E3_SERIAL_TX_PIN PD15 + #define E3_SERIAL_RX_PIN PD15 + + #define E4_SERIAL_TX_PIN PD11 + #define E4_SERIAL_RX_PIN PD11 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH0 +#define TEMP_1_PIN PC2 // TH1 +#define TEMP_2_PIN PC3 // TH2 +#define TEMP_BED_PIN PC0 // TB + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB1 // HE0 +#define HEATER_1_PIN PB0 // HE1 +#define HEATER_2_PIN PA3 // HE2 +#define HEATER_BED_PIN PB10 // H-BED + +#define FAN_PIN PA2 // FAN0 +#define FAN1_PIN PA1 // FAN1 +#define FAN2_PIN PA0 // FAN2 + +// +// Misc. Functions +// +#define MT_DET_1 Y_MAX_PIN +#define MT_DET_2 Z_MAX_PIN +#define PW_DET Y_MAX_PIN +#define PW_OFF Z_MAX_PIN + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN MT_DET_1 +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN MT_DET_2 +#endif + +#define POWER_LOSS_PIN PW_DET +#define PS_ON_PIN PW_OFF + +// Random Info +#define USB_SERIAL -1 // USB Serial + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +// +// Onboard SD card +// +// detect pin dont work when ONBOARD and NO_SD_HOST_DRIVE disabled +#if SD_CONNECTION_IS(ONBOARD) + #define ENABLE_SPI3 + #define SD_SS_PIN -1 + #define SDSS PC9 + #define SD_SCK_PIN PC10 + #define SD_MISO_PIN PC11 + #define SD_MOSI_PIN PC12 + #define SD_DETECT_PIN PC4 +// +// LCD SD +// +#elif SD_CONNECTION_IS(LCD) + #define ENABLE_SPI1 + #define SDSS PA4 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_DETECT_PIN PB11 +#endif + +/** + * _____ _____ + * (BEEPER)PB2 | · · | PE10(BTN_ENC) (SPI1 MISO) PA6 | · · | PA5 (SPI1 SCK) + * (LCD_EN)PE11 | · · | PD10(LCD_RS) (BTN_EN1) PE9 | · · | PA4 (SPI1 CS) + * (LCD_D4)PD9 | · · PD8(LCD_D5) (BTN_EN2) PE8 | · · PA7 (SPI1 MOSI) + * (LCD_D6)PE15 | · · | PE7(LCD_D7) (SPI1_RS) PB11 | · · | RESET + * GND | · · | 5V GND | · · | 3.3V + *  ̄ ̄ ̄  ̄ ̄ ̄ + * EXP1 EXP2 + */ + +#if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X -17253 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 11579 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 514 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -24 + #endif + #ifndef TOUCH_ORIENTATION + #define TOUCH_ORIENTATION TOUCH_LANDSCAPE + #endif + + #define TFT_CS_PIN PE15 + #define TFT_SCK_PIN PA5 + #define TFT_MISO_PIN PA6 + #define TFT_MOSI_PIN PA7 + #define TFT_DC_PIN PE7 + #define TFT_RST_PIN PD10 + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN PD10 + #define TFT_BACKLIGHT_PIN PE11 + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + #define LCD_BACKLIGHT_PIN PE11 + #ifndef TFT_WIDTH + #define TFT_WIDTH 480 + #endif + #ifndef TFT_HEIGHT + #define TFT_HEIGHT 320 + #endif + + #define TOUCH_CS_PIN PD9 // SPI1_NSS + #define TOUCH_SCK_PIN PA5 // SPI1_SCK + #define TOUCH_MISO_PIN PA6 // SPI1_MISO + #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI + + #define BTN_EN1 PE9 + #define BTN_EN2 PE8 + #define BEEPER_PIN PB2 + #define BTN_ENC PE10 + + #define LCD_READ_ID 0xD3 + #define LCD_USE_DMA_SPI + + #define TFT_BUFFER_SIZE 14400 + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN PB2 + #define BTN_ENC PE10 + #define LCD_PINS_ENABLE PE11 + #define LCD_PINS_RS PD10 + #define BTN_EN1 PE9 + #define BTN_EN2 PE8 + #define LCD_BACKLIGHT_PIN -1 + + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + //#define LCD_BACKLIGHT_PIN -1 + //#define LCD_RESET_PIN -1 + #define DOGLCD_A0 PD11 + #define DOGLCD_CS PE15 + //#define DOGLCD_SCK PA5 + //#define DOGLCD_MOSI PA7 + + #elif ENABLED(MKS_MINI_12864_V3) + #define DOGLCD_CS PE11 + #define DOGLCD_A0 PD10 + #define LCD_PINS_DC DOGLCD_A0 + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN PD9 + #define NEOPIXEL_PIN PD8 + #define DOGLCD_MOSI PA7 + #define DOGLCD_SCK PA5 + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + //#define LCD_SCREEN_ROT_180 + + #else + + #define LCD_PINS_D4 PD9 + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 PD8 + #define LCD_PINS_D6 PE15 + #define LCD_PINS_D7 PE7 + #endif + + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #define BOARD_ST7920_DELAY_3 DELAY_NS(600) + + #endif // !MKS_MINI_12864 + +#endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index 726e9a6586..6795b92892 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -59,7 +59,7 @@ // // Limit Switches // -#define X_DIAG_PIN PD15 +#define X_DIAG_PIN PA15 #define Y_DIAG_PIN PD2 #define Z_DIAG_PIN PC8 #define E0_DIAG_PIN PC4 @@ -172,26 +172,27 @@ // // Thermocouples // -//#define MAX6675_SS_PIN HEATER_0_PIN // TC1 - CS1 -//#define MAX6675_SS_PIN HEATER_1_PIN // TC2 - CS2 +//#define TEMP_0_CS_PIN HEATER_0_PIN // TC1 - CS1 +//#define TEMP_0_CS_PIN HEATER_1_PIN // TC2 - CS2 // // Misc. Functions // -#define MT_DET_1 PA4 -#define MT_DET_2 PE6 -#define PW_DET PA13 -#define PW_OFF PB2 +#define MT_DET_1_PIN PA4 +#define MT_DET_2_PIN PE6 +#define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE #ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN MT_DET_1 + #define FIL_RUNOUT_PIN MT_DET_1_PIN #endif #ifndef FIL_RUNOUT2_PIN - #define FIL_RUNOUT2_PIN MT_DET_2 + #define FIL_RUNOUT2_PIN MT_DET_2_PIN #endif -#define POWER_LOSS_PIN PW_DET -#define PS_ON_PIN PW_OFF +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PA13 // PW_DET +#endif +#define PS_ON_PIN PB2 // PW_OFF // // Enable MKSPWC support @@ -212,36 +213,43 @@ #define SDCARD_CONNECTION ONBOARD #endif +// MKS WIFI MODULE +#if ENABLED(MKS_WIFI_MODULE) + #define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN + #define WIFI_RESET_PIN PE9 // MKS ESP WIFI RESET PIN +#endif + +// MKS TEST +#if ENABLED(MKS_TEST) + #define MKS_TEST_POWER_LOSS_PIN PA13 // PW_DET + #define MKS_TEST_PS_ON_PIN PB2 // PW_OFF +#endif + // // Onboard SD card // // detect pin dont work when ONBOARD and NO_SD_HOST_DRIVE disabled #if SD_CONNECTION_IS(ONBOARD) - #define CUSTOM_SPI_PINS // TODO: needed because is the only way to set SPI3 for SD on STM32 (by now) - #if ENABLED(CUSTOM_SPI_PINS) - #define ENABLE_SPI3 - #define SD_SS_PIN -1 - #define SDSS PC9 - #define SD_SCK_PIN PC10 - #define SD_MISO_PIN PC11 - #define SD_MOSI_PIN PC12 - #define SD_DETECT_PIN PD12 - #endif + #define ENABLE_SPI3 + #define SD_SS_PIN -1 + #define SDSS PC9 + #define SD_SCK_PIN PC10 + #define SD_MISO_PIN PC11 + #define SD_MOSI_PIN PC12 + #define SD_DETECT_PIN PD12 #endif // // LCD SD // #if SD_CONNECTION_IS(LCD) - #define CUSTOM_SPI_PINS - #if ENABLED(CUSTOM_SPI_PINS) - #define ENABLE_SPI1 - #define SDSS PE10 - #define SD_SCK_PIN PA5 - #define SD_MISO_PIN PA6 - #define SD_MOSI_PIN PA7 - #define SD_DETECT_PIN PE12 - #endif + #define ENABLE_SPI1 + #define SDSS PE10 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_DETECT_PIN PE12 #endif // @@ -345,6 +353,20 @@ //#define MKS_LCD12864B //#undef SHOW_BOOTSCREEN + #elif ENABLED(MKS_MINI_12864_V3) + #define DOGLCD_CS PD13 + #define DOGLCD_A0 PC6 + #define LCD_PINS_DC DOGLCD_A0 + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN PE14 + #define NEOPIXEL_PIN PE15 + #define DOGLCD_MOSI PA7 + #define DOGLCD_SCK PA5 + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + //#define LCD_SCREEN_ROT_180 + #else // !MKS_MINI_12864 #define LCD_PINS_D4 PE14 diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 1000326dad..0b9512a1cb 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -31,7 +31,7 @@ #define BOARD_INFO_NAME "MKS Robin PRO V2" // Avoid conflict with TIMER_TONE -#define STEP_TIMER 10 +#define STEP_TIMER 10 // Use one of these or SDCard-based Emulation will be used //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation @@ -50,7 +50,7 @@ // // Note: MKS Robin board is using SPI2 interface. // -//#define SPI_MODULE 2 +//#define SPI_MODULE 2 // // Servos @@ -189,8 +189,8 @@ // // Thermocouples // -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PE6 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // // Misc. Functions @@ -203,7 +203,7 @@ //#define LED_PIN PB2 #ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION ONBOARD + #define SDCARD_CONNECTION ONBOARD #endif //#define USE_NEW_SPI_API 1 @@ -214,21 +214,17 @@ // // detect pin dont work when ONBOARD and NO_SD_HOST_DRIVE disabled #if !defined(SDCARD_CONNECTION) || SDCARD_CONNECTION == ONBOARD - #define CUSTOM_SPI_PINS - #if ENABLED(CUSTOM_SPI_PINS) - - #if USE_NEW_SPI_API - #define SD_SPI MARLIN_SPI(HardwareSPI3, PC9) - #else - #define ENABLE_SPI3 - #define SD_SS_PIN -1 - #define SDSS PC9 - #define SD_SCK_PIN PC10 - #define SD_MISO_PIN PC11 - #define SD_MOSI_PIN PC12 - #endif - #define SD_DETECT_PIN PD12 + #if USE_NEW_SPI_API + #define SD_SPI MARLIN_SPI(HardwareSPI3, PC9) + #else + #define ENABLE_SPI3 + #define SD_SS_PIN -1 + #define SDSS PC9 + #define SD_SCK_PIN PC10 + #define SD_MISO_PIN PC11 + #define SD_MOSI_PIN PC12 #endif + #define SD_DETECT_PIN PD12 #endif /* @@ -236,22 +232,19 @@ // LCD SD // #if SDCARD_CONNECTION == LCD - #define CUSTOM_SPI_PINS - #if ENABLED(CUSTOM_SPI_PINS) - #define ENABLE_SPI1 - #define SDSS PE10 - #define SD_SCK_PIN PA5 - #define SD_MISO_PIN PA6 - #define SD_MOSI_PIN PA7 - #define SD_DETECT_PIN PE12 - #endif + #define ENABLE_SPI1 + #define SDSS PE10 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_DETECT_PIN PE12 #endif */ // // LCD / Controller #define SPI_FLASH -#define HAS_SPI_FLASH 1 +#define HAS_SPI_FLASH 1 #define SPI_DEVICE 2 #define SPI_FLASH_SIZE 0x1000000 #if ENABLED(SPI_FLASH) diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h index be6e4f8a34..7bf148874c 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h @@ -45,8 +45,8 @@ // This will be difficult to solve from the Arduino IDE, without modifying the RUMBA32 variant // included with the STM32 framework. -#define STEP_TIMER 10 -#define TEMP_TIMER 14 +#define STEP_TIMER 10 +#define TEMP_TIMER 14 // // Limit Switches diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index 0e6842125e..539a3bb8f3 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -141,7 +141,7 @@ #endif // NO_EXTRUDRBOARD // Enable control of stepper motor currents with the I2C based MCP4728 DAC used on Printrboard REVF -#define HAS_MOTOR_CURRENT_DAC +#define HAS_MOTOR_CURRENT_DAC 1 // Set default drive strength percents if not already defined - X, Y, Z, E axis #ifndef DAC_MOTOR_CURRENT_DEFAULT diff --git a/Marlin/src/pins/teensy2/pins_TEENSYLU.h b/Marlin/src/pins/teensy2/pins_TEENSYLU.h index f551d802cf..535ce534d4 100644 --- a/Marlin/src/pins/teensy2/pins_TEENSYLU.h +++ b/Marlin/src/pins/teensy2/pins_TEENSYLU.h @@ -18,6 +18,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +#pragma once /** * Rev C 2 JUN 2017 diff --git a/Marlin/src/sd/Sd2Card_sdio.h b/Marlin/src/sd/Sd2Card_sdio.h index 1580344805..cc29f5d46d 100644 --- a/Marlin/src/sd/Sd2Card_sdio.h +++ b/Marlin/src/sd/Sd2Card_sdio.h @@ -29,6 +29,8 @@ bool SDIO_Init(); bool SDIO_ReadBlock(uint32_t block, uint8_t *dst); bool SDIO_WriteBlock(uint32_t block, const uint8_t *src); +bool SDIO_IsReady(); +uint32_t SDIO_GetCardSize(); class DiskIODriver_SDIO : public DiskIODriver { public: @@ -36,20 +38,22 @@ class DiskIODriver_SDIO : public DiskIODriver { bool readCSD(csd_t *csd) override { return false; } - bool readStart(const uint32_t block) override { return false; } - bool readData(uint8_t *dst) override { return false; } - bool readStop() override { return false; } + bool readStart(const uint32_t block) override { curBlock = block; return true; } + bool readData(uint8_t *dst) override { return readBlock(curBlock++, dst); } + bool readStop() override { curBlock = -1; return true; } - bool writeStart(const uint32_t block, const uint32_t) override { return false; } - bool writeData(const uint8_t *src) override { return false; } - bool writeStop() override { return false; } + bool writeStart(const uint32_t block, const uint32_t) override { curBlock = block; return true; } + bool writeData(const uint8_t *src) override { return writeBlock(curBlock++, src); } + bool writeStop() override { curBlock = -1; return true; } bool readBlock(uint32_t block, uint8_t *dst) override { return SDIO_ReadBlock(block, dst); } bool writeBlock(uint32_t block, const uint8_t *src) override { return SDIO_WriteBlock(block, src); } - uint32_t cardSize() override { return 0; } + uint32_t cardSize() override { return SDIO_GetCardSize(); } - bool isReady() override { return true; } + bool isReady() override { return SDIO_IsReady(); } void idle() override {} + private: + uint32_t curBlock; }; diff --git a/Marlin/src/sd/SdFatUtil.cpp b/Marlin/src/sd/SdFatUtil.cpp index 7d9f33dc50..e6f7a9a013 100644 --- a/Marlin/src/sd/SdFatUtil.cpp +++ b/Marlin/src/sd/SdFatUtil.cpp @@ -48,7 +48,7 @@ return &top - reinterpret_cast(sbrk(0)); } -#else +#elif defined(__AVR__) extern char* __brkval; extern char __bss_end; diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index dc3df482b5..d7aca6cdc7 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -32,7 +32,7 @@ #include "../lcd/marlinui.h" #if ENABLED(DWIN_CREALITY_LCD) - #include "../lcd/dwin/e3v2/dwin.h" + #include "../lcd/e3v2/creality/dwin.h" #endif #include "../module/planner.h" // for synchronize @@ -121,13 +121,12 @@ uint8_t CardReader::workDirDepth; #endif // SDCARD_SORT_ALPHA -#if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) - DiskIODriver_USBFlash CardReader::media_usbFlashDrive; +#if HAS_USB_FLASH_DRIVE + DiskIODriver_USBFlash CardReader::media_driver_usbFlash; #endif -#if NEED_SD2CARD_SDIO - DiskIODriver_SDIO CardReader::media_sdio; -#elif NEED_SD2CARD_SPI - DiskIODriver_SPI_SD CardReader::media_sd_spi; + +#if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI + CardReader::sdcard_driver_t CardReader::media_driver_sdcard; #endif DiskIODriver* CardReader::driver = nullptr; @@ -144,12 +143,10 @@ uint32_t CardReader::filesize, CardReader::sdpos; CardReader::CardReader() { changeMedia(& - #if SHARED_VOLUME_IS(SD_ONBOARD) - TERN(SDIO_SUPPORT, media_sdio, media_sd_spi) - #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) - media_usbFlashDrive + #if HAS_USB_FLASH_DRIVE && !SHARED_VOLUME_IS(SD_ONBOARD) + media_driver_usbFlash #else - TERN(SDIO_SUPPORT, media_sdio, media_sd_spi) + media_driver_sdcard #endif ); @@ -261,54 +258,84 @@ void CardReader::selectByName(SdFile dir, const char * const match) { } } -// -// Recursive method to print all files within a folder in flat -// DOS 8.3 format. This style of listing is the most compatible -// with legacy hosts. -// -// This method recurses to unlimited depth and lists every -// G-code file within the given parent. If the hierarchy is -// very deep this can blow up the stack, so a 'depth' parameter -// (as with printListingJSON) would be a good addition. -// -void CardReader::printListing(SdFile parent, const char * const prepend/*=nullptr*/) { +/** + * Recursive method to print all files within a folder in flat + * DOS 8.3 format. This style of listing is the most compatible + * with legacy hosts. + * + * This method recurses to unlimited depth and lists all G-code + * files within the given parent. If the hierarchy is very deep + * this can blow up the stack, so a 'depth' parameter would be a + * good addition. + */ +void CardReader::printListing( + SdFile parent + OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) + , const char * const prepend/*=nullptr*/ + OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong/*=nullptr*/) +) { dir_t p; while (parent.readDir(&p, longFilename) > 0) { if (DIR_IS_SUBDIR(&p)) { - // Get the short name for the item, which we know is a folder - char dosFilename[FILENAME_LENGTH]; + size_t lenPrepend = prepend ? strlen(prepend) + 1 : 0; + // Allocate enough stack space for the full path including / separator + char path[lenPrepend + FILENAME_LENGTH]; + if (prepend) { + strcpy(path, prepend); + path[lenPrepend - 1] = '/'; + } + char* dosFilename = path + lenPrepend; createFilename(dosFilename, p); - // Allocate enough stack space for the full path to a folder, trailing slash, and nul - const bool prepend_is_empty = (!prepend || prepend[0] == '\0'); - const int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(dosFilename) + 1 + 1; - char path[len]; - - // Append the FOLDERNAME12/ to the passed string. - // It contains the full path to the "parent" argument. - // We now have the full path to the item in this folder. - strcpy(path, prepend_is_empty ? "/" : prepend); // root slash if prepend is empty - strcat(path, dosFilename); // FILENAME_LENGTH characters maximum - strcat(path, "/"); // 1 character - - // Serial.print(path); - // Get a new directory object using the full path // and dive recursively into it. SdFile child; // child.close() in destructor if (child.open(&parent, dosFilename, O_READ)) - printListing(child, path); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + if (includeLongNames) { + size_t lenPrependLong = prependLong ? strlen(prependLong) + 1 : 0; + // Allocate enough stack space for the full long path including / separator + char pathLong[lenPrependLong + strlen(longFilename) + 1]; + if (prependLong) { + strcpy(pathLong, prependLong); + pathLong[lenPrependLong - 1] = '/'; + } + strcpy(pathLong + lenPrependLong, longFilename); + printListing(child, true, path, pathLong); + } + else + printListing(child, false, path); + #else + printListing(child, path); + #endif else { SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename); return; } } else if (is_dir_or_gcode(p)) { - if (prepend) SERIAL_ECHO(prepend); + if (prepend) { + SERIAL_ECHO(prepend); + SERIAL_CHAR('/'); + } SERIAL_ECHO(createFilename(filename, p)); SERIAL_CHAR(' '); - SERIAL_ECHOLN(p.fileSize); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + if (!includeLongNames) + #endif + SERIAL_ECHOLN(p.fileSize); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + else { + SERIAL_ECHO(p.fileSize); + SERIAL_CHAR(' '); + if (prependLong) { + SERIAL_ECHO(prependLong); + SERIAL_CHAR('/'); + } + SERIAL_ECHOLN(longFilename[0] ? longFilename : "???"); + } + #endif } } } @@ -316,10 +343,10 @@ void CardReader::printListing(SdFile parent, const char * const prepend/*=nullpt // // List all files on the SD card // -void CardReader::ls() { +void CardReader::ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames/*=false*/)) { if (flag.mounted) { root.rewind(); - printListing(root); + printListing(root OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames)); } } @@ -912,7 +939,7 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, con while (atom_ptr) { // Find next subdirectory delimiter - char * const name_end = strchr(atom_ptr, '/'); + const char * const name_end = strchr(atom_ptr, '/'); // Last atom in the path? Item found. if (name_end <= atom_ptr) break; @@ -997,6 +1024,7 @@ int8_t CardReader::cdup() { void CardReader::cdroot() { workDir = root; flag.workDirIsRoot = true; + workDirDepth = 0; TERN_(SDCARD_SORT_ALPHA, presort()); } @@ -1126,7 +1154,7 @@ void CardReader::cdroot() { #if DISABLED(SDSORT_USES_RAM) selectFileByIndex(o1); // Pre-fetch the first entry and save it strcpy(name1, longest_filename()); // so the loop only needs one fetch - #if ENABLED(HAS_FOLDER_SORTING) + #if HAS_FOLDER_SORTING bool dir1 = flag.filenameIsDir; #endif #endif diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 35d7627421..66cb97baeb 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -199,7 +199,7 @@ public: FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); } #endif - static void ls(); + static void ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames=false)); #if ENABLED(POWER_LOSS_RECOVERY) static bool jobRecoverFileExists(); @@ -235,12 +235,13 @@ public: #endif #if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) - static DiskIODriver_USBFlash media_usbFlashDrive; + #define HAS_USB_FLASH_DRIVE 1 + static DiskIODriver_USBFlash media_driver_usbFlash; #endif - #if NEED_SD2CARD_SDIO - static DiskIODriver_SDIO media_sdio; - #elif NEED_SD2CARD_SPI - static DiskIODriver_SPI_SD media_sd_spi; + + #if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI + typedef TERN(NEED_SD2CARD_SDIO, DiskIODriver_SDIO, DiskIODriver_SPI_SD) sdcard_driver_t; + static sdcard_driver_t media_driver_sdcard; #endif private: @@ -329,7 +330,12 @@ private: static int countItems(SdFile dir); static void selectByIndex(SdFile dir, const uint8_t index); static void selectByName(SdFile dir, const char * const match); - static void printListing(SdFile parent, const char * const prepend=nullptr); + static void printListing( + SdFile parent + OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) + , const char * const prepend=nullptr + OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr) + ); #if ENABLED(SDCARD_SORT_ALPHA) static void flush_presort(); diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index ea7472c5da..e0c1d8f38d 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -37,7 +37,7 @@ env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 tee TESTPATH=buildroot/tests STATE_FILE="./.pio/.mftestrc" -SED=$(which gsed || which sed) +SED=$(which gsed sed | head -n1) shopt -s extglob nocasematch diff --git a/buildroot/bin/opt_disable b/buildroot/bin/opt_disable index 18ec03aa94..0444e1b773 100755 --- a/buildroot/bin/opt_disable +++ b/buildroot/bin/opt_disable @@ -3,7 +3,7 @@ # exit on first failure set -e -SED=$(which gsed || which sed) +SED=$(which gsed sed | head -n1) for opt in "$@" ; do DID=0 ; FOUND=0 diff --git a/buildroot/bin/opt_enable b/buildroot/bin/opt_enable index d341ee9bd3..f9be82cbd1 100755 --- a/buildroot/bin/opt_enable +++ b/buildroot/bin/opt_enable @@ -3,7 +3,7 @@ # exit on first failure set -e -SED=$(which gsed || which sed) +SED=$(which gsed sed | head -n1) for opt in "$@" ; do DID=0 ; FOUND=0 diff --git a/buildroot/bin/opt_set b/buildroot/bin/opt_set index 3f67d78900..b9935512a4 100755 --- a/buildroot/bin/opt_set +++ b/buildroot/bin/opt_set @@ -3,7 +3,7 @@ # exit on first failure set -e -SED=$(which gsed || which sed) +SED=$(which gsed sed | head -n1) while [[ $# > 1 ]]; do DID=0 diff --git a/buildroot/bin/pins_set b/buildroot/bin/pins_set index 860c64940f..158c5224e6 100755 --- a/buildroot/bin/pins_set +++ b/buildroot/bin/pins_set @@ -6,6 +6,6 @@ NAM=${PINPATH[1]} PIN=$2 VAL=$3 -SED=$(which gsed || which sed) +SED=$(which gsed sed | head -n1) eval "${SED} -i '/^[[:blank:]]*\(\/\/\)*[[:blank:]]*\(#define \+${PIN}\b\).*$/{s//\2 ${VAL}/;h};\${x;/./{x;q0};x;q9}' Marlin/src/pins/$DIR/pins_${NAM}.h" || (echo "ERROR: pins_set Can't find ${PIN}" >&2 && exit 9) diff --git a/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json b/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json index e89ca0af73..e260950f25 100644 --- a/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json +++ b/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json @@ -2,7 +2,7 @@ "build": { "core": "stm32", "cpu": "cortex-m4", - "extra_flags": "-DSTM32F401xx", + "extra_flags": "-DSTM32F401xx -DARDUINO_STEVAL", "f_cpu": "84000000L", "hwids": [ [ diff --git a/buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json b/buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json index 1765634086..b0fd9db939 100644 --- a/buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json +++ b/buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json @@ -2,7 +2,7 @@ "build": { "core": "stm32", "cpu": "cortex-m4", - "extra_flags": "-DSTM32F407xx", + "extra_flags": "-DSTM32F407xx -DARDUINO_BLACK_F407VE", "f_cpu": "168000000L", "hwids": [ [ @@ -48,7 +48,7 @@ "upload": { "disable_flushing": false, "maximum_ram_size": 131072, - "maximum_size": 514288, + "maximum_size": 524288, "protocol": "stlink", "protocols": [ "stlink", diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py index f64f928787..668475dc01 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -8,10 +8,10 @@ Import("env") # Custom HEX from ELF env.AddPostAction( - join("$BUILD_DIR","${PROGNAME}.elf"), + join("$BUILD_DIR", "${PROGNAME}.elf"), env.VerboseAction(" ".join([ - "$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf - "\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path + "$OBJCOPY", "-O ihex", "$TARGET", + "\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path ]), "Building $TARGET")) # In-line command with arguments diff --git a/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py b/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py deleted file mode 100644 index c98059729f..0000000000 --- a/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py +++ /dev/null @@ -1,22 +0,0 @@ -# -# buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py -# Customizations for env:STM32F103VE_longer -# -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") - 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) - renamed.write(byte) - position += 1 - finally: - firmware.close() - renamed.close() - -marlin.add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index 01ee89e25e..83dfeca879 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -215,7 +215,13 @@ def search_compiler(): # Find the current platform compiler by searching the $PATH # which will be in a platformio toolchain bin folder path_regex = re.escape(env['PROJECT_PACKAGES_DIR']) - gcc = "g++" + + # See if the environment provides a default compiler + try: + gcc = env.GetProjectOption('custom_deps_gcc') + except: + gcc = "g++" + if env['PLATFORM'] == 'win32': path_separator = ';' path_regex += r'.*\\bin' @@ -241,6 +247,8 @@ def search_compiler(): return filepath filepath = env.get('CXX') + if filepath == 'CC': + filepath = gcc blab("Couldn't find a compiler! Fallback to %s" % filepath) return filepath diff --git a/buildroot/share/PlatformIO/scripts/custom_board.py b/buildroot/share/PlatformIO/scripts/custom_board.py index 5d3ca3c652..e462738190 100644 --- a/buildroot/share/PlatformIO/scripts/custom_board.py +++ b/buildroot/share/PlatformIO/scripts/custom_board.py @@ -1,6 +1,9 @@ # # buildroot/share/PlatformIO/scripts/custom_board.py # +# - For build.address replace VECT_TAB_ADDR to relocate the firmware +# - For build.ldscript use one of the linker scripts in buildroot/share/PlatformIO/ldscripts +# import marlin board = marlin.env.BoardConfig() diff --git a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py index 29705de442..fa91b7bb70 100644 --- a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py +++ b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py @@ -30,15 +30,3 @@ if env.MarlinFeatureIsEnabled("POSTMORTEM_DEBUGGING"): print("Done patching exception handler") print("Libmaple modified and ready for post mortem debugging") - -mf = env["MARLIN_FEATURES"] -rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0" -txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0" -if int(rxBuf) < 64: - rxBuf = "64" -if int(txBuf) < 64: - txBuf = "64" - -build_flags = env.get('BUILD_FLAGS') -build_flags.append("-DUSART_RX_BUF_SIZE=" + rxBuf + " -DUSART_TX_BUF_SIZE=" + txBuf) -env.Replace(BUILD_FLAGS=build_flags) diff --git a/buildroot/share/PlatformIO/scripts/generic_create_variant.py b/buildroot/share/PlatformIO/scripts/generic_create_variant.py index 75c62ef70e..7f76ef9426 100644 --- a/buildroot/share/PlatformIO/scripts/generic_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/generic_create_variant.py @@ -28,7 +28,7 @@ if len(platform_packages) == 0: else: platform_name = PackageSpec(platform_packages[0]).name -if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "tool-stm32duino" ]: +if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino" ]: platform_name = "framework-arduinoststm32" FRAMEWORK_DIR = platform.get_package_dir(platform_name) diff --git a/buildroot/share/PlatformIO/scripts/lerdge.py b/buildroot/share/PlatformIO/scripts/lerdge.py index 55f0a65ace..5c35c19e7d 100644 --- a/buildroot/share/PlatformIO/scripts/lerdge.py +++ b/buildroot/share/PlatformIO/scripts/lerdge.py @@ -27,11 +27,12 @@ def encrypt_file(input, output_file, file_length): output_file.write(input_file) return -# Encrypt ${PROGNAME}.bin and save it as build.firmware +# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt def encrypt(source, target, env): - print("Encrypting to:", board.get("build.firmware")) + fwname = board.get("build.encrypt") + print("Encrypting %s to %s" % (target[0].path, fwname)) firmware = open(target[0].path, "rb") - renamed = open(target[0].dir.path + "/" + board.get("build.firmware"), "wb") + renamed = open(target[0].dir.path + "/" + fwname, "wb") length = os.path.getsize(target[0].path) encrypt_file(firmware, renamed, length) @@ -39,8 +40,8 @@ def encrypt(source, target, env): firmware.close() renamed.close() -if 'firmware' in board.get("build").keys(): - marlin.add_post_action(encrypt); +if 'encrypt' in board.get("build").keys(): + marlin.add_post_action(encrypt); else: - print("You need to define output file via board_build.firmware = 'filename' parameter") - exit(1); + print("LERDGE builds require output file via board_build.encrypt = 'filename' parameter") + exit(1); diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py index d83ebceee2..3949037904 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -7,10 +7,12 @@ import os,shutil from SCons.Script import DefaultEnvironment env = DefaultEnvironment() +from os.path import join + 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) + s = join(src, item) + d = join(dst, item) if os.path.isdir(s): shutil.copytree(s, d, symlinks, ignore) else: @@ -64,12 +66,4 @@ def encrypt_mks(source, target, env, new_name): 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); + env.AddPostAction(join("$BUILD_DIR", "${PROGNAME}.bin"), action); diff --git a/buildroot/share/PlatformIO/scripts/mks_encrypt.py b/buildroot/share/PlatformIO/scripts/mks_encrypt.py deleted file mode 100644 index 59322a6388..0000000000 --- a/buildroot/share/PlatformIO/scripts/mks_encrypt.py +++ /dev/null @@ -1,28 +0,0 @@ -# -# buildroot/share/PlatformIO/scripts/mks_encrypt.py -# -# Apply encryption and save as 'build.firmware' for these environments: -# - env:mks_robin -# - env:flsun_hispeedv1 -# - env:mks_robin_nano35 -# -Import("env") - -from SCons.Script import DefaultEnvironment -board = DefaultEnvironment().BoardConfig() - -if 'firmware' in board.get("build").keys(): - - import marlin - - # Encrypt ${PROGNAME}.bin and save it as build.firmware - def encrypt(source, target, env): - marlin.encrypt_mks(source, target, env, board.get("build.firmware")) - - marlin.add_post_action(encrypt); - -else: - - 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 8c5e4ae276..2dea7c615f 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin.ld", "Robin.bin") +import robin +robin.prepare("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 7f6f538d6a..6ddeccbf80 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_e3.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_e3.py # -import marlin -marlin.prepare_robin("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin") +import robin +robin.prepare("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 1f3cacf873..5eeb93c096 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_e3p.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin") +import robin +robin.prepare("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 b8c039ada8..c2018336fd 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_lite.py # -import marlin -marlin.prepare_robin("0x08005000", "mks_robin_lite.ld", "mksLite.bin") +import robin +robin.prepare("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 bea8b80ace..42c8fb18b6 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_lite3.py # -import marlin -marlin.prepare_robin("0x08005000", "mks_robin_lite.ld", "mksLite3.bin") +import robin +robin.prepare("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 3ff9ccf4a6..b0d8388653 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_mini.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin") +import robin +robin.prepare("0x08007000", "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 319b4d4982..35e99830c4 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_nano.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin") +import robin +robin.prepare("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 310c3d6606..4a5726ad5b 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_nano35.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin") +import robin +robin.prepare("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 c624663a33..60e2482bb0 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_pro.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_pro.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_pro.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin") +import robin +robin.prepare("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin") diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py new file mode 100644 index 0000000000..b42b2f3531 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -0,0 +1,60 @@ +# +# offset_and_rename.py +# +# - If 'build.offset' is provided, either by JSON or by the environment... +# - Set linker flag LD_FLASH_OFFSET and relocate the VTAB based on 'build.offset'. +# - Set linker flag LD_MAX_DATA_SIZE based on 'build.maximum_ram_size'. +# - Define STM32_FLASH_SIZE from 'upload.maximum_size' for use by Flash-based EEPROM emulation. +# +# - For 'board_build.rename' add a post-action to rename the firmware file. +# +import os,sys,marlin +Import("env") + +from SCons.Script import DefaultEnvironment +board = DefaultEnvironment().BoardConfig() + +board_keys = board.get("build").keys() + +# +# For build.offset define LD_FLASH_OFFSET, used by ldscript.ld +# +if 'offset' in board_keys: + LD_FLASH_OFFSET = board.get("build.offset") + marlin.relocate_vtab(LD_FLASH_OFFSET) + + # Flash size + maximum_flash_size = int(board.get("upload.maximum_size") / 1024) + marlin.replace_define('STM32_FLASH_SIZE', maximum_flash_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 build.encrypt rename and encode the firmware file. +# +if 'encrypt' in board_keys: + + # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt + def encrypt(source, target, env): + marlin.encrypt_mks(source, target, env, board.get("build.encrypt")) + + marlin.add_post_action(encrypt); + +# +# For build.rename simply rename the firmware file. +# +if 'rename' in board_keys: + + def rename_target(source, target, env): + firmware = os.path.join(target[0].dir.path, board.get("build.rename")) + import shutil + shutil.copy(target[0].path, firmware) + + marlin.add_post_action(rename_target) diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 01cd9c9ef2..6e71ca9eb8 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -6,10 +6,13 @@ from os.path import join Import("env") -env.AddPostAction( - "$BUILD_DIR/${PROGNAME}.elf", - env.VerboseAction(" ".join([ - "$OBJCOPY", "-O", "srec", - "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PROGNAME}.srec\"" - ]), "Building " + join("$BUILD_DIR", "${PROGNAME}.srec")) -) +board = env.BoardConfig() +board_keys = board.get("build").keys() +if 'encrypt' in board_keys: + env.AddPostAction( + join("$BUILD_DIR", "${PROGNAME}.bin"), + env.VerboseAction(" ".join([ + "$OBJCOPY", "-O", "srec", + "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encrypt")) + "\"" + ]), "Building $TARGET") + ) diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 27e5c9d70a..f28319524a 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -61,10 +61,10 @@ def sanity_check_target(): 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 diff --git a/buildroot/share/PlatformIO/scripts/robin.py b/buildroot/share/PlatformIO/scripts/robin.py new file mode 100644 index 0000000000..50d0d92d2f --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/robin.py @@ -0,0 +1,12 @@ +# +# buildroot/share/PlatformIO/scripts/robin.py +# +import marlin + +# Apply customizations for a MKS Robin +def prepare(address, ldname, fwname): + def encrypt(source, target, env): + marlin.encrypt_mks(source, target, env, fwname) + marlin.relocate_firmware(address) + marlin.custom_ld_script(ldname) + marlin.add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/simulator.py b/buildroot/share/PlatformIO/scripts/simulator.py new file mode 100644 index 0000000000..fb9d93cceb --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/simulator.py @@ -0,0 +1,52 @@ +# +# PlatformIO pre: script for simulator builds +# + +# Get the environment thus far for the build +Import("env") + +#print(env.Dump()) + +# +# Give the binary a distinctive name +# + +env['PROGNAME'] = "MarlinSimulator" + +# +# If Xcode is installed add the path to its Frameworks folder, +# or if Mesa is installed try to use its GL/gl.h. +# + +import sys +if sys.platform == 'darwin': + + # + # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS') + # + env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ] + + # Default paths for Xcode and a lucky GL/gl.h dropped by Mesa + xcode_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" + mesa_path = "/opt/local/include/GL/gl.h" + + import os.path + + if os.path.exists(xcode_path): + + env['BUILD_FLAGS'] += [ "-F" + xcode_path ] + print("Using OpenGL framework headers from Xcode.app") + + elif os.path.exists(mesa_path): + + env['BUILD_FLAGS'] += [ '-D__MESA__' ] + print("Using OpenGL header from", mesa_path) + + else: + + print("\n\nNo OpenGL headers found. Install Xcode for matching headers, or use 'sudo port install mesa' to get a GL/gl.h.\n\n") + + # Break out of the PIO build immediately + sys.exit(1) + +env.AddCustomTarget("upload", "$BUILD_DIR/${PROGNAME}", "$BUILD_DIR/${PROGNAME}") diff --git a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py deleted file mode 100644 index b2b5daadb6..0000000000 --- a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py +++ /dev/null @@ -1,43 +0,0 @@ -# -# stm32_bootloader.py -# -import os,sys,shutil,marlin -Import("env") - -from SCons.Script import DefaultEnvironment -board = DefaultEnvironment().BoardConfig() - -# -# Copy the firmware.bin file to build.firmware, no encryption -# -def noencrypt(source, target, env): - firmware = os.path.join(target[0].dir.path, board.get("build.firmware")) - shutil.copy(target[0].path, firmware) - -# -# For build.offset define LD_FLASH_OFFSET, used by ldscript.ld -# -if 'offset' in board.get("build").keys(): - LD_FLASH_OFFSET = board.get("build.offset") - marlin.relocate_vtab(LD_FLASH_OFFSET) - - # Flash size - maximum_flash_size = int(board.get("upload.maximum_size") / 1024) - marlin.replace_define('STM32_FLASH_SIZE', maximum_flash_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) - -# -# Only copy the file if there's no encrypt -# -board_keys = board.get("build").keys() -if 'firmware' in board_keys and ('encrypt' not in board_keys or board.get("build.encrypt") == 'No'): - import marlin - marlin.add_post_action(noencrypt) diff --git a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py index 2be5a202ef..c3779289e0 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py +++ b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py @@ -3,21 +3,57 @@ # Import("env") -# Marlin has `RX_BUFFER_SIZE` and `TX_BUFFER_SIZE` to configure the -# buffer size for receiving and transmitting data respectively. -# Stm32duino uses another set of defines for the same purpose, -# so we get the values from the Marlin configuration and set -# them in `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE`. -# It is not possible to change the values at runtime, they must -# be set with build flags. +# Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to +# configure buffer sizes for receiving \ transmitting serial data. +# Stm32duino uses another set of defines for the same purpose, so this +# script gets the values from the configuration and uses them to define +# `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build +# flags so they are available for use by the platform. # # The script will set the value as the default one (64 bytes) # or the user-configured one, whichever is higher. +# +# Marlin's default buffer sizes are 128 for RX and 32 for TX. +# The highest value is taken (128/64). +# +# If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are +# defined, the first of these values will be used as the minimum. +build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"] mf = env["MARLIN_FEATURES"] -rxBuf = str(max(64, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0)) -txBuf = str(max(64, int(mf["TX_BUFFER_SIZE"]) if "TX_BUFFER_SIZE" in mf else 0)) -build_flags = env.get('BUILD_FLAGS') -build_flags.append("-DSERIAL_RX_BUFFER_SIZE=" + rxBuf) -build_flags.append("-DSERIAL_TX_BUFFER_SIZE=" + txBuf) -env.Replace(BUILD_FLAGS=build_flags) +# Get a build flag's value or None +def getBuildFlagValue(name): + for flag in build_flags: + if isinstance(flag, list) and flag[0] == name: + return flag[1] + + return None + +# Get an overriding buffer size for RX or TX from the build flags +def getInternalSize(side): + return getBuildFlagValue(f"MF_{side}_BUFFER_SIZE") or \ + getBuildFlagValue(f"SERIAL_{side}_BUFFER_SIZE") or \ + getBuildFlagValue(f"USART_{side}_BUF_SIZE") + +# Get the largest defined buffer size for RX or TX +def getBufferSize(side, default): + # Get a build flag value or fall back to the given default + internal = int(getInternalSize(side) or default) + flag = side + "_BUFFER_SIZE" + # Return the largest value + return max(int(mf[flag]), internal) if flag in mf else internal + +# Add a build flag if it's not already defined +def tryAddFlag(name, value): + if getBuildFlagValue(name) is None: + env.Append(BUILD_FLAGS=[f"-D{name}={value}"]) + +# Get the largest defined buffer sizes for RX or TX, using defaults for undefined +rxBuf = getBufferSize("RX", 128) +txBuf = getBufferSize("TX", 64) + +# Provide serial buffer sizes to the stm32duino platform +tryAddFlag("SERIAL_RX_BUFFER_SIZE", rxBuf) +tryAddFlag("SERIAL_TX_BUFFER_SIZE", txBuf) +tryAddFlag("USART_RX_BUF_SIZE", rxBuf) +tryAddFlag("USART_TX_BUF_SIZE", txBuf) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/PeripheralPins.c index 2ad0bb864c..a4f8f696ee 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/PeripheralPins.c @@ -232,6 +232,7 @@ const PinMap PinMap_PWM[] = { 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)}, + {PD_5, 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)}, {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, @@ -248,6 +249,7 @@ const PinMap PinMap_UART_TX[] = { 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)}, + {PD_6, 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)}, {PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h index 4305c81a45..f512a311e3 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h @@ -150,7 +150,7 @@ extern "C" { // PWM resolution //#define PWM_RESOLUTION 12 -#define PWM_FREQUENCY 20000 // >= 20 Khz => inaudible noise for fans +#define PWM_FREQUENCY 1000 // >= 20 Khz => inaudible noise for fans #define PWM_MAX_DUTY_CYCLE 255 // SPI Definitions diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h index 7dcbb793d0..41b194abe0 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h @@ -101,11 +101,24 @@ extern "C" { #endif // Override default Arduino configuration + // SPI Definitions -#define PIN_SPI_SS PA4 -#define PIN_SPI_MOSI PA7 -#define PIN_SPI_MISO PA6 -#define PIN_SPI_SCK PA5 +#if DEFAULT_SPI == 3 + #define PIN_SPI_SS PA15 + #define PIN_SPI_MOSI PB3 + #define PIN_SPI_MISO PB4 + #define PIN_SPI_SCK PB5 +#elif DEFAULT_SPI == 2 + #define PIN_SPI_SS PB12 + #define PIN_SPI_MOSI PB13 + #define PIN_SPI_MISO PB14 + #define PIN_SPI_SCK PB15 +#else + #define PIN_SPI_SS PA4 + #define PIN_SPI_MOSI PA7 + #define PIN_SPI_MISO PA6 + #define PIN_SPI_SCK PA5 +#endif // I2C Definitions #define PIN_WIRE_SDA PB7 @@ -118,6 +131,7 @@ extern "C" { #ifndef TIMER_SERVO #define TIMER_SERVO TIM2 #endif + // UART Definitions // Define here Serial instance number to map on Serial generic name #define SERIAL_UART_INSTANCE 1 @@ -126,7 +140,7 @@ extern "C" { #define PIN_SERIAL_RX PA10 #define PIN_SERIAL_TX PA9 -/* Extra HAL modules */ +// Extra HAL modules #if defined(STM32F103xE) || defined(STM32F103xG) #define HAL_DAC_MODULE_ENABLED #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h index b622b39376..496d8817a1 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h @@ -132,8 +132,12 @@ extern "C" { // Timer Definitions (optional) // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin -#define TIMER_TONE TIM3 -#define TIMER_SERVO TIM2 +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld index 2a61072cb1..fee7418b04 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld @@ -60,8 +60,8 @@ _Min_Stack_Size = 0x400;; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -FLASH (rx) : ORIGIN = 0x8010000, LENGTH = 512K -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET } /* Define output sections */ diff --git a/buildroot/share/fonts/genallfont.sh b/buildroot/share/fonts/genallfont.sh index 0a66990212..d5cad54361 100755 --- a/buildroot/share/fonts/genallfont.sh +++ b/buildroot/share/fonts/genallfont.sh @@ -119,7 +119,7 @@ if [ 1 = 1 ]; then * along with this program. If not, see . * */ -#include +#include #if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7) // reduced font (only symbols 1 - 127) - saves about 1278 bytes of FLASH diff --git a/buildroot/share/fonts/uxggenpages.sh b/buildroot/share/fonts/uxggenpages.sh index a99fd99024..047d3ae661 100755 --- a/buildroot/share/fonts/uxggenpages.sh +++ b/buildroot/share/fonts/uxggenpages.sh @@ -169,7 +169,7 @@ cat <fontutf8-data.h * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include +#include $TMPA #define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {$TMPB}; diff --git a/buildroot/share/git/mfconfig b/buildroot/share/git/mfconfig index fb48d6b5a4..70642a5d39 100755 --- a/buildroot/share/git/mfconfig +++ b/buildroot/share/git/mfconfig @@ -149,7 +149,7 @@ if [[ $ACTION == "init" ]]; then ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset TPARA..." >/dev/null # Update the %VERSION% in the README.md file - SED=$(which gsed || which sed) + SED=$(which gsed sed | head -n1) VERS=$( echo $EXPORT | $SED 's/release-//' ) eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md" rm -f README.md~ diff --git a/buildroot/tests/BIGTREE_BTT002 b/buildroot/tests/BIGTREE_BTT002 index ba13e3eafd..7288c5ef52 100755 --- a/buildroot/tests/BIGTREE_BTT002 +++ b/buildroot/tests/BIGTREE_BTT002 @@ -16,5 +16,11 @@ opt_set MOTHERBOARD BOARD_BTT_BTT002_V1_0 \ Y_DRIVER_TYPE TMC2130 exec_test $1 $2 "BigTreeTech BTT002 Default Configuration plus TMC steppers" "$3" +# +# A test with Probe Temperature Compensation enabled +# +use_example_configs Prusa/MK3S-BigTreeTech-BTT002 +exec_test $1 $2 "BigTreeTech BTT002 with Prusa MK3S and related options" "$3" + # clean up restore_configs diff --git a/buildroot/tests/BIGTREE_GTR_V1_0 b/buildroot/tests/BIGTREE_GTR_V1_0 index 24293a4932..58cbe4a142 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0 +++ b/buildroot/tests/BIGTREE_GTR_V1_0 @@ -20,11 +20,12 @@ exec_test $1 $2 "BigTreeTech GTR | 8 Extruders | Auto-Fan | Mixed TMC Drivers | restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ - EXTRUDERS 6 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 TEMP_SENSOR_5 1 \ - NUM_Z_STEPPER_DRIVERS 3 \ - DEFAULT_Kp_LIST '{ 22.2, 20.0, 21.0, 19.0, 18.0, 17.0 }' DEFAULT_Ki_LIST '{ 1.08 }' DEFAULT_Kd_LIST '{ 114.0, 112.0, 110.0, 108.0 }' -opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_INIT_BEFORE_SWAP TOOLCHANGE_FS_PRIME_FIRST_USED PID_PARAMS_PER_HOTEND -exec_test $1 $2 "BigTreeTech GTR | 6 Extruders | Triple Z" "$3" + EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 \ + NUM_Z_STEPPER_DRIVERS 4 \ + DEFAULT_Kp_LIST '{ 22.2, 20.0, 21.0, 19.0, 18.0 }' DEFAULT_Ki_LIST '{ 1.08 }' DEFAULT_Kd_LIST '{ 114.0, 112.0, 110.0, 108.0 }' +opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_INIT_BEFORE_SWAP TOOLCHANGE_FS_PRIME_FIRST_USED \ + PID_PARAMS_PER_HOTEND Z_MULTI_ENDSTOPS +exec_test $1 $2 "BigTreeTech GTR | 6 Extruders | Quad Z + Endstops" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ diff --git a/buildroot/tests/DUE b/buildroot/tests/DUE index 9931776e00..9eb2157428 100755 --- a/buildroot/tests/DUE +++ b/buildroot/tests/DUE @@ -24,7 +24,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE CALIBRATION_GCODE \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ FWRETRACT ARC_SUPPORT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ - PSU_CONTROL AUTO_POWER_CONTROL \ + PSU_CONTROL AUTO_POWER_CONTROL E_DUAL_STEPPER_DRIVERS \ PIDTEMPBED SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER \ PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL \ EXTENSIBLE_UI @@ -38,10 +38,9 @@ restore_configs opt_set MOTHERBOARD BOARD_RADDS NUM_Z_STEPPER_DRIVERS 3 opt_enable USE_XMAX_PLUG USE_YMAX_PLUG ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \ Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS Z_SAFE_HOMING - #TOUCH_UI_FTDI_EVE LCD_ALEPHOBJECTS_CLCD_UI OTHER_PIN_LAYOUT pins_set ramps/RAMPS X_MAX_PIN -1 pins_set ramps/RAMPS Y_MAX_PIN -1 -exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN" "$3" +exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3" # # Test SWITCHING_EXTRUDER diff --git a/buildroot/tests/LPC1768 b/buildroot/tests/LPC1768 index 95a055d695..b4e489d310 100755 --- a/buildroot/tests/LPC1768 +++ b/buildroot/tests/LPC1768 @@ -16,7 +16,7 @@ set -e restore_configs opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \ NEOPIXEL_TYPE NEO_GRB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24 -opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED \ +opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED E_DUAL_STEPPER_DRIVERS \ NEOPIXEL_LED NEOPIXEL_IS_SEQUENTIAL NEOPIXEL_STARTUP_TEST NEOPIXEL_BKGD_INDEX_FIRST NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_COLOR NEOPIXEL_BKGD_ALWAYS_ON exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel" "$3" diff --git a/buildroot/tests/STM32F103RET6_creality b/buildroot/tests/STM32F103RET6_creality index a3f885147e..8348b6347d 100755 --- a/buildroot/tests/STM32F103RET6_creality +++ b/buildroot/tests/STM32F103RET6_creality @@ -10,7 +10,7 @@ set -e # Build with configs included in the PR # use_example_configs "Creality/Ender-3 V2" -opt_enable MARLIN_DEV_MODE +opt_enable MARLIN_DEV_MODE BUFFER_MONITORING exec_test $1 $2 "Ender 3 v2" "$3" use_example_configs "Creality/Ender-3 V2" diff --git a/buildroot/tests/STM32F103VE_longer_maple b/buildroot/tests/STM32F103VE_longer_maple new file mode 100755 index 0000000000..4570a3214d --- /dev/null +++ b/buildroot/tests/STM32F103VE_longer_maple @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# Build tests for STM32F103VET6 (using maple STM32F1 framework) +# + +# exit on first failure +set -e + +use_example_configs Alfawise/U20 +opt_enable BAUD_RATE_GCODE +exec_test $1 $2 "maple CLASSIC_UI U20 config" "$3" + +use_example_configs Alfawise/U20 +opt_enable BAUD_RATE_GCODE TFT_COLOR_UI +opt_disable TFT_CLASSIC_UI CUSTOM_STATUS_SCREEN_IMAGE +exec_test $1 $2 "maple COLOR_UI U20 config" "$3" + +use_example_configs Alfawise/U20-bltouch +opt_enable BAUD_RATE_GCODE +exec_test $1 $2 "maple BLTouch U20 config" + +# cleanup +restore_configs diff --git a/buildroot/tests/mega1280 b/buildroot/tests/mega1280 index 8b16b1dbc8..d8cefbaf81 100755 --- a/buildroot/tests/mega1280 +++ b/buildroot/tests/mega1280 @@ -47,7 +47,9 @@ exec_test $1 $2 "RAMPS | DELTA | RRD LCD | DELTA_AUTO_CALIBRATION | DELTA_CALIBR # # Delta Config (generic) + ABL bilinear + BLTOUCH use_example_configs delta/generic -opt_set LCD_LANGUAGE cz +opt_set LCD_LANGUAGE cz \ + Z_MIN_PROBE_ENDSTOP_INVERTING false \ + Z_MIN_ENDSTOP_INVERTING false opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER DELTA_CALIBRATION_MENU AUTO_BED_LEVELING_BILINEAR BLTOUCH exec_test $1 $2 "DELTA | RRD LCD | ABL Bilinear | BLTOUCH" "$3" diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index ecf82267f4..edae6d24ae 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -68,7 +68,8 @@ exec_test $1 $2 "Multiple runout sensors (x5) | Distinct runout states" "$3" # restore_configs opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO MIXING_STEPPERS 5 LCD_LANGUAGE ru \ - NUM_RUNOUT_SENSORS E_STEPPERS FIL_RUNOUT2_PIN 16 FIL_RUNOUT3_PIN 17 FIL_RUNOUT4_PIN 4 FIL_RUNOUT5_PIN 5 + NUM_RUNOUT_SENSORS E_STEPPERS REDUNDANT_PART_COOLING_FAN 1 \ + FIL_RUNOUT2_PIN 16 FIL_RUNOUT3_PIN 17 FIL_RUNOUT4_PIN 4 FIL_RUNOUT5_PIN 5 opt_enable MIXING_EXTRUDER GRADIENT_MIX GRADIENT_VTOOL CR10_STOCKDISPLAY \ USE_CONTROLLER_FAN CONTROLLER_FAN_EDITABLE CONTROLLER_FAN_IGNORE_Z \ FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE @@ -193,10 +194,21 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_C MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ - LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER + LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER I2C_AMMETER exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 44780 LCD " "$3" +# +# Test redundant temperature sensors + MAX TC +# +restore_configs +opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 1 \ + TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \ + TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \ + TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 + +exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675" "$3" + # # Language files test with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER # diff --git a/buildroot/tests/mks_robin_nano35 b/buildroot/tests/mks_robin_nano35 index 0891744692..bd16fe48e9 100755 --- a/buildroot/tests/mks_robin_nano35 +++ b/buildroot/tests/mks_robin_nano35 @@ -21,8 +21,9 @@ exec_test $1 $2 "MKS Robin nano v1.2 Emulated DOGM FSMC" "$3" use_example_configs Mks/Robin opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 opt_disable TFT_INTERFACE_FSMC -opt_enable TFT_INTERFACE_SPI -exec_test $1 $2 "MKS Robin v2 nano Emulated DOGM SPI" "$3" +opt_enable TFT_INTERFACE_SPI MKS_WIFI_MODULE +opt_add MKS_TEST +exec_test $1 $2 "MKS Robin v2 nano Emulated DOGM SPI, MKS_WIFI_MODULE" "$3" # # MKS Robin nano v1.2 LVGL FSMC diff --git a/buildroot/tests/mks_robin_nano35_maple b/buildroot/tests/mks_robin_nano35_maple index f1549a8103..ebd5466ce6 100755 --- a/buildroot/tests/mks_robin_nano35_maple +++ b/buildroot/tests/mks_robin_nano35_maple @@ -32,6 +32,7 @@ use_example_configs Mks/Robin opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 opt_disable TFT_INTERFACE_FSMC TFT_COLOR_UI TOUCH_SCREEN TFT_RES_320x240 SERIAL_PORT_2 opt_enable TFT_INTERFACE_SPI TFT_LVGL_UI TFT_RES_480x320 MKS_WIFI_MODULE +opt_add MKS_TEST exec_test $1 $2 "MKS Robin v2 nano LVGL SPI w/ WiFi" "$3" # diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index df2717c715..e755f81cf1 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -32,7 +32,8 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ - PSU_CONTROL AUTO_POWER_CONTROL POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \ + PSU_CONTROL PS_OFF_CONFIRM PS_OFF_SOUND AUTO_POWER_CONTROL \ + POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \ SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \ HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL opt_add DEBUG_POWER_LOSS_RECOVERY @@ -114,12 +115,12 @@ opt_set MOTHERBOARD BOARD_RAMBO \ FAN_MIN_PWM 50 FAN_KICKSTART_TIME 100 \ XY_FREQUENCY_LIMIT 15 opt_enable COREYX USE_XMAX_PLUG MIXING_EXTRUDER GRADIENT_MIX \ - BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY \ + BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY FILAMENT_WIDTH_SENSOR \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER MENU_ADDAUTOSTART SDSUPPORT SDCARD_SORT_ALPHA \ ENDSTOP_NOISE_THRESHOLD FAN_SOFT_PWM \ - FIX_MOUNTED_PROBE AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE FILAMENT_WIDTH_SENSOR PROBE_OFFSET_WIZARD \ + FIX_MOUNTED_PROBE PROBING_ESTEPPERS_OFF AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE PROBE_OFFSET_WIZARD \ Z_SAFE_HOMING SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER \ - SD_ABORT_ON_ENDSTOP_HIT HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT ADVANCED_OK M114_DETAIL \ + SD_ABORT_ON_ENDSTOP_HIT HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT HOST_PAUSE_M76 ADVANCED_OK M114_DETAIL \ VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS EXTRA_FAN_SPEED FWRETRACT \ USE_CONTROLLER_FAN CONTROLLER_FAN_EDITABLE CONTROLLER_FAN_USE_Z_ONLY exec_test $1 $2 "Rambo | CoreXY, Gradient Mix | Endstop Int. | Home Y > X | FW Retract ..." "$3" diff --git a/ini/avr.ini b/ini/avr.ini index cd10f13499..88f54a723c 100644 --- a/ini/avr.ini +++ b/ini/avr.ini @@ -53,8 +53,7 @@ board = megaatmega1280 [mega_extended_optimized] extends = common_avr8 board_build.variant = MARLIN_MEGA_EXTENDED -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +extra_scripts = ${env:mega2560ext.extra_scripts} upload_speed = 57600 build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues diff --git a/ini/esp32.ini b/ini/esp32.ini index 1aee88f692..fcfa829608 100644 --- a/ini/esp32.ini +++ b/ini/esp32.ini @@ -24,6 +24,6 @@ monitor_speed = 250000 #board_build.flash_mode = qio [env:FYSETC_E4] -platform = espressif32@1.11.2 +platform = espressif32@2.1.0 extends = env:esp32 board_build.partitions = default_16MB.csv diff --git a/ini/features.ini b/ini/features.ini index f8f995c69f..250540797d 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -27,15 +27,16 @@ HAS_TMC26X = TMC26XStepper=https://github.com/trinam src_filter=+ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + + +LIB_INTERNAL_MAX31865 = src_filter=+ NEOPIXEL_LED = adafruit/Adafruit NeoPixel@~1.8.0 src_filter=+ -TEMP_.+_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 +I2C_AMMETER = peterus/INA226Lib@1.1.2 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=+ HAS_MARLINUI_HD44780 = src_filter=+ -HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.4.5 +HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.5.0 src_filter=+ HAS_(FSMC|SPI|LTDC)_TFT = src_filter=+ + + HAS_FSMC_TFT = src_filter=+ + @@ -43,8 +44,8 @@ HAS_SPI_TFT = src_filter=+ SOFT_I2C_EEPROM = SlowSoftI2CMaster, SlowSoftWire=https://github.com/felias-fogg/SlowSoftWire/archive/master.zip SPI_EEPROM = src_filter=+ +DWIN_CREALITY_LCD = src_filter=+ HAS_GRAPHICAL_TFT = src_filter=+ -DWIN_CREALITY_LCD = src_filter=+ IS_TFTGLCD_PANEL = src_filter=+ HAS_TOUCH_BUTTONS = src_filter=+ HAS_LCD_MENU = src_filter=+ @@ -127,7 +128,7 @@ HAS_PRUSA_MMU1 = src_filter=+ HAS_PRUSA_MMU2 = src_filter=+ + PASSWORD_FEATURE = src_filter=+ + ADVANCED_PAUSE_FEATURE = src_filter=+ + + -AUTO_POWER_CONTROL = src_filter=+ +PSU_CONTROL = src_filter=+ HAS_POWER_MONITOR = src_filter=+ + POWER_LOSS_RECOVERY = src_filter=+ + PROBE_TEMP_COMPENSATION = src_filter=+ + @@ -165,7 +166,7 @@ HAS_USER_THERMISTORS = src_filter=+ SD_ABORT_ON_ENDSTOP_HIT = src_filter=+ BAUD_RATE_GCODE = src_filter=+ HAS_SMART_EFF_MOD = src_filter=+ -COOLANT_CONTROL = src_filter=+ +COOLANT_CONTROL|AIR_ASSIST = src_filter=+ AIR_EVACUATION = src_filter=+ HAS_SOFTWARE_ENDSTOPS = src_filter=+ HAS_DUPLICATION_MODE = src_filter=+ @@ -188,6 +189,7 @@ HAS_GCODE_M876 = src_filter=+ HAS_RESUME_CONTINUE = src_filter=+ HAS_STATUS_MESSAGE = src_filter=+ HAS_LCD_CONTRAST = src_filter=+ +HAS_LCD_BRIGHTNESS = src_filter=+ HAS_BUZZER = src_filter=+ LCD_SET_PROGRESS_MANUALLY = src_filter=+ TOUCH_SCREEN_CALIBRATION = src_filter=+ @@ -201,7 +203,8 @@ SDSUPPORT = src_filter=+ + GCODE_REPEAT_MARKERS = src_filter=+ + HAS_EXTRUDERS = src_filter=+ + + -HAS_COOLER = src_filter=+ + +HAS_COOLER = src_filter=+ +HAS_COOLER|LASER_COOLANT_FLOW_METER = src_filter=+ AUTO_REPORT_TEMPERATURES = src_filter=+ INCH_MODE_SUPPORT = src_filter=+ TEMPERATURE_UNITS_SUPPORT = src_filter=+ diff --git a/ini/lpc176x.ini b/ini/lpc176x.ini index 450585b01a..3c5f43764b 100644 --- a/ini/lpc176x.ini +++ b/ini/lpc176x.ini @@ -14,7 +14,7 @@ # [common_LPC] platform = https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.3.zip -platform_packages = framework-arduino-lpc176x@^0.2.6 +platform_packages = framework-arduino-lpc176x@^0.2.8 board = nxp_lpc1768 lib_ldf_mode = off lib_compat_mode = strict diff --git a/ini/native.ini b/ini/native.ini index dbdfd26f8b..b40ea836da 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -21,3 +21,110 @@ build_unflags = -Wall lib_ldf_mode = off lib_deps = src_filter = ${common.default_src_filter} + + +# +# Native Simulation +# Builds with a small subset of available features +# Required system libraries: SDL2, SDL2-net, OpenGL, GLM +# +# Tested with Linux (Mint 20) : gcc [9.3.0, 10.2.0]: libsdl2-dev[2.0.10], libsdl2-net-dev[2.0.1], libglm-dev[0.9.9.7, 0.9.9.8] +# +# Debugging with gdb in vscode is as easy as adding the launch task as usual, but platformio +# will randomly remove your task when it recreates its tasks from a template. Add your gdb +# launch task to '~/.platformio/penv/lib/python{PYTHON_VERSION}/site-packages/platformio/ide/tpls/vscode/.vscode' +# to avoid this until platformio updates. +# +[simulator_common] +platform = native +framework = +build_flags = ${common.build_flags} -std=gnu++17 -D__PLAT_NATIVE_SIM__ -DU8G_HAL_LINKS -I/usr/include/SDL2 -IMarlin -IMarlin/src/HAL/NATIVE_SIM/include -IMarlin/src/HAL/NATIVE_SIM/u8g +src_build_flags = -Wall -Wno-expansion-to-defined -Wcast-align +release_flags = -g0 -O3 -flto +debug_build_flags = -fstack-protector-strong -g -g3 -ggdb +lib_compat_mode = off +src_filter = ${common.default_src_filter} + + +lib_deps = ${common.lib_deps} + MarlinSimUI=https://github.com/p3p/MarlinSimUI.git + Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/marlin_sim_native.zip + LiquidCrystal=https://github.com/p3p/LiquidCrystal/archive/master.zip +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/simulator.py + + +[simulator_linux] +extends = simulator_common +build_flags = ${simulator_common.build_flags} -ldl -lpthread -lSDL2 -lSDL2_net -lGL + +[env:simulator_linux_debug] +platform = ${simulator_linux.platform} +extends = simulator_linux +build_type = debug + +[env:simulator_linux_release] +platform = ${simulator_linux.platform} +extends = simulator_linux +build_type = release +build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} + +# +# Simulator for macOS (MacPorts) +# +# sudo port install gcc10 gdb glm libsdl2 freetype +# sudo port install ld64 @3_3 +ld64_xcode +# sudo port uninstall ld64 ld64-latest +# cd /opt/local/bin +# sudo rm -f gcc g++ cc +# sudo ln gcc-mp-10 gcc ; sudo ln g++-mp-10 g++ ; sudo ln g++ cc +# cd - +# +# Use 'sudo port install mesa' to get a if no Xcode is installed. +# If Xcode is installed be sure to run `xcode-select --install` first. +# +# For VSCode debugging paste the block below near the top of launch.json. +# NOTE: The PlatformIO VSCode extension will remove it when regenerating launch.json. +# +# { "name": "Debug Sim", +# "type": "cppdbg", +# "request": "launch", +# "program": "${workspaceFolder}/.pio/build/simulator_macos/MarlinSimulator", +# "miDebuggerPath": "/opt/local/bin/ggdb", +# "MIMode": "gdb", +# "cwd": "${workspaceFolder}/.pio/build/simulator_macos" }, +# +[simulator_macos] +build_unflags = -lGL +custom_verbose = 0 +build_flags = + -I/opt/local/include + -I/opt/local/include/freetype2 + -I/opt/local/include/SDL2/ + -L/opt/local/lib + -Wl,-framework,OpenGl + -Wl,-framework,CoreFoundation + -lSDL2 + +[env:simulator_macos_debug] +platform = ${env:simulator_linux_release.platform} +extends = env:simulator_linux_debug +build_flags = ${env:simulator_linux_debug.build_flags} ${simulator_macos.build_flags} -ggdb -Og -D_THREAD_SAFE +build_unflags = ${simulator_macos.build_unflags} + +[env:simulator_macos_release] +platform = ${env:simulator_linux_release.platform} +extends = env:simulator_linux_release +build_flags = ${env:simulator_linux_release.build_flags} ${simulator_macos.build_flags} +build_unflags = ${simulator_macos.build_unflags} + +# +# Simulator for Windows 10 +# +# MSYS2 mingw-w64-x86_64 with these packages: +# pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-glm mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_net +# +[env:simulator_windows] +platform = ${simulator_common.platform} +extends = simulator_common +src_build_flags = ${simulator_common.src_build_flags} -fpermissive +build_flags = ${simulator_common.build_flags} ${simulator_common.debug_build_flags} -fno-stack-protector -Wl,-subsystem,windows -ldl -lmingw32 -lSDL2main -lSDL2 -lSDL2_net -lopengl32 -lssp +build_type = debug diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini new file mode 100644 index 0000000000..08b0f70b4d --- /dev/null +++ b/ini/stm32-common.ini @@ -0,0 +1,41 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +#################################### +# +# HAL/STM32 Common Environments +# +#################################### + +[common_stm32] +platform = ststm32@~12.1 +board_build.core = stm32 +build_flags = ${common.build_flags} + -std=gnu++14 + -DUSBCON -DUSBD_USE_CDC + -DTIM_IRQ_PRIO=13 + -DADC_RESOLUTION=12 +build_unflags = -std=gnu++11 +src_filter = ${common.default_src_filter} + + +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py + +# +# STM32 board based on a variant. +# +[stm32_variant] +extends = common_stm32 +extra_scripts = ${common_stm32.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/offset_and_rename.py + +# +# USB Flash Drive mix-ins for STM32 +# +[stm_flash_drive] +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-3.zip +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED -DHAL_HCD_MODULE_ENABLED + -DUSBHOST -DUSBH_IRQ_PRIO=3 -DUSBH_IRQ_SUBPRIO=4 diff --git a/ini/stm32f0.ini b/ini/stm32f0.ini index 64568e4b4c..6aebd88298 100644 --- a/ini/stm32f0.ini +++ b/ini/stm32f0.ini @@ -27,8 +27,8 @@ platform = ${common_stm32.platform} extends = common_stm32 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 + -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants + -fno-strict-aliasing -DCUSTOM_STARTUP_FILE # # Malyan M200 v2 (STM32F070CB) @@ -38,7 +38,8 @@ platform = ${common_stm32.platform} extends = common_stm32 board = malyanm200_f070cb build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED -DCUSTOM_STARTUP_FILE + -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB + -DHAL_UART_MODULE_ENABLED -DCUSTOM_STARTUP_FILE # # Malyan M300 (STM32F070CB) @@ -48,5 +49,6 @@ platform = ${common_stm32.platform} extends = common_stm32 board = malyanm300_f070cb build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED + -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB + -DHAL_UART_MODULE_ENABLED src_filter = ${common.default_src_filter} + diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 4daf04263a..0258fb3b7c 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -26,8 +26,7 @@ platform = ststm32@~12.1 board_build.core = maple build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py - ${common.build_flags} - -DARDUINO_ARCH_STM32 + ${common.build_flags} -DARDUINO_ARCH_STM32 -DMAPLE_STM32F1 build_unflags = -std=gnu11 -std=gnu++11 src_filter = ${common.default_src_filter} + lib_ignore = SPI, FreeRTOS701, FreeRTOS821 @@ -36,6 +35,8 @@ lib_deps = ${common.lib_deps} platform_packages = tool-stm32duino extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py + pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py + buildroot/share/PlatformIO/scripts/offset_and_rename.py # # STM32F103RC @@ -74,7 +75,7 @@ upload_protocol = dfu # # FYSETC STM32F103RC # -[env:STM32F103RC_fysetc] +[env:STM32F103RC_fysetc_maple] platform = ${common_stm32f1.platform} extends = common_STM32F103RC_maple extra_scripts = ${common_stm32f1.extra_scripts} @@ -85,19 +86,11 @@ debug_tool = stlink upload_protocol = serial # -# BigTree SKR Mini V1.1 / SKR mini E3 / SKR E3 DIP (STM32F103RCT6 ARM Cortex-M3) +# BigTree SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) # # STM32F103RC_btt_maple ............. RCT6 with 256K # STM32F103RC_btt_USB_maple ......... RCT6 with 256K (USB mass storage) -# STM32F103RC_btt_512K_maple ........ RCT6 with 512K -# STM32F103RC_btt_512K_USB_maple .... RCT6 with 512K (USB mass storage) # -# WARNING! If you have an SKR Mini v1.1 or an SKR Mini E3 1.0 / 1.2 / 2.0 / DIP -# and experience a printer freeze, re-flash Marlin using the regular (non-512K) -# build option. 256K chips may be re-branded 512K chips, but this means the -# upper 256K is sketchy, and failure is very likely. -# - [env:STM32F103RC_btt_maple] platform = ${common_stm32f1.platform} extends = common_STM32F103RC_maple @@ -116,20 +109,6 @@ build_flags = ${env:STM32F103RC_btt_maple.build_flags} -DUSE_USB_COMPOSITE lib_deps = ${env:STM32F103RC_btt_maple.lib_deps} USBComposite for STM32F1@0.91 -[env:STM32F103RC_btt_512K_maple] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RC_btt_maple -board_build.ldscript = STM32F103RE_SKR_MINI_512K.ld -board_upload.maximum_size = 524288 -build_flags = ${env:STM32F103RC_btt_maple.build_flags} -DSTM32_FLASH_SIZE=512 - -[env:STM32F103RC_btt_512K_USB_maple] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RC_btt_512K_maple -build_flags = ${env:STM32F103RC_btt_512K_maple.build_flags} -DUSE_USB_COMPOSITE -lib_deps = ${env:STM32F103RC_btt_512K_maple.lib_deps} - USBComposite for STM32F1@0.91 - # # Generic STM32F103RE environment # @@ -155,7 +134,7 @@ debug_tool = jlink upload_protocol = jlink # -# BigTree SKR Mini E3 DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) +# BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # # STM32F103RE_btt_maple ............. RET6 # STM32F103RE_btt_USB_maple ......... RET6 (USB mass storage) @@ -195,15 +174,15 @@ upload_protocol = serial # # Longer 3D board in Alfawise U20 (STM32F103VET6) # -[env:STM32F103VE_longer] +[env:STM32F103VE_longer_maple] platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE board_build.address = 0x08010000 +board_build.rename = project.bin 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 build_unflags = ${common_stm32f1.build_unflags} @@ -212,7 +191,7 @@ build_unflags = ${common_stm32f1.build_unflags} # # MKS Robin Mini (STM32F103VET6) # -[env:mks_robin_mini] +[env:mks_robin_mini_maple] platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE @@ -250,7 +229,7 @@ build_flags = ${common_stm32f1.build_flags} # # MKS Robin Pro (STM32F103ZET6) # -[env:mks_robin_pro] +[env:mks_robin_pro_maple] platform = ${common_stm32f1.platform} extends = env:mks_robin_maple extra_scripts = ${common_stm32f1.extra_scripts} @@ -259,7 +238,7 @@ extra_scripts = ${common_stm32f1.extra_scripts} # # TRIGORILLA PRO (STM32F103ZET6) # -[env:trigorilla_pro] +[env:trigorilla_pro_maple] platform = ${common_stm32f1.platform} extends = env:mks_robin_maple extra_scripts = ${common_stm32f1.extra_scripts} @@ -281,7 +260,7 @@ build_flags = ${common_stm32f1.build_flags} # MKS Robin E3p (STM32F103VET6) # - LVGL UI # -[env:mks_robin_e3p] +[env:mks_robin_e3p_maple] platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE @@ -295,7 +274,7 @@ upload_protocol = jlink # # MKS Robin Lite/Lite2 (STM32F103RCT6) # -[env:mks_robin_lite] +[env:mks_robin_lite_maple] platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RC @@ -305,7 +284,7 @@ extra_scripts = ${common_stm32f1.extra_scripts} # # MKS ROBIN LITE3 (STM32F103RCT6) # -[env:mks_robin_lite3] +[env:mks_robin_lite3_maple] platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RC @@ -315,7 +294,7 @@ extra_scripts = ${common_stm32f1.extra_scripts} # # JGAurora A5S A1 (STM32F103ZET6) # -[env:jgaurora_a5s_a1] +[env:jgaurora_a5s_a1_maple] platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103ZE @@ -330,7 +309,7 @@ build_flags = ${common_stm32f1.build_flags} # # Malyan M200 (STM32F103CB) # -[env:STM32F103CB_malyan] +[env:STM32F103CB_malyan_maple] platform = ${common_stm32f1.platform} extends = common_stm32f1 board = marlin_malyanM200 @@ -343,11 +322,12 @@ lib_ignore = ${common_stm32f1.lib_ignore} # # Chitu boards like Tronxy X5s (STM32F103ZET6) # -[env:chitu_f103] +[env:chitu_f103_maple] platform = ${common_stm32f1.platform} extends = common_stm32f1 board = marlin_CHITU_F103 -extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py +extra_scripts = ${common_stm32f1.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/common-dependencies.py pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py buildroot/share/PlatformIO/scripts/chitu_crypt.py build_flags = ${common_stm32f1.build_flags} @@ -359,7 +339,21 @@ build_unflags = ${common_stm32f1.build_unflags} # Some Chitu V5 boards have a problem with GPIO init. # Use this target if G28 or G29 are always failing. # -[env:chitu_v5_gpio_init] +[env:chitu_v5_gpio_init_maple] platform = ${common_stm32f1.platform} -extends = env:chitu_f103 -build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX +extends = env:chitu_f103_maple +build_flags = ${env:chitu_f103_maple.build_flags} -DCHITU_V5_Z_MIN_BUGFIX + +# +# FLYmaker FLY Mini (STM32F103RCT6) +# +[env:FLY_MINI_maple] +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/custom_board.py +build_flags = ${common_stm32f1.build_flags} + -DDEBUG_LEVEL=0 -DSS_TIMER=4 diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 2e197ccb4d..029763b9ed 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -10,115 +10,73 @@ # Naming Example: STM32F103RCT6 # # F : Foundation (sometimes High Performance F2/F4) -# 1 : Cortex M1 core +# 1 : Cortex M3 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) +# R : 64 or 66 pins (T:36, C:48, V:100, Z:144, I:176) +# C : 256KB Flash-memory (B: 128KB, D:384KB, E:512KB, G:1024KB) # T : LQFP package # 6 : -40...85°C (7: ...105°C) # ################################# -# -# HAL/STM32 Base Environment values -# -[common_stm32] -platform = ststm32@~12.1 -build_flags = ${common.build_flags} - -std=gnu++14 - -DUSBCON -DUSBD_USE_CDC - -DTIM_IRQ_PRIO=13 - -DADC_RESOLUTION=12 -build_unflags = -std=gnu++11 -src_filter = ${common.default_src_filter} + + -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py - -# -# BigTree SKR Mini V1.1 / SKR mini E3 / SKR E3 DIP (STM32F103RCT6 ARM Cortex-M3) -# -# STM32F103RC_btt ............. RCT6 with 256K -# STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) -# STM32F103RC_btt_512K ........ RCT6 with 512K -# STM32F103RC_btt_512K_USB .... RCT6 with 512K (USB mass storage) -# -# WARNING! If you have an SKR Mini v1.1 or an SKR Mini E3 1.0 / 1.2 / 2.0 / DIP -# and experience a printer freeze, re-flash Marlin using the regular (non-512K) -# build option. 256K chips may be re-branded 512K chips, but this means the -# upper 256K is sketchy, and failure is very likely. -# -[common_STM32F103RC] -platform = ${common_stm32.platform} -extends = common_stm32 +[common_STM32F103RC_variant] +extends = stm32_variant board = genericSTM32F103RC -monitor_speed = 115200 -board_build.core = stm32 board_build.variant = MARLIN_F103Rx -board_build.ldscript = ldscript.ld -extra_scripts = ${common_stm32.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py +build_flags = ${stm32_variant.build_flags} -DDEBUG_LEVEL=0 +monitor_speed = 115200 # # STM32F103RE # [env:STM32F103RE] -platform = ${common_stm32.platform} -extends = common_stm32 -board = genericSTM32F103RE -monitor_speed = 115200 +platform = ${common_stm32.platform} +extends = common_stm32 +board = genericSTM32F103RE +monitor_speed = 115200 # # STM32F103VE # [env:STM32F103VE] -platform = ${common_stm32.platform} -extends = common_stm32 -board = genericSTM32F103VE -monitor_speed = 115200 +platform = ${common_stm32.platform} +extends = common_stm32 +board = genericSTM32F103VE +monitor_speed = 115200 # # STM32F103ZE # [env:STM32F103ZE] -platform = ${common_stm32.platform} -extends = common_stm32 -board = genericSTM32F103ZE -monitor_speed = 115200 +platform = ${common_stm32.platform} +extends = common_stm32 +board = genericSTM32F103ZE +monitor_speed = 115200 +# +# BigTree SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) +# +# STM32F103RC_btt ............. RCT6 with 256K +# STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) +# [env:STM32F103RC_btt] -platform = ${common_stm32.platform} -extends = common_STM32F103RC -build_flags = ${common_stm32.build_flags} -DDEBUG_LEVEL=0 -DTIMER_SERVO=TIM5 -board_build.offset = 0x7000 -board_build.encrypt = No -board_build.firmware = firmware.bin +platform = ${common_stm32.platform} +extends = common_STM32F103RC_variant +build_flags = ${common_STM32F103RC_variant.build_flags} + -DTIMER_SERVO=TIM5 +board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 [env:STM32F103RC_btt_USB] -extends = env:STM32F103RC_btt platform = ${common_stm32.platform} -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-2.zip +extends = env:STM32F103RC_btt +platform_packages = ${stm_flash_drive.platform_packages} +build_flags = ${env:STM32F103RC_btt.build_flags} + -DUSE_USB_FS + -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 + -DUSBD_USE_CDC_MSC build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC -build_flags = ${env:STM32F103RC_btt.build_flags} ${env:stm32_flash_drive.build_flags} - -DUSBCON - -DUSE_USBHOST_HS - -DUSBD_IRQ_PRIO=5 - -DUSBD_IRQ_SUBPRIO=6 - -DUSE_USB_HS_IN_FS - -DUSBD_USE_CDC_MSC - -[env:STM32F103RC_btt_512K] -platform = ${common_stm32.platform} -extends = env:STM32F103RC_btt -board_upload.maximum_size = 524288 -build_flags = ${env:STM32F103RC_btt.build_flags} -DLD_MAX_DATA_SIZE=524288 -DSTM32_FLASH_SIZE=512 - -[env:STM32F103RC_btt_512K_USB] -platform = ${common_stm32.platform} -extends = env:STM32F103RC_btt_USB -board_upload.maximum_size = 524288 -build_flags = ${env:STM32F103RC_btt_USB.build_flags} -DLD_MAX_DATA_SIZE=524288 -DSTM32_FLASH_SIZE=512 # # MKS Robin (STM32F103ZET6) @@ -126,159 +84,293 @@ build_flags = ${env:STM32F103RC_btt_USB.build_flags} -DLD_MAX_DATA_SIZE=52 # [env:mks_robin] platform = ${common_stm32.platform} -extends = common_stm32 +extends = stm32_variant board = genericSTM32F103ZE -board_build.core = stm32 board_build.variant = MARLIN_F103Zx -board_build.ldscript = ldscript.ld +board_build.encrypt = Robin.bin board_build.offset = 0x7000 -board_build.encrypt = Yes -board_build.firmware = Robin.bin -build_flags = ${common_stm32.build_flags} - -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5 -build_unflags = ${common_stm32.build_unflags} - -DUSBCON -DUSBD_USE_CDC -extra_scripts = ${common_stm32.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/mks_encrypt.py -lib_deps = +build_flags = ${stm32_variant.build_flags} + -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5 +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC # # MKS Robin E3/E3D (STM32F103RCT6) with TMC2209 # [env:mks_robin_e3] platform = ${common_stm32.platform} -extends = common_STM32F103RC -build_flags = ${common_stm32.build_flags} - -DDEBUG_LEVEL=0 -DTIMER_SERVO=TIM5 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -monitor_speed = 115200 +extends = common_STM32F103RC_variant +board_build.encrypt = Robin_e3.bin board_build.offset = 0x5000 -board_build.encrypt = Yes -board_build.firmware = Robin_e3.bin board_upload.offset_address = 0x08005000 +build_flags = ${common_STM32F103RC_variant.build_flags} + -DTIMER_SERVO=TIM5 -DDEFAULT_SPI=3 +build_unflags = ${common_STM32F103RC_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC +monitor_speed = 115200 debug_tool = stlink -extra_scripts = ${env:STM32F103RC.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_encrypt.py # # Creality (STM32F103RET6) # [env:STM32F103RET6_creality] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DMCU_STM32F103RE -DHAL_SD_MODULE_ENABLED -DSS_TIMER=4 -DTIMER_SERVO=TIM5 -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 -board = genericSTM32F103RE -monitor_speed = 115200 -board_build.core = stm32 -board_build.variant = MARLIN_F103Rx -board_build.offset = 0x7000 -board_build.ldscript = ldscript.ld +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103RE +board_build.variant = MARLIN_F103Rx +board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - pre:buildroot/share/PlatformIO/scripts/random-bin.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py -debug_tool = jlink -upload_protocol = jlink +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F103RE -DHAL_SD_MODULE_ENABLED + -DSS_TIMER=4 -DTIMER_SERVO=TIM5 + -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC +extra_scripts = ${stm32_variant.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/random-bin.py +monitor_speed = 115200 +debug_tool = jlink +upload_protocol = jlink # -# BigTree SKR Mini E3 DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) +# BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # # STM32F103RE_btt ............. RET6 # STM32F103RE_btt_USB ......... RET6 (USB mass storage) # [env:STM32F103RE_btt] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DMCU_STM32F103RE -DHAL_SD_MODULE_ENABLED -DSS_TIMER=4 -DTIMER_SERVO=TIM5 -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 -board = genericSTM32F103RE -monitor_speed = 115200 -board_build.core = stm32 -board_build.variant = MARLIN_F103Rx -board_build.offset = 0x7000 -board_build.ldscript = ldscript.ld +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103RE +board_build.variant = MARLIN_F103Rx +board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 -build_unflags = ${common_stm32.build_unflags} -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py -debug_tool = jlink -upload_protocol = jlink +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F103RE -DHAL_SD_MODULE_ENABLED + -DSS_TIMER=4 -DTIMER_SERVO=TIM5 + -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 +monitor_speed = 115200 +debug_tool = jlink +upload_protocol = jlink [env:STM32F103RE_btt_USB] -extends = env:STM32F103RE_btt platform = ${common_stm32.platform} -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-2.zip -build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC -build_flags = ${env:STM32F103RE_btt.build_flags} ${env:stm32_flash_drive.build_flags} - -DUSBCON - -DUSE_USBHOST_HS - -DUSBD_IRQ_PRIO=5 - -DUSBD_IRQ_SUBPRIO=6 - -DUSE_USB_HS_IN_FS - -DUSBD_USE_CDC_MSC +extends = env:STM32F103RE_btt +platform_packages = ${stm_flash_drive.platform_packages} +build_flags = ${env:STM32F103RE_btt.build_flags} + -DUSE_USB_FS -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 -DUSBD_USE_CDC_MSC +build_unflags = ${stm32_variant.build_unflags} -DUSBD_USE_CDC # # FLSUN QQS Pro (STM32F103VET6) # board Hispeedv1 # [env:flsun_hispeedv1] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 -board = genericSTM32F103VE -board_build.core = stm32 -board_build.variant = MARLIN_F103Vx -board_build.ldscript = ldscript.ld -board_build.offset = 0x7000 -board_build.firmware = Robin_mini.bin -board_build.encrypt = Yes +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103VE +board_build.variant = MARLIN_F103Vx +board_build.encrypt = Robin_mini.bin +board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -extra_scripts = ${common_stm32.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/mks_encrypt.py +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 + -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC # # MKS Robin Nano V1.2 and V2 # [env:mks_robin_nano35] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 -board = genericSTM32F103VE -board_build.core = stm32 -board_build.variant = MARLIN_F103Vx -board_build.ldscript = ldscript.ld -board_build.offset = 0x7000 -board_build.encrypt = Yes -board_build.firmware = Robin_nano35.bin +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103VE +board_build.variant = MARLIN_F103Vx +board_build.encrypt = Robin_nano35.bin +board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -debug_tool = jlink -upload_protocol = jlink -extra_scripts = ${common_stm32.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/mks_encrypt.py +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 + -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC +debug_tool = jlink +upload_protocol = jlink # # Mingda MPX_ARM_MINI # [env:mingda_mpx_arm_mini] platform = ${common_stm32.platform} -extends = common_stm32 +extends = stm32_variant board = genericSTM32F103ZE -board_build.core = stm32 board_build.variant = MARLIN_F103Zx -board_build.ldscript = ldscript.ld board_build.offset = 0x10000 -build_flags = ${common_stm32.build_flags} -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -extra_scripts = ${common_stm32.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py +build_flags = ${stm32_variant.build_flags} + -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5 +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC + +# +# Malyan M200 (STM32F103CB) +# +[env:STM32F103CB_malyan] +platform = ${common_stm32.platform} +extends = common_stm32 +board = malyanm200_f103cb +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB + -DHAL_UART_MODULE_ENABLED +src_filter = ${common.default_src_filter} + + +# +# FLYmaker FLY Mini (STM32F103RCT6) +# +[env:FLY_MINI] +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103RC +board_build.variant = MARLIN_F103Rx +board_build.offset = 0x5000 +board_upload.offset_address = 0x08005000 +build_flags = ${stm32_variant.build_flags} -DSS_TIMER=4 + +# +# MKS Robin Mini (STM32F103VET6) +# +[env:mks_robin_mini] +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103VE +board_build.variant = MARLIN_F103Vx +board_build.encrypt = Robin_mini.bin +board_build.offset = 0x7000 +board_upload.offset_address = 0x08007000 +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F103VE -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 + +# +# MKS Robin Lite/Lite2 (STM32F103RCT6) +# +[env:mks_robin_lite] +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103RC +board_build.variant = MARLIN_F103Rx +board_build.encrypt = mksLite.bin +board_build.offset = 0x5000 +board_upload.offset_address = 0x08005000 + +# +# MKS ROBIN LITE3 (STM32F103RCT6) +# +[env:mks_robin_lite3] +platform = ${common_stm32.platform} +extends = env:mks_robin_lite +board_build.encrypt = mksLite3.bin + +# +# MKS Robin Pro (STM32F103ZET6) +# +[env:mks_robin_pro] +platform = ${common_stm32.platform} +extends = env:mks_robin +board_build.encrypt = Robin_pro.bin + +# +# MKS Robin E3p (STM32F103VET6) +# - LVGL UI +# +[env:mks_robin_e3p] +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103VE +board_build.variant = MARLIN_F103Vx +board_build.encrypt = Robin_e3p.bin +board_build.offset = 0x7000 +board_upload.offset_address = 0x08007000 +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F103VE -DSS_TIMER=4 + -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 +debug_tool = jlink +upload_protocol = jlink + +# +# JGAurora A5S A1 (STM32F103ZET6) +# +[env:jgaurora_a5s_a1] +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103ZE +board_build.variant = MARLIN_F103Zx +board_build.offset = 0xA000 +board_build.rename = firmware_for_sd_upload.bin +board_upload.offset_address = 0x0800A000 +build_flags = ${stm32_variant.build_flags} + -DSTM32F1xx -DSTM32_XL_DENSITY +extra_scripts = ${stm32_variant.extra_scripts} + buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py + +# +# FYSETC STM32F103RC +# +[env:STM32F103RC_fysetc] +platform = ${common_stm32.platform} +extends = common_STM32F103RC_variant +extra_scripts = ${common_STM32F103RC_variant.extra_scripts} + buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +lib_ldf_mode = chain +debug_tool = stlink +upload_protocol = serial + +# +# Longer 3D board in Alfawise U20 (STM32F103VET6) +# +[env:STM32F103VE_longer] +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103VE +board_build.variant = MARLIN_F103Vx +board_build.rename = project.bin +board_build.offset = 0x10000 +board_upload.offset_address = 0x08010000 +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F103VE -DU20 -DTS_V12 -DLED_BUILTIN=PC2 -UPIN_WIRE_SDA + -UPIN_WIRE_SCL -DPIN_WIRE_SDA=PB11 -DPIN_WIRE_SCL=PB10 + -DHAL_DAC_MODULE_DISABLED -DHAL_I2S_MODULE_DISABLED +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC -DHAL_PCD_MODULE_ENABLED +extra_scripts = ${stm32_variant.extra_scripts} + +# +# TRIGORILLA PRO (STM32F103ZET6) +# +[env:trigorilla_pro] +platform = ${common_stm32.platform} +extends = env:mks_robin +extra_scripts = ${common_stm32.extra_scripts} + +# +# Chitu boards like Tronxy X5s (STM32F103ZET6) +# +[env:chitu_f103] +platform = ${common_stm32.platform} +extends = stm32_variant +board = genericSTM32F103ZE +board_build.variant = MARLIN_F103Zx +build_flags = ${stm32_variant.build_flags} + -DSTM32F1xx -DSTM32_XL_DENSITY +build_unflags = ${stm32_variant.build_unflags} +extra_scripts = ${stm32_variant.extra_scripts} + buildroot/share/PlatformIO/scripts/chitu_crypt.py + +# +# Some Chitu V5 boards have a problem with GPIO init. +# Use this target if G28 or G29 are always failing. +# +[env:chitu_v5_gpio_init] +platform = ${common_stm32.platform} +extends = env:chitu_f103 +build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 021574ad26..d2332630a1 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -12,8 +12,8 @@ # 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) +# R : 64 or 66 pins (T:36, C:48 or 49, M:81, V:100, Z:144, I:176) +# G : 1024KB Flash-memory (B:128KB, C:256KB, D:384KB, E:512KB) # T : LQFP package # 6 : -40...85°C (7: ...105°C) # @@ -27,7 +27,7 @@ platform = ${common_stm32.platform} extends = common_stm32 board = armed_v1 build_flags = ${common_stm32.build_flags} - -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing + -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing # # STM32F401VE @@ -35,55 +35,57 @@ build_flags = ${common_stm32.build_flags} # [env:STM32F401VE_STEVAL] platform = ${common_stm32.platform} -extends = common_stm32 +extends = stm32_variant 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 +build_flags = ${stm32_variant.build_flags} + -DSTM32F401xE -DDISABLE_GENERIC_SERIALUSB + -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS # # STM32F401RC # [env:FYSETC_CHEETAH_V20] -platform = ${common_stm32.platform} -extends = common_stm32 -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 +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_FYSETC_CHEETAH_V20 +board_build.offset = 0xC000 +build_flags = ${stm32_variant.build_flags} -DSTM32F401xC # # FLYF407ZG # [env:FLYF407ZG] platform = ${common_stm32.platform} -extends = common_stm32 +extends = stm32_variant board = marlin_STM32F407ZGT6 board_build.variant = MARLIN_FLY_F407ZG +board_build.offset = 0x8000 upload_protocol = dfu -build_flags = ${common_stm32.build_flags} - -DVECT_TAB_OFFSET=0x8000 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py # # FYSETC S6 (STM32F446RET6 ARM Cortex-M4) # [env:FYSETC_S6] -platform = ${common_stm32.platform} -extends = common_stm32 -platform_packages = tool-stm32duino -board = marlin_fysetc_s6 -build_flags = ${common_stm32.build_flags} - -DVECT_TAB_OFFSET=0x10000 - -DHAL_PCD_MODULE_ENABLED -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py -debug_tool = stlink -upload_protocol = dfu -upload_command = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE" +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_fysetc_s6 +board_build.offset = 0x10000 +board_upload.offset_address = 0x08010000 +build_flags = ${stm32_variant.build_flags} -DHAL_PCD_MODULE_ENABLED +debug_tool = stlink +upload_protocol = dfu +upload_command = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE" + +# +# FYSETC S6 new bootloader +# +[env:FYSETC_S6_8000] +platform = ${common_stm32.platform} +extends = env:FYSETC_S6 +board = marlin_fysetc_s6 +board_build.offset = 0x8000 +board_upload.offset_address = 0x08008000 +upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE" # # STM32F407VET6 with RAMPS-like shield @@ -92,13 +94,10 @@ upload_command = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE" # [env:STM32F407VE_black] platform = ${common_stm32.platform} -extends = common_stm32 +extends = stm32_variant board = marlin_blackSTM32F407VET6 -build_flags = ${common_stm32.build_flags} - -DARDUINO_BLACK_F407VE - -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +build_flags = ${stm32_variant.build_flags} + -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS # # Anet ET4-MB_V1.x/ET4P-MB_V1.x (STM32F407VGT6 ARM Cortex-M4) @@ -106,183 +105,168 @@ extra_scripts = ${common.extra_scripts} # Comment out board_build.offset = 0x10000 if you don't plan to use OpenBLT/flashing directly to 0x08000000. # [env:Anet_ET4_OpenBLT] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED -board = marlin_STM32F407VGT6_CCM -board_build.core = stm32 -board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.firmware = firmware.srec -# Just openblt.py (not stm32_bootloader.py) generates the file -board_build.encrypt = Yes -board_build.offset = 0x10000 +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_STM32F407VGT6_CCM +board_build.variant = MARLIN_F4x7Vx +board_build.encrypt = firmware.srec +board_build.offset = 0x10000 board_upload.offset_address = 0x08010000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 -debug_tool = jlink -upload_protocol = jlink -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/openblt.py +build_flags = ${stm32_variant.build_flags} + -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 +extra_scripts = ${stm32_variant.extra_scripts} + buildroot/share/PlatformIO/scripts/openblt.py +debug_tool = jlink +upload_protocol = jlink # # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) # [env:BIGTREE_SKR_PRO] -platform = ${common_stm32.platform} -extends = common_stm32 -board = marlin_BigTree_SKR_Pro -build_flags = ${common_stm32.build_flags} - -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py -#upload_protocol = stlink -#upload_command = "$PROJECT_PACKAGES_DIR/tool-stm32duino/stlink/ST-LINK_CLI.exe" -c SWD -P "$BUILD_DIR/firmware.bin" 0x8008000 -Rst -Run -debug_tool = stlink -debug_init_break = - -# -# USB Flash Drive mix-ins for STM32 -# -[stm_flash_drive] -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-2.zip -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED -DHAL_HCD_MODULE_ENABLED - -DUSBHOST -DUSBH_IRQ_PRIO=3 -DUSBH_IRQ_SUBPRIO=4 +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_BigTree_SKR_Pro +board_build.offset = 0x8000 +build_flags = ${stm32_variant.build_flags} -DSTM32F407_5ZX +debug_tool = stlink +upload_protocol = stlink # # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_SKR_PRO_usb_flash_drive] +platform = ${common_stm32.platform} extends = env:BIGTREE_SKR_PRO platform_packages = ${stm_flash_drive.platform_packages} -build_unflags = -DUSBCON -DUSBD_USE_CDC -build_flags = ${stm_flash_drive.build_flags} - -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000 +build_flags = ${stm_flash_drive.build_flags} -DSTM32F407_5ZX +build_unflags = ${env:BIGTREE_SKR_PRO.build_unflags} -DUSBCON -DUSBD_USE_CDC # # BigTreeTech E3 RRF (STM32F407VGT6 ARM Cortex-M4) # [env:BIGTREE_E3_RRF] platform = ${common_stm32.platform} -extends = common_stm32 +extends = stm32_variant board = marlin_STM32F407VGT6_CCM 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 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +board_build.offset = 0x8000 +build_flags = ${stm32_variant.build_flags} + -DSTM32F407_5VX + -DMF_RX_BUFFER_SIZE=255 + -DMF_TX_BUFFER_SIZE=255 # # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) # [env:BIGTREE_GTR_V1_0] -platform = ${common_stm32.platform} -extends = common_stm32 -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} - -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000 +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_BigTree_GTR_v1 +board_build.offset = 0x8000 +build_flags = ${stm32_variant.build_flags} -DSTM32F407IX # # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_GTR_V1_0_usb_flash_drive] +platform = ${common_stm32.platform} extends = env:BIGTREE_GTR_V1_0 platform_packages = ${stm_flash_drive.platform_packages} -build_unflags = -DUSBCON -DUSBD_USE_CDC -build_flags = ${stm_flash_drive.build_flags} - -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000 +build_flags = ${stm_flash_drive.build_flags} -DSTM32F407IX +build_unflags = ${env:BIGTREE_GTR_V1_0.build_unflags} -DUSBCON -DUSBD_USE_CDC # # BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4) # [env:BIGTREE_BTT002] -platform = ${common_stm32.platform} -extends = common_stm32 -board = marlin_BigTree_BTT002 -build_flags = ${common_stm32.build_flags} - -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000 - -DHAVE_HWSERIAL2 - -DHAVE_HWSERIAL3 - -DPIN_SERIAL2_RX=PD_6 - -DPIN_SERIAL2_TX=PD_5 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_BigTree_BTT002 +board_build.offset = 0x8000 +build_flags = ${stm32_variant.build_flags} + -DSTM32F407_5VX + -DHAVE_HWSERIAL2 + -DHAVE_HWSERIAL3 + -DPIN_SERIAL2_RX=PD_6 + -DPIN_SERIAL2_TX=PD_5 # # 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 = marlin_STM32F407VGT6_CCM -board_build.core = stm32 -board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.offset = 0x8000 +platform = ${common_stm32.platform} +extends = stm32_variant +platform_packages = ${stm_flash_drive.platform_packages} +board = marlin_STM32F407VGT6_CCM +board_build.variant = MARLIN_F4x7Vx +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 +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 + +# +# BigTreeTech SKR V2.0 (STM32F407VGT6 ARM Cortex-M4) with USB Media Share Support +# +[env:BIGTREE_SKR_2_USB] +platform = ${common_stm32.platform} +extends = env:BIGTREE_SKR_2 +build_flags = ${env:BIGTREE_SKR_2.build_flags} -DUSBD_USE_CDC_MSC +build_unflags = ${env:BIGTREE_SKR_2.build_unflags} -DUSBD_USE_CDC # # BigTreeTech Octopus V1.0/1.1 (STM32F446ZET6 ARM Cortex-M4) # [env:BIGTREE_OCTOPUS_V1] -platform = ${common_stm32.platform} -extends = common_stm32 -board = marlin_BigTree_octopus_v1 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py -build_flags = ${common_stm32.build_flags} - -DSTM32F446_5VX -DVECT_TAB_OFFSET=0x8000 -DUSE_USB_HS_IN_FS +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_BigTree_Octopus_v1 +board_build.offset = 0x8000 +build_flags = ${stm32_variant.build_flags} + -DSTM32F446_5VX -DUSE_USB_HS_IN_FS # # BigTreeTech Octopus V1.0/1.1 (STM32F446ZET6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_OCTOPUS_V1_USB] +platform = ${common_stm32.platform} extends = env:BIGTREE_OCTOPUS_V1 platform_packages = ${stm_flash_drive.platform_packages} -#build_unflags = -DUSBCON -DUSBD_USE_CDC +build_unflags = -DUSBD_USE_CDC build_flags = ${stm_flash_drive.build_flags} - -DSTM32F446_5VX -DVECT_TAB_OFFSET=0x8000 - -DUSBCON -DUSE_USBHOST_HS -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 -DUSE_USB_HS_IN_FS -DUSBD_USE_CDC_MSC + -DSTM32F446_5VX -DUSE_USB_HS_IN_FS + -DUSE_USBHOST_HS -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 + -DUSBD_USE_CDC_MSC # # Lerdge base # [lerdge_common] platform = ${common_stm32.platform} -extends = common_stm32 +extends = stm32_variant board = marlin_STM32F407ZGT6 board_build.variant = MARLIN_LERDGE +board_build.encrypt = firmware.bin board_build.offset = 0x10000 -board_build.encrypt = Yes -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py +build_flags = ${stm32_variant.build_flags} + -DSTM32F4 -DSTM32F4xx -DTARGET_STM32F4 + -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 -DARDUINO_LERDGE + -DHAL_SRAM_MODULE_ENABLED +build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 +extra_scripts = ${stm32_variant.extra_scripts} buildroot/share/PlatformIO/scripts/lerdge.py -build_flags = ${common_stm32.build_flags} - -DSTM32F4 -DSTM32F4xx -DTARGET_STM32F4 - -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 -DARDUINO_LERDGE - -DHAL_SRAM_MODULE_ENABLED -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 # # Lerdge X # [env:LERDGEX] -platform = ${lerdge_common.platform} -extends = lerdge_common -board_build.firmware = Lerdge_X_firmware_force.bin +platform = ${lerdge_common.platform} +extends = lerdge_common +board_build.encrypt = Lerdge_X_firmware_force.bin # # Lerdge X with USB Flash Drive Support @@ -297,9 +281,9 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # Lerdge S # [env:LERDGES] -platform = ${lerdge_common.platform} -extends = lerdge_common -board_build.firmware = Lerdge_firmware_force.bin +platform = ${lerdge_common.platform} +extends = lerdge_common +board_build.encrypt = Lerdge_firmware_force.bin # # Lerdge S with USB Flash Drive Support @@ -314,10 +298,10 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # Lerdge K # [env:LERDGEK] -platform = ${lerdge_common.platform} -extends = lerdge_common -board_build.firmware = Lerdge_K_firmware_force.bin -build_flags = ${lerdge_common.build_flags} -DLERDGEK +platform = ${lerdge_common.platform} +extends = lerdge_common +board_build.encrypt = Lerdge_K_firmware_force.bin +build_flags = ${lerdge_common.build_flags} -DLERDGEK # # Lerdge K with USB Flash Drive Support @@ -333,50 +317,36 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # [env:rumba32] platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} - -Os - -DHAL_PCD_MODULE_ENABLED - -DDISABLE_GENERIC_SERIALUSB - -DHAL_UART_MODULE_ENABLED - -DTIMER_SERIAL=TIM9 +extends = stm32_variant board = rumba32_f446ve -upload_protocol = dfu -monitor_speed = 500000 -board_build.core = stm32 board_build.variant = MARLIN_F446VE -board_build.ldscript = ldscript.ld board_build.offset = 0x0000 -board_build.encrypt = No -board_build.firmware = firmware.bin -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py +build_flags = ${stm32_variant.build_flags} + -Os -DHAL_PCD_MODULE_ENABLED + -DDISABLE_GENERIC_SERIALUSB + -DHAL_UART_MODULE_ENABLED + -DTIMER_SERIAL=TIM9 +monitor_speed = 500000 +upload_protocol = dfu # # MKS Robin Pro V2 # [env:mks_robin_pro2] -platform = ${common_stm32.platform} -platform_packages = ${stm_flash_drive.platform_packages} -extends = common_stm32 -build_flags = ${stm_flash_drive.build_flags} -board = genericSTM32F407VET6 -board_build.core = stm32 -board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.firmware = firmware.bin -board_build.offset = 0x0000 +platform = ${common_stm32.platform} +extends = stm32_variant +platform_packages = ${stm_flash_drive.platform_packages} +board = genericSTM32F407VET6 +board_build.variant = MARLIN_F4x7Vx +board_build.offset = 0x0000 board_upload.offset_address = 0x08000000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -debug_tool = jlink -upload_protocol = jlink -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py +build_flags = ${stm_flash_drive.build_flags} +build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC +debug_tool = jlink +upload_protocol = jlink # -# This SPI is used by Robin Nano V3 +# This I2C1(PB6:I2C1_SCL PB7:I2C1_SDA) is used by Robin Nano V3 # [stm32f4_I2C1] build_flags = -DPIN_WIRE_SCL=PB6 -DPIN_WIRE_SDA=PB7 @@ -385,37 +355,31 @@ build_flags = -DPIN_WIRE_SCL=PB6 -DPIN_WIRE_SDA=PB7 # MKS Robin Nano V3 # [env:mks_robin_nano_v3] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} ${stm32f4_I2C1.build_flags} -DHAL_PCD_MODULE_ENABLED -DUSBCON -DUSBD_USE_CDC -board = marlin_STM32F407VGT6_CCM -board_build.core = stm32 -board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.firmware = Robin_nano_v3.bin -board_build.offset = 0xC000 +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_STM32F407VGT6_CCM +board_build.variant = MARLIN_F4x7Vx +board_build.offset = 0xC000 board_upload.offset_address = 0x0800C000 -build_unflags = ${common_stm32.build_unflags} -debug_tool = jlink -upload_protocol = jlink -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py +board_build.rename = Robin_nano_v3.bin +build_flags = ${stm32_variant.build_flags} ${stm32f4_I2C1.build_flags} + -DHAL_PCD_MODULE_ENABLED +debug_tool = jlink +upload_protocol = jlink # # MKS Robin Nano V3 with USB Flash Drive Support # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_robin_nano_v3_usb_flash_drive] +platform = ${common_stm32.platform} extends = env:mks_robin_nano_v3 platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} - -DUSBCON - -DUSE_USBHOST_HS - -DUSBD_IRQ_PRIO=5 - -DUSBD_IRQ_SUBPRIO=6 - -DUSE_USB_HS_IN_FS - -DUSBD_USE_CDC + -DUSE_USBHOST_HS + -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 + -DUSE_USB_HS_IN_FS # # MKS Robin Nano V3 with USB Flash Drive Support and Shared Media @@ -423,13 +387,52 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} # [env:mks_robin_nano_v3_usb_flash_drive_msc] platform = ${common_stm32.platform} -extends = env:mks_robin_nano_v3 -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-2.zip -build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC -build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} - -DUSBCON - -DUSE_USBHOST_HS - -DUSBD_IRQ_PRIO=5 - -DUSBD_IRQ_SUBPRIO=6 - -DUSE_USB_HS_IN_FS - -DUSBD_USE_CDC_MSC +extends = env:mks_robin_nano_v3_usb_flash_drive +build_flags = ${env:mks_robin_nano_v3_usb_flash_drive} + -DUSBD_USE_CDC_MSC + +# +# This I2C1(PB8:I2C1_SCL PB9:I2C1_SDA) is used by MKS Monster8 +# +[stm32f4_I2C1_CAN] +build_flags = -DPIN_WIRE_SCL=PB8 -DPIN_WIRE_SDA=PB9 + +# +# MKS Monster8 +# +[env:mks_monster8] +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_STM32F407VGT6_CCM +board_build.variant = MARLIN_F4x7Vx +board_build.offset = 0xC000 +board_upload.offset_address = 0x0800C000 +board_build.rename = mks_monster8.bin +build_flags = ${stm32_variant.build_flags} ${stm32f4_I2C1_CAN.build_flags} + -DHAL_PCD_MODULE_ENABLED +debug_tool = jlink +upload_protocol = jlink + +# +# MKS Monster8 with USB Flash Drive Support +# Currently, using a STM32duino fork, until USB Host get merged +# +[env:mks_monster8_usb_flash_drive] +platform = ${common_stm32.platform} +extends = env:mks_monster8 +platform_packages = ${stm_flash_drive.platform_packages} +build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1_CAN.build_flags} + -DUSE_USBHOST_HS + -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 + -DUSE_USB_HS_IN_FS + +# +# MKS Monster8 with USB Flash Drive Support and Shared Media +# Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged +# +[env:mks_monster8_usb_flash_drive_msc] +platform = ${common_stm32.platform} +extends = env:mks_monster8_usb_flash_drive +build_flags = ${env:mks_monster8_usb_flash_drive} + -DUSBD_USE_CDC_MSC diff --git a/ini/stm32f7.ini b/ini/stm32f7.ini index 76d039533c..984b25162e 100644 --- a/ini/stm32f7.ini +++ b/ini/stm32f7.ini @@ -37,29 +37,3 @@ build_flags = ${common_stm32.build_flags} -DTIMER_SERIAL=TIM9 platform = ${common_stm32.platform} extends = common_stm32 board = remram_v1 -build_flags = ${common_stm32.build_flags} - -# -# BigTreeTech SKR SE BX (STM32H743IIT6 ARM Cortex-M7) -# -[env:BTT_SKR_SE_BX] -platform = ${common_stm32.platform} -platform_packages = ${stm_flash_drive.platform_packages} -extends = common_stm32 -board = 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} - ${stm_flash_drive.build_flags} - -DUSE_USBHOST_HS - -DUSE_USB_HS_IN_FS - #-DUSBD_USE_CDC_MSC - -DVECT_TAB_OFFSET=0x20000 - -DHAL_DMA2D_MODULE_ENABLED - -DHAL_LTDC_MODULE_ENABLED - -DHAL_SDRAM_MODULE_ENABLED - -DHAL_QSPI_MODULE_ENABLED - -DHAL_MDMA_MODULE_ENABLED - -DHAL_SD_MODULE_ENABLED -upload_protocol = cmsis-dap -debug_tool = cmsis-dap diff --git a/ini/stm32h7.ini b/ini/stm32h7.ini new file mode 100644 index 0000000000..3d0753a235 --- /dev/null +++ b/ini/stm32h7.ini @@ -0,0 +1,41 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# +# STM32H7 Architecture +# +# Naming Example: STM32H743IIT6 +# +# H : High Performance +# 7 : Cortex M7 core +# 43 : Line/Features +# I : 176 pins +# I : 2048KB Flash-memory +# T : LQFP package +# 6 : -40...85°C (7: ...105°C) +# +################################# + +# +# BigTreeTech SKR SE BX (STM32H743IIT6 ARM Cortex-M7) +# +[env:BTT_SKR_SE_BX] +platform = ${common_stm32.platform} +extends = stm32_variant +platform_packages = ${stm_flash_drive.platform_packages} +board = marlin_BTT_SKR_SE_BX +board_build.offset = 0x20000 +build_flags = ${stm32_variant.build_flags} ${stm_flash_drive.build_flags} + -DUSE_USBHOST_HS + -DUSE_USB_HS_IN_FS + -DHAL_DMA2D_MODULE_ENABLED + -DHAL_LTDC_MODULE_ENABLED + -DHAL_SDRAM_MODULE_ENABLED + -DHAL_QSPI_MODULE_ENABLED + -DHAL_MDMA_MODULE_ENABLED + -DHAL_SD_MODULE_ENABLED +upload_protocol = cmsis-dap +debug_tool = cmsis-dap diff --git a/ini/teensy.ini b/ini/teensy.ini index ae33cc7a02..ef1ad766bc 100644 --- a/ini/teensy.ini +++ b/ini/teensy.ini @@ -9,11 +9,20 @@ # # ################################# +# +# Teensy++ 2.0 +# +[env:teensy20] +platform = teensy +extends = common_avr8 +board = teensy2pp +lib_ignore = ${env:common_avr8.lib_ignore}, NativeEthernet + # # Teensy 3.1 / 3.2 (ARM Cortex-M4) # [env:teensy31] -platform = teensy +platform = teensy@~4.12.0 board = teensy31 src_filter = ${common.default_src_filter} + lib_ignore = NativeEthernet @@ -22,13 +31,13 @@ lib_ignore = NativeEthernet # Teensy 3.5 / 3.6 (ARM Cortex-M4) # [env:teensy35] -platform = teensy +platform = teensy@~4.12.0 board = teensy35 src_filter = ${common.default_src_filter} + lib_ignore = NativeEthernet [env:teensy36] -platform = teensy +platform = teensy@~4.12.0 board = teensy36 src_filter = ${common.default_src_filter} + lib_ignore = NativeEthernet @@ -37,6 +46,6 @@ lib_ignore = NativeEthernet # Teensy 4.0 / 4.1 (ARM Cortex-M7) # [env:teensy41] -platform = teensy +platform = teensy@~4.12.0 board = teensy41 src_filter = ${common.default_src_filter} + diff --git a/platformio.ini b/platformio.ini index 11f4f4ca46..5d5668e7bb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,11 +27,13 @@ extra_configs = ini/lpc176x.ini ini/native.ini ini/samd51.ini + ini/stm32-common.ini ini/stm32f0.ini ini/stm32f1-maple.ini ini/stm32f1.ini ini/stm32f4.ini ini/stm32f7.ini + ini/stm32h7.ini ini/teensy.ini # @@ -50,7 +52,7 @@ extra_scripts = post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py lib_deps = default_src_filter = + - - + - - - - - - - + - - - - - - - - - - - - @@ -203,7 +205,7 @@ default_src_filter = + - - + - - - - - + - - - - - @@ -228,6 +230,7 @@ default_src_filter = + - - + - - - - - - + - - - - - @@ -268,6 +271,13 @@ monitor_flags = # # ################################# +################################# +# # +# AVR Architecture # +# # +################################# + + # # Lulzbot Mini @@ -308,13 +318,14 @@ board = megaatmega2560 [env:TazPro] platform = atmelsam extends = env:DUE -board = archim +board = marlin_archim build_flags = ${common.build_flags} -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSBCON -DTazPro board_build.variants_dir = buildroot/share/PlatformIO/variants/ extra_scripts = ${common.extra_scripts} Marlin/src/HAL/DUE/upload_extra_script.py + # # Just print the dependency tree #