change esp32 example to avoid freezes over serial usage on isr

pull/19/head
midilab 2 years ago
parent 66e40ff420
commit 793a74ce79
  1. 11
      examples/ESP32UartMasterMidiClock/ESP32UartMasterMidiClock.ino

@ -18,6 +18,8 @@
// the blue led // the blue led
#define LED_BUILTIN 2 #define LED_BUILTIN 2
volatile bool _midi_clk_income = false;
uint8_t bpm_blink_timer = 1; uint8_t bpm_blink_timer = 1;
void handle_bpm_led(uint32_t tick) void handle_bpm_led(uint32_t tick)
{ {
@ -37,6 +39,7 @@ void handle_bpm_led(uint32_t tick)
void ClockOut96PPQN(uint32_t tick) { void ClockOut96PPQN(uint32_t tick) {
// Send MIDI_CLOCK to external gears // Send MIDI_CLOCK to external gears
//Serial.write(MIDI_CLOCK); //Serial.write(MIDI_CLOCK);
_midi_clk_income = true;
handle_bpm_led(tick); handle_bpm_led(tick);
} }
@ -71,5 +74,11 @@ void setup() {
// Do it whatever to interface with Clock.stop(), Clock.start(), Clock.setTempo() and integrate your environment... // Do it whatever to interface with Clock.stop(), Clock.start(), Clock.setTempo() and integrate your environment...
void loop() { void loop() {
// watch for income signal from uClock to fire the clock over midi
if (_midi_clk_income) {
Serial.write(MIDI_CLOCK);
noInterrupts();
_midi_clk_income = false;
interrupts();
}
} }

Loading…
Cancel
Save