Browse Source

E3 DWIN: General cleanup

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
584c836918
  1. 128
      Marlin/src/lcd/dwin/e3v2/dwin.cpp
  2. 4
      Marlin/src/lcd/dwin/e3v2/dwin.h

128
Marlin/src/lcd/dwin/e3v2/dwin.cpp

@ -494,6 +494,16 @@ inline void Draw_Back_First(const bool is_sel=true) {
if (is_sel) Draw_Menu_Cursor(0); if (is_sel) Draw_Menu_Cursor(0);
} }
inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valref) {
if (encoder_diffState == ENCODER_DIFF_CW)
valref += EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_CCW)
valref -= EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_ENTER)
return true;
return false;
}
// //
// Draw Menus // Draw Menus
// //
@ -1146,13 +1156,7 @@ inline ENCODER_DiffState get_encoder_state() {
void HMI_Move_X() { void HMI_Move_X() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scale)) {
HMI_ValueStruct.Move_X_scale += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.Move_X_scale -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
checkkey = AxisMove; checkkey = AxisMove;
EncoderRate.enabled = false; EncoderRate.enabled = false;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
@ -1175,13 +1179,7 @@ void HMI_Move_X() {
void HMI_Move_Y() { void HMI_Move_Y() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scale)) {
HMI_ValueStruct.Move_Y_scale += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.Move_Y_scale -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
checkkey = AxisMove; checkkey = AxisMove;
EncoderRate.enabled = false; EncoderRate.enabled = false;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
@ -1204,13 +1202,7 @@ void HMI_Move_Y() {
void HMI_Move_Z() { void HMI_Move_Z() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scale)) {
HMI_ValueStruct.Move_Z_scale += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.Move_Z_scale -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
checkkey = AxisMove; checkkey = AxisMove;
EncoderRate.enabled = false; EncoderRate.enabled = false;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
@ -1236,13 +1228,7 @@ void HMI_Move_Z() {
static float last_E_scale = 0; static float last_E_scale = 0;
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scale)) {
HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
checkkey = AxisMove; checkkey = AxisMove;
EncoderRate.enabled = false; EncoderRate.enabled = false;
last_E_scale = HMI_ValueStruct.Move_E_scale; last_E_scale = HMI_ValueStruct.Move_E_scale;
@ -1278,11 +1264,7 @@ void HMI_Move_Z() {
case -4: zoff_line = PREPARE_CASE_ZOFF + MROWS - index_prepare; break; case -4: zoff_line = PREPARE_CASE_ZOFF + MROWS - index_prepare; break;
default: zoff_line = TUNE_CASE_ZOFF + MROWS - index_tune; default: zoff_line = TUNE_CASE_ZOFF + MROWS - index_tune;
} }
if (encoder_diffState == ENCODER_DIFF_CW) if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.offset_value)) {
HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_CCW)
HMI_ValueStruct.offset_value -= EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
EncoderRate.enabled = false; EncoderRate.enabled = false;
#if HAS_BED_PROBE #if HAS_BED_PROBE
probe.offset.z = dwin_zoffset; probe.offset.z = dwin_zoffset;
@ -1326,13 +1308,7 @@ void HMI_Move_Z() {
case -3: temp_line = PREHEAT_CASE_TEMP; break; case -3: temp_line = PREHEAT_CASE_TEMP; break;
default: temp_line = TUNE_CASE_TEMP + MROWS - index_tune; default: temp_line = TUNE_CASE_TEMP + MROWS - index_tune;
} }
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.E_Temp)) {
HMI_ValueStruct.E_Temp += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.E_Temp -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
EncoderRate.enabled = false; EncoderRate.enabled = false;
if (HMI_ValueStruct.show_mode == -1) { // temperature if (HMI_ValueStruct.show_mode == -1) { // temperature
checkkey = TemperatureID; checkkey = TemperatureID;
@ -1379,13 +1355,7 @@ void HMI_Move_Z() {
case -3: bed_line = PREHEAT_CASE_BED; break; case -3: bed_line = PREHEAT_CASE_BED; break;
default: bed_line = TUNE_CASE_BED + MROWS - index_tune; default: bed_line = TUNE_CASE_BED + MROWS - index_tune;
} }
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Bed_Temp)) {
HMI_ValueStruct.Bed_Temp += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.Bed_Temp -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
EncoderRate.enabled = false; EncoderRate.enabled = false;
if (HMI_ValueStruct.show_mode == -1) { if (HMI_ValueStruct.show_mode == -1) {
checkkey = TemperatureID; checkkey = TemperatureID;
@ -1433,13 +1403,7 @@ void HMI_Move_Z() {
default: fan_line = TUNE_CASE_FAN + MROWS - index_tune; default: fan_line = TUNE_CASE_FAN + MROWS - index_tune;
} }
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Fan_speed)) {
HMI_ValueStruct.Fan_speed += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.Fan_speed -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
EncoderRate.enabled = false; EncoderRate.enabled = false;
if (HMI_ValueStruct.show_mode == -1) { if (HMI_ValueStruct.show_mode == -1) {
checkkey = TemperatureID; checkkey = TemperatureID;
@ -1477,13 +1441,7 @@ void HMI_Move_Z() {
void HMI_PrintSpeed() { void HMI_PrintSpeed() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.print_speed)) {
HMI_ValueStruct.print_speed += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.print_speed -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
checkkey = Tune; checkkey = Tune;
EncoderRate.enabled = false; EncoderRate.enabled = false;
feedrate_percentage = HMI_ValueStruct.print_speed; feedrate_percentage = HMI_ValueStruct.print_speed;
@ -1501,13 +1459,7 @@ void HMI_PrintSpeed() {
void HMI_MaxFeedspeedXYZE() { void HMI_MaxFeedspeedXYZE() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Feedspeed)) {
HMI_ValueStruct.Max_Feedspeed += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.Max_Feedspeed -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
checkkey = MaxSpeed; checkkey = MaxSpeed;
EncoderRate.enabled = false; EncoderRate.enabled = false;
if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS)) if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS))
@ -1527,9 +1479,7 @@ void HMI_MaxFeedspeedXYZE() {
void HMI_MaxAccelerationXYZE() { void HMI_MaxAccelerationXYZE() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Max_Acceleration += EncoderRate.encoderMoveValue;} if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Acceleration)) {
else if (encoder_diffState == ENCODER_DIFF_CCW) { HMI_ValueStruct.Max_Acceleration -= EncoderRate.encoderMoveValue;}
else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
checkkey = MaxAcceleration; checkkey = MaxAcceleration;
EncoderRate.enabled = false; EncoderRate.enabled = false;
if (HMI_flag.acc_axis == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration); if (HMI_flag.acc_axis == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration);
@ -1555,11 +1505,7 @@ void HMI_MaxAccelerationXYZE() {
void HMI_MaxJerkXYZE() { void HMI_MaxJerkXYZE() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
if (encoder_diffState == ENCODER_DIFF_CW) if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk)) {
HMI_ValueStruct.Max_Jerk += EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_CCW)
HMI_ValueStruct.Max_Jerk -= EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
checkkey = MaxJerk; checkkey = MaxJerk;
EncoderRate.enabled = false; EncoderRate.enabled = false;
if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS))
@ -1581,13 +1527,7 @@ void HMI_MaxAccelerationXYZE() {
void HMI_StepXYZE() { void HMI_StepXYZE() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
if (encoder_diffState == ENCODER_DIFF_CW) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step)) {
HMI_ValueStruct.Max_Step += EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
HMI_ValueStruct.Max_Step -= EncoderRate.encoderMoveValue;
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
checkkey = Step; checkkey = Step;
EncoderRate.enabled = false; EncoderRate.enabled = false;
if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS))
@ -1842,7 +1782,7 @@ void HMI_SDCardUpdate() {
if (DWIN_lcd_sd_status != card.isMounted()) { if (DWIN_lcd_sd_status != card.isMounted()) {
DWIN_lcd_sd_status = card.isMounted(); DWIN_lcd_sd_status = card.isMounted();
// SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", int(DWIN_lcd_sd_status)); // SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", int(DWIN_lcd_sd_status));
if (card.isMounted()) { if (DWIN_lcd_sd_status) {
if (checkkey == SelectFile) if (checkkey == SelectFile)
Redraw_SD_List(); Redraw_SD_List();
} }
@ -1863,10 +1803,11 @@ void HMI_SDCardUpdate() {
} }
} }
/* Start Frame */ //
// The status area is always on-screen, except during
void HMI_StartFrame(const bool with_update) { // full-screen modal dialogs. (TODO: Keep alive during dialogs)
Goto_MainMenu(); //
void Draw_Status_Area(const bool with_update) {
// Clear the bottom area of the screen // Clear the bottom area of the screen
DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1);
@ -1906,6 +1847,11 @@ void HMI_StartFrame(const bool with_update) {
} }
} }
void HMI_StartFrame(const bool with_update) {
Goto_MainMenu();
Draw_Status_Area(with_update);
}
inline void Draw_Info_Menu() { inline void Draw_Info_Menu() {
Clear_Main_Window(); Clear_Main_Window();
@ -2233,12 +2179,10 @@ void HMI_PauseOrStop() {
ENCODER_DiffState encoder_diffState = get_encoder_state(); ENCODER_DiffState encoder_diffState = get_encoder_state();
if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_NO) return;
if (encoder_diffState == ENCODER_DIFF_CW) { if (encoder_diffState == ENCODER_DIFF_CW)
Draw_Select_Highlight(false); Draw_Select_Highlight(false);
} else if (encoder_diffState == ENCODER_DIFF_CCW)
else if (encoder_diffState == ENCODER_DIFF_CCW) {
Draw_Select_Highlight(true); Draw_Select_Highlight(true);
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) { else if (encoder_diffState == ENCODER_DIFF_ENTER) {
if (select_print.now == 1) { // pause window if (select_print.now == 1) { // pause window
if (HMI_flag.select_flag) { if (HMI_flag.select_flag) {

4
Marlin/src/lcd/dwin/e3v2/dwin.h

@ -335,8 +335,8 @@ void Icon_temperature(bool value);
void Icon_leveling(bool value); void Icon_leveling(bool value);
// Other // Other
bool Pause_HeatStatus(); void Draw_Status_Area(const bool with_update); // Status Area
void HMI_StartFrame(const bool with_update); // Startup screen void HMI_StartFrame(const bool with_update); // Prepare the menu view
void HMI_MainMenu(); // Main process screen void HMI_MainMenu(); // Main process screen
void HMI_SelectFile(); // File page void HMI_SelectFile(); // File page
void HMI_Printing(); // Print page void HMI_Printing(); // Print page

Loading…
Cancel
Save