ADC using MODDMA and then sending the sampled value encapsulated in an OSC message

Dependencies:   EthernetNetIf mbed

Committer:
Wahaj
Date:
Mon Jun 25 13:13:42 2012 +0000
Revision:
1:887b266205f3
Parent:
0:c6ffbdc6661d

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wahaj 0:c6ffbdc6661d 1 #include "mbed.h"
Wahaj 0:c6ffbdc6661d 2 #include "MODDMA.h"
Wahaj 0:c6ffbdc6661d 3 #include "mbedOSC.h"
Wahaj 0:c6ffbdc6661d 4
Wahaj 0:c6ffbdc6661d 5
Wahaj 0:c6ffbdc6661d 6 // How long between grabbing samples on all channels.
Wahaj 0:c6ffbdc6661d 7 // Value is in microseconds.
Wahaj 0:c6ffbdc6661d 8 #define SAMPLE_PERIOD 10000//////10ms sampling of all adc pins
Wahaj 0:c6ffbdc6661d 9 #define NUM_OF_SAMPLES 6
Wahaj 0:c6ffbdc6661d 10
Wahaj 0:c6ffbdc6661d 11
Wahaj 0:c6ffbdc6661d 12 //// ETHERNET
Wahaj 0:c6ffbdc6661d 13 // Ethernet can be created with *either* an address assigned by DHCP or a static IP address. Uncomment the define line for DHCP
Wahaj 0:c6ffbdc6661d 14 //#define DHCP
Wahaj 0:c6ffbdc6661d 15 #ifdef DHCP
Wahaj 0:c6ffbdc6661d 16 EthernetNetIf eth;
Wahaj 0:c6ffbdc6661d 17 #else
Wahaj 0:c6ffbdc6661d 18 EthernetNetIf eth(
Wahaj 0:c6ffbdc6661d 19 IpAddr(192,168,1,1), //IP Address
Wahaj 0:c6ffbdc6661d 20 IpAddr(255,255,255,0), //Network Mask
Wahaj 0:c6ffbdc6661d 21 IpAddr(), //Gateway
Wahaj 0:c6ffbdc6661d 22 IpAddr() //DNS
Wahaj 0:c6ffbdc6661d 23 );
Wahaj 0:c6ffbdc6661d 24 #endif
Wahaj 0:c6ffbdc6661d 25
Wahaj 0:c6ffbdc6661d 26
Wahaj 0:c6ffbdc6661d 27
Wahaj 0:c6ffbdc6661d 28 DigitalOut led1(LED1);
Wahaj 0:c6ffbdc6661d 29 DigitalOut led2(LED2);
Wahaj 0:c6ffbdc6661d 30 DigitalOut led3(LED3);
Wahaj 0:c6ffbdc6661d 31 DigitalOut led4(LED4);
Wahaj 0:c6ffbdc6661d 32
Wahaj 0:c6ffbdc6661d 33 //// OSC
Wahaj 0:c6ffbdc6661d 34 // The object to do the work of sending and receiving
Wahaj 0:c6ffbdc6661d 35 OSCClass osc;
Wahaj 0:c6ffbdc6661d 36 // The message objects to send and receive with
Wahaj 0:c6ffbdc6661d 37 OSCMessage recMes;
Wahaj 0:c6ffbdc6661d 38 OSCMessage sendMes;
Wahaj 0:c6ffbdc6661d 39 // Setting - The port we're listening to on the mbed for OSC messages
Wahaj 0:c6ffbdc6661d 40 int mbedListenPort = 9000;
Wahaj 0:c6ffbdc6661d 41 // Setting - The address and port we're going to send to, from the mbed
Wahaj 0:c6ffbdc6661d 42 uint8_t destIp[] = { 192, 168, 1, 2};
Wahaj 0:c6ffbdc6661d 43 int destPort = 8000;
Wahaj 0:c6ffbdc6661d 44 //// Our messageReceivedCallback function
Wahaj 0:c6ffbdc6661d 45 void processOSC()
Wahaj 0:c6ffbdc6661d 46 {
Wahaj 0:c6ffbdc6661d 47 // If this function has been called, the OSC message just received will have been parsed into our recMes OSCMessage object
Wahaj 0:c6ffbdc6661d 48 // Note we can access recMes here, outside of the main loop, as we created it as a global variable.
Wahaj 0:c6ffbdc6661d 49 // TASK: If this message one we want, do something about it.
Wahaj 0:c6ffbdc6661d 50 // In this example we're listening for messages with a top address of "mbed".
Wahaj 0:c6ffbdc6661d 51 // Note the strcmp function returns 0 if identical, so !strcmp is true if the two strings are the same
Wahaj 0:c6ffbdc6661d 52 if ( !strcmp( recMes.getAddress(0) , "mbed" ) ) {
Wahaj 0:c6ffbdc6661d 53 printf("OSC Message received addressed to mbed \r\n");
Wahaj 0:c6ffbdc6661d 54 if ( !strcmp( recMes.getAddress(1) , "test1" ) )
Wahaj 0:c6ffbdc6661d 55 printf("Received subAddress= test1 \r\n");
Wahaj 0:c6ffbdc6661d 56 // Send some osc message:
Wahaj 0:c6ffbdc6661d 57 sendMes.setTopAddress("/working...");
Wahaj 0:c6ffbdc6661d 58 osc.sendOsc(&sendMes);
Wahaj 0:c6ffbdc6661d 59 }
Wahaj 0:c6ffbdc6661d 60 led1=!led1;
Wahaj 0:c6ffbdc6661d 61 }
Wahaj 0:c6ffbdc6661d 62
Wahaj 0:c6ffbdc6661d 63
Wahaj 0:c6ffbdc6661d 64 uint32_t adBuffer[NUM_OF_SAMPLES];
Wahaj 0:c6ffbdc6661d 65 bool dmaTransferComplete;
Wahaj 0:c6ffbdc6661d 66
Wahaj 0:c6ffbdc6661d 67 MODDMA dma;
Wahaj 0:c6ffbdc6661d 68 MODDMA_Config *conf;
Wahaj 0:c6ffbdc6661d 69
Wahaj 0:c6ffbdc6661d 70
Wahaj 0:c6ffbdc6661d 71 void TC0_callback(void); /////DMA Transmission
Wahaj 0:c6ffbdc6661d 72 void ERR0_callback(void);
Wahaj 0:c6ffbdc6661d 73 void Sensor_Tap(int chan, uint32_t value1); //////Sending OSC
Wahaj 0:c6ffbdc6661d 74
Wahaj 0:c6ffbdc6661d 75 extern "C" void TIMER1_handler(void) __irq ////// Aka Wahaj bhai!!! yeah im talking to myself ...this function is called
Wahaj 0:c6ffbdc6661d 76 { ///when i want to sample the analgue pins using burst mode and reseting the DMA and timer Configuration for the next sample
Wahaj 0:c6ffbdc6661d 77 led2 = !led2; // Show life
Wahaj 0:c6ffbdc6661d 78 //uint32_t dummyADC = LPC_ADC->ADGDR;
Wahaj 0:c6ffbdc6661d 79 dma.Setup( conf ); // Pre-prep a transfer
Wahaj 0:c6ffbdc6661d 80 dma.Enable( conf );
Wahaj 0:c6ffbdc6661d 81 LPC_ADC->ADCR |= (1UL << 16); // ADC burst mode
Wahaj 0:c6ffbdc6661d 82 LPC_ADC->ADINTEN = 0x100; // Do all channels.
Wahaj 0:c6ffbdc6661d 83 LPC_TIM1->IR = 1; // Clr timer1 irq.
Wahaj 0:c6ffbdc6661d 84 }
Wahaj 0:c6ffbdc6661d 85
Wahaj 0:c6ffbdc6661d 86 int main()
Wahaj 0:c6ffbdc6661d 87 {
Wahaj 0:c6ffbdc6661d 88
Wahaj 0:c6ffbdc6661d 89 //// TASK: Set up the Ethernet port
Wahaj 0:c6ffbdc6661d 90 printf("Setting up ethernet...\r\n");
Wahaj 0:c6ffbdc6661d 91 EthernetErr ethErr = eth.setup();
Wahaj 0:c6ffbdc6661d 92 if (ethErr) {
Wahaj 0:c6ffbdc6661d 93 printf("Ethernet Failed to setup. Error: %d\r\n", ethErr);
Wahaj 0:c6ffbdc6661d 94 return -1;
Wahaj 0:c6ffbdc6661d 95 }
Wahaj 0:c6ffbdc6661d 96 printf("Ethernet OK\r\n");
Wahaj 0:c6ffbdc6661d 97 //// TASK: Set up OSC message sending
Wahaj 0:c6ffbdc6661d 98 // In the OSC message container we've made for send messages, set where we want it to go:
Wahaj 0:c6ffbdc6661d 99 sendMes.setIp( destIp );
Wahaj 0:c6ffbdc6661d 100 sendMes.setPort( destPort );
Wahaj 0:c6ffbdc6661d 101 //// TASK: Set up OSC message receiving
Wahaj 0:c6ffbdc6661d 102 // In the OSC send/receive object...
Wahaj 0:c6ffbdc6661d 103 // Set the OSC message container for it to parse received messages into
Wahaj 0:c6ffbdc6661d 104 osc.setReceiveMessage(&recMes);
Wahaj 0:c6ffbdc6661d 105 // Tell it to begin listening for OSC messages at the port specified (the IP address we know already, it's the mbed's!).
Wahaj 0:c6ffbdc6661d 106 osc.begin(mbedListenPort);
Wahaj 0:c6ffbdc6661d 107 // Rather than constantly checking to see whether there are new messages waiting, the object can call some code of ours to run when a message is received.
Wahaj 0:c6ffbdc6661d 108 // This line does that, attaching a callback function we've written before getting to this point, in this case it's called processOSC
Wahaj 0:c6ffbdc6661d 109 // For more info how this works, see http://mbed.org/cookbook/FunctionPointer
Wahaj 0:c6ffbdc6661d 110 osc.messageReceivedCallback.attach(&processOSC);
Wahaj 0:c6ffbdc6661d 111
Wahaj 0:c6ffbdc6661d 112
Wahaj 0:c6ffbdc6661d 113
Wahaj 0:c6ffbdc6661d 114
Wahaj 0:c6ffbdc6661d 115
Wahaj 0:c6ffbdc6661d 116 ///////////////DMA AND ADC//////////
Wahaj 0:c6ffbdc6661d 117
Wahaj 0:c6ffbdc6661d 118 memset(adBuffer, 0, sizeof(adBuffer));
Wahaj 0:c6ffbdc6661d 119
Wahaj 0:c6ffbdc6661d 120
Wahaj 0:c6ffbdc6661d 121 // Power up the ADC and set PCLK-----Configuraion
Wahaj 0:c6ffbdc6661d 122 LPC_SC->PCONP |= (1UL << 12);
Wahaj 0:c6ffbdc6661d 123 LPC_SC->PCLKSEL0 |= (3UL << 24); // PCLK = CCLK/8 96M/8 = 12MHz
Wahaj 0:c6ffbdc6661d 124 NVIC_DisableIRQ(ADC_IRQn); ///For burst mode disable NVIc for adc
Wahaj 0:c6ffbdc6661d 125
Wahaj 0:c6ffbdc6661d 126 // Set the pin functions to ADC
Wahaj 0:c6ffbdc6661d 127
Wahaj 0:c6ffbdc6661d 128 LPC_PINCON->PINSEL1 &= ~((unsigned int)0x3 << 14);
Wahaj 0:c6ffbdc6661d 129 LPC_PINCON->PINSEL1 |= (unsigned int)0x1 << 14;
Wahaj 0:c6ffbdc6661d 130 LPC_PINCON->PINMODE1 &= ~((unsigned int)0x3 << 14);
Wahaj 0:c6ffbdc6661d 131 LPC_PINCON->PINMODE1 |= (unsigned int)0x2 << 14;
Wahaj 0:c6ffbdc6661d 132
Wahaj 0:c6ffbdc6661d 133 //p16://=p0.24 of LPC1768
Wahaj 0:c6ffbdc6661d 134 LPC_PINCON->PINSEL1 &= ~((unsigned int)0x3 << 16);
Wahaj 0:c6ffbdc6661d 135 LPC_PINCON->PINSEL1 |= (unsigned int)0x1 << 16;
Wahaj 0:c6ffbdc6661d 136 LPC_PINCON->PINMODE1 &= ~((unsigned int)0x3 << 16);
Wahaj 0:c6ffbdc6661d 137 LPC_PINCON->PINMODE1 |= (unsigned int)0x2 << 16;
Wahaj 0:c6ffbdc6661d 138
Wahaj 0:c6ffbdc6661d 139 // p17://=p0.25 of LPC1768
Wahaj 0:c6ffbdc6661d 140 LPC_PINCON->PINSEL1 &= ~((unsigned int)0x3 << 18);
Wahaj 0:c6ffbdc6661d 141 LPC_PINCON->PINSEL1 |= (unsigned int)0x1 << 18;
Wahaj 0:c6ffbdc6661d 142 LPC_PINCON->PINMODE1 &= ~((unsigned int)0x3 << 18);
Wahaj 0:c6ffbdc6661d 143 LPC_PINCON->PINMODE1 |= (unsigned int)0x2 << 18;
Wahaj 0:c6ffbdc6661d 144
Wahaj 0:c6ffbdc6661d 145 //p18://=p0.26 of LPC1768:
Wahaj 0:c6ffbdc6661d 146 LPC_PINCON->PINSEL1 &= ~((unsigned int)0x3 << 20);
Wahaj 0:c6ffbdc6661d 147 LPC_PINCON->PINSEL1 |= (unsigned int)0x1 << 20;
Wahaj 0:c6ffbdc6661d 148 LPC_PINCON->PINMODE1 &= ~((unsigned int)0x3 << 20);
Wahaj 0:c6ffbdc6661d 149 LPC_PINCON->PINMODE1 |= (unsigned int)0x2 << 20;
Wahaj 0:c6ffbdc6661d 150
Wahaj 0:c6ffbdc6661d 151 //=p1.30 of LPC1768
Wahaj 0:c6ffbdc6661d 152 LPC_PINCON->PINSEL3 &= ~((unsigned int)0x3 << 28);
Wahaj 0:c6ffbdc6661d 153 LPC_PINCON->PINSEL3 |= (unsigned int)0x3 << 28;
Wahaj 0:c6ffbdc6661d 154 LPC_PINCON->PINMODE3 &= ~((unsigned int)0x3 << 28);
Wahaj 0:c6ffbdc6661d 155 LPC_PINCON->PINMODE3 |= (unsigned int)0x2 << 28;
Wahaj 0:c6ffbdc6661d 156
Wahaj 0:c6ffbdc6661d 157 //=p1.31 of LPC1768
Wahaj 0:c6ffbdc6661d 158 LPC_PINCON->PINSEL3 &= ~((unsigned int)0x3 << 30);
Wahaj 0:c6ffbdc6661d 159 LPC_PINCON->PINSEL3 |= (unsigned int)0x3 << 30;
Wahaj 0:c6ffbdc6661d 160 LPC_PINCON->PINMODE3 &= ~((unsigned int)0x3 << 30);
Wahaj 0:c6ffbdc6661d 161 LPC_PINCON->PINMODE3 |= (unsigned int)0x2 << 30;
Wahaj 0:c6ffbdc6661d 162
Wahaj 0:c6ffbdc6661d 163 LPC_ADC->ADINTEN = 0x100;
Wahaj 0:c6ffbdc6661d 164 ////////////////Enable ADC////1Mhz clock////6 ADC pins
Wahaj 0:c6ffbdc6661d 165 LPC_ADC->ADCR = (1UL << 21) | (11UL << 8) | (63UL << 0);
Wahaj 0:c6ffbdc6661d 166
Wahaj 0:c6ffbdc6661d 167
Wahaj 0:c6ffbdc6661d 168 //////TIMER 1 Configuraion
Wahaj 0:c6ffbdc6661d 169 LPC_SC->PCONP |= (1UL << 2); // TIM1 On
Wahaj 0:c6ffbdc6661d 170 LPC_SC->PCLKSEL0 |= (3UL << 4); // CCLK/8 = 12MHz
Wahaj 0:c6ffbdc6661d 171 LPC_TIM1->PR = 11; // TC clocks at 1MHz.
Wahaj 0:c6ffbdc6661d 172 LPC_TIM1->MR0 = SAMPLE_PERIOD-1;
Wahaj 0:c6ffbdc6661d 173 LPC_TIM1->MCR = 3; // Reset TCR to zero on match and irq.
Wahaj 0:c6ffbdc6661d 174 NVIC_SetVector(TIMER1_IRQn, (uint32_t)TIMER1_handler);
Wahaj 0:c6ffbdc6661d 175 NVIC_EnableIRQ(TIMER1_IRQn);
Wahaj 0:c6ffbdc6661d 176
Wahaj 0:c6ffbdc6661d 177 // Prepare the GPDMA system.
Wahaj 0:c6ffbdc6661d 178 conf = new MODDMA_Config;
Wahaj 0:c6ffbdc6661d 179 conf
Wahaj 0:c6ffbdc6661d 180 ->channelNum ( MODDMA::Channel_0 )
Wahaj 0:c6ffbdc6661d 181 ->dstMemAddr ( (uint32_t)adBuffer )
Wahaj 0:c6ffbdc6661d 182 ->transferSize ( NUM_OF_SAMPLES )
Wahaj 0:c6ffbdc6661d 183 ->transferType ( MODDMA::p2m )
Wahaj 0:c6ffbdc6661d 184 ->transferWidth ( MODDMA::word )
Wahaj 0:c6ffbdc6661d 185 ->srcConn ( MODDMA::ADC )
Wahaj 0:c6ffbdc6661d 186 ->attach_tc ( &TC0_callback )
Wahaj 0:c6ffbdc6661d 187 ->attach_err ( &ERR0_callback )
Wahaj 0:c6ffbdc6661d 188 ; // end conf.
Wahaj 0:c6ffbdc6661d 189
Wahaj 0:c6ffbdc6661d 190 // Prepare configuration.
Wahaj 0:c6ffbdc6661d 191 if (!dma.Setup( conf ))
Wahaj 0:c6ffbdc6661d 192 {
Wahaj 0:c6ffbdc6661d 193 error("Doh!");
Wahaj 0:c6ffbdc6661d 194 }
Wahaj 0:c6ffbdc6661d 195
Wahaj 0:c6ffbdc6661d 196 // Begin.
Wahaj 0:c6ffbdc6661d 197 LPC_TIM1->TCR = 1;
Wahaj 0:c6ffbdc6661d 198 while (1)
Wahaj 0:c6ffbdc6661d 199 {
Wahaj 0:c6ffbdc6661d 200
Wahaj 0:c6ffbdc6661d 201 // This polls the network connection for new activity, without keeping on calling this you won't receive any OSC!
Wahaj 0:c6ffbdc6661d 202 Net::poll();
Wahaj 0:c6ffbdc6661d 203 if (dmaTransferComplete)
Wahaj 0:c6ffbdc6661d 204 {
Wahaj 0:c6ffbdc6661d 205 int i, value, channel;
Wahaj 0:c6ffbdc6661d 206
Wahaj 0:c6ffbdc6661d 207 for (i = 0; i <NUM_OF_SAMPLES ; i++)
Wahaj 0:c6ffbdc6661d 208 {
Wahaj 0:c6ffbdc6661d 209 value = (adBuffer[i] >> 4) & 0xFFF;
Wahaj 0:c6ffbdc6661d 210 channel = (adBuffer[i] >> 24) & 0x3;
Wahaj 0:c6ffbdc6661d 211 channel--;
Wahaj 0:c6ffbdc6661d 212 adBuffer[i]=0;
Wahaj 0:c6ffbdc6661d 213 if (channel == -1)
Wahaj 0:c6ffbdc6661d 214 channel = 5; // Workaround ch num problem.
Wahaj 0:c6ffbdc6661d 215 double fVal = 5 * (double)((double)value) / ((double)0x1000); // scale to 0v to 3.3v
Wahaj 0:c6ffbdc6661d 216 Sensor_Tap(i,(uint32_t)fVal);
Wahaj 0:c6ffbdc6661d 217
Wahaj 0:c6ffbdc6661d 218
Wahaj 0:c6ffbdc6661d 219 //pc.printf("ADC input (channel=%d) = 0x%03x %01.3f volts\n", channel, value, fVal);
Wahaj 0:c6ffbdc6661d 220 }
Wahaj 0:c6ffbdc6661d 221 dmaTransferComplete = false;
Wahaj 0:c6ffbdc6661d 222 wait(0.05); ////wait for 50 ms for the next finger to pe pressed
Wahaj 0:c6ffbdc6661d 223
Wahaj 0:c6ffbdc6661d 224 }
Wahaj 0:c6ffbdc6661d 225 }
Wahaj 0:c6ffbdc6661d 226 }
Wahaj 0:c6ffbdc6661d 227
Wahaj 0:c6ffbdc6661d 228 // Configuration callback on TC
Wahaj 0:c6ffbdc6661d 229 void TC0_callback(void)
Wahaj 0:c6ffbdc6661d 230 {
Wahaj 0:c6ffbdc6661d 231 led4=!led4;
Wahaj 0:c6ffbdc6661d 232 MODDMA_Config *config = dma.getConfig();
Wahaj 0:c6ffbdc6661d 233
Wahaj 0:c6ffbdc6661d 234 // Disbale burst mode and switch off the IRQ flag.
Wahaj 0:c6ffbdc6661d 235 LPC_ADC->ADCR &= ~(1UL << 16);
Wahaj 0:c6ffbdc6661d 236 LPC_ADC->ADINTEN = 0;
Wahaj 0:c6ffbdc6661d 237
Wahaj 0:c6ffbdc6661d 238 // Finish the DMA cycle by shutting down the channel.
Wahaj 0:c6ffbdc6661d 239 dma.haltAndWaitChannelComplete( (MODDMA::CHANNELS)config->channelNum());
Wahaj 0:c6ffbdc6661d 240 dma.Disable( (MODDMA::CHANNELS)config->channelNum() );
Wahaj 0:c6ffbdc6661d 241
Wahaj 0:c6ffbdc6661d 242 // Tell main() while(1) loop to print the results.
Wahaj 0:c6ffbdc6661d 243 dmaTransferComplete = true;
Wahaj 0:c6ffbdc6661d 244
Wahaj 0:c6ffbdc6661d 245 // Clear DMA IRQ flags.
Wahaj 0:c6ffbdc6661d 246 if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq();
Wahaj 0:c6ffbdc6661d 247 if (dma.irqType() == MODDMA::ErrIrq) dma.clearErrIrq();
Wahaj 0:c6ffbdc6661d 248 }
Wahaj 0:c6ffbdc6661d 249
Wahaj 0:c6ffbdc6661d 250 // Configuration callback on Error
Wahaj 0:c6ffbdc6661d 251 void ERR0_callback(void) {
Wahaj 0:c6ffbdc6661d 252 // Switch off burst conversions.
Wahaj 0:c6ffbdc6661d 253 LPC_ADC->ADCR |= ~(1UL << 16);
Wahaj 0:c6ffbdc6661d 254 LPC_ADC->ADINTEN = 0;
Wahaj 0:c6ffbdc6661d 255 error("Oh no! My Mbed EXPLODED! :( Only kidding, go find the problem");
Wahaj 0:c6ffbdc6661d 256 }
Wahaj 0:c6ffbdc6661d 257
Wahaj 0:c6ffbdc6661d 258
Wahaj 0:c6ffbdc6661d 259 void Sensor_Tap(int chan, uint32_t value1)
Wahaj 0:c6ffbdc6661d 260 {
Wahaj 0:c6ffbdc6661d 261 led3 = !led3;
Wahaj 0:c6ffbdc6661d 262
Wahaj 0:c6ffbdc6661d 263 // if((value>>4)&0xFFFF >= Adc_Threshold)
Wahaj 0:c6ffbdc6661d 264 {
Wahaj 0:c6ffbdc6661d 265 //SendOsc
Wahaj 0:c6ffbdc6661d 266
Wahaj 0:c6ffbdc6661d 267 sendMes.setTopAddress("/MidiGlove");
Wahaj 0:c6ffbdc6661d 268 switch (chan)
Wahaj 0:c6ffbdc6661d 269 {
Wahaj 0:c6ffbdc6661d 270 case 0:
Wahaj 0:c6ffbdc6661d 271 default:
Wahaj 0:c6ffbdc6661d 272 sendMes.setSubAddress("/Thumb");
Wahaj 0:c6ffbdc6661d 273 break;
Wahaj 0:c6ffbdc6661d 274 case 1:
Wahaj 0:c6ffbdc6661d 275 sendMes.setSubAddress("/Finger1");
Wahaj 0:c6ffbdc6661d 276 break;
Wahaj 0:c6ffbdc6661d 277 case 2:
Wahaj 0:c6ffbdc6661d 278 sendMes.setSubAddress("/Finger2");
Wahaj 0:c6ffbdc6661d 279 break;
Wahaj 0:c6ffbdc6661d 280 case 3:
Wahaj 0:c6ffbdc6661d 281 sendMes.setSubAddress("/Finger3");
Wahaj 0:c6ffbdc6661d 282 break;
Wahaj 0:c6ffbdc6661d 283 case 4:
Wahaj 0:c6ffbdc6661d 284 sendMes.setSubAddress("/Finger4");
Wahaj 0:c6ffbdc6661d 285 break;
Wahaj 0:c6ffbdc6661d 286 case 5:
Wahaj 0:c6ffbdc6661d 287 sendMes.setSubAddress("/Finger5");
Wahaj 0:c6ffbdc6661d 288 break;
Wahaj 0:c6ffbdc6661d 289 }
Wahaj 0:c6ffbdc6661d 290 // uint32_t v=123;
Wahaj 0:c6ffbdc6661d 291 sendMes.setArgs("i",&value1); // The payload will be the button state as an integer, ie. 0 or 1. We need to cast to 'long' for ints (and 'double' for floats).
Wahaj 0:c6ffbdc6661d 292 osc.sendOsc(&sendMes);
Wahaj 0:c6ffbdc6661d 293 }
Wahaj 0:c6ffbdc6661d 294
Wahaj 0:c6ffbdc6661d 295 }