Browse Source

Prep formatting for upcoming PR

Scott Lahteine 9 years ago
parent
commit
422582da71
1 changed files with 28 additions and 34 deletions
  1. 28
    34
      Marlin/ultralcd.cpp

+ 28
- 34
Marlin/ultralcd.cpp View File

143
     _menuItemNr++;\
143
     _menuItemNr++;\
144
 } while(0)
144
 } while(0)
145
 #ifdef ENCODER_RATE_MULTIPLIER
145
 #ifdef ENCODER_RATE_MULTIPLIER
146
-#define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
146
+  #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
147
     if (_menuItemNr == _lineNr) { \
147
     if (_menuItemNr == _lineNr) { \
148
       if (lcdDrawUpdate) { \
148
       if (lcdDrawUpdate) { \
149
         const char* _label_pstr = PSTR(label); \
149
         const char* _label_pstr = PSTR(label); \
163
       } \
163
       } \
164
     } \
164
     } \
165
     _menuItemNr++; \
165
     _menuItemNr++; \
166
-} while(0)
167
-#endif
166
+  } while(0)
167
+#endif //ENCODER_RATE_MULTIPLIER
168
 #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
168
 #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
169
 #define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
169
 #define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
170
 #define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
170
 #define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
171
 #ifdef ENCODER_RATE_MULTIPLIER
171
 #ifdef ENCODER_RATE_MULTIPLIER
172
-#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
173
-#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
174
-#else
175
-#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
176
-#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
177
-#endif
172
+  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
173
+  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
174
+#else //!ENCODER_RATE_MULTIPLIER
175
+  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
176
+  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
177
+#endif //!ENCODER_RATE_MULTIPLIER
178
 #define END_MENU() \
178
 #define END_MENU() \
179
     if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
179
     if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
180
     if ((uint8_t)(encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
180
     if ((uint8_t)(encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
1422
         {
1422
         {
1423
       int32_t encoderMultiplier = 1;
1423
       int32_t encoderMultiplier = 1;
1424
 
1424
 
1425
-#ifdef ENCODER_RATE_MULTIPLIER
1426
-      if (encoderRateMultiplierEnabled)
1427
-      {
1428
-        int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
1425
+  #ifdef ENCODER_RATE_MULTIPLIER
1429
 
1426
 
1430
-        if (lastEncoderMovementMillis != 0)
1431
-        {
1432
-          // Note that the rate is always calculated between to passes through the 
1433
-          // loop and that the abs of the encoderDiff value is tracked.
1434
-          float encoderStepRate =
1435
-            (float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0;
1436
-
1437
-          if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC)
1438
-          {
1439
-            encoderMultiplier = 100;
1440
-          }
1441
-          else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC)
1442
-          {
1443
-            encoderMultiplier = 10;
1444
-          }
1427
+    if (encoderRateMultiplierEnabled) {
1428
+      int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
1429
+
1430
+      if (lastEncoderMovementMillis != 0) {
1431
+        // Note that the rate is always calculated between to passes through the 
1432
+        // loop and that the abs of the encoderDiff value is tracked.
1433
+        float encoderStepRate =
1434
+          (float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0;
1445
 
1435
 
1446
-#ifdef ENCODER_RATE_MULTIPLIER_DEBUG
1436
+        if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC)     encoderMultiplier = 100;
1437
+        else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
1438
+
1439
+        #ifdef ENCODER_RATE_MULTIPLIER_DEBUG
1447
           SERIAL_ECHO_START;
1440
           SERIAL_ECHO_START;
1448
           SERIAL_ECHO("Enc Step Rate: ");
1441
           SERIAL_ECHO("Enc Step Rate: ");
1449
           SERIAL_ECHO(encoderStepRate);
1442
           SERIAL_ECHO(encoderStepRate);
1453
           SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC);
1446
           SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC);
1454
           SERIAL_ECHO("  ENCODER_100X_STEPS_PER_SEC: ");
1447
           SERIAL_ECHO("  ENCODER_100X_STEPS_PER_SEC: ");
1455
           SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC);
1448
           SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC);
1456
-#endif
1457
-        }
1458
-
1459
-        lastEncoderMovementMillis = millis();
1449
+        #endif //ENCODER_RATE_MULTIPLIER_DEBUG
1460
       }
1450
       }
1461
-#endif
1451
+
1452
+      lastEncoderMovementMillis = millis();
1453
+    }
1454
+  #endif //ENCODER_RATE_MULTIPLIER
1455
+
1462
             lcdDrawUpdate = 1;
1456
             lcdDrawUpdate = 1;
1463
             encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
1457
             encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
1464
             encoderDiff = 0;
1458
             encoderDiff = 0;

Loading…
Cancel
Save