|
|
@ -81,7 +81,7 @@ uint32_t overload = 0; |
|
|
|
uint32_t peak = 0; |
|
|
|
uint32_t peak = 0; |
|
|
|
uint16_t render_time_max = 0; |
|
|
|
uint16_t render_time_max = 0; |
|
|
|
uint8_t bank = 0; |
|
|
|
uint8_t bank = 0; |
|
|
|
uint8_t max_loaded_banks=0; |
|
|
|
uint8_t max_loaded_banks = 0; |
|
|
|
uint8_t voice = 0; |
|
|
|
uint8_t voice = 0; |
|
|
|
float vol = VOLUME; |
|
|
|
float vol = VOLUME; |
|
|
|
float vol_right = 1.0; |
|
|
|
float vol_right = 1.0; |
|
|
@ -183,8 +183,8 @@ void setup() |
|
|
|
sd_card_available = true; |
|
|
|
sd_card_available = true; |
|
|
|
|
|
|
|
|
|
|
|
// read all bank names
|
|
|
|
// read all bank names
|
|
|
|
max_loaded_banks=get_bank_names(); |
|
|
|
max_loaded_banks = get_bank_names(); |
|
|
|
strip_extension(bank_names[bank],bank_name); |
|
|
|
strip_extension(bank_names[bank], bank_name); |
|
|
|
|
|
|
|
|
|
|
|
// read all voice name for actual bank
|
|
|
|
// read all voice name for actual bank
|
|
|
|
get_voice_names_from_bank(bank); |
|
|
|
get_voice_names_from_bank(bank); |
|
|
@ -253,7 +253,7 @@ void setup() |
|
|
|
lcd.clear(); |
|
|
|
lcd.clear(); |
|
|
|
ui_show_main(); |
|
|
|
ui_show_main(); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
Serial.println(F("<setup end>")); |
|
|
|
Serial.println(F("<setup end>")); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef TEST_NOTE |
|
|
|
#ifdef TEST_NOTE |
|
|
@ -352,15 +352,6 @@ void handle_input(void) |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef MASTER_KEY_MIDI |
|
|
|
|
|
|
|
int enc1_val = enc1.read(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (but1.update()) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// place handling of encoder and showing values on lcd here
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
@ -405,8 +396,7 @@ bool handle_master_key(uint8_t data) |
|
|
|
Serial.print(F("Loading voice number ")); |
|
|
|
Serial.print(F("Loading voice number ")); |
|
|
|
Serial.println(num, DEC); |
|
|
|
Serial.println(num, DEC); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOICE_ADDR, num); |
|
|
|
eeprom_write_sound(); |
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
#ifdef I2C_DISPLAY |
|
|
|
#ifdef I2C_DISPLAY |
|
|
|
lcd.show(1, 0, 2, voice + 1); |
|
|
|
lcd.show(1, 0, 2, voice + 1); |
|
|
|
lcd.show(1, 2, 1, " "); |
|
|
|
lcd.show(1, 2, 1, " "); |
|
|
@ -434,8 +424,6 @@ bool handle_master_key(uint8_t data) |
|
|
|
else if (num > 10 && num <= 20) |
|
|
|
else if (num > 10 && num <= 20) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bank = num - 10; |
|
|
|
bank = num - 10; |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_BANK_ADDR, bank); |
|
|
|
|
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Bank switch to: ")); |
|
|
|
Serial.print(F("Bank switch to: ")); |
|
|
|
Serial.println(bank, DEC); |
|
|
|
Serial.println(bank, DEC); |
|
|
@ -443,7 +431,7 @@ bool handle_master_key(uint8_t data) |
|
|
|
#ifdef I2C_DISPLAY |
|
|
|
#ifdef I2C_DISPLAY |
|
|
|
if (get_voice_names_from_bank(bank)) |
|
|
|
if (get_voice_names_from_bank(bank)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
strip_extension(bank_names[bank],bank_name); |
|
|
|
strip_extension(bank_names[bank], bank_name); |
|
|
|
lcd.show(0, 0, 2, bank + 1); |
|
|
|
lcd.show(0, 0, 2, bank + 1); |
|
|
|
lcd.show(0, 2, 1, " "); |
|
|
|
lcd.show(0, 2, 1, " "); |
|
|
|
lcd.show(0, 3, 10, bank_name); |
|
|
|
lcd.show(0, 3, 10, bank_name); |
|
|
@ -584,10 +572,7 @@ void set_volume(float v, float vr, float vl) |
|
|
|
vol_left = vl; |
|
|
|
vol_left = vl; |
|
|
|
|
|
|
|
|
|
|
|
#ifndef I2C_DISPLAY |
|
|
|
#ifndef I2C_DISPLAY |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX)); |
|
|
|
eeprom_write_volume(); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX)); |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, uint8_t(vol_left * UCHAR_MAX)); |
|
|
|
|
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
uint8_t tmp; |
|
|
|
uint8_t tmp; |
|
|
@ -706,12 +691,9 @@ void initial_values_from_eeprom(void) |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F(" - mismatch -> initializing EEPROM!")); |
|
|
|
Serial.print(F(" - mismatch -> initializing EEPROM!")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_BANK_ADDR, bank); |
|
|
|
eeprom_write_sound(); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOICE_ADDR, voice); |
|
|
|
eeprom_write_volume(); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX)); |
|
|
|
eeprom_write_midichannel(); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX)); |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, uint8_t(vol_left * UCHAR_MAX)); |
|
|
|
|
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -720,6 +702,7 @@ void initial_values_from_eeprom(void) |
|
|
|
vol = float(EEPROM.read(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR)) / UCHAR_MAX; |
|
|
|
vol = float(EEPROM.read(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR)) / UCHAR_MAX; |
|
|
|
vol_right = float(EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR)) / UCHAR_MAX; |
|
|
|
vol_right = float(EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR)) / UCHAR_MAX; |
|
|
|
vol_left = float(EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR)) / UCHAR_MAX; |
|
|
|
vol_left = float(EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR)) / UCHAR_MAX; |
|
|
|
|
|
|
|
midi_channel = EEPROM.read(EEPROM_OFFSET + EEPROM_MIDICHANNEL_ADDR); |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(); |
|
|
|
Serial.println(); |
|
|
@ -768,6 +751,36 @@ uint32_t eeprom_crc32(uint16_t calc_start, uint16_t calc_bytes) // base code fro |
|
|
|
return (crc); |
|
|
|
return (crc); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void eeprom_write_sound(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_BANK_ADDR, bank); |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOICE_ADDR, voice); |
|
|
|
|
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("Sound written to EEPROM")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void eeprom_write_volume(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX)); |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX)); |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, uint8_t(vol_left * UCHAR_MAX)); |
|
|
|
|
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("Volume written to EEPROM")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void eeprom_write_midichannel(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_MIDICHANNEL_ADDR, midi_channel); |
|
|
|
|
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("MIDI channel written to EEPROM")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
void show_cpu_and_mem_usage(void) |
|
|
|
void show_cpu_and_mem_usage(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|