optimisation: spooljoin: use new eeprom init method
Change in memory: Flash: -40 bytes SRAM: -1 byte
This commit is contained in:
parent
982b1bb4bd
commit
c51aa10087
|
|
@ -9,31 +9,16 @@ namespace SpoolJoin {
|
||||||
SpoolJoin spooljoin;
|
SpoolJoin spooljoin;
|
||||||
|
|
||||||
SpoolJoin::SpoolJoin()
|
SpoolJoin::SpoolJoin()
|
||||||
: status(EEPROM::Unknown)
|
: currentMMUSlot(0)
|
||||||
, currentMMUSlot(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpoolJoin::updateSpoolJoinStatus(EEPROM newStatus)
|
|
||||||
{
|
|
||||||
status = newStatus;
|
|
||||||
eeprom_write_byte((uint8_t*)EEPROM_SPOOL_JOIN, (uint8_t)status);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpoolJoin::initSpoolJoinStatus()
|
void SpoolJoin::initSpoolJoinStatus()
|
||||||
{
|
{
|
||||||
EEPROM currentStatus = (EEPROM)eeprom_read_byte((uint8_t*)EEPROM_SPOOL_JOIN);
|
|
||||||
if( currentStatus == EEPROM::Empty)
|
|
||||||
{
|
|
||||||
// By default SpoolJoin is disabled
|
|
||||||
updateSpoolJoinStatus(EEPROM::Disabled);
|
|
||||||
} else {
|
|
||||||
updateSpoolJoinStatus(currentStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Useful information to see during bootup
|
// Useful information to see during bootup
|
||||||
SERIAL_ECHOPGM("SpoolJoin is ");
|
SERIAL_ECHOPGM("SpoolJoin is ");
|
||||||
if (isSpoolJoinEnabled())
|
uint8_t status = eeprom_init_default_byte((uint8_t*)EEPROM_SPOOL_JOIN, (uint8_t)EEPROM::Disabled);
|
||||||
|
if (status == (uint8_t)EEPROM::Enabled)
|
||||||
{
|
{
|
||||||
SERIAL_ECHOLNRPGM(_O(MSG_ON));
|
SERIAL_ECHOLNRPGM(_O(MSG_ON));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,6 @@ public:
|
||||||
/// @brief Called when EEPROM is ready to be read
|
/// @brief Called when EEPROM is ready to be read
|
||||||
void initSpoolJoinStatus();
|
void initSpoolJoinStatus();
|
||||||
|
|
||||||
/// @brief Enable SpoolJoin
|
|
||||||
inline void enableSpoolJoin() { updateSpoolJoinStatus(EEPROM::Enabled); };
|
|
||||||
|
|
||||||
/// @brief Disable SpoolJoin
|
|
||||||
inline void disableSpoolJoin() { updateSpoolJoinStatus(EEPROM::Disabled); };
|
|
||||||
|
|
||||||
/// @brief Toggle SpoolJoin
|
/// @brief Toggle SpoolJoin
|
||||||
static void toggleSpoolJoin();
|
static void toggleSpoolJoin();
|
||||||
|
|
||||||
|
|
@ -44,13 +38,6 @@ public:
|
||||||
uint8_t nextSlot();
|
uint8_t nextSlot();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @brief Update EEPROM
|
|
||||||
/// @param newStatus Status to write into EEPROM
|
|
||||||
void updateSpoolJoinStatus(EEPROM newStatus);
|
|
||||||
|
|
||||||
/// @brief SpoolJoin status
|
|
||||||
enum EEPROM status;
|
|
||||||
|
|
||||||
/// @brief Currently used slot, ranges from 0 to 4
|
/// @brief Currently used slot, ranges from 0 to 4
|
||||||
uint8_t currentMMUSlot;
|
uint8_t currentMMUSlot;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue