|
|
@ -20,33 +20,33 @@
|
|
|
|
#include "crc.h"
|
|
|
|
#include "crc.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace KaleidoscopePlugins {
|
|
|
|
namespace KaleidoscopePlugins {
|
|
|
|
struct EEPROMSettings::settings EEPROMSettings::settings;
|
|
|
|
struct EEPROMSettings::settings EEPROMSettings::settings;
|
|
|
|
bool EEPROMSettings::_isValid;
|
|
|
|
bool EEPROMSettings::_isValid;
|
|
|
|
bool EEPROMSettings::sealed;
|
|
|
|
bool EEPROMSettings::sealed;
|
|
|
|
uint16_t EEPROMSettings::nextStart = sizeof (EEPROMSettings::settings);
|
|
|
|
uint16_t EEPROMSettings::nextStart = sizeof (EEPROMSettings::settings);
|
|
|
|
|
|
|
|
|
|
|
|
EEPROMSettings::EEPROMSettings (void) {
|
|
|
|
EEPROMSettings::EEPROMSettings (void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
EEPROMSettings::begin (void) {
|
|
|
|
EEPROMSettings::begin (void) {
|
|
|
|
EEPROM.get (0, settings);
|
|
|
|
EEPROM.get (0, settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
EEPROMSettings::isValid (void) {
|
|
|
|
EEPROMSettings::isValid (void) {
|
|
|
|
return _isValid;
|
|
|
|
return _isValid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t
|
|
|
|
uint16_t
|
|
|
|
EEPROMSettings::crc (void) {
|
|
|
|
EEPROMSettings::crc (void) {
|
|
|
|
if (sealed)
|
|
|
|
if (sealed)
|
|
|
|
return settings.crc;
|
|
|
|
return settings.crc;
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
EEPROMSettings::seal (void) {
|
|
|
|
EEPROMSettings::seal (void) {
|
|
|
|
sealed = true;
|
|
|
|
sealed = true;
|
|
|
|
|
|
|
|
|
|
|
|
CRC.finalize ();
|
|
|
|
CRC.finalize ();
|
|
|
@ -62,10 +62,10 @@ namespace KaleidoscopePlugins {
|
|
|
|
|
|
|
|
|
|
|
|
if (settings.crc != CRC.crc)
|
|
|
|
if (settings.crc != CRC.crc)
|
|
|
|
_isValid = false;
|
|
|
|
_isValid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t
|
|
|
|
uint16_t
|
|
|
|
EEPROMSettings::requestSlice (uint16_t size) {
|
|
|
|
EEPROMSettings::requestSlice (uint16_t size) {
|
|
|
|
if (sealed)
|
|
|
|
if (sealed)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
@ -75,36 +75,36 @@ namespace KaleidoscopePlugins {
|
|
|
|
CRC.update ((const void *)&size, sizeof (size));
|
|
|
|
CRC.update ((const void *)&size, sizeof (size));
|
|
|
|
|
|
|
|
|
|
|
|
return start;
|
|
|
|
return start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
EEPROMSettings::invalidate (void) {
|
|
|
|
EEPROMSettings::invalidate (void) {
|
|
|
|
_isValid = false;
|
|
|
|
_isValid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t
|
|
|
|
uint16_t
|
|
|
|
EEPROMSettings::used (void) {
|
|
|
|
EEPROMSettings::used (void) {
|
|
|
|
return nextStart;
|
|
|
|
return nextStart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
EEPROMSettings::update (void) {
|
|
|
|
EEPROMSettings::update (void) {
|
|
|
|
settings.crc = CRC.crc;
|
|
|
|
settings.crc = CRC.crc;
|
|
|
|
|
|
|
|
|
|
|
|
EEPROM.put (0, settings);
|
|
|
|
EEPROM.put (0, settings);
|
|
|
|
_isValid = true;
|
|
|
|
_isValid = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t
|
|
|
|
uint8_t
|
|
|
|
EEPROMSettings::version (void) {
|
|
|
|
EEPROMSettings::version (void) {
|
|
|
|
return settings.version;
|
|
|
|
return settings.version;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
EEPROMSettings::version (uint8_t ver) {
|
|
|
|
EEPROMSettings::version (uint8_t ver) {
|
|
|
|
settings.version = ver;
|
|
|
|
settings.version = ver;
|
|
|
|
update ();
|
|
|
|
update ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
KaleidoscopePlugins::EEPROMSettings EEPROMSettings;
|
|
|
|
KaleidoscopePlugins::EEPROMSettings EEPROMSettings;
|
|
|
|