Hy forum,
I'm working on a project involving 3 teensy communicating with I2C (i2c_t3 library) and each one driving and Octows2811 adaptor with 8 strips of leds for each one.
I'm programming with arduino
The communication is working perfectly well (thanks to pull-up resistors). I have one master teensy sending to the two others
The main issue with this project is that the neopixels strips driven by the slave teensies are flashing. The neopixels driven by the master are not flashing.
Each OctoWs2811 is configured like that
The master have this in the loop
The slaves have a loop like this
You see that the slave have a delay of 400ms for the leds show and the master a dely of 200ms. It is supposed to let 200 ms for wire transmission of 2 characters. Even with that the neopixels are flashing.
Is there a way to avoid this flashing behaviour ?
The other issue is that I really have 56 pixels. But I have to declare that I have 75 pixels (so 19 dummy pixels) , to be able to light all the strip. If I declare 56, only 43 are lighted, the others are black... An other mystery for me
I'm working on a project involving 3 teensy communicating with I2C (i2c_t3 library) and each one driving and Octows2811 adaptor with 8 strips of leds for each one.
I'm programming with arduino
The communication is working perfectly well (thanks to pull-up resistors). I have one master teensy sending to the two others
The main issue with this project is that the neopixels strips driven by the slave teensies are flashing. The neopixels driven by the master are not flashing.
Each OctoWs2811 is configured like that
Code:
#define LED_WIDTH 75 // number of LEDs horizontally
#define LED_HEIGHT 8 // number of LEDs vertically (must be multiple of 8)
DMAMEM int displayMemory[LED_WIDTH*LED_HEIGHT];
int drawingMemory[LED_WIDTH*LED_HEIGHT];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(LED_WIDTH, displayMemory, drawingMemory, config);
Code:
//Communication
uint8_t target1 = 0x66; // target Slave1 address
uint8_t target2 = 0x68; // target Slave2 address
size_t idx;
// Construct data message
sprintf(databuf1, "%c%c", anim[1], power[1]);
//Serial.print(anim[8]); Serial.print(" "); Serial.print(power[8]); Serial.print(" ");Serial.print(anim[9]); Serial.print(" "); Serial.print(power[9]); Serial.print(" ");Serial.println(anim[10]);
// Transmit to Slave
Wire.beginTransmission(target1); // Slave address
for(idx = 0; idx <= strlen(databuf1); idx++) // Write string to I2C Tx buffer (incl. string null at end)
Wire.write(databuf1[idx]);
Wire.endTransmission(); // Transmit to Slave
//delay(50);
// Construct data message
sprintf(databuf2, "%c%c", anim[2], power[2]);
//Serial.print(anim[8]); Serial.print(" "); Serial.print(power[8]); Serial.print(" ");Serial.print(anim[9]); Serial.print(" "); Serial.print(power[9]); Serial.print(" ");Serial.println(anim[10]);
// Transmit to Slave
Wire.beginTransmission(target2); // Slave address
for(idx = 0; idx <= strlen(databuf2); idx++) // Write string to I2C Tx buffer (incl. string null at end)
Wire.write(databuf2[idx]);
Wire.endTransmission(); // Transmit to Slave
int portion = leds.numPixels()/8;
int red = (int)((float)_power*0.6+100);
int green = red;
int blue = red;
for (int i=0; i < portion; i++) {
if (i==_power) {
leds.setPixel(i, red, green, blue);
leds.setPixel(i+portion, red, green, blue);
leds.setPixel(i+2*portion, red, green, blue);
leds.setPixel(i+3*portion, red, green, blue);
leds.setPixel(i+4*portion, red, green, blue);
leds.setPixel(i+5*portion, red, green, blue);
leds.setPixel(i+6*portion, red, green, blue);
leds.setPixel(i+7*portion, red, green, blue);
}
else {
leds.setPixel(i, BLACK);
leds.setPixel(i+portion, BLACK);
leds.setPixel(i+2*portion, BLACK);
leds.setPixel(i+3*portion, BLACK);
leds.setPixel(i+4*portion, BLACK);
leds.setPixel(i+5*portion, BLACK);
leds.setPixel(i+6*portion, BLACK);
leds.setPixel(i+7*portion, BLACK);
}
}
leds.show();
delay(200);
The slaves have a loop like this
Code:
if(received)
{
int verifA = (uint8_t)databuf[0];
int verifP = (uint8_t)databuf[1];
if (verifA != 0){
if (verifP>0 && verifP<100){
anim = verifA;
power = verifP;
}
} else {
anim = 0;
power = 0;
}
power = ((int)(float)power*0.01*75.);
//My neopixels driving
int portion = leds.numPixels()/8;
int red = (int)((float)_power*0.6+100);
int green = red;
int blue = red;
for (int i=0; i < portion; i++) {
if (i>_power) {
leds.setPixel(i, BLACK);
leds.setPixel(i+portion, BLACK);
leds.setPixel(i+2*portion, BLACK);
leds.setPixel(i+3*portion, BLACK);
leds.setPixel(i+4*portion, BLACK);
leds.setPixel(i+5*portion, BLACK);
leds.setPixel(i+6*portion, BLACK);
leds.setPixel(i+7*portion, BLACK);
}
else {
leds.setPixel(i, red, green, blue);
leds.setPixel(i+portion, red, green, blue);
leds.setPixel(i+2*portion, red, green, blue);
leds.setPixel(i+3*portion, red, green, blue);
leds.setPixel(i+4*portion, red, green, blue);
leds.setPixel(i+5*portion, red, green, blue);
leds.setPixel(i+6*portion, red, green, blue);
leds.setPixel(i+7*portion, red, green, blue);
}
}
leds.show();
delay(400);
}
You see that the slave have a delay of 400ms for the leds show and the master a dely of 200ms. It is supposed to let 200 ms for wire transmission of 2 characters. Even with that the neopixels are flashing.
Is there a way to avoid this flashing behaviour ?
The other issue is that I really have 56 pixels. But I have to declare that I have 75 pixels (so 19 dummy pixels) , to be able to light all the strip. If I declare 56, only 43 are lighted, the others are black... An other mystery for me