Introduce StateManager to persist state between power cycles (#6)

- add reset state menu option to return all settings back to default values.
- add reverse encoder menu option and save state
- make saving to EEPROM safer by wrapping put calls with noInterrupts()
- improve save state behavior by using a mutex flag and update check with debounce in main loop
- refactor gravity.h global const definitions to be static and more readable.
- improve usage of EncoderDir in ISR with pointer to instance and static isr() method.
- reduce u8g2 memory usage by using single page buffer

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/6
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
This commit is contained in:
2025-06-16 02:47:25 +00:00
committed by adam
parent 07ed4b3d9a
commit d12764313b
10 changed files with 378 additions and 105 deletions

20
clock.h
View File

@ -23,22 +23,22 @@
#define MIDI_STOP 0xFC
#define MIDI_CONTINUE 0xFB
const int DEFAULT_TEMPO = 120;
typedef void (*ExtCallback)(void);
static ExtCallback extUserCallback = nullptr;
static void serialEventNoop(uint8_t msg, uint8_t status) {}
enum Source {
SOURCE_INTERNAL,
SOURCE_EXTERNAL_PPQN_24,
SOURCE_EXTERNAL_PPQN_4,
SOURCE_EXTERNAL_MIDI,
SOURCE_LAST,
};
class Clock {
public:
static constexpr int DEFAULT_TEMPO = 120;
enum Source {
SOURCE_INTERNAL,
SOURCE_EXTERNAL_PPQN_24,
SOURCE_EXTERNAL_PPQN_4,
SOURCE_EXTERNAL_MIDI,
SOURCE_LAST,
};
void Init() {
NeoSerial.begin(31250);