marlin bugfix + SKR + BLTOUCH

This commit is contained in:
Xavier Perignon
2020-06-23 13:14:49 +02:00
parent 770c424d07
commit 131a9f3214
240 changed files with 23983 additions and 1307 deletions

View File

@@ -373,6 +373,7 @@
* 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! * 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) * 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 * 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) * 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) * 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) * 7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
@@ -815,6 +816,8 @@
*/ */
#if DISABLED(CLASSIC_JERK) #if DISABLED(CLASSIC_JERK)
#define JUNCTION_DEVIATION_MM 0.013 // (mm) Distance from real junction edge #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 #endif
/** /**
@@ -902,6 +905,11 @@
*/ */
//#define BLTOUCH //#define BLTOUCH
/**
* Pressure sensor with a BLTouch-like interface
*/
//#define CREALITY_TOUCH
/** /**
* Touch-MI Probe by hotends.fr * Touch-MI Probe by hotends.fr
* *
@@ -1988,6 +1996,12 @@
// //
//#define MKS_MINI_12864 //#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 // FYSETC variant of the MINI12864 graphic controller with SD support
// https://wiki.fysetc.com/Mini12864_Panel/ // https://wiki.fysetc.com/Mini12864_Panel/
@@ -2114,10 +2128,25 @@
// //
//#define FSMC_GRAPHICAL_TFT //#define FSMC_GRAPHICAL_TFT
//
// TFT Little VGL UI
//
//#define TFT_LITTLE_VGL_UI
//============================================================================= //=============================================================================
//============================ Other Controllers ============================ //============================ 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 // ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8
// //

View File

@@ -767,6 +767,34 @@
#define HOME_AFTER_G34 #define HOME_AFTER_G34
#endif #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 // @section motion
#define AXIS_RELATIVE_MODES { false, false, false, false } #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 // Probe temperature calibration generates a table of values starting at PTC_SAMPLE_START
// (e.g. 30), in steps of PTC_SAMPLE_RES (e.g. 5) with PTC_SAMPLE_COUNT (e.g. 10) samples. // (e.g. 30), in steps of PTC_SAMPLE_RES (e.g. 5) with PTC_SAMPLE_COUNT (e.g. 10) samples.
// #define PTC_SAMPLE_START 30.0f //#define PTC_SAMPLE_START 30.0f
// #define PTC_SAMPLE_RES 5.0f //#define PTC_SAMPLE_RES 5.0f
// #define PTC_SAMPLE_COUNT 10U //#define PTC_SAMPLE_COUNT 10U
// Bed temperature calibration builds a similar table. // Bed temperature calibration builds a similar table.
// #define BTC_SAMPLE_START 60.0f //#define BTC_SAMPLE_START 60.0f
// #define BTC_SAMPLE_RES 5.0f //#define BTC_SAMPLE_RES 5.0f
// #define BTC_SAMPLE_COUNT 10U //#define BTC_SAMPLE_COUNT 10U
// The temperature the probe should be at while taking measurements during bed temperature // The temperature the probe should be at while taking measurements during bed temperature
// calibration. // 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. // 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. // 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 // 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 // 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. // 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] // 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. // 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
#endif #endif
@@ -1873,6 +1901,9 @@
// This option inserts short delays between lines of serial output. // This option inserts short delays between lines of serial output.
#define SERIAL_OVERRUN_PROTECTION #define SERIAL_OVERRUN_PROTECTION
// For serial echo, the number of digits after the decimal point
//#define SERIAL_FLOAT_PRECISION 4
// @section extras // @section extras
/** /**
@@ -2984,6 +3015,23 @@
//#define FILAMENT_LCD_DISPLAY //#define FILAMENT_LCD_DISPLAY
#endif #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 * CNC Coordinate Systems
* *

View File

@@ -1,5 +1,4 @@
/* /*==============================================================================
================================================================================
Marlin Firmware Marlin Firmware
@@ -12,8 +11,8 @@
Greetings! Thank you for choosing Marlin 2 as your 3D printer firmware. Greetings! Thank you for choosing Marlin 2 as your 3D printer firmware.
To configure Marlin you must edit Configuration.h and Configuration_adv.h 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 located in the root 'Marlin' folder. Check our Configurations repository to
there's a more suitable starting-point for your specific hardware. see if there's a more suitable starting-point for your specific hardware.
Before diving in, we recommend the following essential links: Before diving in, we recommend the following essential links:
@@ -25,6 +24,9 @@ Marlin Firmware Official Website
Configuration Configuration
- https://github.com/MarlinFirmware/Configurations
Example configurations for several printer models.
- https://www.youtube.com/watch?v=3gwWVFtdg-4 - https://www.youtube.com/watch?v=3gwWVFtdg-4
A good 20-minute overview of Marlin configuration by Tom Sanladerer. A good 20-minute overview of Marlin configuration by Tom Sanladerer.
(Applies to Marlin 1.0.x, so Jerk and Acceleration should be halved.) (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 - https://marlinfw.org/docs/development/coding_standards.html
Before submitting code get to know the Coding Standards. Before submitting code get to know the Coding Standards.
*/
------------------------------------------------------------------------------*/

View File

