add a guard on getTempo to avoid slave calculations before buffer gets full

pull/19/head
midilab 2 years ago
parent c2b63d362d
commit d8723b0df4
  1. 4
      src/uClock.cpp

@ -244,6 +244,10 @@ float uClockClass::getTempo()
{ {
if (mode == EXTERNAL_CLOCK) { if (mode == EXTERNAL_CLOCK) {
uint32_t acc = 0; uint32_t acc = 0;
// wait the buffer get full
if (ext_interval_buffer[EXT_INTERVAL_BUFFER_SIZE-1] == 0) {
return tempo;
}
for (uint8_t i=0; i < EXT_INTERVAL_BUFFER_SIZE; i++) { for (uint8_t i=0; i < EXT_INTERVAL_BUFFER_SIZE; i++) {
acc += ext_interval_buffer[i]; acc += ext_interval_buffer[i];
} }

Loading…
Cancel
Save