Adafruit Neopixel slow test

ethernet-argb-controller
Cole Deck 2 months ago
parent 181dcc98ca
commit e0249dcadf

@ -21,7 +21,6 @@ upload_protocol = cmsis-dap
monitor_speed = 115200
board_build.filesystem_size = 1m
board_build.f_cpu = 133000000L
; build_flags = -O3
; board_flags = -DWIFICC=CYW43_COUNTRY_USA
lib_deps =
https://github.com/FastLED/FastLED#master
lib_deps =
adafruit/Adafruit NeoPixel@^1.12.0
adafruit/Adafruit NeoPXL8@^1.2.6

@ -3,11 +3,11 @@
#define DEBUG
#define LIGHTTEST
//#define LIGHTTEST
// Total LED count
// set to 128*8 for 4 channel, 170*8 for 3 channel
#define MAX_LEDS 128*8
#define MAX_LEDS 170*8
//#define RGBW_MODE
// Amount of color channels per pixel - i.e. RGB = 3, RGBW = 4

@ -6,8 +6,9 @@
#include <HTTPUpdateServer.h>
#include <WebServer.h>
#include "e131.h"
#include <FastLED.h>
#include "FastLED_RGBW.h"
#include <Adafruit_NeoPixel.h>
//#include <FastLED.h>
//#include "FastLED_RGBW.h"
#include "config.h"
#include <EEPROM.h>
#include <pico/stdlib.h>
@ -28,15 +29,30 @@ bool core1_separate_stack = true;
int calculate[LED_STRIPS * 4];
int universes[LED_STRIPS * 4];
#ifdef RGBW_MODE
// EVIL! hack to support RGBW ICs
CRGBW leds[MAX_LEDS];
CRGB *ledstrip = (CRGB *) &leds[0]; // yes, we just casted a 4-byte value array to a pseudo 3-byte value array
int strips[LED_STRIPS] = {getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128)};
#else
int strips[LED_STRIPS] = {170, 170, 170, 170, 170, 170, 170, 170};
CRGB ledstrip[MAX_LEDS];
#endif
Adafruit_NeoPixel *pixel1;
Adafruit_NeoPixel *pixel2;
Adafruit_NeoPixel *pixel3;
Adafruit_NeoPixel *pixel4;
Adafruit_NeoPixel *pixel5;
Adafruit_NeoPixel *pixel6;
Adafruit_NeoPixel *pixel7;
Adafruit_NeoPixel *pixel8;
const int strips[LED_STRIPS] = {170, 170, 170, 170, 170, 170, 170, 170};
int offsets[(LED_STRIPS+1)];
Adafruit_NeoPixel *strip_list[8] = {pixel1,pixel2,pixel3,pixel4,pixel5,pixel6,pixel7,pixel8};
// #ifdef RGBW_MODE
// // EVIL! hack to support RGBW ICs
// CRGBW leds[MAX_LEDS];
// CRGB *ledstrip = (CRGB *) &leds[0]; // yes, we just casted a 4-byte value array to a pseudo 3-byte value array
// int strips[LED_STRIPS] = {getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128)};
// #else
// int strips[LED_STRIPS] = {170, 170, 170, 170, 170, 170, 170, 170};
// CRGB ledstrip[MAX_LEDS];
// #endif
int pins[8];
uint8_t * livedata;
@ -79,7 +95,60 @@ float cputemp;
float airtemp;
int datapos = 0;
inline void setpixelrgb(int idx, byte r, byte g, byte b, byte w = 0) {
if (idx < offsets[1]) {
pixel1->setPixelColor(idx - offsets[0], pixel1->Color(r,g,b,w));
}
else if (idx < offsets[2]) {
pixel1->setPixelColor(idx - offsets[1], pixel1->Color(r,g,b,w));
}
else if (idx < offsets[3]) {
pixel1->setPixelColor(idx - offsets[2], pixel1->Color(r,g,b,w));
}
else if (idx < offsets[4]) {
pixel1->setPixelColor(idx - offsets[3], pixel1->Color(r,g,b,w));
}
else if (idx < offsets[5]) {
pixel1->setPixelColor(idx - offsets[4], pixel1->Color(r,g,b,w));
}
else if (idx < offsets[6]) {
pixel1->setPixelColor(idx - offsets[5], pixel1->Color(r,g,b,w));
}
else if (idx < offsets[7]) {
pixel1->setPixelColor(idx - offsets[6], pixel1->Color(r,g,b,w));
}
else if (idx < offsets[8]) {
pixel1->setPixelColor(idx - offsets[7], pixel1->Color(r,g,b,w));
}
}
inline void showpixels() {
#ifdef STRIP1
pixel1->show();
#endif
#ifdef STRIP2
pixel2->show();
#endif
#ifdef STRIP3
pixel3->show();
#endif
#ifdef STRIP4
pixel4->show();
#endif
#ifdef STRIP5
pixel5->show();
#endif
#ifdef STRIP6
pixel6->show();
#endif
#ifdef STRIP7
pixel7->show();
#endif
#ifdef STRIP8
pixel8->show();
#endif
}
template <class T> T print(T in) {
if(Serial)
Serial.print(String(millis()/1000.0) + ": " + String(in));
@ -195,9 +264,9 @@ void handleForm() {
if(reboot) {
EEPROM.commit();
for (int i = 0; i < MAX_LEDS; i++) {
ledstrip[i] = CRGB(0, 0, 0);
setpixelrgb(i, 0, 0, 0);
}
FastLED.show();
showpixels();
ready = 3; // trigger core 1 to stop
delay(250);
rp2040.reboot();
@ -264,9 +333,9 @@ void write_universe(long universe, uint8_t data[], long size) {
Serial.print(" ");
}*/
#ifdef RGBW_MODE
ledstrip[offset + i] = CRGB(data[j], data[j+1], data[j+2]);
setpixelrgb(offset + i, data[j], data[j+1], data[j+2]);
#else
ledstrip[offset + i] = CRGB(data[j], data[j+1], data[j+2]);
setpixelrgb(offset + i, data[j], data[j+1], data[j+2]);
#endif
//ledstrip[strip].setPixelColor(i + offset, data[j], data[j+1], data[j+2]);
}
@ -284,7 +353,7 @@ void setup() {
set_sys_clock_khz(252000, false);
pinMode(23, OUTPUT);
pinMode(23, HIGH);
//Serial.begin(115200);
Serial.begin(115200);
//rp2040.wdt_begin(8000);
//pinMode(24, INPUT); // VBUS detect - check for USB connection
//if (digitalRead(24)) {
@ -495,6 +564,10 @@ void setup1() {
pinMode(32+1, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
println("Initializing LED outputs and universe mappings...");
offsets[0] = 0;
for (int i = 1; i <= LED_STRIPS; i++) {
offsets[i] = offsets[i-1] + strips[i-1];
}
#ifdef STRIP1
pins[0] = STRIP1;
@ -568,44 +641,54 @@ void setup1() {
}
#ifdef STRIP1
FastLED.addLeds<LED_TYPE, STRIP1, RGB_ORDER>(ledstrip, calculate[0], strips[0]);
pixel1 = new Adafruit_NeoPixel(strips[0], pins[0], NEO_GRB + NEO_KHZ800);
pixel1->begin();
#endif
#ifdef STRIP2
FastLED.addLeds<LED_TYPE, STRIP2, RGB_ORDER>(ledstrip, calculate[1], strips[1]);
pixel2 = new Adafruit_NeoPixel(strips[1], pins[1], NEO_GRB + NEO_KHZ800);
pixel2->begin();
#endif
#ifdef STRIP3
FastLED.addLeds<LED_TYPE, STRIP3, RGB_ORDER>(ledstrip, calculate[2], strips[2]);
pixel3 = new Adafruit_NeoPixel(strips[2], pins[2], NEO_GRB + NEO_KHZ800);
pixel3->begin();
#endif
#ifdef STRIP4
FastLED.addLeds<LED_TYPE, STRIP4, RGB_ORDER>(ledstrip, calculate[3], strips[3]);
pixel4 = new Adafruit_NeoPixel(strips[3], pins[3], NEO_GRB + NEO_KHZ800);
pixel4->begin();
#endif
#ifdef STRIP5
FastLED.addLeds<LED_TYPE, STRIP5, RGB_ORDER>(ledstrip, calculate[4], strips[4]);
pixel5 = new Adafruit_NeoPixel(strips[4], pins[4], NEO_GRB + NEO_KHZ800);
pixel5->begin();
#endif
#ifdef STRIP6
FastLED.addLeds<LED_TYPE, STRIP6, RGB_ORDER>(ledstrip, calculate[5], strips[5]);
pixel6 = new Adafruit_NeoPixel(strips[5], pins[5], NEO_GRB + NEO_KHZ800);
pixel6->begin();
#endif
#ifdef STRIP7
FastLED.addLeds<LED_TYPE, STRIP7, RGB_ORDER>(ledstrip, calculate[6], strips[6]);
pixel7 = new Adafruit_NeoPixel(strips[6], pins[6], NEO_GRB + NEO_KHZ800);
pixel7->begin();
#endif
#ifdef STRIP8
FastLED.addLeds<LED_TYPE, STRIP8, RGB_ORDER>(ledstrip, calculate[7], strips[7]);
pixel8 = new Adafruit_NeoPixel(strips[7], pins[7], NEO_GRB + NEO_KHZ800);
pixel8->begin();
#endif
for (int i = 0; i < MAX_LEDS; i++) {
ledstrip[i] = CRGB(0, 0, 0);
setpixelrgb(i, 0, 0, 0);
}
FastLED.show();
showpixels();
// Test all lights
#ifdef LIGHTTEST
for (int i = 0; i < MAX_LEDS; i++) {
ledstrip[i] = CRGB(0, 0, 50);
FastLED.show();
setpixelrgb(i, 0, 0, 50);
showpixels();
delay(1);
ledstrip[i] = CRGB(0, 0, 0);
setpixelrgb(i, 0, 0, 0);
}
FastLED.show();
showpixels();
#endif
//delay(3000);
@ -619,6 +702,7 @@ void setup1() {
}
void loop() {
/* Parse a packet */
//println("Start loop");
@ -695,7 +779,7 @@ void loop1() {
status2 = 1;
if(status == 1 && e131.universe > START_UNIVERSE - 1 && channels > 0) {
write_universe(e131.universe - START_UNIVERSE - 1, livedata, channels);
FastLED.show();
showpixels();
//println("Done Writing");
status = 0;
}

Loading…
Cancel
Save