Clean up DWIN code

This commit is contained in:
Scott Lahteine 2020-07-14 20:01:29 -05:00 committed by Scott Lahteine
parent 2d33a9fd7c
commit e78f19bc87
5 changed files with 1123 additions and 1101 deletions

View File

@ -1776,7 +1776,10 @@
// Shorthand for common combinations
#if HAS_TEMP_BED && HAS_HEATER_BED
#define HAS_HEATED_BED 1
#define BED_MAX_TARGET (BED_MAXTEMP - 10)
#ifndef BED_OVERSHOOT
#define BED_OVERSHOOT 10
#endif
#define BED_MAX_TARGET (BED_MAXTEMP - (BED_OVERSHOOT))
#endif
#if HAS_HEATED_BED || HAS_TEMP_CHAMBER
#define BED_OR_CHAMBER 1

File diff suppressed because it is too large Load Diff

View File

@ -31,45 +31,8 @@
#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*/
// Process ID
MainMenu,
SelectFile,
Prepare,
@ -94,14 +57,14 @@ enum processID {
Step,
Step_value,
/*Last Process ID*/
// Last Process ID
Last_Prepare,
/*Back Process ID*/
// Back Process ID
Back_Main,
Back_Print,
/*Date variable ID*/
// Date variable ID
Move_X,
Move_Y,
Move_Z,
@ -118,17 +81,17 @@ enum processID {
#endif
PrintSpeed,
/*Window ID*/
// Window ID
Print_window,
Popup_Window
};
/*Picture ID*/
// Picture ID
#define Start_Process 0
#define Language_English 1
#define Language_Chinese 2
/*ICON ID*/
// ICON ID
#define ICON 0x09
#define ICON_LOGO 0
#define ICON_Print_0 1
@ -227,11 +190,11 @@ enum processID {
#define ICON_Info_0 90
#define ICON_Info_1 91
/*
* 3-.00x00-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
*/
/**
* 3-.0The font size, 0x00-0x09, corresponds to the font size below:
* 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
@ -243,17 +206,17 @@ enum processID {
#define font28x56 0x08
#define font32x64 0x09
/* Colour */
// Color
#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 // 选中色
#define Background_window 0x31E8 // Popup background color
#define Background_blue 0x1125 // Dark blue background color
#define Background_black 0x0841 // black background color
#define Font_window 0xD6BA // Popup font background color
#define Line_Color 0x3A6A // Split line color
#define Rectangle_Color 0xEE2F // blue square cursor color
#define Percent_Color 0xFE29 // percentage color
#define BarFill_Color 0x10E4 // fill color of progress bar
#define Select_Color 0x33BB // selected color
extern int checkkey, last_checkkey;
extern float zprobe_zoffset;
@ -262,15 +225,9 @@ extern char print_filename[16];
extern millis_t dwin_heat_time;
typedef struct {
#if HAS_HOTEND
int16_t E_Temp = 0;
#endif
#if HAS_HEATED_BED
int16_t Bed_Temp = 0;
#endif
#if HAS_FAN
int16_t Fan_speed = 0;
#endif
TERN_(HAS_HOTEND, int16_t E_Temp = 0);
TERN_(HAS_HEATED_BED, int16_t Bed_Temp = 0);
TERN_(HAS_FAN, int16_t Fan_speed = 0);
int16_t print_speed = 100;
float Max_Feedspeed = 0;
float Max_Acceleration = 0;
@ -311,12 +268,12 @@ typedef struct {
extern HMI_value_t HMI_ValueStruct;
extern HMI_Flag HMI_flag;
/* Language */
// Language
void lcd_select_language(void);
void set_english_to_eeprom(void);
void set_chinese_to_eeprom(void);
/* Show ICON*/
// Show ICO
void ICON_Print(bool show);
void ICON_Prepare(bool show);
void ICON_Control(bool show);
@ -328,7 +285,7 @@ void ICON_Pause(bool show);
void ICON_Continue(bool show);
void ICON_Stop(bool show);
/* Popup window tips */
// Popup window tips
#if HAS_HOTEND
void Popup_Window_Temperature(const bool toohigh);
void Popup_Window_ETempTooLow(void);
@ -341,7 +298,7 @@ void Popup_Window_Leveling(void);
void Goto_PrintProcess(void);
void Goto_MainMenu(void);
/* Variable control */
// Variable control
void HMI_Move_X(void);
void HMI_Move_Y(void);
void HMI_Move_Z(void);
@ -349,15 +306,10 @@ void HMI_Move_E(void);
void HMI_Zoffset(void);
#if HAS_HOTEND
void HMI_ETemp(void);
#endif
#if HAS_HEATED_BED
void HMI_BedTemp(void);
#endif
#if HAS_FAN
void HMI_FanSpeed(void);
#endif
TERN_(HAS_HOTEND, void HMI_ETemp(void));
TERN_(HAS_HEATED_BED, void HMI_BedTemp(void));
TERN_(HAS_FAN, void HMI_FanSpeed(void));
void HMI_PrintSpeed(void);
void HMI_MaxFeedspeedXYZE(void);
@ -368,40 +320,40 @@ 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 */
// SD Card
void HMI_SDCardInit(void);
void HMI_SDCardUpdate(void);
/* Main Process */
// Main Process
void Icon_print(bool value);
void Icon_control(bool value);
void Icon_temperature(bool value);
void Icon_leveling(bool value);
/* Other */
// 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_StartFrame(const bool with_update); // startup screen
void HMI_MainMenu(void); // main process screen
void HMI_SelectFile(void); // file page
void HMI_Printing(void); // print page
void HMI_Prepare(void); // prepare page
void HMI_Control(void); // control page
void HMI_Leveling(void); // Level the page
void HMI_AxisMove(void); // Axis movement menu
void HMI_Temperature(void); // Temperature menu
void HMI_Motion(void); // Sports menu
void HMI_Info(void); // Information menu
void HMI_Tune(void); // Adjust the menu
#if HAS_HOTEND
void HMI_PLAPreheatSetting(void); // PLA预热设置
void HMI_ABSPreheatSetting(void); // ABS预热设置
void HMI_PLAPreheatSetting(void); // PLA warm-up setting
void HMI_ABSPreheatSetting(void); // ABS warm-up setting
#endif
void HMI_MaxSpeed(void); // 最大速度子菜单
void HMI_MaxAcceleration(void); // 最大加速度子菜单
void HMI_MaxCorner(void); // 最大拐角速度子菜单
void HMI_Step(void); // 传动比
void HMI_MaxSpeed(void); // Maximum speed submenu
void HMI_MaxAcceleration(void); // Maximum acceleration submenu
void HMI_MaxCorner(void); // Maximum corner speed submenu
void HMI_Step(void); // transmission ratio
void HMI_Init(void);
void DWIN_Update(void);

View File

@ -30,11 +30,11 @@
/******************** IIC ********************/
//IO方向设置
//IO direction setting
#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操作函数
//IO operation function
#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)
@ -43,18 +43,18 @@
class BL24CXX;
// IIC所有操作函数
// All operation functions of 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 init(); // Initialize the IO port of IIC
static void start(); // Send IIC start signal
static void stop(); // Send IIC stop signal
static void send_byte(uint8_t txd); // IIC sends a byte
static uint8_t read_byte(unsigned char ack); // IIC reads a byte
static uint8_t wait_ack(); // IIC waits for ACK signal
static void ack(); // IIC sends ACK signal
static void nAck(); // IIC does not send ACK signal
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);
@ -75,12 +75,12 @@ protected:
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); //从指定地址开始读出指定长度的数据
static void init(); // Initialize IIC
static uint8_t check(); // Check the device
static uint8_t readOneByte(uint16_t ReadAddr); // Read a byte at the specified address
static void writeOneByte(uint16_t WriteAddr, uint8_t DataToWrite); // Write a byte at the specified address
static void writeLenByte(uint16_t WriteAddr, uint32_t DataToWrite, uint8_t Len);// The specified address begins to write the data of the specified length
static uint32_t readLenByte(uint16_t ReadAddr, uint8_t Len); // The specified address starts to read the data of the specified length
static void write(uint16_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite); // Write the specified length of data from the specified address
static void read(uint16_t ReadAddr, uint8_t *pBuffer, uint16_t NumToRead); // Read the data of the specified length from the specified address
};

View File

@ -314,10 +314,7 @@ void menu_cancelobject();
#undef PID_BED_MENU_SECTION
#endif
#if ENABLED(PID_AUTOTUNE_MENU)
#ifndef BED_OVERSHOOT
#define BED_OVERSHOOT 5
#endif
EDIT_ITEM_FAST_N(int3, -1, MSG_PID_AUTOTUNE_E, &autotune_temp_bed, PREHEAT_1_TEMP_BED, BED_MAXTEMP - BED_OVERSHOOT, []{ _lcd_autotune(-1); });
EDIT_ITEM_FAST_N(int3, -1, MSG_PID_AUTOTUNE_E, &autotune_temp_bed, PREHEAT_1_TEMP_BED, BED_MAX_TARGET, []{ _lcd_autotune(-1); });
#endif
#endif