Sfoglia il codice sorgente

Merge pull request #3437 from thinkyhead/rc_lcd_encoder_movement

More bits when encoderPosition is cast as signed
Scott Lahteine 8 anni fa
parent
commit
3a1ac14bbc
1 ha cambiato i file con 11 aggiunte e 11 eliminazioni
  1. 11
    11
      Marlin/ultralcd.cpp

+ 11
- 11
Marlin/ultralcd.cpp Vedi File

@@ -432,19 +432,19 @@ static void lcd_status_screen() {
432 432
     }
433 433
 
434 434
     #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
435
-      int new_frm = feedrate_multiplier + int(encoderPosition);
435
+      int new_frm = feedrate_multiplier + (int32_t)encoderPosition;
436 436
       // Dead zone at 100% feedrate
437 437
       if ((feedrate_multiplier < 100 && new_frm > 100) || (feedrate_multiplier > 100 && new_frm < 100)) {
438 438
         feedrate_multiplier = 100;
439 439
         encoderPosition = 0;
440 440
       }
441 441
       else if (feedrate_multiplier == 100) {
442
-        if (int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) {
443
-          feedrate_multiplier += int(encoderPosition) - (ENCODER_FEEDRATE_DEADZONE);
442
+        if ((int32_t)encoderPosition > ENCODER_FEEDRATE_DEADZONE) {
443
+          feedrate_multiplier += (int32_t)encoderPosition - (ENCODER_FEEDRATE_DEADZONE);
444 444
           encoderPosition = 0;
445 445
         }
446
-        else if (int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE) {
447
-          feedrate_multiplier += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
446
+        else if ((int32_t)encoderPosition < -(ENCODER_FEEDRATE_DEADZONE)) {
447
+          feedrate_multiplier += (int32_t)encoderPosition + ENCODER_FEEDRATE_DEADZONE;
448 448
           encoderPosition = 0;
449 449
         }
450 450
       }
@@ -554,7 +554,7 @@ void lcd_set_home_offsets() {
554 554
   static void _lcd_babystep(const int axis, const char* msg) {
555 555
     ENCODER_DIRECTION_NORMAL();
556 556
     if (encoderPosition) {
557
-      int distance =  (int)encoderPosition * BABYSTEP_MULTIPLICATOR;
557
+      int distance =  (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
558 558
       encoderPosition = 0;
559 559
       lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW;
560 560
       #if ENABLED(COREXY) || ENABLED(COREXZ)
@@ -903,7 +903,7 @@ void lcd_cooldown() {
903 903
     // Encoder wheel adjusts the Z position
904 904
     if (encoderPosition && movesplanned() <= 3) {
905 905
       refresh_cmd_timeout();
906
-      current_position[Z_AXIS] += float((int)encoderPosition) * (MBL_Z_STEP);
906
+      current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
907 907
       if (min_software_endstops) NOLESS(current_position[Z_AXIS], Z_MIN_POS);
908 908
       if (max_software_endstops) NOMORE(current_position[Z_AXIS], Z_MAX_POS);
909 909
       encoderPosition = 0;
@@ -1126,7 +1126,7 @@ static void _lcd_move(const char* name, AxisEnum axis, float min, float max) {
1126 1126
   ENCODER_DIRECTION_NORMAL();
1127 1127
   if (encoderPosition && movesplanned() <= 3) {
1128 1128
     refresh_cmd_timeout();
1129
-    current_position[axis] += float((int)encoderPosition) * move_menu_scale;
1129
+    current_position[axis] += float((int32_t)encoderPosition) * move_menu_scale;
1130 1130
     if (min_software_endstops) NOLESS(current_position[axis], min);
1131 1131
     if (max_software_endstops) NOMORE(current_position[axis], max);
1132 1132
     encoderPosition = 0;
@@ -1157,7 +1157,7 @@ static void lcd_move_e(
1157 1157
     active_extruder = e;
1158 1158
   #endif
1159 1159
   if (encoderPosition && movesplanned() <= 3) {
1160
-    current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale;
1160
+    current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1161 1161
     encoderPosition = 0;
1162 1162
     line_to_current(E_AXIS);
1163 1163
     lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW;
@@ -2345,7 +2345,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
2345 2345
       #if ENABLED(RIGIDBOT_PANEL)
2346 2346
         if (ELAPSED(now, next_button_update_ms)) {
2347 2347
           if (BUTTON_PRESSED(UP)) {
2348
-            encoderDiff = -1 * (ENCODER_STEPS_PER_MENU_ITEM);
2348
+            encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM);
2349 2349
             next_button_update_ms = now + 300;
2350 2350
           }
2351 2351
           else if (BUTTON_PRESSED(DWN)) {
@@ -2353,7 +2353,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
2353 2353
             next_button_update_ms = now + 300;
2354 2354
           }
2355 2355
           else if (BUTTON_PRESSED(LFT)) {
2356
-            encoderDiff = -1 * (ENCODER_PULSES_PER_STEP);
2356
+            encoderDiff = -(ENCODER_PULSES_PER_STEP);
2357 2357
             next_button_update_ms = now + 300;
2358 2358
           }
2359 2359
           else if (BUTTON_PRESSED(RT)) {

Loading…
Annulla
Salva