diff --git a/.editorconfig b/.editorconfig index b8f6ef7f8e32..57a5b2fb5ea4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,6 +14,10 @@ end_of_line = lf indent_style = space indent_size = 2 -[{*.py,*.conf,*.sublime-project}] +[{*.py}] +indent_style = space +indent_size = 4 + +[{*.conf,*.sublime-project}] indent_style = tab indent_size = 4 diff --git a/.gitignore b/.gitignore index 0b852d767325..09db344257e7 100755 --- a/.gitignore +++ b/.gitignore @@ -147,6 +147,7 @@ vc-fileutils.settings imgui.ini eeprom.dat spi_flash.bin +fs.img #cmake CMakeLists.txt diff --git a/Makefile b/Makefile index ebcdf25e2d6a..d0495dc7d863 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ tests-single-ci: tests-single-local: @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET= or use make tests-all-local" ; return 1; fi - export PATH=./buildroot/bin/:./buildroot/tests/:${PATH} \ + export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \ && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \ && run_tests . $(TEST_TARGET) "$(ONLY_TEST)" .PHONY: tests-single-local @@ -38,7 +38,7 @@ tests-single-local-docker: .PHONY: tests-single-local-docker tests-all-local: - export PATH=./buildroot/bin/:./buildroot/tests/:${PATH} \ + export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \ && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \ && for TEST_TARGET in $$(./get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done .PHONY: tests-all-local diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 24cdfb8f99ec..4734877bc4de 100755 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -35,7 +35,7 @@ * * Advanced settings can be found in Configuration_adv.h */ -#define CONFIGURATION_H_VERSION 02010100 +#define CONFIGURATION_H_VERSION 02010200 //=========================================================================== //============================= Getting Started ============================= @@ -150,6 +150,8 @@ // Choose your own or use a service like https://www.uuidgenerator.net/version4 //#define MACHINE_UUID "00000000-0000-0000-0000-000000000000" +// @section stepper drivers + /** * Stepper Drivers * @@ -249,6 +251,8 @@ //#define SINGLENOZZLE_STANDBY_FAN #endif +// @section multi-material + /** * Multi-Material Unit * Set to one of these predefined models: @@ -261,6 +265,7 @@ * * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. * See additional options in Configuration_adv.h. + * :["PRUSA_MMU1", "PRUSA_MMU2", "PRUSA_MMU2S", "EXTENDABLE_EMU_MMU2", "EXTENDABLE_EMU_MMU2S"] */ //#define MMU_MODEL PRUSA_MMU2 @@ -500,7 +505,7 @@ * 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 + * 66 : 4.7MΩ Dyze Design / Trianglelab T-D500 500°C High Temperature Thermistor * 67 : 500kΩ SliceEngineering 450°C Thermistor * 68 : PT100 amplifier board from Dyze Design * 70 : 100kΩ bq Hephestos 2 @@ -522,6 +527,7 @@ * 110 : Pt100 with 1kΩ pullup (atypical) * 147 : Pt100 with 4.7kΩ pullup * 1010 : Pt1000 with 1kΩ pullup (atypical) + * 1022 : Pt1000 with 2.2kΩ pullup * 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. @@ -567,6 +573,10 @@ #define MAX31865_SENSOR_OHMS_1 100 #define MAX31865_CALIBRATION_OHMS_1 430 #endif +#if TEMP_SENSOR_IS_MAX_TC(2) + #define MAX31865_SENSOR_OHMS_2 100 + #define MAX31865_CALIBRATION_OHMS_2 430 +#endif #if HAS_E_TEMP_SENSOR #define TEMP_RESIDENCY_TIME 5 // (seconds) Time to wait for hotend to "settle" in M109 @@ -878,7 +888,7 @@ //#define POLARGRAPH #if ENABLED(POLARGRAPH) #define POLARGRAPH_MAX_BELT_LEN 1035.0 - #define POLAR_SEGMENTS_PER_SECOND 5 + #define DEFAULT_SEGMENTS_PER_SECOND 5 #endif // @section delta @@ -890,28 +900,26 @@ // Make delta curves from many straight lines (linear interpolation). // This is a trade-off between visible corners (not enough segments) // and processor overload (too many expensive sqrt calls). - #define DELTA_SEGMENTS_PER_SECOND 200 + #define DEFAULT_SEGMENTS_PER_SECOND 200 // After homing move down to a height where XY movement is unconstrained //#define DELTA_HOME_TO_SAFE_ZONE // Delta calibration menu - // uncomment to add three points calibration menu option. + // Add three-point calibration to the MarlinUI menu. // See http://minow.blogspot.com/index.html#4918805519571907051 //#define DELTA_CALIBRATION_MENU - // uncomment to add G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results) + // G33 Delta Auto-Calibration. Enable EEPROM_SETTINGS to store results. //#define DELTA_AUTO_CALIBRATION - // NOTE NB all values for DELTA_* values MUST be floating point, so always have a decimal point in them - #if ENABLED(DELTA_AUTO_CALIBRATION) - // set the default number of probe points : n*n (1 -> 7) + // Default number of probe points : n*n (1 -> 7) #define DELTA_CALIBRATION_DEFAULT_POINTS 4 #endif #if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU) - // Set the steprate for papertest probing + // Step size for paper-test probing #define PROBE_MANUALLY_STEP 0.05 // (mm) #endif @@ -956,7 +964,7 @@ //#define MP_SCARA #if EITHER(MORGAN_SCARA, MP_SCARA) // If movement is choppy try lowering this value - #define SCARA_SEGMENTS_PER_SECOND 200 + #define DEFAULT_SEGMENTS_PER_SECOND 200 // Length of inner and outer support arms. Measure arm lengths precisely. #define SCARA_LINKAGE_1 150 // (mm) @@ -992,18 +1000,18 @@ // Enable for TPARA kinematics and configure below //#define AXEL_TPARA #if ENABLED(AXEL_TPARA) - #define DEBUG_ROBOT_KINEMATICS - #define ROBOT_SEGMENTS_PER_SECOND 200 + #define DEBUG_TPARA_KINEMATICS + #define DEFAULT_SEGMENTS_PER_SECOND 200 // Length of inner and outer support arms. Measure arm lengths precisely. - #define ROBOT_LINKAGE_1 120 // (mm) - #define ROBOT_LINKAGE_2 120 // (mm) + #define TPARA_LINKAGE_1 120 // (mm) + #define TPARA_LINKAGE_2 120 // (mm) // SCARA tower offset (position of Tower relative to bed zero position) // This needs to be reasonably accurate as it defines the printbed position in the SCARA space. - #define ROBOT_OFFSET_X 0 // (mm) - #define ROBOT_OFFSET_Y 0 // (mm) - #define ROBOT_OFFSET_Z 0 // (mm) + #define TPARA_OFFSET_X 0 // (mm) + #define TPARA_OFFSET_Y 0 // (mm) + #define TPARA_OFFSET_Z 0 // (mm) #define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly @@ -1657,7 +1665,7 @@ #define DISABLE_E false // Disable the extruder when not stepping #define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled -// @section machine +// @section motion // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. #define INVERT_X_DIR false @@ -1961,17 +1969,21 @@ #endif #if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL) - // Gradually reduce leveling correction until a set height is reached, - // at which point movement will be level to the machine's XY plane. - // The height can be set with M420 Z + /** + * Gradually reduce leveling correction until a set height is reached, + * at which point movement will be level to the machine's XY plane. + * The height can be set with M420 Z + */ #define ENABLE_LEVELING_FADE_HEIGHT #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #define DEFAULT_LEVELING_FADE_HEIGHT 10.0 // (mm) Default fade height. #endif - // For Cartesian machines, instead of dividing moves on mesh boundaries, - // split up moves into short segments like a Delta. This follows the - // contours of the bed more closely than edge-to-edge straight moves. + /** + * For Cartesian machines, instead of dividing moves on mesh boundaries, + * split up moves into short segments like a Delta. This follows the + * contours of the bed more closely than edge-to-edge straight moves. + */ #define SEGMENT_LEVELED_MOVES #define LEVELED_SEGMENT_LENGTH 5.0 // (mm) Length of all segments (except the last one) @@ -2191,9 +2203,8 @@ #define XY_DIAG_BD 282.8427124746 #define XY_SIDE_AD 200 - // Or, set the default skew factors directly here - // to override the above measurements: - #define XY_SKEW_FACTOR 0.0 + // Or, set the XY skew factor directly: + //#define XY_SKEW_FACTOR 0.0 #define SKEW_CORRECTION_FOR_Z #if ENABLED(SKEW_CORRECTION_FOR_Z) @@ -2202,8 +2213,10 @@ #define YZ_DIAG_AC 282.8427124746 #define YZ_DIAG_BD 282.8427124746 #define YZ_SIDE_AD 200 - #define XZ_SKEW_FACTOR 0.0 - #define YZ_SKEW_FACTOR 0.0 + + // Or, set the Z skew factors directly: + //#define XZ_SKEW_FACTOR 0.0 + //#define YZ_SKEW_FACTOR 0.0 #endif // Enable this option for M852 to set skew at runtime @@ -2261,7 +2274,7 @@ // @section temperature // -// Preheat Constants - Up to 6 are supported without changes +// Preheat Constants - Up to 10 are supported without changes // #define PREHEAT_1_LABEL "PLA" #define PREHEAT_1_TEMP_HOTEND 200 @@ -2432,7 +2445,7 @@ */ //#define PRINTCOUNTER #if ENABLED(PRINTCOUNTER) - #define PRINTCOUNTER_SAVE_INTERVAL 60 // (minutes) EEPROM save interval during print + #define PRINTCOUNTER_SAVE_INTERVAL 60 // (minutes) EEPROM save interval during print. A value of 0 will save stats at end of print. #endif // @section security @@ -2803,7 +2816,7 @@ // // ReprapWorld Graphical LCD -// https://reprapworld.com/?products_details&products_id/1218 +// https://reprapworld.com/electronics/3d-printer-modules/autonomous-printing/graphical-lcd-screen-v1-0/ // //#define REPRAPWORLD_GRAPHICAL_LCD @@ -3060,6 +3073,7 @@ //#define ANYCUBIC_LCD_CHIRON #if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) //#define ANYCUBIC_LCD_DEBUG + //#define ANYCUBIC_LCD_GCODE_EXT // Add ".gcode" to menu entries for DGUS clone compatibility #endif // @@ -3128,7 +3142,7 @@ //#define MKS_ROBIN_TFT_V1_1R // -// 480x320, 3.5", FSMC Stock Display from TronxXY +// 480x320, 3.5", FSMC Stock Display from Tronxy // //#define TFT_TRONXY_X5SA @@ -3195,6 +3209,10 @@ //#define TFT_COLOR_UI //#define TFT_LVGL_UI +#if ENABLED(TFT_COLOR_UI) + //#define TFT_SHARED_SPI // SPI is shared between TFT display and other devices. Disable async data transfer +#endif + #if ENABLED(TFT_LVGL_UI) //#define MKS_WIFI_MODULE // MKS WiFi module #endif @@ -3227,10 +3245,11 @@ // //#define TOUCH_SCREEN #if ENABLED(TOUCH_SCREEN) - #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens - #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus + #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens + #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus - //#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn) + //#define DISABLE_ENCODER // Disable the click encoder, if any + //#define TOUCH_IDLE_SLEEP_MINS 5 // (minutes) Display Sleep after a period of inactivity. Set with M255 S. #define TOUCH_SCREEN_CALIBRATION @@ -3321,16 +3340,19 @@ * luminance values can be set from 0 to 255. * For NeoPixel LED an overall brightness parameter is also available. * - * *** CAUTION *** + * === CAUTION === * LED Strips require a MOSFET Chip between PWM lines and LEDs, * as the Arduino cannot handle the current the LEDs will require. * Failure to follow this precaution can destroy your Arduino! + * * NOTE: A separate 5V power supply is required! The NeoPixel LED needs * more current than the Arduino 5V linear regulator can produce. - * *** CAUTION *** * - * LED Type. Enable only one of the following two options. + * Requires PWM frequency between 50 <> 100Hz (Check HAL or variant) + * Use FAST_PWM_FAN, if possible, to reduce fan noise. */ + +// LED Type. Enable only one of the following two options: //#define RGB_LED //#define RGBW_LED @@ -3339,6 +3361,10 @@ //#define RGB_LED_G_PIN 43 //#define RGB_LED_B_PIN 35 //#define RGB_LED_W_PIN -1 + //#define RGB_STARTUP_TEST // For PWM pins, fade between all colors + #if ENABLED(RGB_STARTUP_TEST) + #define RGB_STARTUP_TEST_INNER_MS 10 // (ms) Reduce or increase fading speed + #endif #endif // Support for Adafruit NeoPixel LED driver @@ -3360,6 +3386,7 @@ #define NEOPIXEL2_PIXELS 15 // Number of LEDs in the second strip #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) #define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup + #define NEOPIXEL_M150_DEFAULT -1 // Default strip for M150 without 'S'. Use -1 to set all by default. #else //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel #endif diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a2402097c022..3624d2ba05ea 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -30,7 +30,7 @@ * * Basic settings can be found in Configuration.h */ -#define CONFIGURATION_ADV_H_VERSION 02010100 +#define CONFIGURATION_ADV_H_VERSION 02010200 // @section develop @@ -48,7 +48,7 @@ * 3 = schema.json - The entire configuration schema. (13 = pattern groups) * 4 = schema.yml - The entire configuration schema. */ -//#define CONFIG_EXPORT // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml'] +//#define CONFIG_EXPORT 2 // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml'] //=========================================================================== //============================= Thermal Settings ============================ @@ -175,6 +175,7 @@ //#define TEMP_SENSOR_FORCE_HW_SPI // Ignore SCK/MOSI/MISO pins; use CS and the default SPI bus. //#define MAX31865_SENSOR_WIRES_0 2 // (2-4) Number of wires for the probe connected to a MAX31865 board. //#define MAX31865_SENSOR_WIRES_1 2 +//#define MAX31865_SENSOR_WIRES_2 2 //#define MAX31865_50HZ_FILTER // Use a 50Hz filter instead of the default 60Hz. //#define MAX31865_USE_READ_ERROR_DETECTION // Treat value spikes (20°C delta in under 1s) as read errors. @@ -185,6 +186,7 @@ //#define MAX31865_WIRE_OHMS_0 0.95f // For 2-wire, set the wire resistances for more accurate readings. //#define MAX31865_WIRE_OHMS_1 0.0f +//#define MAX31865_WIRE_OHMS_2 0.0f /** * Hephestos 2 24V heated bed upgrade kit. @@ -467,10 +469,10 @@ * Thermistors able to support high temperature tend to have a hard time getting * good readings at room and lower temperatures. This means TEMP_SENSOR_X_RAW_LO_TEMP * will probably be caught when the heating element first turns on during the - * preheating process, which will trigger a min_temp_error as a safety measure + * preheating process, which will trigger a MINTEMP error as a safety measure * and force stop everything. * To circumvent this limitation, we allow for a preheat time (during which, - * min_temp_error won't be triggered) and add a min_temp buffer to handle + * MINTEMP error won't be triggered) and add a min_temp buffer to handle * aberrant readings. * * If you want to enable this feature for your hotend thermistor(s) @@ -478,21 +480,25 @@ */ // The number of consecutive low temperature errors that can occur -// before a min_temp_error is triggered. (Shouldn't be more than 10.) +// before a MINTEMP error is triggered. (Shouldn't be more than 10.) //#define MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED 0 -// The number of milliseconds a hotend will preheat before starting to check -// the temperature. This value should NOT be set to the time it takes the -// hot end to reach the target temperature, but the time it takes to reach -// the minimum temperature your thermistor can read. The lower the better/safer. -// This shouldn't need to be more than 30 seconds (30000) +/** + * The number of milliseconds a hotend will preheat before starting to check + * the temperature. This value should NOT be set to the time it takes the + * hot end to reach the target temperature, but the time it takes to reach + * the minimum temperature your thermistor can read. The lower the better/safer. + * This shouldn't need to be more than 30 seconds (30000) + */ //#define MILLISECONDS_PREHEAT_TIME 0 // @section extruder -// Extruder runout prevention. -// If the machine is idle and the temperature over MINTEMP -// then extrude some filament every couple of SECONDS. +/** + * Extruder runout prevention. + * If the machine is idle and the temperature over MINTEMP + * then extrude some filament every couple of SECONDS. + */ //#define EXTRUDER_RUNOUT_PREVENT #if ENABLED(EXTRUDER_RUNOUT_PREVENT) #define EXTRUDER_RUNOUT_MINTEMP 190 @@ -532,6 +538,7 @@ //#define USE_CONTROLLER_FAN #if ENABLED(USE_CONTROLLER_FAN) //#define CONTROLLER_FAN_PIN -1 // Set a custom pin for the controller fan + //#define CONTROLLER_FAN2_PIN -1 // Set a custom pin for second controller fan //#define CONTROLLER_FAN_USE_Z_ONLY // With this option only the Z axis is considered //#define CONTROLLER_FAN_IGNORE_Z // Ignore Z stepper. Useful when stepper timeout is disabled. #define CONTROLLERFAN_SPEED_MIN 0 // (0-255) Minimum speed. (If set below this value the fan is turned off.) @@ -548,10 +555,14 @@ #endif #endif -// When first starting the main fan, run it at full speed for the -// given number of milliseconds. This gets the fan spinning reliably -// before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu) -//#define FAN_KICKSTART_TIME 100 +/** + * Fan Kickstart + * When part cooling or controller fans first start, run at a speed that + * gets it spinning reliably for a short time before setting the requested speed. + * (Does not work on Sanguinololu with FAN_SOFT_PWM.) + */ +//#define FAN_KICKSTART_TIME 100 // (ms) +//#define FAN_KICKSTART_POWER 180 // 64-255 // Some coolers may require a non-zero "off" state. //#define FAN_OFF_PWM 1 @@ -870,6 +881,7 @@ #define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (linear=mm, rotational=°) Backoff from endstops after homing +//#define XY_COUNTERPART_BACKOFF_MM 0 // (mm) Backoff X after homing Y, and vice-versa //#define QUICK_HOME // If G28 contains XY do a diagonal move first //#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X @@ -1046,6 +1058,43 @@ // @section motion +/** + * Input Shaping -- EXPERIMENTAL + * + * Zero Vibration (ZV) Input Shaping for X and/or Y movements. + * + * This option uses a lot of SRAM for the step buffer. The buffer size is + * calculated automatically from SHAPING_FREQ_[XY], DEFAULT_AXIS_STEPS_PER_UNIT, + * DEFAULT_MAX_FEEDRATE and ADAPTIVE_STEP_SMOOTHING. The default calculation can + * be overridden by setting SHAPING_MIN_FREQ and/or SHAPING_MAX_FEEDRATE. + * The higher the frequency and the lower the feedrate, the smaller the buffer. + * If the buffer is too small at runtime, input shaping will have reduced + * effectiveness during high speed movements. + * + * Tune with M593 D F: + * + * D Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes. + * F Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes. + * T[map] Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet) + * X<1> Set the given parameters only for the X axis. + * Y<1> Set the given parameters only for the Y axis. + */ +#define INPUT_SHAPING_X +#define INPUT_SHAPING_Y +#if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y) + #if ENABLED(INPUT_SHAPING_X) + #define SHAPING_FREQ_X 40 // (Hz) The default dominant resonant frequency on the X axis. + #define SHAPING_ZETA_X 0.15f // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping). + #endif + #if ENABLED(INPUT_SHAPING_Y) + #define SHAPING_FREQ_Y 40 // (Hz) The default dominant resonant frequency on the Y axis. + #define SHAPING_ZETA_Y 0.15f // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping). + #endif + //#define SHAPING_MIN_FREQ 20 // By default the minimum of the shaping frequencies. Override to affect SRAM usage. + //#define SHAPING_MAX_STEPRATE 10000 // By default the maximum total step rate of the shaped axes. Override to affect SRAM usage. + //#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters. +#endif + #define AXIS_RELATIVE_MODES { false, false, false, false } // Add a Duplicate option for well-separated conjoined nozzles @@ -1151,7 +1200,7 @@ #endif /** - * Automatic backlash, position and hotend offset calibration + * Automatic backlash, position, and hotend offset calibration * * Enable G425 to run automatic calibration using an electrically- * conductive cube, bolt, or washer mounted on the bed. @@ -1325,7 +1374,7 @@ // // LCD Backlight Timeout // -//#define LCD_BACKLIGHT_TIMEOUT 30 // (s) Timeout before turning off the backlight +//#define LCD_BACKLIGHT_TIMEOUT_MINS 1 // (minutes) Timeout before turning off the backlight #if HAS_BED_PROBE && EITHER(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI) //#define PROBE_OFFSET_WIZARD // Add a Probe Z Offset calibration option to the LCD menu @@ -1402,9 +1451,6 @@ // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY - // Add an 'M73' G-code to set the current percentage - //#define LCD_SET_PROGRESS_MANUALLY - // Show the E position (filament used) during printing //#define LCD_SHOW_E_TOTAL @@ -1425,37 +1471,45 @@ //#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup #endif #if ENABLED(NEO2_COLOR_PRESETS) - #define NEO2_USER_PRESET_RED 255 // User defined RED value - #define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value - #define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value - #define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value - #define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity - //#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip + #define NEO2_USER_PRESET_RED 255 // User defined RED value + #define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value + #define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value + #define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value + #define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity + //#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip #endif #endif -#endif - -// LCD Print Progress options -#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) - #if CAN_SHOW_REMAINING_TIME - //#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 // HAS_DISPLAY || DWIN_LCD_PROUI + +// Add 'M73' to set print job progress, overrides Marlin's built-in estimate +//#define SET_PROGRESS_MANUALLY +#if ENABLED(SET_PROGRESS_MANUALLY) + #define SET_PROGRESS_PERCENT // Add 'P' parameter to set percentage done + #define SET_REMAINING_TIME // Add 'R' parameter to set remaining time + //#define SET_INTERACTION_TIME // Add 'C' parameter to set time until next filament change or other user interaction + //#define M73_REPORT // Report M73 values to host + #if BOTH(M73_REPORT, SDSUPPORT) + #define M73_REPORT_SD_ONLY // Report only when printing from SD #endif +#endif - #if EITHER(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI) - //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits +// LCD Print Progress options. Multiple times may be displayed in turn. +#if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY) + #define SHOW_PROGRESS_PERCENT // Show print progress percentage (doesn't affect progress bar) + #define SHOW_ELAPSED_TIME // Display elapsed printing time (prefix 'E') + //#define SHOW_REMAINING_TIME // Display estimated time to completion (prefix 'R') + #if ENABLED(SET_INTERACTION_TIME) + #define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change) #endif + //#define PRINT_PROGRESS_SHOW_DECIMALS // Show/report progress with decimal digits, not all UIs support this #if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) //#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing #if ENABLED(LCD_PROGRESS_BAR) #define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar #define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message - #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever) + #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever) //#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it //#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar #endif @@ -1591,6 +1645,7 @@ #define LONG_FILENAME_HOST_SUPPORT // Get the long filename of a file/folder with 'M33 ' and list long filenames with 'M20 L' //#define LONG_FILENAME_WRITE_SUPPORT // Create / delete files with long filenames via M28, M30, and Binary Transfer Protocol + //#define M20_TIMESTAMP_SUPPORT // Include timestamps by adding the 'T' flag to M20 commands #define SCROLL_LONG_FILENAMES // Scroll long filenames in the SD card menu @@ -1752,7 +1807,7 @@ * Adds the menu item Configuration > LCD Timeout (m) to set a wait period * from 0 (disabled) to 99 minutes. */ - //#define DISPLAY_SLEEP_MINUTES 2 // (minutes) Timeout before turning off the screen + //#define DISPLAY_SLEEP_MINUTES 2 // (minutes) Timeout before turning off the screen. Set with M255 S. /** * ST7920-based LCDs can emulate a 16 x 4 character display using @@ -1806,14 +1861,8 @@ #endif // HAS_MARLINUI_U8GLIB #if HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI - // Show SD percentage next to the progress bar - //#define SHOW_SD_PERCENT - - // Enable to save many cycles by drawing a hollow frame on Menu Screens - #define MENU_HOLLOW_FRAME - - // Swap the CW/CCW indicators in the graphics overlay - //#define OVERLAY_GFX_REVERSE + #define MENU_HOLLOW_FRAME // Enable to save many cycles by drawing a hollow frame on Menu Screens + //#define OVERLAY_GFX_REVERSE // Swap the CW/CCW indicators in the graphics overlay #endif // @@ -2071,11 +2120,17 @@ */ #define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) - //#define EXTRA_LIN_ADVANCE_K // Enable for second linear advance constants - #define LIN_ADVANCE_K 0.00 // Unit: mm compression per 1mm/s extruder speed - //#define LA_DEBUG // If enabled, this will generate debug information output over USB. + #if ENABLED(DISTINCT_E_FACTORS) + #define ADVANCE_K { 0.08 } // (mm) Compression length per 1mm/s extruder speed, per extruder + #else + #define ADVANCE_K 0.08 // (mm) Compression length applying to all extruders + #endif + //#define ADVANCE_K_EXTRA // Add a second linear advance constant, configurable with M900 L. + //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. + //#define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA. #define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration #define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. + //#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz. #endif // @section leveling @@ -2533,7 +2588,7 @@ // Longer prime to clean out a SINGLENOZZLE #define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length #define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/min) Extra priming feedrate - #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm) Retract before cooling for less stringing, better wipe, etc. + #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm) Cutting retraction out of park, for less stringing, better wipe, etc. Adjust with LCD or M217 G. // Cool after prime to reduce stringing #define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip @@ -2639,167 +2694,33 @@ //#define FILAMENT_UNLOAD_ALL_EXTRUDERS // Allow M702 to unload all extruders above a minimum target temp (as set by M302) #endif -/** - * TMC26X Stepper Driver options - * - * The TMC26XStepper library is required for this stepper driver. - * https://github.com/trinamic/TMC26XStepper - * @section tmc/tmc26x - */ -#if HAS_DRIVER(TMC26X) - - #if AXIS_DRIVER_TYPE_X(TMC26X) - #define X_MAX_CURRENT 1000 // (mA) - #define X_SENSE_RESISTOR 91 // (mOhms) - #define X_MICROSTEPS 16 // Number of microsteps - #endif - - #if AXIS_DRIVER_TYPE_X2(TMC26X) - #define X2_MAX_CURRENT 1000 - #define X2_SENSE_RESISTOR 91 - #define X2_MICROSTEPS X_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Y(TMC26X) - #define Y_MAX_CURRENT 1000 - #define Y_SENSE_RESISTOR 91 - #define Y_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_Y2(TMC26X) - #define Y2_MAX_CURRENT 1000 - #define Y2_SENSE_RESISTOR 91 - #define Y2_MICROSTEPS Y_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Z(TMC26X) - #define Z_MAX_CURRENT 1000 - #define Z_SENSE_RESISTOR 91 - #define Z_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_Z2(TMC26X) - #define Z2_MAX_CURRENT 1000 - #define Z2_SENSE_RESISTOR 91 - #define Z2_MICROSTEPS Z_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Z3(TMC26X) - #define Z3_MAX_CURRENT 1000 - #define Z3_SENSE_RESISTOR 91 - #define Z3_MICROSTEPS Z_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Z4(TMC26X) - #define Z4_MAX_CURRENT 1000 - #define Z4_SENSE_RESISTOR 91 - #define Z4_MICROSTEPS Z_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_I(TMC26X) - #define I_MAX_CURRENT 1000 - #define I_SENSE_RESISTOR 91 - #define I_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_J(TMC26X) - #define J_MAX_CURRENT 1000 - #define J_SENSE_RESISTOR 91 - #define J_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_K(TMC26X) - #define K_MAX_CURRENT 1000 - #define K_SENSE_RESISTOR 91 - #define K_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_U(TMC26X) - #define U_MAX_CURRENT 1000 - #define U_SENSE_RESISTOR 91 - #define U_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_V(TMC26X) - #define V_MAX_CURRENT 1000 - #define V_SENSE_RESISTOR 91 - #define V_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_W(TMC26X) - #define W_MAX_CURRENT 1000 - #define W_SENSE_RESISTOR 91 - #define W_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_E0(TMC26X) - #define E0_MAX_CURRENT 1000 - #define E0_SENSE_RESISTOR 91 - #define E0_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_E1(TMC26X) - #define E1_MAX_CURRENT 1000 - #define E1_SENSE_RESISTOR 91 - #define E1_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E2(TMC26X) - #define E2_MAX_CURRENT 1000 - #define E2_SENSE_RESISTOR 91 - #define E2_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E3(TMC26X) - #define E3_MAX_CURRENT 1000 - #define E3_SENSE_RESISTOR 91 - #define E3_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E4(TMC26X) - #define E4_MAX_CURRENT 1000 - #define E4_SENSE_RESISTOR 91 - #define E4_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E5(TMC26X) - #define E5_MAX_CURRENT 1000 - #define E5_SENSE_RESISTOR 91 - #define E5_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E6(TMC26X) - #define E6_MAX_CURRENT 1000 - #define E6_SENSE_RESISTOR 91 - #define E6_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E7(TMC26X) - #define E7_MAX_CURRENT 1000 - #define E7_SENSE_RESISTOR 91 - #define E7_MICROSTEPS E0_MICROSTEPS - #endif - -#endif // TMC26X +// @section tmc_smart /** - * To use TMC2130, TMC2160, TMC2660, TMC5130, TMC5160 stepper drivers in SPI mode - * connect your SPI pins to the hardware SPI interface on your board and define - * the required CS pins in your `pins_MYBOARD.h` file. (e.g., RAMPS 1.4 uses AUX3 - * pins `X_CS_PIN 53`, `Y_CS_PIN 49`, etc.). - * You may also use software SPI if you wish to use general purpose IO pins. + * Trinamic Smart Drivers * - * To use TMC2208 stepper UART-configurable stepper drivers connect #_SERIAL_TX_PIN - * to the driver side PDN_UART pin with a 1K resistor. - * To use the reading capabilities, also connect #_SERIAL_RX_PIN to PDN_UART without - * a resistor. - * The drivers can also be used with hardware serial. + * To use TMC2130, TMC2160, TMC2660, TMC5130, TMC5160 stepper drivers in SPI mode: + * - Connect your SPI pins to the Hardware SPI interface on the board. + * Some boards have simple jumper connections! See your board's documentation. + * - Define the required Stepper CS pins in your `pins_MYBOARD.h` file. + * (See the RAMPS pins, for example.) + * - You can also use Software SPI with GPIO pins instead of Hardware SPI. + * + * To use TMC220x stepper drivers with Serial UART: + * - Connect PDN_UART to the #_SERIAL_TX_PIN through a 1K resistor. + * For reading capabilities also connect PDN_UART to #_SERIAL_RX_PIN with no resistor. + * Some boards have simple jumper connections! See your board's documentation. + * - These drivers can also be used with Hardware Serial. + * + * The TMC26XStepper library is required for TMC26X stepper drivers. + * https://github.com/MarlinFirmware/TMC26XStepper + * + * The TMCStepper library is required for other TMC stepper drivers. + * https://github.com/teemuatlut/TMCStepper * - * TMCStepper library is required to use TMC stepper drivers. - * https://github.com/teemuatlut/TMCStepper * @section tmc/config */ -#if HAS_TRINAMIC_CONFIG +#if HAS_TRINAMIC_CONFIG || HAS_TMC26X #define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current @@ -2809,17 +2730,17 @@ */ #define INTERPOLATE true - #if AXIS_IS_TMC(X) + #if AXIS_IS_TMC_CONFIG(X) #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current. #define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing #define X_MICROSTEPS 16 // 0..256 - #define X_RSENSE 0.11 + #define X_RSENSE 0.11 // Multiplied x1000 for TMC26X #define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ... //#define X_INTERPOLATE true // Enable to override 'INTERPOLATE' for the X axis //#define X_HOLD_MULTIPLIER 0.5 // Enable to override 'HOLD_MULTIPLIER' for the X axis #endif - #if AXIS_IS_TMC(X2) + #if AXIS_IS_TMC_CONFIG(X2) #define X2_CURRENT 800 #define X2_CURRENT_HOME X2_CURRENT #define X2_MICROSTEPS X_MICROSTEPS @@ -2829,7 +2750,7 @@ //#define X2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Y) + #if AXIS_IS_TMC_CONFIG(Y) #define Y_CURRENT 800 #define Y_CURRENT_HOME Y_CURRENT #define Y_MICROSTEPS 16 @@ -2839,7 +2760,7 @@ //#define Y_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Y2) + #if AXIS_IS_TMC_CONFIG(Y2) #define Y2_CURRENT 800 #define Y2_CURRENT_HOME Y2_CURRENT #define Y2_MICROSTEPS Y_MICROSTEPS @@ -2849,7 +2770,7 @@ //#define Y2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z) + #if AXIS_IS_TMC_CONFIG(Z) #define Z_CURRENT 800 #define Z_CURRENT_HOME Z_CURRENT #define Z_MICROSTEPS 16 @@ -2859,7 +2780,7 @@ //#define Z_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z2) + #if AXIS_IS_TMC_CONFIG(Z2) #define Z2_CURRENT 800 #define Z2_CURRENT_HOME Z2_CURRENT #define Z2_MICROSTEPS Z_MICROSTEPS @@ -2869,7 +2790,7 @@ //#define Z2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z3) + #if AXIS_IS_TMC_CONFIG(Z3) #define Z3_CURRENT 800 #define Z3_CURRENT_HOME Z3_CURRENT #define Z3_MICROSTEPS Z_MICROSTEPS @@ -2879,7 +2800,7 @@ //#define Z3_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z4) + #if AXIS_IS_TMC_CONFIG(Z4) #define Z4_CURRENT 800 #define Z4_CURRENT_HOME Z4_CURRENT #define Z4_MICROSTEPS Z_MICROSTEPS @@ -2889,7 +2810,7 @@ //#define Z4_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(I) + #if AXIS_IS_TMC_CONFIG(I) #define I_CURRENT 800 #define I_CURRENT_HOME I_CURRENT #define I_MICROSTEPS 16 @@ -2899,7 +2820,7 @@ //#define I_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(J) + #if AXIS_IS_TMC_CONFIG(J) #define J_CURRENT 800 #define J_CURRENT_HOME J_CURRENT #define J_MICROSTEPS 16 @@ -2909,7 +2830,7 @@ //#define J_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(K) + #if AXIS_IS_TMC_CONFIG(K) #define K_CURRENT 800 #define K_CURRENT_HOME K_CURRENT #define K_MICROSTEPS 16 @@ -2919,7 +2840,7 @@ //#define K_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(U) + #if AXIS_IS_TMC_CONFIG(U) #define U_CURRENT 800 #define U_CURRENT_HOME U_CURRENT #define U_MICROSTEPS 8 @@ -2929,7 +2850,7 @@ //#define U_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(V) + #if AXIS_IS_TMC_CONFIG(V) #define V_CURRENT 800 #define V_CURRENT_HOME V_CURRENT #define V_MICROSTEPS 8 @@ -2939,7 +2860,7 @@ //#define V_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(W) + #if AXIS_IS_TMC_CONFIG(W) #define W_CURRENT 800 #define W_CURRENT_HOME W_CURRENT #define W_MICROSTEPS 8 @@ -2949,7 +2870,7 @@ //#define W_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E0) + #if AXIS_IS_TMC_CONFIG(E0) #define E0_CURRENT 800 #define E0_MICROSTEPS 16 #define E0_RSENSE 0.11 @@ -2958,7 +2879,7 @@ //#define E0_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E1) + #if AXIS_IS_TMC_CONFIG(E1) #define E1_CURRENT 800 #define E1_MICROSTEPS E0_MICROSTEPS #define E1_RSENSE 0.11 @@ -2967,7 +2888,7 @@ //#define E1_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E2) + #if AXIS_IS_TMC_CONFIG(E2) #define E2_CURRENT 800 #define E2_MICROSTEPS E0_MICROSTEPS #define E2_RSENSE 0.11 @@ -2976,7 +2897,7 @@ //#define E2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E3) + #if AXIS_IS_TMC_CONFIG(E3) #define E3_CURRENT 800 #define E3_MICROSTEPS E0_MICROSTEPS #define E3_RSENSE 0.11 @@ -2985,7 +2906,7 @@ //#define E3_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E4) + #if AXIS_IS_TMC_CONFIG(E4) #define E4_CURRENT 800 #define E4_MICROSTEPS E0_MICROSTEPS #define E4_RSENSE 0.11 @@ -2994,7 +2915,7 @@ //#define E4_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E5) + #if AXIS_IS_TMC_CONFIG(E5) #define E5_CURRENT 800 #define E5_MICROSTEPS E0_MICROSTEPS #define E5_RSENSE 0.11 @@ -3003,7 +2924,7 @@ //#define E5_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E6) + #if AXIS_IS_TMC_CONFIG(E6) #define E6_CURRENT 800 #define E6_MICROSTEPS E0_MICROSTEPS #define E6_RSENSE 0.11 @@ -3012,7 +2933,7 @@ //#define E6_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E7) + #if AXIS_IS_TMC_CONFIG(E7) #define E7_CURRENT 800 #define E7_MICROSTEPS E0_MICROSTEPS #define E7_RSENSE 0.11 @@ -3114,15 +3035,17 @@ * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. */ - #define STEALTHCHOP_XY - #define STEALTHCHOP_Z - #define STEALTHCHOP_I - #define STEALTHCHOP_J - #define STEALTHCHOP_K - #define STEALTHCHOP_U - #define STEALTHCHOP_V - #define STEALTHCHOP_W - #define STEALTHCHOP_E + #if HAS_STEALTHCHOP + #define STEALTHCHOP_XY + #define STEALTHCHOP_Z + #define STEALTHCHOP_I + #define STEALTHCHOP_J + #define STEALTHCHOP_K + #define STEALTHCHOP_U + #define STEALTHCHOP_V + #define STEALTHCHOP_W + #define STEALTHCHOP_E + #endif /** * Optimize spreadCycle chopper parameters by using predefined parameter sets @@ -3305,7 +3228,7 @@ */ #define TMC_ADV() { } -#endif // HAS_TRINAMIC_CONFIG +#endif // HAS_TRINAMIC_CONFIG || HAS_TMC26X // @section i2cbus @@ -4064,7 +3987,7 @@ /** * Mechanical Gantry Calibration - * Modern replacement for the Prusa TMC_Z_CALIBRATION. + * Modern replacement for the Průša TMC_Z_CALIBRATION. * Adds capability to work with any adjustable current drivers. * Implemented as G34 because M915 is deprecated. * @section calibrate @@ -4155,7 +4078,7 @@ /** * WiFi Support (Espressif ESP32 WiFi) */ -//#define WIFISUPPORT // Marlin embedded WiFi managenent +//#define WIFISUPPORT // Marlin embedded WiFi management //#define ESP3D_WIFISUPPORT // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib) #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) diff --git a/Marlin/Makefile b/Marlin/Makefile index c72c1d589607..ca7cacaa6acb 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -307,20 +307,22 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1154) else ifeq ($(HARDWARE_MOTHERBOARD),1155) # Tenlog D3 Hero IDEX printer else ifeq ($(HARDWARE_MOTHERBOARD),1156) -# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) +# Tenlog D3,5,6 Pro IDEX printers else ifeq ($(HARDWARE_MOTHERBOARD),1157) -# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) +# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) else ifeq ($(HARDWARE_MOTHERBOARD),1158) -# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) +# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) else ifeq ($(HARDWARE_MOTHERBOARD),1159) -# Longer LK1 PRO / Alfawise U20 Pro (PRO version) +# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) else ifeq ($(HARDWARE_MOTHERBOARD),1160) -# Longer LKx PRO / Alfawise Uxx Pro (PRO version) +# Longer LK1 PRO / Alfawise U20 Pro (PRO version) else ifeq ($(HARDWARE_MOTHERBOARD),1161) -# Zonestar zrib V5.3 (Chinese RAMPS replica) +# Longer LKx PRO / Alfawise Uxx Pro (PRO version) else ifeq ($(HARDWARE_MOTHERBOARD),1162) -# Pxmalion Core I3 +# Zonestar zrib V5.3 (Chinese RAMPS replica) else ifeq ($(HARDWARE_MOTHERBOARD),1163) +# Pxmalion Core I3 +else ifeq ($(HARDWARE_MOTHERBOARD),1164) # # RAMBo and derivatives diff --git a/Marlin/Version.h b/Marlin/Version.h index d9ec298edef2..3514add53ba4 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -28,7 +28,7 @@ /** * Marlin release version identifier */ -//#define SHORT_BUILD_VERSION "2.1.1" +//#define SHORT_BUILD_VERSION "2.1.2" /** * Verbose version identifier which should contain a reference to the location @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-08-06" +//#define STRING_DISTRIBUTION_DATE "2022-12-17" /** * 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 149186772158..d458790979ff 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -32,6 +32,7 @@ #include #else #include "MarlinSerial.h" + #define BOARD_NO_NATIVE_USB #endif #include @@ -106,36 +107,36 @@ typedef Servo hal_servo_t; #define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0) #else - #if !WITHIN(SERIAL_PORT, -1, 3) - #error "SERIAL_PORT must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(SERIAL_PORT, 0, 3) + #error "SERIAL_PORT must be from 0 to 3." #endif #define MYSERIAL1 customizedSerial1 #ifdef SERIAL_PORT_2 - #if !WITHIN(SERIAL_PORT_2, -1, 3) - #error "SERIAL_PORT_2 must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(SERIAL_PORT_2, 0, 3) + #error "SERIAL_PORT_2 must be from 0 to 3." #endif #define MYSERIAL2 customizedSerial2 #endif #ifdef SERIAL_PORT_3 - #if !WITHIN(SERIAL_PORT_3, -1, 3) - #error "SERIAL_PORT_3 must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(SERIAL_PORT_3, 0, 3) + #error "SERIAL_PORT_3 must be from 0 to 3." #endif #define MYSERIAL3 customizedSerial3 #endif #endif #ifdef MMU2_SERIAL_PORT - #if !WITHIN(MMU2_SERIAL_PORT, -1, 3) - #error "MMU2_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(MMU2_SERIAL_PORT, 0, 3) + #error "MMU2_SERIAL_PORT must be from 0 to 3" #endif #define MMU2_SERIAL mmuSerial #endif #ifdef LCD_SERIAL_PORT - #if !WITHIN(LCD_SERIAL_PORT, -1, 3) - #error "LCD_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(LCD_SERIAL_PORT, 0, 3) + #error "LCD_SERIAL_PORT must be from 0 to 3." #endif #define LCD_SERIAL lcdSerial #if HAS_DGUS_LCD diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp index 0a384172c32a..d361aaab38f3 100644 --- a/Marlin/src/HAL/AVR/fast_pwm.cpp +++ b/Marlin/src/HAL/AVR/fast_pwm.cpp @@ -146,10 +146,10 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { LIMIT(res_pc_temp, 1U, maxtop); // Calculate frequencies of test prescaler and resolution values - const uint32_t f_diff = _MAX(f, f_desired) - _MIN(f, f_desired), - f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)), + const uint16_t f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)), + f_pc_temp = (F_CPU) / (2 * p * res_pc_temp); + const int f_diff = _MAX(f, f_desired) - _MIN(f, f_desired), f_fast_diff = _MAX(f_fast_temp, f_desired) - _MIN(f_fast_temp, f_desired), - f_pc_temp = (F_CPU) / (2 * p * res_pc_temp), f_pc_diff = _MAX(f_pc_temp, f_desired) - _MIN(f_pc_temp, f_desired); if (f_fast_diff < f_diff && f_fast_diff <= f_pc_diff) { // FAST values are closest to desired f diff --git a/Marlin/src/HAL/AVR/fastio.h b/Marlin/src/HAL/AVR/fastio.h index 51d3b311ee9d..612ab902e36f 100644 --- a/Marlin/src/HAL/AVR/fastio.h +++ b/Marlin/src/HAL/AVR/fastio.h @@ -293,11 +293,11 @@ enum ClockSource2 : uint8_t { #if HAS_MOTOR_CURRENT_PWM #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_Z || P == MOTOR_CURRENT_PWM_XY) + #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1 || P == MOTOR_CURRENT_PWM_Z || P == MOTOR_CURRENT_PWM_XY) #elif PIN_EXISTS(MOTOR_CURRENT_PWM_Z) - #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_Z) + #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1 || P == MOTOR_CURRENT_PWM_Z) #else - #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E) + #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1) #endif #else #define PWM_CHK_MOTOR_CURRENT(P) false diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h index 89425ca853b3..ff1610f74164 100644 --- a/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -37,22 +37,24 @@ || X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \ || BTN_EN1 == N || BTN_EN2 == N \ ) -#if CONF_SERIAL_IS(0) +#if SERIAL_IN_USE(0) // D0-D1. No known conflicts. #endif -#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) - #if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) - #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." - #endif -#else - #if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)) - #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board." +#if SERIAL_IN_USE(1) + #if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) + #if CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19) + #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." + #endif + #else + #if CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11) + #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board." + #endif #endif #endif -#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) +#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board." #endif -#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) +#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board." #endif #undef CHECK_SERIAL_PIN diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 4d3f4823a517..585b8938417f 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -210,7 +210,7 @@ class MarlinHAL { static void adc_init() {} // Called by Temperature::init for each sensor at startup - static void adc_enable(const uint8_t ch) {} + static void adc_enable(const uint8_t /*ch*/) {} // Begin ADC sampling on the given channel. Called from Temperature::isr! static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); } diff --git a/Marlin/src/HAL/DUE/HAL_SPI.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp index 7e3fe0135645..f5bcaacee505 100644 --- a/Marlin/src/HAL/DUE/HAL_SPI.cpp +++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp @@ -247,12 +247,12 @@ b <<= 1; // little setup time WRITE(SD_SCK_PIN, HIGH); - DELAY_NS(spiDelayNS); + DELAY_NS_VAR(spiDelayNS); b |= (READ(SD_MISO_PIN) != 0); WRITE(SD_SCK_PIN, LOW); - DELAY_NS(spiDelayNS); + DELAY_NS_VAR(spiDelayNS); } while (--bits); return b; } diff --git a/Marlin/src/HAL/DUE/InterruptVectors.cpp b/Marlin/src/HAL/DUE/InterruptVectors.cpp index e4e0ce99f2b5..70795d1c30af 100644 --- a/Marlin/src/HAL/DUE/InterruptVectors.cpp +++ b/Marlin/src/HAL/DUE/InterruptVectors.cpp @@ -41,7 +41,7 @@ practice, we need alignment to 256 bytes to make this work in all cases */ __attribute__ ((aligned(256))) -static DeviceVectors ram_tab = { nullptr }; +static DeviceVectors ram_tab[61] = { nullptr }; /** * This function checks if the exception/interrupt table is already in SRAM or not. diff --git a/Marlin/src/HAL/DUE/inc/SanityCheck.h b/Marlin/src/HAL/DUE/inc/SanityCheck.h index 13484f7029d1..1f5acc360c72 100644 --- a/Marlin/src/HAL/DUE/inc/SanityCheck.h +++ b/Marlin/src/HAL/DUE/inc/SanityCheck.h @@ -36,15 +36,15 @@ || X_DIR_PIN == N || Y_DIR_PIN == N || Z_DIR_PIN == N \ || X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \ ) -#if CONF_SERIAL_IS(0) // D0-D1. No known conflicts. +#if SERIAL_IN_USE(0) // D0-D1. No known conflicts. #endif -#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) +#if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." #endif -#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) +#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board." #endif -#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) +#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board." #endif #undef CHECK_SERIAL_PIN diff --git a/Marlin/src/HAL/DUE/pinsDebug.h b/Marlin/src/HAL/DUE/pinsDebug.h index df1ba415e918..2aafe9be0c56 100644 --- a/Marlin/src/HAL/DUE/pinsDebug.h +++ b/Marlin/src/HAL/DUE/pinsDebug.h @@ -70,7 +70,7 @@ #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) #define GET_ARRAY_PIN(p) pin_array[p].pin #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital -#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0) +#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL)) #define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0)) #define IS_ANALOG(P) WITHIN(P, char(analogInputToDigitalPin(0)), char(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1))) #define pwm_status(pin) (((g_pinStatus[pin] & 0xF) == PIN_STATUS_PWM) && \ diff --git a/Marlin/src/HAL/DUE/upload_extra_script.py b/Marlin/src/HAL/DUE/upload_extra_script.py index 4f7a494512b2..ca12b3b54f43 100644 --- a/Marlin/src/HAL/DUE/upload_extra_script.py +++ b/Marlin/src/HAL/DUE/upload_extra_script.py @@ -6,14 +6,14 @@ # import pioutil if pioutil.is_pio_build(): - import platform - current_OS = platform.system() + import platform + current_OS = platform.system() - if current_OS == 'Windows': + if current_OS == 'Windows': - Import("env") + Import("env") - # Use bossac.exe on Windows - env.Replace( - UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE" - ) + # Use bossac.exe on Windows + env.Replace( + UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE" + ) diff --git a/Marlin/src/HAL/DUE/usb/usb_task.c b/Marlin/src/HAL/DUE/usb/usb_task.c index 54a808d7f4f1..86ab27217abc 100644 --- a/Marlin/src/HAL/DUE/usb/usb_task.c +++ b/Marlin/src/HAL/DUE/usb/usb_task.c @@ -62,7 +62,7 @@ void usb_task_idle(void) { // Attend SD card access from the USB MSD -- Prioritize access to improve speed int delay = 2; while (main_b_msc_enable && --delay > 0) { - if (udi_msc_process_trans()) delay = 10000; + if (udi_msc_process_trans()) delay = 20; // Reset the watchdog, just to be sure REG_WDT_CR = WDT_CR_WDRSTT | WDT_CR_KEY(0xA5); diff --git a/Marlin/src/HAL/ESP32/i2s.cpp b/Marlin/src/HAL/ESP32/i2s.cpp index cf337eeb4622..d9bad4ec2d12 100644 --- a/Marlin/src/HAL/ESP32/i2s.cpp +++ b/Marlin/src/HAL/ESP32/i2s.cpp @@ -139,22 +139,40 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg) { } void stepperTask(void *parameter) { - uint32_t remaining = 0; + uint32_t nextMainISR = 0; + #if ENABLED(LIN_ADVANCE) + uint32_t nextAdvanceISR = Stepper::LA_ADV_NEVER; + #endif - while (1) { + for (;;) { xQueueReceive(dma.queue, &dma.current, portMAX_DELAY); dma.rw_pos = 0; while (dma.rw_pos < DMA_SAMPLE_COUNT) { // Fill with the port data post pulse_phase until the next step - if (remaining) { + if (nextMainISR && TERN1(LIN_ADVANCE, nextAdvanceISR)) i2s_push_sample(); - remaining--; - } - else { + + // i2s_push_sample() is also called from Stepper::pulse_phase_isr() and Stepper::advance_isr() + // in a rare case where both are called, we need to double decrement the counters + const uint8_t push_count = 1 + (!nextMainISR && TERN0(LIN_ADVANCE, !nextAdvanceISR)); + + #if ENABLED(LIN_ADVANCE) + if (!nextAdvanceISR) { + Stepper::advance_isr(); + nextAdvanceISR = Stepper::la_interval; + } + else if (nextAdvanceISR == Stepper::LA_ADV_NEVER) + nextAdvanceISR = Stepper::la_interval; + #endif + + if (!nextMainISR) { Stepper::pulse_phase_isr(); - remaining = Stepper::block_phase_isr(); + nextMainISR = Stepper::block_phase_isr(); } + + nextMainISR -= push_count; + TERN_(LIN_ADVANCE, nextAdvanceISR -= push_count); } } } diff --git a/Marlin/src/HAL/ESP32/inc/SanityCheck.h b/Marlin/src/HAL/ESP32/inc/SanityCheck.h index 3ccb15989f33..8c5621f10c02 100644 --- a/Marlin/src/HAL/ESP32/inc/SanityCheck.h +++ b/Marlin/src/HAL/ESP32/inc/SanityCheck.h @@ -45,10 +45,14 @@ #error "FAST_PWM_FAN is not available on TinyBee." #endif +#if BOTH(I2S_STEPPER_STREAM, BABYSTEPPING) && DISABLED(INTEGRATED_BABYSTEPPING) + #error "BABYSTEPPING on I2S stream requires INTEGRATED_BABYSTEPPING." +#endif + #if USING_PULLDOWNS #error "PULLDOWN pin mode is not available on ESP32 boards." #endif -#if BOTH(I2S_STEPPER_STREAM, LIN_ADVANCE) +#if BOTH(I2S_STEPPER_STREAM, LIN_ADVANCE) && DISABLED(EXPERIMENTAL_I2S_LA) #error "I2S stream is currently incompatible with LIN_ADVANCE." #endif diff --git a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp index a445035b2b43..bd7ecdc9f217 100644 --- a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp +++ b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp @@ -32,6 +32,13 @@ #include "HAL.h" #include "SPI.h" +#if ENABLED(SDSUPPORT) + #include "../../sd/cardreader.h" + #if ENABLED(ESP3D_WIFISUPPORT) + #include "sd_ESP32.h" + #endif +#endif + static SPISettings spiConfig; @@ -45,6 +52,11 @@ static SPISettings spiConfig; uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT + + #if ENABLED(PAUSE_LCD_FOR_BUSY_SD) + if (card.flag.saving || card.flag.logging || TERN0(ESP3D_WIFISUPPORT, sd_busy_lock == true)) return 0; + #endif + if (msgInitCount) { if (msg == U8G_COM_MSG_INIT) msgInitCount--; if (msgInitCount) return -1; diff --git a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp index 29f9b43afef0..257d8579e21d 100644 --- a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp +++ b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp @@ -318,8 +318,16 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) { // Enable DMA GPDMA_ChannelCmd(0, ENABLE); + /* + * Observed behaviour on normal data transfer completion (SKR 1.3 board / LPC1768 MCU) + * GPDMA_STAT_INTTC flag is SET + * GPDMA_STAT_INTERR flag is NOT SET + * GPDMA_STAT_RAWINTTC flag is NOT SET + * GPDMA_STAT_RAWINTERR flag is SET + */ + // Wait for data transfer - while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { } + while (!GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)) {} // Clear err and int GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0); @@ -333,6 +341,43 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) { SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE); } +void SPIClass::dmaSendAsync(void *buf, uint16_t length, bool minc) { + //TODO: LPC dma can only write 0xFFF bytes at once. + GPDMA_Channel_CFG_Type GPDMACfg; + + /* Configure GPDMA channel 0 -------------------------------------------------------------*/ + /* DMA Channel 0 */ + GPDMACfg.ChannelNum = 0; + // Source memory + GPDMACfg.SrcMemAddr = (uint32_t)buf; + // Destination memory - Not used + GPDMACfg.DstMemAddr = 0; + // Transfer size + GPDMACfg.TransferSize = length; + // Transfer width + GPDMACfg.TransferWidth = (_currentSetting->dataSize == DATA_SIZE_16BIT) ? GPDMA_WIDTH_HALFWORD : GPDMA_WIDTH_BYTE; + // Transfer type + GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P; + // Source connection - unused + GPDMACfg.SrcConn = 0; + // Destination connection + GPDMACfg.DstConn = (_currentSetting->spi_d == LPC_SSP0) ? GPDMA_CONN_SSP0_Tx : GPDMA_CONN_SSP1_Tx; + + GPDMACfg.DMALLI = 0; + + // Enable dma on SPI + SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE); + + // Only increase memory if minc is true + GPDMACfg.MemoryIncrease = (minc ? GPDMA_DMACCxControl_SI : 0); + + // Setup channel with given parameter + GPDMA_Setup(&GPDMACfg); + + // Enable DMA + GPDMA_ChannelCmd(0, ENABLE); +} + uint16_t SPIClass::read() { return SSP_ReceiveData(_currentSetting->spi_d); } diff --git a/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h b/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h index be574a96e4ed..35499500081a 100644 --- a/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h +++ b/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h @@ -29,6 +29,6 @@ // LPC1768 boards seem to lose steps when saving to EEPROM during print (issue #20785) // TODO: Which other boards are incompatible? -#if defined(MCU_LPC1768) && PRINTCOUNTER_SAVE_INTERVAL > 0 +#if defined(MCU_LPC1768) && ENABLED(FLASH_EEPROM_EMULATION) && PRINTCOUNTER_SAVE_INTERVAL > 0 #define PRINTCOUNTER_SYNC 1 #endif diff --git a/Marlin/src/HAL/LPC1768/include/SPI.h b/Marlin/src/HAL/LPC1768/include/SPI.h index 24f4759315bd..03d34becd856 100644 --- a/Marlin/src/HAL/LPC1768/include/SPI.h +++ b/Marlin/src/HAL/LPC1768/include/SPI.h @@ -155,6 +155,7 @@ class SPIClass { void read(uint8_t *buf, uint32_t len); void dmaSend(void *buf, uint16_t length, bool minc); + void dmaSendAsync(void *buf, uint16_t length, bool minc); /** * @brief Sets the number of the SPI peripheral to be used by diff --git a/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp b/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp index a9847b2d2fa0..804fc85e792f 100644 --- a/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp +++ b/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp @@ -26,7 +26,7 @@ #include "tft_spi.h" -SPIClass TFT_SPI::SPIx(1); +SPIClass TFT_SPI::SPIx(TFT_SPI_DEVICE); void TFT_SPI::Init() { #if PIN_EXISTS(TFT_RESET) @@ -38,40 +38,10 @@ void TFT_SPI::Init() { OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif - SET_OUTPUT(TFT_DC_PIN); - SET_OUTPUT(TFT_CS_PIN); - WRITE(TFT_DC_PIN, HIGH); - WRITE(TFT_CS_PIN, HIGH); - - /** - * STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz - * STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1 - * so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2 - */ - #if 0 - #if SPI_DEVICE == 1 - #define SPI_CLOCK_MAX SPI_CLOCK_DIV4 - #else - #define SPI_CLOCK_MAX SPI_CLOCK_DIV2 - #endif - uint8_t clock; - uint8_t spiRate = SPI_FULL_SPEED; - switch (spiRate) { - case SPI_FULL_SPEED: clock = SPI_CLOCK_MAX ; break; - case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4 ; break; - case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8 ; break; - case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break; - case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break; - case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break; - default: clock = SPI_CLOCK_DIV2; // Default from the SPI library - } - #endif + OUT_WRITE(TFT_DC_PIN, HIGH); + OUT_WRITE(TFT_CS_PIN, HIGH); - #if TFT_MISO_PIN == BOARD_SPI1_MISO_PIN - SPIx.setModule(1); - #elif TFT_MISO_PIN == BOARD_SPI2_MISO_PIN - SPIx.setModule(2); - #endif + SPIx.setModule(TFT_SPI_DEVICE); SPIx.setClock(SPI_CLOCK_MAX_TFT); SPIx.setBitOrder(MSBFIRST); SPIx.setDataMode(SPI_MODE0); @@ -114,17 +84,62 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { return data >> 7; } -bool TFT_SPI::isBusy() { return false; } +bool TFT_SPI::isBusy() { + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->DMACCSrcAddr != 0) + + // DMA Channel 0 is hardcoded in dmaSendAsync() and dmaSend() + if (!__IS_DMA_CONFIGURED(LPC_GPDMACH0)) return false; + + if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)) { + // You should not be here - DMA transfer error flag is set + // Abort DMA transfer and release SPI + } + else { + // Check if DMA transfer completed flag is set + if (!GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)) return true; + // Check if SPI TX butter is empty and SPI is idle + if ((SSP_GetStatus(LPC_SSPx, SSP_STAT_TXFIFO_EMPTY) == RESET) || (SSP_GetStatus(LPC_SSPx, SSP_STAT_BUSY) == SET)) return true; + } + + Abort(); + return false; +} + +void TFT_SPI::Abort() { + // DMA Channel 0 is hardcoded in dmaSendAsync() and dmaSend() + + // Disable DMA + GPDMA_ChannelCmd(0, DISABLE); + + // Clear ERR and TC + GPDMA_ClearIntPending(GPDMA_STATCLR_INTTC, 0); + GPDMA_ClearIntPending(GPDMA_STATCLR_INTERR, 0); + + // Disable DMA on SPI + SSP_DMACmd(LPC_SSPx, SSP_DMA_TX, DISABLE); + + // Deconfigure DMA Channel 0 + LPC_GPDMACH0->DMACCControl = 0U; + LPC_GPDMACH0->DMACCConfig = 0U; + LPC_GPDMACH0->DMACCSrcAddr = 0U; + LPC_GPDMACH0->DMACCDestAddr = 0U; -void TFT_SPI::Abort() { DataTransferEnd(); } + DataTransferEnd(); +} void TFT_SPI::Transmit(uint16_t Data) { SPIx.transfer(Data); } -void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { +void TFT_SPI::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DataTransferBegin(DATASIZE_16BIT); - WRITE(TFT_DC_PIN, HIGH); SPIx.dmaSend(Data, Count, MemoryIncrease); - DataTransferEnd(); + Abort(); +} + +void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + DataTransferBegin(DATASIZE_16BIT); + SPIx.dmaSendAsync(Data, Count, MemoryIncrease); + + TERN_(TFT_SHARED_SPI, while (isBusy())); } #endif // HAS_SPI_TFT diff --git a/Marlin/src/HAL/LPC1768/tft/tft_spi.h b/Marlin/src/HAL/LPC1768/tft/tft_spi.h index 4753fdbae9a0..dad393981ed1 100644 --- a/Marlin/src/HAL/LPC1768/tft/tft_spi.h +++ b/Marlin/src/HAL/LPC1768/tft/tft_spi.h @@ -27,6 +27,18 @@ #include // #include +#define IS_SPI(N) (BOARD_NR_SPI >= N && (TFT_SCK_PIN == BOARD_SPI##N##_SCK_PIN) && (TFT_MOSI_PIN == BOARD_SPI##N##_MOSI_PIN) && (TFT_MISO_PIN == BOARD_SPI##N##_MISO_PIN)) +#if IS_SPI(1) + #define TFT_SPI_DEVICE 1 + #define LPC_SSPx LPC_SSP0 +#elif IS_SPI(2) + #define TFT_SPI_DEVICE 2 + #define LPC_SSPx LPC_SSP1 +#else + #error "Invalid TFT SPI configuration." +#endif +#undef IS_SPI + #ifndef LCD_READ_ID #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341) #endif @@ -34,17 +46,19 @@ #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341) #endif -#define DATASIZE_8BIT SSP_DATABIT_8 -#define DATASIZE_16BIT SSP_DATABIT_16 -#define TFT_IO_DRIVER TFT_SPI +#define DATASIZE_8BIT SSP_DATABIT_8 +#define DATASIZE_16BIT SSP_DATABIT_16 +#define TFT_IO_DRIVER TFT_SPI +#define DMA_MAX_SIZE 0xFFF -#define DMA_MINC_ENABLE 1 -#define DMA_MINC_DISABLE 0 +#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 Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: @@ -56,22 +70,20 @@ class TFT_SPI { static void Abort(); static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT); - static void DataTransferEnd() { OUT_WRITE(TFT_CS_PIN, HIGH); SPIx.end(); }; + static void DataTransferEnd() { WRITE(TFT_CS_PIN, HIGH); SSP_Cmd(LPC_SSPx, DISABLE); }; static void DataTransferAbort(); static void WriteData(uint16_t Data) { Transmit(Data); } - static void WriteReg(uint16_t Reg) { OUT_WRITE(TFT_A0_PIN, LOW); Transmit(Reg); OUT_WRITE(TFT_A0_PIN, HIGH); } + static void WriteReg(uint16_t Reg) { WRITE(TFT_DC_PIN, LOW); Transmit(Reg); WRITE(TFT_DC_PIN, HIGH); } + + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } - // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_MINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; - //LPC dma can only write 0xFFF bytes at once. - #define MAX_DMA_SIZE (0xFFF - 1) while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > MAX_DMA_SIZE ? MAX_DMA_SIZE : Count); - Count = Count > MAX_DMA_SIZE ? Count - MAX_DMA_SIZE : 0; + Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } - #undef MAX_DMA_SIZE } }; diff --git a/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp b/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp index 9c1e158981da..68a2176f5ed6 100644 --- a/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp +++ b/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp @@ -44,9 +44,11 @@ uint16_t delta(uint16_t a, uint16_t b) { return a > b ? a - b : b - a; } #endif void XPT2046::Init() { - SET_INPUT(TOUCH_MISO_PIN); - SET_OUTPUT(TOUCH_MOSI_PIN); - SET_OUTPUT(TOUCH_SCK_PIN); + #if DISABLED(TOUCH_BUTTONS_HW_SPI) + SET_INPUT(TOUCH_MISO_PIN); + SET_OUTPUT(TOUCH_MOSI_PIN); + SET_OUTPUT(TOUCH_SCK_PIN); + #endif OUT_WRITE(TOUCH_CS_PIN, HIGH); #if PIN_EXISTS(TOUCH_INT) diff --git a/Marlin/src/HAL/LPC1768/upload_extra_script.py b/Marlin/src/HAL/LPC1768/upload_extra_script.py index 3e23c63ca19e..efd46fdd6309 100644 --- a/Marlin/src/HAL/LPC1768/upload_extra_script.py +++ b/Marlin/src/HAL/LPC1768/upload_extra_script.py @@ -9,127 +9,127 @@ import pioutil if pioutil.is_pio_build(): - target_filename = "FIRMWARE.CUR" - target_drive = "REARM" + target_filename = "FIRMWARE.CUR" + target_drive = "REARM" - import platform + import platform - current_OS = platform.system() - Import("env") + current_OS = platform.system() + Import("env") - def print_error(e): - print('\nUnable to find destination disk (%s)\n' \ - 'Please select it in platformio.ini using the upload_port keyword ' \ - '(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \ - 'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \ - %(e, env.get('PIOENV'))) + def print_error(e): + print('\nUnable to find destination disk (%s)\n' \ + 'Please select it in platformio.ini using the upload_port keyword ' \ + '(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \ + 'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \ + %(e, env.get('PIOENV'))) - def before_upload(source, target, env): - try: - from pathlib import Path - # - # Find a disk for upload - # - upload_disk = 'Disk not found' - target_file_found = False - target_drive_found = False - if current_OS == 'Windows': - # - # platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:' - # Windows - doesn't care about the disk's name, only cares about the drive letter - import subprocess,string - from ctypes import windll - from pathlib import PureWindowsPath + def before_upload(source, target, env): + try: + from pathlib import Path + # + # Find a disk for upload + # + upload_disk = 'Disk not found' + target_file_found = False + target_drive_found = False + if current_OS == 'Windows': + # + # platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:' + # Windows - doesn't care about the disk's name, only cares about the drive letter + import subprocess,string + from ctypes import windll + from pathlib import PureWindowsPath - # getting list of drives - # https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python - drives = [] - bitmask = windll.kernel32.GetLogicalDrives() - for letter in string.ascii_uppercase: - if bitmask & 1: - drives.append(letter) - bitmask >>= 1 + # getting list of drives + # https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python + drives = [] + bitmask = windll.kernel32.GetLogicalDrives() + for letter in string.ascii_uppercase: + if bitmask & 1: + drives.append(letter) + bitmask >>= 1 - for drive in drives: - final_drive_name = drive + ':' - # print ('disc check: {}'.format(final_drive_name)) - try: - volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)) - except Exception as e: - print ('error:{}'.format(e)) - continue - else: - if target_drive in volume_info and not target_file_found: # set upload if not found target file yet - target_drive_found = True - upload_disk = PureWindowsPath(final_drive_name) - if target_filename in volume_info: - if not target_file_found: - upload_disk = PureWindowsPath(final_drive_name) - target_file_found = True + for drive in drives: + final_drive_name = drive + ':' + # print ('disc check: {}'.format(final_drive_name)) + try: + volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)) + except Exception as e: + print ('error:{}'.format(e)) + continue + else: + if target_drive in volume_info and not target_file_found: # set upload if not found target file yet + target_drive_found = True + upload_disk = PureWindowsPath(final_drive_name) + if target_filename in volume_info: + if not target_file_found: + upload_disk = PureWindowsPath(final_drive_name) + target_file_found = True - elif current_OS == 'Linux': - # - # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive' - # - import getpass - user = getpass.getuser() - mpath = Path('media', user) - drives = [ x for x in mpath.iterdir() if x.is_dir() ] - if target_drive in drives: # If target drive is found, use it. - target_drive_found = True - upload_disk = mpath / target_drive - else: - for drive in drives: - try: - fpath = mpath / drive - files = [ x for x in fpath.iterdir() if x.is_file() ] - except: - continue - else: - if target_filename in files: - upload_disk = mpath / drive - target_file_found = True - break - # - # set upload_port to drive if found - # + elif current_OS == 'Linux': + # + # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive' + # + import getpass + user = getpass.getuser() + mpath = Path('/media', user) + drives = [ x for x in mpath.iterdir() if x.is_dir() ] + if target_drive in drives: # If target drive is found, use it. + target_drive_found = True + upload_disk = mpath / target_drive + else: + for drive in drives: + try: + fpath = mpath / drive + filenames = [ x.name for x in fpath.iterdir() if x.is_file() ] + except: + continue + else: + if target_filename in filenames: + upload_disk = mpath / drive + target_file_found = True + break + # + # set upload_port to drive if found + # - if target_file_found or target_drive_found: - env.Replace( - UPLOAD_FLAGS="-P$UPLOAD_PORT" - ) + if target_file_found or target_drive_found: + env.Replace( + UPLOAD_FLAGS="-P$UPLOAD_PORT" + ) - elif current_OS == 'Darwin': # MAC - # - # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive' - # - dpath = Path('/Volumes') # human readable names - drives = [ x for x in dpath.iterdir() ] - if target_drive in drives and not target_file_found: # set upload if not found target file yet - target_drive_found = True - upload_disk = dpath / target_drive - for drive in drives: - try: - fpath = dpath / drive # will get an error if the drive is protected - files = [ x for x in fpath.iterdir() ] - except: - continue - else: - if target_filename in files: - if not target_file_found: - upload_disk = dpath / drive - target_file_found = True + elif current_OS == 'Darwin': # MAC + # + # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive' + # + dpath = Path('/Volumes') # human readable names + drives = [ x for x in dpath.iterdir() if x.is_dir() ] + if target_drive in drives and not target_file_found: # set upload if not found target file yet + target_drive_found = True + upload_disk = dpath / target_drive + for drive in drives: + try: + fpath = dpath / drive # will get an error if the drive is protected + filenames = [ x.name for x in fpath.iterdir() if x.is_file() ] + except: + continue + else: + if target_filename in filenames: + upload_disk = dpath / drive + target_file_found = True + break - # - # Set upload_port to drive if found - # - if target_file_found or target_drive_found: - env.Replace(UPLOAD_PORT=str(upload_disk)) - print('\nUpload disk: ', upload_disk, '\n') - else: - print_error('Autodetect Error') + # + # Set upload_port to drive if found + # + if target_file_found or target_drive_found: + env.Replace(UPLOAD_PORT=str(upload_disk)) + print('\nUpload disk: ', upload_disk, '\n') + else: + print_error('Autodetect Error') - except Exception as e: - print_error(str(e)) + except Exception as e: + print_error(str(e)) - env.AddPreAction("upload", before_upload) + env.AddPreAction("upload", before_upload) diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index 66203611447f..52e5eb4f3997 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -208,8 +208,8 @@ class MarlinHAL { MarlinHAL() {} // Watchdog - static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); - static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_init(); + static void watchdog_refresh(); static void init() {} // Called early in setup() static void init_board() {} // Called less early in setup() diff --git a/Marlin/src/HAL/NATIVE_SIM/fastio.h b/Marlin/src/HAL/NATIVE_SIM/fastio.h index de8013b1e542..f501afdbaa4e 100644 --- a/Marlin/src/HAL/NATIVE_SIM/fastio.h +++ b/Marlin/src/HAL/NATIVE_SIM/fastio.h @@ -44,7 +44,7 @@ * * 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 + * Why double up on these macros? see https://gcc.gnu.org/onlinedocs/cpp/Stringification.html */ /// Read a pin diff --git a/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h index b131853643a8..4e999f88ff98 100644 --- a/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h +++ b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h @@ -51,7 +51,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/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp index c384cdd75185..a3254774bfdf 100644 --- 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 @@ -168,4 +168,4 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void #endif #endif // IS_U8GLIB_ST7920 -#endif // TARGET_LPC1768 +#endif // __PLAT_NATIVE_SIM__ diff --git a/Marlin/src/HAL/SAMD21/HAL.cpp b/Marlin/src/HAL/SAMD21/HAL.cpp new file mode 100644 index 000000000000..14c439eeb911 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/HAL.cpp @@ -0,0 +1,212 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#include + +#if USING_HW_SERIALUSB + DefaultSerial1 MSerialUSB(false, SerialUSB); +#endif +#if USING_HW_SERIAL0 + DefaultSerial2 MSerial1(false, Serial1); +#endif +#if USING_HW_SERIAL1 + DefaultSerial3 MSerial2(false, Serial2); +#endif + + + +#define WDT_CONFIG_PER_7_Val 0x9u +#define WDT_CONFIG_PER_Pos 0 +#define WDT_CONFIG_PER_7 (WDT_CONFIG_PER_7_Val << WDT_CONFIG_PER_Pos) + +#if ENABLED(USE_WATCHDOG) + + #define WDT_TIMEOUT_REG TERN(WATCHDOG_DURATION_8S, WDT_CONFIG_PER_CYC8192, WDT_CONFIG_PER_CYC4096) // 4 or 8 second timeout + + void MarlinHAL::watchdog_init() { + // Set up the generic clock (GCLK2) used to clock the watchdog timer at 1.024kHz + GCLK->GENDIV.reg = GCLK_GENDIV_DIV(4) | // Divide the 32.768kHz clock source by divisor 32, where 2^(4 + 1): 32.768kHz/32=1.024kHz + GCLK_GENDIV_ID(2); // Select Generic Clock (GCLK) 2 + while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization + + REG_GCLK_GENCTRL = GCLK_GENCTRL_DIVSEL | // Set to divide by 2^(GCLK_GENDIV_DIV(4) + 1) + GCLK_GENCTRL_IDC | // Set the duty cycle to 50/50 HIGH/LOW + GCLK_GENCTRL_GENEN | // Enable GCLK2 + GCLK_GENCTRL_SRC_OSCULP32K | // Set the clock source to the ultra low power oscillator (OSCULP32K) + GCLK_GENCTRL_ID(2); // Select GCLK2 + while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization + + // Feed GCLK2 to WDT (Watchdog Timer) + REG_GCLK_CLKCTRL = GCLK_CLKCTRL_CLKEN | // Enable GCLK2 to the WDT + GCLK_CLKCTRL_GEN_GCLK2 | // Select GCLK2 + GCLK_CLKCTRL_ID_WDT; // Feed the GCLK2 to the WDT + while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization + + WDT->CONFIG.bit.PER = WDT_CONFIG_PER_7; // Set the WDT reset timeout to 4 seconds + while (WDT->STATUS.bit.SYNCBUSY); // Wait for synchronization + REG_WDT_CTRL = WDT_CTRL_ENABLE; // Enable the WDT in normal mode + while (WDT->STATUS.bit.SYNCBUSY); // Wait for synchronization + } + + // Reset watchdog. MUST be called at least every 4 seconds after the + // first watchdog_init or SAMD will go into emergency procedures. + void MarlinHAL::watchdog_refresh() { + WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY; + while (WDT->STATUS.bit.SYNCBUSY); + } + +#endif + +// ------------------------ +// Types +// ------------------------ + +// ------------------------ +// Private Variables +// ------------------------ + +// ------------------------ +// Private functions +// ------------------------ + +void MarlinHAL::dma_init() {} + +// ------------------------ +// Public functions +// ------------------------ + +// HAL initialization task +void MarlinHAL::init() { + TERN_(DMA_IS_REQUIRED, dma_init()); + #if ENABLED(SDSUPPORT) + #if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD) + SET_INPUT_PULLUP(SD_DETECT_PIN); + #endif + OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up + #endif +} + +#pragma push_macro("WDT") +#undef WDT // Required to be able to use '.bit.WDT'. Compiler wrongly replace struct field with WDT define +uint8_t MarlinHAL::get_reset_source() { + + return 0; +} +#pragma pop_macro("WDT") + +void MarlinHAL::reboot() { NVIC_SystemReset(); } + +extern "C" { + void * _sbrk(int incr); + extern unsigned int __bss_end__; // end of bss section +} + +// Return free memory between end of heap (or end bss) and whatever is current +int freeMemory() { + int free_memory, heap_end = (int)_sbrk(0); + return (int)&free_memory - (heap_end ?: (int)&__bss_end__); +} + +// ------------------------ +// ADC +// ------------------------ + +uint16_t MarlinHAL::adc_result; + +void MarlinHAL::adc_init() { + /* thanks to https://www.eevblog.com/forum/microcontrollers/samd21g18-adc-with-resrdy-interrupts-only-reads-once-or-twice/ */ + + ADC->CTRLA.bit.ENABLE = false; + while(ADC->STATUS.bit.SYNCBUSY); + + // load chip corrections + uint32_t bias = (*((uint32_t *) ADC_FUSES_BIASCAL_ADDR) & ADC_FUSES_BIASCAL_Msk) >> ADC_FUSES_BIASCAL_Pos; + uint32_t linearity = (*((uint32_t *) ADC_FUSES_LINEARITY_0_ADDR) & ADC_FUSES_LINEARITY_0_Msk) >> ADC_FUSES_LINEARITY_0_Pos; + linearity |= ((*((uint32_t *) ADC_FUSES_LINEARITY_1_ADDR) & ADC_FUSES_LINEARITY_1_Msk) >> ADC_FUSES_LINEARITY_1_Pos) << 5; + + /* Wait for bus synchronization. */ + while (ADC->STATUS.bit.SYNCBUSY) {}; + + ADC->CALIB.reg = ADC_CALIB_BIAS_CAL(bias) | ADC_CALIB_LINEARITY_CAL(linearity); + + /* Wait for bus synchronization. */ + while (ADC->STATUS.bit.SYNCBUSY) {}; + + ADC->CTRLA.bit.SWRST = true; + while(ADC->STATUS.bit.SYNCBUSY); + + ADC->REFCTRL.reg = ADC_REFCTRL_REFSEL_INTVCC1; + ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_32| ADC_AVGCTRL_ADJRES(4);; + + + ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV128 | + ADC_CTRLB_RESSEL_16BIT | + ADC_CTRLB_FREERUN; + while(ADC->STATUS.bit.SYNCBUSY); + + ADC->SAMPCTRL.bit.SAMPLEN = 0x00; + while(ADC->STATUS.bit.SYNCBUSY); + + ADC->INPUTCTRL.reg = ADC_INPUTCTRL_INPUTSCAN(HAL_ADC_AIN_LEN) // scan (INPUTSCAN + NUM_EXTUDERS - 1) pins + | ADC_INPUTCTRL_GAIN_DIV2 |ADC_INPUTCTRL_MUXNEG_GND| HAL_ADC_AIN_START ; /* set to first AIN */ + + while(ADC->STATUS.bit.SYNCBUSY); + + ADC->INTENSET.reg |= ADC_INTENSET_RESRDY; // enable Result Ready ADC interrupts + while (ADC->STATUS.bit.SYNCBUSY); + + NVIC_EnableIRQ(ADC_IRQn); // enable ADC interrupts + + NVIC_SetPriority(ADC_IRQn, 3); + + ADC->CTRLA.bit.ENABLE = true; +} + +volatile uint32_t adc_results[HAL_ADC_AIN_NUM_SENSORS]; + +void ADC_Handler() { + while(ADC->STATUS.bit.SYNCBUSY == 1); + int pos = ADC->INPUTCTRL.bit.INPUTOFFSET; + + adc_results[pos] = ADC->RESULT.reg; /* Read the value. */ + ADC->INTFLAG.reg = ADC_INTENSET_RESRDY; /* Clear the data ready flag. */ +} + +void MarlinHAL::adc_start(const pin_t pin) { + /* due to the way INPUTOFFSET works, the last sensor is the first position in the array + and we want the ADC_handler interrupt to be as simple possible, so we do the calculation here. + */ + unsigned int pos = PIN_TO_INPUTCTRL(pin) - HAL_ADC_AIN_START + 1; + if (pos == HAL_ADC_AIN_NUM_SENSORS) pos = 0; + adc_result = adc_results[pos]; // 16-bit resolution + //adc_result = 0xFFFF; +} + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/HAL.h b/Marlin/src/HAL/SAMD21/HAL.h new file mode 100644 index 000000000000..1854e523ed62 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/HAL.h @@ -0,0 +1,223 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#define CPU_32_BIT + +#include "../shared/Marduino.h" +#include "../shared/math_32bit.h" +#include "../shared/HAL_SPI.h" +#include "fastio.h" + +// ------------------------ +// Serial ports +// ------------------------ +#include "../../core/serial_hook.h" +typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1; +extern DefaultSerial1 MSerialUSB; + +// Serial ports +typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2; +typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3; + +extern DefaultSerial2 MSerial0; +extern DefaultSerial3 MSerial1; + + +#define __MSERIAL(X) MSerial##X +#define _MSERIAL(X) __MSERIAL(X) +#define MSERIAL(X) _MSERIAL(INCREMENT(X)) + +#if WITHIN(SERIAL_PORT, 0, 1) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) +#elif SERIAL_PORT == -1 + #define MYSERIAL1 MSerialUSB +#else + #error "SERIAL_PORT must be -1 (Native USB only)." +#endif + +#ifdef SERIAL_PORT_2 + #if WITHIN(SERIAL_PORT_2, 0, 1) + #define MYSERIAL2 MSERIAL(SERIAL_PORT) + #elif SERIAL_PORT_2 == -1 + #define MYSERIAL2 MSerialUSB + #else + #error "SERIAL_PORT_2 must be -1 (Native USB only)." + #endif +#endif + +#ifdef MMU2_SERIAL_PORT + #if WITHIN(MMU2_SERIAL_PORT, 0, 1) + #define MMU2_SERIAL MSERIAL(SERIAL_PORT) + #elif MMU2_SERIAL_PORT == -1 + #define MMU2_SERIAL MSerialUSB + #else + #error "MMU2_SERIAL_PORT must be -1 (Native USB only)." + #endif +#endif + +#ifdef LCD_SERIAL_PORT + #if WITHIN(LCD_SERIAL_PORT, 0, 1) + #define LCD_SERIAL MSERIAL(SERIAL_PORT) + #elif LCD_SERIAL_PORT == -1 + #define LCD_SERIAL MSerialUSB + #else + #error "LCD_SERIAL_PORT must be -1 (Native USB only)." + #endif +#endif + +typedef int8_t pin_t; + +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; + +// +// Interrupts +// +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() + +#define cli() __disable_irq() // Disable interrupts +#define sei() __enable_irq() // Enable interrupts + +// +// ADC +// + +#define HAL_ADC_FILTERED 1 // Disable Marlin's oversampling. The HAL filters ADC values. +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 12 +#define HAL_ADC_AIN_START ADC_INPUTCTRL_MUXPOS_PIN3 +#define HAL_ADC_AIN_NUM_SENSORS 3 +#define HAL_ADC_AIN_LEN HAL_ADC_AIN_NUM_SENSORS-1 + +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + +// +// Tone +// +void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); +void noTone(const pin_t _pin); + +// ------------------------ +// Class Utilities +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +#ifdef __cplusplus + extern "C" { +#endif + +char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s); + +extern "C" int freeMemory(); + +#ifdef __cplusplus + } +#endif + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + // Watchdog + static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); + + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } + + static void delay_ms(const int ms) { delay(ms); } + + // Tasks, called from idle() + static void idletask() {} + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch) {} + + // Begin ADC sampling on the given pin. Called from Temperature::isr! + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +private: + static void dma_init(); +}; diff --git a/Marlin/src/HAL/SAMD21/HAL_SPI.cpp b/Marlin/src/HAL/SAMD21/HAL_SPI.cpp new file mode 100644 index 000000000000..0fc530cdb231 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/HAL_SPI.cpp @@ -0,0 +1,148 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Hardware and software SPI implementations are included in this file. + * + * Control of the slave select pin(s) is handled by the calling routines and + * SAMD21 let hardware SPI handling to remove SS from its logic. + */ + +#ifdef __SAMD21__ + +// -------------------------------------------------------------------------- +// Includes +// -------------------------------------------------------------------------- + +#include "../../inc/MarlinConfig.h" +#include + +// -------------------------------------------------------------------------- +// Public functions +// -------------------------------------------------------------------------- + +#if EITHER(SOFTWARE_SPI, FORCE_SOFT_SPI) + + // ------------------------ + // Software SPI + // ------------------------ + #error "Software SPI not supported for SAMD21. Use Hardware SPI." + +#else // !SOFTWARE_SPI + + static SPISettings spiConfig; + + // ------------------------ + // Hardware SPI + // ------------------------ + void spiBegin() { + spiInit(SPI_HALF_SPEED); + } + + void spiInit(uint8_t spiRate) { + // Use datarates Marlin uses + uint32_t clock; + switch (spiRate) { + case SPI_FULL_SPEED: clock = 8000000; break; + case SPI_HALF_SPEED: clock = 4000000; break; + case SPI_QUARTER_SPEED: clock = 2000000; break; + case SPI_EIGHTH_SPEED: clock = 1000000; break; + case SPI_SIXTEENTH_SPEED: clock = 500000; break; + case SPI_SPEED_5: clock = 250000; break; + case SPI_SPEED_6: clock = 125000; break; + default: clock = 4000000; break; // Default from the SPI library + } + spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0); + SPI.begin(); + } + + /** + * @brief Receives a single byte from the SPI port. + * + * @return Byte received + * + * @details + */ + uint8_t spiRec() { + SPI.beginTransaction(spiConfig); + uint8_t returnByte = SPI.transfer(0xFF); + SPI.endTransaction(); + return returnByte; + } + + /** + * @brief Receives a number of bytes from the SPI port to a buffer + * + * @param buf Pointer to starting address of buffer to write to. + * @param nbyte Number of bytes to receive. + * @return Nothing + */ + void spiRead(uint8_t *buf, uint16_t nbyte) { + if (nbyte == 0) return; + memset(buf, 0xFF, nbyte); + + SPI.beginTransaction(spiConfig); + SPI.transfer(buf, nbyte); + SPI.endTransaction(); + + } + + /** + * @brief Sends a single byte on SPI port + * + * @param b Byte to send + * + * @details + */ + void spiSend(uint8_t b) { + SPI.beginTransaction(spiConfig); + SPI.transfer(b); + SPI.endTransaction(); + } + + /** + * @brief Write token and then write from 512 byte buffer to SPI (for SD card) + * + * @param buf Pointer with buffer start address + * @return Nothing + * + * @details Uses DMA + */ + void spiSendBlock(uint8_t token, const uint8_t *buf) { + SPI.beginTransaction(spiConfig); + SPI.transfer(token); + SPI.transfer((uint8_t*)buf, 512); + SPI.endTransaction(); + } + + void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { + spiConfig = SPISettings(spiClock, (BitOrder)bitOrder, dataMode); + SPI.beginTransaction(spiConfig); + } +#endif // !SOFTWARE_SPI + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/MarlinSPI.h b/Marlin/src/HAL/SAMD21/MarlinSPI.h new file mode 100644 index 000000000000..7b5392793e15 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/MarlinSPI.h @@ -0,0 +1,31 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once + +#include + +using MarlinSPI = SPIClass; diff --git a/Marlin/src/HAL/SAMD21/QSPIFlash.cpp b/Marlin/src/HAL/SAMD21/QSPIFlash.cpp new file mode 100644 index 000000000000..fa54c6207125 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/QSPIFlash.cpp @@ -0,0 +1,82 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#include "../../inc/MarlinConfig.h" + +#if ENABLED(QSPI_EEPROM) + +#include "QSPIFlash.h" + +#define INVALID_ADDR 0xFFFFFFFF +#define SECTOR_OF(a) (a & ~(SFLASH_SECTOR_SIZE - 1)) +#define OFFSET_OF(a) (a & (SFLASH_SECTOR_SIZE - 1)) + +Adafruit_SPIFlashBase * QSPIFlash::_flashBase = nullptr; +uint8_t QSPIFlash::_buf[SFLASH_SECTOR_SIZE]; +uint32_t QSPIFlash::_addr = INVALID_ADDR; + +void QSPIFlash::begin() { + if (_flashBase) return; + + _flashBase = new Adafruit_SPIFlashBase(new Adafruit_FlashTransport_QSPI()); + _flashBase->begin(nullptr); +} + +size_t QSPIFlash::size() { + return _flashBase->size(); +} + +uint8_t QSPIFlash::readByte(const uint32_t address) { + if (SECTOR_OF(address) == _addr) return _buf[OFFSET_OF(address)]; + + return _flashBase->read8(address); +} + +void QSPIFlash::writeByte(const uint32_t address, const uint8_t value) { + uint32_t const sector_addr = SECTOR_OF(address); + + // Page changes, flush old and update new cache + if (sector_addr != _addr) { + flush(); + _addr = sector_addr; + + // read a whole page from flash + _flashBase->readBuffer(sector_addr, _buf, SFLASH_SECTOR_SIZE); + } + + _buf[OFFSET_OF(address)] = value; +} + +void QSPIFlash::flush() { + if (_addr == INVALID_ADDR) return; + + _flashBase->eraseSector(_addr / SFLASH_SECTOR_SIZE); + _flashBase->writeBuffer(_addr, _buf, SFLASH_SECTOR_SIZE); + + _addr = INVALID_ADDR; +} + +#endif // QSPI_EEPROM diff --git a/Marlin/src/HAL/SAMD21/QSPIFlash.h b/Marlin/src/HAL/SAMD21/QSPIFlash.h new file mode 100644 index 000000000000..58822fe05f3e --- /dev/null +++ b/Marlin/src/HAL/SAMD21/QSPIFlash.h @@ -0,0 +1,49 @@ +/** + * @file QSPIFlash.h + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Ha Thach and Dean Miller for Adafruit Industries LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Derived from Adafruit_SPIFlash class with no SdFat references + */ +#pragma once + +#include + +// This class extends Adafruit_SPIFlashBase by adding caching support. +// +// This class will use 4096 Bytes of RAM as a block cache. +class QSPIFlash { + public: + static void begin(); + static size_t size(); + static uint8_t readByte(const uint32_t address); + static void writeByte(const uint32_t address, const uint8_t v); + static void flush(); + + private: + static Adafruit_SPIFlashBase * _flashBase; + static uint8_t _buf[SFLASH_SECTOR_SIZE]; + static uint32_t _addr; +}; + +extern QSPIFlash qspi; diff --git a/Marlin/src/HAL/SAMD21/SAMD21.h b/Marlin/src/HAL/SAMD21/SAMD21.h new file mode 100644 index 000000000000..8e9d17fc5026 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/SAMD21.h @@ -0,0 +1,66 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#define SYNC(sc) while (sc) { \ + asm(""); \ + } + +// Get SAMD port/pin from specified arduino pin +#define GET_SAMD_PORT(P) _GET_SAMD_PORT(PIN_TO_SAMD_PIN(P)) +#define GET_SAMD_PIN(P) _GET_SAMD_PIN(PIN_TO_SAMD_PIN(P)) + +// Get external interrupt line associated to specified arduino pin +#define PIN_TO_EILINE(P) _SAMDPORTPIN_TO_EILINE(GET_SAMD_PORT(P), GET_SAMD_PIN(P)) + +// Get adc/ain associated to specified arduino pin +#define PIN_TO_ADC(P) (ANAPIN_TO_ADCAIN(P) >> 8) + +// Private defines +#define PIN_TO_SAMD_PIN(P) DIO##P##_PIN + +#define _GET_SAMD_PORT(P) ((P) >> 5) +#define _GET_SAMD_PIN(P) ((P) & 0x1F) + +// Get external interrupt line +#define _SAMDPORTPIN_TO_EILINE(P,B) ((P == 0 && WITHIN(B, 0, 31) && B != 26 && B != 28 && B != 29) ? (B) & 0xF \ + : (P == 1 && (WITHIN(B, 0, 25) || WITHIN(B, 30, 31))) ? (B) & 0xF \ + : (P == 1 && WITHIN(B, 26, 29)) ? 12 + (B) - 26 \ + : (P == 2 && (WITHIN(B, 0, 6) || WITHIN(B, 10, 31)) && B != 29) ? (B) & 0xF \ + : (P == 2 && B == 7) ? 9 \ + : (P == 3 && WITHIN(B, 0, 1)) ? (B) \ + : (P == 3 && WITHIN(B, 8, 12)) ? 3 + (B) - 8 \ + : (P == 3 && WITHIN(B, 20, 21)) ? 10 + (B) - 20 \ + : -1) + + + +#define A2_AIN 3 +#define A3_AIN 4 +#define A4_AIN 5 +#define PIN_TO_AIN(P) A##P##_AIN +#define AIN_TO_RESULT(P) ( (P - HAL_ADC_AIN_START == HAL_ADC_AIN_NUM_SENSORS-1) ? 0 : (P - HAL_ADC_AIN_START + 1) ) diff --git a/Marlin/src/HAL/SAMD21/Servo.cpp b/Marlin/src/HAL/SAMD21/Servo.cpp new file mode 100644 index 000000000000..38b995fc9a05 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/Servo.cpp @@ -0,0 +1,220 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * This comes from Arduino library which at the moment is buggy and uncompilable + */ + +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#if HAS_SERVOS + +#include "../shared/servo.h" +#include "../shared/servo_private.h" +#include "SAMD21.h" + +#define __TC_GCLK_ID(t) TC##t##_GCLK_ID +#define _TC_GCLK_ID(t) __TC_GCLK_ID(t) +#define TC_GCLK_ID _TC_GCLK_ID(SERVO_TC) + +#define _TC_PRESCALER(d) TC_CTRLA_PRESCALER_DIV##d##_Val +#define TC_PRESCALER(d) _TC_PRESCALER(d) + +#define __SERVO_IRQn(t) TC##t##_IRQn +#define _SERVO_IRQn(t) __SERVO_IRQn(t) +#define SERVO_IRQn _SERVO_IRQn(SERVO_TC) + +#define HAL_SERVO_TIMER_ISR() TC_HANDLER(SERVO_TC) + +#define TIMER_TCCHANNEL(t) ((t) & 1) +#define TC_COUNTER_START_VAL 0xFFFF + + +static volatile int8_t currentServoIndex[_Nbr_16timers]; // index for the servo being pulsed for each timer (or -1 if refresh interval) + +FORCE_INLINE static uint16_t getTimerCount() { + Tcc * const tc = timer_config[SERVO_TC].pTcc; + + tc->CTRLBSET.reg = TCC_CTRLBCLR_CMD_READSYNC; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + + return tc->COUNT.bit.COUNT; +} + +// ---------------------------- +// Interrupt handler for the TC +// ---------------------------- +HAL_SERVO_TIMER_ISR() { + Tcc * const tc = timer_config[SERVO_TC].pTcc; + const timer16_Sequence_t timer = + #ifndef _useTimer1 + _timer2 + #elif !defined(_useTimer2) + _timer1 + #else + (tc->INTFLAG.reg & tc->INTENSET.reg & TC_INTFLAG_MC0) ? _timer1 : _timer2 + #endif + ; + const uint8_t tcChannel = TIMER_TCCHANNEL(timer); + + int8_t cho = currentServoIndex[timer]; // Handle the prior servo first + if (cho < 0) { // Servo -1 indicates the refresh interval completed... + #if defined(_useTimer1) && defined(_useTimer2) + if (currentServoIndex[timer ^ 1] >= 0) { + // Wait for both channels + // Clear the interrupt + tc->INTFLAG.reg = (tcChannel == 0) ? TC_INTFLAG_MC0 : TC_INTFLAG_MC1; + return; + } + #endif + tc->COUNT.reg = TC_COUNTER_START_VAL; // ...so reset the timer + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + } + else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled? + digitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW + + currentServoIndex[timer] = ++cho; // go to the next channel (or 0) + if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) { + if (SERVO(timer, cho).Pin.isActive) // activated? + digitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH + + tc->CC[tcChannel].reg = getTimerCount() - (uint16_t)SERVO(timer, cho).ticks; + } + else { + // finished all channels so wait for the refresh period to expire before starting over + currentServoIndex[timer] = -1; // reset the timer COUNT.reg on the next call + const uint16_t cval = getTimerCount() - 256 / (SERVO_TIMER_PRESCALER), // allow 256 cycles to ensure the next CV not missed + ival = (TC_COUNTER_START_VAL) - (uint16_t)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed + tc->CC[tcChannel].reg = min(cval, ival); + } + if (tcChannel == 0) { + SYNC(tc->SYNCBUSY.bit.CC0); + tc->INTFLAG.reg = TC_INTFLAG_MC0; // Clear the interrupt + } + else { + SYNC(tc->SYNCBUSY.bit.CC1); + tc->INTFLAG.reg = TC_INTFLAG_MC1; // Clear the interrupt + } +} + +void initISR(const timer16_Sequence_t timer) { + Tcc * const tc = timer_config[SERVO_TC].pTcc; + const uint8_t tcChannel = TIMER_TCCHANNEL(timer); + + static bool initialized = false; // Servo TC has been initialized + if (!initialized) { + NVIC_DisableIRQ(SERVO_IRQn); + + // Disable the timer + tc->CTRLA.bit.ENABLE = false; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + + // Select GCLK0 as timer/counter input clock source + GCLK->CLKCTRL.reg =(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(TCC0_GCLK_ID)); + SYNC (GCLK->STATUS.bit.SYNCBUSY); + + // Reset the timer + tc->CTRLA.bit.SWRST = true; + SYNC(tc->CTRLA.bit.SWRST); + + // Set timer counter mode to 16 bits + tc->CTRLA.reg = TC_CTRLA_MODE_COUNT16; + + // Set timer counter mode as normal PWM + tc->WAVE.bit.WAVEGEN = TCC_WAVE_WAVEGEN_NPWM_Val; + + // Set the prescaler factor + tc->CTRLA.bit.PRESCALER = TC_PRESCALER(SERVO_TIMER_PRESCALER); + + // Count down + tc->CTRLBSET.reg = TCC_CTRLBCLR_DIR; + SYNC(tc->SYNCBUSY.bit.CTRLB); + + // Reset all servo indexes + memset((void *)currentServoIndex, 0xFF, sizeof(currentServoIndex)); + + // Configure interrupt request + NVIC_ClearPendingIRQ(SERVO_IRQn); + NVIC_SetPriority(SERVO_IRQn, 5); + NVIC_EnableIRQ(SERVO_IRQn); + + initialized = true; + } + + if (!tc->CTRLA.bit.ENABLE) { + // Reset the timer counter + tc->COUNT.reg = TC_COUNTER_START_VAL; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + + // Enable the timer and start it + tc->CTRLA.bit.ENABLE = true; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + } + // First interrupt request after 1 ms + tc->CC[tcChannel].reg = getTimerCount() - (uint16_t)usToTicks(1000UL); + + if (tcChannel == 0 ) { + SYNC(tc->SYNCBUSY.bit.CC0); + + // Clear pending match interrupt + tc->INTFLAG.reg = TC_INTENSET_MC0; + // Enable the match channel interrupt request + tc->INTENSET.reg = TC_INTENSET_MC0; + } + else { + SYNC(tc->SYNCBUSY.bit.CC1); + + // Clear pending match interrupt + tc->INTFLAG.reg = TC_INTENSET_MC1; + // Enable the match channel interrupt request + tc->INTENSET.reg = TC_INTENSET_MC1; + } +} + +void finISR(const timer16_Sequence_t timer_index) { + Tcc * const tc = timer_config[SERVO_TC].pTcc; + const uint8_t tcChannel = TIMER_TCCHANNEL(timer_index); + + // Disable the match channel interrupt request + tc->INTENCLR.reg = (tcChannel == 0) ? TC_INTENCLR_MC0 : TC_INTENCLR_MC1; + + if (true + #if defined(_useTimer1) && defined(_useTimer2) + && (tc->INTENCLR.reg & (TC_INTENCLR_MC0|TC_INTENCLR_MC1)) == 0 + #endif + ) { + // Disable the timer if not used + tc->CTRLA.bit.ENABLE = false; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + } +} + +#endif // HAS_SERVOS + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/ServoTimers.h b/Marlin/src/HAL/SAMD21/ServoTimers.h new file mode 100644 index 000000000000..89805476831f --- /dev/null +++ b/Marlin/src/HAL/SAMD21/ServoTimers.h @@ -0,0 +1,45 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#define _useTimer1 +#define _useTimer2 + +#define TRIM_DURATION 5 // compensation ticks to trim adjust for digitalWrite delays +#define SERVO_TIMER_PRESCALER 64 // timer prescaler factor to 64 (avoid overflowing 16-bit clock counter, at 120MHz this is 1831 ticks per millisecond + +#define SERVO_TC 3 + +typedef enum { + #ifdef _useTimer1 + _timer1, + #endif + #ifdef _useTimer2 + _timer2, + #endif + _Nbr_16timers +} timer16_Sequence_t; diff --git a/Marlin/src/HAL/SAMD21/eeprom_flash.cpp b/Marlin/src/HAL/SAMD21/eeprom_flash.cpp new file mode 100644 index 000000000000..4a4e328d1a00 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/eeprom_flash.cpp @@ -0,0 +1,141 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(FLASH_EEPROM_EMULATION) + +#define TOTAL_FLASH_SIZE (MARLIN_EEPROM_SIZE+255)/256*256 + +/* reserve flash memory */ +static const uint8_t flashdata[TOTAL_FLASH_SIZE] __attribute__((__aligned__(256))) { }; \ + +#include "../shared/eeprom_api.h" + +size_t PersistentStore::capacity() { + return MARLIN_EEPROM_SIZE; + /* const uint8_t psz = NVMCTRL->SEESTAT.bit.PSZ, + sblk = NVMCTRL->SEESTAT.bit.SBLK; + + return (!psz && !sblk) ? 0 + : (psz <= 2) ? (0x200 << psz) + : (sblk == 1 || psz == 3) ? 4096 + : (sblk == 2 || psz == 4) ? 8192 + : (sblk <= 4 || psz == 5) ? 16384 + : (sblk >= 9 && psz == 7) ? 65536 + : 32768;*/ +} + +uint32_t PAGE_SIZE; +uint32_t ROW_SIZE; +bool hasWritten = false; +uint8_t * buffer; + +void _erase(const volatile void *flash_ptr) { + NVMCTRL->ADDR.reg = ((uint32_t)flash_ptr) / 2; + NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_ER; + while (!NVMCTRL->INTFLAG.bit.READY) { } + +} + +void erase(const volatile void *flash_ptr, uint32_t size) { + const uint8_t *ptr = (const uint8_t *)flash_ptr; + while (size > ROW_SIZE) { + _erase(ptr); + ptr += ROW_SIZE; + size -= ROW_SIZE; + } + _erase(ptr); +} + +bool PersistentStore::access_start() { + /* clear page buffer*/ + NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC; + while (NVMCTRL->INTFLAG.bit.READY == 0) { } + + PAGE_SIZE = pow(2,3 + NVMCTRL->PARAM.bit.PSZ); + ROW_SIZE= PAGE_SIZE * 4; + /*NVMCTRL->SEECFG.reg = NVMCTRL_SEECFG_WMODE_BUFFERED; // Buffered mode and segment reallocation active + if (NVMCTRL->SEESTAT.bit.RLOCK) + NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_USEE); */ // Unlock E2P data write access + // erase(&flashdata[0], TOTAL_FLASH_SIZE); + return true; +} + +bool PersistentStore::access_finish() { + if (hasWritten) { + erase(&flashdata[0], TOTAL_FLASH_SIZE); + + NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC; + while (NVMCTRL->INTFLAG.bit.READY == 0) { } + + NVMCTRL->CTRLB.bit.MANW = 0; + + volatile uint32_t *dst_addr = (volatile uint32_t *) &flashdata; + + uint32_t *pointer = (uint32_t *) buffer; + for (uint32_t i = 0; i < TOTAL_FLASH_SIZE; i+=4) { + + *dst_addr = (uint32_t) *pointer; + pointer++; + dst_addr ++; + } + + // Execute "WP" Write Page + NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_WP; + while (NVMCTRL->INTFLAG.bit.READY == 0) { } + + free(buffer); + hasWritten = false; + } + return true; +} + +bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + if (!hasWritten) { + // init temp buffer + buffer = (uint8_t *) malloc(MARLIN_EEPROM_SIZE); + hasWritten=true; + } + + memcpy(buffer+pos,value,size); + pos += size; + return false; +} + +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { + volatile uint8_t *dst_addr = (volatile uint8_t *) &flashdata; + dst_addr += pos; + + memcpy(value,(const void *) dst_addr,size); + pos += size; + return false; +} + +#endif // FLASH_EEPROM_EMULATION +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/eeprom_qspi.cpp b/Marlin/src/HAL/SAMD21/eeprom_qspi.cpp new file mode 100644 index 000000000000..587dcb0b1416 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/eeprom_qspi.cpp @@ -0,0 +1,79 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(QSPI_EEPROM) + +#error "QSPI_EEPROM emulation Not implemented on SAMD21" + +#include "../shared/eeprom_api.h" + +#include "QSPIFlash.h" + +static bool initialized; + +size_t PersistentStore::capacity() { return qspi.size(); } + +bool PersistentStore::access_start() { + if (!initialized) { + qspi.begin(); + initialized = true; + } + return true; +} + +bool PersistentStore::access_finish() { + qspi.flush(); + return true; +} + +bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + while (size--) { + const uint8_t v = *value; + qspi.writeByte(pos, v); + crc16(crc, &v, 1); + pos++; + value++; + } + return false; +} + +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { + while (size--) { + uint8_t c = qspi.readByte(pos); + if (writing) *value = c; + crc16(crc, &c, 1); + pos++; + value++; + } + return false; +} + +#endif // QSPI_EEPROM +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/eeprom_wired.cpp b/Marlin/src/HAL/SAMD21/eeprom_wired.cpp new file mode 100644 index 000000000000..ab71e616fc7b --- /dev/null +++ b/Marlin/src/HAL/SAMD21/eeprom_wired.cpp @@ -0,0 +1,82 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#if USE_WIRED_EEPROM + +#error "USE_WIRED_EEPROM emulation Not implemented on SAMD21" +/** + * PersistentStore for Arduino-style EEPROM interface + * with simple implementations supplied by Marlin. + */ + +#include "../shared/eeprom_if.h" +#include "../shared/eeprom_api.h" + +#ifndef MARLIN_EEPROM_SIZE + #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } + +bool PersistentStore::access_start() { eeprom_init(); return true; } +bool PersistentStore::access_finish() { return true; } + +bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; + while (size--) { + const uint8_t v = *value; + uint8_t * const p = (uint8_t * const)pos; + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! + eeprom_write_byte(p, v); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes + if (eeprom_read_byte(p) != v) { + SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); + return true; + } + } + crc16(crc, &v, 1); + pos++; + value++; + } + return false; +} + +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { + while (size--) { + uint8_t c = eeprom_read_byte((uint8_t*)pos); + if (writing) *value = c; + crc16(crc, &c, 1); + pos++; + value++; + } + return false; +} + +#endif // USE_WIRED_EEPROM +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/endstop_interrupts.h b/Marlin/src/HAL/SAMD21/endstop_interrupts.h new file mode 100644 index 000000000000..d8711aa01870 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/endstop_interrupts.h @@ -0,0 +1,253 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Endstop interrupts for ATMEL SAMD21 based targets. + * + * On SAMD21, all pins support external interrupt capability. + * Any pin can be used for external interrupts, but there are some restrictions. + * At most 16 different external interrupts can be used at one time. + * Further, you can’t just pick any 16 pins to use. This is because every pin on the SAMD21 + * connects to what is called an EXTINT line, and only one pin per EXTINT line can be used for external + * interrupts at a time + */ + +/** + * Endstop Interrupts + * + * Without endstop interrupts the endstop pins must be polled continually in + * the temperature-ISR via endstops.update(), most of the time finding no change. + * With this feature endstops.update() is called only when we know that at + * least one endstop has changed state, saving valuable CPU cycles. + * + * This feature only works when all used endstop pins can generate an 'external interrupt'. + * + * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'. + * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino) + */ + +#include "../../module/endstops.h" + +#define MATCH_EILINE(P1,P2) (P1 != P2 && PIN_TO_EILINE(P1) == PIN_TO_EILINE(P2)) +#define MATCH_X_MAX_EILINE(P) TERN0(HAS_X_MAX, DEFER4(MATCH_EILINE)(P, X_MAX_PIN)) +#define MATCH_X_MIN_EILINE(P) TERN0(HAS_X_MIN, DEFER4(MATCH_EILINE)(P, X_MIN_PIN)) +#define MATCH_Y_MAX_EILINE(P) TERN0(HAS_Y_MAX, DEFER4(MATCH_EILINE)(P, Y_MAX_PIN)) +#define MATCH_Y_MIN_EILINE(P) TERN0(HAS_Y_MIN, DEFER4(MATCH_EILINE)(P, Y_MIN_PIN)) +#define MATCH_Z_MAX_EILINE(P) TERN0(HAS_Z_MAX, DEFER4(MATCH_EILINE)(P, Z_MAX_PIN)) +#define MATCH_Z_MIN_EILINE(P) TERN0(HAS_Z_MIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PIN)) +#define MATCH_I_MAX_EILINE(P) TERN0(HAS_I_MAX, DEFER4(MATCH_EILINE)(P, I_MAX_PIN)) +#define MATCH_I_MIN_EILINE(P) TERN0(HAS_I_MIN, DEFER4(MATCH_EILINE)(P, I_MIN_PIN)) +#define MATCH_J_MAX_EILINE(P) TERN0(HAS_J_MAX, DEFER4(MATCH_EILINE)(P, J_MAX_PIN)) +#define MATCH_J_MIN_EILINE(P) TERN0(HAS_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN)) +#define MATCH_K_MAX_EILINE(P) TERN0(HAS_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN)) +#define MATCH_K_MIN_EILINE(P) TERN0(HAS_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN)) +#define MATCH_U_MAX_EILINE(P) TERN0(HAS_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN)) +#define MATCH_U_MIN_EILINE(P) TERN0(HAS_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN)) +#define MATCH_V_MAX_EILINE(P) TERN0(HAS_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN)) +#define MATCH_V_MIN_EILINE(P) TERN0(HAS_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN)) +#define MATCH_W_MAX_EILINE(P) TERN0(HAS_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN)) +#define MATCH_W_MIN_EILINE(P) TERN0(HAS_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN)) +#define MATCH_Z2_MAX_EILINE(P) TERN0(HAS_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN)) +#define MATCH_Z2_MIN_EILINE(P) TERN0(HAS_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN)) +#define MATCH_Z3_MAX_EILINE(P) TERN0(HAS_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN)) +#define MATCH_Z3_MIN_EILINE(P) TERN0(HAS_Z3_MIN, DEFER4(MATCH_EILINE)(P, Z3_MIN_PIN)) +#define MATCH_Z4_MAX_EILINE(P) TERN0(HAS_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN)) +#define MATCH_Z4_MIN_EILINE(P) TERN0(HAS_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN)) +#define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(HAS_Z_MIN_PROBE_PIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN)) + +#define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \ + && !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \ + && !MATCH_Y_MAX_EILINE(P) && !MATCH_Y_MIN_EILINE(P) \ + && !MATCH_Z_MAX_EILINE(P) && !MATCH_Z_MIN_EILINE(P) \ + && !MATCH_I_MAX_EILINE(P) && !MATCH_I_MIN_EILINE(P) \ + && !MATCH_J_MAX_EILINE(P) && !MATCH_J_MIN_EILINE(P) \ + && !MATCH_K_MAX_EILINE(P) && !MATCH_K_MIN_EILINE(P) \ + && !MATCH_U_MAX_EILINE(P) && !MATCH_U_MIN_EILINE(P) \ + && !MATCH_V_MAX_EILINE(P) && !MATCH_V_MIN_EILINE(P) \ + && !MATCH_W_MAX_EILINE(P) && !MATCH_W_MIN_EILINE(P) \ + && !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \ + && !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \ + && !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \ + && !MATCH_Z_MIN_PROBE_EILINE(P) ) + +// One ISR for all EXT-Interrupts +void endstop_ISR() { endstops.update(); } + +void setup_endstop_interrupts() { + #define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE) + #if HAS_X_MAX + #if !AVAILABLE_EILINE(X_MAX_PIN) + #error "X_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(X_MAX_PIN); + #endif + #if HAS_X_MIN + #if !AVAILABLE_EILINE(X_MIN_PIN) + #error "X_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(X_MIN_PIN); + #endif + #if HAS_Y_MAX + #if !AVAILABLE_EILINE(Y_MAX_PIN) + #error "Y_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Y_MAX_PIN); + #endif + #if HAS_Y_MIN + #if !AVAILABLE_EILINE(Y_MIN_PIN) + #error "Y_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Y_MIN_PIN); + #endif + #if HAS_Z_MAX + #if !AVAILABLE_EILINE(Z_MAX_PIN) + #error "Z_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Z_MAX_PIN); + #endif + #if HAS_Z_MIN + #if !AVAILABLE_EILINE(Z_MIN_PIN) + #error "Z_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Z_MIN_PIN); + #endif + #if HAS_Z2_MAX + #if !AVAILABLE_EILINE(Z2_MAX_PIN) + #error "Z2_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Z2_MAX_PIN); + #endif + #if HAS_Z2_MIN + #if !AVAILABLE_EILINE(Z2_MIN_PIN) + #error "Z2_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Z2_MIN_PIN); + #endif + #if HAS_Z3_MAX + #if !AVAILABLE_EILINE(Z3_MAX_PIN) + #error "Z3_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Z3_MAX_PIN); + #endif + #if HAS_Z3_MIN + #if !AVAILABLE_EILINE(Z3_MIN_PIN) + #error "Z3_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Z3_MIN_PIN); + #endif + #if HAS_Z4_MAX + #if !AVAILABLE_EILINE(Z4_MAX_PIN) + #error "Z4_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Z4_MAX_PIN); + #endif + #if HAS_Z4_MIN + #if !AVAILABLE_EILINE(Z4_MIN_PIN) + #error "Z4_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Z4_MIN_PIN); + #endif + #if HAS_Z_MIN_PROBE_PIN + #if !AVAILABLE_EILINE(Z_MIN_PROBE_PIN) + #error "Z_MIN_PROBE_PIN has no EXTINT line available." + #endif + _ATTACH(Z_MIN_PROBE_PIN); + #endif + #if HAS_I_MAX + #if !AVAILABLE_EILINE(I_MAX_PIN) + #error "I_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(I_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_I_MIN + #if !AVAILABLE_EILINE(I_MIN_PIN) + #error "I_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(I_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_J_MAX + #if !AVAILABLE_EILINE(J_MAX_PIN) + #error "J_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(J_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_J_MIN + #if !AVAILABLE_EILINE(J_MIN_PIN) + #error "J_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(J_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_K_MAX + #if !AVAILABLE_EILINE(K_MAX_PIN) + #error "K_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(K_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_K_MIN + #if !AVAILABLE_EILINE(K_MIN_PIN) + #error "K_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(K_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_U_MAX + #if !AVAILABLE_EILINE(U_MAX_PIN) + #error "U_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(U_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_U_MIN + #if !AVAILABLE_EILINE(U_MIN_PIN) + #error "U_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(U_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_V_MAX + #if !AVAILABLE_EILINE(V_MAX_PIN) + #error "V_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(V_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_V_MIN + #if !AVAILABLE_EILINE(V_MIN_PIN) + #error "V_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(V_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_W_MAX + #if !AVAILABLE_EILINE(W_MAX_PIN) + #error "W_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(W_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_W_MIN + #if !AVAILABLE_EILINE(W_MIN_PIN) + #error "W_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(W_MIN_PIN, endstop_ISR, CHANGE); + #endif +} diff --git a/Marlin/src/HAL/SAMD21/fastio.h b/Marlin/src/HAL/SAMD21/fastio.h new file mode 100644 index 000000000000..db64f2166fa4 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/fastio.h @@ -0,0 +1,216 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Fast IO functions for SAMD21 + */ + +#include "SAMD21.h" + +/** + * Utility functions + */ + +#ifndef MASK + #define MASK(PIN) _BV(PIN) +#endif + +/** + * Magic I/O routines + * + * Now you can simply SET_OUTPUT(IO); WRITE(IO, HIGH); WRITE(IO, LOW); + */ + +// Read a pin +#define READ(IO) ((PORT->Group[(EPortType)GET_SAMD_PORT(IO)].IN.reg & MASK(GET_SAMD_PIN(IO))) != 0) + +// Write to a pin +#define WRITE(IO,V) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t mask = MASK(GET_SAMD_PIN(IO)); \ + \ + if (V) PORT->Group[port].OUTSET.reg = mask; \ + else PORT->Group[port].OUTCLR.reg = mask; \ + }while(0) + +// Toggle a pin +#define TOGGLE(IO) PORT->Group[(EPortType)GET_SAMD_PORT(IO)].OUTTGL.reg = MASK(GET_SAMD_PIN(IO)); + +// Set pin as input +#define SET_INPUT(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + \ + PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN); \ + PORT->Group[port].DIRCLR.reg = MASK(pin); \ + }while(0) +// Set pin as input with pullup +#define SET_INPUT_PULLUP(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + const uint32_t mask = MASK(pin); \ + \ + PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); \ + PORT->Group[port].DIRCLR.reg = mask; \ + PORT->Group[port].OUTSET.reg = mask; \ + }while(0) +// Set pin as input with pulldown +#define SET_INPUT_PULLDOWN(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + const uint32_t mask = MASK(pin); \ + \ + PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); \ + PORT->Group[port].DIRCLR.reg = mask; \ + PORT->Group[port].OUTCLR.reg = mask; \ + }while(0) +// Set pin as output (push pull) +#define SET_OUTPUT(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + \ + PORT->Group[port].DIRSET.reg = MASK(pin); \ + PORT->Group[port].PINCFG[pin].reg = 0; \ + }while(0) +// Set pin as output (open drain) +#define SET_OUTPUT_OD(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + \ + PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_PULLEN); \ + PORT->Group[port].DIRCLR.reg = MASK(pin); \ + }while(0) +// Set pin as PWM (push pull) +#define SET_PWM SET_OUTPUT +// Set pin as PWM (open drain) +#define SET_PWM_OD SET_OUTPUT_OD + +// check if pin is an output +#define IS_OUTPUT(IO) ((PORT->Group[(EPortType)GET_SAMD_PORT(IO)].DIR.reg & MASK(GET_SAMD_PIN(IO))) \ + || (PORT->Group[(EPortType)GET_SAMD_PORT(IO)].PINCFG[GET_SAMD_PIN(IO)].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN) +// check if pin is an input +#define IS_INPUT(IO) !IS_OUTPUT(IO) + +// Shorthand +#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0) +#define OUT_WRITE_OD(IO,V) do{ SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0) + +// digitalRead/Write wrappers +#define extDigitalRead(IO) digitalRead(IO) +#define extDigitalWrite(IO,V) digitalWrite(IO,V) + +/** + * Ports and functions + * Added as necessary or if I feel like it- not a comprehensive list! + */ + +/* + * Some of these share the same source and so can't be used in the same time + */ +#define PWM_PIN(P) (WITHIN(P, 2, 13) || WITHIN(P, 22, 23) || WITHIN(P, 44, 45) || P == 48) + +// Return fulfilled ADCx->INPUTCTRL.reg +#define PIN_TO_INPUTCTRL(P) ( (P == 0) ? ADC_INPUTCTRL_MUXPOS_PIN0 \ + : ((P) == 1) ? ADC_INPUTCTRL_MUXPOS_PIN1 \ + : ((P) == 2) ? ADC_INPUTCTRL_MUXPOS_PIN3 \ + : ((P) == 3) ? ADC_INPUTCTRL_MUXPOS_PIN4 \ + : ((P) == 4) ? ADC_INPUTCTRL_MUXPOS_PIN5 \ + : ((P) == 5) ? ADC_INPUTCTRL_MUXPOS_PIN5 \ + : ((P) == 6) ? ADC_INPUTCTRL_MUXPOS_PIN6 \ + : ((P) == 7) ? ADC_INPUTCTRL_MUXPOS_PIN7 \ + : ((P) == 8) ? ADC_INPUTCTRL_MUXPOS_PIN8 \ + : ((P) == 9) ? ADC_INPUTCTRL_MUXPOS_PIN9 \ + : ((P) == 10) ? ADC_INPUTCTRL_MUXPOS_PIN10 \ + : ((P) == 11) ? ADC_INPUTCTRL_MUXPOS_PIN11 \ + : ((P) == 12) ? ADC_INPUTCTRL_MUXPOS_PIN12 \ + : ((P) == 13) ? ADC_INPUTCTRL_MUXPOS_PIN13 \ + : ((P) == 14) ? ADC_INPUTCTRL_MUXPOS_PIN14 \ + : ADC_INPUTCTRL_MUXPOS_PIN15) + +#define digitalPinToAnalogInput(P) (WITHIN(P, 67, 74) ? (P) - 67 : WITHIN(P, 54, 61) ? 8 + (P) - 54 : WITHIN(P, 12, 13) ? 16 + (P) - 12 : P == 9 ? 18 : -1) + +/** + * pins + */ + +// PORTA +#define DIO28_PIN PIN_PA02 // A0 +#define DIO56_PIN PIN_PA03 // A13 +#define DIO31_PIN PIN_PA04 // A13 +#define DIO32_PIN PIN_PA05 // A1 +#define DIO8_PIN PIN_PA06 // A14 +#define DIO9_PIN PIN_PA07 // A15 +#define DIO4_PIN PIN_PA08 // A15 +#define DIO3_PIN PIN_PA09 // A15 +#define DIO1_PIN PIN_PA10 +#define DIO0_PIN PIN_PA11 +#define DIO18_PIN PIN_PA12 +#define DIO52_PIN PIN_PA13 +#define DIO2_PIN PIN_PA14 +#define DIO5_PIN PIN_PA15 +#define DIO11_PIN PIN_PA16 +#define DIO13_PIN PIN_PA17 +#define DIO10_PIN PIN_PA18 +#define DIO12_PIN PIN_PA19 +#define DIO6_PIN PIN_PA20 +#define DIO07_PIN PIN_PA21 +#define DIO34_PIN PIN_PA22 +#define DIO35_PIN PIN_PA23 +#define DIO42_PIN PIN_PA24 +#define DIO43_PIN PIN_PA25 + +#define DIO40_PIN PIN_PA27 + +#define DIO26_PIN PIN_PB00 +#define DIO27_PIN PIN_PB01 // A0 +#define DIO33_PIN PIN_PB02 +#define DIO39_PIN PIN_PB03 +#define DIO14_PIN PIN_PB04 +#define DIO15_PIN PIN_PB05 +#define DIO16_PIN PIN_PB06 +#define DIO17_PIN PIN_PB07 +#define DIO29_PIN PIN_PB08 +#define DIO30_PIN PIN_PB09 +#define DIO37_PIN PIN_PB10 +#define DIO38_PIN PIN_PB11 +#define DIO36_PIN PIN_PB12 +#define DIO19_PIN PIN_PB13 +#define DIO20_PIN PIN_PB14 +#define DIO21_PIN PIN_PB15 +#define DIO22_PIN PIN_PB16 +#define DIO23_PIN PIN_PB17 + +#define DIO44_PIN PIN_PB22 +#define DIO45_PIN PIN_PB23 +#define DIO24_PIN PIN_PB30 +#define DIO25_PIN PIN_PB31 + +#define DIO53_PIN PIN_PA21 +#define DIO54_PIN PIN_PA06 +#define DIO55_PIN PIN_PA07 + diff --git a/Marlin/src/HAL/SAMD21/inc/Conditionals_LCD.h b/Marlin/src/HAL/SAMD21/inc/Conditionals_LCD.h new file mode 100644 index 000000000000..ca467937c3ca --- /dev/null +++ b/Marlin/src/HAL/SAMD21/inc/Conditionals_LCD.h @@ -0,0 +1,31 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once + +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for HAL/SAMD21." +#endif diff --git a/Marlin/src/HAL/SAMD21/inc/Conditionals_adv.h b/Marlin/src/HAL/SAMD21/inc/Conditionals_adv.h new file mode 100644 index 000000000000..d6a3c4fe0b91 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/inc/Conditionals_adv.h @@ -0,0 +1,27 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once diff --git a/Marlin/src/HAL/SAMD21/inc/Conditionals_post.h b/Marlin/src/HAL/SAMD21/inc/Conditionals_post.h new file mode 100644 index 000000000000..7315dc12a779 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/inc/Conditionals_post.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once + +#if USE_FALLBACK_EEPROM + #define FLASH_EEPROM_EMULATION +#elif EITHER(I2C_EEPROM, SPI_EEPROM) + #define USE_SHARED_EEPROM 1 +#endif diff --git a/Marlin/src/HAL/SAMD21/inc/SanityCheck.h b/Marlin/src/HAL/SAMD21/inc/SanityCheck.h new file mode 100644 index 000000000000..95fa5e594026 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/inc/SanityCheck.h @@ -0,0 +1,50 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Test SAMD21 specific configuration values for errors at compile-time. + */ + +#if SERVO_TC == MF_TIMER_RTC + #error "Servos can't use RTC timer" +#endif + +#if ENABLED(EMERGENCY_PARSER) + #error "EMERGENCY_PARSER is not yet implemented for SAMD21. Disable EMERGENCY_PARSER to continue." +#endif + +#if ENABLED(SDIO_SUPPORT) + #error "SDIO_SUPPORT is not supported on SAMD21." +#endif + +#if ENABLED(FAST_PWM_FAN) + #error "Features requiring Hardware PWM (FAST_PWM_FAN) are not yet supported on SAMD21." +#endif + +#if ENABLED(POSTMORTEM_DEBUGGING) + #error "POSTMORTEM_DEBUGGING is not yet supported on SAMD21." +#endif diff --git a/Marlin/src/HAL/SAMD21/pinsDebug.h b/Marlin/src/HAL/SAMD21/pinsDebug.h new file mode 100644 index 000000000000..f94315cdf539 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/pinsDebug.h @@ -0,0 +1,160 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#define NUMBER_PINS_TOTAL PINS_COUNT + +#define digitalRead_mod(p) extDigitalRead(p) +#define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); SERIAL_ECHO(buffer); }while (0) +#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 PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) +#define GET_ARRAY_PIN(p) pin_array[p].pin +#define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital +#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL) +#define DIGITAL_PIN_TO_ANALOG_PIN(p) digitalPinToAnalogInput(p) +#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P)!=-1) +#define pwm_status(pin) digitalPinHasPWM(pin) +#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin + +// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities +// uses pin index +#define M43_NEVER_TOUCH(Q) ((Q) >= 75) + +bool GET_PINMODE(int8_t pin) { // 1: output, 0: input + const EPortType samdport = g_APinDescription[pin].ulPort; + const uint32_t samdpin = g_APinDescription[pin].ulPin; + return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN; +} + +void pwm_details(int32_t pin) { + if (pwm_status(pin)) { + //uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative; + //SERIAL_ECHOPGM("PWM = ", duty); + } +} + +/** + * SAMD21 Board pin| PORT | Label + * ----------------+--------+------- + * 0 | PB25 | "RX0" + * 1 | PB24 | "TX0" + * 2 | PC18 | + * 3 | PC19 | + * 4 | PC20 | + * 5 | PC21 | + * 6 | PD20 | + * 7 | PD21 | + * 8 | PB18 | + * 9 | PB2 | + * 10 | PB22 | + * 11 | PB23 | + * 12 | PB0 | "A16" + * 13 | PB1 | LED AMBER "L" / "A17" + * 14 | PB16 | "TX3" + * 15 | PB17 | "RX3" + * 16 | PC22 | "TX2" + * 17 | PC23 | "RX2" + * 18 | PB12 | "TX1" / "A18" + * 19 | PB13 | "RX1" + * 20 | PB20 | "SDA" + * 21 | PB21 | "SCL" + * 22 | PD12 | + * 23 | PA15 | + * 24 | PC17 | + * 25 | PC16 | + * 26 | PA12 | + * 27 | PA13 | + * 28 | PA14 | + * 29 | PB19 | + * 30 | PA23 | + * 31 | PA22 | + * 32 | PA21 | + * 33 | PA20 | + * 34 | PA19 | + * 35 | PA18 | + * 36 | PA17 | + * 37 | PA16 | + * 38 | PB15 | + * 39 | PB14 | + * 40 | PC13 | + * 41 | PC12 | + * 42 | PC15 | + * 43 | PC14 | + * 44 | PC11 | + * 45 | PC10 | + * 46 | PC6 | + * 47 | PC7 | + * 48 | PC4 | + * 49 | PC5 | + * 50 | PD11 | + * 51 | PD8 | + * 52 | PD9 | + * 53 | PD10 | + * 54 | PB5 | "A8" + * 55 | PB6 | "A9" + * 56 | PB7 | "A10" + * 57 | PB8 | "A11" + * 58 | PB9 | "A12" + * 69 | PA4 | "A13" + * 60 | PA6 | "A14" + * 61 | PA7 | "A15" + * 62 | PB17 | + * 63 | PB20 | + * 64 | PD11 | + * 65 | PD8 | + * 66 | PD9 | + * 67 | PA2 | "A0" / "DAC0" + * 68 | PA5 | "A1" / "DAC1" + * 69 | PB3 | "A2" + * 70 | PC0 | "A3" + * 71 | PC1 | "A4" + * 72 | PC2 | "A5" + * 73 | PC3 | "A6" + * 74 | PB4 | "A7" + * 75 | PC31 | LED GREEN "RX" + * 76 | PC30 | LED GREEN "TX" + * 77 | PA27 | USB: Host enable + * 78 | PA24 | USB: D- + * 79 | PA25 | USB: D+ + * 80 | PB29 | SD: MISO + * 81 | PB27 | SD: SCK + * 82 | PB26 | SD: MOSI + * 83 | PB28 | SD: CS + * 84 | PA3 | AREF + * 85 | PA2 | DAC0 (Duplicate) + * 86 | PA5 | DAC1 (Duplicate) + * 87 | PB1 | LED AMBER "L" (Duplicate) + * 88 | PC24 | NeoPixel + * 89 | PB10 | QSPI: SCK + * 90 | PB11 | QSPI: CS + * 91 | PA8 | QSPI: IO0 + * 92 | PA9 | QSPI: IO1 + * 93 | PA10 | QSPI: IO2 + * 94 | PA11 | QSPI: IO3 + * 95 | PB31 | SD: DETECT + */ diff --git a/Marlin/src/HAL/SAMD21/spi_pins.h b/Marlin/src/HAL/SAMD21/spi_pins.h new file mode 100644 index 000000000000..8c25b84dc182 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/spi_pins.h @@ -0,0 +1,54 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * SAMD21 Default SPI Pins + * + * SS SCK MISO MOSI + * +-------------------------+ + * SPI | 53 52 50 51 | + * SPI1 | 83 81 80 82 | + * +-------------------------+ + * Any pin can be used for Chip Select (SD_SS_PIN) + */ +#ifndef SD_SCK_PIN + #define SD_SCK_PIN 38 +#endif +#ifndef SD_MISO_PIN + #define SD_MISO_PIN 36 +#endif +#ifndef SD_MOSI_PIN + #define SD_MOSI_PIN 37 +#endif +#ifndef SDSS + #define SDSS 18 +#endif + +#ifndef SD_SS_PIN + #define SD_SS_PIN SDSS +#endif diff --git a/Marlin/src/HAL/SAMD21/timers.cpp b/Marlin/src/HAL/SAMD21/timers.cpp new file mode 100644 index 000000000000..982eebc54951 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/timers.cpp @@ -0,0 +1,217 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +// -------------------------------------------------------------------------- +// Includes +// -------------------------------------------------------------------------- + +#include "../../inc/MarlinConfig.h" +#include "ServoTimers.h" // for SERVO_TC + +// -------------------------------------------------------------------------- +// Local defines +// -------------------------------------------------------------------------- + +#define NUM_HARDWARE_TIMERS 9 + +// -------------------------------------------------------------------------- +// Private Variables +// -------------------------------------------------------------------------- + +const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = { + { {.pTcc=TCC0}, TimerType::tcc, TCC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2) + { {.pTcc=TCC1}, TimerType::tcc, TCC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers) + { {.pTcc=TCC2}, TimerType::tcc, TCC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5) + { {.pTc=TC3}, TimerType::tc, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (assigned priority 1) + { {.pTc=TC4}, TimerType::tc, TC4_IRQn, TC_PRIORITY(4) }, // 4 - software serial (no interrupts used) + { {.pTc=TC5}, TimerType::tc, TC5_IRQn, TC_PRIORITY(5) }, + { {.pTc=TC6}, TimerType::tc, TC6_IRQn, TC_PRIORITY(6) }, + { {.pTc=TC7}, TimerType::tc, TC7_IRQn, TC_PRIORITY(7) }, + { {.pRtc=RTC}, TimerType::rtc, RTC_IRQn, TC_PRIORITY(8) } // 8 - temperature (assigned priority 6) +}; + +// -------------------------------------------------------------------------- +// Private functions +// -------------------------------------------------------------------------- + +FORCE_INLINE void Disable_Irq(IRQn_Type irq) { + NVIC_DisableIRQ(irq); + + // We NEED memory barriers to ensure Interrupts are actually disabled! + // ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the ) + __DSB(); + __ISB(); +} + +static bool tcIsSyncing(Tc * tc) { + return tc->COUNT32.STATUS.reg & TC_STATUS_SYNCBUSY; +} + +static void tcReset( Tc * tc) { + tc->COUNT32.CTRLA.reg = TC_CTRLA_SWRST; + while (tcIsSyncing(tc)) {} + while (tc->COUNT32.CTRLA.bit.SWRST) {} +} + +// -------------------------------------------------------------------------- +// Public functions +// -------------------------------------------------------------------------- + +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { + IRQn_Type irq = timer_config[timer_num].IRQ_Id; + + // Disable interrupt, just in case it was already enabled + NVIC_DisableIRQ(irq); + NVIC_ClearPendingIRQ(irq); + + if (timer_num == MF_TIMER_RTC) { + + // https://github.com/arduino-libraries/RTCZero + Rtc * const rtc = timer_config[timer_num].pRtc; + PM->APBAMASK.reg |= PM_APBAMASK_RTC; + + GCLK->CLKCTRL.reg = (uint32_t)((GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK4 | (RTC_GCLK_ID << GCLK_CLKCTRL_ID_Pos))); + while (GCLK->STATUS.bit.SYNCBUSY) {} + + GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSCULP32K | GCLK_GENCTRL_ID(4) | GCLK_GENCTRL_DIVSEL ); + while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) {} + + GCLK->GENDIV.reg = GCLK_GENDIV_ID(4); + GCLK->GENDIV.bit.DIV=4; + while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) {} + + // Disable timer interrupt + rtc->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0; + SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY); + + while(rtc->MODE0.STATUS.bit.SYNCBUSY) {} + + // Stop timer, just in case, to be able to reconfigure it + rtc->MODE0.CTRL.reg = + RTC_MODE0_CTRL_MODE_COUNT32 | // Mode 0 = 32-bits counter + RTC_MODE0_CTRL_PRESCALER_DIV1024; // Divisor = 1024 + + while(rtc->MODE0.STATUS.bit.SYNCBUSY) {} + + // Mode, reset counter on match + rtc->MODE0.CTRL.reg = RTC_MODE0_CTRL_MODE_COUNT32 | RTC_MODE0_CTRL_MATCHCLR; + + // Set compare value + rtc->MODE0.COMP[0].reg = (32768 + frequency / 2) / frequency; + SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY); + + // Enable interrupt on compare + rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0; // reset pending interrupt + rtc->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0; // enable compare 0 interrupt + + // And start timer + rtc->MODE0.CTRL.bit.ENABLE = true; + SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY); + + } + else if (timer_config[timer_num].type==TimerType::tcc) { + + Tcc * const tc = timer_config[timer_num].pTcc; + + PM->APBCMASK.reg |= PM_APBCMASK_TCC0; + GCLK->CLKCTRL.reg =(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(TCC0_GCLK_ID)); + SYNC (GCLK->STATUS.bit.SYNCBUSY); + + tc->CTRLA.reg = TCC_CTRLA_SWRST; + SYNC (tc->SYNCBUSY.reg & TCC_SYNCBUSY_SWRST) {} + + SYNC (tc->CTRLA.bit.SWRST); + + tc->CTRLA.reg &= ~(TCC_CTRLA_ENABLE); // disable TC module + + tc->CTRLA.reg |= TCC_WAVE_WAVEGEN_MFRQ; + tc->CTRLA.reg |= TCC_CTRLA_PRESCALER_DIV2; + tc->CC[0].reg = (HAL_TIMER_RATE) / frequency; + tc->INTENSET.reg = TCC_INTFLAG_MC0; + tc->CTRLA.reg |= TCC_CTRLA_ENABLE; + tc->INTFLAG.reg = 0xFF; + SYNC ( tc->STATUS.reg & TC_STATUS_SYNCBUSY); + + } + else { + Tc * const tc = timer_config[timer_num].pTc; + + // Disable timer interrupt + tc->COUNT32.INTENCLR.reg = TC_INTENCLR_OVF; // disable overflow interrupt + + // TCn clock setup + GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TC4_TC5)) ; + SYNC (GCLK->STATUS.bit.SYNCBUSY); + + tcReset(tc); // reset TC + + // Set Timer counter 5 Mode to 16 bits, it will become a 16bit counter ('mode1' in the datasheet) + tc->COUNT32.CTRLA.reg |= TC_CTRLA_MODE_COUNT32; + // Set TC waveform generation mode to 'match frequency' + tc->COUNT32.CTRLA.reg |= TC_CTRLA_WAVEGEN_MFRQ; + //set prescaler + //the clock normally counts at the GCLK_TC frequency, but we can set it to divide that frequency to slow it down + //you can use different prescaler divisons here like TC_CTRLA_PRESCALER_DIV1 to get a different range + tc->COUNT32.CTRLA.reg |= TC_CTRLA_PRESCALER_DIV1 | TC_CTRLA_ENABLE; //it will divide GCLK_TC frequency by 1024 + //set the compare-capture register. + //The counter will count up to this value (it's a 16bit counter so we use uint16_t) + //this is how we fine-tune the frequency, make it count to a lower or higher value + //system clock should be 1MHz (8MHz/8) at Reset by default + tc->COUNT32.CC[0].reg = (uint16_t) (HAL_TIMER_RATE / frequency); + while (tcIsSyncing(tc)) {} + + // Enable the TC interrupt request + tc->COUNT32.INTENSET.bit.MC0 = 1; + while (tcIsSyncing(tc)) {} + } + + NVIC_SetPriority(irq, timer_config[timer_num].priority); + NVIC_EnableIRQ(irq); +} + +void HAL_timer_enable_interrupt(const uint8_t timer_num) { + const IRQn_Type irq = timer_config[timer_num].IRQ_Id; + NVIC_EnableIRQ(irq); +} + +void HAL_timer_disable_interrupt(const uint8_t timer_num) { + const IRQn_Type irq = timer_config[timer_num].IRQ_Id; + Disable_Irq(irq); +} + +// missing from CMSIS: Check if interrupt is enabled or not +static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) { + return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F); +} + +bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { + const IRQn_Type irq = timer_config[timer_num].IRQ_Id; + return NVIC_GetEnabledIRQ(irq); +} + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/timers.h b/Marlin/src/HAL/SAMD21/timers.h new file mode 100644 index 000000000000..303ccbdc505c --- /dev/null +++ b/Marlin/src/HAL/SAMD21/timers.h @@ -0,0 +1,160 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#include + +// -------------------------------------------------------------------------- +// Defines +// -------------------------------------------------------------------------- + +typedef uint32_t hal_timer_t; +#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF + +#define HAL_TIMER_RATE F_CPU // frequency of timers peripherals + +#define MF_TIMER_RTC 8 // This is not a TC but a RTC + +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 4 // Timer Index for Stepper +#endif +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP +#endif +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP MF_TIMER_RTC // Timer Index for Temperature +#endif + +#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 +#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(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) + +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) + +#define TC_PRIORITY(t) ( t == SERVO_TC ? 1 \ + : (t == MF_TIMER_STEP || t == MF_TIMER_PULSE) ? 2 \ + : (t == MF_TIMER_TEMP) ? 6 : 7 ) + +#define _TC_HANDLER(t) void TC##t##_Handler() +#define TC_HANDLER(t) _TC_HANDLER(t) +#ifndef HAL_STEP_TIMER_ISR + #define HAL_STEP_TIMER_ISR() TC_HANDLER(MF_TIMER_STEP) +#endif +#if MF_TIMER_STEP != MF_TIMER_PULSE + #define HAL_PULSE_TIMER_ISR() TC_HANDLER(MF_TIMER_PULSE) +#endif +#if MF_TIMER_TEMP == MF_TIMER_RTC + #define HAL_TEMP_TIMER_ISR() void RTC_Handler() +#else + #define HAL_TEMP_TIMER_ISR() TC_HANDLER(MF_TIMER_TEMP) +#endif + +// -------------------------------------------------------------------------- +// Types +// -------------------------------------------------------------------------- +typedef enum { tcc, tc, rtc } TimerType; + +typedef struct { + union { + Tc *pTc; + Tcc *pTcc; + Rtc *pRtc; + }; + TimerType type; + IRQn_Type IRQ_Id; + uint8_t priority; +} tTimerConfig; + +// -------------------------------------------------------------------------- +// Public Variables +// -------------------------------------------------------------------------- + +extern const tTimerConfig timer_config[]; + +// -------------------------------------------------------------------------- +// Public functions +// -------------------------------------------------------------------------- + +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); + +FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { + // Should never be called with timer MF_TIMER_RTC + Tc * const tc = timer_config[timer_num].pTc; + tc->COUNT32.CC[0].reg = compare; +} + +FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { + // Should never be called with timer MF_TIMER_RTC + Tc * const tc = timer_config[timer_num].pTc; + return (hal_timer_t)tc->COUNT32.CC[0].reg; +} + +FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { + // Should never be called with timer MF_TIMER_RTC + Tc * const tc = timer_config[timer_num].pTc; + tc->COUNT32.READREQ.reg = TC_READREQ_RREQ; + // Request a read synchronization + SYNC (tc->COUNT32.STATUS.bit.SYNCBUSY); + //SYNC(tc->COUNT32.STATUS.bit.SYNCBUSY ); + return tc->COUNT32.COUNT.reg; +} + +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); + +FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { + if (timer_num == MF_TIMER_RTC) { + Rtc * const rtc = timer_config[timer_num].pRtc; + // Clear interrupt flag + rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0| RTC_MODE0_INTFLAG_OVF; + + } + else if (timer_config[timer_num].type == TimerType::tcc){ + Tcc * const tc = timer_config[timer_num].pTcc; + // Clear interrupt flag + tc->INTFLAG.reg = TCC_INTFLAG_OVF; + } + else { + Tc * const tc = timer_config[timer_num].pTc; + // Clear interrupt flag + tc->COUNT32.INTFLAG.bit.MC0 = 1; + } +} + +#define HAL_timer_isr_epilogue(timer_num) diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.cpp b/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.cpp new file mode 100644 index 000000000000..41da7c10fc24 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.cpp @@ -0,0 +1,32 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +// 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 __SAMD21__ + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.h b/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.h new file mode 100644 index 000000000000..d6a3c4fe0b91 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.h @@ -0,0 +1,27 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h b/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h new file mode 100644 index 000000000000..fa98725d2262 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h @@ -0,0 +1,41 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once + +/** + * SAMD21 LCD-specific defines + */ + +// The following are optional depending on the platform. + +// definitions of HAL specific com and device drivers. +uint8_t u8g_com_samd21_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_samd21_st7920_hw_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_HW_SPI u8g_com_samd21_st7920_hw_spi_fn // use SAMD21 specific hardware SPI routine +#define U8G_COM_ST7920_HW_SPI u8g_com_samd21_st7920_hw_spi_fn diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.c b/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.c new file mode 100644 index 000000000000..f9f77825f6e0 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.c @@ -0,0 +1,42 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Low level pin manipulation routines - used by all the drivers. + * + * These are based on the SAMD51 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 __SAMD21__ + +#include + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.h b/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.h new file mode 100644 index 000000000000..92626552b013 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.h @@ -0,0 +1,42 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once + +/** + * Low level pin manipulation routines - used by all the drivers. + * + * These are based on the SAMD51 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. + */ + +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); diff --git a/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp b/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp new file mode 100644 index 000000000000..02dc77229676 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp @@ -0,0 +1,154 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Based on u8g_com_msp430_hw_spi.c + * + * Universal 8bit Graphics Library + * + * Copyright (c) 2012, 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 __SAMD21__ + +#include +#include "SPI.h" + +#include "../../shared/HAL_SPI.h" + +#ifndef LCD_SPI_SPEED + #define LCD_SPI_SPEED SPI_QUARTER_SPEED +#endif + +void u8g_SetPIOutput(u8g_t *u8g, uint8_t pin_index) { + if (u8g->pin_list[pin_index]!= U8G_PIN_NONE) + pinMode(u8g->pin_list[pin_index],OUTPUT); +} + +void u8g_SetPILevel(u8g_t *u8g, uint8_t pin_index, uint8_t level) { + if (u8g->pin_list[pin_index]!= U8G_PIN_NONE) + digitalWrite(u8g->pin_list[pin_index],level); +} + +uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { + + static SPISettings lcdSPIConfig; + + switch (msg) { + case U8G_COM_MSG_STOP: + break; + + case U8G_COM_MSG_INIT: + u8g_SetPIOutput(u8g, U8G_PI_CS); + u8g_SetPIOutput(u8g, U8G_PI_A0); + u8g_SetPIOutput(u8g, U8G_PI_RESET); + + u8g_SetPILevel(u8g, U8G_PI_CS, LOW); + + spiBegin(); + lcdSPIConfig = SPISettings(900000, MSBFIRST, SPI_MODE0); + u8g->pin_list[U8G_PI_A0_STATE] = 0; + 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); + u8g->pin_list[U8G_PI_A0_STATE] = arg_val; + break; + + case U8G_COM_MSG_CHIP_SELECT: // arg_val == 1 means chip selected, but ST7920 is active high, so needs inverting + u8g_SetPILevel(u8g, U8G_PI_CS, arg_val ? HIGH : LOW); + break; + + case U8G_COM_MSG_RESET: + u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); + break; + + case U8G_COM_MSG_WRITE_BYTE: + SPI.beginTransaction(lcdSPIConfig); + + if (u8g->pin_list[U8G_PI_A0_STATE] == 0) { // command + SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2; + } + else if (u8g->pin_list[U8G_PI_A0_STATE] == 1) { // data + SPI.transfer(0x0fa); u8g->pin_list[U8G_PI_A0_STATE] = 2; + } + + SPI.transfer(arg_val & 0x0f0); + SPI.transfer(arg_val << 4); + SPI.endTransaction(); + break; + + case U8G_COM_MSG_WRITE_SEQ: + SPI.beginTransaction(lcdSPIConfig); + + if (u8g->pin_list[U8G_PI_A0_STATE] == 0 ) { // command + SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2; + } + else if (u8g->pin_list[U8G_PI_A0_STATE] == 1) { // data + SPI.transfer(0x0fa); u8g->pin_list[U8G_PI_A0_STATE] = 2; + } + + uint8_t *ptr = (uint8_t*)arg_ptr; + while (arg_val > 0) { + SPI.transfer((*ptr) & 0x0f0); + SPI.transfer((*ptr) << 4); + ptr++; + arg_val--; + } + + SPI.endTransaction(); + break; + } + return 1; +} + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD51/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index bd1c98bfa1d9..8c102b643da8 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index 79ba8021f4fd..fe29d6c7f42d 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #define CPU_32_BIT #include "../shared/Marduino.h" diff --git a/Marlin/src/HAL/SAMD51/HAL_SPI.cpp b/Marlin/src/HAL/SAMD51/HAL_SPI.cpp index 77f4d5ecd513..58fdfe9499a1 100644 --- a/Marlin/src/HAL/SAMD51/HAL_SPI.cpp +++ b/Marlin/src/HAL/SAMD51/HAL_SPI.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -19,6 +20,10 @@ * */ +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + /** * Hardware and software SPI implementations are included in this file. * diff --git a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp index a16ea2f75821..baa7a38503de 100644 --- a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp +++ b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef ADAFRUIT_GRAND_CENTRAL_M4 /** diff --git a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h index ac5a3793983e..1044d9fcd0ef 100644 --- a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h +++ b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #include "../../core/serial_hook.h" typedef Serial1Class UartT; diff --git a/Marlin/src/HAL/SAMD51/SAMD51.h b/Marlin/src/HAL/SAMD51/SAMD51.h index 783956140d58..8cc19d7155c6 100644 --- a/Marlin/src/HAL/SAMD51/SAMD51.h +++ b/Marlin/src/HAL/SAMD51/SAMD51.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #define SYNC(sc) while (sc) { \ asm(""); \ } diff --git a/Marlin/src/HAL/SAMD51/Servo.cpp b/Marlin/src/HAL/SAMD51/Servo.cpp index 665322fe24bc..e533eee30155 100644 --- a/Marlin/src/HAL/SAMD51/Servo.cpp +++ b/Marlin/src/HAL/SAMD51/Servo.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -19,6 +20,10 @@ * */ +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + /** * This comes from Arduino library which at the moment is buggy and uncompilable */ diff --git a/Marlin/src/HAL/SAMD51/ServoTimers.h b/Marlin/src/HAL/SAMD51/ServoTimers.h index 948d515356fb..47e0a190aac9 100644 --- a/Marlin/src/HAL/SAMD51/ServoTimers.h +++ b/Marlin/src/HAL/SAMD51/ServoTimers.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #define _useTimer1 #define _useTimer2 diff --git a/Marlin/src/HAL/SAMD51/eeprom_flash.cpp b/Marlin/src/HAL/SAMD51/eeprom_flash.cpp index 871bf22b7fc4..7d5518956c7a 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_flash.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_flash.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp b/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp index faa763719707..1c82ede04032 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp index 3481fe539c3e..7a03d4eaa34c 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/SAMD51/endstop_interrupts.h b/Marlin/src/HAL/SAMD51/endstop_interrupts.h index 2f02f404f5f1..e0e811c3a018 100644 --- a/Marlin/src/HAL/SAMD51/endstop_interrupts.h +++ b/Marlin/src/HAL/SAMD51/endstop_interrupts.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + /** * Endstop interrupts for ATMEL SAMD51 based targets. * diff --git a/Marlin/src/HAL/SAMD51/fastio.h b/Marlin/src/HAL/SAMD51/fastio.h index 79aede579044..0acf48131796 100644 --- a/Marlin/src/HAL/SAMD51/fastio.h +++ b/Marlin/src/HAL/SAMD51/fastio.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + /** * Fast IO functions for SAMD51 */ diff --git a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h index 1b876c947dc7..ae1bc2f3efd5 100644 --- a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h +++ b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -18,6 +19,11 @@ * along with this program. If not, see . * */ +#pragma once + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ /** * Test SAMD51 specific configuration values for errors at compile-time. diff --git a/Marlin/src/HAL/SAMD51/pinsDebug.h b/Marlin/src/HAL/SAMD51/pinsDebug.h index f0a46fd7c567..94f91c77bcce 100644 --- a/Marlin/src/HAL/SAMD51/pinsDebug.h +++ b/Marlin/src/HAL/SAMD51/pinsDebug.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #define NUMBER_PINS_TOTAL PINS_COUNT #define digitalRead_mod(p) extDigitalRead(p) @@ -29,7 +34,7 @@ #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) #define GET_ARRAY_PIN(p) pin_array[p].pin #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital -#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL) +#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL)) #define DIGITAL_PIN_TO_ANALOG_PIN(p) digitalPinToAnalogInput(p) #define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P)!=-1) #define pwm_status(pin) digitalPinHasPWM(pin) diff --git a/Marlin/src/HAL/SAMD51/spi_pins.h b/Marlin/src/HAL/SAMD51/spi_pins.h index 2a667bcaa1ce..f1e4fd430246 100644 --- a/Marlin/src/HAL/SAMD51/spi_pins.h +++ b/Marlin/src/HAL/SAMD51/spi_pins.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #ifdef ADAFRUIT_GRAND_CENTRAL_M4 /* diff --git a/Marlin/src/HAL/SAMD51/timers.cpp b/Marlin/src/HAL/SAMD51/timers.cpp index 1ad0e360736a..7a211eb36a69 100644 --- a/Marlin/src/HAL/SAMD51/timers.cpp +++ b/Marlin/src/HAL/SAMD51/timers.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ // -------------------------------------------------------------------------- diff --git a/Marlin/src/HAL/SAMD51/timers.h b/Marlin/src/HAL/SAMD51/timers.h index 86e980c56690..86c324189223 100644 --- a/Marlin/src/HAL/SAMD51/timers.h +++ b/Marlin/src/HAL/SAMD51/timers.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #include // -------------------------------------------------------------------------- diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 7c8cc8dd21e1..6bd519877d53 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -95,7 +95,7 @@ static_assert(IS_FLASH_SECTOR(FLASH_SECTOR), "FLASH_SECTOR is invalid"); static_assert(IS_POWER_OF_2(FLASH_UNIT_SIZE), "FLASH_UNIT_SIZE should be a power of 2, please check your chip's spec sheet"); -#endif +#endif // FLASH_EEPROM_LEVELING static bool eeprom_data_written = false; @@ -189,15 +189,15 @@ bool PersistentStore::access_finish() { UNLOCK_FLASH(); - uint32_t offset = 0; - uint32_t address = SLOT_ADDRESS(current_slot); - uint32_t address_end = address + MARLIN_EEPROM_SIZE; - uint32_t data = 0; + uint32_t offset = 0, + address = SLOT_ADDRESS(current_slot), + address_end = address + MARLIN_EEPROM_SIZE, + data = 0; bool success = true; while (address < address_end) { - memcpy(&data, ram_eeprom + offset, sizeof(uint32_t)); + memcpy(&data, ram_eeprom + offset, sizeof(data)); status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data); if (status == HAL_OK) { address += sizeof(uint32_t); @@ -221,7 +221,8 @@ bool PersistentStore::access_finish() { return success; - #else + #else // !FLASH_EEPROM_LEVELING + // The following was written for the STM32F4 but may work with other MCUs as well. // Most STM32F4 flash does not allow reading from flash during erase operations. // This takes about a second on a STM32F407 with a 128kB sector used as EEPROM. @@ -235,7 +236,8 @@ bool PersistentStore::access_finish() { TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); eeprom_data_written = false; - #endif + + #endif // !FLASH_EEPROM_LEVELING } return true; diff --git a/Marlin/src/HAL/STM32/inc/Conditionals_post.h b/Marlin/src/HAL/STM32/inc/Conditionals_post.h index 18826e11d24a..c5ce66a26f54 100644 --- a/Marlin/src/HAL/STM32/inc/Conditionals_post.h +++ b/Marlin/src/HAL/STM32/inc/Conditionals_post.h @@ -27,3 +27,8 @@ #elif EITHER(I2C_EEPROM, SPI_EEPROM) #define USE_SHARED_EEPROM 1 #endif + +// Some STM32F4 boards may lose steps when saving to EEPROM during print (PR #17946) +#if defined(STM32F4xx) && ENABLED(FLASH_EEPROM_EMULATION) && PRINTCOUNTER_SAVE_INTERVAL > 0 + #define PRINTCOUNTER_SYNC 1 +#endif diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h index 0f1a2acaa41c..e8ddfa172005 100644 --- a/Marlin/src/HAL/STM32/inc/SanityCheck.h +++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h @@ -37,11 +37,6 @@ #error "SDCARD_EEPROM_EMULATION requires SDSUPPORT. Enable SDSUPPORT or choose another EEPROM emulation." #endif -#if defined(STM32F4xx) && BOTH(PRINTCOUNTER, FLASH_EEPROM_EMULATION) - #warning "FLASH_EEPROM_EMULATION may cause long delays when writing and should not be used while printing." - #error "Disable PRINTCOUNTER or choose another EEPROM emulation." -#endif - #if !defined(STM32F4xx) && ENABLED(FLASH_EEPROM_LEVELING) #error "FLASH_EEPROM_LEVELING is currently only supported on STM32F4 hardware." #endif @@ -55,3 +50,62 @@ #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32H7xx, STM32F4xx, STM32F1xx) #error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware." #endif + +/** + * Check for common serial pin conflicts + */ +#define _CHECK_SERIAL_PIN(N) (( \ + BTN_EN1 == N || DOGLCD_CS == N || HEATER_BED_PIN == N || FAN_PIN == N || \ + SDIO_D2_PIN == N || SDIO_D3_PIN == N || SDIO_CK_PIN == N || SDIO_CMD_PIN == N \ + )) +#define CHECK_SERIAL_PIN(T,N) defined(UART##N##_##T##_PIN) && _CHECK_SERIAL_PIN(UART##N##_##T##_PIN) +#if SERIAL_IN_USE(1) + #if CHECK_SERIAL_PIN(TX,1) + #error "Serial Port 1 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,1) + #error "Serial Port 1 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(2) + #if CHECK_SERIAL_PIN(TX,2) + #error "Serial Port 2 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,2) + #error "Serial Port 2 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(3) + #if CHECK_SERIAL_PIN(TX,3) + #error "Serial Port 3 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,3) + #error "Serial Port 3 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(4) + #if CHECK_SERIAL_PIN(TX,4) + #error "Serial Port 4 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,4) + #error "Serial Port 4 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(5) + #if CHECK_SERIAL_PIN(TX,5) + #error "Serial Port 5 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,5) + #error "Serial Port 5 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(6) + #if CHECK_SERIAL_PIN(TX,6) + #error "Serial Port 6 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,6) + #error "Serial Port 6 RX IO pins conflict with another pin on the board." + #endif +#endif +#undef CHECK_SERIAL_PIN +#undef _CHECK_SERIAL_PIN diff --git a/Marlin/src/HAL/STM32/pinsDebug.h b/Marlin/src/HAL/STM32/pinsDebug.h index 55c64c868192..29a4e003f98a 100644 --- a/Marlin/src/HAL/STM32/pinsDebug.h +++ b/Marlin/src/HAL/STM32/pinsDebug.h @@ -102,17 +102,18 @@ const XrefInfo pin_xref[] PROGMEM = { #define PIN_NUM_ALPHA_LEFT(P) (((P & 0x000F) < 10) ? ('0' + (P & 0x000F)) : '1') #define PIN_NUM_ALPHA_RIGHT(P) (((P & 0x000F) > 9) ? ('0' + (P & 0x000F) - 10) : 0 ) #define PORT_NUM(P) ((P >> 4) & 0x0007) -#define PORT_ALPHA(P) ('A' + (P >> 4)) +#define PORT_ALPHA(P) ('A' + (P >> 4)) /** * Translation of routines & variables used by pinsDebug.h */ -#if PA0 >= NUM_DIGITAL_PINS +#if NUM_ANALOG_FIRST >= NUM_DIGITAL_PINS #define HAS_HIGH_ANALOG_PINS 1 #endif -#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS) -#define VALID_PIN(ANUM) ((ANUM) >= 0 && (ANUM) < NUMBER_PINS_TOTAL) +#define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1) +#define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS)) +#define VALID_PIN(P) (WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1) || TERN0(HAS_HIGH_ANALOG_PINS, WITHIN(P, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))) #define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads #define PRINT_PIN(Q) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) @@ -168,7 +169,7 @@ bool GET_PINMODE(const pin_t Ard_num) { } int8_t digital_pin_to_analog_pin(const pin_t Ard_num) { - if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_FIRST + NUM_ANALOG_INPUTS - 1)) + if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_LAST)) return Ard_num - NUM_ANALOG_FIRST; const uint32_t ind = digitalPinToAnalogInput(Ard_num); @@ -206,8 +207,11 @@ void port_print(const pin_t Ard_num) { SERIAL_ECHO_SP(7); // Print number to be used with M42 - int calc_p = Ard_num % (NUM_DIGITAL_PINS + 1); - if (Ard_num > NUM_DIGITAL_PINS && calc_p > 7) calc_p += 8; + int calc_p = Ard_num; + if (Ard_num > NUM_DIGITAL_PINS) { + calc_p -= NUM_ANALOG_FIRST; + if (calc_p > 7) calc_p += 8; + } SERIAL_ECHOPGM(" M42 P", calc_p); SERIAL_CHAR(' '); if (calc_p < 100) { diff --git a/Marlin/src/HAL/STM32/tft/gt911.cpp b/Marlin/src/HAL/STM32/tft/gt911.cpp index 180abc68b054..82b7c5b10391 100644 --- a/Marlin/src/HAL/STM32/tft/gt911.cpp +++ b/Marlin/src/HAL/STM32/tft/gt911.cpp @@ -150,9 +150,9 @@ void GT911::read_reg(uint16_t reg, uint8_t reg_len, uint8_t* r_data, uint8_t r_l sw_iic.start(); sw_iic.send_byte(gt911_slave_address + 1); // Set read mode - LOOP_L_N(i, r_len) { + LOOP_L_N(i, r_len) r_data[i] = sw_iic.read_byte(1); // Read data from reg - } + sw_iic.stop(); } diff --git a/Marlin/src/HAL/STM32/tft/gt911.h b/Marlin/src/HAL/STM32/tft/gt911.h index 6ecfe8b82ec7..260c195eca63 100644 --- a/Marlin/src/HAL/STM32/tft/gt911.h +++ b/Marlin/src/HAL/STM32/tft/gt911.h @@ -39,42 +39,18 @@ class SW_IIC { private: uint16_t scl_pin; uint16_t sda_pin; - void write_scl(bool level) - { - WRITE(scl_pin, level); - } - void write_sda(bool level) - { - WRITE(sda_pin, level); - } - bool read_sda() - { - return READ(sda_pin); - } - void set_sda_out() - { - SET_OUTPUT(sda_pin); - } - void set_sda_in() - { - SET_INPUT_PULLUP(sda_pin); - } - static void iic_delay(uint8_t t) - { - delayMicroseconds(t); - } + void write_scl(bool level) { WRITE(scl_pin, level); } + void write_sda(bool level) { WRITE(sda_pin, level); } + bool read_sda() { return READ(sda_pin); } + void set_sda_out() { SET_OUTPUT(sda_pin); } + void set_sda_in() { SET_INPUT_PULLUP(sda_pin); } + static void iic_delay(uint8_t t) { delayMicroseconds(t); } public: SW_IIC(uint16_t sda, uint16_t scl); // setSCL/SDA have to be called before begin() - void setSCL(uint16_t scl) - { - scl_pin = scl; - }; - void setSDA(uint16_t sda) - { - sda_pin = sda; - }; + void setSCL(uint16_t scl) { scl_pin = scl; } + void setSDA(uint16_t sda) { sda_pin = sda; } void init(); // Initialize the IO port of IIC void start(); // Send IIC start signal void stop(); // Send IIC stop signal diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp index e68b3c126939..cf9e569336bc 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp @@ -147,21 +147,36 @@ uint32_t TFT_FSMC::ReadID(tft_data_t Reg) { } bool TFT_FSMC::isBusy() { - #if defined(STM32F1xx) - volatile bool dmaEnabled = (DMAtx.Instance->CCR & DMA_CCR_EN) != RESET; + #ifdef STM32F1xx + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN) + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->CPAR != 0) #elif defined(STM32F4xx) - volatile bool dmaEnabled = DMAtx.Instance->CR & DMA_SxCR_EN; + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN) + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->PAR != 0) #endif - if (dmaEnabled) { - if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) != 0 || __HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) != 0) - Abort(); - } - else - Abort(); - return dmaEnabled; + + if (!__IS_DMA_CONFIGURED(&DMAtx)) return false; + + // Check if DMA transfer error or transfer complete flags are set + if ((__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) == 0) && (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) == 0)) return true; + + __DSB(); + Abort(); + return false; +} + +void TFT_FSMC::Abort() { + HAL_DMA_Abort(&DMAtx); // Abort DMA transfer if any + HAL_DMA_DeInit(&DMAtx); // Deconfigure DMA } void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + DMAtx.Init.PeriphInc = MemoryIncrease; + HAL_DMA_Init(&DMAtx); + HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(LCD->RAM), Count); +} + +void TFT_FSMC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DMAtx.Init.PeriphInc = MemoryIncrease; HAL_DMA_Init(&DMAtx); DataTransferBegin(); diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.h b/Marlin/src/HAL/STM32/tft/tft_fsmc.h index 2200abaa10e8..41ff8c9a83c8 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.h +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.h @@ -41,6 +41,7 @@ #define DATASIZE_8BIT SPI_DATASIZE_8BIT #define DATASIZE_16BIT SPI_DATASIZE_16BIT #define TFT_IO_DRIVER TFT_FSMC +#define DMA_MAX_SIZE 0xFFFF #define TFT_DATASIZE TERN(TFT_INTERFACE_FSMC_8BIT, DATASIZE_8BIT, DATASIZE_16BIT) typedef TERN(TFT_INTERFACE_FSMC_8BIT, uint8_t, uint16_t) tft_data_t; @@ -59,13 +60,14 @@ class TFT_FSMC { static uint32_t ReadID(tft_data_t Reg); static void Transmit(tft_data_t Data) { LCD->RAM = Data; __DSB(); } + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: static void Init(); static uint32_t GetID(); static bool isBusy(); - static void Abort() { __HAL_DMA_DISABLE(&DMAtx); } + static void Abort(); static void DataTransferBegin(uint16_t DataWidth = TFT_DATASIZE) {} static void DataTransferEnd() {}; @@ -73,13 +75,14 @@ class TFT_FSMC { static void WriteData(uint16_t Data) { Transmit(tft_data_t(Data)); } static void WriteReg(uint16_t Reg) { LCD->REG = tft_data_t(Reg); __DSB(); } - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp index 95871bf41f5c..2be900618f20 100644 --- a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp @@ -356,7 +356,7 @@ void TFT_LTDC::WriteReg(uint16_t Reg) { reg = Reg; } -void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { +void TFT_LTDC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { while (x_cur != x_min && Count) { Transmit(*Data); diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.h b/Marlin/src/HAL/STM32/tft/tft_ltdc.h index 7b63d6929b31..8d83839bb3fa 100644 --- a/Marlin/src/HAL/STM32/tft/tft_ltdc.h +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.h @@ -32,6 +32,7 @@ #define DATASIZE_8BIT SPI_DATASIZE_8BIT #define DATASIZE_16BIT SPI_DATASIZE_16BIT #define TFT_IO_DRIVER TFT_LTDC +#define DMA_MAX_SIZE 0xFFFF #define TFT_DATASIZE DATASIZE_16BIT typedef uint16_t tft_data_t; @@ -49,7 +50,7 @@ class TFT_LTDC { static void DrawRect(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color); static void DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *colors); static void Transmit(tft_data_t Data); - static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: static void Init(); @@ -63,13 +64,15 @@ class TFT_LTDC { static void WriteData(uint16_t Data); static void WriteReg(uint16_t Reg); - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + // Non-blocking DMA data transfer is not implemented for LTDC interface + inline static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { WriteSequence(Data, Count); } + inline static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { WriteMultiple(Color, Count); } + + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_PINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 2e18c8a64c06..5e79f156d27c 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -160,16 +160,13 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { for (i = 0; i < 4; i++) { #if TFT_MISO_PIN != TFT_MOSI_PIN - //if (hspi->Init.Direction == SPI_DIRECTION_2LINES) { - while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} - SPIx.Instance->DR = 0; - //} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} + SPIx.Instance->DR = 0; #endif while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_RXNE)) {} Data = (Data << 8) | SPIx.Instance->DR; } - __HAL_SPI_DISABLE(&SPIx); DataTransferEnd(); SPIx.Init.BaudRatePrescaler = BaudRatePrescaler; @@ -179,36 +176,44 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { } bool TFT_SPI::isBusy() { - #if defined(STM32F1xx) - volatile bool dmaEnabled = (DMAtx.Instance->CCR & DMA_CCR_EN) != RESET; + #ifdef STM32F1xx + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN) + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->CPAR != 0) #elif defined(STM32F4xx) - volatile bool dmaEnabled = DMAtx.Instance->CR & DMA_SxCR_EN; + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN) + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->PAR != 0) #endif - if (dmaEnabled) { - if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) != 0 || __HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) != 0) - Abort(); + + if (!__IS_DMA_CONFIGURED(&DMAtx)) return false; + + if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx))) { + // You should not be here - DMA transfer error flag is set + // Abort DMA transfer and release SPI } - else - Abort(); - return dmaEnabled; + else { + // Check if DMA transfer completed flag is set + if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) == 0) return true; + // Check if SPI transmit butter is empty and SPI is idle + if ((!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) || (__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY))) return true; + } + + Abort(); + return false; } void TFT_SPI::Abort() { - // Wait for any running spi - while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} - while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {} - // First, abort any running dma - HAL_DMA_Abort(&DMAtx); - // DeInit objects + HAL_DMA_Abort(&DMAtx); // Abort DMA transfer if any HAL_DMA_DeInit(&DMAtx); - HAL_SPI_DeInit(&SPIx); - // Deselect CS - DataTransferEnd(); + + CLEAR_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); + + DataTransferEnd(); // Stop SPI and deselect CS } void TFT_SPI::Transmit(uint16_t Data) { - if (TFT_MISO_PIN == TFT_MOSI_PIN) + #if TFT_MISO_PIN == TFT_MOSI_PIN SPI_1LINE_TX(&SPIx); + #endif __HAL_SPI_ENABLE(&SPIx); @@ -217,14 +222,31 @@ void TFT_SPI::Transmit(uint16_t Data) { while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {} - if (TFT_MISO_PIN != TFT_MOSI_PIN) - __HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received is not read + #if TFT_MISO_PIN != TFT_MOSI_PIN + __HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received data is not read + #endif } void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { - // Wait last dma finish, to start another - while (isBusy()) { /* nada */ } + DMAtx.Init.MemInc = MemoryIncrease; + HAL_DMA_Init(&DMAtx); + #if TFT_MISO_PIN == TFT_MOSI_PIN + SPI_1LINE_TX(&SPIx); + #endif + + DataTransferBegin(); + + HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(SPIx.Instance->DR), Count); + __HAL_SPI_ENABLE(&SPIx); + + SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); // Enable Tx DMA Request + + TERN_(TFT_SHARED_SPI, while (isBusy())); +} + + +void TFT_SPI::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DMAtx.Init.MemInc = MemoryIncrease; HAL_DMA_Init(&DMAtx); @@ -243,7 +265,6 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun } #if ENABLED(USE_SPI_DMA_TC) - void TFT_SPI::TransmitDMA_IT(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DMAtx.Init.MemInc = MemoryIncrease; @@ -262,8 +283,7 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); // Enable Tx DMA Request } - extern "C" void DMA2_Stream3_IRQHandler(void) { HAL_DMA_IRQHandler(&TFT_SPI::DMAtx); } - + extern "C" void DMA2_Stream3_IRQHandler(void) { TFT_SPI::DMA_IRQHandler(); } #endif #endif // HAS_SPI_TFT diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.h b/Marlin/src/HAL/STM32/tft/tft_spi.h index de051e229459..6b8613e3f87f 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.h +++ b/Marlin/src/HAL/STM32/tft/tft_spi.h @@ -39,46 +39,47 @@ #define DATASIZE_8BIT SPI_DATASIZE_8BIT #define DATASIZE_16BIT SPI_DATASIZE_16BIT #define TFT_IO_DRIVER TFT_SPI +#define DMA_MAX_SIZE 0xFFFF class TFT_SPI { private: static SPI_HandleTypeDef SPIx; - + static DMA_HandleTypeDef DMAtx; static uint32_t ReadID(uint16_t Reg); static void Transmit(uint16_t Data); + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); #if ENABLED(USE_SPI_DMA_TC) static void TransmitDMA_IT(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); #endif public: - static DMA_HandleTypeDef DMAtx; - static void Init(); static uint32_t GetID(); static bool isBusy(); static void Abort(); static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT); - static void DataTransferEnd() { WRITE(TFT_CS_PIN, HIGH); }; + static void DataTransferEnd() { WRITE(TFT_CS_PIN, HIGH); __HAL_SPI_DISABLE(&SPIx); }; static void DataTransferAbort(); static void WriteData(uint16_t Data) { Transmit(Data); } static void WriteReg(uint16_t Reg) { WRITE(TFT_A0_PIN, LOW); Transmit(Reg); WRITE(TFT_A0_PIN, HIGH); } - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } #if ENABLED(USE_SPI_DMA_TC) static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { TransmitDMA_IT(DMA_MINC_ENABLE, Data, Count); } + inline static void DMA_IRQHandler() { HAL_DMA_IRQHandler(&TFT_SPI::DMAtx); } #endif - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_MINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/STM32F1/SPI.cpp b/Marlin/src/HAL/STM32F1/SPI.cpp index 1ce2c7d3fd5d..a180684757ee 100644 --- a/Marlin/src/HAL/STM32F1/SPI.cpp +++ b/Marlin/src/HAL/STM32F1/SPI.cpp @@ -526,23 +526,22 @@ void SPIClass::onReceive(void(*callback)()) { _currentSetting->receiveCallback = callback; if (callback) { switch (_currentSetting->spi_d->clk_id) { - #if BOARD_NR_SPI >= 1 - case RCC_SPI1: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi1EventCallback); - break; - #endif - #if BOARD_NR_SPI >= 2 - case RCC_SPI2: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi2EventCallback); - break; - #endif - #if BOARD_NR_SPI >= 3 - case RCC_SPI3: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi3EventCallback); - break; - #endif - default: - ASSERT(0); + #if BOARD_NR_SPI >= 1 + case RCC_SPI1: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi1EventCallback); + break; + #endif + #if BOARD_NR_SPI >= 2 + case RCC_SPI2: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi2EventCallback); + break; + #endif + #if BOARD_NR_SPI >= 3 + case RCC_SPI3: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi3EventCallback); + break; + #endif + default: ASSERT(0); } } else { @@ -554,23 +553,22 @@ void SPIClass::onTransmit(void(*callback)()) { _currentSetting->transmitCallback = callback; if (callback) { switch (_currentSetting->spi_d->clk_id) { - #if BOARD_NR_SPI >= 1 - case RCC_SPI1: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi1EventCallback); - break; - #endif - #if BOARD_NR_SPI >= 2 - case RCC_SPI2: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi2EventCallback); - break; - #endif - #if BOARD_NR_SPI >= 3 - case RCC_SPI3: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi3EventCallback); - break; - #endif - default: - ASSERT(0); + #if BOARD_NR_SPI >= 1 + case RCC_SPI1: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi1EventCallback); + break; + #endif + #if BOARD_NR_SPI >= 2 + case RCC_SPI2: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi2EventCallback); + break; + #endif + #if BOARD_NR_SPI >= 3 + case RCC_SPI3: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi3EventCallback); + break; + #endif + default: ASSERT(0); } } else { diff --git a/Marlin/src/HAL/STM32F1/SPI.h b/Marlin/src/HAL/STM32F1/SPI.h index 13f4d5ed6cfe..0941fa55b781 100644 --- a/Marlin/src/HAL/STM32F1/SPI.h +++ b/Marlin/src/HAL/STM32F1/SPI.h @@ -33,6 +33,15 @@ #include #include +// Number of SPI ports +#ifdef BOARD_SPI3_SCK_PIN + #define BOARD_NR_SPI 3 +#elif defined(BOARD_SPI2_SCK_PIN) + #define BOARD_NR_SPI 2 +#elif defined(BOARD_SPI1_SCK_PIN) + #define BOARD_NR_SPI 1 +#endif + // SPI_HAS_TRANSACTION means SPI has // - beginTransaction() // - endTransaction() diff --git a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp index 5b52fb416fa3..512e70cf3f70 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp @@ -215,22 +215,47 @@ uint32_t TFT_FSMC::GetID() { } bool TFT_FSMC::isBusy() { + #define __IS_DMA_CONFIGURED(__DMAx__, __CHx__) (dma_channel_regs(__DMAx__, __CHx__)->CPAR != 0) + + if (!__IS_DMA_CONFIGURED(FSMC_DMA_DEV, FSMC_DMA_CHANNEL)) return false; + + // Check if DMA transfer error or transfer complete flags are set + if ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & (DMA_ISR_TCIF | DMA_ISR_TEIF)) == 0) return true; + + __DSB(); + Abort(); return false; } void TFT_FSMC::Abort() { + dma_channel_reg_map *channel_regs = dma_channel_regs(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); // Abort DMA transfer if any + + // Deconfigure DMA + channel_regs->CCR = 0U; + channel_regs->CNDTR = 0U; + channel_regs->CMAR = 0U; + channel_regs->CPAR = 0U; } void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + // TODO: HAL STM32 uses DMA2_Channel1 for FSMC on STM32F1 + dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | MemoryIncrease); + dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Count); + dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); +} + +void TFT_FSMC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { #if defined(FSMC_DMA_DEV) && defined(FSMC_DMA_CHANNEL) dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | MemoryIncrease); dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Count); dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); - while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {}; - dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & (DMA_CCR_TEIE | DMA_CCR_TCIE)) == 0) {} + Abort(); #endif } diff --git a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h index d9ee1f4c7767..8d26f6eac0b7 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h +++ b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h @@ -33,6 +33,10 @@ #define DATASIZE_8BIT DMA_SIZE_8BITS #define DATASIZE_16BIT DMA_SIZE_16BITS #define TFT_IO_DRIVER TFT_FSMC +#define DMA_MAX_SIZE 0xFFFF + +#define DMA_PINC_ENABLE DMA_PINC_MODE +#define DMA_PINC_DISABLE 0 typedef struct { __IO uint16_t REG; @@ -45,6 +49,7 @@ class TFT_FSMC { static uint32_t ReadID(uint16_t Reg); static void Transmit(uint16_t Data); + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: @@ -59,13 +64,14 @@ class TFT_FSMC { static void WriteData(uint16_t Data) { Transmit(Data); } static void WriteReg(uint16_t Reg); - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_MODE, Data, Count); } - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_CIRC_MODE, &Data, Count); } + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_CIRC_MODE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_PINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp index f447cec81107..bb495d5f58b5 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp @@ -26,7 +26,7 @@ #include "tft_spi.h" -SPIClass TFT_SPI::SPIx(1); +SPIClass TFT_SPI::SPIx(TFT_SPI_DEVICE); void TFT_SPI::Init() { #if PIN_EXISTS(TFT_RESET) @@ -46,7 +46,7 @@ void TFT_SPI::Init() { * STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1 * so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2 */ - #if SPI_DEVICE == 1 + #if TFT_SPI_DEVICE == 1 #define SPI_CLOCK_MAX SPI_CLOCK_DIV4 #else #define SPI_CLOCK_MAX SPI_CLOCK_DIV2 @@ -62,7 +62,7 @@ void TFT_SPI::Init() { case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break; default: clock = SPI_CLOCK_DIV2; // Default from the SPI library } - SPIx.setModule(1); + SPIx.setModule(TFT_SPI_DEVICE); SPIx.setClockDivider(clock); SPIx.setBitOrder(MSBFIRST); SPIx.setDataMode(SPI_MODE0); @@ -71,7 +71,7 @@ void TFT_SPI::Init() { void TFT_SPI::DataTransferBegin(uint16_t DataSize) { SPIx.setDataSize(DataSize); SPIx.begin(); - OUT_WRITE(TFT_CS_PIN, LOW); + WRITE(TFT_CS_PIN, LOW); } #ifdef TFT_DEFAULT_DRIVER @@ -113,15 +113,53 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { #endif } -bool TFT_SPI::isBusy() { return false; } +bool TFT_SPI::isBusy() { + #define __IS_DMA_CONFIGURED(__DMAx__, __CHx__) (dma_channel_regs(__DMAx__, __CHx__)->CPAR != 0) -void TFT_SPI::Abort() { DataTransferEnd(); } + if (!__IS_DMA_CONFIGURED(DMAx, DMA_CHx)) return false; + + if (dma_get_isr_bits(DMAx, DMA_CHx) & DMA_ISR_TEIF) { + // You should not be here - DMA transfer error flag is set + // Abort DMA transfer and release SPI + } + else { + // Check if DMA transfer completed flag is set + if (!(dma_get_isr_bits(DMAx, DMA_CHx) & DMA_ISR_TCIF)) return true; + // Check if SPI TX butter is empty and SPI is idle + if (!(SPIdev->regs->SR & SPI_SR_TXE) || (SPIdev->regs->SR & SPI_SR_BSY)) return true; + } + + Abort(); + return false; +} + +void TFT_SPI::Abort() { + dma_channel_reg_map *channel_regs = dma_channel_regs(DMAx, DMA_CHx); + + dma_disable(DMAx, DMA_CHx); // Abort DMA transfer if any + spi_tx_dma_disable(SPIdev); + + // Deconfigure DMA + channel_regs->CCR = 0U; + channel_regs->CNDTR = 0U; + channel_regs->CMAR = 0U; + channel_regs->CPAR = 0U; + + DataTransferEnd(); +} void TFT_SPI::Transmit(uint16_t Data) { SPIx.send(Data); } void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DataTransferBegin(); - OUT_WRITE(TFT_DC_PIN, HIGH); + SPIx.dmaSendAsync(Data, Count, MemoryIncrease == DMA_MINC_ENABLE); + + TERN_(TFT_SHARED_SPI, while (isBusy())); +} + +void TFT_SPI::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + WRITE(TFT_DC_PIN, HIGH); + DataTransferBegin(); SPIx.dmaSend(Data, Count, MemoryIncrease == DMA_MINC_ENABLE); DataTransferEnd(); } diff --git a/Marlin/src/HAL/STM32F1/tft/tft_spi.h b/Marlin/src/HAL/STM32F1/tft/tft_spi.h index da9a8e0c223e..2bda8c21f724 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_spi.h +++ b/Marlin/src/HAL/STM32F1/tft/tft_spi.h @@ -25,6 +25,27 @@ #include +#define IS_SPI(N) (BOARD_NR_SPI >= N && (TFT_SCK_PIN == BOARD_SPI##N##_SCK_PIN) && (TFT_MOSI_PIN == BOARD_SPI##N##_MOSI_PIN) && (TFT_MISO_PIN == BOARD_SPI##N##_MISO_PIN)) +#if IS_SPI(1) + #define TFT_SPI_DEVICE 1 + #define SPIdev SPI1 + #define DMAx DMA1 + #define DMA_CHx DMA_CH3 +#elif IS_SPI(2) + #define TFT_SPI_DEVICE 2 + #define SPIdev SPI2 + #define DMAx DMA1 + #define DMA_CHx DMA_CH5 +#elif IS_SPI(3) + #define TFT_SPI_DEVICE 3 + #define SPIdev SPI3 + #define DMAx DMA2 + #define DMA_CHx DMA_CH2 +#else + #error "Invalid TFT SPI configuration." +#endif +#undef IS_SPI + #ifndef LCD_READ_ID #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341) #endif @@ -32,17 +53,19 @@ #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341) #endif -#define DATASIZE_8BIT DATA_SIZE_8BIT -#define DATASIZE_16BIT DATA_SIZE_16BIT -#define TFT_IO_DRIVER TFT_SPI +#define DATASIZE_8BIT DATA_SIZE_8BIT +#define DATASIZE_16BIT DATA_SIZE_16BIT +#define TFT_IO_DRIVER TFT_SPI +#define DMA_MAX_SIZE 0xFFFF -#define DMA_MINC_ENABLE 1 -#define DMA_MINC_DISABLE 0 +#define DMA_MINC_ENABLE DMA_MINC_MODE +#define DMA_MINC_DISABLE 0 class TFT_SPI { private: static uint32_t ReadID(uint16_t Reg); static void Transmit(uint16_t Data); + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: @@ -58,15 +81,16 @@ class TFT_SPI { static void DataTransferAbort(); static void WriteData(uint16_t Data) { Transmit(Data); } - static void WriteReg(uint16_t Reg) { WRITE(TFT_A0_PIN, LOW); Transmit(Reg); WRITE(TFT_A0_PIN, HIGH); } + static void WriteReg(uint16_t Reg) { WRITE(TFT_DC_PIN, LOW); Transmit(Reg); WRITE(TFT_DC_PIN, HIGH); } + + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_MINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/TEENSY40_41/pinsDebug.h b/Marlin/src/HAL/TEENSY40_41/pinsDebug.h index 94b85ea56861..fc90f671cffe 100644 --- a/Marlin/src/HAL/TEENSY40_41/pinsDebug.h +++ b/Marlin/src/HAL/TEENSY40_41/pinsDebug.h @@ -36,7 +36,7 @@ #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) #define GET_ARRAY_PIN(p) pin_array[p].pin #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital -#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0) +#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL)) #define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0)) #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(13)) || ((P) >= analogInputToDigitalPin(14) && (P) <= analogInputToDigitalPin(17)) #define pwm_status(pin) HAL_pwm_status(pin) diff --git a/Marlin/src/HAL/platforms.h b/Marlin/src/HAL/platforms.h index 28fe28e1094f..488980ce0931 100644 --- a/Marlin/src/HAL/platforms.h +++ b/Marlin/src/HAL/platforms.h @@ -50,6 +50,8 @@ #define HAL_PATH(PATH, NAME) XSTR(PATH/NATIVE_SIM/NAME) #elif defined(__SAMD51__) #define HAL_PATH(PATH, NAME) XSTR(PATH/SAMD51/NAME) +#elif defined(__SAMD21__) + #define HAL_PATH(PATH, NAME) XSTR(PATH/SAMD21/NAME) #else #error "Unsupported Platform!" #endif diff --git a/Marlin/src/HAL/shared/backtrace/unwarm.cpp b/Marlin/src/HAL/shared/backtrace/unwarm.cpp index adbcca69cc58..e72a02e487cd 100644 --- a/Marlin/src/HAL/shared/backtrace/unwarm.cpp +++ b/Marlin/src/HAL/shared/backtrace/unwarm.cpp @@ -33,8 +33,9 @@ void UnwPrintf(const char *format, ...) { va_list args; - va_start( args, format ); - vprintf(format, args ); + va_start(args, format); + vprintf(format, args); + va_end(args); } #endif diff --git a/Marlin/src/HAL/shared/servo.h b/Marlin/src/HAL/shared/servo.h index c2560a853832..15153ca53fa9 100644 --- a/Marlin/src/HAL/shared/servo.h +++ b/Marlin/src/HAL/shared/servo.h @@ -83,10 +83,10 @@ #else #include - #if defined(__AVR__) || defined(ARDUINO_ARCH_SAM) || defined(__SAMD51__) + #if defined(__AVR__) || defined(ARDUINO_ARCH_SAM) || defined(__SAMD51__) || defined(__SAMD21__) // we're good to go #else - #error "This library only supports boards with an AVR, SAM3X or SAMD51 processor." + #error "This library only supports boards with an AVR, SAM3X, SAMD21 or SAMD51 processor." #endif #define Servo_VERSION 2 // software version of this library diff --git a/Marlin/src/HAL/shared/servo_private.h b/Marlin/src/HAL/shared/servo_private.h index 10cc5a198821..8fd5ab2d8883 100644 --- a/Marlin/src/HAL/shared/servo_private.h +++ b/Marlin/src/HAL/shared/servo_private.h @@ -49,8 +49,10 @@ #include "../DUE/ServoTimers.h" #elif defined(__SAMD51__) #include "../SAMD51/ServoTimers.h" +#elif defined(__SAMD21__) + #include "../SAMD21/ServoTimers.h" #else - #error "This library only supports boards with an AVR, SAM3X or SAMD51 processor." + #error "This library only supports boards with an AVR, SAM3X, SAMD21 or SAMD51 processor." #endif // Macros diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 447a46f5b949..867c37db9ff6 100755 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -356,7 +356,7 @@ void startOrResumeJob() { TERN_(GCODE_REPEAT_MARKERS, repeat.reset()); TERN_(CANCEL_OBJECTS, cancelable.reset()); TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0); - #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) ui.reset_remaining_time(); #endif } @@ -514,7 +514,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { } #endif - #if HAS_FREEZE_PIN + #if ENABLED(FREEZE_FEATURE) stepper.frozen = READ(FREEZE_PIN) == FREEZE_STATE; #endif diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 7fbcd1503663..3118decc7952 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -110,13 +110,14 @@ #define BOARD_COPYMASTER_3D 1154 // Copymaster 3D #define BOARD_ORTUR_4 1155 // Ortur 4 #define BOARD_TENLOG_D3_HERO 1156 // Tenlog D3 Hero IDEX printer -#define BOARD_RAMPS_S_12_EEFB 1157 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) -#define BOARD_RAMPS_S_12_EEEB 1158 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) -#define BOARD_RAMPS_S_12_EFFB 1159 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) -#define BOARD_LONGER3D_LK1_PRO 1160 // Longer LK1 PRO / Alfawise U20 Pro (PRO version) -#define BOARD_LONGER3D_LKx_PRO 1161 // Longer LKx PRO / Alfawise Uxx Pro (PRO version) -#define BOARD_ZRIB_V53 1162 // Zonestar zrib V5.3 (Chinese RAMPS replica) -#define BOARD_PXMALION_CORE_I3 1163 // Pxmalion Core I3 +#define BOARD_TENLOG_MB1_V23 1157 // Tenlog D3, D5, D6 IDEX Printer +#define BOARD_RAMPS_S_12_EEFB 1158 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) +#define BOARD_RAMPS_S_12_EEEB 1159 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) +#define BOARD_RAMPS_S_12_EFFB 1160 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) +#define BOARD_LONGER3D_LK1_PRO 1161 // Longer LK1 PRO / Alfawise U20 Pro (PRO version) +#define BOARD_LONGER3D_LKx_PRO 1162 // Longer LKx PRO / Alfawise Uxx Pro (PRO version) +#define BOARD_ZRIB_V53 1163 // Zonestar zrib V5.3 (Chinese RAMPS replica) +#define BOARD_PXMALION_CORE_I3 1164 // Pxmalion Core I3 // // RAMBo and derivatives @@ -324,50 +325,53 @@ #define BOARD_MKS_ROBIN_E3D 4020 // MKS Robin E3D (STM32F103RC) #define BOARD_MKS_ROBIN_E3D_V1_1 4021 // MKS Robin E3D V1.1 (STM32F103RC) #define BOARD_MKS_ROBIN_E3P 4022 // MKS Robin E3p (STM32F103VE) -#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 / STM32F103RE) -#define BOARD_BTT_SKR_MINI_E3_V3_0 4027 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RE) -#define BOARD_BTT_SKR_MINI_MZ_V1_0 4028 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC) -#define BOARD_BTT_SKR_E3_DIP 4029 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) -#define BOARD_BTT_SKR_CR6 4030 // BigTreeTech SKR CR6 v1.0 (STM32F103RE) -#define BOARD_JGAURORA_A5S_A1 4031 // JGAurora A5S A1 (STM32F103ZE) -#define BOARD_FYSETC_AIO_II 4032 // FYSETC AIO_II (STM32F103RC) -#define BOARD_FYSETC_CHEETAH 4033 // FYSETC Cheetah (STM32F103RC) -#define BOARD_FYSETC_CHEETAH_V12 4034 // FYSETC Cheetah V1.2 (STM32F103RC) -#define BOARD_LONGER3D_LK 4035 // Longer3D LK1/2 - Alfawise U20/U20+/U30 (STM32F103VE) -#define BOARD_CCROBOT_MEEB_3DP 4036 // ccrobot-online.com MEEB_3DP (STM32F103RC) -#define BOARD_CHITU3D_V5 4037 // Chitu3D TronXY X5SA V5 Board (STM32F103ZE) -#define BOARD_CHITU3D_V6 4038 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE) -#define BOARD_CHITU3D_V9 4039 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE) -#define BOARD_CREALITY_V4 4040 // Creality v4.x (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V422 4041 // Creality v4.2.2 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V423 4042 // Creality v4.2.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V425 4043 // Creality v4.2.5 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V427 4044 // Creality v4.2.7 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V4210 4045 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 -#define BOARD_CREALITY_V431 4046 // Creality v4.3.1 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_A 4047 // Creality v4.3.1a (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_B 4048 // Creality v4.3.1b (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_C 4049 // Creality v4.3.1c (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_D 4050 // Creality v4.3.1d (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V452 4051 // Creality v4.5.2 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V453 4052 // Creality v4.5.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V24S1 4053 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 -#define BOARD_CREALITY_V24S1_301 4054 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 -#define BOARD_CREALITY_V25S1 4055 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro -#define BOARD_TRIGORILLA_PRO 4056 // Trigorilla Pro (STM32F103ZE) -#define BOARD_FLY_MINI 4057 // FLYmaker FLY MINI (STM32F103RC) -#define BOARD_FLSUN_HISPEED 4058 // FLSUN HiSpeedV1 (STM32F103VE) -#define BOARD_BEAST 4059 // STM32F103RE Libmaple-based controller -#define BOARD_MINGDA_MPX_ARM_MINI 4060 // STM32F103ZE Mingda MD-16 -#define BOARD_GTM32_PRO_VD 4061 // STM32F103VE controller -#define BOARD_ZONESTAR_ZM3E2 4062 // Zonestar ZM3E2 (STM32F103RC) -#define BOARD_ZONESTAR_ZM3E4 4063 // Zonestar ZM3E4 V1 (STM32F103VC) -#define BOARD_ZONESTAR_ZM3E4V2 4064 // Zonestar ZM3E4 V2 (STM32F103VC) -#define BOARD_ERYONE_ERY32_MINI 4065 // Eryone Ery32 mini (STM32F103VE) -#define BOARD_PANDA_PI_V29 4066 // Panda Pi V2.9 - Standalone (STM32F103RC) +#define BOARD_BTT_EBB42_V1_1 4023 // BigTreeTech EBB42 V1.1 (STM32G0B1CB) +#define BOARD_BTT_SKR_MINI_V1_1 4024 // BigTreeTech SKR Mini v1.1 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V1_0 4025 // BigTreeTech SKR Mini E3 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V1_2 4026 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V2_0 4027 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE) +#define BOARD_BTT_SKR_MINI_E3_V3_0 4028 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RE) +#define BOARD_BTT_SKR_MINI_E3_V3_0_1 4029 // BigTreeTech SKR Mini E3 V3.0.1 (STM32F401RC) +#define BOARD_BTT_SKR_MINI_MZ_V1_0 4030 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC) +#define BOARD_BTT_SKR_E3_DIP 4031 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) +#define BOARD_BTT_SKR_CR6 4032 // BigTreeTech SKR CR6 v1.0 (STM32F103RE) +#define BOARD_JGAURORA_A5S_A1 4033 // JGAurora A5S A1 (STM32F103ZE) +#define BOARD_FYSETC_AIO_II 4034 // FYSETC AIO_II (STM32F103RC) +#define BOARD_FYSETC_CHEETAH 4035 // FYSETC Cheetah (STM32F103RC) +#define BOARD_FYSETC_CHEETAH_V12 4036 // FYSETC Cheetah V1.2 (STM32F103RC) +#define BOARD_LONGER3D_LK 4037 // Longer3D LK1/2 - Alfawise U20/U20+/U30 (STM32F103VE) +#define BOARD_CCROBOT_MEEB_3DP 4038 // ccrobot-online.com MEEB_3DP (STM32F103RC) +#define BOARD_CHITU3D_V5 4039 // Chitu3D TronXY X5SA V5 Board (STM32F103ZE) +#define BOARD_CHITU3D_V6 4040 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE) +#define BOARD_CHITU3D_V9 4041 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE) +#define BOARD_CREALITY_V4 4042 // Creality v4.x (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V422 4043 // Creality v4.2.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V423 4044 // Creality v4.2.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V425 4045 // Creality v4.2.5 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V427 4046 // Creality v4.2.7 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V4210 4047 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 +#define BOARD_CREALITY_V431 4048 // Creality v4.3.1 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_A 4049 // Creality v4.3.1a (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_B 4050 // Creality v4.3.1b (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_C 4051 // Creality v4.3.1c (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_D 4052 // Creality v4.3.1d (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V452 4053 // Creality v4.5.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V453 4054 // Creality v4.5.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V521 4055 // Creality v5.2.1 (STM32F103VE) as found in the SV04 +#define BOARD_CREALITY_V24S1 4056 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 +#define BOARD_CREALITY_V24S1_301 4057 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 +#define BOARD_CREALITY_V25S1 4058 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro +#define BOARD_TRIGORILLA_PRO 4059 // Trigorilla Pro (STM32F103ZE) +#define BOARD_FLY_MINI 4060 // FLYmaker FLY MINI (STM32F103RC) +#define BOARD_FLSUN_HISPEED 4061 // FLSUN HiSpeedV1 (STM32F103VE) +#define BOARD_BEAST 4062 // STM32F103RE Libmaple-based controller +#define BOARD_MINGDA_MPX_ARM_MINI 4063 // STM32F103ZE Mingda MD-16 +#define BOARD_GTM32_PRO_VD 4064 // STM32F103VE controller +#define BOARD_ZONESTAR_ZM3E2 4065 // Zonestar ZM3E2 (STM32F103RC) +#define BOARD_ZONESTAR_ZM3E4 4066 // Zonestar ZM3E4 V1 (STM32F103VC) +#define BOARD_ZONESTAR_ZM3E4V2 4067 // Zonestar ZM3E4 V2 (STM32F103VC) +#define BOARD_ERYONE_ERY32_MINI 4068 // Eryone Ery32 mini (STM32F103VE) +#define BOARD_PANDA_PI_V29 4069 // Panda Pi V2.9 - Standalone (STM32F103RC) // @@ -422,7 +426,11 @@ #define BOARD_ARTILLERY_RUBY 4238 // Artillery Ruby (STM32F401RC) #define BOARD_FYSETC_SPIDER_V2_2 4239 // FYSETC Spider V2.2 (STM32F446VE) #define BOARD_CREALITY_V24S1_301F4 4240 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4 -#define BOARD_MKS_E3D_V2 4241 // MKS Robin E3D (STM32F401RCT6) +#define BOARD_OPULO_LUMEN_REV4 4241 // Opulo Lumen PnP Controller REV4 (STM32F407VE / STM32F407VG) +#define BOARD_FYSETC_SPIDER_KING407 4242 // FYSETC Spider King407 (STM32F407ZG) +#define BOARD_MKS_SKIPR_V1 4243 // MKS SKIPR v1.0 all-in-one board (STM32F407VE) +#define BOARD_TRONXY_V10 4244 // TRONXY V10 (STM32F446ZE) +#define BOARD_MKS_E3D_V2 4245 // MKS Robin E3D (STM32F401RCT6) // // ARM Cortex M7 @@ -460,6 +468,12 @@ #define BOARD_BRICOLEMON_V1_0 6101 // Bricolemon #define BOARD_BRICOLEMON_LITE_V1_0 6102 // Bricolemon Lite +// +// SAMD21 ARM Cortex M4 +// + +#define BOARD_MINITRONICS20 6103 // Minitronics v2.0 + // // Custom board // diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 8cf03d342a34..72a7d1f4b7eb 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -125,6 +125,8 @@ || AXIS_DRIVER_TYPE(A,TMC2660) \ || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) ) +#define AXIS_IS_TMC_CONFIG(A) ( AXIS_IS_TMC(A) || AXIS_DRIVER_TYPE(A,TMC26X) ) + // Test for a driver that uses SPI - this allows checking whether a _CS_ pin // is considered sensitive #define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \ diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 157bd6918515..545f9df6410b 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -174,6 +174,7 @@ #define STR_SD_VOL_INIT_FAIL "volume.init failed" #define STR_SD_OPENROOT_FAIL "openRoot failed" #define STR_SD_CARD_OK "SD card ok" +#define STR_SD_CARD_RELEASED "SD card released" #define STR_SD_WORKDIR_FAIL "workDir open failed" #define STR_SD_OPEN_FILE_FAIL "open failed, File: " #define STR_SD_FILE_OPENED "File opened: " diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index ddcf27b2b855..3029009c06b8 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(__has_include) +#ifndef __has_include #define __has_include(...) 1 #endif @@ -338,6 +338,12 @@ #define GANG_N_1(N,K) _GANG_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K) // Macros for initializing arrays +#define LIST_26(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z +#define LIST_25(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y +#define LIST_24(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X +#define LIST_23(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W +#define LIST_22(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V +#define LIST_21(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U #define LIST_20(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T #define LIST_19(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S #define LIST_18(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R @@ -732,6 +738,7 @@ #define MAPLIST(OP,V...) EVAL(_MAPLIST(OP,V)) // Temperature Sensor Config -#define _HAS_E_TEMP(N) || (TEMP_SENSOR_##N != 0) +#define TEMP_SENSOR(N) TEMP_SENSOR_##N +#define _HAS_E_TEMP(N) || TEMP_SENSOR(N) #define HAS_E_TEMP_SENSOR (0 REPEAT(EXTRUDERS, _HAS_E_TEMP)) -#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR_##T == -5 || TEMP_SENSOR_##T == -3 || TEMP_SENSOR_##T == -2) +#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR(T) == -5 || TEMP_SENSOR(T) == -3 || TEMP_SENSOR(T) == -2) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index c9bb7d8c30d1..61c182448e45 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -36,6 +36,8 @@ struct IF { typedef R type; }; template struct IF { typedef L type; }; +#define ALL_AXIS_NAMES X, X2, Y, Y2, Z, Z2, Z3, Z4, I, J, K, U, V, W, E0, E1, E2, E3, E4, E5, E6, E7 + #define NUM_AXIS_GANG(V...) GANG_N(NUM_AXES, V) #define NUM_AXIS_CODE(V...) CODE_N(NUM_AXES, V) #define NUM_AXIS_LIST(V...) LIST_N(NUM_AXES, V) @@ -99,8 +101,8 @@ struct Flags { void set(const int n) { b |= (bits_t)_BV(n); } void clear(const int n) { b &= ~(bits_t)_BV(n); } bool test(const int n) const { return TEST(b, n); } - const bool operator[](const int n) { return test(n); } - const bool operator[](const int n) const { return test(n); } + bool operator[](const int n) { return test(n); } + bool operator[](const int n) const { return test(n); } int size() const { return sizeof(b); } }; @@ -226,8 +228,8 @@ typedef const_float_t const_celsius_float_t; // Helpers #define _RECIP(N) ((N) ? 1.0f / static_cast(N) : 0.0f) #define _ABS(N) ((N) < 0 ? -(N) : (N)) -#define _LS(N) (N = (T)(uint32_t(N) << v)) -#define _RS(N) (N = (T)(uint32_t(N) >> v)) +#define _LS(N) (N = (T)(uint32_t(N) << p)) +#define _RS(N) (N = (T)(uint32_t(N) >> p)) #define FI FORCE_INLINE // Forward declarations @@ -307,9 +309,9 @@ typedef abce_float_t abce_pos_t; void toLogical(xy_pos_t &raw); void toLogical(xyz_pos_t &raw); void toLogical(xyze_pos_t &raw); -void toNative(xy_pos_t &raw); -void toNative(xyz_pos_t &raw); -void toNative(xyze_pos_t &raw); +void toNative(xy_pos_t &lpos); +void toNative(xyz_pos_t &lpos); +void toNative(xyze_pos_t &lpos); // // Paired XY coordinates, counters, flags, etc. @@ -347,6 +349,10 @@ struct XYval { FI operator T* () { return pos; } // If any element is true then it's true FI operator bool() { return x || y; } + // Smallest element + FI T small() const { return _MIN(x, y); } + // Largest element + FI T large() const { return _MAX(x, y); } // Explicit copy and copies with conversion FI XYval copy() const { return *this; } @@ -405,18 +411,18 @@ struct XYval { FI XYval operator* (const XYZEval &rs) { XYval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } FI XYval operator/ (const XYZEval &rs) const { XYval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } FI XYval operator/ (const XYZEval &rs) { XYval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYval operator* (const float &v) const { XYval ls = *this; ls.x *= v; ls.y *= v; return ls; } - FI XYval operator* (const float &v) { XYval ls = *this; ls.x *= v; ls.y *= v; return ls; } - FI XYval operator* (const int &v) const { XYval ls = *this; ls.x *= v; ls.y *= v; return ls; } - FI XYval operator* (const int &v) { XYval ls = *this; ls.x *= v; ls.y *= v; return ls; } - FI XYval operator/ (const float &v) const { XYval ls = *this; ls.x /= v; ls.y /= v; return ls; } - FI XYval operator/ (const float &v) { XYval ls = *this; ls.x /= v; ls.y /= v; return ls; } - FI XYval operator/ (const int &v) const { XYval ls = *this; ls.x /= v; ls.y /= v; return ls; } - FI XYval operator/ (const int &v) { XYval ls = *this; ls.x /= v; ls.y /= v; return ls; } - FI XYval operator>>(const int &v) const { XYval ls = *this; _RS(ls.x); _RS(ls.y); return ls; } - FI XYval operator>>(const int &v) { XYval ls = *this; _RS(ls.x); _RS(ls.y); return ls; } - FI XYval operator<<(const int &v) const { XYval ls = *this; _LS(ls.x); _LS(ls.y); return ls; } - FI XYval operator<<(const int &v) { XYval ls = *this; _LS(ls.x); _LS(ls.y); return ls; } + FI XYval operator* (const float &p) const { XYval ls = *this; ls.x *= p; ls.y *= p; return ls; } + FI XYval operator* (const float &p) { XYval ls = *this; ls.x *= p; ls.y *= p; return ls; } + FI XYval operator* (const int &p) const { XYval ls = *this; ls.x *= p; ls.y *= p; return ls; } + FI XYval operator* (const int &p) { XYval ls = *this; ls.x *= p; ls.y *= p; return ls; } + FI XYval operator/ (const float &p) const { XYval ls = *this; ls.x /= p; ls.y /= p; return ls; } + FI XYval operator/ (const float &p) { XYval ls = *this; ls.x /= p; ls.y /= p; return ls; } + FI XYval operator/ (const int &p) const { XYval ls = *this; ls.x /= p; ls.y /= p; return ls; } + FI XYval operator/ (const int &p) { XYval ls = *this; ls.x /= p; ls.y /= p; return ls; } + FI XYval operator>>(const int &p) const { XYval ls = *this; _RS(ls.x); _RS(ls.y); return ls; } + FI XYval operator>>(const int &p) { XYval ls = *this; _RS(ls.x); _RS(ls.y); return ls; } + FI XYval operator<<(const int &p) const { XYval ls = *this; _LS(ls.x); _LS(ls.y); return ls; } + FI XYval operator<<(const int &p) { XYval ls = *this; _LS(ls.x); _LS(ls.y); return ls; } FI const XYval operator-() const { XYval o = *this; o.x = -x; o.y = -y; return o; } FI XYval operator-() { XYval o = *this; o.x = -x; o.y = -y; return o; } @@ -430,21 +436,15 @@ struct XYval { FI XYval& operator+=(const XYZEval &rs) { x += rs.x; y += rs.y; return *this; } FI XYval& operator-=(const XYZEval &rs) { x -= rs.x; y -= rs.y; return *this; } FI XYval& operator*=(const XYZEval &rs) { x *= rs.x; y *= rs.y; return *this; } - FI XYval& operator*=(const float &v) { x *= v; y *= v; return *this; } - FI XYval& operator*=(const int &v) { x *= v; y *= v; return *this; } - FI XYval& operator>>=(const int &v) { _RS(x); _RS(y); return *this; } - FI XYval& operator<<=(const int &v) { _LS(x); _LS(y); return *this; } + FI XYval& operator*=(const float &p) { x *= p; y *= p; return *this; } + FI XYval& operator*=(const int &p) { x *= p; y *= p; return *this; } + FI XYval& operator>>=(const int &p) { _RS(x); _RS(y); return *this; } + FI XYval& operator<<=(const int &p) { _LS(x); _LS(y); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. - FI bool operator==(const XYval &rs) { return x == rs.x && y == rs.y; } - FI bool operator==(const XYZval &rs) { return x == rs.x && y == rs.y; } - FI bool operator==(const XYZEval &rs) { return x == rs.x && y == rs.y; } FI bool operator==(const XYval &rs) const { return x == rs.x && y == rs.y; } FI bool operator==(const XYZval &rs) const { return x == rs.x && y == rs.y; } FI bool operator==(const XYZEval &rs) const { return x == rs.x && y == rs.y; } - FI bool operator!=(const XYval &rs) { return !operator==(rs); } - FI bool operator!=(const XYZval &rs) { return !operator==(rs); } - FI bool operator!=(const XYZEval &rs) { return !operator==(rs); } FI bool operator!=(const XYval &rs) const { return !operator==(rs); } FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } @@ -494,10 +494,10 @@ struct XYZval { FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; } #endif #if HAS_V_AXIS - FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pu) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } #endif #if HAS_W_AXIS - FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm, const T po) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; v = pv; } + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pu, const T pv) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; v = pv; } #endif // Length reduced to one dimension @@ -506,6 +506,10 @@ struct XYZval { FI operator T* () { return pos; } // If any element is true then it's true FI operator bool() { return NUM_AXIS_GANG(x, || y, || z, || i, || j, || k, || u, || v, || w); } + // Smallest element + FI T small() const { return _MIN(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); } + // Largest element + FI T large() const { return _MAX(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); } // Explicit copy and copies with conversion FI XYZval copy() const { XYZval o = *this; return o; } @@ -565,18 +569,18 @@ struct XYZval { FI XYZval operator* (const XYZEval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } FI XYZval operator/ (const XYZEval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } FI XYZval operator/ (const XYZEval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZval operator* (const float &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZval operator* (const float &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZval operator* (const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZval operator* (const int &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZval operator/ (const float &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZval operator/ (const float &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZval operator/ (const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZval operator/ (const int &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZval operator>>(const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } - FI XYZval operator>>(const int &v) { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } - FI XYZval operator<<(const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } - FI XYZval operator<<(const int &v) { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI XYZval operator* (const float &p) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZval operator* (const float &p) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZval operator* (const int &p) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZval operator* (const int &p) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZval operator/ (const float &p) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZval operator/ (const float &p) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZval operator/ (const int &p) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZval operator/ (const int &p) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZval operator>>(const int &p) const { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZval operator>>(const int &p) { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZval operator<<(const int &p) const { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI XYZval operator<<(const int &p) { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } FI const XYZval operator-() const { XYZval o = *this; NUM_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k, o.u = -u, o.v = -v, o.w = -w); return o; } FI XYZval operator-() { XYZval o = *this; NUM_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k, o.u = -u, o.v = -v, o.w = -w); return o; } @@ -593,15 +597,13 @@ struct XYZval { FI XYZval& operator-=(const XYZEval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } FI XYZval& operator*=(const XYZEval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } FI XYZval& operator/=(const XYZEval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } - FI XYZval& operator*=(const float &v) { NUM_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; } - FI XYZval& operator*=(const int &v) { NUM_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; } - FI XYZval& operator>>=(const int &v) { NUM_AXIS_CODE(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } - FI XYZval& operator<<=(const int &v) { NUM_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } + FI XYZval& operator*=(const float &p) { NUM_AXIS_CODE(x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } + FI XYZval& operator*=(const int &p) { NUM_AXIS_CODE(x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } + FI XYZval& operator>>=(const int &p) { NUM_AXIS_CODE(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } + FI XYZval& operator<<=(const int &p) { NUM_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. - FI bool operator==(const XYZEval &rs) { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } FI bool operator==(const XYZEval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } - FI bool operator!=(const XYZEval &rs) { return !operator==(rs); } FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } }; @@ -634,10 +636,10 @@ struct XYZEval { FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; } #endif #if HAS_V_AXIS - FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pu) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } #endif #if HAS_W_AXIS - FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm, const T po) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pm; v = pv; } + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pu, const T pv) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; v = pv; } #endif // Setters taking struct types and arrays @@ -654,11 +656,15 @@ struct XYZEval { #endif // Length reduced to one dimension - FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k, + u*u, + v*v, + w*w)); } + FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k, + u*u, + v*v, + w*w)); } // Pointer to the data as a simple array - FI operator T* () { return pos; } + FI operator T* () { return pos; } // If any element is true then it's true - FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k, || u, || v, || w); } + FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k, || u, || v, || w); } + // Smallest element + FI T small() const { return _MIN(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } + // Largest element + FI T large() const { return _MAX(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } // Explicit copy and copies with conversion FI XYZEval copy() const { XYZEval v = *this; return v; } @@ -684,76 +690,76 @@ struct XYZEval { FI operator const XYZval&() const { return *(const XYZval*)this; } // Accessor via an AxisEnum (or any integer) [index] - FI T& operator[](const int n) { return pos[n]; } - FI const T& operator[](const int n) const { return pos[n]; } + FI T& operator[](const int n) { return pos[n]; } + FI const T& operator[](const int n) const { return pos[n]; } // Assignment operator overrides do the expected thing - FI XYZEval& operator= (const T v) { set(LOGICAL_AXIS_LIST_1(v)); return *this; } - FI XYZEval& operator= (const XYval &rs) { set(rs.x, rs.y); return *this; } - FI XYZEval& operator= (const XYZval &rs) { set(NUM_AXIS_ELEM(rs)); return *this; } + FI XYZEval& operator= (const T v) { set(LOGICAL_AXIS_LIST_1(v)); return *this; } + FI XYZEval& operator= (const XYval &rs) { set(rs.x, rs.y); return *this; } + FI XYZEval& operator= (const XYZval &rs) { set(NUM_AXIS_ELEM(rs)); return *this; } // Override other operators to get intuitive behaviors - FI XYZEval operator+ (const XYval &rs) const { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZEval operator+ (const XYval &rs) { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZEval operator- (const XYval &rs) const { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZEval operator- (const XYval &rs) { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZEval operator* (const XYval &rs) const { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZEval operator* (const XYval &rs) { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZEval operator/ (const XYval &rs) const { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZEval operator/ (const XYval &rs) { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZEval operator+ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } - FI XYZEval operator+ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } - FI XYZEval operator- (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } - FI XYZEval operator- (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } - FI XYZEval operator* (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } - FI XYZEval operator* (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } - FI XYZEval operator/ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZEval operator/ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZEval operator+ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } - FI XYZEval operator+ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } - FI XYZEval operator- (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } - FI XYZEval operator- (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } - FI XYZEval operator* (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } - FI XYZEval operator* (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } - FI XYZEval operator/ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZEval operator/ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZEval operator* (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZEval operator* (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZEval operator* (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZEval operator* (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZEval operator/ (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZEval operator/ (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZEval operator/ (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZEval operator/ (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZEval operator>>(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } - FI XYZEval operator>>(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } - FI XYZEval operator<<(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } - FI XYZEval operator<<(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } - FI const XYZEval operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } - FI XYZEval operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } + FI XYZEval operator+ (const XYval &rs) const { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } + FI XYZEval operator+ (const XYval &rs) { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } + FI XYZEval operator- (const XYval &rs) const { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } + FI XYZEval operator- (const XYval &rs) { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } + FI XYZEval operator* (const XYval &rs) const { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } + FI XYZEval operator* (const XYval &rs) { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } + FI XYZEval operator/ (const XYval &rs) const { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } + FI XYZEval operator/ (const XYval &rs) { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } + FI XYZEval operator+ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator+ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator- (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator- (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator* (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator* (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator/ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator/ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator+ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator+ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator- (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator- (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator* (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator* (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator/ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator/ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator* (const float &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= p, ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZEval operator* (const float &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= p, ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZEval operator* (const int &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= p, ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZEval operator* (const int &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= p, ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZEval operator/ (const float &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= p, ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZEval operator/ (const float &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= p, ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZEval operator/ (const int &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= p, ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZEval operator/ (const int &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= p, ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZEval operator>>(const int &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZEval operator>>(const int &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZEval operator<<(const int &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI XYZEval operator<<(const int &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI const XYZEval operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } + FI XYZEval operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } // Modifier operators - FI XYZEval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } - FI XYZEval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } - FI XYZEval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } - FI XYZEval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } - FI XYZEval& operator+=(const XYZval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } - FI XYZEval& operator-=(const XYZval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } - FI XYZEval& operator*=(const XYZval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } - FI XYZEval& operator/=(const XYZval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } - FI XYZEval& operator+=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } - FI XYZEval& operator-=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } - FI XYZEval& operator*=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } - FI XYZEval& operator/=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } - FI XYZEval& operator*=(const T &v) { LOGICAL_AXIS_CODE(e *= v, x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; } - FI XYZEval& operator>>=(const int &v) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } - FI XYZEval& operator<<=(const int &v) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } + FI XYZEval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } + FI XYZEval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } + FI XYZEval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } + FI XYZEval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } + FI XYZEval& operator+=(const XYZval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } + FI XYZEval& operator-=(const XYZval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } + FI XYZEval& operator*=(const XYZval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } + FI XYZEval& operator/=(const XYZval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } + FI XYZEval& operator+=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } + FI XYZEval& operator-=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } + FI XYZEval& operator*=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } + FI XYZEval& operator/=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } + FI XYZEval& operator*=(const T &p) { LOGICAL_AXIS_CODE(e *= p, x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } + FI XYZEval& operator>>=(const int &p) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } + FI XYZEval& operator<<=(const int &p) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. - FI bool operator==(const XYZval &rs) { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } - FI bool operator==(const XYZval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } - FI bool operator!=(const XYZval &rs) { return !operator==(rs); } - FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } + FI bool operator==(const XYZval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } + FI bool operator==(const XYZEval &rs) const { return true LOGICAL_AXIS_GANG(&& e == rs.e, && x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } + FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } + FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } }; #undef _RECIP diff --git a/Marlin/src/feature/bedlevel/bdl/bdl.cpp b/Marlin/src/feature/bedlevel/bdl/bdl.cpp index 0668eb705c5b..1a27011a4b8f 100644 --- a/Marlin/src/feature/bedlevel/bdl/bdl.cpp +++ b/Marlin/src/feature/bedlevel/bdl/bdl.cpp @@ -96,22 +96,23 @@ void BDS_Leveling::process() { const float z_sensor = (tmp & 0x3FF) / 100.0f; if (cur_z < 0) config_state = 0; //float abs_z = current_position.z > cur_z ? (current_position.z - cur_z) : (cur_z - current_position.z); - if ( cur_z < config_state * 0.1f - && config_state > 0 - && old_cur_z == cur_z - && old_buf_z == current_position.z - && z_sensor < (MAX_BD_HEIGHT) - ) { - babystep.set_mm(Z_AXIS, cur_z - z_sensor); - #if ENABLED(DEBUG_OUT_BD) - SERIAL_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z); - #endif - } - else { - babystep.set_mm(Z_AXIS, 0); - //if (old_cur_z <= cur_z) Z_DIR_WRITE(!INVERT_Z_DIR); - stepper.set_directions(); - } + #if ENABLED(BABYSTEPPING) + if (cur_z < config_state * 0.1f + && config_state > 0 + && old_cur_z == cur_z + && old_buf_z == current_position.z + && z_sensor < (MAX_BD_HEIGHT) + ) { + babystep.set_mm(Z_AXIS, cur_z - z_sensor); + #if ENABLED(DEBUG_OUT_BD) + SERIAL_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z); + #endif + } + else { + babystep.set_mm(Z_AXIS, 0); //if (old_cur_z <= cur_z) Z_DIR_WRITE(!INVERT_Z_DIR); + stepper.set_directions(); + } + #endif old_cur_z = cur_z; old_buf_z = current_position.z; endstops.bdp_state_update(z_sensor <= 0.01f); diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 2207884c3637..03b67745ec16 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -57,6 +57,7 @@ bool leveling_is_valid() { * Enable: Current position = "unleveled" physical position */ void set_bed_leveling_enabled(const bool enable/*=true*/) { + DEBUG_SECTION(log_sble, "set_bed_leveling_enabled", DEBUGGING(LEVELING)); const bool can_change = TERN1(AUTO_BED_LEVELING_BILINEAR, !enable || leveling_is_valid()); @@ -75,9 +76,9 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) { planner.synchronize(); // Get the corrected leveled / unleveled position - planner.apply_modifiers(current_position); // Physical position with all modifiers - planner.leveling_active ^= true; // Toggle leveling between apply and unapply - planner.unapply_modifiers(current_position); // Logical position with modifiers removed + planner.apply_modifiers(current_position, true); // Physical position with all modifiers + planner.leveling_active ^= true; // Toggle leveling between apply and unapply + planner.unapply_modifiers(current_position, true); // Logical position with modifiers removed sync_plan_position(); _report_leveling(); diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index 1a8e693e8180..aa97cb57ba98 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -109,7 +109,7 @@ class mesh_bed_leveling { static float get_z_correction(const xy_pos_t &pos) { const xy_int8_t ind = cell_indexes(pos); const float x1 = index_to_xpos[ind.x], x2 = index_to_xpos[ind.x+1], - y1 = index_to_xpos[ind.y], y2 = index_to_xpos[ind.y+1], + y1 = index_to_ypos[ind.y], y2 = index_to_ypos[ind.y+1], z1 = calc_z0(pos.x, x1, z_values[ind.x][ind.y ], x2, z_values[ind.x+1][ind.y ]), z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]), zf = calc_z0(pos.y, y1, z1, y2, z2); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 2aa50be34d26..f2af1445b1f0 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -260,7 +260,7 @@ bool unified_bed_leveling::sanity_check() { */ void GcodeSuite::M1004() { - #define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34", "") + #define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34\n", "") #define PROBE_GCODE TERN(HAS_BED_PROBE, "G29P1\nG29P3", "G29P4R") #if HAS_HOTEND @@ -280,7 +280,7 @@ bool unified_bed_leveling::sanity_check() { #endif process_subcommands_now(FPSTR(G28_STR)); // Home - process_subcommands_now(F(ALIGN_GCODE "\n" // Align multi z axis if available + process_subcommands_now(F(ALIGN_GCODE // Align multi z axis if available PROBE_GCODE "\n" // Build mesh with available hardware "G29P3\nG29P3")); // Ensure mesh is complete by running smart fill twice diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index f1e88006ff82..d6cb0b762ff2 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -407,7 +407,7 @@ void unified_bed_leveling::G29() { z_values[x][x2] += 9.999f; // We want the altered line several mesh points thick #if ENABLED(EXTENSIBLE_UI) ExtUI::onMeshUpdate(x, x, z_values[x][x]); - ExtUI::onMeshUpdate(x, (x2), z_values[x][x2]); + ExtUI::onMeshUpdate(x, x2, z_values[x][x2]); #endif } break; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index 18110c67fa8e..96c30a0efd89 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -336,9 +336,9 @@ #if IS_SCARA #define DELTA_SEGMENT_MIN_LENGTH 0.25 // SCARA minimum segment size is 0.25mm #elif ENABLED(DELTA) - #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DELTA_SEGMENTS_PER_SECOND) + #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DEFAULT_SEGMENTS_PER_SECOND) #elif ENABLED(POLARGRAPH) - #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DELTA_SEGMENTS_PER_SECOND) + #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DEFAULT_SEGMENTS_PER_SECOND) #else // CARTESIAN #ifdef LEVELED_SEGMENT_LENGTH #define DELTA_SEGMENT_MIN_LENGTH LEVELED_SEGMENT_LENGTH @@ -423,10 +423,12 @@ LIMIT(icell.x, 0, GRID_MAX_CELLS_X); LIMIT(icell.y, 0, GRID_MAX_CELLS_Y); - float z_x0y0 = z_values[icell.x ][icell.y ], // z at lower left corner - z_x1y0 = z_values[icell.x+1][icell.y ], // z at upper left corner - z_x0y1 = z_values[icell.x ][icell.y+1], // z at lower right corner - z_x1y1 = z_values[icell.x+1][icell.y+1]; // z at upper right corner + const int8_t ncellx = _MIN(icell.x+1, GRID_MAX_CELLS_X), + ncelly = _MIN(icell.y+1, GRID_MAX_CELLS_Y); + float z_x0y0 = z_values[icell.x][icell.y], // z at lower left corner + z_x1y0 = z_values[ncellx ][icell.y], // z at upper left corner + z_x0y1 = z_values[icell.x][ncelly ], // z at lower right corner + z_x1y1 = z_values[ncellx ][ncelly ]; // z at upper right corner if (isnan(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A) if (isnan(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 10d3131aedcb..fe56341a47ec 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -38,8 +38,6 @@ bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drai #include "../module/servo.h" #include "../module/probe.h" -void stop(); - #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../core/debug_out.h" diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index f42bf52ae40a..6e5278ce7451 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -40,6 +40,9 @@ uint8_t ControllerFan::speed; void ControllerFan::setup() { SET_OUTPUT(CONTROLLER_FAN_PIN); + #ifdef CONTROLLER_FAN2_PIN + SET_OUTPUT(CONTROLLER_FAN2_PIN); + #endif init(); } @@ -72,6 +75,22 @@ void ControllerFan::update() { ? settings.active_speed : settings.idle_speed ); + speed = CALC_FAN_SPEED(speed); + + #if FAN_KICKSTART_TIME + static millis_t fan_kick_end = 0; + if (speed > FAN_OFF_PWM) { + if (!fan_kick_end) { + fan_kick_end = ms + FAN_KICKSTART_TIME; // May be longer based on slow update interval for controller fn check. Sets minimum + speed = FAN_KICKSTART_POWER; + } + else if (PENDING(ms, fan_kick_end)) + speed = FAN_KICKSTART_POWER; + } + else + fan_kick_end = 0; + #endif + #if ENABLED(FAN_SOFT_PWM) thermalManager.soft_pwm_controller_speed = speed; #else @@ -79,6 +98,13 @@ void ControllerFan::update() { hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); else WRITE(CONTROLLER_FAN_PIN, speed > 0); + + #ifdef CONTROLLER_FAN2_PIN + if (PWM_PIN(CONTROLLER_FAN2_PIN)) + hal.set_pwm_duty(pin_t(CONTROLLER_FAN2_PIN), speed); + else + WRITE(CONTROLLER_FAN2_PIN, speed > 0); + #endif #endif } } diff --git a/Marlin/src/feature/e_parser.cpp b/Marlin/src/feature/e_parser.cpp index d98afcfee71b..cfe0956aa789 100644 --- a/Marlin/src/feature/e_parser.cpp +++ b/Marlin/src/feature/e_parser.cpp @@ -33,6 +33,9 @@ // Static data members bool EmergencyParser::killed_by_M112, // = false EmergencyParser::quickstop_by_M410, + #if ENABLED(SDSUPPORT) + EmergencyParser::sd_abort_by_M524, + #endif EmergencyParser::enabled; #if ENABLED(HOST_PROMPT_SUPPORT) diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index fda1ba144bc4..3a15a7ffa0f9 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -49,7 +49,7 @@ class EmergencyParser { public: - // Currently looking for: M108, M112, M410, M876 S[0-9], S000, P000, R000 + // Currently looking for: M108, M112, M410, M524, M876 S[0-9], S000, P000, R000 enum State : uint8_t { EP_RESET, EP_N, @@ -58,6 +58,9 @@ class EmergencyParser { EP_M10, EP_M108, EP_M11, EP_M112, EP_M4, EP_M41, EP_M410, + #if ENABLED(SDSUPPORT) + EP_M5, EP_M52, EP_M524, + #endif #if ENABLED(HOST_PROMPT_SUPPORT) EP_M8, EP_M87, EP_M876, EP_M876S, EP_M876SN, #endif @@ -76,6 +79,10 @@ class EmergencyParser { static bool killed_by_M112; static bool quickstop_by_M410; + #if ENABLED(SDSUPPORT) + static bool sd_abort_by_M524; + #endif + #if ENABLED(HOST_PROMPT_SUPPORT) static uint8_t M876_reason; #endif @@ -145,6 +152,9 @@ class EmergencyParser { case ' ': break; case '1': state = EP_M1; break; case '4': state = EP_M4; break; + #if ENABLED(SDSUPPORT) + case '5': state = EP_M5; break; + #endif #if ENABLED(HOST_PROMPT_SUPPORT) case '8': state = EP_M8; break; #endif @@ -165,6 +175,11 @@ class EmergencyParser { case EP_M4: state = (c == '1') ? EP_M41 : EP_IGNORE; break; case EP_M41: state = (c == '0') ? EP_M410 : EP_IGNORE; break; + #if ENABLED(SDSUPPORT) + case EP_M5: state = (c == '2') ? EP_M52 : EP_IGNORE; break; + case EP_M52: state = (c == '4') ? EP_M524 : EP_IGNORE; break; + #endif + #if ENABLED(HOST_PROMPT_SUPPORT) case EP_M8: state = (c == '7') ? EP_M87 : EP_IGNORE; break; @@ -200,6 +215,9 @@ class EmergencyParser { case EP_M108: wait_for_user = wait_for_heatup = false; break; case EP_M112: killed_by_M112 = true; break; case EP_M410: quickstop_by_M410 = true; break; + #if ENABLED(SDSUPPORT) + case EP_M524: sd_abort_by_M524 = true; break; + #endif #if ENABLED(HOST_PROMPT_SUPPORT) case EP_M876SN: hostui.handle_response(M876_reason); break; #endif diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index c03a6bc5976e..773b6ebc61a4 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -111,20 +111,29 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { if (eol) SERIAL_EOL(); } - void HostUI::prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char/*='\0'*/) { + void HostUI::prompt_plus(const bool pgm, FSTR_P const ptype, const char * const str, const char extra_char/*='\0'*/) { prompt(ptype, false); PORT_REDIRECT(SerialMask::All); SERIAL_CHAR(' '); - SERIAL_ECHOF(fstr); + if (pgm) + SERIAL_ECHOPGM_P(str); + else + SERIAL_ECHO(str); if (extra_char != '\0') SERIAL_CHAR(extra_char); SERIAL_EOL(); } + void HostUI::prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) { prompt_end(); host_prompt_reason = reason; prompt_plus(F("begin"), fstr, extra_char); } - void HostUI::prompt_button(FSTR_P const fstr) { prompt_plus(F("button"), fstr); } + void HostUI::prompt_begin(const PromptReason reason, const char * const cstr, const char extra_char/*='\0'*/) { + prompt_end(); + host_prompt_reason = reason; + prompt_plus(F("begin"), cstr, extra_char); + } + void HostUI::prompt_end() { prompt(F("end")); } void HostUI::prompt_show() { prompt(F("show")); } @@ -133,14 +142,26 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { if (btn2) prompt_button(btn2); prompt_show(); } + + void HostUI::prompt_button(FSTR_P const fstr) { prompt_plus(F("button"), fstr); } + void HostUI::prompt_button(const char * const cstr) { prompt_plus(F("button"), cstr); } + void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { prompt_begin(reason, fstr); _prompt_show(btn1, btn2); } + void HostUI::prompt_do(const PromptReason reason, const char * const cstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { + prompt_begin(reason, cstr); + _prompt_show(btn1, btn2); + } void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { prompt_begin(reason, fstr, extra_char); _prompt_show(btn1, btn2); } + void HostUI::prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { + prompt_begin(reason, cstr, extra_char); + _prompt_show(btn1, btn2); + } #if ENABLED(ADVANCED_PAUSE_FEATURE) void HostUI::filament_load_prompt() { diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index 41d66b82ec9b..3f75562398ec 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -79,7 +79,14 @@ class HostUI { #if ENABLED(HOST_PROMPT_SUPPORT) private: static void prompt(FSTR_P const ptype, const bool eol=true); - static void prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0'); + static void prompt_plus(const bool pgm, FSTR_P const ptype, const char * const str, const char extra_char='\0'); + static void prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0') { + prompt_plus(true, ptype, FTOP(fstr), extra_char); + } + static void prompt_plus(FSTR_P const ptype, const char * const cstr, const char extra_char='\0') { + prompt_plus(false, ptype, cstr, extra_char); + } + static void prompt_show(); static void _prompt_show(FSTR_P const btn1, FSTR_P const btn2); @@ -93,10 +100,17 @@ class HostUI { static void notify(const char * const message); static void prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0'); - static void prompt_button(FSTR_P const fstr); + static void prompt_begin(const PromptReason reason, const char * const cstr, const char extra_char='\0'); static void prompt_end(); + + static void prompt_button(FSTR_P const fstr); + static void prompt_button(const char * const cstr); + static void prompt_do(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); + static void prompt_do(const PromptReason reason, const char * const cstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); static void prompt_do(const PromptReason reason, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); + static void prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); + static void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) { if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2); } diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 2a53a7c884e6..3753235ab5e7 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -30,18 +30,6 @@ #include "leds.h" -#if ENABLED(BLINKM) - #include "blinkm.h" -#endif - -#if ENABLED(PCA9632) - #include "pca9632.h" -#endif - -#if ENABLED(PCA9533) - #include "pca9533.h" -#endif - #if EITHER(CASE_LIGHT_USE_RGB_LED, CASE_LIGHT_USE_NEOPIXEL) #include "../../feature/caselight.h" #endif @@ -69,6 +57,44 @@ void LEDLights::setup() { #if ENABLED(RGBW_LED) if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN); #endif + + #if ENABLED(RGB_STARTUP_TEST) + int8_t led_pin_count = 0; + if (PWM_PIN(RGB_LED_R_PIN) && PWM_PIN(RGB_LED_G_PIN) && PWM_PIN(RGB_LED_B_PIN)) led_pin_count = 3; + #if ENABLED(RGBW_LED) + if (PWM_PIN(RGB_LED_W_PIN) && led_pin_count) led_pin_count++; + #endif + // Startup animation + if (led_pin_count) { + // blackout + if (PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), 0); else WRITE(RGB_LED_R_PIN, LOW); + if (PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), 0); else WRITE(RGB_LED_G_PIN, LOW); + if (PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), 0); else WRITE(RGB_LED_B_PIN, LOW); + #if ENABLED(RGBW_LED) + if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), 0); + else WRITE(RGB_LED_W_PIN, LOW); + #endif + delay(200); + + LOOP_L_N(i, led_pin_count) { + LOOP_LE_N(b, 200) { + const uint16_t led_pwm = b <= 100 ? b : 200 - b; + if (i == 0 && PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), led_pwm); else WRITE(RGB_LED_R_PIN, b < 100 ? HIGH : LOW); + if (i == 1 && PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), led_pwm); else WRITE(RGB_LED_G_PIN, b < 100 ? HIGH : LOW); + if (i == 2 && PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), led_pwm); else WRITE(RGB_LED_B_PIN, b < 100 ? HIGH : LOW); + #if ENABLED(RGBW_LED) + if (i == 3){ + if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), led_pwm); + else WRITE(RGB_LED_W_PIN, b < 100 ? HIGH : LOW); + delay(RGB_STARTUP_TEST_INNER_MS);//More slowing for ending + } + #endif + delay(RGB_STARTUP_TEST_INNER_MS); + } + } + delay(500); + } + #endif // RGB_STARTUP_TEST #endif TERN_(NEOPIXEL_LED, neo.init()); TERN_(PCA9533, PCA9533_init()); diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 8649dd014fbf..c6137b45c355 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -40,6 +40,18 @@ #undef _NEOPIXEL_INCLUDE_ #endif +#if ENABLED(BLINKM) + #include "blinkm.h" +#endif + +#if ENABLED(PCA9533) + #include "pca9533.h" +#endif + +#if ENABLED(PCA9632) + #include "pca9632.h" +#endif + /** * LEDcolor type for use with leds.set_color */ @@ -107,6 +119,13 @@ typedef struct LEDColor { class LEDLights { public: + #if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED) + static LEDColor color; // last non-off color + static bool lights_on; // the last set color was "on" + #else + static constexpr bool lights_on = true; + #endif + LEDLights() {} // ctor static void setup(); // init() @@ -142,15 +161,10 @@ class LEDLights { static LEDColor get_color() { return lights_on ? color : LEDColorOff(); } #endif - #if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED) - static LEDColor color; // last non-off color - static bool lights_on; // the last set color was "on" - #endif - #if ENABLED(LED_CONTROL_MENU) static void toggle(); // swap "off" with color #endif - #if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED) + #if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED) || LED_POWEROFF_TIMEOUT > 0 static void update() { set_color(color); } #endif diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 4f104234f15c..ab7ffe217796 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -108,7 +108,7 @@ void Marlin_NeoPixel::init() { set_color(adaneo1.Color TERN(LED_USER_PRESET_STARTUP, (LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE), - (255, 255, 255, 255)) + (0, 0, 0, 0)) ); } diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index a4718b53d9d8..4f86578a60a7 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -54,7 +54,8 @@ MMU2 mmu2; #define MMU_CMD_TIMEOUT 45000UL // 45s timeout for mmu commands (except P0) #define MMU_P0_TIMEOUT 3000UL // Timeout for P0 command: 3seconds -#define MMU2_COMMAND(S) tx_str(F(S "\n")) +#define MMU2_SEND(S) tx_str(F(S "\n")) +#define MMU2_RECV(S) rx_str(F(S "\n")) #if ENABLED(MMU_EXTRUDER_SENSOR) uint8_t mmu_idl_sens = 0; @@ -131,7 +132,7 @@ void MMU2::reset() { safe_delay(20); WRITE(MMU2_RST_PIN, HIGH); #else - MMU2_COMMAND("X0"); // Send soft reset + MMU2_SEND("X0"); // Send soft reset #endif } @@ -157,11 +158,9 @@ void MMU2::mmu_loop() { case -1: if (rx_start()) { prev_P0_request = millis(); // Initialize finda sensor timeout - DEBUG_ECHOLNPGM("MMU => 'start'"); DEBUG_ECHOLNPGM("MMU <= 'S1'"); - - MMU2_COMMAND("S1"); // Read Version + MMU2_SEND("S1"); // Read Version state = -2; } else if (millis() > 30000) { // 30sec after reset disable MMU @@ -173,10 +172,8 @@ void MMU2::mmu_loop() { case -2: if (rx_ok()) { sscanf(rx_buffer, "%huok\n", &version); - DEBUG_ECHOLNPGM("MMU => ", version, "\nMMU <= 'S2'"); - - MMU2_COMMAND("S2"); // Read Build Number + MMU2_SEND("S2"); // Read Build Number state = -3; } break; @@ -191,14 +188,12 @@ void MMU2::mmu_loop() { #if ENABLED(MMU2_MODE_12V) DEBUG_ECHOLNPGM("MMU <= 'M1'"); - - MMU2_COMMAND("M1"); // Stealth Mode + MMU2_SEND("M1"); // Stealth Mode state = -5; #else DEBUG_ECHOLNPGM("MMU <= 'P0'"); - - MMU2_COMMAND("P0"); // Read FINDA + MMU2_SEND("P0"); // Read FINDA state = -4; #endif } @@ -209,10 +204,8 @@ void MMU2::mmu_loop() { // response to M1 if (rx_ok()) { DEBUG_ECHOLNPGM("MMU => ok"); - DEBUG_ECHOLNPGM("MMU <= 'P0'"); - - MMU2_COMMAND("P0"); // Read FINDA + MMU2_SEND("P0"); // Read FINDA state = -4; } break; @@ -250,14 +243,13 @@ void MMU2::mmu_loop() { else if (cmd == MMU_CMD_C0) { // continue loading DEBUG_ECHOLNPGM("MMU <= 'C0'"); - MMU2_COMMAND("C0"); + MMU2_SEND("C0"); state = 3; // wait for response } else if (cmd == MMU_CMD_U0) { // unload current DEBUG_ECHOLNPGM("MMU <= 'U0'"); - - MMU2_COMMAND("U0"); + MMU2_SEND("U0"); state = 3; // wait for response } else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E0 + EXTRUDERS - 1)) { @@ -270,7 +262,7 @@ void MMU2::mmu_loop() { else if (cmd == MMU_CMD_R0) { // recover after eject DEBUG_ECHOLNPGM("MMU <= 'R0'"); - MMU2_COMMAND("R0"); + MMU2_SEND("R0"); state = 3; // wait for response } else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F0 + EXTRUDERS - 1)) { @@ -285,7 +277,7 @@ void MMU2::mmu_loop() { cmd = MMU_CMD_NONE; } else if (ELAPSED(millis(), prev_P0_request + 300)) { - MMU2_COMMAND("P0"); // Read FINDA + MMU2_SEND("P0"); // Read FINDA state = 2; // wait for response } @@ -314,7 +306,7 @@ void MMU2::mmu_loop() { if (mmu_idl_sens) { if (FILAMENT_PRESENT() && mmu_loading_flag) { DEBUG_ECHOLNPGM("MMU <= 'A'"); - MMU2_COMMAND("A"); // send 'abort' request + MMU2_SEND("A"); // send 'abort' request mmu_idl_sens = 0; DEBUG_ECHOLNPGM("MMU IDLER_SENSOR = 0 - ABORT"); } @@ -327,9 +319,9 @@ void MMU2::mmu_loop() { const bool keep_trying = !mmu2s_triggered && last_cmd == MMU_CMD_C0; if (keep_trying) { // MMU ok received but filament sensor not triggered, retrying... - DEBUG_ECHOLNPGM("MMU => 'ok' (filament not present in gears)"); + DEBUG_ECHOLNPGM("MMU => 'ok' (no filament in gears)"); DEBUG_ECHOLNPGM("MMU <= 'C0' (keep trying)"); - MMU2_COMMAND("C0"); + MMU2_SEND("C0"); } #else constexpr bool keep_trying = false; @@ -361,7 +353,7 @@ void MMU2::mmu_loop() { */ bool MMU2::rx_start() { // check for start message - return rx_str(F("start\n")); + return MMU2_RECV("start"); } /** @@ -440,7 +432,7 @@ void MMU2::clear_rx_buffer() { * Check if we received 'ok' from MMU */ bool MMU2::rx_ok() { - if (rx_str(F("ok\n"))) { + if (MMU2_RECV("ok")) { prev_P0_request = millis(); return true; } @@ -585,7 +577,7 @@ static void mmu2_not_responding() { command(MMU_CMD_T0 + index); manage_response(true, true); mmu_continue_loading(); - command(MMU_CMD_C0); + //command(MMU_CMD_C0); extruder = index; active_extruder = 0; @@ -653,13 +645,34 @@ static void mmu2_not_responding() { } void MMU2::mmu_continue_loading() { + // Try to load the filament a limited number of times + bool fil_present = 0; for (uint8_t i = 0; i < MMU_LOADING_ATTEMPTS_NR; i++) { - DEBUG_ECHOLNPGM("Additional load attempt #", i); - if (FILAMENT_PRESENT()) break; + DEBUG_ECHOLNPGM("Load attempt #", i + 1); + + // Done as soon as filament is present + fil_present = FILAMENT_PRESENT(); + if (fil_present) break; + + // Attempt to load the filament, 1mm at a time, for 3s command(MMU_CMD_C0); + stepper.enable_extruder(); + const millis_t expire_ms = millis() + 3000; + do { + current_position.e += 1; + line_to_current_position(MMU_LOAD_FEEDRATE); + planner.synchronize(); + // When (T0 rx->ok) load is ready, but in fact it did not load + // successfully or an overload created pressure in the extruder. + // Send (C0) to load more and move E_AXIS a little to release pressure. + if ((fil_present = FILAMENT_PRESENT())) MMU2_SEND("A"); + } while (!fil_present && PENDING(millis(), expire_ms)); + stepper.disable_extruder(); manage_response(true, true); } - if (!FILAMENT_PRESENT()) { + + // Was the filament still missing in the last check? + if (!fil_present) { DEBUG_ECHOLNPGM("Filament never reached sensor, runout"); filament_runout(); } @@ -682,7 +695,7 @@ static void mmu2_not_responding() { command(MMU_CMD_T0 + index); manage_response(true, true); command(MMU_CMD_C0); - extruder = index; //filament change is finished + extruder = index; // Filament change is finished active_extruder = 0; stepper.enable_extruder(); SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder); @@ -861,7 +874,7 @@ void MMU2::filament_runout() { if (cmd == MMU_CMD_NONE && last_cmd == MMU_CMD_C0) { if (present && !mmu2s_triggered) { DEBUG_ECHOLNPGM("MMU <= 'A'"); - tx_str(F("A\n")); + MMU2_SEND("A"); } // Slowly spin the extruder during C0 else { diff --git a/Marlin/src/feature/mmu/mmu2.h b/Marlin/src/feature/mmu/mmu2.h index 7d3d9ec4df38..18d6d38a359d 100644 --- a/Marlin/src/feature/mmu/mmu2.h +++ b/Marlin/src/feature/mmu/mmu2.h @@ -86,6 +86,7 @@ class MMU2 { #endif #if ENABLED(MMU_EXTRUDER_SENSOR) + #define MMU_LOAD_FEEDRATE 19.02f // (mm/s) static void mmu_continue_loading(); #endif diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 1c2ea59d4daf..83d149fa09e7 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -211,7 +211,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load while (wait_for_user) { impatient_beep(max_beep_count); #if BOTH(FILAMENT_CHANGE_RESUME_ON_INSERT, FILAMENT_RUNOUT_SENSOR) - #if ENABLED(MULTI_FILAMENT_SENSOR) + #if MULTI_FILAMENT_SENSOR #define _CASE_INSERTED(N) case N-1: if (READ(FIL_RUNOUT##N##_PIN) != FIL_RUNOUT##N##_STATE) wait_for_user = false; break; switch (active_extruder) { REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_INSERTED) @@ -410,7 +410,6 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool #endif TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR))); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); // Indicate that the printer is paused ++did_pause_print; @@ -461,6 +460,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool // If axes don't need to home then the nozzle can park if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move + TERN_(DWIN_LCD_PROUI, if (!do_park) ui.set_status(GET_TEXT_F(MSG_PARK_FAILED))); #if ENABLED(DUAL_X_CARRIAGE) const int8_t saved_ext = active_extruder; @@ -472,9 +472,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool if (unload_length) unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT); - #if ENABLED(DUAL_X_CARRIAGE) - set_duplication_enabled(saved_ext_dup_mode, saved_ext); - #endif + TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext)); // Disable the Extruder for manual change disable_active_extruder(); @@ -580,9 +578,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep } idle_no_sleep(); } - #if ENABLED(DUAL_X_CARRIAGE) - set_duplication_enabled(saved_ext_dup_mode, saved_ext); - #endif + TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext)); } /** @@ -714,13 +710,8 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ TERN_(HAS_FILAMENT_SENSOR, runout.reset()); - #if ENABLED(DWIN_LCD_PROUI) - DWIN_Print_Resume(); - HMI_ReturnScreen(); - #else - ui.reset_status(); - ui.return_to_status(); - #endif + ui.reset_status(); + ui.return_to_status(); } #endif // ADVANCED_PAUSE_FEATURE diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index 5a9db1ec24a1..e3c3e58fc412 100644 --- a/Marlin/src/feature/power_monitor.cpp +++ b/Marlin/src/feature/power_monitor.cpp @@ -53,7 +53,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_current() { const float amps = getAmps(); lcd_put_u8str(amps < 100 ? ftostr31ns(amps) : ui16tostr4rj((uint16_t)amps)); - lcd_put_lchar('A'); + lcd_put_u8str(F("A")); } #endif @@ -61,7 +61,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_voltage() { const float volts = getVolts(); lcd_put_u8str(volts < 100 ? ftostr31ns(volts) : ui16tostr4rj((uint16_t)volts)); - lcd_put_lchar('V'); + lcd_put_u8str(F("V")); } #endif @@ -69,7 +69,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_power() { const float power = getPower(); lcd_put_u8str(power < 100 ? ftostr31ns(power) : ui16tostr4rj((uint16_t)power)); - lcd_put_lchar('W'); + lcd_put_u8str(F("W")); } #endif diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 33d9dc007c0d..4bf0c06e2d7e 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -153,6 +153,9 @@ class PrintJobRecovery { static void prepare(); static void setup() { + #if PIN_EXISTS(OUTAGECON) + OUT_WRITE(OUTAGECON_PIN, HIGH); + #endif #if PIN_EXISTS(POWER_LOSS) #if ENABLED(POWER_LOSS_PULLUP) SET_INPUT_PULLUP(POWER_LOSS_PIN); diff --git a/Marlin/src/feature/repeat.cpp b/Marlin/src/feature/repeat.cpp index 165f71fd0fae..fed7ac0908a0 100644 --- a/Marlin/src/feature/repeat.cpp +++ b/Marlin/src/feature/repeat.cpp @@ -42,7 +42,7 @@ void Repeat::add_marker(const uint32_t sdpos, const uint16_t count) { SERIAL_ECHO_MSG("!Too many markers."); else { marker[index].sdpos = sdpos; - marker[index].counter = count ?: -1; + marker[index].counter = count ? count - 1 : -1; index++; DEBUG_ECHOLNPGM("Add Marker ", index, " at ", sdpos, " (", count, ")"); } diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index b667da25bb42..a49e5611a4a9 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -30,9 +30,7 @@ #include "spindle_laser_types.h" -#if HAS_BEEPER - #include "../libs/buzzer.h" -#endif +#include "../libs/buzzer.h" // Inline laser power #include "../module/planner.h" @@ -285,7 +283,7 @@ class SpindleLaser { if (!menuPower) menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); power = upower_to_ocr(menuPower); apply_power(power); - } else + } else apply_power(0); } diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 8b6ea0bf1fae..bfb3b640078b 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -112,7 +112,7 @@ void GcodeSuite::M48() { set_bed_leveling_enabled(false); #endif - TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); + TERN_(HAS_PTC, ptc.set_enabled(parser.boolval('C', true))); // Work with reasonable feedrates remember_feedrate_scaling_off(); diff --git a/Marlin/src/gcode/calibrate/M665.cpp b/Marlin/src/gcode/calibrate/M665.cpp index 7dc657a61b43..a8e02831e2a8 100644 --- a/Marlin/src/gcode/calibrate/M665.cpp +++ b/Marlin/src/gcode/calibrate/M665.cpp @@ -167,8 +167,6 @@ if (parser.seenval('T')) draw_area_max.y = parser.value_linear_units(); if (parser.seenval('B')) draw_area_min.y = parser.value_linear_units(); if (parser.seenval('H')) polargraph_max_belt_len = parser.value_linear_units(); - draw_area_size.x = draw_area_max.x - draw_area_min.x; - draw_area_size.y = draw_area_max.y - draw_area_min.y; } void GcodeSuite::M665_report(const bool forReplay/*=true*/) { diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 989e4d0870a4..b360739e210a 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -43,13 +43,14 @@ * S[linear] Swap length * B[linear] Extra Swap resume length * E[linear] Extra Prime length (as used by M217 Q) - * P[linear/min] Prime speed + * G[linear] Cutting wipe retract length (<=100mm) * R[linear/min] Retract speed * U[linear/min] UnRetract speed + * P[linear/min] Prime speed * V[linear] 0/1 Enable auto prime first extruder used * W[linear] 0/1 Enable park & Z Raise * X[linear] Park X (Requires TOOLCHANGE_PARK) - * Y[linear] Park Y (Requires TOOLCHANGE_PARK) + * Y[linear] Park Y (Requires TOOLCHANGE_PARK and NUM_AXES >= 2) * I[linear] Park I (Requires TOOLCHANGE_PARK and NUM_AXES >= 4) * J[linear] Park J (Requires TOOLCHANGE_PARK and NUM_AXES >= 5) * K[linear] Park K (Requires TOOLCHANGE_PARK and NUM_AXES >= 6) @@ -79,6 +80,7 @@ void GcodeSuite::M217() { if (parser.seenval('B')) { const float v = parser.value_linear_units(); toolchange_settings.extra_resume = constrain(v, -10, 10); } if (parser.seenval('E')) { const float v = parser.value_linear_units(); toolchange_settings.extra_prime = constrain(v, 0, max_extrude); } if (parser.seenval('P')) { const int16_t v = parser.value_linear_units(); toolchange_settings.prime_speed = constrain(v, 10, 5400); } + if (parser.seenval('G')) { const int16_t v = parser.value_linear_units(); toolchange_settings.wipe_retract = constrain(v, 0, 100); } if (parser.seenval('R')) { const int16_t v = parser.value_linear_units(); toolchange_settings.retract_speed = constrain(v, 10, 5400); } if (parser.seenval('U')) { const int16_t v = parser.value_linear_units(); toolchange_settings.unretract_speed = constrain(v, 10, 5400); } #if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN @@ -164,21 +166,24 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) { SERIAL_ECHOPGM(" M217"); #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - SERIAL_ECHOPGM(" S", LINEAR_UNIT(toolchange_settings.swap_length)); - SERIAL_ECHOPGM_P(SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume), - SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime), - SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed)); - SERIAL_ECHOPGM(" R", LINEAR_UNIT(toolchange_settings.retract_speed), - " U", LINEAR_UNIT(toolchange_settings.unretract_speed), - " F", toolchange_settings.fan_speed, - " D", toolchange_settings.fan_time); + SERIAL_ECHOPGM_P( + PSTR(" S"), LINEAR_UNIT(toolchange_settings.swap_length), + SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume), + SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime), + SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed), + PSTR(" G"), LINEAR_UNIT(toolchange_settings.wipe_retract), + PSTR(" R"), LINEAR_UNIT(toolchange_settings.retract_speed), + PSTR(" U"), LINEAR_UNIT(toolchange_settings.unretract_speed), + PSTR(" F"), toolchange_settings.fan_speed, + PSTR(" D"), toolchange_settings.fan_time + ); #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) - SERIAL_ECHOPGM(" A", migration.automode); - SERIAL_ECHOPGM(" L", LINEAR_UNIT(migration.last)); + SERIAL_ECHOPGM(" A", migration.automode, " L", LINEAR_UNIT(migration.last)); #endif #if ENABLED(TOOLCHANGE_PARK) + { SERIAL_ECHOPGM(" W", LINEAR_UNIT(toolchange_settings.enable_park)); SERIAL_ECHOPGM_P( SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x) @@ -196,6 +201,7 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) { ) #endif ); + } #endif #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) diff --git a/Marlin/src/gcode/config/M301.cpp b/Marlin/src/gcode/config/M301.cpp index fc9f1883d616..a3938acb1157 100644 --- a/Marlin/src/gcode/config/M301.cpp +++ b/Marlin/src/gcode/config/M301.cpp @@ -57,19 +57,18 @@ void GcodeSuite::M301() { if (e < HOTENDS) { // catch bad input value - if (parser.seenval('P')) PID_PARAM(Kp, e) = parser.value_float(); - if (parser.seenval('I')) PID_PARAM(Ki, e) = scalePID_i(parser.value_float()); - if (parser.seenval('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float()); + if (parser.seenval('P')) SET_HOTEND_PID(Kp, e, parser.value_float()); + if (parser.seenval('I')) SET_HOTEND_PID(Ki, e, parser.value_float()); + if (parser.seenval('D')) SET_HOTEND_PID(Kd, e, parser.value_float()); #if ENABLED(PID_EXTRUSION_SCALING) - if (parser.seenval('C')) PID_PARAM(Kc, e) = parser.value_float(); + if (parser.seenval('C')) SET_HOTEND_PID(Kc, e, parser.value_float()); if (parser.seenval('L')) thermalManager.lpq_len = parser.value_int(); - NOMORE(thermalManager.lpq_len, LPQ_MAX_LEN); - NOLESS(thermalManager.lpq_len, 0); + LIMIT(thermalManager.lpq_len, 0, LPQ_MAX_LEN); #endif #if ENABLED(PID_FAN_SCALING) - if (parser.seenval('F')) PID_PARAM(Kf, e) = parser.value_float(); + if (parser.seenval('F')) SET_HOTEND_PID(Kf, e, parser.value_float()); #endif thermalManager.updatePID(); @@ -83,6 +82,7 @@ void GcodeSuite::M301_report(const bool forReplay/*=true*/ E_OPTARG(const int8_t IF_DISABLED(HAS_MULTI_EXTRUDER, constexpr int8_t eindex = -1); HOTEND_LOOP() { if (e == eindex || eindex == -1) { + const hotend_pid_t &pid = thermalManager.temp_hotend[e].pid; report_echo_start(forReplay); SERIAL_ECHOPGM_P( #if ENABLED(PID_PARAMS_PER_HOTEND) @@ -90,16 +90,14 @@ void GcodeSuite::M301_report(const bool forReplay/*=true*/ E_OPTARG(const int8_t #else PSTR(" M301 P") #endif - , PID_PARAM(Kp, e) - , PSTR(" I"), unscalePID_i(PID_PARAM(Ki, e)) - , PSTR(" D"), unscalePID_d(PID_PARAM(Kd, e)) + , pid.p(), PSTR(" I"), pid.i(), PSTR(" D"), pid.d() ); #if ENABLED(PID_EXTRUSION_SCALING) - SERIAL_ECHOPGM_P(SP_C_STR, PID_PARAM(Kc, e)); + SERIAL_ECHOPGM_P(SP_C_STR, pid.c()); if (e == 0) SERIAL_ECHOPGM(" L", thermalManager.lpq_len); #endif #if ENABLED(PID_FAN_SCALING) - SERIAL_ECHOPGM(" F", PID_PARAM(Kf, e)); + SERIAL_ECHOPGM(" F", pid.f()); #endif SERIAL_EOL(); } diff --git a/Marlin/src/gcode/config/M302.cpp b/Marlin/src/gcode/config/M302.cpp index 9f4d569d7b2e..12408c898755 100644 --- a/Marlin/src/gcode/config/M302.cpp +++ b/Marlin/src/gcode/config/M302.cpp @@ -28,7 +28,7 @@ #include "../../module/temperature.h" #if ENABLED(DWIN_LCD_PROUI) - #include "../../lcd/e3v2/proui/dwin_defines.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif /** diff --git a/Marlin/src/gcode/config/M304.cpp b/Marlin/src/gcode/config/M304.cpp index c970288238f5..a71a34c6de42 100644 --- a/Marlin/src/gcode/config/M304.cpp +++ b/Marlin/src/gcode/config/M304.cpp @@ -36,17 +36,17 @@ */ void GcodeSuite::M304() { if (!parser.seen("PID")) return M304_report(); - if (parser.seenval('P')) thermalManager.temp_bed.pid.Kp = parser.value_float(); - if (parser.seenval('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float()); - if (parser.seenval('D')) thermalManager.temp_bed.pid.Kd = scalePID_d(parser.value_float()); + if (parser.seenval('P')) thermalManager.temp_bed.pid.set_Kp(parser.value_float()); + if (parser.seenval('I')) thermalManager.temp_bed.pid.set_Ki(parser.value_float()); + if (parser.seenval('D')) thermalManager.temp_bed.pid.set_Kd(parser.value_float()); } void GcodeSuite::M304_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_BED_PID)); - SERIAL_ECHOLNPGM( - " M304 P", thermalManager.temp_bed.pid.Kp - , " I", unscalePID_i(thermalManager.temp_bed.pid.Ki) - , " D", unscalePID_d(thermalManager.temp_bed.pid.Kd) + SERIAL_ECHOLNPGM(" M304" + " P", thermalManager.temp_bed.pid.p() + , " I", thermalManager.temp_bed.pid.i() + , " D", thermalManager.temp_bed.pid.d() ); } diff --git a/Marlin/src/gcode/config/M309.cpp b/Marlin/src/gcode/config/M309.cpp index 577023292e2d..4953113041d7 100644 --- a/Marlin/src/gcode/config/M309.cpp +++ b/Marlin/src/gcode/config/M309.cpp @@ -36,17 +36,17 @@ */ void GcodeSuite::M309() { if (!parser.seen("PID")) return M309_report(); - if (parser.seen('P')) thermalManager.temp_chamber.pid.Kp = parser.value_float(); - if (parser.seen('I')) thermalManager.temp_chamber.pid.Ki = scalePID_i(parser.value_float()); - if (parser.seen('D')) thermalManager.temp_chamber.pid.Kd = scalePID_d(parser.value_float()); + if (parser.seenval('P')) thermalManager.temp_chamber.pid.set_Kp(parser.value_float()); + if (parser.seenval('I')) thermalManager.temp_chamber.pid.set_Ki(parser.value_float()); + if (parser.seenval('D')) thermalManager.temp_chamber.pid.set_Kd(parser.value_float()); } void GcodeSuite::M309_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_CHAMBER_PID)); - SERIAL_ECHOLNPGM( - " M309 P", thermalManager.temp_chamber.pid.Kp - , " I", unscalePID_i(thermalManager.temp_chamber.pid.Ki) - , " D", unscalePID_d(thermalManager.temp_chamber.pid.Kd) + SERIAL_ECHOLNPGM(" M309" + " P", thermalManager.temp_chamber.pid.p() + , " I", thermalManager.temp_chamber.pid.i() + , " D", thermalManager.temp_chamber.pid.d() ); } diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 688b94c9bf39..5807844012b5 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -313,9 +313,16 @@ void GcodeSuite::M43() { // 'P' Get the range of pins to test or watch uint8_t first_pin = PARSED_PIN_INDEX('P', 0), - last_pin = parser.seenval('P') ? first_pin : TERN(HAS_HIGH_ANALOG_PINS, NUM_DIGITAL_PINS, NUMBER_PINS_TOTAL) - 1; + last_pin = parser.seenval('L') ? PARSED_PIN_INDEX('L', 0) : parser.seenval('P') ? first_pin : (NUMBER_PINS_TOTAL) - 1; - if (first_pin > last_pin) return; + NOMORE(first_pin, (NUMBER_PINS_TOTAL) - 1); + NOMORE(last_pin, (NUMBER_PINS_TOTAL) - 1); + + if (first_pin > last_pin) { + const uint8_t f = first_pin; + first_pin = last_pin; + last_pin = f; + } // 'I' to ignore protected pins const bool ignore_protection = parser.boolval('I'); diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index e3ca43e17fd5..a52c706fa6b5 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -169,7 +169,7 @@ if (parser.seen("EPS")) { planner.synchronize(); if (parser.seenval('P')) duplication_e_mask = parser.value_int(); // Set the mask directly - else if (parser.seenval('E')) duplication_e_mask = pow(2, parser.value_int() + 1) - 1; // Set the mask by E index + else if (parser.seenval('E')) duplication_e_mask = _BV(parser.value_int() + 1) - 1; // Set the mask by E index ena = (2 == parser.intval('S', extruder_duplication_enabled ? 2 : 0)); set_duplication_enabled(ena && (duplication_e_mask >= 3)); } diff --git a/Marlin/src/gcode/control/M993_M994.cpp b/Marlin/src/gcode/control/M993_M994.cpp index 252792e5224e..598a73fab756 100644 --- a/Marlin/src/gcode/control/M993_M994.cpp +++ b/Marlin/src/gcode/control/M993_M994.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if ALL(HAS_SPI_FLASH, SDSUPPORT, MARLIN_DEV_MODE) +#if ALL(SPI_FLASH, SDSUPPORT, MARLIN_DEV_MODE) #include "../gcode.h" #include "../../sd/cardreader.h" @@ -85,4 +85,4 @@ void GcodeSuite::M994() { card.closefile(); } -#endif // HAS_SPI_FLASH && SDSUPPORT && MARLIN_DEV_MODE +#endif // SPI_FLASH && SDSUPPORT && MARLIN_DEV_MODE diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index db09faa88310..8c0da41801cc 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -27,8 +27,8 @@ #include "../../gcode.h" #include "../../../module/planner.h" -#if ENABLED(EXTRA_LIN_ADVANCE_K) - float other_extruder_advance_K[EXTRUDERS]; +#if ENABLED(ADVANCE_K_EXTRA) + float other_extruder_advance_K[DISTINCT_E]; uint8_t lin_adv_slot = 0; #endif @@ -36,8 +36,8 @@ * M900: Get or Set Linear Advance K-factor * T Which tool to address * K Set current advance K factor (Slot 0). - * L Set secondary advance K factor (Slot 1). Requires EXTRA_LIN_ADVANCE_K. - * S<0/1> Activate slot 0 or 1. Requires EXTRA_LIN_ADVANCE_K. + * L Set secondary advance K factor (Slot 1). Requires ADVANCE_K_EXTRA. + * S<0/1> Activate slot 0 or 1. Requires ADVANCE_K_EXTRA. */ void GcodeSuite::M900() { @@ -50,6 +50,7 @@ void GcodeSuite::M900() { #if EXTRUDERS < 2 constexpr uint8_t tool_index = 0; + UNUSED(tool_index); #else const uint8_t tool_index = parser.intval('T', active_extruder); if (tool_index >= EXTRUDERS) { @@ -58,12 +59,12 @@ void GcodeSuite::M900() { } #endif - float &kref = planner.extruder_advance_K[tool_index], newK = kref; + float &kref = planner.extruder_advance_K[E_INDEX_N(tool_index)], newK = kref; const float oldK = newK; - #if ENABLED(EXTRA_LIN_ADVANCE_K) + #if ENABLED(ADVANCE_K_EXTRA) - float &lref = other_extruder_advance_K[tool_index]; + float &lref = other_extruder_advance_K[E_INDEX_N(tool_index)]; const bool old_slot = TEST(lin_adv_slot, tool_index), // The tool's current slot (0 or 1) new_slot = parser.boolval('S', old_slot); // The passed slot (default = current) @@ -111,9 +112,9 @@ void GcodeSuite::M900() { if (!parser.seen_any()) { - #if ENABLED(EXTRA_LIN_ADVANCE_K) + #if ENABLED(ADVANCE_K_EXTRA) - #if EXTRUDERS < 2 + #if DISTINCT_E < 2 SERIAL_ECHOLNPGM("Advance S", new_slot, " K", kref, "(S", !new_slot, " K", lref, ")"); #else EXTRUDER_LOOP() { @@ -127,7 +128,7 @@ void GcodeSuite::M900() { #else SERIAL_ECHO_START(); - #if EXTRUDERS < 2 + #if DISTINCT_E < 2 SERIAL_ECHOLNPGM("Advance K=", planner.extruder_advance_K[0]); #else SERIAL_ECHOPGM("Advance K"); @@ -145,7 +146,7 @@ void GcodeSuite::M900() { void GcodeSuite::M900_report(const bool forReplay/*=true*/) { report_heading(forReplay, F(STR_LINEAR_ADVANCE)); - #if EXTRUDERS < 2 + #if DISTINCT_E < 2 report_echo_start(forReplay); SERIAL_ECHOLNPGM(" M900 K", planner.extruder_advance_K[0]); #else diff --git a/Marlin/src/gcode/feature/input_shaping/M593.cpp b/Marlin/src/gcode/feature/input_shaping/M593.cpp new file mode 100644 index 000000000000..a4b3cd3fee97 --- /dev/null +++ b/Marlin/src/gcode/feature/input_shaping/M593.cpp @@ -0,0 +1,85 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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_SHAPING + +#include "../../gcode.h" +#include "../../../module/stepper.h" + +void GcodeSuite::M593_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, F("Input Shaping")); + #if ENABLED(INPUT_SHAPING_X) + SERIAL_ECHOLNPGM(" M593 X" + " F", stepper.get_shaping_frequency(X_AXIS), + " D", stepper.get_shaping_damping_ratio(X_AXIS) + ); + #endif + #if ENABLED(INPUT_SHAPING_Y) + TERN_(INPUT_SHAPING_X, report_echo_start(forReplay)); + SERIAL_ECHOLNPGM(" M593 Y" + " F", stepper.get_shaping_frequency(Y_AXIS), + " D", stepper.get_shaping_damping_ratio(Y_AXIS) + ); + #endif +} + +/** + * M593: Get or Set Input Shaping Parameters + * D Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes. + * F Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes. + * T[map] Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet) + * X Set the given parameters only for the X axis. + * Y Set the given parameters only for the Y axis. + */ +void GcodeSuite::M593() { + if (!parser.seen_any()) return M593_report(); + + const bool seen_X = TERN0(INPUT_SHAPING_X, parser.seen_test('X')), + seen_Y = TERN0(INPUT_SHAPING_Y, parser.seen_test('Y')), + for_X = seen_X || TERN0(INPUT_SHAPING_X, (!seen_X && !seen_Y)), + for_Y = seen_Y || TERN0(INPUT_SHAPING_Y, (!seen_X && !seen_Y)); + + if (parser.seen('D')) { + const float zeta = parser.value_float(); + if (WITHIN(zeta, 0, 1)) { + if (for_X) stepper.set_shaping_damping_ratio(X_AXIS, zeta); + if (for_Y) stepper.set_shaping_damping_ratio(Y_AXIS, zeta); + } + else + SERIAL_ECHO_MSG("?Zeta (D) value out of range (0-1)"); + } + + if (parser.seen('F')) { + const float freq = parser.value_float(); + constexpr float min_freq = float(uint32_t(STEPPER_TIMER_RATE) / 2) / shaping_time_t(-2); + if (freq == 0.0f || freq > min_freq) { + if (for_X) stepper.set_shaping_frequency(X_AXIS, freq); + if (for_Y) stepper.set_shaping_frequency(Y_AXIS, freq); + } + else + SERIAL_ECHOLNPGM("?Frequency (F) must be greater than ", min_freq, " or 0 to disable"); + } +} + +#endif diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 77c58411a37a..43062c3f752a 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -61,7 +61,12 @@ void GcodeSuite::M150() { #if ENABLED(NEOPIXEL_LED) const pixel_index_t index = parser.intval('I', -1); #if ENABLED(NEOPIXEL2_SEPARATE) - int8_t brightness = neo.brightness(), unit = parser.intval('S', -1); + #ifndef NEOPIXEL_M150_DEFAULT + #define NEOPIXEL_M150_DEFAULT -1 + #elif NEOPIXEL_M150_DEFAULT > 1 + #error "NEOPIXEL_M150_DEFAULT must be -1, 0, or 1." + #endif + int8_t brightness = neo.brightness(), unit = parser.intval('S', NEOPIXEL_M150_DEFAULT); switch (unit) { case -1: neo2.neoindex = index; // fall-thru case 0: neo.neoindex = index; old_color = parser.seen('K') ? neo.pixel_color(index >= 0 ? index : 0) : 0; break; diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 44675a850eb5..db31fe3d8ef3 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -197,8 +197,12 @@ void GcodeSuite::M569_report(const bool forReplay/*=true*/) { if (chop_x2 || chop_y2 || chop_z2) { say_M569(forReplay, F("I1")); if (chop_x2) SERIAL_ECHOPGM_P(SP_X_STR); - if (chop_y2) SERIAL_ECHOPGM_P(SP_Y_STR); - if (chop_z2) SERIAL_ECHOPGM_P(SP_Z_STR); + #if HAS_Y_AXIS + if (chop_y2) SERIAL_ECHOPGM_P(SP_Y_STR); + #endif + #if HAS_Z_AXIS + if (chop_z2) SERIAL_ECHOPGM_P(SP_Z_STR); + #endif SERIAL_EOL(); } diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 0a9d1760e91e..0fbf1def6777 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -294,14 +294,14 @@ #if X_HAS_STEALTHCHOP || X2_HAS_STEALTHCHOP case X_AXIS: TERN_(X_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(X,X)); - TERN_(X2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(X,X2)); + TERN_(X2_HAS_STEALTHCHOP, if (!index || index == 2) TMC_SET_PWMTHRS(X,X2)); break; #endif #if Y_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP case Y_AXIS: TERN_(Y_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Y,Y)); - TERN_(Y2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(Y,Y2)); + TERN_(Y2_HAS_STEALTHCHOP, if (!index || index == 2) TMC_SET_PWMTHRS(Y,Y2)); break; #endif @@ -499,7 +499,6 @@ * M914: Set StallGuard sensitivity. */ void GcodeSuite::M914() { - bool report = true; const uint8_t index = parser.byteval('I'); LOOP_NUM_AXES(i) if (parser.seen(AXIS_CHAR(i))) { @@ -509,13 +508,13 @@ #if X_SENSORLESS case X_AXIS: if (index < 2) stepperX.homing_threshold(value); - TERN_(X2_SENSORLESS, if (!(index & 1)) stepperX2.homing_threshold(value)); + TERN_(X2_SENSORLESS, if (!index || index == 2) stepperX2.homing_threshold(value)); break; #endif #if Y_SENSORLESS case Y_AXIS: if (index < 2) stepperY.homing_threshold(value); - TERN_(Y2_SENSORLESS, if (!(index & 1)) stepperY2.homing_threshold(value)); + TERN_(Y2_SENSORLESS, if (!index || index == 2) stepperY2.homing_threshold(value)); break; #endif #if Z_SENSORLESS diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 13ce3914f9c0..fd3ec1cf14a9 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -561,8 +561,8 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 48: M48(); break; // M48: Z probe repeatability test #endif - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) - case 73: M73(); break; // M73: Set progress percentage (for display on LCD) + #if ENABLED(SET_PROGRESS_MANUALLY) + case 73: M73(); break; // M73: Set progress percentage #endif case 75: M75(); break; // M75: Start print timer @@ -600,7 +600,9 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 108: M108(); break; // M108: Cancel Waiting case 112: M112(); break; // M112: Full Shutdown case 410: M410(); break; // M410: Quickstop - Abort all the planned moves. - TERN_(HOST_PROMPT_SUPPORT, case 876:) // M876: Handle Host prompt responses + #if ENABLED(HOST_PROMPT_SUPPORT) + case 876: M876(); break; // M876: Handle Host prompt responses + #endif #else case 108: case 112: case 410: TERN_(HOST_PROMPT_SUPPORT, case 876:) @@ -793,6 +795,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 250: M250(); break; // M250: Set LCD contrast #endif + #if HAS_GCODE_M255 + case 255: M255(); break; // M255: Set LCD Sleep/Backlight Timeout (Minutes) + #endif + #if HAS_LCD_BRIGHTNESS case 256: M256(); break; // M256: Set LCD brightness #endif @@ -927,6 +933,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 575: M575(); break; // M575: Set serial baudrate #endif + #if HAS_SHAPING + case 593: M593(); break; // M593: Set Input Shaping parameters + #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) case 600: M600(); break; // M600: Pause for Filament Change case 603: M603(); break; // M603: Configure Filament Change @@ -1047,7 +1057,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 422: M422(); break; // M422: Set Z Stepper automatic alignment position using probe #endif - #if ALL(HAS_SPI_FLASH, SDSUPPORT, MARLIN_DEV_MODE) + #if ALL(SPI_FLASH, SDSUPPORT, MARLIN_DEV_MODE) case 993: M993(); break; // M993: Backup SPI Flash to SD case 994: M994(); break; // M994: Load a Backup from SD to SPI Flash #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 2b15706395bd..5d56e53dd5e0 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -114,7 +114,7 @@ * M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins (Requires PINS_DEBUGGING) * M48 - Measure Z Probe repeatability: M48 P X Y V E L S. (Requires Z_MIN_PROBE_REPEATABILITY_TEST) * - * M73 - Set the progress percentage. (Requires LCD_SET_PROGRESS_MANUALLY) + * M73 - Set the progress percentage. (Requires SET_PROGRESS_MANUALLY) * M75 - Start the print job timer. * M76 - Pause the print job timer. * M77 - Stop the print job timer. @@ -259,6 +259,7 @@ * 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) + * M593 - Get or set input shaping parameters. (Requires INPUT_SHAPING_[XY]) * 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) @@ -677,7 +678,7 @@ class GcodeSuite { static void M48(); #endif - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_MANUALLY) static void M73(); #endif @@ -1080,6 +1081,11 @@ class GcodeSuite { static void M575(); #endif + #if HAS_SHAPING + static void M593(); + static void M593_report(const bool forReplay=true); + #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) static void M600(); static void M603(); @@ -1194,7 +1200,7 @@ class GcodeSuite { static void M995(); #endif - #if BOTH(HAS_SPI_FLASH, SDSUPPORT) + #if BOTH(SPI_FLASH, SDSUPPORT) static void M993(); static void M994(); #endif diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 2ebe38bbcf19..be431eed0d78 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -156,20 +156,21 @@ void GcodeSuite::D(const int16_t dcode) { } break; case 5: { // D5 Read / Write onboard Flash - #define FLASH_SIZE 1024 + // This will overwrite program and data, so don't use it. + #define ONBOARD_FLASH_SIZE 1024 // 0x400 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(ONBOARD_FLASH_SIZE - 1)); + NOMORE(len, ONBOARD_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++)); + //// TODO: Read bytes from FLASH + // print_hex_byte(flash_read_byte(adr++)); //} SERIAL_EOL(); } diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index d38bd6612d9c..6e8c406adc1a 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -32,6 +32,10 @@ #include "../../feature/caselight.h" #endif +#if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID) + #include "../../libs/hex_print.h" +#endif + //#define MINIMAL_CAP_LINES // Don't even mention the disabled capabilities #if ENABLED(EXTENDED_CAPABILITIES_REPORT) @@ -59,20 +63,37 @@ * the capability is not present. */ void GcodeSuite::M115() { - SERIAL_ECHOLNPGM( - "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ") " - "SOURCE_CODE_URL:" SOURCE_CODE_URL " " - "PROTOCOL_VERSION:" PROTOCOL_VERSION " " - "MACHINE_TYPE:" MACHINE_NAME " " - "EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " " + SERIAL_ECHOPGM("FIRMWARE_NAME:Marlin" + " " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ")" + " SOURCE_CODE_URL:" SOURCE_CODE_URL + " PROTOCOL_VERSION:" PROTOCOL_VERSION + " MACHINE_TYPE:" MACHINE_NAME + " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) #if NUM_AXES != XYZ - "AXIS_COUNT:" STRINGIFY(NUM_AXES) " " + " AXIS_COUNT:" STRINGIFY(NUM_AXES) #endif #ifdef MACHINE_UUID - "UUID:" MACHINE_UUID + " UUID:" MACHINE_UUID #endif ); + // STM32UID:111122223333 + #if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID) + // STM32 based devices output the CPU device serial number + // Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations + // https://github.com/opulo-inc/lumenpnp + // Although this code should work on all STM32 based boards + SERIAL_ECHOPGM(" UUID:"); + uint32_t *uid_address = (uint32_t*)UID_BASE; + LOOP_L_N(i, 3) { + const uint32_t UID = uint32_t(READ_REG(*(uid_address))); + uid_address += 4U; + for (int B = 24; B >= 0; B -= 8) print_hex_byte(UID >> B); + } + #endif + + SERIAL_EOL(); + #if ENABLED(EXTENDED_CAPABILITIES_REPORT) // The port that sent M115 @@ -121,7 +142,7 @@ void GcodeSuite::M115() { cap_line(F("LEVELING_DATA"), ENABLED(HAS_LEVELING)); // BUILD_PERCENT (M73) - cap_line(F("BUILD_PERCENT"), ENABLED(LCD_SET_PROGRESS_MANUALLY)); + cap_line(F("BUILD_PERCENT"), ENABLED(SET_PROGRESS_PERCENT)); // SOFTWARE_POWER (M80, M81) cap_line(F("SOFTWARE_POWER"), ENABLED(PSU_CONTROL)); @@ -130,6 +151,13 @@ void GcodeSuite::M115() { cap_line(F("TOGGLE_LIGHTS"), ENABLED(CASE_LIGHT_ENABLE)); cap_line(F("CASE_LIGHT_BRIGHTNESS"), TERN0(CASE_LIGHT_ENABLE, caselight.has_brightness())); + // SPINDLE AND LASER CONTROL (M3, M4, M5) + #if ENABLED(SPINDLE_FEATURE) + cap_line(F("SPINDLE"), true); + #elif ENABLED(LASER_FEATURE) + cap_line(F("LASER"), true); + #endif + // EMERGENCY_PARSER (M108, M112, M410, M876) cap_line(F("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER)); @@ -194,26 +222,49 @@ void GcodeSuite::M115() { // Machine Geometry #if ENABLED(M115_GEOMETRY_REPORT) - const xyz_pos_t bmin = { 0, 0, 0 }, - bmax = { X_BED_SIZE , Y_BED_SIZE, Z_MAX_POS }, - dmin = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }, - dmax = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; + constexpr xyz_pos_t bmin{0}, + bmax = ARRAY_N(NUM_AXES, X_BED_SIZE, Y_BED_SIZE, Z_MAX_POS, I_MAX_POS, J_MAX_POS, K_MAX_POS, U_MAX_POS, V_MAX_POS, W_MAX_POS), + dmin = ARRAY_N(NUM_AXES, X_MIN_POS, Y_MIN_POS, Z_MIN_POS, I_MIN_POS, J_MIN_POS, K_MIN_POS, U_MIN_POS, V_MIN_POS, W_MIN_POS), + dmax = ARRAY_N(NUM_AXES, X_MAX_POS, Y_MAX_POS, Z_MAX_POS, I_MAX_POS, J_MAX_POS, K_MAX_POS, U_MAX_POS, V_MAX_POS, W_MAX_POS); xyz_pos_t cmin = bmin, cmax = bmax; apply_motion_limits(cmin); apply_motion_limits(cmax); const xyz_pos_t lmin = dmin.asLogical(), lmax = dmax.asLogical(), wmin = cmin.asLogical(), wmax = cmax.asLogical(); + SERIAL_ECHOLNPGM( "area:{" "full:{" - "min:{x:", lmin.x, ",y:", lmin.y, ",z:", lmin.z, "}," - "max:{x:", lmax.x, ",y:", lmax.y, ",z:", lmax.z, "}" - "}," + "min:{" + LIST_N(DOUBLE(NUM_AXES), + "x:", lmin.x, ",y:", lmin.y, ",z:", lmin.z, + ",i:", lmin.i, ",j:", lmin.j, ",k:", lmin.k, + ",u:", lmin.u, ",v:", lmin.v, ",w:", lmin.w + ), + "},max:{" + LIST_N(DOUBLE(NUM_AXES), + "x:", lmax.x, ",y:", lmax.y, ",z:", lmax.z, + ",i:", lmax.i, ",j:", lmax.j, ",k:", lmax.k, + ",u:", lmax.u, ",v:", lmax.v, ",w:", lmax.w + ), + "}" // max + "}," // full "work:{" - "min:{x:", wmin.x, ",y:", wmin.y, ",z:", wmin.z, "}," - "max:{x:", wmax.x, ",y:", wmax.y, ",z:", wmax.z, "}", - "}" - "}" + "min:{" + LIST_N(DOUBLE(NUM_AXES), + "x:", wmin.x, ",y:", wmin.y, ",z:", wmin.z, + ",i:", wmin.i, ",j:", wmin.j, ",k:", wmin.k, + ",u:", wmin.u, ",v:", wmin.v, ",w:", wmin.w + ), + "},max:{" + LIST_N(DOUBLE(NUM_AXES), + "x:", wmax.x, ",y:", wmax.y, ",z:", wmax.z, + ",i:", wmax.i, ",j:", wmax.j, ",k:", wmax.k, + ",u:", wmax.u, ",v:", wmax.v, ",w:", wmax.w + ), + "}" // max + "}" // work + "}" // area ); #endif diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index af03fcb0b1a1..35afea0f6ecd 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -85,7 +85,12 @@ void GcodeSuite::M0_M1() { #endif - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR))); + #if ENABLED(HOST_PROMPT_SUPPORT) + if (parser.string_arg) + hostui.prompt_do(PROMPT_USER_CONTINUE, parser.string_arg, FPSTR(CONTINUE_STR)); + else + hostui.prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR)); + #endif TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms)); diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index 8dbe2fb07e55..942d20afd2f8 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -47,7 +47,7 @@ void GcodeSuite::M145() { preheat_t &mat = ui.material_preset[material]; #if HAS_HOTEND if (parser.seenval('H')) - mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0)); + mat.hotend_temp = constrain(parser.value_int(), thermalManager.extrude_min_temp, thermalManager.hotend_max_target(0)); #endif #if HAS_HEATED_BED if (parser.seenval('B')) diff --git a/Marlin/src/gcode/lcd/M255.cpp b/Marlin/src/gcode/lcd/M255.cpp index 4a9049ab2c61..8dc8099de149 100644 --- a/Marlin/src/gcode/lcd/M255.cpp +++ b/Marlin/src/gcode/lcd/M255.cpp @@ -32,12 +32,11 @@ */ void GcodeSuite::M255() { if (parser.seenval('S')) { + const int m = parser.value_int(); #if HAS_DISPLAY_SLEEP - const int m = parser.value_int(); - ui.sleep_timeout_minutes = constrain(m, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX); + ui.sleep_timeout_minutes = constrain(m, ui.sleep_timeout_min, ui.sleep_timeout_max); #else - const unsigned int s = parser.value_ushort() * 60; - ui.lcd_backlight_timeout = constrain(s, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX); + ui.backlight_timeout_minutes = constrain(m, ui.backlight_timeout_min, ui.backlight_timeout_max); #endif } else @@ -47,11 +46,8 @@ void GcodeSuite::M255() { void GcodeSuite::M255_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_DISPLAY_SLEEP)); SERIAL_ECHOLNPGM(" M255 S", - #if HAS_DISPLAY_SLEEP - ui.sleep_timeout_minutes, " ; (minutes)" - #else - ui.lcd_backlight_timeout, " ; (seconds)" - #endif + TERN(HAS_DISPLAY_SLEEP, ui.sleep_timeout_minutes, ui.backlight_timeout_minutes), + " ; (minutes)" ); } diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index a86eee4d9967..02d44ca00be8 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -22,11 +22,12 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(LCD_SET_PROGRESS_MANUALLY) +#if ENABLED(SET_PROGRESS_MANUALLY) #include "../gcode.h" #include "../../lcd/marlinui.h" #include "../../sd/cardreader.h" +#include "../../libs/numtostr.h" #if ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" @@ -36,7 +37,15 @@ * M73: Set percentage complete (for display on LCD) * * Example: - * M73 P25 ; Set progress to 25% + * M73 P25.63 ; Set progress to 25.63% + * M73 R456 ; Set remaining time to 456 minutes + * M73 C12 ; Set next interaction countdown to 12 minutes + * M73 ; Report current values + * + * M73 Progress: ---%; Time left: -----m; Change: -----m; + * + * When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100% / 23.4% / 3.45% format + * */ void GcodeSuite::M73() { @@ -46,17 +55,40 @@ void GcodeSuite::M73() { #else - if (parser.seenval('P')) - ui.set_progress((PROGRESS_SCALE) > 1 - ? parser.value_float() * (PROGRESS_SCALE) - : parser.value_byte() - ); + #if ENABLED(SET_PROGRESS_PERCENT) + if (parser.seenval('P')) + ui.set_progress((PROGRESS_SCALE) > 1 + ? parser.value_float() * (PROGRESS_SCALE) + : parser.value_byte() + ); + #endif - #if ENABLED(USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong()); #endif + #if ENABLED(SET_INTERACTION_TIME) + if (parser.seenval('C')) ui.set_interaction_time(60 * parser.value_ulong()); + #endif + + #endif + + #if ENABLED(M73_REPORT) + if (TERN1(M73_REPORT_SD_ONLY, IS_SD_PRINTING())) { + SERIAL_ECHO_START(); + SERIAL_ECHOPGM(" M73"); + #if ENABLED(SET_PROGRESS_PERCENT) + SERIAL_ECHOPGM(" Progress: ", TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent()), "%;"); + #endif + #if ENABLED(SET_REMAINING_TIME) + SERIAL_ECHOPGM(" Time left: ", ui.remaining_time / 60, "m;"); + #endif + #if ENABLED(SET_INTERACTION_TIME) + SERIAL_ECHOPGM(" Change: ", ui.interaction_time / 60, "m;"); + #endif + SERIAL_EOL(); + } #endif } -#endif // LCD_SET_PROGRESS_MANUALLY +#endif // SET_PROGRESS_MANUALLY diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 3f5290e81c67..c05d6f32c521 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -256,22 +256,20 @@ class GCodeParser { // Float removes 'E' to prevent scientific notation interpretation static float value_float() { - if (value_ptr) { - char *e = value_ptr; - for (;;) { - const char c = *e; - if (c == '\0' || c == ' ') break; - if (c == 'E' || c == 'e') { - *e = '\0'; - const float ret = strtof(value_ptr, nullptr); - *e = c; - return ret; - } - ++e; + if (!value_ptr) return 0; + char *e = value_ptr; + for (;;) { + const char c = *e; + if (c == '\0' || c == ' ') break; + if (c == 'E' || c == 'e' || c == 'X' || c == 'x') { + *e = '\0'; + const float ret = strtof(value_ptr, nullptr); + *e = c; + return ret; } - return strtof(value_ptr, nullptr); + ++e; } - return 0; + return strtof(value_ptr, nullptr); } // Code value as a long or ulong diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index e474ffe9d689..6893d4bec284 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -58,16 +58,13 @@ void GcodeSuite::G30() { tool_change(0); #endif - const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x), - parser.linearval('Y', current_position.y + probe.offset_xy.y) }; + // Convert the given logical position to native position + const xy_pos_t pos = { + parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x, + parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position.y + }; - if (!probe.can_reach(pos)) { - #if ENABLED(DWIN_LCD_PROUI) - SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); - LCD_MESSAGE(MSG_ZPROBE_OUT); - #endif - } - else { + if (probe.can_reach(pos)) { // Disable leveling so the planner won't mess with us TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); @@ -83,7 +80,7 @@ void GcodeSuite::G30() { const float measured_z = probe.probe_at_point(pos, raise_after, 1); TERN_(HAS_PTC, ptc.set_enabled(true)); if (!isnan(measured_z)) { - SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); + SERIAL_ECHOLNPGM("Bed X: ", pos.asLogical().x, " Y: ", pos.asLogical().y, " Z: ", measured_z); #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) char msg[31], str_1[6], str_2[6], str_3[6]; sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"), @@ -102,6 +99,12 @@ void GcodeSuite::G30() { report_current_position(); } + else { + #if ENABLED(DWIN_LCD_PROUI) + SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); + LCD_MESSAGE(MSG_ZPROBE_OUT); + #endif + } // Restore the active tool TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index)); diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 8b57b759266f..2866621d91b5 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -477,8 +477,11 @@ void GCodeQueue::get_serial_commands() { const long gcode_N = strtol(npos + 1, nullptr, 10); + // The line number must be in the correct sequence. if (gcode_N != serial.last_N + 1 && !M110) { - // In case of error on a serial port, don't prevent other serial port from making progress + // A request-for-resend line was already in transit so we got two - oops! + if (WITHIN(gcode_N, serial.last_N - 1, serial.last_N)) continue; + // A corrupted line or too high, indicating a lost line gcode_line_error(F(STR_ERR_LINE_NO), p); break; } @@ -488,13 +491,11 @@ void GCodeQueue::get_serial_commands() { uint8_t checksum = 0, count = uint8_t(apos - command); while (count) checksum ^= command[--count]; if (strtol(apos + 1, nullptr, 10) != checksum) { - // In case of error on a serial port, don't prevent other serial port from making progress gcode_line_error(F(STR_ERR_CHECKSUM_MISMATCH), p); break; } } else { - // In case of error on a serial port, don't prevent other serial port from making progress gcode_line_error(F(STR_ERR_NO_CHECKSUM), p); break; } diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index cb5f725e61ae..bc998f2ea81a 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -34,7 +34,7 @@ #include "../queue.h" #endif -#if EITHER(LCD_SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE) +#if EITHER(SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE) #include "../../lcd/marlinui.h" #endif @@ -90,7 +90,7 @@ void GcodeSuite::M1001() { process_subcommands_now(F("M77")); // Set the progress bar "done" state - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done()); + TERN_(SET_PROGRESS_PERCENT, ui.set_progress_done()); // Announce SD file completion { @@ -115,7 +115,6 @@ void GcodeSuite::M1001() { #endif TERN_(EXTENSIBLE_UI, ExtUI::onPrintDone()); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); #if ENABLED(RTS_AVAILABLE) diff --git a/Marlin/src/gcode/sd/M20.cpp b/Marlin/src/gcode/sd/M20.cpp index c640309be8c8..2a7e0d08df71 100644 --- a/Marlin/src/gcode/sd/M20.cpp +++ b/Marlin/src/gcode/sd/M20.cpp @@ -28,18 +28,23 @@ #include "../../sd/cardreader.h" /** - * M20: List SD card to serial output + * M20: List SD card to serial output in [name] [size] format. + * + * With CUSTOM_FIRMWARE_UPLOAD: + * F - List BIN files only, for use with firmware upload + * + * With LONG_FILENAME_HOST_SUPPORT: + * L - List long filenames (instead of DOS8.3 names) + * + * With M20_TIMESTAMP_SUPPORT: + * T - Include timestamps */ void GcodeSuite::M20() { if (card.flag.mounted) { SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST); - card.ls( - TERN_(CUSTOM_FIRMWARE_UPLOAD, parser.boolval('F')) - #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) - , - #endif - TERN_(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L')) - ); + card.ls(TERN0(CUSTOM_FIRMWARE_UPLOAD, parser.boolval('F') << LS_ONLY_BIN) + | TERN0(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L') << LS_LONG_FILENAME) + | TERN0(M20_TIMESTAMP_SUPPORT, parser.boolval('T') << LS_TIMESTAMP)); SERIAL_ECHOLNPGM(STR_END_FILE_LIST); } else diff --git a/Marlin/src/gcode/sd/M23.cpp b/Marlin/src/gcode/sd/M23.cpp index 51bc82413040..8722e9b6de95 100644 --- a/Marlin/src/gcode/sd/M23.cpp +++ b/Marlin/src/gcode/sd/M23.cpp @@ -38,7 +38,7 @@ void GcodeSuite::M23() { for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0'; card.openFileRead(parser.string_arg); - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0)); + TERN_(SET_PROGRESS_PERCENT, ui.set_progress(0)); } #endif // SDSUPPORT diff --git a/Marlin/src/gcode/sd/M524.cpp b/Marlin/src/gcode/sd/M524.cpp index 001a1e184263..f2b9274223c2 100644 --- a/Marlin/src/gcode/sd/M524.cpp +++ b/Marlin/src/gcode/sd/M524.cpp @@ -28,7 +28,7 @@ #include "../../sd/cardreader.h" #if ENABLED(DWIN_LCD_PROUI) - #include "../../lcd/e3v2/proui/dwin.h" + #include "../../lcd/marlinui.h" #endif /** @@ -38,7 +38,7 @@ void GcodeSuite::M524() { #if ENABLED(DWIN_LCD_PROUI) - HMI_flag.abort_flag = true; // The LCD will handle it + ui.abort_print(); #else diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 0ed1e6693013..2ff04797eb28 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -39,7 +39,6 @@ void GcodeSuite::M75() { startOrResumeJob(); #if ENABLED(DWIN_LCD_PROUI) - DWIN_Print_Started(false); if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); #endif } @@ -48,9 +47,8 @@ void GcodeSuite::M75() { * M76: Pause print timer */ void GcodeSuite::M76() { - print_job_timer.pause(); + TERN(DWIN_LCD_PROUI, ui.pause_print(), print_job_timer.pause()); TERN_(HOST_PAUSE_M76, hostui.pause()); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); } /** @@ -58,7 +56,6 @@ void GcodeSuite::M76() { */ void GcodeSuite::M77() { print_job_timer.stop(); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); } #if ENABLED(PRINTCOUNTER) diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index a4d514c7334f..820b1556d611 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -61,15 +61,9 @@ void GcodeSuite::M303() { const heater_id_t hid = (heater_id_t)parser.intval('E'); celsius_t default_temp; switch (hid) { - #if ENABLED(PIDTEMP) - case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break; - #endif - #if ENABLED(PIDTEMPBED) - case H_BED: default_temp = PREHEAT_1_TEMP_BED; break; - #endif - #if ENABLED(PIDTEMPCHAMBER) - case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break; - #endif + OPTCODE(PIDTEMP, case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break) + OPTCODE(PIDTEMPBED, case H_BED: default_temp = PREHEAT_1_TEMP_BED; break) + OPTCODE(PIDTEMPCHAMBER, case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break) default: SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID); @@ -84,9 +78,15 @@ void GcodeSuite::M303() { const celsius_t temp = seenS ? parser.value_celsius() : default_temp; const bool u = parser.boolval('U'); - #if ENABLED(DWIN_LCD_PROUI) + #if ENABLED(DWIN_LCD_PROUI) && EITHER(PIDTEMP, PIDTEMPBED) if (seenC) HMI_data.PidCycles = c; - if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else HMI_data.HotendPidT = temp; } + if (seenS) { + switch (hid) { + OPTCODE(PIDTEMP, case 0 ... HOTENDS - 1: HMI_data.HotendPidT = temp; break) + OPTCODE(PIDTEMPBED, case H_BED: HMI_data.BedPidT = temp; break) + default: break; + } + } #endif #if DISABLED(BUSY_WHILE_HEATING) diff --git a/Marlin/src/gcode/temp/M306.cpp b/Marlin/src/gcode/temp/M306.cpp index 7978922ff4c0..c6b700eac3b6 100644 --- a/Marlin/src/gcode/temp/M306.cpp +++ b/Marlin/src/gcode/temp/M306.cpp @@ -25,6 +25,7 @@ #if ENABLED(MPCTEMP) #include "../gcode.h" +#include "../../lcd/marlinui.h" #include "../../module/temperature.h" /** @@ -42,7 +43,12 @@ */ void GcodeSuite::M306() { - if (parser.seen_test('T')) { thermalManager.MPC_autotune(); return; } + if (parser.seen_test('T')) { + LCD_MESSAGE(MSG_MPC_AUTOTUNE); + thermalManager.MPC_autotune(); + ui.reset_status(); + return; + } if (parser.seen("ACFPRH")) { const heater_id_t hid = (heater_id_t)parser.intval('E', 0); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index c1c174da4642..6585c8ec3bf5 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -137,6 +137,7 @@ #define DOGLCD #define IS_U8GLIB_ST7920 1 #define IS_ULTIPANEL 1 + #define ENCODER_PULSES_PER_STEP 2 #elif ENABLED(MKS_12864OLED) @@ -373,6 +374,7 @@ #define LCD_I2C_TYPE_PCF8575 // I2C Character-based 12864 display #define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander + #define IS_ULTIPANEL 1 #if ENABLED(LCD_SAINSMART_I2C_2004) #define LCD_WIDTH 20 @@ -528,10 +530,6 @@ #define HAS_MANUAL_MOVE_MENU 1 #endif -#if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, IS_DWIN_MARLINUI, DWIN_CREALITY_LCD_JYERSUI) - #define CAN_SHOW_REMAINING_TIME 1 -#endif - #if HAS_MARLINUI_U8GLIB #ifndef LCD_PIXEL_WIDTH #define LCD_PIXEL_WIDTH 128 @@ -993,7 +991,7 @@ * with shared motion and temperature settings. * * DISTINCT_E is the number of distinguished extruders. By default this - * well be 1 which indicates all extruders share the same settings. + * will be 1 which indicates all extruders share the same settings. * * E_INDEX_N(E) should be used to get the E index of any item that might be * distinguished. @@ -1023,8 +1021,11 @@ #endif // Helper macros for extruder and hotend arrays -#define EXTRUDER_LOOP() for (int8_t e = 0; e < EXTRUDERS; e++) -#define HOTEND_LOOP() for (int8_t e = 0; e < HOTENDS; e++) +#define _EXTRUDER_LOOP(E) for (int8_t E = 0; E < EXTRUDERS; E++) +#define EXTRUDER_LOOP() _EXTRUDER_LOOP(e) +#define _HOTEND_LOOP(H) for (int8_t H = 0; H < HOTENDS; H++) +#define HOTEND_LOOP() _HOTEND_LOOP(e) + #define ARRAY_BY_EXTRUDERS(V...) ARRAY_N(EXTRUDERS, V) #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_N_1(EXTRUDERS, v1) #define ARRAY_BY_HOTENDS(V...) ARRAY_N(HOTENDS, V) @@ -1068,20 +1069,6 @@ #ifndef Z_PROBE_SERVO_NR #define Z_PROBE_SERVO_NR 0 #endif - #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 - #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) - #if Z_MIN_ENDSTOP_INVERTING - #error "BLTOUCH requires Z_MIN_ENDSTOP_INVERTING set to false. Please update your Configuration.h file." - #endif - #endif #endif /** @@ -1100,10 +1087,10 @@ /** * Set flags for any form of bed probe */ -#if ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, SOLENOID_PROBE, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) +#if ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, HAS_Z_SERVO_PROBE, SOLENOID_PROBE, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) #define HAS_STOWABLE_PROBE 1 #endif -#if ANY(HAS_STOWABLE_PROBE, HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, BD_SENSOR, NOZZLE_AS_PROBE) +#if ANY(HAS_STOWABLE_PROBE, FIX_MOUNTED_PROBE, BD_SENSOR, NOZZLE_AS_PROBE) #define HAS_BED_PROBE 1 #endif @@ -1207,45 +1194,61 @@ #elif X_HOME_DIR < 0 #define X_HOME_TO_MIN 1 #endif -#if Y_HOME_DIR > 0 - #define Y_HOME_TO_MAX 1 -#elif Y_HOME_DIR < 0 - #define Y_HOME_TO_MIN 1 +#if HAS_Y_AXIS + #if Y_HOME_DIR > 0 + #define Y_HOME_TO_MAX 1 + #elif Y_HOME_DIR < 0 + #define Y_HOME_TO_MIN 1 + #endif #endif -#if Z_HOME_DIR > 0 - #define Z_HOME_TO_MAX 1 -#elif Z_HOME_DIR < 0 - #define Z_HOME_TO_MIN 1 +#if HAS_Z_AXIS + #if Z_HOME_DIR > 0 + #define Z_HOME_TO_MAX 1 + #elif Z_HOME_DIR < 0 + #define Z_HOME_TO_MIN 1 + #endif #endif -#if I_HOME_DIR > 0 - #define I_HOME_TO_MAX 1 -#elif I_HOME_DIR < 0 - #define I_HOME_TO_MIN 1 +#if HAS_I_AXIS + #if I_HOME_DIR > 0 + #define I_HOME_TO_MAX 1 + #elif I_HOME_DIR < 0 + #define I_HOME_TO_MIN 1 + #endif #endif -#if J_HOME_DIR > 0 - #define J_HOME_TO_MAX 1 -#elif J_HOME_DIR < 0 - #define J_HOME_TO_MIN 1 +#if HAS_J_AXIS + #if J_HOME_DIR > 0 + #define J_HOME_TO_MAX 1 + #elif J_HOME_DIR < 0 + #define J_HOME_TO_MIN 1 + #endif #endif -#if K_HOME_DIR > 0 - #define K_HOME_TO_MAX 1 -#elif K_HOME_DIR < 0 - #define K_HOME_TO_MIN 1 +#if HAS_K_AXIS + #if K_HOME_DIR > 0 + #define K_HOME_TO_MAX 1 + #elif K_HOME_DIR < 0 + #define K_HOME_TO_MIN 1 + #endif #endif -#if U_HOME_DIR > 0 - #define U_HOME_TO_MAX 1 -#elif U_HOME_DIR < 0 - #define U_HOME_TO_MIN 1 +#if HAS_U_AXIS + #if U_HOME_DIR > 0 + #define U_HOME_TO_MAX 1 + #elif U_HOME_DIR < 0 + #define U_HOME_TO_MIN 1 + #endif #endif -#if V_HOME_DIR > 0 - #define V_HOME_TO_MAX 1 -#elif V_HOME_DIR < 0 - #define V_HOME_TO_MIN 1 +#if HAS_V_AXIS + #if V_HOME_DIR > 0 + #define V_HOME_TO_MAX 1 + #elif V_HOME_DIR < 0 + #define V_HOME_TO_MIN 1 + #endif #endif -#if W_HOME_DIR > 0 - #define W_HOME_TO_MAX 1 -#elif W_HOME_DIR < 0 - #define W_HOME_TO_MIN 1 +#if HAS_W_AXIS + #if W_HOME_DIR > 0 + #define W_HOME_TO_MAX 1 + #elif W_HOME_DIR < 0 + #define W_HOME_TO_MIN 1 + #endif #endif /** @@ -1281,6 +1284,7 @@ // Clear probe pin settings when no probe is selected #undef Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN #undef USE_PROBE_FOR_Z_HOMING + #undef Z_MIN_PROBE_REPEATABILITY_TEST #endif #if ENABLED(BELTPRINTER) && !defined(HOME_Y_BEFORE_X) @@ -1499,7 +1503,7 @@ #endif #elif ENABLED(TFT_GENERIC) #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) - #if NONE(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320) + #if NONE(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320, TFT_RES_1024x600) #define TFT_RES_320x240 #endif #if NONE(TFT_INTERFACE_FSMC, TFT_INTERFACE_SPI) @@ -1577,6 +1581,8 @@ #elif TFT_HEIGHT == 600 #if ENABLED(TFT_INTERFACE_LTDC) #define TFT_1024x600_LTDC + #else + #define TFT_1024x600_SIM // "Simulation" - for testing purposes only #endif #endif #endif @@ -1587,7 +1593,7 @@ #define HAS_UI_480x320 1 #elif EITHER(TFT_480x272, TFT_480x272_SPI) #define HAS_UI_480x272 1 -#elif defined(TFT_1024x600_LTDC) +#elif EITHER(TFT_1024x600_LTDC, TFT_1024x600_SIM) #define HAS_UI_1024x600 1 #endif #if ANY(HAS_UI_320x240, HAS_UI_480x320, HAS_UI_480x272) @@ -1598,7 +1604,7 @@ // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046' #if ENABLED(TOUCH_SCREEN) - #if TOUCH_IDLE_SLEEP + #if TOUCH_IDLE_SLEEP_MINS #define HAS_TOUCH_SLEEP 1 #endif #if NONE(TFT_TOUCH_DEVICE_GT911, TFT_TOUCH_DEVICE_XPT2046) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 597d463eb89a..5122818cc44e 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -79,6 +79,9 @@ #define SERVO_DELAY { 50 } #endif +#if !HAS_BED_PROBE + #undef BABYSTEP_ZPROBE_OFFSET +#endif #if !HAS_STOWABLE_PROBE #undef PROBE_DEPLOY_STOW_MENU #endif @@ -161,9 +164,10 @@ #define HID_E6 6 #define HID_E7 7 -#define _SENSOR_IS(I,N) || (TEMP_SENSOR_##N == I) +#define _SENSOR_IS(I,N) || (TEMP_SENSOR(N) == I) #define _E_SENSOR_IS(I,N) _SENSOR_IS(N,I) -#define ANY_THERMISTOR_IS(N) (0 REPEAT2(HOTENDS, _E_SENSOR_IS, N) \ +#define ANY_E_SENSOR_IS(N) (0 REPEAT2(HOTENDS, _E_SENSOR_IS, N)) +#define ANY_THERMISTOR_IS(N) ( ANY_E_SENSOR_IS(N) \ _SENSOR_IS(N,BED) _SENSOR_IS(N,PROBE) _SENSOR_IS(N,CHAMBER) \ _SENSOR_IS(N,COOLER) _SENSOR_IS(N,BOARD) _SENSOR_IS(N,REDUNDANT) ) @@ -261,26 +265,72 @@ #undef HEATER_1_MAXTEMP #endif +#if TEMP_SENSOR_IS_MAX_TC(2) + #if TEMP_SENSOR_2 == -5 + #define TEMP_SENSOR_2_IS_MAX31865 1 + #define TEMP_SENSOR_2_MAX_TC_TMIN 0 + #define TEMP_SENSOR_2_MAX_TC_TMAX 1024 + #ifndef MAX31865_SENSOR_WIRES_2 + #define MAX31865_SENSOR_WIRES_2 2 + #endif + #ifndef MAX31865_WIRE_OHMS_2 + #define MAX31865_WIRE_OHMS_2 0.0f + #endif + #elif TEMP_SENSOR_2 == -3 + #define TEMP_SENSOR_2_IS_MAX31855 1 + #define TEMP_SENSOR_2_MAX_TC_TMIN -270 + #define TEMP_SENSOR_2_MAX_TC_TMAX 1800 + #elif TEMP_SENSOR_2 == -2 + #define TEMP_SENSOR_2_IS_MAX6675 1 + #define TEMP_SENSOR_2_MAX_TC_TMIN 0 + #define TEMP_SENSOR_2_MAX_TC_TMAX 1024 + #endif + + #if TEMP_SENSOR_2 != TEMP_SENSOR_0 + #if TEMP_SENSOR_2 == -5 + #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_2 then TEMP_SENSOR_0 must match." + #elif TEMP_SENSOR_2 == -3 + #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_2 then TEMP_SENSOR_0 must match." + #elif TEMP_SENSOR_2 == -2 + #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_2 then TEMP_SENSOR_0 must match." + #endif + #endif +#elif TEMP_SENSOR_2 == -4 + #define TEMP_SENSOR_2_IS_AD8495 1 +#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_IS_MAX_TC(REDUNDANT) #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)." + #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2) + #error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)." #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)." + #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2) + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)." #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)." + #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2) + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)." #endif #define TEMP_SENSOR_REDUNDANT_IS_MAX6675 1 @@ -301,15 +351,21 @@ #ifndef MAX31865_SENSOR_WIRES_1 #define MAX31865_SENSOR_WIRES_1 2 #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E2) + #define TEMP_SENSOR_2_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + #define TEMP_SENSOR_2_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX + #ifndef MAX31865_SENSOR_WIRES_2 + #define MAX31865_SENSOR_WIRES_2 2 + #endif #endif - #if (TEMP_SENSOR_IS_MAX_TC(0) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_IS_MAX_TC(1) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) + #if (TEMP_SENSOR_IS_MAX_TC(0) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_IS_MAX_TC(1) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) || (TEMP_SENSOR_IS_MAX_TC(2) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_2) #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." + #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 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." + #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 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." + #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match." #endif #endif #elif TEMP_SENSOR_REDUNDANT == -4 @@ -325,39 +381,19 @@ #endif #endif -#if TEMP_SENSOR_IS_MAX_TC(0) || TEMP_SENSOR_IS_MAX_TC(1) || TEMP_SENSOR_IS_MAX_TC(REDUNDANT) +#if TEMP_SENSOR_IS_MAX_TC(0) || TEMP_SENSOR_IS_MAX_TC(1) || TEMP_SENSOR_IS_MAX_TC(2) || TEMP_SENSOR_IS_MAX_TC(REDUNDANT) #define HAS_MAX_TC 1 #endif -#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675 +#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_2_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 +#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_2_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 +#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_2_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 @@ -598,10 +634,16 @@ #undef MENU_ADDAUTOSTART #endif -#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) +#if EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY) #define HAS_PRINT_PROGRESS 1 #endif +#if DISABLED(SET_PROGRESS_MANUALLY) + #undef SET_REMAINING_TIME + #undef SET_INTERACTION_TIME + #undef M73_REPORT +#endif + #if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) #define HAS_ENCODER_ACTION 1 #endif @@ -647,10 +689,10 @@ #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT) #define HAS_LEDS_OFF_FLAG 1 #endif -#ifdef DISPLAY_SLEEP_MINUTES +#if DISPLAY_SLEEP_MINUTES || TOUCH_IDLE_SLEEP_MINS #define HAS_DISPLAY_SLEEP 1 #endif -#if HAS_DISPLAY_SLEEP || LCD_BACKLIGHT_TIMEOUT +#if HAS_DISPLAY_SLEEP || LCD_BACKLIGHT_TIMEOUT_MINS #define HAS_GCODE_M255 1 #endif @@ -955,8 +997,8 @@ #undef CALIBRATION_MEASURE_IMIN #undef CALIBRATION_MEASURE_IMAX #if NUM_AXES < 3 - #undef Z_IDLE_HEIGHT #undef STEALTHCHOP_Z + #undef Z_IDLE_HEIGHT #undef Z_PROBE_SLED #undef Z_SAFE_HOMING #undef HOME_Z_FIRST @@ -966,6 +1008,7 @@ #undef CNC_WORKSPACE_PLANES #if NUM_AXES < 2 #undef STEALTHCHOP_Y + #undef QUICK_HOME #endif #endif #endif @@ -1003,7 +1046,7 @@ #endif // Flag whether hex_print.cpp is used -#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER) +#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER, M20_TIMESTAMP_SUPPORT) #define NEED_HEX_PRINT 1 #endif @@ -1038,7 +1081,7 @@ */ #ifndef LCD_SERIAL_PORT #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI || HAS_DGUS_LCD - #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_MINI_E3_V3_0, BTT_SKR_E3_TURBO) + #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_MINI_E3_V3_0, BTT_SKR_E3_TURBO, BTT_OCTOPUS_V1_1) #define LCD_SERIAL_PORT 1 #elif MB(CREALITY_V24S1_301, CREALITY_V24S1_301F4, CREALITY_V423, MKS_E3D_V2) #define LCD_SERIAL_PORT 2 @@ -1068,3 +1111,24 @@ #if ANY(DISABLE_INACTIVE_X, DISABLE_INACTIVE_Y, DISABLE_INACTIVE_Z, DISABLE_INACTIVE_I, DISABLE_INACTIVE_J, DISABLE_INACTIVE_K, DISABLE_INACTIVE_U, DISABLE_INACTIVE_V, DISABLE_INACTIVE_W, DISABLE_INACTIVE_E) #define HAS_DISABLE_INACTIVE_AXIS 1 #endif + +// Fan Kickstart +#if FAN_KICKSTART_TIME && !defined(FAN_KICKSTART_POWER) + #define FAN_KICKSTART_POWER 180 +#endif + +#if FAN_MIN_PWM == 0 && FAN_MAX_PWM == 255 + #define CALC_FAN_SPEED(f) (f ?: FAN_OFF_PWM) +#else + #define CALC_FAN_SPEED(f) (f ? map(f, 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM) +#endif + +// Input shaping +#if !HAS_Y_AXIS + #undef INPUT_SHAPING_Y + #undef SHAPING_FREQ_Y + #undef SHAPING_BUFFER_Y +#endif +#if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y) + #define HAS_SHAPING 1 +#endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 7efd50d2b293..2f3aa5fb48bd 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -155,7 +155,7 @@ #define W_BED_SIZE W_MAX_LENGTH #endif -// Require 0,0 bed center for Delta and SCARA +// Require 0,0 bed center for Delta, SCARA, and Polargraph #if IS_KINEMATIC #define BED_CENTER_AT_0_0 #endif @@ -275,10 +275,12 @@ */ #if IS_SCARA #undef SLOWDOWN - #if DISABLED(AXEL_TPARA) + #if ENABLED(AXEL_TPARA) + #define SCARA_PRINTABLE_RADIUS (TPARA_LINKAGE_1 + TPARA_LINKAGE_2) + #else #define QUICK_HOME + #define SCARA_PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2) #endif - #define SCARA_PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2) #endif /** @@ -723,19 +725,19 @@ #define TEMP_0_SCK_PIN MAX31855_SCK_PIN #endif - #elif TEMP_SENSOR_1_IS_MAX31865 - #if !PIN_EXISTS(TEMP_1_MISO) // DO + #elif TEMP_SENSOR_0_IS_MAX31865 + #if !PIN_EXISTS(TEMP_0_MISO) // DO #if PIN_EXISTS(MAX31865_MISO) - #define TEMP_1_MISO_PIN MAX31865_MISO_PIN + #define TEMP_0_MISO_PIN MAX31865_MISO_PIN #elif PIN_EXISTS(MAX31865_DO) - #define TEMP_1_MISO_PIN MAX31865_DO_PIN + #define TEMP_0_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 + #if !PIN_EXISTS(TEMP_0_SCK) && PIN_EXISTS(MAX31865_SCK) + #define TEMP_0_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 + #if !PIN_EXISTS(TEMP_0_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only + #define TEMP_0_MOSI_PIN MAX31865_MOSI_PIN #endif #endif @@ -819,6 +821,75 @@ #endif // TEMP_SENSOR_IS_MAX_TC(1) + #if TEMP_SENSOR_IS_MAX_TC(2) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2)) + + #if !PIN_EXISTS(TEMP_2_CS) // SS3, CS3 + #if PIN_EXISTS(MAX6675_SS3) + #define TEMP_2_CS_PIN MAX6675_SS3_PIN + #elif PIN_EXISTS(MAX6675_CS) + #define TEMP_2_CS_PIN MAX6675_CS3_PIN + #elif PIN_EXISTS(MAX31855_SS3) + #define TEMP_2_CS_PIN MAX31855_SS3_PIN + #elif PIN_EXISTS(MAX31855_CS3) + #define TEMP_2_CS_PIN MAX31855_CS3_PIN + #elif PIN_EXISTS(MAX31865_SS3) + #define TEMP_2_CS_PIN MAX31865_SS3_PIN + #elif PIN_EXISTS(MAX31865_CS3) + #define TEMP_2_CS_PIN MAX31865_CS3_PIN + #endif + #endif + + #if TEMP_SENSOR_2_IS_MAX6675 + #if !PIN_EXISTS(TEMP_2_MISO) // DO + #if PIN_EXISTS(MAX6675_MISO) + #define TEMP_2_MISO_PIN MAX6675_MISO_PIN + #elif PIN_EXISTS(MAX6675_DO) + #define TEMP_2_MISO_PIN MAX6675_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_2_SCK) && PIN_EXISTS(MAX6675_SCK) + #define TEMP_2_SCK_PIN MAX6675_SCK_PIN + #endif + + #elif TEMP_SENSOR_2_IS_MAX31855 + #if !PIN_EXISTS(TEMP_2_MISO) // DO + #if PIN_EXISTS(MAX31855_MISO) + #define TEMP_2_MISO_PIN MAX31855_MISO_PIN + #elif PIN_EXISTS(MAX31855_DO) + #define TEMP_2_MISO_PIN MAX31855_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_2_SCK) && PIN_EXISTS(MAX31855_SCK) + #define TEMP_2_SCK_PIN MAX31855_SCK_PIN + #endif + + #elif TEMP_SENSOR_2_IS_MAX31865 + #if !PIN_EXISTS(TEMP_2_MISO) // DO + #if PIN_EXISTS(MAX31865_MISO) + #define TEMP_2_MISO_PIN MAX31865_MISO_PIN + #elif PIN_EXISTS(MAX31865_DO) + #define TEMP_2_MISO_PIN MAX31865_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_2_SCK) && PIN_EXISTS(MAX31865_SCK) + #define TEMP_2_SCK_PIN MAX31865_SCK_PIN + #endif + #if !PIN_EXISTS(TEMP_2_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only + #define TEMP_2_MOSI_PIN MAX31865_MOSI_PIN + #endif + #endif + + // Software SPI - enable if MISO/SCK are defined. + #if PIN_EXISTS(TEMP_2_MISO) && PIN_EXISTS(TEMP_2_SCK) && DISABLED(TEMP_SENSOR_2_FORCE_HW_SPI) + #if TEMP_SENSOR_2_IS_MAX31865 && !PIN_EXISTS(TEMP_2_MOSI) + #error "TEMP_SENSOR_2 MAX31865 requires TEMP_2_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_2_FORCE_HW_SPI." + #else + #define TEMP_SENSOR_2_HAS_SPI_PINS 1 + #endif + #endif + + #endif // TEMP_SENSOR_IS_MAX_TC(2) + // // User-defined thermocouple libraries // @@ -857,56 +928,14 @@ #define X2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif X2_USE_ENDSTOP == _ZMAX_ #define X2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define X2_MAX_ENDSTOP_INVERTING false #endif #endif - #if !defined(X2_MAX_PIN) && !defined(X2_STOP_PIN) - #if X2_USE_ENDSTOP == _XMIN_ - #define X2_MAX_PIN X_MIN_PIN - #elif X2_USE_ENDSTOP == _XMAX_ - #define X2_MAX_PIN X_MAX_PIN - #elif X2_USE_ENDSTOP == _XSTOP_ - #define X2_MAX_PIN X_STOP_PIN - #elif X2_USE_ENDSTOP == _YMIN_ - #define X2_MAX_PIN Y_MIN_PIN - #elif X2_USE_ENDSTOP == _YMAX_ - #define X2_MAX_PIN Y_MAX_PIN - #elif X2_USE_ENDSTOP == _YSTOP_ - #define X2_MAX_PIN Y_STOP_PIN - #elif X2_USE_ENDSTOP == _ZMIN_ - #define X2_MAX_PIN Z_MIN_PIN - #elif X2_USE_ENDSTOP == _ZMAX_ - #define X2_MAX_PIN Z_MAX_PIN - #elif X2_USE_ENDSTOP == _ZSTOP_ - #define X2_MAX_PIN Z_STOP_PIN - #elif X2_USE_ENDSTOP == _XDIAG_ - #define X2_MAX_PIN X_DIAG_PIN - #elif X2_USE_ENDSTOP == _YDIAG_ - #define X2_MAX_PIN Y_DIAG_PIN - #elif X2_USE_ENDSTOP == _ZDIAG_ - #define X2_MAX_PIN Z_DIAG_PIN - #elif X2_USE_ENDSTOP == _E0DIAG_ - #define X2_MAX_PIN E0_DIAG_PIN - #elif X2_USE_ENDSTOP == _E1DIAG_ - #define X2_MAX_PIN E1_DIAG_PIN - #elif X2_USE_ENDSTOP == _E2DIAG_ - #define X2_MAX_PIN E2_DIAG_PIN - #elif X2_USE_ENDSTOP == _E3DIAG_ - #define X2_MAX_PIN E3_DIAG_PIN - #elif X2_USE_ENDSTOP == _E4DIAG_ - #define X2_MAX_PIN E4_DIAG_PIN - #elif X2_USE_ENDSTOP == _E5DIAG_ - #define X2_MAX_PIN E5_DIAG_PIN - #elif X2_USE_ENDSTOP == _E6DIAG_ - #define X2_MAX_PIN E6_DIAG_PIN - #elif X2_USE_ENDSTOP == _E7DIAG_ - #define X2_MAX_PIN E7_DIAG_PIN + #if !PIN_EXISTS(X2_MAX) + #undef X2_MAX_PIN + #if PIN_EXISTS(X2_STOP) + #define X2_MAX_PIN X2_STOP_PIN #endif #endif - #ifndef X2_MIN_ENDSTOP_INVERTING - #define X2_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef X2_MIN_ENDSTOP_INVERTING #if X2_USE_ENDSTOP == _XMIN_ @@ -921,56 +950,20 @@ #define X2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif X2_USE_ENDSTOP == _ZMAX_ #define X2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define X2_MIN_ENDSTOP_INVERTING false #endif #endif - #if !defined(X2_MIN_PIN) && !defined(X2_STOP_PIN) - #if X2_USE_ENDSTOP == _XMIN_ - #define X2_MIN_PIN X_MIN_PIN - #elif X2_USE_ENDSTOP == _XMAX_ - #define X2_MIN_PIN X_MAX_PIN - #elif X2_USE_ENDSTOP == _XSTOP_ - #define X2_MIN_PIN X_STOP_PIN - #elif X2_USE_ENDSTOP == _YMIN_ - #define X2_MIN_PIN Y_MIN_PIN - #elif X2_USE_ENDSTOP == _YMAX_ - #define X2_MIN_PIN Y_MAX_PIN - #elif X2_USE_ENDSTOP == _YSTOP_ - #define X2_MIN_PIN Y_STOP_PIN - #elif X2_USE_ENDSTOP == _ZMIN_ - #define X2_MIN_PIN Z_MIN_PIN - #elif X2_USE_ENDSTOP == _ZMAX_ - #define X2_MIN_PIN Z_MAX_PIN - #elif X2_USE_ENDSTOP == _ZSTOP_ - #define X2_MIN_PIN Z_STOP_PIN - #elif X2_USE_ENDSTOP == _XDIAG_ - #define X2_MIN_PIN X_DIAG_PIN - #elif X2_USE_ENDSTOP == _YDIAG_ - #define X2_MIN_PIN Y_DIAG_PIN - #elif X2_USE_ENDSTOP == _ZDIAG_ - #define X2_MIN_PIN Z_DIAG_PIN - #elif X2_USE_ENDSTOP == _E0DIAG_ - #define X2_MIN_PIN E0_DIAG_PIN - #elif X2_USE_ENDSTOP == _E1DIAG_ - #define X2_MIN_PIN E1_DIAG_PIN - #elif X2_USE_ENDSTOP == _E2DIAG_ - #define X2_MIN_PIN E2_DIAG_PIN - #elif X2_USE_ENDSTOP == _E3DIAG_ - #define X2_MIN_PIN E3_DIAG_PIN - #elif X2_USE_ENDSTOP == _E4DIAG_ - #define X2_MIN_PIN E4_DIAG_PIN - #elif X2_USE_ENDSTOP == _E5DIAG_ - #define X2_MIN_PIN E5_DIAG_PIN - #elif X2_USE_ENDSTOP == _E6DIAG_ - #define X2_MIN_PIN E6_DIAG_PIN - #elif X2_USE_ENDSTOP == _E7DIAG_ - #define X2_MIN_PIN E7_DIAG_PIN + #if !PIN_EXISTS(X2_MIN) + #undef X2_MIN_PIN + #if PIN_EXISTS(X2_STOP) + #define X2_MIN_PIN X2_STOP_PIN #endif #endif - #ifndef X2_MAX_ENDSTOP_INVERTING - #define X2_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef X2_MAX_ENDSTOP_INVERTING + #define X2_MAX_ENDSTOP_INVERTING false + #endif + #ifndef X2_MIN_ENDSTOP_INVERTING + #define X2_MIN_ENDSTOP_INVERTING false #endif #endif @@ -992,56 +985,14 @@ #define Y2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Y2_USE_ENDSTOP == _ZMAX_ #define Y2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Y2_MAX_ENDSTOP_INVERTING false #endif #endif - #if !defined(Y2_MAX_PIN) && !defined(Y2_STOP_PIN) - #if Y2_USE_ENDSTOP == _XMIN_ - #define Y2_MAX_PIN X_MIN_PIN - #elif Y2_USE_ENDSTOP == _XMAX_ - #define Y2_MAX_PIN X_MAX_PIN - #elif Y2_USE_ENDSTOP == _XSTOP_ - #define Y2_MAX_PIN X_STOP_PIN - #elif Y2_USE_ENDSTOP == _YMIN_ - #define Y2_MAX_PIN Y_MIN_PIN - #elif Y2_USE_ENDSTOP == _YMAX_ - #define Y2_MAX_PIN Y_MAX_PIN - #elif Y2_USE_ENDSTOP == _YSTOP_ - #define Y2_MAX_PIN Y_STOP_PIN - #elif Y2_USE_ENDSTOP == _ZMIN_ - #define Y2_MAX_PIN Z_MIN_PIN - #elif Y2_USE_ENDSTOP == _ZMAX_ - #define Y2_MAX_PIN Z_MAX_PIN - #elif Y2_USE_ENDSTOP == _ZSTOP_ - #define Y2_MAX_PIN Z_STOP_PIN - #elif Y2_USE_ENDSTOP == _XDIAG_ - #define Y2_MAX_PIN X_DIAG_PIN - #elif Y2_USE_ENDSTOP == _YDIAG_ - #define Y2_MAX_PIN Y_DIAG_PIN - #elif Y2_USE_ENDSTOP == _ZDIAG_ - #define Y2_MAX_PIN Z_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E0DIAG_ - #define Y2_MAX_PIN E0_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E1DIAG_ - #define Y2_MAX_PIN E1_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E2DIAG_ - #define Y2_MAX_PIN E2_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E3DIAG_ - #define Y2_MAX_PIN E3_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E4DIAG_ - #define Y2_MAX_PIN E4_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E5DIAG_ - #define Y2_MAX_PIN E5_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E6DIAG_ - #define Y2_MAX_PIN E6_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E7DIAG_ - #define Y2_MAX_PIN E7_DIAG_PIN + #if !PIN_EXISTS(Y2_MAX) + #undef Y2_MAX_PIN + #if PIN_EXISTS(Y2_STOP) + #define Y2_MAX_PIN Y2_STOP_PIN #endif #endif - #ifndef Y2_MIN_ENDSTOP_INVERTING - #define Y2_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef Y2_MIN_ENDSTOP_INVERTING #if Y2_USE_ENDSTOP == _XMIN_ @@ -1056,56 +1007,20 @@ #define Y2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Y2_USE_ENDSTOP == _ZMAX_ #define Y2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Y2_MIN_ENDSTOP_INVERTING false #endif #endif - #if !defined(Y2_MIN_PIN) && !defined(Y2_STOP_PIN) - #if Y2_USE_ENDSTOP == _XMIN_ - #define Y2_MIN_PIN X_MIN_PIN - #elif Y2_USE_ENDSTOP == _XMAX_ - #define Y2_MIN_PIN X_MAX_PIN - #elif Y2_USE_ENDSTOP == _XSTOP_ - #define Y2_MIN_PIN X_STOP_PIN - #elif Y2_USE_ENDSTOP == _YMIN_ - #define Y2_MIN_PIN Y_MIN_PIN - #elif Y2_USE_ENDSTOP == _YMAX_ - #define Y2_MIN_PIN Y_MAX_PIN - #elif Y2_USE_ENDSTOP == _YSTOP_ - #define Y2_MIN_PIN Y_STOP_PIN - #elif Y2_USE_ENDSTOP == _ZMIN_ - #define Y2_MIN_PIN Z_MIN_PIN - #elif Y2_USE_ENDSTOP == _ZMAX_ - #define Y2_MIN_PIN Z_MAX_PIN - #elif Y2_USE_ENDSTOP == _ZSTOP_ - #define Y2_MIN_PIN Z_STOP_PIN - #elif Y2_USE_ENDSTOP == _XDIAG_ - #define Y2_MIN_PIN X_DIAG_PIN - #elif Y2_USE_ENDSTOP == _YDIAG_ - #define Y2_MIN_PIN Y_DIAG_PIN - #elif Y2_USE_ENDSTOP == _ZDIAG_ - #define Y2_MIN_PIN Z_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E0DIAG_ - #define Y2_MIN_PIN E0_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E1DIAG_ - #define Y2_MIN_PIN E1_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E2DIAG_ - #define Y2_MIN_PIN E2_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E3DIAG_ - #define Y2_MIN_PIN E3_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E4DIAG_ - #define Y2_MIN_PIN E4_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E5DIAG_ - #define Y2_MIN_PIN E5_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E6DIAG_ - #define Y2_MIN_PIN E6_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E7DIAG_ - #define Y2_MIN_PIN E7_DIAG_PIN + #if !PIN_EXISTS(Y2_MIN) + #undef Y2_MIN_PIN + #if PIN_EXISTS(Y2_STOP) + #define Y2_MIN_PIN Y2_STOP_PIN #endif #endif - #ifndef Y2_MAX_ENDSTOP_INVERTING - #define Y2_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef Y2_MAX_ENDSTOP_INVERTING + #define Y2_MAX_ENDSTOP_INVERTING false + #endif + #ifndef Y2_MIN_ENDSTOP_INVERTING + #define Y2_MIN_ENDSTOP_INVERTING false #endif #endif @@ -1128,56 +1043,14 @@ #define Z2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z2_USE_ENDSTOP == _ZMAX_ #define Z2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z2_MAX_ENDSTOP_INVERTING false #endif #endif - #if !defined(Z2_MAX_PIN) && !defined(Z2_STOP_PIN) - #if Z2_USE_ENDSTOP == _XMIN_ - #define Z2_MAX_PIN X_MIN_PIN - #elif Z2_USE_ENDSTOP == _XMAX_ - #define Z2_MAX_PIN X_MAX_PIN - #elif Z2_USE_ENDSTOP == _XSTOP_ - #define Z2_MAX_PIN X_STOP_PIN - #elif Z2_USE_ENDSTOP == _YMIN_ - #define Z2_MAX_PIN Y_MIN_PIN - #elif Z2_USE_ENDSTOP == _YMAX_ - #define Z2_MAX_PIN Y_MAX_PIN - #elif Z2_USE_ENDSTOP == _YSTOP_ - #define Z2_MAX_PIN Y_STOP_PIN - #elif Z2_USE_ENDSTOP == _ZMIN_ - #define Z2_MAX_PIN Z_MIN_PIN - #elif Z2_USE_ENDSTOP == _ZMAX_ - #define Z2_MAX_PIN Z_MAX_PIN - #elif Z2_USE_ENDSTOP == _ZSTOP_ - #define Z2_MAX_PIN Z_STOP_PIN - #elif Z2_USE_ENDSTOP == _XDIAG_ - #define Z2_MAX_PIN X_DIAG_PIN - #elif Z2_USE_ENDSTOP == _YDIAG_ - #define Z2_MAX_PIN Y_DIAG_PIN - #elif Z2_USE_ENDSTOP == _ZDIAG_ - #define Z2_MAX_PIN Z_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E0DIAG_ - #define Z2_MAX_PIN E0_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E1DIAG_ - #define Z2_MAX_PIN E1_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E2DIAG_ - #define Z2_MAX_PIN E2_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E3DIAG_ - #define Z2_MAX_PIN E3_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E4DIAG_ - #define Z2_MAX_PIN E4_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E5DIAG_ - #define Z2_MAX_PIN E5_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E6DIAG_ - #define Z2_MAX_PIN E6_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E7DIAG_ - #define Z2_MAX_PIN E7_DIAG_PIN + #if !PIN_EXISTS(Z2_MAX) + #undef Z2_MAX_PIN + #if PIN_EXISTS(Z2_STOP) + #define Z2_MAX_PIN Z2_STOP_PIN #endif #endif - #ifndef Z2_MIN_ENDSTOP_INVERTING - #define Z2_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef Z2_MIN_ENDSTOP_INVERTING #if Z2_USE_ENDSTOP == _XMIN_ @@ -1192,56 +1065,20 @@ #define Z2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z2_USE_ENDSTOP == _ZMAX_ #define Z2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z2_MIN_ENDSTOP_INVERTING false #endif #endif - #ifndef Z2_MIN_PIN - #if Z2_USE_ENDSTOP == _XMIN_ - #define Z2_MIN_PIN X_MIN_PIN - #elif Z2_USE_ENDSTOP == _XMAX_ - #define Z2_MIN_PIN X_MAX_PIN - #elif Z2_USE_ENDSTOP == _XSTOP_ - #define Z2_MIN_PIN X_STOP_PIN - #elif Z2_USE_ENDSTOP == _YMIN_ - #define Z2_MIN_PIN Y_MIN_PIN - #elif Z2_USE_ENDSTOP == _YMAX_ - #define Z2_MIN_PIN Y_MAX_PIN - #elif Z2_USE_ENDSTOP == _YSTOP_ - #define Z2_MIN_PIN Y_STOP_PIN - #elif Z2_USE_ENDSTOP == _ZMIN_ - #define Z2_MIN_PIN Z_MIN_PIN - #elif Z2_USE_ENDSTOP == _ZMAX_ - #define Z2_MIN_PIN Z_MAX_PIN - #elif Z2_USE_ENDSTOP == _ZSTOP_ - #define Z2_MIN_PIN Z_STOP_PIN - #elif Z2_USE_ENDSTOP == _XDIAG_ - #define Z2_MIN_PIN X_DIAG_PIN - #elif Z2_USE_ENDSTOP == _YDIAG_ - #define Z2_MIN_PIN Y_DIAG_PIN - #elif Z2_USE_ENDSTOP == _ZDIAG_ - #define Z2_MIN_PIN Z_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E0DIAG_ - #define Z2_MIN_PIN E0_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E1DIAG_ - #define Z2_MIN_PIN E1_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E2DIAG_ - #define Z2_MIN_PIN E2_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E3DIAG_ - #define Z2_MIN_PIN E3_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E4DIAG_ - #define Z2_MIN_PIN E4_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E5DIAG_ - #define Z2_MIN_PIN E5_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E6DIAG_ - #define Z2_MIN_PIN E6_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E7DIAG_ - #define Z2_MIN_PIN E7_DIAG_PIN + #if !PIN_EXISTS(Z2_MIN) + #undef Z2_MIN_PIN + #if PIN_EXISTS(Z2_STOP) + #define Z2_MIN_PIN Z2_STOP_PIN #endif #endif - #ifndef Z2_MAX_ENDSTOP_INVERTING - #define Z2_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef Z2_MAX_ENDSTOP_INVERTING + #define Z2_MAX_ENDSTOP_INVERTING false + #endif + #ifndef Z2_MIN_ENDSTOP_INVERTING + #define Z2_MIN_ENDSTOP_INVERTING false #endif #if NUM_Z_STEPPERS >= 3 @@ -1259,56 +1096,14 @@ #define Z3_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z3_USE_ENDSTOP == _ZMAX_ #define Z3_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z3_MAX_ENDSTOP_INVERTING false #endif #endif - #ifndef Z3_MAX_PIN - #if Z3_USE_ENDSTOP == _XMIN_ - #define Z3_MAX_PIN X_MIN_PIN - #elif Z3_USE_ENDSTOP == _XMAX_ - #define Z3_MAX_PIN X_MAX_PIN - #elif Z3_USE_ENDSTOP == _XSTOP_ - #define Z3_MAX_PIN X_STOP_PIN - #elif Z3_USE_ENDSTOP == _YMIN_ - #define Z3_MAX_PIN Y_MIN_PIN - #elif Z3_USE_ENDSTOP == _YMAX_ - #define Z3_MAX_PIN Y_MAX_PIN - #elif Z3_USE_ENDSTOP == _YSTOP_ - #define Z3_MAX_PIN Y_STOP_PIN - #elif Z3_USE_ENDSTOP == _ZMIN_ - #define Z3_MAX_PIN Z_MIN_PIN - #elif Z3_USE_ENDSTOP == _ZMAX_ - #define Z3_MAX_PIN Z_MAX_PIN - #elif Z3_USE_ENDSTOP == _ZSTOP_ - #define Z3_MAX_PIN Z_STOP_PIN - #elif Z3_USE_ENDSTOP == _XDIAG_ - #define Z3_MAX_PIN X_DIAG_PIN - #elif Z3_USE_ENDSTOP == _YDIAG_ - #define Z3_MAX_PIN Y_DIAG_PIN - #elif Z3_USE_ENDSTOP == _ZDIAG_ - #define Z3_MAX_PIN Z_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E0DIAG_ - #define Z3_MAX_PIN E0_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E1DIAG_ - #define Z3_MAX_PIN E1_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E2DIAG_ - #define Z3_MAX_PIN E2_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E3DIAG_ - #define Z3_MAX_PIN E3_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E4DIAG_ - #define Z3_MAX_PIN E4_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E5DIAG_ - #define Z3_MAX_PIN E5_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E6DIAG_ - #define Z3_MAX_PIN E6_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E7DIAG_ - #define Z3_MAX_PIN E7_DIAG_PIN + #if !PIN_EXISTS(Z3_MAX) + #undef Z3_MAX_PIN + #if PIN_EXISTS(Z3_STOP) + #define Z3_MAX_PIN Z3_STOP_PIN #endif #endif - #ifndef Z3_MIN_ENDSTOP_INVERTING - #define Z3_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef Z3_MIN_ENDSTOP_INVERTING #if Z3_USE_ENDSTOP == _XMIN_ @@ -1323,56 +1118,20 @@ #define Z3_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z3_USE_ENDSTOP == _ZMAX_ #define Z3_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z3_MIN_ENDSTOP_INVERTING false #endif #endif - #ifndef Z3_MIN_PIN - #if Z3_USE_ENDSTOP == _XMIN_ - #define Z3_MIN_PIN X_MIN_PIN - #elif Z3_USE_ENDSTOP == _XMAX_ - #define Z3_MIN_PIN X_MAX_PIN - #elif Z3_USE_ENDSTOP == _XSTOP_ - #define Z3_MIN_PIN X_STOP_PIN - #elif Z3_USE_ENDSTOP == _YMIN_ - #define Z3_MIN_PIN Y_MIN_PIN - #elif Z3_USE_ENDSTOP == _YMAX_ - #define Z3_MIN_PIN Y_MAX_PIN - #elif Z3_USE_ENDSTOP == _YSTOP_ - #define Z3_MIN_PIN Y_STOP_PIN - #elif Z3_USE_ENDSTOP == _ZMIN_ - #define Z3_MIN_PIN Z_MIN_PIN - #elif Z3_USE_ENDSTOP == _ZMAX_ - #define Z3_MIN_PIN Z_MAX_PIN - #elif Z3_USE_ENDSTOP == _ZSTOP_ - #define Z3_MIN_PIN Z_STOP_PIN - #elif Z3_USE_ENDSTOP == _XDIAG_ - #define Z3_MIN_PIN X_DIAG_PIN - #elif Z3_USE_ENDSTOP == _YDIAG_ - #define Z3_MIN_PIN Y_DIAG_PIN - #elif Z3_USE_ENDSTOP == _ZDIAG_ - #define Z3_MIN_PIN Z_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E0DIAG_ - #define Z3_MIN_PIN E0_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E1DIAG_ - #define Z3_MIN_PIN E1_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E2DIAG_ - #define Z3_MIN_PIN E2_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E3DIAG_ - #define Z3_MIN_PIN E3_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E4DIAG_ - #define Z3_MIN_PIN E4_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E5DIAG_ - #define Z3_MIN_PIN E5_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E6DIAG_ - #define Z3_MIN_PIN E6_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E7DIAG_ - #define Z3_MIN_PIN E7_DIAG_PIN + #if !PIN_EXISTS(Z3_MIN) + #undef Z3_MIN_PIN + #if PIN_EXISTS(Z3_STOP) + #define Z3_MIN_PIN Z3_STOP_PIN #endif #endif - #ifndef Z3_MAX_ENDSTOP_INVERTING - #define Z3_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef Z3_MAX_ENDSTOP_INVERTING + #define Z3_MAX_ENDSTOP_INVERTING false + #endif + #ifndef Z3_MIN_ENDSTOP_INVERTING + #define Z3_MIN_ENDSTOP_INVERTING false #endif #endif @@ -1391,56 +1150,14 @@ #define Z4_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z4_USE_ENDSTOP == _ZMAX_ #define Z4_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z4_MAX_ENDSTOP_INVERTING false #endif #endif - #ifndef Z4_MAX_PIN - #if Z4_USE_ENDSTOP == _XMIN_ - #define Z4_MAX_PIN X_MIN_PIN - #elif Z4_USE_ENDSTOP == _XMAX_ - #define Z4_MAX_PIN X_MAX_PIN - #elif Z4_USE_ENDSTOP == _XSTOP_ - #define Z4_MAX_PIN X_STOP_PIN - #elif Z4_USE_ENDSTOP == _YMIN_ - #define Z4_MAX_PIN Y_MIN_PIN - #elif Z4_USE_ENDSTOP == _YMAX_ - #define Z4_MAX_PIN Y_MAX_PIN - #elif Z4_USE_ENDSTOP == _YSTOP_ - #define Z4_MAX_PIN Y_STOP_PIN - #elif Z4_USE_ENDSTOP == _ZMIN_ - #define Z4_MAX_PIN Z_MIN_PIN - #elif Z4_USE_ENDSTOP == _ZMAX_ - #define Z4_MAX_PIN Z_MAX_PIN - #elif Z4_USE_ENDSTOP == _ZSTOP_ - #define Z4_MAX_PIN Z_STOP_PIN - #elif Z4_USE_ENDSTOP == _XDIAG_ - #define Z4_MAX_PIN X_DIAG_PIN - #elif Z4_USE_ENDSTOP == _YDIAG_ - #define Z4_MAX_PIN Y_DIAG_PIN - #elif Z4_USE_ENDSTOP == _ZDIAG_ - #define Z4_MAX_PIN Z_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E0DIAG_ - #define Z4_MAX_PIN E0_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E1DIAG_ - #define Z4_MAX_PIN E1_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E2DIAG_ - #define Z4_MAX_PIN E2_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E3DIAG_ - #define Z4_MAX_PIN E3_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E4DIAG_ - #define Z4_MAX_PIN E4_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E5DIAG_ - #define Z4_MAX_PIN E5_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E6DIAG_ - #define Z4_MAX_PIN E6_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E7DIAG_ - #define Z4_MAX_PIN E7_DIAG_PIN + #if !PIN_EXISTS(Z4_MAX) + #undef Z4_MAX_PIN + #if PIN_EXISTS(Z4_STOP) + #define Z4_MAX_PIN Z4_STOP_PIN #endif #endif - #ifndef Z4_MIN_ENDSTOP_INVERTING - #define Z4_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef Z4_MIN_ENDSTOP_INVERTING #if Z4_USE_ENDSTOP == _XMIN_ @@ -1455,56 +1172,20 @@ #define Z4_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z4_USE_ENDSTOP == _ZMAX_ #define Z4_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z4_MIN_ENDSTOP_INVERTING false #endif #endif - #ifndef Z4_MIN_PIN - #if Z4_USE_ENDSTOP == _XMIN_ - #define Z4_MIN_PIN X_MIN_PIN - #elif Z4_USE_ENDSTOP == _XMAX_ - #define Z4_MIN_PIN X_MAX_PIN - #elif Z4_USE_ENDSTOP == _XSTOP_ - #define Z4_MIN_PIN X_STOP_PIN - #elif Z4_USE_ENDSTOP == _YMIN_ - #define Z4_MIN_PIN Y_MIN_PIN - #elif Z4_USE_ENDSTOP == _YMAX_ - #define Z4_MIN_PIN Y_MAX_PIN - #elif Z4_USE_ENDSTOP == _YSTOP_ - #define Z4_MIN_PIN Y_STOP_PIN - #elif Z4_USE_ENDSTOP == _ZMIN_ - #define Z4_MIN_PIN Z_MIN_PIN - #elif Z4_USE_ENDSTOP == _ZMAX_ - #define Z4_MIN_PIN Z_MAX_PIN - #elif Z4_USE_ENDSTOP == _ZSTOP_ - #define Z4_MIN_PIN Z_STOP_PIN - #elif Z4_USE_ENDSTOP == _XDIAG_ - #define Z4_MIN_PIN X_DIAG_PIN - #elif Z4_USE_ENDSTOP == _YDIAG_ - #define Z4_MIN_PIN Y_DIAG_PIN - #elif Z4_USE_ENDSTOP == _ZDIAG_ - #define Z4_MIN_PIN Z_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E0DIAG_ - #define Z4_MIN_PIN E0_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E1DIAG_ - #define Z4_MIN_PIN E1_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E2DIAG_ - #define Z4_MIN_PIN E2_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E3DIAG_ - #define Z4_MIN_PIN E3_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E4DIAG_ - #define Z4_MIN_PIN E4_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E5DIAG_ - #define Z4_MIN_PIN E5_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E6DIAG_ - #define Z4_MIN_PIN E6_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E7DIAG_ - #define Z4_MIN_PIN E7_DIAG_PIN + #if !PIN_EXISTS(Z4_MIN) + #undef Z4_MIN_PIN + #if PIN_EXISTS(Z4_STOP) + #define Z4_MIN_PIN Z4_STOP_PIN #endif #endif - #ifndef Z4_MAX_ENDSTOP_INVERTING - #define Z4_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef Z4_MAX_ENDSTOP_INVERTING + #define Z4_MAX_ENDSTOP_INVERTING false + #endif + #ifndef Z4_MIN_ENDSTOP_INVERTING + #define Z4_MIN_ENDSTOP_INVERTING false #endif #endif @@ -2446,16 +2127,16 @@ // // Flag the indexed hardware serial ports in use -#define CONF_SERIAL_IS(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \ - || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \ - || (defined(SERIAL_PORT_3) && SERIAL_PORT_3 == N) \ - || (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \ - || (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == N) \ +#define SERIAL_IN_USE(N) ( (defined(SERIAL_PORT) && N == SERIAL_PORT) \ + || (defined(SERIAL_PORT_2) && N == SERIAL_PORT_2) \ + || (defined(SERIAL_PORT_3) && N == SERIAL_PORT_3) \ + || (defined(MMU2_SERIAL_PORT) && N == MMU2_SERIAL_PORT) \ + || (defined(LCD_SERIAL_PORT) && N == LCD_SERIAL_PORT) \ || (defined(LCD_SERIAL_PORT_2) && LCD_SERIAL_PORT_2 == N) ) // Flag the named hardware serial ports in use #define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N)) -#define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \ +#define ANY_SERIAL_IS(N) ( SERIAL_IN_USE(N) \ || TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \ || TMC_UART_IS(I, N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \ || TMC_UART_IS(U, N) || TMC_UART_IS(V , N) || TMC_UART_IS(W , N) \ @@ -2482,7 +2163,7 @@ #define HW_MSerial9 518 #define HW_MSerial10 519 -#if CONF_SERIAL_IS(-1) +#if SERIAL_IN_USE(-1) #define USING_HW_SERIALUSB 1 #endif #if ANY_SERIAL_IS(0) @@ -2544,6 +2225,21 @@ #undef TMC_UART_IS #undef ANY_SERIAL_IS +// Clean up unused ESP_WIFI pins +#ifdef ESP_WIFI_MODULE_COM + #if !SERIAL_IN_USE(ESP_WIFI_MODULE_COM) + #undef ESP_WIFI_MODULE_COM + #undef ESP_WIFI_MODULE_BAUDRATE + #undef ESP_WIFI_MODULE_RESET_PIN + #undef ESP_WIFI_MODULE_ENABLE_PIN + #undef ESP_WIFI_MODULE_TXD_PIN + #undef ESP_WIFI_MODULE_RXD_PIN + #undef ESP_WIFI_MODULE_GPIO0_PIN + #undef ESP_WIFI_MODULE_GPIO2_PIN + #undef ESP_WIFI_MODULE_GPIO4_PIN + #endif +#endif + // // Endstops and bed probe // @@ -2657,7 +2353,7 @@ // // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // -#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && !TEMP_SENSOR_IS_MAX_TC(P) && !TEMP_SENSOR_##P##_IS_DUMMY) +#define HAS_ADC_TEST(P) (TEMP_SENSOR(P) && PIN_EXISTS(TEMP_##P) && !TEMP_SENSOR_IS_MAX_TC(P) && !TEMP_SENSOR_##P##_IS_DUMMY) #if HOTENDS > 0 && HAS_ADC_TEST(0) #define HAS_TEMP_ADC_0 1 #endif @@ -2777,6 +2473,7 @@ #define BED_MAX_TARGET (BED_MAXTEMP - (BED_OVERSHOOT)) #else #undef PIDTEMPBED + #undef PREHEAT_BEFORE_LEVELING #endif #if HAS_TEMP_COOLER && PIN_EXISTS(COOLER) @@ -3125,73 +2822,6 @@ #define HAS_MICROSTEPS 1 #endif -#if HAS_MICROSTEPS - - // MS1 MS2 MS3 Stepper Driver Microstepping mode table - #ifndef MICROSTEP1 - #define MICROSTEP1 LOW,LOW,LOW - #endif - #if ENABLED(HEROIC_STEPPER_DRIVERS) - #ifndef MICROSTEP128 - #define MICROSTEP128 LOW,HIGH,LOW - #endif - #else - #ifndef MICROSTEP2 - #define MICROSTEP2 HIGH,LOW,LOW - #endif - #ifndef MICROSTEP4 - #define MICROSTEP4 LOW,HIGH,LOW - #endif - #endif - #ifndef MICROSTEP8 - #define MICROSTEP8 HIGH,HIGH,LOW - #endif - #ifdef __SAM3X8E__ - #if MB(ALLIGATOR) - #ifndef MICROSTEP16 - #define MICROSTEP16 LOW,LOW,LOW - #endif - #ifndef MICROSTEP32 - #define MICROSTEP32 HIGH,HIGH,LOW - #endif - #else - #ifndef MICROSTEP16 - #define MICROSTEP16 HIGH,HIGH,LOW - #endif - #endif - #else - #ifndef MICROSTEP16 - #define MICROSTEP16 HIGH,HIGH,LOW - #endif - #endif - - #ifdef MICROSTEP1 - #define HAS_MICROSTEP1 1 - #endif - #ifdef MICROSTEP2 - #define HAS_MICROSTEP2 1 - #endif - #ifdef MICROSTEP4 - #define HAS_MICROSTEP4 1 - #endif - #ifdef MICROSTEP8 - #define HAS_MICROSTEP8 1 - #endif - #ifdef MICROSTEP16 - #define HAS_MICROSTEP16 1 - #endif - #ifdef MICROSTEP32 - #define HAS_MICROSTEP32 1 - #endif - #ifdef MICROSTEP64 - #define HAS_MICROSTEP64 1 - #endif - #ifdef MICROSTEP128 - #define HAS_MICROSTEP128 1 - #endif - -#endif // HAS_MICROSTEPS - /** * Heater signal inversion defaults */ @@ -3307,7 +2937,15 @@ #endif #if HAS_TEMPERATURE && ANY(HAS_MARLINUI_MENU, HAS_DWIN_E3V2, HAS_DGUS_LCD_CLASSIC) - #ifdef PREHEAT_6_LABEL + #ifdef PREHEAT_10_LABEL + #define PREHEAT_COUNT 10 + #elif defined(PREHEAT_9_LABEL) + #define PREHEAT_COUNT 9 + #elif defined(PREHEAT_8_LABEL) + #define PREHEAT_COUNT 8 + #elif defined(PREHEAT_7_LABEL) + #define PREHEAT_COUNT 7 + #elif defined(PREHEAT_6_LABEL) #define PREHEAT_COUNT 6 #elif defined(PREHEAT_5_LABEL) #define PREHEAT_COUNT 5 @@ -3699,13 +3337,13 @@ #endif #endif -#if HAS_MARLINUI_MENU +#if EITHER(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE) // 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 + #define HAS_SCREEN_TIMEOUT 1 #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index e6be35dd9968..438067e3e8cc 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -416,17 +416,17 @@ #elif defined(CHDK) #error "CHDK is now CHDK_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." + MAX6675_SS, MAX6675_SS2, MAX6675_SS3, MAX6675_CS, MAX6675_CS2, MAX6675_CS3,\ + MAX31855_SS, MAX31855_SS2, MAX31855_SS3, MAX31855_CS, MAX31855_CS2, MAX31855_CS3, \ + MAX31865_SS, MAX31865_SS2, MAX31865_SS3, MAX31865_CS, MAX31865_CS2, MAX31865_CS3) + #warning "MAX*_SS_PIN, MAX*_SS2_PIN, MAX*_SS3_PIN, MAX*_CS_PIN, MAX*_CS2_PIN, and MAX*_CS3_PIN, are deprecated and will be removed in a future version. Please use TEMP_0_CS_PIN/TEMP_1_CS_PIN/TEMP_2_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." + #warning "MAX*_SCK_PIN is deprecated and will be removed in a future version. Please use TEMP_0_SCK_PIN/TEMP_1_SCK_PIN/TEMP_2_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." + #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/TEMP_2_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) + #warning "MAX31865_MOSI_PIN is deprecated and will be removed in a future version. Please use TEMP_0_MOSI_PIN/TEMP_1_MOSI_PIN/TEMP_2_MOSI_PIN instead." +#elif ANY_PIN(THERMO_CS1_PIN, THERMO_CS2_PIN, THERMO_CS3_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." @@ -587,7 +587,7 @@ #elif defined(MKS_LCD12864) #error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B." #elif defined(DOGM_SD_PERCENT) - #error "DOGM_SD_PERCENT is now SHOW_SD_PERCENT." + #error "DOGM_SD_PERCENT is now SHOW_PROGRESS_PERCENT." #elif defined(NEOPIXEL_BKGD_LED_INDEX) #error "NEOPIXEL_BKGD_LED_INDEX is now NEOPIXEL_BKGD_INDEX_FIRST." #elif defined(TEMP_SENSOR_1_AS_REDUNDANT) @@ -642,6 +642,20 @@ #error "LEVEL_CORNERS_* settings have been renamed BED_TRAMMING_*." #elif defined(LEVEL_CENTER_TOO) #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER." +#elif defined(TOUCH_IDLE_SLEEP) + #error "TOUCH_IDLE_SLEEP (seconds) is now TOUCH_IDLE_SLEEP_MINS (minutes)." +#elif defined(LCD_BACKLIGHT_TIMEOUT) + #error "LCD_BACKLIGHT_TIMEOUT (seconds) is now LCD_BACKLIGHT_TIMEOUT_MINS (minutes)." +#elif defined(LCD_SET_PROGRESS_MANUALLY) + #error "LCD_SET_PROGRESS_MANUALLY is now SET_PROGRESS_MANUALLY." +#elif defined(USE_M73_REMAINING_TIME) + #error "USE_M73_REMAINING_TIME is now SET_REMAINING_TIME." +#elif defined(SHOW_SD_PERCENT) + #error "SHOW_SD_PERCENT is now SHOW_PROGRESS_PERCENT." +#elif defined(EXTRA_LIN_ADVANCE_K) + #error "EXTRA_LIN_ADVANCE_K is now ADVANCE_K_EXTRA." +#elif defined(POLAR_SEGMENTS_PER_SECOND) || defined(DELTA_SEGMENTS_PER_SECOND) || defined(SCARA_SEGMENTS_PER_SECOND) || defined(TPARA_SEGMENTS_PER_SECOND) + #error "(POLAR|DELTA|SCARA|TPARA)_SEGMENTS_PER_SECOND is now DEFAULT_SEGMENTS_PER_SECOND." #endif // L64xx stepper drivers have been removed @@ -667,6 +681,17 @@ constexpr float arm[] = AXIS_RELATIVE_MODES; static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _LOGICAL_AXES_STR "elements."); +// Consolidate TMC26X, validate migration (#24373) +#define _ISMAX_1(A) defined(A##_MAX_CURRENT) +#define _ISSNS_1(A) defined(A##_SENSE_RESISTOR) +#if DO(ISMAX,||,ALL_AXIS_NAMES) + #error "*_MAX_CURRENT is now set with *_CURRENT." +#elif DO(ISSNS,||,ALL_AXIS_NAMES) + #error "*_SENSE_RESISTOR (in Milli-Ohms) is now set with *_RSENSE (in Ohms), so you must divide values by 1000." +#endif +#undef _ISMAX_1 +#undef _ISSNS_1 + /** * Probe temp compensation requirements */ @@ -817,7 +842,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Granular software endstops (Marlin >= 1.1.7) */ -#if ENABLED(MIN_SOFTWARE_ENDSTOPS) && DISABLED(MIN_SOFTWARE_ENDSTOP_Z) +#if ENABLED(MIN_SOFTWARE_ENDSTOPS) && NONE(MIN_SOFTWARE_ENDSTOP_Z, POLARGRAPH) #if IS_KINEMATIC #error "MIN_SOFTWARE_ENDSTOPS on DELTA/SCARA also requires MIN_SOFTWARE_ENDSTOP_Z." #elif NONE(MIN_SOFTWARE_ENDSTOP_X, MIN_SOFTWARE_ENDSTOP_Y) @@ -825,7 +850,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if ENABLED(MAX_SOFTWARE_ENDSTOPS) && DISABLED(MAX_SOFTWARE_ENDSTOP_Z) +#if ENABLED(MAX_SOFTWARE_ENDSTOPS) && NONE(MAX_SOFTWARE_ENDSTOP_Z, POLARGRAPH) #if IS_KINEMATIC #error "MAX_SOFTWARE_ENDSTOPS on DELTA/SCARA also requires MAX_SOFTWARE_ENDSTOP_Z." #elif NONE(MAX_SOFTWARE_ENDSTOP_X, MAX_SOFTWARE_ENDSTOP_Y) @@ -890,8 +915,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Progress Bar */ #if ENABLED(LCD_PROGRESS_BAR) - #if NONE(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) - #error "LCD_PROGRESS_BAR requires SDSUPPORT or LCD_SET_PROGRESS_MANUALLY." + #if NONE(SDSUPPORT, SET_PROGRESS_MANUALLY) + #error "LCD_PROGRESS_BAR requires SDSUPPORT or SET_PROGRESS_MANUALLY." #elif NONE(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) #error "LCD_PROGRESS_BAR only applies to HD44780 character LCD and TFTGLCD_PANEL_(SPI|I2C)." #elif HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI @@ -901,20 +926,22 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif PROGRESS_MSG_EXPIRE < 0 #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." #endif -#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) - #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." #endif -#if ENABLED(USE_M73_REMAINING_TIME) && DISABLED(LCD_SET_PROGRESS_MANUALLY) - #error "USE_M73_REMAINING_TIME requires LCD_SET_PROGRESS_MANUALLY" +#if ENABLED(SET_PROGRESS_MANUALLY) && NONE(SET_PROGRESS_PERCENT, SET_REMAINING_TIME, SET_INTERACTION_TIME) + #error "SET_PROGRESS_MANUALLY requires at least one of SET_PROGRESS_PERCENT, SET_REMAINING_TIME, SET_INTERACTION_TIME to be enabled." +#endif + +#if HAS_LCDPRINT && LCD_HEIGHT < 4 && ANY(SHOW_PROGRESS_PERCENT, SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME) + #error "Displays with fewer than 4 rows of text can't show progress values." #endif #if !HAS_MARLINUI_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE) #error "SD_REPRINT_LAST_SELECTED_FILE currently requires a Marlin-native LCD menu." #endif -#if ANY(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, EXTENSIBLE_UI) && !defined(MANUAL_FEEDRATE) - #error "MANUAL_FEEDRATE is required for MarlinUI, ExtUI, or FTDI EVE Touch UI." +#if ANY(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, EXTENSIBLE_UI, DWIN_LCD_PROUI) && !defined(MANUAL_FEEDRATE) + #error "MANUAL_FEEDRATE is required for ProUI, MarlinUI, ExtUI, or FTDI EVE Touch UI." #endif /** @@ -1324,10 +1351,15 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Linear Advance 1.5 - Check K value range */ #if ENABLED(LIN_ADVANCE) - static_assert( - WITHIN(LIN_ADVANCE_K, 0, 10), - "LIN_ADVANCE_K must be a value from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)." - ); + #if DISTINCT_E > 1 + constexpr float lak[] = ADVANCE_K; + static_assert(COUNT(lak) <= DISTINCT_E, "The ADVANCE_K array has too many elements (i.e., more than " STRINGIFY(DISTINCT_E) ")."); + #define _LIN_ASSERT(N) static_assert(N >= COUNT(lak) || WITHIN(lak[N], 0, 10), "ADVANCE_K values must be from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)."); + REPEAT(DISTINCT_E, _LIN_ASSERT) + #undef _LIN_ASSERT + #else + static_assert(WITHIN(ADVANCE_K, 0, 10), "ADVANCE_K must be from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)."); + #endif #if ENABLED(S_CURVE_ACCELERATION) && DISABLED(EXPERIMENTAL_SCURVE) #error "LIN_ADVANCE and S_CURVE_ACCELERATION may not play well together! Enable EXPERIMENTAL_SCURVE to continue." #elif ENABLED(DIRECT_STEPPING) @@ -1494,6 +1526,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "To use BED_LIMIT_SWITCHING you must disable PIDTEMPBED." #endif +// Fan Kickstart +#if FAN_KICKSTART_TIME && defined(FAN_KICKSTART_POWER) && !WITHIN(FAN_KICKSTART_POWER, 64, 255) + #error "FAN_KICKSTART_POWER must be an integer from 64 to 255." +#endif + /** * Synchronous M106/M107 checks */ @@ -1620,8 +1657,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Delta requirements */ #if ENABLED(DELTA) - #if NONE(USE_XMAX_PLUG, USE_YMAX_PLUG, USE_ZMAX_PLUG) - #error "You probably want to use Max Endstops for DELTA!" + #if ANY(X_HOME_TO_MIN, Y_HOME_TO_MIN, Z_HOME_TO_MIN) + #error "DELTA kinematics require homing "XYZ" axes to MAX. Set [XYZ]_HOME_DIR to 1." #elif ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(AUTO_BED_LEVELING_BILINEAR) && !UBL_SEGMENTED #error "ENABLE_LEVELING_FADE_HEIGHT on DELTA requires AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL." #elif ENABLED(DELTA_AUTO_CALIBRATION) && !(HAS_BED_PROBE || HAS_MARLINUI_MENU) @@ -1740,7 +1777,29 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if BLTOUCH_DELAY < 200 #error "BLTOUCH_DELAY less than 200 is unsafe and is not supported." #endif - #endif + + #ifdef DEACTIVATE_SERVOS_AFTER_MOVE + #error "BLTOUCH requires DEACTIVATE_SERVOS_AFTER_MOVE to be to disabled. Please update your Configuration.h file." + #endif + + #if HAS_INVERTED_PROBE + #if !Z_MIN_PROBE_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_PROBE_ENDSTOP_INVERTING set to true." + #endif + #elif Z_MIN_PROBE_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_PROBE_ENDSTOP_INVERTING set to false." + #endif + #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #if HAS_INVERTED_PROBE + #if !Z_MIN_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_ENDSTOP_INVERTING set to true." + #endif + #elif Z_MIN_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_ENDSTOP_INVERTING set to false." + #endif + #endif + + #endif // BLTOUCH #if ENABLED(RACK_AND_PINION_PROBE) && !(defined(Z_PROBE_DEPLOY_X) && defined(Z_PROBE_RETRACT_X)) #error "RACK_AND_PINION_PROBE requires Z_PROBE_DEPLOY_X and Z_PROBE_RETRACT_X." @@ -1758,14 +1817,28 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TOUCH_MI_PROBE requires Z_AFTER_PROBING to be disabled." #elif Z_HOMING_HEIGHT < 10 #error "TOUCH_MI_PROBE requires Z_HOMING_HEIGHT >= 10." - #elif Z_MIN_PROBE_ENDSTOP_INVERTING - #error "TOUCH_MI_PROBE requires Z_MIN_PROBE_ENDSTOP_INVERTING to be set to false." #elif DISABLED(BABYSTEP_ZPROBE_OFFSET) #error "TOUCH_MI_PROBE requires BABYSTEPPING with BABYSTEP_ZPROBE_OFFSET." #elif !HAS_RESUME_CONTINUE #error "TOUCH_MI_PROBE currently requires an LCD controller or EMERGENCY_PARSER." #endif - #endif + #if HAS_INVERTED_PROBE + #if !Z_MIN_PROBE_ENDSTOP_INVERTING + #error "TOUCH_MI_PROBE requires Z_MIN_PROBE_ENDSTOP_INVERTING set to true." + #endif + #elif Z_MIN_PROBE_ENDSTOP_INVERTING + #error "TOUCH_MI_PROBE requires Z_MIN_PROBE_ENDSTOP_INVERTING set to false." + #endif + #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #if HAS_INVERTED_PROBE + #if !Z_MIN_ENDSTOP_INVERTING + #error "TOUCH_MI_PROBE requires Z_MIN_ENDSTOP_INVERTING set to true." + #endif + #elif Z_MIN_ENDSTOP_INVERTING + #error "TOUCH_MI_PROBE requires Z_MIN_ENDSTOP_INVERTING set to false." + #endif + #endif + #endif // TOUCH_MI_PROBE /** * Mag mounted probe requirements @@ -1835,15 +1908,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Make sure Z raise values are set */ #ifndef Z_CLEARANCE_DEPLOY_PROBE - #error "You must define Z_CLEARANCE_DEPLOY_PROBE in your configuration." - #elif !defined(Z_CLEARANCE_BETWEEN_PROBES) - #error "You must define Z_CLEARANCE_BETWEEN_PROBES in your configuration." - #elif Z_CLEARANCE_DEPLOY_PROBE < 0 - #error "Probes need Z_CLEARANCE_DEPLOY_PROBE >= 0." - #elif Z_CLEARANCE_BETWEEN_PROBES < 0 - #error "Probes need Z_CLEARANCE_BETWEEN_PROBES >= 0." - #elif Z_AFTER_PROBING < 0 - #error "Probes need Z_AFTER_PROBING >= 0." + #error "Z_CLEARANCE_DEPLOY_PROBE is required for bed probes." + #else + static_assert(Z_CLEARANCE_DEPLOY_PROBE >= 0, "Probes require Z_CLEARANCE_DEPLOY_PROBE >= 0."); + #endif + #ifndef Z_CLEARANCE_BETWEEN_PROBES + #error "Z_CLEARANCE_BETWEEN_PROBES is required for bed probes." + #else + static_assert(Z_CLEARANCE_BETWEEN_PROBES >= 0, "Probes require Z_CLEARANCE_BETWEEN_PROBES >= 0."); + #endif + #ifdef Z_AFTER_PROBING + static_assert(Z_AFTER_PROBING >= 0, "Probes require Z_AFTER_PROBING >= 0."); #endif #if MULTIPLE_PROBING > 0 || EXTRA_PROBING > 0 @@ -2040,6 +2115,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS ); #endif +#define COUNT_SENSORLESS COUNT_ENABLED(Z_SENSORLESS, Z2_SENSORLESS, Z3_SENSORLESS, Z4_SENSORLESS) +#if COUNT_SENSORLESS && COUNT_SENSORLESS != NUM_Z_STEPPERS + #error "All Z steppers must have *_STALL_SENSITIVITY defined to use Z sensorless homing." +#endif +#undef COUNT_SENSORLESS + #ifdef SENSORLESS_BACKOFF_MM constexpr float sbm[] = SENSORLESS_BACKOFF_MM; static_assert(COUNT(sbm) == NUM_AXES, "SENSORLESS_BACKOFF_MM must have " _NUM_AXES_STR "elements (and no others)."); @@ -2193,14 +2274,22 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(USE_CONTROLLER_FAN) #if !HAS_CONTROLLER_FAN #error "USE_CONTROLLER_FAN requires a CONTROLLER_FAN_PIN. Define in Configuration_adv.h." - #elif E0_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #elif PIN_EXISTS(E0_AUTO_FAN) && E0_AUTO_FAN_PIN == CONTROLLER_FAN_PIN #error "You cannot set E0_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." - #elif E1_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #elif PIN_EXISTS(E1_AUTO_FAN) && E1_AUTO_FAN_PIN == CONTROLLER_FAN_PIN #error "You cannot set E1_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." - #elif E2_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #elif PIN_EXISTS(E2_AUTO_FAN) && E2_AUTO_FAN_PIN == CONTROLLER_FAN_PIN #error "You cannot set E2_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." - #elif E3_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #elif PIN_EXISTS(E3_AUTO_FAN) && E3_AUTO_FAN_PIN == CONTROLLER_FAN_PIN #error "You cannot set E3_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." + #elif PIN_EXISTS(E4_AUTO_FAN) && E4_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #error "You cannot set E4_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." + #elif PIN_EXISTS(E5_AUTO_FAN) && E5_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #error "You cannot set E5_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." + #elif PIN_EXISTS(E6_AUTO_FAN) && E6_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #error "You cannot set E6_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." + #elif PIN_EXISTS(E7_AUTO_FAN) && E7_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #error "You cannot set E7_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." #endif #endif @@ -2254,6 +2343,37 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_REDUNDANT 1000 requires REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS and REDUNDANT_BETA in Configuration_adv.h." #endif +/** + * Required thermistor 66 (Dyze Design / Trianglelab T-D500) settings + * https://docs.dyzedesign.com/hotends.html#_500-%C2%B0c-thermistor + */ +#if ANY_E_SENSOR_IS(66) + #define _BAD_MINTEMP(N) (TEMP_SENSOR(N) == 66 && HEATER_##N##_MINTEMP <= 20) + #if _BAD_MINTEMP(0) + #error "Thermistor 66 requires HEATER_0_MINTEMP > 20." + #elif _BAD_MINTEMP(1) + #error "Thermistor 66 requires HEATER_1_MINTEMP > 20." + #elif _BAD_MINTEMP(2) + #error "Thermistor 66 requires HEATER_2_MINTEMP > 20." + #elif _BAD_MINTEMP(3) + #error "Thermistor 66 requires HEATER_3_MINTEMP > 20." + #elif _BAD_MINTEMP(4) + #error "Thermistor 66 requires HEATER_4_MINTEMP > 20." + #elif _BAD_MINTEMP(5) + #error "Thermistor 66 requires HEATER_5_MINTEMP > 20." + #elif _BAD_MINTEMP(6) + #error "Thermistor 66 requires HEATER_6_MINTEMP > 20." + #elif _BAD_MINTEMP(7) + #error "Thermistor 66 requires HEATER_7_MINTEMP > 20." + #endif + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED < 5 + #error "Thermistor 66 requires MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED ≥ 5." + #elif MILLISECONDS_PREHEAT_TIME < 15000 + #error "Thermistor 66 requires MILLISECONDS_PREHEAT_TIME ≥ 15000, but 30000 or higher is recommended." + #endif + #undef _BAD_MINTEMP +#endif + /** * Required MAX31865 settings */ @@ -2271,12 +2391,19 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1/TEMP_SENSOR_REDUNDANT is MAX31865." #endif #endif +#if TEMP_SENSOR_2_IS_MAX31865 || (TEMP_SENSOR_REDUNDANT_IS_MAX31865 && REDUNDANT_TEMP_MATCH(SOURCE, E2)) + #if !defined(MAX31865_SENSOR_WIRES_2) || !WITHIN(MAX31865_SENSOR_WIRES_2, 2, 4) + #error "MAX31865_SENSOR_WIRES_2 must be defined as an integer between 2 and 4." + #elif !defined(MAX31865_SENSOR_OHMS_2) || !defined(MAX31865_CALIBRATION_OHMS_2) + #error "MAX31865_SENSOR_OHMS_2 and MAX31865_CALIBRATION_OHMS_2 must be set if TEMP_SENSOR_2/TEMP_SENSOR_REDUNDANT is MAX31865." + #endif +#endif /** * Redundant temperature sensor config */ #if HAS_TEMP_REDUNDANT - #if !defined(TEMP_SENSOR_REDUNDANT_SOURCE) + #ifndef 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." @@ -2577,7 +2704,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #define _PLUG_UNUSED_TEST(A,P) (DISABLED(USE_##P##MIN_PLUG, USE_##P##MAX_PLUG) \ && !(ENABLED(A##_DUAL_ENDSTOPS) && WITHIN(A##2_USE_ENDSTOP, _##P##MAX_, _##P##MIN_)) \ && !(ENABLED(A##_MULTI_ENDSTOPS) && WITHIN(A##2_USE_ENDSTOP, _##P##MAX_, _##P##MIN_)) ) -#define _AXIS_PLUG_UNUSED_TEST(A) (1 NUM_AXIS_GANG(&& _PLUG_UNUSED_TEST(A,X), && _PLUG_UNUSED_TEST(A,Y), && _PLUG_UNUSED_TEST(A,Z), \ +#define _AXIS_PLUG_UNUSED_TEST(A) (HAS_##A##_A NUM_AXIS_GANG(&& _PLUG_UNUSED_TEST(A,X), && _PLUG_UNUSED_TEST(A,Y), && _PLUG_UNUSED_TEST(A,Z), \ && _PLUG_UNUSED_TEST(A,I), && _PLUG_UNUSED_TEST(A,J), && _PLUG_UNUSED_TEST(A,K), \ && _PLUG_UNUSED_TEST(A,U), && _PLUG_UNUSED_TEST(A,V), && _PLUG_UNUSED_TEST(A,W) ) ) @@ -2592,22 +2719,22 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if _AXIS_PLUG_UNUSED_TEST(Z) #error "You must enable USE_ZMIN_PLUG or USE_ZMAX_PLUG." #endif - #if HAS_I_AXIS && _AXIS_PLUG_UNUSED_TEST(I) + #if _AXIS_PLUG_UNUSED_TEST(I) #error "You must enable USE_IMIN_PLUG or USE_IMAX_PLUG." #endif - #if HAS_J_AXIS && _AXIS_PLUG_UNUSED_TEST(J) + #if _AXIS_PLUG_UNUSED_TEST(J) #error "You must enable USE_JMIN_PLUG or USE_JMAX_PLUG." #endif - #if HAS_K_AXIS && _AXIS_PLUG_UNUSED_TEST(K) + #if _AXIS_PLUG_UNUSED_TEST(K) #error "You must enable USE_KMIN_PLUG or USE_KMAX_PLUG." #endif - #if HAS_U_AXIS && _AXIS_PLUG_UNUSED_TEST(U) + #if _AXIS_PLUG_UNUSED_TEST(U) #error "You must enable USE_UMIN_PLUG or USE_UMAX_PLUG." #endif - #if HAS_V_AXIS && _AXIS_PLUG_UNUSED_TEST(V) + #if _AXIS_PLUG_UNUSED_TEST(V) #error "You must enable USE_VMIN_PLUG or USE_VMAX_PLUG." #endif - #if HAS_W_AXIS && _AXIS_PLUG_UNUSED_TEST(W) + #if _AXIS_PLUG_UNUSED_TEST(W) #error "You must enable USE_WMIN_PLUG or USE_WMAX_PLUG." #endif @@ -2621,29 +2748,29 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Enable USE_YMIN_PLUG when homing Y to MIN." #elif Y_HOME_TO_MAX && DISABLED(USE_YMAX_PLUG) #error "Enable USE_YMAX_PLUG when homing Y to MAX." - #elif HAS_I_AXIS && I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG) + #elif I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG) #error "Enable USE_IMIN_PLUG when homing I to MIN." - #elif HAS_I_AXIS && I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG) + #elif I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG) #error "Enable USE_IMAX_PLUG when homing I to MAX." - #elif HAS_J_AXIS && J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG) + #elif J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG) #error "Enable USE_JMIN_PLUG when homing J to MIN." - #elif HAS_J_AXIS && J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG) + #elif J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG) #error "Enable USE_JMAX_PLUG when homing J to MAX." - #elif HAS_K_AXIS && K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG) + #elif K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG) #error "Enable USE_KMIN_PLUG when homing K to MIN." - #elif HAS_K_AXIS && K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) + #elif K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) #error "Enable USE_KMAX_PLUG when homing K to MAX." - #elif HAS_U_AXIS && U_HOME_TO_MIN && DISABLED(USE_UMIN_PLUG) + #elif U_HOME_TO_MIN && DISABLED(USE_UMIN_PLUG) #error "Enable USE_UMIN_PLUG when homing U to MIN." - #elif HAS_U_AXIS && U_HOME_TO_MAX && DISABLED(USE_UMAX_PLUG) + #elif U_HOME_TO_MAX && DISABLED(USE_UMAX_PLUG) #error "Enable USE_UMAX_PLUG when homing U to MAX." - #elif HAS_V_AXIS && V_HOME_TO_MIN && DISABLED(USE_VMIN_PLUG) + #elif V_HOME_TO_MIN && DISABLED(USE_VMIN_PLUG) #error "Enable USE_VMIN_PLUG when homing V to MIN." - #elif HAS_V_AXIS && V_HOME_TO_MAX && DISABLED(USE_VMAX_PLUG) + #elif V_HOME_TO_MAX && DISABLED(USE_VMAX_PLUG) #error "Enable USE_VMAX_PLUG when homing V to MAX." - #elif HAS_W_AXIS && W_HOME_TO_MIN && DISABLED(USE_WMIN_PLUG) + #elif W_HOME_TO_MIN && DISABLED(USE_WMIN_PLUG) #error "Enable USE_WMIN_PLUG when homing W to MIN." - #elif HAS_W_AXIS && W_HOME_TO_MAX && DISABLED(USE_WMAX_PLUG) + #elif W_HOME_TO_MAX && DISABLED(USE_WMAX_PLUG) #error "Enable USE_WMAX_PLUG when homing W to MAX." #endif #endif @@ -2984,7 +3111,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #if ENABLED(ANYCUBIC_LCD_CHIRON) - #if !defined(BEEPER_PIN) + #ifndef BEEPER_PIN #error "ANYCUBIC_LCD_CHIRON requires BEEPER_PIN" #elif DISABLED(SDSUPPORT) #error "ANYCUBIC_LCD_CHIRON requires SDSUPPORT" @@ -3030,11 +3157,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if LCD_BACKLIGHT_TIMEOUT +#if LCD_BACKLIGHT_TIMEOUT_MINS #if !HAS_ENCODER_ACTION - #error "LCD_BACKLIGHT_TIMEOUT requires an LCD with encoder or keypad." + #error "LCD_BACKLIGHT_TIMEOUT_MINS requires an LCD with encoder or keypad." #elif !PIN_EXISTS(LCD_BACKLIGHT) - #error "LCD_BACKLIGHT_TIMEOUT requires LCD_BACKLIGHT_PIN." + #error "LCD_BACKLIGHT_TIMEOUT_MINS requires LCD_BACKLIGHT_PIN." #endif #endif @@ -3042,7 +3169,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Display Sleep is not supported by these common displays */ #if HAS_DISPLAY_SLEEP - #if ANY(IS_U8GLIB_LM6059_AF, IS_U8GLIB_ST7565_64128, REPRAPWORLD_GRAPHICAL_LCD, FYSETC_MINI, ENDER2_STOCKDISPLAY, MINIPANEL) + #if ANY(IS_U8GLIB_LM6059_AF, IS_U8GLIB_ST7565_64128, REPRAPWORLD_GRAPHICAL_LCD, FYSETC_MINI_12864, CR10_STOCKDISPLAY, MINIPANEL) #error "DISPLAY_SLEEP_MINUTES is not supported by your display." #elif !WITHIN(DISPLAY_SLEEP_MINUTES, 0, 255) #error "DISPLAY_SLEEP_MINUTES must be between 0 and 255." @@ -3501,8 +3628,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SENSORLESS_HOMING on DELTA currently requires STEALTHCHOP_XY and STEALTHCHOP_Z." #elif ENDSTOP_NOISE_THRESHOLD #error "SENSORLESS_HOMING is incompatible with ENDSTOP_NOISE_THRESHOLD." - #elif !(X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS) - #error "SENSORLESS_HOMING requires a TMC stepper driver with StallGuard on X, Y, or Z axes." + #elif !(X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS || I_SENSORLESS || J_SENSORLESS || K_SENSORLESS || U_SENSORLESS || V_SENSORLESS || W_SENSORLESS) + #error "SENSORLESS_HOMING requires a TMC stepper driver with StallGuard on X, Y, Z, I, J, K, U, V, or W axes." #endif #undef X_ENDSTOP_INVERTING @@ -3708,6 +3835,10 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "LED_CONTROL_MENU requires an LCD controller that implements the menu." #endif +#if ENABLED(CUSTOM_MENU_MAIN) && NONE(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, TFT_LVGL_UI) + #error "CUSTOM_MENU_MAIN requires an LCD controller that implements the menu." +#endif + #if ENABLED(CASE_LIGHT_USE_NEOPIXEL) && DISABLED(NEOPIXEL_LED) #error "CASE_LIGHT_USE_NEOPIXEL requires NEOPIXEL_LED." #endif @@ -3989,10 +4120,6 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "COOLANT_FLOOD requires COOLANT_FLOOD_PIN to be defined." #endif -#if NONE(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, IS_DWIN_MARLINUI) && ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) - #error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD." -#endif - #if HAS_ADC_BUTTONS && defined(ADC_BUTTON_DEBOUNCE_DELAY) && ADC_BUTTON_DEBOUNCE_DELAY < 16 #error "ADC_BUTTON_DEBOUNCE_DELAY must be greater than 16." #endif @@ -4173,11 +4300,6 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #endif #endif -// Misc. Cleanup -#undef _TEST_PWM -#undef _NUM_AXES_STR -#undef _LOGICAL_AXES_STR - // JTAG support in the HAL #if ENABLED(DISABLE_DEBUG) && !defined(JTAGSWD_DISABLE) #error "DISABLE_DEBUG is not supported for the selected MCU/Board." @@ -4189,3 +4311,54 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #if ENABLED(XFER_BUILD) && !BOTH(BINARY_FILE_TRANSFER, CUSTOM_FIRMWARE_UPLOAD) #error "BINARY_FILE_TRANSFER and CUSTOM_FIRMWARE_UPLOAD are required for custom upload." #endif + +/** + * Input Shaping requirements + */ +#if HAS_SHAPING + #if ENABLED(DELTA) + #error "Input Shaping is not compatible with DELTA kinematics." + #elif ENABLED(SCARA) + #error "Input Shaping is not compatible with SCARA kinematics." + #elif ENABLED(TPARA) + #error "Input Shaping is not compatible with TPARA kinematics." + #elif ENABLED(POLAR) + #error "Input Shaping is not compatible with POLAR kinematics." + #elif ENABLED(POLARGRAPH) + #error "Input Shaping is not compatible with POLARGRAPH kinematics." + #elif ENABLED(DIRECT_STEPPING) + #error "Input Shaping is not compatible with DIRECT_STEPPING." + #elif ENABLED(INPUT_SHAPING_X) && ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX) + #error "INPUT_SHAPING_X is not supported with COREXY, COREYX, COREXZ, COREZX, or MARKFORGED_*." + #elif ENABLED(INPUT_SHAPING_Y) && ANY(CORE_IS_XY, CORE_IS_YZ, MARKFORGED_XY, MARKFORGED_YX) + #error "INPUT_SHAPING_Y is not supported with COREXY, COREYX, COREYZ, COREZY, or MARKFORGED_*." + #endif + + #ifdef __AVR__ + #ifdef SHAPING_MIN_FREQ + static_assert((SHAPING_MIN_FREQ) > 0, "SHAPING_MIN_FREQ must be > 0."); + #else + TERN_(INPUT_SHAPING_X, static_assert((SHAPING_FREQ_X) > 0, "SHAPING_FREQ_X must be > 0 or SHAPING_MIN_FREQ must be set.")); + TERN_(INPUT_SHAPING_Y, static_assert((SHAPING_FREQ_Y) > 0, "SHAPING_FREQ_Y must be > 0 or SHAPING_MIN_FREQ must be set.")); + #endif + #if ENABLED(INPUT_SHAPING_X) + #if F_CPU > 16000000 + static_assert((SHAPING_FREQ_X) == 0 || (SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (20) for AVR 20MHz."); + #else + static_assert((SHAPING_FREQ_X) == 0 || (SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (16) for AVR 16MHz."); + #endif + #endif + #if ENABLED(INPUT_SHAPING_Y) + #if F_CPU > 16000000 + static_assert((SHAPING_FREQ_Y) == 0 || (SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (20) for AVR 20MHz."); + #else + static_assert((SHAPING_FREQ_Y) == 0 || (SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (16) for AVR 16MHz."); + #endif + #endif + #endif +#endif + +// Misc. Cleanup +#undef _TEST_PWM +#undef _NUM_AXES_STR +#undef _LOGICAL_AXES_STR diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 7fcaee1345f6..afe299db1cb7 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -25,7 +25,7 @@ * Release version. Leave the Marlin version or apply a custom scheme. */ #ifndef SHORT_BUILD_VERSION - #define SHORT_BUILD_VERSION "2.1.1" + #define SHORT_BUILD_VERSION "2.1.2" #endif /** @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-08-06" + #define STRING_DISTRIBUTION_DATE "2022-12-17" #endif /** @@ -52,7 +52,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 02010100 +#define MARLIN_HEX_VERSION 02010200 #ifndef REQUIRED_CONFIGURATION_H_VERSION #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION #endif diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index e665ac5bca4e..24f4d7fbe9f3 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -35,6 +35,10 @@ #warning "WARNING! Disable MARLIN_DEV_MODE for the final build!" #endif +#if ENABLED(LA_DEBUG) + #warning "WARNING! Disable LA_DEBUG for the final build!" +#endif + #if NUM_AXES_WARNING #warning "Note: NUM_AXES is now based on the *_DRIVER_TYPE settings so you can remove NUM_AXES from Configuration.h." #endif @@ -707,9 +711,8 @@ #warning "Don't forget to update your TFT settings in Configuration.h." #endif -// Ender 3 Pro (but, apparently all Creality 4.2.2 boards) -#if ENABLED(EMIT_CREALITY_422_WARNING) || MB(CREALITY_V4) - #warning "Creality 4.2.2 boards come with a variety of stepper drivers. Check the board label and set the correct *_DRIVER_TYPE! (C=HR4988, E=A4988, A=TMC2208, B=TMC2209, H=TMC2225)." +#if ENABLED(EMIT_CREALITY_422_WARNING) && DISABLED(NO_CREALITY_422_DRIVER_WARNING) + #warning "Creality 4.2.2 boards come with a variety of stepper drivers. Check the board label (typically on SD Card module) and set the correct *_DRIVER_TYPE! (C=HR4988, E=A4988, A=TMC2208, B=TMC2209, H=TMC2225, H8=HR4988). (Define NO_CREALITY_422_DRIVER_WARNING to suppress this warning.)" #endif #if PRINTCOUNTER_SYNC diff --git a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index fe31c21e3959..48f5f97133db 100644 --- a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -56,9 +56,9 @@ typedef struct _hd44780_charmap_t { } hd44780_charmap_t; #ifdef __AVR__ - #define IV(a) U##a + #define IV(a) lchar_t(U##a) #else - #define IV(a) L##a + #define IV(a) lchar_t(L##a) #endif static const hd44780_charmap_t g_hd44780_charmap_device[] PROGMEM = { diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index b8dc8db8177a..9445198a22c1 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -58,6 +58,10 @@ #include "../../feature/bedlevel/bedlevel.h" #endif +#if HAS_CUTTER + #include "../../feature/spindle_laser.h" +#endif + // // Create LCD instance and chipset-specific information // @@ -406,7 +410,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } void lcd_erase_line(const lcd_uint_t line) { lcd_moveto(0, line); for (uint8_t i = LCD_WIDTH + 1; --i;) - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); } // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line @@ -414,7 +418,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } uint8_t slen = utf8_strlen(ftxt); if (slen < len) { lcd_put_u8str_max(col, line, ftxt, len); - for (; slen < len; ++slen) lcd_put_lchar(' '); + for (; slen < len; ++slen) lcd_put_u8str(F(" ")); safe_delay(time); } else { @@ -426,7 +430,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } lcd_put_u8str_max_P(col, line, p, len); // Fill with spaces - for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_lchar(' '); + for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_u8str(F(" ")); // Delay safe_delay(dly); @@ -440,9 +444,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); } static void logo_lines(FSTR_P const extra) { int16_t indent = (LCD_WIDTH - 8 - utf8_strlen(extra)) / 2; - lcd_put_lchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_lchar('\x01'); + lcd_put_lchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_u8str(F("\x01")); lcd_put_u8str(indent, 1, F("|Marlin|")); lcd_put_u8str(extra); - lcd_put_lchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_lchar('\x03'); + lcd_put_lchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_u8str(F("\x03")); } void MarlinUI::show_bootscreen() { @@ -522,7 +526,15 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const lcd_put_u8str(value); } - +/** + * @brief Draw current and target for a heater/cooler + * @details Print at the current LCD position the current/target for a single heater, + * blinking the target temperature of an idle heater has timed out. + * + * @param heater_id The heater ID, such as 0, 1, ..., H_BED, H_CHAMBER, etc. + * @param prefix A char to draw in front (e.g., a thermometer or icon) + * @param blink Flag to show the blink state instead of the regular state + */ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) { #if HAS_HEATED_BED const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0); @@ -535,75 +547,74 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr if (prefix >= 0) lcd_put_lchar(prefix); lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1)); - lcd_put_lchar('/'); + lcd_put_u8str(F("/")); #if !HEATER_IDLE_HANDLER UNUSED(blink); #else - if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_lchar(' '); - if (t2 >= 10) lcd_put_lchar(' '); - if (t2 >= 100) lcd_put_lchar(' '); - } + if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) + lcd_put_u8str(F(" ")); else #endif lcd_put_u8str(i16tostr3left(t2)); if (prefix >= 0) { lcd_put_lchar(LCD_STR_DEGREE[0]); - lcd_put_lchar(' '); - if (t2 < 10) lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); + if (t2 < 10) lcd_put_u8str(F(" ")); } } #if HAS_COOLER -FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { - const celsius_t t2 = thermalManager.degTargetCooler(); - if (prefix >= 0) lcd_put_lchar(prefix); + FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { + const celsius_t t2 = thermalManager.degTargetCooler(); - lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); - lcd_put_lchar('/'); + if (prefix >= 0) lcd_put_lchar(prefix); - #if !HEATER_IDLE_HANDLER - UNUSED(blink); - #else - if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_lchar(' '); - if (t2 >= 10) lcd_put_lchar(' '); - if (t2 >= 100) lcd_put_lchar(' '); - } - else - #endif - lcd_put_u8str(i16tostr3left(t2)); + lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); + lcd_put_u8str(F("/")); - if (prefix >= 0) { - lcd_put_lchar(LCD_STR_DEGREE[0]); - lcd_put_lchar(' '); - if (t2 < 10) lcd_put_lchar(' '); + #if !HEATER_IDLE_HANDLER + UNUSED(blink); + #else + if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { + lcd_put_u8str(F(" ")); + if (t2 >= 10) lcd_put_u8str(F(" ")); + if (t2 >= 100) lcd_put_u8str(F(" ")); + } + else + #endif + lcd_put_u8str(i16tostr3left(t2)); + + if (prefix >= 0) { + lcd_put_lchar(LCD_STR_DEGREE[0]); + lcd_put_u8str(F(" ")); + if (t2 < 10) lcd_put_u8str(F(" ")); + } } -} -#endif + +#endif // HAS_COOLER #if ENABLED(LASER_COOLANT_FLOW_METER) FORCE_INLINE void _draw_flowmeter_status() { - lcd_put_u8str("~"); + lcd_put_u8str(F("~")); lcd_put_u8str(ftostr11ns(cooler.flowrate)); - lcd_put_lchar('L'); + lcd_put_u8str(F("L")); } #endif #if ENABLED(I2C_AMMETER) FORCE_INLINE void _draw_ammeter_status() { - lcd_put_u8str(" "); + lcd_put_u8str(F(" ")); ammeter.read(); if (ammeter.current <= 0.999f) { lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); - lcd_put_u8str("mA"); + lcd_put_u8str(F("mA")); } else { lcd_put_u8str(ftostr12ns(ammeter.current)); - lcd_put_lchar('A'); + lcd_put_u8str(F("A")); } } #endif @@ -612,19 +623,35 @@ 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); } -#if HAS_PRINT_PROGRESS +#if HAS_CUTTER - FORCE_INLINE void _draw_print_progress() { - const uint8_t progress = ui.get_progress_percent(); - lcd_put_u8str(F(TERN(SDSUPPORT, "SD", "P:"))); - if (progress) - lcd_put_u8str(ui8tostr3rj(progress)); - else - lcd_put_u8str(F("---")); - lcd_put_lchar('%'); + FORCE_INLINE void _draw_cutter_status() { + lcd_put_u8str(TERN(LASER_FEATURE, GET_TEXT_F(MSG_LASER), GET_TEXT_F(MSG_CUTTER))); + lcd_put_u8str(F(": ")); + + #if CUTTER_UNIT_IS(RPM) + lcd_put_u8str(ftostr61rj(float(cutter.unitPower) / 1000)); + lcd_put_u8str(F("K")); + #else + lcd_put_u8str(cutter_power2str(cutter.unitPower)); + #if CUTTER_UNIT_IS(PERCENT) + lcd_put_u8str(F("%")); + #endif + #endif + + lcd_put_u8str(F(" ")); + lcd_put_u8str(cutter.enabled() ? GET_TEXT_F(MSG_LCD_ON) : GET_TEXT_F(MSG_LCD_OFF)); + lcd_put_u8str(F(" ")); + + switch (cutter.cutter_mode) { + case CUTTER_MODE_STANDARD: lcd_put_u8str(F("S")); break; + case CUTTER_MODE_CONTINUOUS: lcd_put_u8str(F("C")); break; + case CUTTER_MODE_DYNAMIC: lcd_put_u8str(F("D")); break; + case CUTTER_MODE_ERROR: lcd_put_u8str(F("!")); break; + } } -#endif +#endif // HAS_CUTTER #if ENABLED(LCD_PROGRESS_BAR) @@ -668,7 +695,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(ftostr12ns(filwidth.measured_mm)); lcd_put_u8str(F(" V")); lcd_put_u8str(i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled))); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); return; } @@ -687,7 +714,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(status_message); // Fill the rest with spaces - while (slen < LCD_WIDTH) { lcd_put_lchar(' '); ++slen; } + while (slen < LCD_WIDTH) { lcd_put_u8str(F(" ")); ++slen; } } else { // String is larger than the available space in screen. @@ -701,11 +728,11 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < LCD_WIDTH) { uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters - lcd_put_lchar(' '); // Always at 1+ spaces left, draw a space + lcd_put_u8str(F(" ")); // Always at 1+ spaces left, draw a space if (--chars) { // Draw a second space if there's room - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); if (--chars) { // Draw a third space if there's room - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); if (--chars) lcd_put_u8str_max(status_message, chars); // Print a second copy of the message } @@ -726,13 +753,62 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, LCD_WIDTH); // Fill the rest with spaces if there are missing spaces - while (slen < LCD_WIDTH) { - lcd_put_lchar(' '); - ++slen; - } + for (; slen < LCD_WIDTH; ++slen) lcd_put_u8str(F(" ")); #endif } +#if HAS_PRINT_PROGRESS + #define TPOFFSET (LCD_WIDTH - 1) + static uint8_t timepos = TPOFFSET - 6; + static char buffer[8]; + static lcd_uint_t pc, pr; + + #if ENABLED(SHOW_PROGRESS_PERCENT) + void MarlinUI::drawPercent() { + const uint8_t progress = ui.get_progress_percent(); + if (progress) { + lcd_moveto(pc, pr); + lcd_put_u8str(F(TERN(IS_SD_PRINTING, "SD", "P:"))); + lcd_put_u8str(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress))); + lcd_put_u8str(F("%")); + } + } + #endif + #if ENABLED(SHOW_REMAINING_TIME) + void MarlinUI::drawRemain() { + if (printJobOngoing()) { + const duration_t remaint = ui.get_remaining_time(); + timepos = TPOFFSET - remaint.toDigital(buffer); + TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);) + lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'R'); + lcd_put_u8str(buffer); + } + } + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + void MarlinUI::drawInter() { + const duration_t interactt = ui.interaction_time; + if (printingIsActive() && interactt.value) { + timepos = TPOFFSET - interactt.toDigital(buffer); + TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);) + lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'C'); + lcd_put_u8str(buffer); + } + } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + void MarlinUI::drawElapsed() { + if (printJobOngoing()) { + const duration_t elapsedt = print_job_timer.duration(); + timepos = TPOFFSET - elapsedt.toDigital(buffer); + TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);) + lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'E'); + lcd_put_u8str(buffer); + } + } + #endif +#endif // HAS_PRINT_PROGRESS + /** * LCD_INFO_SCREEN_STYLE 0 : Classic Status Screen * @@ -765,35 +841,6 @@ void MarlinUI::draw_status_message(const bool blink) { * |01234567890123456789| */ -inline uint8_t draw_elapsed_or_remaining_time(uint8_t timepos, const bool blink) { - char buffer[14]; - - #if ENABLED(SHOW_REMAINING_TIME) - const bool show_remain = TERN1(ROTATE_PROGRESS_DISPLAY, blink) && printingIsActive(); - if (show_remain) { - #if ENABLED(USE_M73_REMAINING_TIME) - duration_t remaining = ui.get_remaining_time(); - #else - uint8_t progress = ui.get_progress_percent(); - uint32_t elapsed = print_job_timer.duration(); - duration_t remaining = (progress > 0) ? ((elapsed * 25600 / progress) >> 8) - elapsed : 0; - #endif - timepos -= remaining.toDigital(buffer); - lcd_put_lchar(timepos, 2, 'R'); - } - #else - constexpr bool show_remain = false; - #endif - - if (!show_remain) { - duration_t elapsed = print_job_timer.duration(); - timepos -= elapsed.toDigital(buffer); - lcd_put_lchar(timepos, 2, LCD_STR_CLOCK[0]); - } - lcd_put_u8str(buffer); - return timepos; -} - void MarlinUI::draw_status_screen() { const bool blink = get_blink(); @@ -821,6 +868,15 @@ void MarlinUI::draw_status_screen() { lcd_moveto(8, 0); _draw_bed_status(blink); #endif + + #elif HAS_CUTTER + + // + // Cutter Status + // + lcd_moveto(0, 0); + _draw_cutter_status(); + #endif #else // LCD_WIDTH >= 20 @@ -841,6 +897,15 @@ void MarlinUI::draw_status_screen() { lcd_moveto(10, 0); _draw_bed_status(blink); #endif + + #elif HAS_CUTTER + + // + // Cutter Status + // + lcd_moveto(0, 0); + _draw_cutter_status(); + #endif TERN_(HAS_COOLER, _draw_cooler_status('*', blink)); @@ -856,8 +921,8 @@ void MarlinUI::draw_status_screen() { #if LCD_WIDTH < 20 #if HAS_PRINT_PROGRESS - lcd_moveto(0, 2); - _draw_print_progress(); + pc = 0; pr = 2; + rotate_progress(); #endif #else // LCD_WIDTH >= 20 @@ -913,7 +978,7 @@ void MarlinUI::draw_status_screen() { else { const xy_pos_t lpos = current_position.asLogical(); _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink); } @@ -938,20 +1003,19 @@ void MarlinUI::draw_status_screen() { lcd_put_lchar(0, 2, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_lchar('%'); - - const uint8_t timepos = draw_elapsed_or_remaining_time(LCD_WIDTH - 1, blink); + lcd_put_u8str(F("%")); #if LCD_WIDTH >= 20 - lcd_moveto(timepos - 7, 2); + #if HAS_PRINT_PROGRESS - _draw_print_progress(); + pc = 6; pr = 2; + rotate_progress(); #else char c; uint16_t per; #if HAS_FAN0 if (true - #if EXTRUDERS && ENABLED(ADAPTIVE_FAN_SLOWING) + #if BOTH(HAS_EXTRUDERS, ADAPTIVE_FAN_SLOWING) && (blink || thermalManager.fan_speed_scaler[0] < 128) #endif ) { @@ -972,7 +1036,7 @@ void MarlinUI::draw_status_screen() { } lcd_put_lchar(c); lcd_put_u8str(i16tostr3rj(per)); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); #endif #endif @@ -1011,12 +1075,12 @@ void MarlinUI::draw_status_screen() { lcd_put_lchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); // ========== Line 3 ========== // - // SD Percent, Hotend 2, or Bed + // Progress percent, Hotend 2, or Bed // lcd_moveto(0, 2); #if HOTENDS > 2 @@ -1025,24 +1089,17 @@ void MarlinUI::draw_status_screen() { _draw_bed_status(blink); #elif HAS_PRINT_PROGRESS #define DREW_PRINT_PROGRESS 1 - _draw_print_progress(); + pc = 0; pr = 2; + rotate_progress(); #endif // - // Elapsed Time or SD Percent + // All progress strings // - lcd_moveto(LCD_WIDTH - 9, 2); - #if HAS_PRINT_PROGRESS && !DREW_PRINT_PROGRESS - - _draw_print_progress(); - - #else - - (void)draw_elapsed_or_remaining_time(LCD_WIDTH - 4, blink); - + pc = LCD_WIDTH - 9; pr = 2; + rotate_progress(); #endif - #endif // LCD_INFO_SCREEN_STYLE 1 // ========= Last Line ======== @@ -1076,18 +1133,18 @@ void MarlinUI::draw_status_screen() { vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { int8_t pad = (LCD_WIDTH - plen - vlen) / 2; - while (--pad >= 0) { lcd_put_lchar(' '); n--; } + while (--pad >= 0) { lcd_put_u8str(F(" ")); n--; } } if (plen) n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, n); if (vlen) n -= lcd_put_u8str_max(vstr, n); - for (; n > 0; --n) lcd_put_lchar(' '); + for (; n > 0; --n) lcd_put_u8str(F(" ")); } // Draw a generic menu item with pre_char (if selected) and post_char void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char pre_char, const char post_char) { lcd_put_lchar(0, row, sel ? pre_char : ' '); uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2); - for (; n; --n) lcd_put_lchar(' '); + for (; n; --n) lcd_put_u8str(F(" ")); lcd_put_lchar(post_char); } @@ -1097,8 +1154,8 @@ void MarlinUI::draw_status_screen() { lcd_put_lchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vlen); if (vlen) { - lcd_put_lchar(':'); - for (; n; --n) lcd_put_lchar(' '); + lcd_put_u8str(F(":")); + for (; n; --n) lcd_put_u8str(F(" ")); if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } } @@ -1108,7 +1165,7 @@ void MarlinUI::draw_status_screen() { ui.encoder_direction_normal(); uint8_t n = lcd_put_u8str(0, 1, ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1); if (value) { - lcd_put_lchar(':'); n--; + lcd_put_u8str(F(":")); n--; const uint8_t len = utf8_strlen(value) + 1; // Plus one for a leading space const lcd_uint_t valrow = n < len ? 2 : 1; // Value on the next row if it won't fit lcd_put_lchar(LCD_WIDTH - len, valrow, ' '); // Right-justified, padded, leading space @@ -1135,7 +1192,7 @@ void MarlinUI::draw_status_screen() { lcd_put_lchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); constexpr uint8_t maxlen = LCD_WIDTH - 2; uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen); - for (; n; --n) lcd_put_lchar(' '); + for (; n; --n) lcd_put_u8str(F(" ")); lcd_put_lchar(isDir ? LCD_STR_FOLDER[0] : ' '); } @@ -1467,9 +1524,9 @@ void MarlinUI::draw_status_screen() { */ lcd_put_lchar(_LCD_W_POS, 0, '('); lcd_put_u8str(ui8tostr3rj(x_plot)); - lcd_put_lchar(','); + lcd_put_u8str(F(",")); lcd_put_u8str(ui8tostr3rj(y_plot)); - lcd_put_lchar(')'); + lcd_put_u8str(F(")")); #if LCD_HEIGHT <= 3 // 16x2 or 20x2 display diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index f3d98ec55584..e4f9e4eafc08 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -523,17 +523,14 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if !HEATER_IDLE_HANDLER UNUSED(blink); #else - if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_lchar(' '); - if (t2 >= 10) lcd_put_lchar(' '); - if (t2 >= 100) lcd_put_lchar(' '); - } + if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) + lcd_put_u8str(F(" ")); else #endif lcd_put_u8str(i16tostr3left(t2)); - lcd_put_lchar(' '); - if (t2 < 10) lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); + if (t2 < 10) lcd_put_u8str(F(" ")); if (t2) picBits |= ICON_TEMP1; else picBits &= ~ICON_TEMP1; @@ -545,7 +542,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE void _draw_flowmeter_status() { lcd_moveto(5, 5); lcd_put_u8str(F("FLOW")); - lcd_moveto(7, 6); lcd_put_lchar('L'); + lcd_moveto(7, 6); lcd_put_u8str(F("L")); lcd_moveto(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate)); if (cooler.flowrate) picBits |= ICON_FAN; @@ -564,7 +561,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const { lcd_put_u8str("mA"); lcd_moveto(10, 7); - lcd_put_lchar(' '); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); + lcd_put_u8str(F(" ")); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); } else { lcd_put_u8str(" A"); @@ -585,9 +582,9 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if CUTTER_UNIT_IS(RPM) lcd_moveto(16, 6); lcd_put_u8str(F("RPM")); lcd_moveto(15, 7); lcd_put_u8str(ftostr31ns(float(cutter.unitPower) / 1000)); - lcd_put_lchar('K'); + lcd_put_u8str(F("K")); #elif CUTTER_UNIT_IS(PERCENT) - lcd_moveto(17, 6); lcd_put_lchar('%'); + lcd_moveto(17, 6); lcd_put_u8str(F("%")); lcd_moveto(18, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); #else lcd_moveto(17, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); @@ -599,23 +596,58 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #endif // HAS_CUTTER -#if HAS_PRINT_PROGRESS - FORCE_INLINE void _draw_print_progress() { - if (!PanelDetected) return; - const uint8_t progress = ui._get_progress(); - #if ENABLED(SDSUPPORT) - lcd_put_u8str(F("SD")); - #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) - lcd_put_u8str(F("P:")); - #endif - if (progress) - lcd.print(ui8tostr3rj(progress)); - else - lcd_put_u8str(F("---")); - lcd.write('%'); - } +#if HAS_PRINT_PROGRESS // UNTESTED!!! + #define TPOFFSET (LCD_WIDTH - 1) + static uint8_t timepos = TPOFFSET - 6; + #if ENABLED(SHOW_PROGRESS_PERCENT) + void MarlinUI::drawPercent() { + const uint8_t progress = ui.get_progress_percent(); + if (progress) { + lcd_moveto(0, 2); + lcd_put_u8str(F(TERN(IS_SD_PRINTING, "SD", "P:"))); + lcd.print(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress))); + lcd.write('%'); + } + } + #endif + #if ENABLED(SHOW_REMAINING_TIME) + void MarlinUI::drawRemain() { + if (printJobOngoing()) { + const duration_t remaint = ui.get_remaining_time(); + char buffer[10]; + timepos = TPOFFSET - remaint.toDigital(buffer); + lcd_moveto(timepos, 1); + lcd.write('R'); + lcd.print(buffer); + } + } + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + void MarlinUI::drawInter() { + const duration_t interactt = ui.interaction_time; + if (printingIsActive() && interactt.value) { + char buffer[10]; + timepos = TPOFFSET - interactt.toDigital(buffer); + lcd_moveto(timepos, 1); + lcd.write('C'); + lcd.print(buffer); + } + } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + void MarlinUI::drawElapsed() { + if (printJobOngoing()) { + const duration_t elapsedt = print_job_timer.duration(); + char buffer[10]; + timepos = TPOFFSET - elapsedt.toDigital(buffer); + lcd_moveto(timepos, 1); + lcd.write('E'); + lcd.print(buffer); + } + } + #endif #endif // HAS_PRINT_PROGRESS #if ENABLED(LCD_PROGRESS_BAR) @@ -799,23 +831,12 @@ void MarlinUI::draw_status_screen() { #endif // - // Line 2 - feedrate, , time + // Line 2 - feedrate, progress %, progress time // lcd_moveto(0, 1); lcd_put_u8str(F("FR")); lcd.print(i16tostr3rj(feedrate_percentage)); lcd.write('%'); - - #if BOTH(SDSUPPORT, HAS_PRINT_PROGRESS) - lcd_moveto(LCD_WIDTH / 2 - 3, 1); - _draw_print_progress(); - #endif - - char buffer[10]; - duration_t elapsed = print_job_timer.duration(); - uint8_t len = elapsed.toDigital(buffer); - - lcd_moveto((LCD_WIDTH - 1) - len, 1); - lcd.write(LCD_STR_CLOCK[0]); lcd.print(buffer); + ui.rotate_progress(); // UNTESTED!!! // // Line 3 - progressbar diff --git a/Marlin/src/lcd/buttons.h b/Marlin/src/lcd/buttons.h index 2580a71d1b82..58471239bbfb 100644 --- a/Marlin/src/lcd/buttons.h +++ b/Marlin/src/lcd/buttons.h @@ -26,7 +26,7 @@ #if ((!HAS_ADC_BUTTONS && IS_NEWPANEL) || BUTTONS_EXIST(EN1, EN2)) && !IS_TFTGLCD_PANEL #define HAS_ENCODER_WHEEL 1 #endif -#if (HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT)) && DISABLED(TOUCH_UI_FTDI_EVE) +#if (HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DOWN, LEFT, RIGHT)) && DISABLED(TOUCH_UI_FTDI_EVE) #define HAS_DIGITAL_BUTTONS 1 #endif #if !HAS_ADC_BUTTONS && (IS_RRW_KEYPAD || (HAS_WIRED_LCD && !IS_NEWPANEL)) @@ -38,13 +38,6 @@ #define HAS_SLOW_BUTTONS 1 #endif -#if HAS_ENCODER_WHEEL - #define ENCODER_PHASE_0 0 - #define ENCODER_PHASE_1 2 - #define ENCODER_PHASE_2 3 - #define ENCODER_PHASE_3 1 -#endif - #if EITHER(HAS_DIGITAL_BUTTONS, HAS_DWIN_E3V2) // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes) #define BLEN_A 0 @@ -190,20 +183,20 @@ #else #define _BUTTON_PRESSED_UP false #endif -#if BUTTON_EXISTS(DWN) - #define _BUTTON_PRESSED_DWN _BUTTON_PRESSED(DWN) +#if BUTTON_EXISTS(DOWN) + #define _BUTTON_PRESSED_DOWN _BUTTON_PRESSED(DOWN) #else - #define _BUTTON_PRESSED_DWN false + #define _BUTTON_PRESSED_DOWN false #endif -#if BUTTON_EXISTS(LFT) - #define _BUTTON_PRESSED_LFT _BUTTON_PRESSED(LFT) +#if BUTTON_EXISTS(LEFT) + #define _BUTTON_PRESSED_LEFT _BUTTON_PRESSED(LEFT) #else - #define _BUTTON_PRESSED_LFT false + #define _BUTTON_PRESSED_LEFT false #endif -#if BUTTON_EXISTS(RT) - #define _BUTTON_PRESSED_RT _BUTTON_PRESSED(RT) +#if BUTTON_EXISTS(RIGHT) + #define _BUTTON_PRESSED_RIGHT _BUTTON_PRESSED(RIGHT) #else - #define _BUTTON_PRESSED_RT false + #define _BUTTON_PRESSED_RIGHT false #endif #if BUTTON_EXISTS(BACK) #define _BUTTON_PRESSED_BACK _BUTTON_PRESSED(BACK) diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index f38c9d76e3ba..cfba12acff1b 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -41,6 +41,13 @@ #define U8G_COM_HAL_HW_SPI_FN u8g_com_samd51_hw_spi_fn #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd51_st7920_hw_spi_fn + + #elif defined(__SAMD21__) + + uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + + #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd21_st7920_hw_spi_fn + #elif defined(__STM32F1__) uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp index 48b2e92a118d..74a49b095021 100644 --- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp +++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp @@ -34,7 +34,7 @@ int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { return u8g_GetFontBBXWidth(u8g.getU8g()); } u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(), - ret = uxg_DrawWchar(u8g.getU8g(), x, y, c, max_length); + ret = uxg_DrawLchar(u8g.getU8g(), x, y, c, max_length); u8g.setPrintPos(x + ret, y); return ret; } diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index e32715988d2f..1a86058b943c 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -343,8 +343,7 @@ void MarlinUI::draw_kill_screen() { void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #if HAS_DISPLAY_SLEEP - void MarlinUI::sleep_on() { u8g.sleepOn(); } - void MarlinUI::sleep_off() { u8g.sleepOff(); } + void MarlinUI::sleep_display(const bool sleep) { sleep ? u8g.sleepOn() : u8g.sleepOff(); } #endif #if HAS_LCD_BRIGHTNESS @@ -373,9 +372,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop lcd_put_lchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), y2, 'E'); lcd_put_lchar((char)('1' + extruder)); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); - lcd_put_lchar('/'); + lcd_put_u8str(F("/")); if (get_blink() || !thermalManager.heater_idle[extruder].timed_out) lcd_put_u8str(i16tostr3rj(thermalManager.degTargetHotend(extruder))); @@ -421,12 +420,12 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { int pad = (LCD_PIXEL_WIDTH - plen - vlen * MENU_FONT_WIDTH) / MENU_FONT_WIDTH / 2; - while (--pad >= 0) n -= lcd_put_lchar(' '); + while (--pad >= 0) n -= lcd_put_u8str(F(" ")); } if (plen) n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, n / (MENU_FONT_WIDTH)) * (MENU_FONT_WIDTH); if (vlen) n -= lcd_put_u8str_max(vstr, n); - while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); } } @@ -434,9 +433,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char, const char post_char) { if (mark_as_selected(row, sel)) { pixel_len_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1) * (MENU_FONT_WIDTH); - while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); lcd_put_lchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); } } @@ -449,8 +448,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop pixel_len_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vallen * prop) * (MENU_FONT_WIDTH); if (vallen) { - lcd_put_lchar(':'); - while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + lcd_put_u8str(F(":")); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); lcd_moveto(LCD_PIXEL_WIDTH - _MAX((MENU_FONT_WIDTH) * vallen, pixelwidth + 2), row_y2); if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } @@ -494,7 +493,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // If a value is included, print a colon, then print the value right-justified if (value) { - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); if (extra_row) { // Assume that value is numeric (with no descender) baseline += EDIT_FONT_ASCENT + 2; @@ -536,7 +535,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (isDir) lcd_put_lchar(LCD_STR_FOLDER[0]); const pixel_len_t pixw = maxlen * (MENU_FONT_WIDTH); pixel_len_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw); - while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); } } @@ -613,9 +612,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (PAGE_CONTAINS(LCD_PIXEL_HEIGHT - (INFO_FONT_HEIGHT - 1), LCD_PIXEL_HEIGHT)) { lcd_put_lchar(5, LCD_PIXEL_HEIGHT, '('); u8g.print(x_plot); - lcd_put_lchar(','); + lcd_put_u8str(F(",")); u8g.print(y_plot); - lcd_put_lchar(')'); + lcd_put_u8str(F(")")); // Show the location value lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL); diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.h b/Marlin/src/lcd/dogm/marlinui_DOGM.h index 050f147d625c..f70621574c33 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.h +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.h @@ -36,10 +36,16 @@ // RepRapWorld Graphical LCD - #define U8G_CLASS U8GLIB_ST7920_128X64_4X + #if DISABLED(SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_ENABLE == SD_MOSI_PIN) + #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL + #define U8G_PARAM LCD_PINS_RS + #elif ENABLED(SDSUPPORT) && __SAMD21__ + + #define U8G_CLASS U8GLIB_ST7920_128X64_4X #define U8G_PARAM LCD_PINS_RS #else + #define U8G_CLASS U8GLIB_ST7920_128X64_4X #define U8G_PARAM LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS #endif diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 67039d52de7b..cba58f5c02f9 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -40,9 +40,7 @@ #include "../../gcode/parser.h" // for units (and volumetric) -#if ENABLED(LCD_SHOW_E_TOTAL) - #include "../../MarlinCore.h" // for printingIsActive() -#endif +#include "../../MarlinCore.h" // for printingIsActive() #if ENABLED(FILAMENT_LCD_DISPLAY) #include "../../feature/filwidth.h" @@ -440,11 +438,54 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const else if (axis_should_home(axis)) while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?'); else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) - lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" ")); + lcd_put_u8str(TERN0(HAS_Z_AXIS, axis == Z_AXIS) ? F(" ") : F(" ")); else lcd_put_u8str(value); } +// Prepare strings for progress display +#if HAS_PRINT_PROGRESS + static MarlinUI::progress_t progress = 0; + static char bufferc[13]; + + static void prepare_time_string(const duration_t &time, char prefix) { + char str[13]; + memset(&bufferc[2], 0x20, 5); // partialy fill with spaces to avoid artifacts and terminator + bufferc[0] = prefix; + bufferc[1] = ':'; + int str_length = time.toDigital(str, time.value >= 60*60*24L); + strcpy(&bufferc[sizeof(bufferc) - str_length - 1], str); + } + + #if ENABLED(SHOW_PROGRESS_PERCENT) + void MarlinUI::drawPercent() { + if (progress != 0) { + #define PCENTERED 1 // center percent value over progress bar, else align to the right + #define PPOS TERN(PCENTERED, 4, 0) + #define PLEN TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3) + memset(&bufferc, 0x20, 12); + memcpy(&bufferc[PPOS], TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), PLEN); + bufferc[PPOS+PLEN] = '%'; + } + } + #endif + #if ENABLED(SHOW_REMAINING_TIME) + void MarlinUI::drawRemain() { + if (printJobOngoing() && get_remaining_time() != 0) + prepare_time_string(get_remaining_time(), 'R'); } + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + void MarlinUI::drawInter() { + if (printingIsActive() && interaction_time) + prepare_time_string(interaction_time, 'C'); } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + void MarlinUI::drawElapsed() { + if (printJobOngoing()) + prepare_time_string(print_job_timer.duration(), 'E'); } + #endif +#endif // HAS_PRINT_PROGRESS + /** * Draw the Status Screen for a 128x64 DOGM (U8glib) display. * @@ -453,38 +494,22 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const */ void MarlinUI::draw_status_screen() { constexpr int xystorage = TERN(INCH_MODE_SUPPORT, 8, 5); - static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, xystorage)], ystring[xystorage], zstring[8]; + static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, xystorage)]; + #if HAS_Y_AXIS + static char ystring[xystorage]; + #endif + #if HAS_Z_AXIS + static char zstring[8]; + #endif #if ENABLED(FILAMENT_LCD_DISPLAY) static char wstring[5], mstring[4]; #endif - #if HAS_PRINT_PROGRESS - #if DISABLED(SHOW_SD_PERCENT) - #define _SD_INFO_X(len) (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH) / 2 - (len) * (MENU_FONT_WIDTH) / 2) - #else - #define _SD_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH)) - #endif - - #if ENABLED(SHOW_SD_PERCENT) - static char progress_string[5]; - #endif - static uint8_t lastElapsed = 0xFF, lastProgress = 0xFF; - static u8g_uint_t elapsed_x_pos = 0, progress_bar_solid_width = 0; - static char elapsed_string[16]; - #if ENABLED(SHOW_REMAINING_TIME) - static u8g_uint_t estimation_x_pos = 0; - static char estimation_string[10]; - #if BOTH(SHOW_SD_PERCENT, ROTATE_PROGRESS_DISPLAY) - static u8g_uint_t progress_x_pos = 0; - static uint8_t progress_state = 0; - static bool prev_blink = 0; - #endif - #endif - #endif - const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive()); + static u8g_uint_t progress_bar_solid_width = 0; + // At the first page, generate new display values if (first_page) { #if ANIM_HBCC @@ -502,7 +527,9 @@ void MarlinUI::draw_status_screen() { const xyz_pos_t lpos = current_position.asLogical(); const bool is_inch = parser.using_inch_units(); - strcpy(zstring, is_inch ? ftostr42_52(LINEAR_UNIT(lpos.z)) : ftostr52sp(lpos.z)); + #if HAS_Z_AXIS + strcpy(zstring, is_inch ? ftostr42_52(LINEAR_UNIT(lpos.z)) : ftostr52sp(lpos.z)); + #endif if (show_e_total) { #if ENABLED(LCD_SHOW_E_TOTAL) @@ -512,7 +539,7 @@ void MarlinUI::draw_status_screen() { } else { strcpy(xstring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.x)) : ftostr4sign(lpos.x)); - strcpy(ystring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.y)) : ftostr4sign(lpos.y)); + TERN_(HAS_Y_AXIS, strcpy(ystring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.y)) : ftostr4sign(lpos.y))); } #if ENABLED(FILAMENT_LCD_DISPLAY) @@ -520,64 +547,19 @@ void MarlinUI::draw_status_screen() { strcpy(mstring, i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled))); #endif - // Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw + // Progress update to avoid float math on each LCD draw #if HAS_PRINT_PROGRESS - const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); - duration_t elapsed = print_job_timer.duration(); - const uint8_t p = progress & 0xFF, ev = elapsed.value & 0xFF; + progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); + + static uint8_t lastProgress = 0xFF; + const uint8_t p = progress & 0xFF; if (p != lastProgress) { lastProgress = p; - progress_bar_solid_width = u8g_uint_t((PROGRESS_BAR_WIDTH - 2) * (progress / (PROGRESS_SCALE)) * 0.01f); - - #if ENABLED(SHOW_SD_PERCENT) - if (progress == 0) { - progress_string[0] = '\0'; - #if ENABLED(SHOW_REMAINING_TIME) - estimation_string[0] = '\0'; - estimation_x_pos = _SD_INFO_X(0); - #endif - } - else - strcpy(progress_string, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); - - #if BOTH(SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY) // Tri-state progress display mode - progress_x_pos = _SD_INFO_X(strlen(progress_string) + 1); - #endif - #endif - } - - constexpr bool can_show_days = DISABLED(SHOW_SD_PERCENT) || ENABLED(ROTATE_PROGRESS_DISPLAY); - if (ev != lastElapsed) { - lastElapsed = ev; - const uint8_t len = elapsed.toDigital(elapsed_string, can_show_days && elapsed.value >= 60*60*24L); - elapsed_x_pos = _SD_INFO_X(len); - - #if ENABLED(SHOW_REMAINING_TIME) - if (!(ev & 0x3)) { - uint32_t timeval = (0 - #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) - + get_remaining_time() - #endif - ); - if (!timeval && progress > 0) timeval = elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress; - if (!timeval) { - estimation_string[0] = '\0'; - estimation_x_pos = _SD_INFO_X(0); - } - else { - duration_t estimation = timeval; - const uint8_t len = estimation.toDigital(estimation_string, can_show_days && estimation.value >= 60*60*24L); - estimation_x_pos = _SD_INFO_X(len + !BOTH(SHOW_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)); - } - } - #endif } #endif } - const bool blink = get_blink(); - // Status Menu Font set_font(FONT_STATUSMENU); @@ -634,6 +616,8 @@ void MarlinUI::draw_status_screen() { u8g.drawBitmapP(STATUS_CHAMBER_X, chambery, STATUS_CHAMBER_BYTEWIDTH, chamberh, CHAMBER_BITMAP(CHAMBER_ALT())); #endif + const bool blink = ui.get_blink(); + #if DO_DRAW_FAN #if STATUS_FAN_FRAMES > 2 static bool old_blink; @@ -664,8 +648,7 @@ void MarlinUI::draw_status_screen() { if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) { // Extruders #if DO_DRAW_HOTENDS - LOOP_L_N(e, MAX_HOTEND_DRAW) - _draw_hotend_status((heater_id_t)e, blink); + LOOP_L_N(e, MAX_HOTEND_DRAW) _draw_hotend_status((heater_id_t)e, blink); #endif // Laser / Spindle @@ -675,7 +658,7 @@ void MarlinUI::draw_status_screen() { lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #elif CUTTER_UNIT_IS(RPM) lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr61rj(float(cutter.unitPower) / 1000)); - lcd_put_lchar('K'); + lcd_put_u8str(F("K")); #else lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #endif @@ -757,74 +740,20 @@ void MarlinUI::draw_status_screen() { #endif // SDSUPPORT #if HAS_PRINT_PROGRESS - // // Progress bar frame - // - if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + 3)) u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, 4); - // // Progress bar solid part - // - if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + 2)) u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2); - if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) { - - #if ALL(SHOW_SD_PERCENT, SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY) - - if (prev_blink != blink) { - prev_blink = blink; - if (++progress_state >= 3) progress_state = 0; - } - - if (progress_state == 0) { - if (progress_string[0]) { - lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string); - lcd_put_lchar('%'); - } - } - else if (progress_state == 2 && estimation_string[0]) { - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("R:")); - lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string); - } - else if (elapsed_string[0]) { - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("E:")); - lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string); - } - - #else // !SHOW_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY - - // - // SD Percent Complete - // - - #if ENABLED(SHOW_SD_PERCENT) - if (progress_string[0]) { - lcd_put_u8str(55, EXTRAS_BASELINE, progress_string); // Percent complete - lcd_put_lchar('%'); - } - #endif - - // - // Elapsed Time - // - - #if ENABLED(SHOW_REMAINING_TIME) - if (blink && estimation_string[0]) { - lcd_put_lchar(estimation_x_pos, EXTRAS_BASELINE, 'R'); - lcd_put_u8str(estimation_string); - } - else - #endif - lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string); - - #endif // !SHOW_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY + // Progress strings + if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)){ + ui.rotate_progress(); + lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, bufferc); } - - #endif // HAS_PRINT_PROGRESS + #endif // // XYZ Coordinates @@ -892,12 +821,14 @@ void MarlinUI::draw_status_screen() { } else { _draw_axis_value(X_AXIS, xstring, blink); - _draw_axis_value(Y_AXIS, ystring, blink); + TERN_(HAS_Y_AXIS, _draw_axis_value(Y_AXIS, ystring, blink)); } #endif - _draw_axis_value(Z_AXIS, zstring, blink); + #if HAS_Z_AXIS + _draw_axis_value(Z_AXIS, zstring, blink); + #endif #if NONE(XYZ_NO_FRAME, XYZ_HOLLOW_FRAME) u8g.setColorIndex(1); // black on white @@ -916,7 +847,7 @@ void MarlinUI::draw_status_screen() { set_font(FONT_STATUSMENU); lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage)); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); // // Filament sensor display if SD is disabled @@ -924,7 +855,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT) lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring); lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); set_font(FONT_MENU); lcd_put_lchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str(F(LCD_STR_FILAM_DIA)); lcd_put_lchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]); @@ -941,12 +872,12 @@ void MarlinUI::draw_status_screen() { // Alternate Status message and Filament display if (ELAPSED(millis(), next_filament_display)) { lcd_put_u8str(F(LCD_STR_FILAM_DIA)); - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); lcd_put_u8str(wstring); lcd_put_u8str(F(" " LCD_STR_FILAM_MUL)); - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); lcd_put_u8str(mstring); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); return; } #endif @@ -979,7 +910,7 @@ void MarlinUI::draw_status_message(const bool blink) { if (slen <= lcd_width) { // The string fits within the line. Print with no scrolling lcd_put_u8str(status_message); - while (slen < lcd_width) { lcd_put_lchar(' '); ++slen; } + while (slen < lcd_width) { lcd_put_u8str(F(" ")); ++slen; } } else { // String is longer than the available space @@ -997,14 +928,14 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < lcd_width) { uint8_t chars = lcd_width - rlen; // Amount of space left in characters - lcd_put_lchar(' '); // Always at 1+ spaces left, draw a space + lcd_put_u8str(F(" ")); // Always at 1+ spaces left, draw a space if (--chars) { // Draw a second space if there's room - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); if (--chars) { // Draw a third space if there's room - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); if (--chars) { // Print a second copy of the message lcd_put_u8str_max(status_message, pixel_width - (rlen + 2) * (MENU_FONT_WIDTH)); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); } } } @@ -1019,7 +950,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, pixel_width); // Fill the rest with spaces - for (; slen < lcd_width; ++slen) lcd_put_lchar(' '); + for (; slen < lcd_width; ++slen) lcd_put_u8str(F(" ")); #endif // !STATUS_MESSAGE_SCROLLING diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index 492a79a31108..9ed0d8a9d674 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -40,12 +40,38 @@ // Lightweight Status Screen for Graphical Display // +/** One hotend layout + * ------------------ + * |⟱ xxx➜xxx° ✱xxx% + * |_ xxx➜xxx° Fxxx% + * ||||||||||R•xxx:xx + * | status string + * ------------------ + * + * hotend temp | fan speed + * bed temp | feedrate + * progress bar| progress time + * status string + * + * **************************** + * Two hotends layout + * ------------------ + * |⟱ xxx➜xxx° ✱xxx% + * |⟱ xxx➜xxx°||||||| + * |_ xxx➜xxx°Rxxx:xx + * | status string + * ------------------ + * + * hotend temp | fan speed + * hotend temp | progress bar + * bed temp | progress time + * status string + */ + #include "../../inc/MarlinConfigPre.h" #if ENABLED(LIGHTWEIGHT_UI) -#include "status_screen_lite_ST7920.h" - #include "../marlinui.h" #include "../fontutils.h" #include "../lcdprint.h" @@ -53,12 +79,13 @@ #include "../../module/motion.h" #include "../../module/printcounter.h" #include "../../module/temperature.h" +#include "../../libs/numtostr.h" #if ENABLED(SDSUPPORT) #include "../../sd/cardreader.h" #endif -#if ENABLED(LCD_SHOW_E_TOTAL) +#if ENABLED(LCD_SHOW_E_TOTAL) || HAS_PRINT_PROGRESS #include "../../MarlinCore.h" // for printingIsActive #endif @@ -72,6 +99,9 @@ #define DDRAM_LINE_3 0x08 #define DDRAM_LINE_4 0x18 +#include "status_screen_lite_ST7920.h" +extern ST7920_Lite_Status_Screen lightUI; + ST7920_Lite_Status_Screen::st7920_state_t ST7920_Lite_Status_Screen::current_bits; void ST7920_Lite_Status_Screen::cmd(const uint8_t cmd) { @@ -442,72 +472,6 @@ void ST7920_Lite_Status_Screen::draw_static_elements() { draw_fan_icon(false); } -/** - * Although this is undocumented, the ST7920 allows the character - * data buffer (DDRAM) to be used in conjunction with the graphics - * bitmap buffer (CGRAM). The contents of the graphics buffer is - * XORed with the data from the character generator. This allows - * us to make the progress bar out of graphical data (the bar) and - * text data (the percentage). - */ -void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) { - #if HOTENDS == 1 - // If we have only one extruder, draw a long progress bar on the third line - constexpr uint8_t top = 1, // Top in pixels - bottom = 13, // Bottom in pixels - left = 12, // Left edge, in 16-bit words - width = 4; // Width of progress bar, in 16-bit words - #else - constexpr uint8_t top = 16 + 1, - bottom = 16 + 13, - left = 5, - width = 3; - #endif - const uint8_t char_pcnt = 100 / width; // How many percent does each 16-bit word represent? - - // Draw the progress bar as a bitmap in CGRAM - LOOP_S_LE_N(y, top, bottom) { - set_gdram_address(left, y); - begin_data(); - LOOP_L_N(x, width) { - uint16_t gfx_word = 0x0000; - if ((x + 1) * char_pcnt <= value) - gfx_word = 0xFFFF; // Draw completely filled bytes - else if ((x * char_pcnt) < value) - gfx_word = int(0x8000) >> (value % char_pcnt) * 16 / char_pcnt; // Draw partially filled bytes - - // Draw the frame around the progress bar - if (y == top || y == bottom) - gfx_word = 0xFFFF; // Draw top/bottom border - else if (x == width - 1) - gfx_word |= 0x0001; // Draw right border - else if (x == 0) - gfx_word |= 0x8000; // Draw left border - write_word(gfx_word); - } - } - - // Draw the percentage as text in DDRAM - #if HOTENDS == 1 - set_ddram_address(DDRAM_LINE_3 + 4); - begin_data(); - write_byte(' '); - #else - set_ddram_address(DDRAM_LINE_2 + left); - begin_data(); - #endif - - // Draw centered - if (value > 9) { - write_number(value, 4); - write_str(F("% ")); - } - else { - write_number(value, 3); - write_str(F("% ")); - } -} - void ST7920_Lite_Status_Screen::draw_fan_icon(const bool whichIcon) { set_ddram_address(DDRAM_LINE_1 + 5); begin_data(); @@ -592,22 +556,8 @@ void ST7920_Lite_Status_Screen::draw_fan_speed(const uint8_t value) { write_byte('%'); } -void ST7920_Lite_Status_Screen::draw_print_time(const duration_t &elapsed, char suffix) { - #if HOTENDS == 1 - set_ddram_address(DDRAM_LINE_3); - #else - set_ddram_address(DDRAM_LINE_3 + 5); - #endif - char str[7]; - int str_length = elapsed.toDigital(str); - str[str_length++] = suffix; - begin_data(); - write_str(str, str_length); -} - void ST7920_Lite_Status_Screen::draw_feedrate_percentage(const uint16_t percentage) { - // We only have enough room for the feedrate when - // we have one extruder + // We only have enough room for the feedrate when we have one extruder #if HOTENDS == 1 set_ddram_address(DDRAM_LINE_2 + 6); begin_data(); @@ -631,11 +581,9 @@ void ST7920_Lite_Status_Screen::draw_status_message() { write_str(str); while (slen < TEXT_MODE_LCD_WIDTH) { write_byte(' '); ++slen; } } - else { - // String is larger than the available space in screen. + else { // String is larger than the available space in ST7920_Lite_Status_Screen:: - // Get a pointer to the next valid UTF8 character - // and the string remaining length + // Get a pointer to the next valid UTF8 character and the string remaining length uint8_t rlen; const char *stat = ui.status_and_len(rlen); write_str(stat, TEXT_MODE_LCD_WIDTH); @@ -643,12 +591,12 @@ void ST7920_Lite_Status_Screen::draw_status_message() { // If the remaining string doesn't completely fill the screen if (rlen < TEXT_MODE_LCD_WIDTH) { uint8_t chars = TEXT_MODE_LCD_WIDTH - rlen; // Amount of space left in characters - write_byte(' '); // Always at 1+ spaces left, draw a space - if (--chars) { // Draw a second space if there's room + write_byte(' '); // Always at 1+ spaces left, draw a space + if (--chars) { // Draw a second space if there's room write_byte(' '); - if (--chars) { // Draw a third space if there's room + if (--chars) { // Draw a third space if there's room write_byte(' '); - if (--chars) write_str(str, chars); // Print a second copy of the message + if (--chars) write_str(str, chars); // Print a second copy of the message } } } @@ -715,11 +663,155 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { return true; } +// Process progress strings +#if HAS_PRINT_PROGRESS + static char screenstr[8]; + + char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) { + static char str[6]; + memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles + screenstr[0] = prefix; + TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space + int str_length = time.toDigital(str); + memcpy(&screenstr[TERN(HOTENDS == 1, 2, 1)], str, str_length); //memcpy because we can't have terminator + return screenstr; + } + + void ST7920_Lite_Status_Screen::draw_progress_string(uint8_t addr, const char *str) { + set_ddram_address(addr); + begin_data(); + write_str(str, TERN(HOTENDS == 1, 8, 6)); + } + + #define PPOS (DDRAM_LINE_3 + TERN(HOTENDS == 1, 4, 5)) // progress string position, in 16-bit words + + #if ENABLED(SHOW_PROGRESS_PERCENT) + void MarlinUI::drawPercent() { lightUI.drawPercent(); } + void ST7920_Lite_Status_Screen::drawPercent() { + #define LSHIFT TERN(HOTENDS == 1, 0, 1) + const uint8_t progress = ui.get_progress_percent(); + memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts + if (progress){ + memcpy(&screenstr[2 - LSHIFT], \ + TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)), \ + TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3)); + screenstr[(TERN(PRINT_PROGRESS_SHOW_DECIMALS, 6, 5) - LSHIFT)] = '%'; + draw_progress_string(PPOS, screenstr); + } + } + #endif + #if ENABLED(SHOW_REMAINING_TIME) + void MarlinUI::drawRemain() { lightUI.drawRemain(); } + void ST7920_Lite_Status_Screen::drawRemain() { + const duration_t remaint = TERN0(SET_REMAINING_TIME, ui.get_remaining_time()); + if (printJobOngoing() && remaint.value) { + draw_progress_string( PPOS, prepare_time_string(remaint, 'R')); + } + } + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + void MarlinUI::drawInter() { lightUI.drawInter(); } + void ST7920_Lite_Status_Screen::drawInter() { + const duration_t interactt = ui.interaction_time; + if (printingIsActive() && interactt.value) { + draw_progress_string( PPOS, prepare_time_string(interactt, 'C')); + } + } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + void MarlinUI::drawElapsed() { lightUI.drawElapsed(); } + void ST7920_Lite_Status_Screen::drawElapsed() { + if (printJobOngoing()) { + const duration_t elapsedt = print_job_timer.duration(); + draw_progress_string( PPOS, prepare_time_string(elapsedt, 'E')); + } + } + #endif + + /** + * Although this is undocumented, the ST7920 allows the character + * data buffer (DDRAM) to be used in conjunction with the graphics + * bitmap buffer (CGRAM). The contents of the graphics buffer is + * XORed with the data from the character generator. This allows + * us to make the progress bar out of graphical data (the bar) and + * text data (the percentage). + */ + void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) { + #if HOTENDS == 1 + // If we have only one extruder, draw a long progress bar on the third line + constexpr uint8_t top = 1, // Top in pixels + bottom = 13, // Bottom in pixels + left = 8, // Left edge, in 16-bit words + width = 4; // Width of progress bar, in 16-bit words + #else + constexpr uint8_t top = 16 + 1, + bottom = 16 + 13, + left = 5, + width = 3; + #endif + const uint8_t char_pcnt = 100 / width; // How many percent does each 16-bit word represent? + + // Draw the progress bar as a bitmap in CGRAM + // This drawing is a mess and only produce readable result around 25% steps + // i.e. 74-76% look fine [|||||||||||||||||||||||| ], but 73% look like this: [|||||||||||||||| | ] + // meaning partially filled bytes produce only single vertical line, and i bet they're not supposed to! + LOOP_S_LE_N(y, top, bottom) { + set_gdram_address(left, y); + begin_data(); + LOOP_L_N(x, width) { + uint16_t gfx_word = 0x0000; + if ((x + 1) * char_pcnt <= value) + gfx_word = 0xFFFF; // Draw completely filled bytes + else if ((x * char_pcnt) < value) + gfx_word = int16_t(0x8000) >> (value % char_pcnt) * 16 / char_pcnt; // Draw partially filled bytes + + // Draw the frame around the progress bar + if (y == top || y == bottom) + gfx_word = 0xFFFF; // Draw top/bottom border + else if (x == width - 1) + gfx_word |= 0x0001; // Draw right border + else if (x == 0) + gfx_word |= 0x8000; // Draw left border + write_word(gfx_word); + } + } + + // // Draw the percentage as text in DDRAM + // #if HOTENDS == 1 + // set_ddram_address(DDRAM_LINE_3 + 4); + // begin_data(); + // write_byte(' '); + // #else + // set_ddram_address(DDRAM_LINE_2 + left); + // begin_data(); + // #endif + + // // Draw centered + // if (value > 9) + // write_number(value, 4); + // else + // write_number(value, 3); + // write_str(F("% ")); + } + + void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) { + + // Since the progress bar involves writing + // quite a few bytes to GDRAM, only do this + // when an update is actually necessary. + + const uint8_t progress = ui.get_progress_percent(); + static uint8_t last_progress = 0; + if (forceUpdate || last_progress != progress/2) { + last_progress = progress/2; // Because progress bar turns out only 62||46px wide, we only need to redraw it every 2% + draw_progress_bar(progress); + } + } +#endif // HAS_PRINT_PROGRESS + void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) { if (forceUpdate || indicators_changed()) { const bool blink = ui.get_blink(); - const duration_t elapsed = print_job_timer.duration(); - duration_t remaining = TERN0(USE_M73_REMAINING_TIME, ui.get_remaining_time()); const uint16_t feedrate_perc = feedrate_percentage; const celsius_t extruder_1_temp = thermalManager.wholeDegHotend(0), extruder_1_target = thermalManager.degTargetHotend(0); @@ -736,30 +828,20 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) { TERN_(HAS_MULTI_HOTEND, draw_extruder_2_temp(extruder_2_temp, extruder_2_target, forceUpdate)); TERN_(HAS_HEATED_BED, draw_bed_temp(bed_temp, bed_target, forceUpdate)); + // Update the fan and bed animations uint8_t spd = thermalManager.fan_speed[0]; #if ENABLED(ADAPTIVE_FAN_SLOWING) if (!blink && thermalManager.fan_speed_scaler[0] < 128) spd = thermalManager.scaledFanSpeed(0, spd); #endif draw_fan_speed(thermalManager.pwmToPercent(spd)); - - // Draw elapsed/remaining time - const bool show_remaining = ENABLED(SHOW_REMAINING_TIME) && (DISABLED(ROTATE_PROGRESS_DISPLAY) || blink); - if (show_remaining && !remaining.second()) { - const auto progress = ui.get_progress_percent(); - if (progress) - remaining = elapsed.second() * (100 - progress) / progress; - } - if (show_remaining && remaining.second()) - draw_print_time(remaining, 'R'); - else - draw_print_time(elapsed); + if (spd) draw_fan_icon(blink); + TERN_(HAS_HEATED_BED, draw_heat_icon(bed_target > 0 && blink, bed_target > 0)); draw_feedrate_percentage(feedrate_perc); - // Update the fan and bed animations - if (spd) draw_fan_icon(blink); - TERN_(HAS_HEATED_BED, draw_heat_icon(bed_target > 0 && blink, bed_target > 0)); + // Update and draw progress strings + TERN_(HAS_PRINT_PROGRESS, ui.rotate_progress()); } } @@ -839,27 +921,6 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) { #endif } -void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) { - #if EITHER(LCD_SET_PROGRESS_MANUALLY, SDSUPPORT) - - // Since the progress bar involves writing - // quite a few bytes to GDRAM, only do this - // when an update is actually necessary. - - static uint8_t last_progress = 0; - const uint8_t progress = ui.get_progress_percent(); - if (forceUpdate || last_progress != progress) { - last_progress = progress; - draw_progress_bar(progress); - } - - #else - - UNUSED(forceUpdate); - - #endif -} - void ST7920_Lite_Status_Screen::update(const bool forceUpdate) { cs(); update_indicators(forceUpdate); @@ -902,7 +963,7 @@ void ST7920_Lite_Status_Screen::clear_text_buffer() { } void MarlinUI::draw_status_screen() { - ST7920_Lite_Status_Screen::update(false); + lightUI.update(false); } // This method is called before each screen update and @@ -912,9 +973,9 @@ void MarlinUI::lcd_in_status(const bool inStatus) { static bool lastInStatus = false; if (lastInStatus == inStatus) return; if ((lastInStatus = inStatus)) - ST7920_Lite_Status_Screen::on_entry(); + lightUI.on_entry(); else - ST7920_Lite_Status_Screen::on_exit(); + lightUI.on_exit(); } #endif // LIGHTWEIGHT_UI diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h index 7fe878356b0d..d838ee1a3a68 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h @@ -75,7 +75,6 @@ class ST7920_Lite_Status_Screen { protected: static void draw_degree_symbol(uint8_t x, uint8_t y, const bool draw); static void draw_static_elements(); - static void draw_progress_bar(const uint8_t value); static void draw_fan_icon(const bool whichIcon); static void draw_heat_icon(const bool whichIcon, const bool heating); static void draw_temps(uint8_t line, const int16_t temp, const int16_t target, bool showTarget, bool targetStateChange); @@ -83,7 +82,12 @@ class ST7920_Lite_Status_Screen { static void draw_extruder_2_temp(const int16_t temp, const int16_t target, bool forceUpdate=false); static void draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate=false); static void draw_fan_speed(const uint8_t value); - static void draw_print_time(const duration_t &elapsed, char suffix=' '); + #if HAS_PRINT_PROGRESS + static void draw_progress_bar(const uint8_t value); + static char* prepare_time_string(const duration_t &time, char prefix=' '); + static void draw_progress_string(uint8_t addr, const char *str); + static void update_progress(const bool forceUpdate); + #endif static void draw_feedrate_percentage(const uint16_t percentage); static void draw_status_message(); static void draw_position(const xyze_pos_t &pos, bool position_known=true); @@ -96,11 +100,18 @@ class ST7920_Lite_Status_Screen { static void update_indicators(const bool forceUpdate); static void update_position(const bool forceUpdate, bool resetChecksum); static void update_status_or_position(bool forceUpdate); - static void update_progress(const bool forceUpdate); public: static void update(const bool forceUpdate); static void on_entry(); static void on_exit(); static void clear_text_buffer(); + #if HAS_PRINT_PROGRESS + static void drawPercent(); + static void drawRemain(); + static void drawInter(); + static void drawElapsed(); + #endif }; + +extern ST7920_Lite_Status_Screen lightUI; diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp index d5e0e5bafff3..e9d15350963a 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp @@ -161,7 +161,7 @@ static int fontgroup_cb_draw_u8g(void *userdata, const font_t *fnt_current, cons * * Draw a UTF-8 string at the specified position */ -unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &wc, pixel_len_t max_width) { +unsigned int uxg_DrawLchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &wc, pixel_len_t max_width) { struct _uxg_drawu8_data_t data; font_group_t *group = &g_fontgroup_root; const font_t *fnt_default = uxg_GetFont(pu8g); diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.h b/Marlin/src/lcd/dogm/u8g_fontutf8.h index 0109b6674cbe..660eb28ffeb3 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.h +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.h @@ -26,7 +26,7 @@ typedef struct _uxg_fontinfo_t { int uxg_SetUtf8Fonts(const uxg_fontinfo_t * fntinfo, int number); // fntinfo is type of PROGMEM -unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &ch, const pixel_len_t max_length); +unsigned int uxg_DrawLchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &ch, const pixel_len_t max_length); unsigned int uxg_DrawUtf8Str(u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, const pixel_len_t max_length); unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P utf8_msg, const pixel_len_t max_length); diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index 3f699465a9c8..f3abaf25c96b 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -234,7 +234,7 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // *string: The string // rlimit: To limit the drawn string length void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) { - #if DISABLED(DWIN_LCD_PROUI) + #if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, IS_DWIN_MARLINUI) DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); #endif constexpr uint8_t widthAdjust = 0; @@ -266,7 +266,9 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) { size_t i = 0; - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); + #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); + #endif DWIN_Byte(i, 0x14); // Bit 7: bshow // Bit 6: 1 = signed; 0 = unsigned number; @@ -314,7 +316,9 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_ uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) { //uint8_t *fvalue = (uint8_t*)&value; size_t i = 0; - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); + #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); + #endif DWIN_Byte(i, 0x14); DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); DWIN_Word(i, color); diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index f14d63e7b5b3..5081e27690f2 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -96,21 +96,21 @@ EncoderState Encoder_ReceiveAnalyze() { } if (newbutton != lastEncoderBits) { switch (newbutton) { - case ENCODER_PHASE_0: - if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--; + case 0: + if (lastEncoderBits == 1) temp_diff++; + else if (lastEncoderBits == 2) temp_diff--; break; - case ENCODER_PHASE_1: - if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--; + case 2: + if (lastEncoderBits == 0) temp_diff++; + else if (lastEncoderBits == 3) temp_diff--; break; - case ENCODER_PHASE_2: - if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--; + case 3: + if (lastEncoderBits == 2) temp_diff++; + else if (lastEncoderBits == 1) temp_diff--; break; - case ENCODER_PHASE_3: - if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--; + case 1: + if (lastEncoderBits == 3) temp_diff++; + else if (lastEncoderBits == 0) temp_diff--; break; } lastEncoderBits = newbutton; diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index 1232c8e0c91c..08d928684a6f 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -3395,11 +3395,11 @@ void Draw_Max_Accel_Menu() { Draw_Back_First(); LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MaxSpeedJerkX + i); - Draw_Edit_Float3(1, planner.max_jerk[X_AXIS] * MINUNITMULT); - Draw_Edit_Float3(2, planner.max_jerk[Y_AXIS] * MINUNITMULT); - Draw_Edit_Float3(3, planner.max_jerk[Z_AXIS] * MINUNITMULT); + Draw_Edit_Float3(1, planner.max_jerk.x * MINUNITMULT); + Draw_Edit_Float3(2, planner.max_jerk.y * MINUNITMULT); + Draw_Edit_Float3(3, planner.max_jerk.z * MINUNITMULT); #if HAS_HOTEND - Draw_Edit_Float3(4, planner.max_jerk[E_AXIS] * MINUNITMULT); + Draw_Edit_Float3(4, planner.max_jerk.e * MINUNITMULT); #endif } #endif diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 285013d7504e..0f78e58ef5d7 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -80,6 +80,13 @@ #include "../../../feature/powerloss.h" #endif +#if HAS_TRINAMIC_CONFIG + #include "../../../module/stepper/trinamic.h" + + #define TMC_MIN_CURRENT 400 + #define TMC_MAX_CURRENT 1500 +#endif + #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #define DWIN_FONT_MENU font8x16 @@ -204,6 +211,55 @@ bool probe_deployed = false; CrealityDWINClass CrealityDWIN; +template +class TextScroller { +public: + static const unsigned SIZE = N; + static const unsigned SPACE = S; + typedef char Buffer[SIZE + 1]; + + inline TextScroller() + : scrollpos(0) + { } + + inline void reset() { + scrollpos = 0; + } + + const char* scroll(size_t& pos, Buffer &buf, const char * text, bool *updated = nullptr) { + const size_t len = strlen(text); + if (len > SIZE) { + if (updated) *updated = true; + if (scrollpos >= len + SPACE) scrollpos = 0; + pos = 0; + if (scrollpos < len) { + const size_t n = min(len - scrollpos, SIZE); + memcpy(buf, text + scrollpos, n); + pos += n; + } + if (pos < SIZE) { + const size_t n = min(len + SPACE - scrollpos, SIZE - pos); + memset(buf + pos, ' ', n); + pos += n; + } + if (pos < SIZE) { + const size_t n = SIZE - pos; + memcpy(buf + pos, text, n); + pos += n; + } + buf[pos] = '\0'; + ++scrollpos; + return buf; + } else { + pos = len; + return text; + } + } + +private: + uint16_t scrollpos; +}; + #if HAS_MESH struct Mesh_Settings { @@ -684,36 +740,18 @@ void CrealityDWINClass::Draw_Print_Screen() { Update_Status_Bar(true); Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); - TERN_(USE_M73_REMAINING_TIME, Draw_Print_ProgressRemain()); + TERN_(SET_REMAINING_TIME, Draw_Print_ProgressRemain()); Draw_Print_Filename(true); } void CrealityDWINClass::Draw_Print_Filename(const bool reset/*=false*/) { - static uint8_t namescrl = 0; - if (reset) namescrl = 0; + typedef TextScroller<30> Scroller; + static Scroller scroller; + if (reset) scroller.reset(); if (process == Print) { - constexpr int8_t maxlen = 30; - char *outstr = filename; - size_t slen = strlen(filename); - int8_t outlen = slen; - if (slen > maxlen) { - char dispname[maxlen + 1]; - int8_t pos = slen - namescrl, len = maxlen; - if (pos >= 0) { - NOMORE(len, pos); - LOOP_L_N(i, len) dispname[i] = filename[i + namescrl]; - } - else { - const int8_t mp = maxlen + pos; - LOOP_L_N(i, mp) dispname[i] = ' '; - LOOP_S_L_N(i, mp, maxlen) dispname[i] = filename[i - mp]; - if (mp <= 0) namescrl = 0; - } - dispname[len] = '\0'; - outstr = dispname; - outlen = maxlen; - namescrl++; - } + Scroller::Buffer buf; + size_t outlen = 0; + const char* outstr = scroller.scroll(outlen, buf, filename); DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80); const int8_t npos = (DWIN_WIDTH - outlen * MENU_CHR_W) / 2; DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, outstr); @@ -728,7 +766,7 @@ void CrealityDWINClass::Draw_Print_ProgressBar() { DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 133, 133, F("%")); } -#if ENABLED(USE_M73_REMAINING_TIME) +#if ENABLED(SET_REMAINING_TIME) void CrealityDWINClass::Draw_Print_ProgressRemain() { uint16_t remainingtime = ui.get_remaining_time(); @@ -973,57 +1011,30 @@ void CrealityDWINClass::Popup_Select() { } void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { + typedef TextScroller<30> Scroller; static bool new_msg; - static uint8_t msgscrl = 0; + static Scroller scroller; static char lastmsg[64]; if (strcmp(lastmsg, statusmsg) != 0 || refresh) { strcpy(lastmsg, statusmsg); - msgscrl = 0; + scroller.reset(); new_msg = true; } - size_t len = strlen(statusmsg); - int8_t pos = len; - if (pos > 30) { - pos -= msgscrl; - len = pos; - if (len > 30) - len = 30; - char dispmsg[len + 1]; - if (pos >= 0) { - LOOP_L_N(i, len) dispmsg[i] = statusmsg[i + msgscrl]; - } - else { - LOOP_L_N(i, 30 + pos) dispmsg[i] = ' '; - LOOP_S_L_N(i, 30 + pos, 30) dispmsg[i] = statusmsg[i - (30 + pos)]; - } - dispmsg[len] = '\0'; + Scroller::Buffer buf; + size_t len = 0; + const char* dispmsg = scroller.scroll(len, buf, statusmsg, &new_msg); + if (new_msg) { + new_msg = false; if (process == Print) { DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238); - const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2; + const int8_t npos = (DWIN_WIDTH - len * MENU_CHR_W) / 2; DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, dispmsg); } else { DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); - const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2; + const int8_t npos = (DWIN_WIDTH - len * MENU_CHR_W) / 2; DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, dispmsg); } - if (-pos >= 30) msgscrl = 0; - msgscrl++; - } - else { - if (new_msg) { - new_msg = false; - if (process == Print) { - DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238); - const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, statusmsg); - } - else { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); - const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, statusmsg); - } - } } } @@ -1202,7 +1213,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1345,7 +1356,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(ETemp); } else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); Redraw_Menu(); @@ -1732,7 +1743,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1751,7 +1762,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(ETemp); } else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1769,7 +1780,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -2136,7 +2147,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case HOTENDPID_KP: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kp Value")); - Draw_Float(thermalManager.temp_hotend[0].pid.Kp, row, false, 100); + Draw_Float(thermalManager.temp_hotend[0].pid.p(), row, false, 100); } else Modify_Value(thermalManager.temp_hotend[0].pid.Kp, 0, 5000, 100, thermalManager.updatePID); @@ -2144,7 +2155,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case HOTENDPID_KI: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Ki Value")); - Draw_Float(unscalePID_i(thermalManager.temp_hotend[0].pid.Ki), row, false, 100); + Draw_Float(thermalManager.temp_hotend[0].pid.i(), row, false, 100); } else Modify_Value(thermalManager.temp_hotend[0].pid.Ki, 0, 5000, 100, thermalManager.updatePID); @@ -2152,7 +2163,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case HOTENDPID_KD: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kd Value")); - Draw_Float(unscalePID_d(thermalManager.temp_hotend[0].pid.Kd), row, false, 100); + Draw_Float(thermalManager.temp_hotend[0].pid.d(), row, false, 100); } else Modify_Value(thermalManager.temp_hotend[0].pid.Kd, 0, 5000, 100, thermalManager.updatePID); @@ -2203,7 +2214,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case BEDPID_KP: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kp Value")); - Draw_Float(thermalManager.temp_bed.pid.Kp, row, false, 100); + Draw_Float(thermalManager.temp_bed.pid.p(), row, false, 100); } else { Modify_Value(thermalManager.temp_bed.pid.Kp, 0, 5000, 100, thermalManager.updatePID); @@ -2212,7 +2223,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case BEDPID_KI: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Ki Value")); - Draw_Float(unscalePID_i(thermalManager.temp_bed.pid.Ki), row, false, 100); + Draw_Float(thermalManager.temp_bed.pid.i(), row, false, 100); } else Modify_Value(thermalManager.temp_bed.pid.Ki, 0, 5000, 100, thermalManager.updatePID); @@ -2220,7 +2231,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case BEDPID_KD: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kd Value")); - Draw_Float(unscalePID_d(thermalManager.temp_bed.pid.Kd), row, false, 100); + Draw_Float(thermalManager.temp_bed.pid.d(), row, false, 100); } else Modify_Value(thermalManager.temp_bed.pid.Kd, 0, 5000, 100, thermalManager.updatePID); @@ -2291,7 +2302,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Float(planner.flow_percentage[0], row, false, 1); } else - Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1); + Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1, []{ planner.refresh_e_factor(0); }); break; #endif } @@ -2461,35 +2472,35 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case JERK_X: if (draw) { Draw_Menu_Item(row, ICON_MaxSpeedJerkX, F("X Axis")); - Draw_Float(planner.max_jerk[X_AXIS], row, false, 10); + Draw_Float(planner.max_jerk.x, row, false, 10); } else - Modify_Value(planner.max_jerk[X_AXIS], 0, default_max_jerk[X_AXIS] * 2, 10); + Modify_Value(planner.max_jerk.x, 0, default_max_jerk[X_AXIS] * 2, 10); break; case JERK_Y: if (draw) { Draw_Menu_Item(row, ICON_MaxSpeedJerkY, F("Y Axis")); - Draw_Float(planner.max_jerk[Y_AXIS], row, false, 10); + Draw_Float(planner.max_jerk.y, row, false, 10); } else - Modify_Value(planner.max_jerk[Y_AXIS], 0, default_max_jerk[Y_AXIS] * 2, 10); + Modify_Value(planner.max_jerk.y, 0, default_max_jerk[Y_AXIS] * 2, 10); break; case JERK_Z: if (draw) { Draw_Menu_Item(row, ICON_MaxSpeedJerkZ, F("Z Axis")); - Draw_Float(planner.max_jerk[Z_AXIS], row, false, 10); + Draw_Float(planner.max_jerk.z, row, false, 10); } else - Modify_Value(planner.max_jerk[Z_AXIS], 0, default_max_jerk[Z_AXIS] * 2, 10); + Modify_Value(planner.max_jerk.z, 0, default_max_jerk[Z_AXIS] * 2, 10); break; #if HAS_HOTEND case JERK_E: if (draw) { Draw_Menu_Item(row, ICON_MaxSpeedJerkE, F("Extruder")); - Draw_Float(planner.max_jerk[E_AXIS], row, false, 10); + Draw_Float(planner.max_jerk.e, row, false, 10); } else - Modify_Value(planner.max_jerk[E_AXIS], 0, default_max_jerk[E_AXIS] * 2, 10); + Modify_Value(planner.max_jerk.e, 0, default_max_jerk[E_AXIS] * 2, 10); break; #endif } @@ -2716,7 +2727,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define ADVANCED_BACK 0 #define ADVANCED_BEEPER (ADVANCED_BACK + ENABLED(SOUND_MENU_ITEM)) #define ADVANCED_PROBE (ADVANCED_BEEPER + ENABLED(HAS_BED_PROBE)) - #define ADVANCED_CORNER (ADVANCED_PROBE + 1) + #define ADVANCED_TMC (ADVANCED_PROBE + ENABLED(HAS_TRINAMIC_CONFIG)) + #define ADVANCED_CORNER (ADVANCED_TMC + 1) #define ADVANCED_LA (ADVANCED_CORNER + ENABLED(LIN_ADVANCE)) #define ADVANCED_LOAD (ADVANCED_LA + ENABLED(ADVANCED_PAUSE_FEATURE)) #define ADVANCED_UNLOAD (ADVANCED_LOAD + ENABLED(ADVANCED_PAUSE_FEATURE)) @@ -2756,6 +2768,15 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; #endif + #if HAS_TRINAMIC_CONFIG + case ADVANCED_TMC: + if (draw) + Draw_Menu_Item(row, ICON_Motion, F("TMC Drivers"), nullptr, true); + else + Draw_Menu(TMCMenu); + break; + #endif + case ADVANCED_CORNER: if (draw) { Draw_Menu_Item(row, ICON_MaxAccelerated, F("Bed Screw Inset")); @@ -2768,7 +2789,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(LIN_ADVANCE) case ADVANCED_LA: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccelerated, F("Lin Advance Kp")); + Draw_Menu_Item(row, ICON_MaxAccelerated, F("Lin Advance K")); Draw_Float(planner.extruder_advance_K[0], row, false, 100); } else @@ -2901,7 +2922,93 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; } break; - #endif + #endif // HAS_PROBE_MENU + + #if HAS_TRINAMIC_CONFIG + case TMCMenu: + + #define TMC_BACK 0 + #define TMC_STEPPER_CURRENT_X (TMC_BACK + AXIS_IS_TMC(X)) + #define TMC_STEPPER_CURRENT_Y (TMC_STEPPER_CURRENT_X + AXIS_IS_TMC(Y)) + #define TMC_STEPPER_CURRENT_Z (TMC_STEPPER_CURRENT_Y + AXIS_IS_TMC(Z)) + #define TMC_STEPPER_CURRENT_E (TMC_STEPPER_CURRENT_Z + AXIS_IS_TMC(E0)) + #define TMC_TOTAL TMC_STEPPER_CURRENT_E + + switch (item) { + + case TMC_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, F("Back")); + else + Draw_Menu(Advanced, ADVANCED_TMC); + break; + + #if AXIS_IS_TMC(X) + case TMC_STEPPER_CURRENT_X: + + static float stepper_current_x; + + if (draw) { + Draw_Menu_Item(row, ICON_StepX, F("Stepper X current")); + stepper_current_x = stepperX.getMilliamps(); + Draw_Float(stepper_current_x, row, false, 1); + } + else { + Modify_Value(stepper_current_x, TMC_MIN_CURRENT, TMC_MAX_CURRENT, 1, []{ stepperX.rms_current(stepper_current_x); }); + } + break; + #endif + + #if AXIS_IS_TMC(Y) + case TMC_STEPPER_CURRENT_Y: + + static float stepper_current_y; + + if (draw) { + Draw_Menu_Item(row, ICON_StepY, F("Stepper Y current")); + stepper_current_y = stepperY.getMilliamps(); + Draw_Float(stepper_current_y, row, false, 1); + } + else { + Modify_Value(stepper_current_y, TMC_MIN_CURRENT, TMC_MAX_CURRENT, 1, []{ stepperY.rms_current(stepper_current_y); }); + } + break; + #endif + + #if AXIS_IS_TMC(Z) + case TMC_STEPPER_CURRENT_Z: + + static float stepper_current_z; + + if (draw) { + Draw_Menu_Item(row, ICON_StepZ, F("Stepper Z current")); + stepper_current_z = stepperZ.getMilliamps(); + Draw_Float(stepper_current_z, row, false, 1); + } + else { + Modify_Value(stepper_current_z, TMC_MIN_CURRENT, TMC_MAX_CURRENT, 1, []{ stepperZ.rms_current(stepper_current_z); }); + } + break; + #endif + + #if AXIS_IS_TMC(E0) + case TMC_STEPPER_CURRENT_E: + + static float stepper_current_e; + + if (draw) { + Draw_Menu_Item(row, ICON_StepE, F("Stepper E current")); + stepper_current_e = stepperE0.getMilliamps(); + Draw_Float(stepper_current_e, row, false, 1); + } + else { + Modify_Value(stepper_current_e, TMC_MIN_CURRENT, TMC_MAX_CURRENT, 1, []{ stepperE0.rms_current(stepper_current_e); }); + } + break; + #endif + }; + break; + #endif // HAS_TRINAMIC_CONFIG case InfoMain: case Info: @@ -3633,7 +3740,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Float(planner.flow_percentage[0], row, false, 1); } else - Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1); + Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1, []{ planner.refresh_e_factor(0); }); break; case TUNE_HOTEND: if (draw) { @@ -3875,7 +3982,10 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { case Visual: return F("Visual Settings"); case Advanced: return F("Advanced Settings"); #if HAS_BED_PROBE - case ProbeMenu: return F("Probe Menu"); + case ProbeMenu: return F("Bed Probe"); + #endif + #if HAS_TRINAMIC_CONFIG + case TMCMenu: return F("TMC Drivers"); #endif case ColorSettings: return F("UI Color Settings"); case Info: return F("Info"); @@ -3945,6 +4055,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { #if HAS_BED_PROBE case ProbeMenu: return PROBE_TOTAL; #endif + #if HAS_TRINAMIC_CONFIG + case TMCMenu: return TMC_TOTAL; + #endif case Info: return INFO_TOTAL; case InfoMain: return INFO_TOTAL; #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE @@ -4113,8 +4226,6 @@ void CrealityDWINClass::Value_Control() { case LevelManual: mesh_conf.manual_mesh_move(selection == LEVELING_M_OFFSET); break; #endif } - if (valuepointer == &planner.flow_percentage[0]) - planner.refresh_e_factor(0); if (funcpointer) funcpointer(); return; } @@ -4168,35 +4279,25 @@ void CrealityDWINClass::Option_Control() { } void CrealityDWINClass::File_Control() { + typedef TextScroller Scroller; + static Scroller scroller; EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - static uint8_t filescrl = 0; if (encoder_diffState == ENCODER_DIFF_NO) { if (selection > 0) { card.getfilename_sorted(SD_ORDER(selection - 1, card.get_num_Files())); char * const filename = card.longest_filename(); size_t len = strlen(filename); - int8_t pos = len; + size_t pos = len; if (!card.flag.filenameIsDir) while (pos && filename[pos] != '.') pos--; if (pos > MENU_CHAR_LIMIT) { static millis_t time = 0; if (PENDING(millis(), time)) return; time = millis() + 200; - pos -= filescrl; - len = _MIN(pos, MENU_CHAR_LIMIT); - char name[len + 1]; - if (pos >= 0) { - LOOP_L_N(i, len) name[i] = filename[i + filescrl]; - } - else { - LOOP_L_N(i, MENU_CHAR_LIMIT + pos) name[i] = ' '; - LOOP_S_L_N(i, MENU_CHAR_LIMIT + pos, MENU_CHAR_LIMIT) name[i] = filename[i - (MENU_CHAR_LIMIT + pos)]; - } - name[len] = '\0'; + Scroller::Buffer buf; + const char* const name = scroller.scroll(pos, buf, filename); DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_Menu_Item(selection - scrollpos, card.flag.filenameIsDir ? ICON_More : ICON_File, name); - if (-pos >= MENU_CHAR_LIMIT) filescrl = 0; - filescrl++; DWIN_UpdateLCD(); } } @@ -4208,7 +4309,7 @@ void CrealityDWINClass::File_Control() { DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_SD_Item(selection, selection - scrollpos); } - filescrl = 0; + scroller.reset(); selection++; // Select Down if (selection > scrollpos + MROWS) { scrollpos++; @@ -4221,7 +4322,7 @@ void CrealityDWINClass::File_Control() { DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_SD_Item(selection, selection - scrollpos); - filescrl = 0; + scroller.reset(); selection--; // Select Up if (selection < scrollpos) { scrollpos--; @@ -4404,7 +4505,7 @@ void CrealityDWINClass::Popup_Control() { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -4571,8 +4672,8 @@ void CrealityDWINClass::Start_Print(bool sd) { } else strcpy_P(filename, PSTR("Host Print")); - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0)); - TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); + TERN_(SET_PROGRESS_PERCENT, ui.set_progress(0)); + TERN_(SET_REMAINING_TIME, ui.set_remaining_time(0)); Draw_Print_Screen(); } } @@ -4581,8 +4682,8 @@ void CrealityDWINClass::Stop_Print() { printing = false; sdprint = false; thermalManager.cooldown(); - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(100 * (PROGRESS_SCALE))); - TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); + TERN_(SET_PROGRESS_PERCENT, ui.set_progress(100 * (PROGRESS_SCALE))); + TERN_(SET_REMAINING_TIME, ui.set_remaining_time(0)); Draw_Print_confirm(); } @@ -4659,7 +4760,7 @@ void CrealityDWINClass::Screen_Update() { if (process == Print) { Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); - TERN_(USE_M73_REMAINING_TIME, Draw_Print_ProgressRemain()); + TERN_(SET_REMAINING_TIME, Draw_Print_ProgressRemain()); } } diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.h b/Marlin/src/lcd/e3v2/jyersui/dwin.h index 8985647cd131..f360819df53c 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.h +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.h @@ -75,6 +75,9 @@ enum menuID : uint8_t { ColorSettings, Advanced, ProbeMenu, + #if HAS_TRINAMIC_CONFIG + TMCMenu, + #endif Info, Leveling, LevelManual, @@ -188,7 +191,7 @@ class CrealityDWINClass { static void Draw_Print_Screen(); static void Draw_Print_Filename(const bool reset=false); static void Draw_Print_ProgressBar(); - #if ENABLED(USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) static void Draw_Print_ProgressRemain(); #endif static void Draw_Print_ProgressElapsed(); diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index ab21c7be4a9c..560b30be0ad9 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -213,7 +213,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(status_message); // Fill the rest with spaces - while (slen < max_status_chars) { lcd_put_lchar(' '); ++slen; } + while (slen < max_status_chars) { lcd_put_u8str(F(" ")); ++slen; } } } else { @@ -227,10 +227,10 @@ void MarlinUI::draw_status_message(const bool blink) { // If the string doesn't completely fill the line... if (rlen < max_status_chars) { - lcd_put_lchar('.'); // Always at 1+ spaces left, draw a dot + lcd_put_u8str(F(".")); // Always at 1+ spaces left, draw a dot uint8_t chars = max_status_chars - rlen; // Amount of space left in characters if (--chars) { // Draw a second dot if there's space - lcd_put_lchar('.'); + lcd_put_u8str(F(".")); if (--chars) lcd_put_u8str_max(status_message, chars); // Print a second copy of the message } @@ -254,7 +254,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, max_status_chars); // Fill the rest with spaces if there are missing spaces - while (slen < max_status_chars) { lcd_put_lchar(' '); ++slen; } + while (slen < max_status_chars) { lcd_put_u8str(F(" ")); ++slen; } } #endif diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 8024085ef734..205913ca694a 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -315,7 +315,7 @@ void MarlinUI::draw_status_screen() { // Draw a frame around the x/y/z values DWIN_Draw_Rectangle(0, Select_Color, #if ENABLED(DWIN_MARLINUI_PORTRAIT) - 0, 193, LCD_PIXEL_WIDTH, 260 + 0, 193, LCD_PIXEL_WIDTH - 1, 260 #else 0, 115, LCD_PIXEL_WIDTH - 1, 152 #endif @@ -366,6 +366,8 @@ void MarlinUI::draw_status_screen() { ); } + // TODO! + // // Elapsed time // @@ -374,11 +376,11 @@ void MarlinUI::draw_status_screen() { #if ENABLED(DWIN_MARLINUI_PORTRAIT) - // Portrait mode only shows one value at a time, and will rotate if ROTATE_PROGRESS_DISPLAY + // Portrait mode only shows one value at a time, and will rotate if many are enabled dwin_string.set(); char prefix = ' '; #if ENABLED(SHOW_REMAINING_TIME) - if (TERN1(ROTATE_PROGRESS_DISPLAY, blink) && print_job_timer.isRunning()) { + if (blink && print_job_timer.isRunning()) { time = get_remaining_time(); prefix = 'R'; } @@ -447,13 +449,13 @@ void MarlinUI::draw_status_screen() { //if (pb_solid < old_solid) DWIN_Draw_Rectangle(1, Color_Bg_Black, pb_left + 1 + pb_solid, pb_top + 1, pb_right - 1, pb_bottom - 1); // Erase the rest - #if ENABLED(SHOW_SD_PERCENT) + #if ENABLED(SHOW_PROGRESS_PERCENT) dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); dwin_string.add('%'); DWIN_Draw_String( false, font16x32, Percent_Color, Color_Bg_Black, pb_left + (pb_width - dwin_string.length * 16) / 2, - pb_top + (pb_height - 32) / 2, + pb_top + (pb_height - 32) / 2 - 1, S(dwin_string.string()) ); #endif diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp index e967c26198be..760582c76a75 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp @@ -23,23 +23,33 @@ /** * Bed Level Tools for Pro UI * Extended by: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.0.0 - * Date: 2022/05/23 + * Version: 2.1.0 + * Date: 2022/08/27 * * Based on the original work of: Henri-J-Norden * https://github.com/Jyers/Marlin/pull/126 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * */ #include "../../../inc/MarlinConfigPre.h" -#include "bedlevel_tools.h" #if BOTH(DWIN_LCD_PROUI, HAS_LEVELING) #include "../../marlinui.h" #include "../../../core/types.h" -#include "dwin.h" -#include "dwinui.h" -#include "dwin_popup.h" #include "../../../feature/bedlevel/bedlevel.h" #include "../../../module/probe.h" #include "../../../gcode/gcode.h" @@ -48,9 +58,14 @@ #include "../../../libs/least_squares_fit.h" #include "../../../libs/vector_3.h" -BedLevelToolsClass BedLevelTools; +#include "dwin.h" +#include "dwinui.h" +#include "dwin_popup.h" +#include "bedlevel_tools.h" + +BedLevelToolsClass bedLevelTools; -#if USE_UBL_VIEWER +#if ENABLED(USE_UBL_VIEWER) bool BedLevelToolsClass::viewer_asymmetric_range = false; bool BedLevelToolsClass::viewer_print_value = false; #endif @@ -153,26 +168,30 @@ void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, } } +// Move / Probe methods. As examples, not yet used. void BedLevelToolsClass::MoveToXYZ() { - BedLevelTools.goto_mesh_value = true; - BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false); + bedLevelTools.goto_mesh_value = true; + bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, false); } void BedLevelToolsClass::MoveToXY() { - BedLevelTools.goto_mesh_value = false; - BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false); + bedLevelTools.goto_mesh_value = false; + bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, false); } void BedLevelToolsClass::MoveToZ() { - BedLevelTools.goto_mesh_value = true; - BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, true); + bedLevelTools.goto_mesh_value = true; + bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, true); } void BedLevelToolsClass::ProbeXY() { - sprintf_P(cmd, PSTR("G30X%sY%s"), - dtostrf(bedlevel.get_mesh_x(BedLevelTools.mesh_x), 1, 2, str_1), - dtostrf(bedlevel.get_mesh_y(BedLevelTools.mesh_y), 1, 2, str_2) + const uint16_t Clear = Z_CLEARANCE_DEPLOY_PROBE; + sprintf_P(cmd, PSTR("G0Z%i\nG30X%sY%s"), + Clear, + dtostrf(bedlevel.get_mesh_x(bedLevelTools.mesh_x), 1, 2, str_1), + dtostrf(bedlevel.get_mesh_y(bedLevelTools.mesh_y), 1, 2, str_2) ); gcode.process_subcommands_now(cmd); } +// Accessors float BedLevelToolsClass::get_max_value() { float max = __FLT_MAX__ * -1; GRID_LOOP(x, y) { @@ -191,18 +210,16 @@ float BedLevelToolsClass::get_min_value() { return min; } +// Return 'true' if mesh is good and within LCD limits bool BedLevelToolsClass::meshvalidate() { - float min = __FLT_MAX__, max = __FLT_MAX__ * -1; - GRID_LOOP(x, y) { - if (isnan(bedlevel.z_values[x][y])) return false; - if (bedlevel.z_values[x][y] < min) min = bedlevel.z_values[x][y]; - if (bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y]; + const float v = bedlevel.z_values[x][y]; + if (isnan(v) || !WITHIN(v, UBL_Z_OFFSET_MIN, UBL_Z_OFFSET_MAX)) return false; } - return WITHIN(max, MESH_Z_OFFSET_MIN, MESH_Z_OFFSET_MAX); + return true; } -#if USE_UBL_VIEWER +#if ENABLED(USE_UBL_VIEWER) void BedLevelToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) { drawing_mesh = true; diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h index 9373d593f969..6e642f030c18 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h @@ -23,27 +23,38 @@ /** * Bed Level Tools for Pro UI * Extended by: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.0.0 - * Date: 2022/05/23 + * Version: 2.1.0 + * Date: 2022/08/27 * * Based on the original work of: Henri-J-Norden * https://github.com/Jyers/Marlin/pull/126 + * + * 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" -#if ENABLED(AUTO_BED_LEVELING_UBL) - //#define USE_UBL_VIEWER 1 -#endif +//#define USE_UBL_VIEWER 1 -#define MESH_Z_OFFSET_MIN -3.0 -#define MESH_Z_OFFSET_MAX 3.0 +#define UBL_Z_OFFSET_MIN -3.0 +#define UBL_Z_OFFSET_MAX 3.0 class BedLevelToolsClass { public: - #if USE_UBL_VIEWER + #if ENABLED(USE_UBL_VIEWER) static bool viewer_asymmetric_range; static bool viewer_print_value; #endif @@ -66,12 +77,10 @@ class BedLevelToolsClass { static float get_max_value(); static float get_min_value(); static bool meshvalidate(); - #if USE_UBL_VIEWER + #if ENABLED(USE_UBL_VIEWER) static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7); static void Set_Mesh_Viewer_Status(); #endif }; -extern BedLevelToolsClass BedLevelTools; - -void Goto_MeshViewer(); +extern BedLevelToolsClass bedLevelTools; diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index f51da4cf5a71..098db27b1b87 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -23,8 +23,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.2 - * Date: 2022/04/08 + * Version: 3.21.2 + * Date: 2022/12/02 */ #include "../../../inc/MarlinConfig.h" @@ -43,8 +43,8 @@ #if DISABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) #warning "INDIVIDUAL_AXIS_HOMING_SUBMENU is recommended with ProUI." #endif -#if DISABLED(LCD_SET_PROGRESS_MANUALLY) - #warning "LCD_SET_PROGRESS_MANUALLY is recommended with ProUI." +#if DISABLED(SET_PROGRESS_MANUALLY) + #warning "SET_PROGRESS_MANUALLY is recommended with ProUI." #endif #if DISABLED(STATUS_MESSAGE_SCROLLING) #warning "STATUS_MESSAGE_SCROLLING is recommended with ProUI." @@ -62,10 +62,6 @@ #warning "MESH_EDIT_MENU is recommended with ProUI." #endif -#include "dwin.h" -#include "menus.h" -#include "dwin_popup.h" - #include "../../fontutils.h" #include "../../marlinui.h" @@ -78,6 +74,7 @@ #include "../../../module/temperature.h" #include "../../../module/printcounter.h" #include "../../../module/motion.h" +#include "../../../module/stepper.h" #include "../../../module/planner.h" #include "../../../gcode/gcode.h" @@ -112,60 +109,60 @@ #include "../../../feature/bltouch.h" #endif -#if EITHER(BABYSTEPPING, HAS_BED_PROBE) - #define HAS_ZOFFSET_ITEM 1 - #if ENABLED(BABYSTEPPING) - #include "../../../feature/babystep.h" - #if !HAS_BED_PROBE - #define JUST_BABYSTEP 1 - #endif - #endif +#if ENABLED(BABYSTEPPING) + #include "../../../feature/babystep.h" #endif #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../feature/powerloss.h" #endif -#if HAS_ESDIAG - #include "endstop_diag.h" +#if ENABLED(PRINTCOUNTER) + #include "printstats.h" #endif -#if HAS_PIDPLOT - #include "plot.h" +#if ENABLED(CASE_LIGHT_MENU) + #include "../../../feature/caselight.h" #endif -#if HAS_GCODE_PREVIEW - #include "gcode_preview.h" +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" #endif -#if HAS_MESH - #include "meshviewer.h" +#include "dwin.h" +#include "dwinui.h" +#include "menus.h" +#include "dwin_popup.h" + +#if HAS_GCODE_PREVIEW + #include "gcode_preview.h" #endif -#if ENABLED(PRINTCOUNTER) - #include "printstats.h" +#if HAS_ESDIAG + #include "endstop_diag.h" #endif -#if ENABLED(CASE_LIGHT_MENU) - #include "../../../feature/caselight.h" +#if HAS_PIDPLOT + #include "plot.h" #endif -#if ENABLED(LED_CONTROL_MENU) - #include "../../../feature/leds/leds.h" +#if HAS_MESH + #include "meshviewer.h" #endif #if HAS_LOCKSCREEN #include "lockscreen.h" #endif +#define DEBUG_OUT ENABLED(DEBUG_DWIN) +#include "../../../core/debug_out.h" + #ifndef MACHINE_SIZE #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #endif #define PAUSE_HEAT -#define MENU_CHAR_LIMIT 24 - // Print speed limit #define MIN_PRINT_SPEED 10 #define MAX_PRINT_SPEED 999 @@ -186,18 +183,16 @@ // Editable temperature limits #define MIN_ETEMP 0 -#define MAX_ETEMP (HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT)) +#define MAX_ETEMP (thermalManager.hotend_maxtemp[0] - (HOTEND_OVERSHOOT)) #define MIN_BEDTEMP 0 #define MAX_BEDTEMP BED_MAX_TARGET -#define FEEDRATE_E (60) - #define DWIN_VAR_UPDATE_INTERVAL 1024 -#define DWIN_SCROLL_UPDATE_INTERVAL SEC_TO_MS(2) +#define DWIN_UPDATE_INTERVAL 1024 #define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20) -#if HAS_MESH - #define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, HMI_data.ManualZOffset) +#if HAS_MESH && HAS_BED_PROBE + #define BABY_Z_VAR probe.offset.z #else float z_offset = 0; #define BABY_Z_VAR z_offset @@ -208,10 +203,6 @@ HMI_value_t HMI_value; HMI_flag_t HMI_flag{0}; HMI_data_t HMI_data; -millis_t dwin_heat_time = 0; - -uint8_t checkkey = 255, last_checkkey = MainMenu; - enum SelectItem : uint8_t { PAGE_PRINT = 0, PAGE_PREPARE, @@ -233,11 +224,7 @@ typedef struct { bool dec() { if (now) now--; return changed(); } bool inc(uint8_t v) { if (now < (v - 1)) now++; else now = (v - 1); return changed(); } } select_t; - -select_t select_page{0}, select_file{0}, select_print{0}; -uint8_t index_file = MROWS; - -bool hash_changed = true; // Flag to know if message status was changed +select_t select_page{0}, select_print{0}; constexpr float max_feedrate_edit_values[] = #ifdef MAX_FEEDRATE_EDIT_VALUES @@ -265,17 +252,21 @@ constexpr float max_acceleration_edit_values[] = ; #endif -static uint8_t _percent_done = 0; -static uint32_t _remain_time = 0; - -// Additional Aux Host Support -static bool sdprint = false; - #if HAS_HOTEND float last_E = 0; + #define E_MIN_POS (last_E - (EXTRUDE_MAXLENGTH)) + #define E_MAX_POS (last_E + (EXTRUDE_MAXLENGTH)) #endif +bool hash_changed = true; // Flag to know if message status was changed +uint8_t _percent_done = 0; +uint32_t _remain_time = 0; +bool blink = false; +millis_t dwin_heat_time = 0; +uint8_t checkkey = 255, last_checkkey = MainMenu; + // New menu system pointers +MenuClass *FileMenu = nullptr; MenuClass *PrepareMenu = nullptr; MenuClass *TrammingMenu = nullptr; MenuClass *MoveMenu = nullptr; @@ -306,8 +297,12 @@ MenuClass *MaxAccelMenu = nullptr; MenuClass *MaxJerkMenu = nullptr; #endif MenuClass *StepsMenu = nullptr; -MenuClass *HotendPIDMenu = nullptr; -MenuClass *BedPIDMenu = nullptr; +#if ENABLED(PIDTEMP) + MenuClass *HotendPIDMenu = nullptr; +#endif +#if ENABLED(PIDTEMPBED) + MenuClass *BedPIDMenu = nullptr; +#endif #if ENABLED(CASELIGHT_USES_BRIGHTNESS) MenuClass *CaseLightMenu = nullptr; #endif @@ -337,6 +332,10 @@ MenuItemClass *FanSpeedItem = nullptr; MenuItemClass *MMeshMoveZItem = nullptr; MenuItemClass *EditZValueItem = nullptr; +bool Printing() { return printingIsActive() || printingIsPaused(); } +bool SD_Printing() { return Printing() && IS_SD_FILE_OPEN(); } +bool Host_Printing() { return Printing() && !IS_SD_FILE_OPEN(); } + #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 @@ -368,7 +367,7 @@ void HMI_ToggleLanguage() { typedef struct { uint16_t x, y[2], w, h; } text_info_t; void ICON_Button(const bool selected, const int iconid, const frame_rect_t &ico, const text_info_t (&txt), FSTR_P caption) { - DWIN_ICON_Show(true, false, false, ICON, iconid + selected, ico.x, ico.y); + DWINUI::Draw_IconWB(iconid + selected, ico.x, ico.y); if (selected) DWINUI::Draw_Box(0, HMI_data.Highlight_Color, ico); if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, txt.x, txt.y[selected], txt.x + txt.w - 1, txt.y[selected] + txt.h - 1, ico.x + (ico.w - txt.w) / 2, (ico.y + ico.h - 25) - txt.h/2); @@ -452,47 +451,9 @@ void ICON_Stop() { ICON_Button(select_print.now == PRINT_STOP, ICON_Stop_0, ico, txt, GET_TEXT_F(MSG_BUTTON_STOP)); } -//----------------------------------------------------------------------------- -// Drawing routines -//----------------------------------------------------------------------------- - -void Move_Highlight(const int8_t from, const int8_t newline) { - Erase_Menu_Cursor(newline - from); - Draw_Menu_Cursor(newline); -} - -void Add_Menu_Line() { - Move_Highlight(1, MROWS); - DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(MROWS + 1), 240); -} - -void Scroll_Menu(const uint8_t dir) { - DWIN_Frame_AreaMove(1, dir, MLINE, HMI_data.Background_Color, 0, 31, DWIN_WIDTH, 349); - switch (dir) { - case DWIN_SCROLL_DOWN: Move_Highlight(-1, 0); break; - case DWIN_SCROLL_UP: Add_Menu_Line(); break; - } -} - -inline uint16_t nr_sd_menu_items() { - return card.get_num_Files() + !card.flag.workDirIsRoot; -} - -void Erase_Menu_Text(const uint8_t line) { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); -} - -// Draw "Back" line at the top -void Draw_Back_First(const bool is_sel=true) { - Draw_Menu_Line(0, ICON_Back); - if (HMI_IsChinese()) - DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); - else - DWINUI::Draw_String(LBLX, MBASE(0), GET_TEXT_F(MSG_BACK)); - if (is_sel) Draw_Menu_Cursor(0); -} - +// //PopUps +// void Popup_window_PauseOrStop() { if (HMI_IsChinese()) { DWINUI::ClearMainArea(); @@ -546,15 +507,19 @@ void Popup_window_PauseOrStop() { DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } } - else DWIN_Show_Popup(toohigh ? ICON_TempTooHigh : ICON_TempTooLow, F("Nozzle or Bed temperature"), toohigh ? F("is too high") : F("is too low"), BTN_Continue); + else + DWIN_Show_Popup(toohigh ? ICON_TempTooHigh : ICON_TempTooLow, F("Nozzle or Bed temperature"), toohigh ? F("is too high") : F("is too low"), BTN_Continue); } #endif +// // Draw status line -void DWIN_DrawStatusLine() { +// +void DWIN_DrawStatusLine(const char *text) { DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, ui.status_message); + if (text) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, text); } +void DWIN_DrawStatusLine(FSTR_P fstr) { DWIN_DrawStatusLine(FTOP(fstr)); } // Clear & reset status line void DWIN_ResetStatusLine() { @@ -563,12 +528,16 @@ void DWIN_ResetStatusLine() { } // Djb2 hash algorithm -void DWIN_CheckStatusMessage() { - static uint32_t old_hash = 0; - char * str = &ui.status_message[0]; +uint32_t GetHash(char * str) { uint32_t hash = 5381; char c; while ((c = *str++)) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + return hash; +} + +void DWIN_CheckStatusMessage() { + static uint32_t old_hash = 0; + uint32_t hash = GetHash(&ui.status_message[0]); hash_changed = hash != old_hash; old_hash = hash; }; @@ -582,7 +551,7 @@ void DWIN_DrawStatusMessage() { // If the string fits the status line do not scroll it if (slen <= LCD_WIDTH) { if (hash_changed) { - DWIN_DrawStatusLine(); + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } } @@ -601,7 +570,7 @@ void DWIN_DrawStatusMessage() { if (rlen < LCD_WIDTH) { DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); // Always at 1+ spaces left, draw a dot uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters - if (--chars) { // Draw a second dot if there's space + if (--chars) { // Draw a second dot if there's space DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); if (--chars) DWINUI::Draw_String(HMI_data.StatusTxt_Color, ui.status_message, chars); // Print a second copy of the message @@ -614,7 +583,7 @@ void DWIN_DrawStatusMessage() { if (hash_changed) { ui.status_message[LCD_WIDTH] = 0; - DWIN_DrawStatusLine(); + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } @@ -633,7 +602,7 @@ void Draw_Print_Labels() { } void Draw_Print_ProgressBar() { - DWIN_ICON_Show(true, false, false, ICON, ICON_Bar, 15, 93); + DWINUI::Draw_IconWB(ICON_Bar, 15, 93); DWIN_Draw_Rectangle(1, HMI_data.Barfill_Color, 16 + _percent_done * 240 / 100, 93, 256, 113); DWINUI::Draw_Int(HMI_data.PercentTxt_Color, HMI_data.Background_Color, 3, 117, 133, _percent_done); DWINUI::Draw_String(HMI_data.PercentTxt_Color, 142, 133, F("%")); @@ -657,7 +626,7 @@ void ICON_ResumeOrPause() { } // Update filename on print -void DWIN_Print_Header(const char *text=nullptr) { +void DWIN_Print_Header(const char *text = nullptr) { static char headertxt[31] = ""; // Print header text if (text) { const int8_t size = _MIN(30U, strlen_P(text)); @@ -676,7 +645,7 @@ void Draw_PrintProcess() { else Title.ShowCaption(GET_TEXT_F(MSG_PRINTING)); DWINUI::ClearMainArea(); - DWIN_Print_Header(sdprint ? card.longest_filename() : nullptr); + DWIN_Print_Header(SD_Printing() ? card.longest_filename() : nullptr); Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); @@ -707,11 +676,14 @@ void Draw_PrintDone() { Title.ShowCaption(GET_TEXT_F(MSG_PRINT_DONE)); DWINUI::ClearMainArea(); DWIN_Print_Header(nullptr); - if (sdprint && TERN0(HAS_GCODE_PREVIEW, Preview_Valid())) { - DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00); - DWINUI::Draw_Button(BTN_Continue, 86, 300); - } - else { + #if HAS_GCODE_PREVIEW + if (Preview_Valid()) { + DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00); + DWINUI::Draw_Button(BTN_Continue, 86, 300); + } + else + #endif + { Draw_Print_ProgressBar(); Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); @@ -738,7 +710,6 @@ void Draw_Main_Menu() { else Title.ShowCaption(MACHINE_NAME); DWINUI::Draw_Icon(ICON_LOGO, 71, 52); // CREALITY logo - DWIN_ResetStatusLine(); ICON_Print(); ICON_Prepare(); ICON_Control(); @@ -753,13 +724,19 @@ void Goto_Main_Menu() { } // Draw X, Y, Z and blink if in an un-homed or un-trusted state -void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool blink, const bool force) { +void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool force) { const bool draw_qmark = axis_should_home(axis), draw_empty = NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !draw_qmark && !axis_is_trusted(axis); // Check for a position change static xyz_pos_t oldpos = { -1, -1, -1 }; - const float p = current_position[axis]; + + #if ENABLED(SHOW_REAL_POS) + const float p = stepper.position(axis) / planner.settings.axis_steps_per_mm[axis]; + #else + const float p = current_position[axis]; + #endif + const bool changed = oldpos[axis] != p; if (changed) oldpos[axis] = p; @@ -773,18 +750,38 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, } } +void _draw_ZOffsetIcon() { + #if HAS_LEVELING + #if NO_BLINK_LEV_IND + static bool _leveling_active = false; + if (_leveling_active != planner.leveling_active) { + _leveling_active = planner.leveling_active; + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 186, 415, 205, 436); + DWINUI::Draw_Icon(_leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); + } + #else + if (planner.leveling_active) { + DWIN_Draw_Rectangle(1, blink ? HMI_data.SplitLine_Color : HMI_data.Background_Color, 186, 415, 205, 436); + DWINUI::Draw_Icon(ICON_SetZOffset, 186, 416); + } + static bool _leveling_active = false; + if (_leveling_active != planner.leveling_active) { + _leveling_active = planner.leveling_active; + if (!_leveling_active) { + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 186, 415, 205, 436); + DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); + } + } + #endif + #else + DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); + #endif +} + void _draw_xyz_position(const bool force) { - //SERIAL_ECHOPGM("Draw XYZ:"); - static bool _blink = false; - const bool blink = !!(millis() & 0x400UL); - if (force || blink != _blink) { - _blink = blink; - //SERIAL_ECHOPGM(" (blink)"); - _update_axis_value(X_AXIS, 27, 459, blink, true); - _update_axis_value(Y_AXIS, 112, 459, blink, true); - _update_axis_value(Z_AXIS, 197, 459, blink, true); - } - //SERIAL_EOL(); + _update_axis_value(X_AXIS, 27, 459, force); + _update_axis_value(Y_AXIS, 112, 459, force); + _update_axis_value(Z_AXIS, 197, 459, force); } void update_variable() { @@ -812,7 +809,7 @@ void update_variable() { if (_new_fanspeed) _fanspeed = thermalManager.fan_speed[0]; #endif - if (checkkey == Menu && (CurrentMenu == TuneMenu || CurrentMenu == TemperatureMenu)) { + if (IsMenu(TuneMenu) || IsMenu(TemperatureMenu)) { // Tune page temperature update #if HAS_HOTEND if (_new_hotend_target) HotendTargetItem->redraw(); @@ -866,34 +863,23 @@ void update_variable() { DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, _offset); } - #if HAS_MESH - static bool _leveling_active = false; - if (_leveling_active != planner.leveling_active) { - _leveling_active = planner.leveling_active; - DWIN_Draw_Box(1, HMI_data.Background_Color, 186, 416, 20, 20); - if (_leveling_active) - DWINUI::Draw_Icon(ICON_SetZOffset, 186, 416); - else - DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); - } - #else - DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); - #endif - + _draw_ZOffsetIcon(); _draw_xyz_position(false); } /** - * Read and cache the working directory. - * - * TODO: New code can follow the pattern of menu_media.cpp - * and rely on Marlin caching for performance. No need to - * cache files here. + * Memory card and file management */ -#ifndef strcasecmp_P - #define strcasecmp_P(a, b) strcasecmp((a), (b)) -#endif +bool DWIN_lcd_sd_status = false; + +void SetMediaAutoMount() { + Toogle_Chkb_Line(HMI_data.MediaAutoMount); +} + +inline uint16_t nr_sd_menu_items() { + return _MIN(card.get_num_Files() + !card.flag.workDirIsRoot, MENU_MAX_ITEMS); +} void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) { size_t pos = strlen(src); // index of ending nul @@ -919,117 +905,121 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) while (pos--) dst[pos] = src[pos]; } -void HMI_SDCardInit() { card.cdroot(); } - -#if ENABLED(SCROLL_LONG_FILENAMES) - - char shift_name[LONG_FILENAME_LENGTH + 1]; - int8_t shift_amt; // = 0 - millis_t shift_ms; // = 0 - - // Init the shift name based on the highlighted item - void Init_Shift_Name() { - const bool is_subdir = !card.flag.workDirIsRoot; - const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".." - const uint16_t fileCnt = card.get_num_Files(); - if (WITHIN(filenum, 0, fileCnt - 1)) { - card.getfilename_sorted(SD_ORDER(filenum, fileCnt)); - char * const name = card.longest_filename(); - make_name_without_ext(shift_name, name, 100); - } - } - - void Init_SDItem_Shift() { - shift_amt = 0; - shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT ? millis() + 750UL : 0; - } +void Redraw_SD_List() { + InvalidateMenu(); + Draw_Print_File_Menu(); +} -#endif +void SDCard_Up() { + card.cdup(); + DWIN_lcd_sd_status = false; // On next DWIN_Update +} -/** - * Display an SD item, adding a CDUP for subfolders. - */ -void Draw_SDItem(const uint16_t item, int16_t row=-1) { - if (row < 0) row = item + 1 + MROWS - index_file; - const bool is_subdir = !card.flag.workDirIsRoot; - if (is_subdir && item == 0) - return Draw_Menu_Line(row, ICON_Folder, ".."); +void SDCard_Folder(char * const dirname) { + card.cd(dirname); + DWIN_lcd_sd_status = false; // On next DWIN_Update +} - card.getfilename_sorted(SD_ORDER(item - is_subdir, card.get_num_Files())); - char * const name = card.longest_filename(); +void onClickSDItem() { + const uint16_t hasUpDir = !card.flag.workDirIsRoot; + if (hasUpDir && CurrentMenu->selected == 1) return SDCard_Up(); + else { + const uint16_t filenum = CurrentMenu->selected - 1 - hasUpDir; + card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files())); - #if ENABLED(SCROLL_LONG_FILENAMES) - // Init the current selected name - // This is used during scroll drawing - if (item == select_file.now - 1) { - make_name_without_ext(shift_name, name, 100); - Init_SDItem_Shift(); - } - #endif + // Enter that folder! + if (card.flag.filenameIsDir) return SDCard_Folder(card.filename); - // Draw the file/folder with name aligned left - char str[strlen(name) + 1]; - make_name_without_ext(str, name); - const uint8_t icon = card.flag.filenameIsDir ? ICON_Folder : card.fileIsBinary() ? ICON_Binary : ICON_File; - Draw_Menu_Line(row, icon, str); + if (card.fileIsBinary()) + return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); + else + return Goto_ConfirmToPrint(); + } } #if ENABLED(SCROLL_LONG_FILENAMES) + char shift_name[LONG_FILENAME_LENGTH + 1] = ""; void Draw_SDItem_Shifted(uint8_t &shift) { - // Limit to the number of chars past the cutoff - const size_t len = strlen(shift_name); - NOMORE(shift, _MAX(len - MENU_CHAR_LIMIT, 0U)); - // Shorten to the available space - const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT); - + const size_t lastchar = shift + MENU_CHAR_LIMIT; const char c = shift_name[lastchar]; shift_name[lastchar] = '\0'; - const uint8_t row = select_file.now + MROWS - index_file; // skip "Back" and scroll + const uint8_t row = FileMenu->line(); Erase_Menu_Text(row); Draw_Menu_Line(row, 0, &shift_name[shift]); shift_name[lastchar] = c; } + void FileMenuIdle(bool reset=false) { + static bool hasUpDir = false; + static uint8_t last_itemselected = 0; + static int8_t shift_amt = 0; + static int8_t shift_len = 0; + if (reset) { + last_itemselected = 0; + hasUpDir = !card.flag.workDirIsRoot; // is a SubDir + return; + } + const uint8_t selected = FileMenu->selected; + if (last_itemselected != selected) { + if (last_itemselected >= 1 + hasUpDir) FileMenu->Items()[last_itemselected]->redraw(true); + last_itemselected = selected; + if (selected >= 1 + hasUpDir) { + const int8_t filenum = selected - 1 - hasUpDir; // Skip "Back" and ".." + card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files())); + make_name_without_ext(shift_name, card.longest_filename(), LONG_FILENAME_LENGTH); + shift_len = strlen(shift_name); + shift_amt = 0; + } + } + else if ((selected >= 1 + hasUpDir) && (shift_len > MENU_CHAR_LIMIT)) { + uint8_t shift_new = _MIN(shift_amt + 1, shift_len - MENU_CHAR_LIMIT); // Try to shift by... + Draw_SDItem_Shifted(shift_new); // Draw the item + if (shift_new == shift_amt) // Scroll reached the end + shift_new = -1; // Reset + shift_amt = shift_new; // Set new scroll + } + } +#else + char shift_name[FILENAME_LENGTH + 1] = ""; #endif -// Redraw the first set of SD Files -void Redraw_SD_List() { - select_file.reset(); - index_file = MROWS; - - DWINUI::ClearMainArea(); // Leave title bar unchanged - - Draw_Back_First(); +void onDrawFileName(MenuItemClass* menuitem, int8_t line) { + const bool is_subdir = !card.flag.workDirIsRoot; + if (is_subdir && menuitem->pos == 1) { + Draw_Menu_Line(line, ICON_Folder, ".."); + } + else { + uint8_t icon; + card.getfilename_sorted(SD_ORDER(menuitem->pos - is_subdir - 1, card.get_num_Files())); + make_name_without_ext(shift_name, card.longest_filename()); + icon = card.flag.filenameIsDir ? ICON_Folder : card.fileIsBinary() ? ICON_Binary : ICON_File; + Draw_Menu_Line(line, icon, shift_name); + } +} +void Draw_Print_File_Menu() { + checkkey = Menu; if (card.isMounted()) { - // As many files as will fit - LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS)) - Draw_SDItem(i, i + 1); - - TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); + if (SET_MENU(FileMenu, MSG_MEDIA_MENU, nr_sd_menu_items() + 1)) { + BACK_ITEM(Goto_Main_Menu); + LOOP_L_N(i, nr_sd_menu_items()) { + MenuItemAdd(onDrawFileName, onClickSDItem); + } + } + UpdateMenu(FileMenu); + TERN_(DASH_REDRAW, DWIN_RedrawDash()); } else { + if (SET_MENU(FileMenu, MSG_MEDIA_MENU, 1)) BACK_ITEM(Goto_Main_Menu); + UpdateMenu(FileMenu); DWIN_Draw_Rectangle(1, HMI_data.AlertBg_Color, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); DWINUI::Draw_CenteredString(font12x24, HMI_data.AlertTxt_Color, MBASE(3), GET_TEXT_F(MSG_MEDIA_NOT_INSERTED)); } -} - -bool DWIN_lcd_sd_status = false; - -void SDCard_Up() { - card.cdup(); - Redraw_SD_List(); - DWIN_lcd_sd_status = false; // On next DWIN_Update -} - -void SDCard_Folder(char * const dirname) { - card.cd(dirname); - Redraw_SD_List(); - DWIN_lcd_sd_status = false; // On next DWIN_Update + TERN_(SCROLL_LONG_FILENAMES, FileMenuIdle(true)); } // @@ -1039,29 +1029,16 @@ void HMI_SDCardUpdate() { if (HMI_flag.home_flag) return; if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); - //SERIAL_ECHOLNPGM("HMI_SDCardUpdate: ", DWIN_lcd_sd_status); - if (DWIN_lcd_sd_status) { // Media inserted - if (checkkey == SelectFile) - Redraw_SD_List(); - } - else { // Media removed - // clean file icon - if (checkkey == SelectFile) { - Redraw_SD_List(); - } - else if (sdprint && card.isPrinting() && printingIsActive()) { - wait_for_heatup = wait_for_user = false; - HMI_flag.abort_flag = true; // Abort print - } - } + if (IsMenu(FileMenu)) Redraw_SD_List(); + if (!DWIN_lcd_sd_status && SD_Printing()) ui.abort_print(); // Media removed while printing DWIN_UpdateLCD(); } } -// -// The Dashboard is always on-screen, except during -// full-screen modal dialogs. -// +/** + * Dash board and indicators + */ + void DWIN_Draw_Dashboard() { DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, STATUS_Y + 21, DWIN_WIDTH, DWIN_HEIGHT - 1); @@ -1110,11 +1087,11 @@ void DWIN_Draw_Dashboard() { void Draw_Info_Menu() { DWINUI::ClearMainArea(); - Draw_Back_First(); if (HMI_IsChinese()) Title.FrameCopy(30, 17, 28, 13); // "Info" else Title.ShowCaption(GET_TEXT_F(MSG_INFO_SCREEN)); + Draw_Menu_Line(0, ICON_Back, GET_TEXT_F(MSG_BACK), false, true); if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102); // "Size" @@ -1137,15 +1114,6 @@ void Draw_Info_Menu() { } } -void Draw_Print_File_Menu() { - if (HMI_IsChinese()) - Title.FrameCopy(0, 31, 56, 14); // "Print file" - else - Title.ShowCaption(GET_TEXT_F(MSG_MEDIA_MENU)); - Redraw_SD_List(); - TERN_(DASH_REDRAW, DWIN_RedrawDash()); -} - // Main Process void HMI_MainMenu() { EncoderState encoder_diffState = get_encoder_state(); @@ -1174,9 +1142,10 @@ void HMI_MainMenu() { else if (encoder_diffState == ENCODER_DIFF_ENTER) { switch (select_page.now) { case PAGE_PRINT: - checkkey = SelectFile; - card.mount(); - safe_delay(300); + if (HMI_data.MediaAutoMount) { + card.mount(); + safe_delay(800); + }; Draw_Print_File_Menu(); break; case PAGE_PREPARE: Draw_Prepare_Menu(); break; @@ -1187,125 +1156,11 @@ void HMI_MainMenu() { DWIN_UpdateLCD(); } -// Select (and Print) File -void HMI_SelectFile() { - EncoderState encoder_diffState = get_encoder_state(); - - const uint16_t hasUpDir = !card.flag.workDirIsRoot; - - if (encoder_diffState == ENCODER_DIFF_NO) { - #if ENABLED(SCROLL_LONG_FILENAMES) - if (shift_ms && select_file.now >= 1 + hasUpDir) { - // Scroll selected filename every second - const millis_t ms = millis(); - if (ELAPSED(ms, shift_ms)) { - const bool was_reset = shift_amt < 0; - shift_ms = ms + 375UL + was_reset * 250UL; // ms per character - uint8_t shift_new = shift_amt + 1; // Try to shift by... - Draw_SDItem_Shifted(shift_new); // Draw the item - if (!was_reset && shift_new == 0) // Was it limited to 0? - shift_ms = 0; // No scrolling needed - else if (shift_new == shift_amt) // Scroll reached the end - shift_new = -1; // Reset - shift_amt = shift_new; // Set new scroll - } - } - #endif - return; - } - - // First pause is long. Easy. - // On reset, long pause must be after 0. - - const uint16_t fullCnt = nr_sd_menu_items(); - - if (encoder_diffState == ENCODER_DIFF_CW && fullCnt) { - if (select_file.inc(1 + fullCnt)) { - const uint8_t itemnum = select_file.now - 1; // -1 for "Back" - if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted - Erase_Menu_Text(itemnum + MROWS - index_file); // Erase and - Draw_SDItem(itemnum - 1); // redraw - } - if (select_file.now > MROWS && select_file.now > index_file) { // Cursor past the bottom - index_file = select_file.now; // New bottom line - Scroll_Menu(DWIN_SCROLL_UP); - Draw_SDItem(itemnum, MROWS); // Draw and init the shift name - } - else { - Move_Highlight(1, select_file.now + MROWS - index_file); // Just move highlight - TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name - } - TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); - } - } - else if (encoder_diffState == ENCODER_DIFF_CCW && fullCnt) { - if (select_file.dec()) { - const uint8_t itemnum = select_file.now - 1; // -1 for "Back" - if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted - Erase_Menu_Text(select_file.now + 1 + MROWS - index_file); // Erase and - Draw_SDItem(itemnum + 1); // redraw - } - if (select_file.now < index_file - MROWS) { // Cursor past the top - index_file--; // New bottom line - Scroll_Menu(DWIN_SCROLL_DOWN); - if (index_file == MROWS) { - Draw_Back_First(); - TERN_(SCROLL_LONG_FILENAMES, shift_ms = 0); - } - else { - Draw_SDItem(itemnum, 0); // Draw the item (and init shift name) - } - } - else { - Move_Highlight(-1, select_file.now + MROWS - index_file); // Just move highlight - TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name - } - TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); // Reset left. Init timer. - } - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (select_file.now == 0) { // Back - select_page.set(PAGE_PRINT); - return Goto_Main_Menu(); - } - else if (hasUpDir && select_file.now == 1) { // CD-Up - SDCard_Up(); - goto HMI_SelectFileExit; - } - else { - const uint16_t filenum = select_file.now - 1 - hasUpDir; - card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files())); - - // Enter that folder! - if (card.flag.filenameIsDir) { - SDCard_Folder(card.filename); - goto HMI_SelectFileExit; - } - - // Reset highlight for next entry - select_print.reset(); - select_file.reset(); - - // Start choice and print SD file - HMI_flag.heat_flag = true; - HMI_flag.print_finish = false; - - if (card.fileIsBinary()) - return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); - else - return Goto_ConfirmToPrint(); - } - } - - HMI_SelectFileExit: - DWIN_UpdateLCD(); -} - // Pause or Stop popup void onClick_PauseOrStop() { switch (select_print.now) { - case PRINT_PAUSE_RESUME: if (HMI_flag.select_flag) HMI_flag.pause_flag = true; break; // confirm pause - case PRINT_STOP: if (HMI_flag.select_flag) HMI_flag.abort_flag = true; break; // stop confirmed then abort print + case PRINT_PAUSE_RESUME: if (HMI_flag.select_flag) ui.pause_print(); break; // confirm pause + case PRINT_STOP: if (HMI_flag.select_flag) ui.abort_print(); break; // stop confirmed then abort print default: break; } return Goto_PrintProcess(); @@ -1357,7 +1212,6 @@ void HMI_Printing() { void Draw_Main_Area() { switch (checkkey) { case MainMenu: Draw_Main_Menu(); break; - case SelectFile: Draw_Print_File_Menu(); break; case PrintProcess: Draw_PrintProcess(); break; case PrintDone: Draw_PrintDone(); break; #if HAS_ESDIAG @@ -1384,27 +1238,35 @@ void HMI_ReturnScreen() { } void HMI_WaitForUser() { - get_encoder_state(); + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState != ENCODER_DIFF_NO && !ui.backlight) { + if (checkkey == WaitResponse) HMI_ReturnScreen(); + return ui.refresh_brightness(); + } if (!wait_for_user) { switch (checkkey) { case PrintDone: select_page.reset(); Goto_Main_Menu(); break; - TERN_(HAS_ONESTEP_LEVELING, case Leveling:) - default: HMI_ReturnScreen(); break; + #if HAS_BED_PROBE + case Leveling: + #endif + default: + HMI_ReturnScreen(); + break; } } } void HMI_Init() { - DWINUI::Draw_Box(1, Color_Black, {5, 220, DWIN_WIDTH-5, DWINUI::fontHeight()}); + DWINUI::Draw_Box(1, Color_Black, { 5, 220, DWIN_WIDTH - 5, DWINUI::fontHeight() }); DWINUI::Draw_CenteredString(Color_White, 220, F("Professional Firmware ")); - for (uint16_t t = 0; t <= 100; t += 2) { + for (uint16_t t = 15; t <= 257; t += 10) { DWINUI::Draw_Icon(ICON_Bar, 15, 260); - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 15 + t * 242 / 100, 260, 257, 280); + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, t, 260, 257, 280); DWIN_UpdateLCD(); - delay(20); + delay(50); } HMI_SetLanguage(); } @@ -1415,12 +1277,13 @@ void EachMomentUpdate() { if (ELAPSED(ms, next_var_update_ms)) { next_var_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL; + blink = !blink; update_variable(); #if HAS_ESDIAG if (checkkey == ESDiagProcess) ESDiag.Update(); #endif #if HAS_PIDPLOT - if (checkkey == PidProcess) Plot.Update((HMI_value.pidresult == PID_EXTR_START) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); + if (checkkey == PidProcess) Plot.Update((HMI_value.pidresult == PIDTEMP_START) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); #endif } @@ -1433,73 +1296,73 @@ void EachMomentUpdate() { if (ELAPSED(ms, next_status_update_ms)) { next_status_update_ms = ms + 500; DWIN_DrawStatusMessage(); + #if ENABLED(SCROLL_LONG_FILENAMES) + if (IsMenu(FileMenu)) FileMenuIdle(); + #endif } - if (PENDING(ms, next_rts_update_ms)) return; - next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL; - - if (checkkey == PrintProcess) { // print process + if (!PENDING(ms, next_rts_update_ms)) { + next_rts_update_ms = ms + DWIN_UPDATE_INTERVAL; - // Print pause - if (HMI_flag.pause_flag && !HMI_flag.home_flag) { - HMI_flag.pause_flag = false; - if (!HMI_flag.pause_action) { - HMI_flag.pause_action = true; - return ui.pause_print(); - } + if ((Printing() != HMI_flag.printing_flag) && !HMI_flag.home_flag) { + HMI_flag.printing_flag = Printing(); + DEBUG_ECHOLNPGM("printing_flag: ", HMI_flag.printing_flag); + if (HMI_flag.printing_flag) + DWIN_Print_Started(); + else if (HMI_flag.abort_flag) + DWIN_Print_Aborted(); + else + DWIN_Print_Finished(); } - // if print done - if (HMI_flag.print_finish && !HMI_flag.home_flag) { - HMI_flag.print_finish = false; - return DWIN_Print_Finished(); + if ((printingIsPaused() != HMI_flag.pause_flag) && !HMI_flag.home_flag) { + HMI_flag.pause_flag = printingIsPaused(); + DEBUG_ECHOLNPGM("pause_flag: ", HMI_flag.pause_flag); + if (HMI_flag.pause_flag) + DWIN_Print_Pause(); + else if (HMI_flag.abort_flag) + DWIN_Print_Aborted(); + else + DWIN_Print_Resume(); } - // if print was aborted - if (HMI_flag.abort_flag && !HMI_flag.home_flag) { // Print Stop - HMI_flag.abort_flag = false; - if (!HMI_flag.abort_action) { - HMI_flag.abort_action = true; - ui.abort_print(); - return Goto_PrintDone(); - } - } + if (checkkey == PrintProcess) { // print process - duration_t elapsed = print_job_timer.duration(); // print timer + duration_t elapsed = print_job_timer.duration(); // print timer - if (sdprint && card.isPrinting() && !HMI_flag.percent_flag) { - uint8_t percentDone = card.percentDone(); - if (_percent_done != percentDone) { // print percent - _percent_done = percentDone; - Draw_Print_ProgressBar(); + if (card.isPrinting() && !HMI_flag.percent_flag) { + uint8_t percentDone = card.percentDone(); + if (_percent_done != percentDone) { // print percent + _percent_done = percentDone; + Draw_Print_ProgressBar(); } - // Estimate remaining time every 20 seconds - static millis_t next_remain_time_update = 0; - if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag && !HMI_flag.remain_flag) { - _remain_time = (elapsed.value - dwin_heat_time) / (_percent_done * 0.01f) - (elapsed.value - dwin_heat_time); - next_remain_time_update += DWIN_REMAIN_TIME_UPDATE_INTERVAL; - Draw_Print_ProgressRemain(); + // Estimate remaining time every 20 seconds + static millis_t next_remain_time_update = 0; + if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag && !HMI_flag.remain_flag) { + _remain_time = (elapsed.value - dwin_heat_time) / (_percent_done * 0.01f) - (elapsed.value - dwin_heat_time); + next_remain_time_update += DWIN_REMAIN_TIME_UPDATE_INTERVAL; + Draw_Print_ProgressRemain(); + } } - } - // Print time so far - static uint16_t last_Printtime = 0; - const uint16_t min = (elapsed.value % 3600) / 60; - if (last_Printtime != min) { // 1 minute update - last_Printtime = min; - Draw_Print_ProgressElapsed(); - } - - } + // Print time so far + static uint16_t last_Printtime = 0; + const uint16_t min = (elapsed.value % 3600) / 60; + if (last_Printtime != min) { // 1 minute update + last_Printtime = min; + Draw_Print_ProgressElapsed(); + } - #if ENABLED(POWER_LOSS_RECOVERY) - else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off - return Goto_PowerLossRecovery(); } - #endif // POWER_LOSS_RECOVERY + #if ENABLED(POWER_LOSS_RECOVERY) + else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off + return Goto_PowerLossRecovery(); + } + #endif // POWER_LOSS_RECOVERY - DWIN_UpdateLCD(); + DWIN_UpdateLCD(); + } } #if ENABLED(POWER_LOSS_RECOVERY) @@ -1536,8 +1399,6 @@ void EachMomentUpdate() { else { select_print.set(PRINT_SETUP); queue.inject(F("M1000")); - sdprint = true; - return Goto_PrintProcess(); } } @@ -1554,12 +1415,11 @@ void DWIN_HandleScreen() { switch (checkkey) { case MainMenu: HMI_MainMenu(); break; case Menu: HMI_Menu(); break; - case SetInt: HMI_SetInt(); break; + case SetInt: HMI_SetDraw(); break; + case SetFloat: HMI_SetDraw(); break; case SetPInt: HMI_SetPInt(); break; - case SetIntNoDraw: HMI_SetIntNoDraw(); break; - case SetFloat: HMI_SetFloat(); break; case SetPFloat: HMI_SetPFloat(); break; - case SelectFile: HMI_SelectFile(); break; + case SetIntNoDraw: HMI_SetNoDraw(); break; case PrintProcess: HMI_Printing(); break; case Popup: HMI_Popup(); break; case Leveling: break; @@ -1607,15 +1467,11 @@ void DWIN_HomingStart() { void DWIN_HomingDone() { HMI_flag.home_flag = false; - #if ENABLED(MESH_BED_LEVELING) && EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - planner.synchronize(); - babystep.add_mm(Z_AXIS, HMI_data.ManualZOffset); - #endif - if (HMI_flag.abort_action) DWIN_Print_Aborted(); else HMI_ReturnScreen(); + HMI_ReturnScreen(); } void DWIN_LevelingStart() { - #if HAS_ONESTEP_LEVELING + #if HAS_BED_PROBE HMI_SaveProcessID(Leveling); Title.ShowCaption(GET_TEXT_F(MSG_BED_LEVELING)); DWIN_Show_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), GET_TEXT_F(MSG_PLEASE_WAIT)); @@ -1641,10 +1497,10 @@ void DWIN_LevelingDone() { } #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { + void DWIN_MeshUpdate(const int8_t cpos, const int8_t tpos, const_float_t zval) { char msg[33] = ""; char str_1[6] = ""; - sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), xpos, ypos, dtostrf(zval, 1, 2, str_1)); + sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), cpos, tpos, dtostrf(zval, 1, 2, str_1)); ui.set_status(msg); } #endif @@ -1659,96 +1515,102 @@ void DWIN_LevelingDone() { DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_PID_AUTOTUNE)); DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius")); switch (HMI_value.pidresult) { - case PID_EXTR_START: - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running.")); - Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], HMI_data.HotendPidT); - DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.HotendPidT); - break; - case PID_BED_START: - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running.")); - Plot.Draw(gfrm, BED_MAXTEMP, HMI_data.BedPidT); - DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.BedPidT); - break; - default: - break; + #if ENABLED(PIDTEMP) + case PIDTEMP_START: + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running.")); + Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], HMI_data.HotendPidT); + DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.HotendPidT); + break; + #endif + #if ENABLED(PIDTEMPBED) + case PIDTEMPBED_START: + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running.")); + Plot.Draw(gfrm, BED_MAXTEMP, HMI_data.BedPidT); + DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.BedPidT); + break; + #endif + default: break; } } #endif -void DWIN_PidTuning(pidresult_t result) { - HMI_value.pidresult = result; - switch (result) { - case PID_BED_START: - HMI_SaveProcessID(PidProcess); - #if HAS_PIDPLOT - DWIN_Draw_PIDPopup(); - #else - DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running.")); +#if EITHER(PIDTEMP, PIDTEMPBED) + + void DWIN_PidTuning(pidresult_t result) { + HMI_value.pidresult = result; + switch (result) { + #if ENABLED(PIDTEMP) + case PIDTEMP_START: + HMI_SaveProcessID(PidProcess); + #if HAS_PIDPLOT + DWIN_Draw_PIDPopup(); + #else + DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for Nozzle is running.")); + #endif + break; + case PID_BAD_EXTRUDER_NUM: + checkkey = last_checkkey; + DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_BAD_EXTRUDER_NUM)); + break; #endif - break; - case PID_EXTR_START: - HMI_SaveProcessID(PidProcess); - #if HAS_PIDPLOT - DWIN_Draw_PIDPopup(); - #else - DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for Nozzle is running.")); + #if ENABLED(PIDTEMPBED) + case PIDTEMPBED_START: + HMI_SaveProcessID(PidProcess); + #if HAS_PIDPLOT + DWIN_Draw_PIDPopup(); + #else + DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running.")); + #endif + break; #endif - break; - case PID_BAD_EXTRUDER_NUM: - checkkey = last_checkkey; - DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_BAD_EXTRUDER_NUM)); - break; - case PID_TUNING_TIMEOUT: - checkkey = last_checkkey; - DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), GET_TEXT_F(MSG_PID_TIMEOUT)); - break; - case PID_TEMP_TOO_HIGH: - checkkey = last_checkkey; - DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_TEMP_TOO_HIGH)); - break; - case PID_DONE: - checkkey = last_checkkey; - DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE), GET_TEXT_F(MSG_BUTTON_DONE)); - break; - default: - checkkey = last_checkkey; - break; + case PID_TUNING_TIMEOUT: + checkkey = last_checkkey; + DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), GET_TEXT_F(MSG_PID_TIMEOUT)); + break; + case PID_TEMP_TOO_HIGH: + checkkey = last_checkkey; + DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_TEMP_TOO_HIGH)); + break; + case PID_DONE: + checkkey = last_checkkey; + DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE), GET_TEXT_F(MSG_BUTTON_DONE)); + break; + default: checkkey = last_checkkey; break; + } } -} + +#endif // PIDTEMP || PIDTEMPBED // Started a Print Job -void DWIN_Print_Started(const bool sd) { - sdprint = IS_SD_PRINTING() || sd; +void DWIN_Print_Started() { + DEBUG_ECHOLNPGM("DWIN_Print_Started: ", SD_Printing()); + TERN_(HAS_GCODE_PREVIEW, if (Host_Printing()) Preview_Invalidate()); _percent_done = 0; _remain_time = 0; HMI_flag.percent_flag = false; HMI_flag.remain_flag = false; HMI_flag.pause_flag = false; - HMI_flag.pause_action = false; HMI_flag.abort_flag = false; - HMI_flag.abort_action = false; - HMI_flag.print_finish = false; + select_print.reset(); Goto_PrintProcess(); } // Pause a print job void DWIN_Print_Pause() { + DEBUG_ECHOLNPGM("DWIN_Print_Pause"); ICON_ResumeOrPause(); } // Resume print job void DWIN_Print_Resume() { - HMI_flag.pause_action = false; + DEBUG_ECHOLNPGM("DWIN_Print_Resume"); ICON_ResumeOrPause(); - if (printJobOngoing()) { - LCD_MESSAGE(MSG_RESUME_PRINT); - Goto_PrintProcess(); - } + LCD_MESSAGE(MSG_RESUME_PRINT); } // Ended print job void DWIN_Print_Finished() { - if (HMI_flag.abort_flag || checkkey == PrintDone) return; + DEBUG_ECHOLNPGM("DWIN_Print_Finished"); TERN_(POWER_LOSS_RECOVERY, if (card.isPrinting()) recovery.cancel()); HMI_flag.pause_flag = false; wait_for_heatup = false; @@ -1759,12 +1621,8 @@ void DWIN_Print_Finished() { // Print was aborted void DWIN_Print_Aborted() { - TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Print_Aborted")); - HMI_flag.abort_action = false; - wait_for_heatup = false; - planner.finish_and_disable(); - thermalManager.cooldown(); - Goto_PrintDone(); + DEBUG_ECHOLNPGM("DWIN_Print_Aborted"); + DWIN_Print_Finished(); } // Progress and remaining time update @@ -1791,16 +1649,16 @@ void DWIN_M73() { void DWIN_SetColorDefaults() { HMI_data.Background_Color = Def_Background_Color; - HMI_data.Cursor_color = Def_Cursor_color; - HMI_data.TitleBg_color = Def_TitleBg_color; - HMI_data.TitleTxt_color = Def_TitleTxt_color; + HMI_data.Cursor_Color = Def_Cursor_Color; + HMI_data.TitleBg_Color = Def_TitleBg_Color; + HMI_data.TitleTxt_Color = Def_TitleTxt_Color; HMI_data.Text_Color = Def_Text_Color; HMI_data.Selected_Color = Def_Selected_Color; HMI_data.SplitLine_Color = Def_SplitLine_Color; HMI_data.Highlight_Color = Def_Highlight_Color; HMI_data.StatusBg_Color = Def_StatusBg_Color; HMI_data.StatusTxt_Color = Def_StatusTxt_Color; - HMI_data.PopupBg_color = Def_PopupBg_color; + HMI_data.PopupBg_Color = Def_PopupBg_Color; HMI_data.PopupTxt_Color = Def_PopupTxt_Color; HMI_data.AlertBg_Color = Def_AlertBg_Color; HMI_data.AlertTxt_Color = Def_AlertTxt_Color; @@ -1811,19 +1669,23 @@ void DWIN_SetColorDefaults() { } void DWIN_SetDataDefaults() { + DEBUG_ECHOLNPGM("DWIN_SetDataDefaults"); DWIN_SetColorDefaults(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); - TERN_(HAS_HOTEND, HMI_data.HotendPidT = PREHEAT_1_TEMP_HOTEND); - TERN_(HAS_HEATED_BED, HMI_data.BedPidT = PREHEAT_1_TEMP_BED); - TERN_(HAS_HOTEND, HMI_data.PidCycles = 5); + TERN_(PIDTEMP, HMI_data.HotendPidT = DEF_HOTENDPIDT); + TERN_(PIDTEMPBED, HMI_data.BedPidT = DEF_BEDPIDT); + TERN_(HAS_PID_HEATING, HMI_data.PidCycles = DEF_PIDCYCLES); #if ENABLED(PREVENT_COLD_EXTRUSION) HMI_data.ExtMinT = EXTRUDE_MINTEMP; ApplyExtMinT(); #endif - #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) - HMI_data.BedLevT = LEVELING_BED_TEMP; - #endif + TERN_(PREHEAT_BEFORE_LEVELING, HMI_data.BedLevT = LEVELING_BED_TEMP); TERN_(BAUD_RATE_GCODE, SetBaud250K()); + HMI_data.FullManualTramming = false; + HMI_data.MediaAutoMount = ENABLED(HAS_SD_EXTENDER); + #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + HMI_data.z_after_homing = DEF_Z_AFTER_HOMING; + #endif #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) TERN_(LED_COLOR_PRESETS, leds.set_default()); ApplyLEDColor(); @@ -1831,10 +1693,13 @@ void DWIN_SetDataDefaults() { } void DWIN_CopySettingsTo(char * const buff) { + DEBUG_ECHOLNPGM("DWIN_CopySettingsTo"); + DEBUG_ECHOLNPGM("HMI_data: ", sizeof(HMI_data_t)); memcpy(buff, &HMI_data, eeprom_data_size); } void DWIN_CopySettingsFrom(const char * const buff) { + DEBUG_ECHOLNPGM("DWIN_CopySettingsFrom"); memcpy(&HMI_data, buff, sizeof(HMI_data_t)); if (HMI_data.Text_Color == HMI_data.Background_Color) DWIN_SetColorDefaults(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); @@ -1855,22 +1720,25 @@ void DWIN_CopySettingsFrom(const char * const buff) { // Initialize or re-initialize the LCD void MarlinUI::init_lcd() { - TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Startup")); - DWINUI::init(); + DEBUG_ECHOLNPGM("MarlinUI::init_lcd"); + delay(750); // wait to wakeup screen + const bool hs = DWIN_Handshake(); UNUSED(hs); + DEBUG_ECHOPGM("DWIN_Handshake "); + DEBUG_ECHOLNF(hs ? F("ok.") : F("error.")); + DWIN_Frame_SetDir(1); DWIN_JPG_CacheTo1(Language_English); Encoder_Configuration(); } void DWIN_InitScreen() { + DEBUG_ECHOLNPGM("DWIN_InitScreen"); + DWIN_SetColorDefaults(); HMI_Init(); // draws boot screen - onCursorDraw = Draw_Menu_Cursor; - onCursorErase = Erase_Menu_Cursor; + DWINUI::init(); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); DWINUI::onTitleDraw = Draw_Title; - onMenuDraw = Draw_Menu; + InitMenu(); checkkey = 255; - CurrentMenu = nullptr; - PreviousMenu = nullptr; - index_file = MROWS; hash_changed = true; last_E = 0; DWIN_DrawStatusLine(); @@ -1925,12 +1793,12 @@ void DWIN_RedrawScreen() { //if (mode == PAUSE_MODE_SAME) return; pause_mode = mode; switch (message) { - case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 - case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) + case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 + case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), BTN_Continue); break; case PAUSE_MESSAGE_INSERT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT), BTN_Continue); break; case PAUSE_MESSAGE_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; - case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 + case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 case PAUSE_MESSAGE_PURGE: #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE) DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_CONT_PURGE)); @@ -1942,7 +1810,7 @@ void DWIN_RedrawScreen() { case PAUSE_MESSAGE_RESUME: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); break; case PAUSE_MESSAGE_HEAT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), BTN_Continue); break; case PAUSE_MESSAGE_HEATING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEATING)); break; - case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; // Exit from Pause, Load and Unload + case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; // Exit from Pause, Load and Unload default: break; } } @@ -1955,13 +1823,13 @@ void DWIN_RedrawScreen() { } void onClick_FilamentPurge() { - if (HMI_flag.select_flag) - pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // "Purge More" button - else { - HMI_SaveProcessID(NothingToDo); - pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // "Continue" button - } + if (HMI_flag.select_flag) + pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // "Purge More" button + else { + HMI_SaveProcessID(NothingToDo); + pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // "Continue" button } + } void Goto_FilamentPurge() { pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; @@ -2011,15 +1879,14 @@ void DWIN_RedrawScreen() { #if HAS_GCODE_PREVIEW void onClick_ConfirmToPrint() { + Preview_Reset(); + DWIN_ResetStatusLine(); if (HMI_flag.select_flag) { // Confirm - card.openAndPrintFile(card.filename); - return DWIN_Print_Started(true); - } - else { // Cancel - DWIN_ResetStatusLine(); - checkkey = SelectFile; - return Draw_Print_File_Menu(); + HMI_flag.heat_flag = true; + Goto_Main_Menu(); + return card.openAndPrintFile(card.filename); } + else HMI_ReturnScreen(); } void Goto_ConfirmToPrint() { @@ -2028,8 +1895,9 @@ void DWIN_RedrawScreen() { #else void Goto_ConfirmToPrint() { + // Print SD file + HMI_flag.heat_flag = true; card.openAndPrintFile(card.filename); - DWIN_Print_Started(true); } #endif @@ -2048,8 +1916,7 @@ void DWIN_RedrawScreen() { #if ENABLED(EEPROM_SETTINGS) void WriteEeprom() { - ui.set_status(GET_TEXT_F(MSG_STORE_EEPROM)); - DWIN_DrawStatusLine(); + DWIN_DrawStatusLine(GET_TEXT_F(MSG_STORE_EEPROM)); DWIN_UpdateLCD(); DONE_BUZZ(settings.save()); } @@ -2086,13 +1953,6 @@ void Goto_Info_Menu() { HMI_SaveProcessID(WaitResponse); } -void Goto_Move_Menu() { - #if HAS_HOTEND - gcode.process_subcommands_now(F("G92E0")); // reset extruder position - #endif - Draw_Move_Menu(); -} - void DisableMotors() { queue.inject(F("M84")); } void AutoLev() { // Always reacquire the Z "home" position @@ -2100,15 +1960,22 @@ void AutoLev() { // Always reacquire the Z "home" position } void AutoHome() { queue.inject_P(G28_STR); } -void HomeX() { queue.inject(F("G28X")); } -void HomeY() { queue.inject(F("G28Y")); } -void HomeZ() { queue.inject(F("G28Z")); } + +#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + void HomeX() { queue.inject(F("G28X")); } + void HomeY() { queue.inject(F("G28Y")); } + void HomeZ() { queue.inject(F("G28Z")); } + #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + void ApplyZAfterHoming() { HMI_data.z_after_homing = MenuData.Value; }; + void SetZAfterHoming() { SetIntOnClick(0, 20, HMI_data.z_after_homing, ApplyZAfterHoming); } + #endif +#endif #if HAS_HOME_OFFSET // Apply workspace offset, making the current position 0,0,0 void SetHome() { - queue.inject(F("G92X0Y0Z0")); - DONE_BUZZ(true); + queue.inject(F("G92X0Y0Z0")); + DONE_BUZZ(true); } #endif @@ -2119,15 +1986,15 @@ void HomeZ() { queue.inject(F("G28Z")); } #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) const_float_t step_zoffset = round((MenuData.Value / 100.0f) * planner.settings.axis_steps_per_mm[Z_AXIS]) - babystep.accum; if (BABYSTEP_ALLOWED()) babystep.add_steps(Z_AXIS, step_zoffset); + //DEBUG_ECHOLNF(F("BB Steps: "), step_zoffset); #endif } - - #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - void SetZOffset() { + void SetZOffset() { + #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) babystep.accum = round(planner.settings.axis_steps_per_mm[Z_AXIS] * BABY_Z_VAR); - SetPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, ApplyZOffset, LiveZOffset); - } - #endif + #endif + SetPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, ApplyZOffset, LiveZOffset); + } void SetMoveZto0() { #if ENABLED(Z_SAFE_HOMING) @@ -2139,7 +2006,7 @@ void HomeZ() { queue.inject(F("G28Z")); } gcode.process_subcommands_now(cmd); #else TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); - gcode.process_subcommands_now(F("G28O\nG0Z0F300\nM400")); + gcode.process_subcommands_now(F("G28Z\nG0Z0F300\nM400")); #endif ui.reset_status(); DONE_BUZZ(true); @@ -2155,13 +2022,9 @@ void HomeZ() { queue.inject(F("G28Z")); } #endif // HAS_ZOFFSET_ITEM #if HAS_PREHEAT - void DoPreheat0() { ui.preheat_all(0); } - #if PREHEAT_COUNT >= 2 - void DoPreheat1() { ui.preheat_all(1); } - #if PREHEAT_COUNT >= 3 - void DoPreheat2() { ui.preheat_all(2); } - #endif - #endif + #define _DoPreheat(N) void DoPreheat##N() { ui.preheat_all(N-1); }\ + void DoPreheatHotend##N() { ui.preheat_hotend(N-1); } + REPEAT_1(PREHEAT_COUNT, _DoPreheat) #endif void DoCoolDown() { thermalManager.cooldown(); } @@ -2172,56 +2035,55 @@ void SetLanguage() { Draw_Prepare_Menu(); } +bool EnableLiveMove = false; +void SetLiveMove() { Toogle_Chkb_Line(EnableLiveMove); } void LiveMove() { + planner.synchronize(); + if (!EnableLiveMove) return; *MenuData.P_Float = MenuData.Value / MINUNITMULT; - if (!planner.is_full()) { - planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(HMI_value.axis)); - } + if (!planner.is_full()) planner.buffer_line(current_position, manual_feedrate_mm_s[HMI_value.axis]); } -void ApplyMoveE() { - last_E = MenuData.Value / MINUNITMULT; - if (!planner.is_full()) { - planner.synchronize(); - planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E)); - } +void ApplyMove() { + planner.synchronize(); + if (EnableLiveMove) return; + if (HMI_value.axis == E_AXIS) last_E = MenuData.Value / MINUNITMULT; + if (!planner.is_full()) planner.buffer_line(current_position, manual_feedrate_mm_s[HMI_value.axis]); } -void SetMoveX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(X_MIN_POS, X_MAX_POS, UNITFDIGITS, planner.synchronize, LiveMove); } -void SetMoveY() { HMI_value.axis = Y_AXIS; SetPFloatOnClick(Y_MIN_POS, Y_MAX_POS, UNITFDIGITS, planner.synchronize, LiveMove); } -void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS, UNITFDIGITS, planner.synchronize, LiveMove); } + +void SetMoveX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(X_MIN_POS, X_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } +void SetMoveY() { HMI_value.axis = Y_AXIS; SetPFloatOnClick(Y_MIN_POS, Y_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } +void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } #if HAS_HOTEND void SetMoveE() { - #if ENABLED(PREVENT_COLD_EXTRUSION) - if (thermalManager.tooColdToExtrude(0)) - return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); - #endif - SetPFloatOnClick(last_E - (EXTRUDE_MAXLENGTH), last_E + (EXTRUDE_MAXLENGTH), UNITFDIGITS, ApplyMoveE); + if (thermalManager.tooColdToExtrude(0)) return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); + HMI_value.axis = E_AXIS; SetPFloatOnClick(E_MIN_POS, E_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } #endif -void SetPID(celsius_t t, heater_id_t h) { - char cmd[53] = ""; - char str_1[5] = "", str_2[5] = ""; - sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84\nM400"), - dtostrf(X_CENTER, 1, 1, str_1), - dtostrf(Y_CENTER, 1, 1, str_2) - ); - gcode.process_subcommands_now(cmd); - thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); -} -#if HAS_HOTEND - void HotendPID() { SetPID(HMI_data.HotendPidT, H_E0); } -#endif -#if HAS_HEATED_BED - void BedPID() { SetPID(HMI_data.BedPidT, H_BED); } +#if EITHER(PIDTEMP, PIDTEMPBED) + void SetPID(celsius_t t, heater_id_t h) { + char cmd[53] = ""; + char str_1[5] = "", str_2[5] = ""; + sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84\nM400"), + dtostrf(X_CENTER, 1, 1, str_1), + dtostrf(Y_CENTER, 1, 1, str_2) + ); + gcode.process_subcommands_now(cmd); + thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); + } + #if ENABLED(PIDTEMP) + void HotendPID() { SetPID(HMI_data.HotendPidT, H_E0); } + #endif + #if ENABLED(PIDTEMPBED) + void BedPID() { SetPID(HMI_data.BedPidT, H_BED); } + #endif #endif #if ENABLED(POWER_LOSS_RECOVERY) void SetPwrLossr() { - recovery.enable(!recovery.enabled); - Draw_Chkb_Line(CurrentMenu->line(), recovery.enabled); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(recovery.enabled); + recovery.changed(); } #endif @@ -2246,10 +2108,8 @@ void SetPID(celsius_t t, heater_id_t h) { #if ENABLED(CASE_LIGHT_MENU) void SetCaseLight() { - caselight.on = !caselight.on; + Toogle_Chkb_Line(caselight.on); caselight.update_enabled(); - Draw_Chkb_Line(CurrentMenu->line(), caselight.on); - DWIN_UpdateLCD(); } #if ENABLED(CASELIGHT_USES_BRIGHTNESS) void LiveCaseLightBrightness() { caselight.brightness = MenuData.Value; caselight.update_brightness(); } @@ -2261,8 +2121,7 @@ void SetPID(celsius_t t, heater_id_t h) { #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) void SetLedStatus() { leds.toggle(); - Draw_Chkb_Line(CurrentMenu->line(), leds.lights_on); - DWIN_UpdateLCD(); + Show_Chkb_Line(leds.lights_on); } #endif #if HAS_COLOR_LEDS @@ -2285,9 +2144,7 @@ void SetPID(celsius_t t, heater_id_t h) { #if ENABLED(SOUND_MENU_ITEM) void SetEnableSound() { - ui.sound_on = !ui.sound_on; - Draw_Chkb_Line(CurrentMenu->line(), ui.sound_on); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(ui.sound_on); } #endif @@ -2309,11 +2166,9 @@ void SetPID(celsius_t t, heater_id_t h) { void ProbeStow() { probe.stow(); } void ProbeDeploy() { probe.deploy(); } - #ifdef BLTOUCH_HS_MODE + #if ENABLED(BLTOUCH_HS_MODE) void SetHSMode() { - bltouch.high_speed_mode = !bltouch.high_speed_mode; - Draw_Chkb_Line(CurrentMenu->line(), bltouch.high_speed_mode); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(bltouch.high_speed_mode); } #endif @@ -2322,9 +2177,7 @@ void SetPID(celsius_t t, heater_id_t h) { #if HAS_FILAMENT_SENSOR void SetRunoutEnable() { runout.reset(); - runout.enabled = !runout.enabled; - Draw_Chkb_Line(CurrentMenu->line(), runout.enabled); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(runout.enabled); } #if HAS_FILAMENT_RUNOUT_DISTANCE void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } @@ -2342,7 +2195,7 @@ void SetPID(celsius_t t, heater_id_t h) { void SetExtMinT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP, ApplyExtMinT); } #endif -void RestoreDefaultsColors() { +void RestoreDefaultColors() { DWIN_SetColorDefaults(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); DWIN_RedrawScreen(); @@ -2362,7 +2215,7 @@ void LiveRGBColor() { DWIN_Draw_Rectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335); } void SetRGBColor() { - const uint8_t color = CurrentMenu->SelectedItem()->icon; + const uint8_t color = static_cast(CurrentMenu->SelectedItem())->icon; SetIntOnClick(0, (color == 1) ? 63 : 31, HMI_value.Color[color], nullptr, LiveRGBColor); } @@ -2399,10 +2252,12 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } queue.inject(F("M600 B2")); } - void ParkHead() { - LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED); - queue.inject(F("G28O\nG27")); - } + #if ENABLED(NOZZLE_PARK_FEATURE) + void ParkHead() { + LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED); + queue.inject(F("G28O\nG27")); + } + #endif #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) void UnloadFilament() { @@ -2418,8 +2273,7 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } #endif // ADVANCED_PAUSE_FEATURE -void ApplyFlow() { planner.refresh_e_factor(0); } -void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, ApplyFlow); } +void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, []{ planner.refresh_e_factor(0); }); } // Bed Tramming @@ -2522,14 +2376,14 @@ void TramBR() { Tram(2); } void TramBL() { Tram(3); } void TramC () { Tram(4); } -#if HAS_BED_PROBE +#if HAS_BED_PROBE && HAS_MESH void Trammingwizard() { - bed_mesh_t zval = {0}; if (HMI_data.FullManualTramming) { LCD_MESSAGE_F("Disable manual tramming"); return; } + bed_mesh_t zval = {0}; zval[0][0] = Tram(0); checkkey = NothingToDo; MeshViewer.DrawMesh(zval, 2, 2); @@ -2585,12 +2439,10 @@ void TramC () { Tram(4); } } void SetManualTramming() { - HMI_data.FullManualTramming = !HMI_data.FullManualTramming; - Draw_Chkb_Line(CurrentMenu->line(), HMI_data.FullManualTramming); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(HMI_data.FullManualTramming); } -#endif // HAS_BED_PROBE +#endif // HAS_BED_PROBE && HAS_MESH #if ENABLED(MESH_BED_LEVELING) @@ -2607,7 +2459,7 @@ void TramC () { Tram(4); } *MenuData.P_Float = MenuData.Value / POW(10, 2); if (!planner.is_full()) { planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS)); + planner.buffer_line(current_position, manual_feedrate_mm_s[Z_AXIS]); } } void SetMMeshMoveZ() { SetPFloatOnClick(-1, 1, 2, planner.synchronize, LiveMeshMoveZ); } @@ -2654,11 +2506,11 @@ void SetMaxAccelZ() { HMI_value.axis = Z_AXIS, SetIntOnClick(MIN_MAXACCELERATION #if HAS_CLASSIC_JERK void ApplyMaxJerk() { planner.set_max_jerk(HMI_value.axis, MenuData.Value / MINUNITMULT); } - void SetMaxJerkX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[X_AXIS], UNITFDIGITS, planner.max_jerk[X_AXIS], ApplyMaxJerk); } - void SetMaxJerkY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Y_AXIS], UNITFDIGITS, planner.max_jerk[Y_AXIS], ApplyMaxJerk); } - void SetMaxJerkZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Z_AXIS], UNITFDIGITS, planner.max_jerk[Z_AXIS], ApplyMaxJerk); } + void SetMaxJerkX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[X_AXIS], UNITFDIGITS, planner.max_jerk.x, ApplyMaxJerk); } + void SetMaxJerkY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Y_AXIS], UNITFDIGITS, planner.max_jerk.y, ApplyMaxJerk); } + void SetMaxJerkZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Z_AXIS], UNITFDIGITS, planner.max_jerk.z, ApplyMaxJerk); } #if HAS_HOTEND - void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[E_AXIS], UNITFDIGITS, planner.max_jerk[E_AXIS], ApplyMaxJerk); } + void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[E_AXIS], UNITFDIGITS, planner.max_jerk.e, ApplyMaxJerk); } #endif #endif @@ -2667,22 +2519,24 @@ void SetStepsY() { HMI_value.axis = Y_AXIS, SetPFloatOnClick( MIN_STEP, MAX_STEP void SetStepsZ() { HMI_value.axis = Z_AXIS, SetPFloatOnClick( MIN_STEP, MAX_STEP, UNITFDIGITS); } #if HAS_HOTEND void SetStepsE() { HMI_value.axis = E_AXIS; SetPFloatOnClick( MIN_STEP, MAX_STEP, UNITFDIGITS); } - void SetHotendPidT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP); } + #if ENABLED(PIDTEMP) + void SetHotendPidT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP); } + #endif #endif -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) void SetBedPidT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } #endif -#if HAS_HOTEND || HAS_HEATED_BED +#if EITHER(PIDTEMP, PIDTEMPBED) void SetPidCycles() { SetPIntOnClick(3, 50); } void SetKp() { SetPFloatOnClick(0, 1000, 2); } void ApplyPIDi() { *MenuData.P_Float = scalePID_i(MenuData.Value / POW(10, 2)); - thermalManager.updatePID(); + TERN_(PIDTEMP, thermalManager.updatePID()); } void ApplyPIDd() { *MenuData.P_Float = scalePID_d(MenuData.Value / POW(10, 2)); - thermalManager.updatePID(); + TERN_(PIDTEMP, thermalManager.updatePID()); } void SetKi() { MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; @@ -2845,8 +2699,10 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) { } -void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } -void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast(menuitem)->value)); } +#if EITHER(PIDTEMP, PIDTEMPBED) + void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } + void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast(menuitem)->value)); } +#endif void onDrawSpeedItem(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 116, 164, 171, 176); @@ -2905,16 +2761,6 @@ void onDrawSteps(MenuItemClass* menuitem, int8_t line) { onDrawPIntMenu(menuitem, line); } #endif - void onDrawPLAPreheatSubMenu(MenuItemClass* menuitem, int8_t line) { - if (HMI_IsChinese()) menuitem->SetFrame(1, 100, 89, 178, 101); - onDrawSubMenu(menuitem,line); - } - #if PREHEAT_COUNT >= 2 - void onDrawABSPreheatSubMenu(MenuItemClass* menuitem, int8_t line) { - if (HMI_IsChinese()) menuitem->SetFrame(1, 180, 89, 260, 100); - onDrawSubMenu(menuitem,line); - } - #endif #endif // HAS_PREHEAT void onDrawSpeed(MenuItemClass* menuitem, int8_t line) { @@ -3098,161 +2944,145 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) { // Menu Creation and Drawing functions ====================================================== -void SetMenuTitle(frame_rect_t cn, const __FlashStringHelper* fstr) { - if (HMI_IsChinese() && (cn.w != 0)) - CurrentMenu->MenuTitle.SetFrame(cn.x, cn.y, cn.w, cn.h); +frame_rect_t selrect(frame_rect_t) { + if (HMI_IsChinese()) + return {133, 1, 28, 13}; else - CurrentMenu->MenuTitle.SetCaption(fstr); + return{0}; } void Draw_Prepare_Menu() { checkkey = Menu; - if (!PrepareMenu) PrepareMenu = new MenuClass(); - if (CurrentMenu != PrepareMenu) { - CurrentMenu = PrepareMenu; - SetMenuTitle({133, 1, 28, 13}, GET_TEXT_F(MSG_PREPARE)); - MenuItemsPrepare(13); + if (SET_MENU_R(PrepareMenu, selrect({133, 1, 28, 13}), MSG_PREPARE, 10 + PREHEAT_COUNT)) { BACK_ITEM(Goto_Main_Menu); #if ENABLED(ADVANCED_PAUSE_FEATURE) - MENU_ITEM_F(ICON_FilMan, MSG_FILAMENT_MAN, onDrawSubMenu, Draw_FilamentMan_Menu); + MENU_ITEM(ICON_FilMan, MSG_FILAMENT_MAN, onDrawSubMenu, Draw_FilamentMan_Menu); #endif - MENU_ITEM_F(ICON_Axis, MSG_MOVE_AXIS, onDrawMoveSubMenu, Goto_Move_Menu); - MENU_ITEM_F(ICON_Tram, MSG_BED_TRAMMING, onDrawSubMenu, Draw_Tramming_Menu); - MENU_ITEM_F(ICON_CloseMotor, MSG_DISABLE_STEPPERS, onDrawDisableMotors, DisableMotors); + MENU_ITEM(ICON_Axis, MSG_MOVE_AXIS, onDrawMoveSubMenu, Draw_Move_Menu); + MENU_ITEM(ICON_Tram, MSG_BED_TRAMMING, onDrawSubMenu, Draw_Tramming_Menu); + MENU_ITEM(ICON_CloseMotor, MSG_DISABLE_STEPPERS, onDrawDisableMotors, DisableMotors); #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) - MENU_ITEM_F(ICON_Homing, MSG_HOMING, onDrawSubMenu, Draw_Homing_Menu); + MENU_ITEM(ICON_Homing, MSG_HOMING, onDrawSubMenu, Draw_Homing_Menu); #else - MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawAutoHome, AutoHome); + MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawAutoHome, AutoHome); #endif #if ENABLED(MESH_BED_LEVELING) - MENU_ITEM_F(ICON_ManualMesh, MSG_MANUAL_MESH, onDrawSubMenu, Draw_ManualMesh_Menu); - #endif - #if HAS_ONESTEP_LEVELING - MENU_ITEM_F(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); + MENU_ITEM(ICON_ManualMesh, MSG_MANUAL_MESH, onDrawSubMenu, Draw_ManualMesh_Menu); + #elif HAS_BED_PROBE + MENU_ITEM(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); #endif #if HAS_ZOFFSET_ITEM - #if ENABLED(BABYSTEP_ZPROBE_OFFSET) - MENU_ITEM_F(ICON_SetZOffset, MSG_PROBE_WIZARD, onDrawSubMenu, Draw_ZOffsetWiz_Menu); - #elif JUST_BABYSTEP - EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); - #else - MENU_ITEM_F(ICON_SetHome, MSG_SET_HOME_OFFSETS, onDrawHomeOffset, SetHome); + #if HAS_BED_PROBE + MENU_ITEM(ICON_SetZOffset, MSG_PROBE_WIZARD, onDrawSubMenu, Draw_ZOffsetWiz_Menu); + #elif ENABLED(BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, MSG_HOME_OFFSET_Z, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); + #elif HAS_HOME_OFFSET + MENU_ITEM(ICON_SetHome, MSG_SET_HOME_OFFSETS, onDrawHomeOffset, SetHome); #endif #endif #if HAS_PREHEAT - MENU_ITEM_F(ICON_PLAPreheat, MSG_PREHEAT_1, onDrawPreheat1, DoPreheat0); - #if PREHEAT_COUNT > 1 - MENU_ITEM(ICON_ABSPreheat, F("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, DoPreheat1); - #if PREHEAT_COUNT > 2 - MENU_ITEM(ICON_CustomPreheat, F("Preheat " PREHEAT_3_LABEL), onDrawMenuItem, DoPreheat2); - #endif - #endif + #define _ITEM_PREHEAT(N) MENU_ITEM(ICON_Preheat##N, MSG_PREHEAT_##N, onDrawMenuItem, DoPreheat##N); + REPEAT_1(PREHEAT_COUNT, _ITEM_PREHEAT) #endif - MENU_ITEM_F(ICON_Cool, MSG_COOLDOWN, onDrawCooldown, DoCoolDown); - MENU_ITEM_F(ICON_Language, MSG_UI_LANGUAGE, onDrawLanguage, SetLanguage); + MENU_ITEM(ICON_Cool, MSG_COOLDOWN, onDrawCooldown, DoCoolDown); + MENU_ITEM(ICON_Language, MSG_UI_LANGUAGE, onDrawLanguage, SetLanguage); } ui.reset_status(true); - CurrentMenu->draw(); + UpdateMenu(PrepareMenu); } void Draw_Tramming_Menu() { checkkey = Menu; - if (SetMenu(TrammingMenu, GET_TEXT_F(MSG_BED_TRAMMING), 8)) { + if (SET_MENU(TrammingMenu, MSG_BED_TRAMMING, 8)) { BACK_ITEM(Draw_Prepare_Menu); - #if HAS_BED_PROBE - MENU_ITEM_F(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard); - EDIT_ITEM_F(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming); - #else - MENU_ITEM(ICON_MoveZ0, F("Home Z and disable"), onDrawMenuItem, HomeZandDisable); - #endif - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_FL, onDrawMenuItem, TramFL); - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_FR, onDrawMenuItem, TramFR); - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_BR, onDrawMenuItem, TramBR); - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_BL, onDrawMenuItem, TramBL); - MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_C ), onDrawMenuItem, TramC ); + #if HAS_BED_PROBE && HAS_MESH + MENU_ITEM(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard); + EDIT_ITEM(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming); + #elif !HAS_BED_PROBE && HAS_ZOFFSET_ITEM + MENU_ITEM_F(ICON_MoveZ0, "Home Z and disable", onDrawMenuItem, HomeZandDisable); + #endif + MENU_ITEM(ICON_Axis, MSG_LEVBED_FL, onDrawMenuItem, TramFL); + MENU_ITEM(ICON_Axis, MSG_LEVBED_FR, onDrawMenuItem, TramFR); + MENU_ITEM(ICON_Axis, MSG_LEVBED_BR, onDrawMenuItem, TramBR); + MENU_ITEM(ICON_Axis, MSG_LEVBED_BL, onDrawMenuItem, TramBL); + MENU_ITEM(ICON_Axis, MSG_LEVBED_C, onDrawMenuItem, TramC ); } UpdateMenu(TrammingMenu); } void Draw_Control_Menu() { checkkey = Menu; - if (!ControlMenu) ControlMenu = new MenuClass(); - if (CurrentMenu != ControlMenu) { - CurrentMenu = ControlMenu; - SetMenuTitle({103, 1, 28, 14}, GET_TEXT_F(MSG_CONTROL)); - MenuItemsPrepare(10); + if (SET_MENU_R(ControlMenu, selrect({103, 1, 28, 14}), MSG_CONTROL, 10)) { BACK_ITEM(Goto_Main_Menu); - MENU_ITEM_F(ICON_Temperature, MSG_TEMPERATURE, onDrawTempSubMenu, Draw_Temperature_Menu); - MENU_ITEM_F(ICON_Motion, MSG_MOTION, onDrawMotionSubMenu, Draw_Motion_Menu); + MENU_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawTempSubMenu, Draw_Temperature_Menu); + MENU_ITEM(ICON_Motion, MSG_MOTION, onDrawMotionSubMenu, Draw_Motion_Menu); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); - MENU_ITEM_F(ICON_ReadEEPROM, MSG_LOAD_EEPROM, onDrawReadEeprom, ReadEeprom); - MENU_ITEM_F(ICON_ResumeEEPROM, MSG_RESTORE_DEFAULTS, onDrawResetEeprom, ResetEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); + MENU_ITEM(ICON_ReadEEPROM, MSG_LOAD_EEPROM, onDrawReadEeprom, ReadEeprom); + MENU_ITEM(ICON_ResumeEEPROM, MSG_RESTORE_DEFAULTS, onDrawResetEeprom, ResetEeprom); #endif - MENU_ITEM_F(ICON_Reboot, MSG_RESET_PRINTER, onDrawMenuItem, RebootPrinter); + MENU_ITEM(ICON_Reboot, MSG_RESET_PRINTER, onDrawMenuItem, RebootPrinter); #if ENABLED(CASE_LIGHT_MENU) #if ENABLED(CASELIGHT_USES_BRIGHTNESS) - MENU_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawSubMenu, Draw_CaseLight_Menu); + MENU_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawSubMenu, Draw_CaseLight_Menu); #else - MENU_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); + MENU_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); #endif #endif #if ENABLED(LED_CONTROL_MENU) - MENU_ITEM_F(ICON_LedControl, MSG_LED_CONTROL, onDrawSubMenu, Draw_LedControl_Menu); + MENU_ITEM(ICON_LedControl, MSG_LED_CONTROL, onDrawSubMenu, Draw_LedControl_Menu); #endif - MENU_ITEM_F(ICON_Info, MSG_INFO_SCREEN, onDrawInfoSubMenu, Goto_Info_Menu); + MENU_ITEM(ICON_Info, MSG_INFO_SCREEN, onDrawInfoSubMenu, Goto_Info_Menu); } ui.reset_status(true); - CurrentMenu->draw(); + UpdateMenu(ControlMenu); } void Draw_AdvancedSettings_Menu() { checkkey = Menu; - if (SetMenu(AdvancedSettings, GET_TEXT_F(MSG_ADVANCED_SETTINGS), 20)) { + if (SET_MENU(AdvancedSettings, MSG_ADVANCED_SETTINGS, 18)) { BACK_ITEM(Goto_Main_Menu); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); - #endif - #if HAS_BED_PROBE - MENU_ITEM_F(ICON_ProbeSet, MSG_ZPROBE_SETTINGS, onDrawSubMenu, Draw_ProbeSet_Menu); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif #if HAS_MESH - MENU_ITEM_F(ICON_ProbeSet, MSG_MESH_LEVELING, onDrawSubMenu, Draw_MeshSet_Menu); + MENU_ITEM(ICON_ProbeSet, MSG_MESH_LEVELING, onDrawSubMenu, Draw_MeshSet_Menu); #endif - #if HAS_HOME_OFFSET - MENU_ITEM_F(ICON_HomeOffset, MSG_SET_HOME_OFFSETS, onDrawSubMenu, Draw_HomeOffset_Menu); + #if HAS_BED_PROBE + MENU_ITEM(ICON_ProbeSet, MSG_ZPROBE_SETTINGS, onDrawSubMenu, Draw_ProbeSet_Menu); #endif - #if HAS_HOTEND - MENU_ITEM(ICON_PIDNozzle, F(STR_HOTEND_PID " Settings"), onDrawSubMenu, Draw_HotendPID_Menu); + MENU_ITEM(ICON_FilSet, MSG_FILAMENT_SET, onDrawSubMenu, Draw_FilSet_Menu); + #if ENABLED(PIDTEMP) + MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID " Settings", onDrawSubMenu, Draw_HotendPID_Menu); #endif - #if HAS_HEATED_BED - MENU_ITEM(ICON_PIDbed, F(STR_BED_PID " Settings"), onDrawSubMenu, Draw_BedPID_Menu); + #if ENABLED(PIDTEMPBED) + MENU_ITEM_F(ICON_PIDBed, STR_BED_PID " Settings", onDrawSubMenu, Draw_BedPID_Menu); #endif - MENU_ITEM_F(ICON_FilSet, MSG_FILAMENT_SET, onDrawSubMenu, Draw_FilSet_Menu); - #if ENABLED(POWER_LOSS_RECOVERY) - EDIT_ITEM_F(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, SetPwrLossr, &recovery.enabled); + #if HAS_ESDIAG + MENU_ITEM_F(ICON_ESDiag, "End-stops diag.", onDrawSubMenu, Draw_EndStopDiag); #endif - #if ENABLED(BAUD_RATE_GCODE) - EDIT_ITEM(ICON_SetBaudRate, F("115K baud"), onDrawChkbMenu, SetBaudRate, &HMI_data.Baud115K); + #if ENABLED(PRINTCOUNTER) + MENU_ITEM(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats); + MENU_ITEM(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStatsReset); #endif - #if HAS_LCD_BRIGHTNESS - EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); - MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); + #if HAS_LOCKSCREEN + MENU_ITEM(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #endif - MENU_ITEM_F(ICON_Scolor, MSG_COLORS_SELECT, onDrawSubMenu, Draw_SelectColors_Menu); #if ENABLED(SOUND_MENU_ITEM) - EDIT_ITEM_F(ICON_Sound, MSG_SOUND_ENABLE, onDrawChkbMenu, SetEnableSound, &ui.sound_on); + EDIT_ITEM(ICON_Sound, MSG_SOUND_ENABLE, onDrawChkbMenu, SetEnableSound, &ui.sound_on); #endif - #if HAS_ESDIAG - MENU_ITEM(ICON_ESDiag, F("End-stops diag."), onDrawSubMenu, Draw_EndStopDiag); + #if ENABLED(POWER_LOSS_RECOVERY) + EDIT_ITEM(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, SetPwrLossr, &recovery.enabled); #endif - #if ENABLED(PRINTCOUNTER) - MENU_ITEM_F(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats); - MENU_ITEM_F(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStats.Reset); + EDIT_ITEM(ICON_File, MSG_MEDIA_UPDATE, onDrawChkbMenu, SetMediaAutoMount, &HMI_data.MediaAutoMount); + #if ENABLED(BAUD_RATE_GCODE) + EDIT_ITEM_F(ICON_SetBaudRate, "115K baud", onDrawChkbMenu, SetBaudRate, &HMI_data.Baud115K); #endif - #if HAS_LOCKSCREEN - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + #if HAS_LCD_BRIGHTNESS + EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); #endif + MENU_ITEM(ICON_Scolor, MSG_COLORS_SELECT, onDrawSubMenu, Draw_SelectColors_Menu); } ui.reset_status(true); UpdateMenu(AdvancedSettings); @@ -3260,31 +3090,29 @@ void Draw_AdvancedSettings_Menu() { void Draw_Move_Menu() { checkkey = Menu; - if (!MoveMenu) MoveMenu = new MenuClass(); - if (CurrentMenu != MoveMenu) { - CurrentMenu = MoveMenu; - SetMenuTitle({192, 1, 42, 14}, GET_TEXT_F(MSG_MOVE_AXIS)); - MenuItemsPrepare(5); + if (SET_MENU_R(MoveMenu, selrect({192, 1, 42, 14}), MSG_MOVE_AXIS, 6)) { BACK_ITEM(Draw_Prepare_Menu); - EDIT_ITEM_F(ICON_MoveX, MSG_MOVE_X, onDrawMoveX, SetMoveX, ¤t_position.x); - EDIT_ITEM_F(ICON_MoveY, MSG_MOVE_Y, onDrawMoveY, SetMoveY, ¤t_position.y); - EDIT_ITEM_F(ICON_MoveZ, MSG_MOVE_Z, onDrawMoveZ, SetMoveZ, ¤t_position.z); + EDIT_ITEM(ICON_Axis, MSG_LIVE_MOVE, onDrawChkbMenu, SetLiveMove, &EnableLiveMove); + EDIT_ITEM(ICON_MoveX, MSG_MOVE_X, onDrawMoveX, SetMoveX, ¤t_position.x); + EDIT_ITEM(ICON_MoveY, MSG_MOVE_Y, onDrawMoveY, SetMoveY, ¤t_position.y); + EDIT_ITEM(ICON_MoveZ, MSG_MOVE_Z, onDrawMoveZ, SetMoveZ, ¤t_position.z); #if HAS_HOTEND - EDIT_ITEM_F(ICON_Extruder, MSG_MOVE_E, onDrawMoveE, SetMoveE, ¤t_position.e); + gcode.process_subcommands_now(F("G92E0")); // reset extruder position + EDIT_ITEM(ICON_Extruder, MSG_MOVE_E, onDrawMoveE, SetMoveE, ¤t_position.e); #endif } - CurrentMenu->draw(); + UpdateMenu(MoveMenu); if (!all_axes_trusted()) LCD_MESSAGE_F("WARNING: Current position unknown. Home axes."); } #if HAS_HOME_OFFSET void Draw_HomeOffset_Menu() { checkkey = Menu; - if (SetMenu(HomeOffMenu, GET_TEXT_F(MSG_SET_HOME_OFFSETS), 4)) { - BACK_ITEM(Draw_AdvancedSettings_Menu); - EDIT_ITEM_F(ICON_HomeOffsetX, MSG_HOME_OFFSET_X, onDrawPFloatMenu, SetHomeOffsetX, &home_offset.x); - EDIT_ITEM_F(ICON_HomeOffsetY, MSG_HOME_OFFSET_Y, onDrawPFloatMenu, SetHomeOffsetY, &home_offset.y); - EDIT_ITEM_F(ICON_HomeOffsetZ, MSG_HOME_OFFSET_Z, onDrawPFloatMenu, SetHomeOffsetZ, &home_offset.z); + if (SET_MENU(HomeOffMenu, MSG_SET_HOME_OFFSETS, 4)) { + BACK_ITEM(Draw_PhySet_Menu); + EDIT_ITEM(ICON_HomeOffsetX, MSG_HOME_OFFSET_X, onDrawPFloatMenu, SetHomeOffsetX, &home_offset.x); + EDIT_ITEM(ICON_HomeOffsetY, MSG_HOME_OFFSET_Y, onDrawPFloatMenu, SetHomeOffsetY, &home_offset.y); + EDIT_ITEM(ICON_HomeOffsetZ, MSG_HOME_OFFSET_Z, onDrawPFloatMenu, SetHomeOffsetZ, &home_offset.z); } UpdateMenu(HomeOffMenu); } @@ -3293,45 +3121,44 @@ void Draw_Move_Menu() { #if HAS_BED_PROBE void Draw_ProbeSet_Menu() { checkkey = Menu; - if (SetMenu(ProbeSetMenu, GET_TEXT_F(MSG_ZPROBE_SETTINGS), 8)) { + if (SET_MENU(ProbeSetMenu, MSG_ZPROBE_SETTINGS, 9)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - EDIT_ITEM_F(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); - EDIT_ITEM_F(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); - EDIT_ITEM_F(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); + EDIT_ITEM(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); + EDIT_ITEM(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); + EDIT_ITEM(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); #if ENABLED(BLTOUCH) - MENU_ITEM_F(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); - MENU_ITEM_F(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); - MENU_ITEM_F(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset); - #ifdef BLTOUCH_HS_MODE - EDIT_ITEM_F(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); + MENU_ITEM(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); + MENU_ITEM(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); + MENU_ITEM(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset); + #if ENABLED(BLTOUCH_HS_MODE) + EDIT_ITEM(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); #endif #endif - MENU_ITEM_F(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest); + MENU_ITEM(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest); } UpdateMenu(ProbeSetMenu); } - #endif void Draw_FilSet_Menu() { checkkey = Menu; - if (SetMenu(FilSetMenu, GET_TEXT_F(MSG_FILAMENT_SET), 9)) { + if (SET_MENU(FilSetMenu, MSG_FILAMENT_SET, 9)) { BACK_ITEM(Draw_AdvancedSettings_Menu); #if HAS_FILAMENT_SENSOR - EDIT_ITEM_F(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); + EDIT_ITEM(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); #endif #if HAS_FILAMENT_RUNOUT_DISTANCE - EDIT_ITEM_F(ICON_Runout, MSG_RUNOUT_DISTANCE_MM, onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); + EDIT_ITEM(ICON_Runout, MSG_RUNOUT_DISTANCE_MM, onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); #endif #if ENABLED(PREVENT_COLD_EXTRUSION) - EDIT_ITEM_F(ICON_ExtrudeMinT, MSG_EXTRUDER_MIN_TEMP, onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); + EDIT_ITEM(ICON_ExtrudeMinT, MSG_EXTRUDER_MIN_TEMP, onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) - EDIT_ITEM_F(ICON_FilLoad, MSG_FILAMENT_LOAD, onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length); - EDIT_ITEM_F(ICON_FilUnload, MSG_FILAMENT_UNLOAD, onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length); + EDIT_ITEM(ICON_FilLoad, MSG_FILAMENT_LOAD, onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length); + EDIT_ITEM(ICON_FilUnload, MSG_FILAMENT_UNLOAD, onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length); #endif #if ENABLED(FWRETRACT) - MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); + MENU_ITEM(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); #endif } UpdateMenu(FilSetMenu); @@ -3339,80 +3166,80 @@ void Draw_FilSet_Menu() { void Draw_SelectColors_Menu() { checkkey = Menu; - if (SetMenu(SelectColorMenu, GET_TEXT_F(MSG_COLORS_SELECT), 20)) { + if (SET_MENU(SelectColorMenu, MSG_COLORS_SELECT, 20)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - MENU_ITEM_F(ICON_StockConfiguration, MSG_RESTORE_DEFAULTS, onDrawMenuItem, RestoreDefaultsColors); - EDIT_ITEM(0, F("Screen Background"), onDrawSelColorItem, SelColor, &HMI_data.Background_Color); - EDIT_ITEM(0, F("Cursor"), onDrawSelColorItem, SelColor, &HMI_data.Cursor_color); - EDIT_ITEM(0, F("Title Background"), onDrawSelColorItem, SelColor, &HMI_data.TitleBg_color); - EDIT_ITEM(0, F("Title Text"), onDrawSelColorItem, SelColor, &HMI_data.TitleTxt_color); - EDIT_ITEM(0, F("Text"), onDrawSelColorItem, SelColor, &HMI_data.Text_Color); - EDIT_ITEM(0, F("Selected"), onDrawSelColorItem, SelColor, &HMI_data.Selected_Color); - EDIT_ITEM(0, F("Split Line"), onDrawSelColorItem, SelColor, &HMI_data.SplitLine_Color); - EDIT_ITEM(0, F("Highlight"), onDrawSelColorItem, SelColor, &HMI_data.Highlight_Color); - EDIT_ITEM(0, F("Status Background"), onDrawSelColorItem, SelColor, &HMI_data.StatusBg_Color); - EDIT_ITEM(0, F("Status Text"), onDrawSelColorItem, SelColor, &HMI_data.StatusTxt_Color); - EDIT_ITEM(0, F("Popup Background"), onDrawSelColorItem, SelColor, &HMI_data.PopupBg_color); - EDIT_ITEM(0, F("Popup Text"), onDrawSelColorItem, SelColor, &HMI_data.PopupTxt_Color); - EDIT_ITEM(0, F("Alert Background"), onDrawSelColorItem, SelColor, &HMI_data.AlertBg_Color); - EDIT_ITEM(0, F("Alert Text"), onDrawSelColorItem, SelColor, &HMI_data.AlertTxt_Color); - EDIT_ITEM(0, F("Percent Text"), onDrawSelColorItem, SelColor, &HMI_data.PercentTxt_Color); - EDIT_ITEM(0, F("Bar Fill"), onDrawSelColorItem, SelColor, &HMI_data.Barfill_Color); - EDIT_ITEM(0, F("Indicator value"), onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color); - EDIT_ITEM(0, F("Coordinate value"), onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color); + MENU_ITEM(ICON_StockConfiguration, MSG_RESTORE_DEFAULTS, onDrawMenuItem, RestoreDefaultColors); + EDIT_ITEM_F(0, "Screen Background", onDrawSelColorItem, SelColor, &HMI_data.Background_Color); + EDIT_ITEM_F(0, "Cursor", onDrawSelColorItem, SelColor, &HMI_data.Cursor_Color); + EDIT_ITEM_F(0, "Title Background", onDrawSelColorItem, SelColor, &HMI_data.TitleBg_Color); + EDIT_ITEM_F(0, "Title Text", onDrawSelColorItem, SelColor, &HMI_data.TitleTxt_Color); + EDIT_ITEM_F(0, "Text", onDrawSelColorItem, SelColor, &HMI_data.Text_Color); + EDIT_ITEM_F(0, "Selected", onDrawSelColorItem, SelColor, &HMI_data.Selected_Color); + EDIT_ITEM_F(0, "Split Line", onDrawSelColorItem, SelColor, &HMI_data.SplitLine_Color); + EDIT_ITEM_F(0, "Highlight", onDrawSelColorItem, SelColor, &HMI_data.Highlight_Color); + EDIT_ITEM_F(0, "Status Background", onDrawSelColorItem, SelColor, &HMI_data.StatusBg_Color); + EDIT_ITEM_F(0, "Status Text", onDrawSelColorItem, SelColor, &HMI_data.StatusTxt_Color); + EDIT_ITEM_F(0, "Popup Background", onDrawSelColorItem, SelColor, &HMI_data.PopupBg_Color); + EDIT_ITEM_F(0, "Popup Text", onDrawSelColorItem, SelColor, &HMI_data.PopupTxt_Color); + EDIT_ITEM_F(0, "Alert Background", onDrawSelColorItem, SelColor, &HMI_data.AlertBg_Color); + EDIT_ITEM_F(0, "Alert Text", onDrawSelColorItem, SelColor, &HMI_data.AlertTxt_Color); + EDIT_ITEM_F(0, "Percent Text", onDrawSelColorItem, SelColor, &HMI_data.PercentTxt_Color); + EDIT_ITEM_F(0, "Bar Fill", onDrawSelColorItem, SelColor, &HMI_data.Barfill_Color); + EDIT_ITEM_F(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color); + EDIT_ITEM_F(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color); } UpdateMenu(SelectColorMenu); } void Draw_GetColor_Menu() { checkkey = Menu; - if (SetMenu(GetColorMenu, GET_TEXT_F(MSG_COLORS_GET), 5)) { + if (SET_MENU(GetColorMenu, MSG_COLORS_GET, 5)) { BACK_ITEM(DWIN_ApplyColor); - MENU_ITEM_F(ICON_Cancel, MSG_BUTTON_CANCEL, onDrawMenuItem, Draw_SelectColors_Menu); - MENU_ITEM_F(0, MSG_COLORS_RED, onDrawGetColorItem, SetRGBColor); - MENU_ITEM_F(1, MSG_COLORS_GREEN, onDrawGetColorItem, SetRGBColor); - MENU_ITEM_F(2, MSG_COLORS_BLUE, onDrawGetColorItem, SetRGBColor); + MENU_ITEM(ICON_Cancel, MSG_BUTTON_CANCEL, onDrawMenuItem, Draw_SelectColors_Menu); + MENU_ITEM(0, MSG_COLORS_RED, onDrawGetColorItem, SetRGBColor); + MENU_ITEM(1, MSG_COLORS_GREEN, onDrawGetColorItem, SetRGBColor); + MENU_ITEM(2, MSG_COLORS_BLUE, onDrawGetColorItem, SetRGBColor); } UpdateMenu(GetColorMenu); DWIN_Draw_Rectangle(1, *MenuData.P_Int, 20, 315, DWIN_WIDTH - 20, 335); } #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - void Draw_CaseLight_Menu() { - checkkey = Menu; - if (SetMenu(CaseLightMenu, GET_TEXT_F(MSG_CASE_LIGHT), 3)) { - BACK_ITEM(Draw_Control_Menu); - EDIT_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); - EDIT_ITEM_F(ICON_Brightness, MSG_CASE_LIGHT_BRIGHTNESS, onDrawPInt8Menu, SetCaseLightBrightness, &caselight.brightness); - } - UpdateMenu(CaseLightMenu); + void Draw_CaseLight_Menu() { + checkkey = Menu; + if (SET_MENU(CaseLightMenu, MSG_CASE_LIGHT, 3)) { + BACK_ITEM(Draw_Control_Menu); + EDIT_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); + EDIT_ITEM(ICON_Brightness, MSG_CASE_LIGHT_BRIGHTNESS, onDrawPInt8Menu, SetCaseLightBrightness, &caselight.brightness); } + UpdateMenu(CaseLightMenu); + } #endif #if ENABLED(LED_CONTROL_MENU) void Draw_LedControl_Menu() { checkkey = Menu; - if (SetMenu(LedControlMenu, GET_TEXT_F(MSG_LED_CONTROL), 6)) { + if (SET_MENU(LedControlMenu, MSG_LED_CONTROL, 10)) { BACK_ITEM(Draw_Control_Menu); #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) - EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); + EDIT_ITEM(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); #endif #if HAS_COLOR_LEDS #if ENABLED(LED_COLOR_PRESETS) - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_WHITE, onDrawMenuItem, leds.set_white); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_RED, onDrawMenuItem, leds.set_red); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_ORANGE, onDrawMenuItem, leds.set_orange); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_YELLOW, onDrawMenuItem, leds.set_yellow); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_GREEN, onDrawMenuItem, leds.set_green); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_BLUE, onDrawMenuItem, leds.set_blue); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_INDIGO, onDrawMenuItem, leds.set_indigo); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_VIOLET, onDrawMenuItem, leds.set_violet); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_WHITE, onDrawMenuItem, leds.set_white); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_RED, onDrawMenuItem, leds.set_red); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_ORANGE, onDrawMenuItem, leds.set_orange); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_YELLOW, onDrawMenuItem, leds.set_yellow); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_GREEN, onDrawMenuItem, leds.set_green); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_BLUE, onDrawMenuItem, leds.set_blue); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_INDIGO, onDrawMenuItem, leds.set_indigo); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_VIOLET, onDrawMenuItem, leds.set_violet); #else - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r); - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); #if ENABLED(HAS_WHITE_LED) - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLEDColorW, &leds.color.w); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLEDColorW, &leds.color.w); #endif #endif #endif @@ -3423,77 +3250,76 @@ void Draw_GetColor_Menu() { void Draw_Tune_Menu() { checkkey = Menu; - if (!TuneMenu) TuneMenu = new MenuClass(); - if (CurrentMenu != TuneMenu) { - CurrentMenu = TuneMenu; - SetMenuTitle({73, 2, 28, 12}, GET_TEXT_F(MSG_TUNE)); // TODO: Chinese, English "Tune" JPG - MenuItemsPrepare(16); + if (SET_MENU_R(TuneMenu, selrect({73, 2, 28, 12}), MSG_TUNE, 14)) { BACK_ITEM(Goto_PrintProcess); - EDIT_ITEM_F(ICON_Speed, MSG_SPEED, onDrawSpeedItem, SetSpeed, &feedrate_percentage); + EDIT_ITEM(ICON_Speed, MSG_SPEED, onDrawSpeedItem, SetSpeed, &feedrate_percentage); #if HAS_HOTEND - HotendTargetItem = EDIT_ITEM_F(ICON_HotendTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM(ICON_HotendTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = EDIT_ITEM_F(ICON_BedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM(ICON_BedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif - #if HAS_ZOFFSET_ITEM && EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawZOffset, SetZOffset, &BABY_Z_VAR); + #if ALL(HAS_ZOFFSET_ITEM, HAS_BED_PROBE, BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawZOffset, SetZOffset, &BABY_Z_VAR); + #elif ALL(HAS_ZOFFSET_ITEM, MESH_BED_LEVELING, BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, MSG_HOME_OFFSET_Z, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); #endif - EDIT_ITEM_F(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + EDIT_ITEM(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); #if ENABLED(ADVANCED_PAUSE_FEATURE) - MENU_ITEM_F(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); + MENU_ITEM(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); + #endif + #if HAS_FILAMENT_SENSOR + EDIT_ITEM(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); #endif #if ENABLED(FWRETRACT) - MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); + MENU_ITEM(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); #endif #if HAS_LOCKSCREEN - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + MENU_ITEM(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #endif #if HAS_LCD_BRIGHTNESS - EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); - MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); + EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); #endif #if ENABLED(CASE_LIGHT_MENU) - EDIT_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); + EDIT_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); #elif ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL) - EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); + EDIT_ITEM(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); #endif } - CurrentMenu->draw(); + UpdateMenu(TuneMenu); } void Draw_Motion_Menu() { checkkey = Menu; - if (!MotionMenu) MotionMenu = new MenuClass(); - if (CurrentMenu != MotionMenu) { - CurrentMenu = MotionMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MOTION)); // TODO: Chinese, English "Motion" JPG - MenuItemsPrepare(6); + if (SET_MENU_R(MotionMenu, selrect({1, 16, 28, 13}), MSG_MOTION, 6)) { BACK_ITEM(Draw_Control_Menu); - MENU_ITEM_F(ICON_MaxSpeed, MSG_SPEED, onDrawSpeed, Draw_MaxSpeed_Menu); - MENU_ITEM_F(ICON_MaxAccelerated, MSG_ACCELERATION, onDrawAcc, Draw_MaxAccel_Menu); + MENU_ITEM(ICON_MaxSpeed, MSG_SPEED, onDrawSpeed, Draw_MaxSpeed_Menu); + MENU_ITEM(ICON_MaxAccelerated, MSG_ACCELERATION, onDrawAcc, Draw_MaxAccel_Menu); #if HAS_CLASSIC_JERK - MENU_ITEM_F(ICON_MaxJerk, MSG_JERK, onDrawJerk, Draw_MaxJerk_Menu); + MENU_ITEM(ICON_MaxJerk, MSG_JERK, onDrawJerk, Draw_MaxJerk_Menu); #endif - MENU_ITEM_F(ICON_Step, MSG_STEPS_PER_MM, onDrawSteps, Draw_Steps_Menu); - EDIT_ITEM_F(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + MENU_ITEM(ICON_Step, MSG_STEPS_PER_MM, onDrawSteps, Draw_Steps_Menu); + EDIT_ITEM(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); } - CurrentMenu->draw(); + UpdateMenu(MotionMenu); } #if ENABLED(ADVANCED_PAUSE_FEATURE) void Draw_FilamentMan_Menu() { checkkey = Menu; - if (SetMenu(FilamentMenu, GET_TEXT_F(MSG_FILAMENT_MAN), 5)) { + if (SET_MENU(FilamentMenu, MSG_FILAMENT_MAN, 5)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_Park, MSG_FILAMENT_PARK_ENABLED, onDrawMenuItem, ParkHead); - MENU_ITEM_F(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); + #if ENABLED(NOZZLE_PARK_FEATURE) + MENU_ITEM(ICON_Park, MSG_FILAMENT_PARK_ENABLED, onDrawMenuItem, ParkHead); + #endif + MENU_ITEM(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - MENU_ITEM_F(ICON_FilUnload, MSG_FILAMENTUNLOAD, onDrawMenuItem, UnloadFilament); - MENU_ITEM_F(ICON_FilLoad, MSG_FILAMENTLOAD, onDrawMenuItem, LoadFilament); + MENU_ITEM(ICON_FilUnload, MSG_FILAMENTUNLOAD, onDrawMenuItem, UnloadFilament); + MENU_ITEM(ICON_FilLoad, MSG_FILAMENTLOAD, onDrawMenuItem, LoadFilament); #endif } UpdateMenu(FilamentMenu); @@ -3503,13 +3329,13 @@ void Draw_Motion_Menu() { #if ENABLED(MESH_BED_LEVELING) void Draw_ManualMesh_Menu() { checkkey = Menu; - if (SetMenu(ManualMesh, GET_TEXT_F(MSG_UBL_MANUAL_MESH), 6)) { + if (SET_MENU(ManualMesh, MSG_UBL_MANUAL_MESH, 6)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_ManualMesh, MSG_LEVEL_BED, onDrawMenuItem, ManualMeshStart); - MMeshMoveZItem = EDIT_ITEM_F(ICON_Zoffset, MSG_MOVE_Z, onDrawMMeshMoveZ, SetMMeshMoveZ, ¤t_position.z); - MENU_ITEM_F(ICON_Axis, MSG_UBL_CONTINUE_MESH, onDrawMenuItem, ManualMeshContinue); - MENU_ITEM_F(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); - MENU_ITEM_F(ICON_MeshSave, MSG_UBL_SAVE_MESH, onDrawMenuItem, ManualMeshSave); + MENU_ITEM(ICON_ManualMesh, MSG_LEVEL_BED, onDrawMenuItem, ManualMeshStart); + MMeshMoveZItem = EDIT_ITEM(ICON_Zoffset, MSG_MOVE_Z, onDrawMMeshMoveZ, SetMMeshMoveZ, ¤t_position.z); + MENU_ITEM(ICON_Axis, MSG_UBL_CONTINUE_MESH, onDrawMenuItem, ManualMeshContinue); + MENU_ITEM(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); + MENU_ITEM(ICON_MeshSave, MSG_UBL_SAVE_MESH, onDrawMenuItem, ManualMeshSave); } UpdateMenu(ManualMesh); } @@ -3517,203 +3343,160 @@ void Draw_Motion_Menu() { #if HAS_PREHEAT - void Draw_Preheat_Menu(frame_rect_t cn, const __FlashStringHelper* fstr) { + void Draw_Preheat_Menu(bool NotCurrent) { checkkey = Menu; - if (CurrentMenu != PreheatMenu) { - CurrentMenu = PreheatMenu; - SetMenuTitle(cn, fstr); - MenuItemsPrepare(5); + if (NotCurrent) { BACK_ITEM(Draw_Temperature_Menu); #if HAS_HOTEND - EDIT_ITEM_F(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Select].hotend_temp); + EDIT_ITEM(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Select].hotend_temp); #endif #if HAS_HEATED_BED - EDIT_ITEM_F(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Select].bed_temp); + EDIT_ITEM(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Select].bed_temp); #endif #if HAS_FAN - EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Select].fan_speed); + EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Select].fan_speed); #endif #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); #endif } - CurrentMenu->draw(); - } - - void Draw_Preheat1_Menu() { - HMI_value.Select = 0; - if (!PreheatMenu) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({59, 16, 81, 14}, F(PREHEAT_1_LABEL " Preheat Settings")); // TODO: English "PLA Settings" JPG + UpdateMenu(PreheatMenu); } - #if PREHEAT_COUNT >= 2 - void Draw_Preheat2_Menu() { - HMI_value.Select = 1; - if (!PreheatMenu) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({142, 16, 82, 14}, F(PREHEAT_2_LABEL " Preheat Settings")); // TODO: English "ABS Settings" JPG + #define _Preheat_Menu(N) \ + void Draw_Preheat## N ##_Menu() { \ + HMI_value.Select = N-1; \ + Draw_Preheat_Menu(SET_MENU(PreheatMenu, MSG_PREHEAT_## N ##_SETTINGS, 5)); \ } - #endif - - #if PREHEAT_COUNT >= 3 - void Draw_Preheat3_Menu() { - HMI_value.Select = 2; - if (!PreheatMenu) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({225, 16, 82, 14}, F(PREHEAT_3_LABEL " Preheat Settings")); // TODO: English "... Settings" JPG - } - #endif + REPEAT_1(PREHEAT_COUNT, _Preheat_Menu) #endif // HAS_PREHEAT void Draw_Temperature_Menu() { checkkey = Menu; - if (!TemperatureMenu) TemperatureMenu = new MenuClass(); - if (CurrentMenu != TemperatureMenu) { - CurrentMenu = TemperatureMenu; - SetMenuTitle({236, 2, 28, 12}, GET_TEXT_F(MSG_TEMPERATURE)); - MenuItemsPrepare(7); + if (SET_MENU_R(TemperatureMenu, selrect({236, 2, 28, 12}), MSG_TEMPERATURE, 4 + PREHEAT_COUNT)) { BACK_ITEM(Draw_Control_Menu); #if HAS_HOTEND - HotendTargetItem = EDIT_ITEM_F(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = EDIT_ITEM_F(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif #if HAS_PREHEAT - MENU_ITEM_F(ICON_SetPLAPreheat, MSG_PREHEAT_1_SETTINGS, onDrawPLAPreheatSubMenu, Draw_Preheat1_Menu); - #if PREHEAT_COUNT >= 2 - MENU_ITEM_F(ICON_SetABSPreheat, MSG_PREHEAT_2_SETTINGS, onDrawABSPreheatSubMenu, Draw_Preheat2_Menu); - #if PREHEAT_COUNT >= 3 - MENU_ITEM_F(ICON_SetCustomPreheat, MSG_PREHEAT_3_SETTINGS, onDrawSubMenu, Draw_Preheat3_Menu); - #endif - #endif + #define _ITEM_SETPREHEAT(N) MENU_ITEM(ICON_SetPreheat##N, MSG_PREHEAT_## N ##_SETTINGS, onDrawSubMenu, Draw_Preheat## N ##_Menu); + REPEAT_1(PREHEAT_COUNT, _ITEM_SETPREHEAT) #endif } - CurrentMenu->draw(); + UpdateMenu(TemperatureMenu); } void Draw_MaxSpeed_Menu() { checkkey = Menu; - if (!MaxSpeedMenu) MaxSpeedMenu = new MenuClass(); - if (CurrentMenu != MaxSpeedMenu) { - CurrentMenu = MaxSpeedMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MAX_SPEED)); - MenuItemsPrepare(5); + if (SET_MENU_R(MaxSpeedMenu, selrect({1, 16, 28, 13}), MSG_MAX_SPEED, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_MaxSpeedX, MSG_VMAX_A, onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedY, MSG_VMAX_B, onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedZ, MSG_VMAX_C, onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]); + EDIT_ITEM(ICON_MaxSpeedX, MSG_VMAX_A, onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]); + EDIT_ITEM(ICON_MaxSpeedY, MSG_VMAX_B, onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]); + EDIT_ITEM(ICON_MaxSpeedZ, MSG_VMAX_C, onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]); #if HAS_HOTEND - EDIT_ITEM_F(ICON_MaxSpeedE, MSG_VMAX_E, onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]); + EDIT_ITEM(ICON_MaxSpeedE, MSG_VMAX_E, onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]); #endif } - CurrentMenu->draw(); + UpdateMenu(MaxSpeedMenu); } void Draw_MaxAccel_Menu() { checkkey = Menu; - if (!MaxAccelMenu) MaxAccelMenu = new MenuClass(); - if (CurrentMenu != MaxAccelMenu) { - CurrentMenu = MaxAccelMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_ACCELERATION)); - MenuItemsPrepare(5); + if (SET_MENU_R(MaxAccelMenu, selrect({1, 16, 28, 13}), MSG_AMAX_EN, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_MaxAccX, MSG_AMAX_A, onDrawMaxAccelX, SetMaxAccelX, &planner.settings.max_acceleration_mm_per_s2[X_AXIS]); - EDIT_ITEM_F(ICON_MaxAccY, MSG_AMAX_B, onDrawMaxAccelY, SetMaxAccelY, &planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); - EDIT_ITEM_F(ICON_MaxAccZ, MSG_AMAX_C, onDrawMaxAccelZ, SetMaxAccelZ, &planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); + EDIT_ITEM(ICON_MaxAccX, MSG_AMAX_A, onDrawMaxAccelX, SetMaxAccelX, &planner.settings.max_acceleration_mm_per_s2[X_AXIS]); + EDIT_ITEM(ICON_MaxAccY, MSG_AMAX_B, onDrawMaxAccelY, SetMaxAccelY, &planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); + EDIT_ITEM(ICON_MaxAccZ, MSG_AMAX_C, onDrawMaxAccelZ, SetMaxAccelZ, &planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); #if HAS_HOTEND - EDIT_ITEM_F(ICON_MaxAccE, MSG_AMAX_E, onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); + EDIT_ITEM(ICON_MaxAccE, MSG_AMAX_E, onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); #endif } - CurrentMenu->draw(); + UpdateMenu(MaxAccelMenu); } #if HAS_CLASSIC_JERK void Draw_MaxJerk_Menu() { checkkey = Menu; - if (!MaxJerkMenu) MaxJerkMenu = new MenuClass(); - if (CurrentMenu != MaxJerkMenu) { - CurrentMenu = MaxJerkMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_JERK)); - MenuItemsPrepare(5); + if (SET_MENU_R(MaxJerkMenu, selrect({1, 16, 28, 13}), MSG_JERK, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_MaxSpeedJerkX, MSG_VA_JERK, onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk[X_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedJerkY, MSG_VB_JERK, onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk[Y_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedJerkZ, MSG_VC_JERK, onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk[Z_AXIS]); + EDIT_ITEM(ICON_MaxSpeedJerkX, MSG_VA_JERK, onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk.x); + EDIT_ITEM(ICON_MaxSpeedJerkY, MSG_VB_JERK, onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk.y); + EDIT_ITEM(ICON_MaxSpeedJerkZ, MSG_VC_JERK, onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk.z); #if HAS_HOTEND - EDIT_ITEM_F(ICON_MaxSpeedJerkE, MSG_VE_JERK, onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]); + EDIT_ITEM(ICON_MaxSpeedJerkE, MSG_VE_JERK, onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk.e); #endif } - CurrentMenu->draw(); + UpdateMenu(MaxJerkMenu); } #endif void Draw_Steps_Menu() { checkkey = Menu; - if (!StepsMenu) StepsMenu = new MenuClass(); - if (CurrentMenu != StepsMenu) { - CurrentMenu = StepsMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_STEPS_PER_MM)); - MenuItemsPrepare(5); + if (SET_MENU_R(StepsMenu, selrect({1, 16, 28, 13}), MSG_STEPS_PER_MM, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_StepX, MSG_A_STEPS, onDrawStepsX, SetStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); - EDIT_ITEM_F(ICON_StepY, MSG_B_STEPS, onDrawStepsY, SetStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); - EDIT_ITEM_F(ICON_StepZ, MSG_C_STEPS, onDrawStepsZ, SetStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); + EDIT_ITEM(ICON_StepX, MSG_A_STEPS, onDrawStepsX, SetStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); + EDIT_ITEM(ICON_StepY, MSG_B_STEPS, onDrawStepsY, SetStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); + EDIT_ITEM(ICON_StepZ, MSG_C_STEPS, onDrawStepsZ, SetStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); #if HAS_HOTEND - EDIT_ITEM_F(ICON_StepE, MSG_E_STEPS, onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); + EDIT_ITEM(ICON_StepE, MSG_E_STEPS, onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); #endif } - CurrentMenu->draw(); + UpdateMenu(StepsMenu); } -#if HAS_HOTEND +#if ENABLED(PIDTEMP) void Draw_HotendPID_Menu() { checkkey = Menu; - if (SetMenu(HotendPIDMenu, F(STR_HOTEND_PID " Settings"),8)) { + if (SET_MENU_F(HotendPIDMenu, STR_HOTEND_PID " Settings", 8)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - MENU_ITEM(ICON_PIDNozzle, F(STR_HOTEND_PID), onDrawMenuItem, HotendPID); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd); - EDIT_ITEM_F(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); - EDIT_ITEM_F(ICON_PIDcycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID, onDrawMenuItem, HotendPID); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KP, onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KI, onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KD, onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd); + EDIT_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); + EDIT_ITEM(ICON_PIDCycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif } UpdateMenu(HotendPIDMenu); } #endif -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) void Draw_BedPID_Menu() { checkkey = Menu; - if (SetMenu(BedPIDMenu, F(STR_BED_PID " Settings"),8)) { + if (SET_MENU_F(BedPIDMenu, STR_BED_PID " Settings", 8)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - MENU_ITEM(ICON_PIDNozzle, F(STR_BED_PID), onDrawMenuItem,BedPID); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd); - EDIT_ITEM_F(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); - EDIT_ITEM_F(ICON_PIDcycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + MENU_ITEM_F(ICON_PIDBed, STR_BED_PID, onDrawMenuItem,BedPID); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KP, onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KI, onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KD, onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd); + EDIT_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); + EDIT_ITEM(ICON_PIDCycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif } UpdateMenu(BedPIDMenu); } #endif -#if ENABLED(BABYSTEP_ZPROBE_OFFSET) +#if HAS_BED_PROBE void Draw_ZOffsetWiz_Menu() { checkkey = Menu; - if (SetMenu(ZOffsetWizMenu, GET_TEXT_F(MSG_PROBE_WIZARD), 4)) { + if (SET_MENU(ZOffsetWizMenu, MSG_PROBE_WIZARD, 4)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); - MENU_ITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0); - EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); + MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); + MENU_ITEM_F(ICON_MoveZ0, "Move Z to Home", onDrawMenuItem, SetMoveZto0); + EDIT_ITEM(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); } UpdateMenu(ZOffsetWizMenu); if (!axis_is_trusted(Z_AXIS)) LCD_MESSAGE_F("WARNING: Z position unknown, move Z to home"); @@ -3723,12 +3506,15 @@ void Draw_Steps_Menu() { #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) void Draw_Homing_Menu() { checkkey = Menu; - if (SetMenu(HomingMenu, GET_TEXT_F(MSG_HOMING), 5)) { + if (SET_MENU(HomingMenu, MSG_HOMING, 6)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); - MENU_ITEM_F(ICON_HomeX, MSG_AUTO_HOME_X, onDrawMenuItem, HomeX); - MENU_ITEM_F(ICON_HomeY, MSG_AUTO_HOME_Y, onDrawMenuItem, HomeY); - MENU_ITEM_F(ICON_HomeZ, MSG_AUTO_HOME_Z, onDrawMenuItem, HomeZ); + MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); + MENU_ITEM(ICON_HomeX, MSG_AUTO_HOME_X, onDrawMenuItem, HomeX); + MENU_ITEM(ICON_HomeY, MSG_AUTO_HOME_Y, onDrawMenuItem, HomeY); + MENU_ITEM(ICON_HomeZ, MSG_AUTO_HOME_Z, onDrawMenuItem, HomeZ); + #if ENABLED(MESH_BED_LEVELING) + EDIT_ITEM(ICON_ZAfterHome, MSG_Z_AFTER_HOME, onDrawPInt8Menu, SetZAfterHoming, &HMI_data.z_after_homing); + #endif } UpdateMenu(HomingMenu); } @@ -3737,13 +3523,13 @@ void Draw_Steps_Menu() { #if ENABLED(FWRETRACT) void Draw_FWRetract_Menu() { checkkey = Menu; - if (SetMenu(FWRetractMenu, GET_TEXT_F(MSG_FWRETRACT), 6)) { + if (SET_MENU(FWRetractMenu, MSG_FWRETRACT, 6)) { BACK_ITEM(Return_FWRetract_Menu); - EDIT_ITEM_F(ICON_FWRetLength, MSG_CONTROL_RETRACT, onDrawPFloatMenu, SetRetractLength, &fwretract.settings.retract_length); - EDIT_ITEM_F(ICON_FWRetSpeed, MSG_SINGLENOZZLE_RETRACT_SPEED, onDrawPFloatMenu, SetRetractSpeed, &fwretract.settings.retract_feedrate_mm_s); - EDIT_ITEM_F(ICON_FWRetZRaise, MSG_CONTROL_RETRACT_ZHOP, onDrawPFloat2Menu, SetZRaise, &fwretract.settings.retract_zraise); - EDIT_ITEM_F(ICON_FWRecSpeed, MSG_SINGLENOZZLE_UNRETRACT_SPEED, onDrawPFloatMenu, SetRecoverSpeed, &fwretract.settings.retract_recover_feedrate_mm_s); - EDIT_ITEM_F(ICON_FWRecExtra, MSG_CONTROL_RETRACT_RECOVER, onDrawPFloatMenu, SetAddRecover, &fwretract.settings.retract_recover_extra); + EDIT_ITEM(ICON_FWRetLength, MSG_CONTROL_RETRACT, onDrawPFloatMenu, SetRetractLength, &fwretract.settings.retract_length); + EDIT_ITEM(ICON_FWRetSpeed, MSG_SINGLENOZZLE_RETRACT_SPEED, onDrawPFloatMenu, SetRetractSpeed, &fwretract.settings.retract_feedrate_mm_s); + EDIT_ITEM(ICON_FWRetZRaise, MSG_CONTROL_RETRACT_ZHOP, onDrawPFloat2Menu, SetZRaise, &fwretract.settings.retract_zraise); + EDIT_ITEM(ICON_FWRecSpeed, MSG_SINGLENOZZLE_UNRETRACT_SPEED, onDrawPFloatMenu, SetRecoverSpeed, &fwretract.settings.retract_recover_feedrate_mm_s); + EDIT_ITEM(ICON_FWRecExtra, MSG_CONTROL_RETRACT_RECOVER, onDrawPFloatMenu, SetAddRecover, &fwretract.settings.retract_recover_extra); } UpdateMenu(FWRetractMenu); } @@ -3764,7 +3550,7 @@ void Draw_Steps_Menu() { DWIN_UpdateLCD(); } - #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) + #if ENABLED(PREHEAT_BEFORE_LEVELING) void SetBedLevT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } #endif @@ -3772,11 +3558,11 @@ void Draw_Steps_Menu() { #define Z_OFFSET_MIN -3 #define Z_OFFSET_MAX 3 - void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? BedLevelTools.mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : BedLevelTools.mesh_y]; EditZValueItem->redraw(); } - void ApplyEditMeshX() { BedLevelTools.mesh_x = MenuData.Value; } - void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, BedLevelTools.mesh_x, ApplyEditMeshX, LiveEditMesh); } - void ApplyEditMeshY() { BedLevelTools.mesh_y = MenuData.Value; } - void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, BedLevelTools.mesh_y, ApplyEditMeshY, LiveEditMesh); } + void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? bedLevelTools.mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : bedLevelTools.mesh_y]; EditZValueItem->redraw(); } + void ApplyEditMeshX() { bedLevelTools.mesh_x = MenuData.Value; } + void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, bedLevelTools.mesh_x, ApplyEditMeshX, LiveEditMesh); } + void ApplyEditMeshY() { bedLevelTools.mesh_y = MenuData.Value; } + void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, bedLevelTools.mesh_y, ApplyEditMeshY, LiveEditMesh); } void SetEditZValue() { SetPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); } #endif #endif @@ -3790,14 +3576,14 @@ void Draw_Steps_Menu() { onDrawIntMenu(menuitem, line, bedlevel.storage_slot); } - void ApplyUBLTiltGrid() { BedLevelTools.tilt_grid = MenuData.Value; } - void SetUBLTiltGrid() { SetIntOnClick(1, 3, BedLevelTools.tilt_grid, ApplyUBLTiltGrid); } + void ApplyUBLTiltGrid() { bedLevelTools.tilt_grid = MenuData.Value; } + void SetUBLTiltGrid() { SetIntOnClick(1, 3, bedLevelTools.tilt_grid, ApplyUBLTiltGrid); } void UBLTiltMesh() { if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; char buf[15]; - if (BedLevelTools.tilt_grid > 1) { - sprintf_P(buf, PSTR("G28O\nG29 J%i"), BedLevelTools.tilt_grid); + if (bedLevelTools.tilt_grid > 1) { + sprintf_P(buf, PSTR("G28O\nG29 J%i"), bedLevelTools.tilt_grid); gcode.process_subcommands_now(buf); } else @@ -3828,28 +3614,28 @@ void Draw_Steps_Menu() { void Draw_MeshSet_Menu() { checkkey = Menu; - if (SetMenu(MeshMenu, GET_TEXT_F(MSG_MESH_LEVELING), 15)) { + if (SET_MENU(MeshMenu, MSG_MESH_LEVELING, 13)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) - EDIT_ITEM_F(ICON_Temperature, MSG_UBL_SET_TEMP_BED, onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); + #if ENABLED(PREHEAT_BEFORE_LEVELING) + EDIT_ITEM(ICON_Temperature, MSG_UBL_SET_TEMP_BED, onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); #endif - EDIT_ITEM_F(ICON_SetZOffset, MSG_Z_FADE_HEIGHT, onDrawPFloatMenu, SetMeshFadeHeight, &planner.z_fade_height); - EDIT_ITEM_F(ICON_UBLActive, MSG_ACTIVATE_MESH, onDrawChkbMenu, SetMeshActive, &planner.leveling_active); + EDIT_ITEM(ICON_SetZOffset, MSG_Z_FADE_HEIGHT, onDrawPFloatMenu, SetMeshFadeHeight, &planner.z_fade_height); + EDIT_ITEM(ICON_UBLActive, MSG_ACTIVATE_MESH, onDrawChkbMenu, SetMeshActive, &planner.leveling_active); #if HAS_BED_PROBE - MENU_ITEM_F(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); + MENU_ITEM(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh); - EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &BedLevelTools.tilt_grid); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLTiltMesh); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); + EDIT_ITEM(ICON_UBLSlot, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot); + MENU_ITEM(ICON_UBLSaveMesh, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh); + MENU_ITEM(ICON_UBLLoadMesh, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh); + EDIT_ITEM(ICON_UBLTiltGrid, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &bedLevelTools.tilt_grid); + MENU_ITEM(ICON_UBLTiltGrid, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLTiltMesh); + MENU_ITEM(ICON_UBLSmartFill, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); #endif #if ENABLED(MESH_EDIT_MENU) - MENU_ITEM_F(ICON_UBLActive, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu); + MENU_ITEM(ICON_MeshEdit, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu); #endif - MENU_ITEM_F(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); + MENU_ITEM(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); } UpdateMenu(MeshMenu); } @@ -3859,12 +3645,12 @@ void Draw_Steps_Menu() { if (!leveling_is_valid()) { LCD_MESSAGE(MSG_UBL_MESH_INVALID); return; } set_bed_leveling_enabled(false); checkkey = Menu; - if (SetMenu(EditMeshMenu, GET_TEXT_F(MSG_EDIT_MESH), 4)) { - BedLevelTools.mesh_x = BedLevelTools.mesh_y = 0; + if (SET_MENU(EditMeshMenu, MSG_EDIT_MESH, 4)) { + bedLevelTools.mesh_x = bedLevelTools.mesh_y = 0; BACK_ITEM(Draw_MeshSet_Menu); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX,&BedLevelTools.mesh_x); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY,&BedLevelTools.mesh_y); - EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[BedLevelTools.mesh_x][BedLevelTools.mesh_y]); + EDIT_ITEM(ICON_MeshEditX, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX, &bedLevelTools.mesh_x); + EDIT_ITEM(ICON_MeshEditY, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY, &bedLevelTools.mesh_y); + EditZValueItem = EDIT_ITEM(ICON_MeshEditZ, MSG_MESH_EDIT_Z, onDrawPFloat2Menu, SetEditZValue, &bedlevel.z_values[bedLevelTools.mesh_x][bedLevelTools.mesh_y]); } UpdateMenu(EditMeshMenu); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 6d36cca92af7..27e1b4ebfacb 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -24,16 +24,32 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.2 - * Date: 2022/04/08 + * Version: 3.21.2 + * Date: 2022/12/02 */ +#include "../../../inc/MarlinConfig.h" + #include "dwin_defines.h" #include "dwinui.h" #include "../common/encoder.h" #include "../../../libs/BL24CXX.h" -#include "../../../inc/MarlinConfig.h" +#if EITHER(BABYSTEPPING, HAS_BED_PROBE) + #define HAS_ZOFFSET_ITEM 1 + #if !HAS_BED_PROBE + #define JUST_BABYSTEP 1 + #endif +#endif + +namespace GET_LANG(LCD_LANGUAGE) { + #define _MSG_PREHEAT(N) \ + LSTR MSG_PREHEAT_##N = _UxGT("Preheat ") PREHEAT_## N ##_LABEL; \ + LSTR MSG_PREHEAT_## N ##_SETTINGS = _UxGT("Preheat ") PREHEAT_## N ##_LABEL _UxGT(" Conf"); + #if PREHEAT_COUNT > 3 + REPEAT_S(4, PREHEAT_COUNT, _MSG_PREHEAT) + #endif +} enum processID : uint8_t { // Process ID @@ -44,7 +60,6 @@ enum processID : uint8_t { SetIntNoDraw, SetFloat, SetPFloat, - SelectFile, PrintProcess, Popup, Leveling, @@ -59,33 +74,85 @@ enum processID : uint8_t { }; enum pidresult_t : uint8_t { + PIDTEMP_START = 0, + PIDTEMPBED_START, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, - PID_EXTR_START, - PID_BED_START, - PID_DONE + PID_DONE, }; #define DWIN_CHINESE 123 #define DWIN_ENGLISH 0 +typedef struct { + // Color settings + uint16_t Background_Color; + uint16_t Cursor_Color; + uint16_t TitleBg_Color; + uint16_t TitleTxt_Color; + uint16_t Text_Color; + uint16_t Selected_Color; + uint16_t SplitLine_Color; + uint16_t Highlight_Color; + uint16_t StatusBg_Color; + uint16_t StatusTxt_Color; + uint16_t PopupBg_Color; + uint16_t PopupTxt_Color; + uint16_t AlertBg_Color; + uint16_t AlertTxt_Color; + uint16_t PercentTxt_Color; + uint16_t Barfill_Color; + uint16_t Indicator_Color; + uint16_t Coordinate_Color; + + // Temperatures + #if ENABLED(PIDTEMP) + int16_t HotendPidT = DEF_HOTENDPIDT; + #endif + #if ENABLED(PIDTEMPBED) + int16_t BedPidT = DEF_BEDPIDT; + #endif + #if (HAS_HOTEND || HAS_HEATED_BED) && HAS_PID_HEATING + int16_t PidCycles = DEF_PIDCYCLES; + #endif + #if ENABLED(PREVENT_COLD_EXTRUSION) + int16_t ExtMinT = EXTRUDE_MINTEMP; + #endif + #if ENABLED(PREHEAT_BEFORE_LEVELING) + int16_t BedLevT = LEVELING_BED_TEMP; + #endif + #if ENABLED(BAUD_RATE_GCODE) + bool Baud115K = false; + #endif + + bool FullManualTramming = false; + bool MediaAutoMount = ENABLED(HAS_SD_EXTENDER); + #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + uint8_t z_after_homing = DEF_Z_AFTER_HOMING; + #endif + #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) + LEDColor Led_Color = Def_Leds_Color; + #endif +} HMI_data_t; + +extern HMI_data_t HMI_data; +static constexpr size_t eeprom_data_size = sizeof(HMI_data_t); + typedef struct { int8_t Color[3]; // Color components - pidresult_t pidresult = PID_DONE; + TERN_(HAS_PID_HEATING, pidresult_t pidresult = PID_DONE); uint8_t Select = 0; // Auxiliary selector variable AxisEnum axis = X_AXIS; // Axis Select } HMI_value_t; typedef struct { uint8_t language; + bool printing_flag:1; // sd or host printing + bool abort_flag:1; // sd or host was aborted + bool pause_flag:1; // printing is paused bool percent_flag:1; // percent was override by M73 bool remain_flag:1; // remain was override by M73 - bool pause_flag:1; // printing is paused - bool pause_action:1; // flag a pause action - bool abort_flag:1; // printing is aborting - bool abort_action:1; // flag a aborting action - bool print_finish:1; // print was finished bool select_flag:1; // Popup button selected bool home_flag:1; // homing in course bool heat_flag:1; // 0: heating done 1: during heating @@ -105,6 +172,7 @@ extern millis_t dwin_heat_time; #endif // Tool Functions +uint32_t GetHash(char * str); #if ENABLED(EEPROM_SETTINGS) void WriteEeprom(); void ReadEeprom(); @@ -118,15 +186,14 @@ void DisableMotors(); void AutoLev(); void AutoHome(); #if HAS_PREHEAT - void DoPreheat0(); - void DoPreheat1(); - void DoPreheat2(); + #define _DOPREHEAT(N) void DoPreheat##N(); + REPEAT_1(PREHEAT_COUNT, _DOPREHEAT) #endif void DoCoolDown(); -#if HAS_HOTEND +#if ENABLED(PIDTEMP) void HotendPID(); #endif -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) void BedPID(); #endif #if ENABLED(BAUD_RATE_GCODE) @@ -151,6 +218,12 @@ void ParkHead(); void UBLSaveMesh(); void UBLLoadMesh(); #endif +#if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION) + void HostShutDown(); +#endif +#if !HAS_BED_PROBE + void HomeZandDisable(); +#endif // Other void Goto_PrintProcess(); @@ -160,7 +233,7 @@ void Goto_PowerLossRecovery(); void Goto_ConfirmToPrint(); void DWIN_Draw_Dashboard(const bool with_update); // Status Area void Draw_Main_Area(); // Redraw main area -void DWIN_DrawStatusLine(); // Draw simple status text +void DWIN_DrawStatusLine(const char *text = ""); // Draw simple status text void DWIN_RedrawDash(); // Redraw Dash and Status line void DWIN_RedrawScreen(); // Redraw all screen elements void HMI_MainMenu(); // Main process screen @@ -169,7 +242,6 @@ void HMI_Printing(); // Print page void HMI_ReturnScreen(); // Return to previous screen before popups void HMI_WaitForUser(); void HMI_SaveProcessID(const uint8_t id); -void HMI_SDCardInit(); void HMI_SDCardUpdate(); void EachMomentUpdate(); void update_variable(); @@ -179,12 +251,11 @@ void DWIN_CheckStatusMessage(); void DWIN_HomingStart(); void DWIN_HomingDone(); #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); + void DWIN_MeshUpdate(const int8_t cpos, const int8_t tpos, const_float_t zval); #endif void DWIN_LevelingStart(); void DWIN_LevelingDone(); -void DWIN_PidTuning(pidresult_t result); -void DWIN_Print_Started(const bool sd=false); +void DWIN_Print_Started(); void DWIN_Print_Pause(); void DWIN_Print_Resume(); void DWIN_Print_Finished(); @@ -228,6 +299,7 @@ void DWIN_RebootScreen(); #endif // Menu drawing functions +void Draw_Print_File_Menu(); void Draw_Control_Menu(); void Draw_AdvancedSettings_Menu(); void Draw_Prepare_Menu(); @@ -260,12 +332,6 @@ void Draw_Motion_Menu(); #if ENABLED(MESH_BED_LEVELING) void Draw_ManualMesh_Menu(); #endif -#if HAS_HOTEND - void Draw_Preheat1_Menu(); - void Draw_Preheat2_Menu(); - void Draw_Preheat3_Menu(); - void Draw_HotendPID_Menu(); -#endif void Draw_Temperature_Menu(); void Draw_MaxSpeed_Menu(); void Draw_MaxAccel_Menu(); @@ -273,9 +339,6 @@ void Draw_MaxAccel_Menu(); void Draw_MaxJerk_Menu(); #endif void Draw_Steps_Menu(); -#if HAS_HEATED_BED - void Draw_BedPID_Menu(); -#endif #if EITHER(HAS_BED_PROBE, BABYSTEPPING) void Draw_ZOffsetWiz_Menu(); #endif @@ -291,3 +354,12 @@ void Draw_Steps_Menu(); void Draw_EditMesh_Menu(); #endif #endif + +// PID +void DWIN_PidTuning(pidresult_t result); +#if ENABLED(PIDTEMP) + void Draw_HotendPID_Menu(); +#endif +#if ENABLED(PIDTEMPBED) + void Draw_BedPID_Menu(); +#endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index dffc26478d71..de3f40e2814b 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -19,44 +19,45 @@ * along with this program. If not, see . * */ -#pragma once - /** * DWIN general defines and data structs for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.11.2 - * Date: 2022/02/28 + * Version: 3.12.2 + * Date: 2022/08/08 */ -#define HAS_GCODE_PREVIEW 1 -#define HAS_PIDPLOT 1 -#define HAS_ESDIAG 1 -#define HAS_LOCKSCREEN 1 +#pragma once + //#define DEBUG_DWIN 1 //#define NEED_HEX_PRINT 1 -#include "../../../inc/MarlinConfigPre.h" -#include "../common/dwin_color.h" -#if ENABLED(LED_CONTROL_MENU) - #include "../../../feature/leds/leds.h" -#endif -#include - #if defined(__STM32F1__) || defined(STM32F1) #define DASH_REDRAW 1 #endif +#if DISABLED(PROBE_MANUALLY) && ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL) + #define HAS_ONESTEP_LEVELING 1 +#endif + +#if !HAS_BED_PROBE && ENABLED(BABYSTEPPING) + #define JUST_BABYSTEP 1 +#endif + +#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) + #define HAS_ZOFFSET_ITEM 1 +#endif + #define Def_Background_Color RGB( 1, 12, 8) -#define Def_Cursor_color RGB(20, 49, 31) -#define Def_TitleBg_color RGB( 0, 23, 16) -#define Def_TitleTxt_color Color_White +#define Def_Cursor_Color RGB(20, 49, 31) +#define Def_TitleBg_Color RGB( 0, 23, 16) +#define Def_TitleTxt_Color Color_White #define Def_Text_Color Color_White #define Def_Selected_Color Select_Color #define Def_SplitLine_Color RGB( 0, 23, 16) #define Def_Highlight_Color Color_White #define Def_StatusBg_Color RGB( 0, 23, 16) #define Def_StatusTxt_Color Color_Yellow -#define Def_PopupBg_color Color_Bg_Window +#define Def_PopupBg_Color Color_Bg_Window #define Def_PopupTxt_Color Popup_Text_Color #define Def_AlertBg_Color Color_Bg_Red #define Def_AlertTxt_Color Color_Yellow @@ -68,55 +69,15 @@ #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) #define Def_Leds_Color LEDColorWhite() #endif +#if ENABLED(CASELIGHT_USES_BRIGHTNESS) + #define Def_CaseLight_Brightness 255 +#endif +#ifdef Z_AFTER_HOMING + #define DEF_Z_AFTER_HOMING Z_AFTER_HOMING +#else + #define DEF_Z_AFTER_HOMING 0 +#endif +#define DEF_HOTENDPIDT TERN(PREHEAT_1_TEMP_BED, PREHEAT_1_TEMP_HOTEND, 195) +#define DEF_BEDPIDT TERN(PREHEAT_1_TEMP_BED, PREHEAT_1_TEMP_HOTEND, 60) +#define DEF_PIDCYCLES 5 -typedef struct { - // Color settings - uint16_t Background_Color = Def_Background_Color; - uint16_t Cursor_color = Def_Cursor_color; - uint16_t TitleBg_color = Def_TitleBg_color; - uint16_t TitleTxt_color = Def_TitleTxt_color; - uint16_t Text_Color = Def_Text_Color; - uint16_t Selected_Color = Def_Selected_Color; - uint16_t SplitLine_Color = Def_SplitLine_Color; - uint16_t Highlight_Color = Def_Highlight_Color; - uint16_t StatusBg_Color = Def_StatusBg_Color; - uint16_t StatusTxt_Color = Def_StatusTxt_Color; - uint16_t PopupBg_color = Def_PopupBg_color; - uint16_t PopupTxt_Color = Def_PopupTxt_Color; - uint16_t AlertBg_Color = Def_AlertBg_Color; - uint16_t AlertTxt_Color = Def_AlertTxt_Color; - uint16_t PercentTxt_Color = Def_PercentTxt_Color; - uint16_t Barfill_Color = Def_Barfill_Color; - uint16_t Indicator_Color = Def_Indicator_Color; - uint16_t Coordinate_Color = Def_Coordinate_Color; - // Temperatures - #if HAS_HOTEND && defined(PREHEAT_1_TEMP_HOTEND) - int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND; - #endif - #if HAS_HEATED_BED && defined(PREHEAT_1_TEMP_BED) - int16_t BedPidT = PREHEAT_1_TEMP_BED; - #endif - #if HAS_HOTEND || HAS_HEATED_BED - int16_t PidCycles = 10; - #endif - #if ENABLED(PREVENT_COLD_EXTRUSION) - int16_t ExtMinT = EXTRUDE_MINTEMP; - #endif - #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) - int16_t BedLevT = LEVELING_BED_TEMP; - #endif - #if ENABLED(BAUD_RATE_GCODE) - bool Baud115K = false; - #endif - bool FullManualTramming = false; - #if ENABLED(MESH_BED_LEVELING) - float ManualZOffset = 0; - #endif - // Led - #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - LEDColor Led_Color = Def_Leds_Color; - #endif -} HMI_data_t; - -static constexpr size_t eeprom_data_size = sizeof(HMI_data_t); -extern HMI_data_t HMI_data; diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp index 59b6c0d328ae..552075f9dcb9 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -46,8 +46,8 @@ uint16_t HighlightYPos = 280; void Draw_Select_Highlight(const bool sel, const uint16_t ypos) { HighlightYPos = ypos; HMI_flag.select_flag = sel; - const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color, - c2 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color; + const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_Color, + c2 = sel ? HMI_data.PopupBg_Color : HMI_data.Highlight_Color; DWIN_Draw_Rectangle(0, c1, 25, ypos - 1, 126, ypos + 38); DWIN_Draw_Rectangle(0, c1, 24, ypos - 2, 127, ypos + 39); DWIN_Draw_Rectangle(0, c2, 145, ypos - 1, 246, ypos + 38); diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.h b/Marlin/src/lcd/e3v2/proui/dwin_popup.h index b4503ea7866b..f24aac582e6c 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.h @@ -44,7 +44,7 @@ void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick=nul void HMI_Popup(); inline void Draw_Popup_Bkgd() { - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330); + DWIN_Draw_Rectangle(1, HMI_data.PopupBg_Color, 14, 60, 258, 330); DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 60, 258, 330); } diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp index 5ed36e7dacf0..afb18f24dbc9 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -23,21 +23,17 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.18.1 - * Date: 2022/07/05 + * Version: 3.20.1 + * Date: 2022/10/25 */ -#include "../../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(DWIN_LCD_PROUI) -#include "../../../inc/MarlinConfig.h" +#include "dwin_defines.h" #include "dwin_lcd.h" #include "dwinui.h" -#include "dwin_defines.h" - -//#define DEBUG_OUT 1 -#include "../../../core/debug_out.h" xy_int_t DWINUI::cursor = { 0 }; uint16_t DWINUI::pencolor = Color_White; @@ -50,13 +46,6 @@ FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); void (*DWINUI::onTitleDraw)(TitleClass* title) = nullptr; void DWINUI::init() { - delay(750); // Delay for wait to wakeup screen - const bool hs = DWIN_Handshake(); UNUSED(hs); - #if ENABLED(DEBUG_DWIN) - SERIAL_ECHOPGM("DWIN_Handshake "); - SERIAL_ECHOLNF(hs ? F("ok.") : F("error.")); - #endif - DWIN_Frame_SetDir(1); cursor.reset(); pencolor = Color_White; textcolor = Def_Text_Color; @@ -210,6 +199,19 @@ void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t c DWIN_Draw_String(bShow, fid, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); } +// ------------------------- Icons -------------------------------// + +// Draw an Icon and select library automatically +// BG: The icon background display: false=Background filtering is not displayed, true=Background display +// libID: Icon library ID +// picID: Icon ID +// x/y: Upper-left point +void DWINUI::ICON_Show(bool BG, uint8_t icon, uint16_t x, uint16_t y) { + const uint8_t libID = ICON TERN_(HAS_CUSTOMICONS, + (icon / 100)); + const uint8_t picID = icon TERN_(HAS_CUSTOMICONS, % 100); + DWIN_ICON_Show(BG, false, !BG, libID, picID, x, y); +} + // ------------------------- Buttons ------------------------------// void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { @@ -320,8 +322,8 @@ uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) { // x/y: Upper-left point // mode : 0 : unchecked, 1 : checked void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) { - DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" ")); DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17); + DWIN_Draw_Rectangle(1, checked ? color : bcolor, x + 6, y + 6, x + 13, y + 13); } // Clear Menu by filling the menu area with background color diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h index a5444718312c..3dd37f30dfe6 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -19,7 +19,6 @@ * along with this program. If not, see . * */ -#pragma once /** * DWIN Enhanced implementation for PRO UI @@ -28,10 +27,14 @@ * Date: 2022/07/05 */ -#include "dwin_lcd.h" +#pragma once + +#include "../../../inc/MarlinConfigPre.h" + #include "../common/dwin_set.h" #include "../common/dwin_font.h" #include "../common/dwin_color.h" +#include "dwin_lcd.h" // Extra Icons #define ICON_AdvSet ICON_Language @@ -74,6 +77,10 @@ #define ICON_MaxPosX ICON_MoveX #define ICON_MaxPosY ICON_MoveY #define ICON_MaxPosZ ICON_MoveZ +#define ICON_MeshEdit ICON_Homing +#define ICON_MeshEditX ICON_MoveX +#define ICON_MeshEditY ICON_MoveY +#define ICON_MeshEditZ ICON_MoveZ #define ICON_MeshNext ICON_Axis #define ICON_MeshPoints ICON_SetEndTemp #define ICON_MeshSave ICON_WriteEEPROM @@ -85,11 +92,22 @@ #define ICON_ParkPosY ICON_StepY #define ICON_ParkPosZ ICON_StepZ #define ICON_PhySet ICON_PrintSize -#define ICON_PIDbed ICON_SetBedTemp -#define ICON_PIDcycles ICON_ResumeEEPROM +#define ICON_PIDNozzle ICON_SetEndTemp +#define ICON_PIDBed ICON_SetBedTemp +#define ICON_PIDCycles ICON_ResumeEEPROM #define ICON_PIDValue ICON_Contact #define ICON_PrintStats ICON_PrintTime #define ICON_PrintStatsReset ICON_RemainTime +#define ICON_Preheat1 ICON_PLAPreheat +#define ICON_Preheat2 ICON_ABSPreheat +#define ICON_Preheat3 ICON_CustomPreheat +#define ICON_Preheat4 ICON_CustomPreheat +#define ICON_Preheat5 ICON_CustomPreheat +#define ICON_Preheat6 ICON_CustomPreheat +#define ICON_Preheat7 ICON_CustomPreheat +#define ICON_Preheat8 ICON_CustomPreheat +#define ICON_Preheat9 ICON_CustomPreheat +#define ICON_Preheat10 ICON_CustomPreheat #define ICON_ProbeDeploy ICON_SetEndTemp #define ICON_ProbeMargin ICON_PrintSize #define ICON_ProbeOffsetX ICON_StepX @@ -105,9 +123,28 @@ #define ICON_Scolor ICON_MaxSpeed #define ICON_SetBaudRate ICON_Setspeed #define ICON_SetCustomPreheat ICON_SetEndTemp +#define ICON_SetPreheat1 ICON_SetPLAPreheat +#define ICON_SetPreheat2 ICON_SetABSPreheat +#define ICON_SetPreheat3 ICON_SetCustomPreheat +#define ICON_SetPreheat4 ICON_SetCustomPreheat +#define ICON_SetPreheat5 ICON_SetCustomPreheat +#define ICON_SetPreheat6 ICON_SetCustomPreheat +#define ICON_SetPreheat7 ICON_SetCustomPreheat +#define ICON_SetPreheat8 ICON_SetCustomPreheat +#define ICON_SetPreheat9 ICON_SetCustomPreheat +#define ICON_SetPreheat10 ICON_SetCustomPreheat #define ICON_Sound ICON_Cool #define ICON_TBSetup ICON_Contact #define ICON_UBLActive ICON_HotendTemp +#define ICON_UBLActive ICON_HotendTemp +#define ICON_UBLSlot ICON_ResumeEEPROM +#define ICON_UBLSaveMesh ICON_WriteEEPROM +#define ICON_UBLLoadMesh ICON_ReadEEPROM +#define ICON_UBLTiltGrid ICON_PrintSize +#define ICON_UBLSmartFill ICON_StockConfiguration +#define ICON_ZAfterHome ICON_SetEndTemp + + #define ICON_CaseLight ICON_Motion #define ICON_LedControl ICON_Motion @@ -262,18 +299,25 @@ namespace DWINUI { return t; } + // Draw an Icon and select library automatically + // BG: The icon background display: false=Background filtering is not displayed, true=Background display + // libID: Icon library ID + // picID: Icon ID + // x/y: Upper-left point + void ICON_Show(bool BG, uint8_t icon, uint16_t x, uint16_t y); + // Draw an Icon with transparent background from the library ICON // icon: Icon ID // x/y: Upper-left point inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) { - DWIN_ICON_Show(ICON, icon, x, y); + ICON_Show(false, icon, x, y); } // Draw an Icon from the library ICON with its background // icon: Icon ID // x/y: Upper-left point inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) { - DWIN_ICON_Show(true, false, false, ICON, icon, x, y); + ICON_Show(true, icon, x, y); } // Draw a numeric integer value diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 19d726037ce9..0945d6977814 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -23,17 +23,13 @@ /** * DWIN Endstops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.2.2 - * Date: 2022/02/24 + * Version: 1.3.3 + * Date: 2022/10/07 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_LCD_PROUI) - -#include "dwin_defines.h" - -#if HAS_ESDIAG +#if BOTH(DWIN_LCD_PROUI, HAS_ESDIAG) #include "endstop_diag.h" @@ -64,7 +60,7 @@ void draw_es_label(FSTR_P const flabel=nullptr) { void draw_es_state(const bool is_hit) { const uint8_t LM = 130; DWINUI::cursor.x = LM; - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); + DWIN_Draw_Rectangle(1, HMI_data.PopupBg_Color, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN)); DWINUI::MoveBy(0, 25); } @@ -109,5 +105,4 @@ void ESDiagClass::Update() { DWIN_UpdateLCD(); } -#endif // HAS_ESDIAG -#endif // DWIN_LCD_PROUI +#endif // DWIN_LCD_PROUI && HAS_ESDIAG diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.h b/Marlin/src/lcd/e3v2/proui/endstop_diag.h index 316a1e1ed3d9..33f1d10d2da5 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.h +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.h @@ -24,8 +24,8 @@ /** * DWIN End Stops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.2.3 - * Date: 2022/02/24 + * Version: 1.3.2 + * Date: 2022/10/07 */ class ESDiagClass { diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index adb23a96646b..6411b669bbc8 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -23,8 +23,8 @@ /** * DWIN g-code thumbnail preview * Author: Miguel A. Risco-Castillo - * version: 2.1 - * Date: 2021/06/19 + * version: 3.1.2 + * Date: 2022/09/03 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -43,11 +43,8 @@ */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_LCD_PROUI) -#include "dwin_defines.h" - -#if HAS_GCODE_PREVIEW +#if BOTH(DWIN_LCD_PROUI, HAS_GCODE_PREVIEW) #include "../../../core/types.h" #include "../../marlinui.h" @@ -246,6 +243,10 @@ void Preview_DrawFromSD() { } } +void Preview_Invalidate() { + fileprop.thumbstart = 0; +} + bool Preview_Valid() { return !!fileprop.thumbstart; } @@ -254,5 +255,4 @@ void Preview_Reset() { fileprop.thumbsize = 0; } -#endif // HAS_GCODE_PREVIEW -#endif // DWIN_LCD_PROUI +#endif // HAS_GCODE_PREVIEW && DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.h b/Marlin/src/lcd/e3v2/proui/gcode_preview.h index 4417084a242d..c1949c5abc12 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.h +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.h @@ -1,8 +1,8 @@ /** * DWIN g-code thumbnail preview * Author: Miguel A. Risco-Castillo - * version: 2.1 - * Date: 2021/06/19 + * version: 3.1.2 + * Date: 2022/09/03 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -23,5 +23,6 @@ #pragma once void Preview_DrawFromSD(); +void Preview_Invalidate(); bool Preview_Valid(); void Preview_Reset(); diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp index 86c2095294b4..85f35582b268 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -23,18 +23,15 @@ /** * Lock screen implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.2.0 - * Date: 2022/04/11 + * Version: 2.3.2 + * Date: 2022/11/20 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_LCD_PROUI) +#if BOTH(DWIN_LCD_PROUI, HAS_LOCKSCREEN) #include "dwin_defines.h" - -#if HAS_LOCKSCREEN - #include "dwinui.h" #include "dwin.h" #include "lockscreen.h" @@ -75,6 +72,4 @@ void LockScreenClass::onEncoder(EncoderState encoder_diffState) { DWIN_UpdateLCD(); } -#endif // HAS_LOCKSCREEN - -#endif // DWIN_LCD_PROUI +#endif // DWIN_LCD_PROUI && HAS_LOCKSCREEN diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.h b/Marlin/src/lcd/e3v2/proui/lockscreen.h index 83d5530be3e4..cb75f2c7c0db 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.h +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.h @@ -24,8 +24,8 @@ /** * Lock screen implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.2.0 - * Date: 2022/04/11 + * Version: 2.3.2 + * Date: 2022/11/20 */ #include "../common/encoder.h" diff --git a/Marlin/src/lcd/e3v2/proui/menus.cpp b/Marlin/src/lcd/e3v2/proui/menus.cpp index 85594fecdbab..3267eec60d33 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.cpp +++ b/Marlin/src/lcd/e3v2/proui/menus.cpp @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.5.1 - * Date: 2022/05/23 + * Version: 1.9.1 + * Date: 2022/12/02 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -53,22 +53,23 @@ int8_t MenuItemTotal = 0; int8_t MenuItemCount = 0; -MenuItemClass** MenuItems = nullptr; +CustomMenuItemClass** MenuItems = nullptr; MenuClass *CurrentMenu = nullptr; MenuClass *PreviousMenu = nullptr; -void (*onMenuDraw)(MenuClass* menu) = nullptr; -void (*onCursorErase)(const int8_t line) = nullptr; -void (*onCursorDraw)(const int8_t line) = nullptr; MenuData_t MenuData; // Menuitem Drawing functions ================================================= void Draw_Title(TitleClass* title) { - DWIN_Draw_Rectangle(1, HMI_data.TitleBg_color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); + DWIN_Draw_Rectangle(1, HMI_data.TitleBg_Color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); if (title->frameid) DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1); else - DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); + #if ENABLED(TITLE_CENTERED) + DWINUI::Draw_CenteredString(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_Color, HMI_data.TitleBg_Color, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); + #else + DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_Color, HMI_data.TitleBg_Color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); + #endif } void Draw_Menu(MenuClass* menu) { @@ -78,7 +79,7 @@ void Draw_Menu(MenuClass* menu) { void Draw_Menu_Cursor(const int8_t line) { const uint16_t ypos = MYPOS(line); - DWINUI::Draw_Box(1, HMI_data.Cursor_color, {0, ypos, 15, MLINE - 1}); + DWINUI::Draw_Box(1, HMI_data.Cursor_Color, {0, ypos, 15, MLINE - 1}); } void Erase_Menu_Cursor(const int8_t line) { @@ -86,17 +87,39 @@ void Erase_Menu_Cursor(const int8_t line) { DWINUI::Draw_Box(1, HMI_data.Background_Color, {0, ypos, 15, MLINE - 1}); } -void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, const char * const label /*=nullptr*/, bool more /*=false*/) { +void Erase_Menu_Text(const int8_t line) { + if (line < 0 || line >= TROWS) return; + const uint16_t ypos = MYPOS(line) + 1; + DWINUI::Draw_Box(1, HMI_data.Background_Color, {LBLX, ypos, DWIN_WIDTH - LBLX, MLINE - 2}); +} + +void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, const char * const label /*=nullptr*/, bool more /*=false*/, bool selected /*=false*/) { if (icon) DWINUI::Draw_Icon(icon, ICOX, MBASE(line) - 3); if (label) DWINUI::Draw_String(LBLX, MBASE(line) - 1, (char*)label); if (more) DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); + if (selected) Draw_Menu_Cursor(line); DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); } +void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, FSTR_P label /*=nullptr*/, bool more /*=false*/, bool selected /*=false*/) { + Draw_Menu_Line(line, icon, FTOP(label), more, selected); +} + void Draw_Chkb_Line(const uint8_t line, const bool checked) { DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked); } +void Show_Chkb_Line(const bool checked) { + const uint8_t line = CurrentMenu->line(); + DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked); + DWIN_UpdateLCD(); +} + +void Toogle_Chkb_Line(bool &checked) { + checked = !checked; + Show_Chkb_Line(checked); +} + void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value /*=0*/) { DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value); } @@ -140,22 +163,11 @@ void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const flo DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value); } -void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp) { const float value = *(float*)static_cast(menuitem)->value; - const int8_t dp = UNITFDIGITS; onDrawFloatMenu(menuitem, line, dp, value); } -void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - onDrawFloatMenu(menuitem, line, 2, value); -} - -void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - onDrawFloatMenu(menuitem, line, 3, value); -} - void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) { onDrawMenuItem(menuitem, line); Draw_Chkb_Line(line, checked); @@ -166,13 +178,15 @@ void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, val); } -void DrawItemEdit() { +void DrawItemEdit(const bool selected) { + const uint16_t bcolor = selected ? HMI_data.Selected_Color : HMI_data.Background_Color; + const uint8_t iNum = 4 - ((MenuData.dp > 0) ? (MenuData.dp - 1) : 0); switch (checkkey) { case SetIntNoDraw: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; case SetInt: - case SetPInt: DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); break; + case SetPInt: DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); break; case SetFloat: - case SetPFloat: DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, MenuData.dp, VALX - MenuData.dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, MenuData.dp)); break; + case SetPFloat: DWINUI::Draw_Signed_Float(HMI_data.Text_Color, bcolor, iNum, MenuData.dp, VALX - 2 * DWINUI::fontWidth(), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, MenuData.dp)); break; default: break; } } @@ -209,7 +223,7 @@ void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, // Apply: update function when the encoder is pressed void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { SetOnClick(process, lo, hi, 0, val, Apply, LiveUpdate); - Draw_Menu_IntValue(HMI_data.Selected_Color, CurrentMenu->line(), 4, MenuData.Value); + DrawItemEdit(true); } // Generic onclick event for float values @@ -222,7 +236,7 @@ void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { const int32_t value = round(val * POW(10, dp)); SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val); + DrawItemEdit(true); } // Generic onclick event for integer values @@ -271,8 +285,8 @@ void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)( // Generic menu control using the encoder void HMI_Menu() { EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; if (CurrentMenu) { + if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_ENTER) CurrentMenu->onClick(); else @@ -280,65 +294,46 @@ void HMI_Menu() { } } -// Get an integer value using the encoder without draw anything -// lo: low limit -// hi: high limit +// Get a value using the encoder +// draw : draw the value // Return value: // 0 : no change // 1 : live change // 2 : apply change -int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) { +int8_t HMI_Get(bool draw) { + const int32_t lo = MenuData.MinValue; + const int32_t hi = MenuData.MaxValue; const int32_t cval = MenuData.Value; - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, MenuData.Value)) { - EncoderRate.enabled = false; - checkkey = Menu; - return 2; - } - LIMIT(MenuData.Value, lo, hi); - } - return int8_t(cval != MenuData.Value); -} - -// Get an integer value using the encoder -// lo: low limit -// hi: high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetInt(const int32_t lo, const int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + EncoderState encoder_diffState = get_encoder_state(); if (encoder_diffState != ENCODER_DIFF_NO) { if (Apply_Encoder(encoder_diffState, MenuData.Value)) { EncoderRate.enabled = false; - DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Background_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); + if (draw) DrawItemEdit(false); checkkey = Menu; return 2; } LIMIT(MenuData.Value, lo, hi); - DrawItemEdit(); - return 1; } - return 0; + const bool change = cval != MenuData.Value; + if (change) DrawItemEdit(true); + return int8_t(change); } -// Set an integer using the encoder -void HMI_SetInt() { - int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); +// Set and draw a value using the encoder +void HMI_SetDraw() { + int8_t val = HMI_Get(true); switch (val) { - case 0: return; break; + case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; case 2: if (MenuData.Apply) MenuData.Apply(); break; } } -// Set an integer without drawing -void HMI_SetIntNoDraw() { - int8_t val = HMI_GetIntNoDraw(MenuData.MinValue, MenuData.MaxValue); +// Set an value without drawing +void HMI_SetNoDraw() { + int8_t val = HMI_Get(false); switch (val) { - case 0: return; break; + case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; case 2: if (MenuData.Apply) MenuData.Apply(); break; } @@ -346,7 +341,7 @@ void HMI_SetIntNoDraw() { // Set an integer pointer variable using the encoder void HMI_SetPInt() { - int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); + int8_t val = HMI_Get(true); switch (val) { case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; @@ -354,43 +349,9 @@ void HMI_SetPInt() { } } -// Get a scaled float value using the encoder -// dp: decimal places -// lo: scaled low limit -// hi: scaled high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, MenuData.Value)) { - EncoderRate.enabled = false; - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); - checkkey = Menu; - return 2; - } - LIMIT(MenuData.Value, lo, hi); - DrawItemEdit(); - return 1; - } - return 0; -} - -// Set a scaled float using the encoder -void HMI_SetFloat() { - const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); - switch (val) { - case 0: return; - case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; - case 2: if (MenuData.Apply) MenuData.Apply(); break; - } -} - // Set a scaled float pointer variable using the encoder void HMI_SetPFloat() { - const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); + const int8_t val = HMI_Get(true); switch (val) { case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; @@ -398,7 +359,7 @@ void HMI_SetPFloat() { } } -// Menu Classes =============================================================== +// Menu Class =============================================================== MenuClass::MenuClass() { selected = 0; @@ -407,10 +368,10 @@ MenuClass::MenuClass() { void MenuClass::draw() { MenuTitle.draw(); - if (onMenuDraw != nullptr) onMenuDraw(this); + Draw_Menu(this); for (int8_t i = 0; i < MenuItemCount; i++) MenuItems[i]->draw(i - topline); - if (onCursorDraw != nullptr) onCursorDraw(line()); + Draw_Menu_Cursor(line()); DWIN_UpdateLCD(); } @@ -419,7 +380,7 @@ void MenuClass::onScroll(bool dir) { if (dir) sel++; else sel--; LIMIT(sel, 0, MenuItemCount - 1); if (sel != selected) { - if (onCursorErase != nullptr) onCursorErase(line()); + Erase_Menu_Cursor(line()); DWIN_UpdateLCD(); if ((sel - topline) == TROWS) { DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1); @@ -432,7 +393,7 @@ void MenuClass::onScroll(bool dir) { MenuItems[sel]->draw(0); } selected = sel; - if (onCursorDraw != nullptr) onCursorDraw(line()); + Draw_Menu_Cursor(line()); DWIN_UpdateLCD(); } } @@ -441,11 +402,11 @@ void MenuClass::onClick() { if (MenuItems[selected]->onClick != nullptr) (*MenuItems[selected]->onClick)(); } -MenuItemClass *MenuClass::SelectedItem() { +CustomMenuItemClass *MenuClass::SelectedItem() { return MenuItems[selected]; } -MenuItemClass** MenuClass::Items() { +CustomMenuItemClass** MenuClass::Items() { return MenuItems; } @@ -455,40 +416,47 @@ int8_t MenuClass::count() { /* MenuItem Class ===========================================================*/ -MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) { - icon = cicon; +void CustomMenuItemClass::draw(int8_t line) { + if (line < 0 || line >= TROWS) return; + if (onDraw != nullptr) (*onDraw)(static_cast(this), line); +}; + +void CustomMenuItemClass::redraw(bool erase /*=false*/) { + const int8_t line = CurrentMenu->line(this->pos); + if (erase) Erase_Menu_Text(line); + draw(line); +} + +CustomMenuItemClass::CustomMenuItemClass(OnDrawItem ondraw, OnClickItem onclick) { onClick = onclick; - onDraw = ondraw; - const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text)); - memcpy(&caption[0], text, len); - caption[len] = '\0'; + onDraw = ondraw; } -MenuItemClass::MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) { +MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItemClass(ondraw, onclick) { + icon = cicon; + SetCaption(text); +} + +MenuItemClass::MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItemClass(ondraw, onclick) { icon = cicon; - onClick = onclick; - onDraw = ondraw; caption[0] = '\0'; frameid = id; frame = { x1, y1, x2, y2 }; } +void MenuItemClass::SetCaption(const char * const text) { + const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text)); + memcpy(&caption[0], text, len); + caption[len] = '\0'; +} + void MenuItemClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { caption[0] = '\0'; frameid = id; frame = { x1, y1, x2, y2 }; } -void MenuItemClass::draw(int8_t line) { - if (!WITHIN(line, 0, TROWS - 1)) return; - if (onDraw != nullptr) (*onDraw)(this, line); -}; - -void MenuItemClass::redraw() { - draw(CurrentMenu->line(this->pos)); -} - -MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemClass(cicon, text, ondraw, onclick) { +MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItemClass(cicon, text, ondraw, onclick) { value = val; }; @@ -505,40 +473,58 @@ void MenuItemsClear() { void MenuItemsPrepare(int8_t totalitems) { MenuItemsClear(); - MenuItemTotal = totalitems; - MenuItems = new MenuItemClass*[totalitems]; + MenuItemTotal = _MIN(totalitems, MENU_MAX_ITEMS); + MenuItems = new CustomMenuItemClass*[totalitems]; } -MenuItemClass* MenuItemsAdd(MenuItemClass* menuitem) { +bool IsMenu(MenuClass* _menu) { + return ((checkkey == Menu) && !!CurrentMenu && (CurrentMenu == _menu)); +} + +template +T* MenuItemAdd(T* menuitem) { MenuItems[MenuItemCount] = menuitem; menuitem->pos = MenuItemCount++; return menuitem; } -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text/*=nullptr*/, void (*ondraw)(MenuItemClass* menuitem, int8_t line)/*=nullptr*/, void (*onclick)()/*=nullptr*/) { +CustomMenuItemClass* MenuItemAdd(OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) { + if (MenuItemCount < MenuItemTotal) { + CustomMenuItemClass* menuitem = new CustomMenuItemClass(ondraw, onclick); + return MenuItemAdd(menuitem); + } + else return nullptr; +} + +MenuItemClass* MenuItemAdd(uint8_t cicon, const char * const text/*=nullptr*/, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) { if (MenuItemCount < MenuItemTotal) { MenuItemClass* menuitem = new MenuItemClass(cicon, text, ondraw, onclick); - return MenuItemsAdd(menuitem); + return MenuItemAdd(menuitem); } else return nullptr; } -MenuItemClass* MenuItemsAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)/*=nullptr*/, void (*onclick)()/*=nullptr*/) { +MenuItemClass* MenuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) { if (MenuItemCount < MenuItemTotal) { MenuItemClass* menuitem = new MenuItemClass(cicon, id, x1, y1, x2, y2, ondraw, onclick); - return MenuItemsAdd(menuitem); + return MenuItemAdd(menuitem); } else return nullptr; } -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) { +MenuItemClass* EditItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) { if (MenuItemCount < MenuItemTotal) { MenuItemClass* menuitem = new MenuItemPtrClass(cicon, text, ondraw, onclick, val); - return MenuItemsAdd(menuitem); + return MenuItemAdd(menuitem); } else return nullptr; } +void InitMenu() { + PreviousMenu = nullptr; + InvalidateMenu(); +} + bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems) { if (!menu) menu = new MenuClass(); const bool NotCurrent = (CurrentMenu != menu); @@ -549,6 +535,27 @@ bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems) { return NotCurrent; } +bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems) { + if (!menu) menu = new MenuClass(); + const bool NotCurrent = (CurrentMenu != menu); + if (NotCurrent) { + if (cn.w != 0) + menu->MenuTitle.SetFrame(cn.x, cn.y, cn.w, cn.h); + else + menu->MenuTitle.SetCaption(title); + MenuItemsPrepare(totalitems); + } + return NotCurrent; +} + +void InvalidateMenu() { + if (CurrentMenu) { + CurrentMenu->topline = 0; + CurrentMenu->selected = 0; + CurrentMenu = nullptr; + } +} + void UpdateMenu(MenuClass* &menu) { if (!menu) return; if (CurrentMenu != menu) { @@ -558,9 +565,9 @@ void UpdateMenu(MenuClass* &menu) { menu->draw(); } -void ReDrawMenu(const bool force/*=false*/) { - if (CurrentMenu && (force || checkkey == Menu)) CurrentMenu->draw(); - if (force) DrawItemEdit(); +void ReDrawMenu(bool force /*= false*/) { + if (CurrentMenu && (force || checkkey==Menu)) CurrentMenu->draw(); + if (force) DrawItemEdit(true); } #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h index 6a5f8786ca5f..9bc9d702bd30 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.h +++ b/Marlin/src/lcd/e3v2/proui/menus.h @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.5.1 - * Date: 2022/05/23 + * Version: 1.9.1 + * Date: 2022/12/02 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -44,6 +44,9 @@ #include "dwinui.h" +#define MENU_CHAR_LIMIT 24 +#define MENU_MAX_ITEMS TERN(SDSORT_LIMIT, SDSORT_LIMIT, 64) + typedef struct { int32_t MaxValue = 0; // Auxiliar max integer/scaled float value int32_t MinValue = 0; // Auxiliar min integer/scaled float value @@ -56,46 +59,60 @@ typedef struct { } MenuData_t; extern MenuData_t MenuData; -extern void (*onCursorErase)(const int8_t line); -extern void (*onCursorDraw)(const int8_t line); // Auxiliary Macros =========================================================== // Create and add a MenuItem object to the menu array -#define BACK_ITEM(H) MenuItemsAdd(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, H) -#define MENU_ITEM(V...) MenuItemsAdd(V) -#define EDIT_ITEM(V...) MenuItemsAdd(V) -#define MENU_ITEM_F(I,L,V...) MenuItemsAdd(I, GET_TEXT_F(L), V) -#define EDIT_ITEM_F(I,L,V...) MenuItemsAdd(I, GET_TEXT_F(L), V) +#define SET_MENU(I,L,V) SetMenu(I, GET_TEXT_F(L), V) +#define SET_MENU_F(I,L,V) SetMenu(I, F(L), V) +#define SET_MENU_R(I,R,L,V) SetMenu(I, R, GET_TEXT_F(L), V) + +#define BACK_ITEM(H) MenuItemAdd(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, H) +#define MENU_ITEM(I,L,V...) MenuItemAdd(I, GET_TEXT_F(L), V) +#define EDIT_ITEM(I,L,V...) EditItemAdd(I, GET_TEXT_F(L), V) +#define MENU_ITEM_F(I,L,V...) MenuItemAdd(I, F(L), V) +#define EDIT_ITEM_F(I,L,V...) EditItemAdd(I, F(L), V) // Menu Classes =============================================================== -class MenuItemClass { -protected: +class CustomMenuItemClass; +class MenuItemClass; + +typedef void (*OnDrawCustomItem)(CustomMenuItemClass* menuitem, int8_t line); +typedef void (*OnDrawItem)(MenuItemClass* menuitem, int8_t line); +typedef void (*OnClickItem)(); + +class CustomMenuItemClass { public: int8_t pos = 0; + OnDrawItem onDraw = nullptr; + void (*onClick)() = nullptr; + CustomMenuItemClass() {}; + CustomMenuItemClass(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); + virtual ~CustomMenuItemClass(){}; + virtual void draw(int8_t line); + void redraw(bool erase=false); +}; + +class MenuItemClass: public CustomMenuItemClass { +public: uint8_t icon = 0; - char caption[32] = ""; + char caption[MENU_CHAR_LIMIT] = ""; uint8_t frameid = 0; rect_t frame = {0}; - void (*onDraw)(MenuItemClass* menuitem, int8_t line) = nullptr; - void (*onClick)() = nullptr; - MenuItemClass() {}; - MenuItemClass(uint8_t cicon, const char * const text=nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); - // MenuItemClass(uint8_t cicon, FSTR_P text = nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr) : MenuItemClass(cicon, FTOP(text), ondraw, onclick){} - MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); + using CustomMenuItemClass::CustomMenuItemClass; + MenuItemClass(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); + MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); - virtual ~MenuItemClass(){}; - virtual void draw(int8_t line); - void redraw(); + void SetCaption(const char * const text = nullptr); }; class MenuItemPtrClass: public MenuItemClass { public: void *value = nullptr; using MenuItemClass::MenuItemClass; - MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val); - MenuItemPtrClass(uint8_t cicon, FSTR_P text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemPtrClass(cicon, FTOP(text), ondraw, onclick, val){} + MenuItemPtrClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val); + MenuItemPtrClass(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItemPtrClass(cicon, FTOP(text), ondraw, onclick, val){} }; class MenuClass { @@ -111,12 +128,11 @@ class MenuClass { virtual void draw(); virtual void onScroll(bool dir); void onClick(); - MenuItemClass* SelectedItem(); - static MenuItemClass** Items(); + CustomMenuItemClass* SelectedItem(); + static CustomMenuItemClass** Items(); }; extern MenuClass *CurrentMenu; extern MenuClass *PreviousMenu; -extern void (*onMenuDraw)(MenuClass* menu); // Menuitem Drawing functions ================================================= @@ -124,8 +140,12 @@ void Draw_Title(TitleClass* title); void Draw_Menu(MenuClass* menu); void Draw_Menu_Cursor(const int8_t line); void Erase_Menu_Cursor(const int8_t line); -void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false); +void Erase_Menu_Text(const int8_t line); +void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false, bool selected=false); +void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, FSTR_P label=nullptr, bool more=false, bool selected=false); void Draw_Chkb_Line(const uint8_t line, const bool checked); +void Show_Chkb_Line(const bool checked); +void Toogle_Chkb_Line(bool &checked); void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value=0); void onDrawMenuItem(MenuItemClass* menuitem, int8_t line); void onDrawSubMenu(MenuItemClass* menuitem, int8_t line); @@ -134,9 +154,11 @@ void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line); void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line); void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line); void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value); -void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line); -void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line); -void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line); +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp); +inline void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, UNITFDIGITS); }; +inline void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 2); }; +inline void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 3); }; +inline void onDrawPFloat4Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 4); }; void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked); void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line); @@ -153,22 +175,28 @@ void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)( // HMI user control functions ================================================= void HMI_Menu(); -void HMI_SetInt(); +void HMI_SetDraw(); +void HMI_SetNoDraw(); void HMI_SetPInt(); -void HMI_SetIntNoDraw(); -void HMI_SetFloat(); void HMI_SetPFloat(); // Menu auxiliary functions =================================================== +// Initialize menu +void InitMenu(); + // Create a new menu bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems); +bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems); + +// Invalidate CurrentMenu to prepare for full menu drawing +void InvalidateMenu(); //Update the Menu and Draw if it is valid void UpdateMenu(MenuClass* &menu); //Redraw the current Menu if it is valid -void ReDrawMenu(const bool force=false); +void ReDrawMenu(bool force = false); // Clear MenuItems array and free MenuItems elements void MenuItemsClear(); @@ -176,13 +204,17 @@ void MenuItemsClear(); // Prepare MenuItems array void MenuItemsPrepare(int8_t totalitems); +// Is the current menu = menu? +bool IsMenu(MenuClass* menu); + // Add elements to the MenuItems array -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text=nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); -inline MenuItemClass* MenuItemsAdd(uint8_t cicon, FSTR_P text = nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr) { - return MenuItemsAdd(cicon, FTOP(text), ondraw, onclick); +CustomMenuItemClass* MenuItemAdd(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); +MenuItemClass* MenuItemAdd(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); +inline MenuItemClass* MenuItemAdd(uint8_t cicon, FSTR_P text = nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr) { + return MenuItemAdd(cicon, FTOP(text), ondraw, onclick); } -MenuItemClass* MenuItemsAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val); -inline MenuItemClass* MenuItemsAdd(uint8_t cicon, FSTR_P text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) { - return MenuItemsAdd(cicon, FTOP(text), ondraw, onclick, val); +MenuItemClass* MenuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); +MenuItemClass* EditItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val); +inline MenuItemClass* EditItemAdd(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) { + return EditItemAdd(cicon, FTOP(text), ondraw, onclick, val); } diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp index 2511d33ff124..18cdffd00d62 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -113,8 +113,8 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) { Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER)); #if USE_UBL_VIEWER DWINUI::ClearMainArea(); - BedLevelTools.viewer_print_value = true; - BedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); + bedLevelTools.viewer_print_value = true; + bedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); #else DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); #endif @@ -127,7 +127,7 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) { DWINUI::Draw_Button(BTN_Continue, 86, 305); #if USE_UBL_VIEWER - BedLevelTools.Set_Mesh_Viewer_Status(); + bedLevelTools.Set_Mesh_Viewer_Status(); #else char str_1[6], str_2[6] = ""; ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), diff --git a/Marlin/src/lcd/e3v2/proui/plot.cpp b/Marlin/src/lcd/e3v2/proui/plot.cpp index cb1f6c2dda0f..75917320a45f 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.cpp +++ b/Marlin/src/lcd/e3v2/proui/plot.cpp @@ -23,8 +23,8 @@ /** * DWIN Single var plot * Author: Miguel A. Risco-Castillo - * Version: 2.0 - * Date: 2022/01/31 + * Version: 2.1.2 + * Date: 2022/11/20 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -44,14 +44,9 @@ #include "../../../inc/MarlinConfigPre.h" -#ifdef DWIN_LCD_PROUI - -#include "dwin_defines.h" - -#if HAS_PIDPLOT +#if BOTH(DWIN_LCD_PROUI, HAS_PIDPLOT) #include "plot.h" - #include "../../../core/types.h" #include "../../marlinui.h" #include "dwin_lcd.h" @@ -74,7 +69,7 @@ void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) y2 = frame.y + frame.h - 1; r = round((y2) - ref * scale); DWINUI::Draw_Box(1, Plot_Bg_Color, frame); - for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) DWIN_Draw_VLine(Line_Color, i * 50 + frame.x, frame.y, frame.h); + for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) DWIN_Draw_VLine(Line_Color, i * 50 + frame.x, frame.y, frame.h); DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1)); DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); } @@ -94,6 +89,4 @@ void PlotClass::Update(const float value) { grphpoints++; } -#endif // HAS_PIDPLOT - -#endif // DWIN_LCD_PROUI +#endif // DWIN_LCD_PROUI && HAS_PIDPLOT diff --git a/Marlin/src/lcd/e3v2/proui/plot.h b/Marlin/src/lcd/e3v2/proui/plot.h index 8522c530bd3f..ea15255fe53a 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.h +++ b/Marlin/src/lcd/e3v2/proui/plot.h @@ -23,8 +23,8 @@ /** * DWIN Single var plot * Author: Miguel A. Risco-Castillo - * Version: 1.0 - * Date: 2022/01/30 + * Version: 2.1.2 + * Date: 2022/11/20 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as diff --git a/Marlin/src/lcd/e3v2/proui/printstats.cpp b/Marlin/src/lcd/e3v2/proui/printstats.cpp index 5a7b6c9c4170..638cd3420809 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.cpp +++ b/Marlin/src/lcd/e3v2/proui/printstats.cpp @@ -23,8 +23,8 @@ /** * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.3.0 - * Date: 2022/02/24 + * Version: 1.4.2 + * Date: 2022/12/03 */ #include "../../../inc/MarlinConfigPre.h" @@ -79,4 +79,12 @@ void Goto_PrintStats() { HMI_SaveProcessID(WaitResponse); } +// Print Stats Reset popup +void Popup_ResetStats() { DWIN_Popup_ConfirmCancel(ICON_Info_0, GET_TEXT_F(MSG_RESET_STATS)); } +void OnClick_ResetStats() { + if (HMI_flag.select_flag) PrintStatsClass::Reset(); + HMI_ReturnScreen(); +} +void PrintStatsReset() { Goto_Popup(Popup_ResetStats, OnClick_ResetStats); } + #endif // DWIN_LCD_PROUI && PRINTCOUNTER diff --git a/Marlin/src/lcd/e3v2/proui/printstats.h b/Marlin/src/lcd/e3v2/proui/printstats.h index 705c923da41b..4a383068864b 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.h +++ b/Marlin/src/lcd/e3v2/proui/printstats.h @@ -24,8 +24,8 @@ /** * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.3.0 - * Date: 2022/02/24 + * Version: 1.4.2 + * Date: 2022/12/03 */ class PrintStatsClass { @@ -37,3 +37,4 @@ class PrintStatsClass { extern PrintStatsClass PrintStats; void Goto_PrintStats(); +void PrintStatsReset(); diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp index 0da8bb36a780..03997fa95bea 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -46,6 +46,12 @@ #define SENDLINE_DBG_PGM_VAL(x,y,z) sendLine_P(PSTR(x)) #endif +// Append ".gcode" to filename, if requested. Used for some DGUS-clone displays with built-in filter. +// Filenames are limited to 26 characters, so the actual name for the FILENAME can be 20 characters at most. +// If a longer string is desired without "extension, use the ALTNAME macro to provide a (longer) alternative. +#define SPECIAL_MENU_FILENAME(A) A TERN_(ANYCUBIC_LCD_GCODE_EXT, ".gcode") +#define SPECIAL_MENU_ALTNAME(A, B) TERN(ANYCUBIC_LCD_GCODE_EXT, A ".gcode", B) + AnycubicTFTClass AnycubicTFT; char AnycubicTFTClass::TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE]; @@ -383,8 +389,8 @@ void AnycubicTFTClass::RenderCurrentFileList() { if (!isMediaInserted() && !SpecialMenu) { SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to render Current File List... J02"); - SENDLINE_PGM(""); - SENDLINE_PGM(""); + SENDLINE_PGM("")); } else { if (CodeSeen('S')) @@ -403,58 +409,58 @@ void AnycubicTFTClass::RenderSpecialMenu(uint16_t selectedNumber) { switch (selectedNumber) { #if ENABLED(PROBE_MANUALLY) case 0: // First Page - SENDLINE_PGM("<01ZUp0.1>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<02ZUp0.02>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<03ZDn0.02>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<04ZDn0.1>"); - SENDLINE_PGM(""); + SENDLINE_PGM("<01ZUP~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<02ZUP~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<03ZDO~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<04ZDO~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); break; case 4: // Second Page - SENDLINE_PGM("<05PrehtBed>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<06SMeshLvl>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<07MeshNPnt>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<08HtEndPID>"); - SENDLINE_PGM(""); + SENDLINE_PGM("<05PRE~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<06MES~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_ALTNAME("", "")); + SENDLINE_PGM("<07NEX~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<08PID~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); break; case 8: // Third Page - SENDLINE_PGM("<09HtBedPID>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<10FWDeflts>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<11SvEEPROM>"); - SENDLINE_PGM(""); - SENDLINE_PGM(""); - SENDLINE_PGM(""); + SENDLINE_PGM("<09PID~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<10FWD~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<11SAV~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("")); break; #else case 0: // First Page - SENDLINE_PGM("<01PrehtBed>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<02ABL>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<03HtEndPID>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<04HtBedPID>"); - SENDLINE_PGM(""); + SENDLINE_PGM("<01PRE~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<02ABL~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<03PID~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_ALTNAME("", "")); + SENDLINE_PGM("<04PID~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_ALTNAME("", "")); break; case 4: // Second Page - SENDLINE_PGM("<05FWDeflts>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<06SvEEPROM>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<07SendM108>"); - SENDLINE_PGM(""); - SENDLINE_PGM(""); - SENDLINE_PGM(""); + SENDLINE_PGM("<05FWD~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<06SAV~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<06SEN~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_ALTNAME("", "")); + SENDLINE_PGM("")); break; #endif // PROBE_MANUALLY @@ -478,8 +484,8 @@ void AnycubicTFTClass::RenderCurrentFolder(uint16_t selectedNumber) { for (cnt = selectedNumber; cnt <= max_files; cnt++) { if (cnt == 0) { // Special Entry if (currentFileList.isAtRootDir()) { - SENDLINE_PGM(""); - SENDLINE_PGM(""); + SENDLINE_PGM("")); } else { SENDLINE_PGM("/.."); diff --git a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h index b6773db03be9..c307ff44787e 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h @@ -39,7 +39,6 @@ enum DGUSLCD_Screens : uint8_t; -//#define DEBUG_DGUSLCD #define DEBUG_OUT ENABLED(DEBUG_DGUSLCD) #include "../../../core/debug_out.h" diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index 0f34d76cfac4..37543a237c0b 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -152,10 +152,10 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) { // Send an uint8_t between 0 and 100 to a variable scale to 0..255 void DGUSScreenHandler::DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr) { if (var.memadr) { - uint16_t value = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPGM("FAN value get:", value); + const uint16_t value = BE16_P(val_ptr); + DEBUG_ECHOLNPGM("Got percent:", value); *(uint8_t*)var.memadr = map(constrain(value, 0, 100), 0, 100, 0, 255); - DEBUG_ECHOLNPGM("FAN value change:", *(uint8_t*)var.memadr); + DEBUG_ECHOLNPGM("Set uint8:", *(uint8_t*)var.memadr); } } @@ -264,10 +264,10 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) static uint16_t period = 0; static uint16_t index = 0; //DEBUG_ECHOPGM(" DGUSLCD_SendWaitingStatusToDisplay ", var.VP); - //DEBUG_ECHOLNPGM(" data ", swap16(index)); + //DEBUG_ECHOLNPGM(" data ", BE16_P(&index)); if (period++ > DGUS_UI_WAITING_STATUS_PERIOD) { dgusdisplay.WriteVariable(var.VP, index); - //DEBUG_ECHOLNPGM(" data ", swap16(index)); + //DEBUG_ECHOLNPGM(" data ", BE16_P(&index)); if (++index >= DGUS_UI_WAITING_STATUS) index = 0; period = 0; } @@ -306,7 +306,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) void DGUSScreenHandler::DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable& var, void *val_ptr) { auto old_top = top_file; - const int16_t scroll = (int16_t)swap16(*(uint16_t*)val_ptr); + const int16_t scroll = (int16_t)BE16_P(val_ptr); if (scroll) { top_file += scroll; DEBUG_ECHOPGM("new topfile calculated:", top_file); @@ -391,7 +391,7 @@ void DGUSScreenHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr } void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) { - celsius_t newvalue = swap16(*(uint16_t*)val_ptr); + celsius_t newvalue = BE16_P(val_ptr); celsius_t acceptedvalue; switch (var.VP) { @@ -426,7 +426,7 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) { #if HAS_EXTRUDERS - uint16_t newvalue = swap16(*(uint16_t*)val_ptr); + const uint16_t newvalue = BE16_P(val_ptr); uint8_t target_extruder; switch (var.VP) { default: return; @@ -446,7 +446,7 @@ void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_p void DGUSScreenHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleManualExtrude"); - int16_t movevalue = swap16(*(uint16_t*)val_ptr); + const int16_t movevalue = BE16_P(val_ptr); float target = movevalue * 0.01f; ExtUI::extruder_t target_extruder; @@ -468,19 +468,19 @@ void DGUSScreenHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) void DGUSScreenHandler::HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleManualMoveOption"); - *(uint16_t*)var.memadr = swap16(*(uint16_t*)val_ptr); + *(uint16_t*)var.memadr = BE16_P(val_ptr); } #endif void DGUSScreenHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMotorLockUnlock"); - const int16_t lock = swap16(*(uint16_t*)val_ptr); + const int16_t lock = BE16_P(val_ptr); queue.enqueue_one_now(lock ? F("M18") : F("M17")); } void DGUSScreenHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleSettings"); - uint16_t value = swap16(*(uint16_t*)val_ptr); + const uint16_t value = BE16_P(val_ptr); switch (value) { default: break; case 1: @@ -494,11 +494,9 @@ void DGUSScreenHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); - - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPGM("value_raw:", value_raw); - float value = (float)value_raw / 10; + const uint16_t value_raw = BE16_P(val_ptr); + DEBUG_ECHOLNPGM("HandleStepPerMMChanged:", value_raw); + const float value = (float)value_raw / 10; ExtUI::axis_t axis; switch (var.VP) { case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break; @@ -510,15 +508,12 @@ void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ ExtUI::setAxisSteps_per_mm(value, axis); DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(axis)); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); - - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPGM("value_raw:", value_raw); - float value = (float)value_raw / 10; + const uint16_t value_raw = BE16_P(val_ptr); + DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged:", value_raw); + const float value = (float)value_raw / 10; ExtUI::extruder_t extruder; switch (var.VP) { default: return; @@ -575,7 +570,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo void DGUSScreenHandler::HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleProbeOffsetZChanged"); - const float offset = float(int16_t(swap16(*(uint16_t*)val_ptr))) / 100.0f; + const float offset = float(int16_t(BE16_P(val_ptr))) / 100.0f; ExtUI::setZOffset_mm(offset); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel return; @@ -621,7 +616,7 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr void DGUSScreenHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandlePreheat"); - const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); + const uint16_t preheat_option = BE16_P(val_ptr); switch (preheat_option) { default: switch (var.VP) { @@ -644,7 +639,7 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr #if ENABLED(POWER_LOSS_RECOVERY) void DGUSScreenHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value = swap16(*(uint16_t*)val_ptr); + uint16_t value = BE16_P(val_ptr); if (value) { queue.inject(F("M1000")); dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), 32, true); diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h index 4b627fe0f69f..575a71d2892f 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h @@ -42,6 +42,10 @@ #endif +// endianness swap +#define BE16_P(V) ( ((uint8_t*)(V))[0] << 8U | ((uint8_t*)(V))[1] ) +#define BE32_P(V) ( ((uint8_t*)(V))[0] << 24U | ((uint8_t*)(V))[1] << 16U | ((uint8_t*)(V))[2] << 8U | ((uint8_t*)(V))[3] ) + #if ENABLED(DGUS_LCD_UI_ORIGIN) #include "origin/DGUSScreenHandler.h" #elif ENABLED(DGUS_LCD_UI_MKS) diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp index a4c0997bf8a0..0e825c9e7c33 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp @@ -63,7 +63,7 @@ const uint16_t VPList_Main[] PROGMEM = { VP_XPos, VP_YPos, VP_ZPos, VP_Fan0_Percentage, VP_Feedrate_Percentage, - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) VP_PrintProgress_Percentage, #endif 0x0000 diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp index 4c850183da0f..6e4c76ca68df 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp @@ -63,7 +63,7 @@ const uint16_t VPList_Main[] PROGMEM = { VP_XPos, VP_YPos, VP_ZPos, VP_Fan0_Percentage, VP_Feedrate_Percentage, - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) VP_PrintProgress_Percentage, #endif 0x0000 diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index da7fa52774af..bbb16414bba0 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -185,7 +185,7 @@ const uint16_t VPList_Main[] PROGMEM = { VP_XPos, VP_YPos, VP_ZPos, VP_Fan0_Percentage, VP_Feedrate_Percentage, - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) VP_PrintProgress_Percentage, #endif 0x0000 diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 490cacd1b270..22d0c7f7e05d 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -54,9 +54,6 @@ bool DGUSAutoTurnOff = false; MKS_Language mks_language_index; // Initialized by settings.load() -// endianness swap -uint32_t swap32(const uint32_t value) { return (value & 0x000000FFU) << 24U | (value & 0x0000FF00U) << 8U | (value & 0x00FF0000U) >> 8U | (value & 0xFF000000U) >> 24U; } - #if 0 void DGUSScreenHandlerMKS::sendinfoscreen_ch(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4) { dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true); @@ -108,10 +105,10 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) void DGUSScreenHandlerMKS::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) { if (var.memadr) { - const uint16_t value = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPGM("FAN value get:", value); + const uint16_t value = BE16_P(val_ptr); + DEBUG_ECHOLNPGM("Got uint8:", value); *(uint8_t*)var.memadr = map(constrain(value, 0, 255), 0, 255, 0, 255); - DEBUG_ECHOLNPGM("FAN value change:", *(uint8_t*)var.memadr); + DEBUG_ECHOLNPGM("Set uint8:", *(uint8_t*)var.memadr); } } @@ -152,7 +149,7 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { #if ENABLED(SDSUPPORT) 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; + uint16_t touched_nr = (int16_t)BE16_P(val_ptr) + top_file; if (touched_nr != 0x0F && touched_nr > filelist.count()) return; if (!filelist.seek(touched_nr) && touched_nr != 0x0F) return; @@ -191,7 +188,7 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { void DGUSScreenHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) { if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes. - switch (swap16(*(uint16_t*)val_ptr)) { + switch (BE16_P(val_ptr)) { case 0: { // Resume auto cs = getCurrentScreen(); if (runout_mks.runout_status != RUNOUT_WAITING_STATUS && runout_mks.runout_status != UNRUNOUT_STATUS) { @@ -268,7 +265,7 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { #else void DGUSScreenHandlerMKS::PrintReturn(DGUS_VP_Variable& var, void *val_ptr) { - uint16_t value = swap16(*(uint16_t*)val_ptr); + const uint16_t value = BE16_P(val_ptr); if (value == 0x0F) GotoScreen(DGUSLCD_SCREEN_MAIN); } #endif // SDSUPPORT @@ -315,7 +312,7 @@ void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandlerMKS::ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t target = swap16(*(uint16_t *)val_ptr); + const uint16_t target = BE16_P(val_ptr); DEBUG_ECHOLNPGM(" back = 0x%x", target); switch (target) { } @@ -331,7 +328,7 @@ void DGUSScreenHandlerMKS::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) void DGUSScreenHandlerMKS::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetTurnOffCtrl\n"); - const uint16_t value = swap16(*(uint16_t *)val_ptr); + const uint16_t value = BE16_P(val_ptr); switch (value) { case 0 ... 1: DGUSAutoTurnOff = (bool)value; break; default: break; @@ -340,7 +337,7 @@ void DGUSScreenHandlerMKS::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) void DGUSScreenHandlerMKS::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetMinExtrudeTemp"); - const uint16_t value = swap16(*(uint16_t *)val_ptr); + const uint16_t value = BE16_P(val_ptr); TERN_(PREVENT_COLD_EXTRUSION, thermalManager.extrude_min_temp = value); mks_min_extrusion_temp = value; settings.save(); @@ -348,7 +345,7 @@ void DGUSScreenHandlerMKS::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_pt void DGUSScreenHandlerMKS::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetZoffsetDistance"); - const uint16_t value = swap16(*(uint16_t *)val_ptr); + const uint16_t value = BE16_P(val_ptr); float val_distance = 0; switch (value) { case 0: val_distance = 0.01; break; @@ -362,11 +359,11 @@ void DGUSScreenHandlerMKS::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_p void DGUSScreenHandlerMKS::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("\nGetManualMovestep"); - *(uint16_t *)var.memadr = swap16(*(uint16_t *)val_ptr); + *(uint16_t *)var.memadr = BE16_P(val_ptr); } void DGUSScreenHandlerMKS::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t eep_flag = swap16(*(uint16_t *)val_ptr); + const uint16_t eep_flag = BE16_P(val_ptr); switch (eep_flag) { case 0: settings.save(); @@ -384,7 +381,7 @@ void DGUSScreenHandlerMKS::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandlerMKS::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t z_value = swap16(*(uint16_t *)val_ptr); + const uint16_t z_value = BE16_P(val_ptr); switch (z_value) { case 0: Z_distance = 0.01; break; case 1: Z_distance = 0.1; break; @@ -396,22 +393,22 @@ void DGUSScreenHandlerMKS::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) void DGUSScreenHandlerMKS::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) { #if HAS_BED_PROBE - int32_t value = swap32(*(int32_t *)val_ptr); - float Offset = value / 100.0f; + const int32_t value = BE32_P(val_ptr); + const float Offset = value / 100.0f; DEBUG_ECHOLNPGM("\nget int6 offset >> ", value, 6); - #endif - switch (var.VP) { - case VP_OFFSET_X: TERN_(HAS_BED_PROBE, probe.offset.x = Offset); break; - case VP_OFFSET_Y: TERN_(HAS_BED_PROBE, probe.offset.y = Offset); break; - case VP_OFFSET_Z: TERN_(HAS_BED_PROBE, probe.offset.z = Offset); break; - default: break; - } - settings.save(); + switch (var.VP) { + default: break; + case VP_OFFSET_X: probe.offset.x = Offset; break; + case VP_OFFSET_Y: probe.offset.y = Offset; break; + case VP_OFFSET_Z: probe.offset.z = Offset; break; + } + settings.save(); + #endif } void DGUSScreenHandlerMKS::LanguageChange(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t lag_flag = swap16(*(uint16_t *)val_ptr); + const uint16_t lag_flag = BE16_P(val_ptr); switch (lag_flag) { case MKS_SimpleChinese: DGUS_LanguageDisplay(MKS_SimpleChinese); @@ -436,10 +433,10 @@ void DGUSScreenHandlerMKS::LanguageChange(DGUS_VP_Variable &var, void *val_ptr) #endif void DGUSScreenHandlerMKS::Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t lev_but = swap16(*(uint16_t *)val_ptr); #if ENABLED(MESH_BED_LEVELING) auto cs = getCurrentScreen(); #endif + const uint16_t lev_but = BE16_P(val_ptr); switch (lev_but) { case 0: #if ENABLED(AUTO_BED_LEVELING_BILINEAR) @@ -483,7 +480,7 @@ void DGUSScreenHandlerMKS::Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandlerMKS::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t mesh_dist = swap16(*(uint16_t *)val_ptr); + const uint16_t mesh_dist = BE16_P(val_ptr); switch (mesh_dist) { case 0: mesh_adj_distance = 0.01; break; case 1: mesh_adj_distance = 0.1; break; @@ -494,7 +491,7 @@ void DGUSScreenHandlerMKS::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void * void DGUSScreenHandlerMKS::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { #if ENABLED(MESH_BED_LEVELING) - const uint16_t mesh_value = swap16(*(uint16_t *)val_ptr); + const uint16_t mesh_value = BE16_P(val_ptr); // static uint8_t a_first_level = 1; char cmd_buf[30]; float offset = mesh_adj_distance; @@ -592,8 +589,8 @@ void DGUSScreenHandlerMKS::SD_FileBack(DGUS_VP_Variable&, void*) { } void DGUSScreenHandlerMKS::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t lcd_value = swap16(*(uint16_t *)val_ptr); + const uint16_t lcd_value = BE16_P(val_ptr); lcd_default_light = constrain(lcd_value, 10, 100); const uint16_t lcd_data[2] = { lcd_default_light, lcd_default_light }; @@ -601,7 +598,7 @@ void DGUSScreenHandlerMKS::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) } void DGUSScreenHandlerMKS::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) { - const int16_t point_value = swap16(*(uint16_t *)val_ptr); + const int16_t point_value = BE16_P(val_ptr); // Insist on leveling first time at this screen static bool first_level_flag = false; @@ -655,7 +652,7 @@ void DGUSScreenHandlerMKS::ManualAssistLeveling(DGUS_VP_Variable &var, void *val #define mks_max(a, b) ((a) > (b)) ? (a) : (b) void DGUSScreenHandlerMKS::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) { #if EITHER(HAS_TRINAMIC_CONFIG, HAS_STEALTHCHOP) - const uint16_t tmc_value = swap16(*(uint16_t*)val_ptr); + const uint16_t tmc_value = BE16_P(val_ptr); #endif switch (var.VP) { @@ -748,7 +745,7 @@ void DGUSScreenHandlerMKS::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleManualMove"); - int16_t movevalue = swap16(*(uint16_t*)val_ptr); + int16_t movevalue = BE16_P(val_ptr); // Choose Move distance if (manualMoveStep == 0x01) manualMoveStep = 10; @@ -893,7 +890,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandlerMKS::GetParkPos(DGUS_VP_Variable &var, void *val_ptr) { - const int16_t value_pos = swap16(*(int16_t*)val_ptr); + const int16_t value_pos = BE16_P(val_ptr); switch (var.VP) { case VP_X_PARK_POS: mks_park_pos.x = value_pos; break; @@ -907,7 +904,7 @@ void DGUSScreenHandlerMKS::GetParkPos(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenHandlerMKS::HandleChangeLevelPoint(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleChangeLevelPoint"); - const int16_t value_raw = swap16(*(int16_t*)val_ptr); + const int16_t value_raw = BE16_P(val_ptr); DEBUG_ECHOLNPGM("value_raw:", value_raw); *(int16_t*)var.memadr = value_raw; @@ -919,7 +916,7 @@ void DGUSScreenHandlerMKS::HandleChangeLevelPoint(DGUS_VP_Variable &var, void *v void DGUSScreenHandlerMKS::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -941,7 +938,7 @@ void DGUSScreenHandlerMKS::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *v void DGUSScreenHandlerMKS::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -966,7 +963,7 @@ void DGUSScreenHandlerMKS::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void DGUSScreenHandlerMKS::HandleMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMaxSpeedChange"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -988,7 +985,7 @@ void DGUSScreenHandlerMKS::HandleMaxSpeedChange(DGUS_VP_Variable &var, void *val void DGUSScreenHandlerMKS::HandleExtruderMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleExtruderMaxSpeedChange"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -1013,7 +1010,7 @@ void DGUSScreenHandlerMKS::HandleExtruderMaxSpeedChange(DGUS_VP_Variable &var, v void DGUSScreenHandlerMKS::HandleMaxAccChange(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMaxAccChange"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -1035,7 +1032,7 @@ void DGUSScreenHandlerMKS::HandleMaxAccChange(DGUS_VP_Variable &var, void *val_p void DGUSScreenHandlerMKS::HandleExtruderAccChange(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleExtruderAccChange"); - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + uint16_t value_raw = BE16_P(val_ptr); DEBUG_ECHOLNPGM("value_raw:", value_raw); float value = (float)value_raw; ExtUI::extruder_t extruder; @@ -1056,32 +1053,32 @@ void DGUSScreenHandlerMKS::HandleExtruderAccChange(DGUS_VP_Variable &var, void * } void DGUSScreenHandlerMKS::HandleTravelAccChange(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value_travel = swap16(*(uint16_t*)val_ptr); + uint16_t value_travel = BE16_P(val_ptr); planner.settings.travel_acceleration = (float)value_travel; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandlerMKS::HandleFeedRateMinChange(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value_t = swap16(*(uint16_t*)val_ptr); + uint16_t value_t = BE16_P(val_ptr); planner.settings.min_feedrate_mm_s = (float)value_t; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandlerMKS::HandleMin_T_F(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value_t_f = swap16(*(uint16_t*)val_ptr); + uint16_t value_t_f = BE16_P(val_ptr); planner.settings.min_travel_feedrate_mm_s = (float)value_t_f; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value_acc = swap16(*(uint16_t*)val_ptr); + uint16_t value_acc = BE16_P(val_ptr); planner.settings.acceleration = (float)value_acc; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } #if ENABLED(PREVENT_COLD_EXTRUSION) void DGUSScreenHandlerMKS::HandleGetExMinTemp(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr); + const uint16_t value_ex_min_temp = BE16_P(val_ptr); thermalManager.extrude_min_temp = value_ex_min_temp; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -1089,7 +1086,7 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) #if HAS_PID_HEATING void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t rawvalue = swap16(*(uint16_t*)val_ptr); + const uint16_t rawvalue = BE16_P(val_ptr); DEBUG_ECHOLNPGM("V1:", rawvalue); const float value = 1.0f * rawvalue; DEBUG_ECHOLNPGM("V2:", value); @@ -1125,9 +1122,9 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) #if ENABLED(BABYSTEPPING) void DGUSScreenHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleLiveAdjustZ"); - float step = ZOffset_distance; + const float step = ZOffset_distance; - uint16_t flag = swap16(*(uint16_t*)val_ptr); + const uint16_t flag = BE16_P(val_ptr); switch (flag) { case 0: if (step == 0.01) @@ -1159,34 +1156,26 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) z_offset_add += ZOffset_distance; break; - default: - break; + default: break; } ForceCompleteUpdate(); } #endif // BABYSTEPPING void DGUSScreenHandlerMKS::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("GetManualFilament"); - - uint16_t value_len = swap16(*(uint16_t*)val_ptr); + const uint16_t value_len = BE16_P(val_ptr); + const float value = (float)value_len; - float value = (float)value_len; - - DEBUG_ECHOLNPGM("Get Filament len value:", value); + DEBUG_ECHOLNPGM("GetManualFilament:", value); distanceFilament = value; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandlerMKS::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("GetManualFilamentSpeed"); - - uint16_t value_len = swap16(*(uint16_t*)val_ptr); - - DEBUG_ECHOLNPGM("filamentSpeed_mm_s value:", value_len); - + const uint16_t value_len = BE16_P(val_ptr); filamentSpeed_mm_s = value_len; + DEBUG_ECHOLNPGM("GetManualFilamentSpeed:", value_len); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -1205,7 +1194,7 @@ void DGUSScreenHandlerMKS::FilamentLoadUnload(DGUS_VP_Variable &var, void *val_p if (!print_job_timer.isPaused() && !queue.ring_buffer.empty()) return; - const uint16_t val_t = swap16(*(uint16_t*)val_ptr); + const uint16_t val_t = BE16_P(val_ptr); switch (val_t) { default: break; case 0: @@ -1291,7 +1280,7 @@ void DGUSScreenHandlerMKS::FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) uint8_t e_temp = 0; filament_data.heated = false; - uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); + uint16_t preheat_option = BE16_P(val_ptr); if (preheat_option >= 10) { // Unload filament type preheat_option -= 10; filament_data.action = 2; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h index fa5bf3039696..c4e3645f28c9 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h @@ -21,7 +21,10 @@ */ #pragma once -/* DGUS implementation written by coldtobi in 2019 for Marlin */ +/** + * DGUS implementation written by coldtobi in 2019. + * Updated for STM32G0B1RE by Protomosh in 2022. + */ #include "config/DGUS_Screen.h" #include "config/DGUS_Control.h" @@ -30,11 +33,13 @@ #include "../../../inc/MarlinConfigPre.h" #include "../../../MarlinCore.h" +//#define DEBUG_DGUSLCD // Uncomment for debug messages #define DEBUG_OUT ENABLED(DEBUG_DGUSLCD) #include "../../../core/debug_out.h" -#define Swap16(val) ((uint16_t)(((uint16_t)(val) >> 8) |\ - ((uint16_t)(val) << 8))) +// New endianness swap for 32bit mcu (tested with STM32G0B1RE) +#define BE16_P(V) ( ((uint8_t*)(V))[0] << 8U | ((uint8_t*)(V))[1] ) +#define BE32_P(V) ( ((uint8_t*)(V))[0] << 24U | ((uint8_t*)(V))[1] << 16U | ((uint8_t*)(V))[2] << 8U | ((uint8_t*)(V))[3] ) // Low-Level access to the display. class DGUSDisplay { diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index 88fe30a0273f..ce03ab6b8340 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -215,7 +215,7 @@ void DGUSRxHandler::PrintResume(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::Feedrate(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const int16_t feedrate = Swap16(*(int16_t*)data_ptr); + const int16_t feedrate = BE16_P(data_ptr); ExtUI::setFeedrate_percent(feedrate); @@ -223,7 +223,7 @@ void DGUSRxHandler::Feedrate(DGUS_VP &vp, void *data_ptr) { } void DGUSRxHandler::Flowrate(DGUS_VP &vp, void *data_ptr) { - const int16_t flowrate = Swap16(*(int16_t*)data_ptr); + const int16_t flowrate = BE16_P(data_ptr); switch (vp.addr) { default: return; @@ -246,7 +246,7 @@ void DGUSRxHandler::Flowrate(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::BabystepSet(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const int16_t data = Swap16(*(int16_t*)data_ptr); + const int16_t data = BE16_P(data_ptr); const float offset = dgus_display.FromFixedPoint(data); const int16_t steps = ExtUI::mmToWholeSteps(offset - ExtUI::getZOffset_mm(), ExtUI::Z); @@ -315,7 +315,7 @@ void DGUSRxHandler::TempPreset(DGUS_VP &vp, void *data_ptr) { } void DGUSRxHandler::TempTarget(DGUS_VP &vp, void *data_ptr) { - const int16_t temp = Swap16(*(int16_t*)data_ptr); + const int16_t temp = BE16_P(data_ptr); switch (vp.addr) { default: return; @@ -338,7 +338,7 @@ void DGUSRxHandler::TempTarget(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::TempCool(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const DGUS_Data::Heater heater = (DGUS_Data::Heater)Swap16(*(uint16_t*)data_ptr); + const DGUS_Data::Heater heater = (DGUS_Data::Heater)BE16_P(data_ptr); switch (heater) { default: return; @@ -397,7 +397,7 @@ void DGUSRxHandler::ZOffset(DGUS_VP &vp, void *data_ptr) { return; } - const int16_t data = Swap16(*(int16_t*)data_ptr); + const int16_t data = BE16_P(data_ptr); const float offset = dgus_display.FromFixedPoint(data); const int16_t steps = ExtUI::mmToWholeSteps(offset - ExtUI::getZOffset_mm(), ExtUI::Z); @@ -546,7 +546,7 @@ void DGUSRxHandler::DisableABL(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::FilamentSelect(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const DGUS_Data::Extruder extruder = (DGUS_Data::Extruder)Swap16(*(uint16_t*)data_ptr); + const DGUS_Data::Extruder extruder = (DGUS_Data::Extruder)BE16_P(data_ptr); switch (extruder) { default: return; @@ -563,7 +563,7 @@ void DGUSRxHandler::FilamentSelect(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::FilamentLength(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const uint16_t length = Swap16(*(uint16_t*)data_ptr); + const uint16_t length = BE16_P(data_ptr); dgus_screen_handler.filament_length = constrain(length, 0, EXTRUDE_MAXLENGTH); @@ -644,7 +644,7 @@ void DGUSRxHandler::Home(DGUS_VP &vp, void *data_ptr) { } void DGUSRxHandler::Move(DGUS_VP &vp, void *data_ptr) { - const int16_t data = Swap16(*(int16_t*)data_ptr); + const int16_t data = BE16_P(data_ptr); const float position = dgus_display.FromFixedPoint(data); ExtUI::axis_t axis; @@ -816,7 +816,7 @@ void DGUSRxHandler::SettingsExtra(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::PIDSelect(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const DGUS_Data::Heater heater = (DGUS_Data::Heater)Swap16(*(uint16_t*)data_ptr); + const DGUS_Data::Heater heater = (DGUS_Data::Heater)BE16_P(data_ptr); switch (heater) { default: return; @@ -846,7 +846,7 @@ void DGUSRxHandler::PIDSetTemp(DGUS_VP &vp, void *data_ptr) { return; } - uint16_t temp = Swap16(*(uint16_t*)data_ptr); + uint16_t temp = BE16_P(data_ptr); switch (dgus_screen_handler.pid_heater) { default: return; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h index c2e6e4308e5a..4cad11fc0b0b 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h @@ -107,7 +107,7 @@ namespace DGUSRxHandler { break; } case 2: { - const uint16_t data = Swap16(*(uint16_t*)data_ptr); + const uint16_t data = BE16_P(data_ptr); *(T*)vp.extra = (T)data; break; } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp index 62df84e53d8f..1837a0c93ab2 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp @@ -421,16 +421,16 @@ void DGUSTxHandler::PIDKp(DGUS_VP &vp) { default: return; #if ENABLED(PIDTEMPBED) case DGUS_Data::Heater::BED: - value = ExtUI::getBedPIDValues_Kp(); + value = ExtUI::getBedPID_Kp(); break; #endif #if ENABLED(PIDTEMP) case DGUS_Data::Heater::H0: - value = ExtUI::getPIDValues_Kp(ExtUI::E0); + value = ExtUI::getPID_Kp(ExtUI::E0); break; #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: - value = ExtUI::getPIDValues_Kp(ExtUI::E1); + value = ExtUI::getPID_Kp(ExtUI::E1); break; #endif #endif @@ -447,16 +447,16 @@ void DGUSTxHandler::PIDKi(DGUS_VP &vp) { default: return; #if ENABLED(PIDTEMPBED) case DGUS_Data::Heater::BED: - value = ExtUI::getBedPIDValues_Ki(); + value = ExtUI::getBedPID_Ki(); break; #endif #if ENABLED(PIDTEMP) case DGUS_Data::Heater::H0: - value = ExtUI::getPIDValues_Ki(ExtUI::E0); + value = ExtUI::getPID_Ki(ExtUI::E0); break; #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: - value = ExtUI::getPIDValues_Ki(ExtUI::E1); + value = ExtUI::getPID_Ki(ExtUI::E1); break; #endif #endif @@ -473,16 +473,16 @@ void DGUSTxHandler::PIDKd(DGUS_VP &vp) { default: return; #if ENABLED(PIDTEMPBED) case DGUS_Data::Heater::BED: - value = ExtUI::getBedPIDValues_Kd(); + value = ExtUI::getBedPID_Kd(); break; #endif #if ENABLED(PIDTEMP) case DGUS_Data::Heater::H0: - value = ExtUI::getPIDValues_Kd(ExtUI::E0); + value = ExtUI::getPID_Kd(ExtUI::E0); break; #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: - value = ExtUI::getPIDValues_Kd(ExtUI::E1); + value = ExtUI::getPID_Kd(ExtUI::E1); break; #endif #endif diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h index 94632fe385e6..7d1b46773b25 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h @@ -24,6 +24,8 @@ #include "DGUSDisplay.h" #include "definition/DGUS_VP.h" +#define Swap16(val) ((uint16_t)(((uint16_t)(val) >> 8) | ((uint16_t)(val) << 8))) + namespace DGUSTxHandler { #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp index e3b95c4cd490..656c1f04d2ea 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp @@ -52,7 +52,6 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { .enabled(ENABLED(HAS_MULTI_HOTEND)) .tag(6) .button(BTN_POS(1,5), BTN_SIZE(1,1), GET_TEXT_F(MSG_OFFSETS_MENU)) - .tag(7) .button(BTN_POS(2,1), BTN_SIZE(1,1), GET_TEXT_F(MSG_STEPS_PER_MM)) .tag(8) .button(BTN_POS(2,2), BTN_SIZE(1,1), GET_TEXT_F(MSG_MAX_SPEED)) .tag(9) .button(BTN_POS(2,3), BTN_SIZE(1,1), GET_TEXT_F(MSG_ACCELERATION)) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/resolutions.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/resolutions.h index 0c600fa0a580..524ebfafaadf 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/resolutions.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/resolutions.h @@ -97,7 +97,7 @@ #elif defined(TOUCH_UI_800x480) namespace FTDI { - #if defined(TOUCH_UI_800x480_GENERIC) + #ifdef TOUCH_UI_800x480_GENERIC constexpr uint8_t Pclk = 2; constexpr uint16_t Hsize = 800; constexpr uint16_t Vsize = 480; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp index 0a8bebea3c9d..4e5a3fec2f9b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp @@ -45,15 +45,16 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t return false; } - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT if (EventLoop::get_pressed_tag() != 0) { + #if ENABLED(TOUCH_UI_DEBUG) + SERIAL_ECHO_MSG("buttonStyleCallback, resetting timeout"); + #endif reset_menu_timeout(); } #endif - if (buttonIsPressed(tag)) { - options = OPT_FLAT; - } + if (buttonIsPressed(tag)) options = OPT_FLAT; if (style & cmd.STYLE_DISABLED) { cmd.tag(0); @@ -65,7 +66,10 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t } void BaseScreen::onIdle() { - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT + if (EventLoop::get_pressed_tag() != 0) + reset_menu_timeout(); + if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) { reset_menu_timeout(); #if ENABLED(TOUCH_UI_DEBUG) @@ -77,10 +81,10 @@ void BaseScreen::onIdle() { } void BaseScreen::reset_menu_timeout() { - TERN_(SCREENS_CAN_TIME_OUT, last_interaction = millis()); + TERN_(HAS_SCREEN_TIMEOUT, last_interaction = millis()); } -#if SCREENS_CAN_TIME_OUT +#if HAS_SCREEN_TIMEOUT uint32_t BaseScreen::last_interaction; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.h index 030fa51a2aaf..4b29bf1e4190 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/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 SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT static uint32_t last_interaction; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp index a3c3b503d89c..e077eb371ac0 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp @@ -113,7 +113,7 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) { void BaseMoveAxisScreen::raiseZtoTop() { constexpr xyze_feedrate_t homing_feedrate = HOMING_FEEDRATE_MM_M; - setAxisPosition_mm(Z_MAX_POS - 5, Z, homing_feedrate[Z_AXIS]); + setAxisPosition_mm(Z_MAX_POS - 5, Z, homing_feedrate.z); } float BaseMoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) { diff --git a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp index 6f2351bba68c..6508f6f02473 100644 --- a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp +++ b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp @@ -27,8 +27,8 @@ #include "../../../inc/MarlinConfig.h" #include "SPIFlashStorage.h" -#if !HAS_SPI_FLASH - #error "HAS_SPI_FLASH is required with TFT_LVGL_UI." +#if DISABLED(SPI_FLASH) + #error "SPI_FLASH is required with TFT_LVGL_UI." #endif extern W25QXXFlash W25QXX; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_about.cpp b/Marlin/src/lcd/extui/mks_ui/draw_about.cpp index 49ee6eee7377..e254523e1241 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_about.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_about.cpp @@ -31,7 +31,7 @@ extern lv_group_t *g; static lv_obj_t *scr; -static lv_obj_t *fw_type, *board; +static lv_obj_t *fw_type, *board, *website, *uuid, *protocol; enum { ID_A_RETURN = 1 }; @@ -48,11 +48,20 @@ void lv_draw_about() { scr = lv_screen_create(ABOUT_UI); 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_A_RETURN); - fw_type = lv_label_create(scr, "Firmware: Marlin " SHORT_BUILD_VERSION); - lv_obj_align(fw_type, nullptr, LV_ALIGN_CENTER, 0, -20); + board = lv_label_create(scr, BOARD_INFO_NAME); + lv_obj_align(board, nullptr, LV_ALIGN_CENTER, 0, -80); - board = lv_label_create(scr, "Board: " BOARD_INFO_NAME); - lv_obj_align(board, nullptr, LV_ALIGN_CENTER, 0, -60); + fw_type = lv_label_create(scr, "Marlin " SHORT_BUILD_VERSION " (" STRING_DISTRIBUTION_DATE ")"); + lv_obj_align(fw_type, nullptr, LV_ALIGN_CENTER, 0, -50); + + website = lv_label_create(scr, WEBSITE_URL); + lv_obj_align(website, nullptr, LV_ALIGN_CENTER, 0, -20); + + uuid = lv_label_create(scr, "UUID: " DEFAULT_MACHINE_UUID); + lv_obj_align(uuid, nullptr, LV_ALIGN_CENTER, 0, 10); + + protocol = lv_label_create(scr, "Protocol: " PROTOCOL_VERSION); + lv_obj_align(protocol, nullptr, LV_ALIGN_CENTER, 0, 40); } void lv_clear_about() { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp b/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp index a680976d96e1..a070cae15f4e 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp @@ -74,16 +74,16 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { void lv_draw_jerk_settings() { scr = lv_screen_create(JERK_UI, machine_menu.JerkConfTitle); - dtostrf(planner.max_jerk[X_AXIS], 1, 1, public_buf_l); + dtostrf(planner.max_jerk.x, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.X_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_JERK_X, 0, public_buf_l); - dtostrf(planner.max_jerk[Y_AXIS], 1, 1, public_buf_l); + dtostrf(planner.max_jerk.y, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_JERK_Y, 1, public_buf_l); - dtostrf(planner.max_jerk[Z_AXIS], 1, 1, public_buf_l); + dtostrf(planner.max_jerk.z, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_JERK_Z, 2, public_buf_l); - dtostrf(planner.max_jerk[E_AXIS], 1, 1, public_buf_l); + dtostrf(planner.max_jerk.e, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.E_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_JERK_E, 3, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACK_POS_X, PARA_UI_BACK_POS_Y, event_handler, ID_JERK_RETURN, true); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp index deed03724881..850a409a1857 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp @@ -119,22 +119,22 @@ static void disp_key_value() { case XJerk: #if HAS_CLASSIC_JERK - dtostrf(planner.max_jerk[X_AXIS], 1, 1, public_buf_m); + dtostrf(planner.max_jerk.x, 1, 1, public_buf_m); #endif break; case YJerk: #if HAS_CLASSIC_JERK - dtostrf(planner.max_jerk[Y_AXIS], 1, 1, public_buf_m); + dtostrf(planner.max_jerk.y, 1, 1, public_buf_m); #endif break; case ZJerk: #if HAS_CLASSIC_JERK - dtostrf(planner.max_jerk[Z_AXIS], 1, 1, public_buf_m); + dtostrf(planner.max_jerk.z, 1, 1, public_buf_m); #endif break; case EJerk: #if HAS_CLASSIC_JERK - dtostrf(planner.max_jerk[E_AXIS], 1, 1, public_buf_m); + dtostrf(planner.max_jerk.e, 1, 1, public_buf_m); #endif break; @@ -307,10 +307,10 @@ static void set_value_confirm() { case ZMaxFeedRate: planner.settings.max_feedrate_mm_s[Z_AXIS] = atof(key_value); break; case E0MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS] = atof(key_value); break; case E1MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS_N(1)] = atof(key_value); break; - case XJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[X_AXIS] = atof(key_value)); break; - case YJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Y_AXIS] = atof(key_value)); break; - case ZJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Z_AXIS] = atof(key_value)); break; - case EJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[E_AXIS] = atof(key_value)); break; + case XJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk.x = atof(key_value)); break; + case YJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk.y = atof(key_value)); break; + case ZJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk.z = atof(key_value)); break; + case EJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk.e = atof(key_value)); break; case Xstep: planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); planner.refresh_positioning(); break; case Ystep: planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value); planner.refresh_positioning(); break; case Zstep: planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value); planner.refresh_positioning(); break; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp index be596c874074..5dc3861f6525 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp @@ -39,7 +39,7 @@ #include "../../../feature/powerloss.h" #endif -#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) +#if ENABLED(SET_REMAINING_TIME) #include "../../marlinui.h" #endif @@ -244,7 +244,7 @@ void disp_fan_speed() { } void disp_print_time() { - #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) const uint32_t r = ui.get_remaining_time(); sprintf_P(public_buf_l, PSTR("%02d:%02d R"), r / 3600, (r % 3600) / 60); #else 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 38612358110b..b31977e7ca4c 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -482,14 +482,14 @@ void lv_encoder_pin_init() { #if BUTTON_EXISTS(UP) SET_INPUT(BTN_UP); #endif - #if BUTTON_EXISTS(DWN) - SET_INPUT(BTN_DWN); + #if BUTTON_EXISTS(DOWN) + SET_INPUT(BTN_DOWN); #endif - #if BUTTON_EXISTS(LFT) - SET_INPUT(BTN_LFT); + #if BUTTON_EXISTS(LEFT) + SET_INPUT(BTN_LEFT); #endif - #if BUTTON_EXISTS(RT) - SET_INPUT(BTN_RT); + #if BUTTON_EXISTS(RIGHT) + SET_INPUT(BTN_RIGHT); #endif } diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp index 92349659eb3d..63c25177a679 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp @@ -459,17 +459,17 @@ void NextionTFT::PanelInfo(uint8_t req) { case 37: // PID #if ENABLED(PIDTEMP) - #define SEND_PID_INFO_0(A, B) SEND_VALasTXT(A, getPIDValues_K##B(E0)) + #define SEND_PID_INFO_0(A, B) SEND_VALasTXT(A, getPID_K##B(E0)) #else #define SEND_PID_INFO_0(A, B) SEND_NA(A) #endif #if BOTH(PIDTEMP, HAS_MULTI_EXTRUDER) - #define SEND_PID_INFO_1(A, B) SEND_VALasTXT(A, getPIDValues_K##B(E1)) + #define SEND_PID_INFO_1(A, B) SEND_VALasTXT(A, getPID_K##B(E1)) #else #define SEND_PID_INFO_1(A, B) SEND_NA(A) #endif #if ENABLED(PIDTEMPBED) - #define SEND_PID_INFO_BED(A, B) SEND_VALasTXT(A, getBedPIDValues_K##B()) + #define SEND_PID_INFO_BED(A, B) SEND_VALasTXT(A, getBedPID_K##B()) #else #define SEND_PID_INFO_BED(A, B) SEND_NA(A) #endif diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index a711e6dd5726..4422e8115d8a 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -375,9 +375,9 @@ namespace ExtUI { bool canMove(const axis_t axis) { switch (axis) { #if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING) - case X: return axis_should_home(X_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)) + case X: return !axis_should_home(X_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 @@ -712,17 +712,17 @@ namespace ExtUI { #if ENABLED(POWER_LOSS_RECOVERY) bool getPowerLossRecoveryEnabled() { return recovery.enabled; } - void setPowerLossRecoveryEnabled(const bool value) { recovery.enable(value); } + void setPowerLossRecoveryEnabled(const bool value) { recovery.enable(value); } #endif #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t extruder) { - return (extruder < EXTRUDERS) ? planner.extruder_advance_K[extruder - E0] : 0; + return (extruder < EXTRUDERS) ? planner.extruder_advance_K[E_INDEX_N(extruder - E0)] : 0; } void setLinearAdvance_mm_mm_s(const_float_t value, const extruder_t extruder) { if (extruder < EXTRUDERS) - planner.extruder_advance_K[extruder - E0] = constrain(value, 0, 10); + planner.extruder_advance_K[E_INDEX_N(extruder - E0)] = constrain(value, 0, 10); } #endif @@ -976,32 +976,26 @@ namespace ExtUI { float getFeedrate_percent() { return feedrate_percentage; } #if ENABLED(PIDTEMP) - float getPIDValues_Kp(const extruder_t tool) { return PID_PARAM(Kp, tool); } - float getPIDValues_Ki(const extruder_t tool) { return unscalePID_i(PID_PARAM(Ki, tool)); } - float getPIDValues_Kd(const extruder_t tool) { return unscalePID_d(PID_PARAM(Kd, tool)); } - - void setPIDValues(const_float_t p, const_float_t i, const_float_t d, extruder_t tool) { - thermalManager.temp_hotend[tool].pid.Kp = p; - thermalManager.temp_hotend[tool].pid.Ki = scalePID_i(i); - thermalManager.temp_hotend[tool].pid.Kd = scalePID_d(d); - thermalManager.updatePID(); + float getPID_Kp(const extruder_t tool) { return thermalManager.temp_hotend[tool].pid.p(); } + float getPID_Ki(const extruder_t tool) { return thermalManager.temp_hotend[tool].pid.i(); } + float getPID_Kd(const extruder_t tool) { return thermalManager.temp_hotend[tool].pid.d(); } + + void setPID(const_float_t p, const_float_t i, const_float_t d, extruder_t tool) { + thermalManager.setPID(uint8_t(tool), p, i, d); } void startPIDTune(const celsius_t temp, extruder_t tool) { - thermalManager.PID_autotune(temp, (heater_id_t)tool, 8, true); + thermalManager.PID_autotune(temp, heater_id_t(tool), 8, true); } #endif #if ENABLED(PIDTEMPBED) - float getBedPIDValues_Kp() { return thermalManager.temp_bed.pid.Kp; } - float getBedPIDValues_Ki() { return unscalePID_i(thermalManager.temp_bed.pid.Ki); } - float getBedPIDValues_Kd() { return unscalePID_d(thermalManager.temp_bed.pid.Kd); } - - void setBedPIDValues(const_float_t p, const_float_t i, const_float_t d) { - thermalManager.temp_bed.pid.Kp = p; - thermalManager.temp_bed.pid.Ki = scalePID_i(i); - thermalManager.temp_bed.pid.Kd = scalePID_d(d); - thermalManager.updatePID(); + float getBedPID_Kp() { return thermalManager.temp_bed.pid.p(); } + float getBedPID_Ki() { return thermalManager.temp_bed.pid.i(); } + float getBedPID_Kd() { return thermalManager.temp_bed.pid.d(); } + + void setBedPID(const_float_t p, const_float_t i, const_float_t d) { + thermalManager.temp_bed.pid.set(p, i, d); } void startBedPIDTune(const celsius_t temp) { diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 84555187677a..c2ce52ba4c1e 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -164,6 +164,9 @@ namespace ExtUI { #if ENABLED(SHOW_REMAINING_TIME) inline uint32_t getProgress_seconds_remaining() { return ui.get_remaining_time(); } #endif + #if ENABLED(SHOW_INTERACTION_TIME) + inline uint32_t getInteraction_seconds_remaining() { return ui.interaction_time; } + #endif #if HAS_LEVELING bool getLevelingActive(); @@ -324,18 +327,18 @@ namespace ExtUI { #endif #if ENABLED(PIDTEMP) - float getPIDValues_Kp(const extruder_t); - float getPIDValues_Ki(const extruder_t); - float getPIDValues_Kd(const extruder_t); - void setPIDValues(const_float_t, const_float_t , const_float_t , extruder_t); + float getPID_Kp(const extruder_t); + float getPID_Ki(const extruder_t); + float getPID_Kd(const extruder_t); + void setPID(const_float_t, const_float_t , 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); + float getBedPID_Kp(); + float getBedPID_Ki(); + float getBedPID_Kd(); + void setBedPID(const_float_t, const_float_t , const_float_t); void startBedPIDTune(const celsius_t); #endif diff --git a/Marlin/src/lcd/language/language_an.h b/Marlin/src/lcd/language/language_an.h index 37c90c34daf9..8e65f3801285 100644 --- a/Marlin/src/lcd/language/language_an.h +++ b/Marlin/src/lcd/language/language_an.h @@ -90,6 +90,7 @@ namespace Language_an { LSTR MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mover 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mover 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mover 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mover 100mm"); LSTR MSG_SPEED = _UxGT("Velocidat"); LSTR MSG_BED_Z = _UxGT("Base Z"); diff --git a/Marlin/src/lcd/language/language_bg.h b/Marlin/src/lcd/language/language_bg.h index 038df3eccbb6..312ada7b10cd 100644 --- a/Marlin/src/lcd/language/language_bg.h +++ b/Marlin/src/lcd/language/language_bg.h @@ -79,6 +79,7 @@ namespace Language_bg { LSTR MSG_MOVE_01MM = _UxGT("Премести с 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Премести с 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Премести с 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Премести с 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Премести с 100mm"); LSTR MSG_SPEED = _UxGT("Скорост"); LSTR MSG_BED_Z = _UxGT("Bed Z"); diff --git a/Marlin/src/lcd/language/language_ca.h b/Marlin/src/lcd/language/language_ca.h index 54b968ede241..13b5d70837ad 100644 --- a/Marlin/src/lcd/language/language_ca.h +++ b/Marlin/src/lcd/language/language_ca.h @@ -90,6 +90,7 @@ namespace Language_ca { LSTR MSG_MOVE_01MM = _UxGT("Mou 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mou 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mou 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mou 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mou 100mm"); LSTR MSG_SPEED = _UxGT("Velocitat"); LSTR MSG_BED_Z = _UxGT("Llit Z"); @@ -150,7 +151,7 @@ namespace Language_ca { LSTR MSG_CHANGE_MEDIA = _UxGT("Canvia SD"); LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z fora"); LSTR MSG_BLTOUCH_RESET = _UxGT("Reinicia BLTouch"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s primer"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s primer"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Decalatge Z"); LSTR MSG_BABYSTEP_X = _UxGT("Micropas X"); LSTR MSG_BABYSTEP_Y = _UxGT("Micropas Y"); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index 9c5bafc96ec5..0bef3cc8e354 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -240,6 +240,7 @@ namespace Language_cz { LSTR MSG_MOVE_01MM = _UxGT("Posunout o 0,1mm"); LSTR MSG_MOVE_1MM = _UxGT("Posunout o 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Posunout o 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Posunout o 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Posunout o 100mm"); LSTR MSG_SPEED = _UxGT("Rychlost"); LSTR MSG_BED_Z = _UxGT("Výška podl."); @@ -395,7 +396,7 @@ namespace Language_cz { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("vysunout TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Vysunout Z-sondu"); LSTR MSG_MANUAL_STOW = _UxGT("Zasunout Z-sondu"); - LSTR MSG_HOME_FIRST = _UxGT("Domů %s%s%s první"); + LSTR MSG_HOME_FIRST = _UxGT("Domů %s první"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Z ofset"); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); diff --git a/Marlin/src/lcd/language/language_da.h b/Marlin/src/lcd/language/language_da.h index b4afca9d99a8..acb125589dd4 100644 --- a/Marlin/src/lcd/language/language_da.h +++ b/Marlin/src/lcd/language/language_da.h @@ -81,6 +81,7 @@ namespace Language_da { LSTR MSG_MOVE_01MM = _UxGT("Flyt 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Flyt 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Flyt 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Flyt 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Flyt 100mm"); LSTR MSG_SPEED = _UxGT("Hastighed"); LSTR MSG_BED_Z = _UxGT("Plade Z"); @@ -138,7 +139,7 @@ namespace Language_da { LSTR MSG_CHANGE_MEDIA = _UxGT("Skift SD kort"); LSTR MSG_ZPROBE_OUT = _UxGT("Probe udenfor plade"); LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Selv-Test"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s først"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s først"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Opvarmning fejlet"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Fejl: reserve temp"); LSTR MSG_THERMAL_RUNAWAY = _UxGT("Temp løber løbsk"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 5708221e9cc3..129f0dac41f6 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -301,6 +301,7 @@ namespace Language_de { LSTR MSG_MOVE_01MM = _UxGT(" 0,1 mm"); LSTR MSG_MOVE_1MM = _UxGT(" 1,0 mm"); LSTR MSG_MOVE_10MM = _UxGT(" 10,0 mm"); + LSTR MSG_MOVE_50MM = _UxGT(" 50,0 mm"); LSTR MSG_MOVE_100MM = _UxGT("100,0 mm"); LSTR MSG_MOVE_0001IN = _UxGT("0.001 in"); LSTR MSG_MOVE_001IN = _UxGT("0.010 in"); @@ -407,7 +408,6 @@ namespace Language_de { LSTR MSG_ADVANCE_K_E = _UxGT("Vorschubfaktor *"); LSTR MSG_CONTRAST = _UxGT("LCD-Kontrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD-Helligkeit"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD-Ruhezustand (s)"); LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Timeout (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("LCD ausschalten"); LSTR MSG_STORE_EEPROM = _UxGT("Konfig. speichern"); @@ -540,7 +540,7 @@ namespace Language_de { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("TouchMI ausfahren"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Z-Sonde ausfahren"); LSTR MSG_MANUAL_STOW = _UxGT("Z-Sonde einfahren"); - LSTR MSG_HOME_FIRST = _UxGT("Vorher %s%s%s homen"); + LSTR MSG_HOME_FIRST = _UxGT("Vorher %s homen"); LSTR MSG_ZPROBE_SETTINGS = _UxGT("Sondeneinstellungen"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Sondenversatz"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Sondenversatz X"); diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index 41b73ddc571d..57af804147c5 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -95,10 +95,11 @@ namespace Language_el { LSTR MSG_MOVE_N = _UxGT("Μετακίνηση @"); LSTR MSG_MOVE_E = _UxGT("Εξωθητής"); LSTR MSG_MOVE_EN = _UxGT("Εξωθητής *"); - LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση %s μμ"); + LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση $μμ"); LSTR MSG_MOVE_01MM = _UxGT("Μετακίνηση 0,1 μμ"); LSTR MSG_MOVE_1MM = _UxGT("Μετακίνηση 1 μμ"); LSTR MSG_MOVE_10MM = _UxGT("Μετακίνηση 10 μμ"); + LSTR MSG_MOVE_50MM = _UxGT("Μετακίνηση 50 μμ"); LSTR MSG_MOVE_100MM = _UxGT("Μετακίνηση 100 μμ"); LSTR MSG_SPEED = _UxGT("Ταχύτητα"); LSTR MSG_BED_Z = _UxGT("Επ. Εκτύπωσης Z"); diff --git a/Marlin/src/lcd/language/language_el_gr.h b/Marlin/src/lcd/language/language_el_gr.h index 7306aab1235a..08f647f705bb 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -84,10 +84,11 @@ namespace Language_el_gr { LSTR MSG_MOVE_N = _UxGT("Μετακίνηση @"); LSTR MSG_MOVE_E = _UxGT("Εξωθητήρας"); LSTR MSG_MOVE_EN = _UxGT("Εξωθητήρας *"); - LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση %s μμ"); + LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση $μμ"); LSTR MSG_MOVE_01MM = _UxGT("Μετακίνηση 0,1 μμ"); LSTR MSG_MOVE_1MM = _UxGT("Μετακίνηση 1 μμ"); LSTR MSG_MOVE_10MM = _UxGT("Μετακίνηση 10 μμ"); + LSTR MSG_MOVE_50MM = _UxGT("Μετακίνηση 50 μμ"); LSTR MSG_MOVE_100MM = _UxGT("Μετακίνηση 100 μμ"); LSTR MSG_SPEED = _UxGT("Ταχύτητα"); LSTR MSG_BED_Z = _UxGT("Κλίνη Z"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 57cae3d32858..898aa331855a 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -82,6 +82,7 @@ namespace Language_en { LSTR MSG_AUTO_HOME_X = _UxGT("Home X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); + LSTR MSG_Z_AFTER_HOME = _UxGT("Z After Homing"); LSTR MSG_FILAMENT_SET = _UxGT("Filament Settings"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); LSTR MSG_MANUAL_LEVELING = _UxGT("Manual Leveling"); @@ -133,6 +134,7 @@ namespace Language_en { LSTR MSG_PREHEAT_M_BEDONLY = _UxGT("Preheat $ Bed"); LSTR MSG_PREHEAT_M_SETTINGS = _UxGT("Preheat $ Conf"); #endif + LSTR MSG_PREHEAT_HOTEND = _UxGT("Preheat Hotend"); LSTR MSG_PREHEAT_CUSTOM = _UxGT("Preheat Custom"); LSTR MSG_COOLDOWN = _UxGT("Cooldown"); @@ -266,6 +268,7 @@ namespace Language_en { LSTR MSG_UBL_INVALID_SLOT = _UxGT("First Select a Mesh Slot"); LSTR MSG_MESH_LOADED = _UxGT("Mesh %i Loaded"); LSTR MSG_MESH_SAVED = _UxGT("Mesh %i Saved"); + LSTR MSG_MESH_ACTIVE = _UxGT("Mesh %i active"); LSTR MSG_UBL_NO_STORAGE = _UxGT("No Storage"); LSTR MSG_UBL_SAVE_ERROR = _UxGT("Err: UBL Save"); LSTR MSG_UBL_RESTORE_ERROR = _UxGT("Err: UBL Restore"); @@ -316,11 +319,14 @@ namespace Language_en { LSTR MSG_MOVE_01MM = _UxGT("Move 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Move 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Move 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Move 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Move 100mm"); LSTR MSG_MOVE_0001IN = _UxGT("Move 0.001in"); LSTR MSG_MOVE_001IN = _UxGT("Move 0.01in"); LSTR MSG_MOVE_01IN = _UxGT("Move 0.1in"); + LSTR MSG_MOVE_05IN = _UxGT("Move 0.5in"); LSTR MSG_MOVE_1IN = _UxGT("Move 1.0in"); + LSTR MSG_LIVE_MOVE = _UxGT("Live Move"); LSTR MSG_SPEED = _UxGT("Speed"); LSTR MSG_BED_Z = _UxGT("Bed Z"); LSTR MSG_NOZZLE = _UxGT("Nozzle"); @@ -332,6 +338,7 @@ namespace Language_en { LSTR MSG_COOLER = _UxGT("Laser Coolant"); LSTR MSG_COOLER_TOGGLE = _UxGT("Toggle Cooler"); LSTR MSG_FLOWMETER_SAFETY = _UxGT("Flow Safety"); + LSTR MSG_CUTTER = _UxGT("Cutter"); LSTR MSG_LASER = _UxGT("Laser"); LSTR MSG_FAN_SPEED = _UxGT("Fan Speed"); LSTR MSG_FAN_SPEED_N = _UxGT("Fan Speed ~"); @@ -399,6 +406,11 @@ namespace Language_en { LSTR MSG_AMAX_EN = _UxGT("Max * Accel"); LSTR MSG_A_RETRACT = _UxGT("Retract Accel"); LSTR MSG_A_TRAVEL = _UxGT("Travel Accel"); + LSTR MSG_INPUT_SHAPING = _UxGT("Input Shaping"); + LSTR MSG_SHAPING_ENABLE = _UxGT("Enable @ shaping"); + LSTR MSG_SHAPING_DISABLE = _UxGT("Disable @ shaping"); + LSTR MSG_SHAPING_FREQ = _UxGT("@ frequency"); + LSTR MSG_SHAPING_ZETA = _UxGT("@ damping"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("XY Freq Limit"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min FR Factor"); LSTR MSG_STEPS_PER_MM = _UxGT("Steps/mm"); @@ -418,11 +430,16 @@ namespace Language_en { LSTR MSG_FILAMENT_DIAM_E = _UxGT("Fil. Dia. *"); LSTR MSG_FILAMENT_UNLOAD = _UxGT("Unload mm"); LSTR MSG_FILAMENT_LOAD = _UxGT("Load mm"); + LSTR MSG_SEGMENTS_PER_SECOND = _UxGT("Segments/Sec"); + LSTR MSG_DRAW_MIN_X = _UxGT("Draw Min X"); + LSTR MSG_DRAW_MAX_X = _UxGT("Draw Max X"); + LSTR MSG_DRAW_MIN_Y = _UxGT("Draw Min Y"); + LSTR MSG_DRAW_MAX_Y = _UxGT("Draw Max Y"); + LSTR MSG_MAX_BELT_LEN = _UxGT("Max Belt Len"); LSTR MSG_ADVANCE_K = _UxGT("Advance K"); LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *"); LSTR MSG_CONTRAST = _UxGT("LCD Contrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD Timeout (s)"); LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Timeout (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Backlight Off"); LSTR MSG_STORE_EEPROM = _UxGT("Store Settings"); @@ -472,15 +489,27 @@ namespace Language_en { LSTR MSG_PAUSE_PRINT = _UxGT("Pause Print"); LSTR MSG_ADVANCED_PAUSE = _UxGT("Advanced Pause"); LSTR MSG_RESUME_PRINT = _UxGT("Resume Print"); - LSTR MSG_HOST_START_PRINT = _UxGT("Start Host Print"); LSTR MSG_STOP_PRINT = _UxGT("Stop Print"); - LSTR MSG_END_LOOPS = _UxGT("End Repeat Loops"); - LSTR MSG_PRINTING_OBJECT = _UxGT("Printing Object"); - LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Object"); - LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Object ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Power Outage"); - LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Print Job"); - LSTR MSG_MEDIA_MENU = _UxGT("Print from ") MEDIA_TYPE_EN; + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_HOST_START_PRINT = _UxGT("Start Host Print"); + LSTR MSG_PRINTING_OBJECT = _UxGT("Printing Object"); + LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Object"); + LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Object ="); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Print Job"); + LSTR MSG_MEDIA_MENU = _UxGT("Print from ") MEDIA_TYPE_EN; + LSTR MSG_TURN_OFF = _UxGT("Turn off the printer"); + LSTR MSG_END_LOOPS = _UxGT("End Repeat Loops"); + #else + LSTR MSG_HOST_START_PRINT = _UxGT("Host Start"); + LSTR MSG_PRINTING_OBJECT = _UxGT("Print Obj"); + LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Obj"); + LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Obj ="); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Job"); + LSTR MSG_MEDIA_MENU = MEDIA_TYPE_EN _UxGT(" Print"); + LSTR MSG_TURN_OFF = _UxGT("Turn off now"); + LSTR MSG_END_LOOPS = _UxGT("End Loops"); + #endif LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN; LSTR MSG_DWELL = _UxGT("Sleep..."); LSTR MSG_USERWAIT = _UxGT("Click to Resume..."); @@ -491,7 +520,6 @@ namespace Language_en { LSTR MSG_PRINT_ABORTED = _UxGT("Print Aborted"); LSTR MSG_PRINT_DONE = _UxGT("Print Done"); LSTR MSG_PRINTER_KILLED = _UxGT("Printer killed!"); - LSTR MSG_TURN_OFF = _UxGT("Turn off the printer"); LSTR MSG_NO_MOVE = _UxGT("No Move."); LSTR MSG_KILLED = _UxGT("KILLED. "); LSTR MSG_STOPPED = _UxGT("STOPPED. "); @@ -511,8 +539,10 @@ namespace Language_en { LSTR MSG_TOOL_CHANGE = _UxGT("Tool Change"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Z Raise"); LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Prime Speed"); + LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Wipe Retract"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Retract Speed"); LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Park Head"); + LSTR MSG_PARK_FAILED = _UxGT("Head cannot be parked"); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Recover Speed"); LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Fan Speed"); LSTR MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Fan Time"); @@ -529,7 +559,12 @@ namespace Language_en { LSTR MSG_FILAMENTUNLOAD = _UxGT("Unload Filament"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Unload *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Unload All"); - LSTR MSG_ATTACH_MEDIA = _UxGT("Attach ") MEDIA_TYPE_EN; + #if ENABLED(MULTI_VOLUME) + LSTR MSG_ATTACH_MEDIA = _UxGT("Attach SD Card"); + LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Attach USB Drive"); + #else + LSTR MSG_ATTACH_MEDIA = _UxGT("Attach ") MEDIA_TYPE_EN; + #endif LSTR MSG_CHANGE_MEDIA = _UxGT("Change ") MEDIA_TYPE_EN; LSTR MSG_RELEASE_MEDIA = _UxGT("Release ") MEDIA_TYPE_EN; LSTR MSG_ZPROBE_OUT = _UxGT("Z Probe Past Bed"); @@ -555,7 +590,7 @@ namespace Language_en { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Deploy TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Deploy Z-Probe"); LSTR MSG_MANUAL_STOW = _UxGT("Stow Z-Probe"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s First"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s First"); LSTR MSG_ZPROBE_SETTINGS = _UxGT("Probe Settings"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Probe Offsets"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Probe X Offset"); @@ -613,6 +648,7 @@ namespace Language_en { LSTR MSG_MESH_LEVELING = _UxGT("Mesh Leveling"); LSTR MSG_MESH_DONE = _UxGT("Mesh probing done"); LSTR MSG_INFO_STATS_MENU = _UxGT("Printer Stats"); + LSTR MSG_RESET_STATS = _UxGT("Reset Print Stats?"); LSTR MSG_INFO_BOARD_MENU = _UxGT("Board Info"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistors"); LSTR MSG_INFO_EXTRUDERS = _UxGT("Extruders"); diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 5f88f8426d11..e2d120b3dcc7 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -234,6 +234,7 @@ namespace Language_es { LSTR MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mover 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mover 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mover 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mover 100mm"); LSTR MSG_SPEED = _UxGT("Velocidad"); LSTR MSG_BED_Z = _UxGT("Cama Z"); @@ -398,7 +399,7 @@ namespace Language_es { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Subir TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Subir Sonda Z"); LSTR MSG_MANUAL_STOW = _UxGT("Bajar Sonda Z"); - LSTR MSG_HOME_FIRST = _UxGT("Origen %s%s%s Prim."); + LSTR MSG_HOME_FIRST = _UxGT("Origen %s Prim."); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Desf. Sonda"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Desf. Sonda X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Desf. Sonda Y"); diff --git a/Marlin/src/lcd/language/language_eu.h b/Marlin/src/lcd/language/language_eu.h index 210fdbdc168e..f5a365e002bd 100644 --- a/Marlin/src/lcd/language/language_eu.h +++ b/Marlin/src/lcd/language/language_eu.h @@ -143,6 +143,7 @@ namespace Language_eu { LSTR MSG_MOVE_01MM = _UxGT("Mugitu 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mugitu 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mugitu 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mugitu 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mugitu 100mm"); LSTR MSG_SPEED = _UxGT("Abiadura"); LSTR MSG_BED_Z = _UxGT("Z Ohea"); @@ -235,7 +236,7 @@ namespace Language_eu { LSTR MSG_BLTOUCH_RESET = _UxGT("BLTouch berrabia."); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("BLTouch jaitsi/luzatu"); LSTR MSG_BLTOUCH_STOW = _UxGT("BLTouch igo/jaso"); - LSTR MSG_HOME_FIRST = _UxGT("Etxera %s%s%s lehenengo"); + LSTR MSG_HOME_FIRST = _UxGT("Etxera %s lehenengo"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Z Konpentsatu"); LSTR MSG_BABYSTEP_X = _UxGT("Mikro-urratsa X"); LSTR MSG_BABYSTEP_Y = _UxGT("Mikro-urratsa Y"); diff --git a/Marlin/src/lcd/language/language_fi.h b/Marlin/src/lcd/language/language_fi.h index ff1c23eee7e6..300da9b95652 100644 --- a/Marlin/src/lcd/language/language_fi.h +++ b/Marlin/src/lcd/language/language_fi.h @@ -76,6 +76,7 @@ namespace Language_fi { LSTR MSG_MOVE_01MM = _UxGT("Liikuta 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Liikuta 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Liikuta 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Liikuta 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Liikuta 100mm"); LSTR MSG_SPEED = _UxGT("Nopeus"); LSTR MSG_NOZZLE = _UxGT("Suutin"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index 55b1b4e2e9c9..5bea244e3204 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -238,10 +238,12 @@ namespace Language_fr { LSTR MSG_MOVE_01MM = _UxGT("Déplacer 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Déplacer 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Déplacer 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Déplacer 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Déplacer 100mm"); LSTR MSG_MOVE_0001IN = _UxGT("Déplacer 0.001\""); LSTR MSG_MOVE_001IN = _UxGT("Déplacer 0.01\""); LSTR MSG_MOVE_01IN = _UxGT("Déplacer 0.1\""); + LSTR MSG_MOVE_05IN = _UxGT("Déplacer 0.5\""); LSTR MSG_MOVE_1IN = _UxGT("Déplacer 1\""); LSTR MSG_SPEED = _UxGT("Vitesse"); LSTR MSG_BED_Z = _UxGT("Lit Z"); @@ -321,7 +323,7 @@ namespace Language_fr { LSTR MSG_ADVANCE_K_E = _UxGT("Avance K *"); LSTR MSG_BRIGHTNESS = _UxGT("Luminosité LCD"); LSTR MSG_CONTRAST = _UxGT("Contraste LCD"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("Veille LCD (s)"); + LSTR MSG_SCREEN_TIMEOUT = _UxGT("Veille LCD (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Éteindre l'écran LCD"); LSTR MSG_STORE_EEPROM = _UxGT("Enregistrer config."); LSTR MSG_LOAD_EEPROM = _UxGT("Charger config."); @@ -376,6 +378,7 @@ namespace Language_fr { LSTR MSG_TOOL_CHANGE = _UxGT("Changement outil"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Augmenter Z"); LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Vitesse primaire"); + LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Purge Retract"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Vitesse rétract°"); LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Garer Extrudeur"); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Vitesse reprise"); @@ -422,7 +425,7 @@ namespace Language_fr { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Déployer TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Déployer Sonde Z"); LSTR MSG_MANUAL_STOW = _UxGT("Ranger Sonde Z"); - LSTR MSG_HOME_FIRST = _UxGT("Origine %s%s%s Premier"); + LSTR MSG_HOME_FIRST = _UxGT("Origine %s Premier"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Position sonde Z"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Décalage X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Décalage Y"); diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index 9ae64f080925..2731d864e872 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -231,6 +231,7 @@ namespace Language_gl { LSTR MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mover 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mover 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mover 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mover 100mm"); LSTR MSG_SPEED = _UxGT("Velocidade"); LSTR MSG_BED_Z = _UxGT("Cama Z"); @@ -413,7 +414,7 @@ namespace Language_gl { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Estender TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Estender Sonda Z"); LSTR MSG_MANUAL_STOW = _UxGT("Recoller Sonda Z"); - LSTR MSG_HOME_FIRST = _UxGT("Orixe %s%s%s Primeiro"); + LSTR MSG_HOME_FIRST = _UxGT("Orixe %s Primeiro"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Desfases Sonda"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Desfase Sonda X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Desfase Sonda Y"); diff --git a/Marlin/src/lcd/language/language_hr.h b/Marlin/src/lcd/language/language_hr.h index 08ff6cc38c6f..7ca0f5405af1 100644 --- a/Marlin/src/lcd/language/language_hr.h +++ b/Marlin/src/lcd/language/language_hr.h @@ -86,6 +86,7 @@ namespace Language_hr { LSTR MSG_MOVE_01MM = _UxGT("Miči 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Miči 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Miči 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Miči 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Miči 100mm"); LSTR MSG_SPEED = _UxGT("Brzina"); LSTR MSG_BED_Z = _UxGT("Bed Z"); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index eebcb759e5e8..68b489e522f1 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -264,10 +264,12 @@ namespace Language_hu { LSTR MSG_MOVE_01MM = _UxGT("Mozgás 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mozgás 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mozgás 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mozgás 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mozgás 100mm"); LSTR MSG_MOVE_0001IN = _UxGT("Mozgás 0.025mm"); LSTR MSG_MOVE_001IN = _UxGT("Mozgás 0.254mm"); LSTR MSG_MOVE_01IN = _UxGT("Mozgás 2.54mm"); + LSTR MSG_MOVE_05IN = _UxGT("Mozgás 12.7mm"); LSTR MSG_MOVE_1IN = _UxGT("Mozgáá 25.4mm"); LSTR MSG_SPEED = _UxGT("Sebesség"); LSTR MSG_BED_Z = _UxGT("Z ágy"); @@ -466,7 +468,7 @@ namespace Language_hu { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("TouchMI használ"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Z-Szonda telepítés"); LSTR MSG_MANUAL_STOW = _UxGT("Z-Szonda elhelyezés"); - LSTR MSG_HOME_FIRST = _UxGT("Elöször %s%s%s kell"); + LSTR MSG_HOME_FIRST = _UxGT("Elöször %s kell"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Szonda eltolások"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("X szonda eltolás"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Y szonda eltolás"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index f0c21deb96cd..7f0496cd1889 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -178,7 +178,7 @@ namespace Language_it { LSTR MSG_MESH_AMAX = _UxGT("Massimizza area"); LSTR MSG_MESH_CENTER = _UxGT("Area centrale"); LSTR MSG_MESH_EDIT_Z = _UxGT("Valore di Z"); - LSTR MSG_MESH_CANCEL = _UxGT("Mesh cancellato"); + LSTR MSG_MESH_CANCEL = _UxGT("Mesh cancellata"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("Comandi personaliz."); LSTR MSG_M48_TEST = _UxGT("Test sonda M48"); LSTR MSG_M48_POINT = _UxGT("Punto M48"); @@ -251,6 +251,7 @@ namespace Language_it { LSTR MSG_UBL_SMART_FILLIN = _UxGT("Riempimento Smart"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Riempimento Mesh"); LSTR MSG_UBL_MESH_FILLED = _UxGT("Pts mancanti riempiti"); + LSTR MSG_UBL_MESH_INVALID = _UxGT("Mesh non valida"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Invalida Tutto"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Invalid.Punto Vicino"); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Ritocca Tutto"); @@ -312,10 +313,12 @@ namespace Language_it { LSTR MSG_MOVE_01MM = _UxGT("Muovi di 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Muovi di 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Muovi di 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Muovi di 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Muovi di 100mm"); LSTR MSG_MOVE_0001IN = _UxGT("Muovi di 0.001\""); LSTR MSG_MOVE_001IN = _UxGT("Muovi di 0.01\""); LSTR MSG_MOVE_01IN = _UxGT("Muovi di 0.1\""); + LSTR MSG_MOVE_05IN = _UxGT("Muovi di 0.5\""); LSTR MSG_MOVE_1IN = _UxGT("Muovi di 1\""); LSTR MSG_SPEED = _UxGT("Velocità"); LSTR MSG_BED_Z = _UxGT("Piatto Z"); @@ -395,6 +398,11 @@ namespace Language_it { LSTR MSG_AMAX_EN = _UxGT("Acc.Massima *"); LSTR MSG_A_RETRACT = _UxGT("A-Ritrazione"); LSTR MSG_A_TRAVEL = _UxGT("A-Spostamento"); + LSTR MSG_INPUT_SHAPING = _UxGT("Input Shaping"); + LSTR MSG_SHAPING_X_FREQ = _UxGT("Frequenza ") STR_X; + LSTR MSG_SHAPING_Y_FREQ = _UxGT("Frequenza ") STR_Y; + LSTR MSG_SHAPING_X_ZETA = _UxGT("Smorzamento ") STR_X; + LSTR MSG_SHAPING_Y_ZETA = _UxGT("Smorzamento ") STR_Y; LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frequenza max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min"); LSTR MSG_STEPS_PER_MM = _UxGT("Passi/mm"); @@ -414,11 +422,16 @@ namespace Language_it { LSTR MSG_FILAMENT_DIAM_E = _UxGT("Diam. filo *"); LSTR MSG_FILAMENT_UNLOAD = _UxGT("Rimuovi mm"); LSTR MSG_FILAMENT_LOAD = _UxGT("Carica mm"); + LSTR MSG_SEGMENTS_PER_SECOND = _UxGT("Segmenti/Sec"); + LSTR MSG_DRAW_MIN_X = _UxGT("Min X area disegno"); + LSTR MSG_DRAW_MAX_X = _UxGT("Max X area disegno"); + LSTR MSG_DRAW_MIN_Y = _UxGT("Min Y area disegno"); + LSTR MSG_DRAW_MAX_Y = _UxGT("Max Y area disegno"); + LSTR MSG_MAX_BELT_LEN = _UxGT("Lungh.max cinghia"); LSTR MSG_ADVANCE_K = _UxGT("K Avanzamento"); LSTR MSG_ADVANCE_K_E = _UxGT("K Avanzamento *"); LSTR MSG_CONTRAST = _UxGT("Contrasto LCD"); LSTR MSG_BRIGHTNESS = _UxGT("Luminosità LCD"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("Timeout LCD (s)"); LSTR MSG_SCREEN_TIMEOUT = _UxGT("Timeout LCD (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Spegni Retroillum."); LSTR MSG_STORE_EEPROM = _UxGT("Salva impostazioni"); @@ -507,9 +520,10 @@ namespace Language_it { LSTR MSG_TOOL_CHANGE = _UxGT("Cambio utensile"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Risalita Z"); LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Velocità innesco"); + LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Ritrazione pulizia"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Velocità ritrazione"); LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Parcheggia testa"); - LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Recover Speed"); + LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Veloc. di recupero"); LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Velocità ventola"); LSTR MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Tempo ventola"); LSTR MSG_TOOL_MIGRATION_ON = _UxGT("Auto ON"); @@ -551,7 +565,7 @@ namespace Language_it { LSTR MSG_MANUAL_DEPLOY = _UxGT("Estendi Sonda-Z"); LSTR MSG_BLTOUCH_STOW = _UxGT("Ritrai BLTouch"); LSTR MSG_MANUAL_STOW = _UxGT("Ritrai Sonda-Z"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s prima"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s prima"); LSTR MSG_ZPROBE_SETTINGS = _UxGT("Impostazioni sonda"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Offsets sonda"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Offset X sonda"); diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index bc8c9ba40ecb..5f82b0cc9068 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -99,6 +99,7 @@ namespace Language_jp_kana { LSTR MSG_MOVE_01MM = _UxGT("0.1mm イドウ"); // "Move 0.1mm" LSTR MSG_MOVE_1MM = _UxGT(" 1mm イドウ"); // "Move 1mm" LSTR MSG_MOVE_10MM = _UxGT(" 10mm イドウ"); // "Move 10mm" + LSTR MSG_MOVE_50MM = _UxGT(" 50mm イドウ"); // "Move 50mm" LSTR MSG_MOVE_100MM = _UxGT(" 100mm イドウ"); // "Move 100mm" LSTR MSG_SPEED = _UxGT("ソクド"); // "Speed" LSTR MSG_BED_Z = _UxGT("Zオフセット"); // "Bed Z" @@ -175,7 +176,7 @@ namespace Language_jp_kana { LSTR MSG_ZPROBE_OUT = _UxGT("Zプローブ ベッドガイ"); // "Z probe out. bed" LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch ジコシンダン"); // "BLTouch Self-Test" LSTR MSG_BLTOUCH_RESET = _UxGT("BLTouch リセット"); // "Reset BLTouch" - LSTR MSG_HOME_FIRST = _UxGT("サキニ %s%s%s ヲフッキサセテクダサイ"); // "Home ... first" + LSTR MSG_HOME_FIRST = _UxGT("サキニ %s ヲフッキサセテクダサイ"); // "Home ... first" LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Zオフセット"); // "Z Offset" LSTR MSG_BABYSTEP_X = _UxGT("Xジク ビドウ"); // "Babystep X" LSTR MSG_BABYSTEP_Y = _UxGT("Yジク ビドウ"); // "Babystep Y" diff --git a/Marlin/src/lcd/language/language_nl.h b/Marlin/src/lcd/language/language_nl.h index 8aa74d7e9fdc..25e349159714 100644 --- a/Marlin/src/lcd/language/language_nl.h +++ b/Marlin/src/lcd/language/language_nl.h @@ -153,7 +153,7 @@ namespace Language_nl { LSTR MSG_ZPROBE_OUT = _UxGT("Z probe uit. bed"); LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Zelf-Test"); LSTR MSG_BLTOUCH_RESET = _UxGT("Reset BLTouch"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s Eerst"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s Eerst"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Z Offset"); // accepted English term in Dutch LSTR MSG_BABYSTEP_X = _UxGT("Babystap X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystap Y"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index 635866baf106..823524c4e2d8 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -373,7 +373,7 @@ namespace Language_pl { LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Self-Test"); LSTR MSG_BLTOUCH_RESET = _UxGT("Reset BLTouch"); LSTR MSG_BLTOUCH_MODE_CHANGE = _UxGT("UWAGA: Złe ustawienia mogą uszkodzić drukarkę. Kontynuować?"); - LSTR MSG_HOME_FIRST = _UxGT("Najpierw Home %s%s%s"); + LSTR MSG_HOME_FIRST = _UxGT("Najpierw Home %s"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Offset Z"); LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Przesuń dyszę do stołu"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Łącznie"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index 1d07b2b94f22..2f8536218cc6 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -341,7 +341,7 @@ namespace Language_pt_br { LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Estender BLTouch"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Estender Sonda-Z"); LSTR MSG_MANUAL_STOW = _UxGT("Recolher Sonda-Z"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s Primeiro"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s Primeiro"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Compensar Sonda"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Compensar Sonda em X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Compensar Sonda em Y"); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index 2cf6fff263cc..a927a77e1d88 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -420,7 +420,7 @@ namespace Language_ro { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Deploy TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Deploy Z-Probe"); LSTR MSG_MANUAL_STOW = _UxGT("Stow Z-Probe"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s First"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s First"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Probe Offsets"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Probe X Offset"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Probe Y Offset"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index c9b4683bb20d..54492e8c8e8f 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -336,7 +336,7 @@ namespace Language_ru { LSTR MSG_MOVE_E = _UxGT("Экструдер"); LSTR MSG_MOVE_EN = _UxGT("Экструдер *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Сопло не нагрето"); - LSTR MSG_MOVE_N_MM = _UxGT("Движение %sмм"); + LSTR MSG_MOVE_N_MM = _UxGT("Движение $мм"); LSTR MSG_MOVE_01MM = _UxGT("Движение 0.1мм"); LSTR MSG_MOVE_1MM = _UxGT("Движение 1мм"); LSTR MSG_MOVE_10MM = _UxGT("Движение 10мм"); @@ -582,7 +582,7 @@ namespace Language_ru { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Установить TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Установить зонд"); LSTR MSG_MANUAL_STOW = _UxGT("Загрузить зонд"); - LSTR MSG_HOME_FIRST = _UxGT("Сначала паркуй %s%s%s"); + LSTR MSG_HOME_FIRST = _UxGT("Сначала паркуй %s"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Смещения Z-зонда"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Смещение X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Смещение Y"); diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index ef1396e81ff3..8559594bde05 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -419,7 +419,6 @@ namespace Language_sk { LSTR MSG_ADVANCE_K_E = _UxGT("K pre posun *"); LSTR MSG_CONTRAST = _UxGT("Kontrast LCD"); LSTR MSG_BRIGHTNESS = _UxGT("Jas LCD"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("Čas. limit LCD (s)"); LSTR MSG_SCREEN_TIMEOUT = _UxGT("Čas. limit LCD (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Podsviet. vyp."); LSTR MSG_STORE_EEPROM = _UxGT("Uložiť nastavenie"); @@ -552,7 +551,7 @@ namespace Language_sk { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Zasunúť TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Zasunúť sondu Z"); LSTR MSG_MANUAL_STOW = _UxGT("Vysunúť sondu Z"); - LSTR MSG_HOME_FIRST = _UxGT("Najskôr os %s%s%s domov"); + LSTR MSG_HOME_FIRST = _UxGT("Najskôr os %s domov"); LSTR MSG_ZPROBE_SETTINGS = _UxGT("Nastav. sondy"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Ofsety sondy Z"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("X ofset"); diff --git a/Marlin/src/lcd/language/language_sv.h b/Marlin/src/lcd/language/language_sv.h index 1342ccaad764..3803a382f83e 100644 --- a/Marlin/src/lcd/language/language_sv.h +++ b/Marlin/src/lcd/language/language_sv.h @@ -453,7 +453,7 @@ namespace Language_sv { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Fällut TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Fällut Z-Sond"); LSTR MSG_MANUAL_STOW = _UxGT("Stuva undan Z-Sond"); - LSTR MSG_HOME_FIRST = _UxGT("Hem %s%s%s Först"); + LSTR MSG_HOME_FIRST = _UxGT("Hem %s Först"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Sond Offsets"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Sond X Offset"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Sond Y Offset"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index cb2766306c8e..9a3be3a5040f 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -391,7 +391,7 @@ namespace Language_tr { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("TouchMI Aç"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Z-Probe Aç"); LSTR MSG_MANUAL_STOW = _UxGT("Z-Probe Kapat"); - LSTR MSG_HOME_FIRST = _UxGT("Önce %s%s%s Sıfırla"); + LSTR MSG_HOME_FIRST = _UxGT("Önce %s Sıfırla"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Prob Ofsetleri"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("X Prob Ofset"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Y Prob Ofset"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 6170faedaeea..801f825fde84 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -337,7 +337,7 @@ namespace Language_uk { LSTR MSG_MOVE_E = _UxGT("Екструдер"); LSTR MSG_MOVE_EN = _UxGT("Екструдер *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Сопло дуже холодне"); - LSTR MSG_MOVE_N_MM = _UxGT("Рух %sмм"); + LSTR MSG_MOVE_N_MM = _UxGT("Рух $мм"); LSTR MSG_MOVE_01MM = _UxGT("Рух 0.1мм"); LSTR MSG_MOVE_1MM = _UxGT("Рух 1мм"); LSTR MSG_MOVE_10MM = _UxGT("Рух 10мм"); @@ -455,7 +455,7 @@ namespace Language_uk { LSTR MSG_CONTRAST = _UxGT("Контраст"); LSTR MSG_BRIGHTNESS = _UxGT("Яскравість"); #endif - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD Таймаут, с"); + LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Таймаут, x"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Підсвітка вимк."); LSTR MSG_STORE_EEPROM = _UxGT("Зберегти в EEPROM"); LSTR MSG_LOAD_EEPROM = _UxGT("Зчитати з EEPROM"); @@ -599,7 +599,7 @@ namespace Language_uk { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Установити TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Установити Z-зонд"); LSTR MSG_MANUAL_STOW = _UxGT("Завантажити Z-зонд"); - LSTR MSG_HOME_FIRST = _UxGT("Спочатку дім %s%s%s"); + LSTR MSG_HOME_FIRST = _UxGT("Спочатку дім %s"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Зміщення зонду"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Зміщення по X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Зміщення по Y"); diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index 27c6ee11812f..64ea8f40f64f 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -327,7 +327,7 @@ namespace Language_vi { LSTR MSG_BLTOUCH_STOW = _UxGT("Cất BLTouch"); // Stow BLTouch LSTR MSG_MANUAL_DEPLOY = _UxGT("Đem Đầu Dò-Z"); // Deploy Z-Probe LSTR MSG_MANUAL_STOW = _UxGT("Cất Đầu Dò-Z"); // Stow Z-Probe - LSTR MSG_HOME_FIRST = _UxGT("Về nhà %s%s%s Trước"); + LSTR MSG_HOME_FIRST = _UxGT("Về nhà %s Trước"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Đầu Dò Bù Đắp Z"); // Probe Z Offset LSTR MSG_BABYSTEP_X = _UxGT("Nhít X"); // Babystep X LSTR MSG_BABYSTEP_Y = _UxGT("Nhít Y"); diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index 4c5a94edcdc8..9ad6f881b3ba 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -420,7 +420,7 @@ namespace Language_zh_CN { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("部署TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("部署Z探针"); LSTR MSG_MANUAL_STOW = _UxGT("收好Z探针"); - LSTR MSG_HOME_FIRST = _UxGT("归位 %s%s%s 先"); // "Home ... first" + LSTR MSG_HOME_FIRST = _UxGT("归位 %s 先"); // "Home ... first" LSTR MSG_ZPROBE_OFFSETS = _UxGT("探针偏移量"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("探针X偏移"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("探针Y偏移"); diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 4eba832c4ffb..0b9a3cbd8f76 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -226,6 +226,7 @@ namespace Language_zh_TW { LSTR MSG_MOVE_01MM = _UxGT("移動 0.1 mm"); // "Move 0.1mm" LSTR MSG_MOVE_1MM = _UxGT("移動 1 mm"); // "Move 1mm" LSTR MSG_MOVE_10MM = _UxGT("移動 10 mm"); // "Move 10mm" + LSTR MSG_MOVE_50MM = _UxGT("移動 50 mm"); // "Move 50mm" LSTR MSG_MOVE_100MM = _UxGT("移動 100 mm"); // "Move 100mm" LSTR MSG_SPEED = _UxGT("速率"); // "Speed" LSTR MSG_BED_Z = _UxGT("熱床Z"); // "Bed Z" @@ -369,7 +370,7 @@ namespace Language_zh_TW { LSTR MSG_BLTOUCH_STOW = _UxGT("裝載BLTouch"); // "Stow BLTouch" LSTR MSG_BLTOUCH_DEPLOY = _UxGT("部署BLTouch"); // "Deploy BLTouch" - LSTR MSG_HOME_FIRST = _UxGT("歸位 %s%s%s 先"); // "Home ... first" + LSTR MSG_HOME_FIRST = _UxGT("歸位 %s 先"); // "Home ... first" LSTR MSG_ZPROBE_OFFSETS = _UxGT("探針偏移"); //Probe Offsets LSTR MSG_ZPROBE_XOFFSET = _UxGT("探針X偏移量"); //Probe X Offset LSTR MSG_ZPROBE_YOFFSET = _UxGT("探針Y偏移量"); //Probe Y Offset diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index 7757379ac9d2..650824e553bc 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -52,7 +52,7 @@ lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/ if (!wc) break; if (wc == '=' || wc == '~' || wc == '*') { if (ind >= 0) { - if (wc == '*') { lcd_put_lchar('E'); n--; } + if (wc == '*') { lcd_put_u8str(F("E")); n--; } if (n) { int8_t inum = ind + ((wc == '=') ? 0 : LCD_FIRST_TOOL); if (inum >= 10) { diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index e03e80ed3ce3..ff12703ca94c 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -79,11 +79,16 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; statusResetFunc_t MarlinUI::status_reset_callback; // = nullptr #endif -#if ENABLED(LCD_SET_PROGRESS_MANUALLY) - MarlinUI::progress_t MarlinUI::progress_override; // = 0 - #if ENABLED(USE_M73_REMAINING_TIME) +#if ENABLED(SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) + MarlinUI::progress_t MarlinUI::progress_override; // = 0 + #endif + #if ENABLED(SET_REMAINING_TIME) uint32_t MarlinUI::remaining_time; #endif + #if ENABLED(SET_INTERACTION_TIME) + uint32_t MarlinUI::interaction_time; + #endif #endif #if HAS_MULTI_LANGUAGE @@ -153,7 +158,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; bool MarlinUI::lcd_clicked; #endif -#if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI) +#if LCD_WITH_BLINK bool MarlinUI::get_blink() { static uint8_t blink = 0; @@ -168,30 +173,42 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif +#if HAS_U8GLIB_I2C_OLED && PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) + #include "Wire.h" +#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 LCD_BACKLIGHT_TIMEOUT +#if LCD_BACKLIGHT_TIMEOUT_MINS - uint16_t MarlinUI::lcd_backlight_timeout; // Initialized by settings.load() + constexpr uint8_t MarlinUI::backlight_timeout_min, MarlinUI::backlight_timeout_max; + + uint8_t MarlinUI::backlight_timeout_minutes; // Initialized by settings.load() millis_t MarlinUI::backlight_off_ms = 0; void MarlinUI::refresh_backlight_timeout() { - backlight_off_ms = lcd_backlight_timeout ? millis() + lcd_backlight_timeout * 1000UL : 0; + backlight_off_ms = backlight_timeout_minutes ? millis() + backlight_timeout_minutes * 60UL * 1000UL : 0; WRITE(LCD_BACKLIGHT_PIN, HIGH); } #elif HAS_DISPLAY_SLEEP + constexpr uint8_t MarlinUI::sleep_timeout_min, MarlinUI::sleep_timeout_max; + uint8_t MarlinUI::sleep_timeout_minutes; // Initialized by settings.load() millis_t MarlinUI::screen_timeout_millis = 0; void MarlinUI::refresh_screen_timeout() { screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0; - sleep_off(); + sleep_display(false); } + #if !HAS_TOUCH_SLEEP && !HAS_MARLINUI_U8GLIB // without DOGM (COLOR_UI) + void MarlinUI::sleep_display(const bool sleep) {} // if unimplemented + #endif + #endif void MarlinUI::init() { @@ -217,14 +234,14 @@ void MarlinUI::init() { #if BUTTON_EXISTS(UP) SET_INPUT(BTN_UP); #endif - #if BUTTON_EXISTS(DWN) - SET_INPUT(BTN_DWN); + #if BUTTON_EXISTS(DOWN) + SET_INPUT(BTN_DOWN); #endif #if BUTTON_EXISTS(LFT) - SET_INPUT(BTN_LFT); + SET_INPUT(BTN_LEFT); #endif #if BUTTON_EXISTS(RT) - SET_INPUT(BTN_RT); + SET_INPUT(BTN_RIGHT); #endif #endif @@ -252,6 +269,10 @@ void MarlinUI::init() { slow_buttons = 0; #endif + #if HAS_U8GLIB_I2C_OLED && PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) + Wire.begin(int(I2C_SDA_PIN), int(I2C_SCL_PIN)); + #endif + update_buttons(); TERN_(HAS_ENCODER_ACTION, encoderDiff = 0); @@ -306,7 +327,7 @@ void MarlinUI::init() { #endif #endif - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT bool MarlinUI::defer_return_to_status; millis_t MarlinUI::return_to_status_ms = 0; #endif @@ -721,6 +742,11 @@ void MarlinUI::init() { void MarlinUI::wakeup_screen() { TERN(HAS_TOUCH_BUTTONS, touchBt.wakeUp(), touch.wakeUp()); } + #if HAS_DISPLAY_SLEEP && !HAS_MARLINUI_U8GLIB // without DOGM (COLOR_UI) + void MarlinUI::sleep_display(const bool sleep) { + if (!sleep) wakeup_screen(); // relay extra wake up events + } + #endif #endif void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { @@ -1059,7 +1085,7 @@ void MarlinUI::init() { reset_status_timeout(ms); - #if LCD_BACKLIGHT_TIMEOUT + #if LCD_BACKLIGHT_TIMEOUT_MINS refresh_backlight_timeout(); #elif HAS_DISPLAY_SLEEP refresh_screen_timeout(); @@ -1161,7 +1187,7 @@ void MarlinUI::init() { NOLESS(max_display_update_time, millis() - ms); } - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT // Return to Status Screen after a timeout if (on_status_screen() || defer_return_to_status) reset_status_timeout(ms); @@ -1169,14 +1195,14 @@ void MarlinUI::init() { return_to_status(); #endif - #if LCD_BACKLIGHT_TIMEOUT + #if LCD_BACKLIGHT_TIMEOUT_MINS if (backlight_off_ms && ELAPSED(ms, backlight_off_ms)) { WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off backlight_off_ms = 0; } #elif HAS_DISPLAY_SLEEP if (screen_timeout_millis && ELAPSED(ms, screen_timeout_millis)) - sleep_on(); + sleep_display(); #endif // Change state of drawing flag between screen updates @@ -1293,7 +1319,7 @@ void MarlinUI::init() { // // Directional buttons // - #if ANY_BUTTON(UP, DWN, LFT, RT) + #if ANY_BUTTON(UP, DOWN, LEFT, RIGHT) const int8_t pulses = epps * encoderDirection; @@ -1301,20 +1327,20 @@ void MarlinUI::init() { encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * pulses; next_button_update_ms = now + 300; } - else if (BUTTON_PRESSED(DWN)) { + else if (BUTTON_PRESSED(DOWN)) { encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * pulses; next_button_update_ms = now + 300; } - else if (BUTTON_PRESSED(LFT)) { + else if (BUTTON_PRESSED(LEFT)) { encoderDiff = -pulses; next_button_update_ms = now + 300; } - else if (BUTTON_PRESSED(RT)) { + else if (BUTTON_PRESSED(RIGHT)) { encoderDiff = pulses; next_button_update_ms = now + 300; } - #endif // UP || DWN || LFT || RT + #endif // UP || DOWN || LEFT || RIGHT buttons = (newbutton | TERN0(HAS_SLOW_BUTTONS, slow_buttons) #if BOTH(HAS_TOUCH_BUTTONS, HAS_ENCODER_ACTION) @@ -1372,10 +1398,10 @@ void MarlinUI::init() { 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; + case 0: ENCODER_SPIN(1, 2); break; + case 2: ENCODER_SPIN(0, 3); break; + case 3: ENCODER_SPIN(2, 1); break; + case 1: ENCODER_SPIN(3, 0); break; } #if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL) external_encoder(); @@ -1620,10 +1646,11 @@ void MarlinUI::init() { #ifdef ACTION_ON_CANCEL hostui.cancel(); #endif - IF_DISABLED(SDSUPPORT, print_job_timer.stop()); + print_job_timer.stop(); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("UI Aborted"), FPSTR(DISMISS_STR))); LCD_MESSAGE(MSG_PRINT_ABORTED); TERN_(HAS_MARLINUI_MENU, return_to_status()); + TERN_(DWIN_LCD_PROUI, HMI_flag.abort_flag = true); } #if BOTH(HAS_MARLINUI_MENU, PSU_CONTROL) @@ -1672,19 +1699,6 @@ void MarlinUI::init() { print_job_timer.start(); // Also called by M24 } - #if HAS_PRINT_PROGRESS - - MarlinUI::progress_t MarlinUI::_get_progress() { - return ( - TERN0(LCD_SET_PROGRESS_MANUALLY, (progress_override & PROGRESS_MASK)) - #if ENABLED(SDSUPPORT) - ?: TERN(HAS_PRINT_PROGRESS_PERMYRIAD, card.permyriadDone(), card.percentDone()) - #endif - ); - } - - #endif - #if HAS_TOUCH_BUTTONS // @@ -1718,6 +1732,38 @@ void MarlinUI::init() { #endif // HAS_DISPLAY +#if HAS_PRINT_PROGRESS + + MarlinUI::progress_t MarlinUI::_get_progress() { + return ( + TERN0(SET_PROGRESS_PERCENT, (progress_override & PROGRESS_MASK)) + #if ENABLED(SDSUPPORT) + ?: TERN(HAS_PRINT_PROGRESS_PERMYRIAD, card.permyriadDone(), card.percentDone()) + #endif + ); + } + + #if LCD_WITH_BLINK && DISABLED(HAS_GRAPHICAL_TFT) + typedef void (*PrintProgress_t)(); + void MarlinUI::rotate_progress() { // Renew and redraw all enabled progress strings + const PrintProgress_t progFunc[] = { + OPTITEM(SHOW_PROGRESS_PERCENT, drawPercent) + OPTITEM(SHOW_ELAPSED_TIME, drawElapsed) + OPTITEM(SHOW_REMAINING_TIME, drawRemain) + OPTITEM(SHOW_INTERACTION_TIME, drawInter) + }; + static bool prev_blink; + static uint8_t i; + if (prev_blink != get_blink()) { + prev_blink = get_blink(); + if (++i >= COUNT(progFunc)) i = 0; + (*progFunc[i])(); + } + } + #endif + +#endif // HAS_PRINT_PROGRESS + #if ENABLED(SDSUPPORT) #if ENABLED(EXTENSIBLE_UI) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index b2a9bb5de955..ec19f8bd34ba 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -25,7 +25,6 @@ #include "../sd/cardreader.h" #include "../module/motion.h" #include "../libs/buzzer.h" - #include "buttons.h" #if ENABLED(TOUCH_SCREEN_CALIBRATION) @@ -36,7 +35,7 @@ #define MULTI_E_MANUAL 1 #endif -#if HAS_DISPLAY +#if HAS_PRINT_PROGRESS #include "../module/printcounter.h" #endif @@ -86,6 +85,7 @@ typedef bool (*statusResetFunc_t)(); #endif // HAS_WIRED_LCD #if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI) + #define LCD_WITH_BLINK 1 #define LCD_UPDATE_INTERVAL TERN(HAS_TOUCH_BUTTONS, 50, 100) #endif @@ -270,20 +270,19 @@ class MarlinUI { FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); } #endif - #if LCD_BACKLIGHT_TIMEOUT - #define LCD_BKL_TIMEOUT_MIN 1u - #define LCD_BKL_TIMEOUT_MAX UINT16_MAX // Slightly more than 18 hours - static uint16_t lcd_backlight_timeout; + #if LCD_BACKLIGHT_TIMEOUT_MINS + static constexpr uint8_t backlight_timeout_min = 0; + static constexpr uint8_t backlight_timeout_max = 99; + static uint8_t backlight_timeout_minutes; static millis_t backlight_off_ms; static void refresh_backlight_timeout(); #elif HAS_DISPLAY_SLEEP - #define SLEEP_TIMEOUT_MIN 0 - #define SLEEP_TIMEOUT_MAX 99 + static constexpr uint8_t sleep_timeout_min = 0; + static constexpr uint8_t sleep_timeout_max = 99; static uint8_t sleep_timeout_minutes; static millis_t screen_timeout_millis; static void refresh_screen_timeout(); - static void sleep_on(); - static void sleep_off(); + static void sleep_display(const bool sleep=true); #endif #if HAS_DWIN_E3V2_BASIC @@ -304,19 +303,19 @@ class MarlinUI { #define PROGRESS_SCALE 1U #define PROGRESS_MASK 0x7F #endif - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) static progress_t progress_override; static void set_progress(const progress_t p) { progress_override = _MIN(p, 100U * (PROGRESS_SCALE)); } static void set_progress_done() { progress_override = (PROGRESS_MASK + 1U) + 100U * (PROGRESS_SCALE); } static void progress_reset() { if (progress_override & (PROGRESS_MASK + 1U)) set_progress(0); } #endif - #if ENABLED(SHOW_REMAINING_TIME) + #if EITHER(SHOW_REMAINING_TIME, SET_PROGRESS_MANUALLY) static uint32_t _calculated_remaining_time() { const duration_t elapsed = print_job_timer.duration(); const progress_t progress = _get_progress(); return progress ? elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress : 0; } - #if ENABLED(USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) static uint32_t remaining_time; FORCE_INLINE static void set_remaining_time(const uint32_t r) { remaining_time = r; } FORCE_INLINE static uint32_t get_remaining_time() { return remaining_time ?: _calculated_remaining_time(); } @@ -324,12 +323,32 @@ class MarlinUI { #else FORCE_INLINE static uint32_t get_remaining_time() { return _calculated_remaining_time(); } #endif + #if ENABLED(SET_INTERACTION_TIME) + static uint32_t interaction_time; + FORCE_INLINE static void set_interaction_time(const uint32_t r) { interaction_time = r; } + FORCE_INLINE static void reset_interaction_time() { set_interaction_time(0); } + #endif #endif static progress_t _get_progress(); #if HAS_PRINT_PROGRESS_PERMYRIAD FORCE_INLINE static uint16_t get_progress_permyriad() { return _get_progress(); } #endif static uint8_t get_progress_percent() { return uint8_t(_get_progress() / (PROGRESS_SCALE)); } + #if LCD_WITH_BLINK + #if ENABLED(SHOW_PROGRESS_PERCENT) + static void drawPercent(); + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + static void drawElapsed(); + #endif + #if ENABLED(SHOW_REMAINING_TIME) + static void drawRemain(); + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + static void drawInter(); + #endif + static void rotate_progress(); + #endif #else static constexpr uint8_t get_progress_percent() { return 0; } #endif @@ -391,7 +410,7 @@ class MarlinUI { static void poweroff(); #endif - #if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI) + #if LCD_WITH_BLINK static bool get_blink(); #endif @@ -526,7 +545,7 @@ class MarlinUI { #endif static void reset_status_timeout(const millis_t ms) { - TERN(SCREENS_CAN_TIME_OUT, return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS, UNUSED(ms)); + TERN(HAS_SCREEN_TIMEOUT, return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS, UNUSED(ms)); } #if HAS_MARLINUI_MENU @@ -577,11 +596,11 @@ class MarlinUI { #endif FORCE_INLINE static bool screen_is_sticky() { - return TERN1(SCREENS_CAN_TIME_OUT, defer_return_to_status); + return TERN1(HAS_SCREEN_TIMEOUT, defer_return_to_status); } FORCE_INLINE static void defer_status_screen(const bool defer=true) { - TERN(SCREENS_CAN_TIME_OUT, defer_return_to_status = defer, UNUSED(defer)); + TERN(HAS_SCREEN_TIMEOUT, defer_return_to_status = defer, UNUSED(defer)); } static void goto_previous_screen_no_defer() { @@ -759,7 +778,7 @@ class MarlinUI { private: - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT static millis_t return_to_status_ms; static bool defer_return_to_status; #else diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 9dd74988f32a..6389383d287a 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -61,7 +61,7 @@ typedef struct { 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 + #if HAS_SCREEN_TIMEOUT bool sticky; // The screen is sticky #endif } menuPosition; @@ -89,7 +89,7 @@ void MarlinUI::return_to_status() { goto_screen(status_screen); } void MarlinUI::push_current_screen() { if (screen_history_depth < COUNT(screen_history)) - screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items OPTARG(SCREENS_CAN_TIME_OUT, screen_is_sticky()) }; + screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items OPTARG(HAS_SCREEN_TIMEOUT, screen_is_sticky()) }; } void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) { @@ -102,7 +102,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)); + defer_status_screen(TERN_(HAS_SCREEN_TIMEOUT, sh.sticky)); } else return_to_status(); @@ -175,7 +175,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co TERN_(HAS_TOUCH_BUTTONS, repeat_delay = BUTTON_DELAY_MENU); - TERN_(LCD_SET_PROGRESS_MANUALLY, progress_reset()); + TERN_(SET_PROGRESS_PERCENT, progress_reset()); #if BOTH(DOUBLECLICK_FOR_Z_BABYSTEPPING, BABYSTEPPING) static millis_t doubleclick_expire_ms = 0; diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index f9f4116bc3a0..f56b4f899731 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -31,6 +31,7 @@ #include "menu_item.h" #include "../../MarlinCore.h" #include "../../module/planner.h" +#include "../../module/stepper.h" #if DISABLED(NO_VOLUMETRICS) #include "../../gcode/parser.h" @@ -80,8 +81,6 @@ void menu_backlash(); #if HAS_MOTOR_CURRENT_PWM - #include "../../module/stepper.h" - void menu_pwm() { START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); @@ -109,9 +108,9 @@ void menu_backlash(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #if ENABLED(LIN_ADVANCE) - #if EXTRUDERS == 1 + #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); - #elif HAS_MULTI_EXTRUDER + #else EXTRUDER_LOOP() EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif @@ -209,37 +208,59 @@ void menu_backlash(); #if ENABLED(PID_EDIT_MENU) - float raw_Ki, raw_Kd; // place-holders for Ki and Kd edits + // Placeholders for PID editing + float raw_Kp, raw_Ki, raw_Kd; + #if ENABLED(PID_EXTRUSION_SCALING) + float raw_Kc; + #endif + #if ENABLED(PID_FAN_SCALING) + float raw_Kf; + #endif - // Helpers for editing PID Ki & Kd values - // grab the PID value out of the temp variable; scale it; then update the PID driver - void copy_and_scalePID_i(const int8_t e) { + // Helpers for editing PID Kp, Ki and Kd values + void apply_PID_p(const int8_t e) { + switch (e) { + #if ENABLED(PIDTEMPBED) + case H_BED: thermalManager.temp_bed.pid.set_Kp(raw_Kp); break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: thermalManager.temp_chamber.pid.set_Kp(raw_Kp); break; + #endif + default: + #if ENABLED(PIDTEMP) + SET_HOTEND_PID(Kp, e, raw_Kp); + thermalManager.updatePID(); + #endif + break; + } + } + void apply_PID_i(const int8_t e) { switch (e) { #if ENABLED(PIDTEMPBED) - case H_BED: thermalManager.temp_bed.pid.Ki = scalePID_i(raw_Ki); break; + case H_BED: thermalManager.temp_bed.pid.set_Ki(raw_Ki); break; #endif #if ENABLED(PIDTEMPCHAMBER) - case H_CHAMBER: thermalManager.temp_chamber.pid.Ki = scalePID_i(raw_Ki); break; + case H_CHAMBER: thermalManager.temp_chamber.pid.set_Ki(raw_Ki); break; #endif default: #if ENABLED(PIDTEMP) - PID_PARAM(Ki, e) = scalePID_i(raw_Ki); + SET_HOTEND_PID(Ki, e, raw_Ki); thermalManager.updatePID(); #endif break; } } - void copy_and_scalePID_d(const int8_t e) { + void apply_PID_d(const int8_t e) { switch (e) { #if ENABLED(PIDTEMPBED) - case H_BED: thermalManager.temp_bed.pid.Kd = scalePID_d(raw_Kd); break; + case H_BED: thermalManager.temp_bed.pid.set_Kd(raw_Kd); break; #endif #if ENABLED(PIDTEMPCHAMBER) - case H_CHAMBER: thermalManager.temp_chamber.pid.Kd = scalePID_d(raw_Kd); break; + case H_CHAMBER: thermalManager.temp_chamber.pid.set_Kd(raw_Kd); break; #endif default: #if ENABLED(PIDTEMP) - PID_PARAM(Kd, e) = scalePID_d(raw_Kd); + SET_HOTEND_PID(Kd, e, raw_Kd); thermalManager.updatePID(); #endif break; @@ -291,16 +312,18 @@ void menu_backlash(); #if BOTH(PIDTEMP, PID_EDIT_MENU) #define __PID_HOTEND_MENU_ITEMS(N) \ - raw_Ki = unscalePID_i(PID_PARAM(Ki, N)); \ - raw_Kd = unscalePID_d(PID_PARAM(Kd, N)); \ - EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &PID_PARAM(Kp, N), 1, 9990); \ - EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ copy_and_scalePID_i(N); }); \ - EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ copy_and_scalePID_d(N); }) + raw_Kp = thermalManager.temp_hotend[N].pid.p(); \ + raw_Ki = thermalManager.temp_hotend[N].pid.i(); \ + raw_Kd = thermalManager.temp_hotend[N].pid.d(); \ + EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &raw_Kp, 1, 9990, []{ apply_PID_p(N); }); \ + EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ apply_PID_i(N); }); \ + EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ apply_PID_d(N); }) #if ENABLED(PID_EXTRUSION_SCALING) #define _PID_HOTEND_MENU_ITEMS(N) \ __PID_HOTEND_MENU_ITEMS(N); \ - EDIT_ITEM_N(float4, N, MSG_PID_C_E, &PID_PARAM(Kc, N), 1, 9990) + raw_Kc = thermalManager.temp_hotend[N].pid.c(); \ + EDIT_ITEM_N(float4, N, MSG_PID_C_E, &raw_Kc, 1, 9990, []{ SET_HOTEND_PID(Kc, N, raw_Kc); thermalManager.updatePID(); }); #else #define _PID_HOTEND_MENU_ITEMS(N) __PID_HOTEND_MENU_ITEMS(N) #endif @@ -308,7 +331,8 @@ void menu_backlash(); #if ENABLED(PID_FAN_SCALING) #define _HOTEND_PID_EDIT_MENU_ITEMS(N) \ _PID_HOTEND_MENU_ITEMS(N); \ - EDIT_ITEM_N(float4, N, MSG_PID_F_E, &PID_PARAM(Kf, N), 1, 9990) + raw_Kf = thermalManager.temp_hotend[N].pid.f(); \ + EDIT_ITEM_N(float4, N, MSG_PID_F_E, &raw_Kf, 1, 9990, []{ SET_HOTEND_PID(Kf, N, raw_Kf); thermalManager.updatePID(); }); #else #define _HOTEND_PID_EDIT_MENU_ITEMS(N) _PID_HOTEND_MENU_ITEMS(N) #endif @@ -321,11 +345,12 @@ void menu_backlash(); #if ENABLED(PID_EDIT_MENU) && EITHER(PIDTEMPBED, PIDTEMPCHAMBER) #define _PID_EDIT_ITEMS_TMPL(N,T) \ - raw_Ki = unscalePID_i(T.pid.Ki); \ - raw_Kd = unscalePID_d(T.pid.Kd); \ - EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &T.pid.Kp, 1, 9990); \ - EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ copy_and_scalePID_i(N); }); \ - EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ copy_and_scalePID_d(N); }) + raw_Kp = T.pid.p(); \ + raw_Ki = T.pid.i(); \ + raw_Kd = T.pid.d(); \ + EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &raw_Kp, 1, 9990, []{ apply_PID_p(N); }); \ + EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ apply_PID_i(N); }); \ + EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ apply_PID_d(N); }) #endif #if ENABLED(PIDTEMP) @@ -451,7 +476,9 @@ void menu_backlash(); // M201 / M204 Accelerations void menu_advanced_acceleration() { - const float max_accel = _MAX(planner.settings.max_acceleration_mm_per_s2[A_AXIS], planner.settings.max_acceleration_mm_per_s2[B_AXIS], planner.settings.max_acceleration_mm_per_s2[C_AXIS]); + float max_accel = planner.settings.max_acceleration_mm_per_s2[A_AXIS]; + TERN_(HAS_Y_AXIS, NOLESS(max_accel, planner.settings.max_acceleration_mm_per_s2[B_AXIS])); + TERN_(HAS_Z_AXIS, NOLESS(max_accel, planner.settings.max_acceleration_mm_per_s2[C_AXIS])); // M201 settings constexpr xyze_ulong_t max_accel_edit = @@ -510,6 +537,43 @@ void menu_backlash(); END_MENU(); } + #if ENABLED(SHAPING_MENU) + + void menu_advanced_input_shaping() { + constexpr float min_frequency = TERN(__AVR__, float(STEPPER_TIMER_RATE) / 2 / 0x10000, 1.0f); + + START_MENU(); + BACK_ITEM(MSG_ADVANCED_SETTINGS); + + // M593 F Frequency and D Damping ratio + #if ENABLED(INPUT_SHAPING_X) + editable.decimal = stepper.get_shaping_frequency(X_AXIS); + if (editable.decimal) { + ACTION_ITEM_N(X_AXIS, MSG_SHAPING_DISABLE, []{ stepper.set_shaping_frequency(X_AXIS, 0.0f); }); + EDIT_ITEM_FAST_N(float61, X_AXIS, MSG_SHAPING_FREQ, &editable.decimal, min_frequency, 200.0f, []{ stepper.set_shaping_frequency(X_AXIS, editable.decimal); }); + editable.decimal = stepper.get_shaping_damping_ratio(X_AXIS); + EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_SHAPING_ZETA, &editable.decimal, 0.0f, 1.0f, []{ stepper.set_shaping_damping_ratio(X_AXIS, editable.decimal); }); + } + else + ACTION_ITEM_N(X_AXIS, MSG_SHAPING_ENABLE, []{ stepper.set_shaping_frequency(X_AXIS, SHAPING_FREQ_X); }); + #endif + #if ENABLED(INPUT_SHAPING_Y) + editable.decimal = stepper.get_shaping_frequency(Y_AXIS); + if (editable.decimal) { + ACTION_ITEM_N(Y_AXIS, MSG_SHAPING_DISABLE, []{ stepper.set_shaping_frequency(Y_AXIS, 0.0f); }); + EDIT_ITEM_FAST_N(float61, Y_AXIS, MSG_SHAPING_FREQ, &editable.decimal, min_frequency, 200.0f, []{ stepper.set_shaping_frequency(Y_AXIS, editable.decimal); }); + editable.decimal = stepper.get_shaping_damping_ratio(Y_AXIS); + EDIT_ITEM_FAST_N(float42_52, Y_AXIS, MSG_SHAPING_ZETA, &editable.decimal, 0.0f, 1.0f, []{ stepper.set_shaping_damping_ratio(Y_AXIS, editable.decimal); }); + } + else + ACTION_ITEM_N(Y_AXIS, MSG_SHAPING_ENABLE, []{ stepper.set_shaping_frequency(Y_AXIS, SHAPING_FREQ_Y); }); + #endif + + END_MENU(); + } + + #endif + #if HAS_CLASSIC_JERK void menu_advanced_jerk() { @@ -576,11 +640,11 @@ void menu_advanced_steps_per_mm() { BACK_ITEM(MSG_ADVANCED_SETTINGS); LOOP_NUM_AXES(a) - EDIT_ITEM_FAST_N(float61, a, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[a], 5, 9999, []{ planner.refresh_positioning(); }); + EDIT_ITEM_FAST_N(float72, a, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[a], 5, 9999, []{ planner.refresh_positioning(); }); #if ENABLED(DISTINCT_E_FACTORS) LOOP_L_N(n, E_STEPPERS) - EDIT_ITEM_FAST_N(float61, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ + EDIT_ITEM_FAST_N(float72, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ const uint8_t e = MenuItemBase::itemIndex; if (e == active_extruder) planner.refresh_positioning(); @@ -588,7 +652,7 @@ void menu_advanced_steps_per_mm() { planner.mm_per_step[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)]; }); #elif E_STEPPERS - EDIT_ITEM_FAST_N(float61, E_AXIS, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); + EDIT_ITEM_FAST_N(float72, E_AXIS, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); #endif END_MENU(); @@ -606,10 +670,20 @@ void menu_advanced_settings() { #if DISABLED(SLIM_LCD_MENUS) + #if ENABLED(POLARGRAPH) + // M665 - Polargraph Settings + if (!is_busy) { + EDIT_ITEM_FAST(float4, MSG_SEGMENTS_PER_SECOND, &segments_per_second, 100, 9999); // M665 S + EDIT_ITEM_FAST(float51sign, MSG_DRAW_MIN_X, &draw_area_min.x, X_MIN_POS, draw_area_max.x - 10); // M665 L + EDIT_ITEM_FAST(float51sign, MSG_DRAW_MAX_X, &draw_area_max.x, draw_area_min.x + 10, X_MAX_POS); // M665 R + EDIT_ITEM_FAST(float51sign, MSG_DRAW_MIN_Y, &draw_area_min.y, Y_MIN_POS, draw_area_max.y - 10); // M665 T + EDIT_ITEM_FAST(float51sign, MSG_DRAW_MAX_Y, &draw_area_max.y, draw_area_min.y + 10, Y_MAX_POS); // M665 B + EDIT_ITEM_FAST(float51sign, MSG_MAX_BELT_LEN, &polargraph_max_belt_len, 500, 2000); // M665 H + } + #endif + #if HAS_M206_COMMAND - // - // Set Home Offsets - // + // M428 - Set Home Offsets ACTION_ITEM(MSG_SET_HOME_OFFSETS, []{ queue.inject(F("M428")); ui.return_to_status(); }); #endif @@ -619,6 +693,11 @@ void menu_advanced_settings() { // M201 - Acceleration items SUBMENU(MSG_ACCELERATION, menu_advanced_acceleration); + // M593 - Acceleration items + #if ENABLED(SHAPING_MENU) + if (!is_busy) SUBMENU(MSG_INPUT_SHAPING, menu_advanced_input_shaping); + #endif + #if HAS_CLASSIC_JERK // M205 - Max Jerk SUBMENU(MSG_JERK, menu_advanced_jerk); @@ -661,11 +740,11 @@ void menu_advanced_settings() { #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE) SUBMENU(MSG_FILAMENT, menu_advanced_filament); #elif ENABLED(LIN_ADVANCE) - #if EXTRUDERS == 1 + #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); - #elif HAS_MULTI_EXTRUDER - LOOP_L_N(n, E_STEPPERS) - EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10); + #else + EXTRUDER_LOOP() + EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif #endif diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index c4a63dafc6ac..0e0051e65d6c 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -178,7 +178,7 @@ static void _lcd_level_bed_corners_get_next_position() { lcd_put_u8str(GET_TEXT_F(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_lchar('/'); + lcd_put_u8str(F("/")); lcd_put_u8str(GOOD_POINTS_TO_STR(nr_edge_points)); } diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 294666e35621..9505a82dd77c 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -68,10 +68,12 @@ // void _lcd_level_bed_done() { if (!ui.wait_for_move) { - #if Z_AFTER_PROBING > 0 && DISABLED(MESH_BED_LEVELING) - // Display "Done" screen and wait for moves to complete - line_to_z(Z_AFTER_PROBING); - ui.synchronize(GET_TEXT_F(MSG_LEVEL_BED_DONE)); + #if DISABLED(MESH_BED_LEVELING) && defined(Z_AFTER_PROBING) + if (Z_AFTER_PROBING) { + // Display "Done" screen and wait for moves to complete + line_to_z(Z_AFTER_PROBING); + ui.synchronize(GET_TEXT_F(MSG_LEVEL_BED_DONE)); + } #endif ui.goto_previous_screen_no_defer(); ui.completion_feedback(); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 1f2257a77fe3..e50cd69f6302 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -79,7 +79,7 @@ void menu_advanced_settings(); LIMIT(bar_percent, 0, 100); ui.encoderPosition = 0; MenuItem_static::draw(0, GET_TEXT_F(MSG_PROGRESS_BAR_TEST), SS_DEFAULT|SS_INVERT); - lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_lchar('%'); + lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_u8str(F("%")); lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent); } @@ -124,6 +124,7 @@ void menu_advanced_settings(); EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_UNRETRACT_SPEED, &toolchange_settings.unretract_speed, 10, 5400); EDIT_ITEM(float3, MSG_FILAMENT_PURGE_LENGTH, &toolchange_settings.extra_prime, 0, max_extrude); EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_PRIME_SPEED, &toolchange_settings.prime_speed, 10, 5400); + EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_WIPE_RETRACT, &toolchange_settings.wipe_retract, 0, 100); EDIT_ITEM_FAST(uint8, MSG_SINGLENOZZLE_FAN_SPEED, &toolchange_settings.fan_speed, 0, 255); EDIT_ITEM_FAST(uint8, MSG_SINGLENOZZLE_FAN_TIME, &toolchange_settings.fan_time, 1, 30); #endif @@ -547,10 +548,10 @@ void menu_configuration() { // // Set display backlight / sleep timeout // - #if LCD_BACKLIGHT_TIMEOUT && LCD_BKL_TIMEOUT_MIN < LCD_BKL_TIMEOUT_MAX - EDIT_ITEM(uint16_4, MSG_LCD_TIMEOUT_SEC, &ui.lcd_backlight_timeout, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX, ui.refresh_backlight_timeout); + #if LCD_BACKLIGHT_TIMEOUT_MINS + EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.backlight_timeout_minutes, ui.backlight_timeout_min, ui.backlight_timeout_max, ui.refresh_backlight_timeout); #elif HAS_DISPLAY_SLEEP - EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX, ui.refresh_screen_timeout); + EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, ui.sleep_timeout_min, ui.sleep_timeout_max, ui.refresh_screen_timeout); #endif #if ENABLED(FWRETRACT) diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index b0eab65c649b..5cc5f1114250 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -153,6 +153,7 @@ DEFINE_MENU_EDIT_ITEM_TYPE(float4 ,float ,ftostr4sign , 1 ); DEFINE_MENU_EDIT_ITEM_TYPE(float5 ,float ,ftostr5rj , 1 ); // 12345 right-justified DEFINE_MENU_EDIT_ITEM_TYPE(float5_25 ,float ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) DEFINE_MENU_EDIT_ITEM_TYPE(float61 ,float ,ftostr61rj , 10 ); // 12345.6 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float72 ,float ,ftostr72rj , 100 ); // 12345.67 right-justified DEFINE_MENU_EDIT_ITEM_TYPE(float31sign ,float ,ftostr31sign , 10 ); // +12.3 DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float ,ftostr41sign , 10 ); // +123.4 DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float ,ftostr51sign , 10 ); // +1234.5 @@ -402,8 +403,13 @@ class MenuItem_bool : public MenuEditItemBase { // Predefined menu item types // -#define BACK_ITEM_F(FLABEL) MENU_ITEM_F(back, FLABEL) -#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL) +#if DISABLED(DISABLE_ENCODER) + #define BACK_ITEM_F(FLABEL) MENU_ITEM_F(back, FLABEL) + #define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL) +#else + #define BACK_ITEM_F(FLABEL) NOOP + #define BACK_ITEM(LABEL) NOOP +#endif #define ACTION_ITEM_N_S_F(N, S, FLABEL, ACTION) MENU_ITEM_N_S_F(function, N, S, FLABEL, ACTION) #define ACTION_ITEM_N_S(N, S, LABEL, ACTION) ACTION_ITEM_N_S_F(N, S, GET_TEXT_F(LABEL), ACTION) diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 518f1e0f502d..81b36d2b01a9 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -222,6 +222,16 @@ void menu_configuration(); #endif // CUSTOM_MENU_MAIN +#if ENABLED(ADVANCED_PAUSE_FEATURE) + // This menu item is last with an encoder. Otherwise, somewhere in the middle. + #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) + #define FILAMENT_CHANGE_ITEM() YESNO_ITEM(MSG_FILAMENTCHANGE, menu_change_filament, nullptr, \ + GET_TEXT_F(MSG_FILAMENTCHANGE), (const char *)nullptr, F("?")) + #else + #define FILAMENT_CHANGE_ITEM() SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament) + #endif +#endif + void menu_main() { const bool busy = printingIsActive() #if ENABLED(SDSUPPORT) @@ -233,43 +243,8 @@ void menu_main() { START_MENU(); BACK_ITEM(MSG_INFO_SCREEN); - #if ENABLED(SDSUPPORT) - - #if !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL - #define MEDIA_MENU_AT_TOP - #endif - - auto sdcard_menu_items = [&]{ - #if ENABLED(MENU_ADDAUTOSTART) - ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files - #endif - - if (card_detected) { - if (!card_open) { - #if HAS_SD_DETECT - GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21")); // M21 Change Media - #else // - or - - ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media - queue.inject(F("M22")); - #if ENABLED(TFT_COLOR_UI) - // Menu display issue on item removal with multi language selection menu - if (encoderTopLine > 0) encoderTopLine--; - ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); - #endif - }); - #endif - SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) - } - } - else { - #if HAS_SD_DETECT - ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" - #else - GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media - #endif - } - }; - + #if ENABLED(SDSUPPORT) && !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL + #define MEDIA_MENU_AT_TOP #endif if (busy) { @@ -298,9 +273,43 @@ void menu_main() { #endif } else { - #if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP) - sdcard_menu_items(); + // BEGIN MEDIA MENU + #if ENABLED(MENU_ADDAUTOSTART) + ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files + #endif + + if (card_detected) { + if (!card_open) { + #if HAS_SD_DETECT + GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21" TERN_(MULTI_VOLUME, "S"))); // M21 Change Media + #if ENABLED(MULTI_VOLUME) + GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21 Attach USB Media + #endif + #else // - or - + ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media + queue.inject(F("M22")); + #if ENABLED(TFT_COLOR_UI) + // Menu display issue on item removal with multi language selection menu + if (encoderTopLine > 0) encoderTopLine--; + ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); + #endif + }); + #endif + SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) + } + } + else { + #if HAS_SD_DETECT + ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" + #else + GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21" TERN_(MULTI_VOLUME, "S"))); // M21 Attach Media + #if ENABLED(MULTI_VOLUME) + GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21 Attach USB Media + #endif + #endif + } + // END MEDIA MENU #endif if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) @@ -317,6 +326,10 @@ void menu_main() { SUBMENU(MSG_MOTION, menu_motion); } + #if BOTH(ADVANCED_PAUSE_FEATURE, DISABLE_ENCODER) + FILAMENT_CHANGE_ITEM(); + #endif + #if HAS_CUTTER SUBMENU(MSG_CUTTER(MENU), STICKY_SCREEN(menu_spindle_laser)); #endif @@ -349,17 +362,6 @@ void menu_main() { } #endif - #if ENABLED(ADVANCED_PAUSE_FEATURE) - #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) - YESNO_ITEM(MSG_FILAMENTCHANGE, - menu_change_filament, nullptr, - GET_TEXT_F(MSG_FILAMENTCHANGE), (const char *)nullptr, F("?") - ); - #else - SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament); - #endif - #endif - #if ENABLED(LCD_INFO_MENU) SUBMENU(MSG_INFO_MENU, menu_info); #endif @@ -387,7 +389,42 @@ void menu_main() { #endif #if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP) - sdcard_menu_items(); + // BEGIN MEDIA MENU + #if ENABLED(MENU_ADDAUTOSTART) + ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files + #endif + + if (card_detected) { + if (!card_open) { + #if HAS_SD_DETECT + GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21" TERN_(MULTI_VOLUME, "S"))); // M21 Change Media + #if ENABLED(MULTI_VOLUME) + GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21 Attach USB Media + #endif + #else // - or - + ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media + queue.inject(F("M22")); + #if ENABLED(TFT_COLOR_UI) + // Menu display issue on item removal with multi language selection menu + if (encoderTopLine > 0) encoderTopLine--; + ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); + #endif + }); + #endif + SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) + } + } + else { + #if HAS_SD_DETECT + ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" + #else + GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21" TERN_(MULTI_VOLUME, "S"))); // M21 Attach Media + #if ENABLED(MULTI_VOLUME) + GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21 Attach USB Media + #endif + #endif + } + // END MEDIA MENU #endif #if HAS_SERVICE_INTERVALS @@ -458,6 +495,10 @@ void menu_main() { }); #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) && DISABLED(DISABLE_ENCODER) + FILAMENT_CHANGE_ITEM(); + #endif + END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index d5c242442994..4d8cc71553b3 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -28,7 +28,13 @@ #if HAS_MARLINUI_MENU -#define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || (Y_BED_SIZE) >= 1000 || (Z_MAX_POS) >= 1000) +#if ENABLED(TRULY_LARGE_AREA) + #define LARGE_AREA_TEST true +#elif ENABLED(SLIM_LCD_MENUS) + #define LARGE_AREA_TEST false +#else + #define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || TERN0(HAS_Y_AXIS, (Y_BED_SIZE) >= 1000) || TERN0(HAS_Z_AXIS, (Z_MAX_POS) >= 1000)) +#endif #include "menu_item.h" #include "menu_addon.h" @@ -150,18 +156,26 @@ 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)); }); + if (LARGE_AREA_TEST) { + SUBMENU(MSG_MOVE_1IN, []{ _goto_manual_move(IN_TO_MM(1.000f)); }); + SUBMENU(MSG_MOVE_05IN, []{ _goto_manual_move(IN_TO_MM(0.500f)); }); + } 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); }); + if (LARGE_AREA_TEST) { + SUBMENU(MSG_MOVE_100MM, []{ _goto_manual_move(100); }); + SUBMENU(MSG_MOVE_50MM, []{ _goto_manual_move(50); }); + } 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); }); - if (axis == Z_AXIS && (FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) - SUBMENU_f(F(STRINGIFY(FINE_MANUAL_MOVE)), MSG_MOVE_N_MM, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); }); + #if HAS_Z_AXIS + if (axis == Z_AXIS && (FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) + SUBMENU_f(F(STRINGIFY(FINE_MANUAL_MOVE)), MSG_MOVE_N_MM, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); }); + #endif } END_MENU(); } @@ -354,6 +368,13 @@ void menu_motion() { GCODES_ITEM(MSG_MANUAL_STOW, F("M402")); #endif + // + // Probe Offset Wizard + // + #if ENABLED(PROBE_OFFSET_WIZARD) + SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard); + #endif + // // Assisted Bed Tramming // diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index d29b77311fd3..b50194d60dc8 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -61,10 +61,10 @@ void Password::menu_password_entry() { FSTR_P const label = GET_TEXT_F(MSG_ENTER_DIGIT); EDIT_ITEM_F(uint8, label, &editable.uint8, 0, 9, digit_entered); MENU_ITEM_ADDON_START(utf8_strlen(label) + 1); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); lcd_put_lchar('1' + digit_no); SETCURSOR_X(LCD_WIDTH - 2); - lcd_put_lchar('>'); + lcd_put_u8str(F(">")); MENU_ITEM_ADDON_END(); ACTION_ITEM(MSG_START_OVER, start_over); diff --git a/Marlin/src/lcd/menu/menu_spindle_laser.cpp b/Marlin/src/lcd/menu/menu_spindle_laser.cpp index a6f99546f691..de16316987e6 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -79,7 +79,7 @@ EDIT_ITEM_FAST(CUTTER_MENU_PULSE_TYPE, MSG_LASER_PULSE_MS, &cutter.testPulse, LASER_TEST_PULSE_MIN, LASER_TEST_PULSE_MAX); ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse); #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency); + EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 65535, cutter.refresh_frequency); #endif #endif END_MENU(); diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index bc5200196717..423af4e5a1eb 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -76,12 +76,12 @@ #if ENABLED(TFT_COLOR_UI) lcd_moveto(4, 3); lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); lcd_moveto(10, 3); #else lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1)); lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); #endif lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)])); } @@ -210,9 +210,9 @@ void menu_tune() { // Advance K: // #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS) - #if EXTRUDERS == 1 + #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); - #elif HAS_MULTI_EXTRUDER + #else EXTRUDER_LOOP() EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 62c1770bd4c3..d6f42faa5558 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -35,6 +35,9 @@ #include "../../module/planner.h" #include "../../module/settings.h" #include "../../feature/bedlevel/bedlevel.h" +#if HAS_HOTEND + #include "../../module/temperature.h" +#endif static int16_t ubl_storage_slot = 0, custom_hotend_temp = 150, @@ -312,11 +315,7 @@ void _lcd_ubl_build_mesh() { START_MENU(); BACK_ITEM(MSG_UBL_TOOLS); #if HAS_PREHEAT - #if HAS_HEATED_BED - #define PREHEAT_BED_GCODE(M) "M190I" STRINGIFY(M) "\n" - #else - #define PREHEAT_BED_GCODE(M) "" - #endif + #define PREHEAT_BED_GCODE(M) TERN(HAS_HEATED_BED, "M190I" STRINGIFY(M) "\n", "") #define BUILD_MESH_GCODE_ITEM(M) GCODES_ITEM_f(ui.get_preheat_label(M), MSG_UBL_BUILD_MESH_M, \ F( \ "G28\n" \ @@ -325,20 +324,8 @@ void _lcd_ubl_build_mesh() { "G29P1\n" \ "M104S0\n" \ "M140S0" \ - ) ) - BUILD_MESH_GCODE_ITEM(0); - #if PREHEAT_COUNT > 1 - BUILD_MESH_GCODE_ITEM(1); - #if PREHEAT_COUNT > 2 - BUILD_MESH_GCODE_ITEM(2); - #if PREHEAT_COUNT > 3 - BUILD_MESH_GCODE_ITEM(3); - #if PREHEAT_COUNT > 4 - BUILD_MESH_GCODE_ITEM(4); - #endif - #endif - #endif - #endif + ) ); + REPEAT(PREHEAT_COUNT, BUILD_MESH_GCODE_ITEM) #endif // HAS_PREHEAT SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh); diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h index 67cec2ee1c7e..6df4c22d5191 100644 --- a/Marlin/src/lcd/tft/tft.h +++ b/Marlin/src/lcd/tft/tft.h @@ -65,9 +65,9 @@ #endif #endif -#if TFT_BUFFER_SIZE > 65535 +#if TFT_BUFFER_SIZE > DMA_MAX_SIZE // DMA Count parameter is uint16_t - #error "TFT_BUFFER_SIZE can not exceed 65535" + #error "TFT_BUFFER_SIZE can not exceed DMA_MAX_SIZE" #endif class TFT { @@ -86,8 +86,8 @@ class TFT { static bool is_busy() { return io.isBusy(); } static void abort() { io.Abort(); } - static void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); } - static void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); } + static void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultipleDMA(Data, Count); } + static void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequenceDMA(Data, Count); } static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); } static void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); } diff --git a/Marlin/src/lcd/tft/tft_queue.cpp b/Marlin/src/lcd/tft/tft_queue.cpp index 25ab452cef31..19dd810dc7dc 100644 --- a/Marlin/src/lcd/tft/tft_queue.cpp +++ b/Marlin/src/lcd/tft/tft_queue.cpp @@ -86,9 +86,9 @@ void TFT_Queue::fill(queueTask_t *task) { task->state = TASK_STATE_IN_PROGRESS; } - if (task_parameters->count > 65535) { - count = 65535; - task_parameters->count -= 65535; + if (task_parameters->count > DMA_MAX_SIZE) { + count = DMA_MAX_SIZE; + task_parameters->count -= DMA_MAX_SIZE; } else { count = task_parameters->count; diff --git a/Marlin/src/lcd/tft/tft_queue.h b/Marlin/src/lcd/tft/tft_queue.h index 55d0a526b5e3..bc45af822a45 100644 --- a/Marlin/src/lcd/tft/tft_queue.h +++ b/Marlin/src/lcd/tft/tft_queue.h @@ -135,6 +135,7 @@ class TFT_Queue { static void reset(); static void async(); static void sync() { while (current_task != nullptr) async(); } + static bool is_empty() { return current_task == nullptr; } 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 050b59f39f90..6c81ebefcda7 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -43,7 +43,7 @@ int16_t Touch::x, Touch::y; touch_control_t Touch::controls[]; touch_control_t *Touch::current_control; uint16_t Touch::controls_count; -millis_t Touch::last_touch_ms = 0, +millis_t Touch::next_touch_ms = 0, Touch::time_to_hold, Touch::repeat_delay, Touch::touch_time; @@ -83,8 +83,8 @@ void Touch::idle() { // Return if Touch::idle is called within the same millisecond const millis_t now = millis(); - if (last_touch_ms == now) return; - last_touch_ms = now; + if (now <= next_touch_ms) return; + next_touch_ms = now; if (get_point(&_x, &_y)) { #if HAS_RESUME_CONTINUE @@ -97,18 +97,18 @@ void Touch::idle() { } #endif - ui.reset_status_timeout(last_touch_ms); + ui.reset_status_timeout(now); if (touch_time) { #if ENABLED(TOUCH_SCREEN_CALIBRATION) - if (touch_control_type == NONE && ELAPSED(last_touch_ms, touch_time + TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS) && ui.on_status_screen()) + if (touch_control_type == NONE && ELAPSED(now, touch_time + TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS) && ui.on_status_screen()) ui.goto_screen(touch_screen_calibration); #endif return; } - if (time_to_hold == 0) time_to_hold = last_touch_ms + MINIMUM_HOLD_TIME; - if (PENDING(last_touch_ms, time_to_hold)) return; + if (time_to_hold == 0) time_to_hold = now + MINIMUM_HOLD_TIME; + if (PENDING(now, time_to_hold)) return; if (x != 0 && y != 0) { if (current_control) { @@ -133,7 +133,7 @@ void Touch::idle() { } if (!current_control) - touch_time = last_touch_ms; + touch_time = now; } x = _x; y = _y; @@ -252,8 +252,8 @@ void Touch::touch(touch_control_t *control) { void Touch::hold(touch_control_t *control, millis_t delay) { current_control = control; if (delay) { - repeat_delay = delay > MIN_REPEAT_DELAY ? delay : MIN_REPEAT_DELAY; - time_to_hold = last_touch_ms + repeat_delay; + repeat_delay = _MAX(delay, uint32_t(MIN_REPEAT_DELAY)); + time_to_hold = next_touch_ms + repeat_delay; } ui.refresh(); } @@ -301,8 +301,10 @@ bool Touch::get_point(int16_t *x, int16_t *y) { #elif PIN_EXISTS(TFT_BACKLIGHT) WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif + next_touch_ms = millis() + 100; + safe_delay(20); } - next_sleep_ms = millis() + SEC_TO_MS(TOUCH_IDLE_SLEEP); + next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60); } #endif // HAS_TOUCH_SLEEP diff --git a/Marlin/src/lcd/tft/touch.h b/Marlin/src/lcd/tft/touch.h index 6021a840b65e..fd5d9fd73737 100644 --- a/Marlin/src/lcd/tft/touch.h +++ b/Marlin/src/lcd/tft/touch.h @@ -103,7 +103,7 @@ class Touch { static touch_control_t *current_control; static uint16_t controls_count; - static millis_t last_touch_ms, time_to_hold, repeat_delay, touch_time; + static millis_t next_touch_ms, time_to_hold, repeat_delay, touch_time; static TouchControlType touch_control_type; static bool get_point(int16_t *x, int16_t *y); diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 2cce95c8df01..aa266d6b87db 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -57,7 +57,8 @@ void MarlinUI::tft_idle() { #endif tft.queue.async(); - TERN_(TOUCH_SCREEN, touch.idle()); + + TERN_(TOUCH_SCREEN, if (tft.queue.is_empty()) touch.idle()); // Touch driver is not DMA-aware, so only check for touch controls after screen drawing is completed } #if ENABLED(SHOW_BOOTSCREEN) @@ -325,7 +326,10 @@ void MarlinUI::draw_status_screen() { #if ENABLED(TOUCH_SCREEN) add_control(900, y, menu_main, imgSettings); - TERN_(SDSUPPORT, add_control(12, y, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED)); + #if ENABLED(SDSUPPORT) + const bool cm = card.isMounted(), pa = printingIsActive(); + add_control(12, y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED); + #endif #endif y += 100; diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 19cc4590aa5e..bb48b5e1650c 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -57,7 +57,8 @@ void MarlinUI::tft_idle() { #endif tft.queue.async(); - TERN_(TOUCH_SCREEN, touch.idle()); + + TERN_(TOUCH_SCREEN, if (tft.queue.is_empty()) touch.idle()); // Touch driver is not DMA-aware, so only check for touch controls after screen drawing is completed } #if ENABLED(SHOW_BOOTSCREEN) @@ -342,7 +343,10 @@ void MarlinUI::draw_status_screen() { #if ENABLED(TOUCH_SCREEN) add_control(256, 130, menu_main, imgSettings); - TERN_(SDSUPPORT, add_control(0, 130, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED)); + #if ENABLED(SDSUPPORT) + const bool cm = card.isMounted(), pa = printingIsActive(); + add_control(0, 130, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED); + #endif #endif } diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 04a121a0e03d..682ea3e380ed 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -57,7 +57,8 @@ void MarlinUI::tft_idle() { #endif tft.queue.async(); - TERN_(TOUCH_SCREEN, touch.idle()); + + TERN_(TOUCH_SCREEN, if (tft.queue.is_empty()) touch.idle()); // Touch driver is not DMA-aware, so only check for touch controls after screen drawing is completed } #if ENABLED(SHOW_BOOTSCREEN) @@ -319,7 +320,10 @@ void MarlinUI::draw_status_screen() { #if ENABLED(TOUCH_SCREEN) add_control(404, y, menu_main, imgSettings); - TERN_(SDSUPPORT, add_control(12, y, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED)); + #if ENABLED(SDSUPPORT) + const bool cm = card.isMounted(), pa = printingIsActive(); + add_control(12, y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED); + #endif #endif y += TERN(HAS_UI_480x272, 36, 44); diff --git a/Marlin/src/lcd/tft_io/tft_io.cpp b/Marlin/src/lcd/tft_io/tft_io.cpp index acb78c3e6e9f..294c146d5cb9 100644 --- a/Marlin/src/lcd/tft_io/tft_io.cpp +++ b/Marlin/src/lcd/tft_io/tft_io.cpp @@ -60,7 +60,7 @@ TFT_IO_DRIVER TFT_IO::io; uint32_t TFT_IO::lcd_id = 0xFFFFFFFF; void TFT_IO::InitTFT() { -if (lcd_id != 0xFFFFFFFF) return; + if (lcd_id != 0xFFFFFFFF) return; #if PIN_EXISTS(TFT_BACKLIGHT) OUT_WRITE(TFT_BACKLIGHT_PIN, LOW); @@ -243,7 +243,7 @@ void TFT_IO::write_esc_sequence(const uint16_t *Sequence) { continue; } data = *Sequence++; - if (data == 0x7FFF) return; + if (data == 0x7FFF) break; if (data == 0xFFFF) io.WriteData(0xFFFF); else if (data & 0x8000) diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index 50b921cd2a93..c1c4a8e3b192 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -30,7 +30,11 @@ #elif HAS_LTDC_TFT #include HAL_PATH(../../HAL, tft/tft_ltdc.h) #else - #error "TFT IO only supports SPI, FSMC or LTDC interface" + #error "TFT IO only supports SPI, FSMC or LTDC interface." +#endif + +#ifndef DMA_MAX_SIZE + #error "MAX_DMA_SIZE is not configured for this platform." #endif #define TFT_EXCHANGE_XY _BV32(1) @@ -108,27 +112,33 @@ class TFT_IO { static void write_esc_sequence(const uint16_t *Sequence); // Deletaged methods - inline static void Init() { io.Init(); io.Abort(); }; - inline static bool isBusy() { return io.isBusy(); }; - inline static void Abort() { io.Abort(); }; - inline static uint32_t GetID() { return io.GetID(); }; + inline static void Init() { io.Init(); } + inline static bool isBusy() { return io.isBusy(); } + inline static void Abort() { io.Abort(); } + inline static uint32_t GetID() { return io.GetID(); } inline static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) { io.DataTransferBegin(DataWidth); } - inline static void DataTransferEnd() { io.DataTransferEnd(); }; - // inline static void DataTransferAbort() { io.DataTransferAbort(); }; + inline static void DataTransferEnd() { io.DataTransferEnd(); } - inline static void WriteData(uint16_t Data) { io.WriteData(Data); }; - inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); }; + inline static void WriteData(uint16_t Data) { io.WriteData(Data); } + inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); } - inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }; + // Blocking IO used by TFT_CLASSIC_UI and TFT_LVGL_UI + // These functions start data transfer and WAIT for data transfer completion + inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); } + inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); } + // Non-blocking DMA-based IO used by TFT_COLOR_UI only + // These functions start data transfer using DMA and do NOT wait for data transfer completion + inline static void WriteSequenceDMA(uint16_t *Data, uint16_t Count) { io.WriteSequence_DMA(Data, Count); } + inline static void WriteMultipleDMA(uint16_t Color, uint16_t Count) { io.WriteMultiple_DMA(Color, Count); } + + // Non-blocking DMA-based IO with IRQ callback used by TFT_LVGL_UI only + // This function starts data transfer using DMA and does NOT wait for data transfer completion #if ENABLED(USE_SPI_DMA_TC) - inline static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { io.WriteSequenceIT(Data, Count); }; + inline static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { io.WriteSequenceIT(Data, Count); } #endif - // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } - inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); }; - protected: static uint32_t lcd_id; }; diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index 2571efe0759c..54542bed4ed8 100644 --- a/Marlin/src/lcd/thermistornames.h +++ b/Marlin/src/lcd/thermistornames.h @@ -124,6 +124,8 @@ #define THERMISTOR_NAME "ATC104GT-2 1K" #elif THERMISTOR_ID == 1047 #define THERMISTOR_NAME "PT1000 4K7" +#elif THERMISTOR_ID == 1022 + #define THERMISTOR_NAME "PT1000 2K2" #elif THERMISTOR_ID == 1010 #define THERMISTOR_NAME "PT1000 1K" #elif THERMISTOR_ID == 147 @@ -139,7 +141,7 @@ #elif THERMISTOR_ID == 61 #define THERMISTOR_NAME "Formbot 350°C" #elif THERMISTOR_ID == 66 - #define THERMISTOR_NAME "Dyze 4.7M" + #define THERMISTOR_NAME "Dyze / TL 4.7M" #elif THERMISTOR_ID == 67 #define THERMISTOR_NAME "SliceEng 450°C" diff --git a/Marlin/src/lcd/touch/touch_buttons.cpp b/Marlin/src/lcd/touch/touch_buttons.cpp index 604f366ed4f2..d641dd3b1c92 100644 --- a/Marlin/src/lcd/touch/touch_buttons.cpp +++ b/Marlin/src/lcd/touch/touch_buttons.cpp @@ -61,7 +61,7 @@ TouchButtons touchBt; void TouchButtons::init() { touchIO.Init(); - TERN_(HAS_TOUCH_SLEEP, next_sleep_ms = millis() + SEC_TO_MS(TOUCH_IDLE_SLEEP)); + TERN_(HAS_TOUCH_SLEEP, next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60)); } uint8_t TouchButtons::read_buttons() { @@ -135,7 +135,7 @@ uint8_t TouchButtons::read_buttons() { WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif } - next_sleep_ms = millis() + SEC_TO_MS(TOUCH_IDLE_SLEEP); + next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60); } #endif // HAS_TOUCH_SLEEP diff --git a/Marlin/src/libs/W25Qxx.cpp b/Marlin/src/libs/W25Qxx.cpp index 033402d04ab0..591d0d069318 100644 --- a/Marlin/src/libs/W25Qxx.cpp +++ b/Marlin/src/libs/W25Qxx.cpp @@ -22,7 +22,7 @@ #include "../inc/MarlinConfig.h" -#if HAS_SPI_FLASH +#if ENABLED(SPI_FLASH) #include "W25Qxx.h" @@ -380,4 +380,4 @@ void W25QXXFlash::SPI_FLASH_BufferRead(uint8_t *pBuffer, uint32_t ReadAddr, uint SPI_FLASH_CS_H(); } -#endif // HAS_SPI_FLASH +#endif // SPI_FLASH diff --git a/Marlin/src/libs/duration_t.h b/Marlin/src/libs/duration_t.h index df2c9cd099c1..69a648441feb 100644 --- a/Marlin/src/libs/duration_t.h +++ b/Marlin/src/libs/duration_t.h @@ -151,7 +151,9 @@ struct duration_t { * 123456789 (strlen) * 12'34 * 99:59 - * 11d 12:33 + * 123:45 + * 1d 12:33 + * 9999d 12:33 */ uint8_t toDigital(char *buffer, bool with_days=false) const { const uint16_t h = uint16_t(this->hour()), @@ -159,7 +161,7 @@ struct duration_t { if (with_days) { const uint16_t d = this->day(); sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); // 1d 23:45 - return d >= 10 ? 9 : 8; + return strlen_P(buffer); } else if (!h) { const uint16_t s = uint16_t(this->second() % 60UL); diff --git a/Marlin/src/libs/numtostr.cpp b/Marlin/src/libs/numtostr.cpp index f4d47983d225..c28d1246d693 100644 --- a/Marlin/src/libs/numtostr.cpp +++ b/Marlin/src/libs/numtostr.cpp @@ -25,7 +25,7 @@ #include "../inc/MarlinConfigPre.h" #include "../core/utility.h" -char conv[8] = { 0 }; +char conv[9] = { 0 }; #define DIGIT(n) ('0' + (n)) #define DIGIMOD(n, f) DIGIT((n)/(f) % 10) @@ -36,11 +36,11 @@ char conv[8] = { 0 }; // Format uint8_t (0-100) as rj string with 123% / _12% / __1% format const char* pcttostrpctrj(const uint8_t i) { - conv[3] = RJDIGIT(i, 100); - conv[4] = RJDIGIT(i, 10); - conv[5] = DIGIMOD(i, 1); - conv[6] = '%'; - return &conv[3]; + conv[4] = RJDIGIT(i, 100); + conv[5] = RJDIGIT(i, 10); + conv[6] = DIGIMOD(i, 1); + conv[7] = '%'; + return &conv[4]; } // Convert uint8_t (0-255) to a percentage, format as above @@ -50,95 +50,89 @@ const char* ui8tostr4pctrj(const uint8_t i) { // Convert unsigned 8bit int to string 123 format const char* ui8tostr3rj(const uint8_t i) { - conv[4] = RJDIGIT(i, 100); - conv[5] = RJDIGIT(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[4]; + conv[5] = RJDIGIT(i, 100); + conv[6] = RJDIGIT(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[5]; } // Convert uint8_t to string with 12 format const char* ui8tostr2(const uint8_t i) { - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[5]; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[6]; } // Convert signed 8bit int to rj string with 123 or -12 format const char* i8tostr3rj(const int8_t x) { int xx = x; - conv[4] = MINUSOR(xx, RJDIGIT(xx, 100)); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[4]; + conv[5] = MINUSOR(xx, RJDIGIT(xx, 100)); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[5]; } #if HAS_PRINT_PROGRESS_PERMYRIAD - // Convert unsigned 16-bit permyriad to percent with 100 / 23 / 23.4 / 3.45 format + // Convert unsigned 16-bit permyriad to percent with 100 / 23.4 / 3.45 format const char* permyriadtostr4(const uint16_t xx) { if (xx >= 10000) - return "100"; + return " 100"; // space to keep 4-width alignment else if (xx >= 1000) { - conv[3] = DIGIMOD(xx, 1000); + conv[4] = DIGIMOD(xx, 1000); + conv[5] = DIGIMOD(xx, 100); + conv[6] = '.'; + conv[7] = DIGIMOD(xx, 10); + return &conv[4]; + } + else { conv[4] = DIGIMOD(xx, 100); conv[5] = '.'; conv[6] = DIGIMOD(xx, 10); - return &conv[3]; - } - else if (xx % 100 == 0) { - conv[4] = ' '; - conv[5] = RJDIGIT(xx, 1000); - conv[6] = DIGIMOD(xx, 100); + conv[7] = RJDIGIT(xx, 1); return &conv[4]; } - else { - conv[3] = DIGIMOD(xx, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(xx, 10); - conv[6] = RJDIGIT(xx, 1); - return &conv[3]; - } } #endif // Convert unsigned 16bit int to string 12345 format const char* ui16tostr5rj(const uint16_t xx) { - conv[2] = RJDIGIT(xx, 10000); - conv[3] = RJDIGIT(xx, 1000); - conv[4] = RJDIGIT(xx, 100); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[2]; + conv[3] = RJDIGIT(xx, 10000); + conv[4] = RJDIGIT(xx, 1000); + conv[5] = RJDIGIT(xx, 100); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[3]; } // Convert unsigned 16bit int to string 1234 format const char* ui16tostr4rj(const uint16_t xx) { - conv[3] = RJDIGIT(xx, 1000); - conv[4] = RJDIGIT(xx, 100); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[3]; + conv[4] = RJDIGIT(xx, 1000); + conv[5] = RJDIGIT(xx, 100); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[4]; } // Convert unsigned 16bit int to string 123 format const char* ui16tostr3rj(const uint16_t xx) { - conv[4] = RJDIGIT(xx, 100); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[4]; + conv[5] = RJDIGIT(xx, 100); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[5]; } // Convert signed 16bit int to rj string with 123 or -12 format const char* i16tostr3rj(const int16_t x) { int xx = x; - conv[4] = MINUSOR(xx, RJDIGIT(xx, 100)); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[4]; + conv[5] = MINUSOR(xx, RJDIGIT(xx, 100)); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[5]; } // Convert unsigned 16bit int to lj string with 123 format const char* i16tostr3left(const int16_t i) { - char *str = &conv[6]; + char *str = &conv[7]; *str = DIGIMOD(i, 1); if (i >= 10) { *(--str) = DIGIMOD(i, 10); @@ -153,118 +147,118 @@ const char* i16tostr4signrj(const int16_t i) { const bool neg = i < 0; const int ii = neg ? -i : i; if (i >= 1000) { - conv[3] = DIGIMOD(ii, 1000); - conv[4] = DIGIMOD(ii, 100); - conv[5] = DIGIMOD(ii, 10); + conv[4] = DIGIMOD(ii, 1000); + conv[5] = DIGIMOD(ii, 100); + conv[6] = DIGIMOD(ii, 10); } else if (ii >= 100) { - conv[3] = neg ? '-' : ' '; - conv[4] = DIGIMOD(ii, 100); - conv[5] = DIGIMOD(ii, 10); + conv[4] = neg ? '-' : ' '; + conv[5] = DIGIMOD(ii, 100); + conv[6] = DIGIMOD(ii, 10); } else { - conv[3] = ' '; conv[4] = ' '; + conv[5] = ' '; if (ii >= 10) { - conv[4] = neg ? '-' : ' '; - conv[5] = DIGIMOD(ii, 10); + conv[5] = neg ? '-' : ' '; + conv[6] = DIGIMOD(ii, 10); } else { - conv[5] = neg ? '-' : ' '; + conv[6] = neg ? '-' : ' '; } } - conv[6] = DIGIMOD(ii, 1); - return &conv[3]; + conv[7] = DIGIMOD(ii, 1); + return &conv[4]; } // Convert unsigned float to string with 1.1 format const char* ftostr11ns(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[4]; + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[5]; } // Convert unsigned float to string with 1.23 format const char* ftostr12ns(const_float_t f) { const long i = UINTFLOAT(f, 2); - conv[3] = DIGIMOD(i, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[3]; + conv[4] = DIGIMOD(i, 100); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[4]; } // Convert unsigned float to string with 12.3 format const char* ftostr31ns(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[3]; + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[4]; } // Convert unsigned float to string with 123.4 format const char* ftostr41ns(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[2]; + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[3]; } // Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format const char* ftostr42_52(const_float_t f) { if (f <= -10 || f >= 100) return ftostr52(f); // -23.45 / 123.45 long i = INTFLOAT(f, 2); - conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000)); - conv[3] = DIGIMOD(i, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[2]; + conv[3] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000)); + conv[4] = DIGIMOD(i, 100); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[3]; } // Convert signed float to fixed-length string with 023.45 / -23.45 format const char* ftostr52(const_float_t f) { long i = INTFLOAT(f, 2); - conv[1] = MINUSOR(i, DIGIMOD(i, 10000)); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[1]; + conv[2] = MINUSOR(i, DIGIMOD(i, 10000)); + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[2]; } // Convert signed float to fixed-length string with 12.345 / _2.345 / -2.345 or -23.45 / 123.45 format const char* ftostr53_63(const_float_t f) { if (f <= -10 || f >= 100) return ftostr63(f); // -23.456 / 123.456 long i = INTFLOAT(f, 3); - conv[1] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 10000)); - conv[2] = DIGIMOD(i, 1000); - conv[3] = '.'; - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[1]; + conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 10000)); + conv[3] = DIGIMOD(i, 1000); + conv[4] = '.'; + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[2]; } // Convert signed float to fixed-length string with 023.456 / -23.456 format const char* ftostr63(const_float_t f) { long i = INTFLOAT(f, 3); - conv[0] = MINUSOR(i, DIGIMOD(i, 100000)); - conv[1] = DIGIMOD(i, 10000); - conv[2] = DIGIMOD(i, 1000); - conv[3] = '.'; - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[0]; + conv[1] = MINUSOR(i, DIGIMOD(i, 100000)); + conv[2] = DIGIMOD(i, 10000); + conv[3] = DIGIMOD(i, 1000); + conv[4] = '.'; + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } #if ENABLED(LCD_DECIMAL_SMALL_XY) @@ -275,11 +269,11 @@ const char* ftostr63(const_float_t f) { if (!WITHIN(i, -99, 999)) return i16tostr4signrj((int)f); const bool neg = i < 0; const int ii = neg ? -i : i; - conv[3] = neg ? '-' : (ii >= 100 ? DIGIMOD(ii, 100) : ' '); - conv[4] = DIGIMOD(ii, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(ii, 1); - return &conv[3]; + conv[4] = neg ? '-' : (ii >= 100 ? DIGIMOD(ii, 100) : ' '); + conv[5] = DIGIMOD(ii, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(ii, 1); + return &conv[4]; } #endif @@ -287,49 +281,49 @@ const char* ftostr63(const_float_t f) { // Convert float to fixed-length string with +12.3 / -12.3 format const char* ftostr31sign(const_float_t f) { int i = INTFLOAT(f, 1); - conv[2] = MINUSOR(i, '+'); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[2]; + conv[3] = MINUSOR(i, '+'); + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[3]; } // Convert float to fixed-length string with +123.4 / -123.4 format const char* ftostr41sign(const_float_t f) { int i = INTFLOAT(f, 1); - conv[1] = MINUSOR(i, '+'); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[1]; + conv[2] = MINUSOR(i, '+'); + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[2]; } // Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format const char* ftostr43sign(const_float_t f, char plus/*=' '*/) { long i = INTFLOAT(f, 3); - conv[1] = i ? MINUSOR(i, plus) : ' '; - conv[2] = DIGIMOD(i, 1000); - conv[3] = '.'; - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[1]; + conv[2] = i ? MINUSOR(i, plus) : ' '; + conv[3] = DIGIMOD(i, 1000); + conv[4] = '.'; + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[2]; } // Convert signed float to string (5 digit) with -1.2345 / _0.0000 / +1.2345 format const char* ftostr54sign(const_float_t f, char plus/*=' '*/) { long i = INTFLOAT(f, 4); - conv[0] = i ? MINUSOR(i, plus) : ' '; - conv[1] = DIGIMOD(i, 10000); - conv[2] = '.'; - conv[3] = DIGIMOD(i, 1000); - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[0]; + conv[1] = i ? MINUSOR(i, plus) : ' '; + conv[2] = DIGIMOD(i, 10000); + conv[3] = '.'; + conv[4] = DIGIMOD(i, 1000); + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } // Convert unsigned float to rj string with 12345 format @@ -341,52 +335,66 @@ const char* ftostr5rj(const_float_t f) { // Convert signed float to string with +1234.5 format const char* ftostr51sign(const_float_t f) { long i = INTFLOAT(f, 1); - conv[0] = MINUSOR(i, '+'); - conv[1] = DIGIMOD(i, 10000); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return conv; + conv[1] = MINUSOR(i, '+'); + conv[2] = DIGIMOD(i, 10000); + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } // Convert signed float to string with +123.45 format const char* ftostr52sign(const_float_t f) { long i = INTFLOAT(f, 2); - conv[0] = MINUSOR(i, '+'); - conv[1] = DIGIMOD(i, 10000); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return conv; + conv[1] = MINUSOR(i, '+'); + conv[2] = DIGIMOD(i, 10000); + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } // Convert signed float to string with +12.345 format const char* ftostr53sign(const_float_t f) { long i = INTFLOAT(f, 3); - conv[0] = MINUSOR(i, '+'); - conv[1] = DIGIMOD(i, 10000); - conv[2] = DIGIMOD(i, 1000); - conv[3] = '.'; - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return conv; + conv[1] = MINUSOR(i, '+'); + conv[2] = DIGIMOD(i, 10000); + conv[3] = DIGIMOD(i, 1000); + conv[4] = '.'; + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } // Convert unsigned float to string with ____5.6, ___45.6, __345.6, _2345.6, 12345.6 format const char* ftostr61rj(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[0] = RJDIGIT(i, 100000); - conv[1] = RJDIGIT(i, 10000); - conv[2] = RJDIGIT(i, 1000); - conv[3] = RJDIGIT(i, 100); - conv[4] = DIGIMOD(i, 10); + conv[1] = RJDIGIT(i, 100000); + conv[2] = RJDIGIT(i, 10000); + conv[3] = RJDIGIT(i, 1000); + conv[4] = RJDIGIT(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[1]; +} + +// Convert unsigned float to string with ____5.67, ___45.67, __345.67, _2345.67, 12345.67 format +const char* ftostr72rj(const_float_t f) { + const long i = UINTFLOAT(f, 2); + conv[0] = RJDIGIT(i, 1000000); + conv[1] = RJDIGIT(i, 100000); + conv[2] = RJDIGIT(i, 10000); + conv[3] = RJDIGIT(i, 1000); + conv[4] = DIGIMOD(i, 100); conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); return conv; } @@ -394,24 +402,24 @@ const char* ftostr61rj(const_float_t f) { const char* ftostr52sp(const_float_t f) { long i = INTFLOAT(f, 2); uint8_t dig; - conv[0] = MINUSOR(i, ' '); - conv[1] = RJDIGIT(i, 10000); - conv[2] = RJDIGIT(i, 1000); - conv[3] = DIGIMOD(i, 100); + conv[1] = MINUSOR(i, ' '); + conv[2] = RJDIGIT(i, 10000); + conv[3] = RJDIGIT(i, 1000); + conv[4] = DIGIMOD(i, 100); if ((dig = i % 10)) { // second digit after decimal point? - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIT(dig); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIT(dig); } else { if ((dig = (i / 10) % 10)) { // first digit after decimal point? - conv[4] = '.'; - conv[5] = DIGIT(dig); + conv[5] = '.'; + conv[6] = DIGIT(dig); } else // nothing after decimal point - conv[4] = conv[5] = ' '; - conv[6] = ' '; + conv[5] = conv[6] = ' '; + conv[7] = ' '; } - return conv; + return &conv[1]; } diff --git a/Marlin/src/libs/numtostr.h b/Marlin/src/libs/numtostr.h index 1704d35e889d..047b22cd177d 100644 --- a/Marlin/src/libs/numtostr.h +++ b/Marlin/src/libs/numtostr.h @@ -116,6 +116,9 @@ const char* ftostr53sign(const_float_t f); // Convert unsigned float to string with 12345.6 format omitting trailing zeros const char* ftostr61rj(const_float_t x); +// Convert unsigned float to string with 12345.67 format omitting trailing zeros +const char* ftostr72rj(const_float_t x); + // Convert float to rj string with 123 or -12 format FORCE_INLINE const char* ftostr3(const_float_t x) { return i16tostr3rj(int16_t(x + (x < 0 ? -0.5f : 0.5f))); } diff --git a/Marlin/src/libs/vector_3.h b/Marlin/src/libs/vector_3.h index f515333cc768..58bdb43c7b41 100644 --- a/Marlin/src/libs/vector_3.h +++ b/Marlin/src/libs/vector_3.h @@ -75,8 +75,8 @@ struct vector_3 { vector_3 operator-(const vector_3 &v) { return vector_3(x - v.x, y - v.y, z - v.z); } vector_3 operator*(const float &v) { return vector_3(x * v, y * v, z * v); } - operator xy_float_t() { return xy_float_t({ x, y }); } - operator xyz_float_t() { return xyz_float_t({ x, y, z }); } + operator xy_float_t() { return xy_float_t({ x OPTARG(HAS_Y_AXIS, y) }); } + operator xyz_float_t() { return xyz_float_t({ x OPTARG(HAS_Y_AXIS, y) OPTARG(HAS_Z_AXIS, z) }); } void debug(FSTR_P const title); }; diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 6101022fd49d..8df39dae4b65 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -341,7 +341,6 @@ void report_current_position_projected() { can_reach = ( a < polargraph_max_belt_len + 1 && b < polargraph_max_belt_len + 1 - && (a + b) > _MIN(draw_area_size.x, draw_area_size.y) ); #endif @@ -562,7 +561,8 @@ void do_blocking_move_to(NUM_AXIS_ARGS(const float), const_feedRate_t fr_mm_s/*= const feedRate_t w_feedrate = fr_mm_s ?: homing_feedrate(W_AXIS) ); - #if IS_KINEMATIC + #if IS_KINEMATIC && DISABLED(POLARGRAPH) + // kinematic machines are expected to home to a point 1.5x their range? never reachable. if (!position_is_reachable(x, y)) return; destination = current_position; // sync destination at the start #endif @@ -919,11 +919,16 @@ void restore_feedrate_and_scaling() { constexpr xy_pos_t offs{0}; #endif - if (TERN1(IS_SCARA, axis_was_homed(X_AXIS) && axis_was_homed(Y_AXIS))) { - const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y); - if (dist_2 > delta_max_radius_2) - target *= float(delta_max_radius / SQRT(dist_2)); // 200 / 300 = 0.66 - } + #if ENABLED(POLARGRAPH) + LIMIT(target.x, draw_area_min.x, draw_area_max.x); + LIMIT(target.y, draw_area_min.y, draw_area_max.y); + #else + if (TERN1(IS_SCARA, axis_was_homed(X_AXIS) && axis_was_homed(Y_AXIS))) { + const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y); + if (dist_2 > delta_max_radius_2) + target *= float(delta_max_radius / SQRT(dist_2)); // 200 / 300 = 0.66 + } + #endif #else @@ -1466,13 +1471,18 @@ void prepare_line_to_destination() { } bool homing_needed_error(main_axes_bits_t axis_bits/*=main_axes_mask*/) { - if ((axis_bits = axes_should_home(axis_bits))) { - PGM_P home_first = GET_TEXT(MSG_HOME_FIRST); + if ((axis_bits &= axes_should_home(axis_bits))) { + char all_axes[] = STR_AXES_MAIN, need[NUM_AXES + 1]; + uint8_t n = 0; + LOOP_NUM_AXES(i) if (TEST(axis_bits, i)) need[n++] = all_axes[i]; + need[n] = '\0'; + char msg[30]; - #define _AXIS_CHAR(N) TEST(axis_bits, _AXIS(N)) ? STR_##N : "" - sprintf_P(msg, home_first, MAPLIST(_AXIS_CHAR, MAIN_AXIS_NAMES)); + sprintf_P(msg, GET_EN_TEXT(MSG_HOME_FIRST), need); SERIAL_ECHO_START(); SERIAL_ECHOLN(msg); + + sprintf_P(msg, GET_TEXT(MSG_HOME_FIRST), need); ui.set_status(msg); return true; } @@ -1994,6 +2004,17 @@ void prepare_line_to_destination() { } #endif + // + // Back away to prevent opposite endstop damage + // + #if !defined(SENSORLESS_BACKOFF_MM) && XY_COUNTERPART_BACKOFF_MM + if (!(axis_was_homed(X_AXIS) || axis_was_homed(Y_AXIS)) && (axis == X_AXIS || axis == Y_AXIS)) { + const AxisEnum opposite_axis = axis == X_AXIS ? Y_AXIS : X_AXIS; + const float backoff_length = -ABS(XY_COUNTERPART_BACKOFF_MM) * home_dir(opposite_axis); + do_homing_move(opposite_axis, backoff_length, homing_feedrate(opposite_axis)); + } + #endif + // Determine if a homing bump will be done and the bumps distance // When homing Z with probe respect probe clearance const bool use_probe_bump = TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS && home_bump_mm(axis)); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 1c9601632df8..ed85045098ba 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -227,7 +227,7 @@ float Planner::previous_nominal_speed; #endif #if ENABLED(LIN_ADVANCE) - float Planner::extruder_advance_K[EXTRUDERS]; // Initialized by settings.load() + float Planner::extruder_advance_K[DISTINCT_E]; // Initialized by settings.load() #endif #if HAS_POSITION_FLOAT @@ -793,19 +793,21 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t uint32_t cruise_rate = block->nominal_rate; #endif - const int32_t accel = block->acceleration_steps_per_s2; - // Steps for acceleration, plateau and deceleration int32_t plateau_steps = block->step_event_count; uint32_t accelerate_steps = 0, decelerate_steps = 0; + const int32_t accel = block->acceleration_steps_per_s2; + float inverse_accel = 0.0f; if (accel != 0) { - // Steps required for acceleration, deceleration to/from nominal rate - const float nominal_rate_sq = sq(float(block->nominal_rate)); - float accelerate_steps_float = (nominal_rate_sq - sq(float(initial_rate))) * (0.5f / accel); + inverse_accel = 1.0f / accel; + const float half_inverse_accel = 0.5f * inverse_accel, + nominal_rate_sq = sq(float(block->nominal_rate)), + // Steps required for acceleration, deceleration to/from nominal rate + decelerate_steps_float = half_inverse_accel * (nominal_rate_sq - sq(float(final_rate))); + float accelerate_steps_float = half_inverse_accel * (nominal_rate_sq - sq(float(initial_rate))); accelerate_steps = CEIL(accelerate_steps_float); - const float decelerate_steps_float = (nominal_rate_sq - sq(float(final_rate))) * (0.5f / accel); decelerate_steps = FLOOR(decelerate_steps_float); // Steps between acceleration and deceleration, if any @@ -828,9 +830,10 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t } #if ENABLED(S_CURVE_ACCELERATION) + const float rate_factor = inverse_accel * (STEPPER_TIMER_RATE); // Jerk controlled speed requires to express speed versus time, NOT steps - uint32_t acceleration_time = (float(cruise_rate - initial_rate) / accel) * (STEPPER_TIMER_RATE), - deceleration_time = (float(cruise_rate - final_rate) / accel) * (STEPPER_TIMER_RATE), + uint32_t acceleration_time = rate_factor * float(cruise_rate - initial_rate), + deceleration_time = rate_factor * float(cruise_rate - final_rate), // And to offload calculations from the ISR, we also calculate the inverse of those times here acceleration_time_inverse = get_period_inverse(acceleration_time), deceleration_time_inverse = get_period_inverse(deceleration_time); @@ -851,7 +854,7 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t #if ENABLED(LIN_ADVANCE) if (block->la_advance_rate) { - const float comp = extruder_advance_K[block->extruder] * block->steps.e / block->step_event_count; + const float comp = extruder_advance_K[E_INDEX_N(block->extruder)] * block->steps.e / block->step_event_count; block->max_adv_steps = cruise_rate * comp; block->final_adv_steps = final_rate * comp; } @@ -1279,16 +1282,10 @@ void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_s void Planner::sync_fan_speeds(uint8_t (&fan_speed)[FAN_COUNT]) { - #if FAN_MIN_PWM != 0 || FAN_MAX_PWM != 255 - #define CALC_FAN_SPEED(f) (fan_speed[f] ? map(fan_speed[f], 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM) - #else - #define CALC_FAN_SPEED(f) (fan_speed[f] ?: FAN_OFF_PWM) - #endif - #if ENABLED(FAN_SOFT_PWM) - #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F); + #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(fan_speed[F]); #else - #define _FAN_SET(F) hal.set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F)); + #define _FAN_SET(F) hal.set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(fan_speed[F])); #endif #define FAN_SET(F) do{ kickstart_fan(fan_speed, ms, F); _FAN_SET(F); }while(0) @@ -1303,13 +1300,13 @@ void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_s void Planner::kickstart_fan(uint8_t (&fan_speed)[FAN_COUNT], const millis_t &ms, const uint8_t f) { static millis_t fan_kick_end[FAN_COUNT] = { 0 }; - if (fan_speed[f]) { + if (fan_speed[f] > FAN_OFF_PWM) { if (fan_kick_end[f] == 0) { fan_kick_end[f] = ms + FAN_KICKSTART_TIME; - fan_speed[f] = 255; + fan_speed[f] = FAN_KICKSTART_POWER; } else if (PENDING(ms, fan_kick_end[f])) - fan_speed[f] = 255; + fan_speed[f] = FAN_KICKSTART_POWER; } else fan_kick_end[f] = 0; @@ -1727,6 +1724,13 @@ float Planner::triggered_position_mm(const AxisEnum axis) { return result * mm_per_step[axis]; } +bool Planner::busy() { + return (has_blocks_queued() || cleaning_buffer_counter + || TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING()) + || TERN0(HAS_SHAPING, stepper.input_shaping_busy()) + ); +} + void Planner::finish_and_disable() { while (has_blocks_queued() || cleaning_buffer_counter) idle(); stepper.disable_all_steppers(); @@ -2170,7 +2174,7 @@ bool Planner::_populate_block( sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z), + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k), + sq(steps_dist_mm.u), + sq(steps_dist_mm.v), + sq(steps_dist_mm.w) - ); + ) #elif ENABLED(FOAMCUTTER_XYUV) #if HAS_J_AXIS // Special 5 axis kinematics. Return the largest distance move from either X/Y or I/J plane @@ -2241,7 +2245,6 @@ bool Planner::_populate_block( TERN_(MIXING_EXTRUDER, mixer.populate_block(block->b_color)); - #if HAS_FAN FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif @@ -2538,7 +2541,7 @@ bool Planner::_populate_block( * * de > 0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves) */ - use_advance_lead = esteps && extruder_advance_K[extruder] && de > 0; + use_advance_lead = esteps && extruder_advance_K[E_INDEX_N(extruder)] && de > 0; if (use_advance_lead) { float e_D_ratio = (target_float.e - position_float.e) / @@ -2554,7 +2557,7 @@ bool Planner::_populate_block( use_advance_lead = false; else { // Scale E acceleration so that it will be possible to jump to the advance speed. - const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[extruder] * e_D_ratio) * steps_per_mm; + const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[E_INDEX_N(extruder)] * e_D_ratio) * steps_per_mm; if (TERN0(LA_DEBUG, accel > max_accel_steps_per_s2)) SERIAL_ECHOLNPGM("Acceleration limited."); NOMORE(accel, max_accel_steps_per_s2); @@ -2591,7 +2594,7 @@ bool Planner::_populate_block( if (use_advance_lead) { // the Bresenham algorithm will convert this step rate into extruder steps - block->la_advance_rate = extruder_advance_K[extruder] * block->acceleration_steps_per_s2; + block->la_advance_rate = extruder_advance_K[E_INDEX_N(extruder)] * block->acceleration_steps_per_s2; // reduce LA ISR frequency by calling it only often enough to ensure that there will // never be more than four extruder steps per call diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 09afee7db1b5..dcfdb1c28e6b 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -192,11 +192,11 @@ typedef struct PlannerBlock { volatile block_flags_t flag; // Block flags - volatile bool is_fan_sync() { return TERN0(LASER_SYNCHRONOUS_M106_M107, flag.sync_fans); } - volatile bool is_pwr_sync() { return TERN0(LASER_POWER_SYNC, flag.sync_laser_pwr); } - volatile bool is_sync() { return flag.sync_position || is_fan_sync() || is_pwr_sync(); } - volatile bool is_page() { return TERN0(DIRECT_STEPPING, flag.page); } - volatile bool is_move() { return !(is_sync() || is_page()); } + bool is_fan_sync() { return TERN0(LASER_SYNCHRONOUS_M106_M107, flag.sync_fans); } + bool is_pwr_sync() { return TERN0(LASER_POWER_SYNC, flag.sync_laser_pwr); } + bool is_sync() { return flag.sync_position || is_fan_sync() || is_pwr_sync(); } + bool is_page() { return TERN0(DIRECT_STEPPING, flag.page); } + bool is_move() { return !(is_sync() || is_page()); } // Fields used by the motion planner to manage acceleration float nominal_speed, // The nominal speed for this block in (mm/sec) @@ -459,7 +459,7 @@ class Planner { #endif #if ENABLED(LIN_ADVANCE) - static float extruder_advance_K[EXTRUDERS]; + static float extruder_advance_K[DISTINCT_E]; #endif /** @@ -930,11 +930,7 @@ class Planner { static float triggered_position_mm(const AxisEnum axis); // Blocks are queued, or we're running out moves, or the closed loop controller is waiting - static bool busy() { - return (has_blocks_queued() || cleaning_buffer_counter - || TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING()) - ); - } + static bool busy(); // Block until all buffered steps are executed / cleaned static void synchronize(); @@ -988,7 +984,7 @@ class Planner { FORCE_INLINE static void recalculate_max_e_jerk() { const float prop = junction_deviation_mm * SQRT(0.5) / (1.0f - SQRT(0.5)); EXTRUDER_LOOP() - max_e_jerk[E_INDEX_N(e)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_INDEX_N(e)]); + max_e_jerk[E_INDEX_N(e)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_AXIS_N(e)]); } #endif diff --git a/Marlin/src/module/polargraph.cpp b/Marlin/src/module/polargraph.cpp index 42f99304d789..d55d36a6d654 100644 --- a/Marlin/src/module/polargraph.cpp +++ b/Marlin/src/module/polargraph.cpp @@ -37,17 +37,12 @@ #include "../lcd/marlinui.h" #include "../MarlinCore.h" -float segments_per_second; // Initialized by settings.load() - -xy_pos_t draw_area_min = { X_MIN_POS, Y_MIN_POS }, - draw_area_max = { X_MAX_POS, Y_MAX_POS }; - -xy_float_t draw_area_size = { X_MAX_POS - X_MIN_POS, Y_MAX_POS - Y_MIN_POS }; - -float polargraph_max_belt_len = HYPOT(draw_area_size.x, draw_area_size.y); +// Initialized by settings.load() +float segments_per_second, polargraph_max_belt_len; +xy_pos_t draw_area_min, draw_area_max; void inverse_kinematics(const xyz_pos_t &raw) { - const float x1 = raw.x - (draw_area_min.x), x2 = (draw_area_max.x) - raw.x, y = raw.y - (draw_area_max.y); + const float x1 = raw.x - draw_area_min.x, x2 = draw_area_max.x - raw.x, y = raw.y - draw_area_max.y; delta.set(HYPOT(x1, y), HYPOT(x2, y), raw.z); } diff --git a/Marlin/src/module/polargraph.h b/Marlin/src/module/polargraph.h index b465de32874c..f4904ebfe21c 100644 --- a/Marlin/src/module/polargraph.h +++ b/Marlin/src/module/polargraph.h @@ -30,7 +30,6 @@ extern float segments_per_second; extern xy_pos_t draw_area_min, draw_area_max; -extern xy_float_t draw_area_size; extern float polargraph_max_belt_len; void inverse_kinematics(const xyz_pos_t &raw); diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index ad6f4eff6803..3b6239c667ee 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -314,13 +314,13 @@ void PrintCounter::reset() { void PrintCounter::resetServiceInterval(const int index) { switch (index) { #if SERVICE_INTERVAL_1 > 0 - case 1: data.nextService1 = SERVICE_INTERVAL_SEC_1; + case 1: data.nextService1 = SERVICE_INTERVAL_SEC_1; break; #endif #if SERVICE_INTERVAL_2 > 0 - case 2: data.nextService2 = SERVICE_INTERVAL_SEC_2; + case 2: data.nextService2 = SERVICE_INTERVAL_SEC_2; break; #endif #if SERVICE_INTERVAL_3 > 0 - case 3: data.nextService3 = SERVICE_INTERVAL_SEC_3; + case 3: data.nextService3 = SERVICE_INTERVAL_SEC_3; break; #endif } saveStats(); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 8814b50d5e04..9aebf54838ec 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -887,7 +887,9 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai // Move the probe to the starting XYZ do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S)); - TERN_(BD_SENSOR, return bdl.read()); + #if ENABLED(BD_SENSOR) + return current_position.z - bdl.read(); // Difference between Z-home-relative Z and sensor reading + #endif float measured_z = NAN; if (!deploy()) { diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 1bcbc6564241..73b8af000c3c 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -29,6 +29,10 @@ #include "motion.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" +#endif + #if HAS_BED_PROBE enum ProbePtRaise : uint8_t { PROBE_PT_NONE, // No raise or stow after run_z_probe @@ -45,12 +49,14 @@ #define PROBE_TRIGGERED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) #endif -#ifdef Z_AFTER_HOMING - #define Z_POST_CLEARANCE Z_AFTER_HOMING +#if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + #define Z_POST_CLEARANCE HMI_data.z_after_homing; +#elif defined(Z_AFTER_HOMING) + #define Z_POST_CLEARANCE Z_AFTER_HOMING #elif defined(Z_HOMING_HEIGHT) - #define Z_POST_CLEARANCE Z_HOMING_HEIGHT + #define Z_POST_CLEARANCE Z_HOMING_HEIGHT #else - #define Z_POST_CLEARANCE 10 + #define Z_POST_CLEARANCE 10 #endif #if ENABLED(PREHEAT_BEFORE_LEVELING) @@ -146,7 +152,7 @@ class Probe { #else - static constexpr xyz_pos_t offset = xyz_pos_t(NUM_AXIS_ARRAY(0, 0, 0, 0, 0, 0)); // See #16767 + static constexpr xyz_pos_t offset = xyz_pos_t(NUM_AXIS_ARRAY_1(0)); // See #16767 static bool set_deployed(const bool) { return false; } @@ -155,9 +161,9 @@ class Probe { #endif static void move_z_after_homing() { - #ifdef Z_AFTER_HOMING - do_z_clearance(Z_AFTER_HOMING, true); - #elif BOTH(Z_AFTER_PROBING, HAS_BED_PROBE) + #if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) || defined(Z_AFTER_HOMING) + do_z_clearance(Z_POST_CLEARANCE, true); + #elif HAS_BED_PROBE move_z_after_probing(); #endif } diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index bc42b85fbe13..4c42ace884de 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -37,7 +37,7 @@ #include "../MarlinCore.h" #endif -float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SEGMENTS_PER_SECOND); +float segments_per_second = DEFAULT_SEGMENTS_PER_SECOND; #if EITHER(MORGAN_SCARA, MP_SCARA) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 72b4f5a9a485..627e97e45546 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 "V86" +#define EEPROM_VERSION "V87" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -118,8 +118,8 @@ #endif #endif -#if ENABLED(EXTRA_LIN_ADVANCE_K) - extern float other_extruder_advance_K[EXTRUDERS]; +#if ENABLED(ADVANCE_K_EXTRA) + extern float other_extruder_advance_K[DISTINCT_E]; #endif #if HAS_MULTI_EXTRUDER @@ -261,7 +261,7 @@ typedef struct SettingsDataStruct { // HAS_BED_PROBE // - xyz_pos_t probe_offset; + xyz_pos_t probe_offset; // M851 X Y Z // // ABL_PLANAR @@ -323,7 +323,7 @@ typedef struct SettingsDataStruct { #endif // - // Kinematic Settings + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC float segments_per_second; // M665 S @@ -334,7 +334,11 @@ typedef struct SettingsDataStruct { delta_diagonal_rod; // M665 L abc_float_t delta_tower_angle_trim, // M665 X Y Z delta_diagonal_rod_trim; // M665 A B C + #elif ENABLED(POLARGRAPH) + xy_pos_t draw_area_min, draw_area_max; // M665 L R T B + float polargraph_max_belt_len; // M665 H #endif + #endif // @@ -368,18 +372,18 @@ typedef struct SettingsDataStruct { // // PIDTEMP // - PIDCF_t hotendPID[HOTENDS]; // M301 En PIDCF / M303 En U + raw_pidcf_t hotendPID[HOTENDS]; // M301 En PIDCF / M303 En U int16_t lpq_len; // M301 L // // PIDTEMPBED // - PID_t bedPID; // M304 PID / M303 E-1 U + raw_pid_t bedPID; // M304 PID / M303 E-1 U // // PIDTEMPCHAMBER // - PID_t chamberPID; // M309 PID / M303 E-2 U + raw_pid_t chamberPID; // M309 PID / M303 E-2 U // // User-defined Thermistors @@ -406,8 +410,8 @@ typedef struct SettingsDataStruct { // // Display Sleep // - #if LCD_BACKLIGHT_TIMEOUT - uint16_t lcd_backlight_timeout; // M255 S + #if LCD_BACKLIGHT_TIMEOUT_MINS + uint8_t backlight_timeout_minutes; // M255 S #elif HAS_DISPLAY_SLEEP uint8_t sleep_timeout_minutes; // M255 S #endif @@ -446,7 +450,7 @@ typedef struct SettingsDataStruct { // // LIN_ADVANCE // - float planner_extruder_advance_K[_MAX(EXTRUDERS, 1)]; // M900 K planner.extruder_advance_K + float planner_extruder_advance_K[DISTINCT_E]; // M900 K planner.extruder_advance_K // // HAS_MOTOR_CURRENT_PWM @@ -472,7 +476,7 @@ typedef struct SettingsDataStruct { // // SKEW_CORRECTION // - skew_factor_t planner_skew_factor; // M852 I J K planner.skew_factor + skew_factor_t planner_skew_factor; // M852 I J K // // ADVANCED_PAUSE_FEATURE @@ -597,6 +601,18 @@ typedef struct SettingsDataStruct { MPC_t mpc_constants[HOTENDS]; // M306 #endif + // + // Input Shaping + // + #if ENABLED(INPUT_SHAPING_X) + float shaping_x_frequency, // M593 X F + shaping_x_zeta; // M593 X D + #endif + #if ENABLED(INPUT_SHAPING_Y) + float shaping_y_frequency, // M593 Y F + shaping_y_zeta; // M593 Y D + #endif + } SettingsData; //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!"); @@ -664,7 +680,7 @@ void MarlinSettings::postprocess() { TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast()); TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness()); - #if LCD_BACKLIGHT_TIMEOUT + #if LCD_BACKLIGHT_TIMEOUT_MINS ui.refresh_backlight_timeout(); #elif HAS_DISPLAY_SLEEP ui.refresh_screen_timeout(); @@ -1012,7 +1028,7 @@ void MarlinSettings::postprocess() { } // - // Kinematic Settings + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC { @@ -1025,6 +1041,11 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(delta_diagonal_rod); // 1 float EEPROM_WRITE(delta_tower_angle_trim); // 3 floats EEPROM_WRITE(delta_diagonal_rod_trim); // 3 floats + #elif ENABLED(POLARGRAPH) + _FIELD_TEST(draw_area_min); + EEPROM_WRITE(draw_area_min); // 2 floats + EEPROM_WRITE(draw_area_max); // 2 floats + EEPROM_WRITE(polargraph_max_belt_len); // 1 float #endif } #endif @@ -1076,27 +1097,20 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(hotendPID); + #if DISABLED(PIDTEMP) + raw_pidcf_t pidcf = { NAN, NAN, NAN, NAN, NAN }; + #endif HOTEND_LOOP() { - PIDCF_t pidcf = { - #if DISABLED(PIDTEMP) - NAN, NAN, NAN, - NAN, NAN - #else - PID_PARAM(Kp, e), - unscalePID_i(PID_PARAM(Ki, e)), - unscalePID_d(PID_PARAM(Kd, e)), - PID_PARAM(Kc, e), - PID_PARAM(Kf, e) - #endif - }; + #if ENABLED(PIDTEMP) + const hotend_pid_t &pid = thermalManager.temp_hotend[e].pid; + raw_pidcf_t pidcf = { pid.p(), pid.i(), pid.d(), pid.c(), pid.f() }; + #endif EEPROM_WRITE(pidcf); } _FIELD_TEST(lpq_len); - #if DISABLED(PID_EXTRUSION_SCALING) - const int16_t lpq_len = 20; - #endif - EEPROM_WRITE(TERN(PID_EXTRUSION_SCALING, thermalManager.lpq_len, lpq_len)); + const int16_t lpq_len = TERN(PID_EXTRUSION_SCALING, thermalManager.lpq_len, 20); + EEPROM_WRITE(lpq_len); } // @@ -1104,17 +1118,12 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(bedPID); - - const PID_t bed_pid = { - #if DISABLED(PIDTEMPBED) - NAN, NAN, NAN - #else - // Store the unscaled PID values - thermalManager.temp_bed.pid.Kp, - unscalePID_i(thermalManager.temp_bed.pid.Ki), - unscalePID_d(thermalManager.temp_bed.pid.Kd) - #endif - }; + #if ENABLED(PIDTEMPBED) + const PID_t &pid = thermalManager.temp_bed.pid; + const raw_pid_t bed_pid = { pid.p(), pid.i(), pid.d() }; + #else + const raw_pid_t bed_pid = { NAN, NAN, NAN }; + #endif EEPROM_WRITE(bed_pid); } @@ -1123,17 +1132,12 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(chamberPID); - - const PID_t chamber_pid = { - #if DISABLED(PIDTEMPCHAMBER) - NAN, NAN, NAN - #else - // Store the unscaled PID values - thermalManager.temp_chamber.pid.Kp, - unscalePID_i(thermalManager.temp_chamber.pid.Ki), - unscalePID_d(thermalManager.temp_chamber.pid.Kd) - #endif - }; + #if ENABLED(PIDTEMPCHAMBER) + const PID_t &pid = thermalManager.temp_chamber.pid; + const raw_pid_t chamber_pid = { pid.p(), pid.i(), pid.d() }; + #else + const raw_pid_t chamber_pid = { NAN, NAN, NAN }; + #endif EEPROM_WRITE(chamber_pid); } @@ -1141,10 +1145,8 @@ void MarlinSettings::postprocess() { // User-defined Thermistors // #if HAS_USER_THERMISTORS - { _FIELD_TEST(user_thermistor); EEPROM_WRITE(thermalManager.user_thermistor); - } #endif // @@ -1181,8 +1183,8 @@ void MarlinSettings::postprocess() { // // LCD Backlight / Sleep Timeout // - #if LCD_BACKLIGHT_TIMEOUT - EEPROM_WRITE(ui.lcd_backlight_timeout); + #if LCD_BACKLIGHT_TIMEOUT_MINS + EEPROM_WRITE(ui.backlight_timeout_minutes); #elif HAS_DISPLAY_SLEEP EEPROM_WRITE(ui.sleep_timeout_minutes); #endif @@ -1443,7 +1445,7 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(planner.extruder_advance_K); #else dummyf = 0; - for (uint8_t q = _MAX(EXTRUDERS, 1); q--;) EEPROM_WRITE(dummyf); + for (uint8_t q = DISTINCT_E; q--;) EEPROM_WRITE(dummyf); #endif } @@ -1656,6 +1658,20 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(thermalManager.temp_hotend[e].constants); #endif + // + // Input Shaping + /// + #if HAS_SHAPING + #if ENABLED(INPUT_SHAPING_X) + EEPROM_WRITE(stepper.get_shaping_frequency(X_AXIS)); + EEPROM_WRITE(stepper.get_shaping_damping_ratio(X_AXIS)); + #endif + #if ENABLED(INPUT_SHAPING_Y) + EEPROM_WRITE(stepper.get_shaping_frequency(Y_AXIS)); + EEPROM_WRITE(stepper.get_shaping_damping_ratio(Y_AXIS)); + #endif + #endif + // // Report final CRC and Data Size // @@ -1986,7 +2002,7 @@ void MarlinSettings::postprocess() { } // - // Kinematic Segments-per-second + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC { @@ -1999,6 +2015,11 @@ void MarlinSettings::postprocess() { EEPROM_READ(delta_diagonal_rod); // 1 float EEPROM_READ(delta_tower_angle_trim); // 3 floats EEPROM_READ(delta_diagonal_rod_trim); // 3 floats + #elif ENABLED(POLARGRAPH) + _FIELD_TEST(draw_area_min); + EEPROM_READ(draw_area_min); // 2 floats + EEPROM_READ(draw_area_max); // 2 floats + EEPROM_READ(polargraph_max_belt_len); // 1 float #endif } #endif @@ -2047,17 +2068,11 @@ void MarlinSettings::postprocess() { // { HOTEND_LOOP() { - PIDCF_t pidcf; + raw_pidcf_t pidcf; EEPROM_READ(pidcf); #if ENABLED(PIDTEMP) - if (!validating && !isnan(pidcf.Kp)) { - // Scale PID values since EEPROM values are unscaled - PID_PARAM(Kp, e) = pidcf.Kp; - PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki); - PID_PARAM(Kd, e) = scalePID_d(pidcf.Kd); - TERN_(PID_EXTRUSION_SCALING, PID_PARAM(Kc, e) = pidcf.Kc); - TERN_(PID_FAN_SCALING, PID_PARAM(Kf, e) = pidcf.Kf); - } + if (!validating && !isnan(pidcf.p)) + thermalManager.temp_hotend[e].pid.set(pidcf); #endif } } @@ -2079,15 +2094,11 @@ void MarlinSettings::postprocess() { // Heated Bed PID // { - PID_t pid; + raw_pid_t pid; EEPROM_READ(pid); #if ENABLED(PIDTEMPBED) - if (!validating && !isnan(pid.Kp)) { - // Scale PID values since EEPROM values are unscaled - thermalManager.temp_bed.pid.Kp = pid.Kp; - thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki); - thermalManager.temp_bed.pid.Kd = scalePID_d(pid.Kd); - } + if (!validating && !isnan(pid.p)) + thermalManager.temp_bed.pid.set(pid); #endif } @@ -2095,15 +2106,11 @@ void MarlinSettings::postprocess() { // Heated Chamber PID // { - PID_t pid; + raw_pid_t pid; EEPROM_READ(pid); #if ENABLED(PIDTEMPCHAMBER) - if (!validating && !isnan(pid.Kp)) { - // Scale PID values since EEPROM values are unscaled - thermalManager.temp_chamber.pid.Kp = pid.Kp; - thermalManager.temp_chamber.pid.Ki = scalePID_i(pid.Ki); - thermalManager.temp_chamber.pid.Kd = scalePID_d(pid.Kd); - } + if (!validating && !isnan(pid.p)) + thermalManager.temp_chamber.pid.set(pid); #endif } @@ -2152,8 +2159,8 @@ void MarlinSettings::postprocess() { // // LCD Backlight / Sleep Timeout // - #if LCD_BACKLIGHT_TIMEOUT - EEPROM_READ(ui.lcd_backlight_timeout); + #if LCD_BACKLIGHT_TIMEOUT_MINS + EEPROM_READ(ui.backlight_timeout_minutes); #elif HAS_DISPLAY_SLEEP EEPROM_READ(ui.sleep_timeout_minutes); #endif @@ -2411,7 +2418,7 @@ void MarlinSettings::postprocess() { // Linear Advance // { - float extruder_advance_K[_MAX(EXTRUDERS, 1)]; + float extruder_advance_K[DISTINCT_E]; _FIELD_TEST(planner_extruder_advance_K); EEPROM_READ(extruder_advance_K); #if ENABLED(LIN_ADVANCE) @@ -2531,7 +2538,7 @@ void MarlinSettings::postprocess() { #endif // - // Creality DWIN User Data + // DWIN User Data // #if ENABLED(DWIN_LCD_PROUI) { @@ -2654,6 +2661,27 @@ void MarlinSettings::postprocess() { } #endif + // + // Input Shaping + // + #if ENABLED(INPUT_SHAPING_X) + { + float _data[2]; + EEPROM_READ(_data); + stepper.set_shaping_frequency(X_AXIS, _data[0]); + stepper.set_shaping_damping_ratio(X_AXIS, _data[1]); + } + #endif + + #if ENABLED(INPUT_SHAPING_Y) + { + float _data[2]; + EEPROM_READ(_data); + stepper.set_shaping_frequency(Y_AXIS, _data[0]); + stepper.set_shaping_damping_ratio(Y_AXIS, _data[1]); + } + #endif + // // Validate Final Size and CRC // @@ -2853,7 +2881,7 @@ void MarlinSettings::postprocess() { #endif #if ENABLED(DWIN_LCD_PROUI) - status = !BedLevelTools.meshvalidate(); + status = !bedLevelTools.meshvalidate(); if (status) { bedlevel.invalidate(); LCD_MESSAGE(MSG_UBL_MESH_INVALID); @@ -2971,6 +2999,7 @@ void MarlinSettings::reset() { toolchange_settings.unretract_speed = TOOLCHANGE_FS_UNRETRACT_SPEED; toolchange_settings.extra_prime = TOOLCHANGE_FS_EXTRA_PRIME; toolchange_settings.prime_speed = TOOLCHANGE_FS_PRIME_SPEED; + toolchange_settings.wipe_retract = TOOLCHANGE_FS_WIPE_RETRACT; toolchange_settings.fan_speed = TOOLCHANGE_FS_FAN_SPEED; toolchange_settings.fan_time = TOOLCHANGE_FS_FAN_TIME; #endif @@ -3073,15 +3102,11 @@ void MarlinSettings::reset() { #endif // - // Kinematic settings + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC - segments_per_second = ( - TERN_(DELTA, DELTA_SEGMENTS_PER_SECOND) - TERN_(IS_SCARA, SCARA_SEGMENTS_PER_SECOND) - TERN_(POLARGRAPH, POLAR_SEGMENTS_PER_SECOND) - ); + segments_per_second = DEFAULT_SEGMENTS_PER_SECOND; #if ENABLED(DELTA) const abc_float_t adj = DELTA_ENDSTOP_ADJ, dta = DELTA_TOWER_ANGLE_TRIM, ddr = DELTA_DIAGONAL_ROD_TRIM_TOWER; delta_height = DELTA_HEIGHT; @@ -3090,6 +3115,10 @@ void MarlinSettings::reset() { delta_diagonal_rod = DELTA_DIAGONAL_ROD; delta_tower_angle_trim = dta; delta_diagonal_rod_trim = ddr; + #elif ENABLED(POLARGRAPH) + draw_area_min.set(X_MIN_POS, Y_MIN_POS); + draw_area_max.set(X_MAX_POS, Y_MAX_POS); + polargraph_max_belt_len = POLARGRAPH_MAX_BELT_LEN; #endif #endif @@ -3204,11 +3233,13 @@ void MarlinSettings::reset() { #define PID_DEFAULT(N,E) DEFAULT_##N #endif HOTEND_LOOP() { - PID_PARAM(Kp, e) = float(PID_DEFAULT(Kp, ALIM(e, defKp))); - PID_PARAM(Ki, e) = scalePID_i(PID_DEFAULT(Ki, ALIM(e, defKi))); - PID_PARAM(Kd, e) = scalePID_d(PID_DEFAULT(Kd, ALIM(e, defKd))); - TERN_(PID_EXTRUSION_SCALING, PID_PARAM(Kc, e) = float(PID_DEFAULT(Kc, ALIM(e, defKc)))); - TERN_(PID_FAN_SCALING, PID_PARAM(Kf, e) = float(PID_DEFAULT(Kf, ALIM(e, defKf)))); + thermalManager.temp_hotend[e].pid.set( + PID_DEFAULT(Kp, ALIM(e, defKp)), + PID_DEFAULT(Ki, ALIM(e, defKi)), + PID_DEFAULT(Kd, ALIM(e, defKd)) + OPTARG(PID_EXTRUSION_SCALING, PID_DEFAULT(Kc, ALIM(e, defKc))) + OPTARG(PID_FAN_SCALING, PID_DEFAULT(Kf, ALIM(e, defKf))) + ); } #endif @@ -3222,9 +3253,7 @@ void MarlinSettings::reset() { // #if ENABLED(PIDTEMPBED) - thermalManager.temp_bed.pid.Kp = DEFAULT_bedKp; - thermalManager.temp_bed.pid.Ki = scalePID_i(DEFAULT_bedKi); - thermalManager.temp_bed.pid.Kd = scalePID_d(DEFAULT_bedKd); + thermalManager.temp_bed.pid.set(DEFAULT_bedKp, DEFAULT_bedKi, DEFAULT_bedKd); #endif // @@ -3232,9 +3261,7 @@ void MarlinSettings::reset() { // #if ENABLED(PIDTEMPCHAMBER) - thermalManager.temp_chamber.pid.Kp = DEFAULT_chamberKp; - thermalManager.temp_chamber.pid.Ki = scalePID_i(DEFAULT_chamberKi); - thermalManager.temp_chamber.pid.Kd = scalePID_d(DEFAULT_chamberKd); + thermalManager.temp_chamber.pid.set(DEFAULT_chamberKp, DEFAULT_chamberKi, DEFAULT_chamberKd); #endif // @@ -3260,10 +3287,10 @@ void MarlinSettings::reset() { // // LCD Backlight / Sleep Timeout // - #if LCD_BACKLIGHT_TIMEOUT - ui.lcd_backlight_timeout = LCD_BACKLIGHT_TIMEOUT; + #if LCD_BACKLIGHT_TIMEOUT_MINS + ui.backlight_timeout_minutes = LCD_BACKLIGHT_TIMEOUT_MINS; #elif HAS_DISPLAY_SLEEP - ui.sleep_timeout_minutes = DISPLAY_SLEEP_MINUTES; + ui.sleep_timeout_minutes = TERN(TOUCH_SCREEN, TOUCH_IDLE_SLEEP_MINS, DISPLAY_SLEEP_MINUTES); #endif // @@ -3319,12 +3346,17 @@ void MarlinSettings::reset() { // // Linear Advance // - #if ENABLED(LIN_ADVANCE) - EXTRUDER_LOOP() { - planner.extruder_advance_K[e] = LIN_ADVANCE_K; - TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[e] = LIN_ADVANCE_K); - } + #if ENABLED(DISTINCT_E_FACTORS) + constexpr float linAdvanceK[] = ADVANCE_K; + EXTRUDER_LOOP() { + const float a = linAdvanceK[_MAX(uint8_t(e), COUNT(linAdvanceK) - 1)]; + planner.extruder_advance_K[e] = a; + TERN_(ADVANCE_K_EXTRA, other_extruder_advance_K[e] = a); + } + #else + planner.extruder_advance_K[0] = ADVANCE_K; + #endif #endif // @@ -3426,17 +3458,32 @@ void MarlinSettings::reset() { static_assert(COUNT(_filament_heat_capacity_permm) == HOTENDS, "FILAMENT_HEAT_CAPACITY_PERMM must have HOTENDS items."); HOTEND_LOOP() { - thermalManager.temp_hotend[e].constants.heater_power = _mpc_heater_power[e]; - thermalManager.temp_hotend[e].constants.block_heat_capacity = _mpc_block_heat_capacity[e]; - thermalManager.temp_hotend[e].constants.sensor_responsiveness = _mpc_sensor_responsiveness[e]; - thermalManager.temp_hotend[e].constants.ambient_xfer_coeff_fan0 = _mpc_ambient_xfer_coeff[e]; + MPC_t &constants = thermalManager.temp_hotend[e].constants; + constants.heater_power = _mpc_heater_power[e]; + constants.block_heat_capacity = _mpc_block_heat_capacity[e]; + constants.sensor_responsiveness = _mpc_sensor_responsiveness[e]; + constants.ambient_xfer_coeff_fan0 = _mpc_ambient_xfer_coeff[e]; #if ENABLED(MPC_INCLUDE_FAN) - thermalManager.temp_hotend[e].constants.fan255_adjustment = _mpc_ambient_xfer_coeff_fan255[e] - _mpc_ambient_xfer_coeff[e]; + constants.fan255_adjustment = _mpc_ambient_xfer_coeff_fan255[e] - _mpc_ambient_xfer_coeff[e]; #endif - thermalManager.temp_hotend[e].constants.filament_heat_capacity_permm = _filament_heat_capacity_permm[e]; + constants.filament_heat_capacity_permm = _filament_heat_capacity_permm[e]; } #endif + // + // Input Shaping + // + #if HAS_SHAPING + #if ENABLED(INPUT_SHAPING_X) + stepper.set_shaping_frequency(X_AXIS, SHAPING_FREQ_X); + stepper.set_shaping_damping_ratio(X_AXIS, SHAPING_ZETA_X); + #endif + #if ENABLED(INPUT_SHAPING_Y) + stepper.set_shaping_frequency(Y_AXIS, SHAPING_FREQ_Y); + stepper.set_shaping_damping_ratio(Y_AXIS, SHAPING_ZETA_Y); + #endif + #endif + postprocess(); #if EITHER(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) @@ -3604,9 +3651,7 @@ void MarlinSettings::reset() { // // LCD Preheat Settings // - #if HAS_PREHEAT - gcode.M145_report(forReplay); - #endif + TERN_(HAS_PREHEAT, gcode.M145_report(forReplay)); // // PID @@ -3686,6 +3731,11 @@ void MarlinSettings::reset() { // TERN_(HAS_STEALTHCHOP, gcode.M569_report(forReplay)); + // + // Input Shaping + // + TERN_(HAS_SHAPING, gcode.M593_report(forReplay)); + // // Linear Advance // diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index fd49b72e6c64..dc51dfd38019 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -137,6 +137,10 @@ Stepper stepper; // Singleton #include "../lcd/extui/ui_api.h" #endif +#if ENABLED(I2S_STEPPER_STREAM) + #include "../HAL/ESP32/i2s.h" +#endif + // public: #if EITHER(HAS_EXTRA_ENDSTOPS, Z_STEPPER_AUTO_ALIGN) @@ -195,7 +199,7 @@ IF_DISABLED(ADAPTIVE_STEP_SMOOTHING, constexpr) uint8_t Stepper::oversampling_fa xyze_long_t Stepper::delta_error{0}; -xyze_ulong_t Stepper::advance_dividend{0}; +xyze_long_t Stepper::advance_dividend{0}; uint32_t Stepper::advance_divisor = 0, Stepper::step_events_completed = 0, // The number of step events executed in the current block Stepper::accelerate_until, // The count at which to stop accelerating @@ -228,6 +232,28 @@ uint32_t Stepper::advance_divisor = 0, Stepper::la_advance_steps = 0; #endif +#if HAS_SHAPING + shaping_time_t ShapingQueue::now = 0; + shaping_time_t ShapingQueue::times[shaping_echoes]; + shaping_echo_axis_t ShapingQueue::echo_axes[shaping_echoes]; + uint16_t ShapingQueue::tail = 0; + + #if ENABLED(INPUT_SHAPING_X) + shaping_time_t ShapingQueue::delay_x; + shaping_time_t ShapingQueue::peek_x_val = shaping_time_t(-1); + uint16_t ShapingQueue::head_x = 0; + uint16_t ShapingQueue::_free_count_x = shaping_echoes - 1; + ShapeParams Stepper::shaping_x; + #endif + #if ENABLED(INPUT_SHAPING_Y) + shaping_time_t ShapingQueue::delay_y; + shaping_time_t ShapingQueue::peek_y_val = shaping_time_t(-1); + uint16_t ShapingQueue::head_y = 0; + uint16_t ShapingQueue::_free_count_y = shaping_echoes - 1; + ShapeParams Stepper::shaping_y; + #endif +#endif + #if ENABLED(INTEGRATED_BABYSTEPPING) uint32_t Stepper::nextBabystepISR = BABYSTEP_NEVER; #endif @@ -454,12 +480,10 @@ xyze_int8_t Stepper::count_direction{0}; #define PULSE_LOW_TICK_COUNT hal_timer_t(NS_TO_PULSE_TIMER_TICKS(_MIN_PULSE_LOW_NS - _MIN(_MIN_PULSE_LOW_NS, TIMER_SETUP_NS))) #define USING_TIMED_PULSE() hal_timer_t start_pulse_count = 0 -#define START_TIMED_PULSE(DIR) (start_pulse_count = HAL_timer_get_count(MF_TIMER_PULSE)) -#define AWAIT_TIMED_PULSE(DIR) while (PULSE_##DIR##_TICK_COUNT > HAL_timer_get_count(MF_TIMER_PULSE) - start_pulse_count) { } -#define START_HIGH_PULSE() START_TIMED_PULSE(HIGH) -#define AWAIT_HIGH_PULSE() AWAIT_TIMED_PULSE(HIGH) -#define START_LOW_PULSE() START_TIMED_PULSE(LOW) -#define AWAIT_LOW_PULSE() AWAIT_TIMED_PULSE(LOW) +#define START_TIMED_PULSE() (start_pulse_count = HAL_timer_get_count(MF_TIMER_PULSE)) +#define AWAIT_TIMED_PULSE(DIR) while (PULSE_##DIR##_TICK_COUNT > HAL_timer_get_count(MF_TIMER_PULSE) - start_pulse_count) { /* nada */ } +#define AWAIT_HIGH_PULSE() AWAIT_TIMED_PULSE(HIGH) +#define AWAIT_LOW_PULSE() AWAIT_TIMED_PULSE(LOW) #if MINIMUM_STEPPER_PRE_DIR_DELAY > 0 #define DIR_WAIT_BEFORE() DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY) @@ -555,6 +579,16 @@ void Stepper::disable_all_steppers() { TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled()); } +#define SET_STEP_DIR(A) \ + if (motor_direction(_AXIS(A))) { \ + A##_APPLY_DIR(INVERT_##A##_DIR, false); \ + count_direction[_AXIS(A)] = -1; \ + } \ + else { \ + A##_APPLY_DIR(!INVERT_##A##_DIR, false); \ + count_direction[_AXIS(A)] = 1; \ + } + /** * Set the stepper direction of each axis * @@ -566,16 +600,6 @@ void Stepper::set_directions() { DIR_WAIT_BEFORE(); - #define SET_STEP_DIR(A) \ - if (motor_direction(_AXIS(A))) { \ - A##_APPLY_DIR(INVERT_##A##_DIR, false); \ - count_direction[_AXIS(A)] = -1; \ - } \ - else { \ - A##_APPLY_DIR(!INVERT_##A##_DIR, false); \ - count_direction[_AXIS(A)] = 1; \ - } - TERN_(HAS_X_DIR, SET_STEP_DIR(X)); // A TERN_(HAS_Y_DIR, SET_STEP_DIR(Y)); // B TERN_(HAS_Z_DIR, SET_STEP_DIR(Z)); // C @@ -1463,6 +1487,8 @@ void Stepper::isr() { // Enable ISRs to reduce USART processing latency hal.isr_on(); + TERN_(HAS_SHAPING, shaping_isr()); // Do Shaper stepping, if needed + if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses #if ENABLED(LIN_ADVANCE) @@ -1493,10 +1519,12 @@ void Stepper::isr() { // Get the interval to the next ISR call const uint32_t interval = _MIN( - uint32_t(HAL_TIMER_TYPE_MAX), // Come back in a very long time - nextMainISR // Time until the next Pulse / Block phase - OPTARG(LIN_ADVANCE, nextAdvanceISR) // Come back early for Linear Advance? - OPTARG(INTEGRATED_BABYSTEPPING, nextBabystepISR) // Come back early for Babystepping? + uint32_t(HAL_TIMER_TYPE_MAX), // Come back in a very long time + nextMainISR // Time until the next Pulse / Block phase + OPTARG(INPUT_SHAPING_X, ShapingQueue::peek_x()) // Time until next input shaping echo for X + OPTARG(INPUT_SHAPING_Y, ShapingQueue::peek_y()) // Time until next input shaping echo for Y + OPTARG(LIN_ADVANCE, nextAdvanceISR) // Come back early for Linear Advance? + OPTARG(INTEGRATED_BABYSTEPPING, nextBabystepISR) // Come back early for Babystepping? ); // @@ -1507,14 +1535,9 @@ void Stepper::isr() { // nextMainISR -= interval; - - #if ENABLED(LIN_ADVANCE) - if (nextAdvanceISR != LA_ADV_NEVER) nextAdvanceISR -= interval; - #endif - - #if ENABLED(INTEGRATED_BABYSTEPPING) - if (nextBabystepISR != BABYSTEP_NEVER) nextBabystepISR -= interval; - #endif + TERN_(HAS_SHAPING, ShapingQueue::decrement_delays(interval)); + TERN_(LIN_ADVANCE, if (nextAdvanceISR != LA_ADV_NEVER) nextAdvanceISR -= interval); + TERN_(INTEGRATED_BABYSTEPPING, if (nextBabystepISR != BABYSTEP_NEVER) nextBabystepISR -= interval); /** * This needs to avoid a race-condition caused by interleaving @@ -1558,14 +1581,7 @@ void Stepper::isr() { * On AVR the ISR epilogue+prologue is estimated at 100 instructions - Give 8µs as margin * On ARM the ISR epilogue+prologue is estimated at 20 instructions - Give 1µs as margin */ - min_ticks = HAL_timer_get_count(MF_TIMER_STEP) + hal_timer_t( - #ifdef __AVR__ - 8 - #else - 1 - #endif - * (STEPPER_TIMER_TICKS_PER_US) - ); + min_ticks = HAL_timer_get_count(MF_TIMER_STEP) + hal_timer_t(TERN(__AVR__, 8, 1) * (STEPPER_TIMER_TICKS_PER_US)); /** * NB: If for some reason the stepper monopolizes the MPU, eventually the @@ -1607,11 +1623,24 @@ void Stepper::pulse_phase_isr() { // If we must abort the current block, do so! if (abort_current_block) { abort_current_block = false; - if (current_block) discard_current_block(); + if (current_block) { + discard_current_block(); + #if HAS_SHAPING + ShapingQueue::purge(); + #if ENABLED(INPUT_SHAPING_X) + shaping_x.delta_error = 0; + shaping_x.last_block_end_pos = count_position.x; + #endif + #if ENABLED(INPUT_SHAPING_Y) + shaping_y.delta_error = 0; + shaping_y.last_block_end_pos = count_position.y; + #endif + #endif + } } // If there is no current block, do nothing - if (!current_block) return; + if (!current_block || step_events_completed >= step_event_count) return; // Skipping step processing causes motion to freeze if (TERN0(FREEZE_FEATURE, frozen)) return; @@ -1630,6 +1659,9 @@ void Stepper::pulse_phase_isr() { #endif xyze_bool_t step_needed{0}; + // Direct Stepping page? + const bool is_page = current_block->is_page(); + do { #define _APPLY_STEP(AXIS, INV, ALWAYS) AXIS ##_APPLY_STEP(INV, ALWAYS) #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN @@ -1638,15 +1670,50 @@ void Stepper::pulse_phase_isr() { #define PULSE_PREP(AXIS) do{ \ delta_error[_AXIS(AXIS)] += advance_dividend[_AXIS(AXIS)]; \ step_needed[_AXIS(AXIS)] = (delta_error[_AXIS(AXIS)] >= 0); \ - if (step_needed[_AXIS(AXIS)]) { \ - count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ + if (step_needed[_AXIS(AXIS)]) \ delta_error[_AXIS(AXIS)] -= advance_divisor; \ + }while(0) + + // With input shaping, direction changes can happen with almost only + // AWAIT_LOW_PULSE() and DIR_WAIT_BEFORE() between steps. To work around + // the TMC2208 / TMC2225 shutdown bug (#16076), add a half step hysteresis + // in each direction. This results in the position being off by half an + // average half step during travel but correct at the end of each segment. + #if AXIS_DRIVER_TYPE_X(TMC2208) || AXIS_DRIVER_TYPE_X(TMC2208_STANDALONE) || \ + AXIS_DRIVER_TYPE_X(TMC5160) || AXIS_DRIVER_TYPE_X(TMC5160_STANDALONE) + #define HYSTERESIS_X 64 + #else + #define HYSTERESIS_X 0 + #endif + #if AXIS_DRIVER_TYPE_Y(TMC2208) || AXIS_DRIVER_TYPE_Y(TMC2208_STANDALONE) || \ + AXIS_DRIVER_TYPE_Y(TMC5160) || AXIS_DRIVER_TYPE_Y(TMC5160_STANDALONE) + #define HYSTERESIS_Y 64 + #else + #define HYSTERESIS_Y 0 + #endif + #define _HYSTERESIS(AXIS) HYSTERESIS_##AXIS + #define HYSTERESIS(AXIS) _HYSTERESIS(AXIS) + + #define PULSE_PREP_SHAPING(AXIS, DELTA_ERROR, DIVIDEND) do{ \ + if (step_needed[_AXIS(AXIS)]) { \ + DELTA_ERROR += (DIVIDEND); \ + if ((MAXDIR(AXIS) && DELTA_ERROR <= -(64 + HYSTERESIS(AXIS))) || (MINDIR(AXIS) && DELTA_ERROR >= (64 + HYSTERESIS(AXIS)))) { \ + { USING_TIMED_PULSE(); START_TIMED_PULSE(); AWAIT_LOW_PULSE(); } \ + TBI(last_direction_bits, _AXIS(AXIS)); \ + DIR_WAIT_BEFORE(); \ + SET_STEP_DIR(AXIS); \ + DIR_WAIT_AFTER(); \ + } \ + step_needed[_AXIS(AXIS)] = DELTA_ERROR <= -(64 + HYSTERESIS(AXIS)) || DELTA_ERROR >= (64 + HYSTERESIS(AXIS)); \ + if (step_needed[_AXIS(AXIS)]) \ + DELTA_ERROR += MAXDIR(AXIS) ? -128 : 128; \ } \ }while(0) // Start an active pulse if needed #define PULSE_START(AXIS) do{ \ if (step_needed[_AXIS(AXIS)]) { \ + count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ _APPLY_STEP(AXIS, !_INVERT_STEP_PIN(AXIS), 0); \ } \ }while(0) @@ -1658,9 +1725,6 @@ void Stepper::pulse_phase_isr() { } \ }while(0) - // Direct Stepping page? - const bool is_page = current_block->is_page(); - #if ENABLED(DIRECT_STEPPING) // Direct stepping is currently not ready for HAS_I_AXIS if (is_page) { @@ -1810,6 +1874,24 @@ void Stepper::pulse_phase_isr() { } #endif #endif + + #if HAS_SHAPING + // record an echo if a step is needed in the primary bresenham + const bool x_step = TERN0(INPUT_SHAPING_X, shaping_x.enabled && step_needed[X_AXIS]), + y_step = TERN0(INPUT_SHAPING_Y, shaping_y.enabled && step_needed[Y_AXIS]); + if (x_step || y_step) + ShapingQueue::enqueue(x_step, TERN0(INPUT_SHAPING_X, shaping_x.forward), y_step, TERN0(INPUT_SHAPING_Y, shaping_y.forward)); + + // do the first part of the secondary bresenham + #if ENABLED(INPUT_SHAPING_X) + if (shaping_x.enabled) + PULSE_PREP_SHAPING(X, shaping_x.delta_error, shaping_x.factor1 * (shaping_x.forward ? 1 : -1)); + #endif + #if ENABLED(INPUT_SHAPING_Y) + if (shaping_y.enabled) + PULSE_PREP_SHAPING(Y, shaping_y.delta_error, shaping_y.factor1 * (shaping_y.forward ? 1 : -1)); + #endif + #endif } #if ISR_MULTI_STEPS @@ -1849,7 +1931,10 @@ void Stepper::pulse_phase_isr() { #endif #if ENABLED(MIXING_EXTRUDER) - if (step_needed.e) E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); + if (step_needed.e) { + count_position[E_AXIS] += count_direction[E_AXIS]; + E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); + } #elif HAS_E0_STEP PULSE_START(E); #endif @@ -1858,7 +1943,7 @@ void Stepper::pulse_phase_isr() { // TODO: need to deal with MINIMUM_STEPPER_PULSE over i2s #if ISR_MULTI_STEPS - START_HIGH_PULSE(); + START_TIMED_PULSE(); AWAIT_HIGH_PULSE(); #endif @@ -1898,12 +1983,66 @@ void Stepper::pulse_phase_isr() { #endif #if ISR_MULTI_STEPS - if (events_to_do) START_LOW_PULSE(); + if (events_to_do) START_TIMED_PULSE(); #endif } while (--events_to_do); } +#if HAS_SHAPING + + void Stepper::shaping_isr() { + xy_bool_t step_needed{0}; + + // Clear the echoes that are ready to process. If the buffers are too full and risk overflo, also apply echoes early. + TERN_(INPUT_SHAPING_X, step_needed[X_AXIS] = !ShapingQueue::peek_x() || ShapingQueue::free_count_x() < steps_per_isr); + TERN_(INPUT_SHAPING_Y, step_needed[Y_AXIS] = !ShapingQueue::peek_y() || ShapingQueue::free_count_y() < steps_per_isr); + + if (bool(step_needed)) while (true) { + #if ENABLED(INPUT_SHAPING_X) + if (step_needed[X_AXIS]) { + const bool forward = ShapingQueue::dequeue_x(); + PULSE_PREP_SHAPING(X, shaping_x.delta_error, shaping_x.factor2 * (forward ? 1 : -1)); + PULSE_START(X); + } + #endif + + #if ENABLED(INPUT_SHAPING_Y) + if (step_needed[Y_AXIS]) { + const bool forward = ShapingQueue::dequeue_y(); + PULSE_PREP_SHAPING(Y, shaping_y.delta_error, shaping_y.factor2 * (forward ? 1 : -1)); + PULSE_START(Y); + } + #endif + + TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); + + USING_TIMED_PULSE(); + if (bool(step_needed)) { + #if ISR_MULTI_STEPS + START_TIMED_PULSE(); + AWAIT_HIGH_PULSE(); + #endif + #if ENABLED(INPUT_SHAPING_X) + PULSE_STOP(X); + #endif + #if ENABLED(INPUT_SHAPING_Y) + PULSE_STOP(Y); + #endif + } + + TERN_(INPUT_SHAPING_X, step_needed[X_AXIS] = !ShapingQueue::peek_x() || ShapingQueue::free_count_x() < steps_per_isr); + TERN_(INPUT_SHAPING_Y, step_needed[Y_AXIS] = !ShapingQueue::peek_y() || ShapingQueue::free_count_y() < steps_per_isr); + + if (!bool(step_needed)) break; + + START_TIMED_PULSE(); + AWAIT_LOW_PULSE(); + } + } + +#endif // HAS_SHAPING + // Calculate timer interval, with all limits applied. uint32_t Stepper::calc_timer_interval(uint32_t step_rate) { #ifdef CPU_32_BIT @@ -2351,35 +2490,55 @@ uint32_t Stepper::block_phase_isr() { acceleration_time = deceleration_time = 0; #if ENABLED(ADAPTIVE_STEP_SMOOTHING) - uint8_t oversampling = 0; // Assume no axis smoothing (via oversampling) + oversampling_factor = 0; // Assume no axis smoothing (via oversampling) // Decide if axis smoothing is possible uint32_t max_rate = current_block->nominal_rate; // Get the step event rate while (max_rate < MIN_STEP_ISR_FREQUENCY) { // As long as more ISRs are possible... max_rate <<= 1; // Try to double the rate if (max_rate < MIN_STEP_ISR_FREQUENCY) // Don't exceed the estimated ISR limit - ++oversampling; // Increase the oversampling (used for left-shift) + ++oversampling_factor; // Increase the oversampling (used for left-shift) } - oversampling_factor = oversampling; // For all timer interval calculations - #else - constexpr uint8_t oversampling = 0; #endif // Based on the oversampling factor, do the calculations - step_event_count = current_block->step_event_count << oversampling; + step_event_count = current_block->step_event_count << oversampling_factor; // Initialize Bresenham delta errors to 1/2 delta_error = TERN_(LIN_ADVANCE, la_delta_error =) -int32_t(step_event_count); // Calculate Bresenham dividends and divisors - advance_dividend = current_block->steps << 1; + advance_dividend = (current_block->steps << 1).asLong(); advance_divisor = step_event_count << 1; + #if ENABLED(INPUT_SHAPING_X) + if (shaping_x.enabled) { + const int64_t steps = TEST(current_block->direction_bits, X_AXIS) ? -int64_t(current_block->steps.x) : int64_t(current_block->steps.x); + shaping_x.last_block_end_pos += steps; + + // If there are any remaining echos unprocessed, then direction change must + // be delayed and processed in PULSE_PREP_SHAPING. This will cause half a step + // to be missed, which will need recovering and this can be done through shaping_x.remainder. + shaping_x.forward = !TEST(current_block->direction_bits, X_AXIS); + if (!ShapingQueue::empty_x()) SET_BIT_TO(current_block->direction_bits, X_AXIS, TEST(last_direction_bits, X_AXIS)); + } + #endif + + // Y follows the same logic as X (but the comments aren't repeated) + #if ENABLED(INPUT_SHAPING_Y) + if (shaping_y.enabled) { + const int64_t steps = TEST(current_block->direction_bits, Y_AXIS) ? -int64_t(current_block->steps.y) : int64_t(current_block->steps.y); + shaping_y.last_block_end_pos += steps; + shaping_y.forward = !TEST(current_block->direction_bits, Y_AXIS); + if (!ShapingQueue::empty_y()) SET_BIT_TO(current_block->direction_bits, Y_AXIS, TEST(last_direction_bits, Y_AXIS)); + } + #endif + // No step events completed so far step_events_completed = 0; // Compute the acceleration and deceleration points - accelerate_until = current_block->accelerate_until << oversampling; - decelerate_after = current_block->decelerate_after << oversampling; + accelerate_until = current_block->accelerate_until << oversampling_factor; + decelerate_after = current_block->decelerate_after << oversampling_factor; TERN_(MIXING_EXTRUDER, mixer.stepper_setup(current_block->b_color)); @@ -2393,7 +2552,7 @@ uint32_t Stepper::block_phase_isr() { #endif if (current_block->la_advance_rate) { // apply LA scaling and discount the effect of frequency scaling - la_dividend = (advance_dividend.e << current_block->la_scaling) << oversampling; + la_dividend = (advance_dividend.e << current_block->la_scaling) << oversampling_factor; } #endif @@ -2472,31 +2631,28 @@ uint32_t Stepper::block_phase_isr() { // the acceleration and speed values calculated in block_phase_isr(). // This helps keep LA in sync with, for example, S_CURVE_ACCELERATION. la_delta_error += la_dividend; - if (la_delta_error >= 0) { + const bool step_needed = la_delta_error >= 0; + if (step_needed) { count_position.e += count_direction.e; la_advance_steps += count_direction.e; la_delta_error -= advance_divisor; // Set the STEP pulse ON - #if ENABLED(MIXING_EXTRUDER) - E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); - #else - E_STEP_WRITE(stepper_extruder, !INVERT_E_STEP_PIN); - #endif + E_STEP_WRITE(TERN(MIXING_EXTRUDER, mixer.get_next_stepper(), stepper_extruder), !INVERT_E_STEP_PIN); + } + TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); + + if (step_needed) { // Enforce a minimum duration for STEP pulse ON #if ISR_PULSE_CONTROL USING_TIMED_PULSE(); - START_HIGH_PULSE(); + START_TIMED_PULSE(); AWAIT_HIGH_PULSE(); #endif // Set the STEP pulse OFF - #if ENABLED(MIXING_EXTRUDER) - E_STEP_WRITE(mixer.get_stepper(), INVERT_E_STEP_PIN); - #else - E_STEP_WRITE(stepper_extruder, INVERT_E_STEP_PIN); - #endif + E_STEP_WRITE(TERN(MIXING_EXTRUDER, mixer.get_stepper(), stepper_extruder), INVERT_E_STEP_PIN); } } @@ -2822,6 +2978,79 @@ void Stepper::init() { #endif } +#if HAS_SHAPING + + /** + * Calculate a fixed point factor to apply to the signal and its echo + * when shaping an axis. + */ + void Stepper::set_shaping_damping_ratio(const AxisEnum axis, const float zeta) { + // from the damping ratio, get a factor that can be applied to advance_dividend for fixed point maths + // for ZV, we use amplitudes 1/(1+K) and K/(1+K) where K = exp(-zeta * M_PI / sqrt(1.0f - zeta * zeta)) + // which can be converted to 1:7 fixed point with an excellent fit with a 3rd order polynomial + float factor2; + if (zeta <= 0.0f) factor2 = 64.0f; + else if (zeta >= 1.0f) factor2 = 0.0f; + else { + factor2 = 64.44056192 + -99.02008832 * zeta; + const float zeta2 = zeta * zeta; + factor2 += -7.58095488 * zeta2; + const float zeta3 = zeta2 * zeta; + factor2 += 43.073216 * zeta3; + factor2 = floor(factor2); + } + + const bool was_on = hal.isr_state(); + hal.isr_off(); + TERN_(INPUT_SHAPING_X, if (axis == X_AXIS) { shaping_x.factor2 = factor2; shaping_x.factor1 = 128 - factor2; shaping_x.zeta = zeta; }) + TERN_(INPUT_SHAPING_Y, if (axis == Y_AXIS) { shaping_y.factor2 = factor2; shaping_y.factor1 = 128 - factor2; shaping_y.zeta = zeta; }) + if (was_on) hal.isr_on(); + } + + float Stepper::get_shaping_damping_ratio(const AxisEnum axis) { + TERN_(INPUT_SHAPING_X, if (axis == X_AXIS) return shaping_x.zeta); + TERN_(INPUT_SHAPING_Y, if (axis == Y_AXIS) return shaping_y.zeta); + return -1; + } + + void Stepper::set_shaping_frequency(const AxisEnum axis, const float freq) { + // enabling or disabling shaping whilst moving can result in lost steps + planner.synchronize(); + + const bool was_on = hal.isr_state(); + hal.isr_off(); + + const shaping_time_t delay = freq ? float(uint32_t(STEPPER_TIMER_RATE) / 2) / freq : shaping_time_t(-1); + #if ENABLED(INPUT_SHAPING_X) + if (axis == X_AXIS) { + ShapingQueue::set_delay(X_AXIS, delay); + shaping_x.frequency = freq; + shaping_x.enabled = !!freq; + shaping_x.delta_error = 0; + shaping_x.last_block_end_pos = count_position.x; + } + #endif + #if ENABLED(INPUT_SHAPING_Y) + if (axis == Y_AXIS) { + ShapingQueue::set_delay(Y_AXIS, delay); + shaping_y.frequency = freq; + shaping_y.enabled = !!freq; + shaping_y.delta_error = 0; + shaping_y.last_block_end_pos = count_position.y; + } + #endif + + if (was_on) hal.isr_on(); + } + + float Stepper::get_shaping_frequency(const AxisEnum axis) { + TERN_(INPUT_SHAPING_X, if (axis == X_AXIS) return shaping_x.frequency); + TERN_(INPUT_SHAPING_Y, if (axis == Y_AXIS) return shaping_y.frequency); + return -1; + } + +#endif // HAS_SHAPING + /** * Set the stepper positions directly in steps * @@ -2832,6 +3061,13 @@ void Stepper::init() { * derive the current XYZE position later on. */ void Stepper::_set_position(const abce_long_t &spos) { + #if ENABLED(INPUT_SHAPING_X) + const int32_t x_shaping_delta = count_position.x - shaping_x.last_block_end_pos; + #endif + #if ENABLED(INPUT_SHAPING_Y) + const int32_t y_shaping_delta = count_position.y - shaping_y.last_block_end_pos; + #endif + #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) #if CORE_IS_XY // corexy positioning @@ -2861,6 +3097,19 @@ void Stepper::_set_position(const abce_long_t &spos) { // default non-h-bot planning count_position = spos; #endif + + #if ENABLED(INPUT_SHAPING_X) + if (shaping_x.enabled) { + count_position.x += x_shaping_delta; + shaping_x.last_block_end_pos = spos.x; + } + #endif + #if ENABLED(INPUT_SHAPING_Y) + if (shaping_y.enabled) { + count_position.y += y_shaping_delta; + shaping_y.last_block_end_pos = spos.y; + } + #endif } /** @@ -2900,6 +3149,8 @@ void Stepper::set_axis_position(const AxisEnum a, const int32_t &v) { #endif count_position[a] = v; + TERN_(INPUT_SHAPING_X, if (a == X_AXIS) shaping_x.last_block_end_pos = v); + TERN_(INPUT_SHAPING_Y, if (a == Y_AXIS) shaping_y.last_block_end_pos = v); #ifdef __AVR__ // Reenable Stepper ISR @@ -3027,7 +3278,7 @@ void Stepper::report_positions() { #if EXTRA_CYCLES_BABYSTEP > 20 #define _SAVE_START() const hal_timer_t pulse_start = HAL_timer_get_count(MF_TIMER_PULSE) - #define _PULSE_WAIT() while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_count(MF_TIMER_PULSE) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } + #define _PULSE_WAIT() while (EXTRA_CYCLES_BABYSTEP > uint32_t(HAL_timer_get_count(MF_TIMER_PULSE) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } #else #define _SAVE_START() NOOP #if EXTRA_CYCLES_BABYSTEP > 0 @@ -3865,30 +4116,53 @@ void Stepper::report_positions() { } } + // MS1 MS2 MS3 Stepper Driver Microstepping mode table + #ifndef MICROSTEP1 + #define MICROSTEP1 LOW,LOW,LOW + #endif + #if ENABLED(HEROIC_STEPPER_DRIVERS) + #ifndef MICROSTEP128 + #define MICROSTEP128 LOW,HIGH,LOW + #endif + #else + #ifndef MICROSTEP2 + #define MICROSTEP2 HIGH,LOW,LOW + #endif + #ifndef MICROSTEP4 + #define MICROSTEP4 LOW,HIGH,LOW + #endif + #endif + #ifndef MICROSTEP8 + #define MICROSTEP8 HIGH,HIGH,LOW + #endif + #ifndef MICROSTEP16 + #define MICROSTEP16 HIGH,HIGH,LOW + #endif + void Stepper::microstep_mode(const uint8_t driver, const uint8_t stepping_mode) { switch (stepping_mode) { - #if HAS_MICROSTEP1 + #ifdef MICROSTEP1 case 1: microstep_ms(driver, MICROSTEP1); break; #endif - #if HAS_MICROSTEP2 + #ifdef MICROSTEP2 case 2: microstep_ms(driver, MICROSTEP2); break; #endif - #if HAS_MICROSTEP4 + #ifdef MICROSTEP4 case 4: microstep_ms(driver, MICROSTEP4); break; #endif - #if HAS_MICROSTEP8 + #ifdef MICROSTEP8 case 8: microstep_ms(driver, MICROSTEP8); break; #endif - #if HAS_MICROSTEP16 + #ifdef MICROSTEP16 case 16: microstep_ms(driver, MICROSTEP16); break; #endif - #if HAS_MICROSTEP32 + #ifdef MICROSTEP32 case 32: microstep_ms(driver, MICROSTEP32); break; #endif - #if HAS_MICROSTEP64 + #ifdef MICROSTEP64 case 64: microstep_ms(driver, MICROSTEP64); break; #endif - #if HAS_MICROSTEP128 + #ifdef MICROSTEP128 case 128: microstep_ms(driver, MICROSTEP128); break; #endif diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index ccf342b573e7..e86498e841da 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -75,8 +75,8 @@ */ #define TIMER_READ_ADD_AND_STORE_CYCLES 34UL - // The base ISR takes 792 cycles - #define ISR_BASE_CYCLES 792UL + // The base ISR + #define ISR_BASE_CYCLES 770UL // Linear advance base time is 64 cycles #if ENABLED(LIN_ADVANCE) @@ -87,26 +87,34 @@ // S curve interpolation adds 40 cycles #if ENABLED(S_CURVE_ACCELERATION) - #define ISR_S_CURVE_CYCLES 40UL + #ifdef STM32G0B1xx + #define ISR_S_CURVE_CYCLES 500UL + #else + #define ISR_S_CURVE_CYCLES 40UL + #endif #else #define ISR_S_CURVE_CYCLES 0UL #endif + // Input shaping base time + #if HAS_SHAPING + #define ISR_SHAPING_BASE_CYCLES 180UL + #else + #define ISR_SHAPING_BASE_CYCLES 0UL + #endif + // Stepper Loop base cycles #define ISR_LOOP_BASE_CYCLES 4UL - // To start the step pulse, in the worst case takes - #define ISR_START_STEPPER_CYCLES 13UL - // And each stepper (start + stop pulse) takes in worst case - #define ISR_STEPPER_CYCLES 16UL + #define ISR_STEPPER_CYCLES 100UL #else // Cycles to perform actions in START_TIMED_PULSE #define TIMER_READ_ADD_AND_STORE_CYCLES 13UL - // The base ISR takes 752 cycles - #define ISR_BASE_CYCLES 752UL + // The base ISR + #define ISR_BASE_CYCLES 1000UL // Linear advance base time is 32 cycles #if ENABLED(LIN_ADVANCE) @@ -122,12 +130,16 @@ #define ISR_S_CURVE_CYCLES 0UL #endif + // Input shaping base time + #if HAS_SHAPING + #define ISR_SHAPING_BASE_CYCLES 290UL + #else + #define ISR_SHAPING_BASE_CYCLES 0UL + #endif + // Stepper Loop base cycles #define ISR_LOOP_BASE_CYCLES 32UL - // To start the step pulse, in the worst case takes - #define ISR_START_STEPPER_CYCLES 57UL - // And each stepper (start + stop pulse) takes in worst case #define ISR_STEPPER_CYCLES 88UL @@ -202,8 +214,12 @@ #error "Expected at least one of MINIMUM_STEPPER_PULSE or MAXIMUM_STEPPER_RATE to be defined" #endif -// But the user could be enforcing a minimum time, so the loop time is -#define ISR_LOOP_CYCLES (ISR_LOOP_BASE_CYCLES + _MAX(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LOOP_CYCLES)) +// The loop takes the base time plus the time for all the bresenham logic for R pulses plus the time +// between pulses for (R-1) pulses. But the user could be enforcing a minimum time so the loop time is: +#define ISR_LOOP_CYCLES(R) ((ISR_LOOP_BASE_CYCLES + MIN_ISR_LOOP_CYCLES + MIN_STEPPER_PULSE_CYCLES) * (R - 1) + _MAX(MIN_ISR_LOOP_CYCLES, MIN_STEPPER_PULSE_CYCLES)) + +// Model input shaping as an extra loop call +#define ISR_SHAPING_LOOP_CYCLES(R) ((TERN0(HAS_SHAPING, ISR_LOOP_BASE_CYCLES) + TERN0(INPUT_SHAPING_X, ISR_X_STEPPER_CYCLES) + TERN0(INPUT_SHAPING_Y, ISR_Y_STEPPER_CYCLES)) * (R) + (MIN_ISR_LOOP_CYCLES) * (R - 1)) // If linear advance is enabled, then it is handled separately #if ENABLED(LIN_ADVANCE) @@ -228,7 +244,7 @@ #endif // Now estimate the total ISR execution time in cycles given a step per ISR multiplier -#define ISR_EXECUTION_CYCLES(R) (((ISR_BASE_CYCLES + ISR_S_CURVE_CYCLES + (ISR_LOOP_CYCLES) * (R) + ISR_LA_BASE_CYCLES + ISR_LA_LOOP_CYCLES)) / (R)) +#define ISR_EXECUTION_CYCLES(R) (((ISR_BASE_CYCLES + ISR_S_CURVE_CYCLES + ISR_SHAPING_BASE_CYCLES + ISR_LOOP_CYCLES(R) + ISR_SHAPING_LOOP_CYCLES(R) + ISR_LA_BASE_CYCLES + ISR_LA_LOOP_CYCLES)) / (R)) // The maximum allowable stepping frequency when doing x128-x1 stepping (in Hz) #define MAX_STEP_ISR_FREQUENCY_128X ((F_CPU) / ISR_EXECUTION_CYCLES(128)) @@ -312,12 +328,143 @@ constexpr ena_mask_t enable_overlap[] = { //static_assert(!any_enable_overlap(), "There is some overlap."); +#if HAS_SHAPING + + #ifdef SHAPING_MAX_STEPRATE + constexpr float max_step_rate = SHAPING_MAX_STEPRATE; + #else + constexpr float _ISDASU[] = DEFAULT_AXIS_STEPS_PER_UNIT; + constexpr feedRate_t _ISDMF[] = DEFAULT_MAX_FEEDRATE; + constexpr float max_shaped_rate = TERN0(INPUT_SHAPING_X, _ISDMF[X_AXIS] * _ISDASU[X_AXIS]) + + TERN0(INPUT_SHAPING_Y, _ISDMF[Y_AXIS] * _ISDASU[Y_AXIS]); + #if defined(__AVR__) || !defined(ADAPTIVE_STEP_SMOOTHING) + // MIN_STEP_ISR_FREQUENCY is known at compile time on AVRs and any reduction in SRAM is welcome + template constexpr float max_isr_rate() { + return _MAX(_ISDMF[INDEX - 1] * _ISDASU[INDEX - 1], max_isr_rate()); + } + template<> constexpr float max_isr_rate<0>() { + return TERN0(ADAPTIVE_STEP_SMOOTHING, MIN_STEP_ISR_FREQUENCY); + } + constexpr float max_step_rate = _MIN(max_isr_rate(), max_shaped_rate); + #else + constexpr float max_step_rate = max_shaped_rate; + #endif + #endif + + #ifndef SHAPING_MIN_FREQ + #define SHAPING_MIN_FREQ _MIN(0x7FFFFFFFL OPTARG(INPUT_SHAPING_X, SHAPING_FREQ_X) OPTARG(INPUT_SHAPING_Y, SHAPING_FREQ_Y)) + #endif + constexpr uint16_t shaping_min_freq = SHAPING_MIN_FREQ, + shaping_echoes = max_step_rate / shaping_min_freq / 2 + 3; + + typedef IF::type shaping_time_t; + enum shaping_echo_t { ECHO_NONE = 0, ECHO_FWD = 1, ECHO_BWD = 2 }; + struct shaping_echo_axis_t { + TERN_(INPUT_SHAPING_X, shaping_echo_t x:2); + TERN_(INPUT_SHAPING_Y, shaping_echo_t y:2); + }; + + class ShapingQueue { + private: + static shaping_time_t now; + static shaping_time_t times[shaping_echoes]; + static shaping_echo_axis_t echo_axes[shaping_echoes]; + static uint16_t tail; + + #if ENABLED(INPUT_SHAPING_X) + static shaping_time_t delay_x; // = shaping_time_t(-1) to disable queueing + static shaping_time_t peek_x_val; + static uint16_t head_x; + static uint16_t _free_count_x; + #endif + #if ENABLED(INPUT_SHAPING_Y) + static shaping_time_t delay_y; // = shaping_time_t(-1) to disable queueing + static shaping_time_t peek_y_val; + static uint16_t head_y; + static uint16_t _free_count_y; + #endif + + public: + static void decrement_delays(const shaping_time_t interval) { + now += interval; + TERN_(INPUT_SHAPING_X, if (peek_x_val != shaping_time_t(-1)) peek_x_val -= interval); + TERN_(INPUT_SHAPING_Y, if (peek_y_val != shaping_time_t(-1)) peek_y_val -= interval); + } + static void set_delay(const AxisEnum axis, const shaping_time_t delay) { + TERN_(INPUT_SHAPING_X, if (axis == X_AXIS) delay_x = delay); + TERN_(INPUT_SHAPING_Y, if (axis == Y_AXIS) delay_y = delay); + } + static void enqueue(const bool x_step, const bool x_forward, const bool y_step, const bool y_forward) { + TERN_(INPUT_SHAPING_X, if (head_x == tail && x_step) peek_x_val = delay_x); + TERN_(INPUT_SHAPING_Y, if (head_y == tail && y_step) peek_y_val = delay_y); + times[tail] = now; + TERN_(INPUT_SHAPING_X, echo_axes[tail].x = x_step ? (x_forward ? ECHO_FWD : ECHO_BWD) : ECHO_NONE); + TERN_(INPUT_SHAPING_Y, echo_axes[tail].y = y_step ? (y_forward ? ECHO_FWD : ECHO_BWD) : ECHO_NONE); + if (++tail == shaping_echoes) tail = 0; + TERN_(INPUT_SHAPING_X, _free_count_x--); + TERN_(INPUT_SHAPING_Y, _free_count_y--); + TERN_(INPUT_SHAPING_X, if (echo_axes[head_x].x == ECHO_NONE) dequeue_x()); + TERN_(INPUT_SHAPING_Y, if (echo_axes[head_y].y == ECHO_NONE) dequeue_y()); + } + #if ENABLED(INPUT_SHAPING_X) + static shaping_time_t peek_x() { return peek_x_val; } + static bool dequeue_x() { + bool forward = echo_axes[head_x].x == ECHO_FWD; + do { + _free_count_x++; + if (++head_x == shaping_echoes) head_x = 0; + } while (head_x != tail && echo_axes[head_x].x == ECHO_NONE); + peek_x_val = head_x == tail ? shaping_time_t(-1) : times[head_x] + delay_x - now; + return forward; + } + static bool empty_x() { return head_x == tail; } + static uint16_t free_count_x() { return _free_count_x; } + #endif + #if ENABLED(INPUT_SHAPING_Y) + static shaping_time_t peek_y() { return peek_y_val; } + static bool dequeue_y() { + bool forward = echo_axes[head_y].y == ECHO_FWD; + do { + _free_count_y++; + if (++head_y == shaping_echoes) head_y = 0; + } while (head_y != tail && echo_axes[head_y].y == ECHO_NONE); + peek_y_val = head_y == tail ? shaping_time_t(-1) : times[head_y] + delay_y - now; + return forward; + } + static bool empty_y() { return head_y == tail; } + static uint16_t free_count_y() { return _free_count_y; } + #endif + static void purge() { + const auto st = shaping_time_t(-1); + #if ENABLED(INPUT_SHAPING_X) + head_x = tail; _free_count_x = shaping_echoes - 1; peek_x_val = st; + #endif + #if ENABLED(INPUT_SHAPING_Y) + head_y = tail; _free_count_y = shaping_echoes - 1; peek_y_val = st; + #endif + } + }; + + struct ShapeParams { + float frequency; + float zeta; + bool enabled; + int16_t delta_error = 0; // delta_error for seconday bresenham mod 128 + uint8_t factor1; + uint8_t factor2; + bool forward; + int32_t last_block_end_pos = 0; + }; + +#endif // HAS_SHAPING + // // Stepper class definition // class Stepper { friend class KinematicSystem; friend class DeltaKinematicSystem; + friend void stepperTask(void *); public: @@ -390,7 +537,7 @@ class Stepper { // Delta error variables for the Bresenham line tracer static xyze_long_t delta_error; - static xyze_ulong_t advance_dividend; + static xyze_long_t advance_dividend; static uint32_t advance_divisor, step_events_completed, // The number of step events executed in the current block accelerate_until, // The point from where we need to stop acceleration @@ -415,6 +562,15 @@ class Stepper { static bool bezier_2nd_half; // If Bézier curve has been initialized or not #endif + #if HAS_SHAPING + #if ENABLED(INPUT_SHAPING_X) + static ShapeParams shaping_x; + #endif + #if ENABLED(INPUT_SHAPING_Y) + static ShapeParams shaping_y; + #endif + #endif + #if ENABLED(LIN_ADVANCE) static constexpr uint32_t LA_ADV_NEVER = 0xFFFFFFFF; static uint32_t nextAdvanceISR, @@ -474,6 +630,10 @@ class Stepper { // The stepper block processing ISR phase static uint32_t block_phase_isr(); + #if HAS_SHAPING + static void shaping_isr(); + #endif + #if ENABLED(LIN_ADVANCE) // The Linear advance ISR phase static void advance_isr(); @@ -493,6 +653,20 @@ class Stepper { // Check if the given block is busy or not - Must not be called from ISR contexts static bool is_block_busy(const block_t * const block); + #if HAS_SHAPING + // Check whether the stepper is processing any input shaping echoes + static bool input_shaping_busy() { + const bool was_on = hal.isr_state(); + hal.isr_off(); + + const bool result = TERN0(INPUT_SHAPING_X, !ShapingQueue::empty_x()) || TERN0(INPUT_SHAPING_Y, !ShapingQueue::empty_y()); + + if (was_on) hal.isr_on(); + + return result; + } + #endif + // Get the position of a stepper, in steps static int32_t position(const AxisEnum axis); @@ -627,6 +801,13 @@ class Stepper { set_directions(); } + #if HAS_SHAPING + static void set_shaping_damping_ratio(const AxisEnum axis, const float zeta); + static float get_shaping_damping_ratio(const AxisEnum axis); + static void set_shaping_frequency(const AxisEnum axis, const float freq); + static float get_shaping_frequency(const AxisEnum axis); + #endif + private: // Set the current position in steps diff --git a/Marlin/src/module/stepper/TMC26X.cpp b/Marlin/src/module/stepper/TMC26X.cpp index 52d84f84101c..f46163ea2de2 100644 --- a/Marlin/src/module/stepper/TMC26X.cpp +++ b/Marlin/src/module/stepper/TMC26X.cpp @@ -34,7 +34,7 @@ #include "TMC26X.h" -#define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR) +#define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_CURRENT, int(ST##_RSENSE * 1000)) #if AXIS_DRIVER_TYPE_X(TMC26X) _TMC26X_DEFINE(X); diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index bf36f83cd872..48ce020d3dca 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -1023,8 +1023,6 @@ void reset_trinamic_drivers() { // 2. For each axis in use, static_assert using a constexpr function, which counts the // number of matching/conflicting axis. If the value is not exactly 1, fail. -#define ALL_AXIS_NAMES X, X2, Y, Y2, Z, Z2, Z3, Z4, I, J, K, U, V, W, E0, E1, E2, E3, E4, E5, E6, E7 - #if ANY_AXIS_HAS(HW_SERIAL) // Hardware serial names are compared as strings, since actually resolving them cannot occur in a constexpr. // Using a fixed-length character array for the port name allows this to be constexpr compatible. diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 989828cd18a2..2d785ac11468 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -30,6 +30,7 @@ #include "../MarlinCore.h" #include "../HAL/shared/Delay.h" #include "../lcd/marlinui.h" +#include "../gcode/gcode.h" #include "temperature.h" #include "endstops.h" @@ -63,10 +64,6 @@ #include "../feature/host_actions.h" #endif -#if EITHER(HAS_TEMP_SENSOR, LASER_FEATURE) - #include "../gcode/gcode.h" -#endif - #if ENABLED(NOZZLE_PARK_FEATURE) #include "../libs/nozzle.h" #endif @@ -120,13 +117,16 @@ // 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 + #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 + #define TEMP_SENSOR_1_USES_SW_SPI 1 +#endif +#if TEMP_SENSOR_IS_ANY_MAX_TC(2) && TEMP_SENSOR_2_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI) + #define TEMP_SENSOR_2_USES_SW_SPI 1 #endif -#if (TEMP_SENSOR_0_USES_SW_SPI || TEMP_SENSOR_1_USES_SW_SPI) && !HAS_MAXTC_LIBRARIES +#if (TEMP_SENSOR_0_USES_SW_SPI || TEMP_SENSOR_1_USES_SW_SPI || TEMP_SENSOR_2_USES_SW_SPI) && !HAS_MAXTC_LIBRARIES #include "../libs/private_spi.h" #define HAS_MAXTC_SW_SPI 1 @@ -137,12 +137,18 @@ #if PIN_EXISTS(TEMP_0_MOSI) #define SW_SPI_MOSI_PIN TEMP_0_MOSI_PIN #endif - #else + #elif TEMP_SENSOR_1_USES_SW_SPI #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 + #elif TEMP_SENSOR_2_USES_SW_SPI + #define SW_SPI_SCK_PIN TEMP_2_SCK_PIN + #define SW_SPI_MISO_PIN TEMP_2_MISO_PIN + #if PIN_EXISTS(TEMP_2_MOSI) + #define SW_SPI_MOSI_PIN TEMP_2_MOSI_PIN + #endif #endif #ifndef SW_SPI_MOSI_PIN #define SW_SPI_MOSI_PIN SD_MOSI_PIN @@ -263,6 +269,9 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if TEMP_SENSOR_IS_MAX(1, 6675) MAXTC_INIT(1, 6675); #endif + #if TEMP_SENSOR_IS_MAX(2, 6675) + MAXTC_INIT(2, 6675); + #endif #endif #if HAS_MAX31855_LIBRARY @@ -272,12 +281,16 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if TEMP_SENSOR_IS_MAX(1, 31855) MAXTC_INIT(1, 31855); #endif + #if TEMP_SENSOR_IS_MAX(2, 31855) + MAXTC_INIT(2, 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 + #define _MAX31865_2_SW TEMP_SENSOR_2_USES_SW_SPI #if TEMP_SENSOR_IS_MAX(0, 31865) MAXTC_INIT(0, 31865); @@ -285,9 +298,13 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if TEMP_SENSOR_IS_MAX(1, 31865) MAXTC_INIT(1, 31865); #endif + #if TEMP_SENSOR_IS_MAX(2, 31865) + MAXTC_INIT(2, 31865); + #endif #undef _MAX31865_0_SW #undef _MAX31865_1_SW + #undef _MAX31865_2_SW #endif #undef MAXTC_INIT @@ -313,19 +330,19 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #endif #if EITHER(AUTO_POWER_E_FANS, HAS_FANCHECK) - uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 } + uint8_t Temperature::autofan_speed[HOTENDS] = ARRAY_N_1(HOTENDS, FAN_OFF_PWM); #endif #if ENABLED(AUTO_POWER_CHAMBER_FAN) - uint8_t Temperature::chamberfan_speed; // = 0 + uint8_t Temperature::chamberfan_speed = FAN_OFF_PWM; #endif #if ENABLED(AUTO_POWER_COOLER_FAN) - uint8_t Temperature::coolerfan_speed; // = 0 + uint8_t Temperature::coolerfan_speed = FAN_OFF_PWM; #endif #if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN) - uint8_t Temperature::soft_pwm_controller_speed; + uint8_t Temperature::soft_pwm_controller_speed = FAN_OFF_PWM; #endif // Init fans according to whether they're native PWM or Software PWM @@ -349,11 +366,11 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); // HAS_FAN does not include CONTROLLER_FAN #if HAS_FAN - uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 } + uint8_t Temperature::fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, FAN_OFF_PWM); #if ENABLED(EXTRA_FAN_SPEED) - Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT]; + Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, FAN_OFF_PWM); /** * Handle the M106 P T command: @@ -380,7 +397,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE) bool Temperature::fans_paused; // = false; - uint8_t Temperature::saved_fan_speed[FAN_COUNT]; // = { 0 } + uint8_t Temperature::saved_fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, FAN_OFF_PWM); #endif #if ENABLED(ADAPTIVE_FAN_SLOWING) @@ -548,6 +565,7 @@ volatile bool Temperature::raw_temps_ready = false; #endif #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 + #define MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR 1 uint8_t Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 }; #endif @@ -601,7 +619,7 @@ volatile bool Temperature::raw_temps_ready = false; millis_t next_temp_ms = millis(), t1 = next_temp_ms, t2 = next_temp_ms; long t_high = 0, t_low = 0; - PID_t tune_pid = { 0, 0, 0 }; + raw_pid_t tune_pid = { 0, 0, 0 }; celsius_float_t maxT = 0, minT = 10000; const bool isbed = (heater_id == H_BED), @@ -647,7 +665,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(HAS_FAN_LOGIC, fan_update_ms = next_temp_ms + fan_update_interval_ms); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); - TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PIDTEMPBED_START : PIDTEMP_START)); if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { SERIAL_ECHOPGM(STR_PID_AUTOTUNE); @@ -720,16 +738,16 @@ volatile bool Temperature::raw_temps_ready = false; pf = (ischamber || isbed) ? 0.2f : 0.6f, df = (ischamber || isbed) ? 1.0f / 3.0f : 1.0f / 8.0f; - tune_pid.Kp = Ku * pf; - tune_pid.Ki = tune_pid.Kp * 2.0f / Tu; - tune_pid.Kd = tune_pid.Kp * Tu * df; + tune_pid.p = Ku * pf; + tune_pid.i = tune_pid.p * 2.0f / Tu; + tune_pid.d = tune_pid.p * Tu * df; SERIAL_ECHOLNPGM(STR_KU, Ku, STR_TU, Tu); if (ischamber || isbed) SERIAL_ECHOLNPGM(" No overshoot"); else SERIAL_ECHOLNPGM(STR_CLASSIC_PID); - SERIAL_ECHOLNPGM(STR_KP, tune_pid.Kp, STR_KI, tune_pid.Ki, STR_KD, tune_pid.Kd); + SERIAL_ECHOLNPGM(STR_KP, tune_pid.p, STR_KI, tune_pid.i, STR_KD, tune_pid.d); } } SHV((bias + d) >> 1); @@ -815,39 +833,36 @@ volatile bool Temperature::raw_temps_ready = false; #if EITHER(PIDTEMPBED, PIDTEMPCHAMBER) FSTR_P const estring = GHV(F("chamber"), F("bed"), FPSTR(NUL_STR)); - say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp); - say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki); - say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd); + say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.p); + say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.i); + say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.d); #else - say_default_(); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp); - say_default_(); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki); - say_default_(); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd); + say_default_(); SERIAL_ECHOLNPGM("Kp ", tune_pid.p); + say_default_(); SERIAL_ECHOLNPGM("Ki ", tune_pid.i); + say_default_(); SERIAL_ECHOLNPGM("Kd ", tune_pid.d); #endif - auto _set_hotend_pid = [](const uint8_t e, const PID_t &in_pid) { + auto _set_hotend_pid = [](const uint8_t tool, const raw_pid_t &in_pid) { #if ENABLED(PIDTEMP) - PID_PARAM(Kp, e) = in_pid.Kp; - PID_PARAM(Ki, e) = scalePID_i(in_pid.Ki); - PID_PARAM(Kd, e) = scalePID_d(in_pid.Kd); + #if ENABLED(PID_PARAMS_PER_HOTEND) + thermalManager.temp_hotend[tool].pid.set(in_pid); + #else + HOTEND_LOOP() thermalManager.temp_hotend[e].pid.set(in_pid); + #endif updatePID(); - #else - UNUSED(e); UNUSED(in_pid); #endif + UNUSED(tool); UNUSED(in_pid); }; #if ENABLED(PIDTEMPBED) - auto _set_bed_pid = [](const PID_t &in_pid) { - temp_bed.pid.Kp = in_pid.Kp; - temp_bed.pid.Ki = scalePID_i(in_pid.Ki); - temp_bed.pid.Kd = scalePID_d(in_pid.Kd); + auto _set_bed_pid = [](const raw_pid_t &in_pid) { + temp_bed.pid.set(in_pid); }; #endif #if ENABLED(PIDTEMPCHAMBER) - auto _set_chamber_pid = [](const PID_t &in_pid) { - temp_chamber.pid.Kp = in_pid.Kp; - temp_chamber.pid.Ki = scalePID_i(in_pid.Ki); - temp_chamber.pid.Kd = scalePID_d(in_pid.Kd); + auto _set_chamber_pid = [](const raw_pid_t &in_pid) { + temp_chamber.pid.set(in_pid); }; #endif @@ -1323,7 +1338,7 @@ void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_m #endif } -void Temperature::max_temp_error(const heater_id_t heater_id) { +void Temperature::maxtemp_error(const heater_id_t heater_id) { #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED) DWIN_Popup_Temperature(1); #endif @@ -1340,7 +1355,7 @@ void Temperature::max_temp_error(const heater_id_t heater_id) { _temp_error(heater_id, F(STR_T_MAXTEMP), GET_TEXT_F(MSG_ERR_MAXTEMP)); } -void Temperature::min_temp_error(const heater_id_t heater_id) { +void Temperature::mintemp_error(const heater_id_t heater_id) { #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED) DWIN_Popup_Temperature(0); #endif @@ -1414,13 +1429,13 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { FORCE_INLINE void debug(const_celsius_float_t c, const_float_t pid_out, FSTR_P const name=nullptr, const int8_t index=-1) { if (TERN0(HAS_PID_DEBUG, thermalManager.pid_debug_flag)) { SERIAL_ECHO_START(); - if (name) SERIAL_ECHOLNF(name); + if (name) SERIAL_ECHOF(name); if (index >= 0) SERIAL_ECHO(index); SERIAL_ECHOLNPGM( STR_PID_DEBUG_INPUT, c, STR_PID_DEBUG_OUTPUT, pid_out #if DISABLED(PID_OPENLOOP) - , "pTerm", work_pid.Kp, "iTerm", work_pid.Ki, "dTerm", work_pid.Kd + , " pTerm ", work_pid.Kp, " iTerm ", work_pid.Ki, " dTerm ", work_pid.Kd #endif ); } @@ -1434,6 +1449,8 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { float Temperature::get_pid_output_hotend(const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; + const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); + #if ENABLED(PIDTEMP) typedef PIDRunner PIDRunnerHotend; @@ -1443,7 +1460,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { REPEAT(HOTENDS, _HOTENDPID) }; - const float pid_output = hotend_pid[ee].get_pid_output(); + const float pid_output = is_idling ? 0 : hotend_pid[ee].get_pid_output(); #if ENABLED(PID_DEBUG) if (ee == active_extruder) @@ -1506,7 +1523,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { hotend.modeled_ambient_temp += delta_to_apply > 0.f ? _MAX(delta_to_apply, MPC_MIN_AMBIENT_CHANGE * MPC_dT) : _MIN(delta_to_apply, -MPC_MIN_AMBIENT_CHANGE * MPC_dT); float power = 0.0; - if (hotend.target != 0 && TERN1(HEATER_IDLE_HANDLER, !heater_idle[ee].timed_out)) { + if (hotend.target != 0 && !is_idling) { // Plan power level to get to target temperature in 2 seconds power = (hotend.target - hotend.modeled_block_temp) * constants.block_heat_capacity / 2.0f; power -= (hotend.modeled_ambient_temp - hotend.modeled_block_temp) * ambient_xfer_coeff; @@ -1532,7 +1549,6 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #else // No PID or MPC enabled - const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); const float pid_output = (!is_idling && temp_hotend[ee].is_below_target()) ? BANG_MAX : 0; #endif @@ -1569,7 +1585,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { void Temperature::manage_hotends(const millis_t &ms) { HOTEND_LOOP() { #if ENABLED(THERMAL_PROTECTION_HOTENDS) - if (degHotend(e) > temp_range[e].maxtemp) max_temp_error((heater_id_t)e); + if (degHotend(e) > temp_range[e].maxtemp) maxtemp_error((heater_id_t)e); #endif TERN_(HEATER_IDLE_HANDLER, heater_idle[e].update(ms)); @@ -1609,7 +1625,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { void Temperature::manage_heated_bed(const millis_t &ms) { #if ENABLED(THERMAL_PROTECTION_BED) - if (degBed() > BED_MAXTEMP) max_temp_error(H_BED); + if (degBed() > BED_MAXTEMP) maxtemp_error(H_BED); #endif #if WATCH_BED @@ -1655,22 +1671,25 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #endif #if HEATER_IDLE_HANDLER - if (heater_idle[IDLE_INDEX_BED].timed_out) { + const bool bed_timed_out = heater_idle[IDLE_INDEX_BED].timed_out; + if (bed_timed_out) { temp_bed.soft_pwm_amount = 0; if (DISABLED(PIDTEMPBED)) WRITE_HEATER_BED(LOW); } - else + #else + constexpr bool bed_timed_out = false; #endif - { + + if (!bed_timed_out) { #if ENABLED(PIDTEMPBED) temp_bed.soft_pwm_amount = WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0; #else // Check if temperature is within the correct band if (WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP)) { #if ENABLED(BED_LIMIT_SWITCHING) - if (temp_bed.celsius >= temp_bed.target + BED_HYSTERESIS) + if (temp_bed.is_above_target((BED_HYSTERESIS) - 1)) temp_bed.soft_pwm_amount = 0; - else if (temp_bed.is_below_target(-(BED_HYSTERESIS) + 1)) + else if (temp_bed.is_below_target((BED_HYSTERESIS) - 1)) temp_bed.soft_pwm_amount = MAX_BED_POWER >> 1; #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING temp_bed.soft_pwm_amount = temp_bed.is_below_target() ? MAX_BED_POWER >> 1 : 0; @@ -1697,7 +1716,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #endif #if ENABLED(THERMAL_PROTECTION_CHAMBER) - if (degChamber() > CHAMBER_MAXTEMP) max_temp_error(H_CHAMBER); + if (degChamber() > (CHAMBER_MAXTEMP)) maxtemp_error(H_CHAMBER); #endif #if WATCH_CHAMBER @@ -1725,13 +1744,12 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #if CHAMBER_FAN_MODE == 0 fan_chamber_pwm = CHAMBER_FAN_BASE; #elif CHAMBER_FAN_MODE == 1 - fan_chamber_pwm = (temp_chamber.celsius > temp_chamber.target) ? (CHAMBER_FAN_BASE) + (CHAMBER_FAN_FACTOR) * (temp_chamber.celsius - temp_chamber.target) : 0; + fan_chamber_pwm = temp_chamber.is_above_target() ? (CHAMBER_FAN_BASE) + (CHAMBER_FAN_FACTOR) * (temp_chamber.celsius - temp_chamber.target) : 0; #elif CHAMBER_FAN_MODE == 2 fan_chamber_pwm = (CHAMBER_FAN_BASE) + (CHAMBER_FAN_FACTOR) * ABS(temp_chamber.celsius - temp_chamber.target); - if (temp_chamber.soft_pwm_amount) - fan_chamber_pwm += (CHAMBER_FAN_FACTOR) * 2; + if (temp_chamber.soft_pwm_amount) fan_chamber_pwm += (CHAMBER_FAN_FACTOR) * 2; #elif CHAMBER_FAN_MODE == 3 - fan_chamber_pwm = CHAMBER_FAN_BASE + _MAX((CHAMBER_FAN_FACTOR) * (temp_chamber.celsius - temp_chamber.target), 0); + fan_chamber_pwm = (CHAMBER_FAN_BASE) + _MAX((CHAMBER_FAN_FACTOR) * (temp_chamber.celsius - temp_chamber.target), 0); #endif NOMORE(fan_chamber_pwm, 255); set_fan_speed(CHAMBER_FAN_INDEX, fan_chamber_pwm); @@ -1744,7 +1762,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #ifndef MIN_COOLING_SLOPE_DEG_CHAMBER_VENT #define MIN_COOLING_SLOPE_DEG_CHAMBER_VENT 1.5 #endif - if (!flag_chamber_excess_heat && temp_chamber.celsius - temp_chamber.target >= HIGH_EXCESS_HEAT_LIMIT) { + if (!flag_chamber_excess_heat && temp_chamber.is_above_target((HIGH_EXCESS_HEAT_LIMIT) - 1)) { // Open vent after MIN_COOLING_SLOPE_TIME_CHAMBER_VENT seconds if the // temperature didn't drop at least MIN_COOLING_SLOPE_DEG_CHAMBER_VENT if (next_cool_check_ms_2 == 0 || ELAPSED(ms, next_cool_check_ms_2)) { @@ -1758,7 +1776,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { next_cool_check_ms_2 = 0; old_temp = 9999; } - if (flag_chamber_excess_heat && (temp_chamber.target - temp_chamber.celsius >= LOW_EXCESS_HEAT_LIMIT)) + if (flag_chamber_excess_heat && temp_chamber.is_above_target((LOW_EXCESS_HEAT_LIMIT) - 1)) flag_chamber_excess_heat = false; #endif } @@ -1790,9 +1808,9 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { } else { #if ENABLED(CHAMBER_LIMIT_SWITCHING) - if (temp_chamber.celsius >= temp_chamber.target + TEMP_CHAMBER_HYSTERESIS) + if (temp_chamber.is_above_target((TEMP_CHAMBER_HYSTERESIS) - 1)) temp_chamber.soft_pwm_amount = 0; - else if (temp_chamber.is_below_target(-(TEMP_CHAMBER_HYSTERESIS) + 1)) + else if (temp_chamber.is_below_target((TEMP_CHAMBER_HYSTERESIS) - 1)) temp_chamber.soft_pwm_amount = (MAX_CHAMBER_POWER) >> 1; #else temp_chamber.soft_pwm_amount = temp_chamber.is_below_target() ? (MAX_CHAMBER_POWER) >> 1 : 0; @@ -1824,7 +1842,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #endif #if ENABLED(THERMAL_PROTECTION_COOLER) - if (degCooler() > COOLER_MAXTEMP) max_temp_error(H_COOLER); + if (degCooler() > COOLER_MAXTEMP) maxtemp_error(H_COOLER); #endif #if WATCH_COOLER @@ -1844,20 +1862,18 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { if (temp_cooler.target == 0) temp_cooler.target = COOLER_MIN_TARGET; if (ELAPSED(ms, next_cooler_check_ms)) { next_cooler_check_ms = ms + COOLER_CHECK_INTERVAL; - if (temp_cooler.celsius > temp_cooler.target) { - temp_cooler.soft_pwm_amount = temp_cooler.celsius > temp_cooler.target ? MAX_COOLER_POWER : 0; - flag_cooler_state = temp_cooler.soft_pwm_amount > 0 ? true : false; // used to allow M106 fan control when cooler is disabled + if (temp_cooler.is_above_target()) { // too warm? + temp_cooler.soft_pwm_amount = MAX_COOLER_POWER; #if ENABLED(COOLER_FAN) - int16_t fan_cooler_pwm = (COOLER_FAN_BASE) + (COOLER_FAN_FACTOR) * ABS(temp_cooler.celsius - temp_cooler.target); - NOMORE(fan_cooler_pwm, 255); - set_fan_speed(COOLER_FAN_INDEX, fan_cooler_pwm); // Set cooler fan pwm + const int16_t fan_cooler_pwm = (COOLER_FAN_BASE) + (COOLER_FAN_FACTOR) * ABS(temp_cooler.celsius - temp_cooler.target); + set_fan_speed(COOLER_FAN_INDEX, _MIN(fan_cooler_pwm, 255)); // Set cooler fan pwm cooler_fan_flush_ms = ms + 5000; #endif } else { temp_cooler.soft_pwm_amount = 0; #if ENABLED(COOLER_FAN) - set_fan_speed(COOLER_FAN_INDEX, temp_cooler.celsius > temp_cooler.target - 2 ? COOLER_FAN_BASE : 0); + set_fan_speed(COOLER_FAN_INDEX, temp_cooler.is_above_target(-2) ? COOLER_FAN_BASE : 0); #endif WRITE_HEATER_COOLER(LOW); } @@ -1902,22 +1918,34 @@ void Temperature::task() { emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! quickstop_stepper(); } + + #if ENABLED(SDSUPPORT) + if (emergency_parser.sd_abort_by_M524) { // abort SD print immediately + emergency_parser.sd_abort_by_M524 = false; + card.flag.abort_sd_printing = true; + gcode.process_subcommands_now(F("M524")); + } + #endif #endif if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) #if TEMP_SENSOR_IS_MAX_TC(0) - if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); - if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); + if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) maxtemp_error(H_E0); + if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) mintemp_error(H_E0); #endif #if TEMP_SENSOR_IS_MAX_TC(1) - 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); + if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) maxtemp_error(H_E1); + if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) mintemp_error(H_E1); + #endif + #if TEMP_SENSOR_IS_MAX_TC(2) + if (degHotend(2) > _MIN(HEATER_2_MAXTEMP, TEMP_SENSOR_2_MAX_TC_TMAX - 1.0)) maxtemp_error(H_E2); + if (degHotend(2) < _MAX(HEATER_2_MINTEMP, TEMP_SENSOR_2_MAX_TC_TMIN + .01)) mintemp_error(H_E2); #endif #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) - 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); + if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) maxtemp_error(H_REDUNDANT); + if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) mintemp_error(H_REDUNDANT); #endif #else #warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!" @@ -2161,6 +2189,15 @@ void Temperature::task() { case 2: #if TEMP_SENSOR_2_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_2, raw); + #elif TEMP_SENSOR_IS_MAX_TC(2) + #if TEMP_SENSOR_0_IS_MAX31865 + return TERN(LIB_INTERNAL_MAX31865, + max31865_2.temperature(raw), + max31865_2.temperature(MAX31865_SENSOR_OHMS_2, MAX31865_CALIBRATION_OHMS_2) + ); + #else + return (int16_t)raw * 0.25; + #endif #elif TEMP_SENSOR_2_IS_AD595 return TEMP_AD595(raw); #elif TEMP_SENSOR_2_IS_AD8495 @@ -2330,6 +2367,8 @@ void Temperature::task() { return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(raw), (int16_t)raw * 0.25); #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1) return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(raw), (int16_t)raw * 0.25); + #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2) + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_2.temperature(raw), (int16_t)raw * 0.25); #elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN); #elif TEMP_SENSOR_REDUNDANT_IS_AD595 @@ -2365,6 +2404,9 @@ void Temperature::updateTemperaturesFromRawValues() { #if TEMP_SENSOR_IS_MAX_TC(1) temp_hotend[1].setraw(READ_MAX_TC(1)); #endif + #if TEMP_SENSOR_IS_MAX_TC(2) + temp_hotend[2].setraw(READ_MAX_TC(2)); + #endif #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) temp_redundant.setraw(READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE))); #endif @@ -2384,7 +2426,7 @@ void Temperature::updateTemperaturesFromRawValues() { TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); #if HAS_HOTEND - static constexpr int8_t temp_dir[] = { + static constexpr int8_t temp_dir[HOTENDS] = { #if TEMP_SENSOR_IS_ANY_MAX_TC(0) 0 #else @@ -2396,53 +2438,64 @@ void Temperature::updateTemperaturesFromRawValues() { #else , TEMPDIR(1) #endif - #if HOTENDS > 2 - #define _TEMPDIR(N) , TEMPDIR(N) - REPEAT_S(2, HOTENDS, _TEMPDIR) + #endif + #if HOTENDS > 2 + #if TEMP_SENSOR_IS_ANY_MAX_TC(2) + , 0 + #else + , TEMPDIR(2) #endif #endif + #if HOTENDS > 3 + #define _TEMPDIR(N) , TEMPDIR(N) + REPEAT_S(3, HOTENDS, _TEMPDIR) + #endif }; - LOOP_L_N(e, COUNT(temp_dir)) { + HOTEND_LOOP() { const raw_adc_t r = temp_hotend[e].getraw(); const bool neg = temp_dir[e] < 0, pos = temp_dir[e] > 0; if ((neg && r < temp_range[e].raw_max) || (pos && r > temp_range[e].raw_max)) - max_temp_error((heater_id_t)e); + maxtemp_error((heater_id_t)e); + + /** + // DEBUG PREHEATING TIME + SERIAL_ECHOLNPGM("\nExtruder = ", e, " Preheat On/Off = ", is_preheating(e)); + const float test_is_preheating = (preheat_end_time[HOTEND_INDEX] - millis()) * 0.001f; + if (test_is_preheating < 31) SERIAL_ECHOLNPGM("Extruder = ", e, " Preheat remaining time = ", test_is_preheating, "s", "\n"); + //*/ const bool heater_on = temp_hotend[e].target > 0; - if (heater_on && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) { - #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 - if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) - #endif - min_temp_error((heater_id_t)e); + if (heater_on && !is_preheating(e) && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) { + if (TERN1(MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, ++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)) + mintemp_error((heater_id_t)e); + } + else { + TERN_(MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, consecutive_low_temperature_error[e] = 0); } - #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 - else - consecutive_low_temperature_error[e] = 0; - #endif } #endif // HAS_HOTEND #define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) #if ENABLED(THERMAL_PROTECTION_BED) - if (TP_CMP(BED, temp_bed.getraw(), maxtemp_raw_BED)) max_temp_error(H_BED); - if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) min_temp_error(H_BED); + if (TP_CMP(BED, temp_bed.getraw(), maxtemp_raw_BED)) maxtemp_error(H_BED); + if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) mintemp_error(H_BED); #endif #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) - if (TP_CMP(CHAMBER, temp_chamber.getraw(), maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); - if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw())) min_temp_error(H_CHAMBER); + if (TP_CMP(CHAMBER, temp_chamber.getraw(), maxtemp_raw_CHAMBER)) maxtemp_error(H_CHAMBER); + if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw())) mintemp_error(H_CHAMBER); #endif #if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) - if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.getraw(), maxtemp_raw_COOLER)) max_temp_error(H_COOLER); - if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.getraw())) min_temp_error(H_COOLER); + if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.getraw(), maxtemp_raw_COOLER)) maxtemp_error(H_COOLER); + if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.getraw())) mintemp_error(H_COOLER); #endif #if BOTH(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) - if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) max_temp_error(H_BOARD); - if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) min_temp_error(H_BOARD); + if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) maxtemp_error(H_BOARD); + if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) mintemp_error(H_BOARD); #endif #undef TP_CMP @@ -2481,6 +2534,9 @@ void Temperature::init() { #if TEMP_SENSOR_IS_ANY_MAX_TC(1) && PIN_EXISTS(TEMP_1_CS) OUT_WRITE(TEMP_1_CS_PIN, HIGH); #endif + #if TEMP_SENSOR_IS_ANY_MAX_TC(2) && PIN_EXISTS(TEMP_2_CS) + OUT_WRITE(TEMP_2_CS_PIN, HIGH); + #endif // Setup objects for library-based polling of MAX TCs #if HAS_MAXTC_LIBRARIES @@ -2508,6 +2564,18 @@ void Temperature::init() { OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1, MAX31865_WIRE_OHMS_1) ); #endif + + #if TEMP_SENSOR_IS_MAX(2, 6675) && HAS_MAX6675_LIBRARY + max6675_2.begin(); + #elif TEMP_SENSOR_IS_MAX(2, 31855) && HAS_MAX31855_LIBRARY + max31855_2.begin(); + #elif TEMP_SENSOR_IS_MAX(2, 31865) + max31865_2.begin( + MAX31865_WIRES(MAX31865_SENSOR_WIRES_2) // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_2, MAX31865_CALIBRATION_OHMS_2, MAX31865_WIRE_OHMS_2) + ); + #endif + #undef MAX31865_WIRES #undef _MAX31865_WIRES #endif @@ -2540,6 +2608,15 @@ void Temperature::init() { #endif )); #endif + #if PIN_EXISTS(TEMP_2_TR_ENABLE) + OUT_WRITE(TEMP_2_TR_ENABLE_PIN, ( + #if TEMP_SENSOR_IS_ANY_MAX_TC(2) + HIGH + #else + LOW + #endif + )); + #endif #if ENABLED(MPCTEMP) HOTEND_LOOP() temp_hotend[e].modeled_block_temp = NAN; @@ -2695,7 +2772,7 @@ void Temperature::init() { temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) - #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_##N > 0 && TEMP_SENSOR_##N != 998 && TEMP_SENSOR_##N != 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); @@ -3066,25 +3143,34 @@ void Temperature::disable_all_heaters() { // Needed to return the correct temp when this is called between readings static raw_adc_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 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) + #if MAX_TC_COUNT > 2 + #define THERMO_SEL(A,B,C) (hindex > 1 ? (C) : hindex == 1 ? (B) : (A)) + #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; case 2: WRITE(TEMP_2_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) + #elif MAX_TC_COUNT > 1 + #define THERMO_SEL(A,B,C) ( hindex == 1 ? (B) : (A)) + #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) + #endif #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_IS_ANY_MAX_TC(0) - #define THERMO_SEL(A,B) A + #define THERMO_SEL(A,B,C) A #define MAXTC_CS_WRITE(V) WRITE(TEMP_0_CS_PIN, V) - #else - #define THERMO_SEL(A,B) B + #elif TEMP_SENSOR_IS_ANY_MAX_TC(1) + #define THERMO_SEL(A,B,C) B #define MAXTC_CS_WRITE(V) WRITE(TEMP_1_CS_PIN, V) + #elif TEMP_SENSOR_IS_ANY_MAX_TC(2) + #define THERMO_SEL(A,B,C) C + #define MAXTC_CS_WRITE(V) WRITE(TEMP_2_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 + TEMP_SENSOR_1_MAX_TC_TMAX, + TEMP_SENSOR_2_MAX_TC_TMAX ); static uint8_t max_tc_errors[MAX_TC_COUNT] = { 0 }; @@ -3119,23 +3205,23 @@ void Temperature::disable_all_heaters() { MAXTC_CS_WRITE(HIGH); // Disable MAXTC #else #if HAS_MAX6675_LIBRARY - MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1); + MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1, max6675_2); max_tc_temp = max6675ref.readRaw16(); #endif #if HAS_MAX31855_LIBRARY - MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1); + MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1, max31855_2); max_tc_temp = max855ref.readRaw32(); #endif #if HAS_MAX31865 - MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1); + MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1, max31865_2); max_tc_temp = TERN(LIB_INTERNAL_MAX31865, max865ref.readRaw(), max865ref.readRTD_with_Fault()); #endif #endif // 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() + // Either way, return the TMAX for the thermocouple to trigger a maxtemp_error() if (max_tc_temp & MAX_TC_ERROR_MASK) { max_tc_errors[hindex]++; @@ -3174,7 +3260,7 @@ void Temperature::disable_all_heaters() { #endif // 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); + max_tc_temp = THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX, TEMP_SENSOR_2_MAX_TC_TMAX) << (MAX_TC_DISCARD_BITS + 1); } } else { @@ -3212,6 +3298,10 @@ void Temperature::update_raw_temperatures() { temp_hotend[1].update(); #endif + #if HAS_TEMP_ADC_2 && !TEMP_SENSOR_IS_MAX_TC(2) + temp_hotend[2].update(); + #endif + #if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_IS_MAX_TC(REDUNDANT) temp_redundant.update(); #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index f6cf81b8a966..17a608ce3335 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -60,53 +60,6 @@ typedef enum : int8_t { H_NONE = -128 } heater_id_t; -// PID storage -typedef struct { float Kp, Ki, Kd; } PID_t; -typedef struct { float Kp, Ki, Kd, Kc; } PIDC_t; -typedef struct { float Kp, Ki, Kd, Kf; } PIDF_t; -typedef struct { float Kp, Ki, Kd, Kc, Kf; } PIDCF_t; - -typedef - #if BOTH(PID_EXTRUSION_SCALING, PID_FAN_SCALING) - PIDCF_t - #elif ENABLED(PID_EXTRUSION_SCALING) - PIDC_t - #elif ENABLED(PID_FAN_SCALING) - PIDF_t - #else - PID_t - #endif -hotend_pid_t; - -#if ENABLED(PID_EXTRUSION_SCALING) - typedef IF<(LPQ_MAX_LEN > 255), uint16_t, uint8_t>::type lpq_ptr_t; -#endif - -#define PID_PARAM(F,H) _PID_##F(TERN(PID_PARAMS_PER_HOTEND, H, 0 & H)) // Always use 'H' to suppress warning -#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, NAN) -#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, NAN) -#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, NAN) -#if ENABLED(PIDTEMP) - #define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1) - #define _PID_Kf(H) TERN(PID_FAN_SCALING, Temperature::temp_hotend[H].pid.Kf, 0) -#else - #define _PID_Kc(H) 1 - #define _PID_Kf(H) 0 -#endif - -#if ENABLED(MPCTEMP) - typedef struct { - float heater_power; // M306 P - float block_heat_capacity; // M306 C - float sensor_responsiveness; // M306 R - float ambient_xfer_coeff_fan0; // M306 A - #if ENABLED(MPC_INCLUDE_FAN) - float fan255_adjustment; // M306 F - #endif - float filament_heat_capacity_permm; // M306 H - } MPC_t; -#endif - /** * States for ADC reading in the ISR */ @@ -188,7 +141,15 @@ enum ADCSensorState : char { #define ACTUAL_ADC_SAMPLES _MAX(int(MIN_ADC_ISR_LOOPS), int(SensorsReady)) +// +// PID +// + +typedef struct { float p, i, d; } raw_pid_t; +typedef struct { float p, i, d, c, f; } raw_pidcf_t; + #if HAS_PID_HEATING + #define PID_K2 (1-float(PID_K1)) #define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (TEMP_TIMER_FREQUENCY)) @@ -197,10 +158,116 @@ enum ADCSensorState : char { #define unscalePID_i(i) ( float(i) / PID_dT ) #define scalePID_d(d) ( float(d) / PID_dT ) #define unscalePID_d(d) ( float(d) * PID_dT ) + + typedef struct { + float Kp, Ki, Kd; + float p() const { return Kp; } + float i() const { return unscalePID_i(Ki); } + float d() const { return unscalePID_d(Kd); } + float c() const { return 1; } + float f() const { return 0; } + void set_Kp(float p) { Kp = p; } + void set_Ki(float i) { Ki = scalePID_i(i); } + void set_Kd(float d) { Kd = scalePID_d(d); } + void set_Kc(float) {} + void set_Kf(float) {} + void set(float p, float i, float d, float c=1, float f=0) { set_Kp(p); set_Ki(i); set_Kd(d); UNUSED(c); UNUSED(f); } + void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); } + void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d); } + } PID_t; + #endif -#if ENABLED(MPCTEMP) +#if ENABLED(PIDTEMP) + + typedef struct { + float Kp, Ki, Kd, Kc; + float p() const { return Kp; } + float i() const { return unscalePID_i(Ki); } + float d() const { return unscalePID_d(Kd); } + float c() const { return Kc; } + float f() const { return 0; } + void set_Kp(float p) { Kp = p; } + void set_Ki(float i) { Ki = scalePID_i(i); } + void set_Kd(float d) { Kd = scalePID_d(d); } + void set_Kc(float c) { Kc = c; } + void set_Kf(float) {} + void set(float p, float i, float d, float c=1, float f=0) { set_Kp(p); set_Ki(i); set_Kd(d); set_Kc(c); set_Kf(f); } + void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); } + void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d, raw.c); } + } PIDC_t; + + typedef struct { + float Kp, Ki, Kd, Kf; + float p() const { return Kp; } + float i() const { return unscalePID_i(Ki); } + float d() const { return unscalePID_d(Kd); } + float c() const { return 1; } + float f() const { return Kf; } + void set_Kp(float p) { Kp = p; } + void set_Ki(float i) { Ki = scalePID_i(i); } + void set_Kd(float d) { Kd = scalePID_d(d); } + void set_Kc(float) {} + void set_Kf(float f) { Kf = f; } + void set(float p, float i, float d, float c=1, float f=0) { set_Kp(p); set_Ki(i); set_Kd(d); set_Kf(f); } + void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); } + void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d, raw.f); } + } PIDF_t; + + typedef struct { + float Kp, Ki, Kd, Kc, Kf; + float p() const { return Kp; } + float i() const { return unscalePID_i(Ki); } + float d() const { return unscalePID_d(Kd); } + float c() const { return Kc; } + float f() const { return Kf; } + void set_Kp(float p) { Kp = p; } + void set_Ki(float i) { Ki = scalePID_i(i); } + void set_Kd(float d) { Kd = scalePID_d(d); } + void set_Kc(float c) { Kc = c; } + void set_Kf(float f) { Kf = f; } + void set(float p, float i, float d, float c=1, float f=0) { set_Kp(p); set_Ki(i); set_Kd(d); set_Kc(c); set_Kf(f); } + void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); } + void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d, raw.c, raw.f); } + } PIDCF_t; + + typedef + #if BOTH(PID_EXTRUSION_SCALING, PID_FAN_SCALING) + PIDCF_t + #elif ENABLED(PID_EXTRUSION_SCALING) + PIDC_t + #elif ENABLED(PID_FAN_SCALING) + PIDF_t + #else + PID_t + #endif + hotend_pid_t; + + #if ENABLED(PID_EXTRUSION_SCALING) + typedef IF<(LPQ_MAX_LEN > 255), uint16_t, uint8_t>::type lpq_ptr_t; + #endif + + #if ENABLED(PID_PARAMS_PER_HOTEND) + #define SET_HOTEND_PID(F,H,V) thermalManager.temp_hotend[H].pid.set_##F(V) + #else + #define SET_HOTEND_PID(F,_,V) do{ HOTEND_LOOP() thermalManager.temp_hotend[e].pid.set_##F(V); }while(0) + #endif + +#elif ENABLED(MPCTEMP) + + typedef struct { + float heater_power; // M306 P + float block_heat_capacity; // M306 C + float sensor_responsiveness; // M306 R + float ambient_xfer_coeff_fan0; // M306 A + #if ENABLED(MPC_INCLUDE_FAN) + float fan255_adjustment; // M306 F + #endif + float filament_heat_capacity_permm; // M306 H + } MPC_t; + #define MPC_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (TEMP_TIMER_FREQUENCY)) + #endif #if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) @@ -218,7 +285,7 @@ typedef struct TempInfo { inline void sample(const raw_adc_t s) { acc += s; } inline void update() { raw = acc; } void setraw(const raw_adc_t r) { raw = r; } - raw_adc_t getraw() { return raw; } + raw_adc_t getraw() const { return raw; } } temp_info_t; #if HAS_TEMP_REDUNDANT @@ -232,7 +299,8 @@ typedef struct TempInfo { typedef struct HeaterInfo : public TempInfo { celsius_t target; uint8_t soft_pwm_amount; - bool is_below_target(const celsius_t offs=0) const { return (celsius < (target + offs)); } + bool is_below_target(const celsius_t offs=0) const { return (target - celsius > offs); } // celsius < target - offs + bool is_above_target(const celsius_t offs=0) const { return (celsius - target > offs); } // celsius > target + offs } heater_info_t; // A heater with PID stabilization @@ -393,6 +461,7 @@ class Temperature { static const celsius_t hotend_maxtemp[HOTENDS]; static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif + #if HAS_HEATED_BED static bed_info_t temp_bed; #endif @@ -965,12 +1034,16 @@ class Temperature { static constexpr bool adaptive_fan_slowing = true; #endif - /** - * Update the temp manager when PID values change - */ + // Update the temp manager when PID values change #if ENABLED(PIDTEMP) - static void updatePID() { - TERN_(PID_EXTRUSION_SCALING, pes_e_position = 0); + static void updatePID() { TERN_(PID_EXTRUSION_SCALING, pes_e_position = 0); } + static void setPID(const uint8_t hotend, const_float_t p, const_float_t i, const_float_t d) { + #if ENABLED(PID_PARAMS_PER_HOTEND) + temp_hotend[hotend].pid.set(p, i, d); + #else + HOTEND_LOOP() temp_hotend[e].pid.set(p, i, d); + #endif + updatePID(); } #endif @@ -1063,8 +1136,8 @@ class Temperature { #endif static void _temp_error(const heater_id_t e, FSTR_P const serial_msg, FSTR_P const lcd_msg); - static void min_temp_error(const heater_id_t e); - static void max_temp_error(const heater_id_t e); + static void mintemp_error(const heater_id_t e); + static void maxtemp_error(const heater_id_t e); #define HAS_THERMAL_PROTECTION ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_COOLER) diff --git a/Marlin/src/module/thermistor/thermistor_1022.h b/Marlin/src/module/thermistor/thermistor_1022.h new file mode 100644 index 000000000000..1db928fbb86b --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_1022.h @@ -0,0 +1,45 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 REVERSE_TEMP_SENSOR_RANGE_1022 1 + +// Pt1000 with 1k0 pullup +constexpr temp_entry_t temptable_1022[] PROGMEM = { + PtLine( 0, 1000, 2200), + PtLine( 25, 1000, 2200), + PtLine( 50, 1000, 2200), + PtLine( 75, 1000, 2200), + PtLine(100, 1000, 2200), + PtLine(125, 1000, 2200), + PtLine(150, 1000, 2200), + PtLine(175, 1000, 2200), + PtLine(200, 1000, 2200), + PtLine(225, 1000, 2200), + PtLine(250, 1000, 2200), + PtLine(275, 1000, 2200), + PtLine(300, 1000, 2200), + PtLine(350, 1000, 2200), + PtLine(400, 1000, 2200), + PtLine(450, 1000, 2200), + PtLine(500, 1000, 2200) +}; diff --git a/Marlin/src/module/thermistor/thermistor_504.h b/Marlin/src/module/thermistor/thermistor_504.h index 61ce3ae1358c..751bea233e44 100644 --- a/Marlin/src/module/thermistor/thermistor_504.h +++ b/Marlin/src/module/thermistor/thermistor_504.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. - * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * 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 @@ -16,7 +16,7 @@ * 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 . + * along with this program. If not, see . * */ #pragma once diff --git a/Marlin/src/module/thermistor/thermistor_505.h b/Marlin/src/module/thermistor/thermistor_505.h index 6c94b0e1b456..12600f63ae9c 100644 --- a/Marlin/src/module/thermistor/thermistor_505.h +++ b/Marlin/src/module/thermistor/thermistor_505.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. - * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * 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 @@ -16,7 +16,7 @@ * 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 . + * along with this program. If not, see . * */ #pragma once diff --git a/Marlin/src/module/thermistor/thermistor_66.h b/Marlin/src/module/thermistor/thermistor_66.h index 07cb29767935..7c2455b7c652 100644 --- a/Marlin/src/module/thermistor/thermistor_66.h +++ b/Marlin/src/module/thermistor/thermistor_66.h @@ -21,7 +21,7 @@ */ #pragma once -// R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign 500 °C Thermistor +// R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign / Trianglelab T-D500 500 °C Thermistor constexpr temp_entry_t temptable_66[] PROGMEM = { { OV( 17.5), 850 }, { OV( 17.9), 500 }, diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index a38b7f381feb..c596d746f7fd 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -193,6 +193,9 @@ typedef struct { raw_adc_t value; celsius_t celsius; } temp_entry_t; #if ANY_THERMISTOR_IS(1010) // Pt1000 with 1k0 pullup #include "thermistor_1010.h" #endif +#if ANY_THERMISTOR_IS(1022) // Pt1000 with 2k2 pullup + #include "thermistor_1022.h" +#endif #if ANY_THERMISTOR_IS(1047) // Pt1000 with 4k7 pullup #include "thermistor_1047.h" #endif @@ -335,7 +338,7 @@ static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_ // For thermocouples the highest temperature results in the highest ADC value #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_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)) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index dbd95121dce0..7322098c0bb7 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -115,7 +115,8 @@ void move_extruder_servo(const uint8_t e) { planner.synchronize(); - if ((EXTRUDERS & 1) && e < EXTRUDERS - 1) { + constexpr bool evenExtruders = !(EXTRUDERS & 1); + if (evenExtruders || e < EXTRUDERS - 1) { servo[_SERVO_NR(e)].move(servo_angles[_SERVO_NR(e)][e & 1]); safe_delay(500); } @@ -440,6 +441,11 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. } } + +#endif // TOOL_SENSOR + +#if ENABLED(SWITCHING_TOOLHEAD) + inline void switching_toolhead_lock(const bool locked) { #ifdef SWITCHING_TOOLHEAD_SERVO_ANGLES const uint16_t swt_angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES; @@ -452,8 +458,6 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #endif } - #include - void swt_init() { switching_toolhead_lock(true); @@ -494,10 +498,6 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #endif // TOOL_SENSOR } -#endif // TOOL_SENSOR - -#if ENABLED(SWITCHING_TOOLHEAD) - inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (no_move) return; @@ -918,7 +918,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #if HAS_FAN && TOOLCHANGE_FS_FAN >= 0 thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed; gcode.dwell(SEC_TO_MS(toolchange_settings.fan_time)); - thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = 0; + thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = FAN_OFF_PWM; #endif } @@ -940,13 +940,13 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. * Cutting recovery -- Recover from cutting retraction that occurs at the end of nozzle priming * * If the active_extruder is up to temp (!too_cold): - * Extrude filament distance = toolchange_settings.extra_resume + TOOLCHANGE_FS_WIPE_RETRACT + * Extrude filament distance = toolchange_settings.extra_resume + toolchange_settings.wipe_retract * current_position.e = e; * sync_plan_position_e(); */ void extruder_cutting_recover(const_float_t e) { if (!too_cold(active_extruder)) { - const float dist = toolchange_settings.extra_resume + (TOOLCHANGE_FS_WIPE_RETRACT); + const float dist = toolchange_settings.extra_resume + toolchange_settings.wipe_retract; FS_DEBUG("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s"); unscaled_e_move(dist, MMM_TO_MMS(toolchange_settings.unretract_speed)); planner.synchronize(); @@ -973,17 +973,17 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. float fr = toolchange_settings.unretract_speed; // Set default speed for unretract #if ENABLED(TOOLCHANGE_FS_SLOW_FIRST_PRIME) - /* - * Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime - */ - static Flags extruder_did_first_prime; // Extruders first priming status - if (!extruder_did_first_prime[active_extruder]) { - extruder_did_first_prime.set(active_extruder); // Log first prime complete - // new nozzle - prime at user-specified speed. - FS_DEBUG("First time priming T", active_extruder, ", reducing speed from ", MMM_TO_MMS(fr), " to ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s"); - fr = toolchange_settings.prime_speed; - unscaled_e_move(0, MMM_TO_MMS(fr)); // Init planner with 0 length move - } + /** + * Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime + */ + static Flags extruder_did_first_prime; // Extruders first priming status + if (!extruder_did_first_prime[active_extruder]) { + extruder_did_first_prime.set(active_extruder); // Log first prime complete + // new nozzle - prime at user-specified speed. + FS_DEBUG("First time priming T", active_extruder, ", reducing speed from ", MMM_TO_MMS(fr), " to ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s"); + fr = toolchange_settings.prime_speed; + unscaled_e_move(0, MMM_TO_MMS(fr)); // Init planner with 0 length move + } #endif //Calculate and perform the priming distance @@ -1011,8 +1011,8 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. // Cutting retraction #if TOOLCHANGE_FS_WIPE_RETRACT - FS_DEBUG("Performing Cutting Retraction | Distance: ", -(TOOLCHANGE_FS_WIPE_RETRACT), " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s"); - unscaled_e_move(-(TOOLCHANGE_FS_WIPE_RETRACT), MMM_TO_MMS(toolchange_settings.retract_speed)); + FS_DEBUG("Performing Cutting Retraction | Distance: ", -toolchange_settings.wipe_retract, " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s"); + unscaled_e_move(-toolchange_settings.wipe_retract, MMM_TO_MMS(toolchange_settings.retract_speed)); #endif // Cool down with fan @@ -1157,8 +1157,8 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { const uint8_t old_tool = active_extruder; const bool can_move_away = !no_move && !idex_full_control; - #if HAS_LEVELING - // Set current position to the physical position + #if ENABLED(AUTO_BED_LEVELING_UBL) + // Workaround for UBL mesh boundary, possibly? TEMPORARY_BED_LEVELING_STATE(false); #endif diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index 864062f572e3..ff456485e23d 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -33,6 +33,7 @@ float extra_prime; // M217 E float extra_resume; // M217 B int16_t prime_speed; // M217 P + int16_t wipe_retract; // M217 G int16_t retract_speed; // M217 R int16_t unretract_speed; // M217 U uint8_t fan_speed; // M217 F diff --git a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h index 04210bb23440..37ce4ee94e56 100644 --- a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h +++ b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h @@ -166,12 +166,12 @@ #define LCD_BACKLIGHT_PIN -1 #if ENABLED(MKS_MINI_12864) - // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) #define DOGLCD_CS EXP1_06_PIN #define DOGLCD_A0 EXP1_07_PIN #define LCD_RESET_PIN -1 #elif ENABLED(FYSETC_MINI_12864_2_1) - // MKS_MINI_12864_V3, BTT_MINI_12864_V1, FYSETC_MINI_12864_2_1 + // MKS_MINI_12864_V3, BTT_MINI_12864_V1, FYSETC_MINI_12864_2_1 #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 EXP1_04_PIN #define LCD_RESET_PIN EXP1_05_PIN @@ -179,6 +179,9 @@ #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif + #if BOTH(MKS_MINI_12864_V3, SDSUPPORT) + #define PAUSE_LCD_FOR_BUSY_SD + #endif #else #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 9e2eedd68e80..3616b7a27c43 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -396,8 +396,8 @@ #define SD_DETECT_PIN 41 - #define HAS_SPI_FLASH 1 - #if HAS_SPI_FLASH + #define SPI_FLASH + #if ENABLED(SPI_FLASH) #define SPI_DEVICE 1 #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN 31 @@ -450,6 +450,19 @@ #ifndef TOUCH_OFFSET_Y #define TOUCH_OFFSET_Y 1 #endif + #elif ENABLED(TFT_RES_1024x600) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 65533 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 38399 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 2 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 1 + #endif #endif #endif diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h index 031a42f7989c..03994187c88f 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -323,6 +323,9 @@ #define BTN_EN1 EXP2_03_PIN #define BTN_ENC EXP1_02_PIN + #define BEEPER_PIN EXP1_01_PIN + #define SDCARD_CONNECTION ONBOARD + #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 @@ -423,6 +426,7 @@ #define DOGLCD_A0 EXP1_07_PIN #define DOGLCD_SCK EXP2_02_PIN #define DOGLCD_MOSI EXP2_06_PIN + #define FORCE_SOFT_SPI #elif ENABLED(ENDER2_STOCKDISPLAY) 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 209529cbe1ce..aac839808119 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -43,6 +43,7 @@ #if NO_EEPROM_SELECTED //#define I2C_EEPROM // EEPROM on I2C-0 //#define SDCARD_EEPROM_EMULATION + //#undef NO_EEPROM_SELECTED #endif #if ENABLED(I2C_EEPROM) diff --git a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h index f794e178f911..12a7934a3ead 100644 --- a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h @@ -131,12 +131,6 @@ #ifndef E0_AUTO_FAN_PIN #define E0_AUTO_FAN_PIN AUTO_FAN_PIN #endif -#ifndef E1_AUTO_FAN_PIN - #define E1_AUTO_FAN_PIN AUTO_FAN_PIN -#endif -#ifndef E2_AUTO_FAN_PIN - #define E2_AUTO_FAN_PIN AUTO_FAN_PIN -#endif // // SD Card diff --git a/Marlin/src/pins/mega/pins_EINSTART-S.h b/Marlin/src/pins/mega/pins_EINSTART-S.h index d42efe73617f..c8cbee674011 100644 --- a/Marlin/src/pins/mega/pins_EINSTART-S.h +++ b/Marlin/src/pins/mega/pins_EINSTART-S.h @@ -101,9 +101,9 @@ // LCD Display input pins // #define BTN_UP 25 -#define BTN_DWN 26 -#define BTN_LFT 27 -#define BTN_RT 28 +#define BTN_DOWN 26 +#define BTN_LEFT 27 +#define BTN_RIGHT 28 // 'OK' button #define BTN_ENC 29 diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index 3bcece400f96..cff3a11af16f 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -203,14 +203,13 @@ #define BTN_EN2 75 // J4, UP #define BTN_EN1 73 // J3, DOWN - //STOP button connected as KILL_PIN - #define KILL_PIN 14 // J1, RIGHT - //KILL - not connected + // STOP button connected as KILL_PIN + #define KILL_PIN 14 // J1, RIGHT (not connected) #define BEEPER_PIN 8 // H5, SD_WP - //on board leds - #define STAT_LED_RED_LED SERVO0_PIN // C1 (1280-EX1, DEBUG2) + // Onboard leds + #define STAT_LED_RED_PIN SERVO0_PIN // C1 (1280-EX1, DEBUG2) #define STAT_LED_BLUE_PIN SERVO1_PIN // C0 (1280-EX2, DEBUG3) #else @@ -220,9 +219,9 @@ #define SR_STROBE_PIN 33 // C4 #define BTN_UP 75 // J4 - #define BTN_DWN 73 // J3 - #define BTN_LFT 72 // J2 - #define BTN_RT 14 // J1 + #define BTN_DOWN 73 // J3 + #define BTN_LEFT 72 // J2 + #define BTN_RIGHT 14 // J1 // Disable encoder #undef BTN_EN1 diff --git a/Marlin/src/pins/mega/pins_OVERLORD.h b/Marlin/src/pins/mega/pins_OVERLORD.h index f1062b413e83..49accf9f7c4c 100644 --- a/Marlin/src/pins/mega/pins_OVERLORD.h +++ b/Marlin/src/pins/mega/pins_OVERLORD.h @@ -135,7 +135,7 @@ #if IS_NEWPANEL #define BTN_ENC 16 // Enter Pin #define BTN_UP 19 // Button UP Pin - #define BTN_DWN 17 // Button DOWN Pin + #define BTN_DOWN 17 // Button DOWN Pin #endif // Additional connectors/pins on the Overlord V1.X board diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index f38abdf875c4..584729a206dd 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -195,6 +195,8 @@ #include "ramps/pins_ORTUR_4.h" // ATmega2560 env:mega2560 #elif MB(TENLOG_D3_HERO) #include "ramps/pins_TENLOG_D3_HERO.h" // ATmega2560 env:mega2560 +#elif MB(TENLOG_MB1_V23) + #include "ramps/pins_TENLOG_MB1_V23.h" // ATmega2560 env:mega2560 #elif MB(MKS_GEN_L_V21) #include "ramps/pins_MKS_GEN_L_V21.h" // ATmega2560 env:mega2560 #elif MB(RAMPS_S_12_EEFB, RAMPS_S_12_EEEB, RAMPS_S_12_EFFB) @@ -232,7 +234,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 env:MightyBoard1280 env:MightyBoard2560 + #include "mega/pins_MIGHTYBOARD_REVE.h" // ATmega2560, ATmega1280 env:mega2560ext env:MightyBoard1280 env:MightyBoard2560 #elif MB(CHEAPTRONIC) #include "mega/pins_CHEAPTRONIC.h" // ATmega2560 env:mega2560 #elif MB(CHEAPTRONIC_V2) @@ -512,9 +514,9 @@ #elif MB(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 + #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano_v1v2_maple env:mks_robin_nano_v1v2_usbmod #elif MB(MKS_ROBIN_NANO_V2) - #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano35 env:mks_robin_nano35_maple + #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano_v1v2_maple #elif MB(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) @@ -531,6 +533,8 @@ #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 env:mks_robin_e3p_maple +#elif MB(BTT_EBB42_V1_1) + #include "stm32g0/pins_BTT_EBB42_V1_1.h" // STM32G0 env:BTT_EBB42_V1_1_filament_extruder #elif MB(BTT_SKR_MINI_V1_1) #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) @@ -541,6 +545,8 @@ #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_E3_V3_0) #include "stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h" // STM32G0 env:STM32G0B1RE_btt env:STM32G0B1RE_btt_xfer +#elif MB(BTT_SKR_MINI_E3_V3_0_1) + #include "stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h"// STM32F4 env:STM32F401RC_btt #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_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple #elif MB(BTT_SKR_E3_DIP) @@ -589,6 +595,8 @@ #include "stm32f1/pins_CREALITY_V24S1_301.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V25S1) #include "stm32f1/pins_CREALITY_V25S1.h" // STM32F1 env:STM32F103RE_creality_smartPro env:STM32F103RE_creality_smartPro_maple +#elif MB(CREALITY_V521) + #include "stm32f1/pins_CREALITY_V521.h" // STM32F103VE env:STM32F103VE_creality #elif MB(TRIGORILLA_PRO) #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro env:trigorilla_pro_maple env:trigorilla_pro_disk #elif MB(FLY_MINI) @@ -650,7 +658,7 @@ #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) - #include "stm32f4/pins_BTT_OCTOPUS_V1_1.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB + #include "stm32f4/pins_BTT_OCTOPUS_V1_1.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB env:BIGTREE_OCTOPUS_V1_F407 env:BIGTREE_OCTOPUS_V1_F407_USB #elif MB(BTT_OCTOPUS_PRO_V1_0) #include "stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB env:BIGTREE_OCTOPUS_PRO_V1_F429 env:BIGTREE_OCTOPUS_PRO_V1_F429_USB #elif MB(LERDGE_K) @@ -694,15 +702,23 @@ #elif MB(OPULO_LUMEN_REV3) #include "stm32f4/pins_OPULO_LUMEN_REV3.h" // STM32F4 env:Opulo_Lumen_REV3 #elif MB(MKS_ROBIN_NANO_V1_3_F4) - #include "stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h" // STM32F4 env:mks_robin_nano_v1_3_f4 + #include "stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h" // STM32F4 env:mks_robin_nano_v1_3_f4 env:mks_robin_nano_v1_3_f4_usbmod #elif MB(MKS_EAGLE) #include "stm32f4/pins_MKS_EAGLE.h" // STM32F4 env:mks_eagle #elif MB(ARTILLERY_RUBY) #include "stm32f4/pins_ARTILLERY_RUBY.h" // STM32F4 env:Artillery_Ruby #elif MB(CREALITY_V24S1_301F4) #include "stm32f4/pins_CREALITY_V24S1_301F4.h" // STM32F4 env:STM32F401RC_creality env:STM32F401RC_creality_jlink env:STM32F401RC_creality_stlink -#elif MB(MKS_E3D_V2) +#elif MB(MKS_E3D_V2) #include "stm32f4/pins_MKS_E3_V2.h" // STM32F4 env:MKS_E3_V2 +#elif MB(OPULO_LUMEN_REV4) + #include "stm32f4/pins_OPULO_LUMEN_REV4.h" // STM32F4 env:Opulo_Lumen_REV4 +#elif MB(FYSETC_SPIDER_KING407) + #include "stm32f4/pins_FYSETC_SPIDER_KING407.h" // STM32F4 env:FYSETC_SPIDER_KING407 +#elif MB(MKS_SKIPR_V1) + #include "stm32f4/pins_MKS_SKIPR_V1_0.h" // STM32F4 env:mks_skipr_v1 env:mks_skipr_v1_nobootloader +#elif MB(TRONXY_V10) + #include "stm32f4/pins_TRONXY_V10.h" // STM32F4 env:STM32F446_tronxy // // ARM Cortex M7 @@ -761,6 +777,13 @@ #elif MB(BRICOLEMON_LITE_V1_0) #include "samd/pins_BRICOLEMON_LITE_V1_0.h" // SAMD51 env:SAMD51_grandcentral_m4 +// +// ReprapWorld Minitronics (SAMD21) +// + +#elif MB(MINITRONICS20) + #include "samd/pins_MINITRONICS20.h" // SAMD21 env:SAMD21_minitronics20 + // // Custom board (with custom PIO env) // diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index b662f09ba9ef..5b19ff1b2d0d 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -45,23 +45,23 @@ #define REPORT_NAME_ANALOG(COUNTER, NAME) _ADD_PIN(#NAME, COUNTER) #include "pinsDebug_list.h" -#line 48 +#line 49 // manually add pins that have names that are macros which don't play well with these macros #if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768) - #if CONF_SERIAL_IS(0) + #if SERIAL_IN_USE(0) static const char RXD_NAME_0[] PROGMEM = { "RXD0" }; static const char TXD_NAME_0[] PROGMEM = { "TXD0" }; #endif - #if CONF_SERIAL_IS(1) + #if SERIAL_IN_USE(1) static const char RXD_NAME_1[] PROGMEM = { "RXD1" }; static const char TXD_NAME_1[] PROGMEM = { "TXD1" }; #endif - #if CONF_SERIAL_IS(2) + #if SERIAL_IN_USE(2) static const char RXD_NAME_2[] PROGMEM = { "RXD2" }; static const char TXD_NAME_2[] PROGMEM = { "TXD2" }; #endif - #if CONF_SERIAL_IS(3) + #if SERIAL_IN_USE(3) static const char RXD_NAME_3[] PROGMEM = { "RXD3" }; static const char TXD_NAME_3[] PROGMEM = { "TXD3" }; #endif @@ -99,7 +99,7 @@ const PinInfo pin_array[] PROGMEM = { * 2 bytes containing the digital/analog bool flag */ - #if CONF_SERIAL_IS(0) + #if SERIAL_IN_USE(0) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_0, 0, true }, { TXD_NAME_0, 1, true }, @@ -112,7 +112,7 @@ const PinInfo pin_array[] PROGMEM = { #endif #endif - #if CONF_SERIAL_IS(1) + #if SERIAL_IN_USE(1) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_1, 19, true }, { TXD_NAME_1, 18, true }, @@ -130,7 +130,7 @@ const PinInfo pin_array[] PROGMEM = { #endif #endif - #if CONF_SERIAL_IS(2) + #if SERIAL_IN_USE(2) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, @@ -145,7 +145,7 @@ const PinInfo pin_array[] PROGMEM = { #endif #endif - #if CONF_SERIAL_IS(3) + #if SERIAL_IN_USE(3) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, @@ -164,7 +164,7 @@ const PinInfo pin_array[] PROGMEM = { #endif #include "pinsDebug_list.h" - #line 167 + #line 168 }; diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 034e4adf1b66..39e07c739a23 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -41,8 +41,8 @@ #if _EXISTS(EXT_AUX_A0) #if ANALOG_OK(EXT_AUX_A0) - REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) -#endif + REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) + #endif #endif #if _EXISTS(EXT_AUX_A1) #if ANALOG_OK(EXT_AUX_A0) @@ -87,8 +87,8 @@ #if !defined(ARDUINO_ARCH_SAM) && !defined(ARDUINO_ARCH_SAMD) // TC1 & TC2 are macros in the SAM/SAMD tool chain #if _EXISTS(TC1) #if ANALOG_OK(TC1) - REPORT_NAME_ANALOG(__LINE__, TC1) - #endif + REPORT_NAME_ANALOG(__LINE__, TC1) + #endif #endif #if _EXISTS(TC2) #if ANALOG_OK(TC1) @@ -98,8 +98,8 @@ #endif #if PIN_EXISTS(TEMP_0) #if ANALOG_OK(TEMP_0_PIN) - REPORT_NAME_ANALOG(__LINE__, TEMP_0_PIN) - #endif + REPORT_NAME_ANALOG(__LINE__, TEMP_0_PIN) + #endif #endif #if PIN_EXISTS(TEMP_1) #if ANALOG_OK(TEMP_1_PIN) @@ -183,6 +183,10 @@ #if _EXISTS(__GS) REPORT_NAME_DIGITAL(__LINE__, __GS) #endif + +// +// SPI on AVR +// #if PIN_EXISTS(AVR_MISO) REPORT_NAME_DIGITAL(__LINE__, AVR_MISO_PIN) #endif @@ -192,27 +196,29 @@ #if PIN_EXISTS(AVR_SCK) REPORT_NAME_DIGITAL(__LINE__, AVR_SCK_PIN) #endif -#if PIN_EXISTS(ALARM) - REPORT_NAME_DIGITAL(__LINE__, ALARM_PIN) -#endif #if PIN_EXISTS(AVR_SS) REPORT_NAME_DIGITAL(__LINE__, AVR_SS_PIN) #endif + +// +// Sound +// #if PIN_EXISTS(BEEPER) REPORT_NAME_DIGITAL(__LINE__, BEEPER_PIN) #endif +#if PIN_EXISTS(ALARM) + REPORT_NAME_DIGITAL(__LINE__, ALARM_PIN) +#endif + +// +// Digital Encoder / Keypad +// #if _EXISTS(BTN_BACK) REPORT_NAME_DIGITAL(__LINE__, BTN_BACK) #endif #if _EXISTS(BTN_CENTER) REPORT_NAME_DIGITAL(__LINE__, BTN_CENTER) #endif -#if _EXISTS(BTN_DOWN) - REPORT_NAME_DIGITAL(__LINE__, BTN_DOWN) -#endif -#if _EXISTS(BTN_DWN) - REPORT_NAME_DIGITAL(__LINE__, BTN_DWN) -#endif #if _EXISTS(BTN_EN1) REPORT_NAME_DIGITAL(__LINE__, BTN_EN1) #endif @@ -228,21 +234,22 @@ #if _EXISTS(BTN_HOME) REPORT_NAME_DIGITAL(__LINE__, BTN_HOME) #endif +#if _EXISTS(BTN_UP) + REPORT_NAME_DIGITAL(__LINE__, BTN_UP) +#endif +#if _EXISTS(BTN_DOWN) + REPORT_NAME_DIGITAL(__LINE__, BTN_DOWN) +#endif #if _EXISTS(BTN_LEFT) REPORT_NAME_DIGITAL(__LINE__, BTN_LEFT) #endif -#if _EXISTS(BTN_LFT) - REPORT_NAME_DIGITAL(__LINE__, BTN_LFT) -#endif #if _EXISTS(BTN_RIGHT) REPORT_NAME_DIGITAL(__LINE__, BTN_RIGHT) #endif -#if _EXISTS(BTN_RT) - REPORT_NAME_DIGITAL(__LINE__, BTN_RT) -#endif -#if _EXISTS(BTN_UP) - REPORT_NAME_DIGITAL(__LINE__, BTN_UP) -#endif + +// +// Joystick +// #if PIN_EXISTS(JOY_X) REPORT_NAME_DIGITAL(__LINE__, JOY_X_PIN) #endif @@ -255,6 +262,10 @@ #if PIN_EXISTS(JOY_EN) REPORT_NAME_DIGITAL(__LINE__, JOY_EN_PIN) #endif + +// +// Custom Buttons +// #if PIN_EXISTS(BUTTON1) REPORT_NAME_DIGITAL(__LINE__, BUTTON1_PIN) #endif @@ -330,33 +341,32 @@ #if PIN_EXISTS(BUTTON25) REPORT_NAME_DIGITAL(__LINE__, BUTTON25_PIN) #endif + #if PIN_EXISTS(CASE_LIGHT) REPORT_NAME_DIGITAL(__LINE__, CASE_LIGHT_PIN) #endif -#if PIN_EXISTS(CHAMBER_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, CHAMBER_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(CONTROLLER_FAN) - REPORT_NAME_DIGITAL(__LINE__, CONTROLLER_FAN_PIN) -#endif + #if PIN_EXISTS(COOLANT_FLOOD) REPORT_NAME_DIGITAL(__LINE__, COOLANT_FLOOD_PIN) #endif #if PIN_EXISTS(COOLANT_MIST) REPORT_NAME_DIGITAL(__LINE__, COOLANT_MIST_PIN) #endif + #if PIN_EXISTS(CUTOFF_RESET) REPORT_NAME_DIGITAL(__LINE__, CUTOFF_RESET_PIN) #endif #if PIN_EXISTS(CUTOFF_TEST) REPORT_NAME_DIGITAL(__LINE__, CUTOFF_TEST_PIN) #endif + #if _EXISTS(D57) REPORT_NAME_DIGITAL(__LINE__, D57) #endif #if _EXISTS(D58) REPORT_NAME_DIGITAL(__LINE__, D58) #endif + #if PIN_EXISTS(DAC_DISABLE) REPORT_NAME_DIGITAL(__LINE__, DAC_DISABLE_PIN) #endif @@ -366,9 +376,7 @@ #if PIN_EXISTS(DAC1_SYNC) REPORT_NAME_DIGITAL(__LINE__, DAC1_SYNC_PIN) #endif -#if PIN_EXISTS(DEBUG) - REPORT_NAME_DIGITAL(__LINE__, DEBUG_PIN) -#endif + #if _EXISTS(DIGIPOTS_I2C_SCL) REPORT_NAME_DIGITAL(__LINE__, DIGIPOTS_I2C_SCL) #endif @@ -390,21 +398,97 @@ #if PIN_EXISTS(DIGIPOTSS) REPORT_NAME_DIGITAL(__LINE__, DIGIPOTSS_PIN) #endif -#if PIN_EXISTS(LCD_RESET) - REPORT_NAME_DIGITAL(__LINE__, LCD_RESET_PIN) +#if PIN_EXISTS(EXP1_01) + REPORT_NAME_DIGITAL(__LINE__, EXP1_01_PIN) #endif -#if _EXISTS(DOGLCD_A0) - REPORT_NAME_DIGITAL(__LINE__, DOGLCD_A0) +#if PIN_EXISTS(EXP1_02) + REPORT_NAME_DIGITAL(__LINE__, EXP1_02_PIN) #endif -#if _EXISTS(DOGLCD_CS) - REPORT_NAME_DIGITAL(__LINE__, DOGLCD_CS) +#if PIN_EXISTS(EXP1_03) + REPORT_NAME_DIGITAL(__LINE__, EXP1_03_PIN) #endif -#if _EXISTS(DOGLCD_MOSI) - REPORT_NAME_DIGITAL(__LINE__, DOGLCD_MOSI) +#if PIN_EXISTS(EXP1_04) + REPORT_NAME_DIGITAL(__LINE__, EXP1_04_PIN) #endif -#if _EXISTS(DOGLCD_SCK) - REPORT_NAME_DIGITAL(__LINE__, DOGLCD_SCK) +#if PIN_EXISTS(EXP1_05) + REPORT_NAME_DIGITAL(__LINE__, EXP1_05_PIN) +#endif +#if PIN_EXISTS(EXP1_06) + REPORT_NAME_DIGITAL(__LINE__, EXP1_06_PIN) +#endif +#if PIN_EXISTS(EXP1_07) + REPORT_NAME_DIGITAL(__LINE__, EXP1_07_PIN) +#endif +#if PIN_EXISTS(EXP1_08) + REPORT_NAME_DIGITAL(__LINE__, EXP1_08_PIN) +#endif +#if PIN_EXISTS(EXP1_09) + REPORT_NAME_DIGITAL(__LINE__, EXP1_09_PIN) +#endif +#if PIN_EXISTS(EXP1_10) + REPORT_NAME_DIGITAL(__LINE__, EXP1_10_PIN) +#endif +#if PIN_EXISTS(EXP2_01) + REPORT_NAME_DIGITAL(__LINE__, EXP2_01_PIN) +#endif +#if PIN_EXISTS(EXP2_02) + REPORT_NAME_DIGITAL(__LINE__, EXP2_02_PIN) +#endif +#if PIN_EXISTS(EXP2_03) + REPORT_NAME_DIGITAL(__LINE__, EXP2_03_PIN) +#endif +#if PIN_EXISTS(EXP2_04) + REPORT_NAME_DIGITAL(__LINE__, EXP2_04_PIN) +#endif +#if PIN_EXISTS(EXP2_05) + REPORT_NAME_DIGITAL(__LINE__, EXP2_05_PIN) +#endif +#if PIN_EXISTS(EXP2_06) + REPORT_NAME_DIGITAL(__LINE__, EXP2_06_PIN) #endif +#if PIN_EXISTS(EXP2_07) + REPORT_NAME_DIGITAL(__LINE__, EXP2_07_PIN) +#endif +#if PIN_EXISTS(EXP2_08) + REPORT_NAME_DIGITAL(__LINE__, EXP2_08_PIN) +#endif +#if PIN_EXISTS(EXP2_09) + REPORT_NAME_DIGITAL(__LINE__, EXP2_09_PIN) +#endif +#if PIN_EXISTS(EXP2_10) + REPORT_NAME_DIGITAL(__LINE__, EXP2_10_PIN) +#endif +#if PIN_EXISTS(EXP3_01) + REPORT_NAME_DIGITAL(__LINE__, EXP3_01_PIN) +#endif +#if PIN_EXISTS(EXP3_02) + REPORT_NAME_DIGITAL(__LINE__, EXP3_02_PIN) +#endif +#if PIN_EXISTS(EXP3_03) + REPORT_NAME_DIGITAL(__LINE__, EXP3_03_PIN) +#endif +#if PIN_EXISTS(EXP3_04) + REPORT_NAME_DIGITAL(__LINE__, EXP3_04_PIN) +#endif +#if PIN_EXISTS(EXP3_05) + REPORT_NAME_DIGITAL(__LINE__, EXP3_05_PIN) +#endif +#if PIN_EXISTS(EXP3_06) + REPORT_NAME_DIGITAL(__LINE__, EXP3_06_PIN) +#endif +#if PIN_EXISTS(EXP3_07) + REPORT_NAME_DIGITAL(__LINE__, EXP3_07_PIN) +#endif +#if PIN_EXISTS(EXP3_08) + REPORT_NAME_DIGITAL(__LINE__, EXP3_08_PIN) +#endif +#if PIN_EXISTS(EXP3_09) + REPORT_NAME_DIGITAL(__LINE__, EXP3_09_PIN) +#endif +#if PIN_EXISTS(EXP3_10) + REPORT_NAME_DIGITAL(__LINE__, EXP3_10_PIN) +#endif + #if _EXISTS(TMC_SW_MISO) REPORT_NAME_DIGITAL(__LINE__, TMC_SW_MISO) #endif @@ -417,6 +501,10 @@ #if _EXISTS(TFTGLCD_CS) REPORT_NAME_DIGITAL(__LINE__, TFTGLCD_CS) #endif + +// +// E Multiplexing +// #if PIN_EXISTS(E_MUX0) REPORT_NAME_DIGITAL(__LINE__, E_MUX0_PIN) #endif @@ -426,230 +514,155 @@ #if PIN_EXISTS(E_MUX2) REPORT_NAME_DIGITAL(__LINE__, E_MUX2_PIN) #endif -#if PIN_EXISTS(E_STOP) - REPORT_NAME_DIGITAL(__LINE__, E_STOP_PIN) -#endif -#if PIN_EXISTS(E0_ATT) - REPORT_NAME_DIGITAL(__LINE__, E0_ATT_PIN) -#endif -#if PIN_EXISTS(E0_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E0_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E0_CS) - REPORT_NAME_DIGITAL(__LINE__, E0_CS_PIN) -#endif + #if PIN_EXISTS(E0_DIR) REPORT_NAME_DIGITAL(__LINE__, E0_DIR_PIN) #endif #if PIN_EXISTS(E0_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E0_ENABLE_PIN) #endif -#if PIN_EXISTS(E0_MS1) - REPORT_NAME_DIGITAL(__LINE__, E0_MS1_PIN) -#endif -#if PIN_EXISTS(E0_MS2) - REPORT_NAME_DIGITAL(__LINE__, E0_MS2_PIN) -#endif -#if PIN_EXISTS(E0_MS3) - REPORT_NAME_DIGITAL(__LINE__, E0_MS3_PIN) -#endif #if PIN_EXISTS(E0_STEP) REPORT_NAME_DIGITAL(__LINE__, E0_STEP_PIN) #endif -#if PIN_EXISTS(E0_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E0_STDBY_PIN) -#endif -#if PIN_EXISTS(E1_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E1_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E1_CS) - REPORT_NAME_DIGITAL(__LINE__, E1_CS_PIN) -#endif #if PIN_EXISTS(E1_DIR) REPORT_NAME_DIGITAL(__LINE__, E1_DIR_PIN) #endif #if PIN_EXISTS(E1_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E1_ENABLE_PIN) #endif -#if PIN_EXISTS(E1_MS1) - REPORT_NAME_DIGITAL(__LINE__, E1_MS1_PIN) -#endif -#if PIN_EXISTS(E1_MS2) - REPORT_NAME_DIGITAL(__LINE__, E1_MS2_PIN) -#endif -#if PIN_EXISTS(E1_MS3) - REPORT_NAME_DIGITAL(__LINE__, E1_MS3_PIN) -#endif #if PIN_EXISTS(E1_STEP) REPORT_NAME_DIGITAL(__LINE__, E1_STEP_PIN) #endif -#if PIN_EXISTS(E1_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E1_STDBY_PIN) -#endif -#if PIN_EXISTS(E2_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E2_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E2_CS) - REPORT_NAME_DIGITAL(__LINE__, E2_CS_PIN) -#endif #if PIN_EXISTS(E2_DIR) REPORT_NAME_DIGITAL(__LINE__, E2_DIR_PIN) #endif #if PIN_EXISTS(E2_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E2_ENABLE_PIN) #endif -#if PIN_EXISTS(E2_MS1) - REPORT_NAME_DIGITAL(__LINE__, E2_MS1_PIN) -#endif -#if PIN_EXISTS(E2_MS2) - REPORT_NAME_DIGITAL(__LINE__, E2_MS2_PIN) -#endif -#if PIN_EXISTS(E2_MS3) - REPORT_NAME_DIGITAL(__LINE__, E2_MS3_PIN) -#endif #if PIN_EXISTS(E2_STEP) REPORT_NAME_DIGITAL(__LINE__, E2_STEP_PIN) #endif -#if PIN_EXISTS(E2_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E2_STDBY_PIN) -#endif -#if PIN_EXISTS(E3_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E3_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E3_CS) - REPORT_NAME_DIGITAL(__LINE__, E3_CS_PIN) -#endif #if PIN_EXISTS(E3_DIR) REPORT_NAME_DIGITAL(__LINE__, E3_DIR_PIN) #endif #if PIN_EXISTS(E3_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E3_ENABLE_PIN) #endif -#if PIN_EXISTS(E3_MS1) - REPORT_NAME_DIGITAL(__LINE__, E3_MS1_PIN) -#endif -#if PIN_EXISTS(E3_MS2) - REPORT_NAME_DIGITAL(__LINE__, E3_MS2_PIN) -#endif -#if PIN_EXISTS(E3_MS3) - REPORT_NAME_DIGITAL(__LINE__, E3_MS3_PIN) -#endif #if PIN_EXISTS(E3_STEP) REPORT_NAME_DIGITAL(__LINE__, E3_STEP_PIN) #endif -#if PIN_EXISTS(E3_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E3_STDBY_PIN) -#endif -#if PIN_EXISTS(E4_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E4_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E4_CS) - REPORT_NAME_DIGITAL(__LINE__, E4_CS_PIN) -#endif #if PIN_EXISTS(E4_DIR) REPORT_NAME_DIGITAL(__LINE__, E4_DIR_PIN) #endif #if PIN_EXISTS(E4_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E4_ENABLE_PIN) #endif -#if PIN_EXISTS(E4_MS1) - REPORT_NAME_DIGITAL(__LINE__, E4_MS1_PIN) -#endif -#if PIN_EXISTS(E4_MS2) - REPORT_NAME_DIGITAL(__LINE__, E4_MS2_PIN) -#endif -#if PIN_EXISTS(E4_MS3) - REPORT_NAME_DIGITAL(__LINE__, E4_MS3_PIN) -#endif #if PIN_EXISTS(E4_STEP) REPORT_NAME_DIGITAL(__LINE__, E4_STEP_PIN) #endif -#if PIN_EXISTS(E4_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E4_STDBY_PIN) -#endif -#if PIN_EXISTS(E5_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E5_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E5_CS) - REPORT_NAME_DIGITAL(__LINE__, E5_CS_PIN) -#endif #if PIN_EXISTS(E5_DIR) REPORT_NAME_DIGITAL(__LINE__, E5_DIR_PIN) #endif #if PIN_EXISTS(E5_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E5_ENABLE_PIN) #endif -#if PIN_EXISTS(E5_MS1) - REPORT_NAME_DIGITAL(__LINE__, E5_MS1_PIN) -#endif -#if PIN_EXISTS(E5_MS2) - REPORT_NAME_DIGITAL(__LINE__, E5_MS2_PIN) -#endif -#if PIN_EXISTS(E5_MS3) - REPORT_NAME_DIGITAL(__LINE__, E5_MS3_PIN) -#endif #if PIN_EXISTS(E5_STEP) REPORT_NAME_DIGITAL(__LINE__, E5_STEP_PIN) #endif -#if PIN_EXISTS(E5_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E5_STDBY_PIN) -#endif -#if PIN_EXISTS(E6_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E6_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E6_CS) - REPORT_NAME_DIGITAL(__LINE__, E6_CS_PIN) -#endif #if PIN_EXISTS(E6_DIR) REPORT_NAME_DIGITAL(__LINE__, E6_DIR_PIN) #endif #if PIN_EXISTS(E6_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E6_ENABLE_PIN) #endif -#if PIN_EXISTS(E6_MS1) - REPORT_NAME_DIGITAL(__LINE__, E6_MS1_PIN) -#endif -#if PIN_EXISTS(E6_MS2) - REPORT_NAME_DIGITAL(__LINE__, E6_MS2_PIN) -#endif -#if PIN_EXISTS(E6_MS3) - REPORT_NAME_DIGITAL(__LINE__, E6_MS3_PIN) -#endif #if PIN_EXISTS(E6_STEP) REPORT_NAME_DIGITAL(__LINE__, E6_STEP_PIN) #endif -#if PIN_EXISTS(E6_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E6_STDBY_PIN) -#endif -#if PIN_EXISTS(E7_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E7_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E7_CS) - REPORT_NAME_DIGITAL(__LINE__, E7_CS_PIN) -#endif #if PIN_EXISTS(E7_DIR) REPORT_NAME_DIGITAL(__LINE__, E7_DIR_PIN) #endif #if PIN_EXISTS(E7_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E7_ENABLE_PIN) #endif -#if PIN_EXISTS(E7_MS1) - REPORT_NAME_DIGITAL(__LINE__, E7_MS1_PIN) -#endif -#if PIN_EXISTS(E7_MS2) - REPORT_NAME_DIGITAL(__LINE__, E7_MS2_PIN) -#endif -#if PIN_EXISTS(E7_MS3) - REPORT_NAME_DIGITAL(__LINE__, E7_MS3_PIN) -#endif #if PIN_EXISTS(E7_STEP) REPORT_NAME_DIGITAL(__LINE__, E7_STEP_PIN) #endif -#if PIN_EXISTS(E7_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E7_STDBY_PIN) -#endif -#if _EXISTS(ENET_CRS) - REPORT_NAME_DIGITAL(__LINE__, ENET_CRS) + +// +// Stepper Select +// +#if PIN_EXISTS(X_CS) + REPORT_NAME_DIGITAL(__LINE__, X_CS_PIN) +#endif +#if PIN_EXISTS(X2_CS) + REPORT_NAME_DIGITAL(__LINE__, X2_CS_PIN) +#endif +#if PIN_EXISTS(Y_CS) + REPORT_NAME_DIGITAL(__LINE__, Y_CS_PIN) +#endif +#if PIN_EXISTS(Y2_CS) + REPORT_NAME_DIGITAL(__LINE__, Y2_CS_PIN) +#endif +#if PIN_EXISTS(Z_CS) + REPORT_NAME_DIGITAL(__LINE__, Z_CS_PIN) +#endif +#if PIN_EXISTS(Z2_CS) + REPORT_NAME_DIGITAL(__LINE__, Z2_CS_PIN) +#endif +#if PIN_EXISTS(Z3_CS) + REPORT_NAME_DIGITAL(__LINE__, Z3_CS_PIN) +#endif +#if PIN_EXISTS(Z4_CS) + REPORT_NAME_DIGITAL(__LINE__, Z4_CS_PIN) +#endif +#if PIN_EXISTS(I_CS) + REPORT_NAME_DIGITAL(__LINE__, I_CS_PIN) +#endif +#if PIN_EXISTS(J_CS) + REPORT_NAME_DIGITAL(__LINE__, J_CS_PIN) +#endif +#if PIN_EXISTS(K_CS) + REPORT_NAME_DIGITAL(__LINE__, K_CS_PIN) +#endif +#if PIN_EXISTS(U_CS) + REPORT_NAME_DIGITAL(__LINE__, U_CS_PIN) +#endif +#if PIN_EXISTS(V_CS) + REPORT_NAME_DIGITAL(__LINE__, V_CS_PIN) +#endif +#if PIN_EXISTS(W_CS) + REPORT_NAME_DIGITAL(__LINE__, W_CS_PIN) +#endif +#if PIN_EXISTS(E0_CS) + REPORT_NAME_DIGITAL(__LINE__, E0_CS_PIN) +#endif +#if PIN_EXISTS(E1_CS) + REPORT_NAME_DIGITAL(__LINE__, E1_CS_PIN) +#endif +#if PIN_EXISTS(E2_CS) + REPORT_NAME_DIGITAL(__LINE__, E2_CS_PIN) +#endif +#if PIN_EXISTS(E3_CS) + REPORT_NAME_DIGITAL(__LINE__, E3_CS_PIN) +#endif +#if PIN_EXISTS(E4_CS) + REPORT_NAME_DIGITAL(__LINE__, E4_CS_PIN) +#endif +#if PIN_EXISTS(E5_CS) + REPORT_NAME_DIGITAL(__LINE__, E5_CS_PIN) +#endif +#if PIN_EXISTS(E6_CS) + REPORT_NAME_DIGITAL(__LINE__, E6_CS_PIN) +#endif +#if PIN_EXISTS(E7_CS) + REPORT_NAME_DIGITAL(__LINE__, E7_CS_PIN) +#endif + +// +// Ethernet +// +#if _EXISTS(ENET_CRS) + REPORT_NAME_DIGITAL(__LINE__, ENET_CRS) #endif #if _EXISTS(ENET_MDIO) REPORT_NAME_DIGITAL(__LINE__, ENET_MDIO) @@ -675,6 +688,10 @@ #if _EXISTS(ENET_TXD1) REPORT_NAME_DIGITAL(__LINE__, ENET_TXD1) #endif +#if _EXISTS(REF_CLK) + REPORT_NAME_DIGITAL(__LINE__, REF_CLK) +#endif + #if PIN_EXISTS(EXP_VOLTAGE_LEVEL) REPORT_NAME_DIGITAL(__LINE__, EXP_VOLTAGE_LEVEL_PIN) #endif @@ -709,12 +726,10 @@ #if _EXISTS(EXT_AUX_TX1_D3) REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_TX1_D3) #endif -#if _EXISTS(EXTRUDER_0_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, EXTRUDER_0_AUTO_FAN) -#endif -#if _EXISTS(EXTRUDER_1_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, EXTRUDER_1_AUTO_FAN) -#endif + +// +// Fans +// #if PIN_EXISTS(FAN) REPORT_NAME_DIGITAL(__LINE__, FAN_PIN) #endif @@ -748,12 +763,40 @@ #if PIN_EXISTS(FAN_MUX2) REPORT_NAME_DIGITAL(__LINE__, FAN_MUX2_PIN) #endif -#if PIN_EXISTS(POWER_LOSS) - REPORT_NAME_DIGITAL(__LINE__, POWER_LOSS_PIN) +#if PIN_EXISTS(E0_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E0_AUTO_FAN_PIN) #endif -#if PIN_EXISTS(SAFE_POWER) - REPORT_NAME_DIGITAL(__LINE__, SAFE_POWER_PIN) +#if PIN_EXISTS(E1_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E1_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E2_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E2_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E3_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E3_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E4_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E4_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E5_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E5_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E6_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E6_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E7_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E7_AUTO_FAN_PIN) #endif +#if PIN_EXISTS(CHAMBER_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, CHAMBER_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(CONTROLLER_FAN) + REPORT_NAME_DIGITAL(__LINE__, CONTROLLER_FAN_PIN) +#endif + +// +// Filament Runout Sensor +// #if PIN_EXISTS(FIL_RUNOUT) REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT_PIN) #endif @@ -778,6 +821,10 @@ #if PIN_EXISTS(FIL_RUNOUT8) REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT8_PIN) #endif + +// +// Heaters +// #if PIN_EXISTS(HEATER_0) REPORT_NAME_DIGITAL(__LINE__, HEATER_0_PIN) #endif @@ -811,23 +858,55 @@ #if PIN_EXISTS(COOLER) REPORT_NAME_DIGITAL(__LINE__, COOLER_PIN) #endif + #if PIN_EXISTS(HOME) REPORT_NAME_DIGITAL(__LINE__, HOME_PIN) #endif -#if PIN_EXISTS(I2C_SCL) - REPORT_NAME_DIGITAL(__LINE__, I2C_SCL_PIN) -#endif -#if PIN_EXISTS(I2C_SDA) - REPORT_NAME_DIGITAL(__LINE__, I2C_SDA_PIN) -#endif #if HAS_KILL REPORT_NAME_DIGITAL(__LINE__, KILL_PIN) #endif #if PIN_EXISTS(FREEZE) REPORT_NAME_DIGITAL(__LINE__, FREEZE_PIN) #endif -#if PIN_EXISTS(LCD_BACKLIGHT) - REPORT_NAME_DIGITAL(__LINE__, LCD_BACKLIGHT_PIN) +#if PIN_EXISTS(DEBUG) + REPORT_NAME_DIGITAL(__LINE__, DEBUG_PIN) +#endif +#if PIN_EXISTS(SUICIDE) + REPORT_NAME_DIGITAL(__LINE__, SUICIDE_PIN) +#endif +#if PIN_EXISTS(FET_SAFETY) + REPORT_NAME_DIGITAL(__LINE__, FET_SAFETY_PIN) +#endif +#if PIN_EXISTS(SAFETY_TRIGGERED) + REPORT_NAME_DIGITAL(__LINE__, SAFETY_TRIGGERED_PIN) +#endif +#if PIN_EXISTS(SAFE_POWER) + REPORT_NAME_DIGITAL(__LINE__, SAFE_POWER_PIN) +#endif +#if PIN_EXISTS(OUTAGECON) + REPORT_NAME_DIGITAL(__LINE__, OUTAGECON_PIN) +#endif +#if PIN_EXISTS(POWER_LOSS) + REPORT_NAME_DIGITAL(__LINE__, POWER_LOSS_PIN) +#endif +#if PIN_EXISTS(PS_ON) + REPORT_NAME_DIGITAL(__LINE__, PS_ON_PIN) +#endif + +// +// LCD +// +#if _EXISTS(DOGLCD_A0) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_A0) +#endif +#if _EXISTS(DOGLCD_CS) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_CS) +#endif +#if _EXISTS(DOGLCD_MOSI) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_MOSI) +#endif +#if _EXISTS(DOGLCD_SCK) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_SCK) #endif #if _EXISTS(LCD_PINS_D4) REPORT_NAME_DIGITAL(__LINE__, LCD_PINS_D4) @@ -850,9 +929,16 @@ #if _EXISTS(LCD_SDSS) REPORT_NAME_DIGITAL(__LINE__, LCD_SDSS) #endif -#if PIN_EXISTS(LED_GREEN) - REPORT_NAME_DIGITAL(__LINE__, LED_GREEN_PIN) +#if PIN_EXISTS(LCD_RESET) + REPORT_NAME_DIGITAL(__LINE__, LCD_RESET_PIN) +#endif +#if PIN_EXISTS(LCD_BACKLIGHT) + REPORT_NAME_DIGITAL(__LINE__, LCD_BACKLIGHT_PIN) #endif + +// +// LED Lights +// #if PIN_EXISTS(LED) REPORT_NAME_DIGITAL(__LINE__, LED_PIN) #endif @@ -865,9 +951,50 @@ #if PIN_EXISTS(LED4) REPORT_NAME_DIGITAL(__LINE__, LED4_PIN) #endif +#if PIN_EXISTS(LED_GREEN) + REPORT_NAME_DIGITAL(__LINE__, LED_GREEN_PIN) +#endif #if PIN_EXISTS(LED_RED) REPORT_NAME_DIGITAL(__LINE__, LED_RED_PIN) #endif +#if PIN_EXISTS(STAT_LED_BLUE) + REPORT_NAME_DIGITAL(__LINE__, STAT_LED_BLUE_PIN) +#endif +#if PIN_EXISTS(STAT_LED_RED) + REPORT_NAME_DIGITAL(__LINE__, STAT_LED_RED_PIN) +#endif +#if PIN_EXISTS(RGB_LED_R) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_R_PIN) +#endif +#if PIN_EXISTS(RGB_LED_G) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_G_PIN) +#endif +#if PIN_EXISTS(RGB_LED_B) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_B_PIN) +#endif +#if PIN_EXISTS(RGB_LED_W) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_W_PIN) +#endif +#if PIN_EXISTS(NEOPIXEL) + REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL_PIN) +#endif +#if PIN_EXISTS(NEOPIXEL2) + REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL2_PIN) +#endif + +// +// MAX7219 LED Matrix +// +#if PIN_EXISTS(MAX7219_CLK) + REPORT_NAME_DIGITAL(__LINE__, MAX7219_CLK_PIN) +#endif +#if PIN_EXISTS(MAX7219_DIN) + REPORT_NAME_DIGITAL(__LINE__, MAX7219_DIN_PIN) +#endif +#if PIN_EXISTS(MAX7219_LOAD) + REPORT_NAME_DIGITAL(__LINE__, MAX7219_LOAD_PIN) +#endif + #if PIN_EXISTS(TEMP_0_CS) REPORT_NAME_DIGITAL(__LINE__, TEMP_0_CS_PIN) #endif @@ -892,22 +1019,10 @@ #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) -#endif -#if PIN_EXISTS(MAX7219_DIN) - REPORT_NAME_DIGITAL(__LINE__, MAX7219_DIN_PIN) -#endif -#if PIN_EXISTS(MAX7219_LOAD) - REPORT_NAME_DIGITAL(__LINE__, MAX7219_LOAD_PIN) -#endif -//#if _EXISTS(MISO) -// REPORT_NAME_DIGITAL(__LINE__, MISO) -//#endif -#if PIN_EXISTS(MISO) - REPORT_NAME_DIGITAL(__LINE__, SD_MISO_PIN) -#endif +// +// MOSFETs (RAMPS) +// #if PIN_EXISTS(MOSFET_A) REPORT_NAME_DIGITAL(__LINE__, MOSFET_A_PIN) #endif @@ -920,108 +1035,139 @@ #if PIN_EXISTS(MOSFET_D) REPORT_NAME_DIGITAL(__LINE__, MOSFET_D_PIN) #endif + +// +// I2C +// + +//#if _EXISTS(SCL) +// REPORT_NAME_DIGITAL(__LINE__, SCL) +//#endif +#if PIN_EXISTS(I2C_SCL) + REPORT_NAME_DIGITAL(__LINE__, I2C_SCL_PIN) +#endif +//#if _EXISTS(SDA) +// REPORT_NAME_DIGITAL(__LINE__, SDA) +//#endif +#if PIN_EXISTS(I2C_SDA) + REPORT_NAME_DIGITAL(__LINE__, I2C_SDA_PIN) +#endif + +// +// SPI / SD Card +// + +//#if _EXISTS(MISO) +// REPORT_NAME_DIGITAL(__LINE__, MISO) +//#endif +#if PIN_EXISTS(SD_MISO) + REPORT_NAME_DIGITAL(__LINE__, SD_MISO_PIN) +#endif //#if _EXISTS(MOSI) // REPORT_NAME_DIGITAL(__LINE__, MOSI) //#endif -#if PIN_EXISTS(MOSI) +#if PIN_EXISTS(SD_MOSI) REPORT_NAME_DIGITAL(__LINE__, SD_MOSI_PIN) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_E) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E_PIN) -#endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E0_PIN) +//#if _EXISTS(SCK) +// REPORT_NAME_DIGITAL(__LINE__, SCK) +//#endif +#if PIN_EXISTS(SD_SCK) + REPORT_NAME_DIGITAL(__LINE__, SD_SCK_PIN) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E1_PIN) +#if _EXISTS(SDSS) + REPORT_NAME_DIGITAL(__LINE__, SDSS) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_X) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_X_PIN) +#if PIN_EXISTS(SD_SS) + REPORT_NAME_DIGITAL(__LINE__, SD_SS_PIN) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Y_PIN) +#if PIN_EXISTS(SD_DETECT) + REPORT_NAME_DIGITAL(__LINE__, SD_DETECT_PIN) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_XY_PIN) +#if PIN_EXISTS(SDPOWER) + REPORT_NAME_DIGITAL(__LINE__, SDPOWER_PIN) #endif + +// +// Motor Current PWM +// #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_X_PIN) #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Y_PIN) #endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_XY_PIN) +#endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Z_PIN) #endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_I) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_I_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_J) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_J_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_K) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_K_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_U) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_U_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_V) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_V_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_W) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_W_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E0_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E1_PIN) +#endif #if PIN_EXISTS(MOTOR_FAULT) REPORT_NAME_DIGITAL(__LINE__, MOTOR_FAULT_PIN) #endif -#if PIN_EXISTS(PHOTOGRAPH) - REPORT_NAME_DIGITAL(__LINE__, PHOTOGRAPH_PIN) + +#if PIN_EXISTS(SLED) + REPORT_NAME_DIGITAL(__LINE__, SLED_PIN) #endif + +// +// Camera +// #if PIN_EXISTS(CHDK) REPORT_NAME_DIGITAL(__LINE__, CHDK_PIN) #endif -#if PIN_EXISTS(PS_ON) - REPORT_NAME_DIGITAL(__LINE__, PS_ON_PIN) +#if PIN_EXISTS(PHOTOGRAPH) + REPORT_NAME_DIGITAL(__LINE__, PHOTOGRAPH_PIN) #endif + #if PIN_EXISTS(PWM_1) REPORT_NAME_DIGITAL(__LINE__, PWM_1_PIN) #endif #if PIN_EXISTS(PWM_2) REPORT_NAME_DIGITAL(__LINE__, PWM_2_PIN) #endif -#if _EXISTS(REF_CLK) - REPORT_NAME_DIGITAL(__LINE__, REF_CLK) -#endif -#if PIN_EXISTS(NEOPIXEL) - REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL_PIN) -#endif -#if PIN_EXISTS(NEOPIXEL2) - REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL2_PIN) -#endif -#if PIN_EXISTS(RGB_LED_R) - REPORT_NAME_DIGITAL(__LINE__, RGB_LED_R_PIN) -#endif -#if PIN_EXISTS(RGB_LED_G) - REPORT_NAME_DIGITAL(__LINE__, RGB_LED_G_PIN) -#endif -#if PIN_EXISTS(RGB_LED_B) - REPORT_NAME_DIGITAL(__LINE__, RGB_LED_B_PIN) -#endif -#if PIN_EXISTS(RGB_LED_W) - REPORT_NAME_DIGITAL(__LINE__, RGB_LED_W_PIN) -#endif + +// +// Serial UART +// #if PIN_EXISTS(RX_ENABLE) REPORT_NAME_DIGITAL(__LINE__, RX_ENABLE_PIN) #endif -#if PIN_EXISTS(SAFETY_TRIGGERED) - REPORT_NAME_DIGITAL(__LINE__, SAFETY_TRIGGERED_PIN) -#endif -//#if _EXISTS(SCK) -// REPORT_NAME_DIGITAL(__LINE__, SCK) -//#endif -#if PIN_EXISTS(SCK) - REPORT_NAME_DIGITAL(__LINE__, SD_SCK_PIN) -#endif -//#if _EXISTS(SCL) -// REPORT_NAME_DIGITAL(__LINE__, SCL) -//#endif -#if PIN_EXISTS(SD_DETECT) - REPORT_NAME_DIGITAL(__LINE__, SD_DETECT_PIN) +#if PIN_EXISTS(TX_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, TX_ENABLE_PIN) #endif -//#if _EXISTS(SDA) -// REPORT_NAME_DIGITAL(__LINE__, SDA) + +//#if _EXISTS(SERVO0) +// REPORT_NAME_DIGITAL(__LINE__, SERVO0) //#endif -#if PIN_EXISTS(SDPOWER) - REPORT_NAME_DIGITAL(__LINE__, SDPOWER_PIN) -#endif -#if _EXISTS(SDSS) - REPORT_NAME_DIGITAL(__LINE__, SDSS) -#endif -#if _EXISTS(SERVO0) - REPORT_NAME_DIGITAL(__LINE__, SERVO0) -#endif #if PIN_EXISTS(SERVO0) REPORT_NAME_DIGITAL(__LINE__, SERVO0_PIN) #endif @@ -1034,6 +1180,7 @@ #if PIN_EXISTS(SERVO3) REPORT_NAME_DIGITAL(__LINE__, SERVO3_PIN) #endif + #if PIN_EXISTS(SHIFT_CLK) REPORT_NAME_DIGITAL(__LINE__, SHIFT_CLK_PIN) #endif @@ -1046,9 +1193,7 @@ #if PIN_EXISTS(SHIFT_OUT) REPORT_NAME_DIGITAL(__LINE__, SHIFT_OUT_PIN) #endif -#if PIN_EXISTS(SLED) - REPORT_NAME_DIGITAL(__LINE__, SLED_PIN) -#endif + #if PIN_EXISTS(SLEEP_WAKE) REPORT_NAME_DIGITAL(__LINE__, SLEEP_WAKE_PIN) #endif @@ -1076,9 +1221,11 @@ #if PIN_EXISTS(SOL7) REPORT_NAME_DIGITAL(__LINE__, SOL7_PIN) #endif + #if _EXISTS(SPARE_IO) REPORT_NAME_DIGITAL(__LINE__, SPARE_IO) #endif + #if PIN_EXISTS(SPI_EEPROM1_CS) REPORT_NAME_DIGITAL(__LINE__, SPI_EEPROM1_CS_PIN) #endif @@ -1088,6 +1235,7 @@ #if PIN_EXISTS(SPI_FLASH_CS) REPORT_NAME_DIGITAL(__LINE__, SPI_FLASH_CS_PIN) #endif + #if PIN_EXISTS(SPINDLE_DIR) REPORT_NAME_DIGITAL(__LINE__, SPINDLE_DIR_PIN) #endif @@ -1100,6 +1248,7 @@ #if PIN_EXISTS(SPINDLE_LASER_PWM) REPORT_NAME_DIGITAL(__LINE__, SPINDLE_LASER_PWM_PIN) #endif + #if PIN_EXISTS(SR_CLK) REPORT_NAME_DIGITAL(__LINE__, SR_CLK_PIN) #endif @@ -1109,24 +1258,10 @@ #if PIN_EXISTS(SR_STROBE) REPORT_NAME_DIGITAL(__LINE__, SR_STROBE_PIN) #endif -#if PIN_EXISTS(SS) - REPORT_NAME_DIGITAL(__LINE__, SD_SS_PIN) -#endif -#if PIN_EXISTS(STAT_LED_BLUE) - REPORT_NAME_DIGITAL(__LINE__, STAT_LED_BLUE_PIN) -#endif -#if _EXISTS(STAT_LED_RED_LED) - REPORT_NAME_DIGITAL(__LINE__, STAT_LED_RED_LED) -#endif -#if PIN_EXISTS(STAT_LED_RED) - REPORT_NAME_DIGITAL(__LINE__, STAT_LED_RED_PIN) -#endif + #if PIN_EXISTS(STEPPER_RESET) REPORT_NAME_DIGITAL(__LINE__, STEPPER_RESET_PIN) #endif -#if PIN_EXISTS(SUICIDE) - REPORT_NAME_DIGITAL(__LINE__, SUICIDE_PIN) -#endif #if PIN_EXISTS(TLC_BLANK) REPORT_NAME_DIGITAL(__LINE__, TLC_BLANK_PIN) #endif @@ -1139,6 +1274,13 @@ #if PIN_EXISTS(TLC_XLAT) REPORT_NAME_DIGITAL(__LINE__, TLC_XLAT_PIN) #endif + +// +// Generic Tool / PWM +// +#if PIN_EXISTS(TOOL_PWM) + REPORT_NAME_DIGITAL(__LINE__, TOOL_PWM_PIN) +#endif #if PIN_EXISTS(TOOL_0) REPORT_NAME_DIGITAL(__LINE__, TOOL_0_PIN) #endif @@ -1163,279 +1305,250 @@ #if PIN_EXISTS(TOOL_3_PWM) REPORT_NAME_DIGITAL(__LINE__, TOOL_3_PWM_PIN) #endif -#if PIN_EXISTS(TOOL_PWM) - REPORT_NAME_DIGITAL(__LINE__, TOOL_PWM_PIN) + +// +// Tool Sensors +// +#if PIN_EXISTS(TOOL_SENSOR1) + REPORT_NAME_DIGITAL(__LINE__, TOOL_SENSOR1_PIN) #endif -#if PIN_EXISTS(TX_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, TX_ENABLE_PIN) +#if PIN_EXISTS(TOOL_SENSOR2) + REPORT_NAME_DIGITAL(__LINE__, TOOL_SENSOR2_PIN) #endif +#if PIN_EXISTS(TOOL_SENSOR3) + REPORT_NAME_DIGITAL(__LINE__, TOOL_SENSOR3_PIN) +#endif + +// +// UI +// #if _EXISTS(UI1) REPORT_NAME_DIGITAL(__LINE__, UI1) #endif #if _EXISTS(UI2) REPORT_NAME_DIGITAL(__LINE__, UI2) #endif -#if _EXISTS(UNUSED_PWM) - REPORT_NAME_DIGITAL(__LINE__, UNUSED_PWM) -#endif -#if PIN_EXISTS(X_ATT) - REPORT_NAME_DIGITAL(__LINE__, X_ATT_PIN) -#endif -#if PIN_EXISTS(X_CS) - REPORT_NAME_DIGITAL(__LINE__, X_CS_PIN) -#endif -#if PIN_EXISTS(X_DIR) - REPORT_NAME_DIGITAL(__LINE__, X_DIR_PIN) -#endif -#if PIN_EXISTS(X_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, X_ENABLE_PIN) -#endif + +// +// Limit Switches +// #if PIN_EXISTS(X_MAX) REPORT_NAME_DIGITAL(__LINE__, X_MAX_PIN) #endif #if PIN_EXISTS(X_MIN) REPORT_NAME_DIGITAL(__LINE__, X_MIN_PIN) #endif -#if PIN_EXISTS(X_DIAG) - REPORT_NAME_DIGITAL(__LINE__, X_DIAG_PIN) -#endif -#if PIN_EXISTS(X_MS1) - REPORT_NAME_DIGITAL(__LINE__, X_MS1_PIN) -#endif -#if PIN_EXISTS(X_MS2) - REPORT_NAME_DIGITAL(__LINE__, X_MS2_PIN) -#endif -#if PIN_EXISTS(X_MS3) - REPORT_NAME_DIGITAL(__LINE__, X_MS3_PIN) -#endif -#if PIN_EXISTS(X_STEP) - REPORT_NAME_DIGITAL(__LINE__, X_STEP_PIN) -#endif -#if PIN_EXISTS(X_STDBY) - REPORT_NAME_DIGITAL(__LINE__, X_STDBY_PIN) -#endif #if PIN_EXISTS(X_STOP) REPORT_NAME_DIGITAL(__LINE__, X_STOP_PIN) #endif -#if PIN_EXISTS(X2_CS) - REPORT_NAME_DIGITAL(__LINE__, X2_CS_PIN) -#endif -#if PIN_EXISTS(X2_DIR) - REPORT_NAME_DIGITAL(__LINE__, X2_DIR_PIN) -#endif -#if PIN_EXISTS(X2_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, X2_ENABLE_PIN) -#endif + #if PIN_EXISTS(X2_MAX) REPORT_NAME_DIGITAL(__LINE__, X2_MAX_PIN) #endif #if PIN_EXISTS(X2_MIN) REPORT_NAME_DIGITAL(__LINE__, X2_MIN_PIN) #endif -#if PIN_EXISTS(X2_MS1) - REPORT_NAME_DIGITAL(__LINE__, X2_MS1_PIN) -#endif -#if PIN_EXISTS(X2_MS2) - REPORT_NAME_DIGITAL(__LINE__, X2_MS2_PIN) -#endif -#if PIN_EXISTS(X2_MS3) - REPORT_NAME_DIGITAL(__LINE__, X2_MS3_PIN) -#endif -#if PIN_EXISTS(X2_STEP) - REPORT_NAME_DIGITAL(__LINE__, X2_STEP_PIN) -#endif -#if PIN_EXISTS(Y_ATT) - REPORT_NAME_DIGITAL(__LINE__, Y_ATT_PIN) -#endif -#if PIN_EXISTS(Y_CS) - REPORT_NAME_DIGITAL(__LINE__, Y_CS_PIN) -#endif -#if PIN_EXISTS(Y_DIR) - REPORT_NAME_DIGITAL(__LINE__, Y_DIR_PIN) -#endif -#if PIN_EXISTS(Y_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Y_ENABLE_PIN) +#if PIN_EXISTS(X2_STOP) + REPORT_NAME_DIGITAL(__LINE__, X2_STOP_PIN) #endif + #if PIN_EXISTS(Y_MAX) REPORT_NAME_DIGITAL(__LINE__, Y_MAX_PIN) #endif #if PIN_EXISTS(Y_MIN) REPORT_NAME_DIGITAL(__LINE__, Y_MIN_PIN) #endif -#if PIN_EXISTS(Y_DIAG) - REPORT_NAME_DIGITAL(__LINE__, Y_DIAG_PIN) -#endif -#if PIN_EXISTS(Y_MS1) - REPORT_NAME_DIGITAL(__LINE__, Y_MS1_PIN) -#endif -#if PIN_EXISTS(Y_MS2) - REPORT_NAME_DIGITAL(__LINE__, Y_MS2_PIN) -#endif -#if PIN_EXISTS(Y_MS3) - REPORT_NAME_DIGITAL(__LINE__, Y_MS3_PIN) -#endif -#if PIN_EXISTS(Y_STEP) - REPORT_NAME_DIGITAL(__LINE__, Y_STEP_PIN) -#endif -#if PIN_EXISTS(Y_STDBY) - REPORT_NAME_DIGITAL(__LINE__, Y_STDBY_PIN) -#endif #if PIN_EXISTS(Y_STOP) REPORT_NAME_DIGITAL(__LINE__, Y_STOP_PIN) #endif -#if PIN_EXISTS(Y2_CS) - REPORT_NAME_DIGITAL(__LINE__, Y2_CS_PIN) -#endif -#if PIN_EXISTS(Y2_DIR) - REPORT_NAME_DIGITAL(__LINE__, Y2_DIR_PIN) -#endif -#if PIN_EXISTS(Y2_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Y2_ENABLE_PIN) -#endif + #if PIN_EXISTS(Y2_MAX) REPORT_NAME_DIGITAL(__LINE__, Y2_MAX_PIN) #endif #if PIN_EXISTS(Y2_MIN) REPORT_NAME_DIGITAL(__LINE__, Y2_MIN_PIN) #endif -#if PIN_EXISTS(Y2_MS1) - REPORT_NAME_DIGITAL(__LINE__, Y2_MS1_PIN) +#if PIN_EXISTS(Y2_STOP) + REPORT_NAME_DIGITAL(__LINE__, Y2_STOP_PIN) #endif -#if PIN_EXISTS(Y2_MS2) - REPORT_NAME_DIGITAL(__LINE__, Y2_MS2_PIN) + +#if PIN_EXISTS(Z_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z_MAX_PIN) #endif -#if PIN_EXISTS(Y2_MS3) - REPORT_NAME_DIGITAL(__LINE__, Y2_MS3_PIN) +#if PIN_EXISTS(Z_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PIN) #endif -#if PIN_EXISTS(Y2_STEP) - REPORT_NAME_DIGITAL(__LINE__, Y2_STEP_PIN) +#if PIN_EXISTS(Z_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z_STOP_PIN) #endif -#if PIN_EXISTS(Z_ATT) - REPORT_NAME_DIGITAL(__LINE__, Z_ATT_PIN) + +#if PIN_EXISTS(Z2_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z2_MAX_PIN) #endif -#if PIN_EXISTS(Z_CS) - REPORT_NAME_DIGITAL(__LINE__, Z_CS_PIN) +#if PIN_EXISTS(Z2_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z2_MIN_PIN) #endif -#if PIN_EXISTS(Z_DIR) - REPORT_NAME_DIGITAL(__LINE__, Z_DIR_PIN) +#if PIN_EXISTS(Z2_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z2_STOP_PIN) #endif -#if PIN_EXISTS(Z_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Z_ENABLE_PIN) + +#if PIN_EXISTS(Z3_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z3_MAX_PIN) #endif -#if PIN_EXISTS(Z_MAX) - REPORT_NAME_DIGITAL(__LINE__, Z_MAX_PIN) +#if PIN_EXISTS(Z3_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z3_MIN_PIN) #endif -#if PIN_EXISTS(Z_MIN) - REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PIN) +#if PIN_EXISTS(Z3_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z3_STOP_PIN) #endif -#if PIN_EXISTS(Z_DIAG) - REPORT_NAME_DIGITAL(__LINE__, Z_DIAG_PIN) + +#if PIN_EXISTS(Z4_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z4_MAX_PIN) #endif -#if PIN_EXISTS(Z_MS1) - REPORT_NAME_DIGITAL(__LINE__, Z_MS1_PIN) +#if PIN_EXISTS(Z4_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z4_MIN_PIN) #endif -#if PIN_EXISTS(Z_MS2) - REPORT_NAME_DIGITAL(__LINE__, Z_MS2_PIN) +#if PIN_EXISTS(Z4_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z4_STOP_PIN) #endif -#if PIN_EXISTS(Z_MS3) - REPORT_NAME_DIGITAL(__LINE__, Z_MS3_PIN) + +#if PIN_EXISTS(I_MAX) + REPORT_NAME_DIGITAL(__LINE__, I_MAX_PIN) #endif -#if PIN_EXISTS(Z_STEP) - REPORT_NAME_DIGITAL(__LINE__, Z_STEP_PIN) +#if PIN_EXISTS(I_MIN) + REPORT_NAME_DIGITAL(__LINE__, I_MIN_PIN) #endif -#if PIN_EXISTS(Z_STDBY) - REPORT_NAME_DIGITAL(__LINE__, Z_STDBY_PIN) +#if PIN_EXISTS(I_STOP) + REPORT_NAME_DIGITAL(__LINE__, I_STOP_PIN) #endif -#if PIN_EXISTS(Z_STOP) - REPORT_NAME_DIGITAL(__LINE__, Z_STOP_PIN) + +#if PIN_EXISTS(J_MAX) + REPORT_NAME_DIGITAL(__LINE__, J_MAX_PIN) #endif -#if PIN_EXISTS(Z2_CS) - REPORT_NAME_DIGITAL(__LINE__, Z2_CS_PIN) +#if PIN_EXISTS(J_MIN) + REPORT_NAME_DIGITAL(__LINE__, J_MIN_PIN) #endif -#if PIN_EXISTS(Z2_DIR) - REPORT_NAME_DIGITAL(__LINE__, Z2_DIR_PIN) +#if PIN_EXISTS(J_STOP) + REPORT_NAME_DIGITAL(__LINE__, J_STOP_PIN) #endif -#if PIN_EXISTS(Z2_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Z2_ENABLE_PIN) + +#if PIN_EXISTS(K_MAX) + REPORT_NAME_DIGITAL(__LINE__, K_MAX_PIN) #endif -#if PIN_EXISTS(Z2_MAX) - REPORT_NAME_DIGITAL(__LINE__, Z2_MAX_PIN) +#if PIN_EXISTS(K_MIN) + REPORT_NAME_DIGITAL(__LINE__, K_MIN_PIN) #endif -#if PIN_EXISTS(Z2_MIN) - REPORT_NAME_DIGITAL(__LINE__, Z2_MIN_PIN) +#if PIN_EXISTS(K_STOP) + REPORT_NAME_DIGITAL(__LINE__, K_STOP_PIN) #endif -#if PIN_EXISTS(Z2_DIAG) - REPORT_NAME_DIGITAL(__LINE__, Z2_DIAG_PIN) + +#if PIN_EXISTS(U_MAX) + REPORT_NAME_DIGITAL(__LINE__, U_MAX_PIN) #endif -#if PIN_EXISTS(Z2_MS1) - REPORT_NAME_DIGITAL(__LINE__, Z2_MS1_PIN) +#if PIN_EXISTS(U_MIN) + REPORT_NAME_DIGITAL(__LINE__, U_MIN_PIN) #endif -#if PIN_EXISTS(Z2_MS2) - REPORT_NAME_DIGITAL(__LINE__, Z2_MS2_PIN) +#if PIN_EXISTS(U_STOP) + REPORT_NAME_DIGITAL(__LINE__, U_STOP_PIN) #endif -#if PIN_EXISTS(Z2_MS3) - REPORT_NAME_DIGITAL(__LINE__, Z2_MS3_PIN) + +#if PIN_EXISTS(V_MAX) + REPORT_NAME_DIGITAL(__LINE__, V_MAX_PIN) #endif -#if PIN_EXISTS(Z2_STEP) - REPORT_NAME_DIGITAL(__LINE__, Z2_STEP_PIN) +#if PIN_EXISTS(V_MIN) + REPORT_NAME_DIGITAL(__LINE__, V_MIN_PIN) #endif -#if PIN_EXISTS(Z2_STOP) - REPORT_NAME_DIGITAL(__LINE__, Z2_STOP_PIN) +#if PIN_EXISTS(V_STOP) + REPORT_NAME_DIGITAL(__LINE__, V_STOP_PIN) #endif -#if PIN_EXISTS(Z3_CS) - REPORT_NAME_DIGITAL(__LINE__, Z3_CS_PIN) + +#if PIN_EXISTS(W_MAX) + REPORT_NAME_DIGITAL(__LINE__, W_MAX_PIN) #endif -#if PIN_EXISTS(Z3_DIR) - REPORT_NAME_DIGITAL(__LINE__, Z3_DIR_PIN) +#if PIN_EXISTS(W_MIN) + REPORT_NAME_DIGITAL(__LINE__, W_MIN_PIN) #endif -#if PIN_EXISTS(Z3_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Z3_ENABLE_PIN) +#if PIN_EXISTS(W_STOP) + REPORT_NAME_DIGITAL(__LINE__, W_STOP_PIN) #endif -#if PIN_EXISTS(Z3_MAX) - REPORT_NAME_DIGITAL(__LINE__, Z3_MAX_PIN) + +#if PIN_EXISTS(E_STOP) + REPORT_NAME_DIGITAL(__LINE__, E_STOP_PIN) #endif -#if PIN_EXISTS(Z3_MIN) - REPORT_NAME_DIGITAL(__LINE__, Z3_MIN_PIN) + +// +// TMC Diagnostic - Sensorless Endstops +// +#if PIN_EXISTS(X_DIAG) + REPORT_NAME_DIGITAL(__LINE__, X_DIAG_PIN) #endif -#if PIN_EXISTS(Z3_MS1) - REPORT_NAME_DIGITAL(__LINE__, Z3_MS1_PIN) +#if PIN_EXISTS(X2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, X2_DIAG_PIN) #endif -#if PIN_EXISTS(Z3_MS2) - REPORT_NAME_DIGITAL(__LINE__, Z3_MS2_PIN) +#if PIN_EXISTS(Y_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Y_DIAG_PIN) #endif -#if PIN_EXISTS(Z3_MS3) - REPORT_NAME_DIGITAL(__LINE__, Z3_MS3_PIN) +#if PIN_EXISTS(Y2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Y2_DIAG_PIN) #endif -#if PIN_EXISTS(Z3_STEP) - REPORT_NAME_DIGITAL(__LINE__, Z3_STEP_PIN) +#if PIN_EXISTS(Z_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_CS) - REPORT_NAME_DIGITAL(__LINE__, Z4_CS_PIN) +#if PIN_EXISTS(Z2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z2_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_DIR) - REPORT_NAME_DIGITAL(__LINE__, Z4_DIR_PIN) +#if PIN_EXISTS(Z3_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z3_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Z4_ENABLE_PIN) +#if PIN_EXISTS(Z4_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z4_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MAX) - REPORT_NAME_DIGITAL(__LINE__, Z4_MAX_PIN) +#if PIN_EXISTS(I_DIAG) + REPORT_NAME_DIGITAL(__LINE__, I_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MIN) - REPORT_NAME_DIGITAL(__LINE__, Z4_MIN_PIN) +#if PIN_EXISTS(J_DIAG) + REPORT_NAME_DIGITAL(__LINE__, J_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MS1) - REPORT_NAME_DIGITAL(__LINE__, Z4_MS1_PIN) +#if PIN_EXISTS(K_DIAG) + REPORT_NAME_DIGITAL(__LINE__, K_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MS2) - REPORT_NAME_DIGITAL(__LINE__, Z4_MS2_PIN) +#if PIN_EXISTS(U_DIAG) + REPORT_NAME_DIGITAL(__LINE__, U_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MS3) - REPORT_NAME_DIGITAL(__LINE__, Z4_MS3_PIN) +#if PIN_EXISTS(V_DIAG) + REPORT_NAME_DIGITAL(__LINE__, V_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_STEP) - REPORT_NAME_DIGITAL(__LINE__, Z4_STEP_PIN) +#if PIN_EXISTS(W_DIAG) + REPORT_NAME_DIGITAL(__LINE__, W_DIAG_PIN) +#endif +#if PIN_EXISTS(E0_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E0_DIAG_PIN) +#endif +#if PIN_EXISTS(E1_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E1_DIAG_PIN) #endif +#if PIN_EXISTS(E2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E2_DIAG_PIN) +#endif +#if PIN_EXISTS(E3_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E3_DIAG_PIN) +#endif +#if PIN_EXISTS(E4_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E4_DIAG_PIN) +#endif +#if PIN_EXISTS(E5_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E5_DIAG_PIN) +#endif +#if PIN_EXISTS(E6_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E6_DIAG_PIN) +#endif +#if PIN_EXISTS(E7_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E7_DIAG_PIN) +#endif + +// +// Probes +// #if PIN_EXISTS(Z_MIN_PROBE) REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PROBE_PIN) #endif @@ -1448,44 +1561,91 @@ #if PIN_EXISTS(PROBE_TARE) REPORT_NAME_DIGITAL(__LINE__, PROBE_TARE_PIN) #endif -#if PIN_EXISTS(I_ATT) - REPORT_NAME_DIGITAL(__LINE__, I_ATT_PIN) + +// +// Stepper Drivers +// +#if PIN_EXISTS(X_DIR) + REPORT_NAME_DIGITAL(__LINE__, X_DIR_PIN) #endif -#if PIN_EXISTS(I_CS) - REPORT_NAME_DIGITAL(__LINE__, I_CS_PIN) +#if PIN_EXISTS(X_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, X_ENABLE_PIN) #endif -#if PIN_EXISTS(I_DIR) - REPORT_NAME_DIGITAL(__LINE__, I_DIR_PIN) +#if PIN_EXISTS(X_STEP) + REPORT_NAME_DIGITAL(__LINE__, X_STEP_PIN) #endif -#if PIN_EXISTS(I_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, I_ENABLE_PIN) +#if PIN_EXISTS(X2_DIR) + REPORT_NAME_DIGITAL(__LINE__, X2_DIR_PIN) #endif -#if PIN_EXISTS(I_MAX) - REPORT_NAME_DIGITAL(__LINE__, I_MAX_PIN) +#if PIN_EXISTS(X2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, X2_ENABLE_PIN) #endif -#if PIN_EXISTS(I_MIN) - REPORT_NAME_DIGITAL(__LINE__, I_MIN_PIN) +#if PIN_EXISTS(X2_STEP) + REPORT_NAME_DIGITAL(__LINE__, X2_STEP_PIN) #endif -#if PIN_EXISTS(I_MS1) - REPORT_NAME_DIGITAL(__LINE__, I_MS1_PIN) +#if PIN_EXISTS(Y_DIR) + REPORT_NAME_DIGITAL(__LINE__, Y_DIR_PIN) #endif -#if PIN_EXISTS(I_MS2) - REPORT_NAME_DIGITAL(__LINE__, I_MS2_PIN) +#if PIN_EXISTS(Y_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Y_ENABLE_PIN) #endif -#if PIN_EXISTS(I_MS3) - REPORT_NAME_DIGITAL(__LINE__, I_MS3_PIN) +#if PIN_EXISTS(Y_STEP) + REPORT_NAME_DIGITAL(__LINE__, Y_STEP_PIN) #endif -#if PIN_EXISTS(I_STEP) - REPORT_NAME_DIGITAL(__LINE__, I_STEP_PIN) +#if PIN_EXISTS(Y2_DIR) + REPORT_NAME_DIGITAL(__LINE__, Y2_DIR_PIN) #endif -#if PIN_EXISTS(I_STOP) - REPORT_NAME_DIGITAL(__LINE__, I_STOP_PIN) +#if PIN_EXISTS(Y2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Y2_ENABLE_PIN) #endif -#if PIN_EXISTS(J_ATT) - REPORT_NAME_DIGITAL(__LINE__, J_ATT_PIN) +#if PIN_EXISTS(Y2_STEP) + REPORT_NAME_DIGITAL(__LINE__, Y2_STEP_PIN) #endif -#if PIN_EXISTS(J_CS) - REPORT_NAME_DIGITAL(__LINE__, J_CS_PIN) +#if PIN_EXISTS(Z_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z_DIR_PIN) +#endif +#if PIN_EXISTS(Z_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z_STEP_PIN) +#endif +#if PIN_EXISTS(Z2_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z2_DIR_PIN) +#endif +#if PIN_EXISTS(Z2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z2_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z2_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z2_STEP_PIN) +#endif +#if PIN_EXISTS(Z3_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z3_DIR_PIN) +#endif +#if PIN_EXISTS(Z3_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z3_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z3_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z3_STEP_PIN) +#endif +#if PIN_EXISTS(Z4_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z4_DIR_PIN) +#endif +#if PIN_EXISTS(Z4_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z4_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z4_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z4_STEP_PIN) +#endif + +#if PIN_EXISTS(I_DIR) + REPORT_NAME_DIGITAL(__LINE__, I_DIR_PIN) +#endif +#if PIN_EXISTS(I_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, I_ENABLE_PIN) +#endif +#if PIN_EXISTS(I_STEP) + REPORT_NAME_DIGITAL(__LINE__, I_STEP_PIN) #endif #if PIN_EXISTS(J_DIR) REPORT_NAME_DIGITAL(__LINE__, J_DIR_PIN) @@ -1493,11 +1653,129 @@ #if PIN_EXISTS(J_ENABLE) REPORT_NAME_DIGITAL(__LINE__, J_ENABLE_PIN) #endif -#if PIN_EXISTS(J_MAX) - REPORT_NAME_DIGITAL(__LINE__, J_MAX_PIN) +#if PIN_EXISTS(J_STEP) + REPORT_NAME_DIGITAL(__LINE__, J_STEP_PIN) #endif -#if PIN_EXISTS(J_MIN) - REPORT_NAME_DIGITAL(__LINE__, J_MIN_PIN) +#if PIN_EXISTS(K_DIR) + REPORT_NAME_DIGITAL(__LINE__, K_DIR_PIN) +#endif +#if PIN_EXISTS(K_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, K_ENABLE_PIN) +#endif +#if PIN_EXISTS(K_STEP) + REPORT_NAME_DIGITAL(__LINE__, K_STEP_PIN) +#endif +#if PIN_EXISTS(U_DIR) + REPORT_NAME_DIGITAL(__LINE__, U_DIR_PIN) +#endif +#if PIN_EXISTS(U_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, U_ENABLE_PIN) +#endif +#if PIN_EXISTS(U_STEP) + REPORT_NAME_DIGITAL(__LINE__, U_STEP_PIN) +#endif +#if PIN_EXISTS(V_DIR) + REPORT_NAME_DIGITAL(__LINE__, V_DIR_PIN) +#endif +#if PIN_EXISTS(V_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, V_ENABLE_PIN) +#endif +#if PIN_EXISTS(V_STEP) + REPORT_NAME_DIGITAL(__LINE__, V_STEP_PIN) +#endif +#if PIN_EXISTS(W_DIR) + REPORT_NAME_DIGITAL(__LINE__, W_DIR_PIN) +#endif +#if PIN_EXISTS(W_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, W_ENABLE_PIN) +#endif +#if PIN_EXISTS(W_STEP) + REPORT_NAME_DIGITAL(__LINE__, W_STEP_PIN) +#endif + +// +// Digital Micro-steps +// +#if PIN_EXISTS(X_MS1) + REPORT_NAME_DIGITAL(__LINE__, X_MS1_PIN) +#endif +#if PIN_EXISTS(X_MS2) + REPORT_NAME_DIGITAL(__LINE__, X_MS2_PIN) +#endif +#if PIN_EXISTS(X_MS3) + REPORT_NAME_DIGITAL(__LINE__, X_MS3_PIN) +#endif +#if PIN_EXISTS(X2_MS1) + REPORT_NAME_DIGITAL(__LINE__, X2_MS1_PIN) +#endif +#if PIN_EXISTS(X2_MS2) + REPORT_NAME_DIGITAL(__LINE__, X2_MS2_PIN) +#endif +#if PIN_EXISTS(X2_MS3) + REPORT_NAME_DIGITAL(__LINE__, X2_MS3_PIN) +#endif +#if PIN_EXISTS(Y_MS1) + REPORT_NAME_DIGITAL(__LINE__, Y_MS1_PIN) +#endif +#if PIN_EXISTS(Y_MS2) + REPORT_NAME_DIGITAL(__LINE__, Y_MS2_PIN) +#endif +#if PIN_EXISTS(Y_MS3) + REPORT_NAME_DIGITAL(__LINE__, Y_MS3_PIN) +#endif +#if PIN_EXISTS(Y2_MS1) + REPORT_NAME_DIGITAL(__LINE__, Y2_MS1_PIN) +#endif +#if PIN_EXISTS(Y2_MS2) + REPORT_NAME_DIGITAL(__LINE__, Y2_MS2_PIN) +#endif +#if PIN_EXISTS(Y2_MS3) + REPORT_NAME_DIGITAL(__LINE__, Y2_MS3_PIN) +#endif +#if PIN_EXISTS(Z_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z_MS1_PIN) +#endif +#if PIN_EXISTS(Z_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z_MS2_PIN) +#endif +#if PIN_EXISTS(Z_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z_MS3_PIN) +#endif +#if PIN_EXISTS(Z2_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z2_MS1_PIN) +#endif +#if PIN_EXISTS(Z2_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z2_MS2_PIN) +#endif +#if PIN_EXISTS(Z2_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z2_MS3_PIN) +#endif +#if PIN_EXISTS(Z3_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z3_MS1_PIN) +#endif +#if PIN_EXISTS(Z3_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z3_MS2_PIN) +#endif +#if PIN_EXISTS(Z3_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z3_MS3_PIN) +#endif +#if PIN_EXISTS(Z4_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z4_MS1_PIN) +#endif +#if PIN_EXISTS(Z4_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z4_MS2_PIN) +#endif +#if PIN_EXISTS(Z4_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z4_MS3_PIN) +#endif +#if PIN_EXISTS(I_MS1) + REPORT_NAME_DIGITAL(__LINE__, I_MS1_PIN) +#endif +#if PIN_EXISTS(I_MS2) + REPORT_NAME_DIGITAL(__LINE__, I_MS2_PIN) +#endif +#if PIN_EXISTS(I_MS3) + REPORT_NAME_DIGITAL(__LINE__, I_MS3_PIN) #endif #if PIN_EXISTS(J_MS1) REPORT_NAME_DIGITAL(__LINE__, J_MS1_PIN) @@ -1508,150 +1786,222 @@ #if PIN_EXISTS(J_MS3) REPORT_NAME_DIGITAL(__LINE__, J_MS3_PIN) #endif -#if PIN_EXISTS(J_STEP) - REPORT_NAME_DIGITAL(__LINE__, J_STEP_PIN) +#if PIN_EXISTS(K_MS1) + REPORT_NAME_DIGITAL(__LINE__, K_MS1_PIN) #endif -#if PIN_EXISTS(J_STOP) - REPORT_NAME_DIGITAL(__LINE__, J_STOP_PIN) +#if PIN_EXISTS(K_MS2) + REPORT_NAME_DIGITAL(__LINE__, K_MS2_PIN) #endif -#if PIN_EXISTS(K_ATT) - REPORT_NAME_DIGITAL(__LINE__, K_ATT_PIN) +#if PIN_EXISTS(K_MS3) + REPORT_NAME_DIGITAL(__LINE__, K_MS3_PIN) #endif -#if PIN_EXISTS(K_CS) - REPORT_NAME_DIGITAL(__LINE__, K_CS_PIN) +#if PIN_EXISTS(U_MS1) + REPORT_NAME_DIGITAL(__LINE__, U_MS1_PIN) #endif -#if PIN_EXISTS(K_DIR) - REPORT_NAME_DIGITAL(__LINE__, K_DIR_PIN) +#if PIN_EXISTS(U_MS2) + REPORT_NAME_DIGITAL(__LINE__, U_MS2_PIN) #endif -#if PIN_EXISTS(K_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, K_ENABLE_PIN) +#if PIN_EXISTS(U_MS3) + REPORT_NAME_DIGITAL(__LINE__, U_MS3_PIN) #endif -#if PIN_EXISTS(K_MAX) - REPORT_NAME_DIGITAL(__LINE__, K_MAX_PIN) +#if PIN_EXISTS(V_MS1) + REPORT_NAME_DIGITAL(__LINE__, V_MS1_PIN) +#endif +#if PIN_EXISTS(V_MS2) + REPORT_NAME_DIGITAL(__LINE__, V_MS2_PIN) +#endif +#if PIN_EXISTS(V_MS3) + REPORT_NAME_DIGITAL(__LINE__, V_MS3_PIN) +#endif +#if PIN_EXISTS(W_MS1) + REPORT_NAME_DIGITAL(__LINE__, W_MS1_PIN) +#endif +#if PIN_EXISTS(W_MS2) + REPORT_NAME_DIGITAL(__LINE__, W_MS2_PIN) +#endif +#if PIN_EXISTS(W_MS3) + REPORT_NAME_DIGITAL(__LINE__, W_MS3_PIN) +#endif +#if PIN_EXISTS(E0_MS1) + REPORT_NAME_DIGITAL(__LINE__, E0_MS1_PIN) +#endif +#if PIN_EXISTS(E0_MS2) + REPORT_NAME_DIGITAL(__LINE__, E0_MS2_PIN) +#endif +#if PIN_EXISTS(E0_MS3) + REPORT_NAME_DIGITAL(__LINE__, E0_MS3_PIN) +#endif +#if PIN_EXISTS(E1_MS1) + REPORT_NAME_DIGITAL(__LINE__, E1_MS1_PIN) +#endif +#if PIN_EXISTS(E1_MS2) + REPORT_NAME_DIGITAL(__LINE__, E1_MS2_PIN) +#endif +#if PIN_EXISTS(E1_MS3) + REPORT_NAME_DIGITAL(__LINE__, E1_MS3_PIN) +#endif +#if PIN_EXISTS(E2_MS1) + REPORT_NAME_DIGITAL(__LINE__, E2_MS1_PIN) +#endif +#if PIN_EXISTS(E2_MS2) + REPORT_NAME_DIGITAL(__LINE__, E2_MS2_PIN) +#endif +#if PIN_EXISTS(E2_MS3) + REPORT_NAME_DIGITAL(__LINE__, E2_MS3_PIN) +#endif +#if PIN_EXISTS(E3_MS1) + REPORT_NAME_DIGITAL(__LINE__, E3_MS1_PIN) +#endif +#if PIN_EXISTS(E3_MS2) + REPORT_NAME_DIGITAL(__LINE__, E3_MS2_PIN) +#endif +#if PIN_EXISTS(E3_MS3) + REPORT_NAME_DIGITAL(__LINE__, E3_MS3_PIN) +#endif +#if PIN_EXISTS(E4_MS1) + REPORT_NAME_DIGITAL(__LINE__, E4_MS1_PIN) +#endif +#if PIN_EXISTS(E4_MS2) + REPORT_NAME_DIGITAL(__LINE__, E4_MS2_PIN) #endif -#if PIN_EXISTS(K_MIN) - REPORT_NAME_DIGITAL(__LINE__, K_MIN_PIN) +#if PIN_EXISTS(E4_MS3) + REPORT_NAME_DIGITAL(__LINE__, E4_MS3_PIN) #endif -#if PIN_EXISTS(K_MS1) - REPORT_NAME_DIGITAL(__LINE__, K_MS1_PIN) +#if PIN_EXISTS(E5_MS1) + REPORT_NAME_DIGITAL(__LINE__, E5_MS1_PIN) #endif -#if PIN_EXISTS(K_MS2) - REPORT_NAME_DIGITAL(__LINE__, K_MS2_PIN) +#if PIN_EXISTS(E5_MS2) + REPORT_NAME_DIGITAL(__LINE__, E5_MS2_PIN) #endif -#if PIN_EXISTS(K_MS3) - REPORT_NAME_DIGITAL(__LINE__, K_MS3_PIN) +#if PIN_EXISTS(E5_MS3) + REPORT_NAME_DIGITAL(__LINE__, E5_MS3_PIN) #endif -#if PIN_EXISTS(K_STEP) - REPORT_NAME_DIGITAL(__LINE__, K_STEP_PIN) +#if PIN_EXISTS(E6_MS1) + REPORT_NAME_DIGITAL(__LINE__, E6_MS1_PIN) #endif -#if PIN_EXISTS(K_STOP) - REPORT_NAME_DIGITAL(__LINE__, K_STOP_PIN) +#if PIN_EXISTS(E6_MS2) + REPORT_NAME_DIGITAL(__LINE__, E6_MS2_PIN) #endif -#if PIN_EXISTS(U_ATT) - REPORT_NAME_DIGITAL(__LINE__, U_ATT_PIN) +#if PIN_EXISTS(E6_MS3) + REPORT_NAME_DIGITAL(__LINE__, E6_MS3_PIN) #endif -#if PIN_EXISTS(U_CS) - REPORT_NAME_DIGITAL(__LINE__, U_CS_PIN) +#if PIN_EXISTS(E7_MS1) + REPORT_NAME_DIGITAL(__LINE__, E7_MS1_PIN) #endif -#if PIN_EXISTS(U_DIR) - REPORT_NAME_DIGITAL(__LINE__, U_DIR_PIN) +#if PIN_EXISTS(E7_MS2) + REPORT_NAME_DIGITAL(__LINE__, E7_MS2_PIN) #endif -#if PIN_EXISTS(U_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, U_ENABLE_PIN) +#if PIN_EXISTS(E7_MS3) + REPORT_NAME_DIGITAL(__LINE__, E7_MS3_PIN) #endif -#if PIN_EXISTS(U_MAX) - REPORT_NAME_DIGITAL(__LINE__, U_MAX_PIN) + +// +// Stepper Standby +// +#if PIN_EXISTS(X_STDBY) + REPORT_NAME_DIGITAL(__LINE__, X_STDBY_PIN) #endif -#if PIN_EXISTS(U_MIN) - REPORT_NAME_DIGITAL(__LINE__, U_MIN_PIN) +#if PIN_EXISTS(X2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, X2_STDBY_PIN) #endif -#if PIN_EXISTS(U_MS1) - REPORT_NAME_DIGITAL(__LINE__, U_MS1_PIN) +#if PIN_EXISTS(Y_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Y_STDBY_PIN) #endif -#if PIN_EXISTS(U_MS2) - REPORT_NAME_DIGITAL(__LINE__, U_MS2_PIN) +#if PIN_EXISTS(Y2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Y2_STDBY_PIN) #endif -#if PIN_EXISTS(U_MS3) - REPORT_NAME_DIGITAL(__LINE__, U_MS3_PIN) +#if PIN_EXISTS(Z_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z_STDBY_PIN) #endif -#if PIN_EXISTS(U_STEP) - REPORT_NAME_DIGITAL(__LINE__, U_STEP_PIN) +#if PIN_EXISTS(Z2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z2_STDBY_PIN) #endif -#if PIN_EXISTS(U_STOP) - REPORT_NAME_DIGITAL(__LINE__, U_STOP_PIN) +#if PIN_EXISTS(Z3_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z3_STDBY_PIN) #endif -#if PIN_EXISTS(V_ATT) - REPORT_NAME_DIGITAL(__LINE__, V_ATT_PIN) +#if PIN_EXISTS(Z4_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z4_STDBY_PIN) #endif -#if PIN_EXISTS(V_CS) - REPORT_NAME_DIGITAL(__LINE__, V_CS_PIN) +#if PIN_EXISTS(I_STDBY) + REPORT_NAME_DIGITAL(__LINE__, I_STDBY_PIN) #endif -#if PIN_EXISTS(V_DIR) - REPORT_NAME_DIGITAL(__LINE__, V_DIR_PIN) +#if PIN_EXISTS(J_STDBY) + REPORT_NAME_DIGITAL(__LINE__, J_STDBY_PIN) #endif -#if PIN_EXISTS(V_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, V_ENABLE_PIN) +#if PIN_EXISTS(K_STDBY) + REPORT_NAME_DIGITAL(__LINE__, K_STDBY_PIN) #endif -#if PIN_EXISTS(V_MAX) - REPORT_NAME_DIGITAL(__LINE__, V_MAX_PIN) +#if PIN_EXISTS(U_STDBY) + REPORT_NAME_DIGITAL(__LINE__, U_STDBY_PIN) #endif -#if PIN_EXISTS(V_MIN) - REPORT_NAME_DIGITAL(__LINE__, V_MIN_PIN) +#if PIN_EXISTS(V_STDBY) + REPORT_NAME_DIGITAL(__LINE__, V_STDBY_PIN) #endif -#if PIN_EXISTS(V_MS1) - REPORT_NAME_DIGITAL(__LINE__, V_MS1_PIN) +#if PIN_EXISTS(W_STDBY) + REPORT_NAME_DIGITAL(__LINE__, W_STDBY_PIN) #endif -#if PIN_EXISTS(V_MS2) - REPORT_NAME_DIGITAL(__LINE__, V_MS2_PIN) +#if PIN_EXISTS(E0_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E0_STDBY_PIN) #endif -#if PIN_EXISTS(V_MS3) - REPORT_NAME_DIGITAL(__LINE__, V_MS3_PIN) +#if PIN_EXISTS(E1_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E1_STDBY_PIN) #endif -#if PIN_EXISTS(V_STEP) - REPORT_NAME_DIGITAL(__LINE__, V_STEP_PIN) +#if PIN_EXISTS(E2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E2_STDBY_PIN) #endif -#if PIN_EXISTS(V_STOP) - REPORT_NAME_DIGITAL(__LINE__, V_STOP_PIN) +#if PIN_EXISTS(E3_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E3_STDBY_PIN) #endif -#if PIN_EXISTS(W_ATT) - REPORT_NAME_DIGITAL(__LINE__, W_ATT_PIN) +#if PIN_EXISTS(E4_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E4_STDBY_PIN) #endif -#if PIN_EXISTS(W_CS) - REPORT_NAME_DIGITAL(__LINE__, W_CS_PIN) +#if PIN_EXISTS(E5_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E5_STDBY_PIN) #endif -#if PIN_EXISTS(W_DIR) - REPORT_NAME_DIGITAL(__LINE__, W_DIR_PIN) +#if PIN_EXISTS(E6_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E6_STDBY_PIN) #endif -#if PIN_EXISTS(W_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, W_ENABLE_PIN) +#if PIN_EXISTS(E7_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E7_STDBY_PIN) #endif -#if PIN_EXISTS(W_MAX) - REPORT_NAME_DIGITAL(__LINE__, W_MAX_PIN) + +// +// LV8731V Current Attenuation +// +#if PIN_EXISTS(X_ATT) + REPORT_NAME_DIGITAL(__LINE__, X_ATT_PIN) #endif -#if PIN_EXISTS(W_MIN) - REPORT_NAME_DIGITAL(__LINE__, W_MIN_PIN) +#if PIN_EXISTS(Y_ATT) + REPORT_NAME_DIGITAL(__LINE__, Y_ATT_PIN) #endif -#if PIN_EXISTS(W_MS1) - REPORT_NAME_DIGITAL(__LINE__, W_MS1_PIN) +#if PIN_EXISTS(E0_ATT) + REPORT_NAME_DIGITAL(__LINE__, E0_ATT_PIN) #endif -#if PIN_EXISTS(W_MS2) - REPORT_NAME_DIGITAL(__LINE__, W_MS2_PIN) +#if PIN_EXISTS(Z_ATT) + REPORT_NAME_DIGITAL(__LINE__, Z_ATT_PIN) #endif -#if PIN_EXISTS(W_MS3) - REPORT_NAME_DIGITAL(__LINE__, W_MS3_PIN) +#if PIN_EXISTS(I_ATT) + REPORT_NAME_DIGITAL(__LINE__, I_ATT_PIN) #endif -#if PIN_EXISTS(W_STEP) - REPORT_NAME_DIGITAL(__LINE__, W_STEP_PIN) +#if PIN_EXISTS(J_ATT) + REPORT_NAME_DIGITAL(__LINE__, J_ATT_PIN) #endif -#if PIN_EXISTS(W_STOP) - REPORT_NAME_DIGITAL(__LINE__, W_STOP_PIN) +#if PIN_EXISTS(K_ATT) + REPORT_NAME_DIGITAL(__LINE__, K_ATT_PIN) #endif -#if PIN_EXISTS(ZRIB_V20_D6) - REPORT_NAME_DIGITAL(__LINE__, ZRIB_V20_D6_PIN) +#if PIN_EXISTS(U_ATT) + REPORT_NAME_DIGITAL(__LINE__, U_ATT_PIN) +#endif +#if PIN_EXISTS(V_ATT) + REPORT_NAME_DIGITAL(__LINE__, V_ATT_PIN) #endif -#if PIN_EXISTS(ZRIB_V20_D9) - REPORT_NAME_DIGITAL(__LINE__, ZRIB_V20_D9_PIN) +#if PIN_EXISTS(W_ATT) + REPORT_NAME_DIGITAL(__LINE__, W_ATT_PIN) #endif + +// +// TMC Serial UART +// #if PIN_EXISTS(X_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, X_SERIAL_TX_PIN) #endif @@ -1736,99 +2086,59 @@ #if PIN_EXISTS(W_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, W_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E0_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E0_DIAG_PIN) -#endif + #if PIN_EXISTS(E0_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E0_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E0_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E0_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E1_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E1_DIAG_PIN) -#endif #if PIN_EXISTS(E1_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E1_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E1_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E1_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E2_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E2_DIAG_PIN) -#endif #if PIN_EXISTS(E2_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E2_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E2_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E2_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E3_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E3_DIAG_PIN) -#endif #if PIN_EXISTS(E3_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E3_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E3_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E3_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E4_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E4_DIAG_PIN) -#endif #if PIN_EXISTS(E4_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E4_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E4_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E4_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E5_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E5_DIAG_PIN) -#endif #if PIN_EXISTS(E5_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E5_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E5_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E5_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E6_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E6_DIAG_PIN) -#endif #if PIN_EXISTS(E6_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E6_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E6_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E6_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E7_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E7_DIAG_PIN) -#endif #if PIN_EXISTS(E7_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E7_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E7_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E7_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(I_SERIAL_TX) - REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_TX_PIN) -#endif -#if PIN_EXISTS(I_SERIAL_RX) - REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_RX_PIN) -#endif -#if PIN_EXISTS(J_SERIAL_TX) - REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_TX_PIN) -#endif -#if PIN_EXISTS(J_SERIAL_RX) - REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_RX_PIN) -#endif -#if PIN_EXISTS(K_SERIAL_TX) - REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_TX_PIN) -#endif -#if PIN_EXISTS(K_SERIAL_RX) - REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_RX_PIN) -#endif -#if PIN_EXISTS(FET_SAFETY) - REPORT_NAME_DIGITAL(__LINE__, FET_SAFETY_PIN) -#endif + +// +// Touch Screen +// #if PIN_EXISTS(TOUCH_MISO) REPORT_NAME_DIGITAL(__LINE__, TOUCH_MISO_PIN) #endif @@ -1844,27 +2154,51 @@ #if PIN_EXISTS(TOUCH_INT) REPORT_NAME_DIGITAL(__LINE__, TOUCH_INT_PIN) #endif + +// +// USB +// #if PIN_EXISTS(USB_CS) REPORT_NAME_DIGITAL(__LINE__, USB_CS_PIN) #endif #if PIN_EXISTS(USB_INTR) REPORT_NAME_DIGITAL(__LINE__, USB_INTR_PIN) #endif + +// +// MMU2 +// #if PIN_EXISTS(MMU2_RST) REPORT_NAME_DIGITAL(__LINE__, MMU2_RST_PIN) #endif + +// +// G425 Axis Calibration +// #if PIN_EXISTS(CALIBRATION) REPORT_NAME_DIGITAL(__LINE__, CALIBRATION_PIN) #endif + +// +// Duet Smart Effector +// #if PIN_EXISTS(SMART_EFFECTOR_MOD) REPORT_NAME_DIGITAL(__LINE__, SMART_EFFECTOR_MOD_PIN) #endif + +// +// Closed Loop +// #if PIN_EXISTS(CLOSED_LOOP_ENABLE) REPORT_NAME_DIGITAL(__LINE__, CLOSED_LOOP_ENABLE_PIN) #endif #if PIN_EXISTS(CLOSED_LOOP_MOVE_COMPLETE) REPORT_NAME_DIGITAL(__LINE__, CLOSED_LOOP_MOVE_COMPLETE_PIN) #endif + +// +// ESP WiFi +// #if PIN_EXISTS(ESP_WIFI_MODULE_RESET) REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_RESET_PIN) #endif @@ -1877,7 +2211,10 @@ #if PIN_EXISTS(ESP_WIFI_MODULE_GPIO2) REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_GPIO2_PIN) #endif -// TFT PINS + +// +// TFT +// #if PIN_EXISTS(TFT_CS) REPORT_NAME_DIGITAL(__LINE__, TFT_CS_PIN) #endif @@ -1896,3 +2233,84 @@ #if PIN_EXISTS(TFT_RESET) REPORT_NAME_DIGITAL(__LINE__, TFT_RESET_PIN) #endif + +// +// Hardware UART +// +#if SERIAL_IN_USE(1) + #if PIN_EXISTS(UART1_TX) + REPORT_NAME_DIGITAL(__LINE__, UART1_TX_PIN) + #endif + #if PIN_EXISTS(UART1_RX) + REPORT_NAME_DIGITAL(__LINE__, UART1_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(2) + #if PIN_EXISTS(UART2_TX) + REPORT_NAME_DIGITAL(__LINE__, UART2_TX_PIN) + #endif + #if PIN_EXISTS(UART2_RX) + REPORT_NAME_DIGITAL(__LINE__, UART2_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(3) + #if PIN_EXISTS(UART3_TX) + REPORT_NAME_DIGITAL(__LINE__, UART3_TX_PIN) + #endif + #if PIN_EXISTS(UART3_RX) + REPORT_NAME_DIGITAL(__LINE__, UART3_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(4) + #if PIN_EXISTS(UART4_TX) + REPORT_NAME_DIGITAL(__LINE__, UART4_TX_PIN) + #endif + #if PIN_EXISTS(UART4_RX) + REPORT_NAME_DIGITAL(__LINE__, UART4_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(5) + #if PIN_EXISTS(UART5_TX) + REPORT_NAME_DIGITAL(__LINE__, UART5_TX_PIN) + #endif + #if PIN_EXISTS(UART5_RX) + REPORT_NAME_DIGITAL(__LINE__, UART5_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(6) + #if PIN_EXISTS(UART6_TX) + REPORT_NAME_DIGITAL(__LINE__, UART6_TX_PIN) + #endif + #if PIN_EXISTS(UART6_RX) + REPORT_NAME_DIGITAL(__LINE__, UART6_RX_PIN) + #endif +#endif + +// +// SDIO +// +#if PIN_EXISTS(SDIO_D0) + REPORT_NAME_DIGITAL(__LINE__, SDIO_D0_PIN) +#endif +#if PIN_EXISTS(SDIO_D1) + REPORT_NAME_DIGITAL(__LINE__, SDIO_D1_PIN) +#endif +#if PIN_EXISTS(SDIO_D2) + REPORT_NAME_DIGITAL(__LINE__, SDIO_D2_PIN) +#endif +#if PIN_EXISTS(SDIO_D3) + REPORT_NAME_DIGITAL(__LINE__, SDIO_D3_PIN) +#endif +#if PIN_EXISTS(SDIO_CK) + REPORT_NAME_DIGITAL(__LINE__, SDIO_CK_PIN) +#endif +#if PIN_EXISTS(SDIO_CMD) + REPORT_NAME_DIGITAL(__LINE__, SDIO_CMD_PIN) +#endif + +// +// Miscellaneous +// +#if _EXISTS(UNUSED_PWM) + REPORT_NAME_DIGITAL(__LINE__, UNUSED_PWM) +#endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index c3c217557beb..5b5cbcd2147a 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -307,6 +307,76 @@ #define E7_CS_PIN -1 #endif +// +// Destroy stepper driver RX and TX pins when set to -1 +// +#if !PIN_EXISTS(Z2_SERIAL_TX) + #undef Z2_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(Z2_SERIAL_RX) + #undef Z2_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(Z3_SERIAL_TX) + #undef Z3_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(Z3_SERIAL_RX) + #undef Z3_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(Z4_SERIAL_TX) + #undef Z4_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(Z4_SERIAL_RX) + #undef Z4_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(X2_SERIAL_TX) + #undef X2_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(X2_SERIAL_RX) + #undef X2_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(Y2_SERIAL_TX) + #undef Y2_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(Y2_SERIAL_RX) + #undef Y2_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(I_SERIAL_TX) + #undef I_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(I_SERIAL_RX) + #undef I_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(J_SERIAL_TX) + #undef J_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(J_SERIAL_RX) + #undef J_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(K_SERIAL_TX) + #undef K_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(K_SERIAL_RX) + #undef K_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(U_SERIAL_TX) + #undef U_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(U_SERIAL_RX) + #undef U_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(V_SERIAL_TX) + #undef V_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(V_SERIAL_RX) + #undef V_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(W_SERIAL_TX) + #undef W_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(W_SERIAL_RX) + #undef W_SERIAL_RX_PIN +#endif + #ifndef FAN_PIN #define FAN_PIN -1 #endif @@ -645,6 +715,8 @@ #undef FIL_RUNOUT2_PIN #endif +#undef LCD_PINS_DEFINED + #ifndef LCD_PINS_D4 #define LCD_PINS_D4 -1 #endif @@ -1787,6 +1859,497 @@ #undef Z4_MAX_PIN #endif +/** + * X_DUAL_ENDSTOPS endstop reassignment + */ +#if ENABLED(X_DUAL_ENDSTOPS) + #if X_HOME_TO_MAX + #ifndef X2_MAX_PIN + #if PIN_EXISTS(X2_STOP) + #define X2_MAX_PIN X2_STOP_PIN + #elif X2_USE_ENDSTOP == _XMIN_ + #define X2_MAX_PIN X_MIN_PIN + #elif X2_USE_ENDSTOP == _XMAX_ + #define X2_MAX_PIN X_MAX_PIN + #elif X2_USE_ENDSTOP == _XSTOP_ + #define X2_MAX_PIN X_STOP_PIN + #elif X2_USE_ENDSTOP == _YMIN_ + #define X2_MAX_PIN Y_MIN_PIN + #elif X2_USE_ENDSTOP == _YMAX_ + #define X2_MAX_PIN Y_MAX_PIN + #elif X2_USE_ENDSTOP == _YSTOP_ + #define X2_MAX_PIN Y_STOP_PIN + #elif X2_USE_ENDSTOP == _ZMIN_ + #define X2_MAX_PIN Z_MIN_PIN + #elif X2_USE_ENDSTOP == _ZMAX_ + #define X2_MAX_PIN Z_MAX_PIN + #elif X2_USE_ENDSTOP == _ZSTOP_ + #define X2_MAX_PIN Z_STOP_PIN + #elif X2_USE_ENDSTOP == _XDIAG_ + #define X2_MAX_PIN X_DIAG_PIN + #elif X2_USE_ENDSTOP == _YDIAG_ + #define X2_MAX_PIN Y_DIAG_PIN + #elif X2_USE_ENDSTOP == _ZDIAG_ + #define X2_MAX_PIN Z_DIAG_PIN + #elif X2_USE_ENDSTOP == _E0DIAG_ + #define X2_MAX_PIN E0_DIAG_PIN + #elif X2_USE_ENDSTOP == _E1DIAG_ + #define X2_MAX_PIN E1_DIAG_PIN + #elif X2_USE_ENDSTOP == _E2DIAG_ + #define X2_MAX_PIN E2_DIAG_PIN + #elif X2_USE_ENDSTOP == _E3DIAG_ + #define X2_MAX_PIN E3_DIAG_PIN + #elif X2_USE_ENDSTOP == _E4DIAG_ + #define X2_MAX_PIN E4_DIAG_PIN + #elif X2_USE_ENDSTOP == _E5DIAG_ + #define X2_MAX_PIN E5_DIAG_PIN + #elif X2_USE_ENDSTOP == _E6DIAG_ + #define X2_MAX_PIN E6_DIAG_PIN + #elif X2_USE_ENDSTOP == _E7DIAG_ + #define X2_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef X2_MIN_PIN + #if PIN_EXISTS(X2_STOP) + #define X2_MIN_PIN X2_STOP_PIN + #elif X2_USE_ENDSTOP == _XMIN_ + #define X2_MIN_PIN X_MIN_PIN + #elif X2_USE_ENDSTOP == _XMAX_ + #define X2_MIN_PIN X_MAX_PIN + #elif X2_USE_ENDSTOP == _XSTOP_ + #define X2_MIN_PIN X_STOP_PIN + #elif X2_USE_ENDSTOP == _YMIN_ + #define X2_MIN_PIN Y_MIN_PIN + #elif X2_USE_ENDSTOP == _YMAX_ + #define X2_MIN_PIN Y_MAX_PIN + #elif X2_USE_ENDSTOP == _YSTOP_ + #define X2_MIN_PIN Y_STOP_PIN + #elif X2_USE_ENDSTOP == _ZMIN_ + #define X2_MIN_PIN Z_MIN_PIN + #elif X2_USE_ENDSTOP == _ZMAX_ + #define X2_MIN_PIN Z_MAX_PIN + #elif X2_USE_ENDSTOP == _ZSTOP_ + #define X2_MIN_PIN Z_STOP_PIN + #elif X2_USE_ENDSTOP == _XDIAG_ + #define X2_MIN_PIN X_DIAG_PIN + #elif X2_USE_ENDSTOP == _YDIAG_ + #define X2_MIN_PIN Y_DIAG_PIN + #elif X2_USE_ENDSTOP == _ZDIAG_ + #define X2_MIN_PIN Z_DIAG_PIN + #elif X2_USE_ENDSTOP == _E0DIAG_ + #define X2_MIN_PIN E0_DIAG_PIN + #elif X2_USE_ENDSTOP == _E1DIAG_ + #define X2_MIN_PIN E1_DIAG_PIN + #elif X2_USE_ENDSTOP == _E2DIAG_ + #define X2_MIN_PIN E2_DIAG_PIN + #elif X2_USE_ENDSTOP == _E3DIAG_ + #define X2_MIN_PIN E3_DIAG_PIN + #elif X2_USE_ENDSTOP == _E4DIAG_ + #define X2_MIN_PIN E4_DIAG_PIN + #elif X2_USE_ENDSTOP == _E5DIAG_ + #define X2_MIN_PIN E5_DIAG_PIN + #elif X2_USE_ENDSTOP == _E6DIAG_ + #define X2_MIN_PIN E6_DIAG_PIN + #elif X2_USE_ENDSTOP == _E7DIAG_ + #define X2_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif +#endif + +/** + * Y_DUAL_ENDSTOPS endstop reassignment + */ +#if ENABLED(Y_DUAL_ENDSTOPS) + #if Y_HOME_TO_MAX + #ifndef Y2_MAX_PIN + #if PIN_EXISTS(Y2_STOP) + #define Y2_MAX_PIN Y2_STOP_PIN + #elif Y2_USE_ENDSTOP == _XMIN_ + #define Y2_MAX_PIN X_MIN_PIN + #elif Y2_USE_ENDSTOP == _XMAX_ + #define Y2_MAX_PIN X_MAX_PIN + #elif Y2_USE_ENDSTOP == _XSTOP_ + #define Y2_MAX_PIN X_STOP_PIN + #elif Y2_USE_ENDSTOP == _YMIN_ + #define Y2_MAX_PIN Y_MIN_PIN + #elif Y2_USE_ENDSTOP == _YMAX_ + #define Y2_MAX_PIN Y_MAX_PIN + #elif Y2_USE_ENDSTOP == _YSTOP_ + #define Y2_MAX_PIN Y_STOP_PIN + #elif Y2_USE_ENDSTOP == _ZMIN_ + #define Y2_MAX_PIN Z_MIN_PIN + #elif Y2_USE_ENDSTOP == _ZMAX_ + #define Y2_MAX_PIN Z_MAX_PIN + #elif Y2_USE_ENDSTOP == _ZSTOP_ + #define Y2_MAX_PIN Z_STOP_PIN + #elif Y2_USE_ENDSTOP == _XDIAG_ + #define Y2_MAX_PIN X_DIAG_PIN + #elif Y2_USE_ENDSTOP == _YDIAG_ + #define Y2_MAX_PIN Y_DIAG_PIN + #elif Y2_USE_ENDSTOP == _ZDIAG_ + #define Y2_MAX_PIN Z_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E0DIAG_ + #define Y2_MAX_PIN E0_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E1DIAG_ + #define Y2_MAX_PIN E1_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E2DIAG_ + #define Y2_MAX_PIN E2_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E3DIAG_ + #define Y2_MAX_PIN E3_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E4DIAG_ + #define Y2_MAX_PIN E4_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E5DIAG_ + #define Y2_MAX_PIN E5_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E6DIAG_ + #define Y2_MAX_PIN E6_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E7DIAG_ + #define Y2_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef Y2_MIN_PIN + #if PIN_EXISTS(Y2_STOP) + #define Y2_MIN_PIN Y2_STOP_PIN + #elif Y2_USE_ENDSTOP == _XMIN_ + #define Y2_MIN_PIN X_MIN_PIN + #elif Y2_USE_ENDSTOP == _XMAX_ + #define Y2_MIN_PIN X_MAX_PIN + #elif Y2_USE_ENDSTOP == _XSTOP_ + #define Y2_MIN_PIN X_STOP_PIN + #elif Y2_USE_ENDSTOP == _YMIN_ + #define Y2_MIN_PIN Y_MIN_PIN + #elif Y2_USE_ENDSTOP == _YMAX_ + #define Y2_MIN_PIN Y_MAX_PIN + #elif Y2_USE_ENDSTOP == _YSTOP_ + #define Y2_MIN_PIN Y_STOP_PIN + #elif Y2_USE_ENDSTOP == _ZMIN_ + #define Y2_MIN_PIN Z_MIN_PIN + #elif Y2_USE_ENDSTOP == _ZMAX_ + #define Y2_MIN_PIN Z_MAX_PIN + #elif Y2_USE_ENDSTOP == _ZSTOP_ + #define Y2_MIN_PIN Z_STOP_PIN + #elif Y2_USE_ENDSTOP == _XDIAG_ + #define Y2_MIN_PIN X_DIAG_PIN + #elif Y2_USE_ENDSTOP == _YDIAG_ + #define Y2_MIN_PIN Y_DIAG_PIN + #elif Y2_USE_ENDSTOP == _ZDIAG_ + #define Y2_MIN_PIN Z_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E0DIAG_ + #define Y2_MIN_PIN E0_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E1DIAG_ + #define Y2_MIN_PIN E1_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E2DIAG_ + #define Y2_MIN_PIN E2_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E3DIAG_ + #define Y2_MIN_PIN E3_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E4DIAG_ + #define Y2_MIN_PIN E4_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E5DIAG_ + #define Y2_MIN_PIN E5_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E6DIAG_ + #define Y2_MIN_PIN E6_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E7DIAG_ + #define Y2_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif +#endif + +/** + * Z_MULTI_ENDSTOPS endstop reassignment + */ +#if ENABLED(Z_MULTI_ENDSTOPS) + + #if Z_HOME_TO_MAX + #ifndef Z2_MAX_PIN + #if PIN_EXISTS(Z2_STOP) + #define Z2_MAX_PIN Z2_STOP_PIN + #elif Z2_USE_ENDSTOP == _XMIN_ + #define Z2_MAX_PIN X_MIN_PIN + #elif Z2_USE_ENDSTOP == _XMAX_ + #define Z2_MAX_PIN X_MAX_PIN + #elif Z2_USE_ENDSTOP == _XSTOP_ + #define Z2_MAX_PIN X_STOP_PIN + #elif Z2_USE_ENDSTOP == _YMIN_ + #define Z2_MAX_PIN Y_MIN_PIN + #elif Z2_USE_ENDSTOP == _YMAX_ + #define Z2_MAX_PIN Y_MAX_PIN + #elif Z2_USE_ENDSTOP == _YSTOP_ + #define Z2_MAX_PIN Y_STOP_PIN + #elif Z2_USE_ENDSTOP == _ZMIN_ + #define Z2_MAX_PIN Z_MIN_PIN + #elif Z2_USE_ENDSTOP == _ZMAX_ + #define Z2_MAX_PIN Z_MAX_PIN + #elif Z2_USE_ENDSTOP == _ZSTOP_ + #define Z2_MAX_PIN Z_STOP_PIN + #elif Z2_USE_ENDSTOP == _XDIAG_ + #define Z2_MAX_PIN X_DIAG_PIN + #elif Z2_USE_ENDSTOP == _YDIAG_ + #define Z2_MAX_PIN Y_DIAG_PIN + #elif Z2_USE_ENDSTOP == _ZDIAG_ + #define Z2_MAX_PIN Z_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E0DIAG_ + #define Z2_MAX_PIN E0_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E1DIAG_ + #define Z2_MAX_PIN E1_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E2DIAG_ + #define Z2_MAX_PIN E2_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E3DIAG_ + #define Z2_MAX_PIN E3_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E4DIAG_ + #define Z2_MAX_PIN E4_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E5DIAG_ + #define Z2_MAX_PIN E5_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E6DIAG_ + #define Z2_MAX_PIN E6_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E7DIAG_ + #define Z2_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef Z2_MIN_PIN + #if PIN_EXISTS(Z2_STOP) + #define Z2_MIN_PIN Z2_STOP_PIN + #elif Z2_USE_ENDSTOP == _XMIN_ + #define Z2_MIN_PIN X_MIN_PIN + #elif Z2_USE_ENDSTOP == _XMAX_ + #define Z2_MIN_PIN X_MAX_PIN + #elif Z2_USE_ENDSTOP == _XSTOP_ + #define Z2_MIN_PIN X_STOP_PIN + #elif Z2_USE_ENDSTOP == _YMIN_ + #define Z2_MIN_PIN Y_MIN_PIN + #elif Z2_USE_ENDSTOP == _YMAX_ + #define Z2_MIN_PIN Y_MAX_PIN + #elif Z2_USE_ENDSTOP == _YSTOP_ + #define Z2_MIN_PIN Y_STOP_PIN + #elif Z2_USE_ENDSTOP == _ZMIN_ + #define Z2_MIN_PIN Z_MIN_PIN + #elif Z2_USE_ENDSTOP == _ZMAX_ + #define Z2_MIN_PIN Z_MAX_PIN + #elif Z2_USE_ENDSTOP == _ZSTOP_ + #define Z2_MIN_PIN Z_STOP_PIN + #elif Z2_USE_ENDSTOP == _XDIAG_ + #define Z2_MIN_PIN X_DIAG_PIN + #elif Z2_USE_ENDSTOP == _YDIAG_ + #define Z2_MIN_PIN Y_DIAG_PIN + #elif Z2_USE_ENDSTOP == _ZDIAG_ + #define Z2_MIN_PIN Z_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E0DIAG_ + #define Z2_MIN_PIN E0_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E1DIAG_ + #define Z2_MIN_PIN E1_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E2DIAG_ + #define Z2_MIN_PIN E2_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E3DIAG_ + #define Z2_MIN_PIN E3_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E4DIAG_ + #define Z2_MIN_PIN E4_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E5DIAG_ + #define Z2_MIN_PIN E5_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E6DIAG_ + #define Z2_MIN_PIN E6_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E7DIAG_ + #define Z2_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif + + #if NUM_Z_STEPPERS >= 3 + #if Z_HOME_TO_MAX + #ifndef Z3_MAX_PIN + #if PIN_EXISTS(Z3_STOP) + #define Z3_MAX_PIN Z3_STOP_PIN + #elif Z3_USE_ENDSTOP == _XMIN_ + #define Z3_MAX_PIN X_MIN_PIN + #elif Z3_USE_ENDSTOP == _XMAX_ + #define Z3_MAX_PIN X_MAX_PIN + #elif Z3_USE_ENDSTOP == _XSTOP_ + #define Z3_MAX_PIN X_STOP_PIN + #elif Z3_USE_ENDSTOP == _YMIN_ + #define Z3_MAX_PIN Y_MIN_PIN + #elif Z3_USE_ENDSTOP == _YMAX_ + #define Z3_MAX_PIN Y_MAX_PIN + #elif Z3_USE_ENDSTOP == _YSTOP_ + #define Z3_MAX_PIN Y_STOP_PIN + #elif Z3_USE_ENDSTOP == _ZMIN_ + #define Z3_MAX_PIN Z_MIN_PIN + #elif Z3_USE_ENDSTOP == _ZMAX_ + #define Z3_MAX_PIN Z_MAX_PIN + #elif Z3_USE_ENDSTOP == _ZSTOP_ + #define Z3_MAX_PIN Z_STOP_PIN + #elif Z3_USE_ENDSTOP == _XDIAG_ + #define Z3_MAX_PIN X_DIAG_PIN + #elif Z3_USE_ENDSTOP == _YDIAG_ + #define Z3_MAX_PIN Y_DIAG_PIN + #elif Z3_USE_ENDSTOP == _ZDIAG_ + #define Z3_MAX_PIN Z_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E0DIAG_ + #define Z3_MAX_PIN E0_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E1DIAG_ + #define Z3_MAX_PIN E1_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E2DIAG_ + #define Z3_MAX_PIN E2_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E3DIAG_ + #define Z3_MAX_PIN E3_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E4DIAG_ + #define Z3_MAX_PIN E4_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E5DIAG_ + #define Z3_MAX_PIN E5_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E6DIAG_ + #define Z3_MAX_PIN E6_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E7DIAG_ + #define Z3_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef Z3_MIN_PIN + #if PIN_EXISTS(Z3_STOP) + #define Z3_MIN_PIN Z3_STOP_PIN + #elif Z3_USE_ENDSTOP == _XMIN_ + #define Z3_MIN_PIN X_MIN_PIN + #elif Z3_USE_ENDSTOP == _XMAX_ + #define Z3_MIN_PIN X_MAX_PIN + #elif Z3_USE_ENDSTOP == _XSTOP_ + #define Z3_MIN_PIN X_STOP_PIN + #elif Z3_USE_ENDSTOP == _YMIN_ + #define Z3_MIN_PIN Y_MIN_PIN + #elif Z3_USE_ENDSTOP == _YMAX_ + #define Z3_MIN_PIN Y_MAX_PIN + #elif Z3_USE_ENDSTOP == _YSTOP_ + #define Z3_MIN_PIN Y_STOP_PIN + #elif Z3_USE_ENDSTOP == _ZMIN_ + #define Z3_MIN_PIN Z_MIN_PIN + #elif Z3_USE_ENDSTOP == _ZMAX_ + #define Z3_MIN_PIN Z_MAX_PIN + #elif Z3_USE_ENDSTOP == _ZSTOP_ + #define Z3_MIN_PIN Z_STOP_PIN + #elif Z3_USE_ENDSTOP == _XDIAG_ + #define Z3_MIN_PIN X_DIAG_PIN + #elif Z3_USE_ENDSTOP == _YDIAG_ + #define Z3_MIN_PIN Y_DIAG_PIN + #elif Z3_USE_ENDSTOP == _ZDIAG_ + #define Z3_MIN_PIN Z_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E0DIAG_ + #define Z3_MIN_PIN E0_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E1DIAG_ + #define Z3_MIN_PIN E1_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E2DIAG_ + #define Z3_MIN_PIN E2_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E3DIAG_ + #define Z3_MIN_PIN E3_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E4DIAG_ + #define Z3_MIN_PIN E4_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E5DIAG_ + #define Z3_MIN_PIN E5_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E6DIAG_ + #define Z3_MIN_PIN E6_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E7DIAG_ + #define Z3_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif + #endif + + #if NUM_Z_STEPPERS >= 4 + #if Z_HOME_TO_MAX + #ifndef Z4_MAX_PIN + #if PIN_EXISTS(Z4_STOP) + #define Z4_MAX_PIN Z4_STOP_PIN + #elif Z4_USE_ENDSTOP == _XMIN_ + #define Z4_MAX_PIN X_MIN_PIN + #elif Z4_USE_ENDSTOP == _XMAX_ + #define Z4_MAX_PIN X_MAX_PIN + #elif Z4_USE_ENDSTOP == _XSTOP_ + #define Z4_MAX_PIN X_STOP_PIN + #elif Z4_USE_ENDSTOP == _YMIN_ + #define Z4_MAX_PIN Y_MIN_PIN + #elif Z4_USE_ENDSTOP == _YMAX_ + #define Z4_MAX_PIN Y_MAX_PIN + #elif Z4_USE_ENDSTOP == _YSTOP_ + #define Z4_MAX_PIN Y_STOP_PIN + #elif Z4_USE_ENDSTOP == _ZMIN_ + #define Z4_MAX_PIN Z_MIN_PIN + #elif Z4_USE_ENDSTOP == _ZMAX_ + #define Z4_MAX_PIN Z_MAX_PIN + #elif Z4_USE_ENDSTOP == _ZSTOP_ + #define Z4_MAX_PIN Z_STOP_PIN + #elif Z4_USE_ENDSTOP == _XDIAG_ + #define Z4_MAX_PIN X_DIAG_PIN + #elif Z4_USE_ENDSTOP == _YDIAG_ + #define Z4_MAX_PIN Y_DIAG_PIN + #elif Z4_USE_ENDSTOP == _ZDIAG_ + #define Z4_MAX_PIN Z_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E0DIAG_ + #define Z4_MAX_PIN E0_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E1DIAG_ + #define Z4_MAX_PIN E1_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E2DIAG_ + #define Z4_MAX_PIN E2_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E3DIAG_ + #define Z4_MAX_PIN E3_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E4DIAG_ + #define Z4_MAX_PIN E4_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E5DIAG_ + #define Z4_MAX_PIN E5_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E6DIAG_ + #define Z4_MAX_PIN E6_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E7DIAG_ + #define Z4_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef Z4_MIN_PIN + #if PIN_EXISTS(Z4_STOP) + #define Z4_MIN_PIN Z4_STOP_PIN + #elif Z4_USE_ENDSTOP == _XMIN_ + #define Z4_MIN_PIN X_MIN_PIN + #elif Z4_USE_ENDSTOP == _XMAX_ + #define Z4_MIN_PIN X_MAX_PIN + #elif Z4_USE_ENDSTOP == _XSTOP_ + #define Z4_MIN_PIN X_STOP_PIN + #elif Z4_USE_ENDSTOP == _YMIN_ + #define Z4_MIN_PIN Y_MIN_PIN + #elif Z4_USE_ENDSTOP == _YMAX_ + #define Z4_MIN_PIN Y_MAX_PIN + #elif Z4_USE_ENDSTOP == _YSTOP_ + #define Z4_MIN_PIN Y_STOP_PIN + #elif Z4_USE_ENDSTOP == _ZMIN_ + #define Z4_MIN_PIN Z_MIN_PIN + #elif Z4_USE_ENDSTOP == _ZMAX_ + #define Z4_MIN_PIN Z_MAX_PIN + #elif Z4_USE_ENDSTOP == _ZSTOP_ + #define Z4_MIN_PIN Z_STOP_PIN + #elif Z4_USE_ENDSTOP == _XDIAG_ + #define Z4_MIN_PIN X_DIAG_PIN + #elif Z4_USE_ENDSTOP == _YDIAG_ + #define Z4_MIN_PIN Y_DIAG_PIN + #elif Z4_USE_ENDSTOP == _ZDIAG_ + #define Z4_MIN_PIN Z_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E0DIAG_ + #define Z4_MIN_PIN E0_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E1DIAG_ + #define Z4_MIN_PIN E1_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E2DIAG_ + #define Z4_MIN_PIN E2_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E3DIAG_ + #define Z4_MIN_PIN E3_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E4DIAG_ + #define Z4_MIN_PIN E4_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E5DIAG_ + #define Z4_MIN_PIN E5_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E6DIAG_ + #define Z4_MIN_PIN E6_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E7DIAG_ + #define Z4_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif + #endif + +#endif // Z_MULTI_ENDSTOPS + // // 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 9150bf13655d..c5d5fcef78f7 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -136,27 +136,56 @@ #ifndef FAN1_PIN #ifdef MK3_FAN_PINS - #define FAN1_PIN -1 + #define FAN1_PIN -1 #else - #define FAN1_PIN 6 + #define FAN1_PIN 6 #endif #endif +/** + * ------ ------ ------ + * 84 PH2 | 1 2 | PH6 9 50 MISO | 1 2 | SCK 52 62 PK0 | 1 2 | PJ5 76 + * 61 PF7 | 3 4 | PD5 82 72 PJ2 | 3 4 | SDSS 77 20 SDA | 3 4 | GND + * 59 PF5 | 5 6 PG4 70 14 TX3 | 5 6 MOSI 51 21 SCL | 5 6 RX2 16 + * 85 PH7 | 7 8 | PG3 71 15 RX3 | 7 8 | RESET GND | 7 8 | TX2 17 + * GND | 9 10 | 5V GND | 9 10 | PE3 5 5V | 9 10 | 5V + * ------ ------ ------ + * P1 P2 P3 + */ + +#define EXP1_01_PIN 84 +#define EXP1_02_PIN 9 +#define EXP1_03_PIN 61 +#define EXP1_04_PIN 82 +#define EXP1_05_PIN 59 +#define EXP1_06_PIN 70 +#define EXP1_07_PIN 85 +#define EXP1_08_PIN 71 + +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 72 +#define EXP2_04_PIN 77 +#define EXP2_05_PIN 14 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 15 +#define EXP2_08_PIN -1 + // // Misc. Functions // -#define SDSS 77 +#define SDSS EXP2_04_PIN #define LED_PIN 13 #ifndef CASE_LIGHT_PIN - #define CASE_LIGHT_PIN 9 + #define CASE_LIGHT_PIN EXP1_02_PIN #endif // // M3/M4/M5 - Spindle/Laser Control // // use P1 connector for spindle pins -#define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM +#define SPINDLE_LASER_PWM_PIN EXP1_02_PIN // Hardware PWM #define SPINDLE_LASER_ENA_PIN 18 // Pullup! #define SPINDLE_DIR_PIN 19 @@ -179,20 +208,20 @@ #if IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS 85 - #define LCD_PINS_ENABLE 71 - #define LCD_PINS_D4 70 - #define BTN_EN1 61 - #define BTN_EN2 59 + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN #else - #define LCD_PINS_RS 82 - #define LCD_PINS_ENABLE 61 - #define LCD_PINS_D4 59 - #define LCD_PINS_D5 70 - #define LCD_PINS_D6 85 - #define LCD_PINS_D7 71 - #define BTN_EN1 14 - #define BTN_EN2 72 + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -200,9 +229,9 @@ #endif - #define BTN_ENC 9 // AUX-2 - #define BEEPER_PIN 84 // AUX-4 - #define SD_DETECT_PIN 15 + #define BTN_ENC EXP1_02_PIN // P1 + #define BEEPER_PIN EXP1_01_PIN // P1 + #define SD_DETECT_PIN EXP2_07_PIN #endif // IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/ramps/pins_3DRAG.h b/Marlin/src/pins/ramps/pins_3DRAG.h index 6f5b775af9ce..1e9d53a6cb58 100644 --- a/Marlin/src/pins/ramps/pins_3DRAG.h +++ b/Marlin/src/pins/ramps/pins_3DRAG.h @@ -66,6 +66,8 @@ #define MOSFET_C_PIN 9 #define MOSFET_D_PIN 12 +#define HEATER_2_PIN 6 + // // Misc. Functions // @@ -122,16 +124,6 @@ #endif #endif -#include "pins_RAMPS.h" - -// -// Heaters / Fans -// -#define HEATER_2_PIN 6 - -#undef SD_DETECT_PIN -#define SD_DETECT_PIN 53 - // // LCD / Controller // @@ -139,12 +131,6 @@ #undef BEEPER_PIN // TODO: Remap EXP1/2 based on adapter - #undef LCD_PINS_RS - #undef LCD_PINS_ENABLE - #undef LCD_PINS_D4 - #undef LCD_PINS_D5 - #undef LCD_PINS_D6 - #undef LCD_PINS_D7 #define LCD_PINS_RS 27 #define LCD_PINS_ENABLE 29 #define LCD_PINS_D4 37 @@ -153,13 +139,12 @@ #define LCD_PINS_D7 31 // Buttons - #undef BTN_EN1 - #undef BTN_EN2 - #undef BTN_ENC #define BTN_EN1 16 #define BTN_EN2 17 #define BTN_ENC 23 + #define LCD_PINS_DEFINED + #else #define BEEPER_PIN 33 @@ -171,3 +156,7 @@ #define BOARD_ST7920_DELAY_2 188 #define BOARD_ST7920_DELAY_3 0 #endif + +#define SD_DETECT_PIN 53 + +#include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_K8400.h b/Marlin/src/pins/ramps/pins_K8400.h index 36c438aca2de..686c29b7fb8f 100644 --- a/Marlin/src/pins/ramps/pins_K8400.h +++ b/Marlin/src/pins/ramps/pins_K8400.h @@ -50,6 +50,10 @@ #define X_STOP_PIN 3 #define Y_STOP_PIN 14 +#if EITHER(BLTOUCH, TOUCH_MI_PROBE) + #define HAS_INVERTED_PROBE +#endif + #include "pins_3DRAG.h" // ... RAMPS // diff --git a/Marlin/src/pins/ramps/pins_K8600.h b/Marlin/src/pins/ramps/pins_K8600.h index a9613e8eb27f..e4468a609882 100644 --- a/Marlin/src/pins/ramps/pins_K8600.h +++ b/Marlin/src/pins/ramps/pins_K8600.h @@ -37,8 +37,7 @@ // #define X_MIN_PIN 3 #define Y_MAX_PIN 14 -#define Z_MAX_PIN 18 -#define Z_MIN_PIN -1 +#define Z_STOP_PIN 18 // // Steppers @@ -48,6 +47,7 @@ // // Heaters / Fans // +#define HEATER_BED_PIN -1 #define FAN_PIN 8 // @@ -56,28 +56,11 @@ #define SDSS 25 #define CASE_LIGHT_PIN 7 -// -// Other RAMPS pins -// -#include "pins_RAMPS.h" - -// -// Heaters / Fans -// -#undef HEATER_BED_PIN - // // LCD / Controller // #if HAS_WIRED_LCD && IS_NEWPANEL - #undef BEEPER_PIN - #undef LCD_PINS_RS - #undef LCD_PINS_ENABLE - #undef LCD_PINS_D4 - #undef LCD_PINS_D5 - #undef LCD_PINS_D6 - #undef LCD_PINS_D7 #define LCD_PINS_RS 27 #define LCD_PINS_ENABLE 29 #define LCD_PINS_D4 37 @@ -86,15 +69,19 @@ #define LCD_PINS_D7 31 // Buttons - #undef BTN_EN1 - #undef BTN_EN2 - #undef BTN_ENC #define BTN_EN1 17 #define BTN_EN2 16 #define BTN_ENC 23 + #define LCD_PINS_DEFINED + #else #define BEEPER_PIN 33 #endif + +// +// Other RAMPS pins +// +#include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index af1d33c83c60..51f9cd80381c 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -33,56 +33,68 @@ #endif #if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || SERIAL_PORT_3 == 1 - #warning "Serial 1 is originally reserved to DGUS LCD." + #warning "Serial 1 is originally reserved for DGUS LCD." #endif #if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || SERIAL_PORT_3 == 2 || LCD_SERIAL_PORT == 2 #warning "Serial 2 has no connector. Hardware changes may be required to use it." #endif #if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || SERIAL_PORT_3 == 3 || LCD_SERIAL_PORT == 3 - #define CHANGE_Y_LIMIT_PINS - #warning "Serial 3 is originally reserved to Y limit switches. Hardware changes are required to use it." + #warning "Serial 3 is originally reserved for Y limit switches. Hardware changes are required to use it." + #define Y_STOP_PIN 37 + #if MB(LONGER3D_LKx_PRO) + #define Z_STOP_PIN 35 + #endif #endif -// Custom flags and defines for the build -//#define BOARD_CUSTOM_BUILD_FLAGS -D__FOO__ - #define BOARD_INFO_NAME "LGT KIT V1.0" +#if ENABLED(LONGER_LK5) + #define DEFAULT_MACHINE_NAME "LONGER LK5" +#else + #define DEFAULT_MACHINE_NAME "LONGER 3D Printer" +#endif // // Servos // -#if !MB(LONGER3D_LK1_PRO) +#if MB(LONGER3D_LKx_PRO) #define SERVO0_PIN 7 #endif -#define SERVO1_PIN -1 -#define SERVO2_PIN -1 -#define SERVO3_PIN -1 +#define SERVO1_PIN -1 +#define SERVO2_PIN -1 +#define SERVO3_PIN -1 // // Limit Switches // -#define X_STOP_PIN 3 - -#ifdef CHANGE_Y_LIMIT_PINS - #define Y_STOP_PIN 37 +#if ENABLED(LONGER_LK5) + #define X_MIN_PIN 3 + #define X_MAX_PIN 2 #else - #define Y_MIN_PIN 14 - #define Y_MAX_PIN 15 + #define X_STOP_PIN 3 #endif -#if !MB(LONGER3D_LK1_PRO) - #ifdef CHANGE_Y_LIMIT_PINS - #define Z_STOP_PIN 35 +#if !ANY_PIN(Y_MIN, Y_MAX, Y_STOP) + #if ENABLED(LONGER_LK5) + #define Y_STOP_PIN 14 #else + #define Y_MIN_PIN 14 + #define Y_MAX_PIN 15 + #endif +#endif + +#if !ANY_PIN(Z_MIN, Z_MAX, Z_STOP) + #if MB(LONGER3D_LKx_PRO) #define Z_MIN_PIN 35 - #define Z_MAX_PIN 37 + #else + #define Z_MIN_PIN 11 #endif -#else - #define Z_MIN_PIN 11 #define Z_MAX_PIN 37 #endif -#undef CHANGE_Y_LIMIT_PINS +// +// Z Probe (when not Z_MIN_PIN) +// +#define Z_MIN_PROBE_PIN -1 // // Steppers - No E1 pins @@ -92,11 +104,6 @@ #define E1_ENABLE_PIN -1 #define E1_CS_PIN -1 -// -// Z Probe (when not Z_MIN_PIN) -// -#define Z_MIN_PROBE_PIN -1 - // // Temperature Sensors // @@ -115,7 +122,36 @@ #define SD_DETECT_PIN 49 #define FIL_RUNOUT_PIN 2 +// ------------------ ---------------- --------------- ------------- +// Aux-1 | D19 D18 GND 5V | J21 | D4 D5 D6 GND | J17 | D11 GND 24V | J18 | D7 GND 5V | +// ------------------ ---------------- --------------- ------------- + +#if BOTH(CR10_STOCKDISPLAY, LONGER_LK5) + /** CR-10 Stock Display + * ------ + * GND | 9 10 | 5V + * LCD_PINS_RS D5 | 7 8 | D4 LCD_PINS_ENABLE + * BTN_EN2 D19 | 5 6 D6 LCD_PINS_D4 + * BTN_EN1 D18 | 3 4 | GND + * BEEPER_PIN D11 | 1 2 | D15 BTN_ENC + * ------ + * Connected via provided custom cable to: + * Aux-1, J21, J17 and Y-Max. + */ + #define LCD_PINS_RS 5 + #define LCD_PINS_ENABLE 4 + #define LCD_PINS_D4 6 + #define BTN_EN1 18 + #define BTN_EN2 19 + #define BTN_ENC 15 + #define BEEPER_PIN 11 + + #define SDCARD_CONNECTION ONBOARD + + #define LCD_PINS_DEFINED +#endif + // // Other RAMPS 1.3 pins // -#include "pins_RAMPS_13.h" // ... RAMPS +#include "pins_RAMPS_13.h" // ... pins_RAMPS.h diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h index 7a8c99e3af1c..1e354a10dcf2 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h @@ -40,7 +40,9 @@ // Heaters / Fans // // Power outputs EFBF or EFBE -#define MOSFET_D_PIN 7 +// +#define MOSFET_B_PIN 7 +#define FAN_PIN 9 // // PSU / SERVO diff --git a/Marlin/src/pins/ramps/pins_ORTUR_4.h b/Marlin/src/pins/ramps/pins_ORTUR_4.h index bc86c1a8c66a..e47bae191520 100644 --- a/Marlin/src/pins/ramps/pins_ORTUR_4.h +++ b/Marlin/src/pins/ramps/pins_ORTUR_4.h @@ -75,31 +75,25 @@ #define E0_SERIAL_RX_PIN 65 #endif -#include "pins_RAMPS.h" - // // LCD / Controller // #if IS_RRD_FG_SC - #undef BEEPER_PIN #define BEEPER_PIN 35 - #undef LCD_PINS_RS - #undef LCD_PINS_ENABLE - #undef LCD_PINS_D4 #define LCD_PINS_RS 27 #define LCD_PINS_ENABLE 23 #define LCD_PINS_D4 37 - #undef LCD_SDSS - #undef SD_DETECT_PIN #define LCD_SDSS 53 #define SD_DETECT_PIN 49 - #undef BTN_EN1 - #undef BTN_EN2 - #undef BTN_ENC #define BTN_EN1 29 #define BTN_EN2 25 #define BTN_ENC 16 + + #define LCD_PINS_DEFINED + #endif + +#include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index a0edb01a2a36..4e4ca6058389 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -233,16 +233,22 @@ #define HEATER_0_PIN MOSFET_A_PIN #if FET_ORDER_EFB // Hotend, Fan, Bed - #define HEATER_BED_PIN MOSFET_C_PIN + #ifndef HEATER_BED_PIN + #define HEATER_BED_PIN MOSFET_C_PIN + #endif #elif FET_ORDER_EEF // Hotend, Hotend, Fan #define HEATER_1_PIN MOSFET_B_PIN #elif FET_ORDER_EEB // Hotend, Hotend, Bed #define HEATER_1_PIN MOSFET_B_PIN - #define HEATER_BED_PIN MOSFET_C_PIN + #ifndef HEATER_BED_PIN + #define HEATER_BED_PIN MOSFET_C_PIN + #endif #elif FET_ORDER_EFF // Hotend, Fan, Fan #define FAN1_PIN MOSFET_C_PIN #elif DISABLED(FET_ORDER_SF) // Not Spindle, Fan (i.e., "EFBF" or "EFBE") - #define HEATER_BED_PIN MOSFET_C_PIN + #ifndef HEATER_BED_PIN + #define HEATER_BED_PIN MOSFET_C_PIN + #endif #if EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) #define HEATER_1_PIN MOSFET_D_PIN #else @@ -579,7 +585,7 @@ // LCDs and Controllers // ////////////////////////// -#if HAS_WIRED_LCD +#if HAS_WIRED_LCD && DISABLED(LCD_PINS_DEFINED) //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 @@ -709,7 +715,9 @@ #define BTN_EN1 AUX2_05_PIN #define BTN_EN2 AUX2_03_PIN #define BTN_ENC AUX2_04_PIN - #define SD_DETECT_PIN AUX2_08_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN AUX2_08_PIN + #endif #elif ENABLED(LCD_I2C_PANELOLU2) @@ -726,7 +734,9 @@ #define BTN_ENC -1 #define LCD_SDSS SDSS - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #elif EITHER(VIKI2, miniVIKI) @@ -742,7 +752,9 @@ #define BTN_EN2 7 #define BTN_ENC AUX4_08_PIN - #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + #endif #define KILL_PIN EXP2_03_PIN #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) @@ -758,7 +770,9 @@ #define BTN_ENC EXP2_03_PIN #define LCD_SDSS SDSS - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #define KILL_PIN EXP2_08_PIN #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) @@ -827,7 +841,9 @@ #define BTN_EN2 AUX2_04_PIN #define BTN_ENC AUX2_03_PIN - #define SD_DETECT_PIN AUX3_02_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN AUX3_02_PIN + #endif #define KILL_PIN AUX2_05_PIN #elif ENABLED(ZONESTAR_LCD) @@ -842,7 +858,9 @@ #define BEEPER_PIN EXP1_01_PIN - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #define KILL_PIN EXP2_08_PIN #define BTN_EN1 EXP2_05_PIN @@ -851,7 +869,9 @@ #elif IS_TFTGLCD_PANEL - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #else @@ -870,7 +890,7 @@ #endif #endif // IS_NEWPANEL -#endif // HAS_WIRED_LCD +#endif // HAS_WIRED_LCD && !LCD_PINS_DEFINED #if IS_RRW_KEYPAD && !HAS_ADC_BUTTONS #define SHIFT_OUT_PIN AUX2_06_PIN @@ -927,7 +947,9 @@ #define BEEPER_PIN EXP1_01_PIN - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #define CLCD_MOD_RESET EXP2_05_PIN #define CLCD_SPI_CS EXP2_03_PIN diff --git a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h index 2d68577f7c86..273e0274a8e7 100644 --- a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h +++ b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h @@ -103,9 +103,9 @@ // Direction buttons #define BTN_UP 37 - #define BTN_DWN 35 - #define BTN_LFT 33 - #define BTN_RT 32 + #define BTN_DOWN 35 + #define BTN_LEFT 33 + #define BTN_RIGHT 32 // 'R' button #undef BTN_ENC diff --git a/Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h b/Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h new file mode 100644 index 000000000000..b3f7d5f216b5 --- /dev/null +++ b/Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h @@ -0,0 +1,155 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * Tenlog pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Tenlog supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Tenlog MB1 V2.3" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 14 +//#define Y_MAX_PIN 15 // Connected to "DJ" plug on extruder heads +#define Z_MIN_PIN 18 +#if ENABLED(BLTOUCH) + #define SERVO0_PIN 19 +#else + #define Z_MAX_PIN 19 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 + +#define X2_STEP_PIN 36 +#define X2_DIR_PIN 34 +#define X2_ENABLE_PIN 30 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 + +#define Z2_STEP_PIN 65 +#define Z2_DIR_PIN 66 +#define Z2_ENABLE_PIN 64 + +#define E0_STEP_PIN 57 +#define E0_DIR_PIN 58 +#define E0_ENABLE_PIN 59 + +#define E1_STEP_PIN 26 +#define E1_DIR_PIN 28 +#define E1_ENABLE_PIN 24 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 15 // Analog Input +#define TEMP_1_PIN 13 // Analog Input +#define TEMP_BED_PIN 14 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 11 +#define HEATER_1_PIN 10 +#define HEATER_BED_PIN 8 + +#define FAN_PIN 9 +#define FAN2_PIN 5 // Normally this would be a servo pin + +//#define NUM_RUNOUT_SENSORS 0 +#define FIL_RUNOUT_PIN 15 +//#define FIL_RUNOUT2_PIN 21 + +// +// PSU and Powerloss Recovery +// +#if ENABLED(PSU_CONTROL) + #define PS_ON_PIN 40 // The M80/M81 PSU pin for boards v2.1-2.3 +#endif + +// +// Misc. Functions +// +//#define CASE_LIGHT_PIN 5 +//#ifndef LED_PIN +// #define LED_PIN 13 +//#endif + +#if HAS_CUTTER + //#define SPINDLE_LASER_PWM_PIN -1 // Hardware PWM + //#define SPINDLE_LASER_ENA_PIN 4 // Pullup! +#endif + +// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector +//#define FILWIDTH_PIN 5 // Analog Input + +#define SDSS 53 +#define SD_DETECT_PIN 49 + +// +// LCD / Controller +// + +//#if IS_RRD_SC + +//#ifndef BEEPER_PIN +// #define BEEPER_PIN -1 +//#endif + +#define LCD_PINS_RS -1 +#define LCD_PINS_ENABLE -1 +#define LCD_PINS_D4 -1 +#define LCD_PINS_D5 -1 +#define LCD_PINS_D6 -1 +#define LCD_PINS_D7 -1 + +//#define BTN_EN1 31 +//#define BTN_EN2 33 +//#define BTN_ENC 35 + +//#ifndef KILL_PIN +// #define KILL_PIN 41 +//#endif + +//#endif // IS_RRD_SC diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index b685ff0094d0..96c3fced4cc1 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -40,78 +40,95 @@ // // PWM FETS // -#if EITHER(FET_ORDER_EEF, FET_ORDER_EEB) - #define MOSFET_B_PIN 45 // HEATER1 -#elif FET_ORDER_EFB - #define MOSFET_B_PIN 9 // FAN0 -#else - #define MOSFET_B_PIN 7 // FAN1 -#endif - -#if FET_ORDER_EEB - #define MOSFET_C_PIN 8 // BED -#elif FET_ORDER_EFB - #if DISABLED(ANYCUBIC_LCD_CHIRON) - #define MOSFET_C_PIN 8 - #else - #define MOSFET_C_PIN 45 - #endif -#else // EEF, EFF - #define MOSFET_C_PIN 9 -#endif - -#if FET_ORDER_EEB - #define FAN_PIN 9 // Override pin 4 in pins_RAMPS.h -#endif +#define MOSFET_B_PIN 45 // HEATER1 // // Heaters / Fans // -#if ANY(FET_ORDER_EEF, FET_ORDER_EEB, FET_ORDER_EFB) - #define FAN1_PIN 7 -#endif -#define FAN2_PIN 44 +#define FAN_PIN 9 // FAN0 +#define FAN1_PIN 7 // FAN1 +#define FAN2_PIN 44 // FAN2 #ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN 44 // Used in Anycubic Kossel example config -#endif -#if ENABLED(ANYCUBIC_LCD_I3MEGA) - #define CONTROLLER_FAN_PIN 7 + #define E0_AUTO_FAN_PIN FAN2_PIN #endif // -// AnyCubic standard pin mappings +// AnyCubic pin mappings +// +// Define the appropriate mapping option in Configuration.h: +// - TRIGORILLA_MAPPING_CHIRON +// - TRIGORILLA_MAPPING_I3MEGA // -// On most printers, endstops are NOT all wired to the appropriate pins on the Trigorilla board. -// For instance, on a Chiron, Y axis goes to an aux connector. -// There are also other things that have been wired in creative ways. -// To enable PIN definitions for a specific printer model, #define the appropriate symbol after -// MOTHERBOARD in Configuration.h // // Limit Switches // //#define ANYCUBIC_4_MAX_PRO_ENDSTOPS - #if ENABLED(ANYCUBIC_4_MAX_PRO_ENDSTOPS) #define X_MAX_PIN 43 #define Y_STOP_PIN 19 -#elif EITHER(ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_I3MEGA) - #define Y_STOP_PIN 42 - #define Z2_MIN_PIN 43 +#elif EITHER(TRIGORILLA_MAPPING_CHIRON, TRIGORILLA_MAPPING_I3MEGA) + // Chiron uses AUX header for Y and Z endstops + #define Y_STOP_PIN 42 // AUX + #define Z_STOP_PIN 43 // AUX + #define Z2_MIN_PIN 18 // Z- + #ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN 2 #endif - #ifndef FIL_RUNOUT_PIN - #if ENABLED(ANYCUBIC_LCD_CHIRON) + + #define CONTROLLER_FAN_PIN FAN1_PIN + + #if ENABLED(POWER_LOSS_RECOVERY) + #define OUTAGETEST_PIN 79 + #define OUTAGECON_PIN 58 + #endif + + #if ENABLED(TRIGORILLA_MAPPING_CHIRON) + #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 33 - #else + #endif + #define HEATER_BED_PIN MOSFET_B_PIN // HEATER1 + #else + #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 19 #endif #endif + + #if EITHER(TRIGORILLA_MAPPING_CHIRON, SWAP_Z_MOTORS) + // Chiron and some Anycubic i3 MEGAs swap Z steppers + #define Z_STEP_PIN 36 + #define Z_DIR_PIN 34 + #define Z_ENABLE_PIN 30 + #define Z_CS_PIN 44 + + #define Z2_STEP_PIN 46 + #define Z2_DIR_PIN 48 + #define Z2_ENABLE_PIN 62 + #define Z2_CS_PIN 40 + #endif +#endif + +#if EITHER(ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_I3MEGA) #define BEEPER_PIN 31 #define SD_DETECT_PIN 49 #endif +#if HAS_TMC_UART + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN SERVO1_PIN + #endif + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN SERVO0_PIN + #endif + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN SERVO3_PIN + #endif + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN SERVO2_PIN + #endif +#endif + #include "pins_RAMPS.h" // diff --git a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h index 128f1974e0e6..0b15cd35ade9 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h @@ -107,8 +107,8 @@ #define SDSS 53 #define SD_DETECT_PIN 39 #define LED_PIN 8 -#define SAFETY_TRIGGERED_PIN 28 // PIN to detect the safety circuit has triggered -#define MAIN_VOLTAGE_MEASURE_PIN 14 // ANALOG PIN to measure the main voltage, with a 100k - 4k7 resitor divider. +//#define SAFETY_TRIGGERED_PIN 28 // PIN to detect the safety circuit has triggered +//#define MAIN_VOLTAGE_MEASURE_PIN 14 // ANALOG PIN to measure the main voltage, with a 100k - 4k7 resitor divider. // // LCD / Controller diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V20.h b/Marlin/src/pins/ramps/pins_ZRIB_V20.h index e9328ca7bae9..3e236e36ba99 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V20.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V20.h @@ -26,62 +26,37 @@ * V2 and V3 Boards only differ in USB controller, nothing affecting the pins. */ -#include "pins_MKS_GEN_13.h" // ... RAMPS - -#define ZRIB_V20_D6_PIN 6 // Fan -#define ZRIB_V20_D9_PIN 9 // Fan2 -#define ZRIB_V20_A10_PIN 10 -#define ZRIB_V20_D16_PIN 16 -#define ZRIB_V20_D17_PIN 17 -#define ZRIB_V20_D23_PIN 23 -#define ZRIB_V20_D25_PIN 25 -#define ZRIB_V20_D27_PIN 27 -#define ZRIB_V20_D29_PIN 29 -#define ZRIB_V20_D37_PIN 37 +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 11 // Analog Input +#endif // // Auto fans // #ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN ZRIB_V20_D6_PIN + #define E0_AUTO_FAN_PIN 6 // Fan #endif #ifndef E1_AUTO_FAN_PIN - #define E1_AUTO_FAN_PIN ZRIB_V20_D6_PIN + #define E1_AUTO_FAN_PIN 6 #endif #ifndef E2_AUTO_FAN_PIN - #define E2_AUTO_FAN_PIN ZRIB_V20_D6_PIN + #define E2_AUTO_FAN_PIN 6 #endif #ifndef E3_AUTO_FAN_PIN - #define E3_AUTO_FAN_PIN ZRIB_V20_D6_PIN -#endif - -#ifndef FILWIDTH_PIN - #define FILWIDTH_PIN 11 // Analog Input + #define E3_AUTO_FAN_PIN 6 #endif #if ENABLED(ZONESTAR_LCD) - #undef LCD_PINS_RS - #undef LCD_PINS_ENABLE - #undef LCD_PINS_D4 - #undef LCD_PINS_D5 - #undef LCD_PINS_D6 - #undef LCD_PINS_D7 - #undef ADC_KEYPAD_PIN - #undef BEEPER_PIN - - #undef SHIFT_OUT_PIN - #undef SHIFT_CLK_PIN - #undef SHIFT_LD_PIN - #undef BTN_EN1 - #undef BTN_EN2 - #undef BTN_ENC - - #define LCD_PINS_RS ZRIB_V20_D16_PIN - #define LCD_PINS_ENABLE ZRIB_V20_D17_PIN - #define LCD_PINS_D4 ZRIB_V20_D23_PIN - #define LCD_PINS_D5 ZRIB_V20_D25_PIN - #define LCD_PINS_D6 ZRIB_V20_D27_PIN - #define LCD_PINS_D7 ZRIB_V20_D29_PIN - #define ADC_KEYPAD_PIN ZRIB_V20_A10_PIN - #define BEEPER_PIN ZRIB_V20_D37_PIN + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + #define ADC_KEYPAD_PIN 10 // Analog Input + #define BEEPER_PIN 37 + + #define LCD_PINS_DEFINED #endif + +#include "pins_MKS_GEN_13.h" // ... RAMPS diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V52.h b/Marlin/src/pins/ramps/pins_ZRIB_V52.h index 2df789cd6f7f..44e0beaa9fb9 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V52.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V52.h @@ -47,6 +47,16 @@ #define E2_DIR_PIN 5 #define E2_ENABLE_PIN 22 +// +// Servos / XS3 Connector +// +#ifndef SERVO0_PIN + #define SERVO0_PIN 65 // PWM +#endif +#ifndef SERVO1_PIN + #define SERVO1_PIN 66 // PWM +#endif + #include "pins_MKS_BASE_common.h" // ... RAMPS /** @@ -78,20 +88,13 @@ * | GND | * ========== * - * XS3 Connector + * Servos / XS3 Connector * ================= * | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 * |----|-----|----| * | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 * ================= * - * Servos Connector - * ================= - * | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 - * |----|-----|----| - * | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 - * ================= - * * ICSP * ================= * | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V53.h b/Marlin/src/pins/ramps/pins_ZRIB_V53.h index cae71f7a8f6e..7a5cf1479166 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V53.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V53.h @@ -62,10 +62,10 @@ // Servos / XS3 Connector // #ifndef SERVO0_PIN - #define SERVO0_PIN 11 // Analog Output + #define SERVO0_PIN 65 // PWM #endif #ifndef SERVO1_PIN - #define SERVO1_PIN 12 // Analog Output + #define SERVO1_PIN 66 // PWM #endif // @@ -424,18 +424,12 @@ * |--------| Power * | GND | * ========== - * XS3 Connector + * Servos / XS3 Connector * ================= * | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 * |----|-----|----| * | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 * ================= - * XS3/Servos Connector - * ================= - * | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 - * |----|-----|----| - * | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 - * ================= * ICSP * ================= * | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI diff --git a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h index 70c3853dc941..76431937a712 100644 --- a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h +++ b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h @@ -85,6 +85,13 @@ #define Z_MS1_PIN 44 // PC19 #define E0_MS1_PIN 45 // PC18 +#ifndef MICROSTEP16 + #define MICROSTEP16 LOW,LOW,LOW +#endif +#ifndef MICROSTEP32 + #define MICROSTEP32 HIGH,HIGH,LOW +#endif + //#define MOTOR_FAULT_PIN 22 // PB26 , motor X-Y-Z-E0 motor FAULT // diff --git a/Marlin/src/pins/samd/pins_MINITRONICS20.h b/Marlin/src/pins/samd/pins_MINITRONICS20.h new file mode 100644 index 000000000000..02d806b3eccf --- /dev/null +++ b/Marlin/src/pins/samd/pins_MINITRONICS20.h @@ -0,0 +1,556 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * ReprapWorld's Minitronics v2.0 + */ + +#if NOT_TARGET(__SAMD21__) + #error "Oops! Select 'Minitronics v2.0' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Minitronics V2.0" +#endif + +/** + * NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1 + */ + +/** + * EEPROM EMULATION: Works with some bugs already, but the board needs an I2C EEPROM memory soldered on. + */ +//#define FLASH_EEPROM_EMULATION +//#define I2C_EEPROM // EEPROM on I2C-0 +#define MARLIN_EEPROM_SIZE 500 // 4000 bytes + +//This its another option to emulate an EEPROM, but its more efficient to dont loose the data the first One. +//#define SDCARD_EEPROM_EMULATION + +// +// BLTouch +// +#define SERVO0_PIN 33 // BLTouch PWM + +// +// Limit Switches +// +#define X_STOP_PIN 54 +#define Y_STOP_PIN 55 +#define Z_STOP_PIN 4 + +/** + * NOTE: Useful if extra TMC2209 are to be used as independent axes. + * We need to configure the new digital PIN, for this we could configure on the board the extra pin of this stepper, for example as a MIN_PIN/MAX_PIN. This pin is the D14. + */ +//#define Z2_STOP_PIN 14 +//#define X2_STOP_PIN 14 +//#define Y2_STOP_PIN 14 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 12 +#endif + +// +// Steppers +// +#define X_STEP_PIN 1 +#define X_DIR_PIN 3 +#define X_ENABLE_PIN 0 + +#define Y_STEP_PIN 29 +#define Y_DIR_PIN 28 +#define Y_ENABLE_PIN 0 + +#define Z_STEP_PIN 16 +#define Z_DIR_PIN 17 +#define Z_ENABLE_PIN 0 + +#define E0_STEP_PIN 14 +#define E0_DIR_PIN 15 +#define E0_ENABLE_PIN 0 + +#define E1_STEP_PIN 20 +#define E1_DIR_PIN 13 +#define E1_ENABLE_PIN 21 + +// Filament runout. You may choose to use this pin for some other purpose. It's a normal GPIO that can be configured as I/O. +// For example, a switch to detect any kind of behavior, Power supply pin .... etc. +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 44 +#endif + +// This board have the option to use an extra TMC2209 stepper, one of the use could be as a second extruder. +#if EXTRUDERS < 2 + // TODO: Corregir aquí que cuando tenemos dos extrusores o lo que sea, utiliza los endstop que le sobran, osea los max, no hay Z2_endstop + #if NUM_Z_STEPPERS > 1 + #define Z2_STOP_PIN 14 + #endif +#else + // If we want to configure the extra stepper as a Extruder, we should have undef all of the extra motors. + #undef X2_DRIVER_TYPE + #undef Y2_DRIVER_TYPE + #undef Z2_DRIVER_TYPE + #undef Z3_DRIVER_TYPE + #undef Z4_DRIVER_TYPE + + // Si tenemos más de un extrusor lo que hacemos es definir el nuevo extrusor así como sus pines + // Acordarse de definir el #define TEMP_SENSOR_1, ya que este contiene el tipo de sonda del extrusor E1 + + #define FIL_RUNOUT2_PIN 14 + +#endif + +// +// Extruder / Bed +// + +// Temperature Sensors +#define TEMP_0_PIN 4 // T1 + +// You could use one of the ADC for a temp chamber if you don't use the second extruder, for example. +#if TEMP_SENSOR_CHAMBER > 0 + #define TEMP_CHAMBER_PIN 3 +#else + #define TEMP_1_PIN 2 // T3 +#endif + +#define TEMP_BED_PIN 3 // T2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 11 +#define HEATER_BED_PIN 6 +#define SPINDLE_LASER_PWM_PIN 6 + +// The board has 4 PWM fans, use and configure as desired +#define FAN_PIN 24 + +// +// LCD / Controller +// + +#if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_01_PIN EXP1_01_PIN + #define EXP3_02_PIN EXP1_02_PIN + #define EXP3_03_PIN EXP1_03_PIN + #define EXP3_04_PIN EXP1_04_PIN + #define EXP3_05_PIN EXP1_05_PIN + #define EXP3_06_PIN EXP1_06_PIN + #define EXP3_07_PIN EXP1_07_PIN + #define EXP3_08_PIN EXP1_08_PIN +#endif + +/************************************/ +/***** Configurations Section ******/ +/************************************/ + +/** + * This sections starts with the pins_RAMPS_144.h as example, after if you need any new + * display, you could use normal duponts and connect it with with the scheme showed before. + * Tested: + * - Ender 3 Old display (Character LCD) + * - Ender 3 New Serial DWING Display + * - Reprap Display + * - Ender 5 New Serial Display + * - Any Reprap character display like + */ + +#if HAS_WIRED_LCD + + // + // LCD Display output pins + // + + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define LCD_PINS_RS 18 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE MOSI // SID (MOSI) + #define LCD_PINS_D4 SCK // SCK (CLK) clock + + #define BTN_ENC 23 + #define BTN_EN1 27 + #define BTN_EN2 33 + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + // TO TEST + //#define LCD_PINS_RS EXP1_02_PIN + //#define LCD_PINS_ENABLE EXP2_05_PIN + //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 + //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 + //#define LCD_PINS_D6 EXP2_07_PIN + //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + // TO TEST + //#define LCD_PINS_RS EXP3_04_PIN + //#define LCD_PINS_ENABLE EXP3_03_PIN + //#define LCD_PINS_D4 EXP3_05_PIN + + #if !IS_NEWPANEL + // TO TEST + //#define BEEPER_PIN EXP3_05_PIN + #endif + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 + //#define LCD_PINS_ENABLE EXP2_07_PIN + //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 + //#define LCD_PINS_D5 EXP1_02_PIN + //#define LCD_PINS_D6 EXP2_05_PIN + //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + // TO TEST + //#define LCD_PINS_DC 25 // Set as output on init + //#define LCD_PINS_RS 27 // Pull low for 1s to init + // DOGM SPI LCD Support + //#define DOGLCD_CS 16 + //#define DOGLCD_MOSI 17 + //#define DOGLCD_SCK 23 + //#define DOGLCD_A0 LCD_PINS_DC + + #else + // Definitions for any standard Display + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #endif + + #define LCD_PINS_D7 EXP1_08_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP1_01_PIN + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN EXP1_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + //#define BEEPER_PIN EXP1_01_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + // TO TEST + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #else + // Definitions fpr any standard Display + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + + #define BTN_ENC EXP1_02_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif + //#define KILL_PIN EXP2_10_PIN + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + //#define LCD_BACKLIGHT_PIN EXP1_08_PIN // TO TEST + #endif + + #elif ENABLED(LCD_I2C_PANELOLU2) + + // TO TEST + //#define BTN_EN1 47 + //#define BTN_EN2 EXP2_03_PIN + //#define BTN_ENC 32 + //#define LCD_SDSS SDSS + //#define KILL_PIN EXP1_01_PIN + + #elif ENABLED(LCD_I2C_VIKI) + + // TO TEST + //#define BTN_EN1 EXP1_02_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_05_PIN + //#define BTN_ENC -1 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_10_PIN + + #elif EITHER(VIKI2, miniVIKI) + + // TO TEST + //#define DOGLCD_CS 45 + //#define DOGLCD_A0 EXP2_07_PIN + //#define LCD_SCREEN_ROT_180 + + //#define BEEPER_PIN 33 + //#define STAT_LED_RED_PIN 32 + //#define STAT_LED_BLUE_PIN EXP1_03_PIN + + //#define BTN_EN1 22 + //#define BTN_EN2 7 + //#define BTN_ENC EXP1_08_PIN + + //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + //#define KILL_PIN 31 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + // TO TEST + //#define DOGLCD_CS 29 + //#define DOGLCD_A0 27 + + //#define BEEPER_PIN 23 + //#define LCD_BACKLIGHT_PIN 33 + + //#define BTN_EN1 EXP1_03_PIN + //#define BTN_EN2 EXP1_06_PIN + //#define BTN_ENC 31 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN + + #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) + + // TO TEST + //#define BEEPER_PIN EXP1_06_PIN + //#define BTN_ENC EXP1_03_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + + //#ifndef KILL_PIN + // #define KILL_PIN EXP1_01_PIN + //#endif + + #if ENABLED(MKS_MINI_12864) + + // TO TEST + //#define DOGLCD_A0 27 + //#define DOGLCD_CS 25 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define BTN_EN1 31 + //#define BTN_EN2 33 + + #elif ENABLED(FYSETC_MINI_12864) + + // From https://wiki.fysetc.com/Mini12864_Panel/ + + // TO TEST + //#define DOGLCD_A0 16 + //#define DOGLCD_CS 17 + + //#define BTN_EN1 33 + //#define BTN_EN2 31 + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + //#define LCD_RESET_PIN 23 // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + // TO TEST + //#define RGB_LED_R_PIN 25 + #endif + #ifndef RGB_LED_G_PIN + // TO TEST + //#define RGB_LED_G_PIN 27 + #endif + #ifndef RGB_LED_B_PIN + // TO TEST + //#define RGB_LED_B_PIN 29 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + // TO TEST + //#define NEOPIXEL_PIN 25 + #endif + + #endif + + #elif ENABLED(MINIPANEL) + + // TO TEST + //#define BEEPER_PIN EXP2_05_PIN + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define DOGLCD_A0 EXP2_07_PIN + //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + //#define BTN_EN1 EXP1_02_PIN + //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 + //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 + + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define ADC_KEYPAD_PIN 12 + + #elif ENABLED(AZSMZ_12864) + + // TO TEST + + #else + + // Beeper on AUX-4 + //#define BEEPER_PIN 33 + + // Buttons are directly attached to AUX-2 + #if IS_RRW_KEYPAD + // TO TEST + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_CLK_PIN EXP2_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 + #elif ENABLED(PANEL_ONE) + // TO TEST + //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) + //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) + //#define BTN_ENC EXP2_10_PIN // AUX3 PIN 7 + #else + // TO TEST + //#define BTN_EN1 EXP1_06_PIN + //#define BTN_EN2 EXP1_03_PIN + //#define BTN_ENC 31 + #endif + + #if ENABLED(G3D_PANEL) + // TO TEST + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// +// SD Support +// + +#define SDSS 2 +#undef SD_DETECT_PIN +#define SD_DETECT_PIN 22 + +#if HAS_TMC_UART + + /** + * Address for the UART Configuration of the TMC2209. Override in Configuration files. + * To test TMC2209 Steppers enable TMC_DEBUG in Configuration_adv.h and test the M122 command with voltage on the steppers. + */ + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0b00 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 0b01 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 0b10 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0b11 + #endif + #ifndef E1_SLAVE_ADDRESS + #define E1_SLAVE_ADDRESS 0b00 + #endif + + /** + * TMC2208/TMC2209 stepper drivers + * It seems to work perfectly fine on Software Serial, if an advanced user wants to test, you could use the SAMD51 Serial1 and Serial 2. Be careful with the Sercom configurations. + * Steppers 1,2,3,4 (X,Y,Z,E0) are on the Serial1, Sercom (RX = 0, TX = 1), extra stepper 5 (E1 or any axis you want) is on Serial2, Sercom (RX = 17, TX = 16) + */ + + //#define X_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial2 + + #define TMC_BAUD_RATE 250000 + + // + // Software serial + // + #define X_SERIAL_TX_PIN 0 + #define X_SERIAL_RX_PIN 1 + + #define Y_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define Z_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Z_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E0_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define E0_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E1_SERIAL_TX_PIN 17 + #define E1_SERIAL_RX_PIN 16 + +#endif diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 2c42506a5f4d..7adb2404c158 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -452,7 +452,7 @@ //#define SD_DETECT_PIN 49 //#ifndef KILL_PIN - // #define KILL_PIN 41 + // #define KILL_PIN 41 //#endif #if ENABLED(MKS_MINI_12864) diff --git a/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h b/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h index 3edb14ec413f..4c721da00038 100644 --- a/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h +++ b/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h @@ -27,4 +27,6 @@ #define BOARD_INFO_NAME "Azteeg X1" +#define FAN_PIN 4 + #include "pins_SANGUINOLOLU_12.h" // ... SANGUINOLOLU_11 diff --git a/Marlin/src/pins/sanguino/pins_MELZI.h b/Marlin/src/pins/sanguino/pins_MELZI.h index e24636c8e03c..d6f9288e8c2f 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI.h +++ b/Marlin/src/pins/sanguino/pins_MELZI.h @@ -31,6 +31,10 @@ #define IS_MELZI 1 +#ifndef FAN_PIN + #define FAN_PIN 4 +#endif + // Alter timing for graphical display #if IS_U8GLIB_ST7920 #ifndef BOARD_ST7920_DELAY_1 diff --git a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h index 83aa5317f939..f508093c2257 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h @@ -42,24 +42,24 @@ #define BOARD_ST7920_DELAY_3 125 #endif -#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 - // // For the stock CR-10 enable CR10_STOCKDISPLAY in Configuration.h // -#undef LCD_SDSS -#undef LED_PIN -#undef LCD_PINS_RS -#undef LCD_PINS_ENABLE -#undef LCD_PINS_D4 -#undef LCD_PINS_D5 -#undef LCD_PINS_D6 -#undef LCD_PINS_D7 +#if ENABLED(CR10_STOCKDISPLAY) + #define LCD_SDSS 31 // Smart Controller SD card reader (rather than the Melzi) + #define LCD_PINS_RS 28 // ST9720 CS + #define LCD_PINS_ENABLE 17 // ST9720 DAT + #define LCD_PINS_D4 30 // ST9720 CLK + + #define BTN_ENC 16 + #define BTN_EN1 11 + #define BTN_EN2 10 + #define BEEPER_PIN 27 -#define LCD_SDSS 31 // Smart Controller SD card reader (rather than the Melzi) -#define LCD_PINS_RS 28 // ST9720 CS -#define LCD_PINS_ENABLE 17 // ST9720 DAT -#define LCD_PINS_D4 30 // ST9720 CLK + #define LCD_PINS_DEFINED +#endif + +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 #if ENABLED(BLTOUCH) #ifndef SERVO0_PIN diff --git a/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h b/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h index a0421dcf5cc6..d6f36cc6f541 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h @@ -27,19 +27,15 @@ #define BOARD_INFO_NAME "Melzi (Malyan)" -#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 +#if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS 17 // ST9720 CS + #define LCD_PINS_ENABLE 16 // ST9720 DAT + #define LCD_PINS_D4 11 // ST9720 CLK + #define BTN_EN1 30 + #define BTN_EN2 29 + #define BTN_ENC 28 -#undef LCD_SDSS -#undef LCD_PINS_RS -#undef LCD_PINS_ENABLE -#undef LCD_PINS_D4 -#undef BTN_EN1 -#undef BTN_EN2 -#undef BTN_ENC + #define LCD_PINS_DEFINED +#endif -#define LCD_PINS_RS 17 // ST9720 CS -#define LCD_PINS_ENABLE 16 // ST9720 DAT -#define LCD_PINS_D4 11 // ST9720 CLK -#define BTN_EN1 30 -#define BTN_EN2 29 -#define BTN_ENC 28 +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 diff --git a/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h b/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h index 3f7b36765f34..aecad10dabfd 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h @@ -27,6 +27,24 @@ #define BOARD_INFO_NAME "Melzi (Tronxy)" +#define Z_ENABLE_PIN 14 + +#define LCD_SDSS -1 + +#if EITHER(CR10_STOCKDISPLAY, LCD_FOR_MELZI) + #define LCD_PINS_RS 30 + #define LCD_PINS_ENABLE 28 + #define LCD_PINS_D4 16 + #define LCD_PINS_D5 17 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + #define BTN_EN1 10 + #define BTN_EN2 11 + #define BTN_ENC 26 + + #define LCD_PINS_DEFINED +#endif + // Alter timing for graphical display #if IS_U8GLIB_ST7920 #define BOARD_ST7920_DELAY_1 0 @@ -35,26 +53,3 @@ #endif #include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 - -#undef Z_ENABLE_PIN -#undef LCD_PINS_RS -#undef LCD_PINS_ENABLE -#undef LCD_PINS_D4 -#undef LCD_PINS_D5 -#undef LCD_PINS_D6 -#undef LCD_PINS_D7 -#undef BTN_EN1 -#undef BTN_EN2 -#undef BTN_ENC -#undef LCD_SDSS - -#define Z_ENABLE_PIN 14 -#define LCD_PINS_RS 30 -#define LCD_PINS_ENABLE 28 -#define LCD_PINS_D4 16 -#define LCD_PINS_D5 17 -#define LCD_PINS_D6 27 -#define LCD_PINS_D7 29 -#define BTN_EN1 10 -#define BTN_EN2 11 -#define BTN_ENC 26 diff --git a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h index 5fe0d3842dd4..3b6297ba4d1c 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h @@ -90,30 +90,18 @@ // #define HEATER_0_PIN 13 // (extruder) -#if ENABLED(SANGUINOLOLU_V_1_2) - - #define HEATER_BED_PIN 12 // (bed) - #define X_ENABLE_PIN 14 - #define Y_ENABLE_PIN 14 - #define Z_ENABLE_PIN 26 - #define E0_ENABLE_PIN 14 - - #if !defined(FAN_PIN) && ENABLED(LCD_I2C_PANELOLU2) - #define FAN_PIN 4 // Uses Transistor1 (PWM) on Panelolu2's Sanguino Adapter Board to drive the fan - #endif - -#else +#ifndef FAN_PIN + #define FAN_PIN 4 // Works for Panelolu2 too +#endif +#if DISABLED(SANGUINOLOLU_V_1_2) #define HEATER_BED_PIN 14 // (bed) #define X_ENABLE_PIN 4 #define Y_ENABLE_PIN 4 - #define Z_ENABLE_PIN 4 + #ifndef Z_ENABLE_PIN + #define Z_ENABLE_PIN 4 + #endif #define E0_ENABLE_PIN 4 - -#endif - -#if !defined(FAN_PIN) && (MB(AZTEEG_X1, STB_11) || IS_MELZI) - #define FAN_PIN 4 // Works for Panelolu2 too #endif // @@ -151,7 +139,7 @@ // // LCD / Controller // -#if HAS_WIRED_LCD +#if HAS_WIRED_LCD && DISABLED(LCD_PINS_DEFINED) #define SD_DETECT_PIN -1 @@ -245,7 +233,9 @@ #if IS_MELZI #define BTN_ENC 29 - #define LCD_SDSS 30 // Panelolu2 SD card reader rather than the Melzi + #ifndef LCD_SDSS + #define LCD_SDSS 30 // Panelolu2 SD card reader rather than the Melzi + #endif #else #define BTN_ENC 30 #endif @@ -253,7 +243,9 @@ #else // !LCD_FOR_MELZI && !ZONESTAR_LCD && !LCD_I2C_PANELOLU2 #define BTN_ENC 16 - #define LCD_SDSS 28 // Smart Controller SD card reader rather than the Melzi + #ifndef LCD_SDSS + #define LCD_SDSS 28 // Smart Controller SD card reader rather than the Melzi + #endif #endif diff --git a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h index c5c8b4f57e57..ec7621e28f3e 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h @@ -38,5 +38,17 @@ #define BOARD_INFO_NAME "Sanguinololu 1.2" #endif +#define HEATER_BED_PIN 12 // (bed) +#define X_ENABLE_PIN 14 +#define Y_ENABLE_PIN 14 +#ifndef Z_ENABLE_PIN + #define Z_ENABLE_PIN 26 +#endif +#define E0_ENABLE_PIN 14 + +#if !defined(FAN_PIN) && ENABLED(LCD_I2C_PANELOLU2) + #define FAN_PIN 4 // Uses Transistor1 (PWM) on Panelolu2's Sanguino Adapter Board to drive the fan +#endif + #define SANGUINOLOLU_V_1_2 #include "pins_SANGUINOLOLU_11.h" diff --git a/Marlin/src/pins/sanguino/pins_STB_11.h b/Marlin/src/pins/sanguino/pins_STB_11.h index ea36211f3bc9..ad0919e99e69 100644 --- a/Marlin/src/pins/sanguino/pins_STB_11.h +++ b/Marlin/src/pins/sanguino/pins_STB_11.h @@ -27,4 +27,8 @@ #define BOARD_INFO_NAME "STB V1.1" +#ifndef FAN_PIN + #define FAN_PIN 4 // Works for Panelolu2 too +#endif + #include "pins_SANGUINOLOLU_12.h" // ... SANGUINOLOLU_11 diff --git a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h index 4e8731c1cbf9..aa3ce556d16e 100644 --- a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h +++ b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h @@ -36,7 +36,7 @@ * If you don't have a chip programmer you can use a spare Arduino plus a few * electronic components to write the bootloader. * - * See http://www.instructables.com/id/Burn-Arduino-Bootloader-with-Arduino-MEGA/ + * See https://www.instructables.com/Burn-Arduino-Bootloader-with-Arduino-MEGA/ */ /** 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 f9c9de4f031e..075258991ddd 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -166,19 +166,28 @@ * EXP1 */ +#define EXP1_01_PIN PA15 +#define EXP1_02_PIN PB6 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN -1 // RESET +#define EXP1_05_PIN PA10 +#define EXP1_06_PIN PB9 +#define EXP1_07_PIN PB8 +#define EXP1_08_PIN PB7 + #if HAS_WIRED_LCD #if ENABLED(CR10_STOCKDISPLAY) - #define BEEPER_PIN PA15 + #define BEEPER_PIN EXP1_01_PIN - #define BTN_ENC PB6 - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_RS PB8 - #define LCD_PINS_ENABLE PB7 - #define LCD_PINS_D4 PB9 + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! @@ -186,12 +195,12 @@ #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_DIP.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define LCD_PINS_RS PB9 - #define LCD_PINS_ENABLE PB6 - #define LCD_PINS_D4 PB8 - #define LCD_PINS_D5 PA10 - #define LCD_PINS_D6 PA9 - #define LCD_PINS_D7 PA15 + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_02_PIN + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) @@ -207,19 +216,81 @@ * EXP1 */ - #define BTN_ENC PB6 - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define DOGLCD_CS PB8 - #define DOGLCD_A0 PB9 - #define DOGLCD_SCK PA15 - #define DOGLCD_MOSI PB7 + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN #define FORCE_SOFT_SPI #define LCD_BACKLIGHT_PIN -1 + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! FYSETC_MINI_12864_2_1 and it's clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_DIP.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + #if SD_CONNECTION_IS(LCD) + #error "The LCD SD Card is not supported with this configuration." + #endif + + /** + * FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 display pinout + * + * Board Display + * ------ ------ + * (NEOPIXEL) PA15 | 1 2 | PB6 (BTN_ENC) 5V |10 9 | GND + * (BTN_EN2) PA9 | 3 4 | RESET -- | 8 7 | -- + * (BTN_EN1) PA10 5 6 | PB9 (LCD_RESET) NEOPIXEL | 6 5 LCD RESET + * (LCD_A0) PB8 | 7 8 | PB7 (LCD_CS) LCD_A0 | 4 3 | LCD_CS + * GND | 9 10 | 5V BTN_ENC | 2 1 | BEEP + * ------ ------ + * EXP1 EXP1 + * + * + * ----- ------ + * | 1 | RST -- |10 9 | -- + * | 2 | PA3 RX2 RESET_BTN | 8 7 | SD_DETECT + * | 3 | PA2 TX2 LCD_MOSI | 6 5 EN2 + * | 4 | GND -- | 4 3 | EN1 + * | 5 | 5V LCD_SCK | 2 1 | -- + * ----- ------ + * TFT EXP2 + + * + * Needs custom cable. + * + * BOARD EXP1 NEOPIXEL <--> LCD EXP1 NEOPIXEL + * BOARD EXP1 BTN_ENC <--> LCD EXP1 BTN_ENC + * BOARD EXP1 BTN_EN2 <--> LCD EXP2 EN2 + * BOARD EXP1 RESET <--> LCD EXP2 RESET_BTN + * BOARD EXP1 BTN_EN1 <--> LCD EXP2 EN1 + * BOARD EXP1 LCD_RESET <--> LCD EXP1 LCD RESET + * BOARD EXP1 LCD_A0 <--> LCD EXP1 LCD_A0 + * BOARD EXP1 LCD_CS <--> LCD EXP1 LCD_CS + * BOARD TFT RX2 <--> LCD EXP2 LCD_MOSI + * BOARD TFT TX2 <--> LCD EXP2 LCD_SCK + */ + + #define NEOPIXEL_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define LCD_RESET_PIN EXP1_06_PIN + #define BEEPER_PIN -1 + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_08_PIN + + #define DOGLCD_SCK PA2 + #define DOGLCD_MOSI PA3 + + #define LCD_BACKLIGHT_PIN -1 + #define FORCE_SOFT_SPI + #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and MKS_LCD12864A/B are currently supported on the BIGTREE_SKR_E3_DIP." + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, FYSETC_MINI_12864_2_1 and MKS_LCD12864A/B are currently supported on the BIGTREE_SKR_E3_DIP." #endif #endif // HAS_WIRED_LCD @@ -260,10 +331,10 @@ #define CLCD_SPI_BUS 1 // SPI1 connector - #define BEEPER_PIN PB6 + #define BEEPER_PIN EXP1_02_PIN - #define CLCD_MOD_RESET PA9 - #define CLCD_SPI_CS PB8 + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN #endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 @@ -281,8 +352,8 @@ #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 + #define SD_DETECT_PIN EXP1_01_PIN + #define SD_SS_PIN EXP1_05_PIN #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "SD CUSTOM_CABLE is not compatible with SKR E3 DIP." #endif diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index b5fddc4d7494..c0428279f0fe 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -21,7 +21,9 @@ */ #pragma once -#define SKR_MINI_E3_V2 +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR Mini E3 V2.0" +#endif #define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 @@ -29,33 +31,50 @@ #if NO_EEPROM_SELECTED #define I2C_EEPROM #define SOFT_I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x1000 // 4K - #define I2C_SDA_PIN PB7 - #define I2C_SCL_PIN PB6 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K + #define I2C_SDA_PIN PB7 + #define I2C_SCL_PIN PB6 #undef NO_EEPROM_SELECTED #endif -#include "pins_BTT_SKR_MINI_E3_common.h" +#define FAN_PIN PC6 -#ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "BTT SKR Mini E3 V2.0" -#endif +// +// USB connect control +// +#define USB_CONNECT_PIN PA14 + +/** + * SKR Mini E3 V2.0 + * ------ + * (BEEPER) PB5 | 1 2 | PA15 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PB15 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ +#define EXP1_02_PIN PA15 +#define EXP1_08_PIN PB15 + +#include "pins_BTT_SKR_MINI_E3_common.h" // Release PA13/PA14 (led, usb control) from SWD pins #define DISABLE_DEBUG #ifndef NEOPIXEL_PIN - #define NEOPIXEL_PIN PA8 // LED driving pin + #define NEOPIXEL_PIN PA8 // LED driving pin #endif #ifndef PS_ON_PIN - #define PS_ON_PIN PC13 // Power Supply Control + #define PS_ON_PIN PC13 // Power Supply Control #endif -#define FAN1_PIN PC7 +#define FAN1_PIN PC7 #ifndef CONTROLLER_FAN_PIN - #define CONTROLLER_FAN_PIN FAN1_PIN + #define CONTROLLER_FAN_PIN FAN1_PIN #endif #if HAS_TMC_UART 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 537e905e2152..8ed09417f0df 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 @@ -100,41 +100,40 @@ #define HEATER_0_PIN PC8 // "HE" #define HEATER_BED_PIN PC9 // "HB" -#ifdef SKR_MINI_E3_V2 - #define FAN_PIN PC6 -#else +#ifndef FAN_PIN #define FAN_PIN PA8 // "FAN0" #endif // // USB connect control // -#ifdef SKR_MINI_E3_V2 - #define USB_CONNECT_PIN PA14 -#else +#ifndef USB_CONNECT_PIN #define USB_CONNECT_PIN PC13 #endif #define USB_CONNECT_INVERTING false /** - * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 - * ------ ------ - * (BEEPER) PB5 | 1 2 | PB6 (BTN_ENC) (BEEPER) PB5 | 1 2 | PA15 (BTN_ENC) - * (BTN_EN1) PA9 | 3 4 | RESET (BTN_EN1) PA9 | 3 4 | RESET - * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) - * (LCD_RS) PB8 | 7 8 | PB7 (LCD_EN) (LCD_RS) PB8 | 7 8 | PB15 (LCD_EN) - * GND | 9 10 | 5V GND | 9 10 | 5V - * ------ ------ - * EXP1 EXP1 + * SKR Mini E3 V1.0, V1.2 + * ------ + * (BEEPER) PB5 | 1 2 | PB6 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PB7 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 */ -#ifdef SKR_MINI_E3_V2 - #define EXP1_02_PIN PA15 - #define EXP1_08_PIN PB15 -#else +#ifndef EXP1_02_PIN #define EXP1_02_PIN PB6 #define EXP1_08_PIN PB7 #endif +#define EXP1_01_PIN PB5 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN -1 // RESET +#define EXP1_05_PIN PA10 +#define EXP1_06_PIN PB9 +#define EXP1_07_PIN PB8 #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI /** @@ -156,22 +155,22 @@ #define BEEPER_PIN EXP1_02_PIN #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 PB8 - #define BTN_ENC PB5 + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_01_PIN #elif HAS_WIRED_LCD #if ENABLED(CR10_STOCKDISPLAY) - #define BEEPER_PIN PB5 + #define BEEPER_PIN EXP1_01_PIN #define BTN_ENC EXP1_02_PIN - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_RS PB8 + #define LCD_PINS_RS EXP1_07_PIN #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 PB9 + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! @@ -179,23 +178,23 @@ #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define LCD_PINS_RS PB9 + #define LCD_PINS_RS EXP1_06_PIN #define LCD_PINS_ENABLE EXP1_02_PIN - #define LCD_PINS_D4 PB8 - #define LCD_PINS_D5 PA10 - #define LCD_PINS_D6 PA9 - #define LCD_PINS_D7 PB5 + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) #define BTN_ENC EXP1_02_PIN - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define DOGLCD_CS PB8 - #define DOGLCD_A0 PB9 - #define DOGLCD_SCK PB5 + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN #define DOGLCD_MOSI EXP1_08_PIN #define FORCE_SOFT_SPI @@ -238,7 +237,7 @@ * EXP1-1 ----------- EXP1-7 SD_DET */ - #define TFTGLCD_CS PA9 + #define TFTGLCD_CS EXP1_03_PIN #endif @@ -263,8 +262,8 @@ * * --- ------ * RST | 1 | (MISO) |10 9 | SCK - * (RX2) PA2 | 2 | BTN_EN1 | 8 7 | (SS) - * (TX2) PA3 | 3 | BTN_EN2 | 6 5 | MOSI + * (RX2) PA3 | 2 | BTN_EN1 | 8 7 | (SS) + * (TX2) PA2 | 3 | BTN_EN2 | 6 5 | MOSI * GND | 4 | (CD) | 4 3 | (RST) * 5V | 5 | (GND) | 2 1 | (KILL) * --- ------ @@ -279,32 +278,29 @@ * EXP1-8 ----------- EXP2-6 EN2 * EXP1-7 ----------- EXP1-5 RED * EXP1-6 ----------- EXP2-8 EN1 - * EXP1-5 ----------- EXP1-6 LCD_RST - * EXP1-4 ----------- n/c + * EXP1-5 ----------- n/c + * EXP1-4 ----------- EXP1-6 RESET * EXP1-3 ----------- EXP1-8 LCD_CS * EXP1-2 ----------- EXP1-9 ENC * EXP1-1 ----------- EXP1-7 LCD_A0 * - * TFT-2 ----------- EXP2-9 SCK - * TFT-3 ----------- EXP2-5 MOSI + * TFT-2 ----------- EXP2-5 SCK + * TFT-3 ----------- EXP2-9 MOSI * * for backlight configuration see steps 2 (V2.1) and 3 in https://wiki.fysetc.com/Mini12864_Panel/ */ - #define LCD_PINS_RS PA9 // CS - #define LCD_PINS_ENABLE PA3 // MOSI #define LCD_BACKLIGHT_PIN -1 - #define NEOPIXEL_PIN PB8 - #define LCD_CONTRAST 255 - #define LCD_RESET_PIN PA10 + #define NEOPIXEL_PIN EXP1_07_PIN + #define LCD_CONTRAST 255 - #define DOGLCD_CS PA9 - #define DOGLCD_A0 PB5 + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_01_PIN #define DOGLCD_SCK PA2 #define DOGLCD_MOSI PA3 #define BTN_ENC PA15 - #define BTN_EN1 PB9 + #define BTN_EN1 EXP1_06_PIN #define BTN_EN2 PB15 #define FORCE_SOFT_SPI @@ -354,8 +350,8 @@ #define BEEPER_PIN EXP1_02_PIN - #define CLCD_MOD_RESET PA9 - #define CLCD_SPI_CS PB8 + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN #endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 @@ -370,8 +366,8 @@ #if SD_CONNECTION_IS(ONBOARD) #define SD_DETECT_PIN PC4 #elif SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL) - #define SD_DETECT_PIN PB5 - #define SD_SS_PIN PA10 + #define SD_DETECT_PIN EXP1_01_PIN + #define SD_SS_PIN EXP1_05_PIN #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." #endif diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h index 4e343fa8cdff..c544e1353c1f 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -140,7 +140,38 @@ // // LCD / Controller // -#if HAS_WIRED_LCD +#if EITHER(TFT_COLOR_UI, TFT_CLASSIC_UI) + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN EXP1_04_PIN + + #define LCD_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 3 + + #define TOUCH_CS_PIN EXP1_05_PIN // SPI3_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI3_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI3_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI3_MOSI + + #define LCD_READ_ID 0xD3 + #define LCD_USE_DMA_SPI + + #define TFT_BUFFER_SIZE 9600 + +#elif HAS_WIRED_LCD #define BEEPER_PIN EXP1_01_PIN #define BTN_ENC EXP1_02_PIN @@ -253,5 +284,7 @@ #define SD_MOSI_PIN PA7 #define SD_SS_PIN PA4 #endif + #define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card +#define SDSS SD_SS_PIN diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h index 53b6797e91d2..f4cecc21c260 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h @@ -23,6 +23,14 @@ #define BOARD_INFO_NAME "Chitu3D V5" -#define Z_STOP_PIN PA14 +// +// Servos +// +#define SERVO0_PIN PA13 // Z+ (behind FILAMENT) Pinout [+5v|G|S] + +// +// Limit Switches +// +#define Z_STOP_PIN PA14 // Pinout [+12/24v|G|S] #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 b76ef52c420a..89e07d6a21e8 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h @@ -27,6 +27,8 @@ #define Z2_STEP_PIN PF5 #define Z2_DIR_PIN PF1 +#define Z_STOP_PIN PA14 + #ifndef FIL_RUNOUT2_PIN #define FIL_RUNOUT2_PIN PF13 #endif diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h index bc41e97041fc..f5dd4a42b0f6 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h @@ -114,8 +114,8 @@ #endif // SPI Flash -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x200000 // 2MB #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index 5a3e7337adac..f633ee0983c0 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -161,91 +161,148 @@ #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer -#if ENABLED(CR10_STOCKDISPLAY) +#if ANY(RET6_12864_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) + + /** + * RET6 12864 LCD + * ------ + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PB11 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN PC6 + #define EXP3_02_PIN PB2 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN PB11 + #define EXP3_05_PIN PB14 + #define EXP3_06_PIN PB13 + #define EXP3_07_PIN PB12 + #define EXP3_08_PIN PB15 + +#elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD) + + /** + * VET6 12864 LCD + * ------ + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN -1 + #define EXP3_02_PIN PC5 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN -1 + #define EXP3_05_PIN PA6 + #define EXP3_06_PIN PA5 + #define EXP3_07_PIN PA4 + #define EXP3_08_PIN PA7 + +#elif EITHER(CR10_STOCKDISPLAY, FYSETC_MINI_12864_2_1) + #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for the LCD with the Creality V4 controller." +#endif - #if ENABLED(RET6_12864_LCD) - - /** - * RET6 12864 LCD - * ------ - * PC6 | 1 2 | PB2 - * PB10 | 3 4 | PE8 - * PB14 5 6 | PB13 - * PB12 | 7 8 | PB15 - * GND | 9 10 | 5V - * ------ - * EXP1 - */ - #define EXP1_01_PIN PC6 - #define EXP1_02_PIN PB2 - #define EXP1_03_PIN PB10 - #define EXP1_04_PIN PE8 - #define EXP1_05_PIN PB14 - #define EXP1_06_PIN PB13 - #define EXP1_07_PIN PB12 - #define EXP1_08_PIN PB15 - - #ifndef HAS_PIN_27_BOARD - #define BEEPER_PIN EXP1_01_PIN - #endif - - #elif ENABLED(VET6_12864_LCD) - - /** - * VET6 12864 LCD - * ------ - * ? | 1 2 | PC5 - * PB10 | 3 4 | ? - * PA6 5 6 | PA5 - * PA4 | 7 8 | PA7 - * GND | 9 10 | 5V - * ------ - * EXP1 - */ - #define EXP1_01_PIN -1 - #define EXP1_02_PIN PC5 - #define EXP1_03_PIN PB10 - #define EXP1_04_PIN -1 - #define EXP1_05_PIN PA6 - #define EXP1_06_PIN PA5 - #define EXP1_07_PIN PA4 - #define EXP1_08_PIN PA7 +#if ENABLED(CR10_STOCKDISPLAY) - #else - #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." - #endif + #define LCD_PINS_RS EXP3_07_PIN + #define LCD_PINS_ENABLE EXP3_08_PIN + #define LCD_PINS_D4 EXP3_06_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define BTN_ENC EXP3_02_PIN + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN - #define BTN_ENC EXP1_02_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_05_PIN + #ifndef HAS_PIN_27_BOARD + #define BEEPER_PIN EXP3_01_PIN + #endif #elif ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, DWIN_VET6_CREALITY_LCD) - #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI - // RET6 DWIN ENCODER LCD - #define EXP1_05_PIN PB14 - #define EXP1_06_PIN PB13 - #define EXP1_07_PIN PB12 - #define EXP1_08_PIN PB15 - //#define LCD_LED_PIN PB2 - #else - // VET6 DWIN ENCODER LCD - #define EXP1_05_PIN PA6 - #define EXP1_06_PIN PA5 - #define EXP1_07_PIN PA4 - #define EXP1_08_PIN PA7 + #define BTN_ENC EXP3_05_PIN + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_07_PIN + + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP3_06_PIN #endif - #define BTN_ENC EXP1_05_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_07_PIN +#elif ENABLED(FYSETC_MINI_12864_2_1) - #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_06_PIN + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_CREALITY_V4.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning." #endif + #if SD_CONNECTION_IS(LCD) + #error "The LCD SD Card is not connected with this configuration." + #endif + + /** + * + * Board (RET6 12864 LCD) Display + * ------ ------ + * (EN1) PC6 | 1 2 | PB2 (BTN_ENC) 5V |10 9 | GND + * (LCD_CS) PB10 | 3 4 | PB11 (LCD RESET) -- | 8 7 | -- + * (LCD_A0) PB14 5 6 | PB13 (EN2) (DIN) | 6 5 (LCD RESET) + * (LCD_SCK)PB12 | 7 8 | PB15 (MOSI) (LCD_A0) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (BTN_ENC) | 2 1 | -- + * ------ ------ + * EXP1 EXP1 + * + * ------ + * ----- -- |10 9 | -- + * | 1 | VCC (RESET) | 8 7 | -- + * | 2 | PA13 (DIN) (MOSI) | 6 5 (EN2) + * | 3 | PA14 -- | 4 3 | (EN1) + * | 4 | GND (LCD_SCK)| 2 1 | -- + * ----- ------ + * Debug port EXP2 + * + * Needs custom cable. Connect EN2-EN2, LCD_CS-LCD_CS and so on. + * Debug port is just above EXP1. You need to add pins. + * + */ + + #define BTN_ENC EXP3_02_PIN + #define BTN_EN1 EXP3_01_PIN + #define BTN_EN2 EXP3_06_PIN + #define BEEPER_PIN -1 + + #define DOGLCD_CS EXP3_03_PIN + #define DOGLCD_A0 EXP3_05_PIN + #define DOGLCD_SCK EXP3_07_PIN + #define DOGLCD_MOSI EXP3_08_PIN + #define LCD_RESET_PIN EXP3_04_PIN + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + #define NEOPIXEL_PIN PA13 + #endif + +// Pins for documentation and sanity checks only. +// Changing these will not change the pin they are on. + +// Hardware UART pins +#define UART1_TX_PIN PA9 // default uses CH340 RX +#define UART1_RX_PIN PA10 // default uses CH340 TX +#define UART2_TX_PIN PA2 // default uses HEATER_BED_PIN +#define UART2_RX_PIN PA3 // not connected +#define UART3_TX_PIN PB10 // default uses LCD connector +#define UART3_RX_PIN PB11 // default uses LCD connector +#define UART4_TX_PIN PC10 // default uses sdcard SDIO_D2 +#define UART4_RX_PIN PC11 // default uses sdcard SDIO_D3 +#define UART5_TX_PIN PC12 // default uses sdcard SDIO_CK +#define UART5_RX_PIN PD2 // default uses sdcard SDIO_CMD + +// SDIO pins +#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 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h index 86ede843be57..f3b7e4f308b9 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2021 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 + * 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 @@ -22,7 +22,7 @@ #pragma once /** - * CREALITY 4.2.10 (STM32F103RE / STM32F103RC) board pin assignments + * Creality 4.2.10 (STM32F103RE / STM32F103RC) board pin assignments */ #include "env_validate.h" @@ -143,85 +143,75 @@ #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer -#if ENABLED(CR10_STOCKDISPLAY) +#if ANY(RET6_12864_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) + + /** + * RET6 12864 LCD + * ------ + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PE8 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN PC6 + #define EXP3_02_PIN PB2 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN PE8 + #define EXP3_05_PIN PB14 + #define EXP3_06_PIN PB13 + #define EXP3_07_PIN PB12 + #define EXP3_08_PIN PB15 + +#elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD) + + /** + * VET6 12864 LCD + * ------ + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN -1 + #define EXP3_02_PIN PC5 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN -1 + #define EXP3_05_PIN PA6 + #define EXP3_06_PIN PA5 + #define EXP3_07_PIN PA4 + #define EXP3_08_PIN PA7 + +#endif - #if ENABLED(RET6_12864_LCD) - - /** - * RET6 12864 LCD - * ------ - * PC6 | 1 2 | PB2 - * PB10 | 3 4 | PE8 - * PB14 5 6 | PB13 - * PB12 | 7 8 | PB15 - * GND | 9 10 | 5V - * ------ - * EXP1 - */ - #define EXP1_01_PIN PC6 - #define EXP1_02_PIN PB2 - #define EXP1_03_PIN PB10 - #define EXP1_04_PIN PE8 - #define EXP1_05_PIN PB14 - #define EXP1_06_PIN PB13 - #define EXP1_07_PIN PB12 - #define EXP1_08_PIN PB15 - - #define BEEPER_PIN EXP1_01_PIN - - #elif ENABLED(VET6_12864_LCD) - - /** - * VET6 12864 LCD - * ------ - * ? | 1 2 | PC5 - * PB10 | 3 4 | ? - * PA6 5 6 | PA5 - * PA4 | 7 8 | PA7 - * GND | 9 10 | 5V - * ------ - * EXP1 - */ - #define EXP1_01_PIN -1 - #define EXP1_02_PIN PC5 - #define EXP1_03_PIN PB10 - #define EXP1_04_PIN -1 - #define EXP1_05_PIN PA6 - #define EXP1_06_PIN PA5 - #define EXP1_07_PIN PA4 - #define EXP1_08_PIN PA7 - - #else +#if ENABLED(CR10_STOCKDISPLAY) + #if NONE(RET6_12864_LCD, VET6_12864_LCD) #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." #endif - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_RS EXP3_07_PIN + #define LCD_PINS_ENABLE EXP3_08_PIN + #define LCD_PINS_D4 EXP3_06_PIN - #define BTN_ENC EXP1_02_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP3_02_PIN + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN -#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + #define BEEPER_PIN EXP3_01_PIN - // RET6 DWIN ENCODER LCD - #define BTN_ENC PB14 - #define BTN_EN1 PB15 - #define BTN_EN2 PB12 +#elif ANY(DWIN_VET6_CREALITY_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) - //#define LCD_LED_PIN PB2 + // RET6 / VET6 DWIN ENCODER LCD + #define BTN_ENC EXP3_05_PIN + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_07_PIN + + //#define LCD_LED_PIN EXP3_02_PIN #ifndef BEEPER_PIN - #define BEEPER_PIN PB13 + #define BEEPER_PIN EXP3_06_PIN #endif -#elif ENABLED(DWIN_VET6_CREALITY_LCD) - - // VET6 DWIN ENCODER LCD - #define BTN_ENC PA6 - #define BTN_EN1 PA7 - #define BTN_EN2 PA4 - - #define BEEPER_PIN PA5 - #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h index 5499adb07668..9e26b37de0d3 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h @@ -28,4 +28,6 @@ #define BOARD_INFO_NAME "Creality v4.2.2" #define DEFAULT_MACHINE_NAME "Creality3D" +#define EMIT_CREALITY_422_WARNING + #include "pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h index 46f437ecafb2..1c62d19a99e4 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. - * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * 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 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h index 077f4c73a657..ccb7a810cdf5 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h @@ -33,9 +33,10 @@ // #define X_STEP_PIN PB9 #define X_DIR_PIN PC2 -#define Y_STEP_PIN PB7 +#define Y_STEP_PIN PB7 #define Y_DIR_PIN PB8 + #define Z_STEP_PIN PB5 #define Z_DIR_PIN PB6 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V521.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V521.h new file mode 100644 index 000000000000..d3d3685531dc --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V521.h @@ -0,0 +1,226 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * Creality 5.2.1 (STM32F103RE) board pin assignments + */ + +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Creality v5.2.1 supports up to 2 hotends / E steppers." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Creality V521" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "Creality V5.2.1" +#endif + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + // FLASH + //#define FLASH_EEPROM_EMULATION + + // I2C + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 used only for display settings + #if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PC2 + #define IIC_EEPROM_SCL PC3 + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) + #else + #define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX + #define MARLIN_EEPROM_SIZE 0x800 // 2K + #endif + + #undef NO_EEPROM_SELECTED +#endif + +// +// Servos +// +#define SERVO0_PIN PD13 // BLTouch OUT + +// +// Limit Switches +// +#define X_STOP_PIN PD10 // X +#define X2_STOP_PIN PE15 // X2 +#define Y_STOP_PIN PE0 // Y +#define Z_STOP_PIN PE1 // Z +#define Z2_STOP_PIN PE2 // Z2 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PD12 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PE5 // "Pulled-high" +#define FIL_RUNOUT2_PIN PE6 // "Pulled-high" + +// +// Steppers +// +#define X_ENABLE_PIN PC7 +#define X_STEP_PIN PD15 +#define X_DIR_PIN PD14 + +#define Y_ENABLE_PIN PB9 +#define Y_STEP_PIN PB7 +#define Y_DIR_PIN PB6 + +#define Z_ENABLE_PIN PB5 +#define Z_STEP_PIN PB3 +#define Z_DIR_PIN PD7 + +#define E0_ENABLE_PIN PD4 +#define E0_STEP_PIN PD1 +#define E0_DIR_PIN PD0 + +#define E1_ENABLE_PIN PE7 +#define E1_STEP_PIN PB1 +#define E1_DIR_PIN PB0 + +#define X2_ENABLE_PIN PE11 +#define X2_STEP_PIN PE9 +#define X2_DIR_PIN PE8 + +#define Z2_ENABLE_PIN PC5 +#define Z2_STEP_PIN PA7 +#define Z2_DIR_PIN PA6 + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_JTAG + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA4 // TH0 +#define TEMP_1_PIN PA5 // TH1 +#define TEMP_BED_PIN PA3 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA1 // HEATER0 +#define HEATER_1_PIN PA0 // HEATER1 +#define HEATER_BED_PIN PA2 // HOT BED + +#define FAN_PIN PB14 // FAN +#define FAN1_PIN PB12 // FAN +#define FAN_SOFT_PWM + +// +// SD Card +// +#define SD_DETECT_PIN PA8 +#define SDCARD_CONNECTION ONBOARD +#define ONBOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PC11 // SDSS +#define SDIO_SUPPORT +#define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer + +#if ANY(RET6_12864_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) + + /** + * RET6 12864 LCD + * ------ + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PE8 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN PC6 + #define EXP3_02_PIN PB2 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN PE8 + #define EXP3_05_PIN PB14 + #define EXP3_06_PIN PB13 + #define EXP3_07_PIN PB12 + #define EXP3_08_PIN PB15 + +#elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD) + + /** + * VET6 12864 LCD + * ------ + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN -1 + #define EXP3_02_PIN PC5 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN -1 + #define EXP3_05_PIN PA6 + #define EXP3_06_PIN PA5 + #define EXP3_07_PIN PA4 + #define EXP3_08_PIN PA7 + +#endif + +#if ENABLED(CR10_STOCKDISPLAY) + #if NONE(RET6_12864_LCD, VET6_12864_LCD) + #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." + #endif + + #define LCD_PINS_RS EXP3_07_PIN + #define LCD_PINS_ENABLE EXP3_08_PIN + #define LCD_PINS_D4 EXP3_06_PIN + + #define BTN_ENC EXP3_02_PIN + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN + + #define BEEPER_PIN EXP3_01_PIN + +#elif ANY(DWIN_VET6_CREALITY_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) + + // RET6 / VET6 DWIN ENCODER LCD + #define BTN_ENC EXP3_05_PIN + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_07_PIN + + //#define LCD_LED_PIN EXP3_02_PIN + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP3_06_PIN + #endif + +#endif + +// DGUS LCDs +#if HAS_DGUS_LCD + #define LCD_SERIAL_PORT 3 +#endif diff --git a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h index dd621eb5c126..ff588f948812 100644 --- a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h +++ b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h @@ -68,8 +68,8 @@ #define SPI_DEVICE 2 // SPI Flash -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) // SPI 2 #define SPI_FLASH_CS_PIN PB12 // SPI2_NSS / Flash chip-select #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index 4b5d38e8c544..646638dae2f5 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -23,7 +23,7 @@ /** * Geeetech GTM32 Pro VB board pin assignments - * http://www.geeetech.com/wiki/index.php/File:Hardware_GTM32_PRO_VB.pdf + * https://www.geeetech.com/wiki/index.php/File:Hardware_GTM32_PRO_VB.pdf * * Also applies to GTM32 Pro VD */ diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index e6d31746539a..ad6b84b05769 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -183,7 +183,7 @@ // #if NO_EEPROM_SELECTED //#define SPI_EEPROM - //#define HAS_SPI_FLASH 1 // need MARLIN_DEV_MODE for M993/M994 eeprom backup tests + //#define SPI_FLASH // need MARLIN_DEV_MODE for M993/M994 EEPROM backup tests #define FLASH_EEPROM_EMULATION #endif @@ -196,7 +196,7 @@ #define EEPROM_MOSI_PIN BOARD_SPI1_MOSI_PIN // PA7 pin 32 #define EEPROM_PAGE_SIZE 0x1000U // 4K (from datasheet) #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64K for now... -#elif HAS_SPI_FLASH +#elif ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x40000U // limit to 256K (M993 will reboot with 512) #define SPI_FLASH_CS_PIN PC5 #define SPI_FLASH_MOSI_PIN PA7 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index 2c147eb9f3e0..be5f6c740482 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -272,8 +272,8 @@ // // W25Q64 64Mb (8MB) SPI flash // -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x800000 // 8MB #define SPI_FLASH_CS_PIN PG9 #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index b8f6f6a330ad..89525d93ef48 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -377,8 +377,8 @@ #endif // HAS_WIRED_LCD && !HAS_SPI_TFT -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index 0bfc7f5c8d93..59441dc80609 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -196,8 +196,8 @@ #endif #endif -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 // Flash chip-select #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index 115058a19f77..9801676c2e9e 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -29,7 +29,7 @@ #define ALLOW_STM32DUINO #include "env_validate.h" -#define BOARD_INFO_NAME "MKS Robin Nano" +#define BOARD_INFO_NAME "MKS Robin Nano V1" // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role 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 9ce5d270b556..8dba94313651 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -35,7 +35,9 @@ #define BOARD_INFO_NAME "MKS Robin nano V2.0" -#define BOARD_NO_NATIVE_USB +#ifndef USB_MOD + #define BOARD_NO_NATIVE_USB +#endif #define USES_DIAG_PINS // Avoid conflict with TIMER_SERVO when using the STM32 HAL @@ -377,8 +379,8 @@ #endif // HAS_WIRED_LCD && !HAS_SPI_TFT -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h index 0eb7bbdffeb4..858dabb8b986 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h @@ -29,7 +29,9 @@ #error "MKS Robin nano boards support up to 2 hotends / E steppers." #endif -#define BOARD_NO_NATIVE_USB +#ifndef USB_MOD + #define BOARD_NO_NATIVE_USB +#endif // Avoid conflict with TIMER_SERVO when using the STM32 HAL #define TEMP_TIMER 5 @@ -58,9 +60,14 @@ // Limit Switches // #define X_STOP_PIN PA15 -#define Y_STOP_PIN PA12 -#define Z_MIN_PIN PA11 #define Z_MAX_PIN PC4 +#ifndef USB_MOD + #define Y_STOP_PIN PA12 + #define Z_MIN_PIN PA11 +#else + #define Y_STOP_PIN PB10 + #define Z_MIN_PIN PB11 +#endif // // Steppers @@ -201,8 +208,8 @@ #define TFT_BUFFER_SIZE 14400 #endif -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index 1db2d0c5dd84..048570102baf 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -308,8 +308,8 @@ #define BOARD_ST7920_DELAY_3 125 #endif -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 // Flash chip-select #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f4/pins_ARMED.h b/Marlin/src/pins/stm32f4/pins_ARMED.h index d08d3fb66c0a..2abcc21da5a4 100644 --- a/Marlin/src/pins/stm32f4/pins_ARMED.h +++ b/Marlin/src/pins/stm32f4/pins_ARMED.h @@ -19,11 +19,10 @@ * along with this program. If not, see . * */ - -// https://github.com/ktand/Armed - #pragma once +// https://github.com/ktand/Armed + #include "env_validate.h" #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h index 47d009c5a61e..7413b9b0645a 100644 --- a/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h +++ b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h @@ -16,7 +16,7 @@ * 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 . + * along with this program. If not, see . * */ #pragma once 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 9ff9f6a47567..b3d97ae059e4 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -28,7 +28,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (AT24C32) +#define MARLIN_EEPROM_SIZE 0x1000 // 4K (AT24C32) #define I2C_SCL_PIN PB8 #define I2C_SDA_PIN PB9 @@ -429,6 +429,30 @@ #define TFTGLCD_CS EXP2_03_PIN #endif +#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + /** + * ------ ------ --- + * | 1 2 | | 1 2 | 1 | + * | 3 4 | RX | 3 4 | TX | 2 | RX + * ENT 5 6 | BEEP ENT 5 6 | BEEP | 3 | TX + * B | 7 8 | A B | 7 8 | A | 4 | + * GND | 9 10 | VCC GND | 9 10 | VCC 5 | + * ------ ------ --- + * EXP1 DWIN TFT + * + * DWIN pins are labeled as printed on DWIN PCB. GND, VCC, A, B, ENT & BEEP can be connected in the same + * orientation as the existing plug/DWIN to EXP1. TX/RX need to be connected to the TFT port, with TX->RX, RX->TX. + */ + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! Ender-3 V2 display requires a custom cable. See 'pins_BTT_OCTOPUS_V1_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define BEEPER_PIN EXP1_06_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_05_PIN + #elif HAS_WIRED_LCD #define BEEPER_PIN EXP1_01_PIN diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h new file mode 100644 index 000000000000..31551f6ff6f4 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h @@ -0,0 +1,350 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 + +#include "env_validate.h" + +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "BTT SKR Mini E3 V3.0.1 supports up to 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR Mini E3 V3.0.1" +#endif + +#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#ifndef NEOPIXEL_LED + #define LED_PIN PA14 +#endif + +// Onboard I2C EEPROM +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #undef NO_EEPROM_SELECTED + #define I2C_EEPROM + #define SOFT_I2C_EEPROM // Force the use of Software I2C + #define I2C_SCL_PIN PB8 + #define I2C_SDA_PIN PB9 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Servos +// +#define SERVO0_PIN PA0 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PB5 // X-STOP +#define Y_STOP_PIN PB6 // Y-STOP +#define Z_STOP_PIN PB7 // Z-STOP + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PA1 // PROBE + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // E0-STOP +#endif + +// +// Power-loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC13 // Power Loss Detection: PWR-DET +#endif + +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA14 // LED driving pin +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN PC14 // Power Supply Control +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC10 +#define X_STEP_PIN PC11 +#define X_DIR_PIN PC12 + +#define Y_ENABLE_PIN PB13 +#define Y_STEP_PIN PB12 +#define Y_DIR_PIN PB10 + +#define Z_ENABLE_PIN PB2 +#define Z_STEP_PIN PB1 +#define Z_DIR_PIN PB0 + +#define E0_ENABLE_PIN PC3 +#define E0_STEP_PIN PC2 +#define E0_DIR_PIN PC1 + +#if HAS_TMC_UART + /** + * TMC220x stepper drivers + * Hardware serial communication ports + */ + #define X_HARDWARE_SERIAL MSerial6 + #define Y_HARDWARE_SERIAL MSerial6 + #define Z_HARDWARE_SERIAL MSerial6 + #define E0_HARDWARE_SERIAL MSerial6 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC5 // Analog Input "TH0" +#define TEMP_BED_PIN PC4 // Analog Input "TB0" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA15 // "HE" +#define HEATER_BED_PIN PB3 // "HB" +#define FAN_PIN PC9 // "FAN0" +#define FAN1_PIN PA8 // "FAN1" +#define FAN2_PIN PC8 // "FAN2" + +/** + * SKR Mini E3 V3.0.1 + * ------ + * (BEEPER) PB15 | 1 2 | PB14 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB4 (LCD_D4) + * (LCD_RS) PD2 | 7 8 | PC0 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ +#define EXP1_01_PIN PB15 +#define EXP1_02_PIN PB14 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN -1 // RESET +#define EXP1_05_PIN PA10 +#define EXP1_06_PIN PB4 +#define EXP1_07_PIN PD2 +#define EXP1_08_PIN PC0 + +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + /** + * ------ ------ ------ + * (ENT) | 1 2 | (BEEP) |10 9 | |10 9 | + * (RX) | 3 4 | (RX) | 8 7 | (TX) RX | 8 7 | TX + * (TX) 5 6 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP + * (B) | 7 8 | (A) (B) | 4 3 | (A) B | 4 3 | A + * GND | 9 10 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * ------ ------ ------ + * 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_02_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_01_PIN + +#elif HAS_WIRED_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_02_PIN + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN + #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * TFTGLCD_PANEL_SPI display pinout + * + * Board Display + * ------ ------ + * (BEEPER) PB6 | 1 2 | PB15 (SD_DET) 5V |10 9 | GND + * RESET | 3 4 | PA9 (MOD_RESET) -- | 8 7 | (SD_DET) + * PB4 5 6 | PA10 (SD_CS) (MOSI) | 6 5 | -- + * PB7 | 7 8 | PD2 (LCD_CS) (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Display + * + * EXP1-10 ---------- EXP1-10 + * EXP1-9 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-7 ----------- FREE + * SPI1-3 ----------- EXP1-2 + * EXP1-5 ----------- EXP1-4 + * EXP1-4 ----------- FREE + * EXP1-3 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-1 ----------- EXP1-7 + */ + + #define TFTGLCD_CS EXP1_03_PIN + + #endif + + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." + #endif + +#endif // HAS_WIRED_LCD + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * FYSETC TFT TFT81050 display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PB15 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB4 (FREE) (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PD2 | 7 8 | PB7 (FREE) (SD_CS) | 4 3 | (MOD_RESET) + * 5V | 9 10 | GND (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * _________ + * EXP1-10 ---------- EXP1-10 + * EXP1-9 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-7 ----------- EXP1-5 + * SPI1-3 ----------- EXP1-2 + * EXP1-5 ----------- EXP1-4 + * EXP1-4 ----------- EXP1-8 + * EXP1-3 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-1 ----------- EXP1-7 + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN EXP1_02_PIN + + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN + +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL) + #define SD_DETECT_PIN EXP1_01_PIN + #define SD_SS_PIN EXP1_05_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." +#endif + +#define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1... +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card + +#define ENABLE_SPI1 +#define SDSS ONBOARD_SD_CS_PIN +#define SD_SS_PIN 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/stm32f4/pins_MKS_MONSTER8_V1.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h index 7163625e4042..50fe790dc34d 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h @@ -26,7 +26,9 @@ // // Limit Switches // +#define X_MIN_PIN PA14 #define X_MAX_PIN PA13 +#define Y_MIN_PIN PA15 #define Y_MAX_PIN PC5 // diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h index 9c012999b375..d70e935f0a29 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h @@ -23,6 +23,12 @@ #define BOARD_INFO_NAME "MKS Monster8 V2" +// +// Limit Switches +// +#define X_STOP_PIN PA14 +#define Y_STOP_PIN PA15 + // // Steppers // @@ -47,11 +53,11 @@ // //#define WIFI_SERIAL 1// USART1 #if ENABLED(MKS_WIFI_MODULE) - #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN - #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN - #define WIFI_RESET_PIN PD14 // MKS ESP WIFI RESET PIN + #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN + #define WIFI_RESET_PIN PD14 // MKS ESP WIFI RESET PIN #endif -#define NEOPIXEL_PIN PC5 +#define NEOPIXEL_PIN PC5 #include "pins_MKS_MONSTER8_common.h" diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h index 8a9b72225d79..b1031de8d5b7 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h @@ -64,8 +64,6 @@ #define E4_DIAG_PIN -1 // Driver7 diag signal is not connected // Limit Switches for endstops -#define X_MIN_PIN PA14 -#define Y_MIN_PIN PA15 #define Z_MIN_PIN PB13 #define Z_MAX_PIN PB12 diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h index 4ac64ae1d2c4..603da09d14ef 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h @@ -225,7 +225,7 @@ #define SPI_FLASH #if ENABLED(SPI_FLASH) - #define HAS_SPI_FLASH 1 + #define SPI_FLASH #define SPI_DEVICE 2 #define SPI_FLASH_SIZE 0x1000000 #define SPI_FLASH_CS_PIN PB12 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 7e08caaa82af..873ba3e90d66 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -273,7 +273,7 @@ // // LCD / Controller #define SPI_FLASH -#define HAS_SPI_FLASH 1 +#define SPI_FLASH #define SPI_DEVICE 2 #define SPI_FLASH_SIZE 0x1000000 #if ENABLED(SPI_FLASH) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h b/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h new file mode 100644 index 000000000000..d00b21c30b24 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h @@ -0,0 +1,381 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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" + +#if HOTENDS > 4 || E_STEPPERS > 4 + #error "MKS SKIPR supports up to 4 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS SKIPR V1.0" + +// Valid SERIAL_PORT values: -1 (USB-C), 1 (direct to RK3328), 3 (USART3 header) + +#define USES_DIAG_JUMPERS + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4K (AT24C32) +#define I2C_SCL_PIN PB8 +#define I2C_SDA_PIN PB9 + +// +// Servos +// +#define SERVO0_PIN PA8 + +// +// Trinamic Stallguard pins // Connector labels +#define X_DIAG_PIN PA14 // X- +#define Y_DIAG_PIN PA15 // Y- +#define Z_DIAG_PIN PB15 // Z- +#define E0_DIAG_PIN PA13 // MT-DET +#define E1_DIAG_PIN PC5 // NEOPIXEL +#define E2_DIAG_PIN PB14 // Z+ + +// +// Check for additional used endstop pins +// +#if HAS_EXTRA_ENDSTOPS + #define _ENDSTOP_IS_ANY(ES) X2_USE_ENDSTOP == ES || Y2_USE_ENDSTOP == ES || Z2_USE_ENDSTOP == ES || Z3_USE_ENDSTOP == ES || Z4_USE_ENDSTOP == ES + #if _ENDSTOP_IS_ANY(_XMIN_) || _ENDSTOP_IS_ANY(_XMAX_) + #define NEEDS_X_MINMAX 1 + #endif + #if _ENDSTOP_IS_ANY(_YMIN_) || _ENDSTOP_IS_ANY(_YMAX_) + #define NEEDS_Y_MINMAX 1 + #endif + #if _ENDSTOP_IS_ANY(_ZMIN_) || _ENDSTOP_IS_ANY(_ZMAX_) + #define NEEDS_Z_MINMAX 1 + #endif + #undef _ENDSTOP_IS_ANY +#endif + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN // X- +#elif EITHER(DUAL_X_CARRIAGE, NEEDS_X_MINMAX) + #ifndef X_MIN_PIN + #define X_MIN_PIN X_DIAG_PIN // X- + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN E0_DIAG_PIN // MT-DET + #endif +#else + #define X_STOP_PIN X_DIAG_PIN // X- +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN // Y- +#elif NEEDS_Y_MINMAX + #ifndef Y_MIN_PIN + #define Y_MIN_PIN Y_DIAG_PIN // Y- + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN E1_DIAG_PIN // NEOPIXEL + #endif +#else + #define Y_STOP_PIN Y_DIAG_PIN // Y- +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN // Z- +#elif NEEDS_Z_MINMAX + #ifndef Z_MIN_PIN + #define Z_MIN_PIN Z_DIAG_PIN // Z- + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN E2_DIAG_PIN // Z+ + #endif +#else + #define Z_STOP_PIN Z_DIAG_PIN // Z- +#endif + +#if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) || ENABLED(USE_PROBE_FOR_Z_HOMING) + #ifndef Z_MIN_PROBE + #define Z_MIN_PROBE_PIN E2_DIAG_PIN // defaults to 'Z+' connector + #endif +#endif + +#undef NEEDS_X_MINMAX +#undef NEEDS_Y_MINMAX +#undef NEEDS_Z_MINMAX + +// +// Steppers +// +#define X_STEP_PIN PC14 +#define X_DIR_PIN PC13 +#define X_ENABLE_PIN PC15 +#ifndef X_CS_PIN + #define X_CS_PIN PE6 +#endif + +#define Y_STEP_PIN PE5 +#define Y_DIR_PIN PE4 +#define Y_ENABLE_PIN PD14 +#ifndef Y_CS_PIN + #define Y_CS_PIN PE3 +#endif + +#define Z_STEP_PIN PE1 // "Z1" +#define Z_DIR_PIN PE0 +#define Z_ENABLE_PIN PE2 +#ifndef Z_CS_PIN + #define Z_CS_PIN PB7 +#endif + +#define E0_STEP_PIN PB5 +#define E0_DIR_PIN PB4 +#define E0_ENABLE_PIN PB6 +#ifndef E0_CS_PIN + #define E0_CS_PIN PB3 +#endif + +#define E1_STEP_PIN PD6 // "Z2" +#define E1_DIR_PIN PD5 +#define E1_ENABLE_PIN PD7 +#ifndef E1_CS_PIN + #define E1_CS_PIN PD4 +#endif + +#define E2_STEP_PIN PD2 // "Z3" +#define E2_DIR_PIN PD1 +#define E2_ENABLE_PIN PD3 +#ifndef E2_CS_PIN + #define E2_CS_PIN PD0 +#endif + +#define E3_STEP_PIN PC7 // "Z4" +#define E3_DIR_PIN PC6 +#define E3_ENABLE_PIN PC8 +#ifndef E3_CS_PIN + #define E3_CS_PIN PD15 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PC0 // TB +#define TEMP_0_PIN PC1 // TH0 +#define TEMP_1_PIN PC2 // TH1 +#define TEMP_2_PIN PC3 // TH2 + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PD12 // Hotbed +#define HEATER_0_PIN PB1 // Heater0 +#define HEATER_1_PIN PB0 // Heater1 +#define HEATER_2_PIN PA3 // Heater2 + +#define FAN_PIN PA2 // Fan0 +#define FAN1_PIN PA1 // Fan1 +#define FAN2_PIN PA0 // Fan2 + +// +// Software SPI pins for TMC2130 stepper drivers +// This board doesn't support hardware SPI there +// +#if HAS_TMC_SPI + #define TMC_USE_SW_SPI + #define TMC_SW_MOSI PE14 + #define TMC_SW_MISO PE13 + #define TMC_SW_SCK PE12 +#endif + +// +// TMC2208/TMC2209 stepper drivers +// This board is routed for one-wire software serial +// +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PE6 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PB7 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PB3 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD4 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PD0 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + #define E3_SERIAL_TX_PIN PD15 + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +/** ------ ------ + * (BEEPER) PB2 | 1 2 | PE10 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PE11 | 3 4 | PD10 (LCD_RS) (BTN_EN1) PE9 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PD9 | 5 6 PD8 (LCD_D5) (BTN_EN2) PE8 | 5 6 PA7 (MOSI) + * (LCD_D6) PE15 | 7 8 | PE7 (LCD_D7) (SD_DETECT) PD13 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PB2 +#define EXP1_02_PIN PE10 +#define EXP1_03_PIN PE11 +#define EXP1_04_PIN PD10 +#define EXP1_05_PIN PD9 +#define EXP1_06_PIN PD8 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE7 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE9 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PE8 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PD13 +#define EXP2_08_PIN -1 // connected to MCU reset + +// +// SD Support +// Onboard SD card use hardware SPI3 (defined in variant), LCD SD card use hardware SPI1 +// +#if ENABLED(SDSUPPORT) + #ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION LCD + #endif + #if SD_CONNECTION_IS(ONBOARD) + //#define SOFTWARE_SPI + //#define SD_SPI_SPEED SPI_HALF_SPEED + #undef SD_DETECT_STATE + #define SD_DETECT_STATE LOW + #define SD_DETECT_PIN PC4 + #elif SD_CONNECTION_IS(LCD) + //#define SOFTWARE_SPI + //#define SD_SPI_SPEED SPI_QUARTER_SPEED + #define SD_SS_PIN EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" + #endif + #define SDSS SD_SS_PIN +#endif + +// +// LCDs and Controllers +// +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + + #endif +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 120 + #define BOARD_ST7920_DELAY_2 80 + #define BOARD_ST7920_DELAY_3 580 +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PC5 +#endif + +// +// MAX31865 +// +#if HAS_MAX31865 + #define TEMP_0_CS_PIN PD11 + #define TEMP_0_SCK_PIN PE12 + #define TEMP_0_MISO_PIN PE13 + #define TEMP_0_MOSI_PIN PE14 +#endif diff --git a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h index 36dde8810525..06bf09402c06 100644 --- a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h +++ b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h @@ -44,6 +44,9 @@ // I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) #define HAS_MCP3426_ADC +#ifdef STM32F4 + #define HAS_STM32_UID +#endif // // Servos diff --git a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h new file mode 100644 index 000000000000..d16d7b200bd6 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h @@ -0,0 +1,206 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** + * STM32F407VET6 on Opulo Lumen PnP Rev3 + * Website - https://opulo.io/ + */ + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#define BOARD_INFO_NAME "LumenPnP Motherboard REV04" +#define DEFAULT_MACHINE_NAME "LumenPnP" + +/** + * By default, the extra stepper motor configuration is: + * I = Left Head + * J = Right Head + * K = Auxiliary (Conveyor belt) + */ + +#define SRAM_EEPROM_EMULATION +#define MARLIN_EEPROM_SIZE 0x2000 // 8K + +// I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) +#define HAS_MCP3426_ADC + +// +// Servos +// +#define SERVO0_PIN PB10 +#define SERVO1_PIN PB11 + +// +// Limit Switches +// +#define X_STOP_PIN PC6 +#define Y_STOP_PIN PD15 +#define Z_STOP_PIN PD14 + +// None of these require limit switches by default, so we leave these commented +// here for your reference. +//#define I_MIN_PIN PA8 +//#define I_MAX_PIN PA8 +//#define J_MIN_PIN PD13 +//#define J_MAX_PIN PD13 +//#define K_MIN_PIN PC9 +//#define K_MAX_PIN PC9 + +// +// Steppers +// +#define X_STEP_PIN PB15 +#define X_DIR_PIN PB14 +#define X_ENABLE_PIN PD9 + +#define Y_STEP_PIN PE15 +#define Y_DIR_PIN PE14 +#define Y_ENABLE_PIN PB13 + +#define Z_STEP_PIN PE7 +#define Z_DIR_PIN PB1 +#define Z_ENABLE_PIN PE9 + +#define I_STEP_PIN PC4 +#define I_DIR_PIN PA4 +#define I_ENABLE_PIN PB0 + +#define J_STEP_PIN PE11 +#define J_DIR_PIN PE10 +#define J_ENABLE_PIN PE13 + +#define K_STEP_PIN PD6 +#define K_DIR_PIN PD7 +#define K_ENABLE_PIN PA3 + +#if HAS_TMC_SPI + /** + * Make sure to configure the jumpers on the back side of the Mobo according to + * this diagram: https://github.com/MarlinFirmware/Marlin/pull/23851 + */ + #error "SPI drivers require a custom jumper configuration, see comment above! Comment out this line to continue." + + #if AXIS_HAS_SPI(X) + #define X_CS_PIN PD8 + #endif + #if AXIS_HAS_SPI(Y) + #define Y_CS_PIN PB12 + #endif + #if AXIS_HAS_SPI(Z) + #define Z_CS_PIN PE8 + #endif + #if AXIS_HAS_SPI(I) + #define I_CS_PIN PC5 + #endif + #if AXIS_HAS_SPI(J) + #define J_CS_PIN PE12 + #endif + #if AXIS_HAS_SPI(K) + #define K_CS_PIN PA2 + #endif + +#elif HAS_TMC_UART + + #define X_SERIAL_TX_PIN PD8 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PB12 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE8 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define I_SERIAL_TX_PIN PC5 + #define I_SERIAL_RX_PIN I_SERIAL_TX_PIN + + #define J_SERIAL_TX_PIN PE12 + #define J_SERIAL_RX_PIN J_SERIAL_TX_PIN + + #define K_SERIAL_TX_PIN PA2 + #define K_SERIAL_RX_PIN K_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 + +#endif + +// +// Heaters / Fans +// +#define FAN_PIN PE2 +#define FAN1_PIN PE3 +#define FAN2_PIN PE4 +#define FAN3_PIN PE5 + +#define FAN_SOFT_PWM_REQUIRED + +// +// Neopixel +// +#define NEOPIXEL_PIN PC7 +#define NEOPIXEL2_PIN PC8 + +// +// SPI +// +#define MISO_PIN PB4 +#define MOSI_PIN PB5 +#define SCK_PIN PB3 + +#define TMC_SW_MISO MISO_PIN +#define TMC_SW_MOSI MOSI_PIN +#define TMC_SW_SCK SCK_PIN + +// +// I2C +// +#define I2C_SDA_PIN PB7 +#define I2C_SCL_PIN PB6 + +/** + * The index mobo rev03 has 3 aux ports. We define them here so they may be used + * in other places and to make sure someone doesn't have to go look up the pinout + * in the board files. Each 12 pin aux port has this pinout: + * + * VDC 1 2 GND + * 3.3V 3 4 SCL (I2C_SCL_PIN) + * PWM1 5 6 SDA (I2C_SDA_PIN) + * PWM2 7 8 CIPO (MISO_PIN) + * A1 9 10 COPI (MOSI_PIN) + * A2 11 12 SCK (SCK_PIN) + */ +#define LUMEN_AUX1_PWM1 PA15 +#define LUMEN_AUX1_PWM2 PA5 +#define LUMEN_AUX1_A1 PC0 +#define LUMEN_AUX1_A2 PC1 + +#define LUMEN_AUX2_PWM1 PA6 +#define LUMEN_AUX2_PWM2 PA7 +#define LUMEN_AUX2_A1 PC2 +#define LUMEN_AUX2_A2 PC3 + +#define LUMEN_AUX3_PWM1 PB8 +#define LUMEN_AUX3_PWM2 PB9 +#define LUMEN_AUX3_A1 PA0 +#define LUMEN_AUX3_A2 PA1 diff --git a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h index 1a75a859e6c6..4fb57985b993 100644 --- a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h +++ b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h @@ -24,6 +24,10 @@ #define ALLOW_STM32DUINO #include "env_validate.h" +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "TH3D EZBoard only supports 1 hotend / E stepper." +#endif + #define BOARD_INFO_NAME "TH3D EZBoard V2" #define BOARD_WEBSITE_URL "th3dstudio.com" @@ -170,12 +174,6 @@ #ifndef E0_AUTO_FAN_PIN #define E0_AUTO_FAN_PIN AUTO_FAN_PIN #endif -#ifndef E1_AUTO_FAN_PIN - #define E1_AUTO_FAN_PIN AUTO_FAN_PIN -#endif -#ifndef E2_AUTO_FAN_PIN - #define E2_AUTO_FAN_PIN AUTO_FAN_PIN -#endif // // SD Card diff --git a/Marlin/src/pins/stm32f4/pins_TRONXY_V10.h b/Marlin/src/pins/stm32f4/pins_TRONXY_V10.h new file mode 100644 index 000000000000..e3b9f7ef6e55 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_TRONXY_V10.h @@ -0,0 +1,266 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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" + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "Tronxy V10 supports up to 3 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Tronxy V10" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +#define STEP_TIMER 6 +#define TEMP_TIMER 14 + +// +// Servos +// +//#define SERVO0_PIN PB10 + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #undef NO_EEPROM_SELECTED + #if TRONXY_UI > 0 + #define EEPROM_AT24CXX + #else + #define FLASH_EEPROM_EMULATION + #endif +#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 + #if ENABLED(EEPROM_AT24CXX) + #define AT24CXX_SCL PB8 + #define AT24CXX_SDA PB9 + #define AT24CXX_WP PB7 + #else + #define I2C_EEPROM // AT24C32 + #endif + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// SPI Flash +// +//#define SPI_FLASH +#if ENABLED(SPI_FLASH) + #define SPI_FLASH_SIZE 0x200000 // 2MB + #define W25QXX_CS_PIN PG15 // SPI2 + #define W25QXX_MOSI_PIN PB5 + #define W25QXX_MISO_PIN PB4 + #define W25QXX_SCK_PIN PB3 +#endif + +// +// Limit Switches +// +#define X_MIN_PIN PC15 +#define X_MAX_PIN PB0 +#define Y_STOP_PIN PC14 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PE3 +#endif + +#if ENABLED(DUAL_Z_ENDSTOP_PROBE) + #if NUM_Z_STEPPERS > 1 && Z_HOME_TO_MAX // Swap Z1/Z2 for dual Z with max homing + #define Z_MIN_PIN PF11 + #define Z_MAX_PIN PC13 + #else + #define Z_MIN_PIN PC13 + #define Z_MAX_PIN PF11 + #endif +#else + #ifndef Z_STOP_PIN + #define Z_STOP_PIN PC13 + #endif +#endif +// +// Filament Sensors +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PE6 // MT_DET +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN PF12 +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PF0 +#define X_STEP_PIN PE5 +#define X_DIR_PIN PF1 + +#define Y_ENABLE_PIN PF5 +#define Y_STEP_PIN PF9 +#define Y_DIR_PIN PF3 + +#define Z_ENABLE_PIN PA5 +#define Z_STEP_PIN PA6 +#define Z_DIR_PIN PF15 + +#define E0_ENABLE_PIN PF14 +#define E0_STEP_PIN PB1 +#define E0_DIR_PIN PF13 + +#define E1_ENABLE_PIN PG5 +#define E1_STEP_PIN PD12 +#define E1_DIR_PIN PG4 + +#define E2_ENABLE_PIN PF7 +#define E2_STEP_PIN PF6 +#define E2_DIR_PIN PF4 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC3 // TH1 +#define TEMP_BED_PIN PC2 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PG7 // HEATER1 +#define HEATER_BED_PIN PE2 // HOT BED +//#define HEATER_BED_INVERTING true + +#define FAN_PIN PG0 // FAN0 +#define FAN1_PIN PB6 // FAN1 +#define FAN2_PIN PG9 // FAN2 +#define FAN3_PIN PF10 // FAN3 +#define CONTROLLER_FAN_PIN PD7 // BOARD FAN +#define FAN_SOFT_PWM + +// +// Laser / Spindle +// +#if HAS_CUTTER + #define SPINDLE_LASER_ENA_PIN PB11 // wifi:TX + #if ENABLED(SPINDLE_LASER_USE_PWM) + #define SPINDLE_LASER_PWM_PIN PB10 // wifi:RX-TIM2_CH3 + // The PWM pin definition const PinMap PinMap_PWM[] in PeripheralPins.c must be compounded here + // See PWM_PIN(x) definition for details + #endif +#endif + +// +// Misc +// +#define BEEPER_PIN PA8 + +//#define LED_PIN PG10 +#define PS_ON_PIN PG10 // Temporarily switch the machine with LED simulation + +#if ENABLED(TRONXY_BACKUP_POWER) + #define POWER_LOSS_PIN PF11 // Configure as drop-down input +#else + #define POWER_LOSS_PIN PE1 // Output of LM393 comparator, configured as pullup +#endif +//#define POWER_LM393_PIN PE0 // +V for the LM393 comparator, configured as output high + +#if ENABLED(TFT_TRONXY_X5SA) + #error "TFT_TRONXY_X5SA is not yet supported." +#endif + +#if 0 + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #define TFT_RESET_PIN PB12 + #define TFT_BACKLIGHT_PIN PG8 + + #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 PG12 + #define TFT_RS_PIN PG2 + + //#define TFT_WIDTH 480 + //#define TFT_HEIGHT 320 + //#define TFT_PIXEL_OFFSET_X 48 + //#define TFT_PIXEL_OFFSET_Y 32 + //#define TFT_DRIVER ILI9488 + //#define TFT_BUFFER_SIZE 14400 + + #if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PD11 // SPI1_NSS + #define TOUCH_SCK_PIN PB13 // SPI1_SCK + #define TOUCH_MISO_PIN PB14 // SPI1_MISO + #define TOUCH_MOSI_PIN PB15 // SPI1_MOSI + #endif + + #if (LCD_CHIP_INDEX == 1 && (TRONXY_UI == 1 || TRONXY_UI == 2)) || LCD_CHIP_INDEX == 3 + #define TOUCH_CALIBRATION_X -17181 + #define TOUCH_CALIBRATION_Y 11434 + #define TOUCH_OFFSET_X 501 + #define TOUCH_OFFSET_Y -9 + #elif LCD_CHIP_INDEX == 1 && TRONXY_UI == 4 + #define TOUCH_CALIBRATION_X 11166 + #define TOUCH_CALIBRATION_Y 17162 + #define TOUCH_OFFSET_X -10 + #define TOUCH_OFFSET_Y -16 + #elif LCD_CHIP_INDEX == 4 && TRONXY_UI == 3 + //#define TOUCH_CALIBRATION_X 8781 + //#define TOUCH_CALIBRATION_Y 11773 + //#define TOUCH_OFFSET_X -17 + //#define TOUCH_OFFSET_Y -16 + // Upside-down + #define TOUCH_CALIBRATION_X -8553 + #define TOUCH_CALIBRATION_Y -11667 + #define TOUCH_OFFSET_X 253 + #define TOUCH_OFFSET_Y 331 + #elif LCD_CHIP_INDEX == 2 + #define TOUCH_CALIBRATION_X 17184 + #define TOUCH_CALIBRATION_Y 10604 + #define TOUCH_OFFSET_X -31 + #define TOUCH_OFFSET_Y -29 + #endif +#endif + +#endif + +// +// SD Card +// +#define SDIO_SUPPORT +#define SD_DETECT_PIN -1 // PF0, but not connected +#define SDIO_CLOCK 4500000 +#define SDIO_READ_RETRIES 16 + +#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 diff --git a/Marlin/src/pins/stm32g0/pins_BTT_EBB42_V1_1.h b/Marlin/src/pins/stm32g0/pins_BTT_EBB42_V1_1.h new file mode 100644 index 000000000000..fc2be5401e10 --- /dev/null +++ b/Marlin/src/pins/stm32g0/pins_BTT_EBB42_V1_1.h @@ -0,0 +1,153 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 + +/** CAUTION ** + * This board definition is to facilitate support for a Filament Extrusion + * devices, used to convert waste plastic into 3D printable filament. + * This board is NOT a general 3D printing controller; it is NOT supported + * as a toolboard via CANBUS (as it was originally designed) or any device + * that requires kinematics. + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT EBB42 V1.1" +#endif + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #undef NO_EEPROM_SELECTED + #ifndef FLASH_EEPROM_EMULATION + #define FLASH_EEPROM_EMULATION + #endif + #define EEPROM_PAGE_SIZE (0x800UL) // 2K + #define EEPROM_START_ADDRESS (0x0801F800UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#endif + +//#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#define LED_PIN PA13 + +#define I2C_SDA_PIN PB4 +#define I2C_SCL_PIN PB3 + +// +// Servos +// +#define SERVO0_PIN PB9 // SERVOS + +// +// Limit Switches +// +#if !HAS_WIRED_LCD + #define X_STOP_PIN PB6 + #define Y_STOP_PIN PB5 + #define Z_STOP_PIN PB7 +#endif + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PB8 // PROBE + +// +// Steppers +// +#define X_ENABLE_PIN -1 +#define X_STEP_PIN PA10 // Unused. Assigned so Marlin will compile +#define X_DIR_PIN -1 + +#define Y_ENABLE_PIN -1 +#define Y_STEP_PIN PA10 // Unused. Assigned so Marlin will compile +#define Y_DIR_PIN -1 + +#define Z_ENABLE_PIN -1 +#define Z_STEP_PIN PA10 // Unused. Assigned so Marlin will compile +#define Z_DIR_PIN -1 + +#define E0_ENABLE_PIN PD2 +#define E0_STEP_PIN PD0 +#define E0_DIR_PIN PD1 + +#if HAS_TMC_UART + /** + * TMC220x stepper drivers + * Hardware serial communication ports + */ + //#define E0_HARDWARE_SERIAL MSerial4 + + // This is the stable default value after testing, but, higher UART rates could be configured, remeber to test the Steppers with the M122 command to check if everything works. + //#define TMC_BAUD_RATE 250000 + + #define E0_SERIAL_TX_PIN PA15 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 + + // Default TMC slave addresses + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0b00 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA3 // Analog Input "TH0" + +// SPI for MAX Thermocouple +// Uses a separate SPI bus + +#define TEMP_0_CS_PIN PA4 // GTR K-TEMP +#define TEMP_0_SCK_PIN PA5 // SCK +#define TEMP_0_MISO_PIN PA6 // MISO +#define TEMP_0_MOSI_PIN PA7 // For MAX31865 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA2 // "HE" +#define FAN_PIN PA0 // "FAN0" +#define FAN1_PIN PA1 // "FAN1" + +// +// Default NEOPIXEL_PIN +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PD3 // LED driving pin +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BTN_EN1 PB7 + #define BTN_EN2 PB5 + #define BTN_ENC PB6 +#endif diff --git a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h index 956cb71f832b..f931d9924acf 100644 --- a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h +++ b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h @@ -311,7 +311,7 @@ #elif ENABLED(FYSETC_MINI_12864_2_1) #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING - #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_V3_0.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning" + #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_V3_0.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning." #endif /** diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h index 24376d6f9c48..eaceafe29ee3 100644 --- a/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h @@ -46,7 +46,7 @@ #define SOFT_I2C_EEPROM // Force the use of Software I2C #define I2C_SCL_PIN PA14 #define I2C_SDA_PIN PA13 - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index a7f035c1f093..bbf0a3cf9f99 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -29,6 +29,7 @@ #include "cardreader.h" #include "../MarlinCore.h" +#include "../libs/hex_print.h" #include "../lcd/marlinui.h" #if ENABLED(DWIN_CREALITY_LCD) @@ -197,7 +198,7 @@ char *createFilename(char * const buffer, const dir_t &p) { // // Return 'true' if the item is a folder, G-code file or Binary file // -bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/)) { +bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin/*=false*/)) { //uint8_t pn0 = p.name[0]; #if DISABLED(CUSTOM_FIRMWARE_UPLOAD) @@ -279,12 +280,17 @@ void CardReader::selectByName(SdFile dir, const char * const match) { * this can blow up the stack, so a 'depth' parameter would be a * good addition. */ -void CardReader::printListing( - SdFile parent, const char * const prepend - OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/) - OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) +void CardReader::printListing(SdFile parent, const char * const prepend, const uint8_t lsflags OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong/*=nullptr*/) ) { + const bool includeTime = TERN0(M20_TIMESTAMP_SUPPORT, TEST(lsflags, LS_TIMESTAMP)); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + const bool includeLong = TEST(lsflags, LS_LONG_FILENAME); + #endif + #if ENABLED(CUSTOM_FIRMWARE_UPLOAD) + const bool onlyBin = TEST(lsflags, LS_ONLY_BIN); + #endif + UNUSED(lsflags); dir_t p; while (parent.readDir(&p, longFilename) > 0) { if (DIR_IS_SUBDIR(&p)) { @@ -301,19 +307,17 @@ void CardReader::printListing( SdFile child; // child.close() in destructor if (child.open(&parent, dosFilename, O_READ)) { #if ENABLED(LONG_FILENAME_HOST_SUPPORT) - if (includeLongNames) { - size_t lenPrependLong = prependLong ? strlen(prependLong) + 1 : 0; + if (includeLong) { + const 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, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin), true, pathLong); + printListing(child, path, lsflags, pathLong); + continue; } - else - printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); - #else - printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); #endif + printListing(child, path, lsflags); } else { SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename); @@ -325,8 +329,18 @@ void CardReader::printListing( SERIAL_ECHO(createFilename(filename, p)); SERIAL_CHAR(' '); SERIAL_ECHO(p.fileSize); + if (includeTime) { + SERIAL_CHAR(' '); + uint16_t crmodDate = p.lastWriteDate, crmodTime = p.lastWriteTime; + if (crmodDate < p.creationDate || (crmodDate == p.creationDate && crmodTime < p.creationTime)) { + crmodDate = p.creationDate; + crmodTime = p.creationTime; + } + SERIAL_ECHOPGM("0x", hex_word(crmodDate)); + print_hex_word(crmodTime); + } #if ENABLED(LONG_FILENAME_HOST_SUPPORT) - if (includeLongNames) { + if (includeLong) { SERIAL_CHAR(' '); if (prependLong) { SERIAL_ECHO(prependLong); SERIAL_CHAR('/'); } SERIAL_ECHO(longFilename[0] ? longFilename : filename); @@ -340,16 +354,10 @@ void CardReader::printListing( // // List all files on the SD card // -void CardReader::ls( - TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin/*=false*/) - #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) - , - #endif - TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) -) { +void CardReader::ls(const uint8_t lsflags) { if (flag.mounted) { root.rewind(); - printListing(root, nullptr OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin) OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames)); + printListing(root, nullptr, lsflags); } } @@ -539,6 +547,7 @@ void CardReader::release() { #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) nrFiles = 0; #endif + SERIAL_ECHO_MSG(STR_SD_CARD_RELEASED); } /** @@ -572,7 +581,7 @@ void CardReader::startOrResumeFilePrinting() { // void CardReader::endFilePrintNow(TERN_(SD_RESORT, const bool re_sort/*=false*/)) { TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0); - TERN_(HAS_DWIN_E3V2_BASIC, HMI_flag.print_finish = flag.sdprinting); + TERN_(DWIN_CREALITY_LCD, HMI_flag.print_finish = flag.sdprinting); flag.abort_sd_printing = false; if (isFileOpen()) file.close(); TERN_(SD_RESORT, if (re_sort) presort()); @@ -634,7 +643,7 @@ void announceOpen(const uint8_t doing, const char * const path) { // - 2 : Resuming from a sub-procedure // void CardReader::openFileRead(const char * const path, const uint8_t subcall_type/*=0*/) { - if (!isMounted()) return; + if (!isMounted()) return openFailed(path); switch (subcall_type) { case 0: // Starting a new print. "Now fresh file: ..." @@ -676,7 +685,7 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ SdFile *diveDir; const char * const fname = diveToFile(true, diveDir, path); - if (!fname) return; + if (!fname) return openFailed(path); if (file.open(diveDir, fname, O_READ)) { filesize = file.fileSize(); @@ -712,21 +721,20 @@ void CardReader::openFileWrite(const char * const path) { SdFile *diveDir; const char * const fname = diveToFile(false, diveDir, path); - if (!fname) return; + if (!fname) return openFailed(path); - #if ENABLED(SDCARD_READONLY) - openFailed(fname); - #else + #if DISABLED(SDCARD_READONLY) if (file.open(diveDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { flag.saving = true; selectFileByName(fname); TERN_(EMERGENCY_PARSER, emergency_parser.disable()); echo_write_to_file(fname); ui.set_status(fname); + return; } - else - openFailed(fname); #endif + + openFailed(fname); } // @@ -781,7 +789,7 @@ void CardReader::removeFile(const char * const name) { } void CardReader::report_status() { - if (isPrinting()) { + if (isPrinting() || isPaused()) { SERIAL_ECHOPGM(STR_SD_PRINTING_BYTE, sdpos); SERIAL_CHAR('/'); SERIAL_ECHOLN(filesize); diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index d2f462c2a777..6fe75f760e2d 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -89,6 +89,8 @@ typedef struct { ; } card_flags_t; +enum ListingFlags : uint8_t { LS_LONG_FILENAME, LS_ONLY_BIN, LS_TIMESTAMP }; + #if ENABLED(AUTO_REPORT_SD_STATUS) #include "../libs/autoreport.h" #endif @@ -207,13 +209,7 @@ class CardReader { FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); } #endif - static void ls( - TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false) - #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) - , - #endif - TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) - ); + static void ls(const uint8_t lsflags); #if ENABLED(POWER_LOSS_RECOVERY) static bool jobRecoverFileExists(); @@ -348,10 +344,7 @@ class CardReader { 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 - OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false) - OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) + static void printListing(SdFile parent, const char * const prepend, const uint8_t lsflags OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr) ); diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h index 6cfc0152d058..57352a351873 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h @@ -1,270 +1,272 @@ -/* Copyright (C) 2015-2016 Andrew J. Kroll - and -Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as publishe7d by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : https://www.circuitsathome.com -e-mail : support@circuitsathome.com +/* + * Copyright (C) 2015-2016 Andrew J. Kroll + * and + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as publishe7d by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + * */ #if defined(USB_HOST_SHIELD_H) && !defined(USB_HOST_SHIELD_LOADED) #define USB_HOST_SHIELD_LOADED + #include #ifndef digitalPinToInterrupt -#error digitalPinToInterrupt not defined, complain to your board maintainer. + #error digitalPinToInterrupt not defined, complain to your board maintainer. #endif #if USB_HOST_SHIELD_USE_ISR -// allow two slots. this makes the maximum allowed shield count TWO -// for AVRs this is limited to pins 2 and 3 ONLY -// for all other boards, one odd and one even pin number is allowed. -static MAX3421E_HOST *ISReven; -static MAX3421E_HOST *ISRodd; + // allow two slots. this makes the maximum allowed shield count TWO + // for AVRs this is limited to pins 2 and 3 ONLY + // for all other boards, one odd and one even pin number is allowed. + static MAX3421E_HOST *ISReven; + static MAX3421E_HOST *ISRodd; -static void UHS_NI call_ISReven() { - ISReven->ISRTask(); -} + static void UHS_NI call_ISReven() { + ISReven->ISRTask(); + } -static void UHS_NI call_ISRodd() { - UHS_PIN_WRITE(LED_BUILTIN, HIGH); - ISRodd->ISRTask(); -} + static void UHS_NI call_ISRodd() { + UHS_PIN_WRITE(LED_BUILTIN, HIGH); + ISRodd->ISRTask(); + } #endif void UHS_NI MAX3421E_HOST::resume_host() { - // Used on MCU that lack control of IRQ priority (AVR). - // Resumes ISRs. - // NOTE: you must track the state yourself! -#ifdef __AVR__ - noInterrupts(); - if(irq_pin & 1) { - ISRodd = this; - attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); - } else { - ISReven = this; - attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); - } - interrupts(); -#endif - + // Used on MCU that lack control of IRQ priority (AVR). + // Resumes ISRs. + // NOTE: you must track the state yourself! + #ifdef __AVR__ + noInterrupts(); + if (irq_pin & 1) { + ISRodd = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); + } else { + ISReven = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); + } + interrupts(); + #endif } + /* write single byte into MAX3421e register */ void UHS_NI MAX3421E_HOST::regWr(uint8_t reg, uint8_t data) { - SPIclass.beginTransaction(MAX3421E_SPI_Settings); - MARLIN_UHS_WRITE_SS(LOW); - SPIclass.transfer(reg | 0x02); - SPIclass.transfer(data); - MARLIN_UHS_WRITE_SS(HIGH); - SPIclass.endTransaction(); + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg | 0x02); + SPIclass.transfer(data); + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); } - /* multiple-byte write */ /* returns a pointer to memory position after last written */ uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { - SPIclass.beginTransaction(MAX3421E_SPI_Settings); - MARLIN_UHS_WRITE_SS(LOW); - SPIclass.transfer(reg | 0x02); - //printf("%2.2x :", reg); - - while(nbytes) { - SPIclass.transfer(*data_p); - //printf("%2.2x ", *data_p); - nbytes--; - data_p++; // advance data pointer - } - MARLIN_UHS_WRITE_SS(HIGH); - SPIclass.endTransaction(); - //printf("\r\n"); - return (data_p); + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg | 0x02); + //printf("%2.2x :", reg); + + while (nbytes) { + SPIclass.transfer(*data_p); + //printf("%2.2x ", *data_p); + nbytes--; + data_p++; // advance data pointer + } + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); + //printf("\r\n"); + return (data_p); } + /* GPIO write */ /*GPIO byte is split between 2 registers, so two writes are needed to write one byte */ /* GPOUT bits are in the low nybble. 0-3 in IOPINS1, 4-7 in IOPINS2 */ void UHS_NI MAX3421E_HOST::gpioWr(uint8_t data) { - regWr(rIOPINS1, data); - data >>= 4; - regWr(rIOPINS2, data); - return; + regWr(rIOPINS1, data); + data >>= 4; + regWr(rIOPINS2, data); + return; } /* single host register read */ uint8_t UHS_NI MAX3421E_HOST::regRd(uint8_t reg) { - SPIclass.beginTransaction(MAX3421E_SPI_Settings); - MARLIN_UHS_WRITE_SS(LOW); - SPIclass.transfer(reg); - uint8_t rv = SPIclass.transfer(0); - MARLIN_UHS_WRITE_SS(HIGH); - SPIclass.endTransaction(); - return (rv); + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg); + uint8_t rv = SPIclass.transfer(0); + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); + return (rv); } /* multiple-byte register read */ /* returns a pointer to a memory position after last read */ uint8_t* UHS_NI MAX3421E_HOST::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { - SPIclass.beginTransaction(MAX3421E_SPI_Settings); - MARLIN_UHS_WRITE_SS(LOW); - SPIclass.transfer(reg); - while(nbytes) { - *data_p++ = SPIclass.transfer(0); - nbytes--; - } - MARLIN_UHS_WRITE_SS(HIGH); - SPIclass.endTransaction(); - return ( data_p); + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg); + while (nbytes) { + *data_p++ = SPIclass.transfer(0); + nbytes--; + } + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); + return ( data_p); } /* GPIO read. See gpioWr for explanation */ /* GPIN pins are in high nybbles of IOPINS1, IOPINS2 */ uint8_t UHS_NI MAX3421E_HOST::gpioRd() { - uint8_t gpin = 0; - gpin = regRd(rIOPINS2); //pins 4-7 - gpin &= 0xF0; //clean lower nybble - gpin |= (regRd(rIOPINS1) >> 4); //shift low bits and OR with upper from previous operation. - return ( gpin); + uint8_t gpin = 0; + gpin = regRd(rIOPINS2); // pins 4-7 + gpin &= 0xF0; // clean lower nybble + gpin |= (regRd(rIOPINS1) >> 4); // shift low bits and OR with upper from previous operation. + return (gpin); } /* reset MAX3421E. Returns number of microseconds it took for PLL to stabilize after reset - or zero if PLL haven't stabilized in 65535 cycles */ +or zero if PLL haven't stabilized in 65535 cycles */ uint16_t UHS_NI MAX3421E_HOST::reset() { - uint16_t i = 0; - - // Initiate chip reset - regWr(rUSBCTL, bmCHIPRES); - regWr(rUSBCTL, 0x00); - - int32_t now; - uint32_t expires = micros() + 65535; - - // Enable full-duplex SPI so we can read rUSBIRQ - regWr(rPINCTL, bmFDUPSPI); - while((int32_t)(micros() - expires) < 0L) { - if((regRd(rUSBIRQ) & bmOSCOKIRQ)) { - break; - } - } - now = (int32_t)(micros() - expires); - if(now < 0L) { - i = 65535 + now; // Note this subtracts, as now is negative - } - return (i); + uint16_t i = 0; + + // Initiate chip reset + regWr(rUSBCTL, bmCHIPRES); + regWr(rUSBCTL, 0x00); + + int32_t now; + uint32_t expires = micros() + 65535; + + // Enable full-duplex SPI so we can read rUSBIRQ + regWr(rPINCTL, bmFDUPSPI); + while ((int32_t)(micros() - expires) < 0L) { + if ((regRd(rUSBIRQ) & bmOSCOKIRQ)) { + break; + } + } + now = (int32_t)(micros() - expires); + if (now < 0L) { + i = 65535 + now; // Note this subtracts, as now is negative + } + return (i); } void UHS_NI MAX3421E_HOST::VBUS_changed() { - /* modify USB task state because Vbus changed or unknown */ - uint8_t speed = 1; - //printf("\r\n\r\n\r\n\r\nSTATE %2.2x -> ", usb_task_state); - switch(vbusState) { - case LSHOST: // Low speed - - speed = 0; - // Intentional fall-through - case FSHOST: // Full speed - // Start device initialization if we are not initializing - // Resets to the device cause an IRQ - // usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; - //if((usb_task_state & UHS_USB_HOST_STATE_MASK) != UHS_USB_HOST_STATE_DETACHED) { - ReleaseChildren(); - if(!doingreset) { - if(usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE) { - usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; - } else if(usb_task_state != UHS_USB_HOST_STATE_WAIT_BUS_READY) { - usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE; - } - } - sof_countdown = 0; - break; - case SE1: //illegal state - sof_countdown = 0; - doingreset = false; - ReleaseChildren(); - usb_task_state = UHS_USB_HOST_STATE_ILLEGAL; - break; - case SE0: //disconnected - default: - sof_countdown = 0; - doingreset = false; - ReleaseChildren(); - usb_task_state = UHS_USB_HOST_STATE_IDLE; - break; + /* modify USB task state because Vbus changed or unknown */ + uint8_t speed = 1; + //printf("\r\n\r\n\r\n\r\nSTATE %2.2x -> ", usb_task_state); + switch (vbusState) { + case LSHOST: // Low speed + speed = 0; + // Intentional fall-through + case FSHOST: // Full speed + // Start device initialization if we are not initializing + // Resets to the device cause an IRQ + // usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; + //if ((usb_task_state & UHS_USB_HOST_STATE_MASK) != UHS_USB_HOST_STATE_DETACHED) { + ReleaseChildren(); + if (!doingreset) { + if (usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE) { + usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; + } else if (usb_task_state != UHS_USB_HOST_STATE_WAIT_BUS_READY) { + usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE; } - usb_host_speed = speed; - //printf("0x%2.2x\r\n\r\n\r\n\r\n", usb_task_state); - return; -}; + } + sof_countdown = 0; + break; + case SE1: // illegal state + sof_countdown = 0; + doingreset = false; + ReleaseChildren(); + usb_task_state = UHS_USB_HOST_STATE_ILLEGAL; + break; + case SE0: // disconnected + default: + sof_countdown = 0; + doingreset = false; + ReleaseChildren(); + usb_task_state = UHS_USB_HOST_STATE_IDLE; + break; + } + usb_host_speed = speed; + //printf("0x%2.2x\r\n\r\n\r\n\r\n", usb_task_state); + return; +} /** - * Probe bus to determine device presence and speed, - * then switch host to detected speed. + * Probe bus to determine device presence and speed, + * then switch host to detected speed. */ void UHS_NI MAX3421E_HOST::busprobe() { - uint8_t bus_sample; - uint8_t tmpdata; - bus_sample = regRd(rHRSL); //Get J,K status - bus_sample &= (bmJSTATUS | bmKSTATUS); //zero the rest of the byte - switch(bus_sample) { //start full-speed or low-speed host - case(bmJSTATUS): - // Serial.println("J"); - if((regRd(rMODE) & bmLOWSPEED) == 0) { - regWr(rMODE, MODE_FS_HOST); // start full-speed host - vbusState = FSHOST; - } else { - regWr(rMODE, MODE_LS_HOST); // start low-speed host - vbusState = LSHOST; - } - #ifdef USB_HOST_MANUAL_POLL - enable_frame_irq(true); - #endif - tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation - regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. - regWr(rMODE, tmpdata); - break; - case(bmKSTATUS): - // Serial.println("K"); - if((regRd(rMODE) & bmLOWSPEED) == 0) { - regWr(rMODE, MODE_LS_HOST); // start low-speed host - vbusState = LSHOST; - } else { - regWr(rMODE, MODE_FS_HOST); // start full-speed host - vbusState = FSHOST; - } - #ifdef USB_HOST_MANUAL_POLL - enable_frame_irq(true); - #endif - tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation - regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. - regWr(rMODE, tmpdata); - break; - case(bmSE1): //illegal state - // Serial.println("I"); - regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); - vbusState = SE1; - // sofevent = false; - break; - case(bmSE0): //disconnected state - // Serial.println("D"); - regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); - vbusState = SE0; - // sofevent = false; - break; - }//end switch( bus_sample ) + uint8_t bus_sample; + uint8_t tmpdata; + bus_sample = regRd(rHRSL); // Get J,K status + bus_sample &= (bmJSTATUS | bmKSTATUS); // zero the rest of the byte + switch (bus_sample) { // start full-speed or low-speed host + case bmJSTATUS: + // Serial.println("J"); + if ((regRd(rMODE) & bmLOWSPEED) == 0) { + regWr(rMODE, MODE_FS_HOST); // start full-speed host + vbusState = FSHOST; + } else { + regWr(rMODE, MODE_LS_HOST); // start low-speed host + vbusState = LSHOST; + } + #ifdef USB_HOST_MANUAL_POLL + enable_frame_irq(true); + #endif + tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation + regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. + regWr(rMODE, tmpdata); + break; + case bmKSTATUS: + // Serial.println("K"); + if ((regRd(rMODE) & bmLOWSPEED) == 0) { + regWr(rMODE, MODE_LS_HOST); // start low-speed host + vbusState = LSHOST; + } else { + regWr(rMODE, MODE_FS_HOST); // start full-speed host + vbusState = FSHOST; + } + #ifdef USB_HOST_MANUAL_POLL + enable_frame_irq(true); + #endif + tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation + regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. + regWr(rMODE, tmpdata); + break; + case bmSE1: // illegal state + // Serial.println("I"); + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); + vbusState = SE1; + // sofevent = false; + break; + case bmSE0: // disconnected state + // Serial.println("D"); + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); + vbusState = SE0; + // sofevent = false; + break; + } // end switch ( bus_sample ) } /** @@ -274,146 +276,145 @@ void UHS_NI MAX3421E_HOST::busprobe() { * @return 0 on success, -1 on error */ int16_t UHS_NI MAX3421E_HOST::Init(int16_t mseconds) { - usb_task_state = UHS_USB_HOST_STATE_INITIALIZE; //set up state machine - // Serial.print("MAX3421E 'this' USB Host @ 0x"); - // Serial.println((uint32_t)this, HEX); - // Serial.print("MAX3421E 'this' USB Host Address Pool @ 0x"); - // Serial.println((uint32_t)GetAddressPool(), HEX); - Init_dyn_SWI(); - UHS_printf_HELPER_init(); - noInterrupts(); -#ifdef ARDUINO_AVR_ADK - // For Mega ADK, which has a Max3421e on-board, - // set MAX_RESET to output mode, and then set it to HIGH - // PORTJ bit 2 - if(irq_pin == 54) { - DDRJ |= 0x04; // output - PORTJ |= 0x04; // HIGH - } -#endif - SPIclass.begin(); -#ifdef ARDUINO_AVR_ADK - if(irq_pin == 54) { - DDRE &= ~0x20; // input - PORTE |= 0x20; // pullup - } else -#endif - pinMode(irq_pin, INPUT_PULLUP); - //UHS_PIN_WRITE(irq_pin, HIGH); - pinMode(ss_pin, OUTPUT); - MARLIN_UHS_WRITE_SS(HIGH); - -#ifdef USB_HOST_SHIELD_TIMING_PIN - pinMode(USB_HOST_SHIELD_TIMING_PIN, OUTPUT); - // My counter/timer can't work on an inverted gate signal - // so we gate using a high pulse -- AJK - UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); -#endif - interrupts(); - -#if USB_HOST_SHIELD_USE_ISR - int intr = digitalPinToInterrupt(irq_pin); - if(intr == NOT_AN_INTERRUPT) { -#ifdef ARDUINO_AVR_ADK - if(irq_pin == 54) - intr = 6; - else -#endif - return (-2); - } - SPIclass.usingInterrupt(intr); -#else - SPIclass.usingInterrupt(255); -#endif -#ifndef NO_AUTO_SPEED - // test to get to reset acceptance. - uint32_t spd = UHS_MAX3421E_SPD; -again: - MAX3421E_SPI_Settings = SPISettings(spd, MSBFIRST, SPI_MODE0); - if(reset() == 0) { - MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); - if(spd > 1999999) { - spd -= 1000000; - goto again; - } - return (-1); - } else { - // reset passes, does 64k? - uint8_t sample_wr = 0; - uint8_t sample_rd = 0; - uint8_t gpinpol_copy = regRd(rGPINPOL); - for(uint16_t j = 0; j < 65535; j++) { - regWr(rGPINPOL, sample_wr); - sample_rd = regRd(rGPINPOL); - if(sample_rd != sample_wr) { - MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); - if(spd > 1999999) { - spd -= 1000000; - goto again; - } - return (-1); - } - sample_wr++; - } - regWr(rGPINPOL, gpinpol_copy); - } - - MAX_HOST_DEBUG(PSTR("Pass SPI speed %lu\r\n"), spd); -#endif - - if(reset() == 0) { //OSCOKIRQ hasn't asserted in time - MAX_HOST_DEBUG(PSTR("OSCOKIRQ hasn't asserted in time")); - return ( -1); - } - - /* MAX3421E - full-duplex SPI, interrupt kind, vbus off */ - regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE | GPX_VBDET)); - - // Delay a minimum of 1 second to ensure any capacitors are drained. - // 1 second is required to make sure we do not smoke a Microdrive! - if(mseconds != INT16_MIN) { - if(mseconds < 1000) mseconds = 1000; - delay(mseconds); // We can't depend on SOF timer here. - } - - regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host - - // Enable interrupts on the MAX3421e - regWr(rHIEN, IRQ_CHECK_MASK); - // Enable interrupt pin on the MAX3421e, set pulse width for edge - regWr(rCPUCTL, (bmIE | bmPULSEWIDTH)); - - /* check if device is connected */ - regWr(rHCTL, bmSAMPLEBUS); // sample USB bus - while(!(regRd(rHCTL) & bmSAMPLEBUS)); //wait for sample operation to finish - - busprobe(); //check if anything is connected - VBUS_changed(); - - // GPX pin on. This is done here so that a change is detected if we have a switch connected. - /* MAX3421E - full-duplex SPI, interrupt kind, vbus on */ - regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE)); - regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. - regWr(rHCTL, bmBUSRST); // issue bus reset to force generate yet another possible IRQ - - -#if USB_HOST_SHIELD_USE_ISR - // Attach ISR to service IRQ from MAX3421e - noInterrupts(); - if(irq_pin & 1) { - ISRodd = this; - attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); - } else { - ISReven = this; - attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); + usb_task_state = UHS_USB_HOST_STATE_INITIALIZE; //set up state machine + //Serial.print("MAX3421E 'this' USB Host @ 0x"); + //Serial.println((uint32_t)this, HEX); + //Serial.print("MAX3421E 'this' USB Host Address Pool @ 0x"); + //Serial.println((uint32_t)GetAddressPool(), HEX); + Init_dyn_SWI(); + UHS_printf_HELPER_init(); + noInterrupts(); + #ifdef ARDUINO_AVR_ADK + // For Mega ADK, which has a Max3421e on-board, + // set MAX_RESET to output mode, and then set it to HIGH + // PORTJ bit 2 + if (irq_pin == 54) { + DDRJ |= 0x04; // output + PORTJ |= 0x04; // HIGH + } + #endif + SPIclass.begin(); + #ifdef ARDUINO_AVR_ADK + if (irq_pin == 54) { + DDRE &= ~0x20; // input + PORTE |= 0x20; // pullup + } else + #endif + pinMode(irq_pin, INPUT_PULLUP); + //UHS_PIN_WRITE(irq_pin, HIGH); + pinMode(ss_pin, OUTPUT); + MARLIN_UHS_WRITE_SS(HIGH); + + #ifdef USB_HOST_SHIELD_TIMING_PIN + pinMode(USB_HOST_SHIELD_TIMING_PIN, OUTPUT); + // My counter/timer can't work on an inverted gate signal + // so we gate using a high pulse -- AJK + UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); + #endif + interrupts(); + + #if USB_HOST_SHIELD_USE_ISR + int intr = digitalPinToInterrupt(irq_pin); + if (intr == NOT_AN_INTERRUPT) { + #ifdef ARDUINO_AVR_ADK + if (irq_pin == 54) + intr = 6; + else + #endif + return (-2); + } + SPIclass.usingInterrupt(intr); + #else + SPIclass.usingInterrupt(255); + #endif + #ifndef NO_AUTO_SPEED + // test to get to reset acceptance. + uint32_t spd = UHS_MAX3421E_SPD; + again: + MAX3421E_SPI_Settings = SPISettings(spd, MSBFIRST, SPI_MODE0); + if (reset() == 0) { + MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); + if (spd > 1999999) { + spd -= 1000000; + goto again; + } + return (-1); + } else { + // reset passes, does 64k? + uint8_t sample_wr = 0; + uint8_t sample_rd = 0; + uint8_t gpinpol_copy = regRd(rGPINPOL); + for (uint16_t j = 0; j < 65535; j++) { + regWr(rGPINPOL, sample_wr); + sample_rd = regRd(rGPINPOL); + if (sample_rd != sample_wr) { + MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); + if (spd > 1999999) { + spd -= 1000000; + goto again; + } + return (-1); } - interrupts(); -#endif - //printf("\r\nrPINCTL 0x%2.2X\r\n", rPINCTL); - //printf("rCPUCTL 0x%2.2X\r\n", rCPUCTL); - //printf("rHIEN 0x%2.2X\r\n", rHIEN); - //printf("irq_pin %i\r\n", irq_pin); - return 0; + sample_wr++; + } + regWr(rGPINPOL, gpinpol_copy); + } + + MAX_HOST_DEBUG(PSTR("Pass SPI speed %lu\r\n"), spd); + #endif + + if (reset() == 0) { // OSCOKIRQ hasn't asserted in time + MAX_HOST_DEBUG(PSTR("OSCOKIRQ hasn't asserted in time")); + return ( -1); + } + + /* MAX3421E - full-duplex SPI, interrupt kind, vbus off */ + regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE | GPX_VBDET)); + + // Delay a minimum of 1 second to ensure any capacitors are drained. + // 1 second is required to make sure we do not smoke a Microdrive! + if (mseconds != INT16_MIN) { + if (mseconds < 1000) mseconds = 1000; + delay(mseconds); // We can't depend on SOF timer here. + } + + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host + + // Enable interrupts on the MAX3421e + regWr(rHIEN, IRQ_CHECK_MASK); + // Enable interrupt pin on the MAX3421e, set pulse width for edge + regWr(rCPUCTL, (bmIE | bmPULSEWIDTH)); + + /* check if device is connected */ + regWr(rHCTL, bmSAMPLEBUS); // sample USB bus + while (!(regRd(rHCTL) & bmSAMPLEBUS)); // wait for sample operation to finish + + busprobe(); // check if anything is connected + VBUS_changed(); + + // GPX pin on. This is done here so that a change is detected if we have a switch connected. + /* MAX3421E - full-duplex SPI, interrupt kind, vbus on */ + regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE)); + regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. + regWr(rHCTL, bmBUSRST); // issue bus reset to force generate yet another possible IRQ + + #if USB_HOST_SHIELD_USE_ISR + // Attach ISR to service IRQ from MAX3421e + noInterrupts(); + if (irq_pin & 1) { + ISRodd = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); + } else { + ISReven = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); + } + interrupts(); + #endif + //printf("\r\nrPINCTL 0x%2.2X\r\n", rPINCTL); + //printf("rCPUCTL 0x%2.2X\r\n", rCPUCTL); + //printf("rHIEN 0x%2.2X\r\n", rHIEN); + //printf("irq_pin %i\r\n", irq_pin); + return 0; } /** @@ -426,41 +427,41 @@ int16_t UHS_NI MAX3421E_HOST::Init(int16_t mseconds) { * @return 0 on success */ uint8_t UHS_NI MAX3421E_HOST::SetAddress(uint8_t addr, uint8_t ep, UHS_EpInfo **ppep, uint16_t &nak_limit) { - UHS_Device *p = addrPool.GetUsbDevicePtr(addr); + UHS_Device *p = addrPool.GetUsbDevicePtr(addr); - if(!p) - return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; + if (!p) + return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; - if(!p->epinfo) - return UHS_HOST_ERROR_NULL_EPINFO; + if (!p->epinfo) + return UHS_HOST_ERROR_NULL_EPINFO; - *ppep = getEpInfoEntry(addr, ep); + *ppep = getEpInfoEntry(addr, ep); - if(!*ppep) - return UHS_HOST_ERROR_NO_ENDPOINT_IN_TABLE; + if (!*ppep) + return UHS_HOST_ERROR_NO_ENDPOINT_IN_TABLE; - nak_limit = (0x0001UL << (((*ppep)->bmNakPower > UHS_USB_NAK_MAX_POWER) ? UHS_USB_NAK_MAX_POWER : (*ppep)->bmNakPower)); - nak_limit--; - /* - USBTRACE2("\r\nAddress: ", addr); - USBTRACE2(" EP: ", ep); - USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower); - USBTRACE2(" NAK Limit: ", nak_limit); - USBTRACE("\r\n"); - */ - regWr(rPERADDR, addr); //set peripheral address + nak_limit = (0x0001UL << (((*ppep)->bmNakPower > UHS_USB_NAK_MAX_POWER) ? UHS_USB_NAK_MAX_POWER : (*ppep)->bmNakPower)); + nak_limit--; + /* + USBTRACE2("\r\nAddress: ", addr); + USBTRACE2(" EP: ", ep); + USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower); + USBTRACE2(" NAK Limit: ", nak_limit); + USBTRACE("\r\n"); + */ + regWr(rPERADDR, addr); // set peripheral address - uint8_t mode = regRd(rMODE); + uint8_t mode = regRd(rMODE); - //Serial.print("\r\nMode: "); - //Serial.println( mode, HEX); - //Serial.print("\r\nLS: "); - //Serial.println(p->speed, HEX); + //Serial.print("\r\nMode: "); + //Serial.println( mode, HEX); + //Serial.print("\r\nLS: "); + //Serial.println(p->speed, HEX); - // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise - regWr(rMODE, (p->speed) ? mode & ~(bmHUBPRE | bmLOWSPEED) : mode | bmLOWSPEED | hub_present); + // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise + regWr(rMODE, (p->speed) ? mode & ~(bmHUBPRE | bmLOWSPEED) : mode | bmLOWSPEED | hub_present); - return 0; + return 0; } /** @@ -473,71 +474,70 @@ uint8_t UHS_NI MAX3421E_HOST::SetAddress(uint8_t addr, uint8_t ep, UHS_EpInfo ** * @return 0 on success */ uint8_t UHS_NI MAX3421E_HOST::InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data) { - uint8_t rcode = 0; - uint8_t pktsize; - - uint16_t nbytes = *nbytesptr; - MAX_HOST_DEBUG(PSTR("Requesting %i bytes "), nbytes); - uint8_t maxpktsize = pep->maxPktSize; - - *nbytesptr = 0; - regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value - - // use a 'break' to exit this loop - while(1) { - rcode = dispatchPkt(MAX3421E_tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS. -#if 0 - // This issue should be resolved now. - if(rcode == UHS_HOST_ERROR_TOGERR) { - //MAX_HOST_DEBUG(PSTR("toggle wrong\r\n")); - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value - continue; - } -#endif - if(rcode) { - //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! dispatchPkt %2.2x\r\n"), rcode); - break; //should be 0, indicating ACK. Else return error code. - } - /* check for RCVDAVIRQ and generate error if not present */ - /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */ - if((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) { - //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n")); - rcode = 0xF0; //receive error - break; - } - pktsize = regRd(rRCVBC); //number of received bytes - MAX_HOST_DEBUG(PSTR("Got %i bytes \r\n"), pktsize); - - if(pktsize > nbytes) { //certain devices send more than asked - //MAX_HOST_DEBUG(PSTR(">>>>>>>> Warning: wanted %i bytes but got %i.\r\n"), nbytes, pktsize); - pktsize = nbytes; - } - - int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr); - - if(mem_left < 0) - mem_left = 0; - - data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data); - - regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer - *nbytesptr += pktsize; // add this packet's byte count to total transfer length - - /* The transfer is complete under two conditions: */ - /* 1. The device sent a short packet (L.T. maxPacketSize) */ - /* 2. 'nbytes' have been transferred. */ - if((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes? - { - // Save toggle value - pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0; - //MAX_HOST_DEBUG(PSTR("\r\n")); - rcode = 0; - break; - } // if - } //while( 1 ) - return ( rcode); + uint8_t rcode = 0; + uint8_t pktsize; + + uint16_t nbytes = *nbytesptr; + MAX_HOST_DEBUG(PSTR("Requesting %i bytes "), nbytes); + uint8_t maxpktsize = pep->maxPktSize; + + *nbytesptr = 0; + regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); // set toggle value + + // use a 'break' to exit this loop + while (1) { + rcode = dispatchPkt(MAX3421E_tokIN, pep->epAddr, nak_limit); // IN packet to EP-'endpoint'. Function takes care of NAKS. + #if 0 + // This issue should be resolved now. + if (rcode == UHS_HOST_ERROR_TOGERR) { + //MAX_HOST_DEBUG(PSTR("toggle wrong\r\n")); + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); // set toggle value + continue; + } + #endif + if (rcode) { + //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! dispatchPkt %2.2x\r\n"), rcode); + break; // should be 0, indicating ACK. Else return error code. + } + /* check for RCVDAVIRQ and generate error if not present */ + /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */ + if ((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) { + //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n")); + rcode = 0xF0; // receive error + break; + } + pktsize = regRd(rRCVBC); // number of received bytes + MAX_HOST_DEBUG(PSTR("Got %i bytes \r\n"), pktsize); + + if (pktsize > nbytes) { // certain devices send more than asked + //MAX_HOST_DEBUG(PSTR(">>>>>>>> Warning: wanted %i bytes but got %i.\r\n"), nbytes, pktsize); + pktsize = nbytes; + } + + int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr); + + if (mem_left < 0) + mem_left = 0; + + data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data); + + regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer + *nbytesptr += pktsize; // add this packet's byte count to total transfer length + + /* The transfer is complete under two conditions: */ + /* 1. The device sent a short packet (L.T. maxPacketSize) */ + /* 2. 'nbytes' have been transferred. */ + if ((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) { // have we transferred 'nbytes' bytes? + // Save toggle value + pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0; + //MAX_HOST_DEBUG(PSTR("\r\n")); + rcode = 0; + break; + } // if + } // while( 1 ) + return (rcode); } /** @@ -550,72 +550,72 @@ uint8_t UHS_NI MAX3421E_HOST::InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, ui * @return 0 on success */ uint8_t UHS_NI MAX3421E_HOST::OutTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) { - uint8_t rcode = UHS_HOST_ERROR_NONE; - uint8_t retry_count; - uint8_t *data_p = data; //local copy of the data pointer - uint16_t bytes_tosend; - uint16_t nak_count; - uint16_t bytes_left = nbytes; - - uint8_t maxpktsize = pep->maxPktSize; - - if(maxpktsize < 1 || maxpktsize > 64) - return UHS_HOST_ERROR_BAD_MAX_PACKET_SIZE; - - unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; - - regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value - - while(bytes_left) { - SYSTEM_OR_SPECIAL_YIELD(); - retry_count = 0; - nak_count = 0; - bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left; - bytesWr(rSNDFIFO, bytes_tosend, data_p); //filling output FIFO - regWr(rSNDBC, bytes_tosend); //set number of bytes - regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); //dispatch packet - while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ - regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ - rcode = (regRd(rHRSL) & 0x0F); - - while(rcode && ((long)(millis() - timeout) < 0L)) { - switch(rcode) { - case UHS_HOST_ERROR_NAK: - nak_count++; - if(nak_limit && (nak_count == nak_limit)) - goto breakout; - break; - case UHS_HOST_ERROR_TIMEOUT: - retry_count++; - if(retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) - goto breakout; - break; - case UHS_HOST_ERROR_TOGERR: - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value - break; - default: - goto breakout; - }//switch( rcode - - /* process NAK according to Host out NAK bug */ - regWr(rSNDBC, 0); - regWr(rSNDFIFO, *data_p); - regWr(rSNDBC, bytes_tosend); - regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); //dispatch packet - while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ - regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ - rcode = (regRd(rHRSL) & 0x0F); - SYSTEM_OR_SPECIAL_YIELD(); - }//while( rcode && .... - bytes_left -= bytes_tosend; - data_p += bytes_tosend; - }//while( bytes_left... -breakout: - - pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; //bmSNDTOG1 : bmSNDTOG0; //update toggle - return ( rcode); //should be 0 in all cases + uint8_t rcode = UHS_HOST_ERROR_NONE; + uint8_t retry_count; + uint8_t *data_p = data; // local copy of the data pointer + uint16_t bytes_tosend; + uint16_t nak_count; + uint16_t bytes_left = nbytes; + + uint8_t maxpktsize = pep->maxPktSize; + + if (maxpktsize < 1 || maxpktsize > 64) + return UHS_HOST_ERROR_BAD_MAX_PACKET_SIZE; + + unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; + + regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); // set toggle value + + while (bytes_left) { + SYSTEM_OR_SPECIAL_YIELD(); + retry_count = 0; + nak_count = 0; + bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left; + bytesWr(rSNDFIFO, bytes_tosend, data_p); // filling output FIFO + regWr(rSNDBC, bytes_tosend); // set number of bytes + regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); // dispatch packet + while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); // wait for the completion IRQ + regWr(rHIRQ, bmHXFRDNIRQ); // clear IRQ + rcode = (regRd(rHRSL) & 0x0F); + + while (rcode && ((long)(millis() - timeout) < 0L)) { + switch (rcode) { + case UHS_HOST_ERROR_NAK: + nak_count++; + if (nak_limit && (nak_count == nak_limit)) + goto breakout; + break; + case UHS_HOST_ERROR_TIMEOUT: + retry_count++; + if (retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) + goto breakout; + break; + case UHS_HOST_ERROR_TOGERR: + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); // set toggle value + break; + default: + goto breakout; + } // switch (rcode + + /* process NAK according to Host out NAK bug */ + regWr(rSNDBC, 0); + regWr(rSNDFIFO, *data_p); + regWr(rSNDBC, bytes_tosend); + regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); // dispatch packet + while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); // wait for the completion IRQ + regWr(rHIRQ, bmHXFRDNIRQ); // clear IRQ + rcode = (regRd(rHRSL) & 0x0F); + SYSTEM_OR_SPECIAL_YIELD(); + } // while (rcode && .... + bytes_left -= bytes_tosend; + data_p += bytes_tosend; + } // while (bytes_left... + breakout: + + pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; // bmSNDTOG1 : bmSNDTOG0; // update toggle + return (rcode); // should be 0 in all cases } /** @@ -633,45 +633,44 @@ uint8_t UHS_NI MAX3421E_HOST::OutTransfer(UHS_EpInfo *pep, uint16_t nak_limit, u /* return codes 0x00-0x0F are HRSLT( 0x00 being success ), 0xFF means timeout */ uint8_t UHS_NI MAX3421E_HOST::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) { - unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; - uint8_t tmpdata; - uint8_t rcode = UHS_HOST_ERROR_NONE; - uint8_t retry_count = 0; - uint16_t nak_count = 0; - - for(;;) { - regWr(rHXFR, (token | ep)); //launch the transfer - while((long)(millis() - timeout) < 0L) //wait for transfer completion - { - SYSTEM_OR_SPECIAL_YIELD(); - tmpdata = regRd(rHIRQ); - - if(tmpdata & bmHXFRDNIRQ) { - regWr(rHIRQ, bmHXFRDNIRQ); //clear the interrupt - //rcode = 0x00; - break; - }//if( tmpdata & bmHXFRDNIRQ - - }//while ( millis() < timeout - - rcode = (regRd(rHRSL) & 0x0F); //analyze transfer result - - switch(rcode) { - case UHS_HOST_ERROR_NAK: - nak_count++; - if(nak_limit && (nak_count == nak_limit)) - return (rcode); - delayMicroseconds(200); - break; - case UHS_HOST_ERROR_TIMEOUT: - retry_count++; - if(retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) - return (rcode); - break; - default: - return (rcode); - }//switch( rcode - } + unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; + uint8_t tmpdata; + uint8_t rcode = UHS_HOST_ERROR_NONE; + uint8_t retry_count = 0; + uint16_t nak_count = 0; + + for (;;) { + regWr(rHXFR, (token | ep)); // launch the transfer + while (long(millis() - timeout) < 0L) { // wait for transfer completion + SYSTEM_OR_SPECIAL_YIELD(); + tmpdata = regRd(rHIRQ); + + if (tmpdata & bmHXFRDNIRQ) { + regWr(rHIRQ, bmHXFRDNIRQ); // clear the interrupt + //rcode = 0x00; + break; + } // if (tmpdata & bmHXFRDNIRQ + + } // while (millis() < timeout + + rcode = (regRd(rHRSL) & 0x0F); // analyze transfer result + + switch (rcode) { + case UHS_HOST_ERROR_NAK: + nak_count++; + if (nak_limit && (nak_count == nak_limit)) + return (rcode); + delayMicroseconds(200); + break; + case UHS_HOST_ERROR_TIMEOUT: + retry_count++; + if (retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) + return (rcode); + break; + default: + return (rcode); + } // switch (rcode) + } } // @@ -679,325 +678,324 @@ uint8_t UHS_NI MAX3421E_HOST::dispatchPkt(uint8_t token, uint8_t ep, uint16_t na // UHS_EpInfo * UHS_NI MAX3421E_HOST::ctrlReqOpen(uint8_t addr, uint64_t Request, uint8_t *dataptr) { - uint8_t rcode; - UHS_EpInfo *pep = NULL; - uint16_t nak_limit = 0; - rcode = SetAddress(addr, 0, &pep, nak_limit); - - if(!rcode) { - - bytesWr(rSUDFIFO, 8, (uint8_t*)(&Request)); //transfer to setup packet FIFO - - rcode = dispatchPkt(MAX3421E_tokSETUP, 0, nak_limit); //dispatch packet - if(!rcode) { - if(dataptr != NULL) { - if(((Request)/* bmReqType*/ & 0x80) == 0x80) { - pep->bmRcvToggle = 1; //bmRCVTOG1; - } else { - pep->bmSndToggle = 1; //bmSNDTOG1; - } - } - } else { - pep = NULL; - } + uint8_t rcode; + UHS_EpInfo *pep = NULL; + uint16_t nak_limit = 0; + rcode = SetAddress(addr, 0, &pep, nak_limit); + + if (!rcode) { + + bytesWr(rSUDFIFO, 8, (uint8_t*)(&Request)); // transfer to setup packet FIFO + + rcode = dispatchPkt(MAX3421E_tokSETUP, 0, nak_limit); // dispatch packet + if (!rcode) { + if (dataptr != NULL) { + if (((Request)/* bmReqType*/ & 0x80) == 0x80) { + pep->bmRcvToggle = 1; //bmRCVTOG1; + } else { + pep->bmSndToggle = 1; //bmSNDTOG1; } - return pep; + } + } else { + pep = NULL; + } + } + return pep; } uint8_t UHS_NI MAX3421E_HOST::ctrlReqRead(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint16_t nbytes, uint8_t *dataptr) { - *read = 0; - uint16_t nak_limit = 0; - MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i\r\n"), *left); - if(*left) { -again: - *read = nbytes; - uint8_t rcode = InTransfer(pep, nak_limit, read, dataptr); - if(rcode == UHS_HOST_ERROR_TOGERR) { - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - goto again; - } - - if(rcode) { - MAX_HOST_DEBUG(PSTR("ctrlReqRead ERROR: %2.2x, left: %i, read %i\r\n"), rcode, *left, *read); - return rcode; - } - *left -= *read; - MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i, read %i\r\n"), *left, *read); - } - return 0; + *read = 0; + uint16_t nak_limit = 0; + MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i\r\n"), *left); + if (*left) { + again: + *read = nbytes; + uint8_t rcode = InTransfer(pep, nak_limit, read, dataptr); + if (rcode == UHS_HOST_ERROR_TOGERR) { + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + goto again; + } + + if (rcode) { + MAX_HOST_DEBUG(PSTR("ctrlReqRead ERROR: %2.2x, left: %i, read %i\r\n"), rcode, *left, *read); + return rcode; + } + *left -= *read; + MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i, read %i\r\n"), *left, *read); + } + return 0; } uint8_t UHS_NI MAX3421E_HOST::ctrlReqClose(UHS_EpInfo *pep, uint8_t bmReqType, uint16_t left, uint16_t nbytes, uint8_t *dataptr) { - uint8_t rcode = 0; - - //MAX_HOST_DEBUG(PSTR("Closing")); - if(((bmReqType & 0x80) == 0x80) && pep && left && dataptr) { - MAX_HOST_DEBUG(PSTR("ctrlReqRead Sinking %i\r\n"), left); - // If reading, sink the rest of the data. - while(left) { - uint16_t read = nbytes; - rcode = InTransfer(pep, 0, &read, dataptr); - if(rcode == UHS_HOST_ERROR_TOGERR) { - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - continue; - } - if(rcode) break; - left -= read; - if(read < nbytes) break; - } - } - if(!rcode) { - // Serial.println("Dispatching"); - rcode = dispatchPkt(((bmReqType & 0x80) == 0x80) ? MAX3421E_tokOUTHS : MAX3421E_tokINHS, 0, 0); //GET if direction - // } else { - // Serial.println("Bypassed Dispatch"); - } - return rcode; + uint8_t rcode = 0; + + //MAX_HOST_DEBUG(PSTR("Closing")); + if (((bmReqType & 0x80) == 0x80) && pep && left && dataptr) { + MAX_HOST_DEBUG(PSTR("ctrlReqRead Sinking %i\r\n"), left); + // If reading, sink the rest of the data. + while (left) { + uint16_t read = nbytes; + rcode = InTransfer(pep, 0, &read, dataptr); + if (rcode == UHS_HOST_ERROR_TOGERR) { + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + continue; + } + if (rcode) break; + left -= read; + if (read < nbytes) break; + } + } + if (!rcode) { + //Serial.println("Dispatching"); + rcode = dispatchPkt(((bmReqType & 0x80) == 0x80) ? MAX3421E_tokOUTHS : MAX3421E_tokINHS, 0, 0); //GET if direction + //} else { + //Serial.println("Bypassed Dispatch"); + } + return rcode; } /** * Bottom half of the ISR task */ void UHS_NI MAX3421E_HOST::ISRbottom() { - uint8_t x; - // Serial.print("Enter "); - // Serial.print((uint32_t)this,HEX); - // Serial.print(" "); - // Serial.println(usb_task_state, HEX); - - DDSB(); - if(condet) { - VBUS_changed(); -#if USB_HOST_SHIELD_USE_ISR - noInterrupts(); -#endif - condet = false; -#if USB_HOST_SHIELD_USE_ISR - interrupts(); -#endif - } - switch(usb_task_state) { - case UHS_USB_HOST_STATE_INITIALIZE: - // should never happen... - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_INITIALIZE\r\n")); - busprobe(); - VBUS_changed(); - break; - case UHS_USB_HOST_STATE_DEBOUNCE: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE\r\n")); - // This seems to not be needed. The host controller has debounce built in. - sof_countdown = UHS_HOST_DEBOUNCE_DELAY_MS; - usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE; - break; - case UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE\r\n")); - if(!sof_countdown) usb_task_state = UHS_USB_HOST_STATE_RESET_DEVICE; - break; - case UHS_USB_HOST_STATE_RESET_DEVICE: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_DEVICE\r\n")); - busevent = true; - usb_task_state = UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; - regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. - regWr(rHCTL, bmBUSRST); // issue bus reset - break; - case UHS_USB_HOST_STATE_RESET_NOT_COMPLETE: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_NOT_COMPLETE\r\n")); - if(!busevent) usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; - break; - case UHS_USB_HOST_STATE_WAIT_BUS_READY: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_WAIT_BUS_READY\r\n")); - usb_task_state = UHS_USB_HOST_STATE_CONFIGURING; - break; // don't fall through - - case UHS_USB_HOST_STATE_CONFIGURING: - usb_task_state = UHS_USB_HOST_STATE_CHECK; - x = Configuring(0, 1, usb_host_speed); - usb_error = x; - if(usb_task_state == UHS_USB_HOST_STATE_CHECK) { - if(x) { - MAX_HOST_DEBUG(PSTR("Error 0x%2.2x"), x); - if(x == UHS_HOST_ERROR_JERR) { - usb_task_state = UHS_USB_HOST_STATE_IDLE; - } else if(x != UHS_HOST_ERROR_DEVICE_INIT_INCOMPLETE) { - usb_error = x; - usb_task_state = UHS_USB_HOST_STATE_ERROR; - } - } else - usb_task_state = UHS_USB_HOST_STATE_CONFIGURING_DONE; - } - break; - - case UHS_USB_HOST_STATE_CHECK: - // Serial.println((uint32_t)__builtin_return_address(0), HEX); - break; - case UHS_USB_HOST_STATE_CONFIGURING_DONE: - usb_task_state = UHS_USB_HOST_STATE_RUNNING; - break; - #ifdef USB_HOST_MANUAL_POLL - case UHS_USB_HOST_STATE_RUNNING: - case UHS_USB_HOST_STATE_ERROR: - case UHS_USB_HOST_STATE_IDLE: - case UHS_USB_HOST_STATE_ILLEGAL: - enable_frame_irq(false); - break; - #else - case UHS_USB_HOST_STATE_RUNNING: - Poll_Others(); - for(x = 0; (usb_task_state == UHS_USB_HOST_STATE_RUNNING) && (x < UHS_HOST_MAX_INTERFACE_DRIVERS); x++) { - if(devConfig[x]) { - if(devConfig[x]->bPollEnable) devConfig[x]->Poll(); - } - } - // fall thru - #endif - default: - // Do nothing - break; - } // switch( usb_task_state ) - DDSB(); -#if USB_HOST_SHIELD_USE_ISR - if(condet) { - VBUS_changed(); - noInterrupts(); - condet = false; - interrupts(); + uint8_t x; + // Serial.print("Enter "); + // Serial.print((uint32_t)this,HEX); + // Serial.print(" "); + // Serial.println(usb_task_state, HEX); + + DDSB(); + if (condet) { + VBUS_changed(); + #if USB_HOST_SHIELD_USE_ISR + noInterrupts(); + #endif + condet = false; + #if USB_HOST_SHIELD_USE_ISR + interrupts(); + #endif + } + switch (usb_task_state) { + case UHS_USB_HOST_STATE_INITIALIZE: + // should never happen... + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_INITIALIZE\r\n")); + busprobe(); + VBUS_changed(); + break; + case UHS_USB_HOST_STATE_DEBOUNCE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE\r\n")); + // This seems to not be needed. The host controller has debounce built in. + sof_countdown = UHS_HOST_DEBOUNCE_DELAY_MS; + usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE; + break; + case UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE\r\n")); + if (!sof_countdown) usb_task_state = UHS_USB_HOST_STATE_RESET_DEVICE; + break; + case UHS_USB_HOST_STATE_RESET_DEVICE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_DEVICE\r\n")); + busevent = true; + usb_task_state = UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; + regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. + regWr(rHCTL, bmBUSRST); // issue bus reset + break; + case UHS_USB_HOST_STATE_RESET_NOT_COMPLETE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_NOT_COMPLETE\r\n")); + if (!busevent) usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; + break; + case UHS_USB_HOST_STATE_WAIT_BUS_READY: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_WAIT_BUS_READY\r\n")); + usb_task_state = UHS_USB_HOST_STATE_CONFIGURING; + break; // don't fall through + + case UHS_USB_HOST_STATE_CONFIGURING: + usb_task_state = UHS_USB_HOST_STATE_CHECK; + x = Configuring(0, 1, usb_host_speed); + usb_error = x; + if (usb_task_state == UHS_USB_HOST_STATE_CHECK) { + if (x) { + MAX_HOST_DEBUG(PSTR("Error 0x%2.2x"), x); + if (x == UHS_HOST_ERROR_JERR) { + usb_task_state = UHS_USB_HOST_STATE_IDLE; + } else if (x != UHS_HOST_ERROR_DEVICE_INIT_INCOMPLETE) { + usb_error = x; + usb_task_state = UHS_USB_HOST_STATE_ERROR; + } + } else + usb_task_state = UHS_USB_HOST_STATE_CONFIGURING_DONE; + } + break; + + case UHS_USB_HOST_STATE_CHECK: + // Serial.println((uint32_t)__builtin_return_address(0), HEX); + break; + case UHS_USB_HOST_STATE_CONFIGURING_DONE: + usb_task_state = UHS_USB_HOST_STATE_RUNNING; + break; + + #ifdef USB_HOST_MANUAL_POLL + case UHS_USB_HOST_STATE_RUNNING: + case UHS_USB_HOST_STATE_ERROR: + case UHS_USB_HOST_STATE_IDLE: + case UHS_USB_HOST_STATE_ILLEGAL: + enable_frame_irq(false); + break; + #else + case UHS_USB_HOST_STATE_RUNNING: + Poll_Others(); + for (x = 0; (usb_task_state == UHS_USB_HOST_STATE_RUNNING) && (x < UHS_HOST_MAX_INTERFACE_DRIVERS); x++) { + if (devConfig[x]) { + if (devConfig[x]->bPollEnable) devConfig[x]->Poll(); + } } -#endif -#ifdef USB_HOST_SHIELD_TIMING_PIN - // My counter/timer can't work on an inverted gate signal - // so we gate using a high pulse -- AJK - UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); -#endif - //usb_task_polling_disabled--; - EnablePoll(); - DDSB(); + // fall thru + #endif + default: + // Do nothing + break; + } // switch ( usb_task_state ) + DDSB(); + #if USB_HOST_SHIELD_USE_ISR + if (condet) { + VBUS_changed(); + noInterrupts(); + condet = false; + interrupts(); + } + #endif + #ifdef USB_HOST_SHIELD_TIMING_PIN + // My counter/timer can't work on an inverted gate signal + // so we gate using a high pulse -- AJK + UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); + #endif + //usb_task_polling_disabled--; + EnablePoll(); + DDSB(); } /* USB main task. Services the MAX3421e */ #if !USB_HOST_SHIELD_USE_ISR - -void UHS_NI MAX3421E_HOST::ISRTask() { -} -void UHS_NI MAX3421E_HOST::Task() + void UHS_NI MAX3421E_HOST::ISRTask() {} + void UHS_NI MAX3421E_HOST::Task() #else - -void UHS_NI MAX3421E_HOST::Task() { -#ifdef USB_HOST_MANUAL_POLL - if(usb_task_state == UHS_USB_HOST_STATE_RUNNING) { - noInterrupts(); - for(uint8_t x = 0; x < UHS_HOST_MAX_INTERFACE_DRIVERS; x++) - if(devConfig[x] && devConfig[x]->bPollEnable) - devConfig[x]->Poll(); - interrupts(); - } -#endif -} - -void UHS_NI MAX3421E_HOST::ISRTask() -#endif -{ - DDSB(); - -#ifndef SWI_IRQ_NUM - suspend_host(); -#if USB_HOST_SHIELD_USE_ISR - // Enable interrupts + void UHS_NI MAX3421E_HOST::Task() { + #ifdef USB_HOST_MANUAL_POLL + if (usb_task_state == UHS_USB_HOST_STATE_RUNNING) { + noInterrupts(); + for (uint8_t x = 0; x < UHS_HOST_MAX_INTERFACE_DRIVERS; x++) + if (devConfig[x] && devConfig[x]->bPollEnable) + devConfig[x]->Poll(); interrupts(); -#endif -#endif + } + #endif + } - counted = false; - if(!MARLIN_UHS_READ_IRQ()) { - uint8_t HIRQALL = regRd(rHIRQ); //determine interrupt source - uint8_t HIRQ = HIRQALL & IRQ_CHECK_MASK; - uint8_t HIRQ_sendback = 0x00; - - if((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { - MAX_HOST_DEBUG - (PSTR("\r\nBEFORE CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), - (HIRQ & bmCONDETIRQ) ? "T" : "F", - (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", - doingreset ? "T" : "F", - usb_task_state - ); - } - // ALWAYS happens BEFORE or WITH CONDETIRQ - if(HIRQ & bmBUSEVENTIRQ) { - HIRQ_sendback |= bmBUSEVENTIRQ; - if(!doingreset) condet = true; - busprobe(); - busevent = false; - } - - if(HIRQ & bmCONDETIRQ) { - HIRQ_sendback |= bmCONDETIRQ; - if(!doingreset) condet = true; - busprobe(); - } - -#if 1 - if((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { - MAX_HOST_DEBUG - (PSTR("\r\nAFTER CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), - (HIRQ & bmCONDETIRQ) ? "T" : "F", - (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", - doingreset ? "T" : "F", - usb_task_state - ); - } + void UHS_NI MAX3421E_HOST::ISRTask() #endif - - if(HIRQ & bmFRAMEIRQ) { - HIRQ_sendback |= bmFRAMEIRQ; - if(sof_countdown) { - sof_countdown--; - counted = true; - } - sofevent = false; - } - - //MAX_HOST_DEBUG(PSTR("\r\n%s%s%s\r\n"), - // sof_countdown ? "T" : "F", - // counted ? "T" : "F", - // usb_task_polling_disabled? "T" : "F"); - DDSB(); - regWr(rHIRQ, HIRQ_sendback); -#ifndef SWI_IRQ_NUM - resume_host(); -#if USB_HOST_SHIELD_USE_ISR +{ + DDSB(); + + #ifndef SWI_IRQ_NUM + suspend_host(); + #if USB_HOST_SHIELD_USE_ISR + // Enable interrupts + interrupts(); + #endif + #endif + + counted = false; + if (!MARLIN_UHS_READ_IRQ()) { + uint8_t HIRQALL = regRd(rHIRQ); // determine interrupt source + uint8_t HIRQ = HIRQALL & IRQ_CHECK_MASK; + uint8_t HIRQ_sendback = 0x00; + + if ((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { + MAX_HOST_DEBUG + (PSTR("\r\nBEFORE CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), + (HIRQ & bmCONDETIRQ) ? "T" : "F", + (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", + doingreset ? "T" : "F", + usb_task_state + ); + } + // ALWAYS happens BEFORE or WITH CONDETIRQ + if (HIRQ & bmBUSEVENTIRQ) { + HIRQ_sendback |= bmBUSEVENTIRQ; + if (!doingreset) condet = true; + busprobe(); + busevent = false; + } + + if (HIRQ & bmCONDETIRQ) { + HIRQ_sendback |= bmCONDETIRQ; + if (!doingreset) condet = true; + busprobe(); + } + + #if 1 + if ((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { + MAX_HOST_DEBUG + (PSTR("\r\nAFTER CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), + (HIRQ & bmCONDETIRQ) ? "T" : "F", + (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", + doingreset ? "T" : "F", + usb_task_state + ); + } + #endif + + if (HIRQ & bmFRAMEIRQ) { + HIRQ_sendback |= bmFRAMEIRQ; + if (sof_countdown) { + sof_countdown--; + counted = true; + } + sofevent = false; + } + + //MAX_HOST_DEBUG(PSTR("\r\n%s%s%s\r\n"), + // sof_countdown ? "T" : "F", + // counted ? "T" : "F", + // usb_task_polling_disabled? "T" : "F"); + DDSB(); + regWr(rHIRQ, HIRQ_sendback); + #ifndef SWI_IRQ_NUM + resume_host(); + #if USB_HOST_SHIELD_USE_ISR // Disable interrupts noInterrupts(); -#endif -#endif - if(!sof_countdown && !counted && !usb_task_polling_disabled) { - DisablePoll(); - //usb_task_polling_disabled++; -#ifdef USB_HOST_SHIELD_TIMING_PIN - // My counter/timer can't work on an inverted gate signal - // so we gate using a high pulse -- AJK - UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, HIGH); -#endif - -#ifdef SWI_IRQ_NUM - // MAX_HOST_DEBUG(PSTR("--------------- Doing SWI ----------------")); - exec_SWI(this); -#else -#if USB_HOST_SHIELD_USE_ISR - // Enable interrupts - interrupts(); -#endif /* USB_HOST_SHIELD_USE_ISR */ - ISRbottom(); -#endif /* SWI_IRQ_NUM */ - } - } + #endif + #endif + if (!sof_countdown && !counted && !usb_task_polling_disabled) { + DisablePoll(); + //usb_task_polling_disabled++; + #ifdef USB_HOST_SHIELD_TIMING_PIN + // My counter/timer can't work on an inverted gate signal + // so we gate using a high pulse -- AJK + UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, HIGH); + #endif + + #ifdef SWI_IRQ_NUM + //MAX_HOST_DEBUG(PSTR("--------------- Doing SWI ----------------")); + exec_SWI(this); + #else + #if USB_HOST_SHIELD_USE_ISR + // Enable interrupts + interrupts(); + #endif + ISRbottom(); + #endif /* SWI_IRQ_NUM */ + } + } } #if 0 -DDSB(); + DDSB(); #endif + #else -#error "Never include USB_HOST_SHIELD_INLINE.h, include UHS_host.h instead" + #error "Never include USB_HOST_SHIELD_INLINE.h, include UHS_host.h instead" #endif diff --git a/README.md b/README.md index fb1e881dc58b..97244605dccb 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ CI Status GitHub Sponsors
- Follow MarlinFirmware on Twitter + Follow MarlinFirmware on Mastodon

Additional documentation can be found at the [Marlin Home Page](https://marlinfw.org/). @@ -23,18 +23,26 @@ Download earlier versions of Marlin on the [Releases page](https://github.com/Ma ## Example Configurations -Before building Marlin you'll need to configure it for your specific hardware. Your vendor should have already provided source code with configurations for the installed firmware, but if you ever decide to upgrade you'll need updated configuration files. Marlin users have contributed dozens of tested example configurations to get you started. Visit the [MarlinFirmware/Configurations](https://github.com/MarlinFirmware/Configurations) repository to find the right configuration for your hardware. +Before you can build Marlin for your machine you'll need a configuration for your specific hardware. Upon request, your vendor will be happy to provide you with the complete source code and configurations for your machine, but you'll need to get updated configuration files if you want to install a newer version of Marlin. Fortunately, Marlin users have contributed dozens of tested configurations to get you started. Visit the [MarlinFirmware/Configurations](https://github.com/MarlinFirmware/Configurations) repository to find the right configuration for your hardware. ## Building Marlin 2.1 -To build Marlin 2.1 you'll need [Arduino IDE 1.8.8 or newer](https://www.arduino.cc/en/main/software) or [PlatformIO](http://docs.platformio.org/en/latest/ide.html#platformio-ide). Detailed build and install instructions are posted at: +To build and upload Marlin you will use one of these tools: - - [Installing Marlin (Arduino)](http://marlinfw.org/docs/basics/install_arduino.html) - - [Installing Marlin (VSCode)](http://marlinfw.org/docs/basics/install_platformio_vscode.html). +- The free [Visual Studio Code](https://code.visualstudio.com/download) using the [Auto Build Marlin](https://marlinfw.org/docs/basics/auto_build_marlin.html) extension. +- The free [Arduino IDE](https://www.arduino.cc/en/main/software) : See [Building Marlin with Arduino](https://marlinfw.org/docs/basics/install_arduino.html) + +Marlin is optimized to build with the **PlatformIO IDE** extension for **Visual Studio Code**. You can still build Marlin with **Arduino IDE**, and we hope to improve the Arduino build experience, but at this time PlatformIO is the better choice. ## Hardware Abstraction Layer (HAL) -Marlin 2.0 introduced a layer of abstraction to allow all the existing high-level code to be built for 32-bit platforms while still retaining full 8-bit AVR compatibility. Retaining AVR compatibility and a single code-base is important to us, because we want to make sure that features and patches get as much testing and attention as possible, and that all platforms always benefit from the latest improvements. +Marlin includes an abstraction layer to provide a common API for all the platforms it targets. This allows Marlin code to address the details of motion and user interface tasks at the lowest and highest levels with no system overhead, tying all events directly to the hardware clock. + +Every new HAL opens up a world of hardware. At this time we need HALs for RP2040 and the Duet3D family of boards. A HAL that wraps an RTOS is an interesting concept we would can explore. Did you know that Marlin includes a Simulator that can run on Windows, macOS, and Linux? Join the Discord to help move these sub-projects forward! + +## 8-Bit AVR Boards + +A core tenet of this project is to keep supporting 8-bit AVR boards while also maintaining a single codebase that applies equally to all machines. We want casual hobbyists to benefit from the community's innovations as much as possible just as much as those with fancier machines. Plus, those old AVR-based machines are often the best for your testing and feedback! ### Supported Platforms @@ -60,9 +68,15 @@ Marlin 2.0 introduced a layer of abstraction to allow all the existing high-leve ## Submitting Patches -- Submit **Bug Fixes** as Pull Requests to the ([bugfix-2.1.x](https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.1.x)) branch. -- Follow the [Coding Standards](http://marlinfw.org/docs/development/coding_standards.html) to gain points with the maintainers. -- Please submit your questions and concerns to the [Issue Queue](https://github.com/MarlinFirmware/Marlin/issues). +Proposed patches should be submitted as a Pull Request against the ([bugfix-2.1.x](https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.1.x)) branch. + +- Follow the [Coding Standards](https://marlinfw.org/docs/development/coding_standards.html) to gain points with the maintainers. +- Please submit Feature Requests and Bug Reports to the [Issue Queue](https://github.com/MarlinFirmware/Marlin/issues/new/choose). Support resources are also listed there. +- Whenever you add new features, be sure to add tests to `buildroot/tests` and then run your tests locally, if possible. + - It's optional: Running all the tests on Windows might take a long time, and they will run anyway on GitHub. + - If you're running the tests on Linux (or on WSL with the code on a Linux volume) the speed is much faster. + - You can use `make tests-all-local` or `make tests-single-local TEST_TARGET=...`. + - If you prefer Docker you can use `make tests-all-local-docker` or `make tests-all-local-docker TEST_TARGET=...`. ## Marlin Support @@ -83,16 +97,49 @@ Marlin is constantly improving thanks to a huge number of contributors from all Regular users can open and close their own issues, but only the administrators can do project-related things like add labels, merge changes, set milestones, and kick trolls. The current Marlin admin team consists of: - - Scott Lahteine [[@thinkyhead](https://github.com/thinkyhead)] - USA - Project Maintainer   [💸 Donate](https://www.thinkyhead.com/donate-to-marlin) - - Roxanne Neufeld [[@Roxy-3D](https://github.com/Roxy-3D)] - USA - - Keith Bennett [[@thisiskeithb](https://github.com/thisiskeithb)] - USA   [💸 Donate](https://github.com/sponsors/thisiskeithb) - - Peter Ellens [[@ellensp](https://github.com/ellensp)] - New Zealand   [💸 Donate](https://ko-fi.com/ellensp) - - Victor Oliveira [[@rhapsodyv](https://github.com/rhapsodyv)] - Brazil - - Chris Pepper [[@p3p](https://github.com/p3p)] - UK - - Jason Smith [[@sjasonsmith](https://github.com/sjasonsmith)] - USA - - Luu Lac [[@shitcreek](https://github.com/shitcreek)] - USA - - Bob Kuhn [[@Bob-the-Kuhn](https://github.com/Bob-the-Kuhn)] - USA - - Erik van der Zalm [[@ErikZalm](https://github.com/ErikZalm)] - Netherlands   [💸 Donate](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) + + + +
Project Maintainer
+ + 🇺🇸  **Scott Lahteine** +       [@thinkyhead](https://github.com/thinkyhead) +       [  Donate 💸  ](https://www.thinkyhead.com/donate-to-marlin) + + + + 🇺🇸  **Roxanne Neufeld** +       [@Roxy-3D](https://github.com/Roxy-3D) + + 🇺🇸  **Keith Bennett** +       [@thisiskeithb](https://github.com/thisiskeithb) +       [  Donate 💸  ](https://github.com/sponsors/thisiskeithb) + + 🇺🇸  **Jason Smith** +       [@sjasonsmith](https://github.com/sjasonsmith) + + + + 🇧🇷  **Victor Oliveira** +       [@rhapsodyv](https://github.com/rhapsodyv) + + 🇬🇧  **Chris Pepper** +       [@p3p](https://github.com/p3p) + +🇳🇿  **Peter Ellens** +       [@ellensp](https://github.com/ellensp) +       [  Donate 💸  ](https://ko-fi.com/ellensp) + + + + 🇺🇸  **Bob Kuhn** +       [@Bob-the-Kuhn](https://github.com/Bob-the-Kuhn) + + 🇳🇱  **Erik van der Zalm** +       [@ErikZalm](https://github.com/ErikZalm) +       [  Donate 💸  ](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) + +
## License diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index 8a4f3afd4f3e..e4132f02a75c 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -202,7 +202,7 @@ if ((AUTO_BUILD)); then echo "Building environment $TARGET for board $MB ($BNUM)..." ; echo pio run $SILENT_FLAG -e $TARGET fi - exit 0 + exit $? fi # diff --git a/buildroot/share/PlatformIO/boards/marlin_BTT_EBB42_V1_1.json b/buildroot/share/PlatformIO/boards/marlin_BTT_EBB42_V1_1.json new file mode 100644 index 000000000000..51b6b9984e39 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_BTT_EBB42_V1_1.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m0plus", + "extra_flags": "-DSTM32G0xx -DSTM32G0B1xx", + "f_cpu": "64000000L", + "framework_extra_flags": { + "arduino": "-D__CORTEX_SC=0" + }, + "mcu": "stm32g0b1cbt6", + "product_line": "STM32G0B1xx", + "variant": "MARLIN_BTT_EBB42_V1_1" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32G0B1CB", + "onboard_tools": [ + "stlink" + ], + "openocd_target": "stm32g0x", + "svd_path": "STM32G0B1.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "libopencm3", + "stm32cube", + "zephyr" + ], + "name": "STM32G0B1CB", + "upload": { + "maximum_ram_size": 147456, + "maximum_size": 131072, + "protocol": "stlink", + "protocols": [ + "stlink", + "jlink", + "cmsis-dap", + "blackmagic", + "mbed" + ] + }, + "url": "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32g0-series/stm32g0x1.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_MKS_SKIPR_V1.json b/buildroot/share/PlatformIO/boards/marlin_MKS_SKIPR_V1.json new file mode 100644 index 000000000000..7ca62db00531 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_MKS_SKIPR_V1.json @@ -0,0 +1,55 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F4 -DSTM32F407xx", + "f_cpu": "168000000L", + "offset": "0xC000", + "hwids": [ + [ + "0x1EAF", + "0x0003" + ], + [ + "0x0483", + "0x3748" + ] + ], + "mcu": "stm32f407vet6", + "product_line": "STM32F407xx", + "variant": "MARLIN_MKS_SKIPR_V1" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32F407VE", + "openocd_extra_args": [ + "-c", + "reset_config none" + ], + "openocd_target": "stm32f4x", + "svd_path": "STM32F40x.svd" + }, + "frameworks": [ + "arduino" + ], + "name": "STM32F407VE (128k RAM, 64k CCM RAM, 512k Flash", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink" + ], + "offset_address": "0x0800C000", + "require_upload_port": false, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f407ve.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32F401RC.json b/buildroot/share/PlatformIO/boards/marlin_STM32F401RC.json new file mode 100644 index 000000000000..f4242ccc00ca --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F401RC.json @@ -0,0 +1,38 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F401xC -DSTM32F4xx", + "f_cpu": "84000000L", + "mcu": "stm32f401rct6", + "product_line": "STM32F401xC", + "variant": "MARLIN_F401RC" + }, + "debug": { + "jlink_device": "STM32F401RC", + "openocd_target": "stm32f4x", + "svd_path": "STM32F401x.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "spl", + "stm32cube", + "libopencm3" + ], + "name": "STM32F401RC (64k RAM. 256k Flash)", + "upload": { + "maximum_ram_size": 65536, + "maximum_size": 262144, + "protocol": "serial", + "protocols": [ + "blackmagic", + "dfu", + "jlink", + "serial", + "stlink" + ] + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f401rc.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32F407ZE.json b/buildroot/share/PlatformIO/boards/marlin_STM32F407ZE.json new file mode 100644 index 000000000000..ce09de53c41c --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F407ZE.json @@ -0,0 +1,50 @@ +{ + "build": { + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F4 -DSTM32F407xx", + "f_cpu": "168000000L", + "mcu": "stm32f407zgt6", + "product_line": "STM32F407xx", + "variant": "MARLIN_F407ZE" + }, + "connectivity": [ + "can" + ], + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32F407ZE", + "onboard_tools": [ + "stlink" + ], + "openocd_board": "stm32f407", + "openocd_target": "stm32f4x", + "svd_path": "STM32F407x.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "mbed", + "stm32cube", + "libopencm3", + "zephyr" + ], + "name": "STM32F407ZE (128k RAM, 64k CCM RAM, 512k Flash", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f407-417.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32F446ZET_tronxy.json b/buildroot/share/PlatformIO/boards/marlin_STM32F446ZET_tronxy.json new file mode 100644 index 000000000000..bd129a703ad4 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F446ZET_tronxy.json @@ -0,0 +1,35 @@ +{ + "build": { + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F446xx", + "f_cpu": "180000000L", + "mcu": "stm32f446zet6", + "variant": "MARLIN_F446Zx_TRONXY" + }, + "connectivity": [ + "can" + ], + "debug": { + "jlink_device": "STM32F446ZE", + "openocd_target": "stm32f4x", + "svd_path": "STM32F446x.svd" + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "STM32F446ZE (128k RAM. 512k Flash)", + "upload": { + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "jlink", + "stlink", + "blackmagic", + "serial" + ] + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json b/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json index 3b8fa73060b7..4ec34e5b3502 100644 --- a/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json +++ b/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json @@ -3,7 +3,7 @@ "core": "stm32", "cpu": "cortex-m7", "extra_flags": "-DSTM32H7xx -DSTM32H743xx", - "f_cpu": "400000000L", + "f_cpu": "480000000L", "mcu": "stm32h743vit6", "product_line": "STM32H743xx", "variant": "MARLIN_H743Vx" diff --git a/buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev4.json b/buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev4.json new file mode 100644 index 000000000000..ef5ebfa56066 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev4.json @@ -0,0 +1,51 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F407xx", + "f_cpu": "168000000L", + "hwids": [ + [ + "0x0483", + "0xdf11" + ], + [ + "0x1EAF", + "0x0003" + ], + [ + "0x0483", + "0x3748" + ] + ], + "mcu": "stm32f407vet6", + "variant": "MARLIN_F407VE" + }, + "debug": { + "jlink_device": "STM32F407VE", + "openocd_target": "stm32f4x", + "svd_path": "STM32F40x.svd" + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "STM32F407VE (192k RAM. 512k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "dfu", + "protocols": [ + "stlink", + "dfu", + "jlink", + "blackmagic" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f407ve.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/scripts/SAMD21_minitronics20.py b/buildroot/share/PlatformIO/scripts/SAMD21_minitronics20.py new file mode 100644 index 000000000000..81099f58ccef --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/SAMD21_minitronics20.py @@ -0,0 +1,19 @@ +# +# SAMD21_minitronics20.py +# Customizations for env:SAMD21_minitronics20 +# +import pioutil +if pioutil.is_pio_build(): + from os.path import join, isfile + import shutil + + Import("env") + + 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" + + serialBuf = str(max(int(rxBuf), int(txBuf), 350)) + + build_flags = env.get('BUILD_FLAGS') + env.Replace(BUILD_FLAGS=build_flags) diff --git a/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py b/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py index e7442f2485b8..4cd553a3da6c 100644 --- a/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py +++ b/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py @@ -4,17 +4,17 @@ # import pioutil if pioutil.is_pio_build(): - from os.path import join, isfile - import shutil + from os.path import join, isfile + import shutil - Import("env") + Import("env") - 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" + 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" - serialBuf = str(max(int(rxBuf), int(txBuf), 350)) + serialBuf = str(max(int(rxBuf), int(txBuf), 350)) - build_flags = env.get('BUILD_FLAGS') - build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf) - env.Replace(BUILD_FLAGS=build_flags) + build_flags = env.get('BUILD_FLAGS') + build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf) + env.Replace(BUILD_FLAGS=build_flags) diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py index 551f4c63160b..4f2da9cdc0d0 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py @@ -4,17 +4,16 @@ import pioutil if pioutil.is_pio_build(): - import os - Import("env", "projenv") + Import("env", "projenv") - flash_size = 0 - vect_tab_addr = 0 + flash_size = 0 + vect_tab_addr = 0 - for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - vect_tab_addr = define[1] - if define[0] == "STM32_FLASH_SIZE": - flash_size = define[1] + for define in env['CPPDEFINES']: + if define[0] == "VECT_TAB_ADDR": + vect_tab_addr = define[1] + if define[0] == "STM32_FLASH_SIZE": + flash_size = define[1] - print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr)) - print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size)) + print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr)) + print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size)) diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py index c9794702c34a..ecb0cc145c04 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -3,26 +3,25 @@ # import pioutil if pioutil.is_pio_build(): - import os - from os.path import join - from os.path import expandvars - Import("env") + from os.path import join + from os.path import expandvars + Import("env") - # Custom HEX from ELF - env.AddPostAction( - join("$BUILD_DIR", "${PROGNAME}.elf"), - env.VerboseAction(" ".join([ - "$OBJCOPY", "-O ihex", "$TARGET", - "\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path - ]), "Building $TARGET")) + # Custom HEX from ELF + env.AddPostAction( + join("$BUILD_DIR", "${PROGNAME}.elf"), + env.VerboseAction(" ".join([ + "$OBJCOPY", "-O ihex", "$TARGET", + "\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path + ]), "Building $TARGET")) - # In-line command with arguments - UPLOAD_TOOL="stm32flash" - platform = env.PioPlatform() - if platform.get_package_dir("tool-stm32duino") != None: - UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"") + # In-line command with arguments + UPLOAD_TOOL="stm32flash" + platform = env.PioPlatform() + if platform.get_package_dir("tool-stm32duino") != None: + UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"") - env.Replace( - UPLOADER=UPLOAD_TOOL, - UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT") - ) + env.Replace( + UPLOADER=UPLOAD_TOOL, + UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT") + ) diff --git a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py index 0eab7a8361a6..4189cb5899bc 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py @@ -3,29 +3,29 @@ # import pioutil if pioutil.is_pio_build(): - import shutil,marlin - from pathlib import Path + import shutil,marlin + from pathlib import Path - Import("env") - platform = env.PioPlatform() - board = env.BoardConfig() + Import("env") + platform = env.PioPlatform() + board = env.BoardConfig() - FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple")) - assert FRAMEWORK_DIR.is_dir() + FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple")) + assert FRAMEWORK_DIR.is_dir() - source_root = Path("buildroot/share/PlatformIO/variants") - assert source_root.is_dir() + source_root = Path("buildroot/share/PlatformIO/variants") + assert source_root.is_dir() - variant = board.get("build.variant") - variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant + variant = board.get("build.variant") + variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant - source_dir = source_root / variant - assert source_dir.is_dir() + source_dir = source_root / variant + assert source_dir.is_dir() - if variant_dir.is_dir(): - shutil.rmtree(variant_dir) + if variant_dir.is_dir(): + shutil.rmtree(variant_dir) - if not variant_dir.is_dir(): - variant_dir.mkdir() + if not variant_dir.is_dir(): + variant_dir.mkdir() - marlin.copytree(source_dir, variant_dir) + marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/chitu_crypt.py b/buildroot/share/PlatformIO/scripts/chitu_crypt.py index 76792030cf7d..4e81061a19ad 100644 --- a/buildroot/share/PlatformIO/scripts/chitu_crypt.py +++ b/buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -4,123 +4,123 @@ # import pioutil if pioutil.is_pio_build(): - import struct,uuid,marlin + import struct,uuid,marlin - board = marlin.env.BoardConfig() + board = marlin.env.BoardConfig() - def calculate_crc(contents, seed): - accumulating_xor_value = seed; + def calculate_crc(contents, seed): + accumulating_xor_value = seed; - for i in range(0, len(contents), 4): - value = struct.unpack('> ip + # shift the xor_seed left by the bits in IP. + xor_seed = xor_seed >> ip - # load a byte into IP - ip = r0[loop_counter] + # load a byte into IP + ip = r0[loop_counter] - # XOR the seed with r7 - xor_seed = xor_seed ^ r7 + # XOR the seed with r7 + xor_seed = xor_seed ^ r7 - # and then with IP - xor_seed = xor_seed ^ ip + # and then with IP + xor_seed = xor_seed ^ ip - #Now store the byte back - r1[loop_counter] = xor_seed & 0xFF + #Now store the byte back + r1[loop_counter] = xor_seed & 0xFF - #increment the loop_counter - loop_counter = loop_counter + 1 + #increment the loop_counter + loop_counter = loop_counter + 1 - def encrypt_file(input, output_file, file_length): - input_file = bytearray(input.read()) - block_size = 0x800 - key_length = 0x18 + def encrypt_file(input, output_file, file_length): + input_file = bytearray(input.read()) + block_size = 0x800 + key_length = 0x18 - uid_value = uuid.uuid4() - file_key = int(uid_value.hex[0:8], 16) + uid_value = uuid.uuid4() + file_key = int(uid_value.hex[0:8], 16) - xor_crc = 0xEF3D4323; + xor_crc = 0xEF3D4323; - # the input file is exepcted to be in chunks of 0x800 - # so round the size - while len(input_file) % block_size != 0: - input_file.extend(b'0x0') + # the input file is exepcted to be in chunks of 0x800 + # so round the size + while len(input_file) % block_size != 0: + input_file.extend(b'0x0') - # write the file header - output_file.write(struct.pack(">I", 0x443D2D3F)) - # encrypt the contents using a known file header key + # write the file header + output_file.write(struct.pack(">I", 0x443D2D3F)) + # encrypt the contents using a known file header key - # write the file_key - output_file.write(struct.pack("= level: - print("[deps] %s" % str) - - def add_to_feat_cnf(feature, flines): - - try: - feat = FEATURE_CONFIG[feature] - except: - FEATURE_CONFIG[feature] = {} - - # Get a reference to the FEATURE_CONFIG under construction - feat = FEATURE_CONFIG[feature] - - # Split up passed lines on commas or newlines and iterate - # Add common options to the features config under construction - # For lib_deps replace a previous instance of the same library - atoms = re.sub(r',\s*', '\n', flines).strip().split('\n') - for line in atoms: - parts = line.split('=') - name = parts.pop(0) - if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']: - feat[name] = '='.join(parts) - blab("[%s] %s=%s" % (feature, name, feat[name]), 3) - else: - for dep in re.split(r',\s*', line): - lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0) - lib_re = re.compile('(?!^' + lib_name + '\\b)') - feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] - blab("[%s] lib_deps = %s" % (feature, dep), 3) - - def load_features(): - blab("========== Gather [features] entries...") - for key in ProjectConfig().items('features'): - feature = key[0].upper() - if not feature in FEATURE_CONFIG: - FEATURE_CONFIG[feature] = { 'lib_deps': [] } - add_to_feat_cnf(feature, key[1]) - - # Add options matching custom_marlin.MY_OPTION to the pile - blab("========== Gather custom_marlin entries...") - for n in env.GetProjectOptions(): - key = n[0] - mat = re.match(r'custom_marlin\.(.+)', key) - if mat: - try: - val = env.GetProjectOption(key) - except: - val = None - if val: - opt = mat[1].upper() - blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val )) - add_to_feat_cnf(opt, val) - - def get_all_known_libs(): - known_libs = [] - for feature in FEATURE_CONFIG: - feat = FEATURE_CONFIG[feature] - if not 'lib_deps' in feat: - continue - for dep in feat['lib_deps']: - known_libs.append(PackageSpec(dep).name) - return known_libs - - def get_all_env_libs(): - env_libs = [] - lib_deps = env.GetProjectOption('lib_deps') - for dep in lib_deps: - env_libs.append(PackageSpec(dep).name) - return env_libs - - def set_env_field(field, value): - proj = env.GetProjectConfig() - proj.set("env:" + env['PIOENV'], field, value) - - # All unused libs should be ignored so that if a library - # exists in .pio/lib_deps it will not break compilation. - def force_ignore_unused_libs(): - env_libs = get_all_env_libs() - known_libs = get_all_known_libs() - diff = (list(set(known_libs) - set(env_libs))) - lib_ignore = env.GetProjectOption('lib_ignore') + diff - blab("Ignore libraries: %s" % lib_ignore) - set_env_field('lib_ignore', lib_ignore) - - def apply_features_config(): - load_features() - blab("========== Apply enabled features...") - for feature in FEATURE_CONFIG: - if not env.MarlinHas(feature): - continue - - feat = FEATURE_CONFIG[feature] - - if 'lib_deps' in feat and len(feat['lib_deps']): - blab("========== Adding lib_deps for %s... " % feature, 2) - - # feat to add - deps_to_add = {} - for dep in feat['lib_deps']: - deps_to_add[PackageSpec(dep).name] = dep - blab("==================== %s... " % dep, 2) - - # Does the env already have the dependency? - deps = env.GetProjectOption('lib_deps') - for dep in deps: - name = PackageSpec(dep).name - if name in deps_to_add: - del deps_to_add[name] - - # Are there any libraries that should be ignored? - lib_ignore = env.GetProjectOption('lib_ignore') - for dep in deps: - name = PackageSpec(dep).name - if name in deps_to_add: - del deps_to_add[name] - - # Is there anything left? - if len(deps_to_add) > 0: - # Only add the missing dependencies - set_env_field('lib_deps', deps + list(deps_to_add.values())) - - if 'build_flags' in feat: - f = feat['build_flags'] - blab("========== Adding build_flags for %s: %s" % (feature, f), 2) - new_flags = env.GetProjectOption('build_flags') + [ f ] - env.Replace(BUILD_FLAGS=new_flags) - - if 'extra_scripts' in feat: - blab("Running extra_scripts for %s... " % feature, 2) - env.SConscript(feat['extra_scripts'], exports="env") - - if 'src_filter' in feat: - blab("========== Adding build_src_filter for %s... " % feature, 2) - src_filter = ' '.join(env.GetProjectOption('src_filter')) - # first we need to remove the references to the same folder - my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter']) - cur_srcs = re.findall(r'[+-](<.*?>)', src_filter) - for d in my_srcs: - if d in cur_srcs: - src_filter = re.sub(r'[+-]' + d, '', src_filter) - - src_filter = feat['src_filter'] + ' ' + src_filter - set_env_field('build_src_filter', [src_filter]) - env.Replace(SRC_FILTER=src_filter) - - if 'lib_ignore' in feat: - blab("========== Adding lib_ignore for %s... " % feature, 2) - lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']] - set_env_field('lib_ignore', lib_ignore) - - # - # Use the compiler to get a list of all enabled features - # - def load_marlin_features(): - if 'MARLIN_FEATURES' in env: - return - - # Process defines - from preprocessor import run_preprocessor - define_list = run_preprocessor(env) - marlin_features = {} - for define in define_list: - feature = define[8:].strip().decode().split(' ') - feature, definition = feature[0], ' '.join(feature[1:]) - marlin_features[feature] = definition - env['MARLIN_FEATURES'] = marlin_features - - # - # Return True if a matching feature is enabled - # - def MarlinHas(env, feature): - load_marlin_features() - r = re.compile('^' + feature + '$') - found = list(filter(r.match, env['MARLIN_FEATURES'])) - - # Defines could still be 'false' or '0', so check - some_on = False - if len(found): - for f in found: - val = env['MARLIN_FEATURES'][f] - if val in [ '', '1', 'true' ]: - some_on = True - elif val in env['MARLIN_FEATURES']: - some_on = env.MarlinHas(val) - - return some_on - - validate_pio() - - try: - verbose = int(env.GetProjectOption('custom_verbose')) - except: - pass - - # - # Add a method for other PIO scripts to query enabled features - # - env.AddMethod(MarlinHas) - - # - # Add dependencies for enabled Marlin features - # - apply_features_config() - force_ignore_unused_libs() - - #print(env.Dump()) - - from signature import compute_build_signature - compute_build_signature(env) + import subprocess,os,re + Import("env") + + from platformio.package.meta import PackageSpec + from platformio.project.config import ProjectConfig + + verbose = 0 + FEATURE_CONFIG = {} + + def validate_pio(): + PIO_VERSION_MIN = (6, 0, 1) + try: + from platformio import VERSION as PIO_VERSION + weights = (1000, 100, 1) + version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)]) + version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)]) + if version_cur < version_min: + print() + print("**************************************************") + print("****** An update to PlatformIO is ******") + print("****** required to build Marlin Firmware. ******") + print("****** ******") + print("****** Minimum version: ", PIO_VERSION_MIN, " ******") + print("****** Current Version: ", PIO_VERSION, " ******") + print("****** ******") + print("****** Update PlatformIO and try again. ******") + print("**************************************************") + print() + exit(1) + except SystemExit: + exit(1) + except: + print("Can't detect PlatformIO Version") + + def blab(str,level=1): + if verbose >= level: + print("[deps] %s" % str) + + def add_to_feat_cnf(feature, flines): + + try: + feat = FEATURE_CONFIG[feature] + except: + FEATURE_CONFIG[feature] = {} + + # Get a reference to the FEATURE_CONFIG under construction + feat = FEATURE_CONFIG[feature] + + # Split up passed lines on commas or newlines and iterate + # Add common options to the features config under construction + # For lib_deps replace a previous instance of the same library + atoms = re.sub(r',\s*', '\n', flines).strip().split('\n') + for line in atoms: + parts = line.split('=') + name = parts.pop(0) + if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']: + feat[name] = '='.join(parts) + blab("[%s] %s=%s" % (feature, name, feat[name]), 3) + else: + for dep in re.split(r',\s*', line): + lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0) + lib_re = re.compile('(?!^' + lib_name + '\\b)') + feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] + blab("[%s] lib_deps = %s" % (feature, dep), 3) + + def load_features(): + blab("========== Gather [features] entries...") + for key in ProjectConfig().items('features'): + feature = key[0].upper() + if not feature in FEATURE_CONFIG: + FEATURE_CONFIG[feature] = { 'lib_deps': [] } + add_to_feat_cnf(feature, key[1]) + + # Add options matching custom_marlin.MY_OPTION to the pile + blab("========== Gather custom_marlin entries...") + for n in env.GetProjectOptions(): + key = n[0] + mat = re.match(r'custom_marlin\.(.+)', key) + if mat: + try: + val = env.GetProjectOption(key) + except: + val = None + if val: + opt = mat[1].upper() + blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val )) + add_to_feat_cnf(opt, val) + + def get_all_known_libs(): + known_libs = [] + for feature in FEATURE_CONFIG: + feat = FEATURE_CONFIG[feature] + if not 'lib_deps' in feat: + continue + for dep in feat['lib_deps']: + known_libs.append(PackageSpec(dep).name) + return known_libs + + def get_all_env_libs(): + env_libs = [] + lib_deps = env.GetProjectOption('lib_deps') + for dep in lib_deps: + env_libs.append(PackageSpec(dep).name) + return env_libs + + def set_env_field(field, value): + proj = env.GetProjectConfig() + proj.set("env:" + env['PIOENV'], field, value) + + # All unused libs should be ignored so that if a library + # exists in .pio/lib_deps it will not break compilation. + def force_ignore_unused_libs(): + env_libs = get_all_env_libs() + known_libs = get_all_known_libs() + diff = (list(set(known_libs) - set(env_libs))) + lib_ignore = env.GetProjectOption('lib_ignore') + diff + blab("Ignore libraries: %s" % lib_ignore) + set_env_field('lib_ignore', lib_ignore) + + def apply_features_config(): + load_features() + blab("========== Apply enabled features...") + for feature in FEATURE_CONFIG: + if not env.MarlinHas(feature): + continue + + feat = FEATURE_CONFIG[feature] + + if 'lib_deps' in feat and len(feat['lib_deps']): + blab("========== Adding lib_deps for %s... " % feature, 2) + + # feat to add + deps_to_add = {} + for dep in feat['lib_deps']: + deps_to_add[PackageSpec(dep).name] = dep + blab("==================== %s... " % dep, 2) + + # Does the env already have the dependency? + deps = env.GetProjectOption('lib_deps') + for dep in deps: + name = PackageSpec(dep).name + if name in deps_to_add: + del deps_to_add[name] + + # Are there any libraries that should be ignored? + lib_ignore = env.GetProjectOption('lib_ignore') + for dep in deps: + name = PackageSpec(dep).name + if name in deps_to_add: + del deps_to_add[name] + + # Is there anything left? + if len(deps_to_add) > 0: + # Only add the missing dependencies + set_env_field('lib_deps', deps + list(deps_to_add.values())) + + if 'build_flags' in feat: + f = feat['build_flags'] + blab("========== Adding build_flags for %s: %s" % (feature, f), 2) + new_flags = env.GetProjectOption('build_flags') + [ f ] + env.Replace(BUILD_FLAGS=new_flags) + + if 'extra_scripts' in feat: + blab("Running extra_scripts for %s... " % feature, 2) + env.SConscript(feat['extra_scripts'], exports="env") + + if 'src_filter' in feat: + blab("========== Adding build_src_filter for %s... " % feature, 2) + src_filter = ' '.join(env.GetProjectOption('src_filter')) + # first we need to remove the references to the same folder + my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter']) + cur_srcs = re.findall(r'[+-](<.*?>)', src_filter) + for d in my_srcs: + if d in cur_srcs: + src_filter = re.sub(r'[+-]' + d, '', src_filter) + + src_filter = feat['src_filter'] + ' ' + src_filter + set_env_field('build_src_filter', [src_filter]) + env.Replace(SRC_FILTER=src_filter) + + if 'lib_ignore' in feat: + blab("========== Adding lib_ignore for %s... " % feature, 2) + lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']] + set_env_field('lib_ignore', lib_ignore) + + # + # Use the compiler to get a list of all enabled features + # + def load_marlin_features(): + if 'MARLIN_FEATURES' in env: + return + + # Process defines + from preprocessor import run_preprocessor + define_list = run_preprocessor(env) + marlin_features = {} + for define in define_list: + feature = define[8:].strip().decode().split(' ') + feature, definition = feature[0], ' '.join(feature[1:]) + marlin_features[feature] = definition + env['MARLIN_FEATURES'] = marlin_features + + # + # Return True if a matching feature is enabled + # + def MarlinHas(env, feature): + load_marlin_features() + r = re.compile('^' + feature + '$') + found = list(filter(r.match, env['MARLIN_FEATURES'])) + + # Defines could still be 'false' or '0', so check + some_on = False + if len(found): + for f in found: + val = env['MARLIN_FEATURES'][f] + if val in [ '', '1', 'true' ]: + some_on = True + elif val in env['MARLIN_FEATURES']: + some_on = env.MarlinHas(val) + + return some_on + + validate_pio() + + try: + verbose = int(env.GetProjectOption('custom_verbose')) + except: + pass + + # + # Add a method for other PIO scripts to query enabled features + # + env.AddMethod(MarlinHas) + + # + # Add dependencies for enabled Marlin features + # + apply_features_config() + force_ignore_unused_libs() + + #print(env.Dump()) + + from signature import compute_build_signature + compute_build_signature(env) diff --git a/buildroot/share/PlatformIO/scripts/configuration.py b/buildroot/share/PlatformIO/scripts/configuration.py index 3ab0295749a9..d752ebc2c828 100644 --- a/buildroot/share/PlatformIO/scripts/configuration.py +++ b/buildroot/share/PlatformIO/scripts/configuration.py @@ -7,233 +7,234 @@ verbose = 0 def blab(str,level=1): - if verbose >= level: print(f"[config] {str}") + if verbose >= level: print(f"[config] {str}") def config_path(cpath): - return Path("Marlin", cpath) + return Path("Marlin", cpath, encoding='utf-8') # Apply a single name = on/off ; name = value ; etc. # TODO: Limit to the given (optional) configuration def apply_opt(name, val, conf=None): - if name == "lcd": name, val = val, "on" - - # Create a regex to match the option and capture parts of the line - regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE) - - # Find and enable and/or update all matches - for file in ("Configuration.h", "Configuration_adv.h"): - fullpath = config_path(file) - lines = fullpath.read_text().split('\n') - found = False - for i in range(len(lines)): - line = lines[i] - match = regex.match(line) - if match and match[4].upper() == name.upper(): - found = True - # For boolean options un/comment the define - if val in ("on", "", None): - newline = re.sub(r'^(\s*)//+\s*(#define)(\s{1,3})?(\s*)', r'\1\2 \4', line) - elif val == "off": - newline = re.sub(r'^(\s*)(#define)(\s{1,3})?(\s*)', r'\1//\2 \4', line) - else: - # For options with values, enable and set the value - newline = match[1] + match[3] + match[4] + match[5] + val - if match[8]: - sp = match[7] if match[7] else ' ' - newline += sp + match[8] - lines[i] = newline - blab(f"Set {name} to {val}") - - # If the option was found, write the modified lines - if found: - fullpath.write_text('\n'.join(lines)) - break - - # If the option didn't appear in either config file, add it - if not found: - # OFF options are added as disabled items so they appear - # in config dumps. Useful for custom settings. - prefix = "" - if val == "off": - prefix, val = "//", "" # Item doesn't appear in config dump - #val = "false" # Item appears in config dump - - # Uppercase the option unless already mixed/uppercase - added = name.upper() if name.islower() else name - - # Add the provided value after the name - if val != "on" and val != "" and val is not None: - added += " " + val - - # Prepend the new option after the first set of #define lines - fullpath = config_path("Configuration.h") - with fullpath.open() as f: - lines = f.readlines() - linenum = 0 - gotdef = False - for line in lines: - isdef = line.startswith("#define") - if not gotdef: - gotdef = isdef - elif not isdef: - break - linenum += 1 - lines.insert(linenum, f"{prefix}#define {added} // Added by config.ini\n") - fullpath.write_text('\n'.join(lines)) + if name == "lcd": name, val = val, "on" + + # Create a regex to match the option and capture parts of the line + regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE) + + # Find and enable and/or update all matches + for file in ("Configuration.h", "Configuration_adv.h"): + fullpath = config_path(file) + lines = fullpath.read_text(encoding='utf-8').split('\n') + found = False + for i in range(len(lines)): + line = lines[i] + match = regex.match(line) + if match and match[4].upper() == name.upper(): + found = True + # For boolean options un/comment the define + if val in ("on", "", None): + newline = re.sub(r'^(\s*)//+\s*(#define)(\s{1,3})?(\s*)', r'\1\2 \4', line) + elif val == "off": + newline = re.sub(r'^(\s*)(#define)(\s{1,3})?(\s*)', r'\1//\2 \4', line) + else: + # For options with values, enable and set the value + newline = match[1] + match[3] + match[4] + match[5] + val + if match[8]: + sp = match[7] if match[7] else ' ' + newline += sp + match[8] + lines[i] = newline + blab(f"Set {name} to {val}") + + # If the option was found, write the modified lines + if found: + fullpath.write_text('\n'.join(lines), encoding='utf-8') + break + + # If the option didn't appear in either config file, add it + if not found: + # OFF options are added as disabled items so they appear + # in config dumps. Useful for custom settings. + prefix = "" + if val == "off": + prefix, val = "//", "" # Item doesn't appear in config dump + #val = "false" # Item appears in config dump + + # Uppercase the option unless already mixed/uppercase + added = name.upper() if name.islower() else name + + # Add the provided value after the name + if val != "on" and val != "" and val is not None: + added += " " + val + + # Prepend the new option after the first set of #define lines + fullpath = config_path("Configuration.h") + with fullpath.open(encoding='utf-8') as f: + lines = f.readlines() + linenum = 0 + gotdef = False + for line in lines: + isdef = line.startswith("#define") + if not gotdef: + gotdef = isdef + elif not isdef: + break + linenum += 1 + lines.insert(linenum, f"{prefix}#define {added:30} // Added by config.ini\n") + fullpath.write_text(''.join(lines), encoding='utf-8') # Fetch configuration files from GitHub given the path. # Return True if any files were fetched. -def fetch_example(path): - if path.endswith("/"): - path = path[:-1] - - if '@' in path: - path, brch = map(strip, path.split('@')) - - url = path.replace("%", "%25").replace(" ", "%20") - if not path.startswith('http'): - url = "https://raw.githubusercontent.com/MarlinFirmware/Configurations/bugfix-2.1.x/config/%s" % url - - # Find a suitable fetch command - if shutil.which("curl") is not None: - fetch = "curl -L -s -S -f -o" - elif shutil.which("wget") is not None: - fetch = "wget -q -O" - else: - blab("Couldn't find curl or wget", -1) - return False - - import os - - # Reset configurations to default - os.system("git reset --hard HEAD") - - gotfile = False - - # Try to fetch the remote files - for fn in ("Configuration.h", "Configuration_adv.h", "_Bootscreen.h", "_Statusscreen.h"): - if os.system("%s wgot %s/%s >/dev/null 2>&1" % (fetch, url, fn)) == 0: - shutil.move('wgot', config_path(fn)) - gotfile = True - - if Path('wgot').exists(): - shutil.rmtree('wgot') - - return gotfile +def fetch_example(url): + if url.endswith("/"): url = url[:-1] + if url.startswith('http'): + url = url.replace("%", "%25").replace(" ", "%20") + else: + brch = "bugfix-2.1.x" + if '@' in path: path, brch = map(str.strip, path.split('@')) + url = f"https://raw.githubusercontent.com/MarlinFirmware/Configurations/{brch}/config/{url}" + + # Find a suitable fetch command + if shutil.which("curl") is not None: + fetch = "curl -L -s -S -f -o" + elif shutil.which("wget") is not None: + fetch = "wget -q -O" + else: + blab("Couldn't find curl or wget", -1) + return False + + import os + + # Reset configurations to default + os.system("git reset --hard HEAD") + + # Try to fetch the remote files + gotfile = False + for fn in ("Configuration.h", "Configuration_adv.h", "_Bootscreen.h", "_Statusscreen.h"): + if os.system(f"{fetch} wgot {url}/{fn} >/dev/null 2>&1") == 0: + shutil.move('wgot', config_path(fn)) + gotfile = True + + if Path('wgot').exists(): shutil.rmtree('wgot') + + return gotfile def section_items(cp, sectkey): - return cp.items(sectkey) if sectkey in cp.sections() else [] + return cp.items(sectkey) if sectkey in cp.sections() else [] # Apply all items from a config section def apply_ini_by_name(cp, sect): - iniok = True - if sect in ('config:base', 'config:root'): - iniok = False - items = section_items(cp, 'config:base') + section_items(cp, 'config:root') - else: - items = cp.items(sect) + iniok = True + if sect in ('config:base', 'config:root'): + iniok = False + items = section_items(cp, 'config:base') + section_items(cp, 'config:root') + else: + items = section_items(cp, sect) - for item in items: - if iniok or not item[0].startswith('ini_'): - apply_opt(item[0], item[1]) + for item in items: + if iniok or not item[0].startswith('ini_'): + apply_opt(item[0], item[1]) # Apply all config sections from a parsed file def apply_all_sections(cp): - for sect in cp.sections(): - if sect.startswith('config:'): - apply_ini_by_name(cp, sect) + for sect in cp.sections(): + if sect.startswith('config:'): + apply_ini_by_name(cp, sect) # Apply certain config sections from a parsed file -def apply_sections(cp, ckey='all', addbase=False): - blab("[config] apply section key: %s" % ckey) - if ckey == 'all': - apply_all_sections(cp) - else: - # Apply the base/root config.ini settings after external files are done - if addbase or ckey in ('base', 'root'): - apply_ini_by_name(cp, 'config:base') - - # Apply historically 'Configuration.h' settings everywhere - if ckey == 'basic': - apply_ini_by_name(cp, 'config:basic') - - # Apply historically Configuration_adv.h settings everywhere - # (Some of which rely on defines in 'Conditionals_LCD.h') - elif ckey in ('adv', 'advanced'): - apply_ini_by_name(cp, 'config:advanced') - - # Apply a specific config: section directly - elif ckey.startswith('config:'): - apply_ini_by_name(cp, ckey) +def apply_sections(cp, ckey='all'): + blab(f"Apply section key: {ckey}") + if ckey == 'all': + apply_all_sections(cp) + else: + # Apply the base/root config.ini settings after external files are done + if ckey in ('base', 'root'): + apply_ini_by_name(cp, 'config:base') + + # Apply historically 'Configuration.h' settings everywhere + if ckey == 'basic': + apply_ini_by_name(cp, 'config:basic') + + # Apply historically Configuration_adv.h settings everywhere + # (Some of which rely on defines in 'Conditionals_LCD.h') + elif ckey in ('adv', 'advanced'): + apply_ini_by_name(cp, 'config:advanced') + + # Apply a specific config: section directly + elif ckey.startswith('config:'): + apply_ini_by_name(cp, ckey) # Apply settings from a top level config.ini def apply_config_ini(cp): - blab("=" * 20 + " Gather 'config.ini' entries...") - - # Pre-scan for ini_use_config to get config_keys - base_items = section_items(cp, 'config:base') + section_items(cp, 'config:root') - config_keys = ['base'] - for ikey, ival in base_items: - if ikey == 'ini_use_config': - config_keys = [ x.strip() for x in ival.split(',') ] - - # For each ini_use_config item perform an action - for ckey in config_keys: - addbase = False - - # For a key ending in .ini load and parse another .ini file - if ckey.endswith('.ini'): - sect = 'base' - if '@' in ckey: sect, ckey = ckey.split('@') - other_ini = configparser.ConfigParser() - other_ini.read(config_path(ckey)) - apply_sections(other_ini, sect) - - # (Allow 'example/' as a shortcut for 'examples/') - elif ckey.startswith('example/'): - ckey = 'examples' + ckey[7:] - - # For 'examples/' fetch an example set from GitHub. - # For https?:// do a direct fetch of the URL. - elif ckey.startswith('examples/') or ckey.startswith('http'): - addbase = True - fetch_example(ckey) - - # Apply keyed sections after external files are done - apply_sections(cp, 'config:' + ckey, addbase) + blab("=" * 20 + " Gather 'config.ini' entries...") + + # Pre-scan for ini_use_config to get config_keys + base_items = section_items(cp, 'config:base') + section_items(cp, 'config:root') + config_keys = ['base'] + for ikey, ival in base_items: + if ikey == 'ini_use_config': + config_keys = map(str.strip, ival.split(',')) + + # For each ini_use_config item perform an action + for ckey in config_keys: + addbase = False + + # For a key ending in .ini load and parse another .ini file + if ckey.endswith('.ini'): + sect = 'base' + if '@' in ckey: sect, ckey = map(str.strip, ckey.split('@')) + cp2 = configparser.ConfigParser() + cp2.read(config_path(ckey)) + apply_sections(cp2, sect) + ckey = 'base'; + + # (Allow 'example/' as a shortcut for 'examples/') + elif ckey.startswith('example/'): + ckey = 'examples' + ckey[7:] + + # For 'examples/' fetch an example set from GitHub. + # For https?:// do a direct fetch of the URL. + if ckey.startswith('examples/') or ckey.startswith('http:'): + fetch_example(ckey) + ckey = 'base' + + if ckey == 'all': + apply_sections(cp) + + else: + # Apply keyed sections after external files are done + apply_sections(cp, 'config:' + ckey) if __name__ == "__main__": - # - # From command line use the given file name - # - import sys - args = sys.argv[1:] - if len(args) > 0: - if args[0].endswith('.ini'): - ini_file = args[0] - else: - print("Usage: %s <.ini file>" % sys.argv[0]) - else: - ini_file = config_path('config.ini') - - if ini_file: - user_ini = configparser.ConfigParser() - user_ini.read(ini_file) - apply_config_ini(user_ini) + # + # From command line use the given file name + # + import sys + args = sys.argv[1:] + if len(args) > 0: + if args[0].endswith('.ini'): + ini_file = args[0] + else: + print("Usage: %s <.ini file>" % sys.argv[0]) + else: + ini_file = config_path('config.ini') + + if ini_file: + user_ini = configparser.ConfigParser() + user_ini.read(ini_file) + apply_config_ini(user_ini) else: - # - # From within PlatformIO use the loaded INI file - # - import pioutil - if pioutil.is_pio_build(): + # + # From within PlatformIO use the loaded INI file + # + import pioutil + if pioutil.is_pio_build(): - Import("env") + Import("env") - try: - verbose = int(env.GetProjectOption('custom_verbose')) - except: - pass + try: + verbose = int(env.GetProjectOption('custom_verbose')) + except: + pass - from platformio.project.config import ProjectConfig - apply_config_ini(ProjectConfig()) + from platformio.project.config import ProjectConfig + apply_config_ini(ProjectConfig()) diff --git a/buildroot/share/PlatformIO/scripts/custom_board.py b/buildroot/share/PlatformIO/scripts/custom_board.py index da3bdca0bbe7..7a8fe91be066 100644 --- a/buildroot/share/PlatformIO/scripts/custom_board.py +++ b/buildroot/share/PlatformIO/scripts/custom_board.py @@ -6,13 +6,13 @@ # import pioutil if pioutil.is_pio_build(): - import marlin - board = marlin.env.BoardConfig() + import marlin + board = marlin.env.BoardConfig() - address = board.get("build.address", "") - if address: - marlin.relocate_firmware(address) + address = board.get("build.address", "") + if address: + marlin.relocate_firmware(address) - ldscript = board.get("build.ldscript", "") - if ldscript: - marlin.custom_ld_script(ldscript) + ldscript = board.get("build.ldscript", "") + if ldscript: + marlin.custom_ld_script(ldscript) diff --git a/buildroot/share/PlatformIO/scripts/download_mks_assets.py b/buildroot/share/PlatformIO/scripts/download_mks_assets.py index 8d186b755f51..661fb2e438e4 100644 --- a/buildroot/share/PlatformIO/scripts/download_mks_assets.py +++ b/buildroot/share/PlatformIO/scripts/download_mks_assets.py @@ -4,50 +4,50 @@ # import pioutil if pioutil.is_pio_build(): - Import("env") - import requests,zipfile,tempfile,shutil - from pathlib import Path + Import("env") + import requests,zipfile,tempfile,shutil + from pathlib import Path - url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip" - deps_path = Path(env.Dictionary("PROJECT_LIBDEPS_DIR")) - zip_path = deps_path / "mks-assets.zip" - assets_path = Path(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets") + url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip" + deps_path = Path(env.Dictionary("PROJECT_LIBDEPS_DIR")) + zip_path = deps_path / "mks-assets.zip" + assets_path = Path(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets") - def download_mks_assets(): - print("Downloading MKS Assets") - r = requests.get(url, stream=True) - # the user may have a very clean workspace, - # so create the PROJECT_LIBDEPS_DIR directory if not exits - if not deps_path.exists(): - deps_path.mkdir() - with zip_path.open('wb') as fd: - for chunk in r.iter_content(chunk_size=128): - fd.write(chunk) + def download_mks_assets(): + print("Downloading MKS Assets") + r = requests.get(url, stream=True) + # the user may have a very clean workspace, + # so create the PROJECT_LIBDEPS_DIR directory if not exits + if not deps_path.exists(): + deps_path.mkdir() + with zip_path.open('wb') as fd: + for chunk in r.iter_content(chunk_size=128): + fd.write(chunk) - def copy_mks_assets(): - print("Copying MKS Assets") - output_path = Path(tempfile.mkdtemp()) - zip_obj = zipfile.ZipFile(zip_path, 'r') - zip_obj.extractall(output_path) - zip_obj.close() - if assets_path.exists() and not assets_path.is_dir(): - assets_path.unlink() - if not assets_path.exists(): - assets_path.mkdir() - base_path = '' - for filename in output_path.iterdir(): - base_path = filename - fw_path = (output_path / base_path / 'Firmware') - font_path = fw_path / 'mks_font' - for filename in font_path.iterdir(): - shutil.copy(font_path / filename, assets_path) - pic_path = fw_path / 'mks_pic' - for filename in pic_path.iterdir(): - shutil.copy(pic_path / filename, assets_path) - shutil.rmtree(output_path, ignore_errors=True) + def copy_mks_assets(): + print("Copying MKS Assets") + output_path = Path(tempfile.mkdtemp()) + zip_obj = zipfile.ZipFile(zip_path, 'r') + zip_obj.extractall(output_path) + zip_obj.close() + if assets_path.exists() and not assets_path.is_dir(): + assets_path.unlink() + if not assets_path.exists(): + assets_path.mkdir() + base_path = '' + for filename in output_path.iterdir(): + base_path = filename + fw_path = (output_path / base_path / 'Firmware') + font_path = fw_path / 'mks_font' + for filename in font_path.iterdir(): + shutil.copy(font_path / filename, assets_path) + pic_path = fw_path / 'mks_pic' + for filename in pic_path.iterdir(): + shutil.copy(pic_path / filename, assets_path) + shutil.rmtree(output_path, ignore_errors=True) - if not zip_path.exists(): - download_mks_assets() + if not zip_path.exists(): + download_mks_assets() - if not assets_path.exists(): - copy_mks_assets() + if not assets_path.exists(): + copy_mks_assets() diff --git a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py index 83ed17ccca1c..879a7da3d49b 100644 --- a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py +++ b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py @@ -4,32 +4,32 @@ import pioutil if pioutil.is_pio_build(): - import shutil - from os.path import join, isfile - from pprint import pprint + import shutil + from os.path import join, isfile + from pprint import pprint - Import("env") + Import("env") - if env.MarlinHas("POSTMORTEM_DEBUGGING"): - FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple") - patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done") + if env.MarlinHas("POSTMORTEM_DEBUGGING"): + FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple") + patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done") - # patch file only if we didn't do it before - if not isfile(patchflag_path): - print("Patching libmaple exception handlers") - original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S") - backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak") - src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S") + # patch file only if we didn't do it before + if not isfile(patchflag_path): + print("Patching libmaple exception handlers") + original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S") + backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak") + src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S") - assert isfile(original_file) and isfile(src_file) - shutil.copyfile(original_file, backup_file) - shutil.copyfile(src_file, original_file); + assert isfile(original_file) and isfile(src_file) + shutil.copyfile(original_file, backup_file) + shutil.copyfile(src_file, original_file); - def _touch(path): - with open(path, "w") as fp: - fp.write("") + def _touch(path): + with open(path, "w") as fp: + fp.write("") - env.Execute(lambda *args, **kwargs: _touch(patchflag_path)) - print("Done patching exception handler") + env.Execute(lambda *args, **kwargs: _touch(patchflag_path)) + print("Done patching exception handler") - print("Libmaple modified and ready for post mortem debugging") + print("Libmaple modified and ready for post mortem debugging") diff --git a/buildroot/share/PlatformIO/scripts/generic_create_variant.py b/buildroot/share/PlatformIO/scripts/generic_create_variant.py index 5e3637604fb2..49d4c98d3e15 100644 --- a/buildroot/share/PlatformIO/scripts/generic_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/generic_create_variant.py @@ -7,52 +7,52 @@ # import pioutil if pioutil.is_pio_build(): - import shutil,marlin - from pathlib import Path - - # - # Get the platform name from the 'platform_packages' option, - # or look it up by the platform.class.name. - # - env = marlin.env - platform = env.PioPlatform() - - from platformio.package.meta import PackageSpec - platform_packages = env.GetProjectOption('platform_packages') - - # Remove all tool items from platform_packages - platform_packages = [x for x in platform_packages if not x.startswith("platformio/tool-")] - - if len(platform_packages) == 0: - framewords = { - "Ststm32Platform": "framework-arduinoststm32", - "AtmelavrPlatform": "framework-arduino-avr" - } - platform_name = framewords[platform.__class__.__name__] - else: - platform_name = PackageSpec(platform_packages[0]).name - - if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino", "biqu-bx-workaround", "main" ]: - platform_name = "framework-arduinoststm32" - - FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name)) - assert FRAMEWORK_DIR.is_dir() - - board = env.BoardConfig() - - #mcu_type = board.get("build.mcu")[:-2] - variant = board.get("build.variant") - #series = mcu_type[:7].upper() + "xx" - - # Prepare a new empty folder at the destination - variant_dir = FRAMEWORK_DIR / "variants" / variant - if variant_dir.is_dir(): - shutil.rmtree(variant_dir) - if not variant_dir.is_dir(): - variant_dir.mkdir() - - # Source dir is a local variant sub-folder - source_dir = Path("buildroot/share/PlatformIO/variants", variant) - assert source_dir.is_dir() - - marlin.copytree(source_dir, variant_dir) + import shutil,marlin + from pathlib import Path + + # + # Get the platform name from the 'platform_packages' option, + # or look it up by the platform.class.name. + # + env = marlin.env + platform = env.PioPlatform() + + from platformio.package.meta import PackageSpec + platform_packages = env.GetProjectOption('platform_packages') + + # Remove all tool items from platform_packages + platform_packages = [x for x in platform_packages if not x.startswith("platformio/tool-")] + + if len(platform_packages) == 0: + framewords = { + "Ststm32Platform": "framework-arduinoststm32", + "AtmelavrPlatform": "framework-arduino-avr" + } + platform_name = framewords[platform.__class__.__name__] + else: + platform_name = PackageSpec(platform_packages[0]).name + + if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino", "biqu-bx-workaround", "main" ]: + platform_name = "framework-arduinoststm32" + + FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name)) + assert FRAMEWORK_DIR.is_dir() + + board = env.BoardConfig() + + #mcu_type = board.get("build.mcu")[:-2] + variant = board.get("build.variant") + #series = mcu_type[:7].upper() + "xx" + + # Prepare a new empty folder at the destination + variant_dir = FRAMEWORK_DIR / "variants" / variant + if variant_dir.is_dir(): + shutil.rmtree(variant_dir) + if not variant_dir.is_dir(): + variant_dir.mkdir() + + # Source dir is a local variant sub-folder + source_dir = Path("buildroot/share/PlatformIO/variants", variant) + assert source_dir.is_dir() + + marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py index b9516931b514..9256751096c5 100644 --- a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py @@ -5,31 +5,31 @@ import pioutil if pioutil.is_pio_build(): - # Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' - def addboot(source, target, env): - from pathlib import Path + # Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' + def addboot(source, target, env): + from pathlib import Path - fw_path = Path(target[0].path) - fwb_path = fw_path.parent / 'firmware_with_bootloader.bin' - with fwb_path.open("wb") as fwb_file: - bl_path = Path("buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin") - bl_file = bl_path.open("rb") - while True: - b = bl_file.read(1) - if b == b'': break - else: fwb_file.write(b) + fw_path = Path(target[0].path) + fwb_path = fw_path.parent / 'firmware_with_bootloader.bin' + with fwb_path.open("wb") as fwb_file: + bl_path = Path("buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin") + bl_file = bl_path.open("rb") + while True: + b = bl_file.read(1) + if b == b'': break + else: fwb_file.write(b) - with fw_path.open("rb") as fw_file: - while True: - b = fw_file.read(1) - if b == b'': break - else: fwb_file.write(b) + with fw_path.open("rb") as fw_file: + while True: + b = fw_file.read(1) + if b == b'': break + else: fwb_file.write(b) - fws_path = Path(target[0].dir.path, 'firmware_for_sd_upload.bin') - if fws_path.exists(): - fws_path.unlink() + fws_path = Path(target[0].dir.path, 'firmware_for_sd_upload.bin') + if fws_path.exists(): + fws_path.unlink() - fw_path.rename(fws_path) + fw_path.rename(fws_path) - import marlin - marlin.add_post_action(addboot); + import marlin + marlin.add_post_action(addboot); diff --git a/buildroot/share/PlatformIO/scripts/lerdge.py b/buildroot/share/PlatformIO/scripts/lerdge.py index dc0c633139df..607fe312ac84 100644 --- a/buildroot/share/PlatformIO/scripts/lerdge.py +++ b/buildroot/share/PlatformIO/scripts/lerdge.py @@ -7,41 +7,41 @@ # import pioutil if pioutil.is_pio_build(): - import os,marlin + import os,marlin - board = marlin.env.BoardConfig() + board = marlin.env.BoardConfig() - def encryptByte(byte): - byte = 0xFF & ((byte << 6) | (byte >> 2)) - i = 0x58 + byte - j = 0x05 + byte + (i >> 8) - byte = (0xF8 & i) | (0x07 & j) - return byte + def encryptByte(byte): + byte = 0xFF & ((byte << 6) | (byte >> 2)) + i = 0x58 + byte + j = 0x05 + byte + (i >> 8) + byte = (0xF8 & i) | (0x07 & j) + return byte - def encrypt_file(input, output_file, file_length): - input_file = bytearray(input.read()) - for i in range(len(input_file)): - input_file[i] = encryptByte(input_file[i]) - output_file.write(input_file) + def encrypt_file(input, output_file, file_length): + input_file = bytearray(input.read()) + for i in range(len(input_file)): + input_file[i] = encryptByte(input_file[i]) + output_file.write(input_file) - # Encrypt ${PROGNAME}.bin and save it with the name given in build.crypt_lerdge - def encrypt(source, target, env): - fwpath = target[0].path - enname = board.get("build.crypt_lerdge") - print("Encrypting %s to %s" % (fwpath, enname)) - fwfile = open(fwpath, "rb") - enfile = open(target[0].dir.path + "/" + enname, "wb") - length = os.path.getsize(fwpath) + # Encrypt ${PROGNAME}.bin and save it with the name given in build.crypt_lerdge + def encrypt(source, target, env): + fwpath = target[0].path + enname = board.get("build.crypt_lerdge") + print("Encrypting %s to %s" % (fwpath, enname)) + fwfile = open(fwpath, "rb") + enfile = open(target[0].dir.path + "/" + enname, "wb") + length = os.path.getsize(fwpath) - encrypt_file(fwfile, enfile, length) + encrypt_file(fwfile, enfile, length) - fwfile.close() - enfile.close() - os.remove(fwpath) + fwfile.close() + enfile.close() + os.remove(fwpath) - if 'crypt_lerdge' in board.get("build").keys(): - if board.get("build.crypt_lerdge") != "": - marlin.add_post_action(encrypt) - else: - print("LERDGE builds require output file via board_build.crypt_lerdge = 'filename' parameter") - exit(1) + if 'crypt_lerdge' in board.get("build").keys(): + if board.get("build.crypt_lerdge") != "": + marlin.add_post_action(encrypt) + else: + print("LERDGE builds require output file via board_build.crypt_lerdge = 'filename' parameter") + exit(1) diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py index 068d0331a82e..169dd9d3c3a5 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -9,64 +9,64 @@ env = DefaultEnvironment() def copytree(src, dst, symlinks=False, ignore=None): - for item in src.iterdir(): - if item.is_dir(): - shutil.copytree(item, dst / item.name, symlinks, ignore) - else: - shutil.copy2(item, dst / item.name) + for item in src.iterdir(): + if item.is_dir(): + shutil.copytree(item, dst / item.name, symlinks, ignore) + else: + shutil.copy2(item, dst / item.name) def replace_define(field, value): - for define in env['CPPDEFINES']: - if define[0] == field: - env['CPPDEFINES'].remove(define) - env['CPPDEFINES'].append((field, value)) + for define in env['CPPDEFINES']: + if define[0] == field: + env['CPPDEFINES'].remove(define) + env['CPPDEFINES'].append((field, value)) # Relocate the firmware to a new address, such as "0x08005000" def relocate_firmware(address): - replace_define("VECT_TAB_ADDR", address) + replace_define("VECT_TAB_ADDR", address) # Relocate the vector table with a new offset def relocate_vtab(address): - replace_define("VECT_TAB_OFFSET", address) + replace_define("VECT_TAB_OFFSET", address) # Replace the existing -Wl,-T with the given ldscript path def custom_ld_script(ldname): - apath = str(Path("buildroot/share/PlatformIO/ldscripts", ldname).resolve()) - for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + apath - elif flag == "-T": - env["LINKFLAGS"][i + 1] = apath + apath = str(Path("buildroot/share/PlatformIO/ldscripts", ldname).resolve()) + for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,-T" in flag: + env["LINKFLAGS"][i] = "-Wl,-T" + apath + elif flag == "-T": + env["LINKFLAGS"][i + 1] = apath # Encrypt ${PROGNAME}.bin and save it with a new name. This applies (mostly) to MKS boards # This PostAction is set up by offset_and_rename.py for envs with 'build.encrypt_mks'. def encrypt_mks(source, target, env, new_name): - import sys + import sys - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] + key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - # If FIRMWARE_BIN is defined by config, override all - mf = env["MARLIN_FEATURES"] - if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] + # If FIRMWARE_BIN is defined by config, override all + mf = env["MARLIN_FEATURES"] + if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] - fwpath = Path(target[0].path) - fwfile = fwpath.open("rb") - enfile = Path(target[0].dir.path, new_name).open("wb") - length = fwpath.stat().st_size - position = 0 - try: - while position < length: - byte = fwfile.read(1) - if 320 <= position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - enfile.write(byte) - position += 1 - finally: - fwfile.close() - enfile.close() - fwpath.unlink() + fwpath = Path(target[0].path) + fwfile = fwpath.open("rb") + enfile = Path(target[0].dir.path, new_name).open("wb") + length = fwpath.stat().st_size + position = 0 + try: + while position < length: + byte = fwfile.read(1) + if 320 <= position < 31040: + byte = chr(ord(byte) ^ key[position & 31]) + if sys.version_info[0] > 2: + byte = bytes(byte, 'latin1') + enfile.write(byte) + position += 1 + finally: + fwfile.close() + enfile.close() + fwpath.unlink() def add_post_action(action): - env.AddPostAction(str(Path("$BUILD_DIR", "${PROGNAME}.bin")), action); + env.AddPostAction(str(Path("$BUILD_DIR", "${PROGNAME}.bin")), action); diff --git a/buildroot/share/PlatformIO/scripts/mc-apply.py b/buildroot/share/PlatformIO/scripts/mc-apply.py index f71d192679d3..b42ba12f7adf 100755 --- a/buildroot/share/PlatformIO/scripts/mc-apply.py +++ b/buildroot/share/PlatformIO/scripts/mc-apply.py @@ -5,65 +5,64 @@ import json import sys import shutil -import re opt_output = '--opt' in sys.argv output_suffix = '.sh' if opt_output else '' if '--bare-output' in sys.argv else '.gen' try: - with open('marlin_config.json', 'r') as infile: - conf = json.load(infile) - for key in conf: - # We don't care about the hash when restoring here - if key == '__INITIAL_HASH': - continue - if key == 'VERSION': - for k, v in sorted(conf[key].items()): - print(k + ': ' + v) - continue - # The key is the file name, so let's build it now - outfile = open('Marlin/' + key + output_suffix, 'w') - for k, v in sorted(conf[key].items()): - # Make define line now - if opt_output: - if v != '': - if '"' in v: - v = "'%s'" % v - elif ' ' in v: - v = '"%s"' % v - define = 'opt_set ' + k + ' ' + v + '\n' - else: - define = 'opt_enable ' + k + '\n' - else: - define = '#define ' + k + ' ' + v + '\n' - outfile.write(define) - outfile.close() + with open('marlin_config.json', 'r') as infile: + conf = json.load(infile) + for key in conf: + # We don't care about the hash when restoring here + if key == '__INITIAL_HASH': + continue + if key == 'VERSION': + for k, v in sorted(conf[key].items()): + print(k + ': ' + v) + continue + # The key is the file name, so let's build it now + outfile = open('Marlin/' + key + output_suffix, 'w') + for k, v in sorted(conf[key].items()): + # Make define line now + if opt_output: + if v != '': + if '"' in v: + v = "'%s'" % v + elif ' ' in v: + v = '"%s"' % v + define = 'opt_set ' + k + ' ' + v + '\n' + else: + define = 'opt_enable ' + k + '\n' + else: + define = '#define ' + k + ' ' + v + '\n' + outfile.write(define) + outfile.close() - # Try to apply changes to the actual configuration file (in order to keep useful comments) - if output_suffix != '': - # Move the existing configuration so it doesn't interfere - shutil.move('Marlin/' + key, 'Marlin/' + key + '.orig') - infile_lines = open('Marlin/' + key + '.orig', 'r').read().split('\n') - outfile = open('Marlin/' + key, 'w') - for line in infile_lines: - sline = line.strip(" \t\n\r") - if sline[:7] == "#define": - # Extract the key here (we don't care about the value) - kv = sline[8:].strip().split(' ') - if kv[0] in conf[key]: - outfile.write('#define ' + kv[0] + ' ' + conf[key][kv[0]] + '\n') - # Remove the key from the dict, so we can still write all missing keys at the end of the file - del conf[key][kv[0]] - else: - outfile.write(line + '\n') - else: - outfile.write(line + '\n') - # Process any remaining defines here - for k, v in sorted(conf[key].items()): - define = '#define ' + k + ' ' + v + '\n' - outfile.write(define) - outfile.close() + # Try to apply changes to the actual configuration file (in order to keep useful comments) + if output_suffix != '': + # Move the existing configuration so it doesn't interfere + shutil.move('Marlin/' + key, 'Marlin/' + key + '.orig') + infile_lines = open('Marlin/' + key + '.orig', 'r').read().split('\n') + outfile = open('Marlin/' + key, 'w') + for line in infile_lines: + sline = line.strip(" \t\n\r") + if sline[:7] == "#define": + # Extract the key here (we don't care about the value) + kv = sline[8:].strip().split(' ') + if kv[0] in conf[key]: + outfile.write('#define ' + kv[0] + ' ' + conf[key][kv[0]] + '\n') + # Remove the key from the dict, so we can still write all missing keys at the end of the file + del conf[key][kv[0]] + else: + outfile.write(line + '\n') + else: + outfile.write(line + '\n') + # Process any remaining defines here + for k, v in sorted(conf[key].items()): + define = '#define ' + k + ' ' + v + '\n' + outfile.write(define) + outfile.close() - print('Output configuration written to: ' + 'Marlin/' + key + output_suffix) + print('Output configuration written to: ' + 'Marlin/' + key + output_suffix) except: - print('No marlin_config.json found.') + print('No marlin_config.json found.') diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py index 10a34d9c7390..de14ccbbbf5f 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -2,59 +2,64 @@ # 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. +# - 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 pioutil if pioutil.is_pio_build(): - import sys,marlin - - env = marlin.env - board = env.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_mks rename and encode the firmware file. - # - if 'encrypt_mks' in board_keys: - - # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt_mks - def encrypt(source, target, env): - marlin.encrypt_mks(source, target, env, board.get("build.encrypt_mks")) - - if board.get("build.encrypt_mks") != "": - marlin.add_post_action(encrypt) - - # - # For build.rename simply rename the firmware file. - # - if 'rename' in board_keys: - - def rename_target(source, target, env): - from pathlib import Path - Path(target[0].path).replace(Path(target[0].dir.path, board.get("build.rename"))) - - marlin.add_post_action(rename_target) + import marlin + + env = marlin.env + board = env.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_mks rename and encode the firmware file. + # + if 'encrypt_mks' in board_keys: + + # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt_mks + def encrypt(source, target, env): + marlin.encrypt_mks(source, target, env, board.get("build.encrypt_mks")) + + if board.get("build.encrypt_mks") != "": + marlin.add_post_action(encrypt) + + # + # For build.rename simply rename the firmware file. + # + if 'rename' in board_keys: + + # If FIRMWARE_BIN is defined by config, override all + mf = env["MARLIN_FEATURES"] + if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] + else: new_name = board.get("build.rename") + + def rename_target(source, target, env): + from pathlib import Path + Path(target[0].path).replace(Path(target[0].dir.path, new_name)) + + marlin.add_post_action(rename_target) diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 33e82898f7b4..6db8727ce4eb 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -3,18 +3,17 @@ # import pioutil if pioutil.is_pio_build(): - import os,sys - from os.path import join + from os.path import join - Import("env") + Import("env") - board = env.BoardConfig() - board_keys = board.get("build").keys() - if 'encode' 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.encode")) + "\"" - ]), "Building " + board.get("build.encode")) - ) + board = env.BoardConfig() + board_keys = board.get("build").keys() + if 'encode' 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.encode")) + "\"" + ]), "Building " + board.get("build.encode")) + ) diff --git a/buildroot/share/PlatformIO/scripts/pioutil.py b/buildroot/share/PlatformIO/scripts/pioutil.py index 32096dab3f25..18e6dba92889 100644 --- a/buildroot/share/PlatformIO/scripts/pioutil.py +++ b/buildroot/share/PlatformIO/scripts/pioutil.py @@ -4,10 +4,11 @@ # Make sure 'vscode init' is not the current command def is_pio_build(): - from SCons.Script import DefaultEnvironment - env = DefaultEnvironment() - return not env.IsIntegrationDump() + from SCons.Script import DefaultEnvironment + env = DefaultEnvironment() + if "IsCleanTarget" in dir(env) and env.IsCleanTarget(): return False + return not env.IsIntegrationDump() def get_pio_version(): - from platformio import util - return util.pioversion_to_intstr() + from platformio import util + return util.pioversion_to_intstr() diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 0fa9f9d6cc99..08856350d2ad 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -5,123 +5,132 @@ import pioutil if pioutil.is_pio_build(): - import os,re,sys - from pathlib import Path - Import("env") - - def get_envs_for_board(board): - ppath = Path("Marlin/src/pins/pins.h") - with ppath.open() as file: - - if sys.platform == 'win32': - envregex = r"(?:env|win):" - elif sys.platform == 'darwin': - envregex = r"(?:env|mac|uni):" - elif sys.platform == 'linux': - envregex = r"(?:env|lin|uni):" - else: - envregex = r"(?:env):" - - r = re.compile(r"if\s+MB\((.+)\)") - if board.startswith("BOARD_"): - board = board[6:] - - for line in file: - mbs = r.findall(line) - if mbs and board in re.split(r",\s*", mbs[0]): - line = file.readline() - found_envs = re.match(r"\s*#include .+" + envregex, line) - if found_envs: - envlist = re.findall(envregex + r"(\w+)", line) - return [ "env:"+s for s in envlist ] - return [] - - def check_envs(build_env, board_envs, config): - if build_env in board_envs: - return True - ext = config.get(build_env, 'extends', default=None) - if ext: - if isinstance(ext, str): - return check_envs(ext, board_envs, config) - elif isinstance(ext, list): - for ext_env in ext: - if check_envs(ext_env, board_envs, config): - return True - return False - - def sanity_check_target(): - # Sanity checks: - if 'PIOENV' not in env: - raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") - - # Require PlatformIO 6.1.1 or later - vers = pioutil.get_pio_version() - if vers < [6, 1, 1]: - raise SystemExit("Error: Marlin requires PlatformIO >= 6.1.1. Use 'pio upgrade' to get a newer version.") - - if 'MARLIN_FEATURES' not in env: - raise SystemExit("Error: this script should be used after common Marlin scripts") - - if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: - raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") - - build_env = env['PIOENV'] - motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] - board_envs = get_envs_for_board(motherboard) - config = env.GetProjectConfig() - result = check_envs("env:"+build_env, board_envs, config) - - if not result: - err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ - ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) ) - raise SystemExit(err) - - # - # Check for Config files in two common incorrect places - # - epath = Path(env['PROJECT_DIR']) - for p in [ epath, epath / "config" ]: - for f in ("Configuration.h", "Configuration_adv.h"): - if (p / f).is_file(): - err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p - raise SystemExit(err) - - # - # Find the name.cpp.o or name.o and remove it - # - def rm_ofile(subdir, name): - build_dir = Path(env['PROJECT_BUILD_DIR'], build_env); - for outdir in (build_dir, build_dir / "debug"): - for ext in (".cpp.o", ".o"): - fpath = outdir / "src/src" / subdir / (name + ext) - if fpath.exists(): - fpath.unlink() - - # - # Give warnings on every build - # - rm_ofile("inc", "Warnings") - - # - # Rebuild 'settings.cpp' for EEPROM_INIT_NOW - # - if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']: - rm_ofile("module", "settings") - - # - # Check for old files indicating an entangled Marlin (mixing old and new code) - # - mixedin = [] - p = Path(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") - for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: - if (p / f).is_file(): - mixedin += [ f ] - p = Path(env['PROJECT_DIR'], "Marlin/src/feature/bedlevel/abl") - for f in [ "abl.cpp", "abl.h" ]: - if (p / f).is_file(): - mixedin += [ f ] - if mixedin: - err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) - raise SystemExit(err) - - sanity_check_target() + import re,sys + from pathlib import Path + Import("env") + + def get_envs_for_board(board): + ppath = Path("Marlin/src/pins/pins.h") + with ppath.open() as file: + + if sys.platform == 'win32': + envregex = r"(?:env|win):" + elif sys.platform == 'darwin': + envregex = r"(?:env|mac|uni):" + elif sys.platform == 'linux': + envregex = r"(?:env|lin|uni):" + else: + envregex = r"(?:env):" + + r = re.compile(r"if\s+MB\((.+)\)") + if board.startswith("BOARD_"): + board = board[6:] + + for line in file: + mbs = r.findall(line) + if mbs and board in re.split(r",\s*", mbs[0]): + line = file.readline() + found_envs = re.match(r"\s*#include .+" + envregex, line) + if found_envs: + envlist = re.findall(envregex + r"(\w+)", line) + return [ "env:"+s for s in envlist ] + return [] + + def check_envs(build_env, board_envs, config): + if build_env in board_envs: + return True + ext = config.get(build_env, 'extends', default=None) + if ext: + if isinstance(ext, str): + return check_envs(ext, board_envs, config) + elif isinstance(ext, list): + for ext_env in ext: + if check_envs(ext_env, board_envs, config): + return True + return False + + def sanity_check_target(): + # Sanity checks: + if 'PIOENV' not in env: + raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") + + # Require PlatformIO 6.1.1 or later + vers = pioutil.get_pio_version() + if vers < [6, 1, 1]: + raise SystemExit("Error: Marlin requires PlatformIO >= 6.1.1. Use 'pio upgrade' to get a newer version.") + + if 'MARLIN_FEATURES' not in env: + raise SystemExit("Error: this script should be used after common Marlin scripts.") + + if len(env['MARLIN_FEATURES']) == 0: + raise SystemExit("Error: Failed to parse Marlin features. See previous error messages.") + + build_env = env['PIOENV'] + motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] + board_envs = get_envs_for_board(motherboard) + config = env.GetProjectConfig() + result = check_envs("env:"+build_env, board_envs, config) + + if not result: + err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ + ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) ) + raise SystemExit(err) + + # + # Check for Config files in two common incorrect places + # + epath = Path(env['PROJECT_DIR']) + for p in [ epath, epath / "config" ]: + for f in ("Configuration.h", "Configuration_adv.h"): + if (p / f).is_file(): + err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p + raise SystemExit(err) + + # + # Find the name.cpp.o or name.o and remove it + # + def rm_ofile(subdir, name): + build_dir = Path(env['PROJECT_BUILD_DIR'], build_env); + for outdir in (build_dir, build_dir / "debug"): + for ext in (".cpp.o", ".o"): + fpath = outdir / "src/src" / subdir / (name + ext) + if fpath.exists(): + fpath.unlink() + + # + # Give warnings on every build + # + rm_ofile("inc", "Warnings") + + # + # Rebuild 'settings.cpp' for EEPROM_INIT_NOW + # + if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']: + rm_ofile("module", "settings") + + # + # Check for old files indicating an entangled Marlin (mixing old and new code) + # + mixedin = [] + p = Path(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") + for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: + if (p / f).is_file(): + mixedin += [ f ] + p = Path(env['PROJECT_DIR'], "Marlin/src/feature/bedlevel/abl") + for f in [ "abl.cpp", "abl.h" ]: + if (p / f).is_file(): + mixedin += [ f ] + if mixedin: + err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) + raise SystemExit(err) + + # + # Check FILAMENT_RUNOUT_SCRIPT has a %c parammeter when required + # + if 'FILAMENT_RUNOUT_SENSOR' in env['MARLIN_FEATURES'] and 'NUM_RUNOUT_SENSORS' in env['MARLIN_FEATURES']: + if env['MARLIN_FEATURES']['NUM_RUNOUT_SENSORS'].isdigit() and int(env['MARLIN_FEATURES']['NUM_RUNOUT_SENSORS']) > 1: + if 'FILAMENT_RUNOUT_SCRIPT' in env['MARLIN_FEATURES'] and "%c" not in env['MARLIN_FEATURES']['FILAMENT_RUNOUT_SCRIPT']: + err = "ERROR: FILAMENT_RUNOUT_SCRIPT needs a %c parameter when NUM_RUNOUT_SENSORS is > 1" + raise SystemExit(err) + + sanity_check_target() diff --git a/buildroot/share/PlatformIO/scripts/preprocessor.py b/buildroot/share/PlatformIO/scripts/preprocessor.py index 19e8dfe0e1ae..b0fec52bfa10 100644 --- a/buildroot/share/PlatformIO/scripts/preprocessor.py +++ b/buildroot/share/PlatformIO/scripts/preprocessor.py @@ -1,14 +1,14 @@ # # preprocessor.py # -import subprocess,re +import subprocess nocache = 1 verbose = 0 def blab(str): - if verbose: - print(str) + if verbose: + print(str) ################################################################################ # @@ -16,36 +16,36 @@ def blab(str): # preprocessor_cache = {} def run_preprocessor(env, fn=None): - filename = fn or 'buildroot/share/PlatformIO/scripts/common-dependencies.h' - if filename in preprocessor_cache: - return preprocessor_cache[filename] - - # Process defines - build_flags = env.get('BUILD_FLAGS') - build_flags = env.ParseFlagsExtended(build_flags) - - cxx = search_compiler(env) - cmd = ['"' + cxx + '"'] - - # Build flags from board.json - #if 'BOARD' in env: - # cmd += [env.BoardConfig().get("build.extra_flags")] - for s in build_flags['CPPDEFINES']: - if isinstance(s, tuple): - cmd += ['-D' + s[0] + '=' + str(s[1])] - else: - cmd += ['-D' + s] - - cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++'] - depcmd = cmd + [ filename ] - cmd = ' '.join(depcmd) - blab(cmd) - try: - define_list = subprocess.check_output(cmd, shell=True).splitlines() - except: - define_list = {} - preprocessor_cache[filename] = define_list - return define_list + filename = fn or 'buildroot/share/PlatformIO/scripts/common-dependencies.h' + if filename in preprocessor_cache: + return preprocessor_cache[filename] + + # Process defines + build_flags = env.get('BUILD_FLAGS') + build_flags = env.ParseFlagsExtended(build_flags) + + cxx = search_compiler(env) + cmd = ['"' + cxx + '"'] + + # Build flags from board.json + #if 'BOARD' in env: + # cmd += [env.BoardConfig().get("build.extra_flags")] + for s in build_flags['CPPDEFINES']: + if isinstance(s, tuple): + cmd += ['-D' + s[0] + '=' + str(s[1])] + else: + cmd += ['-D' + s] + + cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++'] + depcmd = cmd + [ filename ] + cmd = ' '.join(depcmd) + blab(cmd) + try: + define_list = subprocess.check_output(cmd, shell=True).splitlines() + except: + define_list = {} + preprocessor_cache[filename] = define_list + return define_list ################################################################################ @@ -54,41 +54,41 @@ def run_preprocessor(env, fn=None): # def search_compiler(env): - from pathlib import Path, PurePath - - ENV_BUILD_PATH = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) - GCC_PATH_CACHE = ENV_BUILD_PATH / ".gcc_path" - - try: - gccpath = env.GetProjectOption('custom_gcc') - blab("Getting compiler from env") - return gccpath - except: - pass - - # Warning: The cached .gcc_path will obscure a newly-installed toolkit - if not nocache and GCC_PATH_CACHE.exists(): - blab("Getting g++ path from cache") - return GCC_PATH_CACHE.read_text() - - # Use any item in $PATH corresponding to a platformio toolchain bin folder - path_separator = ':' - gcc_exe = '*g++' - if env['PLATFORM'] == 'win32': - path_separator = ';' - gcc_exe += ".exe" - - # Search for the compiler in PATH - for ppath in map(Path, env['ENV']['PATH'].split(path_separator)): - if ppath.match(env['PROJECT_PACKAGES_DIR'] + "/**/bin"): - for gpath in ppath.glob(gcc_exe): - gccpath = str(gpath.resolve()) - # Cache the g++ path to no search always - if not nocache and ENV_BUILD_PATH.exists(): - blab("Caching g++ for current env") - GCC_PATH_CACHE.write_text(gccpath) - return gccpath - - gccpath = env.get('CXX') - blab("Couldn't find a compiler! Fallback to %s" % gccpath) - return gccpath + from pathlib import Path, PurePath + + ENV_BUILD_PATH = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) + GCC_PATH_CACHE = ENV_BUILD_PATH / ".gcc_path" + + try: + gccpath = env.GetProjectOption('custom_gcc') + blab("Getting compiler from env") + return gccpath + except: + pass + + # Warning: The cached .gcc_path will obscure a newly-installed toolkit + if not nocache and GCC_PATH_CACHE.exists(): + blab("Getting g++ path from cache") + return GCC_PATH_CACHE.read_text() + + # Use any item in $PATH corresponding to a platformio toolchain bin folder + path_separator = ':' + gcc_exe = '*g++' + if env['PLATFORM'] == 'win32': + path_separator = ';' + gcc_exe += ".exe" + + # Search for the compiler in PATH + for ppath in map(Path, env['ENV']['PATH'].split(path_separator)): + if ppath.match(env['PROJECT_PACKAGES_DIR'] + "/**/bin"): + for gpath in ppath.glob(gcc_exe): + gccpath = str(gpath.resolve()) + # Cache the g++ path to no search always + if not nocache and ENV_BUILD_PATH.exists(): + blab("Caching g++ for current env") + GCC_PATH_CACHE.write_text(gccpath) + return gccpath + + gccpath = env.get('CXX') + blab("Couldn't find a compiler! Fallback to %s" % gccpath) + return gccpath diff --git a/buildroot/share/PlatformIO/scripts/random-bin.py b/buildroot/share/PlatformIO/scripts/random-bin.py index 5a88906c3092..dc8634ea7d64 100644 --- a/buildroot/share/PlatformIO/scripts/random-bin.py +++ b/buildroot/share/PlatformIO/scripts/random-bin.py @@ -4,6 +4,6 @@ # import pioutil if pioutil.is_pio_build(): - from datetime import datetime - Import("env") - env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S") + from datetime import datetime + Import("env") + env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S") diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py index 767748757e2d..103aa1f072dc 100755 --- a/buildroot/share/PlatformIO/scripts/schema.py +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -9,395 +9,413 @@ from pathlib import Path def extend_dict(d:dict, k:tuple): - if len(k) >= 1 and k[0] not in d: - d[k[0]] = {} - if len(k) >= 2 and k[1] not in d[k[0]]: - d[k[0]][k[1]] = {} - if len(k) >= 3 and k[2] not in d[k[0]][k[1]]: - d[k[0]][k[1]][k[2]] = {} + if len(k) >= 1 and k[0] not in d: + d[k[0]] = {} + if len(k) >= 2 and k[1] not in d[k[0]]: + d[k[0]][k[1]] = {} + if len(k) >= 3 and k[2] not in d[k[0]][k[1]]: + d[k[0]][k[1]][k[2]] = {} grouping_patterns = [ - re.compile(r'^([XYZIJKUVW]|[XYZ]2|Z[34]|E[0-7])$'), - re.compile(r'^AXIS\d$'), - re.compile(r'^(MIN|MAX)$'), - re.compile(r'^[0-8]$'), - re.compile(r'^HOTEND[0-7]$'), - re.compile(r'^(HOTENDS|BED|PROBE|COOLER)$'), - re.compile(r'^[XYZIJKUVW]M(IN|AX)$') + re.compile(r'^([XYZIJKUVW]|[XYZ]2|Z[34]|E[0-7])$'), + re.compile(r'^AXIS\d$'), + re.compile(r'^(MIN|MAX)$'), + re.compile(r'^[0-8]$'), + re.compile(r'^HOTEND[0-7]$'), + re.compile(r'^(HOTENDS|BED|PROBE|COOLER)$'), + re.compile(r'^[XYZIJKUVW]M(IN|AX)$') ] # If the indexed part of the option name matches a pattern # then add it to the dictionary. def find_grouping(gdict, filekey, sectkey, optkey, pindex): - optparts = optkey.split('_') - if 1 < len(optparts) > pindex: - for patt in grouping_patterns: - if patt.match(optparts[pindex]): - subkey = optparts[pindex] - modkey = '_'.join(optparts) - optparts[pindex] = '*' - wildkey = '_'.join(optparts) - kkey = f'{filekey}|{sectkey}|{wildkey}' - if kkey not in gdict: gdict[kkey] = [] - gdict[kkey].append((subkey, modkey)) + optparts = optkey.split('_') + if 1 < len(optparts) > pindex: + for patt in grouping_patterns: + if patt.match(optparts[pindex]): + subkey = optparts[pindex] + modkey = '_'.join(optparts) + optparts[pindex] = '*' + wildkey = '_'.join(optparts) + kkey = f'{filekey}|{sectkey}|{wildkey}' + if kkey not in gdict: gdict[kkey] = [] + gdict[kkey].append((subkey, modkey)) # Build a list of potential groups. Only those with multiple items will be grouped. def group_options(schema): - for pindex in range(10, -1, -1): - found_groups = {} - for filekey, f in schema.items(): - for sectkey, s in f.items(): - for optkey in s: - find_grouping(found_groups, filekey, sectkey, optkey, pindex) - - fkeys = [ k for k in found_groups.keys() ] - for kkey in fkeys: - items = found_groups[kkey] - if len(items) > 1: - f, s, w = kkey.split('|') - extend_dict(schema, (f, s, w)) # Add wildcard group to schema - for subkey, optkey in items: # Add all items to wildcard group - schema[f][s][w][subkey] = schema[f][s][optkey] # Move non-wildcard item to wildcard group - del schema[f][s][optkey] - del found_groups[kkey] + for pindex in range(10, -1, -1): + found_groups = {} + for filekey, f in schema.items(): + for sectkey, s in f.items(): + for optkey in s: + find_grouping(found_groups, filekey, sectkey, optkey, pindex) + + fkeys = [ k for k in found_groups.keys() ] + for kkey in fkeys: + items = found_groups[kkey] + if len(items) > 1: + f, s, w = kkey.split('|') + extend_dict(schema, (f, s, w)) # Add wildcard group to schema + for subkey, optkey in items: # Add all items to wildcard group + schema[f][s][w][subkey] = schema[f][s][optkey] # Move non-wildcard item to wildcard group + del schema[f][s][optkey] + del found_groups[kkey] # Extract all board names from boards.h def load_boards(): - bpath = Path("Marlin/src/core/boards.h") - if bpath.is_file(): - with bpath.open() as bfile: - boards = [] - for line in bfile: - if line.startswith("#define BOARD_"): - bname = line.split()[1] - if bname != "BOARD_UNKNOWN": boards.append(bname) - return "['" + "','".join(boards) + "']" - return '' + bpath = Path("Marlin/src/core/boards.h") + if bpath.is_file(): + with bpath.open() as bfile: + boards = [] + for line in bfile: + if line.startswith("#define BOARD_"): + bname = line.split()[1] + if bname != "BOARD_UNKNOWN": boards.append(bname) + return "['" + "','".join(boards) + "']" + return '' # # Extract a schema from the current configuration files # def extract(): - # Load board names from boards.h - boards = load_boards() - - # Parsing states - class Parse: - NORMAL = 0 # No condition yet - BLOCK_COMMENT = 1 # Looking for the end of the block comment - EOL_COMMENT = 2 # EOL comment started, maybe add the next comment? - GET_SENSORS = 3 # Gathering temperature sensor options - ERROR = 9 # Syntax error - - # List of files to process, with shorthand - filekey = { 'Configuration.h':'basic', 'Configuration_adv.h':'advanced' } - # A JSON object to store the data - sch_out = { 'basic':{}, 'advanced':{} } - # Regex for #define NAME [VALUE] [COMMENT] with sanitized line - defgrep = re.compile(r'^(//)?\s*(#define)\s+([A-Za-z0-9_]+)\s*(.*?)\s*(//.+)?$') - # Defines to ignore - ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') - # Start with unknown state - state = Parse.NORMAL - # Serial ID - sid = 0 - # Loop through files and parse them line by line - for fn, fk in filekey.items(): - with Path("Marlin", fn).open() as fileobj: - section = 'none' # Current Settings section - line_number = 0 # Counter for the line number of the file - conditions = [] # Create a condition stack for the current file - comment_buff = [] # A temporary buffer for comments - options_json = '' # A buffer for the most recent options JSON found - eol_options = False # The options came from end of line, so only apply once - join_line = False # A flag that the line should be joined with the previous one - line = '' # A line buffer to handle \ continuation - last_added_ref = None # Reference to the last added item - # Loop through the lines in the file - for the_line in fileobj.readlines(): - line_number += 1 - - # Clean the line for easier parsing - the_line = the_line.strip() - - if join_line: # A previous line is being made longer - line += (' ' if line else '') + the_line - else: # Otherwise, start the line anew - line, line_start = the_line, line_number - - # If the resulting line ends with a \, don't process now. - # Strip the end off. The next line will be joined with it. - join_line = line.endswith("\\") - if join_line: - line = line[:-1].strip() - continue - else: - line_end = line_number - - defmatch = defgrep.match(line) - - # Special handling for EOL comments after a #define. - # At this point the #define is already digested and inserted, - # so we have to extend it - if state == Parse.EOL_COMMENT: - # If the line is not a comment, we're done with the EOL comment - if not defmatch and the_line.startswith('//'): - comment_buff.append(the_line[2:].strip()) - else: - last_added_ref['comment'] = ' '.join(comment_buff) - comment_buff = [] - state = Parse.NORMAL - - def use_comment(c, opt, sec, bufref): - if c.startswith(':'): # If the comment starts with : then it has magic JSON - d = c[1:].strip() # Strip the leading : - cbr = c.rindex('}') if d.startswith('{') else c.rindex(']') if d.startswith('[') else 0 - if cbr: - opt, cmt = c[1:cbr+1].strip(), c[cbr+1:].strip() - if cmt != '': bufref.append(cmt) - else: - opt = c[1:].strip() - elif c.startswith('@section'): # Start a new section - sec = c[8:].strip() - elif not c.startswith('========'): - bufref.append(c) - return opt, sec - - # In a block comment, capture lines up to the end of the comment. - # Assume nothing follows the comment closure. - if state in (Parse.BLOCK_COMMENT, Parse.GET_SENSORS): - endpos = line.find('*/') - if endpos < 0: - cline = line - else: - cline, line = line[:endpos].strip(), line[endpos+2:].strip() - - # Temperature sensors are done - if state == Parse.GET_SENSORS: - options_json = f'[ {options_json[:-2]} ]' - - state = Parse.NORMAL - - # Strip the leading '*' from block comments - if cline.startswith('*'): cline = cline[1:].strip() - - # Collect temperature sensors - if state == Parse.GET_SENSORS: - sens = re.match(r'^(-?\d+)\s*:\s*(.+)$', cline) - if sens: - s2 = sens[2].replace("'","''") - options_json += f"{sens[1]}:'{s2}', " - - elif state == Parse.BLOCK_COMMENT: - - # Look for temperature sensors - if cline == "Temperature sensors available:": - state, cline = Parse.GET_SENSORS, "Temperature Sensors" - - options_json, section = use_comment(cline, options_json, section, comment_buff) - - # For the normal state we're looking for any non-blank line - elif state == Parse.NORMAL: - # Skip a commented define when evaluating comment opening - st = 2 if re.match(r'^//\s*#define', line) else 0 - cpos1 = line.find('/*') # Start a block comment on the line? - cpos2 = line.find('//', st) # Start an end of line comment on the line? - - # Only the first comment starter gets evaluated - cpos = -1 - if cpos1 != -1 and (cpos1 < cpos2 or cpos2 == -1): - cpos = cpos1 - comment_buff = [] - state = Parse.BLOCK_COMMENT - eol_options = False - - elif cpos2 != -1 and (cpos2 < cpos1 or cpos1 == -1): - cpos = cpos2 - - # Expire end-of-line options after first use - if cline.startswith(':'): eol_options = True - - # Comment after a define may be continued on the following lines - if state == Parse.NORMAL and defmatch != None and cpos > 10: - state = Parse.EOL_COMMENT - comment_buff = [] - - # Process the start of a new comment - if cpos != -1: - cline, line = line[cpos+2:].strip(), line[:cpos].strip() - - # Strip leading '*' from block comments - if state == Parse.BLOCK_COMMENT: - if cline.startswith('*'): cline = cline[1:].strip() - - # Buffer a non-empty comment start - if cline != '': - options_json, section = use_comment(cline, options_json, section, comment_buff) - - # If the line has nothing before the comment, go to the next line - if line == '': - options_json = '' - continue - - # Parenthesize the given expression if needed - def atomize(s): - if s == '' \ - or re.match(r'^[A-Za-z0-9_]*(\([^)]+\))?$', s) \ - or re.match(r'^[A-Za-z0-9_]+ == \d+?$', s): - return s - return f'({s})' - - # - # The conditions stack is an array containing condition-arrays. - # Each condition-array lists the conditions for the current block. - # IF/N/DEF adds a new condition-array to the stack. - # ELSE/ELIF/ENDIF pop the condition-array. - # ELSE/ELIF negate the last item in the popped condition-array. - # ELIF adds a new condition to the end of the array. - # ELSE/ELIF re-push the condition-array. - # - cparts = line.split() - iselif, iselse = cparts[0] == '#elif', cparts[0] == '#else' - if iselif or iselse or cparts[0] == '#endif': - if len(conditions) == 0: - raise Exception(f'no #if block at line {line_number}') - - # Pop the last condition-array from the stack - prev = conditions.pop() - - if iselif or iselse: - prev[-1] = '!' + prev[-1] # Invert the last condition - if iselif: prev.append(atomize(line[5:].strip())) - conditions.append(prev) - - elif cparts[0] == '#if': - conditions.append([ atomize(line[3:].strip()) ]) - elif cparts[0] == '#ifdef': - conditions.append([ f'defined({line[6:].strip()})' ]) - elif cparts[0] == '#ifndef': - conditions.append([ f'!defined({line[7:].strip()})' ]) - - # Handle a complete #define line - elif defmatch != None: - - # Get the match groups into vars - enabled, define_name, val = defmatch[1] == None, defmatch[3], defmatch[4] - - # Increment the serial ID - sid += 1 - - # Create a new dictionary for the current #define - define_info = { - 'section': section, - 'name': define_name, - 'enabled': enabled, - 'line': line_start, - 'sid': sid - } - - if val != '': define_info['value'] = val - - # Type is based on the value - if val == '': - value_type = 'switch' - elif re.match(r'^(true|false)$', val): - value_type = 'bool' - val = val == 'true' - elif re.match(r'^[-+]?\s*\d+$', val): - value_type = 'int' - val = int(val) - elif re.match(r'[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?', val): - value_type = 'float' - val = float(val.replace('f','')) - else: - value_type = 'string' if val[0] == '"' \ - else 'char' if val[0] == "'" \ - else 'state' if re.match(r'^(LOW|HIGH)$', val) \ - else 'enum' if re.match(r'^[A-Za-z0-9_]{3,}$', val) \ - else 'int[]' if re.match(r'^{(\s*[-+]?\s*\d+\s*(,\s*)?)+}$', val) \ - else 'float[]' if re.match(r'^{(\s*[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?\s*(,\s*)?)+}$', val) \ - else 'array' if val[0] == '{' \ - else '' - - if value_type != '': define_info['type'] = value_type - - # Join up accumulated conditions with && - if conditions: define_info['requires'] = ' && '.join(sum(conditions, [])) - - # If the comment_buff is not empty, add the comment to the info - if comment_buff: - full_comment = '\n'.join(comment_buff) - - # An EOL comment will be added later - # The handling could go here instead of above - if state == Parse.EOL_COMMENT: - define_info['comment'] = '' - else: - define_info['comment'] = full_comment - comment_buff = [] - - # If the comment specifies units, add that to the info - units = re.match(r'^\(([^)]+)\)', full_comment) - if units: - units = units[1] - if units == 's' or units == 'sec': units = 'seconds' - define_info['units'] = units - - # Set the options for the current #define - if define_name == "MOTHERBOARD" and boards != '': - define_info['options'] = boards - elif options_json != '': - define_info['options'] = options_json - if eol_options: options_json = '' - - # Create section dict if it doesn't exist yet - if section not in sch_out[fk]: sch_out[fk][section] = {} - - # If define has already been seen... - if define_name in sch_out[fk][section]: - info = sch_out[fk][section][define_name] - if isinstance(info, dict): info = [ info ] # Convert a single dict into a list - info.append(define_info) # Add to the list - else: - # Add the define dict with name as key - sch_out[fk][section][define_name] = define_info - - if state == Parse.EOL_COMMENT: - last_added_ref = define_info - - return sch_out + # Load board names from boards.h + boards = load_boards() + + # Parsing states + class Parse: + NORMAL = 0 # No condition yet + BLOCK_COMMENT = 1 # Looking for the end of the block comment + EOL_COMMENT = 2 # EOL comment started, maybe add the next comment? + GET_SENSORS = 3 # Gathering temperature sensor options + ERROR = 9 # Syntax error + + # List of files to process, with shorthand + filekey = { 'Configuration.h':'basic', 'Configuration_adv.h':'advanced' } + # A JSON object to store the data + sch_out = { 'basic':{}, 'advanced':{} } + # Regex for #define NAME [VALUE] [COMMENT] with sanitized line + defgrep = re.compile(r'^(//)?\s*(#define)\s+([A-Za-z0-9_]+)\s*(.*?)\s*(//.+)?$') + # Defines to ignore + ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXAMPLES_DIR', 'CONFIG_EXPORT') + # Start with unknown state + state = Parse.NORMAL + # Serial ID + sid = 0 + # Loop through files and parse them line by line + for fn, fk in filekey.items(): + with Path("Marlin", fn).open() as fileobj: + section = 'none' # Current Settings section + line_number = 0 # Counter for the line number of the file + conditions = [] # Create a condition stack for the current file + comment_buff = [] # A temporary buffer for comments + options_json = '' # A buffer for the most recent options JSON found + eol_options = False # The options came from end of line, so only apply once + join_line = False # A flag that the line should be joined with the previous one + line = '' # A line buffer to handle \ continuation + last_added_ref = None # Reference to the last added item + # Loop through the lines in the file + for the_line in fileobj.readlines(): + line_number += 1 + + # Clean the line for easier parsing + the_line = the_line.strip() + + if join_line: # A previous line is being made longer + line += (' ' if line else '') + the_line + else: # Otherwise, start the line anew + line, line_start = the_line, line_number + + # If the resulting line ends with a \, don't process now. + # Strip the end off. The next line will be joined with it. + join_line = line.endswith("\\") + if join_line: + line = line[:-1].strip() + continue + else: + line_end = line_number + + defmatch = defgrep.match(line) + + # Special handling for EOL comments after a #define. + # At this point the #define is already digested and inserted, + # so we have to extend it + if state == Parse.EOL_COMMENT: + # If the line is not a comment, we're done with the EOL comment + if not defmatch and the_line.startswith('//'): + comment_buff.append(the_line[2:].strip()) + else: + last_added_ref['comment'] = ' '.join(comment_buff) + comment_buff = [] + state = Parse.NORMAL + + def use_comment(c, opt, sec, bufref): + if c.startswith(':'): # If the comment starts with : then it has magic JSON + d = c[1:].strip() # Strip the leading : + cbr = c.rindex('}') if d.startswith('{') else c.rindex(']') if d.startswith('[') else 0 + if cbr: + opt, cmt = c[1:cbr+1].strip(), c[cbr+1:].strip() + if cmt != '': bufref.append(cmt) + else: + opt = c[1:].strip() + elif c.startswith('@section'): # Start a new section + sec = c[8:].strip() + elif not c.startswith('========'): + bufref.append(c) + return opt, sec + + # In a block comment, capture lines up to the end of the comment. + # Assume nothing follows the comment closure. + if state in (Parse.BLOCK_COMMENT, Parse.GET_SENSORS): + endpos = line.find('*/') + if endpos < 0: + cline = line + else: + cline, line = line[:endpos].strip(), line[endpos+2:].strip() + + # Temperature sensors are done + if state == Parse.GET_SENSORS: + options_json = f'[ {options_json[:-2]} ]' + + state = Parse.NORMAL + + # Strip the leading '*' from block comments + if cline.startswith('*'): cline = cline[1:].strip() + + # Collect temperature sensors + if state == Parse.GET_SENSORS: + sens = re.match(r'^(-?\d+)\s*:\s*(.+)$', cline) + if sens: + s2 = sens[2].replace("'","''") + options_json += f"{sens[1]}:'{s2}', " + + elif state == Parse.BLOCK_COMMENT: + + # Look for temperature sensors + if cline == "Temperature sensors available:": + state, cline = Parse.GET_SENSORS, "Temperature Sensors" + + options_json, section = use_comment(cline, options_json, section, comment_buff) + + # For the normal state we're looking for any non-blank line + elif state == Parse.NORMAL: + # Skip a commented define when evaluating comment opening + st = 2 if re.match(r'^//\s*#define', line) else 0 + cpos1 = line.find('/*') # Start a block comment on the line? + cpos2 = line.find('//', st) # Start an end of line comment on the line? + + # Only the first comment starter gets evaluated + cpos = -1 + if cpos1 != -1 and (cpos1 < cpos2 or cpos2 == -1): + cpos = cpos1 + comment_buff = [] + state = Parse.BLOCK_COMMENT + eol_options = False + + elif cpos2 != -1 and (cpos2 < cpos1 or cpos1 == -1): + cpos = cpos2 + + # Comment after a define may be continued on the following lines + if defmatch != None and cpos > 10: + state = Parse.EOL_COMMENT + comment_buff = [] + + # Process the start of a new comment + if cpos != -1: + cline, line = line[cpos+2:].strip(), line[:cpos].strip() + + if state == Parse.BLOCK_COMMENT: + # Strip leading '*' from block comments + if cline.startswith('*'): cline = cline[1:].strip() + else: + # Expire end-of-line options after first use + if cline.startswith(':'): eol_options = True + + # Buffer a non-empty comment start + if cline != '': + options_json, section = use_comment(cline, options_json, section, comment_buff) + + # If the line has nothing before the comment, go to the next line + if line == '': + options_json = '' + continue + + # Parenthesize the given expression if needed + def atomize(s): + if s == '' \ + or re.match(r'^[A-Za-z0-9_]*(\([^)]+\))?$', s) \ + or re.match(r'^[A-Za-z0-9_]+ == \d+?$', s): + return s + return f'({s})' + + # + # The conditions stack is an array containing condition-arrays. + # Each condition-array lists the conditions for the current block. + # IF/N/DEF adds a new condition-array to the stack. + # ELSE/ELIF/ENDIF pop the condition-array. + # ELSE/ELIF negate the last item in the popped condition-array. + # ELIF adds a new condition to the end of the array. + # ELSE/ELIF re-push the condition-array. + # + cparts = line.split() + iselif, iselse = cparts[0] == '#elif', cparts[0] == '#else' + if iselif or iselse or cparts[0] == '#endif': + if len(conditions) == 0: + raise Exception(f'no #if block at line {line_number}') + + # Pop the last condition-array from the stack + prev = conditions.pop() + + if iselif or iselse: + prev[-1] = '!' + prev[-1] # Invert the last condition + if iselif: prev.append(atomize(line[5:].strip())) + conditions.append(prev) + + elif cparts[0] == '#if': + conditions.append([ atomize(line[3:].strip()) ]) + elif cparts[0] == '#ifdef': + conditions.append([ f'defined({line[6:].strip()})' ]) + elif cparts[0] == '#ifndef': + conditions.append([ f'!defined({line[7:].strip()})' ]) + + # Handle a complete #define line + elif defmatch != None: + + # Get the match groups into vars + enabled, define_name, val = defmatch[1] == None, defmatch[3], defmatch[4] + + # Increment the serial ID + sid += 1 + + # Create a new dictionary for the current #define + define_info = { + 'section': section, + 'name': define_name, + 'enabled': enabled, + 'line': line_start, + 'sid': sid + } + + # Type is based on the value + if val == '': + value_type = 'switch' + elif re.match(r'^(true|false)$', val): + value_type = 'bool' + val = val == 'true' + elif re.match(r'^[-+]?\s*\d+$', val): + value_type = 'int' + val = int(val) + elif re.match(r'[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?', val): + value_type = 'float' + val = float(val.replace('f','')) + else: + value_type = 'string' if val[0] == '"' \ + else 'char' if val[0] == "'" \ + else 'state' if re.match(r'^(LOW|HIGH)$', val) \ + else 'enum' if re.match(r'^[A-Za-z0-9_]{3,}$', val) \ + else 'int[]' if re.match(r'^{(\s*[-+]?\s*\d+\s*(,\s*)?)+}$', val) \ + else 'float[]' if re.match(r'^{(\s*[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?\s*(,\s*)?)+}$', val) \ + else 'array' if val[0] == '{' \ + else '' + + if val != '': define_info['value'] = val + if value_type != '': define_info['type'] = value_type + + # Join up accumulated conditions with && + if conditions: define_info['requires'] = ' && '.join(sum(conditions, [])) + + # If the comment_buff is not empty, add the comment to the info + if comment_buff: + full_comment = '\n'.join(comment_buff) + + # An EOL comment will be added later + # The handling could go here instead of above + if state == Parse.EOL_COMMENT: + define_info['comment'] = '' + else: + define_info['comment'] = full_comment + comment_buff = [] + + # If the comment specifies units, add that to the info + units = re.match(r'^\(([^)]+)\)', full_comment) + if units: + units = units[1] + if units == 's' or units == 'sec': units = 'seconds' + define_info['units'] = units + + # Set the options for the current #define + if define_name == "MOTHERBOARD" and boards != '': + define_info['options'] = boards + elif options_json != '': + define_info['options'] = options_json + if eol_options: options_json = '' + + # Create section dict if it doesn't exist yet + if section not in sch_out[fk]: sch_out[fk][section] = {} + + # If define has already been seen... + if define_name in sch_out[fk][section]: + info = sch_out[fk][section][define_name] + if isinstance(info, dict): info = [ info ] # Convert a single dict into a list + info.append(define_info) # Add to the list + else: + # Add the define dict with name as key + sch_out[fk][section][define_name] = define_info + + if state == Parse.EOL_COMMENT: + last_added_ref = define_info + + return sch_out def dump_json(schema:dict, jpath:Path): - with jpath.open('w') as jfile: - json.dump(schema, jfile, ensure_ascii=False, indent=2) + with jpath.open('w') as jfile: + json.dump(schema, jfile, ensure_ascii=False, indent=2) def dump_yaml(schema:dict, ypath:Path): - import yaml - with ypath.open('w') as yfile: - yaml.dump(schema, yfile, default_flow_style=False, width=120, indent=2) + import yaml + with ypath.open('w') as yfile: + yaml.dump(schema, yfile, default_flow_style=False, width=120, indent=2) def main(): - try: - schema = extract() - except Exception as exc: - print("Error: " + str(exc)) - schema = None - - if schema: - print("Generating JSON ...") - dump_json(schema, Path('schema.json')) - group_options(schema) - dump_json(schema, Path('schema_grouped.json')) - - try: - import yaml - except ImportError: - print("Installing YAML module ...") - import subprocess - subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) - import yaml - - print("Generating YML ...") - dump_yaml(schema, Path('schema.yml')) + try: + schema = extract() + except Exception as exc: + print("Error: " + str(exc)) + schema = None + + if schema: + + # Get the first command line argument + import sys + if len(sys.argv) > 1: + arg = sys.argv[1] + else: + arg = 'some' + + # JSON schema + if arg in ['some', 'json', 'jsons']: + print("Generating JSON ...") + dump_json(schema, Path('schema.json')) + + # JSON schema (wildcard names) + if arg in ['group', 'jsons']: + group_options(schema) + dump_json(schema, Path('schema_grouped.json')) + + # YAML + if arg in ['some', 'yml', 'yaml']: + try: + import yaml + except ImportError: + print("Installing YAML module ...") + import subprocess + try: + subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) + import yaml + except: + print("Failed to install YAML module") + return + + print("Generating YML ...") + dump_yaml(schema, Path('schema.yml')) if __name__ == '__main__': - main() + main() diff --git a/buildroot/share/PlatformIO/scripts/signature.py b/buildroot/share/PlatformIO/scripts/signature.py index 43d56ac6e1a4..4fc0084e575b 100644 --- a/buildroot/share/PlatformIO/scripts/signature.py +++ b/buildroot/share/PlatformIO/scripts/signature.py @@ -16,32 +16,32 @@ # resulting config.ini to produce more exact configuration files. # def extract_defines(filepath): - f = open(filepath, encoding="utf8").read().split("\n") - a = [] - for line in f: - sline = line.strip() - if sline[:7] == "#define": - # Extract the key here (we don't care about the value) - kv = sline[8:].strip().split() - a.append(kv[0]) - return a + f = open(filepath, encoding="utf8").read().split("\n") + a = [] + for line in f: + sline = line.strip() + if sline[:7] == "#define": + # Extract the key here (we don't care about the value) + kv = sline[8:].strip().split() + a.append(kv[0]) + return a # Compute the SHA256 hash of a file def get_file_sha256sum(filepath): - sha256_hash = hashlib.sha256() - with open(filepath,"rb") as f: - # Read and update hash string value in blocks of 4K - for byte_block in iter(lambda: f.read(4096),b""): - sha256_hash.update(byte_block) - return sha256_hash.hexdigest() + sha256_hash = hashlib.sha256() + with open(filepath,"rb") as f: + # Read and update hash string value in blocks of 4K + for byte_block in iter(lambda: f.read(4096),b""): + sha256_hash.update(byte_block) + return sha256_hash.hexdigest() # # Compress a JSON file into a zip file # import zipfile def compress_file(filepath, outpath): - with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf: - zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9) + with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf: + zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9) # # Compute the build signature. The idea is to extract all defines in the configuration headers @@ -49,228 +49,228 @@ def compress_file(filepath, outpath): # We can reverse the signature to get a 1:1 equivalent configuration file # def compute_build_signature(env): - if 'BUILD_SIGNATURE' in env: - return - - # Definitions from these files will be kept - files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ] - - build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) - - # Check if we can skip processing - hashes = '' - for header in files_to_keep: - hashes += get_file_sha256sum(header)[0:10] - - marlin_json = build_path / 'marlin_config.json' - marlin_zip = build_path / 'mc.zip' - - # Read existing config file - try: - with marlin_json.open() as infile: - conf = json.load(infile) - if conf['__INITIAL_HASH'] == hashes: - # Same configuration, skip recomputing the building signature - compress_file(marlin_json, marlin_zip) - return - except: - pass - - # Get enabled config options based on preprocessor - from preprocessor import run_preprocessor - complete_cfg = run_preprocessor(env) - - # Dumb #define extraction from the configuration files - conf_defines = {} - all_defines = [] - for header in files_to_keep: - defines = extract_defines(header) - # To filter only the define we want - all_defines += defines - # To remember from which file it cames from - conf_defines[header.split('/')[-1]] = defines - - r = re.compile(r"\(+(\s*-*\s*_.*)\)+") - - # First step is to collect all valid macros - defines = {} - for line in complete_cfg: - - # Split the define from the value - key_val = line[8:].strip().decode().split(' ') - key, value = key_val[0], ' '.join(key_val[1:]) - - # Ignore values starting with two underscore, since it's low level - if len(key) > 2 and key[0:2] == "__" : - continue - # Ignore values containing a parenthesis (likely a function macro) - if '(' in key and ')' in key: - continue - - # Then filter dumb values - if r.match(value): - continue - - defines[key] = value if len(value) else "" - - # - # Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_EXPORT - # - if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_EXPORT' in defines): - return - - # Second step is to filter useless macro - resolved_defines = {} - for key in defines: - # Remove all boards now - if key.startswith("BOARD_") and key != "BOARD_INFO_NAME": - continue - # Remove all keys ending by "_NAME" as it does not make a difference to the configuration - if key.endswith("_NAME") and key != "CUSTOM_MACHINE_NAME": - continue - # Remove all keys ending by "_T_DECLARED" as it's a copy of extraneous system stuff - if key.endswith("_T_DECLARED"): - continue - # Remove keys that are not in the #define list in the Configuration list - if key not in all_defines + [ 'DETAILED_BUILD_VERSION', 'STRING_DISTRIBUTION_DATE' ]: - continue - - # Don't be that smart guy here - resolved_defines[key] = defines[key] - - # Generate a build signature now - # We are making an object that's a bit more complex than a basic dictionary here - data = {} - data['__INITIAL_HASH'] = hashes - # First create a key for each header here - for header in conf_defines: - data[header] = {} - - # Then populate the object where each key is going to (that's a O(N^2) algorithm here...) - for key in resolved_defines: - for header in conf_defines: - if key in conf_defines[header]: - data[header][key] = resolved_defines[key] - - # Every python needs this toy - def tryint(key): - try: - return int(defines[key]) - except: - return 0 - - config_dump = tryint('CONFIG_EXPORT') - - # - # Produce an INI file if CONFIG_EXPORT == 2 - # - if config_dump == 2: - print("Generating config.ini ...") - config_ini = build_path / 'config.ini' - with config_ini.open('w') as outfile: - ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') - filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' } - vers = defines["CONFIGURATION_H_VERSION"] - dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S") - ini_fmt = '{0:40}{1}\n' - outfile.write( - '#\n' - + '# Marlin Firmware\n' - + '# config.ini - Options to apply before the build\n' - + '#\n' - + f'# Generated by Marlin build on {dt_string}\n' - + '#\n' - + '\n' - + '[config:base]\n' - + ini_fmt.format('ini_use_config', ' = all') - + ini_fmt.format('ini_config_vers', f' = {vers}') - ) - # Loop through the data array of arrays - for header in data: - if header.startswith('__'): - continue - outfile.write('\n[' + filegrp[header] + ']\n') - for key in sorted(data[header]): - if key not in ignore: - val = 'on' if data[header][key] == '' else data[header][key] - outfile.write(ini_fmt.format(key.lower(), ' = ' + val)) - - # - # Produce a schema.json file if CONFIG_EXPORT == 3 - # - if config_dump >= 3: - try: - conf_schema = schema.extract() - except Exception as exc: - print("Error: " + str(exc)) - conf_schema = None - - if conf_schema: - # - # Produce a schema.json file if CONFIG_EXPORT == 3 - # - if config_dump in (3, 13): - print("Generating schema.json ...") - schema.dump_json(conf_schema, build_path / 'schema.json') - if config_dump == 13: - schema.group_options(conf_schema) - schema.dump_json(conf_schema, build_path / 'schema_grouped.json') - - # - # Produce a schema.yml file if CONFIG_EXPORT == 4 - # - elif config_dump == 4: - print("Generating schema.yml ...") - try: - import yaml - except ImportError: - env.Execute(env.VerboseAction( - '$PYTHONEXE -m pip install "pyyaml"', - "Installing YAML for schema.yml export", - )) - import yaml - schema.dump_yaml(conf_schema, build_path / 'schema.yml') - - # Append the source code version and date - data['VERSION'] = {} - data['VERSION']['DETAILED_BUILD_VERSION'] = resolved_defines['DETAILED_BUILD_VERSION'] - data['VERSION']['STRING_DISTRIBUTION_DATE'] = resolved_defines['STRING_DISTRIBUTION_DATE'] - try: - curver = subprocess.check_output(["git", "describe", "--match=NeVeRmAtCh", "--always"]).strip() - data['VERSION']['GIT_REF'] = curver.decode() - except: - pass - - # - # Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_EXPORT == 1 - # - if config_dump == 1 or 'CONFIGURATION_EMBEDDING' in defines: - with marlin_json.open('w') as outfile: - json.dump(data, outfile, separators=(',', ':')) - - # - # The rest only applies to CONFIGURATION_EMBEDDING - # - if not 'CONFIGURATION_EMBEDDING' in defines: - return - - # Compress the JSON file as much as we can - compress_file(marlin_json, marlin_zip) - - # Generate a C source file for storing this array - with open('Marlin/src/mczip.h','wb') as result_file: - result_file.write( - b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n' - + b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n' - + b'#endif\n' - + b'const unsigned char mc_zip[] PROGMEM = {\n ' - ) - count = 0 - for b in (build_path / 'mc.zip').open('rb').read(): - result_file.write(b' 0x%02X,' % b) - count += 1 - if count % 16 == 0: - result_file.write(b'\n ') - if count % 16: - result_file.write(b'\n') - result_file.write(b'};\n') + if 'BUILD_SIGNATURE' in env: + return + + # Definitions from these files will be kept + files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ] + + build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) + + # Check if we can skip processing + hashes = '' + for header in files_to_keep: + hashes += get_file_sha256sum(header)[0:10] + + marlin_json = build_path / 'marlin_config.json' + marlin_zip = build_path / 'mc.zip' + + # Read existing config file + try: + with marlin_json.open() as infile: + conf = json.load(infile) + if conf['__INITIAL_HASH'] == hashes: + # Same configuration, skip recomputing the building signature + compress_file(marlin_json, marlin_zip) + return + except: + pass + + # Get enabled config options based on preprocessor + from preprocessor import run_preprocessor + complete_cfg = run_preprocessor(env) + + # Dumb #define extraction from the configuration files + conf_defines = {} + all_defines = [] + for header in files_to_keep: + defines = extract_defines(header) + # To filter only the define we want + all_defines += defines + # To remember from which file it cames from + conf_defines[header.split('/')[-1]] = defines + + r = re.compile(r"\(+(\s*-*\s*_.*)\)+") + + # First step is to collect all valid macros + defines = {} + for line in complete_cfg: + + # Split the define from the value + key_val = line[8:].strip().decode().split(' ') + key, value = key_val[0], ' '.join(key_val[1:]) + + # Ignore values starting with two underscore, since it's low level + if len(key) > 2 and key[0:2] == "__" : + continue + # Ignore values containing a parenthesis (likely a function macro) + if '(' in key and ')' in key: + continue + + # Then filter dumb values + if r.match(value): + continue + + defines[key] = value if len(value) else "" + + # + # Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_EXPORT + # + if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_EXPORT' in defines): + return + + # Second step is to filter useless macro + resolved_defines = {} + for key in defines: + # Remove all boards now + if key.startswith("BOARD_") and key != "BOARD_INFO_NAME": + continue + # Remove all keys ending by "_NAME" as it does not make a difference to the configuration + if key.endswith("_NAME") and key != "CUSTOM_MACHINE_NAME": + continue + # Remove all keys ending by "_T_DECLARED" as it's a copy of extraneous system stuff + if key.endswith("_T_DECLARED"): + continue + # Remove keys that are not in the #define list in the Configuration list + if key not in all_defines + [ 'DETAILED_BUILD_VERSION', 'STRING_DISTRIBUTION_DATE' ]: + continue + + # Don't be that smart guy here + resolved_defines[key] = defines[key] + + # Generate a build signature now + # We are making an object that's a bit more complex than a basic dictionary here + data = {} + data['__INITIAL_HASH'] = hashes + # First create a key for each header here + for header in conf_defines: + data[header] = {} + + # Then populate the object where each key is going to (that's a O(N^2) algorithm here...) + for key in resolved_defines: + for header in conf_defines: + if key in conf_defines[header]: + data[header][key] = resolved_defines[key] + + # Every python needs this toy + def tryint(key): + try: + return int(defines[key]) + except: + return 0 + + config_dump = tryint('CONFIG_EXPORT') + + # + # Produce an INI file if CONFIG_EXPORT == 2 + # + if config_dump == 2: + print("Generating config.ini ...") + config_ini = build_path / 'config.ini' + with config_ini.open('w') as outfile: + ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') + filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' } + vers = defines["CONFIGURATION_H_VERSION"] + dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S") + ini_fmt = '{0:40}{1}\n' + outfile.write( + '#\n' + + '# Marlin Firmware\n' + + '# config.ini - Options to apply before the build\n' + + '#\n' + + f'# Generated by Marlin build on {dt_string}\n' + + '#\n' + + '\n' + + '[config:base]\n' + + ini_fmt.format('ini_use_config', ' = all') + + ini_fmt.format('ini_config_vers', f' = {vers}') + ) + # Loop through the data array of arrays + for header in data: + if header.startswith('__'): + continue + outfile.write('\n[' + filegrp[header] + ']\n') + for key in sorted(data[header]): + if key not in ignore: + val = 'on' if data[header][key] == '' else data[header][key] + outfile.write(ini_fmt.format(key.lower(), ' = ' + val)) + + # + # Produce a schema.json file if CONFIG_EXPORT == 3 + # + if config_dump >= 3: + try: + conf_schema = schema.extract() + except Exception as exc: + print("Error: " + str(exc)) + conf_schema = None + + if conf_schema: + # + # Produce a schema.json file if CONFIG_EXPORT == 3 + # + if config_dump in (3, 13): + print("Generating schema.json ...") + schema.dump_json(conf_schema, build_path / 'schema.json') + if config_dump == 13: + schema.group_options(conf_schema) + schema.dump_json(conf_schema, build_path / 'schema_grouped.json') + + # + # Produce a schema.yml file if CONFIG_EXPORT == 4 + # + elif config_dump == 4: + print("Generating schema.yml ...") + try: + import yaml + except ImportError: + env.Execute(env.VerboseAction( + '$PYTHONEXE -m pip install "pyyaml"', + "Installing YAML for schema.yml export", + )) + import yaml + schema.dump_yaml(conf_schema, build_path / 'schema.yml') + + # Append the source code version and date + data['VERSION'] = {} + data['VERSION']['DETAILED_BUILD_VERSION'] = resolved_defines['DETAILED_BUILD_VERSION'] + data['VERSION']['STRING_DISTRIBUTION_DATE'] = resolved_defines['STRING_DISTRIBUTION_DATE'] + try: + curver = subprocess.check_output(["git", "describe", "--match=NeVeRmAtCh", "--always"]).strip() + data['VERSION']['GIT_REF'] = curver.decode() + except: + pass + + # + # Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_EXPORT == 1 + # + if config_dump == 1 or 'CONFIGURATION_EMBEDDING' in defines: + with marlin_json.open('w') as outfile: + json.dump(data, outfile, separators=(',', ':')) + + # + # The rest only applies to CONFIGURATION_EMBEDDING + # + if not 'CONFIGURATION_EMBEDDING' in defines: + return + + # Compress the JSON file as much as we can + compress_file(marlin_json, marlin_zip) + + # Generate a C source file for storing this array + with open('Marlin/src/mczip.h','wb') as result_file: + result_file.write( + b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n' + + b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n' + + b'#endif\n' + + b'const unsigned char mc_zip[] PROGMEM = {\n ' + ) + count = 0 + for b in (build_path / 'mc.zip').open('rb').read(): + result_file.write(b' 0x%02X,' % b) + count += 1 + if count % 16 == 0: + result_file.write(b'\n ') + if count % 16: + result_file.write(b'\n') + result_file.write(b'};\n') diff --git a/buildroot/share/PlatformIO/scripts/simulator.py b/buildroot/share/PlatformIO/scripts/simulator.py index 2961d2826d41..608258c4d17a 100644 --- a/buildroot/share/PlatformIO/scripts/simulator.py +++ b/buildroot/share/PlatformIO/scripts/simulator.py @@ -2,51 +2,52 @@ # simulator.py # PlatformIO pre: script for simulator builds # + import pioutil if pioutil.is_pio_build(): - # Get the environment thus far for the build - Import("env") + # Get the environment thus far for the build + Import("env") - #print(env.Dump()) + #print(env.Dump()) - # - # Give the binary a distinctive name - # + # + # Give the binary a distinctive name + # - env['PROGNAME'] = "MarlinSimulator" + 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. - # + # + # 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': + import sys + if sys.platform == 'darwin': - # - # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS') - # - env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ] + # + # 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" + # 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 + import os.path - if os.path.exists(xcode_path): + if os.path.exists(xcode_path): - env['BUILD_FLAGS'] += [ "-F" + xcode_path ] - print("Using OpenGL framework headers from Xcode.app") + env['BUILD_FLAGS'] += [ "-F" + xcode_path ] + print("Using OpenGL framework headers from Xcode.app") - elif os.path.exists(mesa_path): + elif os.path.exists(mesa_path): - env['BUILD_FLAGS'] += [ '-D__MESA__' ] - print("Using OpenGL header from", mesa_path) + env['BUILD_FLAGS'] += [ '-D__MESA__' ] + print("Using OpenGL header from", mesa_path) - else: + 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") + 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) + # Break out of the PIO build immediately + sys.exit(1) diff --git a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py index 033803009e52..1f5f6eec78ba 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py +++ b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py @@ -3,59 +3,59 @@ # import pioutil if pioutil.is_pio_build(): - Import("env") - - # 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}"]) - - # 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"] - - # 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) + Import("env") + + # 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}"]) + + # 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"] + + # 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_ARCHIM/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.cpp index 72ad45ef4602..5e8e1cc7e4ea 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.cpp @@ -413,7 +413,7 @@ void init( void ) // Disable pull-up on every pin for (unsigned i = 0; i < PINS_COUNT; i++) - digitalWrite(i, LOW); + digitalWrite(i, LOW); // Enable parallel access on PIO output data registers PIOA->PIO_OWER = 0xFFFFFFFF; diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h index 9fa98807d68e..bbce8a1c9a11 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

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

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld index 57c01c8df8fc..0f8a490044f7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld @@ -20,7 +20,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S index 81999dda6a42..9348cd057ade 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S @@ -16,7 +16,7 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2015 STMicroelectronics

+ * Copyright (c) 2015 STMicroelectronics * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld index 6af296a521ff..f7e09b8ef0e7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld index 6af296a521ff..f7e09b8ef0e7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld index 6af296a521ff..f7e09b8ef0e7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/ldscript.ld index 4cac4ac6e2a7..063525c96400 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/ldscript.ld index ca21498cd2d9..ed6cae4379b9 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld index 6af296a521ff..f7e09b8ef0e7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PeripheralPins.c new file mode 100644 index 000000000000..a8a98fc6c59d --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PeripheralPins.c @@ -0,0 +1,377 @@ +/* + ******************************************************************************* + * Copyright (c) 2020, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +/* + * Automatically generated from STM32G0B1C(B-C-E)Tx.xml, STM32G0B1C(B-C-E)Ux.xml + * STM32G0C1C(C-E)Tx.xml, STM32G0C1C(C-E)Ux.xml + * CubeMX DB release 6.0.60 + */ +#if !defined(CUSTOM_PERIPHERAL_PINS) +#include "Arduino.h" +#include "PeripheralPins.h" + +/* ===== + * Notes: + * - The pins mentioned Px_y_ALTz are alternative possibilities which use other + * HW peripheral instances. You can use them the same way as any other "normal" + * pin (i.e. analogWrite(PA7_ALT1, 128);). + * + * - Commented lines are alternative possibilities which are not used per default. + * If you change them, you will have to know what you do + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + {PB_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PB_10, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PB_11, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + {PB_12, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +WEAK const PinMap PinMap_DAC[] = { + {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC1_OUT1 + {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PA_6, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_6_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PA_10, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_10_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_10_R, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_10_R_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_4, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PB_4_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_14, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_7, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_7_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PA_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_9_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_9_R, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_9_R_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PB_3_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_13, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {NC, NP, 0} +}; +#endif + +//*** TIM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_TIM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 1)}, // TIM15_CH1N + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 0)}, // TIM15_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 2, 0)}, // TIM15_CH2 + {PA_4, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PA_6_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM16, 1, 0)}, // TIM16_CH1 + {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PA_7_ALT2, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_7_ALT3, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM17, 1, 0)}, // TIM17_CH1 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PA_9_R, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PA_10_R, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PB_0_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 3, 0)}, // TIM3_CH3 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 4, 0)}, // TIM3_CH4 + {PB_1_ALT2, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM14, 1, 0)}, // TIM14_CH1 + {PB_3, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PB_3_ALT1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PB_6_ALT1, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 1, 0)}, // TIM4_CH1 + {PB_6_ALT2, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 1)}, // TIM16_CH1N + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 2, 0)}, // TIM4_CH2 + {PB_7_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 1)}, // TIM17_CH1N + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 0)}, // TIM16_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 0)}, // TIM17_CH1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PB_13_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 1)}, // TIM15_CH1N + {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PB_14_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 0)}, // TIM15_CH1 + {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PB_15_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N + {PB_15_ALT2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 2, 0)}, // TIM15_CH2 + {PC_6, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PC_6_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PC_7, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PC_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PD_0, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 0)}, // TIM16_CH1 + {PD_1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 0)}, // TIM17_CH1 + {PD_2, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PD_3, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PF_0, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM14, 1, 0)}, // TIM14_CH1 + {PF_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 1, 1)}, // TIM15_CH1N + {NC, NP, 0} +}; +#endif + +//*** UART *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_0, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PA_2, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_2_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_4, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_9_R, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_14, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PA_14_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PB_0, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PB_6, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_6_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {PB_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_8_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PC_6, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PD_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PF_2, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + {PA_1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PA_3, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_3_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_5, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_10_R, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_13, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PA_15, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PB_0, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_1, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_4, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PB_7, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_7_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {PB_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_9_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PC_7, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PD_2, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RTS[] = { + {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_15, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_USART3)}, + {PA_15_ALT1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PB_1, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PB_1_ALT1, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_1_ALT2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_3, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PB_5, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_12, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_14_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PD_2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PF_2, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_CTS[] = { + {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_6_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PA_6_ALT2, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PB_0, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_4, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PB_6, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_7, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PB_13, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_13_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_2, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_10_R, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_5_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PB_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PA_9_R, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PA_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_6, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_0, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_1, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_3_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_8, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PD_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PA_8, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_15_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_0, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PD_0, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** FDCAN *** + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + {PA_11, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_0, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_5, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_8, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_12, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PD_0, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_TD[] = { + {PA_12, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_1, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_6, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_9, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_13, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PD_1, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {NC, NP, 0} +}; +#endif + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) +WEAK const PinMap PinMap_USB_DRD_FS[] = { + {PA_4, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE + {PA_11, USB_DRD_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DM + {PA_12, USB_DRD_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DP + {PA_13, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE + {PA_15, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USB)}, // USB_NOE + {NC, NP, 0} +}; +#endif + +//*** No SD *** + +#endif /* !CUSTOM_PERIPHERAL_PINS */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PinNamesVar.h new file mode 100644 index 000000000000..4e91fa322c9c --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PinNamesVar.h @@ -0,0 +1,78 @@ +/* Remap pin name */ +PA_9_R = PA_9 | PREMAP, +PA_10_R = PA_10 | PREMAP, + +/* Alternate pin name */ +PA_1_ALT1 = PA_1 | ALT1, +PA_2_ALT1 = PA_2 | ALT1, +PA_3_ALT1 = PA_3 | ALT1, +PA_4_ALT1 = PA_4 | ALT1, +PA_6_ALT1 = PA_6 | ALT1, +PA_6_ALT2 = PA_6 | ALT2, +PA_7_ALT1 = PA_7 | ALT1, +PA_7_ALT2 = PA_7 | ALT2, +PA_7_ALT3 = PA_7 | ALT3, +PA_9_ALT1 = PA_9 | ALT1, +PA_9_R_ALT1 = PA_9_R | ALT1, +PA_10_ALT1 = PA_10 | ALT1, +PA_10_R_ALT1 = PA_10_R | ALT1, +PA_14_ALT1 = PA_14 | ALT1, +PA_15_ALT1 = PA_15 | ALT1, +PB_0_ALT1 = PB_0 | ALT1, +PB_1_ALT1 = PB_1 | ALT1, +PB_1_ALT2 = PB_1 | ALT2, +PB_3_ALT1 = PB_3 | ALT1, +PB_4_ALT1 = PB_4 | ALT1, +PB_5_ALT1 = PB_5 | ALT1, +PB_6_ALT1 = PB_6 | ALT1, +PB_6_ALT2 = PB_6 | ALT2, +PB_7_ALT1 = PB_7 | ALT1, +PB_8_ALT1 = PB_8 | ALT1, +PB_9_ALT1 = PB_9 | ALT1, +PB_13_ALT1 = PB_13 | ALT1, +PB_14_ALT1 = PB_14 | ALT1, +PB_15_ALT1 = PB_15 | ALT1, +PB_15_ALT2 = PB_15 | ALT2, +PC_6_ALT1 = PC_6 | ALT1, +PC_7_ALT1 = PC_7 | ALT1, + +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = PC_13, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = PA_2, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = PB_5, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif + +/* USB */ +#ifdef USBCON + USB_DM = PA_11, + USB_DP = PA_12, + #ifdef USB_NOE_PA_4 + USB_NOE = PA_4, + #endif + #ifdef USB_NOE_PA_13 + USB_NOE = PA_13, + #endif + #ifdef USB_NOE_PA_15 + USB_NOE = PA_15, + #endif +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/ldscript.ld new file mode 100644 index 000000000000..ce97a9f4ae31 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/ldscript.ld @@ -0,0 +1,185 @@ +/* +****************************************************************************** +** +** @file : LinkerScript.ld +** +** @author : Auto-generated by STM32CubeIDE +** +** @brief : Linker script for STM32G0B1CBTx Device from STM32G0 series +** 128Kbytes FLASH +** 144Kbytes RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +****************************************************************************** +** @attention +** +** Copyright (c) 2022 STMicroelectronics. +** All rights reserved. +** +** This software is licensed under terms that can be found in the LICENSE file +** in the root directory of this software component. +** If no LICENSE file comes with this software, it is provided AS-IS. +** +****************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ + +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE + FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Sections */ +SECTIONS +{ + /* The startup code into "FLASH" Rom type memory */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data into "FLASH" Rom type memory */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data into "FLASH" Rom type memory */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >FLASH + + .ARM : { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >FLASH + + .preinit_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + /* Used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections into "RAM" Ram type memory */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + *(.RamFunc) /* .RamFunc sections */ + *(.RamFunc*) /* .RamFunc* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + + } >RAM AT> FLASH + + /* Uninitialized data section into "RAM" Ram type memory */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + /* Remove information from the compiler libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.cpp b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.cpp new file mode 100644 index 000000000000..3bb5f755b7ce --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.cpp @@ -0,0 +1,138 @@ +/* + ******************************************************************************* + * Copyright (c) 2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ + +//#if defined(ARDUINO_EBB42_V1_1) +#include "pins_arduino.h" + +// Pin number +const PinName digitalPin[] = { + PA_0, // D0/A0 + PA_1, // D1/A1 + PA_2, // D2/A2 + PA_3, // D3/A3 + PA_4, // D4/A4 + PA_5, // D5/A5 + PA_6, // D6/A6 + PA_7, // D7/A7 + PA_8, // D8 + PA_9, // D9 + PA_10, // D10 + PA_11, // D11 + PA_12, // D12 + PA_13, // D13 + PA_14, // D14 + PA_15, // D15 + PB_0, // D16/A8 + PB_1, // D17/A9 + PB_2, // D18/A10 + PB_3, // D19 + PB_4, // D20 + PB_5, // D21 + PB_6, // D22 + PB_7, // D23 + PB_8, // D24 + PB_9, // D25 + PB_10, // D26/A11 + PB_11, // D27/A12 + PB_12, // D28/A13 + PB_13, // D29 + PB_14, // D30 + PB_15, // D31 + PC_6, // D32 + PC_7, // D33 + PC_13, // D34 + PC_14, // D35 + PC_15, // D36 + PD_0, // D37 + PD_1, // D38 + PD_2, // D39 + PD_3, // D40 + PF_0, // D41 + PF_1, // D42 + PF_2, // D43 + PA_9_R, // D44 + PA_10_R // D45 +}; + +// Analog (Ax) pin number array +const uint32_t analogInputPin[] = { + 0, // A0, PA0 + 1, // A1, PA1 + 2, // A2, PA2 + 3, // A3, PA3 + 4, // A4, PA4 + 5, // A5, PA5 + 6, // A6, PA6 + 7, // A7, PA7 + 16, // A8, PB0 + 17, // A9, PB1 + 18, // A10, PB2 + 26, // A11, PB10 + 27, // A12, PB11 + 28 // A13, PB12 +}; + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; + + /** Configure the main internal regulator output voltage + */ + HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); + + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; + RCC_OscInitStruct.PLL.PLLN = 16; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; + RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + Error_Handler(); + } + + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK + | RCC_CLOCKTYPE_PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { + Error_Handler(); + } +} + +#ifdef __cplusplus +} +#endif +//#endif /* ARDUINO_EBB42_V1_1 */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.h new file mode 100644 index 000000000000..ff75bc1e4839 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.h @@ -0,0 +1,198 @@ +/* + ******************************************************************************* + * Copyright (c) 2020, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +#pragma once + +/*---------------------------------------------------------------------------- + * STM32 pins number + *----------------------------------------------------------------------------*/ +#define PA0 PIN_A0 +#define PA1 PIN_A1 +#define PA2 PIN_A2 +#define PA3 PIN_A3 +#define PA4 PIN_A4 +#define PA5 PIN_A5 +#define PA6 PIN_A6 +#define PA7 PIN_A7 +#define PA8 8 +#define PA9 9 +#define PA10 10 +#define PA11 11 +#define PA12 12 +#define PA13 13 +#define PA14 14 +#define PA15 15 +#define PB0 PIN_A8 +#define PB1 PIN_A9 +#define PB2 PIN_A10 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 PIN_A11 +#define PB11 PIN_A12 +#define PB12 PIN_A13 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC6 32 +#define PC7 33 +#define PC13 34 +#define PC14 35 +#define PC15 36 +#define PD0 37 +#define PD1 38 +#define PD2 39 +#define PD3 40 +#define PF0 41 +#define PF1 42 +#define PF2 43 +#define PA9_R 44 +#define PA10_R 45 + +// Alternate pins number +#define PA1_ALT1 (PA1 | ALT1) +#define PA2_ALT1 (PA2 | ALT1) +#define PA3_ALT1 (PA3 | ALT1) +#define PA4_ALT1 (PA4 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA6_ALT2 (PA6 | ALT2) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA9_ALT1 (PA9 | ALT1) +#define PA9_R_ALT1 (PA9_R | ALT1) +#define PA10_ALT1 (PA10 | ALT1) +#define PA10_R_ALT1 (PA10_R | ALT1) +#define PA14_ALT1 (PA14 | ALT1) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB6_ALT1 (PB6 | ALT1) +#define PB6_ALT2 (PB6 | ALT2) +#define PB7_ALT1 (PB7 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) +#define PB13_ALT1 (PB13 | ALT1) +#define PB14_ALT1 (PB14 | ALT1) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC6_ALT1 (PC6 | ALT1) +#define PC7_ALT1 (PC7 | ALT1) + +#define NUM_DIGITAL_PINS 46 +#define NUM_REMAP_PINS 2 +#define NUM_ANALOG_INPUTS 14 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PNUM_NOT_DEFINED +#endif + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PNUM_NOT_DEFINED +#endif + +// SPI definitions +#ifndef PIN_SPI_SS + #define PIN_SPI_SS PA4 +#endif +#ifndef PIN_SPI_SS1 + #define PIN_SPI_SS1 PA15 +#endif +#ifndef PIN_SPI_SS2 + #define PIN_SPI_SS2 PB0 +#endif +#ifndef PIN_SPI_SS3 + #define PIN_SPI_SS3 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA2 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA1 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PA6 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PA7 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 4 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA1 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA0 +#endif + +// Extra HAL modules +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + #define SERIAL_PORT_HARDWARE Serial + #endif +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h index 99f3a30443b6..f355549a675e 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

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

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the @@ -100,11 +100,11 @@ extern "C" { * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) +#ifndef HSE_VALUE #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ -#if !defined (HSE_STARTUP_TIMEOUT) +#ifndef HSE_STARTUP_TIMEOUT #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ @@ -112,7 +112,7 @@ extern "C" { * @brief Internal oscillator (CSI) default value. * This value is the default CSI value after Reset. */ -#if !defined (CSI_VALUE) +#ifndef CSI_VALUE #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ #endif /* CSI_VALUE */ @@ -121,7 +121,7 @@ extern "C" { * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ -#if !defined (HSI_VALUE) +#ifndef HSI_VALUE #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ #endif /* HSI_VALUE */ @@ -129,16 +129,16 @@ extern "C" { * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ -#if !defined (LSE_VALUE) +#ifndef LSE_VALUE #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ -#if !defined (LSE_STARTUP_TIMEOUT) +#ifndef LSE_STARTUP_TIMEOUT #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ -#if !defined (LSI_VALUE) +#ifndef LSI_VALUE #define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations @@ -148,7 +148,7 @@ in voltage and temperature.*/ * This value is used by the I2S HAL module to compute the I2S clock source * frequency, this source is inserted directly through I2S_CKIN pad. */ -#if !defined (EXTERNAL_CLOCK_VALUE) +#ifndef EXTERNAL_CLOCK_VALUE #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld index 006c87a17a18..931091bc3109 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld @@ -26,7 +26,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp index 203e9fc9b8f8..ce2f2a0aa305 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp @@ -184,7 +184,7 @@ void SystemClockStartupInit() { PWR->CR3 &= ~(1 << 2); // SCUEN=0 PWR->D3CR |= 3 << 14; // VOS=3,Scale1,1.15~1.26V core voltage - while((PWR->D3CR & (1 << 13)) == 0); // Wait for the voltage to stabilize + while((PWR->D3CR & (1 << 13)) == 0); // Wait for the voltage to stabilize RCC->CR |= 1<<16; // Enable HSE uint16_t timeout = 0; @@ -198,9 +198,9 @@ void SystemClockStartupInit() { RCC->PLLCKSELR |= 2 << 0; // PLLSRC[1:0] = 2, HSE for PLL clock source RCC->PLLCKSELR |= 5 << 4; // DIVM1[5:0] = pllm, Prescaler for PLL1 RCC->PLL1DIVR |= (160 - 1) << 0; // DIVN1[8:0] = plln - 1, Multiplication factor for PLL1 VCO - RCC->PLL1DIVR |= (2 - 1) << 9; // DIVP1[6:0] = pllp - 1, PLL1 DIVP division factor + RCC->PLL1DIVR |= (2 - 1) << 9; // DIVP1[6:0] = pllp - 1, PLL1 DIVP division factor RCC->PLL1DIVR |= (4 - 1) << 16; // DIVQ1[6:0] = pllq - 1, PLL1 DIVQ division factor - RCC->PLL1DIVR |= 1 << 24; // DIVR1[6:0] = pllr - 1, PLL1 DIVR division factor + RCC->PLL1DIVR |= 1 << 24; // DIVR1[6:0] = pllr - 1, PLL1 DIVR division factor RCC->PLLCFGR |= 2 << 2; // PLL1 input (ref1_ck) clock range frequency is between 4 and 8 MHz RCC->PLLCFGR |= 0 << 1; // PLL1 VCO selection, 0: 192 to 836 MHz, 1 : 150 to 420 MHz RCC->PLLCFGR |= 3 << 16; // pll1_q_ck and pll1_p_ck output is enabled @@ -209,7 +209,7 @@ void SystemClockStartupInit() { // PLL2 DIVR clock frequency = 220MHz, so that SDRAM clock can be set to 110MHz RCC->PLLCKSELR |= 25 << 12; // DIVM2[5:0] = 25, Prescaler for PLL2 - RCC->PLL2DIVR |= (440 - 1) << 0; // DIVN2[8:0] = 440 - 1, Multiplication factor for PLL2 VCO + RCC->PLL2DIVR |= (440 - 1) << 0; // DIVN2[8:0] = 440 - 1, Multiplication factor for PLL2 VCO RCC->PLL2DIVR |= (2 - 1) << 9; // DIVP2[6:0] = 2-1, PLL2 DIVP division factor RCC->PLL2DIVR |= (2 - 1) << 24; // DIVR2[6:0] = 2-1, PLL2 DIVR division factor RCC->PLLCFGR |= 0 << 6; // PLL2RGE[1:0]=0, PLL2 input (ref2_ck) clock range frequency is between 1 and 2 MHz @@ -271,8 +271,8 @@ uint8_t MPU_Set_Protection(uint32_t baseaddr, uint32_t size, uint32_t rnum, uint uint8_t rnr = 0; if ((size % 32) || size == 0) return 1; rnr = MPU_Convert_Bytes_To_POT(size) - 1; - SCB->SHCSR &= ~(1 << 16); //disable MemManage - MPU->CTRL &= ~(1 << 0); //disable MPU + SCB->SHCSR &= ~(1 << 16); //disable MemManage + MPU->CTRL &= ~(1 << 0); //disable MPU MPU->RNR = rnum; MPU->RBAR = baseaddr; tempreg |= 0 << 28; @@ -286,21 +286,21 @@ uint8_t MPU_Set_Protection(uint32_t baseaddr, uint32_t size, uint32_t rnum, uint tempreg |= 1 << 0; MPU->RASR = tempreg; MPU->CTRL = (1 << 2) | (1 << 0); //enable PRIVDEFENA - SCB->SHCSR |= 1 << 16; //enable MemManage + SCB->SHCSR |= 1 << 16; //enable MemManage return 0; } void MPU_Memory_Protection(void) { - MPU_Set_Protection(0x20000000, 128 * 1024, 1, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect DTCM 128k, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x20000000, 128 * 1024, 1, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect DTCM 128k, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0x24000000, 512 * 1024, 2, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect AXI SRAM, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0x30000000, 512 * 1024, 3, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM1~SRAM3, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0x38000000, 64 * 1024, 4, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM4, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x24000000, 512 * 1024, 2, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect AXI SRAM, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x30000000, 512 * 1024, 3, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM1~SRAM3, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x38000000, 64 * 1024, 4, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM4, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0x60000000, 64 * 1024 * 1024, 5, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect LCD FMC 64M, No sharing, no cache, no buffering - MPU_Set_Protection(0XC0000000, 32 * 1024 * 1024, 6, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SDRAM 32M, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0X80000000, 256 * 1024 * 1024, 7, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect NAND FLASH 256M, No sharing, no cache, no buffering + MPU_Set_Protection(0x60000000, 64 * 1024 * 1024, 5, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect LCD FMC 64M, No sharing, no cache, no buffering + MPU_Set_Protection(0XC0000000, 32 * 1024 * 1024, 6, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SDRAM 32M, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0X80000000, 256 * 1024 * 1024, 7, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect NAND FLASH 256M, No sharing, no cache, no buffering } /** diff --git a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h index 1dd047bb9005..808b5588ed5c 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

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

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld index 004714cd6dc0..d12edc719777 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: @@ -184,4 +184,4 @@ SECTIONS } .ARM.attributes 0 : { *(.ARM.attributes) } -} \ No newline at end of file +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c index 56ae00b41b59..6fb5453e58aa 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c @@ -136,7 +136,7 @@ WEAK const PinMap PinMap_PWM[] = { #endif {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM2_CH3 // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 3, 0)}, // TIM2_CH3 -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM5_CH3 #endif #if defined(STM32F103xE) || defined(STM32F103xG) @@ -148,11 +148,11 @@ WEAK const PinMap PinMap_PWM[] = { #else {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM2_CH4 #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM9_CH2 #endif {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM3_CH1 -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM13_CH1 #endif // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM3_CH2 @@ -161,7 +161,7 @@ WEAK const PinMap PinMap_PWM[] = { #else {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 1)}, // TIM1_CH1N #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM14_CH1 #endif {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM1_CH1 @@ -196,10 +196,10 @@ WEAK const PinMap PinMap_PWM[] = { {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM4_CH3 {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM4_CH4 #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM10_CH1 #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM11_CH1 #endif {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 3, 0)}, // TIM2_CH3 @@ -208,11 +208,11 @@ WEAK const PinMap PinMap_PWM[] = { // {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 4, 0)}, // TIM2_CH4 {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM1_CH1N {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 1)}, // TIM1_CH2N -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM12_CH1 #endif {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM1_CH3N -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM12_CH2 #endif {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 1, 0)}, // TIM3_CH1 @@ -249,7 +249,7 @@ WEAK const PinMap PinMap_UART_TX[] = { #if defined(STM32F103xE) || defined(STM32F103xG) {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #endif -#if defined(STM32F103xB) +#ifdef STM32F103xB {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, #endif #if defined(STM32F103xE) || defined(STM32F103xG) @@ -270,7 +270,7 @@ WEAK const PinMap PinMap_UART_RX[] = { #if defined(STM32F103xE) || defined(STM32F103xG) {PC_11, UART4, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, #endif -#if defined(STM32F103xB) +#ifdef STM32F103xB {PC_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, #endif #if defined(STM32F103xE) || defined(STM32F103xG) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/ldscript.ld index cd7503b3a51d..4eb277cb06f4 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/ldscript.ld @@ -23,7 +23,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h index 3440343ffa1e..b684a090e7ba 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h @@ -171,7 +171,7 @@ extern "C" { * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ -#if !defined(USE_SPI_CRC) +#ifndef USE_SPI_CRC #define USE_SPI_CRC 0 #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/ldscript.ld index 6bc577236a9c..a1042aa8d29a 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/ldscript.ld @@ -22,7 +22,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h index e64272745b9d..8e4f248c2e2f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h @@ -139,7 +139,7 @@ extern "C" { #define PIN_SERIAL2_TX PA2 // Extra HAL modules -#if defined(STM32F103xE) +#ifdef STM32F103xE //#define HAL_DAC_MODULE_ENABLED (unused or maybe for the eeprom write?) #define HAL_SD_MODULE_ENABLED #define HAL_SRAM_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c index 339a55916c14..fd429266a358 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c @@ -143,17 +143,17 @@ WEAK const PinMap PinMap_PWM[] = { #else {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM2_CH4 #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM9_CH2 #endif {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM3_CH1 -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM13_CH1 #endif {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 1)}, // TIM1_CH1N //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM3_CH2 //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM8_CH1N -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM14_CH1 #endif {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM1_CH1 @@ -185,11 +185,11 @@ WEAK const PinMap PinMap_PWM[] = { {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM4_CH1 {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM4_CH2 {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM4_CH3 -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM10_CH1 #endif {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM4_CH4 -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM11_CH1 #endif {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 3, 0)}, // TIM2_CH3 @@ -198,11 +198,11 @@ WEAK const PinMap PinMap_PWM[] = { //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 4, 0)}, // TIM2_CH4 {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM1_CH1N {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 1)}, // TIM1_CH2N -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM12_CH1 #endif {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM1_CH3N -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM12_CH2 #endif {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 1, 0)}, // TIM3_CH1 @@ -223,7 +223,7 @@ WEAK const PinMap PinMap_PWM[] = { {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 2, 0)}, // TIM4_CH2 {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 3, 0)}, // TIM4_CH3 {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 4, 0)}, // TIM4_CH4 -#if defined(STM32F103xG) +#ifdef STM32F103xG {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM9_ENABLE, 1, 0)}, // TIM9_CH1 {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM9_ENABLE, 2, 0)}, // TIM9_CH2 #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld index a65b07d61c5f..3013b096073c 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld @@ -23,7 +23,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h index a41247b9b1f6..a9475dbdd912 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

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

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the @@ -81,15 +81,15 @@ extern "C" { * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) -#if defined(USE_STM3210C_EVAL) +#ifndef HSE_VALUE +#ifdef USE_STM3210C_EVAL #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ -#if !defined (HSE_STARTUP_TIMEOUT) +#ifndef HSE_STARTUP_TIMEOUT #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ @@ -98,14 +98,14 @@ extern "C" { * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ -#if !defined (HSI_VALUE) +#ifndef HSI_VALUE #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) +#ifndef LSI_VALUE #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations @@ -114,11 +114,11 @@ extern "C" { * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ -#if !defined (LSE_VALUE) +#ifndef LSE_VALUE #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ -#if !defined (LSE_STARTUP_TIMEOUT) +#ifndef LSE_STARTUP_TIMEOUT #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ @@ -129,7 +129,7 @@ extern "C" { /** * @brief This is the HAL system configuration section */ -#if !defined(VDD_VALUE) +#ifndef VDD_VALUE #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #endif #if !defined (TICK_INT_PRIORITY) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld index cc4b323f763a..cac12da5c2a1 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld @@ -23,7 +23,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PeripheralPins.c new file mode 100644 index 000000000000..b30ccf606b20 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PeripheralPins.c @@ -0,0 +1,256 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +/* + * Automatically generated from STM32F401R(B-C)Tx.xml, STM32F401R(D-E)Tx.xml + * CubeMX DB release 6.0.30 + */ +#if !defined(CUSTOM_PERIPHERAL_PINS) +#include "Arduino.h" +#include "PeripheralPins.h" + +/* ===== + * Notes: + * - The pins mentioned Px_y_ALTz are alternative possibilities which use other + * HW peripheral instances. You can use them the same way as any other "normal" + * pin (i.e. analogWrite(PA7_ALT1, 128);). + * + * - Commented lines are alternative possibilities which are not used per default. + * If you change them, you will have to know what you do + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + {NC, NP, 0} +}; +#endif + +//*** No DAC *** + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)}, + {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +//*** TIM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_TIM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_0_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + {PA_2_ALT2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + {PA_3_ALT2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PB_0_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8_ALT1, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9_ALT1, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {NC, NP, 0} +}; +#endif + +//*** UART *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RTS[] = { + {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_CTS[] = { + {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_3_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_15_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** No CAN *** + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) +WEAK const PinMap PinMap_USB_OTG_FS[] = { + {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif + +//*** SD *** + +#ifdef HAL_SD_MODULE_ENABLED +WEAK const PinMap PinMap_SD[] = { + {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 + {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 + {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 + {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 + {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 + {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + {PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 + {PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + {PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD + {NC, NP, 0} +}; +#endif + +#endif /* !CUSTOM_PERIPHERAL_PINS */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PinNamesVar.h new file mode 100644 index 000000000000..766cc2ca26c2 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PinNamesVar.h @@ -0,0 +1,52 @@ +/* Alternate pin name */ +PA_0_ALT1 = PA_0 | ALT1, +PA_1_ALT1 = PA_1 | ALT1, +PA_2_ALT1 = PA_2 | ALT1, +PA_2_ALT2 = PA_2 | ALT2, +PA_3_ALT1 = PA_3 | ALT1, +PA_3_ALT2 = PA_3 | ALT2, +PA_4_ALT1 = PA_4 | ALT1, +PA_7_ALT1 = PA_7 | ALT1, +PA_15_ALT1 = PA_15 | ALT1, +PB_0_ALT1 = PB_0 | ALT1, +PB_1_ALT1 = PB_1 | ALT1, +PB_3_ALT1 = PB_3 | ALT1, +PB_4_ALT1 = PB_4 | ALT1, +PB_5_ALT1 = PB_5 | ALT1, +PB_8_ALT1 = PB_8 | ALT1, +PB_9_ALT1 = PB_9 | ALT1, + +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif + +/* USB */ +#ifdef USBCON + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, + USB_OTG_FS_ID = PA_10, + USB_OTG_FS_SOF = PA_8, + USB_OTG_FS_VBUS = PA_9, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld new file mode 100644 index 000000000000..c7e67d311e89 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld @@ -0,0 +1,177 @@ +/** + ****************************************************************************** + * @file LinkerScript.ld + * @author Auto-generated by STM32CubeIDE + * @brief Linker script for STM32F401RBTx Device from STM32F4 series + * 128Kbytes FLASH + * 64Kbytes RAM + * + * Set heap size, stack size and stack location according + * to application requirements. + * + * Set memory bank area and size if external memory is used + ****************************************************************************** + * @attention + * + * Copyright (c) 2020 STMicroelectronics. + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ + +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE + FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Sections */ +SECTIONS +{ + /* The startup code into "FLASH" Rom type memory */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data into "FLASH" Rom type memory */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data into "FLASH" Rom type memory */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >FLASH + + .ARM : { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >FLASH + + .preinit_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + /* Used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections into "RAM" Ram type memory */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + *(.RamFunc) /* .RamFunc sections */ + *(.RamFunc*) /* .RamFunc* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + + } >RAM AT> FLASH + + /* Uninitialized data section into "RAM" Ram type memory */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + /* Remove information from the compiler libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.cpp b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.cpp new file mode 100644 index 000000000000..aac11b0b66cf --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.cpp @@ -0,0 +1,223 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ + +#if defined(STM32F401xC) +#include "pins_arduino.h" + +// Digital PinName array +const PinName digitalPin[] = { + PA_0, // D0/A0 + PA_1, // D1/A1 + PA_2, // D2/A2 + PA_3, // D3/A3 + PA_4, // D4/A4 + PA_5, // D5/A5 + PA_6, // D6/A6 + PA_7, // D7/A7 + PA_8, // D8 + PA_9, // D9 + PA_10, // D10 + PA_11, // D11 + PA_12, // D12 + PA_13, // D13 + PA_14, // D14 + PA_15, // D15 + PB_0, // D16/A8 + PB_1, // D17/A9 + PB_2, // D18 + PB_3, // D19 + PB_4, // D20 + PB_5, // D21 + PB_6, // D22 + PB_7, // D23 + PB_8, // D24 + PB_9, // D25 + PB_10, // D26 + PB_12, // D27 + PB_13, // D28 + PB_14, // D29 + PB_15, // D30 + PC_0, // D31/A10 + PC_1, // D32/A11 + PC_2, // D33/A12 + PC_3, // D34/A13 + PC_4, // D35/A14 + PC_5, // D36/A15 + PC_6, // D37 + PC_7, // D38 + PC_8, // D39 + PC_9, // D40 + PC_10, // D41 + PC_11, // D42 + PC_12, // D43 + PC_13, // D44 + PC_14, // D45 + PC_15, // D46 + PD_2, // D47 + PH_0, // D48 + PH_1 // D49 +}; + +// Analog (Ax) pin number array +const uint32_t analogInputPin[] = { + 0, // A0, PA0 + 1, // A1, PA1 + 2, // A2, PA2 + 3, // A3, PA3 + 4, // A4, PA4 + 5, // A5, PA5 + 6, // A6, PA6 + 7, // A7, PA7 + 16, // A8, PB0 + 17, // A9, PB1 + 31, // A10, PC0 + 32, // A11, PC1 + 33, // A12, PC2 + 34, // A13, PC3 + 35, // A14, PC4 + 36 // A15, PC5 +}; + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * @brief Configures the System clock source, PLL Multiplier and Divider factors, + * AHB/APBx prescalers and Flash settings + * @note This function should be called only once the RCC clock configuration + * is reset to the default reset state (done in SystemInit() function). + * @param None + * @retval None + */ + +/******************************************************************************/ +/* PLL (clocked by HSE) used as System clock source */ +/******************************************************************************/ +static uint8_t SetSysClock_PLL_HSE(uint8_t bypass) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); + + // Enable HSE oscillator and activate PLL with HSE as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + if (bypass == 0) { + RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT + } else { + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN + } + + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = HSE_VALUE / 1000000L; // Expects an 8 MHz external clock by default. Redefine HSE_VALUE if not + RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 84 MHz (336 MHz / 4) + RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> OK for USB + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + // Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 84 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 84 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 42 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 84 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { + return 0; // FAIL + } + + /* Output clock on MCO1 pin(PA8) for debugging purpose */ + /* + if (bypass == 0) + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz + else + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz + */ + + return 1; // OK +} + +/******************************************************************************/ +/* PLL (clocked by HSI) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_HSI(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); + + // Enable HSI oscillator and activate PLL with HSI as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSEState = RCC_HSE_OFF; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; + RCC_OscInitStruct.PLL.PLLM = 16; // VCO input clock = 1 MHz (16 MHz / 16) + RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 84 MHz (336 MHz / 4) + RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> freq is ok but not precise enough + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 84 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 84 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 42 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 84 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { + return 0; // FAIL + } + + /* Output clock on MCO1 pin(PA8) for debugging purpose */ + //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz + + return 1; // OK +} + +WEAK void SystemClock_Config(void) +{ + /* 1- If fail try to start with HSE and external xtal */ + if (SetSysClock_PLL_HSE(0) == 0) { + /* 2- Try to start with HSE and external clock */ + if (SetSysClock_PLL_HSE(1) == 0) { + /* 3- If fail start with HSI clock */ + if (SetSysClock_PLL_HSI() == 0) { + Error_Handler(); + } + } + } + /* Output clock on MCO2 pin(PC9) for debugging purpose */ + //HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4); +} + +#ifdef __cplusplus +} +#endif +#endif /* STM32F401xC */ \ No newline at end of file diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.h b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.h new file mode 100644 index 000000000000..37d60d93068a --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.h @@ -0,0 +1,186 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +#pragma once + +/*---------------------------------------------------------------------------- + * STM32 pins number + *----------------------------------------------------------------------------*/ +#define PA0 PIN_A0 +#define PA1 PIN_A1 +#define PA2 PIN_A2 +#define PA3 PIN_A3 +#define PA4 PIN_A4 +#define PA5 PIN_A5 +#define PA6 PIN_A6 +#define PA7 PIN_A7 +#define PA8 8 +#define PA9 9 +#define PA10 10 +#define PA11 11 +#define PA12 12 +#define PA13 13 +#define PA14 14 +#define PA15 15 +#define PB0 PIN_A8 +#define PB1 PIN_A9 +#define PB2 18 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 26 +#define PB12 27 +#define PB13 28 +#define PB14 29 +#define PB15 30 +#define PC0 PIN_A10 +#define PC1 PIN_A11 +#define PC2 PIN_A12 +#define PC3 PIN_A13 +#define PC4 PIN_A14 +#define PC5 PIN_A15 +#define PC6 37 +#define PC7 38 +#define PC8 39 +#define PC9 40 +#define PC10 41 +#define PC11 42 +#define PC12 43 +#define PC13 44 +#define PC14 45 +#define PC15 46 +#define PD2 47 +#define PH0 48 +#define PH1 49 + +// Alternate pins number +#define PA0_ALT1 (PA0 | ALT1) +#define PA1_ALT1 (PA1 | ALT1) +#define PA2_ALT1 (PA2 | ALT1) +#define PA2_ALT2 (PA2 | ALT2) +#define PA3_ALT1 (PA3 | ALT1) +#define PA3_ALT2 (PA3 | ALT2) +#define PA4_ALT1 (PA4 | ALT1) +#define PA7_ALT1 (PA7 | ALT1) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB1_ALT1 (PB1 | ALT1) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) + +#define NUM_DIGITAL_PINS 50 +#define NUM_ANALOG_INPUTS 16 +#define NUM_ANALOG_FIRST 192 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PNUM_NOT_DEFINED +#endif + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PNUM_NOT_DEFINED +#endif + +// SPI definitions +#ifndef PIN_SPI_SS + #define PIN_SPI_SS PA4 +#endif +#ifndef PIN_SPI_SS1 + #define PIN_SPI_SS1 PA15 +#endif +#ifndef PIN_SPI_SS2 + #define PIN_SPI_SS2 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_SS3 + #define PIN_SPI_SS3 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA7 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA5 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PB3 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PB10 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM10 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM11 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 2 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA3 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA2 +#endif + +// Extra HAL modules +#if !defined(HAL_SD_MODULE_DISABLED) + #define HAL_SD_MODULE_ENABLED +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + #define SERIAL_PORT_HARDWARE Serial + #endif +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h index 58e9646b57f5..ea5e2cc70934 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

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

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/ldscript.ld index 68b65973226f..9357c4b52c17 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PeripheralPins.c new file mode 100644 index 000000000000..d0905853a9a9 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PeripheralPins.c @@ -0,0 +1,433 @@ +/* + ******************************************************************************* + * Copyright (c) 2016, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +// ===== +// Note: Commented lines are alternative possibilities which are not used per default. +// If you change them, you will have to know what you do +// ===== + + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +const PinMap PinMap_ADC[] = { + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + {PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 TH_0 + {PF_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14 TH_1 + {PF_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15 TH_2 + {PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 TH_3 + {PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 EXP_13 + {PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 PT100 + {NC, NP, 0} + + // {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + // {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + // {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + // {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + // {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + // {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + // {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + // {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + // {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + // {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + // {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + //{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + // {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + // {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + // {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + // {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + // {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + // {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + // {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + // {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + // {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + // {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + // {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + // {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + // {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + // {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + // {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + // {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + // {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + // {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + // {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + // {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + // {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +const PinMap PinMap_DAC[] = { + // {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + // {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 - LD2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SDA[] = { + // {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + // {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + // {PC_7, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, + // {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PC_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SCL[] = { + // {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + // {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + // {PC_6, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +const PinMap PinMap_PWM[] = { + {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 BED + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 HEATER0 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 HEATER1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 HEATER2 + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 HEATER3 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 FAN0 + {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 FAN1 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 FAN2 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 FAN3 + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 FAN4 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 FAN5 + + /** + * Unused by specifications on Octopus. + * Uncomment the corresponding line if you want to have HardwarePWM on some pins. + * WARNING: check timers' usage first to avoid conflicts. + * If you don't know what you're doing leave things as they are or you WILL break something (including hardware) + * If you alter this section DO NOT report bugs to Marlin team since they are most likely caused by you. Thank you. + */ + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 BLTOUCH is a "servo" + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 BLTOUCH is a "servo" + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 + //{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + //{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + //{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + //144 pins mcu, 114 gpio + //{PF_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PF_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + //{PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + + //176 pins mcu, 140 gpio + //{PH_10, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PH_6, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + //{PH_11, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{PI_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PI_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_TX[] = { + // {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {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)}, + // {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RX[] = { + // {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {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)}, + // {PC_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RTS[] = { + // {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_CTS[] = { + // {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PC_1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + // {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +const PinMap PinMap_CAN_RD[] = { + // {PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_CAN_MODULE_ENABLED +const PinMap PinMap_CAN_TD[] = { + // {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; +#endif + +//*** ETHERNET *** + +//*** No Ethernet *** + +//*** QUADSPI *** + +#ifdef HAL_QSPI_MODULE_ENABLED +const PinMap PinMap_QUADSPI[] = { + // {PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 + // {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK + // {PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS + // {PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 + // {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 + // {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK2_NCS + {NC, NP, 0} +}; +#endif + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +const PinMap PinMap_USB_OTG_FS[] = { + // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_OTG_FS_VBUS + // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; + +const PinMap PinMap_USB_OTG_HS[] = { + //{PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID + //{PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM + {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP + + /*#error "USB in HS mode isn't supported by the board" + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 + {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 + {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 + {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 + {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 + {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP + {PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR + {PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT + */ + {NC, NP, 0} +}; + + +#ifdef HAL_SD_MODULE_ENABLED +WEAK const PinMap PinMap_SD[] = { + // {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 + // {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 + // {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 + // {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 + {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 + {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + {PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 + {PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + {PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD + {NC, NP, 0} +}; +#endif +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PinNamesVar.h new file mode 100644 index 000000000000..bff3f2134987 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PinNamesVar.h @@ -0,0 +1,30 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, /* SYS_WKUP0 */ +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/hal_conf_extra.h new file mode 100644 index 000000000000..d62c510095c9 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/hal_conf_extra.h @@ -0,0 +1,53 @@ +#pragma once + +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED // Needed for Endstop (and other external) Interrupts +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +//#define HAL_RTC_MODULE_ENABLED // Real Time Clock...do we use it? +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +//#define HAL_UART_MODULE_ENABLED // by default +//#define HAL_PCD_MODULE_ENABLED // Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) +#define HAL_SD_MODULE_ENABLED + +//#undef HAL_SD_MODULE_ENABLED +#undef HAL_DAC_MODULE_ENABLED +#undef HAL_FLASH_MODULE_ENABLED +#undef HAL_CAN_MODULE_ENABLED +#undef HAL_CAN_LEGACY_MODULE_ENABLED +#undef HAL_CEC_MODULE_ENABLED +#undef HAL_CRYP_MODULE_ENABLED +#undef HAL_DCMI_MODULE_ENABLED +#undef HAL_DMA2D_MODULE_ENABLED +#undef HAL_ETH_MODULE_ENABLED +#undef HAL_NAND_MODULE_ENABLED +#undef HAL_NOR_MODULE_ENABLED +#undef HAL_PCCARD_MODULE_ENABLED +#undef HAL_SRAM_MODULE_ENABLED +#undef HAL_SDRAM_MODULE_ENABLED +#undef HAL_HASH_MODULE_ENABLED +#undef HAL_SMBUS_MODULE_ENABLED +#undef HAL_I2S_MODULE_ENABLED +#undef HAL_IWDG_MODULE_ENABLED +#undef HAL_LTDC_MODULE_ENABLED +#undef HAL_DSI_MODULE_ENABLED +#undef HAL_QSPI_MODULE_ENABLED +#undef HAL_RNG_MODULE_ENABLED +#undef HAL_SAI_MODULE_ENABLED +#undef HAL_IRDA_MODULE_ENABLED +#undef HAL_SMARTCARD_MODULE_ENABLED +#undef HAL_WWDG_MODULE_ENABLED +//#undef HAL_HCD_MODULE_ENABLED +#undef HAL_FMPI2C_MODULE_ENABLED +#undef HAL_SPDIFRX_MODULE_ENABLED +#undef HAL_DFSDM_MODULE_ENABLED +#undef HAL_LPTIM_MODULE_ENABLED +#undef HAL_MMC_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/ldscript.ld new file mode 100644 index 000000000000..0edf17b8e815 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/ldscript.ld @@ -0,0 +1,209 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F407ZETx Device with +** 512KByte FLASH, 64KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2014 Ac6

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +MEMORY_ARRAY (rw) : ORIGIN = 0x10000000, LENGTH = 0x144 +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text ALIGN(4): + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata ALIGN(4) : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + + _siccmram = LOADADDR(.ccmram); + + /* CCM-RAM section + * + * IMPORTANT NOTE! + * If initialized variables will be placed in this section, + * the startup code needs to be modified to copy the init-values. + */ + .ccmram : + { + . = ALIGN(4); + _sccmram = .; /* create a global symbol at ccmram start */ + *(.ccmram) + *(.ccmram*) + + . = ALIGN(4); + _eccmram = .; /* create a global symbol at ccmram end */ + } >CCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } + ExtRAMData : {*(.ExtRAMData)} >MEMORY_ARRAY +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.cpp new file mode 100644 index 000000000000..7b5fdd0b712e --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.cpp @@ -0,0 +1,228 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +const PinName digitalPin[] = { + PA_0, //D0 + PA_1, //D1 + PA_2, //D2 + PA_3, //D3 + PA_4, //D4 + PA_5, //D5 + PA_6, //D6 + PA_7, //D7 + PA_8, //D8 + PA_9, //D9 + PA_10, //D10 + PA_11, //D11 + PA_12, //D12 + PA_13, //D13 + PA_14, //D14 + PA_15, //D15 + PB_0, //D16 + PB_1, //D17 + PB_2, //D18 + PB_3, //D19 + PB_4, //D20 + PB_5, //D21 + PB_6, //D22 + PB_7, //D23 + PB_8, //D24 + PB_9, //D25 + PB_10, //D26 + PB_11, //D27 + PB_12, //D28 + PB_13, //D29 + PB_14, //D30 + PB_15, //D31 + PC_0, //D32 + PC_1, //D33 + PC_2, //D34 + PC_3, //D35 + PC_4, //D36 + PC_5, //D37 + PC_6, //D38 + PC_7, //D39 + PC_8, //D40 + PC_9, //D41 + PC_10, //D42 + PC_11, //D43 + PC_12, //D44 + PC_13, //D45 + PC_14, //D46 + PC_15, //D47 + PD_0, //D48 + PD_1, //D49 + PD_2, //D50 + PD_3, //D51 + PD_4, //D52 + PD_5, //D53 + PD_6, //D54 + PD_7, //D55 + PD_8, //D56 + PD_9, //D57 + PD_10, //D58 + PD_11, //D59 + PD_12, //D60 + PD_13, //D61 + PD_14, //D62 + PD_15, //D63 + PE_0, //D64 + PE_1, //D65 + PE_2, //D66 + PE_3, //D67 + PE_4, //D68 + PE_5, //D69 + PE_6, //D70 + PE_7, //D71 + PE_8, //D72 + PE_9, //D73 + PE_10, //D74 + PE_11, //D75 + PE_12, //D76 + PE_13, //D77 + PE_14, //D78 + PE_15, //D79 + PF_0, //D80 + PF_1, //D81 + PF_2, //D82 + PF_3, //D83 + PF_4, //D84 + PF_5, //D85 + PF_6, //D86 + PF_7, //D87 + PF_8, //D88 + PF_9, //D89 + PF_10, //D90 + PF_11, //D91 + PF_12, //D92 + PF_13, //D93 + PF_14, //D94 + PF_15, //D95 + PG_0, //D96 + PG_1, //D97 + PG_2, //D98 + PG_3, //D99 + PG_4, //D100 + PG_5, //D101 + PG_6, //D102 + PG_7, //D103 + PG_8, //D104 + PG_9, //D105 + PG_10, //D106 + PG_11, //D107 + PG_12, //D108 + PG_13, //D109 + PG_14, //D110 + PG_15, //D111 + + //Duplicated ADC Pins + PA_3, //D112/A0 + PA_4, //D113/A1 + PC_0, //D114/A2 + PC_1, //D115/A3 + PC_2, //D116/A4 + PC_3, //D117/A5 + PC_4, //D118/A6 + PF_3, //D119/A16 - 1:FSMC_A3 2:ADC3_IN9 + PF_4, //D120/A17 - 1:FSMC_A4 2:ADC3_IN14 + PF_5, //D121/A18 - 1:FSMC_A5 2:ADC3_IN15 + PF_6, //D122/A19 - 1:TIM10_CH1 2:ADC3_IN4 + PF_7, //D123/A20 - 1:TIM11_CH1 2:ADC3_IN5 + PF_8, //D124/A20 - 1:TIM11_CH1 2:ADC3_IN6 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 168000000 + * HCLK(Hz) = 168000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 4 + * APB2 Prescaler = 2 + * HSE Frequency(Hz) = 8000000 + * PLL_M = 8 + * PLL_N = 336 + * PLL_P = 2 + * PLL_Q = 7 + * VDD(V) = 3.3 + * Main regulator output voltage = Scale1 mode + * Flash Latency(WS) = 5 + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + /* Initialization Error */ + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) + { + /* Initialization Error */ + } +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.h new file mode 100644 index 000000000000..b8e4b9667e80 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.h @@ -0,0 +1,216 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PA0 0 //D0 +#define PA1 1 //D1 +#define PA2 2 //D2 +#define PA3 3 //D3 +#define PA4 4 //D4 +#define PA5 5 //D5 +#define PA6 6 //D6 +#define PA7 7 //D7 +#define PA8 8 //D8 +#define PA9 9 //D9 +#define PA10 10 //D10 +#define PA11 11 //D11 +#define PA12 12 //D12 +#define PA13 13 //D13 +#define PA14 14 //D14 +#define PA15 15 //D15 +#define PB0 16 //D16 +#define PB1 17 //D17 +#define PB2 18 //D18 +#define PB3 19 //D19 +#define PB4 20 //D20 +#define PB5 21 //D21 +#define PB6 22 //D22 +#define PB7 23 //D23 +#define PB8 24 //D24 +#define PB9 25 //D25 +#define PB10 26 //D26 +#define PB11 27 //D27 +#define PB12 28 //D28 +#define PB13 29 //D29 +#define PB14 30 //D30 +#define PB15 31 //D31 +#define PC0 32 //D32 +#define PC1 33 //D33 +#define PC2 34 //D34 +#define PC3 35 //D35 +#define PC4 36 //D36 +#define PC5 37 //D37 +#define PC6 38 //D38 +#define PC7 39 //D39 +#define PC8 40 //D40 +#define PC9 41 //D41 +#define PC10 42 //D42 +#define PC11 43 //D43 +#define PC12 44 //D44 +#define PC13 45 //D45 +#define PC14 46 //D46 +#define PC15 47 //D47 +#define PD0 48 //D48 +#define PD1 49 //D49 +#define PD2 50 //D50 +#define PD3 51 //D51 +#define PD4 52 //D52 +#define PD5 53 //D53 +#define PD6 54 //D54 +#define PD7 55 //D55 +#define PD8 56 //D56 +#define PD9 57 //D57 +#define PD10 58 //D58 +#define PD11 59 //D59 +#define PD12 60 //D60 +#define PD13 61 //D61 +#define PD14 62 //D62 +#define PD15 63 //D63 +#define PE0 64 //D64 +#define PE1 65 //D65 +#define PE2 66 //D66 +#define PE3 67 //D67 +#define PE4 68 //D68 +#define PE5 69 //D69 +#define PE6 70 //D70 +#define PE7 71 //D71 +#define PE8 72 //D72 +#define PE9 73 //D73 +#define PE10 74 //D74 +#define PE11 75 //D75 +#define PE12 76 //D76 +#define PE13 77 //D77 +#define PE14 78 //D78 +#define PE15 79 //D79 +#define PF0 80 //D64 +#define PF1 81 //D65 +#define PF2 82 //D66 +#define PF3 83 //D67 +#define PF4 84 //D68 +#define PF5 85 //D69 +#define PF6 86 //D70 +#define PF7 87 //D71 +#define PF8 88 //D72 +#define PF9 89 //D73 +#define PF10 90 //D74 +#define PF11 91 //D75 +#define PF12 92 //D76 +#define PF13 93 //D77 +#define PF14 94 //D78 +#define PF15 95 //D79 +#define PG0 96 //D64 +#define PG1 97 //D65 +#define PG2 98 //D66 +#define PG3 99 //D67 +#define PG4 100 //D68 +#define PG5 101 //D69 +#define PG6 102 //D70 +#define PG7 103 //D71 +#define PG8 104 //D72 +#define PG9 105 //D73 +#define PG10 106 //D74 +#define PG11 107 //D75 +#define PG12 108 //D76 +#define PG13 109 //D77 +#define PG14 110 //D78 +#define PG15 111 //D79 + +// This must be a literal with the same value as PEND +#define NUM_DIGITAL_PINS 112 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 13 +#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS + +//#define ADC_RESOLUTION 12 + +// PWM resolution +//#define PWM_RESOLUTION 12 +#define PWM_FREQUENCY 1000 // >= 20 Khz => inaudible noise for fans +#define PWM_MAX_DUTY_CYCLE 255 + +// SPI Definitions +#define PIN_SPI_SS PA4 +#define PIN_SPI_MOSI PA7 +#define PIN_SPI_MISO PA6 +#define PIN_SPI_SCK PA5 + +// I2C Definitions +#define PIN_WIRE_SDA PB9 +#define PIN_WIRE_SCL PB8 + +// Timer Definitions +// Do not use timer used by PWM pin. See PinMap_PWM. +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file + +// UART Definitions +//#define SERIAL_UART_INSTANCE 1 // Connected to EXP3 header +/* Enable Serial 3 */ +#define HAVE_HWSERIAL1 +#define HAVE_HWSERIAL3 + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +/* HAL configuration */ +#define HSE_VALUE 8000000U + +#define FLASH_PAGE_SIZE (4U * 1024U) + +#ifdef __cplusplus +} // extern "C" +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE_OPEN Serial +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld index a375232d5981..7d5307717c1e 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld @@ -20,7 +20,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PeripheralPins.c new file mode 100644 index 000000000000..4514efe7e4c6 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PeripheralPins.c @@ -0,0 +1,359 @@ +/* + ******************************************************************************* + * Copyright (c) 2016, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +// ===== +// Note: Commented lines are alternative possibilities which are not used per default. +// If you change them, you will have to know what you do +// ===== + + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +const PinMap PinMap_ADC[] = { + // {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + // {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + // {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + // {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + // {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + // {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + // {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + // {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + // {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + // {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + // {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + // {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + // {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + // {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + // {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + // {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + // {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + // {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + // {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + // {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + // {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + // {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + // {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + // {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + // {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + // {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + // {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + // {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + // {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + // {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + // {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + // {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + // {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +const PinMap PinMap_DAC[] = { + // {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + // {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 - LD2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SDA[] = { + // {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + // {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + // {PC_7, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, + // {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PC_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SCL[] = { + // {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + // {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + // {PC_6, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +const PinMap PinMap_PWM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - STLink Tx + // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - STLink Tx + // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - STLink Tx + // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - STLink Rx + // {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - STLink Rx + // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - STLink Rx + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + // {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // Fan0, TIM8_CH2N + // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // Fan1, TIM8_CH3N + {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // Fan2, TIM2_CH4 + {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // E0 Heater, TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // E1 Heater, TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // LED G, TIM3_CH2 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // LED R, TIM4_CH1 + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // LED B, TIM4_CH2 + // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + // {PB_8, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + // {PB_9, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 + // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + // {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + // {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 + // {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_TX[] = { + // {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RX[] = { + // {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PC_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RTS[] = { + // {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_CTS[] = { + // {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PC_1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + // {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +const PinMap PinMap_CAN_RD[] = { + // {PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_CAN_MODULE_ENABLED +const PinMap PinMap_CAN_TD[] = { + // {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; +#endif + +//*** ETHERNET *** + +//*** No Ethernet *** + +//*** QUADSPI *** + +#ifdef HAL_QSPI_MODULE_ENABLED +const PinMap PinMap_QUADSPI[] = { + // {PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 + // {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK + // {PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS + // {PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 + // {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 + // {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK2_NCS + {NC, NP, 0} +}; +#endif + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +const PinMap PinMap_USB_OTG_FS[] = { + // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_OTG_FS_VBUS + // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif + +#ifdef HAL_PCD_MODULE_ENABLED +const PinMap PinMap_USB_OTG_HS[] = { + {NC, NP, 0} +}; +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PinNamesVar.h new file mode 100644 index 000000000000..bff3f2134987 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PinNamesVar.h @@ -0,0 +1,30 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, /* SYS_WKUP0 */ +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h new file mode 100644 index 000000000000..c23d30ce88a9 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h @@ -0,0 +1,505 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf.h + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

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

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_CUSTOM +#define __STM32F4xx_HAL_CONF_CUSTOM + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ + /** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +#define HAL_CRC_MODULE_ENABLED +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +#define HAL_DMA_MODULE_ENABLED +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +#define HAL_FLASH_MODULE_ENABLED +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +#define HAL_SRAM_MODULE_ENABLED //YSZ-WORK +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +#define HAL_PWR_MODULE_ENABLED +/* #define HAL_QSPI_MODULE_ENABLED */ +#define HAL_RCC_MODULE_ENABLED +/* #define HAL_RNG_MODULE_ENABLED */ +#define HAL_RTC_MODULE_ENABLED +/* #define HAL_SAI_MODULE_ENABLED */ +#define HAL_SD_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +/* #define HAL_UART_MODULE_ENABLED */ +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +#ifndef HAL_PCD_MODULE_ENABLED + #define HAL_PCD_MODULE_ENABLED //Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) +#endif +#define HAL_HCD_MODULE_ENABLED +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#ifndef HSE_VALUE +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#ifndef HSE_STARTUP_TIMEOUT +#if STM32_TYPE == 4 +#define HSE_STARTUP_TIMEOUT 0xFFFFu +#else +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#ifndef HSI_VALUE +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#ifndef LSI_VALUE +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#ifndef LSE_VALUE +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#ifndef LSE_STARTUP_TIMEOUT +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#ifndef EXTERNAL_CLOCK_VALUE +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U +#endif +#if !defined (INSTRUCTION_CACHE_ENABLE) +#define INSTRUCTION_CACHE_ENABLE 1U +#endif +#if !defined (DATA_CACHE_ENABLE) +#define DATA_CACHE_ENABLE 1U +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ +#ifndef USE_SPI_CRC +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f4xx_hal_gpio.h" +#include "stm32f4xx_hal_gpio_ex.h" //YSZ-WORK +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED +#include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED +#include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_FSMC_MODULE_ENABLED +#include "stm32f4xx_ll_fmc.h" +#endif + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_CUSTOM_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld new file mode 100644 index 000000000000..20a9f1db1bb0 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld @@ -0,0 +1,188 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F446RETx Device with +** 512KByte FLASH, 128KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2014 Ac6

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x2000; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text ALIGN(4): + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(8); /*YSZ-WORK:4->8*/ + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4);/*YSZ-WORK:8->4*/ + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4);/*YSZ-WORK:8->4*/ + } >RAM + + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp new file mode 100644 index 000000000000..2d94ee763a42 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp @@ -0,0 +1,320 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +const PinName digitalPin[] = { + PA_0, //D0 + PA_1, //D1 + PA_2, //D2 + PA_3, //D3 + PA_4, //D4 + PA_5, //D5 + PA_6, //D6 + PA_7, //D7 + PA_8, //D8 + PA_9, //D9 + PA_10, //D10 + PA_11, //D11 + PA_12, //D12 + PA_13, //D13 + PA_14, //D14 + PA_15, //D15 + PB_0, //D16 + PB_1, //D17 + PB_2, //D18 + PB_3, //D19 + PB_4, //D20 + PB_5, //D21 + PB_6, //D22 + PB_7, //D23 + PB_8, //D24 + PB_9, //D25 + PB_10, //D26 + PB_11, //D27 + PB_12, //D28 + PB_13, //D29 + PB_14, //D30 + PB_15, //D31 + PC_0, //D32 + PC_1, //D33 + PC_2, //D34 + PC_3, //D35 + PC_4, //D36 + PC_5, //D37 + PC_6, //D38 + PC_7, //D39 + PC_8, //D40 + PC_9, //D41 + PC_10, //D42 + PC_11, //D43 + PC_12, //D44 + PC_13, //D45 + PC_14, //D46 + PC_15, //D47 + PD_0, //D48 + PD_1, //D49 + PD_2, //D50 + PD_3, //D51 + PD_4, //D52 + PD_5, //D53 + PD_6, //D54 + PD_7, //D55 + PD_8, //D56 + PD_9, //D57 + PD_10, //D58 + PD_11, //D59 + PD_12, //D60 + PD_13, //D61 + PD_14, //D62 + PD_15, //D63 + PE_0, //D64 + PE_1, //D65 + PE_2, //D66 + PE_3, //D67 + PE_4, //D68 + PE_5, //D69 + PE_6, //D70 + PE_7, //D71 + PE_8, //D72 + PE_9, //D73 + PE_10, //D74 + PE_11, //D75 + PE_12, //D76 + PE_13, //D77 + PE_14, //D78 + PE_15, //D79 + PF_0, //D80 + PF_1, //D81 + PF_2, //D82 + PF_3, //D83 + PF_4, //D84 + PF_5, //D85 + PF_6, //D86 + PF_7, //D87 + PF_8, //D88 + PF_9, //D89 + PF_10, //D90 + PF_11, //D91 + PF_12, //D92 + PF_13, //D93 + PF_14, //D94 + PF_15, //D95 + PG_0, //D96 + PG_1, //D97 + PG_2, //D98 + PG_3, //D99 + PG_4, //D100 + PG_5, //D101 + PG_6, //D102 + PG_7, //D103 + PG_8, //D104 + PG_9, //D105 + PG_10, //D106 + PG_11, //D107 + PG_12, //D108 + PG_13, //D109 + PG_14, //D110 + PG_15, //D111 + PH_0, //D112 + PH_1, //D113 + PH_2, //D114 + PH_3, //D115 + PH_4, //D116 + PH_5, //D117 + PH_6, //D118 + PH_7, //D119 + PH_8, //D120 + PH_9, //D121 + PH_10, //D122 + PH_11, //D123 + PH_12, //D124 + PH_13, //D125 + PH_14, //D126 + PH_15, //D127 + + //Duplicated ADC Pins + PC_3, //A0 T0 D128 + PC_0, //A1 T1 D129 + PC_2, //A2 BED D130 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t myvar[] = {1,2,3,4,5,6,7,8}; +void myshow(int fre, int times) // YSZ-WORK +{ + uint32_t index = 10; + RCC->AHB1ENR |= 1 << 6; // port G clock + GPIOG->MODER &= ~(3UL << 2 * index); // clear old mode + GPIOG->MODER |= 1 << 2 * index; // mode is output + GPIOG->OSPEEDR &= ~(3UL << 2 * index) // Clear old output speed + GPIOG->OSPEEDR |= 2 << 2 * index; // Set output speed + GPIOG->OTYPER &= ~(1UL << index) // clear old output + GPIOG->OTYPER |= 0 << index; // Set the output mode to push-pull + GPIOG->PUPDR &= ~(3 << 2 * index) // Clear the original settings first + GPIOG->PUPDR |= 1 << 2 * index; // Set new up and down + while (times != 0) { + GPIOG->BSRR = 1UL << index; + for (int i = 0; i < fre; i++) + for (int j = 0; j < 1000000; j++) __NOP(); + GPIOG->BSRR = 1UL << (index + 16); + for (int i = 0; i < fre; i++) + for (int j = 0; j < 1000000; j++) __NOP(); + if (times > 0) times--; + } +} + +HAL_StatusTypeDef SDMMC_IsProgramming(SDIO_TypeDef *SDIOx,uint32_t RCA) +{ + HAL_SD_CardStateTypeDef CardState; + volatile uint32_t respR1 = 0, status = 0; + SDIO_CmdInitTypeDef sdmmc_cmdinit; + do { + sdmmc_cmdinit.Argument = RCA << 16; + sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEND_STATUS; + sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; + sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; + sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; + SDIO_SendCommand(SDIOx,&sdmmc_cmdinit); // send CMD13 + do status = SDIOx->STA; + while (!(status & ((1 << 0) | (1 << 6) | (1 << 2)))); // wait for the operation to complete + if (status & (1 << 0)) { // CRC check failed + SDIOx->ICR |= 1 << 0; // clear error flag + return HAL_ERROR; + } + if (status & (1 << 2)) { // command timed out + SDIOx->ICR |= 1 << 2; // clear error flag + return HAL_ERROR; + } + if (SDIOx->RESPCMD != SDMMC_CMD_SEND_STATUS) return HAL_ERROR; + SDIOx->ICR = 0X5FF; // clear all tags + respR1 = SDIOx->RESP1; + CardState = (respR1 >> 9) & 0x0000000F; + } while ((CardState == HAL_SD_CARD_RECEIVING) || (CardState == HAL_SD_CARD_SENDING) || (CardState == HAL_SD_CARD_PROGRAMMING)); + return HAL_OK; +} + +void debugStr(const char *str) { + while (*str) { + while ((USART1->SR & 0x40) == 0); + USART1->DR = *str++; + } +} + +/** + * @brief System Clock Configuration + * The system Clock is configured as follows: + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 168000000/120000000/180000000 + * HCLK(Hz) = 168000000/120000000/180000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 4 + * APB2 Prescaler = 2 + * HSE Frequency(Hz) = 8000000 + * PLL_M = 8/4/8 + * PLL_N = 336/120/360 + * PLL_P = 2 + * PLL_Q = 7/5/7 + * VDD(V) = 3.3 + * Main regulator output voltage = Scale1 mode + * Flash Latency(WS) = 5 + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; + HAL_StatusTypeDef ret = HAL_OK; + + __HAL_FLASH_INSTRUCTION_CACHE_ENABLE(); + __HAL_FLASH_DATA_CACHE_ENABLE(); + __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); + HAL_RCC_DeInit(); + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = 2; + RCC_OscInitStruct.PLL.PLLQ = 7; + RCC_OscInitStruct.PLL.PLLR = 2; + ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); + + if (ret != HAL_OK) myshow(10,-1); + HAL_PWREx_EnableOverDrive(); + + /* Select PLLSAI output as USB clock source */ + PeriphClkInitStruct.PLLSAI.PLLSAIM = 8; + PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; + PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV4; + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48 | RCC_PERIPHCLK_SDIO; + PeriphClkInitStruct.Clk48ClockSelection = RCC_CK48CLKSOURCE_PLLSAIP; + PeriphClkInitStruct.SdioClockSelection = RCC_SDIOCLKSOURCE_CLK48; // SDIO Clock Mux + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); + if (ret != HAL_OK) myshow(10,-1); + + SystemCoreClockUpdate(); + /* Configure the Systick interrupt time */ + HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000); + + /* Configure the Systick */ + HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); + + /* SysTick_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); + __enable_irq(); // Turn on the interrupt here because it is turned off in the bootloader +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h new file mode 100644 index 000000000000..082be9403ed5 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h @@ -0,0 +1,243 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +extern unsigned long myvar[]; +void myshow(int fre, int times); +void debugStr(const char *str); + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PA0 0x00 +#define PA1 0x01 +#define PA2 0x02 +#define PA3 0x03 +#define PA4 0x04 +#define PA5 0x05 +#define PA6 0x06 +#define PA7 0x07 +#define PA8 0x08 +#define PA9 0x09 +#define PA10 0x0A +#define PA11 0x0B +#define PA12 0x0C +#define PA13 0x0D +#define PA14 0x0E +#define PA15 0x0F + +#define PB0 0x10 +#define PB1 0x11 +#define PB2 0x12 +#define PB3 0x13 +#define PB4 0x14 +#define PB5 0x15 +#define PB6 0x16 +#define PB7 0x17 // 36 pins (F103T) +#define PB8 0x18 +#define PB9 0x19 +#define PB10 0x1A +#define PB11 0x1B +#define PB12 0x1C +#define PB13 0x1D +#define PB14 0x1E +#define PB15 0x1F + +#define PC0 0x20 +#define PC1 0x21 +#define PC2 0x22 +#define PC3 0x23 +#define PC4 0x24 +#define PC5 0x25 +#define PC6 0x26 +#define PC7 0x27 +#define PC8 0x28 +#define PC9 0x29 +#define PC10 0x2A +#define PC11 0x2B +#define PC12 0x2C +#define PC13 0x2D +#define PC14 0x2E +#define PC15 0x2F + +#define PD0 0x30 +#define PD1 0x31 +#define PD2 0x32 // 64 pins (F103R) +#define PD3 0x33 +#define PD4 0x34 +#define PD5 0x35 +#define PD6 0x36 +#define PD7 0x37 +#define PD8 0x38 +#define PD9 0x39 +#define PD10 0x3A +#define PD11 0x3B +#define PD12 0x3C +#define PD13 0x3D +#define PD14 0x3E +#define PD15 0x3F + +#define PE0 0x40 +#define PE1 0x41 +#define PE2 0x42 +#define PE3 0x43 +#define PE4 0x44 +#define PE5 0x45 +#define PE6 0x46 +#define PE7 0x47 +#define PE8 0x48 +#define PE9 0x49 +#define PE10 0x4A +#define PE11 0x4B +#define PE12 0x4C +#define PE13 0x4D +#define PE14 0x4E +#define PE15 0x4F // 100 pins (F446V) + +#define PF0 0x50 +#define PF1 0x51 +#define PF2 0x52 +#define PF3 0x53 +#define PF4 0x54 +#define PF5 0x55 +#define PF6 0x56 +#define PF7 0x57 +#define PF8 0x58 +#define PF9 0x59 +#define PF10 0x5A +#define PF11 0x5B +#define PF12 0x5C +#define PF13 0x5D +#define PF14 0x5E +#define PF15 0x5F + +#define PG0 0x60 +#define PG1 0x61 +#define PG2 0x62 +#define PG3 0x63 +#define PG4 0x64 +#define PG5 0x65 +#define PG6 0x66 +#define PG7 0x67 +#define PG8 0x68 +#define PG9 0x69 +#define PG10 0x6A +#define PG11 0x6B +#define PG12 0x6C +#define PG13 0x6D +#define PG14 0x6E +#define PG15 0x6F + +#define PH0 0x70 +#define PH1 0x71 +#define PH2 0x72 +#define PH3 0x73 +#define PH4 0x74 +#define PH5 0x75 +#define PH6 0x76 +#define PH7 0x77 +#define PH8 0x78 +#define PH9 0x79 +#define PH10 0x7A +#define PH11 0x7B +#define PH12 0x7C +#define PH13 0x7D +#define PH14 0x7E +#define PH15 0x7F // 144 pins (F446Z) + +// This must be a literal with the same value as PEND +#define NUM_DIGITAL_PINS 0x80 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 3 +#define NUM_ANALOG_FIRST 128 + +// PWM resolution +// #define PWM_RESOLUTION 12 +#define PWM_FREQUENCY 20000 // >= 20 Khz => inaudible noise for fans +#define PWM_MAX_DUTY_CYCLE 255 + +// SPI Definitions +// #define PIN_SPI_SS PG15 +// #define PIN_SPI_MOSI PB5 +// #define PIN_SPI_MISO PB4 +// #define PIN_SPI_SCK PB3 + +// I2C Definitions +#define PIN_WIRE_SDA PB9 +#define PIN_WIRE_SCL PB8 +#define PIN_I2C_WP PB7 +#define EEPROM_DEVICE_ADDRESS 0x50 + +// Timer Definitions +// Do not use timer used by PWM pin. See PinMap_PWM. +#define TIMER_TONE TIM8 +#define TIMER_SERVO TIM5 +#define TIMER_SERIAL TIM7 + +// UART Definitions +//#define SERIAL_UART_INSTANCE 1 // Connected to EXP3 header +/* Enable Serial 3 */ +#define HAVE_HWSERIAL1 +// #define HAVE_HWSERIAL3 + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +/* HAL configuration */ +#define HSE_VALUE 8000000U + +#define FLASH_PAGE_SIZE (4U * 1024U) + +#ifdef __cplusplus +} // extern "C" +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE_OPEN Serial +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h index 952fe3c5b881..f2f4ed3e96b5 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h @@ -8,8 +8,8 @@ ****************************************************************************** * @attention * - *

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

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the @@ -91,11 +91,11 @@ * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) +#ifndef HSE_VALUE #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ -#if !defined (HSE_STARTUP_TIMEOUT) +#ifndef HSE_STARTUP_TIMEOUT #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ @@ -104,14 +104,14 @@ * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ -#if !defined (HSI_VALUE) +#ifndef HSI_VALUE #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) +#ifndef LSI_VALUE #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations @@ -119,11 +119,11 @@ /** * @brief External Low Speed oscillator (LSE) value. */ -#if !defined (LSE_VALUE) +#ifndef LSE_VALUE #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ -#if !defined (LSE_STARTUP_TIMEOUT) +#ifndef LSE_STARTUP_TIMEOUT #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ @@ -132,7 +132,7 @@ * This value is used by the I2S HAL module to compute the I2S clock source * frequency, this source is inserted directly through I2S_CKIN pad. */ -#if !defined (EXTERNAL_CLOCK_VALUE) +#ifndef EXTERNAL_CLOCK_VALUE #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld index 8b38135a2a51..df1ed1581a39 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld @@ -19,7 +19,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h index ba145d058cb3..0b78be627fc5 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h @@ -27,98 +27,98 @@ extern "C" { * Pins *----------------------------------------------------------------------------*/ -// | DIGITAL | ANALOG IN | ANALOG OUT | UART/USART | TWI | SPI | SPECIAL | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PA0 PIN_A0 // | 0 | A0 (ADC1) | | UART4_TX | | | | -#define PA1 PIN_A1 // | 1 | A1 (ADC1) | | UART4_RX | | | | -#define PA2 PIN_A2 // | 2 | A2 (ADC1) | | USART2_TX | | | | -#define PA3 PIN_A3 // | 3 | A3 (ADC1) | | USART2_RX | | | | -#define PA4 PIN_A4 // | 4 | A4 (ADC1) | DAC_OUT1 | | | SPI1_SS, (SPI3_SS) | | -#define PA5 PIN_A5 // | 5 | A5 (ADC1) | DAC_OUT2 | | | SPI1_SCK | | -#define PA6 PIN_A6 // | 6 | A6 (ADC1) | | | | SPI1_MISO | | -#define PA7 PIN_A7 // | 7 | A7 (ADC1) | | | | SPI1_MOSI | | -#define PA8 8 // | 8 | | | | TWI3_SCL | | | -#define PA9 9 // | 9 | | | USART1_TX | | | | -#define PA10 10 // | 10 | | | USART1_RX | | | | -#define PA11 11 // | 11 | | | | | | | -#define PA12 12 // | 12 | | | | | | | -#define PA13 13 // | 13 | | | | | | SWD_SWDIO | -#define PA14 14 // | 14 | | | | | | SWD_SWCLK | -#define PA15 15 // | 15 | | | | | SPI3_SS, (SPI1_SS) | | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PB0 PIN_A8 // | 16 | A8 (ADC1) | | | | | | -#define PB1 PIN_A9 // | 17 | A9 (ADC1) | | | | | | -#define PB2 18 // | 18 | | | | | | BOOT1 | -#define PB3 19 // | 19 | | | | | SPI3_SCK, (SPI1_SCK) | | -#define PB4 20 // | 20 | | | | | SPI3_MISO, (SPI1_MISO) | | -#define PB5 21 // | 21 | | | | | SPI3_MOSI, (SPI1_MOSI) | | -#define PB6 22 // | 22 | | | USART1_TX | TWI1_SCL | | | -#define PB7 23 // | 23 | | | USART1_RX | TWI1_SDA | | | -#define PB8 24 // | 24 | | | | TWI1_SCL | | | -#define PB9 25 // | 25 | | | | TWI1_SDA | SPI2_SS | | -#define PB10 26 // | 26 | | | USART3_TX, (UART4_TX) | TWI2_SCL | SPI2_SCK | | -#define PB11 27 // | 27 | | | USART3_RX | TWI2_SDA | | | -#define PB12 28 // | 28 | | | | | SPI2_SS | | -#define PB13 29 // | 29 | | | | | SPI2_SCK | | -#define PB14 30 // | 30 | | | | | SPI2_MISO | | -#define PB15 31 // | 31 | | | | | SPI2_MOSI | | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PC0 PIN_A10 // | 32 | A10 (ADC1) | | | | | | -#define PC1 PIN_A11 // | 33 | A11 (ADC1) | | | | | | -#define PC2 PIN_A12 // | 34 | A12 (ADC1) | | | | SPI2_MISO | | -#define PC3 PIN_A13 // | 35 | A13 (ADC1) | | | | SPI2_MOSI | | -#define PC4 PIN_A14 // | 36 | A14 (ADC1) | | | | | | -#define PC5 PIN_A15 // | 37 | A15 (ADC1) | | USART3_RX | | | | -#define PC6 38 // | 38 | | | USART6_TX | | | | -#define PC7 39 // | 39 | | | USART6_RX | | | | -#define PC8 40 // | 40 | | | | | | | -#define PC9 41 // | 41 | | | USART3_TX | TWI3_SDA | | | -#define PC10 42 // | 42 | | | | | SPI3_SCK | | -#define PC11 43 // | 43 | | | USART3_RX, (UART4_RX) | | SPI3_MISO | | -#define PC12 44 // | 44 | | | UART5_TX | | SPI3_MOSI | | -#define PC13 45 // | 45 | | | | | | | -#define PC14 46 // | 46 | | | | | | OSC32_IN | -#define PC15 47 // | 47 | | | | | | OSC32_OUT | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PD0 48 // | 48 | | | | | | | -#define PD1 49 // | 49 | | | | | | | -#define PD2 50 // | 50 | | | UART5_RX | | | | -#define PD3 51 // | 51 | | | | | | | -#define PD4 52 // | 52 | | | | | | | -#define PD5 53 // | 53 | | | USART2_TX | | | | -#define PD6 54 // | 54 | | | USART2_RX | | | | -#define PD7 55 // | 55 | | | | | | | -#define PD8 56 // | 56 | | | USART3_TX | | | | -#define PD9 57 // | 57 | | | USART3_RX | | | | -#define PD10 58 // | 58 | | | | | | | -#define PD11 59 // | 59 | | | | | | | -#define PD12 60 // | 60 | | | | | | | -#define PD13 61 // | 61 | | | | | | | -#define PD14 62 // | 62 | | | | | | | -#define PD15 63 // | 63 | | | | | | | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PE0 64 // | 64 | | | | | | | -#define PE1 65 // | 65 | | | | | | | -#define PE2 66 // | 66 | | | | | | | -#define PE3 67 // | 67 | | | | | | | -#define PE4 68 // | 68 | | | | | | | -#define PE5 69 // | 69 | | | | | | | -#define PE6 70 // | 70 | | | | | | | -#define PE7 71 // | 71 | | | | | | | -#define PE8 72 // | 72 | | | | | | | -#define PE9 73 // | 73 | | | | | | | -#define PE10 74 // | 74 | | | | | | | -#define PE11 75 // | 75 | | | | | | | -#define PE12 76 // | 76 | | | | | | | -#define PE13 77 // | 77 | | | | | | | -#define PE14 78 // | 78 | | | | | | | -#define PE15 79 // | 79 | | | | | | | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PH0 80 // | 80 | | | | | | OSC_IN | -#define PH1 81 // | 81 | | | | | | OSC_OUT | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| - -/// This must be a literal + // | DIGITAL | ANALOG IN | ANALOG OUT | UART/USART | TWI | SPI | SPECIAL | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PA0 PIN_A0 // | 0 | A0 (ADC1) | | UART4_TX | | | | +#define PA1 PIN_A1 // | 1 | A1 (ADC1) | | UART4_RX | | | | +#define PA2 PIN_A2 // | 2 | A2 (ADC1) | | USART2_TX | | | | +#define PA3 PIN_A3 // | 3 | A3 (ADC1) | | USART2_RX | | | | +#define PA4 PIN_A4 // | 4 | A4 (ADC1) | DAC_OUT1 | | | SPI1_SS, (SPI3_SS) | | +#define PA5 PIN_A5 // | 5 | A5 (ADC1) | DAC_OUT2 | | | SPI1_SCK | | +#define PA6 PIN_A6 // | 6 | A6 (ADC1) | | | | SPI1_MISO | | +#define PA7 PIN_A7 // | 7 | A7 (ADC1) | | | | SPI1_MOSI | | +#define PA8 8 // | 8 | | | | TWI3_SCL | | | +#define PA9 9 // | 9 | | | USART1_TX | | | | +#define PA10 10 // | 10 | | | USART1_RX | | | | +#define PA11 11 // | 11 | | | | | | | +#define PA12 12 // | 12 | | | | | | | +#define PA13 13 // | 13 | | | | | | SWD_SWDIO | +#define PA14 14 // | 14 | | | | | | SWD_SWCLK | +#define PA15 15 // | 15 | | | | | SPI3_SS, (SPI1_SS) | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PB0 PIN_A8 // | 16 | A8 (ADC1) | | | | | | +#define PB1 PIN_A9 // | 17 | A9 (ADC1) | | | | | | +#define PB2 18 // | 18 | | | | | | BOOT1 | +#define PB3 19 // | 19 | | | | | SPI3_SCK, (SPI1_SCK) | | +#define PB4 20 // | 20 | | | | | SPI3_MISO, (SPI1_MISO) | | +#define PB5 21 // | 21 | | | | | SPI3_MOSI, (SPI1_MOSI) | | +#define PB6 22 // | 22 | | | USART1_TX | TWI1_SCL | | | +#define PB7 23 // | 23 | | | USART1_RX | TWI1_SDA | | | +#define PB8 24 // | 24 | | | | TWI1_SCL | | | +#define PB9 25 // | 25 | | | | TWI1_SDA | SPI2_SS | | +#define PB10 26 // | 26 | | | USART3_TX, (UART4_TX) | TWI2_SCL | SPI2_SCK | | +#define PB11 27 // | 27 | | | USART3_RX | TWI2_SDA | | | +#define PB12 28 // | 28 | | | | | SPI2_SS | | +#define PB13 29 // | 29 | | | | | SPI2_SCK | | +#define PB14 30 // | 30 | | | | | SPI2_MISO | | +#define PB15 31 // | 31 | | | | | SPI2_MOSI | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PC0 PIN_A10 // | 32 | A10 (ADC1) | | | | | | +#define PC1 PIN_A11 // | 33 | A11 (ADC1) | | | | | | +#define PC2 PIN_A12 // | 34 | A12 (ADC1) | | | | SPI2_MISO | | +#define PC3 PIN_A13 // | 35 | A13 (ADC1) | | | | SPI2_MOSI | | +#define PC4 PIN_A14 // | 36 | A14 (ADC1) | | | | | | +#define PC5 PIN_A15 // | 37 | A15 (ADC1) | | USART3_RX | | | | +#define PC6 38 // | 38 | | | USART6_TX | | | | +#define PC7 39 // | 39 | | | USART6_RX | | | | +#define PC8 40 // | 40 | | | | | | | +#define PC9 41 // | 41 | | | USART3_TX | TWI3_SDA | | | +#define PC10 42 // | 42 | | | | | SPI3_SCK | | +#define PC11 43 // | 43 | | | USART3_RX, (UART4_RX) | | SPI3_MISO | | +#define PC12 44 // | 44 | | | UART5_TX | | SPI3_MOSI | | +#define PC13 45 // | 45 | | | | | | | +#define PC14 46 // | 46 | | | | | | OSC32_IN | +#define PC15 47 // | 47 | | | | | | OSC32_OUT | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PD0 48 // | 48 | | | | | | | +#define PD1 49 // | 49 | | | | | | | +#define PD2 50 // | 50 | | | UART5_RX | | | | +#define PD3 51 // | 51 | | | | | | | +#define PD4 52 // | 52 | | | | | | | +#define PD5 53 // | 53 | | | USART2_TX | | | | +#define PD6 54 // | 54 | | | USART2_RX | | | | +#define PD7 55 // | 55 | | | | | | | +#define PD8 56 // | 56 | | | USART3_TX | | | | +#define PD9 57 // | 57 | | | USART3_RX | | | | +#define PD10 58 // | 58 | | | | | | | +#define PD11 59 // | 59 | | | | | | | +#define PD12 60 // | 60 | | | | | | | +#define PD13 61 // | 61 | | | | | | | +#define PD14 62 // | 62 | | | | | | | +#define PD15 63 // | 63 | | | | | | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PE0 64 // | 64 | | | | | | | +#define PE1 65 // | 65 | | | | | | | +#define PE2 66 // | 66 | | | | | | | +#define PE3 67 // | 67 | | | | | | | +#define PE4 68 // | 68 | | | | | | | +#define PE5 69 // | 69 | | | | | | | +#define PE6 70 // | 70 | | | | | | | +#define PE7 71 // | 71 | | | | | | | +#define PE8 72 // | 72 | | | | | | | +#define PE9 73 // | 73 | | | | | | | +#define PE10 74 // | 74 | | | | | | | +#define PE11 75 // | 75 | | | | | | | +#define PE12 76 // | 76 | | | | | | | +#define PE13 77 // | 77 | | | | | | | +#define PE14 78 // | 78 | | | | | | | +#define PE15 79 // | 79 | | | | | | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PH0 80 // | 80 | | | | | | OSC_IN | +#define PH1 81 // | 81 | | | | | | OSC_OUT | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| + +// This must be a literal #define NUM_DIGITAL_PINS 82 #define NUM_ANALOG_INPUTS 16 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld index d644d49beb1d..cd7ccef85ff3 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h index 2ff2fd686ea4..fb3d21c6acb3 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

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

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld index eaaff196cd0d..1ded9f2a3e13 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: @@ -184,4 +184,4 @@ SECTIONS } .ARM.attributes 0 : { *(.ARM.attributes) } -} \ No newline at end of file +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld index 900ef0639101..5db15287845f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c new file mode 100644 index 000000000000..5c7c301f8218 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c @@ -0,0 +1,399 @@ +/* + ******************************************************************************* + * Copyright (c) 2019, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + * Automatically generated from STM32F407Z(E-G)Tx.xml + */ +#include +#include + +/* ===== + * Note: Commented lines are alternative possibilities which are not used per default. + * If you change them, you will have to know what you do + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + //{PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + //{PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + //{PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + //{PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + //{PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + //{PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 LCD RX + //{PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + //{PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 LCD TX + //{PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + //{PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + //{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + //{PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + //{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + //{PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + //{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + //{PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + //{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + //{PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + //{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + //{PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + //{PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + //{PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + //{PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + //{PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + //{PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + //{PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + //{PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + //{PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + //{PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + //{PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + //{PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + //{PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + //{PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 + //{PF_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14 + //{PF_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15 + //{PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 + //{PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 + //{PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 + {PF_9, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_IN7 + {PF_10, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_IN8 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +WEAK const PinMap PinMap_DAC[] = { + //{PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + //{PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PF_0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PF_1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_PWM[] = { + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 HEATER_4_PIN + // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N HEATER_1_PIN + // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 HEATER_0_PIN + //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 + //{PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + // {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + // {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 HEATER_3_PIN + // {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 FAN3 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 HEATER_2_PIN + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 FAN4 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 FAN2_PIN + //{PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N FAN_PIN + {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 FAN1_PIN + {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N HEATER_BED_PIN + //{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + //{PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_RX[] = { + //{PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_RTS[] = { + //{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PG_8, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PG_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_CTS[] = { + //{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PG_13, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PG_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + //{PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PD_0, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_CAN_TD[] = { + //{PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PD_1, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {NC, NP, 0} +}; +#endif + +//*** ETHERNET *** + +#ifdef HAL_ETH_MODULE_ENABLED +WEAK const PinMap PinMap_Ethernet[] = { + /* + {PA_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS + {PA_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_REF_CLK|ETH_RX_CLK + {PA_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDIO + {PA_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_COL + {PA_7, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS_DV|ETH_RX_DV + {PB_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD2 + {PB_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD3 + {PB_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT + {PB_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 + {PB_10, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_ER + {PB_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN + {PB_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 + {PB_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + {PC_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDC + {PC_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2 + {PC_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_CLK + {PC_4, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD0 + {PC_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD1 + {PE_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 + {PG_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT + {PG_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN + {PG_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 + {PG_14, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + {NC, NP, 0} + */ +}; +#endif + +//*** No QUADSPI *** + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_FS[] = { + //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_USB_OTG_HS[] = { + /* + #ifdef USE_USB_HS_IN_FS + {PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM + {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP + #else + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 + {PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_CK + {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 + {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 + {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 + {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 + {PB_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D4 + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 + {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP + {PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR + {PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT + #endif // USE_USB_HS_IN_FS + */ + {NC, NP, 0} +}; +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PinNamesVar.h new file mode 100644 index 000000000000..b4bb9d45f8ac --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PinNamesVar.h @@ -0,0 +1,50 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON + USB_OTG_FS_SOF = PA_8, + USB_OTG_FS_VBUS = PA_9, + USB_OTG_FS_ID = PA_10, + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, + USB_OTG_HS_ULPI_D0 = PA_3, + USB_OTG_HS_SOF = PA_4, + USB_OTG_HS_ULPI_CK = PA_5, + USB_OTG_HS_ULPI_D1 = PB_0, + USB_OTG_HS_ULPI_D2 = PB_1, + USB_OTG_HS_ULPI_D7 = PB_5, + USB_OTG_HS_ULPI_D3 = PB_10, + USB_OTG_HS_ULPI_D4 = PB_11, + USB_OTG_HS_ID = PB_12, + USB_OTG_HS_ULPI_D5 = PB_12, + USB_OTG_HS_ULPI_D6 = PB_13, + USB_OTG_HS_VBUS = PB_13, + USB_OTG_HS_DM = PB_14, + USB_OTG_HS_DP = PB_15, + USB_OTG_HS_ULPI_STP = PC_0, + USB_OTG_HS_ULPI_DIR = PC_2, + USB_OTG_HS_ULPI_NXT = PC_3, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld new file mode 100644 index 000000000000..f7e09b8ef0e7 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld @@ -0,0 +1,204 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F407ZGTx Device with +** 1024KByte FLASH, 128KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +** Copyright (c) 2014 Ac6 +** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20020000; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200;; /* required amount of heap */ +_Min_Stack_Size = 0x400;; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 1024K +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text ALIGN(4): + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata ALIGN(4): + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + _siccmram = LOADADDR(.ccmram); + + /* CCM-RAM section + * + * IMPORTANT NOTE! + * If initialized variables will be placed in this section, + * the startup code needs to be modified to copy the init-values. + */ + .ccmram : + { + . = ALIGN(4); + _sccmram = .; /* create a global symbol at ccmram start */ + *(.ccmram) + *(.ccmram*) + + . = ALIGN(4); + _eccmram = .; /* create a global symbol at ccmram end */ + } >CCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >RAM + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.cpp new file mode 100644 index 000000000000..1c7aedd9ac9c --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.cpp @@ -0,0 +1,212 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +const PinName digitalPin[] = { +PA_1, +PA_2, +PA_3, +PA_4, +PA_5, +PA_6, +PA_7, +PA_8, +PA_9, +PA_10, +PA_11, +PA_12, +PA_13, +PA_14, +PA_15, +PB_0, +PB_1, +PB_2, +PB_3, +PB_4, +PB_5, +PB_6, +PB_7, +PB_8, +PB_9, +PB_10, +PB_11, +PB_12, +PB_13, +PB_14, +PB_15, +PC_2, +PC_3, +PC_4, +PC_5, +PC_6, +PC_7, +PC_8, +PC_9, +PC_10, +PC_11, +PC_12, +PC_13, +PC_14, +PC_15, +PD_0, +PD_1, +PD_2, +PD_3, +PD_4, +PD_5, +PD_6, +PD_7, +PD_8, +PD_9, +PD_10, +PD_11, +PD_12, +PD_13, +PD_14, +PD_15, +PE_0, +PE_1, +PE_11, +PE_3, +PE_4, +PE_5, +PE_6, +PE_7, +PE_8, +PE_9, +PE_10, +PE_2, +PE_12, +PE_13, +PE_14, +PE_15, +PF_0, +PF_1, +PF_2, +PF_6, +PF_7, +PF_8, +PF_9, +PF_11, +PF_12, +PF_13, +PF_14, +PF_15, +PG_0, +PG_1, +PG_2, +PG_3, +PG_4, +PG_5, +PG_6, +PG_7, +PG_8, +PG_9, +PG_10, +PG_11, +PG_12, +PG_13, +PG_14, +PG_15, +PH_0, +PH_1, +PA_0, +PC_1, +PC_0, +PF_10, +PF_5, +PF_4, +PF_3, +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /**Configure the main internal regulator output voltage + */ + __HAL_RCC_PWR_CLK_ENABLE(); + + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /**Initializes the CPU, AHB and APB busses clocks + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + _Error_Handler(__FILE__, __LINE__); + } + + /**Initializes the CPU, AHB and APB busses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK + | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { + _Error_Handler(__FILE__, __LINE__); + } +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.h new file mode 100644 index 000000000000..727c0d07d832 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.h @@ -0,0 +1,237 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + + +#define PA1 0 +#define PA2 1 +#define PA3 2 +#define PA4 3 +#define PA5 4 +#define PA6 5 +#define PA7 6 +#define PA8 7 +#define PA9 8 +#define PA10 9 +#define PA11 10 +#define PA12 11 +#define PA13 12 +#define PA14 13 +#define PA15 14 +#define PB0 15 +#define PB1 16 +#define PB2 17 +#define PB3 18 +#define PB4 19 +#define PB5 20 +#define PB6 21 +#define PB7 22 +#define PB8 23 +#define PB9 24 +#define PB10 25 +#define PB11 26 +#define PB12 27 +#define PB13 28 +#define PB14 29 +#define PB15 30 +#define PC2 31 +#define PC3 32 +#define PC4 33 +#define PC5 34 +#define PC6 35 +#define PC7 36 +#define PC8 37 +#define PC9 38 +#define PC10 39 +#define PC11 40 +#define PC12 41 +#define PC13 42 +#define PC14 43 +#define PC15 44 +#define PD0 45 +#define PD1 46 +#define PD2 47 +#define PD3 48 +#define PD4 49 +#define PD5 50 +#define PD6 51 +#define PD7 52 +#define PD8 53 +#define PD9 54 +#define PD10 55 +#define PD11 56 +#define PD12 57 +#define PD13 58 +#define PD14 59 +#define PD15 60 +#define PE0 61 +#define PE1 62 +#define PE11 63 +#define PE3 64 +#define PE4 65 +#define PE5 66 +#define PE6 67 +#define PE7 68 +#define PE8 69 +#define PE9 70 +#define PE10 71 +#define PE2 72 +#define PE12 73 +#define PE13 74 +#define PE14 75 +#define PE15 76 +#define PF0 77 +#define PF1 78 +#define PF2 79 +#define PF6 80 +#define PF7 81 +#define PF8 82 +#define PF9 83 +#define PF11 84 +#define PF12 85 +#define PF13 86 +#define PF14 87 +#define PF15 88 +#define PG0 89 +#define PG1 90 +#define PG2 91 +#define PG3 92 +#define PG4 93 +#define PG5 94 +#define PG6 95 +#define PG7 96 +#define PG8 97 +#define PG9 98 +#define PG10 99 +#define PG11 100 +#define PG12 101 +#define PG13 102 +#define PG14 103 +#define PG15 104 +#define PH0 105 +#define PH1 106 +#define PA0 107 +#define PC1 108 +#define PC0 109 +#define PF10 110 +#define PF5 111 +#define PF4 112 +#define PF3 113 + +// This must be a literal +#define NUM_DIGITAL_PINS 114 +// This must be a literal with a value less than or equal to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 7 +#define NUM_ANALOG_FIRST 107 + + +// Below SPI and I2C definitions already done in the core +// Could be redefined here if differs from the default one +// SPI Definitions +#define PIN_SPI_SS PA4 +#define PIN_SPI_MOSI PA7 +#define PIN_SPI_MISO PA6 +#define PIN_SPI_SCK PA5 + +// I2C Definitions +#define PIN_WIRE_SDA PF0 +#define PIN_WIRE_SCL PF1 + +// Timer Definitions +// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c +#define TIMER_TONE TIM2 +#define TIMER_SERVO TIM5 +#define TIMER_SERIAL TIM7 + +// UART Definitions +#define ENABLE_HWSERIAL1 +#define ENABLE_HWSERIAL2 +// Define here Serial instance number to map on Serial generic name +//#define SERIAL_UART_INSTANCE 1 //1 for Serial = Serial1 (USART1) +// DEBUG_UART could be redefined to print on another instance than 'Serial' +//#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3 +// DEBUG_UART baudrate, default: 9600 if not defined +//#define DEBUG_UART_BAUDRATE x +// DEBUG_UART Tx pin name, default: the first one found in PinMap_UART_TX for DEBUG_UART +//#define DEBUG_PINNAME_TX PX_n // PinName used for TX + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +// Optional PIN_SERIALn_RX and PIN_SERIALn_TX where 'n' is the U(S)ART number +// Used when user instantiate a hardware Serial using its peripheral name. +// Example: HardwareSerial mySerial(USART3); +// will use PIN_SERIAL3_RX and PIN_SERIAL3_TX if defined. +#define PIN_SERIAL1_RX PA10 +#define PIN_SERIAL1_TX PA9 +#define PIN_SERIAL2_RX PA3 +#define PIN_SERIAL2_TX PA2 + +/* HAL configuration */ +#define HSE_VALUE 8000000U + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial2 +#endif + diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c index 0abfc70700d8..eb95de1495f7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c @@ -15,7 +15,7 @@ * STM32G0C1R(C-E)IxN.xml, STM32G0C1R(C-E)TxN.xml * CubeMX DB release 6.0.30 */ -#if !defined(CUSTOM_PERIPHERAL_PINS) +#ifndef CUSTOM_PERIPHERAL_PINS #include "Arduino.h" #include "PeripheralPins.h" diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld index 3b619b6a97e8..4e0e997341c4 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld @@ -13,8 +13,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2020 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp index 8af7150dc781..d18509f35f71 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp @@ -11,7 +11,7 @@ ******************************************************************************* */ -#if defined(STM32G0B1xx) +#ifdef STM32G0B1xx #include "pins_arduino.h" // Digital PinName array diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h index 9cb3d45a0d95..6a26baff45db 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h @@ -124,6 +124,7 @@ #define NUM_DIGITAL_PINS 62 #define NUM_REMAP_PINS 2 #define NUM_ANALOG_INPUTS 16 +#define NUM_ANALOG_FIRST PA0 // SPI definitions #ifndef PIN_SPI_SS diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c index 49c4cbb87aa9..d5ccda9f9bc8 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c @@ -17,7 +17,7 @@ * STM32H753VIHx.xml, STM32H753VITx.xml * CubeMX DB release 6.0.30 */ -#if !defined(CUSTOM_PERIPHERAL_PINS) +#ifndef CUSTOM_PERIPHERAL_PINS #include "Arduino.h" #include "PeripheralPins.h" diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld index 7d248a268283..5f439f3f8e1f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld @@ -26,7 +26,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp index 7813f8860e58..814149f6c776 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp @@ -10,7 +10,7 @@ * ******************************************************************************* */ -#if defined(STM32H743xx) +#ifdef STM32H743xx #include "pins_arduino.h" // Digital PinName array diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h index 35cf65dee9b9..c4635c4b1f64 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h @@ -226,16 +226,16 @@ #endif // Extra HAL modules -#if !defined(HAL_DAC_MODULE_DISABLED) +#ifndef HAL_DAC_MODULE_DISABLED #define HAL_DAC_MODULE_ENABLED #endif -#if !defined(HAL_ETH_MODULE_DISABLED) +#ifndef HAL_ETH_MODULE_DISABLED #define HAL_ETH_MODULE_ENABLED #endif -#if !defined(HAL_QSPI_MODULE_DISABLED) +#ifndef HAL_QSPI_MODULE_DISABLED #define HAL_QSPI_MODULE_ENABLED #endif -#if !defined(HAL_SD_MODULE_DISABLED) +#ifndef HAL_SD_MODULE_DISABLED #define HAL_SD_MODULE_ENABLED #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c new file mode 100644 index 000000000000..11f5cc5afc4f --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c @@ -0,0 +1,169 @@ +/* + ******************************************************************************* + * Copyright (c) 2016, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +// ===== +// Note: Commented lines are alternative possibilities which are not used per default. +// If you change them, you will have to know what you do +// ===== + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 THBED + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 TH0 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 TH1 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 TH2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_I2C_SCL[] = { + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +// Some pins can perform PWM from more than one timer. These were selected to utilize as many channels as +// possible from timers which were already dedicated to PWM output. + +// TIM1 = HEATER0, HEATER1, [SERVO] +// TIM2 = FAN1, FAN2, [BEEPER] +// TIM4 = HEATER_BED +// TIM5 = HEATER2, FAN0 + +WEAK const PinMap PinMap_PWM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 Fan2 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 Fan1 + {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 Fan0 + {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 HE2 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 Servo + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N HE1 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N HE0 + {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 BEEPER + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 HOTBED + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_RX[] = { + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_RTS[] = { + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_CTS[] = { + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; + +const PinMap PinMap_CAN_TD[] = { + {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; +#endif + +//*** USB *** + +// If anyone for some unfathomable reason want to run gcode from Marlin's USB-C drive at 12Mbps - you can +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_FS[] = { + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_USB_OTG_HS[] = { + {NC, NP, 0} +}; +#endif + + diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PinNamesVar.h new file mode 100644 index 000000000000..bff3f2134987 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PinNamesVar.h @@ -0,0 +1,30 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, /* SYS_WKUP0 */ +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h new file mode 100644 index 000000000000..2ca9df2efcdf --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h @@ -0,0 +1,496 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_LEGACY_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED // Needed for Endstop (and other external) Interrupts +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +// #define HAL_UART_MODULE_ENABLED +// #define HAL_PCD_MODULE_ENABLED + +// #define HAL_CAN_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED +//#define HAL_DCMI_MODULE_ENABLED +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED +//#define HAL_FLASH_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED +//#define HAL_SMBUS_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED +//#define HAL_RTC_MODULE_ENABLED +//#define HAL_SAI_MODULE_ENABLED +//#define HAL_SD_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#ifndef HSE_VALUE + #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#ifndef HSE_STARTUP_TIMEOUT + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#ifndef HSI_VALUE + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#ifndef LSI_VALUE + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#ifndef LSE_VALUE + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#ifndef LSE_STARTUP_TIMEOUT + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#ifndef EXTERNAL_CLOCK_VALUE + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +// #define USE_FULL_ASSERT 1U + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848 PHY Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ +#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ +#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ + +#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ +#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ + +#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ +#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ + +#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ +#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld new file mode 100644 index 000000000000..df1ed1581a39 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld @@ -0,0 +1,203 @@ +/* +****************************************************************************** +** +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F4x7Vx Device with +** 512/1024KByte FLASH, 192KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed “as is,” without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +** Copyright (c) 2019 STMicroelectronics +** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of STMicroelectronics nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + _siccmram = LOADADDR(.ccmram); + + /* CCM-RAM section + * + * IMPORTANT NOTE! + * If initialized variables will be placed in this section, + * the startup code needs to be modified to copy the init-values. + */ + .ccmram : + { + . = ALIGN(4); + _sccmram = .; /* create a global symbol at ccmram start */ + *(.ccmram) + *(.ccmram*) + + . = ALIGN(4); + _eccmram = .; /* create a global symbol at ccmram end */ + } >CCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.cpp new file mode 100644 index 000000000000..00c7a90db313 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.cpp @@ -0,0 +1,288 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +// Digital PinName array +const PinName digitalPin[] = { + PA_0, // Digital pin 0 + PA_1, // Digital pin 1 + PA_2, // Digital pin 2 + PA_3, // Digital pin 3 + PA_4, // Digital pin 4 + PA_5, // Digital pin 5 + PA_6, // Digital pin 6 + PA_7, // Digital pin 7 + PA_8, // Digital pin 8 + PA_9, // Digital pin 9 + PA_10, // Digital pin 10 + PA_11, // Digital pin 11 + PA_12, // Digital pin 12 + PA_13, // Digital pin 13 + PA_14, // Digital pin 14 + PA_15, // Digital pin 15 + + PB_0, // Digital pin 16 + PB_1, // Digital pin 17 + PB_2, // Digital pin 18 + PB_3, // Digital pin 19 + PB_4, // Digital pin 20 + PB_5, // Digital pin 21 + PB_6, // Digital pin 22 + PB_7, // Digital pin 23 + PB_8, // Digital pin 24 + PB_9, // Digital pin 25 + PB_10, // Digital pin 26 + PB_11, // Digital pin 27 + PB_12, // Digital pin 28 + PB_13, // Digital pin 29 + PB_14, // Digital pin 30 + PB_15, // Digital pin 31 + + PC_0, // Digital pin 32 + PC_1, // Digital pin 33 + PC_2, // Digital pin 34 + PC_3, // Digital pin 35 + PC_4, // Digital pin 36 + PC_5, // Digital pin 37 + PC_6, // Digital pin 38 + PC_7, // Digital pin 39 + PC_8, // Digital pin 40 + PC_9, // Digital pin 41 + PC_10, // Digital pin 42 + PC_11, // Digital pin 43 + PC_12, // Digital pin 44 + PC_13, // Digital pin 45 + PC_14, // Digital pin 46 + PC_15, // Digital pin 47 + + PD_0, // Digital pin 48 + PD_1, // Digital pin 49 + PD_2, // Digital pin 50 + PD_3, // Digital pin 51 + PD_4, // Digital pin 52 + PD_5, // Digital pin 53 + PD_6, // Digital pin 54 + PD_7, // Digital pin 55 + PD_8, // Digital pin 56 + PD_9, // Digital pin 57 + PD_10, // Digital pin 58 + PD_11, // Digital pin 59 + PD_12, // Digital pin 60 + PD_13, // Digital pin 61 + PD_14, // Digital pin 62 + PD_15, // Digital pin 63 + + PE_0, // Digital pin 64 + PE_1, // Digital pin 65 + PE_2, // Digital pin 66 + PE_3, // Digital pin 67 + PE_4, // Digital pin 68 + PE_5, // Digital pin 69 + PE_6, // Digital pin 70 + PE_7, // Digital pin 71 + PE_8, // Digital pin 72 + PE_9, // Digital pin 73 + PE_10, // Digital pin 74 + PE_11, // Digital pin 75 + PE_12, // Digital pin 76 + PE_13, // Digital pin 77 + PE_14, // Digital pin 78 + PE_15, // Digital pin 79 + + PH_0, // Digital pin 80, used by the external oscillator + PH_1 // Digital pin 81, used by the external oscillator +}; + +// Analog (Ax) pin number array +const uint32_t analogInputPin[] = { + 0, // A0, PA0 + 1, // A1, PA1 + 2, // A2, PA2 + 3, // A3, PA3 + 4, // A4, PA4 + 5, // A5, PA5 + 6, // A6, PA6 + 7, // A7, PA7 + 16, // A8, PB0 + 17, // A9, PB1 + 32, // A10, PC0 + 33, // A11, PC1 + 34, // A12, PC2 + 35, // A13, PC3 + 36, // A14, PC4 + 37 // A15, PC5 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * @brief Configures the System clock source, PLL Multiplier and Divider factors, + * AHB/APBx prescalers and Flash settings + * @note This function should be called only once the RCC clock configuration + * is reset to the default reset state (done in SystemInit() function). + * @param None + * @retval None + */ + +/******************************************************************************/ +/* PLL (clocked by HSE) used as System clock source */ +/******************************************************************************/ +static uint8_t SetSysClock_PLL_HSE(uint8_t bypass) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + // Enable HSE oscillator and activate PLL with HSE as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + if (bypass == 0) { + RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT + } else { + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN + } + + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = HSE_VALUE / 1000000L; // Expects an 8 MHz external clock by default. Redefine HSE_VALUE if not + RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // PLLCLK = 168 MHz (336 MHz / 2) + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + // Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 168 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 42 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 84 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { + return 0; // FAIL + } + + /* Output clock on MCO1 pin(PA8) for debugging purpose */ + /* + if (bypass == 0) + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz + else + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz + */ + + return 1; // OK +} + +/******************************************************************************/ +/* PLL (clocked by HSI) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_HSI(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + // Enable HSI oscillator and activate PLL with HSI as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSEState = RCC_HSE_OFF; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; + RCC_OscInitStruct.PLL.PLLM = 16; // VCO input clock = 1 MHz (16 MHz / 16) + RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // PLLCLK = 168 MHz (336 MHz / 2) + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 168 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 42 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 84 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { + return 0; // FAIL + } + + /* Output clock on MCO1 pin(PA8) for debugging purpose */ + //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz + + return 1; // OK +} + +WEAK void SystemClock_Config(void) +{ + /* 1- If fail try to start with HSE and external xtal */ + if (SetSysClock_PLL_HSE(0) == 0) { + /* 2- Try to start with HSE and external clock */ + if (SetSysClock_PLL_HSE(1) == 0) { + /* 3- If fail start with HSI clock */ + if (SetSysClock_PLL_HSI() == 0) { + Error_Handler(); + } + } + } + + /* Ensure CCM RAM clock is enabled */ + __HAL_RCC_CCMDATARAMEN_CLK_ENABLE(); + + /* Output clock on MCO2 pin(PC9) for debugging purpose */ + //HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4); +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h new file mode 100644 index 000000000000..51a9e92286bf --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h @@ -0,0 +1,196 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus +// +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + // | DIGITAL | ANALOG IN | ANALOG OUT | UART/USART | TWI | SPI | SPECIAL | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PA0 PIN_A0 // | 0 | A0 (ADC1) | | UART4_TX | | | | +#define PA1 PIN_A1 // | 1 | A1 (ADC1) | | UART4_RX | | | | +#define PA2 PIN_A2 // | 2 | A2 (ADC1) | | USART2_TX | | | | +#define PA3 PIN_A3 // | 3 | A3 (ADC1) | | USART2_RX | | | | +#define PA4 PIN_A4 // | 4 | A4 (ADC1) | DAC_OUT1 | | | SPI1_SS, (SPI3_SS) | | +#define PA5 PIN_A5 // | 5 | A5 (ADC1) | DAC_OUT2 | | | SPI1_SCK | | +#define PA6 PIN_A6 // | 6 | A6 (ADC1) | | | | SPI1_MISO | | +#define PA7 PIN_A7 // | 7 | A7 (ADC1) | | | | SPI1_MOSI | | +#define PA8 8 // | 8 | | | | TWI3_SCL | | | +#define PA9 9 // | 9 | | | USART1_TX | | | | +#define PA10 10 // | 10 | | | USART1_RX | | | | +#define PA11 11 // | 11 | | | | | | | +#define PA12 12 // | 12 | | | | | | | +#define PA13 13 // | 13 | | | | | | SWD_SWDIO | +#define PA14 14 // | 14 | | | | | | SWD_SWCLK | +#define PA15 15 // | 15 | | | | | SPI3_SS, (SPI1_SS) | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PB0 PIN_A8 // | 16 | A8 (ADC1) | | | | | | +#define PB1 PIN_A9 // | 17 | A9 (ADC1) | | | | | | +#define PB2 18 // | 18 | | | | | | BOOT1 | +#define PB3 19 // | 19 | | | | | SPI3_SCK, (SPI1_SCK) | | +#define PB4 20 // | 20 | | | | | SPI3_MISO, (SPI1_MISO) | | +#define PB5 21 // | 21 | | | | | SPI3_MOSI, (SPI1_MOSI) | | +#define PB6 22 // | 22 | | | USART1_TX | TWI1_SCL | | | +#define PB7 23 // | 23 | | | USART1_RX | TWI1_SDA | | | +#define PB8 24 // | 24 | | | | TWI1_SCL | | | +#define PB9 25 // | 25 | | | | TWI1_SDA | SPI2_SS | | +#define PB10 26 // | 26 | | | USART3_TX, (UART4_TX) | TWI2_SCL | SPI2_SCK | | +#define PB11 27 // | 27 | | | USART3_RX | TWI2_SDA | | | +#define PB12 28 // | 28 | | | | | SPI2_SS | | +#define PB13 29 // | 29 | | | | | SPI2_SCK | | +#define PB14 30 // | 30 | | | | | SPI2_MISO | | +#define PB15 31 // | 31 | | | | | SPI2_MOSI | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PC0 PIN_A10 // | 32 | A10 (ADC1) | | | | | | +#define PC1 PIN_A11 // | 33 | A11 (ADC1) | | | | | | +#define PC2 PIN_A12 // | 34 | A12 (ADC1) | | | | SPI2_MISO | | +#define PC3 PIN_A13 // | 35 | A13 (ADC1) | | | | SPI2_MOSI | | +#define PC4 PIN_A14 // | 36 | A14 (ADC1) | | | | | | +#define PC5 PIN_A15 // | 37 | A15 (ADC1) | | USART3_RX | | | | +#define PC6 38 // | 38 | | | USART6_TX | | | | +#define PC7 39 // | 39 | | | USART6_RX | | | | +#define PC8 40 // | 40 | | | | | | | +#define PC9 41 // | 41 | | | USART3_TX | TWI3_SDA | | | +#define PC10 42 // | 42 | | | | | SPI3_SCK | | +#define PC11 43 // | 43 | | | USART3_RX, (UART4_RX) | | SPI3_MISO | | +#define PC12 44 // | 44 | | | UART5_TX | | SPI3_MOSI | | +#define PC13 45 // | 45 | | | | | | | +#define PC14 46 // | 46 | | | | | | OSC32_IN | +#define PC15 47 // | 47 | | | | | | OSC32_OUT | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PD0 48 // | 48 | | | | | | | +#define PD1 49 // | 49 | | | | | | | +#define PD2 50 // | 50 | | | UART5_RX | | | | +#define PD3 51 // | 51 | | | | | | | +#define PD4 52 // | 52 | | | | | | | +#define PD5 53 // | 53 | | | USART2_TX | | | | +#define PD6 54 // | 54 | | | USART2_RX | | | | +#define PD7 55 // | 55 | | | | | | | +#define PD8 56 // | 56 | | | USART3_TX | | | | +#define PD9 57 // | 57 | | | USART3_RX | | | | +#define PD10 58 // | 58 | | | | | | | +#define PD11 59 // | 59 | | | | | | | +#define PD12 60 // | 60 | | | | | | | +#define PD13 61 // | 61 | | | | | | | +#define PD14 62 // | 62 | | | | | | | +#define PD15 63 // | 63 | | | | | | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PE0 64 // | 64 | | | | | | | +#define PE1 65 // | 65 | | | | | | | +#define PE2 66 // | 66 | | | | | | | +#define PE3 67 // | 67 | | | | | | | +#define PE4 68 // | 68 | | | | | | | +#define PE5 69 // | 69 | | | | | | | +#define PE6 70 // | 70 | | | | | | | +#define PE7 71 // | 71 | | | | | | | +#define PE8 72 // | 72 | | | | | | | +#define PE9 73 // | 73 | | | | | | | +#define PE10 74 // | 74 | | | | | | | +#define PE11 75 // | 75 | | | | | | | +#define PE12 76 // | 76 | | | | | | | +#define PE13 77 // | 77 | | | | | | | +#define PE14 78 // | 78 | | | | | | | +#define PE15 79 // | 79 | | | | | | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PH0 80 // | 80 | | | | | | OSC_IN | +#define PH1 81 // | 81 | | | | | | OSC_OUT | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| + +// This must be a literal +#define NUM_DIGITAL_PINS 82 +#define NUM_ANALOG_INPUTS 16 + +// Below SPI and I2C definitions already done in the core +// Could be redefined here if differs from the default one +// SPI Definitions +#define PIN_SPI_SS PC9 +#define PIN_SPI_SCK PC10 +#define PIN_SPI_MISO PC11 +#define PIN_SPI_MOSI PC12 + +// I2C Definitions +#define PIN_WIRE_SCL PB8 +#define PIN_WIRE_SDA PB9 + +// Timer Definitions +// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c +// TIM1 = HEATER0, HEATER1, [SERVO] +// TIM2 = FAN1, FAN2, [BEEPER] +// TIM4 = HEATER_BED +// TIM5 = HEATER2, FAN0 +// Uses default for STM32F4xx STEP_TIMER 6 and TEMP_TIMER 14 +#define TIMER_SERVO TIM1 // TIMER_SERVO must be defined in this file +#define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file +#define TIMER_SERIAL TIM3 // TIMER_SERIAL must be defined in this file + +// USART1 (direct to RK3328 SoC) +#define ENABLE_HWSERIAL1 +#define PIN_SERIAL1_TX PA9 +#define PIN_SERIAL1_RX PA10 + +// USART3 connector +#define ENABLE_HWSERIAL3 +#define PIN_SERIAL3_TX PB10 +#define PIN_SERIAL3_RX PB11 + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial1 +#define SERIAL_PORT_USBVIRTUAL SerialUSB +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE1 Serial3 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 +#define SERIAL_PORT_HARDWARE_OPEN1 Serial3 +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h index 2ad290502338..8a04b8be103b 100755 --- a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h @@ -8,8 +8,8 @@ ****************************************************************************** * @attention * - *

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

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the @@ -91,11 +91,11 @@ * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) +#ifndef HSE_VALUE #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ -#if !defined (HSE_STARTUP_TIMEOUT) +#ifndef HSE_STARTUP_TIMEOUT #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ @@ -104,14 +104,14 @@ * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ -#if !defined (HSI_VALUE) +#ifndef HSI_VALUE #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) +#ifndef LSI_VALUE #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations @@ -119,11 +119,11 @@ /** * @brief External Low Speed oscillator (LSE) value. */ -#if !defined (LSE_VALUE) +#ifndef LSE_VALUE #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ -#if !defined (LSE_STARTUP_TIMEOUT) +#ifndef LSE_STARTUP_TIMEOUT #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ @@ -132,7 +132,7 @@ * This value is used by the I2S HAL module to compute the I2S clock source * frequency, this source is inserted directly through I2S_CKIN pad. */ -#if !defined (EXTERNAL_CLOCK_VALUE) +#ifndef EXTERNAL_CLOCK_VALUE #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld index e07c5e4acef9..55ae9227db3b 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld @@ -20,7 +20,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp index 6083664b9408..8a4320a66458 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp +++ b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp @@ -131,74 +131,74 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { {&gpioc, NULL, NULL, 14, 0, ADCx}, /* PC14 OSC32_IN */ {&gpioc, NULL, NULL, 15, 0, ADCx}, /* PC15 OSC32_OUT */ - {&gpiod, NULL, NULL, 0, 0, ADCx} , /* PD0 OSC_IN */ - {&gpiod, NULL, NULL, 1, 0, ADCx} , /* PD1 OSC_OUT */ - {&gpiod, NULL, NULL, 2, 0, ADCx} , /* PD2 TIM3_ETR/UART5_RX SDIO_CMD */ - - {&gpiod, NULL, NULL, 3, 0, ADCx} , /* PD3 FSMC_CLK */ - {&gpiod, NULL, NULL, 4, 0, ADCx} , /* PD4 FSMC_NOE */ - {&gpiod, NULL, NULL, 5, 0, ADCx} , /* PD5 FSMC_NWE */ - {&gpiod, NULL, NULL, 6, 0, ADCx} , /* PD6 FSMC_NWAIT */ - {&gpiod, NULL, NULL, 7, 0, ADCx} , /* PD7 FSMC_NE1/FSMC_NCE2 */ - {&gpiod, NULL, NULL, 8, 0, ADCx} , /* PD8 FSMC_D13 */ - {&gpiod, NULL, NULL, 9, 0, ADCx} , /* PD9 FSMC_D14 */ - {&gpiod, NULL, NULL, 10, 0, ADCx} , /* PD10 FSMC_D15 */ - {&gpiod, NULL, NULL, 11, 0, ADCx} , /* PD11 FSMC_A16 */ - {&gpiod, NULL, NULL, 12, 0, ADCx} , /* PD12 FSMC_A17 */ - {&gpiod, NULL, NULL, 13, 0, ADCx} , /* PD13 FSMC_A18 */ - {&gpiod, NULL, NULL, 14, 0, ADCx} , /* PD14 FSMC_D0 */ - {&gpiod, NULL, NULL, 15, 0, ADCx} , /* PD15 FSMC_D1 */ - - {&gpioe, NULL, NULL, 0, 0, ADCx} , /* PE0 */ - {&gpioe, NULL, NULL, 1, 0, ADCx} , /* PE1 */ - {&gpioe, NULL, NULL, 2, 0, ADCx} , /* PE2 */ - {&gpioe, NULL, NULL, 3, 0, ADCx} , /* PE3 */ - {&gpioe, NULL, NULL, 4, 0, ADCx} , /* PE4 */ - {&gpioe, NULL, NULL, 5, 0, ADCx} , /* PE5 */ - {&gpioe, NULL, NULL, 6, 0, ADCx} , /* PE6 */ - {&gpioe, NULL, NULL, 7, 0, ADCx} , /* PE7 */ - {&gpioe, NULL, NULL, 8, 0, ADCx} , /* PE8 */ - {&gpioe, NULL, NULL, 9, 0, ADCx} , /* PE9 */ - {&gpioe, NULL, NULL, 10, 0, ADCx} , /* PE10 */ - {&gpioe, NULL, NULL, 11, 0, ADCx} , /* PE11 */ - {&gpioe, NULL, NULL, 12, 0, ADCx} , /* PE12 */ - {&gpioe, NULL, NULL, 13, 0, ADCx} , /* PE13 */ - {&gpioe, NULL, NULL, 14, 0, ADCx} , /* PE14 */ - {&gpioe, NULL, NULL, 15, 0, ADCx} , /* PE15 */ - - {&gpiof, NULL, NULL, 0, 0, ADCx} , /* PF0 */ - {&gpiof, NULL, NULL, 1, 0, ADCx} , /* PF1 */ - {&gpiof, NULL, NULL, 2, 0, ADCx} , /* PF2 */ - {&gpiof, NULL, NULL, 3, 0, ADCx} , /* PF3 */ - {&gpiof, NULL, NULL, 4, 0, ADCx} , /* PF4 */ - {&gpiof, NULL, NULL, 5, 0, ADCx} , /* PF5 */ - {&gpiof, NULL, NULL, 6, 0, ADCx} , /* PF6 */ - {&gpiof, NULL, NULL, 7, 0, ADCx} , /* PF7 */ - {&gpiof, NULL, NULL, 8, 0, ADCx} , /* PF8 */ - {&gpiof, NULL, NULL, 9, 0, ADCx} , /* PF9 */ - {&gpiof, NULL, NULL, 10, 0, ADCx} , /* PF10 */ - {&gpiof, NULL, NULL, 11, 0, ADCx} , /* PF11 */ - {&gpiof, NULL, NULL, 12, 0, ADCx} , /* PF12 */ - {&gpiof, NULL, NULL, 13, 0, ADCx} , /* PF13 */ - {&gpiof, NULL, NULL, 14, 0, ADCx} , /* PF14 */ - {&gpiof, NULL, NULL, 15, 0, ADCx} , /* PF15 */ - - {&gpiog, NULL, NULL, 0, 0, ADCx} , /* PG0 */ - {&gpiog, NULL, NULL, 1, 0, ADCx} , /* PG1 */ - {&gpiog, NULL, NULL, 2, 0, ADCx} , /* PG2 */ - {&gpiog, NULL, NULL, 3, 0, ADCx} , /* PG3 */ - {&gpiog, NULL, NULL, 4, 0, ADCx} , /* PG4 */ - {&gpiog, NULL, NULL, 5, 0, ADCx} , /* PG5 */ - {&gpiog, NULL, NULL, 6, 0, ADCx} , /* PG6 */ - {&gpiog, NULL, NULL, 7, 0, ADCx} , /* PG7 */ - {&gpiog, NULL, NULL, 8, 0, ADCx} , /* PG8 */ - {&gpiog, NULL, NULL, 9, 0, ADCx} , /* PG9 */ - {&gpiog, NULL, NULL, 10, 0, ADCx} , /* PG10 */ - {&gpiog, NULL, NULL, 11, 0, ADCx} , /* PG11 */ - {&gpiog, NULL, NULL, 12, 0, ADCx} , /* PG12 */ - {&gpiog, NULL, NULL, 13, 0, ADCx} , /* PG13 */ - {&gpiog, NULL, NULL, 14, 0, ADCx} , /* PG14 */ - {&gpiog, NULL, NULL, 15, 0, ADCx} /* PG15 */ + {&gpiod, NULL, NULL, 0, 0, ADCx} , /* PD0 OSC_IN */ + {&gpiod, NULL, NULL, 1, 0, ADCx} , /* PD1 OSC_OUT */ + {&gpiod, NULL, NULL, 2, 0, ADCx} , /* PD2 TIM3_ETR/UART5_RX SDIO_CMD */ + + {&gpiod, NULL, NULL, 3, 0, ADCx} , /* PD3 FSMC_CLK */ + {&gpiod, NULL, NULL, 4, 0, ADCx} , /* PD4 FSMC_NOE */ + {&gpiod, NULL, NULL, 5, 0, ADCx} , /* PD5 FSMC_NWE */ + {&gpiod, NULL, NULL, 6, 0, ADCx} , /* PD6 FSMC_NWAIT */ + {&gpiod, NULL, NULL, 7, 0, ADCx} , /* PD7 FSMC_NE1/FSMC_NCE2 */ + {&gpiod, NULL, NULL, 8, 0, ADCx} , /* PD8 FSMC_D13 */ + {&gpiod, NULL, NULL, 9, 0, ADCx} , /* PD9 FSMC_D14 */ + {&gpiod, NULL, NULL, 10, 0, ADCx} , /* PD10 FSMC_D15 */ + {&gpiod, NULL, NULL, 11, 0, ADCx} , /* PD11 FSMC_A16 */ + {&gpiod, NULL, NULL, 12, 0, ADCx} , /* PD12 FSMC_A17 */ + {&gpiod, NULL, NULL, 13, 0, ADCx} , /* PD13 FSMC_A18 */ + {&gpiod, NULL, NULL, 14, 0, ADCx} , /* PD14 FSMC_D0 */ + {&gpiod, NULL, NULL, 15, 0, ADCx} , /* PD15 FSMC_D1 */ + + {&gpioe, NULL, NULL, 0, 0, ADCx} , /* PE0 */ + {&gpioe, NULL, NULL, 1, 0, ADCx} , /* PE1 */ + {&gpioe, NULL, NULL, 2, 0, ADCx} , /* PE2 */ + {&gpioe, NULL, NULL, 3, 0, ADCx} , /* PE3 */ + {&gpioe, NULL, NULL, 4, 0, ADCx} , /* PE4 */ + {&gpioe, NULL, NULL, 5, 0, ADCx} , /* PE5 */ + {&gpioe, NULL, NULL, 6, 0, ADCx} , /* PE6 */ + {&gpioe, NULL, NULL, 7, 0, ADCx} , /* PE7 */ + {&gpioe, NULL, NULL, 8, 0, ADCx} , /* PE8 */ + {&gpioe, NULL, NULL, 9, 0, ADCx} , /* PE9 */ + {&gpioe, NULL, NULL, 10, 0, ADCx} , /* PE10 */ + {&gpioe, NULL, NULL, 11, 0, ADCx} , /* PE11 */ + {&gpioe, NULL, NULL, 12, 0, ADCx} , /* PE12 */ + {&gpioe, NULL, NULL, 13, 0, ADCx} , /* PE13 */ + {&gpioe, NULL, NULL, 14, 0, ADCx} , /* PE14 */ + {&gpioe, NULL, NULL, 15, 0, ADCx} , /* PE15 */ + + {&gpiof, NULL, NULL, 0, 0, ADCx} , /* PF0 */ + {&gpiof, NULL, NULL, 1, 0, ADCx} , /* PF1 */ + {&gpiof, NULL, NULL, 2, 0, ADCx} , /* PF2 */ + {&gpiof, NULL, NULL, 3, 0, ADCx} , /* PF3 */ + {&gpiof, NULL, NULL, 4, 0, ADCx} , /* PF4 */ + {&gpiof, NULL, NULL, 5, 0, ADCx} , /* PF5 */ + {&gpiof, NULL, NULL, 6, 0, ADCx} , /* PF6 */ + {&gpiof, NULL, NULL, 7, 0, ADCx} , /* PF7 */ + {&gpiof, NULL, NULL, 8, 0, ADCx} , /* PF8 */ + {&gpiof, NULL, NULL, 9, 0, ADCx} , /* PF9 */ + {&gpiof, NULL, NULL, 10, 0, ADCx} , /* PF10 */ + {&gpiof, NULL, NULL, 11, 0, ADCx} , /* PF11 */ + {&gpiof, NULL, NULL, 12, 0, ADCx} , /* PF12 */ + {&gpiof, NULL, NULL, 13, 0, ADCx} , /* PF13 */ + {&gpiof, NULL, NULL, 14, 0, ADCx} , /* PF14 */ + {&gpiof, NULL, NULL, 15, 0, ADCx} , /* PF15 */ + + {&gpiog, NULL, NULL, 0, 0, ADCx} , /* PG0 */ + {&gpiog, NULL, NULL, 1, 0, ADCx} , /* PG1 */ + {&gpiog, NULL, NULL, 2, 0, ADCx} , /* PG2 */ + {&gpiog, NULL, NULL, 3, 0, ADCx} , /* PG3 */ + {&gpiog, NULL, NULL, 4, 0, ADCx} , /* PG4 */ + {&gpiog, NULL, NULL, 5, 0, ADCx} , /* PG5 */ + {&gpiog, NULL, NULL, 6, 0, ADCx} , /* PG6 */ + {&gpiog, NULL, NULL, 7, 0, ADCx} , /* PG7 */ + {&gpiog, NULL, NULL, 8, 0, ADCx} , /* PG8 */ + {&gpiog, NULL, NULL, 9, 0, ADCx} , /* PG9 */ + {&gpiog, NULL, NULL, 10, 0, ADCx} , /* PG10 */ + {&gpiog, NULL, NULL, 11, 0, ADCx} , /* PG11 */ + {&gpiog, NULL, NULL, 12, 0, ADCx} , /* PG12 */ + {&gpiog, NULL, NULL, 13, 0, ADCx} , /* PG13 */ + {&gpiog, NULL, NULL, 14, 0, ADCx} , /* PG14 */ + {&gpiog, NULL, NULL, 15, 0, ADCx} /* PG15 */ }; /* Basically everything that is defined as having a timer us PWM */ @@ -219,15 +219,15 @@ extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = { #ifdef SERIAL_USB - DEFINE_HWSERIAL(Serial1, 1); - DEFINE_HWSERIAL(Serial2, 2); - DEFINE_HWSERIAL(Serial3, 3); - DEFINE_HWSERIAL_UART(Serial4, 4); - DEFINE_HWSERIAL_UART(Serial5, 5); + DEFINE_HWSERIAL(Serial1, 1); + DEFINE_HWSERIAL(Serial2, 2); + DEFINE_HWSERIAL(Serial3, 3); + DEFINE_HWSERIAL_UART(Serial4, 4); + DEFINE_HWSERIAL_UART(Serial5, 5); #else - DEFINE_HWSERIAL(Serial, 1); - DEFINE_HWSERIAL(Serial1, 2); - DEFINE_HWSERIAL(Serial2, 3); - DEFINE_HWSERIAL_UART(Serial3, 4); - DEFINE_HWSERIAL_UART(Serial4, 5); + DEFINE_HWSERIAL(Serial, 1); + DEFINE_HWSERIAL(Serial1, 2); + DEFINE_HWSERIAL(Serial2, 3); + DEFINE_HWSERIAL_UART(Serial3, 4); + DEFINE_HWSERIAL_UART(Serial4, 5); #endif diff --git a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board/board.h b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board/board.h index a1e33467434a..80261d30274d 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board/board.h +++ b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board/board.h @@ -63,7 +63,6 @@ * SPI3 is unusable due to pin 43 (PB4) and NRST tie-together :(, but * leave the definitions so as not to clutter things up. This is only * OK since RET6 Ed. is specifically advertised as a beta board. */ -#define BOARD_NR_SPI 3 #define BOARD_SPI1_NSS_PIN PA4 #define BOARD_SPI1_SCK_PIN PA5 #define BOARD_SPI1_MISO_PIN PA6 @@ -79,7 +78,6 @@ #define BOARD_SPI3_MISO_PIN PB4 #define BOARD_SPI3_MOSI_PIN PB5 - /* GPIO A to E = 5 * 16 - BOOT1 not used = 79*/ #define BOARD_NR_GPIO_PINS 112 /* Note: NOT 19. The missing one is D38 a.k.a. BOARD_BUTTON_PIN, which diff --git a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp index f22cf354e208..657b92e2243f 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp +++ b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp @@ -144,10 +144,10 @@ static void setup_clocks(void) { * present. If no bootloader is present, the user NVIC usually starts * at the Flash base address, 0x08000000. */ -#if defined(BOOTLOADER_maple) - #define USER_ADDR_ROM 0x08005000 +#ifdef BOOTLOADER_maple + #define USER_ADDR_ROM 0x08005000 #else - #define USER_ADDR_ROM 0x08000000 + #define USER_ADDR_ROM 0x08000000 #endif #define USER_ADDR_RAM 0x20000C00 extern char __text_start__; diff --git a/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board/board.h b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board/board.h index da9ffd893f87..6ffa2447460d 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board/board.h +++ b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board/board.h @@ -63,26 +63,21 @@ * SPI3 is unusable due to pin 43 (PB4) and NRST tie-together :(, but * leave the definitions so as not to clutter things up. This is only * OK since RET6 Ed. is specifically advertised as a beta board. */ -#define BOARD_NR_SPI 3 #define BOARD_SPI1_NSS_PIN PA4 #define BOARD_SPI1_SCK_PIN PA5 #define BOARD_SPI1_MISO_PIN PA6 #define BOARD_SPI1_MOSI_PIN PA7 - - #define BOARD_SPI2_NSS_PIN PB12 #define BOARD_SPI2_SCK_PIN PB13 #define BOARD_SPI2_MISO_PIN PB14 #define BOARD_SPI2_MOSI_PIN PB15 - #define BOARD_SPI3_NSS_PIN PA15 #define BOARD_SPI3_SCK_PIN PB3 #define BOARD_SPI3_MISO_PIN PB4 #define BOARD_SPI3_MOSI_PIN PB5 - /* GPIO A to E = 5 * 16 - BOOT1 not used = 79*/ #define BOARD_NR_GPIO_PINS 51 /* Note: NOT 19. The missing one is D38 a.k.a. BOARD_BUTTON_PIN, which diff --git a/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp index 77dcbcf848d3..1494cec56381 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp +++ b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp @@ -144,7 +144,7 @@ static void setup_clocks(void) { * present. If no bootloader is present, the user NVIC usually starts * at the Flash base address, 0x08000000. */ -#if defined(BOOTLOADER_maple) +#ifdef BOOTLOADER_maple #define USER_ADDR_ROM 0x08002000 #else #define USER_ADDR_ROM 0x08000000 diff --git a/buildroot/share/dwin/bin/makeIco.py b/buildroot/share/dwin/bin/makeIco.py index 274082acee87..65e7eb53a58b 100755 --- a/buildroot/share/dwin/bin/makeIco.py +++ b/buildroot/share/dwin/bin/makeIco.py @@ -18,7 +18,6 @@ # along with this program. If not, see . #---------------------------------------------------------------- -import os import os.path import argparse import DWIN_ICO diff --git a/buildroot/share/dwin/bin/splitIco.py b/buildroot/share/dwin/bin/splitIco.py index ce6ba89749c9..a96d1823d22e 100755 --- a/buildroot/share/dwin/bin/splitIco.py +++ b/buildroot/share/dwin/bin/splitIco.py @@ -18,7 +18,6 @@ # along with this program. If not, see . #---------------------------------------------------------------- -import os import os.path import argparse import DWIN_ICO diff --git a/buildroot/share/extras/uncrustify.cfg b/buildroot/share/extras/uncrustify.cfg index 06661203f09c..82044f8c7b9a 100644 --- a/buildroot/share/extras/uncrustify.cfg +++ b/buildroot/share/extras/uncrustify.cfg @@ -26,7 +26,7 @@ mod_add_long_ifdef_endif_comment = 40 mod_full_brace_do = false mod_full_brace_for = false mod_full_brace_if = false -mod_full_brace_if_chain = true +mod_full_brace_if_chain = 1 mod_full_brace_while = false mod_remove_extra_semicolon = true newlines = lf diff --git a/buildroot/share/git/mfconfig b/buildroot/share/git/mfconfig index b379317d9866..852885944621 100755 --- a/buildroot/share/git/mfconfig +++ b/buildroot/share/git/mfconfig @@ -140,8 +140,17 @@ if [[ $ACTION == "init" ]]; then cp -R "$TEMP/config" . find config -type f \! -name "Configuration*" -exec rm "{}" \; + addpathlabels() { + find config -name "Conf*.h" -print0 | while read -d $'\0' fn ; do + fldr=$(dirname "$fn") + blank_line=$(awk '/^\s*$/ {print NR; exit}' "$fn") + $SED -i~ "${blank_line}i\\\n#define CONFIG_EXAMPLES_DIR \"$fldr\"\\ " "$fn" + rm -f "$fn~" + done + } + echo "- Adding path labels to all configs..." - config-labels.py >/dev/null 2>&1 + addpathlabels git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null @@ -149,7 +158,7 @@ if [[ $ACTION == "init" ]]; then cp -R "$TEMP/config" . # Apply labels again! - config-labels.py >/dev/null 2>&1 + addpathlabels git add . >/dev/null && git commit -m "Examples Extras" >/dev/null diff --git a/buildroot/share/git/mfinfo b/buildroot/share/git/mfinfo index 3f183b8fd8f0..c74e48650cbc 100755 --- a/buildroot/share/git/mfinfo +++ b/buildroot/share/git/mfinfo @@ -56,7 +56,7 @@ done case "$REPO" in Marlin ) TARG=bugfix-2.1.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;; - Configurations ) TARG=import-2.0.x ;; + Configurations ) TARG=import-2.1.x ;; MarlinDocumentation ) TARG=master ;; AutoBuildMarlin ) TARG=master ;; esac diff --git a/buildroot/share/scripts/config-labels.py b/buildroot/share/scripts/config-labels.py deleted file mode 100755 index 519f7b67ca6d..000000000000 --- a/buildroot/share/scripts/config-labels.py +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/env python3 -# -# for python3.5 or higher -#----------------------------------- -# Within Marlin project MarlinFirmware/Configurations, this program visits all folders -# under .../config/examples/*, processing each Configuration.h, Configuration_adv.h, -# _Bootscreen.h, and _Statusscreen.h, to insert: -# #define CONFIG_EXAMPLES_DIR "examples/