From 02a692c5d9dd7cb0cefc5c3bb69f9c25885118b6 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 27 Feb 2019 17:34:03 +0100 Subject: [PATCH] Store cutter enable state in EEPROM. --- Firmware/Marlin.h | 1 - Firmware/Marlin_main.cpp | 2 -- Firmware/eeprom.h | 2 +- Firmware/mmu.cpp | 2 +- Firmware/ultralcd.cpp | 18 +++++++++++++----- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index ff9335ac..2d469a76 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -285,7 +285,6 @@ void setPwmFrequency(uint8_t pin, int val); #endif //CRITICAL_SECTION_START extern bool fans_check_enabled; -extern bool cutter_enabled; extern float homing_feedrate[]; extern bool axis_relative_modes[]; extern int feedmultiply; diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index ee00f35b..d9766e96 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -510,8 +510,6 @@ void servo_init() bool fans_check_enabled = true; -bool cutter_enabled = false; - #ifdef TMC2130 diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 9f878796..16c02ed5 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -153,7 +153,7 @@ #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_MMU_CUTTER_ENABLED (EEPROM_MMU_LOAD_FAIL - 1) // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 37bd631d..cdd85e9b 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1439,7 +1439,7 @@ void mmu_continue_loading() if(mmu_load_fail < 255) eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, mmu_load_fail + 1); if(mmu_load_fail_tot < 65535) eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, mmu_load_fail_tot + 1); - if (cutter_enabled) + if (1 == eeprom_read_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED)) { mmu_command(MmuCmd::K0 + tmp_extruder); manage_response(true, true, MMU_UNLOAD_MOVE); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 57300241..d925ce05 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2293,8 +2293,16 @@ void lcd_set_fan_check() { eeprom_update_byte((unsigned char *)EEPROM_FAN_CHECK_ENABLED, fans_check_enabled); } -void lcd_cutter_enabled() { - cutter_enabled = !cutter_enabled; +void lcd_cutter_enabled() +{ + if (1 == eeprom_read_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED)) + { + eeprom_update_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED, 0); + } + else + { + eeprom_update_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED, 1); + } } void lcd_set_filament_autoload() { @@ -5212,10 +5220,10 @@ static void lcd_settings_menu() SETTINGS_AUTO_DEPLETE; - if (cutter_enabled == true) - MENU_ITEM_FUNCTION_P(_i("Cutter [on]"), lcd_cutter_enabled);////MSG_FANS_CHECK_ON c=17 r=1 + if (1 == eeprom_read_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED)) + MENU_ITEM_FUNCTION_P(_i("Cutter [on]"), lcd_cutter_enabled);//// c=17 r=1 else - MENU_ITEM_FUNCTION_P(_i("Cutter [off]"), lcd_cutter_enabled);////MSG_FANS_CHECK_OFF c=17 r=1 + MENU_ITEM_FUNCTION_P(_i("Cutter [off]"), lcd_cutter_enabled);//// c=17 r=1 if (fans_check_enabled == true) MENU_ITEM_FUNCTION_P(_i("Fans check [on]"), lcd_set_fan_check);////MSG_FANS_CHECK_ON c=17 r=1