From e27fdafcec987f872b3cb63dfde484ae912514c2 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 28 Feb 2019 19:42:09 +0100 Subject: [PATCH] menu switch - initial --- .gitignore | 1 + Firmware/Marlin_main.cpp | 2 +- Firmware/eeprom.h | 5 +++-- Firmware/mesh_bed_calibration.cpp | 17 +++++++++++++++++ Firmware/mesh_bed_calibration.h | 9 +++++++++ Firmware/ultralcd.cpp | 24 ++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 7bae2ff63..bbd9b9ac2 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,4 @@ Firmware/Doc /lang/textaddr.txt /build-env/ /Firmware/Firmware.vcxproj +/Firmware/Configuration_prusa_bckp.h diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index a89aac74a..c89ac3ef8 100644 --- a/Firmware/Marlin_main.cpp +++ b/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 diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index eb99e5bca..907f88781 100644 --- a/Firmware/eeprom.h +++ b/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 !!!!! // !!!!! diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 0f56d999b..1ab22c4f2 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/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; +} \ No newline at end of file diff --git a/Firmware/mesh_bed_calibration.h b/Firmware/mesh_bed_calibration.h index 4990d104b..9c7f45455 100644 --- a/Firmware/mesh_bed_calibration.h +++ b/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 */ diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5a04796f7..37fd4746a 100644 --- a/Firmware/ultralcd.cpp +++ b/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