Browse Source

E3V2 DWIN live movement (#21035)

InsanityAutomation 3 years ago
parent
commit
db82a25177
No account linked to committer's email address
1 changed files with 28 additions and 50 deletions
  1. 28
    50
      Marlin/src/lcd/dwin/e3v2/dwin.cpp

+ 28
- 50
Marlin/src/lcd/dwin/e3v2/dwin.cpp View File

1212
   return state;
1212
   return state;
1213
 }
1213
 }
1214
 
1214
 
1215
+void HMI_Plan_Move(const feedRate_t fr_mm_s) {
1216
+  if (!planner.is_full()) {
1217
+    planner.synchronize();
1218
+    planner.buffer_line(current_position, fr_mm_s, active_extruder);
1219
+    DWIN_UpdateLCD();
1220
+  }
1221
+}
1222
+
1223
+void HMI_Move_Done(const AxisEnum axis) {
1224
+  EncoderRate.enabled = false;
1225
+  planner.synchronize();
1226
+  checkkey = AxisMove;
1227
+  DWIN_UpdateLCD();
1228
+}
1229
+
1215
 void HMI_Move_X() {
1230
 void HMI_Move_X() {
1216
   ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1231
   ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1217
   if (encoder_diffState != ENCODER_DIFF_NO) {
1232
   if (encoder_diffState != ENCODER_DIFF_NO) {
1218
-    if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scaled)) {
1219
-      checkkey = AxisMove;
1220
-      EncoderRate.enabled = false;
1221
-      DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scaled);
1222
-      if (!planner.is_full()) {
1223
-        // Wait for planner moves to finish!
1224
-        planner.synchronize();
1225
-        planner.buffer_line(current_position, homing_feedrate(X_AXIS), active_extruder);
1226
-      }
1227
-      DWIN_UpdateLCD();
1228
-      return;
1229
-    }
1233
+    if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scaled))
1234
+      return HMI_Move_Done(X_AXIS);
1230
     LIMIT(HMI_ValueStruct.Move_X_scaled, (X_MIN_POS) * MINUNITMULT, (X_MAX_POS) * MINUNITMULT);
1235
     LIMIT(HMI_ValueStruct.Move_X_scaled, (X_MIN_POS) * MINUNITMULT, (X_MAX_POS) * MINUNITMULT);
1231
     current_position.x = HMI_ValueStruct.Move_X_scaled / MINUNITMULT;
1236
     current_position.x = HMI_ValueStruct.Move_X_scaled / MINUNITMULT;
1232
     DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(1), HMI_ValueStruct.Move_X_scaled);
1237
     DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(1), HMI_ValueStruct.Move_X_scaled);
1233
     DWIN_UpdateLCD();
1238
     DWIN_UpdateLCD();
1239
+    HMI_Plan_Move(homing_feedrate(X_AXIS));
1234
   }
1240
   }
1235
 }
1241
 }
1236
 
1242
 
1237
 void HMI_Move_Y() {
1243
 void HMI_Move_Y() {
1238
   ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1244
   ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1239
   if (encoder_diffState != ENCODER_DIFF_NO) {
1245
   if (encoder_diffState != ENCODER_DIFF_NO) {
1240
-    if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scaled)) {
1241
-      checkkey = AxisMove;
1242
-      EncoderRate.enabled = false;
1243
-      DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scaled);
1244
-      if (!planner.is_full()) {
1245
-        // Wait for planner moves to finish!
1246
-        planner.synchronize();
1247
-        planner.buffer_line(current_position, homing_feedrate(Y_AXIS), active_extruder);
1248
-      }
1249
-      DWIN_UpdateLCD();
1250
-      return;
1251
-    }
1246
+    if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scaled))
1247
+      return HMI_Move_Done(Y_AXIS);
1252
     LIMIT(HMI_ValueStruct.Move_Y_scaled, (Y_MIN_POS) * MINUNITMULT, (Y_MAX_POS) * MINUNITMULT);
1248
     LIMIT(HMI_ValueStruct.Move_Y_scaled, (Y_MIN_POS) * MINUNITMULT, (Y_MAX_POS) * MINUNITMULT);
1253
     current_position.y = HMI_ValueStruct.Move_Y_scaled / MINUNITMULT;
1249
     current_position.y = HMI_ValueStruct.Move_Y_scaled / MINUNITMULT;