@@ -162,6 +162,7 @@ inline void HAL_adc_init() {
#define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch) #define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
#endif #endif
#define HAL_ADC_VREF 5.0
#define HAL_ADC_RESOLUTION 10 #define HAL_ADC_RESOLUTION 10
#define HAL_READ_ADC() ADC #define HAL_READ_ADC() ADC
#define HAL_ADC_READY() !TEST(ADCSRA, ADSC) #define HAL_ADC_READY() !TEST(ADCSRA, ADSC)

View File

@@ -41,6 +41,8 @@
#elif NUM_SERVOS > 0 && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5) #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." #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system."
#endif #endif
#elif defined(SPINDLE_LASER_FREQUENCY)
#error "SPINDLE_LASER_FREQUENCY requires SPINDLE_LASER_PWM."
#endif #endif
/** /**

View File

@@ -143,8 +143,9 @@ extern uint16_t HAL_adc_result; // result of last ADC conversion
inline void HAL_adc_init() {}//todo 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_ADC_RESOLUTION 10
#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
#define HAL_READ_ADC() HAL_adc_result #define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true #define HAL_ADC_READY() true

View File

@@ -112,8 +112,9 @@ void analogWrite(pin_t pin, int value);
void HAL_adc_init(); 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_ADC_RESOLUTION 10
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result #define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true #define HAL_ADC_READY() true

View File

@@ -86,9 +86,10 @@ int freeMemory();
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
// ADC // ADC
#define HAL_ADC_VREF 5.0
#define HAL_ADC_RESOLUTION 10
#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) #define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch)
#define HAL_START_ADC(ch) HAL_adc_start_conversion(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_READ_ADC() HAL_adc_get_result()
#define HAL_ADC_READY() true #define HAL_ADC_READY() true

View File

@@ -150,6 +150,8 @@ int freeMemory();
// K = 6, 565 samples, 500Hz sample rate, 1.13s convergence on full range step // 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) // 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_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 #define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL

View File

@@ -122,6 +122,7 @@ extern uint16_t HAL_adc_result; // Most recent ADC conversion
void HAL_adc_init(); void HAL_adc_init();
//#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values. //#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_ADC_RESOLUTION 10 // ... 12
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result #define HAL_READ_ADC() HAL_adc_result

View File

@@ -199,8 +199,9 @@ static inline int freeMemory() {
inline void HAL_adc_init() {} 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_ADC_RESOLUTION 10
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result #define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true #define HAL_ADC_READY() true

View File

@@ -36,6 +36,15 @@
#define TEMP_TIMER_IRQ_PRIO 14 // 14 = after hardware ISRs #define TEMP_TIMER_IRQ_PRIO 14 // 14 = after hardware ISRs
#endif #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 #if HAS_TMC_SW_SERIAL
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#ifndef SWSERIAL_TIMER_IRQ_PRIO #ifndef SWSERIAL_TIMER_IRQ_PRIO
@@ -44,23 +53,26 @@
#endif #endif
#ifdef STM32F0xx #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_STEP_TIMER 16
#define MCU_TEMP_TIMER 17 #define MCU_TEMP_TIMER 17
#elif defined(STM32F1xx) #elif defined(STM32F1xx)
#define HAL_TIMER_RATE (F_CPU) #define MCU_TIMER_RATE (F_CPU)
#define MCU_STEP_TIMER 4 #define MCU_STEP_TIMER 4
#define MCU_TEMP_TIMER 2 #define MCU_TEMP_TIMER 2
#elif defined(STM32F401xC) || defined(STM32F401xE) #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_STEP_TIMER 9
#define MCU_TEMP_TIMER 10 #define MCU_TEMP_TIMER 10
#elif defined(STM32F4xx) || defined(STM32F7xx) #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_STEP_TIMER 6 // STM32F401 has no TIM6, TIM7, or TIM8
#define MCU_TEMP_TIMER 14 // TIM7 is consumed by Software Serial if used. #define MCU_TEMP_TIMER 14 // TIM7 is consumed by Software Serial if used.
#endif #endif
#ifndef HAL_TIMER_RATE
#define HAL_TIMER_RATE MCU_TIMER_RATE
#endif
#ifndef STEP_TIMER #ifndef STEP_TIMER
#define STEP_TIMER MCU_STEP_TIMER #define STEP_TIMER MCU_STEP_TIMER
#endif #endif

View File

@@ -139,9 +139,15 @@ const uint8_t adc_pins[] = {
#if HAS_JOY_ADC_Z #if HAS_JOY_ADC_Z
JOY_Z_PIN, JOY_Z_PIN,
#endif #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 #if HAS_TEMP_ADC_0
TEMP_0, TEMP_0,
#endif #endif
@@ -187,6 +193,12 @@ enum TEMP_PINS : char {
#if HAS_JOY_ADC_Z #if HAS_JOY_ADC_Z
JOY_Z, JOY_Z,
#endif #endif
#if ENABLED(POWER_MONITOR_CURRENT)
POWERMON_CURRENT,
#endif
#if ENABLED(POWER_MONITOR_VOLTAGE)
POWERMON_VOLTS,
#endif
ADC_PIN_COUNT ADC_PIN_COUNT
}; };
@@ -323,7 +335,8 @@ void HAL_adc_init() {
} }
void HAL_adc_start_conversion(const uint8_t adc_pin) { void HAL_adc_start_conversion(const uint8_t adc_pin) {
TEMP_PINS pin_index; //TEMP_PINS pin_index;
TempPinIndex pin_index;
switch (adc_pin) { switch (adc_pin) {
default: return; default: return;
#if HAS_TEMP_ADC_0 #if HAS_TEMP_ADC_0
@@ -371,6 +384,12 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
#if ENABLED(ADC_KEYPAD) #if ENABLED(ADC_KEYPAD)
case ADC_KEYPAD_PIN: pin_index = ADC_KEY; break; case ADC_KEYPAD_PIN: pin_index = ADC_KEY; break;
#endif #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. HAL_adc_result = (HAL_adc_results[(int)pin_index] >> 2) & 0x3FF; // shift to get 10 bits only.
} }

View File

@@ -255,8 +255,9 @@ static int freeMemory() {
void HAL_adc_init(); 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_ADC_RESOLUTION 10
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result #define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true #define HAL_ADC_READY() true

View File

@@ -44,8 +44,12 @@ typedef uint16_t hal_timer_t;
#define HAL_TIMER_RATE uint32_t(F_CPU) // frequency of timers peripherals #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 #ifndef STEP_TIMER_CHAN
#define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts #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 * Note: Timers may be used by platforms and libraries

View File

@@ -219,8 +219,9 @@ static inline int freeMemory() {
inline void HAL_adc_init() {} 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_ADC_RESOLUTION 10
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result #define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true #define HAL_ADC_READY() true

View File

@@ -107,8 +107,9 @@ extern "C" {
void HAL_adc_init(); 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_ADC_RESOLUTION 10
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_get_result() #define HAL_READ_ADC() HAL_adc_get_result()
#define HAL_ADC_READY() true #define HAL_ADC_READY() true

View File

@@ -112,8 +112,9 @@ extern "C" {
void HAL_adc_init(); 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_ADC_RESOLUTION 10
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_get_result() #define HAL_READ_ADC() HAL_adc_get_result()
#define HAL_ADC_READY() true #define HAL_ADC_READY() true

View File

@@ -59,6 +59,22 @@
#include "gcode/parser.h" #include "gcode/parser.h"
#include "gcode/queue.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) #if ENABLED(DIRECT_STEPPING)
#include "feature/direct_stepping.h" #include "feature/direct_stepping.h"
#endif #endif
@@ -695,8 +711,8 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
// Update the Beeper queue // Update the Beeper queue
TERN_(USE_BEEPER, buzzer.tick()); TERN_(USE_BEEPER, buzzer.tick());
// Read Buttons and Update the LCD // Handle UI input / draw events
ui.update(); TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
// Run i2c Position Encoders // Run i2c Position Encoders
#if ENABLED(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 // Direct Stepping
TERN_(DIRECT_STEPPING, page_manager.write_responses()); 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) #if ENABLED(MARLIN_DEV_MODE)
auto log_current_ms = [&](PGM_P const msg) { auto log_current_ms = [&](PGM_P const msg) {
SERIAL_ECHO_START(); SERIAL_ECHO_START();
SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHO("] "); SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHOPGM("] ");
serialprintPGM(msg); serialprintPGM(msg);
SERIAL_EOL(); SERIAL_EOL();
}; };
@@ -952,11 +972,18 @@ void setup() {
// UI must be initialized before EEPROM // UI must be initialized before EEPROM
// (because EEPROM code calls the UI). // (because EEPROM code calls the UI).
SETUP_RUN(ui.init()); #if ENABLED(DWIN_CREALITY_LCD)
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.) delay(800); // Required delay (since boot?)
SERIAL_ECHOPGM("\nDWIN handshake ");
#if BOTH(HAS_SPI_LCD, SHOW_BOOTSCREEN) if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error.");
SETUP_RUN(ui.show_bootscreen()); 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 #endif
#if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION) #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) SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults)
// This also updates variables in the planner, elsewhere // 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) #if ENABLED(TOUCH_BUTTONS)
SETUP_RUN(touch.init()); SETUP_RUN(touch.init());
#endif #endif
@@ -1133,6 +1156,22 @@ void setup() {
SETUP_RUN(mmu2.init()); SETUP_RUN(mmu2.init());
#endif #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) #if ENABLED(MAX7219_DEBUG)
SETUP_RUN(max7219.init()); SETUP_RUN(max7219.init());
#endif #endif
@@ -1141,6 +1180,10 @@ void setup() {
SETUP_RUN(page_manager.init()); SETUP_RUN(page_manager.init());
#endif #endif
#if ENABLED(TFT_LITTLE_VGL_UI)
SETUP_RUN(tft_lvgl_init());
#endif
marlin_state = MF_RUNNING; marlin_state = MF_RUNNING;
SETUP_LOG("setup() completed."); SETUP_LOG("setup() completed.");
@@ -1173,5 +1216,7 @@ void loop() {
endstops.event_handler(); endstops.event_handler();
TERN_(TFT_LITTLE_VGL_UI, printer_state_polling());
} while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards } while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
} }

View File

@@ -310,6 +310,7 @@
#define BOARD_CCROBOT_MEEB_3DP 4029 // ccrobot-online.com MEEB_3DP (STM32F103RC) #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_V5 4030 // Chitu3D TronXY X5SA V5 Board
#define BOARD_CHITU3D_V6 4031 // 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 // ARM Cortex-M4F
@@ -332,14 +333,15 @@
#define BOARD_BLACK_STM32F407ZE 4207 // BLACK_STM32F407ZE #define BOARD_BLACK_STM32F407ZE 4207 // BLACK_STM32F407ZE
#define BOARD_STEVAL_3DP001V1 4208 // STEVAL-3DP001V1 3D PRINTER BOARD #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_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_SKR_PRO_V1_2 4210 // BigTreeTech SKR Pro v1.2 (STM32F407ZG)
#define BOARD_BTT_GTR_V1_0 4211 // BigTreeTech GTR v1.0 (STM32F407IGT) #define BOARD_BTT_BTT002_V1_0 4211 // BigTreeTech BTT002 v1.0 (STM32F407VG)
#define BOARD_LERDGE_K 4212 // Lerdge K (STM32F407ZG) #define BOARD_BTT_GTR_V1_0 4212 // BigTreeTech GTR v1.0 (STM32F407IGT)
#define BOARD_LERDGE_X 4213 // Lerdge X (STM32F407VE) #define BOARD_LERDGE_K 4213 // Lerdge K (STM32F407ZG)
#define BOARD_VAKE403D 4214 // VAkE 403D (STM32F446VET6) #define BOARD_LERDGE_X 4214 // Lerdge X (STM32F407VE)
#define BOARD_FYSETC_S6 4215 // FYSETC S6 board #define BOARD_VAKE403D 4215 // VAkE 403D (STM32F446VET6)
#define BOARD_FLYF407ZG 4216 // FLYF407ZG board (STM32F407ZG) #define BOARD_FYSETC_S6 4216 // FYSETC S6 board
#define BOARD_MKS_ROBIN2 4217 // MKS_ROBIN2 (STM32F407ZE) #define BOARD_FLYF407ZG 4217 // FLYF407ZG board (STM32F407ZG)
#define BOARD_MKS_ROBIN2 4218 // MKS_ROBIN2 (STM32F407ZE)
// //
// ARM Cortex M7 // ARM Cortex M7

View File

@@ -31,6 +31,7 @@
#undef DEBUG_ERROR_START #undef DEBUG_ERROR_START
#undef DEBUG_CHAR #undef DEBUG_CHAR
#undef DEBUG_ECHO #undef DEBUG_ECHO
#undef DEBUG_DECIMAL
#undef DEBUG_ECHO_F #undef DEBUG_ECHO_F
#undef DEBUG_ECHOLN #undef DEBUG_ECHOLN
#undef DEBUG_ECHOPGM #undef DEBUG_ECHOPGM
@@ -57,6 +58,7 @@
#define DEBUG_ERROR_START SERIAL_ERROR_START #define DEBUG_ERROR_START SERIAL_ERROR_START
#define DEBUG_CHAR SERIAL_CHAR #define DEBUG_CHAR SERIAL_CHAR
#define DEBUG_ECHO SERIAL_ECHO #define DEBUG_ECHO SERIAL_ECHO
#define DEBUG_DECIMAL SERIAL_DECIMAL
#define DEBUG_ECHO_F SERIAL_ECHO_F #define DEBUG_ECHO_F SERIAL_ECHO_F
#define DEBUG_ECHOLN SERIAL_ECHOLN #define DEBUG_ECHOLN SERIAL_ECHOLN
#define DEBUG_ECHOPGM SERIAL_ECHOPGM #define DEBUG_ECHOPGM SERIAL_ECHOPGM
@@ -82,6 +84,7 @@
#define DEBUG_ERROR_START() NOOP #define DEBUG_ERROR_START() NOOP
#define DEBUG_CHAR(...) NOOP #define DEBUG_CHAR(...) NOOP
#define DEBUG_ECHO(...) NOOP #define DEBUG_ECHO(...) NOOP
#define DEBUG_DECIMAL(...) NOOP
#define DEBUG_ECHO_F(...) NOOP #define DEBUG_ECHO_F(...) NOOP
#define DEBUG_ECHOLN(...) NOOP #define DEBUG_ECHOLN(...) NOOP
#define DEBUG_ECHOPGM(...) NOOP #define DEBUG_ECHOPGM(...) NOOP

View File

@@ -97,10 +97,13 @@
#define CBI(A,B) (A &= ~(1 << (B))) #define CBI(A,B) (A &= ~(1 << (B)))
#endif #endif
#define TBI(N,B) (N ^= _BV(B))
#define _BV32(b) (1UL << (b)) #define _BV32(b) (1UL << (b))
#define TEST32(n,b) !!((n)&_BV32(b)) #define TEST32(n,b) !!((n)&_BV32(b))
#define SBI32(n,b) (n |= _BV32(b)) #define SBI32(n,b) (n |= _BV32(b))
#define CBI32(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 cu(x) ({__typeof__(x) _x = (x); (_x)*(_x)*(_x);})
#define RADIANS(d) ((d)*float(M_PI)/180.0f) #define RADIANS(d) ((d)*float(M_PI)/180.0f)
@@ -267,7 +270,7 @@
#define NEAR(x,y) NEAR_ZERO((x)-(y)) #define NEAR(x,y) NEAR_ZERO((x)-(y))
#define RECIPROCAL(x) (NEAR_ZERO(x) ? 0 : (1 / float(x))) #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 // Maths macros that can be overridden by HAL

View File

@@ -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, 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, 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, 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, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(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, 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 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); } void serial_echopair_PGM(PGM_P const s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); }

View File

@@ -51,10 +51,16 @@ extern uint8_t marlin_debug_flags;
extern int8_t serial_port_index; extern int8_t serial_port_index;
#define _PORT_REDIRECT(n,p) REMEMBER(n,serial_port_index,p) #define _PORT_REDIRECT(n,p) REMEMBER(n,serial_port_index,p)
#define _PORT_RESTORE(n) RESTORE(n) #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); \ #ifdef SERIAL_CATCHALL
if ( serial_port_index) (void)MYSERIAL1.WHAT(V); \ #define SERIAL_OUT(WHAT, V...) (void)CAT(MYSERIAL,SERIAL_CATCHALL).WHAT(V)
}while(0) #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(); } #define SERIAL_ASSERT(P) if(serial_port_index!=(P)){ debugger(); }
#else #else
#define _PORT_REDIRECT(n,p) NOOP #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)) #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.) // Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
// //

View File

@@ -123,10 +123,10 @@ void safe_delay(millis_t ms) {
#if ABL_PLANAR #if ABL_PLANAR
SERIAL_ECHOPGM("ABL Adjustment X"); SERIAL_ECHOPGM("ABL Adjustment X");
LOOP_XYZ(a) { 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)); SERIAL_CHAR(' ', XYZ_CHAR(a));
if (v > 0) SERIAL_CHAR('+'); if (v > 0) SERIAL_CHAR('+');
SERIAL_ECHO(v); SERIAL_DECIMAL(v);
} }
#else #else
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)

View File

@@ -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) { void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return; if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return;
accum += distance; // Count up babysteps for the UI 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); 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_(BABYSTEP_ALWAYS_AVAILABLE, gcode.reset_stepper_timeout());
TERN_(INTEGRATED_BABYSTEPPING, if (has_steps()) stepper.initiateBabystepping()); TERN_(INTEGRATED_BABYSTEPPING, if (has_steps()) stepper.initiateBabystepping());
} }

View File

@@ -393,17 +393,12 @@
#if HAS_BED_PROBE #if HAS_BED_PROBE
if (parser.seen('J')) { 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();
save_ubl_active_state_and_disable(); tilt_mesh_based_on_probed_grid(g29_grid_size == 0); // Zero size does 3-Point
tilt_mesh_based_on_probed_grid(false /* false says to do normal grid probing */ ); restore_ubl_active_state_and_leave();
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)));
else { // grid_size == 0 : A 3-Point leveling has been requested #endif
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)));
report_current_position(); report_current_position();
probe_deployed = true; probe_deployed = true;
} }
@@ -438,7 +433,7 @@
if (g29_verbose_level > 1) { if (g29_verbose_level > 1) {
SERIAL_ECHOPAIR("Probing around (", g29_pos.x); SERIAL_ECHOPAIR("Probing around (", g29_pos.x);
SERIAL_CHAR(','); SERIAL_CHAR(',');
SERIAL_ECHO(g29_pos.y); SERIAL_DECIMAL(g29_pos.y);
SERIAL_ECHOLNPGM(").\n"); SERIAL_ECHOLNPGM(").\n");
} }
const xy_pos_t near_probe_xy = g29_pos + probe.offset_xy; const xy_pos_t near_probe_xy = g29_pos + probe.offset_xy;
@@ -478,7 +473,7 @@
} }
if (parser.seen('B')) { 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) { if (ABS(g29_card_thickness) > 1.5f) {
SERIAL_ECHOLNPGM("?Error in Business Card measurement."); SERIAL_ECHOLNPGM("?Error in Business Card measurement.");
return; return;

View File

@@ -26,9 +26,17 @@
// BLTouch commands are sent as servo angles // BLTouch commands are sent as servo angles
typedef unsigned char BLTCommand; 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_SW_MODE 60
#define BLTOUCH_STOW 90
#define BLTOUCH_SELFTEST 120 #define BLTOUCH_SELFTEST 120
#define BLTOUCH_MODE_STORE 130 #define BLTOUCH_MODE_STORE 130
#define BLTOUCH_5V_MODE 140 #define BLTOUCH_5V_MODE 140
@@ -95,7 +103,7 @@ public:
private: private:
FORCE_INLINE static bool _deploy_query_alarm() { return command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); } 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 void clear();
static bool command(const BLTCommand cmd, const millis_t &ms); static bool command(const BLTCommand cmd, const millis_t &ms);

View File

@@ -107,7 +107,7 @@ void I2CPositionEncoder::update() {
SERIAL_ECHOLNPAIR("New zero-offset of ", zeroOffset); SERIAL_ECHOLNPAIR("New zero-offset of ", zeroOffset);
SERIAL_ECHOPAIR("New position reads as ", get_position()); SERIAL_ECHOPAIR("New position reads as ", get_position());
SERIAL_CHAR('('); SERIAL_CHAR('(');
SERIAL_ECHO(mm_from_count(get_position())); SERIAL_DECIMAL(mm_from_count(get_position()));
SERIAL_ECHOLNPGM(")"); SERIAL_ECHOLNPGM(")");
#endif #endif
} }

