add external buffer calculus reset and examples printBpm updated

pull/19/head
midilab 2 years ago
parent d8723b0df4
commit 4d97a1003d
  1. 17
      examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino
  2. 17
      examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino
  3. 3
      src/uClock.cpp

@ -114,18 +114,17 @@ void setup() {
} }
void printBpm(float _bpm, uint8_t col, uint8_t line) { void printBpm(float _bpm, uint8_t col, uint8_t line) {
uint8_t str_idx = 6;
// clear bpm buffer // clear bpm buffer
memset(bpm_str, ' ', 8); memset(bpm_str, ' ', 7);
// min width=3, precision=2 // min width=3, precision=2
dtostrf(_bpm, 3, 2, bpm_str); dtostrf(_bpm, 3, 1, bpm_str);
bpm_str[6] = '\0'; bpm_str[5] = '\0';
u8x8->drawUTF8(col, line, bpm_str); u8x8->drawUTF8(col, line, bpm_str);
u8x8->drawUTF8(col+7, line, "bpm"); u8x8->drawUTF8(col+5, line, "bpm");
// clear display ghost number for 2 digit // clear display ghost number for 2 digit
// coming from 3 digit bpm changes // coming from 3 digit bpm changes
if (_bpm < 100) { if (_bpm < 100) {
u8x8->drawUTF8(col+5, line, " "); u8x8->drawUTF8(col+4, line, " ");
} }
} }
@ -136,14 +135,14 @@ void loop() {
// read Serial as fast as we can on the loop // read Serial as fast as we can on the loop
if (bpm != uClock.getTempo()) { if (bpm != uClock.getTempo()) {
bpm = uClock.getTempo(); bpm = uClock.getTempo();
printBpm(bpm, 6, 7); printBpm(bpm, 8, 7);
} }
if (clock_state != uClock.state) { if (clock_state != uClock.state) {
clock_state = uClock.state; clock_state = uClock.state;
if (clock_state >= 1) { if (clock_state >= 1) {
u8x8->drawUTF8(0, 7, "play"); u8x8->drawUTF8(0, 7, "playing");
} else { } else {
u8x8->drawUTF8(0, 7, "stop"); u8x8->drawUTF8(0, 7, "stoped ");
} }
} }
if (clock_mode != uClock.getMode()) { if (clock_mode != uClock.getMode()) {

@ -123,32 +123,31 @@ void handleMidiInput() {
} }
void printBpm(float _bpm, uint8_t col, uint8_t line) { void printBpm(float _bpm, uint8_t col, uint8_t line) {
uint8_t str_idx = 6;
// clear bpm buffer // clear bpm buffer
memset(bpm_str, ' ', 8); memset(bpm_str, ' ', 7);
// min width=3, precision=2 // min width=3, precision=2
dtostrf(_bpm, 3, 2, bpm_str); dtostrf(_bpm, 3, 1, bpm_str);
bpm_str[6] = '\0'; bpm_str[5] = '\0';
u8x8->drawUTF8(col, line, bpm_str); u8x8->drawUTF8(col, line, bpm_str);
u8x8->drawUTF8(col+7, line, "bpm"); u8x8->drawUTF8(col+5, line, "bpm");
// clear display ghost number for 2 digit // clear display ghost number for 2 digit
// coming from 3 digit bpm changes // coming from 3 digit bpm changes
if (_bpm < 100) { if (_bpm < 100) {
u8x8->drawUTF8(col+5, line, " "); u8x8->drawUTF8(col+4, line, " ");
} }
} }
void loop() { void loop() {
if (bpm != uClock.getTempo()) { if (bpm != uClock.getTempo()) {
bpm = uClock.getTempo(); bpm = uClock.getTempo();
printBpm(bpm, 6, 7); printBpm(bpm, 8, 7);
} }
if (clock_state != uClock.state) { if (clock_state != uClock.state) {
clock_state = uClock.state; clock_state = uClock.state;
if (clock_state >= 1) { if (clock_state >= 1) {
u8x8->drawUTF8(0, 7, "play"); u8x8->drawUTF8(0, 7, "playing");
} else { } else {
u8x8->drawUTF8(0, 7, "stop"); u8x8->drawUTF8(0, 7, "stoped ");
} }
} }
} }

@ -289,6 +289,9 @@ void uClockClass::resetCounters()
indiv16th_counter = 0; indiv16th_counter = 0;
inmod6_counter = 0; inmod6_counter = 0;
ext_interval_idx = 0; ext_interval_idx = 0;
for (uint8_t i=0; i < EXT_INTERVAL_BUFFER_SIZE; i++) {
ext_interval_buffer[i] = 0;
}
} }
// TODO: Tap stuff // TODO: Tap stuff

Loading…
Cancel
Save