|
|
@ -637,13 +637,11 @@ void setup() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
LCDML.OTHER_jumpToFunc(UI_func_voice_select); |
|
|
|
LCDML.OTHER_jumpToFunc(UI_func_voice_select); |
|
|
|
|
|
|
|
timer1.begin(sequencer, 90000, false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
timer1.begin(sequencer, 74'000,false); |
|
|
|
void loop() |
|
|
|
|
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void loop() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// MIDI input handling
|
|
|
|
// MIDI input handling
|
|
|
|
check_midi_devices(); |
|
|
|
check_midi_devices(); |
|
|
|
|
|
|
|
|
|
|
@ -659,7 +657,7 @@ void setup() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (seq_step != seq_UI_last_step) |
|
|
|
if (seq_step != seq_UI_last_step) |
|
|
|
{ |
|
|
|
{ |
|
|
|
seq_UI_last_step=seq_step; |
|
|
|
seq_UI_last_step = seq_step; |
|
|
|
if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sequencer)) //is in UI of Sequencer
|
|
|
|
if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sequencer)) //is in UI of Sequencer
|
|
|
|
{ |
|
|
|
{ |
|
|
|
lcd.setCursor(seq_step, 1); |
|
|
|
lcd.setCursor(seq_step, 1); |
|
|
@ -763,13 +761,13 @@ void setup() |
|
|
|
show_cpu_and_mem_usage(); |
|
|
|
show_cpu_and_mem_usage(); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
/******************************************************************************
|
|
|
|
MIDI MESSAGE HANDLER |
|
|
|
MIDI MESSAGE HANDLER |
|
|
|
******************************************************************************/ |
|
|
|
******************************************************************************/ |
|
|
|
void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) |
|
|
|
void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Check for MicroDexed
|
|
|
|
// Check for MicroDexed
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -856,11 +854,11 @@ void setup() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if NUM_DRUMS > 0 |
|
|
|
#if NUM_DRUMS > 0 |
|
|
|
uint8_t drum_get_slot(uint8_t dt) |
|
|
|
uint8_t drum_get_slot(uint8_t dt) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (uint8_t i = 0; i < NUM_DRUMS; i++) |
|
|
|
for (uint8_t i = 0; i < NUM_DRUMS; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!Drum[i]->isPlaying()) |
|
|
|
if (!Drum[i]->isPlaying()) |
|
|
@ -887,11 +885,11 @@ void setup() |
|
|
|
drum_type[drum_counter % 4] = dt; |
|
|
|
drum_type[drum_counter % 4] = dt; |
|
|
|
drum_counter++; |
|
|
|
drum_counter++; |
|
|
|
return (drum_counter - 1 % 4); |
|
|
|
return (drum_counter - 1 % 4); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity) |
|
|
|
void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (checkMidiChannel(inChannel, instance_id)) |
|
|
|
if (checkMidiChannel(inChannel, instance_id)) |
|
|
@ -916,10 +914,10 @@ void setup() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleControlChange(byte inChannel, byte inCtrl, byte inValue) |
|
|
|
void handleControlChange(byte inChannel, byte inCtrl, byte inValue) |
|
|
|
{ |
|
|
|
{ |
|
|
|
inCtrl = constrain(inCtrl, 0, 127); |
|
|
|
inCtrl = constrain(inCtrl, 0, 127); |
|
|
|
inValue = constrain(inValue, 0, 127); |
|
|
|
inValue = constrain(inValue, 0, 127); |
|
|
|
|
|
|
|
|
|
|
@ -1132,10 +1130,10 @@ void setup() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleAfterTouch(byte inChannel, byte inPressure) |
|
|
|
void handleAfterTouch(byte inChannel, byte inPressure) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (checkMidiChannel(inChannel, instance_id)) |
|
|
|
if (checkMidiChannel(inChannel, instance_id)) |
|
|
@ -1144,10 +1142,10 @@ void setup() |
|
|
|
MicroDexed[instance_id]->ControllersRefresh(); |
|
|
|
MicroDexed[instance_id]->ControllersRefresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handlePitchBend(byte inChannel, int inPitch) |
|
|
|
void handlePitchBend(byte inChannel, int inPitch) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (checkMidiChannel(inChannel, instance_id)) |
|
|
|
if (checkMidiChannel(inChannel, instance_id)) |
|
|
@ -1155,10 +1153,10 @@ void setup() |
|
|
|
MicroDexed[instance_id]->setPitchbend(inPitch); |
|
|
|
MicroDexed[instance_id]->setPitchbend(inPitch); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleProgramChange(byte inChannel, byte inProgram) |
|
|
|
void handleProgramChange(byte inChannel, byte inProgram) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (checkMidiChannel(inChannel, instance_id)) |
|
|
|
if (checkMidiChannel(inChannel, instance_id)) |
|
|
@ -1178,10 +1176,10 @@ void setup() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleSystemExclusive(byte * sysex, uint len) |
|
|
|
void handleSystemExclusive(byte * sysex, uint len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!checkMidiChannel((sysex[2] & 0x0f) + 1 , instance_id)) |
|
|
|
if (!checkMidiChannel((sysex[2] & 0x0f) + 1 , instance_id)) |
|
|
@ -1580,30 +1578,30 @@ void setup() |
|
|
|
Serial.println(F("E: SysEx parameter length wrong.")); |
|
|
|
Serial.println(F("E: SysEx parameter length wrong.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleTimeCodeQuarterFrame(byte data) |
|
|
|
void handleTimeCodeQuarterFrame(byte data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleAfterTouchPoly(byte inChannel, byte inNumber, byte inVelocity) |
|
|
|
void handleAfterTouchPoly(byte inChannel, byte inNumber, byte inVelocity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleSongSelect(byte inSong) |
|
|
|
void handleSongSelect(byte inSong) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleTuneRequest(void) |
|
|
|
void handleTuneRequest(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleClock(void) |
|
|
|
void handleClock(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (midi_bpm_counter % 24 == 0) |
|
|
|
if (midi_bpm_counter % 24 == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
midi_bpm = (60000.0f / float(midi_bpm_timer) + 0.5); |
|
|
|
midi_bpm = (60000.0f / float(midi_bpm_timer) + 0.5); |
|
|
@ -1654,32 +1652,32 @@ void setup() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
midi_bpm_counter++; |
|
|
|
midi_bpm_counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleStart(void) |
|
|
|
void handleStart(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
midi_bpm_timer = 0; |
|
|
|
midi_bpm_timer = 0; |
|
|
|
midi_bpm_counter = 0; |
|
|
|
midi_bpm_counter = 0; |
|
|
|
_midi_bpm = -1; |
|
|
|
_midi_bpm = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleContinue(void) |
|
|
|
void handleContinue(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleStop(void) |
|
|
|
void handleStop(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleActiveSensing(void) |
|
|
|
void handleActiveSensing(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleSystemReset(void) |
|
|
|
void handleSystemReset(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
@ -1689,13 +1687,13 @@ void setup() |
|
|
|
MicroDexed[instance_id]->panic(); |
|
|
|
MicroDexed[instance_id]->panic(); |
|
|
|
MicroDexed[instance_id]->resetControllers(); |
|
|
|
MicroDexed[instance_id]->resetControllers(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
/******************************************************************************
|
|
|
|
MIDI HELPER |
|
|
|
MIDI HELPER |
|
|
|
******************************************************************************/ |
|
|
|
******************************************************************************/ |
|
|
|
bool checkMidiChannel(byte inChannel, uint8_t instance_id) |
|
|
|
bool checkMidiChannel(byte inChannel, uint8_t instance_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// check for MIDI channel
|
|
|
|
// check for MIDI channel
|
|
|
|
if (configuration.dexed[instance_id].midi_channel == MIDI_CHANNEL_OMNI) |
|
|
|
if (configuration.dexed[instance_id].midi_channel == MIDI_CHANNEL_OMNI) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1715,10 +1713,10 @@ void setup() |
|
|
|
return (false); |
|
|
|
return (false); |
|
|
|
} |
|
|
|
} |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void init_MIDI_send_CC(void) |
|
|
|
void init_MIDI_send_CC(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println("init_MIDI_send_CC():"); |
|
|
|
Serial.println("init_MIDI_send_CC():"); |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -1732,14 +1730,14 @@ void setup() |
|
|
|
MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 105, configuration.fx.delay_time[selected_instance_id]); |
|
|
|
MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 105, configuration.fx.delay_time[selected_instance_id]); |
|
|
|
MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 106, configuration.fx.delay_feedback[selected_instance_id]); |
|
|
|
MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 106, configuration.fx.delay_feedback[selected_instance_id]); |
|
|
|
MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 107, configuration.fx.delay_level[selected_instance_id]); |
|
|
|
MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 107, configuration.fx.delay_level[selected_instance_id]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
/******************************************************************************
|
|
|
|
VOLUME HELPER |
|
|
|
VOLUME HELPER |
|
|
|
******************************************************************************/ |
|
|
|
******************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
void set_volume(uint8_t v, uint8_t m) |
|
|
|
void set_volume(uint8_t v, uint8_t m) |
|
|
|
{ |
|
|
|
{ |
|
|
|
configuration.sys.vol = v; |
|
|
|
configuration.sys.vol = v; |
|
|
|
|
|
|
|
|
|
|
|
if (configuration.sys.vol > 100) |
|
|
|
if (configuration.sys.vol > 100) |
|
|
@ -1780,14 +1778,14 @@ void setup() |
|
|
|
mono2stereo[instance_id]->panorama(mapfloat(PANORAMA_MIN, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); |
|
|
|
mono2stereo[instance_id]->panorama(mapfloat(PANORAMA_MIN, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
/******************************************************************************
|
|
|
|
EEPROM HELPER |
|
|
|
EEPROM HELPER |
|
|
|
******************************************************************************/ |
|
|
|
******************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
void initial_values_from_eeprom(bool init) |
|
|
|
void initial_values_from_eeprom(bool init) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint16_t _m_; |
|
|
|
uint16_t _m_; |
|
|
|
|
|
|
|
|
|
|
|
if (init == true) |
|
|
|
if (init == true) |
|
|
@ -1834,28 +1832,28 @@ void setup() |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
show_configuration(); |
|
|
|
show_configuration(); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void check_configuration(void) |
|
|
|
void check_configuration(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
check_configuration_sys(); |
|
|
|
check_configuration_sys(); |
|
|
|
check_configuration_fx(); |
|
|
|
check_configuration_fx(); |
|
|
|
check_configuration_performance(); |
|
|
|
check_configuration_performance(); |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
check_configuration_dexed(instance_id); |
|
|
|
check_configuration_dexed(instance_id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void check_configuration_sys(void) |
|
|
|
void check_configuration_sys(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
configuration.sys.instances = constrain(configuration.sys.instances, INSTANCES_MIN, INSTANCES_MAX); |
|
|
|
configuration.sys.instances = constrain(configuration.sys.instances, INSTANCES_MIN, INSTANCES_MAX); |
|
|
|
configuration.sys.vol = constrain(configuration.sys.vol, VOLUME_MIN, VOLUME_MAX); |
|
|
|
configuration.sys.vol = constrain(configuration.sys.vol, VOLUME_MIN, VOLUME_MAX); |
|
|
|
configuration.sys.mono = constrain(configuration.sys.mono, MONO_MIN, MONO_MAX); |
|
|
|
configuration.sys.mono = constrain(configuration.sys.mono, MONO_MIN, MONO_MAX); |
|
|
|
configuration.sys.soft_midi_thru = constrain(configuration.sys.soft_midi_thru, SOFT_MIDI_THRU_MIN, SOFT_MIDI_THRU_MAX); |
|
|
|
configuration.sys.soft_midi_thru = constrain(configuration.sys.soft_midi_thru, SOFT_MIDI_THRU_MIN, SOFT_MIDI_THRU_MAX); |
|
|
|
configuration.sys.performance_number = constrain(configuration.sys.performance_number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX); |
|
|
|
configuration.sys.performance_number = constrain(configuration.sys.performance_number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void check_configuration_fx(void) |
|
|
|
void check_configuration_fx(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef USE_PLATEREVERB |
|
|
|
#ifdef USE_PLATEREVERB |
|
|
|
configuration.fx.reverb_lowpass = constrain(configuration.fx.reverb_lowpass, REVERB_LOWPASS_MIN, REVERB_LOWPASS_MAX); |
|
|
|
configuration.fx.reverb_lowpass = constrain(configuration.fx.reverb_lowpass, REVERB_LOWPASS_MIN, REVERB_LOWPASS_MAX); |
|
|
|
configuration.fx.reverb_lodamp = constrain(configuration.fx.reverb_lodamp, REVERB_LODAMP_MIN, REVERB_LODAMP_MAX); |
|
|
|
configuration.fx.reverb_lodamp = constrain(configuration.fx.reverb_lodamp, REVERB_LODAMP_MIN, REVERB_LODAMP_MAX); |
|
|
@ -1881,10 +1879,10 @@ void setup() |
|
|
|
configuration.fx.delay_sync[instance_id] = constrain(configuration.fx.delay_sync[instance_id], DELAY_SYNC_MIN, DELAY_SYNC_MAX); |
|
|
|
configuration.fx.delay_sync[instance_id] = constrain(configuration.fx.delay_sync[instance_id], DELAY_SYNC_MIN, DELAY_SYNC_MAX); |
|
|
|
configuration.fx.reverb_send[instance_id] = constrain(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX); |
|
|
|
configuration.fx.reverb_send[instance_id] = constrain(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void check_configuration_performance(void) |
|
|
|
void check_configuration_performance(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
configuration.performance.fx_number = constrain(configuration.performance.fx_number, FX_NUM_MIN, FX_NUM_MAX); |
|
|
|
configuration.performance.fx_number = constrain(configuration.performance.fx_number, FX_NUM_MIN, FX_NUM_MAX); |
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
@ -1893,10 +1891,10 @@ void setup() |
|
|
|
configuration.performance.voice[instance_id] = constrain(configuration.performance.voice[instance_id], 0, MAX_VOICES - 1); |
|
|
|
configuration.performance.voice[instance_id] = constrain(configuration.performance.voice[instance_id], 0, MAX_VOICES - 1); |
|
|
|
configuration.performance.voiceconfig_number[instance_id] = constrain(configuration.performance.voiceconfig_number[instance_id], VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); |
|
|
|
configuration.performance.voiceconfig_number[instance_id] = constrain(configuration.performance.voiceconfig_number[instance_id], VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void check_configuration_dexed(uint8_t instance_id) |
|
|
|
void check_configuration_dexed(uint8_t instance_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
configuration.dexed[instance_id].midi_channel = constrain(configuration.dexed[instance_id].midi_channel, MIDI_CHANNEL_MIN, MIDI_CHANNEL_MAX); |
|
|
|
configuration.dexed[instance_id].midi_channel = constrain(configuration.dexed[instance_id].midi_channel, MIDI_CHANNEL_MIN, MIDI_CHANNEL_MAX); |
|
|
|
configuration.dexed[instance_id].lowest_note = constrain(configuration.dexed[instance_id].lowest_note, INSTANCE_LOWEST_NOTE_MIN, INSTANCE_LOWEST_NOTE_MAX); |
|
|
|
configuration.dexed[instance_id].lowest_note = constrain(configuration.dexed[instance_id].lowest_note, INSTANCE_LOWEST_NOTE_MIN, INSTANCE_LOWEST_NOTE_MAX); |
|
|
|
configuration.dexed[instance_id].highest_note = constrain(configuration.dexed[instance_id].highest_note, INSTANCE_HIGHEST_NOTE_MIN, INSTANCE_HIGHEST_NOTE_MAX); |
|
|
|
configuration.dexed[instance_id].highest_note = constrain(configuration.dexed[instance_id].highest_note, INSTANCE_HIGHEST_NOTE_MIN, INSTANCE_HIGHEST_NOTE_MAX); |
|
|
@ -1926,10 +1924,10 @@ void setup() |
|
|
|
configuration.dexed[instance_id].portamento_glissando = constrain(configuration.dexed[instance_id].portamento_glissando, PORTAMENTO_GLISSANDO_MIN, PORTAMENTO_GLISSANDO_MAX); |
|
|
|
configuration.dexed[instance_id].portamento_glissando = constrain(configuration.dexed[instance_id].portamento_glissando, PORTAMENTO_GLISSANDO_MIN, PORTAMENTO_GLISSANDO_MAX); |
|
|
|
configuration.dexed[instance_id].portamento_time = constrain(configuration.dexed[instance_id].portamento_time, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX); |
|
|
|
configuration.dexed[instance_id].portamento_time = constrain(configuration.dexed[instance_id].portamento_time, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX); |
|
|
|
configuration.dexed[instance_id].op_enabled = constrain(configuration.dexed[instance_id].op_enabled, OP_ENABLED_MIN, OP_ENABLED_MAX); |
|
|
|
configuration.dexed[instance_id].op_enabled = constrain(configuration.dexed[instance_id].op_enabled, OP_ENABLED_MIN, OP_ENABLED_MAX); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void init_configuration(void) |
|
|
|
void init_configuration(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("INITIALIZING CONFIGURATION")); |
|
|
|
Serial.println(F("INITIALIZING CONFIGURATION")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -2013,17 +2011,17 @@ void setup() |
|
|
|
set_volume(configuration.sys.vol, configuration.sys.mono); |
|
|
|
set_volume(configuration.sys.vol, configuration.sys.mono); |
|
|
|
|
|
|
|
|
|
|
|
eeprom_update(); |
|
|
|
eeprom_update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void eeprom_update(void) |
|
|
|
void eeprom_update(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t* c = (uint8_t*)&configuration; |
|
|
|
uint8_t* c = (uint8_t*)&configuration; |
|
|
|
for (uint16_t i = 0; i < sizeof(configuration); i++) |
|
|
|
for (uint16_t i = 0; i < sizeof(configuration); i++) |
|
|
|
EEPROM.update(EEPROM_START_ADDRESS + i, c[i]); |
|
|
|
EEPROM.update(EEPROM_START_ADDRESS + i, c[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void eeprom_update_sys(void) |
|
|
|
void eeprom_update_sys(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t* c = (uint8_t*)&configuration.sys; |
|
|
|
uint8_t* c = (uint8_t*)&configuration.sys; |
|
|
|
|
|
|
|
|
|
|
|
for (uint16_t i = 0; i < sizeof(configuration.sys); i++) |
|
|
|
for (uint16_t i = 0; i < sizeof(configuration.sys); i++) |
|
|
@ -2032,16 +2030,16 @@ void setup() |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("Updating EEPROM sys.")); |
|
|
|
Serial.println(F("Updating EEPROM sys.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool eeprom_get_sys(void) |
|
|
|
bool eeprom_get_sys(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, sys), configuration.sys); |
|
|
|
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, sys), configuration.sys); |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void eeprom_update_fx(void) |
|
|
|
void eeprom_update_fx(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t* c = (uint8_t*)&configuration.fx; |
|
|
|
uint8_t* c = (uint8_t*)&configuration.fx; |
|
|
|
|
|
|
|
|
|
|
|
for (uint16_t i = 0; i < sizeof(configuration.fx); i++) |
|
|
|
for (uint16_t i = 0; i < sizeof(configuration.fx); i++) |
|
|
@ -2050,16 +2048,16 @@ void setup() |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("Updating EEPROM fx.")); |
|
|
|
Serial.println(F("Updating EEPROM fx.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool eeprom_get_fx(void) |
|
|
|
bool eeprom_get_fx(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, fx), configuration.fx); |
|
|
|
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, fx), configuration.fx); |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void eeprom_update_dexed(uint8_t instance_id) |
|
|
|
void eeprom_update_dexed(uint8_t instance_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if NUM_DEXED == 1 |
|
|
|
#if NUM_DEXED == 1 |
|
|
|
uint8_t* c = (uint8_t*)&configuration.dexed[0]; |
|
|
|
uint8_t* c = (uint8_t*)&configuration.dexed[0]; |
|
|
|
|
|
|
|
|
|
|
@ -2087,10 +2085,10 @@ void setup() |
|
|
|
Serial.print(instance_id); |
|
|
|
Serial.print(instance_id); |
|
|
|
Serial.println(F(").")); |
|
|
|
Serial.println(F(").")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool eeprom_get_dexed(uint8_t instance_id) |
|
|
|
bool eeprom_get_dexed(uint8_t instance_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (uint8_t instance_id = 0; instance_id < MAX_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < MAX_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (instance_id == 0) |
|
|
|
if (instance_id == 0) |
|
|
@ -2099,31 +2097,31 @@ void setup() |
|
|
|
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[1]), configuration.dexed[1]); |
|
|
|
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[1]), configuration.dexed[1]); |
|
|
|
} |
|
|
|
} |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void eeprom_update_performance() |
|
|
|
void eeprom_update_performance() |
|
|
|
{ |
|
|
|
{ |
|
|
|
EEPROM.put(EEPROM_START_ADDRESS + offsetof(configuration_s, performance), configuration.performance); |
|
|
|
EEPROM.put(EEPROM_START_ADDRESS + offsetof(configuration_s, performance), configuration.performance); |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("Updating EEPROM performance.")); |
|
|
|
Serial.println(F("Updating EEPROM performance.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool eeprom_get_performance() |
|
|
|
bool eeprom_get_performance() |
|
|
|
{ |
|
|
|
{ |
|
|
|
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, performance), configuration.performance); |
|
|
|
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, performance), configuration.performance); |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("Getting EEPROM performance.")); |
|
|
|
Serial.println(F("Getting EEPROM performance.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
/******************************************************************************
|
|
|
|
PARAMETER-HELPERS |
|
|
|
PARAMETER-HELPERS |
|
|
|
******************************************************************************/ |
|
|
|
******************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
void set_fx_params(void) |
|
|
|
void set_fx_params(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if defined(USE_FX) |
|
|
|
#if defined(USE_FX) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2210,10 +2208,10 @@ void setup() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
init_MIDI_send_CC(); |
|
|
|
init_MIDI_send_CC(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void set_voiceconfig_params(uint8_t instance_id) |
|
|
|
void set_voiceconfig_params(uint8_t instance_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// INIT PEAK MIXER
|
|
|
|
// INIT PEAK MIXER
|
|
|
|
microdexed_peak_mixer.gain(instance_id, 1.0); |
|
|
|
microdexed_peak_mixer.gain(instance_id, 1.0); |
|
|
|
|
|
|
|
|
|
|
@ -2234,36 +2232,36 @@ void setup() |
|
|
|
|
|
|
|
|
|
|
|
// PANORAMA
|
|
|
|
// PANORAMA
|
|
|
|
mono2stereo[instance_id]->panorama(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); |
|
|
|
mono2stereo[instance_id]->panorama(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void set_sys_params(void) |
|
|
|
void set_sys_params(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// set initial volume
|
|
|
|
// set initial volume
|
|
|
|
set_volume(configuration.sys.vol, configuration.sys.mono); |
|
|
|
set_volume(configuration.sys.vol, configuration.sys.mono); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
/******************************************************************************
|
|
|
|
HELPERS |
|
|
|
HELPERS |
|
|
|
******************************************************************************/ |
|
|
|
******************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
// https://www.reddit.com/r/Teensy/comments/7r19uk/reset_and_reboot_teensy_lc_via_code/
|
|
|
|
// https://www.reddit.com/r/Teensy/comments/7r19uk/reset_and_reboot_teensy_lc_via_code/
|
|
|
|
#define SCB_AIRCR (*(volatile uint32_t *)0xE000ED0C) // Application Interrupt and Reset Control location
|
|
|
|
#define SCB_AIRCR (*(volatile uint32_t *)0xE000ED0C) // Application Interrupt and Reset Control location
|
|
|
|
void _softRestart(void) |
|
|
|
void _softRestart(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Serial.end(); //clears the serial monitor if used
|
|
|
|
Serial.end(); //clears the serial monitor if used
|
|
|
|
SCB_AIRCR = 0x05FA0004; //write value for restart
|
|
|
|
SCB_AIRCR = 0x05FA0004; //write value for restart
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
float pseudo_log_curve(float value) |
|
|
|
float pseudo_log_curve(float value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//return (mapfloat(_pseudo_log * arm_sin_f32(value), 0.0, _pseudo_log * arm_sin_f32(1.0), 0.0, 1.0));
|
|
|
|
//return (mapfloat(_pseudo_log * arm_sin_f32(value), 0.0, _pseudo_log * arm_sin_f32(1.0), 0.0, 1.0));
|
|
|
|
//return (1 - sqrt(1 - value * value));
|
|
|
|
//return (1 - sqrt(1 - value * value));
|
|
|
|
//return (pow(2, value) - 1);
|
|
|
|
//return (pow(2, value) - 1);
|
|
|
|
return (pow(value, 2.2)); |
|
|
|
return (pow(value, 2.2)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https://www.arduino.cc/en/Tutorial/EEPROMCrc
|
|
|
|
uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https://www.arduino.cc/en/Tutorial/EEPROMCrc
|
|
|
|
{ |
|
|
|
{ |
|
|
|
const uint32_t crc_table[16] = |
|
|
|
const uint32_t crc_table[16] = |
|
|
|
{ |
|
|
|
{ |
|
|
|
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, |
|
|
|
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, |
|
|
@ -2281,10 +2279,10 @@ void setup() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return (crc); |
|
|
|
return (crc); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void generate_version_string(char* buffer, uint8_t len) |
|
|
|
void generate_version_string(char* buffer, uint8_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char tmp[3]; |
|
|
|
char tmp[3]; |
|
|
|
|
|
|
|
|
|
|
|
memset(buffer, 0, len); |
|
|
|
memset(buffer, 0, len); |
|
|
@ -2304,21 +2302,21 @@ void setup() |
|
|
|
itoa (MAX_NOTES, tmp, 10); |
|
|
|
itoa (MAX_NOTES, tmp, 10); |
|
|
|
strncat(buffer, tmp, 2); |
|
|
|
strncat(buffer, tmp, 2); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DISPLAY_LCD_SPI |
|
|
|
#ifdef DISPLAY_LCD_SPI |
|
|
|
void change_disp_sd(bool disp) |
|
|
|
void change_disp_sd(bool disp) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (sd_card > 0) |
|
|
|
if (sd_card > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
digitalWrite(sd_card, disp); |
|
|
|
digitalWrite(sd_card, disp); |
|
|
|
digitalWrite(U8X8_CS_PIN, !disp); |
|
|
|
digitalWrite(U8X8_CS_PIN, !disp); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
uint8_t check_sd_cards(void) |
|
|
|
uint8_t check_sd_cards(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t ret = 0; |
|
|
|
uint8_t ret = 0; |
|
|
|
|
|
|
|
|
|
|
|
memset(sd_string, 0, sizeof(sd_string)); |
|
|
|
memset(sd_string, 0, sizeof(sd_string)); |
|
|
@ -2416,10 +2414,10 @@ void setup() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
return (ret); |
|
|
|
return (ret); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void check_and_create_directories(void) |
|
|
|
void check_and_create_directories(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (sd_card > 0) |
|
|
|
if (sd_card > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t i; |
|
|
|
uint8_t i; |
|
|
@ -2527,14 +2525,14 @@ void setup() |
|
|
|
Serial.println(F("No SD card for directory check available.")); |
|
|
|
Serial.println(F("No SD card for directory check available.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
/******************************************************************************
|
|
|
|
DEBUG HELPER |
|
|
|
DEBUG HELPER |
|
|
|
******************************************************************************/ |
|
|
|
******************************************************************************/ |
|
|
|
#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) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t sum_xrun = 0; |
|
|
|
uint32_t sum_xrun = 0; |
|
|
|
uint16_t sum_render_time_max = 0; |
|
|
|
uint16_t sum_render_time_max = 0; |
|
|
|
|
|
|
|
|
|
|
@ -2604,12 +2602,12 @@ void setup() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
void show_configuration(void) |
|
|
|
void show_configuration(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Serial.println(); |
|
|
|
Serial.println(); |
|
|
|
Serial.println(F("CONFIGURATION:")); |
|
|
|
Serial.println(F("CONFIGURATION:")); |
|
|
|
Serial.println(F("System")); |
|
|
|
Serial.println(F("System")); |
|
|
@ -2685,10 +2683,10 @@ void setup() |
|
|
|
|
|
|
|
|
|
|
|
Serial.println(); |
|
|
|
Serial.println(); |
|
|
|
Serial.flush(); |
|
|
|
Serial.flush(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void show_patch(uint8_t instance_id) |
|
|
|
void show_patch(uint8_t instance_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char vn[VOICE_NAME_LEN]; |
|
|
|
char vn[VOICE_NAME_LEN]; |
|
|
|
|
|
|
|
|
|
|
|
Serial.print(F("INSTANCE ")); |
|
|
|
Serial.print(F("INSTANCE ")); |
|
|
@ -2793,30 +2791,30 @@ void setup() |
|
|
|
Serial.println(F(" |")); |
|
|
|
Serial.println(F(" |")); |
|
|
|
Serial.println(F("+=========+=========+=========+=========+==========+==========+=========+==================================+")); |
|
|
|
Serial.println(F("+=========+=========+=========+=========+==========+==========+=========+==================================+")); |
|
|
|
Serial.println(F("+==========================================================================================================+")); |
|
|
|
Serial.println(F("+==========================================================================================================+")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SerialPrintFormatInt3(uint8_t num) |
|
|
|
void SerialPrintFormatInt3(uint8_t num) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char buf[4]; |
|
|
|
char buf[4]; |
|
|
|
sprintf(buf, "%3d", num); |
|
|
|
sprintf(buf, "%3d", num); |
|
|
|
Serial.print(buf); |
|
|
|
Serial.print(buf); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef TEENSY3_6 |
|
|
|
#ifdef TEENSY3_6 |
|
|
|
/* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */ |
|
|
|
/* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */ |
|
|
|
extern "C" char* sbrk(int incr); |
|
|
|
extern "C" char* sbrk(int incr); |
|
|
|
uint32_t FreeMem(void) |
|
|
|
uint32_t FreeMem(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char top; |
|
|
|
char top; |
|
|
|
return &top - reinterpret_cast<char*>(sbrk(0)); |
|
|
|
return &top - reinterpret_cast<char*>(sbrk(0)); |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
/* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */ |
|
|
|
/* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */ |
|
|
|
extern unsigned long _heap_end; |
|
|
|
extern unsigned long _heap_end; |
|
|
|
extern char *__brkval; |
|
|
|
extern char *__brkval; |
|
|
|
int FreeMem(void) |
|
|
|
int FreeMem(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return (char *)&_heap_end - __brkval; |
|
|
|
return (char *)&_heap_end - __brkval; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|