Browse Source

menu switch - initial

PavelSindler 5 years ago
parent
commit
e27fdafcec

+ 1 - 0
.gitignore

@@ -50,3 +50,4 @@ Firmware/Doc
 /lang/textaddr.txt
 /build-env/
 /Firmware/Firmware.vcxproj
+/Firmware/Configuration_prusa_bckp.h

+ 1 - 1
Firmware/Marlin_main.cpp

@@ -1472,7 +1472,7 @@ void setup()
 	if (eeprom_read_byte((uint8_t*)EEPROM_SD_SORT) == 255) {
 		eeprom_write_byte((uint8_t*)EEPROM_SD_SORT, 0);
 	}
-
+	mbl_mode_init();
 	check_babystep(); //checking if Z babystep is in allowed range
 
 #ifdef UVLO_SUPPORT

+ 3 - 2
Firmware/eeprom.h

@@ -154,8 +154,9 @@
 #define EEPROM_MMU_LOAD_FAIL_TOT (EEPROM_MMU_FAIL - 2) //uint16_t
 #define EEPROM_MMU_LOAD_FAIL (EEPROM_MMU_LOAD_FAIL_TOT - 1) //uint8_t
 
-#define EEPROM_UVLO_MESH_BED_LEVELING_FULL     (EEPROM_MMU_LOAD_FAIL - 1000 - 12*12*2) //allow 12 calibration points for future expansion
-//-1000 is to be compatible with future updates from prusa if it not merged, real value is 2503 so there is space
+#define EEPROM_UVLO_MESH_BED_LEVELING_FULL     (EEPROM_MMU_LOAD_FAIL - 12*12*2) //allow 12 calibration points for future expansion
+#define EEPROM_MBL_TYPE	(EEPROM_UVLO_MESH_BED_LEVELING_FULL-1) //uint8_t for mesh bed leveling precision
+
 // !!!!!
 // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
 // !!!!!

+ 17 - 0
Firmware/mesh_bed_calibration.cpp

@@ -3048,3 +3048,20 @@ void count_xyz_details(float (&distanceMin)[2]) {
 	}
 }
 
+e_MBL_TYPE e_mbl_type = e_MBL_OPTIMAL;
+
+void mbl_mode_set() {
+	switch (e_mbl_type) {
+		case e_MBL_OPTIMAL: e_mbl_type = e_MBL_PREC; break;
+		case e_MBL_PREC: e_mbl_type = e_MBL_FAST; break;
+		case e_MBL_FAST: e_mbl_type = e_MBL_OPTIMAL; break;
+		default: e_mbl_type = e_MBL_OPTIMAL; break;
+	}
+	eeprom_update_byte((uint8_t*)EEPROM_MBL_TYPE,(uint8_t)e_mbl_type);
+}
+
+void mbl_mode_init() {
+	uint8_t mbl_type = eeprom_read_byte((uint8_t*)EEPROM_MBL_TYPE);
+	if (mbl_type == 0xFF) e_mbl_type = e_MBL_OPTIMAL;
+	else e_mbl_type = mbl_type;
+}

+ 9 - 0
Firmware/mesh_bed_calibration.h

@@ -201,4 +201,13 @@ extern void babystep_reset();
 extern void count_xyz_details(float (&distanceMin)[2]);
 extern bool sample_z();
 
+typedef enum
+{
+	e_MBL_FAST, e_MBL_OPTIMAL, e_MBL_PREC
+} e_MBL_TYPE;
+
+extern e_MBL_TYPE e_mbl_type;
+extern void mbl_mode_set();
+extern void mbl_mode_init();
+
 #endif /* MESH_BED_CALIBRATION_H */

+ 24 - 0
Firmware/ultralcd.cpp

@@ -5265,6 +5265,28 @@ do\
 while (0)
 #endif // SDCARD_SORT_ALPHA
 
+#define SETTINGS_MBL_MODE \
+do\
+{\
+    switch(e_mbl_type)\
+    {\
+    case e_MBL_FAST:\
+        MENU_ITEM_FUNCTION_P(_i("MBL mode    [Fast]"),mbl_mode_set);\ 
+         break; \
+    case e_MBL_OPTIMAL:\
+	    MENU_ITEM_FUNCTION_P(_i("MBL mode [Optimal]"), mbl_mode_set); \ 
+	     break; \
+    case e_MBL_PREC:\
+	     MENU_ITEM_FUNCTION_P(_i("MBL mode [Precise]"), mbl_mode_set); \
+	     break; \
+    default:\
+	     MENU_ITEM_FUNCTION_P(_i("MBL mode [Optimal]"), mbl_mode_set); \
+	     break; \
+    }\
+}\
+while (0)
+
+
 #define SETTINGS_SOUND \
 do\
 {\
@@ -5311,6 +5333,8 @@ static void lcd_settings_menu()
 
 	SETTINGS_SILENT_MODE;
 
+	SETTINGS_MBL_MODE;
+
 #if defined (TMC2130) && defined (LINEARITY_CORRECTION)
     MENU_ITEM_SUBMENU_P(_i("Lin. correction"), lcd_settings_linearity_correction_menu);
 #endif //LINEARITY_CORRECTION && TMC2130