From 18ce6569bc795f774b02a80a7a4831cfe83ac8a9 Mon Sep 17 00:00:00 2001 From: DaveHodder67 Date: Thu, 2 Jul 2015 13:55:39 +0100 Subject: send MIDI clock at 125bpm --- src/app.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/app.c') diff --git a/src/app.c b/src/app.c index a5fb790..cdb41cc 100644 --- a/src/app.c +++ b/src/app.c @@ -37,6 +37,10 @@ #include "app.h" +//______________________________________________________________________________ +// +// This is where the fun is! Add your code to the callbacks below to define how +// your app behaves. //______________________________________________________________________________ void app_surface_event(u8 type, u8 index, u8 value) @@ -60,6 +64,8 @@ void app_surface_event(u8 type, u8 index, u8 value) } } +//______________________________________________________________________________ + void app_midi_event(u8 port, u8 status, u8 d1, u8 d2) { // example - MIDI interface functionality for USB "MIDI" port -> DIN port @@ -75,10 +81,15 @@ void app_midi_event(u8 port, u8 status, u8 d1, u8 d2) } } +//______________________________________________________________________________ + void app_sysex_event(u8 port, u8 * data, u16 count) { + // example - respond to UDI messages? } +//______________________________________________________________________________ + void app_aftertouch_event(u8 index, u8 value) { // example - send poly aftertouch to MIDI ports @@ -87,22 +98,39 @@ void app_aftertouch_event(u8 index, u8 value) // example - set LED to white, brightness in proportion to pressure hal_plot_led(TYPEPAD, index, value/2, value/2, value/2); } + +//______________________________________________________________________________ void app_cable_event(u8 type, u8 value) { - // example - light the Setup LED to indicate cable connection + // example - light the Setup LED to indicate cable connections if (type == MIDI_IN_CABLE) { - hal_plot_led(TYPESETUP, 0, 0, value, 0); + hal_plot_led(TYPESETUP, 0, 0, value, 0); // green } else if (type == MIDI_OUT_CABLE) { - hal_plot_led(TYPESETUP, 0, value, 0, 0); + hal_plot_led(TYPESETUP, 0, value, 0, 0); // red } } +//______________________________________________________________________________ + + void app_timer_event() { + // example - send MIDI clock at 125bpm + static const int TICK_MS = 20; + + static u8 ms = TICK_MS; + + if (++ms >= TICK_MS) + { + ms = 0; + + // send a clock pulse up the USB + hal_send_midi(USBSTANDALONE, MIDITIMINGCLOCK, 0, 0); + } } //______________________________________________________________________________ -- cgit v1.2.1