Thanks for the answers.
I tried adding Wire.setClock(50000); to Setup with no luck.
Give you more info. I send data from Max/MSP. Im sure this part of the proyect is not the problem because
I try already sending data directly from the arduino code with the same result.
The problem its either with the Arduino code ( I think the code is pretty clean) or the comunication whit the
boards.
It at high speed when I press a button the data seems to be messed up, changing colours and missing steps.
I leave the Arduino code and attach a video with the behaviour.
#include "Adafruit_NeoTrellis.h"
#define Y_DIM 16
#define X_DIM 32
#define INT_PIN 10
Adafruit_NeoTrellis t_array[Y_DIM/4][X_DIM/4] = {
{ Adafruit_NeoTrellis(0x35), Adafruit_NeoTrellis(0x3A), Adafruit_NeoTrellis(0x4A), Adafruit_NeoTrellis(0x33),Adafruit_NeoTrellis(0x4B), Adafruit_NeoTrellis(0x45), Adafruit_NeoTrellis(0x4C), Adafruit_NeoTrellis(0x42) },
{ Adafruit_NeoTrellis(0x4D), Adafruit_NeoTrellis(0x3E) , Adafruit_NeoTrellis(0x40), Adafruit_NeoTrellis(0x38),Adafruit_NeoTrellis(0x31), Adafruit_NeoTrellis(0x3D), Adafruit_NeoTrellis(0x3B), Adafruit_NeoTrellis(0x49) },
{ Adafruit_NeoTrellis(0x2F), Adafruit_NeoTrellis(0x2E), Adafruit_NeoTrellis(0x3C), Adafruit_NeoTrellis(0x47),Adafruit_NeoTrellis(0x32), Adafruit_NeoTrellis(0x36), Adafruit_NeoTrellis(0x48), Adafruit_NeoTrellis(0x3F) },
{ Adafruit_NeoTrellis(0x34), Adafruit_NeoTrellis(0x44), Adafruit_NeoTrellis(0x39), Adafruit_NeoTrellis(0x41), Adafruit_NeoTrellis(0x30), Adafruit_NeoTrellis(0x37), Adafruit_NeoTrellis(0x43), Adafruit_NeoTrellis(0x46) }
,
};
Adafruit_MultiTrellis trellis((Adafruit_NeoTrellis *)t_array, Y_DIM/4, X_DIM/4);
TrellisCallback blink(keyEvent evt){
if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_RISING)
Serial.println (evt.bit.NUM);
else if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_FALLING)
Serial.println(evt.bit.NUM + 1000);
return 0;
}
inline uint32_t rgbColor(uint32_t r, uint32_t g, uint32_t b)
{
return ((r << 16) | (g << 8) | b);
}
const byte numChars = 32;
char receivedChars[numChars];
char tempChars[numChars];
int a = 0;
int b = 0;
int c = 0;
int d = 0;
boolean newData = false;
////////////////////////////////////////////////////////
void setup() {
Serial.begin(9600);
Wire.setClock(50000);
pinMode(INT_PIN,INPUT);
!trellis.begin();
for(int y=0; y<Y_DIM; y++){
for(int x=0; x<X_DIM; x++){
trellis.activateKey(x, y, SEESAW_KEYPAD_EDGE_RISING, true);
trellis.activateKey(x, y, SEESAW_KEYPAD_EDGE_FALLING, true);
trellis.registerCallback(x, y, blink);
}
}
/////////////////////////////////////////////////////////////////////////////////
}
void loop() {
if(!digitalRead(INT_PIN)){
trellis.read();
}
recvWithStartEndMarkers();
if (newData == true) {
strcpy(tempChars, receivedChars);
parseData();
newData = false;
}
}
/////////////////////////////////////////////////////////////////////
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0';
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}
///////////////////////////////////////////////////////////////////
void parseData() {
char * strtokIndx;
strtokIndx = strtok(tempChars," ");
a = atoi(strtokIndx);
strtokIndx = strtok(NULL, " ");
b = atoi(strtokIndx);
strtokIndx = strtok(NULL, " ");
c = atoi(strtokIndx);
strtokIndx = strtok(NULL, " ");
d = atoi(strtokIndx);
trellis.setPixelColor(a, rgbColor(b,c,d));
trellis.show();
}
Desktop.zip (1.74 MB)