summaryrefslogtreecommitdiffstats
path: root/src/app.c
diff options
context:
space:
mode:
authorDave Hodder <dave.hodder@focusrite.com>2017-01-09 14:30:20 +0000
committerDave Hodder <dave.hodder@focusrite.com>2017-01-09 14:30:20 +0000
commit59d4f28fe214601d323b2e0fb8a272040ba02a37 (patch)
tree357ea0d743432d88e20f24168e8c2da6f1bfd7fe /src/app.c
parent50778f7bbb9ba2135df5e699521a61a83dcddbc6 (diff)
downloadlaunchpad-polymaker-59d4f28fe214601d323b2e0fb8a272040ba02a37.tar.gz
launchpad-polymaker-59d4f28fe214601d323b2e0fb8a272040ba02a37.zip
tidying up ADC api
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/src/app.c b/src/app.c
index 3499d58..d4db1f9 100644
--- a/src/app.c
+++ b/src/app.c
@@ -45,8 +45,6 @@
45// In this example, we render the raw ADC data as LED rainbows. 45// In this example, we render the raw ADC data as LED rainbows.
46//______________________________________________________________________________ 46//______________________________________________________________________________
47 47
48#define PAD_COUNT 64
49
50static const u16 *g_ADC = 0; 48static const u16 *g_ADC = 0;
51 49
52//______________________________________________________________________________ 50//______________________________________________________________________________
@@ -82,33 +80,18 @@ void app_cable_event(u8 type, u8 value)
82 80
83//______________________________________________________________________________ 81//______________________________________________________________________________
84 82
85static const u8 ADC_MAP[PAD_COUNT] =
86{
87 11, 51, 12, 52, 13, 53, 14, 54,
88 15, 55, 16, 56, 17 ,57, 18, 58,
89 21, 61, 22, 62, 23, 63, 24, 64,
90 25, 65, 26, 66, 27, 67, 28, 68,
91 31, 71, 32, 72, 33, 73, 34, 74,
92 35, 75, 36, 76, 37, 77, 38, 78,
93 41, 81, 42, 82, 43, 83, 44, 84,
94 45, 85, 46, 86, 47, 87, 48, 88,
95};
96
97
98void app_timer_event() 83void app_timer_event()
99{ 84{
100 // example: render raw ADC data as LEDs 85 // render raw ADC data as LEDs
101 for (int i=0; i < PAD_COUNT; ++i) 86 for (int i=0; i < PAD_COUNT; ++i)
102 { 87 {
103 // raw adc values are 12 bit, but LEDs are 6 bit. 88 // raw adc values are 12 bit, but LEDs are 6 bit.
104 // so saturate into r;g;b for a rainbow effect to show pressure 89 // Let's saturate into r;g;b for a rainbow effect to show pressure
105 u16 r =0; 90 u16 r = 0;
106 u16 g =0; 91 u16 g = 0;
107 u16 b =0; 92 u16 b = 0;
108
109 u16 x = g_ADC[i];
110 93
111 x = (3 * MAXLED * x) >> 12; 94 u16 x = (3 * MAXLED * g_ADC[i]) >> 12;
112 95
113 if (x < MAXLED) 96 if (x < MAXLED)
114 { 97 {
@@ -134,6 +117,6 @@ void app_timer_event()
134void app_init(const u16 *adc_raw) 117void app_init(const u16 *adc_raw)
135{ 118{
136 119
137 // example - store off the raw ADC frame pointer for later use 120 // store off the raw ADC frame pointer for later use
138 g_ADC = adc_raw; 121 g_ADC = adc_raw;
139} 122}