settings saved to EEPROM on play/pause

This commit is contained in:
2023-02-07 01:32:03 +02:00
parent 74acd4efe1
commit a7936d4efb
2 changed files with 11 additions and 4 deletions

View File

@ -4,10 +4,10 @@ Features:
- Separate divider or multiplier per chennel (from /32 to x24) - Separate divider or multiplier per chennel (from /32 to x24)
- Per-channel random pulse skip (currently only 50/50 chance) - Per-channel random pulse skip (currently only 50/50 chance)
- 2 inputs for external modulation (assignable per channel) - 2 inputs for external modulation (assignable per channel)
- All channel settings and bpm are saved on play/pause and recalled on power up
TODO: TODO:
- different chance options for random - different chance options for random
- Save state to EEPROM when stopped
- design PCB - design PCB
- external clock - external clock
- swing - swing

View File

@ -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 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 { struct channel {
unsigned int mode; unsigned int mode;
@ -76,8 +76,9 @@ RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
void setup() { void setup() {
Serial.begin(9600); 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(INPUT_CONNECTED_PIN, INPUT_PULLUP);
pinMode(ENC_BTN_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() { void checkInputs() {
//input jack switcch //input jack switcch
@ -273,6 +279,7 @@ void checkInputs() {
isPlaying = !isPlaying; isPlaying = !isPlaying;
resetClocks(); resetClocks();
playBtnPushed = true; playBtnPushed = true;
saveState();
} else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) { } else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) {
playBtnPushed = false; playBtnPushed = false;
} }