fixes for examples on print bpm slave time

pull/19/head
midilab 2 years ago
parent 8a27c0c3d9
commit c2b63d362d
  1. 34
      examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino
  2. 33
      examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino

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

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

Loading…
Cancel
Save