|
@@ -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
|
|
@@ -412,21 +447,21 @@ static void lcd_tune_menu() {
|
412
|
447
|
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
|
413
|
448
|
MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999);
|
414
|
449
|
#if TEMP_SENSOR_0 != 0
|
415
|
|
- MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
|
|
450
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
|
416
|
451
|
#endif
|
417
|
452
|
#if TEMP_SENSOR_1 != 0
|
418
|
|
- MENU_ITEM_EDIT(int3, MSG_NOZZLE MSG_N2, &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
|
|
453
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N2, &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
|
419
|
454
|
#endif
|
420
|
455
|
#if TEMP_SENSOR_2 != 0
|
421
|
|
- MENU_ITEM_EDIT(int3, MSG_NOZZLE MSG_N3, &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
|
|
456
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N3, &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
|
422
|
457
|
#endif
|
423
|
458
|
#if TEMP_SENSOR_3 != 0
|
424
|
|
- MENU_ITEM_EDIT(int3, MSG_NOZZLE MSG_N4, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
|
|
459
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N4, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
|
425
|
460
|
#endif
|
426
|
461
|
#if TEMP_SENSOR_BED != 0
|
427
|
|
- MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
|
|
462
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
|
428
|
463
|
#endif
|
429
|
|
- MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
|
|
464
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
|
430
|
465
|
MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
|
431
|
466
|
MENU_ITEM_EDIT(int3, MSG_FLOW MSG_F0, &extruder_multiply[0], 10, 999);
|
432
|
467
|
#if TEMP_SENSOR_1 != 0
|
|
@@ -725,7 +760,7 @@ static void lcd_control_menu() {
|
725
|
760
|
void copy_and_scalePID_d_E3() { copy_and_scalePID_d(2); }
|
726
|
761
|
#if EXTRUDERS > 3
|
727
|
762
|
void copy_and_scalePID_i_E4() { copy_and_scalePID_i(3); }
|
728
|
|
- void copy_and_scalePID_d_E5() { copy_and_scalePID_d(3); }
|
|
763
|
+ void copy_and_scalePID_d_E4() { copy_and_scalePID_d(3); }
|
729
|
764
|
#endif //EXTRUDERS > 3
|
730
|
765
|
#endif //EXTRUDERS > 2
|
731
|
766
|
#endif //EXTRUDERS > 1
|
|
@@ -737,27 +772,27 @@ static void lcd_control_temperature_menu() {
|
737
|
772
|
START_MENU();
|
738
|
773
|
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
|
739
|
774
|
#if TEMP_SENSOR_0 != 0
|
740
|
|
- MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
|
|
775
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
|
741
|
776
|
#endif
|
742
|
777
|
#if EXTRUDERS > 1
|
743
|
778
|
#if TEMP_SENSOR_1 != 0
|
744
|
|
- MENU_ITEM_EDIT(int3, MSG_NOZZLE MSG_N2, &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
|
|
779
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N2, &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
|
745
|
780
|
#endif
|
746
|
781
|
#if EXTRUDERS > 2
|
747
|
782
|
#if TEMP_SENSOR_2 != 0
|
748
|
|
- MENU_ITEM_EDIT(int3, MSG_NOZZLE MSG_N3, &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
|
|
783
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N3, &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
|
749
|
784
|
#endif
|
750
|
785
|
#if EXTRUDERS > 3
|
751
|
786
|
#if TEMP_SENSOR_3 != 0
|
752
|
|
- MENU_ITEM_EDIT(int3, MSG_NOZZLE MSG_N4, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
|
|
787
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N4, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
|
753
|
788
|
#endif
|
754
|
|
- #endif
|
755
|
|
- #endif
|
756
|
|
- #endif
|
|
789
|
+ #endif // EXTRUDERS > 3
|
|
790
|
+ #endif // EXTRUDERS > 2
|
|
791
|
+ #endif // EXTRUDERS > 1
|
757
|
792
|
#if TEMP_SENSOR_BED != 0
|
758
|
|
- MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
|
|
793
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
|
759
|
794
|
#endif
|
760
|
|
- MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
|
|
795
|
+ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
|
761
|
796
|
#if defined(AUTOTEMP) && (TEMP_SENSOR_0 != 0)
|
762
|
797
|
MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled);
|
763
|
798
|
MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15);
|
|
@@ -888,21 +923,20 @@ static void lcd_control_motion_menu() {
|
888
|
923
|
END_MENU();
|
889
|
924
|
}
|
890
|
925
|
|
891
|
|
-static void lcd_control_volumetric_menu()
|
892
|
|
-{
|
|
926
|
+static void lcd_control_volumetric_menu() {
|
893
|
927
|
START_MENU();
|
894
|
928
|
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
|
895
|
929
|
|
896
|
930
|
MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
|
897
|
931
|
|
898
|
932
|
if (volumetric_enabled) {
|
899
|
|
- 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);
|
|
933
|
+ MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_0, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers);
|
900
|
934
|
#if EXTRUDERS > 1
|
901
|
|
- 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);
|
|
935
|
+ MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_1, &filament_size[1], 1.5, 3.25, calculate_volumetric_multipliers);
|
902
|
936
|
#if EXTRUDERS > 2
|
903
|
|
- 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);
|
|
937
|
+ MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_2, &filament_size[2], 1.5, 3.25, calculate_volumetric_multipliers);
|
904
|
938
|
#if EXTRUDERS > 3
|
905
|
|
- 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);
|
|
939
|
+ MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_3, &filament_size[3], 1.5, 3.25, calculate_volumetric_multipliers);
|
906
|
940
|
#endif //EXTRUDERS > 3
|
907
|
941
|
#endif //EXTRUDERS > 2
|
908
|
942
|
#endif //EXTRUDERS > 1
|
|
@@ -1217,11 +1251,12 @@ void lcd_update() {
|
1217
|
1251
|
}
|
1218
|
1252
|
#endif//CARDINSERTED
|
1219
|
1253
|
|
1220
|
|
- if (millis() > lcd_next_update_millis) {
|
|
1254
|
+ long ms = millis();
|
|
1255
|
+ if (ms > lcd_next_update_millis) {
|
1221
|
1256
|
|
1222
|
1257
|
#ifdef ULTIPANEL
|
1223
|
1258
|
|
1224
|
|
- #ifdef REPRAPWORLD_KEYPAD
|
|
1259
|
+ #ifdef REPRAPWORLD_KEYPAD
|
1225
|
1260
|
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up();
|
1226
|
1261
|
if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) reprapworld_keypad_move_z_down();
|
1227
|
1262
|
if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) reprapworld_keypad_move_x_left();
|
|
@@ -1229,16 +1264,48 @@ void lcd_update() {
|
1229
|
1264
|
if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) reprapworld_keypad_move_y_down();
|
1230
|
1265
|
if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) reprapworld_keypad_move_y_up();
|
1231
|
1266
|
if (REPRAPWORLD_KEYPAD_MOVE_HOME) reprapworld_keypad_move_home();
|
1232
|
|
- #endif
|
|
1267
|
+ #endif
|
1233
|
1268
|
|
1234
|
1269
|
bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
|
1235
|
1270
|
if (encoderPastThreshold || LCD_CLICKED) {
|
1236
|
1271
|
if (encoderPastThreshold) {
|
|
1272
|
+ int32_t encoderMultiplier = 1;
|
|
1273
|
+
|
|
1274
|
+ #ifdef ENCODER_RATE_MULTIPLIER
|
|
1275
|
+
|
|
1276
|
+ if (encoderRateMultiplierEnabled) {
|
|
1277
|
+ int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
|
|
1278
|
+
|
|
1279
|
+ if (lastEncoderMovementMillis != 0) {
|
|
1280
|
+ // Note that the rate is always calculated between to passes through the
|
|
1281
|
+ // loop and that the abs of the encoderDiff value is tracked.
|
|
1282
|
+ float encoderStepRate = (float)(encoderMovementSteps) / ((float)(ms - lastEncoderMovementMillis)) * 1000.0;
|
|
1283
|
+
|
|
1284
|
+ if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
|
|
1285
|
+ else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
|
|
1286
|
+
|
|
1287
|
+ #ifdef ENCODER_RATE_MULTIPLIER_DEBUG
|
|
1288
|
+ SERIAL_ECHO_START;
|
|
1289
|
+ SERIAL_ECHO("Enc Step Rate: ");
|
|
1290
|
+ SERIAL_ECHO(encoderStepRate);
|
|
1291
|
+ SERIAL_ECHO(" Multiplier: ");
|
|
1292
|
+ SERIAL_ECHO(encoderMultiplier);
|
|
1293
|
+ SERIAL_ECHO(" ENCODER_10X_STEPS_PER_SEC: ");
|
|
1294
|
+ SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC);
|
|
1295
|
+ SERIAL_ECHO(" ENCODER_100X_STEPS_PER_SEC: ");
|
|
1296
|
+ SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC);
|
|
1297
|
+ #endif //ENCODER_RATE_MULTIPLIER_DEBUG
|
|
1298
|
+ }
|
|
1299
|
+
|
|
1300
|
+ lastEncoderMovementMillis = ms;
|
|
1301
|
+ }
|
|
1302
|
+ #endif //ENCODER_RATE_MULTIPLIER
|
|
1303
|
+
|
1237
|
1304
|
lcdDrawUpdate = 1;
|
1238
|
|
- encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP;
|
|
1305
|
+ encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
|
1239
|
1306
|
encoderDiff = 0;
|
1240
|
1307
|
}
|
1241
|
|
- timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
|
|
1308
|
+ timeoutToStatus = ms + LCD_TIMEOUT_TO_STATUS;
|
1242
|
1309
|
}
|
1243
|
1310
|
|
1244
|
1311
|
#endif //ULTIPANEL
|