Fixing bank upload.

pull/32/head
Holger Wirtz 5 years ago
parent 1ff6ea3d5f
commit f29d26d7d6
  1. 41
      MicroDexed.ino
  2. 35
      UI.hpp
  3. 4
      config.h
  4. 32
      dexed_sd.cpp

@ -1151,34 +1151,48 @@ void handleSystemExclusive(byte * sysex, uint len)
LCDML.loop_menu();
}
}
else if (len == 4104 && strlen(receive_bank_filename) > 0 && LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sysex_receive_bank))
else if (len == 4104)
{
if (strlen(receive_bank_filename) > 0 && LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sysex_receive_bank))
{
int32_t bulk_checksum_calc = 0;
int8_t bulk_checksum = sysex[4102];
// 1 Bank bulk upload
#ifdef DEBUG
Serial.println(F("Bank bulk upload"));
#endif
if ((sysex[3] & 0x7f) != 9)
{
#ifdef DEBUG
Serial.println(F("E: Not a SysEx bank bulk upload."));
#endif
lcd.setCursor(0, 1);
lcd.print(F("Error (TYPE) "));
delay(MESSAGE_WAIT_TIME);
LCDML.FUNC_goBackToMenu();
return;
}
#ifdef DEBUG
Serial.println(F("Bank bulk upload."));
#endif
if (((sysex[4] << 7) | sysex[5]) != 0x1000)
{
#ifdef DEBUG
Serial.println(F("E: Wrong length for SysEx bank bulk upload (not 4096)."));
#endif
lcd.setCursor(0, 1);
lcd.print(F("Error (SIZE) "));
delay(MESSAGE_WAIT_TIME);
LCDML.FUNC_goBackToMenu();
return;
}
#ifdef DEBUG
Serial.println(F("Bank type ok"));
#endif
// checksum calculation
for (uint8_t i = 0; i < 4096 ; i++)
for (uint16_t i = 0; i < 4096 ; i++)
{
bulk_checksum_calc -= sysex[i + 6];
}
@ -1193,9 +1207,17 @@ void handleSystemExclusive(byte * sysex, uint len)
Serial.print(bulk_checksum_calc, HEX);
Serial.println(F("]"));
#endif
lcd.setCursor(0, 1);
lcd.print(F("Error (CHECKSUM)"));
delay(MESSAGE_WAIT_TIME);
LCDML.FUNC_goBackToMenu();
return;
}
#ifdef DEBUG
Serial.println(F("Bank checksum ok"));
#endif
if (save_sd_bank(receive_bank_filename, sysex))
{
#ifdef DEBUG
@ -1207,6 +1229,8 @@ void handleSystemExclusive(byte * sysex, uint len)
lcd.print(F("Done. "));
delay(MESSAGE_WAIT_TIME);
LCDML.FUNC_goBackToMenu();
//if (!get_bank_name(bank_number, bank_name, sizeof(bank_name)))
// strncpy(bank_name, "*ERROR*", 7);
}
else
{
@ -1222,6 +1246,11 @@ void handleSystemExclusive(byte * sysex, uint len)
}
memset(receive_bank_filename, 0, FILENAME_LEN);
}
#ifdef DEBUG
else
Serial.println(F("E: Not in MIDI receive bank mode."));
#endif
}
#ifdef DEBUG
else
Serial.println(F("E: SysEx parameter length wrong."));

