From 7c8e7e9e821a4c6bdb2789e365e0796b4c6ace4f Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Thu, 26 Aug 2021 20:52:57 +0200 Subject: [PATCH] Add G-Code to enable/disable stealth mode --- Firmware/Marlin_main.cpp | 51 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 835307f2..6350e34a 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4680,8 +4680,57 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); //else if (code_seen('Cal')) { // lcd_calibration(); // } + } else if (code_seen_P(PSTR("mode"))) { // PRUSA work mode + if(code_seen_P(PSTR("set"))) + { + int mode = (int)code_value(); +#ifdef TMC2130 + if (mode == SILENT_MODE_NORMAL || mode == SILENT_MODE_STEALTH) + { + SilentModeMenu = mode; + eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu); - } + SERIAL_PROTOCOLLN("OK"); + } + else + SERIAL_PROTOCOLLN("ERR: Wrong mode"); +#else + if (mode == SILENT_MODE_POWER || mode == SILENT_MODE_SILENT || mode == SILENT_MODE_AUTO) + { + SilentModeMenu = mode; + eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu); + + SERIAL_PROTOCOLLN("OK"); + } + else + SERIAL_PROTOCOLLN("ERR: Wrong mode"); +#endif + } + else + { +#ifdef TMC2130 + if (SilentModeMenu == SILENT_MODE_NORMAL) SERIAL_PROTOCOLLN("Mode : \"Stealth\""); + else SERIAL_PROTOCOLLN("Mode : \"Normal\""); + +#else + switch (SilentModeMenu) + { + case SILENT_MODE_POWER: + SERIAL_PROTOCOLLN("Mode : \"High power\""); + break; + case SILENT_MODE_SILENT: + SERIAL_PROTOCOLLN("Mode : \"Silent\""); + break; + case SILENT_MODE_AUTO: + SERIAL_PROTOCOLLN("Mode : \"Auto power\""); + break; + default: + SERIAL_PROTOCOLLN("Mode : \"High power\""); + break; /* (probably) not needed*/ + } +#endif + } + } // This prevents reading files with "^" in their names. // Since it is unclear, if there is some usage of this construct, // it will be deprecated in 3.9 alpha a possibly completely removed in the future: