diff --git a/Marlin-bugfix-2.0.x/Marlin/Configuration.h b/Marlin-bugfix-2.0.x/Marlin/Configuration.h index 6aac20d..9109e72 100644 --- a/Marlin-bugfix-2.0.x/Marlin/Configuration.h +++ b/Marlin-bugfix-2.0.x/Marlin/Configuration.h @@ -373,6 +373,7 @@ * 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! * 5 : 100K thermistor - ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan, J-Head, and E3D) (4.7k pullup) * 501 : 100K Zonestar (Tronxy X3A) Thermistor + * 502 : 100K Zonestar Thermistor used by hot bed in Zonestar Prusa P802M * 512 : 100k RPW-Ultra hotend thermistor (4.7k pullup) * 6 : 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) * 7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) @@ -815,6 +816,8 @@ */ #if DISABLED(CLASSIC_JERK) #define JUNCTION_DEVIATION_MM 0.013 // (mm) Distance from real junction edge + #define JD_HANDLE_SMALL_SEGMENTS // Use curvature estimation instead of just the junction angle + // for small segments (< 1mm) with large junction angles (> 135°). #endif /** @@ -902,6 +905,11 @@ */ //#define BLTOUCH +/** + * Pressure sensor with a BLTouch-like interface + */ +//#define CREALITY_TOUCH + /** * Touch-MI Probe by hotends.fr * @@ -1988,6 +1996,12 @@ // //#define MKS_MINI_12864 +// +// MKS LCD12864A/B with graphic controller and SD support. Follows MKS_MINI_12864 pinout. +// https://www.aliexpress.com/item/33018110072.html +// +//#define MKS_LCD12864 + // // FYSETC variant of the MINI12864 graphic controller with SD support // https://wiki.fysetc.com/Mini12864_Panel/ @@ -2114,10 +2128,25 @@ // //#define FSMC_GRAPHICAL_TFT +// +// TFT Little VGL UI +// +//#define TFT_LITTLE_VGL_UI + //============================================================================= //============================ Other Controllers ============================ //============================================================================= +// +// Robin nano v2.0 SPI touch screen +// +//#define SPI_GRAPHICAL_TFT + +// +// Ender-3 v2 OEM display. A DWIN display with Rotary Encoder. +// +//#define DWIN_CREALITY_LCD + // // ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8 // diff --git a/Marlin-bugfix-2.0.x/Marlin/Configuration_adv.h b/Marlin-bugfix-2.0.x/Marlin/Configuration_adv.h index 5d9bcc7..07736c9 100644 --- a/Marlin-bugfix-2.0.x/Marlin/Configuration_adv.h +++ b/Marlin-bugfix-2.0.x/Marlin/Configuration_adv.h @@ -767,6 +767,34 @@ #define HOME_AFTER_G34 #endif +// +// Add the G35 command to read bed corners to help adjust screws. +// +//#define ASSISTED_TRAMMING +#if ENABLED(ASSISTED_TRAMMING) + + // Define positions for probing points, use the hotend as reference not the sensor. + #define TRAMMING_POINT_XY { { 20, 20 }, { 200, 20 }, { 200, 200 }, { 20, 200 } } + + // Define positions names for probing points. + #define TRAMMING_POINT_NAME_1 "Front-Left" + #define TRAMMING_POINT_NAME_2 "Front-Right" + #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 + + /** + * Screw thread: + * M3: 30 = Clockwise, 31 = Counter-Clockwise + * M4: 40 = Clockwise, 41 = Counter-Clockwise + * M5: 50 = Clockwise, 51 = Counter-Clockwise + */ + #define TRAMMING_SCREW_THREAD 30 + +#endif + // @section motion #define AXIS_RELATIVE_MODES { false, false, false, false } @@ -1666,33 +1694,33 @@ // Probe temperature calibration generates a table of values starting at PTC_SAMPLE_START // (e.g. 30), in steps of PTC_SAMPLE_RES (e.g. 5) with PTC_SAMPLE_COUNT (e.g. 10) samples. - // #define PTC_SAMPLE_START 30.0f - // #define PTC_SAMPLE_RES 5.0f - // #define PTC_SAMPLE_COUNT 10U + //#define PTC_SAMPLE_START 30.0f + //#define PTC_SAMPLE_RES 5.0f + //#define PTC_SAMPLE_COUNT 10U // Bed temperature calibration builds a similar table. - // #define BTC_SAMPLE_START 60.0f - // #define BTC_SAMPLE_RES 5.0f - // #define BTC_SAMPLE_COUNT 10U + //#define BTC_SAMPLE_START 60.0f + //#define BTC_SAMPLE_RES 5.0f + //#define BTC_SAMPLE_COUNT 10U // The temperature the probe should be at while taking measurements during bed temperature // calibration. - // #define BTC_PROBE_TEMP 30.0f + //#define BTC_PROBE_TEMP 30.0f // Height above Z=0.0f to raise the nozzle. Lowering this can help the probe to heat faster. // Note: the Z=0.0f offset is determined by the probe offset which can be set using M851. - // #define PTC_PROBE_HEATING_OFFSET 0.5f + //#define PTC_PROBE_HEATING_OFFSET 0.5f // Height to raise the Z-probe between heating and taking the next measurement. Some probes // may fail to untrigger if they have been triggered for a long time, which can be solved by // increasing the height the probe is raised to. - // #define PTC_PROBE_RAISE 15U + //#define PTC_PROBE_RAISE 15U - // If the probe is outside of the defined range, use linear extrapolation using the closest + // If the probe is outside of the defined range, use linear extrapolation using the closest // point and the PTC_LINEAR_EXTRAPOLATION'th next point. E.g. if set to 4 it will use data[0] // and data[4] to perform linear extrapolation for values below PTC_SAMPLE_START. - // #define PTC_LINEAR_EXTRAPOLATION 4 + //#define PTC_LINEAR_EXTRAPOLATION 4 #endif #endif @@ -1873,6 +1901,9 @@ // This option inserts short delays between lines of serial output. #define SERIAL_OVERRUN_PROTECTION +// For serial echo, the number of digits after the decimal point +//#define SERIAL_FLOAT_PRECISION 4 + // @section extras /** @@ -2984,6 +3015,23 @@ //#define FILAMENT_LCD_DISPLAY #endif +/** + * Power Monitor + * Monitor voltage (V) and/or current (A), and -when possible- power (W) + * + * Read and configure with M430 + * + * The current sensor feeds DC voltage (relative to the measured current) to an analog pin + * The voltage sensor feeds DC voltage (relative to the measured voltage) to an analog pin + */ +//#define POWER_MONITOR_CURRENT // Monitor the system current +//#define POWER_MONITOR_VOLTAGE // Monitor the system voltage +#if EITHER(POWER_MONITOR_CURRENT, POWER_MONITOR_VOLTAGE) + #define POWER_MONITOR_VOLTS_PER_AMP 0.05000 // Input voltage to the MCU analog pin per amp - DO NOT apply more than ADC_VREF! + #define POWER_MONITOR_VOLTS_PER_VOLT 0.11786 // Input voltage to the MCU analog pin per volt - DO NOT apply more than ADC_VREF! + #define POWER_MONITOR_FIXED_VOLTAGE 13.6 // Voltage for a current sensor with no voltage sensor (for power display) +#endif + /** * CNC Coordinate Systems * diff --git a/Marlin-bugfix-2.0.x/Marlin/Marlin.ino b/Marlin-bugfix-2.0.x/Marlin/Marlin.ino index d1d58d4..213c18a 100644 --- a/Marlin-bugfix-2.0.x/Marlin/Marlin.ino +++ b/Marlin-bugfix-2.0.x/Marlin/Marlin.ino @@ -1,5 +1,4 @@ -/* -================================================================================ +/*============================================================================== Marlin Firmware @@ -12,8 +11,8 @@ Greetings! Thank you for choosing Marlin 2 as your 3D printer firmware. To configure Marlin you must edit Configuration.h and Configuration_adv.h -located in the root 'Marlin' folder. Check the config/examples folder to see if -there's a more suitable starting-point for your specific hardware. +located in the root 'Marlin' folder. Check our Configurations repository to +see if there's a more suitable starting-point for your specific hardware. Before diving in, we recommend the following essential links: @@ -25,6 +24,9 @@ Marlin Firmware Official Website Configuration + - https://github.com/MarlinFirmware/Configurations + Example configurations for several printer models. + - https://www.youtube.com/watch?v=3gwWVFtdg-4 A good 20-minute overview of Marlin configuration by Tom Sanladerer. (Applies to Marlin 1.0.x, so Jerk and Acceleration should be halved.) @@ -50,4 +52,6 @@ Contributing - https://marlinfw.org/docs/development/coding_standards.html Before submitting code get to know the Coding Standards. -*/ + + +------------------------------------------------------------------------------*/ diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/AVR/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/AVR/HAL.h index b7e05a9..63cb394 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/AVR/HAL.h @@ -162,6 +162,7 @@ inline void HAL_adc_init() { #define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch) #endif +#define HAL_ADC_VREF 5.0 #define HAL_ADC_RESOLUTION 10 #define HAL_READ_ADC() ADC #define HAL_ADC_READY() !TEST(ADCSRA, ADSC) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/AVR/inc/SanityCheck.h index ccdd391..575f1b6 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -41,6 +41,8 @@ #elif NUM_SERVOS > 0 && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5) #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system." #endif +#elif defined(SPINDLE_LASER_FREQUENCY) + #error "SPINDLE_LASER_FREQUENCY requires SPINDLE_LASER_PWM." #endif /** diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/DUE/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/DUE/HAL.h index 7410b2a..bc60b1d 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/DUE/HAL.h @@ -143,8 +143,9 @@ extern uint16_t HAL_adc_result; // result of last ADC conversion inline void HAL_adc_init() {}//todo -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) +#define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 +#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) #define HAL_READ_ADC() HAL_adc_result #define HAL_ADC_READY() true diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/ESP32/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/ESP32/HAL.h index 9eed6d9..3b75291 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/ESP32/HAL.h @@ -112,8 +112,9 @@ void analogWrite(pin_t pin, int value); void HAL_adc_init(); -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) +#define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 +#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_result #define HAL_ADC_READY() true diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/LINUX/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/LINUX/HAL.h index ba9a785..0573b33 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/LINUX/HAL.h @@ -86,9 +86,10 @@ int freeMemory(); #pragma GCC diagnostic pop // ADC +#define HAL_ADC_VREF 5.0 +#define HAL_ADC_RESOLUTION 10 #define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) #define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_ADC_RESOLUTION 10 #define HAL_READ_ADC() HAL_adc_get_result() #define HAL_ADC_READY() true diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/LPC1768/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/LPC1768/HAL.h index 66c55bb..0f9f227 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/LPC1768/HAL.h @@ -150,6 +150,8 @@ int freeMemory(); // K = 6, 565 samples, 500Hz sample rate, 1.13s convergence on full range step // Memory usage per ADC channel (bytes): 4 (32 Bytes for 8 channels) +#define HAL_ADC_VREF 3.3 // ADC voltage reference + #define HAL_ADC_RESOLUTION 12 // 15 bit maximum, raw temperature is stored as int16_t #define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/SAMD51/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/SAMD51/HAL.h index 0829a2c..e72b7a3 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/SAMD51/HAL.h @@ -122,6 +122,7 @@ extern uint16_t HAL_adc_result; // Most recent ADC conversion void HAL_adc_init(); //#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values. +#define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 // ... 12 #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_result diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32/HAL.h index 4046f67..2f37a5e 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32/HAL.h @@ -199,8 +199,9 @@ static inline int freeMemory() { inline void HAL_adc_init() {} -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) +#define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 +#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_result #define HAL_ADC_READY() true diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32/timers.cpp b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32/timers.cpp index 3796814..5383c82 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32/timers.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32/timers.cpp @@ -36,6 +36,15 @@ #define TEMP_TIMER_IRQ_PRIO 14 // 14 = after hardware ISRs #endif +// Ensure the default timer priority is somewhere between the STEP and TEMP priorities. +// The STM32 framework defaults to interrupt 14 for all timers. This should be increased so that +// timing-sensitive operations such as speaker output are note impacted by the long-running +// temperature ISR. This must be defined in the platformio.ini file or the board's variant.h, +// so that it will be consumed by framework code. +#if !(TIM_IRQ_PRIO > STEP_TIMER_IRQ_PRIO && TIM_IRQ_PRIO < TEMP_TIMER_IRQ_PRIO) + #error "Default timer interrupt priority is unspecified or set to a value which may degrade performance." +#endif + #if HAS_TMC_SW_SERIAL #include #ifndef SWSERIAL_TIMER_IRQ_PRIO @@ -44,23 +53,26 @@ #endif #ifdef STM32F0xx - #define HAL_TIMER_RATE (F_CPU) // Frequency of timer peripherals + #define MCU_TIMER_RATE (F_CPU) // Frequency of timer peripherals #define MCU_STEP_TIMER 16 #define MCU_TEMP_TIMER 17 #elif defined(STM32F1xx) - #define HAL_TIMER_RATE (F_CPU) + #define MCU_TIMER_RATE (F_CPU) #define MCU_STEP_TIMER 4 #define MCU_TEMP_TIMER 2 #elif defined(STM32F401xC) || defined(STM32F401xE) - #define HAL_TIMER_RATE (F_CPU / 2) + #define MCU_TIMER_RATE (F_CPU / 2) #define MCU_STEP_TIMER 9 #define MCU_TEMP_TIMER 10 #elif defined(STM32F4xx) || defined(STM32F7xx) - #define HAL_TIMER_RATE (F_CPU / 2) + #define MCU_TIMER_RATE (F_CPU / 2) #define MCU_STEP_TIMER 6 // STM32F401 has no TIM6, TIM7, or TIM8 #define MCU_TEMP_TIMER 14 // TIM7 is consumed by Software Serial if used. #endif +#ifndef HAL_TIMER_RATE + #define HAL_TIMER_RATE MCU_TIMER_RATE +#endif #ifndef STEP_TIMER #define STEP_TIMER MCU_STEP_TIMER #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/HAL.cpp index 01fd2c8..6588829 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/HAL.cpp @@ -139,9 +139,15 @@ const uint8_t adc_pins[] = { #if HAS_JOY_ADC_Z JOY_Z_PIN, #endif + #if ENABLED(POWER_MONITOR_CURRENT) + POWER_MONITOR_CURRENT_PIN, + #endif + #if ENABLED(POWER_MONITOR_VOLTAGE) + POWER_MONITOR_VOLTAGE_PIN, + #endif }; -enum TEMP_PINS : char { +enum TempPinIndex : char { #if HAS_TEMP_ADC_0 TEMP_0, #endif @@ -187,6 +193,12 @@ enum TEMP_PINS : char { #if HAS_JOY_ADC_Z JOY_Z, #endif + #if ENABLED(POWER_MONITOR_CURRENT) + POWERMON_CURRENT, + #endif + #if ENABLED(POWER_MONITOR_VOLTAGE) + POWERMON_VOLTS, + #endif ADC_PIN_COUNT }; @@ -323,7 +335,8 @@ void HAL_adc_init() { } void HAL_adc_start_conversion(const uint8_t adc_pin) { - TEMP_PINS pin_index; + //TEMP_PINS pin_index; + TempPinIndex pin_index; switch (adc_pin) { default: return; #if HAS_TEMP_ADC_0 @@ -371,6 +384,12 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { #if ENABLED(ADC_KEYPAD) case ADC_KEYPAD_PIN: pin_index = ADC_KEY; break; #endif + #if ENABLED(POWER_MONITOR_CURRENT) + case POWER_MONITOR_CURRENT_PIN: pin_index = POWERMON_CURRENT; break; + #endif + #if ENABLED(POWER_MONITOR_VOLTAGE) + case POWER_MONITOR_VOLTAGE_PIN: pin_index = POWERMON_VOLTS; break; + #endif } HAL_adc_result = (HAL_adc_results[(int)pin_index] >> 2) & 0x3FF; // shift to get 10 bits only. } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/HAL.h index 49769a5..6550fbe 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/HAL.h @@ -255,8 +255,9 @@ static int freeMemory() { void HAL_adc_init(); -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) +#define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 +#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_result #define HAL_ADC_READY() true diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/sdio.cpp b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/sdio.cpp index 7184608..3aec7cf 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/sdio.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/sdio.cpp @@ -102,7 +102,7 @@ bool SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) { } while (!SDIO_GET_FLAG(SDIO_STA_DATAEND | SDIO_STA_TRX_ERROR_FLAGS)) { /* wait */ } - + //If there were SDIO errors, do not wait DMA. if (SDIO->STA & SDIO_STA_TRX_ERROR_FLAGS) { SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS); @@ -118,7 +118,7 @@ bool SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) { SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS); return false; } - + dma_disable(SDIO_DMA_DEV, SDIO_DMA_CHANNEL); if (SDIO->STA & SDIO_STA_RXDAVL) { diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/timers.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/timers.h index 442b2ea..57fd0e3 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/timers.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32F1/timers.h @@ -44,8 +44,12 @@ typedef uint16_t hal_timer_t; #define HAL_TIMER_RATE uint32_t(F_CPU) // frequency of timers peripherals -#define STEP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts -#define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts +#ifndef STEP_TIMER_CHAN + #define STEP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts +#endif +#ifndef TEMP_TIMER_CHAN + #define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts +#endif /** * Note: Timers may be used by platforms and libraries diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32_F4_F7/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32_F4_F7/HAL.h index aa8575e..07e56b2 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32_F4_F7/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/STM32_F4_F7/HAL.h @@ -219,8 +219,9 @@ static inline int freeMemory() { inline void HAL_adc_init() {} -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) +#define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 +#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_result #define HAL_ADC_READY() true diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/TEENSY31_32/HAL.h index 23e4c18..3356ec2 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -107,8 +107,9 @@ extern "C" { void HAL_adc_init(); -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) +#define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 +#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_get_result() #define HAL_ADC_READY() true diff --git a/Marlin-bugfix-2.0.x/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin-bugfix-2.0.x/Marlin/src/HAL/TEENSY35_36/HAL.h index 7aa10ab..1d912e3 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -112,8 +112,9 @@ extern "C" { void HAL_adc_init(); -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) +#define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 +#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_get_result() #define HAL_ADC_READY() true diff --git a/Marlin-bugfix-2.0.x/Marlin/src/MarlinCore.cpp b/Marlin-bugfix-2.0.x/Marlin/src/MarlinCore.cpp index 3b0ba07..744e637 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/MarlinCore.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/MarlinCore.cpp @@ -59,6 +59,22 @@ #include "gcode/parser.h" #include "gcode/queue.h" +#if ENABLED(TFT_LITTLE_VGL_UI) + #include "lvgl.h" + #include "lcd/extui/lib/mks_ui/inc/tft_lvgl_configuration.h" + #include "lcd/extui/lib/mks_ui/inc/draw_ui.h" +#endif + +#if ENABLED(DWIN_CREALITY_LCD) + #include "lcd/dwin/dwin.h" + #include "lcd/dwin/dwin_lcd.h" + #include "lcd/dwin/rotary_encoder.h" +#endif + +#if ENABLED(IIC_BL24CXX_EEPROM) + #include "lcd/dwin/eeprom_BL24CXX.h" +#endif + #if ENABLED(DIRECT_STEPPING) #include "feature/direct_stepping.h" #endif @@ -695,8 +711,8 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { // Update the Beeper queue TERN_(USE_BEEPER, buzzer.tick()); - // Read Buttons and Update the LCD - ui.update(); + // Handle UI input / draw events + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); // Run i2c Position Encoders #if ENABLED(I2C_POSITION_ENCODERS) @@ -726,6 +742,10 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { // Direct Stepping TERN_(DIRECT_STEPPING, page_manager.write_responses()); + + #if ENABLED(TFT_LITTLE_VGL_UI) + LV_TASK_HANDLER(); + #endif } /** @@ -837,7 +857,7 @@ void setup() { #if ENABLED(MARLIN_DEV_MODE) auto log_current_ms = [&](PGM_P const msg) { SERIAL_ECHO_START(); - SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHO("] "); + SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHOPGM("] "); serialprintPGM(msg); SERIAL_EOL(); }; @@ -952,11 +972,18 @@ void setup() { // UI must be initialized before EEPROM // (because EEPROM code calls the UI). - SETUP_RUN(ui.init()); - SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.) - - #if BOTH(HAS_SPI_LCD, SHOW_BOOTSCREEN) - SETUP_RUN(ui.show_bootscreen()); + #if ENABLED(DWIN_CREALITY_LCD) + delay(800); // Required delay (since boot?) + SERIAL_ECHOPGM("\nDWIN handshake "); + if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error."); + DWIN_Frame_SetDir(1); // Orientation 90° + DWIN_UpdateLCD(); // Show bootscreen (first image) + #else + SETUP_RUN(ui.init()); + #if HAS_SPI_LCD && ENABLED(SHOW_BOOTSCREEN) + SETUP_RUN(ui.show_bootscreen()); + #endif + SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.) #endif #if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION) @@ -966,10 +993,6 @@ void setup() { SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults) // This also updates variables in the planner, elsewhere - #if HAS_SERVICE_INTERVALS - SETUP_RUN(ui.reset_status(true)); // Show service messages or keep current status - #endif - #if ENABLED(TOUCH_BUTTONS) SETUP_RUN(touch.init()); #endif @@ -1133,6 +1156,22 @@ void setup() { SETUP_RUN(mmu2.init()); #endif + #if ENABLED(IIC_BL24CXX_EEPROM) + BL24CXX::init(); + const uint8_t err = BL24CXX::check(); + SERIAL_ECHO_TERNARY(err, "I2C_EEPROM Check ", "failed", "succeeded", "!\n"); + #endif + + #if ENABLED(DWIN_CREALITY_LCD) + Encoder_Configuration(); + HMI_Init(); + HMI_StartFrame(true); + #endif + + #if HAS_SERVICE_INTERVALS && DISABLED(DWIN_CREALITY_LCD) + ui.reset_status(true); // Show service messages or keep current status + #endif + #if ENABLED(MAX7219_DEBUG) SETUP_RUN(max7219.init()); #endif @@ -1141,6 +1180,10 @@ void setup() { SETUP_RUN(page_manager.init()); #endif + #if ENABLED(TFT_LITTLE_VGL_UI) + SETUP_RUN(tft_lvgl_init()); + #endif + marlin_state = MF_RUNNING; SETUP_LOG("setup() completed."); @@ -1173,5 +1216,7 @@ void loop() { endstops.event_handler(); + TERN_(TFT_LITTLE_VGL_UI, printer_state_polling()); + } while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/core/boards.h b/Marlin-bugfix-2.0.x/Marlin/src/core/boards.h index adbd12e..b3d5f91 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/core/boards.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/core/boards.h @@ -310,6 +310,7 @@ #define BOARD_CCROBOT_MEEB_3DP 4029 // ccrobot-online.com MEEB_3DP (STM32F103RC) #define BOARD_CHITU3D_V5 4030 // Chitu3D TronXY X5SA V5 Board #define BOARD_CHITU3D_V6 4031 // Chitu3D TronXY X5SA V5 Board +#define BOARD_CREALITY_V4 4032 // Creality v4.x (STM32F103RE) // // ARM Cortex-M4F @@ -332,14 +333,15 @@ #define BOARD_BLACK_STM32F407ZE 4207 // BLACK_STM32F407ZE #define BOARD_STEVAL_3DP001V1 4208 // STEVAL-3DP001V1 3D PRINTER BOARD #define BOARD_BTT_SKR_PRO_V1_1 4209 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) -#define BOARD_BTT_BTT002_V1_0 4210 // BigTreeTech BTT002 v1.0 (STM32F407VG) -#define BOARD_BTT_GTR_V1_0 4211 // BigTreeTech GTR v1.0 (STM32F407IGT) -#define BOARD_LERDGE_K 4212 // Lerdge K (STM32F407ZG) -#define BOARD_LERDGE_X 4213 // Lerdge X (STM32F407VE) -#define BOARD_VAKE403D 4214 // VAkE 403D (STM32F446VET6) -#define BOARD_FYSETC_S6 4215 // FYSETC S6 board -#define BOARD_FLYF407ZG 4216 // FLYF407ZG board (STM32F407ZG) -#define BOARD_MKS_ROBIN2 4217 // MKS_ROBIN2 (STM32F407ZE) +#define BOARD_BTT_SKR_PRO_V1_2 4210 // BigTreeTech SKR Pro v1.2 (STM32F407ZG) +#define BOARD_BTT_BTT002_V1_0 4211 // BigTreeTech BTT002 v1.0 (STM32F407VG) +#define BOARD_BTT_GTR_V1_0 4212 // BigTreeTech GTR v1.0 (STM32F407IGT) +#define BOARD_LERDGE_K 4213 // Lerdge K (STM32F407ZG) +#define BOARD_LERDGE_X 4214 // Lerdge X (STM32F407VE) +#define BOARD_VAKE403D 4215 // VAkE 403D (STM32F446VET6) +#define BOARD_FYSETC_S6 4216 // FYSETC S6 board +#define BOARD_FLYF407ZG 4217 // FLYF407ZG board (STM32F407ZG) +#define BOARD_MKS_ROBIN2 4218 // MKS_ROBIN2 (STM32F407ZE) // // ARM Cortex M7 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/core/debug_out.h b/Marlin-bugfix-2.0.x/Marlin/src/core/debug_out.h index b7506a8..8be6523 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/core/debug_out.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/core/debug_out.h @@ -31,6 +31,7 @@ #undef DEBUG_ERROR_START #undef DEBUG_CHAR #undef DEBUG_ECHO +#undef DEBUG_DECIMAL #undef DEBUG_ECHO_F #undef DEBUG_ECHOLN #undef DEBUG_ECHOPGM @@ -57,6 +58,7 @@ #define DEBUG_ERROR_START SERIAL_ERROR_START #define DEBUG_CHAR SERIAL_CHAR #define DEBUG_ECHO SERIAL_ECHO + #define DEBUG_DECIMAL SERIAL_DECIMAL #define DEBUG_ECHO_F SERIAL_ECHO_F #define DEBUG_ECHOLN SERIAL_ECHOLN #define DEBUG_ECHOPGM SERIAL_ECHOPGM @@ -82,6 +84,7 @@ #define DEBUG_ERROR_START() NOOP #define DEBUG_CHAR(...) NOOP #define DEBUG_ECHO(...) NOOP + #define DEBUG_DECIMAL(...) NOOP #define DEBUG_ECHO_F(...) NOOP #define DEBUG_ECHOLN(...) NOOP #define DEBUG_ECHOPGM(...) NOOP diff --git a/Marlin-bugfix-2.0.x/Marlin/src/core/macros.h b/Marlin-bugfix-2.0.x/Marlin/src/core/macros.h index ebcb9eb..2f9273e 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/core/macros.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/core/macros.h @@ -97,10 +97,13 @@ #define CBI(A,B) (A &= ~(1 << (B))) #endif +#define TBI(N,B) (N ^= _BV(B)) + #define _BV32(b) (1UL << (b)) #define TEST32(n,b) !!((n)&_BV32(b)) #define SBI32(n,b) (n |= _BV32(b)) #define CBI32(n,b) (n &= ~_BV32(b)) +#define TBI32(N,B) (N ^= _BV32(B)) #define cu(x) ({__typeof__(x) _x = (x); (_x)*(_x)*(_x);}) #define RADIANS(d) ((d)*float(M_PI)/180.0f) @@ -267,7 +270,7 @@ #define NEAR(x,y) NEAR_ZERO((x)-(y)) #define RECIPROCAL(x) (NEAR_ZERO(x) ? 0 : (1 / float(x))) -#define FIXFLOAT(f) ({__typeof__(f) _f = (f); _f + (_f < 0 ? -0.00005f : 0.00005f);}) +#define FIXFLOAT(f) ({__typeof__(f) _f = (f); _f + (_f < 0 ? -0.0000005f : 0.0000005f);}) // // Maths macros that can be overridden by HAL diff --git a/Marlin-bugfix-2.0.x/Marlin/src/core/serial.cpp b/Marlin-bugfix-2.0.x/Marlin/src/core/serial.cpp index 313d6ce..dee452d 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/core/serial.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/core/serial.cpp @@ -42,8 +42,8 @@ void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P) void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); } void serial_echopair_PGM(PGM_P const s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } +void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } void serial_echopair_PGM(PGM_P const s_P, unsigned int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/core/serial.h b/Marlin-bugfix-2.0.x/Marlin/src/core/serial.h index 1a319e6..8b72e46 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/core/serial.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/core/serial.h @@ -51,10 +51,16 @@ extern uint8_t marlin_debug_flags; extern int8_t serial_port_index; #define _PORT_REDIRECT(n,p) REMEMBER(n,serial_port_index,p) #define _PORT_RESTORE(n) RESTORE(n) - #define SERIAL_OUT(WHAT, V...) do{ \ - if (!serial_port_index || serial_port_index == SERIAL_BOTH) (void)MYSERIAL0.WHAT(V); \ - if ( serial_port_index) (void)MYSERIAL1.WHAT(V); \ - }while(0) + + #ifdef SERIAL_CATCHALL + #define SERIAL_OUT(WHAT, V...) (void)CAT(MYSERIAL,SERIAL_CATCHALL).WHAT(V) + #else + #define SERIAL_OUT(WHAT, V...) do{ \ + if (!serial_port_index || serial_port_index == SERIAL_BOTH) (void)MYSERIAL0.WHAT(V); \ + if ( serial_port_index) (void)MYSERIAL1.WHAT(V); \ + }while(0) + #endif + #define SERIAL_ASSERT(P) if(serial_port_index!=(P)){ debugger(); } #else #define _PORT_REDIRECT(n,p) NOOP @@ -280,6 +286,12 @@ extern uint8_t marlin_debug_flags; #define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, PSTR(PRE), PSTR(ON), PSTR(OFF), PSTR(POST)) +#if SERIAL_FLOAT_PRECISION + #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION) +#else + #define SERIAL_DECIMAL(V) SERIAL_ECHO(V) +#endif + // // Functions for serial printing from PROGMEM. (Saves loads of SRAM.) // diff --git a/Marlin-bugfix-2.0.x/Marlin/src/core/utility.cpp b/Marlin-bugfix-2.0.x/Marlin/src/core/utility.cpp index 62e79e4..e64d6fb 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/core/utility.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/core/utility.cpp @@ -123,10 +123,10 @@ void safe_delay(millis_t ms) { #if ABL_PLANAR SERIAL_ECHOPGM("ABL Adjustment X"); LOOP_XYZ(a) { - float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]; + const float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]; SERIAL_CHAR(' ', XYZ_CHAR(a)); if (v > 0) SERIAL_CHAR('+'); - SERIAL_ECHO(v); + SERIAL_DECIMAL(v); } #else #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/babystep.cpp b/Marlin-bugfix-2.0.x/Marlin/src/feature/babystep.cpp index 9c5bba9..7e621a4 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/babystep.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/babystep.cpp @@ -54,60 +54,12 @@ void Babystep::add_mm(const AxisEnum axis, const float &mm) { } void Babystep::add_steps(const AxisEnum axis, const int16_t distance) { - if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return; accum += distance; // Count up babysteps for the UI + steps[BS_AXIS_IND(axis)] += distance; TERN_(BABYSTEP_DISPLAY_TOTAL, axis_total[BS_TOTAL_IND(axis)] += distance); - - #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE) - #define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: ENABLE_AXIS_X(); break; case Y_AXIS: ENABLE_AXIS_Y(); break; case Z_AXIS: ENABLE_AXIS_Z(); break; default: break; } }while(0) - #else - #define BSA_ENABLE(AXIS) NOOP - #endif - - #if IS_CORE - #if ENABLED(BABYSTEP_XY) - switch (axis) { - case CORE_AXIS_1: // X on CoreXY and CoreXZ, Y on CoreYZ - BSA_ENABLE(CORE_AXIS_1); - BSA_ENABLE(CORE_AXIS_2); - steps[CORE_AXIS_1] += distance * 2; - steps[CORE_AXIS_2] += distance * 2; - break; - case CORE_AXIS_2: // Y on CoreXY, Z on CoreXZ and CoreYZ - BSA_ENABLE(CORE_AXIS_1); - BSA_ENABLE(CORE_AXIS_2); - steps[CORE_AXIS_1] += CORESIGN(distance * 2); - steps[CORE_AXIS_2] -= CORESIGN(distance * 2); - break; - case NORMAL_AXIS: // Z on CoreXY, Y on CoreXZ, X on CoreYZ - default: - BSA_ENABLE(NORMAL_AXIS); - steps[NORMAL_AXIS] += distance; - break; - } - #elif CORE_IS_XZ || CORE_IS_YZ - // Only Z stepping needs to be handled here - BSA_ENABLE(CORE_AXIS_1); - BSA_ENABLE(CORE_AXIS_2); - steps[CORE_AXIS_1] += CORESIGN(distance * 2); - steps[CORE_AXIS_2] -= CORESIGN(distance * 2); - #else - BSA_ENABLE(Z_AXIS); - steps[Z_AXIS] += distance; - #endif - #else - #if ENABLED(BABYSTEP_XY) - BSA_ENABLE(axis); - #else - BSA_ENABLE(Z_AXIS); - #endif - steps[BS_AXIS_IND(axis)] += distance; - #endif - TERN_(BABYSTEP_ALWAYS_AVAILABLE, gcode.reset_stepper_timeout()); - TERN_(INTEGRATED_BABYSTEPPING, if (has_steps()) stepper.initiateBabystepping()); } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin-bugfix-2.0.x/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 8385c4b..3c60416 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -393,17 +393,12 @@ #if HAS_BED_PROBE if (parser.seen('J')) { - if (g29_grid_size) { // if not 0 it is a normal n x n grid being probed - save_ubl_active_state_and_disable(); - tilt_mesh_based_on_probed_grid(false /* false says to do normal grid probing */ ); - restore_ubl_active_state_and_leave(); - } - else { // grid_size == 0 : A 3-Point leveling has been requested - save_ubl_active_state_and_disable(); - tilt_mesh_based_on_probed_grid(true /* true says to do 3-Point leveling */ ); - restore_ubl_active_state_and_leave(); - } - do_blocking_move_to_xy(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y))); + save_ubl_active_state_and_disable(); + tilt_mesh_based_on_probed_grid(g29_grid_size == 0); // Zero size does 3-Point + restore_ubl_active_state_and_leave(); + #if ENABLED(UBL_G29_J_RECENTER) + do_blocking_move_to_xy(0.5f * ((MESH_MIN_X) + (MESH_MAX_X)), 0.5f * ((MESH_MIN_Y) + (MESH_MAX_Y))); + #endif report_current_position(); probe_deployed = true; } @@ -438,7 +433,7 @@ if (g29_verbose_level > 1) { SERIAL_ECHOPAIR("Probing around (", g29_pos.x); SERIAL_CHAR(','); - SERIAL_ECHO(g29_pos.y); + SERIAL_DECIMAL(g29_pos.y); SERIAL_ECHOLNPGM(").\n"); } const xy_pos_t near_probe_xy = g29_pos + probe.offset_xy; @@ -478,7 +473,7 @@ } if (parser.seen('B')) { - g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness((float) Z_CLEARANCE_BETWEEN_PROBES); + g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness(float(Z_CLEARANCE_BETWEEN_PROBES)); if (ABS(g29_card_thickness) > 1.5f) { SERIAL_ECHOLNPGM("?Error in Business Card measurement."); return; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/bltouch.h b/Marlin-bugfix-2.0.x/Marlin/src/feature/bltouch.h index af75fb8..797cc7d 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/bltouch.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/bltouch.h @@ -26,9 +26,17 @@ // BLTouch commands are sent as servo angles typedef unsigned char BLTCommand; -#define BLTOUCH_DEPLOY 10 +#if ENABLED(CREALITY_TOUCH) + #define STOW_ALARM false + #define BLTOUCH_DEPLOY 170 + #define BLTOUCH_STOW 20 +#else + #define STOW_ALARM true + #define BLTOUCH_DEPLOY 10 + #define BLTOUCH_STOW 90 +#endif + #define BLTOUCH_SW_MODE 60 -#define BLTOUCH_STOW 90 #define BLTOUCH_SELFTEST 120 #define BLTOUCH_MODE_STORE 130 #define BLTOUCH_5V_MODE 140 @@ -95,7 +103,7 @@ public: private: FORCE_INLINE static bool _deploy_query_alarm() { return command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); } - FORCE_INLINE static bool _stow_query_alarm() { return command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY); } + FORCE_INLINE static bool _stow_query_alarm() { return command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY) == STOW_ALARM; } static void clear(); static bool command(const BLTCommand cmd, const millis_t &ms); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/encoder_i2c.cpp b/Marlin-bugfix-2.0.x/Marlin/src/feature/encoder_i2c.cpp index cfac36a..d5a8f16 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/encoder_i2c.cpp @@ -107,7 +107,7 @@ void I2CPositionEncoder::update() { SERIAL_ECHOLNPAIR("New zero-offset of ", zeroOffset); SERIAL_ECHOPAIR("New position reads as ", get_position()); SERIAL_CHAR('('); - SERIAL_ECHO(mm_from_count(get_position())); + SERIAL_DECIMAL(mm_from_count(get_position())); SERIAL_ECHOLNPGM(")"); #endif } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/encoder_i2c.h b/Marlin-bugfix-2.0.x/Marlin/src/feature/encoder_i2c.h index 0665ee8..f404954 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/encoder_i2c.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/encoder_i2c.h @@ -280,13 +280,13 @@ class I2CPositionEncodersMgr { static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) { CHECK_IDX(); encoders[idx].set_ec_threshold(newThreshold); - SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis set to ", FIXFLOAT(newThreshold), "mm."); + SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis set to ", newThreshold, "mm."); } static void get_ec_threshold(const int8_t idx, const AxisEnum axis) { CHECK_IDX(); const float threshold = encoders[idx].get_ec_threshold(); - SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis is ", FIXFLOAT(threshold), "mm."); + SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis is ", threshold, "mm."); } static int8_t idx_from_axis(const AxisEnum axis) { diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/leds/neopixel.cpp b/Marlin-bugfix-2.0.x/Marlin/src/feature/leds/neopixel.cpp index 892ebe1..3c2c0b4 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/leds/neopixel.cpp @@ -71,13 +71,11 @@ void Marlin_NeoPixel::set_color_startup(const uint32_t color) { } void Marlin_NeoPixel::init() { - SET_OUTPUT(NEOPIXEL_PIN); set_brightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range begin(); show(); // initialize to all off #if ENABLED(NEOPIXEL_STARTUP_TEST) - safe_delay(1000); set_color_startup(adaneo1.Color(255, 0, 0, 0)); // red safe_delay(1000); set_color_startup(adaneo1.Color(0, 255, 0, 0)); // green diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/power_monitor.cpp b/Marlin-bugfix-2.0.x/Marlin/src/feature/power_monitor.cpp new file mode 100644 index 0000000..30b19a9 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/power_monitor.cpp @@ -0,0 +1,74 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../inc/MarlinConfigPre.h" + +#if HAS_POWER_MONITOR + +#include "power_monitor.h" + +#include "../lcd/ultralcd.h" +#include "../lcd/lcdprint.h" + +uint8_t PowerMonitor::flags; // = 0 + +#if ENABLED(POWER_MONITOR_CURRENT) + pm_lpf_t PowerMonitor::amps; +#endif +#if ENABLED(POWER_MONITOR_VOLTAGE) + pm_lpf_t PowerMonitor::volts; +#endif + +millis_t PowerMonitor::display_item_ms; +uint8_t PowerMonitor::display_item; + +PowerMonitor power_monitor; // Single instance - this calls the constructor + +#if HAS_GRAPHICAL_LCD + + #if ENABLED(POWER_MONITOR_CURRENT) + void PowerMonitor::draw_current() { + const float amps = getAmps(); + lcd_put_u8str(amps < 100 ? ftostr21ns(amps) : ui16tostr4((uint16_t)amps)); + lcd_put_wchar('A'); + } + #endif + + #if HAS_POWER_MONITOR_VREF + void PowerMonitor::draw_voltage() { + const float volts = getVolts(); + lcd_put_u8str(volts < 100 ? ftostr21ns(volts) : ui16tostr4((uint16_t)volts)); + lcd_put_wchar('V'); + } + #endif + + #if HAS_POWER_MONITOR_WATTS + void PowerMonitor::draw_power() { + const float power = getPower(); + lcd_put_u8str(power < 100 ? ftostr21ns(power) : ui16tostr4((uint16_t)power)); + lcd_put_wchar('W'); + } + #endif + +#endif // HAS_GRAPHICAL_LCD + +#endif // HAS_POWER_MONITOR diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/power_monitor.h b/Marlin-bugfix-2.0.x/Marlin/src/feature/power_monitor.h new file mode 100644 index 0000000..fc7a23b --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/power_monitor.h @@ -0,0 +1,140 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "../inc/MarlinConfig.h" + +#define PM_SAMPLE_RANGE 1024 +#define PM_K_VALUE 6 +#define PM_K_SCALE 6 + +template +struct pm_lpf_t { + uint32_t filter_buf; + float value; + void add_sample(const uint16_t sample) { + filter_buf = filter_buf - (filter_buf >> K_VALUE) + (uint32_t(sample) << K_SCALE); + } + void capture() { + value = filter_buf * (SCALE * (1.0f / (1UL << (PM_K_VALUE + PM_K_SCALE)))); + } + void reset(uint16_t reset_value = 0) { + filter_buf = uint32_t(reset_value) << (K_VALUE + K_SCALE); + capture(); + } +}; + +class PowerMonitor { +private: + #if ENABLED(POWER_MONITOR_CURRENT) + static constexpr float amps_adc_scale = float(ADC_VREF) / (POWER_MONITOR_VOLTS_PER_AMP * PM_SAMPLE_RANGE); + static pm_lpf_t amps; + #endif + #if ENABLED(POWER_MONITOR_VOLTAGE) + static constexpr float volts_adc_scale = float(ADC_VREF) / (POWER_MONITOR_VOLTS_PER_VOLT * PM_SAMPLE_RANGE); + static pm_lpf_t volts; + #endif + +public: + static uint8_t flags; // M430 flags to display current + + static millis_t display_item_ms; + static uint8_t display_item; + + PowerMonitor() { reset(); } + + enum PM_Display_Bit : uint8_t { + PM_DISP_BIT_I, // Current display enable bit + PM_DISP_BIT_V, // Voltage display enable bit + PM_DISP_BIT_P // Power display enable bit + }; + + #if ENABLED(POWER_MONITOR_CURRENT) + FORCE_INLINE static float getAmps() { return amps.value; } + void add_current_sample(const uint16_t value) { amps.add_sample(value); } + #endif + + #if HAS_POWER_MONITOR_VREF + #if ENABLED(POWER_MONITOR_VOLTAGE) + FORCE_INLINE static float getVolts() { return volts.value; } + #else + FORCE_INLINE static float getVolts() { return POWER_MONITOR_FIXED_VOLTAGE; } // using a specified fixed valtage as the voltage measurement + #endif + #if ENABLED(POWER_MONITOR_VOLTAGE) + void add_voltage_sample(const uint16_t value) { volts.add_sample(value); } + #endif + #endif + + #if HAS_POWER_MONITOR_WATTS + FORCE_INLINE static float getPower() { return getAmps() * getVolts(); } + #endif + + #if HAS_SPI_LCD + FORCE_INLINE static bool display_enabled() { return flags != 0x00; } + #if ENABLED(POWER_MONITOR_CURRENT) + static void draw_current(); + FORCE_INLINE static bool current_display_enabled() { return TEST(flags, PM_DISP_BIT_I); } + FORCE_INLINE static void set_current_display(const bool b) { SET_BIT_TO(flags, PM_DISP_BIT_I, b); } + FORCE_INLINE static void toggle_current_display() { TBI(flags, PM_DISP_BIT_I); } + #endif + #if HAS_POWER_MONITOR_VREF + static void draw_voltage(); + FORCE_INLINE static bool voltage_display_enabled() { return TEST(flags, PM_DISP_BIT_V); } + FORCE_INLINE static void set_voltage_display(const bool b) { SET_BIT_TO(flags, PM_DISP_BIT_V, b); } + FORCE_INLINE static void toggle_voltage_display() { TBI(flags, PM_DISP_BIT_I); } + #endif + #if HAS_POWER_MONITOR_WATTS + static void draw_power(); + FORCE_INLINE static bool power_display_enabled() { return TEST(flags, PM_DISP_BIT_P); } + FORCE_INLINE static void set_power_display(const bool b) { SET_BIT_TO(flags, PM_DISP_BIT_P, b); } + FORCE_INLINE static void toggle_power_display() { TBI(flags, PM_DISP_BIT_I); } + #endif + #endif + + static void reset() { + flags = 0x00; + + #if ENABLED(POWER_MONITOR_CURRENT) + amps.reset(); + #endif + + #if ENABLED(POWER_MONITOR_VOLTAGE) + volts.reset(); + #endif + + #if ENABLED(SDSUPPORT) + display_item_ms = 0; + display_item = 0; + #endif + } + + static void capture_values() { + #if ENABLED(POWER_MONITOR_CURRENT) + amps.capture(); + #endif + #if ENABLED(POWER_MONITOR_VOLTAGE) + volts.capture(); + #endif + } +}; + +extern PowerMonitor power_monitor; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/powerloss.cpp b/Marlin-bugfix-2.0.x/Marlin/src/feature/powerloss.cpp index 0ba8737..0ae1280 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/powerloss.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/powerloss.cpp @@ -40,6 +40,10 @@ uint8_t PrintJobRecovery::queue_index_r; uint32_t PrintJobRecovery::cmd_sdpos, // = 0 PrintJobRecovery::sdpos[BUFSIZE]; +#if ENABLED(DWIN_CREALITY_LCD) + bool PrintJobRecovery::dwin_flag; // = false +#endif + #include "../sd/cardreader.h" #include "../lcd/ultralcd.h" #include "../gcode/queue.h" @@ -105,6 +109,7 @@ void PrintJobRecovery::check() { load(); if (!valid()) return cancel(); queue.inject_P(PSTR("M1000 S")); + TERN_(DWIN_CREALITY_LCD, dwin_flag = true); } } @@ -467,7 +472,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOPGM("current_position: "); LOOP_XYZE(i) { if (i) DEBUG_CHAR(','); - DEBUG_ECHO(info.current_position[i]); + DEBUG_DECIMAL(info.current_position[i]); } DEBUG_EOL(); @@ -475,7 +480,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOPGM("home_offset: "); LOOP_XYZ(i) { if (i) DEBUG_CHAR(','); - DEBUG_ECHO(info.home_offset[i]); + DEBUG_DECIMAL(info.home_offset[i]); } DEBUG_EOL(); #endif @@ -484,7 +489,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOPGM("position_shift: "); LOOP_XYZ(i) { if (i) DEBUG_CHAR(','); - DEBUG_ECHO(info.position_shift[i]); + DEBUG_DECIMAL(info.position_shift[i]); } DEBUG_EOL(); #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/powerloss.h b/Marlin-bugfix-2.0.x/Marlin/src/feature/powerloss.h index affa2ca..3645f57 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/powerloss.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/powerloss.h @@ -121,6 +121,10 @@ class PrintJobRecovery { static uint32_t cmd_sdpos, //!< SD position of the next command sdpos[BUFSIZE]; //!< SD positions of queued commands + #if ENABLED(DWIN_CREALITY_LCD) + static bool dwin_flag; + #endif + static void init(); static void prepare(); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/spindle_laser.h b/Marlin-bugfix-2.0.x/Marlin/src/feature/spindle_laser.h index 4abed6c..71937a8 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/spindle_laser.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/spindle_laser.h @@ -109,8 +109,6 @@ public: FORCE_INLINE static void refresh() { apply_power(power); } FORCE_INLINE static void set_power(const uint8_t upwr) { power = upwr; refresh(); } - static inline void set_enabled(const bool enable) { set_power(enable ? (power ?: (unitPower ? upower_to_ocr(cpwr_to_upwr(SPEED_POWER_STARTUP)) : 0)) : 0); } - #if ENABLED(SPINDLE_LASER_PWM) static void set_ocr(const uint8_t ocr); @@ -148,21 +146,21 @@ public: cutter_power_t upwr; switch (pwrUnit) { case 0: // PWM - upwr = ( + upwr = cutter_power_t( (pwr < pct_to_ocr(min_pct)) ? pct_to_ocr(min_pct) // Use minimum if set below : (pwr > pct_to_ocr(max_pct)) ? pct_to_ocr(max_pct) // Use maximum if set above : pwr ); break; case 1: // PERCENT - upwr = ( + upwr = cutter_power_t( (pwr < min_pct) ? min_pct // Use minimum if set below : (pwr > max_pct) ? max_pct // Use maximum if set above : pwr // PCT ); break; case 2: // RPM - upwr = ( + upwr = cutter_power_t( (pwr < SPEED_POWER_MIN) ? SPEED_POWER_MIN // Use minimum if set below : (pwr > SPEED_POWER_MAX) ? SPEED_POWER_MAX // Use maximum if set above : pwr // Calculate OCR value @@ -175,6 +173,10 @@ public: #endif // SPINDLE_LASER_PWM + static inline void set_enabled(const bool enable) { + set_power(enable ? TERN(SPINDLE_LASER_PWM, (power ?: (unitPower ? upower_to_ocr(cpwr_to_upwr(SPEED_POWER_STARTUP)) : 0)), 255) : 0); + } + // Wait for spindle to spin up or spin down static inline void power_delay(const bool on) { #if DISABLED(LASER_POWER_INLINE) @@ -194,7 +196,7 @@ public: static inline void enable_with_dir(const bool reverse) { isReady = true; - const uint8_t ocr = upower_to_ocr(menuPower); + const uint8_t ocr = TERN(SPINDLE_LASER_PWM, upower_to_ocr(menuPower), 255); if (menuPower) power = ocr; else @@ -233,7 +235,7 @@ public: // Inline modes of all other functions; all enable planner inline power control static inline void set_inline_enabled(const bool enable) { if (enable) - inline_power(cpwr_to_upwr(SPEED_POWER_STARTUP)); + inline_power(cpwr_to_upwr(SPEED_POWER_STARTUP)); else { isReady = false; unitPower = menuPower = 0; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/tmc_util.h b/Marlin-bugfix-2.0.x/Marlin/src/feature/tmc_util.h index 77e4ce5..4bf68c4 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/tmc_util.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/tmc_util.h @@ -152,8 +152,8 @@ class TMCMarlin : public TMC220 TMCMarlin(Stream * SerialPort, const float RS, uint8_t addr, const uint16_t mul_pin1, const uint16_t mul_pin2) : TMC2208Stepper(SerialPort, RS, addr, mul_pin1, mul_pin2) {} - TMCMarlin(const uint16_t RX, const uint16_t TX, const float RS, const uint8_t, const bool has_rx=true) : - TMC2208Stepper(RX, TX, RS, has_rx) + TMCMarlin(const uint16_t RX, const uint16_t TX, const float RS, const uint8_t) : + TMC2208Stepper(RX, TX, RS) {} uint16_t rms_current() { return TMC2208Stepper::rms_current(); } @@ -197,7 +197,7 @@ class TMCMarlin : public TMC220 TMCMarlin(Stream * SerialPort, const float RS, const uint8_t addr) : TMC2209Stepper(SerialPort, RS, addr) {} - TMCMarlin(const uint16_t RX, const uint16_t TX, const float RS, const uint8_t addr, const bool) : + TMCMarlin(const uint16_t RX, const uint16_t TX, const float RS, const uint8_t addr) : TMC2209Stepper(RX, TX, RS, addr) {} uint8_t get_address() { return slave_address; } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/feature/touch/xpt2046.cpp b/Marlin-bugfix-2.0.x/Marlin/src/feature/touch/xpt2046.cpp index 7f9a718..463034d 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/feature/touch/xpt2046.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/feature/touch/xpt2046.cpp @@ -25,6 +25,29 @@ #include "../../inc/MarlinConfig.h" #include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc. +/* + * Draw and Touch processing + * + * LCD_PIXEL_WIDTH/HEIGHT (128x64) is the (emulated DOGM) Pixel Drawing resolution. + * TOUCH_SCREEN_WIDTH/HEIGHT (320x240) is the Touch Area resolution. + * LCD_FULL_PIXEL_WIDTH/HEIGHT (320x240 or 480x320) is the Actual (FSMC) Display resolution. + * + * - All native (u8g) drawing is done in LCD_PIXEL_* (128x64) + * - The DOGM pixels are is upscaled 2-3x (as needed) for display. + * - Touch coordinates use TOUCH_SCREEN_* resolution and are converted to + * click and scroll-wheel events (emulating of a common DOGM display). + * + * TOUCH_SCREEN resolution exists to fit our calibration values. The original touch code was made + * and originally calibrated for 320x240. If you decide to change the resolution of the touch code, + * new calibration values will be needed. + * + * The Marlin menus are drawn scaled in the upper region of the screen. The bottom region (in a + * fixed location in TOUCH_SCREEN* coordinate space) is used for 4 general-purpose buttons to + * navigate and select menu items. Both regions are touchable. + * + * The Marlin screen touchable area starts at LCD_PIXEL_OFFSET_X/Y (translated to SCREEN_START_LEFT/TOP) + * and spans LCD_PIXEL_WIDTH/HEIGHT (scaled to SCREEN_WIDTH/HEIGHT). + */ // Touch screen resolution independent of display resolution #define TOUCH_SCREEN_HEIGHT 240 #define TOUCH_SCREEN_WIDTH 320 @@ -33,8 +56,13 @@ #define BUTTON_AREA_TOP 175 #define BUTTON_AREA_BOT 234 -#define SCREEN_START_TOP ((LCD_PIXEL_OFFSET_Y) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT)) -#define TOUCHABLE_Y_HEIGHT (BUTTON_AREA_TOP - (SCREEN_START_TOP)) +#define SCREEN_START_TOP ((LCD_PIXEL_OFFSET_Y) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT)) +#define SCREEN_START_LEFT ((LCD_PIXEL_OFFSET_X) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH)) +#define SCREEN_HEIGHT ((LCD_PIXEL_HEIGHT * FSMC_UPSCALE) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT)) +#define SCREEN_WIDTH ((LCD_PIXEL_WIDTH * FSMC_UPSCALE) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH)) + +#define TOUCHABLE_Y_HEIGHT SCREEN_HEIGHT +#define TOUCHABLE_X_WIDTH SCREEN_WIDTH #ifndef TOUCH_INT_PIN #define TOUCH_INT_PIN -1 @@ -98,10 +126,10 @@ uint8_t XPT2046::read_buttons() { : WITHIN(x, 242, 305) ? EN_C : 0; - if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, BUTTON_AREA_TOP)) return 0; + if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0; // Column and row above BUTTON_AREA_TOP - int8_t col = x * (LCD_WIDTH) / (TOUCH_SCREEN_WIDTH), + int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH), row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT); // Send the touch to the UI (which will simulate the encoder wheel) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/bedlevel/G35.cpp new file mode 100644 index 0000000..f4153f3 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/bedlevel/G35.cpp @@ -0,0 +1,190 @@ +/** + * 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(ASSISTED_TRAMMING) + +#include "../gcode.h" +#include "../../module/planner.h" +#include "../../module/probe.h" +#include "../../feature/bedlevel/bedlevel.h" + +#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) +#include "../../core/debug_out.h" + +constexpr xy_pos_t screws_tilt_adjust_pos[] = TRAMMING_POINT_XY; + +static PGMSTR(point_name_1, TRAMMING_POINT_NAME_1); +static PGMSTR(point_name_2, TRAMMING_POINT_NAME_2); +static PGMSTR(point_name_3, TRAMMING_POINT_NAME_3); +#ifdef TRAMMING_POINT_NAME_4 + static PGMSTR(point_name_4, TRAMMING_POINT_NAME_4); + #ifdef TRAMMING_POINT_NAME_5 + static PGMSTR(point_name_5, TRAMMING_POINT_NAME_5); + #endif +#endif + +static PGM_P const tramming_point_name[] PROGMEM = { + point_name_1, point_name_2, point_name_3 + #ifdef TRAMMING_POINT_NAME_4 + , point_name_4 + #ifdef TRAMMING_POINT_NAME_5 + , point_name_5 + #endif + #endif +}; + +#define G35_PROBE_COUNT COUNT(screws_tilt_adjust_pos) + +#if !WITHIN(TRAMMING_SCREW_THREAD, 30, 51) || TRAMMING_SCREW_THREAD % 10 > 1 + #error "TRAMMING_SCREW_THREAD must be equal to 30, 31, 40, 41, 50, or 51." +#endif + +static_assert(G35_PROBE_COUNT > 2, "TRAMMING_POINT_XY requires at least 3 XY positions."); + +/** + * G35: Read bed corners to help adjust bed screws + * + * S + * + * Screw thread: 30 - Clockwise M3 + * 31 - Counter-Clockwise M3 + * 40 - Clockwise M4 + * 41 - Counter-Clockwise M4 + * 50 - Clockwise M5 + * 51 - Counter-Clockwise M5 + **/ +void GcodeSuite::G35() { + if (DEBUGGING(LEVELING)) { + DEBUG_ECHOLNPGM(">>> G35"); + log_machine_info(); + } + + float z_measured[G35_PROBE_COUNT] = { 0 }; + + const uint8_t screw_thread = parser.byteval('S', TRAMMING_SCREW_THREAD); + if (!WITHIN(screw_thread, 30, 51) || screw_thread % 10 > 1) { + SERIAL_ECHOLNPGM("?(S)crew thread must be 30, 31, 40, 41, 50, or 51."); + return; + } + + // Wait for planner moves to finish! + planner.synchronize(); + + // Disable the leveling matrix before auto-aligning + #if HAS_LEVELING + TERN_(RESTORE_LEVELING_AFTER_G35, const bool leveling_was_active = planner.leveling_active); + set_bed_leveling_enabled(false); + #endif + + #if ENABLED(CNC_WORKSPACE_PLANES) + workspace_plane = PLANE_XY; + #endif + + // Always home with tool 0 active + #if HAS_MULTI_HOTEND + const uint8_t old_tool_index = active_extruder; + tool_change(0, true); + #endif + + #if HAS_DUPLICATION_MODE + extruder_duplication_enabled = false; + #endif + + // Home all before this procedure + home_all_axes(); + + bool err_break = false; + + // Probe all positions + LOOP_L_N(i, G35_PROBE_COUNT) { + + // In BLTOUCH HS mode, the probe travels in a deployed state. + // Users of G35 might have a badly misaligned bed, so raise Z by the + // length of the deployed pin (BLTOUCH stroke < 7mm) + current_position.z = (Z_CLEARANCE_BETWEEN_PROBES) + (7 * ENABLED(BLTOUCH_HS_MODE)); + + const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true); + + if (isnan(z_probed_height)) { + SERIAL_ECHOLNPAIR("G35 failed at point ", int(i), " (", tramming_point_name[i], ")" + " X", screws_tilt_adjust_pos[i].x, + " Y", screws_tilt_adjust_pos[i].y); + err_break = true; + break; + } + + if (DEBUGGING(LEVELING)) + DEBUG_ECHOLNPAIR("Probing point ", int(i), " (", tramming_point_name[i], ")" + " X", screws_tilt_adjust_pos[i].x, + " Y", screws_tilt_adjust_pos[i].y, + " Z", z_probed_height); + + z_measured[i] = z_probed_height; + } + + if (!err_break) { + const float threads_factor[] = { 0.5, 0.7, 0.8 }; + + // Calculate adjusts + LOOP_S_L_N(i, 1, G35_PROBE_COUNT) { + const float diff = z_measured[0] - z_measured[i], + adjust = abs(diff) < 0.001f ? 0 : diff / threads_factor[(screw_thread - 30) / 10]; + + const int full_turns = trunc(adjust); + const float decimal_part = adjust - float(full_turns); + const int minutes = trunc(decimal_part * 60.0f); + + SERIAL_ECHOPAIR("Turn ", tramming_point_name[i], + " ", (screw_thread & 1) == (adjust > 0) ? "Counter-Clockwise" : "Clockwise", + "by ", abs(full_turns), " turns"); + if (minutes) SERIAL_ECHOPAIR(" and ", abs(minutes), " minutes"); + SERIAL_EOL(); + } + } + else + SERIAL_ECHOLNPGM("G35 aborted."); + + // Restore the active tool after homing + #if HAS_MULTI_HOTEND + tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER + #endif + + #if BOTH(HAS_LEVELING, RESTORE_LEVELING_AFTER_G35) + set_bed_leveling_enabled(leveling_was_active); + #endif + + // Stow the probe, as the last call to probe.probe_at_point(...) left + // the probe deployed if it was successful. + probe.stow(); + + // After this operation the Z position needs correction + set_axis_not_trusted(Z_AXIS); + + // Home Z after the alignment procedure + process_subcommands_now_P(PSTR("G28Z")); + + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G35"); +} + +#endif // ASSISTED_TRAMMING diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/bedlevel/abl/G29.cpp index 9c5907a..01871ec 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -60,6 +60,10 @@ #include "../../../lcd/extui/ui_api.h" #endif +#if ENABLED(DWIN_CREALITY_LCD) + #include "../../../lcd/dwin/dwin.h" +#endif + #if HAS_MULTI_HOTEND #include "../../../module/tool_change.h" #endif @@ -888,6 +892,10 @@ G29_TYPE GcodeSuite::G29() { process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT)); #endif + #if ENABLED(DWIN_CREALITY_LCD) + DWIN_CompletedLeveling(); + #endif + report_current_position(); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29"); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/calibrate/G28.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/calibrate/G28.cpp index 8720b1a..982c9e9 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/calibrate/G28.cpp @@ -46,6 +46,9 @@ #endif #include "../../lcd/ultralcd.h" +#if ENABLED(DWIN_CREALITY_LCD) + #include "../../lcd/dwin/dwin.h" +#endif #if HAS_L64XX // set L6470 absolute position registers to counts #include "../../libs/L64XX/L64XX_Marlin.h" @@ -209,6 +212,8 @@ void GcodeSuite::G28() { log_machine_info(); } + TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true); + #if ENABLED(DUAL_X_CARRIAGE) bool IDEX_saved_duplication_state = extruder_duplication_enabled; DualXMode IDEX_saved_mode = dual_x_carriage_mode; @@ -475,6 +480,8 @@ void GcodeSuite::G28() { ui.refresh(); + TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming()); + report_current_position(); if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS))) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/config/M200-M205.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/config/M200-M205.cpp index d3c355f..67a0007 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/config/M200-M205.cpp @@ -65,7 +65,7 @@ SERIAL_ECHOLNPGM("?L value out of range (0-20)."); } #endif - + planner.calculate_volumetric_multipliers(); } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/config/M92.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/config/M92.cpp index bc86ff4..4f7279f 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/config/M92.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/config/M92.cpp @@ -105,7 +105,7 @@ void GcodeSuite::M92() { if (wanted) { const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm; SERIAL_ECHOPAIR(", best:[", best); - if (best != wanted) { SERIAL_CHAR(','); SERIAL_ECHO(best + z_full_step_mm); } + if (best != wanted) { SERIAL_CHAR(','); SERIAL_DECIMAL(best + z_full_step_mm); } SERIAL_CHAR(']'); } SERIAL_ECHOLNPGM(" }"); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/control/M3-M5.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/control/M3-M5.cpp index 0ef3852..2ddccde 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/control/M3-M5.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/control/M3-M5.cpp @@ -67,8 +67,12 @@ */ void GcodeSuite::M3_M4(const bool is_M4) { auto get_s_power = [] { - if (parser.seen('S')) - cutter.unitPower = cutter.power_to_range(cutter_power_t(round(parser.value_float()))); + if (parser.seenval('S')) { + const float spwr = parser.value_float(); + cutter.unitPower = TERN(SPINDLE_LASER_PWM, + cutter.power_to_range(cutter_power_t(round(spwr))), + spwr > 0 ? 255 : 0); + } else cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); return cutter.unitPower; @@ -86,7 +90,7 @@ void GcodeSuite::M3_M4(const bool is_M4) { else cutter.inline_power(cutter.upower_to_ocr(get_s_power())); #else - cutter.inline_enabled(true); + cutter.set_inline_enabled(true); #endif return; } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/feature/advance/M900.cpp index b398540..683f6ff 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/feature/advance/M900.cpp @@ -134,7 +134,7 @@ void GcodeSuite::M900() { SERIAL_ECHOPGM("Advance K"); LOOP_L_N(i, EXTRUDERS) { SERIAL_CHAR(' ', '0' + i, ':'); - SERIAL_ECHO(planner.extruder_advance_K[i]); + SERIAL_DECIMAL(planner.extruder_advance_K[i]); } SERIAL_EOL(); #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/feature/power_monitor/M430.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/feature/power_monitor/M430.cpp new file mode 100644 index 0000000..50bb146 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/feature/power_monitor/M430.cpp @@ -0,0 +1,70 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if HAS_POWER_MONITOR + +#include "../../../feature/power_monitor.h" +#include "../../../Marlin.h" +#include "../../gcode.h" + +/** + * M430: Enable/disable current LCD display + * With no parameters report the system current draw (in Amps) + * + * I[bool] - Set Display of current on the LCD + * V[bool] - Set Display of voltage on the LCD + * W[bool] - Set Display of power on the LCD + */ +void GcodeSuite::M430() { + bool do_report = true; + #if HAS_SPI_LCD + #if ENABLED(POWER_MONITOR_CURRENT) + if (parser.seen('I')) { power_monitor.set_current_display(parser.value_bool()); do_report = false; } + #endif + #if HAS_POWER_MONITOR_VREF + if (parser.seen('V')) { power_monitor.set_voltage_display(parser.value_bool()); do_report = false; } + #endif + #if HAS_POWER_MONITOR_WATTS + if (parser.seen('W')) { power_monitor.set_power_display(parser.value_bool()); do_report = false; } + #endif + #endif + if (do_report) { + SERIAL_ECHOLNPAIR( + #if ENABLED(POWER_MONITOR_CURRENT) + "Current: ", power_monitor.getAmps(), "A" + #if HAS_POWER_MONITOR_VREF + " " + #endif + #endif + #if HAS_POWER_MONITOR_VREF + "Voltage: ", power_monitor.getVolts(), "V" + #endif + #if HAS_POWER_MONITOR_WATTS + " Power: ", power_monitor.getPower(), "W" + #endif + ); + } +} + +#endif // HAS_POWER_MONITOR diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/gcode.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/gcode.cpp index 5dee317..960acc3 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/gcode.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/gcode.cpp @@ -179,8 +179,10 @@ void GcodeSuite::get_destination_from_command() { #if ENABLED(LASER_MOVE_POWER) // Set the laser power in the planner to configure this move - if (parser.seen('S')) - cutter.inline_power(cutter.power_to_range(cutter_power_t(round(parser.value_float())))); + if (parser.seen('S')) { + const float spwr = parser.value_float(); + cutter.inline_power(TERN(SPINDLE_LASER_PWM, cutter.power_to_range(cutter_power_t(round(spwr))), spwr > 0 ? 255 : 0)); + } else if (ENABLED(LASER_MOVE_G0_OFF) && parser.codenum == 0) // G0 cutter.set_inline_enabled(false); #endif @@ -319,6 +321,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 34: G34(); break; // G34: Z Stepper automatic alignment using probe #endif + #if ENABLED(ASSISTED_TRAMMING) + case 35: G35(); break; // G35: Read four bed corners to help adjust bed screws + #endif + #if ENABLED(G38_PROBE_TARGET) case 38: // G38.2, G38.3: Probe towards target if (WITHIN(parser.subcode, 2, @@ -718,6 +724,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 428: M428(); break; // M428: Apply current_position to home_offset #endif + #if HAS_POWER_MONITOR + case 430: M430(); break; // M430: Read the system current (A), voltage (V), and power (W) + #endif + #if ENABLED(CANCEL_OBJECTS) case 486: M486(); break; // M486: Identify and cancel objects #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/gcode.h b/Marlin-bugfix-2.0.x/Marlin/src/gcode/gcode.h index 573ef0f..8548f3a 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/gcode.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/gcode.h @@ -65,6 +65,7 @@ * G32 - Undock sled (Z_PROBE_SLED only) * G33 - Delta Auto-Calibration (Requires DELTA_AUTO_CALIBRATION) * G34 - Z Stepper automatic alignment using probe: I T A (Requires Z_STEPPER_AUTO_ALIGN) + * G35 - Read bed corners to help adjust bed screws: T (Requires ASSISTED_TRAMMING) * G38 - Probe in any direction using the Z_MIN_PROBE (Requires G38_PROBE_TARGET) * G42 - Coordinated move to a mesh point (Requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BLINEAR, or AUTO_BED_LEVELING_UBL) * G60 - Save current position. (Requires SAVED_POSITIONS) @@ -217,6 +218,7 @@ * M422 - Set Z Stepper automatic alignment position using probe. X Y A (Requires Z_STEPPER_AUTO_ALIGN) * M425 - Enable/Disable and tune backlash correction. (Requires BACKLASH_COMPENSATION and BACKLASH_GCODE) * M428 - Set the home_offset based on the current_position. Nearest edge applies. (Disabled by NO_WORKSPACE_OFFSETS or DELTA) + * M430 - Read the system current, voltage, and power (Requires POWER_MONITOR_CURRENT, POWER_MONITOR_VOLTAGE, or POWER_MONITOR_FIXED_VOLTAGE) * M486 - Identify and cancel objects. (Requires CANCEL_OBJECTS) * M500 - Store parameters in EEPROM. (Requires EEPROM_SETTINGS) * M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS) @@ -453,6 +455,8 @@ private: static void M422(); #endif + TERN_(ASSISTED_TRAMMING, static void G35()); + TERN_(G38_PROBE_TARGET, static void G38(const int8_t subcode)); TERN_(HAS_MESH, static void G42()); @@ -735,6 +739,8 @@ private: TERN_(HAS_M206_COMMAND, static void M428()); + TERN_(HAS_POWER_MONITOR, static void M430()); + TERN_(CANCEL_OBJECTS, static void M486()); static void M500(); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/host/M115.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/host/M115.cpp index b641be8..a7bf3f4 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/host/M115.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/host/M115.cpp @@ -115,6 +115,9 @@ void GcodeSuite::M115() { // MOTION_MODES (M80-M89) cap_line(PSTR("MOTION_MODES"), ENABLED(GCODE_MOTION_MODES)); + // ARC_SUPPORT (G2-G3) + cap_line(PSTR("ARCS"), ENABLED(ARC_SUPPORT)); + // BABYSTEPPING (M290) cap_line(PSTR("BABYSTEPPING"), ENABLED(BABYSTEPPING)); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/probe/G30.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/probe/G30.cpp index 5a01289..0d80491 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/probe/G30.cpp @@ -53,7 +53,7 @@ void GcodeSuite::G30() { const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const float measured_z = probe.probe_at_point(pos, raise_after, 1); if (!isnan(measured_z)) - SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z)); + SERIAL_ECHOLNPAIR("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); restore_feedrate_and_scaling(); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/gcode/sd/M24_M25.cpp b/Marlin-bugfix-2.0.x/Marlin/src/gcode/sd/M24_M25.cpp index 8ac3f45..86f34f1 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/gcode/sd/M24_M25.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/gcode/sd/M24_M25.cpp @@ -31,7 +31,6 @@ #if ENABLED(PARK_HEAD_ON_PAUSE) #include "../../feature/pause.h" - #include "../queue.h" #endif #if ENABLED(HOST_ACTION_COMMANDS) @@ -98,7 +97,8 @@ void GcodeSuite::M25() { #endif print_job_timer.pause(); - ui.reset_status(); + + TERN(DWIN_CREALITY_LCD,,ui.reset_status()); #if ENABLED(HOST_ACTION_COMMANDS) TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume"))); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_LCD.h b/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_LCD.h index 11cf582..71b5d7a 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_LCD.h @@ -35,7 +35,15 @@ #define IS_CARTESIAN 1 #endif -#if ENABLED(CARTESIO_UI) +#if ENABLED(MKS_LCD12864) + #define MKS_MINI_12864 +#endif + +#if EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define MINIPANEL + +#elif ENABLED(CARTESIO_UI) #define DOGLCD #define IS_ULTIPANEL @@ -98,15 +106,9 @@ #elif ENABLED(CR10_STOCKDISPLAY) #define IS_RRD_FG_SC - #ifndef ST7920_DELAY_1 - #define ST7920_DELAY_1 DELAY_NS(125) - #endif - #ifndef ST7920_DELAY_2 - #define ST7920_DELAY_2 DELAY_NS(125) - #endif - #ifndef ST7920_DELAY_3 - #define ST7920_DELAY_3 DELAY_NS(125) - #endif + #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 ENABLED(MKS_12864OLED) @@ -118,10 +120,6 @@ #define IS_RRD_SC #define IS_U8GLIB_SSD1306 -#elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) - - #define MINIPANEL - #elif ANY(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) #define FYSETC_MINI_12864 @@ -241,6 +239,8 @@ #define DOGLCD #define IS_ULTIPANEL #define DELAYED_BACKLIGHT_INIT +#elif ENABLED(SPI_GRAPHICAL_TFT) + #define DELAYED_BACKLIGHT_INIT #endif /** @@ -527,6 +527,15 @@ #define UNUSED_E(E) UNUSED(E) #endif +#if ENABLED(DWIN_CREALITY_LCD) + #define SERIAL_CATCHALL 0 +#endif + +// Pressure sensor with a BLTouch-like interface +#if ENABLED(CREALITY_TOUCH) + #define BLTOUCH +#endif + /** * The BLTouch Probe emulates a servo probe * and uses "special" angles for its state. diff --git a/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_adv.h b/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_adv.h index 781c139..a318b19 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_adv.h @@ -352,6 +352,17 @@ #define SD_CONNECTION_IS(...) 0 #endif +// Power Monitor sensors +#if EITHER(POWER_MONITOR_CURRENT, POWER_MONITOR_VOLTAGE) + #define HAS_POWER_MONITOR 1 +#endif +#if ENABLED(POWER_MONITOR_VOLTAGE) || defined(POWER_MONITOR_FIXED_VOLTAGE) + #define HAS_POWER_MONITOR_VREF 1 +#endif +#if BOTH(HAS_POWER_MONITOR_VREF, POWER_MONITOR_CURRENT) + #define HAS_POWER_MONITOR_WATTS 1 +#endif + // Flag if an EEPROM type is pre-selected #if ENABLED(EEPROM_SETTINGS) && NONE(I2C_EEPROM, SPI_EEPROM, QSPI_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION) #define NO_EEPROM_SELECTED 1 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_post.h b/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_post.h index ff4f798..b98f16f 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_post.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/inc/Conditionals_post.h @@ -30,6 +30,13 @@ // Extras for CI testing #endif +// ADC +#ifdef BOARD_ADC_VREF + #define ADC_VREF BOARD_ADC_VREF +#else + #define ADC_VREF HAL_ADC_VREF +#endif + // Linear advance uses Jerk since E is an isolated axis #if BOTH(HAS_JUNCTION_DEVIATION, LIN_ADVANCE) #define HAS_LINEAR_E_JERK 1 @@ -287,7 +294,7 @@ #elif ENABLED(AZSMZ_12864) #define _LCD_CONTRAST_MIN 120 #define _LCD_CONTRAST_INIT 190 -#elif ENABLED(MKS_LCD12864B) +#elif ENABLED(MKS_LCD12864) #define _LCD_CONTRAST_MIN 120 #define _LCD_CONTRAST_INIT 205 #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) @@ -1685,16 +1692,16 @@ #if ENABLED(JOYSTICK) #if PIN_EXISTS(JOY_X) #define HAS_JOY_ADC_X 1 -#endif + #endif #if PIN_EXISTS(JOY_Y) #define HAS_JOY_ADC_Y 1 -#endif + #endif #if PIN_EXISTS(JOY_Z) #define HAS_JOY_ADC_Z 1 -#endif + #endif #if PIN_EXISTS(JOY_EN) #define HAS_JOY_ADC_EN 1 -#endif + #endif #endif // Heaters @@ -2465,7 +2472,11 @@ #endif // Number of VFAT entries used. Each entry has 13 UTF-16 characters -#define MAX_VFAT_ENTRIES TERN(SCROLL_LONG_FILENAMES, 5, 2) +#if EITHER(SCROLL_LONG_FILENAMES, DWIN_CREALITY_LCD) + #define MAX_VFAT_ENTRIES (5) +#else + #define MAX_VFAT_ENTRIES (2) +#endif // Nozzle park for Delta #if BOTH(NOZZLE_PARK_FEATURE, DELTA) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/inc/SanityCheck.h b/Marlin-bugfix-2.0.x/Marlin/src/inc/SanityCheck.h index 0d411fb..a9febd9 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/inc/SanityCheck.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/inc/SanityCheck.h @@ -1165,7 +1165,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS + ENABLED(FIX_MOUNTED_PROBE) \ + ENABLED(NOZZLE_AS_PROBE) \ + (HAS_Z_SERVO_PROBE && DISABLED(BLTOUCH)) \ - + ENABLED(BLTOUCH) \ + + ENABLED(BLTOUCH) && DISABLED(CREALITY_TOUCH) \ + + ENABLED(CREALITY_TOUCH) \ + ENABLED(TOUCH_MI_PROBE) \ + ENABLED(SOLENOID_PROBE) \ + ENABLED(Z_PROBE_ALLEN_KEY) \ @@ -1479,6 +1480,17 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #endif #endif +/** + * System Power Sensor + */ +#if ENABLED(POWER_MONITOR_CURRENT) && !PIN_EXISTS(POWER_MONITOR_CURRENT) + #error "POWER_MONITOR_CURRENT requires a valid POWER_MONITOR_CURRENT_PIN." +#elif ENABLED(POWER_MONITOR_VOLTAGE) && !PIN_EXISTS(POWER_MONITOR_VOLTAGE) + #error "POWER_MONITOR_VOLTAGE requires POWER_MONITOR_VOLTAGE_PIN to be defined." +#elif BOTH(POWER_MONITOR_CURRENT, POWER_MONITOR_VOLTAGE) && POWER_MONITOR_CURRENT_PIN == POWER_MONITOR_VOLTAGE_PIN + #error "POWER_MONITOR_CURRENT_PIN and POWER_MONITOR_VOLTAGE_PIN must be different." +#endif + /** * Volumetric Extruder Limit */ @@ -1758,9 +1770,13 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_7 shouldn't be set with only 1 HOTEND." #endif +#if TEMP_SENSOR_CHAMBER && !PIN_EXISTS(TEMP_CHAMBER) + #error "TEMP_SENSOR_CHAMBER requires TEMP_CHAMBER_PIN. Please add it to your configuration." +#endif + #if TEMP_SENSOR_PROBE #if !PIN_EXISTS(TEMP_PROBE) - #error "TEMP_SENSOR_PROBE requires TEMP_PROBE_PIN." + #error "TEMP_SENSOR_PROBE requires TEMP_PROBE_PIN. Please add it to your configuration." #elif !HAS_TEMP_ADC_PROBE #error "TEMP_PROBE_PIN must be an ADC pin." #elif !ENABLED(FIX_MOUNTED_PROBE) @@ -2116,6 +2132,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal + (ENABLED(ULTRA_LCD) && DISABLED(IS_ULTRA_LCD)) \ + (ENABLED(U8GLIB_SSD1306) && DISABLED(IS_U8GLIB_SSD1306)) \ + (ENABLED(MINIPANEL) && DISABLED(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) \ @@ -2142,7 +2159,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal + ENABLED(CARTESIO_UI) \ + ENABLED(LCD_FOR_MELZI) \ + ENABLED(ULTI_CONTROLLER) \ - + ENABLED(MKS_MINI_12864) \ + + ENABLED(MKS_LCD12864) \ + ENABLED(ENDER2_STOCKDISPLAY) \ + ENABLED(FYSETC_MINI_12864_X_X) \ + ENABLED(FYSETC_MINI_12864_1_2) \ @@ -2150,6 +2167,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal + 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) \ diff --git a/Marlin-bugfix-2.0.x/Marlin/src/inc/Version.h b/Marlin-bugfix-2.0.x/Marlin/src/inc/Version.h index 605a6c8..54f6991 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/inc/Version.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-06-15" + #define STRING_DISTRIBUTION_DATE "2020-06-23" #endif /** diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index 45c4f94..4447808 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -927,6 +927,7 @@ static const hd44780_charmap_t g_hd44780_charmap_common[] PROGMEM = { {IV('ю'), '|', 'o'}, {IV('я'), 'g', 0}, // 044F {IV('ё'), 'e', 0}, // 0451 + #endif {IV('•'), '.', 0}, // 2022 · diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/dogm_Statusscreen.h index d2517c3..6d09228 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -1372,7 +1372,7 @@ #define STATUS_LOGO_X 0 #endif #ifndef STATUS_LOGO_Y - #define STATUS_LOGO_Y _MIN(0U, (10 - (STATUS_LOGO_HEIGHT) / 2)) + #define STATUS_LOGO_Y _MIN(0U, ((20 - (STATUS_LOGO_HEIGHT)) / 2) #endif #ifndef STATUS_LOGO_HEIGHT #define STATUS_LOGO_HEIGHT (sizeof(status_logo_bmp) / (STATUS_LOGO_BYTEWIDTH)) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 6fc6b2f..72bdf1e 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -48,6 +48,10 @@ #include "../../feature/spindle_laser.h" #endif +#if HAS_POWER_MONITOR + #include "../../feature/power_monitor.h" +#endif + #if ENABLED(SDSUPPORT) #include "../../sd/cardreader.h" #endif @@ -103,6 +107,59 @@ #define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1) #endif +#if HAS_POWER_MONITOR + + void display_power_monitor(const uint8_t x, const uint8_t y) { + + lcd_moveto(x, y); + + #if ENABLED(POWER_MONITOR_CURRENT) + const bool iflag = power_monitor.current_display_enabled(); + #endif + #if HAS_POWER_MONITOR_VREF + const bool vflag = power_monitor.voltage_display_enabled(); + #endif + #if HAS_POWER_MONITOR_WATTS + const bool wflag = power_monitor.power_display_enabled(); + #endif + + #if ENABLED(POWER_MONITOR_CURRENT) || HAS_POWER_MONITOR_VREF + // cycle between current, voltage, and power + if (ELAPSED(millis(), power_monitor.display_item_ms)) { + power_monitor.display_item_ms = millis() + 1000UL; + ++power_monitor.display_item; + } + #endif + + // ensure we have the right one selected for display + for (uint8_t i = 0; i < 3; i++) { + #if ENABLED(POWER_MONITOR_CURRENT) + if (power_monitor.display_item == 0 && !iflag) ++power_monitor.display_item; + #endif + #if HAS_POWER_MONITOR_VREF + if (power_monitor.display_item == 1 && !vflag) ++power_monitor.display_item; + #endif + #if ENABLED(POWER_MONITOR_CURRENT) + if (power_monitor.display_item == 2 && !wflag) ++power_monitor.display_item; + #endif + if (power_monitor.display_item >= 3) power_monitor.display_item = 0; + } + + switch (power_monitor.display_item) { + #if ENABLED(POWER_MONITOR_CURRENT) // Current + case 0: if (iflag) power_monitor.draw_current(); break; + #endif + #if HAS_POWER_MONITOR_VREF // Voltage + case 1: if (vflag) power_monitor.draw_voltage(); break; + #endif + #if HAS_POWER_MONITOR_WATTS // Power + case 2: if (wflag) power_monitor.draw_power(); break; + #endif + default: break; + } + } +#endif + #define PROGRESS_BAR_X 54 #define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1) #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X) @@ -787,16 +844,25 @@ void MarlinUI::draw_status_screen() { void MarlinUI::draw_status_message(const bool blink) { // Get the UTF8 character count of the string - uint8_t slen = utf8_strlen(status_message); + uint8_t lcd_width = LCD_WIDTH, pixel_width = LCD_PIXEL_WIDTH, + slen = utf8_strlen(status_message); + + #if HAS_POWER_MONITOR + if (power_monitor.display_enabled()) { + // make room at the end of the status line for the power monitor reading + lcd_width -= 6; + pixel_width -= (MENU_FONT_WIDTH) * 6; + } + #endif #if ENABLED(STATUS_MESSAGE_SCROLLING) static bool last_blink = false; - if (slen <= LCD_WIDTH) { + if (slen <= lcd_width) { // The string fits within the line. Print with no scrolling lcd_put_u8str(status_message); - while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; } + while (slen < lcd_width) { lcd_put_wchar(' '); ++slen; } } else { // String is longer than the available space @@ -805,20 +871,21 @@ void MarlinUI::draw_status_message(const bool blink) { // and the string remaining length uint8_t rlen; const char *stat = status_and_len(rlen); - lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH); + lcd_put_u8str_max(stat, pixel_width); // If the remaining string doesn't completely fill the screen - if (rlen < LCD_WIDTH) { + if (rlen < lcd_width) { lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot - uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters + uint8_t chars = lcd_width - rlen; // Amount of space left in characters if (--chars) { // Draw a second dot if there's space lcd_put_wchar('.'); if (--chars) { // Print a second copy of the message - lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH - (rlen + 2) * (MENU_FONT_WIDTH)); + lcd_put_u8str_max(status_message, pixel_width - (rlen + 2) * (MENU_FONT_WIDTH)); lcd_put_wchar(' '); } } } + if (last_blink != blink) { last_blink = blink; advance_status_scroll(); @@ -830,12 +897,16 @@ void MarlinUI::draw_status_message(const bool blink) { UNUSED(blink); // Just print the string to the LCD - lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH); + lcd_put_u8str_max(status_message, pixel_width); // Fill the rest with spaces - for (; slen < LCD_WIDTH; ++slen) lcd_put_wchar(' '); + for (; slen < lcd_width; ++slen) lcd_put_wchar(' '); #endif // !STATUS_MESSAGE_SCROLLING + + #if HAS_POWER_MONITOR + display_power_monitor(pixel_width + MENU_FONT_WIDTH, STATUS_BASELINE); + #endif } #endif // HAS_GRAPHICAL_LCD && !LIGHTWEIGHT_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp index 7c7021a..20fd44f 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp @@ -73,10 +73,6 @@ extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count); #endif -#ifndef FSMC_UPSCALE - #define FSMC_UPSCALE 2 -#endif - #define WIDTH LCD_PIXEL_WIDTH #define HEIGHT LCD_PIXEL_HEIGHT #define PAGE_HEIGHT 8 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/u8g_fontutf8.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/u8g_fontutf8.cpp index b976e27..370b177 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/u8g_fontutf8.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/u8g_fontutf8.cpp @@ -140,7 +140,6 @@ static int fontgroup_cb_draw_u8g(void *userdata, const font_t *fnt_current, cons if (pdata->fnt_prev != fnt_current) { u8g_SetFont(pdata->pu8g, (const u8g_fntpgm_uint8_t*)fnt_current); - //u8g_SetFontPosBottom(pdata->pu8g); pdata->fnt_prev = fnt_current; } if ((pdata->max_width != PIXEL_LEN_NOLIMIT) && (pdata->adv + u8g_GetStrPixelWidth(pdata->pu8g, (char*)msg) > pdata->max_width)) @@ -256,7 +255,6 @@ static int fontgroup_cb_draw_u8gstrlen(void *userdata, const font_t *fnt_current if (pdata->fnt_prev != fnt_current) { u8g_SetFont(pdata->pu8g, (const u8g_fntpgm_uint8_t*)fnt_current); - u8g_SetFontPosBottom(pdata->pu8g); pdata->fnt_prev = fnt_current; } pdata->adv += u8g_GetStrPixelWidth(pdata->pu8g, (char*)msg); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp index aaf2ccc..60c7cc2 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp @@ -240,7 +240,7 @@ bool MarlinUI::detected() { return true; } // Initialize or re-initialize the LCD void MarlinUI::init_lcd() { - #if DISABLED(MKS_LCD12864B) + #if DISABLED(MKS_LCD12864) #if PIN_EXISTS(LCD_BACKLIGHT) OUT_WRITE(LCD_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); // Illuminate after reset or right away @@ -272,7 +272,7 @@ void MarlinUI::init_lcd() { TERN_(LCD_SCREEN_ROT_180, u8g.setRot180()); TERN_(LCD_SCREEN_ROT_270, u8g.setRot270()); - #endif // !MKS_LCD12864B + #endif // !MKS_LCD12864 uxg_SetUtf8Fonts(g_fontinfo, COUNT(g_fontinfo)); } @@ -377,12 +377,14 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Draw a menu item with an editable value void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) { if (mark_as_selected(row, sel)) { - const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data)); + const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data)), + pixelwidth = (pgm ? uxg_GetUtf8StrPixelWidthP(u8g.getU8g(), data) : uxg_GetUtf8StrPixelWidth(u8g.getU8g(), (char*)data)); + u8g_uint_t n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH); if (vallen) { lcd_put_wchar(':'); while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); - lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH) * vallen, row_y2); + lcd_moveto(LCD_PIXEL_WIDTH - _MAX((MENU_FONT_WIDTH) * vallen, pixelwidth + 2), row_y2); if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str((char*)data); } } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_DOGM.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_DOGM.h index 7a7a4df..e96d4d7 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_DOGM.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_DOGM.h @@ -254,4 +254,8 @@ #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT) #define INFO_FONT_WIDTH 6 +#ifndef FSMC_UPSCALE + #define FSMC_UPSCALE 2 +#endif + extern U8G_CLASS u8g; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp index 4e38e55..ea65b97 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp @@ -34,19 +34,30 @@ #include "ultralcd_st7920_u8glib_rrd_AVR.h" #ifndef ST7920_DELAY_1 - #define ST7920_DELAY_1 CPU_ST7920_DELAY_1 + #ifdef BOARD_ST7920_DELAY_1 + #define ST7920_DELAY_1 BOARD_ST7920_DELAY_1 + #else + #define ST7920_DELAY_1 CPU_ST7920_DELAY_1 + #endif #endif #ifndef ST7920_DELAY_2 - #define ST7920_DELAY_2 CPU_ST7920_DELAY_2 + #ifdef BOARD_ST7920_DELAY_2 + #define ST7920_DELAY_2 BOARD_ST7920_DELAY_2 + #else + #define ST7920_DELAY_2 CPU_ST7920_DELAY_2 + #endif #endif #ifndef ST7920_DELAY_3 - #define ST7920_DELAY_3 CPU_ST7920_DELAY_3 + #ifdef BOARD_ST7920_DELAY_3 + #define ST7920_DELAY_3 BOARD_ST7920_DELAY_3 + #else + #define ST7920_DELAY_3 CPU_ST7920_DELAY_3 + #endif #endif // Optimize this code with -O3 #pragma GCC optimize (3) - #ifdef ARDUINO_ARCH_STM32F1 #define ST7920_DAT(V) !!((V) & 0x80) #else diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/README.md b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/README.md new file mode 100644 index 0000000..10b0545 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/README.md @@ -0,0 +1,7 @@ +# DWIN for Creality Ender 3 v2 + +Marlin's Ender 3 v2 support requires the `DWIN_SET` included with the Ender 3 V2 [example configuration](https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.0.x/config/examples/Creality/Ender-3%20V2). + +## Easy Install + +Copy the `DWIN_SET` folder onto a Micro-SD card and insert the card into the slot on the DWIN screen. Cycle the machine and wait for the screen to go from blue to orange. Turn the machine off and remove the SD card. When you turn on the machine the screen will display a "Creality" loading screen. diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin.cpp new file mode 100644 index 0000000..7497222 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin.cpp @@ -0,0 +1,3400 @@ +/** + * 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 . + * + */ + +/** + * DWIN by Creality3D + */ + +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_CREALITY_LCD) + +#include "dwin.h" + +#include +#include +#include + +#include "../fontutils.h" +#include "../ultralcd.h" + +#include "../../sd/cardreader.h" + +#include "../../MarlinCore.h" +#include "../../core/serial.h" +#include "../../core/macros.h" +#include "../../gcode/queue.h" + +#include "../../feature/powerloss.h" +#include "../../feature/babystep.h" + +#include "../../module/configuration_store.h" +#include "../../module/temperature.h" +#include "../../module/printcounter.h" +#include "../../module/motion.h" +#include "../../module/planner.h" + +#if HAS_LEVELING + #include "../../feature/bedlevel/bedlevel.h" +#endif + +#if HAS_BED_PROBE + #include "../../module/probe.h" +#endif + +#include "../../libs/buzzer.h" + +#define PAUSE_HEAT true + +#define USE_STRING_HEADINGS + +#define MENU_FONT font8x16 +#define STAT_FONT font10x20 +#define HEADER_FONT font10x20 + +constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, // Total rows, and other-than-Back + TITLE_HEIGHT = 30, // Title bar height + MLINE = 53, // Menu line height + LBLX = 60, // Menu item label X + MENU_CHR_W = 8, STAT_CHR_W = 10; + +#define MBASE(L) (49+(L)*MLINE) + +#define BABY_Z_VAR TERN(HAS_LEVELING, probe.offset.z, zprobe_zoffset) + +/* Value Init */ +HMI_value_t HMI_ValueStruct; +HMI_Flag HMI_flag{0}; + +millis_t Encoder_ms = 0; +millis_t Wait_ms = 0; +millis_t heat_time = 0; + +int checkkey = 0, last_checkkey = 0; + +typedef struct { + uint8_t now, last; + void set(uint8_t v) { now = last = v; } + void reset() { set(0); } + bool changed() { bool c = (now != last); if (c) last = now; return c; } + bool dec() { if (now) now--; return changed(); } + bool inc(uint8_t v) { if (now < v) now++; else now = v; return changed(); } +} select_t; + +select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0} + , select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0} + , select_PLA{0}, select_ABS{0} + , select_speed{0} + , select_acc{0} + , select_corner{0} + , select_step{0} + //, select_leveling{0} + ; + +uint8_t index_file = MROWS, + index_prepare = MROWS, + index_control = MROWS, + index_leveling = MROWS, + index_tune = 5; + +//char filebuf[50]; + +uint8_t countbuf = 0; + +bool recovery_flag = false, abort_flag = false; + +constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; +constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; +constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; +constexpr float default_axis_steps_per_unit[] = DEFAULT_AXIS_STEPS_PER_UNIT; + +uint8_t Percentrecord = 0; +uint16_t last_Printtime = 0, remain_time = 0; +float last_temp_hotend_target = 0, last_temp_bed_target = 0; +float last_temp_hotend_current = 0, last_temp_bed_current = 0; +uint8_t last_fan_speed = 0; +uint16_t last_speed = 0; + +float last_E_scale = 0; + +bool DWIN_lcd_sd_status = 0; + +bool pause_action_flag = 0; + +int temphot = 0, tempbed = 0; + +float zprobe_zoffset = 0.00; +float last_zoffset = 0.00, last_probe_zoffset = 0.00; + +#define FONT_EEPROM_OFFSET 0 + +void lcd_select_language(void) { + BL24CXX::read(FONT_EEPROM_OFFSET, (uint8_t*)&HMI_flag.language_flag, sizeof(HMI_flag.language_flag)); + if (HMI_flag.language_flag) + DWIN_JPG_CacheTo1(Language_Chinese); + else + DWIN_JPG_CacheTo1(Language_English); +} + +void set_english_to_eeprom(void) { + HMI_flag.language_flag = 0; + DWIN_JPG_CacheTo1(Language_English); + BL24CXX::write(FONT_EEPROM_OFFSET, (uint8_t*)&HMI_flag.language_flag, sizeof(HMI_flag.language_flag)); +} +void set_chinese_to_eeprom(void) { + HMI_flag.language_flag = 1; + DWIN_JPG_CacheTo1(Language_Chinese); + BL24CXX::write(FONT_EEPROM_OFFSET, (uint8_t*)&HMI_flag.language_flag, sizeof(HMI_flag.language_flag)); +} + +void show_plus_or_minus(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) { + if (value < 0) { + DWIN_Draw_String(false,true,size,White,bColor, x-6, y, (char*)"-"); + DWIN_Draw_FloatValue(true,true,0,size,White,bColor, iNum, fNum, x, y, -value); + } + else { + DWIN_Draw_String(false,true,size,White,bColor, x-6, y, (char*)" "); + DWIN_Draw_FloatValue(true,true,0,size,White,bColor, iNum, fNum, x, y, value); + } +} + +void ICON_Print() { + if (select_page.now == 0) { + DWIN_ICON_Show(ICON,ICON_Print_1, 17, 130); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 1, 447, 271-243, 479-19, 58, 201); + else + DWIN_Frame_AreaCopy(1, 1, 451, 271-240, 479-16, 72-15, 201); + } + else { + DWIN_ICON_Show(ICON,ICON_Print_0, 17, 130); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 1, 405, 271-243, 420, 58, 201); + else + DWIN_Frame_AreaCopy(1, 1, 423, 271-240, 423+12, 72-15, 201); + } +} + +void ICON_Prepare() { + if (select_page.now == 1) { + DWIN_ICON_Show(ICON,ICON_Prepare_1, 145, 130); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 31, 447, 271-213, 479-19, 186, 201); + else + DWIN_Frame_AreaCopy(1, 33, 451, 271-189, 479-13, 200-25, 201); + } + else { + DWIN_ICON_Show(ICON,ICON_Prepare_0, 145, 130); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 31, 405, 271-213, 420, 186, 201); + else + DWIN_Frame_AreaCopy(1, 33, 423, 271-189, 423+15, 200-25, 201); + } +} + +void ICON_Control() { + if (select_page.now == 2) { + DWIN_ICON_Show(ICON,ICON_Control_1, 17, 246); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 61, 447, 271-183, 479-19, 58, 318); + else + DWIN_Frame_AreaCopy(1, 85, 451, 271-139, 479-16, 72-24, 318); + } + else { + DWIN_ICON_Show(ICON,ICON_Control_0, 17, 246); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 61, 405, 271-183, 420, 58, 318); + else + DWIN_Frame_AreaCopy(1, 85, 423, 271-139, 479-45, 72-24, 318); + } +} + +void ICON_StartInfo(bool show) { + if (show) { + DWIN_ICON_Show(ICON,ICON_Info_1, 145, 246); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 91, 447, 271-153, 479-19, 186, 318); + else + DWIN_Frame_AreaCopy(1, 132, 451, 159, 479-13, 186, 318); + } + else { + DWIN_ICON_Show(ICON,ICON_Info_0, 145, 246); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 91, 405, 271-153, 420, 186, 318); + else + DWIN_Frame_AreaCopy(1, 132, 423, 159, 423+12, 186, 318); + } +} + +void ICON_Leveling(bool show) { + if (show) { + DWIN_ICON_Show(ICON,ICON_Leveling_1, 145, 246); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 211, 447, 238, 479-19, 186, 318); + else + DWIN_Frame_AreaCopy(1, 84, 437, 120, 449, 200-18, 318); + } + else { + DWIN_ICON_Show(ICON,ICON_Leveling_0, 145, 246); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 211, 405, 238, 420, 186, 318); + else + DWIN_Frame_AreaCopy(1, 84, 465, 120, 478, 200-18, 318); + } +} + +void ICON_Tune() { + if (select_print.now == 0) { + DWIN_ICON_Show(ICON,ICON_Setup_1, 8, 252); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 121, 447, 271-123, 479-21, 34, 325); + else + DWIN_Frame_AreaCopy(1, 1, 465, 271-237, 479-2, 48-17, 325); + } + else { + DWIN_ICON_Show(ICON,ICON_Setup_0, 8, 252); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 121, 405, 271-123, 420, 34, 325); + else + DWIN_Frame_AreaCopy(1, 1, 438, 271-239, 479-31, 48-17, 325); + } +} + +void ICON_Pause() { + if (select_print.now == 1) { + DWIN_ICON_Show(ICON,ICON_Pause_1, 96, 252); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 181, 447, 271-63, 479-20, 124, 325); + else + DWIN_Frame_AreaCopy(1, 177, 451, 271-55, 479-17, 136-20, 325); + } + else { + DWIN_ICON_Show(ICON,ICON_Pause_0, 96, 252); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 181, 405, 271-63, 420, 124, 325); + else + DWIN_Frame_AreaCopy(1, 177, 423, 271-56, 479-46, 136-20, 325); + } +} + +void ICON_Continue() { + if (select_print.now == 1) { + DWIN_ICON_Show(ICON,ICON_Continue_1, 96, 252); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 1, 447, 271-243, 479-19, 124, 325); + else + DWIN_Frame_AreaCopy(1, 1, 451, 271-239, 479-16, 136-15, 325); + } + else { + DWIN_ICON_Show(ICON,ICON_Continue_0, 96, 252); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 1, 405, 271-243, 420, 124, 325); + else + DWIN_Frame_AreaCopy(1, 1, 424, 271-240, 479-45, 136-15, 325); + } +} + +void ICON_Stop() { + if (select_print.now == 2) { + DWIN_ICON_Show(ICON,ICON_Stop_1, 184, 252); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 151, 447, 271-93, 479-20, 210, 325); + else + DWIN_Frame_AreaCopy(1, 218, 451, 271-22, 479-14, 224-15, 325); + } + else { + DWIN_ICON_Show(ICON,ICON_Stop_0, 184, 252); + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 151, 405, 271-93, 420, 210, 325); + else + DWIN_Frame_AreaCopy(1, 218, 423, 271-24, 479-43, 224-15, 325); + } +} + +inline void Clear_Title_Bar(void) { + DWIN_Draw_Rectangle(1, Background_blue, 0, 0, DWIN_WIDTH, 30); +} + +inline void Draw_Title(const char * const title) { + DWIN_Draw_String(false,false,HEADER_FONT,White,Background_blue, 14, 4, (char*)title); +} + +inline void Clear_Menu_Area(void) { + DWIN_Draw_Rectangle(1, Background_black, 0, 31, 272, 360); +} + +inline void Clear_Main_Window(void) { + Clear_Title_Bar(); + Clear_Menu_Area(); +} + +inline void Clear_Popup_Area(void) { + Clear_Title_Bar(); + DWIN_Draw_Rectangle(1, Background_black, 0, 31, 272, 480); +} + +void Draw_Popup_Bkgd_105(void) { + DWIN_Draw_Rectangle(1, Background_window, 14, 105, 271-13, 479-105); +} + +inline void Draw_More_Icon(const uint8_t line) { + DWIN_ICON_Show(ICON, ICON_More, 226, 46+line*MLINE); +} + +inline void Draw_Menu_Cursor(const uint8_t line) { + //DWIN_ICON_Show(ICON,ICON_Rectangle, 0, 31+line*MLINE); + DWIN_Draw_Rectangle(1, Rectangle_Color, 0, 31+line*MLINE, 14, 31+(line+1)*MLINE-2); +} + +inline void Erase_Menu_Cursor(const uint8_t line) { + DWIN_Draw_Rectangle(1, Background_black, 0, 31+line*MLINE, 14, 31+(line+1)*MLINE-2); +} + +inline void Move_Highlight(const int16_t from, const uint16_t newline) { + Erase_Menu_Cursor(newline - from); + Draw_Menu_Cursor(newline); +} + +inline void Add_Menu_Line() { + Move_Highlight(1, MROWS); + DWIN_Draw_Line(Line_Color, 16, 82+MROWS*MLINE, 256, 83+MROWS*MLINE); +} + +inline void Scroll_Menu(const uint8_t dir) { + DWIN_Frame_AreaMove(1, dir, MLINE, Background_black, 0, 31, 272, 349); + switch (dir) { + case DWIN_SCROLL_DOWN: Move_Highlight(-1, 0); break; + case DWIN_SCROLL_UP: Add_Menu_Line(); break; + } +} + +inline uint16_t nr_sd_menu_items() { + return card.get_num_Files() + !card.flag.workDirIsRoot; +} + +inline void Draw_Menu_Icon(const uint8_t line, const uint8_t icon) { + DWIN_ICON_Show(ICON, icon, 26, 46+line*MLINE); +} + +inline void Erase_Menu_Text(const uint8_t line) { + DWIN_Draw_Rectangle(1, Background_black, LBLX, 31+line*MLINE+4, 271, 28+(line+1)*MLINE-4); +} + +inline void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr) { + if (label) DWIN_Draw_String(false,false,font8x16,White,Background_black, LBLX, 48+line*MLINE, (char*)label); + if (icon) Draw_Menu_Icon(line, icon); + DWIN_Draw_Line(Line_Color, 16, 29+(line+1)*MLINE, 256, 30+(line+1)*MLINE); +} + +// The "Back" label is always on the first line +inline void Draw_Back_Label(void) { + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 129, 72, 271-115, 479-395, LBLX, MBASE(0)); + else + DWIN_Frame_AreaCopy(1, 226, 179, 271-15, 479-290, LBLX, MBASE(0)); +} + +// Draw "Back" line at the top +inline void Draw_Back_First(const bool is_sel=true) { + Draw_Menu_Line(0, ICON_Back); + Draw_Back_Label(); + if (is_sel) Draw_Menu_Cursor(0); +} + +// +// Draw Menus +// + +inline void draw_move_en(const uint16_t line) { + DWIN_Frame_AreaCopy(1, 69, 61, 271-169, 479-408, LBLX, line); // "Move" +} + +inline void Prepare_Item_Move(const uint8_t row) { + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 159, 70, 271-71, 479-395, LBLX, MBASE(row)); + else + draw_move_en(MBASE(row)); // "Move >" + Draw_Menu_Line(row, ICON_Axis); + Draw_More_Icon(row); +} + +inline void Prepare_Item_Disable(const uint8_t row) { + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 204, 70, 271-12, 479-397, LBLX, MBASE(row)); + else + DWIN_Frame_AreaCopy(1, 103, 59, 271-71, 479-405, LBLX, MBASE(row)); // "Disable Stepper" + Draw_Menu_Line(row, ICON_CloseMotor); +} + +inline void Prepare_Item_Home(const uint8_t row) { + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 0, 89, 271-230, 479-378, LBLX, MBASE(row)); + else + DWIN_Frame_AreaCopy(1, 202, 61, 271-0, 479-408, LBLX, MBASE(row)); // "Auto Home" + Draw_Menu_Line(row, ICON_Homing); +} + +inline void Prepare_Item_Offset(const uint8_t row) { + if (HMI_flag.language_flag) { + #if HAS_BED_PROBE + DWIN_Frame_AreaCopy(1, 174, 164, 271-48, 479-302, LBLX, MBASE(row)); + show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(row), probe.offset.z*100); + #else + DWIN_Frame_AreaCopy(1, 43, 89, 271-173, 479-378, LBLX, MBASE(row)); + #endif + } + else { + #if HAS_BED_PROBE + DWIN_Frame_AreaCopy(1, 93, 179, 271-130, 479-290, LBLX, MBASE(row)); // "Z-Offset" + show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(row), probe.offset.z*100); + #else + DWIN_Frame_AreaCopy(1, 1, 76, 271-165, 479-393, LBLX, MBASE(row)); // "..." + #endif + } + Draw_Menu_Line(row, ICON_SetHome); +} + +inline void Prepare_Item_PLA(const uint8_t row) { + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 100, 89, 271-93-27, 479-378, LBLX, MBASE(row)); + else { + DWIN_Frame_AreaCopy(1, 107, 76, 271-115, 479-393, LBLX, MBASE(row)); // "Preheat" + DWIN_Frame_AreaCopy(1, 157, 76, 181, 479-393, LBLX+49+3, MBASE(row)); // "PLA" + } + Draw_Menu_Line(row, ICON_PLAPreheat); +} + +inline void Prepare_Item_ABS(const uint8_t row) { + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 180, 89, 271-11-27, 479-379, LBLX, MBASE(row)); + else { + DWIN_Frame_AreaCopy(1, 107, 76, 271-115, 479-393, LBLX, MBASE(row)); // "Preheat" + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479-393, LBLX+49+3, MBASE(row)); // "ABS" + } + Draw_Menu_Line(row, ICON_ABSPreheat); +} + +inline void Prepare_Item_Cool(const uint8_t row) { + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 1, 104, 271-215, 479-362, LBLX, MBASE(row)); + else + DWIN_Frame_AreaCopy(1, 200, 76, 271-7, 479-393, LBLX, MBASE(row)); // "Cooldown" + Draw_Menu_Line(row, ICON_Cool); +} + +inline void Prepare_Item_Lang(const uint8_t row) { + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 239, 134, 271-5, 479-333, LBLX, MBASE(row)); + DWIN_Draw_String(false,false,font8x16,White,Background_black, 226, MBASE(row), (char*)"CN"); + } + else { + DWIN_Frame_AreaCopy(1, 0, 194, 271-150, 479-272, LBLX, MBASE(row)); // "Language selection" + DWIN_Draw_String(false,false,font8x16,White,Background_black, 226, MBASE(row), (char*)"EN"); + } + Draw_Menu_Icon(row, ICON_Language); +} + +inline void Draw_Prepare_Menu() { + Clear_Main_Window(); + + const int16_t scroll = MROWS-index_prepare; // Scrolled-up lines + #define PSCROL(L) (scroll + (L)) + #define PVISI(L) WITHIN(PSCROL(L), 0, MROWS) + + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 133, 1, 271-111, 479-465-1, 14, 8); // "Prepare" + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Prepare"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 178, 2, 271-42, 479-464-1, 14, 8); // "Prepare" + #endif + } + + if (PVISI(0)) Draw_Back_First(select_prepare.now == 0); // < Back + if (PVISI(1)) Prepare_Item_Move(PSCROL(1)); // Move > + if (PVISI(2)) Prepare_Item_Disable(PSCROL(2)); // Disable Stepper + if (PVISI(3)) Prepare_Item_Home(PSCROL(3)); // Auto Home + if (PVISI(4)) Prepare_Item_Offset(PSCROL(4)); // Z-Offset + if (PVISI(5)) Prepare_Item_PLA(PSCROL(5)); // Preheat PLA + if (PVISI(6)) Prepare_Item_ABS(PSCROL(6)); // Preheat ABS + if (PVISI(7)) Prepare_Item_Cool(PSCROL(7)); // Cooldown + if (PVISI(8)) Prepare_Item_Lang(PSCROL(8)); // Language CN/EN + + if (select_prepare.now) Draw_Menu_Cursor(PSCROL(select_prepare.now)); +} + +inline void Draw_Control_Menu() { + Clear_Main_Window(); + + const int16_t scroll = TERN(HAS_LEVELING, MROWS-index_control, 0); // Scrolled-up lines + + #define CSCROL(L) (scroll + (L)) + #define CLINE(L) MBASE(CSCROL(L)) + #define CVISI(L) WITHIN(CSCROL(L), 0, MROWS) + + if (CVISI(0)) Draw_Back_First(select_control.now == 0); // < Back + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 103, 1, 271-141, 479-465, 14, 8); + DWIN_Frame_AreaCopy(1, 57, 104, 271-187, 479-363, LBLX, CLINE(1)); // Temperature > + DWIN_Frame_AreaCopy(1, 87, 104, 271-157, 479-363, LBLX, CLINE(2)); // Motion > + DWIN_Frame_AreaCopy(1, 117, 104, 271- 99, 479-363, LBLX, CLINE(3)); // Store Config + DWIN_Frame_AreaCopy(1, 174, 103, 271- 42, 479-363, LBLX, CLINE(4)); // Read Config + DWIN_Frame_AreaCopy(1, 1, 118, 271-215, 479-348, LBLX, CLINE(5)); // Reset Config + + if (CVISI(6)) + DWIN_Frame_AreaCopy(1, 231, 104, 271- 13, 479-363, LBLX, CLINE(6)); // Info > + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Control"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 128, 2, 271-95, 479-467, 14, 8); + #endif + + DWIN_Frame_AreaCopy(1, 1, 89, 271-188, 479-377-1, LBLX, CLINE(1)); // Temperature > + DWIN_Frame_AreaCopy(1, 84, 89, 271-143, 479-380, LBLX, CLINE(2)); // Motion > + DWIN_Frame_AreaCopy(1, 131+17, 89, 271- 3, 479-377-1, LBLX, CLINE(3)); // "Store Configuration" + + DWIN_Frame_AreaCopy(1, 26, 104, 271-214, 479-365, LBLX, CLINE(4)); // "Read" + DWIN_Frame_AreaCopy(1, 131+51, 89, 271-3, 479-377-1, LBLX+31+3, CLINE(4)); // "Configuration" + + DWIN_Frame_AreaCopy(1, 59, 104, 271-178, 479-365, LBLX, CLINE(5)); // "Reset" + DWIN_Frame_AreaCopy(1, 131+51, 89, 271-3, 479-377-1, LBLX+34+3, CLINE(5)); // "Configuration" + + if (CVISI(6)) + DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(6)); // Info > + } + + if (select_control.now && CVISI(select_control.now)) + Draw_Menu_Cursor(CSCROL(select_control.now)); + + // Draw icons and lines + LOOP_L_N(i, 6) + if (CVISI(i + 1)) Draw_Menu_Line(CSCROL(i + 1), ICON_Temperature+i); + + Draw_More_Icon(CSCROL(1)); + Draw_More_Icon(CSCROL(2)); + if (CVISI(6)) Draw_More_Icon(CSCROL(6)); +} + +inline void Draw_Tune_Menu() { + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 73, 2, 271-171, 479-466, 14, 9); + + DWIN_Frame_AreaCopy(1, 116, 164, 271-100, 479-303, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 1, 134, 271-215, 479-333, LBLX, MBASE(2)); + DWIN_Frame_AreaCopy(1, 58, 134, 271-158, 479-333, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 115, 134, 271-101, 479-333, LBLX, MBASE(4)); + DWIN_Frame_AreaCopy(1, 174, 164, 271-48, 479-302, LBLX, MBASE(5)); + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Tune"); // TODO: GET_TEXT + #else + DWIN_Frame_AreaCopy(1, 94, 2, 271-145, 479-467, 14, 9); + #endif + DWIN_Frame_AreaCopy(1, 1, 179, 271-179, 479-287-2, LBLX, MBASE(1)); // print speed + DWIN_Frame_AreaCopy(1, 197, 104, 271-33, 479-365, LBLX, MBASE(2)); // Hotend... + DWIN_Frame_AreaCopy(1, 1, 89, 271-188, 479-377-1, LBLX+41+3, MBASE(2)); // ...Temperature + DWIN_Frame_AreaCopy(1, 240, 104, 271-7, 479-365, LBLX, MBASE(3)); // Bed... + DWIN_Frame_AreaCopy(1, 1, 89, 271-188, 479-377-1, LBLX+24+3, MBASE(3)); // ...Temperature + DWIN_Frame_AreaCopy(1, 0, 119, 271-207, 479-347, LBLX, MBASE(4)); // fan speed + DWIN_Frame_AreaCopy(1, 93, 179, 271-130, 479-290, LBLX, MBASE(5)); // Z-offset + } + + Draw_Back_First(select_tune.now == 0); + if (select_tune.now) Draw_Menu_Cursor(select_tune.now); + + Draw_Menu_Line(1, ICON_Speed); + Draw_Menu_Line(2, ICON_HotendTemp); + Draw_Menu_Line(3, ICON_BedTemp); + Draw_Menu_Line(4, ICON_FanSpeed); + Draw_Menu_Line(5, ICON_Zoffset); + + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(1), feedrate_percentage); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(4), thermalManager.fan_speed[0]); + show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(5), BABY_Z_VAR*100); +} + +inline void draw_max_en(const uint16_t line) { + DWIN_Frame_AreaCopy(1, 245, 119, 271-2, 479-350, LBLX, line); // "Max" +} +inline void draw_max_accel_en(const uint16_t line) { + draw_max_en(line); + DWIN_Frame_AreaCopy(1, 1, 135, 271-192, 479-334, LBLX+24+3, line); // "Acceleration" +} +inline void draw_speed_en(const uint16_t inset, const uint16_t line) { + DWIN_Frame_AreaCopy(1, 184, 119, 224, 479-347, LBLX+inset, line); // "Speed" +} +inline void draw_corner_en(const uint16_t line) { + DWIN_Frame_AreaCopy(1, 64, 119, 271-165, 479-350, LBLX+24+3, line); // "Corner" +} +inline void draw_steps_per_mm(const uint16_t line) { + DWIN_Frame_AreaCopy(1, 1, 151, 271-170, 479-318, LBLX, line); // "Steps-per-mm" +} +inline void say_x(const uint16_t inset, const uint16_t line) { + DWIN_Frame_AreaCopy(1, 95, 104, 271-169, 479-365, LBLX+inset, line); // "X" +} +inline void say_y(const uint16_t inset, const uint16_t line) { + DWIN_Frame_AreaCopy(1, 104, 104, 271-161, 479-365, LBLX+inset, line); // "Y" +} +inline void say_z(const uint16_t inset, const uint16_t line) { + DWIN_Frame_AreaCopy(1, 112, 104, 271-151, 479-365, LBLX+inset, line); // "Z" +} +inline void say_e(const uint16_t inset, const uint16_t line) { + DWIN_Frame_AreaCopy(1, 237, 119, 271-27, 479-350, LBLX+inset, line); // "E" +} + +inline void Draw_Motion_Menu() { + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 1, 16, 271-243, 479-451, 14, 8); + + DWIN_Frame_AreaCopy(1, 173, 133, 228, 479-332, LBLX, MBASE(1)); // max speed + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(2)); // max... + DWIN_Frame_AreaCopy(1, 28, 149, 271-202, 479-318, LBLX+27, MBASE(2)+1); // ...acceleration + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(3)); // max... + DWIN_Frame_AreaCopy(1, 1, 180, 271-243, 479-287, LBLX+27, MBASE(3)+1); // ... + DWIN_Frame_AreaCopy(1, 202, 133, 228, 479-332, LBLX+54, MBASE(3)); // ...jerk + DWIN_Frame_AreaCopy(1, 153, 148, 271-77, 479-318, LBLX, MBASE(4)); // flow ratio + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Motion"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 144, 16, 271-82, 479-453, 14, 8); + #endif + draw_max_en(MBASE(1)); draw_speed_en(24+3, MBASE(1)); // "Max Speed" + draw_max_accel_en(MBASE(2)); // "Max Acceleration" + draw_max_en(MBASE(3)); draw_corner_en(MBASE(3)); // "Max Corner" + draw_steps_per_mm(MBASE(4)); // "Steps-per-mm" + } + + Draw_Back_First(select_motion.now == 0); + if (select_motion.now) Draw_Menu_Cursor(select_motion.now); + + LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxSpeed+i); + + Draw_More_Icon(1); + Draw_More_Icon(2); + Draw_More_Icon(3); + Draw_More_Icon(4); +} + +// +// Draw Popup Windows +// + +void Popup_Window_Temperature(const bool toohigh) { + Clear_Popup_Area(); + Draw_Popup_Bkgd_105(); + if (toohigh) { + DWIN_ICON_Show(ICON, ICON_TempTooHigh, 102, 165); + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 103, 371, 237, 479-93, 52, 285); + DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285); + DWIN_Frame_AreaCopy(1, 189, 389, 271-0, 402, 95, 310); + } + else { + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 36, 300, (char*)"Nozzle or Bed temperature"); + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 92, 300, (char*)"is too high"); + } + } + else { + DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 165); + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 103, 371, 271-1, 479-93, 52, 285); + DWIN_Frame_AreaCopy(1, 189, 389, 271-0, 402, 95, 310); + } + else { + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 36, 300, (char*)"Nozzle or Bed temperature"); + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 92, 300, (char*)"is too low"); + } + } +} + +inline void Draw_Popup_Bkgd_60() { + DWIN_Draw_Rectangle(1, Background_window, 14, 60, 271-13, 330); +} + +void Popup_Window_ETempTooLow(void) { + Clear_Main_Window(); + Draw_Popup_Bkgd_60(); + DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 105); + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 103, 371, 136, 479-93, 69, 240); + DWIN_Frame_AreaCopy(1, 170, 371, 271-1, 479-93, 69+33, 240); + DWIN_ICON_Show(ICON, ICON_Confirm_C, 86, 280); + } + else { + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 20, 235, (char*)"Nozzle is too cold"); + DWIN_ICON_Show(ICON, ICON_Confirm_E, 86, 280); + } +} + +void Popup_Window_Resume(void) { + Clear_Popup_Area(); + Draw_Popup_Bkgd_105(); + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 160, 338, 271-36, 479-125, 98, 135); + DWIN_Frame_AreaCopy(1, 103, 321, 271-0, 479-144, 52, 192); + DWIN_ICON_Show(ICON, ICON_Continue_C, 26, 307); + DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 307); + } + else { + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 120, 115, (char*)"Tips"); + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 24, 192, (char*)"I see the file stopped"); + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 68, 212, (char*)"unexpectedly last time"); + DWIN_ICON_Show(ICON, ICON_Continue_E, 26, 307); + DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 307); + } +} + +void Popup_Window_Home(void) { + Clear_Main_Window(); + Draw_Popup_Bkgd_60(); + DWIN_ICON_Show(ICON, ICON_BLTouch, 101, 105); + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 0, 371, 33, 386, 85, 240); + DWIN_Frame_AreaCopy(1, 203, 286, 271, 302, 118, 240); + DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); + } + else { + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 80, 230, (char*)"Auto homing..."); + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 24, 260, (char*)"Please wait until completed"); + } +} + +void Popup_Window_Leveling(void) { + Clear_Main_Window(); + Draw_Popup_Bkgd_60(); + DWIN_ICON_Show(ICON, ICON_AutoLeveling, 101, 105); + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 0, 371, 100, 386, 84, 240); + DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); + } + else { + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 76, 230, (char*)"Auto leveling..."); + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 24, 260, (char*)"Please wait until completed"); + } +} + +void Draw_Select_Highlight(const bool sel) { + HMI_flag.select_flag = sel; + const uint16_t c1 = sel ? Select_Color : Background_window, + c2 = sel ? Background_window : Select_Color; + DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318); + DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319); + DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318); + DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319); +} + +void Popup_window_PauseOrStop(void) { + Clear_Main_Window(); + Draw_Popup_Bkgd_60(); + if (HMI_flag.language_flag) { + if (select_print.now == 1) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); + else if (select_print.now == 2) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150); + DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150); + DWIN_ICON_Show(ICON, ICON_Confirm_C, 26, 280); + DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 280); + } + else { + if (select_print.now == 1) DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 88, 150, (char*)"Pause print?"); + else if (select_print.now == 2) DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, 92, 150, (char*)"Stop print?"); + DWIN_ICON_Show(ICON, ICON_Confirm_E, 26, 280); + DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 280); + } + Draw_Select_Highlight(true); +} + +void Draw_Printing_Screen(void) { + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 30, 1, 271-200, 479-465, 14, 9); // Tune + DWIN_Frame_AreaCopy(1, 0, 72, 271-208, 479-393, 41, 188); // Pause + DWIN_Frame_AreaCopy(1, 65, 72, 271-143, 479-393, 176, 188); // Stop + } + else { + DWIN_Frame_AreaCopy(1, 40, 2, 271-179, 479-464-1, 14, 9); // Tune + DWIN_Frame_AreaCopy(1, 0, 44, 271-175, 479-420-1, 41, 188); // Pause + DWIN_Frame_AreaCopy(1, 98, 44, 271-119, 479-420-1, 176, 188); // Stop + } +} + +void Draw_Print_ProgressBar() { + DWIN_ICON_Show(ICON,ICON_Bar, 15, 93); + DWIN_Draw_Rectangle(1, BarFill_Color, 16+Percentrecord*240/100, 93, 256, 113); + DWIN_Draw_IntValue(true,true,0,font8x16,Percent_Color,Background_black, 2, 117, 133, Percentrecord); + DWIN_Draw_String(false,false,font8x16,Percent_Color,Background_black, 117+16, 133, (char*)"%"); +} + +void Draw_Print_ProgressElapsed() { + duration_t elapsed = print_job_timer.duration(); // print timer + DWIN_Draw_IntValue(true,true,1,font8x16,White,Background_black, 2, 42, 212, elapsed.value/3600); + DWIN_Draw_String(false,false,font8x16,White,Background_black, 42+16, 212, (char*)":"); + DWIN_Draw_IntValue(true,true,1,font8x16,White,Background_black, 2, 42+24, 212, (elapsed.value%3600)/60); +} + +void Draw_Print_ProgressRemain() { + DWIN_Draw_IntValue(true,true,1,font8x16,White,Background_black, 2, 176, 212, remain_time/3600); + DWIN_Draw_String(false,false,font8x16,White,Background_black, 176+16, 212, (char*)":"); + DWIN_Draw_IntValue(true,true,1,font8x16,White,Background_black, 2, 176+24, 212, (remain_time%3600)/60); +} + +void Goto_PrintProcess(void) { + checkkey = PrintProcess; + + Clear_Main_Window(); + Draw_Printing_Screen(); + + ICON_Tune(); + if (printingIsPaused()) ICON_Continue(); else ICON_Pause(); + ICON_Stop(); + + // Copy into filebuf string before entry + char * const name = card.longest_filename(); + DWIN_Draw_String(false,false,font8x16,White,Background_black, (DWIN_WIDTH-strlen(name)*MENU_CHR_W)/2, 60, name); + + DWIN_ICON_Show(ICON,ICON_PrintTime, 17, 193); + DWIN_ICON_Show(ICON,ICON_RemainTime, 150, 191); + + Draw_Print_ProgressBar(); + Draw_Print_ProgressElapsed(); + Draw_Print_ProgressRemain(); +} + +void Goto_MainMenu(void) { + checkkey = MainMenu; + + Clear_Main_Window(); + + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 2, 2, 271-244, 479-465, 14, 9); // "Home" + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Home"); // TODO: GET_TEXT + #else + DWIN_Frame_AreaCopy(1, 0, 2, 271-232, 479-467, 14, 9); + #endif + } + + DWIN_ICON_Show(ICON, ICON_LOGO, 71, 52); + + ICON_Print(); + ICON_Prepare(); + ICON_Control(); + TERN(HAS_LEVELING, ICON_Leveling, ICON_StartInfo)(select_page.now == 3); +} + +inline ENCODER_DiffState get_encoder_state() { + const millis_t ms = millis(); + if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; + const ENCODER_DiffState state = Encoder_ReceiveAnalyze(); + if (state != ENCODER_DIFF_NO) Encoder_ms = ms + Encoder_wait; + return state; +} + +void HMI_Move_X(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Move_X_scale += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Move_X_scale -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + checkkey = AxisMove; + EncoderRate.encoderRateEnabled = 0; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + if (!planner.is_full()) { + // Wait for planner moves to finish! + planner.synchronize(); + planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder); + } + DWIN_UpdateLCD(); + return; + } + if (HMI_ValueStruct.Move_X_scale < X_MIN_POS*MinUnitMult) HMI_ValueStruct.Move_X_scale = X_MIN_POS*MinUnitMult; + else if (HMI_ValueStruct.Move_X_scale > X_MAX_POS*MinUnitMult) HMI_ValueStruct.Move_X_scale = X_MAX_POS*MinUnitMult; + current_position[X_AXIS] = HMI_ValueStruct.Move_X_scale/10; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + DWIN_UpdateLCD(); + } +} + +void HMI_Move_Y(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Move_Y_scale += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Move_Y_scale -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + checkkey = AxisMove; + EncoderRate.encoderRateEnabled = 0; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + if (!planner.is_full()) { + // Wait for planner moves to finish! + planner.synchronize(); + planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder); + } + DWIN_UpdateLCD(); + return; + } + if (HMI_ValueStruct.Move_Y_scale < Y_MIN_POS*MinUnitMult) HMI_ValueStruct.Move_Y_scale = Y_MIN_POS*MinUnitMult; + else if (HMI_ValueStruct.Move_Y_scale > Y_MAX_POS*MinUnitMult) HMI_ValueStruct.Move_Y_scale = Y_MAX_POS*MinUnitMult; + current_position[Y_AXIS] = HMI_ValueStruct.Move_Y_scale/10; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + DWIN_UpdateLCD(); + } +} + +void HMI_Move_Z(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Move_Z_scale += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Move_Z_scale -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + checkkey = AxisMove; + EncoderRate.encoderRateEnabled = 0; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + if (!planner.is_full()) { + // Wait for planner moves to finish! + planner.synchronize(); + planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_Z), active_extruder); + } + DWIN_UpdateLCD(); + return; + } + if (HMI_ValueStruct.Move_Z_scale < Z_MIN_POS*MinUnitMult) + HMI_ValueStruct.Move_Z_scale = Z_MIN_POS*MinUnitMult; + else if (HMI_ValueStruct.Move_Z_scale > Z_MAX_POS*MinUnitMult) + HMI_ValueStruct.Move_Z_scale = Z_MAX_POS*MinUnitMult; + current_position[Z_AXIS] = HMI_ValueStruct.Move_Z_scale/10; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + DWIN_UpdateLCD(); + } +} + +void HMI_Move_E(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + checkkey = AxisMove; + EncoderRate.encoderRateEnabled = 0; + last_E_scale = HMI_ValueStruct.Move_E_scale; + show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + if (!planner.is_full()) { + planner.synchronize(); // Wait for planner moves to finish! + planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder); + } + DWIN_UpdateLCD(); + return; + } + if ((HMI_ValueStruct.Move_E_scale-last_E_scale) > EXTRUDE_MAXLENGTH*MinUnitMult) + HMI_ValueStruct.Move_E_scale = last_E_scale + EXTRUDE_MAXLENGTH*MinUnitMult; + else if ((last_E_scale-HMI_ValueStruct.Move_E_scale) > EXTRUDE_MAXLENGTH*MinUnitMult) + HMI_ValueStruct.Move_E_scale = last_E_scale - EXTRUDE_MAXLENGTH*MinUnitMult; + current_position.e = HMI_ValueStruct.Move_E_scale/10; + show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + DWIN_UpdateLCD(); + } +} + +void HMI_Zoffset(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + last_zoffset = zprobe_zoffset; + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.offset_value -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + EncoderRate.encoderRateEnabled = 0; + zprobe_zoffset = HMI_ValueStruct.offset_value / 100; + #if HAS_BED_PROBE + if (WITHIN(zprobe_zoffset - last_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) + probe.offset.z = zprobe_zoffset; + settings.save(); + #elif ENABLED(BABYSTEPPING) + babystep.add_mm(Z_AXIS, (zprobe_zoffset - last_zoffset)); + #else + UNUSED(zprobe_zoffset - last_zoffset); + #endif + + if (HMI_ValueStruct.show_mode == -4) { + checkkey = Prepare; + show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(4+MROWS-index_prepare), TERN(HAS_LEVELING, probe.offset.z*100, HMI_ValueStruct.offset_value)); + } + else { + checkkey = Tune; + show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(5+MROWS-index_tune), TERN(HAS_LEVELING, probe.offset.z*100, HMI_ValueStruct.offset_value)); + } + DWIN_UpdateLCD(); + return; + } + NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN)*100); + NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX)*100); + if (HMI_ValueStruct.show_mode == -4) + show_plus_or_minus(font8x16, Select_Color, 2, 2, 202, MBASE(4+MROWS-index_prepare), HMI_ValueStruct.offset_value); + else + show_plus_or_minus(font8x16, Select_Color, 2, 2, 202, MBASE(5+MROWS-index_tune), HMI_ValueStruct.offset_value); + DWIN_UpdateLCD(); + } +} + +void HMI_ETemp(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.E_Temp += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.E_Temp -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + EncoderRate.encoderRateEnabled = 0; + if (HMI_ValueStruct.show_mode == -1) { // temperature + checkkey = TemperatureID; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp); + } + else if (HMI_ValueStruct.show_mode == -2) { + checkkey = PLAPreheat; + HMI_ValueStruct.preheat_hotend_temp[0] = HMI_ValueStruct.E_Temp; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(1), HMI_ValueStruct.preheat_hotend_temp[0]); + return; + } + else if (HMI_ValueStruct.show_mode == -3) { + checkkey = ABSPreheat; + HMI_ValueStruct.preheat_hotend_temp[1] = HMI_ValueStruct.E_Temp; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(1), HMI_ValueStruct.preheat_hotend_temp[1]); + return; + } + else { // tune + checkkey = Tune; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2+MROWS-index_tune), HMI_ValueStruct.E_Temp); + } + thermalManager.setTargetHotend(HMI_ValueStruct.E_Temp, 0); + return; + } + // E_Temp limit + NOMORE(HMI_ValueStruct.E_Temp, max_E_Temp); + NOLESS(HMI_ValueStruct.E_Temp, min_E_Temp); + // E_Temp value + if (HMI_ValueStruct.show_mode >= 0) // tune + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(2+MROWS-index_tune), HMI_ValueStruct.E_Temp); + else // other page + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp); + } +} + +void HMI_BedTemp(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Bed_Temp += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Bed_Temp -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + EncoderRate.encoderRateEnabled = 0; + if (HMI_ValueStruct.show_mode == -1) { + checkkey = TemperatureID; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp); + } + else if (HMI_ValueStruct.show_mode == -2) { + checkkey = PLAPreheat; + HMI_ValueStruct.preheat_bed_temp[0] = HMI_ValueStruct.Bed_Temp; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2), HMI_ValueStruct.preheat_bed_temp[0]); + return; + } + else if (HMI_ValueStruct.show_mode == -3) { + checkkey = ABSPreheat; + HMI_ValueStruct.preheat_bed_temp[1] = HMI_ValueStruct.Bed_Temp; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2), HMI_ValueStruct.preheat_bed_temp[1]); + return; + } + else { + checkkey = Tune; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3+MROWS-index_tune), HMI_ValueStruct.Bed_Temp); + } + thermalManager.setTargetBed(HMI_ValueStruct.Bed_Temp); + return; + } + //Bed_Temp limit + NOMORE(HMI_ValueStruct.Bed_Temp, max_Bed_Temp); + NOLESS(HMI_ValueStruct.Bed_Temp, min_Bed_Temp); + //Bed_Temp value + if (HMI_ValueStruct.show_mode >= 0) // tune page + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(3+MROWS-index_tune), HMI_ValueStruct.Bed_Temp); + else // other page + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp); + } +} + +void HMI_FanSpeed(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Fan_speed += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Fan_speed -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + EncoderRate.encoderRateEnabled = 0; + if (HMI_ValueStruct.show_mode == -1) { + checkkey = TemperatureID; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed); + } + else if (HMI_ValueStruct.show_mode == -2) { + checkkey = PLAPreheat; + HMI_ValueStruct.preheat_fan_speed[0] = HMI_ValueStruct.Fan_speed; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3), HMI_ValueStruct.preheat_fan_speed[0]); + return; + } + else if (HMI_ValueStruct.show_mode == -3) { + checkkey = ABSPreheat; + HMI_ValueStruct.preheat_fan_speed[1] = HMI_ValueStruct.Fan_speed; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3), HMI_ValueStruct.preheat_fan_speed[1]); + return; + } + else { + checkkey = Tune; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(4+MROWS-index_tune), HMI_ValueStruct.Fan_speed); + } + thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed); + return; + } + //Fan_speed limit + NOMORE(HMI_ValueStruct.Fan_speed, FanOn); + NOLESS(HMI_ValueStruct.Fan_speed, FanOff); + // Fan_speed value + if (HMI_ValueStruct.show_mode >= 0) // tune page + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(4+MROWS-index_tune), HMI_ValueStruct.Fan_speed); + else // other page + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed); + } +} + +void HMI_PrintSpeed(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.print_speed += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.print_speed -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + checkkey = Tune; + EncoderRate.encoderRateEnabled = 0; + feedrate_percentage = HMI_ValueStruct.print_speed; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(1+MROWS-index_tune), HMI_ValueStruct.print_speed); + return; + } + // print_speed limit + NOMORE(HMI_ValueStruct.print_speed, max_print_speed); + NOLESS(HMI_ValueStruct.print_speed, min_print_speed); + // print_speed value + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(1+MROWS-index_tune), HMI_ValueStruct.print_speed); + } +} + +void HMI_MaxFeedspeedXYZE(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Max_Feedspeed += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Max_Feedspeed -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + checkkey = MaxSpeed; + EncoderRate.encoderRateEnabled = 0; + if (HMI_flag.feedspeed_flag == X_AXIS) planner.set_max_feedrate(X_AXIS, HMI_ValueStruct.Max_Feedspeed); + else if (HMI_flag.feedspeed_flag == Y_AXIS) planner.set_max_feedrate(Y_AXIS, HMI_ValueStruct.Max_Feedspeed); + else if (HMI_flag.feedspeed_flag == Z_AXIS) planner.set_max_feedrate(Z_AXIS, HMI_ValueStruct.Max_Feedspeed); + else if (HMI_flag.feedspeed_flag == E_AXIS) planner.set_max_feedrate(E_AXIS, HMI_ValueStruct.Max_Feedspeed); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); + return; + } + //MaxFeedspeed limit + if (HMI_flag.feedspeed_flag == X_AXIS) {if (HMI_ValueStruct.Max_Feedspeed > default_max_feedrate[X_AXIS]*2) HMI_ValueStruct.Max_Feedspeed = default_max_feedrate[X_AXIS]*2;} + else if (HMI_flag.feedspeed_flag == Y_AXIS) {if (HMI_ValueStruct.Max_Feedspeed > default_max_feedrate[Y_AXIS]*2) HMI_ValueStruct.Max_Feedspeed = default_max_feedrate[Y_AXIS]*2;} + else if (HMI_flag.feedspeed_flag == Z_AXIS) {if (HMI_ValueStruct.Max_Feedspeed > default_max_feedrate[Z_AXIS]*2) HMI_ValueStruct.Max_Feedspeed = default_max_feedrate[Z_AXIS]*2;} + else if (HMI_flag.feedspeed_flag == E_AXIS) {if (HMI_ValueStruct.Max_Feedspeed > default_max_feedrate[E_AXIS]*2) HMI_ValueStruct.Max_Feedspeed = default_max_feedrate[E_AXIS]*2;} + if (HMI_ValueStruct.Max_Feedspeed < min_MaxFeedspeed) HMI_ValueStruct.Max_Feedspeed = min_MaxFeedspeed; + //MaxFeedspeed value + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); + } +} + +void HMI_MaxAccelerationXYZE(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) HMI_ValueStruct.Max_Acceleration += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) HMI_ValueStruct.Max_Acceleration -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + checkkey = MaxAcceleration; + EncoderRate.encoderRateEnabled = 0; + if (HMI_flag.acc_flag == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration); + else if (HMI_flag.acc_flag == Y_AXIS) planner.set_max_acceleration(Y_AXIS, HMI_ValueStruct.Max_Acceleration); + else if (HMI_flag.acc_flag == Z_AXIS) planner.set_max_acceleration(Z_AXIS, HMI_ValueStruct.Max_Acceleration); + else if (HMI_flag.acc_flag == E_AXIS) planner.set_max_acceleration(E_AXIS, HMI_ValueStruct.Max_Acceleration); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); + return; + } + // MaxAcceleration limit + if (HMI_flag.acc_flag == X_AXIS) {if (HMI_ValueStruct.Max_Acceleration > default_max_acceleration[X_AXIS]*2) HMI_ValueStruct.Max_Acceleration = default_max_acceleration[X_AXIS]*2;} + else if (HMI_flag.acc_flag == Y_AXIS) {if (HMI_ValueStruct.Max_Acceleration > default_max_acceleration[Y_AXIS]*2) HMI_ValueStruct.Max_Acceleration = default_max_acceleration[Y_AXIS]*2;} + else if (HMI_flag.acc_flag == Z_AXIS) {if (HMI_ValueStruct.Max_Acceleration > default_max_acceleration[Z_AXIS]*2) HMI_ValueStruct.Max_Acceleration = default_max_acceleration[Z_AXIS]*2;} + else if (HMI_flag.acc_flag == E_AXIS) {if (HMI_ValueStruct.Max_Acceleration > default_max_acceleration[E_AXIS]*2) HMI_ValueStruct.Max_Acceleration = default_max_acceleration[E_AXIS]*2;} + if (HMI_ValueStruct.Max_Acceleration < min_MaxAcceleration) HMI_ValueStruct.Max_Acceleration = min_MaxAcceleration; + // MaxAcceleration value + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); + } +} + +void HMI_MaxCornerXYZE(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Max_Corner += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Max_Corner -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + checkkey = MaxCorner; + EncoderRate.encoderRateEnabled = 0; + if (HMI_flag.corner_flag == X_AXIS) planner.set_max_jerk(X_AXIS, HMI_ValueStruct.Max_Corner/10); + else if (HMI_flag.corner_flag == Y_AXIS) planner.set_max_jerk(Y_AXIS, HMI_ValueStruct.Max_Corner/10); + else if (HMI_flag.corner_flag == Z_AXIS) planner.set_max_jerk(Z_AXIS, HMI_ValueStruct.Max_Corner/10); + else if (HMI_flag.corner_flag == E_AXIS) planner.set_max_jerk(E_AXIS, HMI_ValueStruct.Max_Corner/10); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(select_corner.now), HMI_ValueStruct.Max_Corner); + return; + } + //MaxCorner limit + if (HMI_flag.corner_flag == X_AXIS) {if (HMI_ValueStruct.Max_Corner > default_max_jerk[X_AXIS]*2*MinUnitMult) HMI_ValueStruct.Max_Corner = default_max_jerk[X_AXIS]*2*MinUnitMult;} + else if (HMI_flag.corner_flag == Y_AXIS) {if (HMI_ValueStruct.Max_Corner > default_max_jerk[Y_AXIS]*2*MinUnitMult) HMI_ValueStruct.Max_Corner = default_max_jerk[Y_AXIS]*2*MinUnitMult;} + else if (HMI_flag.corner_flag == Z_AXIS) {if (HMI_ValueStruct.Max_Corner > default_max_jerk[Z_AXIS]*2*MinUnitMult) HMI_ValueStruct.Max_Corner = default_max_jerk[Z_AXIS]*2*MinUnitMult;} + else if (HMI_flag.corner_flag == E_AXIS) {if (HMI_ValueStruct.Max_Corner > default_max_jerk[E_AXIS]*2*MinUnitMult) HMI_ValueStruct.Max_Corner = default_max_jerk[E_AXIS]*2*MinUnitMult;} + if (HMI_ValueStruct.Max_Corner < min_MaxCorner*MinUnitMult) HMI_ValueStruct.Max_Corner = min_MaxCorner*MinUnitMult; + //MaxCorner value + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_corner.now), HMI_ValueStruct.Max_Corner); + } +} + +void HMI_StepXYZE(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Max_Step += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Max_Step -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + checkkey = Step; + EncoderRate.encoderRateEnabled = 0; + if (HMI_flag.step_flag == X_AXIS) planner.settings.axis_steps_per_mm[X_AXIS] = HMI_ValueStruct.Max_Step/10; + else if (HMI_flag.step_flag == Y_AXIS) planner.settings.axis_steps_per_mm[Y_AXIS] = HMI_ValueStruct.Max_Step/10; + else if (HMI_flag.step_flag == Z_AXIS) planner.settings.axis_steps_per_mm[Z_AXIS] = HMI_ValueStruct.Max_Step/10; + else if (HMI_flag.step_flag == E_AXIS) planner.settings.axis_steps_per_mm[E_AXIS] = HMI_ValueStruct.Max_Step/10; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + return; + } + //Step limit + if (HMI_flag.step_flag == X_AXIS) {if (HMI_ValueStruct.Max_Step > default_axis_steps_per_unit[X_AXIS]*2*MinUnitMult) HMI_ValueStruct.Max_Step = default_axis_steps_per_unit[X_AXIS]*2*MinUnitMult;} + else if (HMI_flag.step_flag == Y_AXIS) {if (HMI_ValueStruct.Max_Step > default_axis_steps_per_unit[Y_AXIS]*2*MinUnitMult) HMI_ValueStruct.Max_Step = default_axis_steps_per_unit[Y_AXIS]*2*MinUnitMult;} + else if (HMI_flag.step_flag == Z_AXIS) {if (HMI_ValueStruct.Max_Step > default_axis_steps_per_unit[Z_AXIS]*2*MinUnitMult) HMI_ValueStruct.Max_Step = default_axis_steps_per_unit[Z_AXIS]*2*MinUnitMult;} + else if (HMI_flag.step_flag == E_AXIS) {if (HMI_ValueStruct.Max_Step > default_axis_steps_per_unit[E_AXIS]*2*MinUnitMult) HMI_ValueStruct.Max_Step = default_axis_steps_per_unit[E_AXIS]*2*MinUnitMult;} + if (HMI_ValueStruct.Max_Step < min_Step) HMI_ValueStruct.Max_Step = min_Step; + //Step value + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + } +} + +void update_variable(void) { + /* Tune page temperature update */ + if (checkkey == Tune) { + if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2+MROWS-index_tune), thermalManager.temp_hotend[0].target); + } + if (last_temp_bed_target != thermalManager.temp_bed.target) { + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3+MROWS-index_tune), thermalManager.temp_bed.target); + } + if (last_fan_speed != thermalManager.fan_speed[0]) { + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(4+MROWS-index_tune), thermalManager.fan_speed[0]); + last_fan_speed = thermalManager.fan_speed[0]; + } + } + + /* Temperature page temperature update */ + if (checkkey == TemperatureID) { + if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); + } + if (last_temp_bed_target != thermalManager.temp_bed.target) { + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2), thermalManager.temp_bed.target); + } + if (last_fan_speed != thermalManager.fan_speed[0]) { + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3), thermalManager.fan_speed[0]); + last_fan_speed = thermalManager.fan_speed[0]; + } + } + + /* Bottom temperature update */ + if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) { + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); + last_temp_hotend_current = thermalManager.temp_hotend[0].celsius; + } + if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 33+4*STAT_CHR_W+6, 382, thermalManager.temp_hotend[0].target); + last_temp_hotend_target = thermalManager.temp_hotend[0].target; + } + if (last_temp_bed_current != thermalManager.temp_bed.celsius) { + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); + last_temp_bed_current = thermalManager.temp_bed.celsius; + } + if (last_temp_bed_target != thermalManager.temp_bed.target) { + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 178+4*STAT_CHR_W+6, 382, thermalManager.temp_bed.target); + last_temp_bed_target = thermalManager.temp_bed.target; + } + if (last_speed != feedrate_percentage) { + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 33+2*STAT_CHR_W, 429, feedrate_percentage); + last_speed = feedrate_percentage; + } + #if HAS_LEVELING + if (last_probe_zoffset != probe.offset.z) { + show_plus_or_minus(STAT_FONT, Background_black, 2, 2, 178+STAT_CHR_W, 429, probe.offset.z*100); + last_probe_zoffset = probe.offset.z; + } + #else + if (last_zoffset != zprobe_zoffset) { + show_plus_or_minus(STAT_FONT, Background_black, 2, 2, 178+STAT_CHR_W, 429, zprobe_zoffset*100); + last_zoffset = zprobe_zoffset; + } + #endif +} + +/** + * Read and cache the working directory. + * + * TODO: New code can follow the pattern of menu_media.cpp + * and rely on Marlin caching for performance. No need to + * cache files here. + * + */ + +#ifndef strcasecmp_P +#define strcasecmp_P(a, b) strcasecmp((a), (b)) +#endif + +inline void make_name_without_ext(char *dst, char *src, int maxlen=MENU_CHAR_LIMIT) { + char * const name = card.longest_filename(); + size_t pos = strlen(name); // index of ending nul + + // For files, remove the extension + // which may be .gcode, .gco, or .g + if (!card.flag.filenameIsDir) + while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0) + + int len = pos; // nul or '.' + if (len > maxlen) { // Keep the name short + pos = len = maxlen; // move nul down + dst[--pos] = '.'; // insert dots + dst[--pos] = '.'; + dst[--pos] = '.'; + } + + dst[len] = '\0'; // end it + + // Copy down to 0 + while (pos--) dst[pos] = src[pos]; +} + +inline void HMI_SDCardInit(void) { card.cdroot(); } + +void MarlinUI::refresh() { + // The card was mounted or unmounted + // or some other status change occurred + //DWIN_lcd_sd_status = false; // On next DWIN_Update + //HMI_SDCardUpdate(); +} + +#define ICON_Folder ICON_More + +char shift_name[LONG_FILENAME_LENGTH + 1]; +int8_t shift_amt; // = 0 +millis_t shift_ms; // = 0 + +// Init the shift name based on the highlighted item +inline void Init_Shift_Name() { + const bool is_subdir = !card.flag.workDirIsRoot; + const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".." + if (WITHIN(filenum, 0, card.get_num_Files() - 1)) { + card.getfilename_sorted(filenum); + char * const name = card.longest_filename(); + make_name_without_ext(shift_name, name, 100); + } +} + +inline void Init_SDItem_Shift() { + shift_amt = 0; + shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT + ? millis() + 750UL : 0; +} + +/** + * Display an SD item, adding a CDUP for subfolders. + */ +inline void Draw_SDItem(const uint16_t item, int16_t row=-1) { + if (row < 0) row = item + 1 + MROWS-index_file; + const bool is_subdir = !card.flag.workDirIsRoot; + if (is_subdir && item == 0) { + Draw_Menu_Line(row, ICON_Folder, (char*)".."); + return; + } + + card.getfilename_sorted(item - is_subdir); + char * const name = card.longest_filename(); + + // Init the current selected name + // This is used during scroll drawing + if (item == select_file.now - 1) { + make_name_without_ext(shift_name, name, 100); + Init_SDItem_Shift(); + } + + char str[strlen(name) + 1]; + + make_name_without_ext(str, name); + + Draw_Menu_Line(row, card.flag.filenameIsDir ? ICON_Folder : ICON_File, str); +} + +inline void Draw_SDItem_Shifted(int8_t &shift) { + // Limit to the number of chars past the cutoff + const size_t len = strlen(shift_name); + NOMORE(shift, _MAX((signed)len - MENU_CHAR_LIMIT, 0)); + + // Shorten to the available space + const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT); + + const char c = shift_name[lastchar]; + shift_name[lastchar] = '\0'; + + const uint8_t row = select_file.now + MROWS-index_file; // skip "Back" and scroll + Erase_Menu_Text(row); + Draw_Menu_Line(row, 0, &shift_name[shift]); + + shift_name[lastchar] = c; +} + +// Redraw the first set of SD Files +inline void Redraw_SD_List() { + select_file.reset(); + index_file = MROWS; + + Clear_Menu_Area(); // Leave title bar unchanged + + Draw_Back_First(); + + // As many files as will fit + LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS)) + Draw_SDItem(i, i + 1); + + Init_SDItem_Shift(); +} + +inline void SDCard_Up(void) { + card.cdup(); + Redraw_SD_List(); + DWIN_lcd_sd_status = false; // On next DWIN_Update +} + +inline void SDCard_Folder(char * const dirname) { + card.cd(dirname); + Redraw_SD_List(); + DWIN_lcd_sd_status = false; // On next DWIN_Update +} + +// +// Watch for media mount / unmount +// +void HMI_SDCardUpdate(void) { + if (HMI_flag.home_flag) return; + if (DWIN_lcd_sd_status != card.isMounted()) { + DWIN_lcd_sd_status = card.isMounted(); + //SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", int(DWIN_lcd_sd_status)); + if (card.isMounted()) { + if (checkkey == SelectFile) + Redraw_SD_List(); + } + else { + // clean file icon + if (checkkey == SelectFile) + Redraw_SD_List(); + else if (checkkey == PrintProcess || checkkey == Tune || printingIsActive()) { + // TODO: Move card removed abort handling + // to CardReader::manage_media. + card.flag.abort_sd_printing = true; + wait_for_heatup = false; + abort_flag = true; + } + } + DWIN_UpdateLCD(); + } +} + +/* Start */ +void HMI_StartFrame(const bool with_update) { + Goto_MainMenu(); + + DWIN_Draw_Rectangle(1, Background_black, 0, 360, 272, 479); + + DWIN_ICON_Show(ICON,ICON_HotendTemp, 13, 381); + #if HOTENDS > 1 + //DWIN_ICON_Show(ICON,ICON_HotendTemp, 13, 381); + #endif + DWIN_ICON_Show(ICON,ICON_BedTemp, 158, 381); + DWIN_ICON_Show(ICON,ICON_Speed, 13, 429); + DWIN_ICON_Show(ICON,ICON_Zoffset, 158, 428); + + // Draw initial Status Area + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 33+4*STAT_CHR_W+6, 382, thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 178+4*STAT_CHR_W+6, 382, thermalManager.temp_bed.target); + + DWIN_Draw_IntValue(true,true,0,STAT_FONT,White,Background_black, 3, 33+2*STAT_CHR_W, 429, feedrate_percentage); + DWIN_Draw_String(false,false,STAT_FONT,White,Background_black, 33+(2+3)*STAT_CHR_W+2, 429, (char*)"%"); + + show_plus_or_minus(STAT_FONT, Background_black, 2, 2, 178, 429, BABY_Z_VAR * 100); + DWIN_Draw_String(false,false,STAT_FONT,White,Background_black, 33+3*STAT_CHR_W+5, 383, (char*)"/"); + DWIN_Draw_String(false,false,STAT_FONT,White,Background_black, 178+3*STAT_CHR_W+5, 383, (char*)"/"); + + if (with_update) { + DWIN_UpdateLCD(); + delay(5); + } +} + +#ifndef MACHINE_SIZE + #define MACHINE_SIZE "220x220x250" +#endif +#ifndef CORP_WEBSITE_C + #define CORP_WEBSITE_C "www.cxsw3d.com" +#endif +#ifndef CORP_WEBSITE_E + #define CORP_WEBSITE_E "www.creality.com" +#endif + +inline void Draw_Info_Menu() { + Clear_Main_Window(); + + DWIN_Draw_String(false,false,font8x16,White,Background_black, (DWIN_WIDTH-strlen(MACHINE_SIZE)*MENU_CHR_W)/2, 122, (char*)MACHINE_SIZE); + DWIN_Draw_String(false,false,font8x16,White,Background_black, (DWIN_WIDTH-strlen(SHORT_BUILD_VERSION)*MENU_CHR_W)/2, 195, (char*)SHORT_BUILD_VERSION); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 30, 17, 271-214, 479-450, 14, 8); + + DWIN_Frame_AreaCopy(1, 197, 149, 271-19, 479-318, 108, 102); + DWIN_Frame_AreaCopy(1, 1, 164, 271-215, 479-303, 108, 175); + DWIN_Frame_AreaCopy(1, 58, 164, 271-158, 479-303, 105, 248); + DWIN_Draw_String(false,false,font8x16,White,Background_black, (DWIN_WIDTH-strlen(CORP_WEBSITE_C)*MENU_CHR_W)/2, 268, (char*)CORP_WEBSITE_C); + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Info"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 190, 16, 271-56, 479-453, 14, 8); + #endif + + DWIN_Frame_AreaCopy(1, 120, 150, 146, 479-318, 124, 102); + DWIN_Frame_AreaCopy(1, 146, 151, 271-17, 479-318, 82, 175); + DWIN_Frame_AreaCopy(1, 0, 165, 271-177, 479-304, 89, 248); + DWIN_Draw_String(false,false,font8x16,White,Background_black, (DWIN_WIDTH-strlen(CORP_WEBSITE_E)*MENU_CHR_W)/2, 268, (char*)CORP_WEBSITE_E); + } + + Draw_Back_First(); + LOOP_L_N(i, 3) { + DWIN_ICON_Show(ICON,ICON_PrintSize+i, 26, 99+i*73); + DWIN_Draw_Line(Line_Color, 16, MBASE(2)+i*73, 256, 156+i*73); + } +} + +inline void Draw_Print_File_Menu() { + Clear_Title_Bar(); + + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 0, 31, 271-216, 479-435, 14, 8); + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Print file"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 52, 31, 271-134, 479-438, 14, 8); // "Print file" + #endif + } + + Redraw_SD_List(); +} + +/* Main Process */ +void HMI_MainMenu(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_page.inc(3)) { + switch (select_page.now) { + case 0: ICON_Print(); break; + case 1: ICON_Print(); ICON_Prepare(); break; + case 2: ICON_Prepare(); ICON_Control(); break; + case 3: ICON_Control(); TERN(HAS_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break; + } + } + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_page.dec()) { + switch (select_page.now) { + case 0: ICON_Print(); ICON_Prepare(); break; + case 1: ICON_Prepare(); ICON_Control(); break; + case 2: ICON_Control(); TERN(HAS_LEVELING, ICON_Leveling, ICON_StartInfo)(0); break; + case 3: TERN(HAS_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break; + } + } + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_page.now) { + /* Print File */ + case 0: + checkkey = SelectFile; + Draw_Print_File_Menu(); + break; + + /* Prepare */ + case 1: + checkkey = Prepare; + select_prepare.reset(); + index_prepare = MROWS; + Draw_Prepare_Menu(); + break; + + /* Control */ + case 2: + checkkey = Control; + select_control.reset(); + index_control = MROWS; + Draw_Control_Menu(); + break; + + /* Leveling */ + case 3: + #if HAS_LEVELING + checkkey = Leveling; + HMI_Leveling(); + #else + checkkey = Info; + Draw_Info_Menu(); + #endif + break; + } + } + DWIN_UpdateLCD(); +} + +/* Select (and Print) File */ +void HMI_SelectFile(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + + const uint16_t hasUpDir = !card.flag.workDirIsRoot; + + if (encoder_diffState == ENCODER_DIFF_NO) { + if (shift_ms && select_file.now >= 1 + hasUpDir) { + // Scroll selected filename every second + const millis_t ms = millis(); + if (ELAPSED(ms, shift_ms)) { + const bool was_reset = shift_amt < 0; + shift_ms = ms + 375UL + was_reset * 250UL; // ms per character + int8_t shift_new = shift_amt + 1; // Try to shift by... + Draw_SDItem_Shifted(shift_new); // Draw the item + if (!was_reset && shift_new == 0) // Was it limited to 0? + shift_ms = 0; // No scrolling needed + else if (shift_new == shift_amt) // Scroll reached the end + shift_new = -1; // Reset + shift_amt = shift_new; // Set new scroll + } + } + return; + } + + // First pause is long. Easy. + // On reset, long pause must be after 0. + + const uint16_t fullCnt = nr_sd_menu_items(); + + if (encoder_diffState == ENCODER_DIFF_CW && fullCnt) { + if (select_file.inc(fullCnt)) { + const uint8_t itemnum = select_file.now - 1; // -1 for "Back" + if (shift_ms) { // If line was shifted + Erase_Menu_Text(select_file.now - 1 + MROWS-index_file); // Erase and + Draw_SDItem(itemnum - 1); // redraw + } + if (select_file.now > MROWS && select_file.now > index_file) { // Cursor past the bottom + index_file = select_file.now; // New bottom line + Scroll_Menu(DWIN_SCROLL_UP); + Draw_SDItem(itemnum, MROWS); // Draw and init the shift name + } + else { + Move_Highlight(1, select_file.now+MROWS-index_file); // Just move highlight + Init_Shift_Name(); // ...and init the shift name + } + Init_SDItem_Shift(); + } + } + else if (encoder_diffState == ENCODER_DIFF_CCW && fullCnt) { + if (select_file.dec()) { + const uint8_t itemnum = select_file.now - 1; // -1 for "Back" + if (shift_ms) { // If line was shifted + Erase_Menu_Text(select_file.now + 1 + MROWS-index_file); // Erase and + Draw_SDItem(itemnum + 1); // redraw + } + if (select_file.now < index_file - MROWS) { // Cursor past the top + index_file--; // New bottom line + Scroll_Menu(DWIN_SCROLL_DOWN); + if (index_file == MROWS) { + Draw_Back_First(); + shift_ms = 0; + } + else + Draw_SDItem(itemnum, 0); // Draw the item (and init shift name) + } + else { + Move_Highlight(-1, select_file.now+MROWS-index_file); // Just move highlight + Init_Shift_Name(); // ...and init the shift name + } + Init_SDItem_Shift(); // Reset left. Init timer. + } + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (select_file.now == 0) { + /* back */ + select_page.set(0); + Goto_MainMenu(); + } + else if (hasUpDir && select_file.now == 1) { + /* CDUP */ + SDCard_Up(); + goto HMI_SelectFileExit; + } + else { + const uint16_t filenum = select_file.now - 1 - hasUpDir; + card.getfilename_sorted(filenum); + + // Enter that folder! + if (card.flag.filenameIsDir) { + SDCard_Folder(card.filename); + goto HMI_SelectFileExit; + } + + // Reset highlight for next entry + select_print.reset(); + select_file.reset(); + + // Start choice and print SD file + HMI_flag.heat_flag = 1; + HMI_flag.print_finish = 0; + HMI_ValueStruct.show_mode = 0; + + card.openAndPrintFile(card.filename); + + #if FAN_COUNT > 0 + // All fans on for Ender 3 v2 ? + // The slicer should manage this for us. + //for (uint8_t i = 0; i < FAN_COUNT; i++) + // thermalManager.fan_speed[i] = FanOn; + #endif + + Goto_PrintProcess(); + } + } + HMI_SelectFileExit: + DWIN_UpdateLCD(); +} + +/* Printing */ +void HMI_Printing(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + if (HMI_flag.confirm_flag) { + if (encoder_diffState == ENCODER_DIFF_ENTER) { + HMI_flag.confirm_flag = 0; + abort_flag = 1; + } + return; + } + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_print.inc(2)) { + switch (select_print.now) { + case 0: ICON_Tune(); break; + case 1: + ICON_Tune(); + if (printingIsPaused()) ICON_Continue(); else ICON_Pause(); + break; + case 2: + if (printingIsPaused()) ICON_Continue(); else ICON_Pause(); + ICON_Stop(); + break; + } + } + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_print.dec()) { + switch (select_print.now) { + case 0: + ICON_Tune(); + if (printingIsPaused()) ICON_Continue(); else ICON_Pause(); + break; + case 1: + if (printingIsPaused()) ICON_Continue(); else ICON_Pause(); + ICON_Stop(); + break; + case 2: ICON_Stop(); break; + } + } + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_print.now) { + case 0: // setting + checkkey = Tune; + HMI_ValueStruct.show_mode = 0; + select_tune.reset(); + index_tune = 5; + Draw_Tune_Menu(); + break; + case 1: // pause + /* pause */ + if (HMI_flag.pause_flag) { + ICON_Pause(); + + char cmd[40]; + cmd[0] = '\0'; + + #if ENABLED(PAUSE_HEAT) + if (tempbed) sprintf_P(cmd, PSTR("M190 S%i\n"), tempbed); + if (temphot) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), temphot); + #endif + + strcat_P(cmd, PSTR("M24")); + queue.inject(cmd); + } + else { + HMI_flag.select_flag = 1; + checkkey = Print_window; + Popup_window_PauseOrStop(); + } + break; + + case 2: // stop + /* stop */ + HMI_flag.select_flag = 1; + checkkey = Print_window; + Popup_window_PauseOrStop(); + break; + + default: + break; + } + } + DWIN_UpdateLCD(); +} + +/* pause and stop window */ +void HMI_PauseOrStop(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + if (encoder_diffState == ENCODER_DIFF_CW) + Draw_Select_Highlight(false); + else if (encoder_diffState == ENCODER_DIFF_CCW) + Draw_Select_Highlight(true); + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (select_print.now == 1) { // pause window + if (HMI_flag.select_flag) { + pause_action_flag = 1; + ICON_Continue(); + #if ENABLED(POWER_LOSS_RECOVERY) + if (recovery.enabled) recovery.save(true); + #endif + queue.inject_P(PSTR("M25")); + } + else { + // cancel pause + } + Goto_PrintProcess(); + } + else if (select_print.now == 2) { // stop window + if (HMI_flag.select_flag) { + wait_for_heatup = false; // Stop waiting for heater + + #if 0 + // TODO: In ExtUI or MarlinUI add a common stop event + //card.flag.abort_sd_printing = true; + #else + checkkey = Back_Main; + // Wait for planner moves to finish! + if (HMI_flag.home_flag) planner.synchronize(); + card.endFilePrint(); + #ifdef ACTION_ON_CANCEL + host_action_cancel(); + #endif + #ifdef EVENT_GCODE_SD_STOP + Popup_Window_Home(); + queue.inject_P(PSTR(EVENT_GCODE_SD_STOP)); // For Ender 3 "G28 X Y" + #endif + abort_flag = true; + #endif + } + else + Goto_PrintProcess(); // cancel stop + } + } + DWIN_UpdateLCD(); +} + +inline void Draw_Move_Menu() { + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 192, 1, 271-38, 479-465, 14, 8); + + DWIN_Frame_AreaCopy(1, 58, 118, 271-165, 479-347, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 109, 118, 271-114, 479-347, LBLX, MBASE(2)); + DWIN_Frame_AreaCopy(1, 160, 118, 271-62, 479-347, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 212, 118, 271-18, 479-348, LBLX, MBASE(4)); + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Move"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 231, 2, 271-6, 479-467, 14, 8); + #endif + draw_move_en(MBASE(1)); say_x(33+3, MBASE(1)); // "Move X" + draw_move_en(MBASE(2)); say_y(33+3, MBASE(2)); // "Move Y" + draw_move_en(MBASE(3)); say_z(33+3, MBASE(3)); // "Move Z" + DWIN_Frame_AreaCopy(1, 123, 192, 271-95, 479-277, LBLX, MBASE(4)); // "Extruder" + } + + Draw_Back_First(select_axis.now == 0); + if (select_axis.now) Draw_Menu_Cursor(select_axis.now); + + LOOP_L_N(i, MROWS) Draw_Menu_Line(i + 1, ICON_MoveX+i); +} + +/* Prepare */ +void HMI_Prepare(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_prepare.inc(8)) { + if (select_prepare.now > MROWS && select_prepare.now > index_prepare) { + index_prepare = select_prepare.now; + + // Scroll up and draw a blank bottom line + Scroll_Menu(DWIN_SCROLL_UP); + Draw_Menu_Icon(MROWS, ICON_Axis+select_prepare.now-1); + + // Draw "More" icon for sub-menus + if (index_prepare < 7) Draw_More_Icon(MROWS-index_prepare+1); + + if (index_prepare == 6) Prepare_Item_ABS(MROWS); + else if (index_prepare == 7) Prepare_Item_Cool(MROWS); + else if (index_prepare == 8) Prepare_Item_Lang(MROWS); + } + else + Move_Highlight(1, select_prepare.now+MROWS-index_prepare); + } + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_prepare.dec()) { + if (select_prepare.now < index_prepare-MROWS) { + index_prepare--; + Scroll_Menu(DWIN_SCROLL_DOWN); + + if (index_prepare == MROWS) + Draw_Back_First(); + else + Draw_Menu_Line(0, ICON_Axis+select_prepare.now-1); + + if (index_prepare < 7) Draw_More_Icon(MROWS-index_prepare+1); + + if (index_prepare == 6) Prepare_Item_Move(0); + else if (index_prepare == 7) Prepare_Item_Disable(0); + else if (index_prepare == 8) Prepare_Item_Home(0); + } + else + Move_Highlight(-1, select_prepare.now+MROWS-index_prepare); + } + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_prepare.now) { + case 0: // back + select_page.set(1); + Goto_MainMenu(); + break; + case 1: // axis move + checkkey = AxisMove; + select_axis.reset(); + Draw_Move_Menu(); + + queue.inject_P(PSTR("G92 E0")); + current_position.e = HMI_ValueStruct.Move_E_scale = 0; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 216, MBASE(1), current_position[X_AXIS]*MinUnitMult); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 216, MBASE(2), current_position[Y_AXIS]*MinUnitMult); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 216, MBASE(3), current_position[Z_AXIS]*MinUnitMult); + show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), current_position.e*MinUnitMult); + break; + case 2: // close motion + queue.inject_P(PSTR("M84")); + break; + case 3: // homing + checkkey = Last_Prepare; + index_prepare = MROWS; + queue.inject_P(PSTR("G28")); // G28 will set home_flag + Popup_Window_Home(); + break; + case 4: // Z-offset + #if HAS_LEVELING + checkkey = Homeoffset; + HMI_ValueStruct.show_mode = -4; + HMI_ValueStruct.offset_value = probe.offset.z * 100; + show_plus_or_minus(font8x16, Select_Color, 2, 2, 202, MBASE(4+MROWS-index_prepare), HMI_ValueStruct.offset_value); + EncoderRate.encoderRateEnabled = 1; + #else + // Apply workspace offset, making the current position 0,0,0 + queue.inject_P(PSTR("G92 X0 Y0 Z0")); + buzzer.tone(100, 659); + buzzer.tone(100, 698); + #endif + break; + case 5: // PLA preheat + thermalManager.setTargetHotend(HMI_ValueStruct.preheat_hotend_temp[0], 0); + thermalManager.setTargetBed(HMI_ValueStruct.preheat_bed_temp[0]); + thermalManager.set_fan_speed(0, HMI_ValueStruct.preheat_fan_speed[0]); + break; + case 6: // ABS preheat + thermalManager.setTargetHotend(HMI_ValueStruct.preheat_hotend_temp[1], 0); + thermalManager.setTargetBed(HMI_ValueStruct.preheat_bed_temp[1]); + thermalManager.set_fan_speed(0, HMI_ValueStruct.preheat_fan_speed[1]); + break; + case 7: // cool + thermalManager.zero_fan_speeds(); + thermalManager.disable_all_heaters(); + break; + case 8: // language + /* select language */ + HMI_flag.language_flag = !HMI_flag.language_flag; + if (HMI_flag.language_flag) { + set_chinese_to_eeprom(); + DWIN_JPG_CacheTo1(Language_Chinese); + } + else { + set_english_to_eeprom(); + DWIN_JPG_CacheTo1(Language_English); + } + Draw_Prepare_Menu(); + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +void Draw_Temperature_Menu() { + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 236, 2, 271-8, 479-466, 14, 8); + + DWIN_Frame_AreaCopy(1, 1, 134, 271-215, 479-333, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 58, 134, 271-158, 479-333, LBLX, MBASE(2)); + DWIN_Frame_AreaCopy(1, 115, 134, 271-101, 479-333, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 100, 89, 271-93, 479-378, LBLX, MBASE(4)); + DWIN_Frame_AreaCopy(1, 180, 89, 271-11, 479-379, LBLX, MBASE(5)); + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Temperature"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 56, 16, 271-130, 479-450-1, 14, 8); + #endif + + DWIN_Frame_AreaCopy(1, 197, 104, 271-33, 479-365, LBLX, MBASE(1)); // Nozzle... + DWIN_Frame_AreaCopy(1, 1, 89, 271-188, 479-377-1, LBLX+41+3, MBASE(1)); // ...Temperature + DWIN_Frame_AreaCopy(1, 240, 104, 271-7, 479-365, LBLX, MBASE(2)); // Bed... + DWIN_Frame_AreaCopy(1, 1, 89, 271-188, 479-377-1, LBLX+24+3, MBASE(2)); // ...Temperature + DWIN_Frame_AreaCopy(1, 0, 119, 271-207, 479-347, LBLX, MBASE(3)); // Fan speed + DWIN_Frame_AreaCopy(1, 107, 76, 271-115, 479-393, LBLX, MBASE(4)); // Preheat... + DWIN_Frame_AreaCopy(1, 157, 76, 181, 479-393, LBLX+49+3, MBASE(4)); // ...PLA + DWIN_Frame_AreaCopy(1, 131, 119, 271-89, 479-347, LBLX+49+24+6, MBASE(4)); // PLA setting + DWIN_Frame_AreaCopy(1, 107, 76, 271-115, 479-393, LBLX, MBASE(5)); // Preheat... + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479-393, LBLX+49+3, MBASE(5)); // ...ABS + DWIN_Frame_AreaCopy(1, 131, 119, 271-89, 479-347, LBLX+49+3+26+3, MBASE(5)); // ABS setting + } + + Draw_Back_First(select_temp.now == 0); + if (select_temp.now) Draw_Menu_Cursor(select_temp.now); + + LOOP_L_N(i, 5) Draw_Menu_Line(i + 1, ICON_SetEndTemp+i); + + Draw_More_Icon(4); + Draw_More_Icon(5); + + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3), thermalManager.fan_speed[0]); +} + +/* Control */ +void HMI_Control(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + #define CONTROL_ITEMS (5 + ENABLED(HAS_LEVELING)) + if (select_control.inc(CONTROL_ITEMS)) { + if (select_control.now > MROWS && select_control.now > index_control) { + index_control = select_control.now; + Scroll_Menu(DWIN_SCROLL_UP); + Draw_Menu_Icon(MROWS, ICON_Temperature+select_control.now-1); + Draw_More_Icon(1+MROWS-index_control); // Temperature > + Draw_More_Icon(2+MROWS-index_control); // Motion > + if (index_control > MROWS) { + Draw_More_Icon(6+MROWS-index_control); // Info > + if (HMI_flag.language_flag) + DWIN_Frame_AreaCopy(1, 231, 104, 271-13, 479-363, LBLX, MBASE(5)); + else + DWIN_Frame_AreaCopy(1, 0, 104, 271-247, 479-365, LBLX, MBASE(5)); + } + } + else + Move_Highlight(1, select_control.now+MROWS-index_control); + } + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_control.dec()) { + if (select_control.now < index_control-MROWS) { + index_control--; + Scroll_Menu(DWIN_SCROLL_DOWN); + if (index_control == MROWS) + Draw_Back_First(); + else + Draw_Menu_Line(0, ICON_Temperature+select_control.now-1); + Draw_More_Icon(0+MROWS-index_control+1); // Temperature > + Draw_More_Icon(1+MROWS-index_control+1); // Motion > + } + else + Move_Highlight(-1, select_control.now+MROWS-index_control); + } + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_control.now) { + case 0: // back + select_page.set(2); + Goto_MainMenu(); + break; + case 1: // temperature + checkkey = TemperatureID; + HMI_ValueStruct.show_mode = -1; + select_temp.reset(); + Draw_Temperature_Menu(); + break; + case 2: // motion + checkkey = Motion; + select_motion.reset(); + Draw_Motion_Menu(); + break; + case 3: // write EEPROM + if (settings.save()) { + buzzer.tone(100, 659); + buzzer.tone(100, 698); + } + else buzzer.tone(20, 440); + break; + case 4: // read EEPROM + if (settings.load()) { + buzzer.tone(100, 659); + buzzer.tone(100, 698); + } + else buzzer.tone(20, 440); + break; + case 5: // resume EEPROM + settings.reset(); + #if HAS_BUZZER + buzzer.tone(100, 659); + buzzer.tone(100, 698); + #endif + break; + case 6: // info + checkkey = Info; + Draw_Info_Menu(); + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +/* Leveling */ +void HMI_Leveling(void) { + Popup_Window_Leveling(); + DWIN_UpdateLCD(); + queue.inject_P(PSTR("G29")); +} + +/* Axis Move */ +void HMI_AxisMove(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // popup window resume + if (HMI_flag.ETempTooLow_flag) { + if (encoder_diffState == ENCODER_DIFF_ENTER) { + HMI_flag.ETempTooLow_flag = 0; + Draw_Move_Menu(); + current_position.e = HMI_ValueStruct.Move_E_scale = 0; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + DWIN_UpdateLCD(); + } + return; + } + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_axis.inc(4)) Move_Highlight(1, select_axis.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_axis.dec()) Move_Highlight(-1, select_axis.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_axis.now) { + case 0: // back + checkkey = Prepare; + select_prepare.set(1); + index_prepare = MROWS; + Draw_Prepare_Menu(); + break; + case 1: // X axis move + checkkey = Move_X; + HMI_ValueStruct.Move_X_scale = current_position[X_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + EncoderRate.encoderRateEnabled = 1; + break; + case 2: // Y axis move + checkkey = Move_Y; + HMI_ValueStruct.Move_Y_scale = current_position[Y_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + EncoderRate.encoderRateEnabled = 1; + break; + case 3: // Z axis move + checkkey = Move_Z; + HMI_ValueStruct.Move_Z_scale = current_position[Z_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + EncoderRate.encoderRateEnabled = 1; + break; + case 4: // Extruder + // window tips + #ifdef PREVENT_COLD_EXTRUSION + if (thermalManager.temp_hotend[0].celsius < EXTRUDE_MINTEMP) { + HMI_flag.ETempTooLow_flag = 1; + Popup_Window_ETempTooLow(); + DWIN_UpdateLCD(); + return; + } + #endif + checkkey = Extruder; + HMI_ValueStruct.Move_E_scale = current_position.e*MinUnitMult; + show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + EncoderRate.encoderRateEnabled = 1; + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +/* TemperatureID */ +void HMI_Temperature(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_temp.inc(5)) Move_Highlight(1, select_temp.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_temp.dec()) Move_Highlight(-1, select_temp.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_temp.now) { + case 0: // back + checkkey = Control; + select_control.set(1); + index_control = MROWS; + Draw_Control_Menu(); + break; + case 1: // nozzle temperature + checkkey = ETemp; + HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); + EncoderRate.encoderRateEnabled = 1; + break; + case 2: // bed temperature + checkkey = BedTemp; + HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target); + EncoderRate.encoderRateEnabled = 1; + break; + case 3: // fan speed + checkkey = FanSpeed; + HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]); + EncoderRate.encoderRateEnabled = 1; + break; + case 4: // PLA preheat setting + + checkkey = PLAPreheat; + select_PLA.reset(); + HMI_ValueStruct.show_mode = -2; + + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 59, 16, 271-132, 479-450, 14, 8); + + DWIN_Frame_AreaCopy(1, 100, 89, 124, 479-378, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 1, 134, 271-215, 479-333, LBLX+24, MBASE(1)); // PLA nozzle temp + DWIN_Frame_AreaCopy(1, 100, 89, 124, 479-378, LBLX, MBASE(2)); + DWIN_Frame_AreaCopy(1, 58, 134, 271-158, 479-333, LBLX+24, MBASE(2)); // PLA bed temp + DWIN_Frame_AreaCopy(1, 100, 89, 124, 479-378, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 115, 134, 271-101, 479-333, LBLX+24, MBASE(3)); // PLA fan speed + DWIN_Frame_AreaCopy(1, 72, 148, 271-120, 479-317, LBLX, MBASE(4)); // save PLA configuration + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("PLA Settings"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 56, 16, 271-130, 479-450-1, 14, 8); + #endif + + DWIN_Frame_AreaCopy(1, 157, 76, 181, 479-393, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 197, 104, 271-33, 479-365, LBLX+24+3, MBASE(1)); + DWIN_Frame_AreaCopy(1, 1, 89, 271-188, 479-377-1, LBLX+24+41+6, MBASE(1)); // PLA nozzle temp + DWIN_Frame_AreaCopy(1, 157, 76, 181, 479-393, LBLX, MBASE(2)+3); + DWIN_Frame_AreaCopy(1, 240, 104, 271-7, 479-365, LBLX+24+3, MBASE(2)+3); + DWIN_Frame_AreaCopy(1, 1, 89, 271-188, 479-377-1, LBLX+24+24+6, MBASE(2)+3); // PLA bed temp + DWIN_Frame_AreaCopy(1, 157, 76, 181, 479-393, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 0, 119, 271-207, 479-347, LBLX+24+3, MBASE(3)); // PLA fan speed + DWIN_Frame_AreaCopy(1, 97, 165, 271-42, 479-301-1, LBLX, MBASE(4)); // save PLA configuration + } + + Draw_Back_First(); + + Draw_Menu_Line(1, ICON_SetEndTemp); + Draw_Menu_Line(2, ICON_SetBedTemp); + Draw_Menu_Line(3, ICON_FanSpeed); + Draw_Menu_Line(4, ICON_WriteEEPROM); + + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(1), HMI_ValueStruct.preheat_hotend_temp[0]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2), HMI_ValueStruct.preheat_bed_temp[0]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3), HMI_ValueStruct.preheat_fan_speed[0]); + + break; + case 5: // ABS preheat setting + + checkkey = ABSPreheat; + select_ABS.reset(); + HMI_ValueStruct.show_mode = -3; + + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 142, 16, 271-48, 479-450, 14, 8); + + DWIN_Frame_AreaCopy(1, 180, 89, 204, 479-379, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 1, 134, 271-215, 479-333, LBLX+24, MBASE(1)); // ABS nozzle temp + DWIN_Frame_AreaCopy(1, 180, 89, 204, 479-379, LBLX, MBASE(2)); + DWIN_Frame_AreaCopy(1, 58, 134, 271-158, 479-333, LBLX+24, MBASE(2)); // ABS bed temp + DWIN_Frame_AreaCopy(1, 180, 89, 204, 479-379, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 115, 134, 271-101, 479-333, LBLX+24, MBASE(3)); // ABS fan speed + DWIN_Frame_AreaCopy(1, 72, 148, 271-120, 479-317, LBLX, MBASE(4)); + DWIN_Frame_AreaCopy(1, 180, 89, 204, 479-379, LBLX+28, MBASE(4)+2); // save ABS configuration + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("ABS Settings"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 56, 16, 271-130, 479-450-1, 14, 8); + #endif + + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479-393, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 197, 104, 271-33, 479-365, LBLX+24+3, MBASE(1)); + DWIN_Frame_AreaCopy(1, 1, 89, 271-188, 479-377-1, LBLX+24+41+6, MBASE(1)); // ABS nozzle temp + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479-393, LBLX, MBASE(2)+3); + DWIN_Frame_AreaCopy(1, 240, 104, 271-7, 479-365, LBLX+24+3, MBASE(2)+3); + DWIN_Frame_AreaCopy(1, 1, 89, 271-188, 479-377-1, LBLX+24+24+6, MBASE(2)+3); // ABS bed temp + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479-393, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 0, 119, 271-207, 479-347, LBLX+24+3, MBASE(3)); // ABS fan speed + DWIN_Frame_AreaCopy(1, 97, 165, 271-42, 479-301-1, LBLX, MBASE(4)); + DWIN_Frame_AreaCopy(1, 172, 76, 198, 479-393, LBLX+33, MBASE(4)); // save ABS configuration + } + + Draw_Back_First(); + + Draw_Menu_Line(1, ICON_SetEndTemp); + Draw_Menu_Line(2, ICON_SetBedTemp); + Draw_Menu_Line(3, ICON_FanSpeed); + Draw_Menu_Line(4, ICON_WriteEEPROM); + + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(1), HMI_ValueStruct.preheat_hotend_temp[1]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(2), HMI_ValueStruct.preheat_bed_temp[1]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 3, 216, MBASE(3), HMI_ValueStruct.preheat_fan_speed[1]); + + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +inline void Draw_Max_Speed_Menu() { + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 1, 16, 271-243, 479-451, 14, 8); + + auto say_max_speed = [](const uint16_t row) { + DWIN_Frame_AreaCopy(1, 173, 133, 228, 479-332, LBLX, row); // "Max speed" + }; + + say_max_speed(MBASE(1)); // "Max speed" + DWIN_Frame_AreaCopy(1, 229, 133, 236, 479-332, LBLX+55+3, MBASE(1)); // X + say_max_speed(MBASE(2)); // "Max speed" + DWIN_Frame_AreaCopy(1, 1, 150, 271-264, 479-319, LBLX+55+3, MBASE(2)+3); // Y + say_max_speed(MBASE(3)); // "Max speed" + DWIN_Frame_AreaCopy(1, 9, 150, 271-255, 479-319, LBLX+55+3, MBASE(3)+3); // Z + say_max_speed(MBASE(4)); // "Max speed" + DWIN_Frame_AreaCopy(1, 18, 150, 271-246, 479-319, LBLX+55+3, MBASE(4)+3); // E + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Max Speed (mm/s)"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 144, 16, 271-82, 479-453, 14, 8); + #endif + + draw_max_en(MBASE(1)); // "Max" + DWIN_Frame_AreaCopy(1, 184, 119, 271-37, 479-347, LBLX+24+3, MBASE(1)); // "Speed X" + + draw_max_en(MBASE(2)); // "Max" + draw_speed_en(24+3, MBASE(2)); // "Speed" + say_y(24+40+6, MBASE(2)); // "Y" + + draw_max_en(MBASE(3)); // "Max" + draw_speed_en(24+3, MBASE(3)); // "Speed" + say_z(24+40+6, MBASE(3)); // "Z" + + draw_max_en(MBASE(4)); // "Max" + draw_speed_en(24+3, MBASE(4)); // "Speed" + say_e(24+40+6, MBASE(4)); // "E" + } + + Draw_Back_First(); + LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxSpeedX+i); + + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(1), planner.settings.max_feedrate_mm_s[X_AXIS]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(2), planner.settings.max_feedrate_mm_s[Y_AXIS]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(3), planner.settings.max_feedrate_mm_s[Z_AXIS]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(4), planner.settings.max_feedrate_mm_s[E_AXIS]); +} + +inline void Draw_Max_Accel_Menu() { + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 1, 16, 271-243, 479-451, 14, 8); + + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 28, 149, 271-202, 479-318, LBLX+27, MBASE(1)+1); + DWIN_Frame_AreaCopy(1, 229, 133, 236, 479-332, LBLX+27+41+3, MBASE(1)); // max acceleration X + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(2)); + DWIN_Frame_AreaCopy(1, 28, 149, 271-202, 479-318, LBLX+27, MBASE(2)+1); + DWIN_Frame_AreaCopy(1, 1, 150, 271-264, 479-319, LBLX+27+41+3, MBASE(2)+2); // max acceleration Y + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 28, 149, 271-202, 479-318, LBLX+27, MBASE(3)+1); + DWIN_Frame_AreaCopy(1, 9, 150, 271-255, 479-319, LBLX+27+41+3, MBASE(3)+2); // max acceleration Z + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(4)); + DWIN_Frame_AreaCopy(1, 28, 149, 271-202, 479-318, LBLX+27, MBASE(4)+1); + DWIN_Frame_AreaCopy(1, 18, 150, 271-246, 479-319, LBLX+27+41+3, MBASE(4)+2); // max acceleration E + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Max Accel (mm/s/s)"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 144, 16, 271-82, 479-453, 14, 8); + #endif + draw_max_accel_en(MBASE(1)); say_x(24+78+6, MBASE(1)); // "Max Acceleration X" + draw_max_accel_en(MBASE(2)); say_y(24+78+6, MBASE(2)); // "Max Acceleration Y" + draw_max_accel_en(MBASE(3)); say_z(24+78+6, MBASE(3)); // "Max Acceleration Z" + draw_max_accel_en(MBASE(4)); say_e(24+78+6, MBASE(4)); // "Max Acceleration E" + } + + Draw_Back_First(); + LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxAccX+i); + + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(1), planner.settings.max_acceleration_mm_per_s2[X_AXIS]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(2), planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(3), planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); + DWIN_Draw_IntValue(true,true,0,font8x16,White,Background_black, 4, 210, MBASE(4), planner.settings.max_acceleration_mm_per_s2[E_AXIS]); +} + +inline void Draw_Max_Jerk_Menu() { + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 1, 16, 271-243, 479-451, 14, 8); + + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 1, 180, 271-243, 479-287, LBLX+27, MBASE(1)+1); + DWIN_Frame_AreaCopy(1, 202, 133, 228, 479-332, LBLX+53, MBASE(1)); + DWIN_Frame_AreaCopy(1, 229, 133, 236, 479-332, LBLX+80+3, MBASE(1)); // max corner speed X + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(2)); + DWIN_Frame_AreaCopy(1, 1, 180, 271-243, 479-287, LBLX+27, MBASE(2)+1); + DWIN_Frame_AreaCopy(1, 202, 133, 228, 479-332, LBLX+53, MBASE(2)); + DWIN_Frame_AreaCopy(1, 1, 150, 271-264, 479-319, LBLX+80+3, MBASE(2)+3); // max corner speed Y + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 1, 180, 271-243, 479-287, LBLX+27, MBASE(3)+1); + DWIN_Frame_AreaCopy(1, 202, 133, 228, 479-332, LBLX+53, MBASE(3)); + DWIN_Frame_AreaCopy(1, 9, 150, 271-255, 479-319, LBLX+80+3, MBASE(3)+3); // max corner speed Z + DWIN_Frame_AreaCopy(1, 173, 133, 200, 479-332, LBLX, MBASE(4)); + DWIN_Frame_AreaCopy(1, 1, 180, 271-243, 479-287, LBLX+27, MBASE(4)+1); + DWIN_Frame_AreaCopy(1, 202, 133, 228, 479-332, LBLX+53, MBASE(4)); + DWIN_Frame_AreaCopy(1, 18, 150, 271-246, 479-319, LBLX+80+3, MBASE(4)+3); // max corner speed E + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Max Corner"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 144, 16, 271-82, 479-453, 14, 8); + #endif + + draw_max_en(MBASE(1)); // "Max" + draw_corner_en(MBASE(1)); // "Corner" + draw_speed_en(66+6, MBASE(1)); // "Speed" + say_x(106+9, MBASE(1)); // "X" + + draw_max_en(MBASE(2)); // "Max" + draw_corner_en(MBASE(2)); // "Corner" + draw_speed_en(66+6, MBASE(2)); // "Speed" + say_y(106+9, MBASE(2)); // "Y" + + draw_max_en(MBASE(3)); // "Max" + draw_corner_en(MBASE(3)); // "Corner" + draw_speed_en(66+6, MBASE(3)); // "Speed" + say_z(106+9, MBASE(3)); // "Z" + + draw_max_en(MBASE(4)); // "Max" + draw_corner_en(MBASE(4)); // "Corner" + draw_speed_en(66+6, MBASE(4)); // "Speed" + say_e(106+9, MBASE(4)); // "E" + } + + Draw_Back_First(); + LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxSpeedCornerX+i); + + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(1), planner.max_jerk[X_AXIS]*MinUnitMult); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(2), planner.max_jerk[Y_AXIS]*MinUnitMult); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(3), planner.max_jerk[Z_AXIS]*MinUnitMult); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(4), planner.max_jerk[E_AXIS]*MinUnitMult); +} + +inline void Draw_Steps_Menu() { + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + DWIN_Frame_AreaCopy(1, 1, 16, 271-243, 479-451, 14, 8); + + DWIN_Frame_AreaCopy(1, 153, 148, 271-77, 479-318, LBLX, MBASE(1)); + DWIN_Frame_AreaCopy(1, 229, 133, 236, 479-332, LBLX+41+3, MBASE(1)); // Transmission Ratio X + DWIN_Frame_AreaCopy(1, 153, 148, 271-77, 479-318, LBLX, MBASE(2)); + DWIN_Frame_AreaCopy(1, 1, 150, 271-264, 479-319, LBLX+41+3, MBASE(2)+3); // Transmission Ratio Y + DWIN_Frame_AreaCopy(1, 153, 148, 271-77, 479-318, LBLX, MBASE(3)); + DWIN_Frame_AreaCopy(1, 9, 150, 271-255, 479-319, LBLX+41+3, MBASE(3)+3); // Transmission Ratio Z + DWIN_Frame_AreaCopy(1, 153, 148, 271-77, 479-318, LBLX, MBASE(4)); + DWIN_Frame_AreaCopy(1, 18, 150, 271-246, 479-319, LBLX+41+3, MBASE(4)+3); // Transmission Ratio E + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("Steps-per-mm"); // TODO: GET_TEXT_F + #else + DWIN_Frame_AreaCopy(1, 144, 16, 271-82, 479-453, 14, 8); + #endif + draw_steps_per_mm(MBASE(1)); say_x(100+3, MBASE(1)); // "Steps-per-mm X" + draw_steps_per_mm(MBASE(2)); say_y(100+3, MBASE(2)); // "Y" + draw_steps_per_mm(MBASE(3)); say_z(100+3, MBASE(3)); // "Z" + draw_steps_per_mm(MBASE(4)); say_e(100+3, MBASE(4)); // "E" + } + + Draw_Back_First(); + LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_StepX+i); + + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(1), planner.settings.axis_steps_per_mm[X_AXIS]*MinUnitMult); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(2), planner.settings.axis_steps_per_mm[Y_AXIS]*MinUnitMult); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(3), planner.settings.axis_steps_per_mm[Z_AXIS]*MinUnitMult); + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Background_black, 3, 1, 210, MBASE(4), planner.settings.axis_steps_per_mm[E_AXIS]*MinUnitMult); +} + +/* Motion */ +void HMI_Motion(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_motion.inc(4)) Move_Highlight(1, select_motion.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_motion.dec()) Move_Highlight(-1, select_motion.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_motion.now) { + case 0: // back + checkkey = Control; + select_control.set(2); + index_control = MROWS; + Draw_Control_Menu(); + break; + case 1: // max speed + checkkey = MaxSpeed; + select_speed.reset(); + Draw_Max_Speed_Menu(); + break; + case 2: // max acceleration + checkkey = MaxAcceleration; + select_acc.reset(); + Draw_Max_Accel_Menu(); + break; + case 3: // max corner speed + checkkey = MaxCorner; + select_corner.reset(); + Draw_Max_Jerk_Menu(); + break; + case 4: // transmission ratio + checkkey = Step; + select_step.reset(); + Draw_Steps_Menu(); + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +/* Info */ +void HMI_Info(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + if (encoder_diffState == ENCODER_DIFF_ENTER) { + #if HAS_LEVELING + checkkey = Control; + select_control.set(CONTROL_ITEMS); + Draw_Control_Menu(); + #else + select_page.set(3); + Goto_MainMenu(); + #endif + } + DWIN_UpdateLCD(); +} + +/* Tune */ +void HMI_Tune(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_tune.inc(6)) { + if (select_tune.now > MROWS && select_tune.now > index_tune) { + index_tune = select_tune.now; + Scroll_Menu(DWIN_SCROLL_UP); + Prepare_Item_Lang(5); + } + else + Move_Highlight(1, select_tune.now + MROWS-index_tune); + } + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_tune.dec()) { + if (select_tune.now < index_tune-MROWS) { + index_tune--; + Scroll_Menu(DWIN_SCROLL_DOWN); + if (index_tune == MROWS) Draw_Back_First(); + } + else + Move_Highlight(-1, select_tune.now + MROWS-index_tune); + } + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_tune.now) { + case 0: { // back + select_print.set(0); + Goto_PrintProcess(); + } break; + case 1: // print speed + checkkey = PrintSpeed; + HMI_ValueStruct.print_speed = feedrate_percentage; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(1+MROWS-index_tune), feedrate_percentage); + EncoderRate.encoderRateEnabled = 1; + break; + case 2: // nozzle temp + checkkey = ETemp; + HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(2+MROWS-index_tune), thermalManager.temp_hotend[0].target); + EncoderRate.encoderRateEnabled = 1; + break; + case 3: // bed temp + checkkey = BedTemp; + HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(3+MROWS-index_tune), thermalManager.temp_bed.target); + EncoderRate.encoderRateEnabled = 1; + break; + case 4: // fan speed + checkkey = FanSpeed; + HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(4+MROWS-index_tune), thermalManager.fan_speed[0]); + EncoderRate.encoderRateEnabled = 1; + break; + case 5: // z-offset + checkkey = Homeoffset; + HMI_ValueStruct.offset_value = BABY_Z_VAR * 100; + show_plus_or_minus(font8x16, Select_Color, 2, 2, 202, MBASE(5+MROWS-index_tune), HMI_ValueStruct.offset_value); + EncoderRate.encoderRateEnabled = 1; + break; + case 6: // language + /* select language */ + HMI_flag.language_flag = !HMI_flag.language_flag; + + Clear_Main_Window(); + + if (HMI_flag.language_flag) { + set_chinese_to_eeprom(); + DWIN_JPG_CacheTo1(Language_Chinese); + } + else { + set_english_to_eeprom(); + DWIN_JPG_CacheTo1(Language_English); + } + + Draw_Tune_Menu(); + break; + + default: break; + } + } + DWIN_UpdateLCD(); +} + +/* PLA Preheat */ +void HMI_PLAPreheatSetting(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_PLA.inc(4)) Move_Highlight(1, select_PLA.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_PLA.dec()) Move_Highlight(-1, select_PLA.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_PLA.now) { + case 0: // back + checkkey = TemperatureID; + select_temp.now = 4; + HMI_ValueStruct.show_mode = -1; + Draw_Temperature_Menu(); + break; + case 1: // set nozzle temperature + checkkey = ETemp; + HMI_ValueStruct.E_Temp = HMI_ValueStruct.preheat_hotend_temp[0]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(1), HMI_ValueStruct.preheat_hotend_temp[0]); + EncoderRate.encoderRateEnabled = 1; + break; + case 2: // set bed temperature + checkkey = BedTemp; + HMI_ValueStruct.Bed_Temp = HMI_ValueStruct.preheat_bed_temp[0]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(2), HMI_ValueStruct.preheat_bed_temp[0]); + EncoderRate.encoderRateEnabled = 1; + break; + case 3: // set fan speed + checkkey = FanSpeed; + HMI_ValueStruct.Fan_speed = HMI_ValueStruct.preheat_fan_speed[0]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(3), HMI_ValueStruct.preheat_fan_speed[0]); + EncoderRate.encoderRateEnabled = 1; + break; + case 4: // save PLA configuration + if (settings.save()) { + buzzer.tone(100, 659); + buzzer.tone(100, 698); + } + else buzzer.tone(20, 440); + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +/* ABS Preheat */ +void HMI_ABSPreheatSetting(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_ABS.inc(4)) Move_Highlight(1, select_ABS.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_ABS.now) { + case 0: // back + checkkey = TemperatureID; + select_temp.now = 5; + HMI_ValueStruct.show_mode = -1; + Draw_Temperature_Menu(); + break; + case 1: // set nozzle temperature + checkkey = ETemp; + HMI_ValueStruct.E_Temp = HMI_ValueStruct.preheat_hotend_temp[1]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(1), HMI_ValueStruct.preheat_hotend_temp[1]); + EncoderRate.encoderRateEnabled = 1; + break; + case 2: // set bed temperature + checkkey = BedTemp; + HMI_ValueStruct.Bed_Temp = HMI_ValueStruct.preheat_bed_temp[1]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(2), HMI_ValueStruct.preheat_bed_temp[1]); + EncoderRate.encoderRateEnabled = 1; + break; + case 3: // set fan speed + checkkey = FanSpeed; + HMI_ValueStruct.Fan_speed = HMI_ValueStruct.preheat_fan_speed[1]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 3, 216, MBASE(3), HMI_ValueStruct.preheat_fan_speed[1]); + EncoderRate.encoderRateEnabled = 1; + break; + case 4: // save PLA configuration + if (settings.save()) { + buzzer.tone(100, 659); + buzzer.tone(100, 698); + } + else buzzer.tone(20, 440); + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +/* Max Speed */ +void HMI_MaxSpeed(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_speed.inc(4)) Move_Highlight(1, select_speed.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_speed.dec()) Move_Highlight(-1, select_speed.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_speed.now) { + case 0: // back + checkkey = Motion; + select_motion.now = 1; + Draw_Motion_Menu(); + break; + case 1: // max Speed X + checkkey = MaxSpeed_value; + HMI_flag.feedspeed_flag = X_AXIS; + HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[X_AXIS]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); + EncoderRate.encoderRateEnabled = 1; + break; + case 2: // max Speed Y + checkkey = MaxSpeed_value; + HMI_flag.feedspeed_flag = Y_AXIS; + HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[Y_AXIS]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); + EncoderRate.encoderRateEnabled = 1; + break; + case 3: // max Speed Z + checkkey = MaxSpeed_value; + HMI_flag.feedspeed_flag = Z_AXIS; + HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[Z_AXIS]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); + EncoderRate.encoderRateEnabled = 1; + break; + case 4: // max Speed E + checkkey = MaxSpeed_value; + HMI_flag.feedspeed_flag = E_AXIS; + HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[E_AXIS]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); + EncoderRate.encoderRateEnabled = 1; + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +/* Max Acceleration */ +void HMI_MaxAcceleration(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_acc.inc(4)) Move_Highlight(1, select_acc.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_acc.dec()) Move_Highlight(-1, select_acc.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_acc.now) { + case 0: // back + checkkey = Motion; + select_motion.now = 2; + Draw_Motion_Menu(); + break; + case 1: // max acceleration X + checkkey = MaxAcceleration_value; + HMI_flag.acc_flag = X_AXIS; + HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[X_AXIS]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); + EncoderRate.encoderRateEnabled = 1; + break; + case 2: // max acceleration Y + checkkey = MaxAcceleration_value; + HMI_flag.acc_flag = Y_AXIS; + HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[Y_AXIS]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); + EncoderRate.encoderRateEnabled = 1; + break; + case 3: // max acceleration Z + checkkey = MaxAcceleration_value; + HMI_flag.acc_flag = Z_AXIS; + HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[Z_AXIS]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); + EncoderRate.encoderRateEnabled = 1; + break; + case 4: // max acceleration E + checkkey = MaxAcceleration_value; + HMI_flag.acc_flag = E_AXIS; + HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[E_AXIS]; + DWIN_Draw_IntValue(true,true,0,font8x16,White,Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); + EncoderRate.encoderRateEnabled = 1; + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +/* Max Corner */ +void HMI_MaxCorner(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_corner.inc(4)) Move_Highlight(1, select_corner.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_corner.dec()) Move_Highlight(-1, select_corner.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_corner.now) { + case 0: // back + checkkey = Motion; + select_motion.now = 3; + Draw_Motion_Menu(); + break; + case 1: // max corner X + checkkey = MaxCorner_value; + HMI_flag.corner_flag = X_AXIS; + HMI_ValueStruct.Max_Corner = planner.max_jerk[X_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_corner.now), HMI_ValueStruct.Max_Corner); + EncoderRate.encoderRateEnabled = 1; + break; + case 2: // max corner Y + checkkey = MaxCorner_value; + HMI_flag.corner_flag = Y_AXIS; + HMI_ValueStruct.Max_Corner = planner.max_jerk[Y_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_corner.now), HMI_ValueStruct.Max_Corner); + EncoderRate.encoderRateEnabled = 1; + break; + case 3: // max corner Z + checkkey = MaxCorner_value; + HMI_flag.corner_flag = Z_AXIS; + HMI_ValueStruct.Max_Corner = planner.max_jerk[Z_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_corner.now), HMI_ValueStruct.Max_Corner); + EncoderRate.encoderRateEnabled = 1; + break; + case 4: // max corner E + checkkey = MaxCorner_value; + HMI_flag.corner_flag = E_AXIS; + HMI_ValueStruct.Max_Corner = planner.max_jerk[E_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_corner.now), HMI_ValueStruct.Max_Corner); + EncoderRate.encoderRateEnabled = 1; + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +/* Step */ +void HMI_Step(void) { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_step.inc(4)) Move_Highlight(1, select_step.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_step.dec()) Move_Highlight(-1, select_step.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_step.now) { + case 0: // back + checkkey = Motion; + select_motion.now = 4; + Draw_Motion_Menu(); + break; + case 1: // max step X + checkkey = Step_value; + HMI_flag.step_flag = X_AXIS; + HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[X_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + EncoderRate.encoderRateEnabled = 1; + break; + case 2: // max step Y + checkkey = Step_value; + HMI_flag.step_flag = Y_AXIS; + HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[Y_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + EncoderRate.encoderRateEnabled = 1; + break; + case 3: // max step Z + checkkey = Step_value; + HMI_flag.step_flag = Z_AXIS; + HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[Z_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + EncoderRate.encoderRateEnabled = 1; + break; + case 4: // max step E + checkkey = Step_value; + HMI_flag.step_flag = E_AXIS; + HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[E_AXIS]*MinUnitMult; + DWIN_Draw_FloatValue(true,true,0,font8x16,White,Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + EncoderRate.encoderRateEnabled = 1; + break; + default: + break; + } + } + DWIN_UpdateLCD(); +} + +void HMI_Init(void) { + HMI_SDCardInit(); + + for (uint16_t t = 0; t <= 100; t += 2) { + DWIN_ICON_Show(ICON,ICON_Bar, 15, 260); + DWIN_Draw_Rectangle(1, Background_black, 15 + t * 242/100, 260, 257, 280); + DWIN_UpdateLCD(); + delay(20); + } + + lcd_select_language(); + + #if ENABLED(FIX_MOUNTED_PROBE) // For "CREALITY_TOUCH" probe too? + SET_OUTPUT(COM_PIN); + WRITE(COM_PIN, 1); + #endif + + delay(200); +} + +void DWIN_Update(void) { + /* status update */ + EachMomentUpdate(); + + /* sdcard update */ + HMI_SDCardUpdate(); + + /* rotary encoder update */ + DWIN_HandleScreen(); +} + +void EachMomentUpdate(void) { + static millis_t next_rts_update_ms = 0; + const millis_t ms = millis(); + if (PENDING(ms, next_rts_update_ms)) return; + next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL; + + // variable update + update_variable(); + + if (checkkey == PrintProcess) { + // if print done + if (HMI_flag.print_finish && !HMI_flag.confirm_flag) { + HMI_flag.print_finish = 0; + HMI_flag.confirm_flag = 1; + + TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); + + planner.finish_and_disable(); + + // show percent bar and value + Percentrecord = 0; + Draw_Print_ProgressBar(); + + // show print done confirm + DWIN_Draw_Rectangle(1, Background_black, 0, 250, 271, 360); + DWIN_ICON_Show(ICON, HMI_flag.language_flag ? ICON_Confirm_C : ICON_Confirm_E, 86, 302-19); + } + else if (HMI_flag.pause_flag != printingIsPaused()) { + // print status update + HMI_flag.pause_flag = printingIsPaused(); + if (HMI_flag.pause_flag) ICON_Continue(); else ICON_Pause(); + } + } + + // pause after homing + if (pause_action_flag && printingIsPaused() && !planner.has_blocks_queued()) { + pause_action_flag = 0; + #if ENABLED(PAUSE_HEAT) + tempbed = thermalManager.temp_bed.target; + temphot = thermalManager.temp_hotend[0].target; + thermalManager.disable_all_heaters(); + #endif + queue.inject_P(PSTR("G1 F1200 X0 Y0")); + } + + if (card.isPrinting() && checkkey == PrintProcess) { // print process + const uint8_t card_pct = card.percentDone(); + static uint8_t last_cardpercentValue = 101; + if (last_cardpercentValue != card_pct) { // print percent + last_cardpercentValue = card_pct; + if (card_pct) { + Percentrecord = card_pct; + Draw_Print_ProgressBar(); + } + } + + duration_t elapsed = print_job_timer.duration(); // print timer + /* already print time */ + const uint16_t min = (elapsed.value % 3600) / 60; + if (last_Printtime != min) { // 1 minute update + last_Printtime = min; + Draw_Print_ProgressElapsed(); + } + /* remain print time */ + static millis_t next_remain_time_update = 0; + if (elapsed.minute() > 5 && ELAPSED(ms, next_remain_time_update) && HMI_flag.heat_flag == 0) { // show after 5 min and 20s update + remain_time = ((elapsed.value - heat_time) * ((float)card.getFileSize() / (float)card.getIndex())) - (elapsed.value - heat_time); + next_remain_time_update += 20 * 1000UL; + Draw_Print_ProgressRemain(); + } + } + else if (abort_flag && !HMI_flag.home_flag) { // Print Stop + abort_flag = 0; + HMI_ValueStruct.print_speed = feedrate_percentage = 100; + zprobe_zoffset = TERN(HAS_LEVELING, probe.offset.z, 0); + + planner.finish_and_disable(); + + #if DISABLED(SD_ABORT_NO_COOLDOWN) + thermalManager.disable_all_heaters(); + #endif + + select_page.set(0); + Goto_MainMenu(); + } + else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off + recovery.dwin_flag = false; + + recovery.load(); + if (!recovery.valid()) return recovery.purge(); + + auto draw_first_option = [](const bool sel) { + const uint16_t c1 = sel ? Background_window : Select_Color; + DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345); + DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346); + }; + + auto update_selection = [&](const bool sel) { + HMI_flag.select_flag = sel; + draw_first_option(sel); + const uint16_t c2 = sel ? Select_Color : Background_window; + DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345); + DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346); + }; + + LOOP_L_N(i, card.get_num_Files()) { + // TODO: Resume print via M1000 then update the UI + // with the active filename which can come from CardReader. + card.getfilename_sorted(i); + if (!strcmp(card.filename, &recovery.info.sd_filename[1])) { // Resume print before power failure while have the same file + recovery_flag = 1; + HMI_flag.select_flag = 1; + Popup_Window_Resume(); + draw_first_option(false); + char * const name = card.longest_filename(); + DWIN_Draw_String(false,true,font8x16, Font_window, Background_window, (DWIN_WIDTH-strlen(name)*MENU_CHR_W)/2, 252, name); + DWIN_UpdateLCD(); + break; + } + } + + // if hasn't resumable G-code file + if (!recovery_flag) return; + + while (recovery_flag) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_ENTER) { + recovery_flag = 0; + if (HMI_flag.select_flag) break; + TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); + HMI_StartFrame(true); + return; + } + else + update_selection(encoder_diffState == ENCODER_DIFF_CCW); + DWIN_UpdateLCD(); + } + } + + select_print.set(0); + HMI_ValueStruct.show_mode = 0; + HMI_StartFrame(false); + recovery.resume(); + return; + } + DWIN_UpdateLCD(); +} + +void DWIN_HandleScreen(void) { + switch (checkkey) { + case MainMenu: HMI_MainMenu(); break; + case SelectFile: HMI_SelectFile(); break; + case Prepare: HMI_Prepare(); break; + case Control: HMI_Control(); break; + case Leveling: break; + case PrintProcess: HMI_Printing(); break; + case Print_window: HMI_PauseOrStop(); break; + case AxisMove: HMI_AxisMove(); break; + case TemperatureID: HMI_Temperature(); break; + case Motion: HMI_Motion(); break; + case Info: HMI_Info(); break; + case Tune: HMI_Tune(); break; + case PLAPreheat: HMI_PLAPreheatSetting(); break; + case ABSPreheat: HMI_ABSPreheatSetting(); break; + case MaxSpeed: HMI_MaxSpeed(); break; + case MaxAcceleration: HMI_MaxAcceleration(); break; + case MaxCorner: HMI_MaxCorner(); break; + case Step: HMI_Step(); break; + case Move_X: HMI_Move_X(); break; + case Move_Y: HMI_Move_Y(); break; + case Move_Z: HMI_Move_Z(); break; + case Extruder: HMI_Move_E(); break; + case Homeoffset: HMI_Zoffset(); break; + case ETemp: HMI_ETemp(); break; + case BedTemp: HMI_BedTemp(); break; + case FanSpeed: HMI_FanSpeed(); break; + case PrintSpeed: HMI_PrintSpeed(); break; + case MaxSpeed_value: HMI_MaxFeedspeedXYZE(); break; + case MaxAcceleration_value: HMI_MaxAccelerationXYZE(); break; + case MaxCorner_value: HMI_MaxCornerXYZE(); break; + case Step_value: HMI_StepXYZE(); break; + default: break; + } +} + +void DWIN_CompletedHoming(void) { + HMI_flag.home_flag = false; + if (checkkey == Last_Prepare) { + checkkey = Prepare; + select_prepare.now = 3; + index_prepare = MROWS; + Draw_Prepare_Menu(); + } + else if (checkkey == Back_Main) { + HMI_ValueStruct.print_speed = feedrate_percentage = 100; + zprobe_zoffset = TERN0(BLTOUCH, probe.offset.z); + planner.finish_and_disable(); + Goto_MainMenu(); + } +} + +void DWIN_CompletedLeveling(void) { + if (checkkey == Leveling) Goto_MainMenu(); +} + +#endif // DWIN_CREALITY_LCD diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin.h new file mode 100644 index 0000000..7be3026 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin.h @@ -0,0 +1,379 @@ +/** + * 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 + +/** + * DWIN by Creality3D + */ + +#include "dwin_lcd.h" +#include "rotary_encoder.h" +#include "eeprom_BL24CXX.h" + +#include + +#define MACHINE_SIZE "220x220x250" +#define CORP_WEBSITE_C "www.cxsw3d.com" +#define CORP_WEBSITE_E "www.creality.com" + +/*********************************/ + +#define MENU_CHAR_LIMIT 24 + +/*fan speed limit*/ +#define FanOn 255 +#define FanOff 0 + +/*print speed limit*/ +#define max_print_speed 999 +#define min_print_speed 10 + +/*Temp limit*/ +#define max_E_Temp (HEATER_0_MAXTEMP - 15) +#define min_E_Temp HEATER_0_MINTEMP +#define max_Bed_Temp (BED_MAXTEMP - 10) +#define min_Bed_Temp BED_MINTEMP + +/*Feedspeed limit*/ // max feedspeed = DEFAULT_MAX_FEEDRATE * 2 +#define min_MaxFeedspeed 1 +#define min_MaxAcceleration 1 +#define min_MaxCorner 0.1 +#define min_Step 1 + +#define FEEDRATE_E (60) + +// mininum unit (0.1) : multiple (10) +#define MinUnitMult 10 + +#define Encoder_wait 20 +#define DWIN_SCROLL_UPDATE_INTERVAL 2000 +#define DWIN_REMAIN_TIME_UPDATE_INTERVAL 20000 + +enum processID { + /*Process ID*/ + MainMenu, + SelectFile, + Prepare, + Control, + Leveling, + PrintProcess, + AxisMove, + TemperatureID, + Motion, + Info, + Tune, + PLAPreheat, + ABSPreheat, + MaxSpeed, + MaxSpeed_value, + MaxAcceleration, + MaxAcceleration_value, + MaxCorner, + MaxCorner_value, + Step, + Step_value, + + /*Last Process ID*/ + Last_Prepare, + + /*Back Process ID*/ + Back_Main, + Back_Print, + + /*Date variable ID*/ + Move_X, + Move_Y, + Move_Z, + Extruder, + Homeoffset, + ETemp, + BedTemp, + FanSpeed, + PrintSpeed, + + /*Window ID*/ + Print_window, + Popup_Window +}; + +/*Picture ID*/ +#define Start_Process 0 +#define Language_English 1 +#define Language_Chinese 2 + +/*ICON ID*/ +#define ICON 0x09 +#define ICON_LOGO 0 +#define ICON_Print_0 1 +#define ICON_Print_1 2 +#define ICON_Prepare_0 3 +#define ICON_Prepare_1 4 +#define ICON_Control_0 5 +#define ICON_Control_1 6 +#define ICON_Leveling_0 7 +#define ICON_Leveling_1 8 +#define ICON_HotendTemp 9 +#define ICON_BedTemp 10 +#define ICON_Speed 11 +#define ICON_Zoffset 12 +#define ICON_Back 13 +#define ICON_File 14 +#define ICON_PrintTime 15 +#define ICON_RemainTime 16 +#define ICON_Setup_0 17 +#define ICON_Setup_1 18 +#define ICON_Pause_0 19 +#define ICON_Pause_1 20 +#define ICON_Continue_0 21 +#define ICON_Continue_1 22 +#define ICON_Stop_0 23 +#define ICON_Stop_1 24 +#define ICON_Bar 25 +#define ICON_More 26 + +#define ICON_Axis 27 +#define ICON_CloseMotor 28 +#define ICON_Homing 29 +#define ICON_SetHome 30 +#define ICON_PLAPreheat 31 +#define ICON_ABSPreheat 32 +#define ICON_Cool 33 +#define ICON_Language 34 + +#define ICON_MoveX 35 +#define ICON_MoveY 36 +#define ICON_MoveZ 37 +#define ICON_Extruder 38 + +#define ICON_Temperature 40 +#define ICON_Motion 41 +#define ICON_WriteEEPROM 42 +#define ICON_ReadEEPROM 43 +#define ICON_ResumeEEPROM 44 +#define ICON_Info 45 + +#define ICON_SetEndTemp 46 +#define ICON_SetBedTemp 47 +#define ICON_FanSpeed 48 +#define ICON_SetPLAPreheat 49 +#define ICON_SetABSPreheat 50 + +#define ICON_MaxSpeed 51 +#define ICON_MaxAccelerated 52 +#define ICON_MaxCorner 53 +#define ICON_Step 54 +#define ICON_PrintSize 55 +#define ICON_Version 56 +#define ICON_Contact 57 +#define ICON_StockConfiguraton 58 +#define ICON_MaxSpeedX 59 +#define ICON_MaxSpeedY 60 +#define ICON_MaxSpeedZ 61 +#define ICON_MaxSpeedE 62 +#define ICON_MaxAccX 63 +#define ICON_MaxAccY 64 +#define ICON_MaxAccZ 65 +#define ICON_MaxAccE 66 +#define ICON_MaxSpeedCornerX 67 +#define ICON_MaxSpeedCornerY 68 +#define ICON_MaxSpeedCornerZ 69 +#define ICON_MaxSpeedCornerE 70 +#define ICON_StepX 71 +#define ICON_StepY 72 +#define ICON_StepZ 73 +#define ICON_StepE 74 +#define ICON_Setspeed 75 +#define ICON_SetZOffset 76 +#define ICON_Rectangle 77 +#define ICON_BLTouch 78 +#define ICON_TempTooLow 79 +#define ICON_AutoLeveling 80 +#define ICON_TempTooHigh 81 +#define ICON_NoTips_C 82 +#define ICON_NoTips_E 83 +#define ICON_Continue_C 84 +#define ICON_Continue_E 85 +#define ICON_Cancel_C 86 +#define ICON_Cancel_E 87 +#define ICON_Confirm_C 88 +#define ICON_Confirm_E 89 +#define ICON_Info_0 90 +#define ICON_Info_1 91 + +/* +* 3-.0:字号大小,0x00-0x09,对应字体大小于下: +* 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28 +* 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64 +*/ +#define font6x12 0x00 +#define font8x16 0x01 +#define font10x20 0x02 +#define font12x24 0x03 +#define font14x28 0x04 +#define font16x32 0x05 +#define font20x40 0x06 +#define font24x48 0x07 +#define font28x56 0x08 +#define font32x64 0x09 + +/* Colour */ +#define White 0xFFFF +#define Background_window 0x31E8 // 弹窗背景色 +#define Background_blue 0x1125 // 暗蓝背景色 +#define Background_black 0x0841 // 黑色背景色 +#define Font_window 0xD6BA // 弹窗字体背景色 +#define Line_Color 0x3A6A // 分割线颜色 +#define Rectangle_Color 0xEE2F // 蓝色方块光标颜色 +#define Percent_Color 0xFE29 // 百分比颜色 +#define BarFill_Color 0x10E4 // 进度条填充色 +#define Select_Color 0x33BB // 选中色 + +extern int checkkey, last_checkkey; +extern float zprobe_zoffset; +extern char print_filename[16]; + +extern millis_t heat_time; + +typedef struct { + int16_t E_Temp = 0; + int16_t Bed_Temp = 0; + int16_t Fan_speed = 0; + int16_t print_speed = 100; + float Max_Feedspeed = 0; + float Max_Acceleration = 0; + float Max_Corner = 0; + float Max_Step = 0; + float Move_X_scale = 0; + float Move_Y_scale = 0; + float Move_Z_scale = 0; + float Move_E_scale = 0; + float offset_value = 0; + char show_mode = 0; // -1: Temperature control 0: Printing temperature + int16_t preheat_hotend_temp[2]; + int16_t preheat_bed_temp[2]; + uint8_t preheat_fan_speed[2]; +} HMI_value_t; + +typedef struct { + bool language_flag; // 0: EN, 1: CN + bool pause_flag:1; + bool print_finish:1; + bool confirm_flag:1; + bool select_flag:1; + bool home_flag:1; + bool heat_flag:1; // 0: heating done 1: during heating + bool ETempTooLow_flag:1; + bool leveling_offset_flag:1; + char feedspeed_flag; + char acc_flag; + char corner_flag; + char step_flag; +} HMI_Flag; + +extern HMI_value_t HMI_ValueStruct; +extern HMI_Flag HMI_flag; + +/* Language */ +void lcd_select_language(void); +void set_english_to_eeprom(void); +void set_chinese_to_eeprom(void); + +/* Show ICON*/ +void ICON_Print(bool show); +void ICON_Prepare(bool show); +void ICON_Control(bool show); +void ICON_Leveling(bool show); +void ICON_StartInfo(bool show); + +void ICON_Setting(bool show); +void ICON_Pause(bool show); +void ICON_Continue(bool show); +void ICON_Stop(bool show); + +/* Popup window tips */ +void Popup_Window_Temperature(const bool toohigh); +void Popup_Window_ETempTooLow(void); +void Popup_Window_Resume(void); +void Popup_Window_Home(void); +void Popup_Window_Leveling(void); + +void Goto_PrintProcess(void); +void Goto_MainMenu(void); + +/* Variable control */ +void HMI_Move_X(void); +void HMI_Move_Y(void); +void HMI_Move_Z(void); +void HMI_Move_E(void); + +void HMI_Zoffset(void); +void HMI_ETemp(void); +void HMI_BedTemp(void); +void HMI_FanSpeed(void); +void HMI_PrintSpeed(void); + +void HMI_MaxFeedspeedXYZE(void); +void HMI_MaxAccelerationXYZE(void); +void HMI_MaxCornerXYZE(void); +void HMI_StepXYZE(void); + +void update_variable(void); +void show_plus_or_minus(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value); + +/* SD Card */ +void HMI_SDCardInit(void); +void HMI_SDCardUpdate(void); + +/* Main Process */ +void Icon_print(bool value); +void Icon_control(bool value); +void Icon_temperature(bool value); +void Icon_leveling(bool value); + +/* Other */ +bool Pause_HeatStatus(); +void HMI_StartFrame(const bool with_update); // 开机画面 +void HMI_MainMenu(void); // 主进程画面 +void HMI_SelectFile(void); // 文件页 +void HMI_Printing(void); // 打印页 +void HMI_Prepare(void); // 准备页 +void HMI_Control(void); // 控制页 +void HMI_Leveling(void); // 调平页 +void HMI_AxisMove(void); // 轴移动菜单 +void HMI_Temperature(void); // 温度菜单 +void HMI_Motion(void); // 运动菜单 +void HMI_Info(void); // 信息菜单 +void HMI_Tune(void); // 调整菜单 +void HMI_PLAPreheatSetting(void); // PLA预热设置 +void HMI_ABSPreheatSetting(void); // ABS预热设置 +void HMI_MaxSpeed(void); // 最大速度子菜单 +void HMI_MaxAcceleration(void); // 最大加速度子菜单 +void HMI_MaxCorner(void); // 最大拐角速度子菜单 +void HMI_Step(void); // 传动比 + +void HMI_Init(void); +void DWIN_Update(void); +void EachMomentUpdate(void); +void DWIN_HandleScreen(void); + +void DWIN_CompletedHoming(void); +void DWIN_CompletedLeveling(void); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin_lcd.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin_lcd.cpp new file mode 100644 index 0000000..59232e6 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin_lcd.cpp @@ -0,0 +1,302 @@ +/** + * 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 . + * + */ + +/******************************************************************************** + * @file dwin_lcd.c + * @author LEO / Creality3D + * @date 2019/07/18 + * @version 2.0.1 + * @brief 迪文屏控制操作函数 + ********************************************************************************/ + +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_CREALITY_LCD) + +#include "../../inc/MarlinConfig.h" + +#include "dwin_lcd.h" +#include // for memset + +// Make sure DWIN_SendBuf is large enough to hold the largest +// printed string plus the draw command and tail. +uint8_t DWIN_SendBuf[11 + 24] = { 0xAA }; +uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C }; +uint8_t databuf[26] = { 0 }; +uint8_t receivedType; + +int recnum = 0; + +inline void DWIN_Byte(size_t &i, const uint16_t bval) { + DWIN_SendBuf[++i] = bval; +} + +inline void DWIN_Word(size_t &i, const uint16_t wval) { + DWIN_SendBuf[++i] = wval >> 8; + DWIN_SendBuf[++i] = wval & 0xFF; +} + +inline void DWIN_Long(size_t &i, const uint32_t lval) { + DWIN_SendBuf[++i] = (lval >> 24) & 0xFF; + DWIN_SendBuf[++i] = (lval >> 16) & 0xFF; + DWIN_SendBuf[++i] = (lval >> 8) & 0xFF; + DWIN_SendBuf[++i] = lval & 0xFF; +} + +inline void DWIN_String(size_t &i, char * const string) { + const size_t len = strlen(string); + memcpy(&DWIN_SendBuf[i+1], string, len); + i += len; +} + +/*发送当前BUF中的数据以及包尾数据 len:整包数据长度*/ +inline void DWIN_Send(size_t &i) { + ++i; + LOOP_L_N(n, i) { MYSERIAL1.write(DWIN_SendBuf[n]); + delayMicroseconds(1); } + LOOP_L_N(n, 4) { MYSERIAL1.write(DWIN_BufTail[n]); + delayMicroseconds(1); } +} + +/*----------------------------------------------系统变量函数----------------------------------------------*/ +/*握手 1: 握手成功 2: 握手失败*/ +bool DWIN_Handshake(void) { + size_t i = 0; + DWIN_Byte(i, 0x00); + DWIN_Send(i); + + while (MYSERIAL1.available() > 0 && recnum < (signed)sizeof(databuf)) { + databuf[recnum] = MYSERIAL1.read(); + // ignore the invalid data + if (databuf[0] != FHONE) { // prevent the program from running. + if (recnum > 0) { + recnum = 0; + ZERO(databuf); + } + continue; + } + delay(10); + recnum++; + } + + return ( recnum >= 3 + && databuf[0] == FHONE + && databuf[1] == '\0' + && databuf[2] == 'O' + && databuf[3] == 'K' ); +} + +/*设定背光亮度 luminance:亮度(0x00~0xFF)*/ +void DWIN_Backlight_SetLuminance(const uint8_t luminance) { + size_t i = 0; + DWIN_Byte(i, 0x30); + DWIN_Byte(i, _MAX(luminance, 0x1F)); + DWIN_Send(i); +} + +/*设定画面显示方向 dir:0,0°; 1,90°; 2,180°; 3,270°*/ +void DWIN_Frame_SetDir(uint8_t dir) { + size_t i = 0; + DWIN_Byte(i, 0x34); + DWIN_Byte(i, 0x5A); + DWIN_Byte(i, 0xA5); + DWIN_Byte(i, dir); + DWIN_Send(i); +} + +/*更新显示*/ +void DWIN_UpdateLCD(void) { + size_t i = 0; + DWIN_Byte(i, 0x3D); + DWIN_Send(i); +} + +/*----------------------------------------------绘图相关函数----------------------------------------------*/ +/*画面清屏 color:清屏颜色*/ +void DWIN_Frame_Clear(const uint16_t color) { + size_t i = 0; + DWIN_Byte(i, 0x01); + DWIN_Word(i, color); + DWIN_Send(i); +} + +/*画面画线 color:线段颜色 xStart:X起始坐标 yStart:Y起始坐标 xEnd:X终止坐标 yEnd:Y终止坐标*/ +void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) { + size_t i = 0; + DWIN_Byte(i, 0x03); + DWIN_Word(i, color); + DWIN_Word(i, xStart); + DWIN_Word(i, yStart); + DWIN_Word(i, xEnd); + DWIN_Word(i, yEnd); + DWIN_Send(i); +} + +/*画面画矩形 mode:0,外框;1,填充;2,异或填充 color:颜色 xStart/yStart:矩形左上坐标 xEnd/yEnd:矩形右下坐标*/ +void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, + uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) { + size_t i = 0; + DWIN_Byte(i, 0x05); + DWIN_Byte(i, mode); + DWIN_Word(i, color); + DWIN_Word(i, xStart); + DWIN_Word(i, yStart); + DWIN_Word(i, xEnd); + DWIN_Word(i, yEnd); + DWIN_Send(i); +} + +/*画面区域移动 mode:0,环移;1,平移 dir:0,向左移动;1,向右移动;2,向上移动;3,向下移动 dis:移动距离 + color:填充颜色 xStart/yStart:选定区域左上坐标 xEnd/yEnd:选定区域右下坐标*/ +void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, + uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) { + size_t i = 0; + DWIN_Byte(i, 0x09); + DWIN_Byte(i, (mode << 7) | dir); + DWIN_Word(i, dis); + DWIN_Word(i, color); + DWIN_Word(i, xStart); + DWIN_Word(i, yStart); + DWIN_Word(i, xEnd); + DWIN_Word(i, yEnd); + DWIN_Send(i); +} + +/*----------------------------------------------文本相关函数----------------------------------------------*/ +/*画面显示字符串 widthAdjust:true,自调整字符宽度;false,不调整字符宽度 bShow:true,显示背景色;false,不显示背景色 size:字号大小 + color:字符颜色 bColor:背景颜色 x/y:字符串左上坐标 *string:字符串*/ +void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, + uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) { + size_t i = 0; + DWIN_Byte(i, 0x11); + DWIN_Byte(i, (widthAdjust? 0x80:0x00) | (bShow? 0x40:0x00) | size); + DWIN_Word(i, color); + DWIN_Word(i, bColor); + DWIN_Word(i, x); + DWIN_Word(i, y); + DWIN_String(i, string); + DWIN_Send(i); +} + +/*画面显示正整数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小 + color:字符颜色 bColor:背景颜色 iNum:位数 x/y:变量左上坐标 value:整型变量*/ +void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) { + size_t i = 0; + DWIN_Byte(i, 0x14); + DWIN_Byte(i, (bShow? 0x80:0x00) | (zeroFill? 0x20:0x00) | (zeroMode? 0x10:0x00) | size); + DWIN_Word(i, color); + DWIN_Word(i, bColor); + DWIN_Byte(i, iNum); + DWIN_Byte(i, 0); // fNum + DWIN_Word(i, x); + DWIN_Word(i, y); + #if 0 + for (char count = 0; count < 8; count++) { + DWIN_Byte(i, value); + value >>= 8; + if ((value&0xFF) == 0x00) break; + } + #else + // Write a big-endian 64 bit integer + const size_t p = i + 1; + for (char count = 8; count--;) { // 7..0 + ++i; + DWIN_SendBuf[p + count] = value; + value >>= 8; + } + #endif + + DWIN_Send(i); +} + +/*画面显示浮点数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小 + color:字符颜色 bColor:背景颜色 iNum:整数位数 fNum:小数位数 x/y:变量左上坐标 value:浮点数变量*/ +void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) { + //uint8_t *fvalue = (uint8_t*)&value; + size_t i = 0; + DWIN_Byte(i, 0x14); + DWIN_Byte(i, (bShow? 0x80:0x00) | (zeroFill? 0x20:0x00) | (zeroMode? 0x10:0x00) | size); + DWIN_Word(i, color); + DWIN_Word(i, bColor); + DWIN_Byte(i, iNum); + DWIN_Byte(i, fNum); + DWIN_Word(i, x); + DWIN_Word(i, y); + DWIN_Long(i, value); + /* + DWIN_Byte(i, fvalue[3]); + DWIN_Byte(i, fvalue[2]); + DWIN_Byte(i, fvalue[1]); + DWIN_Byte(i, fvalue[0]); + */ + DWIN_Send(i); +} + +/*----------------------------------------------图片相关函数----------------------------------------------*/ +/*jpg图片显示并缓存在#0虚拟显示区 id:图片ID*/ +void DWIN_JPG_ShowAndCache(const uint8_t id) { + size_t i = 0; + DWIN_Word(i, 0x2200); + DWIN_Byte(i, id); + DWIN_Send(i); //AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C +} + +/*图标显示 libID:图标库ID picID:图标ID x/y:图标左上坐标*/ +void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) { + NOMORE(x, DWIN_WIDTH - 1); + NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl + size_t i = 0; + DWIN_Byte(i, 0x23); + DWIN_Word(i, x); + DWIN_Word(i, y); + DWIN_Byte(i, 0x80 | libID); + DWIN_Byte(i, picID); + DWIN_Send(i); +} + +/*jpg图片解压到#1虚拟显示区 id:图片ID*/ +void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) { + size_t i = 0; + DWIN_Byte(i, 0x25); + DWIN_Byte(i, n); + DWIN_Byte(i, id); + DWIN_Send(i); +} + +/*从虚拟显示区复制区域至当前画面 cacheID:虚拟区号 xStart/yStart:虚拟区左上坐标 xEnd/yEnd:虚拟区右下坐标 x/y:当前画面粘贴坐标*/ +void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, + uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) { + size_t i = 0; + DWIN_Byte(i, 0x27); + DWIN_Byte(i, 0x80 | cacheID); + DWIN_Word(i, xStart); + DWIN_Word(i, yStart); + DWIN_Word(i, xEnd); + DWIN_Word(i, yEnd); + DWIN_Word(i, x); + DWIN_Word(i, y); + DWIN_Send(i); +} + +#endif // DWIN_CREALITY_LCD diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin_lcd.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin_lcd.h new file mode 100644 index 0000000..e7624b0 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/dwin_lcd.h @@ -0,0 +1,111 @@ +/** + * 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 + +/******************************************************************************** + * @file dwin_lcd.h + * @author LEO / Creality3D + * @date 2019/07/18 + * @version 2.0.1 + * @brief 迪文屏控制操作函数 + ********************************************************************************/ + +#include + +#define RECEIVED_NO_DATA 0x00 +#define RECEIVED_SHAKE_HAND_ACK 0x01 + +#define FHONE 0xAA + +#define DWIN_SCROLL_UP 2 +#define DWIN_SCROLL_DOWN 3 + +#define DWIN_WIDTH 272 +#define DWIN_HEIGHT 480 + +/*接收数据解析 返回值:true,接收到数据;false,未接收到数据*/ +bool DWIN_ReceiveAnalyze(void); + +/*发送当前BUF中的数据以及包尾数据 len:整包数据长度*/ +void DWIN_Send_BufTail(const uint8_t len); + +/*----------------------------------------------系统变量函数----------------------------------------------*/ +/*握手 1: 握手成功 2: 握手失败*/ +bool DWIN_Handshake(void); + +/*设定背光亮度 luminance:亮度(0x00~0xFF)*/ +void DWIN_Backlight_SetLuminance(const uint8_t luminance); + +/*设定画面显示方向 dir:0,0°; 1,90°; 2,180°; 3,270°*/ +void DWIN_Frame_SetDir(uint8_t dir); + +/*更新显示*/ +void DWIN_UpdateLCD(void); + +/*----------------------------------------------绘图相关函数----------------------------------------------*/ +/*画面清屏 color:清屏颜色*/ +void DWIN_Frame_Clear(const uint16_t color); + +/*画面画线 color:线段颜色 xStart:X起始坐标 yStart:Y起始坐标 xEnd:X终止坐标 yEnd:Y终止坐标*/ +void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd); + +/*画面画矩形 mode:0,外框;1,填充;2,异或填充 color:颜色 xStart/yStart:矩形左上坐标 xEnd/yEnd:矩形右下坐标*/ +void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, + uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd); + +/*画面区域移动 mode:0,环移;1,平移 dir:0,向左移动;1,向右移动;2,向上移动;3,向下移动 dis:移动距离 + color:填充颜色 xStart/yStart:选定区域左上坐标 xEnd/yEnd:选定区域右下坐标*/ +void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, + uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd); + +/*----------------------------------------------文本相关函数----------------------------------------------*/ +/*画面显示字符串 widthAdjust:true,自调整字符宽度;false,不调整字符宽度 bShow:true,显示背景色;false,不显示背景色 size:字号大小 + color:字符颜色 bColor:背景颜色 x/y:字符串左上坐标 *string:字符串*/ +void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, + uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string); + +/*画面显示正整数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小 + color:字符颜色 bColor:背景颜色 iNum:位数 x/y:变量左上坐标 value:整型变量*/ +void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value); + +/*画面显示浮点数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小 + color:字符颜色 bColor:背景颜色 iNum:整数位数 fNum:小数位数 x/y:变量左上坐标 value:浮点数变量*/ +void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value); + +/*----------------------------------------------图片相关函数----------------------------------------------*/ +/*jpg图片显示并缓存在#0虚拟显示区 id:图片ID*/ +void DWIN_JPG_ShowAndCache(const uint8_t id); + +/*图标显示 libID:图标库ID picID:图标ID x/y:图标左上坐标*/ +void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y); + +/*jpg图片解压到#1虚拟显示区 id:图片ID*/ +void DWIN_JPG_CacheToN(uint8_t n, uint8_t id); + +/*jpg图片解压到#1虚拟显示区 id:图片ID*/ +inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); } + +/*从虚拟显示区复制区域至当前画面 cacheID:虚拟区号 xStart/yStart:虚拟区左上坐标 xEnd/yEnd:虚拟区右下坐标 x/y:当前画面粘贴坐标*/ +void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, + uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/eeprom_BL24CXX.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/eeprom_BL24CXX.cpp new file mode 100644 index 0000000..5201e06 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/eeprom_BL24CXX.cpp @@ -0,0 +1,263 @@ +/** + * 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 . + * + */ + +/******************************************************************************** + * @file eeprom_BL24CXX.cpp + * @brief i2c EEPROM for Ender 3 v2 board (4.2.2) + ********************************************************************************/ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(IIC_BL24CXX_EEPROM) + +#include "eeprom_BL24CXX.h" +#include "../../MarlinCore.h" + +#include + +/******************** IIC ********************/ + +// 初始化IIC +void IIC::init() { + SET_OUTPUT(IIC_EEPROM_SDA); + SET_OUTPUT(IIC_EEPROM_SCL); + + IIC_SCL_1(); + IIC_SDA_1(); +} + +// 产生IIC起始信号 +void IIC::start() { + SDA_OUT(); // sda线输出 + IIC_SDA_1(); + IIC_SCL_1(); + delay_us(4); + IIC_SDA_0(); // START:when CLK is high, DATA change form high to low + delay_us(4); + IIC_SCL_0(); // 钳住I2C总线,准备发送或接收数据 +} + +// 产生IIC停止信号 +void IIC::stop() { + SDA_OUT(); // sda线输出 + IIC_SCL_0(); + IIC_SDA_0(); // STOP:when CLK is high DATA change form low to high + delay_us(4); + IIC_SCL_1(); + IIC_SDA_1(); // 发送I2C总线结束信号 + delay_us(4); +} + +// 等待应答信号到来 +// 返回值:1,接收应答失败 +// 0,接收应答成功 +uint8_t IIC::wait_ack() { + uint8_t ucErrTime=0; + SDA_IN(); // SDA设置为输入 + IIC_SDA_1();delay_us(1); + IIC_SCL_1();delay_us(1); + while (READ_SDA()) { + ucErrTime++; + if (ucErrTime>250) { + stop(); + return 1; + } + } + IIC_SCL_0(); // 时钟输出0 + return 0; +} + +// 产生ACK应答 +void IIC::ack() { + IIC_SCL_0(); + SDA_OUT(); + IIC_SDA_0(); + delay_us(2); + IIC_SCL_1(); + delay_us(2); + IIC_SCL_0(); +} + +// 不产生ACK应答 +void IIC::nAck() { + IIC_SCL_0(); + SDA_OUT(); + IIC_SDA_1(); + delay_us(2); + IIC_SCL_1(); + delay_us(2); + IIC_SCL_0(); +} + +// IIC发送一个字节 +// 返回从机有无应答 +// 1,有应答 +// 0,无应答 +void IIC::send_byte(uint8_t txd) { + SDA_OUT(); + IIC_SCL_0(); // 拉低时钟开始数据传输 + LOOP_L_N(t, 8) { + // IIC_SDA = (txd & 0x80) >> 7; + if (txd & 0x80) IIC_SDA_1(); else IIC_SDA_0(); + txd <<= 1; + delay_us(2); // 对TEA5767这三个延时都是必须的 + IIC_SCL_1(); + delay_us(2); + IIC_SCL_0(); + delay_us(2); + } +} + +// 读1个字节,ack=1时,发送ACK,ack=0,发送nACK +uint8_t IIC::read_byte(unsigned char ack_chr) { + unsigned char receive = 0; + SDA_IN(); // SDA设置为输入 + LOOP_L_N(i, 8) { + IIC_SCL_0(); + delay_us(2); + IIC_SCL_1(); + receive <<= 1; + if (READ_SDA()) receive++; + delay_us(1); + } + ack_chr ? ack() : nAck(); // 发送ACK / 发送nACK + return receive; +} + +/******************** EEPROM ********************/ + +// 初始化IIC接口 +void BL24CXX::init() { IIC::init(); } + +// 在BL24CXX指定地址读出一个数据 +// ReadAddr:开始读数的地址 +// 返回值 :读到的数据 +uint8_t BL24CXX::readOneByte(uint16_t ReadAddr) { + uint8_t temp = 0; + IIC::start(); + if (EE_TYPE > BL24C16) { + IIC::send_byte(0xA0); // 发送写命令 + IIC::wait_ack(); + IIC::send_byte(ReadAddr >> 8); // 发送高地址 + IIC::wait_ack(); + } + else + IIC::send_byte(0xA0 + ((ReadAddr >> 8) << 1)); // 发送器件地址0xA0,写数据 + + IIC::wait_ack(); + IIC::send_byte(ReadAddr & 0xFF); // 发送低地址 + IIC::wait_ack(); + IIC::start(); + IIC::send_byte(0xA1); // 进入接收模式 + IIC::wait_ack(); + temp = IIC::read_byte(0); + IIC::stop(); // 产生一个停止条件 + return temp; +} + +// 在BL24CXX指定地址写入一个数据 +// WriteAddr :写入数据的目的地址 +// DataToWrite:要写入的数据 +void BL24CXX::writeOneByte(uint16_t WriteAddr, uint8_t DataToWrite) { + IIC::start(); + if (EE_TYPE > BL24C16) { + IIC::send_byte(0xA0); // 发送写命令 + IIC::wait_ack(); + IIC::send_byte(WriteAddr >> 8); // 发送高地址 + } + else { + IIC::send_byte(0xA0 + ((WriteAddr >> 8) << 1)); // 发送器件地址0xA0,写数据 + } + IIC::wait_ack(); + IIC::send_byte(WriteAddr & 0xFF); // 发送低地址 + IIC::wait_ack(); + IIC::send_byte(DataToWrite); // 发送字节 + IIC::wait_ack(); + IIC::stop(); // 产生一个停止条件 + delay(10); +} + +// 在BL24CXX里面的指定地址开始写入长度为Len的数据 +// 该函数用于写入16bit或者32bit的数据. +// WriteAddr :开始写入的地址 +// DataToWrite:数据数组首地址 +// Len :要写入数据的长度2,4 +void BL24CXX::writeLenByte(uint16_t WriteAddr, uint32_t DataToWrite, uint8_t Len) { + LOOP_L_N(t, Len) + writeOneByte(WriteAddr + t, (DataToWrite >> (8 * t)) & 0xFF); +} + +// 在BL24CXX里面的指定地址开始读出长度为Len的数据 +// 该函数用于读出16bit或者32bit的数据. +// ReadAddr :开始读出的地址 +// 返回值 :数据 +// Len :要读出数据的长度2,4 +uint32_t BL24CXX::readLenByte(uint16_t ReadAddr, uint8_t Len) { + uint32_t temp = 0; + LOOP_L_N(t, Len) { + temp <<= 8; + temp += readOneByte(ReadAddr + Len - t - 1); + } + return temp; +} + +// 检查BL24CXX是否正常 +// 这里用了24XX的最后一个地址(255)来存储标志字. +// 如果用其他24C系列,这个地址要修改 +// 返回1:检测失败 +// 返回0:检测成功 +uint8_t BL24CXX::check() { + uint8_t temp; + temp = readOneByte(255); // 避免每次开机都写BL24CXX + if (temp == 'U') return 0; + else { // 排除第一次初始化的情况 + writeOneByte(255, 'U'); + temp = readOneByte(255); + if (temp == 'U') return 0; + } + return 1; +} + +// 在BL24CXX里面的指定地址开始读出指定个数的数据 +// ReadAddr :开始读出的地址 对24c02为0~255 +// pBuffer :数据数组首地址 +// NumToRead:要读出数据的个数 +void BL24CXX::read(uint16_t ReadAddr, uint8_t *pBuffer, uint16_t NumToRead) { + while (NumToRead) { + *pBuffer++ = readOneByte(ReadAddr++); + NumToRead--; + } +} + +// 在BL24CXX里面的指定地址开始写入指定个数的数据 +// WriteAddr :开始写入的地址 对24c02为0~255 +// pBuffer :数据数组首地址 +// NumToWrite:要写入数据的个数 +void BL24CXX::write(uint16_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite) { + while (NumToWrite--) { + writeOneByte(WriteAddr, *pBuffer); + WriteAddr++; + pBuffer++; + } +} + +#endif // IIC_BL24CXX_EEPROM diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/eeprom_BL24CXX.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/eeprom_BL24CXX.h new file mode 100644 index 0000000..b655fb8 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/eeprom_BL24CXX.h @@ -0,0 +1,86 @@ +/** + * 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 + +/******************************************************************************** + * @file eeprom_BL24CXX.h + * @brief i2c EEPROM for Ender 3 v2 board (4.2.2) + ********************************************************************************/ + +#include + +/******************** IIC ********************/ + +//IO方向设置 +#define SDA_IN() do{ PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH &= 0XFFFF0FFF; PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH |= 8 << 12; }while(0) +#define SDA_OUT() do{ PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH &= 0XFFFF0FFF; PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH |= 3 << 12; }while(0) + +//IO操作函数 +#define IIC_SCL_0() WRITE(IIC_EEPROM_SCL, LOW) +#define IIC_SCL_1() WRITE(IIC_EEPROM_SCL, HIGH) +#define IIC_SDA_0() WRITE(IIC_EEPROM_SDA, LOW) +#define IIC_SDA_1() WRITE(IIC_EEPROM_SDA, HIGH) +#define READ_SDA() READ(IIC_EEPROM_SDA) + +class BL24CXX; + +// IIC所有操作函数 +class IIC { +friend class BL24CXX; +protected: + static void init(); // 初始化IIC的IO口 + static void start(); // 发送IIC开始信号 + static void stop(); // 发送IIC停止信号 + static void send_byte(uint8_t txd); // IIC发送一个字节 + static uint8_t read_byte(unsigned char ack); // IIC读取一个字节 + static uint8_t wait_ack(); // IIC等待ACK信号 + static void ack(); // IIC发送ACK信号 + static void nAck(); // IIC不发送ACK信号 + + static void write_one_byte(uint8_t daddr, uint8_t addr, uint8_t data); + static uint8_t read_one_byte(uint8_t daddr, uint8_t addr); +}; + +/******************** EEPROM ********************/ + +#define BL24C01 127 +#define BL24C02 255 +#define BL24C04 511 +#define BL24C08 1023 +#define BL24C16 2047 +#define BL24C32 4095 +#define BL24C64 8191 +#define BL24C128 16383 +#define BL24C256 32767 +#define EE_TYPE BL24C16 + +class BL24CXX { +public: + static void init(); //初始化IIC + static uint8_t check(); //检查器件 + static uint8_t readOneByte(uint16_t ReadAddr); //指定地址读取一个字节 + static void writeOneByte(uint16_t WriteAddr, uint8_t DataToWrite); //指定地址写入一个字节 + static void writeLenByte(uint16_t WriteAddr, uint32_t DataToWrite, uint8_t Len);//指定地址开始写入指定长度的数据 + static uint32_t readLenByte(uint16_t ReadAddr, uint8_t Len); //指定地址开始读取指定长度数据 + static void write(uint16_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite); //从指定地址开始写入指定长度的数据 + static void read(uint16_t ReadAddr, uint8_t *pBuffer, uint16_t NumToRead); //从指定地址开始读出指定长度的数据 +}; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/rotary_encoder.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/rotary_encoder.cpp new file mode 100644 index 0000000..71a0772 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/rotary_encoder.cpp @@ -0,0 +1,249 @@ +/** + * 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 . + * + */ + +/** + ****************************************************************************** + * @file rotary_encoder.cpp + * @author LEO / Creality3D + * @date 2019/07/06 + * @version 2.0.1 + * @brief 旋转编码器操作函数 + ****************************************************************************** +**/ + +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_CREALITY_LCD) + +#include "rotary_encoder.h" + +#include "../../MarlinCore.h" +#include "../../HAL/shared/Delay.h" + +#if HAS_BUZZER + #include "../../libs/buzzer.h" +#endif + +#include + +ENCODER_Rate EncoderRate; + +/*蜂鸣器响*/ +void Encoder_tick(void) { + WRITE(BEEPER_PIN,1); + delay(10); + WRITE(BEEPER_PIN,0); +} + +/*编码器初始化 PB12:Encoder_A PB13:Encoder_B PB14:Encoder_C*/ +void Encoder_Configuration(void) { + #if BUTTON_EXISTS(EN1) + SET_INPUT_PULLUP(BTN_EN1); + #endif + #if BUTTON_EXISTS(EN2) + SET_INPUT_PULLUP(BTN_EN2); + #endif + #if BUTTON_EXISTS(ENC) + SET_INPUT_PULLUP(BTN_ENC); + #endif + #ifdef BEEPER_PIN + SET_OUTPUT(BEEPER_PIN); + #endif +} + +millis_t next_click_update_ms; +/*接收数据解析 返回值:ENCODER_DIFF_NO,无状态; ENCODER_DIFF_CW,顺时针旋转; ENCODER_DIFF_CCW,逆时针旋转; ENCODER_DIFF_ENTER,按下*/ +ENCODER_DiffState Encoder_ReceiveAnalyze(void) { + const millis_t now = millis(); + static unsigned char lastEncoderBits; + unsigned char newbutton = 0; + static signed char temp_diff = 0; + + ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO; + if (BUTTON_PRESSED(EN1)) newbutton |= 0x01; + if (BUTTON_PRESSED(EN2)) newbutton |= 0x02; + if (BUTTON_PRESSED(ENC)) { + if (ELAPSED(now, next_click_update_ms)) { + next_click_update_ms = millis() + 300; + Encoder_tick(); + #if PIN_EXISTS(LCD_LED) + //LED_Action(); + #endif + return ENCODER_DIFF_ENTER; + } + else return ENCODER_DIFF_NO; + } + if (newbutton != lastEncoderBits) { + switch (newbutton) { + case ENCODER_PHASE_0: { + if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++; + else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--; + }break; + case ENCODER_PHASE_1: { + if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++; + else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--; + }break; + case ENCODER_PHASE_2: { + if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++; + else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--; + }break; + case ENCODER_PHASE_3: { + if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++; + else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--; + }break; + } + lastEncoderBits = newbutton; + } + + if (abs(temp_diff) >= ENCODER_PULSES_PER_STEP) { + if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW; + else temp_diffState = ENCODER_DIFF_CCW; + + #if ENABLED(ENCODER_RATE_MULTIPLIER) + + millis_t ms = millis(); + int32_t encoderMultiplier = 1; + + // if must encoder rati multiplier + if (EncoderRate.encoderRateEnabled) { + const float abs_diff = ABS(temp_diff); + const float encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP); + if (EncoderRate.lastEncoderTime) { + // Note that the rate is always calculated between two passes through the + // loop and that the abs of the temp_diff value is tracked. + const float encoderStepRate = encoderMovementSteps / float(ms - EncoderRate.lastEncoderTime) * 1000; + if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100; + else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10; + else if (encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) encoderMultiplier = 5; + } + EncoderRate.lastEncoderTime = ms; + } + #else + constexpr int32_t encoderMultiplier = 1; + #endif // ENCODER_RATE_MULTIPLIER + + // EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP); + EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP); + if (EncoderRate.encoderMoveValue < 0) EncoderRate.encoderMoveValue = -EncoderRate.encoderMoveValue; + + temp_diff = 0; + } + return temp_diffState; +} + +#if PIN_EXISTS(LCD_LED) + + /*取低24位有效 24Bit: G7 G6 G5 G4 G3 G2 G1 G0 R7 R6 R5 R4 R3 R2 R1 R0 B7 B6 B5 B4 B3 B2 B1 B0*/ + unsigned int LED_DataArray[LED_NUM]; + + /*LED灯操作*/ + void LED_Action(void) { + LED_Control(RGB_SCALE_WARM_WHITE,0x0F); + delay(30); + LED_Control(RGB_SCALE_WARM_WHITE,0x00); + } + + /*LED初始化*/ + void LED_Configuration(void) { + SET_OUTPUT(LCD_LED_PIN); + } + + /*LED写数据*/ + void LED_WriteData(void) { + unsigned char tempCounter_LED, tempCounter_Bit; + for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) { + for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) { + if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) { + LED_DATA_HIGH; + DELAY_NS(300); + LED_DATA_LOW; + DELAY_NS(200); + } + else { + LED_DATA_HIGH; + LED_DATA_LOW; + DELAY_NS(200); + } + } + } + } + + /*LED控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF)*/ + void LED_Control(unsigned char RGB_Scale, unsigned char luminance) { + unsigned char temp_Counter; + for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) { + LED_DataArray[temp_Counter] = 0; + switch(RGB_Scale) { + case RGB_SCALE_R10_G7_B5: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*5/10; break; + case RGB_SCALE_R10_G7_B4: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*4/10; break; + case RGB_SCALE_R10_G8_B7: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*8/10) << 16 | luminance*7/10; break; + } + } + LED_WriteData(); + } + + /*LED渐变控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF) change_Time:渐变时间(ms)*/ + void LED_GraduallyControl(unsigned char RGB_Scale, unsigned char luminance, unsigned int change_Interval) { + unsigned char temp_Counter; + unsigned char LED_R_Data[LED_NUM], LED_G_Data[LED_NUM], LED_B_Data[LED_NUM]; + bool LED_R_Flag = 0, LED_G_Flag = 0, LED_B_Flag = 0; + + for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) { + switch(RGB_Scale) { + case RGB_SCALE_R10_G7_B5: { + LED_R_Data[temp_Counter] = luminance*10/10; + LED_G_Data[temp_Counter] = luminance*7/10; + LED_B_Data[temp_Counter] = luminance*5/10; + }break; + case RGB_SCALE_R10_G7_B4: { + LED_R_Data[temp_Counter] = luminance*10/10; + LED_G_Data[temp_Counter] = luminance*7/10; + LED_B_Data[temp_Counter] = luminance*4/10; + }break; + case RGB_SCALE_R10_G8_B7: { + LED_R_Data[temp_Counter] = luminance*10/10; + LED_G_Data[temp_Counter] = luminance*8/10; + LED_B_Data[temp_Counter] = luminance*7/10; + }break; + } + } + for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) { + if ((unsigned char)(LED_DataArray[temp_Counter] >> 8) > LED_R_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x000100; + else if ((unsigned char)(LED_DataArray[temp_Counter] >> 8) < LED_R_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x000100; + while (1) { + else LED_R_Flag = 1; + if ((unsigned char)(LED_DataArray[temp_Counter]>>16) > LED_G_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x010000; + else if ((unsigned char)(LED_DataArray[temp_Counter]>>16) < LED_G_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x010000; + else LED_G_Flag = 1; + if ((unsigned char)LED_DataArray[temp_Counter] > LED_B_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x000001; + else if ((unsigned char)LED_DataArray[temp_Counter] < LED_B_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x000001; + else LED_B_Flag = 1; + } + LED_WriteData(); + if (LED_R_Flag && LED_G_Flag && LED_B_Flag) break; + else delay(change_Interval); + } + } + +#endif + +#endif // DWIN_CREALITY_LCD diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/rotary_encoder.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/rotary_encoder.h new file mode 100644 index 0000000..d650d53 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/dwin/rotary_encoder.h @@ -0,0 +1,105 @@ +/** + * 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 + +/** + ****************************************************************************** + * @file rotary_encoder.h + * @author LEO / Creality3D + * @date 2019/07/06 + * @version 2.0.1 + * @brief 旋转编码器操作函数 + ****************************************************************************** +**/ + +#include "../../inc/MarlinConfig.h" +#include "../../MarlinCore.h" + +/*********************** Encoder Set ***********************/ + +#define ENCODER_PHASE_0 0 +#define ENCODER_PHASE_1 2 +#define ENCODER_PHASE_2 3 +#define ENCODER_PHASE_3 1 + +#define ENCODER_PULSES_PER_STEP 4 + +#define BUTTON_PRESSED(BN) !READ(BTN_## BN) + +typedef struct { + bool encoderRateEnabled = 0; + int encoderMoveValue = 0; + millis_t lastEncoderTime = 0; +} ENCODER_Rate; + +extern ENCODER_Rate EncoderRate; + +typedef enum { + ENCODER_DIFF_NO = 0, + ENCODER_DIFF_CW = 1, + ENCODER_DIFF_CCW = 2, + ENCODER_DIFF_ENTER = 3 +} ENCODER_DiffState; + +/*编码器初始化 PB12:Encoder_A PB13:Encoder_B PB14:Encoder_C*/ +void Encoder_Configuration(void); + +/*接收数据解析 返回值:ENCODER_DIFF_NO,无状态; ENCODER_DIFF_CW,顺时针旋转; ENCODER_DIFF_CCW,逆时针旋转; ENCODER_DIFF_ENTER,按下*/ +ENCODER_DiffState Encoder_ReceiveAnalyze(void); + + +/*********************** Encoder LED ***********************/ + +#if PIN_EXISTS(LCD_LED) + + #define LED_NUM 4 + #define LED_DATA_HIGH WRITE(LCD_LED_PIN, 1) + #define LED_DATA_LOW WRITE(LCD_LED_PIN, 0) + + #define RGB_SCALE_R10_G7_B5 1 + #define RGB_SCALE_R10_G7_B4 2 + #define RGB_SCALE_R10_G8_B7 3 + #define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5 //正白 + #define RGB_SCALE_WARM_WHITE RGB_SCALE_R10_G7_B4 //暖白 + #define RGB_SCALE_COOL_WHITE RGB_SCALE_R10_G8_B7 //冷白 + + extern unsigned int LED_DataArray[LED_NUM]; + + /*状态LED初始化*/ + void STATE_LED_Configuration(void); + + /*LED灯操作*/ + void LED_Action(void); + + /*LED初始化*/ + void LED_Configuration(void); + + /*LED写数据*/ + void LED_WriteData(void); + + /*LED控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF)*/ + void LED_Control(unsigned char RGB_Scale, unsigned char luminance); + + /*LED渐变控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF) change_Time:渐变时间(ms)*/ + void LED_GraduallyControl(unsigned char RGB_Scale, unsigned char luminance, unsigned int change_Interval); + +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index 24a4ed0..66af4e4 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -592,7 +592,7 @@ void DGUSScreenVariableHandler::HandleManualExtrude(DGUS_VP_Variable &var, void case VP_MOVE_E0: target_extruder = ExtUI::extruder_t::E0; break; #endif #if HOTENDS >= 2 - case VP_MOVE_E1: target_extruder = ExtUI::extruder_t::E1; break + case VP_MOVE_E1: target_extruder = ExtUI::extruder_t::E1; break; #endif default: return; } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp index 23664dc..71ae604 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp @@ -387,7 +387,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.h index 309a23b..51f84a1 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.h @@ -151,7 +151,7 @@ constexpr uint16_t VP_SETTINGS = 0x2400; // PID autotune constexpr uint16_t VP_PID_AUTOTUNE_E0 = 0x2410; -//constexpr uint16_t VP_PID_AUTOTUNE_E1 = 0x2412; +constexpr uint16_t VP_PID_AUTOTUNE_E1 = 0x2412; //constexpr uint16_t VP_PID_AUTOTUNE_E2 = 0x2414; //constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x2416; //constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x2418; @@ -246,7 +246,7 @@ constexpr uint16_t VP_FAN3_STATUS = 0x3306; // Heater status constexpr uint16_t VP_E0_STATUS = 0x3310; -//constexpr uint16_t VP_E1_STATUS = 0x3312; +constexpr uint16_t VP_E1_STATUS = 0x3312; //constexpr uint16_t VP_E2_STATUS = 0x3314; //constexpr uint16_t VP_E3_STATUS = 0x3316; //constexpr uint16_t VP_E4_STATUS = 0x3318; @@ -273,6 +273,9 @@ constexpr uint16_t VP_E1_STEP_PER_MM = 0x3612; constexpr uint16_t VP_E0_PID_P = 0x3700; // at the moment , 2 byte unsigned int , 0~1638.4 constexpr uint16_t VP_E0_PID_I = 0x3702; constexpr uint16_t VP_E0_PID_D = 0x3704; +constexpr uint16_t VP_E1_PID_P = 0x3706; // at the moment , 2 byte unsigned int , 0~1638.4 +constexpr uint16_t VP_E1_PID_I = 0x3708; +constexpr uint16_t VP_E1_PID_D = 0x370A; constexpr uint16_t VP_BED_PID_P = 0x3710; constexpr uint16_t VP_BED_PID_I = 0x3712; constexpr uint16_t VP_BED_PID_D = 0x3714; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h index 9c0a4c3..73aec64 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h @@ -315,7 +315,7 @@ class CommandProcessor : public CLCD::CommandFifo { #ifdef TOUCH_UI_USE_UTF8 const bool is_utf8 = has_utf8_chars(text); #endif - for (;font >= 26;) { + for (;font > 26;) { int16_t width, height; #ifdef TOUCH_UI_USE_UTF8 if (is_utf8) { diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp new file mode 100644 index 0000000..804bc65 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp @@ -0,0 +1,271 @@ +/** + * 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(SPI_GRAPHICAL_TFT) + + #include + #include "../../../../inc/MarlinConfig.h" + #include "SPI_TFT.h" + + TFT SPI_TFT; + + #ifndef SPI_TFT_MISO_PIN + #define SPI_TFT_MISO_PIN PA6 + #endif + #ifndef SPI_TFT_MOSI_PIN + #define SPI_TFT_MOSI_PIN PA7 + #endif + #ifndef SPI_TFT_SCK_PIN + #define SPI_TFT_SCK_PIN PA5 + #endif + #ifndef SPI_TFT_CS_PIN + #define SPI_TFT_CS_PIN PD11 + #endif + #ifndef SPI_TFT_DC_PIN + #define SPI_TFT_DC_PIN PD10 + #endif + #ifndef SPI_TFT_RST_PIN + #define SPI_TFT_RST_PIN PC6 + #endif + +// use SPI1 for the spi tft. + void TFT::spi_init(uint8_t spiRate) { + + SPI_TFT_CS_H; + + /** + * STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz + * STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1 + * so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2 + */ + uint8_t clock; + switch (spiRate) { + case SPI_FULL_SPEED: clock = SPI_CLOCK_DIV4; break; + case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4; break; + case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8; break; + case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break; + case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break; + case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break; + default: clock = SPI_CLOCK_DIV2; // Default from the SPI library + } + SPI.setModule(1); + SPI.begin(); + SPI.setClockDivider(clock); + SPI.setBitOrder(MSBFIRST); + SPI.setDataMode(SPI_MODE0); + } + + uint8_t TFT::spi_Rec() { + uint8_t returnByte = SPI.transfer(ff); + return returnByte; + } + + uint8_t TFT::spi_read_write_byte(uint8_t data) { + uint8_t returnByte = SPI.transfer(data); + return returnByte; + } + +/** + * @brief Receive a number of bytes from the SPI port to a buffer + * + * @param buf Pointer to starting address of buffer to write to. + * @param nbyte Number of bytes to receive. + * @return Nothing + * + * @details Uses DMA + */ + void TFT::spi_Read(uint8_t* buf, uint16_t nbyte) {SPI.dmaTransfer(0, const_cast(buf), nbyte);} + +/** + * @brief Send a single byte on SPI port + * + * @param b Byte to send + * + * @details + */ + void TFT::spi_Send(uint8_t b) {SPI.send(b);} + +/** + * @brief Write token and then write from 512 byte buffer to SPI (for SD card) + * + * @param buf Pointer with buffer start address + * @return Nothing + * + * @details Use DMA + */ + void TFT::spi_SendBlock(uint8_t token, const uint8_t* buf) { + SPI.send(token); + SPI.dmaSend(const_cast(buf), 512); + } + + void TFT::LCD_WR_REG(uint8_t cmd) { + SPI_TFT_CS_L; + SPI_TFT_DC_L; + spi_Send(cmd); + SPI_TFT_CS_H; + } + void TFT::LCD_WR_DATA(uint8_t data) { + SPI_TFT_CS_L; + SPI_TFT_DC_H; + spi_Send(data); + SPI_TFT_CS_H; + } + void TFT::LCD_WriteRAM_Prepare() {LCD_WR_REG(0X2C);} + void TFT::SetCursor(uint16_t x, uint16_t y) { + LCD_WR_REG(0x2a); + LCD_WR_DATA(x >> 8); + LCD_WR_DATA(x); + LCD_WR_DATA(x >> 8); + LCD_WR_DATA(x); + + LCD_WR_REG(0x2b); + LCD_WR_DATA(y >> 8); + LCD_WR_DATA(y); + LCD_WR_DATA(y >> 8); + LCD_WR_DATA(y); + } + void TFT::SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height) { + LCD_WR_REG(0x2a); + LCD_WR_DATA(x >> 8); + LCD_WR_DATA(x); + LCD_WR_DATA((x + with) >> 8); + LCD_WR_DATA((x + with)); + + LCD_WR_REG(0x2b); + LCD_WR_DATA(y >> 8); + LCD_WR_DATA(y); + LCD_WR_DATA((y + height) >> 8); + LCD_WR_DATA(y + height); + } + void TFT::LCD_init() { + SPI_TFT_RST_H; + delay(150); + SPI_TFT_RST_L; + delay(150); + SPI_TFT_RST_H; + + 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); + + 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 + + LCD_clear(0x0000); // + SPI_TFT_BLK_H; + + } + void TFT::LCD_clear(uint16_t color) { + unsigned int i, m; + uint32_t count; + uint8_t tbuf[960]; + + SetCursor(0, 0); + SetWindows(0, 0, 480 - 1, 320 - 1); + LCD_WriteRAM_Prepare(); + SPI_TFT_CS_L; + SPI_TFT_DC_H; + for (i = 0; i < 960;) { + tbuf[i] = color >> 8; + tbuf[i + 1] = color; + i += 2; + } + for (i = 0; i < 320; i++) { + // for(m=0;m<480;m++) + // { + // LCD_WR_DATA(color>>8); + // LCD_WR_DATA(color); + + SPI.dmaSend(tbuf, 960, true); + // SPI_TFT_CS_H; + // } + } + SPI_TFT_CS_H; + } + +#endif // SPI_GRAPHICAL_TFT diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h new file mode 100644 index 0000000..7d01d7a --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.h @@ -0,0 +1,55 @@ +/** + * 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 + +#define SPI_TFT_CS_H OUT_WRITE(SPI_TFT_CS_PIN, HIGH) +#define SPI_TFT_CS_L OUT_WRITE(SPI_TFT_CS_PIN, LOW) + +#define SPI_TFT_DC_H OUT_WRITE(SPI_TFT_DC_PIN, HIGH) +#define SPI_TFT_DC_L OUT_WRITE(SPI_TFT_DC_PIN, LOW) + +#define SPI_TFT_RST_H OUT_WRITE(SPI_TFT_RST_PIN, HIGH) +#define SPI_TFT_RST_L OUT_WRITE(SPI_TFT_RST_PIN, LOW) + +#define SPI_TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH) +#define SPI_TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW) + +class TFT { +public: + void spi_init(uint8_t spiRate); + uint8_t spi_Rec(); + uint8_t spi_read_write_byte(uint8_t data); + void spi_Read(uint8_t* buf, uint16_t nbyte); + void spi_Send(uint8_t b); + void spi_SendBlock(uint8_t token, const uint8_t* buf); + void LCD_WR_REG(uint8_t cmd); + void LCD_WR_DATA(uint8_t data); + void SetCursor(uint16_t x, uint16_t y); + void SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height); + void LCD_init(); + void LCD_clear(uint16_t color); + void LCD_WriteRAM_Prepare(); +}; + +extern TFT SPI_TFT; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/W25Qxx.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/W25Qxx.cpp new file mode 100644 index 0000000..21ed3f9 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/W25Qxx.cpp @@ -0,0 +1,395 @@ +/** + * 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 1 // ENABLED(SPI_FLASH) +#if ENABLED(TFT_LITTLE_VGL_UI) + +#include +#include "../../../../inc/MarlinConfig.h" + +#include "W25Qxx.h" + +#ifndef SPI_FLASH_MISO_PIN + #define SPI_FLASH_MISO_PIN W25QXX_MISO_PIN +#endif +#ifndef SPI_FLASH_MOSI_PIN + #define SPI_FLASH_MOSI_PIN W25QXX_MOSI_PIN +#endif +#ifndef SPI_FLASH_SCK_PIN + #define SPI_FLASH_SCK_PIN W25QXX_SCK_PIN +#endif +#ifndef SPI_FLASH_CS_PIN + #define SPI_FLASH_CS_PIN W25QXX_CS_PIN +#endif + +#define W25QXX_CS_H OUT_WRITE(SPI_FLASH_CS_PIN, HIGH) +#define W25QXX_CS_L OUT_WRITE(SPI_FLASH_CS_PIN, LOW) + +ext_FLASH W25QXX; + +void ext_FLASH::init(uint8_t spiRate) { + + OUT_WRITE(SPI_FLASH_CS_PIN, HIGH); + + /** + * STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz + * STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1 + * so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2 + */ + #if SPI_DEVICE == 1 + #define SPI_CLOCK_MAX SPI_CLOCK_DIV4 + #else + #define SPI_CLOCK_MAX SPI_CLOCK_DIV2 + #endif + uint8_t clock; + switch (spiRate) { + case SPI_FULL_SPEED: clock = SPI_CLOCK_MAX; break; + case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4; break; + case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8; break; + case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break; + case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break; + case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break; + default: clock = SPI_CLOCK_DIV2;// Default from the SPI library + } + SPI.setModule(SPI_DEVICE); + SPI.begin(); + SPI.setClockDivider(clock); + SPI.setBitOrder(MSBFIRST); + SPI.setDataMode(SPI_MODE0); +} + +/** + * @brief Receive a single byte from the SPI port. + * + * @return Byte received + * + * @details + */ +uint8_t ext_FLASH::spi_flash_Rec() { + uint8_t returnByte = SPI.transfer(ff); + return returnByte; +} + +uint8_t ext_FLASH::spi_flash_read_write_byte(uint8_t data) { + uint8_t returnByte = SPI.transfer(data); + return returnByte; +} + +/** + * @brief Receive a number of bytes from the SPI port to a buffer + * + * @param buf Pointer to starting address of buffer to write to. + * @param nbyte Number of bytes to receive. + * @return Nothing + * + * @details Uses DMA + */ +void ext_FLASH::spi_flash_Read(uint8_t* buf, uint16_t nbyte) { SPI.dmaTransfer(0, const_cast(buf), nbyte); } + +/** + * @brief Send a single byte on SPI port + * + * @param b Byte to send + * + * @details + */ +void ext_FLASH::spi_flash_Send(uint8_t b) { SPI.send(b); } + +/** + * @brief Write token and then write from 512 byte buffer to SPI (for SD card) + * + * @param buf Pointer with buffer start address + * @return Nothing + * + * @details Use DMA + */ +void ext_FLASH::spi_flash_SendBlock(uint8_t token, const uint8_t* buf) { + SPI.send(token); + SPI.dmaSend(const_cast(buf), 512); +} + +uint16_t ext_FLASH::W25QXX_ReadID(void) { + uint16_t Temp = 0; + W25QXX_CS_L; + spi_flash_Send(0x90);//���Ͷ�ȡID���� + spi_flash_Send(0x00); + spi_flash_Send(0x00); + spi_flash_Send(0x00); + Temp |= spi_flash_Rec() << 8; + Temp |= spi_flash_Rec(); + W25QXX_CS_H; + return Temp; +} + +void ext_FLASH::SPI_FLASH_WriteEnable(void) { + /* Select the FLASH: Chip Select low */ + W25QXX_CS_L; + /* Send "Write Enable" instruction */ + spi_flash_Send(W25X_WriteEnable); + /* Deselect the FLASH: Chip Select high */ + W25QXX_CS_H; +} + +/******************************************************************************* +* Function Name : SPI_FLASH_WaitForWriteEnd +* Description : Polls the status of the Write In Progress (WIP) flag in the +* FLASH's status register and loop until write opertaion +* has completed. +* Input : None +* Output : None +* Return : None +*******************************************************************************/ +void ext_FLASH::SPI_FLASH_WaitForWriteEnd(void) { + uint8_t FLASH_Status = 0; + + /* Select the FLASH: Chip Select low */ + W25QXX_CS_L; + /* Send "Read Status Register" instruction */ + spi_flash_Send(W25X_ReadStatusReg); + + /* Loop as long as the memory is busy with a write cycle */ + do + /* Send a dummy byte to generate the clock needed by the FLASH + and put the value of the status register in FLASH_Status variable */ + FLASH_Status = spi_flash_Rec(); + while ((FLASH_Status & WIP_Flag) == 0x01); /* Write in progress */ + + /* Deselect the FLASH: Chip Select high */ + W25QXX_CS_H; +} + +void ext_FLASH::SPI_FLASH_SectorErase(uint32_t SectorAddr) { + /* Send write enable instruction */ + SPI_FLASH_WriteEnable(); + + /* Sector Erase */ + /* Select the FLASH: Chip Select low */ + W25QXX_CS_L; + /* Send Sector Erase instruction */ + spi_flash_Send(W25X_SectorErase); + /* Send SectorAddr high nibble address byte */ + spi_flash_Send((SectorAddr & 0xFF0000) >> 16); + /* Send SectorAddr medium nibble address byte */ + spi_flash_Send((SectorAddr & 0xFF00) >> 8); + /* Send SectorAddr low nibble address byte */ + spi_flash_Send(SectorAddr & 0xFF); + /* Deselect the FLASH: Chip Select high */ + + W25QXX_CS_H; + /* Wait the end of Flash writing */ + SPI_FLASH_WaitForWriteEnd(); +} + +void ext_FLASH::SPI_FLASH_BlockErase(uint32_t BlockAddr) { + SPI_FLASH_WriteEnable(); + W25QXX_CS_L; + /* Send Sector Erase instruction */ + spi_flash_Send(W25X_BlockErase); + /* Send SectorAddr high nibble address byte */ + spi_flash_Send((BlockAddr & 0xFF0000) >> 16); + /* Send SectorAddr medium nibble address byte */ + spi_flash_Send((BlockAddr & 0xFF00) >> 8); + /* Send SectorAddr low nibble address byte */ + spi_flash_Send(BlockAddr & 0xFF); + + W25QXX_CS_H; + + SPI_FLASH_WaitForWriteEnd(); +} + +/******************************************************************************* +* Function Name : SPI_FLASH_BulkErase +* Description : Erases the entire FLASH. +* Input : None +* Output : None +* Return : None +*******************************************************************************/ +void ext_FLASH::SPI_FLASH_BulkErase(void) { + /* Send write enable instruction */ + SPI_FLASH_WriteEnable(); + + /* Bulk Erase */ + /* Select the FLASH: Chip Select low */ + W25QXX_CS_L; + + /* Send Bulk Erase instruction */ + spi_flash_Send(W25X_ChipErase); + /* Deselect the FLASH: Chip Select high */ + W25QXX_CS_H; + /* Wait the end of Flash writing */ + SPI_FLASH_WaitForWriteEnd(); +} + +/******************************************************************************* +* Function Name : SPI_FLASH_PageWrite +* Description : Writes more than one byte to the FLASH with a single WRITE +* cycle(Page WRITE sequence). The number of byte can't exceed +* the FLASH page size. +* Input : - pBuffer : pointer to the buffer containing the data to be +* written to the FLASH. +* - WriteAddr : FLASH's internal address to write to. +* - NumByteToWrite : number of bytes to write to the FLASH, +* must be equal or less than "SPI_FLASH_PageSize" value. +* Output : None +* Return : None +*******************************************************************************/ +void ext_FLASH::SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { + /* Enable the write access to the FLASH */ + SPI_FLASH_WriteEnable(); + + /* Select the FLASH: Chip Select low */ + W25QXX_CS_L; + /* Send "Write to Memory " instruction */ + spi_flash_Send(W25X_PageProgram); + /* Send WriteAddr high nibble address byte to write to */ + spi_flash_Send((WriteAddr & 0xFF0000) >> 16); + /* Send WriteAddr medium nibble address byte to write to */ + spi_flash_Send((WriteAddr & 0xFF00) >> 8); + /* Send WriteAddr low nibble address byte to write to */ + spi_flash_Send(WriteAddr & 0xFF); + + NOMORE(NumByteToWrite, SPI_FLASH_PerWritePageSize); + + /* while there is data to be written on the FLASH */ + while (NumByteToWrite--) { + /* Send the current byte */ + spi_flash_Send(*pBuffer); + /* Point on the next byte to be written */ + pBuffer++; + } + + /* Deselect the FLASH: Chip Select high */ + W25QXX_CS_H; + + /* Wait the end of Flash writing */ + SPI_FLASH_WaitForWriteEnd(); +} + +/******************************************************************************* +* Function Name : SPI_FLASH_BufferWrite +* Description : Writes block of data to the FLASH. In this function, the +* number of WRITE cycles are reduced, using Page WRITE sequence. +* Input : - pBuffer : pointer to the buffer containing the data to be +* written to the FLASH. +* - WriteAddr : FLASH's internal address to write to. +* - NumByteToWrite : number of bytes to write to the FLASH. +* Output : None +* Return : None +*******************************************************************************/ +void ext_FLASH::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { + uint8_t NumOfPage = 0, NumOfSingle = 0, Addr = 0, count = 0, temp = 0; + + Addr = WriteAddr % SPI_FLASH_PageSize; + count = SPI_FLASH_PageSize - Addr; + NumOfPage = NumByteToWrite / SPI_FLASH_PageSize; + NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize; + + if (Addr == 0) { /* WriteAddr is SPI_FLASH_PageSize aligned */ + if (NumOfPage == 0) { /* NumByteToWrite < SPI_FLASH_PageSize */ + SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite); + } + else { /* NumByteToWrite > SPI_FLASH_PageSize */ + while (NumOfPage--) { + SPI_FLASH_PageWrite(pBuffer, WriteAddr, SPI_FLASH_PageSize); + WriteAddr += SPI_FLASH_PageSize; + pBuffer += SPI_FLASH_PageSize; + } + SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumOfSingle); + } + } + else { /* WriteAddr is not SPI_FLASH_PageSize aligned */ + if (NumOfPage == 0) { /* NumByteToWrite < SPI_FLASH_PageSize */ + if (NumOfSingle > count) { /* (NumByteToWrite + WriteAddr) > SPI_FLASH_PageSize */ + temp = NumOfSingle - count; + SPI_FLASH_PageWrite(pBuffer, WriteAddr, count); + WriteAddr += count; + pBuffer += count; + SPI_FLASH_PageWrite(pBuffer, WriteAddr, temp); + } + else { + SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite); + } + } + else { /* NumByteToWrite > SPI_FLASH_PageSize */ + NumByteToWrite -= count; + NumOfPage = NumByteToWrite / SPI_FLASH_PageSize; + NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize; + + SPI_FLASH_PageWrite(pBuffer, WriteAddr, count); + WriteAddr += count; + pBuffer += count; + + while (NumOfPage--) { + SPI_FLASH_PageWrite(pBuffer, WriteAddr, SPI_FLASH_PageSize); + WriteAddr += SPI_FLASH_PageSize; + pBuffer += SPI_FLASH_PageSize; + } + + if (NumOfSingle != 0) + SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumOfSingle); + } + } +} + +/******************************************************************************* +* Function Name : SPI_FLASH_BufferRead +* Description : Reads a block of data from the FLASH. +* Input : - pBuffer : pointer to the buffer that receives the data read +* from the FLASH. +* - ReadAddr : FLASH's internal address to read from. +* - NumByteToRead : number of bytes to read from the FLASH. +* Output : None +* Return : None +*******************************************************************************/ +void ext_FLASH::SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) { + /* Select the FLASH: Chip Select low */ + W25QXX_CS_L; + + /* Send "Read from Memory " instruction */ + spi_flash_Send(W25X_ReadData); + + /* Send ReadAddr high nibble address byte to read from */ + spi_flash_Send((ReadAddr & 0xFF0000) >> 16); + /* Send ReadAddr medium nibble address byte to read from */ + spi_flash_Send((ReadAddr & 0xFF00) >> 8); + /* Send ReadAddr low nibble address byte to read from */ + spi_flash_Send(ReadAddr & 0xFF); + + if (NumByteToRead < 33) { + while (NumByteToRead--) { /* while there is data to be read */ + /* Read a byte from the FLASH */ + *pBuffer = spi_flash_Rec(); + /* Point to the next location where the byte read will be saved */ + pBuffer++; + } + } + else { + spi_flash_Read(pBuffer, NumByteToRead); + } + W25QXX_CS_H; +} + +void ext_FLASH::lv_pic_read(uint8_t *P_Rbuff, uint32_t addr, uint32_t size) {SPI_FLASH_BufferRead((uint8_t *)P_Rbuff, addr, size);} + +#endif // TFT_LITTLE_VGL_UI +#endif // 1 ... SPI_FLASH diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/W25Qxx.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/W25Qxx.h new file mode 100644 index 0000000..89b22c3 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/W25Qxx.h @@ -0,0 +1,127 @@ +/** + * 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 + +#include + +#define W25X_WriteEnable 0x06 +#define W25X_WriteDisable 0x04 +#define W25X_ReadStatusReg 0x05 +#define W25X_WriteStatusReg 0x01 +#define W25X_ReadData 0x03 +#define W25X_FastReadData 0x0B +#define W25X_FastReadDual 0x3B +#define W25X_PageProgram 0x02 +#define W25X_BlockErase 0xD8 +#define W25X_SectorErase 0x20 +#define W25X_ChipErase 0xC7 +#define W25X_PowerDown 0xB9 +#define W25X_ReleasePowerDown 0xAB +#define W25X_DeviceID 0xAB +#define W25X_ManufactDeviceID 0x90 +#define W25X_JedecDeviceID 0x9F + +#define WIP_Flag 0x01 /* Write In Progress (WIP) flag */ + +#define Dummy_Byte 0xA5 + +#define SPI_FLASH_SectorSize 4096 +#define SPI_FLASH_PageSize 256 +#define SPI_FLASH_PerWritePageSize 256 + +#if 0 + + #define PIC_NAME_MAX_LEN 50 + + #define LOGO_MAX_SIZE (300*1024)//logo���ֵ + #define TITLELOGO_MAX_SIZE (150*1024)//logo���ֵ + #define DEFAULT_VIEW_MAX_SIZE (200*200*2) + #define FLASH_VIEW_MAX_SIZE (200*200*2) + + //ͼƬ + //Robin2�洢��ַ + #define PIC_NAME_ADDR 0x003000 //ͼƬ��Ϣ�洢��ַ��ͼƬ���� + #define PIC_SIZE_ADDR 0x007000 //ͼƬ��Ϣ�洢��ַ��ͼƬ��Сֵ + #define PIC_COUNTER_ADDR 0x008000 //ͼƬ������ֵ�洢��ַ + #define PIC_LOGO_ADDR 0x009000 //ͼƬlogo�洢��ַ + //#define PIC_DATA_ADDR 0x02f000 //ͼƬ���ݴ洢��ַ + + #define DEFAULT_VIEW_ADDR 0XC5800 + #define BAK_VIEW_ADDR (DEFAULT_VIEW_ADDR+90*1024) + #define PIC_ICON_LOGO_ADDR (BAK_VIEW_ADDR+80*1024) + + #define PIC_DATA_ADDR (PIC_ICON_LOGO_ADDR+350*1024) //ͼƬ���ݴ洢��ַ//(800*240) + + // �ֿ� + #define FONTINFOADDR 0x600000 // 6M�Ժ��ַΪ�ֿ� + #define UNIGBK_FLASH_ADDR (FONTINFOADDR+4096) // 4*1024 + #define GBK_FLASH_ADDR (UNIGBK_FLASH_ADDR+180224) // 176*1024 + + #define PER_PIC_MAX_SPACE (32*1024) // Ϊ�˷�ֹ����Խ������⣬ÿ��СͼƬ�����仮��Ӧ��ȡ�ܹ�����4K��ֵ + + // + union union32 { + uint8_t bytes[4]; + uint32_t dwords; + }; + // ͼƬ��Ϣ�ṹ�� + struct pic_msg { + uint8_t name[PIC_NAME_MAX_LEN]; + union union32 size; + }; + + typedef struct pic_msg PIC_MSG; + +#endif // if 0 + +class ext_FLASH { +public: + void init(uint8_t spiRate); + static uint8_t spi_flash_Rec(); + static uint8_t spi_flash_read_write_byte(uint8_t data); + static void spi_flash_Read(uint8_t* buf, uint16_t nbyte); + static void spi_flash_Send(uint8_t b); + static void spi_flash_SendBlock(uint8_t token, const uint8_t* buf); + static uint16_t W25QXX_ReadID(void); + static void SPI_FLASH_WriteEnable(void); + static void SPI_FLASH_WaitForWriteEnd(void); + static void SPI_FLASH_SectorErase(uint32_t SectorAddr); + static void SPI_FLASH_BlockErase(uint32_t BlockAddr); + static void SPI_FLASH_BulkErase(void); + static void SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); + static void SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); + static void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead); + //uint32_t lv_get_pic_addr(uint8_t *Pname); + void lv_pic_read(uint8_t *P_Rbuff, uint32_t addr, uint32_t size); +}; + +extern ext_FLASH W25QXX; + +//extern uint32_t lv_get_pic_addr(uint8_t *Pname); + +//#ifdef __cplusplus +//} /* C-declarations for C++ */ +//#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp new file mode 100644 index 0000000..8193563 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp @@ -0,0 +1,127 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" + +static lv_obj_t * scr; +static lv_obj_t * fw_type, *board, *fw_version; + +#define ID_A_RETURN 1 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_A_RETURN: + if (event == LV_EVENT_CLICKED) { + // do nothing + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + draw_return_ui(); + } + break; + } +} + +void lv_draw_about(void) { + lv_obj_t *buttonBack, *label_Back; + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ABOUT_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = ABOUT_UI; + } + disp_state = ABOUT_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + buttonBack = lv_imgbtn_create(scr, NULL); + + #if 1 + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_A_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + /*Create a label on the Image button*/ + + label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + + fw_version = lv_label_create(scr, NULL); + lv_obj_set_style(fw_version, &tft_style_lable_rel); + lv_label_set_text(fw_version, "Version: V_2.0.5.3"); + lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60); + + fw_type = lv_label_create(scr, NULL); + lv_obj_set_style(fw_type, &tft_style_lable_rel); + #if (MOTHERBOARD == BOARD_MKS_ROBIN_PRO) + lv_label_set_text(fw_type, "Firmware: Robin_Pro35"); + #elif (MOTHERBOARD == BOARD_MKS_ROBIN_NANO) + lv_label_set_text(fw_type, "Firmware: Robin_Nano35"); + #endif + lv_obj_align(fw_type, NULL, LV_ALIGN_CENTER, 0, -20); + + board = lv_label_create(scr, NULL); + lv_obj_set_style(board, &tft_style_lable_rel); + #if (MOTHERBOARD == BOARD_MKS_ROBIN_PRO) + lv_label_set_text(board, "Board: MKS Robin pro"); + #elif (MOTHERBOARD == BOARD_MKS_ROBIN_NANO) + lv_label_set_text(board, "Board: MKS Robin nano"); + #endif + + lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, 20); +} + +void lv_clear_about() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h new file mode 100644 index 0000000..5904a8a --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h @@ -0,0 +1,34 @@ +/** + * 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 + +extern void lv_draw_about(void); +extern void lv_clear_about(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp new file mode 100644 index 0000000..6d44ecb --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp @@ -0,0 +1,336 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" +#include "../../../../module/planner.h" + +static lv_obj_t * scr; +static lv_obj_t * labelStep, *buttonStep, *buttonMov, *buttonExt; +static lv_obj_t * labelMov, *labelExt; +static lv_obj_t * printSpeedText; + +#define ID_C_ADD 1 +#define ID_C_DEC 2 +#define ID_C_MOVE 3 +#define ID_C_EXT 4 +#define ID_C_STEP 5 +#define ID_C_RETURN 6 + +static uint8_t speedType; + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_C_ADD: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (speedType == 0) { + if (feedrate_percentage < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed) + feedrate_percentage += uiCfg.stepPrintSpeed; + else + feedrate_percentage = MAX_EXT_SPEED_PERCENT; + } + else if (speedType == 1) { + if (planner.flow_percentage[0] < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed) + planner.flow_percentage[0] += uiCfg.stepPrintSpeed; + else + planner.flow_percentage[0] = MAX_EXT_SPEED_PERCENT; + //planner.e_factor[0]= planner.flow_percentage[0]*0.01; + //planner.flow_percentage[1] = planner.flow_percentage[0]; + //planner.e_factor[1]= planner.flow_percentage[1]*0.01; + planner.refresh_e_factor(0); + if (EXTRUDERS == 2) { + planner.flow_percentage[1] = planner.flow_percentage[0]; + planner.refresh_e_factor(1); + } + } + disp_print_speed(); + } + break; + case ID_C_DEC: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (speedType == 0) { + if (feedrate_percentage > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed) + feedrate_percentage -= uiCfg.stepPrintSpeed; + else + feedrate_percentage = MIN_EXT_SPEED_PERCENT; + } + else if (speedType == 1) { + if (planner.flow_percentage[0] > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed) + planner.flow_percentage[0] -= uiCfg.stepPrintSpeed; + else + planner.flow_percentage[0] = MIN_EXT_SPEED_PERCENT; + //planner.e_factor[0]= planner.flow_percentage[0] * 0.01; + //planner.flow_percentage[1] = planner.flow_percentage[0]; + //planner.e_factor[1]= planner.flow_percentage[1] * 0.01; + planner.refresh_e_factor(0); + if (EXTRUDERS == 2) { + planner.flow_percentage[1] = planner.flow_percentage[0]; + planner.refresh_e_factor(1); + } + } + disp_print_speed(); + } + break; + case ID_C_MOVE: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + speedType = 0; + disp_speed_type(); + disp_print_speed(); + } + break; + case ID_C_EXT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + speedType = 1; + disp_speed_type(); + disp_print_speed(); + } + break; + case ID_C_STEP: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + if (uiCfg.stepPrintSpeed == 1) + uiCfg.stepPrintSpeed = 5; + else if (uiCfg.stepPrintSpeed == 5) + uiCfg.stepPrintSpeed = 10; + else + uiCfg.stepPrintSpeed = 1; + disp_speed_step(); + } + break; + case ID_C_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + draw_return_ui(); + } + break; + } +} + +void lv_draw_change_speed(void) { + lv_obj_t *buttonAdd, *buttonDec; + lv_obj_t *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != CHANGE_SPEED_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = CHANGE_SPEED_UI; + } + disp_state = CHANGE_SPEED_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + buttonAdd = lv_imgbtn_create(scr, NULL); + buttonDec = lv_imgbtn_create(scr, NULL); + buttonMov = lv_imgbtn_create(scr, NULL); + buttonExt = lv_imgbtn_create(scr, NULL); + buttonStep = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_C_ADD, "bmp_Add.bin", 0); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); + + #if 1 + lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_C_DEC, "bmp_Dec.bin", 0); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_lable_rel); + + + lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonMov, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonMov, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonExt, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonExt, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_C_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonAdd, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonDec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonMov, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonExt, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonStep, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonAdd, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonDec, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonMov, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonExt, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonStep, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t * labelAdd = lv_label_create(buttonAdd, NULL); + lv_obj_t * labelDec = lv_label_create(buttonDec, NULL); + labelMov = lv_label_create(buttonMov, NULL); + labelExt = lv_label_create(buttonExt, NULL); + labelStep = lv_label_create(buttonStep, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelAdd, speed_menu.add); + lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelDec, speed_menu.dec); + lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + disp_speed_type(); + disp_speed_step(); + + printSpeedText = lv_label_create(scr, NULL); + lv_obj_set_style(printSpeedText, &tft_style_lable_rel); + disp_print_speed(); +} + +void disp_speed_step() { + if (uiCfg.stepPrintSpeed == 1) + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_Step1_percent.bin", 0); + else if (uiCfg.stepPrintSpeed == 5) + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_Step5_percent.bin", 0); + else if (uiCfg.stepPrintSpeed == 10) + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_Step10_percent.bin", 0); + + if (gCfgItems.multiple_language != 0) { + if (uiCfg.stepPrintSpeed == 1) { + lv_label_set_text(labelStep, speed_menu.step_1percent); + lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if (uiCfg.stepPrintSpeed == 5) { + lv_label_set_text(labelStep, speed_menu.step_5percent); + lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if (uiCfg.stepPrintSpeed == 10) { + lv_label_set_text(labelStep, speed_menu.step_10percent); + lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void disp_print_speed() { + char buf[30] = {0}; + + public_buf_l[0] = '\0'; + + if (speedType == 0) { //move + strcat(public_buf_l, speed_menu.move_speed); + strcat(public_buf_l, ": "); + sprintf(buf, "%d%%", feedrate_percentage); + strcat(public_buf_l, buf); + } + else if (speedType == 1) { // e1 + strcat(public_buf_l, speed_menu.extrude_speed); + strcat(public_buf_l, ": "); + sprintf(buf, "%d%%", planner.flow_percentage[0]); + strcat(public_buf_l, buf); + } + lv_label_set_text(printSpeedText, public_buf_l); + lv_obj_align(printSpeedText, NULL, LV_ALIGN_CENTER, 0, -65); +} + +void disp_speed_type() { + switch (speedType) { + case 1: + lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_Extruct_speed_sel.bin", 0); + lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_Mov_speed.bin", 0); + break; + + default: + lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_Extruct_speed.bin", 0); + lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_Mov_speed_sel.bin", 0); + break; + } + lv_obj_refresh_ext_draw_pad(buttonExt); + lv_obj_refresh_ext_draw_pad(buttonMov); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelMov, speed_menu.move); + lv_obj_align(labelMov, buttonMov, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelExt, speed_menu.extrude); + lv_obj_align(labelExt, buttonExt, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } +} + +void lv_clear_change_speed() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h new file mode 100644 index 0000000..14d2b7c --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h @@ -0,0 +1,40 @@ +/** + * 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 + +#define MIN_EXT_SPEED_PERCENT 10 +#define MAX_EXT_SPEED_PERCENT 999 + +extern void lv_draw_change_speed(void); +extern void lv_clear_change_speed(); +extern void disp_speed_step(); +extern void disp_print_speed(); +extern void disp_speed_type(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp new file mode 100644 index 0000000..5620af8 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -0,0 +1,343 @@ +/** + * 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 . + * + */ + +/** + * draw_dialog.cpp + */ + +#include "../../../../inc/MarlinConfigPre.h" + +#if ENABLED(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" +#include "../../../../sd/cardreader.h" +#include "../../../../gcode/queue.h" +#include "../../../../module/temperature.h" +#include "../../../../module/planner.h" + +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../../../../feature/powerloss.h" +#endif + +#if ENABLED(PARK_HEAD_ON_PAUSE) + #include "../../../../feature/pause.h" +#endif + +static lv_obj_t * scr; +extern uint8_t sel_id; +extern uint8_t once_flag; +extern uint8_t gcode_preview_over; +uint8_t DialogType; + +static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) { + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (DialogType == DIALOG_TYPE_PRINT_FILE) { + preview_gcode_prehandle(list_file.file_name[sel_id]); + reset_print_time(); + start_print_time(); + + uiCfg.print_state = WORKING; + lv_clear_dialog(); + lv_draw_printing(); + + #if ENABLED(SDSUPPORT) + if (gcode_preview_over != 1) { + char *cur_name; + cur_name = strrchr(list_file.file_name[sel_id], '/'); + + SdFile file, *curDir; + card.endFilePrint(); + const char * const fname = card.diveToFile(true, curDir, cur_name); + if (!fname) return; + if (file.open(curDir, fname, O_READ)) { + gCfgItems.curFilesize = file.fileSize(); + file.close(); + update_spi_flash(); + } + card.openFileRead(cur_name); + if (card.isFileOpen()) { + feedrate_percentage = 100; + //saved_feedrate_percentage = feedrate_percentage; + planner.flow_percentage[0] = 100; + planner.e_factor[0] = planner.flow_percentage[0] * 0.01f; + #if EXTRUDERS == 2 + planner.flow_percentage[1] = 100; + planner.e_factor[1] = planner.flow_percentage[1] * 0.01f; + #endif + card.startFileprint(); + #if ENABLED(POWER_LOSS_RECOVERY) + recovery.prepare(); + #endif + once_flag = 0; + } + } + #endif + } + else if (DialogType == DIALOG_TYPE_STOP) { + stop_print_time(); + lv_clear_dialog(); + lv_draw_ready_print(); + + #if ENABLED(SDSUPPORT) + //card.endFilePrint(); + //wait_for_heatup = false; + uiCfg.print_state = IDLE; + card.flag.abort_sd_printing = true; + //queue.clear(); + //quickstop_stepper(); + //print_job_timer.stop(); + //thermalManager.disable_all_heaters(); + + //#if ENABLED(POWER_LOSS_RECOVERY) + //recovery.purge(); + //#endif + //queue.enqueue_one_now(PSTR("G91")); + //queue.enqueue_one_now(PSTR("G1 Z10")); + //queue.enqueue_one_now(PSTR("G90")); + //queue.enqueue_one_now(PSTR("G28 X0 Y0")); + //queue.inject_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0\nM84\nM107")); + #endif + } + else if (DialogType == DIALOG_TYPE_FINISH_PRINT) { + clear_cur_ui(); + lv_draw_ready_print(); + } + #if ENABLED(ADVANCED_PAUSE_FEATURE) + else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING + || DialogType == DIALOG_PAUSE_MESSAGE_INSERT + || DialogType == DIALOG_PAUSE_MESSAGE_HEAT + ) { + wait_for_user = false; + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) { + pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_RESUME) { + clear_cur_ui(); + draw_return_ui(); + } + #endif + } +} + +static void btn_cancel_event_cb(lv_obj_t * btn, lv_event_t event) { + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) { + #if ENABLED(ADVANCED_PAUSE_FEATURE) + pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; + #endif + } + else { + clear_cur_ui(); + draw_return_ui(); + } + } +} + +void lv_draw_dialog(uint8_t type) { + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != DIALOG_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = DIALOG_UI; + } + disp_state = DIALOG_UI; + + DialogType = type; + + scr = lv_obj_create(NULL, NULL); + + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + //LV_IMG_DECLARE(bmp_pic); + + static lv_style_t style_btn_rel; // A variable to store the released style + lv_style_copy(&style_btn_rel, &lv_style_plain); // Initialize from a built-in style + style_btn_rel.body.border.color = lv_color_hex3(0x269); + style_btn_rel.body.border.width = 1; + style_btn_rel.body.main_color = lv_color_hex3(0xADF); + style_btn_rel.body.grad_color = lv_color_hex3(0x46B); + style_btn_rel.body.shadow.width = 4; + style_btn_rel.body.shadow.type = LV_SHADOW_BOTTOM; + style_btn_rel.body.radius = LV_RADIUS_CIRCLE; + style_btn_rel.text.color = lv_color_hex3(0xDEF); + style_btn_rel.text.font = &gb2312_puhui32; + + static lv_style_t style_btn_pr; // A variable to store the pressed style + lv_style_copy(&style_btn_pr, &style_btn_rel); // Initialize from the released style + style_btn_pr.body.border.color = lv_color_hex3(0x46B); + style_btn_pr.body.main_color = lv_color_hex3(0x8BD); + style_btn_pr.body.grad_color = lv_color_hex3(0x24A); + style_btn_pr.body.shadow.width = 2; + style_btn_pr.text.color = lv_color_hex3(0xBCD); + style_btn_pr.text.font = &gb2312_puhui32; + + lv_obj_t * labelDialog = lv_label_create(scr, NULL); + lv_obj_set_style(labelDialog, &tft_style_lable_rel); + + if (DialogType == DIALOG_TYPE_FINISH_PRINT || DialogType == DIALOG_PAUSE_MESSAGE_RESUME) { + lv_obj_t * btnOk = lv_btn_create(scr, NULL); // Add a button the current screen + lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y); // Set its position + lv_obj_set_size(btnOk, 100, 50); // Set its size + lv_obj_set_event_cb(btnOk, btn_ok_event_cb); + lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style + lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style + lv_obj_t * labelOk = lv_label_create(btnOk, NULL); // Add a label to the button + lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING + || DialogType == DIALOG_PAUSE_MESSAGE_INSERT + || DialogType == DIALOG_PAUSE_MESSAGE_HEAT) { + lv_obj_t * btnOk = lv_btn_create(scr, NULL); // Add a button the current screen + lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y); // Set its position + lv_obj_set_size(btnOk, 100, 50); // Set its size + lv_obj_set_event_cb(btnOk, btn_ok_event_cb); + lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style + lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style + lv_obj_t * labelOk = lv_label_create(btnOk, NULL); // Add a label to the button + lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_PAUSING + || DialogType == DIALOG_PAUSE_MESSAGE_CHANGING + || DialogType == DIALOG_PAUSE_MESSAGE_UNLOAD + || DialogType == DIALOG_PAUSE_MESSAGE_LOAD + || DialogType == DIALOG_PAUSE_MESSAGE_PURGE + || DialogType == DIALOG_PAUSE_MESSAGE_RESUME + || DialogType == DIALOG_PAUSE_MESSAGE_HEATING + ) { + // nothing to do + } + else { + lv_obj_t * btnOk = lv_btn_create(scr, NULL); // Add a button the current screen + lv_obj_set_pos(btnOk, BTN_OK_X, BTN_OK_Y); // Set its position + lv_obj_set_size(btnOk, 100, 50); // Set its size + lv_obj_set_event_cb(btnOk, btn_ok_event_cb); + lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style + lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style + lv_obj_t * labelOk = lv_label_create(btnOk, NULL); // Add a label to the button + + lv_obj_t * btnCancel = lv_btn_create(scr, NULL); // Add a button the current screen + lv_obj_set_pos(btnCancel, BTN_CANCEL_X, BTN_CANCEL_Y); // Set its position + lv_obj_set_size(btnCancel, 100, 50); // Set its size + lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style + lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style + lv_obj_t * labelCancel = lv_label_create(btnCancel, NULL); // Add a label to the button + + if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) { + lv_label_set_text(labelOk, pause_msg_menu.purgeMore); // Set the labels text + lv_label_set_text(labelCancel, pause_msg_menu.continuePrint); + } + else { + lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text + lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); + } + } + if (DialogType == DIALOG_TYPE_PRINT_FILE) { + lv_label_set_text(labelDialog, print_file_dialog_menu.print_file); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + + lv_obj_t * labelFile = lv_label_create(scr, NULL); + lv_obj_set_style(labelFile, &tft_style_lable_rel); + + lv_label_set_text(labelFile, list_file.long_name[sel_id]); + lv_obj_align(labelFile, NULL, LV_ALIGN_CENTER, 0, -60); + } + else if (DialogType == DIALOG_TYPE_STOP) { + lv_label_set_text(labelDialog, print_file_dialog_menu.cancle_print); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_TYPE_FINISH_PRINT) { + lv_label_set_text(labelDialog, print_file_dialog_menu.print_finish); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_PAUSING) { + lv_label_set_text(labelDialog, pause_msg_menu.pausing); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_CHANGING) { + lv_label_set_text(labelDialog, pause_msg_menu.changing); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_UNLOAD) { + lv_label_set_text(labelDialog, pause_msg_menu.unload); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING) { + lv_label_set_text(labelDialog, pause_msg_menu.waiting); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_INSERT) { + lv_label_set_text(labelDialog, pause_msg_menu.insert); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_LOAD) { + lv_label_set_text(labelDialog, pause_msg_menu.load); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_PURGE) { + lv_label_set_text(labelDialog, pause_msg_menu.purge); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_RESUME) { + lv_label_set_text(labelDialog, pause_msg_menu.resume); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_HEAT) { + lv_label_set_text(labelDialog, pause_msg_menu.heat); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_HEATING) { + lv_label_set_text(labelDialog, pause_msg_menu.heating); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) { + lv_label_set_text(labelDialog, pause_msg_menu.option); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } +} + +void lv_clear_dialog() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h new file mode 100644 index 0000000..894675b --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h @@ -0,0 +1,79 @@ +/** + * 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 + +#define DIALOG_TYPE_STOP 0 +#define DIALOG_TYPE_PRINT_FILE 1 +#define DIALOG_TYPE_REPRINT_NO_FILE 2 + +#define DIALOG_TYPE_M80_FAIL 3 //** +#define DIALOG_TYPE_MESSEGE_ERR1 4 //** + +#define DIALOG_TYPE_UPDATE_ESP_FIRMARE 5 +#define DIALOG_TYPE_UPDATE_ESP_DATA 6 +#define DIALOG_TYPE_UPLOAD_FILE 7 +#define DIALOG_TYPE_UNBIND 8 + +#define DIALOG_TYPE_FILAMENT_LOAD_HEAT 9 +#define DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED 10 +#define DIALOG_TYPE_FILAMENT_LOADING 11 +#define DIALOG_TYPE_FILAMENT_LOAD_COMPLETED 12 +#define DIALOG_TYPE_FILAMENT_UNLOAD_HEAT 13 +#define DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED 14 +#define DIALOG_TYPE_FILAMENT_UNLOADING 15 +#define DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED 16 + +#define DIALOG_TYPE_FILE_LOADING 17 //** + +#define DIALOG_TYPE_FILAMENT_NO_PRESS 18 +#define DIALOG_TYPE_FINISH_PRINT 19 + +#define WIFI_ENABLE_TIPS 20 + +#define DIALOG_PAUSE_MESSAGE_PAUSING 21 +#define DIALOG_PAUSE_MESSAGE_CHANGING 22 +#define DIALOG_PAUSE_MESSAGE_UNLOAD 23 +#define DIALOG_PAUSE_MESSAGE_WAITING 24 +#define DIALOG_PAUSE_MESSAGE_INSERT 25 +#define DIALOG_PAUSE_MESSAGE_LOAD 26 +#define DIALOG_PAUSE_MESSAGE_PURGE 27 +#define DIALOG_PAUSE_MESSAGE_RESUME 28 +#define DIALOG_PAUSE_MESSAGE_HEAT 29 +#define DIALOG_PAUSE_MESSAGE_HEATING 30 +#define DIALOG_PAUSE_MESSAGE_OPTION 31 + +#define BTN_OK_X 100 +#define BTN_OK_Y 180 +#define BTN_CANCEL_X 280 +#define BTN_CANCEL_Y 180 + +extern void lv_draw_dialog(uint8_t type); +extern void lv_clear_dialog(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp new file mode 100644 index 0000000..de57804 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp @@ -0,0 +1,84 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +#include "tft_lvgl_configuration.h" +#include "mks_hardware_test.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" + +static lv_obj_t * scr; + +void lv_draw_error_message(PGM_P const msg) { + #if 0 + static lv_obj_t * message = NULL, *kill_message = NULL, *reset_tips = NULL; + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ERROR_MESSAGE_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = ERROR_MESSAGE_UI; + } + disp_state = ERROR_MESSAGE_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + if (msg) { + message = lv_label_create(scr, NULL); + lv_obj_set_style(message, &tft_style_lable_rel); + lv_label_set_text(message, msg); + lv_obj_align(message, NULL, LV_ALIGN_CENTER, 0, -50); + } + + kill_message = lv_label_create(scr, NULL); + lv_obj_set_style(kill_message, &tft_style_lable_rel); + lv_label_set_text(kill_message, "PRINTER HALTED"); + lv_obj_align(kill_message, NULL, LV_ALIGN_CENTER, 0, -10); + + reset_tips = lv_label_create(scr, NULL); + lv_obj_set_style(reset_tips, &tft_style_lable_rel); + lv_label_set_text(reset_tips, "Please Reset"); + lv_obj_align(reset_tips, NULL, LV_ALIGN_CENTER, 0, 30); + + lv_task_handler(); + #endif + 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); + +} + +void lv_clear_error_message() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h new file mode 100644 index 0000000..53071f9 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h @@ -0,0 +1,34 @@ +/** + * 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 + +extern void lv_draw_error_message(PGM_P const msg); +extern void lv_clear_error_message(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp new file mode 100644 index 0000000..14d7ed0 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -0,0 +1,378 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" +#include "../../../../gcode/queue.h" + +static lv_obj_t * scr; +static lv_obj_t * buttoType, *buttonStep, *buttonSpeed; +static lv_obj_t * labelType; +static lv_obj_t * labelStep; +static lv_obj_t * labelSpeed; +static lv_obj_t * tempText; +static lv_obj_t * ExtruText; + +#define ID_E_ADD 1 +#define ID_E_DEC 2 +#define ID_E_TYPE 3 +#define ID_E_STEP 4 +#define ID_E_SPEED 5 +#define ID_E_RETURN 6 + +static int32_t extructAmount; + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_E_ADD: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) { + queue.enqueue_one_now(PSTR("G91")); + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf((char *)public_buf_l, "G1 E%d F%d", uiCfg.extruStep, 60 * uiCfg.extruSpeed); + queue.enqueue_one_now(PSTR(public_buf_l)); + queue.enqueue_one_now(PSTR("G90")); + extructAmount += uiCfg.extruStep; + disp_extru_amount(); + } + } + break; + case ID_E_DEC: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) { + queue.enqueue_one_now(PSTR("G91")); + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf((char *)public_buf_l, "G1 E%d F%d", 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed); + queue.enqueue_one_now(PSTR(public_buf_l)); + queue.enqueue_one_now(PSTR("G90")); + extructAmount -= uiCfg.extruStep; + disp_extru_amount(); + } + } + break; + case ID_E_TYPE: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (EXTRUDERS == 2) { + if (uiCfg.curSprayerChoose == 0) { + uiCfg.curSprayerChoose = 1; + queue.inject_P(PSTR("T1")); + } + else { + uiCfg.curSprayerChoose = 0; + queue.inject_P(PSTR("T0")); + } + } + else { + uiCfg.curSprayerChoose = 0; + } + extructAmount = 0; + disp_hotend_temp(); + disp_ext_type(); + disp_extru_amount(); + } + break; + case ID_E_STEP: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + switch (abs(uiCfg.extruStep)) { + case 1: uiCfg.extruStep = 5; break; + case 5: uiCfg.extruStep = 10; break; + case 10: uiCfg.extruStep = 1; break; + default: break; + } + disp_ext_step(); + } + break; + case ID_E_SPEED: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + switch (uiCfg.extruSpeed) { + case 1: uiCfg.extruSpeed = 10; break; + case 10: uiCfg.extruSpeed = 20; break; + case 20: uiCfg.extruSpeed = 1; break; + default: break; + } + disp_ext_speed(); + } + break; + case ID_E_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + draw_return_ui(); + } + break; + } +} + + +void lv_draw_extrusion(void) { + lv_obj_t *buttonAdd, *buttonDec, *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EXTRUSION_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = EXTRUSION_UI; + } + disp_state = EXTRUSION_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + buttonAdd = lv_imgbtn_create(scr, NULL); + buttonDec = lv_imgbtn_create(scr, NULL); + buttoType = lv_imgbtn_create(scr, NULL); + buttonStep = lv_imgbtn_create(scr, NULL); + buttonSpeed = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_E_ADD, "bmp_In.bin", 0); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); + + #if 1 + lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_E_DEC, "bmp_Out.bin", 0); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_E_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonAdd, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonDec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttoType, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonStep, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonSpeed, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonAdd, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonDec, LV_LAYOUT_OFF); + lv_btn_set_layout(buttoType, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonStep, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonSpeed, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t * labelAdd = lv_label_create(buttonAdd, NULL); + lv_obj_t * labelDec = lv_label_create(buttonDec, NULL); + labelType = lv_label_create(buttoType, NULL); + labelStep = lv_label_create(buttonStep, NULL); + labelSpeed = lv_label_create(buttonSpeed, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelAdd, extrude_menu.in); + lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelDec, extrude_menu.out); + lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + + disp_ext_type(); + disp_ext_step(); + disp_ext_speed(); + + tempText = lv_label_create(scr, NULL); + lv_obj_set_style(tempText, &tft_style_lable_rel); + disp_hotend_temp(); + + ExtruText = lv_label_create(scr, NULL); + lv_obj_set_style(ExtruText, &tft_style_lable_rel); + disp_extru_amount(); +} + +void disp_ext_type() { + if (uiCfg.curSprayerChoose == 1) { + lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, "bmp_Extru2.bin", 0); + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelType, extrude_menu.ext2); + lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } + else { + lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, "bmp_Extru1.bin", 0); + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelType, extrude_menu.ext1); + lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void disp_ext_speed() { + if (uiCfg.extruSpeed == 20) + lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_Speed_high.bin", 0); + else if (uiCfg.extruSpeed == 1) + lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_Speed_slow.bin", 0); + else + lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_Speed_normal.bin", 0); + + if (gCfgItems.multiple_language != 0) { + if (uiCfg.extruSpeed == 20) { + lv_label_set_text(labelSpeed, extrude_menu.high); + lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if (uiCfg.extruSpeed == 1) { + lv_label_set_text(labelSpeed, extrude_menu.low); + lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else { + lv_label_set_text(labelSpeed, extrude_menu.normal); + lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void disp_hotend_temp() { + char buf[20] = {0}; + public_buf_l[0] = '\0'; + strcat(public_buf_l, extrude_menu.temper_text); + sprintf(buf, extrude_menu.temp_value, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); + strcat(public_buf_l, buf); + lv_label_set_text(tempText, public_buf_l); + lv_obj_align(tempText, NULL, LV_ALIGN_CENTER, 0, -50); +} + +void disp_extru_amount() { + char buf1[10] = {0}; + + public_buf_l[0] = '\0'; + + if (extructAmount < 999 && extructAmount > -99) { + sprintf(buf1, extrude_menu.count_value_mm, extructAmount); + if (uiCfg.curSprayerChoose < 1) + strcat(public_buf_l, extrude_menu.ext1); + else + strcat(public_buf_l, extrude_menu.ext2); + strcat(public_buf_l, buf1); + } + else if (extructAmount < 9999 && extructAmount > -999) { + sprintf(buf1, extrude_menu.count_value_cm, extructAmount / 10); + if (uiCfg.curSprayerChoose < 1) + strcat(public_buf_l, extrude_menu.ext1); + else + strcat(public_buf_l, extrude_menu.ext2); + strcat(public_buf_l, buf1); + } + else { + sprintf(buf1, extrude_menu.count_value_m, extructAmount / 1000); + if (uiCfg.curSprayerChoose < 1) + strcat(public_buf_l, extrude_menu.ext1); + else + strcat(public_buf_l, extrude_menu.ext2); + strcat(public_buf_l, buf1); + } + + lv_label_set_text(ExtruText, public_buf_l); + lv_obj_align(ExtruText, NULL, LV_ALIGN_CENTER, 0, -75); +} + +void disp_ext_step() { + if (uiCfg.extruStep == 1) + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_Step1_mm.bin", 0); + else if (uiCfg.extruStep == 5) + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_Step5_mm.bin", 0); + else if (uiCfg.extruStep == 10) + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_Step10_mm.bin", 0); + + if (gCfgItems.multiple_language != 0) { + if (uiCfg.extruStep == 1) { + lv_label_set_text(labelStep, extrude_menu.step_1mm); + lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if (uiCfg.extruStep == 5) { + lv_label_set_text(labelStep, extrude_menu.step_5mm); + lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if (uiCfg.extruStep == 10) { + lv_label_set_text(labelStep, extrude_menu.step_10mm); + lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void lv_clear_extrusion() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h new file mode 100644 index 0000000..7ebf32b --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h @@ -0,0 +1,39 @@ +/** + * 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 + +extern void lv_draw_extrusion(void); +extern void lv_clear_extrusion(); +extern void disp_ext_type(); +extern void disp_ext_step(); +extern void disp_ext_speed(); +extern void disp_hotend_temp(); +extern void disp_extru_amount(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp new file mode 100644 index 0000000..d5bf62a --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp @@ -0,0 +1,247 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "../../../../MarlinCore.h" +#include "lv_conf.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" +#include "../../../../../Configuration.h" +#include "draw_ui.h" +#include "../../../../module/temperature.h" +#include "../../../../gcode/queue.h" + +static lv_obj_t * scr; +static lv_obj_t * fanText; + +#define ID_F_ADD 1 +#define ID_F_DEC 2 +#define ID_F_HIGH 3 +#define ID_F_MID 4 +#define ID_F_OFF 5 +#define ID_F_RETURN 6 + +static uint8_t fanSpeed; + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_F_ADD: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (fanSpeed + 1 <= 255) { + fanSpeed++; + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, "M106 S%d", fanSpeed); + queue.enqueue_one_now(PSTR(public_buf_l)); + } + } + break; + case ID_F_DEC: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (fanSpeed > 0) { + fanSpeed--; + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, "M106 S%d", fanSpeed); + queue.enqueue_one_now(PSTR(public_buf_l)); + } + } + + break; + case ID_F_HIGH: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + queue.enqueue_one_now(PSTR("M106 S255")); + } + break; + case ID_F_MID: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + queue.enqueue_one_now(PSTR("M106 S127")); + } + break; + case ID_F_OFF: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + queue.enqueue_one_now(PSTR("M107")); + } + break; + case ID_F_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + draw_return_ui(); + } + break; + } +} + + +void lv_draw_fan(void) { + lv_obj_t *buttonAdd, *buttonDec, *buttonHigh, *buttonMid; + lv_obj_t *buttonOff, *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FAN_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = FAN_UI; + } + disp_state = FAN_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + buttonAdd = lv_imgbtn_create(scr, NULL); + buttonDec = lv_imgbtn_create(scr, NULL); + buttonHigh = lv_imgbtn_create(scr, NULL); + buttonMid = lv_imgbtn_create(scr, NULL); + buttonOff = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_F_ADD, "bmp_Add.bin", 0); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); + #if 1 + lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_F_DEC, "bmp_Dec.bin", 0); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonHigh, event_handler, ID_F_HIGH, "bmp_Speed255.bin", 0); + lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonHigh, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonHigh, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonMid, event_handler, ID_F_MID, "bmp_Speed127.bin", 0); + lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonMid, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonMid, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonOff, event_handler, ID_F_OFF, "bmp_Speed0.bin", 0); + lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_F_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonAdd, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonDec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonHigh, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonMid, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonOff, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonAdd, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonDec, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonHigh, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonMid, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonOff, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t * labelAdd = lv_label_create(buttonAdd, NULL); + lv_obj_t * labelDec = lv_label_create(buttonDec, NULL); + lv_obj_t * labelHigh = lv_label_create(buttonHigh, NULL); + lv_obj_t * labelMid = lv_label_create(buttonMid, NULL); + lv_obj_t * labelOff = lv_label_create(buttonOff, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelAdd, fan_menu.add); + lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelDec, fan_menu.dec); + lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelHigh, fan_menu.full); + lv_obj_align(labelHigh, buttonHigh, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelMid, fan_menu.half); + lv_obj_align(labelMid, buttonMid, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelOff, fan_menu.off); + lv_obj_align(labelOff, buttonOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + + fanText = lv_label_create(scr, NULL); + lv_obj_set_style(fanText, &tft_style_lable_rel); + disp_fan_value(); +} + +void disp_fan_value() { + char buf1[10] = {0}; + public_buf_l[0] = '\0'; + strcat(public_buf_l, fan_menu.state); + strcat(public_buf_l, ": "); + sprintf(buf1, "%3d", thermalManager.fan_speed[0]); + strcat(public_buf_l, buf1); + lv_label_set_text(fanText, public_buf_l); + lv_obj_align(fanText, NULL, LV_ALIGN_CENTER, 0, -65); +} + +void lv_clear_fan() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h new file mode 100644 index 0000000..6ad2024 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h @@ -0,0 +1,35 @@ +/** + * 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 + +extern void lv_draw_fan(void); +extern void lv_clear_fan(); +extern void disp_fan_value(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp new file mode 100644 index 0000000..79f550a --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp @@ -0,0 +1,283 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "../../../../MarlinCore.h" +#include "draw_ready_print.h" +#include "draw_set.h" +#include "lv_conf.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" +#include "draw_ui.h" +#include "../../../../gcode/queue.h" + +static lv_obj_t * scr; + +#define ID_H_ALL 1 +#define ID_H_X 2 +#define ID_H_Y 3 +#define ID_H_Z 4 +#define ID_H_RETURN 5 +#define ID_H_OFF_ALL 6 +#define ID_H_OFF_XY 7 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_H_ALL: + if (event == LV_EVENT_CLICKED) { + + + } + else if (event == LV_EVENT_RELEASED) { + queue.inject_P(PSTR("G28")); + } + break; + case ID_H_X: + if (event == LV_EVENT_CLICKED) { + + + } + else if (event == LV_EVENT_RELEASED) { + queue.inject_P(PSTR("G28 X0")); + } + break; + case ID_H_Y: + if (event == LV_EVENT_CLICKED) { + + + } + else if (event == LV_EVENT_RELEASED) { + queue.inject_P(PSTR("G28 Y0")); + } + break; + case ID_H_Z: + if (event == LV_EVENT_CLICKED) { + + + } + else if (event == LV_EVENT_RELEASED) { + queue.inject_P(PSTR("G28 Z0")); + } + break; + case ID_H_OFF_ALL: + if (event == LV_EVENT_CLICKED) { + + + } + else if (event == LV_EVENT_RELEASED) { + queue.inject_P(PSTR("M84")); + } + break; + case ID_H_OFF_XY: + if (event == LV_EVENT_CLICKED) { + + + } + else if (event == LV_EVENT_RELEASED) { + queue.inject_P(PSTR("M84 X Y")); + } + break; + case ID_H_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_obj_del(scr); + lv_draw_tool(); + } + break; + + } +} + + +void lv_draw_home(void) { + lv_obj_t *buttonHomeAll, *buttonHomeX, *buttonHomeY, *buttonHomeZ; + lv_obj_t *buttonBack; + lv_obj_t *buttonOffAll, *buttonOffXY; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ZERO_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = ZERO_UI; + } + disp_state = ZERO_UI; + + scr = lv_obj_create(NULL, NULL); + + //static lv_style_t tool_style; + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + //buttonWifi = lv_imgbtn_create(scr, NULL); + buttonHomeAll = lv_imgbtn_create(scr, NULL); + buttonHomeX = lv_imgbtn_create(scr, NULL); + //buttonContinue = lv_imgbtn_create(scr, NULL); + buttonHomeY = lv_imgbtn_create(scr, NULL); + buttonHomeZ = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + buttonOffAll = lv_imgbtn_create(scr, NULL); + buttonOffXY = lv_imgbtn_create(scr, NULL); + + //lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,"bmp_Wifi.bin",0); + //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, &bmp_pic); + //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, &bmp_pic); + //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_lable_pre); + //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_lable_rel); + //lv_obj_clear_protect(buttonWifi, LV_PROTECT_FOLLOW); + #if 1 + lv_obj_set_event_cb_mks(buttonHomeAll, event_handler, ID_H_ALL, "bmp_Zero.bin", 0); + lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonHomeAll, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonHomeAll, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonHomeX, event_handler, ID_H_X, "bmp_zeroX.bin", 0); + lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonHomeX, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonHomeX, LV_BTN_STATE_REL, &tft_style_lable_rel); + + //lv_obj_set_event_cb_mks(buttonContinue, event_handler,ID_S_CONTINUE,"bmp_Breakpoint.bin",0); + //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_REL, &bmp_pic); + //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_PR, &bmp_pic); + //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_PR, &tft_style_lable_pre); + //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonHomeY, event_handler, ID_H_Y, "bmp_zeroY.bin", 0); + lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonHomeY, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonHomeY, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonHomeZ, event_handler, ID_H_Z, "bmp_zeroZ.bin", 0); + lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonOffAll, event_handler, ID_H_OFF_ALL, "bmp_Motor_off.bin", 0); + lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonOffXY, event_handler, ID_H_OFF_XY, "bmp_Motor_off.bin", 0); + lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_H_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + /*lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight); + lv_obj_set_pos(buttonFan,BTN_X_PIXEL+INTERVAL_V*2,titleHeight); + lv_obj_set_pos(buttonAbout,BTN_X_PIXEL*2+INTERVAL_V*3,titleHeight); + lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight); + lv_obj_set_pos(buMotorOff,INTERVAL_V, BTN_Y_PIXEL+INTERVAL_H+titleHeight); + lv_obj_set_pos(buttonLanguage,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight); + lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight);*/ + + //lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight); + lv_obj_set_pos(buttonHomeX, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); + lv_obj_set_pos(buttonHomeY, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); + //lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight); + lv_obj_set_pos(buttonHomeZ, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonHomeAll, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonOffAll, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonOffXY, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + //lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonHomeAll, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonHomeX, LV_LAYOUT_OFF); + //lv_btn_set_layout(buttonContinue, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonHomeY, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonHomeZ, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonOffAll, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonOffXY, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + //lv_obj_t * labelWifi= lv_label_create(buttonWifi, NULL); + lv_obj_t * labelHomeAll = lv_label_create(buttonHomeAll, NULL); + lv_obj_t * labelHomeX = lv_label_create(buttonHomeX, NULL); + //lv_obj_t * label_Continue = lv_label_create(buttonContinue, NULL); + lv_obj_t * labelHomeY = lv_label_create(buttonHomeY, NULL); + lv_obj_t * labelHomeZ = lv_label_create(buttonHomeZ, NULL); + lv_obj_t * labelOffAll = lv_label_create(buttonOffAll, NULL); + lv_obj_t * labelOffXY = lv_label_create(buttonOffXY, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + + if (gCfgItems.multiple_language != 0) { + //lv_label_set_text(labelWifi, set_menu.wifi); + //lv_obj_align(labelWifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelHomeAll, home_menu.home_all); + lv_obj_align(labelHomeAll, buttonHomeAll, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelHomeX, home_menu.home_x); + lv_obj_align(labelHomeX, buttonHomeX, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + //lv_label_set_text(label_Continue, set_menu.breakpoint); + //lv_obj_align(label_Continue, buttonContinue, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelHomeY, home_menu.home_y); + lv_obj_align(labelHomeY, buttonHomeY, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelHomeZ, home_menu.home_z); + lv_obj_align(labelHomeZ, buttonHomeZ, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelOffAll, set_menu.motoroff); + lv_obj_align(labelOffAll, buttonOffAll, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelOffXY, set_menu.motoroffXY); + lv_obj_align(labelOffXY, buttonOffXY, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } +} + +void lv_clear_home() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h new file mode 100644 index 0000000..9fd373b --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h @@ -0,0 +1,34 @@ +/** + * 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 + +extern void lv_draw_home(void); +extern void lv_clear_home(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp new file mode 100644 index 0000000..c5c77e8 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp @@ -0,0 +1,370 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" +#include + +//static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn; + +#define ID_CN 1 +#define ID_T_CN 2 +#define ID_EN 3 +#define ID_RU 4 +#define ID_ES 5 +#define ID_FR 6 +#define ID_IT 7 +#define ID_L_RETURN 8 + +#define SELECTED 1 +#define UNSELECTED 0 + +static void disp_language(uint8_t language, uint8_t state); + +static lv_obj_t * scr; +static lv_obj_t *buttonCN, *buttonT_CN, *buttonEN, *buttonRU; +static lv_obj_t *buttonES, *buttonFR, *buttonIT, *buttonBack; + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_CN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + disp_language(gCfgItems.language, UNSELECTED); + lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_Simple_cn_sel.bin", 0); + gCfgItems.language = LANG_SIMPLE_CHINESE; + gCfg_to_spiFlah(); + disp_language_init(); + } + break; + case ID_T_CN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + disp_language(gCfgItems.language, UNSELECTED); + lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_Tradition_cn_sel.bin", 0); + gCfgItems.language = LANG_COMPLEX_CHINESE; + gCfg_to_spiFlah(); + disp_language_init(); + } + break; + case ID_EN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + disp_language(gCfgItems.language, UNSELECTED); + lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, "bmp_English_sel.bin", 0); + gCfgItems.language = LANG_ENGLISH; + gCfg_to_spiFlah(); + disp_language_init(); + } + break; + case ID_RU: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + disp_language(gCfgItems.language, UNSELECTED); + lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, "bmp_Russian_sel.bin", 0); + gCfgItems.language = LANG_RUSSIAN; + gCfg_to_spiFlah(); + disp_language_init(); + } + break; + case ID_ES: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + disp_language(gCfgItems.language, UNSELECTED); + lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, "bmp_Spanish_sel.bin", 0); + gCfgItems.language = LANG_SPANISH; + gCfg_to_spiFlah(); + disp_language_init(); + } + break; + case ID_FR: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + disp_language(gCfgItems.language, UNSELECTED); + lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, "bmp_French_sel.bin", 0); + gCfgItems.language = LANG_FRENCH; + gCfg_to_spiFlah(); + disp_language_init(); + } + break; + case ID_IT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + disp_language(gCfgItems.language, UNSELECTED); + lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_FR, "bmp_Italy_sel.bin", 0); + gCfgItems.language = LANG_ITALY; + gCfg_to_spiFlah(); + disp_language_init(); + } + break; + case ID_L_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + + buttonCN = NULL; + buttonT_CN = NULL; + buttonEN = NULL; + buttonRU = NULL; + buttonES = NULL; + buttonFR = NULL; + buttonFR = NULL; + buttonIT = NULL; + buttonBack = NULL; + + lv_obj_del(scr); + lv_draw_set(); + } + break; + + } +} + +static void disp_language(uint8_t language, uint8_t state) { + uint16_t id; + lv_obj_t *obj; + + public_buf_l[0] = '\0'; + + switch (language) { + + case LANG_SIMPLE_CHINESE: + id = ID_CN; + strcat(public_buf_l, "bmp_Simple_cn"); + obj = buttonCN; + + break; + case LANG_COMPLEX_CHINESE: + id = ID_T_CN; + strcat(public_buf_l, "bmp_Tradition_cn"); + obj = buttonT_CN; + break; + case LANG_ENGLISH: + id = ID_EN; + strcat(public_buf_l, "bmp_English"); + obj = buttonEN; + break; + case LANG_RUSSIAN: + id = ID_RU; + strcat(public_buf_l, "bmp_Russian"); + obj = buttonRU; + break; + case LANG_SPANISH: + id = ID_ES; + strcat(public_buf_l, "bmp_Spanish"); + obj = buttonES; + break; + case LANG_FRENCH: + id = ID_FR; + strcat(public_buf_l, "bmp_French"); + obj = buttonFR; + break; + case LANG_ITALY: + id = ID_IT; + strcat(public_buf_l, "bmp_Italy"); + obj = buttonIT; + break; + default: + id = ID_CN; + strcat(public_buf_l, "bmp_Simple_cn"); + obj = buttonCN; + break; + } + + if (state == SELECTED) strcat(public_buf_l, "_sel.bin"); + else strcat(public_buf_l, ".bin"); + + lv_obj_set_event_cb_mks(obj, event_handler, id, public_buf_l, 0); + + if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj); +} + +void lv_draw_language(void) { + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LANGUAGE_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = LANGUAGE_UI; + } + disp_state = LANGUAGE_UI; + + scr = lv_obj_create(NULL, NULL); + + //static lv_style_t tool_style; + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + buttonCN = lv_imgbtn_create(scr, NULL); + buttonT_CN = lv_imgbtn_create(scr, NULL); + buttonEN = lv_imgbtn_create(scr, NULL); + buttonRU = lv_imgbtn_create(scr, NULL); + buttonES = lv_imgbtn_create(scr, NULL); + buttonFR = lv_imgbtn_create(scr, NULL); + buttonIT = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + + lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_Simple_cn.bin", 0); + lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW); + #if 1 + lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_Tradition_cn.bin", 0); + lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonT_CN, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonT_CN, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, "bmp_English.bin", 0); + lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonEN, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonEN, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, "bmp_Russian.bin", 0); + lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonRU, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonRU, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, "bmp_Spanish.bin", 0); + lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonES, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonES, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, "bmp_French.bin", 0); + lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonFR, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonFR, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_IT, "bmp_Italy.bin", 0); + lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonIT, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonIT, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_L_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonCN, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonT_CN, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); + lv_obj_set_pos(buttonEN, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); + lv_obj_set_pos(buttonRU, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonES, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonFR, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonIT, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonCN, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonT_CN, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonEN, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonRU, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonES, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonFR, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonIT, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t * label_CN = lv_label_create(buttonCN, NULL); + lv_obj_t * label_T_CN = lv_label_create(buttonT_CN, NULL); + lv_obj_t * label_EN = lv_label_create(buttonEN, NULL); + lv_obj_t * label_RU = lv_label_create(buttonRU, NULL); + lv_obj_t * label_ES = lv_label_create(buttonES, NULL); + lv_obj_t * label_FR = lv_label_create(buttonFR, NULL); + lv_obj_t * label_IT = lv_label_create(buttonIT, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + disp_language(gCfgItems.language, SELECTED); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(label_CN, language_menu.chinese_s); + lv_obj_align(label_CN, buttonCN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_T_CN, language_menu.chinese_t); + lv_obj_align(label_T_CN, buttonT_CN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_EN, language_menu.english); + lv_obj_align(label_EN, buttonEN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_RU, language_menu.russian); + lv_obj_align(label_RU, buttonRU, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_ES, language_menu.spanish); + lv_obj_align(label_ES, buttonES, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_FR, language_menu.french); + lv_obj_align(label_FR, buttonFR, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_IT, language_menu.italy); + lv_obj_align(label_IT, buttonIT, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } +} + +void lv_clear_language() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h new file mode 100644 index 0000000..4d967b4 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h @@ -0,0 +1,34 @@ +/** + * 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 + +extern void lv_draw_language(void); +extern void lv_clear_language(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp new file mode 100644 index 0000000..b97483e --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp @@ -0,0 +1,284 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "../../../../MarlinCore.h" +#include "lv_conf.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" +#include "draw_ui.h" +#include "../../../../gcode/queue.h" + +//static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn; +static lv_obj_t * scr; + +#define ID_M_POINT1 1 +#define ID_M_POINT2 2 +#define ID_M_POINT3 3 +#define ID_M_POINT4 4 +#define ID_M_POINT5 5 + +#define ID_MANUAL_RETURN 6 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_M_POINT1: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + + if (queue.length == 0) { + if (uiCfg.leveling_first_time) { + queue.enqueue_one_P(PSTR("G28")); + uiCfg.leveling_first_time = 0; + } + + queue.enqueue_one_P(PSTR("G1 Z10")); + + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, "G1 X%d Y%d", X_MIN_POS + 30, Y_MIN_POS + 30); + queue.enqueue_one_P(PSTR(public_buf_l)); + queue.enqueue_one_P(PSTR("G1 Z0")); + } + } + break; + case ID_M_POINT2: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length == 0) { + if (uiCfg.leveling_first_time) { + queue.enqueue_one_P(PSTR("G28")); + uiCfg.leveling_first_time = 0; + } + + queue.enqueue_one_P(PSTR("G1 Z10")); + + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, "G1 X%d Y%d", X_MAX_POS - 30, Y_MIN_POS + 30); + queue.enqueue_one_P(PSTR(public_buf_l)); + queue.enqueue_one_P(PSTR("G1 Z0")); + } + } + break; + case ID_M_POINT3: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length == 0) { + if (uiCfg.leveling_first_time) { + queue.enqueue_one_P(PSTR("G28")); + uiCfg.leveling_first_time = 0; + } + + queue.enqueue_one_P(PSTR("G1 Z10")); + + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, "G1 X%d Y%d", X_MAX_POS - 30, Y_MAX_POS - 30); + queue.enqueue_one_P(PSTR(public_buf_l)); + queue.enqueue_one_P(PSTR("G1 Z0")); + } + } + + break; + case ID_M_POINT4: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length == 0) { + if (uiCfg.leveling_first_time) { + queue.enqueue_one_P(PSTR("G28")); + uiCfg.leveling_first_time = 0; + } + + queue.enqueue_one_P(PSTR("G1 Z10")); + + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, "G1 X%d Y%d", X_MIN_POS + 30, Y_MAX_POS - 30); + queue.enqueue_one_P(PSTR(public_buf_l)); + queue.enqueue_one_P(PSTR("G1 Z0")); + } + } + break; + case ID_M_POINT5: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length == 0) { + if (uiCfg.leveling_first_time) { + queue.enqueue_one_P(PSTR("G28")); + uiCfg.leveling_first_time = 0; + } + + queue.enqueue_one_P(PSTR("G1 Z10")); + + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, "G1 X%d Y%d", X_BED_SIZE / 2, Y_BED_SIZE / 2); + queue.enqueue_one_P(PSTR(public_buf_l)); + queue.enqueue_one_P(PSTR("G1 Z0")); + } + } + + break; + case ID_MANUAL_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_manualLevel(); + lv_draw_tool(); + } + break; + + } +} + + +void lv_draw_manualLevel(void) { + lv_obj_t *buttonPoint1, *buttonPoint2, *buttonPoint3, *buttonPoint4, *buttonPoint5; + lv_obj_t *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_UI; + } + disp_state = LEVELING_UI; + + scr = lv_obj_create(NULL, NULL); + + //static lv_style_t tool_style; + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + buttonPoint1 = lv_imgbtn_create(scr, NULL); + buttonPoint2 = lv_imgbtn_create(scr, NULL); + buttonPoint3 = lv_imgbtn_create(scr, NULL); + buttonPoint4 = lv_imgbtn_create(scr, NULL); + buttonPoint5 = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonPoint1, event_handler, ID_M_POINT1, "bmp_Leveling1.bin", 0); + lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonPoint1, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPoint1, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW); + #if 1 + lv_obj_set_event_cb_mks(buttonPoint2, event_handler, ID_M_POINT2, "bmp_Leveling2.bin", 0); + lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonPoint2, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPoint2, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonPoint3, event_handler, ID_M_POINT3, "bmp_Leveling3.bin", 0); + lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonPoint3, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPoint3, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonPoint4, event_handler, ID_M_POINT4, "bmp_Leveling4.bin", 0); + lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonPoint4, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPoint4, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonPoint5, event_handler, ID_M_POINT5, "bmp_Leveling5.bin", 0); + lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonPoint5, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPoint5, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonPoint1, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonPoint2, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); + lv_obj_set_pos(buttonPoint3, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); + lv_obj_set_pos(buttonPoint4, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonPoint5, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonPoint1, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonPoint2, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonPoint3, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonPoint4, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonPoint5, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t * label_Point1 = lv_label_create(buttonPoint1, NULL); + lv_obj_t * label_Point2 = lv_label_create(buttonPoint2, NULL); + lv_obj_t * label_Point3 = lv_label_create(buttonPoint3, NULL); + lv_obj_t * label_Point4 = lv_label_create(buttonPoint4, NULL); + lv_obj_t * label_Point5 = lv_label_create(buttonPoint5, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(label_Point1, leveling_menu.position1); + lv_obj_align(label_Point1, buttonPoint1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Point2, leveling_menu.position2); + lv_obj_align(label_Point2, buttonPoint2, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Point3, leveling_menu.position3); + lv_obj_align(label_Point3, buttonPoint3, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Point4, leveling_menu.position4); + lv_obj_align(label_Point4, buttonPoint4, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Point5, leveling_menu.position5); + lv_obj_align(label_Point5, buttonPoint5, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } +} + +void lv_clear_manualLevel() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h new file mode 100644 index 0000000..346e0bb --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h @@ -0,0 +1,34 @@ +/** + * 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 + +extern void lv_draw_manualLevel(void); +extern void lv_clear_manualLevel(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp new file mode 100644 index 0000000..71d5d74 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp @@ -0,0 +1,329 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "../../../../MarlinCore.h" +#include "lv_conf.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" +#include "draw_ui.h" +#include "../../../../gcode/queue.h" + +static lv_obj_t * scr; + +static lv_obj_t * labelV, *buttonV; + +#define ID_M_X_P 1 +#define ID_M_X_N 2 +#define ID_M_Y_P 3 +#define ID_M_Y_N 4 +#define ID_M_Z_P 5 +#define ID_M_Z_N 6 +#define ID_M_STEP 7 +#define ID_M_RETURN 8 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_M_X_P: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length <= (BUFSIZE - 3)) { + memset(public_buf_l, 0, sizeof(public_buf_l)); + queue.enqueue_one_P(PSTR("G91")); + sprintf(public_buf_l, "G1 X%3.1f F%d", uiCfg.move_dist, uiCfg.moveSpeed); + queue.enqueue_one_P(PSTR(public_buf_l)); + queue.enqueue_one_P(PSTR("G90")); + } + } + break; + case ID_M_X_N: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length <= (BUFSIZE - 3)) { + memset(public_buf_l, 0, sizeof(public_buf_l)); + queue.enqueue_one_now(PSTR("G91")); + sprintf(public_buf_l, "G1 X-%3.1f F%d", uiCfg.move_dist, uiCfg.moveSpeed); + queue.enqueue_one_now(PSTR(public_buf_l)); + queue.enqueue_one_now(PSTR("G90")); + } + } + break; + case ID_M_Y_P: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length <= (BUFSIZE - 3)) { + memset(public_buf_l, 0, sizeof(public_buf_l)); + queue.enqueue_one_now(PSTR("G91")); + sprintf(public_buf_l, "G1 Y%3.1f F%d", uiCfg.move_dist, uiCfg.moveSpeed); + queue.enqueue_one_now(PSTR(public_buf_l)); + queue.enqueue_one_now(PSTR("G90")); + } + } + break; + case ID_M_Y_N: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length <= (BUFSIZE - 3)) { + memset(public_buf_l, 0, sizeof(public_buf_l)); + queue.enqueue_one_now(PSTR("G91")); + sprintf(public_buf_l, "G1 Y-%3.1f F%d", uiCfg.move_dist, uiCfg.moveSpeed); + queue.enqueue_one_now(PSTR(public_buf_l)); + queue.enqueue_one_now(PSTR("G90")); + } + } + break; + case ID_M_Z_P: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length <= (BUFSIZE - 3)) { + memset(public_buf_l, 0, sizeof(public_buf_l)); + queue.enqueue_one_now(PSTR("G91")); + sprintf(public_buf_l, "G1 Z%3.1f F%d", uiCfg.move_dist, uiCfg.moveSpeed); + queue.enqueue_one_now(PSTR(public_buf_l)); + queue.enqueue_one_now(PSTR("G90")); + } + } + break; + case ID_M_Z_N: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (queue.length <= (BUFSIZE - 3)) { + memset(public_buf_l, 0, sizeof(public_buf_l)); + queue.enqueue_one_now(PSTR("G91")); + sprintf(public_buf_l, "G1 Z-%3.1f F%d", uiCfg.move_dist, uiCfg.moveSpeed); + queue.enqueue_one_now(PSTR(public_buf_l)); + queue.enqueue_one_now(PSTR("G90")); + } + } + break; + case ID_M_STEP: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (abs(10 * (int)uiCfg.move_dist) == 100) + uiCfg.move_dist = 0.1; + else + uiCfg.move_dist *= (float)10; + + disp_move_dist(); + } + + break; + case ID_M_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + draw_return_ui(); + } + break; + + } +} + + +void lv_draw_move_motor(void) { + lv_obj_t *buttonXI, *buttonXD, *buttonYI, *buttonYD; + lv_obj_t *buttonZI, *buttonZD, *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOVE_MOTOR_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = MOVE_MOTOR_UI; + } + disp_state = MOVE_MOTOR_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + + /*Create an Image button*/ + buttonXI = lv_imgbtn_create(scr, NULL); + buttonXD = lv_imgbtn_create(scr, NULL); + buttonYI = lv_imgbtn_create(scr, NULL); + buttonYD = lv_imgbtn_create(scr, NULL); + buttonZI = lv_imgbtn_create(scr, NULL); + buttonZD = lv_imgbtn_create(scr, NULL); + buttonV = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_M_X_P, "bmp_xAdd.bin", 0); + lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW); + #if 1 + lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_M_X_N, "bmp_xDec.bin", 0); + lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_M_Y_P, "bmp_yAdd.bin", 0); + lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_M_Y_N, "bmp_yDec.bin", 0); + lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_M_Z_P, "bmp_zAdd.bin", 0); + lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_M_Z_N, "bmp_zDec.bin", 0); + lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_REL, &tft_style_lable_rel); + + //lv_obj_set_event_cb_mks(buttonV, event_handler,ID_T_MORE,"bmp_More.bin",0); + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonV, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonV, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_M_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + lv_obj_set_pos(buttonXI, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonYI, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); + lv_obj_set_pos(buttonZI, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); + lv_obj_set_pos(buttonV, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonXD, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonYD, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonZD, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonXI, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonXD, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonYI, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonYD, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonZI, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonZD, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonV, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t * labelXI = lv_label_create(buttonXI, NULL); + lv_obj_t * labelXD = lv_label_create(buttonXD, NULL); + lv_obj_t * labelYI = lv_label_create(buttonYI, NULL); + lv_obj_t * labelYD = lv_label_create(buttonYD, NULL); + lv_obj_t * labelZI = lv_label_create(buttonZI, NULL); + lv_obj_t * labelZD = lv_label_create(buttonZD, NULL); + labelV = lv_label_create(buttonV, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelXI, move_menu.x_add); + lv_obj_align(labelXI, buttonXI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelXD, move_menu.x_dec); + lv_obj_align(labelXD, buttonXD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelYI, move_menu.y_add); + lv_obj_align(labelYI, buttonYI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelYD, move_menu.y_dec); + lv_obj_align(labelYD, buttonYD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelZI, move_menu.z_add); + lv_obj_align(labelZI, buttonZI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelZD, move_menu.z_dec); + lv_obj_align(labelZD, buttonZD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + + disp_move_dist(); +} + +void disp_move_dist() { + //char buf[30] = {0}; + + if ((int)(10 * uiCfg.move_dist) == 1) + lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_Step_move0_1.bin", 0); + else if ((int)(10 * uiCfg.move_dist) == 10) + lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_Step_move1.bin", 0); + else if ((int)(10 * uiCfg.move_dist) == 100) + lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_Step_move10.bin", 0); + if (gCfgItems.multiple_language != 0) { + if ((int)(10 * uiCfg.move_dist) == 1) { + lv_label_set_text(labelV, move_menu.step_01mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if ((int)(10 * uiCfg.move_dist) == 10) { + lv_label_set_text(labelV, move_menu.step_1mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if ((int)(10 * uiCfg.move_dist) == 100) { + lv_label_set_text(labelV, move_menu.step_10mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void lv_clear_move_motor() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h new file mode 100644 index 0000000..407ff31 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h @@ -0,0 +1,35 @@ +/** + * 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 + +extern void lv_draw_move_motor(void); +extern void lv_clear_move_motor(); +extern void disp_move_dist(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_opration.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_opration.cpp new file mode 100644 index 0000000..483de3f --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_opration.cpp @@ -0,0 +1,322 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" + +static lv_obj_t * scr; + +#define ID_O_PRE_HEAT 1 +#define ID_O_EXTRUCT 2 +#define ID_O_MOV 3 +#define ID_O_FILAMENT 4 +#define ID_O_SPEED 5 +#define ID_O_RETURN 6 +#define ID_O_FAN 7 +#define ID_O_POWER_OFF 8 + +static lv_obj_t *label_PowerOff; +static lv_obj_t *buttonPowerOff; + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_O_PRE_HEAT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_opration(); + lv_draw_preHeat(); + } + break; + case ID_O_EXTRUCT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_opration(); + lv_draw_extrusion(); + } + break; + case ID_O_MOV: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_opration(); + lv_draw_move_motor(); + } + break; + case ID_O_FILAMENT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + } + break; + case ID_O_FAN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_opration(); + lv_draw_fan(); + } + break; + case ID_O_SPEED: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_opration(); + lv_draw_change_speed(); + } + break; + case ID_O_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + draw_return_ui(); + } + break; + case ID_O_POWER_OFF: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (gCfgItems.finish_power_off == 1) { + gCfgItems.finish_power_off = 0; + lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_Mamual.bin", 0); + lv_label_set_text(label_PowerOff, printing_more_menu.manual); + lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + lv_obj_refresh_ext_draw_pad(label_PowerOff); + update_spi_flash(); + } + else { + gCfgItems.finish_power_off = 1; + lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_Auto.bin", 0); + lv_label_set_text(label_PowerOff, printing_more_menu.auto_close); + lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + lv_obj_refresh_ext_draw_pad(label_PowerOff); + update_spi_flash(); + } + } + break; + + } +} + +void lv_draw_opration(void) { + lv_obj_t *buttonPreHeat, *buttonExtrusion, *buttonSpeed; + lv_obj_t *buttonBack, *buttonFan; + lv_obj_t *labelPreHeat, *labelExtrusion; + lv_obj_t *label_Back, *label_Speed, *label_Fan; + lv_obj_t *buttonMove = NULL, *label_Move = NULL; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != OPERATE_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = OPERATE_UI; + } + disp_state = OPERATE_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + buttonPreHeat = lv_imgbtn_create(scr, NULL); + buttonExtrusion = lv_imgbtn_create(scr, NULL); + buttonFan = lv_imgbtn_create(scr, NULL); + buttonSpeed = lv_imgbtn_create(scr, NULL); + + if (uiCfg.print_state != WORKING) + //buttonFilament = lv_imgbtn_create(scr, NULL); + //else + buttonMove = lv_imgbtn_create(scr, NULL); + buttonPowerOff = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_O_PRE_HEAT, "bmp_PreHeat.bin", 0); + lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonPreHeat, LV_PROTECT_FOLLOW); + #if 1 + lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_O_EXTRUCT, "bmp_Extruct.bin", 0); + lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_O_FAN, "bmp_Fan.bin", 0); + lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_O_SPEED, "bmp_Speed.bin", 0); + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_lable_rel); + + if (uiCfg.print_state != WORKING) { + /*{ + lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_O_FILAMENT,"bmp_Filamentchange.bin",0); + lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_lable_rel); + } + else*/ + lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_O_MOV, "bmp_Mov.bin", 0); + lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_lable_rel); + } + if (gCfgItems.finish_power_off == 1) + lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_Auto.bin", 0); + else + lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_Mamual.bin", 0); + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_O_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonExtrusion, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); + + lv_obj_set_pos(buttonFan, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); + lv_obj_set_pos(buttonSpeed, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + + if (uiCfg.print_state != WORKING) { + /*{ + lv_obj_set_pos(buttonFilament,INTERVAL_V,BTN_Y_PIXEL+INTERVAL_H+titleHeight); + } + else*/ + lv_obj_set_pos(buttonMove, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonPowerOff, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + } + else { + lv_obj_set_pos(buttonPowerOff, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + } + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonPreHeat, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonExtrusion, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonFan, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonSpeed, LV_LAYOUT_OFF); + + if (uiCfg.print_state != WORKING) + /*{ + lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF); + } + else*/ + lv_btn_set_layout(buttonMove, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonPowerOff, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + labelPreHeat = lv_label_create(buttonPreHeat, NULL); + labelExtrusion = lv_label_create(buttonExtrusion, NULL); + + label_Fan = lv_label_create(buttonFan, NULL); + label_Speed = lv_label_create(buttonSpeed, NULL); + + if (uiCfg.print_state != WORKING) + /*{ + label_Filament = lv_label_create(buttonFilament, NULL); + } + else*/ + label_Move = lv_label_create(buttonMove, NULL); + label_PowerOff = lv_label_create(buttonPowerOff, NULL); + + label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelPreHeat, operation_menu.temp); + lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelExtrusion, operation_menu.extr); + lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Fan, operation_menu.fan); + lv_obj_align(label_Fan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Speed, operation_menu.speed); + lv_obj_align(label_Speed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + if (uiCfg.print_state != WORKING) { + /*{ + lv_label_set_text(label_Filament, operation_menu.filament); + lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + } + else*/ + lv_label_set_text(label_Move, operation_menu.move); + lv_obj_align(label_Move, buttonMove, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + + if (gCfgItems.finish_power_off == 1) + lv_label_set_text(label_PowerOff, printing_more_menu.auto_close); + else + lv_label_set_text(label_PowerOff, printing_more_menu.manual); + lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } +} + +void lv_clear_opration() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_opration.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_opration.h new file mode 100644 index 0000000..27f21d4 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_opration.h @@ -0,0 +1,34 @@ +/** + * 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 + +extern void lv_draw_opration(void); +extern void lv_clear_opration(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp new file mode 100644 index 0000000..cf477ec --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp @@ -0,0 +1,55 @@ +/** + * 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 BOTH(TFT_LITTLE_VGL_UI, ADVANCED_PAUSE_FEATURE) + +#include "draw_ui.h" +#include "lv_conf.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" +#include "../../../../feature/pause.h" + +void lv_draw_pause_message(const PauseMessage msg) { + switch (msg) { + case PAUSE_MESSAGE_PAUSING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_PAUSING); break; + case PAUSE_MESSAGE_CHANGING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_CHANGING); break; + case PAUSE_MESSAGE_UNLOAD: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_UNLOAD); break; + case PAUSE_MESSAGE_WAITING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_WAITING); break; + case PAUSE_MESSAGE_INSERT: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_INSERT); break; + case PAUSE_MESSAGE_LOAD: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_LOAD); break; + case PAUSE_MESSAGE_PURGE: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_PURGE); break; + case PAUSE_MESSAGE_RESUME: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_RESUME); break; + case PAUSE_MESSAGE_HEAT: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_HEAT); break; + case PAUSE_MESSAGE_HEATING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_HEATING); break; + case PAUSE_MESSAGE_OPTION: pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; + clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_OPTION); break; + case PAUSE_MESSAGE_STATUS: + default: break; + } +} + +#endif // TFT_LITTLE_VGL_UI && ADVANCED_PAUSE_FEATURE diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h new file mode 100644 index 0000000..5b0d4ab --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h @@ -0,0 +1,33 @@ +/** + * 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 + +extern void lv_draw_pause_message(const PauseMessage msg); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp new file mode 100644 index 0000000..beea300 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -0,0 +1,392 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" + +static lv_obj_t * scr; +static lv_obj_t *buttoType, *buttonStep; +static lv_obj_t * labelType; +static lv_obj_t * labelStep; +static lv_obj_t * tempText1; + +#define ID_P_ADD 1 +#define ID_P_DEC 2 +#define ID_P_TYPE 3 +#define ID_P_STEP 4 +#define ID_P_OFF 5 +#define ID_P_RETURN 6 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_P_ADD: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (uiCfg.curTempType == 0) { + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target += uiCfg.stepHeat; + if (uiCfg.curSprayerChoose == 0) { + if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) { + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); + + thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + } + } + #if !defined(SINGLENOZZLE) && EXTRUDERS >= 2 + else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) { + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); + + thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + } + #endif + } + #if HAS_HEATED_BED + else { + + thermalManager.temp_bed.target += uiCfg.stepHeat; + + if ((int)thermalManager.temp_bed.target > BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) { + thermalManager.temp_bed.target = (float)BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1); + thermalManager.start_watching_bed(); + } + + } + #endif + disp_desire_temp(); + } + break; + case ID_P_DEC: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (uiCfg.curTempType == 0) { + if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat) { + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat; + thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + } + else { + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)0; + thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + } + } + #if HAS_HEATED_BED + else { + if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat) { + thermalManager.temp_bed.target -= uiCfg.stepHeat; + thermalManager.start_watching_bed(); + } + else { + thermalManager.temp_bed.target = (float)0; + thermalManager.start_watching_bed(); + } + } + #endif + disp_desire_temp(); + } + + break; + case ID_P_TYPE: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (uiCfg.curTempType == 0) { + if (EXTRUDERS == 2) { + if (uiCfg.curSprayerChoose == 0) { + uiCfg.curSprayerChoose = 1; + } + else if (uiCfg.curSprayerChoose == 1) { + if (TEMP_SENSOR_BED != 0) { + uiCfg.curTempType = 1; + } + else { + uiCfg.curTempType = 0; + uiCfg.curSprayerChoose = 0; + } + } + } + else if (uiCfg.curSprayerChoose == 0) { + if (TEMP_SENSOR_BED != 0) + uiCfg.curTempType = 1; + else + uiCfg.curTempType = 0; + } + } + else if (uiCfg.curTempType == 1) { + uiCfg.curSprayerChoose = 0; + uiCfg.curTempType = 0; + } + disp_temp_type(); + } + break; + case ID_P_STEP: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + switch (uiCfg.stepHeat) { + case 1: uiCfg.stepHeat = 5; break; + case 5: uiCfg.stepHeat = 10; break; + case 10: uiCfg.stepHeat = 1; break; + default: break; + } + disp_step_heat(); + } + break; + case ID_P_OFF: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (uiCfg.curTempType == 0) { + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)0; + thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + } + #if HAS_HEATED_BED + else { + thermalManager.temp_bed.target = (float)0; + thermalManager.start_watching_bed(); + } + #endif + disp_desire_temp(); + } + break; + case ID_P_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + draw_return_ui(); + } + break; + } +} + +void lv_draw_preHeat(void) { + lv_obj_t *buttonAdd, *buttonDec; + lv_obj_t *buttonOff, *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PRE_HEAT_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = PRE_HEAT_UI; + } + disp_state = PRE_HEAT_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + buttonAdd = lv_imgbtn_create(scr, NULL); + buttonDec = lv_imgbtn_create(scr, NULL); + buttoType = lv_imgbtn_create(scr, NULL); + buttonStep = lv_imgbtn_create(scr, NULL); + buttonOff = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_P_ADD, "bmp_Add.bin", 0); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); + #if 1 + lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_P_DEC, "bmp_Dec.bin", 0); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_lable_rel); + + + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_lable_rel); + + + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonOff, event_handler, ID_P_OFF, "bmp_Speed0.bin", 0); + lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonAdd, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonDec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttoType, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonStep, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonOff, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonAdd, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonDec, LV_LAYOUT_OFF); + lv_btn_set_layout(buttoType, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonStep, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonOff, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t * labelAdd = lv_label_create(buttonAdd, NULL); + lv_obj_t * labelDec = lv_label_create(buttonDec, NULL); + labelType = lv_label_create(buttoType, NULL); + labelStep = lv_label_create(buttonStep, NULL); + lv_obj_t * labelOff = lv_label_create(buttonOff, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelAdd, preheat_menu.add); + lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelDec, preheat_menu.dec); + lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelOff, preheat_menu.off); + lv_obj_align(labelOff, buttonOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + + disp_temp_type(); + disp_step_heat(); + + tempText1 = lv_label_create(scr, NULL); + lv_obj_set_style(tempText1, &tft_style_lable_rel); + disp_desire_temp(); +} + +void disp_temp_type() { + + if (uiCfg.curTempType == 0) { + if (uiCfg.curSprayerChoose == 1) { + lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_Extru2.bin", 0); + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelType, preheat_menu.ext2); + lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } + else { + lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_Extru1.bin", 0); + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelType, preheat_menu.ext1); + lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } + + } + else { + lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_Bed.bin", 0); + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelType, preheat_menu.hotbed); + lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } + +} + +void disp_desire_temp() { + char buf[20] = {0}; + + public_buf_l[0] = '\0'; + + if (uiCfg.curTempType == 0) { + if (uiCfg.curSprayerChoose < 1) + strcat(public_buf_l, preheat_menu.ext1); + else + strcat(public_buf_l, preheat_menu.ext2); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); + } + #if HAS_HEATED_BED + else { + strcat(public_buf_l, preheat_menu.hotbed); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); + } + #endif + strcat(public_buf_l, ": "); + strcat(public_buf_l, buf); + lv_label_set_text(tempText1, public_buf_l); + lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50); +} + +void disp_step_heat() { + if (uiCfg.stepHeat == 1) + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_Step1_degree.bin", 0); + else if (uiCfg.stepHeat == 5) + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_Step5_degree.bin", 0); + else if (uiCfg.stepHeat == 10) + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_Step10_degree.bin", 0); + + if (gCfgItems.multiple_language != 0) { + if (uiCfg.stepHeat == 1) { + lv_label_set_text(labelStep, preheat_menu.step_1c); + lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if (uiCfg.stepHeat == 5) { + lv_label_set_text(labelStep, preheat_menu.step_5c); + lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if (uiCfg.stepHeat == 10) { + lv_label_set_text(labelStep, preheat_menu.step_10c); + lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void lv_clear_preHeat() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h new file mode 100644 index 0000000..c042b70 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h @@ -0,0 +1,37 @@ +/** + * 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 + +extern void lv_draw_preHeat(void); +extern void lv_clear_preHeat(); +extern void disp_temp_type(); +extern void disp_step_heat(); +extern void disp_desire_temp(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp new file mode 100644 index 0000000..cc9fa0e --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp @@ -0,0 +1,595 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "../../../../MarlinCore.h" +#include "lv_conf.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" +#include "draw_ui.h" +#include "../../../../sd/cardreader.h" + +static lv_obj_t * scr; + +static lv_obj_t *buttonPageUp, *buttonPageDown, *buttonBack, *buttonGcode[FILE_BTN_CNT]; +static lv_obj_t * labelPageUp[FILE_BTN_CNT]; +static lv_obj_t *buttonText[FILE_BTN_CNT]; + +#define ID_P_UP 7 +#define ID_P_DOWN 8 +#define ID_P_RETURN 9 + +int8_t curDirLever = 0; +LIST_FILE list_file; +DIR_OFFSET dir_offset[10]; + +extern uint8_t public_buf[512]; +extern char public_buf_m[100]; + +uint8_t sel_id = 0; + +#if ENABLED(SDSUPPORT) + +static uint8_t search_file() { + int valid_name_cnt = 0; + //char tmp[SHORT_NEME_LEN*MAX_DIR_LEVEL+1]; + + list_file.Sd_file_cnt = 0; + //list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset; + + //root2.rewind(); + //SERIAL_ECHOLN(list_file.curDirPath); + + if (curDirLever != 0) card.cd(list_file.curDirPath); + else card.cdroot(); //while(card.cdup()); + + const uint16_t fileCnt = card.get_num_Files(); + + for (uint16_t i = 0; i < fileCnt; i++) { + if (list_file.Sd_file_cnt == list_file.Sd_file_offset) { + const uint16_t nr = SD_ORDER(i, fileCnt); + card.getfilename_sorted(nr); + + if (card.flag.filenameIsDir) + /* + SERIAL_ECHOLN(card.longest_filename); + */ + list_file.IsFolder[valid_name_cnt] = 1; + else + //SERIAL_ECHOLN(card.longFilename); + list_file.IsFolder[valid_name_cnt] = 0; + + #if 1 + // + memset(list_file.file_name[valid_name_cnt], 0, strlen(list_file.file_name[valid_name_cnt])); + strcpy(list_file.file_name[valid_name_cnt], list_file.curDirPath); + strcat(list_file.file_name[valid_name_cnt], "/"); + strcat(list_file.file_name[valid_name_cnt], card.filename); + // + memset(list_file.long_name[valid_name_cnt], 0, strlen(list_file.long_name[valid_name_cnt])); + if (card.longFilename[0] == 0) + strncpy(list_file.long_name[valid_name_cnt], card.filename, strlen(card.filename)); + else + strncpy(list_file.long_name[valid_name_cnt], card.longFilename, strlen(card.longFilename)); + + valid_name_cnt++; + if (valid_name_cnt == 1) + dir_offset[curDirLever].cur_page_first_offset = list_file.Sd_file_offset; + if (valid_name_cnt >= FILE_NUM) { + dir_offset[curDirLever].cur_page_last_offset = list_file.Sd_file_offset; + list_file.Sd_file_offset++; + break; + } + list_file.Sd_file_offset++; + #endif + } + list_file.Sd_file_cnt++; + } + //card.closefile(false); + return valid_name_cnt; +} + +#endif // SDSUPPORT + +uint8_t have_pre_pic(char *path) { + #if ENABLED(SDSUPPORT) + char *ps1, *ps2, *cur_name = strrchr(path, '/'); + + card.openFileRead(cur_name); + card.read(public_buf, 512); + ps1 = strstr((char *)public_buf, ";simage:"); + card.read(public_buf, 512); + ps2 = strstr((char *)public_buf, ";simage:"); + if (ps1 || ps2) { + card.closefile(); + return 1; + } + card.closefile(); + #endif + + return 0; +} + +LV_IMG_DECLARE(bmp_pic_117x92); +LV_IMG_DECLARE(bmp_pic_100x100); +LV_IMG_DECLARE(bmp_pic); +LV_IMG_DECLARE(bmp_pic_100x40); + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + uint8_t i, file_count = 0; + //switch (obj->mks_obj_id) + //{ + if (obj->mks_obj_id == ID_P_UP) { + if (event == LV_EVENT_CLICKED) { + } + else if (event == LV_EVENT_RELEASED) { + if (dir_offset[curDirLever].curPage > 0) { + //2015.05.19 + list_file.Sd_file_cnt = 0; + + if (dir_offset[curDirLever].cur_page_first_offset >= FILE_NUM) + list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset - FILE_NUM; + + #if ENABLED(SDSUPPORT) + file_count = search_file(); + #endif + if (file_count != 0) { + dir_offset[curDirLever].curPage--; + lv_obj_del(scr); + disp_gcode_icon(file_count); + } + } + } + } + else if (obj->mks_obj_id == ID_P_DOWN) { + if (event == LV_EVENT_CLICKED) { + } + else if (event == LV_EVENT_RELEASED) { + if (dir_offset[curDirLever].cur_page_last_offset > 0) { + list_file.Sd_file_cnt = 0; + list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_last_offset + 1; + #if ENABLED(SDSUPPORT) + file_count = search_file(); + #endif + if (file_count != 0) { + dir_offset[curDirLever].curPage++; + lv_obj_del(scr); + disp_gcode_icon(file_count); + } + if (file_count < FILE_NUM) + dir_offset[curDirLever].cur_page_last_offset = 0; + } + } + } + else if (obj->mks_obj_id == ID_P_RETURN) { + if (event == LV_EVENT_CLICKED) { + } + else if (event == LV_EVENT_RELEASED) { + if (curDirLever > 0) { + int8_t *ch = (int8_t *)strrchr(list_file.curDirPath, '/'); + if (ch) { + *ch = 0; + #if ENABLED(SDSUPPORT) + card.cdup(); + #endif + dir_offset[curDirLever].curPage = 0; + dir_offset[curDirLever].cur_page_first_offset = 0; + dir_offset[curDirLever].cur_page_last_offset = 0; + curDirLever--; + list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset; + #if ENABLED(SDSUPPORT) + file_count = search_file(); + #endif + lv_obj_del(scr); + disp_gcode_icon(file_count); + } + } + else { + lv_obj_del(scr); + lv_draw_ready_print(); + } + } + } + else { + for (i = 0; i < FILE_BTN_CNT; i++) { + if (obj->mks_obj_id == (i + 1)) { + if (event == LV_EVENT_CLICKED) { + } + else if (event == LV_EVENT_RELEASED) { + if (list_file.file_name[i][0] != 0) { + if (list_file.IsFolder[i] == 1) { + memset(list_file.curDirPath, 0, sizeof(list_file.curDirPath)); + strcpy(list_file.curDirPath, list_file.file_name[i]); + curDirLever++; + list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset; + #if ENABLED(SDSUPPORT) + file_count = search_file(); + #endif + lv_obj_del(scr); + disp_gcode_icon(file_count); + } + else { + sel_id = i; + lv_obj_del(scr); + lv_draw_dialog(DIALOG_TYPE_PRINT_FILE); + } + break; + } + } + } + } + } +} + +void lv_draw_print_file(void) { + //uint8_t i; + uint8_t file_count; + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PRINT_FILE_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = PRINT_FILE_UI; + } + disp_state = PRINT_FILE_UI; + + curDirLever = 0; + dir_offset[curDirLever].curPage = 0; + + list_file.Sd_file_offset = 0; + list_file.Sd_file_cnt = 0; + + ZERO(dir_offset); + ZERO(list_file.IsFolder); + ZERO(list_file.curDirPath); + + list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset; + #if ENABLED(SDSUPPORT) + card.mount(); + file_count = search_file(); + #endif + disp_gcode_icon(file_count); + + //lv_obj_t * labelPageUp = lv_label_create(buttonPageUp, NULL); + //lv_obj_t * labelPageDown = lv_label_create(buttonPageDown, NULL); + //lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + /* + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelPageUp, tool_menu.preheat); + lv_obj_align(labelPageUp, buttonPageUp, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelPageDown, tool_menu.extrude); + lv_obj_align(labelPageDown, buttonPageDown, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + } + */ +} + +void disp_gcode_icon(uint8_t file_num) { + uint8_t i; + + scr = lv_obj_create(NULL, NULL); + + //static lv_style_t tool_style; + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + buttonPageUp = lv_imgbtn_create(scr, NULL); + buttonPageDown = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonPageUp, event_handler, ID_P_UP, "bmp_pageUp.bin", 0); + lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_REL, &bmp_pic_117x92); + lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_PR, &bmp_pic_117x92); + lv_imgbtn_set_style(buttonPageUp, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPageUp, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonPageUp, LV_PROTECT_FOLLOW); + + #if 1 + lv_obj_set_event_cb_mks(buttonPageDown, event_handler, ID_P_DOWN, "bmp_pageDown.bin", 0); + lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_REL, &bmp_pic_117x92); + lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_PR, &bmp_pic_117x92); + lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_Back.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic_117x92); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic_117x92); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonPageUp, OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonPageDown, OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL + INTERVAL_H); + lv_obj_set_pos(buttonBack, OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL * 2 + INTERVAL_H * 2); + + /*Create a label on the Image button*/ + + lv_btn_set_layout(buttonPageUp, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonPageDown, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + for (i = 0; i < FILE_BTN_CNT; i++) { + /* + if(seq) { + j = (FILE_BTN_CNT-1) - i; + back_flg = 1; + } + else { + j = i; + back_flg = 0; + } + */ + if (i >= file_num) break; + + #ifdef TFT35 + buttonGcode[i] = lv_imgbtn_create(scr, NULL); + + lv_imgbtn_set_style(buttonGcode[i], LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonGcode[i], LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonGcode[i], LV_PROTECT_FOLLOW); + lv_btn_set_layout(buttonGcode[i], LV_LAYOUT_OFF); + + ZERO(public_buf_m); + cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m); + + if (list_file.IsFolder[i] == 1) { + lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "bmp_Dir.bin", 0); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic); + if (i < 3) + lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight); + else + lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1), BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + labelPageUp[i] = lv_label_create(buttonGcode[i], NULL); + lv_obj_set_style(labelPageUp[i], &tft_style_lable_rel); + lv_label_set_text(labelPageUp[i], public_buf_m); + lv_obj_align(labelPageUp[i], buttonGcode[i], LV_ALIGN_IN_BOTTOM_MID, 0, -5); + } + else { + if (have_pre_pic((char *)list_file.file_name[i])) { + lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic_100x100); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic_100x100); + if (i < 3) { + lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET); + buttonText[i] = lv_btn_create(scr, NULL); + //lv_obj_set_event_cb(buttonText[i], event_handler); + + lv_btn_set_style(buttonText[i], LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_btn_set_style(buttonText[i], LV_BTN_STATE_REL, &tft_style_lable_rel); + //lv_obj_set_style(buttonText[i], &tft_style_lable_pre); + //lv_obj_set_style(buttonText[i], &tft_style_lable_rel); + lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW); + lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF); + //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL,0); + //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_REL, &bmp_pic_100x40); + //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_PR, &bmp_pic_100x40); + lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET + 100); + lv_obj_set_size(buttonText[i], 100, 40); + } + else { + lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET); + buttonText[i] = lv_btn_create(scr, NULL); + //lv_obj_set_event_cb(buttonText[i], event_handler); + + lv_btn_set_style(buttonText[i], LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_btn_set_style(buttonText[i], LV_BTN_STATE_REL, &tft_style_lable_rel); + + //lv_imgbtn_set_style(buttonText[i], LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW); + lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF); + //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL,0); + //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_REL, &bmp_pic_100x40); + //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_PR, &bmp_pic_100x40); + lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET + 100); + lv_obj_set_size(buttonText[i], 100, 40); + } + labelPageUp[i] = lv_label_create(buttonText[i], NULL); + lv_obj_set_style(labelPageUp[i], &tft_style_lable_rel); + lv_label_set_text(labelPageUp[i], public_buf_m); + lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0); + } + else { + lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "bmp_File.bin", 0); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic); + if (i < 3) + lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight); + else + lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1), BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + labelPageUp[i] = lv_label_create(buttonGcode[i], NULL); + lv_obj_set_style(labelPageUp[i], &tft_style_lable_rel); + lv_label_set_text(labelPageUp[i], public_buf_m); + lv_obj_align(labelPageUp[i], buttonGcode[i], LV_ALIGN_IN_BOTTOM_MID, 0, -5); + } + } + #else // ifdef TFT35 + #endif // ifdef TFT35 + } +} + +void lv_open_gcode_file(char *path) { + #if ENABLED(SDSUPPORT) + //uint32_t read; + uint32_t *ps4; + int pre_sread_cnt; + char *cur_name; + + cur_name = strrchr(path, '/'); + + card.openFileRead(cur_name); + card.read(public_buf, 512); + ps4 = (uint32_t *)strstr((char *)public_buf, ";simage:"); + + if (ps4) { + pre_sread_cnt = (uint32_t)ps4 - (uint32_t)((uint32_t *)(&public_buf[0])); + card.setIndex(pre_sread_cnt + 8); + } + #endif +} + +int ascii2dec_test(char *ascii) { + int result = 0; + + if (ascii == 0) return 0; + + if (*(ascii) >= '0' && *(ascii) <= '9') + result = *(ascii) - '0'; + else if (*(ascii) >= 'a' && *(ascii) <= 'f') + result = *(ascii) - 'a' + 0x0a; + else if (*(ascii) >= 'A' && *(ascii) <= 'F') + result = *(ascii) - 'A' + 0x0a; + else + return 0; + + return result; +} + +void lv_gcode_file_read(uint8_t *data_buf) { + #if ENABLED(SDSUPPORT) + uint16_t i = 0, j = 0, k = 0; + //uint32_t read; + uint16_t row_1 = 0; + char temp_test[200]; + + while (1) { + card.read(temp_test, 200); + for (i = 0; i < 200;) { + public_buf[row_1 * 200 + 100 * k + j] = (char)(ascii2dec_test(&temp_test[i]) << 4 | ascii2dec_test(&temp_test[i + 1])); + j++; + i += 2; + } + k++; + j = 0; + if (k >= 2) { + k = 0; + card.read(temp_test, 9); + break; + } + } + memcpy(data_buf, public_buf, 200); + #endif +} + +void lv_close_gcode_file() {TERN_(SDSUPPORT, card.closefile());} + +void cutFileName(char *path, int len, int bytePerLine, char *outStr) { + #if _LFN_UNICODE + TCHAR *tmpFile; + TCHAR *strIndex1 = 0, *strIndex2 = 0, *beginIndex; + TCHAR secSeg[10] = {0}; + TCHAR gFileTail[4] = {'~', '.', 'g', '\0'}; + #else + char *tmpFile; + char *strIndex1 = 0, *strIndex2 = 0, *beginIndex; + char secSeg[10] = {0}; + #endif + + if (path == 0 || len <= 3 || outStr == 0) return; + + tmpFile = path; + #if _LFN_UNICODE + strIndex1 = (WCHAR *)wcsstr((const WCHAR *)tmpFile, (const WCHAR *)'/'); + strIndex2 = (WCHAR *)wcsstr((const WCHAR *)tmpFile, (const WCHAR *)'.'); + #else + strIndex1 = (char *)strrchr(tmpFile, '/'); + strIndex2 = (char *)strrchr(tmpFile, '.'); + #endif + + beginIndex = (strIndex1 != 0 + // && (strIndex2 != 0) && (strIndex1 < strIndex2) + ) ? strIndex1 + 1 : tmpFile; + + if (strIndex2 == 0 || (strIndex1 > strIndex2)) { // not gcode file + #if _LFN_UNICODE + if (wcslen(beginIndex) > len) + wcsncpy(outStr, beginIndex, len); + else + wcscpy(outStr, beginIndex); + #else + if ((int)strlen(beginIndex) > len) + strncpy(outStr, beginIndex, len); + else + strcpy(outStr, beginIndex); + #endif + } + else { //gcode file + if (strIndex2 - beginIndex > (len - 2)) { + #if _LFN_UNICODE + wcsncpy(outStr, (const WCHAR *)beginIndex, len - 3); + wcscat(outStr, (const WCHAR *)gFileTail); + #else + //strncpy(outStr, beginIndex, len - 3); + strncpy(outStr, beginIndex, len - 4); + strcat(outStr, "~.g"); + #endif + } + else { + #if _LFN_UNICODE + wcsncpy(outStr, (const WCHAR *)beginIndex, strIndex2 - beginIndex + 1); + wcscat(outStr, (const WCHAR *)&gFileTail[3]); + #else + strncpy(outStr, beginIndex, strIndex2 - beginIndex + 1); + strcat(outStr, "g"); + #endif + } + } + + #if _LFN_UNICODE + if (wcslen(outStr) > bytePerLine) { + wcscpy(secSeg, (const WCHAR *)&outStr[bytePerLine]); + outStr[bytePerLine] = '\n'; + outStr[bytePerLine + 1] = '\0'; + wcscat(outStr, (const WCHAR *)secSeg); + } + #else + if ((int)strlen(outStr) > bytePerLine) { + strcpy(secSeg, &outStr[bytePerLine]); + outStr[bytePerLine] = '\n'; + outStr[bytePerLine + 1] = '\0'; + strcat(outStr, secSeg); + } + else { + strcat(outStr, "\n"); + } + #endif +} + +void lv_clear_print_file() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h new file mode 100644 index 0000000..1b060d4 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h @@ -0,0 +1,65 @@ +/** + * 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 + +typedef struct { + int cur_page_first_offset; + int cur_page_last_offset; + int curPage; +} DIR_OFFSET; +extern DIR_OFFSET dir_offset[10]; + +#define FILE_NUM 6 +#define SHORT_NEME_LEN 13 +#define NAME_CUT_LEN 23 + +#define MAX_DIR_LEVEL 10 + +typedef struct { + //char longName[FILE_NUM][LONG_FILENAME_LENGTH]; + char file_name[FILE_NUM][SHORT_NEME_LEN * MAX_DIR_LEVEL + 1]; + char curDirPath[SHORT_NEME_LEN * MAX_DIR_LEVEL + 1]; + char long_name[FILE_NUM][SHORT_NEME_LEN * 2 + 1]; + char IsFolder[FILE_NUM]; + char Sd_file_cnt; + char sd_file_index; + char Sd_file_offset; +} LIST_FILE; +extern LIST_FILE list_file; + +extern void disp_gcode_icon(uint8_t file_num); +extern void lv_draw_print_file(void); +extern void lv_open_gcode_file(char *path); +extern void lv_gcode_file_read(uint8_t *data_buf); +extern void lv_close_gcode_file(); +extern void cutFileName(char *path, int len, int bytePerLine, char *outStr); +extern int ascii2dec_test(char *ascii); +extern void lv_clear_print_file(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp new file mode 100644 index 0000000..6580cc9 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -0,0 +1,443 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" +#include "../../../../module/motion.h" +#include "../../../../sd/cardreader.h" +#include "../../../../gcode/queue.h" + +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../../../../feature/powerloss.h" +#endif +#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) + #include "../../../ultralcd.h" +#endif + +static lv_obj_t * scr; +static lv_obj_t * labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime; +static lv_obj_t * labelPause, * labelStop, * labelOperat; +static lv_obj_t * bar1; +static lv_obj_t * buttonPause, *buttonOperat, *buttonStop; + +#if HAS_HEATED_BED + static lv_obj_t* labelBed; +#endif + +#define ID_PAUSE 1 +#define ID_STOP 2 +#define ID_OPTION 3 + +lv_style_t lv_bar_style_indic; + +uint8_t once_flag = 0; +extern uint32_t To_pre_view; +extern uint8_t flash_preview_begin; +extern uint8_t default_preview_flg; +extern uint8_t gcode_preview_over; + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_PAUSE: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (gcode_preview_over != 1) { + if (uiCfg.print_state == WORKING) { + //#if ENABLED(PARK_HEAD_ON_PAUSE) + //queue.inject_P(PSTR("M25 P\nM24")); + #if ENABLED(SDSUPPORT) + //queue.inject_P(PSTR("M25\nG91\nG1 Z10\nG90")); + card.pauseSDPrint(); + stop_print_time(); + uiCfg.print_state = PAUSING; + #endif + lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_Pause.bin", 0); + lv_label_set_text(labelPause, printing_menu.resume); + lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0); + } + else if (uiCfg.print_state == PAUSED) { + uiCfg.print_state = RESUMING; + //if (IS_SD_PAUSED())queue.inject_P(PSTR("M24"));// queue.inject_P(M24_STR); + lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_Resume.bin", 0); + lv_label_set_text(labelPause, printing_menu.pause); + lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0); + } + #if ENABLED(POWER_LOSS_RECOVERY) + else if (uiCfg.print_state == REPRINTING) { + uiCfg.print_state = REPRINTED; + lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_Resume.bin", 0); + lv_label_set_text(labelPause, printing_menu.pause); + lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0); + //recovery.resume(); + print_time.minutes = recovery.info.print_job_elapsed / 60; + print_time.seconds = recovery.info.print_job_elapsed % 60; + print_time.hours = print_time.minutes / 60; + } + #endif + } + } + break; + + case ID_STOP: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (gcode_preview_over != 1) { + lv_obj_del(scr); + lv_draw_dialog(DIALOG_TYPE_STOP); + } + } + break; + case ID_OPTION: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (gcode_preview_over != 1) { + lv_obj_del(scr); + lv_draw_opration(); + } + } + break; + } +} + +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; + + disp_state = PRINTING_UI; + + scr = lv_obj_create(NULL, NULL); + + //static lv_style_t tool_style; + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic_150x80); + LV_IMG_DECLARE(bmp_pic_45x45); + + /*Create an Image button*/ + buttonExt1 = lv_imgbtn_create(scr, NULL); + if (EXTRUDERS == 2) + buttonExt2 = lv_imgbtn_create(scr, NULL); + + #if HAS_HEATED_BED + buttonBedstate = lv_imgbtn_create(scr, NULL); + #endif + + buttonFanstate = lv_imgbtn_create(scr, NULL); + buttonZpos = lv_imgbtn_create(scr, NULL); + buttonPause = lv_imgbtn_create(scr, NULL); + buttonStop = lv_imgbtn_create(scr, NULL); + buttonOperat = lv_imgbtn_create(scr, NULL); + buttonTime = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonExt1, event_handler, 0, "bmp_Ext1_state.bin", 0); + lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_REL, &bmp_pic_45x45); + lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_PR, &bmp_pic_45x45); + lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonExt1, LV_PROTECT_FOLLOW); + #if 1 + if (EXTRUDERS == 2) { + lv_obj_set_event_cb_mks(buttonExt2, event_handler, 0, "bmp_Ext2_state.bin", 0); + lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_REL, &bmp_pic_45x45); + lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_PR, &bmp_pic_45x45); + lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_REL, &tft_style_lable_rel); + } + #if HAS_HEATED_BED + lv_obj_set_event_cb_mks(buttonBedstate, event_handler, 0, "bmp_Bed_state.bin", 0); + lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_REL, &bmp_pic_45x45); + lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_PR, &bmp_pic_45x45); + lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_event_cb_mks(buttonFanstate, event_handler, 0, "bmp_Fan_state.bin", 0); + lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_REL, &bmp_pic_45x45); + lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_PR, &bmp_pic_45x45); + lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonTime, event_handler, 0, "bmp_Time_state.bin", 0); + lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_REL, &bmp_pic_45x45); + lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_PR, &bmp_pic_45x45); + lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonZpos, event_handler, 0, "bmp_Zpos_state.bin", 0); + lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_REL, &bmp_pic_45x45); + lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_PR, &bmp_pic_45x45); + lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_REL, &tft_style_lable_rel); + + if (uiCfg.print_state == WORKING) + lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_Resume.bin", 0); + else + lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_Pause.bin", 0); + + lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, &bmp_pic_150x80); + lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, &bmp_pic_150x80); + lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, "bmp_Stop.bin", 0); + lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, &bmp_pic_150x80); + lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, &bmp_pic_150x80); + lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, "bmp_Operate.bin", 0); + lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, &bmp_pic_150x80); + lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, &bmp_pic_150x80); + lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonExt1, 205, 136); + if (EXTRUDERS == 2) + lv_obj_set_pos(buttonExt2, 350, 136); + + #if HAS_HEATED_BED + lv_obj_set_pos(buttonBedstate, 205, 186); + #endif + + lv_obj_set_pos(buttonFanstate, 350, 186); + lv_obj_set_pos(buttonTime, 205, 86); + lv_obj_set_pos(buttonZpos, 350, 86); + lv_obj_set_pos(buttonPause, 5, 240); + lv_obj_set_pos(buttonStop, 165, 240); + lv_obj_set_pos(buttonOperat, 325, 240); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonExt1, LV_LAYOUT_OFF); + if (EXTRUDERS == 2) + lv_btn_set_layout(buttonExt2, LV_LAYOUT_OFF); + + #if HAS_HEATED_BED + lv_btn_set_layout(buttonBedstate, LV_LAYOUT_OFF); + #endif + + lv_btn_set_layout(buttonFanstate, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonPause, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonStop, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonOperat, LV_LAYOUT_OFF); + + labelExt1 = lv_label_create(scr, NULL); + lv_obj_set_style(labelExt1, &tft_style_lable_rel); + lv_obj_set_pos(labelExt1, 250, 146); + + if (EXTRUDERS == 2) { + labelExt2 = lv_label_create(scr, NULL); + lv_obj_set_style(labelExt2, &tft_style_lable_rel); + lv_obj_set_pos(labelExt2, 395, 146); + } + + #if HAS_HEATED_BED + labelBed = lv_label_create(scr, NULL); + lv_obj_set_style(labelBed, &tft_style_lable_rel); + lv_obj_set_pos(labelBed, 250, 196); + #endif + + labelFan = lv_label_create(scr, NULL); + lv_obj_set_style(labelFan, &tft_style_lable_rel); + lv_obj_set_pos(labelFan, 395, 196); + + labelZpos = lv_label_create(scr, NULL); + lv_obj_set_style(labelZpos, &tft_style_lable_rel); + lv_obj_set_pos(labelZpos, 395, 96); + + labelTime = lv_label_create(scr, NULL); + lv_obj_set_style(labelTime, &tft_style_lable_rel); + lv_obj_set_pos(labelTime, 250, 96); + + labelPause = lv_label_create(buttonPause, NULL); + labelStop = lv_label_create(buttonStop, NULL); + labelOperat = lv_label_create(buttonOperat, NULL); + + if (gCfgItems.multiple_language != 0) { + if (uiCfg.print_state == WORKING) + lv_label_set_text(labelPause, printing_menu.pause); + else + lv_label_set_text(labelPause, printing_menu.resume); + lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0); + + lv_label_set_text(labelStop, printing_menu.stop); + lv_obj_align(labelStop, buttonStop, LV_ALIGN_CENTER, 30, 0); + + lv_label_set_text(labelOperat, printing_menu.option); + lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 30, 0); + } + + lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color); + lv_bar_style_indic.text.color = lv_color_hex3(0xADF); + lv_bar_style_indic.image.color = lv_color_hex3(0xADF); + lv_bar_style_indic.line.color = lv_color_hex3(0xADF); + lv_bar_style_indic.body.main_color = lv_color_hex3(0xADF); + lv_bar_style_indic.body.grad_color = lv_color_hex3(0xADF); + lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF); + + bar1 = lv_bar_create(scr, NULL); + lv_obj_set_pos(bar1, 205, 36); + lv_obj_set_size(bar1, 270, 40); + lv_bar_set_style(bar1, LV_BAR_STYLE_INDIC, &lv_bar_style_indic); + lv_bar_set_anim_time(bar1, 1000); + lv_bar_set_value(bar1, 0, LV_ANIM_ON); + + disp_ext_temp(); + disp_bed_temp(); + disp_fan_speed(); + disp_print_time(); + disp_fan_Zpos(); +} + +void disp_ext_temp() { + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); + lv_label_set_text(labelExt1, public_buf_l); + + if (EXTRUDERS == 2) { + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target); + lv_label_set_text(labelExt2, public_buf_l); + } +} + +void disp_bed_temp() { + #if HAS_HEATED_BED + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); + lv_label_set_text(labelBed, public_buf_l); + #endif +} + +void disp_fan_speed() { + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, "%3d", thermalManager.fan_speed[0]); + lv_label_set_text(labelFan, public_buf_l); +} + +void disp_print_time() { + memset(public_buf_l, 0, sizeof(public_buf_l)); + #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) + const uint32_t r = ui.get_remaining_time(); + sprintf(public_buf_l, "%02d:%02d R", r / 3600, (r % 3600) / 60); + #else + sprintf(public_buf_l, "%d%d:%d%d:%d%d", print_time.hours / 10, print_time.hours % 10, print_time.minutes / 10, print_time.minutes % 10, print_time.seconds / 10, print_time.seconds % 10); + #endif + lv_label_set_text(labelTime, public_buf_l); +} + +void disp_fan_Zpos() { + memset(public_buf_l, 0, sizeof(public_buf_l)); + sprintf(public_buf_l, "%.3f", current_position[Z_AXIS]); + lv_label_set_text(labelZpos, public_buf_l); +} + +void reset_print_time() { + //print_time.days = 0; + print_time.hours = 0; + print_time.minutes = 0; + print_time.seconds = 0; + print_time.ms_10 = 0; + //print_time.start = 1; +} + +void start_print_time() { print_time.start = 1; } + +void stop_print_time() { print_time.start = 0; } + +void setProBarRate() { + int rate; + volatile long long rate_tmp_r; + + if (gCfgItems.from_flash_pic != 1) { + #if ENABLED(SDSUPPORT) + rate_tmp_r = (long long)card.getIndex() * 100; + #endif + rate = rate_tmp_r / gCfgItems.curFilesize; + } + else { + #if ENABLED(SDSUPPORT) + rate_tmp_r = (long long)card.getIndex(); + #endif + rate = (rate_tmp_r - (PREVIEW_SIZE + To_pre_view)) * 100 / (gCfgItems.curFilesize - (PREVIEW_SIZE + To_pre_view)); + } + //gCurFileState.totalSend = rate; + + if (rate <= 0) return; + + if (disp_state == PRINTING_UI) { + lv_bar_set_value(bar1, rate, LV_ANIM_ON); + + if (marlin_state == MF_SD_COMPLETE) { + if (once_flag == 0) { + stop_print_time(); + + flash_preview_begin = 0; + default_preview_flg = 0; + lv_clear_printing(); + lv_draw_dialog(DIALOG_TYPE_FINISH_PRINT); + + once_flag = 1; + + #if HAS_SUICIDE + if (gCfgItems.finish_power_off == 1) + suicide(); + #endif + } + } + } +} + +void lv_clear_printing() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h new file mode 100644 index 0000000..1e0cc86 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h @@ -0,0 +1,52 @@ +/** + * 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 + +#define IDLE 0 +#define WORKING 1 +#define PAUSING 2 +#define PAUSED 3 +#define REPRINTING 4 +#define REPRINTED 5 +#define RESUMING 6 +#define STOP 7 + +extern void lv_draw_printing(void); +extern void lv_clear_printing(); +extern void disp_ext_temp(); +extern void disp_bed_temp(); +extern void disp_fan_speed(); +extern void disp_print_time(); +extern void disp_fan_Zpos(); +extern void reset_print_time(); +extern void start_print_time(); +extern void stop_print_time(); +extern void setProBarRate(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp new file mode 100644 index 0000000..a3708ef --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -0,0 +1,319 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "draw_ready_print.h" +#include "draw_tool.h" +#include "lv_conf.h" +#include "lvgl.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" +#include "tft_lvgl_configuration.h" +#include "mks_hardware_test.h" +#include "draw_ui.h" + +#include + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" + +//static lv_obj_t *buttonPrint,*buttonTool,*buttonSet; +static lv_obj_t * scr; +#if ENABLED(MKS_TEST) + uint8_t curent_disp_ui = 0; +#endif + +#define ID_TOOL 1 +#define ID_SET 2 +#define ID_PRINT 3 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_TOOL: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + #if ENABLED(MKS_TEST) + curent_disp_ui = 2; + #endif + lv_obj_del(scr); + lv_draw_tool(); + } + break; + case ID_SET: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_obj_del(scr); + lv_draw_set(); + } + break; + case ID_PRINT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_obj_del(scr); + lv_draw_print_file(); + } + break; + } +} + + +#if ENABLED(MKS_TEST) + + lv_obj_t *limit_info, *det_info; + lv_style_t limit_style, det_style; + void disp_Limit_ok() { + limit_style.text.color.full = 0xFFFF; + lv_obj_set_style(limit_info, &limit_style); + lv_label_set_text(limit_info, "Limit:ok"); + } + void disp_Limit_error() { + limit_style.text.color.full = 0xF800; + lv_obj_set_style(limit_info, &limit_style); + lv_label_set_text(limit_info, "Limit:error"); + } + + void disp_det_ok() { + det_style.text.color.full = 0xFFFF; + lv_obj_set_style(det_info, &det_style); + lv_label_set_text(det_info, "det:ok"); + } + void disp_det_error() { + det_style.text.color.full = 0xF800; + lv_obj_set_style(det_info, &det_style); + lv_label_set_text(det_info, "det:error"); + } + + lv_obj_t *e1, *e2, *e3, *bed; + void disp_test() { + char buf[30] = {0}; + //lv_obj_t * label_tool2 = lv_label_create(scr, NULL); + //lv_obj_set_pos(label_tool,20,50); + memset(buf, 0, sizeof(buf)); + sprintf(buf, "e1:%d", (int)thermalManager.temp_hotend[0].celsius); + lv_label_set_text(e1, buf); + + memset(buf, 0, sizeof(buf)); + sprintf(buf, "e2:%d", (int)thermalManager.temp_hotend[1].celsius); + lv_label_set_text(e2, buf); + + memset(buf, 0, sizeof(buf)); + sprintf(buf, "e3:%d", (int)thermalManager.temp_hotend[2].celsius); + lv_label_set_text(e3, buf); + + memset(buf, 0, sizeof(buf)); + sprintf(buf, "bed:%d", (int)thermalManager.temp_bed.celsius); + lv_label_set_text(bed, buf); + } + +#endif // MKS_TEST + +void lv_draw_ready_print(void) { + #if ENABLED(MKS_TEST) + char buf[30] = {0}; + lv_obj_t *buttonTool; + + static lv_style_t style_pr, style_rel; + + curent_disp_ui = 1; + + scr = lv_obj_create(NULL, NULL); + + static lv_style_t ready_style; + + lv_style_copy(&ready_style, &lv_style_scr); + //ready_style.body.main_color.full = 0X18C3; + //ready_style.body.grad_color.full = 0X18C3; + ready_style.body.main_color.full = 0X0000; + ready_style.body.grad_color.full = 0X0000; + ready_style.text.color.full = 0Xffff; + lv_obj_set_style(scr, &ready_style); + lv_scr_load(scr); + lv_obj_clean(scr); + //lv_obj_set_hidden(scr,true); + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + //LV_IMG_DECLARE(bmp_pic2); + //LV_IMG_DECLARE(bmp_pic3); + + //scr = lv_obj_create(NULL, NULL); + //lv_scr_load(scr); + + /*Create an Image button*/ + buttonTool = lv_imgbtn_create(scr, NULL); + + //lv_btn_setting(&style_pr,0x5d8f16,0x5d8f16); + //lv_btn_setting(&style_rel,0x5d8f16,0x5d8f16); + + lv_obj_set_event_cb_mks(buttonTool, event_handler, 3, "bmp_Tool.bin", 0); + //lv_imgbtn_set_src_mks(buttonTool, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_tool.bin"); + lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &style_pr); + lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &style_rel); + + lv_obj_set_pos(buttonTool, 360, 180); + + lv_btn_set_layout(buttonTool, LV_LAYOUT_OFF); + + lv_obj_t * label_tool = lv_label_create(buttonTool, NULL); + + lv_obj_set_pos(label_tool, 30, 100); + lv_label_set_text(label_tool, "Back"); + + e1 = lv_label_create(scr, NULL); + lv_obj_set_pos(e1, 20, 20); + sprintf(buf, "e1: %d", (int)thermalManager.temp_hotend[0].celsius); + lv_label_set_text(e1, buf); + + e2 = lv_label_create(scr, NULL); + lv_obj_set_pos(e2, 20, 45); + sprintf(buf, "e1: %d", (int)thermalManager.temp_hotend[1].celsius); + lv_label_set_text(e2, buf); + + e3 = lv_label_create(scr, NULL); + lv_obj_set_pos(e3, 20, 70); + sprintf(buf, "e1: %d", (int)thermalManager.temp_hotend[2].celsius); + lv_label_set_text(e3, buf); + + bed = lv_label_create(scr, NULL); + lv_obj_set_pos(bed, 20, 95); + sprintf(buf, "bed: %d", (int)thermalManager.temp_bed.celsius); + lv_label_set_text(bed, buf); + + limit_info = lv_label_create(scr, NULL); + + lv_style_copy(&limit_style, &lv_style_scr); + limit_style.body.main_color.full = 0X0000; + limit_style.body.grad_color.full = 0X0000; + limit_style.text.color.full = 0Xffff; + lv_obj_set_style(limit_info, &limit_style); + + lv_obj_set_pos(limit_info, 20, 120); + lv_label_set_text(limit_info, " "); + + det_info = lv_label_create(scr, NULL); + + lv_style_copy(&det_style, &lv_style_scr); + det_style.body.main_color.full = 0X0000; + det_style.body.grad_color.full = 0X0000; + det_style.text.color.full = 0Xffff; + lv_obj_set_style(det_info, &det_style); + + lv_obj_set_pos(det_info, 20, 145); + lv_label_set_text(det_info, " "); + #else // !MKS_TEST + lv_obj_t *buttonPrint, *buttonTool, *buttonSet; + + disp_state_stack._disp_index = 0; + memset(disp_state_stack._disp_state, 0, sizeof(disp_state_stack._disp_state)); + disp_state_stack._disp_state[disp_state_stack._disp_index] = PRINT_READY_UI; + + disp_state = PRINT_READY_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + //lv_obj_set_hidden(scr,true); + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + //lv_obj_t * title = lv_label_create(scr, NULL); + //lv_obj_set_style(title, &tft_style_lable_rel); + //lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); + //lv_label_set_text(title, creat_title_text()); + + /*Create an Image button*/ + buttonPrint = lv_imgbtn_create(scr, NULL); + buttonTool = lv_imgbtn_create(scr, NULL); + buttonSet = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonPrint, event_handler, ID_PRINT, "bmp_Print.bin", 0); + //lv_imgbtn_set_src_mks(buttonPrint, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_printing.bin"); + lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonPrint, LV_PROTECT_FOLLOW); + #if 1 + lv_obj_set_event_cb_mks(buttonSet, event_handler, ID_SET, "bmp_Set.bin", 0); + //lv_imgbtn_set_src_mks(buttonSet, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_set.bin"); + lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, "bmp_Tool.bin", 0); + //lv_imgbtn_set_src_mks(buttonTool, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_tool.bin"); + lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + lv_obj_set_pos(buttonTool, 20, 90); + lv_obj_set_pos(buttonSet, 180, 90); + lv_obj_set_pos(buttonPrint, 340, 90); + + //lv_obj_set_pos(buttonTool,SIMPLE_FIRST_PAGE_GRAP+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2); + //lv_obj_set_pos(buttonSet,BTN_X_PIXEL+SIMPLE_FIRST_PAGE_GRAP*2+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2); + //lv_obj_set_pos(buttonPrint,BTN_X_PIXEL*2+SIMPLE_FIRST_PAGE_GRAP*3+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonPrint, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonSet, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonTool, LV_LAYOUT_OFF); + + lv_obj_t * label_print = lv_label_create(buttonPrint, NULL); + lv_obj_t * label_set = lv_label_create(buttonSet, NULL); + lv_obj_t * label_tool = lv_label_create(buttonTool, NULL); + if (gCfgItems.multiple_language != 0) { + + lv_label_set_text(label_print, main_menu.print); + lv_obj_align(label_print, buttonPrint, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_set, main_menu.set); + lv_obj_align(label_set, buttonSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + //lv_label_set_style(label_tool,LV_BTN_STATE_PR,&tft_style_lable_pre); + //lv_label_set_style(label_tool,LV_BTN_STATE_REL,&tft_style_lable_rel); + lv_label_set_text(label_tool, main_menu.tool); + lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + #endif // !MKS_TEST +} + +void lv_clear_ready_print() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h new file mode 100644 index 0000000..fbb3a00 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h @@ -0,0 +1,39 @@ +/** + * 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 + +extern void lv_draw_ready_print(void); +extern void disp_test(); +extern void disp_Limit_ok(); +extern void disp_Limit_error(); +extern void disp_det_error(); +extern void disp_det_ok(); +extern void lv_clear_ready_print(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp new file mode 100644 index 0000000..e41e943 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp @@ -0,0 +1,258 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "../../../../MarlinCore.h" +#include "draw_ready_print.h" +#include "draw_set.h" +#include "lv_conf.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" +#include "draw_ui.h" +#include "../../../../gcode/queue.h" + +static lv_obj_t * scr; + +#define ID_S_WIFI 1 +#define ID_S_FAN 2 +#define ID_S_ABOUT 3 +#define ID_S_CONTINUE 4 +#define ID_S_MOTOR_OFF 5 +#define ID_S_LANGUAGE 6 +#define ID_S_RETURN 7 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_S_WIFI: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + } + break; + case ID_S_FAN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_obj_del(scr); + lv_draw_fan(); + } + break; + case ID_S_ABOUT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_obj_del(scr); + lv_draw_about(); + } + break; + case ID_S_CONTINUE: + + break; + case ID_S_MOTOR_OFF: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + #if HAS_SUICIDE + suicide(); + #else + queue.enqueue_one_now(PSTR("M84")); + #endif + } + break; + case ID_S_LANGUAGE: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_obj_del(scr); + lv_draw_language(); + } + break; + case ID_S_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_obj_del(scr); + lv_draw_ready_print(); + } + break; + + } +} + +void lv_draw_set(void) { + lv_obj_t *buttonFan, *buttonAbout; + lv_obj_t *buMotorOff, *buttonLanguage, *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != SET_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = SET_UI; + } + disp_state = SET_UI; + + scr = lv_obj_create(NULL, NULL); + + //static lv_style_t tool_style; + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + //buttonWifi = lv_imgbtn_create(scr, NULL); + buttonFan = lv_imgbtn_create(scr, NULL); + buttonAbout = lv_imgbtn_create(scr, NULL); + //buttonContinue = lv_imgbtn_create(scr, NULL); + buMotorOff = lv_imgbtn_create(scr, NULL); + buttonLanguage = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + + //lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,"bmp_Wifi.bin",0); + //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, &bmp_pic); + //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, &bmp_pic); + //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_lable_pre); + //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_lable_rel); + //lv_obj_clear_protect(buttonWifi, LV_PROTECT_FOLLOW); + #if 1 + lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_S_FAN, "bmp_Fan.bin", 0); + lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonAbout, event_handler, ID_S_ABOUT, "bmp_About.bin", 0); + lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonAbout, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonAbout, LV_BTN_STATE_REL, &tft_style_lable_rel); + + //lv_obj_set_event_cb_mks(buttonContinue, event_handler,ID_S_CONTINUE,"bmp_Breakpoint.bin",0); + //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_REL, &bmp_pic); + //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_PR, &bmp_pic); + //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_PR, &tft_style_lable_pre); + //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_REL, &tft_style_lable_rel); + #if HAS_SUICIDE + lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_Mamual.bin", 0); + #else + lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_Motor_off.bin", 0); + #endif + lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonLanguage, event_handler, ID_S_LANGUAGE, "bmp_Language.bin", 0); + lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_S_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + /*lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight); + lv_obj_set_pos(buttonFan,BTN_X_PIXEL+INTERVAL_V*2,titleHeight); + lv_obj_set_pos(buttonAbout,BTN_X_PIXEL*2+INTERVAL_V*3,titleHeight); + lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight); + lv_obj_set_pos(buMotorOff,INTERVAL_V, BTN_Y_PIXEL+INTERVAL_H+titleHeight); + lv_obj_set_pos(buttonLanguage,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight); + lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight);*/ + + //lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight); + lv_obj_set_pos(buttonFan, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); + lv_obj_set_pos(buttonAbout, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); + //lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight); + lv_obj_set_pos(buMotorOff, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonLanguage, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + //lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonFan, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonAbout, LV_LAYOUT_OFF); + //lv_btn_set_layout(buttonContinue, LV_LAYOUT_OFF); + lv_btn_set_layout(buMotorOff, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonLanguage, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + //lv_obj_t * labelWifi= lv_label_create(buttonWifi, NULL); + lv_obj_t * labelFan = lv_label_create(buttonFan, NULL); + lv_obj_t * label_About = lv_label_create(buttonAbout, NULL); + //lv_obj_t * label_Continue = lv_label_create(buttonContinue, NULL); + lv_obj_t * label_MotorOff = lv_label_create(buMotorOff, NULL); + lv_obj_t * label_Language = lv_label_create(buttonLanguage, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + + if (gCfgItems.multiple_language != 0) { + //lv_label_set_text(labelWifi, set_menu.wifi); + //lv_obj_align(labelWifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelFan, set_menu.fan); + lv_obj_align(labelFan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_About, set_menu.about); + lv_obj_align(label_About, buttonAbout, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + //lv_label_set_text(label_Continue, set_menu.breakpoint); + //lv_obj_align(label_Continue, buttonContinue, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + #if HAS_SUICIDE + lv_label_set_text(label_MotorOff, set_menu.shutdown); + #else + lv_label_set_text(label_MotorOff, set_menu.motoroff); + #endif + lv_obj_align(label_MotorOff, buMotorOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Language, set_menu.language); + lv_obj_align(label_Language, buttonLanguage, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } +} + +void lv_clear_set() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h new file mode 100644 index 0000000..e2300e4 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h @@ -0,0 +1,34 @@ +/** + * 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 + +extern void lv_draw_set(void); +extern void lv_clear_set(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp new file mode 100644 index 0000000..dc87ec5 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp @@ -0,0 +1,270 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "lv_conf.h" +#include "draw_ui.h" +//#include "../lvgl/src/lv_objx/lv_imgbtn.h" +//#include "../lvgl/src/lv_objx/lv_img.h" +//#include "../lvgl/src/lv_core/lv_disp.h" +//#include "../lvgl/src/lv_core/lv_refr.h" + +#include "../../../../MarlinCore.h" +#include "../../../../gcode/queue.h" + +//static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn; +static lv_obj_t * scr; +#if ENABLED(MKS_TEST) + extern uint8_t curent_disp_ui; +#endif + +#define ID_T_PRE_HEAT 1 +#define ID_T_EXTRUCT 2 +#define ID_T_MOV 3 +#define ID_T_HOME 4 +#define ID_T_LEVELING 5 +#define ID_T_FILAMENT 6 +#define ID_T_MORE 7 +#define ID_T_RETURN 8 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_T_PRE_HEAT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_tool(); + lv_draw_preHeat(); + } + break; + case ID_T_EXTRUCT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_tool(); + lv_draw_extrusion(); + } + break; + case ID_T_MOV: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_tool(); + lv_draw_move_motor(); + } + break; + case ID_T_HOME: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_tool(); + lv_draw_home(); + } + break; + case ID_T_LEVELING: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + queue.enqueue_one_P(PSTR("G28")); + queue.enqueue_one_P(PSTR("G29")); + #else + uiCfg.leveling_first_time = 1; + lv_clear_tool(); + lv_draw_manualLevel(); + #endif + } + break; + case ID_T_FILAMENT: break; + case ID_T_MORE: break; + case ID_T_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + TERN_(MKS_TEST, curent_disp_ui = 1); + lv_obj_del(scr); + lv_draw_ready_print(); + } + break; + } +} + +void lv_draw_tool(void) { + lv_obj_t *buttonPreHeat, *buttonExtrusion, *buttonMove, *buttonHome, *buttonLevel; + lv_obj_t *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TOOL_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = TOOL_UI; + } + disp_state = TOOL_UI; + + scr = lv_obj_create(NULL, NULL); + + //static lv_style_t tool_style; + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_lable_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + LV_IMG_DECLARE(bmp_pic); + + /*Create an Image button*/ + buttonPreHeat = lv_imgbtn_create(scr, NULL); + buttonExtrusion = lv_imgbtn_create(scr, NULL); + buttonMove = lv_imgbtn_create(scr, NULL); + buttonHome = lv_imgbtn_create(scr, NULL); + buttonLevel = lv_imgbtn_create(scr, NULL); + //buttonFilament = lv_imgbtn_create(scr, NULL); + //buttonMore = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_T_PRE_HEAT, "bmp_PreHeat.bin", 0); + lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_REL, &tft_style_lable_rel); + lv_obj_clear_protect(buttonPreHeat, LV_PROTECT_FOLLOW); + + #if 1 + lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_T_EXTRUCT, "bmp_Extruct.bin", 0); + lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_T_MOV, "bmp_Mov.bin", 0); + lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonHome, event_handler, ID_T_HOME, "bmp_Zero.bin", 0); + lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_T_LEVELING, "bmp_Leveling.bin", 0); + lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_REL, &tft_style_lable_rel); + + //lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_T_FILAMENT,"bmp_Filamentchange.bin",0); + //lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, &bmp_pic); + //lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, &bmp_pic); + //lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_lable_pre); + //lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_lable_rel); + + //lv_obj_set_event_cb_mks(buttonMore, event_handler,ID_T_MORE,"bmp_More.bin",0); + //lv_imgbtn_set_src(buttonMore, LV_BTN_STATE_REL, &bmp_pic); + //lv_imgbtn_set_src(buttonMore, LV_BTN_STATE_PR, &bmp_pic); + //lv_imgbtn_set_style(buttonMore, LV_BTN_STATE_PR, &tft_style_lable_pre); + //lv_imgbtn_set_style(buttonMore, LV_BTN_STATE_REL, &tft_style_lable_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_T_RETURN, "bmp_Return.bin", 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_lable_rel); + #endif + + lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonExtrusion, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); + lv_obj_set_pos(buttonMove, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); + lv_obj_set_pos(buttonHome, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonLevel, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + //lv_obj_set_pos(buttonFilament,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight); + //lv_obj_set_pos(buttonMore,BTN_X_PIXEL*2+INTERVAL_V*3, BTN_Y_PIXEL+INTERVAL_H+titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + /*Create a label on the Image button*/ + lv_btn_set_layout(buttonPreHeat, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonExtrusion, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonMove, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonHome, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF); + //lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF); + //lv_btn_set_layout(buttonMore, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t * labelPreHeat = lv_label_create(buttonPreHeat, NULL); + lv_obj_t * labelExtrusion = lv_label_create(buttonExtrusion, NULL); + lv_obj_t * label_Move = lv_label_create(buttonMove, NULL); + lv_obj_t * label_Home = lv_label_create(buttonHome, NULL); + lv_obj_t * label_Level = lv_label_create(buttonLevel, NULL); + //lv_obj_t * label_Filament = lv_label_create(buttonFilament, NULL); + //lv_obj_t * label_More = lv_label_create(buttonMore, NULL); + lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelPreHeat, tool_menu.preheat); + lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelExtrusion, tool_menu.extrude); + lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Move, tool_menu.move); + lv_obj_align(label_Move, buttonMove, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Home, tool_menu.home); + lv_obj_align(label_Home, buttonHome, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + /* + if (gCfgItems.leveling_mode != 2) { + lv_label_set_text(label_Level, gCfgItems.leveling_mode == 1 ? tool_menu.autoleveling : tool_menu.leveling); + lv_obj_align(label_Level, buttonLevel, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + */ + lv_label_set_text(label_Level, tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling)); + lv_obj_align(label_Level, buttonLevel, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + //lv_label_set_text(label_Filament, tool_menu.filament); + //lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + //lv_label_set_text(label_More, tool_menu.more); + //lv_obj_align(label_More, buttonMore, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } +} + +void lv_clear_tool() { lv_obj_del(scr); } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h new file mode 100644 index 0000000..b05b6fe --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h @@ -0,0 +1,34 @@ +/** + * 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 + +extern void lv_draw_tool(void); +extern void lv_clear_tool(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp new file mode 100644 index 0000000..01fa6bc --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -0,0 +1,1181 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "W25Qxx.h" +#include "tft_lvgl_configuration.h" +#include "pic_manager.h" + +#include + +#if ENABLED(SPI_GRAPHICAL_TFT) + #include "SPI_TFT.h" +#endif + +#include "../../../../MarlinCore.h" +#include "../../../../sd/cardreader.h" +#include "../../../../module/motion.h" +#include "../../../../module/planner.h" + +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../../../../feature/powerloss.h" +#endif + +#if ENABLED(PARK_HEAD_ON_PAUSE) + #include "../../../../feature/pause.h" +#endif + +CFG_ITMES gCfgItems; +UI_CFG uiCfg; +DISP_STATE_STACK disp_state_stack; +DISP_STATE disp_state = MAIN_UI; +DISP_STATE last_disp_state; +PRINT_TIME print_time; + +uint32_t To_pre_view; +uint8_t gcode_preview_over; +uint8_t flash_preview_begin; +uint8_t default_preview_flg; +uint32_t size = 809; +uint16_t row; +uint8_t temperature_change_frequency; +uint8_t printing_rate_update_flag; + +extern uint8_t once_flag; +extern uint8_t sel_id; +extern uint8_t public_buf[512]; +extern uint8_t bmp_public_buf[17 * 1024]; + +extern void LCD_IO_WriteData(uint16_t RegValue); + +void gCfgItems_init() { + gCfgItems.multiple_language = MULTI_LANGUAGE_ENABLE; + gCfgItems.language = LANG_ENGLISH; + gCfgItems.leveling_mode = 0; + gCfgItems.from_flash_pic = 0; + gCfgItems.curFilesize = 0; + gCfgItems.finish_power_off = 0; + gCfgItems.pause_reprint = 0; + + W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems.spi_flash_flag, VAR_INF_ADDR, sizeof(gCfgItems.spi_flash_flag)); + if (gCfgItems.spi_flash_flag == GCFG_FLAG_VALUE) { + W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); + } + else { + gCfgItems.spi_flash_flag = GCFG_FLAG_VALUE; + W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); + } + +} + +void gCfg_to_spiFlah() { + W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); +} + +void ui_cfg_init() { + uiCfg.curTempType = 0; + uiCfg.curSprayerChoose = 0; + uiCfg.stepHeat = 10; + uiCfg.leveling_first_time = 0; + uiCfg.extruStep = 5; + uiCfg.extruSpeed = 10; + uiCfg.move_dist = 1; + uiCfg.moveSpeed = 3000; + uiCfg.stepPrintSpeed = 10; +} + +void update_spi_flash() { + W25QXX.init(SPI_QUARTER_SPEED); + W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); +} + +lv_style_t tft_style_scr; +lv_style_t tft_style_lable_pre; +lv_style_t tft_style_lable_rel; + +void tft_style_init() { + lv_style_copy(&tft_style_scr, &lv_style_scr); + tft_style_scr.body.main_color = LV_COLOR_BACKGROUND; + tft_style_scr.body.grad_color = LV_COLOR_BACKGROUND; + tft_style_scr.text.color = LV_COLOR_TEXT; + tft_style_scr.text.sel_color = LV_COLOR_TEXT; + tft_style_scr.line.width = 0; + tft_style_scr.text.letter_space = 0; + tft_style_scr.text.line_space = 0; + + lv_style_copy(&tft_style_lable_pre, &lv_style_scr); + lv_style_copy(&tft_style_lable_rel, &lv_style_scr); + tft_style_lable_pre.body.main_color = LV_COLOR_BACKGROUND; + tft_style_lable_pre.body.grad_color = LV_COLOR_BACKGROUND; + tft_style_lable_pre.text.color = LV_COLOR_TEXT; + tft_style_lable_pre.text.sel_color = LV_COLOR_TEXT; + tft_style_lable_rel.body.main_color = LV_COLOR_BACKGROUND; + tft_style_lable_rel.body.grad_color = LV_COLOR_BACKGROUND; + tft_style_lable_rel.text.color = LV_COLOR_TEXT; + tft_style_lable_rel.text.sel_color = LV_COLOR_TEXT; + tft_style_lable_pre.text.font = &gb2312_puhui32; + tft_style_lable_rel.text.font = &gb2312_puhui32; + tft_style_lable_pre.line.width = 0; + tft_style_lable_rel.line.width = 0; + tft_style_lable_pre.text.letter_space = 0; + tft_style_lable_rel.text.letter_space = 0; + tft_style_lable_pre.text.line_space = -5; + tft_style_lable_rel.text.line_space = -5; +} + +#define MAX_TITLE_LEN 28 + +char public_buf_m[100] = {0}; + +char public_buf_l[30]; + +void titleText_cat(char *str, int strSize, char *addPart) { + if (str == 0 || addPart == 0) return; + if ((int)(strlen(str) + strlen(addPart)) >= strSize) return; + strcat(str, addPart); +} + +char *getDispText(int index) { + + memset(public_buf_l, 0, sizeof(public_buf_l)); + + switch (disp_state_stack._disp_state[index]) { + case PRINT_READY_UI: + strcpy(public_buf_l, main_menu.title); + break; + case PRINT_FILE_UI: + strcpy(public_buf_l, file_menu.title); + break; + case PRINTING_UI: + if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI + #ifndef TFT35 + || disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI + || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI + #endif + ) strcpy(public_buf_l, common_menu.print_special_title); + else strcpy(public_buf_l, printing_menu.title); + break; + case MOVE_MOTOR_UI: + strcpy(public_buf_l, move_menu.title); + break; + case OPERATE_UI: + if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI + #ifndef TFT35 + || disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI + || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI + #endif + ) strcpy(public_buf_l, common_menu.operate_special_title); + else strcpy(public_buf_l, operation_menu.title); + break; + + case PAUSE_UI: + if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI + || disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI + || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI + ) strcpy(public_buf_l, common_menu.pause_special_title); + else strcpy(public_buf_l, pause_menu.title); + break; + + case EXTRUSION_UI: + strcpy(public_buf_l, extrude_menu.title); + break; + case CHANGE_SPEED_UI: + strcpy(public_buf_l, speed_menu.title); + break; + case FAN_UI: + strcpy(public_buf_l, fan_menu.title); + break; + case PRE_HEAT_UI: + if ((disp_state_stack._disp_state[disp_state_stack._disp_index - 1] == OPERATE_UI)) strcpy(public_buf_l, preheat_menu.adjust_title); + else strcpy(public_buf_l, preheat_menu.title); + break; + case SET_UI: + strcpy(public_buf_l, set_menu.title); + break; + case ZERO_UI: + strcpy(public_buf_l, home_menu.title); + break; + case SPRAYER_UI: break; + case MACHINE_UI: break; + case LANGUAGE_UI: + strcpy(public_buf_l, language_menu.title); + break; + case ABOUT_UI: + strcpy(public_buf_l, about_menu.title); + break; + case LOG_UI: break; + case DISK_UI: + strcpy(public_buf_l, filesys_menu.title); + break; + case DIALOG_UI: + strcpy(public_buf_l, common_menu.dialog_confirm_title); + break; + case WIFI_UI: + strcpy(public_buf_l, wifi_menu.title); + break; + case MORE_UI: + case PRINT_MORE_UI: + strcpy(public_buf_l, more_menu.title); + break; + case FILAMENTCHANGE_UI: + strcpy(public_buf_l, filament_menu.title); + break; + case LEVELING_UI: + case MESHLEVELING_UI: + strcpy(public_buf_l, leveling_menu.title); + break; + case BIND_UI: + strcpy(public_buf_l, cloud_menu.title); + break; + case ZOFFSET_UI: + strcpy(public_buf_l, zoffset_menu.title); + break; + case TOOL_UI: + strcpy(public_buf_l, tool_menu.title); + break; + case WIFI_LIST_UI: + //strcpy(public_buf_l, list_menu.title); + break; + case MACHINE_PARA_UI: + strcpy(public_buf_l, MachinePara_menu.title); + break; + case BABY_STEP_UI: + strcpy(public_buf_l, operation_menu.babystep); + break; + default: break; + } + + return public_buf_l; +} + +char *creat_title_text() { + int index = 0; + char *tmpText = 0; + char tmpCurFileStr[20]; + + memset(tmpCurFileStr, 0, sizeof(tmpCurFileStr)); + + #if _LFN_UNICODE + //cutFileName((TCHAR *)curFileName, 16, 16, (TCHAR *)tmpCurFileStr); + #else + cutFileName(list_file.long_name[sel_id], 16, 16, tmpCurFileStr); + #endif + + memset(public_buf_m, 0, sizeof(public_buf_m)); + + while (index <= disp_state_stack._disp_index) { + tmpText = getDispText(index); + if ((*tmpText == 0) || (tmpText == 0)) { + index++; + continue; + } + + titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText); + if (index < disp_state_stack._disp_index) titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)">"); + + index++; + } + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI + /*|| disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI + || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI*/) { + titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)":"); + titleText_cat(public_buf_m, sizeof(public_buf_m), tmpCurFileStr); + } + + if (strlen(public_buf_m) > MAX_TITLE_LEN) { + memset(public_buf_m, 0, sizeof(public_buf_m)); + + tmpText = getDispText(0); + if (*tmpText != 0) { + titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText); + titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)">...>"); + tmpText = getDispText(disp_state_stack._disp_index); + if (*tmpText != 0) titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText); + } + + } + + return public_buf_m; +} + +void preview_gcode_prehandle(char *path) { + #if ENABLED(SDSUPPORT) + //uint8_t re; + //uint32_t read; + uint32_t pre_read_cnt = 0; + uint32_t *p1; + char *cur_name; + + cur_name = strrchr(path, '/'); + card.openFileRead(cur_name); + card.read(public_buf, 512); + p1 = (uint32_t *)strstr((char *)public_buf, ";simage:"); + + if (p1) { + pre_read_cnt = (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0])); + + To_pre_view = pre_read_cnt; + gcode_preview_over = 1; + gCfgItems.from_flash_pic = 1; + update_spi_flash(); + } + else { + gcode_preview_over = 0; + default_preview_flg = 1; + gCfgItems.from_flash_pic = 0; + update_spi_flash(); + } + card.closefile(); + #endif +} + +void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) { + #if ENABLED(SDSUPPORT) + //uint8_t ress; + //uint32_t write; + volatile uint32_t i, j; + volatile uint16_t *p_index; + //int res; + char *cur_name; + uint16_t Color; + + cur_name = strrchr(path, '/'); + card.openFileRead(cur_name); + + card.setIndex((PREVIEW_LITTLE_PIC_SIZE + To_pre_view) + size * row + 8); + #if ENABLED(SPI_GRAPHICAL_TFT) + SPI_TFT.spi_init(SPI_FULL_SPEED); + //SPI_TFT.SetCursor(0,0); + SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1); + SPI_TFT.LCD_WriteRAM_Prepare(); + #else + ili9320_SetWindows(xpos_pixel, ypos_pixel + row, 200, 1); + LCD_WriteRAM_Prepare(); + #endif + + j = i = 0; + + while (1) { + card.read(public_buf, 400); + for (i = 0; i < 400;) { + bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]); + i += 2; + j++; + } + + //if (i > 800) break; + //#ifdef TFT70 + //if (j>400) { + // f_read(file, buff_pic, 1, &read); + // break; + //} + //#elif defined(TFT35) + if (j >= 400) + //f_read(file, buff_pic, 1, &read); + break; + //#endif + + } + #if ENABLED(SPI_GRAPHICAL_TFT) + for (i = 0; i < 400;) { + p_index = (uint16_t *)(&bmp_public_buf[i]); + Color = (*p_index >> 8); + *p_index = Color | ((*p_index & 0xFF) << 8); + i += 2; + } + SPI_TFT_CS_L; + SPI_TFT_DC_H; + SPI.dmaSend(bmp_public_buf, 400, true); + SPI_TFT_CS_H; + #else + for (i = 0; i < 400;) { + p_index = (uint16_t *)(&bmp_public_buf[i]); + //if (*p_index == 0x0000)*p_index=gCfgItems.preview_bk_color; + LCD_IO_WriteData(*p_index); + i += 2; + } + #endif + W25QXX.init(SPI_QUARTER_SPEED); + if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096); + W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400); + row++; + if (row >= 200) { + size = 809; + row = 0; + + gcode_preview_over = 0; + //flash_preview_begin = 1; + + card.closefile(); + + /* + if (gCurFileState.file_open_flag != 0xaa) { + reset_file_info(); + res = f_open(file, curFileName, FA_OPEN_EXISTING | FA_READ); + if (res == FR_OK) { + f_lseek(file,PREVIEW_SIZE+To_pre_view); + gCurFileState.file_open_flag = 0xaa; + //bakup_file_path((uint8_t *)curFileName, strlen(curFileName)); + srcfp = file; + mksReprint.mks_printer_state = MKS_WORKING; + once_flag = 0; + } + } + */ + char *cur_name; + + cur_name = strrchr(list_file.file_name[sel_id], '/'); + + SdFile file; + SdFile *curDir; + card.endFilePrint(); + const char * const fname = card.diveToFile(true, curDir, cur_name); + if (!fname) return; + if (file.open(curDir, fname, O_READ)) { + gCfgItems.curFilesize = file.fileSize(); + file.close(); + update_spi_flash(); + } + + card.openFileRead(cur_name); + if (card.isFileOpen()) { + feedrate_percentage = 100; + // saved_feedrate_percentage = feedrate_percentage; + planner.flow_percentage[0] = 100; + planner.e_factor[0] = planner.flow_percentage[0] * 0.01; + if (EXTRUDERS == 2) { + planner.flow_percentage[1] = 100; + planner.e_factor[1] = planner.flow_percentage[1] * 0.01; + } + card.startFileprint(); + TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); + once_flag = 0; + } + return; + } + card.closefile(); + #endif // SDSUPPORT +} + +void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) { + int index; + int x_off = 0, y_off = 0; + int _y; + uint16_t *p_index; + int i, j; + uint16_t temp_p, Color; + + for (index = 0; index < 10; index++) { // 200*200 + if (sel == 1) flash_view_Read(bmp_public_buf, 8000); //20k + //memset(bmp_public_buf,0x1f,8000); + else + //memset(bmp_public_buf,0x1f,8000); + default_view_Read(bmp_public_buf, 8000); //20k + + i = 0; + #if ENABLED(SPI_GRAPHICAL_TFT) + //SPI_TFT.spi_init(SPI_FULL_SPEED); + //SPI_TFT.SetWindows(xpos_pixel, y_off * 20+ypos_pixel, 200,20); //200*200 + //SPI_TFT.LCD_WriteRAM_Prepare(); + j = 0; + for (_y = y_off * 20; _y < (y_off + 1) * 20; _y++) { + SPI_TFT.spi_init(SPI_FULL_SPEED); + SPI_TFT.SetWindows(xpos_pixel, y_off * 20 + ypos_pixel + j, 200, 1); //200*200 + SPI_TFT.LCD_WriteRAM_Prepare(); + + j++; + //memcpy(public_buf,&bmp_public_buf[i],400); + SPI_TFT_CS_L; + SPI_TFT_DC_H; + SPI.dmaSend(&bmp_public_buf[i], 400, true); + SPI_TFT_CS_H; + + i += 400; + if (i >= 8000) break; + } + #else + ili9320_SetWindows(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); //200*200 + + LCD_WriteRAM_Prepare(); + + for (_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]); + } + LCD_IO_WriteData(*p_index); + i += 2; + } + if (i >= 8000) break; + } + #endif + y_off++; + } + W25QXX.init(SPI_QUARTER_SPEED); +} + +void disp_pre_gcode(int xpos_pixel, int ypos_pixel) { + if (gcode_preview_over == 1) gcode_preview(list_file.file_name[sel_id], xpos_pixel, ypos_pixel); + if (flash_preview_begin == 1) { + flash_preview_begin = 0; + Draw_default_preview(xpos_pixel, ypos_pixel, 1); + } + if (default_preview_flg == 1) { + Draw_default_preview(xpos_pixel, ypos_pixel, 0); + default_preview_flg = 0; + } +} + +void print_time_run() { + static uint8_t lastSec = 0; + + if (print_time.seconds >= 60) { + print_time.seconds = 0; + print_time.minutes++; + if (print_time.minutes >= 60) { + print_time.minutes = 0; + print_time.hours++; + } + } + if (disp_state == PRINTING_UI) { + if (lastSec != print_time.seconds) disp_print_time(); + lastSec = print_time.seconds; + } +} + +void GUI_RefreshPage() { + if ((systick_uptime_millis % 1000) == 0) temperature_change_frequency = 1; + if ((systick_uptime_millis % 3000) == 0) printing_rate_update_flag = 1; + + switch (disp_state) { + case MAIN_UI: + lv_draw_ready_print(); + break; + case EXTRUSION_UI: + if (temperature_change_frequency == 1) { + temperature_change_frequency = 0; + disp_hotend_temp(); + } + break; + case PRE_HEAT_UI: + if (temperature_change_frequency == 1) { + temperature_change_frequency = 0; + disp_desire_temp(); + } + break; + case PRINT_READY_UI: + /* + if (gCfgItems.display_style == 2) { + if (temperature_change_frequency) { + temperature_change_frequency = 0; + disp_restro_state(); + } + } + */ + break; + + case PRINT_FILE_UI: break; + + case PRINTING_UI: + if (temperature_change_frequency) { + temperature_change_frequency = 0; + disp_ext_temp(); + disp_bed_temp(); + disp_fan_speed(); + disp_print_time(); + disp_fan_Zpos(); + } + if (printing_rate_update_flag || marlin_state == MF_SD_COMPLETE) { + printing_rate_update_flag = 0; + if (gcode_preview_over == 0) setProBarRate(); + } + break; + + case OPERATE_UI: + /* + if (temperature_change_frequency == 1) { + temperature_change_frequency = 0; + disp_temp_operate(); + } + + setProBarRateOpera(); + */ + break; + + case PAUSE_UI: + /* + if (temperature_change_frequency == 1) { + temperature_change_frequency = 0; + disp_temp_pause(); + } + */ + break; + + case FAN_UI: + if (temperature_change_frequency == 1) { + temperature_change_frequency = 0; + disp_fan_value(); + } + break; + + case MOVE_MOTOR_UI: + /* + if (mksReprint.mks_printer_state == MKS_IDLE) { + if ((z_high_count==1)&&(temper_error_flg != 1)) { + z_high_count = 0; + { + memset((char *)gCfgItems.move_z_coordinate, ' ', sizeof(gCfgItems.move_z_coordinate)); + GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS); + sprintf((char *)gCfgItems.move_z_coordinate, "Z: %.3f", current_position[Z_AXIS]); + GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS); + } + } + } + */ + break; + + case WIFI_UI: + /* + if (wifi_refresh_flg == 1) { + disp_wifi_state(); + wifi_refresh_flg = 0; + } + */ + break; + case BIND_UI: + /*refresh_bind_ui();*/ + break; + + case FILAMENTCHANGE_UI: + /* + if (temperature_change_frequency) { + temperature_change_frequency = 0; + disp_filament_sprayer_temp(); + } + */ + break; + case DIALOG_UI: + /*filament_dialog_handle(); + wifi_scan_handle();*/ + break; + case MESHLEVELING_UI: + /*disp_zpos();*/ + break; + case HARDWARE_TEST_UI: + break; + case WIFI_LIST_UI: + /* + if (wifi_refresh_flg == 1) { + disp_wifi_list(); + wifi_refresh_flg = 0; + } + */ + break; + case KEY_BOARD_UI: + /*update_password_disp(); + update_join_state_disp();*/ + break; + case TIPS_UI: + /* + switch (tips_type) { + case TIPS_TYPE_JOINING: + if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex]) == 0) { + tips_disp.timer = TIPS_TIMER_STOP; + tips_disp.timer_count = 0; + Clear_Tips(); + tips_type = TIPS_TYPE_WIFI_CONECTED; + draw_Tips(); + } + if (tips_disp.timer_count >= 30) { + tips_disp.timer = TIPS_TIMER_STOP; + tips_disp.timer_count = 0; + Clear_Tips(); + tips_type = TIPS_TYPE_TAILED_JOIN; + draw_Tips(); + } + break; + case TIPS_TYPE_TAILED_JOIN: + if (tips_disp.timer_count >= 3) { + tips_disp.timer = TIPS_TIMER_STOP; + tips_disp.timer_count = 0; + last_disp_state = TIPS_UI; + Clear_Tips(); + draw_Wifi_list(); + } + break; + case TIPS_TYPE_WIFI_CONECTED: + if (tips_disp.timer_count >= 3) { + tips_disp.timer = TIPS_TIMER_STOP; + tips_disp.timer_count = 0; + + last_disp_state = TIPS_UI; + Clear_Tips(); + draw_Wifi(); + } + break; + default: break; + } + */ + break; + case BABY_STEP_UI: + /* + if (temperature_change_frequency == 1) { + temperature_change_frequency = 0; + disp_z_offset_value(); + } + */ + break; + default: break; + } + + print_time_run(); +} + +void clear_cur_ui() { + last_disp_state = disp_state_stack._disp_state[disp_state_stack._disp_index]; + + switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) { + case PRINT_READY_UI: + //Get_Temperature_Flg = 0; + lv_clear_ready_print(); + break; + case PRINT_FILE_UI: + lv_clear_print_file(); + break; + case PRINTING_UI: + lv_clear_printing(); + break; + case MOVE_MOTOR_UI: + lv_clear_move_motor(); + break; + case OPERATE_UI: + lv_clear_opration(); + break; + case PAUSE_UI: + //Clear_pause(); + break; + case EXTRUSION_UI: + lv_clear_extrusion(); + break; + case PRE_HEAT_UI: + lv_clear_preHeat(); + break; + case CHANGE_SPEED_UI: + lv_clear_change_speed(); + break; + case FAN_UI: + lv_clear_fan(); + break; + case SET_UI: + lv_clear_set(); + break; + case ZERO_UI: + lv_clear_home(); + break; + case SPRAYER_UI: + //Clear_Sprayer(); + break; + case MACHINE_UI: + //Clear_Machine(); + break; + case LANGUAGE_UI: + lv_clear_language(); + break; + case ABOUT_UI: + lv_clear_about(); + break; + case LOG_UI: + //Clear_Connect(); + break; + case DISK_UI: + //Clear_Disk(); + break; + case WIFI_UI: + //Clear_Wifi(); + break; + case MORE_UI: + //Clear_more(); + break; + case FILETRANSFER_UI: + //Clear_fileTransfer(); + break; + case DIALOG_UI: + lv_clear_dialog(); + break; + case FILETRANSFERSTATE_UI: + //Clear_WifiFileTransferdialog(); + break; + case PRINT_MORE_UI: + //Clear_Printmore(); + break; + case LEVELING_UI: + lv_clear_manualLevel(); + break; + case BIND_UI: + //Clear_Bind(); + break; + case ZOFFSET_UI: + //Clear_Zoffset(); + break; + case TOOL_UI: + lv_clear_tool(); + break; + case MESHLEVELING_UI: + //Clear_MeshLeveling(); + break; + case HARDWARE_TEST_UI: + //Clear_Hardwaretest(); + break; + case WIFI_LIST_UI: + //Clear_Wifi_list(); + break; + case KEY_BOARD_UI: + //Clear_Keyboard(); + break; + case TIPS_UI: + //Clear_Tips(); + break; + case MACHINE_PARA_UI: + //Clear_MachinePara(); + break; + case MACHINE_SETTINGS_UI: + //Clear_MachineSettings(); + break; + case TEMPERATURE_SETTINGS_UI: + //Clear_TemperatureSettings(); + break; + case MOTOR_SETTINGS_UI: + //Clear_MotorSettings(); + break; + case MACHINETYPE_UI: + //Clear_MachineType(); + break; + case STROKE_UI: + //Clear_Stroke(); + break; + case HOME_DIR_UI: + //Clear_HomeDir(); + break; + case ENDSTOP_TYPE_UI: + //Clear_EndstopType(); + break; + case FILAMENT_SETTINGS_UI: + //Clear_FilamentSettings(); + break; + case LEVELING_SETTIGNS_UI: + //Clear_LevelingSettings(); + break; + case LEVELING_PARA_UI: + //Clear_LevelingPara(); + break; + case DELTA_LEVELING_PARA_UI: + //Clear_DeltaLevelPara(); + break; + case XYZ_LEVELING_PARA_UI: + //Clear_XYZLevelPara(); + break; + case MAXFEEDRATE_UI: + //Clear_MaxFeedRate(); + break; + case STEPS_UI: + //Clear_Steps(); + break; + case ACCELERATION_UI: + //Clear_Acceleration(); + break; + case JERK_UI: + //Clear_Jerk(); + break; + case MOTORDIR_UI: + //Clear_MotorDir(); + break; + case HOMESPEED_UI: + //Clear_HomeSpeed(); + break; + case NOZZLE_CONFIG_UI: + //Clear_NozzleConfig(); + break; + case HOTBED_CONFIG_UI: + //Clear_HotbedConfig(); + break; + case ADVANCED_UI: + //Clear_Advanced(); + break; + case DOUBLE_Z_UI: + //Clear_DoubleZ(); + break; + case ENABLE_INVERT_UI: + //Clear_EnableInvert(); + break; + case NUMBER_KEY_UI: + //Clear_NumberKey(); + break; + case BABY_STEP_UI: + //Clear_babyStep(); + break; + default: + break; + } + //GUI_Clear(); +} + +void draw_return_ui() { + if (disp_state_stack._disp_index > 0) { + disp_state_stack._disp_index--; + + switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) { + case PRINT_READY_UI: + lv_draw_ready_print(); + break; + case PRINT_FILE_UI: + lv_draw_print_file(); + break; + case PRINTING_UI: + if (gCfgItems.from_flash_pic == 1) flash_preview_begin = 1; + else default_preview_flg = 1; + lv_draw_printing(); + break; + case MOVE_MOTOR_UI: + lv_draw_move_motor(); + break; + case OPERATE_UI: + lv_draw_opration(); + break; + + #if 1 + case PAUSE_UI: + //draw_pause(); + break; + #endif + + case EXTRUSION_UI: + lv_draw_extrusion(); + break; + case PRE_HEAT_UI: + lv_draw_preHeat(); + break; + case CHANGE_SPEED_UI: + lv_draw_change_speed(); + break; + case FAN_UI: + lv_draw_fan(); + break; + case SET_UI: + lv_draw_set(); + break; + case ZERO_UI: + lv_draw_home(); + break; + case SPRAYER_UI: + //draw_Sprayer(); + break; + case MACHINE_UI: + //draw_Machine(); + break; + case LANGUAGE_UI: + lv_draw_language(); + break; + case ABOUT_UI: + lv_draw_about(); + break; + + #if tan_mask + case LOG_UI: + //draw_Connect(); + break; + #endif + + case CALIBRATE_UI: + //draw_calibrate(); + break; + case DISK_UI: + //draw_Disk(); + break; + case WIFI_UI: + //draw_Wifi(); + break; + case MORE_UI: + //draw_More(); + break; + case PRINT_MORE_UI: + //draw_printmore(); + break; + case FILAMENTCHANGE_UI: + //draw_FilamentChange(); + break; + case LEVELING_UI: + lv_draw_manualLevel(); + break; + case BIND_UI: + //draw_bind(); + break; + + #if tan_mask + case ZOFFSET_UI: + //draw_Zoffset(); + break; + #endif + + case TOOL_UI: + lv_draw_tool(); + break; + case MESHLEVELING_UI: + //draw_meshleveling(); + break; + case HARDWARE_TEST_UI: + //draw_Hardwaretest(); + break; + case WIFI_LIST_UI: + //draw_Wifi_list(); + break; + case KEY_BOARD_UI: + //draw_Keyboard(); + break; + case TIPS_UI: + //draw_Tips(); + break; + case MACHINE_PARA_UI: + //draw_MachinePara(); + break; + case MACHINE_SETTINGS_UI: + //draw_MachineSettings(); + break; + case TEMPERATURE_SETTINGS_UI: + //draw_TemperatureSettings(); + break; + case MOTOR_SETTINGS_UI: + //draw_MotorSettings(); + break; + case MACHINETYPE_UI: + //draw_MachineType(); + break; + case STROKE_UI: + //draw_Stroke(); + break; + case HOME_DIR_UI: + //draw_HomeDir(); + break; + case ENDSTOP_TYPE_UI: + //draw_EndstopType(); + break; + case FILAMENT_SETTINGS_UI: + //draw_FilamentSettings(); + break; + case LEVELING_SETTIGNS_UI: + //draw_LevelingSettings(); + break; + case LEVELING_PARA_UI: + //draw_LevelingPara(); + break; + case DELTA_LEVELING_PARA_UI: + //draw_DeltaLevelPara(); + break; + case XYZ_LEVELING_PARA_UI: + //draw_XYZLevelPara(); + break; + case MAXFEEDRATE_UI: + //draw_MaxFeedRate(); + break; + case STEPS_UI: + //draw_Steps(); + break; + case ACCELERATION_UI: + //draw_Acceleration(); + break; + case JERK_UI: + //draw_Jerk(); + break; + case MOTORDIR_UI: + //draw_MotorDir(); + break; + case HOMESPEED_UI: + //draw_HomeSpeed(); + break; + case NOZZLE_CONFIG_UI: + //draw_NozzleConfig(); + break; + case HOTBED_CONFIG_UI: + //draw_HotbedConfig(); + break; + case ADVANCED_UI: + //draw_Advanced(); + break; + case DOUBLE_Z_UI: + //draw_DoubleZ(); + break; + case ENABLE_INVERT_UI: + //draw_EnableInvert(); + break; + case NUMBER_KEY_UI: + //draw_NumberKey(); + break; + case DIALOG_UI: + //draw_dialog(DialogType); + break; + case BABY_STEP_UI: + //draw_babyStep(); + break; + default: break; + } + } +} + +#if ENABLED(SDSUPPORT) + + void sd_detection() { + static bool last_sd_status; + const bool sd_status = IS_SD_INSERTED(); + if (sd_status != last_sd_status) { + last_sd_status = sd_status; + if (sd_status) card.mount(); else card.release(); + } + } + +#endif + +extern volatile uint32_t systick_uptime_millis; + +void print_time_count() { + if ((systick_uptime_millis % 1000) == 0) + if (print_time.start == 1) print_time.seconds++; +} + +void LV_TASK_HANDLER() { + //lv_tick_inc(1); + lv_task_handler(); + TERN_(MKS_TEST, mks_test()); + disp_pre_gcode(2, 36); + GUI_RefreshPage(); + //sd_detection(); +} + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h new file mode 100644 index 0000000..54720a3 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -0,0 +1,229 @@ +/** + * 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 + +#include +#include +#include "lvgl.h" +#include "inc/tft_multi_language.h" +#include "inc/draw_ready_print.h" +#include "inc/draw_language.h" +#include "inc/draw_set.h" +#include "inc/draw_tool.h" +#include "inc/draw_print_file.h" +#include "inc/draw_dialog.h" +#include "inc/draw_printing.h" +#include "inc/draw_opration.h" +#include "inc/draw_preHeat.h" +#include "inc/draw_extrusion.h" +#include "inc/draw_home.h" +#include "inc/draw_move_motor.h" +#include "inc/draw_fan.h" +#include "inc/draw_about.h" +#include "inc/draw_change_speed.h" +#include "inc/draw_manuaLevel.h" +#include "inc/draw_error_message.h" +#include "inc/printer_opration.h" + +#define TFT35 + +#ifdef TFT35 + + #define TFT_WIDTH 480 + #define TFT_HEIGHT 320 + + #define titleHeight 36 // TFT_screen.title_high + #define INTERVAL_H 2 // TFT_screen.gap_h // 2 + #define INTERVAL_V 2 // TFT_screen.gap_v // 2 + #define BTN_X_PIXEL 117 // TFT_screen.btn_x_pixel + #define BTN_Y_PIXEL 140 // TFT_screen.btn_y_pixel + + #define SIMPLE_FIRST_PAGE_GRAP 30 + + #define BUTTON_TEXT_Y_OFFSET -20 + + #define TITLE_XPOS 3 //TFT_screen.title_xpos + #define TITLE_YPOS 5 //TFT_screen.title_ypos + + #define FILE_BTN_CNT 6 + + #define OTHER_BTN_XPIEL 117 + #define OTHER_BTN_YPIEL 92 + + #define FILE_PRE_PIC_X_OFFSET 8 + #define FILE_PRE_PIC_Y_OFFSET 0 + + #define PREVIEW_LITTLE_PIC_SIZE 40910//400*100+9*101+1 + #define PREVIEW_SIZE 202720//(PREVIEW_LITTLE_PIC_SIZE+800*200+201*9+1) + + #define GCFG_FLAG_VALUE 0xEE + +#else + + #define TFT_WIDTH 320 + #define TFT_HEIGHT 240 + +#endif + +extern char public_buf_m[100]; +extern char public_buf_l[30]; + +typedef struct { + uint8_t spi_flash_flag; + uint8_t multiple_language; + uint8_t language; + uint8_t leveling_mode; + uint8_t from_flash_pic; + uint8_t finish_power_off; + uint8_t pause_reprint; + uint32_t curFilesize; +} CFG_ITMES; + +typedef struct { + uint8_t curTempType : 1, + curSprayerChoose : 3, + stepHeat : 4; + uint8_t leveling_first_time : 1; + uint8_t extruStep; + uint8_t extruSpeed; + uint8_t print_state; + uint8_t stepPrintSpeed; + uint8_t waitEndMoves; + uint16_t moveSpeed; + float move_dist; +} UI_CFG; + +typedef enum { + MAIN_UI, + PRINT_READY_UI, + PRINT_FILE_UI, + PRINTING_UI, + MOVE_MOTOR_UI, + OPERATE_UI, + PAUSE_UI, + EXTRUSION_UI, + FAN_UI, + PRE_HEAT_UI, + CHANGE_SPEED_UI, + TEMP_UI, + SET_UI, + ZERO_UI, + SPRAYER_UI, + MACHINE_UI, + LANGUAGE_UI, + ABOUT_UI, + LOG_UI, + DISK_UI, + CALIBRATE_UI, + DIALOG_UI, + WIFI_UI, + MORE_UI, + FILETRANSFER_UI, + FILETRANSFERSTATE_UI, + PRINT_MORE_UI, + FILAMENTCHANGE_UI, + LEVELING_UI, + MESHLEVELING_UI, + BIND_UI, + ZOFFSET_UI, + TOOL_UI, + HARDWARE_TEST_UI, + WIFI_LIST_UI, + KEY_BOARD_UI, + TIPS_UI, + MACHINE_PARA_UI, + MACHINE_SETTINGS_UI, + TEMPERATURE_SETTINGS_UI, + MOTOR_SETTINGS_UI, + MACHINETYPE_UI, + STROKE_UI, + HOME_DIR_UI, + ENDSTOP_TYPE_UI, + FILAMENT_SETTINGS_UI, + LEVELING_SETTIGNS_UI, + LEVELING_PARA_UI, + DELTA_LEVELING_PARA_UI, + XYZ_LEVELING_PARA_UI, + MAXFEEDRATE_UI, + STEPS_UI, + ACCELERATION_UI, + JERK_UI, + MOTORDIR_UI, + HOMESPEED_UI, + NOZZLE_CONFIG_UI, + HOTBED_CONFIG_UI, + ADVANCED_UI, + DOUBLE_Z_UI, + ENABLE_INVERT_UI, + NUMBER_KEY_UI, + BABY_STEP_UI, + ERROR_MESSAGE_UI +} DISP_STATE; + +typedef struct { + DISP_STATE _disp_state[100]; + int _disp_index; +} DISP_STATE_STACK; + +typedef struct { + int16_t days; + uint16_t hours; + uint8_t minutes; + volatile int8_t seconds; + int8_t ms_10; + int8_t start; +} PRINT_TIME; +extern PRINT_TIME print_time; + +extern CFG_ITMES gCfgItems; +extern UI_CFG uiCfg; +extern DISP_STATE disp_state; +extern DISP_STATE last_disp_state; +extern DISP_STATE_STACK disp_state_stack; + +extern lv_style_t tft_style_scr; +extern lv_style_t tft_style_lable_pre; +extern lv_style_t tft_style_lable_rel; + +extern void gCfgItems_init(); +extern void ui_cfg_init(); +extern void tft_style_init(); +extern char *creat_title_text(void); +extern void preview_gcode_prehandle(char *path); +extern void update_spi_flash(); +extern void disp_pre_gcode(int xpos_pixel, int ypos_pixel); +extern void GUI_RefreshPage(); +extern void clear_cur_ui(); +extern void draw_return_ui(); +extern void sd_detection(); +extern void gCfg_to_spiFlah(); +extern void print_time_count(); + +extern void LV_TASK_HANDLER(); + +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/gb2312_puhui16.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/gb2312_puhui16.cpp new file mode 100644 index 0000000..39fb836 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/gb2312_puhui16.cpp @@ -0,0 +1,111 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "../../../../MarlinCore.h" +#include "lvgl.h" +#include "pic_manager.h" + +typedef struct { + uint16_t min; + uint16_t max; + uint8_t bpp; + uint8_t reserved[3]; +} x_header_t; + +typedef struct { + uint32_t pos; +} x_table_t; + +typedef struct { + uint8_t adv_w; + uint8_t box_w; +} glyph_dsc_t; + +static x_header_t __g_xbf_hd = { .min = 0, .max = 0, .bpp = 0 }; +static uint8_t __g_font_buf[75]; + +static uint8_t *__user_font_getdata(int offset, int size) { + //memset(__g_font_buf,0,sizeof(__g_font_buf)); + get_spi_flash_data((char *)__g_font_buf, offset, size); + return __g_font_buf; + //return &buf_test[offset]; +} + +static const uint8_t * __user_font_get_bitmap(const lv_font_t * font, uint32_t unicode_letter) { + if (__g_xbf_hd.max == 0) { + uint8_t *p = __user_font_getdata(0, sizeof(x_header_t)); + memcpy(&__g_xbf_hd, p, sizeof(x_header_t)); + } + if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min) + return NULL; + uint32_t unicode_offset = sizeof(x_header_t) + (unicode_letter - __g_xbf_hd.min) * 4; + uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4); + if (p_pos[0] != 0) { + uint32_t pos = p_pos[0]; + //glyph_dsc_t * gdsc = (glyph_dsc_t*)__user_font_getdata(pos, 2); + __user_font_getdata(pos, 2); + //return __user_font_getdata(pos+2, gdsc->box_w*__g_xbf_hd.bpp/8); + return __user_font_getdata(pos + 2, sizeof(__g_font_buf)); + } + return NULL; +} + +static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + if (__g_xbf_hd.max == 0) { + uint8_t *p = __user_font_getdata(0, sizeof(x_header_t)); + memcpy(&__g_xbf_hd, p, sizeof(x_header_t)); + } + if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min) + return NULL; + uint32_t unicode_offset = sizeof(x_header_t) + (unicode_letter - __g_xbf_hd.min) * 4; + uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4); + if (p_pos[0] != 0) { + glyph_dsc_t * gdsc = (glyph_dsc_t*)__user_font_getdata(p_pos[0], 2); + dsc_out->adv_w = gdsc->adv_w; + dsc_out->box_h = font->line_height; + dsc_out->box_w = gdsc->box_w; + dsc_out->ofs_x = 0; + dsc_out->ofs_y = 0; + dsc_out->bpp = __g_xbf_hd.bpp; + return true; + } + return false; +} + +/*lv_font_t gb2312_puhui32 = { +.get_glyph_bitmap = __user_font_get_bitmap, +.get_glyph_dsc = __user_font_get_glyph_dsc, +.line_height = 25, +.base_line = 0, +};*/ +lv_font_t gb2312_puhui32; +void init_gb2312_font() { + gb2312_puhui32.get_glyph_bitmap = __user_font_get_bitmap; + gb2312_puhui32.get_glyph_dsc = __user_font_get_glyph_dsc; + gb2312_puhui32.line_height = 25; + gb2312_puhui32.base_line = 0; +} + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp new file mode 100644 index 0000000..08ce13c --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp @@ -0,0 +1,594 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "tft_lvgl_configuration.h" +#include "lvgl.h" +#include "draw_ready_print.h" +#include "W25Qxx.h" +#include "pic_manager.h" +#include "mks_hardware_test.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" +#include "../../../../feature/touch/xpt2046.h" + +#if ENABLED(MKS_TEST) + + extern uint8_t curent_disp_ui; + + uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det2_sta, mt_det3_sta; + uint8_t endstopx1_sta, endstopx2_sta, endstopy1_sta, endstopy2_sta, endstopz1_sta, endstopz2_sta; + void test_gpio_readlevel_L() { + volatile uint32_t itest; + WRITE(WIFI_IO2_PIN, HIGH); + itest = 10000; + while (itest--); + pw_det_sta = (READ(POWER_LOSS_PIN) == 0); + pw_off_sta = (READ(PS_ON_PIN) == 0); + mt_det_sta = (READ(FIL_RUNOUT_PIN) == 0); + mt_det2_sta = (READ(FIL_RUNOUT_2_PIN) == 0); + mt_det3_sta = (READ(FIL_RUNOUT_3_PIN) == 0); + endstopx1_sta = (READ(X_MIN_PIN) == 0); + endstopx2_sta = (READ(X_MAX_PIN) == 0); + endstopy1_sta = (READ(Y_MIN_PIN) == 0); + endstopy2_sta = (READ(Y_MAX_PIN) == 0); + endstopz1_sta = (READ(Z_MIN_PIN) == 0); + endstopz2_sta = (READ(Z_MAX_PIN) == 0); + } + + void test_gpio_readlevel_H() { + volatile uint32_t itest; + WRITE(WIFI_IO2_PIN, LOW); + itest = 10000; + while (itest--); + pw_det_sta = (READ(POWER_LOSS_PIN) == 1); + pw_off_sta = (READ(PS_ON_PIN) == 1); + mt_det_sta = (READ(FIL_RUNOUT_PIN) == 1); + mt_det2_sta = (READ(FIL_RUNOUT_2_PIN) == 1); + mt_det3_sta = (READ(FIL_RUNOUT_3_PIN) == 1); + endstopx1_sta = (READ(X_MIN_PIN) == 1); + endstopx2_sta = (READ(X_MAX_PIN) == 1); + endstopy1_sta = (READ(Y_MIN_PIN) == 1); + endstopy2_sta = (READ(Y_MAX_PIN) == 1); + endstopz1_sta = (READ(Z_MIN_PIN) == 1); + endstopz2_sta = (READ(Z_MAX_PIN) == 1); + } + + void init_Tst_GPIO() { + SET_INPUT_PULLUP(X_MIN_PIN); + SET_INPUT_PULLUP(X_MAX_PIN); + SET_INPUT_PULLUP(Y_MIN_PIN); + SET_INPUT_PULLUP(Y_MAX_PIN); + SET_INPUT_PULLUP(Z_MIN_PIN); + SET_INPUT_PULLUP(Z_MAX_PIN); + + SET_OUTPUT(WIFI_IO2_PIN); + + SET_INPUT_PULLUP(FIL_RUNOUT_PIN); + SET_INPUT_PULLUP(FIL_RUNOUT_2_PIN); + SET_INPUT_PULLUP(FIL_RUNOUT_3_PIN); + + SET_INPUT_PULLUP(POWER_LOSS_PIN); + SET_INPUT_PULLUP(PS_ON_PIN); + + SET_INPUT_PULLUP(SERVO0_PIN); + + SET_OUTPUT(E0_ENABLE_PIN); + SET_OUTPUT(X_ENABLE_PIN); + + WRITE(X_ENABLE_PIN, LOW); + WRITE(Y_ENABLE_PIN, LOW); + WRITE(Z_ENABLE_PIN, LOW); + WRITE(E0_ENABLE_PIN, LOW); + WRITE(E1_ENABLE_PIN, LOW); + WRITE(E2_ENABLE_PIN, LOW); + } + + void mks_test_beeper() { + WRITE(BEEPER_PIN, HIGH); + delay(100); + WRITE(BEEPER_PIN, LOW); + delay(100); + } + + void Test_GPIO() { + init_Tst_GPIO(); + + test_gpio_readlevel_L(); + test_gpio_readlevel_H(); + test_gpio_readlevel_L(); + if ((pw_det_sta == 1) && (mt_det_sta == 1) && (mt_det2_sta == 1) && (mt_det3_sta == 1)) { + if (curent_disp_ui == 1) disp_det_ok(); + } + else if (curent_disp_ui == 1) disp_det_error(); + if ((endstopx1_sta == 1) + && (endstopx2_sta == 1) + && (endstopy1_sta == 1) + && (endstopy2_sta == 1) + && (endstopz1_sta == 1) + && (endstopz2_sta == 1) + ) { + if (curent_disp_ui == 1) disp_Limit_ok(); + } + else if (curent_disp_ui == 1) + disp_Limit_error(); + //mks_test_beeper(); + + } + + void mks_test() { + if (millis() % 2000 < 1000) { + WRITE(X_DIR_PIN, LOW); + WRITE(Y_DIR_PIN, LOW); + WRITE(Z_DIR_PIN, LOW); + WRITE(E0_DIR_PIN, LOW); + WRITE(E1_DIR_PIN, LOW); + WRITE(E2_DIR_PIN, LOW); + thermalManager.fan_speed[0] = 255; + WRITE(HEATER_2_PIN, HIGH); // HE2 + WRITE(HEATER_1_PIN, HIGH); // HE1 + WRITE(HEATER_0_PIN, HIGH); // HE0 + WRITE(HEATER_BED_PIN, HIGH); // HOT-BED + } + else { + WRITE(X_DIR_PIN, HIGH); + WRITE(Y_DIR_PIN, HIGH); + WRITE(Z_DIR_PIN, HIGH); + WRITE(E0_DIR_PIN, HIGH); + WRITE(E1_DIR_PIN, HIGH); + WRITE(E2_DIR_PIN, HIGH); + thermalManager.fan_speed[0] = 0; + WRITE(HEATER_2_PIN, LOW); // HE2 + WRITE(HEATER_1_PIN, LOW); // HE1 + WRITE(HEATER_0_PIN, LOW); // HE0 + WRITE(HEATER_BED_PIN, LOW); // HOT-BED + } + if ((endstopx1_sta == 1) && (endstopx2_sta == 1) + && (endstopy1_sta == 1) && (endstopy2_sta == 1) + && (endstopz1_sta == 1) && (endstopz2_sta == 1) + ) { + + } + else { + mks_test_beeper(); + } + + if (curent_disp_ui == 1) + disp_test(); + } + +#endif // MKS_TEST + +static const uint16_t ASCII_Table_16x24[] PROGMEM = { + // Space ' ' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '!' + 0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0000, 0x0000, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '"' + 0x0000, 0x0000, 0x00CC, 0x00CC, 0x00CC, 0x00CC, 0x00CC, 0x00CC, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '#' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C60, 0x0C60, + 0x0C60, 0x0630, 0x0630, 0x1FFE, 0x1FFE, 0x0630, 0x0738, 0x0318, + 0x1FFE, 0x1FFE, 0x0318, 0x0318, 0x018C, 0x018C, 0x018C, 0x0000, + // '$' + 0x0000, 0x0080, 0x03E0, 0x0FF8, 0x0E9C, 0x1C8C, 0x188C, 0x008C, + 0x0098, 0x01F8, 0x07E0, 0x0E80, 0x1C80, 0x188C, 0x188C, 0x189C, + 0x0CB8, 0x0FF0, 0x03E0, 0x0080, 0x0080, 0x0000, 0x0000, 0x0000, + // '%' + 0x0000, 0x0000, 0x0000, 0x180E, 0x0C1B, 0x0C11, 0x0611, 0x0611, + 0x0311, 0x0311, 0x019B, 0x018E, 0x38C0, 0x6CC0, 0x4460, 0x4460, + 0x4430, 0x4430, 0x4418, 0x6C18, 0x380C, 0x0000, 0x0000, 0x0000, + // '&' + 0x0000, 0x01E0, 0x03F0, 0x0738, 0x0618, 0x0618, 0x0330, 0x01F0, + 0x00F0, 0x00F8, 0x319C, 0x330E, 0x1E06, 0x1C06, 0x1C06, 0x3F06, + 0x73FC, 0x21F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // "'" + 0x0000, 0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '(' + 0x0000, 0x0200, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x0060, 0x0060, + 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, + 0x0060, 0x0060, 0x00C0, 0x00C0, 0x0180, 0x0300, 0x0200, 0x0000, + // ')' + 0x0000, 0x0020, 0x0060, 0x00C0, 0x0180, 0x0180, 0x0300, 0x0300, + 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, + 0x0300, 0x0300, 0x0180, 0x0180, 0x00C0, 0x0060, 0x0020, 0x0000, + // '*' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0, + 0x06D8, 0x07F8, 0x01E0, 0x0330, 0x0738, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '+' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x3FFC, 0x3FFC, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // ',' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0180, 0x0180, 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, + // '-' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x07E0, 0x07E0, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '.' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '/' + 0x0000, 0x0C00, 0x0C00, 0x0600, 0x0600, 0x0600, 0x0300, 0x0300, + 0x0300, 0x0380, 0x0180, 0x0180, 0x0180, 0x00C0, 0x00C0, 0x00C0, + 0x0060, 0x0060, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '0' + 0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C18, 0x180C, 0x180C, 0x180C, + 0x180C, 0x180C, 0x180C, 0x180C, 0x180C, 0x180C, 0x0C18, 0x0E38, + 0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '1' + 0x0000, 0x0100, 0x0180, 0x01C0, 0x01F0, 0x0198, 0x0188, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '2' + 0x0000, 0x03E0, 0x0FF8, 0x0C18, 0x180C, 0x180C, 0x1800, 0x1800, + 0x0C00, 0x0600, 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018, + 0x1FFC, 0x1FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '3' + 0x0000, 0x01E0, 0x07F8, 0x0E18, 0x0C0C, 0x0C0C, 0x0C00, 0x0600, + 0x03C0, 0x07C0, 0x0C00, 0x1800, 0x1800, 0x180C, 0x180C, 0x0C18, + 0x07F8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '4' + 0x0000, 0x0C00, 0x0E00, 0x0F00, 0x0F00, 0x0D80, 0x0CC0, 0x0C60, + 0x0C60, 0x0C30, 0x0C18, 0x0C0C, 0x3FFC, 0x3FFC, 0x0C00, 0x0C00, + 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '5' + 0x0000, 0x0FF8, 0x0FF8, 0x0018, 0x0018, 0x000C, 0x03EC, 0x07FC, + 0x0E1C, 0x1C00, 0x1800, 0x1800, 0x1800, 0x180C, 0x0C1C, 0x0E18, + 0x07F8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '6' + 0x0000, 0x07C0, 0x0FF0, 0x1C38, 0x1818, 0x0018, 0x000C, 0x03CC, + 0x0FEC, 0x0E3C, 0x1C1C, 0x180C, 0x180C, 0x180C, 0x1C18, 0x0E38, + 0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '7' + 0x0000, 0x1FFC, 0x1FFC, 0x0C00, 0x0600, 0x0600, 0x0300, 0x0380, + 0x0180, 0x01C0, 0x00C0, 0x00E0, 0x0060, 0x0060, 0x0070, 0x0030, + 0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '8' + 0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C18, 0x0C18, 0x0C18, 0x0638, + 0x07F0, 0x07F0, 0x0C18, 0x180C, 0x180C, 0x180C, 0x180C, 0x0C38, + 0x0FF8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '9' + 0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C1C, 0x180C, 0x180C, 0x180C, + 0x1C1C, 0x1E38, 0x1BF8, 0x19E0, 0x1800, 0x0C00, 0x0C00, 0x0E1C, + 0x07F8, 0x01F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // ':' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // ';' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0180, 0x0180, 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, 0x0000, + // '<' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x1000, 0x1C00, 0x0F80, 0x03E0, 0x00F8, 0x0018, 0x00F8, 0x03E0, + 0x0F80, 0x1C00, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '=' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x1FF8, 0x0000, 0x0000, 0x0000, 0x1FF8, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '>' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0008, 0x0038, 0x01F0, 0x07C0, 0x1F00, 0x1800, 0x1F00, 0x07C0, + 0x01F0, 0x0038, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '?' + 0x0000, 0x03E0, 0x0FF8, 0x0C18, 0x180C, 0x180C, 0x1800, 0x0C00, + 0x0600, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x00C0, 0x0000, 0x0000, + 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '@' + 0x0000, 0x0000, 0x07E0, 0x1818, 0x2004, 0x29C2, 0x4A22, 0x4411, + 0x4409, 0x4409, 0x4409, 0x2209, 0x1311, 0x0CE2, 0x4002, 0x2004, + 0x1818, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'A' + 0x0000, 0x0380, 0x0380, 0x06C0, 0x06C0, 0x06C0, 0x0C60, 0x0C60, + 0x1830, 0x1830, 0x1830, 0x3FF8, 0x3FF8, 0x701C, 0x600C, 0x600C, + 0xC006, 0xC006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'B' + 0x0000, 0x03FC, 0x0FFC, 0x0C0C, 0x180C, 0x180C, 0x180C, 0x0C0C, + 0x07FC, 0x0FFC, 0x180C, 0x300C, 0x300C, 0x300C, 0x300C, 0x180C, + 0x1FFC, 0x07FC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'C' + 0x0000, 0x07C0, 0x1FF0, 0x3838, 0x301C, 0x700C, 0x6006, 0x0006, + 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x6006, 0x700C, 0x301C, + 0x1FF0, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'D' + 0x0000, 0x03FE, 0x0FFE, 0x0E06, 0x1806, 0x1806, 0x3006, 0x3006, + 0x3006, 0x3006, 0x3006, 0x3006, 0x3006, 0x1806, 0x1806, 0x0E06, + 0x0FFE, 0x03FE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'E' + 0x0000, 0x3FFC, 0x3FFC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, + 0x1FFC, 0x1FFC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, + 0x3FFC, 0x3FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'F' + 0x0000, 0x3FF8, 0x3FF8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x1FF8, 0x1FF8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x0018, 0x0018, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'G' + 0x0000, 0x0FE0, 0x3FF8, 0x783C, 0x600E, 0xE006, 0xC007, 0x0003, + 0x0003, 0xFE03, 0xFE03, 0xC003, 0xC007, 0xC006, 0xC00E, 0xF03C, + 0x3FF8, 0x0FE0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'H' + 0x0000, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, + 0x3FFC, 0x3FFC, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, + 0x300C, 0x300C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'I' + 0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'J' + 0x0000, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, + 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0618, 0x0618, 0x0738, + 0x03F0, 0x01E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'K' + 0x0000, 0x3006, 0x1806, 0x0C06, 0x0606, 0x0306, 0x0186, 0x00C6, + 0x0066, 0x0076, 0x00DE, 0x018E, 0x0306, 0x0606, 0x0C06, 0x1806, + 0x3006, 0x6006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'L' + 0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x1FF8, 0x1FF8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'M' + 0x0000, 0xE00E, 0xF01E, 0xF01E, 0xF01E, 0xD836, 0xD836, 0xD836, + 0xD836, 0xCC66, 0xCC66, 0xCC66, 0xC6C6, 0xC6C6, 0xC6C6, 0xC6C6, + 0xC386, 0xC386, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'N' + 0x0000, 0x300C, 0x301C, 0x303C, 0x303C, 0x306C, 0x306C, 0x30CC, + 0x30CC, 0x318C, 0x330C, 0x330C, 0x360C, 0x360C, 0x3C0C, 0x3C0C, + 0x380C, 0x300C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'O' + 0x0000, 0x07E0, 0x1FF8, 0x381C, 0x700E, 0x6006, 0xC003, 0xC003, + 0xC003, 0xC003, 0xC003, 0xC003, 0xC003, 0x6006, 0x700E, 0x381C, + 0x1FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'P' + 0x0000, 0x0FFC, 0x1FFC, 0x380C, 0x300C, 0x300C, 0x300C, 0x300C, + 0x180C, 0x1FFC, 0x07FC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, + 0x000C, 0x000C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'Q' + 0x0000, 0x07E0, 0x1FF8, 0x381C, 0x700E, 0x6006, 0xE003, 0xC003, + 0xC003, 0xC003, 0xC003, 0xC003, 0xE007, 0x6306, 0x3F0E, 0x3C1C, + 0x3FF8, 0xF7E0, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'R' + 0x0000, 0x0FFE, 0x1FFE, 0x3806, 0x3006, 0x3006, 0x3006, 0x3806, + 0x1FFE, 0x07FE, 0x0306, 0x0606, 0x0C06, 0x1806, 0x1806, 0x3006, + 0x3006, 0x6006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'S' + 0x0000, 0x03E0, 0x0FF8, 0x0C1C, 0x180C, 0x180C, 0x000C, 0x001C, + 0x03F8, 0x0FE0, 0x1E00, 0x3800, 0x3006, 0x3006, 0x300E, 0x1C1C, + 0x0FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'T' + 0x0000, 0x7FFE, 0x7FFE, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'U' + 0x0000, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, + 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x1818, + 0x1FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'V' + 0x0000, 0x6003, 0x3006, 0x3006, 0x3006, 0x180C, 0x180C, 0x180C, + 0x0C18, 0x0C18, 0x0E38, 0x0630, 0x0630, 0x0770, 0x0360, 0x0360, + 0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'W' + 0x0000, 0x6003, 0x61C3, 0x61C3, 0x61C3, 0x3366, 0x3366, 0x3366, + 0x3366, 0x3366, 0x3366, 0x1B6C, 0x1B6C, 0x1B6C, 0x1A2C, 0x1E3C, + 0x0E38, 0x0E38, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'X' + 0x0000, 0xE00F, 0x700C, 0x3018, 0x1830, 0x0C70, 0x0E60, 0x07C0, + 0x0380, 0x0380, 0x03C0, 0x06E0, 0x0C70, 0x1C30, 0x1818, 0x300C, + 0x600E, 0xE007, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'Y' + 0x0000, 0xC003, 0x6006, 0x300C, 0x381C, 0x1838, 0x0C30, 0x0660, + 0x07E0, 0x03C0, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'Z' + 0x0000, 0x7FFC, 0x7FFC, 0x6000, 0x3000, 0x1800, 0x0C00, 0x0600, + 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018, 0x000C, 0x0006, + 0x7FFE, 0x7FFE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '[' + 0x0000, 0x03E0, 0x03E0, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, + 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, + 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x03E0, 0x03E0, 0x0000, + // '\' + 0x0000, 0x0030, 0x0030, 0x0060, 0x0060, 0x0060, 0x00C0, 0x00C0, + 0x00C0, 0x01C0, 0x0180, 0x0180, 0x0180, 0x0300, 0x0300, 0x0300, + 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // ']' + 0x0000, 0x03E0, 0x03E0, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, + 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, + 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x03E0, 0x03E0, 0x0000, + // '^' + 0x0000, 0x0000, 0x01C0, 0x01C0, 0x0360, 0x0360, 0x0360, 0x0630, + 0x0630, 0x0C18, 0x0C18, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '_' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // ''' + 0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'a' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03F0, 0x07F8, + 0x0C1C, 0x0C0C, 0x0F00, 0x0FF0, 0x0CF8, 0x0C0C, 0x0C0C, 0x0F1C, + 0x0FF8, 0x18F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'b' + 0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x03D8, 0x0FF8, + 0x0C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C38, + 0x0FF8, 0x03D8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'c' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x07F0, + 0x0E30, 0x0C18, 0x0018, 0x0018, 0x0018, 0x0018, 0x0C18, 0x0E30, + 0x07F0, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'd' + 0x0000, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1BC0, 0x1FF0, + 0x1C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C30, + 0x1FF0, 0x1BC0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'e' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0FF0, + 0x0C30, 0x1818, 0x1FF8, 0x1FF8, 0x0018, 0x0018, 0x1838, 0x1C30, + 0x0FF0, 0x07C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'f' + 0x0000, 0x0F80, 0x0FC0, 0x00C0, 0x00C0, 0x00C0, 0x07F0, 0x07F0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'g' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0DE0, 0x0FF8, + 0x0E18, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0E18, + 0x0FF8, 0x0DE0, 0x0C00, 0x0C0C, 0x061C, 0x07F8, 0x01F0, 0x0000, + // 'h' + 0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x07D8, 0x0FF8, + 0x1C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, + 0x1818, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'i' + 0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'j' + 0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00F8, 0x0078, 0x0000, + // 'k' + 0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x0C0C, 0x060C, + 0x030C, 0x018C, 0x00CC, 0x006C, 0x00FC, 0x019C, 0x038C, 0x030C, + 0x060C, 0x0C0C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'l' + 0x0000, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'm' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3C7C, 0x7EFF, + 0xE3C7, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, + 0xC183, 0xC183, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'n' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0798, 0x0FF8, + 0x1C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, + 0x1818, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'o' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0FF0, + 0x0C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C30, + 0x0FF0, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'p' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03D8, 0x0FF8, + 0x0C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C38, + 0x0FF8, 0x03D8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0000, + // 'q' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1BC0, 0x1FF0, + 0x1C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C30, + 0x1FF0, 0x1BC0, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x0000, + // 'r' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07B0, 0x03F0, + 0x0070, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, + 0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 's' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, 0x03F0, + 0x0E38, 0x0C18, 0x0038, 0x03F0, 0x07C0, 0x0C00, 0x0C18, 0x0E38, + 0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 't' + 0x0000, 0x0000, 0x0080, 0x00C0, 0x00C0, 0x00C0, 0x07F0, 0x07F0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x07C0, 0x0780, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'u' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1818, 0x1818, + 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C38, + 0x1FF0, 0x19E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'v' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x180C, 0x0C18, + 0x0C18, 0x0C18, 0x0630, 0x0630, 0x0630, 0x0360, 0x0360, 0x0360, + 0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'w' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x41C1, 0x41C1, + 0x61C3, 0x6363, 0x6363, 0x6363, 0x3636, 0x3636, 0x3636, 0x1C1C, + 0x1C1C, 0x1C1C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'x' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x381C, 0x1C38, + 0x0C30, 0x0660, 0x0360, 0x0360, 0x0360, 0x0360, 0x0660, 0x0C30, + 0x1C38, 0x381C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // 'y' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3018, 0x1830, + 0x1830, 0x1870, 0x0C60, 0x0C60, 0x0CE0, 0x06C0, 0x06C0, 0x0380, + 0x0380, 0x0380, 0x0180, 0x0180, 0x01C0, 0x00F0, 0x0070, 0x0000, + // 'z' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1FFC, 0x1FFC, + 0x0C00, 0x0600, 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018, + 0x1FFC, 0x1FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // '{' + 0x0000, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x0060, 0x0060, 0x0030, 0x0060, 0x0040, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x0180, 0x0300, 0x0000, 0x0000, + // '|' + 0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0000, + // '}' + 0x0000, 0x0060, 0x00C0, 0x01C0, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0300, 0x0300, 0x0600, 0x0300, 0x0100, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x00C0, 0x0060, 0x0000, 0x0000, + // '~' + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x10F0, 0x1FF8, 0x0F08, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +}; + +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++) + tft_set_point(x + j, y + i, ((tmp_char >> j) & 0x01) ? charColor : bkColor); + } +} + +void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor, uint16_t bkColor) { + while (*string != '\0') { + disp_char_1624(x, y, *string, charColor, bkColor); + string++; + x += 16; + } +} + +//static lv_obj_t * scr_test; +void disp_pic_update() { + LCD_Clear(0x0000); + disp_string(120, 150, "PIC Updating...", 0xFFFF, 0x0000); +} + +void disp_font_update() { + LCD_Clear(0x0000); + disp_string(120, 150, "FONT Updating...", 0xFFFF, 0x0000); +} + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.h new file mode 100644 index 0000000..a1e2972 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.h @@ -0,0 +1,31 @@ +/** + * 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 "lvgl.h" + +void Test_GPIO(); +void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint16_t bkColor); +void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor, uint16_t bkColor); +void mks_test(); +void disp_pic_update(); +void disp_font_update(); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp new file mode 100644 index 0000000..85049ed --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp @@ -0,0 +1,736 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "../../../../MarlinCore.h" + +//#include "type_define.h" +#include "string.h" + +#include "pic_manager.h" +#include "W25Qxx.h" +#include "../../../../sd/cardreader.h" +#include "draw_ready_print.h" +#include "mks_hardware_test.h" + +//#include "gui.h" +//#include "spi_flash.h" + +//uint8_t DMA_ERRO_FLAG; +extern uint16_t DeviceCode; +extern unsigned char bmp_public_buf[17 * 1024]; + +#if ENABLED(SDSUPPORT) + extern char *createFilename(char * const buffer, const dir_t &p); +#endif + +/*void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) {}*/ + +uint32_t lv_get_pic_addr(uint8_t *Pname) { + uint8_t Pic_cnt; + uint8_t i, j; + PIC_MSG PIC; + uint32_t tmp_cnt = 0; + uint32_t addr = 0; + + W25QXX.init(SPI_QUARTER_SPEED); + + W25QXX.SPI_FLASH_BufferRead(&Pic_cnt, PIC_COUNTER_ADDR, 1); + if (Pic_cnt == 0xff) + Pic_cnt = 0; + for (i = 0; i < Pic_cnt; i++) { + j = 0; + do + { + W25QXX.SPI_FLASH_BufferRead(&PIC.name[j], PIC_NAME_ADDR + tmp_cnt, 1); + tmp_cnt++; + }while (PIC.name[j++] != '\0'); + + if ((strcmp((char*)Pname, (char*)PIC.name)) == 0) { + + if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) + addr = PIC_DATA_ADDR_TFT35 + i * PER_PIC_MAX_SPACE_TFT35; + else + addr = PIC_DATA_ADDR_TFT32 + i * PER_PIC_MAX_SPACE_TFT32; + return (addr + 4);//The purpose of adding 4 is to remove 4-byte picture header information. + } + } + + return addr; +} + +const char *picPath = "mks_pic"; +const char *bakPath = "bak_pic"; + +const char *fontPath = "mks_font"; +const char *bakFont = "bak_font"; + +#if 1 + +void spiFlashErase_PIC() { + #if 1 + volatile uint32_t pic_sectorcnt = 0; + + //LCD_Clear(BACK_COLOR); + //LCD_DisplayString(90,80,"SPI Flash"); + //LCD_DisplayString(120,90,"PIC Erasing..."); + if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) { + //LCD_ShowString(180,100,200,24,24,"SPI Flash"); + //LCD_ShowString(170,130,200,24,24,"PIC Erasing..."); + } + else { + //LCD_ShowString(100,90,200,24,24,"SPI Flash"); + //LCD_ShowString(100,120,200,24,24,"PIC Erasing..."); + } + #if ENABLED(MKS_TEST) + for (pic_sectorcnt = 0; pic_sectorcnt < 2; pic_sectorcnt++) + W25QXX.SPI_FLASH_BlockErase(PICINFOADDR + pic_sectorcnt * 64 * 1024); + + #else + for (pic_sectorcnt = 0; pic_sectorcnt < PIC_SIZE_xM * 1024 / 64; pic_sectorcnt++) + W25QXX.SPI_FLASH_BlockErase(PICINFOADDR + pic_sectorcnt * 64 * 1024); + + #endif + /* + FLASH_Unlock(); + spiFlashEraseFlag = SPI_FLASH_ERASE_FLAG_DATA; + FLASH_ProgramHalfWord(SPI_FLASH_ERASE_FLAG_ADDR,spiFlashEraseFlag); + FLASH_Lock(); + */ + #if 0 + if (DeviceCode == 0x9488) + LCD_ShowString(170, 130, 200, 24, 24, "PIC Erase Done"); + else + LCD_ShowString(100, 120, 200, 24, 24, "PIC Erase Done"); + + #endif + //spiFlashEraseFlag = 1; + #endif +} + +void spiFlashErase_FONT() { + volatile uint32_t Font_sectorcnt = 0; + + //LCD_Clear(BACK_COLOR); + if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) { + //LCD_ShowString(180,100,200,24,24,"SPI Flash"); + //LCD_ShowString(170,130,200,24,24,"FONT Erasing..."); + } + else { + //LCD_ShowString(100,90,200,24,24,"SPI Flash"); + //LCD_ShowString(90,120,200,24,24,"FONT Erasing..."); + } + + for (Font_sectorcnt = 0; Font_sectorcnt < FONT_SIZE_xM * 1024 / 64; Font_sectorcnt++) + W25QXX.SPI_FLASH_BlockErase(FONTINFOADDR + Font_sectorcnt * 64 * 1024); + + /* + FLASH_Unlock(); + spiFlashEraseFlag = SPI_FLASH_ERASE_FLAG_DATA; + FLASH_ProgramHalfWord(SPI_FLASH_ERASE_FLAG_ADDR,spiFlashEraseFlag); + FLASH_Lock(); + */ + #if 0 + if (DeviceCode == 0x9488) + LCD_ShowString(170, 130, 200, 24, 24, "FONT Erase Done"); + else + LCD_ShowString(90, 120, 200, 24, 24, "FONT Erase Done"); + //LCD_DisplayString(120,90,"FONT Erase Done"); + #endif + //spiFlashEraseFlag = 1; +} + +uint32_t LogoWrite_Addroffset = 0; + +uint8_t Pic_Logo_Write(uint8_t *LogoName, uint8_t *Logo_Wbuff, uint32_t LogoWriteSize) { + //uint16_t n; + uint32_t i; + uint8_t temp1; + static uint32_t logo_maxsize; + + if (LogoWriteSize <= 0) return 0; + + W25QXX.SPI_FLASH_BufferWrite(Logo_Wbuff, PIC_LOGO_ADDR + LogoWrite_Addroffset, LogoWriteSize); + + for (i = 0; i < LogoWriteSize; i++) { + W25QXX.SPI_FLASH_BufferRead(&temp1, PIC_LOGO_ADDR + LogoWrite_Addroffset + i, 1); + if (*(Logo_Wbuff + i) != temp1) return 0; + } + LogoWrite_Addroffset += LogoWriteSize; + if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) + logo_maxsize = LOGO_MAX_SIZE_TFT35; + else + logo_maxsize = LOGO_MAX_SIZE_TFT32; + if (LogoWrite_Addroffset >= logo_maxsize) + LogoWrite_Addroffset = 0; + return 1; +} + +uint32_t TitleLogoWrite_Addroffset = 0; +uint8_t Pic_TitleLogo_Write(uint8_t *TitleLogoName, uint8_t *TitleLogo_Wbuff, uint32_t TitleLogoWriteSize) { + //uint32_t i; + //uint8_t temp1; + if (TitleLogoWriteSize <= 0) + return 0; + if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) + W25QXX.SPI_FLASH_BufferWrite(TitleLogo_Wbuff, PIC_ICON_LOGO_ADDR_TFT35 + TitleLogoWrite_Addroffset, TitleLogoWriteSize); + else + W25QXX.SPI_FLASH_BufferWrite(TitleLogo_Wbuff, PIC_ICON_LOGO_ADDR_TFT32 + TitleLogoWrite_Addroffset, TitleLogoWriteSize); + TitleLogoWrite_Addroffset += TitleLogoWriteSize; + if (TitleLogoWrite_Addroffset >= TITLELOGO_MAX_SIZE) + TitleLogoWrite_Addroffset = 0; + return 1; +} + +uint32_t default_view_addroffset_r = 0; +void default_view_Write(uint8_t *default_view__Rbuff, uint32_t default_view_Writesize) { + W25QXX.SPI_FLASH_BufferWrite(default_view__Rbuff, DEFAULT_VIEW_ADDR_TFT35 + default_view_addroffset_r, default_view_Writesize); + default_view_addroffset_r += default_view_Writesize; + if (default_view_addroffset_r >= DEFAULT_VIEW_MAX_SIZE) + default_view_addroffset_r = 0; +} + +uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { + uint8_t pic_counter = 0; + uint32_t Pic_SaveAddr; + uint32_t Pic_SizeSaveAddr; + uint32_t Pic_NameSaveAddr; + //uint8_t temp; + uint8_t Pname_temp; + uint32_t i, j; + uint32_t name_len = 0; + uint32_t SaveName_len = 0; + union union32 size_tmp; + //union union32 size1; + //uint8_t Pn[PIC_NAME_MAX_LEN]; + //uint8_t cnt_temp; + //uint16_t n0; + //uint32_t Name_saveAddr = 0; + //uint8_t pic_position; + + W25QXX.SPI_FLASH_BufferRead(&pic_counter, PIC_COUNTER_ADDR, 1); + + if (pic_counter == 0xFF) + pic_counter = 0; + + if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) + Pic_SaveAddr = PIC_DATA_ADDR_TFT35 + pic_counter * PER_PIC_MAX_SPACE_TFT35; + else + Pic_SaveAddr = PIC_DATA_ADDR_TFT32 + pic_counter * PER_PIC_MAX_SPACE_TFT32; + + for (j = 0; j < pic_counter; j++) { + do { + W25QXX.SPI_FLASH_BufferRead(&Pname_temp, PIC_NAME_ADDR + SaveName_len, 1); + SaveName_len++; + } while (Pname_temp != '\0'); + } + i = 0; + while ((*(P_name + i) != '\0')) { + i++; + name_len++; + } + + Pic_NameSaveAddr = PIC_NAME_ADDR + SaveName_len; + W25QXX.SPI_FLASH_BufferWrite(P_name, Pic_NameSaveAddr, name_len + 1); + Pic_SizeSaveAddr = PIC_SIZE_ADDR + 4 * pic_counter; + size_tmp.dwords = P_size; + W25QXX.SPI_FLASH_BufferWrite(size_tmp.bytes, Pic_SizeSaveAddr, 4); + + pic_counter++; + W25QXX.SPI_FLASH_SectorErase(PIC_COUNTER_ADDR); + W25QXX.SPI_FLASH_BufferWrite(&pic_counter, PIC_COUNTER_ADDR, 1); + + return Pic_SaveAddr; +} + +uint8_t public_buf[512]; + +//uint8_t public_buf_test[512]; + #if ENABLED(SDSUPPORT) +void UpdatePic() { + //int r; + //unsigned char *p; + //char rootPath[10]={0}; + char *fn; + unsigned char logoFlag; + uint16_t pbr; + uint32_t pfileSize; + uint32_t Pic_Write_Addr; + /*----------------------------------*/ + + // FILINFO fno; + //DIR dir; + //char tmp[30]; + #if 0//_USE_LFN + static char lfn[_MAX_LFN + 1]; + finfo.lfname = lfn; + finfo.lfsize = sizeof(lfn); + #endif + //SdFile curDir; + //if (f_opendir(&dirs, picPath) == FR_OK) + //card.cd(picPath); + + //const uint16_t fileCnt = card.get_num_Files(); + + //SdFile *curDir; + //SdFile dir; + //dir.open(picPath, O_READ); + //const char * const fname = card.diveToFile(true, curDir, picPath); + //if (!fname) return; + + SdFile dir, root = card.getroot(); + if (dir.open(&root, picPath, O_RDONLY)) { + + disp_pic_update(); + spiFlashErase_PIC(); + + dir_t d; + while (dir.readDir(&d, card.longFilename) > 0) { + #if 1 + /* + if (power_det == 0) { + PW_DET_ON; + power_det=0; + } + SPI_FLASH_Init(); + */ + + //for (uint16_t i = 0; i < fileCnt; i++) { + //res = f_readdir(&dirs, &finfo); + //card.getfilename_sorted(i); + + if (card.longFilename[0] == 0) + break; + /*if ( card.filename[0] == '.') + continue; + */ + if (card.longFilename[0] == '.') + continue; + + fn = card.longFilename; + + /*if ((finfo.lfname[0] == 0) || (finfo.lfname == 0)) + fn = finfo.fname; + else + fn = finfo.lfname;*/ + + /* if (fno.fattrib & AM_DIR) + { + continue; + } + else */ + //{ + //if ((strstr(fn, ".gco")) || (strstr(fn, ".GCO")) || (fno.fattrib & AM_DIR)) + if (strstr(fn, ".bin")) { + if (strstr(fn, "_logo")) + logoFlag = 1; + else if (strstr(fn, "_titlelogo")) + logoFlag = 2; + else if (strstr(fn, "_preview")) + logoFlag = 3; + else + logoFlag = 0; + + //public_buf[0] = '\0'; + //strcat(public_buf, picPath); + //strcat(public_buf, "/"); + char dosFilename[FILENAME_LENGTH]; + createFilename(dosFilename, d); + //strcat(public_buf, dosFilename); + + SdFile file; + if (file.open(&dir, dosFilename, O_READ)) { + #if 1 + /*LCD_Clear(BACK_COLOR); + + if ((DeviceCode==0x9488)||(DeviceCode==0x5761)) { + LCD_ShowString(170,100,200,24,24,(u8 *)fn); + LCD_ShowString(180,130,200,24,24,"Updating..."); + } + else { + LCD_ShowString(90,90,200,24,24,(u8 *)fn); + LCD_ShowString(90,120,200,24,24,"Updating..."); + } + */ + if (logoFlag == 1) { + while (1) { + pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); + Pic_Logo_Write((uint8_t *)fn, public_buf, pbr); // + if (pbr < BMP_WRITE_BUF_LEN) break; + } + } + else if (logoFlag == 2) { + while (1) { + pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); + Pic_TitleLogo_Write((uint8_t *)fn, public_buf, pbr); // + if (pbr < BMP_WRITE_BUF_LEN) break; + } + } + else if (logoFlag == 3) { + while (1) + { + pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); + default_view_Write(public_buf, pbr); // + if (pbr < BMP_WRITE_BUF_LEN) break; + } + } + else { + pfileSize = file.fileSize(); + Pic_Write_Addr = Pic_Info_Write((uint8_t *)fn, pfileSize); + //uint32_t addr_test = Pic_Write_Addr; + //memset(bmp_public_buf, 0xff, BMP_WRITE_BUF_LEN); + while (1) + { + pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); + W25QXX.SPI_FLASH_BufferWrite(public_buf, Pic_Write_Addr, pbr); + Pic_Write_Addr += pbr; + if (pbr < BMP_WRITE_BUF_LEN) break; + } + //W25QXX.SPI_FLASH_BufferRead(public_buf_test,addr_test,BMP_WRITE_BUF_LEN); + } + + /*--------------read test--------------------*/ + /* + BufferSet(picBuffer, 0xff, PICTURE_MAX_SIZE); + if (logoFlag == 0) + { + PicMsg_Init(); + Pic_Read(fn,picBuffer); + } + else + Pic_Logo_Read(fn,picBuffer,PICTURE_MAX_SIZE); + */ + /*--------------read test--------------------*/ + + file.close(); + #endif + } + + } + //} + //} + /* + LCD_Clear(LCD_COLOR_BLACK); + //LCD_ShowString(110,100,200,24,24,"Complete"); + LCD_DisplayString(110,80,"Complete"); + delay(0xfffff); + */ + //r = f_chdir("/"); + #if 1 + //SdFile dir, root = card.getroot(); + /*if (dir.open(&root, bakPath, O_RDONLY)) + { + dir.remove(); + }*/ + + //r = f_rename(picPath, bakPath); + + + //update_flag_ok = 1; + #endif + #endif + } + dir.rename(&root, bakPath); + } +} + + +void spi_flash_read_test() {W25QXX.SPI_FLASH_BufferRead(public_buf, UNIGBK_FLASH_ADDR, BMP_WRITE_BUF_LEN);} + +void UpdateFont() { + //int r; + //unsigned char *p; + //char rootPath[10]={0}; + char *fn; + //unsigned char logoFlag; + uint16_t pbr; + uint32_t flashaddr = 0; + //uint32_t pfileSize; + //uint32_t Pic_Write_Addr; + /*----------------------------------*/ + + // FILINFO fno; + //DIR dir; + //char tmp[30]; + #if 0//_USE_LFN + static char lfn[_MAX_LFN + 1]; + finfo.lfname = lfn; + finfo.lfsize = sizeof(lfn); + #endif + //SdFile curDir; + //if (f_opendir(&dirs, picPath) == FR_OK) + //card.cd(picPath); + + //const uint16_t fileCnt = card.get_num_Files(); + + //SdFile *curDir; + //SdFile dir; + //dir.open(picPath, O_READ); + //const char * const fname = card.diveToFile(true, curDir, picPath); + //if (!fname) return; + + SdFile dir, root = card.getroot(); + if (dir.open(&root, fontPath, O_RDONLY)) { + + disp_font_update(); + spiFlashErase_FONT(); + + dir_t d; + while (dir.readDir(&d, card.longFilename) > 0) + { + #if 1 + /*if (power_det == 0) + { + PW_DET_ON; + power_det=0; + } + SPI_FLASH_Init();*/ + + + //for (uint16_t i = 0; i < fileCnt; i++) + //{ + //res = f_readdir(&dirs, &finfo); + //card.getfilename_sorted(i); + + if (card.longFilename[0] == 0) + break; + /*if ( card.filename[0] == '.') + continue; + */ + if (card.longFilename[0] == '.') + continue; + + fn = card.longFilename; + + /*if ((finfo.lfname[0] == 0) || (finfo.lfname == 0)) + fn = finfo.fname; + else + fn = finfo.lfname;*/ + + /* if (fno.fattrib & AM_DIR) + { + continue; + } + else */ + //{ + //if ((strstr(fn, ".gco")) || (strstr(fn, ".GCO")) || (fno.fattrib & AM_DIR)) + if (strstr(fn, ".bin")) { + char dosFilename[FILENAME_LENGTH]; + createFilename(dosFilename, d); + //strcat(public_buf, dosFilename); + + SdFile file; + if (file.open(&dir, dosFilename, O_READ)) { + + #if 1 + /*LCD_Clear(BACK_COLOR); + + if ((DeviceCode==0x9488)||(DeviceCode==0x5761)) + { + LCD_ShowString(170,100,200,24,24,(u8 *)fn); + LCD_ShowString(180,130,200,24,24,"Updating..."); + } + else + { + LCD_ShowString(90,90,200,24,24,(u8 *)fn); + LCD_ShowString(90,120,200,24,24,"Updating..."); + } + */ + flashaddr = UNIGBK_FLASH_ADDR; + pbr = 0; + while (1) + { + flashaddr += pbr; + pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); + W25QXX.SPI_FLASH_BufferWrite(public_buf, flashaddr, pbr); + //W25QXX.SPI_FLASH_BufferRead(public_buf_test,flashaddr,pbr); + /*if (UNIGBKFlag == 1) + { + fontrate = (uint16_t)(((float)(flashaddr - UNIGBK_FLASH_ADDR)/(float)(psrc.fsize))*100); + } + else + { + fontrate = (uint16_t)(((float)(flashaddr - GBK_FLASH_ADDR)/(float)(psrc.fsize))*100); + } + + if (fontrate > 99) fontrate=99; + + if (fontrate < 10) + { + fontString[0] = fontrate%10 + 0x30; + fontString[1] = '%'; + fontString[2] = '\0'; + } + else + { + fontString[0] = fontrate/10 + 0x30; + fontString[1] = fontrate%10 + 0x30; + fontString[2] = '%'; + fontString[3] = '\0'; + }*/ + //LCD_DisplayString(140,130,fontString); + if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) { + //LCD_ShowString(200,160,200,24,24,fontString); + } + else { + //LCD_ShowString(140,150,200,24,24,fontString); + } + if (pbr < BMP_WRITE_BUF_LEN) break; + } + /*--------------read test--------------------*/ + /* + BufferSet(picBuffer, 0xff, PICTURE_MAX_SIZE); + if (logoFlag == 0) + { + PicMsg_Init(); + Pic_Read(fn,picBuffer); + } + else + Pic_Logo_Read(fn,picBuffer,PICTURE_MAX_SIZE); + */ + /*--------------read test--------------------*/ + + file.close(); + #endif + } + + } + //} + //} + /* + LCD_Clear(LCD_COLOR_BLACK); + //LCD_ShowString(110,100,200,24,24,"Complete"); + LCD_DisplayString(110,80,"Complete"); + delay(0xfffff); + */ + //r = f_chdir("/"); + #if 1 + //SdFile dir, root = card.getroot(); + /*if (dir.open(&root, bakPath, O_RDONLY)) + { + dir.remove(); + }*/ + dir.rename(&root, bakFont); + //r = f_rename(picPath, bakPath); + + + //update_flag_ok = 1; + #endif + #endif + } + } +} + #endif // SDSUPPORT + +#endif + +#if 1 + +void Pic_Read(uint8_t *Pname, uint8_t *P_Rbuff) { + uint8_t i, j; + uint8_t Pic_cnt; + uint32_t tmp_cnt = 0; + PIC_MSG PIC; + + //void SPI_FLASH_BufferRead(u8* pBuffer, u32 ReadAddr, u16 NumByteToRead); + + W25QXX.SPI_FLASH_BufferRead(&Pic_cnt, PIC_COUNTER_ADDR, 1); + if (Pic_cnt == 0xff) + Pic_cnt = 0; + + for (i = 0; i < Pic_cnt; i++) { + //pic name + j = 0; + do + { + W25QXX.SPI_FLASH_BufferRead(&PIC.name[j], PIC_NAME_ADDR + tmp_cnt, 1); + tmp_cnt++; + }while (PIC.name[j++] != '\0'); + //pic size + W25QXX.SPI_FLASH_BufferRead(PIC.size.bytes, PIC_SIZE_ADDR + i * 4, 4); + + if ((strcmp((char*)Pname, (char*)PIC.name)) == 0) { + W25QXX.SPI_FLASH_BufferRead((uint8_t *)P_Rbuff, PIC_DATA_ADDR_TFT35 + i * PER_PIC_MAX_SPACE_TFT35, PIC.size.dwords); + /*if (DMA_ERRO_FLAG) + { + DMA_ERRO_FLAG = 0; + SPI_FLASH_BufferRead((uint8_t *)P_Rbuff,PIC_DATA_ADDR+i*PER_PIC_MAX_SPACE,PIC.size.dwords); + }*/ + break; + } + } +} + +void lv_pic_test(uint8_t *P_Rbuff, uint32_t addr, uint32_t size) { + W25QXX.init(SPI_QUARTER_SPEED); + W25QXX.SPI_FLASH_BufferRead((uint8_t *)P_Rbuff, addr, size); + /*if (DMA_ERRO_FLAG) { + DMA_ERRO_FLAG = 0; + SPI_FLASH_BufferRead((uint8_t *)P_Rbuff,addr,size); + }*/ + +} + +void get_spi_flash_data(const char *rec_buf, int addr, int size) { + W25QXX.init(SPI_QUARTER_SPEED); + W25QXX.SPI_FLASH_BufferRead((uint8_t *)rec_buf, UNIGBK_FLASH_ADDR + addr, size); +} + +#endif + +#if 1 + + uint32_t logo_addroffset = 0; + void Pic_Logo_Read(uint8_t *LogoName, uint8_t *Logo_Rbuff, uint32_t LogoReadsize) { + W25QXX.SPI_FLASH_BufferRead(Logo_Rbuff, PIC_LOGO_ADDR + logo_addroffset, LogoReadsize); + logo_addroffset += LogoReadsize; + if (logo_addroffset >= LOGO_MAX_SIZE_TFT35) + logo_addroffset = 0; + } + + uint32_t default_view_addroffset = 0; + void default_view_Read(uint8_t *default_view_Rbuff, uint32_t default_view_Readsize) { + W25QXX.init(SPI_QUARTER_SPEED); + + W25QXX.SPI_FLASH_BufferRead(default_view_Rbuff, DEFAULT_VIEW_ADDR_TFT35 + default_view_addroffset + 4, default_view_Readsize); + default_view_addroffset += default_view_Readsize; + if (default_view_addroffset >= DEFAULT_VIEW_MAX_SIZE) + default_view_addroffset = 0; + + } + + uint32_t flash_view_addroffset = 0; + void flash_view_Read(uint8_t *flash_view_Rbuff, uint32_t flash_view_Readsize) { + W25QXX.init(SPI_QUARTER_SPEED); + + W25QXX.SPI_FLASH_BufferRead(flash_view_Rbuff, BAK_VIEW_ADDR_TFT35 + flash_view_addroffset, flash_view_Readsize); + flash_view_addroffset += flash_view_Readsize; + if (flash_view_addroffset >= FLASH_VIEW_MAX_SIZE) + flash_view_addroffset = 0; + + } + +#endif + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h new file mode 100644 index 0000000..b307cc8 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h @@ -0,0 +1,120 @@ +/** + * 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 + +#include +#include +#include "lvgl.h" + +#if 1 + + #define PIC_MAX_CN 100 // Maximum number of pictures + #define PIC_NAME_MAX_LEN 50 // Picture name maximum length + + #define LOGO_MAX_SIZE_TFT35 (300*1024) + #define LOGO_MAX_SIZE_TFT32 (150*1024) + #define TITLELOGO_MAX_SIZE (150*1024) // Little logo maximum + #define DEFAULT_VIEW_MAX_SIZE (200*200*2) + #define FLASH_VIEW_MAX_SIZE (200*200*2) + + #define PER_PIC_MAX_SPACE_TFT35 (32*1024) + #define PER_PIC_MAX_SPACE_TFT32 (16*1024) + #define PER_FONT_MAX_SPACE (16*1024) + + //pic + //Robin_pro pic addr + #define PIC_NAME_ADDR 0x003000 // Pic information addr + #define PIC_SIZE_ADDR 0x007000 // Pic size information addr + #define PIC_COUNTER_ADDR 0x008000 // Pic total number + #define PER_PIC_SAVE_ADDR 0x009000 // Storage address of each picture + #define PIC_LOGO_ADDR 0x00A000 // Logo addr + //#define PIC_DATA_ADDR 0x02F000 // + + // TFT35 + #define DEFAULT_VIEW_ADDR_TFT35 0XC5800 + #define BAK_VIEW_ADDR_TFT35 (DEFAULT_VIEW_ADDR_TFT35+90*1024) + #define PIC_ICON_LOGO_ADDR_TFT35 (BAK_VIEW_ADDR_TFT35+80*1024) + #define PIC_DATA_ADDR_TFT35 (PIC_ICON_LOGO_ADDR_TFT35+350*1024)//0XC5800 + + // TFT32 + #define PIC_DATA_ADDR_TFT32 0x02F000 + #define PIC_ICON_LOGO_ADDR_TFT32 0x5D8000 + #define PIC_OTHER_SIZE_ADDR_TFT32 0x5EE000 + + // font + #define FONTINFOADDR 0x600000 // 6M -- font addr + #define UNIGBK_FLASH_ADDR (FONTINFOADDR+4096) // 4*1024 + #define GBK_FLASH_ADDR (UNIGBK_FLASH_ADDR+180224) // 176*1024 + + // Flash flag + #define FLASH_INF_VALID_FLAG 0xAA558761 + // SD card information first addr + #define VAR_INF_ADDR 0x000000 + + union union32 { + uint8_t bytes[4]; + uint32_t dwords; + }; + + // pic information + struct pic_msg { + uint8_t name[PIC_NAME_MAX_LEN]; + union union32 size; + }; + + typedef struct pic_msg PIC_MSG; + + #define BMP_WRITE_BUF_LEN 512 + + #define PICINFOADDR 0 + + #define PIC_SIZE_xM 6 + #define FONT_SIZE_xM 2 + + //extern void PicMsg_Init(void); + extern void Pic_Read(uint8_t *Pname, uint8_t *P_Rbuff); + //extern void bindBmpFileData(const uint8_t **pBuf, uint8_t *pName); + //extern void Pic_Logo_Read(uint8_t *LogoName,uint8_t *Logo_Rbuff,uint32_t LogoReadsize); + //extern void default_view_Read(uint8_t *default_view_Rbuff,uint32_t default_view_Readsize); + //extern void flash_view_Read(uint8_t *flash_view_Rbuff,uint32_t flash_view_Readsize); + + //extern void lv_Pic_Read(uint8_t *Pname,uint8_t *P_Rbuff,uint32_t addr,uint32_t size); + extern void lv_pic_test(uint8_t *P_Rbuff, uint32_t addr, uint32_t size); + +#endif + +extern uint32_t lv_get_pic_addr(uint8_t *Pname); + +extern void get_spi_flash_data(const char *rec_buf, int offset, int size); +//extern void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead); + +extern void spi_flash_read_test(); +extern void default_view_Read(uint8_t *default_view_Rbuff, uint32_t default_view_Readsize); +extern void flash_view_Read(uint8_t *flash_view_Rbuff, uint32_t flash_view_Readsize); + +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/printer_opration.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/printer_opration.cpp new file mode 100644 index 0000000..584a009 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/printer_opration.cpp @@ -0,0 +1,218 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + + #include "../../../../MarlinCore.h" + + #include "lv_conf.h" + #include "draw_ui.h" + #include "../../../../module/temperature.h" + #include "../../../../module/motion.h" + #include "../../../../sd/cardreader.h" + #include "../../../../gcode/queue.h" + + #if ENABLED(POWER_LOSS_RECOVERY) + #include "../../../../feature/powerloss.h" + #endif + + #include "../../../../gcode/gcode.h" + #include "../../../../module/planner.h" + + extern uint32_t To_pre_view; + extern uint8_t flash_preview_begin, default_preview_flg, gcode_preview_over; + + void printer_state_polling() { + if (uiCfg.print_state == PAUSING) { + #if ENABLED(SDSUPPORT) + if (!planner.has_blocks_queued() && card.getIndex() > MIN_FILE_PRINTED) //���� �ļ��� M109��M190ָ�� + uiCfg.waitEndMoves++; + + if (uiCfg.waitEndMoves > 20) { + uiCfg.waitEndMoves = 0; + planner.synchronize(); + gcode.process_subcommands_now_P(PSTR("M25")); + gcode.process_subcommands_now_P(PSTR("G91")); + gcode.process_subcommands_now_P(PSTR("G1 Z5")); + gcode.process_subcommands_now_P(PSTR("G90")); + + uiCfg.print_state = PAUSED; + + //#if ENABLED(POWER_LOSS_RECOVERY) + // if (recovery.enabled) recovery.save(true); + //#endif + gCfgItems.pause_reprint = 1; + update_spi_flash(); + } + #endif + } + else { + uiCfg.waitEndMoves = 0; + } + + if (uiCfg.print_state == PAUSED) { + + } + + if (uiCfg.print_state == RESUMING) { + if (IS_SD_PAUSED()) { + gcode.process_subcommands_now_P(PSTR("G91")); + gcode.process_subcommands_now_P(PSTR("G1 Z-5")); + gcode.process_subcommands_now_P(PSTR("G90")); + gcode.process_subcommands_now_P(PSTR("M24")); + uiCfg.print_state = WORKING; + start_print_time(); + + gCfgItems.pause_reprint = 0; + update_spi_flash(); + } + } + #if ENABLED(POWER_LOSS_RECOVERY) + if (uiCfg.print_state == REPRINTED) { + memset(public_buf_m, 0, sizeof(public_buf_m)); + #if HOTENDS + HOTEND_LOOP() { + const int16_t et = recovery.info.target_temperature[e]; + if (et) { + #if HOTENDS > 1 + sprintf_P(public_buf_m, PSTR("T%i"), e); + gcode.process_subcommands_now(public_buf_m); + #endif + sprintf_P(public_buf_m, PSTR("M109 S%i"), et); + gcode.process_subcommands_now(public_buf_m); + } + } + #endif + + if (gCfgItems.pause_reprint == 1) { + gcode.process_subcommands_now_P(PSTR("G91")); + gcode.process_subcommands_now_P(PSTR("G1 Z-5")); + gcode.process_subcommands_now_P(PSTR("G90")); + } + recovery.resume(); + + uiCfg.print_state = WORKING; + start_print_time(); + + gCfgItems.pause_reprint = 0; + update_spi_flash(); + } + #endif + + if (uiCfg.print_state == WORKING) + filament_check(); + } + + void filament_pin_setup() { + #if PIN_EXISTS(MT_DET_1) + pinMode(MT_DET_1_PIN, INPUT_PULLUP); + #endif + #if PIN_EXISTS(MT_DET_2) + pinMode(MT_DET_2_PIN, INPUT_PULLUP); + #endif + #if PIN_EXISTS(MT_DET_3) + pinMode(MT_DET_3_PIN, INPUT_PULLUP); + #endif + } + + void filament_check() { + const int FIL_DELAY = 20; + #if PIN_EXISTS(MT_DET_1) + static int fil_det_count_1 = 0; + if (!READ(MT_DET_1_PIN) && !MT_DET_PIN_INVERTING) + fil_det_count_1++; + else if (READ(MT_DET_1_PIN) && MT_DET_PIN_INVERTING) + fil_det_count_1++; + else if (fil_det_count_1 > 0) + fil_det_count_1--; + + if (!READ(MT_DET_1_PIN) && !MT_DET_PIN_INVERTING) + fil_det_count_1++; + else if (READ(MT_DET_1_PIN) && MT_DET_PIN_INVERTING) + fil_det_count_1++; + else if (fil_det_count_1 > 0) + fil_det_count_1--; + #endif + + #if PIN_EXISTS(MT_DET_2) + static int fil_det_count_2 = 0; + if (!READ(MT_DET_2_PIN) && !MT_DET_PIN_INVERTING) + fil_det_count_2++; + else if (READ(MT_DET_2_PIN) && MT_DET_PIN_INVERTING) + fil_det_count_2++; + else if (fil_det_count_2 > 0) + fil_det_count_2--; + + if (!READ(MT_DET_2_PIN) && !MT_DET_PIN_INVERTING) + fil_det_count_2++; + else if (READ(MT_DET_2_PIN) && MT_DET_PIN_INVERTING) + fil_det_count_2++; + else if (fil_det_count_2 > 0) + fil_det_count_2--; + #endif + + #if PIN_EXISTS(MT_DET_3) + static int fil_det_count_3 = 0; + if (!READ(MT_DET_3_PIN) && !MT_DET_PIN_INVERTING) + fil_det_count_3++; + else if (READ(MT_DET_3_PIN) && MT_DET_PIN_INVERTING) + fil_det_count_3++; + else if (fil_det_count_3 > 0) + fil_det_count_3--; + + if (!READ(MT_DET_3_PIN) && !MT_DET_PIN_INVERTING) + fil_det_count_3++; + else if (READ(MT_DET_3_PIN) && MT_DET_PIN_INVERTING) + fil_det_count_3++; + else if (fil_det_count_3 > 0) + fil_det_count_3--; + #endif + + if ( + #if PIN_EXISTS(MT_DET_1) + fil_det_count_1 >= FIL_DELAY + #else + false + #endif + #if PIN_EXISTS(MT_DET_2) + || fil_det_count_2 >= FIL_DELAY + #endif + #if PIN_EXISTS(MT_DET_3) + || fil_det_count_3 >= FIL_DELAY + #endif + ) { + clear_cur_ui(); + card.pauseSDPrint(); + stop_print_time(); + uiCfg.print_state = PAUSING; + + if (gCfgItems.from_flash_pic == 1) + flash_preview_begin = 1; + else + default_preview_flg = 1; + + lv_draw_printing(); + } + } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/printer_opration.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/printer_opration.h new file mode 100644 index 0000000..7235188 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/printer_opration.h @@ -0,0 +1,36 @@ +/** + * 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 + +#define MIN_FILE_PRINTED 100 //5000 + +extern void printer_state_polling(); +extern void filament_pin_setup(); +extern void filament_check(); + +#ifdef __cplusplus +} /* C-declarations for C++ */ +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h new file mode 100644 index 0000000..038f5f4 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h @@ -0,0 +1,718 @@ +/** + * 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 + +//****************英文***************************// +#define MACHINE_CONFIG_EN "Machine\nSettings" + +#define NEXT_EN "Next" +#define PREVIOUS_EN "Previous" +#define DEFAULT_EN "Default" +#define KEY_BACK_EN "Del" +#define KEY_REST_EN "Rest" +#define KEY_CONFIRM_EN "Confirm" + +#define KEYBOARD_KEY0_EN "0" +#define KEYBOARD_KEY1_EN "1" +#define KEYBOARD_KEY2_EN "2" +#define KEYBOARD_KEY3_EN "3" +#define KEYBOARD_KEY4_EN "4" +#define KEYBOARD_KEY5_EN "5" +#define KEYBOARD_KEY6_EN "6" +#define KEYBOARD_KEY7_EN "7" +#define KEYBOARD_KEY8_EN "8" +#define KEYBOARD_KEY9_EN "9" +#define KEYBOARD_KEY_POINT_EN "." +#define KEYBOARD_KEY_NEGATIVE_EN "-" + +#define MACHINE_PARA_EN "Machine\nsettings" +#define MACHINE_PARA_TITLE_EN "Machine settings" +#define MACHINE_TYPE_CNOFIG_EN "Machine" +#define TEMPERATURE_CONFIG_EN "Temperature" +#define MOTOR_CONFIG_EN "Motor" +#define ADVANCE_CONFIG_EN "Adavance" + +#define MACHINE_CONFIG_TITLE_EN "Machine Settings" +#define MACHINE_TYPE_EN "Machine type" +#define MACHINE_STROKE_EN "Machine Size" +#define MACHINE_HOMEDIR_EN "Home direction" +#define MACHINE_ENDSTOP_TYPE_EN "Endstop type" +#define MACHINE_FILAMENT_CONFIG_EN "Filament settings" +#define MACHINE_LEVELING_CONFIG_EN "Leveling settings" + +#define MACHINE_TYPE_CONFIG_TITLE_EN "Machine Settings>Machine type" +#define MACHINE_TYPE_XYZ_EN "XYZ Machine" +#define MACHINE_TYPE_DELTA_EN "Delta Machine" +#define MACHINE_TYPE_COREXY_EN "Corexy Machine" + +#define MACHINE_STROKE_CONF_TITLE_EN "Machine Settings>Machine Size" +#define X_MAX_LENGTH_EN "X-axis maximum stroke" +#define Y_MAX_LENGTH_EN "Y-axis maximum stroke" +#define Z_MAX_LENGTH_EN "Z-axis maximum stroke" + +#define X_MIN_LENGTH_EN "X-axis minimum stroke" +#define Y_MIN_LENGTH_EN "Y-axis minimum stroke" +#define Z_MIN_LENGTH_EN "Z-axis minimum stroke" + +#define HOME_DIR_CONF_TITLE_EN "Machine Settings>Home direction" +#define HOME_DIR_X_EN "X-axis home direction" +#define HOME_DIR_Y_EN "Y-axis home direction" +#define HOME_DIR_Z_EN "Z-axis home direction" +#define HOME_MIN_EN "MIN" +#define HOME_MAX_EN "MAX" + +#define ENDSTOP_CONF_TITLE_EN "Machine Settings>Endstop type" +#define MIN_ENDSTOP_X_EN "X-axis minimum Endstop" +#define MIN_ENDSTOP_Y_EN "Y-axis minimum Endstop" +#define MIN_ENDSTOP_Z_EN "Z-axis minimum Endstop" +#define MAX_ENDSTOP_X_EN "X axis maximum Endstop" +#define MAX_ENDSTOP_Y_EN "Y axis maximum Endstop" +#define MAX_ENDSTOP_Z_EN "Z axis maximum Endstop" +#define ENDSTOP_FIL_EN "Filament sensor" +#define ENDSTOP_LEVEL_EN "Leveling sensor" +#define ENDSTOP_OPENED_EN "Open" +#define ENDSTOP_CLOSED_EN "Close" + +#define FILAMENT_CONF_TITLE_EN "Filament settings" +#define FILAMENT_IN_TEMPERATURE_EN "Load temperature" +#define FILAMENT_IN_LENGTH_EN "Load length" +#define FILAMENT_IN_SPEED_EN "Load speed" +#define FILAMENT_OUT_TEMPERATURE_EN "Unload temperature" +#define FILAMENT_OUT_LENGTH_EN "Unload length" +#define FILAMENT_OUT_SPEED_EN "Unload speed" + +#define LEVELING_CONF_TITLE_EN "Leveling settings" +#define LEVELING_PARA_CONF_EN "Leveling settings" +#define LEVELING_DELTA_EN "delta machine leveling" +#define LEVELING_XYZ_EN "Manual leveling coordinate settings" + +#define LEVELING_PARA_CONF_TITLE_EN "leveling setting" +#define AUTO_LEVELING_ENABLE_EN "Enable auto leveling" +#define BLTOUCH_LEVELING_ENABLE_EN "Enable BLtouch" +#define PROBE_PORT_EN "Probe connector" +#define PROBE_X_OFFSET_EN "Probe x axis offset" +#define PROBE_Y_OFFSET_EN "Probe y axis offset" +#define PROBE_Z_OFFSET_EN "Probe z axis offset" +#define PROBE_XY_SPEED_EN "Probe xy axis speed" +#define PROBE_Z_SPEED_EN "Probe z axis speed" +#define ENABLE_EN "YES" +#define DISABLE_EN "NO" +#define Z_MIN_EN "ZMin" +#define Z_MAX_EN "ZMax" + +#define DELTA_LEVEL_CONF_TITLE_EN "Delta Machine settings" +#define DELTA_LEVEL_CONF_EN "Delta Machine Leveling" +#define DELTA_MACHINE_RADIUS_EN "Machine Radius" +#define DELTA_DIAGONAL_ROD_EN "Machine rod length" +#define DELTA_PRINT_RADIUS_EN "Print radius" +#define DELTA_HEIGHT_EN "Print height" +#define SMOOTH_ROD_OFFSET_EN "Slider offset" +#define EFFECTOR_OFFSET_EN "Effector offset" +#define CALIBRATION_RADIUS_EN "Leveling radius" + +#define XYZ_LEVEL_CONF_TITLE_EN "Cartesian Machine Settings" +#define PROBE_REACH_MAX_LEFT_EN "Probe reaches leftmost position" +#define PROBE_REACH_MAX_RIGHT_EN "Probe reaches rightmost position" +#define PROBE_REACH_MAX_FRONT_EN "Probe reaches front position" +#define PROBE_REACH_MAX_BACK_EN "Probe reaches final position" + +#define TEMPERATURE_CONF_TITLE_EN "Machine Settings>Temperature settings" +#define NOZZLE_CONF_EN "Nozzle settings" +#define HOTBED_CONF_EN "Hotbed settings" +#define PREHEAT_TEMPER_EN "Preset temperature" + +#define NOZZLE_CONF_TITLE_EN "Machine Settings>Nozzle settings" +#define NOZZLECNT_EN "Number of nozzles" +#define NOZZLE_TYPE_EN "E0 Temperature type" +#define NOZZLE_ADJUST_TYPE_EN "PID thermostat" +#define NOZZLE_MIN_TEMPERATURE_EN "lowest temperature" +#define NOZZLE_MAX_TEMPERATURE_EN "Maximum temperature" +#define EXTRUD_MIN_TEMPER_EN "Minimum extrusion temperature" + +#define HOTBED_CONF_TITLE_EN "Machine Settings>Hotbed settings" +#define HOTBED_ADJUST_EN "PID thermostat" +#define HOTBED_MIN_TEMPERATURE_EN "lowest temperature" +#define HOTBED_MAX_TEMPERATURE_EN "Maximum temperature" + +#define MOTOR_CONF_TITLE_EN "Machine Settings>Motor settings" +#define MAXFEEDRATE_CONF_EN "Maximum speed settings" +#define ACCELERATION_CONF_EN "Acceleration settings" +#define JERKCONF_EN "Jerk settings" +#define STEPSCONF_EN "Steps settings" +#define MOTORDIRCONF_EN "Motor direction settings" +#define HOMEFEEDRATECONF_EN "Home speed setting" + +#define MAXFEEDRATE_CONF_TITLE_EN "Machine Settings>Maximum speed" +#define X_MAXFEEDRATE_EN "X axis maximum speed" +#define Y_MAXFEEDRATE_EN "Y axis maximum speed" +#define Z_MAXFEEDRATE_EN "Z axis maximum speed" +#define E0_MAXFEEDRATE_EN "E0 axis maximum speed" +#define E1_MAXFEEDRATE_EN "E1 axis maximum speed" + +#define ACCELERATION_CONF_TITLE_EN "Machine Settings>Acceleration" +#define PRINT_ACCELERATION_EN "Print acceleration" +#define RETRACT_ACCELERATION_EN "Retraction acceleration" +#define TRAVEL_ACCELERATION_EN "Travel acceleration" +#define X_ACCELERATION_EN "X-axis acceleration" +#define Y_ACCELERATION_EN "Y-axis acceleration" +#define Z_ACCELERATION_EN "Z-axis acceleration" +#define E0_ACCELERATION_EN "E0-axis acceleration" +#define E1_ACCELERATION_EN "E1-axis acceleration" + +#define JERK_CONF_TITLE_EN "Machine Settings>Jerk speed" +#define X_JERK_EN "X-axis jerk speed" +#define Y_JERK_EN "Y-axis jerk speed" +#define Z_JERK_EN "J-axis jerk speed" +#define E_JERK_EN "E-axis jerk speed" + +#define STEPS_CONF_TITLE_EN "Machine Settings>Steps settings" +#define X_STEPS_EN "X-axis steps" +#define Y_STEPS_EN "Y-axis stepS" +#define Z_STEPS_EN "Z-axis stepS" +#define E0_STEPS_EN "E0-axis steps" +#define E1_STEPS_EN "E1-axis steps" + +#define MOTORDIR_CONF_TITLE_EN "Machine Settings>Motor direction" +#define X_MOTORDIR_EN "X-axis motor direction invert" +#define Y_MOTORDIR_EN "Y-axis motor direction invert" +#define Z_MOTORDIR_EN "Z-axis motor direction invert" +#define E0_MOTORDIR_EN "E0-axis motor direction invert" +#define E1_MOTORDIR_EN "E1-axis motor direction invert" +#define INVERT_P_EN "YES" +#define INVERT_N_EN "NO" + +#define HOMEFEEDRATE_CONF_TITLE_EN "Machine Settings>Home speed" +#define X_HOMESPEED_EN "XY-axis Home speed" +#define Y_HOMESPEED_EN "Y-axis Home speed" +#define Z_HOMESPEED_EN "Z-axis Home speed" + +#define ADVANCED_CONF_TITLE_EN "Machine Settings>Advance" +#define PWROFF_DECTION_EN "power off dection module" +#define PWROFF_AFTER_PRINT_EN "Auto Shutdown after print" +#define HAVE_UPS_EN "Has UPS power supply" +#define Z2_AND_Z2ENDSTOP_CONF_EN "Z2 Settings" +#define ENABLE_PINS_CONF_EN "Enable pins level settings" + +#define Z2_AND_Z2ENDSTOP_CONF_TITLE_EN "Z2 Settings" +#define Z2_ENABLE_EN "Z2 Enable" +#define Z2_ENDSTOP_EN "Z2_EndStop Enable" +#define Z2_PORT_EN "Z2 Connector" + +#define ENABLE_PINS_CONF_TITLE_EN "ENABLE_PINS_LEVEL" +#define X_ENABLE_PINS_INVERT_EN "X_ENABLE_PIN_INVERT" +#define Y_ENABLE_PINS_INVERT_EN "Y_ENABLE_PIN_INVERT" +#define Z_ENABLE_PINS_INVERT_EN "Z_ENABLE_PIN_INVERT" +#define E_ENABLE_PINS_INVERT_EN "E_ENABLE_PIN_INVERT" + +#define TOOL_TEXT_EN "Tool" +#define PREHEAT_TEXT_EN "Preheat" +#define MOVE_TEXT_EN "Move" +#define HOME_TEXT_EN "Home" +#define PRINT_TEXT_EN "Printing" +#define EXTRUDE_TEXT_EN "Extrusion" +#define LEVELING_TEXT_EN "Leveling" +#define AUTO_LEVELING_TEXT_EN "AutoLevel" +#define SET_TEXT_EN "Settings" +#define MORE_TEXT_EN "More" + +#define ADD_TEXT_EN "Add" +#define DEC_TEXT_EN "Dec" +#define EXTRUDER_1_TEXT_EN "Extrusion1" +#define EXTRUDER_2_TEXT_EN "Extrusion2" +#define HEATBED_TEXT_EN "HeatBed" +#define TEXT_1C_EN "1℃" +#define TEXT_5C_EN "5℃" +#define TEXT_10C_EN "10℃" +#define CLOSE_TEXT_EN "Close" + +#define BACK_TEXT_EN "Back" + +#define TOOL_PREHEAT_EN "Preheat" +#define TOOL_EXTRUDE_EN "Extrusion" +#define TOOL_MOVE_EN "Move" +#define TOOL_HOME_EN "Home" +#define TOOL_LEVELING_EN "Leveling" +#define TOOL_AUTO_LEVELING_EN "AutoLevel" +#define TOOL_FILAMENT_EN "Filament" +#define TOOL_MORE_EN "More" + +#define AXIS_X_ADD_TEXT_EN "X+" +#define AXIS_X_DEC_TEXT_EN "X-" +#define AXIS_Y_ADD_TEXT_EN "Y+" +#define AXIS_Y_DEC_TEXT_EN "Y-" +#define AXIS_Z_ADD_TEXT_EN "Z+" +#define AXIS_Z_DEC_TEXT_EN "Z-" +#define TEXT_01MM_EN "0.1mm" +#define TEXT_1MM_EN "1mm" +#define TEXT_10MM_EN "10mm" + +#define HOME_X_TEXT_EN "X" +#define HOME_Y_TEXT_EN "Y" +#define HOME_Z_TEXT_EN "Z" +#define HOME_ALL_TEXT_EN "Home" +#define HOME_STOPMOVE_EN "Quickstop" + +#define PAGE_UP_TEXT_EN "Page up" +#define PAGE_DOWN_TEXT_EN "Page down" + +#define EXTRUDER_IN_TEXT_EN "In" +#define EXTRUDER_OUT_TEXT_EN "Out" +#define EXTRUDE_1MM_TEXT_EN "1mm" +#define EXTRUDE_5MM_TEXT_EN "5mm" +#define EXTRUDE_10MM_TEXT_EN "10mm" +#define EXTRUDE_LOW_SPEED_TEXT_EN "Low" +#define EXTRUDE_MEDIUM_SPEED_TEXT_EN "Normal" +#define EXTRUDE_HIGH_SPEED_TEXT_EN "High" + +#define LEVELING_POINT1_TEXT_EN "Point1" +#define LEVELING_POINT2_TEXT_EN "Point2" +#define LEVELING_POINT3_TEXT_EN "Point3" +#define LEVELING_POINT4_TEXT_EN "Point4" +#define LEVELING_POINT5_TEXT_EN "Point5" + +#define FILESYS_TEXT_EN "FileSys" +#define WIFI_TEXT_EN "WiFi" +#define FAN_TEXT_EN "Fan" +#define ABOUT_TEXT_EN "About" +#define BREAK_POINT_TEXT_EN "Continue" +#define FILAMENT_TEXT_EN "Filament" +#define LANGUAGE_TEXT_EN "Language" +#define MOTOR_OFF_TEXT_EN "Motor-off" +#define MOTOR_OFF_XY_TEXT_EN "Off-XY" +#define SHUTDOWN_TEXT_EN "Shutdown" + +#define U_DISK_TEXT_EN "USB" +#define SD_CARD_TEXT_EN "SD" +#define WIFI_NAME_TEXT_EN "WiFi: " +#define WIFI_KEY_TEXT_EN "Key: " +#define WIFI_IP_TEXT_EN "IP: " +#define WIFI_AP_TEXT_EN "State: AP" +#define WIFI_STA_TEXT_EN "State: STA" +#define WIFI_CONNECTED_TEXT_EN "Connected" +#define WIFI_DISCONNECTED_TEXT_EN "Disconnected" +#define WIFI_EXCEPTION_TEXT_EN "Exception" +#define WIFI_RECONNECT_TEXT_EN "Reconnect" +#define CLOUD_TEXT_EN "Cloud" +#define CLOUD_BIND_EN "Bind" +#define CLOUD_UNBIND_EN "Unbind" +#define CLOUD_UNBINDING_EN "Unbinding" +#define CLOUD_DISCONNECTED_EN "Disconnected" +#define CLOUD_UNBINDED_EN "Unbinded" +#define CLOUD_BINDED_EN "Binded" +#define CLOUD_DISABLE_EN "Disable" + +#define FAN_ADD_TEXT_EN "Add" +#define FAN_DEC_TEXT_EN "Dec" +#define FAN_OPEN_TEXT_EN "100%" +#define FAN_HALF_TEXT_EN "50%" +#define FAN_CLOSE_TEXT_EN "Close" +#define FAN_TIPS1_TEXT_EN "FAN" +#define FAN_TIPS2_TEXT_EN "FAN\nClose" + +#define FILAMENT_IN_TEXT_EN "Load" +#define FILAMENT_OUT_TEXT_EN "Unload" +#define FILAMENT_EXT0_TEXT_EN "Extrusion1" +#define FILAMENT_EXT1_TEXT_EN "Extrusion2" +#define FILAMENT_HEAT_TEXT_EN "Preheat" +#define FILAMENT_STOP_TEXT_EN "Stop" +//#define FILAMENT_CHANGE_TEXT_EN "Filament replace" +#define FILAMENT_TIPS2_TEXT_EN "T:" +#define FILAMENT_TIPS3_TEXT_EN "Loading..." +#define FILAMENT_TIPS4_TEXT_EN "Unloading..." +#define FILAMENT_TIPS5_TEXT_EN "Temp is too low to go,please heat" +#define FILAMENT_TIPS6_TEXT_EN "Completed" + +#if 0 + #define FILAMENT_REPLAYS_IDLE_TEXT_EN "Please click or \nto replace filament!" + #define FILAMENT_CHANGE_TEXT_EN "Please click or ,\nAfter pinter pause." + #define FILAMENT_DIALOG_LOAD_HEAT_TIPS_EN "Heating up the nozzle,please wait..." + #define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_EN "Heating up the nozzle,please wait..." + #define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_EN "Heat completed,please load filament to extruder,and click for start loading." + #define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_EN "Please load filament to extruder,and click for start loading." + #define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_EN "Heat completed,please click for start unloading.!" + #define FILAMENT_DIALOG_LOADING_TIPS_EN "Is loading ,please wait!" + #define FILAMENT_DIALOG_UNLOADING_TIPS_EN "Is unloading,please wait!" + #define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_EN "Load filament completed,click for return!" + #define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_EN "Unload filament completed,click for return!" +#endif + + +#define FILAMENT_CHANGE_TEXT_EN "Please click \nor ,After \npinter pause." +#define FILAMENT_DIALOG_LOAD_HEAT_TIPS_EN "Heating up the nozzle,\nplease wait..." +#define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_EN "Heating up the nozzle,\nplease wait..." +#define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_EN "Heat completed,please load filament \nto extruder,and click \nfor start loading." +#define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_EN "Please load filament to extruder,\nand click for start loading." +#define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_EN "Heat completed,please \nclick for start unloading.!" +#define FILAMENT_DIALOG_LOADING_TIPS_EN "Is loading ,please wait!" +#define FILAMENT_DIALOG_UNLOADING_TIPS_EN "Is unloading,please wait!" +#define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_EN "Load filament completed,\nclick for return!" +#define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_EN "Unload filament completed,\nclick for return!" + + +#define PRE_HEAT_EXT_TEXT_EN "E" +#define PRE_HEAT_BED_TEXT_EN "Bed" + +#define FILE_LOADING_EN "Loading......" +#if 0 + #define NO_FILE_AND_CHECK_EN "No files found!Please insert SD card or U disk!" +#else + #define NO_FILE_AND_CHECK_EN " No files found!\n Check the file system configuration!" +#endif + +#define NO_FILE_EN "No files found!" + +#define EXTRUDER_TEMP_TEXT_EN "Temper" +#define EXTRUDER_E_LENGTH1_TEXT_EN "Extrusion1" +#define EXTRUDER_E_LENGTH2_TEXT_EN "Extrusion2" +#define EXTRUDER_E_LENGTH3_TEXT_EN "Extrusion3" + +#define ABOUT_TYPE_TEXT_EN "Type: " +#define ABOUT_VERSION_TEXT_EN "Firmware: " +#define ABOUT_WIFI_TEXT_EN "WiFi: " + +#define PRINTING_OPERATION_EN "Option" +#define PRINTING_PAUSE_EN "Pause" +#define PRINTING_TEMP_EN "Temp." +#define PRINTING_CHANGESPEED_EN "Speed" +#define PRINTING_RESUME_EN "Resume" +#define PRINTING_STOP_EN "Stop" +#define PRINTING_MORE_EN "More" +#define PRINTING_EXTRUDER_EN "Extrusion" +#define PRINTING_MOVE_EN "Move" + +#define EXTRUDER_SPEED_EN "Extrusion" +#define MOVE_SPEED_EN "Move" +#define EXTRUDER_SPEED_STATE_EN "Extrude Speed" +#define MOVE_SPEED_STATE_EN "Move Speed" +#define STEP_1PERCENT_EN "1%" +#define STEP_5PERCENT_EN "5%" +#define STEP_10PERCENT_EN "10%" + +#define ZOFFSET_EN "Z Offset" +#define ZOFFSET_INC_EN "Add" +#define ZOFFSET_DEC_EN "Dec" + +#define TITLE_READYPRINT_EN "ReadyPrint" +#define TITLE_PREHEAT_EN "Preheat" +#define TITLE_MOVE_EN "Move" +#define TITLE_HOME_EN "Home" +#define TITLE_EXTRUDE_EN "Extrusion" +#define TITLE_LEVELING_EN "Leveling" +#define TITLE_SET_EN "Settings" +#define TITLE_MORE_EN "More" +#define TITLE_CHOOSEFILE_EN "ChooseFile" +#define TITLE_PRINTING_EN "Printing" +#define TITLE_OPERATION_EN "Operation" +#define TITLE_ADJUST_EN "Adjust" +#define TITLE_WIRELESS_EN "Wireless" +#define TITLE_FILAMENT_EN "Filament" +#define TITLE_ABOUT_EN "About" +#define TITLE_FAN_EN "Fan" +#define TITLE_LANGUAGE_EN "Language" +#define TITLE_PAUSE_EN "Pause" +#define TITLE_CHANGESPEED_EN "Speed" +#define TITLE_CLOUD_TEXT_EN "Cloud" +#define TITLE_DIALOG_CONFIRM_EN "Confirm" +#define TITLE_FILESYS_EN "FileSys" +#define TITLE_ZOFFSET_EN "Z Offset" + +#define AUTO_SHUTDOWN_EN "Auto" +#define MANUAL_SHUTDOWN_EN "Manual" + +#define DIALOG_CONFIRM_EN "Confirm" +#define DIALOG_CANCLE_EN "Cancel" +#define DIALOG_OK_EN "OK" +#define DIALOG_RESET_EN "Reset" +#define DIALOG_RETRY_EN "Retry" +#define DIALOG_DISABLE_EN "Disable" +#define DIALOG_PRINT_MODEL_EN "Print this model?" +#define DIALOG_CANCEL_PRINT_EN "Stop print?" +#define DIALOG_RETRY_EN "Retry" +#define DIALOG_STOP_EN "Stop" +#define DIALOG_REPRINT_FROM_BREAKPOINT_EN "Reprint from breakpoint?" +//#define DIALOG_UNBIND_PRINTER_EN "Unbind the printer?" +#define DIALOG_ERROR_TIPS1_EN "Error:no file,please check it again." +#define DIALOG_ERROR_TIPS2_EN "Error:transaction failed.please check display baudrate \nwhether as the same as mainboard!" +#define DIALOG_ERROR_TIPS3_EN "Error:file name or path is too long!" +#define DIALOG_CLOSE_MACHINE_EN "Closing machine......" +#define DIALOG_UNBIND_PRINTER_EN "Unbind the printer?" +#define DIALOG_FILAMENT_NO_PRESS_EN "Filament detection switch is not pressed" +#define DIALOG_PRINT_FINISH_EN "Done print!" +#define DIALOG_PRINT_TIME_EN "Print time: " +#define DIALOG_REPRINT_EN "Print again" +#define DIALOG_WIFI_ENABLE_TIPS_EN "The wifi module is being configured\nplease wait a moment....." + +#define HOTBED_ENABLE_EN "Enable heatbed" +#define MOTOR_EN_HIGH_LEVEL_EN "High" +#define MOTOR_EN_LOW_LEVEL_EN "Low" + +#define TEXT_WIFI_MENU_TITLE_EN "WI-FI" +#define TEXT_WIFI_SAPCE_EN "space" +#define TEXT_WIFI_LETTER_EN "abc" +#define TEXT_WIFI_DIGITAL_EN "123" +#define TEXT_WIFI_SYMBOL_EN "#+=" +#define TEXT_WIFI_PASSWORD_EN "Password" + +#define TEXT_WIFI_POINT_BOLD_EN "`" + +#define TEXT_WIFI_JOINING_EN "Joining\nNetwork..." +#define TEXT_WIFI_FAILED_JOIN_EN "Failed to\nJoin Wi-Fi" +#define TEXT_WIFI_WIFI_CONECTED_EN "Wi-Fi\nConnected" + +#define TEXT_BUTTON_DISCONECTED_EN "Disconnect" +#define TEXT_WIFI_FORGET_EN "Forget Network" +#define TEXT_DISCONECTED_EN "Wi-Fi Connected" + +//wifi-list +#define MAIN_BUILT_EN "Build" +#define MAIN_FILAMENT_EN "Filament" +#define MAIN_SETUP_EN "Setup" +#define MAIN_ABOUT_EN "About" +#define MAIN_MENU_EN "Menu" +#define FILE_MENU_BUILD_EN "Build" +#define FILE_MENU_MENU_EN " < Menu" + +//about +#define ABOUT_TITLE_EN "About" +#define ABOUT_BUILT_MACHINES_EN "Built Machines" +#define ABOUT_SPARK_EN "Spark" +#define ABOUT_VERSION_EN "Version 1.1.0" +#define ABOUT_SERIAL_NUMBER_EN "Serial Number:" +#define ABOUT_S_NUMBER_EN "DCPLX02KFC6P" + +//set +#define SETUP_TITLE_EN "Setup" +#define SETUP_WIFI_EN "Wi-Fi" +#define SETUP_MANUAL_IP_EN "Manual IP" +#define SETUP_WIFI_NOT_CONNECTED_EN "Not Connected" +#define SETUP_WIFI_NETWORK_EN "WiFi_Network" + +//build +#define BUILD_TITLE_EN "Build" +#define BUILD_SD_CARD_EN "SD Card" +#define BUILD_USB_DRIVE_EN "USB Drive" + +//SD card +#define SD_CARD_TITLE_EN "SD Card" +#define SD_CARD_BACK_EN "< Back" +//USB Drive +#define USB_DRIVE_TITLE_EN "USB Drive" +#define USB_DRIVE_BACK_EN "< Back" +#define FILE_PAGES_EN "%d/%d" +#define FILE_NEXT_PAGE_EN "Next Page" + +//BUILD PLATE +#define PLATE_TITLE_EN "Build Plate" +#define PLATE_BACK_EN "< Back" +#define PLATE_CONFIRM_EN "Confirm >" +#define PLATE_TIPS_EN "Confirm that there is a Clear\nBuild Plate installed in the\nmachine." + +//build model +#define MODEL_TITLE_EN "Build Model" +#define MODEL_START_BUILD_EN "Start Build" +#define MODEL_BACK_EN "< Back" + +//building +#define BUILDING_TITLE_EN "Building" +#define BUILDING_MENU_EN "Build Menu" +#define BUILDING_COMPLETED "Build\nComplete" + +//building menu +#define BUILDING_MENU_TITLE_EN "Build Menu" +#define BUILDING_MENU_SETTINGS_EN "Build Settings" +#define BUILDING_MENU_PAUSE_EN "Pause Build" +#define BUILDING_MENU_CANCEL_EN "Cancel Build" +#define BUILDING_MENU_BACK_EN "< Back" + +//build settings +#define SETTINGS_TITLE_EN "Build Settings" +#define SETTINGS_NOZZLE_TEMPER_EN "Nozzle Temp:" +#define SETTINGS_NOZZLE_VALUE_EN "%d" +#define SETTINGS_BED_TEMPER_EN "Bed Temp:" +#define SETTINGS_BED_VALUE_EN "%d" +#define SETTINGS_BUILD_SPEED_EN "Build Speed:" +#define SETTINGS_SPEED_VALUE_EN "Standard" +#define SETTINGS_BACK_EN "< Back" + +//build paused +#define PAUSED_TITLE_EN "Build Paused" +#define PAUSED_RESUME_EN "Resume Build" +#define PAUSED_CANCEL_EN "Cancel Build" +#define PAUSED_BACK_EN "< Back" + +//build cancel +#define CANCEL_TITLE_EN "Cancel Build" +#define CANCEL_BUILD_EN "Cancel Build" +#define CANCEL_TIPS_EN "Are you sure you want to\ncancel this build? The model\nwill be deleted from this\nmachine. It will need to be\nresent from your computer\nbefore it can be built in the\nfuture." +#define CANCEL_BACK_EN "< Back" +#define CANCEL_BUILD_DISPLAY_EN "Build\nCanceled" +#define CANCEL_OVER_PLATE_TIPS_EN "Confirm that the Build Plate\nhas been removed from the\nmachine." + +//filament model enter +#define FILAMENT_MODEL_ENTER_TITLE_EN "Model-PLA" +#define FILAMENT_MODEL_ENTER_BACK_EN "< Back" +#define FILAMENT_MODEL_ENTER_BEGIN_EN "Begin >" +#define FILAMENT_MODEL_ENTER_TIPS_EN "The Model Filament spool\ncompartment is located on\nthe right side of the machine." + +//filament model PLA +#define FILAMENT_MODEL_PLA_TITLE_EN "Model-PLA" +#define FILAMENT_PLA_LOAD_TITLE_EN "Load Filament" +#define FILAMENT_PLA_UNLOAD_TITLE_EN "Unload Filament" +#define FILAMENT_MODEL_PLA_LOAD_EN "Load Filament" +#define FILAMENT_MODEL_PLA_UNLOAD_EN "Unload Filament" +//filament support enter +#define FILAMENT_SUPPORT_ENTER_TITLE_EN "Support-PVA" +#define FILAMENT_SUPPORT_ENTER_BACK_EN "< Back" +#define FILAMENT_SUPPORT_ENTER_BEGIN_EN "Begin >" +#define FILAMENT_SUPPORT_ENTER_TIPS_EN "The Support Filament spool\ncompartment is located on\nthe left side of the machine." +//filament heating +#define FILAMENT_HEATING_LOAD_TITLE_EN "Load Filament" +#define FILAMENT_HEATING_UNLOAD_TITLE_EN "Unload Filament" +#define FILAMENT_HEATING_CANCEL_EN "< Cancel" +#define FILAMENT_HEATING_MATERIAL_EN "Material:" +#define FILAMENT_HEATING_PLA_EN "Model-PLA" +#define FILAMENT_HEATING_TIPS_EN "Print head is heating..." +//rotate left +#define ROTATE_LEFT_LOAD_TITLE_EN "Load Filament" +#define ROTATE_LEFT_UNLOAD_TITLE_EN "Unload Filament" +#define ROTATE_LEFT_CANCEL_EN "< Cancel" +#define ROTATE_LEFT_MATERIAL_EN "Material:" +#define ROTATE_LEFT_PLA_EN "Model-PLA" +#define ROTATE_LEFT_NEXT_EN "Next >" +#define ROTATE_LEFT_TIPS_EN "Rotate extruder selection\ndial to the left." + +//hang spool +#define HANG_SPOOL_TITLE_EN "Load Filament" +#define HANG_SPOOL_PREVIOUS_EN "< Previous" +#define HANG_SPOOL_MATERIAL_EN "Material:" +#define HANG_SPOOL_PLA_EN "Model-PLA" +#define HANG_SPOOL_NEXT_EN "Next >" +#define HANG_SPOOL_TIPS_EN "Hang the spool in the spool\ncompartment as shown." + +//feed filament +#define FEED_FILAMENT_TITLE_EN "Load Filament" +#define FEED_FILAMENT_PREVIOUS_EN "< Previous" +#define FEED_FILAMENT_MATERIAL_EN "Material:" +#define FEED_FILAMENT_PLA_EN "Model-PLA" +#define FEED_FILAMENT_NEXT_EN "Next >" +#define FEED_FILAMENT_TIPS_EN "Feed filament into extruder\nup beyond the gears." + +//feed filament +#define ROTATE_UP_TITLE_EN "Load Filament" +#define ROTATE_UP_PREVIOUS_EN "< Previous" +#define ROTATE_UP_MATERIAL_EN "Material:" +#define ROTATE_UP_PLA_EN "Model-PLA" +#define ROTATE_UP_NEXT_EN "Next >" +#define ROTATE_UP_TIPS_EN "Rotate extruder selection\ndial up." + +//filament begin +#define FEED_BEGIN_TITLE_EN "Load Filament" +#define FEED_BEGIN_MATERIAL_EN "Material:" +#define FEED_BEGIN_PLA_EN "Model-PLA" +#define FEED_BEGIN_NEXT_EN "Next >" +#define FEED_BEGIN_TIPS_EN "Press Next when filament\nbegins to extrude." + +//filament finish +#define FEED_FINISH_TITLE_EN "Load Filament" +#define FEED_FINISH_MATERIAL_EN "Material:" +#define FEED_FINISH_PLA_EN "Model-PLA" +#define FEED_FINISH_NEXT_EN "Finish >" +#define FEED_FINISH_TIPS_EN "Remove filament from the\nnozzle and discard." +//fiament remove +#define REMOVE_SPOOL_TITLE_EN "Unload Filament" +#define REMOVE_SPOOL_PREVIOUS_EN "< Previous" +#define REMOVE_SPOOL_FINISH_EN "Finish >" +#define REMOVE_SPOOL_MATERIAL_EN "Material:" +#define REMOVE_SPOOL_PLA_EN "Model-PLA" +#define REMOVE_SPOOL_TIPS_EN "Remove the spool and pull\nfilament out of the machine." + +#define FILAMENT_SUPPORT_PVA_EN "Support-PVA" +#define LOAD_FINISH_EN "Load\nFilament\nComplete" +#define UNLOAD_FINISH_EN "Unload\nFilament\nComplete" + +//manual ip +#define MANUAL_IP_TITLE_EN "Manual IP" +#define MANUAL_IP_CANCEL_EN "< Cancel" +#define MANUAL_IP_APPLY_EN "Join >" +#define MANUAL_IP_ADDRESS_EN "IP Address" +#define MANUAL_IP_MASK_EN "Subnet Mask" +#define MANUAL_IP_GATEWAY_EN "Default Gateway" +#define MANUAL_IP_SERVER_EN "Name Server" +#define MANUAL_IP_INIT_DATA_EN "0.0.0.0" +#define MANUAL_TEXT_POINT_EN "." +#define MANUAL_TEXT_ENTER_EN "enter" + +//Wifi name +//#define TEXT_WIFI_MENU_TITLE_EN "WI-FI" +//#define TEXT_WIFI_SAPCE_EN "space" +//#define TEXT_WIFI_LETTER_EN "abc" +//#define TEXT_WIFI_DIGITAL_EN "123" +//#define TEXT_WIFI_SYMBOL_EN "#+=" +//#define TEXT_WIFI_PASSWORD_EN "Password" + +//#define TEXT_WIFI_POINT_BOLD_EN "`" + +//#define TEXT_WIFI_JOINING_EN "Joining\nNetwork..." +//#define TEXT_WIFI_FAILED_JOIN_EN "Failed to\nJoin Wi-Fi" +//#define TEXT_WIFI_WIFI_CONECTED_EN "Wi-Fi\nConnected" + +//#define TEXT_BUTTON_DISCONECTED_EN "Disconnect" +//#define TEXT_WIFI_FORGET_EN "Forget Network" +//#define TEXT_DISCONECTED_EN "Wi-Fi Connected" + +#define TEXT_FORGET_TIPS_TITLE_EN "Forget Network" +#define TEXT_FORGET_NETWORK_TIPS1_EN "Are you sure you want to\nforget this network?" +#define TEXT_FORGET_NETWORK_TIPS2_EN "This machine will no longer\njoin this Wi-Fi Network." + +#define TEXT_IPADDRESS_EN "IP Address: " + +#define TEXT_BUILD_FROM_CURA_CANCEL_TIPS1_EN "Are you sure you want to\ncancel this build?" +#define TEXT_BUILD_FROM_CURA_CANCEL_TIPS2_EN "The model will be deleted\nfrom this machine.It will\nneed to be resent from your\ncomputer before it can be\nbuilt in the future." + +#define DIALOG_CONFIRM_EN2 "Confirm" + +#define HEATING_TITLE_EN "Heating" +#define LEVELING_TITLE_EN "Leveling" + +#define ABOUT_SPARK_ADD_EN "Spark+" + +#define TEXT_RECEIVING_DATA_EN "Receiving Data" + +#define TEXT_BABY_STEP_EN "Babystep" + +#define PRINTING_OTHER_LANGUGE "Printing" +#define PRINTING_OPERATION_OTHER_LANGUGE "Operation" +#define PRINTING_PAUSE_OTHER_LANGUGE "Pause" + +#define MESSEGE_PAUSING_EN "Parking..." +#define MESSEGE_CHANGING_EN "Wait for filament change to start" +#define MESSEGE_UNLOAD_EN "Wait for filament unload" +#define MESSEGE_WAITING_EN "Press Button to resume print" +#define MESSEGE_INSERT_EN "Insert filament and press button to continue" +#define MESSEGE_LOAD_EN "Wait for filament load" +#define MESSEGE_PURGE_EN "Wait for filament purge" +#define MESSEGE_RESUME_EN "Wait for print to resume..." +#define MESSEGE_HEAT_EN "Press button to heat nozzle" +#define MESSEGE_HEATING_EN "Nozzle heating Please wait..." +#define MESSEGE_OPTION_EN "Purge more or continue print?" +#define MESSEGE_PURGE_MORE_EN "Purge" +#define MESSEGE_CONTINUE_PRINT_EN "Print" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h new file mode 100644 index 0000000..c1dd8eb --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h @@ -0,0 +1,276 @@ +/** + * 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 + +//*************法文****************************// +#define TOOL_TEXT_FR "prêt" +#define PREHEAT_TEXT_FR "Préchauffe" +#define MOVE_TEXT_FR "Déplace" +#define HOME_TEXT_FR "Acceuil" +#define PRINT_TEXT_FR "Impression" +#define EXTRUDE_TEXT_FR "Extruder" +#define LEVELING_TEXT_FR "Leveling" +#define AUTO_LEVELING_TEXT_FR "AutoLevel" +#define SET_TEXT_FR "Config" +#define MORE_TEXT_FR "Plus" + +#define ADD_TEXT_FR "Ajouter" +#define DEC_TEXT_FR "Réduire" +#define EXTRUDER_1_TEXT_FR "Extr1" +#define EXTRUDER_2_TEXT_FR "Extr2" +#define HEATBED_TEXT_FR "Hotlit" +#define TEXT_1C_FR "1℃" +#define TEXT_5C_FR "5℃" +#define TEXT_10C_FR "10℃" +#define CLOSE_TEXT_FR "Off" + +#define BACK_TEXT_FR "Arrière" + +#define TOOL_PREHEAT_FR "Préchauffe" +#define TOOL_EXTRUDE_FR "Extruder" +#define TOOL_MOVE_FR "Déplace" +#define TOOL_HOME_FR "Acceuil" +#define TOOL_LEVELING_FR "Leveling" +#define TOOL_AUTO_LEVELING_FR "AutoLevel" +#define TOOL_FILAMENT_FR "Filament" +#define TOOL_MORE_FR "Plus" + +#define AXIS_X_ADD_TEXT_FR "X+" +#define AXIS_X_DEC_TEXT_FR "X-" +#define AXIS_Y_ADD_TEXT_FR "Y+" +#define AXIS_Y_DEC_TEXT_FR "Y-" +#define AXIS_Z_ADD_TEXT_FR "Z+" +#define AXIS_Z_DEC_TEXT_FR "Z-" +#define TEXT_01MM_FR "0.1mm" +#define TEXT_1MM_FR "1mm" +#define TEXT_10MM_FR "10mm" + +#define HOME_X_TEXT_FR "X" +#define HOME_Y_TEXT_FR "Y" +#define HOME_Z_TEXT_FR "Z" +#define HOME_ALL_TEXT_FR "ALL" +#define HOME_STOPMOVE_FR "Quickstop" + +#define PAGE_UP_TEXT_FR "En haut" +#define PAGE_DOWN_TEXT_FR "En bas" + +#define EXTRUDER_IN_TEXT_FR "Insérer" +#define EXTRUDER_OUT_TEXT_FR "éjecter" +#define EXTRUDE_1MM_TEXT_FR "1mm" +#define EXTRUDE_5MM_TEXT_FR "5mm" +#define EXTRUDE_10MM_TEXT_FR "10mm" +#define EXTRUDE_LOW_SPEED_TEXT_FR "Lente" +#define EXTRUDE_MEDIUM_SPEED_TEXT_FR "Moyen" +#define EXTRUDE_HIGH_SPEED_TEXT_FR "Rapide" + +#define LEVELING_POINT1_TEXT_FR "Premier" +#define LEVELING_POINT2_TEXT_FR "Seconde" +#define LEVELING_POINT3_TEXT_FR "Troisième" +#define LEVELING_POINT4_TEXT_FR "Quatrième" +#define LEVELING_POINT5_TEXT_FR "Cinquième" + +#define FILESYS_TEXT_FR "Fichier" +#define WIFI_TEXT_FR "WiFi" +#define FAN_TEXT_FR "Fan" +#define ABOUT_TEXT_FR "A propos" +#define BREAK_POINT_TEXT_FR "Continuer" +#define FILAMENT_TEXT_FR "Remplacer" +#define LANGUAGE_TEXT_FR "Langue" +#define MOTOR_OFF_TEXT_FR "M-hors" +#define MOTOR_OFF_XY_TEXT_FR "M-hors-XY" +#define SHUTDOWN_TEXT_FR "Eteindre" + +#define U_DISK_TEXT_FR "Clé usb" +#define SD_CARD_TEXT_FR "Carte SD" +#define WIFI_NAME_TEXT_FR "WiFi: " +#define WIFI_KEY_TEXT_FR "Key: " +#define WIFI_IP_TEXT_FR "IP: " +#define WIFI_AP_TEXT_FR "Etat: AP" +#define WIFI_STA_TEXT_FR "Etat: STA" +#define WIFI_CONNECTED_TEXT_FR "Connecté" +#define WIFI_DISCONNECTED_TEXT_FR "Déconnecté" +#define WIFI_EXCEPTION_TEXT_FR "Exception" +#define WIFI_RECONNECT_TEXT_FR "Reconnect" +#define CLOUD_TEXT_FR "Cloud" +#define CLOUD_BIND_FR "Lié" +#define CLOUD_UNBIND_FR "Délier" +#define CLOUD_UNBINDING_FR "Délier" +#define CLOUD_DISCONNECTED_FR "Déconnecté" +#define CLOUD_UNBINDED_FR "Délier" +#define CLOUD_BINDED_FR "Lié" +#define CLOUD_DISABLE_FR "Désactiver" + +#define FAN_ADD_TEXT_FR "Ajouter" +#define FAN_DEC_TEXT_FR "Réduire" +#define FAN_OPEN_TEXT_FR "100%" +#define FAN_HALF_TEXT_FR "50%" +#define FAN_CLOSE_TEXT_FR "0%" +#define FAN_TIPS1_TEXT_FR "ventilateur" +#define FAN_TIPS2_TEXT_FR "ventilateur\n0" + +#define FILAMENT_IN_TEXT_FR "Insérer" +#define FILAMENT_OUT_TEXT_FR "éjecter" +#define FILAMENT_EXT0_TEXT_FR "Extr1" +#define FILAMENT_EXT1_TEXT_FR "Extr2" +#define FILAMENT_HEAT_TEXT_FR "Preheat" +#define FILAMENT_STOP_TEXT_FR "Arrêter" +//#define FILAMENT_CHANGE_TEXT_FR "Filament remplacer" +#define FILAMENT_TIPS2_TEXT_FR "T:" +#define FILAMENT_TIPS3_TEXT_FR "Insérer le filament..." +#define FILAMENT_TIPS4_TEXT_FR "éjecter le filament..." +#define FILAMENT_TIPS5_TEXT_FR "Température trop basse pour démarrer, chauffez svp" +#define FILAMENT_TIPS6_TEXT_FR "Terminé" + +#if 0 + #define FILAMENT_REPLAYS_IDLE_TEXT_FR "Please click or <éjecter> \nto replace filament!" + #define FILAMENT_CHANGE_TEXT_FR "Please click or <éjecter>,\nAfter pinter pause." + #define FILAMENT_DIALOG_LOAD_HEAT_TIPS_FR "Heating up the nozzle,please wait..." + #define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_FR "Heating up the nozzle,please wait..." + #define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_FR "Heat completed,please load filament to extruder,and click for start loading." + #define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_FR "Please load filament to extruder,and click for start loading." + #define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_FR "Heat completed,please click for start unloading.!" + #define FILAMENT_DIALOG_LOADING_TIPS_FR "Is loading ,please wait!" + #define FILAMENT_DIALOG_UNLOADING_TIPS_FR "Is unloading,please wait!" + #define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_FR "Load filament completed,click for return!" + #define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_FR "Unload filament completed,click for return!" +#endif +#define FILAMENT_CHANGE_TEXT_FR "Please click \nor ,After \npinter pause." +#define FILAMENT_DIALOG_LOAD_HEAT_TIPS_FR "Heating up the nozzle,\nplease wait..." +#define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_FR "Heating up the nozzle,\nplease wait..." +#define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_FR "Heat completed,please load filament \nto extruder,and click \nfor start loading." +#define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_FR "Please load filament to extruder,\nand click for start loading." +#define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_FR "Heat completed,please \nclick for start unloading.!" +#define FILAMENT_DIALOG_LOADING_TIPS_FR "Is loading ,please wait!" +#define FILAMENT_DIALOG_UNLOADING_TIPS_FR "Is unloading,please wait!" +#define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_FR "Load filament completed,\nclick for return!" +#define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_FR "Unload filament completed,\nclick for return!" + + +#define PRE_HEAT_EXT_TEXT_FR "E" +#define PRE_HEAT_BED_TEXT_FR "Bed" + +#define FILE_LOADING_FR "Chargement......" +#if 0 + #define NO_FILE_AND_CHECK_FR "Aucun fichier trouvé! Insérez une carte SD ou un disque U!" +#else + #define NO_FILE_AND_CHECK_FR "Aucun fichier,vérifiez à nouveau!" +#endif + +#define NO_FILE_FR "Pas de fichier!" + + + +#define EXTRUDER_TEMP_TEXT_FR "Temper" +#define EXTRUDER_E_LENGTH1_TEXT_FR "Extruder1" +#define EXTRUDER_E_LENGTH2_TEXT_FR "Extruder2" +#define EXTRUDER_E_LENGTH3_TEXT_FR "Extruder3" + +#define ABOUT_TYPE_TEXT_FR "Type: " +#define ABOUT_VERSION_TEXT_FR "Firmware: " +#define ABOUT_WIFI_TEXT_FR "Wifi: " + +#define PRINTING_OPERATION_FR "Option" +#define PRINTING_PAUSE_FR "Pause" +#define PRINTING_TEMP_FR "Temp." +#define PRINTING_CHANGESPEED_FR "Speed" +#define PRINTING_RESUME_FR "Reprendre" +#define PRINTING_STOP_FR "Stop" +#define PRINTING_MORE_FR "Plus" +#define PRINTING_EXTRUDER_FR "Extruder" +#define PRINTING_MOVE_FR "Déplace" + +#define EXTRUDER_SPEED_FR "Extruder" +#define MOVE_SPEED_FR "Déplace" +#define EXTRUDER_SPEED_STATE_FR "Vitesse d'extrusion" +#define MOVE_SPEED_STATE_FR "vitesse de déplacement" +#define STEP_1PERCENT_FR "1%" +#define STEP_5PERCENT_FR "5%" +#define STEP_10PERCENT_FR "10%" + +#define ZOFFSET_FR "Z Offset" +#define ZOFFSET_INC_FR "Ajouter" +#define ZOFFSET_DEC_FR "Réduire" + +#define TITLE_READYPRINT_FR "Prête" +#define TITLE_PREHEAT_FR "Préchauffe" +#define TITLE_MOVE_FR "Déplace" +#define TITLE_HOME_FR "Acceuil" +#define TITLE_EXTRUDE_FR "Extruder" +#define TITLE_LEVELING_FR "Leveling" +#define TITLE_SET_FR "Paramètres" +#define TITLE_MORE_FR "Plus" +#define TITLE_CHOOSEFILE_FR "Fichier" +#define TITLE_PRINTING_FR "Pimpression" +#define TITLE_OPERATION_FR "Option" +#define TITLE_ADJUST_FR "Réglage" +#define TITLE_WIRELESS_FR "Sans fil" +#define TITLE_FILAMENT_FR "Remplacer" +#define TITLE_ABOUT_FR "A propos" +#define TITLE_FAN_FR "Ventilateur" +#define TITLE_LANGUAGE_FR "Langue" +#define TITLE_PAUSE_FR "Pause" +#define TITLE_CHANGESPEED_FR "Speed" +#define TITLE_CLOUD_TEXT_FR "Cloud" +#define TITLE_DIALOG_CONFIRM_FR "Confirm" +#define TITLE_FILESYS_FR "FileSys" +#define TITLE_ZOFFSET_FR "Z Offset" + +#define DIALOG_CLOSE_MACHINE_FR "Closing machine......" + +#define AUTO_SHUTDOWN_FR "Auto" +#define MANUAL_SHUTDOWN_FR "Manuel" + +#define DIALOG_CONFIRM_FR "Confirmer" +#define DIALOG_CANCLE_FR "Annuler" +#define DIALOG_OK_FR "OK" +#define DIALOG_RESET_FR "Réinitialiser" +#define DIALOG_RETRY_FR "Recommencez" +#define DIALOG_DISABLE_FR "Disable" +#define DIALOG_PRINT_MODEL_FR "Imprimer le fichier?" +#define DIALOG_CANCEL_PRINT_FR "Arrêter?" + +#define DIALOG_STOP_FR "Arrêter" +#define DIALOG_REPRINT_FROM_BREAKPOINT_FR "Continuer?" +//#define DIALOG_UNBIND_PRINTER_FR "Non lié?" +#define DIALOG_ERROR_TIPS1_FR "Erreur:error:Aucun fichier, \nvérifiez à nouveau." +#define DIALOG_ERROR_TIPS2_FR "Erreur:La opération a échoué. \nVerifiez que le baudrate de l'écran et de \nla carte mère soient identique!" +#define DIALOG_ERROR_TIPS3_FR "Erreur: le nom du fichier ou le \nchemin d'accès est trop long." +#define DIALOG_UNBIND_PRINTER_FR "Unbind the printer?" +#define DIALOG_FILAMENT_NO_PRESS_FR "Filament detection switch is not pressed" +#define DIALOG_PRINT_FINISH_FR "L'impression est terminée!" +#define DIALOG_PRINT_TIME_FR "Temps d'impression: " +#define DIALOG_REPRINT_FR "Print again" +#define DIALOG_WIFI_ENABLE_TIPS_FR "The wifi module is being configured,\nplease wait a moment....." + +#define MESSEGE_PAUSING_FR "Parking..." +#define MESSEGE_CHANGING_FR "Attente filament pour démarrer" +#define MESSEGE_UNLOAD_FR "Attente retrait du filament" +#define MESSEGE_WAITING_FR "Presser bouton,pour reprendre" +#define MESSEGE_INSERT_FR "Insérer filament et app. bouton pour continuer..." +#define MESSEGE_LOAD_FR "Attente chargement filament" +#define MESSEGE_PURGE_FR "Attente Purge filament" +#define MESSEGE_RESUME_FR "Attente reprise impression" +#define MESSEGE_HEAT_FR "Presser le bouton pour chauffer..." +#define MESSEGE_HEATING_FR "Buse en chauffe Patienter SVP..." +#define MESSEGE_OPTION_FR "Purger davantage ou continuer l'impression?" +#define MESSEGE_PURGE_MORE_FR "Purge" +#define MESSEGE_CONTINUE_PRINT_FR "Impression" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h new file mode 100644 index 0000000..d43ba08 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h @@ -0,0 +1,271 @@ +/** + * 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 + +//****************意大利语***************************// +#define TOOL_TEXT_IT "Strumento" +#define PREHEAT_TEXT_IT "Prerisc" +#define MOVE_TEXT_IT "Muovi" +#define HOME_TEXT_IT "Home" +#define PRINT_TEXT_IT "Stampa" +#define EXTRUDE_TEXT_IT "Estrude" +#define LEVELING_TEXT_IT "Leveling" +#define AUTO_LEVELING_TEXT_IT "AutoLevel" +#define SET_TEXT_IT "Imposta" +#define MORE_TEXT_IT "Di più" + +#define ADD_TEXT_IT "Aumentare" +#define DEC_TEXT_IT "Ridurre" +#define EXTRUDER_1_TEXT_IT "Estrude1" +#define EXTRUDER_2_TEXT_IT "Estrude2" +#define HEATBED_TEXT_IT "Piano" +#define TEXT_1C_IT "1℃" +#define TEXT_5C_IT "5℃" +#define TEXT_10C_IT "10℃" +#define CLOSE_TEXT_IT "Spento" + +#define BACK_TEXT_IT "Indietro" + +#define TOOL_PREHEAT_IT "Prerisc" +#define TOOL_EXTRUDE_IT "Estrude" +#define TOOL_MOVE_IT "Muovi" +#define TOOL_HOME_IT "Home" +#define TOOL_LEVELING_IT "Leveling" +#define TOOL_AUTO_LEVELING_IT "Autolevel" +#define TOOL_FILAMENT_IT "Filamento" +#define TOOL_MORE_IT "Di più" + +#define AXIS_X_ADD_TEXT_IT "X+" +#define AXIS_X_DEC_TEXT_IT "X-" +#define AXIS_Y_ADD_TEXT_IT "Y+" +#define AXIS_Y_DEC_TEXT_IT "Y-" +#define AXIS_Z_ADD_TEXT_IT "Z+" +#define AXIS_Z_DEC_TEXT_IT "Z-" +#define TEXT_01MM_IT "0.1mm" +#define TEXT_1MM_IT "1mm" +#define TEXT_10MM_IT "10mm" + +#define HOME_X_TEXT_IT "X" +#define HOME_Y_TEXT_IT "Y" +#define HOME_Z_TEXT_IT "Z" +#define HOME_ALL_TEXT_IT "All" +#define HOME_STOPMOVE_IT "Quickstop" + +#define PAGE_UP_TEXT_IT "Pagina su" +#define PAGE_DOWN_TEXT_IT "Pagina giù" + +#define EXTRUDER_IN_TEXT_IT "Estru" +#define EXTRUDER_OUT_TEXT_IT "Ritra" +#define EXTRUDE_1MM_TEXT_IT "1mm" +#define EXTRUDE_5MM_TEXT_IT "5mm" +#define EXTRUDE_10MM_TEXT_IT "10mm" +#define EXTRUDE_LOW_SPEED_TEXT_IT "Bassa" +#define EXTRUDE_MEDIUM_SPEED_TEXT_IT "Media" +#define EXTRUDE_HIGH_SPEED_TEXT_IT "Alta" + +#define LEVELING_POINT1_TEXT_IT "Primo" +#define LEVELING_POINT2_TEXT_IT "Secondo" +#define LEVELING_POINT3_TEXT_IT "Terzo" +#define LEVELING_POINT4_TEXT_IT "Quarto" +#define LEVELING_POINT5_TEXT_IT "Quinto" + +#define FILESYS_TEXT_IT "FileSys" +#define WIFI_TEXT_IT "WIFI" +#define FAN_TEXT_IT "Ventola" +#define ABOUT_TEXT_IT "Circa" +#define BREAK_POINT_TEXT_IT "Continua" +#define FILAMENT_TEXT_IT "Filamento" +#define LANGUAGE_TEXT_IT "Lingua" +#define MOTOR_OFF_TEXT_IT "Motor off" +#define MOTOR_OFF_XY_TEXT_IT "Off-XY" +#define SHUTDOWN_TEXT_IT "Spento" + +#define U_DISK_TEXT_IT "USB" +#define SD_CARD_TEXT_IT "SD" +#define WIFI_NAME_TEXT_IT "WIFI: " +#define WIFI_KEY_TEXT_IT "KEY: " +#define WIFI_IP_TEXT_IT "IP: " +#define WIFI_AP_TEXT_IT "Stato: AP" +#define WIFI_STA_TEXT_IT "Stato: STA" +#define WIFI_CONNECTED_TEXT_IT "Connesso" +#define WIFI_DISCONNECTED_TEXT_IT "Disconnesso" +#define WIFI_EXCEPTION_TEXT_IT "Eccezione" +#define WIFI_RECONNECT_TEXT_IT "Reconnect" +#define CLOUD_TEXT_IT "Cloud" +#define CLOUD_BIND_IT "Legato" +#define CLOUD_UNBIND_IT "Libero" +#define CLOUD_DISCONNECTED_IT "Disconnesso" +#define CLOUD_UNBINDING_IT "Libero" +#define CLOUD_UNBINDED_IT "Sciolto" +#define CLOUD_BINDED_IT "Legato" +#define CLOUD_DISABLE_IT "Disable" + +#define FAN_ADD_TEXT_IT "Aumentare" +#define FAN_DEC_TEXT_IT "Ridurre" +#define FAN_OPEN_TEXT_IT "100%" +#define FAN_HALF_TEXT_IT "50%" +#define FAN_CLOSE_TEXT_IT "Spento" +#define FAN_TIPS1_TEXT_IT "Ventola" +#define FAN_TIPS2_TEXT_IT "Ventola\n0" + +#define FILAMENT_IN_TEXT_IT "Inser" +#define FILAMENT_OUT_TEXT_IT "Estra" +#define FILAMENT_EXT0_TEXT_IT "Estrude1" +#define FILAMENT_EXT1_TEXT_IT "Estrude2" +#define FILAMENT_HEAT_TEXT_IT "Preriscaldamento" +#define FILAMENT_STOP_TEXT_IT "Stop" +//#define FILAMENT_CHANGE_TEXT_IT "Filamento" +#define FILAMENT_TIPS2_TEXT_IT "T:" +#define FILAMENT_TIPS3_TEXT_IT "Inserimento del filamento..." +#define FILAMENT_TIPS4_TEXT_IT "Estrazione del filamento..." +#define FILAMENT_TIPS5_TEXT_IT "Temp is too low to go,please heat" +#define FILAMENT_TIPS6_TEXT_IT "Completato" + +#if 0 + #define FILAMENT_REPLAYS_IDLE_TEXT_IT "Please click or \nto replace filament!" + #define FILAMENT_CHANGE_TEXT_IT "Please click or ,\nAfter pinter pause." + #define FILAMENT_DIALOG_LOAD_HEAT_TIPS_IT "Heating up the nozzle,please wait..." + #define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_IT "Heating up the nozzle,please wait..." + #define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_IT "Heat completed,please load filament to extruder,and click for start loading." + #define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_IT "Please load filament to extruder,and click for start loading." + #define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_IT "Heat completed,please click for start unloading.!" + #define FILAMENT_DIALOG_LOADING_TIPS_IT "Is loading ,please wait!" + #define FILAMENT_DIALOG_UNLOADING_TIPS_IT "Is unloading,please wait!" + #define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_IT "Load filament completed,click for return!" + #define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_IT "Unload filament completed,click for return!" +#endif +#define FILAMENT_CHANGE_TEXT_IT "Please click \nor ,After \npinter pause." +#define FILAMENT_DIALOG_LOAD_HEAT_TIPS_IT "Heating up the nozzle,please wait..." +#define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_IT "Heating up the nozzle,please wait..." +#define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_IT "Heat completed,please load filament \nto extruder,and click \nfor start loading." +#define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_IT "Please load filament to extruder,\nand click for start loading." +#define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_IT "Heat completed,please \nclick for start unloading.!" +#define FILAMENT_DIALOG_LOADING_TIPS_IT "Is loading ,please wait!" +#define FILAMENT_DIALOG_UNLOADING_TIPS_IT "Is unloading,please wait!" +#define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_IT "Load filament completed,\nclick for return!" +#define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_IT "Unload filament completed,\nclick for return!" + + +#define PRE_HEAT_EXT_TEXT_IT "E" +#define PRE_HEAT_BED_TEXT_IT "Piano" + +#define FILE_LOADING_IT "Caricamento......" +#if 0 + #define NO_FILE_AND_CHECK_IT "Nessun file trovato! Inserisci la scheda SD o il disco U!" +#endif +#define NO_FILE_AND_CHECK_IT "Nessun file,\n per favore controllare di nuovo!" + +#define NO_FILE_IT "Nessun file!" + +#define EXTRUDER_TEMP_TEXT_IT "Temper" +#define EXTRUDER_E_LENGTH1_TEXT_IT "Estrude1" +#define EXTRUDER_E_LENGTH2_TEXT_IT "Estrude2" +#define EXTRUDER_E_LENGTH3_TEXT_IT "Estrude3" + +#define ABOUT_TYPE_TEXT_IT "Type: " +#define ABOUT_VERSION_TEXT_IT "Firmware: " +#define ABOUT_WIFI_TEXT_IT "WiFi: " + +#define PRINTING_OPERATION_IT "Opzioni" +#define PRINTING_PAUSE_IT "Pause" +#define PRINTING_TEMP_IT "Temp." +#define PRINTING_CHANGESPEED_IT "Velocità" +#define PRINTING_RESUME_IT "Recupero" +#define PRINTING_STOP_IT "Stop" +#define PRINTING_MORE_IT "Di più" +#define PRINTING_EXTRUDER_IT "Estrude" +#define PRINTING_MOVE_IT "Muovi" + +#define EXTRUDER_SPEED_IT "Estrude" +#define MOVE_SPEED_IT "Muovi" +#define EXTRUDER_SPEED_STATE_IT "Estrusione" +#define MOVE_SPEED_STATE_IT "Movimento" +#define STEP_1PERCENT_IT "1%" +#define STEP_5PERCENT_IT "5%" +#define STEP_10PERCENT_IT "10%" + +#define ZOFFSET_IT "Z Offset" +#define ZOFFSET_INC_IT "Add" +#define ZOFFSET_DEC_IT "Dec" + +#define TITLE_READYPRINT_IT "Pronto" +#define TITLE_PREHEAT_IT "Preris" +#define TITLE_MOVE_IT "Muovi" +#define TITLE_HOME_IT "Home" +#define TITLE_EXTRUDE_IT "Estrude" +#define TITLE_LEVELING_IT "Livella" +#define TITLE_SET_IT "Impostare" +#define TITLE_MORE_IT "Di più" +#define TITLE_CHOOSEFILE_IT "File" +#define TITLE_PRINTING_IT "Stampa" +#define TITLE_OPERATION_IT "Opzioni" +#define TITLE_ADJUST_IT "Regolare" +#define TITLE_WIRELESS_IT "Wireless" +#define TITLE_FILAMENT_IT "Filamento" +#define TITLE_ABOUT_IT "Circa" +#define TITLE_FAN_IT "Ventola" +#define TITLE_LANGUAGE_IT "Lingua" +#define TITLE_PAUSE_IT "Pausa" +#define TITLE_CHANGESPEED_IT "Velocità" +#define TITLE_CLOUD_TEXT_IT "Cloud" +#define TITLE_DIALOG_CONFIRM_IT "Confirm" +#define TITLE_FILESYS_IT "FileSys" +#define TITLE_ZOFFSET_IT "Z Offset" + +#define AUTO_SHUTDOWN_IT "Auto" +#define MANUAL_SHUTDOWN_IT "Manuale" + +#define DIALOG_CONFIRM_IT "Conferma" +#define DIALOG_CANCLE_IT "Cancella" +#define DIALOG_OK_IT "OK" +#define DIALOG_RESET_IT "Resettare" +#define DIALOG_RETRY_IT "Riprovare" +#define DIALOG_DISABLE_IT "Disable" +#define DIALOG_PRINT_MODEL_IT "Gcode stampa?" +#define DIALOG_CANCEL_PRINT_IT "Stop stampa?" +#define DIALOG_STOP_IT "Stop" +#define DIALOG_REPRINT_FROM_BREAKPOINT_IT "Continua a stampare dal \npunto di interruzione?" +//#define DIALOG_UNBIND_PRINTER_IT "Libero?" +#define DIALOG_ERROR_TIPS1_IT "Errore: nessun file, \nper favore controllare di nuovo." +#define DIALOG_ERROR_TIPS2_IT "Errore: operazione non riuscita, \nsi prega di controllare se il baudrate del \ndisplay è lo stesso scheda madre" +#define DIALOG_ERROR_TIPS3_IT "Errore: il nome del file o il \npercorso è troppo lungo!" +#define DIALOG_CLOSE_MACHINE_IT "Closing machine......" +#define DIALOG_UNBIND_PRINTER_IT "Unbind the printer?" +#define DIALOG_FILAMENT_NO_PRESS_IT "Filament detection switch is not pressed" +#define DIALOG_PRINT_FINISH_IT "La stampa è completa!" +#define DIALOG_PRINT_TIME_IT "Tempo di stampa: " +#define DIALOG_REPRINT_IT "Print again" +#define DIALOG_WIFI_ENABLE_TIPS_IT "The wifi module is being configured,\nplease wait a moment....." + +#define MESSEGE_PAUSING_IT "Parcheggiando..." +#define MESSEGE_CHANGING_IT "Attendere avvio del cambio di filamento" +#define MESSEGE_UNLOAD_IT "Attendere l'espulsione del filamento" +#define MESSEGE_WAITING_IT "Premi per riprendere la stampa" +#define MESSEGE_INSERT_IT "Inserisci il filamento e premi per continuare" +#define MESSEGE_LOAD_IT "Attendere il caricamento del filamento" +#define MESSEGE_PURGE_IT "Attendere lo spurgo del filamento" +#define MESSEGE_RESUME_IT "Attendere la ripresa della stampa..." +#define MESSEGE_HEAT_IT "Premi per riscaldare ugello" +#define MESSEGE_HEATING_IT "Riscaldam. ugello Attendere prego..." +#define MESSEGE_OPTION_IT "Eliminare di più o continuare a stampare?" +#define MESSEGE_PURGE_MORE_IT "Epurazione" +#define MESSEGE_CONTINUE_PRINT_IT "Stampa" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h new file mode 100644 index 0000000..e78067d --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h @@ -0,0 +1,272 @@ +/** + * 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 + +//****************俄语***************************// +#define TOOL_TEXT_RU "инструмент" +#define PREHEAT_TEXT_RU " нагрев" +#define MOVE_TEXT_RU "движение" +#define HOME_TEXT_RU "домой" +#define PRINT_TEXT_RU " печать" +#define EXTRUDE_TEXT_RU "экструзия" +#define LEVELING_TEXT_RU "уровень" +#define AUTO_LEVELING_TEXT_RU "aвто" +#define SET_TEXT_RU "настройки" +#define MORE_TEXT_RU "больше" + +#define ADD_TEXT_RU "добавить" +#define DEC_TEXT_RU "уменьшить" +#define EXTRUDER_1_TEXT_RU "экструдер1" +#define EXTRUDER_2_TEXT_RU "экструдер2" +#define HEATBED_TEXT_RU "стол" +#define TEXT_1C_RU "1℃" +#define TEXT_5C_RU "5℃" +#define TEXT_10C_RU "10℃" +#define CLOSE_TEXT_RU "выкл" + +#define BACK_TEXT_RU "назад" + +#define TOOL_PREHEAT_RU "нагрев" +#define TOOL_EXTRUDE_RU "экструзия" +#define TOOL_MOVE_RU "движение" +#define TOOL_HOME_RU "домой" +#define TOOL_LEVELING_RU "уровень" +#define TOOL_AUTO_LEVELING_RU "aвто" +#define TOOL_FILAMENT_RU "замена" +#define TOOL_MORE_RU "больше" + +#define AXIS_X_ADD_TEXT_RU "X+" +#define AXIS_X_DEC_TEXT_RU "X-" +#define AXIS_Y_ADD_TEXT_RU "Y+" +#define AXIS_Y_DEC_TEXT_RU "Y-" +#define AXIS_Z_ADD_TEXT_RU "Z+" +#define AXIS_Z_DEC_TEXT_RU "Z-" +#define TEXT_01MM_RU "0.1mm" +#define TEXT_1MM_RU "1mm" +#define TEXT_10MM_RU "10mm" + +#define HOME_X_TEXT_RU "X" +#define HOME_Y_TEXT_RU "Y" +#define HOME_Z_TEXT_RU "Z" +#define HOME_ALL_TEXT_RU "Home" +#define HOME_STOPMOVE_RU "Quickstop" + +#define PAGE_UP_TEXT_RU "вверх" +#define PAGE_DOWN_TEXT_RU "вниз" + +#define EXTRUDER_IN_TEXT_RU "втянуть" +#define EXTRUDER_OUT_TEXT_RU "выдавить" +#define EXTRUDE_1MM_TEXT_RU "1mm" +#define EXTRUDE_5MM_TEXT_RU "5mm" +#define EXTRUDE_10MM_TEXT_RU "10mm" +#define EXTRUDE_LOW_SPEED_TEXT_RU "мин" +#define EXTRUDE_MEDIUM_SPEED_TEXT_RU "сред" +#define EXTRUDE_HIGH_SPEED_TEXT_RU "выс" + +#define LEVELING_POINT1_TEXT_RU "1точка" +#define LEVELING_POINT2_TEXT_RU "2точка" +#define LEVELING_POINT3_TEXT_RU "3точка" +#define LEVELING_POINT4_TEXT_RU "4точка" +#define LEVELING_POINT5_TEXT_RU "5точка" + +#define FILESYS_TEXT_RU "система" +#define WIFI_TEXT_RU "WiFi" +#define FAN_TEXT_RU "вентилятор" +#define ABOUT_TEXT_RU "инфо" +#define BREAK_POINT_TEXT_RU "продолжить" +#define FILAMENT_TEXT_RU "замена" +#define LANGUAGE_TEXT_RU "язык" +#define MOTOR_OFF_TEXT_RU "отклмотор" +#define MOTOR_OFF_XY_TEXT_RU "Off-XY" +#define SHUTDOWN_TEXT_RU "выключение" + +#define U_DISK_TEXT_RU "U диск" +#define SD_CARD_TEXT_RU "SD диск" +#define WIFI_NAME_TEXT_RU "WiFi: " +#define WIFI_KEY_TEXT_RU "пароль: " +#define WIFI_IP_TEXT_RU "IP: " +#define WIFI_AP_TEXT_RU "режим: AP" +#define WIFI_STA_TEXT_RU "режим: STA" +#define WIFI_CONNECTED_TEXT_RU "подключен" +#define WIFI_DISCONNECTED_TEXT_RU "не подключен" +#define WIFI_EXCEPTION_TEXT_RU "исключение" +#define WIFI_RECONNECT_TEXT_RU "Reconnect" +#define CLOUD_TEXT_RU "облако" +#define CLOUD_BIND_RU "соединён" +#define CLOUD_UNBIND_RU "не соединён" +#define CLOUD_UNBINDING_RU "Unbinding" +#define CLOUD_DISCONNECTED_RU "Disconnected" +#define CLOUD_UNBINDED_RU "Unbinded" +#define CLOUD_BINDED_RU "Binded" +#define CLOUD_DISABLE_RU "Disable" + +#define FAN_ADD_TEXT_RU "добавить" +#define FAN_DEC_TEXT_RU "уменьшить" +#define FAN_OPEN_TEXT_RU "100%" +#define FAN_HALF_TEXT_RU "50%" +#define FAN_CLOSE_TEXT_RU "откл" +#define FAN_TIPS1_TEXT_RU "вентилятор" +#define FAN_TIPS2_TEXT_RU "вентилятор\nоткл" + +#define FILAMENT_IN_TEXT_RU "втянуть" +#define FILAMENT_OUT_TEXT_RU "выдавить" +#define FILAMENT_EXT0_TEXT_RU "экструдер1" +#define FILAMENT_EXT1_TEXT_RU "экструдер2" +#define FILAMENT_HEAT_TEXT_RU "нагрев" +#define FILAMENT_STOP_TEXT_RU "стоп" +//#define FILAMENT_CHANGE_TEXT_RU "замена" +#define FILAMENT_TIPS2_TEXT_RU "T:" +#define FILAMENT_TIPS3_TEXT_RU "втянуть..." +#define FILAMENT_TIPS4_TEXT_RU "вядавить..." +#define FILAMENT_TIPS5_TEXT_RU "Низкая температура, \nнеобходим нагрев" +#define FILAMENT_TIPS6_TEXT_RU "завершено" + +#if 0 + #define FILAMENT_REPLAYS_IDLE_TEXT_RU "Please click <втянуть> or <выдавить> \nto replace filament!" + #define FILAMENT_CHANGE_TEXT_RU "Please click <втянуть> or <выдавить>,\nAfter pinter pause." + #define FILAMENT_DIALOG_LOAD_HEAT_TIPS_RU "Heating up the nozzle,please wait..." + #define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_RU "Heating up the nozzle,please wait..." + #define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_RU "Heat completed,please load filament to extruder,and click <да> for start loading." + #define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_RU "Please load filament to extruder,and click <да> for start loading." + #define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_RU "Heat completed,please click <да> for start unloading.!" + #define FILAMENT_DIALOG_LOADING_TIPS_RU "Is loading ,please wait!" + #define FILAMENT_DIALOG_UNLOADING_TIPS_RU "Is unloading,please wait!" + #define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_RU "Load filament completed,click <да> for return!" + #define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_RU "Unload filament completed,click <да> for return!" +#endif +#define FILAMENT_CHANGE_TEXT_RU "Please click \nor ,After \npinter pause." +#define FILAMENT_DIALOG_LOAD_HEAT_TIPS_RU "Heating up the nozzle,\nplease wait..." +#define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_RU "Heating up the nozzle,\nplease wait..." +#define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_RU "Heat completed,please load filament \nto extruder,and click \nfor start loading." +#define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_RU "Please load filament to extruder,\nand click for start loading." +#define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_RU "Heat completed,please \nclick for start unloading.!" +#define FILAMENT_DIALOG_LOADING_TIPS_RU "Is loading ,please wait!" +#define FILAMENT_DIALOG_UNLOADING_TIPS_RU "Is unloading,please wait!" +#define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_RU "Load filament completed,\nclick for return!" +#define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_RU "Unload filament completed,\nclick for return!" + + +#define PRE_HEAT_EXT_TEXT_RU "E" +#define PRE_HEAT_BED_TEXT_RU "стол" + +#define FILE_LOADING_RU "загрузка......" +#if 0 + #define NO_FILE_AND_CHECK_RU "Файлы не найдены! Вставьте SD-карту или диск U!" +#endif +#define NO_FILE_AND_CHECK_RU "нет файла,попробуйте ещё раз!" + +#define NO_FILE_RU "нет файла!" + +#define EXTRUDER_TEMP_TEXT_RU "температура" +#define EXTRUDER_E_LENGTH1_TEXT_RU "экструзия1" +#define EXTRUDER_E_LENGTH2_TEXT_RU "экструзия2" +#define EXTRUDER_E_LENGTH3_TEXT_RU "экструзия3" + +#define ABOUT_TYPE_TEXT_RU "Type: " +#define ABOUT_VERSION_TEXT_RU "Firmware: " +#define ABOUT_WIFI_TEXT_RU "WiFi: " + +#define PRINTING_OPERATION_RU "управление" +#define PRINTING_PAUSE_RU "пауза" +#define PRINTING_TEMP_RU "темп" +#define PRINTING_CHANGESPEED_RU "скорости" +#define PRINTING_RESUME_RU "возобновить" +#define PRINTING_STOP_RU "стоп" +#define PRINTING_MORE_RU "больше" +#define PRINTING_EXTRUDER_RU "экстр" +#define PRINTING_MOVE_RU "движение" + +#define EXTRUDER_SPEED_RU "экстр" +#define MOVE_SPEED_RU "движ" +#define EXTRUDER_SPEED_STATE_RU "скорость экстр" +#define MOVE_SPEED_STATE_RU "скорость движ" +#define STEP_1PERCENT_RU "1%" +#define STEP_5PERCENT_RU "5%" +#define STEP_10PERCENT_RU "10%" + +#define ZOFFSET_RU "Z Offset" +#define ZOFFSET_INC_RU "добавить" +#define ZOFFSET_DEC_RU "уменьшить" + +#define TITLE_READYPRINT_RU "готов к" +#define TITLE_PREHEAT_RU "движение" +#define TITLE_MOVE_RU "движение" +#define TITLE_HOME_RU "Home" +#define TITLE_EXTRUDE_RU "экструзия" +#define TITLE_LEVELING_RU "уровень" +#define TITLE_SET_RU "настройки" +#define TITLE_MORE_RU "больше" +#define TITLE_CHOOSEFILE_RU "файла" +#define TITLE_PRINTING_RU "печать" +#define TITLE_OPERATION_RU "управление" +#define TITLE_ADJUST_RU "регулировать" +#define TITLE_WIRELESS_RU "Wireless" +#define TITLE_FILAMENT_RU "замена" +#define TITLE_ABOUT_RU "инфо" +#define TITLE_FAN_RU "вентилятор" +#define TITLE_LANGUAGE_RU "язык" +#define TITLE_PAUSE_RU "пауза" +#define TITLE_CHANGESPEED_RU "скорости" +#define TILE_TOOL_RU "инструмент" +#define TITLE_CLOUD_TEXT_RU "Cloud" +#define TITLE_DIALOG_CONFIRM_RU "Confirm" +#define TITLE_FILESYS_RU "FileSys" +#define TITLE_ZOFFSET_RU "Z Offset" + +#define AUTO_SHUTDOWN_RU "авто-откл" +#define MANUAL_SHUTDOWN_RU "ручн-откл" + +#define DIALOG_CONFIRM_RU "да"//"подтвердить" +#define DIALOG_CANCLE_RU "отмена" +#define DIALOG_OK_RU "да" +#define DIALOG_RESET_RU "сброс" +#define DIALOG_RETRY_RU "повтор" +#define DIALOG_DISABLE_RU "запретить" +#define DIALOG_PRINT_MODEL_RU "печать модели?" +#define DIALOG_CANCEL_PRINT_RU "стоп?" +#define DIALOG_STOP_RU "стоп" +#define DIALOG_REPRINT_FROM_BREAKPOINT_RU "продолжить?" +//#define DIALOG_UNBIND_PRINTER_RU "разрыв?" +#define DIALOG_ERROR_TIPS1_RU "ошибка:нет файла, попробуйте ещё раз." +#define DIALOG_ERROR_TIPS2_RU "ошибка:сбой передачи. установите скорость \nпередачи данных как на плате управления!" +#define DIALOG_ERROR_TIPS3_RU "ошибка: имя файла слишком длинное!" +#define DIALOG_CLOSE_MACHINE_RU "Closing machine......" +#define DIALOG_UNBIND_PRINTER_RU "Unbind the printer?" +#define DIALOG_FILAMENT_NO_PRESS_RU "Filament detection switch is not pressed" +#define DIALOG_PRINT_FINISH_RU "Печать завершена!" +#define DIALOG_PRINT_TIME_RU "Время печати: " +#define DIALOG_REPRINT_RU "Print again" +#define DIALOG_WIFI_ENABLE_TIPS_RU "The wifi module is being configured,\nplease wait a moment....." + +#define MESSEGE_PAUSING_RU "Стоянка..." +#define MESSEGE_CHANGING_RU "Подождите, пока начнется смена филамента" +#define MESSEGE_UNLOAD_RU "Дождитесь выгрузки нити" +#define MESSEGE_WAITING_RU "Нажмите кнопку,чтобы возобновить печать" +#define MESSEGE_INSERT_RU "Вставьте нить и нажмите кнопку,чтобы продолжить" +#define MESSEGE_LOAD_RU "Дождитесь загрузки нити" +#define MESSEGE_PURGE_RU "Дождитесь чистки нити" +#define MESSEGE_RESUME_RU "Подождите,пока печать возобновится ..." +#define MESSEGE_HEAT_RU "Нажмите кнопку, чтобы нагреть форсунку" +#define MESSEGE_HEATING_RU "Подогрев форсунки Пожалуйста, подождите ..." +#define MESSEGE_OPTION_RU "Очистить больше или продолжить печать?" +#define MESSEGE_PURGE_MORE_RU "чистка" +#define MESSEGE_CONTINUE_PRINT_RU "Распечатать" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h new file mode 100644 index 0000000..50a9dea --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h @@ -0,0 +1,264 @@ +/** + * 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 + +//*************简体中文***********************// +#define TOOL_TEXT_CN "工具" +#define PREHEAT_TEXT_CN "预热" +#define MOVE_TEXT_CN "移动" +#define HOME_TEXT_CN "回零" +#define PRINT_TEXT_CN "打印" +#define EXTRUDE_TEXT_CN "挤出" +#define LEVELING_TEXT_CN "调平" +#define AUTO_LEVELING_TEXT_CN "自动调平" +#define SET_TEXT_CN "设置" +#define MORE_TEXT_CN "更多" + +#define ADD_TEXT_CN "增加" +#define DEC_TEXT_CN "减少" +#define EXTRUDER_1_TEXT_CN "喷头1" +#define EXTRUDER_2_TEXT_CN "喷头2" +#define HEATBED_TEXT_CN "热床" +#define TEXT_1C_CN "1℃" +#define TEXT_5C_CN "5℃" +#define TEXT_10C_CN "10℃" +#define CLOSE_TEXT_CN "关闭" + +#define BACK_TEXT_CN "返回" + +#define TOOL_PREHEAT_CN "预热" +#define TOOL_EXTRUDE_CN "挤出" +#define TOOL_MOVE_CN "移动" +#define TOOL_HOME_CN "回零" +#define TOOL_LEVELING_CN "调平" +#define TOOL_AUTO_LEVELING_CN "自动调平" +#define TOOL_FILAMENT_CN "换料" +#define TOOL_MORE_CN "更多" + +#define AXIS_X_ADD_TEXT_CN "X+" +#define AXIS_X_DEC_TEXT_CN "X-" +#define AXIS_Y_ADD_TEXT_CN "Y+" +#define AXIS_Y_DEC_TEXT_CN "Y-" +#define AXIS_Z_ADD_TEXT_CN "Z+" +#define AXIS_Z_DEC_TEXT_CN "Z-" +#define TEXT_01MM_CN "0.1mm" +#define TEXT_1MM_CN "1mm" +#define TEXT_10MM_CN "10mm" + +#define HOME_X_TEXT_CN "X" +#define HOME_Y_TEXT_CN "Y" +#define HOME_Z_TEXT_CN "Z" +#define HOME_ALL_TEXT_CN "回零" +#define HOME_STOPMOVE_CN "急停" + +#define PAGE_UP_TEXT_CN "上一页" +#define PAGE_DOWN_TEXT_CN "下一页" + +#define EXTRUDER_IN_TEXT_CN "进料" +#define EXTRUDER_OUT_TEXT_CN "退料" +#define EXTRUDE_1MM_TEXT_CN "1mm" +#define EXTRUDE_5MM_TEXT_CN "5mm" +#define EXTRUDE_10MM_TEXT_CN "10mm" +#define EXTRUDE_LOW_SPEED_TEXT_CN "低速" +#define EXTRUDE_MEDIUM_SPEED_TEXT_CN "常速" +#define EXTRUDE_HIGH_SPEED_TEXT_CN "高速" + +#define LEVELING_POINT1_TEXT_CN "第一点" +#define LEVELING_POINT2_TEXT_CN "第二点" +#define LEVELING_POINT3_TEXT_CN "第三点" +#define LEVELING_POINT4_TEXT_CN "第四点" +#define LEVELING_POINT5_TEXT_CN "第五点" + +#define FILESYS_TEXT_CN "文件系统" +#define WIFI_TEXT_CN "WIFI" +#define FAN_TEXT_CN "风扇" +#define ABOUT_TEXT_CN "关于" +#define BREAK_POINT_TEXT_CN "断点续打" +#define FILAMENT_TEXT_CN "换料" +#define LANGUAGE_TEXT_CN "语言" +#define MOTOR_OFF_TEXT_CN "关闭电机" +#define MOTOR_OFF_XY_TEXT_CN "关闭XY" +#define SHUTDOWN_TEXT_CN "关机" + +#define U_DISK_TEXT_CN "U盘" +#define SD_CARD_TEXT_CN "SD卡" +#define WIFI_NAME_TEXT_CN "无线网络:" +#define WIFI_KEY_TEXT_CN "密码: " +#define WIFI_IP_TEXT_CN "IP: " +#define WIFI_AP_TEXT_CN "状态: AP" +#define WIFI_STA_TEXT_CN "状态: STA" +#define WIFI_CONNECTED_TEXT_CN "已连接" +#define WIFI_DISCONNECTED_TEXT_CN "未连接" +#define WIFI_EXCEPTION_TEXT_CN "模块异常" +#define CLOUD_TEXT_CN "云服务" +#define CLOUD_BIND_CN "已绑定" +#define CLOUD_UNBIND_CN "解绑" +#define CLOUD_UNBINDING_CN "解绑中" +#define CLOUD_DISCONNECTED_CN "未连接" +#define CLOUD_UNBINDED_CN "未绑定" +#define CLOUD_BINDED_CN "已绑定" +#define CLOUD_DISABLE_CN "已禁用" + +#define FAN_ADD_TEXT_CN "增加" +#define FAN_DEC_TEXT_CN "减少" +#define FAN_OPEN_TEXT_CN "100%" +#define FAN_HALF_TEXT_CN "50%" +#define FAN_CLOSE_TEXT_CN "关闭" +#define FAN_TIPS1_TEXT_CN "风扇" +#define FAN_TIPS2_TEXT_CN "FAN\nClose" + +#define FILAMENT_IN_TEXT_CN "进料" +#define FILAMENT_OUT_TEXT_CN "退料" +#define FILAMENT_EXT0_TEXT_CN "喷头1" +#define FILAMENT_EXT1_TEXT_CN "喷头2" +#define FILAMENT_HEAT_TEXT_CN "预热" +#define FILAMENT_STOP_TEXT_CN "停止" +#if 0 + #define FILAMENT_REPLAYS_IDLE_TEXT_CN "请按<进料>或<退料>进行换料!" + #define FILAMENT_CHANGE_TEXT_CN "待打印机暂停后,请按<进料>或<退料>进行换料!" +#else + #define FILAMENT_CHANGE_TEXT_CN "待打印机暂停后,\n请按<进料>或<退料>" +#endif + +#define FILAMENT_DIALOG_LOAD_HEAT_TIPS_CN "准备进料,正在加热,请稍等!" +#define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_CN "准备退料,正在加热,请稍等!" +#define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_CN "加热完成,请装载耗材后,按<确定>开始进料!" +#define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_CN "请装载耗材,按<确定>开始进料!" +#define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_CN "加热完成,请按<确定>开始退料!" +#define FILAMENT_DIALOG_LOADING_TIPS_CN "正在进料,请等待耗材加载完成!" +#define FILAMENT_DIALOG_UNLOADING_TIPS_CN "正在退料,请等待耗材卸载完成!" +#define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_CN "进料完成,请按<确定>返回" +#define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_CN "退料完成,请按<确定>返回" + +#define FILAMENT_TIPS3_TEXT_CN "正在进料" +#define FILAMENT_TIPS4_TEXT_CN "正在退料" +#define FILAMENT_TIPS5_TEXT_CN "温度太低,请先预热" +#define FILAMENT_TIPS6_TEXT_CN "换料完成" + +#define PRE_HEAT_EXT_TEXT_CN "喷头" +#define PRE_HEAT_BED_TEXT_CN "热床" + +#define FILE_LOADING_CN "正在载入......" +#define NO_FILE_AND_CHECK_CN "无文件!请插入sd卡或u盘!" +#define NO_FILE_CN "无文件!" + +#define EXTRUDER_TEMP_TEXT_CN "温度" +#define EXTRUDER_E_LENGTH1_TEXT_CN "喷头" +#define EXTRUDER_E_LENGTH2_TEXT_CN "喷头" +#define EXTRUDER_E_LENGTH3_TEXT_CN "喷头" + +#define ABOUT_TYPE_TEXT_CN "Type: " +#define ABOUT_VERSION_TEXT_CN "Firmware: " +#define ABOUT_WIFI_TEXT_CN "Wifi: " + +#define PRINTING_OPERATION_CN "操作" +#define PRINTING_PAUSE_CN "暂停" +#define PRINTING_TEMP_CN "温度" +#define PRINTING_CHANGESPEED_CN "变速" +#define PRINTING_RESUME_CN "恢复" +#define PRINTING_STOP_CN "停止" +#define PRINTING_MORE_CN "更多" +#define PRINTING_EXTRUDER_CN "挤出" +#define PRINTING_MOVE_CN "移动" + +#define EXTRUDER_SPEED_CN "挤出" +#define MOVE_SPEED_CN "移动" +#define EXTRUDER_SPEED_STATE_CN "挤出速度" +#define MOVE_SPEED_STATE_CN "移动速度" +#define STEP_1PERCENT_CN "1%" +#define STEP_5PERCENT_CN "5%" +#define STEP_10PERCENT_CN "10%" + +#define ZOFFSET_CN "Z Offset" +#define ZOFFSET_INC_CN "增加" +#define ZOFFSET_DEC_CN "减少" + +#define TITLE_READYPRINT_CN "准备打印" +#define TITLE_PREHEAT_CN "预热" +#define TITLE_MOVE_CN "移动" +#define TITLE_HOME_CN "回零" +#define TITLE_EXTRUDE_CN "挤出" +#define TITLE_LEVELING_CN "调平" +#define TITLE_SET_CN "设置" +#define TITLE_MORE_CN "更多" +#define TITLE_CHOOSEFILE_CN "选择文件" +#define TITLE_PRINTING_CN "正在打印" +#define TITLE_OPERATION_CN "操作" +#define TITLE_ADJUST_CN "调整" +#define TITLE_WIRELESS_CN "无线网络" +#define TITLE_FILAMENT_CN "换料" +#define TITLE_ABOUT_CN "关于" +#define TITLE_FAN_CN "风扇" +#define TITLE_LANGUAGE_CN "语言" +#define TITLE_PAUSE_CN "暂停" +#define TITLE_CHANGESPEED_CN "变速" +#define TITLE_CLOUD_TEXT_CN "云服务" +#define TITLE_DIALOG_CONFIRM_CN "确认" +#define TITLE_FILESYS_CN "文件系统" +#define TITLE_ZOFFSET_CN "Z Offset" + +#define AUTO_SHUTDOWN_CN "自动关机" +#define MANUAL_SHUTDOWN_CN "手动关机" + +#define DIALOG_CONFIRM_CN "确定" +#define DIALOG_CANCLE_CN "取消" +#define DIALOG_OK_CN "确认" +#define DIALOG_RESET_CN "重置" +#define DIALOG_DISABLE_CN "禁用" +#define DIALOG_PRINT_MODEL_CN "打印模型?" +#define DIALOG_CANCEL_PRINT_CN "停止打印?" +#define DIALOG_RETRY_CN "重试" +#define DIALOG_STOP_CN "停止" +#define DIALOG_REPRINT_FROM_BREAKPOINT_CN "从断点续打?" +//#define DIALOG_UNBIND_PRINTER_CN "解除绑定 ?" +#define DIALOG_ERROR_TIPS1_CN "错误:找不到文件,请插入sd卡/u盘!" +#define DIALOG_ERROR_TIPS2_CN "错误:通信失败,请检查波特率或主板硬件!" +#define DIALOG_ERROR_TIPS3_CN "错误:文件名或文件路径太长 !" +#define DIALOG_CLOSE_MACHINE_CN "正在关机......" +#define DIALOG_UNBIND_PRINTER_CN "解除绑定?" +#define DIALOG_FILAMENT_NO_PRESS_CN "请先装载耗材!" +#define DIALOG_PRINT_FINISH_CN "打印完成!" +#define DIALOG_PRINT_TIME_CN "打印时间: " +#define DIALOG_REPRINT_CN "再打印一次" +#define DIALOG_WIFI_ENABLE_TIPS_CN "wifi模块正在配置中,请稍等......" + +#define TEXT_VALUE_CN "%d℃/%d℃" +#define EXTRUDE_TEXT_VALUE_T_CN ": %d℃" +#define WIFI_RECONNECT_TEXT_CN "重新连接" + +#define PRINTING_GBK "正在打印" +#define PRINTING_OPERATION_GBK "操作" +#define PRINTING_PAUSE_GBK "暂停" + +#define MESSEGE_PAUSING_CN "暂停中..." +#define MESSEGE_CHANGING_CN "等待换料开始..." +#define MESSEGE_UNLOAD_CN "退料中,请稍等..." +#define MESSEGE_WAITING_CN "点击按钮恢复打印" +#define MESSEGE_INSERT_CN "装载耗材后,点击按钮开始打印" +#define MESSEGE_LOAD_CN "进料中,请稍等..." +#define MESSEGE_PURGE_CN "等待挤出..." +#define MESSEGE_RESUME_CN "等待恢复打印..." +#define MESSEGE_HEAT_CN "按下按钮,加热喷头" +#define MESSEGE_HEATING_CN "喷头加热中,请等待..." +#define MESSEGE_OPTION_CN "挤出更多还是继续打印?" +#define MESSEGE_PURGE_MORE_CN "挤出" +#define MESSEGE_CONTINUE_PRINT_CN "打印" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h new file mode 100644 index 0000000..f83771b --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h @@ -0,0 +1,279 @@ +/** + * 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 + +//****************西班牙语*************************** +#define TOOL_TEXT_SP "Ajustes" +#define PREHEAT_TEXT_SP "Precalentar"//"precalent\nar" +#define MOVE_TEXT_SP "Mover" +#define HOME_TEXT_SP "Origen" +#define PRINT_TEXT_SP "Imprimir" +#define EXTRUDE_TEXT_SP "Extrusor" +#define LEVELING_TEXT_SP "Leveling"//"nivelac\nión" +#define AUTO_LEVELING_TEXT_SP "Autolevel"//"auto\nnivelación" +#define SET_TEXT_SP "Config" +#define MORE_TEXT_SP "Más" + +#define ADD_TEXT_SP "Más" +#define DEC_TEXT_SP "Menos" +#define EXTRUDER_1_TEXT_SP "Extrusor1: " +#define EXTRUDER_2_TEXT_SP "Extrusor2: " +#define HEATBED_TEXT_SP "Cama: " +#define TEXT_1C_SP "1℃" +#define TEXT_5C_SP "5℃" +#define TEXT_10C_SP "10℃" +#define CLOSE_TEXT_SP "Apagar" + +#define BACK_TEXT_SP "Atrás" + +#define TOOL_PREHEAT_SP "Precalentar" +#define TOOL_EXTRUDE_SP "Extrusor" +#define TOOL_MOVE_SP "Mover" +#define TOOL_HOME_SP "Origen" +#define TOOL_LEVELING_SP "Leveling" +#define TOOL_AUTO_LEVELING_SP "Autolevel" +#define TOOL_FILAMENT_SP "Filamento" +#define TOOL_MORE_SP "Más" + +#define AXIS_X_ADD_TEXT_SP "X+" +#define AXIS_X_DEC_TEXT_SP "X-" +#define AXIS_Y_ADD_TEXT_SP "Y+" +#define AXIS_Y_DEC_TEXT_SP "Y-" +#define AXIS_Z_ADD_TEXT_SP "Z+" +#define AXIS_Z_DEC_TEXT_SP "Z-" +#define TEXT_01MM_SP "0.1mm" +#define TEXT_1MM_SP "1mm" +#define TEXT_10MM_SP "10mm" + +#define HOME_X_TEXT_SP "EJE X" +#define HOME_Y_TEXT_SP "EJE Y" +#define HOME_Z_TEXT_SP "EJE Z" +#define HOME_ALL_TEXT_SP "TODOS" +#define HOME_STOPMOVE_SP "Quickstop" + +#define PAGE_UP_TEXT_SP "Arriba" +#define PAGE_DOWN_TEXT_SP "Abajo" + +#define EXTRUDER_IN_TEXT_SP "Dentro" +#define EXTRUDER_OUT_TEXT_SP "Fuera" +#define EXTRUDE_1MM_TEXT_SP "1mm" +#define EXTRUDE_5MM_TEXT_SP "5mm" +#define EXTRUDE_10MM_TEXT_SP "10mm" +#define EXTRUDE_LOW_SPEED_TEXT_SP "Baja" +#define EXTRUDE_MEDIUM_SPEED_TEXT_SP "Media" +#define EXTRUDE_HIGH_SPEED_TEXT_SP "Alta" + +#define LEVELING_POINT1_TEXT_SP "Primero" +#define LEVELING_POINT2_TEXT_SP "Segundo" +#define LEVELING_POINT3_TEXT_SP "Tercero" +#define LEVELING_POINT4_TEXT_SP "Cuarto" +#define LEVELING_POINT5_TEXT_SP "Quinto" + +#define FILESYS_TEXT_SP "Puerto" +#define WIFI_TEXT_SP "WiFi" +#define FAN_TEXT_SP "Ventilador" +#define ABOUT_TEXT_SP "Acerca" +#define BREAK_POINT_TEXT_SP "Continuar" +#define FILAMENT_TEXT_SP "Filamento" +#define LANGUAGE_TEXT_SP "Language" +#define MOTOR_OFF_TEXT_SP "Apagar motor" +#define MOTOR_OFF_XY_TEXT_SP "Off-XY" +#define SHUTDOWN_TEXT_SP "Apagar" + +#define U_DISK_TEXT_SP "PENDRIVE" +#define SD_CARD_TEXT_SP "SD" +#define WIFI_NAME_TEXT_SP "WIFI: " +#define WIFI_KEY_TEXT_SP "Contraseña: " +#define WIFI_IP_TEXT_SP "IP: " +#define WIFI_AP_TEXT_SP "Estado: AP" +#define WIFI_STA_TEXT_SP "Estado: STA" +#define WIFI_CONNECTED_TEXT_SP "Conectado" +#define WIFI_DISCONNECTED_TEXT_SP "Desconectado" +#define WIFI_EXCEPTION_TEXT_SP "Excepción" +#define WIFI_RECONNECT_TEXT_SP "Reconnect" +#define CLOUD_TEXT_SP "Nube" +#define CLOUD_BIND_SP "Atado" +#define CLOUD_UNBIND_SP "Sin atar" +#define CLOUD_UNBINDING_SP "Unbinding" +#define CLOUD_DISCONNECTED_SP "Disconnected" +#define CLOUD_UNBINDED_SP "Unbinded" +#define CLOUD_BINDED_SP "Binded" +#define CLOUD_DISABLE_SP "Disable" + +#define FAN_ADD_TEXT_SP "Más" +#define FAN_DEC_TEXT_SP "Menos" +#define FAN_OPEN_TEXT_SP "100%" +#define FAN_HALF_TEXT_SP "50%" +#define FAN_CLOSE_TEXT_SP "0%" +#define FAN_TIPS1_TEXT_SP "ventilador" +#define FAN_TIPS2_TEXT_SP "ventilador\n0" + +#define FILAMENT_IN_TEXT_SP "Dentro" +#define FILAMENT_OUT_TEXT_SP "Fuera" +#define FILAMENT_EXT0_TEXT_SP "Extrusor1" +#define FILAMENT_EXT1_TEXT_SP "Extrusor2" +#define FILAMENT_HEAT_TEXT_SP "Precalentar" +#define FILAMENT_STOP_TEXT_SP "Parar" +//#define FILAMENT_CHANGE_TEXT_SP "Filamento" +#define FILAMENT_TIPS2_TEXT_SP "T:" +#define FILAMENT_TIPS3_TEXT_SP "Dentro..." +#define FILAMENT_TIPS4_TEXT_SP "Fuera..." +#define FILAMENT_TIPS5_TEXT_SP "Temperatura demasiado baja, por favor calentar" +#define FILAMENT_TIPS6_TEXT_SP "Completado" +#if 0 + #define FILAMENT_REPLAYS_IDLE_TEXT_SP "Please click or \nto replace filament!" + #define FILAMENT_CHANGE_TEXT_SP "Please click or ,\nAfter pinter pause." + #define FILAMENT_DIALOG_LOAD_HEAT_TIPS_SP "Calentando el extrusor, por favor espere..." + #define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_SP "Calentando el extrusor, por favor espere..." + #define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_SP "Temperatura alcanzada.Inserte el filamento y luego presione\"Confirmar\"para comenzar la carga." + #define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_SP "Inserte el filamento y luego presione\"Confirmar\"para comenzar la carga." + #define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_SP "Temperatura alcanzada.Presione\"Confirmar\"para retirar el filamento." + #define FILAMENT_DIALOG_LOADING_TIPS_SP "Cargando filamento,por favor espere." + #define FILAMENT_DIALOG_UNLOADING_TIPS_SP "Retirando filamento,por favor espere." + #define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_SP "Filamento cargado,presione\"Confirmar\"." + #define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_SP "Filamento retirado,presione\"Confirmar\"." +#else + #define FILAMENT_CHANGE_TEXT_SP "Please click \nor ,After \npinter pause." + #define FILAMENT_DIALOG_LOAD_HEAT_TIPS_SP "Calentando el extrusor,\npor favor espere..." + #define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_SP "Calentando el extrusor,\npor favor espere..." + #define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_SP "Temperatura alcanzada.Inserte el \nfilamento y luego presione\"Confirmar\"\npara comenzar la carga." + #define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_SP "Inserte el filamento y \nluego presione\"Confirmar\"para \ncomenzar la carga." + #define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_SP "Temperatura alcanzada.\nPresione\"Confirmar\"para retirar \nel filamento." + #define FILAMENT_DIALOG_LOADING_TIPS_SP "Cargando filamento,\npor favor espere." + #define FILAMENT_DIALOG_UNLOADING_TIPS_SP "Retirando filamento,\npor favor espere." + #define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_SP "Filamento cargado,\npresione\"Confirmar\"." + #define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_SP "Filamento retirado,\npresione\"Confirmar\"." +#endif + +#define PRE_HEAT_EXT_TEXT_SP "Extrusor" +#define PRE_HEAT_BED_TEXT_SP "cama" + +#define FILE_LOADING_SP "Cargando......" +#if 0 + #define NO_FILE_AND_CHECK_SP "No se encontraron archivos! Por favor, inserte la tarjeta SD o el disco U!" +#endif +#define NO_FILE_AND_CHECK_SP "Archivo no encontrado,\n por favor insertar SD o disco USB!" + +#define NO_FILE_SP "Sin archivo!" + + + +#define EXTRUDER_TEMP_TEXT_SP "Temper" +#define EXTRUDER_E_LENGTH1_TEXT_SP "Extrusor1" +#define EXTRUDER_E_LENGTH2_TEXT_SP "Extrusor2" +#define EXTRUDER_E_LENGTH3_TEXT_SP "Extrusor3" + +#define ABOUT_TYPE_TEXT_SP "Pantalla: " +#define ABOUT_VERSION_TEXT_SP "Firmware: " +#define ABOUT_WIFI_TEXT_SP "WiFi: " + +#define PRINTING_OPERATION_SP "Ajustes" +#define PRINTING_PAUSE_SP "Pausar" +#define PRINTING_TEMP_SP "Temp." +#define PRINTING_CHANGESPEED_SP "Velocidad" +#define PRINTING_RESUME_SP "Resumir" +#define PRINTING_STOP_SP "Detener" +#define PRINTING_MORE_SP "Más" +#define PRINTING_EXTRUDER_SP "Extrusor" +#define PRINTING_MOVE_SP "Mover" + +#define EXTRUDER_SPEED_SP "Extrusor" +#define MOVE_SPEED_SP "Mover" +#define EXTRUDER_SPEED_STATE_SP "Extrusión" +#define MOVE_SPEED_STATE_SP "Movimiento" +#define STEP_1PERCENT_SP "1%" +#define STEP_5PERCENT_SP "5%" +#define STEP_10PERCENT_SP "10%" + +#define ZOFFSET_SP "Z Offset" +#define ZOFFSET_INC_SP "Más" +#define ZOFFSET_DEC_SP "Menos" + +#define TITLE_READYPRINT_SP "Inicio" +#define TITLE_PREHEAT_SP "Precalentar" +#define TITLE_MOVE_SP "Mover" +#define TITLE_HOME_SP "Origen" +#define TITLE_EXTRUDE_SP "Extrusor" +#define TITLE_LEVELING_SP "Leveling" +#define TITLE_SET_SP "Config" +#define TITLE_MORE_SP "Más" +#define TITLE_CHOOSEFILE_SP "Imprimir" +#define TITLE_PRINTING_SP "Imprimir" +#define TITLE_OPERATION_SP "Ajustes" +#define TITLE_ADJUST_SP "Temp." +#define TITLE_WIRELESS_SP "Wireless" +#define TITLE_FILAMENT_SP "Filamento" +#define TITLE_ABOUT_SP "Acerca" +#define TITLE_FAN_SP "Ventilador" +#define TITLE_LANGUAGE_SP "Language" +#define TITLE_PAUSE_SP "Pausar" +#define TITLE_CHANGESPEED_SP "Velocidad" +#define TILE_TOOL_SP "Ajustes" +#define TITLE_CLOUD_TEXT_SP "Cloud" +#define TITLE_DIALOG_CONFIRM_SP "Confirmar" +#define TITLE_FILESYS_SP "Puerto" +#define TITLE_ZOFFSET_SP "Z Offset" + +#define AUTO_SHUTDOWN_SP "Auto" +#define MANUAL_SHUTDOWN_SP "manual" + +#define DIALOG_CONFIRM_SP "Confirmar" +#define DIALOG_CANCLE_SP "Cancelar" +#define DIALOG_OK_SP "OK" +#define DIALOG_RESET_SP "Resetear" +#define DIALOG_RETRY_SP "Reintentar" +#define DIALOG_DISABLE_SP "Desactivar" +#define DIALOG_PRINT_MODEL_SP "¿Está seguro?" +#define DIALOG_CANCEL_PRINT_SP "¿Está seguro que desea detener la impresión?" + +#define DIALOG_RETRY_SP "Reintentar" +#define DIALOG_STOP_SP "Stop" +#define DIALOG_REPRINT_FROM_BREAKPOINT_SP "Reprint from breakpoint?" +//#define DIALOG_UNBIND_PRINTER_SP "Unbind the printer?" +#define DIALOG_ERROR_TIPS1_SP "Error:archivo no encontrado, \npor favor insertar SD o disco USB." +#define DIALOG_ERROR_TIPS2_SP "error:transacción fallida, \nconfigurar baudrate del \ndisplay para la placa base!" +#define DIALOG_ERROR_TIPS3_SP "Error : nombre de archivo o \nruta demasiado largo!" +#define DIALOG_CLOSE_MACHINE_SP "Closing machine......" +#define DIALOG_UNBIND_PRINTER_SP "Unbind the printer?" +#define DIALOG_FILAMENT_NO_PRESS_SP "Filament detection switch is not pressed" +#define DIALOG_PRINT_FINISH_SP "¡La impresión está completa!" +#define DIALOG_PRINT_TIME_SP "Tiempo de impresión: " +#define DIALOG_REPRINT_SP "Print again" +#define DIALOG_WIFI_ENABLE_TIPS_SP "The wifi module is being configured,\nplease wait a moment....." + +#define PRINTING_SP "Imprimiendo" +#define PRINTING_AJUSTES_SP "Ajustes" +#define PRINTING_PAUSAR_SP "Pausar" + +#define MESSEGE_PAUSING_SP "Aparcando..." +#define MESSEGE_CHANGING_SP "Esperando para iniciar el cambio de filamento" +#define MESSEGE_UNLOAD_SP "Espere para liberar el filamento" +#define MESSEGE_WAITING_SP "Pulsar el botón para reanudar impresión" +#define MESSEGE_INSERT_SP "Inserte el filamento y pulse el botón para continuar..." +#define MESSEGE_LOAD_SP "Espere para purgar el filamento" +#define MESSEGE_PURGE_SP "Espere para purgar el filamento" +#define MESSEGE_RESUME_SP "Esperando impresora para reanudar..." +#define MESSEGE_HEAT_SP "Pulse el botón para calentar la boquilla" +#define MESSEGE_HEATING_SP "Calentando boquilla Espere por favor..." +#define MESSEGE_OPTION_SP "¿Purgar más o continuar con la impresión?" +#define MESSEGE_PURGE_MORE_SP "Purga" +#define MESSEGE_CONTINUE_PRINT_SP "Impresión" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h new file mode 100644 index 0000000..e69de29 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp new file mode 100644 index 0000000..25fd708 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp @@ -0,0 +1,273 @@ +/** + * 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_LITTLE_VGL_UI) + + #if defined(ARDUINO_ARCH_STM32F1) && PIN_EXISTS(FSMC_CS) // FSMC on 100/144 pins SoCs + + #include + #include + #include + #include + +/* Timing configuration */ + #define FSMC_ADDRESS_SETUP_TIME 15// AddressSetupTime + #define FSMC_DATA_SETUP_TIME 15// DataSetupTime + + void LCD_IO_Init(uint8_t cs, uint8_t rs); + void LCD_IO_WriteData(uint16_t RegValue); + void LCD_IO_WriteReg(uint16_t Reg); + uint16_t LCD_IO_ReadData(uint16_t RegValue); + uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize); + uint16_t ILI9488_ReadRAM(); + #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 + +/** + * FSMC LCD IO + */ + #define __ASM __asm + #define __STATIC_INLINE static inline + + __attribute__((always_inline)) __STATIC_INLINE void __DSB() {__ASM volatile ("dsb 0xF" ::: "memory");} + + #define FSMC_CS_NE1 PD7 + + #if ENABLED(STM32_XL_DENSITY) + #define FSMC_CS_NE2 PG9 + #define FSMC_CS_NE3 PG10 + #define FSMC_CS_NE4 PG12 + + #define FSMC_RS_A0 PF0 + #define FSMC_RS_A1 PF1 + #define FSMC_RS_A2 PF2 + #define FSMC_RS_A3 PF3 + #define FSMC_RS_A4 PF4 + #define FSMC_RS_A5 PF5 + #define FSMC_RS_A6 PF12 + #define FSMC_RS_A7 PF13 + #define FSMC_RS_A8 PF14 + #define FSMC_RS_A9 PF15 + #define FSMC_RS_A10 PG0 + #define FSMC_RS_A11 PG1 + #define FSMC_RS_A12 PG2 + #define FSMC_RS_A13 PG3 + #define FSMC_RS_A14 PG4 + #define FSMC_RS_A15 PG5 + #endif + + #define FSMC_RS_A16 PD11 + #define FSMC_RS_A17 PD12 + #define FSMC_RS_A18 PD13 + #define FSMC_RS_A19 PE3 + #define FSMC_RS_A20 PE4 + #define FSMC_RS_A21 PE5 + #define FSMC_RS_A22 PE6 + #define FSMC_RS_A23 PE2 + + #if ENABLED(STM32_XL_DENSITY) + #define FSMC_RS_A24 PG13 + #define FSMC_RS_A25 PG14 + #endif + + static uint8_t fsmcInit = 0; + + typedef struct { + __IO uint16_t REG; + __IO uint16_t RAM; + } LCD_CONTROLLER_TypeDef; + + LCD_CONTROLLER_TypeDef *LCD; + + void LCD_IO_Init(uint8_t cs, uint8_t rs) { + uint32_t controllerAddress; + + if (fsmcInit) return; + fsmcInit = 1; + + switch (cs) { + case FSMC_CS_NE1: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION1; break; + #if ENABLED(STM32_XL_DENSITY) + case FSMC_CS_NE2: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION2; break; + case FSMC_CS_NE3: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION3; break; + case FSMC_CS_NE4: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION4; break; + #endif + default: return; + } + + #define _ORADDR(N) controllerAddress |= (_BV32(N) - 2) + + switch (rs) { + #if ENABLED(STM32_XL_DENSITY) + case FSMC_RS_A0: _ORADDR( 1); break; + case FSMC_RS_A1: _ORADDR( 2); break; + case FSMC_RS_A2: _ORADDR( 3); break; + case FSMC_RS_A3: _ORADDR( 4); break; + case FSMC_RS_A4: _ORADDR( 5); break; + case FSMC_RS_A5: _ORADDR( 6); break; + case FSMC_RS_A6: _ORADDR( 7); break; + case FSMC_RS_A7: _ORADDR( 8); break; + case FSMC_RS_A8: _ORADDR( 9); break; + case FSMC_RS_A9: _ORADDR(10); break; + case FSMC_RS_A10: _ORADDR(11); break; + case FSMC_RS_A11: _ORADDR(12); break; + case FSMC_RS_A12: _ORADDR(13); break; + case FSMC_RS_A13: _ORADDR(14); break; + case FSMC_RS_A14: _ORADDR(15); break; + case FSMC_RS_A15: _ORADDR(16); break; + #endif + case FSMC_RS_A16: _ORADDR(17); break; + case FSMC_RS_A17: _ORADDR(18); break; + case FSMC_RS_A18: _ORADDR(19); break; + case FSMC_RS_A19: _ORADDR(20); break; + case FSMC_RS_A20: _ORADDR(21); break; + case FSMC_RS_A21: _ORADDR(22); break; + case FSMC_RS_A22: _ORADDR(23); break; + case FSMC_RS_A23: _ORADDR(24); break; + #if ENABLED(STM32_XL_DENSITY) + case FSMC_RS_A24: _ORADDR(25); break; + case FSMC_RS_A25: _ORADDR(26); break; + #endif + default: return; + } + + rcc_clk_enable(RCC_FSMC); + + gpio_set_mode(GPIOD, 14, GPIO_AF_OUTPUT_PP); // FSMC_D00 + gpio_set_mode(GPIOD, 15, GPIO_AF_OUTPUT_PP); // FSMC_D01 + gpio_set_mode(GPIOD, 0, GPIO_AF_OUTPUT_PP);// FSMC_D02 + gpio_set_mode(GPIOD, 1, GPIO_AF_OUTPUT_PP);// FSMC_D03 + gpio_set_mode(GPIOE, 7, GPIO_AF_OUTPUT_PP);// FSMC_D04 + gpio_set_mode(GPIOE, 8, GPIO_AF_OUTPUT_PP);// FSMC_D05 + gpio_set_mode(GPIOE, 9, GPIO_AF_OUTPUT_PP);// FSMC_D06 + gpio_set_mode(GPIOE, 10, GPIO_AF_OUTPUT_PP); // FSMC_D07 + gpio_set_mode(GPIOE, 11, GPIO_AF_OUTPUT_PP); // FSMC_D08 + gpio_set_mode(GPIOE, 12, GPIO_AF_OUTPUT_PP); // FSMC_D09 + gpio_set_mode(GPIOE, 13, GPIO_AF_OUTPUT_PP); // FSMC_D10 + gpio_set_mode(GPIOE, 14, GPIO_AF_OUTPUT_PP); // FSMC_D11 + gpio_set_mode(GPIOE, 15, GPIO_AF_OUTPUT_PP); // FSMC_D12 + gpio_set_mode(GPIOD, 8, GPIO_AF_OUTPUT_PP);// FSMC_D13 + gpio_set_mode(GPIOD, 9, GPIO_AF_OUTPUT_PP);// FSMC_D14 + gpio_set_mode(GPIOD, 10, GPIO_AF_OUTPUT_PP); // FSMC_D15 + + gpio_set_mode(GPIOD, 4, GPIO_AF_OUTPUT_PP);// FSMC_NOE + gpio_set_mode(GPIOD, 5, GPIO_AF_OUTPUT_PP);// FSMC_NWE + + gpio_set_mode(PIN_MAP[cs].gpio_device, PIN_MAP[cs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_CS_NEx + gpio_set_mode(PIN_MAP[rs].gpio_device, PIN_MAP[rs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_RS_Ax + + #if ENABLED(STM32_XL_DENSITY) + FSMC_NOR_PSRAM4_BASE->BCR = FSMC_BCR_WREN | FSMC_BCR_MTYP_SRAM | FSMC_BCR_MWID_16BITS | FSMC_BCR_MBKEN; + FSMC_NOR_PSRAM4_BASE->BTR = (FSMC_DATA_SETUP_TIME << 8) | FSMC_ADDRESS_SETUP_TIME; + #else // PSRAM1 for STM32F103V (high density) + FSMC_NOR_PSRAM1_BASE->BCR = FSMC_BCR_WREN | FSMC_BCR_MTYP_SRAM | FSMC_BCR_MWID_16BITS | FSMC_BCR_MBKEN; + FSMC_NOR_PSRAM1_BASE->BTR = (FSMC_DATA_SETUP_TIME << 8) | FSMC_ADDRESS_SETUP_TIME; + #endif + + afio_remap(AFIO_REMAP_FSMC_NADV); + + LCD = (LCD_CONTROLLER_TypeDef*)controllerAddress; + } + + void LCD_IO_WriteData(uint16_t RegValue) { + LCD->RAM = RegValue; + __DSB(); + } + + void LCD_IO_WriteReg(uint16_t Reg) { + LCD->REG = Reg; + __DSB(); + } + + uint16_t LCD_IO_ReadData(uint16_t RegValue) { + LCD->REG = RegValue; + __DSB(); + + return LCD->RAM; + } + + uint16_t ILI9488_ReadRAM() { + uint16_t data; + data = LCD->RAM; + return data; + } + + uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) { + volatile uint32_t data; + LCD->REG = RegValue; + __DSB(); + + data = LCD->RAM; // dummy read + data = LCD->RAM & 0x00FF; + + while (--ReadSize) { + data <<= 8; + data |= (LCD->RAM & 0x00FF); + } + return uint32_t(data); + } + + #if ENABLED(LCD_USE_DMA_FSMC) + + void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) { + while (count > 0) { + dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, &color, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM); + dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, count > 65535 ? 65535 : count); + dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + + while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {} + dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + + count = count > 65535 ? count - 65535 : 0; + } + } + + void LCD_IO_WriteSequence(uint16_t *data, uint16_t length) { + dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | DMA_PINC_MODE); + dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, length); + dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + + while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {} + dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + } + + void LCD_IO_WriteSequence_Async(uint16_t *data, uint16_t length) { + dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | DMA_PINC_MODE); + dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, length); + dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + } + + void LCD_IO_WaitSequence_Async() { + while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {} + dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + } + + #endif // LCD_USE_DMA_FSMC + #endif // ARDUINO_ARCH_STM32F1 && FSMC_CS_PIN +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h new file mode 100644 index 0000000..13720d1 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h @@ -0,0 +1,30 @@ +/** + * 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-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp new file mode 100644 index 0000000..a34b1ff --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp @@ -0,0 +1,791 @@ +/** + * 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 . + * + */ + +/** + * @file lcd_lvgl_configuration.c + * @date 2020-02-21 + */ + +#include "../../../../inc/MarlinConfigPre.h" + +#if ENABLED(TFT_LITTLE_VGL_UI) + + #include "../../../../MarlinCore.h" + + #include "tft_lvgl_configuration.h" + #include "lvgl.h" + #include "../../../../feature/touch/xpt2046.h" + #include "draw_ready_print.h" + #include "W25Qxx.h" + #include "pic_manager.h" + + #include "mks_hardware_test.h" + #include "draw_ui.h" + + #if ENABLED(POWER_LOSS_RECOVERY) + #include "../../../../feature/powerloss.h" + #endif + + #include + + #if ENABLED(SPI_GRAPHICAL_TFT) + #include "SPI_TFT.h" + #endif + +//#include "../../Configuration.h" +//#include "../../src/core/macros.h" + + 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); + + extern void init_gb2312_font(); + + static lv_disp_buf_t disp_buf; +//static lv_color_t buf[LV_HOR_RES_MAX * 18]; +//static lv_color_t buf[10*5]; +//extern lv_obj_t * scr; + #if ENABLED(SDSUPPORT) + extern void UpdatePic(); + extern void UpdateFont(); + #endif + 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; + + void SysTick_Callback() { + lv_tick_inc(1); + print_time_count(); + } + + void tft_set_cursor(uint16_t x, uint16_t y) { + #if 0 + if (DeviceCode == 0x8989) { + LCD_WriteReg(0x004E, y); //行 + LCD_WriteReg(0x004F, x); //列 + } + else if ((DeviceCode == 0x9919)) { + LCD_WriteReg(0x004E, x); // 行 + LCD_WriteReg(0x004F, y); // 列 + } + else if ((DeviceCode == 0x5761)) { //SSD1963 + LCD_WrtReg(0x002A); + LCD_WrtRAM(x >> 8); + LCD_WrtRAM(x & 0x00FF); + LCD_WrtRAM(HDP >> 8); + LCD_WrtRAM(HDP & 0x00FF); + LCD_WrtReg(0x002B); + LCD_WrtRAM(y >> 8); + LCD_WrtRAM(y & 0x00FF); + LCD_WrtRAM(VDP >> 8); + LCD_WrtRAM(VDP & 0x00FF); + } + else if (DeviceCode == 0x9488) { + ILI9488_WriteCmd(0x002A); + ILI9488_WriteData(x >> 8); + ILI9488_WriteData(x & 0x00FF); + ILI9488_WriteData(x >> 8); + ILI9488_WriteData(x & 0x00FF); + //ILI9488_WriteData(0x01); + //ILI9488_WriteData(0xDF); + ILI9488_WriteCmd(0x002B); + ILI9488_WriteData(y >> 8); + ILI9488_WriteData(y & 0x00FF); + ILI9488_WriteData(y >> 8); + ILI9488_WriteData(y & 0x00FF); + //ILI9488_WriteData(0x01); + //ILI9488_WriteData(0x3F); + } + else { + LCD_WriteReg(0x0020, y); // 行 + LCD_WriteReg(0x0021, 0x13f - x); // 列 + } + #else // if 0 + 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); + #endif // if 0 + } + + void LCD_WriteRAM_Prepare(void) { + #if 0 + if ((DeviceCode == 0x9325) || (DeviceCode == 0x9328) || (DeviceCode == 0x8989)) { + ClrCs + LCD->LCD_REG = R34; + SetCs + } + else { + 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 > 480) || (y > 320)) return; + //} + //**if ( (x>320)||(y>240) ) return; + tft_set_cursor(x, y); /*设置光标位置*/ + + LCD_WriteRAM_Prepare(); /* 开始写入GRAM*/ + //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 ili9320_SetWindows(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, 320 - xEnd); + LCD_WriteReg(0x0053, 320 - 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); + ili9320_SetWindows(0, 0, 480, 320); + LCD_WriteRAM_Prepare(); + //index = (160*480); + for (index = 0; index < 320 * 480; index++) + LCD_IO_WriteData(Color); + //LCD_IO_WriteMultiple(Color, (480*320)); + //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); + } + } + + extern uint16_t ILI9488_ReadRAM(); + + #if DISABLED(SPI_GRAPHICAL_TFT) + + void init_tft() { + uint16_t i; + //************* Start Initial Sequence **********// + + LCD_IO_Init(FSMC_CS_PIN, FSMC_RS_PIN); + + _delay_ms(5); + + LCD_IO_WriteReg(0x00D3); + DeviceCode = ILI9488_ReadRAM(); //dummy read + DeviceCode = ILI9488_ReadRAM(); + DeviceCode = ILI9488_ReadRAM(); + DeviceCode <<= 8; + DeviceCode |= ILI9488_ReadRAM(); + + 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); + //ILI9488_WriteData(0x0068); + //if (gCfgItems.overturn_180 != 0xEE) + //{ + LCD_IO_WriteData(0x0068); + //} + //else + //{ + //ILI9488_WriteData(0x00A8); + //} + + 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++); + LCD_IO_WriteReg(0x0029); + + ili9320_SetWindows(0, 0, 480, 320); + LCD_Clear(0x0000); + + OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH); + } + } + + #endif // if DISABLED(SPI_GRAPHICAL_TFT) + + extern uint8_t bmp_public_buf[17 * 1024]; + void tft_lvgl_init() { + //uint16_t test_id=0; + W25QXX.init(SPI_QUARTER_SPEED); + //test_id=W25QXX.W25QXX_ReadID(); + #if ENABLED(SDSUPPORT) + UpdatePic(); + UpdateFont(); + #endif + + gCfgItems_init(); + ui_cfg_init(); + disp_language_init(); + //spi_flash_read_test(); + + #if ENABLED(SPI_GRAPHICAL_TFT) + SPI_TFT.spi_init(SPI_FULL_SPEED); + SPI_TFT.LCD_init(); + #else + init_tft(); + #endif + + lv_init(); + + lv_disp_buf_init(&disp_buf, bmp_public_buf, NULL, LV_HOR_RES_MAX * 18); /*Initialize the display buffer*/ + + lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ + lv_disp_drv_init(&disp_drv); /*Basic initialization*/ + disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/ + disp_drv.buffer = &disp_buf; /*Assign the buffer to the display*/ + lv_disp_drv_register(&disp_drv); /*Finally register the driver*/ + + lv_indev_drv_t indev_drv; + lv_indev_drv_init(&indev_drv); /*Descriptor of a input device driver*/ + indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/ + indev_drv.read_cb = my_touchpad_read; /*Set your driver function*/ + lv_indev_drv_register(&indev_drv); /*Finally register the driver*/ + + systick_attach_callback(SysTick_Callback); + + init_gb2312_font(); + + tft_style_init(); + + filament_pin_setup(); + + #if ENABLED(POWER_LOSS_RECOVERY) + if (recovery.valid()) { + if (gCfgItems.from_flash_pic == 1) + flash_preview_begin = 1; + else + default_preview_flg = 1; + + uiCfg.print_state = REPRINTING; + + memset(public_buf_m, 0, sizeof(public_buf_m)); + strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m)); + card.printLongPath(public_buf_m); + + strncpy(list_file.long_name[sel_id], card.longFilename, sizeof(list_file.long_name[sel_id])); + + lv_draw_printing(); + } + else + #endif + lv_draw_ready_print(); + + #if ENABLED(MKS_TEST) + Test_GPIO(); + #endif + } + + #if 0 + void LCD_WriteRAM(uint16_t RGB_Code) { + #if 0 + ClrCs + /* Write 16-bit GRAM Reg */ + LCD->LCD_RAM = RGB_Code; + SetCs + #else + LCD_IO_WriteData(RGB_Code); + #endif + } + #endif + + void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) { + #if ENABLED(SPI_GRAPHICAL_TFT) + uint16_t i, width, height; + uint16_t clr_temp; + uint8_t tbuf[480 * 2]; + + SPI_TFT.spi_init(SPI_FULL_SPEED); + + width = area->x2 - area->x1 + 1; + height = area->y2 - area->y1 + 1; + + for (int j = 0; j < height; j++) { + SPI_TFT.SetCursor(0, 0); + SPI_TFT.SetWindows((uint16_t)area->x1, (uint16_t)area->y1 + j, width, 1); + SPI_TFT.LCD_WriteRAM_Prepare(); + + for (i = 0; i < width * 2;) { + clr_temp = (uint16_t)(((uint16_t)color_p->ch.red << 11) + | ((uint16_t)color_p->ch.green << 5) + | ((uint16_t)color_p->ch.blue)); + + tbuf[i] = clr_temp >> 8; + tbuf[i + 1] = clr_temp; + i += 2; + color_p++; + } + SPI_TFT_CS_L; + SPI_TFT_DC_H; + SPI.dmaSend(tbuf, width * 2, true); + SPI_TFT_CS_H; + } + + lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/ + + W25QXX.init(SPI_QUARTER_SPEED); + #else + #if 1 + uint16_t i, width, height; + uint16_t clr_temp; + #if 0 + int32_t x, y; + for (y = area->y1; y <= area->y2; y++) + for (x = area->x1; x <= area->x2; x++) { + //set_pixel(x, y, *color_p); /* Put a pixel to the display.*/ + clr_temp = (uint16_t)(((uint16_t)color_p->ch.red << 11) + | ((uint16_t)color_p->ch.green << 5) + | ((uint16_t)color_p->ch.blue)); + tft_set_point(x, y, clr_temp); + color_p++; + } + + #else + width = area->x2 - area->x1 + 1; + height = area->y2 - area->y1 + 1; + //tft_set_cursor((uint16_t)area->x1,(uint16_t)area->y1); + ili9320_SetWindows((uint16_t)area->x1, (uint16_t)area->y1, width, height); + LCD_WriteRAM_Prepare(); + for (i = 0; i < width * height; 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(clr_temp); + color_p++; + } + #endif + + lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/ + #endif + #endif // SPI_GRAPHICAL_TFT + } + + #define TICK_CYCLE 1 + + static int32_t touch_time1 = 0; + + unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick) { + if (lastTick <= curTick) + return (curTick - lastTick) * TICK_CYCLE; + else + return (0xFFFFFFFF - lastTick + curTick) * TICK_CYCLE; + } + + #if ENABLED(SPI_GRAPHICAL_TFT) + + #ifndef USE_XPT2046 + #define USE_XPT2046 1 + #define XPT2046_XY_SWAP 1 + #define XPT2046_X_INV 1 + #define XPT2046_Y_INV 0 + #endif + + #if USE_XPT2046 + #define XPT2046_HOR_RES 480 + #define XPT2046_VER_RES 320 + #define XPT2046_X_MIN 201 + #define XPT2046_Y_MIN 164 + #define XPT2046_X_MAX 3919 + #define XPT2046_Y_MAX 3776 + #define XPT2046_AVG 4 + #define XPT2046_INV 1 + #endif + + #else + + #ifndef USE_XPT2046 + #define USE_XPT2046 1 + #define XPT2046_XY_SWAP 1 + #define XPT2046_X_INV 0 + #define XPT2046_Y_INV 1 + #endif + + #if USE_XPT2046 + #define XPT2046_HOR_RES 480 + #define XPT2046_VER_RES 320 + #define XPT2046_X_MIN 201 + #define XPT2046_Y_MIN 164 + #define XPT2046_X_MAX 3919 + #define XPT2046_Y_MAX 3776 + #define XPT2046_AVG 4 + #define XPT2046_INV 0 + #endif + + #endif + + static void xpt2046_corr(uint16_t *x, uint16_t *y) { + #if XPT2046_XY_SWAP + int16_t swap_tmp; + swap_tmp = *x; + *x = *y; + *y = swap_tmp; + #endif + if ((*x) > XPT2046_X_MIN) (*x) -= XPT2046_X_MIN; else (*x) = 0; + if ((*y) > XPT2046_Y_MIN) (*y) -= XPT2046_Y_MIN; else (*y) = 0; + (*x) = uint32_t(uint32_t(*x) * XPT2046_HOR_RES) / (XPT2046_X_MAX - XPT2046_X_MIN); + (*y) = uint32_t(uint32_t(*y) * XPT2046_VER_RES) / (XPT2046_Y_MAX - XPT2046_Y_MIN); + #if XPT2046_X_INV + (*x) = XPT2046_HOR_RES - (*x); + #endif + #if XPT2046_Y_INV + (*y) = XPT2046_VER_RES - (*y); + #endif + } + + #define times 4 + #define CHX 0x90// 0x90 + #define CHY 0xD0// 0xD0 + + int SPI2_ReadWrite2Bytes(void) { + volatile uint16_t ans = 0; + uint16_t temp = 0; + #if ENABLED(SPI_GRAPHICAL_TFT) + temp = SPI_TFT.spi_read_write_byte(0xFF); + ans = temp << 8; + temp = SPI_TFT.spi_read_write_byte(0xFF); + ans |= temp; + ans >>= 3; + #else + temp = W25QXX.spi_flash_read_write_byte(0xFF); + ans = temp << 8; + temp = W25QXX.spi_flash_read_write_byte(0xFF); + ans |= temp; + ans >>= 3; + #endif + return ans & 0x0FFF; + } + + uint16_t x_addata[times], y_addata[times]; + void XPT2046_Rd_Addata(uint16_t *X_Addata, uint16_t *Y_Addata) { + uint16_t i, j, k; + //int result; + //#if ENABLED(TOUCH_BUTTONS) + + #if ENABLED(SPI_GRAPHICAL_TFT) + SPI_TFT.spi_init(SPI_QUARTER_SPEED); + #endif + + for (i = 0; i < times; i++) { + #if ENABLED(SPI_GRAPHICAL_TFT) + OUT_WRITE(TOUCH_CS_PIN, LOW); + SPI_TFT.spi_read_write_byte(CHX); + y_addata[i] = SPI2_ReadWrite2Bytes(); + WRITE(TOUCH_CS_PIN, HIGH); + + OUT_WRITE(TOUCH_CS_PIN, LOW); + SPI_TFT.spi_read_write_byte(CHY); + x_addata[i] = SPI2_ReadWrite2Bytes(); + WRITE(TOUCH_CS_PIN, HIGH); + #else // #if ENABLED(TOUCH_BUTTONS) + OUT_WRITE(TOUCH_CS_PIN, LOW); + W25QXX.spi_flash_read_write_byte(CHX); + y_addata[i] = SPI2_ReadWrite2Bytes(); + WRITE(TOUCH_CS_PIN, HIGH); + + OUT_WRITE(TOUCH_CS_PIN, LOW); + W25QXX.spi_flash_read_write_byte(CHY); + x_addata[i] = SPI2_ReadWrite2Bytes(); + WRITE(TOUCH_CS_PIN, HIGH); + #endif + + } + //#endif + //result = x_addata[0]; + for (i = 0; i < times; i++) + for (j = i + 1; j < times; j++) + if (x_addata[j] > x_addata[i]) { + k = x_addata[j]; + x_addata[j] = x_addata[i]; + x_addata[i] = k; + } + if (x_addata[times / 2 - 1] - x_addata[times / 2] > 50) { + *X_Addata = *Y_Addata = 0; + return; + } + + *X_Addata = (x_addata[times / 2 - 1] + x_addata[times / 2]) / 2; + + //result = y_addata[0]; + for (i = 0; i < times; i++) + for (j = i + 1; j < times; j++) + if (y_addata[j] > y_addata[i]) { + k = y_addata[j]; + y_addata[j] = y_addata[i]; + y_addata[i] = k; + } + + if (y_addata[times / 2 - 1] - y_addata[times / 2] > 50) { + *X_Addata = *Y_Addata = 0; + return; + } + + *Y_Addata = (y_addata[times / 2 - 1] + y_addata[times / 2]) / 2; + } + + #define ADC_VALID_OFFSET 10 + + uint8_t TOUCH_PressValid(uint16_t _usX, uint16_t _usY) { + if ((_usX <= ADC_VALID_OFFSET) || (_usY <= ADC_VALID_OFFSET) + || (_usX >= 4095 - ADC_VALID_OFFSET) || (_usY >= 4095 - ADC_VALID_OFFSET) + ) return 0; + + return 1; + } + + static lv_coord_t last_x = 0, last_y = 0; + bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) { + #if 1 + uint32_t tmpTime, diffTime = 0; + + tmpTime = millis(); + diffTime = getTickDiff(tmpTime, touch_time1); + /*Save the state and save the pressed coordinate*/ + //data->state = TOUCH_PressValid(last_x, last_y) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; + //if (data->state == LV_INDEV_STATE_PR) ADS7843_Rd_Addata((u16 *)&last_x, (u16 *)&last_y); + //touchpad_get_xy(&last_x, &last_y); + /*Save the pressed coordinates and the state*/ + if (diffTime > 10) { + XPT2046_Rd_Addata((uint16_t *)&last_x, (uint16_t *)&last_y); + if (TOUCH_PressValid(last_x, last_y)) { + + data->state = LV_INDEV_STATE_PR; + + /*Set the coordinates (if released use the last pressed coordinates)*/ + + xpt2046_corr((uint16_t *)&last_x, (uint16_t *)&last_y); + data->point.x = last_x; + data->point.y = last_y; + + } + else { + data->state = LV_INDEV_STATE_REL; + } + touch_time1 = tmpTime; + } + + return false; /*Return `false` because we are not buffering and no more data to read*/ + #endif + } + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h new file mode 100644 index 0000000..c1e40e7 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h @@ -0,0 +1,46 @@ +/** + * 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 + +/** + * @file tft_lvgl_configuration.h + * @date 2020-02-21 + * */ + +//#ifdef __cplusplus +//extern "C" { +//#endif + +#include "lvgl.h" + +void tft_lvgl_init(); +void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p); +bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data); + +void LCD_Clear(uint16_t Color); +void tft_set_point(uint16_t x, uint16_t y, uint16_t point); +void ili9320_SetWindows(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh); +void LCD_WriteRAM_Prepare(void); + +//#ifdef __cplusplus +//} /* extern "C" */ +//#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp new file mode 100644 index 0000000..9874d24 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp @@ -0,0 +1,1903 @@ +/** + * 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(TFT_LITTLE_VGL_UI) + +#include "../../../../MarlinCore.h" + +#include "draw_ui.h" +#include "tft_multi_language.h" + +//********************************************// + +//*********************************************// + +common_menu_def common_menu; +main_menu_def main_menu; +preheat_menu_def preheat_menu; +move_menu_def move_menu; +home_menu_def home_menu; +file_menu_def file_menu; +extrude_menu_def extrude_menu; +leveling_menu_def leveling_menu; +set_menu_def set_menu; +more_menu_def more_menu; +wifi_menu_def wifi_menu; +cloud_menu_def cloud_menu; +about_menu_def about_menu; +fan_menu_def fan_menu; +filament_menu_def filament_menu; +printing_menu_def printing_menu; +operation_menu_def operation_menu; +pause_menu_def pause_menu; +speed_menu_def speed_menu; +printing_more_menu_def printing_more_menu; +dialog_menu_def dialog_menu; +language_menu_def language_menu; +print_file_dialog_menu_def print_file_dialog_menu; +filesys_menu_def filesys_menu; +zoffset_menu_def zoffset_menu; +tool_menu_def tool_menu; +MachinePara_menu_def MachinePara_menu; +MachineSettings_menu_def MachineSettings_menu; +TemperatureSettings_menu_def TemperatureSettings_menu; +pause_msg_def pause_msg_menu; + +void disp_language_init() { + preheat_menu.value_state = TEXT_VALUE; + preheat_menu.step_1c = TEXT_1C; + preheat_menu.step_5c = TEXT_5C; + preheat_menu.step_10c = TEXT_10C; + + move_menu.x_add = AXIS_X_ADD_TEXT; + move_menu.x_dec = AXIS_X_DEC_TEXT; + move_menu.y_add = AXIS_Y_ADD_TEXT; + move_menu.y_dec = AXIS_Y_DEC_TEXT; + move_menu.z_add = AXIS_Z_ADD_TEXT; + move_menu.z_dec = AXIS_Z_DEC_TEXT; + + move_menu.step_001mm = TEXT_001MM; + move_menu.step_005mm = TEXT_005MM; + move_menu.step_01mm = TEXT_01MM; + move_menu.step_1mm = TEXT_1MM; + move_menu.step_10mm = TEXT_10MM; + + home_menu.home_x = HOME_X_TEXT; + home_menu.home_y = HOME_Y_TEXT; + home_menu.home_z = HOME_Z_TEXT; + home_menu.home_all = HOME_ALL_TEXT; + + extrude_menu.temp_value = TEXT_VALUE_T; + extrude_menu.count_value_mm = TEXT_VALUE_mm; + extrude_menu.count_value_cm = TEXT_VALUE_cm; + extrude_menu.count_value_m = TEXT_VALUE_m; + extrude_menu.step_1mm = EXTRUDE_1MM_TEXT; + extrude_menu.step_5mm = EXTRUDE_5MM_TEXT; + extrude_menu.step_10mm = EXTRUDE_10MM_TEXT; + + fan_menu.full = FAN_OPEN_TEXT; + fan_menu.half = FAN_HALF_TEXT; + fan_menu.off = FAN_CLOSE_TEXT; + + speed_menu.step_1percent = STEP_1PERCENT; + speed_menu.step_5percent = STEP_5PERCENT; + speed_menu.step_10percent = STEP_10PERCENT; + + language_menu.chinese_s = LANGUAGE_S_CN; + language_menu.chinese_t = LANGUAGE_T_CN; + language_menu.english = LANGUAGE_EN; + language_menu.russian = LANGUAGE_RU; + language_menu.spanish = LANGUAGE_SP; + language_menu.german = LANGUAGE_GE; + language_menu.japan = LANGUAGE_JP; + language_menu.korean = LANGUAGE_KR; + language_menu.portuguese = LANGUAGE_PR; + language_menu.italy = LANGUAGE_IT; + language_menu.brazil = LANGUAGE_BR; + language_menu.french = LANGUAGE_FR; + + about_menu.type_name = ABOUT_TYPE_TEXT; + about_menu.firmware_v = ABOUT_VERSION_TEXT; + //about_menu.wifi = ABOUT_WIFI_TEXT; + + wifi_menu.ip = WIFI_IP_TEXT; + wifi_menu.wifi = WIFI_NAME_TEXT; + wifi_menu.key = WIFI_KEY_TEXT; + wifi_menu.state_ap = WIFI_STATE_AP_TEXT; + wifi_menu.state_sta = WIFI_STATE_STA_TEXT; + wifi_menu.connected = WIFI_CONNECTED_TEXT; + wifi_menu.disconnected = WIFI_DISCONNECTED_TEXT; + wifi_menu.exception = WIFI_EXCEPTION_TEXT; + + printing_menu.temp1 = TEXT_VALUE; + printing_menu.temp2 = TEXT_VALUE; + printing_menu.bed_temp = TEXT_VALUE; + + filament_menu.stat_temp = TEXT_VALUE; + + zoffset_menu.step001 = ZOFFSET_STEP001; + zoffset_menu.step01 = ZOFFSET_STEP01; + zoffset_menu.step1 = ZOFFSET_STEP1; + + //wifi-list + #if 0 + list_menu.title = TEXT_WIFI_MENU_TITLE_EN; + list_menu.file_pages = FILE_PAGES_EN; + //keyboard + keyboard_menu.apply = MANUAL_IP_APPLY_EN; + keyboard_menu.password = TEXT_WIFI_PASSWORD_EN; + keyboard_menu.space = TEXT_WIFI_SAPCE_EN; + keyboard_menu.letter = TEXT_WIFI_LETTER_EN; + keyboard_menu.digital = TEXT_WIFI_DIGITAL_EN; + keyboard_menu.symbol = TEXT_WIFI_SYMBOL_EN; + //tips + tips_menu.pointBold = TEXT_WIFI_POINT_BOLD_EN; + tips_menu.joining = TEXT_WIFI_JOINING_EN; + tips_menu.failedJoin = TEXT_WIFI_FAILED_JOIN_EN; + tips_menu.wifiConected = TEXT_WIFI_WIFI_CONECTED_EN; + #endif + operation_menu.babystep = TEXT_BABY_STEP_EN; + + switch (gCfgItems.language) { + case LANG_SIMPLE_CHINESE: + common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_CN; + common_menu.text_back = BACK_TEXT_CN; + common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_CN; + common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_CN; + common_menu.print_special_title = PRINTING_GBK; + common_menu.pause_special_title = PRINTING_PAUSE_GBK; + common_menu.operate_special_title = PRINTING_OPERATION_GBK; + // + main_menu.title = TITLE_READYPRINT_CN; + main_menu.preheat = PREHEAT_TEXT_CN; + main_menu.move = MOVE_TEXT_CN; + main_menu.home = HOME_TEXT_CN; + main_menu.print = PRINT_TEXT_CN; + main_menu.extrude = EXTRUDE_TEXT_CN; + main_menu.leveling = LEVELING_TEXT_CN; + main_menu.autoleveling = AUTO_LEVELING_TEXT_CN; + main_menu.fan = FAN_TEXT_CN; + main_menu.set = SET_TEXT_CN; + main_menu.more = MORE_TEXT_CN; + main_menu.tool = TOOL_TEXT_CN; + //TOOL + tool_menu.title = TOOL_TEXT_CN; + tool_menu.preheat = TOOL_PREHEAT_CN; + tool_menu.extrude = TOOL_EXTRUDE_CN; + tool_menu.move = TOOL_MOVE_CN; + tool_menu.home = TOOL_HOME_CN; + tool_menu.leveling = TOOL_LEVELING_CN; + tool_menu.autoleveling = TOOL_AUTO_LEVELING_CN; + tool_menu.filament = TOOL_FILAMENT_CN; + tool_menu.more = TOOL_MORE_CN; + // + preheat_menu.adjust_title = TITLE_ADJUST_CN; + preheat_menu.title = TITLE_PREHEAT_CN; + preheat_menu.add = ADD_TEXT_CN; + preheat_menu.dec = DEC_TEXT_CN; + preheat_menu.ext1 = EXTRUDER_1_TEXT_CN; + preheat_menu.ext2 = EXTRUDER_2_TEXT_CN; + preheat_menu.hotbed = HEATBED_TEXT_CN; + preheat_menu.off = CLOSE_TEXT_CN; + + preheat_menu.value_state = TEXT_VALUE_CN; + preheat_menu.step_1c = TEXT_1C_CN; + preheat_menu.step_5c = TEXT_5C_CN; + preheat_menu.step_10c = TEXT_10C_CN; + // + move_menu.title = MOVE_TEXT_CN; + // + home_menu.title = TITLE_HOME_CN; + home_menu.stopmove = HOME_STOPMOVE_CN; + // + file_menu.title = TITLE_CHOOSEFILE_CN; + file_menu.page_up = PAGE_UP_TEXT_CN; + file_menu.page_down = PAGE_DOWN_TEXT_CN; + file_menu.file_loading = FILE_LOADING_CN; + file_menu.no_file = NO_FILE_CN; + file_menu.no_file_and_check = NO_FILE_CN;//NO_FILE_AND_CHECK_CN; + // + extrude_menu.title = TITLE_EXTRUDE_CN; + extrude_menu.in = EXTRUDER_IN_TEXT_CN; + extrude_menu.out = EXTRUDER_OUT_TEXT_CN; + extrude_menu.ext1 = EXTRUDER_1_TEXT_CN; + extrude_menu.ext2 = EXTRUDER_2_TEXT_CN; + extrude_menu.low = EXTRUDE_LOW_SPEED_TEXT_CN; + extrude_menu.normal = EXTRUDE_MEDIUM_SPEED_TEXT_CN; + extrude_menu.high = EXTRUDE_HIGH_SPEED_TEXT_CN; + extrude_menu.temper_text = EXTRUDER_TEMP_TEXT_CN; + extrude_menu.temp_value = EXTRUDE_TEXT_VALUE_T_CN; + // + leveling_menu.title = TITLE_LEVELING_CN; + leveling_menu.position1 = LEVELING_POINT1_TEXT_CN; + leveling_menu.position2 = LEVELING_POINT2_TEXT_CN; + leveling_menu.position3 = LEVELING_POINT3_TEXT_CN; + leveling_menu.position4 = LEVELING_POINT4_TEXT_CN; + leveling_menu.position5 = LEVELING_POINT5_TEXT_CN; + // + set_menu.title = TITLE_SET_CN; + set_menu.filesys = FILESYS_TEXT_CN; + set_menu.wifi = WIFI_TEXT_CN; + set_menu.about = ABOUT_TEXT_CN; + set_menu.fan = FAN_TEXT_CN; + set_menu.filament = FILAMENT_TEXT_CN; + set_menu.breakpoint = BREAK_POINT_TEXT_CN; + set_menu.motoroff = MOTOR_OFF_TEXT_CN; + set_menu.motoroffXY = MOTOR_OFF_XY_TEXT_CN; + set_menu.language = LANGUAGE_TEXT_CN; + set_menu.shutdown = SHUTDOWN_TEXT_CN; + //set_menu.machine_para = MACHINE_PARA_CN; + + // + filesys_menu.title = TITLE_FILESYS_CN; + filesys_menu.sd_sys = SD_CARD_TEXT_CN; + filesys_menu.usb_sys = U_DISK_TEXT_CN; + // + more_menu.title = TITLE_MORE_CN; + more_menu.zoffset = ZOFFSET_CN; + //WIFI + wifi_menu.title = WIFI_TEXT; + //wifi_menu.key = WIFI_KEY_TEXT_CN; + //wifi_menu.ip = WIFI_IP_TEXT_CN; + //wifi_menu.state = WIFI_STA_TEXT_CN; + wifi_menu.cloud = CLOUD_TEXT_CN; + wifi_menu.reconnect = WIFI_RECONNECT_TEXT_CN; + //CLOUD + cloud_menu.title = TITLE_CLOUD_TEXT_CN; + cloud_menu.bind = CLOUD_BINDED_CN; + cloud_menu.binded = CLOUD_BINDED_CN; + cloud_menu.unbind = CLOUD_UNBIND_CN; + cloud_menu.unbinding = CLOUD_UNBINDED_CN; + cloud_menu.disconnected = CLOUD_DISCONNECTED_CN; + cloud_menu.disable = CLOUD_DISABLE_CN; + // + about_menu.title = ABOUT_TEXT_CN; + about_menu.type = ABOUT_TYPE_TEXT_CN; + about_menu.version = ABOUT_VERSION_TEXT_CN; + about_menu.wifi = ABOUT_WIFI_TEXT_CN; + + // + fan_menu.title = FAN_TEXT_CN; + fan_menu.add = FAN_ADD_TEXT_CN; + fan_menu.dec = FAN_DEC_TEXT_CN; + fan_menu.state = FAN_TIPS1_TEXT_CN; + // + filament_menu.title = TITLE_FILAMENT_CN; + filament_menu.in = FILAMENT_IN_TEXT_CN; + filament_menu.out = FILAMENT_OUT_TEXT_CN; + filament_menu.ext1 = FILAMENT_EXT0_TEXT_CN; + filament_menu.ext2 = FILAMENT_EXT1_TEXT_CN; + filament_menu.ready_replace = FILAMENT_CHANGE_TEXT_CN; + filament_menu.filament_dialog_load_heat = FILAMENT_DIALOG_LOAD_HEAT_TIPS_CN; + filament_menu.filament_dialog_load_heat_confirm = FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_CN; + filament_menu.filament_dialog_loading = FILAMENT_DIALOG_LOADING_TIPS_CN; + filament_menu.filament_dialog_load_completed = FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_CN; + filament_menu.filament_dialog_unload_heat = FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_CN; + filament_menu.filament_dialog_unload_heat_confirm = FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_CN; + filament_menu.filament_dialog_unloading = FILAMENT_DIALOG_UNLOADING_TIPS_CN; + filament_menu.filament_dialog_unload_completed = FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_CN; + + + // + language_menu.title = TITLE_LANGUAGE_CN; + language_menu.next = PAGE_DOWN_TEXT_CN; + language_menu.up = PAGE_UP_TEXT_CN; + + // + printing_menu.title = TITLE_PRINTING_CN; + printing_menu.option = PRINTING_OPERATION_CN; + printing_menu.stop = PRINTING_STOP_CN; + printing_menu.pause = PRINTING_PAUSE_CN; + printing_menu.resume = PRINTING_RESUME_CN; + + // + operation_menu.title = TITLE_OPERATION_CN; + operation_menu.pause = PRINTING_PAUSE_CN; + operation_menu.stop = PRINTING_STOP_CN; + operation_menu.temp = PRINTING_TEMP_CN; + operation_menu.fan = FAN_TEXT_CN; + operation_menu.filament = FILAMENT_TEXT_CN; + operation_menu.extr = PRINTING_EXTRUDER_CN; + operation_menu.speed = PRINTING_CHANGESPEED_CN; + operation_menu.more = PRINTING_MORE_CN; + operation_menu.move = PRINTING_MOVE_CN; + operation_menu.auto_off = AUTO_SHUTDOWN_CN; + operation_menu.manual_off = MANUAL_SHUTDOWN_CN; + // + pause_menu.title = TITLE_PAUSE_CN; + pause_menu.resume = PRINTING_RESUME_CN; + pause_menu.stop = PRINTING_STOP_CN; + pause_menu.extrude = PRINTING_EXTRUDER_CN; + pause_menu.move = PRINTING_MOVE_CN; + pause_menu.filament = FILAMENT_TEXT_CN; + pause_menu.more = PRINTING_MORE_CN; + + // + speed_menu.title = PRINTING_CHANGESPEED_CN; + speed_menu.add = ADD_TEXT_CN; + speed_menu.dec = DEC_TEXT_CN; + speed_menu.move = MOVE_SPEED_CN; + speed_menu.extrude = EXTRUDER_SPEED_CN; + speed_menu.extrude_speed = EXTRUDER_SPEED_STATE_CN; + speed_menu.move_speed = MOVE_SPEED_STATE_CN; + // + printing_more_menu.title = TITLE_MORE_CN; + printing_more_menu.fan = FAN_TEXT_CN; + printing_more_menu.auto_close = AUTO_SHUTDOWN_CN; + printing_more_menu.manual = MANUAL_SHUTDOWN_CN; + printing_more_menu.speed = PRINTING_CHANGESPEED_CN; + printing_more_menu.temp = PRINTING_TEMP_CN; + + //print_file_dialog_menu.title = TITLE_DIALOG_CONFIRM_CN; + print_file_dialog_menu.confirm = DIALOG_CONFIRM_CN; + print_file_dialog_menu.cancle = DIALOG_CANCLE_CN; + print_file_dialog_menu.print_file = DIALOG_PRINT_MODEL_CN; + print_file_dialog_menu.cancle_print = DIALOG_CANCEL_PRINT_CN; + print_file_dialog_menu.retry = DIALOG_RETRY_CN; + print_file_dialog_menu.stop = DIALOG_STOP_CN; + print_file_dialog_menu.no_file_print_tips = DIALOG_ERROR_TIPS1_CN; + print_file_dialog_menu.print_from_breakpoint = DIALOG_REPRINT_FROM_BREAKPOINT_CN; + + print_file_dialog_menu.close_machine_error = DIALOG_ERROR_TIPS2_CN; + print_file_dialog_menu.filament_no_press = DIALOG_FILAMENT_NO_PRESS_CN; + + print_file_dialog_menu.print_finish = DIALOG_PRINT_FINISH_CN; + print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_CN; + print_file_dialog_menu.reprint = DIALOG_REPRINT_CN; + print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_CN; + + //ZOFFSET + zoffset_menu.title = TITLE_ZOFFSET_CN; + zoffset_menu.inc = ZOFFSET_INC_CN; + zoffset_menu.dec = ZOFFSET_DEC_CN; + + pause_msg_menu.pausing = MESSEGE_PAUSING_CN; + pause_msg_menu.changing = MESSEGE_CHANGING_CN; + pause_msg_menu.unload = MESSEGE_UNLOAD_CN; + pause_msg_menu.waiting = MESSEGE_WAITING_CN; + pause_msg_menu.insert = MESSEGE_INSERT_CN; + pause_msg_menu.load = MESSEGE_LOAD_CN; + pause_msg_menu.purge = MESSEGE_PURGE_CN; + pause_msg_menu.resume = MESSEGE_RESUME_CN; + pause_msg_menu.heat = MESSEGE_HEAT_CN; + pause_msg_menu.heating = MESSEGE_HEATING_CN; + pause_msg_menu.option = MESSEGE_OPTION_CN; + pause_msg_menu.purgeMore = MESSEGE_PURGE_MORE_CN; + pause_msg_menu.continuePrint = MESSEGE_CONTINUE_PRINT_CN; + break; + + #if 1 + #if 1 + + case LANG_COMPLEX_CHINESE: + common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_T_CN; + common_menu.text_back = BACK_TEXT_T_CN; + common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_T_CN; + common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_T_CN; + common_menu.print_special_title = PRINTING_GBK; + common_menu.pause_special_title = PRINTING_PAUSE_GBK; + common_menu.operate_special_title = PRINTING_OPERATION_GBK; + // + main_menu.title = TITLE_READYPRINT_T_CN; + main_menu.preheat = PREHEAT_TEXT_T_CN; + main_menu.move = MOVE_TEXT_T_CN; + main_menu.home = HOME_TEXT_T_CN; + main_menu.print = PRINT_TEXT_T_CN; + main_menu.extrude = EXTRUDE_TEXT_T_CN; + main_menu.leveling = LEVELING_TEXT_T_CN; + main_menu.autoleveling = AUTO_LEVELING_TEXT_T_CN; + main_menu.fan = FAN_TEXT_T_CN; + main_menu.set = SET_TEXT_T_CN; + main_menu.more = MORE_TEXT_T_CN; + main_menu.tool = TOOL_TEXT_T_CN; + //TOOL + tool_menu.title = TOOL_TEXT_T_CN; + tool_menu.preheat = TOOL_PREHEAT_T_CN; + tool_menu.extrude = TOOL_EXTRUDE_T_CN; + tool_menu.move = TOOL_MOVE_T_CN; + tool_menu.home = TOOL_HOME_T_CN; + tool_menu.leveling = TOOL_LEVELING_T_CN; + tool_menu.autoleveling = TOOL_AUTO_LEVELING_T_CN; + tool_menu.filament = TOOL_FILAMENT_T_CN; + tool_menu.more = TOOL_MORE_T_CN; + // + preheat_menu.adjust_title = TITLE_ADJUST_T_CN; + preheat_menu.title = TITLE_PREHEAT_T_CN; + preheat_menu.add = ADD_TEXT_T_CN; + preheat_menu.dec = DEC_TEXT_T_CN; + preheat_menu.ext1 = EXTRUDER_1_TEXT_T_CN; + preheat_menu.ext2 = EXTRUDER_2_TEXT_T_CN; + preheat_menu.hotbed = HEATBED_TEXT_T_CN; + preheat_menu.off = CLOSE_TEXT_T_CN; + preheat_menu.value_state = TEXT_VALUE_T_CN; + preheat_menu.step_1c = TEXT_1C_T_CN; + preheat_menu.step_5c = TEXT_5C_T_CN; + preheat_menu.step_10c = TEXT_10C_T_CN; + // + move_menu.title = MOVE_TEXT_T_CN; + more_menu.zoffset = ZOFFSET_T_CN; + // + home_menu.title = TITLE_HOME_T_CN; + home_menu.stopmove = HOME_STOPMOVE_T_CN; + // + file_menu.title = TITLE_CHOOSEFILE_T_CN; + file_menu.page_up = PAGE_UP_TEXT_T_CN; + file_menu.page_down = PAGE_DOWN_TEXT_T_CN; + file_menu.file_loading = FILE_LOADING_T_CN; + file_menu.no_file = NO_FILE_T_CN; + file_menu.no_file_and_check = NO_FILE_T_CN;//NO_FILE_AND_CHECK_T_CN; + // + extrude_menu.title = TITLE_EXTRUDE_T_CN; + extrude_menu.in = EXTRUDER_IN_TEXT_T_CN; + extrude_menu.out = EXTRUDER_OUT_TEXT_T_CN; + extrude_menu.ext1 = EXTRUDER_1_TEXT_T_CN; + extrude_menu.ext2 = EXTRUDER_2_TEXT_T_CN; + extrude_menu.low = EXTRUDE_LOW_SPEED_TEXT_T_CN; + extrude_menu.normal = EXTRUDE_MEDIUM_SPEED_TEXT_T_CN; + extrude_menu.high = EXTRUDE_HIGH_SPEED_TEXT_T_CN; + extrude_menu.temper_text = EXTRUDER_TEMP_TEXT_T_CN; + extrude_menu.temp_value = EXTRUDE_TEXT_VALUE_T_T_CN; + // + leveling_menu.title = TITLE_LEVELING_CN; + leveling_menu.position1 = LEVELING_POINT1_TEXT_T_CN; + leveling_menu.position2 = LEVELING_POINT2_TEXT_T_CN; + leveling_menu.position3 = LEVELING_POINT3_TEXT_T_CN; + leveling_menu.position4 = LEVELING_POINT4_TEXT_T_CN; + leveling_menu.position5 = LEVELING_POINT5_TEXT_T_CN; + // + set_menu.title = TITLE_SET_T_CN; + set_menu.filesys = FILESYS_TEXT_T_CN; + set_menu.wifi = WIFI_TEXT_T_CN; + set_menu.about = ABOUT_TEXT_T_CN; + set_menu.fan = FAN_TEXT_T_CN; + set_menu.filament = FILAMENT_TEXT_T_CN; + set_menu.breakpoint = BREAK_POINT_TEXT_T_CN; + set_menu.motoroff = MOTOR_OFF_TEXT_T_CN; + set_menu.motoroffXY = MOTOR_OFF_XY_TEXT_T_CN; + set_menu.language = LANGUAGE_TEXT_T_CN; + set_menu.shutdown = SHUTDOWN_TEXT_T_CN; + //set_menu.machine_para = MACHINE_PARA_T_CN; + // + filesys_menu.title = TITLE_FILESYS_T_CN; + filesys_menu.sd_sys = SD_CARD_TEXT_T_CN; + filesys_menu.usb_sys = U_DISK_TEXT_T_CN; + // + more_menu.title = TITLE_MORE_T_CN; + //WIFI + wifi_menu.title = WIFI_TEXT; + //wifi_menu.key = WIFI_KEY_TEXT_CN; + //wifi_menu.ip = WIFI_IP_TEXT_CN; + //wifi_menu.state = WIFI_STA_TEXT_CN; + wifi_menu.cloud = CLOUD_TEXT_T_CN; + wifi_menu.reconnect = WIFI_RECONNECT_TEXT_T_CN; + //CLOUD + cloud_menu.title = TITLE_CLOUD_TEXT_T_CN; + cloud_menu.bind = CLOUD_BINDED_T_CN; + cloud_menu.binded = CLOUD_BINDED_T_CN; + cloud_menu.unbind = CLOUD_UNBIND_T_CN; + cloud_menu.unbinding = CLOUD_UNBINDED_T_CN; + cloud_menu.disconnected = CLOUD_DISCONNECTED_T_CN; + cloud_menu.disable = CLOUD_DISABLE_T_CN; + // + about_menu.title = ABOUT_TEXT_T_CN; + about_menu.type = ABOUT_TYPE_TEXT_T_CN; + about_menu.version = ABOUT_VERSION_TEXT_T_CN; + about_menu.wifi = ABOUT_WIFI_TEXT_T_CN; + + // + fan_menu.title = FAN_TEXT_T_CN; + fan_menu.add = FAN_ADD_TEXT_T_CN; + fan_menu.dec = FAN_DEC_TEXT_T_CN; + fan_menu.state = FAN_TIPS1_TEXT_T_CN; + // + filament_menu.title = TITLE_FILAMENT_T_CN; + filament_menu.in = FILAMENT_IN_TEXT_T_CN; + filament_menu.out = FILAMENT_OUT_TEXT_T_CN; + filament_menu.ext1 = FILAMENT_EXT0_TEXT_T_CN; + filament_menu.ext2 = FILAMENT_EXT1_TEXT_T_CN; + filament_menu.ready_replace = FILAMENT_CHANGE_TEXT_T_CN; + filament_menu.filament_dialog_load_heat = FILAMENT_DIALOG_LOAD_HEAT_TIPS_T_CN; + filament_menu.filament_dialog_load_heat_confirm = FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_T_CN; + filament_menu.filament_dialog_loading = FILAMENT_DIALOG_LOADING_TIPS_T_CN; + filament_menu.filament_dialog_load_completed = FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_T_CN; + filament_menu.filament_dialog_unload_heat = FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_T_CN; + filament_menu.filament_dialog_unload_heat_confirm = FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_T_CN; + filament_menu.filament_dialog_unloading = FILAMENT_DIALOG_UNLOADING_TIPS_T_CN; + filament_menu.filament_dialog_unload_completed = FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_T_CN; + + + // + language_menu.title = TITLE_LANGUAGE_T_CN; + language_menu.next = PAGE_DOWN_TEXT_T_CN; + language_menu.up = PAGE_UP_TEXT_T_CN; + + // + printing_menu.title = TITLE_PRINTING_T_CN; + printing_menu.option = PRINTING_OPERATION_T_CN; + printing_menu.stop = PRINTING_STOP_T_CN; + printing_menu.pause = PRINTING_PAUSE_T_CN; + printing_menu.resume = PRINTING_RESUME_T_CN; + + // + operation_menu.title = TITLE_OPERATION_T_CN; + operation_menu.pause = PRINTING_PAUSE_T_CN; + operation_menu.stop = PRINTING_STOP_T_CN; + operation_menu.temp = PRINTING_TEMP_T_CN; + operation_menu.fan = FAN_TEXT_T_CN; + operation_menu.extr = PRINTING_EXTRUDER_T_CN; + operation_menu.speed = PRINTING_CHANGESPEED_T_CN; + operation_menu.filament = FILAMENT_TEXT_T_CN; + operation_menu.more = PRINTING_MORE_T_CN; + operation_menu.move = PRINTING_MOVE_T_CN; + operation_menu.auto_off = AUTO_SHUTDOWN_T_CN; + operation_menu.manual_off = MANUAL_SHUTDOWN_T_CN; + // + pause_menu.title = TITLE_PAUSE_T_CN; + pause_menu.resume = PRINTING_RESUME_T_CN; + pause_menu.stop = PRINTING_STOP_T_CN; + pause_menu.extrude = PRINTING_EXTRUDER_T_CN; + pause_menu.move = PRINTING_MOVE_T_CN; + pause_menu.filament = FILAMENT_TEXT_T_CN; + pause_menu.more = PRINTING_MORE_T_CN; + + // + speed_menu.title = PRINTING_CHANGESPEED_T_CN; + speed_menu.add = ADD_TEXT_T_CN; + speed_menu.dec = DEC_TEXT_T_CN; + speed_menu.move = MOVE_SPEED_T_CN; + speed_menu.extrude = EXTRUDER_SPEED_T_CN; + speed_menu.extrude_speed = EXTRUDER_SPEED_STATE_T_CN; + speed_menu.move_speed = MOVE_SPEED_STATE_T_CN; + // + printing_more_menu.title = TITLE_MORE_T_CN; + printing_more_menu.fan = FAN_TEXT_T_CN; + printing_more_menu.auto_close = AUTO_SHUTDOWN_T_CN; + printing_more_menu.manual = MANUAL_SHUTDOWN_T_CN; + printing_more_menu.speed = PRINTING_CHANGESPEED_T_CN; + printing_more_menu.temp = PRINTING_TEMP_T_CN; + + //print_file_dialog_menu.title = TITLE_DIALOG_CONFIRM_CN; + print_file_dialog_menu.confirm = DIALOG_CONFIRM_T_CN; + print_file_dialog_menu.cancle = DIALOG_CANCLE_T_CN; + print_file_dialog_menu.print_file = DIALOG_PRINT_MODEL_T_CN; + print_file_dialog_menu.cancle_print = DIALOG_CANCEL_PRINT_T_CN; + print_file_dialog_menu.retry = DIALOG_RETRY_T_CN; + print_file_dialog_menu.stop = DIALOG_STOP_T_CN; + print_file_dialog_menu.no_file_print_tips = DIALOG_ERROR_TIPS1_T_CN; + print_file_dialog_menu.print_from_breakpoint = DIALOG_REPRINT_FROM_BREAKPOINT_T_CN; + + print_file_dialog_menu.close_machine_error = DIALOG_ERROR_TIPS2_T_CN; + print_file_dialog_menu.filament_no_press = DIALOG_FILAMENT_NO_PRESS_T_CN; + print_file_dialog_menu.print_finish = DIALOG_PRINT_FINISH_T_CN; + print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_T_CN; + print_file_dialog_menu.reprint = DIALOG_REPRINT_T_CN; + print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_T_CN; + //ZOFFSET + zoffset_menu.title = TITLE_ZOFFSET_T_CN; + zoffset_menu.inc = ZOFFSET_INC_T_CN; + zoffset_menu.dec = ZOFFSET_DEC_T_CN; + + pause_msg_menu.pausing = MESSEGE_PAUSING_T_CN; + pause_msg_menu.changing = MESSEGE_CHANGING_T_CN; + pause_msg_menu.unload = MESSEGE_UNLOAD_T_CN; + pause_msg_menu.waiting = MESSEGE_WAITING_T_CN; + pause_msg_menu.insert = MESSEGE_INSERT_T_CN; + pause_msg_menu.load = MESSEGE_LOAD_T_CN; + pause_msg_menu.purge = MESSEGE_PURGE_T_CN; + pause_msg_menu.resume = MESSEGE_RESUME_T_CN; + pause_msg_menu.heat = MESSEGE_HEAT_T_CN; + pause_msg_menu.heating = MESSEGE_HEATING_T_CN; + pause_msg_menu.option = MESSEGE_OPTION_T_CN; + pause_msg_menu.purgeMore = MESSEGE_PURGE_MORE_T_CN; + pause_msg_menu.continuePrint = MESSEGE_CONTINUE_PRINT_T_CN; + break; + case LANG_ENGLISH: + common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_EN; + common_menu.text_back = BACK_TEXT_EN; + common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_EN; + common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_EN; + common_menu.print_special_title = PRINTING_OTHER_LANGUGE; + common_menu.pause_special_title = PRINTING_PAUSE_OTHER_LANGUGE; + common_menu.operate_special_title = PRINTING_OPERATION_OTHER_LANGUGE; + // + main_menu.title = TITLE_READYPRINT_EN; + main_menu.preheat = PREHEAT_TEXT_EN; + main_menu.move = MOVE_TEXT_EN; + main_menu.home = HOME_TEXT_EN; + main_menu.print = PRINT_TEXT_EN; + main_menu.extrude = EXTRUDE_TEXT_EN; + main_menu.leveling = LEVELING_TEXT_EN; + main_menu.autoleveling = AUTO_LEVELING_TEXT_EN; + main_menu.fan = FAN_TEXT_EN; + main_menu.set = SET_TEXT_EN; + main_menu.more = MORE_TEXT_EN; + main_menu.tool = TOOL_TEXT_EN; + //TOOL + tool_menu.title = TOOL_TEXT_EN; + tool_menu.preheat = TOOL_PREHEAT_EN; + tool_menu.extrude = TOOL_EXTRUDE_EN; + tool_menu.move = TOOL_MOVE_EN; + tool_menu.home = TOOL_HOME_EN; + tool_menu.leveling = TOOL_LEVELING_EN; + tool_menu.autoleveling = TOOL_AUTO_LEVELING_EN; + tool_menu.filament = TOOL_FILAMENT_EN; + tool_menu.more = TOOL_MORE_EN; + // + preheat_menu.adjust_title = TITLE_ADJUST_EN; + preheat_menu.title = TITLE_PREHEAT_EN; + preheat_menu.add = ADD_TEXT_EN; + preheat_menu.dec = DEC_TEXT_EN; + preheat_menu.ext1 = EXTRUDER_1_TEXT_EN; + preheat_menu.ext2 = EXTRUDER_2_TEXT_EN; + preheat_menu.hotbed = HEATBED_TEXT_EN; + preheat_menu.off = CLOSE_TEXT_EN; + // + move_menu.title = TITLE_MOVE_EN; + // + home_menu.title = TITLE_HOME_EN; + home_menu.stopmove = HOME_STOPMOVE_EN; + // + file_menu.title = TITLE_CHOOSEFILE_EN; + file_menu.page_up = PAGE_UP_TEXT_EN; + file_menu.page_down = PAGE_DOWN_TEXT_EN; + file_menu.file_loading = FILE_LOADING_EN; + file_menu.no_file = NO_FILE_EN; + file_menu.no_file_and_check = NO_FILE_EN;//NO_FILE_AND_CHECK_EN; + // + extrude_menu.title = TITLE_EXTRUDE_EN; + extrude_menu.in = EXTRUDER_IN_TEXT_EN; + extrude_menu.out = EXTRUDER_OUT_TEXT_EN; + extrude_menu.ext1 = EXTRUDER_1_TEXT_EN; + extrude_menu.ext2 = EXTRUDER_2_TEXT_EN; + extrude_menu.low = EXTRUDE_LOW_SPEED_TEXT_EN; + extrude_menu.normal = EXTRUDE_MEDIUM_SPEED_TEXT_EN; + extrude_menu.high = EXTRUDE_HIGH_SPEED_TEXT_EN; + extrude_menu.temper_text = EXTRUDER_TEMP_TEXT_EN; + // + leveling_menu.title = TITLE_LEVELING_EN; + leveling_menu.position1 = LEVELING_POINT1_TEXT_EN; + leveling_menu.position2 = LEVELING_POINT2_TEXT_EN; + leveling_menu.position3 = LEVELING_POINT3_TEXT_EN; + leveling_menu.position4 = LEVELING_POINT4_TEXT_EN; + leveling_menu.position5 = LEVELING_POINT5_TEXT_EN; + // + set_menu.title = TITLE_SET_EN; + set_menu.filesys = FILESYS_TEXT_EN; + set_menu.wifi = WIFI_TEXT_EN; + set_menu.about = ABOUT_TEXT_EN; + set_menu.fan = FAN_TEXT_EN; + set_menu.filament = FILAMENT_TEXT_EN; + set_menu.breakpoint = BREAK_POINT_TEXT_EN; + set_menu.motoroff = MOTOR_OFF_TEXT_EN; + set_menu.motoroffXY = MOTOR_OFF_XY_TEXT_EN; + set_menu.language = LANGUAGE_TEXT_EN; + set_menu.shutdown = SHUTDOWN_TEXT_EN; + //set_menu.machine_para = MACHINE_PARA_EN; + // + more_menu.title = TITLE_MORE_EN; + more_menu.zoffset = ZOFFSET_EN; + // + filesys_menu.title = TITLE_FILESYS_EN; + filesys_menu.sd_sys = SD_CARD_TEXT_EN; + filesys_menu.usb_sys = U_DISK_TEXT_EN; + //WIFI + wifi_menu.title = WIFI_TEXT; + //wifi_menu.key = WIFI_KEY_TEXT_EN; + //wifi_menu.ip = WIFI_IP_TEXT_EN; + //wifi_menu.state = WIFI_STA_TEXT_EN; + wifi_menu.cloud = CLOUD_TEXT_EN; + wifi_menu.reconnect = WIFI_RECONNECT_TEXT_EN; + + cloud_menu.title = TITLE_CLOUD_TEXT_EN; + cloud_menu.bind = CLOUD_BINDED_EN; + cloud_menu.binded = CLOUD_BINDED_EN; + cloud_menu.unbind = CLOUD_UNBIND_EN; + cloud_menu.unbinding = CLOUD_UNBINDED_EN; + cloud_menu.disconnected = CLOUD_DISCONNECTED_EN; + cloud_menu.disable = CLOUD_DISABLE_EN; + // + about_menu.title = TITLE_ABOUT_EN; + about_menu.type = ABOUT_TYPE_TEXT_EN; + about_menu.version = ABOUT_VERSION_TEXT_EN; + about_menu.wifi = ABOUT_WIFI_TEXT_EN; + // + fan_menu.title = TITLE_FAN_EN; + fan_menu.add = FAN_ADD_TEXT_EN; + fan_menu.dec = FAN_DEC_TEXT_EN; + fan_menu.state = FAN_TIPS1_TEXT_EN; + // + filament_menu.title = TITLE_FILAMENT_EN; + filament_menu.in = FILAMENT_IN_TEXT_EN; + filament_menu.out = FILAMENT_OUT_TEXT_EN; + filament_menu.ext1 = FILAMENT_EXT0_TEXT_EN; + filament_menu.ext2 = FILAMENT_EXT1_TEXT_EN; + filament_menu.ready_replace = FILAMENT_CHANGE_TEXT_EN; + filament_menu.filament_dialog_load_heat = FILAMENT_DIALOG_LOAD_HEAT_TIPS_EN; + filament_menu.filament_dialog_load_heat_confirm = FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_EN; + filament_menu.filament_dialog_loading = FILAMENT_DIALOG_LOADING_TIPS_EN; + filament_menu.filament_dialog_load_completed = FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_EN; + filament_menu.filament_dialog_unload_heat = FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_EN; + filament_menu.filament_dialog_unload_heat_confirm = FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_EN; + filament_menu.filament_dialog_unloading = FILAMENT_DIALOG_UNLOADING_TIPS_EN; + filament_menu.filament_dialog_unload_completed = FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_EN; + + // + language_menu.title = TITLE_LANGUAGE_EN; + language_menu.next = PAGE_DOWN_TEXT_EN; + language_menu.up = PAGE_UP_TEXT_EN; + // + printing_menu.title = TITLE_PRINTING_EN; + printing_menu.option = PRINTING_OPERATION_EN; + printing_menu.stop = PRINTING_STOP_EN; + printing_menu.pause = PRINTING_PAUSE_EN; + printing_menu.resume = PRINTING_RESUME_EN; + + // + operation_menu.title = TITLE_OPERATION_EN; + operation_menu.pause = PRINTING_PAUSE_EN; + operation_menu.stop = PRINTING_STOP_EN; + operation_menu.temp = PRINTING_TEMP_EN; + operation_menu.fan = FAN_TEXT_EN; + operation_menu.extr = PRINTING_EXTRUDER_EN; + operation_menu.speed = PRINTING_CHANGESPEED_EN; + operation_menu.filament = FILAMENT_TEXT_EN; + operation_menu.more = PRINTING_MORE_EN; + operation_menu.move = PRINTING_MOVE_EN; + operation_menu.auto_off = AUTO_SHUTDOWN_EN; + operation_menu.manual_off = MANUAL_SHUTDOWN_EN; + // + pause_menu.title = TITLE_PAUSE_EN; + pause_menu.resume = PRINTING_RESUME_EN; + pause_menu.stop = PRINTING_STOP_EN; + pause_menu.extrude = PRINTING_EXTRUDER_EN; + pause_menu.move = PRINTING_MOVE_EN; + pause_menu.filament = FILAMENT_TEXT_EN; + pause_menu.more = PRINTING_MORE_EN; + + // + speed_menu.title = TITLE_CHANGESPEED_EN; + speed_menu.add = ADD_TEXT_EN; + speed_menu.dec = DEC_TEXT_EN; + speed_menu.move = MOVE_SPEED_EN; + speed_menu.extrude = EXTRUDER_SPEED_EN; + speed_menu.extrude_speed = EXTRUDER_SPEED_STATE_EN; + speed_menu.move_speed = MOVE_SPEED_STATE_EN; + // + printing_more_menu.title = TITLE_MORE_EN; + printing_more_menu.fan = FAN_TEXT_EN; + printing_more_menu.auto_close = AUTO_SHUTDOWN_EN; + printing_more_menu.manual = MANUAL_SHUTDOWN_EN; + printing_more_menu.speed = PRINTING_CHANGESPEED_EN; + printing_more_menu.temp = PRINTING_TEMP_EN; + + //print_file_dialog_menu.title = TITLE_DIALOG_CONFIRM_EN; + print_file_dialog_menu.confirm = DIALOG_CONFIRM_EN; + print_file_dialog_menu.cancle = DIALOG_CANCLE_EN; + print_file_dialog_menu.print_file = DIALOG_PRINT_MODEL_EN; + print_file_dialog_menu.cancle_print = DIALOG_CANCEL_PRINT_EN; + print_file_dialog_menu.retry = DIALOG_RETRY_EN; + print_file_dialog_menu.stop = DIALOG_STOP_EN; + print_file_dialog_menu.no_file_print_tips = DIALOG_ERROR_TIPS1_EN; + print_file_dialog_menu.print_from_breakpoint = DIALOG_REPRINT_FROM_BREAKPOINT_EN; + print_file_dialog_menu.close_machine_error = DIALOG_ERROR_TIPS2_EN; + print_file_dialog_menu.filament_no_press = DIALOG_FILAMENT_NO_PRESS_EN; + print_file_dialog_menu.print_finish = DIALOG_PRINT_FINISH_EN; + print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_EN; + print_file_dialog_menu.reprint = DIALOG_REPRINT_EN; + print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_EN; + //ZOFFSET + zoffset_menu.title = TITLE_ZOFFSET_EN; + zoffset_menu.inc = ZOFFSET_INC_EN; + zoffset_menu.dec = ZOFFSET_DEC_EN; + + pause_msg_menu.pausing = MESSEGE_PAUSING_EN; + pause_msg_menu.changing = MESSEGE_CHANGING_EN; + pause_msg_menu.unload = MESSEGE_UNLOAD_EN; + pause_msg_menu.waiting = MESSEGE_WAITING_EN; + pause_msg_menu.insert = MESSEGE_INSERT_EN; + pause_msg_menu.load = MESSEGE_LOAD_EN; + pause_msg_menu.purge = MESSEGE_PURGE_EN; + pause_msg_menu.resume = MESSEGE_RESUME_EN; + pause_msg_menu.heat = MESSEGE_HEAT_EN; + pause_msg_menu.heating = MESSEGE_HEATING_EN; + pause_msg_menu.option = MESSEGE_OPTION_EN; + pause_msg_menu.purgeMore = MESSEGE_PURGE_MORE_EN; + pause_msg_menu.continuePrint = MESSEGE_CONTINUE_PRINT_EN; + break; + case LANG_RUSSIAN: + common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_RU; + common_menu.text_back = BACK_TEXT_RU; + common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_RU; + common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_RU; + common_menu.print_special_title = PRINTING_OTHER_LANGUGE; + common_menu.pause_special_title = PRINTING_PAUSE_OTHER_LANGUGE; + common_menu.operate_special_title = PRINTING_OPERATION_OTHER_LANGUGE; + // + main_menu.title = TITLE_READYPRINT_RU; + main_menu.preheat = PREHEAT_TEXT_RU; + main_menu.move = MOVE_TEXT_RU; + main_menu.home = HOME_TEXT_RU; + main_menu.print = PRINT_TEXT_RU; + main_menu.extrude = EXTRUDE_TEXT_RU; + main_menu.leveling = LEVELING_TEXT_RU; + main_menu.autoleveling = AUTO_LEVELING_TEXT_RU; + main_menu.fan = FAN_TEXT_RU; + main_menu.set = SET_TEXT_RU; + main_menu.more = MORE_TEXT_RU; + main_menu.tool = TOOL_TEXT_RU; + //TOOL + tool_menu.title = TOOL_TEXT_RU; + tool_menu.preheat = TOOL_PREHEAT_RU; + tool_menu.extrude = TOOL_EXTRUDE_RU; + tool_menu.move = TOOL_MOVE_RU; + tool_menu.home = TOOL_HOME_RU; + tool_menu.leveling = TOOL_LEVELING_RU; + tool_menu.autoleveling = TOOL_AUTO_LEVELING_RU; + tool_menu.filament = TOOL_FILAMENT_RU; + tool_menu.more = TOOL_MORE_RU; + // + preheat_menu.adjust_title = TITLE_ADJUST_RU; + preheat_menu.title = TITLE_PREHEAT_RU; + preheat_menu.add = ADD_TEXT_RU; + preheat_menu.dec = DEC_TEXT_RU; + preheat_menu.ext1 = EXTRUDER_1_TEXT_RU; + preheat_menu.ext2 = EXTRUDER_2_TEXT_RU; + preheat_menu.hotbed = HEATBED_TEXT_RU; + preheat_menu.off = CLOSE_TEXT_RU; + // + move_menu.title = MOVE_TEXT_RU; + // + home_menu.title = TITLE_HOME_RU; + home_menu.stopmove = HOME_STOPMOVE_RU; + // + file_menu.title = TITLE_CHOOSEFILE_RU; + file_menu.page_up = PAGE_UP_TEXT_RU; + file_menu.page_down = PAGE_DOWN_TEXT_RU; + file_menu.file_loading = FILE_LOADING_RU; + file_menu.no_file = NO_FILE_RU; + file_menu.no_file_and_check = NO_FILE_RU;//NO_FILE_AND_CHECK_RU; + // + extrude_menu.title = TITLE_EXTRUDE_RU; + extrude_menu.in = EXTRUDER_IN_TEXT_RU; + extrude_menu.out = EXTRUDER_OUT_TEXT_RU; + extrude_menu.ext1 = EXTRUDER_1_TEXT_RU; + extrude_menu.ext2 = EXTRUDER_2_TEXT_RU; + extrude_menu.low = EXTRUDE_LOW_SPEED_TEXT_RU; + extrude_menu.normal = EXTRUDE_MEDIUM_SPEED_TEXT_RU; + extrude_menu.high = EXTRUDE_HIGH_SPEED_TEXT_RU; + extrude_menu.temper_text = EXTRUDER_TEMP_TEXT_RU; + // + leveling_menu.title = TITLE_LEVELING_RU; + leveling_menu.position1 = LEVELING_POINT1_TEXT_RU; + leveling_menu.position2 = LEVELING_POINT2_TEXT_RU; + leveling_menu.position3 = LEVELING_POINT3_TEXT_RU; + leveling_menu.position4 = LEVELING_POINT4_TEXT_RU; + leveling_menu.position5 = LEVELING_POINT5_TEXT_RU; + // + set_menu.title = TITLE_SET_RU; + set_menu.filesys = FILESYS_TEXT_RU; + set_menu.wifi = WIFI_TEXT_RU; + set_menu.about = ABOUT_TEXT_RU; + set_menu.fan = FAN_TEXT_RU; + set_menu.filament = FILAMENT_TEXT_RU; + set_menu.breakpoint = BREAK_POINT_TEXT_RU; + set_menu.motoroff = MOTOR_OFF_TEXT_RU; + set_menu.motoroffXY = MOTOR_OFF_XY_TEXT_RU; + set_menu.language = LANGUAGE_TEXT_RU; + set_menu.shutdown = SHUTDOWN_TEXT_RU; + // + more_menu.title = TITLE_MORE_RU; + more_menu.zoffset = ZOFFSET_RU; + // + filesys_menu.title = TITLE_FILESYS_RU; + filesys_menu.sd_sys = SD_CARD_TEXT_RU; + filesys_menu.usb_sys = U_DISK_TEXT_RU; + //WIFI + wifi_menu.title = WIFI_TEXT; + //wifi_menu.key = WIFI_KEY_TEXT_RU; + //wifi_menu.ip = WIFI_IP_TEXT_RU; + //wifi_menu.state = WIFI_STA_TEXT_RU; + wifi_menu.cloud = CLOUD_TEXT_RU; + wifi_menu.reconnect = WIFI_RECONNECT_TEXT_RU; + + + cloud_menu.title = TITLE_CLOUD_TEXT_RU; + cloud_menu.bind = CLOUD_BINDED_RU; + cloud_menu.binded = CLOUD_BINDED_RU; + cloud_menu.unbind = CLOUD_UNBIND_RU; + cloud_menu.unbinding = CLOUD_UNBINDED_RU; + cloud_menu.disconnected = CLOUD_DISCONNECTED_RU; + cloud_menu.disable = CLOUD_DISABLE_RU; + // + about_menu.title = ABOUT_TEXT_RU; + about_menu.type = ABOUT_TYPE_TEXT_RU; + about_menu.version = ABOUT_VERSION_TEXT_RU; + about_menu.wifi = ABOUT_WIFI_TEXT_RU; + // + fan_menu.title = FAN_TEXT_RU; + fan_menu.add = FAN_ADD_TEXT_RU; + fan_menu.dec = FAN_DEC_TEXT_RU; + fan_menu.state = FAN_TIPS1_TEXT_RU; + // + filament_menu.title = TITLE_FILAMENT_RU; + filament_menu.in = FILAMENT_IN_TEXT_RU; + filament_menu.out = FILAMENT_OUT_TEXT_RU; + filament_menu.ext1 = FILAMENT_EXT0_TEXT_RU; + filament_menu.ext2 = FILAMENT_EXT1_TEXT_RU; + filament_menu.ready_replace = FILAMENT_CHANGE_TEXT_RU; + filament_menu.filament_dialog_load_heat = FILAMENT_DIALOG_LOAD_HEAT_TIPS_RU; + filament_menu.filament_dialog_load_heat_confirm = FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_RU; + filament_menu.filament_dialog_loading = FILAMENT_DIALOG_LOADING_TIPS_RU; + filament_menu.filament_dialog_load_completed = FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_RU; + filament_menu.filament_dialog_unload_heat = FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_RU; + filament_menu.filament_dialog_unload_heat_confirm = FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_RU; + filament_menu.filament_dialog_unloading = FILAMENT_DIALOG_UNLOADING_TIPS_RU; + filament_menu.filament_dialog_unload_completed = FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_RU; + + // + language_menu.title = LANGUAGE_TEXT_RU; + language_menu.next = PAGE_DOWN_TEXT_RU; + language_menu.up = PAGE_UP_TEXT_RU; + // + printing_menu.title = TITLE_PRINTING_RU; + printing_menu.option = PRINTING_OPERATION_RU; + printing_menu.stop = PRINTING_STOP_RU; + printing_menu.pause = PRINTING_PAUSE_RU; + printing_menu.resume = PRINTING_RESUME_RU; + + // + operation_menu.title = TITLE_OPERATION_RU; + operation_menu.pause = PRINTING_PAUSE_RU; + operation_menu.stop = PRINTING_STOP_RU; + operation_menu.temp = PRINTING_TEMP_RU; + operation_menu.fan = FAN_TEXT_RU; + operation_menu.extr = PRINTING_EXTRUDER_RU; + operation_menu.speed = PRINTING_CHANGESPEED_RU; + operation_menu.filament = FILAMENT_TEXT_RU; + operation_menu.more = PRINTING_MORE_RU; + operation_menu.move = PRINTING_MOVE_RU; + operation_menu.auto_off = AUTO_SHUTDOWN_RU; + operation_menu.manual_off = MANUAL_SHUTDOWN_RU; + // + pause_menu.title = TITLE_PAUSE_RU; + pause_menu.resume = PRINTING_RESUME_RU; + pause_menu.stop = PRINTING_STOP_RU; + pause_menu.extrude = PRINTING_EXTRUDER_RU; + pause_menu.move = PRINTING_MOVE_RU; + pause_menu.filament = FILAMENT_TEXT_RU; + pause_menu.more = PRINTING_MORE_RU; + + // + speed_menu.title = PRINTING_CHANGESPEED_RU; + speed_menu.add = ADD_TEXT_RU; + speed_menu.dec = DEC_TEXT_RU; + speed_menu.move = MOVE_SPEED_RU; + speed_menu.extrude = EXTRUDER_SPEED_RU; + speed_menu.extrude_speed = EXTRUDER_SPEED_STATE_RU; + speed_menu.move_speed = MOVE_SPEED_STATE_RU; + // + printing_more_menu.title = TITLE_MORE_RU; + printing_more_menu.fan = FAN_TEXT_RU; + printing_more_menu.auto_close = AUTO_SHUTDOWN_RU; + printing_more_menu.manual = MANUAL_SHUTDOWN_RU; + printing_more_menu.speed = PRINTING_CHANGESPEED_RU; + printing_more_menu.temp = PRINTING_TEMP_RU; + //print_file_dialog_menu.title = TITLE_DIALOG_CONFIRM_RU; + print_file_dialog_menu.confirm = DIALOG_CONFIRM_RU; + print_file_dialog_menu.cancle = DIALOG_CANCLE_RU; + print_file_dialog_menu.print_file = DIALOG_PRINT_MODEL_RU; + print_file_dialog_menu.cancle_print = DIALOG_CANCEL_PRINT_RU; + print_file_dialog_menu.retry = DIALOG_RETRY_RU; + print_file_dialog_menu.stop = DIALOG_STOP_RU; + print_file_dialog_menu.no_file_print_tips = DIALOG_ERROR_TIPS1_RU; + print_file_dialog_menu.print_from_breakpoint = DIALOG_REPRINT_FROM_BREAKPOINT_RU; + print_file_dialog_menu.close_machine_error = DIALOG_ERROR_TIPS2_RU; + print_file_dialog_menu.filament_no_press = DIALOG_FILAMENT_NO_PRESS_RU; + print_file_dialog_menu.print_finish = DIALOG_PRINT_FINISH_RU; + print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_RU; + print_file_dialog_menu.reprint = DIALOG_REPRINT_RU; + print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_RU; + //ZOFFSET + zoffset_menu.title = TITLE_ZOFFSET_RU; + zoffset_menu.inc = ZOFFSET_INC_RU; + zoffset_menu.dec = ZOFFSET_DEC_RU; + + pause_msg_menu.pausing = MESSEGE_PAUSING_RU; + pause_msg_menu.changing = MESSEGE_CHANGING_RU; + pause_msg_menu.unload = MESSEGE_UNLOAD_RU; + pause_msg_menu.waiting = MESSEGE_WAITING_RU; + pause_msg_menu.insert = MESSEGE_INSERT_RU; + pause_msg_menu.load = MESSEGE_LOAD_RU; + pause_msg_menu.purge = MESSEGE_PURGE_RU; + pause_msg_menu.resume = MESSEGE_RESUME_RU; + pause_msg_menu.heat = MESSEGE_HEAT_RU; + pause_msg_menu.heating = MESSEGE_HEATING_RU; + pause_msg_menu.option = MESSEGE_OPTION_RU; + pause_msg_menu.purgeMore = MESSEGE_PURGE_MORE_RU; + pause_msg_menu.continuePrint = MESSEGE_CONTINUE_PRINT_RU; + break; + case LANG_SPANISH: + common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_SP; + common_menu.text_back = BACK_TEXT_SP; + common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_SP; + common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_SP; + common_menu.print_special_title = PRINTING_SP; + common_menu.pause_special_title = PRINTING_PAUSAR_SP; + common_menu.operate_special_title = PRINTING_AJUSTES_SP; + // + main_menu.title = TITLE_READYPRINT_SP; + main_menu.preheat = PREHEAT_TEXT_SP; + main_menu.move = MOVE_TEXT_SP; + main_menu.home = HOME_TEXT_SP; + main_menu.print = PRINT_TEXT_SP; + main_menu.extrude = EXTRUDE_TEXT_SP; + main_menu.leveling = LEVELING_TEXT_SP; + main_menu.autoleveling = AUTO_LEVELING_TEXT_SP; + main_menu.fan = FAN_TEXT_SP; + main_menu.set = SET_TEXT_SP; + main_menu.more = MORE_TEXT_SP; + main_menu.tool = TOOL_TEXT_SP; + //TOOL + tool_menu.title = TOOL_TEXT_SP; + tool_menu.preheat = TOOL_PREHEAT_SP; + tool_menu.extrude = TOOL_EXTRUDE_SP; + tool_menu.move = TOOL_MOVE_SP; + tool_menu.home = TOOL_HOME_SP; + tool_menu.leveling = TOOL_LEVELING_SP; + tool_menu.autoleveling = TOOL_AUTO_LEVELING_SP; + tool_menu.filament = TOOL_FILAMENT_SP; + tool_menu.more = TOOL_MORE_SP; + // + preheat_menu.adjust_title = TITLE_ADJUST_SP; + preheat_menu.title = TITLE_PREHEAT_SP; + preheat_menu.add = ADD_TEXT_SP; + preheat_menu.dec = DEC_TEXT_SP; + preheat_menu.ext1 = EXTRUDER_1_TEXT_SP; + preheat_menu.ext2 = EXTRUDER_2_TEXT_SP; + preheat_menu.hotbed = HEATBED_TEXT_SP; + preheat_menu.off = CLOSE_TEXT_SP; + // + move_menu.title = MOVE_TEXT_SP; + // + home_menu.title = TITLE_HOME_SP; + home_menu.home_x = HOME_X_TEXT_SP; + home_menu.home_y = HOME_Y_TEXT_SP; + home_menu.home_z = HOME_Z_TEXT_SP; + home_menu.home_all = HOME_ALL_TEXT_SP; + home_menu.stopmove = HOME_STOPMOVE_SP; + // + file_menu.title = TITLE_CHOOSEFILE_SP; + file_menu.page_up = PAGE_UP_TEXT_SP; + file_menu.page_down = PAGE_DOWN_TEXT_SP; + file_menu.file_loading = FILE_LOADING_SP; + file_menu.no_file = NO_FILE_SP; + file_menu.no_file_and_check = NO_FILE_SP;//NO_FILE_AND_CHECK_SP; + // + extrude_menu.title = TITLE_EXTRUDE_SP; + extrude_menu.in = EXTRUDER_IN_TEXT_SP; + extrude_menu.out = EXTRUDER_OUT_TEXT_SP; + extrude_menu.ext1 = EXTRUDER_1_TEXT_SP; + extrude_menu.ext2 = EXTRUDER_2_TEXT_SP; + extrude_menu.low = EXTRUDE_LOW_SPEED_TEXT_SP; + extrude_menu.normal = EXTRUDE_MEDIUM_SPEED_TEXT_SP; + extrude_menu.high = EXTRUDE_HIGH_SPEED_TEXT_SP; + extrude_menu.temper_text = EXTRUDER_TEMP_TEXT_SP; + // + leveling_menu.title = TITLE_LEVELING_SP; + leveling_menu.position1 = LEVELING_POINT1_TEXT_SP; + leveling_menu.position2 = LEVELING_POINT2_TEXT_SP; + leveling_menu.position3 = LEVELING_POINT3_TEXT_SP; + leveling_menu.position4 = LEVELING_POINT4_TEXT_SP; + leveling_menu.position5 = LEVELING_POINT5_TEXT_SP; + // + set_menu.title = TITLE_SET_SP; + set_menu.filesys = FILESYS_TEXT_SP; + set_menu.wifi = WIFI_TEXT_SP; + set_menu.about = ABOUT_TEXT_SP; + set_menu.fan = FAN_TEXT_SP; + set_menu.filament = FILAMENT_TEXT_SP; + set_menu.breakpoint = BREAK_POINT_TEXT_SP; + set_menu.motoroff = MOTOR_OFF_TEXT_SP; + set_menu.motoroffXY = MOTOR_OFF_XY_TEXT_SP; + set_menu.language = LANGUAGE_TEXT_SP; + set_menu.shutdown = SHUTDOWN_TEXT_SP; + // + more_menu.title = TITLE_MORE_SP; + more_menu.zoffset = ZOFFSET_SP; + // + filesys_menu.title = TITLE_FILESYS_SP; + filesys_menu.sd_sys = SD_CARD_TEXT_SP; + filesys_menu.usb_sys = U_DISK_TEXT_SP; + + //WIFI + wifi_menu.title = WIFI_TEXT; + //wifi_menu.key = WIFI_KEY_TEXT_SP; + //wifi_menu.ip = WIFI_IP_TEXT_SP; + //wifi_menu.state = WIFI_STA_TEXT_SP; + wifi_menu.cloud = CLOUD_TEXT_SP; + wifi_menu.reconnect = WIFI_RECONNECT_TEXT_SP; + + cloud_menu.title = TITLE_CLOUD_TEXT_SP; + cloud_menu.bind = CLOUD_BINDED_SP; + cloud_menu.binded = CLOUD_BINDED_SP; + cloud_menu.unbind = CLOUD_UNBIND_SP; + cloud_menu.unbinding = CLOUD_UNBINDED_SP; + cloud_menu.disconnected = CLOUD_DISCONNECTED_SP; + cloud_menu.disable = CLOUD_DISABLE_SP; + // + about_menu.title = ABOUT_TEXT_SP; + about_menu.type = ABOUT_TYPE_TEXT_SP; + about_menu.version = ABOUT_VERSION_TEXT_SP; + about_menu.wifi = ABOUT_WIFI_TEXT_SP; + // + fan_menu.title = FAN_TEXT_SP; + fan_menu.add = FAN_ADD_TEXT_SP; + fan_menu.dec = FAN_DEC_TEXT_SP; + fan_menu.state = FAN_TIPS1_TEXT_SP; + // + filament_menu.title = TITLE_FILAMENT_SP; + filament_menu.in = FILAMENT_IN_TEXT_SP; + filament_menu.out = FILAMENT_OUT_TEXT_SP; + filament_menu.ext1 = FILAMENT_EXT0_TEXT_SP; + filament_menu.ext2 = FILAMENT_EXT1_TEXT_SP; + filament_menu.ready_replace = FILAMENT_CHANGE_TEXT_SP; + filament_menu.filament_dialog_load_heat = FILAMENT_DIALOG_LOAD_HEAT_TIPS_SP; + filament_menu.filament_dialog_load_heat_confirm = FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_SP; + filament_menu.filament_dialog_loading = FILAMENT_DIALOG_LOADING_TIPS_SP; + filament_menu.filament_dialog_load_completed = FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_SP; + filament_menu.filament_dialog_unload_heat = FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_SP; + filament_menu.filament_dialog_unload_heat_confirm = FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_SP; + filament_menu.filament_dialog_unloading = FILAMENT_DIALOG_UNLOADING_TIPS_SP; + filament_menu.filament_dialog_unload_completed = FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_SP; + + // + language_menu.title = LANGUAGE_TEXT_SP; + language_menu.next = PAGE_DOWN_TEXT_SP; + language_menu.up = PAGE_UP_TEXT_SP; + // + printing_menu.title = TITLE_PRINTING_SP; + printing_menu.option = PRINTING_OPERATION_SP; + printing_menu.stop = PRINTING_STOP_SP; + printing_menu.pause = PRINTING_PAUSE_SP; + printing_menu.resume = PRINTING_RESUME_SP; + + // + operation_menu.title = TITLE_OPERATION_SP; + operation_menu.pause = PRINTING_PAUSE_SP; + operation_menu.stop = PRINTING_STOP_SP; + operation_menu.temp = PRINTING_TEMP_SP; + operation_menu.fan = FAN_TEXT_SP; + operation_menu.extr = PRINTING_EXTRUDER_SP; + operation_menu.speed = PRINTING_CHANGESPEED_SP; + operation_menu.filament = FILAMENT_TEXT_SP; + operation_menu.more = PRINTING_MORE_SP; + operation_menu.move = PRINTING_MOVE_SP; + operation_menu.auto_off = AUTO_SHUTDOWN_SP; + operation_menu.manual_off = MANUAL_SHUTDOWN_SP; + // + pause_menu.title = TITLE_PAUSE_RU; + pause_menu.resume = PRINTING_RESUME_SP; + pause_menu.stop = PRINTING_STOP_SP; + pause_menu.extrude = PRINTING_EXTRUDER_SP; + pause_menu.move = PRINTING_MOVE_SP; + pause_menu.filament = FILAMENT_TEXT_SP; + pause_menu.more = PRINTING_MORE_SP; + + // + speed_menu.title = PRINTING_CHANGESPEED_SP; + speed_menu.add = ADD_TEXT_SP; + speed_menu.dec = DEC_TEXT_SP; + speed_menu.move = MOVE_SPEED_SP; + speed_menu.extrude = EXTRUDER_SPEED_SP; + speed_menu.extrude_speed = EXTRUDER_SPEED_STATE_SP; + speed_menu.move_speed = MOVE_SPEED_STATE_SP; + // + printing_more_menu.title = TITLE_MORE_SP; + printing_more_menu.fan = FAN_TEXT_SP; + printing_more_menu.auto_close = AUTO_SHUTDOWN_SP; + printing_more_menu.manual = MANUAL_SHUTDOWN_SP; + printing_more_menu.speed = PRINTING_CHANGESPEED_SP; + printing_more_menu.temp = PRINTING_TEMP_SP; + + //print_file_dialog_menu.title = TITLE_DIALOG_CONFIRM_SP; + print_file_dialog_menu.confirm = DIALOG_CONFIRM_SP; + print_file_dialog_menu.cancle = DIALOG_CANCLE_SP; + print_file_dialog_menu.print_file = DIALOG_PRINT_MODEL_SP; + print_file_dialog_menu.cancle_print = DIALOG_CANCEL_PRINT_SP; + print_file_dialog_menu.retry = DIALOG_RETRY_SP; + print_file_dialog_menu.stop = DIALOG_STOP_SP; + print_file_dialog_menu.no_file_print_tips = DIALOG_ERROR_TIPS1_SP; + print_file_dialog_menu.print_from_breakpoint = DIALOG_REPRINT_FROM_BREAKPOINT_SP; + print_file_dialog_menu.close_machine_error = DIALOG_ERROR_TIPS2_SP; + print_file_dialog_menu.filament_no_press = DIALOG_FILAMENT_NO_PRESS_SP; + print_file_dialog_menu.print_finish = DIALOG_PRINT_FINISH_SP; + print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_SP; + print_file_dialog_menu.reprint = DIALOG_REPRINT_SP; + print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_SP; + //ZOFFSET + zoffset_menu.title = TITLE_ZOFFSET_SP; + zoffset_menu.inc = ZOFFSET_INC_SP; + zoffset_menu.dec = ZOFFSET_DEC_SP; + + pause_msg_menu.pausing = MESSEGE_PAUSING_SP; + pause_msg_menu.changing = MESSEGE_CHANGING_SP; + pause_msg_menu.unload = MESSEGE_UNLOAD_SP; + pause_msg_menu.waiting = MESSEGE_WAITING_SP; + pause_msg_menu.insert = MESSEGE_INSERT_SP; + pause_msg_menu.load = MESSEGE_LOAD_SP; + pause_msg_menu.purge = MESSEGE_PURGE_SP; + pause_msg_menu.resume = MESSEGE_RESUME_SP; + pause_msg_menu.heat = MESSEGE_HEAT_SP; + pause_msg_menu.heating = MESSEGE_HEATING_SP; + pause_msg_menu.option = MESSEGE_OPTION_SP; + pause_msg_menu.purgeMore = MESSEGE_PURGE_MORE_SP; + pause_msg_menu.continuePrint = MESSEGE_CONTINUE_PRINT_SP; + break; + + #endif + + case LANG_FRENCH: + common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_FR; + common_menu.text_back = BACK_TEXT_FR; + common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_FR; + common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_FR; + common_menu.print_special_title = PRINTING_OTHER_LANGUGE; + common_menu.pause_special_title = PRINTING_PAUSE_OTHER_LANGUGE; + common_menu.operate_special_title = PRINTING_OPERATION_OTHER_LANGUGE; + + // + main_menu.title = TITLE_READYPRINT_FR; + main_menu.preheat = PREHEAT_TEXT_FR; + main_menu.move = MOVE_TEXT_FR; + main_menu.home = HOME_TEXT_FR; + main_menu.print = PRINT_TEXT_FR; + main_menu.extrude = EXTRUDE_TEXT_FR; + main_menu.leveling = LEVELING_TEXT_FR; + main_menu.autoleveling = AUTO_LEVELING_TEXT_FR; + main_menu.fan = FAN_TEXT_FR; + main_menu.set = SET_TEXT_FR; + main_menu.more = MORE_TEXT_FR; + main_menu.tool = TOOL_TEXT_FR; + //TOOL + tool_menu.title = TOOL_TEXT_FR; + tool_menu.preheat = TOOL_PREHEAT_FR; + tool_menu.extrude = TOOL_EXTRUDE_FR; + tool_menu.move = TOOL_MOVE_FR; + tool_menu.home = TOOL_HOME_FR; + tool_menu.leveling = TOOL_LEVELING_FR; + tool_menu.autoleveling = TOOL_AUTO_LEVELING_FR; + tool_menu.filament = TOOL_FILAMENT_FR; + tool_menu.more = TOOL_MORE_FR; + // + preheat_menu.adjust_title = TITLE_ADJUST_FR; + preheat_menu.title = TITLE_PREHEAT_FR; + preheat_menu.add = ADD_TEXT_FR; + preheat_menu.dec = DEC_TEXT_FR; + preheat_menu.ext1 = EXTRUDER_1_TEXT_FR; + preheat_menu.ext2 = EXTRUDER_2_TEXT_FR; + preheat_menu.hotbed = HEATBED_TEXT_FR; + preheat_menu.off = CLOSE_TEXT_FR; + // + move_menu.title = MOVE_TEXT_FR; + // + home_menu.title = TITLE_HOME_FR; + home_menu.stopmove = HOME_STOPMOVE_FR; + // + file_menu.title = TITLE_CHOOSEFILE_FR; + file_menu.page_up = PAGE_UP_TEXT_FR; + file_menu.page_down = PAGE_DOWN_TEXT_FR; + // + extrude_menu.title = TITLE_EXTRUDE_FR; + extrude_menu.in = EXTRUDER_IN_TEXT_FR; + extrude_menu.out = EXTRUDER_OUT_TEXT_FR; + extrude_menu.ext1 = EXTRUDER_1_TEXT_FR; + extrude_menu.ext2 = EXTRUDER_2_TEXT_FR; + extrude_menu.low = EXTRUDE_LOW_SPEED_TEXT_FR; + extrude_menu.normal = EXTRUDE_MEDIUM_SPEED_TEXT_FR; + extrude_menu.high = EXTRUDE_HIGH_SPEED_TEXT_FR; + extrude_menu.temper_text = EXTRUDER_TEMP_TEXT_FR; + // + leveling_menu.title = TITLE_LEVELING_FR; + leveling_menu.position1 = LEVELING_POINT1_TEXT_FR; + leveling_menu.position2 = LEVELING_POINT2_TEXT_FR; + leveling_menu.position3 = LEVELING_POINT3_TEXT_FR; + leveling_menu.position4 = LEVELING_POINT4_TEXT_FR; + leveling_menu.position5 = LEVELING_POINT5_TEXT_FR; + // + set_menu.title = TITLE_SET_FR; + set_menu.filesys = FILESYS_TEXT_FR; + set_menu.wifi = WIFI_TEXT_FR; + set_menu.about = ABOUT_TEXT_FR; + set_menu.fan = FAN_TEXT_FR; + set_menu.filament = FILAMENT_TEXT_FR; + set_menu.breakpoint = BREAK_POINT_TEXT_FR; + set_menu.motoroff = MOTOR_OFF_TEXT_FR; + set_menu.motoroffXY = MOTOR_OFF_XY_TEXT_FR; + set_menu.language = LANGUAGE_TEXT_FR; + set_menu.shutdown = SHUTDOWN_TEXT_FR; + // + more_menu.title = TITLE_MORE_FR; + more_menu.zoffset = ZOFFSET_FR; + // + filesys_menu.title = TITLE_FILESYS_FR; + filesys_menu.sd_sys = SD_CARD_TEXT_FR; + filesys_menu.usb_sys = U_DISK_TEXT_FR; + file_menu.file_loading = FILE_LOADING_FR; + file_menu.no_file = NO_FILE_FR; + file_menu.no_file_and_check = NO_FILE_FR;//NO_FILE_AND_CHECK_FR; + //WIFI + wifi_menu.title = WIFI_NAME_TEXT_FR; + //wifi_menu.key = WIFI_KEY_TEXT_FR; + //wifi_menu.ip = WIFI_IP_TEXT_FR; + //wifi_menu.state = WIFI_STA_TEXT_FR; + //wifi_menu.cloud = CLOSE_TEXT_FR; + wifi_menu.cloud = CLOUD_TEXT_FR; + wifi_menu.reconnect = WIFI_RECONNECT_TEXT_FR; + + cloud_menu.title = TITLE_CLOUD_TEXT_FR; + cloud_menu.bind = CLOUD_BINDED_FR; + cloud_menu.binded = CLOUD_BINDED_FR; + cloud_menu.unbind = CLOUD_UNBIND_FR; + cloud_menu.unbinding = CLOUD_UNBINDED_FR; + cloud_menu.disconnected = CLOUD_DISCONNECTED_FR; + cloud_menu.disable = CLOUD_DISABLE_FR; + // + about_menu.title = ABOUT_TEXT_FR; + about_menu.type = ABOUT_TYPE_TEXT_FR; + about_menu.version = ABOUT_VERSION_TEXT_FR; + about_menu.wifi = ABOUT_WIFI_TEXT_FR; + // + fan_menu.title = FAN_TEXT_FR; + fan_menu.add = FAN_ADD_TEXT_FR; + fan_menu.dec = FAN_DEC_TEXT_FR; + fan_menu.state = FAN_TIPS1_TEXT_FR; + // + filament_menu.title = TITLE_FILAMENT_FR; + filament_menu.in = FILAMENT_IN_TEXT_FR; + filament_menu.out = FILAMENT_OUT_TEXT_FR; + filament_menu.ext1 = FILAMENT_EXT0_TEXT_FR; + filament_menu.ext2 = FILAMENT_EXT1_TEXT_FR; + filament_menu.ready_replace = FILAMENT_CHANGE_TEXT_FR; + filament_menu.filament_dialog_load_heat = FILAMENT_DIALOG_LOAD_HEAT_TIPS_FR; + filament_menu.filament_dialog_load_heat_confirm = FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_FR; + filament_menu.filament_dialog_loading = FILAMENT_DIALOG_LOADING_TIPS_FR; + filament_menu.filament_dialog_load_completed = FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_FR; + filament_menu.filament_dialog_unload_heat = FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_FR; + filament_menu.filament_dialog_unload_heat_confirm = FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_FR; + filament_menu.filament_dialog_unloading = FILAMENT_DIALOG_UNLOADING_TIPS_FR; + filament_menu.filament_dialog_unload_completed = FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_FR; + + // + language_menu.title = LANGUAGE_TEXT_FR; + + // + printing_menu.title = TITLE_PRINTING_FR; + printing_menu.option = PRINTING_OPERATION_FR; + printing_menu.stop = PRINTING_STOP_FR; + printing_menu.pause = PRINTING_PAUSE_FR; + printing_menu.resume = PRINTING_RESUME_FR; + + // + operation_menu.title = TITLE_OPERATION_FR; + operation_menu.pause = PRINTING_PAUSE_FR; + operation_menu.stop = PRINTING_STOP_FR; + operation_menu.temp = PRINTING_TEMP_FR; + operation_menu.fan = FAN_TEXT_FR; + operation_menu.extr = PRINTING_EXTRUDER_FR; + operation_menu.speed = PRINTING_CHANGESPEED_FR; + operation_menu.filament = FILAMENT_TEXT_FR; + operation_menu.more = PRINTING_MORE_FR; + operation_menu.move = PRINTING_MOVE_FR; + operation_menu.auto_off = AUTO_SHUTDOWN_FR; + operation_menu.manual_off = MANUAL_SHUTDOWN_FR; + // + pause_menu.title = TITLE_PAUSE_FR; + pause_menu.resume = PRINTING_RESUME_FR; + pause_menu.stop = PRINTING_STOP_FR; + pause_menu.extrude = PRINTING_EXTRUDER_FR; + pause_menu.move = PRINTING_MOVE_FR; + pause_menu.filament = FILAMENT_TEXT_FR; + pause_menu.more = PRINTING_MORE_FR; + + // + speed_menu.title = PRINTING_CHANGESPEED_FR; + speed_menu.add = ADD_TEXT_FR; + speed_menu.dec = DEC_TEXT_FR; + speed_menu.move = MOVE_SPEED_FR; + speed_menu.extrude = EXTRUDER_SPEED_FR; + speed_menu.extrude_speed = EXTRUDER_SPEED_STATE_FR; + speed_menu.move_speed = MOVE_SPEED_STATE_FR; + // + printing_more_menu.fan = FAN_TEXT_FR; + printing_more_menu.auto_close = AUTO_SHUTDOWN_FR; + printing_more_menu.manual = MANUAL_SHUTDOWN_FR; + printing_more_menu.speed = PRINTING_CHANGESPEED_FR; + printing_more_menu.temp = PRINTING_TEMP_FR; + + //print_file_dialog_menu.title = TITLE_DIALOG_CONFIRM_SP; + print_file_dialog_menu.confirm = DIALOG_CONFIRM_FR; + print_file_dialog_menu.cancle = DIALOG_CANCLE_FR; + print_file_dialog_menu.print_file = DIALOG_PRINT_MODEL_FR; + print_file_dialog_menu.cancle_print = DIALOG_CANCEL_PRINT_FR; + print_file_dialog_menu.retry = DIALOG_RETRY_FR; + print_file_dialog_menu.stop = DIALOG_STOP_FR; + print_file_dialog_menu.no_file_print_tips = DIALOG_ERROR_TIPS1_FR; + print_file_dialog_menu.print_from_breakpoint = DIALOG_REPRINT_FROM_BREAKPOINT_FR; + print_file_dialog_menu.close_machine_error = DIALOG_ERROR_TIPS2_FR; + print_file_dialog_menu.filament_no_press = DIALOG_FILAMENT_NO_PRESS_FR; + print_file_dialog_menu.print_finish = DIALOG_PRINT_FINISH_FR; + print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_FR; + print_file_dialog_menu.reprint = DIALOG_REPRINT_FR; + print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_FR; + //ZOFFSET + zoffset_menu.title = TITLE_ZOFFSET_FR; + zoffset_menu.inc = ZOFFSET_INC_FR; + zoffset_menu.dec = ZOFFSET_DEC_FR; + + pause_msg_menu.pausing = MESSEGE_PAUSING_FR; + pause_msg_menu.changing = MESSEGE_CHANGING_FR; + pause_msg_menu.unload = MESSEGE_UNLOAD_FR; + pause_msg_menu.waiting = MESSEGE_WAITING_FR; + pause_msg_menu.insert = MESSEGE_INSERT_FR; + pause_msg_menu.load = MESSEGE_LOAD_FR; + pause_msg_menu.purge = MESSEGE_PURGE_FR; + pause_msg_menu.resume = MESSEGE_RESUME_FR; + pause_msg_menu.heat = MESSEGE_HEAT_FR; + pause_msg_menu.heating = MESSEGE_HEATING_FR; + pause_msg_menu.option = MESSEGE_OPTION_FR; + pause_msg_menu.purgeMore = MESSEGE_PURGE_MORE_FR; + pause_msg_menu.continuePrint = MESSEGE_CONTINUE_PRINT_FR; + break; + + case LANG_ITALY: + common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_IT; + common_menu.text_back = BACK_TEXT_IT; + common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_IT; + common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_IT; + common_menu.print_special_title = PRINTING_OTHER_LANGUGE; + common_menu.pause_special_title = PRINTING_PAUSE_OTHER_LANGUGE; + common_menu.operate_special_title = PRINTING_OPERATION_OTHER_LANGUGE; + + // + main_menu.title = TITLE_READYPRINT_IT; + main_menu.preheat = PREHEAT_TEXT_IT; + main_menu.move = MOVE_TEXT_IT; + main_menu.home = HOME_TEXT_IT; + main_menu.print = PRINT_TEXT_IT; + main_menu.extrude = EXTRUDE_TEXT_IT; + main_menu.leveling = LEVELING_TEXT_IT; + main_menu.autoleveling = AUTO_LEVELING_TEXT_IT; + main_menu.fan = FAN_TEXT_IT; + main_menu.set = SET_TEXT_IT; + main_menu.more = MORE_TEXT_IT; + main_menu.tool = TOOL_TEXT_IT; + //TOOL + tool_menu.title = TOOL_TEXT_IT; + tool_menu.preheat = TOOL_PREHEAT_IT; + tool_menu.extrude = TOOL_EXTRUDE_IT; + tool_menu.move = TOOL_MOVE_IT; + tool_menu.home = TOOL_HOME_IT; + tool_menu.leveling = TOOL_LEVELING_IT; + tool_menu.autoleveling = TOOL_AUTO_LEVELING_IT; + tool_menu.filament = TOOL_FILAMENT_IT; + tool_menu.more = TOOL_MORE_IT; + // + preheat_menu.adjust_title = TITLE_ADJUST_IT; + preheat_menu.title = TITLE_PREHEAT_IT; + preheat_menu.add = ADD_TEXT_IT; + preheat_menu.dec = DEC_TEXT_IT; + preheat_menu.ext1 = EXTRUDER_1_TEXT_IT; + preheat_menu.ext2 = EXTRUDER_2_TEXT_IT; + preheat_menu.hotbed = HEATBED_TEXT_IT; + preheat_menu.off = CLOSE_TEXT_IT; + // + move_menu.title = MOVE_TEXT_IT; + // + home_menu.title = TITLE_HOME_IT; + home_menu.stopmove = HOME_STOPMOVE_IT; + // + file_menu.title = TITLE_CHOOSEFILE_IT; + file_menu.page_up = PAGE_UP_TEXT_IT; + file_menu.page_down = PAGE_DOWN_TEXT_IT; + file_menu.file_loading = FILE_LOADING_IT; + file_menu.no_file = NO_FILE_IT; + file_menu.no_file_and_check = NO_FILE_IT;//NO_FILE_AND_CHECK_IT; + // + extrude_menu.title = TITLE_EXTRUDE_IT; + extrude_menu.in = EXTRUDER_IN_TEXT_IT; + extrude_menu.out = EXTRUDER_OUT_TEXT_IT; + extrude_menu.ext1 = EXTRUDER_1_TEXT_IT; + extrude_menu.ext2 = EXTRUDER_2_TEXT_IT; + extrude_menu.low = EXTRUDE_LOW_SPEED_TEXT_IT; + extrude_menu.normal = EXTRUDE_MEDIUM_SPEED_TEXT_IT; + extrude_menu.high = EXTRUDE_HIGH_SPEED_TEXT_IT; + extrude_menu.temper_text = EXTRUDER_TEMP_TEXT_IT; + // + leveling_menu.title = TITLE_LEVELING_IT; + leveling_menu.position1 = LEVELING_POINT1_TEXT_IT; + leveling_menu.position2 = LEVELING_POINT2_TEXT_IT; + leveling_menu.position3 = LEVELING_POINT3_TEXT_IT; + leveling_menu.position4 = LEVELING_POINT4_TEXT_IT; + leveling_menu.position5 = LEVELING_POINT5_TEXT_IT; + // + set_menu.title = TITLE_SET_IT; + set_menu.filesys = FILESYS_TEXT_IT; + set_menu.wifi = WIFI_TEXT_IT; + set_menu.about = ABOUT_TEXT_IT; + set_menu.fan = FAN_TEXT_IT; + set_menu.filament = FILAMENT_TEXT_IT; + set_menu.breakpoint = BREAK_POINT_TEXT_IT; + set_menu.motoroff = MOTOR_OFF_TEXT_IT; + set_menu.motoroffXY = MOTOR_OFF_XY_TEXT_IT; + set_menu.language = LANGUAGE_TEXT_IT; + set_menu.shutdown = SHUTDOWN_TEXT_IT; + // + more_menu.title = TITLE_MORE_IT; + more_menu.zoffset = ZOFFSET_IT; + // + filesys_menu.title = TITLE_FILESYS_IT; + filesys_menu.sd_sys = SD_CARD_TEXT_IT; + filesys_menu.usb_sys = U_DISK_TEXT_IT; + + //WIFI + wifi_menu.title = WIFI_NAME_TEXT_IT; + //wifi_menu.key = WIFI_KEY_TEXT_IT; + //wifi_menu.ip = WIFI_IP_TEXT_IT; + //wifi_menu.state = WIFI_STA_TEXT_IT; + wifi_menu.cloud = CLOSE_TEXT_IT; + wifi_menu.reconnect = WIFI_RECONNECT_TEXT_IT; + + cloud_menu.title = TITLE_CLOUD_TEXT_IT; + cloud_menu.bind = CLOUD_BINDED_IT; + cloud_menu.binded = CLOUD_BINDED_IT; + cloud_menu.unbind = CLOUD_UNBIND_IT; + cloud_menu.unbinding = CLOUD_UNBINDED_IT; + cloud_menu.disconnected = CLOUD_DISCONNECTED_IT; + cloud_menu.disable = CLOUD_DISABLE_IT; + // + about_menu.title = ABOUT_TEXT_IT; + about_menu.type = ABOUT_TYPE_TEXT_IT; + about_menu.version = ABOUT_VERSION_TEXT_IT; + about_menu.wifi = ABOUT_WIFI_TEXT_IT; + // + fan_menu.title = FAN_TEXT_IT; + fan_menu.add = FAN_ADD_TEXT_IT; + fan_menu.dec = FAN_DEC_TEXT_IT; + fan_menu.state = FAN_TIPS1_TEXT_IT; + // + filament_menu.title = TITLE_FILAMENT_IT; + filament_menu.in = FILAMENT_IN_TEXT_IT; + filament_menu.out = FILAMENT_OUT_TEXT_IT; + filament_menu.ext1 = FILAMENT_EXT0_TEXT_IT; + filament_menu.ext2 = FILAMENT_EXT1_TEXT_IT; + filament_menu.ready_replace = FILAMENT_CHANGE_TEXT_IT; + filament_menu.filament_dialog_load_heat = FILAMENT_DIALOG_LOAD_HEAT_TIPS_IT; + filament_menu.filament_dialog_load_heat_confirm = FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_IT; + filament_menu.filament_dialog_loading = FILAMENT_DIALOG_LOADING_TIPS_IT; + filament_menu.filament_dialog_load_completed = FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_IT; + filament_menu.filament_dialog_unload_heat = FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_IT; + filament_menu.filament_dialog_unload_heat_confirm = FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_IT; + filament_menu.filament_dialog_unloading = FILAMENT_DIALOG_UNLOADING_TIPS_IT; + filament_menu.filament_dialog_unload_completed = FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_IT; + + // + language_menu.title = LANGUAGE_TEXT_IT; + + // + printing_menu.title = TITLE_PRINTING_IT; + printing_menu.option = PRINTING_OPERATION_IT; + printing_menu.stop = PRINTING_STOP_IT; + printing_menu.pause = PRINTING_PAUSE_IT; + printing_menu.resume = PRINTING_RESUME_IT; + + // + operation_menu.title = TITLE_OPERATION_IT; + operation_menu.pause = PRINTING_PAUSE_IT; + operation_menu.stop = PRINTING_STOP_IT; + operation_menu.temp = PRINTING_TEMP_IT; + operation_menu.fan = FAN_TEXT_IT; + operation_menu.extr = PRINTING_EXTRUDER_IT; + operation_menu.speed = PRINTING_CHANGESPEED_IT; + operation_menu.filament = FILAMENT_TEXT_IT; + operation_menu.more = PRINTING_MORE_IT; + operation_menu.move = PRINTING_MOVE_IT; + operation_menu.auto_off = AUTO_SHUTDOWN_IT; + operation_menu.manual_off = MANUAL_SHUTDOWN_IT; + // + pause_menu.title = TITLE_PAUSE_IT; + pause_menu.resume = PRINTING_RESUME_IT; + pause_menu.stop = PRINTING_STOP_IT; + pause_menu.extrude = PRINTING_EXTRUDER_IT; + pause_menu.move = PRINTING_MOVE_IT; + pause_menu.filament = FILAMENT_TEXT_IT; + pause_menu.more = PRINTING_MORE_IT; + + // + speed_menu.title = PRINTING_CHANGESPEED_IT; + speed_menu.add = ADD_TEXT_IT; + speed_menu.dec = DEC_TEXT_IT; + speed_menu.move = MOVE_SPEED_IT; + speed_menu.extrude = EXTRUDER_SPEED_IT; + speed_menu.extrude_speed = EXTRUDER_SPEED_STATE_IT; + speed_menu.move_speed = MOVE_SPEED_STATE_IT; + // + printing_more_menu.fan = FAN_TEXT_IT; + printing_more_menu.auto_close = AUTO_SHUTDOWN_IT; + printing_more_menu.manual = MANUAL_SHUTDOWN_IT; + printing_more_menu.temp = PRINTING_TEMP_IT; + printing_more_menu.speed = PRINTING_CHANGESPEED_IT; + + //print_file_dialog_menu.title = TITLE_DIALOG_CONFIRM_SP; + print_file_dialog_menu.confirm = DIALOG_CONFIRM_IT; + print_file_dialog_menu.cancle = DIALOG_CANCLE_IT; + print_file_dialog_menu.print_file = DIALOG_PRINT_MODEL_IT; + print_file_dialog_menu.cancle_print = DIALOG_CANCEL_PRINT_IT; + print_file_dialog_menu.retry = DIALOG_RETRY_IT; + print_file_dialog_menu.stop = DIALOG_STOP_IT; + print_file_dialog_menu.no_file_print_tips = DIALOG_ERROR_TIPS1_IT; + print_file_dialog_menu.print_from_breakpoint = DIALOG_REPRINT_FROM_BREAKPOINT_IT; + print_file_dialog_menu.close_machine_error = DIALOG_ERROR_TIPS2_IT; + print_file_dialog_menu.filament_no_press = DIALOG_FILAMENT_NO_PRESS_IT; + print_file_dialog_menu.print_finish = DIALOG_PRINT_FINISH_IT; + print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_IT; + print_file_dialog_menu.reprint = DIALOG_REPRINT_IT; + print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_IT; + //ZOFFSET + zoffset_menu.title = TITLE_ZOFFSET_IT; + zoffset_menu.inc = ZOFFSET_INC_IT; + zoffset_menu.dec = ZOFFSET_DEC_IT; + + pause_msg_menu.pausing = MESSEGE_PAUSING_IT; + pause_msg_menu.changing = MESSEGE_CHANGING_IT; + pause_msg_menu.unload = MESSEGE_UNLOAD_IT; + pause_msg_menu.waiting = MESSEGE_WAITING_IT; + pause_msg_menu.insert = MESSEGE_INSERT_IT; + pause_msg_menu.load = MESSEGE_LOAD_IT; + pause_msg_menu.purge = MESSEGE_PURGE_IT; + pause_msg_menu.resume = MESSEGE_RESUME_IT; + pause_msg_menu.heat = MESSEGE_HEAT_IT; + pause_msg_menu.heating = MESSEGE_HEATING_IT; + pause_msg_menu.option = MESSEGE_OPTION_IT; + pause_msg_menu.purgeMore = MESSEGE_PURGE_MORE_IT; + pause_msg_menu.continuePrint = MESSEGE_CONTINUE_PRINT_IT; + break; + + #endif + + default: + common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_EN; + common_menu.text_back = BACK_TEXT_EN; + common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_EN; + common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_EN; + common_menu.print_special_title = PRINTING_OTHER_LANGUGE; + common_menu.pause_special_title = PRINTING_PAUSE_OTHER_LANGUGE; + common_menu.operate_special_title = PRINTING_OPERATION_OTHER_LANGUGE; + // + main_menu.title = TITLE_READYPRINT_EN; + main_menu.preheat = PREHEAT_TEXT_EN; + main_menu.move = MOVE_TEXT_EN; + main_menu.home = HOME_TEXT_EN; + main_menu.print = PRINT_TEXT_EN; + main_menu.extrude = EXTRUDE_TEXT_EN; + main_menu.leveling = LEVELING_TEXT_EN; + main_menu.autoleveling = AUTO_LEVELING_TEXT_EN; + main_menu.fan = FAN_TEXT_EN; + main_menu.set = SET_TEXT_EN; + main_menu.more = MORE_TEXT_EN; + main_menu.tool = TOOL_TEXT_EN; + //TOOL + tool_menu.title = TOOL_TEXT_EN; + tool_menu.preheat = TOOL_PREHEAT_EN; + tool_menu.extrude = TOOL_EXTRUDE_EN; + tool_menu.move = TOOL_MOVE_EN; + tool_menu.home = TOOL_HOME_EN; + tool_menu.leveling = TOOL_LEVELING_EN; + tool_menu.autoleveling = TOOL_AUTO_LEVELING_EN; + tool_menu.filament = TOOL_FILAMENT_EN; + tool_menu.more = TOOL_MORE_EN; + // + preheat_menu.adjust_title = TITLE_ADJUST_EN; + preheat_menu.title = TITLE_PREHEAT_EN; + preheat_menu.add = ADD_TEXT_EN; + preheat_menu.dec = DEC_TEXT_EN; + preheat_menu.ext1 = EXTRUDER_1_TEXT_EN; + preheat_menu.ext2 = EXTRUDER_2_TEXT_EN; + preheat_menu.hotbed = HEATBED_TEXT_EN; + preheat_menu.off = CLOSE_TEXT_EN; + // + move_menu.title = TITLE_MOVE_EN; + // + home_menu.title = TITLE_HOME_EN; + home_menu.stopmove = HOME_STOPMOVE_EN; + // + file_menu.title = TITLE_CHOOSEFILE_EN; + file_menu.page_up = PAGE_UP_TEXT_EN; + file_menu.page_down = PAGE_DOWN_TEXT_EN; + file_menu.file_loading = FILE_LOADING_EN; + file_menu.no_file = NO_FILE_EN; + file_menu.no_file_and_check = NO_FILE_EN;//NO_FILE_AND_CHECK_EN; + // + extrude_menu.title = TITLE_EXTRUDE_EN; + extrude_menu.in = EXTRUDER_IN_TEXT_EN; + extrude_menu.out = EXTRUDER_OUT_TEXT_EN; + extrude_menu.ext1 = EXTRUDER_1_TEXT_EN; + extrude_menu.ext2 = EXTRUDER_2_TEXT_EN; + extrude_menu.low = EXTRUDE_LOW_SPEED_TEXT_EN; + extrude_menu.normal = EXTRUDE_MEDIUM_SPEED_TEXT_EN; + extrude_menu.high = EXTRUDE_HIGH_SPEED_TEXT_EN; + extrude_menu.temper_text = EXTRUDER_TEMP_TEXT_EN; + // + leveling_menu.title = TITLE_LEVELING_EN; + leveling_menu.position1 = LEVELING_POINT1_TEXT_EN; + leveling_menu.position2 = LEVELING_POINT2_TEXT_EN; + leveling_menu.position3 = LEVELING_POINT3_TEXT_EN; + leveling_menu.position4 = LEVELING_POINT4_TEXT_EN; + leveling_menu.position5 = LEVELING_POINT5_TEXT_EN; + // + set_menu.title = TITLE_SET_EN; + set_menu.filesys = FILESYS_TEXT_EN; + set_menu.wifi = WIFI_TEXT_EN; + set_menu.about = ABOUT_TEXT_EN; + set_menu.fan = FAN_TEXT_EN; + set_menu.filament = FILAMENT_TEXT_EN; + set_menu.breakpoint = BREAK_POINT_TEXT_EN; + set_menu.motoroff = MOTOR_OFF_TEXT_EN; + set_menu.motoroffXY = MOTOR_OFF_XY_TEXT_EN; + set_menu.language = LANGUAGE_TEXT_EN; + set_menu.shutdown = SHUTDOWN_TEXT_EN; + //set_menu.machine_para = MACHINE_PARA_EN; + // + more_menu.title = TITLE_MORE_EN; + more_menu.zoffset = ZOFFSET_EN; + // + filesys_menu.title = TITLE_FILESYS_EN; + filesys_menu.sd_sys = SD_CARD_TEXT_EN; + filesys_menu.usb_sys = U_DISK_TEXT_EN; + //WIFI + wifi_menu.title = WIFI_TEXT; + //wifi_menu.key = WIFI_KEY_TEXT_EN; + //wifi_menu.ip = WIFI_IP_TEXT_EN; + //wifi_menu.state = WIFI_STA_TEXT_EN; + wifi_menu.cloud = CLOUD_TEXT_EN; + wifi_menu.reconnect = WIFI_RECONNECT_TEXT_EN; + + cloud_menu.title = TITLE_CLOUD_TEXT_EN; + cloud_menu.bind = CLOUD_BINDED_EN; + cloud_menu.binded = CLOUD_BINDED_EN; + cloud_menu.unbind = CLOUD_UNBIND_EN; + cloud_menu.unbinding = CLOUD_UNBINDED_EN; + cloud_menu.disconnected = CLOUD_DISCONNECTED_EN; + cloud_menu.disable = CLOUD_DISABLE_EN; + // + about_menu.title = TITLE_ABOUT_EN; + about_menu.type = ABOUT_TYPE_TEXT_EN; + about_menu.version = ABOUT_VERSION_TEXT_EN; + about_menu.wifi = ABOUT_WIFI_TEXT_EN; + // + fan_menu.title = TITLE_FAN_EN; + fan_menu.add = FAN_ADD_TEXT_EN; + fan_menu.dec = FAN_DEC_TEXT_EN; + fan_menu.state = FAN_TIPS1_TEXT_EN; + // + filament_menu.title = TITLE_FILAMENT_EN; + filament_menu.in = FILAMENT_IN_TEXT_EN; + filament_menu.out = FILAMENT_OUT_TEXT_EN; + filament_menu.ext1 = FILAMENT_EXT0_TEXT_EN; + filament_menu.ext2 = FILAMENT_EXT1_TEXT_EN; + filament_menu.ready_replace = FILAMENT_CHANGE_TEXT_EN; + filament_menu.filament_dialog_load_heat = FILAMENT_DIALOG_LOAD_HEAT_TIPS_EN; + filament_menu.filament_dialog_load_heat_confirm = FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_EN; + filament_menu.filament_dialog_loading = FILAMENT_DIALOG_LOADING_TIPS_EN; + filament_menu.filament_dialog_load_completed = FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_EN; + filament_menu.filament_dialog_unload_heat = FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_EN; + filament_menu.filament_dialog_unload_heat_confirm = FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_EN; + filament_menu.filament_dialog_unloading = FILAMENT_DIALOG_UNLOADING_TIPS_EN; + filament_menu.filament_dialog_unload_completed = FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_EN; + + // + language_menu.title = TITLE_LANGUAGE_EN; + language_menu.next = PAGE_DOWN_TEXT_EN; + language_menu.up = PAGE_UP_TEXT_EN; + // + printing_menu.title = TITLE_PRINTING_EN; + printing_menu.option = PRINTING_OPERATION_EN; + printing_menu.stop = PRINTING_STOP_EN; + printing_menu.pause = PRINTING_PAUSE_EN; + printing_menu.resume = PRINTING_RESUME_EN; + + // + operation_menu.title = TITLE_OPERATION_EN; + operation_menu.pause = PRINTING_PAUSE_EN; + operation_menu.stop = PRINTING_STOP_EN; + operation_menu.temp = PRINTING_TEMP_EN; + operation_menu.fan = FAN_TEXT_EN; + operation_menu.extr = PRINTING_EXTRUDER_EN; + operation_menu.speed = PRINTING_CHANGESPEED_EN; + operation_menu.filament = FILAMENT_TEXT_EN; + operation_menu.more = PRINTING_MORE_EN; + operation_menu.move = PRINTING_MOVE_EN; + operation_menu.auto_off = AUTO_SHUTDOWN_EN; + operation_menu.manual_off = MANUAL_SHUTDOWN_EN; + // + pause_menu.title = TITLE_PAUSE_EN; + pause_menu.resume = PRINTING_RESUME_EN; + pause_menu.stop = PRINTING_STOP_EN; + pause_menu.extrude = PRINTING_EXTRUDER_EN; + pause_menu.move = PRINTING_MOVE_EN; + pause_menu.filament = FILAMENT_TEXT_EN; + pause_menu.more = PRINTING_MORE_EN; + + // + speed_menu.title = TITLE_CHANGESPEED_EN; + speed_menu.add = ADD_TEXT_EN; + speed_menu.dec = DEC_TEXT_EN; + speed_menu.move = MOVE_SPEED_EN; + speed_menu.extrude = EXTRUDER_SPEED_EN; + speed_menu.extrude_speed = EXTRUDER_SPEED_STATE_EN; + speed_menu.move_speed = MOVE_SPEED_STATE_EN; + // + printing_more_menu.title = TITLE_MORE_EN; + printing_more_menu.fan = FAN_TEXT_EN; + printing_more_menu.auto_close = AUTO_SHUTDOWN_EN; + printing_more_menu.manual = MANUAL_SHUTDOWN_EN; + printing_more_menu.speed = PRINTING_CHANGESPEED_EN; + printing_more_menu.temp = PRINTING_TEMP_EN; + + //print_file_dialog_menu.title = TITLE_DIALOG_CONFIRM_EN; + print_file_dialog_menu.confirm = DIALOG_CONFIRM_EN; + print_file_dialog_menu.cancle = DIALOG_CANCLE_EN; + print_file_dialog_menu.print_file = DIALOG_PRINT_MODEL_EN; + print_file_dialog_menu.cancle_print = DIALOG_CANCEL_PRINT_EN; + print_file_dialog_menu.retry = DIALOG_RETRY_EN; + print_file_dialog_menu.stop = DIALOG_STOP_EN; + print_file_dialog_menu.no_file_print_tips = DIALOG_ERROR_TIPS1_EN; + print_file_dialog_menu.print_from_breakpoint = DIALOG_REPRINT_FROM_BREAKPOINT_EN; + print_file_dialog_menu.close_machine_error = DIALOG_ERROR_TIPS2_EN; + print_file_dialog_menu.filament_no_press = DIALOG_FILAMENT_NO_PRESS_EN; + print_file_dialog_menu.print_finish = DIALOG_PRINT_FINISH_EN; + print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_EN; + print_file_dialog_menu.reprint = DIALOG_REPRINT_EN; + print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_EN; + //ZOFFSET + zoffset_menu.title = TITLE_ZOFFSET_EN; + zoffset_menu.inc = ZOFFSET_INC_EN; + zoffset_menu.dec = ZOFFSET_DEC_EN; + + pause_msg_menu.pausing = MESSEGE_PAUSING_EN; + pause_msg_menu.changing = MESSEGE_CHANGING_EN; + pause_msg_menu.unload = MESSEGE_UNLOAD_EN; + pause_msg_menu.waiting = MESSEGE_WAITING_EN; + pause_msg_menu.insert = MESSEGE_INSERT_EN; + pause_msg_menu.load = MESSEGE_LOAD_EN; + pause_msg_menu.purge = MESSEGE_PURGE_EN; + pause_msg_menu.resume = MESSEGE_RESUME_EN; + pause_msg_menu.heat = MESSEGE_HEAT_EN; + pause_msg_menu.heating = MESSEGE_HEATING_EN; + pause_msg_menu.option = MESSEGE_OPTION_EN; + pause_msg_menu.purgeMore = MESSEGE_PURGE_MORE_EN; + pause_msg_menu.continuePrint = MESSEGE_CONTINUE_PRINT_EN; + break; + } +} + +#endif // TFT_LITTLE_VGL_UI diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h new file mode 100644 index 0000000..2443bc7 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h @@ -0,0 +1,584 @@ +/** + * 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/tft_Language_en.h" +#include "inc/tft_Language_s_cn.h" +#include "inc/tft_Language_t_cn.h" +#include "inc/tft_Language_ru.h" +#include "inc/tft_Language_fr.h" +#include "inc/tft_Language_sp.h" +#include "inc/tft_Language_it.h" + +extern void disp_language_init(); + +#define LANG_SIMPLE_CHINESE 1 +#define LANG_COMPLEX_CHINESE 2 +#define LANG_ENGLISH 3 +#define LANG_JAPAN 4 +#define LANG_GERMAN 5 +#define LANG_FRENCH 6 +#define LANG_RUSSIAN 7 +#define LANG_KOREAN 8 +#define LANG_TURKISH 9 +#define LANG_SPANISH 10 +#define LANG_GREEK 11 +#define LANG_ITALY 12 +#define LANG_PORTUGUESE 13 + +#define MULTI_LANGUAGE_ENABLE 1 +#define MULTI_LANGUAGE_DISABLE 0 + +typedef struct common_menu_disp { + const char *text_back; + const char *dialog_confirm_title; + const char *close_machine_tips; + const char *unbind_printer_tips; + const char *print_special_title; + const char *pause_special_title; + const char *operate_special_title; + const char *next; + const char *previous; +} common_menu_def; +extern common_menu_def common_menu; + +typedef struct main_menu_disp { + const char *title; + const char *preheat; + const char *move; + const char *home; + const char *print; + const char *extrude; + const char *leveling; + const char *autoleveling; + const char *fan; + const char *set; + const char *tool; + const char *more; + const char *machine_para; +} main_menu_def; +extern main_menu_def main_menu; + +typedef struct preheat_menu_disp { + const char *adjust_title; + const char *title; + const char *add; + const char *dec; + const char *ext1; + const char *ext2; + const char *hotbed; + const char *off; + const char *step_1c; + const char *step_5c; + const char *step_10c; + const char *back; + + const char *value_state; + + const char *dialog_tips; + +}preheat_menu_def; +extern preheat_menu_def preheat_menu; + +typedef struct move_menu_disp { + const char *title; + const char *x_add; + const char *x_dec; + const char *y_add; + const char *y_dec; + const char *z_add; + const char *z_dec; + const char *step_001mm; + const char *step_005mm; + const char *step_01mm; + const char *step_1mm; + const char *step_10mm; + const char *back; +} move_menu_def; +extern move_menu_def move_menu; + +typedef struct home_menu_disp { + const char *title; + const char *home_all; + const char *home_x; + const char *home_y; + const char *home_z; + const char *stopmove; + const char *back; +} home_menu_def; +extern home_menu_def home_menu; + +typedef struct file_menu_disp { + const char *title; + const char *page_up; + const char *page_down; + const char *back; + + const char *file_loading; + const char *no_file; + const char *no_file_and_check; + +}file_menu_def; +extern file_menu_def file_menu; + +typedef struct extrude_menu_disp { + const char *title; + const char *in; + const char *out; + const char *ext1; + const char *ext2; + const char *step_1mm; + const char *step_5mm; + const char *step_10mm; + const char *low; + const char *normal; + const char *high; + const char *back; + + const char *count_value_mm; + const char *count_value_cm; + const char *count_value_m; + const char *temp_value; + const char *temper_text; +} extrude_menu_def; +extern extrude_menu_def extrude_menu; + +typedef struct leveling_menu_disp { + const char *title; + const char *position1; + const char *position2; + const char *position3; + const char *position4; + const char *position5; + + char *back; +} leveling_menu_def; +extern leveling_menu_def leveling_menu; + +typedef struct set_menu_disp { + const char *title; + const char *filesys; + const char *wifi; + const char *about; + const char *fan; + const char *filament; + const char *breakpoint; + const char *motoroff; + const char *motoroffXY; + const char *shutdown; + const char *language; + const char *machine_para; + const char *back; +} set_menu_def; +extern set_menu_def set_menu; + +typedef struct filesys_menu_disp { + const char *title; + const char *filesys; + const char *sd_sys; + const char *usb_sys; + const char *back; +} filesys_menu_def; +extern filesys_menu_def filesys_menu; + +typedef struct more_menu_disp { + const char *title; + const char *zoffset; + const char *back; +} more_menu_def; +extern more_menu_def more_menu; + +typedef struct wifi_menu_disp { + const char *title; + const char *ip; + const char *wifi; + const char *key; + const char *state_ap; + const char *state_sta; + const char *cloud; + const char *connected; + const char *disconnected; + const char *exception; + const char *back; + const char *reconnect; +} wifi_menu_def; +extern wifi_menu_def wifi_menu; + +typedef struct cloud_menu_disp { + const char *title; + const char *unbind; + const char *unbinding; + const char *unbinded; + const char *bind; + const char *binding; + const char *binded; + const char *disable; + const char *disconnected; + const char *back; + const char *unbind_printer_tips; +} cloud_menu_def; +extern cloud_menu_def cloud_menu; + +typedef struct about_menu_disp { + const char *title; + const char *type_name; + const char *firmware_v; + const char *type; + const char *version; + const char *wifi; + const char *type_robin; + const char *type_robin_mini; + const char *back; +} about_menu_def; +extern about_menu_def about_menu; + +typedef struct fan_menu_disp { + const char *title; + const char *add; + const char *dec; + const char *full; + const char *half; + const char *off; + const char *back; + + const char *state; + const char *state_value; +} fan_menu_def; +extern fan_menu_def fan_menu; + +typedef struct filament_menu_disp { + const char *title; + const char *in; + const char *out; + const char *ext1; + const char *ext2; + const char *back; + const char *stat_temp; + const char *ready_replace; + const char *replacing; + const char *loading; + const char *unloading; + const char *heating; + const char *complete_and_back; + const char *filament_dialog_load_heat; + const char *filament_dialog_unload_heat; + const char *filament_dialog_load_heat_confirm; + const char *filament_dialog_unload_heat_confirm; + const char *filament_dialog_loading; + const char *filament_dialog_unloading; + const char *filament_dialog_load_completed; + const char *filament_dialog_unload_completed; + const char *filament_dialog_ok; + const char *filament_dialog_back; +} filament_menu_def; +extern filament_menu_def filament_menu; + +typedef struct language_menu { + const char *title; + const char *chinese_s; + const char *chinese_t; + const char *english; + const char *russian; + const char *japan; + const char *italy; + const char *german; + const char *spanish; + const char *korean; + const char *french; + const char *brazil; + const char *portuguese; + const char *next; + const char *up; + const char *back; +} language_menu_def; +extern language_menu_def language_menu; + +typedef struct printing_menu_disp { + const char *title; + const char *option; + const char *temp1; + const char *temp2; + const char *bed_temp; + const char *fan_speed; + const char *pause; + const char *resume; + const char *stop; +} printing_menu_def; +extern printing_menu_def printing_menu; + +typedef struct operation_menu_disp { + const char *title; + const char *pause; + const char *stop; + const char *temp; + const char *fan; + const char *filament; + const char *extr; + const char *speed; + const char *move; + const char *more; + const char *auto_off; + const char *manual_off; + const char *back; + const char *babystep; +} operation_menu_def; +extern operation_menu_def operation_menu; + +typedef struct pause_menu_disp { + const char *title; + const char *resume; + const char *stop; + const char *extrude; + const char *move; + const char *filament; + const char *more; +} pause_menu_def; +extern pause_menu_def pause_menu; + +typedef struct speed_menu_disp { + const char *title; + const char *add; + const char *dec; + const char *extrude; + const char *move; + const char *step_1percent; + const char *step_5percent; + const char *step_10percent; + const char *back; + const char *move_speed; + const char *extrude_speed; +} speed_menu_def; +extern speed_menu_def speed_menu; + +typedef struct printing_more_menu_disp { + const char *title; + const char *fan; + const char *auto_close; + const char *manual; + const char *temp; + const char *speed; + const char *back; +} printing_more_menu_def; +extern printing_more_menu_def printing_more_menu; + +typedef struct dialog_menu_disp { + const char *confirm_title; + + const char *error1_repint_no_file; + const char *error2_communication_fail; + const char *error3_filename_too_long; + const char *error4_no_file; + const char *error5_check_filesys; + + const char *tip1_print_file; + const char *tip2_stop_file; +} dialog_menu_def; +extern dialog_menu_def dialog_menu; + +typedef struct print_file_dialog_disp { + const char *title; + const char *confirm; + const char *cancle; + const char *print_file; + const char *cancle_print; + const char *retry; + const char *stop; + const char *no_file_print_tips; + const char *print_from_breakpoint; + const char *file_name_too_long_error; + const char *close_machine_error; + const char *filament_no_press; + const char *print_finish; + const char *print_time; + const char *reprint; + const char *wifi_enable_tips; +} print_file_dialog_menu_def; +extern print_file_dialog_menu_def print_file_dialog_menu; + +typedef struct zoffset_menu_disp { + const char *title; + const char *inc; + const char *dec; + const char *step001; + const char *step01; + const char *step1; + const char *back; +} zoffset_menu_def; +extern zoffset_menu_def zoffset_menu; + +typedef struct tool_menu_disp { + const char *title; + const char *preheat; + const char *extrude; + const char *move; + const char *home; + const char *leveling; + const char *autoleveling; + const char *filament; + const char *more; + const char *back; +} tool_menu_def; +extern tool_menu_def tool_menu; + +typedef struct MachinePara_menu_disp { + const char *title; + const char *MachineSetting; + const char *TemperatureSetting; + const char *MotorSetting; + const char *AdvanceSetting; + //const char *back; +} MachinePara_menu_def; +extern MachinePara_menu_def MachinePara_menu; + +typedef struct MachineSettings_menu_disp { + const char *title; + const char *Machine; + const char *Stroke; + const char *HomeDir; + const char *EndStopType; + const char *filamet; + const char *leveling; + const char *back; +} MachineSettings_menu_def; +extern MachineSettings_menu_def MachineSettings_menu; + +typedef struct TemperatureSettings_menu_disp { + const char *title; + const char *nozzle; + const char *hotbed; + const char *preheat; + const char *back; +} TemperatureSettings_menu_def; +extern TemperatureSettings_menu_def TemperatureSettings_menu; + +typedef struct pause_msg_disp { + const char *pausing; + const char *changing; + const char *unload; + const char *waiting; + const char *insert; + const char *load; + const char *purge; + const char *resume; + const char *heat; + const char *heating; + const char *option; + const char *purgeMore; + const char *continuePrint; +} pause_msg_def; +extern pause_msg_def pause_msg_menu; + +/*****************************************/ +//********************************************// +//#if defined(TFT70) +// +//#elif defined(TFT35) +#define TEXT_VALUE "%d/%d" +//#endif + +#define TEXT_VALUE_T ": %d℃" +#define TEXT_VALUE_mm ": %dmm" +#define TEXT_VALUE_cm ": %dcm" +#define TEXT_VALUE_m ": %dm" + +#define TEMP_UNIT_SYBOL "%d℃" +#define FLOAT_TEMP_UNIT_SYBOL "%.1f℃" + +#define TEXT_1C "1℃" +#define TEXT_5C "5℃" +#define TEXT_10C "10℃" + +#define AXIS_X_ADD_TEXT "X+" +#define AXIS_X_DEC_TEXT "X-" +#define AXIS_Y_ADD_TEXT "Y+" +#define AXIS_Y_DEC_TEXT "Y-" +#define AXIS_Z_ADD_TEXT "Z+" +#define AXIS_Z_DEC_TEXT "Z-" +#define TEXT_001MM "0.01mm" +#define TEXT_005MM "0.05mm" +#define TEXT_01MM "0.1mm" +#define TEXT_1MM "1mm" +#define TEXT_10MM "10mm" + +#define EXTRUDE_1MM_TEXT "1mm" +#define EXTRUDE_5MM_TEXT "5mm" +#define EXTRUDE_10MM_TEXT "10mm" + +#define STEP_1PERCENT "1%" +#define STEP_5PERCENT "5%" +#define STEP_10PERCENT "10%" + +#define LANGUAGE_S_CN "简体" +#define LANGUAGE_T_CN "繁体" +#define LANGUAGE_EN "English" +#define LANGUAGE_JP "日本語" +#define LANGUAGE_GE "Deutsch" +#define LANGUAGE_FR "français" +#define LANGUAGE_IT "Italia" +#define LANGUAGE_PR "português" +#define LANGUAGE_KR "Korean" +#define LANGUAGE_BR "Brazil" +#define LANGUAGE_RU "русский" +#define LANGUAGE_SP "español" + +#define HOME_X_TEXT "X" +#define HOME_Y_TEXT "Y" +#define HOME_Z_TEXT "Z" +#define HOME_ALL_TEXT "All" +//#if defined(MKS_ROBIN_NANO) +#define ABOUT_TYPE_TEXT "MKS Robin Pro" +//#elif defined(MKS_ROBIN_MINI) +//#define ABOUT_TYPE_TEXT "MKS Robin Mini" +//#endif +#define ABOUT_VERSION_TEXT "1.0.0" +//#define ABOUT_WIFI_TEXT "WiFi:" + +#define FAN_OPEN_TEXT "100%" +#define FAN_HALF_TEXT "50%" +#define FAN_CLOSE_TEXT "0%" +//#define FAN_TIPS1_TEXT "FAN" +//#define FAN_TIPS2_TEXT "FAN\nClose" + +#define WIFI_TEXT "WIFI" +#define WIFI_IP_TEXT "IP: " +#define WIFI_NAME_TEXT "WiFi: " +#define WIFI_KEY_TEXT "Key: " +#define WIFI_STATE_AP_TEXT "State: AP" +#define WIFI_STATE_STA_TEXT "State: STA" +#define WIFI_CONNECTED_TEXT "Connected" +#define WIFI_DISCONNECTED_TEXT "Disconnected" +#define WIFI_EXCEPTION_TEXT "Exception" + +#define FILAMENT_TIPS2_TEXT "T:" + +#define DIALOG_UPLOAD_ING_EN "Uploading......" +#define DIALOG_UPLOAD_ERROR_EN "Upload error" +#define DIALOG_UPLOAD_FINISH_EN "Upload finished" +#define DIALOG_UPLOAD_SIZE_EN "Size" +#define DIALOG_UPLOAD_TIME_EN "Time" +#define DIALOG_UPLOAD_SPEED_EN "Speed" +#define DIALOG_UPDATE_WIFI_FIRMWARE_EN "Updating wifi model firmware" +#define DIALOG_UPDATE_WIFI_WEB_EN "Updating wifi model web data" + +#define ZOFFSET_STEP001 "0.01mm" +#define ZOFFSET_STEP01 "0.1mm" +#define ZOFFSET_STEP1 "1mm" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/language/language_en.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/language/language_en.h index bfa1ed5..cb95205 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/language/language_en.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/language/language_en.h @@ -340,6 +340,10 @@ namespace Language_en { PROGMEM Language_Str MSG_INFO_SCREEN = _UxGT("Info Screen"); PROGMEM Language_Str MSG_PREPARE = _UxGT("Prepare"); PROGMEM Language_Str MSG_TUNE = _UxGT("Tune"); + PROGMEM Language_Str MSG_POWER_MONITOR = _UxGT("Power monitor"); + PROGMEM Language_Str MSG_CURRENT = _UxGT("Current"); + PROGMEM Language_Str MSG_VOLTAGE = _UxGT("Voltage"); + PROGMEM Language_Str MSG_POWER = _UxGT("Power"); PROGMEM Language_Str MSG_START_PRINT = _UxGT("Start Print"); PROGMEM Language_Str MSG_BUTTON_NEXT = _UxGT("Next"); PROGMEM Language_Str MSG_BUTTON_INIT = _UxGT("Init"); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_advanced.cpp index d79d398..c0d4df8 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_advanced.cpp @@ -454,7 +454,7 @@ void menu_cancelobject(); #endif #if HAS_CLASSIC_JERK constexpr xyze_float_t max_jerk_edit = - #ifdef MAX_ACCEL_EDIT_VALUES + #ifdef MAX_JERK_EDIT_VALUES MAX_JERK_EDIT_VALUES #elif ENABLED(LIMITED_JERK_EDITING) { (DEFAULT_XJERK) * 2, (DEFAULT_YJERK) * 2, (DEFAULT_ZJERK) * 2, (DEFAULT_EJERK) * 2 } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_led.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_led.cpp index 1d2638e..a361d97 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_led.cpp @@ -32,7 +32,7 @@ #if ENABLED(LED_CONTROL_MENU) #include "../../feature/leds/leds.h" - + #if ENABLED(LED_COLOR_PRESETS) void menu_led_presets() { START_MENU(); @@ -71,7 +71,7 @@ #if ENABLED(CASE_LIGHT_MENU) #include "../../feature/caselight.h" - + #if DISABLED(CASE_LIGHT_NO_BRIGHTNESS) void menu_case_light() { START_MENU(); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_main.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_main.cpp index ee46c6a..7ef267f 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_main.cpp @@ -59,6 +59,14 @@ void menu_configuration(); void menu_user(); #endif +#if HAS_POWER_MONITOR + void menu_power_monitor(); +#endif + +#if ENABLED(MIXING_EXTRUDER) + void menu_mixer(); +#endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) void _menu_temp_filament_op(const PauseMode, const int8_t); void menu_change_filament(); @@ -76,10 +84,6 @@ void menu_configuration(); void menu_spindle_laser(); #endif -#if ENABLED(MIXING_EXTRUDER) - void menu_mixer(); -#endif - extern const char M21_STR[]; void menu_main() { @@ -155,6 +159,10 @@ void menu_main() { SUBMENU(MSG_TEMPERATURE, menu_temperature); + #if HAS_POWER_MONITOR + MENU_ITEM(submenu, MSG_POWER_MONITOR, menu_power_monitor); + #endif + #if ENABLED(MIXING_EXTRUDER) SUBMENU(MSG_MIXER, menu_mixer); #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_power_monitor.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_power_monitor.cpp new file mode 100644 index 0000000..7055f01 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/menu/menu_power_monitor.cpp @@ -0,0 +1,62 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +// +// Power Monitor Menu +// + +#include "../../inc/MarlinConfigPre.h" + +#if HAS_LCD_MENU && HAS_POWER_MONITOR + +#include "menu.h" +#include "../../feature/power_monitor.h" + +void menu_power_monitor() { + START_MENU(); + MENU_BACK(MSG_MAIN); + + #if ENABLED(POWER_MONITOR_CURRENT) + { + bool ena = power_monitor.current_display_enabled(); + MENU_ITEM_EDIT_CALLBACK(bool, MSG_CURRENT, &ena, power_monitor.toggle_current_display); + } + #endif + + #if HAS_POWER_MONITOR_VREF + { + bool ena = power_monitor.voltage_display_enabled(); + MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLTAGE, &ena, power_monitor.toggle_voltage_display); + } + #endif + + #if HAS_POWER_MONITOR_WATTS + { + bool ena = power_monitor.power_display_enabled(); + MENU_ITEM_EDIT_CALLBACK(bool, MSG_POWER, &ena, power_monitor.toggle_power_display); + } + #endif + + END_MENU(); +} + +#endif // HAS_LCD_MENU && HAS_POWER_MONITOR diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/thermistornames.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/thermistornames.h index f347460..1c66b2a 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/thermistornames.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/thermistornames.h @@ -50,8 +50,14 @@ // Standard thermistors #elif THERMISTOR_ID == 1 #define THERMISTOR_NAME "EPCOS 100K" +#elif THERMISTOR_ID == 331 + #define THERMISTOR_NAME "3.3V EPCOS 100K (MEGA)" +#elif THERMISTOR_ID == 332 + #define THERMISTOR_NAME "3.3V EPCOS 100K (DUE)" #elif THERMISTOR_ID == 2 #define THERMISTOR_NAME "ATC 204GT-2" +#elif THERMISTOR_ID == 202 + #define THERMISTOR_NAME "200k Copymaster 3D" #elif THERMISTOR_ID == 3 #define THERMISTOR_NAME "Mendel-parts" #elif THERMISTOR_ID == 4 @@ -98,6 +104,8 @@ #define THERMISTOR_NAME "Hephestos 2" #elif THERMISTOR_ID == 75 #define THERMISTOR_NAME "MGB18" +#elif THERMISTOR_ID == 99 + #define THERMISTOR_NAME "100k with 10k pull-up" // Modified thermistors #elif THERMISTOR_ID == 51 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/ultralcd.cpp b/Marlin-bugfix-2.0.x/Marlin/src/lcd/ultralcd.cpp index 4c41609..98f2980 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/ultralcd.cpp @@ -40,7 +40,7 @@ MarlinUI ui; #include "../gcode/queue.h" #include "fontutils.h" #include "../sd/cardreader.h" - #if ENABLED(EXTENSIBLE_UI) + #if EITHER(EXTENSIBLE_UI, DWIN_CREALITY_LCD) #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u) #endif #endif @@ -56,7 +56,7 @@ MarlinUI ui; #else constexpr uint8_t MAX_MESSAGE_LENGTH = MAX_LANG_CHARSIZE * (LCD_WIDTH); #endif -#elif ENABLED(EXTENSIBLE_UI) +#elif EITHER(EXTENSIBLE_UI, DWIN_CREALITY_LCD) constexpr uint8_t MAX_MESSAGE_LENGTH = 63; #endif @@ -112,6 +112,10 @@ MarlinUI ui; #include "../module/thermistor/thermistors.h" #endif +#if HAS_POWER_MONITOR + #include "../feature/power_monitor.h" +#endif + #if HAS_ENCODER_ACTION volatile uint8_t MarlinUI::buttons; #if HAS_SLOW_BUTTONS @@ -145,41 +149,42 @@ millis_t MarlinUI::next_button_update_ms; // = 0 volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update #endif -#if HAS_LCD_MENU - #include "menu/menu.h" +#if ENABLED(SDSUPPORT) + #include "../sd/cardreader.h" - #if ENABLED(SDSUPPORT) - - #if ENABLED(SCROLL_LONG_FILENAMES) - uint8_t MarlinUI::filename_scroll_pos, MarlinUI::filename_scroll_max; - #endif - - const char * MarlinUI::scrolled_filename(CardReader &theCard, const uint8_t maxlen, uint8_t hash, const bool doScroll) { - const char *outstr = theCard.longest_filename(); - if (theCard.longFilename[0]) { - #if ENABLED(SCROLL_LONG_FILENAMES) - if (doScroll) { - for (uint8_t l = FILENAME_LENGTH; l--;) - hash = ((hash << 1) | (hash >> 7)) ^ theCard.filename[l]; // rotate, xor - static uint8_t filename_scroll_hash; - if (filename_scroll_hash != hash) { // If the hash changed... - filename_scroll_hash = hash; // Save the new hash - filename_scroll_max = _MAX(0, utf8_strlen(theCard.longFilename) - maxlen); // Update the scroll limit - filename_scroll_pos = 0; // Reset scroll to the start - lcd_status_update_delay = 8; // Don't scroll right away - } - outstr += filename_scroll_pos; - } - #else - theCard.longFilename[maxlen] = '\0'; // cutoff at screen edge - #endif - } - return outstr; - } - + #if MARLINUI_SCROLL_NAME + uint8_t MarlinUI::filename_scroll_pos, MarlinUI::filename_scroll_max; #endif + const char * MarlinUI::scrolled_filename(CardReader &theCard, const uint8_t maxlen, uint8_t hash, const bool doScroll) { + const char *outstr = theCard.longest_filename(); + if (theCard.longFilename[0]) { + #if MARLINUI_SCROLL_NAME + if (doScroll) { + for (uint8_t l = FILENAME_LENGTH; l--;) + hash = ((hash << 1) | (hash >> 7)) ^ theCard.filename[l]; // rotate, xor + static uint8_t filename_scroll_hash; + if (filename_scroll_hash != hash) { // If the hash changed... + filename_scroll_hash = hash; // Save the new hash + filename_scroll_max = _MAX(0, utf8_strlen(theCard.longFilename) - maxlen); // Update the scroll limit + filename_scroll_pos = 0; // Reset scroll to the start + lcd_status_update_delay = 8; // Don't scroll right away + } + outstr += filename_scroll_pos; + } + #else + theCard.longFilename[maxlen] = '\0'; // cutoff at screen edge + #endif + } + return outstr; + } + +#endif + +#if HAS_LCD_MENU + #include "menu/menu.h" + screenFunc_t MarlinUI::currentScreen; // Initialized in CTOR bool MarlinUI::screen_changed; @@ -532,7 +537,6 @@ void MarlinUI::status_screen() { #endif // LCD_PROGRESS_BAR #if HAS_LCD_MENU - if (use_click()) { #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) next_filament_display = millis() + 5000UL; // Show status message for 5s @@ -1455,7 +1459,7 @@ void MarlinUI::update() { encoderDiff = ENCODER_PULSES_PER_STEP * ydir; else if (screen_items > 0) { // Last 3 cols act as a scroll :-) - if (col > (LCD_WIDTH) - 3) + if (col > (LCD_WIDTH) - 5) // 2 * LCD_HEIGHT to scroll to bottom of next page. (LCD_HEIGHT would only go 1 item down.) encoderDiff = ENCODER_PULSES_PER_STEP * (encoderLine - encoderTopLine + 2 * (LCD_HEIGHT)) * ydir; else @@ -1579,5 +1583,7 @@ void MarlinUI::update() { set_status_P(eeprom_err(msgid)); #endif } - #endif -#endif + + #endif // EEPROM_AUTO_INIT + +#endif // EEPROM_SETTINGS diff --git a/Marlin-bugfix-2.0.x/Marlin/src/lcd/ultralcd.h b/Marlin-bugfix-2.0.x/Marlin/src/lcd/ultralcd.h index 6ddacaf..6eaca31 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/lcd/ultralcd.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/lcd/ultralcd.h @@ -27,6 +27,10 @@ #include "../libs/buzzer.h" #endif +#if ENABLED(SDSUPPORT) + #include "../sd/cardreader.h" +#endif + #if EITHER(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY) #define HAS_ENCODER_ACTION 1 #endif @@ -111,7 +115,7 @@ #endif // HAS_LCD_MENU -#endif +#endif // HAS_SPI_LCD // REPRAPWORLD_KEYPAD (and ADC_KEYPAD) #if ENABLED(REPRAPWORLD_KEYPAD) @@ -287,9 +291,13 @@ public: static void init_lcd(); FORCE_INLINE static void refresh() { refresh(LCDVIEW_CLEAR_CALL_REDRAW); } #else + #if ENABLED(DWIN_CREALITY_LCD) + static void refresh(); + #else + static inline void refresh() {} + #endif static inline bool detected() { return true; } static inline void init_lcd() {} - static inline void refresh() {} #endif #if HAS_DISPLAY @@ -451,6 +459,16 @@ public: #endif + #if ENABLED(SDSUPPORT) + #if BOTH(SCROLL_LONG_FILENAMES, HAS_LCD_MENU) + #define MARLINUI_SCROLL_NAME 1 + #endif + #if MARLINUI_SCROLL_NAME + static uint8_t filename_scroll_pos, filename_scroll_max; + #endif + static const char * scrolled_filename(CardReader &theCard, const uint8_t maxlen, uint8_t hash, const bool doScroll); + #endif + #if HAS_LCD_MENU #if ENABLED(TOUCH_BUTTONS) @@ -464,13 +482,6 @@ public: static void enable_encoder_multiplier(const bool onoff); #endif - #if ENABLED(SDSUPPORT) - #if ENABLED(SCROLL_LONG_FILENAMES) - static uint8_t filename_scroll_pos, filename_scroll_max; - #endif - static const char * scrolled_filename(CardReader &theCard, const uint8_t maxlen, uint8_t hash, const bool doScroll); - #endif - #if IS_KINEMATIC static bool processing_manual_move; #else diff --git a/Marlin-bugfix-2.0.x/Marlin/src/libs/numtostr.cpp b/Marlin-bugfix-2.0.x/Marlin/src/libs/numtostr.cpp index 1ed315a..2788ec6 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/libs/numtostr.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/libs/numtostr.cpp @@ -174,6 +174,27 @@ const char* ftostr12ns(const float &f) { return &conv[3]; } +// Convert unsigned float to string with 12.3 format +const char* ftostr31ns(const float &f) { + const long i = ((f < 0 ? -f : f) * 100 + 5) / 10; + conv[3] = DIGIMOD(i, 100); + conv[4] = DIGIMOD(i, 10); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 1); + return &conv[3]; +} + +// Convert unsigned float to string with 123.4 format +const char* ftostr41ns(const float &f) { + const long i = ((f < 0 ? -f : f) * 100 + 5) / 10; + conv[2] = DIGIMOD(i, 1000); + conv[3] = DIGIMOD(i, 100); + conv[4] = DIGIMOD(i, 10); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 1); + return &conv[2]; +} + // Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format const char* ftostr42_52(const float &f) { if (f <= -10 || f >= 100) return ftostr52(f); // -23.45 / 123.45 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/libs/numtostr.h b/Marlin-bugfix-2.0.x/Marlin/src/libs/numtostr.h index 8b6b833..ab340f5 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/libs/numtostr.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/libs/numtostr.h @@ -58,6 +58,12 @@ const char* i16tostr4signrj(const int16_t x); // Convert unsigned float to string with 1.23 format const char* ftostr12ns(const float &x); +// Convert unsigned float to string with 12.3 format +const char* ftostr31ns(const float &x); + +// Convert unsigned float to string with 123.4 format +const char* ftostr41ns(const float &x); + // Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format const char* ftostr42_52(const float &x); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/configuration_store.cpp b/Marlin-bugfix-2.0.x/Marlin/src/module/configuration_store.cpp index aa15067..77b807e 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/configuration_store.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/configuration_store.cpp @@ -50,6 +50,11 @@ #include "planner.h" #include "stepper.h" #include "temperature.h" + +#if ENABLED(DWIN_CREALITY_LCD) + #include "../lcd/dwin/dwin.h" +#endif + #include "../lcd/ultralcd.h" #include "../libs/vector_3.h" // for matrix_3x3 #include "../gcode/gcode.h" @@ -89,6 +94,10 @@ #include "../feature/powerloss.h" #endif +#if ENABLED(POWER_MONITOR) + #include "../feature/power_monitor.h" +#endif + #include "../feature/pause.h" #if ENABLED(BACKLASH_COMPENSATION) @@ -296,6 +305,11 @@ typedef struct SettingsDataStruct { user_thermistor_t user_thermistor[USER_THERMISTORS]; // M305 P0 R4700 T100000 B3950 #endif + // + // Power monitor + // + uint8_t power_monitor_flags; // M430 I V W + // // HAS_LCD_CONTRAST // @@ -804,6 +818,10 @@ void MarlinSettings::postprocess() { const int16_t (&ui_preheat_hotend_temp)[2] = ui.preheat_hotend_temp, (&ui_preheat_bed_temp)[2] = ui.preheat_bed_temp; const uint8_t (&ui_preheat_fan_speed)[2] = ui.preheat_fan_speed; + #elif ENABLED(DWIN_CREALITY_LCD) + const int16_t (&ui_preheat_hotend_temp)[2] = HMI_ValueStruct.preheat_hotend_temp, + (&ui_preheat_bed_temp)[2] = HMI_ValueStruct.preheat_bed_temp; + const uint8_t (&ui_preheat_fan_speed)[2] = HMI_ValueStruct.preheat_fan_speed; #else constexpr int16_t ui_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND }, ui_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED }; @@ -872,6 +890,19 @@ void MarlinSettings::postprocess() { } #endif + // + // Power monitor + // + { + #if HAS_POWER_MONITOR + const uint8_t &power_monitor_flags = power_monitor.flags; + #else + constexpr uint8_t power_monitor_flags = 0x00; + #endif + _FIELD_TEST(power_monitor_flags); + EEPROM_WRITE(power_monitor_flags); + } + // // LCD Contrast // @@ -1664,7 +1695,11 @@ void MarlinSettings::postprocess() { int16_t (&ui_preheat_hotend_temp)[2] = ui.preheat_hotend_temp, (&ui_preheat_bed_temp)[2] = ui.preheat_bed_temp; uint8_t (&ui_preheat_fan_speed)[2] = ui.preheat_fan_speed; - #else + #elif ENABLED(DWIN_CREALITY_LCD) + int16_t (&ui_preheat_hotend_temp)[2] = HMI_ValueStruct.preheat_hotend_temp, + (&ui_preheat_bed_temp)[2] = HMI_ValueStruct.preheat_bed_temp; + uint8_t (&ui_preheat_fan_speed)[2] = HMI_ValueStruct.preheat_fan_speed; + #else int16_t ui_preheat_hotend_temp[2], ui_preheat_bed_temp[2]; uint8_t ui_preheat_fan_speed[2]; #endif @@ -1732,6 +1767,19 @@ void MarlinSettings::postprocess() { } #endif + // + // Power monitor + // + { + #if HAS_POWER_MONITOR + uint8_t &power_monitor_flags = power_monitor.flags; + #else + uint8_t power_monitor_flags; + #endif + _FIELD_TEST(power_monitor_flags); + EEPROM_READ(power_monitor_flags); + } + // // LCD Contrast // @@ -2539,14 +2587,22 @@ void MarlinSettings::reset() { // // Preheat parameters // - - #if HAS_HOTEND && HAS_LCD_MENU - ui.preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND; - ui.preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND; - ui.preheat_bed_temp[0] = PREHEAT_1_TEMP_BED; - ui.preheat_bed_temp[1] = PREHEAT_2_TEMP_BED; - ui.preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED; - ui.preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED; + #if HAS_HOTEND + #if ENABLED(DWIN_CREALITY_LCD) + HMI_ValueStruct.preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND; + HMI_ValueStruct.preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND; + HMI_ValueStruct.preheat_bed_temp[0] = PREHEAT_1_TEMP_BED; + HMI_ValueStruct.preheat_bed_temp[1] = PREHEAT_2_TEMP_BED; + HMI_ValueStruct.preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED; + HMI_ValueStruct.preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED; + #elif HAS_LCD_MENU + ui.preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND; + ui.preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND; + ui.preheat_bed_temp[0] = PREHEAT_1_TEMP_BED; + ui.preheat_bed_temp[1] = PREHEAT_2_TEMP_BED; + ui.preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED; + ui.preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED; + #endif #endif // @@ -2583,6 +2639,11 @@ void MarlinSettings::reset() { // TERN_(HAS_USER_THERMISTORS, thermalManager.reset_user_thermistors()); + // + // Power Monitor + // + TERN_(POWER_MONITOR, power_monitor.reset()); + // // LCD Contrast // diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/motion.cpp b/Marlin-bugfix-2.0.x/Marlin/src/module/motion.cpp index 727bb15..7fba6f8 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/motion.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/motion.cpp @@ -1537,8 +1537,8 @@ void homeaxis(const AxisEnum axis) { #define _CAN_HOME(A) (axis == _AXIS(A) && ( \ ENABLED(A##_SPI_SENSORLESS) \ || (_AXIS(A) == Z_AXIS && ENABLED(HOMING_Z_WITH_PROBE)) \ - || (A##_MIN_PIN > 0 && A##_HOME_DIR < 0) \ - || (A##_MAX_PIN > 0 && A##_HOME_DIR > 0) \ + || (A##_MIN_PIN > -1 && A##_HOME_DIR < 0) \ + || (A##_MAX_PIN > -1 && A##_HOME_DIR > 0) \ )) if (!_CAN_HOME(X) && !_CAN_HOME(Y) && !_CAN_HOME(Z)) return; #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/planner.cpp b/Marlin-bugfix-2.0.x/Marlin/src/module/planner.cpp index f6a0909..2703cd6 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/planner.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/planner.cpp @@ -2107,9 +2107,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, * TERN(HAS_MIXER_SYNC_CHANNEL, MIXING_STEPPERS, 1); if (cs > max_fr) NOMORE(speed_factor, max_fr / cs); //respect max feedrate on any movement (doesn't matter if E axes only or not) - + #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) - const feedRate_t max_vfr = volumetric_extruder_feedrate_limit[extruder] + const feedRate_t max_vfr = volumetric_extruder_feedrate_limit[extruder] * TERN(HAS_MIXER_SYNC_CHANNEL, MIXING_STEPPERS, 1); // TODO: Doesn't work properly for joined segments. Set MIN_STEPS_PER_SEGMENT 1 as workaround. @@ -2352,89 +2352,93 @@ bool Planner::_populate_block(block_t * const block, bool split_move, vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2); - // For small moves with >135° junction (octagon) find speed for approximate arc - if (block->millimeters < 1 && junction_cos_theta < -0.7071067812f) { + #if ENABLED(JD_HANDLE_SMALL_SEGMENTS) - #if ENABLED(JD_USE_MATH_ACOS) + // For small moves with >135° junction (octagon) find speed for approximate arc + if (block->millimeters < 1 && junction_cos_theta < -0.7071067812f) { - #error "TODO: Inline maths with the MCU / FPU." + #if ENABLED(JD_USE_MATH_ACOS) - #elif ENABLED(JD_USE_LOOKUP_TABLE) + #error "TODO: Inline maths with the MCU / FPU." - // Fast acos approximation (max. error +-0.01 rads) - // Based on LUT table and linear interpolation + #elif ENABLED(JD_USE_LOOKUP_TABLE) - /** - * // Generate the JD Lookup Table - * constexpr float c = 1.00751495f; // Correction factor to center error around 0 - * for (int i = 0; i < jd_lut_count - 1; ++i) { - * const float x0 = (sq(i) - 1) / sq(i), - * y0 = acos(x0) * (i == 0 ? 1 : c), - * x1 = i < jd_lut_count - 1 ? 0.5 * x0 + 0.5 : 0.999999f, - * y1 = acos(x1) * (i < jd_lut_count - 1 ? c : 1); - * jd_lut_k[i] = (y0 - y1) / (x0 - x1); - * jd_lut_b[i] = (y1 * x0 - y0 * x1) / (x0 - x1); - * } - * - * // Compute correction factor (Set c to 1.0f first!) - * float min = INFINITY, max = -min; - * for (float t = 0; t <= 1; t += 0.0003f) { - * const float e = acos(t) / approx(t); - * if (isfinite(e)) { - * if (e < min) min = e; - * if (e > max) max = e; - * } - * } - * fprintf(stderr, "%.9gf, ", (min + max) / 2); - */ - static constexpr int16_t jd_lut_count = 16; - static constexpr uint16_t jd_lut_tll = _BV(jd_lut_count - 1); - static constexpr int16_t jd_lut_tll0 = __builtin_clz(jd_lut_tll) + 1; // i.e., 16 - jd_lut_count + 1 - static constexpr float jd_lut_k[jd_lut_count] PROGMEM = { - -1.03145837f, -1.30760646f, -1.75205851f, -2.41705704f, - -3.37769222f, -4.74888992f, -6.69649887f, -9.45661736f, - -13.3640480f, -18.8928222f, -26.7136841f, -37.7754593f, - -53.4201813f, -75.5458374f, -106.836761f, -218.532821f }; - static constexpr float jd_lut_b[jd_lut_count] PROGMEM = { - 1.57079637f, 1.70887053f, 2.04220939f, 2.62408352f, - 3.52467871f, 4.85302639f, 6.77020454f, 9.50875854f, - 13.4009285f, 18.9188995f, 26.7321243f, 37.7885055f, - 53.4293975f, 75.5523529f, 106.841369f, 218.534011f }; + // Fast acos approximation (max. error +-0.01 rads) + // Based on LUT table and linear interpolation - const float neg = junction_cos_theta < 0 ? -1 : 1, - t = neg * junction_cos_theta; + /** + * // Generate the JD Lookup Table + * constexpr float c = 1.00751495f; // Correction factor to center error around 0 + * for (int i = 0; i < jd_lut_count - 1; ++i) { + * const float x0 = (sq(i) - 1) / sq(i), + * y0 = acos(x0) * (i == 0 ? 1 : c), + * x1 = i < jd_lut_count - 1 ? 0.5 * x0 + 0.5 : 0.999999f, + * y1 = acos(x1) * (i < jd_lut_count - 1 ? c : 1); + * jd_lut_k[i] = (y0 - y1) / (x0 - x1); + * jd_lut_b[i] = (y1 * x0 - y0 * x1) / (x0 - x1); + * } + * + * // Compute correction factor (Set c to 1.0f first!) + * float min = INFINITY, max = -min; + * for (float t = 0; t <= 1; t += 0.0003f) { + * const float e = acos(t) / approx(t); + * if (isfinite(e)) { + * if (e < min) min = e; + * if (e > max) max = e; + * } + * } + * fprintf(stderr, "%.9gf, ", (min + max) / 2); + */ + static constexpr int16_t jd_lut_count = 16; + static constexpr uint16_t jd_lut_tll = _BV(jd_lut_count - 1); + static constexpr int16_t jd_lut_tll0 = __builtin_clz(jd_lut_tll) + 1; // i.e., 16 - jd_lut_count + 1 + static constexpr float jd_lut_k[jd_lut_count] PROGMEM = { + -1.03145837f, -1.30760646f, -1.75205851f, -2.41705704f, + -3.37769222f, -4.74888992f, -6.69649887f, -9.45661736f, + -13.3640480f, -18.8928222f, -26.7136841f, -37.7754593f, + -53.4201813f, -75.5458374f, -106.836761f, -218.532821f }; + static constexpr float jd_lut_b[jd_lut_count] PROGMEM = { + 1.57079637f, 1.70887053f, 2.04220939f, 2.62408352f, + 3.52467871f, 4.85302639f, 6.77020454f, 9.50875854f, + 13.4009285f, 18.9188995f, 26.7321243f, 37.7885055f, + 53.4293975f, 75.5523529f, 106.841369f, 218.534011f }; - const int16_t idx = (t < 0.00000003f) ? 0 : __builtin_clz(uint16_t((1.0f - t) * jd_lut_tll)) - jd_lut_tll0; + const float neg = junction_cos_theta < 0 ? -1 : 1, + t = neg * junction_cos_theta; - float junction_theta = t * pgm_read_float(&jd_lut_k[idx]) + pgm_read_float(&jd_lut_b[idx]); - if (neg > 0) junction_theta = RADIANS(180) - junction_theta; // acos(-t) + const int16_t idx = (t < 0.00000003f) ? 0 : __builtin_clz(uint16_t((1.0f - t) * jd_lut_tll)) - jd_lut_tll0; - #else + float junction_theta = t * pgm_read_float(&jd_lut_k[idx]) + pgm_read_float(&jd_lut_b[idx]); + if (neg > 0) junction_theta = RADIANS(180) - junction_theta; // acos(-t) - // Fast acos(-t) approximation (max. error +-0.033rad = 1.89°) - // Based on MinMax polynomial published by W. Randolph Franklin, see - // https://wrf.ecse.rpi.edu/Research/Short_Notes/arcsin/onlyelem.html - // acos( t) = pi / 2 - asin(x) - // acos(-t) = pi - acos(t) ... pi / 2 + asin(x) + #else - const float neg = junction_cos_theta < 0 ? -1 : 1, - t = neg * junction_cos_theta, - asinx = 0.032843707f - + t * (-1.451838349f - + t * ( 29.66153956f - + t * (-131.1123477f - + t * ( 262.8130562f - + t * (-242.7199627f - + t * ( 84.31466202f ) ))))), - junction_theta = RADIANS(90) + neg * asinx; // acos(-t) + // Fast acos(-t) approximation (max. error +-0.033rad = 1.89°) + // Based on MinMax polynomial published by W. Randolph Franklin, see + // https://wrf.ecse.rpi.edu/Research/Short_Notes/arcsin/onlyelem.html + // acos( t) = pi / 2 - asin(x) + // acos(-t) = pi - acos(t) ... pi / 2 + asin(x) - // NOTE: junction_theta bottoms out at 0.033 which avoids divide by 0. + const float neg = junction_cos_theta < 0 ? -1 : 1, + t = neg * junction_cos_theta, + asinx = 0.032843707f + + t * (-1.451838349f + + t * ( 29.66153956f + + t * (-131.1123477f + + t * ( 262.8130562f + + t * (-242.7199627f + + t * ( 84.31466202f ) ))))), + junction_theta = RADIANS(90) + neg * asinx; // acos(-t) - #endif + // NOTE: junction_theta bottoms out at 0.033 which avoids divide by 0. - const float limit_sqr = (block->millimeters * junction_acceleration) / junction_theta; - NOMORE(vmax_junction_sqr, limit_sqr); - } + #endif + + const float limit_sqr = (block->millimeters * junction_acceleration) / junction_theta; + NOMORE(vmax_junction_sqr, limit_sqr); + } + + #endif // JD_HANDLE_SMALL_SEGMENTS } // Get the lowest speed diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/planner.h b/Marlin-bugfix-2.0.x/Marlin/src/module/planner.h index 4086a8a..07bead3 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/planner.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/planner.h @@ -32,7 +32,7 @@ #include "../MarlinCore.h" -#if HAS_JUNCTION_DEVIATION +#if ENABLED(JD_HANDLE_SMALL_SEGMENTS) // Enable this option for perfect accuracy but maximum // computation. Should be fine on ARM processors. //#define JD_USE_MATH_ACOS @@ -493,7 +493,7 @@ class Planner { // Update multipliers based on new diameter measurements static void calculate_volumetric_multipliers(); - + #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) // Update pre calculated extruder feedrate limits based on volumetric values static void calculate_volumetric_extruder_limit(const uint8_t e); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/probe.cpp b/Marlin-bugfix-2.0.x/Marlin/src/module/probe.cpp index 6aefcfa..08aa53f 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/probe.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/probe.cpp @@ -715,11 +715,8 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise else if (raise_after == PROBE_PT_STOW) if (stow()) measured_z = NAN; // Error on stow? - if (verbose_level > 2) { - SERIAL_ECHOPAIR_F("Bed X: ", LOGICAL_X_POSITION(rx), 3); - SERIAL_ECHOPAIR_F( " Y: ", LOGICAL_Y_POSITION(ry), 3); - SERIAL_ECHOLNPAIR_F( " Z: ", measured_z, 3); - } + if (verbose_level > 2) + SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z); } feedrate_mm_s = old_feedrate_mm_s; @@ -727,7 +724,9 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise if (isnan(measured_z)) { stow(); LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); - SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED); + #if DISABLED(G29_RETRY_AND_RECOVER) + SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED); + #endif } if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< Probe::probe_at_point"); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/probe.h b/Marlin-bugfix-2.0.x/Marlin/src/module/probe.h index 0f8ce4a..abab33b 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/probe.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/probe.h @@ -190,7 +190,7 @@ public: #else points[0].set(min_x(), min_y()); points[1].set(max_x(), min_y()); - points[2].set((max_x() - min_x()) / 2, max_y()); + points[2].set((min_x() + max_x()) / 2, max_y()); #endif #endif } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/stepper.cpp b/Marlin-bugfix-2.0.x/Marlin/src/module/stepper.cpp index b278ae9..6b957ba 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/stepper.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/stepper.cpp @@ -2802,7 +2802,9 @@ void Stepper::report_positions() { EXTRA_DIR_WAIT_AFTER(); \ }while(0) - #elif IS_CORE + #endif + + #if IS_CORE #define BABYSTEP_CORE(A, B, INV, DIR, ALT) do{ \ const xy_byte_t old_dir = { _READ_DIR(A), _READ_DIR(B) }; \ @@ -2848,7 +2850,7 @@ void Stepper::report_positions() { case Y_AXIS: #if CORE_IS_XY - BABYSTEP_CORE(X, Y, 0, direction, (CORESIGN(1)<0)); + BABYSTEP_CORE(X, Y, 1, !direction, (CORESIGN(1)>0)); #elif CORE_IS_YZ BABYSTEP_CORE(Y, Z, 0, direction, (CORESIGN(1)<0)); #else diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/stepper/trinamic.cpp b/Marlin-bugfix-2.0.x/Marlin/src/module/stepper/trinamic.cpp index 26a0f58..7d87853 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/stepper/trinamic.cpp @@ -54,7 +54,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; #else #define TMC_UART_HW_DEFINE(IC, ST, L, AI) TMCMarlin stepper##ST(&ST##_HARDWARE_SERIAL, float(ST##_RSENSE), ST##_SLAVE_ADDRESS) #endif -#define TMC_UART_SW_DEFINE(IC, ST, L, AI) TMCMarlin stepper##ST(ST##_SERIAL_RX_PIN, ST##_SERIAL_TX_PIN, float(ST##_RSENSE), ST##_SLAVE_ADDRESS, ST##_SERIAL_RX_PIN > -1) +#define TMC_UART_SW_DEFINE(IC, ST, L, AI) TMCMarlin stepper##ST(ST##_SERIAL_RX_PIN, ST##_SERIAL_TX_PIN, float(ST##_RSENSE), ST##_SLAVE_ADDRESS) #define _TMC_SPI_DEFINE(IC, ST, AI) __TMC_SPI_DEFINE(IC, ST, TMC_##ST##_LABEL, AI) #define TMC_SPI_DEFINE(ST, AI) _TMC_SPI_DEFINE(ST##_DRIVER_TYPE, ST, AI##_AXIS) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/temperature.cpp b/Marlin-bugfix-2.0.x/Marlin/src/module/temperature.cpp index 1fcc849..16e29f7 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/temperature.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/temperature.cpp @@ -32,6 +32,11 @@ #include "../HAL/shared/Delay.h" #include "../lcd/ultralcd.h" + +#if ENABLED(DWIN_CREALITY_LCD) + #include "../lcd/dwin/dwin.h" +#endif + #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" #endif @@ -79,6 +84,10 @@ #include "../feature/filwidth.h" #endif +#if HAS_POWER_MONITOR + #include "../feature/power_monitor.h" +#endif + #if ENABLED(EMERGENCY_PARSER) #include "../feature/e_parser.h" #endif @@ -559,7 +568,8 @@ volatile bool Temperature::raw_temps_ready = false; #ifndef MAX_CYCLE_TIME_PID_AUTOTUNE #define MAX_CYCLE_TIME_PID_AUTOTUNE 20L #endif - if (((ms - t1) + (ms - t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) { + if ((ms - _MIN(t1, t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) { + TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); break; @@ -612,7 +622,7 @@ volatile bool Temperature::raw_temps_ready = false; goto EXIT_M303; } - ui.update(); + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); } disable_all_heaters(); @@ -794,10 +804,12 @@ void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg, } void Temperature::max_temp_error(const heater_ind_t heater) { + TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(1)); _temp_error(heater, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP)); } void Temperature::min_temp_error(const heater_ind_t heater) { + TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); _temp_error(heater, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP)); } @@ -1029,8 +1041,10 @@ void Temperature::manage_heater() { #if WATCH_HOTENDS // Make sure temperature is increasing if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) { // Time to check this extruder? - if (degHotend(e) < watch_hotend[e].target) // Failed to increase enough? + if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough? + TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); _temp_error((heater_ind_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); + } else // Start again if the target is still far off start_watching_hotend(e); } @@ -1071,8 +1085,10 @@ void Temperature::manage_heater() { #if WATCH_BED // Make sure temperature is increasing if (watch_bed.elapsed(ms)) { // Time to check the bed? - if (degBed() < watch_bed.target) // Failed to increase enough? + if (degBed() < watch_bed.target) { // Failed to increase enough? + TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); _temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); + } else // Start again if the target is still far off start_watching_bed(); } @@ -1517,11 +1533,13 @@ void Temperature::updateTemperaturesFromRawValues() { #if HAS_HOTEND HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); #endif + TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw)); TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw)); TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw)); TERN_(TEMP_SENSOR_1_AS_REDUNDANT, redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1)); TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); + TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); // Reset the watchdog on good temperature measurement watchdog_refresh(); @@ -1728,6 +1746,12 @@ void Temperature::init() { #if HAS_ADC_BUTTONS HAL_ANALOG_SELECT(ADC_KEYPAD_PIN); #endif + #if ENABLED(POWER_MONITOR_CURRENT) + HAL_ANALOG_SELECT(POWER_MONITOR_CURRENT_PIN); + #endif + #if ENABLED(POWER_MONITOR_VOLTAGE) + HAL_ANALOG_SELECT(POWER_MONITOR_VOLTAGE_PIN); + #endif HAL_timer_start(TEMP_TIMER_NUM, TEMP_TIMER_FREQUENCY); ENABLE_TEMPERATURE_INTERRUPT(); @@ -1981,6 +2005,7 @@ void Temperature::init() { sm.state = TRRunaway; case TRRunaway: + TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); _temp_error(heater_id, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY)); } } @@ -2747,13 +2772,31 @@ void Temperature::tick() { #if ENABLED(FILAMENT_WIDTH_SENSOR) case Prepare_FILWIDTH: HAL_START_ADC(FILWIDTH_PIN); break; case Measure_FILWIDTH: - if (!HAL_ADC_READY()) - next_sensor_state = adc_sensor_state; // redo this state - else - filwidth.accumulate(HAL_READ_ADC()); + if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state + else filwidth.accumulate(HAL_READ_ADC()); break; #endif + #if ENABLED(POWER_MONITOR_CURRENT) + case Prepare_POWER_MONITOR_CURRENT: + HAL_START_ADC(POWER_MONITOR_CURRENT_PIN); + break; + case Measure_POWER_MONITOR_CURRENT: + if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state + else power_monitor.add_current_sample(HAL_READ_ADC()); + break; + #endif + + #if ENABLED(POWER_MONITOR_VOLTAGE) + case Prepare_POWER_MONITOR_VOLTAGE: + HAL_START_ADC(POWER_MONITOR_VOLTAGE_PIN); + break; + case Measure_POWER_MONITOR_VOLTAGE: + if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state + else power_monitor.add_voltage_sample(HAL_READ_ADC()); + break; + #endif + #if HAS_JOY_ADC_X case PrepareJoy_X: HAL_START_ADC(JOY_X_PIN); break; case MeasureJoy_X: ACCUMULATE_ADC(joystick.x); break; @@ -3082,7 +3125,13 @@ void Temperature::tick() { } while (wait_for_heatup && TEMP_CONDITIONS); if (wait_for_heatup) { - ui.reset_status(); + #if ENABLED(DWIN_CREALITY_LCD) + HMI_flag.heat_flag = 0; + duration_t elapsed = print_job_timer.duration(); // print timer + heat_time = elapsed.value; + #else + ui.reset_status(); + #endif TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onHeatingDone()); } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/temperature.h b/Marlin-bugfix-2.0.x/Marlin/src/module/temperature.h index 8f875f8..0f95d0a 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/temperature.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/temperature.h @@ -148,6 +148,14 @@ enum ADCSensorState : char { #if ENABLED(FILAMENT_WIDTH_SENSOR) Prepare_FILWIDTH, Measure_FILWIDTH, #endif + #if ENABLED(POWER_MONITOR_CURRENT) + Prepare_POWER_MONITOR_CURRENT, + Measure_POWER_MONITOR_CURRENT, + #endif + #if ENABLED(POWER_MONITOR_VOLTAGE) + Prepare_POWER_MONITOR_VOLTAGE, + Measure_POWER_MONITOR_VOLTAGE, + #endif #if HAS_ADC_BUTTONS Prepare_ADC_KEY, Measure_ADC_KEY, #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/thermistor/thermistor_22.h b/Marlin-bugfix-2.0.x/Marlin/src/module/thermistor/thermistor_22.h index b3ef68a..e9b6acb 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/thermistor/thermistor_22.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/thermistor/thermistor_22.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. - * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/thermistor/thermistor_23.h b/Marlin-bugfix-2.0.x/Marlin/src/module/thermistor/thermistor_23.h index 46c025d..13918c5 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/thermistor/thermistor_23.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/thermistor/thermistor_23.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. - * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/Marlin-bugfix-2.0.x/Marlin/src/module/tool_change.cpp b/Marlin-bugfix-2.0.x/Marlin/src/module/tool_change.cpp index 36830f2..8aa3675 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/module/tool_change.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/module/tool_change.cpp @@ -967,10 +967,12 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (ENABLED(SINGLENOZZLE)) { active_extruder = new_tool; return; } } else { - // If first new tool, toolchange without unloading the old not initialized 'Just prime/init the new' - if (first_tool_is_primed) - unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); - first_tool_is_primed = true; // The first new tool will be primed by toolchanging + #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) + // For first new tool, change without unloading the old. 'Just prime/init the new' + if (first_tool_is_primed) + unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); + first_tool_is_primed = true; // The first new tool will be primed by toolchanging + #endif } } #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h index 98ce887..4f43a2a 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h @@ -49,19 +49,19 @@ // // Steppers // -#define X_STEP_PIN P2_0 -#define X_DIR_PIN P0_5 -#define X_ENABLE_PIN P0_4 +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P0_04 -#define Y_STEP_PIN P2_1 +#define Y_STEP_PIN P2_01 #define Y_DIR_PIN P0_11 #define Y_ENABLE_PIN P0_10 -#define Z_STEP_PIN P2_2 +#define Z_STEP_PIN P2_02 #define Z_DIR_PIN P0_20 #define Z_ENABLE_PIN P0_19 -#define E0_STEP_PIN P2_3 +#define E0_STEP_PIN P2_03 #define E0_DIR_PIN P0_22 #define E0_ENABLE_PIN P0_21 @@ -75,10 +75,10 @@ // // Heaters / Fans // -#define HEATER_0_PIN P2_7 -#define HEATER_BED_PIN P2_5 +#define HEATER_0_PIN P2_07 +#define HEATER_BED_PIN P2_05 #ifndef FAN_PIN - #define FAN_PIN P2_4 + #define FAN_PIN P2_04 #endif // diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index 2ca8f86..6502edd 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -59,8 +59,12 @@ #define TEMP_BED_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_BED_PIN #endif -#if HOTENDS == 1 && TEMP_SENSOR_PROBE - #define TEMP_PROBE_PIN TEMP_1_PIN +#if HOTENDS == 1 + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif #endif // diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/mega/pins_PICA.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/mega/pins_PICA.h index 6997477..490316b 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/mega/pins_PICA.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/mega/pins_PICA.h @@ -49,9 +49,9 @@ // // Servos // -#define SERVO0_PIN 3 -#define SERVO1_PIN 4 -#define SERVO2_PIN 5 +#define SERVO0_PIN 3 +#define SERVO1_PIN 4 +#define SERVO2_PIN 5 // // Limit Switches // diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/pins.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/pins.h index f134f92..63a6b1c 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/pins.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/pins.h @@ -541,9 +541,11 @@ #elif MB(CCROBOT_MEEB_3DP) #include "stm32f1/pins_CCROBOT_MEEB_3DP.h" // STM32F1 env:STM32F103RC_meeb #elif MB(CHITU3D_V5) - #include "stm32f1/pins_CHITU3D_V5.h" // STM32F1 env:chitu_f103 + #include "stm32f1/pins_CHITU3D_V5.h" // STM32F1 env:chitu_f103 env:chitu_v5_gpio_init #elif MB(CHITU3D_V6) #include "stm32f1/pins_CHITU3D_V6.h" // STM32F1 env:chitu_f103 +#elif MB(CREALITY_V4) + #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RET6_creality // // ARM Cortex-M4F @@ -565,17 +567,19 @@ #elif MB(ARMED) #include "stm32f4/pins_ARMED.h" // STM32F4 env:ARMED #elif MB(RUMBA32_V1_0) - #include "stm32f4/pins_RUMBA32_AUS3D.h" // STM32F4 env:rumba32_f446ve + #include "stm32f4/pins_RUMBA32_AUS3D.h" // STM32F4 env:rumba32 #elif MB(RUMBA32_V1_1) - #include "stm32f4/pins_RUMBA32_AUS3D.h" // STM32F4 env:rumba32_f446ve + #include "stm32f4/pins_RUMBA32_AUS3D.h" // STM32F4 env:rumba32 #elif MB(RUMBA32_MKS) - #include "stm32f4/pins_RUMBA32_MKS.h" // STM32F4 env:rumba32_mks + #include "stm32f4/pins_RUMBA32_MKS.h" // STM32F4 env:rumba32 #elif MB(BLACK_STM32F407VE) #include "stm32f4/pins_BLACK_STM32F407VE.h" // STM32F4 env:STM32F407VE_black #elif MB(STEVAL_3DP001V1) #include "stm32f4/pins_STEVAL_3DP001V1.h" // STM32F4 env:STM32F401VE_STEVAL #elif MB(BTT_SKR_PRO_V1_1) #include "stm32f4/pins_BTT_SKR_PRO_V1_1.h" // STM32F4 env:BIGTREE_SKR_PRO +#elif MB(BTT_SKR_PRO_V1_2) + #include "stm32f4/pins_BTT_SKR_PRO_V1_2.h" // STM32F4 env:BIGTREE_SKR_PRO #elif MB(BTT_GTR_V1_0) #include "stm32f4/pins_BTT_GTR_V1_0.h" // STM32F4 env:BIGTREE_GTR_V1_0 #elif MB(BTT_BTT002_V1_0) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/pinsDebug_list.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/pinsDebug_list.h index 2ffa709..04ec39f 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/pinsDebug_list.h @@ -30,7 +30,7 @@ // Analog Pin Assignments // -#define ANALOG_OK(PN) ((PN) >= 0 && (PN) < NUM_ANALOG_PINS) +#define ANALOG_OK(PN) ((PN) >= 0 && (PN) < NUM_ANALOG_INPUTS) #if defined(EXT_AUX_A0) && ANALOG_OK(EXT_AUX_A0) REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h index d9286e4..c98ba6a 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h @@ -21,15 +21,6 @@ */ #pragma once -/** - * Override default LCD timing for Formbot T-Rex 2+ machines. - * The long LCD cables and the routing near electrically noisy stepper motors - * requires a slightly longer setup and hold time on the signals. - */ -#define BOARD_ST7920_DELAY_1 DELAY_NS(200) -#define BOARD_ST7920_DELAY_2 DELAY_NS(200) -#define BOARD_ST7920_DELAY_3 DELAY_NS(200) - /** * Formbot pin assignments */ @@ -205,3 +196,15 @@ #define LCD_PINS_D6 27 #define LCD_PINS_D7 29 #endif + +#if HAS_GRAPHICAL_LCD + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(200) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(200) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(200) + #endif +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/ramps/pins_RAMPS.h index 8f7b745..7059bbb 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/ramps/pins_RAMPS.h @@ -603,7 +603,7 @@ #define KILL_PIN 41 #endif - #if ENABLED(MKS_MINI_12864) // Added in Marlin 1.1.6 + #if ENABLED(MKS_MINI_12864) #define DOGLCD_A0 27 #define DOGLCD_CS 25 @@ -707,7 +707,7 @@ #endif // HAS_SPI_LCD -#if ENABLED(REPRAPWORLD_KEYPAD) +#if ENABLED(REPRAPWORLD_KEYPAD) && DISABLED(ADC_KEYPAD) #define SHIFT_OUT 40 #define SHIFT_CLK 44 #define SHIFT_LD 42 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/samd/pins_RAMPS_144.h index 566a726..d95e869 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -473,7 +473,7 @@ // #define KILL_PIN 41 //#endif - #if ENABLED(MKS_MINI_12864) // Added in Marlin 1.1.6 + #if ENABLED(MKS_MINI_12864) // TO TEST //#define DOGLCD_A0 27 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h index 75c52b3..0428c17 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h @@ -37,9 +37,15 @@ // Alter timing for graphical display #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(125) - #define BOARD_ST7920_DELAY_2 DELAY_NS(125) - #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #endif #endif #include "pins_MELZI.h" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h index 1ceb8b9..1b14d6e 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h @@ -29,9 +29,15 @@ // Alter timing for graphical display #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(125) - #define BOARD_ST7920_DELAY_2 DELAY_NS(125) - #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #endif #endif #include "pins_MELZI.h" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h index 8da6059..1221c20 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h @@ -28,9 +28,15 @@ #define BOARD_INFO_NAME "Melzi (Tronxy)" #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(0) - #define BOARD_ST7920_DELAY_2 DELAY_NS(125) - #define BOARD_ST7920_DELAY_3 DELAY_NS(0) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(0) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(0) + #endif #endif #include "pins_MELZI.h" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_V2.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_V2.h index 7db9a2e..33462d1 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_V2.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/sanguino/pins_MELZI_V2.h @@ -24,10 +24,16 @@ #define BOARD_INFO_NAME "Melzi V2" -#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) - #define BOARD_ST7920_DELAY_1 DELAY_NS(0) - #define BOARD_ST7920_DELAY_2 DELAY_NS(188) - #define BOARD_ST7920_DELAY_3 DELAY_NS(0) +#if HAS_GRAPHICAL_LCD + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(0) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(188) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(0) + #endif #endif #include "pins_MELZI.h" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index 7fb1c48..92feef3 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -187,7 +187,7 @@ #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! - #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3.h' for details. Comment out this line to continue." + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." #define LCD_PINS_RS PB9 #define LCD_PINS_ENABLE PB6 @@ -222,7 +222,7 @@ #define LCD_BACKLIGHT_PIN -1 #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, and MKS_MINI_12864 are currently supported on the BIGTREE_SKR_E3_DIP." + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and MKS_LCD12864 are currently supported on the BIGTREE_SKR_E3_DIP." #endif #endif // HAS_SPI_LCD diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h index 7adce16..a5141ac 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h @@ -21,7 +21,7 @@ */ #pragma once -#include "pins_BTT_SKR_MINI_E3.h" +#include "pins_BTT_SKR_MINI_E3_common.h" #define BOARD_INFO_NAME "BTT SKR Mini E3 V1.0" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h index 5d649bc..8299758 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h @@ -21,7 +21,7 @@ */ #pragma once -#include "pins_BTT_SKR_MINI_E3.h" +#include "pins_BTT_SKR_MINI_E3_common.h" #define BOARD_INFO_NAME "BTT SKR Mini E3 V1.2" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index 57d964e..d6ca379 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -30,7 +30,7 @@ #undef NO_EEPROM_SELECTED #endif -#include "pins_BTT_SKR_MINI_E3.h" +#include "pins_BTT_SKR_MINI_E3_common.h" #define BOARD_INFO_NAME "BTT SKR Mini E3 V2.0" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h new file mode 100644 index 0000000..6d8100e --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -0,0 +1,240 @@ +/** + * 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 + +#ifndef TARGET_STM32F1 + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#endif + +// Release PB3/PB4 (E0 STP/DIR) from JTAG pins +#define DISABLE_JTAG + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB +#endif + +// +// Servos +// +#define SERVO0_PIN PA1 // "SERVOS" + +// +// Limit Switches +// +#define X_STOP_PIN PC0 // "X-STOP" +#define Y_STOP_PIN PC1 // "Y-STOP" +#define Z_STOP_PIN PC2 // "Z-STOP" + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PC14 // "PROBE" + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // "E0-STOP" +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PB14 +#define X_STEP_PIN PB13 +#define X_DIR_PIN PB12 + +#define Y_ENABLE_PIN PB11 +#define Y_STEP_PIN PB10 +#define Y_DIR_PIN PB2 + +#define Z_ENABLE_PIN PB1 +#define Z_STEP_PIN PB0 +#define Z_DIR_PIN PC5 + +#define E0_ENABLE_PIN PD2 +#define E0_STEP_PIN PB3 +#define E0_DIR_PIN PB4 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input "TH0" +#define TEMP_BED_PIN PC3 // Analog Input "TB0" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC8 // "HE" +#define HEATER_BED_PIN PC9 // "HB" + +#ifdef SKR_MINI_E3_V2 + #define FAN_PIN PC6 +#else + #define FAN_PIN PA8 // "FAN0" +#endif + +// +// USB connect control +// +#ifdef SKR_MINI_E3_V2 + #define USB_CONNECT_PIN PA14 +#else + #define USB_CONNECT_PIN PC13 +#endif + +#define USB_CONNECT_INVERTING false + +/** + * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 + * _____ _____ + * 5V | 1 2 | GND 5V | 1 2 | GND + * (LCD_EN) PB7 | 3 4 | PB8 (LCD_RS) (LCD_EN) PB15 | 3 4 | PB8 (LCD_RS) + * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) + * RESET | 7 8 | PA9 (BTN_EN1) RESET | 7 8 | PA9 (BTN_EN1) + * (BTN_ENC) PB6 | 9 10| PB5 (BEEPER) (BTN_ENC) PA15 | 9 10| PB5 (BEEPER) + * ----- ----- + * EXP1 EXP1 + */ +#ifdef SKR_MINI_E3_V2 + #define EXP1_9 PA15 + #define EXP1_3 PB15 +#else + #define EXP1_9 PB6 + #define EXP1_3 PB7 +#endif + +#if HAS_SPI_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN PB5 + #define BTN_ENC EXP1_9 + + #define BTN_EN1 PA9 + #define BTN_EN2 PA10 + + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE EXP1_3 + #define LCD_PINS_D4 PB9 + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." + + #define LCD_PINS_RS PB9 + #define LCD_PINS_ENABLE EXP1_9 + #define LCD_PINS_D4 PB8 + #define LCD_PINS_D5 PA10 + #define LCD_PINS_D6 PA9 + #define LCD_PINS_D7 PB5 + #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_ENC EXP1_9 + #define BTN_EN1 PA9 + #define BTN_EN2 PA10 + + #define DOGLCD_CS PB8 + #define DOGLCD_A0 PB9 + #define DOGLCD_SCK PB5 + #define DOGLCD_MOSI EXP1_3 + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, and MKS_MINI_12864 are currently supported on the BIGTREE_SKR_MINI_E3." + #endif + +#endif // HAS_SPI_LCD + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." + + /** FYSETC TFT TFT81050 display pinout + * + * Board Display + * _____ _____ + * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) + * (FREE) PB9 | 5 6 PA10 (SD_CS) (PB8) LCD_CS | 5 6 MOSI (SPI1-MOSI) + * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | RESET + * (BEEPER) PB6 | 9 10| PB5 (SD_DET) GND | 9 10| 5V + * ----- ----- + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * _________ + * EXP1-1 ----------- EXP1-10 + * EXP1-2 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-4 ----------- EXP1-5 + * SPI1-3 ----------- EXP1-2 + * EXP1-6 ----------- EXP1-4 + * EXP1-7 ----------- EXP1-8 + * EXP1-8 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-10 ----------- EXP1-7 + * + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN EXP1_9 + + #define CLCD_MOD_RESET PA9 + #define CLCD_SPI_CS PB8 + +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN PC4 +#endif + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) && SD_CONNECTION_IS(LCD) + #define SD_DETECT_PIN PB5 + #define SS_PIN PA10 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." +#endif + +#define ON_BOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h index 59a9de7..661fbdb 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -163,15 +163,27 @@ #else // !FYSETC_MINI_12864 - #define LCD_PINS_D4 PC13 - #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 PB7 - #define LCD_PINS_D6 PC15 - #define LCD_PINS_D7 PC14 - #endif + #define LCD_PINS_D4 PC13 + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 PB7 + #define LCD_PINS_D6 PC15 + #define LCD_PINS_D7 PC14 + #endif #endif // !FYSETC_MINI_12864 + #if HAS_GRAPHICAL_LCD + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #endif + #endif + #endif #endif // HAS_SPI_LCD @@ -201,11 +213,5 @@ #define MOSI_PIN PA7 #define SS_PIN PA4 #endif -#define ON_BOARD_SPI_DEVICE 1 //SPI1 +#define ON_BOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card - -#if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(125) - #define BOARD_ST7920_DELAY_2 DELAY_NS(125) - #define BOARD_ST7920_DELAY_3 DELAY_NS(125) -#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index 6cfa4e2..0978369 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -43,9 +43,9 @@ // #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE 0x800U // 2KB + #define EEPROM_PAGE_SIZE 0x800U // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // @@ -143,9 +143,15 @@ // Alter timing for graphical display #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(125) - #define BOARD_ST7920_DELAY_2 DELAY_NS(125) - #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #endif #endif // diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h index 5dd9202..fc95d6c 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h @@ -42,9 +42,9 @@ // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) #define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE) #define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE #else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM #endif // diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h index 176ccc8..15c01e8 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h @@ -46,9 +46,9 @@ // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) #define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE) #define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE #else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM #endif // diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h new file mode 100644 index 0000000..b50be33 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -0,0 +1,167 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * CREALITY (STM32F103) board pin assignments + */ + +#ifndef __STM32F1__ + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#endif + +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "CREALITY supports up to 1 hotends / E-steppers. Comment out this line to continue." +#endif + +#define BOARD_INFO_NAME "CREALITY V4" +#define DEFAULT_MACHINE_NAME "Ender 3 V2" + +// +// EEPROM +// + +/* I2C */ +#define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 +//#define E2END 0x3FFF // 16Kb (24c16) +#define IIC_EEPROM_SDA PA11 +#define IIC_EEPROM_SCL PA12 + +// SD EEPROM was in your original build, so... +#define SDCARD_EEPROM_EMULATION + +/* SPI */ +//#define SPI_EEPROM // EEPROM on SPI-0 +//#define SPI_CHAN_EEPROM1 ? +//#define SPI_EEPROM1_CS ? +// 2K EEPROM +//#define SPI_EEPROM2_CS ? +// 32Mb FLASH +//#define SPI_FLASH_CS ? + +/* FLASH */ +//#define FLASH_EEPROM_EMULATION + +// +// Servos +// +#define SERVO0_PIN PB0 // BLTouch OUT + +// +// Limit Switches +// +#define X_STOP_PIN PA5 +#define Y_STOP_PIN PA6 +#define Z_STOP_PIN PA7 + +#define Z_PROBE_PIN PB1 // BLTouch IN + +// +// Steppers +// +#define X_ENABLE_PIN PC3 +#define X_STEP_PIN PC2 +#define X_DIR_PIN PB9 + +#define Y_ENABLE_PIN PC3 +#define Y_STEP_PIN PB8 +#define Y_DIR_PIN PB7 + +#define Z_ENABLE_PIN PC3 +#define Z_STEP_PIN PB6 +#define Z_DIR_PIN PB5 + +#define E0_ENABLE_PIN PC3 +#define E0_STEP_PIN PB4 +#define E0_DIR_PIN PB3 + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC5 // TH1 +#define TEMP_BED_PIN PC4 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA1 // HEATER1 +#define HEATER_BED_PIN PA2 // HOT BED + +#define FAN_PIN PA0 // FAN +#define FAN_SOFT_PWM + +// +// SD Card +// +#define SD_DETECT_PIN PC7 +#define SDCARD_CONNECTION ONBOARD +#define ON_BOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PA4 // SDSS +#define SDIO_SUPPORT + +#if ENABLED(RET6_12864_LCD) + + /* RET6 12864 LCD */ + #define LCD_PINS_RS PB12 + #define LCD_PINS_ENABLE PB15 + #define LCD_PINS_D4 PB13 + + #define BTN_ENC PB2 + #define BTN_EN1 PB10 + #define BTN_EN2 PB14 + + #define BEEPER_PIN PC6 +#elif ENABLED(VET6_12864_LCD) + + /* VET6 12864 LCD */ + #define LCD_PINS_RS PA4 + #define LCD_PINS_ENABLE PA7 + #define LCD_PINS_D4 PA5 + + #define BTN_ENC PC5 + #define BTN_EN1 PB10 + #define BTN_EN2 PA6 + +#elif ENABLED(DWIN_CREALITY_LCD) + + /* RET6 DWIN ENCODER LCD */ + #define BTN_ENC PB14 + #define BTN_EN1 PB15 + #define BTN_EN2 PB12 + + //#define LCD_LED_PIN PB2 + #define BEEPER_PIN PB13 + +#elif ENABLED(DWIN_VET6_CREALITY_LCD) + + /* VET6 DWIN ENCODER LCD */ + #define BTN_ENC PA6 + #define BTN_EN1 PA7 + #define BTN_EN2 PA4 + + #define BEEPER_PIN PA5 + +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h index e7e7197..a3645af 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h @@ -159,9 +159,15 @@ #endif #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) - #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #endif #endif #endif // HAS_SPI_LCD diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index e7e7197..a3645af 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -159,9 +159,15 @@ #endif #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) - #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #endif #endif #endif // HAS_SPI_LCD diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3.h index c441efa..46c80e9 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3.h @@ -22,174 +22,15 @@ #pragma once /** - * MKS Robin E3D (STM32F103RCT6) board pin assignments + * MKS Robin E3 (STM32F103RCT6) board pin assignments */ -#ifndef __STM32F1__ - #error "Oops! Select an STM32F1 board in 'Tools > Board.'" -#elif HOTENDS > 1 || E_STEPPERS > 1 - #error "MKS Robin E3D supports up to 1 hotends / E-steppers. Comment out this line to continue." +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "MKS Robin E3 supports up to 1 hotends / E-steppers. Comment out this line to continue." #endif #ifndef BOARD_INFO_NAME #define BOARD_INFO_NAME "MKS Robin E3" #endif -#define BOARD_WEBSITE_URL "github.com/makerbase-mks" -//#define DISABLE_DEBUG -#define DISABLE_JTAG -#define ENABLE_SPI2 - -// -// EEPROM -// -#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) - #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB - #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB -#endif - -// -// Servos -// -#define SERVO0_PIN PA3 - -// -// Limit Switches -// -#define X_STOP_PIN PA12 -#define Y_STOP_PIN PA11 -#define Z_MIN_PIN PC6 -#define Z_MAX_PIN PB1 - -// -// Steppers -// -#define X_STEP_PIN PC0 -#define X_DIR_PIN PB2 -#define X_ENABLE_PIN PC13 - -#define Y_STEP_PIN PC2 -#define Y_DIR_PIN PB9 -#define Y_ENABLE_PIN PB12 - -#define Z_STEP_PIN PB7 -#define Z_DIR_PIN PB6 -#define Z_ENABLE_PIN PB8 - -#define E0_STEP_PIN PB4 -#define E0_DIR_PIN PB3 -#define E0_ENABLE_PIN PB5 - -#if HAS_TMC220x - /** - * TMC2208/TMC2209 stepper drivers - * - * Hardware serial communication ports. - * If undefined software serial is used according to the pins below - */ - //#define X_HARDWARE_SERIAL Serial1 - //#define Y_HARDWARE_SERIAL Serial1 - //#define Z_HARDWARE_SERIAL Serial1 - //#define E0_HARDWARE_SERIAL Serial1 - - // - // Software serial - // - #define X_SERIAL_TX_PIN PC7 - #define X_SERIAL_RX_PIN PC7 - - #define Y_SERIAL_TX_PIN PD2 - #define Y_SERIAL_RX_PIN PD2 - - #define Z_SERIAL_TX_PIN PC12 - #define Z_SERIAL_RX_PIN PC12 - - #define E0_SERIAL_TX_PIN PC11 - #define E0_SERIAL_RX_PIN PC11 - - // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 -#endif - -// -// Heaters 0,1 / Fans / Bed -// -#define HEATER_0_PIN PC9 -#define FAN_PIN PA8 -#define HEATER_BED_PIN PC8 - -// -// Temperature Sensors -// -#define TEMP_BED_PIN PA1 //TB -#define TEMP_0_PIN PA0 //TH1 - -#define FIL_RUNOUT_PIN PB10 // MT_DET - -/** - * _____ _____ _____ - * (BEEPER) PC1 | 1 2 | PC3 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SD_SCK) 5V | 1 2 | GND - * (LCD_EN) PA4 | 3 4 | PA5 (LCD_RS) (BTN_EN1) PB11 | 3 4 | PA15 (SD_SS) (LCD_EN) PA4 | 3 4 | PA5 (LCD_RS) - * (LCD_D4) PA6 | 5 6 PA7 (LCD_D5) (BTN_EN2) PB0 | 5 6 PB15 (SD_MOSI) (LCD_D4) PA6 | 5 6 PB0 (BTN_EN2) - * (LCD_D6) PC4 | 7 8 | PC5 (LCD_D7) (SD_DETECT) PC10 | 7 8 | RESET RESET | 7 8 | PB11 (BTN_EN1) - * GND | 9 10| 5V GND | 9 10| NC (BTN_ENC) PC3 | 9 10| PC1 (BEEPER) - * ----- ----- ----- - * EXP1 EXP2 EXP3 - */ -#if HAS_SPI_LCD - - #define BEEPER_PIN PC1 - #define BTN_ENC PC3 - #define LCD_PINS_ENABLE PA4 - #define LCD_PINS_RS PA5 - #define BTN_EN1 PB11 - #define BTN_EN2 PB0 - - // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) - #if ENABLED(MKS_MINI_12864) - - #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN -1 - #define DOGLCD_A0 PC4 - #define DOGLCD_CS PA7 - #define DOGLCD_SCK PB13 - #define DOGLCD_MOSI PB15 - - // Required for MKS_MINI_12864 with this board - #define MKS_LCD12864B - #undef SHOW_BOOTSCREEN - - #else // !MKS_MINI_12864 - - #define LCD_PINS_D4 PA6 - #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 PA7 - #define LCD_PINS_D6 PC4 - #define LCD_PINS_D7 PC5 - #endif - - #endif // !MKS_MINI_12864 - -#endif // HAS_SPI_LCD - -// -// SD Card -// -#define ENABLE_SPI2 -#define SD_DETECT_PIN PC10 -#define SCK_PIN PB13 -#define MISO_PIN PB14 -#define MOSI_PIN PB15 -#define SS_PIN PA15 - -#ifndef ST7920_DELAY_1 - #define ST7920_DELAY_1 DELAY_NS(125) -#endif -#ifndef ST7920_DELAY_2 - #define ST7920_DELAY_2 DELAY_NS(125) -#endif -#ifndef ST7920_DELAY_3 - #define ST7920_DELAY_3 DELAY_NS(125) -#endif +#include "pins_MKS_ROBIN_E3_common.h" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h index 6111bef..0b8a443 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h @@ -25,71 +25,26 @@ * MKS Robin E3D (STM32F103RCT6) board pin assignments */ -#ifndef __STM32F1__ - #error "Oops! Select an STM32F1 board in 'Tools > Board.'" -#elif HOTENDS > 1 || E_STEPPERS > 1 +#if HOTENDS > 1 || E_STEPPERS > 1 #error "MKS Robin E3D supports up to 1 hotends / E-steppers. Comment out this line to continue." #endif #ifndef BOARD_INFO_NAME #define BOARD_INFO_NAME "MKS Robin E3D" #endif -#define BOARD_WEBSITE_URL "github.com/makerbase-mks" - -//#define DISABLE_DEBUG -#define DISABLE_JTAG -#define ENABLE_SPI2 - -// -// EEPROM -// -#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) - #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB - #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB -#endif - -// -// Servos -// -#define SERVO0_PIN PA3 - -// -// Limit Switches -// -#define X_STOP_PIN PA12 -#define Y_STOP_PIN PA11 -#define Z_MIN_PIN PC6 -#define Z_MAX_PIN PB1 // // Steppers // -#define X_STEP_PIN PC0 -#define X_DIR_PIN PB2 -#define X_ENABLE_PIN PC13 #ifndef X_CS_PIN #define X_CS_PIN PC7 #endif - -#define Y_STEP_PIN PC2 -#define Y_DIR_PIN PB9 -#define Y_ENABLE_PIN PB12 #ifndef Y_CS_PIN #define Y_CS_PIN PD2 #endif - -#define Z_STEP_PIN PB7 -#define Z_DIR_PIN PB6 -#define Z_ENABLE_PIN PB8 #ifndef Z_CS_PIN #define Z_CS_PIN PC12 #endif - -#define E0_STEP_PIN PB4 -#define E0_DIR_PIN PB3 -#define E0_ENABLE_PIN PB5 #ifndef E0_CS_PIN #define E0_CS_PIN PC11 #endif @@ -109,114 +64,4 @@ #endif #endif -#if HAS_TMC220x - /** - * TMC2208/TMC2209 stepper drivers - * - * Hardware serial communication ports. - * If undefined software serial is used according to the pins below - */ - //#define X_HARDWARE_SERIAL Serial1 - //#define Y_HARDWARE_SERIAL Serial1 - //#define Z_HARDWARE_SERIAL Serial1 - //#define E0_HARDWARE_SERIAL Serial1 - - // - // Software serial - // - #define X_SERIAL_TX_PIN PC7 - #define X_SERIAL_RX_PIN PC7 - - #define Y_SERIAL_TX_PIN PD2 - #define Y_SERIAL_RX_PIN PD2 - - #define Z_SERIAL_TX_PIN PC12 - #define Z_SERIAL_RX_PIN PC12 - - #define E0_SERIAL_TX_PIN PC11 - #define E0_SERIAL_RX_PIN PC11 - - // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 -#endif - -// -// Heaters 0,1 / Fans / Bed -// -#define HEATER_0_PIN PC9 -#define FAN_PIN PA8 -#define HEATER_BED_PIN PC8 - -// -// Temperature Sensors -// -#define TEMP_BED_PIN PA1 //TB -#define TEMP_0_PIN PA0 //TH1 - -#define FIL_RUNOUT_PIN PB10 // MT_DET - -/** - * _____ _____ _____ - * (BEEPER) PC1 | 1 2 | PC3 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SD_SCK) 5V | 1 2 | GND - * (LCD_EN) PA4 | 3 4 | PA5 (LCD_RS) (BTN_EN1) PB11 | 3 4 | PA15 (SD_SS) (LCD_EN) PA4 | 3 4 | PA5 (LCD_RS) - * (LCD_D4) PA6 | 5 6 PA7 (LCD_D5) (BTN_EN2) PB0 | 5 6 PB15 (SD_MOSI) (LCD_D4) PA6 | 5 6 PB0 (BTN_EN2) - * (LCD_D6) PC4 | 7 8 | PC5 (LCD_D7) (SD_DETECT) PC10 | 7 8 | RESET RESET | 7 8 | PB11 (BTN_EN1) - * GND | 9 10| 5V GND | 9 10| NC (BTN_ENC) PC3 | 9 10| PC1 (BEEPER) - * ----- ----- ----- - * EXP1 EXP2 EXP3 - */ -#if HAS_SPI_LCD - - #define BEEPER_PIN PC1 - #define BTN_ENC PC3 - #define LCD_PINS_ENABLE PA4 - #define LCD_PINS_RS PA5 - #define BTN_EN1 PB11 - #define BTN_EN2 PB0 - - // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) - #if ENABLED(MKS_MINI_12864) - - #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN -1 - #define DOGLCD_A0 PC4 - #define DOGLCD_CS PA7 - #define DOGLCD_SCK PB13 - #define DOGLCD_MOSI PB15 - - // Required for MKS_MINI_12864 with this board - #define MKS_LCD12864B - #undef SHOW_BOOTSCREEN - - #else // !MKS_MINI_12864 - - #define LCD_PINS_D4 PA6 - #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 PA7 - #define LCD_PINS_D6 PC4 - #define LCD_PINS_D7 PC5 - #endif - - #endif // !MKS_MINI_12864 - -#endif // HAS_SPI_LCD - -// -// SD Card -// -#define ENABLE_SPI2 -#define SD_DETECT_PIN PC10 -#define SCK_PIN PB13 -#define MISO_PIN PB14 -#define MOSI_PIN PB15 -#define SS_PIN PA15 - -#ifndef ST7920_DELAY_1 - #define ST7920_DELAY_1 DELAY_NS(125) -#endif -#ifndef ST7920_DELAY_2 - #define ST7920_DELAY_2 DELAY_NS(125) -#endif -#ifndef ST7920_DELAY_3 - #define ST7920_DELAY_3 DELAY_NS(125) -#endif +#include "pins_MKS_ROBIN_E3_common.h" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h new file mode 100644 index 0000000..b575b24 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -0,0 +1,188 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * MKS Robin E3 & E3D (STM32F103RCT6) common board pin assignments + */ + +#ifndef __STM32F1__ + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#endif + +#define BOARD_WEBSITE_URL "github.com/makerbase-mks" + +//#define DISABLE_DEBUG +#define DISABLE_JTAG +#define ENABLE_SPI2 + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB +#endif + +// +// Servos +// +#define SERVO0_PIN PA3 + +// +// Limit Switches +// +#define X_STOP_PIN PA12 +#define Y_STOP_PIN PA11 +#define Z_MIN_PIN PC6 +#define Z_MAX_PIN PB1 + +// +// Steppers +// +#define X_STEP_PIN PC0 +#define X_DIR_PIN PB2 +#define X_ENABLE_PIN PC13 + +#define Y_STEP_PIN PC2 +#define Y_DIR_PIN PB9 +#define Y_ENABLE_PIN PB12 + +#define Z_STEP_PIN PB7 +#define Z_DIR_PIN PB6 +#define Z_ENABLE_PIN PB8 + +#define E0_STEP_PIN PB4 +#define E0_DIR_PIN PB3 +#define E0_ENABLE_PIN PB5 + +#if HAS_TMC220x + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + + // + // Software serial + // + #define X_SERIAL_TX_PIN PC7 + #define X_SERIAL_RX_PIN PC7 + + #define Y_SERIAL_TX_PIN PD2 + #define Y_SERIAL_RX_PIN PD2 + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN PC12 + + #define E0_SERIAL_TX_PIN PC11 + #define E0_SERIAL_RX_PIN PC11 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Heaters 0,1 / Fans / Bed +// +#define HEATER_0_PIN PC9 +#define FAN_PIN PA8 +#define HEATER_BED_PIN PC8 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA1 // TB +#define TEMP_0_PIN PA0 // TH1 + +#define FIL_RUNOUT_PIN PB10 // MT_DET + +/** + * _____ _____ _____ + * (BEEPER) PC1 | 1 2 | PC3 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SD_SCK) 5V | 1 2 | GND + * (LCD_EN) PA4 | 3 4 | PA5 (LCD_RS) (BTN_EN1) PB11 | 3 4 | PA15 (SD_SS) (LCD_EN) PA4 | 3 4 | PA5 (LCD_RS) + * (LCD_D4) PA6 | 5 6 PA7 (LCD_D5) (BTN_EN2) PB0 | 5 6 PB15 (SD_MOSI) (LCD_D4) PA6 | 5 6 PB0 (BTN_EN2) + * (LCD_D6) PC4 | 7 8 | PC5 (LCD_D7) (SD_DETECT) PC10 | 7 8 | RESET RESET | 7 8 | PB11 (BTN_EN1) + * GND | 9 10| 5V GND | 9 10| NC (BTN_ENC) PC3 | 9 10| PC1 (BEEPER) + * ----- ----- ----- + * EXP1 EXP2 EXP3 + */ +#if HAS_SPI_LCD + + #define BEEPER_PIN PC1 + #define BTN_ENC PC3 + #define LCD_PINS_ENABLE PA4 + #define LCD_PINS_RS PA5 + #define BTN_EN1 PB11 + #define BTN_EN2 PB0 + + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 PC4 + #define DOGLCD_CS PA7 + #define DOGLCD_SCK PB13 + #define DOGLCD_MOSI PB15 + + #undef SHOW_BOOTSCREEN + + #else + + #define LCD_PINS_D4 PA6 + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 PA7 + #define LCD_PINS_D6 PC4 + #define LCD_PINS_D7 PC5 + #endif + + #endif // !MKS_MINI_12864 + +#endif // HAS_SPI_LCD + +// +// SD Card +// +#define ENABLE_SPI2 +#define SD_DETECT_PIN PC10 +#define SCK_PIN PB13 +#define MISO_PIN PB14 +#define MOSI_PIN PB15 +#define SS_PIN PA15 + +#ifndef ST7920_DELAY_1 + #define ST7920_DELAY_1 DELAY_NS(125) +#endif +#ifndef ST7920_DELAY_2 + #define ST7920_DELAY_2 DELAY_NS(125) +#endif +#ifndef ST7920_DELAY_3 + #define ST7920_DELAY_3 DELAY_NS(125) +#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index 4c10a31..0763016 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -111,6 +111,18 @@ #endif // !MKS_MINI_12864 + #if HAS_GRAPHICAL_LCD + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #endif + #endif + #endif // HAS_SPI_LCD // Motor current PWM pins @@ -129,9 +141,3 @@ #define MISO_PIN P1B4 #define MOSI_PIN P1B5 #define SS_PIN PA15 - -#if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(125) - #define BOARD_ST7920_DELAY_2 DELAY_NS(125) - #define BOARD_ST7920_DELAY_3 DELAY_NS(125) -#endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h index 466bdec..5f94a15 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h @@ -115,8 +115,6 @@ #define DOGLCD_SCK PB13 #define DOGLCD_MOSI PB15 - // Required for MKS_MINI_12864 with this board - #define MKS_LCD12864B #undef SHOW_BOOTSCREEN #else // !MKS_MINI_12864 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index 06369fb..2b10f08 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -45,6 +45,7 @@ //#define FLASH_EEPROM_EMULATION #define SDCARD_EEPROM_EMULATION #endif +#define ENABLE_SPI2 // // Limit Switches @@ -91,11 +92,24 @@ // // Heaters / Fans // -#define HEATER_0_PIN PC3 // HEATER1 -#define HEATER_1_PIN PB0 // HEATER2 -#define HEATER_BED_PIN PA0 // HOT BED - -#define FAN_PIN PB1 // FAN +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PC3 +#endif +#if HOTENDS == 1 + #ifndef FAN1_PIN + #define FAN1_PIN PB0 + #endif +#else + #ifndef HEATER_1_PIN + #define HEATER_1_PIN PB0 + #endif +#endif +#ifndef FAN_PIN + #define FAN_PIN PB1 // FAN +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PA0 +#endif // // Thermocouples @@ -106,10 +120,21 @@ // // Misc. Functions // -#define POWER_LOSS_PIN PA2 // PW_DET -#define PS_ON_PIN PA3 // PW_OFF +//#define POWER_LOSS_PIN PA2 // PW_DET +//#define PS_ON_PIN PA3 // PW_OFF -#define LED_PIN PB2 +//#define SUICIDE_PIN PB2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY +//#define SUICIDE_PIN_INVERTING false + +//#define KILL_PIN PA2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY +//#define KILL_PIN_INVERTING true // Enable MKSPWC support ROBIN NANO v1.2 ONLY + +//#define SERVO0_PIN PA8 // Enable BLTOUCH support ROBIN NANO v1.2 ONLY + +//#define LED_PIN PB2 + +#define MT_DET_1_PIN PA4 +#define MT_DET_PIN_INVERTING false // // SD Card @@ -119,7 +144,9 @@ #endif #define SDIO_SUPPORT +#define SDIO_CLOCK 4500000 // 4.5 MHz #define SD_DETECT_PIN PD12 +#define ONBOARD_SD_CS_PIN PC11 // // LCD / Controller @@ -131,7 +158,90 @@ * If the screen stays white, disable 'LCD_RESET_PIN' * to let the bootloader init the screen. */ -#if ENABLED(FSMC_GRAPHICAL_TFT) + +#if ENABLED(SPI_GRAPHICAL_TFT) + + #if HAS_SPI_LCD + + #define BEEPER_PIN PC5 + #define BTN_ENC PE13 + #define LCD_PINS_ENABLE PD13 + #define LCD_PINS_RS PC6 + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 + #define LCD_BACKLIGHT_PIN -1 + + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 PD11 + #define DOGLCD_CS PE15 + #define DOGLCD_SCK PA5 + #define DOGLCD_MOSI PA7 + + // Required for MKS_MINI_12864 with this board + #define MKS_LCD12864B + #undef SHOW_BOOTSCREEN + + #else // !MKS_MINI_12864 + + #define LCD_PINS_D4 PE14 + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 PE15 + #define LCD_PINS_D6 PD11 + #define LCD_PINS_D7 PD10 + #endif + + #ifndef ST7920_DELAY_1 + #define ST7920_DELAY_1 DELAY_NS(125) + #endif + #ifndef ST7920_DELAY_2 + #define ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef ST7920_DELAY_3 + #define ST7920_DELAY_3 DELAY_NS(125) + #endif + + #endif // !MKS_MINI_12864 + + #else + + #define SPI_TFT_CS_PIN PD11 + #define SPI_TFT_SCK_PIN PA5 + #define SPI_TFT_MISO_PIN PA6 + #define SPI_TFT_MOSI_PIN PA7 + #define SPI_TFT_DC_PIN PD10 + #define SPI_TFT_RST_PIN PC6 + + #define LCD_BACKLIGHT_PIN PD13 + + #define TOUCH_CS_PIN PE14 // SPI1_NSS + #define TOUCH_SCK_PIN PA5 // SPI1_SCK + #define TOUCH_MISO_PIN PA6 // SPI1_MISO + #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI + + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 + #define BEEPER_PIN PC5 + #define BTN_ENC PE13 + + #endif // HAS_SPI_LCD + +#elif ENABLED(TFT_LITTLE_VGL_UI) + + #define FSMC_CS_PIN PD7 // NE4 + #define FSMC_RS_PIN PD11 // A0 + + #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 LCD_BACKLIGHT_PIN PD13 + +#elif ENABLED(FSMC_GRAPHICAL_TFT) + #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 @@ -146,4 +256,13 @@ #define TOUCH_MISO_PIN PB14 // SPI2_MISO #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI #endif + +#endif + +#define SPI_FLASH +#if ENABLED(SPI_FLASH) + #define W25QXX_CS_PIN PB12 + #define W25QXX_MOSI_PIN PB15 + #define W25QXX_MISO_PIN PB14 + #define W25QXX_SCK_PIN PB13 #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index 8a6afcc..a759445 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -237,9 +237,15 @@ // Alter timing for graphical display #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) - #define BOARD_ST7920_DELAY_3 DELAY_NS(600) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(600) + #endif #endif #endif // HAS_SPI_LCD diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index e2ecdae..4ecee9c 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -328,9 +328,10 @@ #define LCD_PINS_ENABLE PG5 #define LCD_PINS_D4 PG7 - //#undef ST7920_DELAY_1 - //#undef ST7920_DELAY_2 - //#undef ST7920_DELAY_3 + // CR10_STOCKDISPLAY default timing is too fast + #undef BOARD_ST7920_DELAY_1 + #undef BOARD_ST7920_DELAY_2 + #undef BOARD_ST7920_DELAY_3 #else @@ -377,9 +378,15 @@ // Alter timing for graphical display #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) - #define BOARD_ST7920_DELAY_3 DELAY_NS(600) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(600) + #endif #endif //#define DOGLCD_CS PB12 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h index ccb03e7..64a8ddb 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h @@ -21,340 +21,10 @@ */ #pragma once -#ifndef TARGET_STM32F4 - #error "Oops! Select an STM32F4 board in 'Tools > Board.'" -#elif HOTENDS > 3 || E_STEPPERS > 3 +#if HOTENDS > 3 || E_STEPPERS > 3 #error "BIGTREE SKR Pro V1.1 supports up to 3 hotends / E-steppers." #endif -#define BOARD_INFO_NAME "BTT SKR Pro V1.1" // redefined? +#define BOARD_INFO_NAME "BTT SKR Pro V1.1" -// Use one of these or SDCard-based Emulation will be used -#if NO_EEPROM_SELECTED - //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation - #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation -#endif - -#if ENABLED(FLASH_EEPROM_EMULATION) - // Decrease delays and flash wear by spreading writes across the - // 128 kB sector allocated for EEPROM emulation. - #define FLASH_EEPROM_LEVELING -#endif - -// -// Servos -// -#define SERVO0_PIN PA1 - -// -// Trinamic Stallguard pins -// -#define X_DIAG_PIN PB10 // X- -#define Y_DIAG_PIN PE12 // Y- -#define Z_DIAG_PIN PG8 // Z- -#define E0_DIAG_PIN PE15 // E0 -#define E1_DIAG_PIN PE10 // E1 -#define E2_DIAG_PIN PG5 // E2 - -// -// Limit Switches -// -#ifdef X_STALL_SENSITIVITY - #define X_STOP_PIN X_DIAG_PIN - #if X_HOME_DIR < 0 - #define X_MAX_PIN PE15 // E0 - #else - #define X_MIN_PIN PE15 // E0 - #endif -#else - #define X_MIN_PIN PB10 // X- - #define X_MAX_PIN PE15 // E0 -#endif - -#ifdef Y_STALL_SENSITIVITY - #define Y_STOP_PIN Y_DIAG_PIN - #if Y_HOME_DIR < 0 - #define Y_MAX_PIN PE10 // E1 - #else - #define Y_MIN_PIN PE10 // E1 - #endif -#else - #define Y_MIN_PIN PE12 // Y- - #define Y_MAX_PIN PE10 // E1 -#endif - -#ifdef Z_STALL_SENSITIVITY - #define Z_STOP_PIN Z_DIAG_PIN - #if Z_HOME_DIR < 0 - #define Z_MAX_PIN PG5 // E2 - #else - #define Z_MIN_PIN PG5 // E2 - #endif -#else - #define Z_MIN_PIN PG8 // Z- - #define Z_MAX_PIN PG5 // E2 -#endif - -// -// Z Probe must be this pin -// -#ifndef Z_MIN_PROBE_PIN - #define Z_MIN_PROBE_PIN PA2 -#endif - -// -// Steppers -// -#define X_STEP_PIN PE9 -#define X_DIR_PIN PF1 -#define X_ENABLE_PIN PF2 -#ifndef X_CS_PIN - #define X_CS_PIN PA15 -#endif - -#define Y_STEP_PIN PE11 -#define Y_DIR_PIN PE8 -#define Y_ENABLE_PIN PD7 - #ifndef Y_CS_PIN - #define Y_CS_PIN PB8 -#endif - -#define Z_STEP_PIN PE13 -#define Z_DIR_PIN PC2 -#define Z_ENABLE_PIN PC0 -#ifndef Z_CS_PIN - #define Z_CS_PIN PB9 -#endif - -#define E0_STEP_PIN PE14 -#define E0_DIR_PIN PA0 -#define E0_ENABLE_PIN PC3 -#ifndef E0_CS_PIN - #define E0_CS_PIN PB3 -#endif - -#define E1_STEP_PIN PD15 -#define E1_DIR_PIN PE7 -#define E1_ENABLE_PIN PA3 -#ifndef E1_CS_PIN - #define E1_CS_PIN PG15 -#endif - -#define E2_STEP_PIN PD13 -#define E2_DIR_PIN PG9 -#define E2_ENABLE_PIN PF0 -#ifndef E2_CS_PIN - #define E2_CS_PIN PG12 -#endif - -// -// Software SPI pins for TMC2130 stepper drivers -// -#if ENABLED(TMC_USE_SW_SPI) - #ifndef TMC_SW_MOSI - #define TMC_SW_MOSI PC12 - #endif - #ifndef TMC_SW_MISO - #define TMC_SW_MISO PC11 - #endif - #ifndef TMC_SW_SCK - #define TMC_SW_SCK PC10 - #endif -#endif - -#if HAS_TMC_UART - /** - * TMC2208/TMC2209 stepper drivers - * - * Hardware serial communication ports. - * If undefined software serial is used according to the pins below - */ - //#define X_HARDWARE_SERIAL Serial - //#define X2_HARDWARE_SERIAL Serial1 - //#define Y_HARDWARE_SERIAL Serial1 - //#define Y2_HARDWARE_SERIAL Serial1 - //#define Z_HARDWARE_SERIAL Serial1 - //#define Z2_HARDWARE_SERIAL Serial1 - //#define E0_HARDWARE_SERIAL Serial1 - //#define E1_HARDWARE_SERIAL Serial1 - //#define E2_HARDWARE_SERIAL Serial1 - //#define E3_HARDWARE_SERIAL Serial1 - //#define E4_HARDWARE_SERIAL Serial1 - - // - // Software serial - // - #define X_SERIAL_TX_PIN PC13 - #define X_SERIAL_RX_PIN PC13 - - #define Y_SERIAL_TX_PIN PE3 - #define Y_SERIAL_RX_PIN PE3 - - #define Z_SERIAL_TX_PIN PE1 - #define Z_SERIAL_RX_PIN PE1 - - #define E0_SERIAL_TX_PIN PD4 - #define E0_SERIAL_RX_PIN PD4 - - #define E1_SERIAL_TX_PIN PD1 - #define E1_SERIAL_RX_PIN PD1 - - #define E2_SERIAL_TX_PIN PD6 - #define E2_SERIAL_RX_PIN PD6 - - // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 -#endif - -// -// Temperature Sensors -// -#define TEMP_0_PIN PF4 // T1 <-> E0 -#define TEMP_1_PIN PF5 // T2 <-> E1 -#define TEMP_2_PIN PF6 // T3 <-> E2 -#define TEMP_BED_PIN PF3 // T0 <-> Bed - -// -// Heaters / Fans -// -#define HEATER_0_PIN PB1 // Heater0 -#define HEATER_1_PIN PD14 // Heater1 -#define HEATER_2_PIN PB0 // Heater1 -#define HEATER_BED_PIN PD12 // Hotbed -#define FAN_PIN PC8 // Fan0 -#define FAN1_PIN PE5 // Fan1 -#define FAN2_PIN PE6 - -#ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN FAN1_PIN -#endif - -// -// Misc. Functions -// - -#ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION LCD -#endif - -// -// Onboard SD card -// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 -// -#if SD_CONNECTION_IS(ONBOARD) - #define SOFTWARE_SPI // Use soft SPI for onboard SD - #define SDSS PA4 - #define SCK_PIN PA5 - #define MISO_PIN PA6 - #define MOSI_PIN PB5 -#endif - -/** - * _____ _____ - * NC | · · | GND 5V | · · | GND - * RESET | · · | PF12(SD_DETECT) (LCD_D7) PG7 | · · | PG6 (LCD_D6) - * (MOSI)PB15 | · · | PF11(BTN_EN2) (LCD_D5) PG3 | · · | PG2 (LCD_D4) - * (SD_SS)PB12 | · · | PG10(BTN_EN1) (LCD_RS) PD10 | · · | PD11 (LCD_EN) - * (SCK)PB13 | · · | PB14(MISO) (BTN_ENC) PA8 | · · | PG4 (BEEPER) - *  ̄ ̄  ̄ ̄ - * EXP2 EXP1 - */ - -// -// LCDs and Controllers -// -#if HAS_SPI_LCD - #define BEEPER_PIN PG4 - #define BTN_ENC PA8 - #if SD_CONNECTION_IS(LCD) - #define SDSS PB12 // Uses default hardware SPI for LCD's SD - #endif - - #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS PG6 - - #define BTN_EN1 PD11 - #define BTN_EN2 PG2 - - #define LCD_PINS_ENABLE PG7 - #define LCD_PINS_D4 PG3 - - // CR10_Stock Display needs a different delay setting on SKR PRO v1.1, so undef it here. - // It will be defined again at the #HAS_GRAPHICAL_LCD section below. - #undef ST7920_DELAY_1 - #undef ST7920_DELAY_2 - #undef ST7920_DELAY_3 - - #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 PG6 - #define DOGLCD_CS PG3 - - #else - - #define LCD_PINS_RS PD10 - - #define BTN_EN1 PG10 - #define BTN_EN2 PF11 - #define SD_DETECT_PIN PF12 - - #define LCD_SDSS PB12 - - #define LCD_PINS_ENABLE PD11 - #define LCD_PINS_D4 PG2 - - #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS PD11 - #define DOGLCD_A0 PD10 - //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN PG2 // Must be high or open for LCD to operate normally. - #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) - #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN PG3 - #endif - #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN PG6 - #endif - #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN PG7 - #endif - #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN PG3 - #endif - #endif // !FYSETC_MINI_12864 - - #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 PG3 - #define LCD_PINS_D6 PG6 - #define LCD_PINS_D7 PG7 - #endif - - #endif - - // Alter timing for graphical display - #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) - #define BOARD_ST7920_DELAY_3 DELAY_NS(600) - #endif - -#endif // HAS_SPI_LCD - -// -// WIFI -// - -/** - * _____ - * TX | 1 2 | GND Enable PG1 // Must be high for module to run - * Enable | 3 4 | GPIO2 Reset PG0 // active low, probably OK to leave floating - * Reset | 5 6 | GPIO0 GPIO2 PF15 // must be high (ESP3D software configures this with a pullup so OK to leave as floating) - * 3.3V| 7 8 | RX GPIO0 PF14 // Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) - *  ̄ ̄ - * W1 - */ -#define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this -#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 -#define ESP_WIFI_MODULE_RESET_PIN PG0 -#define ESP_WIFI_MODULE_ENABLE_PIN PG1 -#define ESP_WIFI_MODULE_GPIO0_PIN PF14 -#define ESP_WIFI_MODULE_GPIO2_PIN PF15 +#include "pins_BTT_SKR_PRO_common.h" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_2.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_2.h new file mode 100644 index 0000000..01ab161 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_2.h @@ -0,0 +1,30 @@ +/** + * 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 HOTENDS > 3 || E_STEPPERS > 3 + #error "BIGTREE SKR Pro V1.2 supports up to 3 hotends / E-steppers." +#endif + +#define BOARD_INFO_NAME "BTT SKR Pro V1.2" + +#include "pins_BTT_SKR_PRO_common.h" diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h new file mode 100644 index 0000000..1f2c8d9 --- /dev/null +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -0,0 +1,361 @@ +/** + * 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 + +#ifndef TARGET_STM32F4 + #error "Oops! Select an STM32F4 board in 'Tools > Board.'" +#endif + +// Use one of these or SDCard-based Emulation will be used +#if NO_EEPROM_SELECTED + //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#endif + +// +// Servos +// +#define SERVO0_PIN PA1 + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PB10 // X- +#define Y_DIAG_PIN PE12 // Y- +#define Z_DIAG_PIN PG8 // Z- +#define E0_DIAG_PIN PE15 // E0 +#define E1_DIAG_PIN PE10 // E1 +#define E2_DIAG_PIN PG5 // E2 + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_DIR < 0 + #define X_MAX_PIN PE15 // E0 + #else + #define X_MIN_PIN PE15 // E0 + #endif +#else + #define X_MIN_PIN PB10 // X- + #define X_MAX_PIN PE15 // E0 +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_DIR < 0 + #define Y_MAX_PIN PE10 // E1 + #else + #define Y_MIN_PIN PE10 // E1 + #endif +#else + #define Y_MIN_PIN PE12 // Y- + #define Y_MAX_PIN PE10 // E1 +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_DIR < 0 + #define Z_MAX_PIN PG5 // E2 + #else + #define Z_MIN_PIN PG5 // E2 + #endif +#else + #define Z_MIN_PIN PG8 // Z- + #define Z_MAX_PIN PG5 // E2 +#endif + +// +// Z Probe must be this pin +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PA2 +#endif + +// +// Steppers +// +#define X_STEP_PIN PE9 +#define X_DIR_PIN PF1 +#define X_ENABLE_PIN PF2 +#ifndef X_CS_PIN + #define X_CS_PIN PA15 +#endif + +#define Y_STEP_PIN PE11 +#define Y_DIR_PIN PE8 +#define Y_ENABLE_PIN PD7 + #ifndef Y_CS_PIN + #define Y_CS_PIN PB8 +#endif + +#define Z_STEP_PIN PE13 +#define Z_DIR_PIN PC2 +#define Z_ENABLE_PIN PC0 +#ifndef Z_CS_PIN + #define Z_CS_PIN PB9 +#endif + +#define E0_STEP_PIN PE14 +#define E0_DIR_PIN PA0 +#define E0_ENABLE_PIN PC3 +#ifndef E0_CS_PIN + #define E0_CS_PIN PB3 +#endif + +#define E1_STEP_PIN PD15 +#define E1_DIR_PIN PE7 +#define E1_ENABLE_PIN PA3 +#ifndef E1_CS_PIN + #define E1_CS_PIN PG15 +#endif + +#define E2_STEP_PIN PD13 +#define E2_DIR_PIN PG9 +#define E2_ENABLE_PIN PF0 +#ifndef E2_CS_PIN + #define E2_CS_PIN PG12 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PC12 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PC11 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PC10 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + // + // Software serial + // + #define X_SERIAL_TX_PIN PC13 + #define X_SERIAL_RX_PIN PC13 + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN PE3 + + #define Z_SERIAL_TX_PIN PE1 + #define Z_SERIAL_RX_PIN PE1 + + #define E0_SERIAL_TX_PIN PD4 + #define E0_SERIAL_RX_PIN PD4 + + #define E1_SERIAL_TX_PIN PD1 + #define E1_SERIAL_RX_PIN PD1 + + #define E2_SERIAL_TX_PIN PD6 + #define E2_SERIAL_RX_PIN PD6 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PF4 // T1 <-> E0 +#define TEMP_1_PIN PF5 // T2 <-> E1 +#define TEMP_2_PIN PF6 // T3 <-> E2 +#define TEMP_BED_PIN PF3 // T0 <-> Bed + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB1 // Heater0 +#define HEATER_1_PIN PD14 // Heater1 +#define HEATER_2_PIN PB0 // Heater1 +#define HEATER_BED_PIN PD12 // Hotbed +#define FAN_PIN PC8 // Fan0 +#define FAN1_PIN PE5 // Fan1 +#define FAN2_PIN PE6 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN +#endif + +// +// Misc. Functions +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION LCD +#endif + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(ONBOARD) + #define SOFTWARE_SPI // Use soft SPI for onboard SD + #define SDSS PA4 + #define SCK_PIN PA5 + #define MISO_PIN PA6 + #define MOSI_PIN PB5 +#endif + +/** + * _____ _____ + * NC | · · | GND 5V | · · | GND + * RESET | · · | PF12(SD_DETECT) (LCD_D7) PG7 | · · | PG6 (LCD_D6) + * (MOSI)PB15 | · · | PF11(BTN_EN2) (LCD_D5) PG3 | · · | PG2 (LCD_D4) + * (SD_SS)PB12 | · · | PG10(BTN_EN1) (LCD_RS) PD10 | · · | PD11 (LCD_EN) + * (SCK)PB13 | · · | PB14(MISO) (BTN_ENC) PA8 | · · | PG4 (BEEPER) + *  ̄ ̄  ̄ ̄ + * EXP2 EXP1 + */ + +// +// LCDs and Controllers +// +#if HAS_SPI_LCD + #define BEEPER_PIN PG4 + #define BTN_ENC PA8 + #if SD_CONNECTION_IS(LCD) + #define SDSS PB12 // Uses default hardware SPI for LCD's SD + #endif + + #if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS PG6 + + #define BTN_EN1 PD11 + #define BTN_EN2 PG2 + + #define LCD_PINS_ENABLE PG7 + #define LCD_PINS_D4 PG3 + + // CR10_STOCKDISPLAY default timing is too fast + #undef BOARD_ST7920_DELAY_1 + #undef BOARD_ST7920_DELAY_2 + #undef BOARD_ST7920_DELAY_3 + + #elif ENABLED(MKS_MINI_12864) + #define DOGLCD_A0 PG6 + #define DOGLCD_CS PG3 + + #else + + #define LCD_PINS_RS PD10 + + #define BTN_EN1 PG10 + #define BTN_EN2 PF11 + #define SD_DETECT_PIN PF12 + + #define LCD_SDSS PB12 + + #define LCD_PINS_ENABLE PD11 + #define LCD_PINS_D4 PG2 + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS PD11 + #define DOGLCD_A0 PD10 + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN PG2 // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PG3 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PG6 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PG7 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN PG3 + #endif + #endif // !FYSETC_MINI_12864 + + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 PG3 + #define LCD_PINS_D6 PG6 + #define LCD_PINS_D7 PG7 + #endif + + #endif + + // Alter timing for graphical display + #if HAS_GRAPHICAL_LCD + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(600) + #endif + #endif + +#endif // HAS_SPI_LCD + +// +// WIFI +// + +/** + * _____ + * TX | 1 2 | GND Enable PG1 // Must be high for module to run + * Enable | 3 4 | GPIO2 Reset PG0 // active low, probably OK to leave floating + * Reset | 5 6 | GPIO0 GPIO2 PF15 // must be high (ESP3D software configures this with a pullup so OK to leave as floating) + * 3.3V| 7 8 | RX GPIO0 PF14 // Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) + *  ̄ ̄ + * W1 + */ +#define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_RESET_PIN PG0 +#define ESP_WIFI_MODULE_ENABLE_PIN PG1 +#define ESP_WIFI_MODULE_GPIO0_PIN PF14 +#define ESP_WIFI_MODULE_GPIO2_PIN PF15 diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 9895213..2d931f3 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -191,11 +191,10 @@ #define LCD_PINS_ENABLE PD1 #define LCD_PINS_D4 PC12 - // CR10_Stock Display needs a different delay setting on SKR PRO v1.1, so undef it here. - // It will be defined again at the #HAS_GRAPHICAL_LCD section below. - #undef ST7920_DELAY_1 - #undef ST7920_DELAY_2 - #undef ST7920_DELAY_3 + // CR10_STOCKDISPLAY default timing is too fast + #undef BOARD_ST7920_DELAY_1 + #undef BOARD_ST7920_DELAY_2 + #undef BOARD_ST7920_DELAY_3 #else diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h index 0d9356c..355d1eb 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h @@ -185,7 +185,13 @@ // ST7920 Delays // #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) - #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #endif #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_LERDGE_K.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_LERDGE_K.h index 3d274b1..35ad324 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_LERDGE_K.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_LERDGE_K.h @@ -173,7 +173,13 @@ // ST7920 Delays // #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) - #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #endif #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_LERDGE_X.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_LERDGE_X.h index 436381e..04588be 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_LERDGE_X.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_LERDGE_X.h @@ -170,7 +170,13 @@ // ST7920 Delays // #if HAS_GRAPHICAL_LCD - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) - #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(715) + #endif #endif diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h index 87e0e46..12108fc 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h @@ -31,7 +31,7 @@ #define BOARD_INFO_NAME "RUMBA32" #if NO_EEPROM_SELECTED - #if MB(RUMBA32_V1_0) + #if MB(RUMBA32_V1_0) #define FLASH_EEPROM_EMULATION #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #elif MB(RUMBA32_V1_1) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h index 521f720..118b8d8 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h @@ -37,7 +37,7 @@ #if NO_EEPROM_SELECTED #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif #if ENABLED(FLASH_EEPROM_EMULATION) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h index 08608d1..50c9949 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h @@ -44,9 +44,10 @@ // TIM7 is used for SERVO // TIMER_SERIAL defaults to TIM7 so we'll override it here // -#define STEP_TIMER 10 -#define TEMP_TIMER 14 +#define STEP_TIMER 10 +#define TEMP_TIMER 14 #define TIMER_SERIAL TIM9 +#define HAL_TIMER_RATE F_CPU // // Limit Switches diff --git a/Marlin-bugfix-2.0.x/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin-bugfix-2.0.x/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index f5f05dd..c0e089a 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -246,7 +246,7 @@ //#define MOSI 22 // 12 B2 ICSP-03 EXP2-05 //#define MISO 23 // 13 B3 ICSP-06 EXP2-05 - // increase delays + // Alter timing for graphical display #define BOARD_ST7920_DELAY_1 DELAY_NS(313) #define BOARD_ST7920_DELAY_2 DELAY_NS(313) #define BOARD_ST7920_DELAY_3 DELAY_NS(313) diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/cardreader.cpp b/Marlin-bugfix-2.0.x/Marlin/src/sd/cardreader.cpp index 9c662fd..2631edf 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/cardreader.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/cardreader.cpp @@ -28,6 +28,11 @@ #include "../MarlinCore.h" #include "../lcd/ultralcd.h" + +#if ENABLED(DWIN_CREALITY_LCD) + #include "../lcd/dwin/dwin.h" +#endif + #include "../module/planner.h" // for synchronize #include "../module/printcounter.h" #include "../gcode/queue.h" @@ -180,7 +185,7 @@ int CardReader::countItems(SdFile dir) { while (dir.readDir(&p, longFilename) > 0) c += is_dir_or_gcode(p); - #if ENABLED(SDCARD_SORT_ALPHA) && SDSORT_USES_RAM && SDSORT_CACHE_NAMES + #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) nrFiles = c; #endif @@ -385,7 +390,11 @@ void CardReader::mount() { void CardReader::manage_media() { static uint8_t prev_stat = TERN(INIT_SDCARD_ON_BOOT, 2, 0); uint8_t stat = uint8_t(IS_SD_INSERTED()); - if (stat != prev_stat && ui.detected()) { + if (stat == prev_stat) return; + + flag.workDirIsRoot = true; // Return to root on mount/release + + if (ui.detected()) { uint8_t old_stat = prev_stat; prev_stat = stat; // Change now to prevent re-entry @@ -420,6 +429,10 @@ void CardReader::manage_media() { void CardReader::release() { endFilePrint(); flag.mounted = false; + flag.workDirIsRoot = true; + #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) + nrFiles = 0; + #endif } void CardReader::openAndPrintFile(const char *name) { @@ -440,6 +453,7 @@ void CardReader::startFileprint() { void CardReader::endFilePrint(TERN_(SD_RESORT, const bool re_sort/*=false*/)) { TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0); + TERN_(DWIN_CREALITY_LCD, HMI_flag.print_finish = flag.sdprinting); flag.sdprinting = flag.abort_sd_printing = false; if (isFileOpen()) file.close(); TERN_(SD_RESORT, if (re_sort) presort()); @@ -944,7 +958,7 @@ void CardReader::cdroot() { #if HAS_FOLDER_SORTING const uint16_t bit = i & 0x07, ind = i >> 3; if (bit == 0) isDir[ind] = 0x00; - if (flag.filenameIsDir) isDir[ind] |= _BV(bit); + if (flag.filenameIsDir) SBI(isDir[ind], bit); #endif #endif } @@ -972,7 +986,7 @@ void CardReader::cdroot() { #if HAS_FOLDER_SORTING #if ENABLED(SDSORT_USES_RAM) // Folder sorting needs an index and bit to test for folder-ness. - #define _SORT_CMP_DIR(fs) IS_DIR(o1) == IS_DIR(o2) ? _SORT_CMP_NODIR() : IS_DIR(fs > 0 ? o1 : o2) + #define _SORT_CMP_DIR(fs) (IS_DIR(o1) == IS_DIR(o2) ? _SORT_CMP_NODIR() : IS_DIR(fs > 0 ? o1 : o2)) #else #define _SORT_CMP_DIR(fs) ((dir1 == flag.filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1)) #endif @@ -1062,13 +1076,14 @@ void CardReader::cdroot() { #endif // SDCARD_SORT_ALPHA uint16_t CardReader::get_num_Files() { - return - #if ENABLED(SDCARD_SORT_ALPHA) && SDSORT_USES_RAM && SDSORT_CACHE_NAMES + if (!isMounted()) return 0; + return ( + #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) nrFiles // no need to access the SD card for filenames #else countFilesInWorkDir() #endif - ; + ); } // @@ -1084,9 +1099,7 @@ void CardReader::fileHasFinished() { startFileprint(); } else { - endFilePrint(); - - TERN_(SDCARD_SORT_ALPHA, presort()); + endFilePrint(TERN_(SD_RESORT, true)); marlin_state = MF_SD_COMPLETE; } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/cardreader.h b/Marlin-bugfix-2.0.x/Marlin/src/sd/cardreader.h index 4f488e3..36b8191 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/cardreader.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/cardreader.h @@ -152,6 +152,7 @@ public: static inline bool isFileOpen() { return isMounted() && file.isOpen(); } static inline uint32_t getIndex() { return sdpos; } + static inline uint32_t getFileSize() { return filesize; } static inline bool eof() { return sdpos >= filesize; } static inline void setIndex(const uint32_t index) { sdpos = index; file.seekSet(index); } static inline char* getWorkDirName() { workDir.getDosName(filename); return filename; } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp index 9092633..5601446 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp @@ -428,7 +428,7 @@ void USB::Task() { //USB state machine uint8_t rcode; uint8_t tmpdata; static uint32_t delay = 0; - //USB_DEVICE_DESCRIPTOR buf; + //USB_FD_DEVICE_DESCRIPTOR buf; bool lowspeed = false; MAX3421E::Task(); @@ -647,8 +647,8 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { //printf("Configuring: parent = %i, port = %i\r\n", parent, port); uint8_t devConfigIndex; uint8_t rcode = 0; - uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; - USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); + uint8_t buf[sizeof (USB_FD_DEVICE_DESCRIPTOR)]; + USB_FD_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); UsbDevice *p = nullptr; EpInfo *oldep_ptr = nullptr; EpInfo epInfo; @@ -678,13 +678,13 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { p->lowspeed = lowspeed; // Get device descriptor - rcode = getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); + rcode = getDevDescr(0, 0, sizeof (USB_FD_DEVICE_DESCRIPTOR), (uint8_t*)buf); // Restore p->epinfo p->epinfo = oldep_ptr; if (rcode) { - //printf("Configuring error: Can't get USB_DEVICE_DESCRIPTOR\r\n"); + //printf("Configuring error: Can't get USB_FD_DEVICE_DESCRIPTOR\r\n"); return rcode; } @@ -762,7 +762,7 @@ uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t con uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) { const uint8_t bufSize = 64; uint8_t buf[bufSize]; - USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); + USB_FD_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); uint8_t ret = getConfDescr(addr, ep, 9, conf, buf); if (ret) return ret; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h index 5d4ddaf..10478eb 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h @@ -30,10 +30,10 @@ class UsbConfigXtracter { public: - //virtual void ConfigXtract(const USB_CONFIGURATION_DESCRIPTOR *conf) = 0; - //virtual void InterfaceXtract(uint8_t conf, const USB_INTERFACE_DESCRIPTOR *iface) = 0; + //virtual void ConfigXtract(const USB_FD_CONFIGURATION_DESCRIPTOR *conf) = 0; + //virtual void InterfaceXtract(uint8_t conf, const USB_FD_INTERFACE_DESCRIPTOR *iface) = 0; - virtual void EndpointXtract(uint8_t conf __attribute__((unused)), uint8_t iface __attribute__((unused)), uint8_t alt __attribute__((unused)), uint8_t proto __attribute__((unused)), const USB_ENDPOINT_DESCRIPTOR *ep __attribute__((unused))) { + virtual void EndpointXtract(uint8_t conf __attribute__((unused)), uint8_t iface __attribute__((unused)), uint8_t alt __attribute__((unused)), uint8_t proto __attribute__((unused)), const USB_FD_ENDPOINT_DESCRIPTOR *ep __attribute__((unused))) { } }; @@ -50,7 +50,7 @@ class ConfigDescParser : public USBReadParser { MultiValueBuffer theBuffer; MultiByteValueParser valParser; ByteSkipper theSkipper; - uint8_t varBuffer[16 /*sizeof(USB_CONFIGURATION_DESCRIPTOR)*/]; + uint8_t varBuffer[16 /*sizeof(USB_FD_CONFIGURATION_DESCRIPTOR)*/]; uint8_t stateParseDescr; // ParseDescriptor state @@ -97,8 +97,8 @@ void ConfigDescParser::Parse(const uin compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */ template bool ConfigDescParser::ParseDescriptor(uint8_t **pp, uint16_t *pcntdn) { - USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); - USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); + USB_FD_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); + USB_FD_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); switch (stateParseDescr) { case 0: theBuffer.valueSize = 2; @@ -155,7 +155,7 @@ bool ConfigDescParser::ParseDescriptor case USB_DESCRIPTOR_ENDPOINT: if (!valParser.Parse(pp, pcntdn)) return false; if (isGoodInterface && theXtractor) - theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer); + theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_FD_ENDPOINT_DESCRIPTOR*)varBuffer); break; //case HID_DESCRIPTOR_HID: // if (!valParser.Parse(pp, pcntdn)) return false; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp index a57245f..2512e38 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp @@ -250,10 +250,10 @@ bLastUsbError(0) { */ uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); + const uint8_t constBufSize = sizeof (USB_FD_DEVICE_DESCRIPTOR); uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); + USB_FD_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; UsbDevice *p = nullptr; EpInfo *oldep_ptr = nullptr; @@ -529,7 +529,7 @@ uint8_t BulkOnly::Init(uint8_t parent __attribute__((unused)), uint8_t port __at * @param proto * @param pep */ -void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto __attribute__((unused)), const USB_ENDPOINT_DESCRIPTOR * pep) { +void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto __attribute__((unused)), const USB_FD_ENDPOINT_DESCRIPTOR * pep) { ErrorMessage (PSTR("Conf.Val"), conf); ErrorMessage (PSTR("Iface Num"), iface); ErrorMessage (PSTR("Alt.Set"), alt); @@ -1166,7 +1166,7 @@ uint8_t BulkOnly::HandleSCSIError(uint8_t status) { * * @param ep_ptr */ -void BulkOnly::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR * ep_ptr) { +void BulkOnly::PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR * ep_ptr) { Notify(PSTR("Endpoint descriptor:"), 0x80); Notify(PSTR("\r\nLength:\t\t"), 0x80); D_PrintHex (ep_ptr->bLength, 0x80); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h index 09b82fd..960651f 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h @@ -491,7 +491,7 @@ protected: uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes. bool WriteOk[MASS_MAX_SUPPORTED_LUN]; - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); + void PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR* ep_ptr); // Additional Initialization Method for Subclasses @@ -526,7 +526,7 @@ public: virtual uint8_t GetAddress() { return bAddress; } // UsbConfigXtracter implementation - void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_FD_ENDPOINT_DESCRIPTOR *ep); virtual bool DEVCLASSOK(uint8_t klass) { return klass == USB_CLASS_MASS_STORAGE; } diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp index 78a9ba1..0ab58b9 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp @@ -37,7 +37,7 @@ int UsbDEBUGlvl = 0x80; void E_Notifyc(char c, int lvl) { if (UsbDEBUGlvl < lvl) return; USB_HOST_SERIAL.print(c - #if !defined(ARDUINO) || ARDUINO < 100 + #if !defined(ARDUINO) && !defined(ARDUINO_ARCH_LPC176X) , BYTE #endif ); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h index 039215b..a08d58b 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h @@ -116,7 +116,7 @@ typedef struct { uint8_t iProduct; // Index of String Descriptor describing the product. uint8_t iSerialNumber; // Index of String Descriptor with the device's serial number. uint8_t bNumConfigurations; // Number of possible configurations. -} __attribute__((packed)) USB_DEVICE_DESCRIPTOR; +} __attribute__((packed)) USB_FD_DEVICE_DESCRIPTOR; /* Configuration descriptor structure */ typedef struct { @@ -128,7 +128,7 @@ typedef struct { uint8_t iConfiguration; // Index of String Descriptor describing the configuration. uint8_t bmAttributes; // Configuration characteristics. uint8_t bMaxPower; // Maximum power consumed by this configuration. -} __attribute__((packed)) USB_CONFIGURATION_DESCRIPTOR; +} __attribute__((packed)) USB_FD_CONFIGURATION_DESCRIPTOR; /* Interface descriptor structure */ typedef struct { @@ -141,7 +141,7 @@ typedef struct { uint8_t bInterfaceSubClass; // Subclass code (assigned by the USB-IF). uint8_t bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. uint8_t iInterface; // Index of String Descriptor describing the interface. -} __attribute__((packed)) USB_INTERFACE_DESCRIPTOR; +} __attribute__((packed)) USB_FD_INTERFACE_DESCRIPTOR; /* Endpoint descriptor structure */ typedef struct { @@ -151,7 +151,7 @@ typedef struct { uint8_t bmAttributes; // Endpoint transfer type. uint16_t wMaxPacketSize; // Maximum packet size. uint8_t bInterval; // Polling interval in frames. -} __attribute__((packed)) USB_ENDPOINT_DESCRIPTOR; +} __attribute__((packed)) USB_FD_ENDPOINT_DESCRIPTOR; /* HID descriptor */ typedef struct { diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h index 6ad9cb5..26ed852 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h @@ -174,7 +174,7 @@ protected: volatile uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits volatile bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes. volatile bool WriteOk[MASS_MAX_SUPPORTED_LUN]; - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); + void PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR* ep_ptr); public: UHS_Bulk_Storage(UHS_USB_HOST_BASE *p); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h index a171b13..6ad9cff 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h @@ -1188,7 +1188,7 @@ uint8_t UHS_NI UHS_Bulk_Storage::HandleSCSIError(uint8_t status) { * * @param ep_ptr */ -void UHS_NI UHS_Bulk_Storage::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR * ep_ptr) { +void UHS_NI UHS_Bulk_Storage::PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR * ep_ptr) { Notify(PSTR("Endpoint descriptor:"), 0x80); Notify(PSTR("\r\nLength:\t\t"), 0x80); D_PrintHex (ep_ptr->bLength, 0x80); diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h index 908391a..eb96c7e 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h @@ -239,12 +239,12 @@ uint8_t UHS_USB_HOST_BASE::Configuring(uint8_t parent, uint8_t port, uint8_t spe // wrap in {} to throw away the 64 byte buffer when we are done with it { uint8_t buf[biggest]; - USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); + USB_FD_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); #else const uint8_t biggest = 18; uint8_t buf[biggest]; - USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); - USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); + USB_FD_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); + USB_FD_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); #endif //for(devConfigIndex = 0; devConfigIndex < UHS_HOST_MAX_INTERFACE_DRIVERS; devConfigIndex++) { @@ -309,7 +309,7 @@ again: sof_delay(200); goto again; } - HOST_DEBUG("Configuring error: 0x%2.2x Can't get USB_DEVICE_DESCRIPTOR\r\n", rcode); + HOST_DEBUG("Configuring error: 0x%2.2x Can't get USB_FD_DEVICE_DESCRIPTOR\r\n", rcode); return rcode; } @@ -378,7 +378,7 @@ again: } // unwrapped, old large buf now invalid and discarded. uint8_t buf[18]; - USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); + USB_FD_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); #endif ei.address = addrPool.AllocAddress(parent, IsHub(ei.klass), port); @@ -415,9 +415,9 @@ again: HOST_DEBUG("configs: %i\r\n", configs); for(uint8_t conf = 0; (!rcode) && (conf < configs); conf++) { // read the config descriptor into a buffer. - rcode = getConfDescr(ei.address, sizeof (USB_CONFIGURATION_DESCRIPTOR), conf, buf); + rcode = getConfDescr(ei.address, sizeof (USB_FD_CONFIGURATION_DESCRIPTOR), conf, buf); if(rcode) { - HOST_DEBUG("Configuring error: %2.2x Can't get USB_INTERFACE_DESCRIPTOR\r\n", rcode); + HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR\r\n", rcode); rcode = UHS_HOST_ERROR_FailGetConfDescr; continue; } @@ -438,7 +438,7 @@ again: uint8_t offset; rcode = initDescrStream(&ei, ucd, pep, data, &left, &read, &offset); if(rcode) { - HOST_DEBUG("Configuring error: %2.2x Can't get USB_INTERFACE_DESCRIPTOR stream.\r\n", rcode); + HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode); break; } for(; (numinf) && (!rcode); inf++) { @@ -451,7 +451,7 @@ again: break; } if(rcode) { - HOST_DEBUG("Configuring error: %2.2x Can't close USB_INTERFACE_DESCRIPTOR stream.\r\n", rcode); + HOST_DEBUG("Configuring error: %2.2x Can't close USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode); continue; } rcode = TestInterface(&ei); @@ -471,9 +471,9 @@ again: if(!bestsuccess) rcode = UHS_HOST_ERROR_DEVICE_NOT_SUPPORTED; } if(!rcode) { - rcode = getConfDescr(ei.address, sizeof (USB_CONFIGURATION_DESCRIPTOR), bestconf, buf); + rcode = getConfDescr(ei.address, sizeof (USB_FD_CONFIGURATION_DESCRIPTOR), bestconf, buf); if(rcode) { - HOST_DEBUG("Configuring error: %2.2x Can't get USB_INTERFACE_DESCRIPTOR\r\n", rcode); + HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR\r\n", rcode); rcode = UHS_HOST_ERROR_FailGetConfDescr; } } @@ -497,7 +497,7 @@ again: uint8_t offset; rcode = initDescrStream(&ei, ucd, pep, data, &left, &read, &offset); if(rcode) { - HOST_DEBUG("Configuring error: %2.2x Can't get USB_INTERFACE_DESCRIPTOR stream.\r\n", rcode); + HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode); } else { for(; (numinf) && (!rcode); inf++) { // iterate for each interface on this config @@ -508,7 +508,7 @@ again: break; } if(rcode) { - HOST_DEBUG("Configuring error: %2.2x Can't close USB_INTERFACE_DESCRIPTOR stream.\r\n", rcode); + HOST_DEBUG("Configuring error: %2.2x Can't close USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode); continue; } @@ -721,7 +721,7 @@ uint8_t UHS_USB_HOST_BASE::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytes * @param offset * @return zero for success or error code */ -uint8_t UHS_USB_HOST_BASE::initDescrStream(ENUMERATION_INFO *ei, USB_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset) { +uint8_t UHS_USB_HOST_BASE::initDescrStream(ENUMERATION_INFO *ei, USB_FD_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset) { if(!ei || !ucd) return UHS_HOST_ERROR_BAD_ARGUMENT; if(!pep) return UHS_HOST_ERROR_NULL_EPINFO; *left = ucd->wTotalLength; @@ -837,7 +837,7 @@ uint8_t UHS_USB_HOST_BASE::getNextInterface(ENUMERATION_INFO *ei, UHS_EpInfo *pe return rcode; } -uint8_t UHS_USB_HOST_BASE::seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_CONFIGURATION_DESCRIPTOR *ucd) { +uint8_t UHS_USB_HOST_BASE::seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_FD_CONFIGURATION_DESCRIPTOR *ucd) { if(!ei || !ucd) return UHS_HOST_ERROR_BAD_ARGUMENT; uint8_t data[ei->bMaxPacketSize0]; UHS_EpInfo *pep; diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h index 34b8ad7..9d945d6 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h @@ -164,7 +164,7 @@ typedef struct { uint8_t iProduct; // Index of String Descriptor describing the product. uint8_t iSerialNumber; // Index of String Descriptor with the device's serial number. uint8_t bNumConfigurations; // Number of possible configurations. -} __attribute__((packed)) USB_DEVICE_DESCRIPTOR; +} __attribute__((packed)) USB_FD_DEVICE_DESCRIPTOR; /* Configuration descriptor structure */ typedef struct { @@ -176,7 +176,7 @@ typedef struct { uint8_t iConfiguration; // Index of String Descriptor describing the configuration. uint8_t bmAttributes; // Configuration characteristics. uint8_t bMaxPower; // Maximum power consumed by this configuration. -} __attribute__((packed)) USB_CONFIGURATION_DESCRIPTOR; +} __attribute__((packed)) USB_FD_CONFIGURATION_DESCRIPTOR; /* Interface descriptor structure */ typedef struct { @@ -189,7 +189,7 @@ typedef struct { uint8_t bInterfaceSubClass; // Subclass code (assigned by the USB-IF). uint8_t bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. uint8_t iInterface; // Index of String Descriptor describing the interface. -} __attribute__((packed)) USB_INTERFACE_DESCRIPTOR; +} __attribute__((packed)) USB_FD_INTERFACE_DESCRIPTOR; /* Endpoint descriptor structure */ typedef struct { @@ -199,7 +199,7 @@ typedef struct { uint8_t bmAttributes; // Endpoint transfer type. uint16_t wMaxPacketSize; // Maximum packet size. uint8_t bInterval; // Polling interval in frames. -} __attribute__((packed)) USB_ENDPOINT_DESCRIPTOR; +} __attribute__((packed)) USB_FD_ENDPOINT_DESCRIPTOR; /* HID descriptor */ /* diff --git a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h index 9a6b110..c19574b 100644 --- a/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h +++ b/Marlin-bugfix-2.0.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h @@ -207,7 +207,7 @@ public: interrupts(); } - uint8_t UHS_NI seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_CONFIGURATION_DESCRIPTOR *ucd); + uint8_t UHS_NI seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_FD_CONFIGURATION_DESCRIPTOR *ucd); uint8_t UHS_NI setEpInfoEntry(uint8_t addr, uint8_t iface, uint8_t epcount, volatile UHS_EpInfo* eprecord_ptr); @@ -261,7 +261,7 @@ public: uint8_t TestInterface(ENUMERATION_INFO *ei); uint8_t enumerateInterface(ENUMERATION_INFO *ei); uint8_t getNextInterface(ENUMERATION_INFO *ei, UHS_EpInfo *pep, uint8_t data[], uint16_t *left, uint16_t *read, uint8_t *offset); - uint8_t initDescrStream(ENUMERATION_INFO *ei, USB_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset); + uint8_t initDescrStream(ENUMERATION_INFO *ei, USB_FD_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset); uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data); uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data); uint8_t doSoftReset(uint8_t parent, uint8_t port, uint8_t address); diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/ldscripts/creality.ld b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/ldscripts/creality.ld new file mode 100644 index 0000000..7853455 --- /dev/null +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/ldscripts/creality.ld @@ -0,0 +1,14 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40 + rom (rx) : ORIGIN = 0x08007000, LENGTH = 512K - 28K +} + +/* Provide memory region aliases for common.inc */ +REGION_ALIAS("REGION_TEXT", rom); +REGION_ALIAS("REGION_DATA", ram); +REGION_ALIAS("REGION_BSS", ram); +REGION_ALIAS("REGION_RODATA", rom); + +/* Let common.inc handle the real work. */ +INCLUDE common.inc diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld index 7122acb..6777e59 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld @@ -5,7 +5,7 @@ MEMORY { ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K - rom (rx) : ORIGIN = 0x08010000, LENGTH = 256K - 64K + rom (rx) : ORIGIN = 0x08008000, LENGTH = 256K - 32K } /* Provide memory region aliases for common.inc */ diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py index a66c18a..b69f625 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -3,11 +3,11 @@ from os.path import join from os.path import expandvars Import("env") -# Relocate firmware from 0x08000000 to 0x08010000 +# Relocate firmware from 0x08000000 to 0x08008000 #for define in env['CPPDEFINES']: # if define[0] == "VECT_TAB_ADDR": # env['CPPDEFINES'].remove(define) -#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000")) +#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08008000")) #custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld") #for i, flag in enumerate(env["LINKFLAGS"]): diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/creality.py b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/creality.py new file mode 100644 index 0000000..d7b7823 --- /dev/null +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/creality.py @@ -0,0 +1,16 @@ +import os +Import("env") + +# Relocate firmware from 0x08000000 to 0x08007000 +for define in env['CPPDEFINES']: + if define[0] == "VECT_TAB_ADDR": + env['CPPDEFINES'].remove(define) +env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) + +custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/creality.ld") +for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,-T" in flag: + env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script + elif flag == "-T": + env["LINKFLAGS"][i + 1] = custom_ld_script + diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py new file mode 100644 index 0000000..0047289 --- /dev/null +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py @@ -0,0 +1,40 @@ +import os +Import("env") + +# Relocate firmware from 0x08000000 to 0x08007000 +for define in env['CPPDEFINES']: + if define[0] == "VECT_TAB_ADDR": + env['CPPDEFINES'].remove(define) +env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) + +custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_nano.ld") +for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,-T" in flag: + env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script + elif flag == "-T": + env["LINKFLAGS"][i + 1] = custom_ld_script + + +# Encrypt ${PROGNAME}.bin and save it as 'Robin_nano35.bin' +def encrypt(source, target, env): + import sys + + key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] + + firmware = open(target[0].path, "rb") + robin = open(target[0].dir.path +'/Robin_nano35.bin', "wb") + length = os.path.getsize(target[0].path) + position = 0 + try: + while position < length: + byte = firmware.read(1) + if position >= 320 and position < 31040: + byte = chr(ord(byte) ^ key[position & 31]) + if sys.version_info[0] > 2: + byte = bytes(byte, 'latin1') + robin.write(byte) + position += 1 + finally: + firmware.close() + robin.close() +env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp index fbc5c7d..6083664 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp @@ -71,19 +71,19 @@ void boardInit(void) { extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { /* - gpio_dev *gpio_device; GPIO device + gpio_dev *gpio_device; GPIO device timer_dev *timer_device; Pin's timer device, if any. - const adc_dev *adc_device; ADC device, if any. - uint8 gpio_bit; Pin's GPIO port bit. - uint8 timer_channel; Timer channel, or 0 if none. - uint8 adc_channel; Pin ADC channel, or ADCx if none. + const adc_dev *adc_device; ADC device, if any. + uint8 gpio_bit; Pin's GPIO port bit. + uint8 timer_channel; Timer channel, or 0 if none. + uint8 adc_channel; Pin ADC channel, or ADCx if none. */ {&gpioa, &timer2, &adc1, 0, 1, 0}, /* PA0 */ {&gpioa, &timer2, &adc1, 1, 2, 1}, /* PA1 */ {&gpioa, &timer2, &adc1, 2, 3, 2}, /* PA2 */ {&gpioa, &timer2, &adc1, 3, 4, 3}, /* PA3 */ - {&gpioa, NULL, &adc1, 4, 0, 4}, /* PA4 */ + {&gpioa, NULL, &adc1, 4, 0, 4}, /* PA4 */ {&gpioa, NULL, &adc1, 5, 0, 5}, /* PA5 */ {&gpioa, &timer3, &adc1, 6, 1, 6}, /* PA6 */ {&gpioa, &timer3, &adc1, 7, 2, 7}, /* PA7 */ @@ -91,7 +91,7 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { {&gpioa, &timer1, NULL, 9, 2, ADCx}, /* PA9 */ {&gpioa, &timer1, NULL, 10, 3, ADCx}, /* PA10 */ {&gpioa, NULL, NULL, 11, 0, ADCx}, /* PA11 */ - {&gpioa, NULL, NULL, 12, 0, ADCx}, /* PA12 */ + {&gpioa, NULL, NULL, 12, 0, ADCx}, /* PA12 */ {&gpioa, NULL, NULL, 13, 0, ADCx}, /* PA13 */ {&gpioa, NULL, NULL, 14, 0, ADCx}, /* PA14 */ {&gpioa, NULL, NULL, 15, 0, ADCx}, /* PA15 */ @@ -120,13 +120,13 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { {&gpioc, NULL, &adc1, 3, 0, 13}, /* PC3 */ {&gpioc, NULL, &adc1, 4, 0, 14}, /* PC4 */ {&gpioc, NULL, &adc1, 5, 0, 15}, /* PC5 */ - {&gpioc, &timer8, NULL, 6, 1, ADCx}, /* PC6 */ + {&gpioc, &timer8, NULL, 6, 1, ADCx}, /* PC6 */ {&gpioc, &timer8, NULL, 7, 2, ADCx}, /* PC7 */ {&gpioc, &timer8, NULL, 8, 3, ADCx}, /* PC8 */ {&gpioc, &timer8, NULL, 9, 4, ADCx}, /* PC9 */ {&gpioc, NULL, NULL, 10, 0, ADCx}, /* PC10 UART4_TX/SDIO_D2 */ {&gpioc, NULL, NULL, 11, 0, ADCx}, /* PC11 UART4_RX/SDIO_D3 */ - {&gpioc, NULL, NULL, 12, 0, ADCx}, /* PC12 UART5_TX/SDIO_CK */ + {&gpioc, NULL, NULL, 12, 0, ADCx}, /* PC12 UART5_TX/SDIO_CK */ {&gpioc, NULL, NULL, 13, 0, ADCx}, /* PC13 TAMPER-RTC */ {&gpioc, NULL, NULL, 14, 0, ADCx}, /* PC14 OSC32_IN */ {&gpioc, NULL, NULL, 15, 0, ADCx}, /* PC15 OSC32_OUT */ @@ -134,7 +134,7 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { {&gpiod, NULL, NULL, 0, 0, ADCx} , /* PD0 OSC_IN */ {&gpiod, NULL, NULL, 1, 0, ADCx} , /* PD1 OSC_OUT */ {&gpiod, NULL, NULL, 2, 0, ADCx} , /* PD2 TIM3_ETR/UART5_RX SDIO_CMD */ - + {&gpiod, NULL, NULL, 3, 0, ADCx} , /* PD3 FSMC_CLK */ {&gpiod, NULL, NULL, 4, 0, ADCx} , /* PD4 FSMC_NOE */ {&gpiod, NULL, NULL, 5, 0, ADCx} , /* PD5 FSMC_NWE */ @@ -145,10 +145,10 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { {&gpiod, NULL, NULL, 10, 0, ADCx} , /* PD10 FSMC_D15 */ {&gpiod, NULL, NULL, 11, 0, ADCx} , /* PD11 FSMC_A16 */ {&gpiod, NULL, NULL, 12, 0, ADCx} , /* PD12 FSMC_A17 */ - {&gpiod, NULL, NULL, 13, 0, ADCx} , /* PD13 FSMC_A18 */ + {&gpiod, NULL, NULL, 13, 0, ADCx} , /* PD13 FSMC_A18 */ {&gpiod, NULL, NULL, 14, 0, ADCx} , /* PD14 FSMC_D0 */ {&gpiod, NULL, NULL, 15, 0, ADCx} , /* PD15 FSMC_D1 */ - + {&gpioe, NULL, NULL, 0, 0, ADCx} , /* PE0 */ {&gpioe, NULL, NULL, 1, 0, ADCx} , /* PE1 */ {&gpioe, NULL, NULL, 2, 0, ADCx} , /* PE2 */ @@ -162,9 +162,9 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { {&gpioe, NULL, NULL, 10, 0, ADCx} , /* PE10 */ {&gpioe, NULL, NULL, 11, 0, ADCx} , /* PE11 */ {&gpioe, NULL, NULL, 12, 0, ADCx} , /* PE12 */ - {&gpioe, NULL, NULL, 13, 0, ADCx} , /* PE13 */ + {&gpioe, NULL, NULL, 13, 0, ADCx} , /* PE13 */ {&gpioe, NULL, NULL, 14, 0, ADCx} , /* PE14 */ - {&gpioe, NULL, NULL, 15, 0, ADCx} , /* PE15 */ + {&gpioe, NULL, NULL, 15, 0, ADCx} , /* PE15 */ {&gpiof, NULL, NULL, 0, 0, ADCx} , /* PF0 */ {&gpiof, NULL, NULL, 1, 0, ADCx} , /* PF1 */ @@ -179,10 +179,10 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { {&gpiof, NULL, NULL, 10, 0, ADCx} , /* PF10 */ {&gpiof, NULL, NULL, 11, 0, ADCx} , /* PF11 */ {&gpiof, NULL, NULL, 12, 0, ADCx} , /* PF12 */ - {&gpiof, NULL, NULL, 13, 0, ADCx} , /* PF13 */ + {&gpiof, NULL, NULL, 13, 0, ADCx} , /* PF13 */ {&gpiof, NULL, NULL, 14, 0, ADCx} , /* PF14 */ - {&gpiof, NULL, NULL, 15, 0, ADCx} , /* PF15 */ - + {&gpiof, NULL, NULL, 15, 0, ADCx} , /* PF15 */ + {&gpiog, NULL, NULL, 0, 0, ADCx} , /* PG0 */ {&gpiog, NULL, NULL, 1, 0, ADCx} , /* PG1 */ {&gpiog, NULL, NULL, 2, 0, ADCx} , /* PG2 */ @@ -196,9 +196,9 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { {&gpiog, NULL, NULL, 10, 0, ADCx} , /* PG10 */ {&gpiog, NULL, NULL, 11, 0, ADCx} , /* PG11 */ {&gpiog, NULL, NULL, 12, 0, ADCx} , /* PG12 */ - {&gpiog, NULL, NULL, 13, 0, ADCx} , /* PG13 */ + {&gpiog, NULL, NULL, 13, 0, ADCx} , /* PG13 */ {&gpiog, NULL, NULL, 14, 0, ADCx} , /* PG14 */ - {&gpiog, NULL, NULL, 15, 0, ADCx} /* PG15 */ + {&gpiog, NULL, NULL, 15, 0, ADCx} /* PG15 */ }; /* Basically everything that is defined as having a timer us PWM */ diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103z_dfu.ld b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103z_dfu.ld index 5cdf24e..81eaa8b 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103z_dfu.ld +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103z_dfu.ld @@ -1,5 +1,5 @@ /* - * libmaple linker script + * libmaple linker script * * This build puts .text (and .rodata) in Flash, and * .data/.bss/heap (of course) in SRAM, but links starting at the diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zc.ld b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zc.ld index dbb50a6..37bc3da 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zc.ld +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zc.ld @@ -1,5 +1,5 @@ /* - * libmaple linker script + * libmaple linker script * * This build puts .text (and .rodata) in Flash, and * .data/.bss/heap (of course) in SRAM, but links starting at the diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zd.ld b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zd.ld index 9cbff79..f3f2180 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zd.ld +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zd.ld @@ -1,5 +1,5 @@ /* - * libmaple linker script + * libmaple linker script * * This build puts .text (and .rodata) in Flash, and * .data/.bss/heap (of course) in SRAM, but links starting at the diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103ze.ld b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103ze.ld index a7c9c99..2f86c3f 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103ze.ld +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103ze.ld @@ -1,5 +1,5 @@ /* - * libmaple linker script + * libmaple linker script * * This build puts .text (and .rodata) in Flash, and * .data/.bss/heap (of course) in SRAM, but links starting at the diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp index 98b31cf..c3f5247 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp @@ -49,17 +49,17 @@ // currently officially supports). #ifndef BOARD_RCC_PLLMUL #if !USE_HSI_CLOCK - #if F_CPU==128000000 - #define BOARD_RCC_PLLMUL RCC_PLLMUL_16 - #elif F_CPU==72000000 - #define BOARD_RCC_PLLMUL RCC_PLLMUL_9 - #elif F_CPU==48000000 - #define BOARD_RCC_PLLMUL RCC_PLLMUL_6 - #elif F_CPU==16000000 - #define BOARD_RCC_PLLMUL RCC_PLLMUL_2 - #endif + #if F_CPU==128000000 + #define BOARD_RCC_PLLMUL RCC_PLLMUL_16 + #elif F_CPU==72000000 + #define BOARD_RCC_PLLMUL RCC_PLLMUL_9 + #elif F_CPU==48000000 + #define BOARD_RCC_PLLMUL RCC_PLLMUL_6 + #elif F_CPU==16000000 + #define BOARD_RCC_PLLMUL RCC_PLLMUL_2 + #endif #else - #define BOARD_RCC_PLLMUL RCC_PLLMUL_16 + #define BOARD_RCC_PLLMUL RCC_PLLMUL_16 #endif #endif @@ -83,33 +83,39 @@ namespace wirish { rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1); rcc_set_prescaler(RCC_PRESCALER_APB1, RCC_APB1_HCLK_DIV_2); rcc_set_prescaler(RCC_PRESCALER_APB2, RCC_APB2_HCLK_DIV_1); - rcc_clk_disable(RCC_USB); - #if F_CPU == 72000000 - rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5); - #elif F_CPU == 48000000 - rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1); - #endif + rcc_clk_disable(RCC_USB); +#if F_CPU == 72000000 + rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5); +#elif F_CPU == 48000000 + rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1); +#endif } __weak void board_setup_gpio(void) { + /** + * PA14 is a pull up pin. But, some V5 boards it start with LOW state! And just behave properly when the Z- PROBE is actived at least once. + * So, if the sensor isnt actived, the PA14 pin will be forever in LOW state, telling Marlin the probe IS ALWAYS ACTIVE, that isnt the case! + * Chitu original firmware seems to start with every pullup PIN with HIGH to workaround this. + * So we are doing the same here. + * This hack only works if applied *before* the GPIO Init, it's the reason I did it here. + */ + #ifdef CHITU_V5_Z_MIN_BUGFIX + GPIOA->regs->BSRR = (1U << PA14); + #endif gpio_init_all(); } __weak void board_setup_usb(void) { - +#ifdef SERIAL_USB +#ifdef GENERIC_BOOTLOADER + // Reset the USB interface on generic boards - developed by Victor PV + gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP); + gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0); - -#ifdef SERIAL_USB -#ifdef GENERIC_BOOTLOADER - //Reset the USB interface on generic boards - developed by Victor PV - gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP); - gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0); - - for(volatile unsigned int i=0;i<512;i++);// Only small delay seems to be needed, and USB pins will get configured in Serial.begin - gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING); -#endif - - Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility + for (volatile unsigned int i = 0; i < 512; i++); // Only small delay seems to be needed, and USB pins will get configured in Serial.begin + gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING); +#endif + Serial.begin(); // Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility #endif } @@ -118,6 +124,5 @@ namespace wirish { // interrupts work out of the box. afio_init(); } - } } diff --git a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/FYSETC_S6/variant.h b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/FYSETC_S6/variant.h index de34697..da6a824 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/FYSETC_S6/variant.h +++ b/Marlin-bugfix-2.0.x/buildroot/share/PlatformIO/variants/FYSETC_S6/variant.h @@ -132,7 +132,7 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pin. See PinMap_PWM. #define TIMER_TONE TIM6 -#define TIMER_SERVO TIM2 +#define TIMER_SERVO TIM5 #define TIMER_SERIAL TIM7 // UART Definitions diff --git a/Marlin-bugfix-2.0.x/buildroot/share/git/mfpub b/Marlin-bugfix-2.0.x/buildroot/share/git/mfpub index ab43b70..6a912e5 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/git/mfpub +++ b/Marlin-bugfix-2.0.x/buildroot/share/git/mfpub @@ -135,4 +135,4 @@ git push -f upstream | { rm -rf ${TMPFOLDER} # Go back to the branch we started from -[[ $BRANCH != $CURR ]] && git checkout $BRANCH && [[ $HAS_STASH == 1 ]] && git stash pop +git checkout $CURR && [[ $HAS_STASH == 1 ]] && git stash pop diff --git a/Marlin-bugfix-2.0.x/buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode b/Marlin-bugfix-2.0.x/buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode index 2d3a473..643f271 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode +++ b/Marlin-bugfix-2.0.x/buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode @@ -93,7 +93,7 @@ N234 G1 X-5 Y+2 *64 error ; ^constant.numeric.checksum.gcode ; ^invalid.error.syntax.gcode -N234 M107 *64 +N234 M107 *64 ; ^-invalid.error.syntax.gcode M92 E304.5:304.5:420:420:420:420 ; EOL Comment diff --git a/Marlin-bugfix-2.0.x/buildroot/share/tests/DUE-tests b/Marlin-bugfix-2.0.x/buildroot/share/tests/DUE-tests index 0d9b95e..5c36db0 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/tests/DUE-tests +++ b/Marlin-bugfix-2.0.x/buildroot/share/tests/DUE-tests @@ -14,7 +14,7 @@ opt_set TEMP_SENSOR_BED 2 opt_set GRID_MAX_POINTS_X 16 opt_set FANMUX0_PIN 53 opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ - PIDTEMPBED FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING \ + FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING ASSISTED_TRAMMING \ EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \ BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ NEOPIXEL_LED CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \ @@ -24,13 +24,14 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ FWRETRACT ARC_SUPPORT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ PSU_CONTROL AUTO_POWER_CONTROL \ - SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER \ + PIDTEMPBED SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER \ PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL \ EXTENSIBLE_UI opt_add EXTUI_EXAMPLE opt_set E0_AUTO_FAN_PIN 8 opt_set EXTRUDER_AUTO_FAN_SPEED 100 opt_set TEMP_SENSOR_CHAMBER 3 +opt_add TEMP_CHAMBER_PIN 6 opt_set HEATER_CHAMBER_PIN 45 exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), EXTENSIBLE_UI, S-Curve, many options." diff --git a/Marlin-bugfix-2.0.x/buildroot/share/tests/STM32F103RC_fysetc-tests b/Marlin-bugfix-2.0.x/buildroot/share/tests/STM32F103RC_fysetc-tests index 7d08fb7..dfa85d9 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/tests/STM32F103RC_fysetc-tests +++ b/Marlin-bugfix-2.0.x/buildroot/share/tests/STM32F103RC_fysetc-tests @@ -9,7 +9,7 @@ set -e # # Build with the default configurations # -use_example_configs "FYSETC/Cheetah 1.2/base" +use_example_configs "Creality/Ender-3/FYSETC Cheetah 1.2/base" exec_test $1 $2 "Cheetah 1.2 Configuration" # clean up diff --git a/Marlin-bugfix-2.0.x/buildroot/share/tests/STM32F103RET6_creality-tests b/Marlin-bugfix-2.0.x/buildroot/share/tests/STM32F103RET6_creality-tests new file mode 100644 index 0000000..f9ae634 --- /dev/null +++ b/Marlin-bugfix-2.0.x/buildroot/share/tests/STM32F103RET6_creality-tests @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# Build tests for STM32F103RET6_creality +# + +# exit on first failure +set -e + +# +# Build with configs included in the PR +# +use_example_configs "Creality/Ender-3 V2" +exec_test $1 $2 "Ender 3 v2" + +restore_configs diff --git a/Marlin-bugfix-2.0.x/buildroot/share/tests/rambo-tests b/Marlin-bugfix-2.0.x/buildroot/share/tests/rambo-tests index fbe27a2..53ac729 100644 --- a/Marlin-bugfix-2.0.x/buildroot/share/tests/rambo-tests +++ b/Marlin-bugfix-2.0.x/buildroot/share/tests/rambo-tests @@ -18,6 +18,7 @@ opt_set TEMP_SENSOR_BED 2 opt_set TEMP_SENSOR_PROBE 1 opt_add TEMP_PROBE_PIN 12 opt_set TEMP_SENSOR_CHAMBER 3 +opt_add TEMP_CHAMBER_PIN 3 opt_add HEATER_CHAMBER_PIN 45 opt_set GRID_MAX_POINTS_X 16 opt_set FANMUX0_PIN 53 diff --git a/Marlin-bugfix-2.0.x/buildroot/share/tests/rumba32-tests b/Marlin-bugfix-2.0.x/buildroot/share/tests/rumba32-tests new file mode 100644 index 0000000..42f9beb --- /dev/null +++ b/Marlin-bugfix-2.0.x/buildroot/share/tests/rumba32-tests @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# +# Build tests for rumba32 +# + +# exit on first failure +set -e + +# Build examples +restore_configs +opt_set MOTHERBOARD BOARD_RUMBA32_V1_0 +opt_set SERIAL_PORT -1 +opt_disable PIDTEMP +opt_enable PIDTEMPBED +opt_set TEMP_SENSOR_BED 1 +opt_disable THERMAL_PROTECTION_BED +opt_set X_DRIVER_TYPE TMC2130 +exec_test $1 $2 "RUMBA32 V1.0 with TMC2130, PID Bed, and bed thermal protection disabled" + +# Build examples +restore_configs +opt_set MOTHERBOARD BOARD_RUMBA32_V1_1 +opt_set SERIAL_PORT -1 +opt_enable PIDTEMPBED EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +opt_set TEMP_SENSOR_BED 1 +opt_set X_DRIVER_TYPE TMC2130 +opt_set Y_DRIVER_TYPE TMC2208 +exec_test $1 $2 "RUMBA32 V1.1 with TMC2130, TMC2208, PID Bed, EEPROM settings, and graphic LCD controller" + +# Build examples +restore_configs +opt_set MOTHERBOARD BOARD_RUMBA32_MKS +opt_set SERIAL_PORT -1 +opt_set X_DRIVER_TYPE TMC2130 +opt_set Y_DRIVER_TYPE TMC2208 +exec_test $1 $2 "RUMBA32 MKS Default Config with Mixed TMC Drivers" + +# cleanup +restore_configs diff --git a/Marlin-bugfix-2.0.x/platformio.ini b/Marlin-bugfix-2.0.x/platformio.ini index 3b64e71..3461d19 100644 --- a/Marlin-bugfix-2.0.x/platformio.ini +++ b/Marlin-bugfix-2.0.x/platformio.ini @@ -29,7 +29,7 @@ extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py build_flags = -fmax-errors=5 -g -D__MARLIN_FIRMWARE__ -fmerge-all-constants lib_deps = LiquidCrystal - TMCStepper@>=0.6.2 + TMCStepper@>=0.7.0 Adafruit MAX31865 library@>=1.1,<1.2 Adafruit NeoPixel U8glib-HAL=https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip @@ -320,7 +320,7 @@ board = nxp_lpc1769 # # HAL/STM32 Base Environment values # -[base_stm32] +[common_stm32] platform = ststm32@<6.2.0 platform_packages = framework-arduinoststm32@>=4.10700,<4.10800 lib_deps = ${common.lib_deps} @@ -328,17 +328,11 @@ lib_ignore = SoftwareSerial build_flags = ${common.build_flags} -IMarlin/src/HAL/STM32 -std=gnu++14 -DUSBCON -DUSBD_USE_CDC + -DUSBD_VID=0x0483 + -DTIM_IRQ_PRIO=13 build_unflags = -std=gnu++11 src_filter = ${common.default_src_filter} + -# -# HAL/STM32 Common Environment values -# -[common_stm32] -platform = ${base_stm32.platform} -extends = base_stm32 -build_flags = ${base_stm32.build_flags} -DUSBD_VID=0x0483 - # # HAL/STM32F1 Common Environment values # @@ -550,7 +544,6 @@ extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_nano.py build_flags = ${common_stm32f1.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 - # # MKS Robin (STM32F103ZET6) # @@ -626,6 +619,23 @@ build_flags = ${common_stm32f1.build_flags} lib_ignore = ${common_stm32f1.lib_ignore} LiquidCrystal, LiquidTWI2, TMCStepper, U8glib-HAL, SoftwareSerialM +# +# MKS Robin Nano (STM32F103VET6) +# +[env:mks_robin_nano35] +platform = ststm32 +board = genericSTM32F103VE +platform_packages = tool-stm32duino +build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py + ${common.build_flags} -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4 +build_unflags = -std=gnu++11 +extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_nano35.py +src_filter = ${common.default_src_filter} + +lib_deps = ${common.lib_deps} + SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip + MKS-LittlevGL=https://github.com/makerbase-mks/MKS-LittlevGL/archive/master.zip +lib_ignore = Adafruit NeoPixel, SPI + # # Malyan M200 v2 (STM32F070RB) # @@ -664,6 +674,31 @@ build_flags = ${common_stm32f1.build_flags} build_unflags = ${common_stm32f1.build_unflags} -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG= -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 +# +# Some Chitu V5 boards have a problem with GPIO init. +# Use this target if G28 or G29 are always failing. +# +[env:chitu_v5_gpio_init] +platform = ${common_stm32f1.platform} +extends = env:chitu_f103 +build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX + +# +# Creality (STM32F103RET6) +# +[env:STM32F103RET6_creality] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103RC +build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py + ${common.build_flags} -std=gnu++14 -DSTM32_XL_DENSITY -DTEMP_TIMER_CHAN=4 +extra_scripts = buildroot/share/PlatformIO/scripts/creality.py +lib_ignore = ${common_stm32f1.lib_ignore} + LiquidCrystal, LiquidTWI2, U8glib-HAL, Adafruit_MAX31865, Arduino-L6470, SailfishLCD, SlowSoftI2CMaster +debug_tool = jlink +upload_protocol = jlink +monitor_speed = 115200 + # # STM32F401VE # 'STEVAL-3DP001V1' STM32F401VE board - https://www.st.com/en/evaluation-tools/steval-3dp001v1.html @@ -773,13 +808,12 @@ lib_ignore = Adafruit NeoPixel, SailfishLCD, SlowSoftI2CMaster, SoftwareS # # RUMBA32 # - -[common_rumba32] -platform = ${base_stm32.platform} -extends = base_stm32 -build_flags = ${base_stm32.build_flags} -Os - -DSTM32F4xx -DARDUINO_RUMBA32_F446VE -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"RUMBA32_F446VE\"" - -DSTM32F446xx "-DUSB_PRODUCT=\"RUMBA32_F446VE\"" +[env:rumba32] +platform = ${common_stm32.platform} +extends = common_stm32 +build_flags = ${common_stm32.build_flags} + -Os + "-DUSB_PRODUCT=\"RUMBA32\"" -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED @@ -787,22 +821,6 @@ board = rumba32_f446ve upload_protocol = dfu monitor_speed = 500000 -# -# RUMBA32 F446VE -# -[env:rumba32_f446ve] -platform = ${common_rumba32.platform} -extends = common_rumba32 -build_flags = ${common_rumba32.build_flags} -DUSBD_VID=0x0483 - -# -# MKS RUMBA32 (adds TMC2208/2209 UART interface and AUX-1) -# -[env:rumba32_mks] -platform = ${common_rumba32.platform} -extends = common_rumba32 -build_flags = ${common_rumba32.build_flags} -DUSBD_VID=0x8000 - ################################# # # # Other Architectures # diff --git a/skr-e3-reddit2 b/skr-e3-reddit2 deleted file mode 160000 index 0ec4496..0000000 --- a/skr-e3-reddit2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0ec449635231c5bfc067304b7813deccefcce230