diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 8dd3f92703ce..a611650e78b9 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -177,7 +177,7 @@ #endif /** - * Prusa Multi-Material Unit v2 + * Průša Multi-Material Unit v2 * * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. * Requires EXTRUDERS = 5 @@ -235,8 +235,8 @@ #elif ENABLED(MAGNETIC_PARKING_EXTRUDER) - #define MPE_FAST_SPEED 9000 // (mm/m) Speed for travel before last distance point - #define MPE_SLOW_SPEED 4500 // (mm/m) Speed for last distance travel to park and couple + #define MPE_FAST_SPEED 9000 // (mm/min) Speed for travel before last distance point + #define MPE_SLOW_SPEED 4500 // (mm/min) Speed for last distance travel to park and couple #define MPE_TRAVEL_DISTANCE 10 // (mm) Last distance point #define MPE_COMPENSATION 0 // Offset Compensation -1 , 0 , 1 (multiplier) only for coupling @@ -284,8 +284,8 @@ #if ENABLED(PRIME_BEFORE_REMOVE) #define SWITCHING_TOOLHEAD_PRIME_MM 20 // (mm) Extruder prime length #define SWITCHING_TOOLHEAD_RETRACT_MM 10 // (mm) Retract after priming length - #define SWITCHING_TOOLHEAD_PRIME_FEEDRATE 300 // (mm/m) Extruder prime feedrate - #define SWITCHING_TOOLHEAD_RETRACT_FEEDRATE 2400 // (mm/m) Extruder retract feedrate + #define SWITCHING_TOOLHEAD_PRIME_FEEDRATE 300 // (mm/min) Extruder prime feedrate + #define SWITCHING_TOOLHEAD_RETRACT_FEEDRATE 2400 // (mm/min) Extruder retract feedrate #endif #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) #define SWITCHING_TOOLHEAD_Z_HOP 2 // (mm) Z raise for switching @@ -330,7 +330,7 @@ //#define PSU_NAME "Power Supply" #if ENABLED(PSU_CONTROL) - #define PSU_ACTIVE_HIGH false // Set 'false' for ATX (1), 'true' for X-Box (2) + #define PSU_ACTIVE_STATE LOW // Set 'LOW' for ATX, 'HIGH' for X-Box //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80 //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power @@ -372,7 +372,7 @@ * 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! * 5 : 100K thermistor - ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan, J-Head, and E3D) (4.7k pullup) * 501 : 100K Zonestar (Tronxy X3A) Thermistor - * 502 : 100K Zonestar Thermistor used by hot bed in Zonestar Prusa P802M + * 502 : 100K Zonestar Thermistor used by hot bed in Zonestar Průša P802M * 512 : 100k RPW-Ultra hotend thermistor (4.7k pullup) * 6 : 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) * 7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) @@ -589,7 +589,7 @@ // @section machine -// Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// Enable one of the options below for CoreXY, CoreXZ, or CoreYZ kinematics, // either in the usual order or reversed //#define COREXY //#define COREXZ @@ -597,6 +597,7 @@ //#define COREYX //#define COREZX //#define COREZY +//#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042 //=========================================================================== //============================== Endstop Settings =========================== @@ -978,10 +979,10 @@ // X and Y axis travel speed (mm/m) between probes #define XY_PROBE_SPEED 6000 -// Feedrate (mm/m) for the first approach when double-probing (MULTIPLE_PROBING == 2) +// Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2) #define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z -// Feedrate (mm/m) for the "accurate" probe of each point +// Feedrate (mm/min) for the "accurate" probe of each point #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2) /** @@ -1150,10 +1151,11 @@ */ //#define FILAMENT_RUNOUT_SENSOR #if ENABLED(FILAMENT_RUNOUT_SENSOR) - #define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. - #define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present. - #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. - //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. + #define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500. + #define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. + #define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present. + #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. + //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. // Set one or more commands to execute on filament runout. // (After 'M412 H' Marlin will ask the host to handle the process.) @@ -1579,9 +1581,12 @@ // Move the nozzle to the initial position after cleaning #define NOZZLE_CLEAN_GOBACK - // Enable for a purge/clean station that's always at the gantry height (thus no Z move) + // For a purge/clean station that's always at the gantry height (thus no Z move) //#define NOZZLE_CLEAN_NO_Z + // For a purge/clean station mounted on the X axis + //#define NOZZLE_CLEAN_NO_Y + // Explicit wipe G-code script applies to a G12 with no arguments. //#define WIPE_SEQUENCE_COMMANDS "G1 X-17 Y25 Z10 F4000\nG1 Z1\nM114\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 Z15\nM400\nG0 X-10.0 Y-9.0" @@ -1642,7 +1647,7 @@ #define PASSWORD_LENGTH 4 // (#) Number of digits (1-9). 3 or 4 is recommended #define PASSWORD_ON_STARTUP #define PASSWORD_UNLOCK_GCODE // Unlock with the M511 P command. Disable to prevent brute-force attack. - #define PASSWORD_CHANGE_GCODE // Change the password with M512 P N. + #define PASSWORD_CHANGE_GCODE // Change the password with M512 P S. //#define PASSWORD_ON_SD_PRINT_MENU // This does not prevent gcodes from running //#define PASSWORD_AFTER_SD_PRINT_END //#define PASSWORD_AFTER_SD_PRINT_ABORT @@ -1661,7 +1666,7 @@ * Select the language to display on the LCD. These languages are available: * * en, an, bg, ca, cz, da, de, el, el_gr, es, eu, fi, fr, gl, hr, hu, it, - * jp_kana, ko_KR, nl, pl, pt, pt_br, ro ru, sk, tr, uk, vi, zh_CN, zh_TW, test + * jp_kana, ko_KR, nl, pl, pt, pt_br, ro, ru, sk, tr, uk, vi, zh_CN, zh_TW, test * * :{ 'en':'English', 'an':'Aragonese', 'bg':'Bulgarian', 'ca':'Catalan', 'cz':'Czech', 'da':'Danish', 'de':'German', 'el':'Greek', 'el_gr':'Greek (Greece)', 'es':'Spanish', 'eu':'Basque-Euskera', 'fi':'Finnish', 'fr':'French', 'gl':'Galician', 'hr':'Croatian', 'hu':'Hungarian', 'it':'Italian', 'jp_kana':'Japanese', 'ko_KR':'Korean (South Korea)', 'nl':'Dutch', 'pl':'Polish', 'pt':'Portuguese', 'pt_br':'Portuguese (Brazilian)', 'ro':'Romanian', 'ru':'Russian', 'sk':'Slovak', 'tr':'Turkish', 'uk':'Ukrainian', 'vi':'Vietnamese', 'zh_CN':'Chinese (Simplified)', 'zh_TW':'Chinese (Traditional)', 'test':'TEST' } */ @@ -1692,9 +1697,9 @@ #define DISPLAY_CHARSET_HD44780 WESTERN /** - * Info Screen Style (0:Classic, 1:Prusa) + * Info Screen Style (0:Classic, 1:Průša) * - * :[0:'Classic', 1:'Prusa'] + * :[0:'Classic', 1:'Průša'] */ #define LCD_INFO_SCREEN_STYLE 0 @@ -2031,10 +2036,11 @@ // FYSETC variant of the MINI12864 graphic controller with SD support // https://wiki.fysetc.com/Mini12864_Panel/ // -//#define FYSETC_MINI_12864_X_X // Type C/D/E/F. No tunable RGB Backlight by default -//#define FYSETC_MINI_12864_1_2 // Type C/D/E/F. Simple RGB Backlight (always on) -//#define FYSETC_MINI_12864_2_0 // Type A/B. Discreet RGB Backlight -//#define FYSETC_MINI_12864_2_1 // Type A/B. Neopixel RGB Backlight +//#define FYSETC_MINI_12864_X_X // Type C/D/E/F. No tunable RGB Backlight by default +//#define FYSETC_MINI_12864_1_2 // Type C/D/E/F. Simple RGB Backlight (always on) +//#define FYSETC_MINI_12864_2_0 // Type A/B. Discreet RGB Backlight +//#define FYSETC_MINI_12864_2_1 // Type A/B. NeoPixel RGB Backlight +//#define FYSETC_GENERIC_12864_1_1 // Larger display with basic ON/OFF backlight. // // Factory display for Creality CR-10 @@ -2242,6 +2248,10 @@ // @section extras +// Set number of user-controlled fans. Disable to use all board-defined fans. +// :[1,2,3,4,5,6,7,8] +//#define NUM_M106_FANS 1 + // Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino //#define FAST_PWM_FAN @@ -2292,13 +2302,13 @@ * Adds the M150 command to set the LED (or LED strip) color. * If pins are PWM capable (e.g., 4, 5, 6, 11) then a range of * luminance values can be set from 0 to 255. - * For Neopixel LED an overall brightness parameter is also available. + * For NeoPixel LED an overall brightness parameter is also available. * * *** 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 + * NOTE: A separate 5V power supply is required! The NeoPixel LED needs * more current than the Arduino 5V linear regulator can produce. * *** CAUTION *** * @@ -2327,7 +2337,17 @@ #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) #define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup - // Use a single Neopixel LED for static (background) lighting + // Support for second Adafruit NeoPixel LED driver controlled with M150 S1 ... + //#define NEOPIXEL2_SEPARATE + #if ENABLED(NEOPIXEL2_SEPARATE) + #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 + #else + //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel + #endif + + // Use a single NeoPixel LED for static (background) lighting //#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W #endif diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index db6a4cfaae72..8251ab4e4177 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -277,7 +277,7 @@ #if ENABLED(EXTRUDER_RUNOUT_PREVENT) #define EXTRUDER_RUNOUT_MINTEMP 190 #define EXTRUDER_RUNOUT_SECONDS 30 - #define EXTRUDER_RUNOUT_SPEED 1500 // (mm/m) + #define EXTRUDER_RUNOUT_SPEED 1500 // (mm/min) #define EXTRUDER_RUNOUT_EXTRUDE 5 // (mm) #endif @@ -426,7 +426,7 @@ //#define CASE_LIGHT_MAX_PWM 128 // Limit pwm //#define CASE_LIGHT_MENU // Add Case Light options to the LCD menu //#define CASE_LIGHT_NO_BRIGHTNESS // Disable brightness control. Enable for non-PWM lighting. - //#define CASE_LIGHT_USE_NEOPIXEL // Use Neopixel LED as case light, requires NEOPIXEL_LED. + //#define CASE_LIGHT_USE_NEOPIXEL // Use NeoPixel LED as case light, requires NEOPIXEL_LED. #if ENABLED(CASE_LIGHT_USE_NEOPIXEL) #define CASE_LIGHT_NEOPIXEL_COLOR { 255, 255, 255, 255 } // { Red, Green, Blue, White } #endif @@ -743,13 +743,13 @@ //#define HOME_AFTER_DEACTIVATE // Require rehoming after steppers are deactivated -// Minimum time that a segment needs to take as the buffer gets emptied -#define DEFAULT_MINSEGMENTTIME 20000 // (µs) Set with M205 B. - // Default Minimum Feedrates for printing and travel moves #define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s) Minimum feedrate. Set with M205 S. #define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s) Minimum travel feedrate. Set with M205 T. +// Minimum time that a segment needs to take as the buffer gets emptied +#define DEFAULT_MINSEGMENTTIME 20000 // (µs) Set with M205 B. + // Slow down the machine if the lookahead buffer is (by default) half full. // Increase the slowdown divisor for larger buffer sizes. #define SLOWDOWN @@ -801,7 +801,7 @@ // increments while checking for the contact to be broken. #define BACKLASH_MEASUREMENT_LIMIT 0.5 // (mm) #define BACKLASH_MEASUREMENT_RESOLUTION 0.005 // (mm) - #define BACKLASH_MEASUREMENT_FEEDRATE Z_PROBE_SPEED_SLOW // (mm/m) + #define BACKLASH_MEASUREMENT_FEEDRATE Z_PROBE_SPEED_SLOW // (mm/min) #endif #endif #endif @@ -827,9 +827,9 @@ #define CALIBRATION_MEASUREMENT_RESOLUTION 0.01 // mm - #define CALIBRATION_FEEDRATE_SLOW 60 // mm/m - #define CALIBRATION_FEEDRATE_FAST 1200 // mm/m - #define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/m + #define CALIBRATION_FEEDRATE_SLOW 60 // mm/min + #define CALIBRATION_FEEDRATE_FAST 1200 // mm/min + #define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/min // The following parameters refer to the conical section of the nozzle tip. #define CALIBRATION_NOZZLE_TIP_HEIGHT 1.0 // mm @@ -943,7 +943,7 @@ // @section lcd #if EITHER(ULTIPANEL, EXTENSIBLE_UI) - #define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 2*60 } // (mm/m) Feedrates for manual moves along X, Y, Z, E from panel + #define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 2*60 } // (mm/min) Feedrates for manual moves along X, Y, Z, E from panel #define SHORT_MANUAL_Z_MOVE 0.025 // (mm) Smallest manual Z move (< 0.1mm) #if ENABLED(ULTIPANEL) #define MANUAL_E_MOVES_RELATIVE // Display extruder move distance rather than "position" @@ -983,6 +983,7 @@ //#define LED_CONTROL_MENU #if ENABLED(LED_CONTROL_MENU) #define LED_COLOR_PRESETS // Enable the Preset Color menu option + //#define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option #if ENABLED(LED_COLOR_PRESETS) #define LED_USER_PRESET_RED 255 // User defined RED value #define LED_USER_PRESET_GREEN 128 // User defined GREEN value @@ -991,6 +992,14 @@ #define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity //#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 + #endif #endif #endif // HAS_LCD_MENU @@ -1895,13 +1904,13 @@ // Load / Unload #define TOOLCHANGE_FS_LENGTH 12 // (mm) Load / Unload length #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart, fine tune by LCD/Gcode) - #define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/m) (Unloading) - #define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/m) (On SINGLENOZZLE or Bowden loading must be slowed down) + #define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/min) (Unloading) + #define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/min) (On SINGLENOZZLE or Bowden loading must be slowed down) // 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/m) Extra priming feedrate - #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm/m) Retract before cooling for less stringing, better wipe, etc. + #define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/min) Extra priming feedrate + #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm/min) Retract before cooling for less stringing, better wipe, etc. // Cool after prime to reduce stringing #define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip @@ -1937,7 +1946,7 @@ //#define TOOLCHANGE_PARK #if ENABLED(TOOLCHANGE_PARK) #define TOOLCHANGE_PARK_XY { X_MIN_POS + 10, Y_MIN_POS + 10 } - #define TOOLCHANGE_PARK_XY_FEEDRATE 6000 // (mm/m) + #define TOOLCHANGE_PARK_XY_FEEDRATE 6000 // (mm/min) //#define TOOLCHANGE_PARK_X_ONLY // X axis only move //#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move #endif @@ -2288,7 +2297,7 @@ * CHOPPER_DEFAULT_24V * CHOPPER_DEFAULT_36V * CHOPPER_09STEP_24V // 0.9 degree steppers (24V) - * CHOPPER_PRUSAMK3_24V // Imported parameters from the official Prusa firmware for MK3 (24V) + * CHOPPER_PRUSAMK3_24V // Imported parameters from the official Průša firmware for MK3 (24V) * CHOPPER_MARLIN_119 // Old defaults from Marlin v1.1.9 * * Define you own with @@ -2339,7 +2348,7 @@ #define E5_HYBRID_THRESHOLD 30 /** - * Use StallGuard2 to home / probe X, Y, Z. + * Use StallGuard to home / probe X, Y, Z. * * TMC2130, TMC2160, TMC2209, TMC2660, TMC5130, and TMC5160 only * Connect the stepper driver's DIAG1 pin to the X/Y endstop pin. @@ -2361,7 +2370,7 @@ * IMPROVE_HOMING_RELIABILITY tunes acceleration and jerk when * homing and adds a guard period for endstop triggering. * - * TMC2209 requires STEALTHCHOP enabled for SENSORLESS_HOMING + * Comment *_STALL_SENSITIVITY to disable sensorless homing for that axis. */ //#define SENSORLESS_HOMING // StallGuard capable drivers only @@ -2647,7 +2656,7 @@ //#define SPINDLE_FEATURE //#define LASER_FEATURE #if EITHER(SPINDLE_FEATURE, LASER_FEATURE) - #define SPINDLE_LASER_ACTIVE_HIGH false // Set to "true" if the on/off function is active HIGH + #define SPINDLE_LASER_ACTIVE_STATE LOW // Set to "HIGH" if the on/off function is active HIGH #define SPINDLE_LASER_PWM true // Set to "true" if your controller supports setting the speed/power #define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower @@ -2947,7 +2956,7 @@ //#define GCODE_MOTION_MODES // Remember the motion mode (G0 G1 G2 G3 G5 G38.X) and apply for X Y Z E F, etc. // Enable and set a (default) feedrate for all G0 moves -//#define G0_FEEDRATE 3000 // (mm/m) +//#define G0_FEEDRATE 3000 // (mm/min) #ifdef G0_FEEDRATE //#define VARIABLE_G0_FEEDRATE // The G0 feedrate is set by F in G0 motion mode #endif @@ -3177,7 +3186,7 @@ #endif /** - * Prusa Multi-Material Unit v2 + * Průša Multi-Material Unit v2 * Enable in Configuration.h */ #if ENABLED(PRUSA_MMU2) @@ -3201,7 +3210,7 @@ //#define MMU2_MENUS #if ENABLED(MMU2_MENUS) // Settings for filament load / unload from the LCD menu. - // This is for Prusa MK3-style extruders. Customize for your hardware. + // This is for Průša MK3-style extruders. Customize for your hardware. #define MMU2_FILAMENTCHANGE_EJECT_FEED 80.0 #define MMU2_LOAD_TO_NOZZLE_SEQUENCE \ { 7.2, 1145 }, \ @@ -3227,7 +3236,7 @@ /** * MMU Extruder Sensor * - * Support for a Prusa (or other) IR Sensor to detect filament near the extruder + * Support for a Průša (or other) IR Sensor to detect filament near the extruder * and make loading more reliable. Suitable for an extruder equipped with a filament * sensor less than 38mm from the gears. * @@ -3249,7 +3258,7 @@ #if ENABLED(PRUSA_MMU2_S_MODE) #define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries) - #define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/m) + #define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/min) #define MMU2_CAN_LOAD_SEQUENCE \ { 0.1, MMU2_CAN_LOAD_FEEDRATE }, \ { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ diff --git a/Marlin/src/HAL/AVR/ServoTimers.h b/Marlin/src/HAL/AVR/ServoTimers.h index 564714df6e8e..436b28141f95 100644 --- a/Marlin/src/HAL/AVR/ServoTimers.h +++ b/Marlin/src/HAL/AVR/ServoTimers.h @@ -59,10 +59,12 @@ // Say which 16 bit timers can be used and in what order #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //#define _useTimer1 - #define _useTimer3 #define _useTimer4 - #if !HAS_MOTOR_CURRENT_PWM - #define _useTimer5 // Timer 5 is used for motor current PWM and can't be used for servos. + #if NUM_SERVOS > SERVOS_PER_TIMER + #define _useTimer3 + #if !HAS_MOTOR_CURRENT_PWM && SERVOS > 2 * SERVOS_PER_TIMER + #define _useTimer5 // Timer 5 is used for motor current PWM and can't be used for servos. + #endif #endif #elif defined(__AVR_ATmega32U4__) #define _useTimer3 diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h index e55e45b73bd0..731cf9286582 100644 --- a/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -36,9 +36,10 @@ * Sanity checks for Spindle / Laser PWM */ #if ENABLED(SPINDLE_LASER_PWM) + #include "../ServoTimers.h" // Needed to check timer availability (_useTimer3) #if SPINDLE_LASER_PWM_PIN == 4 || WITHIN(SPINDLE_LASER_PWM_PIN, 11, 13) #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by a system interrupt." - #elif NUM_SERVOS > 0 && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5) + #elif NUM_SERVOS > 0 && defined(_useTimer3) && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5) #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system." #endif #elif defined(SPINDLE_LASER_FREQUENCY) diff --git a/Marlin/src/HAL/DUE/usb/arduino_due_x.h b/Marlin/src/HAL/DUE/usb/arduino_due_x.h index b5be621791d2..d3b333fb349a 100644 --- a/Marlin/src/HAL/DUE/usb/arduino_due_x.h +++ b/Marlin/src/HAL/DUE/usb/arduino_due_x.h @@ -93,5 +93,5 @@ #define USB_VBOF_GPIO (PIO_PB10_IDX) #define USB_VBOF_FLAGS (PIO_PERIPH_A | PIO_DEFAULT) /*! Active level of the USB_VBOF output pin. */ -#define USB_VBOF_ACTIVE_LEVEL LOW +#define USB_VBOF_ACTIVE_STATE LOW /* ------------------------------------------------------------------------ */ diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index 29702f2d2b61..c7b7531442db 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -38,7 +38,7 @@ // String helper #ifndef PGMSTR - #define PGMSTR(NAM,STR) constexpr char NAM[] = STR + #define PGMSTR(NAM,STR) const char NAM[] = STR #endif inline void watchdog_refresh() { diff --git a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp index e34a102012a1..00b4310d1dc7 100644 --- a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp +++ b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp @@ -30,7 +30,7 @@ */ /** - * Hardware SPI and a software SPI implementations are included in this file. + * Hardware SPI and Software SPI implementations are included in this file. * The hardware SPI runs faster and has higher throughput but is not compatible * with some LCD interfaces/adapters. * @@ -51,6 +51,10 @@ #include "../../inc/MarlinConfig.h" #include +// Hardware SPI and SPIClass +#include +#include + // ------------------------ // Public functions // ------------------------ @@ -96,12 +100,6 @@ #else - // Hardware SPI - - #include - #include - #include - // decide which HW SPI device to use #ifndef LPC_HW_SPI_DEV #if (SCK_PIN == P0_07 && MISO_PIN == P0_08 && MOSI_PIN == P0_09) @@ -114,7 +112,7 @@ #endif #endif #endif - #if (LPC_HW_SPI_DEV == 0) + #if LPC_HW_SPI_DEV == 0 #define LPC_SSPn LPC_SSP0 #else #define LPC_SSPn LPC_SSP1 @@ -192,7 +190,7 @@ for (uint16_t i = 0; i < nbyte; i++) buf[i] = doio(0xFF); } - static uint8_t spiTransfer(uint8_t b) { + uint8_t spiTransfer(uint8_t b) { return doio(b); } @@ -211,30 +209,236 @@ #endif // LPC_SOFTWARE_SPI -void SPIClass::begin() { spiBegin(); } +/** + * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. + */ +static inline void waitSpiTxEnd(LPC_SSP_TypeDef *spi_d) { + while (SSP_GetStatus(spi_d, SSP_STAT_TXFIFO_EMPTY) == RESET) { /* nada */ } // wait until TXE=1 + while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0 +} + +SPIClass::SPIClass(uint8_t device) { + // Init things specific to each SPI device + // clock divider setup is a bit of hack, and needs to be improved at a later date. + + PINSEL_CFG_Type PinCfg; // data structure to hold init values + #if BOARD_NR_SPI >= 1 + _settings[0].spi_d = LPC_SSP0; + // _settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock); + PinCfg.Funcnum = 2; + PinCfg.OpenDrain = 0; + PinCfg.Pinmode = 0; + PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_SCK_PIN); + PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_SCK_PIN); + PINSEL_ConfigPin(&PinCfg); + SET_OUTPUT(BOARD_SPI1_SCK_PIN); + + PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MISO_PIN); + PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MISO_PIN); + PINSEL_ConfigPin(&PinCfg); + SET_INPUT(BOARD_SPI1_MISO_PIN); + + PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MOSI_PIN); + PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MOSI_PIN); + PINSEL_ConfigPin(&PinCfg); + SET_OUTPUT(BOARD_SPI1_MOSI_PIN); + #endif + + #if BOARD_NR_SPI >= 2 + _settings[1].spi_d = LPC_SSP1; + // _settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock); + PinCfg.Funcnum = 2; + PinCfg.OpenDrain = 0; + PinCfg.Pinmode = 0; + PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_SCK_PIN); + PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_SCK_PIN); + PINSEL_ConfigPin(&PinCfg); + SET_OUTPUT(BOARD_SPI2_SCK_PIN); + + PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MISO_PIN); + PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MISO_PIN); + PINSEL_ConfigPin(&PinCfg); + SET_INPUT(BOARD_SPI2_MISO_PIN); + + PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MOSI_PIN); + PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MOSI_PIN); + PINSEL_ConfigPin(&PinCfg); + SET_OUTPUT(BOARD_SPI2_MOSI_PIN); + #endif + + setModule(device); + + /* Initialize GPDMA controller */ + //TODO: call once in the constructor? or each time? + GPDMA_Init(); +} + +void SPIClass::begin() { + updateSettings(); + SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running +} void SPIClass::beginTransaction(const SPISettings &cfg) { - uint8_t spiRate; - switch (cfg.spiRate()) { - case 8000000: spiRate = 0; break; - case 4000000: spiRate = 1; break; - case 2000000: spiRate = 2; break; - case 1000000: spiRate = 3; break; - case 500000: spiRate = 4; break; - case 250000: spiRate = 5; break; - case 125000: spiRate = 6; break; - default: spiRate = 2; break; - } - spiInit(spiRate); + setBitOrder(cfg.bitOrder); + setDataMode(cfg.dataMode); + setDataSize(cfg.dataSize); + //setClockDivider(determine_baud_rate(_currentSetting->spi_d, settings.clock)); + begin(); } -uint8_t SPIClass::transfer(const uint8_t B) { return spiTransfer(B); } +uint8_t SPIClass::transfer(const uint16_t b) { + /* send and receive a single byte */ + SSP_ReceiveData(_currentSetting->spi_d); // read any previous data + SSP_SendData(_currentSetting->spi_d, b); + waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish + return SSP_ReceiveData(_currentSetting->spi_d); +} uint16_t SPIClass::transfer16(const uint16_t data) { return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF); } -SPIClass SPI; +void SPIClass::end() { + // SSP_Cmd(_currentSetting->spi_d, DISABLE); // stop device or SSP_DeInit? + SSP_DeInit(_currentSetting->spi_d); +} + +void SPIClass::send(uint8_t data) { + SSP_SendData(_currentSetting->spi_d, data); +} + +void SPIClass::dmaSend(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 = (minc ? length : 1); + // 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); + + // if minc=false, I'm repeating the same byte 'length' times, as I could not find yet how do GPDMA without memory increment + do { + // Setup channel with given parameter + GPDMA_Setup(&GPDMACfg); + + // enabled dma + GPDMA_ChannelCmd(0, ENABLE); + + // wait data transfer + while (!GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)) { } + + // clear err and int + GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0); + GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0); + + // dma disable + GPDMA_ChannelCmd(0, DISABLE); + + --length; + } while (!minc && length > 0); + + waitSpiTxEnd(_currentSetting->spi_d); + + SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE); +} + +uint16_t SPIClass::read() { + return SSP_ReceiveData(_currentSetting->spi_d); +} + +void SPIClass::read(uint8_t *buf, uint32_t len) { + for (uint16_t i = 0; i < len; i++) buf[i] = transfer(0xFF); +} + +void SPIClass::setClock(uint32_t clock) { + _currentSetting->clock = clock; +} + +void SPIClass::setModule(uint8_t device) { + _currentSetting = &_settings[device - 1];// SPI channels are called 1 2 and 3 but the array is zero indexed +} + +void SPIClass::setBitOrder(uint8_t bitOrder) { + _currentSetting->bitOrder = bitOrder; +} + +void SPIClass::setDataMode(uint8_t dataMode) { + _currentSetting->dataSize = dataMode; +} + +void SPIClass::setDataSize(uint32_t ds) { + _currentSetting->dataSize = ds; +} + +/** + * Set up/tear down + */ +void SPIClass::updateSettings() { + //SSP_DeInit(_currentSetting->spi_d); //todo: need force de init?! + + // divide PCLK by 2 for SSP0 + CLKPWR_SetPCLKDiv(_currentSetting->spi_d == LPC_SSP0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2); + + SSP_CFG_Type HW_SPI_init; // data structure to hold init values + SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode + HW_SPI_init.ClockRate = _currentSetting->clock; + HW_SPI_init.Databit = _currentSetting->dataSize; + + /** + * SPI Mode CPOL CPHA Shift SCK-edge Capture SCK-edge + * 0 0 0 Falling Rising + * 1 0 1 Rising Falling + * 2 1 0 Rising Falling + * 3 1 1 Falling Rising + */ + switch (_currentSetting->dataMode) { + case SPI_MODE0: + HW_SPI_init.CPHA = SSP_CPHA_FIRST; + HW_SPI_init.CPOL = SSP_CPOL_HI; + break; + case SPI_MODE1: + HW_SPI_init.CPHA = SSP_CPHA_SECOND; + HW_SPI_init.CPOL = SSP_CPOL_HI; + break; + case SPI_MODE2: + HW_SPI_init.CPHA = SSP_CPHA_FIRST; + HW_SPI_init.CPOL = SSP_CPOL_LO; + break; + case SPI_MODE3: + HW_SPI_init.CPHA = SSP_CPHA_SECOND; + HW_SPI_init.CPOL = SSP_CPOL_LO; + break; + default: + break; + } + + // TODO: handle bitOrder + SSP_Init(_currentSetting->spi_d, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers +} + +#if MISO_PIN == BOARD_SPI1_MISO_PIN + SPIClass SPI(1); +#elif MISO_PIN == BOARD_SPI2_MISO_PIN + SPIClass SPI(2); +#endif #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h b/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h index 7d4de40faac2..b9bc0bf82e61 100644 --- a/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h @@ -21,6 +21,13 @@ */ #pragma once -#if HAS_SPI_TFT || HAS_FSMC_TFT - #error "Sorry! TFT displays are not available for HAL/LPC1768." +#if HAS_FSMC_TFT + #error "Sorry! FSMC TFT displays are not current available for HAL/LPC1768." +#endif + +// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046' +#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT + #undef TOUCH_SCREEN + #undef TOUCH_SCREEN_CALIBRATION + #define HAS_TOUCH_XPT2046 1 #endif diff --git a/Marlin/src/HAL/LPC1768/include/SPI.h b/Marlin/src/HAL/LPC1768/include/SPI.h index 4acd9e7022a9..e2645b9290db 100644 --- a/Marlin/src/HAL/LPC1768/include/SPI.h +++ b/Marlin/src/HAL/LPC1768/include/SPI.h @@ -24,25 +24,139 @@ #include "../../shared/HAL_SPI.h" #include +#include +#include -#define MSBFIRST 1 -#define SPI_MODE3 0 +//#define MSBFIRST 1 + +#define SPI_MODE0 0 +#define SPI_MODE1 1 +#define SPI_MODE2 2 +#define SPI_MODE3 3 + +#define DATA_SIZE_8BIT SSP_DATABIT_8 +#define DATA_SIZE_16BIT SSP_DATABIT_16 + +#define SPI_CLOCK_DIV2 8333333 //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED +#define SPI_CLOCK_DIV4 4166667 //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED +#define SPI_CLOCK_DIV8 2083333 //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED +#define SPI_CLOCK_DIV16 1000000 //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED +#define SPI_CLOCK_DIV32 500000 //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5 +#define SPI_CLOCK_DIV64 250000 //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6 +#define SPI_CLOCK_DIV128 125000 //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h + +#define SPI_CLOCK_MAX SPI_CLOCK_DIV2 + +#define BOARD_NR_SPI 2 + +//#define BOARD_SPI1_NSS_PIN PA4 ?! +#define BOARD_SPI1_SCK_PIN P0_15 +#define BOARD_SPI1_MISO_PIN P0_17 +#define BOARD_SPI1_MOSI_PIN P0_18 + +//#define BOARD_SPI2_NSS_PIN PB12 ?! +#define BOARD_SPI2_SCK_PIN P0_07 +#define BOARD_SPI2_MISO_PIN P0_08 +#define BOARD_SPI2_MOSI_PIN P0_09 class SPISettings { - public: - SPISettings(uint32_t speed, int, int) : spi_speed(speed) {}; - uint32_t spiRate() const { return spi_speed; } - private: - uint32_t spi_speed; +public: + SPISettings(uint32_t speed, int, int) : spi_speed(speed) {}; + SPISettings(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) { + if (__builtin_constant_p(inClock)) + init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize); + else + init_MightInline(inClock, inBitOrder, inDataMode, inDataSize); + } + SPISettings() { + init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT); + } + + uint32_t spiRate() const { return spi_speed; } + +private: + void init_MightInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) { + init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize); + } + void init_AlwaysInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) __attribute__((__always_inline__)) { + clock = inClock; + bitOrder = inBitOrder; + dataMode = inDataMode; + dataSize = inDataSize; + } + + uint32_t spi_speed; + uint32_t clock; + uint32_t dataSize; + //uint32_t clockDivider; + uint8_t bitOrder; + uint8_t dataMode; + LPC_SSP_TypeDef *spi_d; + + friend class SPIClass; }; +/** + * @brief Wirish SPI interface. + * + * This is the same interface is available across HAL + * + * This implementation uses software slave management, so the caller + * is responsible for controlling the slave select line. + */ class SPIClass { - public: - void begin(); - void beginTransaction(const SPISettings&); - void endTransaction() {}; - uint8_t transfer(uint8_t data); - uint16_t transfer16(uint16_t data); +public: + /** + * @param spiPortNumber Number of the SPI port to manage. + */ + SPIClass(uint8_t spiPortNumber); + + /** + * Select and configure the current selected SPI device to use + */ + void begin(); + + /** + * Disable the current SPI device + */ + void end(); + + void beginTransaction(const SPISettings&); + void endTransaction() {}; + + // Transfer using 1 "Data Size" + uint8_t transfer(uint16_t data); + // Transfer 2 bytes in 8 bit mode + uint16_t transfer16(uint16_t data); + + void send(uint8_t data); + + uint16_t read(); + void read(uint8_t *buf, uint32_t len); + + void dmaSend(void *buf, uint16_t length, bool minc); + + /** + * @brief Sets the number of the SPI peripheral to be used by + * this HardwareSPI instance. + * + * @param spi_num Number of the SPI port. 1-2 in low density devices + * or 1-3 in high density devices. + */ + void setModule(uint8_t device); + + void setClock(uint32_t clock); + void setBitOrder(uint8_t bitOrder); + void setDataMode(uint8_t dataMode); + void setDataSize(uint32_t ds); + + inline uint32_t getDataSize() { return _currentSetting->dataSize; } + +private: + SPISettings _settings[BOARD_NR_SPI]; + SPISettings *_currentSetting; + + void updateSettings(); }; extern SPIClass SPI; diff --git a/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp b/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp new file mode 100644 index 000000000000..84907acd0702 --- /dev/null +++ b/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp @@ -0,0 +1,153 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if HAS_SPI_TFT + +#include "tft_spi.h" + +//TFT_SPI tft; + +SPIClass TFT_SPI::SPIx(1); + +#define TFT_CS_H WRITE(TFT_CS_PIN, HIGH) +#define TFT_CS_L WRITE(TFT_CS_PIN, LOW) + +#define TFT_DC_H WRITE(TFT_DC_PIN, HIGH) +#define TFT_DC_L WRITE(TFT_DC_PIN, LOW) + +#define TFT_RST_H WRITE(TFT_RESET_PIN, HIGH) +#define TFT_RST_L WRITE(TFT_RESET_PIN, LOW) + +#define TFT_BLK_H WRITE(TFT_BACKLIGHT_PIN, HIGH) +#define TFT_BLK_L WRITE(TFT_BACKLIGHT_PIN, LOW) + +void TFT_SPI::Init() { + #if PIN_EXISTS(TFT_RESET) + SET_OUTPUT(TFT_RESET_PIN); + TFT_RST_H; + delay(100); + #endif + + #if PIN_EXISTS(TFT_BACKLIGHT) + SET_OUTPUT(TFT_BACKLIGHT_PIN); + TFT_BLK_H; + #endif + + SET_OUTPUT(TFT_DC_PIN); + SET_OUTPUT(TFT_CS_PIN); + + TFT_DC_H; + TFT_CS_H; + + /** + * 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 + + #if TFT_MISO_PIN == BOARD_SPI1_MISO_PIN + SPIx.setModule(1); + #elif TFT_MISO_PIN == BOARD_SPI2_MISO_PIN + SPIx.setModule(2); + #endif + SPIx.setClock(SPI_CLOCK_MAX); + SPIx.setBitOrder(MSBFIRST); + SPIx.setDataMode(SPI_MODE0); +} + +void TFT_SPI::DataTransferBegin(uint16_t DataSize) { + SPIx.setDataSize(DataSize); + SPIx.begin(); + TFT_CS_L; +} + +uint32_t TFT_SPI::GetID() { + uint32_t id; + id = ReadID(LCD_READ_ID); + if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) + id = ReadID(LCD_READ_ID4); + return id; +} + +uint32_t TFT_SPI::ReadID(uint16_t Reg) { + uint32_t data = 0; + + #if PIN_EXISTS(TFT_MISO) + uint8_t d = 0; + SPIx.setDataSize(DATASIZE_8BIT); + SPIx.setClock(SPI_CLOCK_DIV64); + SPIx.begin(); + TFT_CS_L; + WriteReg(Reg); + + LOOP_L_N(i, 4) { + SPIx.read((uint8_t*)&d, 1); + data = (data << 8) | d; + } + + DataTransferEnd(); + SPIx.setClock(SPI_CLOCK_MAX); + #endif + + return data >> 7; +} + +bool TFT_SPI::isBusy() { + return false; +} + +void TFT_SPI::Abort() { + DataTransferEnd(); +} + +void TFT_SPI::Transmit(uint16_t Data) { + SPIx.transfer(Data); +} + +void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + DataTransferBegin(DATASIZE_16BIT); //16 + TFT_DC_H; + SPIx.dmaSend(Data, Count, MemoryIncrease); + DataTransferEnd(); +} + +#endif // HAS_SPI_TFT diff --git a/Marlin/src/HAL/LPC1768/tft/tft_spi.h b/Marlin/src/HAL/LPC1768/tft/tft_spi.h new file mode 100644 index 000000000000..8d3e3127bbd1 --- /dev/null +++ b/Marlin/src/HAL/LPC1768/tft/tft_spi.h @@ -0,0 +1,77 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "../../../inc/MarlinConfig.h" + +#include +#include +// #include + +#ifndef LCD_READ_ID + #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341) +#endif +#ifndef LCD_READ_ID4 + #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341) +#endif + +#define DATASIZE_8BIT SSP_DATABIT_8 +#define DATASIZE_16BIT SSP_DATABIT_16 +#define TFT_IO TFT_SPI + +#define DMA_MINC_ENABLE 1 +#define DMA_MINC_DISABLE 0 + +class TFT_SPI { +private: + static uint32_t ReadID(uint16_t Reg); + static void Transmit(uint16_t Data); + static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); + +public: + static SPIClass SPIx; + + static void Init(); + static uint32_t GetID(); + static bool isBusy(); + static void Abort(); + + static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT); + static void DataTransferEnd() { OUT_WRITE(TFT_CS_PIN, HIGH); SPIx.end(); }; + 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 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 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; + } + #undef MAX_DMA_SIZE + } +}; diff --git a/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp b/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp new file mode 100644 index 000000000000..c72e5f0eac44 --- /dev/null +++ b/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp @@ -0,0 +1,129 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if HAS_TFT_XPT2046 || HAS_TOUCH_XPT2046 + +#include "xpt2046.h" +#include + +uint16_t delta(uint16_t a, uint16_t b) { return a > b ? a - b : b - a; } + +#if ENABLED(TOUCH_BUTTONS_HW_SPI) + #include + + SPIClass XPT2046::SPIx(TOUCH_BUTTONS_HW_SPI_DEVICE); + + static void touch_spi_init(uint8_t spiRate) { + XPT2046::SPIx.setModule(TOUCH_BUTTONS_HW_SPI_DEVICE); + XPT2046::SPIx.setClock(SPI_CLOCK_DIV128); + XPT2046::SPIx.setBitOrder(MSBFIRST); + XPT2046::SPIx.setDataMode(SPI_MODE0); + XPT2046::SPIx.setDataSize(DATA_SIZE_8BIT); + } +#endif + +void XPT2046::Init() { + SET_INPUT(TOUCH_MISO_PIN); + SET_OUTPUT(TOUCH_MOSI_PIN); + SET_OUTPUT(TOUCH_SCK_PIN); + OUT_WRITE(TOUCH_CS_PIN, HIGH); + + #if PIN_EXISTS(TOUCH_INT) + // Optional Pendrive interrupt pin + SET_INPUT(TOUCH_INT_PIN); + #endif + + TERN_(TOUCH_BUTTONS_HW_SPI, touch_spi_init(SPI_SPEED_6)); + + // Read once to enable pendrive status pin + getRawData(XPT2046_X); +} + +bool XPT2046::isTouched() { + return isBusy() ? false : ( + #if PIN_EXISTS(TOUCH_INT) + READ(TOUCH_INT_PIN) != HIGH + #else + getRawData(XPT2046_Z1) >= XPT2046_Z1_THRESHOLD + #endif + ); +} + +bool XPT2046::getRawPoint(int16_t *x, int16_t *y) { + if (isBusy()) return false; + if (!isTouched()) return false; + *x = getRawData(XPT2046_X); + *y = getRawData(XPT2046_Y); + SERIAL_ECHOLNPAIR("X: ", *x, ", Y: ", *y); + return isTouched(); +} + +uint16_t XPT2046::getRawData(const XPTCoordinate coordinate) { + uint16_t data[3]; + + DataTransferBegin(); + TERN_(TOUCH_BUTTONS_HW_SPI, SPIx.begin()); + + for (uint16_t i = 0; i < 3 ; i++) { + IO(coordinate); + data[i] = (IO() << 4) | (IO() >> 4); + } + + TERN_(TOUCH_BUTTONS_HW_SPI, SPIx.end()); + DataTransferEnd(); + + uint16_t delta01 = delta(data[0], data[1]), + delta02 = delta(data[0], data[2]), + delta12 = delta(data[1], data[2]); + + if (delta01 > delta02 || delta01 > delta12) + data[delta02 > delta12 ? 0 : 1] = data[2]; + + return (data[0] + data[1]) >> 1; +} + +uint16_t XPT2046::IO(uint16_t data) { + return TERN(TOUCH_BUTTONS_HW_SPI, HardwareIO, SoftwareIO)(data); +} + +extern uint8_t spiTransfer(uint8_t b); + +#if ENABLED(TOUCH_BUTTONS_HW_SPI) + uint16_t XPT2046::HardwareIO(uint16_t data) { + return SPIx.transfer(data & 0xFF); + } +#endif + +uint16_t XPT2046::SoftwareIO(uint16_t data) { + uint16_t result = 0; + + for (uint8_t j = 0x80; j; j >>= 1) { + WRITE(TOUCH_SCK_PIN, LOW); + WRITE(TOUCH_MOSI_PIN, data & j ? HIGH : LOW); + if (READ(TOUCH_MISO_PIN)) result |= j; + WRITE(TOUCH_SCK_PIN, HIGH); + } + WRITE(TOUCH_SCK_PIN, LOW); + + return result; +} + +#endif // HAS_TFT_XPT2046 diff --git a/Marlin/src/HAL/LPC1768/tft/xpt2046.h b/Marlin/src/HAL/LPC1768/tft/xpt2046.h new file mode 100644 index 000000000000..019f75efce12 --- /dev/null +++ b/Marlin/src/HAL/LPC1768/tft/xpt2046.h @@ -0,0 +1,80 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "../../../inc/MarlinConfig.h" + +#if ENABLED(TOUCH_BUTTONS_HW_SPI) + #include +#endif + +#ifndef TOUCH_MISO_PIN + #define TOUCH_MISO_PIN MISO_PIN +#endif +#ifndef TOUCH_MOSI_PIN + #define TOUCH_MOSI_PIN MOSI_PIN +#endif +#ifndef TOUCH_SCK_PIN + #define TOUCH_SCK_PIN SCK_PIN +#endif +#ifndef TOUCH_CS_PIN + #define TOUCH_CS_PIN CS_PIN +#endif +#ifndef TOUCH_INT_PIN + #define TOUCH_INT_PIN -1 +#endif + +#define XPT2046_DFR_MODE 0x00 +#define XPT2046_SER_MODE 0x04 +#define XPT2046_CONTROL 0x80 + +enum XPTCoordinate : uint8_t { + XPT2046_X = 0x10 | XPT2046_CONTROL | XPT2046_DFR_MODE, + XPT2046_Y = 0x50 | XPT2046_CONTROL | XPT2046_DFR_MODE, + XPT2046_Z1 = 0x30 | XPT2046_CONTROL | XPT2046_DFR_MODE, + XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE, +}; + +#if !defined(XPT2046_Z1_THRESHOLD) + #define XPT2046_Z1_THRESHOLD 10 +#endif + +class XPT2046 { +private: + static bool isBusy() { return false; } + + static uint16_t getRawData(const XPTCoordinate coordinate); + static bool isTouched(); + + static inline void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; + static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; + #if ENABLED(TOUCH_BUTTONS_HW_SPI) + static uint16_t HardwareIO(uint16_t data); + #endif + static uint16_t SoftwareIO(uint16_t data); + static uint16_t IO(uint16_t data = 0); + +public: + #if ENABLED(TOUCH_BUTTONS_HW_SPI) + static SPIClass SPIx; + #endif + + static void Init(); + static bool getRawPoint(int16_t *x, int16_t *y); +}; diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 5a0b0460092b..f76d8c54a0e3 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -46,6 +46,8 @@ #include "msc_sd.h" #endif +#include "MarlinSerial.h" + // ------------------------ // Defines // ------------------------ @@ -64,17 +66,6 @@ #else #define UsbSerial MarlinCompositeSerial #endif - #define MSerial1 Serial1 - #define MSerial2 Serial2 - #define MSerial3 Serial3 - #define MSerial4 Serial4 - #define MSerial5 Serial5 -#else - #define MSerial1 Serial - #define MSerial2 Serial1 - #define MSerial3 Serial2 - #define MSerial4 Serial3 - #define MSerial5 Serial4 #endif #if SERIAL_PORT == 0 diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.cpp b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp new file mode 100644 index 000000000000..f965bc99cf06 --- /dev/null +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp @@ -0,0 +1,93 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../inc/MarlinConfigPre.h" +#include "MarlinSerial.h" +#include + +// Copied from ~/.platformio/packages/framework-arduinoststm32-maple/STM32F1/system/libmaple/usart_private.h +// Changed to handle Emergency Parser +static inline __always_inline void my_usart_irq(ring_buffer *rb, ring_buffer *wb, usart_reg_map *regs, MarlinSerial &serial) { + /* Handle RXNEIE and TXEIE interrupts. + * RXNE signifies availability of a byte in DR. + * + * See table 198 (sec 27.4, p809) in STM document RM0008 rev 15. + * We enable RXNEIE. + */ + if ((regs->CR1 & USART_CR1_RXNEIE) && (regs->SR & USART_SR_RXNE)) { + uint8_t c = (uint8)regs->DR; + #ifdef USART_SAFE_INSERT + // If the buffer is full and the user defines USART_SAFE_INSERT, + // ignore new bytes. + rb_safe_insert(rb, c); + #else + // By default, push bytes around in the ring buffer. + rb_push_insert(rb, c); + #endif + #if ENABLED(EMERGENCY_PARSER) + emergency_parser.update(serial.emergency_state, c); + #endif + } + // TXE signifies readiness to send a byte to DR. + if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) { + if (!rb_is_empty(wb)) + regs->DR=rb_remove(wb); + else + regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE + } +} + +#define DEFINE_HWSERIAL_MARLIN(name, n) \ + MarlinSerial name(USART##n, \ + BOARD_USART##n##_TX_PIN, \ + BOARD_USART##n##_RX_PIN); \ + extern "C" void __irq_usart##n(void) { \ + my_usart_irq(USART##n->rb, USART##n->wb, USART##n##_BASE, MSerial##n); \ + } + +#define DEFINE_HWSERIAL_UART_MARLIN(name, n) \ + MarlinSerial name(UART##n, \ + BOARD_USART##n##_TX_PIN, \ + BOARD_USART##n##_RX_PIN); \ + extern "C" void __irq_usart##n(void) { \ + my_usart_irq(USART##n->rb, USART##n->wb, USART##n##_BASE, MSerial##n); \ + } + +#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1 + DEFINE_HWSERIAL_MARLIN(MSerial1, 1); +#endif + +#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2 + DEFINE_HWSERIAL_MARLIN(MSerial2, 2); +#endif + +#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3 + DEFINE_HWSERIAL_MARLIN(MSerial3, 3); +#endif + +#if SERIAL_PORT == 4 || SERIAL_PORT_2 == 4 || DGUS_SERIAL_PORT == 4 + DEFINE_HWSERIAL_UART_MARLIN(MSerial4, 4); +#endif + +#if SERIAL_PORT == 5 || SERIAL_PORT_2 == 5 || DGUS_SERIAL_PORT == 5 + DEFINE_HWSERIAL_UART_MARLIN(MSerial5, 5); +#endif diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.h b/Marlin/src/HAL/STM32F1/MarlinSerial.h new file mode 100644 index 000000000000..4e8a47d2f909 --- /dev/null +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.h @@ -0,0 +1,50 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include +#include + +#include "../../inc/MarlinConfigPre.h" +#if ENABLED(EMERGENCY_PARSER) + #include "../../feature/e_parser.h" +#endif + +class MarlinSerial : public HardwareSerial { +public: + MarlinSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) : + HardwareSerial(usart_device, tx_pin, rx_pin) + #if ENABLED(EMERGENCY_PARSER) + , emergency_state(EmergencyParser::State::EP_RESET) + #endif + { } + + #if ENABLED(EMERGENCY_PARSER) + EmergencyParser::State emergency_state; + #endif +}; + +extern MarlinSerial MSerial1; +extern MarlinSerial MSerial2; +extern MarlinSerial MSerial3; +extern MarlinSerial MSerial4; +extern MarlinSerial MSerial5; diff --git a/Marlin/src/HAL/STM32F1/SPI.cpp b/Marlin/src/HAL/STM32F1/SPI.cpp index 423772dbc948..0452cf629390 100644 --- a/Marlin/src/HAL/STM32F1/SPI.cpp +++ b/Marlin/src/HAL/STM32F1/SPI.cpp @@ -40,6 +40,9 @@ #include #include +#include "../../inc/MarlinConfig.h" +#include "spi_pins.h" + /** Time in ms for DMA receive timeout */ #define DMA_TIMEOUT 100 @@ -710,6 +713,6 @@ static spi_baud_rate determine_baud_rate(spi_dev *dev, uint32_t freq) { return baud_rates[i]; } -SPIClass SPI(1); +SPIClass SPI(SPI_DEVICE); #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_fsmc.cpp b/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_fsmc.cpp deleted file mode 100644 index 445e53b67f54..000000000000 --- a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_fsmc.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * u8g_com_stm32duino_fsmc.cpp - * - * Communication interface for FSMC - */ - -#include "../../../inc/MarlinConfig.h" - -#if defined(ARDUINO_ARCH_STM32F1) && PIN_EXISTS(FSMC_CS) // FSMC on 100/144 pins SoCs - -#if HAS_GRAPHICAL_LCD - -#include -#include -#include -#include -#include - -#ifndef LCD_READ_ID - #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341) -#endif - -/* Timing configuration */ -#define FSMC_ADDRESS_SETUP_TIME 15 // AddressSetupTime -#define FSMC_DATA_SETUP_TIME 15 // DataSetupTime - -void LCD_IO_Init(uint8_t cs, uint8_t rs); -void LCD_IO_WriteData(uint16_t RegValue); -void LCD_IO_WriteReg(uint16_t Reg); -uint16_t LCD_IO_ReadData(uint16_t RegValue); -uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize); -#ifdef LCD_USE_DMA_FSMC - void LCD_IO_WriteMultiple(uint16_t data, uint32_t count); - void LCD_IO_WriteSequence(uint16_t *data, uint16_t length); -#endif - -static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT - -uint8_t u8g_com_stm32duino_fsmc_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { - if (msgInitCount) { - if (msg == U8G_COM_MSG_INIT) msgInitCount--; - if (msgInitCount) return -1; - } - - static uint8_t isCommand; - - switch (msg) { - case U8G_COM_MSG_STOP: break; - case U8G_COM_MSG_INIT: - u8g_SetPIOutput(u8g, U8G_PI_RESET); - - #ifdef LCD_USE_DMA_FSMC - dma_init(FSMC_DMA_DEV); - dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); - dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM); - #endif - - LCD_IO_Init(u8g->pin_list[U8G_PI_CS], u8g->pin_list[U8G_PI_A0]); - u8g_Delay(50); - - if (arg_ptr) { - *((uint32_t *)arg_ptr) = LCD_IO_ReadData(0x0000); - if (*((uint32_t *)arg_ptr) == 0) - *((uint32_t *)arg_ptr) = (LCD_READ_ID << 24) | LCD_IO_ReadData(LCD_READ_ID, 3); - } - isCommand = 0; - break; - - case U8G_COM_MSG_ADDRESS: // define cmd (arg_val = 0) or data mode (arg_val = 1) - isCommand = arg_val == 0 ? 1 : 0; - break; - - case U8G_COM_MSG_RESET: - u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); - break; - - case U8G_COM_MSG_WRITE_BYTE: - if (isCommand) - LCD_IO_WriteReg(arg_val); - else - LCD_IO_WriteData((uint16_t)arg_val); - break; - - case U8G_COM_MSG_WRITE_SEQ: - for (uint8_t i = 0; i < arg_val; i += 2) - LCD_IO_WriteData(*(uint16_t *)(((uint32_t)arg_ptr) + i)); - break; - } - return 1; -} - -/** - * FSMC LCD IO - */ -#define __ASM __asm -#define __STATIC_INLINE static inline - -__attribute__((always_inline)) __STATIC_INLINE void __DSB() { - __ASM volatile ("dsb 0xF":::"memory"); -} - -#define FSMC_CS_NE1 PD7 - -#if ENABLED(STM32_XL_DENSITY) - #define FSMC_CS_NE2 PG9 - #define FSMC_CS_NE3 PG10 - #define FSMC_CS_NE4 PG12 - - #define FSMC_RS_A0 PF0 - #define FSMC_RS_A1 PF1 - #define FSMC_RS_A2 PF2 - #define FSMC_RS_A3 PF3 - #define FSMC_RS_A4 PF4 - #define FSMC_RS_A5 PF5 - #define FSMC_RS_A6 PF12 - #define FSMC_RS_A7 PF13 - #define FSMC_RS_A8 PF14 - #define FSMC_RS_A9 PF15 - #define FSMC_RS_A10 PG0 - #define FSMC_RS_A11 PG1 - #define FSMC_RS_A12 PG2 - #define FSMC_RS_A13 PG3 - #define FSMC_RS_A14 PG4 - #define FSMC_RS_A15 PG5 -#endif - -#define FSMC_RS_A16 PD11 -#define FSMC_RS_A17 PD12 -#define FSMC_RS_A18 PD13 -#define FSMC_RS_A19 PE3 -#define FSMC_RS_A20 PE4 -#define FSMC_RS_A21 PE5 -#define FSMC_RS_A22 PE6 -#define FSMC_RS_A23 PE2 - -#if ENABLED(STM32_XL_DENSITY) - #define FSMC_RS_A24 PG13 - #define FSMC_RS_A25 PG14 -#endif - -static uint8_t fsmcInit = 0; - -typedef struct { - __IO uint16_t REG; - __IO uint16_t RAM; -} LCD_CONTROLLER_TypeDef; - -LCD_CONTROLLER_TypeDef *LCD; - -void LCD_IO_Init(uint8_t cs, uint8_t rs) { - uint32_t controllerAddress; - struct fsmc_nor_psram_reg_map* fsmcPsramRegion; - - if (fsmcInit) return; - fsmcInit = 1; - - switch (cs) { - case FSMC_CS_NE1: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION1; fsmcPsramRegion = FSMC_NOR_PSRAM1_BASE; break; - #if ENABLED(STM32_XL_DENSITY) - case FSMC_CS_NE2: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION2; fsmcPsramRegion = FSMC_NOR_PSRAM2_BASE; break; - case FSMC_CS_NE3: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION3; fsmcPsramRegion = FSMC_NOR_PSRAM3_BASE; break; - case FSMC_CS_NE4: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION4; fsmcPsramRegion = FSMC_NOR_PSRAM4_BASE; break; - #endif - default: return; - } - - #define _ORADDR(N) controllerAddress |= (_BV32(N) - 2) - - switch (rs) { - #if ENABLED(STM32_XL_DENSITY) - case FSMC_RS_A0: _ORADDR( 1); break; - case FSMC_RS_A1: _ORADDR( 2); break; - case FSMC_RS_A2: _ORADDR( 3); break; - case FSMC_RS_A3: _ORADDR( 4); break; - case FSMC_RS_A4: _ORADDR( 5); break; - case FSMC_RS_A5: _ORADDR( 6); break; - case FSMC_RS_A6: _ORADDR( 7); break; - case FSMC_RS_A7: _ORADDR( 8); break; - case FSMC_RS_A8: _ORADDR( 9); break; - case FSMC_RS_A9: _ORADDR(10); break; - case FSMC_RS_A10: _ORADDR(11); break; - case FSMC_RS_A11: _ORADDR(12); break; - case FSMC_RS_A12: _ORADDR(13); break; - case FSMC_RS_A13: _ORADDR(14); break; - case FSMC_RS_A14: _ORADDR(15); break; - case FSMC_RS_A15: _ORADDR(16); break; - #endif - case FSMC_RS_A16: _ORADDR(17); break; - case FSMC_RS_A17: _ORADDR(18); break; - case FSMC_RS_A18: _ORADDR(19); break; - case FSMC_RS_A19: _ORADDR(20); break; - case FSMC_RS_A20: _ORADDR(21); break; - case FSMC_RS_A21: _ORADDR(22); break; - case FSMC_RS_A22: _ORADDR(23); break; - case FSMC_RS_A23: _ORADDR(24); break; - #if ENABLED(STM32_XL_DENSITY) - case FSMC_RS_A24: _ORADDR(25); break; - case FSMC_RS_A25: _ORADDR(26); break; - #endif - default: return; - } - - rcc_clk_enable(RCC_FSMC); - - gpio_set_mode(GPIOD, 14, GPIO_AF_OUTPUT_PP); // FSMC_D00 - gpio_set_mode(GPIOD, 15, GPIO_AF_OUTPUT_PP); // FSMC_D01 - gpio_set_mode(GPIOD, 0, GPIO_AF_OUTPUT_PP); // FSMC_D02 - gpio_set_mode(GPIOD, 1, GPIO_AF_OUTPUT_PP); // FSMC_D03 - gpio_set_mode(GPIOE, 7, GPIO_AF_OUTPUT_PP); // FSMC_D04 - gpio_set_mode(GPIOE, 8, GPIO_AF_OUTPUT_PP); // FSMC_D05 - gpio_set_mode(GPIOE, 9, GPIO_AF_OUTPUT_PP); // FSMC_D06 - gpio_set_mode(GPIOE, 10, GPIO_AF_OUTPUT_PP); // FSMC_D07 - gpio_set_mode(GPIOE, 11, GPIO_AF_OUTPUT_PP); // FSMC_D08 - gpio_set_mode(GPIOE, 12, GPIO_AF_OUTPUT_PP); // FSMC_D09 - gpio_set_mode(GPIOE, 13, GPIO_AF_OUTPUT_PP); // FSMC_D10 - gpio_set_mode(GPIOE, 14, GPIO_AF_OUTPUT_PP); // FSMC_D11 - gpio_set_mode(GPIOE, 15, GPIO_AF_OUTPUT_PP); // FSMC_D12 - gpio_set_mode(GPIOD, 8, GPIO_AF_OUTPUT_PP); // FSMC_D13 - gpio_set_mode(GPIOD, 9, GPIO_AF_OUTPUT_PP); // FSMC_D14 - gpio_set_mode(GPIOD, 10, GPIO_AF_OUTPUT_PP); // FSMC_D15 - - gpio_set_mode(GPIOD, 4, GPIO_AF_OUTPUT_PP); // FSMC_NOE - gpio_set_mode(GPIOD, 5, GPIO_AF_OUTPUT_PP); // FSMC_NWE - - gpio_set_mode(PIN_MAP[cs].gpio_device, PIN_MAP[cs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_CS_NEx - gpio_set_mode(PIN_MAP[rs].gpio_device, PIN_MAP[rs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_RS_Ax - - fsmcPsramRegion->BCR = FSMC_BCR_WREN | FSMC_BCR_MTYP_SRAM | FSMC_BCR_MWID_16BITS | FSMC_BCR_MBKEN; - fsmcPsramRegion->BTR = (FSMC_DATA_SETUP_TIME << 8) | FSMC_ADDRESS_SETUP_TIME; - - afio_remap(AFIO_REMAP_FSMC_NADV); - - LCD = (LCD_CONTROLLER_TypeDef*)controllerAddress; -} - -void LCD_IO_WriteData(uint16_t RegValue) { - LCD->RAM = RegValue; - __DSB(); -} - -void LCD_IO_WriteReg(uint16_t Reg) { - LCD->REG = Reg; - __DSB(); -} - -uint16_t LCD_IO_ReadData(uint16_t RegValue) { - LCD->REG = RegValue; - __DSB(); - - return LCD->RAM; -} - -uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) { - volatile uint32_t data; - LCD->REG = RegValue; - __DSB(); - - data = LCD->RAM; // dummy read - data = LCD->RAM & 0x00FF; - - while (--ReadSize) { - data <<= 8; - data |= (LCD->RAM & 0x00FF); - } - return uint32_t(data); -} - -#ifdef LCD_USE_DMA_FSMC - -void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) { - while (count > 0) { - dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, &color, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM); - dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, count > 65535 ? 65535 : 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); - - count = count > 65535 ? count - 65535 : 0; - } -} - -void LCD_IO_WriteSequence(uint16_t *data, uint16_t length) { - dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | DMA_PINC_MODE); - dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, length); - 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); -} - -void LCD_IO_WriteSequence_Async(uint16_t *data, uint16_t length) { - dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | DMA_PINC_MODE); - dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, length); - dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); - dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); -} - -void LCD_IO_WaitSequence_Async() { - while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {}; - dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); -} - -#endif // LCD_USE_DMA_FSMC - -#endif // HAS_GRAPHICAL_LCD -#endif // ARDUINO_ARCH_STM32F1 && FSMC_CS_PIN diff --git a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_hwspi.cpp b/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_hwspi.cpp deleted file mode 100644 index 206c3fda3d3f..000000000000 --- a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_hwspi.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#ifdef __STM32F1__ - -#include "../../../inc/MarlinConfig.h" - -#if ENABLED(SPI_GRAPHICAL_TFT) && DISABLED(FORCE_SOFT_SPI) - -#include "../HAL.h" -#include -#include - -#define SPI_TFT_CS_H OUT_WRITE(SPI_TFT_CS_PIN, HIGH) -#define SPI_TFT_CS_L OUT_WRITE(SPI_TFT_CS_PIN, LOW) - -#define SPI_TFT_DC_H OUT_WRITE(SPI_TFT_DC_PIN, HIGH) -#define SPI_TFT_DC_L OUT_WRITE(SPI_TFT_DC_PIN, LOW) - -#define SPI_TFT_RST_H OUT_WRITE(SPI_TFT_RST_PIN, HIGH) -#define SPI_TFT_RST_L OUT_WRITE(SPI_TFT_RST_PIN, LOW) - -#define SPI_TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH) -#define SPI_TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW) - -void LCD_IO_Init(uint8_t cs, uint8_t rs); -void LCD_IO_WriteData(uint16_t RegValue); -void LCD_IO_WriteReg(uint16_t Reg); -uint16_t LCD_IO_ReadData(uint16_t RegValue); -uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize); -#ifdef LCD_USE_DMA_SPI - void LCD_IO_WriteMultiple(uint16_t data, uint32_t count); - void LCD_IO_WriteSequence(uint16_t *data, uint16_t length); -#endif - -void LCD_WR_REG(uint8_t cmd) { - SPI_TFT_CS_L; - SPI_TFT_DC_L; - SPI.send(cmd); - SPI_TFT_CS_H; -} -void LCD_WR_DATA(uint8_t data) { - SPI_TFT_CS_L; - SPI_TFT_DC_H; - SPI.send(data); - SPI_TFT_CS_H; -} - -void spi1Init(uint8_t spiRate) { - SPI_TFT_CS_H; - - /** - * 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 - */ - uint8_t clock; - switch (spiRate) { - case SPI_FULL_SPEED: clock = SPI_CLOCK_DIV4; 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 - } - SPI.setModule(1); - SPI.begin(); - SPI.setClockDivider(clock); - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); -} - -void LCD_IO_Init(uint8_t cs, uint8_t rs) { - spi1Init(SPI_FULL_SPEED); -} - -void LCD_IO_WriteData(uint16_t RegValue) { - LCD_WR_DATA(RegValue); -} - -void LCD_IO_WriteReg(uint16_t Reg) { - LCD_WR_REG(Reg); -} - -uint16_t LCD_IO_ReadData(uint16_t RegValue) { - uint16_t d = 0; - SPI_TFT_CS_L; - - SPI_TFT_DC_L; - SPI.send(RegValue); - SPI_TFT_DC_H; - - SPI.read((uint8_t*)&d, 1); //dummy read - SPI.read((uint8_t*)&d, 1); - - SPI_TFT_CS_H; - return d >> 7; -} - -uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) { - uint32_t data = 0; - uint8_t d = 0; - SPI_TFT_CS_L; - - SPI_TFT_DC_L; - SPI.send(RegValue); - SPI_TFT_DC_H; - - SPI.read((uint8_t*)&d, 1); //dummy read - SPI.read((uint8_t*)&d, 1); - data = d; - while (--ReadSize) { - data <<= 8; - SPI.read((uint8_t*)&d, 1); - data |= (d & 0xFF); - } - - SPI_TFT_CS_H; - return uint32_t(data >> 7); -} - -#ifdef LCD_USE_DMA_SPI - void LCD_IO_WriteMultiple(uint16_t data, uint32_t count) { - if (SPI.getDataSize() == DATA_SIZE_8BIT) { - count *= 2; - } - while (count > 0) { - SPI_TFT_CS_L; - SPI_TFT_DC_H; - SPI.dmaSend(&data, 1, true); - SPI_TFT_CS_H; - count--; - } - } - - void LCD_IO_WriteSequence(uint16_t *data, uint16_t length) { - if (SPI.getDataSize() == DATA_SIZE_8BIT) { - length *= 2; - } - SPI_TFT_CS_L; - SPI_TFT_DC_H; - SPI.dmaSend(data, length, true); - SPI_TFT_CS_H; - } - - void LCD_IO_WriteSequence_Async(uint16_t *data, uint16_t length) { - if (SPI.getDataSize() == DATA_SIZE_8BIT) { - length *= 2; - } - SPI_TFT_CS_L; - SPI_TFT_DC_H; - SPI.dmaSendAsync(data, length, true); - SPI_TFT_CS_H; - } - - void LCD_IO_WaitSequence_Async() { - SPI_TFT_CS_L; - SPI_TFT_DC_H; - SPI.dmaSendAsync(NULL, 0, true); - SPI_TFT_CS_H; - } -#endif - -static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT - -#ifndef LCD_READ_ID - #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341) -#endif - -uint8_t u8g_com_stm32duino_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { - if (msgInitCount) { - if (msg == U8G_COM_MSG_INIT) msgInitCount--; - if (msgInitCount) return -1; - } - - static uint8_t isCommand; - - LCD_IO_Init(-1, -1); - - switch (msg) { - case U8G_COM_MSG_STOP: break; - case U8G_COM_MSG_INIT: - u8g_SetPIOutput(u8g, U8G_PI_RESET); - - u8g_Delay(50); - - if (arg_ptr) { - spi1Init(SPI_EIGHTH_SPEED); - *((uint32_t *)arg_ptr) = (LCD_READ_ID << 24) | LCD_IO_ReadData(LCD_READ_ID, 3); - spi1Init(SPI_FULL_SPEED); - } - isCommand = 0; - break; - - case U8G_COM_MSG_ADDRESS: // define cmd (arg_val = 0) or data mode (arg_val = 1) - isCommand = arg_val == 0 ? 1 : 0; - break; - - case U8G_COM_MSG_RESET: - u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); - break; - - case U8G_COM_MSG_WRITE_BYTE: - if (isCommand) - LCD_IO_WriteReg(arg_val); - else - LCD_IO_WriteData((uint16_t)arg_val); - break; - - case U8G_COM_MSG_WRITE_SEQ: - for (uint8_t i = 0; i < arg_val; i += 2) - LCD_IO_WriteData(*(uint16_t *)(((uint32_t)arg_ptr) + i)); - break; - - } - return 1; -} - -#endif // SPI_GRAPHICAL_TFT && !FORCE_SOFT_SPI -#endif // STM32F1 diff --git a/Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h b/Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h index 09d79030b53e..25110d7c80e4 100644 --- a/Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h @@ -26,8 +26,8 @@ #undef SD_CHECK_AND_RETRY #endif -// This platform has 'touch/xpt2046', not 'tft/xpt2046' -#if ENABLED(TOUCH_SCREEN) && !HAS_FSMC_TFT && !HAS_SPI_TFT +// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046' +#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT #undef TOUCH_SCREEN #undef TOUCH_SCREEN_CALIBRATION #define HAS_TOUCH_XPT2046 1 diff --git a/Marlin/src/HAL/STM32F1/inc/SanityCheck.h b/Marlin/src/HAL/STM32F1/inc/SanityCheck.h index c0cb48695253..9d5026fbab10 100644 --- a/Marlin/src/HAL/STM32F1/inc/SanityCheck.h +++ b/Marlin/src/HAL/STM32F1/inc/SanityCheck.h @@ -25,10 +25,6 @@ * Test STM32F1-specific configuration values for errors at compile-time. */ -#if ENABLED(EMERGENCY_PARSER) - #error "EMERGENCY_PARSER is not yet implemented for STM32F1. Disable EMERGENCY_PARSER to continue." -#endif - #if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on STM32F1." #endif diff --git a/Marlin/src/HAL/STM32F1/msc_sd.cpp b/Marlin/src/HAL/STM32F1/msc_sd.cpp index ab5530174e3b..6a4652e467fb 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.cpp +++ b/Marlin/src/HAL/STM32F1/msc_sd.cpp @@ -21,7 +21,7 @@ #define PRODUCT_ID 0x29 USBMassStorage MarlinMSC; -USBCompositeSerial MarlinCompositeSerial; +MarlinUSBCompositeSerial MarlinCompositeSerial; #include "../../inc/MarlinConfig.h" @@ -38,6 +38,17 @@ USBCompositeSerial MarlinCompositeSerial; #endif +#if ENABLED(EMERGENCY_PARSER) + void (*real_rx_callback)(void); + + void my_rx_callback(void) { + real_rx_callback(); + int len = MarlinCompositeSerial.available(); + while (len-- > 0) // >0 because available() may return a negative value + emergency_parser.update(MarlinCompositeSerial.emergency_state, MarlinCompositeSerial.peek()); + } +#endif + void MSC_SD_init() { USBComposite.setProductId(PRODUCT_ID); // Just set MarlinCompositeSerial enabled to true @@ -59,6 +70,11 @@ void MSC_SD_init() { // Register composite Serial MarlinCompositeSerial.registerComponent(); USBComposite.begin(); + #if ENABLED(EMERGENCY_PARSER) + //rx is usbSerialPart.endpoints[2] + real_rx_callback = usbSerialPart.endpoints[2].callback; + usbSerialPart.endpoints[2].callback = my_rx_callback; + #endif } #endif // USE_USB_COMPOSITE diff --git a/Marlin/src/HAL/STM32F1/msc_sd.h b/Marlin/src/HAL/STM32F1/msc_sd.h index 8715888f474c..d9cdbe6bb3d1 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.h +++ b/Marlin/src/HAL/STM32F1/msc_sd.h @@ -17,7 +17,25 @@ #include +#include "../../inc/MarlinConfigPre.h" +#if ENABLED(EMERGENCY_PARSER) + #include "../../feature/e_parser.h" +#endif + +class MarlinUSBCompositeSerial : public USBCompositeSerial { +public: + MarlinUSBCompositeSerial() : USBCompositeSerial() + #if ENABLED(EMERGENCY_PARSER) + , emergency_state(EmergencyParser::State::EP_RESET) + #endif + { } + + #if ENABLED(EMERGENCY_PARSER) + EmergencyParser::State emergency_state; + #endif +}; + extern USBMassStorage MarlinMSC; -extern USBCompositeSerial MarlinCompositeSerial; +extern MarlinUSBCompositeSerial MarlinCompositeSerial; void MSC_SD_init(); diff --git a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp index e0047e7d5910..bc1b012dc788 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp @@ -22,7 +22,7 @@ #include "../../../inc/MarlinConfig.h" -#if HAS_FSMC_TFT || ENABLED(TFT_LVGL_UI_FSMC) +#if HAS_FSMC_TFT #include "tft_fsmc.h" #include diff --git a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp index 2610262b0f2c..1095389946ad 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp @@ -22,7 +22,7 @@ #include "../../../inc/MarlinConfig.h" -#if HAS_SPI_TFT || ENABLED(TFT_LVGL_UI_SPI) +#if HAS_SPI_TFT #include "tft_spi.h" @@ -30,32 +30,32 @@ SPIClass TFT_SPI::SPIx(1); -#define SPI_TFT_CS_H OUT_WRITE(TFT_CS_PIN, HIGH) -#define SPI_TFT_CS_L OUT_WRITE(TFT_CS_PIN, LOW) +#define TFT_CS_H OUT_WRITE(TFT_CS_PIN, HIGH) +#define TFT_CS_L OUT_WRITE(TFT_CS_PIN, LOW) -#define SPI_TFT_DC_H OUT_WRITE(TFT_DC_PIN, HIGH) -#define SPI_TFT_DC_L OUT_WRITE(TFT_DC_PIN, LOW) +#define TFT_DC_H OUT_WRITE(TFT_DC_PIN, HIGH) +#define TFT_DC_L OUT_WRITE(TFT_DC_PIN, LOW) -#define SPI_TFT_RST_H OUT_WRITE(TFT_RST_PIN, HIGH) -#define SPI_TFT_RST_L OUT_WRITE(TFT_RST_PIN, LOW) +#define TFT_RST_H OUT_WRITE(TFT_RST_PIN, HIGH) +#define TFT_RST_L OUT_WRITE(TFT_RST_PIN, LOW) -#define SPI_TFT_BLK_H OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH) -#define SPI_TFT_BLK_L OUT_WRITE(TFT_BACKLIGHT_PIN, LOW) +#define TFT_BLK_H OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH) +#define TFT_BLK_L OUT_WRITE(TFT_BACKLIGHT_PIN, LOW) void TFT_SPI::Init() { #if PIN_EXISTS(TFT_RESET) // OUT_WRITE(TFT_RESET_PIN, HIGH); - SPI_TFT_RST_H; + TFT_RST_H; delay(100); #endif #if PIN_EXISTS(TFT_BACKLIGHT) // OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH); - SPI_TFT_BLK_H; + TFT_BLK_H; #endif - SPI_TFT_DC_H; - SPI_TFT_CS_H; + TFT_DC_H; + TFT_CS_H; /** * STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz @@ -87,7 +87,7 @@ void TFT_SPI::Init() { void TFT_SPI::DataTransferBegin(uint16_t DataSize) { SPIx.setDataSize(DataSize); SPIx.begin(); - SPI_TFT_CS_L; + TFT_CS_L; } uint32_t TFT_SPI::GetID() { @@ -135,7 +135,7 @@ void TFT_SPI::Transmit(uint16_t Data) { void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DataTransferBegin(); - SPI_TFT_DC_H; + TFT_DC_H; if (MemoryIncrease == DMA_MINC_ENABLE) { SPIx.dmaSend(Data, Count, true); } diff --git a/Marlin/src/HAL/STM32F1/tft/xpt2046.cpp b/Marlin/src/HAL/STM32F1/tft/xpt2046.cpp index e06cace7419a..616d05fead15 100644 --- a/Marlin/src/HAL/STM32F1/tft/xpt2046.cpp +++ b/Marlin/src/HAL/STM32F1/tft/xpt2046.cpp @@ -19,7 +19,7 @@ #include "../../../inc/MarlinConfig.h" -#if HAS_TFT_XPT2046 +#if HAS_TFT_XPT2046 || HAS_TOUCH_XPT2046 #include "xpt2046.h" #include diff --git a/Marlin/src/HAL/STM32F1/tft/xpt2046.h b/Marlin/src/HAL/STM32F1/tft/xpt2046.h index d2b7ad29b03e..019f75efce12 100644 --- a/Marlin/src/HAL/STM32F1/tft/xpt2046.h +++ b/Marlin/src/HAL/STM32F1/tft/xpt2046.h @@ -24,16 +24,18 @@ #include #endif -#if !PIN_EXISTS(TOUCH_MISO) - #error "TOUCH_MISO_PIN is not defined." -#elif !PIN_EXISTS(TOUCH_MOSI) - #error "TOUCH_MOSI_PIN is not defined." -#elif !PIN_EXISTS(TOUCH_SCK) - #error "TOUCH_SCK_PIN is not defined." -#elif !PIN_EXISTS(TOUCH_CS) - #error "TOUCH_CS_PIN is not defined." +#ifndef TOUCH_MISO_PIN + #define TOUCH_MISO_PIN MISO_PIN +#endif +#ifndef TOUCH_MOSI_PIN + #define TOUCH_MOSI_PIN MOSI_PIN +#endif +#ifndef TOUCH_SCK_PIN + #define TOUCH_SCK_PIN SCK_PIN +#endif +#ifndef TOUCH_CS_PIN + #define TOUCH_CS_PIN CS_PIN #endif - #ifndef TOUCH_INT_PIN #define TOUCH_INT_PIN -1 #endif diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 30b6fbe3d59d..89791c90820b 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -30,6 +30,10 @@ #include "MarlinCore.h" +#if ENABLED(MARLIN_DEV_MODE) + #warning "WARNING! Disable MARLIN_DEV_MODE for the final build!" +#endif + #include "HAL/shared/Delay.h" #include "HAL/shared/esp_wifi.h" @@ -57,7 +61,7 @@ #include "lcd/ultralcd.h" #if HAS_TOUCH_XPT2046 - #include "lcd/touch/xpt2046.h" + #include "lcd/touch/touch_buttons.h" #endif #if HAS_TFT_LVGL_UI @@ -68,9 +72,9 @@ #endif #if ENABLED(DWIN_CREALITY_LCD) - #include "lcd/dwin/dwin.h" + #include "lcd/dwin/e3v2/dwin.h" #include "lcd/dwin/dwin_lcd.h" - #include "lcd/dwin/rotary_encoder.h" + #include "lcd/dwin/e3v2/rotary_encoder.h" #endif #if ENABLED(IIC_BL24CXX_EEPROM) @@ -684,7 +688,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { * - Read Buttons and Update the LCD * - Run i2c Position Encoders * - Auto-report Temperatures / SD Status - * - Update the Prusa MMU2 + * - Update the Průša MMU2 * - Handle Joystick jogging */ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { @@ -760,7 +764,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { } #endif - // Update the Prusa MMU2 + // Update the Průša MMU2 TERN_(PRUSA_MMU2, mmu2.mmu_loop()); // Handle Joystick jogging @@ -922,7 +926,7 @@ void setup() { SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers #endif - #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) + #if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); // Put Smart Effector into NORMAL mode #endif @@ -991,6 +995,10 @@ void setup() { SETUP_RUN(leds.setup()); #endif + #if ENABLED(NEOPIXEL2_SEPARATE) + SETUP_RUN(leds2.setup()); + #endif + #if ENABLED(USE_CONTROLLER_FAN) // Set up fan controller to initialize also the default configurations. SETUP_RUN(controllerFan.setup()); #endif diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index 81041c8ee62f..69afc7f30e88 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -89,8 +89,8 @@ extern bool wait_for_heatup; #if ENABLED(PSU_CONTROL) extern bool powersupply_on; - #define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_HIGH); powersupply_on = true; }while(0) - #define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_HIGH); powersupply_on = false; }while(0) + #define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_STATE); powersupply_on = true; }while(0) + #define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_STATE); powersupply_on = false; }while(0) #if ENABLED(AUTO_POWER_CONTROL) #define PSU_ON() powerManager.power_on() #define PSU_OFF() powerManager.power_off() diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 32b9168a6229..e280d955b800 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -235,6 +235,7 @@ #define BOARD_SMOOTHIEBOARD 2506 // Smoothieboard #define BOARD_TH3D_EZBOARD 2507 // TH3D EZBoard v1.0 #define BOARD_BTT_SKR_V1_4_TURBO 2508 // BigTreeTech SKR v1.4 TURBO (Power outputs: Hotend0, Hotend1, Fan, Bed) +#define BOARD_MKS_SGEN_L_V2 2509 // MKS SGEN_L V2 (Power outputs: Hotend0, Hotend1, Bed, Fan) // // SAM3X8E ARM Cortex M3 @@ -313,7 +314,8 @@ #define BOARD_CHITU3D_V5 4031 // Chitu3D TronXY X5SA V5 Board #define BOARD_CHITU3D_V6 4032 // Chitu3D TronXY X5SA V5 Board #define BOARD_CREALITY_V4 4033 // Creality v4.x (STM32F103RE) -#define BOARD_TRIGORILLA_PRO 4034 // Trigorilla Pro (STM32F103ZET6) +#define BOARD_CREALITY_V427 4034 // Creality v4.2.7 (STM32F103RE) +#define BOARD_TRIGORILLA_PRO 4035 // Trigorilla Pro (STM32F103ZET6) // // ARM Cortex-M4F @@ -344,8 +346,9 @@ #define BOARD_LERDGE_X 4215 // Lerdge X (STM32F407VE) #define BOARD_VAKE403D 4216 // VAkE 403D (STM32F446VET6) #define BOARD_FYSETC_S6 4217 // FYSETC S6 board -#define BOARD_FLYF407ZG 4218 // FLYF407ZG board (STM32F407ZG) -#define BOARD_MKS_ROBIN2 4219 // MKS_ROBIN2 (STM32F407ZE) +#define BOARD_FYSETC_S6_V2_0 4218 // FYSETC S6 v2.0 board +#define BOARD_FLYF407ZG 4219 // FLYF407ZG board (STM32F407ZG) +#define BOARD_MKS_ROBIN2 4220 // MKS_ROBIN2 (STM32F407ZE) // // ARM Cortex M7 diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index f0ddbdd6d096..1d81ee61fb6d 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -120,6 +120,7 @@ #define STR_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: " #define STR_ERR_NO_CHECKSUM "No Checksum with line number, Last Line: " #define STR_FILE_PRINTED "Done printing file" +#define STR_NO_MEDIA "No media" #define STR_BEGIN_FILE_LIST "Begin file list" #define STR_END_FILE_LIST "End file list" #define STR_INVALID_EXTRUDER "Invalid extruder" diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 295657fa64f3..f99956816778 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -57,10 +57,11 @@ void safe_delay(millis_t ms) { void log_machine_info() { SERIAL_ECHOLNPGM("Machine Type: " - TERN_(DELTA, "Delta") - TERN_(IS_SCARA, "SCARA") - TERN_(IS_CORE, "Core") - TERN_(IS_CARTESIAN, "Cartesian") + TERN_(DELTA, "Delta") + TERN_(IS_SCARA, "SCARA") + TERN_(IS_CORE, "Core") + TERN_(MARKFORGED_XY, "MarkForged") + TERN_(IS_CARTESIAN, "Cartesian") ); SERIAL_ECHOLNPGM("Probe: " diff --git a/Marlin/src/feature/babystep.cpp b/Marlin/src/feature/babystep.cpp index 41d0a9cb1e91..b07688146110 100644 --- a/Marlin/src/feature/babystep.cpp +++ b/Marlin/src/feature/babystep.cpp @@ -26,7 +26,8 @@ #include "babystep.h" #include "../MarlinCore.h" -#include "../module/planner.h" +#include "../module/motion.h" // for axes_should_home() +#include "../module/planner.h" // for axis_steps_per_mm[] #include "../module/stepper.h" #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE) @@ -54,7 +55,7 @@ void Babystep::add_mm(const AxisEnum axis, const float &mm) { } void Babystep::add_steps(const AxisEnum axis, const int16_t distance) { - if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return; + if (DISABLED(BABYSTEP_WITHOUT_HOMING) && axes_should_home(_BV(axis))) return; accum += distance; // Count up babysteps for the UI steps[BS_AXIS_IND(axis)] += distance; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 809caecf49ea..087fdf42b2ac 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -48,7 +48,7 @@ void unified_bed_leveling::report_current_mesh() { if (!leveling_is_valid()) return; - SERIAL_ECHO_MSG(" G29 I99"); + SERIAL_ECHO_MSG(" G29 I999"); GRID_LOOP(x, y) if (!isnan(z_values[x][y])) { SERIAL_ECHO_START(); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 69a66420f898..d13a8c3dc455 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -321,7 +321,7 @@ // Check for commands that require the printer to be homed if (may_move) { planner.synchronize(); - if (axes_need_homing()) gcode.home_all_axes(); + if (axes_should_home()) gcode.home_all_axes(); TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0)); } diff --git a/Marlin/src/feature/direct_stepping.cpp b/Marlin/src/feature/direct_stepping.cpp index d3bdb43ab3cd..9766d1464053 100644 --- a/Marlin/src/feature/direct_stepping.cpp +++ b/Marlin/src/feature/direct_stepping.cpp @@ -56,9 +56,6 @@ namespace DirectStepping { template volatile bool SerialPageManager::page_states_dirty; - template - millis_t SerialPageManager::next_response; - template uint8_t SerialPageManager::pages[Cfg::NUM_PAGES][Cfg::PAGE_SIZE]; @@ -80,7 +77,6 @@ namespace DirectStepping { page_states[i] = PageState::FREE; fatal_error = false; - next_response = 0; state = State::NEWLINE; page_states_dirty = false; @@ -181,15 +177,8 @@ namespace DirectStepping { return; } - // Runs on a set interval also, as responses may get lost. - if (next_response && next_response < millis()) { - page_states_dirty = true; - } - if (!page_states_dirty) return; - page_states_dirty = false; - next_response = millis() + Cfg::RESPONSE_INTERVAL_MS; SERIAL_ECHO(Cfg::CONTROL_CHAR); constexpr int state_bits = 2; @@ -238,29 +227,29 @@ const uint8_t segment_table[DirectStepping::Config::NUM_SEGMENTS][DirectStepping #if STEPPER_PAGE_FORMAT == SP_4x4D_128 - { 1, 1, 1, 1, 1, 1, 1, 0 }, // 0 = -7 - { 1, 1, 1, 0, 1, 1, 1, 0 }, // 1 = -6 - { 0, 1, 1, 0, 1, 0, 1, 1 }, // 2 = -5 - { 0, 1, 0, 1, 0, 1, 0, 1 }, // 3 = -4 - { 0, 1, 0, 0, 1, 0, 0, 1 }, // 4 = -3 - { 0, 0, 1, 0, 0, 0, 1, 0 }, // 5 = -2 - { 0, 0, 0, 0, 1, 0, 0, 0 }, // 6 = -1 - { 0, 0, 0, 0, 0, 0, 0, 0 }, // 7 = 0 - { 0, 0, 0, 0, 1, 0, 0, 0 }, // 8 = 1 - { 0, 0, 1, 0, 0, 0, 1, 0 }, // 9 = 2 - { 0, 1, 0, 0, 1, 0, 0, 1 }, // 10 = 3 - { 0, 1, 0, 1, 0, 1, 0, 1 }, // 11 = 4 - { 0, 1, 1, 0, 1, 0, 1, 1 }, // 12 = 5 - { 1, 1, 1, 0, 1, 1, 1, 0 }, // 13 = 6 - { 1, 1, 1, 1, 1, 1, 1, 0 }, // 14 = 7 + { 1, 1, 1, 1, 1, 1, 1 }, // 0 = -7 + { 1, 1, 1, 0, 1, 1, 1 }, // 1 = -6 + { 1, 1, 1, 0, 1, 0, 1 }, // 2 = -5 + { 1, 1, 0, 1, 0, 1, 0 }, // 3 = -4 + { 1, 1, 0, 0, 1, 0, 0 }, // 4 = -3 + { 0, 0, 1, 0, 0, 0, 1 }, // 5 = -2 + { 0, 0, 0, 1, 0, 0, 0 }, // 6 = -1 + { 0, 0, 0, 0, 0, 0, 0 }, // 7 = 0 + { 0, 0, 0, 1, 0, 0, 0 }, // 8 = 1 + { 0, 0, 1, 0, 0, 0, 1 }, // 9 = 2 + { 1, 1, 0, 0, 1, 0, 0 }, // 10 = 3 + { 1, 1, 0, 1, 0, 1, 0 }, // 11 = 4 + { 1, 1, 1, 0, 1, 0, 1 }, // 12 = 5 + { 1, 1, 1, 0, 1, 1, 1 }, // 13 = 6 + { 1, 1, 1, 1, 1, 1, 1 }, // 14 = 7 { 0 } #elif STEPPER_PAGE_FORMAT == SP_4x2_256 - { 0, 0, 0, 0 }, // 0 - { 0, 1, 0, 0 }, // 1 - { 1, 0, 1, 0 }, // 2 - { 1, 1, 1, 0 }, // 3 + { 0, 0, 0 }, // 0 + { 0, 1, 0 }, // 1 + { 1, 0, 1 }, // 2 + { 1, 1, 1 }, // 3 #elif STEPPER_PAGE_FORMAT == SP_4x1_512 diff --git a/Marlin/src/feature/direct_stepping.h b/Marlin/src/feature/direct_stepping.h index dea2616508d2..cde9d1a0b438 100644 --- a/Marlin/src/feature/direct_stepping.h +++ b/Marlin/src/feature/direct_stepping.h @@ -70,7 +70,6 @@ namespace DirectStepping { static volatile PageState page_states[Cfg::NUM_PAGES]; static volatile bool page_states_dirty; - static millis_t next_response; static uint8_t pages[Cfg::NUM_PAGES][Cfg::PAGE_SIZE]; static uint8_t checksum; @@ -94,14 +93,11 @@ namespace DirectStepping { static constexpr int DIRECTIONAL = dir ? 1 : 0; static constexpr int SEGMENTS = segments; - static constexpr int RAW = (BITS_SEGMENT == 1) ? 1 : 0; static constexpr int NUM_SEGMENTS = 1 << BITS_SEGMENT; - static constexpr int SEGMENT_STEPS = 1 << (BITS_SEGMENT - DIRECTIONAL - RAW); + static constexpr int SEGMENT_STEPS = (1 << (BITS_SEGMENT - DIRECTIONAL)) - 1; static constexpr int TOTAL_STEPS = SEGMENT_STEPS * SEGMENTS; static constexpr int PAGE_SIZE = (NUM_AXES * BITS_SEGMENT * SEGMENTS) / 8; - static constexpr millis_t RESPONSE_INTERVAL_MS = 50; - typedef typename TypeSelector<(PAGE_SIZE>256), uint16_t, uint8_t>::type write_byte_idx_t; typedef typename TypeSelector<(NUM_PAGES>256), uint16_t, uint8_t>::type page_idx_t; }; diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index eec0cde630da..ef9099fb2093 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -44,11 +44,8 @@ #if ENABLED(LED_COLOR_PRESETS) const LEDColor LEDLights::defaultLEDColor = MakeLEDColor( - LED_USER_PRESET_RED, - LED_USER_PRESET_GREEN, - LED_USER_PRESET_BLUE, - LED_USER_PRESET_WHITE, - LED_USER_PRESET_BRIGHTNESS + LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, + LED_USER_PRESET_WHITE, LED_USER_PRESET_BRIGHTNESS ); #endif @@ -117,24 +114,22 @@ void LEDLights::set_color(const LEDColor &incol // This variant uses 3-4 separate pins for the RGB(W) components. // If the pins can do PWM then their intensity will be set. - #define UPDATE_RGBW(C,c) do { if (PWM_PIN(RGB_LED_##C##_PIN)) \ + #define UPDATE_RGBW(C,c) do { \ + if (PWM_PIN(RGB_LED_##C##_PIN)) \ analogWrite(pin_t(RGB_LED_##C##_PIN), incol.c); \ - else WRITE(RGB_LED_##C##_PIN, incol.c ? HIGH : LOW); }while(0) - UPDATE_RGBW(R,r); - UPDATE_RGBW(G,g); - UPDATE_RGBW(B,b); + else \ + WRITE(RGB_LED_##C##_PIN, incol.c ? HIGH : LOW); \ + }while(0) + UPDATE_RGBW(R,r); UPDATE_RGBW(G,g); UPDATE_RGBW(B,b); #if ENABLED(RGBW_LED) UPDATE_RGBW(W,w); #endif #endif - #if ENABLED(PCA9632) - // Update I2C LED driver - pca9632_set_led_color(incol); - #endif - - TERN_(PCA9533, PCA9533_setColor(incol.r, incol.g, incol.b)); + // Update I2C LED driver + TERN_(PCA9632, PCA9632_set_led_color(incol)); + TERN_(PCA9533, PCA9533_set_rgb(incol.r, incol.g, incol.b)); #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) // Don't update the color when OFF @@ -161,4 +156,45 @@ void LEDLights::set_color(const LEDColor &incol #endif -#endif // HAS_COLOR_LEDS +#if ENABLED(NEOPIXEL2_SEPARATE) + + #if ENABLED(NEO2_COLOR_PRESETS) + const LEDColor LEDLights2::defaultLEDColor = MakeLEDColor( + NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, + NEO2_USER_PRESET_WHITE, NEO2_USER_PRESET_BRIGHTNESS + ); + #endif + + #if ENABLED(LED_CONTROL_MENU) + LEDColor LEDLights2::color; + bool LEDLights2::lights_on; + #endif + + LEDLights2 leds2; + + void LEDLights2::setup() { + neo2.init(); + TERN_(NEO2_USER_PRESET_STARTUP, set_default()); + } + + void LEDLights2::set_color(const LEDColor &incol) { + const uint32_t neocolor = LEDColorWhite() == incol + ? neo2.Color(NEO2_WHITE) + : neo2.Color(incol.r, incol.g, incol.b, incol.w); + neo2.set_brightness(incol.i); + neo2.set_color(neocolor); + + #if ENABLED(LED_CONTROL_MENU) + // Don't update the color when OFF + lights_on = !incol.is_off(); + if (lights_on) color = incol; + #endif + } + + #if ENABLED(LED_CONTROL_MENU) + void LEDLights2::toggle() { if (lights_on) set_off(); else update(); } + #endif + +#endif // NEOPIXEL2_SEPARATE + +#endif // HAS_COLOR_LEDS diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 577c94752ffd..055ea0df37ad 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -104,11 +104,7 @@ typedef struct LEDColor { bool operator!=(const LEDColor &right) { return !operator==(right); } bool is_off() const { - return 3 > r + g + b - #if HAS_WHITE_LED - + w - #endif - ; + return 3 > r + g + b + TERN0(HAS_WHITE_LED, w); } } LEDColor; @@ -156,14 +152,12 @@ class LEDLights { #endif ); - inline void set_color(uint8_t r, uint8_t g, uint8_t b + static inline void set_color(uint8_t r, uint8_t g, uint8_t b #if HAS_WHITE_LED , uint8_t w=0 - #if ENABLED(NEOPIXEL_LED) - , uint8_t i=NEOPIXEL_BRIGHTNESS - #endif #endif #if ENABLED(NEOPIXEL_LED) + , uint8_t i=NEOPIXEL_BRIGHTNESS , bool isSequence=false #endif ) { @@ -216,3 +210,44 @@ class LEDLights { }; extern LEDLights leds; + +#if ENABLED(NEOPIXEL2_SEPARATE) + + class LEDLights2 { + public: + LEDLights2() {} + + static void setup(); // init() + + static void set_color(const LEDColor &color); + + inline void set_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w=0, uint8_t i=NEOPIXEL2_BRIGHTNESS) { + set_color(MakeLEDColor(r, g, b, w, i)); + } + + static inline void set_off() { set_color(LEDColorOff()); } + static inline void set_green() { set_color(LEDColorGreen()); } + static inline void set_white() { set_color(LEDColorWhite()); } + + #if ENABLED(NEO2_COLOR_PRESETS) + static const LEDColor defaultLEDColor; + static inline void set_default() { set_color(defaultLEDColor); } + static inline void set_red() { set_color(LEDColorRed()); } + static inline void set_orange() { set_color(LEDColorOrange()); } + static inline void set_yellow() { set_color(LEDColorYellow()); } + static inline void set_blue() { set_color(LEDColorBlue()); } + static inline void set_indigo() { set_color(LEDColorIndigo()); } + static inline void set_violet() { set_color(LEDColorViolet()); } + #endif + + #if ENABLED(NEOPIXEL2_SEPARATE) + static LEDColor color; // last non-off color + static bool lights_on; // the last set color was "on" + static void toggle(); // swap "off" with color + static inline void update() { set_color(color); } + #endif + }; + + extern LEDLights2 leds2; + +#endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 5d80cfe5d22a..27bbeb348c5d 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -30,7 +30,7 @@ #include "neopixel.h" -#if ENABLED(NEOPIXEL_STARTUP_TEST) +#if EITHER(NEOPIXEL_STARTUP_TEST, NEOPIXEL2_STARTUP_TEST) #include "../../core/utility.h" #endif @@ -38,7 +38,7 @@ Marlin_NeoPixel neo; int8_t Marlin_NeoPixel::neoindex; Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800) - #if MULTIPLE_NEOPIXEL_TYPES + #if CONJOINED_NEOPIXEL , Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800) #endif ; @@ -53,9 +53,9 @@ Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIX #endif void Marlin_NeoPixel::set_color(const uint32_t color) { - if (get_neo_index() >= 0) { - set_pixel_color(get_neo_index(), color); - set_neo_index(-1); + if (neoindex >= 0) { + set_pixel_color(neoindex, color); + neoindex = -1; } else { for (uint16_t i = 0; i < pixels(); ++i) { @@ -78,18 +78,18 @@ void Marlin_NeoPixel::set_color_startup(const uint32_t color) { } void Marlin_NeoPixel::init() { - set_neo_index(-1); // -1 .. NEOPIXEL_PIXELS-1 range + neoindex = -1; // -1 .. NEOPIXEL_PIXELS-1 range set_brightness(NEOPIXEL_BRIGHTNESS); // 0 .. 255 range begin(); show(); // initialize to all off #if ENABLED(NEOPIXEL_STARTUP_TEST) set_color_startup(adaneo1.Color(255, 0, 0, 0)); // red - safe_delay(1000); + safe_delay(500); set_color_startup(adaneo1.Color(0, 255, 0, 0)); // green - safe_delay(1000); + safe_delay(500); set_color_startup(adaneo1.Color(0, 0, 255, 0)); // blue - safe_delay(1000); + safe_delay(500); #endif #ifdef NEOPIXEL_BKGD_LED_INDEX @@ -120,4 +120,53 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint } #endif +#if ENABLED(NEOPIXEL2_SEPARATE) + + Marlin_NeoPixel2 neo2; + + int8_t Marlin_NeoPixel2::neoindex; + Adafruit_NeoPixel Marlin_NeoPixel2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); + + void Marlin_NeoPixel2::set_color(const uint32_t color) { + if (neoindex >= 0) { + set_pixel_color(neoindex, color); + neoindex = -1; + } + else { + for (uint16_t i = 0; i < pixels(); ++i) + set_pixel_color(i, color); + } + show(); + } + + void Marlin_NeoPixel2::set_color_startup(const uint32_t color) { + for (uint16_t i = 0; i < pixels(); ++i) + set_pixel_color(i, color); + show(); + } + + void Marlin_NeoPixel2::init() { + neoindex = -1; // -1 .. NEOPIXEL2_PIXELS-1 range + set_brightness(NEOPIXEL2_BRIGHTNESS); // 0 .. 255 range + begin(); + show(); // initialize to all off + + #if ENABLED(NEOPIXEL2_STARTUP_TEST) + set_color_startup(adaneo.Color(255, 0, 0, 0)); // red + safe_delay(500); + set_color_startup(adaneo.Color(0, 255, 0, 0)); // green + safe_delay(500); + set_color_startup(adaneo.Color(0, 0, 255, 0)); // blue + safe_delay(500); + #endif + + #if ENABLED(NEO2_USER_PRESET_STARTUP) + set_color(adaneo.Color(NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE)); + #else + set_color(adaneo.Color(0, 0, 0, 0)); + #endif + } + +#endif // NEOPIXEL2_SEPARATE + #endif // NEOPIXEL_LED diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 17057498d4d5..42046fa5638f 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -22,7 +22,7 @@ #pragma once /** - * Neopixel support + * NeoPixel support */ // ------------------------ @@ -38,10 +38,14 @@ // Defines // ------------------------ -#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE +#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE && DISABLED(NEOPIXEL2_SEPARATE) #define MULTIPLE_NEOPIXEL_TYPES 1 #endif +#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) + #define CONJOINED_NEOPIXEL 1 +#endif + #if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR #define NEOPIXEL_IS_RGB 1 #else @@ -61,47 +65,52 @@ class Marlin_NeoPixel { private: static Adafruit_NeoPixel adaneo1 - #if MULTIPLE_NEOPIXEL_TYPES + #if CONJOINED_NEOPIXEL , adaneo2 #endif ; - static int8_t neoindex; public: + static int8_t neoindex; + static void init(); static void set_color_startup(const uint32_t c); static void set_color(const uint32_t c); - FORCE_INLINE static void set_neo_index(const int8_t neoIndex) { neoindex = neoIndex; } - FORCE_INLINE static int8_t get_neo_index() { return neoindex; } - #ifdef NEOPIXEL_BKGD_LED_INDEX static void set_color_background(); #endif static inline void begin() { adaneo1.begin(); - TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.begin()); + TERN_(CONJOINED_NEOPIXEL, adaneo2.begin()); } static inline void set_pixel_color(const uint16_t n, const uint32_t c) { - adaneo1.setPixelColor(n, c); - TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c)); + #if ENABLED(NEOPIXEL2_INSERIES) + if (n >= NEOPIXEL_PIXELS) adaneo2.setPixelColor(n - (NEOPIXEL_PIXELS), c); + else adaneo1.setPixelColor(n, c); + #else + adaneo1.setPixelColor(n, c); + #if MULTIPLE_NEOPIXEL_TYPES + adaneo2.setPixelColor(n, c); + #endif + #endif } static inline void set_brightness(const uint8_t b) { adaneo1.setBrightness(b); - TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setBrightness(b)); + TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b)); } static inline void show() { adaneo1.show(); #if PIN_EXISTS(NEOPIXEL2) - #if MULTIPLE_NEOPIXEL_TYPES + #if CONJOINED_NEOPIXEL adaneo2.show(); #else - adaneo1.setPin(NEOPIXEL2_PIN); + TERN(NEOPIXEL2_SEPARATE,,adaneo1.setPin(NEOPIXEL2_PIN)); adaneo1.show(); adaneo1.setPin(NEOPIXEL_PIN); #endif @@ -113,7 +122,7 @@ class Marlin_NeoPixel { #endif // Accessors - static inline uint16_t pixels() { return adaneo1.numPixels(); } + static inline uint16_t pixels() { TERN(NEOPIXEL2_INSERIES, return adaneo1.numPixels() * 2, return adaneo1.numPixels()); } static inline uint8_t brightness() { return adaneo1.getBrightness(); } static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { return adaneo1.Color(r, g, b, w); @@ -121,3 +130,50 @@ class Marlin_NeoPixel { }; extern Marlin_NeoPixel neo; + +// Neo pixel channel 2 +#if ENABLED(NEOPIXEL2_SEPARATE) + + #if NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR + #define NEOPIXEL2_IS_RGB 1 + #else + #define NEOPIXEL2_IS_RGBW 1 + #endif + + #if NEOPIXEL2_IS_RGB + #define NEO2_WHITE 255, 255, 255, 0 + #else + #define NEO2_WHITE 0, 0, 0, 255 + #endif + + class Marlin_NeoPixel2 { + private: + static Adafruit_NeoPixel adaneo; + + public: + static int8_t neoindex; + + static void init(); + static void set_color_startup(const uint32_t c); + + static void set_color(const uint32_t c); + + static inline void begin() { adaneo.begin(); } + static inline void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); } + static inline void set_brightness(const uint8_t b) { adaneo.setBrightness(b); } + static inline void show() { + adaneo.show(); + adaneo.setPin(NEOPIXEL2_PIN); + } + + // Accessors + static inline uint16_t pixels() { return adaneo.numPixels();} + static inline uint8_t brightness() { return adaneo.getBrightness(); } + static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { + return adaneo.Color(r, g, b, w); + } + }; + + extern Marlin_NeoPixel2 neo2; + +#endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/feature/leds/pca9533.cpp b/Marlin/src/feature/leds/pca9533.cpp index bcc4bc50a474..0fd4d6675771 100644 --- a/Marlin/src/feature/leds/pca9533.cpp +++ b/Marlin/src/feature/leds/pca9533.cpp @@ -62,7 +62,7 @@ void PCA9533_setOff() { PCA9533_writeRegister(PCA9533_REG_SEL, 0); } -void PCA9533_setColor(uint8_t red, uint8_t green, uint8_t blue) { +void PCA9533_set_rgb(uint8_t red, uint8_t green, uint8_t blue) { uint8_t r_pwm0 = 0; // Register data - PWM value uint8_t r_pwm1 = 0; // Register data - PWM value diff --git a/Marlin/src/feature/leds/pca9533.h b/Marlin/src/feature/leds/pca9533.h index 899418ff232c..431058c49136 100644 --- a/Marlin/src/feature/leds/pca9533.h +++ b/Marlin/src/feature/leds/pca9533.h @@ -55,5 +55,5 @@ void PCA9533_init(); void PCA9533_reset(); -void PCA9533_setColor(uint8_t red, uint8_t green, uint8_t blue); +void PCA9533_set_rgb(uint8_t red, uint8_t green, uint8_t blue); void PCA9533_setOff(); diff --git a/Marlin/src/feature/leds/pca9632.cpp b/Marlin/src/feature/leds/pca9632.cpp index df991ded36cc..d8af31cb6ce4 100644 --- a/Marlin/src/feature/leds/pca9632.cpp +++ b/Marlin/src/feature/leds/pca9632.cpp @@ -120,7 +120,7 @@ static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const } #endif -void pca9632_set_led_color(const LEDColor &color) { +void PCA9632_set_led_color(const LEDColor &color) { Wire.begin(); if (!PCA_init) { PCA_init = 1; @@ -138,7 +138,7 @@ void pca9632_set_led_color(const LEDColor &color) { #if ENABLED(PCA9632_BUZZER) - void pca9632_buzz(const long, const uint16_t) { + void PCA9632_buzz(const long, const uint16_t) { uint8_t data[] = PCA9632_BUZZER_DATA; Wire.beginTransmission(I2C_ADDRESS(PCA9632_ADDRESS)); Wire.write(data, sizeof(data)); diff --git a/Marlin/src/feature/leds/pca9632.h b/Marlin/src/feature/leds/pca9632.h index 34aceb31d6e3..fb59a8c18479 100644 --- a/Marlin/src/feature/leds/pca9632.h +++ b/Marlin/src/feature/leds/pca9632.h @@ -29,9 +29,9 @@ struct LEDColor; typedef LEDColor LEDColor; -void pca9632_set_led_color(const LEDColor &color); +void PCA9632_set_led_color(const LEDColor &color); #if ENABLED(PCA9632_BUZZER) #include - void pca9632_buzz(const long, const uint16_t); + void PCA9632_buzz(const long, const uint16_t); #endif diff --git a/Marlin/src/feature/mixing.cpp b/Marlin/src/feature/mixing.cpp index 7de4eb79ea67..b002e9808adc 100644 --- a/Marlin/src/feature/mixing.cpp +++ b/Marlin/src/feature/mixing.cpp @@ -180,7 +180,12 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*= } void Mixer::update_gradient_for_planner_z() { - update_gradient_for_z(planner.get_axis_position_mm(Z_AXIS)); + #if ENABLED(DELTA) + get_cartesian_from_steppers(); + update_gradient_for_z(cartes.z); + #else + update_gradient_for_z(planner.get_axis_position_mm(Z_AXIS)); + #endif } #endif // GRADIENT_MIX diff --git a/Marlin/src/feature/password/password.cpp b/Marlin/src/feature/password/password.cpp index c519ee7c9c46..90bb647118b5 100644 --- a/Marlin/src/feature/password/password.cpp +++ b/Marlin/src/feature/password/password.cpp @@ -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 . * */ diff --git a/Marlin/src/feature/password/password.h b/Marlin/src/feature/password/password.h index 66f1c70ba314..3ed584b29d5e 100644 --- a/Marlin/src/feature/password/password.h +++ b/Marlin/src/feature/password/password.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/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 77f352c399b5..a7ed93425cf1 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -413,7 +413,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE); // Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos) - if (!axes_need_homing()) + if (!axes_should_home()) nozzle.park(0, park_point); #if ENABLED(DUAL_X_CARRIAGE) @@ -582,6 +582,9 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_RESUME)); + // Check Temperature before moving hotend + ensure_safe_temperature(); + // Retract to prevent oozing unscaled_e_move(-(PAUSE_PARK_RETRACT_LENGTH), feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE)); @@ -594,8 +597,6 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le // Unretract unscaled_e_move(PAUSE_PARK_RETRACT_LENGTH, feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE)); - ensure_safe_temperature(); - // Intelligent resuming #if ENABLED(FWRETRACT) // If retracted before goto pause diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index 74850122c296..5be554e5e472 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -59,7 +59,6 @@ bool Power::is_power_needed() { // If any of the drivers or the bed are enabled... if (X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON || Z_ENABLE_READ() == Z_ENABLE_ON - || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0) #if HAS_X2_ENABLE || X2_ENABLE_READ() == X_ENABLE_ON #endif @@ -75,8 +74,8 @@ bool Power::is_power_needed() { #endif ) return true; - HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0) return true; - if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0)) return true; + HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0 || thermalManager.temp_hotend[e].soft_pwm_amount > 0) return true; + if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0 || thermalManager.temp_bed.soft_pwm_amount > 0)) return true; #if HAS_HOTEND && AUTO_POWER_E_TEMP HOTEND_LOOP() if (thermalManager.degHotend(e) >= AUTO_POWER_E_TEMP) return true; diff --git a/Marlin/src/feature/power_monitor.h b/Marlin/src/feature/power_monitor.h index ca52ed74c6bc..a86bd07ec4d1 100644 --- a/Marlin/src/feature/power_monitor.h +++ b/Marlin/src/feature/power_monitor.h @@ -89,7 +89,9 @@ class PowerMonitor { #endif #if HAS_SPI_LCD - FORCE_INLINE static bool display_enabled() { return flags != 0x00; } + #if HAS_GRAPHICAL_LCD && DISABLED(LIGHTWEIGHT_UI) + FORCE_INLINE static bool display_enabled() { return flags != 0x00; } + #endif #if ENABLED(POWER_MONITOR_CURRENT) static void draw_current(); FORCE_INLINE static bool current_display_enabled() { return TEST(flags, PM_DISP_BIT_I); } diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 9a3eee31b55c..06296dd215fa 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -365,7 +365,7 @@ void PrintJobRecovery::resume() { #endif // Pretend that all axes are homed - axis_homed = axis_known_position = xyz_bits; + set_all_homed(); // Recover volumetric extrusion state #if DISABLED(NO_VOLUMETRICS) diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 0b5c0ebc2e62..71f31f214559 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -44,14 +44,6 @@ bool FilamentMonitorBase::enabled = true, #include "../module/tool_change.h" #endif -/** - * Called by FilamentSensorSwitch::run when filament is detected. - * Called by FilamentSensorEncoder::block_completed when motion is detected. - */ -void FilamentSensorBase::filament_present(const uint8_t extruder) { - runout.filament_present(extruder); // calls response.filament_present(extruder) -} - #if HAS_FILAMENT_RUNOUT_DISTANCE float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM; volatile float RunoutResponseDelayed::runout_mm_countdown[EXTRUDERS]; diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 450ae1830a7b..a7f836684949 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -48,6 +48,24 @@ void event_filament_runout(); +template +class TFilamentMonitor; +class FilamentSensorEncoder; +class FilamentSensorSwitch; +class RunoutResponseDelayed; +class RunoutResponseDebounced; + +/********************************* TEMPLATE SPECIALIZATION *********************************/ + +typedef TFilamentMonitor< + TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced), + TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch) + > FilamentMonitor; + +extern FilamentMonitor runout; + +/*******************************************************************************************/ + class FilamentMonitorBase { public: static bool enabled, filament_ran_out; @@ -121,7 +139,13 @@ class TFilamentMonitor : public FilamentMonitorBase { class FilamentSensorBase { protected: - static void filament_present(const uint8_t extruder); + /** + * Called by FilamentSensorSwitch::run when filament is detected. + * Called by FilamentSensorEncoder::block_completed when motion is detected. + */ + static inline void filament_present(const uint8_t extruder) { + runout.filament_present(extruder); // ...which calls response.filament_present(extruder) + } public: static inline void setup() { @@ -311,12 +335,3 @@ class FilamentSensorBase { }; #endif // !HAS_FILAMENT_RUNOUT_DISTANCE - -/********************************* TEMPLATE SPECIALIZATION *********************************/ - -typedef TFilamentMonitor< - TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced), - TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch) - > FilamentMonitor; - -extern FilamentMonitor runout; diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 9d2ee7d9e57c..bc387a93348d 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -37,7 +37,7 @@ cutter_power_t SpindleLaser::menuPower, // Power s SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM #if ENABLED(MARLIN_DEV_MODE) - cutter_frequency_t SpindleLaser::frequency; // setting PWM frequency; range: 2K - 50K + cutter_frequency_t SpindleLaser::frequency; // PWM frequency setting; range: 2K - 50K #endif #define SPINDLE_LASER_PWM_OFF ((SPINDLE_LASER_PWM_INVERT) ? 255 : 0) @@ -45,13 +45,13 @@ cutter_power_t SpindleLaser::menuPower, // Power s // Init the cutter to a safe OFF state // void SpindleLaser::init() { - OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_HIGH); // Init spindle to off + OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off #if ENABLED(SPINDLE_CHANGE_DIR) OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR ? 255 : 0); // Init rotation to clockwise (M3) #endif #if ENABLED(SPINDLE_LASER_PWM) SET_PWM(SPINDLE_LASER_PWM_PIN); - analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // set to lowest speed + analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed #endif #if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY) set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); @@ -64,14 +64,14 @@ void SpindleLaser::init() { * Set the cutter PWM directly to the given ocr value */ void SpindleLaser::set_ocr(const uint8_t ocr) { - WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_HIGH); // turn spindle on + WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Turn spindle on analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); #if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); #endif } void SpindleLaser::ocr_off() { - WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_HIGH); // Turn spindle off + WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Turn spindle off analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Only write low byte } #endif @@ -98,7 +98,7 @@ void SpindleLaser::apply_power(const uint8_t opwr) { isReady = false; } #else - WRITE(SPINDLE_LASER_ENA_PIN, enabled() == SPINDLE_LASER_ACTIVE_HIGH); + WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); isReady = true; #endif } diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 2399f207bfa2..cd0dbb13cdcb 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -490,7 +490,7 @@ void GcodeSuite::G26() { // Don't allow Mesh Validation without homing first, // or if the parameter parsing did not go OK, abort - if (axis_unhomed_error()) return; + if (homing_needed_error()) return; // Change the tool first, if specified if (parser.seenval('T')) tool_change(parser.value_int()); diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 786065b34655..7595067dbf85 100755 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -176,7 +176,7 @@ void GcodeSuite::G35() { probe.stow(); // After this operation the Z position needs correction - set_axis_not_trusted(Z_AXIS); + set_axis_never_homed(Z_AXIS); // Home Z after the alignment procedure process_subcommands_now_P(PSTR("G28Z")); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index f25fe32b07e5..9bb1ebe23819 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -61,7 +61,7 @@ #endif #if ENABLED(DWIN_CREALITY_LCD) - #include "../../../lcd/dwin/dwin.h" + #include "../../../lcd/dwin/e3v2/dwin.h" #endif #if HAS_MULTI_HOTEND @@ -183,7 +183,7 @@ G29_TYPE GcodeSuite::G29() { faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action; // Don't allow auto-leveling without homing first - if (axis_unhomed_error()) G29_RETURN(false); + if (homing_needed_error()) G29_RETURN(false); if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip"); diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 78695bc05b40..be222a7b1724 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -47,7 +47,7 @@ #include "../../lcd/ultralcd.h" #if ENABLED(DWIN_CREALITY_LCD) - #include "../../lcd/dwin/dwin.h" + #include "../../lcd/dwin/e3v2/dwin.h" #endif #if HAS_L64XX // set L6470 absolute position registers to counts @@ -118,7 +118,7 @@ DEBUG_SECTION(log_G28, "home_z_safely", DEBUGGING(LEVELING)); // Disallow Z homing if X or Y homing is needed - if (axis_unhomed_error(_BV(X_AXIS) | _BV(Y_AXIS))) return; + if (homing_needed_error(_BV(X_AXIS) | _BV(Y_AXIS))) return; sync_plan_position(); @@ -299,8 +299,8 @@ void GcodeSuite::G28() { #else // NOT DELTA const bool homeZ = parser.seen('Z'), - needX = homeZ && TERN0(Z_SAFE_HOMING, axes_need_homing(_BV(X_AXIS))), - needY = homeZ && TERN0(Z_SAFE_HOMING, axes_need_homing(_BV(Y_AXIS))), + needX = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(X_AXIS))), + needY = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(Y_AXIS))), homeX = needX || parser.seen('X'), homeY = needY || parser.seen('Y'), home_all = homeX == homeY && homeX == homeZ, // All or None doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ; diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 3360dc050fcf..1fd0754ec780 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -346,7 +346,7 @@ void GcodeSuite::G34() { #if ENABLED(HOME_AFTER_G34) // After this operation the z position needs correction - set_axis_not_trusted(Z_AXIS); + set_axis_never_homed(Z_AXIS); // Home Z after the alignment procedure process_subcommands_now_P(PSTR("G28Z")); #else diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 0ef23d28f92b..746cb108766b 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -584,7 +584,7 @@ void GcodeSuite::G425() { TEMPORARY_SOFT_ENDSTOP_STATE(false); TEMPORARY_BED_LEVELING_STATE(false); - if (axis_unhomed_error()) return; + if (homing_needed_error()) return; measurements_t m; diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index f2f53d213d3a..9870d9fbe567 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -45,7 +45,7 @@ * - When calibrating bed, probe temperature is held constant. * Compensation values are deltas to first probe measurement at bed temp. = 60°C. * - The hotend will not be heated at any time. - * - On my Prusa MK3S clone I put a piece of paper between the probe and the hotend + * - On my Průša MK3S clone I put a piece of paper between the probe and the hotend * so the hotend fan would not cool my probe constantly. Alternativly you could just * make sure the fan is not running while running the calibration process. * diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 47c72eece7f4..aaf58eed1c78 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -27,13 +27,10 @@ #include "../gcode.h" #include "../../module/motion.h" #include "../../module/probe.h" +#include "../../lcd/ultralcd.h" #include "../../feature/bedlevel/bedlevel.h" -#if HAS_SPI_LCD - #include "../../lcd/ultralcd.h" -#endif - #if HAS_LEVELING #include "../../module/planner.h" #endif @@ -58,7 +55,7 @@ extern const char SP_Y_STR[]; void GcodeSuite::M48() { - if (axis_unhomed_error()) return; + if (homing_needed_error()) return; const int8_t verbose_level = parser.byteval('V', 1); if (!WITHIN(verbose_level, 0, 4)) { @@ -77,61 +74,85 @@ void GcodeSuite::M48() { const ProbePtRaise raise_after = parser.boolval('E') ? PROBE_PT_STOW : PROBE_PT_RAISE; - xy_float_t next_pos = current_position; - - const xy_pos_t probe_pos = { - parser.linearval('X', next_pos.x + probe.offset_xy.x), // If no X use the probe's current X position - parser.linearval('Y', next_pos.y + probe.offset_xy.y) // If no Y, ditto + // Test at the current position by default, overridden by X and Y + const xy_pos_t test_position = { + parser.linearval('X', current_position.x + probe.offset_xy.x), // If no X use the probe's current X position + parser.linearval('Y', current_position.y + probe.offset_xy.y) // If no Y, ditto }; - if (!probe.can_reach(probe_pos)) { + if (!probe.can_reach(test_position)) { + ui.set_status_P(GET_TEXT(MSG_M48_OUT_OF_BOUNDS), 99); SERIAL_ECHOLNPGM("? (X,Y) out of bounds."); return; } + // Get the number of leg moves per test-point bool seen_L = parser.seen('L'); uint8_t n_legs = seen_L ? parser.value_byte() : 0; if (n_legs > 15) { - SERIAL_ECHOLNPGM("?Number of legs in movement not plausible (0-15)."); + SERIAL_ECHOLNPGM("?Legs of movement implausible (0-15)."); return; } if (n_legs == 1) n_legs = 2; + // Schizoid motion as an optional stress-test const bool schizoid_flag = parser.boolval('S'); if (schizoid_flag && !seen_L) n_legs = 7; - /** - * Now get everything to the specified probe point So we can safely do a - * probe to get us close to the bed. If the Z-Axis is far from the bed, - * we don't want to use that as a starting point for each probe. - */ if (verbose_level > 2) SERIAL_ECHOLNPGM("Positioning the probe..."); - // Disable bed level correction in M48 because we want the raw data when we probe + // Always disable Bed Level correction before probing... #if HAS_LEVELING const bool was_enabled = planner.leveling_active; set_bed_leveling_enabled(false); #endif + // Work with reasonable feedrates remember_feedrate_scaling_off(); - float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples]; + // Working variables + float mean = 0.0, // The average of all points so far, used to calculate deviation + sigma = 0.0, // Standard deviation of all points so far + min = 99999.9, // Smallest value sampled so far + max = -99999.9, // Largest value sampled so far + sample_set[n_samples]; // Storage for sampled values + + auto dev_report = [](const bool verbose, const float &mean, const float &sigma, const float &min, const float &max, const bool final=false) { + if (verbose) { + SERIAL_ECHOPAIR_F("Mean: ", mean, 6); + if (!final) SERIAL_ECHOPAIR_F(" Sigma: ", sigma, 6); + SERIAL_ECHOPAIR_F(" Min: ", min, 3); + SERIAL_ECHOPAIR_F(" Max: ", max, 3); + SERIAL_ECHOPAIR_F(" Range: ", max-min, 3); + if (final) SERIAL_EOL(); + } + if (final) { + SERIAL_ECHOLNPAIR_F("Standard Deviation: ", sigma, 6); + SERIAL_EOL(); + } + }; // Move to the first point, deploy, and probe - const float t = probe.probe_at_point(probe_pos, raise_after, verbose_level); + const float t = probe.probe_at_point(test_position, raise_after, verbose_level); bool probing_good = !isnan(t); if (probing_good) { randomSeed(millis()); + float sample_sum = 0.0; + LOOP_L_N(n, n_samples) { #if HAS_SPI_LCD // Display M48 progress in the status bar ui.status_printf_P(0, PSTR(S_FMT ": %d/%d"), GET_TEXT(MSG_M48_POINT), int(n + 1), int(n_samples)); #endif + + // When there are "legs" of movement move around the point before probing if (n_legs) { + + // Pick a random direction, starting angle, and radius const int dir = (random(0, 10) > 5.0) ? -1 : 1; // clockwise or counter clockwise float angle = random(0, 360); const float radius = random( @@ -142,48 +163,51 @@ void GcodeSuite::M48() { int(5), int(0.125 * _MIN(X_BED_SIZE, Y_BED_SIZE)) #endif ); - if (verbose_level > 3) { SERIAL_ECHOPAIR("Start radius:", radius, " angle:", angle, " dir:"); if (dir > 0) SERIAL_CHAR('C'); SERIAL_ECHOLNPGM("CW"); } + // Move from leg to leg in rapid succession LOOP_L_N(l, n_legs - 1) { - float delta_angle; + // Move some distance around the perimeter + float delta_angle; if (schizoid_flag) { - // The points of a 5 point star are 72 degrees apart. We need to - // skip a point and go to the next one on the star. + // The points of a 5 point star are 72 degrees apart. + // Skip a point and go to the next one on the star. delta_angle = dir * 2.0 * 72.0; } else { - // If we do this line, we are just trying to move further - // around the circle. - delta_angle = dir * (float) random(25, 45); + // Just move further along the perimeter. + delta_angle = dir * (float)random(25, 45); } - angle += delta_angle; - while (angle > 360.0) angle -= 360.0; // We probably do not need to keep the angle between 0 and 2*PI, but the - // Arduino documentation says the trig functions should not be given values - while (angle < 0.0) angle += 360.0; // outside of this range. It looks like they behave correctly with - // numbers outside of the range, but just to be safe we clamp them. - const xy_pos_t noz_pos = probe_pos - probe.offset_xy; - next_pos.set(noz_pos.x + cos(RADIANS(angle)) * radius, - noz_pos.y + sin(RADIANS(angle)) * radius); + // Trig functions work without clamping, but just to be safe... + while (angle > 360.0) angle -= 360.0; + while (angle < 0.0) angle += 360.0; - #if DISABLED(DELTA) - LIMIT(next_pos.x, X_MIN_POS, X_MAX_POS); - LIMIT(next_pos.y, Y_MIN_POS, Y_MAX_POS); - #else - // If we have gone out too far, we can do a simple fix and scale the numbers - // back in closer to the origin. + // Choose the next position as an offset to chosen test position + const xy_pos_t noz_pos = test_position - probe.offset_xy; + xy_pos_t next_pos = { + noz_pos.x + cos(RADIANS(angle)) * radius, + noz_pos.y + sin(RADIANS(angle)) * radius + }; + + #if ENABLED(DELTA) + // If the probe can't reach the point on a round bed... + // Simply scale the numbers to bring them closer to origin. while (!probe.can_reach(next_pos)) { next_pos *= 0.8f; if (verbose_level > 3) SERIAL_ECHOLNPAIR_P(PSTR("Moving inward: X"), next_pos.x, SP_Y_STR, next_pos.y); } + #else + // For a rectangular bed just keep the probe in bounds + LIMIT(next_pos.x, X_MIN_POS, X_MAX_POS); + LIMIT(next_pos.y, Y_MIN_POS, Y_MAX_POS); #endif if (verbose_level > 3) @@ -194,45 +218,35 @@ void GcodeSuite::M48() { } // n_legs // Probe a single point - sample_set[n] = probe.probe_at_point(probe_pos, raise_after, 0); + const float pz = probe.probe_at_point(test_position, raise_after, 0); // Break the loop if the probe fails - probing_good = !isnan(sample_set[n]); + probing_good = !isnan(pz); if (!probing_good) break; - /** - * Get the current mean for the data points we have so far - */ - float sum = 0.0; - LOOP_LE_N(j, n) sum += sample_set[j]; - mean = sum / (n + 1); - - NOMORE(min, sample_set[n]); - NOLESS(max, sample_set[n]); - - /** - * Now, use that mean to calculate the standard deviation for the - * data points we have so far - */ - sum = 0.0; - LOOP_LE_N(j, n) - sum += sq(sample_set[j] - mean); - - sigma = SQRT(sum / (n + 1)); - if (verbose_level > 0) { - if (verbose_level > 1) { - SERIAL_ECHO(n + 1); - SERIAL_ECHOPAIR(" of ", int(n_samples)); - SERIAL_ECHOPAIR_F(": z: ", sample_set[n], 3); - if (verbose_level > 2) { - SERIAL_ECHOPAIR_F(" mean: ", mean, 4); - SERIAL_ECHOPAIR_F(" sigma: ", sigma, 6); - SERIAL_ECHOPAIR_F(" min: ", min, 3); - SERIAL_ECHOPAIR_F(" max: ", max, 3); - SERIAL_ECHOPAIR_F(" range: ", max-min, 3); - } - SERIAL_EOL(); - } + // Store the new sample + sample_set[n] = pz; + + // Keep track of the largest and smallest samples + NOMORE(min, pz); + NOLESS(max, pz); + + // Get the mean value of all samples thus far + sample_sum += pz; + mean = sample_sum / (n + 1); + + // Calculate the standard deviation so far. + // The value after the last sample will be the final output. + float dev_sum = 0.0; + LOOP_LE_N(j, n) dev_sum += sq(sample_set[j] - mean); + sigma = SQRT(dev_sum / (n + 1)); + + if (verbose_level > 1) { + SERIAL_ECHO(n + 1); + SERIAL_ECHOPAIR(" of ", int(n_samples)); + SERIAL_ECHOPAIR_F(": z: ", pz, 3); + dev_report(verbose_level > 2, mean, sigma, min, max); + SERIAL_EOL(); } } // n_samples loop @@ -242,16 +256,7 @@ void GcodeSuite::M48() { if (probing_good) { SERIAL_ECHOLNPGM("Finished!"); - - if (verbose_level > 0) { - SERIAL_ECHOPAIR_F("Mean: ", mean, 6); - SERIAL_ECHOPAIR_F(" Min: ", min, 3); - SERIAL_ECHOPAIR_F(" Max: ", max, 3); - SERIAL_ECHOLNPAIR_F(" Range: ", max-min, 3); - } - - SERIAL_ECHOLNPAIR_F("Standard Deviation: ", sigma, 6); - SERIAL_EOL(); + dev_report(verbose_level > 0, mean, sigma, min, max, true); #if HAS_SPI_LCD // Display M48 results in the status bar diff --git a/Marlin/src/gcode/config/M672.cpp b/Marlin/src/gcode/config/M672.cpp index 58dc27177046..af74230516e1 100644 --- a/Marlin/src/gcode/config/M672.cpp +++ b/Marlin/src/gcode/config/M672.cpp @@ -22,20 +22,12 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) +#if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) #include "../gcode.h" #include "../../HAL/shared/Delay.h" #include "../parser.h" -/** - * M672 - Set/reset Duet Smart Effector sensitivity - * - * One of these is required: - * S - 0-255 - * R - Flag to reset sensitivity to default - */ - /** * The Marlin format for the M672 command is different than shown in the Duet Smart Effector * documentation https://duet3d.dozuki.com/Wiki/Smart_effector_and_carriage_adapters_for_delta_printer @@ -77,6 +69,13 @@ void M672_send(uint8_t b) { // bit rate requirement: 1KHz +/- 30% } } +/** + * M672 - Set/reset Duet Smart Effector sensitivity + * + * One of these is required: + * S - 0-255 + * R - Flag to reset sensitivity to default + */ void GcodeSuite::M672() { if (parser.seen('R')) { M672_send(M672_ERASEBYTE); @@ -96,4 +95,4 @@ void GcodeSuite::M672() { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); // Keep Smart Effector in NORMAL mode } -#endif // SMART_EFFECTOR && SMART_EFFECTOR_MOD_PIN +#endif // DUET_SMART_EFFECTOR && SMART_EFFECTOR_MOD_PIN diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index 0dede7ea644c..6302bb5c6787 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -21,16 +21,14 @@ */ #include "../gcode.h" + #include "../../module/temperature.h" -#include "../../module/stepper.h" -#include "../../module/printcounter.h" // for print_job_timer +#include "../../module/planner.h" // for planner.finish_and_disable +#include "../../module/printcounter.h" // for print_job_timer.stop +#include "../../lcd/ultralcd.h" // for LCD_MESSAGEPGM_P #include "../../inc/MarlinConfig.h" -#if HAS_LCD_MENU - #include "../../lcd/ultralcd.h" -#endif - #if HAS_SUICIDE #include "../../MarlinCore.h" #endif @@ -39,6 +37,8 @@ #if ENABLED(AUTO_POWER_CONTROL) #include "../../feature/power.h" + #else + void restore_stepper_drivers(); #endif // Could be moved to a feature, but this is all the data @@ -108,7 +108,5 @@ void GcodeSuite::M81() { PSU_OFF(); #endif - #if HAS_LCD_MENU - LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF ".")); - #endif + LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF ".")); } diff --git a/Marlin/src/gcode/feature/camera/M240.cpp b/Marlin/src/gcode/feature/camera/M240.cpp index 9664ce15222b..fc350d8a558c 100644 --- a/Marlin/src/gcode/feature/camera/M240.cpp +++ b/Marlin/src/gcode/feature/camera/M240.cpp @@ -126,7 +126,7 @@ void GcodeSuite::M240() { #ifdef PHOTO_POSITION - if (axis_unhomed_error()) return; + if (homing_needed_error()) return; const xyz_pos_t old_pos = { current_position.x + parser.linearval('A'), diff --git a/Marlin/src/gcode/feature/clean/G12.cpp b/Marlin/src/gcode/feature/clean/G12.cpp index fc99cc5c1d06..f91db39703f0 100644 --- a/Marlin/src/gcode/feature/clean/G12.cpp +++ b/Marlin/src/gcode/feature/clean/G12.cpp @@ -45,7 +45,7 @@ */ void GcodeSuite::G12() { // Don't allow nozzle cleaning without homing first - if (axis_unhomed_error()) return; + if (homing_needed_error()) return; #ifdef WIPE_SEQUENCE_COMMANDS if (!parser.seen_any()) { diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 88f02951add2..cf09bf14ead7 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -35,7 +35,10 @@ * If brightness is left out, no value changed * * With NEOPIXEL_LED: - * I Set the Neopixel index to affect. Default: All + * I Set the NeoPixel index to affect. Default: All + * + * With NEOPIXEL2_SEPARATE: + * S The NeoPixel strip to set. Default is index 0. * * Examples: * @@ -47,18 +50,35 @@ * M150 P127 ; Set LED 50% brightness * M150 P ; Set LED full brightness * M150 I1 R ; Set NEOPIXEL index 1 to red + * M150 S1 I1 R ; Set SEPARATE index 1 to red */ + void GcodeSuite::M150() { #if ENABLED(NEOPIXEL_LED) - neo.set_neo_index(parser.intval('I', -1)); + const uint8_t index = parser.intval('I', -1); + #if ENABLED(NEOPIXEL2_SEPARATE) + const uint8_t unit = parser.intval('S'), + brightness = unit ? neo2.brightness() : neo.brightness(); + *(unit ? &neo2.neoindex : &neo.neoindex) = index; + #else + const uint8_t brightness = neo.brightness(); + neo.neoindex = index; + #endif #endif - leds.set_color(MakeLEDColor( + + const LEDColor color = MakeLEDColor( parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : neo.brightness() - )); + parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness + ); + + #if ENABLED(NEOPIXEL2_SEPARATE) + if (unit == 1) { leds2.set_color(color); return; } + #endif + + leds.set_color(color); } #endif // HAS_COLOR_LEDS diff --git a/Marlin/src/gcode/feature/mixing/M166.cpp b/Marlin/src/gcode/feature/mixing/M166.cpp index 5f2c4f042a56..9e071a47ec27 100644 --- a/Marlin/src/gcode/feature/mixing/M166.cpp +++ b/Marlin/src/gcode/feature/mixing/M166.cpp @@ -86,7 +86,14 @@ void GcodeSuite::M166() { echo_zt(mixer.gradient.end_vtool, mixer.gradient.end_z); mixer.update_mix_from_gradient(); - SERIAL_ECHOPAIR(" ; Current Z", planner.get_axis_position_mm(Z_AXIS)); + + SERIAL_ECHOPGM(" ; Current Z"); + #if ENABLED(DELTA) + get_cartesian_from_steppers(); + SERIAL_ECHO(cartes.z); + #else + SERIAL_ECHO(planner.get_axis_position_mm(Z_AXIS)); + #endif echo_mix(); } diff --git a/Marlin/src/gcode/feature/password/M510-M512.cpp b/Marlin/src/gcode/feature/password/M510-M512.cpp index f26fb75fdada..79f1da065b3c 100644 --- a/Marlin/src/gcode/feature/password/M510-M512.cpp +++ b/Marlin/src/gcode/feature/password/M510-M512.cpp @@ -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 . * */ diff --git a/Marlin/src/gcode/feature/pause/G27.cpp b/Marlin/src/gcode/feature/pause/G27.cpp index ea6aadf173c0..3ce618d67568 100644 --- a/Marlin/src/gcode/feature/pause/G27.cpp +++ b/Marlin/src/gcode/feature/pause/G27.cpp @@ -34,7 +34,7 @@ */ void GcodeSuite::G27() { // Don't allow nozzle parking without homing first - if (axis_unhomed_error()) return; + if (homing_needed_error()) return; nozzle.park(parser.ushortval('P')); } diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index 7449787d780b..a02f2368e21c 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -61,7 +61,7 @@ void GcodeSuite::M701() { #if ENABLED(NO_MOTION_BEFORE_HOMING) // Don't raise Z if the machine isn't homed - if (axes_need_homing()) park_point.z = 0; + if (axes_should_home()) park_point.z = 0; #endif #if ENABLED(MIXING_EXTRUDER) @@ -149,7 +149,7 @@ void GcodeSuite::M702() { #if ENABLED(NO_MOTION_BEFORE_HOMING) // Don't raise Z if the machine isn't homed - if (axes_need_homing()) park_point.z = 0; + if (axes_should_home()) park_point.z = 0; #endif #if ENABLED(MIXING_EXTRUDER) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index edbeca9c9279..c0a795025fc7 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -790,7 +790,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 666: M666(); break; // M666: Set delta or multiple endstop adjustment #endif - #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) + #if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) case 672: M672(); break; // M672: Set/clear Duet Smart Effector sensitivity #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index e04cd637eb92..23bf2c0ce5b1 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -155,7 +155,7 @@ * M141 - Set heated chamber target temp. S (Requires a chamber heater) * M145 - Set heatup values for materials on the LCD. H B F for S (0=PLA, 1=ABS) * M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT) - * M150 - Set Status LED Color as R U B P. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632). + * M150 - Set Status LED Color as R U B W P. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632). * M155 - Auto-report temperatures with interval of S. (Requires AUTO_REPORT_TEMPERATURES) * M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER) * M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER) @@ -236,7 +236,7 @@ * M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) * M665 - Set delta configurations: "M665 H L R S B X Y Z (Requires DELTA) * M666 - Set/get offsets for delta (Requires DELTA) or dual endstops. (Requires [XYZ]_DUAL_ENDSTOPS) - * M672 - Set/Reset Duet Smart Effector's sensitivity. (Requires SMART_EFFECTOR and SMART_EFFECTOR_MOD_PIN) + * M672 - Set/Reset Duet Smart Effector's sensitivity. (Requires DUET_SMART_EFFECTOR and SMART_EFFECTOR_MOD_PIN) * M701 - Load filament (Requires FILAMENT_LOAD_UNLOAD_GCODES) * M702 - Unload filament (Requires FILAMENT_LOAD_UNLOAD_GCODES) * M810-M819 - Define/execute a G-code macro (Requires GCODE_MACROS) @@ -792,7 +792,7 @@ class GcodeSuite { static void M666(); #endif - #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) + #if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) static void M672(); #endif diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 2a007427a79c..a477a1a526ef 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -61,7 +61,7 @@ void GcodeSuite::M206() { * Use M206 to set these values directly. */ void GcodeSuite::M428() { - if (axis_unhomed_error()) return; + if (homing_needed_error()) return; xyz_float_t diff; LOOP_XYZ(i) { diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index 87ca23becd48..9970dc4df95c 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -145,10 +145,11 @@ void GcodeSuite::M360() { config_prefix(PSTR("PrinterType")); SERIAL_ECHOLNPGM( - TERN_(DELTA, "Delta") - TERN_(IS_SCARA, "SCARA") - TERN_(IS_CORE, "Core") - TERN_(IS_CARTESIAN, "Cartesian") + TERN_(DELTA, "Delta") + TERN_(IS_SCARA, "SCARA") + TERN_(IS_CORE, "Core") + TERN_(MARKFORGED_XY, "MarkForged") + TERN_(IS_CARTESIAN, "Cartesian") ); // diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index 3aa082c25e83..b6ddf9634b7b 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -52,7 +52,7 @@ void GcodeSuite::G0_G1( if (IsRunning() #if ENABLED(NO_MOTION_BEFORE_HOMING) - && !axis_unhomed_error( + && !homing_needed_error( (parser.seen('X') ? _BV(X_AXIS) : 0) | (parser.seen('Y') ? _BV(Y_AXIS) : 0) | (parser.seen('Z') ? _BV(Z_AXIS) : 0) ) diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 54bc452f97de..b28429f6315d 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -75,7 +75,10 @@ void GcodeSuite::M1001() { TERN_(POWER_LOSS_RECOVERY, recovery.purge()); // Announce SD file completion - SERIAL_ECHOLNPGM(STR_FILE_PRINTED); + { + PORT_REDIRECT(SERIAL_BOTH); + SERIAL_ECHOLNPGM(STR_FILE_PRINTED); + } // Update the status LED color #if HAS_LEDS_OFF_FLAG diff --git a/Marlin/src/gcode/sd/M20.cpp b/Marlin/src/gcode/sd/M20.cpp index 6d4c55752cc3..7ac4affdae9c 100644 --- a/Marlin/src/gcode/sd/M20.cpp +++ b/Marlin/src/gcode/sd/M20.cpp @@ -31,9 +31,13 @@ * M20: List SD card to serial output */ void GcodeSuite::M20() { - SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST); - card.ls(); - SERIAL_ECHOLNPGM(STR_END_FILE_LIST); + if (card.flag.mounted) { + SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST); + card.ls(); + SERIAL_ECHOLNPGM(STR_END_FILE_LIST); + } + else + SERIAL_ECHO_MSG(STR_NO_MEDIA); } #endif // SDSUPPORT diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index d8c8103a4214..d5ef62b621b6 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -26,6 +26,7 @@ * Conditionals that need to be set before Configuration_adv.h or pins.h */ +// Kinematics #if ENABLED(MORGAN_SCARA) #define IS_SCARA 1 #define IS_KINEMATIC 1 @@ -35,10 +36,26 @@ #define IS_CARTESIAN 1 #endif +// MKS_LCD12864 is a variant of MKS_MINI_12864 #if ENABLED(MKS_LCD12864) #define MKS_MINI_12864 #endif +/** + * General Flags that may be set below by specific LCDs + * + * DOGLCD : Run a Graphical LCD through U8GLib (with MarlinUI) + * IS_ULTIPANEL : Define LCD_PINS_D5/6/7 for direct-connected "Ultipanel" LCDs + * IS_ULTRA_LCD : Ultra LCD, not necessarily Ultipanel. Used most often with NEWPANEL. + * IS_RRD_SC : Common RRD Smart Controller digital interface pins + * IS_RRD_FG_SC : Common RRD Full Graphical Smart Controller digital interface pins + * U8GLIB_ST7920 : Most common DOGM display SPI interface, supporting a "lightweight" display mode. + * U8GLIB_SH1106 : SH1106 OLED with I2C interface via U8GLib + * IS_U8GLIB_SSD1306 : SSD1306 OLED with I2C interface via U8GLib + * U8GLIB_SSD1309 : SSD1309 OLED with I2C interface via U8GLib + * U8GLIB_ST7565_64128N : ST7565 128x64 LCD with SPI interface via U8GLib + * U8GLIB_LM6059_AF : LM6059 with Hardware SPI via U8GLib + */ #if EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) #define MINIPANEL @@ -48,6 +65,11 @@ #define DOGLCD #define IS_ULTIPANEL +#elif EITHER(DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) + + #define IS_DWIN_MARLINUI 1 + #define IS_ULTIPANEL + #elif ENABLED(ZONESTAR_LCD) #define ADC_KEYPAD @@ -85,7 +107,6 @@ #elif ANY(miniVIKI, VIKI2, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864) - #define IS_ULTRA_LCD #define DOGLCD #define IS_ULTIPANEL @@ -234,9 +255,9 @@ // 128x64 I2C OLED LCDs - SSD1306/SSD1309/SH1106 #if ANY(U8GLIB_SSD1306, U8GLIB_SSD1309, U8GLIB_SH1106) - #define HAS_SSD1306_OLED_I2C 1 + #define HAS_U8GLIB_I2C_OLED 1 #endif -#if HAS_SSD1306_OLED_I2C +#if HAS_U8GLIB_I2C_OLED #define IS_ULTRA_LCD #define DOGLCD #endif @@ -286,14 +307,15 @@ #define DELAYED_BACKLIGHT_INIT #endif -// FSMC/SPI TFT Panels (HAL STM32) -#if EITHER(TFT_320x240, TFT_480x320) +// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi).h +#if ANY(TFT_320x240, TFT_480x320, TFT_LVGL_UI_FSMC, FSMC_GRAPHICAL_TFT) #define HAS_FSMC_TFT 1 -#elif EITHER(TFT_320x240_SPI, TFT_480x320_SPI) +#elif ANY(TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_SPI, SPI_GRAPHICAL_TFT) #define HAS_SPI_TFT 1 #endif -#if HAS_FSMC_TFT || HAS_SPI_TFT +// Color UI +#if ANY(TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI) #define HAS_GRAPHICAL_TFT 1 #define IS_ULTIPANEL #endif @@ -401,7 +423,6 @@ #define IS_ULTRA_LCD #define NEWPANEL #endif - #if ENABLED(IS_ULTRA_LCD) #define ULTRA_LCD #endif @@ -511,7 +532,7 @@ #undef DISABLE_INACTIVE_EXTRUDER #endif -// Prusa MK2 Multiplexer and MMU 2.0 force SINGLENOZZLE +// Průša MK2 Multiplexer and MMU 2.0 force SINGLENOZZLE #if EITHER(MK2_MULTIPLEXER, PRUSA_MMU2) #define SINGLENOZZLE #endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index fa4f0cd9b1f6..35542f9412ab 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -246,6 +246,28 @@ #endif #endif +#if BOTH(LED_CONTROL_MENU, NEOPIXEL2_SEPARATE) + #ifndef LED2_USER_PRESET_RED + #define LED2_USER_PRESET_RED 255 + #endif + #ifndef LED2_USER_PRESET_GREEN + #define LED2_USER_PRESET_GREEN 255 + #endif + #ifndef LED2_USER_PRESET_BLUE + #define LED2_USER_PRESET_BLUE 255 + #endif + #ifndef LED2_USER_PRESET_WHITE + #define LED2_USER_PRESET_WHITE 0 + #endif + #ifndef LED2_USER_PRESET_BRIGHTNESS + #ifdef NEOPIXEL2_BRIGHTNESS + #define LED2_USER_PRESET_BRIGHTNESS NEOPIXEL2_BRIGHTNESS + #else + #define LED2_USER_PRESET_BRIGHTNESS 255 + #endif + #endif +#endif + // If platform requires early initialization of watchdog to properly boot #if ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM) #define EARLY_WATCHDOG 1 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 6243d82aa8c8..89dc73fb5c61 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -149,11 +149,16 @@ #define CORE_AXIS_2 C_AXIS #endif #define CORESIGN(n) (ANY(COREYX, COREZX, COREZY) ? (-(n)) : (n)) +#elif ENABLED(MARKFORGED_XY) + // Markforged kinematics + #define CORE_AXIS_1 A_AXIS + #define CORE_AXIS_2 B_AXIS + #define NORMAL_AXIS Z_AXIS #endif // Calibration codes only for non-core axes #if EITHER(BACKLASH_GCODE, CALIBRATION_GCODE) - #if IS_CORE + #if EITHER(IS_CORE, MARKFORGED_XY) #define X_AXIS_INDEX 0 #define Y_AXIS_INDEX 1 #define Z_AXIS_INDEX 2 @@ -403,7 +408,7 @@ #ifndef PSU_NAME #if DISABLED(PSU_CONTROL) #define PSU_NAME "Generic" // No control - #elif PSU_ACTIVE_HIGH + #elif PSU_ACTIVE_STATE #define PSU_NAME "XBox" // X-Box 360 (203W) #else #define PSU_NAME "ATX" // ATX style @@ -1622,7 +1627,7 @@ // // Is an endstop plug used for extra Z endstops or the probe? -#define IS_PROBE_PIN(A,M) (HAS_CUSTOM_PROBE_PIN && Z_MIN_PROBE_PIN == P) +#define IS_PROBE_PIN(A,M) (HAS_CUSTOM_PROBE_PIN && Z_MIN_PROBE_PIN == A##_##M##_PIN) #define IS_X2_ENDSTOP(A,M) (ENABLED(X_DUAL_ENDSTOPS) && X2_USE_ENDSTOP == _##A##M##_) #define IS_Y2_ENDSTOP(A,M) (ENABLED(Y_DUAL_ENDSTOPS) && Y2_USE_ENDSTOP == _##A##M##_) #define IS_Z2_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && Z2_USE_ENDSTOP == _##A##M##_) @@ -1876,12 +1881,28 @@ #undef AUTO_POWER_CHAMBER_FAN #endif -// Other fans +// Print Cooling fans (limit) +#ifdef NUM_M106_FANS + #define MAX_FANS NUM_M106_FANS +#else + #define MAX_FANS 8 // Max supported fans +#endif + +#define _NOT_E_AUTO(N,F) (E##N##_AUTO_FAN_PIN != FAN##F##_PIN) +#define _HAS_FAN(F) (PIN_EXISTS(FAN##F) \ + && CONTROLLER_FAN_PIN != FAN##F##_PIN \ + && _NOT_E_AUTO(0,F) \ + && _NOT_E_AUTO(1,F) \ + && _NOT_E_AUTO(2,F) \ + && _NOT_E_AUTO(3,F) \ + && _NOT_E_AUTO(4,F) \ + && _NOT_E_AUTO(5,F) \ + && _NOT_E_AUTO(6,F) \ + && _NOT_E_AUTO(7,F) \ + && F < MAX_FANS) #if PIN_EXISTS(FAN) #define HAS_FAN0 1 #endif -#define _NOT_E_AUTO(N,F) (E##N##_AUTO_FAN_PIN != FAN##F##_PIN) -#define _HAS_FAN(F) (PIN_EXISTS(FAN##F) && CONTROLLER_FAN_PIN != FAN##F##_PIN && _NOT_E_AUTO(0,F) && _NOT_E_AUTO(1,F) && _NOT_E_AUTO(2,F) && _NOT_E_AUTO(3,F) && _NOT_E_AUTO(4,F) && _NOT_E_AUTO(5,F) && _NOT_E_AUTO(6,F) && _NOT_E_AUTO(7,F)) #if _HAS_FAN(1) #define HAS_FAN1 1 #endif @@ -2591,14 +2612,14 @@ #ifndef LCD_WIDTH #if HAS_GRAPHICAL_LCD #define LCD_WIDTH 21 - #else + #elif HAS_CHARACTER_LCD #define LCD_WIDTH TERN(ULTIPANEL, 20, 16) #endif #endif #ifndef LCD_HEIGHT #if HAS_GRAPHICAL_LCD #define LCD_HEIGHT 5 - #else + #elif HAS_CHARACTER_LCD #define LCD_HEIGHT TERN(ULTIPANEL, 4, 2) #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 6fcd867981de..775899febb16 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -39,26 +39,20 @@ #define TEST2 1 #define TEST3 0 #define TEST4 true -#if ENABLED(TEST0) +#if ENABLED(TEST0) || !ENABLED(TEST2) || ENABLED(TEST3) #error "ENABLED is borked!" #endif -#if DISABLED(TEST1) - #error "DISABLED is borked!" -#endif -#if !ENABLED(TEST2) - #error "ENABLED is borked!" -#endif -#if ENABLED(TEST3) - #error "ENABLED is borked!" +#if BOTH(TEST0, TEST1) + #error "BOTH is borked!" #endif -#if DISABLED(TEST4) +#if DISABLED(TEST1) || !DISABLED(TEST3) || DISABLED(TEST4) || DISABLED(TEST0, TEST1, TEST2, TEST4) || !DISABLED(TEST0, TEST3) #error "DISABLED is borked!" #endif #if !ANY(TEST1, TEST2, TEST3, TEST4) || ANY(TEST0, TEST3) #error "ANY is borked!" #endif -#if DISABLED(TEST0, TEST1, TEST2, TEST4) - #error "DISABLED is borked!" +#if NONE(TEST0, TEST1, TEST2, TEST4) || !NONE(TEST0, TEST3) + #error "NONE is borked!" #endif #undef TEST1 #undef TEST2 @@ -419,8 +413,10 @@ #error "SPINDLE_DIR_CHANGE is now SPINDLE_CHANGE_DIR. Please update your Configuration_adv.h." #elif defined(SPINDLE_STOP_ON_DIR_CHANGE) #error "SPINDLE_STOP_ON_DIR_CHANGE is now SPINDLE_CHANGE_DIR_STOP. Please update your Configuration_adv.h." +#elif defined(SPINDLE_LASER_ACTIVE_HIGH) + #error "SPINDLE_LASER_ACTIVE_HIGH is now SPINDLE_LASER_ACTIVE_STATE. Please update your Configuration_adv.h." #elif defined(SPINDLE_LASER_ENABLE_INVERT) - #error "SPINDLE_LASER_ENABLE_INVERT is now SPINDLE_LASER_ACTIVE_HIGH. Please update your Configuration_adv.h." + #error "SPINDLE_LASER_ENABLE_INVERT is now SPINDLE_LASER_ACTIVE_STATE. Please update your Configuration_adv.h." #elif defined(CUTTER_POWER_DISPLAY) #error "CUTTER_POWER_DISPLAY is now CUTTER_POWER_UNIT. Please update your Configuration_adv.h." #elif defined(CHAMBER_HEATER_PIN) @@ -441,10 +437,12 @@ #error "USB_SD_DISABLED is now NO_SD_HOST_DRIVE. Please update your Configuration_adv.h." #elif defined(USB_SD_ONBOARD) #error "USB_SD_ONBOARD is obsolete. Disable NO_SD_HOST_DRIVE instead." +#elif defined(PSU_ACTIVE_HIGH) + #error "PSU_ACTIVE_HIGH is now PSU_ACTIVE_STATE. Please update your configuration." #elif POWER_SUPPLY == 1 - #error "Replace POWER_SUPPLY 1 by enabling PSU_CONTROL and setting PSU_ACTIVE_HIGH to 'false'." + #error "Replace POWER_SUPPLY 1 by enabling PSU_CONTROL and setting PSU_ACTIVE_STATE to 'LOW'." #elif POWER_SUPPLY == 2 - #error "Replace POWER_SUPPLY 2 by enabling PSU_CONTROL and setting PSU_ACTIVE_HIGH to 'true'." + #error "Replace POWER_SUPPLY 2 by enabling PSU_CONTROL and setting PSU_ACTIVE_STATE to 'HIGH'." #elif defined(POWER_SUPPLY) #error "POWER_SUPPLY is now obsolete. Please remove it from Configuration.h." #elif defined(MKS_ROBIN_TFT) @@ -515,20 +513,21 @@ #error "DIGIPOT_I2C is now DIGIPOT_MCP4451 (or DIGIPOT_MCP4018). Please update Configuration_adv.h." #elif defined(TOUCH_BUTTONS) #error "TOUCH_BUTTONS is now TOUCH_SCREEN. Please update your Configuration.h." +#elif defined(LCD_FULL_PIXEL_HEIGHT) + #error "LCD_FULL_PIXEL_HEIGHT is deprecated and should be removed. Please update your Configuration.h." +#elif defined(LCD_FULL_PIXEL_WIDTH) + #error "LCD_FULL_PIXEL_WIDTH is deprecated and should be removed. Please update your Configuration.h." +#elif defined(FSMC_UPSCALE) + #error "FSMC_UPSCALE is now GRAPHICAL_TFT_UPSCALE. Please update your Configuration.h." #elif defined(ANYCUBIC_TFT_MODEL) #error "ANYCUBIC_TFT_MODEL is now ANYCUBIC_LCD_I3MEGA. Please update your Configuration.h." #elif defined(EVENT_GCODE_SD_STOP) #error "EVENT_GCODE_SD_STOP is now EVENT_GCODE_SD_ABORT. Please update your Configuration.h." -#endif - -#ifdef FIL_RUNOUT_INVERTING +#elif defined(FIL_RUNOUT_INVERTING) #if FIL_RUNOUT_INVERTING - #warning "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_STATE HIGH. Please update Configuration.h." + #error "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_STATE HIGH. Please update your Configuration.h." #else - #warning "FIL_RUNOUT_INVERTING false is now FIL_RUNOUT_STATE LOW. Please update Configuration.h." - #endif - #ifndef FIL_RUNOUT_STATE - #define FIL_RUNOUT_STATE ((FIL_RUNOUT_INVERTING) ? HIGH : LOW) + #error "FIL_RUNOUT_INVERTING false is now FIL_RUNOUT_STATE LOW. Please update your Configuration.h." #endif #endif @@ -765,6 +764,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(BABYSTEPPING) #if ENABLED(SCARA) #error "BABYSTEPPING is not implemented for SCARA yet." + #elif BOTH(MARKFORGED_XY, BABYSTEP_XY) + #error "BABYSTEPPING only implemented for Z axis on MarkForged." #elif BOTH(DELTA, BABYSTEP_XY) #error "BABYSTEPPING only implemented for Z axis on deltabots." #elif BOTH(BABYSTEP_ZPROBE_OFFSET, MESH_BED_LEVELING) @@ -788,6 +789,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(BABYSTEP_XY) static_assert(BABYSTEP_MULTIPLICATOR_XY <= 0.25f, "BABYSTEP_MULTIPLICATOR_XY must be less than or equal to 0.25mm."); #endif + #elif ENABLED(BABYSTEP_DISPLAY_TOTAL) && ANY(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI) + #error "New Color UI (TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI) does not support BABYSTEP_DISPLAY_TOTAL yet." #endif #endif @@ -1106,6 +1109,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "FANMUX0_PIN and FANMUX1_PIN must be set before FANMUX2_PIN can be set." #endif +/** + * Limited user-controlled fans + */ +#if NUM_M106_FANS > FAN_COUNT + #error "The selected board doesn't support enough user-controlled fans. Reduce NUM_M106_FANS." +#endif + /** * Limited number of servos */ @@ -1149,8 +1159,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS + ENABLED(COREYZ) \ + ENABLED(COREYX) \ + ENABLED(COREZX) \ - + ENABLED(COREZY) - #error "Please enable only one of DELTA, MORGAN_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, or COREZY." + + ENABLED(COREZY) \ + + ENABLED(MARKFORGED_XY) + #error "Please enable only one of DELTA, MORGAN_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, COREZY, or MARKFORGED_XY." #endif /** @@ -1311,7 +1322,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS static_assert(PROBING_MARGIN_RIGHT >= 0, "PROBING_MARGIN_RIGHT must be >= 0."); #endif - #define _MARGIN(A) TERN(IS_SCARA, SCARA_PRINTABLE_RADIUS, TERN(DELTA, DELTA_PRINTABLE_RADIUS, A##_CENTER)) + #define _MARGIN(A) TERN(IS_SCARA, SCARA_PRINTABLE_RADIUS, TERN(DELTA, DELTA_PRINTABLE_RADIUS, ((A##_BED_SIZE) / 2))) static_assert(PROBING_MARGIN < _MARGIN(X), "PROBING_MARGIN is too large."); static_assert(PROBING_MARGIN_BACK < _MARGIN(Y), "PROBING_MARGIN_BACK is too large."); static_assert(PROBING_MARGIN_FRONT < _MARGIN(Y), "PROBING_MARGIN_FRONT is too large."); @@ -1570,8 +1581,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if ENABLED(DUAL_X_CARRIAGE) #if EXTRUDERS < 2 #error "DUAL_X_CARRIAGE requires 2 (or more) extruders." - #elif CORE_IS_XY || CORE_IS_XZ - #error "DUAL_X_CARRIAGE cannot be used with COREXY, COREYX, COREXZ, or COREZX." + #elif ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) + #error "DUAL_X_CARRIAGE cannot be used with COREXY, COREYX, COREXZ, COREZX, or MARKFORGED_XY." #elif !GOOD_AXIS_PINS(X2) #error "DUAL_X_CARRIAGE requires X2 stepper pins to be defined." #elif !HAS_X_MAX @@ -2110,12 +2121,19 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if !(_RGB_TEST && PIN_EXISTS(RGB_LED_W)) #error "RGBW_LED requires RGB_LED_R_PIN, RGB_LED_G_PIN, RGB_LED_B_PIN, and RGB_LED_W_PIN." #endif -#elif ENABLED(NEOPIXEL_LED) - #if !(PIN_EXISTS(NEOPIXEL) && NEOPIXEL_PIXELS > 0) +#endif +#undef _RGB_TEST + +// NeoPixel requirements +#if ENABLED(NEOPIXEL_LED) + #if !PIN_EXISTS(NEOPIXEL) || NEOPIXEL_PIXELS == 0 #error "NEOPIXEL_LED requires NEOPIXEL_PIN and NEOPIXEL_PIXELS." + #elif ENABLED(NEOPIXEL2_SEPARATE) && !(defined(NEOPIXEL2_TYPE) && PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) + #error "NEOPIXEL2_SEPARATE requires NEOPIXEL2_TYPE, NEOPIXEL2_PIN and NEOPIXEL2_PIXELS." + #elif ENABLED(NEO2_COLOR_PRESETS) && DISABLED(NEOPIXEL2_SEPARATE) + #error "NEO2_COLOR_PRESETS requires NEOPIXEL2_SEPARATE to be enabled." #endif #endif -#undef _RGB_TEST #if DISABLED(NO_COMPILE_TIME_PWM) #define _TEST_PWM(P) PWM_PIN(P) @@ -2185,7 +2203,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal + (ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && DISABLED(IS_RRD_FG_SC)) \ + (ENABLED(ULTRA_LCD) && DISABLED(IS_ULTRA_LCD)) \ + (ENABLED(U8GLIB_SSD1306) && DISABLED(IS_U8GLIB_SSD1306)) \ - + (ENABLED(MINIPANEL) && DISABLED(MKS_MINI_12864, ENDER2_STOCKDISPLAY)) \ + + (ENABLED(MINIPANEL) && NONE(MKS_MINI_12864, ENDER2_STOCKDISPLAY)) \ + (ENABLED(MKS_MINI_12864) && DISABLED(MKS_LCD12864)) \ + (ENABLED(EXTENSIBLE_UI) && DISABLED(IS_EXTUI)) \ + (ENABLED(ULTIPANEL) && DISABLED(IS_ULTIPANEL)) \ @@ -2522,6 +2540,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "CoreXZ requires both X and Z to use sensorless homing if either one does." #elif CORE_IS_YZ && Y_SENSORLESS != Z_SENSORLESS && !HOMING_Z_WITH_PROBE #error "CoreYZ requires both Y and Z to use sensorless homing if either one does." +#elif ENABLED(MARKFORGED_XY) && X_SENSORLESS != Y_SENSORLESS + #error "MARKFORGED_XY requires both X and Y to use sensorless homing if either one does." #endif // Other TMC feature requirements @@ -2837,6 +2857,10 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #error "BACKLASH_COMPENSATION requires BACKLASH_DISTANCE_MM." #elif !defined(BACKLASH_CORRECTION) #error "BACKLASH_COMPENSATION requires BACKLASH_CORRECTION." + #elif ENABLED(MARKFORGED_XY) + constexpr float backlash_arr[] = BACKLASH_DISTANCE_MM; + static_assert(!backlash_arr[CORE_AXIS_1] && !backlash_arr[CORE_AXIS_2], + "BACKLASH_COMPENSATION can only apply to " STRINGIFY(NORMAL_AXIS) " on a MarkForged system."); #elif IS_CORE constexpr float backlash_arr[] = BACKLASH_DISTANCE_MM; static_assert(!backlash_arr[CORE_AXIS_1] && !backlash_arr[CORE_AXIS_2], @@ -2866,7 +2890,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #endif /** - * Prusa MMU2 requirements + * Průša MMU2 requirements */ #if ENABLED(PRUSA_MMU2) #if EXTRUDERS != 5 @@ -2910,8 +2934,8 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) * Ensure this option is set intentionally */ #if ENABLED(PSU_CONTROL) - #ifndef PSU_ACTIVE_HIGH - #error "PSU_CONTROL requires PSU_ACTIVE_HIGH to be defined as 'true' or 'false'." + #ifndef PSU_ACTIVE_STATE + #error "PSU_CONTROL requires PSU_ACTIVE_STATE to be defined as 'HIGH' or 'LOW'." #elif !PIN_EXISTS(PS_ON) #error "PSU_CONTROL requires PS_ON_PIN." #endif @@ -3082,7 +3106,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) * Sanity check for WIFI */ #if EITHER(ESP3D_WIFISUPPORT, WIFISUPPORT) && DISABLED(ARDUINO_ARCH_ESP32) - #error "ESP3D_WIFISUPPORT or WIFISUPPORT requires an ESP32 controller." + #error "ESP3D_WIFISUPPORT or WIFISUPPORT requires an ESP32 MOTHERBOARD." #endif /** diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index b0b9bfd96e50..14d019088c8f 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-08-14" + #define STRING_DISTRIBUTION_DATE "2020-09-07" #endif /** diff --git a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index 9ba9b871ecca..9fe69d442832 100644 --- a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -982,7 +982,7 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { if (max_length < 1) return 0; - // TODO: fix the '\\' that doesnt exist in the HD44870 + // TODO: fix the '\\' that doesn't exist in the HD44870 if (c < 128) { lcd.write((uint8_t)c); return 1; diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index 1f9621e9c05e..da7d4f6f1ec0 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -82,16 +82,6 @@ #define U8G_COM_SSD_I2C_HAL u8g_com_arduino_ssd_i2c_fn - #if PIN_EXISTS(FSMC_CS) - uint8_t u8g_com_stm32duino_fsmc_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_HAL_FSMC_FN u8g_com_stm32duino_fsmc_fn - #endif - - #if ENABLED(SPI_GRAPHICAL_TFT) - uint8_t u8g_com_stm32duino_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_HAL_FSMC_FN u8g_com_stm32duino_spi_fn - #endif - #elif defined(TARGET_LPC1768) uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); @@ -122,6 +112,9 @@ #ifndef U8G_COM_SSD_I2C_HAL #define U8G_COM_SSD_I2C_HAL u8g_com_null_fn #endif -#ifndef U8G_COM_HAL_FSMC_FN - #define U8G_COM_HAL_FSMC_FN u8g_com_null_fn +#if EITHER(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT) + uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + #define U8G_COM_HAL_TFT_FN u8g_com_hal_tft_fn +#else + #define U8G_COM_HAL_TFT_FN u8g_com_null_fn #endif diff --git a/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp b/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp index 205cafbccb39..39c294defe5b 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp @@ -67,28 +67,24 @@ #define HAS_LCD_IO 1 #endif -#if HAS_LCD_IO - extern void LCD_IO_Init(uint8_t cs, uint8_t rs); - extern uint16_t LCD_IO_ReadData(uint16_t Reg); - extern uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize); - extern void LCD_IO_WriteReg(uint16_t Reg); - extern void LCD_IO_WriteData(uint16_t RegValue); - extern void LCD_IO_WriteSequence(uint16_t *data, uint16_t length); - extern void LCD_IO_WriteSequence_Async(uint16_t *data, uint16_t length); - extern void LCD_IO_WaitSequence_Async(); - extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count); +#if ENABLED(SPI_GRAPHICAL_TFT) + #include HAL_PATH(../../HAL, tft/tft_spi.h) +#elif ENABLED(FSMC_GRAPHICAL_TFT) + #include HAL_PATH(../../HAL, tft/tft_fsmc.h) #endif +TFT_IO tftio; + #define WIDTH LCD_PIXEL_WIDTH #define HEIGHT LCD_PIXEL_HEIGHT #define PAGE_HEIGHT 8 #include "../scaled_tft.h" -#define UPSCALE0(M) ((M) * (FSMC_UPSCALE)) +#define UPSCALE0(M) ((M) * (GRAPHICAL_TFT_UPSCALE)) #define UPSCALE(A,M) (UPSCALE0(M) + (A)) -#define X_HI (UPSCALE(LCD_PIXEL_OFFSET_X, WIDTH) - 1) -#define Y_HI (UPSCALE(LCD_PIXEL_OFFSET_Y, HEIGHT) - 1) +#define X_HI (UPSCALE(TFT_PIXEL_OFFSET_X, WIDTH) - 1) +#define Y_HI (UPSCALE(TFT_PIXEL_OFFSET_Y, HEIGHT) - 1) // see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html @@ -156,7 +152,8 @@ static uint32_t lcd_id = 0; static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { #if HAS_LCD_IO - #define IO_REG_DATA(R,D) do { LCD_IO_WriteReg(R); LCD_IO_WriteData(D); }while(0) + tftio.DataTransferBegin(DATASIZE_8BIT); + #define IO_REG_DATA(R,D) do { tftio.WriteReg(R); tftio.WriteData(D); }while(0) #else #define IO_REG_DATA(R,D) do { u8g_WriteByte(u8g, dev, R); u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&D); }while(0) #endif @@ -174,7 +171,8 @@ static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_ IO_REG_DATA(ILI9328_VASET, Xmin); #if HAS_LCD_IO - LCD_IO_WriteReg(ILI9328_WRITE_RAM); + tftio.WriteReg(ILI9328_WRITE_RAM); + tftio.DataTransferEnd(); #else u8g_WriteByte(u8g, dev, ILI9328_WRITE_RAM); u8g_SetAddress(u8g, dev, 1); @@ -183,19 +181,21 @@ static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_ static void setWindow_st7789v(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { #if HAS_LCD_IO - LCD_IO_WriteReg(ST7789V_CASET); - LCD_IO_WriteData((Xmin >> 8) & 0xFF); - LCD_IO_WriteData(Xmin & 0xFF); - LCD_IO_WriteData((Xmax >> 8) & 0xFF); - LCD_IO_WriteData(Xmax & 0xFF); - - LCD_IO_WriteReg(ST7789V_RASET); - LCD_IO_WriteData((Ymin >> 8) & 0xFF); - LCD_IO_WriteData(Ymin & 0xFF); - LCD_IO_WriteData((Ymax >> 8) & 0xFF); - LCD_IO_WriteData(Ymax & 0xFF); - - LCD_IO_WriteReg(ST7789V_WRITE_RAM); + tftio.DataTransferBegin(DATASIZE_8BIT); + tftio.WriteReg(ST7789V_CASET); + tftio.WriteData((Xmin >> 8) & 0xFF); + tftio.WriteData(Xmin & 0xFF); + tftio.WriteData((Xmax >> 8) & 0xFF); + tftio.WriteData(Xmax & 0xFF); + + tftio.WriteReg(ST7789V_RASET); + tftio.WriteData((Ymin >> 8) & 0xFF); + tftio.WriteData(Ymin & 0xFF); + tftio.WriteData((Ymax >> 8) & 0xFF); + tftio.WriteData(Ymax & 0xFF); + + tftio.WriteReg(ST7789V_WRITE_RAM); + tftio.DataTransferEnd(); #else u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_CASET); u8g_SetAddress(u8g, dev, 1); u8g_WriteByte(u8g, dev, (Xmin >> 8) & 0xFF); @@ -227,17 +227,17 @@ void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint for (;;) { data = *sequence++; if (data != 0xFFFF) { - LCD_IO_WriteData(data); + tftio.WriteData(data); continue; } data = *sequence++; if (data == 0x7FFF) return; if (data == 0xFFFF) { - LCD_IO_WriteData(data); + tftio.WriteData(data); } else if (data & 0x8000) { delay(data & 0x7FFF); } else if ((data & 0xFF00) == 0) { - LCD_IO_WriteReg(data); + tftio.WriteReg(data); } } } @@ -298,7 +298,7 @@ static const uint16_t st7789v_init[] = { ESC_REG(0x0010), ESC_DELAY(10), ESC_REG(0x0001), ESC_DELAY(200), ESC_REG(0x0011), ESC_DELAY(120), - ESC_REG(0x0036), 0x00A0, + ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x0060, 0x00A0), ESC_REG(0x003A), 0x0055, ESC_REG(0x002A), 0x0000, 0x0000, 0x0001, 0x003F, ESC_REG(0x002B), 0x0000, 0x0000, 0x0000, 0x00EF, @@ -366,7 +366,7 @@ static const uint16_t ili9328_init[] = { static const uint16_t ili9341_init[] = { ESC_REG(0x0010), ESC_DELAY(10), ESC_REG(0x0001), ESC_DELAY(200), - ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x00E8, 0x0028), + ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x0028, 0x00E8), ESC_REG(0x003A), 0x0055, ESC_REG(0x002A), 0x0000, 0x0000, 0x0001, 0x003F, ESC_REG(0x002B), 0x0000, 0x0000, 0x0000, 0x00EF, @@ -591,7 +591,7 @@ static const uint16_t st7796_init[] = { #define BUTTON_Y_HI (UPSCALE(BUTTON_Y_LO, BUTTON_SIZE_Y) - 1) void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) { - uint16_t buffer[BUTTON_SIZE_X * sq(FSMC_UPSCALE)]; + uint16_t buffer[BUTTON_SIZE_X * sq(GRAPHICAL_TFT_UPSCALE)]; if (length > BUTTON_SIZE_X) return; @@ -603,16 +603,16 @@ static const uint16_t st7796_init[] = { v = color; else v = TFT_MARLINBG_COLOR; - LOOP_L_N(n, FSMC_UPSCALE) buffer[k++] = v; + LOOP_L_N(n, GRAPHICAL_TFT_UPSCALE) buffer[k++] = v; } #if HAS_LCD_IO - LOOP_S_L_N(n, 1, FSMC_UPSCALE) + LOOP_S_L_N(n, 1, GRAPHICAL_TFT_UPSCALE) for (uint16_t l = 0; l < UPSCALE0(length); l++) buffer[l + n * UPSCALE0(length)] = buffer[l]; - LCD_IO_WriteSequence(buffer, length * sq(FSMC_UPSCALE)); + tftio.WriteSequence(buffer, length * sq(GRAPHICAL_TFT_UPSCALE)); #else - for (uint8_t i = FSMC_UPSCALE; i--;) + for (uint8_t i = GRAPHICAL_TFT_UPSCALE; i--;) u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer); #endif } @@ -632,22 +632,17 @@ static uint8_t page; uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); - #if ENABLED(SPI_GRAPHICAL_TFT) - LCD_IO_Init(-1, -1); - #endif - #if HAS_LCD_IO - static uint16_t bufferA[WIDTH * sq(FSMC_UPSCALE)], bufferB[WIDTH * sq(FSMC_UPSCALE)]; + static uint16_t bufferA[WIDTH * sq(GRAPHICAL_TFT_UPSCALE)], bufferB[WIDTH * sq(GRAPHICAL_TFT_UPSCALE)]; uint16_t* buffer = &bufferA[0]; - bool allow_async = DISABLED(SPI_GRAPHICAL_TFT); #else - uint16_t buffer[WIDTH * FSMC_UPSCALE]; // 16-bit RGB 565 pixel line buffer + uint16_t buffer[WIDTH * GRAPHICAL_TFT_UPSCALE]; // 16-bit RGB 565 pixel line buffer #endif switch (msg) { case U8G_DEV_MSG_INIT: dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, &lcd_id); - + tftio.DataTransferBegin(DATASIZE_8BIT); switch (lcd_id & 0xFFFF) { case 0x8552: // ST7789V WRITE_ESC_SEQUENCE(st7789v_init); @@ -658,6 +653,9 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u setWindow = setWindow_ili9328; break; case 0x9341: // ILI9341 + WRITE_ESC_SEQUENCE(ili9341_init); + setWindow = setWindow_st7789v; + break; case 0x8066: // Anycubic / TronXY TFTs (480x320) WRITE_ESC_SEQUENCE(ili9488_init); setWindow = setWindow_st7789v; @@ -679,6 +677,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u setWindow = (lcd_id & 0xFF000000) ? setWindow_st7789v : setWindow_ili9328; break; } + tftio.DataTransferEnd(); if (preinit) { preinit = false; @@ -686,13 +685,13 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u } // Clear Screen - setWindow(u8g, dev, 0, 0, (LCD_FULL_PIXEL_WIDTH) - 1, (LCD_FULL_PIXEL_HEIGHT) - 1); + setWindow(u8g, dev, 0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1); #if HAS_LCD_IO - LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT)); + tftio.WriteMultiple(TFT_MARLINBG_COLOR, uint32_t(TFT_WIDTH) * (TFT_HEIGHT)); #else - memset2(buffer, TFT_MARLINBG_COLOR, (LCD_FULL_PIXEL_WIDTH) / 2); - for (uint16_t i = 0; i < (LCD_FULL_PIXEL_HEIGHT) * sq(FSMC_UPSCALE); i++) - u8g_WriteSequence(u8g, dev, LCD_FULL_PIXEL_WIDTH / 2, (uint8_t *)buffer); + memset2(buffer, TFT_MARLINBG_COLOR, (TFT_WIDTH) / 2); + for (uint16_t i = 0; i < (TFT_HEIGHT) * sq(GRAPHICAL_TFT_UPSCALE); i++) + u8g_WriteSequence(u8g, dev, (TFT_WIDTH) / 2, (uint8_t *)buffer); #endif // Bottom buttons @@ -716,7 +715,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u case U8G_DEV_MSG_PAGE_FIRST: page = 0; - setWindow(u8g, dev, LCD_PIXEL_OFFSET_X, LCD_PIXEL_OFFSET_Y, X_HI, Y_HI); + setWindow(u8g, dev, TFT_PIXEL_OFFSET_X, TFT_PIXEL_OFFSET_Y, X_HI, Y_HI); break; case U8G_DEV_MSG_PAGE_NEXT: @@ -730,26 +729,18 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u for (uint16_t i = 0; i < (uint32_t)pb->width; i++) { const uint8_t b = *(((uint8_t *)pb->buf) + i); const uint16_t c = TEST(b, y) ? TFT_MARLINUI_COLOR : TFT_MARLINBG_COLOR; - LOOP_L_N(n, FSMC_UPSCALE) buffer[k++] = c; + LOOP_L_N(n, GRAPHICAL_TFT_UPSCALE) buffer[k++] = c; } #if HAS_LCD_IO - LOOP_S_L_N(n, 1, FSMC_UPSCALE) + LOOP_S_L_N(n, 1, GRAPHICAL_TFT_UPSCALE) for (uint16_t l = 0; l < UPSCALE0(WIDTH); l++) buffer[l + n * UPSCALE0(WIDTH)] = buffer[l]; - if (allow_async) { - if (y > 0 || page > 1) LCD_IO_WaitSequence_Async(); - if (y == 7 && page == 8) - LCD_IO_WriteSequence(buffer, COUNT(bufferA)); // last line of last page - else - LCD_IO_WriteSequence_Async(buffer, COUNT(bufferA)); - } - else - LCD_IO_WriteSequence(buffer, COUNT(bufferA)); + tftio.WriteSequence(buffer, COUNT(bufferA)); #else uint8_t* bufptr = (uint8_t*) buffer; - for (uint8_t i = FSMC_UPSCALE; i--;) { - LOOP_S_L_N(n, 0, FSMC_UPSCALE * 2) { + for (uint8_t i = GRAPHICAL_TFT_UPSCALE; i--;) { + LOOP_S_L_N(n, 0, GRAPHICAL_TFT_UPSCALE * 2) { u8g_WriteSequence(u8g, dev, WIDTH, &bufptr[WIDTH * n]); } } @@ -767,6 +758,59 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); } -U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_tft_320x240_upscale_from_128x64_fn, U8G_COM_HAL_FSMC_FN); +static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT + +uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { + if (msgInitCount) { + if (msg == U8G_COM_MSG_INIT) msgInitCount--; + if (msgInitCount) return -1; + } + + static uint8_t isCommand; + + switch (msg) { + case U8G_COM_MSG_STOP: break; + case U8G_COM_MSG_INIT: + u8g_SetPIOutput(u8g, U8G_PI_RESET); + + u8g_Delay(50); + + tftio.Init(); + + if (arg_ptr) { + *((uint32_t *)arg_ptr) = tftio.GetID(); + } + isCommand = 0; + break; + + case U8G_COM_MSG_ADDRESS: // define cmd (arg_val = 0) or data mode (arg_val = 1) + isCommand = arg_val == 0 ? 1 : 0; + break; + + case U8G_COM_MSG_RESET: + u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); + break; + + case U8G_COM_MSG_WRITE_BYTE: + tftio.DataTransferBegin(DATASIZE_8BIT); + if (isCommand) + tftio.WriteReg(arg_val); + else + tftio.WriteData((uint16_t)arg_val); + tftio.DataTransferEnd(); + break; + + case U8G_COM_MSG_WRITE_SEQ: + tftio.DataTransferBegin(DATASIZE_16BIT); + for (uint8_t i = 0; i < arg_val; i += 2) + tftio.WriteData(*(uint16_t *)(((uint32_t)arg_ptr) + i)); + tftio.DataTransferEnd(); + break; + + } + return 1; +} + +U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_tft_320x240_upscale_from_128x64_fn, U8G_COM_HAL_TFT_FN); #endif // HAS_GRAPHICAL_LCD && FSMC_CS diff --git a/Marlin/src/lcd/dogm/u8g_dev_uc1701_mini12864_HAL.cpp b/Marlin/src/lcd/dogm/u8g_dev_uc1701_mini12864_HAL.cpp index 85339e83495a..e4e387c1907f 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_uc1701_mini12864_HAL.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_uc1701_mini12864_HAL.cpp @@ -112,6 +112,7 @@ static const uint8_t u8g_dev_uc1701_mini12864_HAL_init_seq[] PROGMEM = { U8G_ESC_CS(1), // enable chip UC1701_ALL_PIX(0), // normal display U8G_ESC_CS(0), // disable chip + U8G_ESC_DLY(150), // delay 150 ms before sending any data U8G_ESC_END // end of sequence }; diff --git a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp index d17c336eec24..bf0edbb8ded2 100644 --- a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp @@ -240,39 +240,35 @@ bool MarlinUI::detected() { return true; } // Initialize or re-initialize the LCD void MarlinUI::init_lcd() { - #if DISABLED(MKS_LCD12864) - - #if PIN_EXISTS(LCD_BACKLIGHT) - OUT_WRITE(LCD_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); // Illuminate after reset or right away - #endif - - #if ANY(MKS_12864OLED, MKS_12864OLED_SSD1306, FYSETC_242_OLED_12864, ZONESTAR_12864OLED) - SET_OUTPUT(LCD_PINS_DC); - #ifndef LCD_RESET_PIN - #define LCD_RESET_PIN LCD_PINS_RS - #endif + #if PIN_EXISTS(LCD_BACKLIGHT) + OUT_WRITE(LCD_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); // Illuminate after reset or right away + #endif + + #if ANY(MKS_12864OLED, MKS_12864OLED_SSD1306, FYSETC_242_OLED_12864, ZONESTAR_12864OLED) + SET_OUTPUT(LCD_PINS_DC); + #ifndef LCD_RESET_PIN + #define LCD_RESET_PIN LCD_PINS_RS #endif + #endif - #if PIN_EXISTS(LCD_RESET) - // Perform a clean hardware reset with needed delays - OUT_WRITE(LCD_RESET_PIN, LOW); - _delay_ms(5); - WRITE(LCD_RESET_PIN, HIGH); - _delay_ms(5); - u8g.begin(); - #endif - - #if PIN_EXISTS(LCD_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT) - WRITE(LCD_BACKLIGHT_PIN, HIGH); - #endif + #if PIN_EXISTS(LCD_RESET) + // Perform a clean hardware reset with needed delays + OUT_WRITE(LCD_RESET_PIN, LOW); + _delay_ms(5); + WRITE(LCD_RESET_PIN, HIGH); + _delay_ms(5); + u8g.begin(); + #endif - TERN_(HAS_LCD_CONTRAST, refresh_contrast()); + #if PIN_EXISTS(LCD_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT) + WRITE(LCD_BACKLIGHT_PIN, HIGH); + #endif - TERN_(LCD_SCREEN_ROT_90, u8g.setRot90()); - TERN_(LCD_SCREEN_ROT_180, u8g.setRot180()); - TERN_(LCD_SCREEN_ROT_270, u8g.setRot270()); + TERN_(HAS_LCD_CONTRAST, refresh_contrast()); - #endif // !MKS_LCD12864 + TERN_(LCD_SCREEN_ROT_90, u8g.setRot90()); + TERN_(LCD_SCREEN_ROT_180, u8g.setRot180()); + TERN_(LCD_SCREEN_ROT_270, u8g.setRot270()); uxg_SetUtf8Fonts(g_fontinfo, COUNT(g_fontinfo)); } @@ -439,6 +435,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop lcd_put_u8str(value); } } + TERN_(USE_BIG_EDIT_FONT, ui.set_font(FONT_MENU)); } inline void draw_boxed_string(const u8g_uint_t x, const u8g_uint_t y, PGM_P const pstr, const bool inv) { diff --git a/Marlin/src/lcd/dwin/dwin_lcd.cpp b/Marlin/src/lcd/dwin/dwin_lcd.cpp index 0ca6b8a3ae62..3b30629a8dae 100644 --- a/Marlin/src/lcd/dwin/dwin_lcd.cpp +++ b/Marlin/src/lcd/dwin/dwin_lcd.cpp @@ -37,9 +37,12 @@ #include "dwin_lcd.h" #include // for memset -// Make sure DWIN_SendBuf is large enough to hold the largest -// printed string plus the draw command and tail. -uint8_t DWIN_SendBuf[11 + 24] = { 0xAA }; +//#define DEBUG_OUT 1 +#include "../../core/debug_out.h" + +// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail. +// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters. +uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA }; uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C }; uint8_t databuf[26] = { 0 }; uint8_t receivedType; @@ -63,7 +66,7 @@ inline void DWIN_Long(size_t &i, const uint32_t lval) { } inline void DWIN_String(size_t &i, char * const string) { - const size_t len = strlen(string); + const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, strlen(string)); memcpy(&DWIN_SendBuf[i+1], string, len); i += len; } @@ -79,10 +82,8 @@ inline void DWIN_String(size_t &i, const __FlashStringHelper * string) { // Send the data in the buffer and the packet end inline void DWIN_Send(size_t &i) { ++i; - LOOP_L_N(n, i) { MYSERIAL1.write(DWIN_SendBuf[n]); - delayMicroseconds(1); } - LOOP_L_N(n, 4) { MYSERIAL1.write(DWIN_BufTail[n]); - delayMicroseconds(1); } + LOOP_L_N(n, i) { MYSERIAL1.write(DWIN_SendBuf[n]); delayMicroseconds(1); } + LOOP_L_N(n, 4) { MYSERIAL1.write(DWIN_BufTail[n]); delayMicroseconds(1); } } /*-------------------------------------- System variable function --------------------------------------*/ @@ -185,7 +186,6 @@ void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, DWIN_Send(i); } -// // Move a screen area // mode: 0, circle shift; 1, translation // dir: 0=left, 1=right, 2=up, 3=down @@ -230,19 +230,6 @@ void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, DWIN_Send(i); } -void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, - uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *string) { - size_t i = 0; - DWIN_Byte(i, 0x11); - DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size); - DWIN_Word(i, color); - DWIN_Word(i, bColor); - DWIN_Word(i, x); - DWIN_Word(i, y); - DWIN_String(i, string); - DWIN_Send(i); -} - // Draw a positive integer // bShow: true=display background color; false=don't display background color // zeroFill: true=zero fill; false=no zero fill @@ -343,8 +330,9 @@ void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) { DWIN_Send(i); } -// Unzip the JPG picture to virtual display area #1 -// id: picture ID +// Unzip the JPG picture to a virtual display area +// n: Cache index +// id: Picture ID void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) { size_t i = 0; DWIN_Byte(i, 0x25); diff --git a/Marlin/src/lcd/dwin/dwin_lcd.h b/Marlin/src/lcd/dwin/dwin_lcd.h index 3fae1ccfc91a..0893974e4c3f 100644 --- a/Marlin/src/lcd/dwin/dwin_lcd.h +++ b/Marlin/src/lcd/dwin/dwin_lcd.h @@ -42,70 +42,151 @@ #define DWIN_WIDTH 272 #define DWIN_HEIGHT 480 -/*接收数据解析 返回值:true,接收到数据;false,未接收到数据*/ -bool DWIN_ReceiveAnalyze(void); +/*-------------------------------------- System variable function --------------------------------------*/ -/*发送当前BUF中的数据以及包尾数据 len:整包数据长度*/ -void DWIN_Send_BufTail(const uint8_t len); - -/*----------------------------------------------系统变量函数----------------------------------------------*/ -/*握手 1: 握手成功 2: 握手失败*/ +// Handshake (1: Success, 0: Fail) bool DWIN_Handshake(void); -/*设定背光亮度 luminance:亮度(0x00~0xFF)*/ +// Common DWIN startup +void DWIN_Startup(void); + +// Set the backlight luminance +// luminance: (0x00-0xFF) void DWIN_Backlight_SetLuminance(const uint8_t luminance); -/*设定画面显示方向 dir:0,0°; 1,90°; 2,180°; 3,270°*/ +// Set screen display direction +// dir: 0=0°, 1=90°, 2=180°, 3=270° void DWIN_Frame_SetDir(uint8_t dir); -/*更新显示*/ +// Update display void DWIN_UpdateLCD(void); -/*----------------------------------------------绘图相关函数----------------------------------------------*/ -/*画面清屏 color:清屏颜色*/ +/*---------------------------------------- Drawing functions ----------------------------------------*/ + +// Clear screen +// color: Clear screen color void DWIN_Frame_Clear(const uint16_t color); -/*画面画线 color:线段颜色 xStart:X起始坐标 yStart:Y起始坐标 xEnd:X终止坐标 yEnd:Y终止坐标*/ +// Draw a line +// color: Line segment color +// xStart/yStart: Start point +// xEnd/yEnd: End point void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd); -/*画面画矩形 mode:0,外框;1,填充;2,异或填充 color:颜色 xStart/yStart:矩形左上坐标 xEnd/yEnd:矩形右下坐标*/ +// Draw a Horizontal line +// color: Line segment color +// xStart/yStart: Start point +// xLength: Line Length +inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) { + DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart); +} + +// Draw a Vertical line +// color: Line segment color +// xStart/yStart: Start point +// yLength: Line Length +inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) { + DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1); +} + +// Draw a rectangle +// mode: 0=frame, 1=fill, 2=XOR fill +// color: Rectangle color +// xStart/yStart: upper left point +// xEnd/yEnd: lower right point void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd); -/*画面区域移动 mode:0,环移;1,平移 dir:0,向左移动;1,向右移动;2,向上移动;3,向下移动 dis:移动距离 - color:填充颜色 xStart/yStart:选定区域左上坐标 xEnd/yEnd:选定区域右下坐标*/ +// Draw a box +// mode: 0=frame, 1=fill, 2=XOR fill +// color: Rectangle color +// xStart/yStart: upper left point +// xSize/ySize: box size +inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) { + DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1); +} + +// Move a screen area +// mode: 0, circle shift; 1, translation +// dir: 0=left, 1=right, 2=up, 3=down +// dis: Distance +// color: Fill color +// xStart/yStart: upper left point +// xEnd/yEnd: bottom right point void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd); -/*----------------------------------------------文本相关函数----------------------------------------------*/ -/*画面显示字符串 widthAdjust:true,自调整字符宽度;false,不调整字符宽度 bShow:true,显示背景色;false,不显示背景色 size:字号大小 - color:字符颜色 bColor:背景颜色 x/y:字符串左上坐标 *string:字符串*/ +/*---------------------------------------- Text related functions ----------------------------------------*/ + +// Draw a string +// widthAdjust: true=self-adjust character width; false=no adjustment +// bShow: true=display background color; false=don't display background color +// size: Font size +// color: Character color +// bColor: Background color +// x/y: Upper-left coordinate of the string +// *string: The string void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string); -/*画面显示正整数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小 - color:字符颜色 bColor:背景颜色 iNum:位数 x/y:变量左上坐标 value:整型变量*/ +class __FlashStringHelper; + +inline void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) { + DWIN_Draw_String(widthAdjust, bShow, size, color, bColor, x, y, (char *)title); +} + +// Draw a positive integer +// bShow: true=display background color; false=don't display background color +// zeroFill: true=zero fill; false=no zero fill +// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of digits +// x/y: Upper-left coordinate +// value: Integer value 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, uint16_t value); -/*画面显示浮点数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小 - color:字符颜色 bColor:背景颜色 iNum:整数位数 fNum:小数位数 x/y:变量左上坐标 value:浮点数变量*/ +// Draw a floating point number +// bShow: true=display background color; false=don't display background color +// zeroFill: true=zero fill; false=no zero fill +// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of whole digits +// fNum: Number of decimal digits +// x/y: Upper-left point +// value: Float value void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value); -/*----------------------------------------------图片相关函数----------------------------------------------*/ -/*jpg图片显示并缓存在#0虚拟显示区 id:图片ID*/ +/*---------------------------------------- Picture related functions ----------------------------------------*/ + +// Draw JPG and cached in #0 virtual display area +// id: Picture ID void DWIN_JPG_ShowAndCache(const uint8_t id); -/*图标显示 libID:图标库ID picID:图标ID x/y:图标左上坐标*/ +// Draw an Icon +// libID: Icon library ID +// picID: Icon ID +// x/y: Upper-left point void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y); -/*jpg图片解压到#1虚拟显示区 id:图片ID*/ +// Unzip the JPG picture to a virtual display area +// n: Cache index +// id: Picture ID void DWIN_JPG_CacheToN(uint8_t n, uint8_t id); -/*jpg图片解压到#1虚拟显示区 id:图片ID*/ +// Unzip the JPG picture to virtual display area #1 +// id: Picture ID inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); } -/*从虚拟显示区复制区域至当前画面 cacheID:虚拟区号 xStart/yStart:虚拟区左上坐标 xEnd/yEnd:虚拟区右下坐标 x/y:当前画面粘贴坐标*/ +// Copy area from virtual display area to current screen +// cacheID: virtual area number +// xStart/yStart: Upper-left of virtual area +// xEnd/yEnd: Lower-right of virtual area +// x/y: Screen paste point void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y); diff --git a/Marlin/src/lcd/dwin/README.md b/Marlin/src/lcd/dwin/e3v2/README.md similarity index 100% rename from Marlin/src/lcd/dwin/README.md rename to Marlin/src/lcd/dwin/e3v2/README.md diff --git a/Marlin/src/lcd/dwin/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp similarity index 86% rename from Marlin/src/lcd/dwin/dwin.cpp rename to Marlin/src/lcd/dwin/e3v2/dwin.cpp index 1aa2656dcfd6..1d9c83e6da8a 100644 --- a/Marlin/src/lcd/dwin/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -24,49 +24,51 @@ * DWIN by Creality3D */ -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if ENABLED(DWIN_CREALITY_LCD) +#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY) + #define HAS_ONESTEP_LEVELING 1 +#endif + #include "dwin.h" #include #include #include -#include "../fontutils.h" -#include "../ultralcd.h" +#include "../../fontutils.h" +#include "../../ultralcd.h" -#include "../../sd/cardreader.h" +#include "../../../sd/cardreader.h" -#include "../../MarlinCore.h" -#include "../../core/serial.h" -#include "../../core/macros.h" -#include "../../gcode/queue.h" +#include "../../../MarlinCore.h" +#include "../../../core/serial.h" +#include "../../../core/macros.h" +#include "../../../gcode/queue.h" -#include "../../feature/powerloss.h" -#include "../../feature/babystep.h" +#include "../../../feature/powerloss.h" +#include "../../../feature/babystep.h" -#include "../../module/settings.h" -#include "../../module/temperature.h" -#include "../../module/printcounter.h" -#include "../../module/motion.h" -#include "../../module/planner.h" +#include "../../../module/settings.h" +#include "../../../module/temperature.h" +#include "../../../module/printcounter.h" +#include "../../../module/motion.h" +#include "../../../module/planner.h" #if ENABLED(HOST_ACTION_COMMANDS) - #include "../../feature/host_actions.h" + #include "../../../feature/host_actions.h" #endif -#if HAS_LEVELING - #include "../../feature/bedlevel/bedlevel.h" +#if HAS_ONESTEP_LEVELING + #include "../../../feature/bedlevel/bedlevel.h" #endif #if HAS_BED_PROBE - #include "../../module/probe.h" + #include "../../../module/probe.h" #endif -#include "../../libs/buzzer.h" - #ifndef MACHINE_SIZE #define MACHINE_SIZE "220x220x250" #endif @@ -192,23 +194,23 @@ float last_zoffset = 0, last_probe_zoffset = 0; #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 -void lcd_select_language(void) { - BL24CXX::read(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_flag, sizeof(HMI_flag.language_flag)); - if (HMI_flag.language_flag) +void HMI_SetLanguage(void) { + BL24CXX::read(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); + if (HMI_flag.language_chinese) DWIN_JPG_CacheTo1(Language_Chinese); else DWIN_JPG_CacheTo1(Language_English); } -void set_english_to_eeprom(void) { - HMI_flag.language_flag = 0; +void HMI_SetAndSaveLanguageWestern(void) { + HMI_flag.language_chinese = false; DWIN_JPG_CacheTo1(Language_English); - BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_flag, sizeof(HMI_flag.language_flag)); + BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); } -void set_chinese_to_eeprom(void) { - HMI_flag.language_flag = 1; +void HMI_SetAndSaveLanguageChinese(void) { + HMI_flag.language_chinese = true; DWIN_JPG_CacheTo1(Language_Chinese); - BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_flag, sizeof(HMI_flag.language_flag)); + BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); } void show_plus_or_minus(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) { @@ -225,14 +227,14 @@ void show_plus_or_minus(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNu void ICON_Print() { if (select_page.now == 0) { DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 1, 447, 271 - 243, 479 - 19, 58, 201); else DWIN_Frame_AreaCopy(1, 1, 451, 271 - 240, 479 - 16, 72 - 15, 201); } else { DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 1, 405, 271 - 243, 420, 58, 201); else DWIN_Frame_AreaCopy(1, 1, 423, 271 - 240, 423 + 12, 72 - 15, 201); @@ -242,14 +244,14 @@ void ICON_Print() { void ICON_Prepare() { if (select_page.now == 1) { DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 31, 447, 271 - 213, 479 - 19, 186, 201); else DWIN_Frame_AreaCopy(1, 33, 451, 271 - 189, 479 - 13, 200 - 25, 201); } else { DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 31, 405, 271 - 213, 420, 186, 201); else DWIN_Frame_AreaCopy(1, 33, 423, 271 - 189, 423 + 15, 200 - 25, 201); @@ -259,14 +261,14 @@ void ICON_Prepare() { void ICON_Control() { if (select_page.now == 2) { DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 61, 447, 271 - 183, 479 - 19, 58, 318); else DWIN_Frame_AreaCopy(1, 85, 451, 271 - 139, 479 - 16, 72 - 24, 318); } else { DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 61, 405, 271 - 183, 420, 58, 318); else DWIN_Frame_AreaCopy(1, 85, 423, 271 - 139, 479 - 45, 72 - 24, 318); @@ -276,14 +278,14 @@ void ICON_Control() { void ICON_StartInfo(bool show) { if (show) { DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 91, 447, 271 - 153, 479 - 19, 186, 318); else DWIN_Frame_AreaCopy(1, 132, 451, 159, 479 - 13, 186, 318); } else { DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 91, 405, 271 - 153, 420, 186, 318); else DWIN_Frame_AreaCopy(1, 132, 423, 159, 423 + 12, 186, 318); @@ -293,14 +295,14 @@ void ICON_StartInfo(bool show) { void ICON_Leveling(bool show) { if (show) { DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 211, 447, 238, 479 - 19, 186, 318); else DWIN_Frame_AreaCopy(1, 84, 437, 120, 449, 200 - 18, 318); } else { DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 211, 405, 238, 420, 186, 318); else DWIN_Frame_AreaCopy(1, 84, 465, 120, 478, 200 - 18, 318); @@ -310,14 +312,14 @@ void ICON_Leveling(bool show) { void ICON_Tune() { if (select_print.now == 0) { DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 121, 447, 271 - 123, 479 - 21, 34, 325); else DWIN_Frame_AreaCopy(1, 1, 465, 271 - 237, 479 - 2, 48 - 17, 325); } else { DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 121, 405, 271 - 123, 420, 34, 325); else DWIN_Frame_AreaCopy(1, 1, 438, 271 - 239, 479 - 31, 48 - 17, 325); @@ -327,14 +329,14 @@ void ICON_Tune() { void ICON_Pause() { if (select_print.now == 1) { DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 181, 447, 271 - 63, 479 - 20, 124, 325); else DWIN_Frame_AreaCopy(1, 177, 451, 271 - 55, 479 - 17, 136 - 20, 325); } else { DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 181, 405, 271 - 63, 420, 124, 325); else DWIN_Frame_AreaCopy(1, 177, 423, 271 - 56, 479 - 46, 136 - 20, 325); @@ -344,14 +346,14 @@ void ICON_Pause() { void ICON_Continue() { if (select_print.now == 1) { DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 1, 447, 271 - 243, 479 - 19, 124, 325); else DWIN_Frame_AreaCopy(1, 1, 451, 271 - 239, 479 - 16, 136 - 15, 325); } else { DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 1, 405, 271 - 243, 420, 124, 325); else DWIN_Frame_AreaCopy(1, 1, 424, 271 - 240, 479 - 45, 136 - 15, 325); @@ -361,14 +363,14 @@ void ICON_Continue() { void ICON_Stop() { if (select_print.now == 2) { DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 151, 447, 271 - 93, 479 - 20, 210, 325); else DWIN_Frame_AreaCopy(1, 218, 451, 271 - 22, 479 - 14, 224 - 15, 325); } else { DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252); - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 151, 405, 271 - 93, 420, 210, 325); else DWIN_Frame_AreaCopy(1, 218, 423, 271 - 24, 479 - 43, 224 - 15, 325); @@ -456,7 +458,7 @@ inline void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char // The "Back" label is always on the first line inline void Draw_Back_Label(void) { - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 129, 72, 271 - 115, 479 - 395, LBLX, MBASE(0)); else DWIN_Frame_AreaCopy(1, 226, 179, 271 - 15, 479 - 290, LBLX, MBASE(0)); @@ -478,7 +480,7 @@ inline void draw_move_en(const uint16_t line) { } inline void Prepare_Item_Move(const uint8_t row) { - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 159, 70, 271 - 71, 479 - 395, LBLX, MBASE(row)); else draw_move_en(MBASE(row)); // "Move >" @@ -487,7 +489,7 @@ inline void Prepare_Item_Move(const uint8_t row) { } inline void Prepare_Item_Disable(const uint8_t row) { - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 204, 70, 271 - 12, 479 - 397, LBLX, MBASE(row)); else DWIN_Frame_AreaCopy(1, 103, 59, 271 - 71, 479 - 405, LBLX, MBASE(row)); // "Disable Stepper" @@ -495,7 +497,7 @@ inline void Prepare_Item_Disable(const uint8_t row) { } inline void Prepare_Item_Home(const uint8_t row) { - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 0, 89, 271 - 230, 479 - 378, LBLX, MBASE(row)); else DWIN_Frame_AreaCopy(1, 202, 61, 271 - 0, 479 - 408, LBLX, MBASE(row)); // "Auto Home" @@ -503,7 +505,7 @@ inline void Prepare_Item_Home(const uint8_t row) { } inline void Prepare_Item_Offset(const uint8_t row) { - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { #if HAS_BED_PROBE DWIN_Frame_AreaCopy(1, 174, 164, 271 - 48, 479 - 302, LBLX, MBASE(row)); show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(row), probe.offset.z * 100); @@ -523,7 +525,7 @@ inline void Prepare_Item_Offset(const uint8_t row) { } inline void Prepare_Item_PLA(const uint8_t row) { - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 100, 89, 271 - 93 - 27, 479 - 378, LBLX, MBASE(row)); } else { @@ -534,7 +536,7 @@ inline void Prepare_Item_PLA(const uint8_t row) { } inline void Prepare_Item_ABS(const uint8_t row) { - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 180, 89, 271 - 11 - 27, 479 - 379, LBLX, MBASE(row)); } else { @@ -545,7 +547,7 @@ inline void Prepare_Item_ABS(const uint8_t row) { } inline void Prepare_Item_Cool(const uint8_t row) { - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 1, 104, 271 - 215, 479 - 362, LBLX, MBASE(row)); else DWIN_Frame_AreaCopy(1, 200, 76, 271 - 7, 479 - 393, LBLX, MBASE(row));// "Cooldown" @@ -553,7 +555,7 @@ inline void Prepare_Item_Cool(const uint8_t row) { } inline void Prepare_Item_Lang(const uint8_t row) { - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 239, 134, 271 - 5, 479 - 333, LBLX, MBASE(row)); DWIN_Draw_String(false, false, font8x16, White, Background_black, 226, MBASE(row), (char*)"CN"); } @@ -571,7 +573,7 @@ inline void Draw_Prepare_Menu() { #define PSCROL(L) (scroll + (L)) #define PVISI(L) WITHIN(PSCROL(L), 0, MROWS) - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 133, 1, 271 - 111, 479 - 465 - 1, 14, 8); // "Prepare" } else { @@ -598,7 +600,7 @@ inline void Draw_Prepare_Menu() { inline void Draw_Control_Menu() { Clear_Main_Window(); - const int16_t scroll = TERN(HAS_LEVELING, MROWS - index_control, 0); // Scrolled-up lines + const int16_t scroll = TERN(HAS_ONESTEP_LEVELING, MROWS - index_control, 0); // Scrolled-up lines #define CSCROL(L) (scroll + (L)) #define CLINE(L) MBASE(CSCROL(L)) @@ -606,7 +608,7 @@ inline void Draw_Control_Menu() { if (CVISI(0)) Draw_Back_First(select_control.now == 0); // < Back - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 103, 1, 271 - 141, 479 - 465, 14, 8); DWIN_Frame_AreaCopy(1, 57, 104, 271 - 187, 479 - 363, LBLX, CLINE(1)); // Temperature > DWIN_Frame_AreaCopy(1, 87, 104, 271 - 157, 479 - 363, LBLX, CLINE(2)); // Motion > @@ -620,22 +622,25 @@ inline void Draw_Control_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_CONTROL)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)GET_TEXT_F(MSG_TEMPERATURE)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)GET_TEXT_F(MSG_MOTION)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)GET_TEXT_F(MSG_LOAD_EEPROM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), (char*)GET_TEXT_F(MSG_RESTORE_DEFAULTS)); + if (CVISI(6)) + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 5), (char*)"Info"); #else DWIN_Frame_AreaCopy(1, 128, 2, 271 - 95, 479 - 467, 14, 8); + DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX, CLINE(1));// Temperature > + DWIN_Frame_AreaCopy(1, 84, 89, 271 - 143, 479 - 380, LBLX, CLINE(2));// Motion > + DWIN_Frame_AreaCopy(1, 131 + 17, 89, 271 - 3, 479 - 377 - 1, LBLX, CLINE(3));// "Store Configuration" + DWIN_Frame_AreaCopy(1, 26, 104, 271 - 214, 479 - 365, LBLX, CLINE(4)); // "Read" + DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 31 + 3, CLINE(4)); // "Configuration" + DWIN_Frame_AreaCopy(1, 59, 104, 271 - 178, 479 - 365, LBLX, CLINE(5)); // "Reset" + DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 34 + 3, CLINE(5)); // "Configuration" + if (CVISI(6)) + DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(6)); // Info > #endif - - DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX, CLINE(1));// Temperature > - DWIN_Frame_AreaCopy(1, 84, 89, 271 - 143, 479 - 380, LBLX, CLINE(2));// Motion > - DWIN_Frame_AreaCopy(1, 131 + 17, 89, 271 - 3, 479 - 377 - 1, LBLX, CLINE(3));// "Store Configuration" - - DWIN_Frame_AreaCopy(1, 26, 104, 271 - 214, 479 - 365, LBLX, CLINE(4)); // "Read" - DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 31 + 3, CLINE(4)); // "Configuration" - - DWIN_Frame_AreaCopy(1, 59, 104, 271 - 178, 479 - 365, LBLX, CLINE(5)); // "Reset" - DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 34 + 3, CLINE(5)); // "Configuration" - - if (CVISI(6)) - DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(6)); // Info > } if (select_control.now && CVISI(select_control.now)) @@ -653,9 +658,8 @@ inline void Draw_Control_Menu() { inline void Draw_Tune_Menu() { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 73, 2, 271 - 171, 479 - 466, 14, 9); - DWIN_Frame_AreaCopy(1, 116, 164, 271 - 100, 479 - 303, LBLX, MBASE(1)); DWIN_Frame_AreaCopy(1, 1, 134, 271 - 215, 479 - 333, LBLX, MBASE(2)); DWIN_Frame_AreaCopy(1, 58, 134, 271 - 158, 479 - 333, LBLX, MBASE(3)); @@ -665,16 +669,21 @@ inline void Draw_Tune_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TUNE)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)GET_TEXT_F(MSG_SPEED)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), (char*)GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); #else DWIN_Frame_AreaCopy(1, 94, 2, 271 - 145, 479 - 467, 14, 9); + DWIN_Frame_AreaCopy(1, 1, 179, 271 - 179, 479 - 287 - 2, LBLX, MBASE(1)); // print speed + DWIN_Frame_AreaCopy(1, 197, 104, 271 - 33, 479 - 365, LBLX, MBASE(2)); // Hotend... + DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 41 + 3, MBASE(2)); // ...Temperature + DWIN_Frame_AreaCopy(1, 240, 104, 271 - 7, 479 - 365, LBLX, MBASE(3)); // Bed... + DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 3, MBASE(3)); // ...Temperature + DWIN_Frame_AreaCopy(1, 0, 119, 271 - 207, 479 - 347, LBLX, MBASE(4)); // fan speed + DWIN_Frame_AreaCopy(1, 93, 179, 271 - 130, 479 - 290, LBLX, MBASE(5)); // Z-offset #endif - DWIN_Frame_AreaCopy(1, 1, 179, 271 - 179, 479 - 287 - 2, LBLX, MBASE(1)); // print speed - DWIN_Frame_AreaCopy(1, 197, 104, 271 - 33, 479 - 365, LBLX, MBASE(2)); // Hotend... - DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 41 + 3, MBASE(2)); // ...Temperature - DWIN_Frame_AreaCopy(1, 240, 104, 271 - 7, 479 - 365, LBLX, MBASE(3)); // Bed... - DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 3, MBASE(3)); // ...Temperature - DWIN_Frame_AreaCopy(1, 0, 119, 271 - 207, 479 - 347, LBLX, MBASE(4)); // fan speed - DWIN_Frame_AreaCopy(1, 93, 179, 271 - 130, 479 - 290, LBLX, MBASE(5)); // Z-offset } Draw_Back_First(select_tune.now == 0); @@ -725,7 +734,7 @@ inline void say_e(const uint16_t inset, const uint16_t line) { inline void Draw_Motion_Menu() { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 1, 16, 271 - 243, 479 - 451, 14, 8); DWIN_Frame_AreaCopy(1, 173, 133, 228, 479 - 332, LBLX, MBASE(1)); // max speed @@ -739,13 +748,17 @@ inline void Draw_Motion_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_MOTION)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)"Feedrate"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)GET_TEXT_F(MSG_ACCELERATION)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)GET_TEXT_F(MSG_JERK)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)GET_TEXT_F(MSG_STEPS_PER_MM)); #else DWIN_Frame_AreaCopy(1, 144, 16, 271 - 82, 479 - 453, 14, 8); + draw_max_en(MBASE(1)); draw_speed_en(24 + 3, MBASE(1)); // "Max Speed" + draw_max_accel_en(MBASE(2)); // "Max Acceleration" + draw_max_en(MBASE(3)); draw_corner_en(MBASE(3)); // "Max Corner" + draw_steps_per_mm(MBASE(4)); // "Steps-per-mm" #endif - draw_max_en(MBASE(1)); draw_speed_en(24 + 3, MBASE(1)); // "Max Speed" - draw_max_accel_en(MBASE(2)); // "Max Acceleration" - draw_max_en(MBASE(3)); draw_corner_en(MBASE(3)); // "Max Corner" - draw_steps_per_mm(MBASE(4)); // "Steps-per-mm" } Draw_Back_First(select_motion.now == 0); @@ -768,7 +781,7 @@ void Popup_Window_Temperature(const bool toohigh) { Draw_Popup_Bkgd_105(); if (toohigh) { DWIN_ICON_Show(ICON, ICON_TempTooHigh, 102, 165); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 103, 371, 237, 479 - 93, 52, 285); DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285); DWIN_Frame_AreaCopy(1, 189, 389, 271 - 0, 402, 95, 310); @@ -780,7 +793,7 @@ void Popup_Window_Temperature(const bool toohigh) { } else { DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 165); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 103, 371, 271 - 1, 479 - 93, 52, 285); DWIN_Frame_AreaCopy(1, 189, 389, 271 - 0, 402, 95, 310); } @@ -801,7 +814,7 @@ inline void Draw_Popup_Bkgd_60() { Clear_Main_Window(); Draw_Popup_Bkgd_60(); DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 105); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 103, 371, 136, 479 - 93, 69, 240); DWIN_Frame_AreaCopy(1, 170, 371, 271 - 1, 479 - 93, 69 + 33, 240); DWIN_ICON_Show(ICON, ICON_Confirm_C, 86, 280); @@ -817,7 +830,7 @@ inline void Draw_Popup_Bkgd_60() { void Popup_Window_Resume(void) { Clear_Popup_Area(); Draw_Popup_Bkgd_105(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 160, 338, 271 - 36, 479 - 125, 98, 135); DWIN_Frame_AreaCopy(1, 103, 321, 271 - 0, 479 - 144, 52, 192); DWIN_ICON_Show(ICON, ICON_Continue_C, 26, 307); @@ -836,13 +849,13 @@ void Popup_Window_Home(void) { Clear_Main_Window(); Draw_Popup_Bkgd_60(); DWIN_ICON_Show(ICON, ICON_BLTouch, 101, 105); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 0, 371, 33, 386, 85, 240); DWIN_Frame_AreaCopy(1, 203, 286, 271, 302, 118, 240); DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 80, 230, (char*)"Auto homing..."); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 80, 230, (char*)GET_TEXT_F(MSG_LEVEL_BED_HOMING)); DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 260, (char*)"Please wait until completed"); } } @@ -851,12 +864,12 @@ void Popup_Window_Leveling(void) { Clear_Main_Window(); Draw_Popup_Bkgd_60(); DWIN_ICON_Show(ICON, ICON_AutoLeveling, 101, 105); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 0, 371, 100, 386, 84, 240); DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 76, 230, (char*)"Auto leveling..."); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 76, 230, (char*)GET_TEXT_F(MSG_BED_LEVELING)); DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 260, (char*)"Please wait until completed"); } } @@ -874,7 +887,7 @@ void Draw_Select_Highlight(const bool sel) { void Popup_window_PauseOrStop(void) { Clear_Main_Window(); Draw_Popup_Bkgd_60(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { if (select_print.now == 1) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); else if (select_print.now == 2) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150); DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150); @@ -882,8 +895,8 @@ void Popup_window_PauseOrStop(void) { DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 280); } else { - if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 88, 150, (char*)"Pause print?"); - else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 150, (char*)"Stop print?"); + if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 88, 150, (char*)GET_TEXT_F(MSG_PAUSE_PRINT)); + else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 150, (char*)GET_TEXT_F(MSG_STOP_PRINT)); DWIN_ICON_Show(ICON, ICON_Confirm_E, 26, 280); DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 280); } @@ -891,7 +904,7 @@ void Popup_window_PauseOrStop(void) { } void Draw_Printing_Screen(void) { - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 30, 1, 271 - 200, 479 - 465, 14, 9);// Tune DWIN_Frame_AreaCopy(1, 0, 72, 271 - 208, 479 - 393, 41, 188);// Pause DWIN_Frame_AreaCopy(1, 65, 72, 271 - 143, 479 - 393, 176, 188); // Stop @@ -935,7 +948,8 @@ void Goto_PrintProcess(void) { // Copy into filebuf string before entry char * const name = card.longest_filename(); - DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2, 60, name); + const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2; + DWIN_Draw_String(false, false, font8x16, White, Background_black, npos, 60, name); DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193); DWIN_ICON_Show(ICON, ICON_RemainTime, 150, 191); @@ -950,7 +964,7 @@ void Goto_MainMenu(void) { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 2, 2, 271 - 244, 479 - 465, 14, 9); // "Home" } else { @@ -966,7 +980,7 @@ void Goto_MainMenu(void) { ICON_Print(); ICON_Prepare(); ICON_Control(); - TERN(HAS_LEVELING, ICON_Leveling, ICON_StartInfo)(select_page.now == 3); + TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(select_page.now == 3); } inline ENCODER_DiffState get_encoder_state() { @@ -1064,36 +1078,40 @@ void HMI_Move_Z(void) { } } -void HMI_Move_E(void) { - ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - checkkey = AxisMove; - EncoderRate.encoderRateEnabled = 0; - last_E_scale = HMI_ValueStruct.Move_E_scale; - show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); - if (!planner.is_full()) { - planner.synchronize(); // Wait for planner moves to finish! - planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder); +#if EXTRUDERS + + void HMI_Move_E(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) { + HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue; + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue; + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + checkkey = AxisMove; + EncoderRate.encoderRateEnabled = 0; + last_E_scale = HMI_ValueStruct.Move_E_scale; + show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + if (!planner.is_full()) { + planner.synchronize(); // Wait for planner moves to finish! + planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder); + } + DWIN_UpdateLCD(); + return; } + if ((HMI_ValueStruct.Move_E_scale - last_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) + HMI_ValueStruct.Move_E_scale = last_E_scale + (EXTRUDE_MAXLENGTH) * MINUNITMULT; + else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) + HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT; + current_position.e = HMI_ValueStruct.Move_E_scale / 10; + show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); DWIN_UpdateLCD(); - return; } - if ((HMI_ValueStruct.Move_E_scale - last_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) - HMI_ValueStruct.Move_E_scale = last_E_scale + (EXTRUDE_MAXLENGTH) * MINUNITMULT; - else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) - HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT; - current_position.e = HMI_ValueStruct.Move_E_scale / 10; - show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); - DWIN_UpdateLCD(); } -} + +#endif void HMI_Zoffset(void) { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); @@ -1514,7 +1532,7 @@ void update_variable(void) { #define strcasecmp_P(a, b) strcasecmp((a), (b)) #endif -inline void make_name_without_ext(char *dst, char *src, int maxlen=MENU_CHAR_LIMIT) { +inline void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) { char * const name = card.longest_filename(); size_t pos = strlen(name); // index of ending nul @@ -1523,7 +1541,7 @@ inline void make_name_without_ext(char *dst, char *src, int maxlen=MENU_CHAR_LIM if (!card.flag.filenameIsDir) while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0) - int len = pos; // nul or '.' + size_t len = pos; // nul or '.' if (len > maxlen) { // Keep the name short pos = len = maxlen; // move nul down dst[--pos] = '.'; // insert dots @@ -1712,7 +1730,7 @@ inline void Draw_Info_Menu() { DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(MACHINE_SIZE) * MENU_CHR_W) / 2, 122, (char*)MACHINE_SIZE); DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(SHORT_BUILD_VERSION) * MENU_CHR_W) / 2, 195, (char*)SHORT_BUILD_VERSION); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 30, 17, 271 - 214, 479 - 450, 14, 8); DWIN_Frame_AreaCopy(1, 197, 149, 271 - 19, 479 - 318, 108, 102); @@ -1743,7 +1761,7 @@ inline void Draw_Info_Menu() { inline void Draw_Print_File_Menu() { Clear_Title_Bar(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 0, 31, 271 - 216, 479 - 435, 14, 8); } else { @@ -1768,7 +1786,7 @@ void HMI_MainMenu(void) { case 0: ICON_Print(); break; case 1: ICON_Print(); ICON_Prepare(); break; case 2: ICON_Prepare(); ICON_Control(); break; - case 3: ICON_Control(); TERN(HAS_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break; + case 3: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break; } } } @@ -1777,8 +1795,8 @@ void HMI_MainMenu(void) { switch (select_page.now) { case 0: ICON_Print(); ICON_Prepare(); break; case 1: ICON_Prepare(); ICON_Control(); break; - case 2: ICON_Control(); TERN(HAS_LEVELING, ICON_Leveling, ICON_StartInfo)(0); break; - case 3: TERN(HAS_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break; + case 2: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(0); break; + case 3: TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break; } } } @@ -1808,7 +1826,7 @@ void HMI_MainMenu(void) { /* Leveling */ case 3: - #if HAS_LEVELING + #if HAS_ONESTEP_LEVELING checkkey = Leveling; HMI_Leveling(); #else @@ -2090,12 +2108,14 @@ void HMI_PauseOrStop(void) { inline void Draw_Move_Menu() { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 192, 1, 271 - 38, 479 - 465, 14, 8); DWIN_Frame_AreaCopy(1, 58, 118, 271 - 165, 479 - 347, LBLX, MBASE(1)); DWIN_Frame_AreaCopy(1, 109, 118, 271 - 114, 479 - 347, LBLX, MBASE(2)); DWIN_Frame_AreaCopy(1, 160, 118, 271 - 62, 479 - 347, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 212, 118, 271 - 18, 479 - 348, LBLX, MBASE(4)); + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 212, 118, 271 - 18, 479 - 348, LBLX, MBASE(4)); + #endif } else { #ifdef USE_STRING_HEADINGS @@ -2106,7 +2126,9 @@ inline void Draw_Move_Menu() { draw_move_en(MBASE(1)); say_x(33 + 3, MBASE(1)); // "Move X" draw_move_en(MBASE(2)); say_y(33 + 3, MBASE(2)); // "Move Y" draw_move_en(MBASE(3)); say_z(33 + 3, MBASE(3)); // "Move Z" - DWIN_Frame_AreaCopy(1, 123, 192, 271 - 95, 479 - 277, LBLX, MBASE(4)); // "Extruder" + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 123, 192, 271 - 95, 479 - 277, LBLX, MBASE(4)); // "Extruder" + #endif } Draw_Back_First(select_axis.now == 0); @@ -2115,6 +2137,18 @@ inline void Draw_Move_Menu() { LOOP_L_N(i, MROWS) Draw_Menu_Line(i + 1, ICON_MoveX + i); } +#include "../../../libs/buzzer.h" + +void HMI_AudioFeedback(const bool success=true) { + if (success) { + buzzer.tone(100, 659); + buzzer.tone(10, 0); + buzzer.tone(100, 698); + } + else + buzzer.tone(40, 440); +} + /* Prepare */ void HMI_Prepare(void) { ENCODER_DiffState encoder_diffState = get_encoder_state(); @@ -2201,8 +2235,7 @@ void HMI_Prepare(void) { #else // Apply workspace offset, making the current position 0,0,0 queue.inject_P(PSTR("G92 X0 Y0 Z0")); - buzzer.tone(100, 659); - buzzer.tone(100, 698); + HMI_AudioFeedback(); #endif break; case 5: // PLA preheat @@ -2221,13 +2254,13 @@ void HMI_Prepare(void) { break; case 8: // language /* select language */ - HMI_flag.language_flag = !HMI_flag.language_flag; - if (HMI_flag.language_flag) { - set_chinese_to_eeprom(); + HMI_flag.language_chinese ^= true; + if (HMI_flag.language_chinese) { + HMI_SetAndSaveLanguageChinese(); DWIN_JPG_CacheTo1(Language_Chinese); } else { - set_english_to_eeprom(); + HMI_SetAndSaveLanguageWestern(); DWIN_JPG_CacheTo1(Language_English); } Draw_Prepare_Menu(); @@ -2242,7 +2275,7 @@ void HMI_Prepare(void) { void Draw_Temperature_Menu() { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 236, 2, 271 - 8, 479 - 466, 14, 8); DWIN_Frame_AreaCopy(1, 1, 134, 271 - 215, 479 - 333, LBLX, MBASE(1)); @@ -2254,21 +2287,25 @@ void Draw_Temperature_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TEMPERATURE)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)"PLA Preheat Settings"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), (char*)"ABS Preheat Settings"); #else DWIN_Frame_AreaCopy(1, 56, 16, 271 - 130, 479 - 450 - 1, 14, 8); + DWIN_Frame_AreaCopy(1, 197, 104, 271 - 33, 479 - 365, LBLX, MBASE(1)); // Nozzle... + DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 41 + 3, MBASE(1)); // ...Temperature + DWIN_Frame_AreaCopy(1, 240, 104, 271 - 7, 479 - 365, LBLX, MBASE(2)); // Bed... + DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 3, MBASE(2)); // ...Temperature + DWIN_Frame_AreaCopy(1, 0, 119, 271 - 207, 479 - 347, LBLX, MBASE(3)); // Fan speed + DWIN_Frame_AreaCopy(1, 107, 76, 271 - 115, 479 - 393, LBLX, MBASE(4)); // Preheat... + DWIN_Frame_AreaCopy(1, 157, 76, 181, 479 - 393, LBLX + 49 + 3, MBASE(4)); // ...PLA + DWIN_Frame_AreaCopy(1, 131, 119, 271 - 89, 479 - 347, LBLX + 49 + 24 + 6, MBASE(4)); // PLA setting + DWIN_Frame_AreaCopy(1, 107, 76, 271 - 115, 479 - 393, LBLX, MBASE(5)); // Preheat... + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX + 49 + 3, MBASE(5)); // ...ABS + DWIN_Frame_AreaCopy(1, 131, 119, 271 - 89, 479 - 347, LBLX + 49 + 3 + 26 + 3, MBASE(5)); // ABS setting #endif - - DWIN_Frame_AreaCopy(1, 197, 104, 271 - 33, 479 - 365, LBLX, MBASE(1)); // Nozzle... - DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 41 + 3, MBASE(1)); // ...Temperature - DWIN_Frame_AreaCopy(1, 240, 104, 271 - 7, 479 - 365, LBLX, MBASE(2)); // Bed... - DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 3, MBASE(2)); // ...Temperature - DWIN_Frame_AreaCopy(1, 0, 119, 271 - 207, 479 - 347, LBLX, MBASE(3)); // Fan speed - DWIN_Frame_AreaCopy(1, 107, 76, 271 - 115, 479 - 393, LBLX, MBASE(4)); // Preheat... - DWIN_Frame_AreaCopy(1, 157, 76, 181, 479 - 393, LBLX + 49 + 3, MBASE(4)); // ...PLA - DWIN_Frame_AreaCopy(1, 131, 119, 271 - 89, 479 - 347, LBLX + 49 + 24 + 6, MBASE(4)); // PLA setting - DWIN_Frame_AreaCopy(1, 107, 76, 271 - 115, 479 - 393, LBLX, MBASE(5)); // Preheat... - DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX + 49 + 3, MBASE(5)); // ...ABS - DWIN_Frame_AreaCopy(1, 131, 119, 271 - 89, 479 - 347, LBLX + 49 + 3 + 26 + 3, MBASE(5)); // ABS setting } Draw_Back_First(select_temp.now == 0); @@ -2291,7 +2328,7 @@ void HMI_Control(void) { // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - #define CONTROL_ITEMS (5 + ENABLED(HAS_LEVELING)) + #define CONTROL_ITEMS (5 + ENABLED(HAS_ONESTEP_LEVELING)) if (select_control.inc(CONTROL_ITEMS)) { if (select_control.now > MROWS && select_control.now > index_control) { index_control = select_control.now; @@ -2301,7 +2338,7 @@ void HMI_Control(void) { Draw_More_Icon(2 + MROWS - index_control); // Motion > if (index_control > MROWS) { Draw_More_Icon(6 + MROWS - index_control); // Info > - if (HMI_flag.language_flag) + if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 231, 104, 271 - 13, 479 - 363, LBLX, MBASE(5)); else DWIN_Frame_AreaCopy(1, 0, 104, 271 - 247, 479 - 365, LBLX, MBASE(5)); @@ -2346,27 +2383,17 @@ void HMI_Control(void) { select_motion.reset(); Draw_Motion_Menu(); break; - case 3: // write EEPROM - if (settings.save()) { - buzzer.tone(100, 659); - buzzer.tone(100, 698); - } - else - buzzer.tone(20, 440); - break; - case 4: // read EEPROM - if (settings.load()) { - buzzer.tone(100, 659); - buzzer.tone(100, 698); - } - else {buzzer.tone(20, 440);} - break; + case 3: { // write EEPROM + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; + case 4: { // read EEPROM + const bool success = settings.load(); + HMI_AudioFeedback(success); + } break; case 5: // resume EEPROM settings.reset(); - #if HAS_BUZZER - buzzer.tone(100, 659); - buzzer.tone(100, 698); - #endif + HMI_AudioFeedback(); break; case 6: // info checkkey = Info; @@ -2379,12 +2406,17 @@ void HMI_Control(void) { DWIN_UpdateLCD(); } -/* Leveling */ -void HMI_Leveling(void) { - Popup_Window_Leveling(); - DWIN_UpdateLCD(); - queue.inject_P(PSTR("G28O\nG29")); -} + +#if HAS_ONESTEP_LEVELING + + /* Leveling */ + void HMI_Leveling(void) { + Popup_Window_Leveling(); + DWIN_UpdateLCD(); + queue.inject_P(PSTR("G28O\nG29")); + } + +#endif /* Axis Move */ void HMI_AxisMove(void) { @@ -2515,7 +2547,7 @@ void HMI_Temperature(void) { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 59, 16, 271 - 132, 479 - 450, 14, 8); DWIN_Frame_AreaCopy(1, 100, 89, 124, 479 - 378, LBLX, MBASE(1)); @@ -2529,19 +2561,22 @@ void HMI_Temperature(void) { else { #ifdef USE_STRING_HEADINGS Draw_Title("PLA Settings"); // TODO: GET_TEXT_F + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)"Nozzle Temp"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)"Bed Temp"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)GET_TEXT_F(MSG_STORE_EEPROM)); #else DWIN_Frame_AreaCopy(1, 56, 16, 271 - 130, 479 - 450 - 1, 14, 8); + DWIN_Frame_AreaCopy(1, 157, 76, 181, 479 - 393, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 197, 104, 271 - 33, 479 - 365, LBLX + 24 + 3, MBASE(1)); + DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 41 + 6, MBASE(1)); // PLA nozzle temp + DWIN_Frame_AreaCopy(1, 157, 76, 181, 479 - 393, LBLX, MBASE(2) + 3); + DWIN_Frame_AreaCopy(1, 240, 104, 271 - 7, 479 - 365, LBLX + 24 + 3, MBASE(2) + 3); + DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 24 + 6, MBASE(2) + 3); // PLA bed temp + DWIN_Frame_AreaCopy(1, 157, 76, 181, 479 - 393, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 0, 119, 271 - 207, 479 - 347, LBLX + 24 + 3, MBASE(3)); // PLA fan speed + DWIN_Frame_AreaCopy(1, 97, 165, 271 - 42, 479 - 301 - 1, LBLX, MBASE(4)); // save PLA configuration #endif - - DWIN_Frame_AreaCopy(1, 157, 76, 181, 479 - 393, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 197, 104, 271 - 33, 479 - 365, LBLX + 24 + 3, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 41 + 6, MBASE(1)); // PLA nozzle temp - DWIN_Frame_AreaCopy(1, 157, 76, 181, 479 - 393, LBLX, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 240, 104, 271 - 7, 479 - 365, LBLX + 24 + 3, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 24 + 6, MBASE(2) + 3); // PLA bed temp - DWIN_Frame_AreaCopy(1, 157, 76, 181, 479 - 393, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 0, 119, 271 - 207, 479 - 347, LBLX + 24 + 3, MBASE(3)); // PLA fan speed - DWIN_Frame_AreaCopy(1, 97, 165, 271 - 42, 479 - 301 - 1, LBLX, MBASE(4)); // save PLA configuration } Draw_Back_First(); @@ -2564,7 +2599,7 @@ void HMI_Temperature(void) { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 142, 16, 271 - 48, 479 - 450, 14, 8); DWIN_Frame_AreaCopy(1, 180, 89, 204, 479 - 379, LBLX, MBASE(1)); @@ -2579,20 +2614,23 @@ void HMI_Temperature(void) { else { #ifdef USE_STRING_HEADINGS Draw_Title("ABS Settings"); // TODO: GET_TEXT_F + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)"Nozzle Temp"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)"Bed Temp"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)GET_TEXT_F(MSG_STORE_EEPROM)); #else DWIN_Frame_AreaCopy(1, 56, 16, 271 - 130, 479 - 450 - 1, 14, 8); + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 197, 104, 271 - 33, 479 - 365, LBLX + 24 + 3, MBASE(1)); + DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 41 + 6, MBASE(1)); // ABS nozzle temp + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX, MBASE(2) + 3); + DWIN_Frame_AreaCopy(1, 240, 104, 271 - 7, 479 - 365, LBLX + 24 + 3, MBASE(2) + 3); + DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 24 + 6, MBASE(2) + 3); // ABS bed temp + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 0, 119, 271 - 207, 479 - 347, LBLX + 24 + 3, MBASE(3)); // ABS fan speed + DWIN_Frame_AreaCopy(1, 97, 165, 271 - 42, 479 - 301 - 1, LBLX, MBASE(4)); + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX + 33, MBASE(4)); // save ABS configuration #endif - - DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 197, 104, 271 - 33, 479 - 365, LBLX + 24 + 3, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 41 + 6, MBASE(1)); // ABS nozzle temp - DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 240, 104, 271 - 7, 479 - 365, LBLX + 24 + 3, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX + 24 + 24 + 6, MBASE(2) + 3); // ABS bed temp - DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 0, 119, 271 - 207, 479 - 347, LBLX + 24 + 3, MBASE(3)); // ABS fan speed - DWIN_Frame_AreaCopy(1, 97, 165, 271 - 42, 479 - 301 - 1, LBLX, MBASE(4)); - DWIN_Frame_AreaCopy(1, 172, 76, 198, 479 - 393, LBLX + 33, MBASE(4)); // save ABS configuration } Draw_Back_First(); @@ -2616,7 +2654,7 @@ void HMI_Temperature(void) { inline void Draw_Max_Speed_Menu() { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 1, 16, 271 - 243, 479 - 451, 14, 8); auto say_max_speed = [](const uint16_t row) { @@ -2635,24 +2673,28 @@ inline void Draw_Max_Speed_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title("Max Speed (mm/s)"); // TODO: GET_TEXT_F + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)"Max Feedrate X"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)"Max Feedrate Y"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)"Max Feedrate Z"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)"Max Feedrate E"); #else DWIN_Frame_AreaCopy(1, 144, 16, 271 - 82, 479 - 453, 14, 8); - #endif - draw_max_en(MBASE(1)); // "Max" - DWIN_Frame_AreaCopy(1, 184, 119, 271 - 37, 479 - 347, LBLX + 24 + 3, MBASE(1)); // "Speed X" + draw_max_en(MBASE(1)); // "Max" + DWIN_Frame_AreaCopy(1, 184, 119, 271 - 37, 479 - 347, LBLX + 24 + 3, MBASE(1)); // "Speed X" - draw_max_en(MBASE(2)); // "Max" - draw_speed_en(24 + 3, MBASE(2)); // "Speed" - say_y(24 + 40 + 6, MBASE(2)); // "Y" + draw_max_en(MBASE(2)); // "Max" + draw_speed_en(24 + 3, MBASE(2)); // "Speed" + say_y(24 + 40 + 6, MBASE(2)); // "Y" - draw_max_en(MBASE(3)); // "Max" - draw_speed_en(24 + 3, MBASE(3)); // "Speed" - say_z(24 + 40 + 6, MBASE(3)); // "Z" + draw_max_en(MBASE(3)); // "Max" + draw_speed_en(24 + 3, MBASE(3)); // "Speed" + say_z(24 + 40 + 6, MBASE(3)); // "Z" - draw_max_en(MBASE(4)); // "Max" - draw_speed_en(24 + 3, MBASE(4)); // "Speed" - say_e(24 + 40 + 6, MBASE(4)); // "E" + draw_max_en(MBASE(4)); // "Max" + draw_speed_en(24 + 3, MBASE(4)); // "Speed" + say_e(24 + 40 + 6, MBASE(4)); // "E" + #endif } Draw_Back_First(); @@ -2667,7 +2709,7 @@ inline void Draw_Max_Speed_Menu() { inline void Draw_Max_Accel_Menu() { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 1, 16, 271 - 243, 479 - 451, 14, 8); DWIN_Frame_AreaCopy(1, 173, 133, 200, 479 - 332, LBLX, MBASE(1)); @@ -2685,14 +2727,18 @@ inline void Draw_Max_Accel_Menu() { } else { #ifdef USE_STRING_HEADINGS - Draw_Title("Max Accel (mm/s/s)"); // TODO: GET_TEXT_F + Draw_Title(GET_TEXT_F(MSG_ACCELERATION)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)"Max Accel X"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)"Max Accel Y"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)"Max Accel Z"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)"Max Accel E"); #else DWIN_Frame_AreaCopy(1, 144, 16, 271 - 82, 479 - 453, 14, 8); + draw_max_accel_en(MBASE(1)); say_x(24 + 78 + 6, MBASE(1)); // "Max Acceleration X" + draw_max_accel_en(MBASE(2)); say_y(24 + 78 + 6, MBASE(2)); // "Max Acceleration Y" + draw_max_accel_en(MBASE(3)); say_z(24 + 78 + 6, MBASE(3)); // "Max Acceleration Z" + draw_max_accel_en(MBASE(4)); say_e(24 + 78 + 6, MBASE(4)); // "Max Acceleration E" #endif - draw_max_accel_en(MBASE(1)); say_x(24 + 78 + 6, MBASE(1)); // "Max Acceleration X" - draw_max_accel_en(MBASE(2)); say_y(24 + 78 + 6, MBASE(2)); // "Max Acceleration Y" - draw_max_accel_en(MBASE(3)); say_z(24 + 78 + 6, MBASE(3)); // "Max Acceleration Z" - draw_max_accel_en(MBASE(4)); say_e(24 + 78 + 6, MBASE(4)); // "Max Acceleration E" } Draw_Back_First(); @@ -2707,7 +2753,7 @@ inline void Draw_Max_Accel_Menu() { inline void Draw_Max_Jerk_Menu() { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 1, 16, 271 - 243, 479 - 451, 14, 8); DWIN_Frame_AreaCopy(1, 173, 133, 200, 479 - 332, LBLX, MBASE(1)); @@ -2729,30 +2775,33 @@ inline void Draw_Max_Jerk_Menu() { } else { #ifdef USE_STRING_HEADINGS - Draw_Title("Max Corner"); // TODO: GET_TEXT_F + Draw_Title(GET_TEXT_F(MSG_JERK)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)"Max Jerk X"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)"Max Jerk Y"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)"Max Jerk Z"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)"Max Jerk E"); #else DWIN_Frame_AreaCopy(1, 144, 16, 271 - 82, 479 - 453, 14, 8); + draw_max_en(MBASE(1)); // "Max" + draw_corner_en(MBASE(1)); // "Corner" + draw_speed_en(66 + 6, MBASE(1)); // "Speed" + say_x(106 + 9, MBASE(1)); // "X" + + draw_max_en(MBASE(2)); // "Max" + draw_corner_en(MBASE(2)); // "Corner" + draw_speed_en(66 + 6, MBASE(2)); // "Speed" + say_y(106 + 9, MBASE(2)); // "Y" + + draw_max_en(MBASE(3)); // "Max" + draw_corner_en(MBASE(3)); // "Corner" + draw_speed_en(66 + 6, MBASE(3)); // "Speed" + say_z(106 + 9, MBASE(3)); // "Z" + + draw_max_en(MBASE(4)); // "Max" + draw_corner_en(MBASE(4)); // "Corner" + draw_speed_en(66 + 6, MBASE(4)); // "Speed" + say_e(106 + 9, MBASE(4)); // "E" #endif - - draw_max_en(MBASE(1)); // "Max" - draw_corner_en(MBASE(1)); // "Corner" - draw_speed_en(66 + 6, MBASE(1)); // "Speed" - say_x(106 + 9, MBASE(1)); // "X" - - draw_max_en(MBASE(2)); // "Max" - draw_corner_en(MBASE(2)); // "Corner" - draw_speed_en(66 + 6, MBASE(2)); // "Speed" - say_y(106 + 9, MBASE(2)); // "Y" - - draw_max_en(MBASE(3)); // "Max" - draw_corner_en(MBASE(3)); // "Corner" - draw_speed_en(66 + 6, MBASE(3)); // "Speed" - say_z(106 + 9, MBASE(3)); // "Z" - - draw_max_en(MBASE(4)); // "Max" - draw_corner_en(MBASE(4)); // "Corner" - draw_speed_en(66 + 6, MBASE(4)); // "Speed" - say_e(106 + 9, MBASE(4)); // "E" } Draw_Back_First(); @@ -2767,7 +2816,7 @@ inline void Draw_Max_Jerk_Menu() { inline void Draw_Steps_Menu() { Clear_Main_Window(); - if (HMI_flag.language_flag) { + if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 1, 16, 271 - 243, 479 - 451, 14, 8); DWIN_Frame_AreaCopy(1, 153, 148, 271 - 77, 479 - 318, LBLX, MBASE(1)); @@ -2781,14 +2830,18 @@ inline void Draw_Steps_Menu() { } else { #ifdef USE_STRING_HEADINGS - Draw_Title("Steps-per-mm"); // TODO: GET_TEXT_F + Draw_Title(GET_TEXT_F(MSG_STEPS_PER_MM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), (char*)"Steps/mm X"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), (char*)"Steps/mm Y"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), (char*)"Steps/mm Z"); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), (char*)"Steps/mm E"); #else DWIN_Frame_AreaCopy(1, 144, 16, 271 - 82, 479 - 453, 14, 8); + draw_steps_per_mm(MBASE(1)); say_x(100 + 3, MBASE(1)); // "Steps-per-mm X" + draw_steps_per_mm(MBASE(2)); say_y(100 + 3, MBASE(2)); // "Y" + draw_steps_per_mm(MBASE(3)); say_z(100 + 3, MBASE(3)); // "Z" + draw_steps_per_mm(MBASE(4)); say_e(100 + 3, MBASE(4)); // "E" #endif - draw_steps_per_mm(MBASE(1)); say_x(100 + 3, MBASE(1)); // "Steps-per-mm X" - draw_steps_per_mm(MBASE(2)); say_y(100 + 3, MBASE(2)); // "Y" - draw_steps_per_mm(MBASE(3)); say_z(100 + 3, MBASE(3)); // "Z" - draw_steps_per_mm(MBASE(4)); say_e(100 + 3, MBASE(4)); // "E" } Draw_Back_First(); @@ -2852,7 +2905,7 @@ void HMI_Info(void) { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_ENTER) { - #if HAS_LEVELING + #if HAS_ONESTEP_LEVELING checkkey = Control; select_control.set(CONTROL_ITEMS); Draw_Control_Menu(); @@ -2939,16 +2992,16 @@ void HMI_Tune(void) { break; case 6: // Language // Select language - HMI_flag.language_flag = !HMI_flag.language_flag; + HMI_flag.language_chinese ^= true; Clear_Main_Window(); - if (HMI_flag.language_flag) { - set_chinese_to_eeprom(); + if (HMI_flag.language_chinese) { + HMI_SetAndSaveLanguageChinese(); DWIN_JPG_CacheTo1(Language_Chinese); } else { - set_english_to_eeprom(); + HMI_SetAndSaveLanguageWestern(); DWIN_JPG_CacheTo1(Language_English); } @@ -3005,14 +3058,10 @@ void HMI_PLAPreheatSetting(void) { EncoderRate.encoderRateEnabled = 1; break; #endif - case 4: // save PLA configuration - if (settings.save()) { - buzzer.tone(100, 659); - buzzer.tone(100, 698); - } - else - buzzer.tone(20, 440); - break; + case 4: { // save PLA configuration + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; default: break; } } @@ -3063,14 +3112,10 @@ void HMI_ABSPreheatSetting(void) { EncoderRate.encoderRateEnabled = 1; break; #endif - case 4: // save PLA configuration - if (settings.save()) { - buzzer.tone(100, 659); - buzzer.tone(100, 698); - } - else - buzzer.tone(20, 440); - break; + case 4: { // save ABS configuration + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; default: break; } @@ -3304,14 +3349,7 @@ void HMI_Init(void) { delay(20); } - lcd_select_language(); - - #if ENABLED(FIX_MOUNTED_PROBE) // For "CREALITY_TOUCH" probe too? - SET_OUTPUT(COM_PIN); - WRITE(COM_PIN, 1); - #endif - - delay(200); + HMI_SetLanguage(); } void DWIN_Update(void) { @@ -3345,7 +3383,7 @@ void EachMomentUpdate(void) { // show print done confirm DWIN_Draw_Rectangle(1, Background_black, 0, 250, 271, 360); - DWIN_ICON_Show(ICON, HMI_flag.language_flag ? ICON_Confirm_C : ICON_Confirm_E, 86, 302 - 19); + DWIN_ICON_Show(ICON, HMI_flag.language_chinese ? ICON_Confirm_C : ICON_Confirm_E, 86, 302 - 19); } else if (HMI_flag.pause_flag != printingIsPaused()) { // print status update @@ -3436,7 +3474,8 @@ void EachMomentUpdate(void) { Popup_Window_Resume(); draw_first_option(false); char * const name = card.longest_filename(); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2, 252, name); + const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2; + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, npos, 252, name); DWIN_UpdateLCD(); break; } @@ -3494,11 +3533,11 @@ void DWIN_HandleScreen(void) { case Move_X: HMI_Move_X(); break; case Move_Y: HMI_Move_Y(); break; case Move_Z: HMI_Move_Z(); break; - case Extruder: HMI_Move_E(); break; - case Homeoffset: HMI_Zoffset(); break; #if HAS_HOTEND + case Extruder: HMI_Move_E(); break; case ETemp: HMI_ETemp(); break; #endif + case Homeoffset: HMI_Zoffset(); break; #if HAS_HEATED_BED case BedTemp: HMI_BedTemp(); break; #endif diff --git a/Marlin/src/lcd/dwin/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h similarity index 97% rename from Marlin/src/lcd/dwin/dwin.h rename to Marlin/src/lcd/dwin/e3v2/dwin.h index 2d24d2504e7e..dffd40bd03fb 100644 --- a/Marlin/src/lcd/dwin/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -25,9 +25,9 @@ * DWIN by Creality3D */ -#include "dwin_lcd.h" +#include "../dwin_lcd.h" #include "rotary_encoder.h" -#include "../../libs/BL24CXX.h" +#include "../../../libs/BL24CXX.h" #include @@ -68,11 +68,11 @@ enum processID { Move_X, Move_Y, Move_Z, - Extruder, - Homeoffset, #if HAS_HOTEND + Extruder, ETemp, #endif + Homeoffset, #if HAS_HEATED_BED BedTemp, #endif @@ -244,7 +244,7 @@ typedef struct { } HMI_value_t; typedef struct { - bool language_flag; // 0: EN, 1: CN + bool language_chinese; // 0: EN, 1: CN bool pause_flag:1; bool print_finish:1; bool confirm_flag:1; @@ -269,9 +269,9 @@ extern HMI_value_t HMI_ValueStruct; extern HMI_Flag HMI_flag; // Language -void lcd_select_language(void); -void set_english_to_eeprom(void); -void set_chinese_to_eeprom(void); +void HMI_SetLanguage(void); +void HMI_SetAndSaveLanguageWestern(void); +void HMI_SetAndSaveLanguageChinese(void); // Show ICO void ICON_Print(bool show); diff --git a/Marlin/src/lcd/dwin/rotary_encoder.cpp b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp similarity index 98% rename from Marlin/src/lcd/dwin/rotary_encoder.cpp rename to Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp index 62e2cda35126..e4c563cf6b98 100644 --- a/Marlin/src/lcd/dwin/rotary_encoder.cpp +++ b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp @@ -30,17 +30,17 @@ ****************************************************************************** **/ -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if ENABLED(DWIN_CREALITY_LCD) #include "rotary_encoder.h" -#include "../../MarlinCore.h" -#include "../../HAL/shared/Delay.h" +#include "../../../MarlinCore.h" +#include "../../../HAL/shared/Delay.h" #if HAS_BUZZER - #include "../../libs/buzzer.h" + #include "../../../libs/buzzer.h" #endif #include diff --git a/Marlin/src/lcd/dwin/rotary_encoder.h b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h similarity index 97% rename from Marlin/src/lcd/dwin/rotary_encoder.h rename to Marlin/src/lcd/dwin/e3v2/rotary_encoder.h index 5c5a8f86a29b..db074098ebf1 100644 --- a/Marlin/src/lcd/dwin/rotary_encoder.h +++ b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h @@ -31,8 +31,8 @@ ****************************************************************************** **/ -#include "../../inc/MarlinConfig.h" -#include "../../MarlinCore.h" +#include "../../../inc/MarlinConfig.h" +#include "../../../MarlinCore.h" /*********************** Encoder Set ***********************/ diff --git a/Marlin/src/lcd/extui_anycubic_chiron_lcd.cpp b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp similarity index 99% rename from Marlin/src/lcd/extui_anycubic_chiron_lcd.cpp rename to Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp index 15cc96711c73..889a25b85950 100644 --- a/Marlin/src/lcd/extui_anycubic_chiron_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp @@ -21,16 +21,16 @@ */ /** - * extui_anycubic_chiron_lcd.cpp + * anycubic_chiron_lcd.cpp * * Anycubic Chiron TFT support for Marlin */ -#include "../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfigPre.h" #if ENABLED(ANYCUBIC_LCD_CHIRON) -#include "extui/ui_api.h" +#include "ui_api.h" #if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if GRID_MAX_POINTS_X != 5 || GRID_MAX_POINTS_Y != 5 diff --git a/Marlin/src/lcd/extui_anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp similarity index 95% rename from Marlin/src/lcd/extui_anycubic_i3mega_lcd.cpp rename to Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp index 360ea75de8ea..15526d16fc21 100644 --- a/Marlin/src/lcd/extui_anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp @@ -21,15 +21,15 @@ */ /** - * extui_anycubic_i3mega_lcd.cpp + * anycubic_i3mega_lcd.cpp */ -#include "../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfigPre.h" #if ENABLED(ANYCUBIC_LCD_I3MEGA) -#include "extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.h" -#include "extui/ui_api.h" +#include "lib/anycubic_i3mega/anycubic_i3mega_lcd.h" +#include "ui_api.h" #include // for the ::tone() call diff --git a/Marlin/src/lcd/extui_dgus_lcd.cpp b/Marlin/src/lcd/extui/dgus_lcd.cpp similarity index 95% rename from Marlin/src/lcd/extui_dgus_lcd.cpp rename to Marlin/src/lcd/extui/dgus_lcd.cpp index c3978eb7e187..d175b5acac9a 100644 --- a/Marlin/src/lcd/extui_dgus_lcd.cpp +++ b/Marlin/src/lcd/extui/dgus_lcd.cpp @@ -21,19 +21,19 @@ */ /** - * extui_dgus_lcd.cpp + * dgus_lcd.cpp * * DGUS implementation for Marlin by coldtobi, Feb-May 2019 */ -#include "../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfigPre.h" #if HAS_DGUS_LCD -#include "extui/ui_api.h" -#include "extui/lib/dgus/DGUSDisplay.h" -#include "extui/lib/dgus/DGUSDisplayDef.h" -#include "extui/lib/dgus/DGUSScreenHandler.h" +#include "ui_api.h" +#include "lib/dgus/DGUSDisplay.h" +#include "lib/dgus/DGUSDisplayDef.h" +#include "lib/dgus/DGUSScreenHandler.h" extern const char NUL_STR[]; diff --git a/Marlin/src/lcd/extui_example.cpp b/Marlin/src/lcd/extui/example.cpp similarity index 97% rename from Marlin/src/lcd/extui_example.cpp rename to Marlin/src/lcd/extui/example.cpp index 5258a5b6a27d..a5ef5652bc0f 100644 --- a/Marlin/src/lcd/extui_example.cpp +++ b/Marlin/src/lcd/extui/example.cpp @@ -1,5 +1,5 @@ /********************* - * extui_example.cpp * + * example.cpp * *********************/ /**************************************************************************** @@ -19,11 +19,11 @@ * location: . * ****************************************************************************/ -#include "../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfigPre.h" #if BOTH(EXTUI_EXAMPLE, EXTENSIBLE_UI) -#include "extui/ui_api.h" +#include "ui_api.h" // To implement a new UI, complete the functions below and // read or update Marlin's state using the methods in the diff --git a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp index 1c9b9299fc43..9b54dbdd2ba2 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -28,6 +28,7 @@ #include "../../../../inc/MarlinConfig.h" #include "../../ui_api.h" #include "../../../../MarlinCore.h" // for quickstop_stepper and disable_steppers +#include "../../../../module/motion.h" // for A20 read printing speed feedrate_percentage // command sending macro's with debugging capability #define SEND_PGM(x) send_P(PSTR(x)) @@ -412,6 +413,7 @@ void AnycubicTFTClass::RenderCurrentFileList() { uint16_t selectedNumber = 0; SelectedDirectory[0] = 0; SelectedFile[0] = 0; + ExtUI::FileList currentFileList; SENDLINE_PGM("FN "); // Filelist start @@ -427,7 +429,7 @@ void AnycubicTFTClass::RenderCurrentFileList() { if (SpecialMenu) RenderSpecialMenu(selectedNumber); - else + else if (selectedNumber <= currentFileList.count()) RenderCurrentFolder(selectedNumber); } SENDLINE_PGM("END"); // Filelist stop @@ -804,7 +806,6 @@ void AnycubicTFTClass::GetCommandFromTFT() { break; case 20: { // A20 read printing speed - int16_t feedrate_percentage = 100; if (CodeSeen('S')) feedrate_percentage = constrain(CodeValue(), 40, 999); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h index 1bb35a599577..a9fdb5c5c73c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h @@ -133,6 +133,7 @@ class CLCD { static void set_brightness (uint8_t brightness); static uint8_t get_brightness(); static void host_cmd (unsigned char host_command, unsigned char byte2); + static uint32_t dl_size() {return CLCD::mem_read_32(REG::CMD_DL) & 0x1FFF;} static void get_font_metrics (uint8_t font, struct FontMetrics &fm); static uint16_t get_text_width(const uint8_t font, const char *str); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp index 728e433154ae..f736916a3be4 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp @@ -32,7 +32,8 @@ * * The cache memory begins with a table at * DL_CACHE_START: each table entry contains - * an address and size for a cached DL slot. + * an address, size and used bytes for a cached + * DL slot. * * Immediately following the table is the * DL_FREE_ADDR, which points to free cache @@ -44,11 +45,14 @@ * * DL_CACHE_START slot0_addr 4 * slot0_size 4 + * slot0_used 4 * slot1_addr 4 * slot1_size 4 + * slot1_used 4 * ... * slotN_addr 4 * slotN_size 4 + * slotN_used 4 * DL_FREE_ADDR dl_free_ptr 4 * cached data * ... @@ -57,7 +61,7 @@ */ #define DL_CACHE_START MAP::RAM_G_SIZE - 0xFFFF -#define DL_FREE_ADDR DL_CACHE_START + DL_CACHE_SLOTS * 8 +#define DL_FREE_ADDR DL_CACHE_START + DL_CACHE_SLOTS * 12 using namespace FTDI; @@ -66,12 +70,12 @@ using namespace FTDI; void DLCache::init() { CLCD::mem_write_32(DL_FREE_ADDR, DL_FREE_ADDR + 4); for(uint8_t slot = 0; slot < DL_CACHE_SLOTS; slot++) { - save_slot(slot, 0, 0); + save_slot(slot, 0, 0, 0); } } bool DLCache::has_data() { - return dl_size != 0; + return dl_slot_size != 0; } bool DLCache::wait_until_idle() { @@ -93,12 +97,12 @@ bool DLCache::wait_until_idle() { * that it can be appended later. The memory is * dynamically allocated following DL_FREE_ADDR. * - * If num_bytes is provided, then that many bytes + * If min_bytes is provided, then that many bytes * will be reserved so that the cache may be re-written * later with potentially a bigger DL. */ -bool DLCache::store(uint32_t num_bytes /* = 0*/) { +bool DLCache::store(uint32_t min_bytes /* = 0*/) { CLCD::CommandFifo cmd; // Execute any commands already in the FIFO @@ -107,67 +111,69 @@ bool DLCache::store(uint32_t num_bytes /* = 0*/) { return false; // Figure out how long the display list is - uint32_t new_dl_size = CLCD::mem_read_32(REG::CMD_DL) & 0x1FFF; - uint32_t free_space = 0; - uint32_t dl_alloc = 0; + const uint32_t dl_size = CLCD::dl_size(); - if (dl_addr == 0) { + if (dl_slot_addr == 0) { // If we are allocating new space... - dl_addr = CLCD::mem_read_32(DL_FREE_ADDR); - free_space = MAP::RAM_G_SIZE - dl_addr; - dl_alloc = num_bytes ?: new_dl_size; - dl_size = new_dl_size; - } else { - // Otherwise, we can only store as much space - // as was previously allocated. - free_space = num_bytes ?: dl_size; - dl_alloc = 0; - dl_size = new_dl_size; + dl_slot_addr = CLCD::mem_read_32(DL_FREE_ADDR); + dl_slot_size = max(dl_size, min_bytes); + + const uint32_t free_space = MAP::RAM_G_SIZE - dl_slot_addr; + if (dl_slot_size <= free_space) { + CLCD::mem_write_32(DL_FREE_ADDR, dl_slot_addr + dl_slot_size); + } + else { + dl_slot_addr = 0; + dl_slot_size = 0; + dl_slot_used = 0; + } } - if (dl_size > free_space) { + if (dl_size > dl_slot_size) { // Not enough memory to cache the display list. #if ENABLED(TOUCH_UI_DEBUG) SERIAL_ECHO_START(); - SERIAL_ECHOPAIR ("Not enough space in GRAM to cache display list, free space: ", free_space); + SERIAL_ECHOPAIR ("Not enough space in GRAM to cache display list, free space: ", dl_slot_size); SERIAL_ECHOLNPAIR(" Required: ", dl_size); #endif + dl_slot_used = 0; + save_slot(); return false; - } else { + } + else { #if ENABLED(TOUCH_UI_DEBUG) SERIAL_ECHO_START(); - SERIAL_ECHOPAIR ("Saving DL to RAMG cache, bytes: ", dl_size); - SERIAL_ECHOLNPAIR(" Free space: ", free_space); + SERIAL_ECHOPAIR ("Saving DL to RAMG cache, bytes: ", dl_slot_used); + SERIAL_ECHOLNPAIR(" Free space: ", dl_slot_size); #endif - cmd.memcpy(dl_addr, MAP::RAM_DL, dl_size); + dl_slot_used = dl_size; + save_slot(); + cmd.memcpy(dl_slot_addr, MAP::RAM_DL, dl_slot_used); cmd.execute(); - save_slot(dl_slot, dl_addr, dl_size); - if (dl_alloc > 0) { - // If we allocated space dynamically, then adjust dl_free_addr. - CLCD::mem_write_32(DL_FREE_ADDR, dl_addr + dl_alloc); - } return true; } } -void DLCache::save_slot(uint8_t dl_slot, uint32_t dl_addr, uint32_t dl_size) { - CLCD::mem_write_32(DL_CACHE_START + dl_slot * 8 + 0, dl_addr); - CLCD::mem_write_32(DL_CACHE_START + dl_slot * 8 + 4, dl_size); +void DLCache::save_slot(uint8_t indx, uint32_t addr, uint16_t size, uint16_t used) { + CLCD::mem_write_32(DL_CACHE_START + indx * 12 + 0, addr); + CLCD::mem_write_32(DL_CACHE_START + indx * 12 + 4, size); + CLCD::mem_write_32(DL_CACHE_START + indx * 12 + 8, used); } -void DLCache::load_slot() { - dl_addr = CLCD::mem_read_32(DL_CACHE_START + dl_slot * 8 + 0); - dl_size = CLCD::mem_read_32(DL_CACHE_START + dl_slot * 8 + 4); +void DLCache::load_slot(uint8_t indx, uint32_t &addr, uint16_t &size, uint16_t &used) { + addr = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 0); + size = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 4); + used = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 8); } void DLCache::append() { CLCD::CommandFifo cmd; - cmd.append(dl_addr, dl_size); + cmd.append(dl_slot_addr, dl_slot_used); #if ENABLED(TOUCH_UI_DEBUG) cmd.execute(); wait_until_idle(); SERIAL_ECHO_START(); - SERIAL_ECHOPAIR ("Appending to DL from RAMG cache, bytes: ", dl_size); + SERIAL_ECHOPAIR ("Appending to DL from RAMG cache, bytes: ", dl_slot_used); SERIAL_ECHOLNPAIR(" REG_CMD_DL: ", CLCD::mem_read_32(REG::CMD_DL)); #endif } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.h index 4ae4bce3efab..da927aeae23a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.h @@ -44,12 +44,16 @@ class DLCache { typedef FTDI::ftdi_registers REG; typedef FTDI::ftdi_memory_map MAP; - uint8_t dl_slot; - uint32_t dl_addr; - uint16_t dl_size; + uint8_t dl_slot_indx; + uint32_t dl_slot_addr; + uint16_t dl_slot_size; + uint16_t dl_slot_used; - void load_slot(); - static void save_slot(uint8_t dl_slot, uint32_t dl_addr, uint32_t dl_size); + void load_slot() {load_slot(dl_slot_indx, dl_slot_addr, dl_slot_size, dl_slot_used);} + void save_slot() {save_slot(dl_slot_indx, dl_slot_addr, dl_slot_size, dl_slot_used);} + + static void load_slot(uint8_t indx, uint32_t &addr, uint16_t &size, uint16_t &used); + static void save_slot(uint8_t indx, uint32_t addr, uint16_t size, uint16_t used); bool wait_until_idle(); @@ -57,12 +61,12 @@ class DLCache { static void init(); DLCache(uint8_t slot) { - dl_slot = slot; + dl_slot_indx = slot; load_slot(); } bool has_data(); - bool store(uint32_t num_bytes = 0); + bool store(uint32_t min_bytes = 0); void append(); }; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h index e1904511b264..6e4d0668fe3e 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h @@ -47,4 +47,5 @@ #include "sound_list.h" #include "polygon.h" #include "text_box.h" + #include "text_ellipsis.h" #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.h index 972c38395b14..d1f84c8a6e86 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.h @@ -144,8 +144,8 @@ class UIScreen { static bool onTouchEnd(uint8_t) {return true;} }; -#define PUSH_SCREEN(screen) current_screen.push(screen::onRedraw); -#define GOTO_SCREEN(screen) current_screen.goTo(screen::onRedraw); +#define PUSH_SCREEN(screen) current_screen.push(screen::onRedraw) +#define GOTO_SCREEN(screen) current_screen.goTo(screen::onRedraw) #define GOTO_PREVIOUS() current_screen.goBack(); #define AT_SCREEN(screen) (current_screen.getType() == current_screen.lookupScreen(screen::onRedraw)) #define IS_PARENT_SCREEN(screen) (current_screen.peek() == current_screen.lookupScreen(screen::onRedraw)) @@ -173,10 +173,21 @@ class UncachedScreen { template class CachedScreen { protected: + static void gfxError() { + using namespace FTDI; + CommandProcessor cmd; + cmd.cmd(CMD_DLSTART) + .cmd(CLEAR(true,true,true)) + .font(30) + .text(0, 0, display_width, display_height, F("GFX MEM FULL")); + } + static bool storeBackground() { DLCache dlcache(DL_SLOT); if (!dlcache.store(DL_SIZE)) { SERIAL_ECHO_MSG("CachedScreen::storeBackground() failed: not enough DL cache space"); + gfxError(); // Try to cache a shorter error message instead. + dlcache.store(DL_SIZE); return false; } return true; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp new file mode 100644 index 000000000000..3746f1cde0f5 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp @@ -0,0 +1,80 @@ +/********************* + * text_ellipsis.cpp * + *********************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2019 - Aleph Objects, Inc. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#include "ftdi_extended.h" + +#ifdef FTDI_EXTENDED + +namespace FTDI { + + /** + * Helper function for drawing text with ellipses. The str buffer may be modified and should have space for up to two extra characters. + */ + static void _draw_text_with_ellipsis(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, char *str, uint16_t options, uint8_t font) { + FontMetrics fm(font); + const uint16_t ellipsisWidth = fm.get_char_width('.') * 3; + + // Compute the total line length, as well as + // the location in the string where it can + // split and still allow the ellipsis to fit. + uint16_t lineWidth = 0; + char *breakPoint = str; + for(char* c = str; *c; c++) { + lineWidth += fm.get_char_width(*c); + if(lineWidth + ellipsisWidth < w) + breakPoint = c; + } + + if(lineWidth > w) { + *breakPoint = '\0'; + strcpy_P(breakPoint,PSTR("...")); + } + + cmd.apply_text_alignment(x, y, w, h, options); + #ifdef TOUCH_UI_USE_UTF8 + if (has_utf8_chars(str)) { + draw_utf8_text(cmd, x, y, str, font_size_t::from_romfont(font), options); + } else + #endif + { + cmd.CLCD::CommandFifo::text(x, y, font, options); + cmd.CLCD::CommandFifo::str(str); + } + } + + /** + * These functions draws text inside a bounding box, truncating the text and + * adding ellipsis if the text does not fit. + */ + void draw_text_with_ellipsis(CommandProcessor& cmd, int x, int y, int w, int h, const char *str, uint16_t options, uint8_t font) { + char tmp[strlen(str) + 3]; + strcpy(tmp, str); + _draw_text_with_ellipsis(cmd, x, y, w, h, tmp, options, font); + } + + void draw_text_with_ellipsis(CommandProcessor& cmd, int x, int y, int w, int h, progmem_str pstr, uint16_t options, uint8_t font) { + char tmp[strlen_P((const char*)pstr) + 3]; + strcpy_P(tmp, (const char*)pstr); + _draw_text_with_ellipsis(cmd, x, y, w, h, tmp, options, font); + } +} // namespace FTDI + +#endif // FTDI_EXTENDED diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.h new file mode 100644 index 000000000000..7852b7ec3e38 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.h @@ -0,0 +1,31 @@ +/******************* + * text_ellipsis.h * + *******************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2020 - SynDaver Labs, Inc. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#pragma once + +/** + * This function draws text inside a bounding box, truncating the text and + * showing ellipsis if it does not fit. + */ +namespace FTDI { + void draw_text_with_ellipsis(class CommandProcessor& cmd, int x, int y, int w, int h, progmem_str str, uint16_t options = 0, uint8_t font = 31); + void draw_text_with_ellipsis(class CommandProcessor& cmd, int x, int y, int w, int h, const char *str, uint16_t options = 0, uint8_t font = 31); +} diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h index b00c836ce470..f2971087c160 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h @@ -91,9 +91,6 @@ namespace Language_en { PROGMEM Language_Str MSG_UNITS_STEP_MM = u8"st/mm"; PROGMEM Language_Str MSG_UNITS_PERCENT = u8"%"; PROGMEM Language_Str MSG_UNITS_C = DEGREE_SIGN u8"C"; - PROGMEM Language_Str MSG_MATERIAL_PLA = u8"PLA"; - PROGMEM Language_Str MSG_MATERIAL_ABS = u8"ABS"; - PROGMEM Language_Str MSG_MATERIAL_HIGH_TEMP = u8"High"; PROGMEM Language_Str MSG_IDLE = u8"idle"; PROGMEM Language_Str MSG_SET_MAXIMUM = u8"Set Maximum"; PROGMEM Language_Str MSG_PRINT_SPEED = u8"Print Speed"; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp index a9b4ec6cd8b2..e06f9f3a29de 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp @@ -92,7 +92,7 @@ namespace ExtUI { char lcd_msg[30]; sprintf_P(lcd_msg, PSTR("Extruder %d Filament Error"), extruder + 1); StatusScreen::setStatusMessage(lcd_msg); - InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED); + InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED, FTDI::PLAY_SYNCHRONOUS); } void onFactoryReset() { diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.cpp index 47a35cd0a805..9cd17637bd52 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.cpp @@ -80,6 +80,7 @@ void AboutScreen::onRedraw(draw_mode_t) { #endif , OPT_CENTER, font_xlarge ); + cmd.tag(3); draw_text_box(cmd, FW_VERS_POS, #ifdef TOUCH_UI_VERSION F(TOUCH_UI_VERSION) @@ -87,6 +88,7 @@ void AboutScreen::onRedraw(draw_mode_t) { progmem_str(getFirmwareName_str()) #endif , OPT_CENTER, font_medium); + cmd.tag(0); draw_text_box(cmd, FW_INFO_POS, about_str, OPT_CENTER, font_medium); draw_text_box(cmd, INSET_POS(LICENSE_POS), GET_TEXT_F(MSG_LICENSE), OPT_CENTER, font_tiny); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.cpp index afa3211a01ae..589da9b21055 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.cpp @@ -207,13 +207,13 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) { { char str[30]; - format_temp_and_material(str, LOW_TEMP, GET_TEXT(MSG_MATERIAL_PLA)); + format_temp(str, LOW_TEMP); cmd.tag(2) .TOG_STYLE(tog2) .button (BTN_POS(2,6), BTN_SIZE(1,1), str); - format_temp_and_material(str, MED_TEMP, GET_TEXT(MSG_MATERIAL_ABS)); + format_temp(str, MED_TEMP); cmd.tag(3) .TOG_STYLE(tog3) .button (BTN_POS(2,5), BTN_SIZE(1,1), str); - format_temp_and_material(str, HIGH_TEMP, GET_TEXT(MSG_MATERIAL_HIGH_TEMP)); + format_temp(str, HIGH_TEMP); cmd.tag(4) .TOG_STYLE(tog4) .button (BTN_POS(2,4), BTN_SIZE(1,1), str); } cmd.colors(normal_btn) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.cpp index 974ce3a6e1fe..7e1a82025ddc 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.cpp @@ -38,7 +38,7 @@ bool ConfirmAutoCalibrationDialogBox::onTouchEnd(uint8_t tag) { switch (tag) { case 1: GOTO_SCREEN(StatusScreen); - injectCommands_P(PSTR(CALIBRATION_COMMANDS)); + injectCommands_P(PSTR("G425")); return true; default: return DialogBoxBaseClass::onTouchEnd(tag); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.cpp index e3043024223a..8d6fb1860394 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.cpp @@ -83,15 +83,19 @@ void FilesScreen::drawFileButton(const char* filename, uint8_t tag, bool is_dir, cmd.font(font_medium) .rectangle( 0, BTN_Y(header_h+line), display_width, BTN_H(1)); cmd.cmd(COLOR_RGB(is_highlighted ? normal_btn.rgb : bg_text_enabled)); + constexpr uint16_t dim[2] = {BTN_SIZE(6,1)}; + #define POS_AND_SHORTEN(SHORTEN) BTN_POS(1,header_h+line), dim[0] - (SHORTEN), dim[1] + #define POS_AND_SIZE POS_AND_SHORTEN(0) #if ENABLED(SCROLL_LONG_FILENAMES) if (is_highlighted) { cmd.cmd(SAVE_CONTEXT()); cmd.cmd(MACRO(0)); - } + cmd.text(POS_AND_SIZE, filename, OPT_CENTERY | OPT_NOFIT); + } else #endif - cmd.text (BTN_POS(1,header_h+line), BTN_SIZE(6,1), filename, OPT_CENTERY | TERN0(SCROLL_LONG_FILENAMES, OPT_NOFIT)); - if (is_dir) { - cmd.text(BTN_POS(1,header_h+line), BTN_SIZE(6,1), F("> "), OPT_CENTERY | OPT_RIGHTX); + draw_text_with_ellipsis(cmd, POS_AND_SHORTEN(is_dir ? 20 : 0), filename, OPT_CENTERY, font_medium); + if (is_dir && !is_highlighted) { + cmd.text(POS_AND_SIZE, F("> "), OPT_CENTERY | OPT_RIGHTX); } #if ENABLED(SCROLL_LONG_FILENAMES) if (is_highlighted) { @@ -102,7 +106,7 @@ void FilesScreen::drawFileButton(const char* filename, uint8_t tag, bool is_dir, void FilesScreen::drawFileList() { FileList files; - screen_data.FilesScreen.num_page = max(1,(ceil)(float(files.count()) / files_per_page)); + screen_data.FilesScreen.num_page = max(1,ceil(float(files.count()) / files_per_page)); screen_data.FilesScreen.cur_page = min(screen_data.FilesScreen.cur_page, screen_data.FilesScreen.num_page-1); screen_data.FilesScreen.flags.is_root = files.isAtRootDir(); @@ -134,7 +138,6 @@ void FilesScreen::drawHeader() { sprintf_P(str, PSTR("Page %d of %d"), screen_data.FilesScreen.cur_page + 1, screen_data.FilesScreen.num_page); - CommandProcessor cmd; cmd.colors(normal_btn) .font(font_small) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h index 92e6b230f7ef..ae48f752406e 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h @@ -96,7 +96,7 @@ enum { #define STATUS_SCREEN_DL_SIZE 2048 #define ALERT_BOX_DL_SIZE 3072 #define SPINNER_DL_SIZE 3072 -#define FILE_SCREEN_DL_SIZE 3072 +#define FILE_SCREEN_DL_SIZE 4160 #define PRINTING_SCREEN_DL_SIZE 2048 /************************* MENU SCREEN DECLARATIONS *************************/ diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.cpp index ac1fccd579a6..f2524c7982f1 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.cpp @@ -97,7 +97,7 @@ void StatusScreen::draw_axis_position(draw_mode_t what) { strcpy_P(y_str, PSTR("?")); if (isAxisPositionKnown(Z)) - format_position(z_str, getAxisPosition_mm(Z)); + format_position(z_str, getAxisPosition_mm(Z), 2); else strcpy_P(z_str, PSTR("?")); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.cpp index 340ffd055329..b7ce76ecd2b3 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.cpp @@ -61,8 +61,8 @@ void format_temp_and_material(char *str, float t1, const char *material) { /** * Formats a position value (e.g. "10 mm") */ -void format_position(char *str, float p) { - dtostrf(p, 5, 1, str); +void format_position(char *str, float p, uint8_t decimals) { + dtostrf(p, 4 + decimals, decimals, str); strcat_P(str, PSTR(" ")); strcat_P(str, GET_TEXT(MSG_UNITS_MM)); } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.h index ce3af4db878f..e37a82d28a5f 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.h @@ -25,5 +25,5 @@ void format_temp(char *str, float t1); void format_temp_and_idle(char *str, float t1); void format_temp_and_temp(char *str, float t1, float t2); void format_temp_and_material(char *str, float t1, const char *material); -void format_position(char *str, float p); +void format_position(char *str, float p, uint8_t decimals = 1); void format_position(char *str, float x, float y, float z); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp b/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp index 607090ba391d..ea94d6c1a571 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp @@ -33,25 +33,6 @@ TFT SPI_TFT; -#ifndef SPI_TFT_MISO_PIN - #define SPI_TFT_MISO_PIN PA6 -#endif -#ifndef SPI_TFT_MOSI_PIN - #define SPI_TFT_MOSI_PIN PA7 -#endif -#ifndef SPI_TFT_SCK_PIN - #define SPI_TFT_SCK_PIN PA5 -#endif -#ifndef SPI_TFT_CS_PIN - #define SPI_TFT_CS_PIN PD11 -#endif -#ifndef SPI_TFT_DC_PIN - #define SPI_TFT_DC_PIN PD10 -#endif -#ifndef SPI_TFT_RST_PIN - #define SPI_TFT_RST_PIN PC6 -#endif - // use SPI1 for the spi tft. void TFT::spi_init(uint8_t spiRate) { tftio.Init(); @@ -93,11 +74,11 @@ void TFT::SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height) { } void TFT::LCD_init() { - SPI_TFT_RST_H; + TFT_RST_H; delay(150); - SPI_TFT_RST_L; + TFT_RST_L; delay(150); - SPI_TFT_RST_H; + TFT_RST_H; tftio.DataTransferBegin(DATASIZE_8BIT); @@ -176,22 +157,22 @@ void TFT::LCD_init() { LCD_clear(0x0000); // LCD_Draw_Logo(); - SPI_TFT_BLK_H; + TFT_BLK_H; delay(2000); } void TFT::LCD_clear(uint16_t color) { - SetWindows(0, 0, (LCD_FULL_PIXEL_WIDTH) - 1, (LCD_FULL_PIXEL_HEIGHT) - 1); - tftio.WriteMultiple(color, (uint32_t)(LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT)); + SetWindows(0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1); + tftio.WriteMultiple(color, (uint32_t)(TFT_WIDTH) * (TFT_HEIGHT)); } extern unsigned char bmp_public_buf[17 * 1024]; void TFT::LCD_Draw_Logo() { - SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT); - for (uint16_t i = 0; i < (LCD_FULL_PIXEL_HEIGHT); i ++) { - Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (LCD_FULL_PIXEL_WIDTH) * 2); - tftio.WriteSequence((uint16_t *)bmp_public_buf, LCD_FULL_PIXEL_WIDTH); + SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT); + for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) { + Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2); + tftio.WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH); } } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h b/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h index c4b04e1c2183..e40039fe8649 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h @@ -29,11 +29,11 @@ #include HAL_PATH(../../HAL, tft/tft_fsmc.h) #endif -#define SPI_TFT_RST_H OUT_WRITE(SPI_TFT_RST_PIN, HIGH) -#define SPI_TFT_RST_L OUT_WRITE(SPI_TFT_RST_PIN, LOW) +#define TFT_RST_H OUT_WRITE(TFT_RESET_PIN, HIGH) +#define TFT_RST_L OUT_WRITE(TFT_RESET_PIN, LOW) -#define SPI_TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH) -#define SPI_TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW) +#define TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH) +#define TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW) class TFT { public: diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp index dc5e4910e939..ff9d0518d378 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -653,10 +653,10 @@ char *creat_title_text() { i += 2; if (*p_index == 0x0000) *p_index = 0xC318; } - SPI_TFT_CS_L; - SPI_TFT_DC_H; + TFT_CS_L; + TFT_DC_H; SPI.dmaSend(bmp_public_buf, 400, true); - SPI_TFT_CS_H; + TFT_CS_H; #else for (i = 0; i < 400;) { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp b/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp index a2795e933bcf..297ba723de8f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp @@ -34,8 +34,6 @@ #include "pic_manager.h" #include -#include "../../../touch/xpt2046.h" - #include "../../../../MarlinCore.h" #include "../../../../module/temperature.h" #include "../../../../sd/cardreader.h" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp index 391e12ba3fc7..23072d27c750 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp @@ -51,11 +51,11 @@ XPT2046 touch; #include -#ifndef LCD_FULL_PIXEL_WIDTH - #define LCD_FULL_PIXEL_WIDTH 480 +#ifndef TFT_WIDTH + #define TFT_WIDTH 480 #endif -#ifndef LCD_FULL_PIXEL_HEIGHT - #define LCD_FULL_PIXEL_HEIGHT 320 +#ifndef TFT_HEIGHT + #define TFT_HEIGHT 320 #endif #if HAS_SPI_FLASH_FONT @@ -135,7 +135,7 @@ void LCD_WriteRAM_Prepare(void) { void tft_set_point(uint16_t x, uint16_t y, uint16_t point) { //if (DeviceCode == 0x9488) { - if (x > (LCD_FULL_PIXEL_WIDTH) || y > (LCD_FULL_PIXEL_HEIGHT)) return; + if (x > (TFT_WIDTH) || y > (TFT_HEIGHT)) return; //} tft_set_cursor(x, y); @@ -196,8 +196,8 @@ void ili9320_SetWindows(uint16_t StartX, uint16_t StartY, uint16_t width, uint16 LCD_WriteReg(0x0053, yEnd);*/ LCD_WriteReg(0x0050, StartY); // Specify the start/end positions of the window address in the horizontal direction by an address unit LCD_WriteReg(0x0051, yEnd); // Specify the start positions of the window address in the vertical direction by an address unit - LCD_WriteReg(0x0052, (LCD_FULL_PIXEL_HEIGHT) - xEnd); - LCD_WriteReg(0x0053, (LCD_FULL_PIXEL_HEIGHT) - StartX - 1); // Specify the end positions of the window address in the vertical direction by an address unit + LCD_WriteReg(0x0052, (TFT_HEIGHT) - xEnd); + LCD_WriteReg(0x0053, (TFT_HEIGHT) - StartX - 1); // Specify the end positions of the window address in the vertical direction by an address unit } else { @@ -231,16 +231,16 @@ void LCD_Clear(uint16_t Color) { if (DeviceCode == 0x9488) { tft_set_cursor(0, 0); - ili9320_SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT); + ili9320_SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT); LCD_WriteRAM_Prepare(); #ifdef LCD_USE_DMA_FSMC - LCD_IO_WriteMultiple(Color, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT)); + LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT)); #else - //index = (LCD_FULL_PIXEL_HEIGHT) / 2 * (LCD_FULL_PIXEL_WIDTH); - for (index = 0; index < (LCD_FULL_PIXEL_HEIGHT) * (LCD_FULL_PIXEL_WIDTH); index++) + //index = (TFT_HEIGHT) / 2 * (TFT_WIDTH); + for (index = 0; index < (TFT_HEIGHT) * (TFT_WIDTH); index++) LCD_IO_WriteData(Color); #endif - //LCD_IO_WriteMultiple(Color, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT)); + //LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT)); //while(index --) LCD_IO_WriteData(Color); } else if (DeviceCode == 0x5761) { @@ -378,7 +378,7 @@ void init_tft() { for (i = 0; i < 65535; i++); LCD_IO_WriteReg(0x0029); - ili9320_SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT); + ili9320_SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT); LCD_Clear(0x0000); OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH); @@ -522,8 +522,8 @@ static bool get_point(int16_t *x, int16_t *y) { } #if ENABLED(GRAPHICAL_TFT_ROTATE_180) - x = (LCD_FULL_PIXEL_WIDTH) - x; - y = (LCD_FULL_PIXEL_HEIGHT) - y; + x = (TFT_WIDTH) - x; + y = (TFT_HEIGHT) - y; #endif return is_touched; diff --git a/Marlin/src/lcd/extui_malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp similarity index 97% rename from Marlin/src/lcd/extui_malyan_lcd.cpp rename to Marlin/src/lcd/extui/malyan_lcd.cpp index 38a8fbc0f99a..b5148065c7cc 100644 --- a/Marlin/src/lcd/extui_malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -21,7 +21,7 @@ */ /** - * extui_malyan_lcd.cpp + * malyan_lcd.cpp * * LCD implementation for Malyan's LCD, a separate ESP8266 MCU running * on Serial1 for the M200 board. This module outputs a pseudo-gcode @@ -41,25 +41,25 @@ * Copyright (c) 2017 Jason Nelson (xC0000005) */ -#include "../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfigPre.h" #if ENABLED(MALYAN_LCD) #define DEBUG_MALYAN_LCD -#include "extui/ui_api.h" +#include "ui_api.h" -#include "ultralcd.h" -#include "../sd/cardreader.h" -#include "../module/temperature.h" -#include "../module/stepper.h" -#include "../module/motion.h" -#include "../libs/duration_t.h" -#include "../module/printcounter.h" -#include "../gcode/queue.h" +#include "../ultralcd.h" +#include "../../sd/cardreader.h" +#include "../../module/temperature.h" +#include "../../module/stepper.h" +#include "../../module/motion.h" +#include "../../libs/duration_t.h" +#include "../../module/printcounter.h" +#include "../../gcode/queue.h" #define DEBUG_OUT ENABLED(DEBUG_MALYAN_LCD) -#include "../core/debug_out.h" +#include "../../core/debug_out.h" // On the Malyan M200, this will be Serial1. On a RAMPS board, // it might not be. diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index c19275449507..31449fcef4c7 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -548,7 +548,7 @@ namespace ExtUI { void setAxisSteps_per_mm(const float value, const extruder_t extruder) { UNUSED_E(extruder); - planner.settings.axis_steps_per_mm[E_AXIS_N(axis - E0)] = value; + planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)] = value; } feedRate_t getAxisMaxFeedrate_mm_s(const axis_t axis) { @@ -557,7 +557,7 @@ namespace ExtUI { feedRate_t getAxisMaxFeedrate_mm_s(const extruder_t extruder) { UNUSED_E(extruder); - return planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)]; + return planner.settings.max_feedrate_mm_s[E_AXIS_N(extruder - E0)]; } void setAxisMaxFeedrate_mm_s(const feedRate_t value, const axis_t axis) { @@ -1057,10 +1057,6 @@ namespace ExtUI { // At the moment, we piggy-back off the ultralcd calls, but this could be cleaned up in the future void MarlinUI::init() { - #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) - SET_INPUT_PULLUP(SD_DETECT_PIN); - #endif - ExtUI::onStartup(); } diff --git a/Marlin/src/lcd/fontutils.cpp b/Marlin/src/lcd/fontutils.cpp index ffa6d0df70b8..8b046af9a7a2 100644 --- a/Marlin/src/lcd/fontutils.cpp +++ b/Marlin/src/lcd/fontutils.cpp @@ -73,7 +73,7 @@ int pf_bsearch_r(void *userdata, size_t num_data, pf_bsearch_cb_comp_t cb_comp, return -1; } -/* This function gets the character at the pstart position, interpreting UTF8 multybyte sequences +/* This function gets the character at the pstart position, interpreting UTF8 multibyte sequences and returns the pointer to the next character */ uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval) { uint32_t val = 0; @@ -161,7 +161,6 @@ uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t } static inline uint8_t utf8_strlen_cb(const char *pstart, read_byte_cb_t cb_read_byte) { - uint8_t cnt = 0; uint8_t *pnext = (uint8_t *)pstart; for (;;) { diff --git a/Marlin/src/lcd/fontutils.h b/Marlin/src/lcd/fontutils.h index 8839e36a2bd1..74c4a87fb9d3 100644 --- a/Marlin/src/lcd/fontutils.h +++ b/Marlin/src/lcd/fontutils.h @@ -38,6 +38,6 @@ int pf_bsearch_r(void *userdata, size_t num_data, pf_bsearch_cb_comp_t cb_comp, /* Get the character, decoding multibyte UTF8 characters and returning a pointer to the start of the next UTF8 character */ uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval); -/* Returns lenght of string in CHARACTERS, NOT BYTES */ +/* Returns length of string in CHARACTERS, NOT BYTES */ uint8_t utf8_strlen(const char *pstart); uint8_t utf8_strlen_P(PGM_P pstart); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index c21cacddc89b..069a8e5a55a0 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -404,8 +404,6 @@ namespace Language_cz { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Celkem"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Endstop abort"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Chyba zahřívání"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Chyba zahř.podl."); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Chyba zahř.komory"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("REDUND. TEPLOTA"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("TEPLOTNÍ ÚNIK"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("TEPL. ÚNIK PODL."); @@ -527,7 +525,7 @@ namespace Language_cz { PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Vytáhněte, klikněte"); PROGMEM Language_Str MSG_MIX = _UxGT("Mix"); - PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Komponenta ~"); + PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Komponenta ="); PROGMEM Language_Str MSG_MIXER = _UxGT("Mixér"); PROGMEM Language_Str MSG_GRADIENT = _UxGT("Přechod"); PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Celý přechod"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index ebd08050373b..84b304c242be 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -33,10 +33,10 @@ namespace Language_de { using namespace Language_en; // Inherit undefined strings from English constexpr uint8_t CHARSIZE = 2; - PROGMEM Language_Str LANGUAGE = _UxGT("Deutsche"); + PROGMEM Language_Str LANGUAGE = _UxGT("Deutsch"); PROGMEM Language_Str WELCOME_MSG = MACHINE_NAME _UxGT(" bereit"); - + PROGMEM Language_Str MSG_MARLIN = _UxGT("Marlin"); PROGMEM Language_Str MSG_YES = _UxGT("JA"); PROGMEM Language_Str MSG_NO = _UxGT("NEIN"); PROGMEM Language_Str MSG_BACK = _UxGT("Zurück"); @@ -44,9 +44,11 @@ namespace Language_de { PROGMEM Language_Str MSG_MEDIA_INSERTED = _UxGT("Medium erkannt"); PROGMEM Language_Str MSG_MEDIA_REMOVED = _UxGT("Medium entfernt"); PROGMEM Language_Str MSG_MEDIA_WAITING = _UxGT("Warten auf Medium"); + PROGMEM Language_Str MSG_SD_INIT_FAIL = _UxGT("SD Init fehlgesch."); PROGMEM Language_Str MSG_MEDIA_READ_ERROR = _UxGT("Medium Lesefehler"); PROGMEM Language_Str MSG_MEDIA_USB_REMOVED = _UxGT("USB Gerät entfernt"); PROGMEM Language_Str MSG_MEDIA_USB_FAILED = _UxGT("USB Start fehlge."); + PROGMEM Language_Str MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Subcall überschritten"); PROGMEM Language_Str MSG_LCD_ENDSTOPS = _UxGT("Endstopp"); // Max length 8 characters PROGMEM Language_Str MSG_LCD_SOFT_ENDSTOPS = _UxGT("Software-Endstopp"); PROGMEM Language_Str MSG_MAIN = _UxGT("Hauptmenü"); @@ -56,7 +58,13 @@ namespace Language_de { PROGMEM Language_Str MSG_DISABLE_STEPPERS = _UxGT("Motoren deaktivieren"); // M84 :: Max length 19 characters PROGMEM Language_Str MSG_DEBUG_MENU = _UxGT("Debug-Menü"); PROGMEM Language_Str MSG_PROGRESS_BAR_TEST = _UxGT("Statusbalken-Test"); + PROGMEM Language_Str MSG_AUTO_HOME = _UxGT("Auto Home"); + PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("Home X"); + PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Home Y"); + PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Home Z"); PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Z-Achsen ausgleichen"); + PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Bett ausrichten"); // Bettausrichtung + PROGMEM Language_Str MSG_LEVEL_BED_HOMING = _UxGT("XYZ homen"); PROGMEM Language_Str MSG_LEVEL_BED_WAITING = _UxGT("Klick zum Starten"); PROGMEM Language_Str MSG_LEVEL_BED_NEXT_POINT = _UxGT("Nächste Koordinate"); PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Nivellieren fertig!"); @@ -110,9 +118,9 @@ namespace Language_de { PROGMEM Language_Str MSG_MESH_Y = _UxGT("Index Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Z-Wert"); PROGMEM Language_Str MSG_USER_MENU = _UxGT("Benutzer-Menü"); - PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Berührungspunkt"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Sondentest"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Punkt"); + PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Zu weit draußen"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Abweichung"); PROGMEM Language_Str MSG_IDEX_MENU = _UxGT("IDEX-Modus"); PROGMEM Language_Str MSG_OFFSETS_MENU = _UxGT("Werkzeugversätze"); @@ -126,6 +134,7 @@ namespace Language_de { PROGMEM Language_Str MSG_UBL_DOING_G29 = _UxGT("G29 ausführen"); PROGMEM Language_Str MSG_UBL_TOOLS = _UxGT("UBL-Werkzeuge"); PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); + PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Berührungspunkt"); PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Netz manuell erst."); PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Unterlegen & messen"); PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Messen"); @@ -154,6 +163,7 @@ namespace Language_de { PROGMEM Language_Str MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Eig. Netz validieren"); PROGMEM Language_Str MSG_G26_HEATING_BED = _UxGT("G26 heizt Bett"); PROGMEM Language_Str MSG_G26_HEATING_NOZZLE = _UxGT("G26 Düse aufheizen"); + PROGMEM Language_Str MSG_G26_MANUAL_PRIME = _UxGT("Manuell Prime..."); PROGMEM Language_Str MSG_G26_FIXED_LENGTH = _UxGT("Feste Länge Prime"); PROGMEM Language_Str MSG_G26_PRIME_DONE = _UxGT("Priming fertig"); PROGMEM Language_Str MSG_G26_CANCELED = _UxGT("G26 abgebrochen"); @@ -234,6 +244,7 @@ namespace Language_de { PROGMEM Language_Str MSG_NOZZLE = _UxGT("Düse"); PROGMEM Language_Str MSG_NOZZLE_N = _UxGT("Düse ~"); PROGMEM Language_Str MSG_NOZZLE_PARKED = _UxGT("Düse geparkt"); + PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Düse bereit"); PROGMEM Language_Str MSG_BED = _UxGT("Bett"); PROGMEM Language_Str MSG_CHAMBER = _UxGT("Gehäuse"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Lüfter"); @@ -255,6 +266,22 @@ namespace Language_de { PROGMEM Language_Str MSG_AUTOTEMP = _UxGT("Auto Temperatur"); PROGMEM Language_Str MSG_LCD_ON = _UxGT("an"); PROGMEM Language_Str MSG_LCD_OFF = _UxGT("aus"); + PROGMEM Language_Str MSG_PID_AUTOTUNE = _UxGT("PID Autotune"); + PROGMEM Language_Str MSG_PID_AUTOTUNE_E = _UxGT("PID Autotune *"); + PROGMEM Language_Str MSG_PID_AUTOTUNE_DONE = _UxGT("PID Tuning fertig"); + PROGMEM Language_Str MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune fehlge. Falscher Extruder"); + PROGMEM Language_Str MSG_PID_TEMP_TOO_HIGH = _UxGT("Autotune fehlge. Temperatur zu hoch."); + PROGMEM Language_Str MSG_PID_TIMEOUT = _UxGT("Autotune fehlge.! Timeout."); + PROGMEM Language_Str MSG_PID_P = _UxGT("PID-P"); + PROGMEM Language_Str MSG_PID_P_E = _UxGT("PID-P *"); + PROGMEM Language_Str MSG_PID_I = _UxGT("PID-I"); + PROGMEM Language_Str MSG_PID_I_E = _UxGT("PID-I *"); + PROGMEM Language_Str MSG_PID_D = _UxGT("PID-D"); + PROGMEM Language_Str MSG_PID_D_E = _UxGT("PID-D *"); + PROGMEM Language_Str MSG_PID_C = _UxGT("PID-C"); + PROGMEM Language_Str MSG_PID_C_E = _UxGT("PID-C *"); + PROGMEM Language_Str MSG_PID_F = _UxGT("PID-F"); + PROGMEM Language_Str MSG_PID_F_E = _UxGT("PID-F *"); PROGMEM Language_Str MSG_SELECT = _UxGT("Auswählen"); PROGMEM Language_Str MSG_SELECT_E = _UxGT("Auswählen *"); PROGMEM Language_Str MSG_ACC = _UxGT("Beschleunigung"); @@ -281,6 +308,8 @@ namespace Language_de { PROGMEM Language_Str MSG_AMAX_EN = _UxGT("A max *"); PROGMEM Language_Str MSG_A_RETRACT = _UxGT("A Einzug"); PROGMEM Language_Str MSG_A_TRAVEL = _UxGT("A Leerfahrt"); + PROGMEM Language_Str MSG_XY_FREQUENCY_LIMIT = _UxGT("max. Frequenz"); + PROGMEM Language_Str MSG_XY_FREQUENCY_FEEDRATE = _UxGT("min. Vorschub"); PROGMEM Language_Str MSG_STEPS_PER_MM = _UxGT("Steps/mm"); PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" Steps/mm"); PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" Steps/mm"); @@ -291,6 +320,8 @@ namespace Language_de { PROGMEM Language_Str MSG_MOTION = _UxGT("Bewegung"); PROGMEM Language_Str MSG_FILAMENT = _UxGT("Filament"); PROGMEM Language_Str MSG_VOLUMETRIC_ENABLED = _UxGT("E in mm³"); + PROGMEM Language_Str MSG_VOLUMETRIC_LIMIT = _UxGT("E Limit in mm³"); + PROGMEM Language_Str MSG_VOLUMETRIC_LIMIT_E = _UxGT("E Limit *"); PROGMEM Language_Str MSG_FILAMENT_DIAM = _UxGT("Filamentdurchmesser"); PROGMEM Language_Str MSG_FILAMENT_DIAM_E = _UxGT("Filamentdurchmesser *"); PROGMEM Language_Str MSG_FILAMENT_UNLOAD = _UxGT("Entladen mm"); @@ -302,6 +333,9 @@ namespace Language_de { PROGMEM Language_Str MSG_LOAD_EEPROM = _UxGT("Konfig. laden"); PROGMEM Language_Str MSG_RESTORE_DEFAULTS = _UxGT("Standardwerte laden"); PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("Werkseinstellungen"); + PROGMEM Language_Str MSG_ERR_EEPROM_CRC = _UxGT("EEPROM CRC Fehler"); + PROGMEM Language_Str MSG_ERR_EEPROM_INDEX = _UxGT("EEPROM Index Fehler"); + PROGMEM Language_Str MSG_ERR_EEPROM_VERSION = _UxGT("EEPROM Version Fehler"); PROGMEM Language_Str MSG_SETTINGS_STORED = _UxGT("Einstell. gespei."); PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("FW Update vom Medium"); PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Drucker neustarten"); @@ -309,19 +343,26 @@ namespace Language_de { PROGMEM Language_Str MSG_INFO_SCREEN = _UxGT("Info"); PROGMEM Language_Str MSG_PREPARE = _UxGT("Vorbereitung"); PROGMEM Language_Str MSG_TUNE = _UxGT("Justierung"); + PROGMEM Language_Str MSG_POWER_MONITOR = _UxGT("Power Monitor"); + PROGMEM Language_Str MSG_CURRENT = _UxGT("Strom"); + PROGMEM Language_Str MSG_VOLTAGE = _UxGT("Spannung"); + PROGMEM Language_Str MSG_POWER = _UxGT("Power"); PROGMEM Language_Str MSG_START_PRINT = _UxGT("Starte Druck"); PROGMEM Language_Str MSG_BUTTON_NEXT = _UxGT("Weiter"); PROGMEM Language_Str MSG_BUTTON_INIT = _UxGT("Bestätigen"); PROGMEM Language_Str MSG_BUTTON_STOP = _UxGT("Stop"); PROGMEM Language_Str MSG_BUTTON_PRINT = _UxGT("Drucken"); PROGMEM Language_Str MSG_BUTTON_RESET = _UxGT("Reseten"); + PROGMEM Language_Str MSG_BUTTON_IGNORE = _UxGT("Ignorieren"); PROGMEM Language_Str MSG_BUTTON_CANCEL = _UxGT("Abbrechen"); PROGMEM Language_Str MSG_BUTTON_DONE = _UxGT("Fertig"); PROGMEM Language_Str MSG_BUTTON_BACK = _UxGT("Zurück"); + PROGMEM Language_Str MSG_BUTTON_PROCEED = _UxGT("Weiter"); PROGMEM Language_Str MSG_PAUSING = _UxGT("Pause..."); PROGMEM Language_Str MSG_PAUSE_PRINT = _UxGT("SD-Druck pausieren"); PROGMEM Language_Str MSG_RESUME_PRINT = _UxGT("SD-Druck fortsetzen"); PROGMEM Language_Str MSG_STOP_PRINT = _UxGT("SD-Druck abbrechen"); + PROGMEM Language_Str MSG_PRINTING_OBJECT = _UxGT("Objekt drucken"); PROGMEM Language_Str MSG_CANCEL_OBJECT = _UxGT("Objekt abbrechen"); PROGMEM Language_Str MSG_CANCEL_OBJECT_N = _UxGT("Objekt abbrechen ="); PROGMEM Language_Str MSG_OUTAGE_RECOVERY = _UxGT("Wiederh. n. Stroma."); @@ -346,12 +387,22 @@ namespace Language_de { PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAPF = _UxGT("S UnRet V"); PROGMEM Language_Str MSG_AUTORETRACT = _UxGT("Autom. Einzug"); PROGMEM Language_Str MSG_FILAMENT_SWAP_LENGTH = _UxGT("Einzugslänge"); + PROGMEM Language_Str MSG_FILAMENT_SWAP_EXTRA = _UxGT("Extra Einzug"); PROGMEM Language_Str MSG_FILAMENT_PURGE_LENGTH = _UxGT("Entladelänge"); PROGMEM Language_Str MSG_TOOL_CHANGE = _UxGT("Werkzeugwechsel"); PROGMEM Language_Str MSG_TOOL_CHANGE_ZLIFT = _UxGT("Z anheben"); PROGMEM Language_Str MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Prime-Geschwin."); PROGMEM Language_Str MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Einzug-Geschwin."); - PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Düsen-Standby"); + PROGMEM Language_Str MSG_FILAMENT_PARK_ENABLED = _UxGT("Kopf parken"); + PROGMEM Language_Str MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Rückzugsgeschwindigkeit"); + PROGMEM Language_Str MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Lüfter Geschwindigkeit"); + PROGMEM Language_Str MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Lüfter Zeit"); + PROGMEM Language_Str MSG_TOOL_MIGRATION_ON = _UxGT("Auto AN"); + PROGMEM Language_Str MSG_TOOL_MIGRATION_OFF = _UxGT("Auto AUS"); + PROGMEM Language_Str MSG_TOOL_MIGRATION = _UxGT("Werkzeugmigration"); + PROGMEM Language_Str MSG_TOOL_MIGRATION_AUTO = _UxGT("Auto-Migration"); + PROGMEM Language_Str MSG_TOOL_MIGRATION_END = _UxGT("Letzter Extruder"); + PROGMEM Language_Str MSG_TOOL_MIGRATION_SWAP = _UxGT("Migrieren zu *"); PROGMEM Language_Str MSG_FILAMENTCHANGE = _UxGT("Filament wechseln"); PROGMEM Language_Str MSG_FILAMENTCHANGE_E = _UxGT("Filament wechseln *"); PROGMEM Language_Str MSG_FILAMENTLOAD = _UxGT("Filament laden"); @@ -367,6 +418,7 @@ namespace Language_de { PROGMEM Language_Str MSG_BLTOUCH = _UxGT("BLTouch"); PROGMEM Language_Str MSG_BLTOUCH_SELFTEST = _UxGT("Selbsttest"); PROGMEM Language_Str MSG_BLTOUCH_RESET = _UxGT("Zurücksetzen"); + PROGMEM Language_Str MSG_BLTOUCH_STOW = _UxGT("Einfahren"); PROGMEM Language_Str MSG_BLTOUCH_DEPLOY = _UxGT("Ausfahren"); PROGMEM Language_Str MSG_BLTOUCH_SW_MODE = _UxGT("SW-Modus"); PROGMEM Language_Str MSG_BLTOUCH_5V_MODE = _UxGT("5V-Modus"); @@ -374,7 +426,6 @@ namespace Language_de { PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_5V = _UxGT("Setze auf 5V"); PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_OD = _UxGT("Setze auf OD"); - PROGMEM Language_Str MSG_BLTOUCH_STOW = _UxGT("Einfahren"); PROGMEM Language_Str MSG_BLTOUCH_MODE_ECHO = _UxGT("Modus: "); PROGMEM Language_Str MSG_BLTOUCH_MODE_CHANGE = _UxGT("ACHTUNG: Falsche Einstellung - kann zu Beschädigung führen! Fortfahren?"); PROGMEM Language_Str MSG_TOUCHMI_PROBE = _UxGT("TouchMI"); @@ -395,8 +446,6 @@ namespace Language_de { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Total"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Abbr. mit Endstopp"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("HEIZEN ERFOLGLOS"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Bett heizen fehlge."); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Geh. heizen fehlge."); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("REDUND. TEMP-ABWEI."); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("BETT") " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); @@ -443,6 +492,9 @@ namespace Language_de { PROGMEM Language_Str MSG_INFO_EXTRUDERS = _UxGT("Extruder"); PROGMEM Language_Str MSG_INFO_BAUDRATE = _UxGT("Baudrate"); PROGMEM Language_Str MSG_INFO_PROTOCOL = _UxGT("Protokoll"); + PROGMEM Language_Str MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: AUS"); + PROGMEM Language_Str MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: AN"); + PROGMEM Language_Str MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); PROGMEM Language_Str MSG_CASE_LIGHT = _UxGT("Beleuchtung"); PROGMEM Language_Str MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Helligkeit"); @@ -508,7 +560,7 @@ namespace Language_de { PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Entfernen, klicken"); PROGMEM Language_Str MSG_MIX = _UxGT("Mix"); - PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Komponente ~"); + PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Komponente ="); PROGMEM Language_Str MSG_MIXER = _UxGT("Mixer"); PROGMEM Language_Str MSG_GRADIENT = _UxGT("Gradient"); // equal Farbverlauf PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Volle Gradient"); @@ -531,6 +583,20 @@ namespace Language_de { PROGMEM Language_Str MSG_SNAKE = _UxGT("Sn4k3"); PROGMEM Language_Str MSG_MAZE = _UxGT("Maze"); + PROGMEM Language_Str MSG_BAD_PAGE = _UxGT("ungült. Seitenzahl"); + PROGMEM Language_Str MSG_BAD_PAGE_SPEED = _UxGT("ungült. Seitengeschw."); + + PROGMEM Language_Str MSG_EDIT_PASSWORD = _UxGT("Passwort bearbeiten"); + PROGMEM Language_Str MSG_LOGIN_REQUIRED = _UxGT("Login erforderlich"); + PROGMEM Language_Str MSG_PASSWORD_SETTINGS = _UxGT("Passwort Einstellungen"); + PROGMEM Language_Str MSG_ENTER_DIGIT = _UxGT("PIN eingeben"); + PROGMEM Language_Str MSG_CHANGE_PASSWORD = _UxGT("Passwort ändern"); + PROGMEM Language_Str MSG_REMOVE_PASSWORD = _UxGT("Passwort löschen"); + PROGMEM Language_Str MSG_PASSWORD_SET = _UxGT("Passwort ist "); + PROGMEM Language_Str MSG_START_OVER = _UxGT("von vorn beginnen"); + PROGMEM Language_Str MSG_REMINDER_SAVE_SETTINGS = _UxGT("Bald speichern!"); + PROGMEM Language_Str MSG_PASSWORD_REMOVED = _UxGT("Passwort gelöscht"); + // // Die Filament-Change-Bildschirme können bis zu 3 Zeilen auf einem 4-Zeilen-Display anzeigen // ...oder 2 Zeilen auf einem 3-Zeilen-Display. @@ -576,7 +642,11 @@ namespace Language_de { PROGMEM Language_Str MSG_BACKLASH_SMOOTHING = _UxGT("Glätten"); PROGMEM Language_Str MSG_LEVEL_X_AXIS = _UxGT("X Achse leveln"); PROGMEM Language_Str MSG_AUTO_CALIBRATE = _UxGT("Auto. Kalibiren"); - PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Heizung Timeout"); + #if ENABLED(TOUCH_UI_FTDI_EVE) + PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Idle Timeout, Temperatur fällt. Drücke Okay, um erneut aufzuheizen und fortzufahren."); + #else + PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Heizungs Timeout"); + #endif PROGMEM Language_Str MSG_REHEAT = _UxGT("Erneut aufheizen"); PROGMEM Language_Str MSG_REHEATING = _UxGT("Erneut aufhei. ..."); } diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 9f6178ae50cc..8ae40304bdf3 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -48,6 +48,7 @@ namespace Language_en { PROGMEM Language_Str MSG_MEDIA_INSERTED = _UxGT("Media Inserted"); PROGMEM Language_Str MSG_MEDIA_REMOVED = _UxGT("Media Removed"); PROGMEM Language_Str MSG_MEDIA_WAITING = _UxGT("Waiting for media"); + PROGMEM Language_Str MSG_SD_INIT_FAIL = _UxGT("SD Init Fail"); PROGMEM Language_Str MSG_MEDIA_READ_ERROR = _UxGT("Media read error"); PROGMEM Language_Str MSG_MEDIA_USB_REMOVED = _UxGT("USB device removed"); PROGMEM Language_Str MSG_MEDIA_USB_FAILED = _UxGT("USB start failed"); @@ -123,6 +124,7 @@ namespace Language_en { PROGMEM Language_Str MSG_USER_MENU = _UxGT("Custom Commands"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Probe Test"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Point"); + PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Probe out of bounds"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Deviation"); PROGMEM Language_Str MSG_IDEX_MENU = _UxGT("IDEX Mode"); PROGMEM Language_Str MSG_OFFSETS_MENU = _UxGT("Tool Offsets"); @@ -220,6 +222,10 @@ namespace Language_en { PROGMEM Language_Str MSG_SET_LEDS_VIOLET = _UxGT("Violet"); PROGMEM Language_Str MSG_SET_LEDS_WHITE = _UxGT("White"); PROGMEM Language_Str MSG_SET_LEDS_DEFAULT = _UxGT("Default"); + PROGMEM Language_Str MSG_LED_CHANNEL_N = _UxGT("Channel ="); + PROGMEM Language_Str MSG_LEDS2 = _UxGT("Lights #2"); + PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Light #2 Presets"); + PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Brightness"); PROGMEM Language_Str MSG_CUSTOM_LEDS = _UxGT("Custom Lights"); PROGMEM Language_Str MSG_INTENSITY_R = _UxGT("Red Intensity"); PROGMEM Language_Str MSG_INTENSITY_G = _UxGT("Green Intensity"); @@ -445,8 +451,6 @@ namespace Language_en { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Total"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Endstop Abort"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Heating Failed"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Bed Heating Failed"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Chamber Heating Fail"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: REDUNDANT TEMP"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("THERMAL RUNAWAY"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("BED THERMAL RUNAWAY"); @@ -645,7 +649,11 @@ namespace Language_en { PROGMEM Language_Str MSG_LEVEL_X_AXIS = _UxGT("Level X Axis"); PROGMEM Language_Str MSG_AUTO_CALIBRATE = _UxGT("Auto Calibrate"); - PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Heater Timeout"); + #if ENABLED(TOUCH_UI_FTDI_EVE) + PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Idle timeout, temperature decreased. Press Okay to reheat and again to resume."); + #else + PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Heater Timeout"); + #endif PROGMEM Language_Str MSG_REHEAT = _UxGT("Reheat"); PROGMEM Language_Str MSG_REHEATING = _UxGT("Reheating..."); } diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 2b10bfe313e1..5beab6c1c90f 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -415,8 +415,6 @@ namespace Language_es { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Total"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Cancelado - Endstop"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Calent. fallido"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Calent. cama fallido"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Calent. Cám. fallido"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: TEMP. REDUN."); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("FUGA TÉRMICA"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("FUGA TÉRMICA CAMA"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index d403477eb015..0042a30f8e5f 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -508,7 +508,7 @@ namespace Language_fr { PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("Réinit. MMU..."); PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Retrait, click"); - PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Composante ~"); + PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Composante ="); PROGMEM Language_Str MSG_MIXER = _UxGT("Mixeur"); PROGMEM Language_Str MSG_GRADIENT = _UxGT("Dégradé"); PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Dégradé complet"); diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index 4415fc5e1c12..90e4129abd7c 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -437,8 +437,6 @@ namespace Language_gl { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Total"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Erro FinCarro"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Fallo Quentando"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Fallo Quent. Cama"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Fallo Quent. Cámara"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Erro:Temp Redundante"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("FUGA TÉRMICA"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("FUGA TÉRMICA CAMA"); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index 182ed27072bb..64ea482249ef 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -439,8 +439,6 @@ namespace Language_hu { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Teljes"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Végállás megszakítva!"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Fütés hiba!"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Ágy fütés hiba!"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Kamra fütés hiba!"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Hiba: SZÜKSÉGTELEN HÖFOK"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("FÜTÉS KIMARADÁS"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("ÁGY FÜTÉS KIMARADÁS"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 1a5bdb22e98e..0a56fdf5ecfe 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -122,6 +122,7 @@ namespace Language_it { PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Punto inclinaz."); PROGMEM Language_Str MSG_M48_TEST = _UxGT("Test sonda M48"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("Punto M48"); + PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Sonda oltre i limiti"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Deviazione"); PROGMEM Language_Str MSG_IDEX_MENU = _UxGT("Modo IDEX"); PROGMEM Language_Str MSG_OFFSETS_MENU = _UxGT("Strumenti Offsets"); @@ -444,9 +445,7 @@ namespace Language_it { PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Babystep Z"); PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Totali"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Finecorsa annullati"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Riscald. Fallito"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Risc. piatto fallito"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Risc. camera fallito"); + PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Risc.Fallito"); // Max 12 caratteri PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: TEMP RIDONDANTE"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("TEMP FUORI CONTROLLO"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("TEMP PIAT.FUORI CTRL"); @@ -560,7 +559,7 @@ namespace Language_it { PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Rimuovi, click"); PROGMEM Language_Str MSG_MIX = _UxGT("Miscela"); - PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Componente ~"); + PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Componente ="); PROGMEM Language_Str MSG_MIXER = _UxGT("Miscelatore"); PROGMEM Language_Str MSG_GRADIENT = _UxGT("Gradiente"); PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Gradiente pieno"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index 79190ddfcb42..17ca0bd00f45 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -385,8 +385,6 @@ namespace Language_pl { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Łącznie"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Błąd krańcówki"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Rozgrz. nieudane"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Rozgrz. stołu nieudane"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Rozgrz. komory nieudane"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Błąd temperatury"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("ZANIK TEMPERATURY"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("ZANIK TEMP. STOŁU"); @@ -500,7 +498,7 @@ namespace Language_pl { PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Usuń, kliknij"); PROGMEM Language_Str MSG_MIX = _UxGT("Miks"); - PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Komponent ~"); + PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Komponent ="); PROGMEM Language_Str MSG_MIXER = _UxGT("Mikser"); PROGMEM Language_Str MSG_GRADIENT = _UxGT("Gradient"); PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Pełny gradient"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index e0a52fc3906a..2c6c2af1486e 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -351,8 +351,6 @@ namespace Language_pt_br { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Total"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Abortar Fim de Curso"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Aquecimento falhou"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Aquecer mesa falhou"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Aquecer câmara falhou"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Erro:Temp Redundante"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("ESCAPE TÉRMICO"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("ESCAPE TÉRMICO MESA"); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index 39e5cb9e2cd8..dc5591117602 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -442,8 +442,6 @@ namespace Language_ro { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Total"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Endstop Abort"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Heating Failed"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Bed Heating Failed"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Chamber Heating Fail"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: REDUNDANT TEMP"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("THERMAL RUNAWAY"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("BED THERMAL RUNAWAY"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index 6228e92346ab..e1abfa542972 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -530,8 +530,6 @@ namespace Language_ru { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Сумарно"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Сработал концевик"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Разогрев не удался"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Сбой нагрева стола"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Сбой нагрева камеры"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Ошибка:Избыточная Т"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("УТЕЧКА ТЕПЛА"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("УТЕЧКА ТЕПЛА СТОЛА"); diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index 736e2069d999..71949014b7c7 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -435,8 +435,6 @@ namespace Language_sk { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Celkom"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Zastavenie Endstop"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Chyba ohrevu"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Chyba ohrevu podl."); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Chyba ohrevu komory"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Chyba: REDUND. TEP."); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("TEPLOTNÝ SKOK"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("TEPLOTNÝ SKOK PODL."); @@ -551,7 +549,7 @@ namespace Language_sk { PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Odstráňte, kliknite"); PROGMEM Language_Str MSG_MIX = _UxGT("Mix"); - PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Zložka ~"); + PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Zložka ="); PROGMEM Language_Str MSG_MIXER = _UxGT("Mixér"); PROGMEM Language_Str MSG_GRADIENT = _UxGT("Gradient"); PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Plný gradient"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index bb68a6171766..c0ce4bfdc5d0 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -414,8 +414,6 @@ namespace Language_tr { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Toplam"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Endstop iptal"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Isınma başarısız"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Yatak Isınma Başrsız"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Oda Isıtma Hatası"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Hata: Sıcaklık Aşımı"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("TERMAL PROBLEM"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("TABLA TERMAL PROBLEM"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 686657246f3b..30d45338d98d 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -524,8 +524,6 @@ namespace Language_uk { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Сумарно"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Кінцевик спрацював"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Збій нагріву"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Збій нагріву столу"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("Збій нагріву камери"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("ЗАВИЩЕНА Т") LCD_STR_DEGREE; PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("ВИТІК ТЕПЛА"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("ВИТІК ТЕПЛА СТОЛУ"); diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index 227a4950f367..02453e58792f 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -330,7 +330,6 @@ namespace Language_vi { PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Nhít Z"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Hủy bỏ công tắc"); // Endstop abort PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Sưởi đầu phun không thành công"); // Heating failed - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Sưởi bàn không thành công"); // Bed heating failed PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Điều sai: nhiệt độ dư"); // Err: REDUNDANT TEMP PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("Vấn đề nhiệt"); // THERMAL RUNAWAY | problem PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("Vấn đề nhiệt bàn"); // BED THERMAL RUNAWAY diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index cf772caaef66..49d7acd94cc8 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -441,8 +441,6 @@ namespace Language_zh_CN { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("总计"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("挡块终止"); //"Endstop abort" PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("加热失败"); //"Heating failed" - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("热床加热失败"); - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("机箱加热失败"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("错误:冗余温度"); //"Err: REDUNDANT TEMP" PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("温控失控"); //"THERMAL RUNAWAY" PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("热床热量失控"); diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 94a7944b3598..ac543585347f 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -382,8 +382,6 @@ namespace Language_zh_TW { PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("總計"); //"Total" PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("擋塊終止"); //"Endstop abort" PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("加熱失敗"); //"Heating failed" - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("熱床加熱失敗"); //"Bed Heating Failed" - PROGMEM Language_Str MSG_HEATING_FAILED_LCD_CHAMBER = _UxGT("機箱加熱失敗"); //"Chamber Heating Fail" PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("錯誤:冗餘溫度"); //"Err: REDUNDANT TEMP" PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("溫度失控"); //"THERMAL RUNAWAY" PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("熱床溫度失控"); //"BED THERMAL RUNAWAY" diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index 00139808aebc..8ea174bd65fc 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -76,10 +76,10 @@ #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT) #define INFO_FONT_WIDTH 6 - #define SETCURSOR(col, row) lcd_moveto(col * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT)) - #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT)) + #define SETCURSOR(col, row) lcd_moveto((col) * (MENU_FONT_WIDTH), ((row) + 1) * (MENU_FONT_HEIGHT)) + #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), ((row) + 1) * (MENU_FONT_HEIGHT)) -#else +#elif HAS_CHARACTER_LCD #define _UxGT(a) a typedef uint8_t lcd_uint_t; @@ -94,12 +94,13 @@ #define LCD_PIXEL_WIDTH LCD_WIDTH #define LCD_PIXEL_HEIGHT LCD_HEIGHT - #define SETCURSOR(col, row) lcd_moveto(col, row) - #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_WIDTH - (len), row) + #define SETCURSOR(col, row) lcd_moveto(col, row) + #define SETCURSOR_RJ(len, row) SETCURSOR(LCD_WIDTH - (len), row) #endif -#define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr) +#define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr) +#define SETCURSOR_X_RJ(len) SETCURSOR_RJ(len, _lcdLineNr) #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u) int lcd_glyph_height(); diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index c3afc787eba9..81845c39150b 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -99,12 +99,6 @@ void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_b return_to_status(); } -//////////////////////////////////////////// -/////////// Common Menu Actions //////////// -//////////////////////////////////////////// - -void MenuItem_gcode::action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pgcode); } - //////////////////////////////////////////// /////////// Menu Editing Actions /////////// //////////////////////////////////////////// @@ -169,35 +163,6 @@ void MenuEditItemBase::goto_edit_screen( liveEdit = le; } -// TODO: Remove these but test build size with and without -#define DEFINE_MENU_EDIT_ITEM(NAME) template class TMenuEditItem - -DEFINE_MENU_EDIT_ITEM(percent); // 100% right-justified -DEFINE_MENU_EDIT_ITEM(int3); // 123, -12 right-justified -DEFINE_MENU_EDIT_ITEM(int4); // 1234, -123 right-justified -DEFINE_MENU_EDIT_ITEM(int8); // 123, -12 right-justified -DEFINE_MENU_EDIT_ITEM(uint8); // 123 right-justified -DEFINE_MENU_EDIT_ITEM(uint16_3); // 123 right-justified -DEFINE_MENU_EDIT_ITEM(uint16_4); // 1234 right-justified -DEFINE_MENU_EDIT_ITEM(uint16_5); // 12345 right-justified -DEFINE_MENU_EDIT_ITEM(float3); // 123 right-justified -DEFINE_MENU_EDIT_ITEM(float42_52); // _2.34, 12.34, -2.34 or 123.45, -23.45 -DEFINE_MENU_EDIT_ITEM(float43); // 1.234 -DEFINE_MENU_EDIT_ITEM(float5); // 12345 right-justified -DEFINE_MENU_EDIT_ITEM(float5_25); // 12345 right-justified (25 increment) -DEFINE_MENU_EDIT_ITEM(float51); // 1234.5 right-justified -DEFINE_MENU_EDIT_ITEM(float31sign); // +12.3 -DEFINE_MENU_EDIT_ITEM(float41sign); // +123.4 -DEFINE_MENU_EDIT_ITEM(float51sign); // +1234.5 -DEFINE_MENU_EDIT_ITEM(float52sign); // +123.45 -DEFINE_MENU_EDIT_ITEM(long5); // 12345 right-justified -DEFINE_MENU_EDIT_ITEM(long5_25); // 12345 right-justified (25 increment) - -void MenuItem_bool::action(PGM_P const, bool * const ptr, screenFunc_t callback) { - *ptr ^= true; ui.refresh(); - if (callback) (*callback)(); -} - //////////////////////////////////////////// ///////////////// Menu Tree //////////////// //////////////////////////////////////////// @@ -412,7 +377,10 @@ void MenuItem_confirm::select_screen( const bool ui_selection = ui.update_selection(), got_click = ui.use_click(); if (got_click || ui.should_draw()) { draw_select_screen(yes, no, ui_selection, pref, string, suff); - if (got_click) { ui_selection ? yesFunc() : noFunc(); } + if (got_click) { + selectFunc_t callFunc = ui_selection ? yesFunc : noFunc; + if (callFunc) callFunc(); else ui.goto_previous_screen(); + } ui.defer_status_screen(); } } diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 7c3df79a19e4..d69214446481 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -43,14 +43,6 @@ typedef void (*selectFunc_t)(); void _lcd_zoffset_overlay_gfx(const float zvalue); #endif -#if HAS_BED_PROBE - #if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9 - #define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000 - #else - #define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99 - #endif -#endif - #if ENABLED(BABYSTEP_ZPROBE_OFFSET) && Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9 #define BABYSTEP_TO_STR(N) ftostr43sign(N) #elif ENABLED(BABYSTEPPING) @@ -81,13 +73,24 @@ class MenuItemBase { } }; +// STATIC_ITEM(LABEL,...) class MenuItem_static : public MenuItemBase { public: static void draw(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_DEFAULT, const char * const vstr=nullptr); }; -// CONFIRM_ITEM(LABEL,Y,N,FY,FN,V...), -// YESNO_ITEM(LABEL,FY,FN,V...) +// BACK_ITEM(LABEL) +class MenuItem_back : public MenuItemBase { + public: + FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) { + _draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]); + } + // Back Item action goes back one step in history + FORCE_INLINE static void action(PGM_P const=nullptr) { ui.go_back(); } +}; + +// CONFIRM_ITEM(LABEL,Y,N,FY,FN,...), +// YESNO_ITEM(LABEL,FY,FN,...) class MenuItem_confirm : public MenuItemBase { public: FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { @@ -123,60 +126,6 @@ class MenuItem_confirm : public MenuItemBase { } }; -// BACK_ITEM(LABEL) -class MenuItem_back : public MenuItemBase { - public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) { - _draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]); - } - // Back Item action goes back one step in history - FORCE_INLINE static void action(PGM_P const=nullptr) { ui.go_back(); } -}; - -// SUBMENU(LABEL, screen_handler) -class MenuItem_submenu : public MenuItemBase { - public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { - _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]); - } - static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); } -}; - -// Any menu item that invokes an immediate action -class MenuItem_button : public MenuItemBase { - public: - // Button-y Items are selectable lines with no other indicator - static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { - _draw(sel, row, pstr, '>', ' '); - } -}; - -// GCODES_ITEM(LABEL, GCODES) -class MenuItem_gcode : public MenuItem_button { - public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { - _draw(sel, row, pstr, '>', ' '); - } - static void action(PGM_P const, const char * const pgcode); - static inline void action(PGM_P const pstr, const uint8_t, const char * const pgcode) { action(pstr, pgcode); } -}; - -// ACTION_ITEM(LABEL, FUNC) -class MenuItem_function : public MenuItem_button { - public: - //static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); }; - static inline void action(PGM_P const, const menuAction_t func) { (*func)(); }; -}; - -#if ENABLED(SDSUPPORT) - class CardReader; - class MenuItem_sdbase { - public: - // Implemented for HD44780 and DOGM - static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir); - }; -#endif - //////////////////////////////////////////// ///////////// Edit Menu Items ////////////// //////////////////////////////////////////// @@ -233,360 +182,15 @@ class MenuEditItemBase : public MenuItemBase { static inline void draw_edit_screen(const char* const value) { draw_edit_screen(editLabel, value); } }; -// Template for specific Menu Edit Item Types -template -class TMenuEditItem : MenuEditItemBase { - private: - typedef typename NAME::type_t type_t; - static inline float scale(const float value) { return NAME::scale(value); } - static inline float unscale(const float value) { return NAME::unscale(value); } - static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); } - static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); } - public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) { - MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data))); - } - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) { - MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget())); - } - // Edit screen for this type of item - static void edit_screen() { MenuEditItemBase::edit_screen(to_string, load); } - static void action( - PGM_P const pstr, // Edit label - type_t * const ptr, // Value pointer - const type_t minValue, // Value range - const type_t maxValue, - const screenFunc_t callback=nullptr, // Value update callback - const bool live=false // Callback during editing - ) { - // Make sure minv and maxv fit within int32_t - const int32_t minv = _MAX(scale(minValue), INT32_MIN), - maxv = _MIN(scale(maxValue), INT32_MAX); - goto_edit_screen(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv, - edit_screen, callback, live); - } -}; - -// Provide a set of Edit Item Types which encompass a primitive -// type, a string function, and a scale factor for edit and display. -// These items call the Edit Item draw method passing the prepared string. -#define __DOFIXfloat PROBE() -#define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V))) -#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, V...) \ - struct MenuEditItemInfo_##NAME { \ - typedef TYPE type_t; \ - static inline float scale(const float value) { return value * (SCALE) + (V+0); } \ - static inline float unscale(const float value) { return value / (SCALE) + (V+0); } \ - static inline const char* strfunc(const float value) { return STRFUNC(_DOFIX(TYPE,value)); } \ - }; \ - typedef TMenuEditItem MenuItem_##NAME - -// NAME TYPE STRFUNC SCALE +ROUND -DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, 0.5f); // 100% right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(int3 ,int16_t ,i16tostr3rj , 1 ); // 123, -12 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(int4 ,int16_t ,i16tostr4signrj , 1 ); // 1234, -123 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(int8 ,int8_t ,i8tostr3rj , 1 ); // 123, -12 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(uint8 ,uint8_t ,ui8tostr3rj , 1 ); // 123 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3 ,uint16_t ,ui16tostr3rj , 1 ); // 123 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4 ,uint16_t ,ui16tostr4rj , 0.1f ); // 1234 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5 ,uint16_t ,ui16tostr5rj , 0.01f ); // 12345 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(float3 ,float ,ftostr3 , 1 ); // 123 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(float42_52 ,float ,ftostr42_52 , 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45 -DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); // -1.234, _1.234, +1.234 -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(float51 ,float ,ftostr51rj , 10 ); // 1234.5 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 -DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float ,ftostr52sign , 100 ); // +123.45 -DEFINE_MENU_EDIT_ITEM_TYPE(long5 ,uint32_t ,ftostr5rj , 0.01f ); // 12345 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) - -class MenuItem_bool : public MenuEditItemBase { - public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) { - MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true); - } - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) { - draw(sel, row, pstr, *data); - } - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) { - draw(sel, row, pstr, pget()); - } - static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr); -}; - -//////////////////////////////////////////// -//////////// Menu System Macros //////////// -//////////////////////////////////////////// - -/** - * Marlin's native menu screens work by running a loop from the top visible line index - * to the bottom visible line index (according to how much the screen has been scrolled). - * This complete loop is done on every menu screen call. - * - * The menu system is highly dynamic, so it doesn't know ahead of any menu loop which - * items will be visible or hidden, so menu items don't have a fixed index number. - * - * During the loop, each menu item checks to see if its line is the current one. If it is, - * then it checks to see if a click has arrived so it can run its action. If the action - * doesn't redirect to another screen then the menu item calls its draw method. - * - * Menu item add-ons can do whatever they like. - * - * This mixture of drawing and processing inside a loop has the advantage that a single - * line can be used to represent a menu item, and that is the rationale for this design. - * - * One of the pitfalls of this method is that DOGM displays call the screen handler 2x, - * 4x, or 8x per screen update to draw just one segment of the screen. As a result, any - * menu item that exists in two screen segments is drawn and processed twice per screen - * update. With each item processed 5, 10, 20, or 40 times the logic has to be simple. - * - * To avoid repetition and side-effects, function calls for testing menu item conditions - * should be done before the menu loop (START_MENU / START_SCREEN). - */ - -/** - * SCREEN_OR_MENU_LOOP generates header code for a screen or menu - * - * encoderTopLine is the top menu line to display - * _lcdLineNr is the index of the LCD line (e.g., 0-3) - * _menuLineNr is the menu item to draw and process - * _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM - */ -#define SCREEN_OR_MENU_LOOP(IS_MENU) \ - scroll_screen(IS_MENU ? 1 : LCD_HEIGHT, IS_MENU); \ - int8_t _menuLineNr = encoderTopLine, _thisItemNr = 0; \ - bool _skipStatic = IS_MENU; UNUSED(_thisItemNr); \ - for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \ - _thisItemNr = 0 - -/** - * START_SCREEN Opening code for a screen having only static items. - * Do simplified scrolling of the entire screen. - * - * START_MENU Opening code for a screen with menu items. - * Scroll as-needed to keep the selected line in view. - */ -#define START_SCREEN() SCREEN_OR_MENU_LOOP(false) -#define START_MENU() SCREEN_OR_MENU_LOOP(true) -#define NEXT_ITEM() (++_thisItemNr) -#define SKIP_ITEM() NEXT_ITEM() -#define END_SCREEN() } screen_items = _thisItemNr -#define END_MENU() END_SCREEN(); UNUSED(_skipStatic) - -#if ENABLED(ENCODER_RATE_MULTIPLIER) - #define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F) - #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) do{ if (USE_MULTIPLIER) ui.enable_encoder_multiplier(true); }while(0) - //#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value -#else - #define ENCODER_RATE_MULTIPLY(F) NOOP - #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) +#if ENABLED(SDSUPPORT) + class CardReader; + class MenuItem_sdbase { + public: + // Implemented for HD44780 and DOGM + static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir); + }; #endif -/** - * MENU_ITEM generates draw & handler code for a menu item, potentially calling: - * - * MenuItem_::draw(sel, row, label, arg3...) - * MenuItem_::action(arg3...) - * - * Examples: - * BACK_ITEM(MSG_INFO_SCREEN) - * MenuItem_back::action(plabel, ...) - * MenuItem_back::draw(sel, row, plabel, ...) - * - * ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause) - * MenuItem_function::action(plabel, lcd_sdcard_pause) - * MenuItem_function::draw(sel, row, plabel, lcd_sdcard_pause) - * - * EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999) - * MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999) - * MenuItem_int3::draw(sel, row, plabel, &feedrate_percentage, 10, 999) - */ - -#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \ - PGM_P const plabel = PLABEL; \ - if (encoderLine == _thisItemNr && ui.use_click()) { \ - _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \ - MenuItem_##TYPE::action(plabel, ##V); \ - if (ui.screen_changed) return; \ - } \ - if (ui.should_draw()) \ - MenuItem_##TYPE::draw \ - (encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \ -}while(0) - -#define _MENU_ITEM_P(TYPE, V...) do { \ - if (_menuLineNr == _thisItemNr) { \ - _skipStatic = false; \ - _MENU_INNER_P(TYPE, ##V); \ - } \ - NEXT_ITEM(); \ -}while(0) - -// Indexed items set a global index value and optional data -#define _MENU_ITEM_N_S_P(TYPE, N, S, V...) do{ \ - if (_menuLineNr == _thisItemNr) { \ - _skipStatic = false; \ - MenuItemBase::init(N, S); \ - _MENU_INNER_P(TYPE, ##V); \ - } \ - NEXT_ITEM(); \ -}while(0) - -// Indexed items set a global index value -#define _MENU_ITEM_N_P(TYPE, N, V...) do{ \ - if (_menuLineNr == _thisItemNr) { \ - _skipStatic = false; \ - MenuItemBase::itemIndex = N; \ - _MENU_INNER_P(TYPE, ##V); \ - } \ - NEXT_ITEM(); \ -}while(0) - -// Items with a unique string -#define _MENU_ITEM_S_P(TYPE, S, V...) do{ \ - if (_menuLineNr == _thisItemNr) { \ - _skipStatic = false; \ - MenuItemBase::itemString = S; \ - _MENU_INNER_P(TYPE, ##V); \ - } \ - NEXT_ITEM(); \ -}while(0) - -// STATIC_ITEM draws a styled string with no highlight. -// Parameters: label [, style [, char *value] ] - -#define STATIC_ITEM_INNER_P(PLABEL, V...) do{ \ - if (_skipStatic && encoderLine <= _thisItemNr) { \ - ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \ - ++encoderLine; \ - } \ - if (ui.should_draw()) \ - MenuItem_static::draw(_lcdLineNr, PLABEL, ##V); \ -} while(0) - -#define STATIC_ITEM_P(PLABEL, V...) do{ \ - if (_menuLineNr == _thisItemNr) \ - STATIC_ITEM_INNER_P(PLABEL, ##V); \ - NEXT_ITEM(); \ -} while(0) - -#define STATIC_ITEM_N_P(PLABEL, N, V...) do{ \ - if (_menuLineNr == _thisItemNr) { \ - MenuItemBase::init(N); \ - STATIC_ITEM_INNER_P(PLABEL, ##V); \ - } \ - NEXT_ITEM(); \ -}while(0) - -#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_P(GET_TEXT(LABEL), ##V) -#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_P(GET_TEXT(LABEL), ##V) - -#define MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, V...) _MENU_ITEM_N_S_P(TYPE, N, S, false, PLABEL, ##V) -#define MENU_ITEM_N_S(TYPE, N, S, LABEL, V...) MENU_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V) -#define MENU_ITEM_S_P(TYPE, S, PLABEL, V...) _MENU_ITEM_S_P(TYPE, S, false, PLABEL, ##V) -#define MENU_ITEM_S(TYPE, S, LABEL, V...) MENU_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V) -#define MENU_ITEM_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, false, PLABEL, ##V) -#define MENU_ITEM_N(TYPE, N, LABEL, V...) MENU_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V) -#define MENU_ITEM_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, false, PLABEL, ##V) -#define MENU_ITEM(TYPE, LABEL, V...) MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V) - -#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL) - -#define ACTION_ITEM_N_S_P(N, S, PLABEL, ACTION) MENU_ITEM_N_S_P(function, N, S, PLABEL, ACTION) -#define ACTION_ITEM_N_S(N, S, LABEL, ACTION) ACTION_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ACTION) -#define ACTION_ITEM_S_P(S, PLABEL, ACTION) MENU_ITEM_S_P(function, S, PLABEL, ACTION) -#define ACTION_ITEM_S(S, LABEL, ACTION) ACTION_ITEM_S_P(S, GET_TEXT(LABEL), ACTION) -#define ACTION_ITEM_N_P(N, PLABEL, ACTION) MENU_ITEM_N_P(function, N, PLABEL, ACTION) -#define ACTION_ITEM_N(N, LABEL, ACTION) ACTION_ITEM_N_P(N, GET_TEXT(LABEL), ACTION) -#define ACTION_ITEM_P(PLABEL, ACTION) MENU_ITEM_P(function, PLABEL, ACTION) -#define ACTION_ITEM(LABEL, ACTION) ACTION_ITEM_P(GET_TEXT(LABEL), ACTION) - -#define GCODES_ITEM_N_S_P(N, S, PLABEL, GCODES) MENU_ITEM_N_S_P(gcode, N, S, PLABEL, GCODES) -#define GCODES_ITEM_N_S(N, S, LABEL, GCODES) GCODES_ITEM_N_S_P(N, S, GET_TEXT(LABEL), GCODES) -#define GCODES_ITEM_S_P(S, PLABEL, GCODES) MENU_ITEM_S_P(gcode, S, PLABEL, GCODES) -#define GCODES_ITEM_S(S, LABEL, GCODES) GCODES_ITEM_S_P(S, GET_TEXT(LABEL), GCODES) -#define GCODES_ITEM_N_P(N, PLABEL, GCODES) MENU_ITEM_N_P(gcode, N, PLABEL, GCODES) -#define GCODES_ITEM_N(N, LABEL, GCODES) GCODES_ITEM_N_P(N, GET_TEXT(LABEL), GCODES) -#define GCODES_ITEM_P(PLABEL, GCODES) MENU_ITEM_P(gcode, PLABEL, GCODES) -#define GCODES_ITEM(LABEL, GCODES) GCODES_ITEM_P(GET_TEXT(LABEL), GCODES) - -#define SUBMENU_N_S_P(N, S, PLABEL, DEST) MENU_ITEM_N_S_P(submenu, N, S, PLABEL, DEST) -#define SUBMENU_N_S(N, S, LABEL, DEST) SUBMENU_N_S_P(N, S, GET_TEXT(LABEL), DEST) -#define SUBMENU_S_P(S, PLABEL, DEST) MENU_ITEM_S_P(submenu, S, PLABEL, DEST) -#define SUBMENU_S(S, LABEL, DEST) SUBMENU_S_P(S, GET_TEXT(LABEL), DEST) -#define SUBMENU_N_P(N, PLABEL, DEST) MENU_ITEM_N_P(submenu, N, PLABEL, DEST) -#define SUBMENU_N(N, LABEL, DEST) SUBMENU_N_P(N, GET_TEXT(LABEL), DEST) -#define SUBMENU_P(PLABEL, DEST) MENU_ITEM_P(submenu, PLABEL, DEST) -#define SUBMENU(LABEL, DEST) SUBMENU_P(GET_TEXT(LABEL), DEST) - -#define EDIT_ITEM_N_S_P(TYPE, N, S, PLABEL, V...) MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, ##V) -#define EDIT_ITEM_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_S_P(TYPE, S, PLABEL, V...) MENU_ITEM_S_P(TYPE, S, PLABEL, ##V) -#define EDIT_ITEM_S(TYPE, S, LABEL, V...) EDIT_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_N_P(TYPE, N, PLABEL, V...) MENU_ITEM_N_P(TYPE, N, PLABEL, ##V) -#define EDIT_ITEM_N(TYPE, N, LABEL, V...) EDIT_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_P(TYPE, PLABEL, V...) MENU_ITEM_P(TYPE, PLABEL, ##V) -#define EDIT_ITEM(TYPE, LABEL, V...) EDIT_ITEM_P(TYPE, GET_TEXT(LABEL), ##V) - -#define EDIT_ITEM_FAST_N_S_P(TYPE, N, S, PLABEL, V...) _MENU_ITEM_N_S_P(TYPE, N, S, true, PLABEL, ##V) -#define EDIT_ITEM_FAST_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_FAST_N_S_P(TYPE, N, S, true, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_FAST_S_P(TYPE, S, PLABEL, V...) _MENU_ITEM_S_P(TYPE, S, true, PLABEL, ##V) -#define EDIT_ITEM_FAST_S(TYPE, S, LABEL, V...) EDIT_ITEM_FAST_S_P(TYPE, S, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_FAST_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, true, PLABEL, ##V) -#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...) EDIT_ITEM_FAST_N_P(TYPE, N, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_FAST_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, true, PLABEL, ##V) -#define EDIT_ITEM_FAST(TYPE, LABEL, V...) EDIT_ITEM_FAST_P(TYPE, GET_TEXT(LABEL), ##V) - -#define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do { \ - if (encoderLine == _thisItemNr && ui.use_click()) { \ - ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \ - return; \ - } \ - if (ui.should_draw()) MenuItem_confirm::draw \ - (encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V); \ -}while(0) - -// Indexed items set a global index value and optional data -#define _CONFIRM_ITEM_P(PLABEL, V...) do { \ - if (_menuLineNr == _thisItemNr) { \ - _skipStatic = false; \ - _CONFIRM_ITEM_INNER_P(PLABEL, ##V); \ - } \ - NEXT_ITEM(); \ -}while(0) - -// Indexed items set a global index value -#define _CONFIRM_ITEM_N_S_P(N, S, V...) do{ \ - if (_menuLineNr == _thisItemNr) { \ - _skipStatic = false; \ - MenuItemBase::init(N, S); \ - _CONFIRM_ITEM_INNER_P(TYPE, ##V); \ - } \ - NEXT_ITEM(); \ -}while(0) - -// Indexed items set a global index value -#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V) - -#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) -#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V) - -#define YESNO_ITEM_P(PLABEL, V...) _CONFIRM_ITEM_P(PLABEL, ##V) -#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V) - -#define CONFIRM_ITEM_N_S_P(N,S,PLABEL,A,B,V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) -#define CONFIRM_ITEM_N_S(N,S,LABEL,V...) CONFIRM_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) -#define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...) _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) -#define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V) - -#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, ##V) -#define YESNO_ITEM_N_S(N,S,LABEL, V...) YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) -#define YESNO_ITEM_N_P(N,PLABEL, V...) _CONFIRM_ITEM_N_P(N, PLABEL, ##V) -#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V) - //////////////////////////////////////////// /////////////// Menu Screens /////////////// //////////////////////////////////////////// @@ -598,15 +202,6 @@ void menu_move(); void menu_media(); #endif -// First Fan Speed title in "Tune" and "Control>Temperature" menus -#if HAS_FAN && HAS_FAN0 - #if FAN_COUNT > 1 - #define FAN_SPEED_1_SUFFIX " 1" - #else - #define FAN_SPEED_1_SUFFIX "" - #endif -#endif - //////////////////////////////////////////// //////// Menu Item Helper Functions //////// //////////////////////////////////////////// @@ -624,10 +219,6 @@ void _lcd_draw_homing(); void _lcd_zoffset_overlay_gfx(const float zvalue); #endif -#if ENABLED(LEVEL_BED_CORNERS) - void _lcd_level_bed_corners(); -#endif - #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS)) void _lcd_toggle_bed_leveling(); #endif @@ -651,10 +242,6 @@ void _lcd_draw_homing(); #endif -#if ENABLED(POWER_LOSS_RECOVERY) - void menu_job_recovery(); -#endif - #if ENABLED(TOUCH_SCREEN_CALIBRATION) void touch_screen_calibration(); #endif diff --git a/Marlin/src/lcd/menu/menu_addon.h b/Marlin/src/lcd/menu/menu_addon.h index b6eb8e163493..73e7061bf32c 100644 --- a/Marlin/src/lcd/menu/menu_addon.h +++ b/Marlin/src/lcd/menu/menu_addon.h @@ -23,8 +23,11 @@ #include "../lcdprint.h" -#define MENU_ITEM_ADDON_START(X) do{ \ +#define _MENU_ITEM_ADDON_START(N,X) do{ \ if (ui.should_draw() && _menuLineNr == _thisItemNr - 1) { \ - SETCURSOR_X(X) + N(X) + +#define MENU_ITEM_ADDON_START(X) _MENU_ITEM_ADDON_START(SETCURSOR_X, X) +#define MENU_ITEM_ADDON_START_RJ(X) _MENU_ITEM_ADDON_START(SETCURSOR_X_RJ, X) #define MENU_ITEM_ADDON_END() } }while(0) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index e41786107228..9978bc7eabef 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU -#include "menu.h" +#include "menu_item.h" #include "../../module/planner.h" #if DISABLED(NO_VOLUMETRICS) @@ -614,7 +614,7 @@ void menu_advanced_settings() { #if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS) CONFIRM_ITEM(MSG_INIT_EEPROM, MSG_BUTTON_INIT, MSG_BUTTON_CANCEL, - ui.init_eeprom, ui.goto_previous_screen, + ui.init_eeprom, nullptr, GET_TEXT(MSG_INIT_EEPROM), (const char *)nullptr, PSTR("?") ); #endif diff --git a/Marlin/src/lcd/menu/menu_backlash.cpp b/Marlin/src/lcd/menu/menu_backlash.cpp index 2aad9a415f0c..0e1bfb591099 100644 --- a/Marlin/src/lcd/menu/menu_backlash.cpp +++ b/Marlin/src/lcd/menu/menu_backlash.cpp @@ -28,7 +28,7 @@ #if BOTH(HAS_LCD_MENU, BACKLASH_GCODE) -#include "menu.h" +#include "menu_item.h" #include "../../feature/backlash.h" diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 6dbe7c6d1801..16f9992c1852 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -28,7 +28,7 @@ #if BOTH(HAS_LCD_MENU, LEVEL_BED_CORNERS) -#include "menu.h" +#include "menu_item.h" #include "../../module/motion.h" #include "../../module/planner.h" diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 3796f44ff612..6841561c1bf8 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -28,7 +28,7 @@ #if ENABLED(LCD_BED_LEVELING) -#include "menu.h" +#include "menu_item.h" #include "../../module/planner.h" #include "../../feature/bedlevel/bedlevel.h" diff --git a/Marlin/src/lcd/menu/menu_cancelobject.cpp b/Marlin/src/lcd/menu/menu_cancelobject.cpp index 55b88c45b033..a8ced05759bd 100644 --- a/Marlin/src/lcd/menu/menu_cancelobject.cpp +++ b/Marlin/src/lcd/menu/menu_cancelobject.cpp @@ -28,7 +28,7 @@ #if BOTH(HAS_LCD_MENU, CANCEL_OBJECTS) -#include "menu.h" +#include "menu_item.h" #include "menu_addon.h" #include "../../feature/cancel_object.h" diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 26120fc5da6c..a77e9a735462 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU -#include "menu.h" +#include "menu_item.h" #if HAS_FILAMENT_SENSOR #include "../../feature/runout.h" @@ -181,7 +181,7 @@ void menu_advanced_settings(); #if ENABLED(DUAL_X_CARRIAGE) void menu_idex() { - const bool need_g28 = !(TEST(axis_known_position, Y_AXIS) && TEST(axis_known_position, Z_AXIS)); + const bool need_g28 = axes_should_home(_BV(Y_AXIS)|_BV(Z_AXIS)); START_MENU(); BACK_ITEM(MSG_CONFIGURATION); @@ -224,11 +224,11 @@ void menu_advanced_settings(); ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow); ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode); #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) - CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); - CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); + CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); + CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); ACTION_ITEM(MSG_BLTOUCH_MODE_STORE, bltouch._mode_store); - CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_5V, MSG_BLTOUCH_MODE_STORE_5V, MSG_BUTTON_CANCEL, bltouch.mode_conv_5V, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); - CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_OD, MSG_BLTOUCH_MODE_STORE_OD, MSG_BUTTON_CANCEL, bltouch.mode_conv_OD, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); + CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_5V, MSG_BLTOUCH_MODE_STORE_5V, MSG_BUTTON_CANCEL, bltouch.mode_conv_5V, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); + CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_OD, MSG_BLTOUCH_MODE_STORE_OD, MSG_BUTTON_CANCEL, bltouch.mode_conv_OD, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); ACTION_ITEM(MSG_BLTOUCH_MODE_ECHO, bltouch_report); #endif END_MENU(); diff --git a/Marlin/src/lcd/menu/menu_custom.cpp b/Marlin/src/lcd/menu/menu_custom.cpp index 729254cda4a3..7c54ec6e2616 100644 --- a/Marlin/src/lcd/menu/menu_custom.cpp +++ b/Marlin/src/lcd/menu/menu_custom.cpp @@ -28,7 +28,7 @@ #if BOTH(HAS_LCD_MENU, CUSTOM_USER_MENUS) -#include "menu.h" +#include "menu_item.h" #include "../../gcode/queue.h" #ifdef USER_SCRIPT_DONE diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index 6b99355a60c6..705ec4161120 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) -#include "menu.h" +#include "menu_item.h" #include "../../module/delta.h" #include "../../module/motion.h" diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 1b11438f4c38..5d02d674aa84 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -28,7 +28,7 @@ #if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE) -#include "menu.h" +#include "menu_item.h" #include "../../module/temperature.h" #include "../../feature/pause.h" #include "../../gcode/queue.h" @@ -138,8 +138,9 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) { SUBMENU_N_P(s, msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); }); else { ACTION_ITEM_N_P(s, msg, []{ - char cmd[13]; - sprintf_P(cmd, PSTR("M600 B0 T%i"), int(MenuItemBase::itemIndex)); + PGM_P const cmdpstr = PSTR("M600 B0 T%i"); + char cmd[strlen_P(cmdpstr) + 3 + 1]; + sprintf_P(cmd, cmdpstr, int(MenuItemBase::itemIndex)); queue.inject(cmd); }); } diff --git a/Marlin/src/lcd/menu/menu_game.cpp b/Marlin/src/lcd/menu/menu_game.cpp index 21e101404a52..fa56d7eee266 100644 --- a/Marlin/src/lcd/menu/menu_game.cpp +++ b/Marlin/src/lcd/menu/menu_game.cpp @@ -24,7 +24,7 @@ #if HAS_GAME_MENU -#include "menu.h" +#include "menu_item.h" #include "game/game.h" void menu_game() { diff --git a/Marlin/src/lcd/menu/menu_info.cpp b/Marlin/src/lcd/menu/menu_info.cpp index b94be2e53f2f..00ab9ad195e3 100644 --- a/Marlin/src/lcd/menu/menu_info.cpp +++ b/Marlin/src/lcd/menu/menu_info.cpp @@ -28,15 +28,12 @@ #if BOTH(HAS_LCD_MENU, LCD_INFO_MENU) -#include "menu.h" +#include "menu_item.h" #if HAS_GAMES #include "game/game.h" #endif -#define VALUE_ITEM(MSG, VALUE, STYL) do{ char msg[21]; strcpy_P(msg, PSTR(": ")); strcpy(msg + 2, VALUE); STATIC_ITEM(MSG, STYL, msg); }while(0) -#define VALUE_ITEM_P(MSG, PVALUE, STYL) do{ char msg[21]; strcpy_P(msg, PSTR(": ")); strcpy_P(msg + 2, PSTR(PVALUE)); STATIC_ITEM(MSG, STYL, msg); }while(0) - #if ENABLED(PRINTCOUNTER) #include "../../module/printcounter.h" @@ -52,14 +49,14 @@ char buffer[21]; START_SCREEN(); // 12345678901234567890 - VALUE_ITEM(MSG_INFO_PRINT_COUNT, i16tostr3left(stats.totalPrints), SS_LEFT); // Print Count: 999 - VALUE_ITEM(MSG_INFO_COMPLETED_PRINTS, i16tostr3left(stats.finishedPrints), SS_LEFT); // Completed : 666 + STATIC_ITEM(MSG_INFO_PRINT_COUNT, SS_LEFT, i16tostr3left(stats.totalPrints)); // Print Count: 999 + STATIC_ITEM(MSG_INFO_COMPLETED_PRINTS, SS_LEFT, i16tostr3left(stats.finishedPrints)); // Completed : 666 STATIC_ITEM(MSG_INFO_PRINT_TIME, SS_LEFT); // Total print Time: - STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.printTime).toString(buffer)); // > 99y 364d 23h 59m 59s + STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.printTime).toString(buffer)); // > 99y 364d 23h 59m 59s STATIC_ITEM(MSG_INFO_PRINT_LONGEST, SS_LEFT); // Longest job time: - STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.longestPrint).toString(buffer)); // > 99y 364d 23h 59m 59s + STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.longestPrint).toString(buffer)); // > 99y 364d 23h 59m 59s STATIC_ITEM(MSG_INFO_PRINT_FILAMENT, SS_LEFT); // Extruded total: sprintf_P(buffer, PSTR("%ld.%im") @@ -73,8 +70,8 @@ #endif #if SERVICE_INTERVAL_1 > 0 - STATIC_ITEM_P(PSTR(SERVICE_NAME_1 " "), SS_LEFT, buffer); // Service X in: - STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService1).toString(buffer)); // > 7d 12h 11m 10s + STATIC_ITEM_P(PSTR(SERVICE_NAME_1 " "), SS_LEFT, buffer); // Service X in: + STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService1).toString(buffer)); // > 7d 12h 11m 10s #endif #if SERVICE_INTERVAL_2 > 0 @@ -104,8 +101,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_0 #include "../thermistornames.h" STATIC_ITEM_P(PSTR(LCD_STR_E0 ": " THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_0_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_0_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_0_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_0_MAXTEMP), SS_LEFT); #endif #if TEMP_SENSOR_1 != 0 @@ -113,8 +110,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_1 #include "../thermistornames.h" STATIC_ITEM_P(PSTR(LCD_STR_E1 ": " THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_1_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_1_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_1_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_1_MAXTEMP), SS_LEFT); #endif #if TEMP_SENSOR_2 != 0 @@ -122,8 +119,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_2 #include "../thermistornames.h" STATIC_ITEM_P(PSTR(LCD_STR_E2 ": " THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_2_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_2_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_2_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_2_MAXTEMP), SS_LEFT); #endif #if TEMP_SENSOR_3 != 0 @@ -131,8 +128,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_3 #include "../thermistornames.h" STATIC_ITEM_P(PSTR(LCD_STR_E3 ": " THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_3_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_3_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_3_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_3_MAXTEMP), SS_LEFT); #endif #if TEMP_SENSOR_4 != 0 @@ -140,8 +137,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_4 #include "../thermistornames.h" STATIC_ITEM_P(PSTR(LCD_STR_E4 ": " THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_4_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_4_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_4_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_4_MAXTEMP), SS_LEFT); #endif #if TEMP_SENSOR_5 != 0 @@ -149,8 +146,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_5 #include "../thermistornames.h" STATIC_ITEM_P(PSTR(LCD_STR_E5 ": " THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_5_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_5_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_5_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_5_MAXTEMP), SS_LEFT); #endif #if TEMP_SENSOR_6 != 0 @@ -158,8 +155,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_6 #include "../thermistornames.h" STATIC_ITEM_P(PSTR(LCD_STR_E6 ": " THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_6_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_6_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_6_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_6_MAXTEMP), SS_LEFT); #endif #if TEMP_SENSOR_7 != 0 @@ -167,8 +164,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_7 #include "../thermistornames.h" STATIC_ITEM_P(PSTR(LCD_STR_E7 ": " THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_7_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_7_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_7_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_7_MAXTEMP), SS_LEFT); #endif #if EXTRUDERS @@ -180,8 +177,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_BED #include "../thermistornames.h" STATIC_ITEM_P(PSTR("BED:" THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(BED_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(BED_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(BED_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(BED_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_BED, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); #endif @@ -190,8 +187,8 @@ void menu_info_thermistors() { #define THERMISTOR_ID TEMP_SENSOR_CHAMBER #include "../thermistornames.h" STATIC_ITEM_P(PSTR("CHAM:" THERMISTOR_NAME), SS_INVERT); - VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(CHAMBER_MINTEMP), SS_LEFT); - VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(CHAMBER_MAXTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(CHAMBER_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(CHAMBER_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_CHAMBER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); #endif @@ -209,9 +206,9 @@ void menu_info_board() { #ifdef BOARD_WEBSITE_URL STATIC_ITEM_P(PSTR(BOARD_WEBSITE_URL), SS_LEFT); // www.my3dprinter.com #endif - VALUE_ITEM_P(MSG_INFO_BAUDRATE, STRINGIFY(BAUDRATE), SS_CENTER); // Baud: 250000 - VALUE_ITEM_P(MSG_INFO_PROTOCOL, PROTOCOL_VERSION, SS_CENTER); // Protocol: 1.0 - VALUE_ITEM_P(MSG_INFO_PSU, PSU_NAME, SS_CENTER); + PSTRING_ITEM(MSG_INFO_BAUDRATE, STRINGIFY(BAUDRATE), SS_CENTER); // Baud: 250000 + PSTRING_ITEM(MSG_INFO_PROTOCOL, PROTOCOL_VERSION, SS_CENTER); // Protocol: 1.0 + PSTRING_ITEM(MSG_INFO_PSU, PSU_NAME, SS_CENTER); END_SCREEN(); } @@ -242,7 +239,7 @@ void menu_info_board() { STATIC_ITEM_P(PSTR(STRING_DISTRIBUTION_DATE)); // YYYY-MM-DD HH:MM STATIC_ITEM_P(PSTR(MACHINE_NAME)); // My3DPrinter STATIC_ITEM_P(PSTR(WEBSITE_URL)); // www.my3dprinter.com - VALUE_ITEM_P(MSG_INFO_EXTRUDERS, STRINGIFY(EXTRUDERS), SS_CENTER); // Extruders: 2 + PSTRING_ITEM(MSG_INFO_EXTRUDERS, STRINGIFY(EXTRUDERS), SS_CENTER); // Extruders: 2 #if HAS_LEVELING STATIC_ITEM( TERN_(AUTO_BED_LEVELING_3POINT, MSG_3POINT_LEVELING) // 3-Point Leveling diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h new file mode 100644 index 000000000000..bee05141bb28 --- /dev/null +++ b/Marlin/src/lcd/menu/menu_item.h @@ -0,0 +1,454 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "menu.h" +#include "../ultralcd.h" +#include "../../gcode/queue.h" // for inject_P + +#include "../../inc/MarlinConfigPre.h" + +void lcd_move_z(); + +//////////////////////////////////////////// +///////////// Base Menu Items ////////////// +//////////////////////////////////////////// + +// SUBMENU(LABEL, screen_handler) +class MenuItem_submenu : public MenuItemBase { + public: + FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { + _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]); + } + static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); } +}; + +// Any menu item that invokes an immediate action +class MenuItem_button : public MenuItemBase { + public: + // Button-y Items are selectable lines with no other indicator + static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { + _draw(sel, row, pstr, '>', ' '); + } +}; + +// ACTION_ITEM(LABEL, FUNC) +class MenuItem_function : public MenuItem_button { + public: + //static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); }; + static inline void action(PGM_P const, const menuAction_t func) { (*func)(); }; +}; + +// GCODES_ITEM(LABEL, GCODES) +class MenuItem_gcode : public MenuItem_button { + public: + FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { + _draw(sel, row, pstr, '>', ' '); + } + static void action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pgcode); } + static inline void action(PGM_P const pstr, const uint8_t, const char * const pgcode) { action(pstr, pgcode); } +}; + +//////////////////////////////////////////// +///////////// Edit Menu Items ////////////// +//////////////////////////////////////////// + +// Template for specific Menu Edit Item Types +template +class TMenuEditItem : MenuEditItemBase { + private: + typedef typename NAME::type_t type_t; + static inline float scale(const float value) { return NAME::scale(value); } + static inline float unscale(const float value) { return NAME::unscale(value); } + static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); } + static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); } + public: + FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) { + MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data))); + } + FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) { + MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget())); + } + // Edit screen for this type of item + static void edit_screen() { MenuEditItemBase::edit_screen(to_string, load); } + static void action( + PGM_P const pstr, // Edit label + type_t * const ptr, // Value pointer + const type_t minValue, // Value range + const type_t maxValue, + const screenFunc_t callback=nullptr, // Value update callback + const bool live=false // Callback during editing + ) { + // Make sure minv and maxv fit within int32_t + const int32_t minv = _MAX(scale(minValue), INT32_MIN), + maxv = _MIN(scale(maxValue), INT32_MAX); + goto_edit_screen(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv, + edit_screen, callback, live); + } +}; + +// Provide a set of Edit Item Types which encompass a primitive +// type, a string function, and a scale factor for edit and display. +// These items call the Edit Item draw method passing the prepared string. +#define __DOFIXfloat PROBE() +#define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V))) +#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, V...) \ + struct MenuEditItemInfo_##NAME { \ + typedef TYPE type_t; \ + static inline float scale(const float value) { return value * (SCALE) + (V+0); } \ + static inline float unscale(const float value) { return value / (SCALE) + (V+0); } \ + static inline const char* strfunc(const float value) { return STRFUNC(_DOFIX(TYPE,value)); } \ + }; \ + typedef TMenuEditItem MenuItem_##NAME + +// NAME TYPE STRFUNC SCALE +ROUND +DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, 0.5f); // 100% right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(int3 ,int16_t ,i16tostr3rj , 1 ); // 123, -12 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(int4 ,int16_t ,i16tostr4signrj , 1 ); // 1234, -123 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(int8 ,int8_t ,i8tostr3rj , 1 ); // 123, -12 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(uint8 ,uint8_t ,ui8tostr3rj , 1 ); // 123 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3 ,uint16_t ,ui16tostr3rj , 1 ); // 123 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4 ,uint16_t ,ui16tostr4rj , 0.1f ); // 1234 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5 ,uint16_t ,ui16tostr5rj , 0.01f ); // 12345 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float3 ,float ,ftostr3 , 1 ); // 123 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float42_52 ,float ,ftostr42_52 , 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45 +DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); // -1.234, _1.234, +1.234 +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(float51 ,float ,ftostr51rj , 10 ); // 1234.5 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 +DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float ,ftostr52sign , 100 ); // +123.45 +DEFINE_MENU_EDIT_ITEM_TYPE(long5 ,uint32_t ,ftostr5rj , 0.01f ); // 12345 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) + +#if HAS_BED_PROBE + #if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9 + #define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000 + #else + #define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99 + #endif +#endif + +class MenuItem_bool : public MenuEditItemBase { + public: + FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) { + MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true); + } + FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) { + draw(sel, row, pstr, *data); + } + FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) { + draw(sel, row, pstr, pget()); + } + static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr) { + *ptr ^= true; ui.refresh(); + if (callbackFunc) (*callbackFunc)(); + } +}; + +/** + * //////////////////////////////////////////// + * //////////// Menu System Macros //////////// + * //////////////////////////////////////////// + * + * Marlin's native menu screens work by running a loop from the top visible line index + * to the bottom visible line index (according to how much the screen has been scrolled). + * This complete loop is done on every menu screen call. + * + * The menu system is highly dynamic, so it doesn't know ahead of any menu loop which + * items will be visible or hidden, so menu items don't have a fixed index number. + * + * During the loop, each menu item checks to see if its line is the current one. If it is, + * then it checks to see if a click has arrived so it can run its action. If the action + * doesn't redirect to another screen then the menu item calls its draw method. + * + * Menu item add-ons can do whatever they like. + * + * This mixture of drawing and processing inside a loop has the advantage that a single + * line can be used to represent a menu item, and that is the rationale for this design. + * + * One of the pitfalls of this method is that DOGM displays call the screen handler 2x, + * 4x, or 8x per screen update to draw just one segment of the screen. As a result, any + * menu item that exists in two screen segments is drawn and processed twice per screen + * update. With each item processed 5, 10, 20, or 40 times the logic has to be simple. + * + * To avoid repetition and side-effects, function calls for testing menu item conditions + * should be done before the menu loop (START_MENU / START_SCREEN). + */ + +/** + * SCREEN_OR_MENU_LOOP generates header code for a screen or menu + * + * encoderTopLine is the top menu line to display + * _lcdLineNr is the index of the LCD line (e.g., 0-3) + * _menuLineNr is the menu item to draw and process + * _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM + */ +#define SCREEN_OR_MENU_LOOP(IS_MENU) \ + scroll_screen(IS_MENU ? 1 : LCD_HEIGHT, IS_MENU); \ + int8_t _menuLineNr = encoderTopLine, _thisItemNr = 0; \ + bool _skipStatic = IS_MENU; UNUSED(_thisItemNr); \ + for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \ + _thisItemNr = 0 + +/** + * START_SCREEN Opening code for a screen having only static items. + * Do simplified scrolling of the entire screen. + * + * START_MENU Opening code for a screen with menu items. + * Scroll as-needed to keep the selected line in view. + */ +#define START_SCREEN() SCREEN_OR_MENU_LOOP(false) +#define START_MENU() SCREEN_OR_MENU_LOOP(true) +#define NEXT_ITEM() (++_thisItemNr) +#define SKIP_ITEM() NEXT_ITEM() +#define END_SCREEN() } screen_items = _thisItemNr +#define END_MENU() END_SCREEN(); UNUSED(_skipStatic) + +/** + * MENU_ITEM generates draw & handler code for a menu item, potentially calling: + * + * MenuItem_::draw(sel, row, label, arg3...) + * MenuItem_::action(arg3...) + * + * Examples: + * BACK_ITEM(MSG_INFO_SCREEN) + * MenuItem_back::action(plabel, ...) + * MenuItem_back::draw(sel, row, plabel, ...) + * + * ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause) + * MenuItem_function::action(plabel, lcd_sdcard_pause) + * MenuItem_function::draw(sel, row, plabel, lcd_sdcard_pause) + * + * EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999) + * MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999) + * MenuItem_int3::draw(sel, row, plabel, &feedrate_percentage, 10, 999) + */ + +#if ENABLED(ENCODER_RATE_MULTIPLIER) + #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) do{ if (USE_MULTIPLIER) ui.enable_encoder_multiplier(true); }while(0) +#else + #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) +#endif + +#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \ + PGM_P const plabel = PLABEL; \ + if (encoderLine == _thisItemNr && ui.use_click()) { \ + _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \ + MenuItem_##TYPE::action(plabel, ##V); \ + if (ui.screen_changed) return; \ + } \ + if (ui.should_draw()) \ + MenuItem_##TYPE::draw \ + (encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \ +}while(0) + +#define _MENU_ITEM_P(TYPE, V...) do { \ + if (_menuLineNr == _thisItemNr) { \ + _skipStatic = false; \ + _MENU_INNER_P(TYPE, ##V); \ + } \ + NEXT_ITEM(); \ +}while(0) + +// Indexed items set a global index value and optional data +#define _MENU_ITEM_N_S_P(TYPE, N, S, V...) do{ \ + if (_menuLineNr == _thisItemNr) { \ + _skipStatic = false; \ + MenuItemBase::init(N, S); \ + _MENU_INNER_P(TYPE, ##V); \ + } \ + NEXT_ITEM(); \ +}while(0) + +// Indexed items set a global index value +#define _MENU_ITEM_N_P(TYPE, N, V...) do{ \ + if (_menuLineNr == _thisItemNr) { \ + _skipStatic = false; \ + MenuItemBase::itemIndex = N; \ + _MENU_INNER_P(TYPE, ##V); \ + } \ + NEXT_ITEM(); \ +}while(0) + +// Items with a unique string +#define _MENU_ITEM_S_P(TYPE, S, V...) do{ \ + if (_menuLineNr == _thisItemNr) { \ + _skipStatic = false; \ + MenuItemBase::itemString = S; \ + _MENU_INNER_P(TYPE, ##V); \ + } \ + NEXT_ITEM(); \ +}while(0) + +// STATIC_ITEM draws a styled string with no highlight. +// Parameters: label [, style [, char *value] ] + +#define STATIC_ITEM_INNER_P(PLABEL, V...) do{ \ + if (_skipStatic && encoderLine <= _thisItemNr) { \ + ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \ + ++encoderLine; \ + } \ + if (ui.should_draw()) \ + MenuItem_static::draw(_lcdLineNr, PLABEL, ##V); \ +} while(0) + +#define STATIC_ITEM_P(PLABEL, V...) do{ \ + if (_menuLineNr == _thisItemNr) \ + STATIC_ITEM_INNER_P(PLABEL, ##V); \ + NEXT_ITEM(); \ +} while(0) + +#define STATIC_ITEM_N_P(PLABEL, N, V...) do{ \ + if (_menuLineNr == _thisItemNr) { \ + MenuItemBase::init(N); \ + STATIC_ITEM_INNER_P(PLABEL, ##V); \ + } \ + NEXT_ITEM(); \ +}while(0) + +// PSTRING_ITEM is like STATIC_ITEM but it takes +// two PSTRs with the style as the last parameter. + +#define PSTRING_ITEM_P(PLABEL, PVAL, STYL) do{ \ + constexpr int m = 20; \ + char msg[m+1]; \ + msg[0] = ':'; msg[1] = ' '; \ + strncpy_P(msg+2, PSTR(PVAL), m-2); \ + if (msg[m-1] & 0x80) msg[m-1] = '\0'; \ + STATIC_ITEM_P(PLABEL, STYL, msg); \ +}while(0) + +#define PSTRING_ITEM(LABEL, V...) PSTRING_ITEM_P(GET_TEXT(LABEL), ##V) + +#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_P(GET_TEXT(LABEL), ##V) +#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_P(GET_TEXT(LABEL), ##V) + +#define MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, V...) _MENU_ITEM_N_S_P(TYPE, N, S, false, PLABEL, ##V) +#define MENU_ITEM_N_S(TYPE, N, S, LABEL, V...) MENU_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V) +#define MENU_ITEM_S_P(TYPE, S, PLABEL, V...) _MENU_ITEM_S_P(TYPE, S, false, PLABEL, ##V) +#define MENU_ITEM_S(TYPE, S, LABEL, V...) MENU_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V) +#define MENU_ITEM_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, false, PLABEL, ##V) +#define MENU_ITEM_N(TYPE, N, LABEL, V...) MENU_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V) +#define MENU_ITEM_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, false, PLABEL, ##V) +#define MENU_ITEM(TYPE, LABEL, V...) MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V) + +#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL) + +#define ACTION_ITEM_N_S_P(N, S, PLABEL, ACTION) MENU_ITEM_N_S_P(function, N, S, PLABEL, ACTION) +#define ACTION_ITEM_N_S(N, S, LABEL, ACTION) ACTION_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ACTION) +#define ACTION_ITEM_S_P(S, PLABEL, ACTION) MENU_ITEM_S_P(function, S, PLABEL, ACTION) +#define ACTION_ITEM_S(S, LABEL, ACTION) ACTION_ITEM_S_P(S, GET_TEXT(LABEL), ACTION) +#define ACTION_ITEM_N_P(N, PLABEL, ACTION) MENU_ITEM_N_P(function, N, PLABEL, ACTION) +#define ACTION_ITEM_N(N, LABEL, ACTION) ACTION_ITEM_N_P(N, GET_TEXT(LABEL), ACTION) +#define ACTION_ITEM_P(PLABEL, ACTION) MENU_ITEM_P(function, PLABEL, ACTION) +#define ACTION_ITEM(LABEL, ACTION) ACTION_ITEM_P(GET_TEXT(LABEL), ACTION) + +#define GCODES_ITEM_N_S_P(N, S, PLABEL, GCODES) MENU_ITEM_N_S_P(gcode, N, S, PLABEL, GCODES) +#define GCODES_ITEM_N_S(N, S, LABEL, GCODES) GCODES_ITEM_N_S_P(N, S, GET_TEXT(LABEL), GCODES) +#define GCODES_ITEM_S_P(S, PLABEL, GCODES) MENU_ITEM_S_P(gcode, S, PLABEL, GCODES) +#define GCODES_ITEM_S(S, LABEL, GCODES) GCODES_ITEM_S_P(S, GET_TEXT(LABEL), GCODES) +#define GCODES_ITEM_N_P(N, PLABEL, GCODES) MENU_ITEM_N_P(gcode, N, PLABEL, GCODES) +#define GCODES_ITEM_N(N, LABEL, GCODES) GCODES_ITEM_N_P(N, GET_TEXT(LABEL), GCODES) +#define GCODES_ITEM_P(PLABEL, GCODES) MENU_ITEM_P(gcode, PLABEL, GCODES) +#define GCODES_ITEM(LABEL, GCODES) GCODES_ITEM_P(GET_TEXT(LABEL), GCODES) + +#define SUBMENU_N_S_P(N, S, PLABEL, DEST) MENU_ITEM_N_S_P(submenu, N, S, PLABEL, DEST) +#define SUBMENU_N_S(N, S, LABEL, DEST) SUBMENU_N_S_P(N, S, GET_TEXT(LABEL), DEST) +#define SUBMENU_S_P(S, PLABEL, DEST) MENU_ITEM_S_P(submenu, S, PLABEL, DEST) +#define SUBMENU_S(S, LABEL, DEST) SUBMENU_S_P(S, GET_TEXT(LABEL), DEST) +#define SUBMENU_N_P(N, PLABEL, DEST) MENU_ITEM_N_P(submenu, N, PLABEL, DEST) +#define SUBMENU_N(N, LABEL, DEST) SUBMENU_N_P(N, GET_TEXT(LABEL), DEST) +#define SUBMENU_P(PLABEL, DEST) MENU_ITEM_P(submenu, PLABEL, DEST) +#define SUBMENU(LABEL, DEST) SUBMENU_P(GET_TEXT(LABEL), DEST) + +#define EDIT_ITEM_N_S_P(TYPE, N, S, PLABEL, V...) MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, ##V) +#define EDIT_ITEM_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V) +#define EDIT_ITEM_S_P(TYPE, S, PLABEL, V...) MENU_ITEM_S_P(TYPE, S, PLABEL, ##V) +#define EDIT_ITEM_S(TYPE, S, LABEL, V...) EDIT_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V) +#define EDIT_ITEM_N_P(TYPE, N, PLABEL, V...) MENU_ITEM_N_P(TYPE, N, PLABEL, ##V) +#define EDIT_ITEM_N(TYPE, N, LABEL, V...) EDIT_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V) +#define EDIT_ITEM_P(TYPE, PLABEL, V...) MENU_ITEM_P(TYPE, PLABEL, ##V) +#define EDIT_ITEM(TYPE, LABEL, V...) EDIT_ITEM_P(TYPE, GET_TEXT(LABEL), ##V) + +#define EDIT_ITEM_FAST_N_S_P(TYPE, N, S, PLABEL, V...) _MENU_ITEM_N_S_P(TYPE, N, S, true, PLABEL, ##V) +#define EDIT_ITEM_FAST_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_FAST_N_S_P(TYPE, N, S, true, GET_TEXT(LABEL), ##V) +#define EDIT_ITEM_FAST_S_P(TYPE, S, PLABEL, V...) _MENU_ITEM_S_P(TYPE, S, true, PLABEL, ##V) +#define EDIT_ITEM_FAST_S(TYPE, S, LABEL, V...) EDIT_ITEM_FAST_S_P(TYPE, S, GET_TEXT(LABEL), ##V) +#define EDIT_ITEM_FAST_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, true, PLABEL, ##V) +#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...) EDIT_ITEM_FAST_N_P(TYPE, N, GET_TEXT(LABEL), ##V) +#define EDIT_ITEM_FAST_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, true, PLABEL, ##V) +#define EDIT_ITEM_FAST(TYPE, LABEL, V...) EDIT_ITEM_FAST_P(TYPE, GET_TEXT(LABEL), ##V) + +#define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do { \ + if (encoderLine == _thisItemNr && ui.use_click()) { \ + ui.save_previous_screen(); \ + ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \ + return; \ + } \ + if (ui.should_draw()) MenuItem_confirm::draw \ + (encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V); \ +}while(0) + +// Indexed items set a global index value and optional data +#define _CONFIRM_ITEM_P(PLABEL, V...) do { \ + if (_menuLineNr == _thisItemNr) { \ + _skipStatic = false; \ + _CONFIRM_ITEM_INNER_P(PLABEL, ##V); \ + } \ + NEXT_ITEM(); \ +}while(0) + +// Indexed items set a global index value +#define _CONFIRM_ITEM_N_S_P(N, S, V...) do{ \ + if (_menuLineNr == _thisItemNr) { \ + _skipStatic = false; \ + MenuItemBase::init(N, S); \ + _CONFIRM_ITEM_INNER_P(TYPE, ##V); \ + } \ + NEXT_ITEM(); \ +}while(0) + +// Indexed items set a global index value +#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V) + +#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) +#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V) + +#define YESNO_ITEM_P(PLABEL, V...) _CONFIRM_ITEM_P(PLABEL, ##V) +#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V) + +#define CONFIRM_ITEM_N_S_P(N,S,PLABEL,A,B,V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) +#define CONFIRM_ITEM_N_S(N,S,LABEL,V...) CONFIRM_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) +#define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...) _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) +#define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V) + +#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, ##V) +#define YESNO_ITEM_N_S(N,S,LABEL, V...) YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) +#define YESNO_ITEM_N_P(N,PLABEL, V...) _CONFIRM_ITEM_N_P(N, PLABEL, ##V) +#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V) + +#if ENABLED(LEVEL_BED_CORNERS) + void _lcd_level_bed_corners(); +#endif diff --git a/Marlin/src/lcd/menu/menu_job_recovery.cpp b/Marlin/src/lcd/menu/menu_job_recovery.cpp index a2743ef58b5d..7cd2949d627c 100644 --- a/Marlin/src/lcd/menu/menu_job_recovery.cpp +++ b/Marlin/src/lcd/menu/menu_job_recovery.cpp @@ -28,7 +28,7 @@ #if BOTH(HAS_LCD_MENU, POWER_LOSS_RECOVERY) -#include "menu.h" +#include "menu_item.h" #include "../../gcode/queue.h" #include "../../sd/cardreader.h" #include "../../feature/powerloss.h" diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index b117e0baa1dd..386a4d799aa2 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -28,24 +28,25 @@ #if HAS_LCD_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU) -#include "menu.h" +#include "menu_item.h" #if ENABLED(LED_CONTROL_MENU) #include "../../feature/leds/leds.h" #if ENABLED(LED_COLOR_PRESETS) + void menu_led_presets() { START_MENU(); #if LCD_HEIGHT > 2 STATIC_ITEM(MSG_LED_PRESETS, SS_DEFAULT|SS_INVERT); #endif BACK_ITEM(MSG_LED_CONTROL); - ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white); - ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red); + ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white); + ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red); ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds.set_orange); - ACTION_ITEM(MSG_SET_LEDS_YELLOW,leds.set_yellow); - ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green); - ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue); + ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow); + ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green); + ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue); ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo); ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds.set_violet); END_MENU(); @@ -53,9 +54,33 @@ #endif + #if ENABLED(NEO2_COLOR_PRESETS) + + void menu_leds2_presets() { + START_MENU(); + #if LCD_HEIGHT > 2 + STATIC_ITEM(MSG_NEO2_PRESETS, SS_DEFAULT|SS_INVERT); + #endif + BACK_ITEM(MSG_LED_CONTROL); + ACTION_ITEM(MSG_SET_LEDS_WHITE, leds2.set_white); + ACTION_ITEM(MSG_SET_LEDS_RED, leds2.set_red); + ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds2.set_orange); + ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds2.set_yellow); + ACTION_ITEM(MSG_SET_LEDS_GREEN, leds2.set_green); + ACTION_ITEM(MSG_SET_LEDS_BLUE, leds2.set_blue); + ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds2.set_indigo); + ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds2.set_violet); + END_MENU(); + } + + #endif + void menu_led_custom() { START_MENU(); BACK_ITEM(MSG_LED_CONTROL); + #if ENABLED(NEOPIXEL2_SEPARATE) + STATIC_ITEM_N(MSG_LED_CHANNEL_N, 1, SS_DEFAULT|SS_INVERT); + #endif EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true); @@ -65,6 +90,14 @@ EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true); #endif #endif + #if ENABLED(NEOPIXEL2_SEPARATE) + STATIC_ITEM_N(MSG_LED_CHANNEL_N, 2, SS_DEFAULT|SS_INVERT); + EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true); + #endif END_MENU(); } #endif @@ -83,20 +116,28 @@ #endif #endif - - void menu_led() { START_MENU(); BACK_ITEM(MSG_MAIN); + #if ENABLED(LED_CONTROL_MENU) - bool led_on = leds.lights_on; - EDIT_ITEM(bool, MSG_LEDS, &led_on, leds.toggle); + editable.state = leds.lights_on; + EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle); ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default); + #if ENABLED(NEOPIXEL2_SEPARATE) + editable.state = leds2.lights_on; + EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle); + ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds2.set_default); + #endif #if ENABLED(LED_COLOR_PRESETS) SUBMENU(MSG_LED_PRESETS, menu_led_presets); #endif + #if ENABLED(NEO2_COLOR_PRESETS) + SUBMENU(MSG_NEO2_PRESETS, menu_leds2_presets); + #endif SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom); #endif + // // Set Case light on/off/brightness // diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 9a1d2ece68e8..8908f49fb22f 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU -#include "menu.h" +#include "menu_item.h" #include "../../module/temperature.h" #include "../../gcode/queue.h" #include "../../module/printcounter.h" @@ -138,13 +138,11 @@ void menu_main() { if (card_detected) { if (!card_open) { SUBMENU(MSG_MEDIA_MENU, TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media)); - MENU_ITEM(gcode, - #if PIN_EXISTS(SD_DETECT) - MSG_CHANGE_MEDIA, M21_STR - #else - MSG_RELEASE_MEDIA, PSTR("M22") - #endif - ); + #if PIN_EXISTS(SD_DETECT) + GCODES_ITEM(MSG_CHANGE_MEDIA, M21_STR); + #else + GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22")); + #endif } } else { @@ -172,7 +170,7 @@ void menu_main() { #endif #if HAS_POWER_MONITOR - MENU_ITEM(submenu, MSG_POWER_MONITOR, menu_power_monitor); + SUBMENU(MSG_POWER_MONITOR, menu_power_monitor); #endif #if ENABLED(MIXING_EXTRUDER) @@ -237,13 +235,11 @@ void menu_main() { if (card_detected) { if (!card_open) { - MENU_ITEM(gcode, - #if PIN_EXISTS(SD_DETECT) - MSG_CHANGE_MEDIA, M21_STR - #else - MSG_RELEASE_MEDIA, PSTR("M22") - #endif - ); + #if PIN_EXISTS(SD_DETECT) + GCODES_ITEM(MSG_CHANGE_MEDIA, M21_STR); + #else + GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22")); + #endif SUBMENU(MSG_MEDIA_MENU, TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media)); } } diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index c22314fa9f0a..3c0c6532f034 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -28,7 +28,7 @@ #if BOTH(HAS_LCD_MENU, SDSUPPORT) -#include "menu.h" +#include "menu_item.h" #include "../../sd/cardreader.h" void lcd_sd_updir() { diff --git a/Marlin/src/lcd/menu/menu_mixer.cpp b/Marlin/src/lcd/menu/menu_mixer.cpp index 3f57d257ad49..8010239336ab 100644 --- a/Marlin/src/lcd/menu/menu_mixer.cpp +++ b/Marlin/src/lcd/menu/menu_mixer.cpp @@ -28,7 +28,7 @@ #if BOTH(HAS_LCD_MENU, MIXING_EXTRUDER) -#include "menu.h" +#include "menu_item.h" #include "menu_addon.h" #include "../../feature/mixing.h" @@ -37,52 +37,33 @@ #if ENABLED(GRADIENT_MIX) - void lcd_mixer_gradient_z_start_edit() { + void _lcd_mixer_gradient_z_edit(const bool isend) { ui.defer_status_screen(); ENCODER_RATE_MULTIPLY(true); - if (ui.encoderPosition != 0) { - mixer.gradient.start_z += float(int32_t(ui.encoderPosition)) * 0.1; - ui.encoderPosition = 0; - NOLESS(mixer.gradient.start_z, 0); - NOMORE(mixer.gradient.start_z, Z_MAX_POS); - } - if (ui.should_draw()) { - char tmp[21]; - strcpy_P(tmp, GET_TEXT(MSG_START_Z)); - sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10); - SETCURSOR(2, (LCD_HEIGHT - 1) / 2); - lcd_put_u8str(tmp); - } - if (ui.lcd_clicked) { - if (mixer.gradient.start_z > mixer.gradient.end_z) - mixer.gradient.end_z = mixer.gradient.start_z; - mixer.refresh_gradient(); - ui.goto_previous_screen(); - } - } + float &zvar = isend ? mixer.gradient.end_z : mixer.gradient.start_z; - void lcd_mixer_gradient_z_end_edit() { - ui.defer_status_screen(); - ENCODER_RATE_MULTIPLY(true); - if (ui.encoderPosition != 0) { - mixer.gradient.end_z += float(int32_t(ui.encoderPosition)) * 0.1; + if (ui.encoderPosition) { + zvar += float(int32_t(ui.encoderPosition)) * 0.1; ui.encoderPosition = 0; - NOLESS(mixer.gradient.end_z, 0); - NOMORE(mixer.gradient.end_z, Z_MAX_POS); + NOLESS(zvar, 0); + NOMORE(zvar, Z_MAX_POS); } if (ui.should_draw()) { - char tmp[21]; - strcpy_P(tmp, GET_TEXT(MSG_END_Z)); - sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10); - SETCURSOR(2, (LCD_HEIGHT - 1) / 2); + char tmp[16]; + SETCURSOR(1, (LCD_HEIGHT - 1) / 2); + lcd_put_u8str_P(isend ? GET_TEXT(MSG_END_Z) : GET_TEXT(MSG_START_Z)); + sprintf_P(tmp, PSTR("%4d.%d mm"), int(zvar), int(zvar * 10) % 10); + SETCURSOR_RJ(9, (LCD_HEIGHT - 1) / 2); lcd_put_u8str(tmp); } if (ui.lcd_clicked) { - if (mixer.gradient.end_z < mixer.gradient.start_z) - mixer.gradient.start_z = mixer.gradient.end_z; + if (isend && zvar < mixer.gradient.start_z) + mixer.gradient.start_z = zvar; + else if (!isend && zvar > mixer.gradient.end_z) + mixer.gradient.end_z = zvar; mixer.refresh_gradient(); ui.goto_previous_screen(); } @@ -96,19 +77,21 @@ EDIT_ITEM(int8, MSG_END_VTOOL, &mixer.gradient.end_vtool, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient); #if ENABLED(GRADIENT_VTOOL) - EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient); + EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, -1, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient); #endif char tmp[18]; - SUBMENU(MSG_START_Z, lcd_mixer_gradient_z_start_edit); - MENU_ITEM_ADDON_START(9); + PGM_P const slabel = GET_TEXT(MSG_START_Z); + SUBMENU_P(slabel, []{ _lcd_mixer_gradient_z_edit(false); }); + MENU_ITEM_ADDON_START_RJ(11); sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10); lcd_put_u8str(tmp); MENU_ITEM_ADDON_END(); - SUBMENU(MSG_END_Z, lcd_mixer_gradient_z_end_edit); - MENU_ITEM_ADDON_START(9); + PGM_P const elabel = GET_TEXT(MSG_END_Z); + SUBMENU_P(elabel, []{ _lcd_mixer_gradient_z_edit(true); }); + MENU_ITEM_ADDON_START_RJ(11); sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10); lcd_put_u8str(tmp); MENU_ITEM_ADDON_END(); @@ -125,7 +108,7 @@ static uint8_t v_index; char tmp[20]; // "100%_100%" sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1])); SETCURSOR(2, y); lcd_put_u8str_P(GET_TEXT(MSG_MIX)); - SETCURSOR_RJ(9, y); lcd_put_u8str(tmp); + SETCURSOR_RJ(10, y); lcd_put_u8str(tmp); } #endif @@ -157,7 +140,7 @@ void lcd_mixer_mix_edit() { #if HAS_DUAL_MIXING && !CHANNEL_MIX_EDITING // Adjust 2-channel mix from the encoder - if (ui.encoderPosition != 0) { + if (ui.encoderPosition) { mixer.mix[0] += int32_t(ui.encoderPosition); ui.encoderPosition = 0; if (mixer.mix[0] < 0) mixer.mix[0] += 101; @@ -241,9 +224,9 @@ void menu_mixer() { #if HAS_DUAL_MIXING { - char tmp[10]; + char tmp[11]; SUBMENU(MSG_MIX, lcd_mixer_mix_edit); - MENU_ITEM_ADDON_START(10); + MENU_ITEM_ADDON_START_RJ(9); mixer.update_mix_from_vtool(); sprintf_P(tmp, PSTR("%3d;%3d%%"), int(mixer.mix[0]), int(mixer.mix[1])); lcd_put_u8str(tmp); @@ -264,7 +247,7 @@ void menu_mixer() { LCD_MESSAGEPGM(MSG_VTOOLS_RESET); ui.return_to_status(); }, - ui.goto_previous_screen, + nullptr, GET_TEXT(MSG_RESET_VTOOLS), (const char *)nullptr, PSTR("?") ); @@ -272,7 +255,7 @@ void menu_mixer() { { char tmp[13]; SUBMENU(MSG_GRADIENT, lcd_mixer_edit_gradient_menu); - MENU_ITEM_ADDON_START(10); + MENU_ITEM_ADDON_START_RJ(9); sprintf_P(tmp, PSTR("T%i->T%i"), mixer.gradient.start_vtool, mixer.gradient.end_vtool); lcd_put_u8str(tmp); MENU_ITEM_ADDON_END(); diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index 304e95887784..0a63d90c6370 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -26,7 +26,7 @@ #include "../../feature/mmu2/mmu2.h" #include "menu_mmu2.h" -#include "menu.h" +#include "menu_item.h" uint8_t currentTool; bool mmuMenuWait; diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 622cd091c061..77ab643cd652 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU -#include "menu.h" +#include "menu_item.h" #include "menu_addon.h" #include "../../module/motion.h" @@ -195,11 +195,12 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move( 1); }); SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); }); if (axis == Z_AXIS && (SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) { - char tmp[20], numstr[10]; // Determine digits needed right of decimal - const uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 : - !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 100 - int((SHORT_MANUAL_Z_MOVE) * 100)) ? 3 : 2; - sprintf_P(tmp, GET_TEXT(MSG_MOVE_Z_DIST), dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr)); + constexpr uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 : + !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 100 - int((SHORT_MANUAL_Z_MOVE) * 100)) ? 3 : 2; + PGM_P const label = GET_TEXT(MSG_MOVE_Z_DIST); + char tmp[strlen_P(label) + 10 + 1], numstr[10]; + sprintf_P(tmp, label, dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr)); #if DISABLED(HAS_GRAPHICAL_TFT) extern const char NUL_STR[]; @@ -386,7 +387,7 @@ void menu_motion() { #endif #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) - GCODES_ITEM(MSG_M48_TEST, PSTR("G28\nM48 P10")); + GCODES_ITEM(MSG_M48_TEST, PSTR("G28 O\nM48 P10")); #endif // diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index f8e0b567218c..c3924b568699 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -30,7 +30,7 @@ #include "../../feature/password/password.h" -#include "menu.h" +#include "menu_item.h" #include "menu_addon.h" void menu_advanced_settings(); diff --git a/Marlin/src/lcd/menu/menu_power_monitor.cpp b/Marlin/src/lcd/menu/menu_power_monitor.cpp index bacf7f379f30..e88bdb28d8c8 100644 --- a/Marlin/src/lcd/menu/menu_power_monitor.cpp +++ b/Marlin/src/lcd/menu/menu_power_monitor.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU && HAS_POWER_MONITOR -#include "menu.h" +#include "menu_item.h" #include "../../feature/power_monitor.h" void menu_power_monitor() { diff --git a/Marlin/src/lcd/menu/menu_spindle_laser.cpp b/Marlin/src/lcd/menu/menu_spindle_laser.cpp index 00a98d12444a..04b999eaf620 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU && HAS_CUTTER - #include "menu.h" + #include "menu_item.h" #include "../../feature/spindle_laser.h" diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 4be98f132d1b..141a8138b595 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU && HAS_TEMPERATURE -#include "menu.h" +#include "menu_item.h" #include "../../module/temperature.h" #if FAN_COUNT > 1 || ENABLED(SINGLENOZZLE) diff --git a/Marlin/src/lcd/menu/menu_tmc.cpp b/Marlin/src/lcd/menu/menu_tmc.cpp index f2f26886fc87..402ee41a1b45 100644 --- a/Marlin/src/lcd/menu/menu_tmc.cpp +++ b/Marlin/src/lcd/menu/menu_tmc.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU && HAS_TRINAMIC_CONFIG -#include "menu.h" +#include "menu_item.h" #include "../../module/stepper/indirection.h" #include "../../feature/tmc_util.h" diff --git a/Marlin/src/lcd/menu/menu_touch_screen.cpp b/Marlin/src/lcd/menu/menu_touch_screen.cpp index 71fb7b75568e..96eae2298e6c 100644 --- a/Marlin/src/lcd/menu/menu_touch_screen.cpp +++ b/Marlin/src/lcd/menu/menu_touch_screen.cpp @@ -24,7 +24,7 @@ #if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) -#include "menu.h" +#include "menu_item.h" #include "../ultralcd.h" void touch_screen_calibration() { diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 2d40318156e4..c02906f7f946 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -28,7 +28,7 @@ #if HAS_LCD_MENU -#include "menu.h" +#include "menu_item.h" #include "../../module/motion.h" #include "../../module/planner.h" #include "../../module/temperature.h" diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index d1c1e6dd0a5f..d034de095215 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -28,7 +28,7 @@ #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL) -#include "menu.h" +#include "menu_item.h" #include "../../gcode/gcode.h" #include "../../gcode/queue.h" #include "../../module/motion.h" diff --git a/Marlin/src/lcd/scaled_tft.h b/Marlin/src/lcd/scaled_tft.h index f22bdf696ad9..be846f70a9dd 100644 --- a/Marlin/src/lcd/scaled_tft.h +++ b/Marlin/src/lcd/scaled_tft.h @@ -23,28 +23,28 @@ #include "../inc/MarlinConfig.h" -#ifndef FSMC_UPSCALE - #define FSMC_UPSCALE 2 +#ifndef GRAPHICAL_TFT_UPSCALE + #define GRAPHICAL_TFT_UPSCALE 2 #endif -#ifndef LCD_FULL_PIXEL_WIDTH - #if FSMC_UPSCALE == 3 - #define LCD_FULL_PIXEL_WIDTH 480 +#ifndef TFT_WIDTH + #if GRAPHICAL_TFT_UPSCALE == 3 + #define TFT_WIDTH 480 #else - #define LCD_FULL_PIXEL_WIDTH 320 + #define TFT_WIDTH 320 #endif #endif -#ifndef LCD_FULL_PIXEL_HEIGHT - #if FSMC_UPSCALE == 3 - #define LCD_FULL_PIXEL_HEIGHT 320 +#ifndef TFT_HEIGHT + #if GRAPHICAL_TFT_UPSCALE == 3 + #define TFT_HEIGHT 320 #else - #define LCD_FULL_PIXEL_HEIGHT 240 + #define TFT_HEIGHT 240 #endif #endif -#ifndef LCD_PIXEL_OFFSET_X - #define LCD_PIXEL_OFFSET_X 48 +#ifndef TFT_PIXEL_OFFSET_X + #define TFT_PIXEL_OFFSET_X 48 #endif -#ifndef LCD_PIXEL_OFFSET_Y - #define LCD_PIXEL_OFFSET_Y 48 +#ifndef TFT_PIXEL_OFFSET_Y + #define TFT_PIXEL_OFFSET_Y 48 #endif diff --git a/Marlin/src/lcd/tft/st7789v.h b/Marlin/src/lcd/tft/st7789v.h index 6ed7c0ce6604..f6e937c2c2b3 100644 --- a/Marlin/src/lcd/tft/st7789v.h +++ b/Marlin/src/lcd/tft/st7789v.h @@ -39,7 +39,9 @@ #define ST7789V_ORIENTATION_DOWN 0 // 240x320 ; Cable on the lower side //#define ST7789V_COLOR_BGR -#define ST7789V_ORIENTATION ST7789V_ORIENTATION_LEFT +#ifndef ST7789V_ORIENTATION + #define ST7789V_ORIENTATION ST7789V_ORIENTATION_LEFT +#endif #define ST7789V_MADCTL_DATA (ST7789V_ORIENTATION | TERN(ST7789V_COLOR_BGR, ST7789V_MADCTL_BGR, ST7789V_MADCTL_RGB)) #define ST7789V_NOP 0x00 // No Operation diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 69f4ada86f27..d2b860ab155f 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -23,8 +23,9 @@ #include "touch.h" -#include "../ultralcd.h" -#include "../menu/menu.h" +#include "../ultralcd.h" // for ui methods +#include "../menu/menu_item.h" // for touch_screen_calibration + #include "../../module/temperature.h" #include "../../module/planner.h" diff --git a/Marlin/src/lcd/touch/touch_buttons.cpp b/Marlin/src/lcd/touch/touch_buttons.cpp new file mode 100644 index 000000000000..8eae73df1194 --- /dev/null +++ b/Marlin/src/lcd/touch/touch_buttons.cpp @@ -0,0 +1,112 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../inc/MarlinConfig.h" + +#if HAS_TOUCH_XPT2046 + +#include "touch_buttons.h" +#include "../scaled_tft.h" + +#include HAL_PATH(../../HAL, tft/xpt2046.h) +XPT2046 touchIO; + +#include "../../lcd/ultralcd.h" // For EN_C bit mask + +/** + * Draw and Touch processing + * + * LCD_PIXEL_WIDTH/HEIGHT (128x64) is the (emulated DOGM) Pixel Drawing resolution. + * TOUCH_SENSOR_WIDTH/HEIGHT (320x240) is the Touch Area resolution. + * TFT_WIDTH/HEIGHT (320x240 or 480x320) is the Actual (FSMC) Display resolution. + * + * - All native (u8g) drawing is done in LCD_PIXEL_* (128x64) + * - The DOGM pixels are is upscaled 2-3x (as needed) for display. + * - Touch coordinates use TOUCH_SENSOR_* resolution and are converted to + * click and scroll-wheel events (emulating of a common DOGM display). + * + * TOUCH_SCREEN resolution exists to fit our calibration values. The original touch code was made + * and originally calibrated for 320x240. If you decide to change the resolution of the touch code, + * new calibration values will be needed. + * + * The Marlin menus are drawn scaled in the upper region of the screen. The bottom region (in a + * fixed location in TOUCH_SCREEN* coordinate space) is used for 4 general-purpose buttons to + * navigate and select menu items. Both regions are touchable. + * + * The Marlin screen touchable area starts at TFT_PIXEL_OFFSET_X/Y (translated to SCREEN_PCT_LEFT/TOP) + * and spans LCD_PIXEL_WIDTH/HEIGHT (scaled to SCREEN_PCT_WIDTH/HEIGHT). + */ + +// Touch sensor resolution independent of display resolution +#define TOUCH_SENSOR_WIDTH 320 +#define TOUCH_SENSOR_HEIGHT 240 + +#define SCREEN_PCT_WIDE(X) ((X) * (TOUCH_SENSOR_WIDTH) / (TFT_WIDTH)) +#define SCREEN_PCT_HIGH(Y) ((Y) * (TOUCH_SENSOR_HEIGHT) / (TFT_HEIGHT)) + +#define SCREEN_PCT_LEFT SCREEN_PCT_WIDE(TFT_PIXEL_OFFSET_X) +#define SCREEN_PCT_TOP SCREEN_PCT_HIGH(TFT_PIXEL_OFFSET_Y) +#define SCREEN_PCT_WIDTH SCREEN_PCT_WIDE((GRAPHICAL_TFT_UPSCALE) * (LCD_PIXEL_WIDTH)) +#define SCREEN_PCT_HEIGHT SCREEN_PCT_HIGH((GRAPHICAL_TFT_UPSCALE) * (LCD_PIXEL_HEIGHT)) + +// Coordinates in terms of 240-unit-tall touch area +#define BUTTON_AREA_TOP 175 +#define BUTTON_AREA_BOT 234 + +TouchButtons touch; + +void TouchButtons::init() { touchIO.Init(); } + +uint8_t TouchButtons::read_buttons() { + #ifdef HAS_SPI_LCD + int16_t x, y; + + if (!touchIO.getRawPoint(&x, &y)) return 0; + + x = uint16_t((uint32_t(x) * XPT2046_X_CALIBRATION) >> 16) + XPT2046_X_OFFSET; + y = uint16_t((uint32_t(y) * XPT2046_Y_CALIBRATION) >> 16) + XPT2046_Y_OFFSET; + + #if ENABLED(GRAPHICAL_TFT_ROTATE_180) + x = TOUCH_SENSOR_WIDTH - x; + y = TOUCH_SENSOR_HEIGHT - y; + #endif + + // Touch within the button area simulates an encoder button + if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT) + return WITHIN(x, 14, 77) ? EN_D + : WITHIN(x, 90, 153) ? EN_A + : WITHIN(x, 166, 229) ? EN_B + : WITHIN(x, 242, 305) ? EN_C + : 0; + + if ( !WITHIN(x, SCREEN_PCT_LEFT, SCREEN_PCT_LEFT + SCREEN_PCT_WIDTH) + || !WITHIN(y, SCREEN_PCT_TOP, SCREEN_PCT_TOP + SCREEN_PCT_HEIGHT) + ) return 0; + + // Column and row above BUTTON_AREA_TOP + int8_t col = (x - (SCREEN_PCT_LEFT)) * (LCD_WIDTH) / (SCREEN_PCT_WIDTH), + row = (y - (SCREEN_PCT_TOP)) * (LCD_HEIGHT) / (SCREEN_PCT_HEIGHT); + + // Send the touch to the UI (which will simulate the encoder wheel) + MarlinUI::screen_click(row, col, x, y); + #endif + return 0; +} + +#endif // HAS_TOUCH_XPT2046 diff --git a/Marlin/src/lcd/touch/xpt2046.h b/Marlin/src/lcd/touch/touch_buttons.h similarity index 56% rename from Marlin/src/lcd/touch/xpt2046.h rename to Marlin/src/lcd/touch/touch_buttons.h index 467317901b2b..451e5a5a37ca 100644 --- a/Marlin/src/lcd/touch/xpt2046.h +++ b/Marlin/src/lcd/touch/touch_buttons.h @@ -20,30 +20,10 @@ #include -// Relies on XPT2046-compatible mode of ADS7843, -// hence no Z1 / Z2 measurements are possible. - -#define XPT2046_DFR_MODE 0x00 -#define XPT2046_SER_MODE 0x04 -#define XPT2046_CONTROL 0x80 - -enum XPTCoordinate : uint8_t { - XPT2046_X = 0x10, - XPT2046_Y = 0x50, - XPT2046_Z1 = 0x30, - XPT2046_Z2 = 0x40 -}; - -class XPT2046 { +class TouchButtons { public: static void init(); static uint8_t read_buttons(); - bool getTouchPoint(uint16_t &x, uint16_t &y); - static bool isTouched(); - inline void waitForRelease() { while (isTouched()) { /* nada */ } } - inline void waitForTouch(uint16_t &x, uint16_t &y) { while (!getTouchPoint(x, y)) { /* nada */ } } -private: - static uint16_t getInTouch(const XPTCoordinate coordinate); }; -extern XPT2046 touch; +extern TouchButtons touch; diff --git a/Marlin/src/lcd/touch/xpt2046.cpp b/Marlin/src/lcd/touch/xpt2046.cpp deleted file mode 100644 index 1fed5b78f0e3..000000000000 --- a/Marlin/src/lcd/touch/xpt2046.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_TOUCH_XPT2046 - -#include "xpt2046.h" -#include "../scaled_tft.h" - -#ifndef XPT2046_Z1_THRESHOLD - #define XPT2046_Z1_THRESHOLD 10 -#endif - -/** - * Draw and Touch processing - * - * LCD_PIXEL_WIDTH/HEIGHT (128x64) is the (emulated DOGM) Pixel Drawing resolution. - * TOUCH_SENSOR_WIDTH/HEIGHT (320x240) is the Touch Area resolution. - * LCD_FULL_PIXEL_WIDTH/HEIGHT (320x240 or 480x320) is the Actual (FSMC) Display resolution. - * - * - All native (u8g) drawing is done in LCD_PIXEL_* (128x64) - * - The DOGM pixels are is upscaled 2-3x (as needed) for display. - * - Touch coordinates use TOUCH_SENSOR_* resolution and are converted to - * click and scroll-wheel events (emulating of a common DOGM display). - * - * TOUCH_SCREEN resolution exists to fit our calibration values. The original touch code was made - * and originally calibrated for 320x240. If you decide to change the resolution of the touch code, - * new calibration values will be needed. - * - * The Marlin menus are drawn scaled in the upper region of the screen. The bottom region (in a - * fixed location in TOUCH_SCREEN* coordinate space) is used for 4 general-purpose buttons to - * navigate and select menu items. Both regions are touchable. - * - * The Marlin screen touchable area starts at LCD_PIXEL_OFFSET_X/Y (translated to SCREEN_START_LEFT/TOP) - * and spans LCD_PIXEL_WIDTH/HEIGHT (scaled to SCREEN_WIDTH/HEIGHT). - */ - -// Coordinates in terms of touch area -#define BUTTON_AREA_TOP 175 -#define BUTTON_AREA_BOT 234 - -// Touch sensor resolution independent of display resolution -#define TOUCH_SENSOR_WIDTH 320 -#define TOUCH_SENSOR_HEIGHT 240 - -#define SCREEN_WIDTH_PCT(X) ((X) * (TOUCH_SENSOR_WIDTH) / (LCD_FULL_PIXEL_WIDTH)) -#define SCREEN_HEIGHT_PCT(Y) ((Y) * (TOUCH_SENSOR_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT)) - -#define SCREEN_START_LEFT SCREEN_WIDTH_PCT(LCD_PIXEL_OFFSET_X) -#define SCREEN_START_TOP SCREEN_HEIGHT_PCT(LCD_PIXEL_OFFSET_Y) -#define SCREEN_WIDTH SCREEN_WIDTH_PCT((LCD_PIXEL_WIDTH) * (FSMC_UPSCALE)) -#define SCREEN_HEIGHT SCREEN_HEIGHT_PCT((LCD_PIXEL_HEIGHT) * (FSMC_UPSCALE)) - -#define TOUCHABLE_X_WIDTH SCREEN_WIDTH -#define TOUCHABLE_Y_HEIGHT SCREEN_HEIGHT - -#ifndef TOUCH_INT_PIN - #define TOUCH_INT_PIN -1 -#endif -#ifndef TOUCH_MISO_PIN - #define TOUCH_MISO_PIN MISO_PIN -#endif -#ifndef TOUCH_MOSI_PIN - #define TOUCH_MOSI_PIN MOSI_PIN -#endif -#ifndef TOUCH_SCK_PIN - #define TOUCH_SCK_PIN SCK_PIN -#endif -#ifndef TOUCH_CS_PIN - #define TOUCH_CS_PIN CS_PIN -#endif - -XPT2046 touch; - -void XPT2046::init() { - SET_INPUT(TOUCH_MISO_PIN); - SET_OUTPUT(TOUCH_MOSI_PIN); - SET_OUTPUT(TOUCH_SCK_PIN); - OUT_WRITE(TOUCH_CS_PIN, HIGH); - - #if PIN_EXISTS(TOUCH_INT) - // Optional Pendrive interrupt pin - SET_INPUT(TOUCH_INT_PIN); - #endif - - // Read once to enable pendrive status pin - getInTouch(XPT2046_X); -} - -#include "../../lcd/ultralcd.h" // For EN_C bit mask - -uint8_t XPT2046::read_buttons() { - #ifdef HAS_SPI_LCD - int16_t tsoffsets[4] = { 0 }; - - if (tsoffsets[0] + tsoffsets[1] == 0) { - // Not yet set, so use defines as fallback... - tsoffsets[0] = XPT2046_X_CALIBRATION; - tsoffsets[1] = XPT2046_X_OFFSET; - tsoffsets[2] = XPT2046_Y_CALIBRATION; - tsoffsets[3] = XPT2046_Y_OFFSET; - } - - // We rely on XPT2046 compatible mode to ADS7843, hence no Z1 and Z2 measurements possible. - - if (!isTouched()) return 0; - uint16_t x = uint16_t(((uint32_t(getInTouch(XPT2046_X))) * tsoffsets[0]) >> 16) + tsoffsets[1], - y = uint16_t(((uint32_t(getInTouch(XPT2046_Y))) * tsoffsets[2]) >> 16) + tsoffsets[3]; - if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read. - - #if ENABLED(GRAPHICAL_TFT_ROTATE_180) - x = TOUCH_SENSOR_WIDTH - x; - y = TOUCH_SENSOR_HEIGHT - y; - #endif - - // Touch within the button area simulates an encoder button - if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT) - return WITHIN(x, 14, 77) ? EN_D - : WITHIN(x, 90, 153) ? EN_A - : WITHIN(x, 166, 229) ? EN_B - : WITHIN(x, 242, 305) ? EN_C - : 0; - - if (x > TOUCH_SENSOR_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0; - - // Column and row above BUTTON_AREA_TOP - int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH), - row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT); - - // Send the touch to the UI (which will simulate the encoder wheel) - MarlinUI::screen_click(row, col, x, y); - #endif - return 0; -} - -bool XPT2046::isTouched() { - return ( - #if PIN_EXISTS(TOUCH_INT) - READ(TOUCH_INT_PIN) != HIGH - #else - getInTouch(XPT2046_Z1) >= XPT2046_Z1_THRESHOLD - #endif - ); -} - -#if ENABLED(TOUCH_BUTTONS_HW_SPI) - #include - - static void touch_spi_init(uint8_t spiRate) { - /** - * 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 - */ - uint8_t clock; - switch (spiRate) { - case SPI_FULL_SPEED: clock = SPI_CLOCK_DIV4; 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 - } - SPI.setModule(TOUCH_BUTTONS_HW_SPI_DEVICE); - SPI.begin(); - SPI.setClockDivider(clock); - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - } -#endif // TOUCH_BUTTONS_HW_SPI - -uint16_t XPT2046::getInTouch(const XPTCoordinate coordinate) { - uint16_t data[3]; - const uint8_t coord = uint8_t(coordinate) | XPT2046_CONTROL | XPT2046_DFR_MODE; - - #if ENABLED(TOUCH_BUTTONS_HW_SPI) - - touch_spi_init(SPI_SPEED_6); - for (uint16_t i = 0; i < 3; i++) { - OUT_WRITE(TOUCH_CS_PIN, LOW); - SPI.transfer(coord); - data[i] = (((SPI.transfer(0xFF) << 8) | SPI.transfer(0xFF)) >> 3) & 0x0FFF; - WRITE(TOUCH_CS_PIN, HIGH); - } - - #else // !TOUCH_BUTTONS_HW_SPI - - OUT_WRITE(TOUCH_CS_PIN, LOW); - for (uint16_t i = 0; i < 3; i++) { - for (uint8_t j = 0x80; j; j >>= 1) { - WRITE(TOUCH_SCK_PIN, LOW); - WRITE(TOUCH_MOSI_PIN, bool(coord & j)); - WRITE(TOUCH_SCK_PIN, HIGH); - } - - data[i] = 0; - for (uint16_t j = 0x8000; j; j >>= 1) { - WRITE(TOUCH_SCK_PIN, LOW); - if (READ(TOUCH_MISO_PIN)) data[i] |= j; - WRITE(TOUCH_SCK_PIN, HIGH); - } - WRITE(TOUCH_SCK_PIN, LOW); - data[i] >>= 4; - } - WRITE(TOUCH_CS_PIN, HIGH); - - #endif // !TOUCH_BUTTONS_HW_SPI - - uint16_t delta01 = _MAX(data[0], data[1]) - _MIN(data[0], data[1]), - delta02 = _MAX(data[0], data[2]) - _MIN(data[0], data[2]), - delta12 = _MAX(data[1], data[2]) - _MIN(data[1], data[2]); - - if (delta01 <= delta02 && delta01 <= delta12) - return (data[0] + data[1]) >> 1; - - if (delta02 <= delta12) - return (data[0] + data[2]) >> 1; - - return (data[1] + data[2]) >> 1; -} - -bool XPT2046::getTouchPoint(uint16_t &x, uint16_t &y) { - if (isTouched()) { - x = getInTouch(XPT2046_X); - y = getInTouch(XPT2046_Y); - } - return isTouched(); -} - -#endif // HAS_TOUCH_XPT2046 diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 670c916dd766..b30f6e49c9e0 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -81,7 +81,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif void MarlinUI::buzz(const long duration, const uint16_t freq) { #if ENABLED(PCA9632_BUZZER) - pca9632_buzz(duration, freq); + PCA9632_buzz(duration, freq); #elif USE_BEEPER buzzer.tone(duration, freq); #endif @@ -150,7 +150,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; volatile uint8_t MarlinUI::slow_buttons; #endif #if HAS_TOUCH_XPT2046 - #include "touch/xpt2046.h" + #include "touch/touch_buttons.h" bool MarlinUI::on_edit_screen = false; #endif #endif @@ -372,10 +372,6 @@ void MarlinUI::init() { #endif // HAS_SHIFT_ENCODER - #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) - SET_INPUT_PULLUP(SD_DETECT_PIN); - #endif - #if HAS_ENCODER_ACTION && HAS_SLOW_BUTTONS slow_buttons = 0; #endif @@ -938,6 +934,8 @@ void MarlinUI::update() { if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100; else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10; + // Enable to output the encoder steps per second value + //#define ENCODER_RATE_MULTIPLIER_DEBUG #if ENABLED(ENCODER_RATE_MULTIPLIER_DEBUG) SERIAL_ECHO_START(); SERIAL_ECHOPAIR("Enc Step Rate: ", encoderStepRate); diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index 662adef0c5e2..0200d39014c1 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -312,16 +312,18 @@ class MarlinUI { static void media_changed(const uint8_t old_stat, const uint8_t stat); #endif + #if ENABLED(DWIN_CREALITY_LCD) + static void refresh(); + #else + FORCE_INLINE static void refresh() { + TERN_(HAS_SPI_LCD, refresh(LCDVIEW_CLEAR_CALL_REDRAW)); + } + #endif + #if HAS_SPI_LCD static bool detected(); static void init_lcd(); - FORCE_INLINE static void refresh() { refresh(LCDVIEW_CLEAR_CALL_REDRAW); } #else - #if ENABLED(DWIN_CREALITY_LCD) - static void refresh(); - #else - static inline void refresh() {} - #endif static inline bool detected() { return true; } static inline void init_lcd() {} #endif @@ -403,14 +405,10 @@ class MarlinUI { #if HAS_GRAPHICAL_LCD - static bool drawing_screen, first_page; - static void set_font(const MarlinFont font_nr); #else - static constexpr bool drawing_screen = false, first_page = true; - static void set_custom_characters(const HD44780CharSet screen_charset=CHARSET_INFO); #if ENABLED(LCD_PROGRESS_BAR) @@ -460,6 +458,12 @@ class MarlinUI { #endif + #if HAS_GRAPHICAL_LCD + static bool drawing_screen, first_page; + #else + static constexpr bool drawing_screen = false, first_page = true; + #endif + static bool get_blink(); static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component); static void draw_kill_screen(); @@ -514,6 +518,9 @@ class MarlinUI { static bool encoderRateMultiplierEnabled; static millis_t lastEncoderMovementMillis; static void enable_encoder_multiplier(const bool onoff); + #define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F) + #else + #define ENCODER_RATE_MULTIPLY(F) NOOP #endif // Manual Movement diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 21e6ffb7cd13..f93e5524813a 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -46,15 +46,24 @@ Nozzle nozzle; // Move to the starting point #if ENABLED(NOZZLE_CLEAN_NO_Z) - do_blocking_move_to_xy(start); + #if ENABLED(NOZZLE_CLEAN_NO_Y) + do_blocking_move_to_x(start.x); + #else + do_blocking_move_to_xy(start); + #endif #else do_blocking_move_to(start); #endif // Start the stroke pattern LOOP_L_N(i, strokes >> 1) { - do_blocking_move_to_xy(end); - do_blocking_move_to_xy(start); + #if ENABLED(NOZZLE_CLEAN_NO_Y) + do_blocking_move_to_x(end.x); + do_blocking_move_to_x(start.x); + #else + do_blocking_move_to_xy(end); + do_blocking_move_to_xy(start); + #endif } TERN_(NOZZLE_CLEAN_GOBACK, do_blocking_move_to(oldpos)); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 289270072d97..1169ede2dc1e 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -498,7 +498,7 @@ void Endstops::update() { #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) #define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT)) - #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ) + #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) // If G38 command is active check Z_MIN_PROBE for ALL movement if (G38_move) UPDATE_ENDSTOP_BIT(Z, MIN_PROBE); #endif @@ -514,12 +514,12 @@ void Endstops::update() { #endif // Use HEAD for core axes, AXIS for others - #if CORE_IS_XY || CORE_IS_XZ + #if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) #define X_AXIS_HEAD X_HEAD #else #define X_AXIS_HEAD X_AXIS #endif - #if CORE_IS_XY || CORE_IS_YZ + #if ANY(CORE_IS_XY, CORE_IS_YZ, MARKFORGED_XY) #define Y_AXIS_HEAD Y_HEAD #else #define Y_AXIS_HEAD Y_AXIS @@ -736,7 +736,7 @@ void Endstops::update() { #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX) #endif - #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ) + #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) #if ENABLED(G38_PROBE_AWAY) #define _G38_OPEN_STATE (G38_move >= 4) #else @@ -865,7 +865,7 @@ void Endstops::update() { bool hit = false; #if X_SPI_SENSORLESS if (tmc_spi_homing.x && (stepperX.test_stall_status() - #if CORE_IS_XY && Y_SPI_SENSORLESS + #if ANY(CORE_IS_XY, MARKFORGED_XY) && Y_SPI_SENSORLESS || stepperY.test_stall_status() #elif CORE_IS_XZ && Z_SPI_SENSORLESS || stepperZ.test_stall_status() @@ -877,7 +877,7 @@ void Endstops::update() { #endif #if Y_SPI_SENSORLESS if (tmc_spi_homing.y && (stepperY.test_stall_status() - #if CORE_IS_XY && X_SPI_SENSORLESS + #if ANY(CORE_IS_XY, MARKFORGED_XY) && X_SPI_SENSORLESS || stepperX.test_stall_status() #elif CORE_IS_YZ && Z_SPI_SENSORLESS || stepperZ.test_stall_status() diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 9b8c1c60ffa5..2f12302e5915 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1097,17 +1097,16 @@ void prepare_line_to_destination() { current_position = destination; } -uint8_t axes_need_homing(uint8_t axis_bits/*=0x07*/) { - #define HOMED_FLAGS TERN(HOME_AFTER_DEACTIVATE, axis_known_position, axis_homed) - // Clear test bits that are homed - if (TEST(axis_bits, X_AXIS) && TEST(HOMED_FLAGS, X_AXIS)) CBI(axis_bits, X_AXIS); - if (TEST(axis_bits, Y_AXIS) && TEST(HOMED_FLAGS, Y_AXIS)) CBI(axis_bits, Y_AXIS); - if (TEST(axis_bits, Z_AXIS) && TEST(HOMED_FLAGS, Z_AXIS)) CBI(axis_bits, Z_AXIS); +uint8_t axes_should_home(uint8_t axis_bits/*=0x07*/) { + // Clear test bits that are trusted + if (TEST(axis_bits, X_AXIS) && TEST(axis_homed, X_AXIS)) CBI(axis_bits, X_AXIS); + if (TEST(axis_bits, Y_AXIS) && TEST(axis_homed, Y_AXIS)) CBI(axis_bits, Y_AXIS); + if (TEST(axis_bits, Z_AXIS) && TEST(axis_homed, Z_AXIS)) CBI(axis_bits, Z_AXIS); return axis_bits; } -bool axis_unhomed_error(uint8_t axis_bits/*=0x07*/) { - if ((axis_bits = axes_need_homing(axis_bits))) { +bool homing_needed_error(uint8_t axis_bits/*=0x07*/) { + if ((axis_bits = axes_should_home(axis_bits))) { PGM_P home_first = GET_TEXT(MSG_HOME_FIRST); char msg[strlen_P(home_first)+1]; sprintf_P(msg, home_first, @@ -1153,7 +1152,7 @@ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) { #if AXIS_HAS_STALLGUARD(X2) stealth_states.x2 = tmc_enable_stallguard(stepperX2); #endif - #if CORE_IS_XY && Y_SENSORLESS + #if EITHER(CORE_IS_XY, MARKFORGED_XY) && Y_SENSORLESS stealth_states.y = tmc_enable_stallguard(stepperY); #elif CORE_IS_XZ && Z_SENSORLESS stealth_states.z = tmc_enable_stallguard(stepperZ); @@ -1166,7 +1165,7 @@ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) { #if AXIS_HAS_STALLGUARD(Y2) stealth_states.y2 = tmc_enable_stallguard(stepperY2); #endif - #if CORE_IS_XY && X_SENSORLESS + #if EITHER(CORE_IS_XY, MARKFORGED_XY) && X_SENSORLESS stealth_states.x = tmc_enable_stallguard(stepperX); #elif CORE_IS_YZ && Z_SENSORLESS stealth_states.z = tmc_enable_stallguard(stepperZ); @@ -1217,7 +1216,7 @@ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) { #if AXIS_HAS_STALLGUARD(X2) tmc_disable_stallguard(stepperX2, enable_stealth.x2); #endif - #if CORE_IS_XY && Y_SENSORLESS + #if EITHER(CORE_IS_XY, MARKFORGED_XY) && Y_SENSORLESS tmc_disable_stallguard(stepperY, enable_stealth.y); #elif CORE_IS_XZ && Z_SENSORLESS tmc_disable_stallguard(stepperZ, enable_stealth.z); @@ -1230,7 +1229,7 @@ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) { #if AXIS_HAS_STALLGUARD(Y2) tmc_disable_stallguard(stepperY2, enable_stealth.y2); #endif - #if CORE_IS_XY && X_SENSORLESS + #if EITHER(CORE_IS_XY, MARKFORGED_XY) && X_SENSORLESS tmc_disable_stallguard(stepperX, enable_stealth.x); #elif CORE_IS_YZ && Z_SENSORLESS tmc_disable_stallguard(stepperZ, enable_stealth.z); @@ -1431,15 +1430,15 @@ void set_axis_is_at_home(const AxisEnum axis) { } /** - * Set an axis' to be unhomed. + * Set an axis to be unhomed. */ -void set_axis_not_trusted(const AxisEnum axis) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_not_trusted(", axis_codes[axis], ")"); +void set_axis_never_homed(const AxisEnum axis) { + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", axis_codes[axis], ")"); CBI(axis_known_position, axis); CBI(axis_homed, axis); - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_not_trusted(", axis_codes[axis], ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", axis_codes[axis], ")"); TERN_(I2C_POSITION_ENCODERS, I2CPEM.unhomed(axis)); } @@ -1790,7 +1789,7 @@ void homeaxis(const AxisEnum axis) { do_homing_move(axis, adjDistance, get_homing_bump_feedrate(axis)); } - #else // CARTESIAN / CORE + #else // CARTESIAN / CORE / MARKFORGED_XY set_axis_is_at_home(axis); sync_plan_position(); @@ -1819,8 +1818,11 @@ void homeaxis(const AxisEnum axis) { #if ENABLED(SENSORLESS_HOMING) planner.synchronize(); - if (TERN0(IS_CORE, axis != NORMAL_AXIS)) - safe_delay(200); // Short delay to allow belts to spring back + if (false + #if EITHER(IS_CORE, MARKFORGED_XY) + || axis != NORMAL_AXIS + #endif + ) safe_delay(200); // Short delay to allow belts to spring back #endif } #endif diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 38ce980dae98..c3f2d9b779a4 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -40,8 +40,8 @@ constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS); FORCE_INLINE bool no_axes_homed() { return !axis_homed; } FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; } FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; } -FORCE_INLINE void set_all_unhomed() { axis_homed = 0; } -FORCE_INLINE void set_all_unknown() { axis_known_position = 0; } +FORCE_INLINE void set_all_homed() { axis_homed = axis_known_position = xyz_bits; } +FORCE_INLINE void set_all_unhomed() { axis_homed = axis_known_position = 0; } FORCE_INLINE bool homing_needed() { return !TERN(HOME_AFTER_DEACTIVATE, all_axes_known, all_axes_homed)(); @@ -239,22 +239,18 @@ void do_z_clearance(const float &zclear, const bool z_known=true, const bool rai // // Homing // - -uint8_t axes_need_homing(uint8_t axis_bits=0x07); -bool axis_unhomed_error(uint8_t axis_bits=0x07); +void homeaxis(const AxisEnum axis); +void set_axis_is_at_home(const AxisEnum axis); +void set_axis_never_homed(const AxisEnum axis); +uint8_t axes_should_home(uint8_t axis_bits=0x07); +bool homing_needed_error(uint8_t axis_bits=0x07); #if ENABLED(NO_MOTION_BEFORE_HOMING) - #define MOTION_CONDITIONS (IsRunning() && !axis_unhomed_error()) + #define MOTION_CONDITIONS (IsRunning() && !homing_needed_error()) #else #define MOTION_CONDITIONS IsRunning() #endif -void set_axis_is_at_home(const AxisEnum axis); - -void set_axis_not_trusted(const AxisEnum axis); - -void homeaxis(const AxisEnum axis); - /** * Workspace offsets */ diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 931daa3322b8..82c62ed579de 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1614,6 +1614,7 @@ void Planner::finish_and_disable() { float Planner::get_axis_position_mm(const AxisEnum axis) { float axis_steps; #if IS_CORE + // Requesting one of the "core" axes? if (axis == CORE_AXIS_1 || axis == CORE_AXIS_2) { @@ -1631,9 +1632,30 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { } else axis_steps = stepper.position(axis); + + #elif ENABLED(MARKFORGED_XY) + + // Requesting one of the joined axes? + if (axis == CORE_AXIS_1 || axis == CORE_AXIS_2) { + // Protect the access to the position. + const bool was_enabled = stepper.suspend(); + + const int32_t p1 = stepper.position(CORE_AXIS_1), + p2 = stepper.position(CORE_AXIS_2); + + if (was_enabled) stepper.wake_up(); + + axis_steps = ((axis == CORE_AXIS_1) ? p1 - p2 : p2); + } + else + axis_steps = stepper.position(axis); + #else + axis_steps = stepper.position(axis); + #endif + return axis_steps * steps_to_mm[axis]; } @@ -1808,6 +1830,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (dc < 0) SBI(dm, Z_HEAD); // ...and Z if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction if (CORESIGN(db - dc) < 0) SBI(dm, C_AXIS); // Motor C direction + #elif ENABLED(MARKFORGED_XY) + if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis + if (db < 0) SBI(dm, Y_HEAD); // ...and Y + if (dc < 0) SBI(dm, Z_AXIS); + if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction + if (db < 0) SBI(dm, B_AXIS); // Motor B direction #else if (da < 0) SBI(dm, X_AXIS); if (db < 0) SBI(dm, Y_AXIS); @@ -1843,6 +1871,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->steps.set(ABS(da + dc), ABS(db), ABS(da - dc)); #elif CORE_IS_YZ block->steps.set(ABS(da), ABS(db + dc), ABS(db - dc)); + #elif ENABLED(MARKFORGED_XY) + block->steps.set(ABS(da + db), ABS(db), ABS(dc)); #elif IS_SCARA block->steps.set(ABS(da), ABS(db), ABS(dc)); #else @@ -1859,7 +1889,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed. */ struct DistanceMM : abce_float_t { - TERN_(IS_CORE, xyz_pos_t head); + #if EITHER(IS_CORE, MARKFORGED_XY) + xyz_pos_t head; + #endif } steps_dist_mm; #if IS_CORE #if CORE_IS_XY @@ -1881,6 +1913,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move, steps_dist_mm.b = (db + dc) * steps_to_mm[B_AXIS]; steps_dist_mm.c = CORESIGN(db - dc) * steps_to_mm[C_AXIS]; #endif + #elif ENABLED(MARKFORGED_XY) + steps_dist_mm.head.x = da * steps_to_mm[A_AXIS]; + steps_dist_mm.head.y = db * steps_to_mm[B_AXIS]; + steps_dist_mm.z = dc * steps_to_mm[Z_AXIS]; + steps_dist_mm.a = (da - db) * steps_to_mm[A_AXIS]; + steps_dist_mm.b = db * steps_to_mm[B_AXIS]; #else steps_dist_mm.a = da * steps_to_mm[A_AXIS]; steps_dist_mm.b = db * steps_to_mm[B_AXIS]; @@ -1907,7 +1945,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->millimeters = millimeters; else block->millimeters = SQRT( - #if CORE_IS_XY + #if EITHER(CORE_IS_XY, MARKFORGED_XY) sq(steps_dist_mm.head.x) + sq(steps_dist_mm.head.y) + sq(steps_dist_mm.z) #elif CORE_IS_XZ sq(steps_dist_mm.head.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.head.z) @@ -1964,7 +2002,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif // Enable active axes - #if CORE_IS_XY + #if EITHER(CORE_IS_XY, MARKFORGED_XY) if (block->steps.a || block->steps.b) { ENABLE_AXIS_X(); ENABLE_AXIS_Y(); @@ -2325,9 +2363,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, * On CoreXY the length of the vector [A,B] is SQRT(2) times the length of the head movement vector [X,Y]. * So taking Z and E into account, we cannot scale to a unit vector with "inverse_millimeters". * => normalize the complete junction vector. - * Elsewise, when needed JD factors in the E component + * Elsewise, when needed JD will factor-in the E component */ - if (ENABLED(IS_CORE) || esteps > 0) + if (EITHER(IS_CORE, MARKFORGED_XY) || esteps > 0) normalize_junction_vector(unit_vec); // Normalize with XYZE components else unit_vec *= inverse_millimeters; // Use pre-calculated (1 / SQRT(x^2 + y^2 + z^2)) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 4fab4ec27b49..12b617ec439e 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -359,7 +359,7 @@ bool Probe::set_deployed(const bool deploy) { do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE)); #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY) - if (axis_unhomed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) { + if (homing_needed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) { SERIAL_ERROR_MSG(STR_STOP_UNHOMED); stop(); return true; diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index f1ab0fca6927..8af2071e3600 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -21,7 +21,7 @@ */ /** - * configuration_store.cpp + * settings.cpp * * Settings and EEPROM storage * @@ -52,7 +52,7 @@ #include "temperature.h" #if ENABLED(DWIN_CREALITY_LCD) - #include "../lcd/dwin/dwin.h" + #include "../lcd/dwin/e3v2/dwin.h" #endif #include "../lcd/ultralcd.h" @@ -106,6 +106,9 @@ #if HAS_FILAMENT_SENSOR #include "../feature/runout.h" + #ifndef FIL_RUNOUT_ENABLED_DEFAULT + #define FIL_RUNOUT_ENABLED_DEFAULT true + #endif #endif #if ENABLED(EXTRA_LIN_ADVANCE_K) @@ -626,7 +629,12 @@ void MarlinSettings::postprocess() { #endif EEPROM_WRITE(home_offset); #endif + } + // + // Hotend Offsets, if any + // + { #if HAS_HOTEND_OFFSET // Skip hotend 0 which must be 0 LOOP_S_L_N(e, 1, HOTENDS) @@ -641,15 +649,16 @@ void MarlinSettings::postprocess() { #if HAS_FILAMENT_SENSOR const bool &runout_sensor_enabled = runout.enabled; #else - constexpr bool runout_sensor_enabled = true; + constexpr int8_t runout_sensor_enabled = -1; #endif + _FIELD_TEST(runout_sensor_enabled); + EEPROM_WRITE(runout_sensor_enabled); + #if HAS_FILAMENT_RUNOUT_DISTANCE const float &runout_distance_mm = runout.runout_distance(); #else constexpr float runout_distance_mm = 0; #endif - _FIELD_TEST(runout_sensor_enabled); - EEPROM_WRITE(runout_sensor_enabled); EEPROM_WRITE(runout_distance_mm); } @@ -1513,13 +1522,14 @@ void MarlinSettings::postprocess() { // Filament Runout Sensor // { - #if HAS_FILAMENT_SENSOR - const bool &runout_sensor_enabled = runout.enabled; - #else - bool runout_sensor_enabled; - #endif + int8_t runout_sensor_enabled; _FIELD_TEST(runout_sensor_enabled); EEPROM_READ(runout_sensor_enabled); + #if HAS_FILAMENT_SENSOR + runout.enabled = runout_sensor_enabled < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled; + #endif + + TERN_(HAS_FILAMENT_SENSOR, if (runout.enabled) runout.reset()); float runout_distance_mm; EEPROM_READ(runout_distance_mm); @@ -2469,7 +2479,7 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - runout.enabled = true; + runout.enabled = FIL_RUNOUT_ENABLED_DEFAULT; runout.reset(); TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM)); #endif diff --git a/Marlin/src/module/settings.h b/Marlin/src/module/settings.h index c654b11bd5ef..b213de93a433 100644 --- a/Marlin/src/module/settings.h +++ b/Marlin/src/module/settings.h @@ -21,6 +21,10 @@ */ #pragma once +// +// settings.cpp - Settings and EEPROM storage +// + #include "../inc/MarlinConfig.h" #if ENABLED(EEPROM_SETTINGS) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index c9d87486f87d..fab1a615482d 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1264,7 +1264,7 @@ void Stepper::set_directions() { } FORCE_INLINE int32_t Stepper::_eval_bezier_curve(const uint32_t curr_step) { - #if defined(__ARM__) || defined(__thumb__) + #if defined(__arm__) || defined(__thumb__) // For ARM Cortex M3/M4 CPUs, we have the optimized assembler version, that takes 43 cycles to execute uint32_t flo = 0; @@ -1578,12 +1578,11 @@ void Stepper::pulse_phase_isr() { #if STEPPER_PAGE_FORMAT == SP_4x4D_128 - #define PAGE_SEGMENT_UPDATE(AXIS, VALUE, MID) do{ \ - if ((VALUE) == MID) {} \ - else if ((VALUE) < MID) SBI(dm, _AXIS(AXIS)); \ - else CBI(dm, _AXIS(AXIS)); \ - page_step_state.sd[_AXIS(AXIS)] = VALUE; \ - page_step_state.bd[_AXIS(AXIS)] += VALUE; \ + #define PAGE_SEGMENT_UPDATE(AXIS, VALUE) do{ \ + if ((VALUE) < 7) SBI(dm, _AXIS(AXIS)); \ + else if ((VALUE) > 7) CBI(dm, _AXIS(AXIS)); \ + page_step_state.sd[_AXIS(AXIS)] = VALUE; \ + page_step_state.bd[_AXIS(AXIS)] += VALUE; \ }while(0) #define PAGE_PULSE_PREP(AXIS) do{ \ @@ -1592,7 +1591,7 @@ void Stepper::pulse_phase_isr() { }while(0) switch (page_step_state.segment_steps) { - case 8: + case DirectStepping::Config::SEGMENT_STEPS: page_step_state.segment_idx += 2; page_step_state.segment_steps = 0; // fallthru @@ -1601,10 +1600,10 @@ void Stepper::pulse_phase_isr() { high = page_step_state.page[page_step_state.segment_idx + 1]; uint8_t dm = last_direction_bits; - PAGE_SEGMENT_UPDATE(X, low >> 4, 7); - PAGE_SEGMENT_UPDATE(Y, low & 0xF, 7); - PAGE_SEGMENT_UPDATE(Z, high >> 4, 7); - PAGE_SEGMENT_UPDATE(E, high & 0xF, 7); + PAGE_SEGMENT_UPDATE(X, low >> 4); + PAGE_SEGMENT_UPDATE(Y, low & 0xF); + PAGE_SEGMENT_UPDATE(Z, high >> 4); + PAGE_SEGMENT_UPDATE(E, high & 0xF); if (dm != last_direction_bits) { last_direction_bits = dm; @@ -1615,9 +1614,9 @@ void Stepper::pulse_phase_isr() { default: break; } - PAGE_PULSE_PREP(X), - PAGE_PULSE_PREP(Y), - PAGE_PULSE_PREP(Z), + PAGE_PULSE_PREP(X); + PAGE_PULSE_PREP(Y); + PAGE_PULSE_PREP(Z); PAGE_PULSE_PREP(E); page_step_state.segment_steps++; @@ -1634,7 +1633,7 @@ void Stepper::pulse_phase_isr() { }while(0) switch (page_step_state.segment_steps) { - case 4: + case DirectStepping::Config::SEGMENT_STEPS: page_step_state.segment_idx++; page_step_state.segment_steps = 0; // fallthru @@ -1664,7 +1663,6 @@ void Stepper::pulse_phase_isr() { }while(0) uint8_t steps = page_step_state.page[page_step_state.segment_idx >> 1]; - if (page_step_state.segment_idx & 0x1) steps >>= 4; PAGE_PULSE_PREP(X, 3); @@ -2043,6 +2041,8 @@ uint32_t Stepper::block_phase_isr() { #define X_CMP(A,B) ((A)!=(B)) #endif #define X_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && X_CMP(D_(1),D_(2))) ) + #elif ENABLED(MARKFORGED_XY) + #define X_MOVE_TEST (current_block->steps.a != current_block->steps.b) #else #define X_MOVE_TEST !!current_block->steps.a #endif @@ -2616,6 +2616,8 @@ void Stepper::_set_position(const int32_t &a, const int32_t &b, const int32_t &c #elif CORE_IS_YZ // coreyz planning count_position.set(a, b + c, CORESIGN(b - c)); + #elif ENABLED(MARKFORGED_XY) + count_position.set(a - b, b, c); #else // default non-h-bot planning count_position.set(a, b, c); @@ -2682,6 +2684,10 @@ void Stepper::endstop_triggered(const AxisEnum axis) { ? CORESIGN(count_position[CORE_AXIS_1] - count_position[CORE_AXIS_2]) : count_position[CORE_AXIS_1] + count_position[CORE_AXIS_2] ) * double(0.5) + #elif ENABLED(MARKFORGED_XY) + axis == CORE_AXIS_1 + ? count_position[CORE_AXIS_1] - count_position[CORE_AXIS_2] + : count_position[CORE_AXIS_2] #else // !IS_CORE count_position[axis] #endif @@ -2711,12 +2717,12 @@ int32_t Stepper::triggered_position(const AxisEnum axis) { } void Stepper::report_a_position(const xyz_long_t &pos) { - #if CORE_IS_XY || CORE_IS_XZ || ENABLED(DELTA) || IS_SCARA + #if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, DELTA, IS_SCARA) SERIAL_ECHOPAIR(STR_COUNT_A, pos.x, " B:", pos.y); #else SERIAL_ECHOPAIR_P(PSTR(STR_COUNT_X), pos.x, SP_Y_LBL, pos.y); #endif - #if CORE_IS_XZ || CORE_IS_YZ || ENABLED(DELTA) + #if ANY(CORE_IS_XZ, CORE_IS_YZ, DELTA) SERIAL_ECHOLNPAIR(" C:", pos.z); #else SERIAL_ECHOLNPAIR_P(SP_Z_LBL, pos.z); diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 1fd1a72e7e9f..ec0d63a89d97 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -840,21 +840,22 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset // // Axis steppers enable / disable macros // +#define FORGET_AXIS(A) TERN(HOME_AFTER_DEACTIVATE, set_axis_never_homed(A), CBI(axis_known_position, A)) #define ENABLE_AXIS_X() do{ ENABLE_STEPPER_X(); ENABLE_STEPPER_X2(); }while(0) -#define DISABLE_AXIS_X() do{ DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); CBI(axis_known_position, X_AXIS); }while(0) +#define DISABLE_AXIS_X() do{ DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); FORGET_AXIS(X_AXIS); }while(0) #define ENABLE_AXIS_Y() do{ ENABLE_STEPPER_Y(); ENABLE_STEPPER_Y2(); }while(0) -#define DISABLE_AXIS_Y() do{ DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); CBI(axis_known_position, Y_AXIS); }while(0) +#define DISABLE_AXIS_Y() do{ DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); FORGET_AXIS(Y_AXIS); }while(0) #define ENABLE_AXIS_Z() do{ ENABLE_STEPPER_Z(); ENABLE_STEPPER_Z2(); ENABLE_STEPPER_Z3(); ENABLE_STEPPER_Z4(); }while(0) #ifdef Z_AFTER_DEACTIVATE - #define Z_RESET() do{ current_position.z = Z_AFTER_DEACTIVATE; planner.sync_plan_position(); }while(0) + #define Z_RESET() do{ current_position.z = Z_AFTER_DEACTIVATE; sync_plan_position(); }while(0) #else #define Z_RESET() #endif -#define DISABLE_AXIS_Z() do{ DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); CBI(axis_known_position, Z_AXIS); Z_RESET(); }while(0) +#define DISABLE_AXIS_Z() do{ DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); FORGET_AXIS(Z_AXIS); Z_RESET(); }while(0) // // Extruder steppers enable / disable macros diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 1dc480a9279a..6b22c50a7b14 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -37,7 +37,7 @@ #include "../lcd/ultralcd.h" #if ENABLED(DWIN_CREALITY_LCD) - #include "../lcd/dwin/dwin.h" + #include "../lcd/dwin/e3v2/dwin.h" #endif #if ENABLED(EXTENSIBLE_UI) @@ -195,7 +195,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #endif #if ENABLED(ADAPTIVE_FAN_SLOWING) - uint8_t Temperature::fan_speed_scaler[FAN_COUNT] = ARRAY_N(FAN_COUNT, 128, 128, 128, 128, 128, 128); + uint8_t Temperature::fan_speed_scaler[FAN_COUNT] = ARRAY_N(FAN_COUNT, 128, 128, 128, 128, 128, 128, 128, 128); #endif /** @@ -210,9 +210,10 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, if (target < EXTRUDERS) singlenozzle_fan_speed[target] = speed; return; } - target = 0; // Always use fan index 0 with SINGLENOZZLE #endif + TERN_(SINGLENOZZLE, target = 0); // Always use fan index 0 with SINGLENOZZLE + if (target >= FAN_COUNT) return; fan_speed[target] = speed; @@ -361,7 +362,7 @@ volatile bool Temperature::raw_temps_ready = false; #endif #if ENABLED(PID_EXTRUSION_SCALING) - int16_t Temperature::lpq_len; // Initialized in configuration_store + int16_t Temperature::lpq_len; // Initialized in settings.cpp #endif #if HAS_PID_HEATING @@ -435,6 +436,7 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_START); disable_all_heaters(); + TERN_(AUTO_POWER_CONTROL, powerManager.power_on()); SHV(bias = d = (MAX_BED_POWER) >> 1, bias = d = (PID_MAX) >> 1); diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 44680a7baa41..56921c6d186e 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -72,7 +72,7 @@ typedef struct { int16_t value, celsius; } temp_entry_t; #if ANY_THERMISTOR_IS(501) // 100K Zonestar thermistor #include "thermistor_501.h" #endif -#if ANY_THERMISTOR_IS(502) // Unknown thermistor used by the Zonestar Prusa P802M hot bed +#if ANY_THERMISTOR_IS(502) // Unknown thermistor used by the Zonestar Průša P802M hot bed #include "thermistor_502.h" #endif #if ANY_THERMISTOR_IS(512) // 100k thermistor in RPW-Ultra hotend, Pull-up = 4.7 kOhm, "unknown model" diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index d1017cea8078..855756026684 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -174,7 +174,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a grabpos = mpe_settings.parking_xpos[new_tool] + (new_tool ? mpe_settings.grab_distance : -mpe_settings.grab_distance), offsetcompensation = TERN0(HAS_HOTEND_OFFSET, hotend_offset[active_extruder].x * mpe_settings.compensation_factor); - if (axis_unhomed_error(_BV(X_AXIS))) return; + if (homing_needed_error(_BV(X_AXIS))) return; /** * Z Lift and Nozzle Offset shift ar defined in caller method to work equal with any Multi Hotend realization diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 9361680c2371..2b7909221ec9 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -50,7 +50,7 @@ #endif #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif #define IS_RAMPS_EFB 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 9e26a335974b..fb1218068eb3 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -182,7 +182,7 @@ #define E1_SERIAL_RX_PIN P1_01 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif /** 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 f467ba58cbec..b32f99c68db0 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -208,7 +208,7 @@ #define Z2_SERIAL_RX_PIN P1_01 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // @@ -250,6 +250,62 @@ #define LCD_PINS_ENABLE P1_23 #define LCD_PINS_D4 P1_21 + #elif ENABLED(ENDER2_STOCKDISPLAY) + + /** Creality Ender-2 display pinout + * _____ + * 5V | 1 2 | GND + * (MOSI) 1.23 | 3 4 | 1.22 (LCD_RS) + * (LCD_A0) 1.21 | 5 6 | 1.20 (BTN_EN2) + * RESET 1.19 | 7 8 | 1.18 (BTN_EN1) + * (BTN_ENC) 0.28 | 9 10| 1.30 (SCK) + * ----- + * EXP1 + */ + + #define BTN_EN1 P1_18 + #define BTN_EN2 P1_20 + #define BTN_ENC P0_28 + + #define DOGLCD_CS P1_22 + #define DOGLCD_A0 P1_21 + #define DOGLCD_SCK P1_30 + #define DOGLCD_MOSI P1_23 + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI + #define SS_PIN -1 + //#define ONBOARD_SD_CS_PIN -1 + + #define TFT_CS_PIN P1_22 + #define TFT_A0_PIN P1_23 + #define TFT_DC_PIN P1_23 + #define TFT_MISO_PIN P0_17 + #define TFT_BACKLIGHT_PIN P1_18 + #define TFT_RESET_PIN P1_19 + + #define LPC_HW_SPI_DEV 0 + #define LCD_USE_DMA_SPI + + #define TOUCH_INT_PIN P1_21 + #define TOUCH_CS_PIN P1_20 + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + #ifndef GRAPHICAL_TFT_UPSCALE + #define GRAPHICAL_TFT_UPSCALE 3 + #endif + + // SPI 1 + #define SCK_PIN P0_15 + #define MISO_PIN P0_17 + #define MOSI_PIN P0_18 + + // Disable any LCD related PINs config + #define LCD_PINS_ENABLE -1 + #define LCD_PINS_RS -1 + #else #define BTN_ENC P0_28 // (58) open-drain @@ -321,7 +377,7 @@ #endif // -// Neopixel LED +// NeoPixel LED // #ifndef NEOPIXEL_PIN #define NEOPIXEL_PIN P1_24 diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index cc35dfb0d4eb..bfae569cc422 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -30,7 +30,7 @@ #endif // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Steppers diff --git a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h index 7012068d615b..6bba067cbef8 100644 --- a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h +++ b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h @@ -28,7 +28,7 @@ #define BOARD_INFO_NAME "GMARSH X6 REV1" // Ignore temp readings during develpment. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Enable 12MHz clock output on P1.27 pin to sync TMC2208 chip clocks @@ -97,7 +97,7 @@ #define E2_SERIAL_RX_PIN P2_06 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #else #error "TMC2208 UART configuration is required for GMarsh X6." #endif diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h index db8551c114a1..54f3dfd95c16 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h @@ -289,20 +289,21 @@ #define E0_CS_PIN P2_11 #define E1_CS_PIN P4_28 -// Hardware SPI is on EXP2. See if you can make it work: -// https://github.com/makerbase-mks/MKS-SBASE/issues/25 -#define TMC_USE_SW_SPI -#if ENABLED(TMC_USE_SW_SPI) - #ifndef TMC_SW_MOSI - #define TMC_SW_MOSI P0_03 // AUX1 - #endif - #ifndef TMC_SW_MISO - #define TMC_SW_MISO P0_02 // AUX1 - #endif - #ifndef TMC_SW_SCK - #define TMC_SW_SCK P0_26 // TH4 + // Hardware SPI is on EXP2. See if you can make it work: + // https://github.com/makerbase-mks/MKS-SBASE/issues/25 + #define TMC_USE_SW_SPI + #if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P0_03 // AUX1 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P0_02 // AUX1 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P0_26 // TH4 + #endif #endif - #endif + #endif #if MB(MKS_SBASE) && HAS_TMC_UART @@ -324,7 +325,7 @@ #define E0_SERIAL_RX_PIN P0_26 // TH4 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // UNUSED diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index c4bc90c17f67..733751eb0a8e 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -188,7 +188,7 @@ #define Z2_SERIAL_RX_PIN P1_17 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // TMC2208 || TMC2209 // diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index 554c060cb44f..32c9ad271187 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -158,7 +158,7 @@ #endif // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h index 042b724e8cfd..8d5080b28033 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -82,11 +82,11 @@ // DIGIPOT slave addresses // #ifndef DIGIPOT_I2C_ADDRESS_A - #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for first DIGIPOT + #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for first DIGIPOT #endif #ifndef DIGIPOT_I2C_ADDRESS_B - #define DIGIPOT_I2C_ADDRESS_B 0x2E // unshifted slave address for second DIGIPOT + #define DIGIPOT_I2C_ADDRESS_B 0x2E // unshifted slave address for second DIGIPOT #endif // diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h index 23275e86b6c8..c9f3ff7aae26 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h @@ -56,5 +56,5 @@ #define E1_SERIAL_RX_PIN P4_28 // J8-6 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h new file mode 100644 index 000000000000..d112cc5d5080 --- /dev/null +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -0,0 +1,357 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * MKS SGen pin assignments + */ + +#ifndef MCU_LPC1769 + #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." +#endif + +#define BOARD_INFO_NAME "MKS SGEN_L V2" +#define BOARD_WEBSITE_URL "github.com/makerbase-mks" + +// +// EEPROM, MKS SGEN_L V2.0 hardware has 4K EEPROM on the board +// +#if NO_EEPROM_SELECTED + //#define SDCARD_EEPROM_EMULATION + //#define I2C_EEPROM // AT24C32 + #define FLASH_EEPROM_EMULATION + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +// +// Servos +// +#define SERVO0_PIN P1_23 // SERVO P1.23 +#define SERVO1_PIN P2_00 // SERVO P2.0 + +// +// Trinamic Stallguard pins, can connect or disconnect by jumpers cap on the board +// +#define X_DIAG_PIN P1_29 // X- +#define Y_DIAG_PIN P1_27 // Y- +#define Z_DIAG_PIN P1_25 // Z- +#define E0_DIAG_PIN P1_28 // X+ +#define E1_DIAG_PIN P1_26 // Y+ + +// +// Limit Switches +// +#if X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_DIR < 0 + #define X_MAX_PIN P1_28 // X+ + #else + #define X_MIN_PIN P1_28 // X+ + #endif +#else + #define X_MIN_PIN P1_29 // X- + #define X_MAX_PIN P1_28 // X+ +#endif + +#if Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_DIR < 0 + #define Y_MAX_PIN P1_26 // Y+ + #else + #define Y_MIN_PIN P1_26 // Y+ + #endif +#else + #define Y_MIN_PIN P1_27 // Y- + #define Y_MAX_PIN P1_26 // Y+ +#endif + +#if Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_DIR < 0 + #define Z_MAX_PIN P1_24 // Z+ + #else + #define Z_MIN_PIN P1_24 // Z+ + #endif +#else + #define Z_MIN_PIN P1_25 // Z- + #define Z_MAX_PIN P1_24 // Z+ +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P1_24 +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_02 +#define X_DIR_PIN P2_03 +#define X_ENABLE_PIN P2_01 +#ifndef X_CS_PIN + #define X_CS_PIN P1_01 +#endif + +#define Y_STEP_PIN P0_19 +#define Y_DIR_PIN P0_20 +#define Y_ENABLE_PIN P2_08 +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_08 +#endif + +#define Z_STEP_PIN P0_22 +#define Z_DIR_PIN P2_11 +#define Z_ENABLE_PIN P0_21 +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_10 +#endif + +#define E0_STEP_PIN P2_13 +#define E0_DIR_PIN P0_11 +#define E0_ENABLE_PIN P2_12 +#ifndef E0_CS_PIN + #define E0_CS_PIN P1_15 +#endif + +#define E1_STEP_PIN P1_09 +#define E1_DIR_PIN P1_14 +#define E1_ENABLE_PIN P0_10 +#ifndef E1_CS_PIN + #define E1_CS_PIN P1_17 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P1_16 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P0_05 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P0_04 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + // + // Software serial + // + #define X_SERIAL_TX_PIN P1_01 + #define X_SERIAL_RX_PIN P1_01 + #define Y_SERIAL_TX_PIN P1_08 + #define Y_SERIAL_RX_PIN P1_08 + #define Z_SERIAL_TX_PIN P1_10 + #define Z_SERIAL_RX_PIN P1_10 + #define E0_SERIAL_TX_PIN P1_15 + #define E0_SERIAL_RX_PIN P1_15 + #define E1_SERIAL_TX_PIN P1_17 + #define E1_SERIAL_RX_PIN P1_17 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif // HAS_TMC_UART + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_23_A0 // Analog Input A0 (TH1) +#define TEMP_BED_PIN P0_24_A1 // Analog Input A1 (TB) +#define TEMP_1_PIN P0_25_A2 // Analog Input A2 (TH2) +#define TEMP_2_PIN P0_26_A3 // Analog Input A3 (P0.26, No pull up) + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P2_05 +#define HEATER_0_PIN P2_07 +#if HOTENDS == 1 + #ifndef FAN1_PIN + #define FAN1_PIN P2_06 + #endif +#else + #ifndef HEATER_1_PIN + #define HEATER_1_PIN P2_06 + #endif +#endif +#ifndef FAN_PIN + #define FAN_PIN P2_04 +#endif +#ifndef FAN2_PIN + #define FAN2_PIN P1_04 +#endif + +// +// Misc. Functions +// +#define LED_PIN P1_18 // Used as a status indicator +#define LED2_PIN P1_19 +#define LED3_PIN P1_20 +#define LED4_PIN P1_21 + +/** + * _____ _____ + * (BEEPER) 1.31 | · · | 1.30 (BTN_ENC) (MISO) 0.8 | · · | 0.7 (SD_SCK) + * (LCD_EN) 0.18 | · · | 0.16 (LCD_RS) (BTN_EN1) 3.25 | · · | 0.28 (SD_CS2) + * (LCD_D4) 0.15 | · ·| 0.17 (LCD_D5) (BTN_EN2) 3.26 | · ·| 0.9 (SD_MOSI) + * (LCD_D6) 1.0 | · · | 1.22 (LCD_D7) (SD_DETECT) 0.27 | · · | RST + * GND | · · | 5V GND | · · | NC + * ----- ----- + * EXP1 EXP2 + */ +#if HAS_SPI_LCD + #define BEEPER_PIN P1_31 + #define BTN_ENC P1_30 + + #if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS P1_00 + + #define BTN_EN1 P0_18 + #define BTN_EN2 P0_15 + + #define LCD_PINS_ENABLE P1_22 + #define LCD_PINS_D4 P0_17 + + #else + + #define BTN_EN1 P3_25 + #define BTN_EN2 P3_26 + + #define LCD_SDSS P0_28 + + #if ENABLED(MKS_12864OLED_SSD1306) + + #define LCD_PINS_DC P0_17 + #define DOGLCD_CS P0_16 + #define DOGLCD_A0 LCD_PINS_DC + #define DOGLCD_SCK P0_15 + #define DOGLCD_MOSI P0_18 + + #define LCD_PINS_RS P1_00 + #define LCD_PINS_D7 P1_22 + #define KILL_PIN -1 // NC + + #else // !MKS_12864OLED_SSD1306 + + #define LCD_PINS_RS P0_16 + + #define LCD_PINS_ENABLE P0_18 + #define LCD_PINS_D4 P0_15 + + #if ENABLED(FYSETC_MINI_12864) + + #define DOGLCD_CS P0_18 + #define DOGLCD_A0 P0_16 + #define DOGLCD_SCK P0_07 + #define DOGLCD_MOSI P1_20 + + #define LCD_BACKLIGHT_PIN -1 + + #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 P0_15 // 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 P0_17 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN P1_00 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN P1_22 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN P0_17 + #endif + + #else // !FYSETC_MINI_12864 + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_CS P0_17 + #define DOGLCD_A0 P1_00 + #endif + + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 P0_17 + #define LCD_PINS_D6 P1_00 + #define LCD_PINS_D7 P1_22 + #endif + + #endif // !FYSETC_MINI_12864 + + #endif // !MKS_12864OLED_SSD1306 + + #endif // !CR10_STOCKDISPLAY + +#endif // HAS_SPI_LCD + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + +#if SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN P0_27 + #define SCK_PIN P0_07 + #define MISO_PIN P0_08 + #define MOSI_PIN P0_09 + #if SD_CONNECTION_IS(ONBOARD) + #define SS_PIN ONBOARD_SD_CS_PIN + #else + #define SS_PIN P0_28 + #endif +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +// +// Other Pins +// +//#define PIN_P0_02 P0_02 // AUX1 (Interrupt Capable/ADC/Serial Port 0) +//#define PIN_P0_03 P0_03 // AUX1 (Interrupt Capable/ADC/Serial Port 0) +//#define PS_ON_PIN P1_23 // SERVO P1.23 diff --git a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h index 0712a274bbe6..de148995cacb 100644 --- a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h @@ -111,6 +111,64 @@ #elif HAS_SPI_LCD - #error "Marlin's Smoothieboard support cannot drive your LCD." + /* + The Smoothieboard supports the REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER with either + a custom cable with breakouts to the pins indicated below or the RRD GLCD Adapter board + found at http://smoothieware.org/rrdglcdadapter + + Other links to information about setting up a display panel with Smoothieboard + http://chibidibidiwah.wdfiles.com/local--files/panel/smoothieboard2sd.jpg + http://smoothieware.org/panel + */ + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + // EXP1 Pins + #define BEEPER_PIN P1_31 // EXP1 Pin 1 + #define BTN_ENC P1_30 // EXP1 Pin 2 + #define LCD_PINS_ENABLE P0_18 // EXP1 Pin 3 (MOSI) + #define LCD_PINS_RS P0_16 // EXP1 Pin 4 (CS) + #define LCD_PINS_D4 P0_15 // EXP1 Pin 5 (SCK) + // EXP2 Pins + #define BTN_EN2 P3_26 // EXP2 Pin 3 + #define BTN_EN1 P3_25 // EXP2 Pin 5 + + /* + SD Support + + For the RRD GLCD it CANNOT share the same SPI as the LCD so it must be + hooked up to the onboard SDCard SPI and use a spare pin for the SDCS. + Also note that an external SDCard sharing the SPI port with the + onboard/internal SDCard must be ejected before rebooting as the bootloader + does not like the external card. NOTE Smoothie will not boot if the external + sdcard is inserted in the RRD LCD sdcard slot at boot time, it must be + inserted after it has booted. + */ + + #define MISO_PIN P0_08 // EXP2 Pin 1 (PB3, SD_MISO) + #define SCK_PIN P0_07 // EXP2 Pin 2 (SD_SCK) + #define SS_PIN P0_28 // EXP2 Pin 4 (SD_CSEL, SD_CS) + #define MOSI_PIN P0_09 // EXP2 Pin 6 (PB2, SD_MOSI) + #define SD_DETECT_PIN P0_27 // EXP2 Pin 7 (SD_CD, SD_DET) + + #else + #error "Marlin's Smoothieboard support cannot drive your LCD." + #endif #endif + +/** + * I2C Digipots - MCP4451 + * Address 58 (2C << 1) + * Set from 0 - 127 with stop bit. + * (Ex. 3F << 1 | 1) + */ +#define DIGIPOTS_I2C_SCL P0_0 +#define DIGIPOTS_I2C_SDA_X P0_04 +#define DIGIPOTS_I2C_SDA_Y P0_10 +#define DIGIPOTS_I2C_SDA_Z P0_19 +#define DIGIPOTS_I2C_SDA_E0 P0_21 +#define DIGIPOTS_I2C_SDA_E1 P4_29 + +#ifndef DIGIPOT_I2C_ADDRESS_A + #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address (58 <- 2C << 1) +#endif diff --git a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h index a1d3b08caa8f..81f5b75016c3 100644 --- a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h @@ -89,7 +89,7 @@ #define E0_SERIAL_RX_PIN P0_21 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // diff --git a/Marlin/src/pins/mega/pins_INTAMSYS40.h b/Marlin/src/pins/mega/pins_INTAMSYS40.h index 19725eda2ffd..b6ff30a4fc23 100644 --- a/Marlin/src/pins/mega/pins_INTAMSYS40.h +++ b/Marlin/src/pins/mega/pins_INTAMSYS40.h @@ -82,7 +82,7 @@ // Motor current PWM conversion, PWM value = MotorCurrentSetting * 255 / range #ifndef MOTOR_CURRENT_PWM_RANGE - #define MOTOR_CURRENT_PWM_RANGE 2000 + #define MOTOR_CURRENT_PWM_RANGE 2000 #endif #define DEFAULT_PWM_MOTOR_CURRENT { 1300, 1300, 1250 } diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS.h b/Marlin/src/pins/mega/pins_MEGATRONICS.h index 84346e5f6696..2d98256fe71f 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS.h @@ -124,7 +124,7 @@ #define SD_DETECT_PIN -1 // RAMPS doesn't use this -#endif // HAS_SPI_LCD && NEWPANEL +#endif // ULTRA_LCD && NEWPANEL // // M3/M4/M5 - Spindle/Laser Control diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index efa99164208d..526c9bfc68b9 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -116,7 +116,7 @@ #define DIGIPOTS_I2C_SDA_E1 77 // J6 #ifndef DIGIPOT_I2C_ADDRESS_A - #define DIGIPOT_I2C_ADDRESS_A 0x2F // unshifted slave address (5E <- 2F << 1) + #define DIGIPOT_I2C_ADDRESS_A 0x2F // unshifted slave address (5E <- 2F << 1) #endif // diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 9b6be5a6e106..2dfb2b53b8ea 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -410,6 +410,8 @@ #include "lpc1769/pins_TH3D_EZBOARD.h" // LPC1769 env:LPC1769 #elif MB(BTT_SKR_V1_4_TURBO) #include "lpc1769/pins_BTT_SKR_V1_4_TURBO.h" // LPC1769 env:LPC1769 +#elif MB(MKS_SGEN_L_V2) + #include "lpc1769/pins_MKS_SGEN_L_V2.h" // LPC1769 env:LPC1769 // // Due (ATSAM) boards @@ -550,6 +552,8 @@ #include "stm32f1/pins_CHITU3D_V6.h" // STM32F1 env:chitu_f103 #elif MB(CREALITY_V4) #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RET6_creality +#elif MB(CREALITY_V427) + #include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RET6_creality #elif MB(TRIGORILLA_PRO) #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro @@ -604,6 +608,8 @@ #include "stm32f4/pins_FLYF407ZG.h" // STM32F4 env:FLYF407ZG #elif MB(MKS_ROBIN2) #include "stm32f4/pins_MKS_ROBIN2.h" // STM32F4 env:MKS_ROBIN2 +#elif MB(FYSETC_S6_V2_0) + #include "stm32f4/pins_FYSETC_S6_V2_0.h" // STM32F4 env:FYSETC_S6 // // ARM Cortex M7 diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 3307cbde97e8..ac15a3c9bae2 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -1421,3 +1421,22 @@ #if PIN_EXISTS(ESP_WIFI_MODULE_GPIO2) REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_GPIO2_PIN) #endif +// TFT PINS +#if PIN_EXISTS(TFT_CS) + REPORT_NAME_DIGITAL(__LINE__, TFT_CS_PIN) +#endif +#if PIN_EXISTS(TFT_A0) + REPORT_NAME_DIGITAL(__LINE__, TFT_A0_PIN) +#endif +#if PIN_EXISTS(TFT_DC) + REPORT_NAME_DIGITAL(__LINE__, TFT_DC_PIN) +#endif +#if PIN_EXISTS(TFT_MISO) + REPORT_NAME_DIGITAL(__LINE__, TFT_MISO_PIN) +#endif +#if PIN_EXISTS(TFT_BACKLIGHT) + REPORT_NAME_DIGITAL(__LINE__, TFT_BACKLIGHT_PIN) +#endif +#if PIN_EXISTS(TFT_RESET) + REPORT_NAME_DIGITAL(__LINE__, TFT_RESET_PIN) +#endif diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index 8fb3be47da54..e2a4940e8789 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -80,6 +80,13 @@ #define Z_MIN_PROBE_PIN 10 #endif +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 62 +#endif + // // Steppers // diff --git a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h index 0df977a05bbd..672c37241464 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h @@ -166,11 +166,11 @@ // // LCD / Controller // -#if HAS_SPI_LCD || TOUCH_UI_ULTIPANEL || ENABLED(TOUCH_UI_FTDI_EVE) +#if ANY(HAS_SPI_LCD, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) #define KILL_PIN 32 - #if ENABLED(ULTIPANEL) || TOUCH_UI_ULTIPANEL || ENABLED(TOUCH_UI_FTDI_EVE) + #if ANY(ULTIPANEL, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) #if ENABLED(CR10_STOCKDISPLAY) #define LCD_PINS_RS 85 @@ -194,5 +194,6 @@ #define SD_DETECT_PIN 15 - #endif // ULTIPANEL || TOUCH_UI_ULTIPANEL -#endif // HAS_SPI_LCD + #endif // ULTIPANEL || TOUCH_UI_ULTIPANEL || TOUCH_UI_FTDI_EVE + +#endif // HAS_SPI_LCD || TOUCH_UI_ULTIPANEL || TOUCH_UI_FTDI_EVE diff --git a/Marlin/src/pins/rambo/pins_MINIRAMBO.h b/Marlin/src/pins/rambo/pins_MINIRAMBO.h index f89bba2d7ff1..0c14d9f46b29 100644 --- a/Marlin/src/pins/rambo/pins_MINIRAMBO.h +++ b/Marlin/src/pins/rambo/pins_MINIRAMBO.h @@ -189,4 +189,4 @@ #endif // ULTIPANEL || TOUCH_UI_ULTIPANEL -#endif // HAS_SPI_LCD +#endif // HAS_SPI_LCD || TOUCH_UI_ULTIPANEL diff --git a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h index a23ada0aca2f..5eee450fc507 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h @@ -67,10 +67,10 @@ // DIGIPOT slave addresses #ifndef DIGIPOT_I2C_ADDRESS_A - #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for first DIGIPOT 0x2C (0x58 <- 0x2C << 1) + #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for first DIGIPOT 0x2C (0x58 <- 0x2C << 1) #endif #ifndef DIGIPOT_I2C_ADDRESS_B - #define DIGIPOT_I2C_ADDRESS_B 0x2E // unshifted slave address for second DIGIPOT 0x2E (0x5C <- 0x2E << 1) + #define DIGIPOT_I2C_ADDRESS_B 0x2E // unshifted slave address for second DIGIPOT 0x2E (0x5C <- 0x2E << 1) #endif // diff --git a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h index b2a412e305c8..1dc898e6ca9a 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h @@ -64,5 +64,5 @@ #define SUICIDE_PIN 12 // Used by CR2020 Industrial series #ifndef SUICIDE_PIN_INVERTING - #define SUICIDE_PIN_INVERTING true + #define SUICIDE_PIN_INVERTING true #endif diff --git a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h index 9af4a3e05c0f..bdd53abbc04d 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h @@ -74,7 +74,7 @@ #undef E0_CS_PIN #undef E1_CS_PIN -#if ENABLED(ULTRA_LCD, REPRAPWORLD_GRAPHICAL_LCD, CR10_STOCKDISPLAY) && !BOTH(NEWPANEL, PANEL_ONE) +#if ENABLED(ULTRA_LCD) && NONE(REPRAPWORLD_GRAPHICAL_LCD, CR10_STOCKDISPLAY) && !BOTH(NEWPANEL, PANEL_ONE) #if DISABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306) #undef LCD_PINS_RS #define LCD_PINS_RS 42 // 3DYMY boards pin 16 -> 42 diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index 708f8fa26cd6..412aa2290223 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -64,7 +64,7 @@ #elif TEMP_SENSOR_BED // EFB (Anycubic Kossel default) #define RAMPS_D9_PIN TG_FAN0_PIN - #if ENABLED(ANYCUBIC_CHIRON) + #if ENABLED(ANYCUBIC_LCD_CHIRON) #define RAMPS_D8_PIN TG_HEATER_1_PIN // Heated bed is connected to HEATER1 output #else #define RAMPS_D8_PIN TG_HEATER_BED_PIN @@ -84,7 +84,7 @@ #define E0_AUTO_FAN_PIN TG_FAN2_PIN // Used in Anycubic Kossel example config #endif -#if ENABLED(ANYCUBIC_I3MEGA) +#if ENABLED(ANYCUBIC_LCD_I3MEGA) #define CONTROLLER_FAN_PIN TG_FAN1_PIN #endif @@ -105,14 +105,14 @@ #if ENABLED(ANYCUBIC_4_MAX_PRO_ENDSTOPS) #define X_MAX_PIN 43 #define Y_STOP_PIN 19 -#elif EITHER(ANYCUBIC_CHIRON, ANYCUBIC_I3MEGA) +#elif EITHER(ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_I3MEGA) #define Y_STOP_PIN 42 #define Z2_MIN_PIN 43 #ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN 2 #endif #ifndef FIL_RUNOUT_PIN - #if ENABLED(ANYCUBIC_CHIRON) + #if ENABLED(ANYCUBIC_LCD_CHIRON) #define FIL_RUNOUT_PIN 33 #else #define FIL_RUNOUT_PIN 19 diff --git a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h index 955801558457..a44baf26e4d0 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h @@ -174,7 +174,7 @@ #define LCD_PINS_D6 32 #define LCD_PINS_D7 30 -#elif ENABLED(BOARD_REV_1_5, ULTRA_LCD) +#elif BOTH(BOARD_REV_1_5, ULTRA_LCD) #define BEEPER_PIN 18 diff --git a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h index 7cd81456b17d..4d08ed784d68 100644 --- a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h +++ b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h @@ -144,17 +144,16 @@ // LCD / Controller // #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) - #define LCD_PINS_RS 18 #define LCD_PINS_ENABLE 15 #define LCD_PINS_D4 19 #define BEEPER_PIN 64 + #undef UI_VOLTAGE_LEVEL + #define UI_VOLTAGE_LEVEL 1 +#endif +#if ENABLED(NEWPANEL) #define BTN_EN1 14 #define BTN_EN2 16 #define BTN_ENC 17 - - #undef UI_VOLTAGE_LEVEL - #define UI_VOLTAGE_LEVEL 1 - -#endif // REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +#endif diff --git a/Marlin/src/pins/sam/pins_ARCHIM2.h b/Marlin/src/pins/sam/pins_ARCHIM2.h index bbd4804dbd50..b527b511835f 100644 --- a/Marlin/src/pins/sam/pins_ARCHIM2.h +++ b/Marlin/src/pins/sam/pins_ARCHIM2.h @@ -237,7 +237,7 @@ // // LCD / Controller // -#if HAS_SPI_LCD || TOUCH_UI_ULTIPANEL || ENABLED(TOUCH_UI_FTDI_EVE) +#if ANY(HAS_SPI_LCD, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) #define BEEPER_PIN 23 // D24 PA15_CTS1 #define LCD_PINS_RS 17 // D17 PA12_RXD1 #define LCD_PINS_ENABLE 24 // D23 PA14_RTS1 @@ -248,10 +248,10 @@ #define SD_DETECT_PIN 2 // D2 PB25_TIOA0 - #if ENABLED(ULTIPANEL) || TOUCH_UI_ULTIPANEL || ENABLED(TOUCH_UI_FTDI_EVE) + #if ANY(ULTIPANEL, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) // Buttons on AUX-2 #define BTN_EN1 60 // D60 PA3_TIOB1 #define BTN_EN2 13 // D13 PB27_TIOB0 #define BTN_ENC 16 // D16 PA13_TXD1 // the click - #endif // ULTIPANEL || TOUCH_UI_ULTIPANEL -#endif // HAS_SPI_LCD + #endif +#endif diff --git a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h index b977ad1aba54..a2094bee4daf 100644 --- a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h +++ b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h @@ -92,7 +92,7 @@ // // Fans // -//#define FAN0_PIN 8 +//#define FAN_PIN 8 // // Auto fans diff --git a/Marlin/src/pins/sam/pins_DUE3DOM.h b/Marlin/src/pins/sam/pins_DUE3DOM.h index e0a56137f730..260a2810f5e8 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM.h @@ -147,7 +147,7 @@ #define SDSS 4 #define SD_DETECT_PIN 14 - #elif HAS_SSD1306_OLED_I2C + #elif HAS_U8GLIB_I2C_OLED #define BTN_EN1 50 #define BTN_EN2 52 diff --git a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h index 9a488e312682..946cadcfa943 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h @@ -139,7 +139,7 @@ #define SDSS 4 #define SD_DETECT_PIN 14 - #elif HAS_SSD1306_OLED_I2C + #elif HAS_U8GLIB_I2C_OLED #define BTN_EN1 50 #define BTN_EN2 52 diff --git a/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h b/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h index 5d8716b67887..be6b0fb2ed86 100644 --- a/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h +++ b/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h @@ -147,7 +147,7 @@ #define FET_SAFETY_PIN 31 // PA7 must be pulsed low every 50 mS or FETs are turned off #define FET_SAFETY_DELAY 50 // 50 mS delay between pulses -#define FET_SAFETY_INVERTED true // true - negative going pulse of 2 uS +#define FET_SAFETY_INVERTED true // true - negative going pulse of 2 uS ///////////////////////////////////////////////////////// diff --git a/Marlin/src/pins/sam/pins_RADDS.h b/Marlin/src/pins/sam/pins_RADDS.h index 78231afaffa2..bbbfb2e55826 100644 --- a/Marlin/src/pins/sam/pins_RADDS.h +++ b/Marlin/src/pins/sam/pins_RADDS.h @@ -36,7 +36,7 @@ // #if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x2000 // 8KB + #define MARLIN_EEPROM_SIZE 0x2000 // 8KB #endif // @@ -266,7 +266,7 @@ #define SDSS 10 #define SD_DETECT_PIN 14 - #elif HAS_SSD1306_OLED_I2C + #elif HAS_U8GLIB_I2C_OLED #define BTN_EN1 50 #define BTN_EN2 52 diff --git a/Marlin/src/pins/sam/pins_RAMPS_SMART.h b/Marlin/src/pins/sam/pins_RAMPS_SMART.h index 4c26d19cafdb..06eee2d970eb 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_SMART.h +++ b/Marlin/src/pins/sam/pins_RAMPS_SMART.h @@ -70,7 +70,7 @@ // I2C EEPROM with 4K of space #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 +#define MARLIN_EEPROM_SIZE 0x1000 #define RESET_PIN 42 // Resets the board if the jumper is attached diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index 22353611b61b..3ecd64aa8aee 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -186,7 +186,7 @@ // // EEPROM // -#define MARLIN_EEPROM_SIZE 0x8000 // 32Kb (24lc256) +#define MARLIN_EEPROM_SIZE 0x8000 // 32Kb (24lc256) #define I2C_EEPROM // EEPROM on I2C-0 //#define EEPROM_SD // EEPROM on SDCARD //#define SPI_EEPROM // EEPROM on SPI-0 @@ -221,7 +221,7 @@ #define LCD_PINS_RS 52 #define LCD_PINS_ENABLE 53 - #elif HAS_SSD1306_OLED_I2C + #elif HAS_U8GLIB_I2C_OLED #define BEEPER_PIN 62 #define LCD_SDSS 10 diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h index 19b8ac97754b..2b52338d35ca 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -172,7 +172,7 @@ // // EEPROM // -#define MARLIN_EEPROM_SIZE 0x8000 // 32Kb (24lc256) +#define MARLIN_EEPROM_SIZE 0x8000 // 32Kb (24lc256) #define I2C_EEPROM // EEPROM on I2C-0 //#define EEPROM_SD // EEPROM on SDCARD //#define SPI_EEPROM // EEPROM on SPI-0 @@ -207,7 +207,7 @@ #define LCD_PINS_RS 52 #define LCD_PINS_ENABLE 53 - #elif HAS_SSD1306_OLED_I2C + #elif HAS_U8GLIB_I2C_OLED #define BEEPER_PIN 62 #define LCD_SDSS 10 diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 319584b5eb56..93e758b3ae66 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -46,7 +46,7 @@ // //#define QSPI_EEPROM // Use AGCM4 onboard QSPI EEPROM (Uses 4K of RAM) #define I2C_EEPROM // EEPROM on I2C-0 -#define MARLIN_EEPROM_SIZE 0x8000 // 32K (24lc256) +#define MARLIN_EEPROM_SIZE 0x8000 // 32K (24lc256) // // Limit Switches diff --git a/Marlin/src/pins/sanguino/pins_ANET_10.h b/Marlin/src/pins/sanguino/pins_ANET_10.h index a2ef1e2c17dd..6830192f319b 100644 --- a/Marlin/src/pins/sanguino/pins_ANET_10.h +++ b/Marlin/src/pins/sanguino/pins_ANET_10.h @@ -163,7 +163,7 @@ #define LCD_PINS_D6 16 #define LCD_PINS_D7 17 #define ADC_KEYPAD_PIN 1 - #elif EITHER(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER, ANET_FULL_GRAPHICS_LCD) + #elif EITHER(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) // Pin definitions for the Anet A6 Full Graphics display and the RepRapDiscount Full Graphics // display using an adapter board // https://go.aisler.net/benlye/anet-lcd-adapter/pcb // See below for alternative pin definitions for use with https://www.thingiverse.com/thing:2103748 diff --git a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h index b8c2ed950392..d6a83aca1a30 100644 --- a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h +++ b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h @@ -43,8 +43,8 @@ // // Timers // -#define STEP_TIMER 6 -#define TEMP_TIMER 7 +#define STEP_TIMER 6 +#define TEMP_TIMER 7 // // Limit Switches 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 3801a9bae4b5..cff34daf2f02 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -31,7 +31,7 @@ #define DISABLE_JTAG // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION @@ -138,7 +138,7 @@ #define E0_SERIAL_RX_PIN PD2 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // @@ -158,7 +158,7 @@ // USB connect control // #define USB_CONNECT_PIN PC13 -#define USB_CONNECT_INVERTING false +#define USB_CONNECT_INVERTING false /** * _____ @@ -260,7 +260,7 @@ * */ - #define CLCD_SPI_BUS 1 // SPI1 connector + #define CLCD_SPI_BUS 1 // SPI1 connector #define BEEPER_PIN PB6 @@ -288,5 +288,5 @@ #error "SD CUSTOM_CABLE is not compatible with SKR E3 DIP." #endif -#define ON_BOARD_SPI_DEVICE 1 // SPI1 +#define ON_BOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card 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 a8df0e5c02df..923b0fa4c1b2 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 @@ -29,7 +29,7 @@ #define DISABLE_JTAG // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION @@ -108,7 +108,7 @@ #define USB_CONNECT_PIN PC13 #endif -#define USB_CONNECT_INVERTING false +#define USB_CONNECT_INVERTING false /** * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 @@ -208,7 +208,7 @@ * */ - #define CLCD_SPI_BUS 1 // SPI1 connector + #define CLCD_SPI_BUS 1 // SPI1 connector #define BEEPER_PIN EXP1_9 @@ -236,5 +236,5 @@ #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." #endif -#define ON_BOARD_SPI_DEVICE 1 // SPI1 +#define ON_BOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card 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 db31eb377fcb..4a12d5d32db0 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 @@ -31,7 +31,7 @@ #define DISABLE_JTAG // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION @@ -213,5 +213,5 @@ #define MOSI_PIN PA7 #define SS_PIN PA4 #endif -#define ON_BOARD_SPI_DEVICE 1 // SPI1 +#define ON_BOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index f99721f144a6..5254166fa576 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -43,9 +43,9 @@ // #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE 0x800U // 2KB + #define EEPROM_PAGE_SIZE 0x800U // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // @@ -95,7 +95,7 @@ #define E0_SERIAL_RX_PIN PC4 // Reduce baud rate to improve software serial reliability -#define TMC_BAUD_RATE 19200 +#define TMC_BAUD_RATE 19200 // // Temperature Sensors @@ -113,7 +113,7 @@ #define FAN1_PIN PA8 // FAN (fan0 on board) e0 cool fan #define FAN2_PIN PB9 // FAN (fan1 on board) controller cool fan -// One neopixel onboard and a connector for other neopixels +// One NeoPixel onboard and a connector for other NeoPixels #define NEOPIXEL_PIN PC7 // The NEOPIXEL LED driving pin /** @@ -173,7 +173,7 @@ #define SS_PIN PA4 #endif -#define ON_BOARD_SPI_DEVICE 1 // SPI1 +#define ON_BOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for SD-NAND #endif diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D.h b/Marlin/src/pins/stm32f1/pins_CHITU3D.h index e3b7d2f547cf..bf9a7d8e0543 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D.h @@ -36,7 +36,7 @@ //#define I2C_EEPROM // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Steppers diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h index e4f0014417b1..54ff9a779a30 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h @@ -44,7 +44,7 @@ #define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB) #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE #else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM #endif // @@ -104,49 +104,6 @@ //#define POWER_LOSS_PIN -1 #define FIL_RUNOUT_PIN PA15 -// -// TronXY TFT Support -// -//#define FSMC_GRAPHICAL_TFT -//#define HAS_TOUCH_XPT2046 1 - -#if ENABLED(FSMC_GRAPHICAL_TFT) - #define FSMC_UPSCALE 3 - - #define LCD_RESET_PIN PF11 - #define LCD_BACKLIGHT_PIN PD13 - #define FSMC_CS_PIN PD7 - #define FSMC_RS_PIN PD11 - - #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 - - #if NEED_TOUCH_PINS - #define TOUCH_CS_PIN PB7 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - - #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens - #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus - - #ifndef XPT2046_X_CALIBRATION - #define XPT2046_X_CALIBRATION -12316 - #endif - #ifndef XPT2046_Y_CALIBRATION - #define XPT2046_Y_CALIBRATION 8981 - #endif - #ifndef XPT2046_X_OFFSET - #define XPT2046_X_OFFSET 340 - #endif - #ifndef XPT2046_Y_OFFSET - #define XPT2046_Y_OFFSET -20 - #endif - - #endif -#endif - // SPI Flash #define SPI_FLASH_SIZE 0x200000 // 2MB #define HAS_SPI_FLASH 1 @@ -157,28 +114,18 @@ #define W25QXX_MISO_PIN PB14 #define W25QXX_SCK_PIN PB13 -#if HAS_TFT_LVGL_UI - #define HAS_SPI_FLASH_FONT 1 - #define HAS_GCODE_PREVIEW 1 - #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0 - #define HAS_LANG_SELECT_SCREEN 1 - #define HAS_BAK_VIEW_IN_FLASH 0 - #define HAS_LOGO_IN_FLASH 0 +// +// TronXY TFT Support +// + +#if HAS_FSMC_TFT + + // Shared FSMC #define TOUCH_CS_PIN PB7 // SPI1_NSS #define TOUCH_SCK_PIN PA5 // SPI1_SCK #define TOUCH_MISO_PIN PA6 // SPI1_MISO #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - //#define TOUCH_INT_PIN PB6 - - #if ENABLED(TFT_LVGL_UI_SPI) - #define SPI_TFT_CS_PIN TOUCH_CS_PIN - #define SPI_TFT_SCK_PIN TOUCH_SCK_PIN - #define SPI_TFT_MISO_PIN TOUCH_MISO_PIN - #define SPI_TFT_MOSI_PIN TOUCH_MOSI_PIN - #define SPI_TFT_DC_PIN PB6 - #define SPI_TFT_RST_PIN PF11 - #endif #define LCD_RESET_PIN PF11 #define LCD_BACKLIGHT_PIN PD13 @@ -191,12 +138,23 @@ #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 - #define LCD_PIXEL_WIDTH 480 - #define LCD_PIXEL_HEIGHT 320 - #define LCD_FULL_PIXEL_WIDTH LCD_PIXEL_WIDTH - #define LCD_FULL_PIXEL_HEIGHT LCD_PIXEL_HEIGHT - #define LCD_PIXEL_OFFSET_X 48 - #define LCD_PIXEL_OFFSET_Y 48 + #define TFT_WIDTH 480 + #define TFT_HEIGHT 320 + #define TFT_PIXEL_OFFSET_X 48 + #define TFT_PIXEL_OFFSET_Y 32 + +#endif + +#if HAS_TFT_LVGL_UI + + // LVGL + + #define HAS_SPI_FLASH_FONT 1 + #define HAS_GCODE_PREVIEW 1 + #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0 + #define HAS_LANG_SELECT_SCREEN 1 + #define HAS_BAK_VIEW_IN_FLASH 0 + #define HAS_LOGO_IN_FLASH 0 #define XPT2046_X_CALIBRATION -17181 #define XPT2046_Y_CALIBRATION 11434 @@ -204,31 +162,38 @@ #define XPT2046_Y_OFFSET -9 #elif ENABLED(TFT_480x320) - #define TFT_RESET_PIN PF11 - #define TFT_BACKLIGHT_PIN PD13 - #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT - #define FSMC_CS_PIN PD7 - #define FSMC_RS_PIN PD11 - #define FSMC_DMA_DEV DMA2 - #define FSMC_DMA_CHANNEL DMA_CH5 + // Color UI + + #define TFT_DRIVER ILI9488 + #define TFT_BUFFER_SIZE 14400 #define XPT2046_X_CALIBRATION -17181 #define XPT2046_Y_CALIBRATION 11434 #define XPT2046_X_OFFSET 501 #define XPT2046_Y_OFFSET -9 - #define TOUCH_CS_PIN PB7 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI +#elif ENABLED(FSMC_GRAPHICAL_TFT) - #define TFT_DRIVER ILI9488 - #define TFT_BUFFER_SIZE 14400 + // Emulated DOGM + + #define GRAPHICAL_TFT_UPSCALE 3 + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION -12316 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION 8981 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET 340 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET -20 + #endif #endif // SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available -// We nee to use the SPI2 +// Needs to use SPI2 #define ENABLE_SPI2 #define SCK_PIN PB13 #define MISO_PIN PB14 @@ -240,5 +205,5 @@ // #define SDIO_SUPPORT #define SD_DETECT_PIN -1 // PF0, but it isn't connected -#define SDIO_CLOCK 4500000 -#define SDIO_READ_RETRIES 16 +#define SDIO_CLOCK 4500000 +#define SDIO_READ_RETRIES 16 diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h index 3d36de82424f..a825db275c6a 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h @@ -48,7 +48,7 @@ #define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB) #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE #else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM #endif // @@ -96,7 +96,7 @@ // #define HEATER_0_PIN PG12 // HEATER1 #define HEATER_BED_PIN PG11 // HOT BED -//#define HEATER_BED_INVERTING true +//#define HEATER_BED_INVERTING true // // Fans @@ -119,71 +119,9 @@ #define FIL_RUNOUT2_PIN PF13 #endif -// -// TronXY TFT Support -// -#if ENABLED(FSMC_GRAPHICAL_TFT) - #define FSMC_UPSCALE 3 - - #define LCD_RESET_PIN PF11 - #define LCD_BACKLIGHT_PIN PD13 - #define FSMC_CS_PIN PD7 - #define FSMC_RS_PIN PD11 - - #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 - - #if NEED_TOUCH_PINS - #define TOUCH_CS_PIN PB7 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - - #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens - #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus - - #ifndef XPT2046_X_CALIBRATION - #define XPT2046_X_CALIBRATION -12316 - #endif - #ifndef XPT2046_Y_CALIBRATION - #define XPT2046_Y_CALIBRATION 8981 - #endif - #ifndef XPT2046_X_OFFSET - #define XPT2046_X_OFFSET 340 - #endif - #ifndef XPT2046_Y_OFFSET - #define XPT2046_Y_OFFSET -20 - #endif - #endif - -#elif ENABLED(TFT_480x320) - #define TFT_RESET_PIN PF11 - #define TFT_BACKLIGHT_PIN PD13 - - #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT - #define FSMC_CS_PIN PD7 - #define FSMC_RS_PIN PD11 - #define FSMC_DMA_DEV DMA2 - #define FSMC_DMA_CHANNEL DMA_CH5 - - #define XPT2046_X_CALIBRATION -17181 - #define XPT2046_Y_CALIBRATION 11434 - #define XPT2046_X_OFFSET 501 - #define XPT2046_Y_OFFSET -9 - - #define TOUCH_CS_PIN PB7 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - - #define TFT_DRIVER ILI9488 - #define TFT_BUFFER_SIZE 14400 -#endif - // SPI Flash -#define SPI_FLASH_SIZE 0x200000 // 2MB -#define HAS_SPI_FLASH 1 +#define SPI_FLASH_SIZE 0x200000 // 2MB +#define HAS_SPI_FLASH 1 // SPI 2 #define W25QXX_CS_PIN PB12 @@ -191,28 +129,16 @@ #define W25QXX_MISO_PIN PB14 #define W25QXX_SCK_PIN PB13 -#if HAS_TFT_LVGL_UI - #define HAS_SPI_FLASH_FONT 0 - #define HAS_GCODE_PREVIEW 1 - #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0 - #define HAS_LANG_SELECT_SCREEN 0 - #define HAS_BAK_VIEW_IN_FLASH 0 - #define HAS_LOGO_IN_FLASH 0 +// +// TronXY TFT Support +// +// Shared FSMC Configs +#if HAS_FSMC_TFT #define TOUCH_CS_PIN PB7 // SPI1_NSS #define TOUCH_SCK_PIN PA5 // SPI1_SCK #define TOUCH_MISO_PIN PA6 // SPI1_MISO #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - //#define TOUCH_INT_PIN PB6 - - #if ENABLED(TFT_LVGL_UI_SPI) - #define SPI_TFT_CS_PIN TOUCH_CS_PIN - #define SPI_TFT_SCK_PIN TOUCH_SCK_PIN - #define SPI_TFT_MISO_PIN TOUCH_MISO_PIN - #define SPI_TFT_MOSI_PIN TOUCH_MOSI_PIN - #define SPI_TFT_DC_PIN PB6 - #define SPI_TFT_RST_PIN PF11 - #endif #define LCD_RESET_PIN PF11 #define LCD_BACKLIGHT_PIN PD13 @@ -225,17 +151,56 @@ #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 - #define LCD_PIXEL_WIDTH 480 - #define LCD_PIXEL_HEIGHT 320 - #define LCD_FULL_PIXEL_WIDTH LCD_PIXEL_WIDTH - #define LCD_FULL_PIXEL_HEIGHT LCD_PIXEL_HEIGHT - #define LCD_PIXEL_OFFSET_X 48 - #define LCD_PIXEL_OFFSET_Y 48 + #define TFT_WIDTH 480 + #define TFT_HEIGHT 320 + #define TFT_PIXEL_OFFSET_X 48 + #define TFT_PIXEL_OFFSET_Y 32 + +#endif + +// LVGL Configs +#if HAS_TFT_LVGL_UI + + #define HAS_SPI_FLASH_FONT 1 + #define HAS_GCODE_PREVIEW 1 + #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0 + #define HAS_LANG_SELECT_SCREEN 1 + #define HAS_BAK_VIEW_IN_FLASH 0 + #define HAS_LOGO_IN_FLASH 0 #define XPT2046_X_CALIBRATION -17181 #define XPT2046_Y_CALIBRATION 11434 #define XPT2046_X_OFFSET 501 #define XPT2046_Y_OFFSET -9 + +// Color UI Configs +#elif ENABLED(TFT_480x320) + + #define TFT_DRIVER ILI9488 + #define TFT_BUFFER_SIZE 14400 + + #define XPT2046_X_CALIBRATION -17181 + #define XPT2046_Y_CALIBRATION 11434 + #define XPT2046_X_OFFSET 501 + #define XPT2046_Y_OFFSET -9 + +// Emulated DOGM +#elif ENABLED(FSMC_GRAPHICAL_TFT) + #define GRAPHICAL_TFT_UPSCALE 3 + + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION -12316 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION 8981 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET 340 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET -20 + #endif + #endif // SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available @@ -251,5 +216,5 @@ // #define SDIO_SUPPORT #define SD_DETECT_PIN -1 // PF0, but it isn't connected -#define SDIO_CLOCK 4500000 -#define SDIO_READ_RETRIES 16 +#define SDIO_CLOCK 4500000 +#define SDIO_READ_RETRIES 16 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index ed281eb00c21..090f3ee3f8f9 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -32,8 +32,12 @@ #error "CREALITY supports up to 1 hotends / E-steppers. Comment out this line to continue." #endif -#define BOARD_INFO_NAME "CREALITY V4" -#define DEFAULT_MACHINE_NAME "Ender 3 V2" +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Creality V4" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "Ender 3 V2" +#endif // // EEPROM @@ -47,10 +51,10 @@ #if ENABLED(IIC_BL24CXX_EEPROM) #define IIC_EEPROM_SDA PA11 #define IIC_EEPROM_SCL PA12 - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) + #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) #else #define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb + #define MARLIN_EEPROM_SIZE 0x800 // 2Kb #endif // SPI @@ -77,7 +81,7 @@ #define Y_STOP_PIN PA6 #define Z_STOP_PIN PA7 -#define Z_PROBE_PIN PB1 // BLTouch IN +#define Z_MIN_PROBE_PIN PB1 // BLTouch IN // // Filament Runout Sensor @@ -90,20 +94,36 @@ // Steppers // #define X_ENABLE_PIN PC3 -#define X_STEP_PIN PC2 -#define X_DIR_PIN PB9 +#ifndef X_STEP_PIN + #define X_STEP_PIN PC2 +#endif +#ifndef X_DIR_PIN + #define X_DIR_PIN PB9 +#endif #define Y_ENABLE_PIN PC3 -#define Y_STEP_PIN PB8 -#define Y_DIR_PIN PB7 +#ifndef Y_STEP_PIN + #define Y_STEP_PIN PB8 +#endif +#ifndef Y_DIR_PIN + #define Y_DIR_PIN PB7 +#endif #define Z_ENABLE_PIN PC3 -#define Z_STEP_PIN PB6 -#define Z_DIR_PIN PB5 +#ifndef Z_STEP_PIN + #define Z_STEP_PIN PB6 +#endif +#ifndef Z_DIR_PIN + #define Z_DIR_PIN PB5 +#endif #define E0_ENABLE_PIN PC3 -#define E0_STEP_PIN PB4 -#define E0_DIR_PIN PB3 +#ifndef E0_STEP_PIN + #define E0_STEP_PIN PB4 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN PB3 +#endif // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role @@ -130,9 +150,14 @@ // #define SD_DETECT_PIN PC7 #define SDCARD_CONNECTION ONBOARD -#define ON_BOARD_SPI_DEVICE 1 +#define ON_BOARD_SPI_DEVICE 1 #define ONBOARD_SD_CS_PIN PA4 // SDSS #define SDIO_SUPPORT +#define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer + +#if ENABLED(CR10_STOCKDISPLAY) && 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 #if ENABLED(RET6_12864_LCD) @@ -146,6 +171,7 @@ #define BTN_EN2 PB14 #define BEEPER_PIN PC6 + #elif ENABLED(VET6_12864_LCD) /* VET6 12864 LCD */ @@ -165,7 +191,10 @@ #define BTN_EN2 PB12 //#define LCD_LED_PIN PB2 - #define BEEPER_PIN PB13 + #ifndef BEEPER_PIN + #define BEEPER_PIN PB13 + #undef SPEAKER + #endif #elif ENABLED(DWIN_VET6_CREALITY_LCD) diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h new file mode 100644 index 000000000000..9453a6d515b2 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h @@ -0,0 +1,48 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 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 . + * + */ + +/** + * CREALITY v4.2.7 (STM32F103) board pin assignments + */ + +#ifndef __STM32F1__ + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "Creality v4.2.7" +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Steppers +// +#define X_STEP_PIN PB9 +#define X_DIR_PIN PC2 +#define Y_STEP_PIN PB7 + +#define Y_DIR_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB6 + +#define E0_STEP_PIN PB3 +#define E0_DIR_PIN PB4 + +#include "pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index 6a30a2cb23ce..ca9364a570d9 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -33,7 +33,7 @@ #define pins_v2_20190128 // new pins define // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Flash EEPROM Emulation @@ -112,7 +112,7 @@ // Stepper current PWM // #ifndef MOTOR_CURRENT_PWM_RANGE - #define MOTOR_CURRENT_PWM_RANGE 1500 // origin:2000 + #define MOTOR_CURRENT_PWM_RANGE 1500 // origin:2000 #endif #define DEFAULT_PWM_MOTOR_CURRENT { 500, 500, 400 } // origin: {1300,1300,1250} @@ -152,7 +152,7 @@ #define DOGLCD_CS PB7 #endif - //#define LCD_CONTRAST_INIT 190 + //#define LCD_CONTRAST_INIT 190 //#define LCD_SCREEN_ROT_90 //#define LCD_SCREEN_ROT_180 //#define LCD_SCREEN_ROT_270 diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index 7143176bd7fc..1f5e70a15a28 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -32,7 +32,7 @@ // https://github.com/FYSETC/Cheetah // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 #define DISABLE_JTAG @@ -151,7 +151,7 @@ #define LCD_PINS_D4 PB13 // SCLK #define LCD_PINS_ENABLE PB15 // DATA MOSI - //#define LCD_CONTRAST_INIT 190 + //#define LCD_CONTRAST_INIT 190 #if ENABLED(NEWPANEL) #define BTN_EN1 PC10 @@ -172,6 +172,6 @@ #define CLCD_SOFT_SPI_MISO PB14 #define CLCD_SOFT_SPI_SCLK PB13 #else - #define CLCD_SPI_BUS 2 + #define CLCD_SPI_BUS 2 #endif #endif diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h index 03f9ce0216e4..fe6c0b1325c9 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h @@ -49,12 +49,12 @@ //#define DISABLE_JTAGSWD // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // @@ -236,6 +236,6 @@ // ESP WiFi can be soldered to J9 connector which is wired to USART2. // Must define WIFISUPPORT in Configuration.h for the printer. // -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115200 +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115200 #define ESP_WIFI_MODULE_RESET_PIN -1 diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h index 3f5a39a90c03..716de610a710 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h @@ -49,12 +49,12 @@ //#define DISABLE_JTAGSWD // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // @@ -230,6 +230,6 @@ // ESP WiFi can be soldered to J9 connector which is wired to USART2. // Must define WIFISUPPORT in Configuration.h for the printer. // -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115200 +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115200 #define ESP_WIFI_MODULE_RESET_PIN -1 diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index 03f9ce0216e4..fe6c0b1325c9 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -49,12 +49,12 @@ //#define DISABLE_JTAGSWD // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // @@ -236,6 +236,6 @@ // ESP WiFi can be soldered to J9 connector which is wired to USART2. // Must define WIFISUPPORT in Configuration.h for the printer. // -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115200 +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115200 #define ESP_WIFI_MODULE_RESET_PIN -1 diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h index c39c89e42cec..1fc4fa94249e 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h @@ -49,12 +49,12 @@ //#define DISABLE_JTAGSWD // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // @@ -233,6 +233,6 @@ // ESP WiFi can be soldered to J9 connector which is wired to USART2. // Must define WIFISUPPORT in Configuration.h for the printer. // -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115200 +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115200 #define ESP_WIFI_MODULE_RESET_PIN -1 diff --git a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h index dcd1c868f4c0..d474eb25f6a7 100644 --- a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -43,10 +43,10 @@ // Enable EEPROM Emulation for this board, so that we don't overwrite factory data //#define I2C_EEPROM // AT24C64 -//#define MARLIN_EEPROM_SIZE 0x8000UL // 64KB +//#define MARLIN_EEPROM_SIZE 0x8000UL // 64KB //#define FLASH_EEPROM_EMULATION -//#define MARLIN_EEPROM_SIZE 0x1000UL // 4KB +//#define MARLIN_EEPROM_SIZE 0x1000UL // 4KB //#define MARLIN_EEPROM_SIZE (EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE) * 2UL) //#define EEPROM_CHITCHAT diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 2f5dbd010564..d08045ec16d5 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -86,8 +86,8 @@ #define FAN_PIN PA15 // pin 77 (4cm Fan) #define FAN_SOFT_PWM // Required to avoid issues with heating or STLink -#define FAN_MIN_PWM 35 // Fan will not start in 1-30 range -#define FAN_MAX_PWM 255 +#define FAN_MIN_PWM 35 // Fan will not start in 1-30 range +#define FAN_MAX_PWM 255 //#define BEEPER_PIN PD13 // pin 60 (Servo PWM output 5V/GND on Board V0G+) made for BL-Touch sensor // Can drive a PC Buzzer, if connected between PWM and 5V pins @@ -119,17 +119,26 @@ */ #define LCD_RESET_PIN PC4 // pin 33 -#define LCD_BACKLIGHT_PIN PD12 // pin 59 +#define TFT_RESET_PIN PC4 // pin 33 +#define TFT_BACKLIGHT_PIN PD12 // pin 59 #define FSMC_CS_PIN PD7 // pin 88 = FSMC_NE1 #define FSMC_RS_PIN PD11 // pin 58 A16 Register. Only one address needed -#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT +//#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT (broken) #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 #define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h #define DOGLCD_SCK -1 +#define GRAPHICAL_TFT_UPSCALE 2 +#define TFT_WIDTH 320 +#define TFT_HEIGHT 240 +#define TFT_PIXEL_OFFSET_X 32 +#define TFT_PIXEL_OFFSET_Y 32 + +//#define TFT_DRIVER ILI9341 + /** * Note: Alfawise U20/U30 boards DON'T use SPI2, as the hardware designer * mixed up MOSI and MISO pins. SPI is managed in SW, and needs pins @@ -154,12 +163,12 @@ #if ENABLED(SPI_EEPROM) // SPI1 EEPROM Winbond W25Q64 (8MB/64Mbits) - #define SPI_CHAN_EEPROM1 1 + #define SPI_CHAN_EEPROM1 1 #define SPI_EEPROM1_CS PC5 // pin 34 #define EEPROM_SCK BOARD_SPI1_SCK_PIN // PA5 pin 30 #define EEPROM_MISO BOARD_SPI1_MISO_PIN // PA6 pin 31 #define EEPROM_MOSI BOARD_SPI1_MOSI_PIN // PA7 pin 32 - #define EEPROM_PAGE_SIZE 0x1000U // 4KB (from datasheet) + #define EEPROM_PAGE_SIZE 0x1000U // 4KB (from datasheet) #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64KB for now... #elif ENABLED(FLASH_EEPROM_EMULATION) // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) @@ -167,5 +176,5 @@ #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) #else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM #endif diff --git a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h index 6a8f316b0dc2..39c52ab0d30e 100644 --- a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h +++ b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h @@ -44,8 +44,8 @@ // On STM32F103: // PB3, PB6, PB7, and PB8 can be used with pwm, which rules out TIM2 and TIM4. // On STM32F070, 16 and 17 are in use, but 1 and 3 are available. -#define STEP_TIMER 1 -#define TEMP_TIMER 3 +#define STEP_TIMER 1 +#define TEMP_TIMER 3 // // Limit Switches diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index 5193ddad2329..1ab9165830e0 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -212,6 +212,6 @@ // Reduce baud rate for software serial reliability #if HAS_TMC_SW_SERIAL - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h index 0f55de824573..9461a828af01 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -33,7 +33,6 @@ //#define DISABLE_DEBUG #define DISABLE_JTAG -#define ENABLE_SPI2 // // EEPROM @@ -105,7 +104,7 @@ #define E0_SERIAL_RX_PIN PC11 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // @@ -152,8 +151,6 @@ #define DOGLCD_SCK PB13 #define DOGLCD_MOSI PB15 - #undef SHOW_BOOTSCREEN - #else #define LCD_PINS_D4 PA6 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h index 9cf8685dfab5..6ce6c6010501 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h @@ -115,8 +115,6 @@ #define DOGLCD_SCK PB13 #define DOGLCD_MOSI PB15 - #undef SHOW_BOOTSCREEN - #else // !MKS_MINI_12864 #define LCD_PINS_D4 PA6 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index 716cb1637556..19b04c9e7c6f 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -81,14 +81,13 @@ #define E0_STEP_PIN PD6 #define E0_DIR_PIN PD3 - // Motor current PWM pins #define MOTOR_CURRENT_PWM_XY_PIN PA6 #define MOTOR_CURRENT_PWM_Z_PIN PA7 #define MOTOR_CURRENT_PWM_E_PIN PB0 #define MOTOR_CURRENT_PWM_RANGE 1500 // (255 * (1000mA / 65535)) * 257 = 1000 is equal 1.6v Vref in turn equal 1Amp #ifndef DEFAULT_PWM_MOTOR_CURRENT - #define DEFAULT_PWM_MOTOR_CURRENT { 800, 800, 800 } + #define DEFAULT_PWM_MOTOR_CURRENT { 800, 800, 800 } #endif // // Temperature Sensors @@ -113,7 +112,7 @@ #define SERVO0_PIN PA8 // Enable BLTOUCH support on IO0 (WIFI connector) #define MT_DET_1_PIN PA4 -#define MT_DET_PIN_INVERTING false +#define MT_DET_PIN_INVERTING false #define WIFI_IO0_PIN PC13 @@ -149,9 +148,9 @@ #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 - #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #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 FSMC_DMA_CHANNEL DMA_CH5 #define LCD_RESET_PIN PC6 // FSMC_RST #define LCD_BACKLIGHT_PIN PD13 @@ -163,7 +162,7 @@ #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI #endif -#elif ENABLED(TFT_320x240) //TFT32/28 +#elif ENABLED(TFT_320x240) //TFT32/28 #define TFT_RESET_PIN PC6 #define TFT_BACKLIGHT_PIN PD13 @@ -181,7 +180,7 @@ #define TFT_DRIVER ILI9341 #define TFT_BUFFER_SIZE 14400 - + // YV for normal screen mounting #define ILI9341_ORIENTATION ILI9341_MADCTL_MY | ILI9341_MADCTL_MV // XV for 180° rotated screen mounting @@ -190,7 +189,7 @@ #define ILI9341_COLOR_RGB #endif -#define HAS_SPI_FLASH 1 +#define HAS_SPI_FLASH 1 #define SPI_FLASH_SIZE 0x1000000 // 16MB #if HAS_SPI_FLASH #define W25QXX_CS_PIN PB12 // Flash chip-select diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index 948663f6f059..d66338b8ad32 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -127,10 +127,10 @@ #define PS_ON_PIN PA3 // PW_OFF //#define SUICIDE_PIN PB2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY -//#define SUICIDE_PIN_INVERTING false +//#define SUICIDE_PIN_INVERTING false //#define KILL_PIN PA2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY -//#define KILL_PIN_INVERTING true // Enable MKSPWC support ROBIN NANO v1.2 ONLY +//#define KILL_PIN_INVERTING true // Enable MKSPWC support ROBIN NANO v1.2 ONLY #define SERVO0_PIN PA8 // Enable BLTOUCH support ROBIN NANO v1.2 ONLY @@ -138,7 +138,7 @@ #define MT_DET_1_PIN PA4 #define MT_DET_2_PIN PE6 -#define MT_DET_PIN_INVERTING false +#define MT_DET_PIN_INVERTING false #define WIFI_IO0_PIN PC13 @@ -150,7 +150,7 @@ #endif #define SDIO_SUPPORT -#define SDIO_CLOCK 4500000 // 4.5 MHz +#define SDIO_CLOCK 4500000 // 4.5 MHz #define SD_DETECT_PIN PD12 #define ONBOARD_SD_CS_PIN PC11 @@ -165,8 +165,8 @@ * to let the bootloader init the screen. */ -#if ENABLED(TFT_LVGL_UI_FSMC) - +// Shared FSMC Configs +#if HAS_FSMC_TFT #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 @@ -175,12 +175,11 @@ #define TOUCH_MISO_PIN PB14 // SPI2_MISO #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + #define LCD_RESET_PIN PC6 // FSMC_RST #define LCD_BACKLIGHT_PIN PD13 - #define XPT2046_X_CALIBRATION 17880 - #define XPT2046_Y_CALIBRATION -12234 - #define XPT2046_X_OFFSET -45 - #define XPT2046_Y_OFFSET 349 + #define TFT_RESET_PIN PC6 // FSMC_RST + #define TFT_BACKLIGHT_PIN PD13 #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT #define FSMC_CS_PIN PD7 @@ -188,45 +187,62 @@ #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 +#endif + +// LVGL Configs +#if ENABLED(TFT_LVGL_UI_FSMC) + + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION 17880 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION -12234 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET -45 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET 349 + #endif + +// Emulated DOGM Configs #elif ENABLED(FSMC_GRAPHICAL_TFT) #define DOGLCD_MOSI -1 // prevent redefine Conditionals_post.h #define DOGLCD_SCK -1 - #ifndef FSMC_UPSCALE - #define FSMC_UPSCALE 3 + #ifndef GRAPHICAL_TFT_UPSCALE + #define GRAPHICAL_TFT_UPSCALE 3 #endif - #ifndef LCD_FULL_PIXEL_WIDTH - #define LCD_FULL_PIXEL_WIDTH 480 + #ifndef TFT_WIDTH + #define TFT_WIDTH 480 #endif - #ifndef LCD_PIXEL_OFFSET_X - #define LCD_PIXEL_OFFSET_X 48 + #ifndef TFT_PIXEL_OFFSET_X + #define TFT_PIXEL_OFFSET_X 48 #endif - #ifndef LCD_FULL_PIXEL_HEIGHT - #define LCD_FULL_PIXEL_HEIGHT 320 + #ifndef TFT_HEIGHT + #define TFT_HEIGHT 320 #endif - #ifndef LCD_PIXEL_OFFSET_Y - #define LCD_PIXEL_OFFSET_Y 32 + #ifndef TFT_PIXEL_OFFSET_Y + #define TFT_PIXEL_OFFSET_Y 32 #endif - #define FSMC_CS_PIN PD7 // NE4 - #define FSMC_RS_PIN PD11 // A0 - - #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT - #define FSMC_DMA_DEV DMA2 - #define FSMC_DMA_CHANNEL DMA_CH5 - - #define LCD_RESET_PIN PC6 // FSMC_RST - #define LCD_BACKLIGHT_PIN PD13 - - #if NEED_TOUCH_PINS - #define TOUCH_CS_PIN PA7 // SPI2_NSS - #define TOUCH_SCK_PIN PB13 // SPI2_SCK - #define TOUCH_MISO_PIN PB14 // SPI2_MISO - #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION 12149 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION -8746 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET -35 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET 256 #endif -#elif ENABLED(TFT_480x320) +#elif ENABLED(TFT_320x240) // TFT32/28 #define TFT_RESET_PIN PC6 #define TFT_BACKLIGHT_PIN PD13 @@ -236,23 +252,55 @@ #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 - #define XPT2046_X_CALIBRATION 17880 - #define XPT2046_Y_CALIBRATION -12234 - #define XPT2046_X_OFFSET -45 - #define XPT2046_Y_OFFSET 349 + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION -12246 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION 9453 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET 360 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET -22 + #endif #define TOUCH_CS_PIN PA7 // SPI2_NSS - #define TOUCH_SCK_PIN PB13 // SPI2_SCK - #define TOUCH_MISO_PIN PB14 // SPI2_MISO - #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + #define TOUCH_SCK_PIN PB13 // SPI2_SCK + #define TOUCH_MISO_PIN PB14 // SPI2_MISO + #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + + #define TFT_DRIVER ILI9341 + #define TFT_BUFFER_SIZE 14400 + + // YV for normal screen mounting + //#define ILI9341_ORIENTATION ILI9341_MADCTL_MY | ILI9341_MADCTL_MV + // XV for 180° rotated screen mounting + #define ILI9341_ORIENTATION ILI9341_MADCTL_MX | ILI9341_MADCTL_MV + + #define ILI9341_COLOR_RGB + +#elif ENABLED(TFT_480x320) + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION 17880 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION -12234 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET -45 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET 349 + #endif - #define TFT_DRIVER ILI9488 - #define TFT_BUFFER_SIZE 14400 + #define TFT_DRIVER ILI9488 + #define TFT_BUFFER_SIZE 14400 #define ILI9488_ORIENTATION ILI9488_MADCTL_MX | ILI9488_MADCTL_MV #endif -#define HAS_SPI_FLASH 1 -#define SPI_FLASH_SIZE 0x1000000 // 16MB +#define HAS_SPI_FLASH 1 +#define SPI_FLASH_SIZE 0x1000000 // 16MB #if HAS_SPI_FLASH #define W25QXX_CS_PIN PB12 #define W25QXX_MOSI_PIN PB15 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 feac729c73b2..1295c7c46b12 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -29,6 +29,8 @@ #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "MKS Robin nano supports up to 2 hotends / E-steppers. Comment out this line to continue." +#elif HAS_FSMC_TFT + #error "MKS Robin nano v2 doesn't support FSMC-based TFT displays." #endif #define BOARD_INFO_NAME "MKS Robin nano V2.0" @@ -47,13 +49,13 @@ #if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) #define I2C_EEPROM // EEPROM on I2C-0 - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // // Note: MKS Robin board is using SPI2 interface. // -//#define SPI_MODULE 2 +//#define SPI_MODULE 2 #define ENABLE_SPI2 // @@ -162,7 +164,7 @@ #define E1_SERIAL_RX_PIN PD8 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // TMC2208 || TMC2209 // @@ -194,10 +196,10 @@ #define PS_ON_PIN PA3 // PW_OFF //#define SUICIDE_PIN PB2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY -//#define SUICIDE_PIN_INVERTING false +//#define SUICIDE_PIN_INVERTING false //#define KILL_PIN PA2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY -//#define KILL_PIN_INVERTING true // Enable MKSPWC support ROBIN NANO v1.2 ONLY +//#define KILL_PIN_INVERTING true // Enable MKSPWC support ROBIN NANO v1.2 ONLY #define SERVO0_PIN PA8 // Enable BLTOUCH support ROBIN NANO v1.2 ONLY @@ -205,7 +207,7 @@ #define MT_DET_1_PIN PA4 #define MT_DET_2_PIN PE6 -#define MT_DET_PIN_INVERTING false +#define MT_DET_PIN_INVERTING false #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN MT_DET_1_PIN @@ -224,7 +226,7 @@ #endif #define SDIO_SUPPORT -#define SDIO_CLOCK 4500000 // 4.5 MHz +#define SDIO_CLOCK 4500000 // 4.5 MHz #define SD_DETECT_PIN PD12 #define ONBOARD_SD_CS_PIN PC11 @@ -241,14 +243,9 @@ * to let the bootloader init the screen. */ -#if ENABLED(TFT_LVGL_UI_SPI) +#if HAS_SPI_TFT - #define SPI_TFT_CS_PIN PD11 - #define SPI_TFT_SCK_PIN PA5 - #define SPI_TFT_MISO_PIN PA6 - #define SPI_TFT_MOSI_PIN PA7 - #define SPI_TFT_DC_PIN PD10 - #define SPI_TFT_RST_PIN PC6 + // Shared SPI TFT #define LCD_BACKLIGHT_PIN PD13 @@ -261,132 +258,98 @@ #define BTN_EN2 PE11 #define BTN_ENC PE13 - #define TFT_CS_PIN PD11 - #define TFT_SCK_PIN PA5 - #define TFT_MISO_PIN PA6 - #define TFT_MOSI_PIN PA7 - #define TFT_DC_PIN PD10 - #define TFT_RST_PIN PC6 - #define TFT_A0_PIN TFT_DC_PIN - - #define TFT_RESET_PIN PC6 - #define TFT_BACKLIGHT_PIN PD13 - - #define XPT2046_X_CALIBRATION -17253 - #define XPT2046_Y_CALIBRATION 11579 - #define XPT2046_X_OFFSET 514 - #define XPT2046_Y_OFFSET -24 + #define TFT_CS_PIN PD11 + #define TFT_SCK_PIN PA5 + #define TFT_MISO_PIN PA6 + #define TFT_MOSI_PIN PA7 + #define TFT_DC_PIN PD10 + #define TFT_RST_PIN PC6 + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN PC6 + #define TFT_BACKLIGHT_PIN PD13 + #define TOUCH_BUTTONS_HW_SPI - #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 - #ifndef LCD_FULL_PIXEL_WIDTH - #define LCD_FULL_PIXEL_WIDTH 480 + #ifndef TFT_WIDTH + #define TFT_WIDTH 480 #endif - #ifndef LCD_FULL_PIXEL_HEIGHT - #define LCD_FULL_PIXEL_HEIGHT 320 + #ifndef TFT_HEIGHT + #define TFT_HEIGHT 320 #endif -#endif + #define LCD_READ_ID 0xD3 + #define LCD_USE_DMA_SPI -#if HAS_SPI_LCD - - #if ENABLED(SPI_GRAPHICAL_TFT) // Emulated DOGM SPI - #define SPI_TFT_CS_PIN PD11 - #define SPI_TFT_SCK_PIN PA5 - #define SPI_TFT_MISO_PIN PA6 - #define SPI_TFT_MOSI_PIN PA7 - #define SPI_TFT_DC_PIN PD10 - #define SPI_TFT_RST_PIN PC6 - - #define LCD_BACKLIGHT_PIN PD13 - - #define LCD_READ_ID 0xD3 - #define LCD_USE_DMA_SPI - - #define TOUCH_BUTTONS_HW_SPI - #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 - - //#define TOUCH_SCREEN - #if EITHER(TOUCH_SCREEN, NEED_TOUCH_PINS) - #define TOUCH_CS_PIN PE14 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - - #ifndef XPT2046_X_CALIBRATION - #define XPT2046_X_CALIBRATION -5481 - #endif - #ifndef XPT2046_Y_CALIBRATION - #define XPT2046_Y_CALIBRATION 4000 - #endif - #ifndef XPT2046_X_OFFSET - #define XPT2046_X_OFFSET 343 - #endif - #ifndef XPT2046_Y_OFFSET - #define XPT2046_Y_OFFSET 0 - #endif - #endif +#endif - #ifndef FSMC_UPSCALE - #define FSMC_UPSCALE 3 - #endif - #ifndef LCD_PIXEL_OFFSET_Y - #define LCD_PIXEL_OFFSET_Y 32 - #endif +#if ENABLED(TFT_LVGL_UI_SPI) - #define BTN_ENC PE13 - #define BTN_EN1 PE8 - #define BTN_EN2 PE11 + // LVGL - #define LCD_PINS_ENABLE PD13 - #define LCD_PINS_RS PC6 + #define XPT2046_X_CALIBRATION -17253 + #define XPT2046_Y_CALIBRATION 11579 + #define XPT2046_X_OFFSET 514 + #define XPT2046_Y_OFFSET -24 - #elif ENABLED(MKS_MINI_12864) +#elif ENABLED(SPI_GRAPHICAL_TFT) - // MKS MINI12864 and MKS LCD12864B - // If using MKS LCD12864A (Need to remove RPK2 resistor) + // Emulated DOGM SPI - #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN -1 - #define DOGLCD_A0 PD11 - #define DOGLCD_CS PE15 - #define DOGLCD_SCK PA5 - #define DOGLCD_MOSI PA7 + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION -11386 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION 8684 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET 339 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET -18 + #endif - // Required for MKS_MINI_12864 with this board - #define MKS_LCD12864B - #undef SHOW_BOOTSCREEN + #ifndef GRAPHICAL_TFT_UPSCALE + #define GRAPHICAL_TFT_UPSCALE 3 + #endif + #ifndef TFT_PIXEL_OFFSET_Y + #define TFT_PIXEL_OFFSET_Y 32 + #endif - #elif ENABLED(TFT_480x320_SPI) - #define TFT_CS_PIN PD11 - #define TFT_SCK_PIN PA5 - #define TFT_MISO_PIN PA6 - #define TFT_MOSI_PIN PA7 - #define TFT_DC_PIN PD10 - #define TFT_RST_PIN PC6 - #define TFT_A0_PIN TFT_DC_PIN + #define BTN_ENC PE13 + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 - #define TFT_RESET_PIN PC6 - #define TFT_BACKLIGHT_PIN PD13 + #define LCD_PINS_ENABLE PD13 + #define LCD_PINS_RS PC6 +#elif ENABLED(TFT_480x320_SPI) #define XPT2046_X_CALIBRATION -17253 #define XPT2046_Y_CALIBRATION 11579 #define XPT2046_X_OFFSET 514 #define XPT2046_Y_OFFSET -24 - #define TOUCH_CS_PIN PE14 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - #define TFT_DRIVER ST7796 #define TFT_BUFFER_SIZE 14400 - #define LCD_READ_ID 0xD3 - #define LCD_USE_DMA_SPI +#endif + +#if HAS_SPI_LCD && !HAS_SPI_TFT + + // NON TFT Displays - #define TOUCH_BUTTONS_HW_SPI - #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + #if ENABLED(MKS_MINI_12864) + + // MKS MINI12864 and MKS LCD12864B + // If using MKS LCD12864A (Need to remove RPK2 resistor) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 PD11 + #define DOGLCD_CS PE15 + #define DOGLCD_SCK PA5 + #define DOGLCD_MOSI PA7 #else // !MKS_MINI_12864 @@ -409,10 +372,10 @@ #endif // !MKS_MINI_12864 -#endif // HAS_SPI_LCD +#endif // HAS_SPI_LCD && !HAS_SPI_TFT -#define HAS_SPI_FLASH 1 -#define SPI_FLASH_SIZE 0x1000000 // 16MB +#define HAS_SPI_FLASH 1 +#define SPI_FLASH_SIZE 0x1000000 // 16MB #if HAS_SPI_FLASH #define W25QXX_CS_PIN PB12 #define W25QXX_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 3ca59a93a3c1..c00466677a25 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -41,7 +41,7 @@ // // Note: MKS Robin board is using SPI2 interface. // -//#define SPI_MODULE 2 +//#define SPI_MODULE 2 #define ENABLE_SPI2 // diff --git a/Marlin/src/pins/stm32f1/pins_STM32F1R.h b/Marlin/src/pins/stm32f1/pins_STM32F1R.h index 475f31cb71c3..63fb383c9b52 100644 --- a/Marlin/src/pins/stm32f1/pins_STM32F1R.h +++ b/Marlin/src/pins/stm32f1/pins_STM32F1R.h @@ -33,7 +33,7 @@ #define DEFAULT_MACHINE_NAME "STM32F103RET6" // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Limit Switches @@ -100,9 +100,9 @@ #if HAS_SPI_LCD #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define LCD_PINS_RS 49 // CS chip select /SS chip slave select - #define LCD_PINS_ENABLE 51 // SID (MOSI) - #define LCD_PINS_D4 52 // SCK (CLK) clock + #define LCD_PINS_RS 49 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE 51 // SID (MOSI) + #define LCD_PINS_D4 52 // SCK (CLK) clock #elif BOTH(NEWPANEL, PANEL_ONE) #define LCD_PINS_RS PB8 #define LCD_PINS_ENABLE PD2 @@ -118,13 +118,13 @@ #define LCD_PINS_D6 PB14 #define LCD_PINS_D7 PB15 #if DISABLED(NEWPANEL) - #define BEEPER_PIN 33 + #define BEEPER_PIN 33 // Buttons attached to a shift register // Not wired yet - //#define SHIFT_CLK 38 - //#define SHIFT_LD 42 - //#define SHIFT_OUT 40 - //#define SHIFT_EN 17 + //#define SHIFT_CLK 38 + //#define SHIFT_LD 42 + //#define SHIFT_OUT 40 + //#define SHIFT_EN 17 #endif #endif @@ -132,125 +132,125 @@ #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) - #define BEEPER_PIN 37 + #define BEEPER_PIN 37 - #define BTN_EN1 31 - #define BTN_EN2 33 - #define BTN_ENC 35 + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 - #define SD_DETECT_PIN 49 - #define KILL_PIN 41 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 #if ENABLED(BQ_LCD_SMART_CONTROLLER) - #define LCD_BACKLIGHT_PIN 39 + #define LCD_BACKLIGHT_PIN 39 #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define BTN_EN1 64 - #define BTN_EN2 59 - #define BTN_ENC 63 - #define SD_DETECT_PIN 42 + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #define SD_DETECT_PIN 42 #elif ENABLED(LCD_I2C_PANELOLU2) - #define BTN_EN1 47 - #define BTN_EN2 43 - #define BTN_ENC 32 - #define LCD_SDSS 53 + #define BTN_EN1 47 + #define BTN_EN2 43 + #define BTN_ENC 32 + #define LCD_SDSS 53 #define SD_DETECT_PIN -1 - #define KILL_PIN 41 + #define KILL_PIN 41 #elif ENABLED(LCD_I2C_VIKI) - #define BTN_EN1 22 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. - #define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13. + #define BTN_EN1 22 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + #define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13. #define BTN_ENC -1 - #define LCD_SDSS 53 - #define SD_DETECT_PIN 49 + #define LCD_SDSS 53 + #define SD_DETECT_PIN 49 #elif ANY(VIKI2, miniVIKI) - #define BEEPER_PIN 33 + #define BEEPER_PIN 33 // Pins for DOGM SPI LCD Support - #define DOGLCD_A0 44 - #define DOGLCD_CS 45 + #define DOGLCD_A0 44 + #define DOGLCD_CS 45 #define LCD_SCREEN_ROT_180 - #define BTN_EN1 22 - #define BTN_EN2 7 - #define BTN_ENC 39 + #define BTN_EN1 22 + #define BTN_EN2 7 + #define BTN_ENC 39 - #define SDSS 53 + #define SDSS 53 #define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board - #define KILL_PIN 31 + #define KILL_PIN 31 - #define STAT_LED_RED_PIN 32 - #define STAT_LED_BLUE_PIN 35 + #define STAT_LED_RED_PIN 32 + #define STAT_LED_BLUE_PIN 35 #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) - #define BTN_EN1 35 - #define BTN_EN2 37 - #define BTN_ENC 31 - #define SD_DETECT_PIN 49 - #define LCD_SDSS 53 - #define KILL_PIN 41 - #define BEEPER_PIN 23 - #define DOGLCD_CS 29 - #define DOGLCD_A0 27 - #define LCD_BACKLIGHT_PIN 33 + #define BTN_EN1 35 + #define BTN_EN2 37 + #define BTN_ENC 31 + #define SD_DETECT_PIN 49 + #define LCD_SDSS 53 + #define KILL_PIN 41 + #define BEEPER_PIN 23 + #define DOGLCD_CS 29 + #define DOGLCD_A0 27 + #define LCD_BACKLIGHT_PIN 33 #elif ENABLED(MINIPANEL) - #define BEEPER_PIN 42 + #define BEEPER_PIN 42 // Pins for DOGM SPI LCD Support - #define DOGLCD_A0 44 - #define DOGLCD_CS 66 - #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 - #define SDSS 53 + #define DOGLCD_A0 44 + #define DOGLCD_CS 66 + #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 + #define SDSS 53 - #define KILL_PIN 64 + #define KILL_PIN 64 // GLCD features // Uncomment screen orientation //#define LCD_SCREEN_ROT_90 //#define LCD_SCREEN_ROT_180 //#define LCD_SCREEN_ROT_270 // The encoder and click button - #define BTN_EN1 40 - #define BTN_EN2 63 - #define BTN_ENC 59 + #define BTN_EN1 40 + #define BTN_EN2 63 + #define BTN_ENC 59 // not connected to a pin - #define SD_DETECT_PIN 49 + #define SD_DETECT_PIN 49 #else // Beeper on AUX-4 - #define BEEPER_PIN 33 + #define BEEPER_PIN 33 // Buttons directly attached to AUX-2 #if ENABLED(REPRAPWORLD_KEYPAD) - #define BTN_EN1 64 - #define BTN_EN2 59 - #define BTN_ENC 63 - #define SHIFT_OUT 40 - #define SHIFT_CLK 44 - #define SHIFT_LD 42 + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #define SHIFT_OUT 40 + #define SHIFT_CLK 44 + #define SHIFT_LD 42 #elif ENABLED(PANEL_ONE) - #define BTN_EN1 59 // AUX2 PIN 3 - #define BTN_EN2 63 // AUX2 PIN 4 - #define BTN_ENC 49 // AUX3 PIN 7 + #define BTN_EN1 59 // AUX2 PIN 3 + #define BTN_EN2 63 // AUX2 PIN 4 + #define BTN_ENC 49 // AUX3 PIN 7 #else - #define BTN_EN1 37 - #define BTN_EN2 35 - #define BTN_ENC 31 + #define BTN_EN1 37 + #define BTN_EN2 35 + #define BTN_ENC 31 #endif #if ENABLED(G3D_PANEL) - #define SD_DETECT_PIN 49 - #define KILL_PIN 41 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 #else //#define SD_DETECT_PIN -1 // Ramps doesn't use this #endif diff --git a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h index eb7fc9493955..c18642fb1df1 100644 --- a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h @@ -36,7 +36,7 @@ #define I2C_EEPROM // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Limit Switches @@ -115,9 +115,9 @@ #if HAS_SPI_LCD #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define LCD_PINS_RS 49 // CS chip select /SS chip slave select - #define LCD_PINS_ENABLE 51 // SID (MOSI) - #define LCD_PINS_D4 52 // SCK (CLK) clock + #define LCD_PINS_RS 49 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE 51 // SID (MOSI) + #define LCD_PINS_D4 52 // SCK (CLK) clock #elif BOTH(NEWPANEL, PANEL_ONE) #define LCD_PINS_RS PB8 #define LCD_PINS_ENABLE PD2 @@ -133,13 +133,13 @@ #define LCD_PINS_D6 PB14 #define LCD_PINS_D7 PB15 #if DISABLED(NEWPANEL) - #define BEEPER_PIN 33 + #define BEEPER_PIN 33 // Buttons attached to a shift register // Not wired yet - //#define SHIFT_CLK 38 - //#define SHIFT_LD 42 - //#define SHIFT_OUT 40 - //#define SHIFT_EN 17 + //#define SHIFT_CLK 38 + //#define SHIFT_LD 42 + //#define SHIFT_OUT 40 + //#define SHIFT_EN 17 #endif #endif @@ -155,126 +155,126 @@ #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) - #define BEEPER_PIN 37 + #define BEEPER_PIN 37 - #define BTN_EN1 31 - #define BTN_EN2 33 - #define BTN_ENC 35 + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 - #define SD_DETECT_PIN 49 - #define KILL_PIN 41 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 #if ENABLED(BQ_LCD_SMART_CONTROLLER) - #define LCD_BACKLIGHT_PIN 39 + #define LCD_BACKLIGHT_PIN 39 #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define BTN_EN1 64 - #define BTN_EN2 59 - #define BTN_ENC 63 - #define SD_DETECT_PIN 42 + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #define SD_DETECT_PIN 42 #elif ENABLED(LCD_I2C_PANELOLU2) - #define BTN_EN1 47 - #define BTN_EN2 43 - #define BTN_ENC 32 - #define LCD_SDSS 53 + #define BTN_EN1 47 + #define BTN_EN2 43 + #define BTN_ENC 32 + #define LCD_SDSS 53 #define SD_DETECT_PIN -1 - #define KILL_PIN 41 + #define KILL_PIN 41 #elif ENABLED(LCD_I2C_VIKI) - #define BTN_EN1 22 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. - #define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13. + #define BTN_EN1 22 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + #define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13. #define BTN_ENC -1 - #define LCD_SDSS 53 - #define SD_DETECT_PIN 49 + #define LCD_SDSS 53 + #define SD_DETECT_PIN 49 #elif ANY(VIKI2, miniVIKI) - #define BEEPER_PIN 33 + #define BEEPER_PIN 33 // Pins for DOGM SPI LCD Support - #define DOGLCD_A0 44 - #define DOGLCD_CS 45 + #define DOGLCD_A0 44 + #define DOGLCD_CS 45 #define LCD_SCREEN_ROT_180 - #define BTN_EN1 22 - #define BTN_EN2 7 - #define BTN_ENC 39 + #define BTN_EN1 22 + #define BTN_EN2 7 + #define BTN_ENC 39 - #define SDSS 53 + #define SDSS 53 #define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board - #define KILL_PIN 31 + #define KILL_PIN 31 - #define STAT_LED_RED_PIN 32 - #define STAT_LED_BLUE_PIN 35 + #define STAT_LED_RED_PIN 32 + #define STAT_LED_BLUE_PIN 35 #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) - #define BTN_EN1 35 - #define BTN_EN2 37 - #define BTN_ENC 31 - #define SD_DETECT_PIN 49 - #define LCD_SDSS 53 - #define KILL_PIN 41 - #define BEEPER_PIN 23 - #define DOGLCD_CS 29 - #define DOGLCD_A0 27 - #define LCD_BACKLIGHT_PIN 33 + #define BTN_EN1 35 + #define BTN_EN2 37 + #define BTN_ENC 31 + #define SD_DETECT_PIN 49 + #define LCD_SDSS 53 + #define KILL_PIN 41 + #define BEEPER_PIN 23 + #define DOGLCD_CS 29 + #define DOGLCD_A0 27 + #define LCD_BACKLIGHT_PIN 33 #elif ENABLED(MINIPANEL) - #define BEEPER_PIN 42 + #define BEEPER_PIN 42 // Pins for DOGM SPI LCD Support - #define DOGLCD_A0 44 - #define DOGLCD_CS 66 - #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 - #define SDSS 53 + #define DOGLCD_A0 44 + #define DOGLCD_CS 66 + #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 + #define SDSS 53 - #define KILL_PIN 64 + #define KILL_PIN 64 // GLCD features // Uncomment screen orientation //#define LCD_SCREEN_ROT_90 //#define LCD_SCREEN_ROT_180 //#define LCD_SCREEN_ROT_270 // The encoder and click button - #define BTN_EN1 40 - #define BTN_EN2 63 - #define BTN_ENC 59 + #define BTN_EN1 40 + #define BTN_EN2 63 + #define BTN_ENC 59 // not connected to a pin - #define SD_DETECT_PIN 49 + #define SD_DETECT_PIN 49 #else // Beeper on AUX-4 - #define BEEPER_PIN 33 + #define BEEPER_PIN 33 // Buttons directly attached to AUX-2 #if ENABLED(REPRAPWORLD_KEYPAD) - #define BTN_EN1 64 - #define BTN_EN2 59 - #define BTN_ENC 63 - #define SHIFT_OUT 40 - #define SHIFT_CLK 44 - #define SHIFT_LD 42 + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #define SHIFT_OUT 40 + #define SHIFT_CLK 44 + #define SHIFT_LD 42 #elif ENABLED(PANEL_ONE) - #define BTN_EN1 59 // AUX2 PIN 3 - #define BTN_EN2 63 // AUX2 PIN 4 - #define BTN_ENC 49 // AUX3 PIN 7 + #define BTN_EN1 59 // AUX2 PIN 3 + #define BTN_EN2 63 // AUX2 PIN 4 + #define BTN_ENC 49 // AUX3 PIN 7 #else - #define BTN_EN1 37 - #define BTN_EN2 35 - #define BTN_ENC 31 + #define BTN_EN1 37 + #define BTN_EN2 35 + #define BTN_ENC 31 #endif #if ENABLED(G3D_PANEL) - #define SD_DETECT_PIN 49 - #define KILL_PIN 41 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 #else //#define SD_DETECT_PIN -1 // Ramps doesn't use this #endif diff --git a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h index c0a0c016b0bc..598db026fd94 100644 --- a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h @@ -92,7 +92,7 @@ // #define HEATER_0_PIN PG12 // HEATER1 #define HEATER_BED_PIN PG11 // HOT BED -#define HEATER_BED_INVERTING true +#define HEATER_BED_INVERTING true // // Fans diff --git a/Marlin/src/pins/stm32f4/pins_ARMED.h b/Marlin/src/pins/stm32f4/pins_ARMED.h index 232337f6df99..696241693629 100644 --- a/Marlin/src/pins/stm32f4/pins_ARMED.h +++ b/Marlin/src/pins/stm32f4/pins_ARMED.h @@ -39,7 +39,7 @@ #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB // // Limit Switches @@ -225,5 +225,5 @@ #define Z2_SERIAL_RX_PIN EXT4_PIN #define Z2_SERIAL_TX_PIN EXT4_PIN - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif diff --git a/Marlin/src/pins/stm32f4/pins_BEAST.h b/Marlin/src/pins/stm32f4/pins_BEAST.h index 676f1f8c9bfb..691b468c343a 100644 --- a/Marlin/src/pins/stm32f4/pins_BEAST.h +++ b/Marlin/src/pins/stm32f4/pins_BEAST.h @@ -36,7 +36,7 @@ #define I2C_EEPROM // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Steppers @@ -123,9 +123,9 @@ #if HAS_SPI_LCD #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define LCD_PINS_RS 49 // CS chip select /SS chip slave select - #define LCD_PINS_ENABLE 51 // SID (MOSI) - #define LCD_PINS_D4 52 // SCK (CLK) clock + #define LCD_PINS_RS 49 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE 51 // SID (MOSI) + #define LCD_PINS_D4 52 // SCK (CLK) clock #elif BOTH(NEWPANEL, PANEL_ONE) #define LCD_PINS_RS PB8 #define LCD_PINS_ENABLE PD2 @@ -141,13 +141,13 @@ #define LCD_PINS_D6 PB14 #define LCD_PINS_D7 PB15 #if DISABLED(NEWPANEL) - #define BEEPER_PIN 33 + #define BEEPER_PIN 33 // Buttons attached to a shift register // Not wired yet - //#define SHIFT_CLK 38 - //#define SHIFT_LD 42 - //#define SHIFT_OUT 40 - //#define SHIFT_EN 17 + //#define SHIFT_CLK 38 + //#define SHIFT_LD 42 + //#define SHIFT_OUT 40 + //#define SHIFT_EN 17 #endif #endif @@ -155,126 +155,126 @@ #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) - #define BEEPER_PIN 37 + #define BEEPER_PIN 37 - #define BTN_EN1 31 - #define BTN_EN2 33 - #define BTN_ENC 35 + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 - #define SD_DETECT_PIN 49 - #define KILL_PIN 41 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 #if ENABLED(BQ_LCD_SMART_CONTROLLER) - #define LCD_BACKLIGHT_PIN 39 + #define LCD_BACKLIGHT_PIN 39 #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define BTN_EN1 64 - #define BTN_EN2 59 - #define BTN_ENC 63 - #define SD_DETECT_PIN 42 + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #define SD_DETECT_PIN 42 #elif ENABLED(LCD_I2C_PANELOLU2) - #define BTN_EN1 47 - #define BTN_EN2 43 - #define BTN_ENC 32 - #define LCD_SDSS 53 + #define BTN_EN1 47 + #define BTN_EN2 43 + #define BTN_ENC 32 + #define LCD_SDSS 53 #define SD_DETECT_PIN -1 - #define KILL_PIN 41 + #define KILL_PIN 41 #elif ENABLED(LCD_I2C_VIKI) - #define BTN_EN1 22 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. - #define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13. + #define BTN_EN1 22 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + #define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13. #define BTN_ENC -1 - #define LCD_SDSS 53 - #define SD_DETECT_PIN 49 + #define LCD_SDSS 53 + #define SD_DETECT_PIN 49 #elif ANY(VIKI2, miniVIKI) - #define BEEPER_PIN 33 + #define BEEPER_PIN 33 // Pins for DOGM SPI LCD Support - #define DOGLCD_A0 44 - #define DOGLCD_CS 45 + #define DOGLCD_A0 44 + #define DOGLCD_CS 45 #define LCD_SCREEN_ROT_180 - #define BTN_EN1 22 - #define BTN_EN2 7 - #define BTN_ENC 39 + #define BTN_EN1 22 + #define BTN_EN2 7 + #define BTN_ENC 39 - #define SDSS 53 + #define SDSS 53 #define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board - #define KILL_PIN 31 + #define KILL_PIN 31 - #define STAT_LED_RED_PIN 32 - #define STAT_LED_BLUE_PIN 35 + #define STAT_LED_RED_PIN 32 + #define STAT_LED_BLUE_PIN 35 #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) - #define BTN_EN1 35 - #define BTN_EN2 37 - #define BTN_ENC 31 - #define SD_DETECT_PIN 49 - #define LCD_SDSS 53 - #define KILL_PIN 41 - #define BEEPER_PIN 23 - #define DOGLCD_CS 29 - #define DOGLCD_A0 27 - #define LCD_BACKLIGHT_PIN 33 + #define BTN_EN1 35 + #define BTN_EN2 37 + #define BTN_ENC 31 + #define SD_DETECT_PIN 49 + #define LCD_SDSS 53 + #define KILL_PIN 41 + #define BEEPER_PIN 23 + #define DOGLCD_CS 29 + #define DOGLCD_A0 27 + #define LCD_BACKLIGHT_PIN 33 #elif ENABLED(MINIPANEL) - #define BEEPER_PIN 42 + #define BEEPER_PIN 42 // Pins for DOGM SPI LCD Support - #define DOGLCD_A0 44 - #define DOGLCD_CS 66 - #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 - #define SDSS 53 + #define DOGLCD_A0 44 + #define DOGLCD_CS 66 + #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 + #define SDSS 53 - #define KILL_PIN 64 + #define KILL_PIN 64 // GLCD features // Uncomment screen orientation //#define LCD_SCREEN_ROT_90 //#define LCD_SCREEN_ROT_180 //#define LCD_SCREEN_ROT_270 // The encoder and click button - #define BTN_EN1 40 - #define BTN_EN2 63 - #define BTN_ENC 59 + #define BTN_EN1 40 + #define BTN_EN2 63 + #define BTN_ENC 59 // not connected to a pin - #define SD_DETECT_PIN 49 + #define SD_DETECT_PIN 49 #else // Beeper on AUX-4 - #define BEEPER_PIN 33 + #define BEEPER_PIN 33 // Buttons directly attached to AUX-2 #if ENABLED(REPRAPWORLD_KEYPAD) - #define BTN_EN1 64 - #define BTN_EN2 59 - #define BTN_ENC 63 - #define SHIFT_OUT 40 - #define SHIFT_CLK 44 - #define SHIFT_LD 42 + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #define SHIFT_OUT 40 + #define SHIFT_CLK 44 + #define SHIFT_LD 42 #elif ENABLED(PANEL_ONE) - #define BTN_EN1 59 // AUX2 PIN 3 - #define BTN_EN2 63 // AUX2 PIN 4 - #define BTN_ENC 49 // AUX3 PIN 7 + #define BTN_EN1 59 // AUX2 PIN 3 + #define BTN_EN2 63 // AUX2 PIN 4 + #define BTN_ENC 49 // AUX3 PIN 7 #else - #define BTN_EN1 37 - #define BTN_EN2 35 - #define BTN_ENC 31 + #define BTN_EN1 37 + #define BTN_EN2 35 + #define BTN_ENC 31 #endif #if ENABLED(G3D_PANEL) - #define SD_DETECT_PIN 49 - #define KILL_PIN 41 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 #else //#define SD_DETECT_PIN -1 // Ramps doesn't use this #endif diff --git a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h index e6350f71dcdb..dc0dab1cd15d 100644 --- a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h +++ b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h @@ -41,7 +41,7 @@ //#define I2C_EEPROM #define SRAM_EEPROM_EMULATION -#define MARLIN_EEPROM_SIZE 0x2000 // 8KB +#define MARLIN_EEPROM_SIZE 0x2000 // 8KB // // Servos diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index 0e81237ad91b..d3510b1ff815 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -42,7 +42,7 @@ #endif // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Limit Switches @@ -153,7 +153,7 @@ #define E0_SERIAL_RX_PIN PD7 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index 776ab1d811b2..ea643322b67b 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -33,7 +33,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24C64 ... 64Kb = 8KB) +#define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24C64 ... 64Kb = 8KB) #define TP // Enable to define servo and probe pins @@ -223,7 +223,7 @@ #define E7_SERIAL_RX_PIN PH14 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // @@ -280,24 +280,29 @@ //#define FAN6_PIN PC9 // Fan6 //#define FAN7_PIN PE14 // Fan7 +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + // -// By default the onboard SD (SPI1) is enabled +// By default the LCD SD (SPI2) is enabled +// Onboard SD is on a completely separate SPI bus, and requires +// overriding pins to access. // -#define CUSTOM_SPI_PINS -#if DISABLED(CUSTOM_SPI_PINS) +#if SD_CONNECTION_IS(LCD) + #define SD_DETECT_PIN PB10 #define SDSS PB12 -#endif - -// HAL SPI1 pins group -#if ENABLED(CUSTOM_SPI_PINS) +#elif SD_CONNECTION_IS(ONBOARD) + // Instruct the STM32 HAL to override the default SPI pins from the variant.h file + #define CUSTOM_SPI_PINS #define SDSS PA4 - #define SD_DETECT_PIN PC4 - #define LCD_SDSS PA4 - + #define SS_PIN SDSS #define SCK_PIN PA5 #define MISO_PIN PA6 #define MOSI_PIN PA7 - #define SS_PIN PA4 // Chip select for SD card used by Marlin + #define SD_DETECT_PIN PC4 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #define "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" #endif /** @@ -319,7 +324,6 @@ #define BTN_ENC PA15 #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS PG6 #define BTN_EN1 PC10 @@ -333,6 +337,15 @@ #undef BOARD_ST7920_DELAY_2 #undef BOARD_ST7920_DELAY_3 + #elif ENABLED(MKS_MINI_12864) + #define DOGLCD_A0 PG6 + #define DOGLCD_CS PG7 + #define BTN_EN1 PD10 + #define BTN_EN2 PH10 + + #if SD_CONNECTION_IS(ONBOARD) + #define SOFTWARE_SPI + #endif #else #define LCD_PINS_RS PA8 @@ -340,17 +353,17 @@ #define BTN_EN1 PD10 #define BTN_EN2 PH10 - #if DISABLED(CUSTOM_SPI_PINS) - #define SD_DETECT_PIN PB10 - #define LCD_SDSS PB12 - #endif - #define LCD_PINS_ENABLE PC10 #define LCD_PINS_D4 PG8 #if ENABLED(FYSETC_MINI_12864) #define DOGLCD_CS PC10 #define DOGLCD_A0 PA8 + + #if SD_CONNECTION_IS(ONBOARD) + #define SOFTWARE_SPI + #endif + //#define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN PG8 // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) @@ -389,11 +402,6 @@ #endif #endif - //#define DOGLCD_CS PB12 - //#define DOGLCD_A0 PA8 - //#define LCD_PINS_DC PB14 - //#define DOGLCD_MOSI PB15 - #endif // HAS_SPI_LCD #undef TP diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index b6bb854d5be0..56c509562fc5 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -212,7 +212,7 @@ #define E2_SERIAL_RX_PIN PD6 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // @@ -250,12 +250,22 @@ // Onboard SD card // Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 // -#if SD_CONNECTION_IS(ONBOARD) - #define SOFTWARE_SPI // Use soft SPI for onboard SD +#if SD_CONNECTION_IS(LCD) + #define SD_DETECT_PIN PF12 + #define SDSS PB12 +#elif SD_CONNECTION_IS(ONBOARD) + // The SKR Pro's ONBOARD SD interface is on SPI1. + // Due to a pull resistor on the clock line, it needs to use SPI Data Mode 3 to + // function with Hardware SPI. This is not currently configurable in the HAL, + // so force Software SPI to work around this issue. + #define SOFTWARE_SPI #define SDSS PA4 #define SCK_PIN PA5 #define MISO_PIN PA6 #define MOSI_PIN PB5 + #define SD_DETECT_PIN PB11 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #define "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" #endif /** @@ -275,9 +285,6 @@ #if HAS_SPI_LCD #define BEEPER_PIN PG4 #define BTN_ENC PA8 - #if SD_CONNECTION_IS(LCD) - #define SDSS PB12 // Uses default hardware SPI for LCD's SD - #endif #if ENABLED(CR10_STOCKDISPLAY) #define LCD_PINS_RS PG6 @@ -296,16 +303,14 @@ #elif ENABLED(MKS_MINI_12864) #define DOGLCD_A0 PG6 #define DOGLCD_CS PG3 - + #define BTN_EN1 PG10 + #define BTN_EN2 PF11 #else #define LCD_PINS_RS PD10 #define BTN_EN1 PG10 #define BTN_EN2 PF11 - #define SD_DETECT_PIN PF12 - - #define LCD_SDSS PB12 #define LCD_PINS_ENABLE PD11 #define LCD_PINS_D4 PG2 @@ -366,7 +371,7 @@ *  ̄ ̄ * W1 */ -#define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 #define ESP_WIFI_MODULE_RESET_PIN PG0 #define ESP_WIFI_MODULE_ENABLE_PIN PG1 diff --git a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h index 499edc8dc0a7..a3a5ccdff8dc 100644 --- a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h +++ b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h @@ -45,11 +45,11 @@ // the 128kB sector allocated for EEPROM emulation. #define FLASH_EEPROM_LEVELING #elif ENABLED(I2C_EEPROM) - #define MARLIN_EEPROM_SIZE 0x2000 // 8KB + #define MARLIN_EEPROM_SIZE 0x2000 // 8KB #endif #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 03960584fb2f..9ffedc2ac477 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -28,14 +28,14 @@ #endif #ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "FYSETC_S6" + #define BOARD_INFO_NAME "FYSETC S6" #endif #ifndef DEFAULT_MACHINE_NAME #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME #endif // Change the priority to 3. Priority 2 is for software serial. -//#define TEMP_TIMER_IRQ_PRIO 3 +//#define TEMP_TIMER_IRQ_PRIO 3 // // EEPROM Emulation @@ -51,7 +51,7 @@ // 128 kB sector allocated for EEPROM emulation. #define FLASH_EEPROM_LEVELING #elif ENABLED(I2C_EEPROM) - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // @@ -82,7 +82,9 @@ // #define X_STEP_PIN PE11 #define X_DIR_PIN PE10 -#define X_ENABLE_PIN PE12 +#ifndef X_ENABLE_PIN + #define X_ENABLE_PIN PE12 +#endif #define X_CS_PIN PE7 #define Y_STEP_PIN PD8 @@ -118,23 +120,42 @@ // // Software serial // - #define X_SERIAL_TX_PIN PE9 - #define X_SERIAL_RX_PIN PE8 - - #define Y_SERIAL_TX_PIN PE14 - #define Y_SERIAL_RX_PIN PE13 - - #define Z_SERIAL_TX_PIN PD11 - #define Z_SERIAL_RX_PIN PD12 - - #define E0_SERIAL_TX_PIN PD3 - #define E0_SERIAL_RX_PIN PA15 - - #define E1_SERIAL_TX_PIN PC4 - #define E1_SERIAL_RX_PIN PC5 - - #define E2_SERIAL_TX_PIN PE1 - #define E2_SERIAL_RX_PIN PE0 + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN PE9 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN PE8 + #endif + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN PE14 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN PE13 + #endif + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN PD11 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN PD12 + #endif + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN PD3 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN PA15 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN PC4 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN PC5 + #endif + #ifndef E2_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN PE1 + #endif + #ifndef E2_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN PE0 + #endif #endif // diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h new file mode 100644 index 000000000000..6cd970501fde --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h @@ -0,0 +1,67 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "FYSETC S6 2.0" + +// +// EEPROM Emulation +// +#if NO_EEPROM_SELECTED + #undef NO_EEPROM_SELECTED + //#define FLASH_EEPROM_EMULATION + //#define SRAM_EEPROM_EMULATION + #define I2C_EEPROM +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PE9 + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PE8 + #define Y_SERIAL_TX_PIN PC4 + #define Y_SERIAL_RX_PIN PC4 + #define Z_SERIAL_TX_PIN PD12 + #define E0_SERIAL_TX_PIN PA15 + #define E1_SERIAL_TX_PIN PC5 + #define E2_SERIAL_TX_PIN PE0 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#define TMC_USE_SW_SPI +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PE14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PE13 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PE12 + #endif +#endif + +#include "pins_FYSETC_S6.h" diff --git a/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h b/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h index b84c72466729..44b2e6b27cbc 100644 --- a/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h +++ b/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h @@ -37,11 +37,11 @@ //#define I2C_EEPROM #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Limit Switches diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h index 126d571464ee..0f0d3d048c71 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h @@ -147,10 +147,10 @@ // Misc. Functions // #define SDSS PC11 -#define LED_PIN PA15 // Alive +#define LED_PIN PA15 // Alive #define PS_ON_PIN -1 #define KILL_PIN -1 -#define POWER_LOSS_PIN PA4 // Power-loss / nAC_FAULT +#define POWER_LOSS_PIN PA4 // Power-loss / nAC_FAULT #define SCK_PIN PC12 #define MISO_PIN PC8 diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h index 8f9a4339cd07..2e55782edb41 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h @@ -27,8 +27,8 @@ #define BOARD_INFO_NAME "Lerdge S" #define DEFAULT_MACHINE_NAME "LERDGE" -#define STEP_TIMER 4 -#define TEMP_TIMER 2 +#define STEP_TIMER 4 +#define TEMP_TIMER 2 //#define I2C_EEPROM @@ -127,7 +127,7 @@ #endif // -// Prusa i3 MK2 Multi Material Multiplexer Support +// Průša i3 MK2 Multi Material Multiplexer Support // //#define E_MUX0_PIN -1 //#define E_MUX1_PIN -1 @@ -173,15 +173,15 @@ #if ENABLED(SPI_EEPROM) // Lerdge has an SPI EEPROM Winbond W25Q128 (128Mbits) https://www.pjrc.com/teensy/W25Q128FV.pdf - #define SPI_CHAN_EEPROM1 1 + #define SPI_CHAN_EEPROM1 1 #define SPI_EEPROM1_CS PB12 // datasheet: /CS pin, found with multimeter, not tested #define EEPROM_SCK PB13 // datasheet: CLK pin, found with multimeter, not tested #define EEPROM_MISO PB14 // datasheet: DO pin, found with multimeter, not tested #define EEPROM_MOSI PB15 // datasheet: DI pin, found with multimeter, not tested - #define EEPROM_PAGE_SIZE 0x1000U // 4KB (from datasheet) + #define EEPROM_PAGE_SIZE 0x1000U // 4KB (from datasheet) #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64KB for now... #else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM #endif // diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h index 745d911e3a7a..da2851c1316d 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h @@ -27,8 +27,8 @@ #define BOARD_INFO_NAME "Lerdge X" #define DEFAULT_MACHINE_NAME "LERDGE" -#define STEP_TIMER 4 -#define TEMP_TIMER 2 +#define STEP_TIMER 4 +#define TEMP_TIMER 2 #define I2C_EEPROM @@ -115,7 +115,7 @@ #define KILL_PIN -1 // Lerdge supports auto-power off and power loss sense through a single pin. -#define POWER_LOSS_PIN PC14 // Power-loss / nAC_FAULT +#define POWER_LOSS_PIN PC14 // Power-loss / nAC_FAULT #define SCK_PIN PC12 #define MISO_PIN PC8 diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h index de8d13c546dd..a60a2781495c 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h @@ -33,10 +33,10 @@ #if NO_EEPROM_SELECTED #if MB(RUMBA32_V1_0) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #elif MB(RUMBA32_V1_1) #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24LC64T-I/OT) + #define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24LC64T-I/OT) #endif #endif diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h index d67962b1a61e..fe6e559bdb8e 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h @@ -37,7 +37,7 @@ #if NO_EEPROM_SELECTED #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif #if ENABLED(FLASH_EEPROM_EMULATION) diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h index aa481a8b7433..3b513b31ca8c 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h @@ -44,8 +44,8 @@ // TIM7 is used for SERVO // TIMER_SERIAL defaults to TIM7 so we'll override it here // -#define STEP_TIMER 10 -#define TEMP_TIMER 14 +#define STEP_TIMER 10 +#define TEMP_TIMER 14 #define TIMER_SERIAL TIM9 #define HAL_TIMER_RATE F_CPU diff --git a/Marlin/src/pins/stm32f4/pins_VAKE403D.h b/Marlin/src/pins/stm32f4/pins_VAKE403D.h index 01e9da590a58..1ffe25b49927 100644 --- a/Marlin/src/pins/stm32f4/pins_VAKE403D.h +++ b/Marlin/src/pins/stm32f4/pins_VAKE403D.h @@ -31,7 +31,7 @@ #define BOARD_INFO_NAME "STM32F4 VAkE" //#define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB // // Servos @@ -147,7 +147,7 @@ //#define NEOPIXEL_PIN PF13 // -// Prusa i3 MK2 Multi Material Multiplexer Support +// Průša i3 MK2 Multi Material Multiplexer Support // //#define E_MUX0_PIN PG3 //#define E_MUX1_PIN PG4 diff --git a/Marlin/src/pins/stm32f7/pins_THE_BORG.h b/Marlin/src/pins/stm32f7/pins_THE_BORG.h index fa4279920ca0..756f495e4b2e 100644 --- a/Marlin/src/pins/stm32f7/pins_THE_BORG.h +++ b/Marlin/src/pins/stm32f7/pins_THE_BORG.h @@ -31,11 +31,11 @@ #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE 0x1000 + #define MARLIN_EEPROM_SIZE 0x1000 #endif // Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Limit Switches diff --git a/Marlin/src/pins/teensy2/pins_5DPRINT.h b/Marlin/src/pins/teensy2/pins_5DPRINT.h index f473ad145e62..7ba1fbcf8db8 100644 --- a/Marlin/src/pins/teensy2/pins_5DPRINT.h +++ b/Marlin/src/pins/teensy2/pins_5DPRINT.h @@ -144,5 +144,5 @@ //DIGIPOTS slave addresses #ifndef DIGIPOT_I2C_ADDRESS_A - #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for DIGIPOT 0x2C (0x58 <- 0x2C << 1) + #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for DIGIPOT 0x2C (0x58 <- 0x2C << 1) #endif diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h index 51080b2fd19f..7d96bd12ff9c 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h @@ -166,4 +166,4 @@ #endif -#endif // HAS_SPI_LCD && NEWPANEL +#endif // ULTRA_LCD && NEWPANEL diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index 7bf0f334f4ee..83b17b65606c 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -158,7 +158,7 @@ #define DAC_STEPPER_MAX 3520 #define DAC_STEPPER_VREF 1 // internal Vref, gain 1x = 2.048V #define DAC_STEPPER_GAIN 0 -#define DAC_OR_ADDRESS 0x00 +#define DAC_OR_ADDRESS 0x00 // // Temperature Sensors diff --git a/Marlin/src/pins/teensy2/pins_TEENSYLU.h b/Marlin/src/pins/teensy2/pins_TEENSYLU.h index 8ee07a427d8c..c69a1c06a785 100644 --- a/Marlin/src/pins/teensy2/pins_TEENSYLU.h +++ b/Marlin/src/pins/teensy2/pins_TEENSYLU.h @@ -155,7 +155,7 @@ #define SD_DETECT_PIN -1 -#endif // HAS_SPI_LCD && NEWPANEL +#endif // ULTRA_LCD && NEWPANEL // // M3/M4/M5 - Spindle/Laser Control diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 864552516bcc..538fca3c881f 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -24,13 +24,15 @@ #if ENABLED(SDSUPPORT) +//#define DEBUG_CARDREADER + #include "cardreader.h" #include "../MarlinCore.h" #include "../lcd/ultralcd.h" #if ENABLED(DWIN_CREALITY_LCD) - #include "../lcd/dwin/dwin.h" + #include "../lcd/dwin/e3v2/dwin.h" #endif #include "../module/planner.h" // for synchronize @@ -51,6 +53,9 @@ #include "../feature/pause.h" #endif +#define DEBUG_OUT ENABLED(DEBUG_CARDREADER) +#include "../core/debug_out.h" + // public: card_flags_t CardReader::flag; @@ -137,6 +142,10 @@ CardReader::CardReader() { // Disable autostart until card is initialized autostart_index = -1; + #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) + SET_INPUT_PULLUP(SD_DETECT_PIN); + #endif + #if PIN_EXISTS(SDPOWER) OUT_WRITE(SDPOWER_PIN, HIGH); // Power the SD reader #endif @@ -272,8 +281,10 @@ void CardReader::printListing(SdFile parent, const char * const prepend/*=nullpt // List all files on the SD card // void CardReader::ls() { - root.rewind(); - printListing(root); + if (flag.mounted) { + root.rewind(); + printListing(root); + } } #if ENABLED(LONG_FILENAME_HOST_SUPPORT) @@ -376,7 +387,13 @@ void CardReader::mount() { flag.mounted = true; SERIAL_ECHO_MSG(STR_SD_CARD_OK); } - cdroot(); + + if (flag.mounted) + cdroot(); + #if ENABLED(USB_FLASH_DRIVE_SUPPORT) || PIN_EXISTS(SD_DETECT) + else if (marlin_state != MF_INITIALIZING) + ui.set_status_P(GET_TEXT(MSG_SD_INIT_FAIL), -1); + #endif ui.refresh(); } @@ -393,6 +410,8 @@ void CardReader::manage_media() { uint8_t stat = uint8_t(IS_SD_INSERTED()); if (stat == prev_stat) return; + DEBUG_ECHOLNPAIR("SD: Status changed from ", prev_stat, " to ", stat); + flag.workDirIsRoot = true; // Return to root on mount/release if (ui.detected()) { @@ -419,12 +438,15 @@ void CardReader::manage_media() { if (stat) { TERN_(SDCARD_EEPROM_EMULATION, settings.first_load()); if (old_stat == 2) // First mount? + DEBUG_ECHOLNPGM("First mount."); TERN(POWER_LOSS_RECOVERY, recovery.check(), // Check for PLR file. (If not there it will beginautostart) beginautostart() // Look for auto0.g on the next loop ); } } + else + DEBUG_ECHOLNPGM("SD: No UI Detected."); } void CardReader::release() { diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index 78f338fdae0c..a097df510523 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -94,9 +94,7 @@ static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined"); #include "Sd2Card_FlashDrive.h" -#if HAS_DISPLAY - #include "../../lcd/ultralcd.h" -#endif +#include "../../lcd/ultralcd.h" static enum { UNINITIALIZED, @@ -116,9 +114,7 @@ bool Sd2Card::usbStartup() { SERIAL_ECHOPGM("Starting USB host..."); if (!UHS_START) { SERIAL_ECHOLNPGM(" failed."); - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) - LCD_MESSAGEPGM(MSG_MEDIA_USB_FAILED); - #endif + LCD_MESSAGEPGM(MSG_MEDIA_USB_FAILED); return false; } @@ -213,9 +209,7 @@ void Sd2Card::idle() { #if USB_DEBUG >= 1 SERIAL_ECHOLNPGM("Waiting for media"); #endif - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) - LCD_MESSAGEPGM(MSG_MEDIA_WAITING); - #endif + LCD_MESSAGEPGM(MSG_MEDIA_WAITING); GOTO_STATE_AFTER_DELAY(state, 2000); } break; @@ -229,11 +223,9 @@ void Sd2Card::idle() { #if USB_DEBUG >= 1 SERIAL_ECHOLNPGM("USB device removed"); #endif - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) - if (state != MEDIA_READY) - LCD_MESSAGEPGM(MSG_MEDIA_USB_REMOVED); - #endif - GOTO_STATE_AFTER_DELAY( WAIT_FOR_DEVICE, 0 ); + if (state != MEDIA_READY) + LCD_MESSAGEPGM(MSG_MEDIA_USB_REMOVED); + GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); } else if (state > WAIT_FOR_LUN && !bulk.LUNIsGood(0)) { @@ -241,17 +233,13 @@ void Sd2Card::idle() { #if USB_DEBUG >= 1 SERIAL_ECHOLNPGM("Media removed"); #endif - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) - LCD_MESSAGEPGM(MSG_MEDIA_REMOVED); - #endif - GOTO_STATE_AFTER_DELAY( WAIT_FOR_DEVICE, 0 ); + LCD_MESSAGEPGM(MSG_MEDIA_REMOVED); + GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); } else if (task_state == UHS_STATE(ERROR)) { - #if EITHER(ULTRA_LCD, EXTENSIBLE_UI) - LCD_MESSAGEPGM(MSG_MEDIA_READ_ERROR); - #endif - GOTO_STATE_AFTER_DELAY( MEDIA_ERROR, 0 ); + LCD_MESSAGEPGM(MSG_MEDIA_READ_ERROR); + GOTO_STATE_AFTER_DELAY(MEDIA_ERROR, 0); } } } diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index 6c1b571bf16b..def3bf40c225 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -9,10 +9,33 @@ import configparser except ImportError: import ConfigParser as configparser -from platformio.managers.package import PackageManager +try: + # PIO < 4.4 + from platformio.managers.package import PackageManager +except ImportError: + # PIO >= 4.4 + from platformio.package.meta import PackageSpec as PackageManager Import("env") +#print(env.Dump()) + +try: + verbose = int(env.GetProjectOption('custom_verbose')) +except: + verbose = 0 + +def blab(str): + if verbose: + print(str) + +def parse_pkg_uri(spec): + if PackageManager.__name__ == 'PackageSpec': + return PackageManager(spec).name + else: + name, _, _ = PackageManager.parse_pkg_uri(spec) + return name + FEATURE_CONFIG = {} def add_to_feat_cnf(feature, flines): @@ -56,7 +79,7 @@ def get_all_known_libs(): if not 'lib_deps' in feat: continue for dep in feat['lib_deps']: - name, _, _ = PackageManager.parse_pkg_uri(dep) + name = parse_pkg_uri(dep) known_libs.append(name) return known_libs @@ -64,7 +87,7 @@ def get_all_env_libs(): env_libs = [] lib_deps = env.GetProjectOption('lib_deps') for dep in lib_deps: - name, _, _ = PackageManager.parse_pkg_uri(dep) + name = parse_pkg_uri(dep) env_libs.append(name) return env_libs @@ -79,7 +102,8 @@ def force_ignore_unused_libs(): known_libs = get_all_known_libs() diff = (list(set(known_libs) - set(env_libs))) lib_ignore = env.GetProjectOption('lib_ignore') + diff - print("Ignore libraries:", lib_ignore) + if verbose: + print("Ignore libraries:", lib_ignore) set_env_field('lib_ignore', lib_ignore) def apply_features_config(): @@ -91,25 +115,25 @@ def apply_features_config(): feat = FEATURE_CONFIG[feature] if 'lib_deps' in feat and len(feat['lib_deps']): - print("Adding lib_deps for %s... " % feature) + blab("Adding lib_deps for %s... " % feature) # feat to add deps_to_add = {} for dep in feat['lib_deps']: - name, _, _ = PackageManager.parse_pkg_uri(dep) + name = parse_pkg_uri(dep) deps_to_add[name] = dep # Does the env already have the dependency? deps = env.GetProjectOption('lib_deps') for dep in deps: - name, _, _ = PackageManager.parse_pkg_uri(dep) + name = parse_pkg_uri(dep) 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, _, _ = PackageManager.parse_pkg_uri(dep) + name = parse_pkg_uri(dep) if name in deps_to_add: del deps_to_add[name] @@ -119,11 +143,11 @@ def apply_features_config(): set_env_field('lib_deps', deps + list(deps_to_add.values())) if 'extra_scripts' in feat: - print("Running extra_scripts for %s... " % feature) + blab("Running extra_scripts for %s... " % feature) env.SConscript(feat['extra_scripts'], exports="env") if 'src_filter' in feat: - print("Adding src_filter for %s... " % feature) + blab("Adding src_filter for %s... " % feature) 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']) @@ -137,7 +161,7 @@ def apply_features_config(): env.Replace(SRC_FILTER=src_filter) if 'lib_ignore' in feat: - print("Adding lib_ignore for %s... " % feature) + blab("Adding lib_ignore for %s... " % feature) lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']] set_env_field('lib_ignore', lib_ignore) @@ -147,41 +171,49 @@ def apply_features_config(): ENV_BUILD_PATH = os.path.join(env.Dictionary('PROJECT_BUILD_DIR'), env['PIOENV']) GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path") def search_compiler(): + try: + filepath = env.GetProjectOption('custom_gcc') + blab('Getting compiler from env') + return filepath + except: + pass + if os.path.exists(GCC_PATH_CACHE): - print('Getting g++ path from cache') + blab('Getting g++ path from cache') with open(GCC_PATH_CACHE, 'r') as f: return f.read() - # PlatformIO inserts the toolchain bin folder on the front of the $PATH # Find the current platform compiler by searching the $PATH + # which will be in a platformio toolchain bin folder + path_regex = re.escape(env['PROJECT_PACKAGES_DIR']) + gcc = "g++" if env['PLATFORM'] == 'win32': path_separator = ';' - path_regex = re.escape(env['PROJECT_PACKAGES_DIR']) + r'.*\\bin' - gcc = "g++.exe" + path_regex += r'.*\\bin' + gcc += ".exe" else: path_separator = ':' - path_regex = re.escape(env['PROJECT_PACKAGES_DIR']) + r'.*/bin' - gcc = "g++" + path_regex += r'/.+/bin' # Search for the compiler - for path in env['ENV']['PATH'].split(path_separator): - if not re.search(path_regex, path, re.IGNORECASE): + for pathdir in env['ENV']['PATH'].split(path_separator): + if not re.search(path_regex, pathdir, re.IGNORECASE): continue - for file in os.listdir(path): - if not file.endswith(gcc): + for filepath in os.listdir(pathdir): + if not filepath.endswith(gcc): continue # Cache the g++ path to no search always if os.path.exists(ENV_BUILD_PATH): - print('Caching g++ for current env') + blab('Caching g++ for current env') with open(GCC_PATH_CACHE, 'w+') as f: - f.write(file) + f.write(filepath) - return file + return filepath - file = env.get('CXX') - print("Couldn't find a compiler! Fallback to", file) - return file + filepath = env.get('CXX') + blab("Couldn't find a compiler! Fallback to %s" % filepath) + return filepath # # Use the compiler to get a list of all enabled features @@ -191,7 +223,6 @@ def load_marlin_features(): return # Process defines - #print(env.Dump()) build_flags = env.get('BUILD_FLAGS') build_flags = env.ParseFlagsExtended(build_flags) @@ -209,7 +240,7 @@ def load_marlin_features(): cmd += ['-w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h'] cmd = ' '.join(cmd) - print(cmd) + blab(cmd) define_list = subprocess.check_output(cmd, shell=True).splitlines() marlin_features = {} for define in define_list: diff --git a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py index 02957ec47026..f7d3f0d03ab7 100644 --- a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py +++ b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py @@ -1,6 +1,19 @@ import os,shutil from SCons.Script import DefaultEnvironment from platformio import util +try: + # PIO < 4.4 + from platformio.managers.package import PackageManager +except ImportError: + # PIO >= 4.4 + from platformio.package.meta import PackageSpec as PackageManager + +def parse_pkg_uri(spec): + if PackageManager.__name__ == 'PackageSpec': + return PackageManager(spec).name + else: + name, _, _ = PackageManager.parse_pkg_uri(spec) + return name def copytree(src, dst, symlinks=False, ignore=None): for item in os.listdir(src): @@ -16,7 +29,18 @@ def copytree(src, dst, symlinks=False, ignore=None): board = env.BoardConfig() variant = board.get("build.variant") -FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32") +platform_packages = env.GetProjectOption('platform_packages') +# if there's no framework defined, take it from the class name of platform +framewords = { + "Ststm32Platform": "framework-arduinoststm32", + "AtmelavrPlatform": "framework-arduino-avr" +} +if len(platform_packages) == 0: + platform_name = framewords[platform.__class__.__name__] +else: + platform_name = parse_pkg_uri(platform_packages[0]) + +FRAMEWORK_DIR = platform.get_package_dir(platform_name) assert os.path.isdir(FRAMEWORK_DIR) assert os.path.isdir("buildroot/share/PlatformIO/variants") diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c index 4014a519a305..db0a439562a6 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c @@ -125,38 +125,62 @@ const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED const PinMap PinMap_PWM[] = { + + // 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 = [FAN4, FAN5, HEATER6, FAN7] + // TIM2 = [, HEATER1, BED, ] + // TIM3 = [, , HEATER2, HEATER0] + // TIM4 = [HEATER5, HEATER4, , HEATER3] + // TIM8 = [FAN3, HEATER7, FAN2, FAN6] + // TIM9 = [FAN0, FAN1, , ] + {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 HEATER0 - {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 HEATER1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 HEATER1 {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 HEATER2 - {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 BED - {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 FAN0 - {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 FAN1 - {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 FAN2 - {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 EXTENSION1-4 - {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 BL-TOUCH-SERVO - - // These pins have been defined for something else on the board but they MIGHT be - // used by the user as PWM pins if they aren't used for their primary purpose. + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 HEATER3 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 HEATER4 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 HEATER5 + {PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 HEATER6 + {PI_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 HEATER7 + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 BED + + {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 FAN0 + {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 FAN1 + {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 FAN2 + {PI_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 FAN3 + {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 FAN4 + {PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 FAN5 + {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 FAN6 + {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 FAN7 + + + // Alternate timer assignments for pins commonly using PWM + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N HEATER0 + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N HEATER0 + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 HEATER1 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N HEATER2 + //{PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N HEATER2 + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 BED + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 BED + //{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 FAN2 + //{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 FAN6 + + // Pins with an available timer channel, on a timer already allocated for PWM. + // These can be freely used for purposes requiring PWM, without creating new timer conflicts. + // This pins are very likely already used for other purposes and enabling PWM on them won't be useful. + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 BLTouch / Probe Output {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 ESP8266 connector. Available if 8266 isn't used {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 ESP8266 connector. Available if 8266 isn't used - {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 I2C connector, SDA pin. Available if I2C isn't used. - // TIM5_CH1 is used by the Servo Library - {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 BL-TOUCH port. Available if Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN - /** - * Unused by specifications on SKR-Pro. + /* + * Pins not utilizing hardware PWM on the GTR. * 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 @@ -173,20 +197,16 @@ const PinMap PinMap_PWM[] = { //{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_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 @@ -197,30 +217,17 @@ const PinMap PinMap_PWM[] = { //{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 + //{PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - {PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - {PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio - //{PF_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 - //{PF_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 - //{PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 - //{PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 - #endif - #if STM32F4X_PIN_NUM >= 176 //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 - #endif + //{PF_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PF_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + //{PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + //{PH_10, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PH_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 {NC, NP, 0} }; #endif diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/variant.h b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/variant.h index 1ba0a18d6af6..2da195c6cff0 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/variant.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/variant.h @@ -255,8 +255,8 @@ extern "C" { // 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 // Only 1 Servo PIN on SKR-PRO, so use the same timer as defined in PeripheralPins +#define TIMER_TONE TIM10 +#define TIMER_SERVO TIM5 #define TIMER_SERIAL TIM7 // UART Definitions diff --git a/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h b/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h new file mode 100755 index 000000000000..81f2ae3e19a1 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h @@ -0,0 +1,461 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + + 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., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define NUM_DIGITAL_PINS 86 +#define NUM_ANALOG_INPUTS 16 +#define analogInputToDigitalPin(p) ((p < 16) ? (p) + 54 : -1) +#define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46)) + +#define PIN_SPI_SS (53) +#define PIN_SPI_MOSI (51) +#define PIN_SPI_MISO (50) +#define PIN_SPI_SCK (52) + +static const uint8_t SS = PIN_SPI_SS; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +#define PIN_WIRE_SDA (20) +#define PIN_WIRE_SCL (21) + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +#define LED_BUILTIN 13 + +#define PIN_A0 (54) +#define PIN_A1 (55) +#define PIN_A2 (56) +#define PIN_A3 (57) +#define PIN_A4 (58) +#define PIN_A5 (59) +#define PIN_A6 (60) +#define PIN_A7 (61) +#define PIN_A8 (62) +#define PIN_A9 (63) +#define PIN_A10 (64) +#define PIN_A11 (65) +#define PIN_A12 (66) +#define PIN_A13 (67) +#define PIN_A14 (68) +#define PIN_A15 (69) + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; +static const uint8_t A5 = PIN_A5; +static const uint8_t A6 = PIN_A6; +static const uint8_t A7 = PIN_A7; +static const uint8_t A8 = PIN_A8; +static const uint8_t A9 = PIN_A9; +static const uint8_t A10 = PIN_A10; +static const uint8_t A11 = PIN_A11; +static const uint8_t A12 = PIN_A12; +static const uint8_t A13 = PIN_A13; +static const uint8_t A14 = PIN_A14; +static const uint8_t A15 = PIN_A15; + +// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins) +// Only pins available for RECEIVE (TRANSMIT can be on any pin): +// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me) +// Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 + +#define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \ + (((p) >= 50) && ((p) <= 53)) || \ + (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) ) + +#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \ + ( (((p) >= 62) && ((p) <= 69)) ? 2 : \ + 0 ) ) + +#define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \ + ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \ + ((uint8_t *)0) ) ) + +#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \ + ( ((p) == 50) ? 3 : \ + ( ((p) == 51) ? 2 : \ + ( ((p) == 52) ? 1 : \ + ( ((p) == 53) ? 0 : \ + ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \ + 0 ) ) ) ) ) ) + +#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) : NOT_AN_INTERRUPT))) + +#ifdef ARDUINO_MAIN + +const uint16_t PROGMEM port_to_mode_PGM[] = { + NOT_A_PORT, + (uint16_t) &DDRA, + (uint16_t) &DDRB, + (uint16_t) &DDRC, + (uint16_t) &DDRD, + (uint16_t) &DDRE, + (uint16_t) &DDRF, + (uint16_t) &DDRG, + (uint16_t) &DDRH, + NOT_A_PORT, + (uint16_t) &DDRJ, + (uint16_t) &DDRK, + (uint16_t) &DDRL, +}; + +const uint16_t PROGMEM port_to_output_PGM[] = { + NOT_A_PORT, + (uint16_t) &PORTA, + (uint16_t) &PORTB, + (uint16_t) &PORTC, + (uint16_t) &PORTD, + (uint16_t) &PORTE, + (uint16_t) &PORTF, + (uint16_t) &PORTG, + (uint16_t) &PORTH, + NOT_A_PORT, + (uint16_t) &PORTJ, + (uint16_t) &PORTK, + (uint16_t) &PORTL, +}; + +const uint16_t PROGMEM port_to_input_PGM[] = { + NOT_A_PIN, + (uint16_t) &PINA, + (uint16_t) &PINB, + (uint16_t) &PINC, + (uint16_t) &PIND, + (uint16_t) &PINE, + (uint16_t) &PINF, + (uint16_t) &PING, + (uint16_t) &PINH, + NOT_A_PIN, + (uint16_t) &PINJ, + (uint16_t) &PINK, + (uint16_t) &PINL, +}; + +const uint8_t PROGMEM digital_pin_to_port_PGM[] = { + // PORTLIST + // ------------------------------------------- + PE , // PE 0 ** 0 ** USART0_RX + PE , // PE 1 ** 1 ** USART0_TX + PE , // PE 4 ** 2 ** PWM2 + PE , // PE 5 ** 3 ** PWM3 + PG , // PG 5 ** 4 ** PWM4 + PE , // PE 3 ** 5 ** PWM5 + PH , // PH 3 ** 6 ** PWM6 + PH , // PH 4 ** 7 ** PWM7 + PH , // PH 5 ** 8 ** PWM8 + PH , // PH 6 ** 9 ** PWM9 + PB , // PB 4 ** 10 ** PWM10 + PB , // PB 5 ** 11 ** PWM11 + PB , // PB 6 ** 12 ** PWM12 + PB , // PB 7 ** 13 ** PWM13 + PJ , // PJ 1 ** 14 ** USART3_TX + PJ , // PJ 0 ** 15 ** USART3_RX + PH , // PH 1 ** 16 ** USART2_TX + PH , // PH 0 ** 17 ** USART2_RX + PD , // PD 3 ** 18 ** USART1_TX + PD , // PD 2 ** 19 ** USART1_RX + PD , // PD 1 ** 20 ** I2C_SDA + PD , // PD 0 ** 21 ** I2C_SCL + PA , // PA 0 ** 22 ** D22 + PA , // PA 1 ** 23 ** D23 + PA , // PA 2 ** 24 ** D24 + PA , // PA 3 ** 25 ** D25 + PA , // PA 4 ** 26 ** D26 + PA , // PA 5 ** 27 ** D27 + PA , // PA 6 ** 28 ** D28 + PA , // PA 7 ** 29 ** D29 + PC , // PC 7 ** 30 ** D30 + PC , // PC 6 ** 31 ** D31 + PC , // PC 5 ** 32 ** D32 + PC , // PC 4 ** 33 ** D33 + PC , // PC 3 ** 34 ** D34 + PC , // PC 2 ** 35 ** D35 + PC , // PC 1 ** 36 ** D36 + PC , // PC 0 ** 37 ** D37 + PD , // PD 7 ** 38 ** D38 + PG , // PG 2 ** 39 ** D39 + PG , // PG 1 ** 40 ** D40 + PG , // PG 0 ** 41 ** D41 + PL , // PL 7 ** 42 ** D42 + PL , // PL 6 ** 43 ** D43 + PL , // PL 5 ** 44 ** D44 + PL , // PL 4 ** 45 ** D45 + PL , // PL 3 ** 46 ** D46 + PL , // PL 2 ** 47 ** D47 + PL , // PL 1 ** 48 ** D48 + PL , // PL 0 ** 49 ** D49 + PB , // PB 3 ** 50 ** SPI_MISO + PB , // PB 2 ** 51 ** SPI_MOSI + PB , // PB 1 ** 52 ** SPI_SCK + PB , // PB 0 ** 53 ** SPI_SS + PF , // PF 0 ** 54 ** A0 + PF , // PF 1 ** 55 ** A1 + PF , // PF 2 ** 56 ** A2 + PF , // PF 3 ** 57 ** A3 + PF , // PF 4 ** 58 ** A4 + PF , // PF 5 ** 59 ** A5 + PF , // PF 6 ** 60 ** A6 + PF , // PF 7 ** 61 ** A7 + PK , // PK 0 ** 62 ** A8 + PK , // PK 1 ** 63 ** A9 + PK , // PK 2 ** 64 ** A10 + PK , // PK 3 ** 65 ** A11 + PK , // PK 4 ** 66 ** A12 + PK , // PK 5 ** 67 ** A13 + PK , // PK 6 ** 68 ** A14 + PK , // PK 7 ** 69 ** A15 + PG , // PG 4 ** 70 ** D70 + PG , // PG 3 ** 71 ** D71 + PJ , // PJ 2 ** 72 ** D72 + PJ , // PJ 3 ** 73 ** D73 + PJ , // PJ 7 ** 74 ** D74 + PJ , // PJ 4 ** 75 ** D75 + PJ , // PJ 5 ** 76 ** D76 + PJ , // PJ 6 ** 77 ** D77 + PE , // PE 2 ** 78 ** D78 + PE , // PE 6 ** 79 ** D79 + PE , // PE 7 ** 80 ** D80 + PD , // PD 4 ** 81 ** D81 + PD , // PD 5 ** 82 ** D82 + PD , // PD 6 ** 83 ** D83 + PH , // PH 2 ** 84 ** D84 + PH , // PH 7 ** 85 ** D85 +}; + +const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { + // PIN IN PORT + // ------------------------------------------- + _BV( 0 ) , // PE 0 ** 0 ** USART0_RX + _BV( 1 ) , // PE 1 ** 1 ** USART0_TX + _BV( 4 ) , // PE 4 ** 2 ** PWM2 + _BV( 5 ) , // PE 5 ** 3 ** PWM3 + _BV( 5 ) , // PG 5 ** 4 ** PWM4 + _BV( 3 ) , // PE 3 ** 5 ** PWM5 + _BV( 3 ) , // PH 3 ** 6 ** PWM6 + _BV( 4 ) , // PH 4 ** 7 ** PWM7 + _BV( 5 ) , // PH 5 ** 8 ** PWM8 + _BV( 6 ) , // PH 6 ** 9 ** PWM9 + _BV( 4 ) , // PB 4 ** 10 ** PWM10 + _BV( 5 ) , // PB 5 ** 11 ** PWM11 + _BV( 6 ) , // PB 6 ** 12 ** PWM12 + _BV( 7 ) , // PB 7 ** 13 ** PWM13 + _BV( 1 ) , // PJ 1 ** 14 ** USART3_TX + _BV( 0 ) , // PJ 0 ** 15 ** USART3_RX + _BV( 1 ) , // PH 1 ** 16 ** USART2_TX + _BV( 0 ) , // PH 0 ** 17 ** USART2_RX + _BV( 3 ) , // PD 3 ** 18 ** USART1_TX + _BV( 2 ) , // PD 2 ** 19 ** USART1_RX + _BV( 1 ) , // PD 1 ** 20 ** I2C_SDA + _BV( 0 ) , // PD 0 ** 21 ** I2C_SCL + _BV( 0 ) , // PA 0 ** 22 ** D22 + _BV( 1 ) , // PA 1 ** 23 ** D23 + _BV( 2 ) , // PA 2 ** 24 ** D24 + _BV( 3 ) , // PA 3 ** 25 ** D25 + _BV( 4 ) , // PA 4 ** 26 ** D26 + _BV( 5 ) , // PA 5 ** 27 ** D27 + _BV( 6 ) , // PA 6 ** 28 ** D28 + _BV( 7 ) , // PA 7 ** 29 ** D29 + _BV( 7 ) , // PC 7 ** 30 ** D30 + _BV( 6 ) , // PC 6 ** 31 ** D31 + _BV( 5 ) , // PC 5 ** 32 ** D32 + _BV( 4 ) , // PC 4 ** 33 ** D33 + _BV( 3 ) , // PC 3 ** 34 ** D34 + _BV( 2 ) , // PC 2 ** 35 ** D35 + _BV( 1 ) , // PC 1 ** 36 ** D36 + _BV( 0 ) , // PC 0 ** 37 ** D37 + _BV( 7 ) , // PD 7 ** 38 ** D38 + _BV( 2 ) , // PG 2 ** 39 ** D39 + _BV( 1 ) , // PG 1 ** 40 ** D40 + _BV( 0 ) , // PG 0 ** 41 ** D41 + _BV( 7 ) , // PL 7 ** 42 ** D42 + _BV( 6 ) , // PL 6 ** 43 ** D43 + _BV( 5 ) , // PL 5 ** 44 ** D44 + _BV( 4 ) , // PL 4 ** 45 ** D45 + _BV( 3 ) , // PL 3 ** 46 ** D46 + _BV( 2 ) , // PL 2 ** 47 ** D47 + _BV( 1 ) , // PL 1 ** 48 ** D48 + _BV( 0 ) , // PL 0 ** 49 ** D49 + _BV( 3 ) , // PB 3 ** 50 ** SPI_MISO + _BV( 2 ) , // PB 2 ** 51 ** SPI_MOSI + _BV( 1 ) , // PB 1 ** 52 ** SPI_SCK + _BV( 0 ) , // PB 0 ** 53 ** SPI_SS + _BV( 0 ) , // PF 0 ** 54 ** A0 + _BV( 1 ) , // PF 1 ** 55 ** A1 + _BV( 2 ) , // PF 2 ** 56 ** A2 + _BV( 3 ) , // PF 3 ** 57 ** A3 + _BV( 4 ) , // PF 4 ** 58 ** A4 + _BV( 5 ) , // PF 5 ** 59 ** A5 + _BV( 6 ) , // PF 6 ** 60 ** A6 + _BV( 7 ) , // PF 7 ** 61 ** A7 + _BV( 0 ) , // PK 0 ** 62 ** A8 + _BV( 1 ) , // PK 1 ** 63 ** A9 + _BV( 2 ) , // PK 2 ** 64 ** A10 + _BV( 3 ) , // PK 3 ** 65 ** A11 + _BV( 4 ) , // PK 4 ** 66 ** A12 + _BV( 5 ) , // PK 5 ** 67 ** A13 + _BV( 6 ) , // PK 6 ** 68 ** A14 + _BV( 7 ) , // PK 7 ** 69 ** A15 + _BV( 4 ) , // PG 4 ** 70 ** D70 + _BV( 3 ) , // PG 3 ** 71 ** D71 + _BV( 2 ) , // PJ 2 ** 72 ** D72 + _BV( 3 ) , // PJ 3 ** 73 ** D73 + _BV( 7 ) , // PJ 7 ** 74 ** D74 + _BV( 4 ) , // PJ 4 ** 75 ** D75 + _BV( 5 ) , // PJ 5 ** 76 ** D76 + _BV( 6 ) , // PJ 6 ** 77 ** D77 + _BV( 2 ) , // PE 2 ** 78 ** D78 + _BV( 6 ) , // PE 6 ** 79 ** D79 + _BV( 7 ) , // PE 7 ** 80 ** D80 + _BV( 4 ) , // PD 4 ** 81 ** D81 + _BV( 5 ) , // PD 5 ** 82 ** D82 + _BV( 6 ) , // PD 6 ** 83 ** D83 + _BV( 2 ) , // PH 2 ** 84 ** D84 + _BV( 7 ) , // PH 7 ** 85 ** D85 +}; + +const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { + // TIMERS + // ------------------------------------------- + NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX + NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX + TIMER3B , // PE 4 ** 2 ** PWM2 + TIMER3C , // PE 5 ** 3 ** PWM3 + TIMER0B , // PG 5 ** 4 ** PWM4 + TIMER3A , // PE 3 ** 5 ** PWM5 + TIMER4A , // PH 3 ** 6 ** PWM6 + TIMER4B , // PH 4 ** 7 ** PWM7 + TIMER4C , // PH 5 ** 8 ** PWM8 + TIMER2B , // PH 6 ** 9 ** PWM9 + TIMER2A , // PB 4 ** 10 ** PWM10 + TIMER1A , // PB 5 ** 11 ** PWM11 + TIMER1B , // PB 6 ** 12 ** PWM12 + TIMER0A , // PB 7 ** 13 ** PWM13 + NOT_ON_TIMER , // PJ 1 ** 14 ** USART3_TX + NOT_ON_TIMER , // PJ 0 ** 15 ** USART3_RX + NOT_ON_TIMER , // PH 1 ** 16 ** USART2_TX + NOT_ON_TIMER , // PH 0 ** 17 ** USART2_RX + NOT_ON_TIMER , // PD 3 ** 18 ** USART1_TX + NOT_ON_TIMER , // PD 2 ** 19 ** USART1_RX + NOT_ON_TIMER , // PD 1 ** 20 ** I2C_SDA + NOT_ON_TIMER , // PD 0 ** 21 ** I2C_SCL + NOT_ON_TIMER , // PA 0 ** 22 ** D22 + NOT_ON_TIMER , // PA 1 ** 23 ** D23 + NOT_ON_TIMER , // PA 2 ** 24 ** D24 + NOT_ON_TIMER , // PA 3 ** 25 ** D25 + NOT_ON_TIMER , // PA 4 ** 26 ** D26 + NOT_ON_TIMER , // PA 5 ** 27 ** D27 + NOT_ON_TIMER , // PA 6 ** 28 ** D28 + NOT_ON_TIMER , // PA 7 ** 29 ** D29 + NOT_ON_TIMER , // PC 7 ** 30 ** D30 + NOT_ON_TIMER , // PC 6 ** 31 ** D31 + NOT_ON_TIMER , // PC 5 ** 32 ** D32 + NOT_ON_TIMER , // PC 4 ** 33 ** D33 + NOT_ON_TIMER , // PC 3 ** 34 ** D34 + NOT_ON_TIMER , // PC 2 ** 35 ** D35 + NOT_ON_TIMER , // PC 1 ** 36 ** D36 + NOT_ON_TIMER , // PC 0 ** 37 ** D37 + NOT_ON_TIMER , // PD 7 ** 38 ** D38 + NOT_ON_TIMER , // PG 2 ** 39 ** D39 + NOT_ON_TIMER , // PG 1 ** 40 ** D40 + NOT_ON_TIMER , // PG 0 ** 41 ** D41 + NOT_ON_TIMER , // PL 7 ** 42 ** D42 + NOT_ON_TIMER , // PL 6 ** 43 ** D43 + TIMER5C , // PL 5 ** 44 ** D44 + TIMER5B , // PL 4 ** 45 ** D45 + TIMER5A , // PL 3 ** 46 ** D46 + NOT_ON_TIMER , // PL 2 ** 47 ** D47 + NOT_ON_TIMER , // PL 1 ** 48 ** D48 + NOT_ON_TIMER , // PL 0 ** 49 ** D49 + NOT_ON_TIMER , // PB 3 ** 50 ** SPI_MISO + NOT_ON_TIMER , // PB 2 ** 51 ** SPI_MOSI + NOT_ON_TIMER , // PB 1 ** 52 ** SPI_SCK + NOT_ON_TIMER , // PB 0 ** 53 ** SPI_SS + NOT_ON_TIMER , // PF 0 ** 54 ** A0 + NOT_ON_TIMER , // PF 1 ** 55 ** A1 + NOT_ON_TIMER , // PF 2 ** 56 ** A2 + NOT_ON_TIMER , // PF 3 ** 57 ** A3 + NOT_ON_TIMER , // PF 4 ** 58 ** A4 + NOT_ON_TIMER , // PF 5 ** 59 ** A5 + NOT_ON_TIMER , // PF 6 ** 60 ** A6 + NOT_ON_TIMER , // PF 7 ** 61 ** A7 + NOT_ON_TIMER , // PK 0 ** 62 ** A8 + NOT_ON_TIMER , // PK 1 ** 63 ** A9 + NOT_ON_TIMER , // PK 2 ** 64 ** A10 + NOT_ON_TIMER , // PK 3 ** 65 ** A11 + NOT_ON_TIMER , // PK 4 ** 66 ** A12 + NOT_ON_TIMER , // PK 5 ** 67 ** A13 + NOT_ON_TIMER , // PK 6 ** 68 ** A14 + NOT_ON_TIMER , // PK 7 ** 69 ** A15 + NOT_ON_TIMER , // PG 4 ** 70 ** D70 + NOT_ON_TIMER , // PG 3 ** 71 ** D71 + NOT_ON_TIMER , // PJ 2 ** 72 ** D72 + NOT_ON_TIMER , // PJ 3 ** 73 ** D73 + NOT_ON_TIMER , // PJ 7 ** 74 ** D74 + NOT_ON_TIMER , // PJ 4 ** 75 ** D75 + NOT_ON_TIMER , // PJ 5 ** 76 ** D76 + NOT_ON_TIMER , // PJ 6 ** 77 ** D77 + NOT_ON_TIMER , // PE 2 ** 78 ** D78 + NOT_ON_TIMER , // PE 6 ** 79 ** D79 + NOT_ON_TIMER , // PE 7 ** 80 ** D80 + NOT_ON_TIMER , // PD 4 ** 81 ** D81 + NOT_ON_TIMER , // PD 5 ** 82 ** D82 + NOT_ON_TIMER , // PD 6 ** 83 ** D83 + NOT_ON_TIMER , // PH 2 ** 84 ** D84 + NOT_ON_TIMER , // PH 7 ** 85 ** D85 +}; + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_HARDWARE1 Serial1 +#define SERIAL_PORT_HARDWARE2 Serial2 +#define SERIAL_PORT_HARDWARE3 Serial3 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 +#define SERIAL_PORT_HARDWARE_OPEN1 Serial2 +#define SERIAL_PORT_HARDWARE_OPEN2 Serial3 + +#endif diff --git a/buildroot/share/git/ghtp b/buildroot/share/git/ghtp index 3c0e21e371b1..14afd8a27b7d 100755 --- a/buildroot/share/git/ghtp +++ b/buildroot/share/git/ghtp @@ -5,13 +5,15 @@ # Set all remotes in the current repo to HTTPS or SSH connection. # Useful when switching environments, using public wifi, etc. # +# Optionally, specify a particular remote to change. +# GH_SSH="git@github\.com:" GH_HTTPS="https:\/\/github\.com\/" case "$1" in - -[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;; - -[Ss]) TYPE=SSH ; MATCH="https:" ; FORMULA="$GH_HTTPS/$GH_SSH" ;; + -[Hh]) TYPE=HTTPS ; MATCH="git@" ; REPLACE="$GH_SSH/$GH_HTTPS" ;; + -[Ss]) TYPE=SSH ; MATCH="https:" ; REPLACE="$GH_HTTPS/$GH_SSH" ;; *) echo "Usage: `basename $0` -h | -s" 1>&2 echo -e " \e[0;92m-h\e[0m to switch to HTTPS" 1>&2 @@ -22,12 +24,14 @@ esac AWK=$(which gawk || which awk) -REMOTES=$(git remote -v | egrep "\t$MATCH" | "$AWK" '{print $1 " " $2}' | sort -u | sed "s/$FORMULA/") +# Match all or specified remotes of the other type +REGEX="\t$MATCH" ; [[ $# > 1 ]] && REGEX="^$2$REGEX" + +REMOTES=$(git remote -v | egrep "$REGEX" | "$AWK" '{print $1 " " $2}' | sort -u | sed "s/$REPLACE/") -if [[ -z $REMOTES ]]; then - echo "Nothing to do." ; exit -fi +[[ -z $REMOTES ]] && { echo "Nothing to do." ; exit ; } +# Update a remote for each results pair echo "$REMOTES" | xargs -n2 git remote set-url echo -n "Remotes set to $TYPE: " diff --git a/buildroot/share/scripts/config-labels.py b/buildroot/share/scripts/config-labels.py index 8effb54eed58..267aa2d27353 100755 --- a/buildroot/share/scripts/config-labels.py +++ b/buildroot/share/scripts/config-labels.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # for python3.5 or higher #----------------------------------- diff --git a/buildroot/share/scripts/pinsformat.js b/buildroot/share/scripts/pinsformat.js index 3e2a57b556dc..a82c2f2659f0 100755 --- a/buildroot/share/scripts/pinsformat.js +++ b/buildroot/share/scripts/pinsformat.js @@ -38,10 +38,12 @@ for (let m of mpatt) mexpr.push(new RegExp('^' + m + '$')); const argv = process.argv.slice(2), argc = argv.length; -var src_file = 0, src_name = 'STDIN', dst_file; +var src_file = 0, src_name = 'STDIN', dst_file, do_log = false; if (argc > 0) { - src_file = src_name = argv[0]; - dst_file = argv[argc > 1 ? 1 : 0]; + let ind = 0; + if (argv[0] == '-v') { do_log = true; ind++; } + dst_file = src_file = src_name = argv[ind++]; + if (ind < argc) dst_file = argv[ind]; } // Read from file or STDIN until it terminates @@ -81,7 +83,7 @@ function process_text(txt) { aliasPatt = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+([A-Z_][A-Z0-9_()]+)\\s*(//.*)?$'), switchPatt = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s*(//.*)?$'), undefPatt = new RegExp('^(\\s*(//)?#undef)\\s+([A-Z_][A-Z0-9_]+)\\s*(//.*)?$'), - defPatt = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+(\\w+)\\s*(//.*)?$'), + defPatt = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+([-_\\w]+)\\s*(//.*)?$'), condPatt = new RegExp('^(\\s*(//)?#(if|ifn?def|else|elif)(\\s+\\S+)*)\\s+(//.*)$'), commPatt = new RegExp('^\\s{20,}(//.*)?$'); const col_value_lj = col_comment - patt.pad - 2; @@ -98,6 +100,7 @@ function process_text(txt) { // // #define MY_PIN [pin] // + if (do_log) console.log("pin:", line); const pinnum = r[4].charAt(0) == 'P' ? r[4] : r[4].lpad(patt.pad); line = r[1] + ' ' + r[3]; line = line.rpad(col_value_lj) + pinnum; @@ -107,31 +110,57 @@ function process_text(txt) { // // #define MY_PIN -1 // + if (do_log) console.log("pin -1:", line); line = r[1] + ' ' + r[3]; line = line.rpad(col_value_lj) + '-1'; if (r[5]) line = line.rpad(col_comment) + r[5]; } else if ((r = skipPatt.exec(line)) !== null) { + // + // #define SKIP_ME + // + if (do_log) console.log("skip:", line); } else if ((r = aliasPatt.exec(line)) !== null) { + // + // #define ALIAS OTHER + // + if (do_log) console.log("alias:", line); line = r[1] + ' ' + r[3]; line += r[4].lpad(col_value_rj + 1 - line.length); if (r[5]) line = line.rpad(col_comment) + r[5]; } else if ((r = switchPatt.exec(line)) !== null) { + // + // #define SWITCH + // + if (do_log) console.log("switch:", line); line = r[1] + ' ' + r[3]; if (r[4]) line = line.rpad(col_comment) + r[4]; check_comment_next = true; } else if ((r = defPatt.exec(line)) !== null) { - line = r[1] + ' ' + r[3] + ' ' + r[4]; - if (r[5]) line = line.rpad(col_comment) + r[5]; + // + // #define ... + // + if (do_log) console.log("def:", line); + line = r[1] + ' ' + r[3] + ' '; + line += r[4].lpad(col_value_rj + 1 - line.length); + if (r[5]) line = line.rpad(col_comment - 1) + ' ' + r[5]; } else if ((r = undefPatt.exec(line)) !== null) { + // + // #undef ... + // + if (do_log) console.log("undef:", line); line = r[1] + ' ' + r[3]; if (r[4]) line = line.rpad(col_comment) + r[4]; } else if ((r = condPatt.exec(line)) !== null) { + // + // #if ... + // + if (do_log) console.log("cond:", line); line = r[1].rpad(col_comment) + r[5]; check_comment_next = true; } diff --git a/buildroot/share/sublime/MarlinFirmware.sublime-project b/buildroot/share/sublime/MarlinFirmware.sublime-project index e437369ec243..9b5234f7a13c 100644 --- a/buildroot/share/sublime/MarlinFirmware.sublime-project +++ b/buildroot/share/sublime/MarlinFirmware.sublime-project @@ -8,7 +8,6 @@ "MarlinFirmware/lib", "Marlin/lib", "datatmp", - "Marlin/*/src", ".vscode" ], "binary_file_patterns": diff --git a/buildroot/share/vscode/avrdude.conf b/buildroot/share/vscode/avrdude.conf index 9f85aa0d26d6..991d255750f5 100644 --- a/buildroot/share/vscode/avrdude.conf +++ b/buildroot/share/vscode/avrdude.conf @@ -151,7 +151,7 @@ # # INSTRUCTION FORMATS # -# Instruction formats are specified as a comma seperated list of +# Instruction formats are specified as a comma separated list of # string values containing information (bit specifiers) about each # of the 32 bits of the instruction. Bit specifiers may be one of # the following formats: diff --git a/buildroot/share/vscode/avrdude_linux.conf b/buildroot/share/vscode/avrdude_linux.conf index 64d3b677d5bf..ff429a028cca 100644 --- a/buildroot/share/vscode/avrdude_linux.conf +++ b/buildroot/share/vscode/avrdude_linux.conf @@ -151,7 +151,7 @@ # # INSTRUCTION FORMATS # -# Instruction formats are specified as a comma seperated list of +# Instruction formats are specified as a comma separated list of # string values containing information (bit specifiers) about each # of the 32 bits of the instruction. Bit specifiers may be one of # the following formats: diff --git a/buildroot/share/vscode/avrdude_macOS.conf b/buildroot/share/vscode/avrdude_macOS.conf index 814e87e35ea3..6147a2259ac9 100644 --- a/buildroot/share/vscode/avrdude_macOS.conf +++ b/buildroot/share/vscode/avrdude_macOS.conf @@ -151,7 +151,7 @@ # # INSTRUCTION FORMATS # -# Instruction formats are specified as a comma seperated list of +# Instruction formats are specified as a comma separated list of # string values containing information (bit specifiers) about each # of the 32 bits of the instruction. Bit specifiers may be one of # the following formats: diff --git a/buildroot/tests/mks_robin_nano35-tests b/buildroot/tests/mks_robin_nano35-tests index ac72050875ab..92c97be756cd 100644 --- a/buildroot/tests/mks_robin_nano35-tests +++ b/buildroot/tests/mks_robin_nano35-tests @@ -35,5 +35,12 @@ opt_disable TOUCH_SCREEN opt_enable TFT_LVGL_UI_SPI exec_test $1 $2 "MKS Robin v2 nano LVGL SPI" +use_example_configs Mks/Robin +opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 +opt_disable TFT_320x240 +opt_enable TOUCH_SCREEN +opt_enable TFT_480x320_SPI +exec_test $1 $2 "MKS Robin v2 nano New Color UI 480x320 SPI" + # cleanup restore_configs diff --git a/platformio.ini b/platformio.ini index 9ee43c245356..0a48e49ea1af 100644 --- a/platformio.ini +++ b/platformio.ini @@ -49,12 +49,12 @@ default_src_filter = + - - + - - - - - - - - - - + - - + - + - - - - - + - - - - @@ -241,11 +241,11 @@ HAS_MENU_TMC = src_filter=+ HAS_MENU_TOUCH_SCREEN = src_filter=+ HAS_MENU_UBL = src_filter=+ ANYCUBIC_LCD_I3MEGA = src_filter=+ -HAS_DGUS_LCD = src_filter=+ + +HAS_DGUS_LCD = src_filter=+ + TOUCH_UI_FTDI_EVE = src_filter=+ -HAS_ANYCUBIC_TFT_EXTUI = src_filter=+ -EXTUI_EXAMPLE = src_filter=+ -MALYAN_LCD = src_filter=+ +HAS_ANYCUBIC_TFT_EXTUI = src_filter=+ +EXTUI_EXAMPLE = src_filter=+ +MALYAN_LCD = src_filter=+ HAS_SPI_LCD = src_filter=+ USB_FLASH_DRIVE_SUPPORT = src_filter=+ AUTO_BED_LEVELING_BILINEAR = src_filter=+ @@ -406,9 +406,20 @@ src_filter = ${common.default_src_filter} + # ATmega2560 # [env:mega2560] -platform = atmelavr -extends = common_avr8 -board = megaatmega2560 +platform = atmelavr +extends = common_avr8 +board = megaatmega2560 + +# +# ATmega2560 with extended pins 70-85 defined +# +[env:mega2560ext] +platform = atmelavr +extends = mega2560 +board = megaatmega2560 +board_build.variant = megaextendedpins +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py # # ATmega1280