Browse Source

Merge pull request #1521 from thinkyhead/fixup_encoder_code

Encoder multiplier - revised code
Scott Lahteine 10 years ago
parent
commit
c3c50528e6

+ 5
- 0
Marlin/Configuration_adv.h View File

284
 //=============================Additional Features===========================
284
 //=============================Additional Features===========================
285
 //===========================================================================
285
 //===========================================================================
286
 
286
 
287
+#define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
288
+#define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value
289
+#define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value
290
+//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
291
+
287
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
292
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
288
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
293
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
289
 
294
 

+ 5
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

284
 //=============================Additional Features===========================
284
 //=============================Additional Features===========================
285
 //===========================================================================
285
 //===========================================================================
286
 
286
 
287
+#define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
288
+#define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value
289
+#define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value
290
+//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
291
+
287
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
292
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
288
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
293
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
289
 
294
 

+ 5
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

284
 //=============================Additional Features===========================
284
 //=============================Additional Features===========================
285
 //===========================================================================
285
 //===========================================================================
286
 
286
 
287
+#define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
288
+#define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value
289
+#define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value
290
+//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
291
+
287
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
292
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
288
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
293
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
289
 
294
 

+ 5
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

287
 //=============================Additional Features===========================
287
 //=============================Additional Features===========================
288
 //===========================================================================
288
 //===========================================================================
289
 
289
 
290
+#define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
291
+#define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value
292
+#define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value
293
+//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
294
+
290
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
295
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
291
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
296
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
292
 
297
 

+ 5
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

284
 //=============================Additional Features===========================
284
 //=============================Additional Features===========================
285
 //===========================================================================
285
 //===========================================================================
286
 
286
 
287
+#define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
288
+#define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value
289
+#define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value
290
+//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
291
+
287
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
292
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
288
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
293
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
289
 
294
 

+ 5
- 0
Marlin/example_configurations/delta/Configuration_adv.h View File

279
 //=============================Additional Features===========================
279
 //=============================Additional Features===========================
280
 //===========================================================================
280
 //===========================================================================
281
 
281
 
282
+#define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
283
+#define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value
284
+#define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value
285
+//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
286
+
282
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
287
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
283
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
288
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
284
 
289
 

+ 5
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

283
 //=============================Additional Features===========================
283
 //=============================Additional Features===========================
284
 //===========================================================================
284
 //===========================================================================
285
 
285
 
286
+#define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
287
+#define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value
288
+#define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value
289
+//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
290
+
286
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
291
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
287
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
292
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
288
 
293
 

+ 5
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

284
 //=============================Additional Features===========================
284
 //=============================Additional Features===========================
285
 //===========================================================================
285
 //===========================================================================
286
 
286
 
287
+#define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
288
+#define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value
289
+#define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value
290
+//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
291
+
287
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
292
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
288
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
293
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
289
 
294
 

+ 95
- 27
Marlin/ultralcd.cpp View File

10
 
10
 
11
 int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
11
 int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
12
 
12
 
13
+bool encoderRateMultiplierEnabled;
14
+int32_t lastEncoderMovementMillis;
15
+
13
 /* Configuration settings */
16
 /* Configuration settings */
14
 int plaPreheatHotendTemp;
17
 int plaPreheatHotendTemp;
15
 int plaPreheatHPBTemp;
18
 int plaPreheatHPBTemp;
114
 
117
 
115
 /* Helper macros for menus */
118
 /* Helper macros for menus */
116
 #define START_MENU() do { \
119
 #define START_MENU() do { \
120
+	encoderRateMultiplierEnabled = false; \
117
     if (encoderPosition > 0x8000) encoderPosition = 0; \
121
     if (encoderPosition > 0x8000) encoderPosition = 0; \
118
     if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
122
     if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
119
     uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
123
     uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
138
     }\
142
     }\
139
     _menuItemNr++;\
143
     _menuItemNr++;\
140
 } while(0)
144
 } while(0)
145
+#ifdef ENCODER_RATE_MULTIPLIER
146
+  #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
147
+    if (_menuItemNr == _lineNr) { \
148
+      if (lcdDrawUpdate) { \
149
+        const char* _label_pstr = PSTR(label); \
150
+        if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
151
+          lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \
152
+        } \
153
+        else { \
154
+          lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \
155
+        } \
156
+      } \
157
+      if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
158
+        lcd_quick_feedback(); \
159
+        encoderRateMultiplierEnabled = true; \
160
+        lastEncoderMovementMillis = 0; \
161
+        menu_action_ ## type ( args ); \
162
+        return; \
163
+      } \
164
+    } \
165
+    _menuItemNr++; \
166
+  } while(0)
167
+#endif //ENCODER_RATE_MULTIPLIER
141
 #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
