mmu: add DisableMMUInSettings

power_on should not be modifying
EEPROM_MMU_ENABLED. The code is never
executed unless it's already been set.

Only disable EEPROM_MMU_ENABLED through Buttons::DisableMMU

Change in memory:
Flash: -18 bytes
SRAM: 0 bytes
This commit is contained in:
Guðni Már Gilbert 2023-10-18 23:19:54 +00:00
parent cd3372dc92
commit ef33db9a71
4 changed files with 14 additions and 10 deletions

View File

@ -69,7 +69,7 @@ void MMU2::Start() {
void MMU2::Stop() {
StopKeepPowered();
PowerOff(); // This also disables the MMU in the EEPROM.
PowerOff();
}
void MMU2::StopKeepPowered() {
@ -125,11 +125,9 @@ void MMU2::TriggerResetPin() {
void MMU2::PowerCycle() {
// cut the power to the MMU and after a while restore it
// Sadly, MK3/S/+ cannot do this
// NOTE: the below will toggle the EEPROM var. Should we
// assert this function is never called in the MK3 FW? Do we even care?
PowerOff();
Stop();
safe_delay_keep_alive(1000);
PowerOn();
Start();
}
void MMU2::PowerOff() {
@ -735,7 +733,8 @@ void MMU2::CheckUserInput() {
// ... but mmu2_power.cpp knows this and triggers a soft-reset instead.
break;
case Buttons::DisableMMU:
Stop(); // Poweroff handles updating the EEPROM shutoff.
Stop();
DisableMMUInSettings();
break;
case Buttons::StopPrint:
// @@TODO not sure if we shall handle this high level operation at this spot

View File

@ -4,7 +4,6 @@
#include "fastio.h"
#include <util/delay.h>
#include "mmu2.h"
#include "eeprom.h"
namespace MMU2 {
@ -16,13 +15,10 @@ void power_on() {
SET_OUTPUT(MMU_RST_PIN); // setup reset pin
#endif //MMU_HWRESET
eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, true);
reset();
}
void power_off() {
eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, false);
}
void reset() {

View File

@ -1,4 +1,5 @@
#include <avr/pgmspace.h>
#include "eeprom.h"
#include "mmu2.h"
#include "mmu2_log.h"
#include "mmu2_reporting.h"
@ -344,6 +345,11 @@ void TryLoadUnloadReporter::DumpToSerial(){
MMU2_ECHO_MSGLN(buf);
}
/// Disables MMU in EEPROM
void DisableMMUInSettings() {
eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, false);
}
void IncrementLoadFails(){
eeprom_increment_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL);
eeprom_increment_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT);

View File

@ -84,6 +84,9 @@ bool MMUAvailable();
/// Global Enable/Disable use MMU (to be stored in EEPROM)
bool UseMMU();
/// Disables MMU in EEPROM
void DisableMMUInSettings();
/// Increments EEPROM cell - number of failed loads into the nozzle
/// Note: technically, this is not an MMU error but an error of the printer.
void IncrementLoadFails();