From ccb826eb04f2e9df3e9c1dd30307c2ef70641cb4 Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:33:04 +0100 Subject: [PATCH 01/10] Create AVRUartSlaveMidiClock.ino Created a basic Uart based MIDI slave clock example for AVR, tested on an Arduino Uno --- .../AVRUartSlaveMidiClock.ino | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 examples/AVRUartSlaveMidiClock/AVRUartSlaveMidiClock.ino diff --git a/examples/AVRUartSlaveMidiClock/AVRUartSlaveMidiClock.ino b/examples/AVRUartSlaveMidiClock/AVRUartSlaveMidiClock.ino new file mode 100644 index 0000000..64c52a5 --- /dev/null +++ b/examples/AVRUartSlaveMidiClock/AVRUartSlaveMidiClock.ino @@ -0,0 +1,155 @@ +/* USB MIDI Sync Slave Box Monitor + * + * This example demonstrates how to create a + * MIDI slave clock box with + * monitor support using oled display + * + * MIDI in must be provided via an opto-isolator to pin RX/D0 + * on an Arduino Uno. + * + * You need the following libraries to make it work + * - Midi Library + * - u8g2 + * - uClock + * This example code is in the public domain. + * + * Code by midilab contact@midilab.co + * Example modified by Jackson Devices contact@jacksondevices.com + */ +#include +#include + +// +// BPM Clock support +// +#include + +MIDI_CREATE_DEFAULT_INSTANCE(); +U8X8 * u8x8; + +// MIDI clock, start, stop, note on and note off byte definitions - based on MIDI 1.0 Standards. +#define MIDI_CLOCK 0xF8 +#define MIDI_START 0xFA +#define MIDI_STOP 0xFC + +float bpm = 126.0; +uint8_t bpm_blink_timer = 1; +uint8_t clock_state = 1; +uint8_t clock_mode = 0; + +void handle_bpm_led(uint32_t tick) { + // BPM led indicator + if (!(tick % (96)) || (tick == 1)) { // first compass step will flash longer + bpm_blink_timer = 8; + digitalWrite(LED_BUILTIN, HIGH); + } else if (!(tick % (24))) { // each quarter led on + digitalWrite(LED_BUILTIN, HIGH); + } else if (!(tick % bpm_blink_timer)) { // get led off + digitalWrite(LED_BUILTIN, LOW); + bpm_blink_timer = 1; + } +} + +// Internal clock handlers +void ClockOut96PPQN(uint32_t tick) { + // Send MIDI_CLOCK to external gears + MIDI.sendRealTime(MIDI_CLOCK); + handle_bpm_led(tick); +} + +void onClockStart() { + MIDI.sendRealTime(MIDI_START); +} + +void onClockStop() { + MIDI.sendRealTime(MIDI_STOP); + digitalWrite(LED_BUILTIN, LOW); +} + +// External clock handlers +void onExternalClock() { + uClock.clockMe(); +} + +void onExternalStart() { + uClock.start(); +} + +void onExternalStop() { + uClock.stop(); + digitalWrite(LED_BUILTIN, LOW); +} + +void setup() { + // + // MIDI setup + // + // Initiate MIDI communications, listen to all channels, disable soft MIDI thru + MIDI.begin(); + MIDI.turnThruOff(); +MIDI.setHandleClock(onExternalClock); + MIDI.setHandleStart(onExternalStart); + MIDI.setHandleStop(onExternalStop); + + // An led to display MIDI reception + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + // + // OLED setup + // Please check you oled model to correctly init him +// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp + // + //u8x8 = new U8X8_SH1106_128X64_NONAME_HW_I2C(U8X8_PIN_NONE); + u8x8 = new U8X8_SSD1306_128X64_NONAME_HW_I2C(U8X8_PIN_NONE); + u8x8->begin(); + u8x8->setFont(u8x8_font_pressstart2p_r); + u8x8->clear(); + u8x8->setFlipMode(true); + u8x8->drawUTF8(0, 0, "uClock"); + + // + // uClock Setup + // + uClock.init(); + uClock.setClock96PPQNOutput(ClockOut96PPQN); + // For MIDI Sync Start and Stop + uClock.setOnClockStartOutput(onClockStart); + uClock.setOnClockStopOutput(onClockStop); + uClock.setMode(uClock.EXTERNAL_CLOCK); + //uClock.setTempo(136.5); + //uClock.start(); +} + +void loop() { + while(MIDI.read()) {} + // DO NOT ADD MORE PROCESS HERE AT THE COST OF LOSING CLOCK SYNC + // Since arduino make use of Serial RX interruption we need to + // read Serial as fast as we can on the loop + if (bpm != uClock.getTempo()) { + bpm = uClock.getTempo(); + u8x8->drawUTF8(8, 7, String(bpm, 1).c_str()); + u8x8->drawUTF8(8 + 5, 7, "BPM"); + // clear display ghost number for 2 digit + // coming from 3 digit bpm changes + if (bpm < 100) { + u8x8->drawUTF8(8 + 4, 7, " "); + } + } + if (clock_state != uClock.state) { + clock_state = uClock.state; + if (clock_state >= 1) { + u8x8->drawUTF8(0, 7, "Playing"); + } else { + u8x8->drawUTF8(0, 7, "Stopped "); + } + } + if (clock_mode != uClock.getMode()) { + clock_mode = uClock.getMode(); + if (clock_mode == uClock.EXTERNAL_CLOCK) { + u8x8->drawUTF8(10, 0, "Slave "); + } else { + u8x8->drawUTF8(10, 0, "Master"); + } + } +} From 3ccc0632c337e2c945ecd183dd102320eb8ca0fc Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:34:58 +0100 Subject: [PATCH 02/10] Update LeonardoUsbSlaveMidiClockMonitor.ino Minor spelling corrections --- .../LeonardoUsbSlaveMidiClockMonitor.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino b/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino index 7b00f44..f176dc7 100644 --- a/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino +++ b/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino @@ -130,17 +130,17 @@ void loop() { if (clock_state != uClock.state) { clock_state = uClock.state; if (clock_state >= 1) { - u8x8->drawUTF8(0, 7, "playing"); + u8x8->drawUTF8(0, 7, "Playing"); } else { - u8x8->drawUTF8(0, 7, "stoped "); + u8x8->drawUTF8(0, 7, "Stopped"); } } if (clock_mode != uClock.getMode()) { clock_mode = uClock.getMode(); if (clock_mode == uClock.EXTERNAL_CLOCK) { - u8x8->drawUTF8(10, 0, "slave "); + u8x8->drawUTF8(10, 0, "Slave "); } else { - u8x8->drawUTF8(10, 0, "master"); + u8x8->drawUTF8(10, 0, "Master"); } } } From 67b4f0c73cf79b1febc64083cc48f317595b03d0 Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:39:00 +0100 Subject: [PATCH 03/10] Update TeensyUsbSlaveMidiClockMonitor.ino Match OLED code with Leonardo example --- .../TeensyUsbSlaveMidiClockMonitor.ino | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino b/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino index 2621fac..60055a5 100644 --- a/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino +++ b/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino @@ -135,9 +135,17 @@ void loop() { if (clock_state != uClock.state) { clock_state = uClock.state; if (clock_state >= 1) { - u8x8->drawUTF8(0, 7, "playing"); + u8x8->drawUTF8(0, 7, "Playing"); } else { - u8x8->drawUTF8(0, 7, "stoped "); + u8x8->drawUTF8(0, 7, "Stopped"); + } + } + if (clock_mode != uClock.getMode()) { + clock_mode = uClock.getMode(); + if (clock_mode == uClock.EXTERNAL_CLOCK) { + u8x8->drawUTF8(10, 0, "Slave "); + } else { + u8x8->drawUTF8(10, 0, "Master"); } } } From 57ac22ece66e04b2a12804cbe1ae89391eab8d7f Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:02:57 +0100 Subject: [PATCH 04/10] Update TeensyUsbSlaveMidiClockMonitor.ino --- .../TeensyUsbSlaveMidiClockMonitor.ino | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino b/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino index 60055a5..0517902 100644 --- a/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino +++ b/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino @@ -1,7 +1,8 @@ /* USB MIDI Sync Slave Box Monitor * * This example demonstrates how to create a - * MIDI hid compilant slave clock box with + * MIDI hid compilant slave clock box using + * Teensy LC, 3.x and 4.x with * monitor support using oled displays * * Making use of a 250 usceconds timer to @@ -32,6 +33,7 @@ IntervalTimer teensyTimer; float bpm = 126; uint8_t bpm_blink_timer = 1; uint8_t clock_state = 1; +uint8_t clock_mode = 0; void handle_bpm_led(uint32_t tick) { @@ -95,10 +97,12 @@ void setup() { // OLED setup // Please check you oled model to correctly init him // - u8x8 = new U8X8_SH1106_128X64_NONAME_HW_I2C(U8X8_PIN_NONE); + //u8x8 = new U8X8_SH1106_128X64_NONAME_HW_I2C(U8X8_PIN_NONE); + u8x8 = new U8X8_SSD1306_128X64_NONAME_HW_I2C(U8X8_PIN_NONE); u8x8->begin(); u8x8->setFont(u8x8_font_pressstart2p_r); u8x8->clear(); + //u8x8->setFlipMode(true); u8x8->drawUTF8(0, 0, "uClock"); // From 7156d8a55b7f35d1b1038be38023577c556cbefb Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:08:56 +0100 Subject: [PATCH 05/10] Update TeensyUsbSlaveMidiClock.ino added Teensy 4.x --- examples/TeensyUsbSlaveMidiClock/TeensyUsbSlaveMidiClock.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/TeensyUsbSlaveMidiClock/TeensyUsbSlaveMidiClock.ino b/examples/TeensyUsbSlaveMidiClock/TeensyUsbSlaveMidiClock.ino index 7a0475d..5a017b3 100644 --- a/examples/TeensyUsbSlaveMidiClock/TeensyUsbSlaveMidiClock.ino +++ b/examples/TeensyUsbSlaveMidiClock/TeensyUsbSlaveMidiClock.ino @@ -1,7 +1,7 @@ /* USB MIDI Sync Slave Box * * This example demonstrates how to change the USB MIDI - * device name on Teensy LC and 3.x. When creating more + * device name on Teensy LC, 3.x and 4.x. When creating more * that one MIDI device, custom names are much easier to * use when selecting each device in MIDI software on * your PC or Mac. The custom name is in the "name.c" tab. From 41424e246a1e6cfb733df37c1fc97e8167825722 Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:09:55 +0100 Subject: [PATCH 06/10] Update TeensyUsbMasterMidiClock.ino added 4.x --- examples/TeensyUsbMasterMidiClock/TeensyUsbMasterMidiClock.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/TeensyUsbMasterMidiClock/TeensyUsbMasterMidiClock.ino b/examples/TeensyUsbMasterMidiClock/TeensyUsbMasterMidiClock.ino index 542b7b5..ad10e3c 100644 --- a/examples/TeensyUsbMasterMidiClock/TeensyUsbMasterMidiClock.ino +++ b/examples/TeensyUsbMasterMidiClock/TeensyUsbMasterMidiClock.ino @@ -1,7 +1,7 @@ /* USB MIDI Sync Box * * This example demonstrates how to change the USB MIDI - * device name on Teensy LC and 3.x. When creating more + * device name on Teensy LC, 3.x and 4.x. When creating more * that one MIDI device, custom names are much easier to * use when selecting each device in MIDI software on * your PC or Mac. The custom name is in the "name.c" tab. From 33cdcfa114108b3124da3ffee90762a7b89857f0 Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:18:20 +0100 Subject: [PATCH 07/10] Create AVRUartSlaveMidiClockMonitor.ino --- .../AVRUartSlaveMidiClockMonitor.ino | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 examples/AVRUartSlaveMidiClockMonitor/AVRUartSlaveMidiClockMonitor.ino diff --git a/examples/AVRUartSlaveMidiClockMonitor/AVRUartSlaveMidiClockMonitor.ino b/examples/AVRUartSlaveMidiClockMonitor/AVRUartSlaveMidiClockMonitor.ino new file mode 100644 index 0000000..1b255f0 --- /dev/null +++ b/examples/AVRUartSlaveMidiClockMonitor/AVRUartSlaveMidiClockMonitor.ino @@ -0,0 +1,155 @@ +/* Uart MIDI Sync Slave Box Monitor + * + * This example demonstrates how to create a + * MIDI slave clock box with + * monitor support using oled display + * + * MIDI in must be provided via an opto-isolator to pin RX/D0 + * Tested on an Arduino Uno. + * + * You need the following libraries to make it work + * - Midi Library + * - u8g2 + * - uClock + * This example code is in the public domain. + * + * Code by midilab contact@midilab.co + * Example modified by Jackson Devices contact@jacksondevices.com + */ +#include +#include + +// +// BPM Clock support +// +#include + +MIDI_CREATE_DEFAULT_INSTANCE(); +U8X8 * u8x8; + +// MIDI clock, start, stop, note on and note off byte definitions - based on MIDI 1.0 Standards. +#define MIDI_CLOCK 0xF8 +#define MIDI_START 0xFA +#define MIDI_STOP 0xFC + +float bpm = 126.0; +uint8_t bpm_blink_timer = 1; +uint8_t clock_state = 1; +uint8_t clock_mode = 0; + +void handle_bpm_led(uint32_t tick) { + // BPM led indicator + if (!(tick % (96)) || (tick == 1)) { // first compass step will flash longer + bpm_blink_timer = 8; + digitalWrite(LED_BUILTIN, HIGH); + } else if (!(tick % (24))) { // each quarter led on + digitalWrite(LED_BUILTIN, HIGH); + } else if (!(tick % bpm_blink_timer)) { // get led off + digitalWrite(LED_BUILTIN, LOW); + bpm_blink_timer = 1; + } +} + +// Internal clock handlers +void ClockOut96PPQN(uint32_t tick) { + // Send MIDI_CLOCK to external gears + MIDI.sendRealTime(MIDI_CLOCK); + handle_bpm_led(tick); +} + +void onClockStart() { + MIDI.sendRealTime(MIDI_START); +} + +void onClockStop() { + MIDI.sendRealTime(MIDI_STOP); + digitalWrite(LED_BUILTIN, LOW); +} + +// External clock handlers +void onExternalClock() { + uClock.clockMe(); +} + +void onExternalStart() { + uClock.start(); +} + +void onExternalStop() { + uClock.stop(); + digitalWrite(LED_BUILTIN, LOW); +} + +void setup() { + // + // MIDI setup + // + // Initiate MIDI communications, listen to all channels, disable soft MIDI thru + MIDI.begin(); + MIDI.turnThruOff(); +MIDI.setHandleClock(onExternalClock); + MIDI.setHandleStart(onExternalStart); + MIDI.setHandleStop(onExternalStop); + + // An led to display MIDI reception + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + // + // OLED setup + // Please check you oled model to correctly init him +// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp + // + //u8x8 = new U8X8_SH1106_128X64_NONAME_HW_I2C(U8X8_PIN_NONE); + u8x8 = new U8X8_SSD1306_128X64_NONAME_HW_I2C(U8X8_PIN_NONE); + u8x8->begin(); + u8x8->setFont(u8x8_font_pressstart2p_r); + u8x8->clear(); + u8x8->setFlipMode(true); + u8x8->drawUTF8(0, 0, "uClock"); + + // + // uClock Setup + // + uClock.init(); + uClock.setClock96PPQNOutput(ClockOut96PPQN); + // For MIDI Sync Start and Stop + uClock.setOnClockStartOutput(onClockStart); + uClock.setOnClockStopOutput(onClockStop); + uClock.setMode(uClock.EXTERNAL_CLOCK); + //uClock.setTempo(136.5); + //uClock.start(); +} + +void loop() { + while(MIDI.read()) {} + // DO NOT ADD MORE PROCESS HERE AT THE COST OF LOSING CLOCK SYNC + // Since arduino make use of Serial RX interruption we need to + // read Serial as fast as we can on the loop + if (bpm != uClock.getTempo()) { + bpm = uClock.getTempo(); + u8x8->drawUTF8(8, 7, String(bpm, 1).c_str()); + u8x8->drawUTF8(8 + 5, 7, "BPM"); + // clear display ghost number for 2 digit + // coming from 3 digit bpm changes + if (bpm < 100) { + u8x8->drawUTF8(8 + 4, 7, " "); + } + } + if (clock_state != uClock.state) { + clock_state = uClock.state; + if (clock_state >= 1) { + u8x8->drawUTF8(0, 7, "Playing"); + } else { + u8x8->drawUTF8(0, 7, "Stopped "); + } + } + if (clock_mode != uClock.getMode()) { + clock_mode = uClock.getMode(); + if (clock_mode == uClock.EXTERNAL_CLOCK) { + u8x8->drawUTF8(10, 0, "Slave "); + } else { + u8x8->drawUTF8(10, 0, "Master"); + } + } +} From ad75ec755e28f480a6e78f735c29bb3960171945 Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:22:15 +0100 Subject: [PATCH 08/10] Delete examples/AVRUartSlaveMidiClock directory wrong file and directory name --- .../AVRUartSlaveMidiClock.ino | 155 ------------------ 1 file changed, 155 deletions(-) delete mode 100644 examples/AVRUartSlaveMidiClock/AVRUartSlaveMidiClock.ino diff --git a/examples/AVRUartSlaveMidiClock/AVRUartSlaveMidiClock.ino b/examples/AVRUartSlaveMidiClock/AVRUartSlaveMidiClock.ino deleted file mode 100644 index 64c52a5..0000000 --- a/examples/AVRUartSlaveMidiClock/AVRUartSlaveMidiClock.ino +++ /dev/null @@ -1,155 +0,0 @@ -/* USB MIDI Sync Slave Box Monitor - * - * This example demonstrates how to create a - * MIDI slave clock box with - * monitor support using oled display - * - * MIDI in must be provided via an opto-isolator to pin RX/D0 - * on an Arduino Uno. - * - * You need the following libraries to make it work - * - Midi Library - * - u8g2 - * - uClock - * This example code is in the public domain. - * - * Code by midilab contact@midilab.co - * Example modified by Jackson Devices contact@jacksondevices.com - */ -#include -#include - -// -// BPM Clock support -// -#include - -MIDI_CREATE_DEFAULT_INSTANCE(); -U8X8 * u8x8; - -// MIDI clock, start, stop, note on and note off byte definitions - based on MIDI 1.0 Standards. -#define MIDI_CLOCK 0xF8 -#define MIDI_START 0xFA -#define MIDI_STOP 0xFC - -float bpm = 126.0; -uint8_t bpm_blink_timer = 1; -uint8_t clock_state = 1; -uint8_t clock_mode = 0; - -void handle_bpm_led(uint32_t tick) { - // BPM led indicator - if (!(tick % (96)) || (tick == 1)) { // first compass step will flash longer - bpm_blink_timer = 8; - digitalWrite(LED_BUILTIN, HIGH); - } else if (!(tick % (24))) { // each quarter led on - digitalWrite(LED_BUILTIN, HIGH); - } else if (!(tick % bpm_blink_timer)) { // get led off - digitalWrite(LED_BUILTIN, LOW); - bpm_blink_timer = 1; - } -} - -// Internal clock handlers -void ClockOut96PPQN(uint32_t tick) { - // Send MIDI_CLOCK to external gears - MIDI.sendRealTime(MIDI_CLOCK); - handle_bpm_led(tick); -} - -void onClockStart() { - MIDI.sendRealTime(MIDI_START); -} - -void onClockStop() { - MIDI.sendRealTime(MIDI_STOP); - digitalWrite(LED_BUILTIN, LOW); -} - -// External clock handlers -void onExternalClock() { - uClock.clockMe(); -} - -void onExternalStart() { - uClock.start(); -} - -void onExternalStop() { - uClock.stop(); - digitalWrite(LED_BUILTIN, LOW); -} - -void setup() { - // - // MIDI setup - // - // Initiate MIDI communications, listen to all channels, disable soft MIDI thru - MIDI.begin(); - MIDI.turnThruOff(); -MIDI.setHandleClock(onExternalClock); - MIDI.setHandleStart(onExternalStart); - MIDI.setHandleStop(onExternalStop); - - // An led to display MIDI reception - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - // - // OLED setup - // Please check you oled model to correctly init him -// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp - // - //u8x8 = new U8X8_SH1106_128X64_NONAME_HW_I2C(U8X8_PIN_NONE); - u8x8 = new U8X8_SSD1306_128X64_NONAME_HW_I2C(U8X8_PIN_NONE); - u8x8->begin(); - u8x8->setFont(u8x8_font_pressstart2p_r); - u8x8->clear(); - u8x8->setFlipMode(true); - u8x8->drawUTF8(0, 0, "uClock"); - - // - // uClock Setup - // - uClock.init(); - uClock.setClock96PPQNOutput(ClockOut96PPQN); - // For MIDI Sync Start and Stop - uClock.setOnClockStartOutput(onClockStart); - uClock.setOnClockStopOutput(onClockStop); - uClock.setMode(uClock.EXTERNAL_CLOCK); - //uClock.setTempo(136.5); - //uClock.start(); -} - -void loop() { - while(MIDI.read()) {} - // DO NOT ADD MORE PROCESS HERE AT THE COST OF LOSING CLOCK SYNC - // Since arduino make use of Serial RX interruption we need to - // read Serial as fast as we can on the loop - if (bpm != uClock.getTempo()) { - bpm = uClock.getTempo(); - u8x8->drawUTF8(8, 7, String(bpm, 1).c_str()); - u8x8->drawUTF8(8 + 5, 7, "BPM"); - // clear display ghost number for 2 digit - // coming from 3 digit bpm changes - if (bpm < 100) { - u8x8->drawUTF8(8 + 4, 7, " "); - } - } - if (clock_state != uClock.state) { - clock_state = uClock.state; - if (clock_state >= 1) { - u8x8->drawUTF8(0, 7, "Playing"); - } else { - u8x8->drawUTF8(0, 7, "Stopped "); - } - } - if (clock_mode != uClock.getMode()) { - clock_mode = uClock.getMode(); - if (clock_mode == uClock.EXTERNAL_CLOCK) { - u8x8->drawUTF8(10, 0, "Slave "); - } else { - u8x8->drawUTF8(10, 0, "Master"); - } - } -} From 865f04864b1cec8f2695dce2f3347ffdc0ea8641 Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:39:57 +0100 Subject: [PATCH 09/10] Update LeonardoUsbSlaveMidiClockMonitor.ino --- .../LeonardoUsbSlaveMidiClockMonitor.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino b/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino index f176dc7..491d861 100644 --- a/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino +++ b/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino @@ -120,7 +120,7 @@ void loop() { if (bpm != uClock.getTempo()) { bpm = uClock.getTempo(); u8x8->drawUTF8(8, 7, String(bpm, 1).c_str()); - u8x8->drawUTF8(8+5, 7, "bpm"); + u8x8->drawUTF8(8+5, 7, "BPM"); // clear display ghost number for 2 digit // coming from 3 digit bpm changes if (bpm < 100) { From 633b5f8520e633d34209b3a2eeda4a1d6f4793c5 Mon Sep 17 00:00:00 2001 From: Jackson-Devices <123213412+Jackson-Devices@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:43:33 +0100 Subject: [PATCH 10/10] Update TeensyUsbSlaveMidiClockMonitor.ino --- .../TeensyUsbSlaveMidiClockMonitor.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino b/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino index 0517902..1c05c0e 100644 --- a/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino +++ b/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino @@ -102,7 +102,7 @@ void setup() { u8x8->begin(); u8x8->setFont(u8x8_font_pressstart2p_r); u8x8->clear(); - //u8x8->setFlipMode(true); + u8x8->setFlipMode(true); u8x8->drawUTF8(0, 0, "uClock"); // @@ -129,7 +129,7 @@ void loop() { if (bpm != uClock.getTempo()) { bpm = uClock.getTempo(); u8x8->drawUTF8(8, 7, String(bpm, 1).c_str()); - u8x8->drawUTF8(8+5, 7, "bpm"); + u8x8->drawUTF8(8+5, 7, "BPM"); // clear display ghost number for 2 digit // coming from 3 digit bpm changes if (bpm < 100) {