Merge pull request #22 from Jackson-Devices/patch-1

Update STM32UartMasterMidiClock.ino for tested example
pull/24/head
midilab 1 year ago committed by GitHub
commit 9b7abae36b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      examples/STM32UartMasterMidiClock/STM32UartMasterMidiClock.ino

@ -1,12 +1,19 @@
/* Uart MIDI Sync Box
/* Uart MIDI out
*
* This example demonstrates how to send MIDI data via Uart
* interface on STM32 family.
*
* This example code is in the public domain.
*
* Requires STM32Duino board manager to be installed.
*
* ...
*
* Define HardwareSerial using any available UART/USART.
* Nucleo boards have UART/USART pins that are used by the ST-LINK interface (unless using solder bridging).
*
* Tested on Nucleo-F401RE and Nucleo-F072RB (PA9=D8 PA10=D2 on the Arduino pins)
*
* Code by midilab contact@midilab.co
* Example modified by Jackson Devices contact@jacksondevices.com
*/
#include <uClock.h>
@ -15,8 +22,7 @@
#define MIDI_START 0xFA
#define MIDI_STOP 0xFC
// the blue led
#define LED_BUILTIN 2
HardwareSerial Serial1(PA10, PA9);
uint8_t bpm_blink_timer = 1;
void handle_bpm_led(uint32_t tick)
@ -35,24 +41,26 @@ void handle_bpm_led(uint32_t tick)
// Internal clock handlers
void ClockOut96PPQN(uint32_t tick) {
// Send MIDI_CLOCK to external gears
//Serial.write(MIDI_CLOCK);
// Send MIDI_CLOCK to external gear
Serial1.write(MIDI_CLOCK);
handle_bpm_led(tick);
}
void onClockStart() {
//Serial.write(MIDI_START);
// Send MIDI_START to external gear
Serial1.write(MIDI_START);
}
void onClockStop() {
//Serial.write(MIDI_STOP);
// Send MIDI_STOP to external gear
Serial1.write(MIDI_STOP);
}
void setup() {
// Initialize serial communication at 31250 bits per second, the default MIDI serial speed communication:
//Serial.begin(31250);
// Initialize Serial1 communication at 31250 bits per second, the default MIDI Serial1 speed communication:
Serial1.begin(31250);
// A led to count bpms
// An led to display BPM
pinMode(LED_BUILTIN, OUTPUT);
// Setup our clock system
@ -64,7 +72,7 @@ void setup() {
uClock.setOnClockStartOutput(onClockStart);
uClock.setOnClockStopOutput(onClockStop);
// Set the clock BPM to 126 BPM
uClock.setTempo(126);
uClock.setTempo(120);
// Starts the clock, tick-tac-tick-tac...
uClock.start();
}

Loading…
Cancel
Save