168
 #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
142
 #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 )
143
 #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
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
144
 #define END_MENU() \
178
 #define END_MENU() \
145
     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; \
146
     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; } \
199
 /* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
233
 /* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
200
 static void lcd_status_screen()
234
 static void lcd_status_screen()
201
 {
235
 {
236
+	encoderRateMultiplierEnabled = false;
202
   #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
237
   #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
203
     uint16_t mil = millis();
238
     uint16_t mil = millis();
204
     #ifndef PROGRESS_MSG_ONCE
239
     #ifndef PROGRESS_MSG_ONCE
417
     MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
452
     MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
418
     MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999);
453
     MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999);
419
 #if TEMP_SENSOR_0 != 0
454
 #if TEMP_SENSOR_0 != 0
420
-    MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
455
+    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
421
 #endif
456
 #endif
422
 #if TEMP_SENSOR_1 != 0
457
 #if TEMP_SENSOR_1 != 0
423
-    MENU_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
458
+    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
424
 #endif
459
 #endif
425
 #if TEMP_SENSOR_2 != 0
460
 #if TEMP_SENSOR_2 != 0
426
-    MENU_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
461
+    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
427
 #endif
462
 #endif
428
 #if TEMP_SENSOR_3 != 0
463
 #if TEMP_SENSOR_3 != 0
429
-    MENU_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
464
+    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
430
 #endif
465
 #endif
431
 
466
 
432
 
467
 
433
 #if TEMP_SENSOR_BED != 0
468
 #if TEMP_SENSOR_BED != 0
434
-    MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
469
+    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
435
 #endif
470
 #endif
436
-    MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
471
+    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
437
     MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
472
     MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
438
     MENU_ITEM_EDIT(int3, MSG_FLOW " 0", &extruder_multiply[0], 10, 999);
473
     MENU_ITEM_EDIT(int3, MSG_FLOW " 0", &extruder_multiply[0], 10, 999);
439
 #if TEMP_SENSOR_1 != 0
474
 #if TEMP_SENSOR_1 != 0
610
   MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
645
   MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
611
   MENU_ITEM(function, MSG_PREHEAT_ABS_N "1", lcd_preheat_abs0);
646
   MENU_ITEM(function, MSG_PREHEAT_ABS_N "1", lcd_preheat_abs0);
612
 #if TEMP_SENSOR_1 != 0 //2 extruder preheat
647
 #if TEMP_SENSOR_1 != 0 //2 extruder preheat
613
-	MENU_ITEM(function, MSG_PREHEAT_ABS_N "2", lcd_preheat_abs1);
648
+    MENU_ITEM(function, MSG_PREHEAT_ABS_N "2", lcd_preheat_abs1);
614
 #endif //2 extruder preheat
649
 #endif //2 extruder preheat
615
 #if TEMP_SENSOR_2 != 0 //3 extruder preheat
650
 #if TEMP_SENSOR_2 != 0 //3 extruder preheat
616
   MENU_ITEM(function, MSG_PREHEAT_ABS_N "3", lcd_preheat_abs2);
651
   MENU_ITEM(function, MSG_PREHEAT_ABS_N "3", lcd_preheat_abs2);
828
         void copy_and_scalePID_d_E3() { copy_and_scalePID_d(2); }
863
         void copy_and_scalePID_d_E3() { copy_and_scalePID_d(2); }
829
         #if EXTRUDERS > 3
864
         #if EXTRUDERS > 3
830
           void copy_and_scalePID_i_E4() { copy_and_scalePID_i(3); }
865
           void copy_and_scalePID_i_E4() { copy_and_scalePID_i(3); }
831
-          void copy_and_scalePID_d_E5() { copy_and_scalePID_d(3); }
866
+          void copy_and_scalePID_d_E4() { copy_and_scalePID_d(3); }
832
         #endif //EXTRUDERS > 3
867
         #endif //EXTRUDERS > 3
833
       #endif //EXTRUDERS > 2
868
       #endif //EXTRUDERS > 2
834
     #endif //EXTRUDERS > 1
869
     #endif //EXTRUDERS > 1
841
   START_MENU();
876
   START_MENU();
842
   MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
877
   MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
843
   #if TEMP_SENSOR_0 != 0
878
   #if TEMP_SENSOR_0 != 0
844
-    MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
879
+    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
845
   #endif
880
   #endif
846
   #if EXTRUDERS > 1
881
   #if EXTRUDERS > 1
847
     #if TEMP_SENSOR_1 != 0
882
     #if TEMP_SENSOR_1 != 0
848
-      MENU_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
883
+      MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
849
     #endif
884
     #endif
850
     #if EXTRUDERS > 2
885
     #if EXTRUDERS > 2
851
       #if TEMP_SENSOR_2 != 0
886
       #if TEMP_SENSOR_2 != 0
852
-        MENU_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
887
+        MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
853
       #endif
888
       #endif
854
-      #if EXTRUDERS > 2
889
+      #if EXTRUDERS > 3
855
         #if TEMP_SENSOR_3 != 0
890
         #if TEMP_SENSOR_3 != 0
856
-          MENU_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
891
+          MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
857
         #endif
892
         #endif
858
       #endif
893
       #endif
859
     #endif
894
     #endif
860
   #endif
895
   #endif
861
   #if TEMP_SENSOR_BED != 0
896
   #if TEMP_SENSOR_BED != 0
862
-    MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
897
+    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
863
   #endif
898
   #endif
864
-  MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
865
-  #if defined AUTOTEMP && (TEMP_SENSOR_0 != 0)
899
+  MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
900
+  #if defined(AUTOTEMP) && (TEMP_SENSOR_0 != 0)
866
     MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled);
901
     MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled);
867
     MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15);
902
     MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15);
868
     MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP - 15);
903
     MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP - 15);
1003
 	MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
1038
 	MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
1004
 
1039
 
1005
 	if (volumetric_enabled) {
1040
 	if (volumetric_enabled) {
1006
-		MENU_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_0, &filament_size[0], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers);
1007
-#if EXTRUDERS > 1
1008
-		MENU_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_1, &filament_size[1], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers);
1009
-#if EXTRUDERS > 2
1010
-		MENU_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_2, &filament_size[2], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers);
1011
-#if EXTRUDERS > 3
1012
-		MENU_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_3, &filament_size[3], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers);
1013
-#endif //EXTRUDERS > 3
1014
-#endif //EXTRUDERS > 2
1015
-#endif //EXTRUDERS > 1
1041
+    MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_0, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers);
1042
+    #if EXTRUDERS > 1
1043
+      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_1, &filament_size[1], 1.5, 3.25, calculate_volumetric_multipliers);
1044
+      #if EXTRUDERS > 2
1045
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_2, &filament_size[2], 1.5, 3.25, calculate_volumetric_multipliers);
1046
+        #if EXTRUDERS > 3
1047
+          MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_3, &filament_size[3], 1.5, 3.25, calculate_volumetric_multipliers);
1048
+        #endif //EXTRUDERS > 3
1049
+      #endif //EXTRUDERS > 2
1050
+    #endif //EXTRUDERS > 1
1016
 	}
1051
 	}
1017
 
1052
 
1018
 	END_MENU();
1053
 	END_MENU();
1384
 		#endif
1419
 		#endif
1385
         if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP)
1420
         if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP)
1386
         {
1421
         {
1422
+      int32_t encoderMultiplier = 1;
1423
+
1424
+  #ifdef ENCODER_RATE_MULTIPLIER
1425
+
1426
+    if (encoderRateMultiplierEnabled) {
1427
+      int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
1428
+
1429
+      if (lastEncoderMovementMillis != 0) {
1430
+        // Note that the rate is always calculated between to passes through the 
1431
+        // loop and that the abs of the encoderDiff value is tracked.
1432
+        float encoderStepRate =
1433
+          (float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0;
1434
+
1435
+        if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC)     encoderMultiplier = 100;
1436
+        else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
1437
+
1438
+        #ifdef ENCODER_RATE_MULTIPLIER_DEBUG
1439
+          SERIAL_ECHO_START;
1440
+          SERIAL_ECHO("Enc Step Rate: ");
1441
+          SERIAL_ECHO(encoderStepRate);
1442
+          SERIAL_ECHO("  Multiplier: ");
1443
+          SERIAL_ECHO(encoderMultiplier);
1444
+          SERIAL_ECHO("  ENCODER_10X_STEPS_PER_SEC: ");
1445
+          SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC);
1446
+          SERIAL_ECHO("  ENCODER_100X_STEPS_PER_SEC: ");
1447
+          SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC);
1448
+        #endif //ENCODER_RATE_MULTIPLIER_DEBUG
1449
+      }
1450
+
1451
+      lastEncoderMovementMillis = millis();
1452
+    }
1453
+  #endif //ENCODER_RATE_MULTIPLIER
1454
+
1387
             lcdDrawUpdate = 1;
1455
             lcdDrawUpdate = 1;
1388
-            encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP;
1456
+            encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
1389
             encoderDiff = 0;
1457
             encoderDiff = 0;
1390
             timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
1458
             timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
1391
         }
1459
         }

Loading…
Cancel
Save