diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index b2287837998b..f7ba348cc002 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -81,6 +81,7 @@ jobs: - STM32F103RET6_creality - LERDGEX - mks_robin_nano35 + - NUCLEO_F767ZI # Put lengthy tests last diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 628cd28aad85..2c62dcf6d04e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -37,7 +37,7 @@ * * Advanced settings can be found in Configuration_adv.h */ -#define CONFIGURATION_H_VERSION 020007 +#define CONFIGURATION_H_VERSION 020008 //=========================================================================== //============================= Getting Started ============================= @@ -433,6 +433,12 @@ #define DUMMY_THERMISTOR_998_VALUE 25 #define DUMMY_THERMISTOR_999_VALUE 100 +// Resistor values when using a MAX31865 (sensor -5) +// Sensor value is typically 100 (PT100) or 1000 (PT1000) +// Calibration value is typically 430 ohm for AdaFruit PT100 modules and 4300 ohm for AdaFruit PT1000 modules. +//#define MAX31865_SENSOR_OHMS 100 +//#define MAX31865_CALIBRATION_OHMS 430 + // Use temp sensor 1 as a redundant sensor with sensor 0. If the readings // from the two sensors differ too much the print will be aborted. //#define TEMP_SENSOR_1_AS_REDUNDANT @@ -2200,43 +2206,108 @@ //=============================== Graphical TFTs ============================== //============================================================================= +/** + * Specific TFT Model Presets. Enable one of the following options + * or enable TFT_GENERIC and set sub-options. + */ + // -// TFT display with optional touch screen -// Color Marlin UI with standard menu system +// 480x320, 3.5", SPI Display From MKS +// Normally used in MKS Robin Nano V2 // -//#define TFT_320x240 -//#define TFT_320x240_SPI -#define TFT_480x320 -//#define TFT_480x320_SPI +//#define MKS_TS35_V2_0 // -// Skip autodetect and force specific TFT driver -// Mandatory for SPI screens with no MISO line -// Available drivers are: ST7735, ST7789, ST7796, R61505, ILI9328, ILI9341, ILI9488 +// 320x240, 2.4", FSMC Display From MKS +// Normally used in MKS Robin Nano V1.2 // -//#define TFT_DRIVER AUTO +//#define MKS_ROBIN_TFT24 // -// SPI display (MKS Robin Nano V2.0, MKS Gen L V2.0) -// Upscaled 128x64 Marlin UI +// 320x240, 2.8", FSMC Display From MKS +// Normally used in MKS Robin Nano V1.2 // -//#define SPI_GRAPHICAL_TFT +//#define MKS_ROBIN_TFT28 // -// FSMC display (MKS Robin, Alfawise U20, JGAurora A5S, REXYZ A1, etc.) -// Upscaled 128x64 Marlin UI +// 320x240, 3.2", FSMC Display From MKS +// Normally used in MKS Robin Nano V1.2 // -//#define FSMC_GRAPHICAL_TFT +//#define MKS_ROBIN_TFT32 // -// TFT LVGL UI +// 480x320, 3.5", FSMC Display From MKS +// Normally used in MKS Robin Nano V1.2 +// +//#define MKS_ROBIN_TFT35 + +// +// 480x272, 4.3", FSMC Display From MKS +// +//#define MKS_ROBIN_TFT43 + // -// Using default MKS icons and fonts from: https://git.io/JJvzK -// Just copy the 'assets' folder from the build directory to the -// root of your SD card, together with the compiled firmware. +// 320x240, 3.2", FSMC Display From MKS +// Normally used in MKS Robin +// +//#define MKS_ROBIN_TFT_V1_1R + +// +// 480x320, 3.5", FSMC Stock Display from TronxXY +// +#define TFT_TRONXY_X5SA + +// +// 480x320, 3.5", FSMC Stock Display from AnyCubic +// +//#define ANYCUBIC_TFT35 + // -//#define TFT_LVGL_UI_FSMC // Robin nano v1.2 uses FSMC -//#define TFT_LVGL_UI_SPI // Robin nano v2.0 uses SPI +// 320x240, 2.8", FSMC Stock Display from Longer/Alfawise +// +//#define LONGER_LK_TFT28 + +// +// Generic TFT with detailed options +// +//#define TFT_GENERIC +#if ENABLED(TFT_GENERIC) + // :[ 'AUTO', 'ST7735', 'ST7789', 'ST7796', 'R61505', 'ILI9328', 'ILI9341', 'ILI9488' ] + #define TFT_DRIVER AUTO + + // Interface. Enable one of the following options: + //#define TFT_INTERFACE_FSMC + //#define TFT_INTERFACE_SPI + + // TFT Resolution. Enable one of the following options: + //#define TFT_RES_320x240 + //#define TFT_RES_480x272 + //#define TFT_RES_480x320 +#endif + +/** + * TFT UI - User Interface Selection. Enable one of the following options: + * + * TFT_CLASSIC_UI - Emulated DOGM - 128x64 Upscaled + * TFT_COLOR_UI - Marlin Default Menus, Touch Friendly, using full TFT capabilities + * TFT_LVGL_UI - A Modern UI using LVGL + * + * For LVGL_UI also copy the 'assets' folder from the build directory to the + * root of your SD card, together with the compiled firmware. + */ +//#define TFT_CLASSIC_UI +#define TFT_COLOR_UI +//#define TFT_LVGL_UI + +/** + * TFT Rotation. Set to one of the following values: + * + * TFT_ROTATE_90, TFT_ROTATE_90_MIRROR_X, TFT_ROTATE_90_MIRROR_Y, + * TFT_ROTATE_180, TFT_ROTATE_180_MIRROR_X, TFT_ROTATE_180_MIRROR_Y, + * TFT_ROTATE_270, TFT_ROTATE_270_MIRROR_X, TFT_ROTATE_270_MIRROR_Y, + * TFT_MIRROR_X, TFT_MIRROR_Y, TFT_NO_ROTATION + */ +//#define TFT_ROTATION TFT_NO_ROTATION // // Anycubic Mega TFT (AI3M) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 5cb2601bc2f2..ed26770a2458 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -32,7 +32,7 @@ * * Basic settings can be found in Configuration.h */ -#define CONFIGURATION_ADV_H_VERSION 020007 +#define CONFIGURATION_ADV_H_VERSION 020008 //=========================================================================== //============================= Thermal Settings ============================ @@ -808,11 +808,9 @@ #define TRAMMING_POINT_NAME_3 "Back-Right" #define TRAMMING_POINT_NAME_4 "Back-Left" - // Enable to restore leveling setup after operation - #define RESTORE_LEVELING_AFTER_G35 - - // Add a menu item for Assisted Tramming - //#define ASSISTED_TRAMMING_MENU_ITEM + #define RESTORE_LEVELING_AFTER_G35 // Enable to restore leveling setup after operation + //#define REPORT_TRAMMING_MM // Report Z deviation (mm) for each point relative to the first + //#define ASSISTED_TRAMMING_MENU_ITEM // Add a menu item for Assisted Tramming /** * Screw thread: @@ -1050,10 +1048,10 @@ // @section lcd -#if EITHER(ULTIPANEL, EXTENSIBLE_UI) +#if EITHER(IS_ULTIPANEL, EXTENSIBLE_UI) #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) + #if IS_ULTIPANEL #define MANUAL_E_MOVES_RELATIVE // Display extruder move distance rather than "position" #define ULTIPANEL_FEEDMULTIPLY // Encoder sets the feedrate multiplier on the Status Screen #endif @@ -1562,10 +1560,9 @@ #endif // -// FSMC / SPI Graphical TFT +// Classic UI Options // #if TFT_SCALED_DOGLCD - //#define GRAPHICAL_TFT_ROTATE_180 //#define TFT_MARLINUI_COLOR 0xFFFF // White //#define TFT_MARLINBG_COLOR 0x0000 // Black //#define TFT_DISABLED_COLOR 0x0003 // Almost black @@ -2961,7 +2958,7 @@ * This allows the laser to keep in perfect sync with the planner and removes * the powerup/down delay since lasers require negligible time. */ - #define LASER_POWER_INLINE + //#define LASER_POWER_INLINE #if ENABLED(LASER_POWER_INLINE) /** @@ -3378,6 +3375,25 @@ //#define JOYSTICK_DEBUG #endif +/** + * Mechanical Gantry Calibration + * Modern replacement for the Prusa TMC_Z_CALIBRATION. + * Adds capability to work with any adjustable current drivers. + * Implemented as G34 because M915 is deprecated. + */ +//#define MECHANICAL_GANTRY_CALIBRATION +#if ENABLED(MECHANICAL_GANTRY_CALIBRATION) + #define GANTRY_CALIBRATION_CURRENT 600 // Default calibration current in ma + #define GANTRY_CALIBRATION_EXTRA_HEIGHT 15 // Extra distance in mm past Z_###_POS to move + #define GANTRY_CALIBRATION_FEEDRATE 500 // Feedrate for correction move + //#define GANTRY_CALIBRATION_TO_MIN // Enable to calibrate Z in the MIN direction + + //#define GANTRY_CALIBRATION_SAFE_POSITION { X_CENTER, Y_CENTER } // Safe position for nozzle + //#define GANTRY_CALIBRATION_XY_PARK_FEEDRATE 3000 // XY Park Feedrate - MMM + //#define GANTRY_CALIBRATION_COMMANDS_PRE "" + #define GANTRY_CALIBRATION_COMMANDS_POST "G28" // G28 highly recommended to ensure an accurate position +#endif + /** * MAX7219 Debug Matrix * diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp index 47060d6a5be2..7df180cbaa82 100644 --- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp +++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp @@ -145,7 +145,7 @@ uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va } #if ENABLED(LIGHTWEIGHT_UI) - #include "../../../lcd/ultralcd.h" + #include "../../../lcd/marlinui.h" #include "../../shared/HAL_ST7920.h" #define ST7920_CS_PIN LCD_PINS_RS diff --git a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp index 1682faea666d..d9fbabce2148 100644 --- a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp +++ b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp @@ -154,7 +154,7 @@ void Stepper::digipot_init() { NVIC_SetPriority(PWM_IRQn, NVIC_EncodePriority(0, 10, 0)); // normal priority for PWM module (can stand some jitter on the Vref signals) } -void Stepper::digipot_current(const uint8_t driver, const int16_t current) { +void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) { if (!(PWM->PWM_CH_NUM[0].PWM_CPRD == PWM_PERIOD_US)) digipot_init(); // Init PWM system if needed diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index 8b6a978d2103..5eca2f7eacfe 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -34,7 +34,7 @@ #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION) #ifndef I2C_ADDRESS - #define I2C_ADDRESS(A) (A) + #define I2C_ADDRESS(A) uint8_t(A) #endif // Needed for AVR sprintf_P PROGMEM extension diff --git a/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h b/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h index b9bc0bf82e61..32ef908d633c 100644 --- a/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h @@ -24,10 +24,3 @@ #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/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index fd82e2884ae9..8b7d27742d40 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -72,7 +72,7 @@ static_assert(!(NUM_SERVOS && ENABLED(FAST_PWM_FAN)), "BLTOUCH and Servos are in //#endif #if MB(RAMPS_14_RE_ARM_EFB, RAMPS_14_RE_ARM_EEB, RAMPS_14_RE_ARM_EFF, RAMPS_14_RE_ARM_EEF, RAMPS_14_RE_ARM_SF) - #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI) + #if IS_RRD_FG_SC && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI) #error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 requires TMC_USE_SW_SPI." #endif #endif @@ -191,7 +191,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o // // Flag any i2c pin conflicts // -#if ANY(HAS_I2C_DIGIPOT, DAC_STEPPER_CURRENT, EXPERIMENTAL_I2CBUS, I2C_POSITION_ENCODERS, PCA9632, I2C_EEPROM) +#if ANY(HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC, EXPERIMENTAL_I2CBUS, I2C_POSITION_ENCODERS, PCA9632, I2C_EEPROM) #define USEDI2CDEV_M 1 // /Wire.cpp #if USEDI2CDEV_M == 0 // P0_27 [D57] (AUX-1) .......... P0_28 [D58] (AUX-1) diff --git a/Marlin/src/HAL/LPC1768/tft/tft_spi.h b/Marlin/src/HAL/LPC1768/tft/tft_spi.h index 8d3e3127bbd1..4753fdbae9a0 100644 --- a/Marlin/src/HAL/LPC1768/tft/tft_spi.h +++ b/Marlin/src/HAL/LPC1768/tft/tft_spi.h @@ -36,7 +36,7 @@ #define DATASIZE_8BIT SSP_DATABIT_8 #define DATASIZE_16BIT SSP_DATABIT_16 -#define TFT_IO TFT_SPI +#define TFT_IO_DRIVER TFT_SPI #define DMA_MINC_ENABLE 1 #define DMA_MINC_DISABLE 0 diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index abc6c04a693b..7cb3635bd7c9 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -35,7 +35,8 @@ // MYSERIAL0 required before MarlinSerial includes! - #define _MSERIAL(X) Serial##X + #define __MSERIAL(X) Serial##X + #define _MSERIAL(X) __MSERIAL(X) #define MSERIAL(X) _MSERIAL(INCREMENT(X)) #if SERIAL_PORT == -1 diff --git a/Marlin/src/HAL/STM32/fastio.h b/Marlin/src/HAL/STM32/fastio.h index f000d68cf0c3..ea28b8f3bfaa 100644 --- a/Marlin/src/HAL/STM32/fastio.h +++ b/Marlin/src/HAL/STM32/fastio.h @@ -51,15 +51,15 @@ void FastIO_init(); // Must be called before using fast io macros #if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32L0xx) || defined(STM32L4xx) #define _WRITE(IO, V) do { \ - if (V) FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO])) ; \ - else FastIOPortMap[STM_PORT(digitalPin[IO])]->BRR = _BV32(STM_PIN(digitalPin[IO])) ; \ + if (V) FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \ + else FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BRR = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \ }while(0) #else - #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO]) + ((V) ? 0 : 16))) + #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO)) + ((V) ? 0 : 16))) #endif -#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPin[IO])]->IDR, _BV32(STM_PIN(digitalPin[IO])))) -#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPin[IO])]->ODR ^= _BV32(STM_PIN(digitalPin[IO]))) +#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->IDR, _BV32(STM_PIN(digitalPinToPinName(IO))))) +#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR ^= _BV32(STM_PIN(digitalPinToPinName(IO)))) #define _GET_MODE(IO) #define _SET_MODE(IO,M) pinMode(IO, M) diff --git a/Marlin/src/HAL/STM32/pinsDebug_STM32duino.h b/Marlin/src/HAL/STM32/pinsDebug_STM32duino.h index 09f2bb54e66a..71480153a717 100644 --- a/Marlin/src/HAL/STM32/pinsDebug_STM32duino.h +++ b/Marlin/src/HAL/STM32/pinsDebug_STM32duino.h @@ -51,8 +51,8 @@ * It contains: * - name of the signal * - the Ard_num assigned by the pins_YOUR_BOARD.h file using the platform defines. - * EXAMPLE: "#define KILL_PIN PB1" results in Ard_num of 57. 57 is then used as an - * index into digitalPin[] to get the Port_pin number + * EXAMPLE: "#define KILL_PIN PB1" results in Ard_num of 57. 57 is then used as the + * argument to digitalPinToPinName(IO) to get the Port_pin number * - if it is a digital or analog signal. PWMs are considered digital here. * * pin_xref is a structure generated by this header file. It is generated by the @@ -68,8 +68,6 @@ * signal. The Arduino pin number is listed by the M43 I command. */ -extern const PinName digitalPin[]; // provided by the platform - //////////////////////////////////////////////////////// // // make a list of the Arduino pin numbers in the Port/Pin order @@ -137,7 +135,7 @@ const XrefInfo pin_xref[] PROGMEM = { uint8_t get_pin_mode(const pin_t Ard_num) { uint32_t mode_all = 0; - const PinName dp = digitalPin[Ard_num]; + const PinName dp = digitalPinToPinName(Ard_num); switch (PORT_ALPHA(dp)) { case 'A' : mode_all = GPIOA->MODER; break; case 'B' : mode_all = GPIOB->MODER; break; @@ -218,7 +216,7 @@ bool pwm_status(const pin_t Ard_num) { void pwm_details(const pin_t Ard_num) { if (pwm_status(Ard_num)) { uint32_t alt_all = 0; - const PinName dp = digitalPin[Ard_num]; + const PinName dp = digitalPinToPinName(Ard_num); pin_t pin_number = uint8_t(PIN_NUM(dp)); const bool over_7 = pin_number >= 8; const uint8_t ind = over_7 ? 1 : 0; diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.h b/Marlin/src/HAL/STM32/tft/tft_fsmc.h index 8500fee113eb..cbec7613ef4a 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.h +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.h @@ -38,7 +38,7 @@ #define DATASIZE_8BIT SPI_DATASIZE_8BIT #define DATASIZE_16BIT SPI_DATASIZE_16BIT -#define TFT_IO TFT_FSMC +#define TFT_IO_DRIVER TFT_FSMC #ifdef STM32F1xx #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN) diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.h b/Marlin/src/HAL/STM32/tft/tft_spi.h index 1eed45a709cc..d477b58c004d 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.h +++ b/Marlin/src/HAL/STM32/tft/tft_spi.h @@ -38,7 +38,7 @@ #define DATASIZE_8BIT SPI_DATASIZE_8BIT #define DATASIZE_16BIT SPI_DATASIZE_16BIT -#define TFT_IO TFT_SPI +#define TFT_IO_DRIVER TFT_SPI class TFT_SPI { private: diff --git a/Marlin/src/HAL/STM32/watchdog.cpp b/Marlin/src/HAL/STM32/watchdog.cpp index 37e5638b05c0..cc1855314968 100644 --- a/Marlin/src/HAL/STM32/watchdog.cpp +++ b/Marlin/src/HAL/STM32/watchdog.cpp @@ -30,7 +30,11 @@ #include "watchdog.h" #include - void watchdog_init() { IWatchdog.begin(4000000); } // 4 sec timeout + void watchdog_init() { + #if DISABLED(DISABLE_WATCHDOG_INIT) + IWatchdog.begin(4000000); // 4 sec timeout + #endif + } void HAL_watchdog_refresh() { IWatchdog.reload(); diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index cd1efc16591d..6733aead6d7c 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -130,7 +130,7 @@ const uint8_t adc_pins[] = { #if ENABLED(FILAMENT_WIDTH_SENSOR) FILWIDTH_PIN, #endif - #if ENABLED(ADC_KEYPAD) + #if HAS_ADC_BUTTONS ADC_KEYPAD_PIN, #endif #if HAS_JOY_ADC_X @@ -187,7 +187,7 @@ enum TempPinIndex : char { #if ENABLED(FILAMENT_WIDTH_SENSOR) FILWIDTH, #endif - #if ENABLED(ADC_KEYPAD) + #if HAS_ADC_BUTTONS ADC_KEY, #endif #if HAS_JOY_ADC_X @@ -389,7 +389,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { #if ENABLED(FILAMENT_WIDTH_SENSOR) case FILWIDTH_PIN: pin_index = FILWIDTH; break; #endif - #if ENABLED(ADC_KEYPAD) + #if HAS_ADC_BUTTONS case ADC_KEYPAD_PIN: pin_index = ADC_KEY; break; #endif #if ENABLED(POWER_MONITOR_CURRENT) diff --git a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp b/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp index f88fa8850788..60596054e820 100644 --- a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp +++ b/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp @@ -22,7 +22,6 @@ #if BOTH(HAS_MARLINUI_U8GLIB, FORCE_SOFT_SPI) -#include "../HAL.h" #include #undef SPI_SPEED @@ -161,5 +160,5 @@ uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, return 1; } -#endif // HAS_MARLINUI_U8GLIB +#endif // HAS_MARLINUI_U8GLIB && 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 25110d7c80e4..f52e6fec2b1e 100644 --- a/Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h @@ -25,10 +25,3 @@ //#warning "SD_CHECK_AND_RETRY isn't needed with USE_USB_COMPOSITE." #undef SD_CHECK_AND_RETRY #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/STM32F1/inc/SanityCheck.h b/Marlin/src/HAL/STM32F1/inc/SanityCheck.h index 9d5026fbab10..a0381ea8c8d5 100644 --- a/Marlin/src/HAL/STM32F1/inc/SanityCheck.h +++ b/Marlin/src/HAL/STM32F1/inc/SanityCheck.h @@ -51,3 +51,10 @@ #if ENABLED(NEOPIXEL_LED) #error "NEOPIXEL_LED (Adafruit NeoPixel) is not supported for HAL/STM32F1. Comment out this line to proceed at your own risk!" #endif + +// Emergency Parser needs at least one serial with HardwareSerial or USBComposite. +// The USBSerial maple don't allow any hook to implement EMERGENCY_PARSER. +// And copy all USBSerial code to marlin space to support EMERGENCY_PARSER, when we have another options, don't worth it. +#if ENABLED(EMERGENCY_PARSER) && !defined(USE_USB_COMPOSITE) && ((SERIAL_PORT == -1 && !defined(SERIAL_PORT_2)) || (SERIAL_PORT_2 == -1 && !defined(SERIAL_PORT))) + #error "EMERGENCY_PARSER is only supported by HardwareSerial or USBComposite in HAL/STM32F1." +#endif diff --git a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp index 008301d9bc0c..5b52fb416fa3 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp @@ -89,25 +89,12 @@ void TFT_FSMC::Init() { uint8_t cs = FSMC_CS_PIN, rs = FSMC_RS_PIN; uint32_t controllerAddress; - #if PIN_EXISTS(TFT_BACKLIGHT) - OUT_WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); - #endif - #if ENABLED(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 - #if PIN_EXISTS(TFT_RESET) - OUT_WRITE(TFT_RESET_PIN, HIGH); - delay(100); - #endif - - #if PIN_EXISTS(TFT_BACKLIGHT) - OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH); - #endif - struct fsmc_nor_psram_reg_map* fsmcPsramRegion; if (fsmcInit) return; diff --git a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h index 6fcfea8a1167..11eb1ffa8410 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h +++ b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h @@ -32,7 +32,7 @@ #define DATASIZE_8BIT DMA_SIZE_8BITS #define DATASIZE_16BIT DMA_SIZE_16BITS -#define TFT_IO TFT_FSMC +#define TFT_IO_DRIVER TFT_FSMC typedef struct { __IO uint16_t REG; diff --git a/Marlin/src/HAL/STM32F1/tft/tft_spi.h b/Marlin/src/HAL/STM32F1/tft/tft_spi.h index bb26fc21b64f..da9a8e0c223e 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_spi.h +++ b/Marlin/src/HAL/STM32F1/tft/tft_spi.h @@ -34,7 +34,7 @@ #define DATASIZE_8BIT DATA_SIZE_8BIT #define DATASIZE_16BIT DATA_SIZE_16BIT -#define TFT_IO TFT_SPI +#define TFT_IO_DRIVER TFT_SPI #define DMA_MINC_ENABLE 1 #define DMA_MINC_DISABLE 0 diff --git a/Marlin/src/HAL/STM32F1/watchdog.cpp b/Marlin/src/HAL/STM32F1/watchdog.cpp index 4123bc3ef0ff..ca91a6fe4350 100644 --- a/Marlin/src/HAL/STM32F1/watchdog.cpp +++ b/Marlin/src/HAL/STM32F1/watchdog.cpp @@ -52,7 +52,9 @@ void watchdogSetup() { * @details The watchdog clock is 40Khz. We need a 4 seconds interval, so use a /256 preescaler and 625 reload value (counts down to 0) */ void watchdog_init() { - //iwdg_init(IWDG_PRE_256, STM32F1_WD_RELOAD); + #if DISABLED(DISABLE_WATCHDOG_INIT) + iwdg_init(IWDG_PRE_256, STM32F1_WD_RELOAD); + #endif } #endif // USE_WATCHDOG diff --git a/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp b/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp index 4b085f90cef5..c93494d485c3 100644 --- a/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp +++ b/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp @@ -85,7 +85,7 @@ #define START_FLASH_ADDR 0x08000000 #define END_FLASH_ADDR 0x08100000 -#elif MB(REMRAM_V1) +#elif MB(REMRAM_V1, NUCLEO_F767ZI) // For STM32F765VI in RemRam v1 // SRAM (0x20000000 - 0x20080000) (512kb) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 672858d05a35..786a847fa653 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -59,7 +59,7 @@ #include "sd/cardreader.h" -#include "lcd/ultralcd.h" +#include "lcd/marlinui.h" #if HAS_TOUCH_XPT2046 #include "lcd/touch/touch_buttons.h" #endif @@ -97,7 +97,7 @@ #include "feature/closedloop.h" #endif -#if HAS_I2C_DIGIPOT +#if HAS_MOTOR_CURRENT_I2C #include "feature/digipot/digipot.h" #endif @@ -125,7 +125,7 @@ #include "module/servo.h" #endif -#if ENABLED(DAC_STEPPER_CURRENT) +#if ENABLED(HAS_MOTOR_CURRENT_DAC) #include "feature/dac/stepper_dac.h" #endif @@ -1137,12 +1137,12 @@ void setup() { SETUP_RUN(enableStepperDrivers()); #endif - #if HAS_I2C_DIGIPOT - SETUP_RUN(digipot_i2c_init()); + #if HAS_MOTOR_CURRENT_I2C + SETUP_RUN(digipot_i2c.init()); #endif - #if ENABLED(DAC_STEPPER_CURRENT) - SETUP_RUN(dac_init()); + #if ENABLED(HAS_MOTOR_CURRENT_DAC) + SETUP_RUN(stepper_dac.init()); #endif #if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1 diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 8658c8578554..da7d15ec33d5 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -363,6 +363,7 @@ #define BOARD_REMRAM_V1 5001 // RemRam v1 #define BOARD_TEENSY41 5002 // Teensy 4.1 #define BOARD_T41U5XBB 5003 // T41U5XBB Teensy 4.1 breakout board +#define BOARD_NUCLEO_F767ZI 5004 // ST NUCLEO-F767ZI Dev Board // // Espressif ESP32 WiFi diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 72644b195ccd..7948e8ce873c 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -170,7 +170,7 @@ #define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V)) #define __DO_N(W,C,N,V...) _DO_##N(W,C,V) #define _DO_N(W,C,N,V...) __DO_N(W,C,N,V) -#define DO(W,C,V...) _DO_N(W,C,NUM_ARGS(V),V) +#define DO(W,C,V...) (_DO_N(W,C,NUM_ARGS(V),V)) // Macros to support option testing #define _CAT(a,V...) a##V @@ -186,6 +186,7 @@ #define _DIS_1(O) NOT(_ENA_1(O)) #define ENABLED(V...) DO(ENA,&&,V) #define DISABLED(V...) DO(DIS,&&,V) +#define COUNT_ENABLED(V...) DO(ENA,+,V) #define TERN(O,A,B) _TERN(_ENA_1(O),B,A) // OPTION converted to '0' or '1' #define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION converted to A or '0' @@ -200,6 +201,7 @@ #define ALL(V...) ENABLED(V) #define BOTH(V1,V2) ALL(V1,V2) #define EITHER(V1,V2) ANY(V1,V2) +#define MANY(V...) (COUNT_ENABLED(V) > 1) // Macros to support pins/buttons exist testing #define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0) @@ -452,6 +454,12 @@ #define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)()) #define _END_OF_ARGUMENTS_() 0 + +// Simple Inline IF Macros, friendly to use in other macro definitions +#define IF(O, A, B) ((O) ? (A) : (B)) +#define IF_0(O, A) IF(O, A, 0) +#define IF_1(O, A) IF(O, A, 1) + // // REPEAT core macros. Recurse N times with ascending I. // diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 3e9225b7f932..0e0b87e8905b 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -36,7 +36,7 @@ #endif #if ENABLED(LCD_BED_LEVELING) - #include "../../lcd/ultralcd.h" + #include "../../lcd/marlinui.h" #endif #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index 9ac9de180638..22ca1f69ecce 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -59,7 +59,7 @@ class unified_bed_leveling { static int g29_grid_size; #endif - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL static void move_z_with_encoder(const float &multiplier); static float measure_point_with_encoder(); static float measure_business_card_thickness(float in_height); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index dc91b7d6b185..ea2e62dd51e0 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -30,7 +30,7 @@ #include "../../../HAL/shared/eeprom_api.h" #include "../../../libs/hex_print.h" #include "../../../module/settings.h" - #include "../../../lcd/ultralcd.h" + #include "../../../lcd/marlinui.h" #include "../../../module/stepper.h" #include "../../../module/planner.h" #include "../../../module/motion.h" @@ -1009,6 +1009,8 @@ lcd_mesh_edit_setup(new_z); + SET_SOFT_ENDSTOP_LOOSE(true); + do { idle(); new_z = lcd_mesh_edit(); @@ -1016,6 +1018,8 @@ SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } while (!ui.button_pressed()); + SET_SOFT_ENDSTOP_LOOSE(false); + if (!lcd_map_control) ui.return_to_status(); // Just editing a single point? Return to status if (click_and_hold(abort_fine_tune)) break; // Button held down? Abort editing diff --git a/Marlin/src/feature/cancel_object.cpp b/Marlin/src/feature/cancel_object.cpp index 16f876f13686..853e765b660f 100644 --- a/Marlin/src/feature/cancel_object.cpp +++ b/Marlin/src/feature/cancel_object.cpp @@ -25,7 +25,7 @@ #include "cancel_object.h" #include "../gcode/gcode.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" CancelObject cancelable; diff --git a/Marlin/src/feature/dac/dac_mcp4728.cpp b/Marlin/src/feature/dac/dac_mcp4728.cpp index 55f10a49ef70..81c465cf29e4 100644 --- a/Marlin/src/feature/dac/dac_mcp4728.cpp +++ b/Marlin/src/feature/dac/dac_mcp4728.cpp @@ -32,16 +32,18 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(DAC_STEPPER_CURRENT) +#if ENABLED(HAS_MOTOR_CURRENT_DAC) #include "dac_mcp4728.h" -xyze_uint_t mcp4728_values; +MCP4728 mcp4728; + +xyze_uint_t dac_values; /** * Begin I2C, get current values (input register and eeprom) of mcp4728 */ -void mcp4728_init() { +void MCP4728::init() { Wire.begin(); Wire.requestFrom(I2C_ADDRESS(DAC_DEV_ADDRESS), uint8_t(24)); while (Wire.available()) { @@ -50,7 +52,7 @@ void mcp4728_init() { loByte = Wire.read(); if (!(deviceID & 0x08)) - mcp4728_values[(deviceID & 0x30) >> 4] = word((hiByte & 0x0F), loByte); + dac_values[(deviceID & 0x30) >> 4] = word((hiByte & 0x0F), loByte); } } @@ -58,9 +60,9 @@ void mcp4728_init() { * Write input resister value to specified channel using fastwrite method. * Channel : 0-3, Values : 0-4095 */ -uint8_t mcp4728_analogWrite(const uint8_t channel, const uint16_t value) { - mcp4728_values[channel] = value; - return mcp4728_fastWrite(); +uint8_t MCP4728::analogWrite(const uint8_t channel, const uint16_t value) { + dac_values[channel] = value; + return fastWrite(); } /** @@ -68,12 +70,12 @@ uint8_t mcp4728_analogWrite(const uint8_t channel, const uint16_t value) { * This will update both input register and EEPROM value * This will also write current Vref, PowerDown, Gain settings to EEPROM */ -uint8_t mcp4728_eepromWrite() { +uint8_t MCP4728::eepromWrite() { Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS)); Wire.write(SEQWRITE); LOOP_XYZE(i) { - Wire.write(DAC_STEPPER_VREF << 7 | DAC_STEPPER_GAIN << 4 | highByte(mcp4728_values[i])); - Wire.write(lowByte(mcp4728_values[i])); + Wire.write(DAC_STEPPER_VREF << 7 | DAC_STEPPER_GAIN << 4 | highByte(dac_values[i])); + Wire.write(lowByte(dac_values[i])); } return Wire.endTransmission(); } @@ -81,7 +83,7 @@ uint8_t mcp4728_eepromWrite() { /** * Write Voltage reference setting to all input regiters */ -uint8_t mcp4728_setVref_all(const uint8_t value) { +uint8_t MCP4728::setVref_all(const uint8_t value) { Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS)); Wire.write(VREFWRITE | (value ? 0x0F : 0x00)); return Wire.endTransmission(); @@ -89,7 +91,7 @@ uint8_t mcp4728_setVref_all(const uint8_t value) { /** * Write Gain setting to all input regiters */ -uint8_t mcp4728_setGain_all(const uint8_t value) { +uint8_t MCP4728::setGain_all(const uint8_t value) { Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS)); Wire.write(GAINWRITE | (value ? 0x0F : 0x00)); return Wire.endTransmission(); @@ -98,16 +100,16 @@ uint8_t mcp4728_setGain_all(const uint8_t value) { /** * Return Input Register value */ -uint16_t mcp4728_getValue(const uint8_t channel) { return mcp4728_values[channel]; } +uint16_t MCP4728::getValue(const uint8_t channel) { return dac_values[channel]; } #if 0 /** * Steph: Might be useful in the future * Return Vout */ -uint16_t mcp4728_getVout(const uint8_t channel) { +uint16_t MCP4728::getVout(const uint8_t channel) { const uint32_t vref = 2048, - vOut = (vref * mcp4728_values[channel] * (_DAC_STEPPER_GAIN + 1)) / 4096; + vOut = (vref * dac_values[channel] * (_DAC_STEPPER_GAIN + 1)) / 4096; return _MIN(vOut, defaultVDD); } #endif @@ -115,15 +117,15 @@ uint16_t mcp4728_getVout(const uint8_t channel) { /** * Returns DAC values as a 0-100 percentage of drive strength */ -uint8_t mcp4728_getDrvPct(const uint8_t channel) { return uint8_t(100.0 * mcp4728_values[channel] / (DAC_STEPPER_MAX) + 0.5); } +uint8_t MCP4728::getDrvPct(const uint8_t channel) { return uint8_t(100.0 * dac_values[channel] / (DAC_STEPPER_MAX) + 0.5); } /** * Receives all Drive strengths as 0-100 percent values, updates * DAC Values array and calls fastwrite to update the DAC. */ -void mcp4728_setDrvPct(xyze_uint8_t &pct) { - mcp4728_values *= 0.01 * pct * (DAC_STEPPER_MAX); - mcp4728_fastWrite(); +void MCP4728::setDrvPct(xyze_uint8_t &pct) { + dac_values *= 0.01 * pct * (DAC_STEPPER_MAX); + fastWrite(); } /** @@ -131,11 +133,11 @@ void mcp4728_setDrvPct(xyze_uint8_t &pct) { * DAC Input and PowerDown bits update. * No EEPROM update */ -uint8_t mcp4728_fastWrite() { +uint8_t MCP4728::fastWrite() { Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS)); LOOP_XYZE(i) { - Wire.write(highByte(mcp4728_values[i])); - Wire.write(lowByte(mcp4728_values[i])); + Wire.write(highByte(dac_values[i])); + Wire.write(lowByte(dac_values[i])); } return Wire.endTransmission(); } @@ -143,10 +145,10 @@ uint8_t mcp4728_fastWrite() { /** * Common function for simple general commands */ -uint8_t mcp4728_simpleCommand(const byte simpleCommand) { +uint8_t MCP4728::simpleCommand(const byte simpleCommand) { Wire.beginTransmission(I2C_ADDRESS(GENERALCALL)); Wire.write(simpleCommand); return Wire.endTransmission(); } -#endif // DAC_STEPPER_CURRENT +#endif // HAS_MOTOR_CURRENT_DAC diff --git a/Marlin/src/feature/dac/dac_mcp4728.h b/Marlin/src/feature/dac/dac_mcp4728.h index fc69bd8ff4eb..571716d4834e 100644 --- a/Marlin/src/feature/dac/dac_mcp4728.h +++ b/Marlin/src/feature/dac/dac_mcp4728.h @@ -65,13 +65,18 @@ // DAC_OR_ADDRESS defined in pins_BOARD.h file #define DAC_DEV_ADDRESS (BASE_ADDR | DAC_OR_ADDRESS) -void mcp4728_init(); -uint8_t mcp4728_analogWrite(const uint8_t channel, const uint16_t value); -uint8_t mcp4728_eepromWrite(); -uint8_t mcp4728_setVref_all(const uint8_t value); -uint8_t mcp4728_setGain_all(const uint8_t value); -uint16_t mcp4728_getValue(const uint8_t channel); -uint8_t mcp4728_fastWrite(); -uint8_t mcp4728_simpleCommand(const byte simpleCommand); -uint8_t mcp4728_getDrvPct(const uint8_t channel); -void mcp4728_setDrvPct(xyze_uint8_t &pct); +class MCP4728 { +public: + static void init(); + static uint8_t analogWrite(const uint8_t channel, const uint16_t value); + static uint8_t eepromWrite(); + static uint8_t setVref_all(const uint8_t value); + static uint8_t setGain_all(const uint8_t value); + static uint16_t getValue(const uint8_t channel); + static uint8_t fastWrite(); + static uint8_t simpleCommand(const byte simpleCommand); + static uint8_t getDrvPct(const uint8_t channel); + static void setDrvPct(xyze_uint8_t &pct); +}; + +extern MCP4728 mcp4728; diff --git a/Marlin/src/feature/dac/stepper_dac.cpp b/Marlin/src/feature/dac/stepper_dac.cpp index 6b140a002510..5f10b4ccfbdc 100644 --- a/Marlin/src/feature/dac/stepper_dac.cpp +++ b/Marlin/src/feature/dac/stepper_dac.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(DAC_STEPPER_CURRENT) +#if ENABLED(HAS_MOTOR_CURRENT_DAC) #include "stepper_dac.h" #include "../../MarlinCore.h" // for SP_X_LBL... @@ -35,56 +35,53 @@ bool dac_present = false; constexpr xyze_uint8_t dac_order = DAC_STEPPER_ORDER; xyze_uint8_t dac_channel_pct = DAC_MOTOR_CURRENT_DEFAULT; -int dac_init() { +StepperDAC stepper_dac; + +int StepperDAC::init() { #if PIN_EXISTS(DAC_DISABLE) OUT_WRITE(DAC_DISABLE_PIN, LOW); // set pin low to enable DAC #endif - mcp4728_init(); + mcp4728.init(); - if (mcp4728_simpleCommand(RESET)) return -1; + if (mcp4728.simpleCommand(RESET)) return -1; dac_present = true; - mcp4728_setVref_all(DAC_STEPPER_VREF); - mcp4728_setGain_all(DAC_STEPPER_GAIN); + mcp4728.setVref_all(DAC_STEPPER_VREF); + mcp4728.setGain_all(DAC_STEPPER_GAIN); - if (mcp4728_getDrvPct(0) < 1 || mcp4728_getDrvPct(1) < 1 || mcp4728_getDrvPct(2) < 1 || mcp4728_getDrvPct(3) < 1 ) { - mcp4728_setDrvPct(dac_channel_pct); - mcp4728_eepromWrite(); + if (mcp4728.getDrvPct(0) < 1 || mcp4728.getDrvPct(1) < 1 || mcp4728.getDrvPct(2) < 1 || mcp4728.getDrvPct(3) < 1 ) { + mcp4728.setDrvPct(dac_channel_pct); + mcp4728.eepromWrite(); } return 0; } -void dac_current_percent(uint8_t channel, float val) { +void StepperDAC::set_current_value(const uint8_t channel, uint16_t val) { if (!dac_present) return; - NOMORE(val, 100); + NOMORE(val, uint16_t(DAC_STEPPER_MAX)); - mcp4728_analogWrite(dac_order[channel], val * 0.01 * (DAC_STEPPER_MAX)); - mcp4728_simpleCommand(UPDATE); + mcp4728.analogWrite(dac_order[channel], val); + mcp4728.simpleCommand(UPDATE); } -void dac_current_raw(uint8_t channel, uint16_t val) { - if (!dac_present) return; - - NOMORE(val, uint16_t(DAC_STEPPER_MAX)); - - mcp4728_analogWrite(dac_order[channel], val); - mcp4728_simpleCommand(UPDATE); +void StepperDAC::set_current_percent(const uint8_t channel, float val) { + set_current_value(channel, _MIN(val, 100.0f) * (DAC_STEPPER_MAX) / 100.0f); } -static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * RECIPROCAL(DAC_STEPPER_MAX); } -static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * RECIPROCAL(DAC_STEPPER_SENSE); } +static float dac_perc(int8_t n) { return 100.0 * mcp4728.getValue(dac_order[n]) * RECIPROCAL(DAC_STEPPER_MAX); } +static float dac_amps(int8_t n) { return mcp4728.getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * RECIPROCAL(DAC_STEPPER_SENSE); } -uint8_t dac_current_get_percent(const AxisEnum axis) { return mcp4728_getDrvPct(dac_order[axis]); } -void dac_current_set_percents(xyze_uint8_t &pct) { +uint8_t StepperDAC::get_current_percent(const AxisEnum axis) { return mcp4728.getDrvPct(dac_order[axis]); } +void StepperDAC::set_current_percents(xyze_uint8_t &pct) { LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]]; - mcp4728_setDrvPct(dac_channel_pct); + mcp4728.setDrvPct(dac_channel_pct); } -void dac_print_values() { +void StepperDAC::print_values() { if (!dac_present) return; SERIAL_ECHO_MSG("Stepper current values in % (Amps):"); SERIAL_ECHO_START(); @@ -94,9 +91,9 @@ void dac_print_values() { SERIAL_ECHOLNPAIR_P(SP_E_LBL, dac_perc(E_AXIS), PSTR(" ("), dac_amps(E_AXIS), PSTR(")")); } -void dac_commit_eeprom() { +void StepperDAC::commit_eeprom() { if (!dac_present) return; - mcp4728_eepromWrite(); + mcp4728.eepromWrite(); } -#endif // DAC_STEPPER_CURRENT +#endif // HAS_MOTOR_CURRENT_DAC diff --git a/Marlin/src/feature/dac/stepper_dac.h b/Marlin/src/feature/dac/stepper_dac.h index 0543b6275e2c..6836335e9806 100644 --- a/Marlin/src/feature/dac/stepper_dac.h +++ b/Marlin/src/feature/dac/stepper_dac.h @@ -27,10 +27,15 @@ #include "dac_mcp4728.h" -int dac_init(); -void dac_current_percent(uint8_t channel, float val); -void dac_current_raw(uint8_t channel, uint16_t val); -void dac_print_values(); -void dac_commit_eeprom(); -uint8_t dac_current_get_percent(AxisEnum axis); -void dac_current_set_percents(xyze_uint8_t &pct); +class StepperDAC { +public: + static int init(); + static void set_current_percent(const uint8_t channel, float val); + static void set_current_value(const uint8_t channel, uint16_t val); + static void print_values(); + static void commit_eeprom(); + static uint8_t get_current_percent(AxisEnum axis); + static void set_current_percents(xyze_uint8_t &pct); +}; + +extern StepperDAC stepper_dac; diff --git a/Marlin/src/feature/digipot/digipot.h b/Marlin/src/feature/digipot/digipot.h index d59f8b930af5..3fbd1f36625e 100644 --- a/Marlin/src/feature/digipot/digipot.h +++ b/Marlin/src/feature/digipot/digipot.h @@ -21,5 +21,13 @@ */ #pragma once -void digipot_i2c_set_current(const uint8_t channel, const float current); -void digipot_i2c_init(); +// +// Header for MCP4018 and MCP4451 current control i2c devices +// +class DigipotI2C { +public: + static void init(); + static void set_current(const uint8_t channel, const float current); +}; + +extern DigipotI2C digipot_i2c; diff --git a/Marlin/src/feature/digipot/digipot_mcp4018.cpp b/Marlin/src/feature/digipot/digipot_mcp4018.cpp index 35c513a32c39..4b90cc4ead6b 100644 --- a/Marlin/src/feature/digipot/digipot_mcp4018.cpp +++ b/Marlin/src/feature/digipot/digipot_mcp4018.cpp @@ -24,6 +24,8 @@ #if ENABLED(DIGIPOT_MCP4018) +#include "digipot.h" + #include #include // https://github.com/stawel/SlowSoftI2CMaster @@ -68,7 +70,7 @@ static SlowSoftI2CMaster pots[DIGIPOT_I2C_NUM_CHANNELS] = { #endif }; -static void i2c_send(const uint8_t channel, const byte v) { +static void digipot_i2c_send(const uint8_t channel, const byte v) { if (WITHIN(channel, 0, DIGIPOT_I2C_NUM_CHANNELS - 1)) { pots[channel].i2c_start(((DIGIPOT_I2C_ADDRESS_A) << 1) | I2C_WRITE); pots[channel].i2c_write(v); @@ -77,12 +79,12 @@ static void i2c_send(const uint8_t channel, const byte v) { } // This is for the MCP4018 I2C based digipot -void digipot_i2c_set_current(const uint8_t channel, const float current) { +void DigipotI2C::set_current(const uint8_t channel, const float current) { const float ival = _MIN(_MAX(current, 0), float(DIGIPOT_MCP4018_MAX_VALUE)); - i2c_send(channel, current_to_wiper(ival)); + digipot_i2c_send(channel, current_to_wiper(ival)); } -void digipot_i2c_init() { +void DigipotI2C::init() { LOOP_L_N(i, DIGIPOT_I2C_NUM_CHANNELS) pots[i].i2c_init(); // Init currents according to Configuration_adv.h @@ -94,7 +96,9 @@ void digipot_i2c_init() { #endif ; LOOP_L_N(i, COUNT(digipot_motor_current)) - digipot_i2c_set_current(i, pgm_read_float(&digipot_motor_current[i])); + set_current(i, pgm_read_float(&digipot_motor_current[i])); } +DigipotI2C digipot_i2c; + #endif // DIGIPOT_MCP4018 diff --git a/Marlin/src/feature/digipot/digipot_mcp4451.cpp b/Marlin/src/feature/digipot/digipot_mcp4451.cpp index 0c8ff04a0bbf..1b4cf43923a8 100644 --- a/Marlin/src/feature/digipot/digipot_mcp4451.cpp +++ b/Marlin/src/feature/digipot/digipot_mcp4451.cpp @@ -24,6 +24,8 @@ #if ENABLED(DIGIPOT_MCP4451) +#include "digipot.h" + #include #include @@ -61,7 +63,7 @@ static void digipot_i2c_send(const byte addr, const byte a, const byte b) { } // This is for the MCP4451 I2C based digipot -void digipot_i2c_set_current(const uint8_t channel, const float current) { +void DigipotI2C::set_current(const uint8_t channel, const float current) { // These addresses are specific to Azteeg X3 Pro, can be set to others. // In this case first digipot is at address A0=0, A1=0, second one is at A0=0, A1=1 const byte addr = channel < 4 ? DIGIPOT_I2C_ADDRESS_A : DIGIPOT_I2C_ADDRESS_B; // channel 0-3 vs 4-7 @@ -75,7 +77,7 @@ void digipot_i2c_set_current(const uint8_t channel, const float current) { digipot_i2c_send(addr, addresses[channel & 0x3], current_to_wiper(_MIN(float(_MAX(current, 0)), DIGIPOT_I2C_MAX_CURRENT))); } -void digipot_i2c_init() { +void DigipotI2C::init() { #if MB(MKS_SBASE) configure_i2c(16); // Set clock_option to 16 ensure I2C is initialized at 400kHz #else @@ -90,7 +92,9 @@ void digipot_i2c_init() { #endif ; LOOP_L_N(i, COUNT(digipot_motor_current)) - digipot_i2c_set_current(i, pgm_read_float(&digipot_motor_current[i])); + set_current(i, pgm_read_float(&digipot_motor_current[i])); } +DigipotI2C digipot_i2c; + #endif // DIGIPOT_MCP4451 diff --git a/Marlin/src/feature/e_parser.cpp b/Marlin/src/feature/e_parser.cpp index a4c2d0dac92c..d98afcfee71b 100644 --- a/Marlin/src/feature/e_parser.cpp +++ b/Marlin/src/feature/e_parser.cpp @@ -32,6 +32,7 @@ // Static data members bool EmergencyParser::killed_by_M112, // = false + EmergencyParser::quickstop_by_M410, EmergencyParser::enabled; #if ENABLED(HOST_PROMPT_SUPPORT) diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index 085cbd4eab0e..0bb0253149eb 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -63,6 +63,7 @@ class EmergencyParser { }; static bool killed_by_M112; + static bool quickstop_by_M410; #if ENABLED(HOST_PROMPT_SUPPORT) static uint8_t M876_reason; @@ -168,7 +169,7 @@ class EmergencyParser { if (enabled) switch (state) { case EP_M108: wait_for_user = wait_for_heatup = false; break; case EP_M112: killed_by_M112 = true; break; - case EP_M410: quickstop_stepper(); break; + case EP_M410: quickstop_by_M410 = true; break; #if ENABLED(HOST_PROMPT_SUPPORT) case EP_M876SN: host_response_handler(M876_reason); break; #endif diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp index 9d5594c2f184..7f8f20a04793 100644 --- a/Marlin/src/feature/hotend_idle.cpp +++ b/Marlin/src/feature/hotend_idle.cpp @@ -34,7 +34,7 @@ #include "../module/temperature.h" #include "../module/motion.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" extern HotendIdleProtection hotend_idle; diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 3d635369e438..c5cf48585093 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -30,7 +30,7 @@ MMU2 mmu2; #include "../../gcode/gcode.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../libs/buzzer.h" #include "../../libs/nozzle.h" #include "../../module/temperature.h" diff --git a/Marlin/src/feature/password/password.h b/Marlin/src/feature/password/password.h index 3ed584b29d5e..3c223b6a824b 100644 --- a/Marlin/src/feature/password/password.h +++ b/Marlin/src/feature/password/password.h @@ -21,7 +21,7 @@ */ #pragma once -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" class Password { public: diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index a36ff5075683..6f970d1a4c04 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -55,12 +55,16 @@ #include "../lcd/extui/ui_api.h" #endif -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #if HAS_BUZZER #include "../libs/buzzer.h" #endif +#if ENABLED(POWER_LOSS_RECOVERY) + #include "powerloss.h" +#endif + #include "../libs/nozzle.h" #include "pause.h" @@ -128,8 +132,10 @@ static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=P DEBUG_SECTION(est, "ensure_safe_temperature", true); DEBUG_ECHOLNPAIR("... wait:", int(wait), " mode:", int(mode)); - if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) - thermalManager.setTargetHotend(thermalManager.extrude_min_temp, active_extruder); + #if ENABLED(PREVENT_COLD_EXTRUSION) + if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) + thermalManager.setTargetHotend(thermalManager.extrude_min_temp, active_extruder); + #endif #if HAS_LCD_MENU lcd_pause_show_message(PAUSE_MESSAGE_HEATING, mode); @@ -217,8 +223,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l #if ENABLED(DUAL_X_CARRIAGE) const int8_t saved_ext = active_extruder; const bool saved_ext_dup_mode = extruder_duplication_enabled; - active_extruder = DXC_ext; - extruder_duplication_enabled = false; + set_duplication_enabled(false, DXC_ext); #endif // Slow Load filament @@ -239,9 +244,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l } #if ENABLED(DUAL_X_CARRIAGE) // Tie the two extruders movement back together. - active_extruder = saved_ext; - extruder_duplication_enabled = saved_ext_dup_mode; - stepper.set_directions(); + set_duplication_enabled(saved_ext_dup_mode, saved_ext); #endif #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE) @@ -433,17 +436,14 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float #if ENABLED(DUAL_X_CARRIAGE) const int8_t saved_ext = active_extruder; const bool saved_ext_dup_mode = extruder_duplication_enabled; - active_extruder = DXC_ext; - extruder_duplication_enabled = false; + set_duplication_enabled(false, DXC_ext); #endif if (unload_length) // Unload the filament unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT); #if ENABLED(DUAL_X_CARRIAGE) - active_extruder = saved_ext; - extruder_duplication_enabled = saved_ext_dup_mode; - stepper.set_directions(); + set_duplication_enabled(saved_ext_dup_mode, saved_ext); #endif return true; @@ -489,8 +489,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep #if ENABLED(DUAL_X_CARRIAGE) const int8_t saved_ext = active_extruder; const bool saved_ext_dup_mode = extruder_duplication_enabled; - active_extruder = DXC_ext; - extruder_duplication_enabled = false; + set_duplication_enabled(false, DXC_ext); #endif // Wait for filament insert by user and press button @@ -544,9 +543,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep idle_no_sleep(); } #if ENABLED(DUAL_X_CARRIAGE) - active_extruder = saved_ext; - extruder_duplication_enabled = saved_ext_dup_mode; - stepper.set_directions(); + set_duplication_enabled(saved_ext_dup_mode, saved_ext); #endif } @@ -640,6 +637,9 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le // Set extruder to saved position planner.set_e_position_mm((destination.e = current_position.e = resume_position.e)); + // Write PLR now to update the z axis value + TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true)); + TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS)); #ifdef ACTION_ON_RESUMED diff --git a/Marlin/src/feature/pause.h b/Marlin/src/feature/pause.h index 016b0ce3f7d9..c69ed73546e0 100644 --- a/Marlin/src/feature/pause.h +++ b/Marlin/src/feature/pause.h @@ -89,10 +89,11 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_count=0 DXC_PARAMS); -void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, const int8_t max_beep_count=0, int16_t targetTemp=0 DXC_PARAMS); +void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, + const int8_t max_beep_count=0, int16_t targetTemp=0 DXC_PARAMS); -bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0, const bool show_lcd=false, - const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS); +bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0, + const bool show_lcd=false, const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS); bool unload_filament(const float &unload_length, const bool show_lcd=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT #if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER) diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index af31d156fc84..e1e7324fb6c6 100644 --- a/Marlin/src/feature/power_monitor.cpp +++ b/Marlin/src/feature/power_monitor.cpp @@ -26,7 +26,7 @@ #include "power_monitor.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #include "../lcd/lcdprint.h" #include "../libs/numtostr.h" diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index e4bc605bb55f..874bcff46da9 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -45,7 +45,7 @@ uint32_t PrintJobRecovery::cmd_sdpos, // = 0 #endif #include "../sd/cardreader.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #include "../gcode/queue.h" #include "../gcode/gcode.h" #include "../module/motion.h" diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index a7f836684949..a5abf057d1ff 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -237,7 +237,7 @@ class FilamentSensorBase { #if NUM_RUNOUT_SENSORS == 1 UNUSED(extruder); #else - if ( !TERN0(DUAL_X_CARRIAGE, dxc_is_duplicating()) + if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled) ) return TEST(runout_states, extruder); // A specific extruder ran out #endif diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index b65a1254c656..187cfda48334 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -22,7 +22,7 @@ #pragma once #include "../inc/MarlinConfig.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #if HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index c66d4a7d4974..6123fbf6c873 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -111,7 +111,7 @@ #include "../../module/motion.h" #include "../../module/tool_change.h" #include "../../module/temperature.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #define EXTRUSION_MULTIPLIER 1.0 #define PRIME_LENGTH 10.0 @@ -511,11 +511,9 @@ void GcodeSuite::G26() { g26_keep_heaters_on = parser.boolval('K'); // Accept 'I' if temperature presets are defined - const uint8_t preset_index = (0 - #if PREHEAT_COUNT - + (parser.seenval('I') ? _MIN(parser.value_byte(), PREHEAT_COUNT - 1) + 1 : 0) - #endif - ); + #if PREHEAT_COUNT + const uint8_t preset_index = parser.seenval('I') ? _MIN(parser.value_byte(), PREHEAT_COUNT - 1) + 1 : 0; + #endif #if HAS_HEATED_BED diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index bd7f4f0411e1..f6ae2db2c709 100755 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -110,9 +110,8 @@ void GcodeSuite::G35() { tool_change(0, true); #endif - #if HAS_DUPLICATION_MODE - extruder_duplication_enabled = false; - #endif + // Disable duplication mode on homing + TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false)); // Home all before this procedure home_all_axes(); @@ -160,6 +159,7 @@ void GcodeSuite::G35() { " ", (screw_thread & 1) == (adjust > 0) ? "CCW" : "CW", " by ", abs(full_turns), " turns"); if (minutes) SERIAL_ECHOPAIR(" and ", abs(minutes), " minutes"); + if (ENABLED(REPORT_TRAMMING_MM)) SERIAL_ECHOPAIR(" (", -diff, "mm)"); SERIAL_EOL(); } } diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index e9b6e0e3a6db..fcdab742cfbd 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -42,7 +42,7 @@ #endif #if HAS_DISPLAY - #include "../../../lcd/ultralcd.h" + #include "../../../lcd/marlinui.h" #endif #if ENABLED(AUTO_BED_LEVELING_LINEAR) @@ -201,10 +201,6 @@ G29_TYPE GcodeSuite::G29() { ABL_VAR int abl_probe_index; #endif - #if BOTH(HAS_SOFTWARE_ENDSTOPS, PROBE_MANUALLY) - ABL_VAR bool saved_soft_endstops_state = true; - #endif - #if ABL_GRID #if ENABLED(PROBE_MANUALLY) @@ -461,7 +457,7 @@ G29_TYPE GcodeSuite::G29() { // Abort current G29 procedure, go back to idle state if (seenA && g29_in_progress) { SERIAL_ECHOLNPGM("Manual G29 aborted"); - TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state); + SET_SOFT_ENDSTOP_LOOSE(false); set_bed_leveling_enabled(abl_should_enable); g29_in_progress = false; TERN_(LCD_BED_LEVELING, ui.wait_for_move = false); @@ -482,7 +478,7 @@ G29_TYPE GcodeSuite::G29() { if (abl_probe_index == 0) { // For the initial G29 S2 save software endstop state - TERN_(HAS_SOFTWARE_ENDSTOPS, saved_soft_endstops_state = soft_endstops_enabled); + SET_SOFT_ENDSTOP_LOOSE(true); // Move close to the bed before the first point do_blocking_move_to_z(0); } @@ -552,14 +548,14 @@ G29_TYPE GcodeSuite::G29() { _manual_goto_xy(probePos); // Can be used here too! // Disable software endstops to allow manual adjustment // If G29 is not completed, they will not be re-enabled - TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = false); + SET_SOFT_ENDSTOP_LOOSE(true); G29_RETURN(false); } else { // Leveling done! Fall through to G29 finishing code below SERIAL_ECHOLNPGM("Grid probing done."); // Re-enable software endstops, if needed - TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state); + SET_SOFT_ENDSTOP_LOOSE(false); } #elif ENABLED(AUTO_BED_LEVELING_3POINT) @@ -570,7 +566,7 @@ G29_TYPE GcodeSuite::G29() { _manual_goto_xy(probePos); // Disable software endstops to allow manual adjustment // If G29 is not completed, they will not be re-enabled - TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = false); + SET_SOFT_ENDSTOP_LOOSE(true); G29_RETURN(false); } else { @@ -578,7 +574,7 @@ G29_TYPE GcodeSuite::G29() { SERIAL_ECHOLNPGM("3-point probing done."); // Re-enable software endstops, if needed - TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state); + SET_SOFT_ENDSTOP_LOOSE(false); if (!dryrun) { vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal(); diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 5da99386adc5..d5cc8a4fcb83 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -34,7 +34,7 @@ #include "../../queue.h" #include "../../../libs/buzzer.h" -#include "../../../lcd/ultralcd.h" +#include "../../../lcd/marlinui.h" #include "../../../module/motion.h" #include "../../../module/stepper.h" @@ -61,7 +61,6 @@ inline void echo_not_entered(const char c) { SERIAL_CHAR(c); SERIAL_ECHOLNPGM(" void GcodeSuite::G29() { static int mbl_probe_index = -1; - TERN_(HAS_SOFTWARE_ENDSTOPS, static bool saved_soft_endstops_state); MeshLevelingState state = (MeshLevelingState)parser.byteval('S', (int8_t)MeshReport); if (!WITHIN(state, 0, 5)) { @@ -98,26 +97,19 @@ void GcodeSuite::G29() { } // For each G29 S2... if (mbl_probe_index == 0) { - #if HAS_SOFTWARE_ENDSTOPS - // For the initial G29 S2 save software endstop state - saved_soft_endstops_state = soft_endstops_enabled; - #endif // Move close to the bed before the first point do_blocking_move_to_z(0); } else { // Save Z for the previous mesh position mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z); - TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state); + SET_SOFT_ENDSTOP_LOOSE(false); } // If there's another point to sample, move there with optional lift. if (mbl_probe_index < GRID_MAX_POINTS) { - #if HAS_SOFTWARE_ENDSTOPS - // Disable software endstops to allow manual adjustment - // If G29 is not completed, they will not be re-enabled - soft_endstops_enabled = false; - #endif - + // Disable software endstops to allow manual adjustment + // If G29 is left hanging without completion they won't be re-enabled! + SET_SOFT_ENDSTOP_LOOSE(true); mbl.zigzag(mbl_probe_index++, ix, iy); _manual_goto_xy({ mbl.index_to_xpos[ix], mbl.index_to_ypos[iy] }); } diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 7bc40b2127c4..06b9fee257ac 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -45,7 +45,7 @@ #include "../../feature/bltouch.h" #endif -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #if ENABLED(DWIN_CREALITY_LCD) #include "../../lcd/dwin/e3v2/dwin.h" #endif @@ -134,8 +134,8 @@ if (DEBUGGING(LEVELING)) DEBUG_POS("home_z_safely", destination); - // This causes the carriage on Dual X to unpark - TERN_(DUAL_X_CARRIAGE, active_extruder_parked = false); + // Free the active extruder for movement + TERN_(DUAL_X_CARRIAGE, idex_set_parked(false)); TERN_(SENSORLESS_HOMING, safe_delay(500)); // Short delay needed to settle @@ -222,8 +222,9 @@ void GcodeSuite::G28() { return; } - // Wait for planner moves to finish! - planner.synchronize(); + planner.synchronize(); // Wait for planner moves to finish! + + SET_SOFT_ENDSTOP_LOOSE(false); // Reset a leftover 'loose' motion state // Disable the leveling matrix before homing #if HAS_LEVELING @@ -281,7 +282,7 @@ void GcodeSuite::G28() { tool_change(0, true); #endif - TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false); + TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false)); remember_feedrate_scaling_off(); @@ -341,16 +342,14 @@ void GcodeSuite::G28() { homeaxis(X_AXIS); // Remember this extruder's position for later tool change - inactive_extruder_x_pos = current_position.x; + inactive_extruder_x = current_position.x; // Home the 1st (left) extruder active_extruder = 0; homeaxis(X_AXIS); - // Consider the active extruder to be parked - raised_parked_position = current_position; - delayed_move_time = 0; - active_extruder_parked = true; + // Consider the active extruder to be in its "parked" position + idex_set_parked(); #else @@ -391,7 +390,7 @@ void GcodeSuite::G28() { */ #if ENABLED(DUAL_X_CARRIAGE) - if (dxc_is_duplicating()) { + if (idex_is_duplicating()) { TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing = begin_slow_homing()); @@ -400,19 +399,17 @@ void GcodeSuite::G28() { homeaxis(X_AXIS); // Remember this extruder's position for later tool change - inactive_extruder_x_pos = current_position.x; + inactive_extruder_x = current_position.x; // Home the 1st (left) extruder active_extruder = 0; homeaxis(X_AXIS); // Consider the active extruder to be parked - raised_parked_position = current_position; - delayed_move_time = 0; - active_extruder_parked = true; - extruder_duplication_enabled = IDEX_saved_duplication_state; - dual_x_carriage_mode = IDEX_saved_mode; - stepper.set_directions(); + idex_set_parked(); + + dual_x_carriage_mode = IDEX_saved_mode; + set_duplication_enabled(IDEX_saved_duplication_state); TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing)); } diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 53af04d52876..77cc45771cc8 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -29,7 +29,7 @@ #include "../../module/motion.h" #include "../../module/stepper.h" #include "../../module/endstops.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #if HAS_BED_PROBE #include "../../module/probe.h" diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp new file mode 100644 index 000000000000..0ca4490eb6c1 --- /dev/null +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -0,0 +1,156 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(MECHANICAL_GANTRY_CALIBRATION) + +#include "../gcode.h" +#include "../../module/motion.h" +#include "../../module/stepper.h" +#include "../../module/endstops.h" + +#if HAS_LEVELING + #include "../../feature/bedlevel/bedlevel.h" +#endif + +#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) +#include "../../core/debug_out.h" + +void GcodeSuite::G34() { + + // Home before the alignment procedure + if (!all_axes_known()) home_all_axes(); + + SET_SOFT_ENDSTOP_LOOSE(true); + TEMPORARY_BED_LEVELING_STATE(false); + TemporaryGlobalEndstopsState unlock_z(false); + + #ifdef GANTRY_CALIBRATION_COMMANDS_PRE + gcode.process_subcommands_now_P(PSTR(GANTRY_CALIBRATION_COMMANDS_PRE)); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Sub Commands Processed"); + #endif + + #ifdef GANTRY_CALIBRATION_SAFE_POSITION + // Move XY to safe position + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Parking XY"); + const xy_pos_t safe_pos = GANTRY_CALIBRATION_SAFE_POSITION; + do_blocking_move_to(safe_pos, MMM_TO_MMS(GANTRY_CALIBRATION_XY_PARK_FEEDRATE)); + #endif + + const float move_distance = parser.intval('Z', GANTRY_CALIBRATION_EXTRA_HEIGHT), + zbase = ENABLED(GANTRY_CALIBRATION_TO_MIN) ? Z_MIN_POS : Z_MAX_POS, + zpounce = zbase - move_distance, zgrind = zbase + move_distance; + + // Move Z to pounce position + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Setting Z Pounce"); + do_blocking_move_to_z(zpounce, MMM_TO_MMS(HOMING_FEEDRATE_Z)); + + // Store current motor settings, then apply reduced value + + #define _REDUCE_CURRENT ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_MOTOR_CURRENT_DAC, HAS_MOTOR_CURRENT_I2C, HAS_TRINAMIC_CONFIG) + #if _REDUCE_CURRENT + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Reducing Current"); + #endif + + #if HAS_MOTOR_CURRENT_SPI + const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); + const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS]; + stepper.set_digipot_current(Z_AXIS, target_current); + #elif HAS_MOTOR_CURRENT_PWM + const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); + const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS]; + stepper.set_digipot_current(1, target_current); + #elif HAS_MOTOR_CURRENT_DAC + const float target_current = parser.floatval('S', GANTRY_CALIBRATION_CURRENT); + const float previous_current = dac_amps(Z_AXIS, target_current); + stepper_dac.set_current_value(Z_AXIS, target_current); + #elif ENABLED(HAS_MOTOR_CURRENT_I2C) + const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); + previous_current = dac_amps(Z_AXIS); + digipot_i2c.set_current(Z_AXIS, target_current) + #elif HAS_TRINAMIC_CONFIG + const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); + static uint16_t previous_current_arr[NUM_Z_STEPPER_DRIVERS]; + #if AXIS_IS_TMC(Z) + previous_current_arr[0] = stepperZ.getMilliamps(); + stepperZ.rms_current(target_current); + #endif + #if AXIS_IS_TMC(Z2) + previous_current_arr[1] = stepperZ2.getMilliamps(); + stepperZ2.rms_current(target_current); + #endif + #if AXIS_IS_TMC(Z3) + previous_current_arr[2] = stepperZ3.getMilliamps(); + stepperZ3.rms_current(target_current); + #endif + #if AXIS_IS_TMC(Z4) + previous_current_arr[3] = stepperZ4.getMilliamps(); + stepperZ4.rms_current(target_current); + #endif + #endif + + // Do Final Z move to adjust + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Final Z Move"); + do_blocking_move_to_z(zgrind, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE)); + + // Back off end plate, back to normal motion range + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Backoff"); + do_blocking_move_to_z(zpounce, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE)); + + #if _REDUCE_CURRENT + // Reset current to original values + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore Current"); + #endif + + #if HAS_MOTOR_CURRENT_SPI + stepper.set_digipot_current(Z_AXIS, previous_current); + #elif HAS_MOTOR_CURRENT_PWM + stepper.set_digipot_current(1, previous_current); + #elif HAS_MOTOR_CURRENT_DAC + stepper_dac.set_current_value(Z_AXIS, previous_current); + #elif ENABLED(HAS_MOTOR_CURRENT_I2C) + digipot_i2c.set_current(Z_AXIS, previous_current) + #elif HAS_TRINAMIC_CONFIG + #if AXIS_IS_TMC(Z) + stepperZ.rms_current(previous_current_arr[0]); + #endif + #if AXIS_IS_TMC(Z2) + stepperZ2.rms_current(previous_current_arr[1]); + #endif + #if AXIS_IS_TMC(Z3) + stepperZ3.rms_current(previous_current_arr[2]); + #endif + #if AXIS_IS_TMC(Z4) + stepperZ4.rms_current(previous_current_arr[3]); + #endif + #endif + + #ifdef GANTRY_CALIBRATION_COMMANDS_POST + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Running Post Commands"); + gcode.process_subcommands_now_P(PSTR(GANTRY_CALIBRATION_COMMANDS_POST)); + #endif + + SET_SOFT_ENDSTOP_LOOSE(false); +} + +#endif // MECHANICAL_GANTRY_CALIBRATION diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 1fd0754ec780..5e1ec5b961ab 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -20,28 +20,29 @@ * */ -#include "../../inc/MarlinConfig.h" +#include "../../inc/MarlinConfigPre.h" #if ENABLED(Z_STEPPER_AUTO_ALIGN) #include "../../feature/z_stepper_align.h" #include "../gcode.h" -#include "../../module/planner.h" -#include "../../module/stepper.h" #include "../../module/motion.h" +#include "../../module/stepper.h" +#include "../../module/planner.h" #include "../../module/probe.h" - -#if HAS_MULTI_HOTEND - #include "../../module/tool_change.h" -#endif +#include "../../lcd/marlinui.h" // for LCD_MESSAGEPGM #if HAS_LEVELING #include "../../feature/bedlevel/bedlevel.h" #endif +#if HAS_MULTI_HOTEND + #include "../../module/tool_change.h" +#endif + #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - #include "../../libs/least_squares_fit.h" + #include "../../libs/least_squares_fit.h" #endif #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) @@ -112,12 +113,12 @@ void GcodeSuite::G34() { tool_change(0, true); #endif - TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false); + TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false)); // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G34 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - #define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE) + #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE)) // Compute a worst-case clearance height to probe from. After the first // iteration this will be re-calculated based on the actual bed position @@ -154,21 +155,29 @@ void GcodeSuite::G34() { z_maxdiff = 0.0f, amplification = z_auto_align_amplification; - // These are needed after the for-loop - uint8_t iteration; - bool err_break = false; - float z_measured_min; - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) bool adjustment_reverse = false; #endif - // 'iteration' is declared above and is also used after the for-loop. - // *not* the same as LOOP_L_N(iteration, z_auto_align_iterations) - for (iteration = 0; iteration < z_auto_align_iterations; ++iteration) { + #if HAS_DISPLAY + PGM_P const msg_iteration = GET_TEXT(MSG_ITERATION); + const uint8_t iter_str_len = strlen_P(msg_iteration); + #endif + + // Final z and iteration values will be used after breaking the loop + float z_measured_min; + uint8_t iteration = 0; + bool err_break = false; // To break out of nested loops + while (iteration < z_auto_align_iterations) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> probing all positions."); - SERIAL_ECHOLNPAIR("\nITERATION: ", int(iteration + 1)); + const int iter = iteration + 1; + SERIAL_ECHOLNPAIR("\nG34 Iteration: ", iter); + #if HAS_DISPLAY + char str[iter_str_len + 2 + 1]; + sprintf_P(str, msg_iteration, iter); + ui.set_status(str); + #endif // Initialize minimum value z_measured_min = 100000.0f; @@ -190,7 +199,8 @@ void GcodeSuite::G34() { // current_position.z has been manually altered in the "dirty trick" above. const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false); if (isnan(z_probed_height)) { - SERIAL_ECHOLNPGM("Probing failed."); + SERIAL_ECHOLNPGM("Probing failed"); + LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); err_break = true; break; } @@ -249,8 +259,39 @@ void GcodeSuite::G34() { , " Z3-Z1=", ABS(z_measured[2] - z_measured[0]) #endif ); + #if HAS_DISPLAY + char fstr1[10]; + #if NUM_Z_STEPPER_DRIVERS == 2 + char msg[6 + (6 + 5) * 1 + 1]; + #else + char msg[6 + (6 + 5) * 3 + 1], fstr2[10], fstr3[10]; + #endif + sprintf_P(msg, + PSTR("Diffs Z1-Z2=%s" + #if NUM_Z_STEPPER_DRIVERS == 3 + " Z2-Z3=%s" + " Z3-Z1=%s" + #endif + ), dtostrf(ABS(z_measured[0] - z_measured[1]), 1, 3, fstr1) + #if NUM_Z_STEPPER_DRIVERS == 3 + , dtostrf(ABS(z_measured[1] - z_measured[2]), 1, 3, fstr2) + , dtostrf(ABS(z_measured[2] - z_measured[0]), 1, 3, fstr3) + #endif + ); + ui.set_status(msg); + #endif + + auto decreasing_accuracy = [](const float &v1, const float &v2){ + if (v1 < v2 * 0.7f) { + SERIAL_ECHOLNPGM("Decreasing Accuracy Detected."); + LCD_MESSAGEPGM(MSG_DECREASING_ACCURACY); + return true; + } + return false; + }; #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + // Check if the applied corrections go in the correct direction. // Calculate the sum of the absolute deviations from the mean of the probe measurements. // Compare to the last iteration to ensure it's getting better. @@ -266,11 +307,8 @@ void GcodeSuite::G34() { z_align_level_indicator += ABS(z_measured[zstepper] - z_measured_mean); // If it's getting worse, stop and throw an error - if (last_z_align_level_indicator < z_align_level_indicator * 0.7f) { - SERIAL_ECHOLNPGM("Decreasing accuracy detected."); - err_break = true; - break; - } + err_break = decreasing_accuracy(last_z_align_level_indicator, z_align_level_indicator); + if (err_break) break; last_z_align_level_indicator = z_align_level_indicator; #endif @@ -290,8 +328,7 @@ void GcodeSuite::G34() { if (z_align_abs) amplification = (iteration == 1) ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification; // Check for less accuracy compared to last move - if (last_z_align_move[zstepper] < z_align_abs * 0.7f) { - SERIAL_ECHOLNPGM("Decreasing accuracy detected."); + if (decreasing_accuracy(last_z_align_move[zstepper], z_align_abs)) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " last_z_align_move = ", last_z_align_move[zstepper]); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " z_align_abs = ", z_align_abs); adjustment_reverse = !adjustment_reverse; @@ -329,9 +366,14 @@ void GcodeSuite::G34() { if (err_break) break; - if (success_break) { SERIAL_ECHOLNPGM("Target accuracy achieved."); break; } + if (success_break) { + SERIAL_ECHOLNPGM("Target accuracy achieved."); + LCD_MESSAGEPGM(MSG_ACCURACY_ACHIEVED); + break; + } - } // for (iteration) + iteration++; + } // while (iteration < z_auto_align_iterations) if (err_break) SERIAL_ECHOLNPGM("G34 aborted."); diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 746cb108766b..6517e6b4bdc4 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -30,7 +30,7 @@ #include "../../feature/backlash.h" #endif -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../module/motion.h" #include "../../module/planner.h" #include "../../module/tool_change.h" @@ -581,13 +581,12 @@ void GcodeSuite::G425() { GcodeSuite::process_subcommands_now_P(PSTR(CALIBRATION_SCRIPT_PRE)); #endif - TEMPORARY_SOFT_ENDSTOP_STATE(false); - TEMPORARY_BED_LEVELING_STATE(false); - if (homing_needed_error()) return; - measurements_t m; + TEMPORARY_BED_LEVELING_STATE(false); + SET_SOFT_ENDSTOP_LOOSE(true); + measurements_t m; float uncertainty = parser.seenval('U') ? parser.value_float() : CALIBRATION_MEASUREMENT_UNCERTAIN; if (parser.seen('B')) @@ -612,6 +611,8 @@ void GcodeSuite::G425() { else calibrate_all(); + SET_SOFT_ENDSTOP_LOOSE(false); + #ifdef CALIBRATION_SCRIPT_POST GcodeSuite::process_subcommands_now_P(PSTR(CALIBRATION_SCRIPT_POST)); #endif diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index 89393b4582c1..38f17869fb45 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -37,7 +37,7 @@ #include "../../module/probe.h" #include "../../feature/probe_temp_comp.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../MarlinCore.h" // for wait_for_heatup and idle() #if ENABLED(PRINTJOB_TIMER_AUTOSTART) diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 8640dfa39166..e70815ad543a 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -27,7 +27,7 @@ #include "../gcode.h" #include "../../module/motion.h" #include "../../module/probe.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../feature/bedlevel/bedlevel.h" diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 1e7374542c3d..005fdf0f3146 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -46,6 +46,10 @@ #include "../../lcd/extui/ui_api.h" #endif +#if HAS_RESUME_CONTINUE + #include "../../lcd/marlinui.h" +#endif + #ifndef GET_PIN_MAP_PIN_M43 #define GET_PIN_MAP_PIN_M43(Q) GET_PIN_MAP_PIN(Q) #endif @@ -362,7 +366,10 @@ void GcodeSuite::M43() { } } - if (TERN0(HAS_RESUME_CONTINUE, !wait_for_user)) break; + #if HAS_RESUME_CONTINUE + ui.update(); + if (!wait_for_user) break; + #endif safe_delay(200); } diff --git a/Marlin/src/gcode/control/M111.cpp b/Marlin/src/gcode/control/M111.cpp index e31c3e2fb7b2..38cb06532241 100644 --- a/Marlin/src/gcode/control/M111.cpp +++ b/Marlin/src/gcode/control/M111.cpp @@ -71,7 +71,7 @@ void GcodeSuite::M111() { #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED) SERIAL_ECHOPAIR("\nMax RX Queue Size: ", MYSERIAL0.rxMaxEnqueued()); #endif - #endif // !defined(__AVR__) || !defined(USBCON) + #endif // !__AVR__ || !USBCON } SERIAL_EOL(); } diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index 499feef71586..b35b4653319c 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -22,7 +22,7 @@ #include "../gcode.h" #include "../../MarlinCore.h" // for stepper_inactive_time, disable_e_steppers -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../module/stepper.h" #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin/src/gcode/control/M211.cpp b/Marlin/src/gcode/control/M211.cpp index ffad722f3f7a..2049f1eb6955 100644 --- a/Marlin/src/gcode/control/M211.cpp +++ b/Marlin/src/gcode/control/M211.cpp @@ -37,8 +37,8 @@ void GcodeSuite::M211() { l_soft_max = soft_endstop.max.asLogical(); SERIAL_ECHO_START(); SERIAL_ECHOPGM(STR_SOFT_ENDSTOPS); - if (parser.seen('S')) soft_endstops_enabled = parser.value_bool(); - serialprint_onoff(soft_endstops_enabled); + if (parser.seen('S')) soft_endstop._enabled = parser.value_bool(); + serialprint_onoff(soft_endstop._enabled); print_xyz(l_soft_min, PSTR(STR_SOFT_MIN), PSTR(" ")); print_xyz(l_soft_max, PSTR(STR_SOFT_MAX)); } diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 5dc36428b503..b1e54b25e779 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -68,7 +68,7 @@ const DualXMode previous_mode = dual_x_carriage_mode; dual_x_carriage_mode = (DualXMode)parser.value_byte(); - mirrored_duplication_mode = false; + idex_set_mirrored_mode(false); if (dual_x_carriage_mode == DXC_MIRRORED_MODE) { if (previous_mode != DXC_DUPLICATION_MODE) { @@ -77,8 +77,7 @@ dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; return; } - mirrored_duplication_mode = true; - stepper.set_directions(); + idex_set_mirrored_mode(true); float x_jog = current_position.x - .1; for (uint8_t i = 2; --i;) { planner.buffer_line(x_jog, current_position.y, current_position.z, current_position.e, feedrate_mm_s, 0); @@ -102,10 +101,8 @@ dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; break; } - active_extruder_parked = false; - extruder_duplication_enabled = false; - stepper.set_directions(); - delayed_move_time = 0; + idex_set_parked(false); + set_duplication_enabled(false); } else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; @@ -125,7 +122,7 @@ if (!active_extruder_parked) DEBUG_ECHOPGM(" NOT "); DEBUG_ECHOPGM(" parked."); DEBUG_ECHOPAIR("\nactive_extruder_x_pos: ", current_position.x); - DEBUG_ECHOPAIR("\ninactive_extruder_x_pos: ", inactive_extruder_x_pos); + DEBUG_ECHOPAIR("\ninactive_extruder_x: ", inactive_extruder_x); DEBUG_ECHOPAIR("\nextruder_duplication_enabled: ", int(extruder_duplication_enabled)); DEBUG_ECHOPAIR("\nduplicate_extruder_x_offset: ", duplicate_extruder_x_offset); DEBUG_ECHOPAIR("\nduplicate_extruder_temp_offset: ", duplicate_extruder_temp_offset); @@ -166,7 +163,7 @@ if (parser.seenval('P')) duplication_e_mask = parser.value_int(); // Set the mask directly else if (parser.seenval('E')) duplication_e_mask = pow(2, parser.value_int() + 1) - 1; // Set the mask by E index ena = (2 == parser.intval('S', extruder_duplication_enabled ? 2 : 0)); - extruder_duplication_enabled = ena && (duplication_e_mask >= 3); + set_duplication_enabled(ena && (duplication_e_mask >= 3)); } SERIAL_ECHO_START(); SERIAL_ECHOPGM(STR_DUPLICATION_MODE); diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index 6302bb5c6787..a8f7f7c10b64 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -25,7 +25,7 @@ #include "../../module/temperature.h" #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 "../../lcd/marlinui.h" // for LCD_MESSAGEPGM_P #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/gcode/control/M999.cpp b/Marlin/src/gcode/control/M999.cpp index 3bd908cad640..7487b4cf6e74 100644 --- a/Marlin/src/gcode/control/M999.cpp +++ b/Marlin/src/gcode/control/M999.cpp @@ -22,7 +22,7 @@ #include "../gcode.h" -#include "../../lcd/ultralcd.h" // for lcd_reset_alert_level +#include "../../lcd/marlinui.h" // for lcd_reset_alert_level #include "../../MarlinCore.h" // for marlin_state #include "../queue.h" // for flush_and_request_resend diff --git a/Marlin/src/gcode/feature/clean/G12.cpp b/Marlin/src/gcode/feature/clean/G12.cpp index f91db39703f0..216db5bae374 100644 --- a/Marlin/src/gcode/feature/clean/G12.cpp +++ b/Marlin/src/gcode/feature/clean/G12.cpp @@ -70,9 +70,11 @@ void GcodeSuite::G12() { TEMPORARY_BED_LEVELING_STATE(!TEST(cleans, Z_AXIS) && planner.leveling_active); #endif - TEMPORARY_SOFT_ENDSTOP_STATE(parser.boolval('E')); + SET_SOFT_ENDSTOP_LOOSE(!parser.boolval('E')); nozzle.clean(pattern, strokes, radius, objects, cleans); + + SET_SOFT_ENDSTOP_LOOSE(false); } #endif // NOZZLE_CLEAN_FEATURE diff --git a/Marlin/src/gcode/feature/digipot/M907-M910.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp index 54599a045134..e46366620798 100644 --- a/Marlin/src/gcode/feature/digipot/M907-M910.cpp +++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp @@ -22,19 +22,19 @@ #include "../../../inc/MarlinConfig.h" -#if ANY(HAS_DIGIPOTSS, HAS_MOTOR_CURRENT_PWM, HAS_I2C_DIGIPOT, DAC_STEPPER_CURRENT) +#if ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC) #include "../../gcode.h" -#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM +#if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM #include "../../../module/stepper.h" #endif -#if HAS_I2C_DIGIPOT +#if HAS_MOTOR_CURRENT_I2C #include "../../../feature/digipot/digipot.h" #endif -#if ENABLED(DAC_STEPPER_CURRENT) +#if ENABLED(HAS_MOTOR_CURRENT_DAC) #include "../../../feature/dac/stepper_dac.h" #endif @@ -42,61 +42,61 @@ * M907: Set digital trimpot motor current using axis codes X, Y, Z, E, B, S */ void GcodeSuite::M907() { - #if HAS_DIGIPOTSS + #if HAS_MOTOR_CURRENT_SPI - LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.digipot_current(i, parser.value_int()); - if (parser.seenval('B')) stepper.digipot_current(4, parser.value_int()); - if (parser.seenval('S')) LOOP_LE_N(i, 4) stepper.digipot_current(i, parser.value_int()); + LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.set_digipot_current(i, parser.value_int()); + if (parser.seenval('B')) stepper.set_digipot_current(4, parser.value_int()); + if (parser.seenval('S')) LOOP_LE_N(i, 4) stepper.set_digipot_current(i, parser.value_int()); #elif HAS_MOTOR_CURRENT_PWM #if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY) - if (parser.seenval('X') || parser.seenval('Y')) stepper.digipot_current(0, parser.value_int()); + if (parser.seenval('X') || parser.seenval('Y')) stepper.set_digipot_current(0, parser.value_int()); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) - if (parser.seenval('Z')) stepper.digipot_current(1, parser.value_int()); + if (parser.seenval('Z')) stepper.set_digipot_current(1, parser.value_int()); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) - if (parser.seenval('E')) stepper.digipot_current(2, parser.value_int()); + if (parser.seenval('E')) stepper.set_digipot_current(2, parser.value_int()); #endif #endif - #if HAS_I2C_DIGIPOT + #if HAS_MOTOR_CURRENT_I2C // this one uses actual amps in floating point - LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) digipot_i2c_set_current(i, parser.value_float()); + LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) digipot_i2c.set_current(i, parser.value_float()); // Additional extruders use B,C,D for channels 4,5,6. // TODO: Change these parameters because 'E' is used. B? for (uint8_t i = E_AXIS + 1; i < DIGIPOT_I2C_NUM_CHANNELS; i++) - if (parser.seenval('B' + i - (E_AXIS + 1))) digipot_i2c_set_current(i, parser.value_float()); + if (parser.seenval('B' + i - (E_AXIS + 1))) digipot_i2c.set_current(i, parser.value_float()); #endif - #if ENABLED(DAC_STEPPER_CURRENT) + #if ENABLED(HAS_MOTOR_CURRENT_DAC) if (parser.seenval('S')) { const float dac_percent = parser.value_float(); - LOOP_LE_N(i, 4) dac_current_percent(i, dac_percent); + LOOP_LE_N(i, 4) stepper_dac.set_current_percent(i, dac_percent); } - LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) dac_current_percent(i, parser.value_float()); + LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper_dac.set_current_percent(i, parser.value_float()); #endif } -#if EITHER(HAS_DIGIPOTSS, DAC_STEPPER_CURRENT) +#if EITHER(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC) /** * M908: Control digital trimpot directly (M908 P S) */ void GcodeSuite::M908() { - TERN_(HAS_DIGIPOTSS, stepper.digitalPotWrite(parser.intval('P'), parser.intval('S'))); - TERN_(DAC_STEPPER_CURRENT, dac_current_raw(parser.byteval('P', -1), parser.ushortval('S', 0))); + TERN_(HAS_MOTOR_CURRENT_SPI, stepper.set_digipot_value_spi(parser.intval('P'), parser.intval('S'))); + TERN_(HAS_MOTOR_CURRENT_DAC, stepper_dac.set_current_value(parser.byteval('P', -1), parser.ushortval('S', 0))); } -#endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT + #if ENABLED(HAS_MOTOR_CURRENT_DAC) -#if ENABLED(DAC_STEPPER_CURRENT) + void GcodeSuite::M909() { stepper_dac.print_values(); } + void GcodeSuite::M910() { stepper_dac.commit_eeprom(); } - void GcodeSuite::M909() { dac_print_values(); } - void GcodeSuite::M910() { dac_commit_eeprom(); } + #endif // HAS_MOTOR_CURRENT_DAC -#endif // DAC_STEPPER_CURRENT +#endif // HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_DAC -#endif // HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM || HAS_I2C_DIGIPOT || DAC_STEPPER_CURRENT +#endif // HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM || HAS_MOTOR_CURRENT_I2C || HAS_MOTOR_CURRENT_DAC diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index db78e870d71a..ed9a3933107b 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -32,7 +32,7 @@ #include "../../../module/printcounter.h" #if HAS_LCD_MENU - #include "../../../lcd/ultralcd.h" + #include "../../../lcd/marlinui.h" #endif #if ENABLED(POWER_LOSS_RECOVERY) diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 7c9be54b2916..0af68333caa2 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -34,7 +34,7 @@ #endif #if HAS_LCD_MENU - #include "../../../lcd/ultralcd.h" + #include "../../../lcd/marlinui.h" #endif #if ENABLED(MMU2_MENUS) @@ -87,7 +87,7 @@ void GcodeSuite::M600() { if (!parser.seen('T')) { // If no tool index is specified, M600 was (probably) sent in response to filament runout. // In this case, for duplicating modes set DXC_ext to the extruder that ran out. #if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1 - if (dxc_is_duplicating()) + if (idex_is_duplicating()) DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT_STATE) ? 1 : 0; #else DXC_ext = active_extruder; @@ -108,7 +108,7 @@ void GcodeSuite::M600() { #if HAS_MULTI_EXTRUDER // Change toolhead if specified const uint8_t active_extruder_before_filament_change = active_extruder; - if (active_extruder != target_extruder && TERN1(DUAL_X_CARRIAGE, !dxc_is_duplicating())) + if (active_extruder != target_extruder && TERN1(DUAL_X_CARRIAGE, !idex_is_duplicating())) tool_change(target_extruder, false); #endif diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index c1f7223142c3..a193d83d40f6 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -35,7 +35,7 @@ #endif #if HAS_LCD_MENU - #include "../../../lcd/ultralcd.h" + #include "../../../lcd/marlinui.h" #endif #if ENABLED(PRUSA_MMU2) diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index e9477dd2fbf3..14c92531fa0b 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -27,7 +27,7 @@ #include "../../gcode.h" #include "../../../feature/powerloss.h" #include "../../../module/motion.h" -#include "../../../lcd/ultralcd.h" +#include "../../../lcd/marlinui.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" #endif diff --git a/Marlin/src/gcode/feature/powerloss/M413.cpp b/Marlin/src/gcode/feature/powerloss/M413.cpp index 3538ccaa6e07..64573e5dff2a 100644 --- a/Marlin/src/gcode/feature/powerloss/M413.cpp +++ b/Marlin/src/gcode/feature/powerloss/M413.cpp @@ -27,7 +27,7 @@ #include "../../gcode.h" #include "../../../feature/powerloss.h" #include "../../../module/motion.h" -#include "../../../lcd/ultralcd.h" +#include "../../../lcd/marlinui.h" /** * M413: Enable / Disable power-loss recovery diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index cbf62e0fcf97..f2bd81e670dc 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -327,7 +327,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 33: G33(); break; // G33: Delta Auto-Calibration #endif - #if ENABLED(Z_STEPPER_AUTO_ALIGN) + #if EITHER(Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION) case 34: G34(); break; // G34: Z Stepper automatic alignment using probe #endif @@ -823,11 +823,11 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 900: M900(); break; // M900: Set advance K factor. #endif - #if ANY(HAS_DIGIPOTSS, HAS_MOTOR_CURRENT_PWM, HAS_I2C_DIGIPOT, DAC_STEPPER_CURRENT) + #if ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC) case 907: M907(); break; // M907: Set digital trimpot motor current using axis codes. - #if EITHER(HAS_DIGIPOTSS, DAC_STEPPER_CURRENT) + #if EITHER(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC) case 908: M908(); break; // M908: Control digital trimpot directly. - #if ENABLED(DAC_STEPPER_CURRENT) + #if ENABLED(HAS_MOTOR_CURRENT_DAC) case 909: M909(); break; // M909: Print digipot/DAC current value case 910: M910(); break; // M910: Commit digipot/DAC value to external EEPROM #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 73a372781370..3d745eff8939 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -258,9 +258,9 @@ * M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE) * M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) * M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots) - * M908 - Control digital trimpot directly. (Requires DAC_STEPPER_CURRENT or DIGIPOTSS_PIN) - * M909 - Print digipot/DAC current value. (Requires DAC_STEPPER_CURRENT) - * M910 - Commit digipot/DAC value to external EEPROM via I2C. (Requires DAC_STEPPER_CURRENT) + * M908 - Control digital trimpot directly. (Requires HAS_MOTOR_CURRENT_DAC or DIGIPOTSS_PIN) + * M909 - Print digipot/DAC current value. (Requires HAS_MOTOR_CURRENT_DAC) + * M910 - Commit digipot/DAC value to external EEPROM via I2C. (Requires HAS_MOTOR_CURRENT_DAC) * M911 - Report stepper driver overtemperature pre-warn condition. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD) @@ -465,11 +465,12 @@ class GcodeSuite { TERN_(DELTA_AUTO_CALIBRATION, static void G33()); - #if ENABLED(Z_STEPPER_AUTO_ALIGN) + #if EITHER(Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION) static void G34(); - static void M422(); #endif + TERN_(Z_STEPPER_AUTO_ALIGN, static void M422()); + TERN_(ASSISTED_TRAMMING, static void G35()); TERN_(G38_PROBE_TARGET, static void G38(const int8_t subcode)); @@ -847,11 +848,11 @@ class GcodeSuite { static void M918(); #endif - #if ANY(HAS_DIGIPOTSS, HAS_MOTOR_CURRENT_PWM, HAS_I2C_DIGIPOT, DAC_STEPPER_CURRENT) + #if ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC) static void M907(); - #if EITHER(HAS_DIGIPOTSS, DAC_STEPPER_CURRENT) + #if EITHER(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC) static void M908(); - #if ENABLED(DAC_STEPPER_CURRENT) + #if ENABLED(HAS_MOTOR_CURRENT_DAC) static void M909(); static void M910(); #endif diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 4bc3b6c6c377..1f38a85b9135 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -25,8 +25,10 @@ #include "gcode.h" #include "../module/settings.h" + #include "../module/temperature.h" #include "../libs/hex_print.h" #include "../HAL/shared/eeprom_if.h" + #include "../HAL/shared/Delay.h" /** * Dn: G-code for development and testing @@ -84,40 +86,23 @@ } } break; - case 3: { // D3 Read / Write EEPROM - uint8_t *pointer = parser.hex_adr_val('A'); - uint16_t len = parser.ushortval('C', 1); - uintptr_t addr = (uintptr_t)pointer; - #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE size_t(E2END + 1) - #endif - NOMORE(addr, (size_t)(MARLIN_EEPROM_SIZE - 1)); - NOMORE(len, MARLIN_EEPROM_SIZE - addr); - if (parser.seenval('X')) { - uint16_t val = parser.hex_val('X'); - #if ENABLED(EEPROM_SETTINGS) - persistentStore.access_start(); - while(len--) { - int pos = 0; - persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val)); - } - SERIAL_EOL(); - persistentStore.access_finish(); - #else - SERIAL_ECHOLN("NO EEPROM"); + #if ENABLED(EEPROM_SETTINGS) + case 3: { // D3 Read / Write EEPROM + uint8_t *pointer = parser.hex_adr_val('A'); + uint16_t len = parser.ushortval('C', 1); + uintptr_t addr = (uintptr_t)pointer; + #ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE size_t(E2END + 1) #endif - } - else { - while (len--) { - // Read bytes from EEPROM + NOMORE(addr, (size_t)(MARLIN_EEPROM_SIZE - 1)); + NOMORE(len, MARLIN_EEPROM_SIZE - addr); + if (parser.seenval('X')) { + uint16_t val = parser.hex_val('X'); #if ENABLED(EEPROM_SETTINGS) persistentStore.access_start(); - uint8_t val; while(len--) { int pos = 0; - if (!persistentStore.read_data(pos, (uint8_t *)&val, sizeof(val))) { - print_hex_byte(val); - } + persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val)); } SERIAL_EOL(); persistentStore.access_finish(); @@ -125,9 +110,28 @@ SERIAL_ECHOLN("NO EEPROM"); #endif } - SERIAL_EOL(); - } - } break; + else { + while (len--) { + // Read bytes from EEPROM + #if ENABLED(EEPROM_SETTINGS) + persistentStore.access_start(); + uint8_t val; + while(len--) { + int pos = 0; + if (!persistentStore.read_data(pos, (uint8_t *)&val, sizeof(val))) { + print_hex_byte(val); + } + } + SERIAL_EOL(); + persistentStore.access_finish(); + #else + SERIAL_ECHOLN("NO EEPROM"); + #endif + } + SERIAL_EOL(); + } + } break; + #endif case 4: { // D4 Read / Write PIN // const uint8_t pin = parser.byteval('P'); @@ -167,6 +171,20 @@ SERIAL_EOL(); } } break; + + case 100: { // D100 Disable heaters and attempt a hard hang (Watchdog Test) + SERIAL_ECHOLN("Disabling heaters and attempting to trigger Watchdog"); + SERIAL_ECHOLN("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")"); + thermalManager.disable_all_heaters(); + delay(1000); // Allow time to print + DISABLE_ISRS(); + // Use a low-level delay that does not rely on interrupts to function + // Do not spin forever, to avoid thermal risks if heaters are enabled and + // watchdog does not work. + DELAY_US(10000000); + ENABLE_ISRS(); + SERIAL_ECHOLN("FAILURE: Watchdog did not trigger board reset."); + } } } diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index a477a1a526ef..70cb1e19e50f 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -26,7 +26,7 @@ #include "../gcode.h" #include "../../module/motion.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../libs/buzzer.h" /** diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 1d18b706029c..414c4ce02396 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -32,7 +32,7 @@ #include "../../MarlinCore.h" // for wait_for_user_response() #if HAS_LCD_MENU - #include "../../lcd/ultralcd.h" + #include "../../lcd/marlinui.h" #elif ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" #endif diff --git a/Marlin/src/gcode/lcd/M117.cpp b/Marlin/src/gcode/lcd/M117.cpp index 8459135f3018..59305d94c5b5 100644 --- a/Marlin/src/gcode/lcd/M117.cpp +++ b/Marlin/src/gcode/lcd/M117.cpp @@ -21,7 +21,7 @@ */ #include "../gcode.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" /** * M117: Set LCD Status Message diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index abd4dcc7439b..84a7e75aa440 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -25,7 +25,7 @@ #if PREHEAT_COUNT #include "../gcode.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" /** * M145: Set the heatup state for a material in the LCD menu diff --git a/Marlin/src/gcode/lcd/M250.cpp b/Marlin/src/gcode/lcd/M250.cpp index f42daaeac428..f553044d31c0 100644 --- a/Marlin/src/gcode/lcd/M250.cpp +++ b/Marlin/src/gcode/lcd/M250.cpp @@ -25,7 +25,7 @@ #if HAS_LCD_CONTRAST #include "../gcode.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" /** * M250: Read and optionally set the LCD contrast diff --git a/Marlin/src/gcode/lcd/M300.cpp b/Marlin/src/gcode/lcd/M300.cpp index 56d9ee5d7350..5250774955fb 100644 --- a/Marlin/src/gcode/lcd/M300.cpp +++ b/Marlin/src/gcode/lcd/M300.cpp @@ -26,7 +26,7 @@ #include "../gcode.h" -#include "../../lcd/ultralcd.h" // i2c-based BUZZ +#include "../../lcd/marlinui.h" // i2c-based BUZZ #include "../../libs/buzzer.h" // Buzzer, if possible /** diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index 7a5454419da9..5b135bdff8bd 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -25,7 +25,7 @@ #if ENABLED(LCD_SET_PROGRESS_MANUALLY) #include "../gcode.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../sd/cardreader.h" /** diff --git a/Marlin/src/gcode/motion/G4.cpp b/Marlin/src/gcode/motion/G4.cpp index 3a37fe5b2c4e..724ed7f1cad9 100644 --- a/Marlin/src/gcode/motion/G4.cpp +++ b/Marlin/src/gcode/motion/G4.cpp @@ -22,7 +22,7 @@ #include "../gcode.h" #include "../../module/stepper.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" /** * G4: Dwell S or P diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index 7158525ed9d9..18cc161fce29 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -127,7 +127,7 @@ void GcodeSuite::M290() { #else PSTR("Babystep Z") #endif - , babystep.axis_total[BS_AXIS_IND(Z_AXIS)] + , babystep.axis_total[BS_TOTAL_IND(Z_AXIS)] ); } #endif diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index b9169d90e1c7..4de5056fb2ab 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -29,7 +29,7 @@ GCodeQueue queue; #include "gcode.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #include "../sd/cardreader.h" #include "../module/planner.h" #include "../module/temperature.h" diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index b28429f6315d..4a461170bc39 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -32,7 +32,7 @@ #endif #if EITHER(LCD_SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE) - #include "../../lcd/ultralcd.h" + #include "../../lcd/marlinui.h" #endif #if ENABLED(POWER_LOSS_RECOVERY) diff --git a/Marlin/src/gcode/sd/M23.cpp b/Marlin/src/gcode/sd/M23.cpp index b88f66b59162..51bc82413040 100644 --- a/Marlin/src/gcode/sd/M23.cpp +++ b/Marlin/src/gcode/sd/M23.cpp @@ -26,7 +26,7 @@ #include "../gcode.h" #include "../../sd/cardreader.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" /** * M23: Open a file diff --git a/Marlin/src/gcode/sd/M24_M25.cpp b/Marlin/src/gcode/sd/M24_M25.cpp index bdb37f605cbf..611ba17c55bc 100644 --- a/Marlin/src/gcode/sd/M24_M25.cpp +++ b/Marlin/src/gcode/sd/M24_M25.cpp @@ -27,7 +27,7 @@ #include "../gcode.h" #include "../../sd/cardreader.h" #include "../../module/printcounter.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #if ENABLED(PARK_HEAD_ON_PAUSE) #include "../../feature/pause.h" diff --git a/Marlin/src/gcode/stats/M31.cpp b/Marlin/src/gcode/stats/M31.cpp index b39108bb903e..c0e7d2a7ae23 100644 --- a/Marlin/src/gcode/stats/M31.cpp +++ b/Marlin/src/gcode/stats/M31.cpp @@ -24,7 +24,7 @@ #include "../../core/serial.h" #include "../../module/printcounter.h" #include "../../libs/duration_t.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" /** * M31: Get the time since the start of SD Print (or last M109) diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 908e6e5a31ee..568d9b0e2707 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -22,7 +22,7 @@ #include "../gcode.h" #include "../../module/printcounter.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../MarlinCore.h" // for startOrResumeJob diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index a289983b9294..d2b466e2fba5 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -34,7 +34,7 @@ #include "../../module/temperature.h" #include "../../module/motion.h" #include "../../module/planner.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../MarlinCore.h" // for startOrResumeJob, etc. @@ -94,7 +94,7 @@ void GcodeSuite::M104() { thermalManager.setTargetHotend(temp, target_extruder); #if ENABLED(DUAL_X_CARRIAGE) - if (dxc_is_duplicating() && target_extruder == 0) + if (idex_is_duplicating() && target_extruder == 0) thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1); #endif @@ -172,7 +172,7 @@ void GcodeSuite::M109() { thermalManager.setTargetHotend(temp, target_extruder); #if ENABLED(DUAL_X_CARRIAGE) - if (dxc_is_duplicating() && target_extruder == 0) + if (idex_is_duplicating() && target_extruder == 0) thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1); #endif diff --git a/Marlin/src/gcode/temp/M106_M107.cpp b/Marlin/src/gcode/temp/M106_M107.cpp index 17ff8c3c8f60..9c70f1ebc782 100644 --- a/Marlin/src/gcode/temp/M106_M107.cpp +++ b/Marlin/src/gcode/temp/M106_M107.cpp @@ -29,7 +29,7 @@ #include "../../module/temperature.h" #if PREHEAT_COUNT - #include "../../lcd/ultralcd.h" + #include "../../lcd/marlinui.h" #endif #if ENABLED(SINGLENOZZLE) diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 9438b9e0c23c..ac8228085e0e 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -33,7 +33,7 @@ #include "../gcode.h" #include "../../module/temperature.h" #include "../../module/motion.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #if ENABLED(PRINTJOB_TIMER_AUTOSTART) #include "../../module/printcounter.h" diff --git a/Marlin/src/gcode/temp/M141_M191.cpp b/Marlin/src/gcode/temp/M141_M191.cpp index 41a79825aa3b..fc80c5f4cba4 100644 --- a/Marlin/src/gcode/temp/M141_M191.cpp +++ b/Marlin/src/gcode/temp/M141_M191.cpp @@ -34,7 +34,7 @@ #include "../../module/temperature.h" #include "../../module/motion.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #if ENABLED(PRINTJOB_TIMER_AUTOSTART) #include "../../module/printcounter.h" diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index ccce09b4f1ee..c1bf9efd7f38 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -25,7 +25,7 @@ #if HAS_PID_HEATING #include "../gcode.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" #include "../../module/temperature.h" #if ENABLED(EXTENSIBLE_UI) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 42d82dcc1066..cbc75cfb6d33 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -46,7 +46,7 @@ * * 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_ULTRA_LCD : Ultra LCD, not necessarily Ultipanel. * 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. @@ -63,22 +63,21 @@ #elif ENABLED(CARTESIO_UI) #define DOGLCD - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #elif EITHER(DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) #define IS_DWIN_MARLINUI 1 - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #elif ENABLED(ZONESTAR_LCD) - #define ADC_KEYPAD - #define IS_RRW_KEYPAD + #define HAS_ADC_BUTTONS 1 #define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 #define ADC_KEY_NUM 8 - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 - // This helps to implement ADC_KEYPAD menus + // This helps to implement HAS_ADC_BUTTONS menus #define REVERSE_MENU_DIRECTION #define ENCODER_PULSES_PER_STEP 1 #define ENCODER_STEPS_PER_MENU_ITEM 1 @@ -86,29 +85,25 @@ #elif ENABLED(ZONESTAR_12864LCD) #define DOGLCD - #define IS_RRD_SC + #define IS_RRD_SC 1 #define U8GLIB_ST7920 #elif ENABLED(ZONESTAR_12864OLED) - #define IS_RRD_SC + #define IS_RRD_SC 1 #define U8GLIB_SH1106 #elif ENABLED(ZONESTAR_12864OLED_SSD1306) - #define IS_RRD_SC + #define IS_RRD_SC 1 #define IS_U8GLIB_SSD1306 #elif ENABLED(RADDS_DISPLAY) - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #define ENCODER_PULSES_PER_STEP 2 -#elif EITHER(ANET_FULL_GRAPHICS_LCD, BQ_LCD_SMART_CONTROLLER) - - #define IS_RRD_FG_SC - #elif ANY(miniVIKI, VIKI2, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864) #define DOGLCD - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #if ENABLED(miniVIKI) #define U8GLIB_ST7565_64128N @@ -123,40 +118,33 @@ #elif ENABLED(OLED_PANEL_TINYBOY2) #define IS_U8GLIB_SSD1306 - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #elif ENABLED(RA_CONTROL_PANEL) #define LCD_I2C_TYPE_PCA8574 #define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) #define DOGLCD #define U8GLIB_ST7920 - #define IS_ULTIPANEL - -#elif ENABLED(CR10_STOCKDISPLAY) - - #define IS_RRD_FG_SC - #define BOARD_ST7920_DELAY_1 DELAY_NS(125) - #define BOARD_ST7920_DELAY_2 DELAY_NS(125) - #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #define IS_ULTIPANEL 1 #elif ENABLED(MKS_12864OLED) - #define IS_RRD_SC + #define IS_RRD_SC 1 #define U8GLIB_SH1106 #elif ENABLED(MKS_12864OLED_SSD1306) - #define IS_RRD_SC + #define IS_RRD_SC 1 #define IS_U8GLIB_SSD1306 #elif ENABLED(FYSETC_242_OLED_12864) - #define IS_RRD_SC + #define IS_RRD_SC 1 #define U8GLIB_SH1106 #define LED_CONTROL_MENU @@ -179,7 +167,7 @@ #define FYSETC_MINI_12864 #define DOGLCD - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #define LED_COLORS_REDUCE_GREEN #if ENABLED(PSU_CONTROL) && EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) #define LED_BACKLIGHT_TIMEOUT 10000 @@ -205,7 +193,7 @@ #elif ENABLED(ULTI_CONTROLLER) - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #define U8GLIB_SSD1309 #define LCD_RESET_PIN LCD_PINS_D6 // This controller need a reset pin #define ENCODER_PULSES_PER_STEP 2 @@ -213,14 +201,14 @@ #elif ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602) - #define IS_RRD_SC + #define IS_RRD_SC 1 #define LCD_WIDTH 16 #define LCD_HEIGHT 2 #elif EITHER(TFTGLCD_PANEL_SPI, TFTGLCD_PANEL_I2C) #define IS_TFTGLCD_PANEL 1 - #define IS_ULTIPANEL // Note that IS_ULTIPANEL leads to HAS_WIRED_LCD + #define IS_ULTIPANEL 1 // Note that IS_ULTIPANEL leads to HAS_WIRED_LCD #if ENABLED(SDSUPPORT) && DISABLED(LCD_PROGRESS_BAR) #define LCD_PROGRESS_BAR @@ -239,14 +227,35 @@ #define CONVERT_TO_EXT_ASCII // Use extended 128-255 symbols from ASCII table. // At this time present conversion only for cyrillic - bg, ru and uk languages. // First 7 ASCII symbols in panel font must be replaced with Marlin's special symbols. + +#elif ENABLED(CR10_STOCKDISPLAY) + + #define IS_RRD_FG_SC 1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + +#elif ANY(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER, ANET_FULL_GRAPHICS_LCD, BQ_LCD_SMART_CONTROLLER) + + #define IS_RRD_FG_SC 1 + +#elif ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + + // RepRapDiscount LCD or Graphical LCD with rotary click encoder + #define IS_RRD_SC 1 + #endif -#if ENABLED(IS_RRD_FG_SC) - #define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +// ST7920-based graphical displays +#if ANY(IS_RRD_FG_SC, LCD_FOR_MELZI, SILVER_GATE_GLCD_CONTROLLER) + #define DOGLCD + #define U8GLIB_ST7920 + #define IS_RRD_SC 1 #endif +// ST7565 / 64128N graphical displays #if EITHER(MAKRPANEL, MINIPANEL) - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #define DOGLCD #if ENABLED(MAKRPANEL) #define U8GLIB_ST7565_64128N @@ -258,7 +267,7 @@ #endif #if ENABLED(OVERLORD_OLED) - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #define U8GLIB_SH1106 /** * PCA9632 for buzzer and LEDs via i2c @@ -278,77 +287,68 @@ // 128x64 I2C OLED LCDs - SSD1306/SSD1309/SH1106 #if ANY(U8GLIB_SSD1306, U8GLIB_SSD1309, U8GLIB_SH1106) #define HAS_U8GLIB_I2C_OLED 1 -#endif -#if HAS_U8GLIB_I2C_OLED - #define IS_ULTRA_LCD + #define IS_ULTRA_LCD 1 #define DOGLCD #endif -// ST7920-based graphical displays -#if ANY(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER, LCD_FOR_MELZI, SILVER_GATE_GLCD_CONTROLLER) - #define DOGLCD - #define U8GLIB_ST7920 - #define IS_RRD_SC -#endif - -// RepRapDiscount LCD or Graphical LCD with rotary click encoder -#if ENABLED(IS_RRD_SC) - #define REPRAP_DISCOUNT_SMART_CONTROLLER -#endif - /** * SPI Ultipanels */ // Basic Ultipanel-like displays -#if ANY(ULTIMAKERCONTROLLER, REPRAP_DISCOUNT_SMART_CONTROLLER, G3D_PANEL, RIGIDBOT_PANEL, PANEL_ONE, U8GLIB_SH1106) - #define IS_ULTIPANEL +#if ANY(ULTIMAKERCONTROLLER, IS_RRD_SC, G3D_PANEL, RIGIDBOT_PANEL, PANEL_ONE, U8GLIB_SH1106) + #define IS_ULTIPANEL 1 #endif // Einstart OLED has Cardinal nav via pins defined in pins_EINSTART-S.h #if ENABLED(U8GLIB_SH1106_EINSTART) #define DOGLCD - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 +#endif + +// TFT Compatibility +#if ANY(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT, TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_FSMC, TFT_LVGL_UI_SPI) + #define IS_LEGACY_TFT 1 + #define TFT_GENERIC + #warning "Don't forget to update your TFT settings in Configuration.h." +#endif + +#if ANY(FSMC_GRAPHICAL_TFT, TFT_320x240, TFT_480x320, TFT_LVGL_UI_FSMC) + #define TFT_INTERFACE_FSMC +#elif ANY(SPI_GRAPHICAL_TFT, TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_SPI) + #define TFT_INTERFACE_SPI +#endif + +#if EITHER(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT) + #define TFT_CLASSIC_UI +#elif ANY(TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI) + #define TFT_COLOR_UI +#elif EITHER(TFT_LVGL_UI_FSMC, TFT_LVGL_UI_SPI) + #define TFT_LVGL_UI #endif // FSMC/SPI TFT Panels (LVGL) -#if EITHER(TFT_LVGL_UI_SPI, TFT_LVGL_UI_FSMC) +#if ENABLED(TFT_LVGL_UI) #define HAS_TFT_LVGL_UI 1 #endif // FSMC/SPI TFT Panels -#if EITHER(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT) +#if ENABLED(TFT_CLASSIC_UI) #define TFT_SCALED_DOGLCD 1 #endif #if TFT_SCALED_DOGLCD #define DOGLCD - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #define DELAYED_BACKLIGHT_INIT -#elif ENABLED(TFT_LVGL_UI_SPI) +#elif ENABLED(TFT_LVGL_UI) #define DELAYED_BACKLIGHT_INIT #endif -// 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 ANY(TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_SPI, SPI_GRAPHICAL_TFT) - #define HAS_SPI_TFT 1 -#endif - // Color UI -#if ANY(TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI) +#if ENABLED(TFT_COLOR_UI) #define HAS_GRAPHICAL_TFT 1 - #define IS_ULTIPANEL -#endif - -// Fewer lines with touch buttons on-screen -#if EITHER(TFT_320x240, TFT_320x240_SPI) - #define HAS_UI_320x240 1 - #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) -#elif EITHER(TFT_480x320, TFT_480x320_SPI) - #define HAS_UI_480x320 1 - #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) + #define IS_ULTIPANEL 1 #endif /** @@ -372,7 +372,7 @@ #define LCD_I2C_TYPE_MCP23017 #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander #define LCD_USE_I2C_BUZZER // Enable buzzer on LCD (optional) - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #elif ENABLED(LCD_I2C_VIKI) @@ -387,7 +387,7 @@ #define LCD_I2C_TYPE_MCP23017 #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander #define LCD_USE_I2C_BUZZER // Enable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later) - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #define ENCODER_FEEDRATE_DEADZONE 4 @@ -399,7 +399,7 @@ #define STD_ENCODER_PULSES_PER_STEP 2 #define STD_ENCODER_STEPS_PER_MENU_ITEM 1 -#elif ANY(REPRAP_DISCOUNT_SMART_CONTROLLER, miniVIKI, VIKI2, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864, OLED_PANEL_TINYBOY2, BQ_LCD_SMART_CONTROLLER, LCD_I2C_PANELOLU2) +#elif ANY(IS_RRD_SC, miniVIKI, VIKI2, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864, OLED_PANEL_TINYBOY2, BQ_LCD_SMART_CONTROLLER, LCD_I2C_PANELOLU2) #define STD_ENCODER_PULSES_PER_STEP 4 #define STD_ENCODER_STEPS_PER_MENU_ITEM 1 @@ -432,30 +432,24 @@ // https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #if ENABLED(FF_INTERFACEBOARD) #define SR_LCD_3W_NL // Non latching 3 wire shift register - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 #elif ENABLED(SAV_3DLCD) #define SR_LCD_2W_NL // Non latching 2 wire shift register - #define IS_ULTIPANEL + #define IS_ULTIPANEL 1 +#elif ENABLED(ULTIPANEL) + #define IS_ULTIPANEL 1 #endif -#if ENABLED(IS_ULTIPANEL) - #define ULTIPANEL -#endif -#if ENABLED(ULTIPANEL) - #define IS_ULTRA_LCD - #define NEWPANEL -#endif -#if ENABLED(IS_ULTRA_LCD) - #define ULTRA_LCD +#if EITHER(IS_ULTIPANEL, ULTRA_LCD) + #define IS_ULTRA_LCD 1 #endif -#if ENABLED(IS_RRW_KEYPAD) - #define REPRAPWORLD_KEYPAD +#if EITHER(IS_ULTIPANEL, REPRAPWORLD_KEYPAD) + #define IS_NEWPANEL 1 #endif -// Keypad needs a move step -#if ENABLED(REPRAPWORLD_KEYPAD) - #define NEWPANEL +#if EITHER(ZONESTAR_LCD, REPRAPWORLD_KEYPAD) + #define IS_RRW_KEYPAD 1 #ifndef REPRAPWORLD_KEYPAD_MOVE_STEP #define REPRAPWORLD_KEYPAD_MOVE_STEP 1.0 #endif @@ -468,16 +462,16 @@ // Extensible UI serial touch screens. (See src/lcd/extui) #if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) - #define IS_EXTUI + #define IS_EXTUI 1 #define EXTENSIBLE_UI #endif // Aliases for LCD features -#if EITHER(ULTRA_LCD, EXTENSIBLE_UI) +#if EITHER(IS_ULTRA_LCD, EXTENSIBLE_UI) #define HAS_DISPLAY 1 #endif -#if ENABLED(ULTRA_LCD) +#if IS_ULTRA_LCD #define HAS_WIRED_LCD 1 #if ENABLED(DOGLCD) #define HAS_MARLINUI_U8GLIB 1 @@ -488,12 +482,9 @@ #endif #endif -#if ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS) +#if IS_ULTIPANEL && DISABLED(NO_LCD_MENUS) #define HAS_LCD_MENU 1 #endif -#if ENABLED(ADC_KEYPAD) - #define HAS_ADC_BUTTONS 1 -#endif #if HAS_MARLINUI_U8GLIB #ifndef LCD_PIXEL_WIDTH @@ -810,3 +801,132 @@ #ifndef EXTRUDE_MINTEMP #define EXTRUDE_MINTEMP 170 #endif + +/** + * TFT Displays + * + * Configure parameters for TFT displays: + * - TFT_DEFAULT_ORIENTATION + * - TFT_DRIVER + * - TFT_WIDTH + * - TFT_HEIGHT + * - TFT_INTERFACE_(SPI|FSMC) + * - TFT_COLOR + * - GRAPHICAL_TFT_UPSCALE + */ +#if ENABLED(MKS_TS35_V2_0) + // Most common: ST7796 + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY) + #define TFT_RES_480x320 + #define TFT_INTERFACE_SPI +#elif ENABLED(MKS_ROBIN_TFT24) + // Most common: ST7789 + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y) + #define TFT_RES_320x240 + #define TFT_INTERFACE_FSMC +#elif ENABLED(MKS_ROBIN_TFT28) + // Most common: ST7789 + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y) + #define TFT_RES_320x240 + #define TFT_INTERFACE_FSMC +#elif ENABLED(MKS_ROBIN_TFT32) + // Most common: ST7789 + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y) + #define TFT_RES_320x240 + #define TFT_INTERFACE_FSMC +#elif ENABLED(MKS_ROBIN_TFT35) + // Most common: ILI9488 + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) + #define TFT_RES_480x320 + #define TFT_INTERFACE_FSMC +#elif ENABLED(MKS_ROBIN_TFT43) + #define TFT_DEFAULT_ORIENTATION 0 + #define TFT_DRIVER SSD1963 + #define TFT_RES_480x272 + #define TFT_INTERFACE_FSMC +#elif ENABLED(MKS_ROBIN_TFT_V1_1R) + // ILI9328 or R61505 + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) + #define TFT_RES_320x240 + #define TFT_INTERFACE_FSMC +#elif EITHER(TFT_TRONXY_X5SA, ANYCUBIC_TFT35) + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) + #define TFT_DRIVER ILI9488 + #define TFT_RES_480x320 + #define TFT_INTERFACE_FSMC +#elif ENABLED(LONGER_LK_TFT28) + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) + #define TFT_RES_320x240 + #define TFT_INTERFACE_FSMC +#elif ENABLED(TFT_GENERIC) + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) + #if NONE(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320) + #define TFT_RES_320x240 + #endif + #if NONE(TFT_INTERFACE_FSMC, TFT_INTERFACE_SPI) + #define TFT_INTERFACE_SPI + #endif +#endif + +#if ENABLED(TFT_RES_320x240) + #define TFT_WIDTH 320 + #define TFT_HEIGHT 240 + #define GRAPHICAL_TFT_UPSCALE 2 +#elif ENABLED(TFT_RES_480x272) + #define TFT_WIDTH 480 + #define TFT_HEIGHT 272 + #define GRAPHICAL_TFT_UPSCALE 2 +#elif ENABLED(TFT_RES_480x320) + #define TFT_WIDTH 480 + #define TFT_HEIGHT 320 + #define GRAPHICAL_TFT_UPSCALE 3 +#endif + +// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi).h +#if ENABLED(TFT_INTERFACE_FSMC) + #define HAS_FSMC_TFT 1 + #if ENABLED(TFT_CLASSIC_UI) + #define HAS_FSMC_GRAPHICAL_TFT 1 + #elif ENABLED(TFT_LVGL_UI) + #define HAS_TFT_LVGL_UI_FSMC 1 + #endif +#elif ENABLED(TFT_INTERFACE_SPI) + #define HAS_SPI_TFT 1 + #if ENABLED(TFT_CLASSIC_UI) + #define HAS_SPI_GRAPHICAL_TFT 1 + #elif ENABLED(TFT_LVGL_UI) + #define HAS_TFT_LVGL_UI_SPI 1 + #endif +#endif + +#if ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 240 + #if ENABLED(TFT_INTERFACE_SPI) + #define TFT_320x240_SPI + #elif ENABLED(TFT_INTERFACE_FSMC) + #define TFT_320x240 + #endif +#elif ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 320 + #if ENABLED(TFT_INTERFACE_SPI) + #define TFT_480x320_SPI + #elif ENABLED(TFT_INTERFACE_FSMC) + #define TFT_480x320 + #endif +#endif + +// Fewer lines with touch buttons on-screen +#if EITHER(TFT_320x240, TFT_320x240_SPI) + #define HAS_UI_320x240 1 + #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) +#elif EITHER(TFT_480x320, TFT_480x320_SPI) + #define HAS_UI_480x320 1 + #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) +#endif + +// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046' +#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT + #undef TOUCH_SCREEN + #undef TOUCH_SCREEN_CALIBRATION + #if !HAS_TFT_LVGL_UI + #define HAS_TOUCH_XPT2046 1 + #endif +#endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 0952148d1989..78c014865c7b 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -148,7 +148,7 @@ #if ANY(MARLIN_BRICKOUT, MARLIN_INVADERS, MARLIN_SNAKE, MARLIN_MAZE) #define HAS_GAMES 1 - #if (1 < ENABLED(MARLIN_BRICKOUT) + ENABLED(MARLIN_INVADERS) + ENABLED(MARLIN_SNAKE) + ENABLED(MARLIN_MAZE)) + #if MANY(MARLIN_BRICKOUT, MARLIN_INVADERS, MARLIN_SNAKE, MARLIN_MAZE) #define HAS_GAME_MENU 1 #endif #endif @@ -163,7 +163,7 @@ #if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS) #define HAS_SOFTWARE_ENDSTOPS 1 #endif -#if ANY(EXTENSIBLE_UI, NEWPANEL, EMERGENCY_PARSER, HAS_ADC_BUTTONS, DWIN_CREALITY_LCD) +#if ANY(EXTENSIBLE_UI, IS_NEWPANEL, EMERGENCY_PARSER, HAS_ADC_BUTTONS, DWIN_CREALITY_LCD) #define HAS_RESUME_CONTINUE 1 #endif @@ -175,7 +175,7 @@ #endif #if EITHER(DIGIPOT_MCP4018, DIGIPOT_MCP4451) - #define HAS_I2C_DIGIPOT 1 + #define HAS_MOTOR_CURRENT_I2C 1 #endif // Multiple Z steppers diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index f832137f5b40..3587d82cdab7 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -383,7 +383,7 @@ #endif -#if ANY(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT) || !PIN_EXISTS(SD_DETECT) +#if ANY(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT) || !PIN_EXISTS(SD_DETECT) #define NO_LCD_REINIT 1 // Suppress LCD re-initialization #endif @@ -1976,7 +1976,7 @@ #define HAS_STEPPER_RESET 1 #endif #if PIN_EXISTS(DIGIPOTSS) - #define HAS_DIGIPOTSS 1 + #define HAS_MOTOR_CURRENT_SPI 1 #endif #if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_E) #define HAS_MOTOR_CURRENT_PWM 1 @@ -2578,7 +2578,7 @@ // Force SDCARD_SORT_ALPHA to be enabled for Graphical LCD on LPC1768 // on boards where SD card and LCD display share the same SPI bus // because of a bug in the shared SPI implementation. (See #8122) -#if defined(TARGET_LPC1768) && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && (SCK_PIN == LCD_PINS_D4) +#if defined(TARGET_LPC1768) && IS_RRD_FG_SC && (SCK_PIN == LCD_PINS_D4) #define SDCARD_SORT_ALPHA // Keep one directory level in RAM. Changing directory levels // may still glitch the screen, but LCD updates clean it up. #undef SDSORT_LIMIT @@ -2614,14 +2614,14 @@ #if HAS_MARLINUI_U8GLIB #define LCD_WIDTH 21 #else - #define LCD_WIDTH TERN(ULTIPANEL, 20, 16) + #define LCD_WIDTH TERN(IS_ULTIPANEL, 20, 16) #endif #endif #ifndef LCD_HEIGHT #if HAS_MARLINUI_U8GLIB #define LCD_HEIGHT 5 #else - #define LCD_HEIGHT TERN(ULTIPANEL, 4, 2) + #define LCD_HEIGHT TERN(IS_ULTIPANEL, 4, 2) #endif #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index c4dcfd54ae82..9aea18c2d768 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -422,7 +422,7 @@ #elif defined(CHAMBER_HEATER_PIN) #error "CHAMBER_HEATER_PIN is now HEATER_CHAMBER_PIN. Please update your configuration and/or pins." #elif defined(TMC_Z_CALIBRATION) - #error "TMC_Z_CALIBRATION has been deprecated in favor of Z_STEPPER_AUTO_ALIGN. Please update your configuration." + #error "TMC_Z_CALIBRATION has been deprecated in favor of MECHANICAL_GANTRY_CALIBRATION. Please update your configuration." #elif defined(Z_MIN_PROBE_ENDSTOP) #error "Z_MIN_PROBE_ENDSTOP is no longer required. Please remove it from Configuration.h." #elif defined(DUAL_NOZZLE_DUPLICATION_MODE) @@ -447,8 +447,6 @@ #error "POWER_SUPPLY is now obsolete. Please remove it from Configuration.h." #elif defined(MKS_ROBIN_TFT) #error "MKS_ROBIN_TFT is now FSMC_GRAPHICAL_TFT. Please update your configuration." -#elif defined(TFT_LVGL_UI) - #error "TFT_LVGL_UI is now TFT_LVGL_UI_FSMC. Please update your configuration." #elif defined(SDPOWER) #error "SDPOWER is now SDPOWER_PIN. Please update your configuration and/or pins." #elif defined(STRING_SPLASH_LINE1) || defined(STRING_SPLASH_LINE2) @@ -535,6 +533,8 @@ #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." +#elif defined(GRAPHICAL_TFT_ROTATE_180) + #error "GRAPHICAL_TFT_ROTATE_180 is now TFT_ROTATION set to TFT_ROTATE_180. Please update your Configuration.h." #elif defined(FIL_RUNOUT_INVERTING) #if FIL_RUNOUT_INVERTING #error "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_STATE HIGH. Please update your Configuration.h." @@ -702,8 +702,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif PROGRESS_MSG_EXPIRE < 0 #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." #endif -#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI) - #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, or EXTENSIBLE_UI." +#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI) + #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, or EXTENSIBLE_UI." + #endif #endif #if !HAS_LCD_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE) @@ -843,7 +845,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "ADVANCED_PAUSE_FEATURE requires FILAMENT_UNLOAD_PURGE_FEEDRATE. Please add it to Configuration_adv.h." #elif ENABLED(EXTRUDER_RUNOUT_PREVENT) #error "EXTRUDER_RUNOUT_PREVENT is incompatible with ADVANCED_PAUSE_FEATURE." - #elif ENABLED(PARK_HEAD_ON_PAUSE) && NONE(SDSUPPORT, NEWPANEL, EMERGENCY_PARSER) + #elif ENABLED(PARK_HEAD_ON_PAUSE) && NONE(SDSUPPORT, IS_NEWPANEL, EMERGENCY_PARSER) #error "PARK_HEAD_ON_PAUSE requires SDSUPPORT, EMERGENCY_PARSER, or an LCD controller." #elif ENABLED(HOME_BEFORE_FILAMENT_CHANGE) && DISABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT) #error "HOME_BEFORE_FILAMENT_CHANGE requires PAUSE_PARK_NO_STEPPER_TIMEOUT." @@ -1026,15 +1028,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Special tool-changing options */ -#if 1 < 0 \ - + ENABLED(SINGLENOZZLE) \ - + ENABLED(DUAL_X_CARRIAGE) \ - + ENABLED(PARKING_EXTRUDER) \ - + ENABLED(MAGNETIC_PARKING_EXTRUDER) \ - + ENABLED(SWITCHING_TOOLHEAD) \ - + ENABLED(MAGNETIC_SWITCHING_TOOLHEAD) \ - + ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) - #error "Please select only one of SINGLENOZZLE, DUAL_X_CARRIAGE, PARKING_EXTRUDER, SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD, or ELECTROMAGNETIC_SWITCHING_TOOLHEAD." +#if MANY(SINGLENOZZLE, DUAL_X_CARRIAGE, PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER, SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD, ELECTROMAGNETIC_SWITCHING_TOOLHEAD) + #error "Please select only one of SINGLENOZZLE, DUAL_X_CARRIAGE, PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER, SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD, or ELECTROMAGNETIC_SWITCHING_TOOLHEAD." #endif /** @@ -1161,16 +1156,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Allow only one kinematic type to be defined */ -#if 1 < 0 \ - + ENABLED(DELTA) \ - + ENABLED(MORGAN_SCARA) \ - + ENABLED(COREXY) \ - + ENABLED(COREXZ) \ - + ENABLED(COREYZ) \ - + ENABLED(COREYX) \ - + ENABLED(COREZX) \ - + ENABLED(COREZY) \ - + ENABLED(MARKFORGED_XY) +#if MANY(DELTA, MORGAN_SCARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY) #error "Please enable only one of DELTA, MORGAN_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, COREZY, or MARKFORGED_XY." #endif @@ -1210,18 +1196,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Allow only one probe option to be defined */ #if 1 < 0 \ - + ENABLED(PROBE_MANUALLY) \ - + ENABLED(FIX_MOUNTED_PROBE) \ - + ENABLED(NOZZLE_AS_PROBE) \ - + (HAS_Z_SERVO_PROBE && DISABLED(BLTOUCH)) \ - + ENABLED(BLTOUCH) && DISABLED(CREALITY_TOUCH) \ - + ENABLED(CREALITY_TOUCH) \ - + ENABLED(TOUCH_MI_PROBE) \ - + ENABLED(SOLENOID_PROBE) \ - + ENABLED(Z_PROBE_ALLEN_KEY) \ - + ENABLED(Z_PROBE_SLED) \ - + ENABLED(RACK_AND_PINION_PROBE) \ - + ENABLED(SENSORLESS_PROBING) + + (DISABLED(BLTOUCH) && HAS_Z_SERVO_PROBE) \ + + (ENABLED(BLTOUCH) && DISABLED(CREALITY_TOUCH)) \ + + COUNT_ENABLED(PROBE_MANUALLY, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, CREALITY_TOUCH, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING) #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or Z Servo." #endif @@ -1391,12 +1368,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Allow only one bed leveling option to be defined */ -#if 1 < 0 \ - + ENABLED(AUTO_BED_LEVELING_LINEAR) \ - + ENABLED(AUTO_BED_LEVELING_3POINT) \ - + ENABLED(AUTO_BED_LEVELING_BILINEAR) \ - + ENABLED(AUTO_BED_LEVELING_UBL) \ - + ENABLED(MESH_BED_LEVELING) +#if MANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING) #error "Select only one of: MESH_BED_LEVELING, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL." #endif @@ -1558,8 +1530,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal /** * ULTIPANEL encoder */ -#if ENABLED(ULTIPANEL) && NONE(NEWPANEL, SR_LCD_2W_NL) && !defined(SHIFT_CLK) - #error "ULTIPANEL requires some kind of encoder." +#if IS_ULTIPANEL && NONE(IS_NEWPANEL, SR_LCD_2W_NL) && !defined(SHIFT_CLK) + #error "ULTIPANEL controllers require some kind of encoder." #endif #if ENCODER_PULSES_PER_STEP < 0 @@ -1845,6 +1817,10 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT." #endif +#if ENABLED(MAX6675_IS_MAX31865) && (!defined(MAX31865_SENSOR_OHMS) || !defined(MAX31865_CALIBRATION_OHMS)) + #error "MAX31865_SENSOR_OHMS and MAX31865_CALIBRATION_OHMS must be set in Configuration.h when using a MAX31865 temperature sensor." +#endif + /** * Test Heater, Temp Sensor, and Extruder Pins */ @@ -2233,89 +2209,100 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal * Make sure only one display is enabled */ #if 1 < 0 \ - + (ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) && DISABLED(IS_RRD_SC)) \ - + (ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && DISABLED(IS_RRD_FG_SC)) \ - + (ENABLED(ULTRA_LCD) && DISABLED(IS_ULTRA_LCD)) \ + + ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) \ + + ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) \ + + ENABLED(ULTIPANEL) \ + + ENABLED(ULTRA_LCD) \ + (ENABLED(U8GLIB_SSD1306) && DISABLED(IS_U8GLIB_SSD1306)) \ + (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)) \ - + ENABLED(RADDS_DISPLAY) \ - + ENABLED(ULTIMAKERCONTROLLER) \ - + ENABLED(PANEL_ONE) \ + + (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \ + + (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \ + + COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \ + + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY) \ + + COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY, DWIN_CREALITY_LCD) \ + + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \ + + COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \ + + COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \ + + COUNT_ENABLED(MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R) \ + + COUNT_ENABLED(TFTGLCD_PANEL_SPI, TFTGLCD_PANEL_I2C) \ + + COUNT_ENABLED(VIKI2, miniVIKI) \ + + COUNT_ENABLED(ZONESTAR_12864LCD, ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) \ + + ENABLED(ANET_FULL_GRAPHICS_LCD) \ + + ENABLED(AZSMZ_12864) \ + + ENABLED(BQ_LCD_SMART_CONTROLLER) \ + + ENABLED(CARTESIO_UI) \ + + ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) \ + + ENABLED(FF_INTERFACEBOARD) \ + + ENABLED(FYSETC_242_OLED_12864) \ + ENABLED(G3D_PANEL) \ - + ENABLED(RIGIDBOT_PANEL) \ - + ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602) \ - + ENABLED(ZONESTAR_LCD) \ - + ENABLED(RA_CONTROL_PANEL) \ - + ENABLED(LCD_SAINSMART_I2C_1602) \ - + ENABLED(LCD_SAINSMART_I2C_2004) \ - + ENABLED(LCM1602) \ + + ENABLED(LCD_FOR_MELZI) \ + ENABLED(LCD_I2C_PANELOLU2) \ + ENABLED(LCD_I2C_VIKI) \ - + ENABLED(SAV_3DLCD) \ - + ENABLED(FF_INTERFACEBOARD) \ - + ENABLED(REPRAPWORLD_GRAPHICAL_LCD) \ - + ENABLED(VIKI2) \ - + ENABLED(miniVIKI) \ + + ENABLED(LCM1602) \ + + ENABLED(LONGER_LK_TFT28) \ + + ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602) \ + ENABLED(MAKRPANEL) \ - + ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) \ - + ENABLED(BQ_LCD_SMART_CONTROLLER) \ - + ENABLED(CARTESIO_UI) \ - + ENABLED(LCD_FOR_MELZI) \ - + ENABLED(ULTI_CONTROLLER) \ + + ENABLED(MALYAN_LCD) \ + ENABLED(MKS_LCD12864) \ - + ENABLED(ENDER2_STOCKDISPLAY) \ - + ENABLED(FYSETC_MINI_12864_X_X) \ - + ENABLED(FYSETC_MINI_12864_1_2) \ - + ENABLED(FYSETC_MINI_12864_2_0) \ - + ENABLED(FYSETC_MINI_12864_2_1) \ - + ENABLED(FYSETC_GENERIC_12864_1_1) \ - + ENABLED(CR10_STOCKDISPLAY) \ - + ENABLED(DWIN_CREALITY_LCD) \ - + ENABLED(ANET_FULL_GRAPHICS_LCD) \ - + ENABLED(AZSMZ_12864) \ - + ENABLED(SILVER_GATE_GLCD_CONTROLLER) \ - + ENABLED(SAV_3DGLCD) \ + ENABLED(OLED_PANEL_TINYBOY2) \ - + ENABLED(MKS_12864OLED) \ - + ENABLED(MKS_12864OLED_SSD1306) \ - + ENABLED(ZONESTAR_12864LCD) \ - + ENABLED(ZONESTAR_12864OLED) \ - + ENABLED(ZONESTAR_12864OLED_SSD1306) \ - + ENABLED(U8GLIB_SH1106_EINSTART) \ + ENABLED(OVERLORD_OLED) \ - + ENABLED(FYSETC_242_OLED_12864) \ - + ENABLED(DGUS_LCD_UI_ORIGIN) \ - + ENABLED(DGUS_LCD_UI_FYSETC) \ - + ENABLED(DGUS_LCD_UI_HIPRECY) \ - + ENABLED(MALYAN_LCD) \ + + ENABLED(PANEL_ONE) \ + + ENABLED(RA_CONTROL_PANEL) \ + + ENABLED(RADDS_DISPLAY) \ + + ENABLED(REPRAPWORLD_GRAPHICAL_LCD) \ + + ENABLED(RIGIDBOT_PANEL) \ + + ENABLED(SAV_3DGLCD) \ + + ENABLED(SAV_3DLCD) \ + + ENABLED(SILVER_GATE_GLCD_CONTROLLER) \ + + ENABLED(TFT_TRONXY_X5SA) \ + ENABLED(TOUCH_UI_FTDI_EVE) \ - + ENABLED(TFT_320x240) \ - + ENABLED(TFT_320x240_SPI) \ - + ENABLED(FSMC_GRAPHICAL_TFT) \ - + ENABLED(TFT_LVGL_UI_FSMC) \ - + ENABLED(TFT_LVGL_UI_SPI) \ - + ENABLED(ANYCUBIC_LCD_I3MEGA) \ - + ENABLED(ANYCUBIC_LCD_CHIRON) \ - + ENABLED(TFTGLCD_PANEL_SPI) \ - + ENABLED(TFTGLCD_PANEL_I2C) + + ENABLED(U8GLIB_SH1106_EINSTART) \ + + ENABLED(ULTI_CONTROLLER) \ + + ENABLED(ULTIMAKERCONTROLLER) \ + + ENABLED(ZONESTAR_LCD) #error "Please select only one LCD controller option." #endif -#undef IS_RRD_SC -#undef IS_RRD_FG_SC -#undef IS_ULTRA_LCD #undef IS_U8GLIB_SSD1306 -#undef IS_RRW_KEYPAD #undef IS_EXTUI -#undef IS_ULTIPANEL +#undef IS_LEGACY_TFT + +#if ANY(TFT_GENERIC, MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, TFT_TRONXY_X5SA, ANYCUBIC_TFT35, ANYCUBIC_TFT35, LONGER_LK_TFT28) + #if NONE(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI) + #error "TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI is required for your TFT. Please enable one." + #elif 1 < ENABLED(TFT_COLOR_UI) + ENABLED(TFT_CLASSIC_UI) + ENABLED(TFT_LVGL_UI) + #error "Please select only one of TFT_COLOR_UI, TFT_CLASSIC_UI, or TFT_LVGL_UI." + #endif +#elif ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI) + #error "TFT_(COLOR|CLASSIC|LVGL)_UI requires a TFT display to be enabled." +#endif + +#if ENABLED(TFT_GENERIC) && NONE(TFT_INTERFACE_FSMC, TFT_INTERFACE_SPI) + #error "TFT_GENERIC requires either TFT_INTERFACE_FSMC or TFT_INTERFACE_SPI interface." +#endif + +#if BOTH(TFT_INTERFACE_FSMC, TFT_INTERFACE_SPI) + #error "Please enable only one of TFT_INTERFACE_SPI or TFT_INTERFACE_SPI." +#endif -#if 1 < ENABLED(LCD_SCREEN_ROT_0) + ENABLED(LCD_SCREEN_ROT_90) + ENABLED(LCD_SCREEN_ROT_180) + ENABLED(LCD_SCREEN_ROT_270) +#if MANY(LCD_SCREEN_ROT_0, LCD_SCREEN_ROT_90, LCD_SCREEN_ROT_180, LCD_SCREEN_ROT_270) #error "Please enable only one LCD_SCREEN_ROT_* option: 0, 90, 180, or 270." #endif +#if MANY(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320) + #error "Please select only one of TFT_RES_480x320, TFT_RES_480x320, or TFT_RES_480x272." +#endif + +#if HAS_TFT_LVGL_UI && DISABLED(TFT_RES_480x320) + #error "(FMSC|SPI)TFT_LVGL_UI requires TFT_RES_480x320." +#endif + +#if defined(GRAPHICAL_TFT_UPSCALE) && !WITHIN(GRAPHICAL_TFT_UPSCALE, 2, 3) + #error "GRAPHICAL_TFT_UPSCALE must be set to 2 or 3." +#endif + /** * Serial displays require a dedicated serial port */ @@ -2667,7 +2654,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal /** * Digipot requirement */ -#if HAS_I2C_DIGIPOT +#if HAS_MOTOR_CURRENT_I2C #if BOTH(DIGIPOT_MCP4018, DIGIPOT_MCP4451) #error "Enable only one of DIGIPOT_MCP4018 or DIGIPOT_MCP4451." #elif !MB(MKS_SBASE) \ @@ -2752,7 +2739,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #error "BLOCK_BUFFER_SIZE must be a power of 2." #endif -#if ENABLED(LED_CONTROL_MENU) && DISABLED(ULTIPANEL) +#if ENABLED(LED_CONTROL_MENU) && !IS_ULTIPANEL #error "LED_CONTROL_MENU requires an LCD controller." #endif @@ -2788,6 +2775,25 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #endif #endif +#if ENABLED(MECHANICAL_GANTRY_CALIBRATION) + #if NONE(HAS_MOTOR_CURRENT_DAC, HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC, HAS_TRINAMIC_CONFIG, HAS_MOTOR_CURRENT_PWM) + #error "It is highly recommended to have adjustable current drivers to prevent damage. Disable this line to continue anyway." + #elif !defined(GANTRY_CALIBRATION_CURRENT) + #error "MECHANICAL_GANTRY_CALIBRATION Requires GANTRY_CALIBRATION_CURRENT to be set." + #elif !defined(GANTRY_CALIBRATION_EXTRA_HEIGHT) + #error "MECHANICAL_GANTRY_CALIBRATION Requires GANTRY_CALIBRATION_EXTRA_HEIGHT to be set." + #elif !defined(GANTRY_CALIBRATION_FEEDRATE) + #error "MECHANICAL_GANTRY_CALIBRATION Requires GANTRY_CALIBRATION_FEEDRATE to be set." + #endif + #if defined(GANTRY_CALIBRATION_SAFE_POSITION) && !defined(GANTRY_CALIBRATION_XY_PARK_FEEDRATE) + #error "GANTRY_CALIBRATION_SAFE_POSITION Requires GANTRY_CALIBRATION_XY_PARK_FEEDRATE to be set." + #endif +#endif + +#if BOTH(Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION) + #error "You cannot use Z_STEPPER_AUTO_ALIGN and MECHANICAL_GANTRY_CALIBRATION at the same time." +#endif + #if ENABLED(PRINTCOUNTER) && DISABLED(EEPROM_SETTINGS) #error "PRINTCOUNTER requires EEPROM_SETTINGS. Please update your Configuration." #endif diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 274659c48b17..c64cd805fec9 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-10-10" + #define STRING_DISTRIBUTION_DATE "2020-10-17" #endif /** @@ -52,7 +52,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 020007 +#define MARLIN_HEX_VERSION 020008 #ifndef REQUIRED_CONFIGURATION_H_VERSION #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION #endif diff --git a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index aa3c3c04a123..8aca19b0cd9e 100644 --- a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -16,10 +16,10 @@ #if HAS_MARLINUI_HD44780 -#include "../ultralcd.h" +#include "../marlinui.h" #include "../../MarlinCore.h" -#include "ultralcd_HD44780.h" +#include "marlinui_HD44780.h" #include diff --git a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp similarity index 99% rename from Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp rename to Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index e6cc22746571..3c7993e375e9 100644 --- a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -25,14 +25,14 @@ #if HAS_MARLINUI_HD44780 /** - * ultralcd_HD44780.cpp + * marlinui_HD44780.cpp * * LCD display implementations for Hitachi HD44780. * These are the most common LCD character displays. */ -#include "ultralcd_HD44780.h" -#include "../ultralcd.h" +#include "marlinui_HD44780.h" +#include "../marlinui.h" #include "../../libs/numtostr.h" #include "../../sd/cardreader.h" diff --git a/Marlin/src/lcd/HD44780/ultralcd_HD44780.h b/Marlin/src/lcd/HD44780/marlinui_HD44780.h similarity index 100% rename from Marlin/src/lcd/HD44780/ultralcd_HD44780.h rename to Marlin/src/lcd/HD44780/marlinui_HD44780.h diff --git a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp index 51681a800953..dddab1f259f5 100644 --- a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp @@ -37,11 +37,11 @@ #if IS_TFTGLCD_PANEL -#include "../ultralcd.h" +#include "../marlinui.h" #include "../../MarlinCore.h" #include "../../libs/numtostr.h" -#include "ultralcd_TFTGLCD.h" +#include "marlinui_TFTGLCD.h" #include diff --git a/Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp similarity index 99% rename from Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp rename to Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index b5789091dc2f..83ebe111ae3d 100644 --- a/Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -25,10 +25,10 @@ #if IS_TFTGLCD_PANEL /** - * ultralcd_TFTGLCD.cpp + * marlinui_TFTGLCD.cpp * * Implementation of the LCD display routines for a TFT GLCD displays with external controller. - * This display looks as a REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER but has good text font + * This display looks like a REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER but has good text font * and supports color output. */ @@ -42,8 +42,8 @@ #include #endif -#include "ultralcd_TFTGLCD.h" -#include "../ultralcd.h" +#include "marlinui_TFTGLCD.h" +#include "../marlinui.h" #include "../../libs/numtostr.h" #include "../../sd/cardreader.h" diff --git a/Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.h b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.h similarity index 100% rename from Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.h rename to Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.h diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index da7d4f6f1ec0..535502f2e1a6 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -112,7 +112,7 @@ #ifndef U8G_COM_SSD_I2C_HAL #define U8G_COM_SSD_I2C_HAL u8g_com_null_fn #endif -#if EITHER(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT) +#if HAS_FSMC_GRAPHICAL_TFT || HAS_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 diff --git a/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin/src/lcd/dogm/dogm_Statusscreen.h index 70802f905e1d..e76b7da59834 100644 --- a/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -29,7 +29,7 @@ */ #include "../../inc/MarlinConfig.h" -#include "ultralcd_DOGM.h" +#include "marlinui_DOGM.h" #define BW(N) ((N + 7) / 8) @@ -1341,7 +1341,7 @@ #undef STATUS_LOGO_WIDTH #endif - #if (HAS_MULTI_HOTEND && STATUS_LOGO_WIDTH && BED_OR_CHAMBER_OR_FAN) || (HOTENDS >= 3 && !BED_OR_CHAMBER_OR_FAN) + #if !defined(STATUS_HEATERS_X) && ((HAS_MULTI_HOTEND && STATUS_LOGO_WIDTH && BED_OR_CHAMBER_OR_FAN) || (HOTENDS >= 3 && !BED_OR_CHAMBER_OR_FAN)) #define _STATUS_HEATERS_X(H,S,N) ((LCD_PIXEL_WIDTH - (H * (S + N)) - (_EXTRA_WIDTH) + (STATUS_LOGO_WIDTH)) / 2) #if STATUS_HOTEND1_WIDTH #if HOTENDS > 2 diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp index a6bdb373dd70..a85dc9f97911 100644 --- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp +++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp @@ -11,9 +11,9 @@ #if HAS_MARLINUI_U8GLIB -#include "ultralcd_DOGM.h" +#include "marlinui_DOGM.h" -#include "../ultralcd.h" +#include "../marlinui.h" #include "../../MarlinCore.h" #include "../fontutils.h" diff --git a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp similarity index 99% rename from Marlin/src/lcd/dogm/ultralcd_DOGM.cpp rename to Marlin/src/lcd/dogm/marlinui_DOGM.cpp index c48abac81016..53a20476e9c5 100644 --- a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -21,7 +21,7 @@ */ /** - * lcd/dogm/ultralcd_DOGM.h + * lcd/dogm/marlinui_DOGM.h * * Implementation of the LCD display routines for a DOGM128 graphic display. * by STB for ErikZalm/Marlin. Common LCD 128x64 pixel graphic displays. @@ -39,7 +39,7 @@ #if HAS_MARLINUI_U8GLIB -#include "ultralcd_DOGM.h" +#include "marlinui_DOGM.h" #include "u8g_fontutf8.h" #if ENABLED(SHOW_BOOTSCREEN) @@ -49,7 +49,7 @@ #include "../lcdprint.h" #include "../fontutils.h" #include "../../libs/numtostr.h" -#include "../ultralcd.h" +#include "../marlinui.h" #include "../../sd/cardreader.h" #include "../../module/temperature.h" diff --git a/Marlin/src/lcd/dogm/ultralcd_DOGM.h b/Marlin/src/lcd/dogm/marlinui_DOGM.h similarity index 99% rename from Marlin/src/lcd/dogm/ultralcd_DOGM.h rename to Marlin/src/lcd/dogm/marlinui_DOGM.h index 228cee6848b4..29a1b7d3cff5 100644 --- a/Marlin/src/lcd/dogm/ultralcd_DOGM.h +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.h @@ -22,7 +22,7 @@ #pragma once /** - * lcd/dogm/ultralcd_DOGM.h + * lcd/dogm/marlinui_DOGM.h */ #include "../../inc/MarlinConfigPre.h" @@ -189,7 +189,7 @@ // Unspecified 320x240 TFT pre-initialized by built-in bootloader #define U8G_CLASS U8GLIB_TFT_320X240_UPSCALE_FROM_128X64 - #if ENABLED(FSMC_GRAPHICAL_TFT) + #if HAS_FSMC_GRAPHICAL_TFT #define U8G_PARAM FSMC_CS_PIN, FSMC_RS_PIN #else #define U8G_PARAM -1, -1 diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 987924201a80..d07474d810e3 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -30,8 +30,8 @@ #if HAS_MARLINUI_U8GLIB && DISABLED(LIGHTWEIGHT_UI) #include "dogm_Statusscreen.h" -#include "ultralcd_DOGM.h" -#include "../ultralcd.h" +#include "marlinui_DOGM.h" +#include "../marlinui.h" #include "../lcdprint.h" #include "../../libs/numtostr.h" diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index 806f370db327..c06080f601bb 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -46,7 +46,7 @@ #include "status_screen_lite_ST7920.h" -#include "../ultralcd.h" +#include "../marlinui.h" #include "../fontutils.h" #include "../lcdprint.h" #include "../../libs/duration_t.h" diff --git a/Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp b/Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp index 740436d93c07..c745f971dc1f 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp @@ -201,7 +201,7 @@ u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi = { u8g_dev_st7920_128x64_HAL_4x_f #if NONE(__AVR__, ARDUINO_ARCH_STM32, ARDUINO_ARCH_ESP32) || defined(U8G_HAL_LINKS) // Also use this device for HAL version of rrd class. This results in the same device being used - // for the ST7920 for HAL systems no matter what is selected in ultralcd_impl_DOGM.h. + // for the ST7920 for HAL systems no matter what is selected in marlinui_DOGM.h. u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = { u8g_dev_st7920_128x64_HAL_4x_fn, &u8g_dev_st7920_128x64_HAL_4x_pb, U8G_COM_ST7920_HAL_SW_SPI }; #endif diff --git a/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp similarity index 59% rename from Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp rename to Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp index 0f53e45a27b5..2599b1ad2267 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp @@ -55,10 +55,10 @@ #include "../../inc/MarlinConfig.h" -#if HAS_MARLINUI_U8GLIB && (PIN_EXISTS(FSMC_CS) || ENABLED(SPI_GRAPHICAL_TFT)) +#if HAS_MARLINUI_U8GLIB && (PIN_EXISTS(FSMC_CS) || HAS_SPI_GRAPHICAL_TFT) #include "HAL_LCD_com_defines.h" -#include "ultralcd_DOGM.h" +#include "marlinui_DOGM.h" #include @@ -66,12 +66,7 @@ #define HAS_LCD_IO 1 #endif -#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 - +#include "../tft_io/tft_io.h" TFT_IO tftio; #define WIDTH LCD_PIXEL_WIDTH @@ -132,299 +127,10 @@ TFT_IO tftio; #define TFT_BTOKMENU_COLOR COLOR_RED #endif -static uint32_t lcd_id = 0; - -#define ST7789V_CASET 0x2A /* Column address register */ -#define ST7789V_RASET 0x2B /* Row address register */ -#define ST7789V_WRITE_RAM 0x2C /* Write data to GRAM */ - - -/* Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X */ -#define ILI9328_HASET 0x20 /* Horizontal GRAM address register (0-255) */ -#define ILI9328_VASET 0x21 /* Vertical GRAM address register (0-511)*/ -#define ILI9328_WRITE_RAM 0x22 /* Write data to GRAM */ - -#define ILI9328_HASTART 0x50 /* Horizontal address start position (0-255) */ -#define ILI9328_HAEND 0x51 /* Horizontal address end position (0-255) */ -#define ILI9328_VASTART 0x52 /* Vertical address start position (0-511) */ -#define ILI9328_VAEND 0x53 /* Vertical address end position (0-511) */ - -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 - 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 - - #if NONE(LCD_USE_DMA_FSMC, LCD_USE_DMA_SPI) - u8g_SetAddress(u8g, dev, 0); - #endif - - IO_REG_DATA(ILI9328_HASTART, Ymin); - IO_REG_DATA(ILI9328_HAEND, Ymax); - IO_REG_DATA(ILI9328_VASTART, Xmin); - IO_REG_DATA(ILI9328_VAEND, Xmax); - - IO_REG_DATA(ILI9328_HASET, Ymin); - IO_REG_DATA(ILI9328_VASET, Xmin); - - #if HAS_LCD_IO - tftio.WriteReg(ILI9328_WRITE_RAM); - tftio.DataTransferEnd(); - #else - u8g_WriteByte(u8g, dev, ILI9328_WRITE_RAM); - u8g_SetAddress(u8g, dev, 1); - #endif -} - -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 - 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); - u8g_WriteByte(u8g, dev, Xmin & 0xFF); - u8g_WriteByte(u8g, dev, (Xmax >> 8) & 0xFF); - u8g_WriteByte(u8g, dev, Xmax & 0xFF); - - u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_RASET); u8g_SetAddress(u8g, dev, 1); - u8g_WriteByte(u8g, dev, (Ymin >> 8) & 0xFF); - u8g_WriteByte(u8g, dev, Ymin & 0xFF); - u8g_WriteByte(u8g, dev, (Ymax >> 8) & 0xFF); - u8g_WriteByte(u8g, dev, Ymax & 0xFF); - - u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_WRITE_RAM); u8g_SetAddress(u8g, dev, 1); - #endif +static void setWindow(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { + tftio.set_window(Xmin, Ymin, Xmax, Ymax); } -static void setWindow_none(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {} -void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) = setWindow_none; - -#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x -#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF) -#define ESC_END 0xFFFF, 0x7FFF -#define ESC_FFFF 0xFFFF, 0xFFFF - -#if HAS_LCD_IO - void writeEscSequence(const uint16_t *sequence) { - uint16_t data; - for (;;) { - data = *sequence++; - if (data != 0xFFFF) { - tftio.WriteData(data); - continue; - } - data = *sequence++; - if (data == 0x7FFF) return; - if (data == 0xFFFF) { - tftio.WriteData(data); - } else if (data & 0x8000) { - delay(data & 0x7FFF); - } else if ((data & 0xFF00) == 0) { - tftio.WriteReg(data); - } - } - } - #define WRITE_ESC_SEQUENCE(V) writeEscSequence(V) - #define WRITE_ESC_SEQUENCE16(V) writeEscSequence(V) -#else - void writeEscSequence8(u8g_t *u8g, u8g_dev_t *dev, const uint16_t *sequence) { - uint16_t data; - u8g_SetAddress(u8g, dev, 1); - for (;;) { - data = *sequence++; - if (data != 0xFFFF) { - u8g_WriteByte(u8g, dev, data & 0xFF); - continue; - } - data = *sequence++; - if (data == 0x7FFF) return; - if (data == 0xFFFF) { - u8g_WriteByte(u8g, dev, data & 0xFF); - } else if (data & 0x8000) { - delay(data & 0x7FFF); - } else if ((data & 0xFF00) == 0) { - u8g_SetAddress(u8g, dev, 0); - u8g_WriteByte(u8g, dev, data & 0xFF); - u8g_SetAddress(u8g, dev, 1); - } - } - } - - #define WRITE_ESC_SEQUENCE(V) writeEscSequence8(u8g, dev, V) - - void writeEscSequence16(u8g_t *u8g, u8g_dev_t *dev, const uint16_t *sequence) { - uint16_t data; - u8g_SetAddress(u8g, dev, 0); - for (;;) { - data = *sequence++; - if (data != 0xFFFF) { - u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&data); - continue; - } - data = *sequence++; - if (data == 0x7FFF) return; - if (data == 0xFFFF) { - u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&data); - } else if (data & 0x8000) { - delay(data & 0x7FFF); - } else if ((data & 0xFF00) == 0) { - u8g_WriteByte(u8g, dev, data & 0xFF); - } - } - u8g_SetAddress(u8g, dev, 1); - } - - #define WRITE_ESC_SEQUENCE16(V) writeEscSequence16(u8g, dev, V) -#endif - -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), 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, - ESC_REG(0x00B2), 0x000C, 0x000C, 0x0000, 0x0033, 0x0033, - ESC_REG(0x00B7), 0x0035, - ESC_REG(0x00BB), 0x001F, - ESC_REG(0x00C0), 0x002C, - ESC_REG(0x00C2), 0x0001, 0x00C3, - ESC_REG(0x00C4), 0x0020, - ESC_REG(0x00C6), 0x000F, - ESC_REG(0x00D0), 0x00A4, 0x00A1, - ESC_REG(0x0029), - ESC_REG(0x0011), - ESC_END -}; - -static const uint16_t ili9328_init[] = { - ESC_REG(0x0001), 0x0100, - ESC_REG(0x0002), 0x0400, - ESC_REG(0x0003), 0x1038, - ESC_REG(0x0004), 0x0000, - ESC_REG(0x0008), 0x0202, - ESC_REG(0x0009), 0x0000, - ESC_REG(0x000A), 0x0000, - ESC_REG(0x000C), 0x0000, - ESC_REG(0x000D), 0x0000, - ESC_REG(0x000F), 0x0000, - ESC_REG(0x0010), 0x0000, - ESC_REG(0x0011), 0x0007, - ESC_REG(0x0012), 0x0000, - ESC_REG(0x0013), 0x0000, - ESC_REG(0x0007), 0x0001, - ESC_DELAY(200), - ESC_REG(0x0010), 0x1690, - ESC_REG(0x0011), 0x0227, - ESC_DELAY(50), - ESC_REG(0x0012), 0x008C, - ESC_DELAY(50), - ESC_REG(0x0013), 0x1500, - ESC_REG(0x0029), 0x0004, - ESC_REG(0x002B), 0x000D, - ESC_DELAY(50), - ESC_REG(0x0050), 0x0000, - ESC_REG(0x0051), 0x00EF, - ESC_REG(0x0052), 0x0000, - ESC_REG(0x0053), 0x013F, - ESC_REG(0x0020), 0x0000, - ESC_REG(0x0021), 0x0000, - ESC_REG(0x0060), 0x2700, - ESC_REG(0x0061), 0x0001, - ESC_REG(0x006A), 0x0000, - ESC_REG(0x0080), 0x0000, - ESC_REG(0x0081), 0x0000, - ESC_REG(0x0082), 0x0000, - ESC_REG(0x0083), 0x0000, - ESC_REG(0x0084), 0x0000, - ESC_REG(0x0085), 0x0000, - ESC_REG(0x0090), 0x0010, - ESC_REG(0x0092), 0x0600, - ESC_REG(0x0007), 0x0133, - ESC_REG(0x0022), - ESC_END -}; - -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, 0x0028, 0x00E8), - ESC_REG(0x003A), 0x0055, - ESC_REG(0x002A), 0x0000, 0x0000, 0x0001, 0x003F, - ESC_REG(0x002B), 0x0000, 0x0000, 0x0000, 0x00EF, - ESC_REG(0x00C5), 0x003E, 0x0028, - ESC_REG(0x00C7), 0x0086, - ESC_REG(0x00B1), 0x0000, 0x0018, - ESC_REG(0x00C0), 0x0023, - ESC_REG(0x00C1), 0x0010, - ESC_REG(0x0029), - ESC_REG(0x0011), - ESC_DELAY(100), - ESC_END -}; - -static const uint16_t ili9488_init[] = { - ESC_REG(0x00E0), 0x0000, 0x0007, 0x000F, 0x000D, 0x001B, 0x000A, 0x003C, 0x0078, 0x004A, 0x0007, 0x000E, 0x0009, 0x001B, 0x001E, 0x000F, - ESC_REG(0x00E1), 0x0000, 0x0022, 0x0024, 0x0006, 0x0012, 0x0007, 0x0036, 0x0047, 0x0047, 0x0006, 0x000A, 0x0007, 0x0030, 0x0037, 0x000F, - ESC_REG(0x00C0), 0x0010, 0x0010, - ESC_REG(0x00C1), 0x0041, - ESC_REG(0x00C5), 0x0000, 0x0022, 0x0080, - ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x00A8, 0x0068), - ESC_REG(0x003A), 0x0055, - ESC_REG(0x00B0), 0x0000, - ESC_REG(0x00B1), 0x00B0, 0x0011, - ESC_REG(0x00B4), 0x0002, - ESC_REG(0x00B6), 0x0002, 0x0042, - ESC_REG(0x00B7), 0x00C6, - ESC_REG(0x00E9), 0x0000, - ESC_REG(0x00F0), 0x00A9, 0x0051, 0x002C, 0x0082, - ESC_REG(0x0029), - ESC_REG(0x0011), - ESC_DELAY(100), - ESC_END -}; - -static const uint16_t st7796_init[] = { - ESC_REG(0x0010), ESC_DELAY(120), - ESC_REG(0x0001), ESC_DELAY(120), - ESC_REG(0x0011), ESC_DELAY(120), - ESC_REG(0x00F0), 0x00C3, - ESC_REG(0x00F0), 0x0096, - ESC_REG(0x0036), TERN(GRAPHICAL_TFT_ROTATE_180, 0x00E8, 0x0028), - ESC_REG(0x003A), 0x0055, - ESC_REG(0x00B4), 0x0001, - ESC_REG(0x00B7), 0x00C6, - ESC_REG(0x00E8), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033, - ESC_REG(0x00C1), 0x0006, - ESC_REG(0x00C2), 0x00A7, - ESC_REG(0x00C5), 0x0018, - ESC_REG(0x00E0), 0x00F0, 0x0009, 0x000B, 0x0006, 0x0004, 0x0015, 0x002F, 0x0054, 0x0042, 0x003C, 0x0017, 0x0014, 0x0018, 0x001B, - ESC_REG(0x00E1), 0x00F0, 0x0009, 0x000B, 0x0006, 0x0004, 0x0003, 0x002D, 0x0043, 0x0042, 0x003B, 0x0016, 0x0014, 0x0017, 0x001B, - ESC_REG(0x00F0), 0x003C, - ESC_REG(0x00F0), 0x0069, ESC_DELAY(120), - ESC_REG(0x0029), - ESC_REG(0x0011), - ESC_DELAY(100), - ESC_END -}; - #if HAS_TOUCH_XPT2046 static const uint8_t buttonD[] = { @@ -640,43 +346,9 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u 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); - setWindow = setWindow_st7789v; - break; - case 0x9328: // ILI9328 - WRITE_ESC_SEQUENCE16(ili9328_init); - 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; - break; - case 0x7796: - WRITE_ESC_SEQUENCE(st7796_init); - setWindow = setWindow_st7789v; - break; - case 0x9488: - WRITE_ESC_SEQUENCE(ili9488_init); - setWindow = setWindow_st7789v; - case 0x0404: // No connected display on FSMC - lcd_id = 0; - return 0; - case 0xFFFF: // No connected display on SPI - lcd_id = 0; - return 0; - default: - setWindow = (lcd_id & 0xFF000000) ? setWindow_st7789v : setWindow_ili9328; - break; - } - tftio.DataTransferEnd(); + dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, NULL); + tftio.Init(); + tftio.InitTFT(); if (preinit) { preinit = false; @@ -771,14 +443,7 @@ uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_p 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; @@ -812,4 +477,4 @@ uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_p 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_MARLINUI_U8GLIB && FSMC_CS +#endif // HAS_MARLINUI_U8GLIB && (FSMC_CS_PIN || HAS_SPI_GRAPHICAL_TFT) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 28087497371f..45704d5724f8 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -47,7 +47,7 @@ #include #include "../../fontutils.h" -#include "../../ultralcd.h" +#include "../../marlinui.h" #include "../../../sd/cardreader.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp index 3beed892e35b..e2f2fd934695 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp @@ -35,7 +35,7 @@ #include "../../../../../module/planner.h" #include "../../../ui_api.h" -#include "../../../../ultralcd.h" +#include "../../../../marlinui.h" #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) uint16_t distanceToMove = 10; diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp index 82c06d7a4afb..ed26cac3c503 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp @@ -35,7 +35,7 @@ #include "../../../../../module/planner.h" #include "../../../ui_api.h" -#include "../../../../ultralcd.h" +#include "../../../../marlinui.h" #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) uint16_t distanceToMove = 10; diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp index f9d4351e02d9..46e542a9598a 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp @@ -34,7 +34,7 @@ #include "../../../../../module/motion.h" #include "../../../../../module/planner.h" -#include "../../../../ultralcd.h" +#include "../../../../marlinui.h" #include "../../../ui_api.h" #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) 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 351d033d01ec..394ce4807572 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp @@ -22,7 +22,7 @@ #include "../../../../inc/MarlinConfigPre.h" -#if ENABLED(TFT_LVGL_UI_SPI) +#if HAS_TFT_LVGL_UI #include "SPI_TFT.h" #include "pic_manager.h" @@ -32,6 +32,8 @@ #include +#include "draw_ui.h" + TFT SPI_TFT; // use SPI1 for the spi tft. @@ -39,142 +41,48 @@ void TFT::spi_init(uint8_t spiRate) { tftio.Init(); } -void TFT::LCD_WR_REG(uint8_t cmd) { - tftio.WriteReg(cmd); -} - -void TFT::LCD_WR_DATA(uint8_t data) { - tftio.WriteData(data); -} - void TFT::SetPoint(uint16_t x, uint16_t y, uint16_t point) { if ((x > 480) || (y > 320)) return; - SetWindows(x, y, 1, 1); + setWindow(x, y, 1, 1); tftio.WriteMultiple(point, (uint16_t)1); } -void TFT::SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height) { - tftio.DataTransferBegin(DATASIZE_8BIT); - - LCD_WR_REG(0x2A); - LCD_WR_DATA(x >> 8); - LCD_WR_DATA(x); - LCD_WR_DATA((x + with - 1) >> 8); - LCD_WR_DATA((x + with - 1)); - - LCD_WR_REG(0x2B); - LCD_WR_DATA(y >> 8); - LCD_WR_DATA(y); - LCD_WR_DATA((y + height - 1) >> 8); - LCD_WR_DATA(y + height - 1); - - LCD_WR_REG(0X2C); - - tftio.DataTransferEnd(); +void TFT::setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height) { + tftio.set_window(x, y, (x + with - 1), (y + height - 1)); } void TFT::LCD_init() { - TFT_BLK_L; - TFT_RST_H; - delay(150); - TFT_RST_L; - delay(150); - TFT_RST_H; - - tftio.DataTransferBegin(DATASIZE_8BIT); - - delay(120); - LCD_WR_REG(0x11); - delay(120); - - LCD_WR_REG(0xF0); - LCD_WR_DATA(0xC3); - LCD_WR_REG(0xF0); - LCD_WR_DATA(0x96); - - LCD_WR_REG(0x36); - LCD_WR_DATA(0x28 + TERN0(GRAPHICAL_TFT_ROTATE_180, 0x80)); - LCD_WR_REG(0x3A); - LCD_WR_DATA(0x55); - - LCD_WR_REG(0xB4); - LCD_WR_DATA(0x01); - LCD_WR_REG(0xB7); - LCD_WR_DATA(0xC6); - LCD_WR_REG(0xE8); - LCD_WR_DATA(0x40); - LCD_WR_DATA(0x8A); - LCD_WR_DATA(0x00); - LCD_WR_DATA(0x00); - LCD_WR_DATA(0x29); - LCD_WR_DATA(0x19); - LCD_WR_DATA(0xA5); - LCD_WR_DATA(0x33); - LCD_WR_REG(0xC1); - LCD_WR_DATA(0x06); - LCD_WR_REG(0xC2); - LCD_WR_DATA(0xA7); - LCD_WR_REG(0xC5); - LCD_WR_DATA(0x18); - LCD_WR_REG(0xE0); // Positive Voltage Gamma Control - LCD_WR_DATA(0xF0); - LCD_WR_DATA(0x09); - LCD_WR_DATA(0x0B); - LCD_WR_DATA(0x06); - LCD_WR_DATA(0x04); - LCD_WR_DATA(0x15); - LCD_WR_DATA(0x2F); - LCD_WR_DATA(0x54); - LCD_WR_DATA(0x42); - LCD_WR_DATA(0x3C); - LCD_WR_DATA(0x17); - LCD_WR_DATA(0x14); - LCD_WR_DATA(0x18); - LCD_WR_DATA(0x1B); - LCD_WR_REG(0xE1); // Negative Voltage Gamma Control - LCD_WR_DATA(0xF0); - LCD_WR_DATA(0x09); - LCD_WR_DATA(0x0B); - LCD_WR_DATA(0x06); - LCD_WR_DATA(0x04); - LCD_WR_DATA(0x03); - LCD_WR_DATA(0x2D); - LCD_WR_DATA(0x43); - LCD_WR_DATA(0x42); - LCD_WR_DATA(0x3B); - LCD_WR_DATA(0x16); - LCD_WR_DATA(0x14); - LCD_WR_DATA(0x17); - LCD_WR_DATA(0x1B); - LCD_WR_REG(0xF0); - LCD_WR_DATA(0x3C); - LCD_WR_REG(0xF0); - LCD_WR_DATA(0x69); - delay(120); // Delay 120ms - LCD_WR_REG(0x29); // Display ON - - tftio.DataTransferEnd(); - - LCD_clear(0x0000); // + tftio.InitTFT(); + #if PIN_EXISTS(TFT_BACKLIGHT) + OUT_WRITE(TFT_BACKLIGHT_PIN, LOW); + #endif + delay(100); + LCD_clear(0x0000); LCD_Draw_Logo(); - TFT_BLK_H; - delay(2000); + #if PIN_EXISTS(TFT_BACKLIGHT) + OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH); + #endif + #if HAS_LOGO_IN_FLASH + delay(2000); + #endif } void TFT::LCD_clear(uint16_t color) { - SetWindows(0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1); + setWindow(0, 0, (TFT_WIDTH), (TFT_HEIGHT)); 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, 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); - } + #if HAS_LOGO_IN_FLASH + setWindow(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); + } + #endif } -#endif // HAS_TFT_LVGL_UI_SPI +#endif // HAS_TFT_LVGL_UI 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 e40039fe8649..696bc16974be 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h @@ -23,29 +23,21 @@ #include "../../inc/MarlinConfigPre.h" -#if ENABLED(TFT_LVGL_UI_SPI) - #include HAL_PATH(../../HAL, tft/tft_spi.h) -#elif ENABLED(TFT_LVGL_UI_FSMC) - #include HAL_PATH(../../HAL, tft/tft_fsmc.h) -#endif +#if HAS_TFT_LVGL_UI -#define TFT_RST_H OUT_WRITE(TFT_RESET_PIN, HIGH) -#define TFT_RST_L OUT_WRITE(TFT_RESET_PIN, LOW) - -#define TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH) -#define TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW) +#include "../../../tft_io/tft_io.h" class TFT { public: TFT_IO tftio; void spi_init(uint8_t spiRate); - void LCD_WR_REG(uint8_t cmd); - void LCD_WR_DATA(uint8_t data); void SetPoint(uint16_t x, uint16_t y, uint16_t point); - void SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height); + void setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height); void LCD_init(); void LCD_clear(uint16_t color); void LCD_Draw_Logo(); }; extern TFT SPI_TFT; + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp index 1bcdccda414a..c21ee3612c3a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp @@ -23,9 +23,7 @@ #if HAS_TFT_LVGL_UI -#if ENABLED(TFT_LVGL_UI_SPI) - #include "SPI_TFT.h" -#endif +#include "SPI_TFT.h" #include "lv_conf.h" #include "draw_ui.h" @@ -77,7 +75,7 @@ void lv_draw_error_message(PGM_P const msg) { lv_task_handler(); #endif - TERN(TFT_LVGL_UI_SPI, SPI_TFT.LCD_clear, LCD_Clear)(0x0000); + SPI_TFT.LCD_clear(0x0000); if (msg) disp_string((TFT_WIDTH - strlen(msg) * 16) / 2, 100, msg, 0xFFFF, 0x0000); disp_string((TFT_WIDTH - strlen("PRINTER HALTED") * 16) / 2, 140, "PRINTER HALTED", 0xFFFF, 0x0000); disp_string((TFT_WIDTH - strlen("Please Reset") * 16) / 2, 180, "Please Reset", 0xFFFF, 0x0000); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp index 6d7b68af42a7..e84bb395e098 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp @@ -520,7 +520,7 @@ void lv_gcode_file_read(uint8_t *data_buf) { j = 0; ignore_start = false; } - #if ENABLED(TFT_LVGL_UI_SPI) + #if HAS_TFT_LVGL_UI_SPI for (i = 0; i < 200;) { p_index = (uint16_t *)(&public_buf[i]); @@ -529,7 +529,7 @@ void lv_gcode_file_read(uint8_t *data_buf) { i += 2; if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; } - #else + #else // !HAS_TFT_LVGL_UI_SPI for (i = 0; i < 200;) { p_index = (uint16_t *)(&public_buf[i]); //Color = (*p_index >> 8); @@ -537,7 +537,7 @@ void lv_gcode_file_read(uint8_t *data_buf) { i += 2; if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; // 0x18C3; } - #endif // TFT_LVGL_UI_SPI + #endif // !HAS_TFT_LVGL_UI_SPI memcpy(data_buf, public_buf, 200); #endif // SDSUPPORT } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index a81b5b851bb3..0b49bf4ab79d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -41,12 +41,13 @@ #include "../../../../feature/powerloss.h" #endif #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) - #include "../../../ultralcd.h" + #include "../../../marlinui.h" #endif extern lv_group_t * g; static lv_obj_t * scr; -static lv_obj_t *labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime; +static lv_obj_t *labelExt1, * labelFan, * labelZpos, * labelTime; +TERN_(HAS_MULTI_EXTRUDER, static lv_obj_t *labelExt2;) static lv_obj_t *labelPause, * labelStop, * labelOperat; static lv_obj_t * bar1, *bar1ValueText; static lv_obj_t * buttonPause, *buttonOperat, *buttonStop; @@ -137,9 +138,6 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } void lv_draw_printing(void) { - lv_obj_t *buttonExt1, *buttonExt2, *buttonFanstate, *buttonZpos, *buttonTime; - TERN_(HAS_HEATED_BED, lv_obj_t * buttonBedstate); - disp_state_stack._disp_index = 0; ZERO(disp_state_stack._disp_state); disp_state_stack._disp_state[disp_state_stack._disp_index] = PRINTING_UI; @@ -162,16 +160,16 @@ void lv_draw_printing(void) { lv_refr_now(lv_refr_get_disp_refreshing()); // Create image buttons - buttonExt1 = lv_img_create(scr, NULL); + lv_obj_t *buttonExt1 = lv_img_create(scr, NULL); #if HAS_MULTI_EXTRUDER - buttonExt2 = lv_img_create(scr, NULL); + lv_obj_t *buttonExt2 = lv_img_create(scr, NULL); #endif #if HAS_HEATED_BED - buttonBedstate = lv_img_create(scr, NULL); + lv_obj_t *buttonBedstate = lv_img_create(scr, NULL); #endif - buttonFanstate = lv_img_create(scr, NULL); - buttonTime = lv_img_create(scr, NULL); - buttonZpos = lv_img_create(scr, NULL); + lv_obj_t *buttonFanstate = lv_img_create(scr, NULL); + lv_obj_t *buttonTime = lv_img_create(scr, NULL); + lv_obj_t *buttonZpos = lv_img_create(scr, NULL); buttonPause = lv_imgbtn_create(scr, NULL); buttonStop = lv_imgbtn_create(scr, NULL); buttonOperat = lv_imgbtn_create(scr, NULL); 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 458620801b1b..519fae2f3968 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -23,9 +23,7 @@ #if HAS_TFT_LVGL_UI -#if ENABLED(TFT_LVGL_UI_SPI) - #include "SPI_TFT.h" -#endif +#include "SPI_TFT.h" #include "tft_lvgl_configuration.h" @@ -165,7 +163,7 @@ void gCfgItems_init() { W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[4], OTHERS_COMMAND_ADDR_4, 100); } - const byte rot = TERN0(GRAPHICAL_TFT_ROTATE_180, 0xEE); + const byte rot = (TFT_ROTATION & TFT_ROTATE_180) ? 0xEE : 0x00; if (gCfgItems.disp_rotation_180 != rot) { gCfgItems.disp_rotation_180 = rot; update_spi_flash(); @@ -655,12 +653,7 @@ char *creat_title_text() { } card.setIndex((gPicturePreviewStart + To_pre_view) + size * row + 8); - #if ENABLED(TFT_LVGL_UI_SPI) - SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1); - #else - LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1); - LCD_WriteRAM_Prepare(); - #endif + SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1); j = i = 0; @@ -673,20 +666,11 @@ char *creat_title_text() { } if (j >= 400) break; } - #if ENABLED(TFT_LVGL_UI_SPI) - for (i = 0; i < 400; i += 2) { - p_index = (uint16_t *)(&bmp_public_buf[i]); - if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; - } - SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200); - #else - for (i = 0; i < 400;) { - p_index = (uint16_t *)(&bmp_public_buf[i]); - if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color; - LCD_IO_WriteData(*p_index); - i += 2; - } - #endif + for (i = 0; i < 400; i += 2) { + p_index = (uint16_t *)(&bmp_public_buf[i]); + if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; + } + SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200); #if HAS_BAK_VIEW_IN_FLASH W25QXX.init(SPI_QUARTER_SPEED); if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096); @@ -767,8 +751,8 @@ char *creat_title_text() { card.openFileRead(cur_name); card.setIndex((PREVIEW_LITTLE_PIC_SIZE + To_pre_view) + size * row + 8); - #if ENABLED(TFT_LVGL_UI_SPI) - SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1); + #if HAS_TFT_LVGL_UI_SPI + SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1); #else LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1); LCD_WriteRAM_Prepare(); @@ -798,7 +782,7 @@ char *creat_title_text() { //#endif } - #if ENABLED(TFT_LVGL_UI_SPI) + #if HAS_TFT_LVGL_UI_SPI for (i = 0; i < 400;) { p_index = (uint16_t *)(&bmp_public_buf[i]); @@ -901,34 +885,9 @@ char *creat_title_text() { default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 8k #endif - #if ENABLED(TFT_LVGL_UI_SPI) - SPI_TFT.SetWindows(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200 - SPI_TFT.tftio.WriteSequence((uint16_t*)(bmp_public_buf), DEFAULT_VIEW_MAX_SIZE / 20); - #else - int x_off = 0; - uint16_t temp_p; - int i = 0; - uint16_t *p_index; - LCD_setWindowArea(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200 - - LCD_WriteRAM_Prepare(); - - for (int _y = y_off * 20; _y < (y_off + 1) * 20; _y++) { - for (x_off = 0; x_off < 200; x_off++) { - if (sel == 1) { - temp_p = (uint16_t)(bmp_public_buf[i] | bmp_public_buf[i + 1] << 8); - p_index = &temp_p; - } - else { - p_index = (uint16_t *)(&bmp_public_buf[i]); - } - if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color; - LCD_IO_WriteData(*p_index); - i += 2; - } - if (i >= 8000) break; - } - #endif // TFT_LVGL_UI_SPI + SPI_TFT.setWindow(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200 + SPI_TFT.tftio.WriteSequence((uint16_t*)(bmp_public_buf), DEFAULT_VIEW_MAX_SIZE / 20); + y_off++; } W25QXX.init(SPI_QUARTER_SPEED); 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 eeb6bae706bc..bc329aa82b89 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 @@ -23,9 +23,7 @@ #if HAS_TFT_LVGL_UI -#if ENABLED(TFT_LVGL_UI_SPI) - #include "SPI_TFT.h" -#endif +#include "SPI_TFT.h" #include "tft_lvgl_configuration.h" #include "draw_ready_print.h" @@ -626,10 +624,8 @@ static const uint16_t ASCII_Table_16x24[] PROGMEM = { void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint16_t bkColor) { for (uint16_t i = 0; i < 24; i++) { const uint16_t tmp_char = pgm_read_word(&ASCII_Table_16x24[((c - 0x20) * 24) + i]); - for (uint16_t j = 0; j < 16; j++) { - TERN(TFT_LVGL_UI_SPI, SPI_TFT.SetPoint, tft_set_point) - (x + j, y + i, ((tmp_char >> j) & 0x01) ? charColor : bkColor); - } + for (uint16_t j = 0; j < 16; j++) + SPI_TFT.SetPoint(x + j, y + i, ((tmp_char >> j) & 0x01) ? charColor : bkColor); } } @@ -643,7 +639,7 @@ void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor //static lv_obj_t * scr_test; void disp_assets_update() { - TERN(TFT_LVGL_UI_SPI,, LCD_Clear(0x0000)); + SPI_TFT.LCD_clear(0x0000); disp_string(100, 140, "Assets Updating...", 0xFFFF, 0x0000); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp index d6f5fbf8b5fd..07ac56380262 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp @@ -266,19 +266,24 @@ void spiFlashErase_PIC() { W25QXX.init(SPI_QUARTER_SPEED); //erase 0x001000 -64K for (pic_sectorcnt = 0; pic_sectorcnt < (64 - 4) / 4; pic_sectorcnt++) { + watchdog_refresh(); W25QXX.SPI_FLASH_SectorErase(PICINFOADDR + pic_sectorcnt * 4 * 1024); } //erase 64K -- 6M - for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++) + for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++) { + watchdog_refresh(); W25QXX.SPI_FLASH_BlockErase((pic_sectorcnt + 1) * 64 * 1024); + } } #if HAS_SPI_FLASH_FONT void spiFlashErase_FONT() { volatile uint32_t Font_sectorcnt = 0; W25QXX.init(SPI_QUARTER_SPEED); - for (Font_sectorcnt = 0; Font_sectorcnt < 32-1; Font_sectorcnt++) + for (Font_sectorcnt = 0; Font_sectorcnt < 32-1; Font_sectorcnt++) { + watchdog_refresh(); W25QXX.SPI_FLASH_BlockErase(FONTINFOADDR + Font_sectorcnt * 64 * 1024); + } } #endif @@ -410,6 +415,7 @@ uint8_t public_buf[512]; return; } + watchdog_refresh(); disp_assets_update_progress(fn); W25QXX.init(SPI_QUARTER_SPEED); @@ -422,18 +428,21 @@ uint8_t public_buf[512]; totalSizeLoaded += pfileSize; if (assetType == ASSET_TYPE_LOGO) { do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); Pic_Logo_Write((uint8_t *)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_TITLE_LOGO) { do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); Pic_TitleLogo_Write((uint8_t *)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_G_PREVIEW) { do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); default_view_Write(public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); @@ -443,6 +452,7 @@ uint8_t public_buf[512]; SPIFlash.beginWrite(Pic_Write_Addr); #if HAS_SPI_FLASH_COMPRESSION do { + watchdog_refresh(); pbr = file.read(public_buf, SPI_FLASH_PageSize); TERN_(MARLIN_DEV_MODE, totalSizes += pbr); SPIFlash.writeData(public_buf, SPI_FLASH_PageSize); @@ -463,6 +473,7 @@ uint8_t public_buf[512]; else if (assetType == ASSET_TYPE_FONT) { Pic_Write_Addr = UNIGBK_FLASH_ADDR; do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); W25QXX.SPI_FLASH_BufferWrite(public_buf, Pic_Write_Addr, pbr); Pic_Write_Addr += pbr; @@ -482,9 +493,11 @@ uint8_t public_buf[512]; disp_assets_update(); disp_assets_update_progress("Erasing pics..."); + watchdog_refresh(); spiFlashErase_PIC(); #if HAS_SPI_FLASH_FONT disp_assets_update_progress("Erasing fonts..."); + watchdog_refresh(); spiFlashErase_FONT(); #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp b/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp deleted file mode 100644 index 62967b9d8061..000000000000 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp +++ /dev/null @@ -1,60 +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 . - * - */ - -#include "../../../../inc/MarlinConfig.h" - -#if ENABLED(TFT_LVGL_UI_FSMC) - -#include HAL_PATH(../../HAL, tft/tft_fsmc.h) -TFT_IO tftio; - -void LCD_IO_Init(uint8_t cs, uint8_t rs); -void LCD_IO_WriteData(uint16_t RegValue); -void LCD_IO_WriteReg(uint16_t Reg); -#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 - -void LCD_IO_Init(uint8_t cs, uint8_t rs) { - tftio.Init(); -} - -void LCD_IO_WriteData(uint16_t RegValue) { - tftio.WriteData(RegValue); -} - -void LCD_IO_WriteReg(uint16_t Reg) { - tftio.WriteReg(Reg); -} - -#ifdef LCD_USE_DMA_FSMC - void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) { - tftio.WriteMultiple(color, count); - } - - void LCD_IO_WriteSequence(uint16_t *data, uint16_t length) { - tftio.WriteSequence(data, length); - } -#endif // LCD_USE_DMA_FSMC - -#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h deleted file mode 100644 index b2e19d66f8f8..000000000000 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h +++ /dev/null @@ -1,30 +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 . - * - */ -#pragma once - -#ifdef __cplusplus - extern "C" { /* C-declarations for C++ */ -#endif - -#ifdef __cplusplus - } /* C-declarations for C++ */ -#endif 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 49b44799a69f..f74ed3c798d2 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 @@ -29,9 +29,7 @@ #if HAS_TFT_LVGL_UI -#if ENABLED(TFT_LVGL_UI_SPI) - #include "SPI_TFT.h" -#endif +#include "SPI_TFT.h" #include "tft_lvgl_configuration.h" #include "draw_ready_print.h" @@ -46,7 +44,7 @@ #include "../../../../inc/MarlinConfig.h" #include HAL_PATH(../../HAL, tft/xpt2046.h) -#include "../../../ultralcd.h" +#include "../../../marlinui.h" XPT2046 touch; #if ENABLED(POWER_LOSS_RECOVERY) @@ -74,24 +72,6 @@ lv_group_t* g; uint16_t DeviceCode = 0x9488; extern uint8_t sel_id; -#define SetCs -#define ClrCs - -#define HDP 799 // Horizontal Display Period -#define HT 1000 // Horizontal Total -#define HPS 51 // LLINE Pulse Start Position -#define LPS 3 // Horizontal Display Period Start Position -#define HPW 8 // LLINE Pulse Width - -#define VDP 479 // Vertical Display Period -#define VT 530 // Vertical Total -#define VPS 24 // LFRAME Pulse Start Position -#define FPS 23 // Vertical Display Period Start Positio -#define VPW 3 // LFRAME Pulse Width - -#define MAX_HZ_POSX HDP+1 -#define MAX_HZ_POSY VDP+1 - extern uint8_t gcode_preview_over, flash_preview_begin, default_preview_flg; uint8_t bmp_public_buf[17 * 1024]; @@ -125,317 +105,7 @@ void SysTick_Callback() { } } -#if DISABLED(TFT_LVGL_UI_SPI) - - extern void LCD_IO_Init(uint8_t cs, uint8_t rs); - extern void LCD_IO_WriteData(uint16_t RegValue); - extern void LCD_IO_WriteReg(uint16_t Reg); - - extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count); - void tft_set_cursor(uint16_t x, uint16_t y) { - LCD_IO_WriteReg(0x002A); - LCD_IO_WriteData(x >> 8); - LCD_IO_WriteData(x & 0x00FF); - LCD_IO_WriteData(x >> 8); - LCD_IO_WriteData(x & 0x00FF); - //ILI9488_WriteData(0x01); - //ILI9488_WriteData(0xDF); - LCD_IO_WriteReg(0x002B); - LCD_IO_WriteData(y >> 8); - LCD_IO_WriteData(y & 0x00FF); - LCD_IO_WriteData(y >> 8); - LCD_IO_WriteData(y & 0x00FF); - //ILI9488_WriteData(0x01); - //ILI9488_WriteData(0x3F); - } - - void LCD_WriteRAM_Prepare(void) { - #if 0 - switch (DeviceCode) { - case 0x9325: case 0x9328: case 0x8989: { - ClrCs - LCD->LCD_REG = R34; - SetCs - } break; - default: LCD_WrtReg(0x002C); - } - #else - LCD_IO_WriteReg(0x002C); - #endif - } - - void tft_set_point(uint16_t x, uint16_t y, uint16_t point) { - //if (DeviceCode == 0x9488) { - if (x > (TFT_WIDTH) || y > (TFT_HEIGHT)) return; - //} - tft_set_cursor(x, y); - - LCD_WriteRAM_Prepare(); - //LCD_WriteRAM(point); - LCD_IO_WriteData(point); - } - - void LCD_WriteReg(uint16_t LCD_Reg, uint16_t LCD_RegValue) { - /* Write 16-bit Index, then Write Reg */ - ClrCs - LCD_IO_WriteReg(LCD_Reg); - /* Write 16-bit Reg */ - LCD_IO_WriteData(LCD_RegValue); - SetCs - } - - void LCD_setWindowArea(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh) { - uint16_t s_h, s_l, e_h, e_l; - uint16_t xEnd, yEnd; - xEnd = StartX + width; - yEnd = StartY + heigh - 1; - if (DeviceCode == 0x8989) { - /*LCD_WriteReg(0x0044, (StartX & 0xFF) | (xEnd << 8)); - LCD_WriteReg(0x0045, StartY); - LCD_WriteReg(0x0046, yEnd);*/ - LCD_WriteReg(0x0044, (StartY & 0xFF) | (yEnd << 8)); - LCD_WriteReg(0x0045, StartX); - LCD_WriteReg(0x0046, xEnd); - } - else if (DeviceCode == 0x9488) { - s_h = (StartX >> 8) & 0x00FF; - s_l = StartX & 0x00FF; - e_h = ((StartX + width - 1) >> 8) & 0x00FF; - e_l = (StartX + width - 1) & 0x00FF; - - LCD_IO_WriteReg(0x002A); - LCD_IO_WriteData(s_h); - LCD_IO_WriteData(s_l); - LCD_IO_WriteData(e_h); - LCD_IO_WriteData(e_l); - - s_h = (StartY >> 8) & 0x00FF; - s_l = StartY & 0x00FF; - e_h = ((StartY + heigh - 1) >> 8) & 0x00FF; - e_l = (StartY + heigh - 1) & 0x00FF; - - LCD_IO_WriteReg(0x002B); - LCD_IO_WriteData(s_h); - LCD_IO_WriteData(s_l); - LCD_IO_WriteData(e_h); - LCD_IO_WriteData(e_l); - } - else if ((DeviceCode == 0x9325) || (DeviceCode == 0x9328) || (DeviceCode == 0x1505)) { - /* LCD_WriteReg(0x0050, StartX); - LCD_WriteReg(0x0052, StartY); - LCD_WriteReg(0x0051, xEnd); - 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, (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 { - s_h = (StartX >> 8) & 0xFF; - s_l = StartX & 0xFF; - e_h = ((StartX + width - 1) >> 8) & 0xFF; - e_l = (StartX + width - 1) & 0xFF; - - LCD_IO_WriteReg(0x2A); - LCD_IO_WriteData(s_h); - LCD_IO_WriteData(s_l); - LCD_IO_WriteData(e_h); - LCD_IO_WriteData(e_l); - - s_h = (StartY >> 8) & 0xFF; - s_l = StartY & 0xFF; - e_h = ((StartY + heigh - 1) >> 8) & 0xFF; - e_l = (StartY + heigh - 1) & 0xFF; - - LCD_IO_WriteReg(0x2B); - LCD_IO_WriteData(s_h); - LCD_IO_WriteData(s_l); - LCD_IO_WriteData(e_h); - LCD_IO_WriteData(e_l); - } - } - - void LCD_Clear(uint16_t Color) { - uint32_t index = 0; - unsigned int count; - - if (DeviceCode == 0x9488) { - tft_set_cursor(0, 0); - LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT); - LCD_WriteRAM_Prepare(); - #ifdef LCD_USE_DMA_FSMC - LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT)); - #else - //index = (TFT_HEIGHT) / 2 * (TFT_WIDTH); - for (index = 0; index < (TFT_HEIGHT) * (TFT_WIDTH); index++) - LCD_IO_WriteData(Color); - #endif - //LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT)); - //while(index --) LCD_IO_WriteData(Color); - } - else if (DeviceCode == 0x5761) { - LCD_IO_WriteReg(0x002A); - LCD_IO_WriteData(0); - LCD_IO_WriteData(0); - LCD_IO_WriteData(HDP >> 8); - LCD_IO_WriteData(HDP & 0x00FF); - LCD_IO_WriteReg(0x002B); - LCD_IO_WriteData(0); - LCD_IO_WriteData(0); - LCD_IO_WriteData(VDP >> 8); - LCD_IO_WriteData(VDP & 0x00FF); - LCD_IO_WriteReg(0x002C); - LCD_IO_WriteReg(0x002C); - for (count = 0; count < (HDP + 1) * (VDP + 1); count++) - LCD_IO_WriteData(Color); - } - else { - tft_set_cursor(0, 0); - LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ - for (index = 0; index < 76800; index++) - LCD_IO_WriteData(Color); - } - } - - #include HAL_PATH(../../HAL, tft/tft_fsmc.h) - extern TFT_IO tftio; - void fsmc_tft_init() { - uint16_t i; - - TERN_(HAS_LCD_CONTRAST, refresh_contrast()); - - #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(FSMC_CS_PIN, FSMC_RS_PIN); - - _delay_ms(5); - - DeviceCode = tftio.GetID() & 0xFFFF; - // Chitu and others - if (DeviceCode == 0x8066) DeviceCode = 0x9488; - - if (DeviceCode == 0x9488) { - LCD_IO_WriteReg(0x00E0); - LCD_IO_WriteData(0x0000); - LCD_IO_WriteData(0x0007); - LCD_IO_WriteData(0x000F); - LCD_IO_WriteData(0x000D); - LCD_IO_WriteData(0x001B); - LCD_IO_WriteData(0x000A); - LCD_IO_WriteData(0x003C); - LCD_IO_WriteData(0x0078); - LCD_IO_WriteData(0x004A); - LCD_IO_WriteData(0x0007); - LCD_IO_WriteData(0x000E); - LCD_IO_WriteData(0x0009); - LCD_IO_WriteData(0x001B); - LCD_IO_WriteData(0x001E); - LCD_IO_WriteData(0x000F); - - LCD_IO_WriteReg(0x00E1); - LCD_IO_WriteData(0x0000); - LCD_IO_WriteData(0x0022); - LCD_IO_WriteData(0x0024); - LCD_IO_WriteData(0x0006); - LCD_IO_WriteData(0x0012); - LCD_IO_WriteData(0x0007); - LCD_IO_WriteData(0x0036); - LCD_IO_WriteData(0x0047); - LCD_IO_WriteData(0x0047); - LCD_IO_WriteData(0x0006); - LCD_IO_WriteData(0x000A); - LCD_IO_WriteData(0x0007); - LCD_IO_WriteData(0x0030); - LCD_IO_WriteData(0x0037); - LCD_IO_WriteData(0x000F); - - LCD_IO_WriteReg(0x00C0); - LCD_IO_WriteData(0x0010); - LCD_IO_WriteData(0x0010); - - LCD_IO_WriteReg(0x00C1); - LCD_IO_WriteData(0x0041); - - LCD_IO_WriteReg(0x00C5); - LCD_IO_WriteData(0x0000); - LCD_IO_WriteData(0x0022); - LCD_IO_WriteData(0x0080); - - LCD_IO_WriteReg(0x0036); - LCD_IO_WriteData(TERN(GRAPHICAL_TFT_ROTATE_180, 0xE8, 0x0068)); - - LCD_IO_WriteReg(0x003A); //Interface Mode Control - LCD_IO_WriteData(0x0055); - - LCD_IO_WriteReg(0x00B0); //Interface Mode Control - LCD_IO_WriteData(0x0000); - LCD_IO_WriteReg(0x00B1); //Frame rate 70HZ - LCD_IO_WriteData(0x00B0); - LCD_IO_WriteData(0x0011); - LCD_IO_WriteReg(0x00B4); - LCD_IO_WriteData(0x0002); - LCD_IO_WriteReg(0x00B6); //RGB/MCU Interface Control - LCD_IO_WriteData(0x0002); - LCD_IO_WriteData(0x0042); - - LCD_IO_WriteReg(0x00B7); - LCD_IO_WriteData(0x00C6); - - //WriteComm(0xBE); - //WriteData(0x00); - //WriteData(0x04); - - LCD_IO_WriteReg(0x00E9); - LCD_IO_WriteData(0x0000); - - LCD_IO_WriteReg(0x00F7); - LCD_IO_WriteData(0x00A9); - LCD_IO_WriteData(0x0051); - LCD_IO_WriteData(0x002C); - LCD_IO_WriteData(0x0082); - - LCD_IO_WriteReg(0x0011); - for (i = 0; i < 65535; i++) { /* do nothing */ } - LCD_IO_WriteReg(0x0029); - - LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT); - - OUT_WRITE(LCD_BACKLIGHT_PIN, LOW); - LCD_Clear(0x0000); - - TERN_(HAS_LOGO_IN_FLASH, lcd_draw_logo()); - - OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH); - delay(2000); - } - } - - extern void LCD_IO_WriteSequence(uint16_t *data, uint16_t length); - - void lcd_draw_logo() { - LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT); - LCD_WriteRAM_Prepare(); - - for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) { - Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2); - #ifdef LCD_USE_DMA_FSMC - LCD_IO_WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH); - #else - int index = 0;,x_off = 0; - for (x_off = 0; x_off < TFT_WIDTH; x_off++) { - LCD_IO_WriteData((uint16_t)bmp_public_buf[index]); - index += 2; - } - #endif - } - } - -#endif // !TFT_LVGL_UI_SPI +extern uint8_t bmp_public_buf[17 * 1024]; void tft_lvgl_init() { @@ -448,17 +118,16 @@ void tft_lvgl_init() { disp_language_init(); //init tft first! - #if ENABLED(TFT_LVGL_UI_SPI) - SPI_TFT.spi_init(SPI_FULL_SPEED); - SPI_TFT.LCD_init(); - #else - fsmc_tft_init(); - #endif + SPI_TFT.spi_init(SPI_FULL_SPEED); + SPI_TFT.LCD_init(); //spi_flash_read_test(); #if ENABLED(SDSUPPORT) + watchdog_refresh(); UpdateAssets(); #endif + + watchdog_refresh(); mks_test_get(); touch.Init(); @@ -548,41 +217,18 @@ void tft_lvgl_init() { } void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) { - #if ENABLED(TFT_LVGL_UI_SPI) - uint16_t i, width, height; + uint16_t i, width, height; - width = area->x2 - area->x1 + 1; - height = area->y2 - area->y1 + 1; + width = area->x2 - area->x1 + 1; + height = area->y2 - area->y1 + 1; - SPI_TFT.SetWindows((uint16_t)area->x1, (uint16_t)area->y1, width, height); - for (i = 0; i < height; i++) { - SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width); - } - lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/ - - W25QXX.init(SPI_QUARTER_SPEED); - - #else // !TFT_LVGL_UI_SPI - - #if 1 - uint16_t i, width, height; - //uint16_t clr_temp; - width = area->x2 - area->x1 + 1; - height = area->y2 - area->y1 + 1; - LCD_setWindowArea((uint16_t)area->x1, (uint16_t)area->y1, width, height); - LCD_WriteRAM_Prepare(); - for (i = 0; i < width * height - 2; i++) { - //clr_temp = (uint16_t)(((uint16_t)color_p->ch.red << 11) - //| ((uint16_t)color_p->ch.green << 5) - //| ((uint16_t)color_p->ch.blue)); - LCD_IO_WriteData(color_p->full); - color_p++; - } - - lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/ - #endif + SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height); + for (i = 0; i < height; i++) { + SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width); + } + lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/ - #endif // !TFT_LVGL_UI_SPI + W25QXX.init(SPI_QUARTER_SPEED); } #define TICK_CYCLE 1 @@ -599,7 +245,7 @@ static bool get_point(int16_t *x, int16_t *y) { *y = int16_t((int32_t(*y) * XPT2046_Y_CALIBRATION) >> 16) + XPT2046_Y_OFFSET; } - #if ENABLED(GRAPHICAL_TFT_ROTATE_180) + #if (TFT_ROTATION & TFT_ROTATE_180) *x = int16_t((TFT_WIDTH) - (int)(*x)); *y = int16_t((TFT_HEIGHT) - (int)(*y)); #endif @@ -799,39 +445,40 @@ void lv_encoder_pin_init() { //static const int8_t encoderDirection = 1; //static int16_t enc_Direction; void lv_update_encoder() { - static uint8_t buttons; static uint32_t encoder_time1; uint32_t tmpTime, diffTime = 0; tmpTime = millis(); diffTime = getTickDiff(tmpTime, encoder_time1); if (diffTime > 50) { - #if ANY_BUTTON(EN1, EN2, ENC, BACK) + #if HAS_ENCODER_WHEEL + + #if ANY_BUTTON(EN1, EN2, ENC, BACK) - uint8_t newbutton = 0; + uint8_t newbutton = 0; - #if BUTTON_EXISTS(EN1) - if (BUTTON_PRESSED(EN1)) newbutton |= EN_A; - #endif - #if BUTTON_EXISTS(EN2) - if (BUTTON_PRESSED(EN2)) newbutton |= EN_B; - #endif - #if BUTTON_EXISTS(ENC) - if (BUTTON_PRESSED(ENC)) newbutton |= EN_C; - #endif - #if BUTTON_EXISTS(BACK) - if (BUTTON_PRESSED(BACK)) newbutton |= EN_D; - #endif + #if BUTTON_EXISTS(EN1) + if (BUTTON_PRESSED(EN1)) newbutton |= EN_A; + #endif + #if BUTTON_EXISTS(EN2) + if (BUTTON_PRESSED(EN2)) newbutton |= EN_B; + #endif + #if BUTTON_EXISTS(ENC) + if (BUTTON_PRESSED(ENC)) newbutton |= EN_C; + #endif + #if BUTTON_EXISTS(BACK) + if (BUTTON_PRESSED(BACK)) newbutton |= EN_D; + #endif - #else + #else - constexpr uint8_t newbutton = 0; + constexpr uint8_t newbutton = 0; - #endif + #endif - buttons = newbutton; - #if HAS_ENCODER_WHEEL + static uint8_t buttons = 0; + buttons = newbutton; static uint8_t lastEncoderBits; #define encrot0 0 diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h index 7e24f948fd09..727ab33aea30 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h @@ -32,7 +32,7 @@ #include -//#define GRAPHICAL_TFT_ROTATE_180 +//#define TFT_ROTATION TFT_ROTATE_180 #define USE_WIFI_FUNCTION 0 extern void tft_lvgl_init(); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp index f5d954792ead..e4fb4ece0366 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -33,7 +33,7 @@ #include "../../../../module/temperature.h" #include "../../../../gcode/queue.h" #include "../../../../gcode/gcode.h" -#include "../../../../lcd/ultralcd.h" +#include "../../../../lcd/marlinui.h" #include "../../../../sd/cardreader.h" #include "../../../../module/planner.h" #if ENABLED(POWER_LOSS_RECOVERY) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp index 77bcb767b72d..087a3b21105c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp @@ -110,24 +110,17 @@ const char *resultMessages[] = { // 230400b always manages to connect. static const uint32_t uploadBaudRates[] = { 460800, 230400, 115200, 74880 }; - - signed char IsReady() { return esp_upload.state == upload_idle; } - - - - void uploadPort_write(const uint8_t *buf, size_t len) { #if 0 int i; - for(i = 0; i < len; i++) { - while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); - - USART_SendData(USART1, *(buf + i)); + for (i = 0; i < len; i++) { + while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) { /* nada */ } + USART_SendData(USART1, *(buf + i)); } #endif } @@ -138,28 +131,22 @@ char uploadPort_read() { return retChar; else return 0; - } int uploadPort_available() { return usartFifoAvailable(&WifiRxFifo); } - void uploadPort_begin() { esp_port_begin(1); } void uploadPort_close() { - //WIFI_COM.end(); //WIFI_COM.begin(115200, true); - esp_port_begin(0); - } - void flushInput() { while (uploadPort_available() != 0) { (void)uploadPort_read(); @@ -304,7 +291,6 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t *bodyLen = 0; - while (state != done) { uint8_t c; EspUploadResult stat; @@ -322,73 +308,73 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t } // sufficient bytes have been received for the current state, process them - switch(state) { - case begin: // expecting frame start - c = uploadPort_read(); - if (c != (uint8_t)0xC0) { - break; - } - state = header; - needBytes = 2; + switch (state) { + case begin: // expecting frame start + c = uploadPort_read(); + if (c != (uint8_t)0xC0) { + break; + } + state = header; + needBytes = 2; - break; - case end: // expecting frame end - c = uploadPort_read(); - if (c != (uint8_t)0xC0) { - return slipFrame; - } - state = done; + break; + case end: // expecting frame end + c = uploadPort_read(); + if (c != (uint8_t)0xC0) { + return slipFrame; + } + state = done; - break; + break; - case header: // reading an 8-byte header - case body: // reading the response body - { - int rslt; - // retrieve a byte with SLIP decoding - rslt = ReadByte(&c, 1); - if (rslt != 1 && rslt != 2) { - // some error occurred - stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame; - return stat; - } - else if (state == header) { - //store the header byte - hdr[hdrIdx++] = c; - if (hdrIdx >= headerLength) { - // get the body length, prepare a buffer for it - *bodyLen = (uint16_t)getData(2, hdr, 2); - - // extract the value, if requested - if (valp != 0) { - *valp = getData(4, hdr, 4); + case header: // reading an 8-byte header + case body: // reading the response body + { + int rslt; + // retrieve a byte with SLIP decoding + rslt = ReadByte(&c, 1); + if (rslt != 1 && rslt != 2) { + // some error occurred + stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame; + return stat; + } + else if (state == header) { + //store the header byte + hdr[hdrIdx++] = c; + if (hdrIdx >= headerLength) { + // get the body length, prepare a buffer for it + *bodyLen = (uint16_t)getData(2, hdr, 2); + + // extract the value, if requested + if (valp != 0) { + *valp = getData(4, hdr, 4); + } + + if (*bodyLen != 0) { + state = body; + } + else { + needBytes = 1; + state = end; + } } - - if (*bodyLen != 0) { - state = body; + } + else { + // Store the response body byte, check for completion + if (bodyIdx < ARRAY_SIZE(respBuf)) { + respBuf[bodyIdx] = c; } - else { + ++bodyIdx; + if (bodyIdx >= *bodyLen) { needBytes = 1; state = end; } } } - else { - // Store the response body byte, check for completion - if (bodyIdx < ARRAY_SIZE(respBuf)) { - respBuf[bodyIdx] = c; - } - ++bodyIdx; - if (bodyIdx >= *bodyLen) { - needBytes = 1; - state = end; - } - } - } - break; + break; - default: // this shouldn't happen - return slipState; + default: // this shouldn't happen + return slipState; } } @@ -397,7 +383,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t opRet = (uint8_t)getData(1, hdr, 1); // Sync packets often provoke a response with a zero opcode instead of ESP_SYNC if (resp != 0x01 || opRet != op) { -//debug//printf("resp %02x %02x\n", resp, opRet); + //printf("resp %02x %02x\n", resp, opRet); //debug return respHeader; } @@ -432,20 +418,19 @@ void _writePacket(const uint8_t *data, size_t len) { // 0xC0 and 0xDB replaced by the two-byte sequences {0xDB, 0xDC} and {0xDB, 0xDD} respectively. void writePacket(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) { - - WriteByteRaw(0xC0); // send the packet start character + WriteByteRaw(0xC0); // send the packet start character _writePacket(hdr, hdrLen); // send the header - _writePacket(data, dataLen); // send the data block - WriteByteRaw(0xC0); // send the packet end character + _writePacket(data, dataLen); // send the data block + WriteByteRaw(0xC0); // send the packet end character } // Send a packet to the serial port while performing SLIP framing. The packet data comprises a header and an optional data block. // This is like writePacket except that it does a fast block write for both the header and the main data with no SLIP encoding. Used to send sync commands. void writePacketRaw(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) { - WriteByteRaw(0xC0); // send the packet start character - _writePacketRaw(hdr, hdrLen); // send the header + WriteByteRaw(0xC0); // send the packet start character + _writePacketRaw(hdr, hdrLen); // send the header _writePacketRaw(data, dataLen); // send the data block in raw mode - WriteByteRaw(0xC0); // send the packet end character + WriteByteRaw(0xC0); // send the packet end character } // Send a command to the attached device together with the supplied data, if any. @@ -460,12 +445,10 @@ void sendCommand(uint8_t op, uint32_t checkVal, const uint8_t *data, size_t data // send the packet //flushInput(); - if (op == ESP_SYNC) { + if (op == ESP_SYNC) writePacketRaw(hdr, sizeof(hdr), data, dataLen); - } - else { + else writePacket(hdr, sizeof(hdr), data, dataLen); - } } // Send a command to the attached device together with the supplied data, if any, and get the response @@ -476,9 +459,8 @@ EspUploadResult doCommand(uint8_t op, const uint8_t *data, size_t dataLen, uint3 sendCommand(op, checkVal, data, dataLen); stat = readPacket(op, valp, &bodyLen, msTimeout); - if (stat == success && bodyLen != 2) { + if (stat == success && bodyLen != 2) stat = badReply; - } return stat; } @@ -611,6 +593,8 @@ EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) { //printf("Upload %d\%\n", ftell(&esp_upload.uploadFile) * 100 / esp_upload.fileSize); return stat; + #else + return success; #endif } @@ -625,15 +609,14 @@ void upload_spin() { esp_upload.uploadResult = connected; esp_upload.state = done; } - else{ + else { // Reset the serial port at the new baud rate. Also reset the ESP8266. - // const uint32_t baud = uploadBaudRates[esp_upload.connectAttemptNumber/esp_upload.retriesPerBaudRate]; + // const uint32_t baud = uploadBaudRates[esp_upload.connectAttemptNumber/esp_upload.retriesPerBaudRate]; if (esp_upload.connectAttemptNumber % esp_upload.retriesPerBaudRate == 0) { } - // uploadPort.begin(baud); - // uploadPort_close(); - + //uploadPort.begin(baud); + //uploadPort_close(); uploadPort_begin(); @@ -654,7 +637,7 @@ void upload_spin() { esp_upload.lastAttemptTime = getWifiTick(); if (res == success) { // Successful connection -// //MessageF(" success on attempt %d\n", (connectAttemptNumber % retriesPerBaudRate) + 1); + //MessageF(" success on attempt %d\n", (connectAttemptNumber % retriesPerBaudRate) + 1); //printf("connect success\n"); esp_upload.state = erasing; } @@ -675,14 +658,13 @@ void upload_spin() { const uint32_t sectorSize = 4096; const uint32_t numSectors = (esp_upload.fileSize + sectorSize - 1)/sectorSize; const uint32_t startSector = esp_upload.uploadAddress/sectorSize; + uint32_t headSectors = sectorsPerBlock - (startSector % sectorsPerBlock); + NOMORE(headSectors, numSectors); - if (numSectors < headSectors) { - headSectors = numSectors; - } - eraseSize = (numSectors < 2 * headSectors) - ? (numSectors + 1) / 2 * sectorSize - : (numSectors - headSectors) * sectorSize; + eraseSize = (numSectors < 2 * headSectors) + ? (numSectors + 1) / 2 * sectorSize + : (numSectors - headSectors) * sectorSize; //MessageF("Erasing %u bytes...\n", fileSize); esp_upload.uploadResult = flashBegin(esp_upload.uploadAddress, eraseSize); @@ -755,7 +737,7 @@ void SendUpdateFile(const char *file, uint32_t address) { if (res != FR_OK) return; - esp_upload.fileSize = f_size(&esp_upload.uploadFile); + esp_upload.fileSize = f_size(&esp_upload.uploadFile); if (esp_upload.fileSize == 0) { f_close(&esp_upload.uploadFile); return; diff --git a/Marlin/src/lcd/extui/malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp index 79a5fb961aa1..5505a0dff7d7 100644 --- a/Marlin/src/lcd/extui/malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -49,7 +49,7 @@ #include "ui_api.h" -#include "../ultralcd.h" +#include "../marlinui.h" #include "../../sd/cardreader.h" #include "../../module/temperature.h" #include "../../module/stepper.h" diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 0acfc9c025c1..8151828a0837 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -45,7 +45,7 @@ #if ENABLED(EXTENSIBLE_UI) -#include "../ultralcd.h" +#include "../marlinui.h" #include "../../gcode/queue.h" #include "../../module/motion.h" #include "../../module/planner.h" @@ -305,27 +305,9 @@ namespace ExtUI { } void setAxisPosition_mm(const float position, const axis_t axis, const feedRate_t feedrate/*=0*/) { - // Start with no limits to movement - float min = current_position[axis] - 1000, - max = current_position[axis] + 1000; - - // Limit to software endstops, if enabled - #if HAS_SOFTWARE_ENDSTOPS - if (soft_endstops_enabled) switch (axis) { - case X_AXIS: - TERN_(MIN_SOFTWARE_ENDSTOP_X, min = soft_endstop.min.x); - TERN_(MAX_SOFTWARE_ENDSTOP_X, max = soft_endstop.max.x); - break; - case Y_AXIS: - TERN_(MIN_SOFTWARE_ENDSTOP_Y, min = soft_endstop.min.y); - TERN_(MAX_SOFTWARE_ENDSTOP_Y, max = soft_endstop.max.y); - break; - case Z_AXIS: - TERN_(MIN_SOFTWARE_ENDSTOP_Z, min = soft_endstop.min.z); - TERN_(MAX_SOFTWARE_ENDSTOP_Z, max = soft_endstop.max.z); - default: break; - } - #endif // HAS_SOFTWARE_ENDSTOPS + // Get motion limit from software endstops, if any + float min, max; + soft_endstop.get_manual_axis_limits((AxisEnum)axis, min, max); // Delta limits XY based on the current offset from center // This assumes the center is 0,0 @@ -389,8 +371,8 @@ namespace ExtUI { } #if HAS_SOFTWARE_ENDSTOPS - bool getSoftEndstopState() { return soft_endstops_enabled; } - void setSoftEndstopState(const bool value) { soft_endstops_enabled = value; } + bool getSoftEndstopState() { return soft_endstop._enabled; } + void setSoftEndstopState(const bool value) { soft_endstop._enabled = value; } #endif #if HAS_TRINAMIC_CONFIG @@ -1071,11 +1053,9 @@ namespace ExtUI { } // namespace ExtUI -// At the moment, we piggy-back off the ultralcd calls, but this could be cleaned up in the future +// At the moment we hook into MarlinUI methods, but this could be cleaned up in the future -void MarlinUI::init() { - ExtUI::onStartup(); -} +void MarlinUI::init() { ExtUI::onStartup(); } void MarlinUI::update() { ExtUI::onIdle(); } diff --git a/Marlin/src/lcd/fontutils.cpp b/Marlin/src/lcd/fontutils.cpp index 5bf07e1bd458..22b54c72de72 100644 --- a/Marlin/src/lcd/fontutils.cpp +++ b/Marlin/src/lcd/fontutils.cpp @@ -10,7 +10,7 @@ #include "../inc/MarlinConfig.h" #if HAS_WIRED_LCD - #include "ultralcd.h" + #include "marlinui.h" #include "../MarlinCore.h" #endif diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 74e185680cc7..f8d891576e15 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -70,7 +70,7 @@ namespace Language_de { PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Ausblendhöhe"); PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Setze Homeversatz"); PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Homeversatz aktiv"); - PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Setze Nullpunkte"); //"G92 X0 Y0 Z0" commented out in ultralcd.cpp + PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Setze Nullpunkte"); //"G92 X0 Y0 Z0" commented out in marlinui.cpp #if PREHEAT_COUNT PROGMEM Language_Str MSG_PREHEAT_1 = PREHEAT_1_LABEL _UxGT(" Vorwärmen"); PROGMEM Language_Str MSG_PREHEAT_1_H = PREHEAT_1_LABEL _UxGT(" Vorwärmen ~"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index b41515a73428..e8b4769cc216 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -67,6 +67,9 @@ namespace Language_en { PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Home Z"); PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Auto Z-Align"); PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Assisted Tramming"); + PROGMEM Language_Str MSG_ITERATION = _UxGT("G34 Iteration: %i"); + PROGMEM Language_Str MSG_DECREASING_ACCURACY = _UxGT("Accuracy Decreasing!"); + PROGMEM Language_Str MSG_ACCURACY_ACHIEVED = _UxGT("Accuracy Achieved"); PROGMEM Language_Str MSG_LEVEL_BED_HOMING = _UxGT("Homing XYZ"); PROGMEM Language_Str MSG_LEVEL_BED_WAITING = _UxGT("Click to Begin"); PROGMEM Language_Str MSG_LEVEL_BED_NEXT_POINT = _UxGT("Next Point"); diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/marlinui.cpp similarity index 99% rename from Marlin/src/lcd/ultralcd.cpp rename to Marlin/src/lcd/marlinui.cpp index 58e6d9473b35..487678eccfc1 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -31,7 +31,7 @@ #endif // All displays share the MarlinUI class -#include "ultralcd.h" +#include "marlinui.h" MarlinUI ui; #if HAS_DISPLAY @@ -117,7 +117,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_WIRED_LCD #if HAS_MARLINUI_U8GLIB - #include "dogm/ultralcd_DOGM.h" + #include "dogm/marlinui_DOGM.h" #endif #include "lcdprint.h" @@ -400,7 +400,7 @@ bool MarlinUI::get_blink() { ///////////// Keypad Handling ////////////// //////////////////////////////////////////// -#if BOTH(REPRAPWORLD_KEYPAD, HAS_ENCODER_ACTION) +#if IS_RRW_KEYPAD && HAS_ENCODER_ACTION volatile uint8_t MarlinUI::keypad_buttons; @@ -432,7 +432,7 @@ bool MarlinUI::get_blink() { #if HAS_ENCODER_ACTION refresh(LCDVIEW_REDRAW_NOW); #if HAS_LCD_MENU - if (encoderDirection == -(ENCODERBASE)) { // ADC_KEYPAD forces REVERSE_MENU_DIRECTION, so this indicates menu navigation + if (encoderDirection == -(ENCODERBASE)) { // HAS_ADC_BUTTONS forces REVERSE_MENU_DIRECTION, so this indicates menu navigation if (RRK(EN_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; else if (RRK(EN_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM; else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); } @@ -497,12 +497,12 @@ bool MarlinUI::get_blink() { return true; } - #endif // !ADC_KEYPAD + #endif // !HAS_ADC_BUTTONS return false; } -#endif // REPRAPWORLD_KEYPAD +#endif // IS_RRW_KEYPAD && HAS_ENCODER_ACTION /** * Status Screen @@ -1478,10 +1478,6 @@ void MarlinUI::update() { set_status_P(msg, -1); } - #if ENABLED(SDSUPPORT) - extern bool wait_for_user, wait_for_heatup; - #endif - void MarlinUI::abort_print() { #if ENABLED(SDSUPPORT) wait_for_heatup = wait_for_user = false; @@ -1553,12 +1549,15 @@ void MarlinUI::update() { // - On edit screens, touch Up Half for -, Bottom Half to + // void MarlinUI::screen_click(const uint8_t row, const uint8_t col, const uint8_t, const uint8_t) { + const millis_t now = millis(); + if (PENDING(now, next_button_update_ms)) return; + next_button_update_ms = now + repeat_delay; // Assume the repeat delay const int8_t xdir = col < (LCD_WIDTH ) / 2 ? -1 : 1, ydir = row < (LCD_HEIGHT) / 2 ? -1 : 1; if (on_edit_screen) encoderDiff = epps * ydir; else if (screen_items > 0) { - // Last 3 cols act as a scroll :-) + // Last 5 cols act as a scroll :-) if (col > (LCD_WIDTH) - 5) // 2 * LCD_HEIGHT to scroll to bottom of next page. (LCD_HEIGHT would only go 1 item down.) encoderDiff = epps * (encoderLine - encoderTopLine + 2 * (LCD_HEIGHT)) * ydir; diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/marlinui.h similarity index 98% rename from Marlin/src/lcd/ultralcd.h rename to Marlin/src/lcd/marlinui.h index c7ef41596df5..bf9e47e0c845 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/marlinui.h @@ -34,13 +34,13 @@ #if EITHER(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY) #define HAS_ENCODER_ACTION 1 #endif -#if ((!HAS_ADC_BUTTONS && ENABLED(NEWPANEL)) || BUTTONS_EXIST(EN1, EN2)) && !IS_TFTGLCD_PANEL +#if ((!HAS_ADC_BUTTONS && IS_NEWPANEL) || BUTTONS_EXIST(EN1, EN2)) && !IS_TFTGLCD_PANEL #define HAS_ENCODER_WHEEL 1 #endif #if HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT) #define HAS_DIGITAL_BUTTONS 1 #endif -#if !HAS_ADC_BUTTONS && (ENABLED(REPRAPWORLD_KEYPAD) || (HAS_WIRED_LCD && DISABLED(NEWPANEL))) +#if !HAS_ADC_BUTTONS && (IS_RRW_KEYPAD || (HAS_WIRED_LCD && !IS_NEWPANEL)) #define HAS_SHIFT_ENCODER 1 #endif @@ -106,8 +106,7 @@ #endif // HAS_WIRED_LCD -// REPRAPWORLD_KEYPAD (and ADC_KEYPAD) -#if ENABLED(REPRAPWORLD_KEYPAD) +#if IS_RRW_KEYPAD #define BTN_OFFSET 0 // Bit offset into buttons for shift register values #define BLEN_KEYPAD_F3 0 @@ -136,7 +135,7 @@ #define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE) #endif -#endif +#endif // IS_RRW_KEYPAD #if HAS_DIGITAL_BUTTONS @@ -633,7 +632,7 @@ class MarlinUI { #if HAS_ENCODER_ACTION static volatile uint8_t buttons; - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD static volatile uint8_t keypad_buttons; static bool handle_keypad(); #endif diff --git a/Marlin/src/lcd/menu/game/game.h b/Marlin/src/lcd/menu/game/game.h index e788f2980512..cba79e4f28e1 100644 --- a/Marlin/src/lcd/menu/game/game.h +++ b/Marlin/src/lcd/menu/game/game.h @@ -22,9 +22,9 @@ #pragma once #include "../../../inc/MarlinConfigPre.h" -#include "../../dogm/ultralcd_DOGM.h" +#include "../../dogm/marlinui_DOGM.h" #include "../../lcdprint.h" -#include "../../ultralcd.h" +#include "../../marlinui.h" //#define MUTE_GAMES diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 89970225adbe..4dd66637f1a2 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -21,7 +21,7 @@ */ #pragma once -#include "../ultralcd.h" +#include "../marlinui.h" #include "../../libs/numtostr.h" #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 68a10245e951..642d9d84d94f 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -58,16 +58,16 @@ void menu_tmc(); void menu_backlash(); -#if ENABLED(DAC_STEPPER_CURRENT) +#if ENABLED(HAS_MOTOR_CURRENT_DAC) #include "../../feature/dac/stepper_dac.h" void menu_dac() { static xyze_uint8_t driverPercent; - LOOP_XYZE(i) driverPercent[i] = dac_current_get_percent((AxisEnum)i); + LOOP_XYZE(i) driverPercent[i] = stepper_dac.get_current_percent((AxisEnum)i); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); - #define EDIT_DAC_PERCENT(A) EDIT_ITEM(uint8, MSG_DAC_PERCENT_##A, &driverPercent[_AXIS(A)], 0, 100, []{ dac_current_set_percents(driverPercent); }) + #define EDIT_DAC_PERCENT(A) EDIT_ITEM(uint8, MSG_DAC_PERCENT_##A, &driverPercent[_AXIS(A)], 0, 100, []{ stepper_dac.set_current_percents(driverPercent); }) EDIT_DAC_PERCENT(X); EDIT_DAC_PERCENT(Y); EDIT_DAC_PERCENT(Z); @@ -568,7 +568,7 @@ void menu_advanced_settings() { SUBMENU(MSG_BACKLASH, menu_backlash); #endif - #if ENABLED(DAC_STEPPER_CURRENT) + #if ENABLED(HAS_MOTOR_CURRENT_DAC) SUBMENU(MSG_DRIVE_STRENGTH, menu_dac); #endif #if HAS_MOTOR_CURRENT_PWM diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index 705ec4161120..4efcb7c8eded 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -118,7 +118,7 @@ void lcd_delta_settings() { } void menu_delta_calibrate() { - const bool all_homed = all_axes_homed(); + TERN_(DELTA_CALIBRATION_MENU, const bool all_homed = all_axes_homed()); // Acquire ahead of loop START_MENU(); BACK_ITEM(MSG_MAIN); diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index bd3af0cec6b3..3ebe38235ddb 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -22,7 +22,7 @@ #pragma once #include "menu.h" -#include "../ultralcd.h" +#include "../marlinui.h" #include "../../gcode/queue.h" // for inject_P #include "../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index dff9895c6b64..2972920f34a7 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -57,28 +57,9 @@ static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) { if (ui.use_click()) return ui.goto_previous_screen_no_defer(); if (ui.encoderPosition && !ui.manual_move.processing) { - - // Start with no limits to movement - float min = current_position[axis] - 1000, - max = current_position[axis] + 1000; - - // Limit to software endstops, if enabled - #if HAS_SOFTWARE_ENDSTOPS - if (soft_endstops_enabled) switch (axis) { - case X_AXIS: - TERN_(MIN_SOFTWARE_ENDSTOP_X, min = soft_endstop.min.x); - TERN_(MAX_SOFTWARE_ENDSTOP_X, max = soft_endstop.max.x); - break; - case Y_AXIS: - TERN_(MIN_SOFTWARE_ENDSTOP_Y, min = soft_endstop.min.y); - TERN_(MAX_SOFTWARE_ENDSTOP_Y, max = soft_endstop.max.y); - break; - case Z_AXIS: - TERN_(MIN_SOFTWARE_ENDSTOP_Z, min = soft_endstop.min.z); - TERN_(MAX_SOFTWARE_ENDSTOP_Z, max = soft_endstop.max.z); - default: break; - } - #endif // HAS_SOFTWARE_ENDSTOPS + // Get motion limit from software endstops, if any + float min, max; + soft_endstop.get_manual_axis_limits(axis, min, max); // Delta limits XY based on the current offset from center // This assumes the center is 0,0 @@ -238,7 +219,7 @@ void menu_move() { BACK_ITEM(MSG_MOTION); #if BOTH(HAS_SOFTWARE_ENDSTOPS, SOFT_ENDSTOPS_MENU_ITEM) - EDIT_ITEM(bool, MSG_LCD_SOFT_ENDSTOPS, &soft_endstops_enabled); + EDIT_ITEM(bool, MSG_LCD_SOFT_ENDSTOPS, &soft_endstop._enabled); #endif if (NONE(IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed()) { @@ -358,7 +339,7 @@ void menu_motion() { // // Auto Z-Align // - #if ENABLED(Z_STEPPER_AUTO_ALIGN) + #if EITHER(Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION) GCODES_ITEM(MSG_AUTO_Z_ALIGN, PSTR("G34")); #endif diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index 87957e6207ef..4623b8f49242 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -48,16 +48,12 @@ float z_offset_backup, calculated_z_offset; TERN_(HAS_LEVELING, bool leveling_was_active); -TERN_(HAS_SOFTWARE_ENDSTOPS, bool store_soft_endstops_enabled); void prepare_for_calibration() { z_offset_backup = probe.offset.z; // Disable soft endstops for free Z movement - #if HAS_SOFTWARE_ENDSTOPS - store_soft_endstops_enabled = soft_endstops_enabled; - soft_endstops_enabled = false; - #endif + SET_SOFT_ENDSTOP_LOOSE(true); // Disable leveling for raw planner motion #if HAS_LEVELING @@ -68,7 +64,7 @@ void prepare_for_calibration() { void set_offset_and_go_back(const float &z) { probe.offset.z = z; - TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = store_soft_endstops_enabled); + SET_SOFT_ENDSTOP_LOOSE(false); TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); ui.goto_previous_screen_no_defer(); } @@ -92,16 +88,20 @@ void probe_offset_wizard_menu() { SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move_z( 0.1f); }); if ((SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) { - extern const char NUL_STR[]; - SUBMENU_P(NUL_STR, []{ _goto_manual_move_z(float(SHORT_MANUAL_Z_MOVE)); }); - MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780)); - 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)); + 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)); + #if DISABLED(HAS_GRAPHICAL_TFT) + extern const char NUL_STR[]; + SUBMENU_P(NUL_STR, []{ _goto_manual_move_z(float(SHORT_MANUAL_Z_MOVE)); }); + MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780)); lcd_put_u8str(tmp); - MENU_ITEM_ADDON_END(); + MENU_ITEM_ADDON_END(); + #else + SUBMENU_P(tmp, []{ _goto_manual_move_z(float(SHORT_MANUAL_Z_MOVE)); }); + #endif } ACTION_ITEM(MSG_BUTTON_DONE, []{ diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 0c70cd7e18e8..28ea54efbab1 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -31,7 +31,7 @@ #include "menu_item.h" #include "../../module/temperature.h" -#if FAN_COUNT > 1 || ENABLED(SINGLENOZZLE) +#if HAS_FAN || ENABLED(SINGLENOZZLE) #include "../../module/motion.h" #endif @@ -44,24 +44,17 @@ // void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t indb) { + UNUSED(e); UNUSED(indh); UNUSED(indb); #if HAS_HOTEND if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0) setTargetHotend(_MIN(thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, ui.material_preset[indh].hotend_temp), e); - #else - UNUSED(e); UNUSED(indh); #endif #if HAS_HEATED_BED if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp); - #else - UNUSED(indb); #endif #if HAS_FAN - set_fan_speed(( - #if FAN_COUNT > 1 - active_extruder < FAN_COUNT ? active_extruder : - #endif - 0), ui.material_preset[indh].fan_speed - ); + if (indh >= 0) + set_fan_speed(active_extruder < (FAN_COUNT) ? active_extruder : 0, ui.material_preset[indh].fan_speed); #endif ui.return_to_status(); } @@ -93,7 +86,9 @@ void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t i #endif - void do_preheat_end_m() { _preheat_end(editable.int8, 0); } + void do_preheat_end_m() { + _preheat_end(editable.int8, 0); + } #if HAS_MULTI_HOTEND || HAS_HEATED_BED diff --git a/Marlin/src/lcd/menu/menu_touch_screen.cpp b/Marlin/src/lcd/menu/menu_touch_screen.cpp index 96eae2298e6c..ea610e088639 100644 --- a/Marlin/src/lcd/menu/menu_touch_screen.cpp +++ b/Marlin/src/lcd/menu/menu_touch_screen.cpp @@ -25,7 +25,7 @@ #if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) #include "menu_item.h" -#include "../ultralcd.h" +#include "../marlinui.h" void touch_screen_calibration() { diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 6bf5c3a15d96..041786794eee 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -47,7 +47,7 @@ #include "../../feature/babystep.h" #include "../lcdprint.h" #if HAS_MARLINUI_U8GLIB - #include "../dogm/ultralcd_DOGM.h" + #include "../dogm/marlinui_DOGM.h" #endif void _lcd_babystep(const AxisEnum axis, PGM_P const msg) { diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 2cd300958f8b..f0f5c21beca2 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -188,11 +188,10 @@ void _lcd_ubl_edit_mesh() { */ void _lcd_ubl_validate_custom_mesh() { char ubl_lcd_gcode[24]; - const int16_t temp = TERN(HAS_HEATED_BED, custom_bed_temp, 0); sprintf_P(ubl_lcd_gcode, PSTR("G28\nG26 C P H%" PRIi16 TERN_(HAS_HEATED_BED, " B%" PRIi16)) , custom_hotend_temp #if HAS_HEATED_BED - , temp + , custom_bed_temp #endif ); queue.inject(ubl_lcd_gcode); diff --git a/Marlin/src/lcd/scaled_tft.h b/Marlin/src/lcd/scaled_tft.h index be846f70a9dd..54bf6f8d1342 100644 --- a/Marlin/src/lcd/scaled_tft.h +++ b/Marlin/src/lcd/scaled_tft.h @@ -43,8 +43,13 @@ #endif #ifndef TFT_PIXEL_OFFSET_X - #define TFT_PIXEL_OFFSET_X 48 + #if GRAPHICAL_TFT_UPSCALE == 2 + #define TFT_PIXEL_OFFSET_X 32 + #else + #define TFT_PIXEL_OFFSET_X 48 + #endif #endif + #ifndef TFT_PIXEL_OFFSET_Y - #define TFT_PIXEL_OFFSET_Y 48 + #define TFT_PIXEL_OFFSET_Y 32 // 32 is best for both 320x240 and 480x320 #endif diff --git a/Marlin/src/lcd/tft/tft.cpp b/Marlin/src/lcd/tft/tft.cpp index 81fe6788e7c7..fa3c2c241f79 100644 --- a/Marlin/src/lcd/tft/tft.cpp +++ b/Marlin/src/lcd/tft/tft.cpp @@ -25,173 +25,16 @@ #if HAS_GRAPHICAL_TFT #include "tft.h" -#include "st7735.h" -#include "st7789v.h" -#include "st7796s.h" -#include "r65105.h" -#include "ili9328.h" -#include "ili9341.h" -#include "ili9488.h" //#define DEBUG_GRAPHICAL_TFT #define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT) #include "../../core/debug_out.h" uint16_t TFT::buffer[]; -uint32_t TFT::lcd_id = 0xFFFFFFFF; void TFT::init() { - if (lcd_id != 0xFFFFFFFF) return; - io.Init(); - - #if TFT_DRIVER != AUTO - lcd_id = TFT_DRIVER; - #endif - - #if TFT_DRIVER == ST7735 - write_esc_sequence(st7735_init); - #elif TFT_DRIVER == ST7789 - write_esc_sequence(st7789v_init); - #elif TFT_DRIVER == ST7796 - write_esc_sequence(st7796s_init); - #elif TFT_DRIVER == R61505 - write_esc_sequence(r61505_init); - #elif TFT_DRIVER == ILI9328 - write_esc_sequence(ili9328_init); - #elif TFT_DRIVER == ILI9341 - write_esc_sequence(ili9341_init); - #elif TFT_DRIVER == ILI9488 - write_esc_sequence(ili9488_init); - #elif TFT_DRIVER == LERDGE_ST7796 - lcd_id = ST7796; - write_esc_sequence(lerdge_st7796s_init); - - #elif TFT_DRIVER == AUTO // autodetect - - lcd_id = io.GetID() & 0xFFFF; - - switch (lcd_id) { - case ST7796: // ST7796S 480x320 - DEBUG_ECHO_MSG(" ST7796S"); - write_esc_sequence(st7796s_init); - break; - case ST7789: // ST7789V 320x240 - DEBUG_ECHO_MSG(" ST7789V"); - write_esc_sequence(st7789v_init); - break; - case ST7735: // ST7735 160x128 - DEBUG_ECHO_MSG(" ST7735"); - write_esc_sequence(st7735_init); - break; - case R61505: // R61505U 320x240 - DEBUG_ECHO_MSG(" R61505U"); - write_esc_sequence(r61505_init); - break; - case ILI9328: // ILI9328 320x240 - DEBUG_ECHO_MSG(" ILI9328"); - write_esc_sequence(ili9328_init); - break; - case ILI9341: // ILI9341 320x240 - DEBUG_ECHO_MSG(" ILI9341"); - write_esc_sequence(ili9341_init); - break; - case ILI9488: // ILI9488 480x320 - DEBUG_ECHO_MSG(" ILI9488"); - write_esc_sequence(ili9488_init); - break; - default: - lcd_id = 0; - } - #else - #error Unsupported TFT driver - #endif -} - -void TFT::set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { - #ifdef OFFSET_X - Xmin += OFFSET_X; Xmax += OFFSET_X; - #endif - #ifdef OFFSET_Y - Ymin += OFFSET_Y; Ymax += OFFSET_Y; - #endif - - switch (lcd_id) { - case ST7735: // ST7735 160x128 - case ST7789: // ST7789V 320x240 - case ST7796: // ST7796 480x320 - case ILI9341: // ILI9341 320x240 - case ILI9488: // ILI9488 480x320 - io.DataTransferBegin(DATASIZE_8BIT); - - // CASET: Column Address Set - io.WriteReg(ILI9341_CASET); - io.WriteData((Xmin >> 8) & 0xFF); - io.WriteData(Xmin & 0xFF); - io.WriteData((Xmax >> 8) & 0xFF); - io.WriteData(Xmax & 0xFF); - - // RASET: Row Address Set - io.WriteReg(ILI9341_PASET); - io.WriteData((Ymin >> 8) & 0xFF); - io.WriteData(Ymin & 0xFF); - io.WriteData((Ymax >> 8) & 0xFF); - io.WriteData(Ymax & 0xFF); - - // RAMWR: Memory Write - io.WriteReg(ILI9341_RAMWR); - break; - case R61505: // R61505U 320x240 - case ILI9328: // ILI9328 320x240 - io.DataTransferBegin(DATASIZE_16BIT); - - // Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X - io.WriteReg(ILI9328_HASTART); - io.WriteData(Ymin); - io.WriteReg(ILI9328_HAEND); - io.WriteData(Ymax); - io.WriteReg(ILI9328_VASTART); - io.WriteData(Xmin); - io.WriteReg(ILI9328_VAEND); - io.WriteData(Xmax); - - io.WriteReg(ILI9328_HASET); - io.WriteData(Ymin); - io.WriteReg(ILI9328_VASET); - io.WriteData(Xmin); - - io.WriteReg(ILI9328_RAMWR); - break; - default: - break; - } - - io.DataTransferEnd(); -} - -void TFT::write_esc_sequence(const uint16_t *Sequence) { - uint16_t dataWidth, data; - - dataWidth = *Sequence++; - io.DataTransferBegin(dataWidth); - - for (;;) { - data = *Sequence++; - if (data != 0xFFFF) { - io.WriteData(data); - continue; - } - data = *Sequence++; - if (data == 0x7FFF) return; - if (data == 0xFFFF) - io.WriteData(0xFFFF); - else if (data & 0x8000) - delay(data & 0x7FFF); - else if ((data & 0xFF00) == 0) - io.WriteReg(data); - } - - io.DataTransferEnd(); + io.InitTFT(); } TFT tft; diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h index 6d429109c892..ed3d5e35c157 100644 --- a/Marlin/src/lcd/tft/tft.h +++ b/Marlin/src/lcd/tft/tft.h @@ -26,7 +26,7 @@ #include "tft_color.h" #include "tft_string.h" #include "tft_image.h" -#include "tft_io.h" +#include "../tft_io/tft_io.h" #include "../../inc/MarlinConfig.h" @@ -40,20 +40,6 @@ #error "Unsupported display resolution!" #endif -#define ST7735 0x89F0 -#define ST7789 0x8552 -#define ST7796 0x7796 -#define R61505 0x1505 -#define ILI9328 0x9328 -#define ILI9341 0x9341 -#define ILI9488 0x9488 -#define LERDGE_ST7796 0xFFFE -#define AUTO 0xFFFF - -#ifndef TFT_DRIVER - #define TFT_DRIVER AUTO -#endif - #ifndef TFT_BUFFER_SIZE #ifdef STM32F103xB #define TFT_BUFFER_SIZE 1024 @@ -71,14 +57,8 @@ #error "TFT_BUFFER_SIZE can not exceed 65535" #endif -#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x -#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF) -#define ESC_END 0xFFFF, 0x7FFF -#define ESC_FFFF 0xFFFF, 0xFFFF - class TFT { private: - static uint32_t lcd_id; static TFT_String string; static TFT_IO io; @@ -91,13 +71,11 @@ class TFT { static inline void set_font(const uint8_t *Font) { string.set_font(Font); } static inline void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); } - static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax); - static void write_esc_sequence(const uint16_t *Sequence); - static inline bool is_busy() { return io.isBusy(); } static inline void abort() { io.Abort(); } static inline void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); } static inline void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); } + static inline void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); } static inline void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); } static inline void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); } diff --git a/Marlin/src/lcd/tft/tft_io.h b/Marlin/src/lcd/tft/tft_io.h deleted file mode 100644 index bffe92b0ff30..000000000000 --- a/Marlin/src/lcd/tft/tft_io.h +++ /dev/null @@ -1,30 +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 . - * - */ -#pragma once - -#include "../../inc/MarlinConfig.h" - -#if HAS_SPI_TFT - #include HAL_PATH(../../HAL, tft/tft_spi.h) -#elif HAS_FSMC_TFT - #include HAL_PATH(../../HAL, tft/tft_fsmc.h) -#endif diff --git a/Marlin/src/lcd/tft/tft_string.cpp b/Marlin/src/lcd/tft/tft_string.cpp index 7e66c3d29cf8..663ed97c36c8 100644 --- a/Marlin/src/lcd/tft/tft_string.cpp +++ b/Marlin/src/lcd/tft/tft_string.cpp @@ -116,6 +116,17 @@ void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString) { eol(); } +void TFT_String::add(uint8_t *string) { + wchar_t wchar; + while (*string) { + string = get_utf8_value_cb(string, read_byte, &wchar); + if (wchar > 255) wchar |= 0x0080; + uint8_t ch = uint8_t(wchar & 0x00FF); + add_character(ch); + } + eol(); +} + void TFT_String::add_character(uint8_t character) { if (length < MAX_STRING_LENGTH) { data[length] = character; diff --git a/Marlin/src/lcd/tft/tft_string.h b/Marlin/src/lcd/tft/tft_string.h index d83d3af7027e..924d6de43027 100644 --- a/Marlin/src/lcd/tft/tft_string.h +++ b/Marlin/src/lcd/tft/tft_string.h @@ -85,7 +85,7 @@ class TFT_String { static void set(); static void add(uint8_t character) { add_character(character); eol(); } - static void add(uint8_t *string) { while (*string) { add_character(*string++); } eol(); } + static void add(uint8_t *string); static void add(uint8_t *string, int8_t index, uint8_t *itemString = NULL); static void set(uint8_t *string) { set(); add(string); }; static void set(uint8_t *string, int8_t index, const char *itemString = NULL) { set(); add(string, index, (uint8_t *)itemString); }; diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index d19cc4bf1d95..6dcddc5d560c 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -23,7 +23,7 @@ #include "touch.h" -#include "../ultralcd.h" // for ui methods +#include "../marlinui.h" // for ui methods #include "../menu/menu_item.h" // for touch_screen_calibration #include "../../module/temperature.h" @@ -40,16 +40,19 @@ int16_t Touch::x, Touch::y; touch_control_t Touch::controls[]; touch_control_t *Touch::current_control; uint16_t Touch::controls_count; -millis_t Touch::now = 0; -millis_t Touch::time_to_hold; -millis_t Touch::repeat_delay; -millis_t Touch::touch_time; +millis_t Touch::last_touch_ms = 0, + Touch::time_to_hold, + Touch::repeat_delay, + Touch::touch_time; TouchControlType Touch::touch_control_type = NONE; touch_calibration_t Touch::calibration; #if ENABLED(TOUCH_SCREEN_CALIBRATION) calibrationState Touch::calibration_state = CALIBRATION_NONE; touch_calibration_point_t Touch::calibration_points[4]; #endif +#if HAS_RESUME_CONTINUE + extern bool wait_for_user; +#endif void Touch::init() { calibration_reset(); @@ -76,24 +79,36 @@ void Touch::idle() { if (!enabled) return; - if (now == millis()) return; - now = millis(); + // Return if Touch::idle is called within the same millisecond + const millis_t now = millis(); + if (last_touch_ms == now) return; + last_touch_ms = now; if (get_point(&_x, &_y)) { + #if HAS_RESUME_CONTINUE + // UI is waiting for a click anywhere? + if (wait_for_user) { + touch_control_type = CLICK; + ui.lcd_clicked = true; + if (ui.external_control) wait_for_user = false; + return; + } + #endif + #if LCD_TIMEOUT_TO_STATUS - ui.return_to_status_ms = now + LCD_TIMEOUT_TO_STATUS; + ui.return_to_status_ms = last_touch_ms + LCD_TIMEOUT_TO_STATUS; #endif if (touch_time) { #if ENABLED(TOUCH_SCREEN_CALIBRATION) - if (touch_control_type == NONE && ELAPSED(now, touch_time + TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS) && ui.on_status_screen()) + if (touch_control_type == NONE && ELAPSED(last_touch_ms, touch_time + TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS) && ui.on_status_screen()) ui.goto_screen(touch_screen_calibration); #endif return; } - if (time_to_hold == 0) time_to_hold = now + MINIMUM_HOLD_TIME; - if (PENDING(now, time_to_hold)) return; + if (time_to_hold == 0) time_to_hold = last_touch_ms + MINIMUM_HOLD_TIME; + if (PENDING(last_touch_ms, time_to_hold)) return; if (x != 0 && y != 0) { if (current_control) { @@ -119,7 +134,7 @@ void Touch::idle() { } if (current_control == NULL) - touch_time = now; + touch_time = last_touch_ms; } x = _x; y = _y; @@ -272,7 +287,7 @@ void Touch::hold(touch_control_t *control, millis_t delay) { current_control = control; if (delay) { repeat_delay = delay > MIN_REPEAT_DELAY ? delay : MIN_REPEAT_DELAY; - time_to_hold = now + repeat_delay; + time_to_hold = last_touch_ms + repeat_delay; } ui.refresh(); } diff --git a/Marlin/src/lcd/tft/touch.h b/Marlin/src/lcd/tft/touch.h index 7d8f222918db..17aa5bdd97b9 100644 --- a/Marlin/src/lcd/tft/touch.h +++ b/Marlin/src/lcd/tft/touch.h @@ -140,10 +140,7 @@ class Touch { static touch_control_t *current_control; static uint16_t controls_count; - static millis_t now; - static millis_t time_to_hold; - static millis_t repeat_delay; - static millis_t touch_time; + static millis_t last_touch_ms, time_to_hold, repeat_delay, touch_time; static TouchControlType touch_control_type; static inline bool get_point(int16_t *x, int16_t *y); @@ -164,7 +161,13 @@ class Touch { static void reset() { controls_count = 0; touch_time = -1; current_control = NULL; } static void clear() { controls_count = 0; } static void idle(); - static bool is_clicked() { return touch_control_type == CLICK; } + static bool is_clicked() { + if (touch_control_type == CLICK) { + touch_control_type = NONE; + return true; + } + return false; + } static void disable() { enabled = false; } static void enable() { enabled = true; } diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index de8498c5ff0f..339c26cca27d 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -26,7 +26,7 @@ #include "ui_320x240.h" -#include "../ultralcd.h" +#include "../marlinui.h" #include "../menu/menu.h" #include "../../libs/numtostr.h" diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 549cbc4d9ba5..b67e041349b2 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -26,7 +26,7 @@ #include "ui_480x320.h" -#include "../ultralcd.h" +#include "../marlinui.h" #include "../menu/menu.h" #include "../../libs/numtostr.h" @@ -813,27 +813,9 @@ static void moveAxis(AxisEnum axis, const int8_t direction) { } if (!ui.manual_move.processing) { - // Start with no limits to movement - float min = current_position[axis] - 1000, - max = current_position[axis] + 1000; - - // Limit to software endstops, if enabled - #if HAS_SOFTWARE_ENDSTOPS - if (soft_endstops_enabled) switch (axis) { - case X_AXIS: - TERN_(MIN_SOFTWARE_ENDSTOP_X, min = soft_endstop.min.x); - TERN_(MAX_SOFTWARE_ENDSTOP_X, max = soft_endstop.max.x); - break; - case Y_AXIS: - TERN_(MIN_SOFTWARE_ENDSTOP_Y, min = soft_endstop.min.y); - TERN_(MAX_SOFTWARE_ENDSTOP_Y, max = soft_endstop.max.y); - break; - case Z_AXIS: - TERN_(MIN_SOFTWARE_ENDSTOP_Z, min = soft_endstop.min.z); - TERN_(MAX_SOFTWARE_ENDSTOP_Z, max = soft_endstop.max.z); - default: break; - } - #endif // HAS_SOFTWARE_ENDSTOPS + // Get motion limit from software endstops, if any + float min, max; + soft_endstop.get_manual_axis_limits(axis, min, max); // Delta limits XY based on the current offset from center // This assumes the center is 0,0 diff --git a/Marlin/src/lcd/tft/ili9328.h b/Marlin/src/lcd/tft_io/ili9328.h similarity index 87% rename from Marlin/src/lcd/tft/ili9328.h rename to Marlin/src/lcd/tft_io/ili9328.h index 85edfa7bee0a..b50517adfea5 100644 --- a/Marlin/src/lcd/tft/ili9328.h +++ b/Marlin/src/lcd/tft_io/ili9328.h @@ -21,7 +21,7 @@ */ #pragma once -#include "tft.h" +#include "tft_io.h" #include "../../inc/MarlinConfig.h" @@ -40,8 +40,31 @@ #define ILI9328_ETMOD_AM 0x0008 // 0 - Horizontal / 1 - Vertical // MKS Robin TFT v1.1 - 320x240 ; Cable on the left side -#define ILI9328_DRVCTL_DATA ILI9328_DRVCTL_SS -#define ILI9328_ETMOD_DATA ILI9328_ETMOD_BGR | ILI9328_ETMOD_ID1 | ILI9328_ETMOD_ID0 | ILI9328_ETMOD_AM + +#if TFT_ROTATION == TFT_ROTATE_180 + #define ILI9328_DRVCTL_DATA 0x0000 + #define ILI9328_GATE_SCANCTL1_DATA 0xA700 +#else + #define ILI9328_DRVCTL_DATA ILI9328_DRVCTL_SS + #define ILI9328_GATE_SCANCTL1_DATA 0x2700 +#endif + +/* +#define ILI9328_ETMOD_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9328_ETMOD_AM) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ILI9328_ETMOD_ID1) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ILI9328_ETMOD_ID0) +*/ + +#define ILI9328_ETMOD_ORIENTATION (ILI9328_ETMOD_AM | ILI9328_ETMOD_ID1 | ILI9328_ETMOD_ID0) + +#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR + #define ILI9328_ETMOD_COLOR ILI9328_ETMOD_BGR +#elif TFT_COLOR == TFT_COLOR_RGB + #define ILI9328_ETMOD_COLOR ILI9328_ETMOD_RGB +#endif + +#define ILI9328_ETMOD_DATA (ILI9328_ETMOD_ORIENTATION) | (ILI9328_ETMOD_COLOR) + #define ILI9328_RDDID 0x00 // ID code - 0x9328 #define ILI9328_DRVCTL 0x01 // Driver Output Control @@ -134,7 +157,7 @@ static const uint16_t ili9328_init[] = { ESC_REG(ILI9328_PWCTRL7), 0x0004, ESC_REG(ILI9328_FRMCTR), 0x000D, ESC_DELAY(50), - ESC_REG(ILI9328_GATE_SCANCTL1), 0x2700, + ESC_REG(ILI9328_GATE_SCANCTL1), ILI9328_GATE_SCANCTL1_DATA, ESC_REG(ILI9328_GATE_SCANCTL2), 0x0001, ESC_REG(ILI9328_GATE_SCANCTL3), 0x0000, ESC_REG(ILI9328_PLTPOS1), 0x0000, diff --git a/Marlin/src/lcd/tft/ili9341.h b/Marlin/src/lcd/tft_io/ili9341.h similarity index 94% rename from Marlin/src/lcd/tft/ili9341.h rename to Marlin/src/lcd/tft_io/ili9341.h index d4a493412fb2..dda326df6d5b 100644 --- a/Marlin/src/lcd/tft/ili9341.h +++ b/Marlin/src/lcd/tft_io/ili9341.h @@ -21,7 +21,7 @@ */ #pragma once -#include "tft.h" +#include "tft_io.h" #include "../../inc/MarlinConfig.h" @@ -38,13 +38,17 @@ #define ILI9341_ORIENTATION_LEFT ILI9341_MADCTL_MY | ILI9341_MADCTL_MX | ILI9341_MADCTL_MV // 320x240 ; Cable on the left side #define ILI9341_ORIENTATION_DOWN ILI9341_MADCTL_MX // 240x320 ; Cable on the upper side -#ifndef ILI9341_COLOR_RGB - #define ILI9341_COLOR_BGR -#endif -#ifndef ILI9341_ORIENTATION - #define ILI9341_ORIENTATION ILI9341_ORIENTATION_LEFT +#define ILI9341_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9341_MADCTL_MV) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ILI9341_MADCTL_MX) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ILI9341_MADCTL_MY) + +#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR + #define ILI9341_COLOR ILI9341_MADCTL_BGR +#elif TFT_COLOR == TFT_COLOR_RGB + #define ILI9341_COLOR ILI9341_MADCTL_RGB #endif -#define ILI9341_MADCTL_DATA (ILI9341_ORIENTATION | TERN(ILI9341_COLOR_BGR, ILI9341_MADCTL_BGR, ILI9341_MADCTL_RGB)) + +#define ILI9341_MADCTL_DATA (ILI9341_ORIENTATION) | (ILI9341_COLOR) #define ILI9341_NOP 0x00 // No Operation #define ILI9341_SWRESET 0x01 // Software Reset diff --git a/Marlin/src/lcd/tft/ili9488.h b/Marlin/src/lcd/tft_io/ili9488.h similarity index 93% rename from Marlin/src/lcd/tft/ili9488.h rename to Marlin/src/lcd/tft_io/ili9488.h index 19fdc78e0a5e..e71c0d16d775 100644 --- a/Marlin/src/lcd/tft/ili9488.h +++ b/Marlin/src/lcd/tft_io/ili9488.h @@ -21,7 +21,7 @@ */ #pragma once -#include "tft.h" +#include "tft_io.h" #include "../../inc/MarlinConfig.h" @@ -38,13 +38,17 @@ #define ILI9488_ORIENTATION_LEFT ILI9488_MADCTL_MY | ILI9488_MADCTL_MX | ILI9488_MADCTL_MV // 480x320 ; Cable on the left side #define ILI9488_ORIENTATION_DOWN ILI9488_MADCTL_MX // 320x480 ; Cable on the upper side -#ifndef ILI9488_COLOR_RGB - #define ILI9488_COLOR_BGR -#endif -#ifndef ILI9488_ORIENTATION - #define ILI9488_ORIENTATION ILI9488_ORIENTATION_LEFT +#define ILI9488_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9488_MADCTL_MV) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ILI9488_MADCTL_MX) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ILI9488_MADCTL_MY) + +#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR + #define ILI9488_COLOR ILI9488_MADCTL_BGR +#elif TFT_COLOR == TFT_COLOR_RGB + #define ILI9488_COLOR ILI9488_MADCTL_RGB #endif -#define ILI9488_MADCTL_DATA (ILI9488_ORIENTATION | TERN(ILI9488_COLOR_BGR, ILI9488_MADCTL_BGR, ILI9488_MADCTL_RGB)) + +#define ILI9488_MADCTL_DATA (ILI9488_ORIENTATION) | (ILI9488_COLOR) #define ILI9488_NOP 0x00 // No Operation #define ILI9488_SWRESET 0x01 // Software Reset diff --git a/Marlin/src/lcd/tft/r65105.h b/Marlin/src/lcd/tft_io/r65105.h similarity index 87% rename from Marlin/src/lcd/tft/r65105.h rename to Marlin/src/lcd/tft_io/r65105.h index 8d073f5d0d1c..8be2afe4423c 100644 --- a/Marlin/src/lcd/tft/r65105.h +++ b/Marlin/src/lcd/tft_io/r65105.h @@ -21,7 +21,7 @@ */ #pragma once -#include "tft.h" +#include "tft_io.h" #include "../../inc/MarlinConfig.h" @@ -42,9 +42,30 @@ #define R61505_DRVCTRL_GS 0x8000 // Gate Scan direction // MKS Robin TFT v1.1 - 320x240 ; Cable on the left side -#define R61505_DRVCTL_DATA R61505_DRVCTL_SS -#define R61505_ETMOD_DATA R61505_ETMOD_BGR | R61505_ETMOD_ID1 | R61505_ETMOD_ID0 | R61505_ETMOD_AM -#define R61505_DRVCTRL_GSDIR R61505_DRVCTRL_GS + +#if TFT_ROTATION == TFT_ROTATE_180 + #define R61505_DRVCTL_DATA 0x0000 + #define R61505_DRVCTRL_DATA (0x2700 | R61505_DRVCTRL_GS) +#else + #define R61505_DRVCTL_DATA R61505_DRVCTL_SS + #define R61505_DRVCTRL_DATA 0x2700 +#endif + +/* +#define R61505_ETMOD_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, R61505_ETMOD_AM) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, R61505_ETMOD_ID0) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, R61505_ETMOD_ID1) +*/ + +#define R61505_ETMOD_ORIENTATION (R61505_ETMOD_AM | R61505_ETMOD_ID0 | R61505_ETMOD_ID1) + +#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR + #define R61505_ETMOD_COLOR R61505_ETMOD_BGR +#elif TFT_COLOR == TFT_COLOR_RGB + #define R61505_ETMOD_COLOR R61505_ETMOD_RGB +#endif + +#define R61505_ETMOD_DATA (R61505_ETMOD_ORIENTATION) | (R61505_ETMOD_COLOR) #define R61505_RDDID 0x00 // ID code - 0x1505 @@ -141,7 +162,7 @@ static const uint16_t r61505_init[] = { ESC_REG(R61505_GAMCTRL9), 0x0700, ESC_REG(R61505_GAMCTRLA), 0x0A1F, - ESC_REG(R61505_DRVCTRL), R61505_DRVCTRL_GSDIR | 0x2700, + ESC_REG(R61505_DRVCTRL), R61505_DRVCTRL_DATA, ESC_REG(R61505_BASE_IMAGE_CTRL), 0x0001, ESC_REG(R61505_VSCROLL_CTRL), 0x0000, diff --git a/Marlin/src/lcd/tft_io/ssd1963.h b/Marlin/src/lcd/tft_io/ssd1963.h new file mode 100644 index 000000000000..4953a96233e8 --- /dev/null +++ b/Marlin/src/lcd/tft_io/ssd1963.h @@ -0,0 +1,131 @@ +/** + * 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 "tft_io.h" + +#include "../../inc/MarlinConfig.h" + +#define SSD1963_MADCTL_MY 0x80 // Row Address Order +#define SSD1963_MADCTL_MX 0x40 // Column Address Order +#define SSD1963_MADCTL_MV 0x20 // Row/Column Exchange +#define SSD1963_MADCTL_MH 0x10 // Horizontal Refresh Order +#define SSD1963_MADCTL_BGR 0x08 // RGB-BGR ORDER +#define SSD1963_MADCTL_RGB 0x00 +#define SSD1963_MADCTL_ML 0x04 // Vertical Refresh Order +#define SSD1963_MADCTL_FH 0x02 // Flip Horizontal +#define SSD1963_MADCTL_FV 0x01 // Flip Vertical + +#define SSD1963_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, SSD1963_MADCTL_MV) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, SSD1963_MADCTL_FH) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, SSD1963_MADCTL_FV) + +#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR + #define SSD1963_COLOR SSD1963_MADCTL_BGR +#elif TFT_COLOR == TFT_COLOR_RGB + #define SSD1963_COLOR SSD1963_MADCTL_RGB +#endif + +#define SSD1963_MADCTL_DATA (SSD1963_ORIENTATION) | (SSD1963_COLOR) + +#define SSD1963_NOP 0x00 // No Operation +#define SSD1963_SWRESET 0x01 // Software reset +#define SSD1963_RDDPM 0x0A // Read Display Power Mode +#define SSD1963_RDDMADCTL 0x0B // Read Display MADCTL +#define SSD1963_RDDCOLMOD 0x0C // Read Display Pixel Format +#define SSD1963_RDDIM 0x0D // Read Display Image Mode +#define SSD1963_RDDSM 0x0E // Read Display Signal Mode +#define SSD1963_SLPIN 0x10 // Sleep In +#define SSD1963_SLPOUT 0x11 // Sleep Out +#define SSD1963_PTLON 0x12 // Partial Display Mode On +#define SSD1963_NORON 0x13 // Normal Display Mode On +#define SSD1963_INVOFF 0x20 // Display Inversion Off +#define SSD1963_INVON 0x21 // Display Inversion On +#define SSD1963_GAMSET 0x26 // Gamma Set +#define SSD1963_DISPOFF 0x28 // Display Off +#define SSD1963_DISPON 0x29 // Display On +#define SSD1963_CASET 0x2A // Column Address Set +#define SSD1963_RASET 0x2B // Row Address Set +#define SSD1963_RAMWR 0x2C // Memory Write +#define SSD1963_RAMRD 0x2E // Memory Read +#define SSD1963_PTLAR 0x30 // Partial Area +#define SSD1963_VSCRDEF 0x33 // Vertical Scrolling Definition +#define SSD1963_TEOFF 0x34 // Tearing Effect Line OFF +#define SSD1963_TEON 0x35 // Tearing Effect Line ON +#define SSD1963_MADCTL 0x36 // Memory Data Access Control +#define SSD1963_VSCSAD 0x37 // Vertical Scroll Start Address of RAM +#define SSD1963_IDMOFF 0x38 // Idle Mode Off +#define SSD1963_IDMON 0x39 // Idle Mode On +#define SSD1963_WRMEMC 0x3C // Write Memory Continue +#define SSD1963_RDMEMC 0x3E // Read Memory Continue +#define SSD1963_STE 0x44 // Set Tear Scanline +#define SSD1963_GSCAN 0x45 // Get Scanline +#define SSD1963_WRDISBV 0x51 // Write Display Brightness +#define SSD1963_RDDISBV 0x52 // Read Display Brightness +#define SSD1963_WRCTRLD 0x53 // Write CTRL Display +#define SSD1963_RDCTRLD 0x54 // Read CTRL Value Display +#define SSD1963_WRCACE 0x55 // Write Content Adaptive Brightness Control and Color Enhancement +#define SSD1963_RDCABC 0x56 // Read Content Adaptive Brightness Control +#define SSD1963_WRCABCMB 0x5E // Write CABC Minimum Brightness +#define SSD1963_RDCABCMB 0x5F // Read CABC Minimum Brightness +#define SSD1963_RDABCSDR 0x68 // Read Automatic Brightness Control Self-Diagnostic Result +#define SSD1963_RDDDB 0xA1 // Read Device Descriptor Block +#define SSD1963_SLCDMODE 0xB0 // Set the LCD panel mode and resolution +#define SSD1963_SHSYNC 0xB4 // Set HSYNC +#define SSD1963_GHSYNC 0xB5 // Get HSYNC +#define SSD1963_SVSYNC 0xB6 // Set VSYNC +#define SSD1963_GVSYNC 0xB7 // Get VSYNC +#define SSD1963_SGPIOCFG 0xB8 // Set GPIO Conf +#define SSD1963_SGPIOV 0xBA // Set GPIO Value +#define SSD1963_SPWMCFG 0xBE // Set PWM Conf +#define SSD1963_GPWMCFG 0xBF // Get PWM Conf +#define SSD1963_SDBCCFG 0xD0 // Set Dynamic Back Light Config +#define SSD1963_GDBCCFG 0xD1 // Get Dynamic Back Light Config +#define SSD1963_PLLON 0xE0 // PLL Enable +#define SSD1963_PLLMN 0xE2 // Set PLL Multiplier +#define SSD1963_SLSHIFT 0xE6 // Set the LSHIFT (pixel clock) frequency +#define SSD1963_COLMOD 0xF0 // Interface Pixel Format + +static const uint16_t ssd1963_init[] = { + DATASIZE_8BIT, + ESC_REG(SSD1963_PLLMN), 0x0023, 0x0002, 0x0054, + ESC_REG(SSD1963_PLLON), 0x0001, ESC_DELAY(10), + ESC_REG(SSD1963_PLLON), 0x0003, ESC_DELAY(10), + ESC_REG(SSD1963_SWRESET), ESC_DELAY(100), + + ESC_REG(SSD1963_SLSHIFT), 0x0001, 0x001F, 0x00FF, + ESC_REG(SSD1963_SLCDMODE), 0x0020, 0x0000, 0x0001, 0x00DF, 0x0001, 0x000F, 0x0000, + ESC_REG(SSD1963_SHSYNC), 0x0002, 0x0013, 0x0000, 0x0008, 0x002B, 0x0000, 0x0002, 0x0000, + ESC_REG(SSD1963_SVSYNC), 0x0001, 0x0020, 0x0000, 0x0004, 0x000C, 0x0000, 0x0002, + ESC_REG(SSD1963_SGPIOV), 0x000F, + ESC_REG(SSD1963_SGPIOCFG), 0x0007, 0x0001, + + ESC_REG(SSD1963_MADCTL), SSD1963_MADCTL_DATA, + ESC_REG(SSD1963_COLMOD), 0x0003, ESC_DELAY(1),//RBG 565 + + ESC_REG(SSD1963_NORON), + ESC_REG(SSD1963_DISPON), + + ESC_REG(SSD1963_SPWMCFG), 0x0006, 0x00f0, 0x0001, 0x00f0, 0x0000, 0x0000, + ESC_REG(SSD1963_SDBCCFG), 0x000D, + ESC_END +}; diff --git a/Marlin/src/lcd/tft/st7735.h b/Marlin/src/lcd/tft_io/st7735.h similarity index 92% rename from Marlin/src/lcd/tft/st7735.h rename to Marlin/src/lcd/tft_io/st7735.h index 62f93d5044c0..1b0d23b6c4b9 100644 --- a/Marlin/src/lcd/tft/st7735.h +++ b/Marlin/src/lcd/tft_io/st7735.h @@ -21,7 +21,7 @@ */ #pragma once -#include "tft.h" +#include "tft_io.h" #include "../../inc/MarlinConfig.h" @@ -38,9 +38,17 @@ #define ST7735_ORIENTATION_LEFT ST7735_MADCTL_MV | ST7735_MADCTL_MX // 160x128 ; Cable on the left side #define ST7735_ORIENTATION_DOWN ST7735_MADCTL_MX | ST7735_MADCTL_MY // 128x160 ; Cable on the lower side -//#define ST7735_COLOR_BGR -#define ST7735_ORIENTATION ST7735_ORIENTATION_DOWN -#define ST7735_MADCTL_DATA (ST7735_ORIENTATION | TERN(ST7735_COLOR_BGR, ST7735_MADCTL_BGR, ST7735_MADCTL_RGB)) +#define ST7735_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7735_MADCTL_MV) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ST7735_MADCTL_MX) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ST7735_MADCTL_MY) + +#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_RGB + #define ST7735_COLOR ST7735_MADCTL_RGB +#elif TFT_COLOR == TFT_COLOR_BGR + #define ST7735_COLOR ST7735_MADCTL_BGR +#endif + +#define ST7735_MADCTL_DATA (ST7735_ORIENTATION) | (ST7735_COLOR) #define ST7735_NOP 0x00 // No Operation #define ST7735_SWRESET 0x01 // Software reset diff --git a/Marlin/src/lcd/tft/st7789v.h b/Marlin/src/lcd/tft_io/st7789v.h similarity index 93% rename from Marlin/src/lcd/tft/st7789v.h rename to Marlin/src/lcd/tft_io/st7789v.h index 67da67966d2c..d0cf969c66ce 100644 --- a/Marlin/src/lcd/tft/st7789v.h +++ b/Marlin/src/lcd/tft_io/st7789v.h @@ -21,7 +21,7 @@ */ #pragma once -#include "tft.h" +#include "tft_io.h" #include "../../inc/MarlinConfig.h" @@ -38,11 +38,17 @@ #define ST7789V_ORIENTATION_LEFT ST7789V_MADCTL_MY | ST7789V_MADCTL_MV // 320x240 ; Cable on the left side #define ST7789V_ORIENTATION_DOWN 0 // 240x320 ; Cable on the lower side -//#define ST7789V_COLOR_BGR -#ifndef ST7789V_ORIENTATION - #define ST7789V_ORIENTATION ST7789V_ORIENTATION_LEFT +#define ST7789V_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7789V_MADCTL_MV) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ST7789V_MADCTL_MX) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ST7789V_MADCTL_MY) + +#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_RGB + #define ST7789V_COLOR ST7789V_MADCTL_RGB +#elif TFT_COLOR == TFT_COLOR_BGR + #define ST7789V_COLOR ST7789V_MADCTL_BGR #endif -#define ST7789V_MADCTL_DATA (ST7789V_ORIENTATION | TERN(ST7789V_COLOR_BGR, ST7789V_MADCTL_BGR, ST7789V_MADCTL_RGB)) + +#define ST7789V_MADCTL_DATA (ST7789V_ORIENTATION) | (ST7789V_COLOR) #define ST7789V_NOP 0x00 // No Operation #define ST7789V_SWRESET 0x01 // Software reset diff --git a/Marlin/src/lcd/tft/st7796s.h b/Marlin/src/lcd/tft_io/st7796s.h similarity index 93% rename from Marlin/src/lcd/tft/st7796s.h rename to Marlin/src/lcd/tft_io/st7796s.h index 10452293de0b..8653a49ca2ef 100644 --- a/Marlin/src/lcd/tft/st7796s.h +++ b/Marlin/src/lcd/tft_io/st7796s.h @@ -21,7 +21,7 @@ */ #pragma once -#include "tft.h" +#include "tft_io.h" #include "../../inc/MarlinConfig.h" @@ -33,9 +33,17 @@ #define ST7796S_MADCTL_RGB 0x00 #define ST7796S_MADCTL_MH 0x04 // Horizontal Refresh Order -#define ST7796S_COLOR_BGR -#define ST7796S_ORIENTATION ST7796S_MADCTL_MV -#define ST7796S_MADCTL_DATA (ST7796S_ORIENTATION | TERN(ST7796S_COLOR_BGR, ST7796S_MADCTL_BGR, ST7796S_MADCTL_RGB)) +#define ST7796S_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7796S_MADCTL_MV) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ST7796S_MADCTL_MX) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ST7796S_MADCTL_MY) + +#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR + #define ST7796S_COLOR ST7796S_MADCTL_BGR +#elif TFT_COLOR == TFT_COLOR_RGB + #define ST7796S_COLOR ST7796S_MADCTL_RGB +#endif + +#define ST7796S_MADCTL_DATA (ST7796S_ORIENTATION) | (ST7796S_COLOR) #define ST7796S_NOP 0x00 // No Operation #define ST7796S_SWRESET 0x01 // Software reset diff --git a/Marlin/src/lcd/tft_io/tft_io.cpp b/Marlin/src/lcd/tft_io/tft_io.cpp new file mode 100644 index 000000000000..cd535458a181 --- /dev/null +++ b/Marlin/src/lcd/tft_io/tft_io.cpp @@ -0,0 +1,226 @@ +/** + * 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 "tft_io.h" + +#if HAS_SPI_TFT || HAS_FSMC_TFT + +#include "st7735.h" +#include "st7789v.h" +#include "st7796s.h" +#include "r65105.h" +#include "ili9328.h" +#include "ili9341.h" +#include "ili9488.h" +#include "ssd1963.h" + +#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT) +#include "../../core/debug_out.h" + +TFT_IO_DRIVER TFT_IO::io; +uint32_t TFT_IO::lcd_id = 0xFFFFFFFF; + +void TFT_IO::InitTFT() { +if (lcd_id != 0xFFFFFFFF) return; + + #if PIN_EXISTS(TFT_BACKLIGHT) + OUT_WRITE(TFT_BACKLIGHT_PIN, LOW); + #endif + + #if PIN_EXISTS(TFT_RESET) + OUT_WRITE(TFT_RESET_PIN, HIGH); + delay(10); + OUT_WRITE(TFT_RESET_PIN, LOW); + delay(10); + OUT_WRITE(TFT_RESET_PIN, HIGH); + #endif + + #if PIN_EXISTS(TFT_BACKLIGHT) + OUT_WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); + #endif + + // io.Init(); + delay(100); + + #if TFT_DRIVER != AUTO + lcd_id = TFT_DRIVER; + #endif + + #if TFT_DRIVER == ST7735 + write_esc_sequence(st7735_init); + #elif TFT_DRIVER == SSD1963 + write_esc_sequence(ssd1963_init); + #elif TFT_DRIVER == ST7789 + write_esc_sequence(st7789v_init); + #elif TFT_DRIVER == ST7796 + write_esc_sequence(st7796s_init); + #elif TFT_DRIVER == R61505 + write_esc_sequence(r61505_init); + #elif TFT_DRIVER == ILI9328 + write_esc_sequence(ili9328_init); + #elif TFT_DRIVER == ILI9341 + write_esc_sequence(ili9341_init); + #elif TFT_DRIVER == ILI9488 + write_esc_sequence(ili9488_init); + #elif TFT_DRIVER == LERDGE_ST7796 + lcd_id = ST7796; + write_esc_sequence(lerdge_st7796s_init); + + #elif TFT_DRIVER == AUTO // autodetect + + lcd_id = io.GetID() & 0xFFFF; + + switch (lcd_id) { + case ST7796: // ST7796S 480x320 + DEBUG_ECHO_MSG(" ST7796S"); + write_esc_sequence(st7796s_init); + break; + case ST7789: // ST7789V 320x240 + DEBUG_ECHO_MSG(" ST7789V"); + write_esc_sequence(st7789v_init); + break; + case SSD1963: // SSD1963 + DEBUG_ECHO_MSG(" SSD1963"); + write_esc_sequence(ssd1963_init); + break; + case ST7735: // ST7735 160x128 + DEBUG_ECHO_MSG(" ST7735"); + write_esc_sequence(st7735_init); + break; + case R61505: // R61505U 320x240 + DEBUG_ECHO_MSG(" R61505U"); + write_esc_sequence(r61505_init); + break; + case ILI9328: // ILI9328 320x240 + DEBUG_ECHO_MSG(" ILI9328"); + write_esc_sequence(ili9328_init); + break; + case ILI9341: // ILI9341 320x240 + DEBUG_ECHO_MSG(" ILI9341"); + write_esc_sequence(ili9341_init); + break; + case ILI9488: // ILI9488 480x320 + case ILI9488_ID1: // 0x8066 ILI9488 480x320 + DEBUG_ECHO_MSG(" ILI9488"); + write_esc_sequence(ili9488_init); + break; + default: + lcd_id = 0; + } + #else + #error Unsupported TFT driver + #endif + + #if PIN_EXISTS(TFT_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT) + OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH); + #endif +} + +void TFT_IO::set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { + #ifdef OFFSET_X + Xmin += OFFSET_X; Xmax += OFFSET_X; + #endif + #ifdef OFFSET_Y + Ymin += OFFSET_Y; Ymax += OFFSET_Y; + #endif + + switch (lcd_id) { + case ST7735: // ST7735 160x128 + case ST7789: // ST7789V 320x240 + case ST7796: // ST7796 480x320 + case ILI9341: // ILI9341 320x240 + case ILI9488: // ILI9488 480x320 + case SSD1963: // SSD1963 + case ILI9488_ID1: // 0x8066 ILI9488 480x320 + io.DataTransferBegin(DATASIZE_8BIT); + + // CASET: Column Address Set + io.WriteReg(ILI9341_CASET); + io.WriteData((Xmin >> 8) & 0xFF); + io.WriteData(Xmin & 0xFF); + io.WriteData((Xmax >> 8) & 0xFF); + io.WriteData(Xmax & 0xFF); + + // RASET: Row Address Set + io.WriteReg(ILI9341_PASET); + io.WriteData((Ymin >> 8) & 0xFF); + io.WriteData(Ymin & 0xFF); + io.WriteData((Ymax >> 8) & 0xFF); + io.WriteData(Ymax & 0xFF); + + // RAMWR: Memory Write + io.WriteReg(ILI9341_RAMWR); + break; + case R61505: // R61505U 320x240 + case ILI9328: // ILI9328 320x240 + io.DataTransferBegin(DATASIZE_16BIT); + + // Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X + io.WriteReg(ILI9328_HASTART); + io.WriteData(Ymin); + io.WriteReg(ILI9328_HAEND); + io.WriteData(Ymax); + io.WriteReg(ILI9328_VASTART); + io.WriteData(Xmin); + io.WriteReg(ILI9328_VAEND); + io.WriteData(Xmax); + + io.WriteReg(ILI9328_HASET); + io.WriteData(Ymin); + io.WriteReg(ILI9328_VASET); + io.WriteData(Xmin); + + io.WriteReg(ILI9328_RAMWR); + break; + default: + break; + } + + io.DataTransferEnd(); +} + +void TFT_IO::write_esc_sequence(const uint16_t *Sequence) { + uint16_t dataWidth, data; + + dataWidth = *Sequence++; + io.DataTransferBegin(dataWidth); + + for (;;) { + data = *Sequence++; + if (data != 0xFFFF) { + io.WriteData(data); + continue; + } + data = *Sequence++; + if (data == 0x7FFF) return; + if (data == 0xFFFF) + io.WriteData(0xFFFF); + else if (data & 0x8000) + delay(data & 0x7FFF); + else if ((data & 0xFF00) == 0) + io.WriteReg(data); + } + + io.DataTransferEnd(); +} + +#endif // HAS_SPI_TFT || HAS_FSMC_TFT diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h new file mode 100644 index 000000000000..63d6936ac0b8 --- /dev/null +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -0,0 +1,124 @@ +/** + * 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" + +#if HAS_SPI_TFT || HAS_FSMC_TFT + +#if HAS_SPI_TFT + #include HAL_PATH(../../HAL, tft/tft_spi.h) +#elif HAS_FSMC_TFT + #include HAL_PATH(../../HAL, tft/tft_fsmc.h) +#else + #error "TFT IO only supports SPI or FSMC interface" +#endif + +#define TFT_EXCHANGE_XY (1UL << 1) +#define TFT_INVERT_X (1UL << 2) +#define TFT_INVERT_Y (1UL << 3) + +#define TFT_NO_ROTATION (0x00) +#define TFT_ROTATE_90 (TFT_EXCHANGE_XY | TFT_INVERT_X) +#define TFT_ROTATE_180 (TFT_INVERT_X | TFT_INVERT_Y) +#define TFT_ROTATE_270 (TFT_EXCHANGE_XY | TFT_INVERT_Y) + +#define TFT_MIRROR_X (TFT_INVERT_Y) +#define TFT_MIRROR_Y (TFT_INVERT_X) + +#define TFT_ROTATE_90_MIRROR_X (TFT_ROTATE_90 ^ TFT_INVERT_Y) +#define TFT_ROTATE_90_MIRROR_Y (TFT_ROTATE_90 ^ TFT_INVERT_X) + +#define TFT_ROTATE_180_MIRROR_X (TFT_ROTATE_180 ^ TFT_INVERT_Y) +#define TFT_ROTATE_180_MIRROR_Y (TFT_ROTATE_180 ^ TFT_INVERT_X) + +#define TFT_ROTATE_270_MIRROR_X (TFT_ROTATE_270 ^ TFT_INVERT_Y) +#define TFT_ROTATE_270_MIRROR_Y (TFT_ROTATE_270 ^ TFT_INVERT_X) + +// TFT_ROTATION is user configurable +#ifndef TFT_ROTATION + #define TFT_ROTATION TFT_NO_ROTATION +#endif + + +// TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION +#define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION)) + +#define TFT_COLOR_RGB (1UL << 3) +#define TFT_COLOR_BGR (1UL << 4) + +// Each TFT Driver is responsible for its default color mode. +// #ifndef TFT_COLOR +// #define TFT_COLOR TFT_COLOR_RGB +// #endif + +#define SSD1963 0x5761 +#define ST7735 0x89F0 +#define ST7789 0x8552 +#define ST7796 0x7796 +#define R61505 0x1505 +#define ILI9328 0x9328 +#define ILI9341 0x9341 +#define ILI9488 0x9488 +#define ILI9488_ID1 0x8066 //Some ILI9488 have 0x8066 in the 0x04 +#define LERDGE_ST7796 0xFFFE +#define AUTO 0xFFFF + +#ifndef TFT_DRIVER + #define TFT_DRIVER AUTO +#endif + +#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x +#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF) +#define ESC_END 0xFFFF, 0x7FFF +#define ESC_FFFF 0xFFFF, 0xFFFF + +class TFT_IO { +public: + static TFT_IO_DRIVER io; + + static void InitTFT(); + static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax); + static void write_esc_sequence(const uint16_t *Sequence); + + // Deletaged methods + inline static void Init() { io.Init(); }; + inline static bool isBusy() { return io.isBusy(); }; + inline static void Abort() { io.Abort(); }; + inline static uint32_t GetID() { return io.GetID(); }; + + inline static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) { io.DataTransferBegin(DataWidth); } + inline static void DataTransferEnd() { io.DataTransferEnd(); }; + // inline static void DataTransferAbort() { io.DataTransferAbort(); }; + + inline static void WriteData(uint16_t Data) { io.WriteData(Data); }; + inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); }; + + inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }; + // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } + inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); }; + +protected: + static uint32_t lcd_id; +}; + +#endif // HAS_SPI_TFT || HAS_FSMC_TFT diff --git a/Marlin/src/lcd/touch/touch_buttons.cpp b/Marlin/src/lcd/touch/touch_buttons.cpp index c97018c379c0..eeb22aae6eee 100644 --- a/Marlin/src/lcd/touch/touch_buttons.cpp +++ b/Marlin/src/lcd/touch/touch_buttons.cpp @@ -27,7 +27,7 @@ #include HAL_PATH(../../HAL, tft/xpt2046.h) XPT2046 touchIO; -#include "../../lcd/ultralcd.h" // For EN_C bit mask +#include "../../lcd/marlinui.h" // For EN_C bit mask /** * Draw and Touch processing @@ -82,7 +82,7 @@ uint8_t TouchButtons::read_buttons() { 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) + #if (TFT_ROTATION & TFT_ROTATE_180) x = TOUCH_SENSOR_WIDTH - x; y = TOUCH_SENSOR_HEIGHT - y; #endif diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp index dd85473e9802..8914bc560eee 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp @@ -62,11 +62,11 @@ const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR , (INVERT_X_DIR) // X2 #if ENABLED(X_DUAL_STEPPER_DRIVERS) - ^ (INVERT_X2_VS_X_DIR) + ^ ENABLED(INVERT_X2_VS_X_DIR) #endif , (INVERT_Y_DIR) // Y2 #if ENABLED(Y_DUAL_STEPPER_DRIVERS) - ^ (INVERT_Y2_VS_Y_DIR) + ^ ENABLED(INVERT_Y2_VS_Y_DIR) #endif , INVERT_Z_DIR, INVERT_Z_DIR, INVERT_Z_DIR // Z2,Z3,Z4 diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index f93e5524813a..10021005e5b3 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -161,7 +161,7 @@ Nozzle nozzle; LIMIT( end[arrPos].A, soft_endstop.min.A, soft_endstop.max.A); \ }while(0) - if (soft_endstops_enabled) { + if (soft_endstop.enabled()) { LIMIT_AXIS(x); LIMIT_AXIS(y); diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index df6cae6e0a97..93238a69e364 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -34,7 +34,7 @@ // For homing: #include "planner.h" #include "endstops.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #include "../MarlinCore.h" #if HAS_BED_PROBE diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 712182a0ea40..928c9ad8b9d0 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -30,7 +30,7 @@ #include "../MarlinCore.h" #include "../sd/cardreader.h" #include "temperature.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE) #include HAL_PATH(../HAL, endstop_interrupts.h) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index b904309018d6..03c8ddc46296 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -36,7 +36,7 @@ #if IS_SCARA #include "../libs/buzzer.h" - #include "../lcd/ultralcd.h" + #include "../lcd/marlinui.h" #endif #if HAS_BED_PROBE @@ -52,7 +52,7 @@ #endif #if HAS_DISPLAY - #include "../lcd/ultralcd.h" + #include "../lcd/marlinui.h" #endif #if HAS_FILAMENT_SENSOR @@ -510,7 +510,7 @@ void do_z_clearance(const float &zclear, const bool z_known/*=true*/, const bool const bool rel = raise_on_unknown && !z_known; float zdest = zclear + (rel ? current_position.z : 0.0f); if (!lower_allowed) NOLESS(zdest, current_position.z); - do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), MMM_TO_MMS(Z_PROBE_SPEED_FAST)); + do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), MMM_TO_MMS(TERN(HAS_BED_PROBE, Z_PROBE_SPEED_FAST, HOMING_FEEDRATE_Z))); } // @@ -534,10 +534,9 @@ void restore_feedrate_and_scaling() { #if HAS_SOFTWARE_ENDSTOPS - bool soft_endstops_enabled = true; - // Software Endstops are based on the configured limits. - axis_limits_t soft_endstop = { + soft_endstops_t soft_endstop = { + true, false, { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }, { X_MAX_POS, Y_MAX_POS, Z_MAX_POS } }; @@ -570,7 +569,7 @@ void restore_feedrate_and_scaling() { soft_endstop.min.x = X2_MIN_POS; soft_endstop.max.x = dual_max_x; } - else if (dxc_is_duplicating()) { + else if (idex_is_duplicating()) { // In Duplication Mode, T0 can move as far left as X1_MIN_POS // but not so far to the right that T1 would move past the end soft_endstop.min.x = X1_MIN_POS; @@ -624,9 +623,9 @@ void restore_feedrate_and_scaling() { #endif - if (DEBUGGING(LEVELING)) - SERIAL_ECHOLNPAIR("Axis ", XYZ_CHAR(axis), " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]); -} + if (DEBUGGING(LEVELING)) + SERIAL_ECHOLNPAIR("Axis ", XYZ_CHAR(axis), " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]); + } /** * Constrain the given coordinates to the software endstops. @@ -636,7 +635,7 @@ void restore_feedrate_and_scaling() { */ void apply_motion_limits(xyz_pos_t &target) { - if (!soft_endstops_enabled) return; + if (!soft_endstop._enabled) return; #if IS_KINEMATIC @@ -688,7 +687,11 @@ void restore_feedrate_and_scaling() { } } -#endif // HAS_SOFTWARE_ENDSTOPS +#else // !HAS_SOFTWARE_ENDSTOPS + + soft_endstops_t soft_endstop; + +#endif // !HAS_SOFTWARE_ENDSTOPS #if !UBL_SEGMENTED @@ -929,8 +932,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { #endif // !UBL_SEGMENTED #if HAS_DUPLICATION_MODE - bool extruder_duplication_enabled, - mirrored_duplication_mode; + bool extruder_duplication_enabled; #if ENABLED(MULTI_NOZZLE_DUPLICATION) uint8_t duplication_e_mask; // = 0 #endif @@ -939,12 +941,13 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { #if ENABLED(DUAL_X_CARRIAGE) DualXMode dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; - float inactive_extruder_x_pos = X2_MAX_POS, // used in mode 0 & 1 - duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2 - xyz_pos_t raised_parked_position; // used in mode 1 - bool active_extruder_parked = false; // used in mode 1 & 2 - millis_t delayed_move_time = 0; // used in mode 1 - int16_t duplicate_extruder_temp_offset = 0; // used in mode 2 + float inactive_extruder_x = X2_MAX_POS, // Used in mode 0 & 1 + duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // Used in mode 2 + xyz_pos_t raised_parked_position; // Used in mode 1 + bool active_extruder_parked = false; // Used in mode 1 & 2 + millis_t delayed_move_time = 0; // Used in mode 1 + int16_t duplicate_extruder_temp_offset = 0; // Used in mode 2 + bool idex_mirrored_mode = false; // Used in mode 3 float x_home_pos(const uint8_t extruder) { if (extruder == 0) @@ -959,6 +962,23 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { return hotend_offset[1].x > 0 ? hotend_offset[1].x : X2_HOME_POS; } + void idex_set_mirrored_mode(const bool mirr) { + idex_mirrored_mode = mirr; + stepper.set_directions(); + } + + void set_duplication_enabled(const bool dupe, const int8_t tool_index/*=-1*/) { + extruder_duplication_enabled = dupe; + if (tool_index >= 0) active_extruder = tool_index; + stepper.set_directions(); + } + + void idex_set_parked(const bool park/*=true*/) { + delayed_move_time = 0; + active_extruder_parked = park; + if (park) raised_parked_position = current_position; // Remember current raised toolhead position for use by unpark + } + /** * Prepare a linear move in a dual X axis setup * @@ -967,9 +987,10 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { inline bool dual_x_carriage_unpark() { if (active_extruder_parked) { switch (dual_x_carriage_mode) { - case DXC_FULL_CONTROL_MODE: - break; - case DXC_AUTO_PARK_MODE: + + case DXC_FULL_CONTROL_MODE: break; + + case DXC_AUTO_PARK_MODE: { if (current_position.e == destination.e) { // This is a travel move (with no extrusion) // Skip it, but keep track of the current position @@ -981,23 +1002,27 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { return true; } } - // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower - - #define CUR_X current_position.x - #define CUR_Y current_position.y - #define CUR_Z current_position.z - #define CUR_E current_position.e - #define RAISED_X raised_parked_position.x - #define RAISED_Y raised_parked_position.y - #define RAISED_Z raised_parked_position.z - - if ( planner.buffer_line(RAISED_X, RAISED_Y, RAISED_Z, CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder)) - if (planner.buffer_line( CUR_X, CUR_Y, RAISED_Z, CUR_E, PLANNER_XY_FEEDRATE(), active_extruder)) - line_to_current_position(planner.settings.max_feedrate_mm_s[Z_AXIS]); - delayed_move_time = 0; - active_extruder_parked = false; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Clear active_extruder_parked"); - break; + // + // Un-park the active extruder + // + const feedRate_t fr_zfast = planner.settings.max_feedrate_mm_s[Z_AXIS]; + #define CURPOS current_position + #define RAISED raised_parked_position + // 1. Move to the raised parked XYZ. Presumably the tool is already at XY. + if (planner.buffer_line(RAISED.x, RAISED.y, RAISED.z, CURPOS.e, fr_zfast, active_extruder)) { + // 2. Move to the current native XY and raised Z. Presumably this is a null move. + if (planner.buffer_line(CURPOS.x, CURPOS.y, RAISED.z, CURPOS.e, PLANNER_XY_FEEDRATE(), active_extruder)) { + // 3. Lower Z back down + line_to_current_position(fr_zfast); + } + } + planner.synchronize(); // paranoia + stepper.set_directions(); + + idex_set_parked(false); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("idex_set_parked(false)"); + } break; + case DXC_MIRRORED_MODE: case DXC_DUPLICATION_MODE: if (active_extruder == 0) { @@ -1005,22 +1030,23 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) new_pos.x += duplicate_extruder_x_offset; else - new_pos.x = inactive_extruder_x_pos; - // move duplicate extruder into correct duplication position. - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Set planner X", inactive_extruder_x_pos, " ... Line to X", new_pos.x); - planner.set_position_mm(inactive_extruder_x_pos, current_position.y, current_position.z, current_position.e); + new_pos.x = inactive_extruder_x; + // Move duplicate extruder into correct duplication position. + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Set planner X", inactive_extruder_x, " ... Line to X", new_pos.x); + planner.set_position_mm(inactive_extruder_x, current_position.y, current_position.z, current_position.e); if (!planner.buffer_line(new_pos, planner.settings.max_feedrate_mm_s[X_AXIS], 1)) break; + planner.synchronize(); sync_plan_position(); - extruder_duplication_enabled = true; - active_extruder_parked = false; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Set extruder_duplication_enabled\nClear active_extruder_parked"); + + set_duplication_enabled(true); + idex_set_parked(false); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("set_duplication_enabled(true)\nidex_set_parked(false)"); } else if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Active extruder not 0"); break; } } - stepper.set_directions(); return false; } @@ -1126,8 +1152,9 @@ bool homing_needed_error(uint8_t axis_bits/*=0x07*/) { * Homing bump feedrate (mm/s) */ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) { - if (TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS)) - return MMM_TO_MMS(Z_PROBE_SPEED_SLOW); + #if HOMING_Z_WITH_PROBE + if (axis == Z_AXIS) return MMM_TO_MMS(Z_PROBE_SPEED_SLOW); + #endif static const uint8_t homing_bump_divisor[] PROGMEM = HOMING_BUMP_DIVISOR; uint8_t hbd = pgm_read_byte(&homing_bump_divisor[axis]); if (hbd < 1) { @@ -1588,7 +1615,7 @@ void homeaxis(const AxisEnum axis) { // When homing Z with probe respect probe clearance const bool use_probe_bump = TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS && home_bump_mm(Z_AXIS)); const float bump = axis_home_dir * ( - use_probe_bump ? _MAX(Z_CLEARANCE_BETWEEN_PROBES, home_bump_mm(Z_AXIS)) : home_bump_mm(axis) + use_probe_bump ? _MAX(TERN0(HOMING_Z_WITH_PROBE, Z_CLEARANCE_BETWEEN_PROBES), home_bump_mm(Z_AXIS)) : home_bump_mm(axis) ); // If a second homing move is configured... diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 2b108b053177..5a8a8e004505 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -148,26 +148,59 @@ inline float home_bump_mm(const AxisEnum axis) { constexpr xyz_pos_t hotend_offset[1] = { { 0 } }; #endif -typedef struct { xyz_pos_t min, max; } axis_limits_t; #if HAS_SOFTWARE_ENDSTOPS - extern bool soft_endstops_enabled; - extern axis_limits_t soft_endstop; + + typedef struct { + bool _enabled, _loose; + bool enabled() { return _enabled && !_loose; } + + xyz_pos_t min, max; + void get_manual_axis_limits(const AxisEnum axis, float &amin, float &amax) { + amin = -100000; amax = 100000; // "No limits" + #if HAS_SOFTWARE_ENDSTOPS + if (enabled()) switch (axis) { + case X_AXIS: + TERN_(MIN_SOFTWARE_ENDSTOP_X, amin = min.x); + TERN_(MAX_SOFTWARE_ENDSTOP_X, amax = max.x); + break; + case Y_AXIS: + TERN_(MIN_SOFTWARE_ENDSTOP_Y, amin = min.y); + TERN_(MAX_SOFTWARE_ENDSTOP_Y, amax = max.y); + break; + case Z_AXIS: + TERN_(MIN_SOFTWARE_ENDSTOP_Z, amin = min.z); + TERN_(MAX_SOFTWARE_ENDSTOP_Z, amax = max.z); + default: break; + } + #endif + } + } soft_endstops_t; + + extern soft_endstops_t soft_endstop; void apply_motion_limits(xyz_pos_t &target); void update_software_endstops(const AxisEnum axis #if HAS_HOTEND_OFFSET , const uint8_t old_tool_index=0, const uint8_t new_tool_index=0 #endif ); - #define TEMPORARY_SOFT_ENDSTOP_STATE(enable) REMEMBER(tes, soft_endstops_enabled, enable); -#else - constexpr bool soft_endstops_enabled = false; - //constexpr axis_limits_t soft_endstop = { - // { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }, - // { X_MAX_POS, Y_MAX_POS, Z_MAX_POS } }; - #define apply_motion_limits(V) NOOP + #define SET_SOFT_ENDSTOP_LOOSE(loose) (soft_endstop._loose = loose) + +#else // !HAS_SOFTWARE_ENDSTOPS + + typedef struct { + bool enabled() { return false; } + void get_manual_axis_limits(const AxisEnum axis, float &amin, float &amax) { + // No limits + amin = current_position[axis] - 1000; + amax = current_position[axis] + 1000; + } + } soft_endstops_t; + extern soft_endstops_t soft_endstop; + #define apply_motion_limits(V) NOOP #define update_software_endstops(...) NOOP - #define TEMPORARY_SOFT_ENDSTOP_STATE(...) NOOP -#endif + #define SET_SOFT_ENDSTOP_LOOSE(V) NOOP + +#endif // !HAS_SOFTWARE_ENDSTOPS void report_real_position(); void report_current_position(); @@ -351,8 +384,7 @@ bool homing_needed_error(uint8_t axis_bits=0x07); * Duplication mode */ #if HAS_DUPLICATION_MODE - extern bool extruder_duplication_enabled, // Used in Dual X mode 2 - mirrored_duplication_mode; // Used in Dual X mode 3 + extern bool extruder_duplication_enabled; // Used in Dual X mode 2 #if ENABLED(MULTI_NOZZLE_DUPLICATION) extern uint8_t duplication_e_mask; #endif @@ -371,23 +403,29 @@ bool homing_needed_error(uint8_t axis_bits=0x07); }; extern DualXMode dual_x_carriage_mode; - extern float inactive_extruder_x_pos, // Used in mode 0 & 1 + extern float inactive_extruder_x, // Used in mode 0 & 1 duplicate_extruder_x_offset; // Used in mode 2 & 3 extern xyz_pos_t raised_parked_position; // Used in mode 1 extern bool active_extruder_parked; // Used in mode 1, 2 & 3 extern millis_t delayed_move_time; // Used in mode 1 extern int16_t duplicate_extruder_temp_offset; // Used in mode 2 & 3 + extern bool idex_mirrored_mode; // Used in mode 3 - FORCE_INLINE bool dxc_is_duplicating() { return dual_x_carriage_mode >= DXC_DUPLICATION_MODE; } + FORCE_INLINE bool idex_is_duplicating() { return dual_x_carriage_mode >= DXC_DUPLICATION_MODE; } float x_home_pos(const uint8_t extruder); FORCE_INLINE int x_home_dir(const uint8_t extruder) { return extruder ? X2_HOME_DIR : X_HOME_DIR; } + void set_duplication_enabled(const bool dupe, const int8_t tool_index=-1); + void idex_set_mirrored_mode(const bool mirr); + void idex_set_parked(const bool park=true); + #else #if ENABLED(MULTI_NOZZLE_DUPLICATION) enum DualXMode : char { DXC_DUPLICATION_MODE = 2 }; + FORCE_INLINE void set_duplication_enabled(const bool dupe) { extruder_duplication_enabled = dupe; } #endif FORCE_INLINE int x_home_dir(const uint8_t) { return home_dir(X_AXIS); } diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 4ad7c4ccf044..74535df1f9c9 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -66,7 +66,7 @@ #include "stepper.h" #include "motion.h" #include "temperature.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #include "../gcode/parser.h" #include "../MarlinCore.h" diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index defc22b1fe8e..d00872038939 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -36,9 +36,9 @@ #include "endstops.h" #include "../gcode/gcode.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" -#include "../MarlinCore.h" // for stop(), disable_e_steppers, wait_for_user +#include "../MarlinCore.h" // for stop(), disable_e_steppers #if HAS_LEVELING #include "../feature/bedlevel/bedlevel.h" diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 3ccd8ffd9185..eac2af38c3d0 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V81" +#define EEPROM_VERSION "V82" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -54,7 +54,7 @@ #include "../lcd/dwin/e3v2/dwin.h" #endif -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #include "../libs/vector_3.h" // for matrix_3x3 #include "../gcode/gcode.h" #include "../MarlinCore.h" @@ -365,7 +365,10 @@ typedef struct SettingsDataStruct { // // HAS_MOTOR_CURRENT_PWM // - uint32_t motor_current_setting[3]; // M907 X Z E + #ifndef MOTOR_CURRENT_COUNT + #define MOTOR_CURRENT_COUNT 3 + #endif + uint32_t motor_current_setting[MOTOR_CURRENT_COUNT]; // M907 X Z E // // CNC_COORDINATE_SYSTEMS @@ -1277,10 +1280,10 @@ void MarlinSettings::postprocess() { { _FIELD_TEST(motor_current_setting); - #if HAS_MOTOR_CURRENT_PWM + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM EEPROM_WRITE(stepper.motor_current_setting); #else - const uint32_t no_current[3] = { 0 }; + const uint32_t no_current[MOTOR_CURRENT_COUNT] = { 0 }; EEPROM_WRITE(no_current); #endif } @@ -2110,10 +2113,16 @@ void MarlinSettings::postprocess() { // Motor Current PWM // { - uint32_t motor_current_setting[3]; _FIELD_TEST(motor_current_setting); + uint32_t motor_current_setting[MOTOR_CURRENT_COUNT] + #if HAS_MOTOR_CURRENT_SPI + = DIGIPOT_MOTOR_CURRENT + #endif + ; + DEBUG_ECHOLNPGM("DIGIPOTS Loading"); EEPROM_READ(motor_current_setting); - #if HAS_MOTOR_CURRENT_PWM + DEBUG_ECHOLNPGM("DIGIPOTS Loaded"); + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM if (!validating) COPY(stepper.motor_current_setting, motor_current_setting); #endif @@ -2791,9 +2800,20 @@ void MarlinSettings::reset() { // #if HAS_MOTOR_CURRENT_PWM - constexpr uint32_t tmp_motor_current_setting[3] = PWM_MOTOR_CURRENT; - LOOP_L_N(q, 3) - stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q])); + constexpr uint32_t tmp_motor_current_setting[MOTOR_CURRENT_COUNT] = PWM_MOTOR_CURRENT; + LOOP_L_N(q, MOTOR_CURRENT_COUNT) + stepper.set_digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q])); + #endif + + // + // DIGIPOTS + // + #if HAS_MOTOR_CURRENT_SPI + static constexpr uint32_t tmp_motor_current_setting[] = DIGIPOT_MOTOR_CURRENT; + DEBUG_ECHOLNPGM("Writing Digipot"); + LOOP_L_N(q, COUNT(tmp_motor_current_setting)) + stepper.set_digipot_current(q, tmp_motor_current_setting[q]); + DEBUG_ECHOLNPGM("Digipot Written"); #endif // @@ -3695,14 +3715,23 @@ void MarlinSettings::reset() { #endif #endif - #if HAS_MOTOR_CURRENT_PWM + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM CONFIG_ECHO_HEADING("Stepper motor currents:"); CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M907 X"), stepper.motor_current_setting[0] - , SP_Z_STR, stepper.motor_current_setting[1] - , SP_E_STR, stepper.motor_current_setting[2] - ); + #if HAS_MOTOR_CURRENT_PWM + SERIAL_ECHOLNPAIR_P( + PSTR(" M907 X"), stepper.motor_current_setting[0] + , SP_Z_STR, stepper.motor_current_setting[1] + , SP_E_STR, stepper.motor_current_setting[2] + ); + #elif HAS_MOTOR_CURRENT_SPI + SERIAL_ECHOPGM(" M907"); + LOOP_L_N(q, MOTOR_CURRENT_COUNT) { + SERIAL_CHAR(' '); + SERIAL_CHAR(axis_codes[q]); + SERIAL_ECHO(stepper.motor_current_setting[q]); + } + #endif #endif /** diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 56a75d1b4812..7b3e13eff44b 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -83,10 +83,6 @@ Stepper stepper; // Singleton #define BABYSTEPPING_EXTRA_DIR_WAIT -#if HAS_MOTOR_CURRENT_PWM - bool Stepper::initialized; // = false -#endif - #ifdef __AVR__ #include "speed_lookuptable.h" #endif @@ -96,7 +92,7 @@ Stepper stepper; // Singleton #include "motion.h" #include "temperature.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #include "../gcode/queue.h" #include "../sd/cardreader.h" #include "../MarlinCore.h" @@ -110,7 +106,7 @@ Stepper stepper; // Singleton #include "../feature/dac/dac_dac084s085.h" #endif -#if HAS_DIGIPOTSS +#if HAS_MOTOR_CURRENT_SPI #include #endif @@ -142,8 +138,12 @@ Stepper stepper; // Singleton bool Stepper::separate_multi_axis = false; #endif -#if HAS_MOTOR_CURRENT_PWM - uint32_t Stepper::motor_current_setting[3]; // Initialized by settings.load() +#if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + bool Stepper::initialized; // = false + uint32_t Stepper::motor_current_setting[MOTOR_CURRENT_COUNT]; // Initialized by settings.load() + #if HAS_MOTOR_CURRENT_SPI + constexpr uint32_t Stepper::digipot_count[]; + #endif #endif // private: @@ -348,7 +348,7 @@ xyze_int8_t Stepper::count_direction{0}; } #if ENABLED(X_DUAL_STEPPER_DRIVERS) - #define X_APPLY_DIR(v,Q) do{ X_DIR_WRITE(v); X2_DIR_WRITE((v) != INVERT_X2_VS_X_DIR); }while(0) + #define X_APPLY_DIR(v,Q) do{ X_DIR_WRITE(v); X2_DIR_WRITE((v) ^ ENABLED(INVERT_X2_VS_X_DIR)); }while(0) #if ENABLED(X_DUAL_ENDSTOPS) #define X_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(X,v) #else @@ -356,7 +356,7 @@ xyze_int8_t Stepper::count_direction{0}; #endif #elif ENABLED(DUAL_X_CARRIAGE) #define X_APPLY_DIR(v,ALWAYS) do{ \ - if (extruder_duplication_enabled || ALWAYS) { X_DIR_WRITE(v); X2_DIR_WRITE(mirrored_duplication_mode ? !(v) : v); } \ + if (extruder_duplication_enabled || ALWAYS) { X_DIR_WRITE(v); X2_DIR_WRITE((v) ^ idex_mirrored_mode); } \ else if (last_moved_extruder) X2_DIR_WRITE(v); else X_DIR_WRITE(v); \ }while(0) #define X_APPLY_STEP(v,ALWAYS) do{ \ @@ -369,7 +369,7 @@ xyze_int8_t Stepper::count_direction{0}; #endif #if ENABLED(Y_DUAL_STEPPER_DRIVERS) - #define Y_APPLY_DIR(v,Q) do{ Y_DIR_WRITE(v); Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR); }while(0) + #define Y_APPLY_DIR(v,Q) do{ Y_DIR_WRITE(v); Y2_DIR_WRITE((v) ^ ENABLED(INVERT_Y2_VS_Y_DIR)); }while(0) #if ENABLED(Y_DUAL_ENDSTOPS) #define Y_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(Y,v) #else @@ -1605,10 +1605,9 @@ void Stepper::pulse_phase_isr() { PAGE_SEGMENT_UPDATE(Z, high >> 4); PAGE_SEGMENT_UPDATE(E, high & 0xF); - if (dm != last_direction_bits) { - last_direction_bits = dm; - set_directions(); - } + if (dm != last_direction_bits) + set_directions(dm); + } break; default: break; @@ -2131,9 +2130,7 @@ uint32_t Stepper::block_phase_isr() { MIXER_STEPPER_SETUP(); #endif - #if HAS_MULTI_EXTRUDER - stepper_extruder = current_block->extruder; - #endif + TERN_(HAS_MULTI_EXTRUDER, stepper_extruder = current_block->extruder); // Initialize the trapezoid generator from the current block. #if ENABLED(LIN_ADVANCE) @@ -2151,17 +2148,14 @@ uint32_t Stepper::block_phase_isr() { else LA_isr_rate = LA_ADV_NEVER; #endif - if ( ENABLED(HAS_L64XX) // Always set direction for L64xx (Also enables the chips) + if ( ENABLED(HAS_L64XX) // Always set direction for L64xx (Also enables the chips) + || ENABLED(DUAL_X_CARRIAGE) // TODO: Find out why this fixes "jittery" small circles || current_block->direction_bits != last_direction_bits || TERN(MIXING_EXTRUDER, false, stepper_extruder != last_moved_extruder) ) { - last_direction_bits = current_block->direction_bits; - #if HAS_MULTI_EXTRUDER - last_moved_extruder = stepper_extruder; - #endif - + TERN_(HAS_MULTI_EXTRUDER, last_moved_extruder = stepper_extruder); TERN_(HAS_L64XX, L64XX_OK_to_power_up = true); - set_directions(); + set_directions(current_block->direction_bits); } #if ENABLED(LASER_POWER_INLINE) @@ -2583,15 +2577,12 @@ void Stepper::init() { #endif // Init direction bits for first moves - last_direction_bits = 0 - | (INVERT_X_DIR ? _BV(X_AXIS) : 0) - | (INVERT_Y_DIR ? _BV(Y_AXIS) : 0) - | (INVERT_Z_DIR ? _BV(Z_AXIS) : 0); - - set_directions(); + set_directions((INVERT_X_DIR ? _BV(X_AXIS) : 0) + | (INVERT_Y_DIR ? _BV(Y_AXIS) : 0) + | (INVERT_Z_DIR ? _BV(Z_AXIS) : 0)); - #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM - TERN_(HAS_MOTOR_CURRENT_PWM, initialized = true); + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + initialized = true; digipot_init(); #endif } @@ -2930,10 +2921,10 @@ void Stepper::report_positions() { * Software-controlled Stepper Motor Current */ -#if HAS_DIGIPOTSS +#if HAS_MOTOR_CURRENT_SPI // From Arduino DigitalPotControl example - void Stepper::digitalPotWrite(const int16_t address, const int16_t value) { + void Stepper::set_digipot_value_spi(const int16_t address, const int16_t value) { WRITE(DIGIPOTSS_PIN, LOW); // Take the SS pin low to select the chip SPI.transfer(address); // Send the address and value via SPI SPI.transfer(value); @@ -2941,7 +2932,7 @@ void Stepper::report_positions() { //delay(10); } -#endif // HAS_DIGIPOTSS +#endif // HAS_MOTOR_CURRENT_SPI #if HAS_MOTOR_CURRENT_PWM @@ -2958,7 +2949,7 @@ void Stepper::report_positions() { #if ANY_PIN(MOTOR_CURRENT_PWM_E, MOTOR_CURRENT_PWM_E0, MOTOR_CURRENT_PWM_E1) case 2: #endif - digipot_current(i, motor_current_setting[i]); + set_digipot_current(i, motor_current_setting[i]); default: break; } } @@ -2968,21 +2959,22 @@ void Stepper::report_positions() { #if !MB(PRINTRBOARD_G2) - #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM - void Stepper::digipot_current(const uint8_t driver, const int16_t current) { + void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) { + if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1)) + motor_current_setting[driver] = current; // update motor_current_setting - #if HAS_DIGIPOTSS + if (!initialized) return; - const uint8_t digipot_ch[] = DIGIPOT_CHANNELS; - digitalPotWrite(digipot_ch[driver], current); + #if HAS_MOTOR_CURRENT_SPI - #elif HAS_MOTOR_CURRENT_PWM + //SERIAL_ECHOLNPAIR("Digipotss current ", current); - if (!initialized) return; + const uint8_t digipot_ch[] = DIGIPOT_CHANNELS; + set_digipot_value_spi(digipot_ch[driver], current); - if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1)) - motor_current_setting[driver] = current; // update motor_current_setting + #elif HAS_MOTOR_CURRENT_PWM #define _WRITE_CURRENT_PWM(P) analogWrite(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) switch (driver) { @@ -3019,17 +3011,13 @@ void Stepper::report_positions() { void Stepper::digipot_init() { - #if HAS_DIGIPOTSS - - static const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT; + #if HAS_MOTOR_CURRENT_SPI SPI.begin(); SET_OUTPUT(DIGIPOTSS_PIN); - LOOP_L_N(i, COUNT(digipot_motor_current)) { - //digitalPotWrite(digipot_ch[i], digipot_motor_current[i]); - digipot_current(i, digipot_motor_current[i]); - } + LOOP_L_N(i, COUNT(motor_current_setting)) + set_digipot_current(i, motor_current_setting[i]); #elif HAS_MOTOR_CURRENT_PWM diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index da38192d8ea3..639a1b2650bd 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -245,12 +245,18 @@ class Stepper { static bool separate_multi_axis; #endif - #if HAS_MOTOR_CURRENT_PWM - #ifndef PWM_MOTOR_CURRENT - #define PWM_MOTOR_CURRENT DEFAULT_PWM_MOTOR_CURRENT + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + #if HAS_MOTOR_CURRENT_PWM + #ifndef PWM_MOTOR_CURRENT + #define PWM_MOTOR_CURRENT DEFAULT_PWM_MOTOR_CURRENT + #endif + #define MOTOR_CURRENT_COUNT 3 + #elif HAS_MOTOR_CURRENT_SPI + static constexpr uint32_t digipot_count[] = DIGIPOT_MOTOR_CURRENT; + #define MOTOR_CURRENT_COUNT COUNT(Stepper::digipot_count) #endif - static uint32_t motor_current_setting[3]; static bool initialized; + static uint32_t motor_current_setting[MOTOR_CURRENT_COUNT]; // Initialized by settings.load() #endif // Last-moved extruder, as set when the last movement was fetched from planner @@ -457,9 +463,9 @@ class Stepper { // Triggered position of an axis in steps static int32_t triggered_position(const AxisEnum axis); - #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM - static void digitalPotWrite(const int16_t address, const int16_t value); - static void digipot_current(const uint8_t driver, const int16_t current); + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + static void set_digipot_value_spi(const int16_t address, const int16_t value); + static void set_digipot_current(const uint8_t driver, const int16_t current); #endif #if HAS_MICROSTEPS @@ -508,9 +514,15 @@ class Stepper { static void refresh_motor_power(); #endif - // Set direction bits for all steppers + // Update direction states for all steppers static void set_directions(); + // Set direction bits and update all stepper DIR states + static void set_directions(const uint8_t bits) { + last_direction_bits = bits; + set_directions(); + } + private: // Set the current position in steps @@ -582,7 +594,7 @@ class Stepper { static int32_t _eval_bezier_curve(const uint32_t curr_step); #endif - #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM static void digipot_init(); #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f8ff972f8034..3468a4c1c5d3 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -34,7 +34,7 @@ #include "planner.h" #include "../HAL/shared/Delay.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/dwin/e3v2/dwin.h" @@ -1032,8 +1032,14 @@ void Temperature::manage_heater() { if (!inited) return watchdog_refresh(); #endif - if (TERN0(EMERGENCY_PARSER, emergency_parser.killed_by_M112)) - kill(M112_KILL_STR, nullptr, true); + #if ENABLED(EMERGENCY_PARSER) + if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true); + + if (emergency_parser.quickstop_by_M410) { + emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! + quickstop_stepper(); + } + #endif if (!raw_temps_ready) return; @@ -1461,7 +1467,7 @@ void Temperature::manage_heater() { #elif ENABLED(HEATER_0_USES_MAX6675) return ( #if ENABLED(MAX6675_IS_MAX31865) - max31865.temperature(100, 400) // 100 ohms = PT100 resistance. 400 ohms = calibration resistor + max31865.temperature(MAX31865_SENSOR_OHMS, MAX31865_CALIBRATION_OHMS) #else raw * 0.25 #endif @@ -2236,7 +2242,7 @@ void Temperature::disable_all_heaters() { next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; #if ENABLED(MAX6675_IS_MAX31865) - max6675_temp = int(max31865.temperature(100, 400)); // 100 ohms = PT100 resistance. 400 ohms = calibration resistor + max6675_temp = int(max31865.temperature(MAX31865_SENSOR_OHMS, MAX31865_CALIBRATION_OHMS)); #endif // diff --git a/Marlin/src/module/thermistor/thermistor_666.h b/Marlin/src/module/thermistor/thermistor_666.h index 86493988e053..490dbd5f3ee9 100644 --- a/Marlin/src/module/thermistor/thermistor_666.h +++ b/Marlin/src/module/thermistor/thermistor_666.h @@ -33,8 +33,7 @@ * B: 0.00031362 * C: -2.03978e-07 */ -#define NUMTEMPS 61 -const short temptable_666[NUMTEMPS][2] PROGMEM = { +const temp_entry_t temptable_666[] PROGMEM = { { OV( 1), 794 }, { OV( 18), 288 }, { OV( 35), 234 }, diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 0f823cfbd000..2c1a1a6017a9 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -61,6 +61,10 @@ #include "../gcode/gcode.h" #endif +#if ENABLED(DUAL_X_CARRIAGE) + #include "stepper.h" +#endif + #if ANY(SWITCHING_EXTRUDER, SWITCHING_NOZZLE, SWITCHING_TOOLHEAD) #include "servo.h" #endif @@ -90,7 +94,7 @@ #endif #if HAS_LCD_MENU - #include "../lcd/ultralcd.h" + #include "../lcd/marlinui.h" #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) @@ -701,6 +705,13 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a #if ENABLED(DUAL_X_CARRIAGE) + /** + * @brief Dual X Tool Change + * @details Change tools, with extra behavior based on current mode + * + * @param new_tool Tool index to activate + * @param no_move Flag indicating no moves should take place + */ inline void dualx_tool_change(const uint8_t new_tool, bool &no_move) { DEBUG_ECHOPGM("Dual X Carriage Mode "); @@ -711,17 +722,16 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a case DXC_MIRRORED_MODE: DEBUG_ECHOLNPGM("MIRRORED"); break; } + // Get the home position of the currently-active tool const float xhome = x_home_pos(active_extruder); - if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE - && IsRunning() && !no_move - && (delayed_move_time || current_position.x != xhome) - ) { + if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE // If Auto-Park mode is enabled + && IsRunning() && !no_move // ...and movement is permitted + && (delayed_move_time || current_position.x != xhome) // ...and delayed_move_time is set OR not "already parked"... + ) { DEBUG_ECHOLNPAIR("MoveX to ", xhome); - - // Park old head current_position.x = xhome; - line_to_current_position(planner.settings.max_feedrate_mm_s[X_AXIS]); + line_to_current_position(planner.settings.max_feedrate_mm_s[X_AXIS]); // Park the current head planner.synchronize(); } @@ -736,20 +746,21 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a switch (dual_x_carriage_mode) { case DXC_FULL_CONTROL_MODE: // New current position is the position of the activated extruder - current_position.x = inactive_extruder_x_pos; + current_position.x = inactive_extruder_x; // Save the inactive extruder's position (from the old current_position) - inactive_extruder_x_pos = destination.x; + inactive_extruder_x = destination.x; + DEBUG_ECHOLNPAIR("DXC Full Control curr.x=", current_position.x, " dest.x=", destination.x); break; case DXC_AUTO_PARK_MODE: - // record current raised toolhead position for use by unpark - raised_parked_position = current_position; - active_extruder_parked = true; - delayed_move_time = 0; + idex_set_parked(); break; default: break; } + // Ensure X axis DIR pertains to the correct carriage + stepper.set_directions(); + DEBUG_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no"); DEBUG_POS("New extruder (parked)", current_position); } @@ -875,7 +886,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { planner.synchronize(); #if ENABLED(DUAL_X_CARRIAGE) // Only T0 allowed if the Printer is in DXC_DUPLICATION_MODE or DXC_MIRRORED_MODE - if (new_tool != 0 && dxc_is_duplicating()) + if (new_tool != 0 && idex_is_duplicating()) return invalid_extruder_error(new_tool); #endif @@ -1017,14 +1028,10 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { // Raise by a configured distance to avoid workpiece, except with // SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead. if (!no_move) { - #if HAS_SOFTWARE_ENDSTOPS - const float maxz = _MIN(soft_endstop.max.z, Z_MAX_POS); - #else - constexpr float maxz = Z_MAX_POS; - #endif + const float newz = current_position.z + _MAX(-diff.z, 0.0); // Check if Z has space to compensate at least z_offset, and if not, just abort now - const float newz = current_position.z + _MAX(-diff.z, 0.0); + const float maxz = _MIN(TERN(HAS_SOFTWARE_ENDSTOPS, soft_endstop.max.z, Z_MAX_POS), Z_MAX_POS); if (newz > maxz) return; current_position.z = _MIN(newz + toolchange_settings.z_raise, maxz); @@ -1155,7 +1162,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { } #endif - TERN_(DUAL_X_CARRIAGE, active_extruder_parked = false); + TERN_(DUAL_X_CARRIAGE, idex_set_parked(false)); } #if ENABLED(SWITCHING_NOZZLE) diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPE.h b/Marlin/src/pins/esp32/pins_MRR_ESPE.h index 95f761f26ad9..d22a82d7a45a 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPE.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPE.h @@ -134,7 +134,7 @@ #define BEEPER_PIN 151 - #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #elif IS_RRD_FG_SC #define BEEPER_PIN 151 diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 002d2ebd9c62..ce2ee2579abb 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -400,7 +400,7 @@ #define LCD_PINS_ENABLE 51 // SID (MOSI) #define LCD_PINS_D4 52 // SCK (CLK) clock - #elif BOTH(NEWPANEL, PANEL_ONE) + #elif BOTH(IS_NEWPANEL, PANEL_ONE) #define LCD_PINS_RS 40 #define LCD_PINS_ENABLE 42 @@ -417,7 +417,7 @@ #define LCD_PINS_ENABLE 29 #define LCD_PINS_D4 25 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 37 #endif @@ -450,13 +450,13 @@ #define LCD_PINS_D7 29 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 33 #endif #endif - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL // Buttons attached to a shift register // Not wired yet //#define SHIFT_CLK 38 @@ -470,7 +470,7 @@ // // LCD Display input pins // - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) @@ -607,7 +607,7 @@ #define BEEPER_PIN 33 // Buttons are directly attached to AUX-2 - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD #define SHIFT_OUT 40 #define SHIFT_CLK 44 #define SHIFT_LD 42 @@ -630,6 +630,6 @@ #endif #endif - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h b/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h index df182049f994..8c1c124d90a7 100644 --- a/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h +++ b/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h @@ -138,8 +138,8 @@ #define LCD_PINS_ENABLE P0_18 // (MOSI) EXP1-3 #define LCD_PINS_D4 P0_15 // (SCK) EXP1-5 - #if BOTH(HAS_MARLINUI_HD44780, REPRAP_DISCOUNT_SMART_CONTROLLER) - #error "REPRAP_DISCOUNT_SMART_CONTROLLER is not supported by the BIQU B300 v1.0" + #if BOTH(HAS_MARLINUI_HD44780, IS_RRD_SC) + #error "REPRAP_DISCOUNT_SMART_CONTROLLER displays aren't supported by the BIQU B300 v1.0" #endif #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h b/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h index bcff04eb85e8..d92d5e578f62 100644 --- a/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h +++ b/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h @@ -109,8 +109,8 @@ #define LCD_PINS_ENABLE P0_18 // (MOSI) EXP1-3 #define LCD_PINS_D4 P0_15 // (SCK) EXP1-5 - #if BOTH(HAS_MARLINUI_HD44780, REPRAP_DISCOUNT_SMART_CONTROLLER) - #error "REPRAP_DISCOUNT_SMART_CONTROLLER is not supported by the BIQU BQ111-A4" + #if BOTH(HAS_MARLINUI_HD44780, IS_RRD_SC) + #error "REPRAP_DISCOUNT_SMART_CONTROLLER displays aren't supported by the BIQU BQ111-A4" #endif #if ENABLED(SDSUPPORT) 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 31373fedff66..51e48fc8e949 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -348,7 +348,7 @@ #define LCD_BACKLIGHT_PIN -1 #endif - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 EXPA1_05_PIN #define LCD_PINS_D6 EXPA1_04_PIN #define LCD_PINS_D7 EXPA1_03_PIN 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 5bb32a420aee..f2afc23bc2e6 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -293,28 +293,44 @@ #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 - // Emulated DOGM have xpt calibration values independent of display resolution - #if ENABLED(SPI_GRAPHICAL_TFT) + // XPT2046 Touch Screen calibration + #if ENABLED(TFT_CLASSIC_UI) + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION -11245 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION 8629 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET 685 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET -285 + #endif + #elif ENABLED(TFT_480x320_SPI) #ifndef XPT2046_X_CALIBRATION - #define XPT2046_X_CALIBRATION -11245 + #define XPT2046_X_CALIBRATION -17232 #endif #ifndef XPT2046_Y_CALIBRATION - #define XPT2046_Y_CALIBRATION 8629 + #define XPT2046_Y_CALIBRATION 11196 #endif #ifndef XPT2046_X_OFFSET - #define XPT2046_X_OFFSET 685 + #define XPT2046_X_OFFSET 1047 #endif #ifndef XPT2046_Y_OFFSET - #define XPT2046_Y_OFFSET -285 + #define XPT2046_Y_OFFSET -358 #endif + + #define TFT_BUFFER_SIZE 2400 #endif #elif IS_TFTGLCD_PANEL @@ -379,7 +395,7 @@ #define FORCE_SOFT_SPI #endif - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 P1_21 #define LCD_PINS_D6 P1_22 #define LCD_PINS_D7 P1_23 diff --git a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h index 5132081a5591..3562619f5c09 100644 --- a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h +++ b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h @@ -125,7 +125,7 @@ // // LCD // -#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) +#if IS_RRD_SC #define BEEPER_PIN P0_19 #define BTN_EN1 P1_23 #define BTN_EN2 P1_24 diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h index 196503c822c5..2430958895ea 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h @@ -147,7 +147,7 @@ // // Ethernet pins // -#ifndef ULTIPANEL +#if !IS_ULTIPANEL #define ENET_MDIO P1_17 // J12-4 #define ENET_RX_ER P1_14 // J12-6 #define ENET_RXD1 P1_10 // J12-8 @@ -220,7 +220,7 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS P3_25 // EXP2.3 + #define TFTGLCD_CS P3_25 // EXP2.3 #endif #if SD_CONNECTION_IS(LCD) diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index d269ecbdc90d..0a8f3a6da8af 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -319,7 +319,7 @@ #define DOGLCD_A0 P1_00 #endif - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 P0_17 #define LCD_PINS_D6 P1_00 #define LCD_PINS_D7 P1_22 diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index c602af1c3028..674bd6b0ff9f 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -357,8 +357,8 @@ #define LCD_PINS_RS P0_16 // (16) J3-7 & AUX-4 #define LCD_SDSS P1_23 // (53) J3-5 & AUX-3 - #if ENABLED(NEWPANEL) - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_NEWPANEL + #if IS_RRW_KEYPAD #define SHIFT_OUT P0_18 // (51) (MOSI) J3-10 & AUX-3 #define SHIFT_CLK P0_15 // (52) (SCK) J3-9 & AUX-3 #define SHIFT_LD P1_31 // (49) J3-1 & AUX-3 (NOT 5V tolerant) @@ -371,7 +371,7 @@ #endif #if ANY(VIKI2, miniVIKI) - // #define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_180 #define DOGLCD_CS P0_16 // (16) #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 @@ -416,7 +416,7 @@ #define LCD_BACKLIGHT_PIN P0_16 //(16) J3-7 & AUX-4 - only used on DOGLCD controllers #define LCD_PINS_ENABLE P0_18 // (51) (MOSI) J3-10 & AUX-3 #define LCD_PINS_D4 P0_15 // (52) (SCK) J3-9 & AUX-3 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 P1_17 // (71) ENET_MDIO #define LCD_PINS_D6 P1_14 // (73) ENET_RX_ER #define LCD_PINS_D7 P1_10 // (75) ENET_RXD1 @@ -436,7 +436,7 @@ // // Ethernet pins // -#if DISABLED(ULTIPANEL) +#if !IS_ULTIPANEL #define ENET_MDIO P1_17 // (71) J12-4 #define ENET_RX_ER P1_14 // (73) J12-6 #define ENET_RXD1 P1_10 // (75) J12-8 diff --git a/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h b/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h index f9b9db918d55..4e3b2ef4258a 100644 --- a/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h +++ b/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h @@ -96,7 +96,7 @@ // Display // -#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) +#if IS_RRD_FG_SC #define LCD_PINS_RS P0_16 #define LCD_PINS_ENABLE P0_18 #define LCD_PINS_D4 P0_15 @@ -110,4 +110,4 @@ #define BTN_ENC P1_30 #define SD_DETECT_PIN -1 -#endif // REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +#endif // IS_RRD_FG_SC diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h index 6331d6aa7c0a..ad792447ea73 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -144,11 +144,11 @@ #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD #define SHIFT_OUT P0_18 // (51) (MOSI) J3-10 & AUX-3 #define SHIFT_CLK P0_15 // (52) (SCK) J3-9 & AUX-3 #define SHIFT_LD P1_31 // (49) not 5V tolerant J3-1 & AUX-3 - #elif DISABLED(NEWPANEL) + #elif !IS_NEWPANEL //#define SHIFT_OUT P2_11 // (35) J3-3 & AUX-4 //#define SHIFT_CLK P3_26 // (31) J3-2 & AUX-4 //#define SHIFT_LD P3_25 // (33) J3-4 & AUX-4 @@ -166,7 +166,7 @@ #define STAT_LED_BLUE_PIN P0_26 // (63) may change if cable changes #define STAT_LED_RED_PIN P1_21 // ( 6) may change if cable changes #else - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 P1_17 // (71) ENET_MDIO #define LCD_PINS_D6 P1_14 // (73) ENET_RX_ER #define LCD_PINS_D7 P1_10 // (75) ENET_RXD1 diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h index 76c54c3bba21..6d6d7557f57d 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -161,7 +161,7 @@ // #define TEMP_0_PIN P0_24 #define TEMP_1_PIN P0_23 -//#define TEMP_2_PIN P1_30 // Onboard thermistor +//#define TEMP_2_PIN P1_30 // Onboard thermistor #define TEMP_BED_PIN P0_25 // diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h index cbbe8a9416d4..1a558075b60e 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -39,7 +39,7 @@ //#define SDCARD_EEPROM_EMULATION //#define I2C_EEPROM // AT24C32 #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // @@ -190,7 +190,7 @@ #define E1_SERIAL_RX_PIN P1_17 // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 + #define TMC_BAUD_RATE 19200 #endif // HAS_TMC_UART // @@ -227,9 +227,25 @@ // 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 + +// +// RGB LED +// +#if ENABLED(RGB_LED) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN P1_19 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN P1_20 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN P1_21 + #endif +#else + #define LED2_PIN P1_19 // Initialized by HAL/LPC1768/main.cpp + #define LED3_PIN P1_20 + #define LED4_PIN P1_21 +#endif /** * _____ _____ @@ -325,7 +341,7 @@ #define DOGLCD_A0 P1_00 #endif - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 P0_17 #define LCD_PINS_D6 P1_00 #define LCD_PINS_D7 P1_22 diff --git a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h index f2811b14abdc..3c47a7010125 100644 --- a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h @@ -138,7 +138,7 @@ * http://chibidibidiwah.wdfiles.com/local--files/panel/smoothieboard2sd.jpg * http://smoothieware.org/panel */ - #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #if IS_RRD_FG_SC // EXP1 Pins #define BEEPER_PIN P1_31 // EXP1 Pin 1 #define BTN_ENC P1_30 // EXP1 Pin 2 diff --git a/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h b/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h index 3a84f4395f3a..af9f683c7d33 100644 --- a/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h +++ b/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h @@ -129,7 +129,7 @@ #define SD_DETECT_PIN 49 #endif -#if ENABLED(NEWPANEL) +#if IS_NEWPANEL #define BTN_EN1 11 #define BTN_EN2 12 #define BTN_ENC 43 diff --git a/Marlin/src/pins/mega/pins_GT2560_REV_A.h b/Marlin/src/pins/mega/pins_GT2560_REV_A.h index 2fe9a43ba136..f481db2b9670 100644 --- a/Marlin/src/pins/mega/pins_GT2560_REV_A.h +++ b/Marlin/src/pins/mega/pins_GT2560_REV_A.h @@ -109,7 +109,7 @@ #define BEEPER_PIN 18 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #if ENABLED(MKS_MINI_12864) #define DOGLCD_A0 5 @@ -130,7 +130,7 @@ #define BTN_ENC 19 #define SD_DETECT_PIN 38 - #else // !NEWPANEL + #else // !IS_NEWPANEL #define SHIFT_CLK 38 #define SHIFT_LD 42 @@ -146,6 +146,6 @@ #define SD_DETECT_PIN -1 - #endif // !NEWPANEL + #endif // !IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/mega/pins_GT2560_V3.h b/Marlin/src/pins/mega/pins_GT2560_V3.h index d71a19541914..606debd1b06b 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3.h @@ -172,7 +172,7 @@ #define LCD_PINS_D7 36 #endif -#if ENABLED(NEWPANEL) +#if IS_NEWPANEL #ifndef BTN_EN1 #define BTN_EN1 42 #endif diff --git a/Marlin/src/pins/mega/pins_GT2560_V3_A20.h b/Marlin/src/pins/mega/pins_GT2560_V3_A20.h index e1956488c6c7..20cccf148f92 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3_A20.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3_A20.h @@ -32,7 +32,7 @@ #define SPEAKER // The speaker can produce tones -#if ENABLED(NEWPANEL) +#if IS_NEWPANEL #define BTN_EN1 16 #define BTN_EN2 17 #define BTN_ENC 19 diff --git a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h index e30a65b90e1b..fa2027fb7825 100644 --- a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h +++ b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h @@ -127,7 +127,7 @@ #define BEEPER_PIN 18 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #define LCD_PINS_RS 20 // LCD_CS #define LCD_PINS_ENABLE 15 // LCD_SDA @@ -168,6 +168,6 @@ #define LCD_PINS_D6 20 #define LCD_PINS_D7 19 - #endif // !NEWPANEL + #endif // !IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS.h b/Marlin/src/pins/mega/pins_MEGATRONICS.h index 1c37b21ab707..f813366a14e0 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS.h @@ -108,7 +108,7 @@ // #define BEEPER_PIN 33 -#if BOTH(ULTRA_LCD, NEWPANEL) +#if IS_ULTRA_LCD && IS_NEWPANEL #define LCD_PINS_RS 16 #define LCD_PINS_ENABLE 17 @@ -124,7 +124,7 @@ #define SD_DETECT_PIN -1 // RAMPS doesn't use this -#endif // ULTRA_LCD && NEWPANEL +#endif // IS_ULTRA_LCD && IS_NEWPANEL // // M3/M4/M5 - Spindle/Laser Control diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS_2.h b/Marlin/src/pins/mega/pins_MEGATRONICS_2.h index ff7cf1571465..67ec24ed6f79 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS_2.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS_2.h @@ -139,7 +139,7 @@ #define LCD_PINS_D6 32 #define LCD_PINS_D7 33 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL // Buttons are directly attached using keypad #define BTN_EN1 61 #define BTN_EN2 59 diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index 963911ec5d70..d074db8b256a 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -214,7 +214,7 @@ // #if HAS_WIRED_LCD - #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #if IS_RRD_FG_SC #define LCD_PINS_RS 33 // C4: LCD-STROBE #define LCD_PINS_ENABLE 72 // J2: LEFT diff --git a/Marlin/src/pins/mega/pins_OVERLORD.h b/Marlin/src/pins/mega/pins_OVERLORD.h index 045c1bc0fa6c..18bb1f27bf43 100644 --- a/Marlin/src/pins/mega/pins_OVERLORD.h +++ b/Marlin/src/pins/mega/pins_OVERLORD.h @@ -132,7 +132,7 @@ #endif #endif -#if ENABLED(NEWPANEL) +#if IS_NEWPANEL #define BTN_ENC 16 // Enter Pin #define BTN_UP 19 // Button UP Pin #define BTN_DWN 17 // Button DOWN Pin diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index a7888e54d4a6..bd85c448995b 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -49,7 +49,9 @@ #define IS_RAMPS_SF #endif -#define HAS_FREE_AUX2_PINS !(BOTH(ULTRA_LCD, NEWPANEL) && ANY(PANEL_ONE, VIKI2, miniVIKI, MINIPANEL, REPRAPWORLD_KEYPAD)) +#if !(BOTH(IS_ULTRA_LCD, IS_NEWPANEL) && ANY(PANEL_ONE, VIKI2, miniVIKI, MINIPANEL, REPRAPWORLD_KEYPAD)) + #define HAS_FREE_AUX2_PINS 1 +#endif // Test the target within the included pins file #ifdef __MARLIN_DEPS__ @@ -634,6 +636,8 @@ #include "stm32f7/pins_THE_BORG.h" // STM32F7 env:STM32F7 #elif MB(REMRAM_V1) #include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:STM32F7 +#elif MB(NUCLEO_F767ZI) + #include "stm32f7/pins_NUCLEO_F767ZI.h" // STM32F7 env:NUCLEO_F767ZI #elif MB(TEENSY41) #include "teensy4/pins_TEENSY41.h" // Teensy-4.x env:teensy41 #elif MB(T41U5XBB) diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index 2ea15c97d332..c2cc24943ab2 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -164,7 +164,7 @@ #define KILL_PIN 32 - #if ENABLED(ULTIPANEL) || TOUCH_UI_ULTIPANEL + #if IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #if ENABLED(CR10_STOCKDISPLAY) #define LCD_PINS_RS 85 @@ -187,5 +187,5 @@ #define BEEPER_PIN 84 // AUX-4 #define SD_DETECT_PIN 15 - #endif // ULTIPANEL || TOUCH_UI_ULTIPANEL + #endif // IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h index 4a1bf70b6eaa..7e532461812c 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h @@ -170,7 +170,7 @@ #define KILL_PIN 32 - #if ANY(ULTIPANEL, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) + #if ANY(IS_ULTIPANEL, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) #if ENABLED(CR10_STOCKDISPLAY) #define LCD_PINS_RS 85 @@ -194,6 +194,6 @@ #define SD_DETECT_PIN 15 - #endif // ULTIPANEL || TOUCH_UI_ULTIPANEL || TOUCH_UI_FTDI_EVE + #endif // IS_ULTIPANEL || TOUCH_UI_ULTIPANEL || TOUCH_UI_FTDI_EVE #endif // HAS_WIRED_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 6314bc07b8c0..8b034820cfdb 100644 --- a/Marlin/src/pins/rambo/pins_MINIRAMBO.h +++ b/Marlin/src/pins/rambo/pins_MINIRAMBO.h @@ -147,7 +147,7 @@ #define KILL_PIN 32 #endif - #if ENABLED(ULTIPANEL) || TOUCH_UI_ULTIPANEL + #if IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #if MB(MINIRAMBO_10A) @@ -187,6 +187,6 @@ #endif // !MINIRAMBO_10A - #endif // ULTIPANEL || TOUCH_UI_ULTIPANEL + #endif // IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #endif // HAS_WIRED_LCD || TOUCH_UI_ULTIPANEL diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 735852b2ff79..0254edea26af 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -187,7 +187,7 @@ #define KILL_PIN 80 - #if ENABLED(ULTIPANEL) || TOUCH_UI_ULTIPANEL + #if IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #define LCD_PINS_RS 70 #define LCD_PINS_ENABLE 71 @@ -228,7 +228,7 @@ #endif // !VIKI2 && !miniVIKI - #else // !NEWPANEL - old style panel with shift register + #else // !IS_NEWPANEL - old style panel with shift register // No Beeper added #define BEEPER_PIN 33 @@ -247,6 +247,6 @@ #define LCD_PINS_D6 27 #define LCD_PINS_D7 29 - #endif // !NEWPANEL + #endif // !IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/ramps/pins_3DRAG.h b/Marlin/src/pins/ramps/pins_3DRAG.h index f0057e1fc980..b7f0517aac02 100644 --- a/Marlin/src/pins/ramps/pins_3DRAG.h +++ b/Marlin/src/pins/ramps/pins_3DRAG.h @@ -78,7 +78,7 @@ // // LCD / Controller // -#if BOTH(ULTRA_LCD, NEWPANEL) +#if IS_ULTRA_LCD && IS_NEWPANEL #undef BEEPER_PIN #undef LCD_PINS_RS @@ -106,7 +106,7 @@ #define BEEPER_PIN 33 -#endif // ULTRA_LCD && NEWPANEL +#endif // IS_ULTRA_LCD && IS_NEWPANEL /** * M3/M4/M5 - Spindle/Laser Control @@ -157,7 +157,7 @@ #define SPINDLE_LASER_PWM_PIN 46 // Hardware PWM #define SPINDLE_LASER_ENA_PIN 62 // Pullup! #define SPINDLE_DIR_PIN 48 - #elif !BOTH(ULTRA_LCD, NEWPANEL) // use expansion header if no LCD in use + #elif !BOTH(IS_ULTRA_LCD, IS_NEWPANEL) // use expansion header if no LCD in use #define SPINDLE_LASER_ENA_PIN 16 // Pullup or pulldown! #define SPINDLE_DIR_PIN 17 #endif diff --git a/Marlin/src/pins/ramps/pins_FELIX2.h b/Marlin/src/pins/ramps/pins_FELIX2.h index 6cc6997adc56..e572d3f2866c 100644 --- a/Marlin/src/pins/ramps/pins_FELIX2.h +++ b/Marlin/src/pins/ramps/pins_FELIX2.h @@ -49,11 +49,11 @@ // // LCD / Controller // -#if BOTH(ULTRA_LCD, NEWPANEL) +#if IS_ULTRA_LCD && IS_NEWPANEL #define SD_DETECT_PIN 6 -#endif // NEWPANEL && ULTRA_LCD +#endif // // M3/M4/M5 - Spindle/Laser Control diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h index 0877d168d60f..5b724787e941 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h @@ -181,7 +181,7 @@ // // Formbot only supports REPRAP_DISCOUNT_SMART_CONTROLLER // -#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) +#if IS_RRD_SC #define BEEPER_PIN 37 #define BTN_EN1 31 #define BTN_EN2 33 diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h index 75a219c177de..81b6ea16d7fe 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h @@ -175,7 +175,7 @@ // // Formbot only supports REPRAP_DISCOUNT_SMART_CONTROLLER // -#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) +#if IS_RRD_SC #ifndef BEEPER_PIN #define BEEPER_PIN 37 #endif diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h index 0470fc47e98b..a97b0d2d1227 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h @@ -155,7 +155,7 @@ // // Formbot only supports REPRAP_DISCOUNT_SMART_CONTROLLER // -#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) +#if IS_RRD_SC #define LCD_PINS_RS 16 #define LCD_PINS_ENABLE 17 #define LCD_PINS_D4 23 diff --git a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h index 3fa3cc9e8c9c..80eb3f15346b 100644 --- a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h +++ b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h @@ -261,7 +261,7 @@ #define NEOPIXEL_PIN 25 #endif - #elif HAS_MARLINUI_U8GLIB + #elif HAS_MARLINUI_U8GLIB || HAS_MARLINUI_HD44780 #define LCD_PINS_RS 16 #define LCD_PINS_ENABLE 17 @@ -277,7 +277,7 @@ #endif - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #define BTN_EN1 31 #define BTN_EN2 33 #define BTN_ENC 35 diff --git a/Marlin/src/pins/ramps/pins_K8600.h b/Marlin/src/pins/ramps/pins_K8600.h index 0de01927528c..60bb18204a4e 100644 --- a/Marlin/src/pins/ramps/pins_K8600.h +++ b/Marlin/src/pins/ramps/pins_K8600.h @@ -96,7 +96,7 @@ // // LCD / Controller // -#if BOTH(ULTRA_LCD, NEWPANEL) +#if IS_ULTRA_LCD && IS_NEWPANEL #undef BEEPER_PIN #undef LCD_PINS_RS diff --git a/Marlin/src/pins/ramps/pins_K8800.h b/Marlin/src/pins/ramps/pins_K8800.h index 7e8c245a4158..5388c9621da5 100644 --- a/Marlin/src/pins/ramps/pins_K8800.h +++ b/Marlin/src/pins/ramps/pins_K8800.h @@ -113,7 +113,7 @@ #define LCD_CONTRAST_MAX 100 #define DEFAULT_LCD_CONTRAST 30 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #define BTN_EN1 17 #define BTN_EN2 16 #define BTN_ENC 23 diff --git a/Marlin/src/pins/ramps/pins_ORTUR_4.h b/Marlin/src/pins/ramps/pins_ORTUR_4.h index cef01bf62a46..e79973e06f07 100644 --- a/Marlin/src/pins/ramps/pins_ORTUR_4.h +++ b/Marlin/src/pins/ramps/pins_ORTUR_4.h @@ -91,7 +91,7 @@ // // LCD / Controller // -#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) +#if IS_RRD_FG_SC #undef BEEPER_PIN #define BEEPER_PIN 35 diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index de56d2b59d9b..c8578f2fa1ff 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -441,7 +441,7 @@ #define LCD_PINS_ENABLE 51 // SID (MOSI) #define LCD_PINS_D4 52 // SCK (CLK) clock - #elif BOTH(NEWPANEL, PANEL_ONE) + #elif BOTH(IS_NEWPANEL, PANEL_ONE) #define LCD_PINS_RS 40 #define LCD_PINS_ENABLE 42 @@ -462,7 +462,7 @@ #define LCD_PINS_ENABLE 29 #define LCD_PINS_D4 25 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 37 #endif @@ -481,10 +481,10 @@ #define LCD_PINS_DC 25 // Set as output on init #define LCD_PINS_RS 27 // Pull low for 1s to init // DOGM SPI LCD Support + #define DOGLCD_A0 LCD_PINS_DC #define DOGLCD_CS 16 #define DOGLCD_MOSI 17 #define DOGLCD_SCK 23 - #define DOGLCD_A0 LCD_PINS_DC #else #define LCD_PINS_RS 16 #define LCD_PINS_ENABLE 17 @@ -495,13 +495,13 @@ #define LCD_PINS_D7 29 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 33 #endif #endif - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL // Buttons attached to a shift register // Not wired yet //#define SHIFT_CLK 38 @@ -515,9 +515,9 @@ // // LCD Display input pins // - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC #define BEEPER_PIN 37 @@ -685,6 +685,7 @@ #elif ENABLED(AZSMZ_12864) // Pins only defined for RAMPS_SMART currently + #error "No pins defined for RAMPS with AZSMZ_12864." #elif IS_TFTGLCD_PANEL @@ -712,11 +713,11 @@ #endif #endif - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD -#if ENABLED(REPRAPWORLD_KEYPAD) && DISABLED(ADC_KEYPAD) +#if IS_RRW_KEYPAD && !HAS_ADC_BUTTONS #define SHIFT_OUT 40 #define SHIFT_CLK 44 #define SHIFT_LD 42 diff --git a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h index 9908d9494f34..23b1dfa34690 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h @@ -73,7 +73,7 @@ #undef E0_CS_PIN #undef E1_CS_PIN -#if ENABLED(ULTRA_LCD) && NONE(REPRAPWORLD_GRAPHICAL_LCD, CR10_STOCKDISPLAY) && !BOTH(NEWPANEL, PANEL_ONE) +#if IS_ULTRA_LCD && NONE(REPRAPWORLD_GRAPHICAL_LCD, CR10_STOCKDISPLAY) && !BOTH(IS_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_RIGIDBOARD.h b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h index c43d786aa2e2..345c51d5de59 100644 --- a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h +++ b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h @@ -124,7 +124,7 @@ #undef SD_DETECT_PIN #define SD_DETECT_PIN 22 -#elif ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) +#elif IS_RRD_SC #undef SD_DETECT_PIN #define SD_DETECT_PIN 22 diff --git a/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h b/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h index 406cbec8167f..1428de31a22b 100644 --- a/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h +++ b/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h @@ -34,7 +34,7 @@ // // I2C based DAC like on the Printrboard REVF -#define DAC_STEPPER_CURRENT +#define HAS_MOTOR_CURRENT_DAC // Channels available for DAC, For Rigidboard there are 4 #define DAC_STEPPER_ORDER { 0, 1, 2, 3 } diff --git a/Marlin/src/pins/ramps/pins_RUMBA.h b/Marlin/src/pins/ramps/pins_RUMBA.h index 5be2896e18c0..4af49d9164d4 100644 --- a/Marlin/src/pins/ramps/pins_RUMBA.h +++ b/Marlin/src/pins/ramps/pins_RUMBA.h @@ -227,7 +227,7 @@ #define SD_DETECT_PIN 49 #endif -#if ENABLED(NEWPANEL) +#if IS_NEWPANEL #define BTN_EN1 11 #define BTN_EN2 12 #define BTN_ENC 43 diff --git a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h index e7a59a69dffe..84e7e311264e 100644 --- a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h +++ b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h @@ -163,7 +163,7 @@ // LCD / Controller // -//#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) +//#if IS_RRD_SC #define LCD_PINS_RS -1 #define LCD_PINS_ENABLE -1 @@ -182,4 +182,4 @@ #define BEEPER_PIN -1 //#endif -//#endif // REPRAP_DISCOUNT_SMART_CONTROLLER +//#endif // IS_RRD_SC diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index 1c2cb609579e..54d91cee6a81 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -131,13 +131,13 @@ #if 0 && HAS_WIRED_LCD // LCD Display output pins - #if BOTH(NEWPANEL, PANEL_ONE) + #if BOTH(IS_NEWPANEL, PANEL_ONE) #undef LCD_PINS_D6 #define LCD_PINS_D6 57 #endif // LCD Display input pins - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #if ANY(VIKI2, miniVIKI) #undef DOGLCD_A0 #define DOGLCD_A0 23 diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index 1568288e69bc..725d36466c25 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -282,7 +282,7 @@ #define LCD_PINS_ENABLE 51 // SID (MOSI) #define LCD_PINS_D4 52 // SCK (CLK) clock - #elif BOTH(NEWPANEL, PANEL_ONE) + #elif BOTH(IS_NEWPANEL, PANEL_ONE) #define LCD_PINS_RS 40 #define LCD_PINS_ENABLE 42 @@ -309,7 +309,7 @@ #define LCD_PINS_ENABLE 29 #define LCD_PINS_D4 25 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 37 #endif @@ -333,13 +333,13 @@ #define LCD_PINS_D7 29 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 33 #endif #endif - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL // Buttons attached to a shift register // Not wired yet //#define SHIFT_CLK 38 @@ -353,9 +353,9 @@ // // LCD Display input pins // - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC #define BEEPER_PIN 37 @@ -486,7 +486,7 @@ #define BEEPER_PIN 33 // Buttons are directly attached to AUX-2 - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD #define SHIFT_OUT 40 #define SHIFT_CLK 44 #define SHIFT_LD 42 @@ -510,6 +510,6 @@ #endif - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif diff --git a/Marlin/src/pins/ramps/pins_ULTIMAKER.h b/Marlin/src/pins/ramps/pins_ULTIMAKER.h index 597a37bdbc8b..116301f4d459 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER.h @@ -123,7 +123,7 @@ #define BEEPER_PIN 18 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #define LCD_PINS_RS 20 #define LCD_PINS_ENABLE 17 @@ -139,7 +139,7 @@ #define SD_DETECT_PIN 38 - #else // !NEWPANEL - Old style panel with shift register + #else // !IS_NEWPANEL - Old style panel with shift register // Buttons attached to a shift register #define SHIFT_CLK 38 @@ -156,7 +156,7 @@ #define SD_DETECT_PIN -1 - #endif // !NEWPANEL + #endif // !IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h index c5bbd02bf5a9..9b17384aaf55 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h @@ -174,11 +174,11 @@ #define LCD_PINS_D6 32 #define LCD_PINS_D7 30 -#elif BOTH(BOARD_REV_1_5, ULTRA_LCD) +#elif BOTH(BOARD_REV_1_5, IS_ULTRA_LCD) #define BEEPER_PIN 18 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #define LCD_PINS_RS 20 #define LCD_PINS_ENABLE 17 @@ -194,7 +194,7 @@ #define SD_DETECT_PIN 38 - #else // !NEWPANEL - Old style panel with shift register + #else // !IS_NEWPANEL - Old style panel with shift register // Buttons attached to a shift register #define SHIFT_CLK 38 @@ -209,7 +209,7 @@ #define LCD_PINS_D6 20 #define LCD_PINS_D7 19 - #endif // !NEWPANEL + #endif // !IS_NEWPANEL #endif diff --git a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h index 8d6906117dd1..b01d1aafdfe0 100644 --- a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h +++ b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h @@ -143,7 +143,7 @@ // // LCD / Controller // -#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) +#if IS_RRD_FG_SC #define LCD_PINS_RS 18 #define LCD_PINS_ENABLE 15 #define LCD_PINS_D4 19 @@ -152,7 +152,7 @@ #define UI_VOLTAGE_LEVEL 1 #endif -#if ENABLED(NEWPANEL) +#if IS_NEWPANEL #define BTN_EN1 14 #define BTN_EN2 16 #define BTN_ENC 17 diff --git a/Marlin/src/pins/sam/pins_ARCHIM1.h b/Marlin/src/pins/sam/pins_ARCHIM1.h index 6e3768c663bc..347afe9ebdf2 100644 --- a/Marlin/src/pins/sam/pins_ARCHIM1.h +++ b/Marlin/src/pins/sam/pins_ARCHIM1.h @@ -192,10 +192,10 @@ #define SD_DETECT_PIN 2 // D2 PB25_TIOA0 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL // 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 - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/sam/pins_ARCHIM2.h b/Marlin/src/pins/sam/pins_ARCHIM2.h index 5a3fe0e4d5c7..5923ea0f8f84 100644 --- a/Marlin/src/pins/sam/pins_ARCHIM2.h +++ b/Marlin/src/pins/sam/pins_ARCHIM2.h @@ -247,11 +247,11 @@ #define LCD_PINS_D7 34 // D34 PC2_PWML0 #define SD_DETECT_PIN 2 // D2 PB25_TIOA0 +#endif - #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 +#if ANY(IS_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 diff --git a/Marlin/src/pins/sam/pins_DUE3DOM.h b/Marlin/src/pins/sam/pins_DUE3DOM.h index cd4033aa6f1f..a5c22ff3f2ba 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM.h @@ -122,7 +122,7 @@ #define LCD_PINS_D6 46 #define LCD_PINS_D7 47 - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC #define BEEPER_PIN 41 diff --git a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h index 5f9ad48a08c4..b3e76199dcc5 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h @@ -114,7 +114,7 @@ #define LCD_PINS_D6 46 #define LCD_PINS_D7 47 - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC #define BEEPER_PIN 41 diff --git a/Marlin/src/pins/sam/pins_RADDS.h b/Marlin/src/pins/sam/pins_RADDS.h index 60fe3512378e..cd895365d041 100644 --- a/Marlin/src/pins/sam/pins_RADDS.h +++ b/Marlin/src/pins/sam/pins_RADDS.h @@ -248,7 +248,7 @@ #define SDSS 10 #define SD_DETECT_PIN 14 - #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #elif IS_RRD_FG_SC // The REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER requires // an adapter such as https://www.thingiverse.com/thing:1740725 diff --git a/Marlin/src/pins/sam/pins_RAMPS_DUO.h b/Marlin/src/pins/sam/pins_RAMPS_DUO.h index bfc3968ffac2..44e2695a5358 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_DUO.h +++ b/Marlin/src/pins/sam/pins_RAMPS_DUO.h @@ -78,7 +78,7 @@ // #if HAS_WIRED_LCD - #if BOTH(NEWPANEL, PANEL_ONE) + #if BOTH(IS_NEWPANEL, PANEL_ONE) #undef LCD_PINS_D4 #define LCD_PINS_D4 68 @@ -89,7 +89,7 @@ #define LCD_PINS_D7 67 #endif - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) @@ -115,7 +115,7 @@ #else - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD #undef BTN_EN1 #define BTN_EN1 67 // encoder @@ -127,6 +127,6 @@ #endif #endif - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h index ee525eefaa56..a0dbddf56792 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h +++ b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h @@ -148,7 +148,7 @@ #define BTN_ENC 35 #define SD_DETECT_PIN 49 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #define LCD_PINS_RS 16 #define LCD_PINS_ENABLE 17 #endif @@ -178,7 +178,7 @@ #define NEOPIXEL_PIN 25 #endif - #elif ENABLED(NEWPANEL) + #elif IS_NEWPANEL #define LCD_PINS_D4 23 #define LCD_PINS_D5 25 diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index b9e61fb27c53..49378541a9c2 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -202,7 +202,7 @@ // #if HAS_WIRED_LCD - #if ANY(RADDS_DISPLAY, REPRAP_DISCOUNT_SMART_CONTROLLER, REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) #define BEEPER_PIN 62 #define LCD_PINS_D4 48 #define LCD_PINS_D5 50 @@ -211,12 +211,12 @@ #define SD_DETECT_PIN 51 #endif - #if EITHER(RADDS_DISPLAY, REPRAP_DISCOUNT_SMART_CONTROLLER) + #if EITHER(RADDS_DISPLAY, IS_RRD_SC) #define LCD_PINS_RS 63 #define LCD_PINS_ENABLE 64 - #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #elif IS_RRD_FG_SC #define LCD_PINS_RS 52 #define LCD_PINS_ENABLE 53 @@ -265,7 +265,7 @@ #endif // SPARK_FULL_GRAPHICS - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #define BTN_EN1 44 #define BTN_EN2 42 #define BTN_ENC 40 diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h index dc0c1279954b..1cc2eee6b0b2 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -188,7 +188,7 @@ // #if HAS_WIRED_LCD - #if ANY(RADDS_DISPLAY, REPRAP_DISCOUNT_SMART_CONTROLLER, REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) #define BEEPER_PIN 62 #define LCD_PINS_D4 48 #define LCD_PINS_D5 50 @@ -197,12 +197,12 @@ #define SD_DETECT_PIN 51 #endif - #if EITHER(RADDS_DISPLAY, REPRAP_DISCOUNT_SMART_CONTROLLER) + #if EITHER(RADDS_DISPLAY, IS_RRD_SC) #define LCD_PINS_RS 63 #define LCD_PINS_ENABLE 64 - #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #elif IS_RRD_FG_SC #define LCD_PINS_RS 52 #define LCD_PINS_ENABLE 53 @@ -247,7 +247,7 @@ #endif - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #define BTN_EN1 44 #define BTN_EN2 42 #define BTN_ENC 40 diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 6076be07e9d4..1948acf8971e 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -299,7 +299,7 @@ //#define LCD_PINS_ENABLE 51 // SID (MOSI) //#define LCD_PINS_D4 52 // SCK (CLK) clock - #elif BOTH(NEWPANEL, PANEL_ONE) + #elif BOTH(IS_NEWPANEL, PANEL_ONE) // TO TEST //#define LCD_PINS_RS 40 @@ -318,7 +318,7 @@ //#define LCD_PINS_ENABLE 29 //#define LCD_PINS_D4 25 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL // TO TEST //#define BEEPER_PIN 37 #endif @@ -354,13 +354,13 @@ #define LCD_PINS_D7 29 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 33 #endif #endif - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL // Buttons attached to a shift register // Not wired yet //#define SHIFT_CLK 38 @@ -374,9 +374,9 @@ // // LCD Display input pins // - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC #define BEEPER_PIN 37 @@ -565,7 +565,7 @@ //#define BEEPER_PIN 33 // Buttons are directly attached to AUX-2 - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD // TO TEST //#define SHIFT_OUT 40 //#define SHIFT_CLK 44 @@ -592,7 +592,7 @@ #endif #endif - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/sanguino/pins_ANET_10.h b/Marlin/src/pins/sanguino/pins_ANET_10.h index 74692a21a390..d48db36287ee 100644 --- a/Marlin/src/pins/sanguino/pins_ANET_10.h +++ b/Marlin/src/pins/sanguino/pins_ANET_10.h @@ -151,7 +151,7 @@ #if HAS_WIRED_LCD #define LCD_SDSS 28 - #if ENABLED(ADC_KEYPAD) + #if HAS_ADC_BUTTONS #define SERVO0_PIN 27 // free for BLTouch/3D-Touch #define LCD_PINS_RS 28 #define LCD_PINS_ENABLE 29 @@ -160,7 +160,7 @@ #define LCD_PINS_D6 16 #define LCD_PINS_D7 17 #define ADC_KEYPAD_PIN 1 - #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #elif IS_RRD_FG_SC // 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/sanguino/pins_SANGUINOLOLU_11.h b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h index 438d49d615c8..69b351e3fced 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h @@ -136,7 +136,7 @@ #define LCD_BACKLIGHT_PIN 17 // LCD backlight LED #endif -#if NONE(SPINDLE_FEATURE, LASER_FEATURE) && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(ULTRA_LCD, NEWPANEL)// try to use IO Header +#if NONE(SPINDLE_FEATURE, LASER_FEATURE) && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(IS_ULTRA_LCD, IS_NEWPANEL) // try to use IO Header #define CASE_LIGHT_PIN 4 // Hardware PWM - see if IO Header is available #endif @@ -185,7 +185,7 @@ // with M42 instead of BEEPER_PIN. #define BEEPER_PIN 27 - #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #if IS_RRD_FG_SC #ifndef BOARD_ST7920_DELAY_1 #define BOARD_ST7920_DELAY_1 DELAY_NS(0) #endif @@ -283,7 +283,7 @@ #endif - #if ENABLED(NEWPANEL) && !defined(BTN_EN1) + #if IS_NEWPANEL && !defined(BTN_EN1) #define BTN_EN1 11 #define BTN_EN2 10 #endif @@ -294,7 +294,7 @@ // M3/M4/M5 - Spindle/Laser Control // #if HAS_CUTTER - #if !MB(AZTEEG_X1) && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(ULTRA_LCD, NEWPANEL)// try to use IO Header + #if !MB(AZTEEG_X1) && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(IS_ULTRA_LCD, IS_NEWPANEL) // try to use IO Header #define SPINDLE_LASER_ENA_PIN 10 // Pullup or pulldown! #define SPINDLE_LASER_PWM_PIN 4 // Hardware PWM diff --git a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h index 838ffe38aa9a..4257b2c40e1e 100644 --- a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h +++ b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h @@ -225,7 +225,7 @@ // // All the above are also RRDSC with rotary encoder // -#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) +#if IS_RRD_SC #define BTN_EN1 2 #define BTN_EN2 12 #define BTN_ENC 29 diff --git a/Marlin/src/pins/sensitive_pins.h b/Marlin/src/pins/sensitive_pins.h index 169f74b43787..d7eb1872458f 100644 --- a/Marlin/src/pins/sensitive_pins.h +++ b/Marlin/src/pins/sensitive_pins.h @@ -608,12 +608,6 @@ #define _Z_PROBE #endif -#if TEMP_SENSOR_BED && PIN_EXISTS(HEATER_BED) - #define _HEATER_BED HEATER_BED_PIN, -#else - #define _HEATER_BED -#endif - #if PIN_EXISTS(FAN) #define _FAN0 FAN_PIN, #else @@ -660,21 +654,26 @@ #define _FANC #endif -#if PIN_EXISTS(HEATER_BED) && PIN_EXISTS(TEMP_BED) +#if TEMP_SENSOR_BED && PINS_EXIST(TEMP_BED, HEATER_BED) #define _BED_PINS HEATER_BED_PIN, analogInputToDigitalPin(TEMP_BED_PIN), #else #define _BED_PINS #endif -#if PIN_EXISTS(TEMP_CHAMBER) - #define __CHAMBER_PINS CHAMBER_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_CHAMBER_PIN), +#if TEMP_SENSOR_CHAMBER && PIN_EXISTS(TEMP_CHAMBER) + #define _CHAMBER_TEMP analogInputToDigitalPin(TEMP_CHAMBER_PIN), +#else + #define _CHAMBER_TEMP +#endif +#if TEMP_SENSOR_CHAMBER && PINS_EXIST(TEMP_CHAMBER, HEATER_CHAMBER) + #define _CHAMBER_HEATER HEATER_CHAMBER_PIN, #else - #define __CHAMBER_PINS + #define _CHAMBER_HEATER #endif -#if PIN_EXISTS(HEATER_CHAMBER) - #define _CHAMBER_PINS __CHAMBER_PINS HEATER_CHAMBER_PIN, +#if TEMP_SENSOR_CHAMBER && PINS_EXIST(TEMP_CHAMBER, CHAMBER_AUTO_FAN) + #define _CHAMBER_FAN CHAMBER_AUTO_FAN_PIN, #else - #define _CHAMBER_PINS + #define _CHAMBER_FAN #endif #ifndef HAL_SENSITIVE_PINS @@ -685,6 +684,6 @@ _X_PINS _Y_PINS _Z_PINS _X2_PINS _Y2_PINS _Z2_PINS _Z3_PINS _Z4_PINS _Z_PROBE \ _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS _E5_PINS _E6_PINS _E7_PINS \ _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS _H5_PINS _H6_PINS _H7_PINS \ - _PS_ON _HEATER_BED _FAN0 _FAN1 _FAN2 _FAN3 _FAN4 _FAN5 _FAN6 _FAN7 _FANC \ - _BED_PINS _CHAMBER_PINS HAL_SENSITIVE_PINS \ + _PS_ON _FAN0 _FAN1 _FAN2 _FAN3 _FAN4 _FAN5 _FAN6 _FAN7 _FANC \ + _BED_PINS _CHAMBER_TEMP _CHAMBER_HEATER _CHAMBER_FAN HAL_SENSITIVE_PINS \ } 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 47fff4467c72..ce43e677e285 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 @@ -175,7 +175,7 @@ #else // !FYSETC_MINI_12864 #define LCD_PINS_D4 PC13 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PB7 #define LCD_PINS_D6 PC15 #define LCD_PINS_D7 PC14 diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D.h b/Marlin/src/pins/stm32f1/pins_CHITU3D.h index 3a872db0253e..1d8f4f684b06 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D.h @@ -126,7 +126,7 @@ #define LCD_PINS_RS PD1 // 49 // CS chip select /SS chip slave select #define LCD_PINS_ENABLE PD3 // 51 // SID (MOSI) #define LCD_PINS_D4 PD4 // 52 // SCK (CLK) clock - #elif BOTH(NEWPANEL, PANEL_ONE) + #elif BOTH(IS_NEWPANEL, PANEL_ONE) #define LCD_PINS_RS PB8 #define LCD_PINS_ENABLE PD2 #define LCD_PINS_D4 PB12 @@ -140,7 +140,7 @@ #define LCD_PINS_D5 PB13 #define LCD_PINS_D6 PB14 #define LCD_PINS_D7 PB15 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN PC1 // 33 // Buttons attached to a shift register // Not wired yet @@ -151,9 +151,9 @@ #endif #endif - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC #define BEEPER_PIN PC5 @@ -254,7 +254,7 @@ #define BEEPER_PIN PC1 // 33 // Buttons directly attached to AUX-2 - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD #define BTN_EN1 PE0 // 64 #define BTN_EN2 PD11 // 59 #define BTN_ENC PD15 // 63 @@ -279,6 +279,6 @@ #endif #endif - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h index 5d81d1eca9ab..33ec27ddbad2 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h @@ -129,8 +129,6 @@ #define TOUCH_MISO_PIN PA6 // SPI1_MISO #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - #define LCD_RESET_PIN PF11 - #define LCD_BACKLIGHT_PIN PD13 #define TFT_RESET_PIN PF11 #define TFT_BACKLIGHT_PIN PD13 @@ -140,14 +138,9 @@ #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 - #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 +#if ENABLED(TFT_LVGL_UI) // LVGL #define HAS_SPI_FLASH_FONT 1 #define HAS_GCODE_PREVIEW 1 @@ -155,16 +148,14 @@ #define HAS_LANG_SELECT_SCREEN 1 #define HAS_BAK_VIEW_IN_FLASH 0 #define HAS_LOGO_IN_FLASH 0 -#elif ENABLED(TFT_480x320) +#elif ENABLED(TFT_COLOR_UI) // Color UI #define TFT_DRIVER ILI9488 #define TFT_BUFFER_SIZE 14400 -#elif ENABLED(FSMC_GRAPHICAL_TFT) - // Emulated DOGM - #define GRAPHICAL_TFT_UPSCALE 3 #endif -#if EITHER(HAS_TFT_LVGL_UI, TFT_480x320) +// XPT2046 Touch Screen calibration +#if EITHER(TFT_LVGL_UI, TFT_COLOR_UI) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -17181 #endif @@ -177,7 +168,7 @@ #ifndef XPT2046_Y_OFFSET #define XPT2046_Y_OFFSET -9 #endif -#elif ENABLED(FSMC_GRAPHICAL_TFT) +#elif ENABLED(TFT_CLASSIC_UI) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -12316 #endif diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h index e6c9b33a5a29..990d33b759a0 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h @@ -135,15 +135,15 @@ // TronXY TFT Support // -// Shared FSMC Configs #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 LCD_RESET_PIN PF11 - #define LCD_BACKLIGHT_PIN PD13 #define TFT_RESET_PIN PF11 #define TFT_BACKLIGHT_PIN PD13 @@ -153,14 +153,9 @@ #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 - #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 +#if ENABLED(TFT_LVGL_UI) // LVGL #define HAS_SPI_FLASH_FONT 1 #define HAS_GCODE_PREVIEW 1 @@ -168,16 +163,14 @@ #define HAS_LANG_SELECT_SCREEN 1 #define HAS_BAK_VIEW_IN_FLASH 0 #define HAS_LOGO_IN_FLASH 0 -#elif ENABLED(TFT_480x320) +#elif ENABLED(TFT_COLOR_UI) // Color UI #define TFT_DRIVER ILI9488 #define TFT_BUFFER_SIZE 14400 -#elif ENABLED(FSMC_GRAPHICAL_TFT) - // Emulated DOGM - #define GRAPHICAL_TFT_UPSCALE 3 #endif -#if EITHER(HAS_TFT_LVGL_UI, TFT_480x320) +// XPT2046 Touch Screen calibration +#if EITHER(TFT_LVGL_UI, TFT_COLOR_UI) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -17181 #endif @@ -190,7 +183,7 @@ #ifndef XPT2046_Y_OFFSET #define XPT2046_Y_OFFSET -9 #endif -#elif ENABLED(FSMC_GRAPHICAL_TFT) +#elif ENABLED(TFT_CLASSIC_UI) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -12316 #endif diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index ebe5964d0588..d2c587beb85a 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -162,7 +162,7 @@ // not connected to a pin #define SD_DETECT_PIN PC3 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL // The encoder and click button #define BTN_EN1 PC10 #define BTN_EN2 PC11 diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index de5ea45d44e8..deca1a054641 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -153,7 +153,7 @@ //#define LCD_CONTRAST_INIT 190 - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL #define BTN_EN1 PC10 #define BTN_EN2 PC11 #define BTN_ENC PC12 diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h index ca25c45a7bba..00c5721384df 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h @@ -137,7 +137,7 @@ // #if HAS_WIRED_LCD - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC // // LCD display on J2 FFC40 // Geeetech's LCD2004A Control Panel is very much like @@ -172,7 +172,7 @@ #endif // HAS_WIRED_LCD -#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) +#if IS_RRD_SC // // Geeetech's LCD2004A Control Panel is very much like // RepRapDiscount Smart Controller, but adds an FFC40 connector diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h index 02fd3bcae721..b10748e57f3b 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h @@ -137,7 +137,7 @@ // #if HAS_WIRED_LCD - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC // // LCD display on J2 FFC40 // Geeetech's LCD2004A Control Panel is very much like diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index ca25c45a7bba..00c5721384df 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -137,7 +137,7 @@ // #if HAS_WIRED_LCD - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC // // LCD display on J2 FFC40 // Geeetech's LCD2004A Control Panel is very much like @@ -172,7 +172,7 @@ #endif // HAS_WIRED_LCD -#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) +#if IS_RRD_SC // // Geeetech's LCD2004A Control Panel is very much like // RepRapDiscount Smart Controller, but adds an FFC40 connector diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h index fc18263fddf6..b913530f676b 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h @@ -137,7 +137,7 @@ // #if HAS_WIRED_LCD - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC // // LCD display on J2 FFC40 diff --git a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h index 64948039baf9..3c277233d73e 100644 --- a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -39,7 +39,7 @@ #define STM32_XL_DENSITY #endif -// #define MCU_STM32F103ZE // not yet required +//#define MCU_STM32F103ZE // not yet required // Enable EEPROM Emulation for this board, so that we don't overwrite factory data //#define I2C_EEPROM // AT24C64 diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 47d7118b53d1..af81bbebe2d4 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -118,7 +118,6 @@ * because Marlin uses the reset as a failsafe to revive a glitchy LCD. */ -#define LCD_RESET_PIN PC4 // pin 33 #define TFT_RESET_PIN PC4 // pin 33 #define TFT_BACKLIGHT_PIN PD12 // pin 59 #define FSMC_CS_PIN PD7 // pin 88 = FSMC_NE1 @@ -131,13 +130,11 @@ #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 +// Longer/Alfawise TFT +#define LONGER_LK_TFT28 -//#define TFT_DRIVER ILI9341 +// Buffer for Color UI +#define TFT_BUFFER_SIZE 3200 /** * Note: Alfawise U20/U30 boards DON'T use SPI2, as the hardware designer diff --git a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h index d3c26c497d8f..95e7e92174fa 100644 --- a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h +++ b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h @@ -33,6 +33,9 @@ #define BOARD_INFO_NAME "Malyan M200" #endif +// Prevents hanging from an extra watchdog init +#define DISABLE_WATCHDOG_INIT + // Assume Flash EEPROM #if NO_EEPROM_SELECTED #define FLASH_EEPROM_EMULATION diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index 26a0c9260e03..63c0da476dfc 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -126,6 +126,11 @@ #endif #define LED_PIN PB2 +#if HAS_FSMC_TFT || HAS_GRAPHICAL_TFT + #define TFT_CS_PIN PG12 // NE4 + #define TFT_RS_PIN PF0 // A0 +#endif + #if HAS_FSMC_TFT /** * Note: MKS Robin TFT screens use various TFT controllers @@ -141,10 +146,8 @@ */ //#define LCD_RESET_PIN PF6 #define LCD_BACKLIGHT_PIN PG11 - #define FSMC_CS_PIN PG12 // NE4 - #define FSMC_RS_PIN PF0 // A0 - #define TFT_CS_PIN FSMC_CS_PIN - #define TFT_RS_PIN FSMC_RS_PIN + #define FSMC_CS_PIN TFT_CS_PIN + #define FSMC_RS_PIN TFT_RS_PIN #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT #define FSMC_DMA_DEV DMA2 @@ -152,8 +155,6 @@ #elif HAS_GRAPHICAL_TFT #define TFT_RESET_PIN PF6 #define TFT_BACKLIGHT_PIN PG11 - #define TFT_CS_PIN PG12 // NE4 - #define TFT_RS_PIN PF0 // A0 #endif #if NEED_TOUCH_PINS diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index d9ba4e3c408b..4998c92dc5be 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -269,27 +269,19 @@ #endif -#if ENABLED(SPI_GRAPHICAL_TFT) +#if HAS_SPI_GRAPHICAL_TFT // Emulated DOGM SPI - #ifndef GRAPHICAL_TFT_UPSCALE - #define GRAPHICAL_TFT_UPSCALE 3 - #endif - #ifndef TFT_PIXEL_OFFSET_Y - #define TFT_PIXEL_OFFSET_Y 32 - #endif - + #define LCD_PINS_ENABLE PD13 + #define LCD_PINS_RS PC6 #define BTN_ENC PE13 #define BTN_EN1 PE8 #define BTN_EN2 PE11 - - #define LCD_PINS_ENABLE PD13 - #define LCD_PINS_RS PC6 - #elif ENABLED(TFT_480x320_SPI) #define TFT_DRIVER ST7796 #define TFT_BUFFER_SIZE 14400 #endif +// XPT2046 Touch Screen calibration #if EITHER(HAS_TFT_LVGL_UI, TFT_480x320_SPI) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -17253 @@ -303,7 +295,7 @@ #ifndef XPT2046_Y_OFFSET #define XPT2046_Y_OFFSET -24 #endif -#elif ENABLED(SPI_GRAPHICAL_TFT) +#elif HAS_SPI_GRAPHICAL_TFT #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -11386 #endif @@ -341,7 +333,7 @@ #else // !MKS_MINI_12864 #define LCD_PINS_D4 PE14 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PE15 #define LCD_PINS_D6 PD11 #define LCD_PINS_D7 PD10 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 015e29bdbe60..af2908545bd9 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -154,7 +154,7 @@ #else #define LCD_PINS_D4 PA6 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PA7 #define LCD_PINS_D6 PC4 #define LCD_PINS_D7 PC5 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index aa1ccedb3550..ffd21917dd66 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -103,7 +103,7 @@ #else // !MKS_MINI_12864 #define LCD_PINS_D4 PC1 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 -1 #define LCD_PINS_D6 -1 #define LCD_PINS_D7 -1 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h index d5318b8e8787..493efc5c7b81 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h @@ -124,7 +124,7 @@ #else // !MKS_MINI_12864 #define LCD_PINS_D4 PA6 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PA7 #define LCD_PINS_D6 PC4 #define LCD_PINS_D7 PC5 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index 2b099b3e9372..14f9c3b6260b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -139,23 +139,7 @@ * If the screen stays white, disable 'LCD_RESET_PIN' * to let the bootloader init the screen. */ -#if ENABLED(TOUCH_SCREEN) - #ifndef XPT2046_X_CALIBRATION - #define XPT2046_X_CALIBRATION 12033 - #endif - #ifndef XPT2046_Y_CALIBRATION - #define XPT2046_Y_CALIBRATION -9047 - #endif - #ifndef XPT2046_X_OFFSET - #define XPT2046_X_OFFSET -30 - #endif - #ifndef XPT2046_Y_OFFSET - #define XPT2046_Y_OFFSET 254 - #endif -#endif - -#if ENABLED(FSMC_GRAPHICAL_TFT) - +#if EITHER(HAS_FSMC_GRAPHICAL_TFT, TFT_320x240) #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 @@ -165,39 +149,38 @@ #define LCD_RESET_PIN PC6 // FSMC_RST #define LCD_BACKLIGHT_PIN PD13 +#endif - #if NEED_TOUCH_PINS - #define TOUCH_CS_PIN PC2 // SPI2_NSS - #define TOUCH_SCK_PIN PB13 // SPI2_SCK - #define TOUCH_MISO_PIN PB14 // SPI2_MISO - #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI - #endif - -#elif ENABLED(TFT_320x240) //TFT32/28 - - #define TFT_RESET_PIN PC6 - #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 - +#if BOTH(NEED_TOUCH_PINS, HAS_FSMC_GRAPHICAL_TFT) || ENABLED(TFT_320x240) #define TOUCH_CS_PIN PC2 // SPI2_NSS #define TOUCH_SCK_PIN PB13 // SPI2_SCK #define TOUCH_MISO_PIN PB14 // SPI2_MISO #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI +#endif +#if ENABLED(TFT_320x240) // TFT32/28 #define TFT_DRIVER ILI9341 #define TFT_BUFFER_SIZE 14400 - + #define ILI9341_COLOR_RGB // 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 +#endif - #define ILI9341_COLOR_RGB +#if ENABLED(TOUCH_SCREEN) + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION 12033 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION -9047 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET -30 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET 254 + #endif #endif #define HAS_SPI_FLASH 1 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index 35909ed43080..86dab411212c 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -171,6 +171,9 @@ // Shared FSMC Configs #if HAS_FSMC_TFT + #define DOGLCD_MOSI -1 // prevent redefine Conditionals_post.h + #define DOGLCD_SCK -1 + #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 @@ -179,9 +182,6 @@ #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 TFT_RESET_PIN PC6 // FSMC_RST #define TFT_BACKLIGHT_PIN PD13 @@ -193,61 +193,12 @@ #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 -#endif - -#if ENABLED(FSMC_GRAPHICAL_TFT) - // Emulated DOGM - #define DOGLCD_MOSI -1 // prevent redefine Conditionals_post.h - #define DOGLCD_SCK -1 - - #ifndef GRAPHICAL_TFT_UPSCALE - #define GRAPHICAL_TFT_UPSCALE 3 - #endif - #ifndef TFT_WIDTH - #define TFT_WIDTH 480 - #endif - #ifndef TFT_PIXEL_OFFSET_X - #define TFT_PIXEL_OFFSET_X 48 - #endif - #ifndef TFT_HEIGHT - #define TFT_HEIGHT 320 - #endif - #ifndef TFT_PIXEL_OFFSET_Y - #define TFT_PIXEL_OFFSET_Y 32 - #endif - -#elif ENABLED(TFT_320x240) // TFT32/28 - #define TFT_RESET_PIN PC6 - #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 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 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) - #define TFT_DRIVER ILI9488 #define TFT_BUFFER_SIZE 14400 - #define ILI9488_ORIENTATION ILI9488_MADCTL_MX | ILI9488_MADCTL_MV #endif -#if EITHER(TFT_LVGL_UI_FSMC, TFT_480x320) +// XPT2046 Touch Screen calibration +#if EITHER(HAS_TFT_LVGL_UI_FSMC, TFT_480x320) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION 17880 #endif @@ -260,7 +211,7 @@ #ifndef XPT2046_Y_OFFSET #define XPT2046_Y_OFFSET 349 #endif -#elif ENABLED(FSMC_GRAPHICAL_TFT) +#elif ENABLED(TFT_CLASSIC_UI) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION 12149 #endif @@ -273,7 +224,7 @@ #ifndef XPT2046_Y_OFFSET #define XPT2046_Y_OFFSET 256 #endif -#elif ENABLED(TFT_320x240) // TFT32/28 +#elif ENABLED(TFT_320x240) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -12246 #endif 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 b40c66496af6..b1e49f4d9fd2 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -269,40 +269,23 @@ #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 - #ifndef TFT_WIDTH - #define TFT_WIDTH 480 - #endif - #ifndef TFT_HEIGHT - #define TFT_HEIGHT 320 - #endif - - #define LCD_READ_ID 0xD3 #define LCD_USE_DMA_SPI #endif -#if ENABLED(SPI_GRAPHICAL_TFT) +#if ENABLED(TFT_CLASSIC_UI) // Emulated DOGM SPI - #ifndef GRAPHICAL_TFT_UPSCALE - #define GRAPHICAL_TFT_UPSCALE 3 - #endif - #ifndef TFT_PIXEL_OFFSET_Y - #define TFT_PIXEL_OFFSET_Y 32 - #endif - + #define LCD_PINS_ENABLE PD13 + #define LCD_PINS_RS PC6 #define BTN_ENC PE13 #define BTN_EN1 PE8 #define BTN_EN2 PE11 - - #define LCD_PINS_ENABLE PD13 - #define LCD_PINS_RS PC6 - -#elif ENABLED(TFT_480x320_SPI) - #define TFT_DRIVER ST7796 +#elif ENABLED(TFT_COLOR_UI) #define TFT_BUFFER_SIZE 14400 #endif -#if EITHER(TFT_LVGL_UI_SPI, TFT_480x320_SPI) +// XPT2046 Touch Screen calibration +#if EITHER(TFT_LVGL_UI, TFT_COLOR_UI) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -17253 #endif @@ -315,7 +298,7 @@ #ifndef XPT2046_Y_OFFSET #define XPT2046_Y_OFFSET -24 #endif -#elif ENABLED(SPI_GRAPHICAL_TFT) +#elif ENABLED(TFT_CLASSIC_UI) #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -11386 #endif @@ -362,7 +345,7 @@ #else // !MKS_MINI_12864 #define LCD_PINS_D4 PE14 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PE15 #define LCD_PINS_D6 PD11 #define LCD_PINS_D7 PD10 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index 12c40b31b374..db6bc9320506 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -200,6 +200,7 @@ #elif SD_CONNECTION_IS(ONBOARD) #define SDIO_SUPPORT #define SD_DETECT_PIN PD12 + #define ONBOARD_SD_CS_PIN PC11 #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "No custom SD drive cable defined for this board." #endif @@ -209,7 +210,7 @@ * If the screen stays white, disable 'LCD_RESET_PIN' * to let the bootloader init the screen. */ -#if ENABLED(FSMC_GRAPHICAL_TFT) +#if HAS_FSMC_GRAPHICAL_TFT #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 @@ -253,7 +254,7 @@ #else // !MKS_MINI_12864 && !ENDER2_STOCKDISPLAY #define LCD_PINS_D4 PF14 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PF15 #define LCD_PINS_D6 PF12 #define LCD_PINS_D7 PF13 diff --git a/Marlin/src/pins/stm32f1/pins_STM32F1R.h b/Marlin/src/pins/stm32f1/pins_STM32F1R.h index cf2ba2c5fa74..1b9a62fe9ed7 100644 --- a/Marlin/src/pins/stm32f1/pins_STM32F1R.h +++ b/Marlin/src/pins/stm32f1/pins_STM32F1R.h @@ -103,7 +103,7 @@ #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) + #elif BOTH(IS_NEWPANEL, PANEL_ONE) #define LCD_PINS_RS PB8 #define LCD_PINS_ENABLE PD2 #define LCD_PINS_D4 PB12 @@ -117,7 +117,7 @@ #define LCD_PINS_D5 PB13 #define LCD_PINS_D6 PB14 #define LCD_PINS_D7 PB15 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 33 // Buttons attached to a shift register // Not wired yet @@ -128,9 +128,9 @@ #endif #endif - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC #define BEEPER_PIN 37 @@ -231,7 +231,7 @@ #define BEEPER_PIN 33 // Buttons directly attached to AUX-2 - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD #define BTN_EN1 64 #define BTN_EN2 59 #define BTN_ENC 63 @@ -256,6 +256,6 @@ #endif #endif - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h index e74698f89eff..3ebc4bca571f 100644 --- a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h @@ -118,7 +118,7 @@ #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) + #elif BOTH(IS_NEWPANEL, PANEL_ONE) #define LCD_PINS_RS PB8 #define LCD_PINS_ENABLE PD2 #define LCD_PINS_D4 PB12 @@ -132,7 +132,7 @@ #define LCD_PINS_D5 PB13 #define LCD_PINS_D6 PB14 #define LCD_PINS_D7 PB15 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 33 // Buttons attached to a shift register // Not wired yet @@ -151,9 +151,9 @@ #define TOUCH_MISO_PIN PB15 #define TOUCH_INT_PIN PC6 // (PenIRQ coming from ADS7843) - #elif ENABLED(NEWPANEL) + #elif IS_NEWPANEL - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC #define BEEPER_PIN 37 @@ -255,7 +255,7 @@ #define BEEPER_PIN 33 // Buttons directly attached to AUX-2 - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD #define BTN_EN1 64 #define BTN_EN2 59 #define BTN_ENC 63 @@ -280,6 +280,6 @@ #endif #endif - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h index 4745641ea934..bfd1f2abdcbd 100644 --- a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h @@ -120,14 +120,50 @@ * Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu * because Marlin uses the reset as a failsafe to revive a glitchy LCD. */ -#define LCD_RESET_PIN PF11 -#define LCD_BACKLIGHT_PIN PD13 -#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 +#if HAS_FSMC_TFT + #define TFT_RESET_PIN PF11 + #define TFT_BACKLIGHT_PIN PD13 + #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 ANYCUBIC_TFT35 +#else + #define LCD_RESET_PIN PF11 + #define LCD_BACKLIGHT_PIN PD13 +#endif + +// XPT2046 Touch Screen calibration +#if ENABLED(TFT_COLOR_UI) || ENABLED(TFT_LVGL_UI) + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION -17181 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION 11434 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET 501 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET -9 + #endif +#elif ENABLED(TFT_CLASSIC_UI) + #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 #if NEED_TOUCH_PINS #define TOUCH_CS_PIN PB7 // SPI2_NSS diff --git a/Marlin/src/pins/stm32f4/pins_BEAST.h b/Marlin/src/pins/stm32f4/pins_BEAST.h index 268b7b59cd45..279d0b9ec70d 100644 --- a/Marlin/src/pins/stm32f4/pins_BEAST.h +++ b/Marlin/src/pins/stm32f4/pins_BEAST.h @@ -126,7 +126,7 @@ #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) + #elif BOTH(IS_NEWPANEL, PANEL_ONE) #define LCD_PINS_RS PB8 #define LCD_PINS_ENABLE PD2 #define LCD_PINS_D4 PB12 @@ -140,7 +140,7 @@ #define LCD_PINS_D5 PB13 #define LCD_PINS_D6 PB14 #define LCD_PINS_D7 PB15 - #if DISABLED(NEWPANEL) + #if !IS_NEWPANEL #define BEEPER_PIN 33 // Buttons attached to a shift register // Not wired yet @@ -151,9 +151,9 @@ #endif #endif - #if ENABLED(NEWPANEL) + #if IS_NEWPANEL - #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #if IS_RRD_SC #define BEEPER_PIN 37 @@ -255,7 +255,7 @@ #define BEEPER_PIN 33 // Buttons directly attached to AUX-2 - #if ENABLED(REPRAPWORLD_KEYPAD) + #if IS_RRW_KEYPAD #define BTN_EN1 64 #define BTN_EN2 59 #define BTN_ENC 63 @@ -280,6 +280,6 @@ #endif #endif - #endif // NEWPANEL + #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD 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 c37f6cce0445..6f9c3d309588 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -228,7 +228,7 @@ #define LCD_PINS_ENABLE PE9 #define LCD_PINS_D4 PE10 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PE11 #define LCD_PINS_D6 PE12 #define LCD_PINS_D7 PE13 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 dc8ce9f2d1b2..eaf90da1aee4 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -385,7 +385,7 @@ #endif #endif // !FYSETC_MINI_12864 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PG7 #define LCD_PINS_D6 PG6 #define LCD_PINS_D7 PG5 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 83fd987d9dbf..995fcb95854a 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -350,7 +350,7 @@ #endif #endif // !FYSETC_MINI_12864 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PG3 #define LCD_PINS_D6 PG6 #define LCD_PINS_D7 PG7 diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 151f6c3bc06e..8638e9a4cfb1 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -252,7 +252,7 @@ #endif #endif // !FYSETC_MINI_12864 - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PC12 #define LCD_PINS_D6 PD0 #define LCD_PINS_D7 PD1 diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h index d52bb11d1206..9a6a16516cac 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h @@ -161,7 +161,7 @@ #define DOGLCD_A0 PE14 #endif - #if ENABLED(ULTIPANEL) + #if IS_ULTIPANEL #define LCD_PINS_D5 PE13 #define LCD_PINS_D6 PE14 #define LCD_PINS_D7 PE15 diff --git a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h new file mode 100644 index 000000000000..0a00e03612aa --- /dev/null +++ b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h @@ -0,0 +1,201 @@ +/** + * 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 + +#if NOT_TARGET(STM32F767xx) + #error "Oops! Select an STM32F767 environment" +#endif + +#define BOARD_INFO_NAME "NUCLEO-F767ZI" +#define DEFAULT_MACHINE_NAME "Prototype Board" + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + // Not yet supported on F7 hardware + // #define FLASH_EEPROM_LEVELING +#endif + +/** + * Timer assignments + * + * TIM1 - + * TIM2 - Hardware PWM (Fan/Heater Pins) + * TIM3 - Hardware PWM (Servo Pins) + * TIM4 - STEP_TIMER (Marlin) + * TIM5 - + * TIM6 - TIMER_TONE (variant.h) + * TIM7 - TIMER_SERVO (variant.h) + * TIM9 - TIMER_SERIAL (platformio.ini) + * TIM10 - For some reason trips Watchdog when used for SW Serial + * TIM11 - + * TIM12 - + * TIM13 - + * TIM14 - TEMP_TIMER (Marlin) + * + */ +#define STEP_TIMER 4 +#define TEMP_TIMER 14 + + +/** + * These pin assignments are arbitrary and intending for testing purposes. + * Assignments may not be ideal, and not every assignment has been tested. + * Proceed at your own risk. + * _CN7_ + * (X_STEP) PC6 | · · | PB8 (X_EN) + * (X_DIR) PB15 | · · | PB9 (X_CS) + * (LCD_D4) PB13 | · · | AVDD + * _CN8_ PB12 | · · | GND + * NC | · · | PC8 (HEATER_0) PA15 | · · | PA5 (SCLK) + * IOREF | · · | PC9 (BEEPER) PC7 | · · | PA6 (MISO) + * RESET | · · | PC10 (SERVO1_PIN) PB5 | · · | PA7 (MOSI) + * +3.3V | · · | PC11 (HEATER_BED) PB3 | · · | PD14 (SD_DETECT) + * +5V | · · | PC12 (SDSS) PA4 | · · | PD15 (LCD_ENABLE) + * GND | · · | PD2 (SERVO0_PIN) PB4 | · · | PF12 (LCD_RS) + * GND | · · | PG2  ̄ ̄ ̄ + * VIN | · · | PG3 +_*  ̄ ̄ ̄ _CN10 + * AVDD | · · | PF13 (BTN_EN1) + * _CN9_ AGND | · · | PE9 (BTN_EN2) + * (TEMP_0) PA3 | · · | PD7 GND | · · | PE11 (BTN_ENC) + * (TEMP_BED) PC0 | · · | PD6 PB1 | · · | PF14 + * PC3 | · · | PD5 PC2 | · · | PE13 + * PF3 | · · | PD4 PF4 | · · | PF15 + * PF5 | · · | PD3 (E_STEP) PB6 | · · | PG14 (E_EN) + * PF10 | · · | GND (E_DIR) PB2 | · · | PG9 (E_CS) + * NC | · · | PE2 GND | · · | PE8 + * PA7 | · · | PE4 PD13 | · · | PE7 + * PF2 | · · | PE5 PD12 | · · | GND + * (Y_STEP) PF1 | · · | PE6 (Y_EN) (Z_STEP) PD11 | · · | PE10 (Z_EN) + * (Y_DIR) PF0 | · · | PE3 (Y_CS) (Z_DIR) PE2 | · · | PE12 (Z_CS) + * GND | · · | PF8 GND | · · | PE14 + * (Z_MAX) PD0 | · · | PF7 (X_MIN) PA0 | · · | PE15 + * (Z_MIN) PD1 | · · | PF9 (X_MAX) PB0 | · · | PB10 (FAN) + * (Y_MAX) PG0 | · · | PG1 (Y_MIN) PE0 | · · | PB11 (FAN1) + *  ̄ ̄ ̄  ̄ ̄ ̄ ̄ + */ + +#define X_MIN_PIN PF7 +#define X_MAX_PIN PF9 +#define Y_MIN_PIN PG1 +#define Y_MAX_PIN PG0 +#define Z_MIN_PIN PD1 +#define Z_MAX_PIN PD0 + +// +// Steppers +// +#define X_STEP_PIN PC6 +#define X_DIR_PIN PB15 +#define X_ENABLE_PIN PB8 +#define X_CS_PIN PB9 + +#define Y_STEP_PIN PF1 +#define Y_DIR_PIN PF0 +#define Y_ENABLE_PIN PE6 +#define Y_CS_PIN PE3 + +#define Z_STEP_PIN PD11 +#define Z_DIR_PIN PE2 +#define Z_ENABLE_PIN PE10 +#define Z_CS_PIN PE12 + +#define E0_STEP_PIN PB6 +#define E0_DIR_PIN PB2 +#define E0_ENABLE_PIN PG14 +#define E0_CS_PIN PG9 + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PB9 + #define X_SERIAL_RX_PIN PB9 + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN PE3 + + #define Z_SERIAL_TX_PIN PE12 + #define Z_SERIAL_RX_PIN PE12 + + #define E_SERIAL_TX_PIN PG9 + #define E_SERIAL_RX_PIN PG9 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA3 +#define TEMP_BED_PIN PC0 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA15 // PWM Capable, TIM2_CH1 +#define HEATER_BED_PIN PB3 // PWM Capable, TIM2_CH2 + +#ifndef FAN_PIN + #define FAN_PIN PB10 // PWM Capable, TIM2_CH3 +#endif +#define FAN1_PIN PB11 // PWM Capable, TIM2_CH4 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN +#endif + +// +// Servos +// +#define SERVO0_PIN PB4 // PWM Capable, TIM3_CH1 +#define SERVO1_PIN PB5 // PWM Capable, TIM3_CH2 + +// SPI for external SD Card (Not entirely sure this will work) +#define SCK_PIN PA5 +#define MISO_PIN PA6 +#define MOSI_PIN PA7 +#define SS_PIN PA4 +#define SDSS PA4 + +#define LED_PIN LED_BLUE + +// +// LCD / Controller +// +#if IS_RRD_FG_SC + #define BEEPER_PIN PC7 // LCD_BEEPER + #define BTN_ENC PE11 // BTN_ENC + #define SD_DETECT_PIN PD14 + #define LCD_PINS_RS PF12 // LCD_RS + #define LCD_PINS_ENABLE PD15 // LCD_EN + #define LCD_PINS_D4 PB13 // LCD_D4 + // #define LCD_PINS_D5 + // #define LCD_PINS_D6 + // #define LCD_PINS_D7 + #define BTN_EN1 PF13 // BTN_EN1 + #define BTN_EN2 PE9 // BTN_EN2 + + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #define BOARD_ST7920_DELAY_2 DELAY_NS(63) + #define BOARD_ST7920_DELAY_3 DELAY_NS(780) +#endif diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h index ffecc03b4a25..2401c976f157 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h @@ -124,7 +124,7 @@ // // LCD / Controller // -#if BOTH(ULTRA_LCD, NEWPANEL) +#if IS_ULTRA_LCD && IS_NEWPANEL #define LCD_PINS_RS 9 // E1 JP11-11 #define LCD_PINS_ENABLE 8 // E0 JP11-10 @@ -166,4 +166,4 @@ #endif -#endif // ULTRA_LCD && NEWPANEL +#endif // IS_ULTRA_LCD && IS_NEWPANEL diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index 6ffd35dff273..d4f9fc76415d 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -67,7 +67,7 @@ #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" #endif -#ifndef USBCON +#if !defined(__MARLIN_DEPS__) && !defined(USBCON) #error "USBCON should be defined by the platform for this board." #endif @@ -143,7 +143,7 @@ #endif // NO_EXTRUDRBOARD // Enable control of stepper motor currents with the I2C based MCP4728 DAC used on Printrboard REVF -#define DAC_STEPPER_CURRENT +#define HAS_MOTOR_CURRENT_DAC // Set default drive strength percents if not already defined - X, Y, Z, E axis #ifndef DAC_MOTOR_CURRENT_DEFAULT diff --git a/Marlin/src/pins/teensy2/pins_TEENSY2.h b/Marlin/src/pins/teensy2/pins_TEENSY2.h index 4efd83d9bc5c..d43e39b09aac 100644 --- a/Marlin/src/pins/teensy2/pins_TEENSY2.h +++ b/Marlin/src/pins/teensy2/pins_TEENSY2.h @@ -168,7 +168,7 @@ // // LCD / Controller // -#if ENABLED(ULTIPANEL) +#if IS_ULTIPANEL #define LCD_PINS_RS 8 // E0 #define LCD_PINS_ENABLE 9 // E1 #define LCD_PINS_D4 10 // C0 diff --git a/Marlin/src/pins/teensy2/pins_TEENSYLU.h b/Marlin/src/pins/teensy2/pins_TEENSYLU.h index 9de119b62b4a..54cee137ad24 100644 --- a/Marlin/src/pins/teensy2/pins_TEENSYLU.h +++ b/Marlin/src/pins/teensy2/pins_TEENSYLU.h @@ -141,7 +141,7 @@ // // LCD / Controller // -#if BOTH(ULTRA_LCD, NEWPANEL) +#if IS_ULTRA_LCD && IS_NEWPANEL #define BEEPER_PIN -1 @@ -154,7 +154,7 @@ #define SD_DETECT_PIN -1 -#endif // ULTRA_LCD && NEWPANEL +#endif // IS_ULTRA_LCD && IS_NEWPANEL // // M3/M4/M5 - Spindle/Laser Control diff --git a/Marlin/src/pins/teensy3/pins_TEENSY35_36.h b/Marlin/src/pins/teensy3/pins_TEENSY35_36.h index 2e09c8a425ca..b8a0ffe2c80b 100644 --- a/Marlin/src/pins/teensy3/pins_TEENSY35_36.h +++ b/Marlin/src/pins/teensy3/pins_TEENSY35_36.h @@ -139,13 +139,13 @@ #define LCD_PINS_D7 45 #endif -#if ENABLED(NEWPANEL) +#if IS_NEWPANEL #define BTN_EN1 46 #define BTN_EN2 47 #define BTN_ENC 48 #endif -#if ENABLED(REPRAPWORLD_KEYPAD) +#if IS_RRW_KEYPAD #define SHIFT_OUT 40 #define SHIFT_CLK 44 #define SHIFT_LD 42 diff --git a/Marlin/src/pins/teensy4/pins_T41U5XBB.h b/Marlin/src/pins/teensy4/pins_T41U5XBB.h index 830637bebd93..5f62bb05a64b 100644 --- a/Marlin/src/pins/teensy4/pins_T41U5XBB.h +++ b/Marlin/src/pins/teensy4/pins_T41U5XBB.h @@ -85,17 +85,17 @@ #define X_STEP_PIN 2 #define X_DIR_PIN 3 #define X_ENABLE_PIN 10 -//#define X_CS_PIN 30 +//#define X_CS_PIN 30 #define Y_STEP_PIN 4 #define Y_DIR_PIN 5 #define Y_ENABLE_PIN 40 -//#define Y_CS_PIN 31 +//#define Y_CS_PIN 31 #define Z_STEP_PIN 6 #define Z_DIR_PIN 7 #define Z_ENABLE_PIN 39 -//#define Z_CS_PIN 32 +//#define Z_CS_PIN 32 #define E0_STEP_PIN 8 #define E0_DIR_PIN 9 diff --git a/Marlin/src/pins/teensy4/pins_TEENSY41.h b/Marlin/src/pins/teensy4/pins_TEENSY41.h index 31c6fda5c900..21a1ff675f24 100644 --- a/Marlin/src/pins/teensy4/pins_TEENSY41.h +++ b/Marlin/src/pins/teensy4/pins_TEENSY41.h @@ -81,17 +81,17 @@ #define X_STEP_PIN 0 #define X_DIR_PIN 1 #define X_ENABLE_PIN 6 -//#define X_CS_PIN 30 +//#define X_CS_PIN 30 #define Y_STEP_PIN 2 #define Y_DIR_PIN 3 #define Y_ENABLE_PIN 7 -//#define Y_CS_PIN 31 +//#define Y_CS_PIN 31 #define Z_STEP_PIN 4 #define Z_DIR_PIN 5 #define Z_ENABLE_PIN 8 -//#define Z_CS_PIN 32 +//#define Z_CS_PIN 32 #define E0_STEP_PIN 9 #define E0_DIR_PIN 10 @@ -123,8 +123,8 @@ // #define LED_PIN 13 #define SOL0_PIN 28 -//#define PS_ON_PIN 1 -//#define FILWIDTH_PIN 6 // A6 +//#define PS_ON_PIN 1 +//#define FILWIDTH_PIN 6 // A6 #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index e154ea9f314b..b809b2c10fec 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -29,7 +29,7 @@ #include "cardreader.h" #include "../MarlinCore.h" -#include "../lcd/ultralcd.h" +#include "../lcd/marlinui.h" #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/dwin/e3v2/dwin.h" diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index a097df510523..539d31654265 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -94,7 +94,7 @@ static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined"); #include "Sd2Card_FlashDrive.h" -#include "../../lcd/ultralcd.h" +#include "../../lcd/marlinui.h" static enum { UNINITIALIZED, diff --git a/README.md b/README.md index 1e78528b7a88..f3c2afa87477 100644 --- a/README.md +++ b/README.md @@ -10,63 +10,118 @@ Additional documentation can be found at the [Marlin Home Page](https://marlinfw.org/). Please test this firmware and let us know if it misbehaves in any way. Volunteers are standing by! -## Marlin 2.0 +## Marlin 2.0 Bugfix Branch + +__Not for production use. Use with caution!__ Marlin 2.0 takes this popular RepRap firmware to the next level by adding support for much faster 32-bit and ARM-based boards while improving support for 8-bit AVR boards. Read about Marlin's decision to use a "Hardware Abstraction Layer" below. +This branch is for patches to the latest 2.0.x release version. Periodically this branch will form the basis for the next minor 2.0.x release. + Download earlier versions of Marlin on the [Releases page](https://github.com/MarlinFirmware/Marlin/releases). ## Building Marlin 2.0 -To build Marlin 2.0 you'll need [Arduino IDE 1.8.8 or newer](https://www.arduino.cc/en/main/software) or [PlatformIO](http://docs.platformio.org/en/latest/ide.html#platformio-ide). Detailed build and install instructions are posted at: - - - [Installing Marlin (Arduino)](http://marlinfw.org/docs/basics/install_arduino.html) - - [Installing Marlin (VSCode)](http://marlinfw.org/docs/basics/install_platformio_vscode.html). - -### Supported Platforms - - Platform|MCU|Example Boards - --------|---|------- - [Arduino AVR](https://www.arduino.cc/)|ATmega|RAMPS, Melzi, RAMBo - [Teensy++ 2.0](http://www.microchip.com/wwwproducts/en/AT90USB1286)|AT90USB1286|Printrboard - [Arduino Due](https://www.arduino.cc/en/Guide/ArduinoDue)|SAM3X8E|RAMPS-FD, RADDS, RAMPS4DUE - [LPC1768](http://www.nxp.com/products/microcontrollers-and-processors/arm-based-processors-and-mcus/lpc-cortex-m-mcus/lpc1700-cortex-m3/512kb-flash-64kb-sram-ethernet-usb-lqfp100-package:LPC1768FBD100)|ARM® Cortex-M3|MKS SBASE, Re-ARM, Selena Compact - [LPC1769](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc1700-cortex-m3/512kb-flash-64kb-sram-ethernet-usb-lqfp100-package:LPC1769FBD100)|ARM® Cortex-M3|Smoothieboard, Azteeg X5 mini, TH3D EZBoard - [STM32F103](https://www.st.com/en/microcontrollers-microprocessors/stm32f103.html)|ARM® Cortex-M3|Malyan M200, GTM32 Pro, MKS Robin, BTT SKR Mini - [STM32F401](https://www.st.com/en/microcontrollers-microprocessors/stm32f401.html)|ARM® Cortex-M4|ARMED, Rumba32, SKR Pro, Lerdge, FYSETC S6 - [STM32F7x6](https://www.st.com/en/microcontrollers-microprocessors/stm32f7x6.html)|ARM® Cortex-M7|The Borg, RemRam V1 - [SAMD51P20A](https://www.adafruit.com/product/4064)|ARM® Cortex-M4|Adafruit Grand Central M4 - [Teensy 3.5](https://www.pjrc.com/store/teensy35.html)|ARM® Cortex-M4| - [Teensy 3.6](https://www.pjrc.com/store/teensy36.html)|ARM® Cortex-M4| - [Teensy 4.0](https://www.pjrc.com/store/teensy40.html)|ARM® Cortex-M7| - [Teensy 4.1](https://www.pjrc.com/store/teensy41.html)|ARM® Cortex-M7| - -## Submitting Changes - -- Submit **Bug Fixes** as Pull Requests to the ([bugfix-2.0.x](https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.0.x)) branch. -- Follow the [Coding Standards](http://marlinfw.org/docs/development/coding_standards.html) to gain points with the maintainers. -- Please submit your questions and concerns to the [Issue Queue](https://github.com/MarlinFirmware/Marlin/issues). +To build Marlin 2.0 you'll need [Arduino IDE 1.8.8 or newer](https://www.arduino.cc/en/main/software) or [PlatformIO](https://docs.platformio.org/en/latest/ide.html#platformio-ide). We've posted detailed instructions on [Building Marlin with Arduino](https://marlinfw.org/docs/basics/install_arduino.html) and [Building Marlin with PlatformIO for ReArm](https://marlinfw.org/docs/basics/install_rearm.html) (which applies well to other 32-bit boards). + +## Hardware Abstraction Layer (HAL) + +Marlin 2.0 introduces a layer of abstraction so that all the existing high-level code can be built for 32-bit platforms while still retaining full 8-bit AVR compatibility. Retaining AVR compatibility and a single code-base is important to us, because we want to make sure that features and patches get as much testing and attention as possible, and that all platforms always benefit from the latest improvements. + +### Current HALs + + #### AVR (8-bit) + + board|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [Arduino AVR](https://www.arduino.cc/)|ATmega, ATTiny, etc.|16-20MHz|64-256k|2-16k|5V|no + + #### DUE + + boards|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [Arduino Due](https://www.arduino.cc/en/Guide/ArduinoDue), [RAMPS-FD](https://www.reprap.org/wiki/RAMPS-FD), etc.|[SAM3X8E ARM-Cortex M3](https://www.microchip.com/wwwproducts/en/ATsam3x8e)|84MHz|512k|64+32k|3.3V|no + + #### ESP32 + + board|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [ESP32](https://www.espressif.com/en/products/hardware/esp32/overview)|Tensilica Xtensa LX6|160-240MHz variants|---|---|3.3V|--- + + #### LPC1768 / LPC1769 + + boards|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [Re-ARM](https://www.kickstarter.com/projects/1245051645/re-arm-for-ramps-simple-32-bit-upgrade)|[LPC1768 ARM-Cortex M3](https://www.nxp.com/products/microcontrollers-and-processors/arm-based-processors-and-mcus/lpc-cortex-m-mcus/lpc1700-cortex-m3/512kb-flash-64kb-sram-ethernet-usb-lqfp100-package:LPC1768FBD100)|100MHz|512k|32+16+16k|3.3-5V|no + [MKS SBASE](https://reprap.org/forum/read.php?13,499322)|LPC1768 ARM-Cortex M3|100MHz|512k|32+16+16k|3.3-5V|no + [Selena Compact](https://github.com/Ales2-k/Selena)|LPC1768 ARM-Cortex M3|100MHz|512k|32+16+16k|3.3-5V|no + [Azteeg X5 GT](https://www.panucatt.com/azteeg_X5_GT_reprap_3d_printer_controller_p/ax5gt.htm)|LPC1769 ARM-Cortex M3|120MHz|512k|32+16+16k|3.3-5V|no + [Smoothieboard](https://reprap.org/wiki/Smoothieboard)|LPC1769 ARM-Cortex M3|120MHz|512k|64k|3.3-5V|no + + #### SAMD51 -## Marlin Support + boards|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [Adafruit Grand Central M4](https://www.adafruit.com/product/4064)|[SAMD51P20A ARM-Cortex M4](https://www.microchip.com/wwwproducts/en/ATSAMD51P20A)|120MHz|1M|256k|3.3V|yes -For best results getting help with configuration and troubleshooting, please use the following resources: + #### STM32F1 + + boards|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [Arduino STM32](https://github.com/rogerclarkmelbourne/Arduino_STM32)|[STM32F1](https://www.st.com/en/microcontrollers-microprocessors/stm32f103.html) ARM-Cortex M3|72MHz|256-512k|48-64k|3.3V|no + [Geeetech3D GTM32](https://github.com/Geeetech3D/Diagram/blob/master/Rostock301/Hardware_GTM32_PRO_VB.pdf)|[STM32F1](https://www.st.com/en/microcontrollers-microprocessors/stm32f103.html) ARM-Cortex M3|72MHz|256-512k|48-64k|3.3V|no + + #### STM32F4 + + boards|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [STEVAL-3DP001V1](https://www.st.com/en/evaluation-tools/steval-3dp001v1.html)|[STM32F401VE Arm-Cortex M4](https://www.st.com/en/microcontrollers-microprocessors/stm32f401ve.html)|84MHz|512k|64+32k|3.3-5V|yes + + #### Teensy++ 2.0 + + boards|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [Teensy++ 2.0](https://www.microchip.com/wwwproducts/en/AT90USB1286)|[AT90USB1286](https://www.microchip.com/wwwproducts/en/AT90USB1286)|16MHz|128k|8k|5V|no + + #### Teensy 3.1 / 3.2 + + boards|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [Teensy 3.2](https://www.pjrc.com/store/teensy32.html)|[MK20DX256VLH7](https://www.mouser.com/ProductDetail/NXP-Freescale/MK20DX256VLH7) ARM-Cortex M4|72MHz|256k|32k|3.3V-5V|yes + + #### Teensy 3.5 / 3.6 + + boards|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [Teensy 3.5](https://www.pjrc.com/store/teensy35.html)|[MK64FX512VMD12](https://www.mouser.com/ProductDetail/NXP-Freescale/MK64FX512VMD12) ARM-Cortex M4|120MHz|512k|192k|3.3-5V|yes + [Teensy 3.6](https://www.pjrc.com/store/teensy36.html)|[MK66FX1M0VMD18](https://www.mouser.com/ProductDetail/NXP-Freescale/MK66FX1M0VMD18) ARM-Cortex M4|180MHz|1M|256k|3.3V|yes + + #### Teensy 4.0 / 4.1 + + boards|processor|speed|flash|sram|logic|fpu + ----|---------|-----|-----|----|-----|--- + [Teensy 4.0](https://www.pjrc.com/store/teensy40.html)|[IMXRT1062DVL6A](https://www.mouser.com/new/nxp-semiconductors/nxp-imx-rt1060-crossover-processor/) ARM-Cortex M7|600MHz|1M|2M|3.3V|yes + [Teensy 4.1](https://www.pjrc.com/store/teensy41.html)|[IMXRT1062DVJ6A](https://www.mouser.com/new/nxp-semiconductors/nxp-imx-rt1060-crossover-processor/) ARM-Cortex M7|600MHz|1M|2M|3.3V|yes + +## Submitting Patches + +Proposed patches should be submitted as a Pull Request against the ([bugfix-2.0.x](https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.0.x)) branch. + +- This branch is for fixing bugs and integrating any new features for the duration of the Marlin 2.0.x life-cycle. +- Follow the [Coding Standards](https://marlinfw.org/docs/development/coding_standards.html) to gain points with the maintainers. +- Please submit your questions and concerns to the [Issue Queue](https://github.com/MarlinFirmware/Marlin/issues). -- [Marlin Documentation](http://marlinfw.org) - Official Marlin documentation -- [Marlin Discord](https://discord.gg/n5NJ59y) - Discuss issues with Marlin users and developers -- Facebook Group ["Marlin Firmware"](https://www.facebook.com/groups/1049718498464482/) -- RepRap.org [Marlin Forum](http://forums.reprap.org/list.php?415) -- [Tom's 3D Forums](https://forum.toms3d.org/) -- Facebook Group ["Marlin Firmware for 3D Printers"](https://www.facebook.com/groups/3Dtechtalk/) -- [Marlin Configuration](https://www.youtube.com/results?search_query=marlin+configuration) on YouTube +### [RepRap.org Wiki Page](https://reprap.org/wiki/Marlin) ## Credits The current Marlin dev team consists of: - - Scott Lahteine [[@thinkyhead](https://github.com/thinkyhead)] - USA   [Donate](http://www.thinkyhead.com/donate-to-marlin) + - Scott Lahteine [[@thinkyhead](https://github.com/thinkyhead)] - USA   [Donate](https://www.thinkyhead.com/donate-to-marlin) / Flattr: [![Flattr Scott](https://api.flattr.com/button/flattr-badge-small.png)](https://flattr.com/submit/auto?user_id=thinkyhead&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) - Roxanne Neufeld [[@Roxy-3D](https://github.com/Roxy-3D)] - USA - Chris Pepper [[@p3p](https://github.com/p3p)] - UK - Bob Kuhn [[@Bob-the-Kuhn](https://github.com/Bob-the-Kuhn)] - USA + - João Brazio [[@jbrazio](https://github.com/jbrazio)] - Portugal - Erik van der Zalm [[@ErikZalm](https://github.com/ErikZalm)] - Netherlands   [![Flattr Erik](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) ## License diff --git a/buildroot/tests/LPC1769-tests b/buildroot/tests/LPC1769-tests index a7a6456d026d..4314b0d5ff8d 100755 --- a/buildroot/tests/LPC1769-tests +++ b/buildroot/tests/LPC1769-tests @@ -61,7 +61,7 @@ opt_set MOTHERBOARD BOARD_COHESION3D_REMIX opt_set X_DRIVER_TYPE TMC2130 opt_set Y_DRIVER_TYPE TMC2130 opt_set Z_DRIVER_TYPE TMC2130 -opt_enable AUTO_BED_LEVELING_BILINEAR EEPROM_SETTINGS EEPROM_CHITCHAT \ +opt_enable AUTO_BED_LEVELING_BILINEAR EEPROM_SETTINGS EEPROM_CHITCHAT MECHANICAL_GANTRY_CALIBRATION \ TMC_USE_SW_SPI MONITOR_DRIVER_STATUS STEALTHCHOP_XY STEALTHCHOP_Z HYBRID_THRESHOLD \ SENSORLESS_PROBING Z_SAFE_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY TMC_DEBUG \ EXPERIMENTAL_I2CBUS diff --git a/buildroot/tests/NUCLEO_F767ZI-tests b/buildroot/tests/NUCLEO_F767ZI-tests new file mode 100644 index 000000000000..05125a453902 --- /dev/null +++ b/buildroot/tests/NUCLEO_F767ZI-tests @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Build tests for NUCLEO_F767ZI +# + +# exit on first failure +set -e + +# +# Build with the default configurations +# +restore_configs +opt_set MOTHERBOARD BOARD_NUCLEO_F767ZI +opt_set SERIAL_PORT -1 +opt_enable BLTOUCH Z_SAFE_HOMING SPEAKER +opt_set X_DRIVER_TYPE TMC2209 +opt_set Y_DRIVER_TYPE TMC2208 +exec_test $1 $2 "Mixed timer usage" + +# clean up +restore_configs diff --git a/buildroot/tests/STM32F103VE_longer-tests b/buildroot/tests/STM32F103VE_longer-tests index 85b22c1284dd..8eb9e4cd1b0f 100755 --- a/buildroot/tests/STM32F103VE_longer-tests +++ b/buildroot/tests/STM32F103VE_longer-tests @@ -7,8 +7,6 @@ set -e use_example_configs Alfawise/U20 -opt_set MOTHERBOARD BOARD_LONGER3D_LK -opt_set SERIAL_PORT 1 opt_enable BAUD_RATE_GCODE exec_test $1 $2 "Full-featured U20 config" diff --git a/buildroot/tests/mks_robin-tests b/buildroot/tests/mks_robin-tests index d6350622052c..424623107097 100644 --- a/buildroot/tests/mks_robin-tests +++ b/buildroot/tests/mks_robin-tests @@ -8,9 +8,7 @@ set -e use_example_configs Mks/Robin -opt_disable TFT_320x240 -opt_enable FSMC_GRAPHICAL_TFT -exec_test $1 $2 "MKS Robin base configuration" +exec_test $1 $2 "MKS Robin config (FSMC Color UI)" # cleanup restore_configs diff --git a/buildroot/tests/mks_robin_nano35-tests b/buildroot/tests/mks_robin_nano35-tests index 92c97be756cd..ce98f563b9d9 100644 --- a/buildroot/tests/mks_robin_nano35-tests +++ b/buildroot/tests/mks_robin_nano35-tests @@ -7,39 +7,50 @@ # exit on first failure set -e +# +# MKS Robin nano v1.2 Emulated DOGM FSMC +# use_example_configs Mks/Robin opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO -opt_disable TFT_320x240 -opt_enable TOUCH_SCREEN -opt_enable FSMC_GRAPHICAL_TFT exec_test $1 $2 "MKS Robin nano v1.2 Emulated DOGM FSMC" +# +# MKS Robin v2 nano LVGL SPI +# (Robin v2 nano has no FSMC interface) +# use_example_configs Mks/Robin opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 -opt_disable TFT_320x240 -opt_enable TOUCH_SCREEN -opt_enable SPI_GRAPHICAL_TFT +opt_disable TFT_INTERFACE_FSMC +opt_enable TFT_INTERFACE_SPI exec_test $1 $2 "MKS Robin v2 nano Emulated DOGM SPI" +# +# MKS Robin nano v1.2 LVGL FSMC +# use_example_configs Mks/Robin opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO -opt_disable TFT_320x240 -opt_disable TOUCH_SCREEN -opt_enable TFT_LVGL_UI_FSMC +opt_disable TFT_CLASSIC_UI TFT_COLOR_UI TOUCH_SCREEN TFT_RES_320x240 +opt_enable TFT_LVGL_UI TFT_RES_480x320 exec_test $1 $2 "MKS Robin nano v1.2 LVGL FSMC" +# +# MKS Robin v2 nano LVGL SPI +# (Robin v2 nano has no FSMC interface) +# use_example_configs Mks/Robin opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 -opt_disable TFT_320x240 -opt_disable TOUCH_SCREEN -opt_enable TFT_LVGL_UI_SPI +opt_disable TFT_INTERFACE_FSMC TFT_COLOR_UI TOUCH_SCREEN TFT_RES_320x240 +opt_enable TFT_INTERFACE_SPI TFT_LVGL_UI TFT_RES_480x320 exec_test $1 $2 "MKS Robin v2 nano LVGL SPI" +# +# MKS Robin v2 nano New Color UI 480x320 SPI +# (Robin v2 nano has no FSMC interface) +# 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 +opt_disable TFT_INTERFACE_FSMC TFT_RES_320x240 +opt_enable TFT_INTERFACE_SPI TFT_RES_480x320 exec_test $1 $2 "MKS Robin v2 nano New Color UI 480x320 SPI" # cleanup diff --git a/buildroot/tests/mks_robin_pro-tests b/buildroot/tests/mks_robin_pro-tests index 7ae4670fedac..50ec7b0dd127 100644 --- a/buildroot/tests/mks_robin_pro-tests +++ b/buildroot/tests/mks_robin_pro-tests @@ -13,7 +13,7 @@ opt_set X_DRIVER_TYPE TMC2209 opt_set Y_DRIVER_TYPE TMC2130 opt_set TEMP_SENSOR_BED 1 opt_disable THERMAL_PROTECTION_HOTENDS -exec_test $1 $2 "MKS Robin Pro with TMC Drivers, hotend thermal protection disabled" +exec_test $1 $2 "MKS Robin Pro, TMC Drivers, no thermal protection" # cleanup -#restore_configs +restore_configs diff --git a/platformio.ini b/platformio.ini index d4beca6519be..0abb4ac38810 100644 --- a/platformio.ini +++ b/platformio.ini @@ -26,7 +26,7 @@ include_dir = Marlin # [common] default_src_filter = + - - + - - - - - - + - - - - - - - - - - - - @@ -110,6 +110,7 @@ default_src_filter = + - - + - - - + - - - - @@ -211,7 +212,7 @@ HAS_TRINAMIC_CONFIG = TMCStepper@~0.7.1 src_filter=+ + + + + HAS_STEALTHCHOP = src_filter=+ SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip -HAS_I2C_DIGIPOT = SlowSoftI2CMaster +HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster src_filter=+ HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip src_filter=+ @@ -226,7 +227,7 @@ HAS_WIRED_LCD = src_filter=+ HAS_MARLINUI_HD44780 = src_filter=+ HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.4.1 src_filter=+ -HAS_(FSMC|SPI)_TFT = src_filter=+ + +HAS_(FSMC|SPI)_TFT = src_filter=+ + + HAS_FSMC_TFT = src_filter=+ + HAS_SPI_TFT = src_filter=+ + HAS_GRAPHICAL_TFT = src_filter=+ @@ -277,7 +278,7 @@ CANCEL_OBJECTS = src_filter=+ + + EXTERNAL_CLOSED_LOOP_CONTROLLER = src_filter=+ + USE_CONTROLLER_FAN = src_filter=+ -DAC_STEPPER_CURRENT = src_filter=+ +HAS_MOTOR_CURRENT_DAC = src_filter=+ DIRECT_STEPPING = src_filter=+ + EMERGENCY_PARSER = src_filter=+ - I2C_POSITION_ENCODERS = src_filter=+ @@ -309,6 +310,7 @@ MK2_MULTIPLEXER = src_filter=+ EXT_SOLENOID|MANUAL_SOLENOID_CONTROL = src_filter=+ + HAS_CUTTER = src_filter=+ + EXPERIMENTAL_I2CBUS = src_filter=+ + +MECHANICAL_GANTRY_CAL.+ = src_filter=+ Z_STEPPER_AUTO_ALIGN = src_filter=+ + G26_MESH_VALIDATION = src_filter=+ ASSISTED_TRAMMING = src_filter=+ @@ -443,7 +445,7 @@ board = megaatmega2560 # [env:mega2560ext] platform = atmelavr -extends = mega2560 +extends = env:mega2560 board = megaatmega2560 board_build.variant = megaextendedpins extra_scripts = ${common.extra_scripts} @@ -557,6 +559,7 @@ build_unflags = -g -ggdb platform = teensy extends = common_avr8 board = at90usb1286 +lib_ignore = ${env:common_avr8.lib_ignore} Teensy_ADC # # AT90USB1286 boards using DFU bootloader @@ -853,6 +856,17 @@ board = remram_v1 build_flags = ${common.build_flags} -DUSE_STM32GENERIC -DSTM32GENERIC -DSTM32F7 -DMENU_USB_SERIAL -DMENU_SERIAL=SerialUSB -DHAL_IWDG_MODULE_ENABLED src_filter = ${common.default_src_filter} + - +# +# ST NUCLEO-F767ZI Development Board +# This environment is for testing purposes prior to control boards +# being readily available based on STM32F7 MCUs +# +[env:NUCLEO_F767ZI] +platform = ${common_stm32.platform} +extends = common_stm32 +board = nucleo_f767zi +build_flags = ${common_stm32.build_flags} -DTIMER_SERIAL=TIM9 + # # ARMED (STM32) # @@ -906,8 +920,6 @@ build_flags = ${common_stm32f1.build_flags} # # MKS Robin Nano (STM32F103VET6) -# v1.2 - Emulated Graphical 128x64 (DOGM) UI and LVGL UI -# v2.0 - LVGL UI # [env:mks_robin_nano35] platform = ${common_stm32f1.platform}