dimitre
Well-known member
I'm testing some new LED strips (HD108) with Teensy 3.2 and I'm noticing some unusual
Animations begin very smooth and beautiful, over time (after one minute) we can notice looking at the LEDs it gradually starts decreasing frame rate.
Resetting board in reset button restores smoothness until it slow downs again.
I'm wondering if I'm missing something in the code, or maybe it is something else
I'm using latest Platformio in macOS
Animations begin very smooth and beautiful, over time (after one minute) we can notice looking at the LEDs it gradually starts decreasing frame rate.
Resetting board in reset button restores smoothness until it slow downs again.
I'm wondering if I'm missing something in the code, or maybe it is something else
I'm using latest Platformio in macOS
Code:
#include <Arduino.h>
#include <SPI.h>
void setup() {
// SCK 13, MOSI 11
SPI.begin();
}
void loop() {
SPI.beginTransaction(SPISettings(40000000, MSBFIRST, SPI_MODE0));
// Start frame
for (int i = 0; i < 8; i++) {
SPI.transfer16(0x0000);
}
int numLeds = 60 * 2;
for (int i=0; i< numLeds; i++) {
SPI.transfer16(0b1000110001100011); // bit 1 + (1)(5bit)(5bit)(5bit) brightnesses
float t = (float)millis()/610.0f + (float)i * 0.3;
float max = 5000;
uint16_t r = (sin(t + 60.0 * 0.0) * max + max);
uint16_t g = (sin(t + 60.0 * 1.0) * max + max);
uint16_t b = (sin(t + 60.0 * 2.0) * max + max);
SPI.transfer16(g);
SPI.transfer16(r);
SPI.transfer16(b);
}
// End Frame
for (int i = 0; i < (numLeds/8); i++) {
SPI.transfer(0xFF);
}
SPI.endTransaction();
delay(10);
}