From 69cb7add269296034daafca57f0c9fb7603f8db5 Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Mon, 30 Oct 2023 18:14:10 +0100
Subject: [PATCH 1/5] Add en- and disable MMU to M709 Add X42 to erase the MMU
eeprom
---
Firmware/Marlin_main.cpp | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index eb703187a..bf887c254 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -8581,14 +8581,15 @@ Sigma_Exit:
} break;
/*!
- ### M709 - MMU reset M709: MMU reset
- The MK3S cannot not power off the MMU, for that reason the functionality is not supported.
+ ### M709 - MMU power & reset M709: MMU power & reset
+ The MK3S cannot not power off the MMU, but we can en- and disable the MMU.
#### Usage
- M709 [ X ]
+ M709 [ S | X ]
#### Parameters
- - `X` - Reset MMU (0:soft reset | 1:hardware reset)
+ - `X` - Reset MMU (0:soft reset | 1:hardware reset | 42: erease MMU eeprom)
+ - `S` - En-/disable the MMU (0:off | 1:on)
#### Example
@@ -8596,9 +8597,28 @@ Sigma_Exit:
M709 X1 - toggle the MMU's reset pin (hardware reset)
+ M709 S1 - enable MMU
+
+ M709 S0 - disable MMU
+
+ M709 - Serial message if en- or disabled
*/
case 709:
{
+ if (code_seen('S'))
+ {
+ switch (code_value_uint8())
+ {
+ case 0:
+ MMU2::mmu2.Stop();
+ break;
+ case 1:
+ MMU2::mmu2.Start();
+ break;
+ default:
+ break;
+ }
+ }
if (MMU2::mmu2.Enabled() && code_seen('X'))
{
switch (code_value_uint8())
@@ -8609,10 +8629,14 @@ Sigma_Exit:
case 1:
MMU2::mmu2.Reset(MMU2::MMU2::ResetPin);
break;
+ case 42:
+ MMU2::mmu2.Reset(MMU2::MMU2::EraseEEPROM);
+ break;
default:
break;
}
}
+ printf_P(_n("MMU state:%d\n"), MMU2::mmu2.Enabled());
}
break;
From b11c0024d1998d6e84582f1738412e1907e1e2b1 Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Mon, 6 Nov 2023 11:47:43 +0100
Subject: [PATCH 2/5] Update requested changes
---
Firmware/Marlin_main.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index bf887c254..436412c0d 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -8582,13 +8582,13 @@ Sigma_Exit:
/*!
### M709 - MMU power & reset M709: MMU power & reset
- The MK3S cannot not power off the MMU, but we can en- and disable the MMU.
+ The MK3S cannot not power off the MMU, but we can en- and disable the MMU and will be also stored in EEPROM.
#### Usage
M709 [ S | X ]
#### Parameters
- - `X` - Reset MMU (0:soft reset | 1:hardware reset | 42: erease MMU eeprom)
+ - `X` - Reset MMU (0:soft reset | 1:hardware reset | 42: erase MMU eeprom)
- `S` - En-/disable the MMU (0:off | 1:on)
#### Example
@@ -8610,9 +8610,11 @@ Sigma_Exit:
switch (code_value_uint8())
{
case 0:
+ eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, false);
MMU2::mmu2.Stop();
break;
case 1:
+ eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, true);
MMU2::mmu2.Start();
break;
default:
From e3392a763aea4b10a9c6b835c07b66e0faa04345 Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Wed, 8 Nov 2023 07:47:38 +0100
Subject: [PATCH 3/5] Update doxygen for M709
---
Firmware/Marlin_main.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index 436412c0d..2e1001cc5 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -8583,6 +8583,8 @@ Sigma_Exit:
/*!
### M709 - MMU power & reset M709: MMU power & reset
The MK3S cannot not power off the MMU, but we can en- and disable the MMU and will be also stored in EEPROM.
+
+ The new state of the MMU is stored in printer's EEPROM - i.e. if you disable the MMU via M709, it will not be activated after the printer resets.
#### Usage
M709 [ S | X ]
From 0016b778277087688b3ebfa576ea27662208adc3 Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Thu, 9 Nov 2023 09:53:37 +0100
Subject: [PATCH 4/5] Updated MMU serial status message - Shown during bootup -
Shown on LCD menue MMU [ON|OFF] - Shown using `M709` - Shown when `Disable`d
with MMU ERROR FW UPDATE NEEDED
---
Firmware/Marlin_main.cpp | 3 ++-
Firmware/mmu2.cpp | 14 ++++++++++++++
Firmware/mmu2.h | 3 +++
Firmware/mmu2_reporting.cpp | 1 +
Firmware/ultralcd.cpp | 1 +
5 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index 2e1001cc5..b37818402 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -1125,6 +1125,7 @@ void setup()
if (eeprom_init_default_byte((uint8_t *)EEPROM_MMU_ENABLED, 0)) {
MMU2::mmu2.Start();
}
+ MMU2::mmu2.Status();
SpoolJoin::spooljoin.initSpoolJoinStatus();
//SERIAL_ECHOPAIR("Active sheet before:", static_cast(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))));
@@ -8640,7 +8641,7 @@ Sigma_Exit:
break;
}
}
- printf_P(_n("MMU state:%d\n"), MMU2::mmu2.Enabled());
+ MMU2::mmu2.Status();
}
break;
diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp
index 3797d9e54..fd35e7514 100644
--- a/Firmware/mmu2.cpp
+++ b/Firmware/mmu2.cpp
@@ -12,6 +12,9 @@
#include "strlen_cx.h"
#include "SpoolJoin.h"
+#include "messages.h"
+#include "language.h"
+
#ifdef __AVR__
// As of FW 3.12 we only support building the FW with only one extruder, all the multi-extruder infrastructure will be removed.
// Saves at least 800B of code size
@@ -52,6 +55,17 @@ MMU2::MMU2()
, tmcFailures(0) {
}
+void MMU2::Status() {
+ // Useful information to see during bootup and change state
+ SERIAL_ECHOPGM("MMU is ");
+ uint8_t status = eeprom_init_default_byte((uint8_t*)EEPROM_MMU_ENABLED, 0);
+ if (status == 1) {
+ SERIAL_ECHOLNRPGM(_O(MSG_ON));
+ } else {
+ SERIAL_ECHOLNRPGM(_O(MSG_OFF));
+ }
+}
+
void MMU2::Start() {
mmu2Serial.begin(MMU_BAUD);
diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h
index f5eea95b9..0765e82ec 100644
--- a/Firmware/mmu2.h
+++ b/Firmware/mmu2.h
@@ -39,6 +39,9 @@ public:
/// Stops the protocol logic, closes the UART, powers OFF the MMU
void Stop();
+ /// Serial output of MMU state
+ void Status();
+
inline xState State() const { return state; }
inline bool Enabled() const { return State() == xState::Active; }
diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp
index 3e3d69dc9..45f18034c 100644
--- a/Firmware/mmu2_reporting.cpp
+++ b/Firmware/mmu2_reporting.cpp
@@ -347,6 +347,7 @@ void TryLoadUnloadReporter::DumpToSerial(){
/// Disables MMU in EEPROM
void DisableMMUInSettings() {
eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, false);
+ mmu2.Status();
}
void IncrementLoadFails(){
diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp
index 203ab22f8..e6b90a9f4 100644
--- a/Firmware/ultralcd.cpp
+++ b/Firmware/ultralcd.cpp
@@ -4093,6 +4093,7 @@ static void mmu_enable_switch()
}
eeprom_toggle((uint8_t *)EEPROM_MMU_ENABLED);
+ MMU2::mmu2.Status();
}
static void SETTINGS_SILENT_MODE()
From 342d8e92ab0927059198c5175520d2d2c353a345 Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Sat, 11 Nov 2023 12:20:58 +0100
Subject: [PATCH 5/5] Update doxygen M709
---
Firmware/Marlin_main.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index b37818402..054aa3448 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -8583,7 +8583,7 @@ Sigma_Exit:
/*!
### M709 - MMU power & reset M709: MMU power & reset
- The MK3S cannot not power off the MMU, but we can en- and disable the MMU and will be also stored in EEPROM.
+ The MK3S cannot not power off the MMU, but we can en- and disable the MMU.
The new state of the MMU is stored in printer's EEPROM - i.e. if you disable the MMU via M709, it will not be activated after the printer resets.
#### Usage
@@ -8600,6 +8600,8 @@ Sigma_Exit:
M709 X1 - toggle the MMU's reset pin (hardware reset)
+ M709 X42 - erase MMU EEPROM
+
M709 S1 - enable MMU
M709 S0 - disable MMU