Browse Source

Merge pull request #1984 from thinkyhead/leveling_menu_items

Level Bed in Prepare submenu
Scott Lahteine 9 years ago
parent
commit
ed988e39a8

+ 0
- 1
Marlin/Configuration_adv.h View File

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

+ 0
- 1
Marlin/configurator/config/Configuration_adv.h View File

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

+ 1
- 0
Marlin/dogm_lcd_implementation.h View File

@@ -172,6 +172,7 @@ char lcd_printPGM(const char* str) {
172 172
 
173 173
 static bool show_splashscreen = true;
174 174
 
175
+/* Warning: This function is called from interrupt context */
175 176
 static void lcd_implementation_init() {
176 177
 
177 178
   #ifdef LCD_PIN_BL // Enable LCD backlight

+ 0
- 1
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

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

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

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

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

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

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

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

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

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

@@ -259,7 +259,6 @@
259 259
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
260 260
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
261 261
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
262
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
263 262
 
264 263
 //#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/
265 264
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

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

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

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

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

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

@@ -258,7 +258,6 @@
258 258
 #define ENCODER_RATE_MULTIPLIER         // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
259 259
 #define ENCODER_10X_STEPS_PER_SEC 75    // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
260 260
 #define ENCODER_100X_STEPS_PER_SEC 160  // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
261
-//#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
262 261
 
263 262
 //#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/
264 263
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again

+ 305
- 114
Marlin/ultralcd.cpp View File

@@ -173,6 +173,9 @@ static void lcd_status_screen();
173 173
   } while(0)
174 174
 
175 175
   #ifdef ENCODER_RATE_MULTIPLIER
176
+
177
+    //#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
178
+
176 179
     /**
177 180
      * MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item
178 181
      */
@@ -246,6 +249,9 @@ menuFunc_t callbackFunc;
246 249
 // place-holders for Ki and Kd edits
247 250
 float raw_Ki, raw_Kd;
248 251
 
252
+/**
253
+ * General function to go directly to a menu
254
+ */
249 255
 static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint32_t encoder=0) {
250 256
   if (currentMenu != menu) {
251 257
     currentMenu = menu;
@@ -260,7 +266,13 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint
260 266
   }
261 267
 }
262 268
 
263
-/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
269
+/**
270
+ *
271
+ * "Info Screen"
272
+ *
273
+ * This is very display-dependent, so the lcd implementation draws this.
274
+ */
275
+
264 276
 static void lcd_status_screen() {
265 277
 	encoderRateMultiplierEnabled = false;
266 278
 
@@ -371,7 +383,12 @@ static void lcd_sdcard_stop() {
371 383
   lcd_setstatus(MSG_PRINT_ABORTED, true);
372 384
 }
373 385
 
374
-/* Menu implementation */
386
+/**
387
+ *
388
+ * "Main" menu
389
+ *
390
+ */
391
+
375 392
 static void lcd_main_menu() {
376 393
   START_MENU();
377 394
   MENU_ITEM(back, MSG_WATCH, lcd_status_screen);
@@ -453,6 +470,12 @@ void lcd_set_home_offsets() {
453 470
 
454 471
 #endif //BABYSTEPPING
455 472
 
473
+/**
474
+ *
475
+ * "Tune" submenu
476
+ *
477
+ */
478
+
456 479
 static void lcd_tune_menu() {
457 480
   START_MENU();
458 481
   MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
@@ -594,17 +617,55 @@ void lcd_cooldown() {
594 617
   lcd_return_to_status();
595 618
 }
596 619
 
620
+/**
621
+ *
622
+ * "Prepare" submenu
623
+ *
624
+ */
625
+
597 626
 static void lcd_prepare_menu() {
598 627
   START_MENU();
628
+
629
+  //
630
+  // ^ Main
631
+  //
599 632
   MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
600
-  #if defined( SDSUPPORT ) && defined( MENU_ADDAUTOSTART )
601
-    MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
602
-  #endif
603
-  MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
633
+
634
+  //
635
+  // Auto Home
636
+  //
604 637
   MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
638
+
639
+  //
640
+  // Set Home Offsets
641
+  //
605 642
   MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
606 643
   //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
607 644
 
645
+  //
646
+  // Level Bed
647
+  //
648
+  #ifdef ENABLE_AUTO_BED_LEVELING
649
+    if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS])
650
+      MENU_ITEM(gcode, MSG_LEVEL_BED, PSTR("G29"));
651
+  #elif defined(MANUAL_BED_LEVELING)
652
+    MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed);
653
+  #endif
654
+
655
+  //
656
+  // Move Axis
657
+  //
658
+  MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
659
+
660
+  //
661
+  // Disable Steppers
662
+  //
663
+  MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
664
+
665
+  //
666
+  // Preheat PLA
667
+  // Preheat ABS
668
+  //
608 669
   #if TEMP_SENSOR_0 != 0
609 670
     #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0
610 671
       MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu);
@@ -615,8 +676,14 @@ static void lcd_prepare_menu() {
615 676
     #endif
616 677
   #endif
617 678
 
679
+  //
680
+  // Cooldown
681
+  //
618 682
   MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
619 683
 
684
+  //
685
+  // Switch power on/off
686
+  //
620 687
   #if HAS_POWER_SWITCH
621 688
     if (powersupply)
622 689
       MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
@@ -624,12 +691,13 @@ static void lcd_prepare_menu() {
624 691
       MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
625 692
   #endif
626 693
 
627
-  MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
628
-
629
-  #if defined(MANUAL_BED_LEVELING)
630
-    MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed);
694
+  //
695
+  // Autostart
696
+  //
697
+  #if defined(SDSUPPORT) && defined(MENU_ADDAUTOSTART)
698
+    MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
631 699
   #endif
632
-	
700
+
633 701
   END_MENU();
634 702
 }
635 703
 
@@ -657,6 +725,12 @@ inline void line_to_current(AxisEnum axis) {
657 725
   #endif
658 726
 }
659 727
 
728
+/**
729
+ *
730
+ * "Prepare" > "Move Axis" submenu
731
+ *
732
+ */
733
+
660 734
 float move_menu_scale;
661 735
 static void lcd_move_menu_axis();
662 736
 
@@ -687,6 +761,12 @@ static void lcd_move_e() {
687 761
   if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis);
688 762
 }
689 763
 
764
+/**
765
+ *
766
+ * "Prepare" > "Move Xmm" > "Move XYZ" submenu
767
+ *
768
+ */
769
+
690 770
 static void lcd_move_menu_axis() {
691 771
   START_MENU();
692 772
   MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu);
@@ -712,6 +792,12 @@ static void lcd_move_menu_01mm() {
712 792
   lcd_move_menu_axis();
713 793
 }
714 794
 
795
+/**
796
+ *
797
+ * "Prepare" > "Move Axis" submenu
798
+ *
799
+ */
800
+
715 801
 static void lcd_move_menu() {
716 802
   START_MENU();
717 803
   MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
@@ -722,6 +808,12 @@ static void lcd_move_menu() {
722 808
   END_MENU();
723 809
 }
724 810
 
811
+/**
812
+ *
813
+ * "Control" submenu
814
+ *
815
+ */
816
+
725 817
 static void lcd_control_menu() {
726 818
   START_MENU();
727 819
   MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
@@ -744,6 +836,12 @@ static void lcd_control_menu() {
744 836
   END_MENU();
745 837
 }
746 838
 
839
+/**
840
+ *
841
+ * "Temperature" submenu
842
+ *
843
+ */
844
+
747 845
 #ifdef PIDTEMP
748 846
 
749 847
   // Helpers for editing PID Ki & Kd values
@@ -775,6 +873,12 @@ static void lcd_control_menu() {
775 873
 
776 874
 #endif //PIDTEMP
777 875
 
876
+/**
877
+ *
878
+ * "Control" > "Temperature" submenu
879
+ *
880
+ */
881
+
778 882
 static void lcd_control_temperature_menu() {
779 883
   START_MENU();
780 884
   MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
@@ -863,6 +967,12 @@ static void lcd_control_temperature_menu() {
863 967
   END_MENU();
864 968
 }
865 969
 
970
+/**
971
+ *
972
+ * "Temperature" > "Preheat PLA conf" submenu
973
+ *
974
+ */
975
+
866 976
 static void lcd_control_temperature_preheat_pla_settings_menu() {
867 977
   START_MENU();
868 978
   MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
@@ -879,6 +989,12 @@ static void lcd_control_temperature_preheat_pla_settings_menu() {
879 989
   END_MENU();
880 990
 }
881 991
 
992
+/**
993
+ *
994
+ * "Temperature" > "Preheat ABS conf" submenu
995
+ *
996
+ */
997
+
882 998
 static void lcd_control_temperature_preheat_abs_settings_menu() {
883 999
   START_MENU();
884 1000
   MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
@@ -895,6 +1011,12 @@ static void lcd_control_temperature_preheat_abs_settings_menu() {
895 1011
   END_MENU();
896 1012
 }
897 1013
 
1014
+/**
1015
+ *
1016
+ * "Control" > "Motion" submenu
1017
+ *
1018
+ */
1019
+
898 1020
 static void lcd_control_motion_menu() {
899 1021
   START_MENU();
900 1022
   MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
@@ -931,6 +1053,12 @@ static void lcd_control_motion_menu() {
931 1053
   END_MENU();
932 1054
 }
933 1055
 
1056
+/**
1057
+ *
1058
+ * "Control" > "Filament" submenu
1059
+ *
1060
+ */
1061
+
934 1062
 static void lcd_control_volumetric_menu() {
935 1063
   START_MENU();
936 1064
   MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
@@ -953,6 +1081,12 @@ static void lcd_control_volumetric_menu() {
953 1081
   END_MENU();
954 1082
 }
955 1083
 
1084
+/**
1085
+ *
1086
+ * "Control" > "Contrast" submenu
1087
+ *
1088
+ */
1089
+
956 1090
 #ifdef HAS_LCD_CONTRAST
957 1091
   static void lcd_set_contrast() {
958 1092
     if (encoderPosition != 0) {
@@ -967,6 +1101,12 @@ static void lcd_control_volumetric_menu() {
967 1101
   }
968 1102
 #endif // HAS_LCD_CONTRAST
969 1103
 
1104
+/**
1105
+ *
1106
+ * "Control" > "Retract" submenu
1107
+ *
1108
+ */
1109
+
970 1110
 #ifdef FWRETRACT
971 1111
   static void lcd_control_retract_menu() {
972 1112
     START_MENU();
@@ -999,6 +1139,12 @@ static void lcd_sd_updir() {
999 1139
   currentMenuViewOffset = 0;
1000 1140
 }
1001 1141
 
1142
+/**
1143
+ *
1144
+ * "Print from SD" submenu
1145
+ *
1146
+ */
1147
+
1002 1148
 void lcd_sdcard_menu() {
1003 1149
   if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return;	// nothing to do (so don't thrash the SD card)
1004 1150
   uint16_t fileCnt = card.getnrfilenames();
@@ -1034,6 +1180,11 @@ void lcd_sdcard_menu() {
1034 1180
   END_MENU();
1035 1181
 }
1036 1182
 
1183
+/**
1184
+ *
1185
+ * Functions for editing single values
1186
+ *
1187
+ */
1037 1188
 #define menu_edit_type(_type, _name, _strFunc, scale) \
1038 1189
   bool _menu_edit_ ## _name () { \
1039 1190
     bool isClicked = LCD_CLICKED; \
@@ -1080,6 +1231,11 @@ menu_edit_type(float, float51, ftostr51, 10)
1080 1231
 menu_edit_type(float, float52, ftostr52, 100)
1081 1232
 menu_edit_type(unsigned long, long5, ftostr5, 0.01)
1082 1233
 
1234
+/**
1235
+ *
1236
+ * Handlers for RepRap World Keypad input
1237
+ *
1238
+ */
1083 1239
 #ifdef REPRAPWORLD_KEYPAD
1084 1240
   static void reprapworld_keypad_move_z_up() {
1085 1241
     encoderPosition = 1;
@@ -1114,10 +1270,14 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01)
1114 1270
   static void reprapworld_keypad_move_home() {
1115 1271
     enqueuecommands_P((PSTR("G28"))); // move all axis home
1116 1272
   }
1117
-#endif //REPRAPWORLD_KEYPAD
1273
+#endif // REPRAPWORLD_KEYPAD
1118 1274
 
1119
-/** End of menus **/
1120 1275
 
1276
+/**
1277
+ *
1278
+ * Audio feedback for controller clicks
1279
+ *
1280
+ */
1121 1281
 void lcd_quick_feedback() {
1122 1282
   lcdDrawUpdate = 2;
1123 1283
   next_button_update_ms = millis() + 500;
@@ -1146,11 +1306,15 @@ void lcd_quick_feedback() {
1146 1306
   #endif
1147 1307
 }
1148 1308
 
1149
-/** Menu action functions **/
1150
-static void menu_action_back(menuFunc_t data) { lcd_goto_menu(data); }
1151
-static void menu_action_submenu(menuFunc_t data) { lcd_goto_menu(data); }
1309
+/**
1310
+ *
1311
+ * Menu actions
1312
+ *
1313
+ */
1314
+static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); }
1315
+static void menu_action_submenu(menuFunc_t func) { lcd_goto_menu(func); }
1152 1316
 static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); }
1153
-static void menu_action_function(menuFunc_t data) { (*data)(); }
1317
+static void menu_action_function(menuFunc_t func) { (*func)(); }
1154 1318
 static void menu_action_sdfile(const char* filename, char* longFilename) {
1155 1319
   char cmd[30];
1156 1320
   char* c;
@@ -1243,6 +1407,19 @@ int lcd_strlen_P(const char *s) {
1243 1407
   return j;
1244 1408
 }
1245 1409
 
1410
+/**
1411
+ * Update the LCD, read encoder buttons, etc.
1412
+ *   - Read button states
1413
+ *   - Check the SD Card slot state
1414
+ *   - Act on RepRap World keypad input
1415
+ *   - Update the encoder position
1416
+ *   - Apply acceleration to the encoder position
1417
+ *   - Reset the Info Screen timeout if there's any input
1418
+ *   - Update status indicators, if any
1419
+ *   - Clear the LCD if lcdDrawUpdate == 2
1420
+ *
1421
+ * Warning: This function is called from interrupt context!
1422
+ */
1246 1423
 void lcd_update() {
1247 1424
   #ifdef ULTIPANEL
1248 1425
     static millis_t return_to_status_ms = 0;
@@ -1381,7 +1558,7 @@ void lcd_update() {
1381 1558
 
1382 1559
     if (lcdDrawUpdate == 2) lcd_implementation_clear();
1383 1560
     if (lcdDrawUpdate) lcdDrawUpdate--;
1384
-    next_lcd_update_ms = millis() + LCD_UPDATE_INTERVAL;
1561
+    next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
1385 1562
   }
1386 1563
 }
1387 1564
 
@@ -1454,112 +1631,116 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
1454 1631
 
1455 1632
 #ifdef ULTIPANEL
1456 1633
 
1457
-////////////////////////
1458
-// Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement)
1459
-// These values are independent of which pins are used for EN_A and EN_B indications
1460
-// The rotary encoder part is also independent to the chipset used for the LCD
1461
-#if defined(EN_A) && defined(EN_B)
1462
-  #define encrot0 0
1463
-  #define encrot1 2
1464
-  #define encrot2 3
1465
-  #define encrot3 1
1466
-#endif 
1467
-
1468
-/* Warning: This function is called from interrupt context */
1469
-void lcd_buttons_update() {
1470
-  #ifdef NEWPANEL
1471
-    uint8_t newbutton = 0;
1472
-    if (READ(BTN_EN1) == 0) newbutton |= EN_A;
1473
-    if (READ(BTN_EN2) == 0) newbutton |= EN_B;
1474
-    #if BTN_ENC > 0
1475
-      if (millis() > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C;
1476
-    #endif
1477
-    buttons = newbutton;
1478
-    #ifdef LCD_HAS_SLOW_BUTTONS
1479
-      buttons |= slow_buttons;
1480
-    #endif
1481
-    #ifdef REPRAPWORLD_KEYPAD
1482
-      // for the reprapworld_keypad
1483
-      uint8_t newbutton_reprapworld_keypad=0;
1634
+  /**
1635
+   * Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement)
1636
+   * These values are independent of which pins are used for EN_A and EN_B indications
1637
+   * The rotary encoder part is also independent to the chipset used for the LCD
1638
+   */
1639
+  #if defined(EN_A) && defined(EN_B)
1640
+    #define encrot0 0
1641
+    #define encrot1 2
1642
+    #define encrot2 3
1643
+    #define encrot3 1
1644
+  #endif 
1645
+
1646
+  /**
1647
+   * Read encoder buttons from the hardware registers
1648
+   * Warning: This function is called from interrupt context!
1649
+   */
1650
+  void lcd_buttons_update() {
1651
+    #ifdef NEWPANEL
1652
+      uint8_t newbutton = 0;
1653
+      if (READ(BTN_EN1) == 0) newbutton |= EN_A;
1654
+      if (READ(BTN_EN2) == 0) newbutton |= EN_B;
1655
+      #if BTN_ENC > 0
1656
+        if (millis() > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C;
1657
+      #endif
1658
+      buttons = newbutton;
1659
+      #ifdef LCD_HAS_SLOW_BUTTONS
1660
+        buttons |= slow_buttons;
1661
+      #endif
1662
+      #ifdef REPRAPWORLD_KEYPAD
1663
+        // for the reprapworld_keypad
1664
+        uint8_t newbutton_reprapworld_keypad=0;
1665
+        WRITE(SHIFT_LD, LOW);
1666
+        WRITE(SHIFT_LD, HIGH);
1667
+        for(int8_t i = 0; i < 8; i++) {
1668
+          newbutton_reprapworld_keypad >>= 1;
1669
+          if (READ(SHIFT_OUT)) newbutton_reprapworld_keypad |= BIT(7);
1670
+          WRITE(SHIFT_CLK, HIGH);
1671
+          WRITE(SHIFT_CLK, LOW);
1672
+        }
1673
+        buttons_reprapworld_keypad=~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
1674
+      #endif
1675
+    #else   //read it from the shift register
1676
+      uint8_t newbutton = 0;
1484 1677
       WRITE(SHIFT_LD, LOW);
1485 1678
       WRITE(SHIFT_LD, HIGH);
1486
-      for(int8_t i = 0; i < 8; i++) {
1487
-        newbutton_reprapworld_keypad >>= 1;
1488
-        if (READ(SHIFT_OUT)) newbutton_reprapworld_keypad |= BIT(7);
1679
+      unsigned char tmp_buttons = 0;
1680
+      for(int8_t i=0; i<8; i++) {
1681
+        newbutton >>= 1;
1682
+        if (READ(SHIFT_OUT)) newbutton |= BIT(7);
1489 1683
         WRITE(SHIFT_CLK, HIGH);
1490 1684
         WRITE(SHIFT_CLK, LOW);
1491 1685
       }
1492
-      buttons_reprapworld_keypad=~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
1493
-    #endif
1494
-  #else   //read it from the shift register
1495
-    uint8_t newbutton = 0;
1496
-    WRITE(SHIFT_LD, LOW);
1497
-    WRITE(SHIFT_LD, HIGH);
1498
-    unsigned char tmp_buttons = 0;
1499
-    for(int8_t i=0; i<8; i++) {
1500
-      newbutton >>= 1;
1501
-      if (READ(SHIFT_OUT)) newbutton |= BIT(7);
1502
-      WRITE(SHIFT_CLK, HIGH);
1503
-      WRITE(SHIFT_CLK, LOW);
1504
-    }
1505
-    buttons = ~newbutton; //invert it, because a pressed switch produces a logical 0
1506
-  #endif //!NEWPANEL
1507
-
1508
-  //manage encoder rotation
1509
-  uint8_t enc=0;
1510
-  if (buttons & EN_A) enc |= B01;
1511
-  if (buttons & EN_B) enc |= B10;
1512
-  if (enc != lastEncoderBits) {
1513
-    switch(enc) {
1514
-      case encrot0:
1515
-        if (lastEncoderBits==encrot3) encoderDiff++;
1516
-        else if (lastEncoderBits==encrot1) encoderDiff--;
1517
-        break;
1518
-      case encrot1:
1519
-        if (lastEncoderBits==encrot0) encoderDiff++;
1520
-        else if (lastEncoderBits==encrot2) encoderDiff--;
1521
-        break;
1522
-      case encrot2:
1523
-        if (lastEncoderBits==encrot1) encoderDiff++;
1524
-        else if (lastEncoderBits==encrot3) encoderDiff--;
1525
-        break;
1526
-      case encrot3:
1527
-        if (lastEncoderBits==encrot2) encoderDiff++;
1528
-        else if (lastEncoderBits==encrot0) encoderDiff--;
1529
-        break;
1686
+      buttons = ~newbutton; //invert it, because a pressed switch produces a logical 0
1687
+    #endif //!NEWPANEL
1688
+
1689
+    //manage encoder rotation
1690
+    uint8_t enc=0;
1691
+    if (buttons & EN_A) enc |= B01;
1692
+    if (buttons & EN_B) enc |= B10;
1693
+    if (enc != lastEncoderBits) {
1694
+      switch(enc) {
1695
+        case encrot0:
1696
+          if (lastEncoderBits==encrot3) encoderDiff++;
1697
+          else if (lastEncoderBits==encrot1) encoderDiff--;
1698
+          break;
1699
+        case encrot1:
1700
+          if (lastEncoderBits==encrot0) encoderDiff++;
1701
+          else if (lastEncoderBits==encrot2) encoderDiff--;
1702
+          break;
1703
+        case encrot2:
1704
+          if (lastEncoderBits==encrot1) encoderDiff++;
1705
+          else if (lastEncoderBits==encrot3) encoderDiff--;
1706
+          break;
1707
+        case encrot3:
1708
+          if (lastEncoderBits==encrot2) encoderDiff++;
1709
+          else if (lastEncoderBits==encrot0) encoderDiff--;
1710
+          break;
1711
+      }
1530 1712
     }
1713
+    lastEncoderBits = enc;
1531 1714
   }
1532
-  lastEncoderBits = enc;
1533
-}
1534
-
1535
-bool lcd_detected(void) {
1536
-  #if (defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE)
1537
-    return lcd.LcdDetected() == 1;
1538
-  #else
1539
-    return true;
1540
-  #endif
1541
-}
1542 1715
 
1543
-void lcd_buzz(long duration, uint16_t freq) {
1544
-  if (freq > 0) {
1545
-    #if BEEPER > 0
1546
-      SET_OUTPUT(BEEPER);
1547
-      tone(BEEPER, freq, duration);
1548
-      delay(duration);
1549
-    #elif defined(LCD_USE_I2C_BUZZER)
1550
-      lcd.buzz(duration, freq);
1716
+  bool lcd_detected(void) {
1717
+    #if (defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE)
1718
+      return lcd.LcdDetected() == 1;
1551 1719
     #else
1552
-      delay(duration);
1720
+      return true;
1553 1721
     #endif
1554 1722
   }
1555
-  else {
1556
-    delay(duration);
1723
+
1724
+  void lcd_buzz(long duration, uint16_t freq) {
1725
+    if (freq > 0) {
1726
+      #if BEEPER > 0
1727
+        SET_OUTPUT(BEEPER);
1728
+        tone(BEEPER, freq, duration);
1729
+        delay(duration);
1730
+      #elif defined(LCD_USE_I2C_BUZZER)
1731
+        lcd.buzz(duration, freq);
1732
+      #else
1733
+        delay(duration);
1734
+      #endif
1735
+    }
1736
+    else {
1737
+      delay(duration);
1738
+    }
1557 1739
   }
1558
-}
1559 1740
 
1560
-bool lcd_clicked() { return LCD_CLICKED; }
1741
+  bool lcd_clicked() { return LCD_CLICKED; }
1561 1742
 
1562
-#endif //ULTIPANEL
1743
+#endif // ULTIPANEL
1563 1744
 
1564 1745
 /*********************************/
1565 1746
 /** Number to string conversion **/
@@ -1621,8 +1802,7 @@ char *ftostr32(const float &x) {
1621 1802
 }
1622 1803
 
1623 1804
 // Convert float to string with 1.234 format
1624
-char *ftostr43(const float &x)
1625
-{
1805
+char *ftostr43(const float &x) {
1626 1806
 	long xx = x * 1000;
1627 1807
     if (xx >= 0)
1628 1808
 		conv[0] = (xx / 1000) % 10 + '0';
@@ -1638,8 +1818,7 @@ char *ftostr43(const float &x)
1638 1818
 }
1639 1819
 
1640 1820
 // Convert float to string with 1.23 format
1641
-char *ftostr12ns(const float &x)
1642
-{
1821
+char *ftostr12ns(const float &x) {
1643 1822
   long xx=x*100;
1644 1823
   
1645 1824
   xx=abs(xx);
@@ -1799,6 +1978,12 @@ char *ftostr52(const float &x) {
1799 1978
 #ifdef MANUAL_BED_LEVELING
1800 1979
 
1801 1980
   static int _lcd_level_bed_position;
1981
+
1982
+  /**
1983
+   * MBL Wait for controller movement and clicks:
1984
+   *   - Movement adjusts the Z axis
1985
+   *   - Click saves the Z and goes to the next mesh point
1986
+   */
1802 1987
   static void _lcd_level_bed() {
1803 1988
     if (encoderPosition != 0) {
1804 1989
       refresh_cmd_timeout();
@@ -1844,6 +2029,9 @@ char *ftostr52(const float &x) {
1844 2029
     }
1845 2030
   }
1846 2031
 
2032
+  /**
2033
+   * MBL Move to mesh starting point
2034
+   */
1847 2035
   static void _lcd_level_bed_homing() {
1848 2036
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), "Homing");
1849 2037
     if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) {
@@ -1858,6 +2046,9 @@ char *ftostr52(const float &x) {
1858 2046
     lcdDrawUpdate = 2;
1859 2047
   }
1860 2048
 
2049
+  /**
2050
+   * MBL entry-point
2051
+   */
1861 2052
   static void lcd_level_bed() {
1862 2053
     axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false;
1863 2054
     mbl.reset();

Loading…
Cancel
Save