1254
     DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(2), HMI_ValueStruct.Move_Y_scaled);
1250
     DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(2), HMI_ValueStruct.Move_Y_scaled);
1255
     DWIN_UpdateLCD();
1251
     DWIN_UpdateLCD();
1252
+    HMI_Plan_Move(homing_feedrate(Y_AXIS));
1256
   }
1253
   }
1257
 }
1254
 }
1258
 
1255
 
1259
 void HMI_Move_Z() {
1256
 void HMI_Move_Z() {
1260
   ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1257
   ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1261
   if (encoder_diffState != ENCODER_DIFF_NO) {
1258
   if (encoder_diffState != ENCODER_DIFF_NO) {
1262
-    if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scaled)) {
1263
-      checkkey = AxisMove;
1264
-      EncoderRate.enabled = false;
1265
-      DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled);
1266
-      if (!planner.is_full()) {
1267
-        // Wait for planner moves to finish!
1268
-        planner.synchronize();
1269
-        planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
1270
-      }
1271
-      DWIN_UpdateLCD();
1272
-      return;
1273
-    }
1274
-    LIMIT(HMI_ValueStruct.Move_Z_scaled, Z_MIN_POS * MINUNITMULT, Z_MAX_POS * MINUNITMULT);
1259
+    if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scaled))
1260
+      return HMI_Move_Done(Z_AXIS);
1261
+    LIMIT(HMI_ValueStruct.Move_Z_scaled, (Z_MIN_POS) * MINUNITMULT, (Z_MAX_POS) * MINUNITMULT);
1275
     current_position.z = HMI_ValueStruct.Move_Z_scaled / MINUNITMULT;
1262
     current_position.z = HMI_ValueStruct.Move_Z_scaled / MINUNITMULT;
1276
     DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled);
1263
     DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled);
1277
     DWIN_UpdateLCD();
1264
     DWIN_UpdateLCD();
1265
+    HMI_Plan_Move(homing_feedrate(Z_AXIS));
1278
   }
1266
   }
1279
 }
1267
 }
1280
 
1268
 
1285
     ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1273
     ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
1286
     if (encoder_diffState != ENCODER_DIFF_NO) {
1274
     if (encoder_diffState != ENCODER_DIFF_NO) {
1287
       if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scaled)) {
1275
       if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scaled)) {
1288
-        checkkey = AxisMove;
1289
-        EncoderRate.enabled = false;
1290
         last_E_scaled = HMI_ValueStruct.Move_E_scaled;
1276
         last_E_scaled = HMI_ValueStruct.Move_E_scaled;
1291
-        DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(4), HMI_ValueStruct.Move_E_scaled);
1292
-        if (!planner.is_full()) {
1293
-          planner.synchronize(); // Wait for planner moves to finish!
1294
-          planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder);
1295
-        }
1296
-        DWIN_UpdateLCD();
1297
-        return;
1277
+        return HMI_Move_Done(E_AXIS);
1298
       }
1278
       }
1299
-      if ((HMI_ValueStruct.Move_E_scaled - last_E_scaled) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
1300
-        HMI_ValueStruct.Move_E_scaled = last_E_scaled + (EXTRUDE_MAXLENGTH) * MINUNITMULT;
1301
-      else if ((last_E_scaled - HMI_ValueStruct.Move_E_scaled) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
1302
-        HMI_ValueStruct.Move_E_scaled = last_E_scaled - (EXTRUDE_MAXLENGTH) * MINUNITMULT;
1279
+      LIMIT(HMI_ValueStruct.Move_E_scaled, last_E_scaled - (EXTRUDE_MAXLENGTH) * MINUNITMULT, last_E_scaled + (EXTRUDE_MAXLENGTH) * MINUNITMULT);
1303
       current_position.e = HMI_ValueStruct.Move_E_scaled / MINUNITMULT;
1280
       current_position.e = HMI_ValueStruct.Move_E_scaled / MINUNITMULT;
1304
       DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(4), HMI_ValueStruct.Move_E_scaled);
1281
       DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(4), HMI_ValueStruct.Move_E_scaled);
1305
       DWIN_UpdateLCD();
1282
       DWIN_UpdateLCD();
1283
+      HMI_Plan_Move(MMM_TO_MMS(FEEDRATE_E));
1306
     }
1284
     }
1307
   }
1285
   }
1308
 
1286
 

Loading…
Cancel
Save