From a7936d4efb3607916d985e178af335f265cb5647 Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Tue, 7 Feb 2023 01:32:03 +0200 Subject: [PATCH] settings saved to EEPROM on play/pause --- README.MD | 2 +- software/GToE/GToE.ino | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.MD b/README.MD index cb4ef9b..13026e2 100644 --- a/README.MD +++ b/README.MD @@ -4,10 +4,10 @@ Features: - Separate divider or multiplier per chennel (from /32 to x24) - Per-channel random pulse skip (currently only 50/50 chance) - 2 inputs for external modulation (assignable per channel) +- All channel settings and bpm are saved on play/pause and recalled on power up TODO: - different chance options for random -- Save state to EEPROM when stopped - design PCB - external clock - swing diff --git a/software/GToE/GToE.ino b/software/GToE/GToE.ino index aaaed6d..93a2410 100644 --- a/software/GToE/GToE.ino +++ b/software/GToE/GToE.ino @@ -25,7 +25,7 @@ const int outsPins[6] = {5, 6, 7, 8, 9, 10}; const int clockModes[18] = {-24, -16, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32}; //positive - divide, negative - multiply, 0 - off -int bpm = 130; +unsigned int bpm = 130; struct channel { unsigned int mode; @@ -76,8 +76,9 @@ RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03); void setup() { Serial.begin(9600); - channels[2].mode = 5; - Serial.println(channels[2].mode); + + EEPROM.get(0, bpm); + EEPROM.get(sizeof(int), channels); pinMode(INPUT_CONNECTED_PIN, INPUT_PULLUP); pinMode(ENC_BTN_PIN, INPUT_PULLUP); @@ -193,6 +194,11 @@ void resetClocks() { } } +void saveState() { + EEPROM.put(0, bpm); + EEPROM.put(sizeof(int), channels); +} + void checkInputs() { //input jack switcch @@ -273,6 +279,7 @@ void checkInputs() { isPlaying = !isPlaying; resetClocks(); playBtnPushed = true; + saveState(); } else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) { playBtnPushed = false; }