From d22793f2766a14d1c07609336baa843e9557f4cd Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 28 Mar 2019 12:02:46 +0100 Subject: [PATCH] Z-probe nr. states reduced to 1; 3; 5 --- Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 2 +- Firmware/ultralcd.cpp | 30 ++++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 2477d1c2..1a278013 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -21,7 +21,7 @@ #include "Configuration.h" #include "pins.h" #include "Timer.h" -extern int mbl_z_probe_nr; +extern uint8_t mbl_z_probe_nr; #ifndef AT90USB #define HardwareSerial_h // trick to disable the standard HWserial diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 67601fb1..45a1d401 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -167,7 +167,7 @@ CardReader card; unsigned long PingTime = _millis(); unsigned long NcTime; -int mbl_z_probe_nr = 3; //numer of Z measurements for each point in mesh bed leveling calibration +uint8_t mbl_z_probe_nr = 3; //numer of Z measurements for each point in mesh bed leveling calibration //used for PINDA temp calibration and pause print #define DEFAULT_RETRACTION 1 diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 04f4d763..7a6581f8 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6688,6 +6688,17 @@ static void mbl_mesh_set() { eeprom_update_byte((uint8_t*)EEPROM_MBL_POINTS_NR, mesh_nr); } +static void mbl_probe_nr_set() { + mbl_z_probe_nr = eeprom_read_byte((uint8_t*)EEPROM_MBL_PROBE_NR); + switch (mbl_z_probe_nr) { + case 1: mbl_z_probe_nr = 3; break; + case 3: mbl_z_probe_nr = 5; break; + case 5: mbl_z_probe_nr = 1; break; + default: mbl_z_probe_nr = 3; break; + } + eeprom_update_byte((uint8_t*)EEPROM_MBL_PROBE_NR, mbl_z_probe_nr); +} + static void lcd_mesh_bed_leveling_settings() { @@ -6695,25 +6706,20 @@ static void lcd_mesh_bed_leveling_settings() uint8_t points_nr = eeprom_read_byte((uint8_t*)EEPROM_MBL_POINTS_NR); MENU_BEGIN(); - // leaving menu - this condition must be immediately before MENU_ITEM_BACK_P - if (((menu_item == menu_line) && menu_clicked && (lcd_encoder == menu_item)) || menu_leaving) - { - eeprom_update_byte((uint8_t*)EEPROM_MBL_PROBE_NR, (uint8_t)mbl_z_probe_nr); - } MENU_ITEM_BACK_P(_T(MSG_SETTINGS)); - if(points_nr == 3) MENU_ITEM_FUNCTION_P(_i("Mesh [3x3]"), mbl_mesh_set); - else MENU_ITEM_FUNCTION_P(_i("Mesh [7x7]"), mbl_mesh_set); - MENU_ITEM_EDIT_int3_P(_i("Z-probe nr."), &mbl_z_probe_nr, 1, 5); + if(points_nr == 3) MENU_ITEM_FUNCTION_P(_i("Mesh [3x3]"), mbl_mesh_set); ////MSG_MESH_3x3 c=18 r=0 + else MENU_ITEM_FUNCTION_P(_i("Mesh [7x7]"), mbl_mesh_set); ////MSG_MESH_7x7 c=18 r=0 + switch (mbl_z_probe_nr) { + case 1: MENU_ITEM_FUNCTION_P(_i("Z-probe nr. [1]"), mbl_probe_nr_set); break; ////MSG_Z_PROBE_NR_1 c=18 r=0 + case 5: MENU_ITEM_FUNCTION_P(_i("Z-probe nr. [5]"), mbl_probe_nr_set); break; ////MSG_Z_PROBE_NR_1 c=18 r=0 + default: MENU_ITEM_FUNCTION_P(_i("Z-probe nr. [3]"), mbl_probe_nr_set); break; ////MSG_Z_PROBE_NR_1 c=18 r=0 + } if (points_nr == 7) { if (magnet_elimination) MENU_ITEM_FUNCTION_P(_i("Magnets comp. [On]"), mbl_magnets_elimination_set); else MENU_ITEM_FUNCTION_P(_i("Magnets comp.[Off]"), mbl_magnets_elimination_set); } else menu_item_text_P(_i("Magnets comp.[N/A]")); MENU_END(); - /*if(menu_leaving) - { - eeprom_update_byte((uint8_t*)EEPROM_MBL_POINTS_NR, mbl_z_probe_nr); - }*/ //SETTINGS_MBL_MODE; }