Browse Source

More bits when encoderPosition is cast as signed

Scott Lahteine 8 years ago
parent
commit
8198cc30b5
1 changed files with 11 additions and 11 deletions
  1. 11
    11
      Marlin/ultralcd.cpp

+ 11
- 11
Marlin/ultralcd.cpp View File

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

Loading…
Cancel
Save