From 7214584723fae5dac2ce3c87c7a64a29bf524f27 Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Sat, 22 Feb 2020 10:02:07 -0500 Subject: [PATCH] Fixed conflict with force_z, added P flags --- Firmware/Marlin.h | 1 + Firmware/Marlin_main.cpp | 41 +++++++++++++++++++++++++++++++--------- Firmware/ultralcd.cpp | 28 ++++++++++++++++++++++----- 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index ac55a7874..3828ccb01 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -173,6 +173,7 @@ void manage_inactivity(bool ignore_stepper_queue=false); #define enable_z() poweron_z() #define disable_z() poweroff_z() #else + extern bool bEnableForce_z; // Used by ultralcd stealth toggle void init_force_z(); void check_force_z(); void enable_force_z(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 069edc2e5..11d7bd359 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8230,30 +8230,53 @@ Sigma_Exit: break; #endif // TMC2130_SERVICE_CODES_M910_M918 - /*! + /*! ### M914 - Set TMC2130 normal mode M914: Set TMC2130 normal mode + Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout) + #### Usage + + M914 [P] + + #### Parameters + - `P` - Make the mode change permanent (write to EEPROM) */ #ifdef TMC2130 case 914: { - printf_P(_n("tmc2130mode/smm/eep: %d %d %d\n"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT)); - if (tmc2130_mode != TMC2130_MODE_NORMAL) + if (code_seen('P')) + { + eeprom_update_byte((unsigned char *)EEPROM_SILENT, SILENT_MODE_NORMAL); + SilentModeMenu = SILENT_MODE_NORMAL; + } + //printf_P(_n("tmc2130mode/smm/eep: %d %d %d %d"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT), bEnableForce_z); + if (tmc2130_mode != TMC2130_MODE_NORMAL) { tmc2130_mode = TMC2130_MODE_NORMAL; - update_mode_profile(); - tmc2130_init(TMCInitParams(false, FarmOrUserECool())); - printf_P(_n("tmc2130mode/smm/eep: %d %d %d\n"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT)); + update_mode_profile(); + tmc2130_init(TMCInitParams(false, FarmOrUserECool())); + //printf_P(_n("tmc2130mode/smm/eep: %d %d %d\n"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT)); } } break; /*! ### M915 - Set TMC2130 silent mode M915: Set TMC2130 silent mode - Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. + Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout) + #### Usage + + M915 [P] + + #### Parameters + - `P` - Make the mode change permanent (write to EEPROM) */ case 915: { - printf_P(_n("tmc2130mode/smm/eep: %d %d %d\n"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT)); + if (code_seen('P')) + { + eeprom_update_byte((unsigned char *)EEPROM_SILENT, SILENT_MODE_STEALTH); + SilentModeMenu = SILENT_MODE_STEALTH; + } + //printf_P(_n("tmc2130mode/smm/eep: %d %d %d %d"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT), bEnableForce_z); if (tmc2130_mode != TMC2130_MODE_SILENT) { // This is basically the equivalent of force_high_power_mode for silent mode. st_synchronize(); @@ -8261,7 +8284,7 @@ Sigma_Exit: tmc2130_mode = TMC2130_MODE_SILENT; update_mode_profile(); tmc2130_init(TMCInitParams(false, FarmOrUserECool())); - printf_P(_n("tmc2130mode/smm/eep: %d %d %d\n"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT)); + //printf_P(_n("tmc2130mode/smm/eep: %d %d %d\n"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT)); st_reset_timer(); sei(); } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5c7b65511..03e4afec6 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4218,16 +4218,25 @@ static void mmu_reset() } #ifdef TMC2130 + + +#ifdef PSU_Delta // This setup changes to "stealth" mode on timeout, need to check for that. +#define SILENT_DESYNC_IF if (bDesync && bEnableForce_z) +#else +#define SILENT_DESYNC_IF if (bDesync) +#endif + + #define SETTINGS_SILENT_MODE \ do\ {\ if(!farm_mode)\ {\ - /* M914/5 do not update eeprom, only tmc2130_mode */\ + /* M914/5 do not update SilentModeMenu, only tmc2130_mode */\ bool bDesync = tmc2130_mode ^ eeprom_read_byte((uint8_t*)EEPROM_SILENT);\ if (SilentModeMenu == SILENT_MODE_NORMAL) \ {\ - if (bDesync)\ + SILENT_DESYNC_IF\ MENU_ITEM_TOGGLE_P(_T(MSG_MODE), PSTR("M915"), lcd_silent_mode_set);\ else\ MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_NORMAL), lcd_silent_mode_set);\ @@ -4238,7 +4247,7 @@ do\ MENU_ITEM_TOGGLE_P(_T(MSG_MODE), PSTR("M914") , lcd_silent_mode_set);\ else\ MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_STEALTH), lcd_silent_mode_set);\ - }\ + }\ if (SilentModeMenu == SILENT_MODE_NORMAL)\ {\ if (lcd_crash_detect_enabled()) MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), _T(MSG_ON), crash_mode_switch);\ @@ -5618,15 +5627,24 @@ static void lcd_tune_menu() #ifdef TMC2130 if(!farm_mode) { + bool bDesync = tmc2130_mode ^ eeprom_read_byte((uint8_t*)EEPROM_SILENT); if (SilentModeMenu == SILENT_MODE_NORMAL) { - MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_NORMAL), lcd_silent_mode_set); + SILENT_DESYNC_IF { + MENU_ITEM_TOGGLE_P(_T(MSG_MODE), PSTR("M915"), lcd_silent_mode_set); + } else { + MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_NORMAL), lcd_silent_mode_set); + } if (lcd_crash_detect_enabled()) { MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), _T(MSG_ON), crash_mode_switch); } else { MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), _T(MSG_OFF), crash_mode_switch); } } else { - MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_STEALTH), lcd_silent_mode_set); + if (bDesync) { + MENU_ITEM_TOGGLE_P(_T(MSG_MODE), PSTR("M914") , lcd_silent_mode_set); + } else { + MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_STEALTH), lcd_silent_mode_set); + } MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), NULL, lcd_crash_mode_info); } }