View File

@@ -280,13 +280,13 @@ class I2CPositionEncodersMgr {
static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) { static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) {
CHECK_IDX(); CHECK_IDX();
encoders[idx].set_ec_threshold(newThreshold); 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) { static void get_ec_threshold(const int8_t idx, const AxisEnum axis) {
CHECK_IDX(); CHECK_IDX();
const float threshold = encoders[idx].get_ec_threshold(); 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) { static int8_t idx_from_axis(const AxisEnum axis) {

View File

@@ -71,13 +71,11 @@ void Marlin_NeoPixel::set_color_startup(const uint32_t color) {
} }
void Marlin_NeoPixel::init() { void Marlin_NeoPixel::init() {
SET_OUTPUT(NEOPIXEL_PIN);
set_brightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range set_brightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range
begin(); begin();
show(); // initialize to all off show(); // initialize to all off
#if ENABLED(NEOPIXEL_STARTUP_TEST) #if ENABLED(NEOPIXEL_STARTUP_TEST)
safe_delay(1000);
set_color_startup(adaneo1.Color(255, 0, 0, 0)); // red set_color_startup(adaneo1.Color(255, 0, 0, 0)); // red
safe_delay(1000); safe_delay(1000);
set_color_startup(adaneo1.Color(0, 255, 0, 0)); // green set_color_startup(adaneo1.Color(0, 255, 0, 0)); // green

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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_adc_scale, PM_K_VALUE, PM_K_SCALE> PowerMonitor::amps;
#endif
#if ENABLED(POWER_MONITOR_VOLTAGE)
pm_lpf_t<PowerMonitor::volts_adc_scale, PM_K_VALUE, PM_K_SCALE> 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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../inc/MarlinConfig.h"
#define PM_SAMPLE_RANGE 1024
#define PM_K_VALUE 6
#define PM_K_SCALE 6
template <const float & SCALE, int K_VALUE, int K_SCALE>
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_adc_scale, PM_K_VALUE, PM_K_SCALE> 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_adc_scale, PM_K_VALUE, PM_K_SCALE> 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;

View File

@@ -40,6 +40,10 @@ uint8_t PrintJobRecovery::queue_index_r;
uint32_t PrintJobRecovery::cmd_sdpos, // = 0 uint32_t PrintJobRecovery::cmd_sdpos, // = 0
PrintJobRecovery::sdpos[BUFSIZE]; PrintJobRecovery::sdpos[BUFSIZE];
#if ENABLED(DWIN_CREALITY_LCD)
bool PrintJobRecovery::dwin_flag; // = false
#endif
#include "../sd/cardreader.h" #include "../sd/cardreader.h"
#include "../lcd/ultralcd.h" #include "../lcd/ultralcd.h"
#include "../gcode/queue.h" #include "../gcode/queue.h"
@@ -105,6 +109,7 @@ void PrintJobRecovery::check() {
load(); load();
if (!valid()) return cancel(); if (!valid()) return cancel();
queue.inject_P(PSTR("M1000 S")); queue.inject_P(PSTR("M1000 S"));
TERN_(DWIN_CREALITY_LCD, dwin_flag = true);
} }
} }
@@ -467,7 +472,7 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOPGM("current_position: "); DEBUG_ECHOPGM("current_position: ");
LOOP_XYZE(i) { LOOP_XYZE(i) {
if (i) DEBUG_CHAR(','); if (i) DEBUG_CHAR(',');
DEBUG_ECHO(info.current_position[i]); DEBUG_DECIMAL(info.current_position[i]);
} }
DEBUG_EOL(); DEBUG_EOL();
@@ -475,7 +480,7 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOPGM("home_offset: "); DEBUG_ECHOPGM("home_offset: ");
LOOP_XYZ(i) { LOOP_XYZ(i) {
if (i) DEBUG_CHAR(','); if (i) DEBUG_CHAR(',');
DEBUG_ECHO(info.home_offset[i]); DEBUG_DECIMAL(info.home_offset[i]);
} }
DEBUG_EOL(); DEBUG_EOL();
#endif #endif
@@ -484,7 +489,7 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOPGM("position_shift: "); DEBUG_ECHOPGM("position_shift: ");
LOOP_XYZ(i) { LOOP_XYZ(i) {
if (i) DEBUG_CHAR(','); if (i) DEBUG_CHAR(',');
DEBUG_ECHO(info.position_shift[i]); DEBUG_DECIMAL(info.position_shift[i]);
} }
DEBUG_EOL(); DEBUG_EOL();
#endif #endif

View File

@@ -121,6 +121,10 @@ class PrintJobRecovery {
static uint32_t cmd_sdpos, //!< SD position of the next command static uint32_t cmd_sdpos, //!< SD position of the next command
sdpos[BUFSIZE]; //!< SD positions of queued commands sdpos[BUFSIZE]; //!< SD positions of queued commands
#if ENABLED(DWIN_CREALITY_LCD)
static bool dwin_flag;
#endif
static void init(); static void init();
static void prepare(); static void prepare();

View File

@@ -109,8 +109,6 @@ public:
FORCE_INLINE static void refresh() { apply_power(power); } FORCE_INLINE static void refresh() { apply_power(power); }
FORCE_INLINE static void set_power(const uint8_t upwr) { power = upwr; refresh(); } 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) #if ENABLED(SPINDLE_LASER_PWM)
static void set_ocr(const uint8_t ocr); static void set_ocr(const uint8_t ocr);
@@ -148,21 +146,21 @@ public:
cutter_power_t upwr; cutter_power_t upwr;
switch (pwrUnit) { switch (pwrUnit) {
case 0: // PWM 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(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 > pct_to_ocr(max_pct)) ? pct_to_ocr(max_pct) // Use maximum if set above
: pwr : pwr
); );
break; break;
case 1: // PERCENT case 1: // PERCENT
upwr = ( upwr = cutter_power_t(
(pwr < min_pct) ? min_pct // Use minimum if set below (pwr < min_pct) ? min_pct // Use minimum if set below
: (pwr > max_pct) ? max_pct // Use maximum if set above : (pwr > max_pct) ? max_pct // Use maximum if set above
: pwr // PCT : pwr // PCT
); );
break; break;
case 2: // RPM case 2: // RPM
upwr = ( upwr = cutter_power_t(
(pwr < SPEED_POWER_MIN) ? SPEED_POWER_MIN // Use minimum if set below (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 > SPEED_POWER_MAX) ? SPEED_POWER_MAX // Use maximum if set above
: pwr // Calculate OCR value : pwr // Calculate OCR value
@@ -175,6 +173,10 @@ public:
#endif // SPINDLE_LASER_PWM #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 // Wait for spindle to spin up or spin down
static inline void power_delay(const bool on) { static inline void power_delay(const bool on) {
#if DISABLED(LASER_POWER_INLINE) #if DISABLED(LASER_POWER_INLINE)
@@ -194,7 +196,7 @@ public:
static inline void enable_with_dir(const bool reverse) { static inline void enable_with_dir(const bool reverse) {
isReady = true; 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) if (menuPower)
power = ocr; power = ocr;
else else

View File

@@ -152,8 +152,8 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
TMCMarlin(Stream * SerialPort, const float RS, uint8_t addr, const uint16_t mul_pin1, const uint16_t mul_pin2) : 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) 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) : TMCMarlin(const uint16_t RX, const uint16_t TX, const float RS, const uint8_t) :
TMC2208Stepper(RX, TX, RS, has_rx) TMC2208Stepper(RX, TX, RS)
{} {}
uint16_t rms_current() { return TMC2208Stepper::rms_current(); } uint16_t rms_current() { return TMC2208Stepper::rms_current(); }
@@ -197,7 +197,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
TMCMarlin(Stream * SerialPort, const float RS, const uint8_t addr) : TMCMarlin(Stream * SerialPort, const float RS, const uint8_t addr) :
TMC2209Stepper(SerialPort, RS, 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) TMC2209Stepper(RX, TX, RS, addr)
{} {}
uint8_t get_address() { return slave_address; } uint8_t get_address() { return slave_address; }

View File

@@ -25,6 +25,29 @@
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
#include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc. #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 // Touch screen resolution independent of display resolution
#define TOUCH_SCREEN_HEIGHT 240 #define TOUCH_SCREEN_HEIGHT 240
#define TOUCH_SCREEN_WIDTH 320 #define TOUCH_SCREEN_WIDTH 320
@@ -33,8 +56,13 @@
#define BUTTON_AREA_TOP 175 #define BUTTON_AREA_TOP 175
#define BUTTON_AREA_BOT 234 #define BUTTON_AREA_BOT 234
#define SCREEN_START_TOP ((LCD_PIXEL_OFFSET_Y) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT)) #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_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 #ifndef TOUCH_INT_PIN
#define TOUCH_INT_PIN -1 #define TOUCH_INT_PIN -1
@@ -98,10 +126,10 @@ uint8_t XPT2046::read_buttons() {
: WITHIN(x, 242, 305) ? EN_C : WITHIN(x, 242, 305) ? EN_C
: 0; : 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 // 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); row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
// Send the touch to the UI (which will simulate the encoder wheel) // Send the touch to the UI (which will simulate the encoder wheel)

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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>
*
* 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

View File

@@ -60,6 +60,10 @@
#include "../../../lcd/extui/ui_api.h" #include "../../../lcd/extui/ui_api.h"
#endif #endif
#if ENABLED(DWIN_CREALITY_LCD)
#include "../../../lcd/dwin/dwin.h"
#endif
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
#include "../../../module/tool_change.h" #include "../../../module/tool_change.h"
#endif #endif
@@ -888,6 +892,10 @@ G29_TYPE GcodeSuite::G29() {
process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT)); process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT));
#endif #endif
#if ENABLED(DWIN_CREALITY_LCD)
DWIN_CompletedLeveling();
#endif
report_current_position(); report_current_position();
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29");

View File

@@ -46,6 +46,9 @@
#endif #endif
#include "../../lcd/ultralcd.h" #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 #if HAS_L64XX // set L6470 absolute position registers to counts
#include "../../libs/L64XX/L64XX_Marlin.h" #include "../../libs/L64XX/L64XX_Marlin.h"
@@ -209,6 +212,8 @@ void GcodeSuite::G28() {
log_machine_info(); log_machine_info();
} }
TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true);
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
bool IDEX_saved_duplication_state = extruder_duplication_enabled; bool IDEX_saved_duplication_state = extruder_duplication_enabled;
DualXMode IDEX_saved_mode = dual_x_carriage_mode; DualXMode IDEX_saved_mode = dual_x_carriage_mode;
@@ -475,6 +480,8 @@ void GcodeSuite::G28() {
ui.refresh(); ui.refresh();
TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming());
report_current_position(); report_current_position();
if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS))) if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS)))