@ -266,6 +266,7 @@ void lcd_active_instance_number(uint8_t instance_id);
void lcd_OP_active_instance_number(uint8_t instance_id, uint8_t op);
void lcd_special_chars(uint8_t mode);
void eeprom_update_var(uint16_t pos, uint8_t val, const char* val_string);
void string_trim(char *s);
// normal menu
LCDMenuLib2_menu LCDML_0(255, 0, 0, NULL, NULL); // normal root menu element (do not change)
@ -4693,13 +4694,14 @@ void UI_func_sysex_receive_bank(uint8_t param)
yesno = false;
mode = 0;
bank_number = configuration.performance.bank[selected_instance_id];
memset(receive_bank_filename, 0, sizeof(receive_bank_filename));
lcd.setCursor(0, 0);
lcd.print(F("MIDI Recv Bank"));
lcd.setCursor(0, 1);
lcd.print(F("[ ]"));
if (!get_bank_name(configuration.performance.bank[selected_instance_id], receive_bank_filename, sizeof(receive_bank_filename)))
strncpy(receive_bank_filename, "*ERROR*", sizeof(receive_bank_filename));
strncpy(receive_bank_filename, "*ERROR*", 7);
lcd.show(1, 1, 2, bank_number);
lcd.show(1, 5, 10, receive_bank_filename);
}
@ -4715,7 +4717,7 @@ void UI_func_sysex_receive_bank(uint8_t param)
case 0:
bank_number = constrain(bank_number + ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1);
if (!get_bank_name(bank_number, receive_bank_filename, sizeof(receive_bank_filename)))
strncpy(receive_bank_filename, "*ERROR*", sizeof(receive_bank_filename));
strncpy(receive_bank_filename, "*ERROR*", 7);
lcd.show(1, 1, 2, bank_number);
lcd.show(1, 5, 10, receive_bank_filename);
break;
@ -4762,7 +4764,7 @@ void UI_func_sysex_receive_bank(uint8_t param)
if (!strncmp(receive_bank_filename, "*ERROR*", sizeof(receive_bank_filename)))
{
yesno = true;
strncpy(receive_bank_filename, "EMPTY", BANK_NAME_LEN);
strncpy(receive_bank_filename, "NONAME", 6);
mode += 2;
lcd.blink();
}
@ -4788,8 +4790,22 @@ void UI_func_sysex_receive_bank(uint8_t param)
{
if (yesno == true)
{
#ifdef DEBUG
Serial.print(F("Bank name: ["));
Serial.print(receive_bank_filename);
Serial.println(F("]"));
#endif
char tmp[FILENAME_LEN];
strncpy(tmp, receive_bank_filename, strlen(receive_bank_filename));
sprintf(receive_bank_filename, "/%d/%s.syx", bank_number, tmp);
#ifdef DEBUG
Serial.print(F("Receiving into bank "));
Serial.print(bank_number);
Serial.print(F(" as filename "));
Serial.print(receive_bank_filename);
Serial.println(F("."));
#endif
mode = 0xff;
lcd.noBlink();
lcd.setCursor(0, 1);
lcd.print(F("Waiting... "));
@ -5133,6 +5149,8 @@ bool UI_select_name(uint8_t y, uint8_t x, char* edit_string, uint8_t len, bool i
{
edit_pos = 0;
edit_mode = false;
string_trim(edit_string);
return (true);
}
else
@ -5467,5 +5485,14 @@ void eeprom_update_var(uint16_t pos, uint8_t val, const char* val_string)
EEPROM.update(EEPROM_START_ADDRESS + pos, val);
}
void string_trim(char *s)
{
int i;
while (isspace (*s)) s++; // skip left side white spaces
for (i = strlen (s) - 1; (isspace (s[i])); i--) ; // skip right side white spaces
s[i + 1] = '\0';
}
#endif
#endif

@ -45,7 +45,8 @@
//
// e.g.:
// * sendmidi dev "MicroDexed MIDI" on 80 127 && sleep 1.0 && sendmidi dev "MicroDexed MIDI" off 80 0
// * sendmidi dev "MicroDexed MIDI" syx syf addon/SD/90/RitCh1.syx
// * sendmidi dev "MicroDexed MIDI" syf addon/SD/90/RitCh1.syx
// * amidi -p hw:2,0,0 -s addon/SD/90/RitCh1.syx
//
// Receiving and storing MIDI SYSEX with Linux:
// amidi -p hw:2,0,0 -d -r /tmp/bkup1.syx
@ -53,6 +54,7 @@
// For SYSEX Bank upload via USB:
// sed -i.orig 's/SYSEX_MAX_LEN = 290/SYSEX_MAX_LEN = 4104/' /usr/local/arduino-teensy-1.8.12/hardware/teensy/avr/libraries/USBHost_t36/USBHost_t36.h
// sed -i.orig 's/^#define USB_MIDI_SYSEX_MAX 290/#define USB_MIDI_SYSEX_MAX 4104/' /usr/local/arduino-teensy-1.8.12/hardware/teensy/avr/cores/teensy3/usb_midi.h
#define USB_MIDI_SYSEX_MAX 4104
#define VERSION "0.9.9k"

@ -292,11 +292,18 @@ bool put_sd_voice(File sysex, uint8_t voice_number, uint8_t* data)
bool save_sd_bank(const char* bank_filename, uint8_t* data)
{
char tmp[FILENAME_LEN];
char tmp2[FILENAME_LEN];
int bank_number;
File root, entry;
if (sd_card > 0)
{
#ifdef DEBUG
Serial.print(F("Trying so store "));
Serial.print(bank_filename);
Serial.println(F("."));
#endif
// first remove old bank
sscanf(bank_filename, "/%d/%s", &bank_number, tmp);
sprintf(tmp, "/%d", bank_number);
@ -314,8 +321,20 @@ bool save_sd_bank(const char* bank_filename, uint8_t* data)
Serial.print(F("/"));
Serial.println(entry.name());
#endif
SD.remove(entry.name());
sprintf(tmp2, "%s/%s", tmp, entry.name());
entry.close();
#ifndef DEBUG
SD.remove(tmp2);
#else
bool r = SD.remove(tmp2);
if (r == false)
{
Serial.print(F("E: cannot remove "));
Serial.print(tmp2);
Serial.println(F("."));
}
#endif
break;
}
}
else
@ -326,13 +345,16 @@ bool save_sd_bank(const char* bank_filename, uint8_t* data)
root.close();
// store new bank at /<b>/<bank_name>.syx
root = SD.open(bank_filename);
root.write(data, 4104);
root.close();
#ifdef DEBUG
Serial.print(F("Storing bank as "));
Serial.print(bank_filename);
Serial.println(F("."));
Serial.print(F("..."));
#endif
root = SD.open(bank_filename, FILE_WRITE);
root.write(data, 4104);
root.close();
#ifdef DEBUG
Serial.println(F(" done."));
#endif
}
else

Loading…
Cancel
Save