Procházet zdrojové kódy

Creality DWIN cleanup

Scott Lahteine před 4 roky
rodič
revize
092aad1813
2 změnil soubory, kde provedl 70 přidání a 71 odebrání
  1. 68
    69
      Marlin/src/lcd/dwin/dwin.cpp
  2. 2
    2
      Marlin/src/lcd/dwin/dwin.h

+ 68
- 69
Marlin/src/lcd/dwin/dwin.cpp Zobrazit soubor

@@ -65,8 +65,6 @@
65 65
   #include "../../module/probe.h"
66 66
 #endif
67 67
 
68
-#include "../../libs/buzzer.h"
69
-
70 68
 #ifndef MACHINE_SIZE
71 69
   #define MACHINE_SIZE "220x220x250"
72 70
 #endif
@@ -1065,36 +1063,40 @@ void HMI_Move_Z(void) {
1065 1063
   }
1066 1064
 }
1067 1065
 
1068
-void HMI_Move_E(void) {
1069
-  ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1070
-  if (encoder_diffState != ENCODER_DIFF_NO) {
1071
-    if (encoder_diffState == ENCODER_DIFF_CW) {
1072
-      HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue;
1073
-    }
1074
-    else if (encoder_diffState == ENCODER_DIFF_CCW) {
1075
-      HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue;
1076
-    }
1077
-    else if (encoder_diffState == ENCODER_DIFF_ENTER) {
1078
-      checkkey = AxisMove;
1079
-      EncoderRate.encoderRateEnabled = 0;
1080
-      last_E_scale = HMI_ValueStruct.Move_E_scale;
1081
-      show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
1082
-      if (!planner.is_full()) {
1083
-        planner.synchronize(); // Wait for planner moves to finish!
1084
-        planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder);
1066
+#if EXTRUDERS
1067
+
1068
+  void HMI_Move_E(void) {
1069
+    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1070
+    if (encoder_diffState != ENCODER_DIFF_NO) {
1071
+      if (encoder_diffState == ENCODER_DIFF_CW) {
1072
+        HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue;
1073
+      }
1074
+      else if (encoder_diffState == ENCODER_DIFF_CCW) {
1075
+        HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue;
1085 1076
       }
1077
+      else if (encoder_diffState == ENCODER_DIFF_ENTER) {
1078
+        checkkey = AxisMove;
1079
+        EncoderRate.encoderRateEnabled = 0;
1080
+        last_E_scale = HMI_ValueStruct.Move_E_scale;
1081
+        show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
1082
+        if (!planner.is_full()) {
1083
+          planner.synchronize(); // Wait for planner moves to finish!
1084
+          planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder);
1085
+        }
1086
+        DWIN_UpdateLCD();
1087
+        return;
1088
+      }
1089
+      if ((HMI_ValueStruct.Move_E_scale - last_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
1090
+        HMI_ValueStruct.Move_E_scale = last_E_scale + (EXTRUDE_MAXLENGTH) * MINUNITMULT;
1091
+      else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
1092
+        HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT;
1093
+      current_position.e = HMI_ValueStruct.Move_E_scale / 10;
1094
+      show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
1086 1095
       DWIN_UpdateLCD();
1087
-      return;
1088 1096
     }
1089
-    if ((HMI_ValueStruct.Move_E_scale - last_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
1090
-      HMI_ValueStruct.Move_E_scale = last_E_scale + (EXTRUDE_MAXLENGTH) * MINUNITMULT;
1091
-    else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
1092
-      HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT;
1093
-    current_position.e = HMI_ValueStruct.Move_E_scale / 10;
1094
-    show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
1095
-    DWIN_UpdateLCD();
1096 1097
   }
1097
-}
1098
+
1099
+#endif
1098 1100
 
1099 1101
 void HMI_Zoffset(void) {
1100 1102
   ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
@@ -2096,7 +2098,9 @@ inline void Draw_Move_Menu() {
2096 2098
     DWIN_Frame_AreaCopy(1, 58, 118, 271 - 165, 479 - 347, LBLX, MBASE(1));
2097 2099
     DWIN_Frame_AreaCopy(1, 109, 118, 271 - 114, 479 - 347, LBLX, MBASE(2));
2098 2100
     DWIN_Frame_AreaCopy(1, 160, 118, 271 - 62, 479 - 347, LBLX, MBASE(3));
2099
-    DWIN_Frame_AreaCopy(1, 212, 118, 271 - 18, 479 - 348, LBLX, MBASE(4));
2101
+    #if HAS_HOTEND
2102
+      DWIN_Frame_AreaCopy(1, 212, 118, 271 - 18, 479 - 348, LBLX, MBASE(4));
2103
+    #endif
2100 2104
   }
2101 2105
   else {
2102 2106
     #ifdef USE_STRING_HEADINGS
@@ -2107,7 +2111,9 @@ inline void Draw_Move_Menu() {
2107 2111
     draw_move_en(MBASE(1)); say_x(33 + 3, MBASE(1));                    // "Move X"
2108 2112
     draw_move_en(MBASE(2)); say_y(33 + 3, MBASE(2));                    // "Move Y"
2109 2113
     draw_move_en(MBASE(3)); say_z(33 + 3, MBASE(3));                    // "Move Z"
2110
-    DWIN_Frame_AreaCopy(1, 123, 192, 271 - 95, 479 - 277, LBLX, MBASE(4)); // "Extruder"
2114
+    #if HAS_HOTEND
2115
+      DWIN_Frame_AreaCopy(1, 123, 192, 271 - 95, 479 - 277, LBLX, MBASE(4)); // "Extruder"
2116
+    #endif
2111 2117
   }
2112 2118
 
2113 2119
   Draw_Back_First(select_axis.now == 0);
@@ -2116,6 +2122,18 @@ inline void Draw_Move_Menu() {
2116 2122
   LOOP_L_N(i, MROWS) Draw_Menu_Line(i + 1, ICON_MoveX + i);
2117 2123
 }
2118 2124
 
2125
+#include "../../libs/buzzer.h"
2126
+
2127
+void HMI_AudioFeedback(const bool success=true) {
2128
+  if (success) {
2129
+    buzzer.tone(100, 659);
2130
+    buzzer.tone(10, 0);
2131
+    buzzer.tone(100, 698);
2132
+  }
2133
+  else
2134
+    buzzer.tone(40, 440);
2135
+}
2136
+
2119 2137
 /* Prepare */
2120 2138
 void HMI_Prepare(void) {
2121 2139
   ENCODER_DiffState encoder_diffState = get_encoder_state();
@@ -2202,8 +2220,7 @@ void HMI_Prepare(void) {
2202 2220
         #else
2203 2221
           // Apply workspace offset, making the current position 0,0,0
2204 2222
           queue.inject_P(PSTR("G92 X0 Y0 Z0"));
2205
-          buzzer.tone(100, 659);
2206
-          buzzer.tone(100, 698);
2223
+          HMI_AudioFeedback();
2207 2224
         #endif
2208 2225
         break;
2209 2226
       case 5: // PLA preheat
@@ -2347,27 +2364,17 @@ void HMI_Control(void) {
2347 2364
         select_motion.reset();
2348 2365
         Draw_Motion_Menu();
2349 2366
         break;
2350
-      case 3: // write EEPROM
2351
-        if (settings.save()) {
2352
-          buzzer.tone(100, 659);
2353
-          buzzer.tone(100, 698);
2354
-        }
2355
-        else
2356
-          buzzer.tone(20, 440);
2357
-        break;
2358
-      case 4: // read EEPROM
2359
-        if (settings.load()) {
2360
-          buzzer.tone(100, 659);
2361
-          buzzer.tone(100, 698);
2362
-        }
2363
-        else {buzzer.tone(20, 440);}
2364
-        break;
2367
+      case 3: { // write EEPROM
2368
+        const bool success = settings.save();
2369
+        HMI_AudioFeedback(success);
2370
+      } break;
2371
+      case 4: { // read EEPROM
2372
+        const bool success = settings.load();
2373
+        HMI_AudioFeedback(success);
2374
+      } break;
2365 2375
       case 5: // resume EEPROM
2366 2376
         settings.reset();
2367
-        #if HAS_BUZZER
2368
-          buzzer.tone(100, 659);
2369
-          buzzer.tone(100, 698);
2370
-        #endif
2377
+        HMI_AudioFeedback();
2371 2378
         break;
2372 2379
       case 6: // info
2373 2380
         checkkey = Info;
@@ -3006,14 +3013,10 @@ void HMI_PLAPreheatSetting(void) {
3006 3013
             EncoderRate.encoderRateEnabled = 1;
3007 3014
             break;
3008 3015
         #endif
3009
-      case 4: // save PLA configuration
3010
-        if (settings.save()) {
3011
-          buzzer.tone(100, 659);
3012
-          buzzer.tone(100, 698);
3013
-        }
3014
-        else
3015
-          buzzer.tone(20, 440);
3016
-        break;
3016
+      case 4: { // save PLA configuration
3017
+        const bool success = settings.save();
3018
+        HMI_AudioFeedback(success);
3019
+      } break;
3017 3020
       default: break;
3018 3021
     }
3019 3022
   }
@@ -3064,14 +3067,10 @@ void HMI_ABSPreheatSetting(void) {
3064 3067
             EncoderRate.encoderRateEnabled = 1;
3065 3068
             break;
3066 3069
         #endif
3067
-      case 4: // save PLA configuration
3068
-        if (settings.save()) {
3069
-          buzzer.tone(100, 659);
3070
-          buzzer.tone(100, 698);
3071
-        }
3072
-        else
3073
-          buzzer.tone(20, 440);
3074
-        break;
3070
+      case 4: { // save ABS configuration
3071
+        const bool success = settings.save();
3072
+        HMI_AudioFeedback(success);
3073
+      } break;
3075 3074
       default:
3076 3075
         break;
3077 3076
     }
@@ -3496,11 +3495,11 @@ void DWIN_HandleScreen(void) {
3496 3495
     case Move_X:                HMI_Move_X(); break;
3497 3496
     case Move_Y:                HMI_Move_Y(); break;
3498 3497
     case Move_Z:                HMI_Move_Z(); break;
3499
-    case Extruder:              HMI_Move_E(); break;
3500
-    case Homeoffset:            HMI_Zoffset(); break;
3501 3498
     #if HAS_HOTEND
3499
+      case Extruder:            HMI_Move_E(); break;
3502 3500
       case ETemp:               HMI_ETemp(); break;
3503 3501
     #endif
3502
+    case Homeoffset:            HMI_Zoffset(); break;
3504 3503
     #if HAS_HEATED_BED
3505 3504
       case BedTemp:             HMI_BedTemp(); break;
3506 3505
     #endif

+ 2
- 2
Marlin/src/lcd/dwin/dwin.h Zobrazit soubor

@@ -68,11 +68,11 @@ enum processID {
68 68
   Move_X,
69 69
   Move_Y,
70 70
   Move_Z,
71
-  Extruder,
72
-  Homeoffset,
73 71
   #if HAS_HOTEND
72
+    Extruder,
74 73
     ETemp,
75 74
   #endif
75
+  Homeoffset,
76 76
   #if HAS_HEATED_BED
77 77
     BedTemp,
78 78
   #endif

Loading…
Zrušit
Uložit