View File

@@ -105,7 +105,7 @@ void GcodeSuite::M92() {
if (wanted) { if (wanted) {
const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm; const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm;
SERIAL_ECHOPAIR(", best:[", best); 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_CHAR(']');
} }
SERIAL_ECHOLNPGM(" }"); SERIAL_ECHOLNPGM(" }");

View File

@@ -67,8 +67,12 @@
*/ */
void GcodeSuite::M3_M4(const bool is_M4) { void GcodeSuite::M3_M4(const bool is_M4) {
auto get_s_power = [] { auto get_s_power = [] {
if (parser.seen('S')) if (parser.seenval('S')) {
cutter.unitPower = cutter.power_to_range(cutter_power_t(round(parser.value_float()))); 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 else
cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP);
return cutter.unitPower; return cutter.unitPower;
@@ -86,7 +90,7 @@ void GcodeSuite::M3_M4(const bool is_M4) {
else else
cutter.inline_power(cutter.upower_to_ocr(get_s_power())); cutter.inline_power(cutter.upower_to_ocr(get_s_power()));
#else #else
cutter.inline_enabled(true); cutter.set_inline_enabled(true);
#endif #endif
return; return;
} }

View File

@@ -134,7 +134,7 @@ void GcodeSuite::M900() {
SERIAL_ECHOPGM("Advance K"); SERIAL_ECHOPGM("Advance K");
LOOP_L_N(i, EXTRUDERS) { LOOP_L_N(i, EXTRUDERS) {
SERIAL_CHAR(' ', '0' + i, ':'); SERIAL_CHAR(' ', '0' + i, ':');
SERIAL_ECHO(planner.extruder_advance_K[i]); SERIAL_DECIMAL(planner.extruder_advance_K[i]);
} }
SERIAL_EOL(); SERIAL_EOL();
#endif #endif

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -179,8 +179,10 @@ void GcodeSuite::get_destination_from_command() {
#if ENABLED(LASER_MOVE_POWER) #if ENABLED(LASER_MOVE_POWER)
// Set the laser power in the planner to configure this move // Set the laser power in the planner to configure this move
if (parser.seen('S')) if (parser.seen('S')) {
cutter.inline_power(cutter.power_to_range(cutter_power_t(round(parser.value_float())))); 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 else if (ENABLED(LASER_MOVE_G0_OFF) && parser.codenum == 0) // G0
cutter.set_inline_enabled(false); cutter.set_inline_enabled(false);
#endif #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 case 34: G34(); break; // G34: Z Stepper automatic alignment using probe
#endif #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) #if ENABLED(G38_PROBE_TARGET)
case 38: // G38.2, G38.3: Probe towards target case 38: // G38.2, G38.3: Probe towards target
if (WITHIN(parser.subcode, 2, 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 case 428: M428(); break; // M428: Apply current_position to home_offset
#endif #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) #if ENABLED(CANCEL_OBJECTS)
case 486: M486(); break; // M486: Identify and cancel objects case 486: M486(); break; // M486: Identify and cancel objects
#endif #endif

View File

@@ -65,6 +65,7 @@
* G32 - Undock sled (Z_PROBE_SLED only) * G32 - Undock sled (Z_PROBE_SLED only)
* G33 - Delta Auto-Calibration (Requires DELTA_AUTO_CALIBRATION) * G33 - Delta Auto-Calibration (Requires DELTA_AUTO_CALIBRATION)
* G34 - Z Stepper automatic alignment using probe: I<iterations> T<accuracy> A<amplification> (Requires Z_STEPPER_AUTO_ALIGN) * G34 - Z Stepper automatic alignment using probe: I<iterations> T<accuracy> A<amplification> (Requires Z_STEPPER_AUTO_ALIGN)
* G35 - Read bed corners to help adjust bed screws: T<screw_thread> (Requires ASSISTED_TRAMMING)
* G38 - Probe in any direction using the Z_MIN_PROBE (Requires G38_PROBE_TARGET) * 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) * 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) * G60 - Save current position. (Requires SAVED_POSITIONS)
@@ -217,6 +218,7 @@
* M422 - Set Z Stepper automatic alignment position using probe. X<units> Y<units> A<axis> (Requires Z_STEPPER_AUTO_ALIGN) * M422 - Set Z Stepper automatic alignment position using probe. X<units> Y<units> A<axis> (Requires Z_STEPPER_AUTO_ALIGN)
* M425 - Enable/Disable and tune backlash correction. (Requires BACKLASH_COMPENSATION and BACKLASH_GCODE) * 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) * 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) * M486 - Identify and cancel objects. (Requires CANCEL_OBJECTS)
* M500 - Store parameters in EEPROM. (Requires EEPROM_SETTINGS) * M500 - Store parameters in EEPROM. (Requires EEPROM_SETTINGS)
* M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS) * M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS)
@@ -453,6 +455,8 @@ private:
static void M422(); static void M422();
#endif #endif
TERN_(ASSISTED_TRAMMING, static void G35());
TERN_(G38_PROBE_TARGET, static void G38(const int8_t subcode)); TERN_(G38_PROBE_TARGET, static void G38(const int8_t subcode));
TERN_(HAS_MESH, static void G42()); TERN_(HAS_MESH, static void G42());
@@ -735,6 +739,8 @@ private:
TERN_(HAS_M206_COMMAND, static void M428()); TERN_(HAS_M206_COMMAND, static void M428());
TERN_(HAS_POWER_MONITOR, static void M430());
TERN_(CANCEL_OBJECTS, static void M486()); TERN_(CANCEL_OBJECTS, static void M486());
static void M500(); static void M500();

View File

@@ -115,6 +115,9 @@ void GcodeSuite::M115() {
// MOTION_MODES (M80-M89) // MOTION_MODES (M80-M89)
cap_line(PSTR("MOTION_MODES"), ENABLED(GCODE_MOTION_MODES)); cap_line(PSTR("MOTION_MODES"), ENABLED(GCODE_MOTION_MODES));
// ARC_SUPPORT (G2-G3)
cap_line(PSTR("ARCS"), ENABLED(ARC_SUPPORT));
// BABYSTEPPING (M290) // BABYSTEPPING (M290)
cap_line(PSTR("BABYSTEPPING"), ENABLED(BABYSTEPPING)); cap_line(PSTR("BABYSTEPPING"), ENABLED(BABYSTEPPING));

View File

@@ -53,7 +53,7 @@ void GcodeSuite::G30() {
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; 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); const float measured_z = probe.probe_at_point(pos, raise_after, 1);
if (!isnan(measured_z)) 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(); restore_feedrate_and_scaling();

View File

@@ -31,7 +31,6 @@
#if ENABLED(PARK_HEAD_ON_PAUSE) #if ENABLED(PARK_HEAD_ON_PAUSE)
#include "../../feature/pause.h" #include "../../feature/pause.h"
#include "../queue.h"
#endif #endif
#if ENABLED(HOST_ACTION_COMMANDS) #if ENABLED(HOST_ACTION_COMMANDS)
@@ -98,7 +97,8 @@ void GcodeSuite::M25() {
#endif #endif
print_job_timer.pause(); print_job_timer.pause();
ui.reset_status();
TERN(DWIN_CREALITY_LCD,,ui.reset_status());
#if ENABLED(HOST_ACTION_COMMANDS) #if ENABLED(HOST_ACTION_COMMANDS)
TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume"))); TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume")));

View File

@@ -35,7 +35,15 @@
#define IS_CARTESIAN 1 #define IS_CARTESIAN 1
#endif #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 DOGLCD
#define IS_ULTIPANEL #define IS_ULTIPANEL
@@ -98,15 +106,9 @@
#elif ENABLED(CR10_STOCKDISPLAY) #elif ENABLED(CR10_STOCKDISPLAY)
#define IS_RRD_FG_SC #define IS_RRD_FG_SC
#ifndef ST7920_DELAY_1 #define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#define ST7920_DELAY_1 DELAY_NS(125) #define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#endif #define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#ifndef ST7920_DELAY_2
#define ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef ST7920_DELAY_3
#define ST7920_DELAY_3 DELAY_NS(125)
#endif
#elif ENABLED(MKS_12864OLED) #elif ENABLED(MKS_12864OLED)
@@ -118,10 +120,6 @@
#define IS_RRD_SC #define IS_RRD_SC
#define IS_U8GLIB_SSD1306 #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) #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 #define FYSETC_MINI_12864
@@ -241,6 +239,8 @@
#define DOGLCD #define DOGLCD
#define IS_ULTIPANEL #define IS_ULTIPANEL
#define DELAYED_BACKLIGHT_INIT #define DELAYED_BACKLIGHT_INIT
#elif ENABLED(SPI_GRAPHICAL_TFT)
#define DELAYED_BACKLIGHT_INIT
#endif #endif
/** /**
@@ -527,6 +527,15 @@
#define UNUSED_E(E) UNUSED(E) #define UNUSED_E(E) UNUSED(E)
#endif #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 * The BLTouch Probe emulates a servo probe
* and uses "special" angles for its state. * and uses "special" angles for its state.

View File

@@ -352,6 +352,17 @@
#define SD_CONNECTION_IS(...) 0 #define SD_CONNECTION_IS(...) 0
#endif #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 // 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) #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 #define NO_EEPROM_SELECTED 1

View File

@@ -30,6 +30,13 @@
// Extras for CI testing // Extras for CI testing
#endif #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 // Linear advance uses Jerk since E is an isolated axis
#if BOTH(HAS_JUNCTION_DEVIATION, LIN_ADVANCE) #if BOTH(HAS_JUNCTION_DEVIATION, LIN_ADVANCE)
#define HAS_LINEAR_E_JERK 1 #define HAS_LINEAR_E_JERK 1
@@ -287,7 +294,7 @@
#elif ENABLED(AZSMZ_12864) #elif ENABLED(AZSMZ_12864)
#define _LCD_CONTRAST_MIN 120 #define _LCD_CONTRAST_MIN 120
#define _LCD_CONTRAST_INIT 190 #define _LCD_CONTRAST_INIT 190
#elif ENABLED(MKS_LCD12864B) #elif ENABLED(MKS_LCD12864)
#define _LCD_CONTRAST_MIN 120 #define _LCD_CONTRAST_MIN 120
#define _LCD_CONTRAST_INIT 205 #define _LCD_CONTRAST_INIT 205
#elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY)
@@ -1685,16 +1692,16 @@
#if ENABLED(JOYSTICK) #if ENABLED(JOYSTICK)
#if PIN_EXISTS(JOY_X) #if PIN_EXISTS(JOY_X)
#define HAS_JOY_ADC_X 1 #define HAS_JOY_ADC_X 1
#endif #endif
#if PIN_EXISTS(JOY_Y) #if PIN_EXISTS(JOY_Y)
#define HAS_JOY_ADC_Y 1 #define HAS_JOY_ADC_Y 1
#endif #endif
#if PIN_EXISTS(JOY_Z) #if PIN_EXISTS(JOY_Z)
#define HAS_JOY_ADC_Z 1 #define HAS_JOY_ADC_Z 1
#endif #endif
#if PIN_EXISTS(JOY_EN) #if PIN_EXISTS(JOY_EN)
#define HAS_JOY_ADC_EN 1 #define HAS_JOY_ADC_EN 1
#endif #endif
#endif #endif
// Heaters // Heaters
@@ -2465,7 +2472,11 @@
#endif #endif
// Number of VFAT entries used. Each entry has 13 UTF-16 characters // 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 // Nozzle park for Delta
#if BOTH(NOZZLE_PARK_FEATURE, DELTA) #if BOTH(NOZZLE_PARK_FEATURE, DELTA)

View File

@@ -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(FIX_MOUNTED_PROBE) \
+ ENABLED(NOZZLE_AS_PROBE) \ + ENABLED(NOZZLE_AS_PROBE) \
+ (HAS_Z_SERVO_PROBE && DISABLED(BLTOUCH)) \ + (HAS_Z_SERVO_PROBE && DISABLED(BLTOUCH)) \
+ ENABLED(BLTOUCH) \ + ENABLED(BLTOUCH) && DISABLED(CREALITY_TOUCH) \
+ ENABLED(CREALITY_TOUCH) \
+ ENABLED(TOUCH_MI_PROBE) \ + ENABLED(TOUCH_MI_PROBE) \
+ ENABLED(SOLENOID_PROBE) \ + ENABLED(SOLENOID_PROBE) \
+ ENABLED(Z_PROBE_ALLEN_KEY) \ + 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
#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 * 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." #error "TEMP_SENSOR_7 shouldn't be set with only 1 HOTEND."
#endif #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 TEMP_SENSOR_PROBE
#if !PIN_EXISTS(TEMP_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 #elif !HAS_TEMP_ADC_PROBE
#error "TEMP_PROBE_PIN must be an ADC pin." #error "TEMP_PROBE_PIN must be an ADC pin."
#elif !ENABLED(FIX_MOUNTED_PROBE) #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(ULTRA_LCD) && DISABLED(IS_ULTRA_LCD)) \
+ (ENABLED(U8GLIB_SSD1306) && DISABLED(IS_U8GLIB_SSD1306)) \ + (ENABLED(U8GLIB_SSD1306) && DISABLED(IS_U8GLIB_SSD1306)) \
+ (ENABLED(MINIPANEL) && DISABLED(MKS_MINI_12864, ENDER2_STOCKDISPLAY)) \ + (ENABLED(MINIPANEL) && DISABLED(MKS_MINI_12864, ENDER2_STOCKDISPLAY)) \
+ (ENABLED(MKS_MINI_12864) && DISABLED(MKS_LCD12864)) \
+ (ENABLED(EXTENSIBLE_UI) && DISABLED(IS_EXTUI)) \ + (ENABLED(EXTENSIBLE_UI) && DISABLED(IS_EXTUI)) \
+ (ENABLED(ULTIPANEL) && DISABLED(IS_ULTIPANEL)) \ + (ENABLED(ULTIPANEL) && DISABLED(IS_ULTIPANEL)) \
+ ENABLED(RADDS_DISPLAY) \ + 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(CARTESIO_UI) \
+ ENABLED(LCD_FOR_MELZI) \ + ENABLED(LCD_FOR_MELZI) \
+ ENABLED(ULTI_CONTROLLER) \ + ENABLED(ULTI_CONTROLLER) \
+ ENABLED(MKS_MINI_12864) \ + ENABLED(MKS_LCD12864) \
+ ENABLED(ENDER2_STOCKDISPLAY) \ + ENABLED(ENDER2_STOCKDISPLAY) \
+ ENABLED(FYSETC_MINI_12864_X_X) \ + ENABLED(FYSETC_MINI_12864_X_X) \
+ ENABLED(FYSETC_MINI_12864_1_2) \ + 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_MINI_12864_2_1) \
+ ENABLED(FYSETC_GENERIC_12864_1_1) \ + ENABLED(FYSETC_GENERIC_12864_1_1) \
+ ENABLED(CR10_STOCKDISPLAY) \ + ENABLED(CR10_STOCKDISPLAY) \
+ ENABLED(DWIN_CREALITY_LCD) \
+ ENABLED(ANET_FULL_GRAPHICS_LCD) \ + ENABLED(ANET_FULL_GRAPHICS_LCD) \
+ ENABLED(AZSMZ_12864) \ + ENABLED(AZSMZ_12864) \
+ ENABLED(SILVER_GATE_GLCD_CONTROLLER) \ + ENABLED(SILVER_GATE_GLCD_CONTROLLER) \

View File

@@ -42,7 +42,7 @@
* version was tagged. * version was tagged.
*/ */
#ifndef STRING_DISTRIBUTION_DATE #ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2020-06-15" #define STRING_DISTRIBUTION_DATE "2020-06-23"
#endif #endif
/** /**

View File

@@ -927,6 +927,7 @@ static const hd44780_charmap_t g_hd44780_charmap_common[] PROGMEM = {
{IV('ю'), '|', 'o'}, {IV('ю'), '|', 'o'},
{IV('я'), 'g', 0}, // 044F {IV('я'), 'g', 0}, // 044F
{IV('ё'), 'e', 0}, // 0451 {IV('ё'), 'e', 0}, // 0451
#endif #endif
{IV(''), '.', 0}, // 2022 · {IV(''), '.', 0}, // 2022 ·

View File

@@ -1372,7 +1372,7 @@
#define STATUS_LOGO_X 0 #define STATUS_LOGO_X 0
#endif #endif
#ifndef STATUS_LOGO_Y #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 #endif
#ifndef STATUS_LOGO_HEIGHT #ifndef STATUS_LOGO_HEIGHT
#define STATUS_LOGO_HEIGHT (sizeof(status_logo_bmp) / (STATUS_LOGO_BYTEWIDTH)) #define STATUS_LOGO_HEIGHT (sizeof(status_logo_bmp) / (STATUS_LOGO_BYTEWIDTH))

View File

@@ -48,6 +48,10 @@
#include "../../feature/spindle_laser.h" #include "../../feature/spindle_laser.h"
#endif #endif
#if HAS_POWER_MONITOR
#include "../../feature/power_monitor.h"
#endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "../../sd/cardreader.h" #include "../../sd/cardreader.h"
#endif #endif
@@ -103,6 +107,59 @@
#define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1) #define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
#endif #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_X 54
#define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1) #define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1)
#define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X) #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) { void MarlinUI::draw_status_message(const bool blink) {
// Get the UTF8 character count of the string // 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) #if ENABLED(STATUS_MESSAGE_SCROLLING)
static bool last_blink = false; static bool last_blink = false;
if (slen <= LCD_WIDTH) { if (slen <= lcd_width) {
// The string fits within the line. Print with no scrolling // The string fits within the line. Print with no scrolling
lcd_put_u8str(status_message); lcd_put_u8str(status_message);
while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; } while (slen < lcd_width) { lcd_put_wchar(' '); ++slen; }
} }
else { else {
// String is longer than the available space // String is longer than the available space
@@ -805,20 +871,21 @@ void MarlinUI::draw_status_message(const bool blink) {
// and the string remaining length // and the string remaining length
uint8_t rlen; uint8_t rlen;
const char *stat = status_and_len(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 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 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 if (--chars) { // Draw a second dot if there's space
lcd_put_wchar('.'); lcd_put_wchar('.');
if (--chars) { // Print a second copy of the message 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(' '); lcd_put_wchar(' ');
} }
} }
} }
if (last_blink != blink) { if (last_blink != blink) {
last_blink = blink; last_blink = blink;
advance_status_scroll(); advance_status_scroll();
@@ -830,12 +897,16 @@ void MarlinUI::draw_status_message(const bool blink) {
UNUSED(blink); UNUSED(blink);
// Just print the string to the LCD // 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 // 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 #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 #endif // HAS_GRAPHICAL_LCD && !LIGHTWEIGHT_UI

View File

@@ -73,10 +73,6 @@
extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count); extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count);
#endif #endif
#ifndef FSMC_UPSCALE
#define FSMC_UPSCALE 2
#endif
#define WIDTH LCD_PIXEL_WIDTH #define WIDTH LCD_PIXEL_WIDTH
#define HEIGHT LCD_PIXEL_HEIGHT #define HEIGHT LCD_PIXEL_HEIGHT
#define PAGE_HEIGHT 8 #define PAGE_HEIGHT 8

View File

@@ -140,7 +140,6 @@ static int fontgroup_cb_draw_u8g(void *userdata, const font_t *fnt_current, cons
if (pdata->fnt_prev != fnt_current) { if (pdata->fnt_prev != fnt_current) {
u8g_SetFont(pdata->pu8g, (const u8g_fntpgm_uint8_t*)fnt_current); u8g_SetFont(pdata->pu8g, (const u8g_fntpgm_uint8_t*)fnt_current);
//u8g_SetFontPosBottom(pdata->pu8g);
pdata->fnt_prev = fnt_current; pdata->fnt_prev = fnt_current;
} }
if ((pdata->max_width != PIXEL_LEN_NOLIMIT) && (pdata->adv + u8g_GetStrPixelWidth(pdata->pu8g, (char*)msg) > pdata->max_width)) 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) { if (pdata->fnt_prev != fnt_current) {
u8g_SetFont(pdata->pu8g, (const u8g_fntpgm_uint8_t*)fnt_current); u8g_SetFont(pdata->pu8g, (const u8g_fntpgm_uint8_t*)fnt_current);
u8g_SetFontPosBottom(pdata->pu8g);
pdata->fnt_prev = fnt_current; pdata->fnt_prev = fnt_current;
} }
pdata->adv += u8g_GetStrPixelWidth(pdata->pu8g, (char*)msg); pdata->adv += u8g_GetStrPixelWidth(pdata->pu8g, (char*)msg);

View File

@@ -240,7 +240,7 @@ bool MarlinUI::detected() { return true; }
// Initialize or re-initialize the LCD // Initialize or re-initialize the LCD
void MarlinUI::init_lcd() { void MarlinUI::init_lcd() {
#if DISABLED(MKS_LCD12864B) #if DISABLED(MKS_LCD12864)
#if PIN_EXISTS(LCD_BACKLIGHT) #if PIN_EXISTS(LCD_BACKLIGHT)
OUT_WRITE(LCD_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); // Illuminate after reset or right away 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_180, u8g.setRot180());
TERN_(LCD_SCREEN_ROT_270, u8g.setRot270()); TERN_(LCD_SCREEN_ROT_270, u8g.setRot270());
#endif // !MKS_LCD12864B #endif // !MKS_LCD12864
uxg_SetUtf8Fonts(g_fontinfo, COUNT(g_fontinfo)); 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 // 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) { 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)) { 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); u8g_uint_t n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH);
if (vallen) { if (vallen) {
lcd_put_wchar(':'); lcd_put_wchar(':');
while (n > MENU_FONT_WIDTH) n -= 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); if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str((char*)data);
} }
} }

View File

@@ -254,4 +254,8 @@
#define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT) #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
#define INFO_FONT_WIDTH 6 #define INFO_FONT_WIDTH 6
#ifndef FSMC_UPSCALE
#define FSMC_UPSCALE 2
#endif
extern U8G_CLASS u8g; extern U8G_CLASS u8g;

View File

@@ -34,19 +34,30 @@
#include "ultralcd_st7920_u8glib_rrd_AVR.h" #include "ultralcd_st7920_u8glib_rrd_AVR.h"
#ifndef ST7920_DELAY_1 #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 #endif
#ifndef ST7920_DELAY_2 #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 #endif
#ifndef ST7920_DELAY_3 #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 #endif
// Optimize this code with -O3 // Optimize this code with -O3
#pragma GCC optimize (3) #pragma GCC optimize (3)
#ifdef ARDUINO_ARCH_STM32F1 #ifdef ARDUINO_ARCH_STM32F1
#define ST7920_DAT(V) !!((V) & 0x80) #define ST7920_DAT(V) !!((V) & 0x80)
#else #else

View File

@@ -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.

File diff suppressed because it is too large Load Diff

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* DWIN by Creality3D
*/
#include "dwin_lcd.h"
#include "rotary_encoder.h"
#include "eeprom_BL24CXX.h"
#include <stdint.h>
#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);

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
/********************************************************************************
* @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 <string.h> // 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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
/********************************************************************************
* @file dwin_lcd.h
* @author LEO / Creality3D
* @date 2019/07/18
* @version 2.0.1
* @brief 迪文屏控制操作函数
********************************************************************************/
#include <stdint.h>
#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);

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
/********************************************************************************
* @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 <stdlib.h>
/******************** 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时发送ACKack=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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
/********************************************************************************
* @file eeprom_BL24CXX.h
* @brief i2c EEPROM for Ender 3 v2 board (4.2.2)
********************************************************************************/
#include <libmaple/gpio.h>
/******************** 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); //从指定地址开始读出指定长度的数据
};

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
/**
******************************************************************************
* @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 <stdlib.h>
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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -592,7 +592,7 @@ void DGUSScreenVariableHandler::HandleManualExtrude(DGUS_VP_Variable &var, void
case VP_MOVE_E0: target_extruder = ExtUI::extruder_t::E0; break; case VP_MOVE_E0: target_extruder = ExtUI::extruder_t::E0; break;
#endif #endif
#if HOTENDS >= 2 #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 #endif
default: return; default: return;
} }

View File

@@ -387,7 +387,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
#endif #endif
#endif #endif
#if HOTENDS >= 2 #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_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_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr),

View File

@@ -151,7 +151,7 @@ constexpr uint16_t VP_SETTINGS = 0x2400;
// PID autotune // PID autotune
constexpr uint16_t VP_PID_AUTOTUNE_E0 = 0x2410; 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_E2 = 0x2414;
//constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x2416; //constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x2416;
//constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x2418; //constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x2418;
@@ -246,7 +246,7 @@ constexpr uint16_t VP_FAN3_STATUS = 0x3306;
// Heater status // Heater status
constexpr uint16_t VP_E0_STATUS = 0x3310; 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_E2_STATUS = 0x3314;
//constexpr uint16_t VP_E3_STATUS = 0x3316; //constexpr uint16_t VP_E3_STATUS = 0x3316;
//constexpr uint16_t VP_E4_STATUS = 0x3318; //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_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_I = 0x3702;
constexpr uint16_t VP_E0_PID_D = 0x3704; 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_P = 0x3710;
constexpr uint16_t VP_BED_PID_I = 0x3712; constexpr uint16_t VP_BED_PID_I = 0x3712;
constexpr uint16_t VP_BED_PID_D = 0x3714; constexpr uint16_t VP_BED_PID_D = 0x3714;

View File

@@ -315,7 +315,7 @@ class CommandProcessor : public CLCD::CommandFifo {
#ifdef TOUCH_UI_USE_UTF8 #ifdef TOUCH_UI_USE_UTF8
const bool is_utf8 = has_utf8_chars(text); const bool is_utf8 = has_utf8_chars(text);
#endif #endif
for (;font >= 26;) { for (;font > 26;) {
int16_t width, height; int16_t width, height;
#ifdef TOUCH_UI_USE_UTF8 #ifdef TOUCH_UI_USE_UTF8
if (is_utf8) { if (is_utf8) {

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(SPI_GRAPHICAL_TFT)
#include <SPI.h>
#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<uint8_t*>(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<uint8_t*>(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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <stdint.h>
#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;

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if 1 // ENABLED(SPI_FLASH)
#if ENABLED(TFT_LITTLE_VGL_UI)
#include <SPI.h>
#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<uint8_t*>(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<uint8_t*>(buf), 512);
}
uint16_t ext_FLASH::W25QXX_ReadID(void) {
uint16_t Temp = 0;
W25QXX_CS_L;
spi_flash_Send(0x90);//<2F><><EFBFBD>Ͷ<EFBFBD>ȡID<49><44><EFBFBD><EFBFBD>
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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
//#ifdef __cplusplus
//extern "C" { /* C-declarations for C++ */
//#endif
#include <stdint.h>
#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<67><6F><EFBFBD>ֵ
#define TITLELOGO_MAX_SIZE (150*1024)//logo<67><6F><EFBFBD>ֵ
#define DEFAULT_VIEW_MAX_SIZE (200*200*2)
#define FLASH_VIEW_MAX_SIZE (200*200*2)
//ͼƬ
//Robin2<6E><EFBFBD><E6B4A2>ַ
#define PIC_NAME_ADDR 0x003000 //ͼƬ<CDBC><C6AC>Ϣ<EFBFBD><EFBFBD><E6B4A2>ַ<EFBFBD><D6B7>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>
#define PIC_SIZE_ADDR 0x007000 //ͼƬ<CDBC><C6AC>Ϣ<EFBFBD><EFBFBD><E6B4A2>ַ<EFBFBD><D6B7>ͼƬ<CDBC><C6AC>Сֵ
#define PIC_COUNTER_ADDR 0x008000 //ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><E6B4A2>ַ
#define PIC_LOGO_ADDR 0x009000 //ͼƬlogo<67><EFBFBD><E6B4A2>ַ
//#define PIC_DATA_ADDR 0x02f000 //ͼƬ<CDBC><C6AC><EFBFBD>ݴ洢<DDB4><E6B4A2>ַ
#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) //ͼƬ<CDBC><C6AC><EFBFBD>ݴ洢<DDB4><E6B4A2>ַ//(800*240)
// <20>ֿ<EFBFBD>
#define FONTINFOADDR 0x600000 // 6M<36>Ժ<EFBFBD><D4BA>ַΪ<D6B7>ֿ<EFBFBD>
#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) // Ϊ<>˷<EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬ÿ<E2A3AC><C3BF>СͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4BBAE>Ӧ<EFBFBD><D3A6>ȡ<EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD><EFBFBD>4K<34><4B>ֵ
//
union union32 {
uint8_t bytes[4];
uint32_t dwords;
};
// ͼƬ<CDBC><C6AC>Ϣ<EFBFBD><EFBFBD><E1B9B9>
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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
/**
* 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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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 <string.h>
//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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

Some files were not shown because too many files have changed in this diff Show More