|
@@ -10,6 +10,9 @@
|
10
|
10
|
|
11
|
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
|
16
|
/* Configuration settings */
|
14
|
17
|
int plaPreheatHotendTemp;
|
15
|
18
|
int plaPreheatHPBTemp;
|
|
@@ -114,6 +117,7 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
|
114
|
117
|
|
115
|
118
|
/* Helper macros for menus */
|
116
|
119
|
#define START_MENU() do { \
|
|
120
|
+ encoderRateMultiplierEnabled = false; \
|
117
|
121
|
if (encoderPosition > 0x8000) encoderPosition = 0; \
|
118
|
122
|
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
|
119
|
123
|
uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
|
|
@@ -138,9 +142,39 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
|
138
|
142
|
}\
|
139
|
143
|
_menuItemNr++;\
|
140
|
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
|
168
|
#define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
|
142
|
169
|
#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
|
143
|
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
|
178
|
#define END_MENU() \
|
145
|
179
|
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
|
146
|
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,6 +233,7 @@ static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder=0, const bool
|
199
|
233
|
/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
|
200
|
234
|
static void lcd_status_screen()
|
201
|
235
|
{
|
|
236
|
+ encoderRateMultiplierEnabled = false;
|
202
|
237
|
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
|
203
|
238
|
uint16_t mil = millis();
|
204
|
239
|
#ifndef PROGRESS_MSG_ONCE
|
|
@@ -417,23 +452,23 @@ static void lcd_tune_menu()
|
417
|
452
|
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
|
418
|
453
|
MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999);
|
419
|
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
|
456
|
#endif
|
422
|
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
|
459
|
#endif
|
425
|
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
|
462
|
#endif
|
428
|
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
|
465
|
#endif
|
431
|
466
|
|
432
|
467
|
|
433
|
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
|
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
|
472
|
MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
|
438
|
473
|
MENU_ITEM_EDIT(int3, MSG_FLOW " 0", &extruder_multiply[0], 10, 999);
|
439
|
474
|
#if TEMP_SENSOR_1 != 0
|
|
@@ -610,7 +645,7 @@ static void lcd_preheat_abs_menu()
|
610
|
645
|
MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
|
611
|
646
|
MENU_ITEM(function, MSG_PREHEAT_ABS_N "1", lcd_preheat_abs0);
|
612
|
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
|
649
|
#endif //2 extruder preheat
|
615
|
650
|
#if TEMP_SENSOR_2 != 0 //3 extruder preheat
|
616
|
651
|
MENU_ITEM(function, MSG_PREHEAT_ABS_N "3", lcd_preheat_abs2);
|
|
@@ -828,7 +863,7 @@ static void lcd_control_menu()
|
828
|
863
|
void copy_and_scalePID_d_E3() { copy_and_scalePID_d(2); }
|
829
|
864
|
#if EXTRUDERS > 3
|
830
|
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
|
867
|
#endif //EXTRUDERS > 3
|
833
|
868
|
#endif //EXTRUDERS > 2
|
834
|
869
|
#endif //EXTRUDERS > 1
|
|
@@ -841,28 +876,28 @@ static void lcd_control_temperature_menu()
|
841
|
876
|
START_MENU();
|
842
|
877
|
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
|
843
|
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
|
880
|
#endif
|
846
|
881
|
#if EXTRUDERS > 1
|
847
|
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
|
884
|
#endif
|
850
|
885
|
#if EXTRUDERS > 2
|
851
|
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
|
888
|
#endif
|
854
|
|
- #if EXTRUDERS > 2
|
|
889
|
+ #if EXTRUDERS > 3
|
855
|
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
|
892
|
#endif
|
858
|
893
|
#endif
|
859
|
894
|
#endif
|
860
|
895
|
#endif
|
861
|
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
|
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
|
901
|
MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled);
|
867
|
902
|
MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15);
|
868
|
903
|
MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP - 15);
|
|
@@ -1003,16 +1038,16 @@ static void lcd_control_volumetric_menu()
|
1003
|
1038
|
MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
|
1004
|
1039
|
|
1005
|
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
|
1053
|
END_MENU();
|
|
@@ -1384,8 +1419,41 @@ void lcd_update()
|
1384
|
1419
|
#endif
|
1385
|
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
|
1455
|
lcdDrawUpdate = 1;
|
1388
|
|
- encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP;
|
|
1456
|
+ encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
|
1389
|
1457
|
encoderDiff = 0;
|
1390
|
1458
|
timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
|
1391
|
1459
|
}
|