Menu system fixes; made state less global
This commit is contained in:
parent
cfc2390b8b
commit
209959e2de
14 changed files with 964 additions and 731 deletions
|
|
@ -32,11 +32,11 @@ uint16_t readInt(uint16_t address) {
|
|||
return data.val;
|
||||
}
|
||||
|
||||
void writeCalibration() {
|
||||
void writeCalibration(calibration_t &calibration) {
|
||||
EEPROM.put(SETTINGS_OFFSET, calibration);
|
||||
}
|
||||
|
||||
void readCalibration() {
|
||||
void readCalibration(calibration_t &calibration) {
|
||||
EEPROM.get(SETTINGS_OFFSET, calibration);
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +181,6 @@ bool receiveSysexSettings(const uint8_t* data, const uint16_t length) {
|
|||
uint16_t *preset_buffer = (uint16_t*)presets;
|
||||
for(uint16_t i=0; i<payload_size/2; i++) {
|
||||
uint16_t addr = i*2;
|
||||
uint16_t val;
|
||||
|
||||
preset_buffer[addr] = convertFromMidiValue(data+(payload_pos+addr));
|
||||
}
|
||||
|
|
@ -270,7 +269,7 @@ void handleSysex(uint8_t *data, unsigned int length) {
|
|||
}
|
||||
|
||||
//Get message code
|
||||
char messageCode[3];
|
||||
char messageCode[4];
|
||||
strncpy(messageCode, (char*)(data+9), 3);
|
||||
|
||||
if(!strncmp(messageCode, "c00", 3)) { //Config dump request
|
||||
|
|
@ -319,7 +318,7 @@ void configModeLoop() {
|
|||
}
|
||||
|
||||
//Read settings from eeprom. Returns wether or not anything was written (due to factory reset or upgrade)
|
||||
void readEEPROM(const bool factoryReset) {
|
||||
void readEEPROM(const bool factoryReset, calibration_t &calibration) {
|
||||
|
||||
// if stored settings are not for current version, or Enter+Menu are pressed at startup, they are replaced by factory settings
|
||||
uint16_t settings_version = readInt(EEPROM_VERSION_ADDR);
|
||||
|
|
@ -329,7 +328,7 @@ void readEEPROM(const bool factoryReset) {
|
|||
settings_version = 0;
|
||||
} else {
|
||||
readPresets();
|
||||
readCalibration();
|
||||
readCalibration(calibration);
|
||||
}
|
||||
|
||||
if(settings_version != EEPROM_VERSION) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue