Browse Source

Creality DWIN cleanup

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
092aad1813
  1. 137
      Marlin/src/lcd/dwin/dwin.cpp
  2. 4
      Marlin/src/lcd/dwin/dwin.h

137
Marlin/src/lcd/dwin/dwin.cpp

@ -65,8 +65,6 @@
#include "../../module/probe.h" #include "../../module/probe.h"
#endif #endif
#include "../../libs/buzzer.h"
#ifndef MACHINE_SIZE #ifndef MACHINE_SIZE
#define MACHINE_SIZE "220x220x250" #define MACHINE_SIZE "220x220x250"
#endif #endif
@ -1065,36 +1063,40 @@ void HMI_Move_Z(void) {
} }
} }
void HMI_Move_E(void) { #if EXTRUDERS
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { void HMI_Move_E(void) {
if (encoder_diffState == ENCODER_DIFF_CW) { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue; if (encoder_diffState != ENCODER_DIFF_NO) {
} if (encoder_diffState == ENCODER_DIFF_CW) {
else if (encoder_diffState == ENCODER_DIFF_CCW) { HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue;
HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue; }
} else if (encoder_diffState == ENCODER_DIFF_CCW) {
else if (encoder_diffState == ENCODER_DIFF_ENTER) { HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue;
checkkey = AxisMove;
EncoderRate.encoderRateEnabled = 0;
last_E_scale = HMI_ValueStruct.Move_E_scale;
show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
if (!planner.is_full()) {
planner.synchronize(); // Wait for planner moves to finish!
planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder);
} }
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
checkkey = AxisMove;
EncoderRate.encoderRateEnabled = 0;
last_E_scale = HMI_ValueStruct.Move_E_scale;
show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
if (!planner.is_full()) {
planner.synchronize(); // Wait for planner moves to finish!
planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder);
}
DWIN_UpdateLCD();
return;
}
if ((HMI_ValueStruct.Move_E_scale - last_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
HMI_ValueStruct.Move_E_scale = last_E_scale + (EXTRUDE_MAXLENGTH) * MINUNITMULT;
else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT;
current_position.e = HMI_ValueStruct.Move_E_scale / 10;
show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
DWIN_UpdateLCD(); DWIN_UpdateLCD();
return;
} }
if ((HMI_ValueStruct.Move_E_scale - last_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
HMI_ValueStruct.Move_E_scale = last_E_scale + (EXTRUDE_MAXLENGTH) * MINUNITMULT;
else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT;
current_position.e = HMI_ValueStruct.Move_E_scale / 10;
show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
DWIN_UpdateLCD();
} }
}
#endif
void HMI_Zoffset(void) { void HMI_Zoffset(void) {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
@ -2096,7 +2098,9 @@ inline void Draw_Move_Menu() {
DWIN_Frame_AreaCopy(1, 58, 118, 271 - 165, 479 - 347, LBLX, MBASE(1)); DWIN_Frame_AreaCopy(1, 58, 118, 271 - 165, 479 - 347, LBLX, MBASE(1));
DWIN_Frame_AreaCopy(1, 109, 118, 271 - 114, 479 - 347, LBLX, MBASE(2)); DWIN_Frame_AreaCopy(1, 109, 118, 271 - 114, 479 - 347, LBLX, MBASE(2));
DWIN_Frame_AreaCopy(1, 160, 118, 271 - 62, 479 - 347, LBLX, MBASE(3)); DWIN_Frame_AreaCopy(1, 160, 118, 271 - 62, 479 - 347, LBLX, MBASE(3));
DWIN_Frame_AreaCopy(1, 212, 118, 271 - 18, 479 - 348, LBLX, MBASE(4)); #if HAS_HOTEND
DWIN_Frame_AreaCopy(1, 212, 118, 271 - 18, 479 - 348, LBLX, MBASE(4));
#endif
} }
else { else {
#ifdef USE_STRING_HEADINGS #ifdef USE_STRING_HEADINGS
@ -2107,7 +2111,9 @@ inline void Draw_Move_Menu() {
draw_move_en(MBASE(1)); say_x(33 + 3, MBASE(1)); // "Move X" draw_move_en(MBASE(1)); say_x(33 + 3, MBASE(1)); // "Move X"
draw_move_en(MBASE(2)); say_y(33 + 3, MBASE(2)); // "Move Y" draw_move_en(MBASE(2)); say_y(33 + 3, MBASE(2)); // "Move Y"
draw_move_en(MBASE(3)); say_z(33 + 3, MBASE(3)); // "Move Z" draw_move_en(MBASE(3)); say_z(33 + 3, MBASE(3)); // "Move Z"
DWIN_Frame_AreaCopy(1, 123, 192, 271 - 95, 479 - 277, LBLX, MBASE(4)); // "Extruder" #if HAS_HOTEND
DWIN_Frame_AreaCopy(1, 123, 192, 271 - 95, 479 - 277, LBLX, MBASE(4)); // "Extruder"
#endif
} }
Draw_Back_First(select_axis.now == 0); Draw_Back_First(select_axis.now == 0);
@ -2116,6 +2122,18 @@ inline void Draw_Move_Menu() {
LOOP_L_N(i, MROWS) Draw_Menu_Line(i + 1, ICON_MoveX + i); LOOP_L_N(i, MROWS) Draw_Menu_Line(i + 1, ICON_MoveX + i);
} }
#include "../../libs/buzzer.h"
void HMI_AudioFeedback(const bool success=true) {
if (success) {
buzzer.tone(100, 659);
buzzer.tone(10, 0);
buzzer.tone(100, 698);
}
else
buzzer.tone(40, 440);
}
/* Prepare */ /* Prepare */
void HMI_Prepare(void) { void HMI_Prepare(void) {
ENCODER_DiffState encoder_diffState = get_encoder_state(); ENCODER_DiffState encoder_diffState = get_encoder_state();
@ -2202,8 +2220,7 @@ void HMI_Prepare(void) {
#else #else
// Apply workspace offset, making the current position 0,0,0 // Apply workspace offset, making the current position 0,0,0
queue.inject_P(PSTR("G92 X0 Y0 Z0")); queue.inject_P(PSTR("G92 X0 Y0 Z0"));
buzzer.tone(100, 659); HMI_AudioFeedback();
buzzer.tone(100, 698);
#endif #endif
break; break;
case 5: // PLA preheat case 5: // PLA preheat
@ -2347,27 +2364,17 @@ void HMI_Control(void) {
select_motion.reset(); select_motion.reset();
Draw_Motion_Menu(); Draw_Motion_Menu();
break; break;
case 3: // write EEPROM case 3: { // write EEPROM
if (settings.save()) { const bool success = settings.save();
buzzer.tone(100, 659); HMI_AudioFeedback(success);
buzzer.tone(100, 698); } break;
} case 4: { // read EEPROM
else const bool success = settings.load();
buzzer.tone(20, 440); HMI_AudioFeedback(success);
break; } break;
case 4: // read EEPROM
if (settings.load()) {
buzzer.tone(100, 659);
buzzer.tone(100, 698);
}
else {buzzer.tone(20, 440);}
break;
case 5: // resume EEPROM case 5: // resume EEPROM
settings.reset(); settings.reset();
#if HAS_BUZZER HMI_AudioFeedback();
buzzer.tone(100, 659);
buzzer.tone(100, 698);
#endif
break; break;
case 6: // info case 6: // info
checkkey = Info; checkkey = Info;
@ -3006,14 +3013,10 @@ void HMI_PLAPreheatSetting(void) {
EncoderRate.encoderRateEnabled = 1; EncoderRate.encoderRateEnabled = 1;
break; break;
#endif #endif
case 4: // save PLA configuration case 4: { // save PLA configuration
if (settings.save()) { const bool success = settings.save();
buzzer.tone(100, 659); HMI_AudioFeedback(success);
buzzer.tone(100, 698); } break;
}
else
buzzer.tone(20, 440);
break;
default: break; default: break;
} }
} }
@ -3064,14 +3067,10 @@ void HMI_ABSPreheatSetting(void) {
EncoderRate.encoderRateEnabled = 1; EncoderRate.encoderRateEnabled = 1;
break; break;
#endif #endif
case 4: // save PLA configuration case 4: { // save ABS configuration
if (settings.save()) { const bool success = settings.save();
buzzer.tone(100, 659); HMI_AudioFeedback(success);
buzzer.tone(100, 698); } break;
}
else
buzzer.tone(20, 440);
break;
default: default:
break; break;
} }
@ -3496,11 +3495,11 @@ void DWIN_HandleScreen(void) {
case Move_X: HMI_Move_X(); break; case Move_X: HMI_Move_X(); break;
case Move_Y: HMI_Move_Y(); break; case Move_Y: HMI_Move_Y(); break;
case Move_Z: HMI_Move_Z(); break; case Move_Z: HMI_Move_Z(); break;
case Extruder: HMI_Move_E(); break;
case Homeoffset: HMI_Zoffset(); break;
#if HAS_HOTEND #if HAS_HOTEND
case Extruder: HMI_Move_E(); break;
case ETemp: HMI_ETemp(); break; case ETemp: HMI_ETemp(); break;
#endif #endif
case Homeoffset: HMI_Zoffset(); break;
#if HAS_HEATED_BED #if HAS_HEATED_BED
case BedTemp: HMI_BedTemp(); break; case BedTemp: HMI_BedTemp(); break;
#endif #endif

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

@ -68,11 +68,11 @@ enum processID {
Move_X, Move_X,
Move_Y, Move_Y,
Move_Z, Move_Z,
Extruder,
Homeoffset,
#if HAS_HOTEND #if HAS_HOTEND
Extruder,
ETemp, ETemp,
#endif #endif
Homeoffset,
#if HAS_HEATED_BED #if HAS_HEATED_BED
BedTemp, BedTemp,
#endif #endif

Loading…
Cancel
Save