Skip to content

Commit

Permalink
Merge pull request #32 from twistedelectrons/resetFix
Browse files Browse the repository at this point in the history
Reset fix
  • Loading branch information
twisted-electrons authored Jun 7, 2023
2 parents e068fd7 + 5ed1d4e commit 276d30e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define MEGAFM_CONSTANTS_H

const byte kVersion0 = 3;
const byte kVersion1 = 2;
const byte kVersion1 = 3;

const byte kDefaultSeq[16] = {0, 0, 0, 0, 12, 12, 12, 12, 0, 0, 12, 0, 0, 12, 12, 0};

Expand Down
2 changes: 1 addition & 1 deletion include/preset.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ byte getByte();
void store(byte input);
void eWrite(uint16_t theMemoryAddress, uint8_t u8Byte);
uint8_t eRead(uint16_t theMemoryAddress);
void clearSSEG();
void clearSSEG(bool allBanks);
#endif // MEGAFM_CMAKE_PRESET_H
14 changes: 11 additions & 3 deletions src/MEGAfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,11 @@ void setup() {
input = EEPROM.read(3966);
stereoCh3 = bitRead(input, 0);

newWide = EEPROM.read(3970);
if (EEPROM.read(3970)) {
newWide = true;
} else {
newWide = false;
}

input = EEPROM.read(3950);
noiseTableLength[0] = 0;
Expand Down Expand Up @@ -436,7 +440,7 @@ void setup() {

// first boot into 3.X? clear the SSEG and Offsets so presets aren't crazy (yet)!
if (EEPROM.read(3969) != 82) {
clearSSEG();
clearSSEG(1);
EEPROM.write(3969, 82);
}

Expand Down Expand Up @@ -469,8 +473,12 @@ void setup() {
digit(1, 18);

for (int i = 0; i < 4000; i++) {
EEPROM.write(i, kFactoryPresets[i]);
EEPROM.update(i, kFactoryPresets[i]);
}
clearSSEG(0);
EEPROM.update(3970, 0);
newWide = false;
EEPROM.update(3969, 82);

loadPreset();
eWrite(69, 69);
Expand Down
8 changes: 6 additions & 2 deletions src/midi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,12 @@ void HandleControlChange(byte channel, byte number, byte val) {
break;

case 20:
newWide = constrain(val, 0, 1);
EEPROM.update(3970, constrain(val, 0, 1));
if (val) {
newWide = true;
} else {
newWide = false;
}
EEPROM.update(3970, newWide);
break;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void panel() {

void setIndex() { index = (preset * 79) + kBankOffsets[bank]; }

void clearSSEG() {
void clearSSEG(bool allBanks) {

// show CL(ear)
digit(1, 11);
Expand All @@ -57,6 +57,8 @@ void clearSSEG() {
index += 3; // skip the next 3 bytes
}
}
if (!allBanks)
b = 6;
}
}

Expand Down

0 comments on commit 276d30e

Please sign in to comment.