Hi, I'm trying to trying to control an led matrix from pure data over osc. I'm able to control 10 leds (ie.'/led/1' - '/led/9'. However I'm not able to receive osc messages with double digit numbers.
I believe the problem has to do with the following lines of code which I did not write and as a result don't fully understand. Could someone give me a better understanding of what's going on here so I might be able to adjust the code?
I believe the problem has to do with the following lines of code which I did not write and as a result don't fully understand. Could someone give me a better understanding of what's going on here so I might be able to adjust the code?
Code:
char whatLED[] = {'/','1',0};
for(int i=0; i<16;i++){
whatLED[1] = char (i | 0x30);
Code:
#include "Tlc5940.h"
#include <OSCBoards.h>
#include <OSCMessage.h>
#ifdef BOARD_HAS_USB_SERIAL
#include <SLIPEncodedUSBSerial.h>
SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB );
#else
#include <SLIPEncodedSerial.h>
SLIPEncodedSerial SLIPSerial(Serial1);
#endif
byte outPins[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; //for tlc pins
int brightness;
int i;
void setup() {
SLIPSerial.begin(9600); // set this as high as you can reliably run on your platform
Tlc.init();
}
void routeSystem(OSCMessage &msg, int matched ){
char whatLED[] = {'/','1',0};
for(int i=0; i<16;i++){
whatLED[1] = char (i | 0x30);
if(msg.match(whatLED,matched)){
if(msg.getInt(0));
int brightness = msg.getInt(0);
Tlc.set(outPins[i],brightness); // addressing tlcs
Tlc.update();
}
}
}
//reads and routes the incoming messages
void loop(){
OSCMessage messageIN;
int size;
while(!SLIPSerial.endofPacket())
if ((size =SLIPSerial.available()) > 0)
{
while(size--)
messageIN.fill(SLIPSerial.read());
}
if(!messageIN.hasError())
{
messageIN.route("/led", routeSystem);
}
}