summaryrefslogtreecommitdiffstats
path: root/src/app.c
diff options
context:
space:
mode:
authorDaveHodder67 <dave.hodder@focusrite.com>2015-07-02 13:55:39 +0100
committerDaveHodder67 <dave.hodder@focusrite.com>2015-07-02 13:55:39 +0100
commit18ce6569bc795f774b02a80a7a4831cfe83ac8a9 (patch)
treee38de35e1307b025e328e06b6d65fef8ea7d01e2 /src/app.c
parentec9c000a36953bdae95d4555164bf4ea129bb0d9 (diff)
downloadlaunchpad-polymaker-18ce6569bc795f774b02a80a7a4831cfe83ac8a9.tar.gz
launchpad-polymaker-18ce6569bc795f774b02a80a7a4831cfe83ac8a9.zip
send MIDI clock at 125bpm
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/app.c b/src/app.c
index a5fb790..cdb41cc 100644
--- a/src/app.c
+++ b/src/app.c
@@ -38,6 +38,10 @@
38#include "app.h" 38#include "app.h"
39 39
40//______________________________________________________________________________ 40//______________________________________________________________________________
41//
42// This is where the fun is! Add your code to the callbacks below to define how
43// your app behaves.
44//______________________________________________________________________________
41 45
42void app_surface_event(u8 type, u8 index, u8 value) 46void app_surface_event(u8 type, u8 index, u8 value)
43{ 47{
@@ -60,6 +64,8 @@ void app_surface_event(u8 type, u8 index, u8 value)
60 } 64 }
61} 65}
62 66
67//______________________________________________________________________________
68
63void app_midi_event(u8 port, u8 status, u8 d1, u8 d2) 69void app_midi_event(u8 port, u8 status, u8 d1, u8 d2)
64{ 70{
65 // example - MIDI interface functionality for USB "MIDI" port -> DIN port 71 // 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)
75 } 81 }
76} 82}
77 83
84//______________________________________________________________________________
85
78void app_sysex_event(u8 port, u8 * data, u16 count) 86void app_sysex_event(u8 port, u8 * data, u16 count)
79{ 87{
88 // example - respond to UDI messages?
80} 89}
81 90
91//______________________________________________________________________________
92
82void app_aftertouch_event(u8 index, u8 value) 93void app_aftertouch_event(u8 index, u8 value)
83{ 94{
84 // example - send poly aftertouch to MIDI ports 95 // example - send poly aftertouch to MIDI ports
@@ -87,22 +98,39 @@ void app_aftertouch_event(u8 index, u8 value)
87 // example - set LED to white, brightness in proportion to pressure 98 // example - set LED to white, brightness in proportion to pressure
88 hal_plot_led(TYPEPAD, index, value/2, value/2, value/2); 99 hal_plot_led(TYPEPAD, index, value/2, value/2, value/2);
89} 100}
101
102//______________________________________________________________________________
90 103
91void app_cable_event(u8 type, u8 value) 104void app_cable_event(u8 type, u8 value)
92{ 105{
93 // example - light the Setup LED to indicate cable connection 106 // example - light the Setup LED to indicate cable connections
94 if (type == MIDI_IN_CABLE) 107 if (type == MIDI_IN_CABLE)
95 { 108 {
96 hal_plot_led(TYPESETUP, 0, 0, value, 0); 109 hal_plot_led(TYPESETUP, 0, 0, value, 0); // green
97 } 110 }
98 else if (type == MIDI_OUT_CABLE) 111 else if (type == MIDI_OUT_CABLE)
99 { 112 {
100 hal_plot_led(TYPESETUP, 0, value, 0, 0); 113 hal_plot_led(TYPESETUP, 0, value, 0, 0); // red
101 } 114 }
102} 115}
103 116
117//______________________________________________________________________________
118
119
104void app_timer_event() 120void app_timer_event()
105{ 121{
122 // example - send MIDI clock at 125bpm
123 static const int TICK_MS = 20;
124
125 static u8 ms = TICK_MS;
126
127 if (++ms >= TICK_MS)
128 {
129 ms = 0;
130
131 // send a clock pulse up the USB
132 hal_send_midi(USBSTANDALONE, MIDITIMINGCLOCK, 0, 0);
133 }
106} 134}
107 135
108//______________________________________________________________________________ 136//______________________________________________________________________________