I am working on converting a project to use 105 pixels of RGBW Sk6812 LEDs on an Arduino Uno reading generic serial data from Vixen. My current sketch is written for RGB LEDs using the FastLED library. I need to adapt the sketch to take the 4 channel (RGBW) serial data from Vixen and hopefully with the new RGBW support in FastLED make the sketch drive the Sk6812 RGBW LEDs…the sketch compiles and functions but obviously doesn’t apply the data correctly since it’s outputting RGB vs RGBW. If you have a potential solution, I will post the sketch and we can work through it…a simple solution can work since I will only be using white light. I just need help getting this working quickly. Thanks in advance.
I decided it might save time if I go ahead and post the sketch I am starting from...I am new to this and I will dig deeper into the C coding but I have to get this done ASAP.... Please bear with me.... Here is the Sketch...
#include <FastLED.h>
#define NUM_LEDS 105
#define DATA_PIN 6
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(115200);
}
void loop() {
int cnt;
unsigned int num_leds;
unsigned int d1, d2, d3;
for(;;) {
cnt = 0;
while(!Serial.available());
if(Serial.read() != '>') {
continue;
}
while(!Serial.available());
if(Serial.read() != '>') {
continue;
}
while(!Serial.available());
d1 = Serial.read();
while(!Serial.available());
d2 = Serial.read();
while(!Serial.available());
d3 = Serial.read();
while(!Serial.available());
if(Serial.read() != '<') {
continue;
}
while(!Serial.available());
if(Serial.read() != '<') {
continue;
}
num_leds = (d1-'0')*100+(d2-'0')*10+(d3-'0');
if(num_leds > NUM_LEDS) {
continue;
}
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, num_leds);
do {
while(!Serial.available());
leds[cnt].r = Serial.read();
while(!Serial.available());
leds[cnt].g = Serial.read();
while(!Serial.available());
leds[cnt++].b = Serial.read();
}
while(--num_leds);
FastLED.show();
}
}
I'm not familiar with Vixen; I've just installed it so I can try to help.
Can you attach a basic tim file for your setup? You probably will have rename it (add ".txt" to the name) or zip it. That way I have an example that I can use to analyse the protocol.
Some comments
You have two blocks like this; what is your Serial configuration? Screenshot will do.
FastLED.addLeds() does, to my knowledge, not belong in loop()
.
So true !
And you are not running into issues with the Serial reception ? What framerate is Vixen putting out at ?
while(!Serial.available());
if(Serial.read() != '<') {
continue;
Vixen sends a header with the number of pixels, the number is bracketed with >> and <<.
I will upload a very basic .Tim file shortly.
The Baud rate from vixen is set to 115200 to match the sketch…it is set when you setup the controller in vixen and can be adjusted to any value. I don’t think I am having any issues but I have not run the sketch for a long period to see if I get any kind of issue.
Test .tim file in zip. This should light the first 15 leds as 0,3,6,9,12 together then 1,4,7,10,13, etc holding each on until all lit, then the next 30 pulse in together, next 30, and next 30, then all should randomly pulse in intensity to twinkle.... something like that..
test_tim.zip (4.5 KB)
As I have no idea how to work with Vixen, the tim file is unfortunately insufficient. I've only managed to received headers and 0 0 0 0.
Reading a bit more, I suspect that I need the full profile to be able to analyse and test. Would that be possible?
For simplicities sake, and assuming Vixen fully supports your RGBW. Somehow it seems FastLED just doesn't and there are libraries out there that do like Adafruit_NeoPixel and Makuna Neopixelbus I suggest that you switch libraries
I am not averse to switching libraries but I do not have the skills to write the sketch… I can adapt so so but to start from scratch I think I would be in big trouble….maybe by next year Christmas I could learn enough to put it together …lol …. I thought they just came out with a new update for FastLED that was supposed to work for RGBW specifically sk6812 strips
I can post the file for the prop. You could then import it and set it up with the controller…takes maybe 10 minutes to do….
Star.zip (621.0 KB)
this is the prop, just import, select all elements and assign color handling to RGBW....that will create 420 points to patch to the 420 points created on the controller when setting it up you declare the individual #of leds so 105 x 4 leds per pixel = 420 control points.... thats really bout all there is to it.
I think if you compare the examples from both libraries and the sketch you are using now, you should manage, otherwise this project is beyond you to begin with.
Slowly; I'm a beginner to Vixen. You'll have to chew it to me.
None of the main menus have an option "just import" The only place where I seem to be able to do something with the .prp file is in tools -> custom prop editor. Opening that prp file does not seem to give me elements (as in the first image in your post #8) nor a schedule; or I do not know how to go from there.
What I was hoping for was a zip that has a profile (which is nothing more than a directory by the looks of it it) with all related stuff (elements, sequences and whatever else is needed). And preferably an instruction how I can start / stop / pause the show / sequence with the click of a button.
That way I do not have to study the Vixen stuff which will take me ages.
Just a question. Did you use WS2812 (or similar strips) for that and hence using FastLED.show()? Or just simple RGB strips?
I actually have not had the sketch in full operation with LEDs before…it was originally incandescent Christmas lights with a controller built into the string but finally died. As for Vixen I will put something together after work and upload which will give you a detailed setup. For simplicity I may just make it just a simple string of LEDs in a line….the layout of the pixels is rather irrelevant as long as there are 105 in series on pin 6 and are set to RGBW. As I recall you can add single item from drop down on the left then select it on the screen, right click, select “add multiple” then tell it 105 pixels, select all elements created and at the bottom select color handling and then configure…select last option and assign RGBW from drop down. Then patch elements to controllers and you are done …. I can write it up with more detail later but I am out the door to work atm.
Is there a particular reason you want to use Vixen as a sort of 'remote' control ? I mean, wouldn't it be easier to program some effects straight into the arduino and forget about Vixen ?
Ultimately the sequences
| Deva_Rishi
November 26 |
- | - |
Is there a particular reason you want to use Vixen as a sort of 'remote' control ? I mean, wouldn't it be easier to program some effects straight into the arduino and forget about Vixen ?
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
Ultimately the sequences will be choreographed to a loop of about 20 minutes of Christmas tunes hence why Vixen is needed, plus creating a specific sequences of patterns is more easily done in Vixen or Xlights
Yeah that explains things. I was just curious you know.
Anyway, to write something that looks a bit more decent than what you have at the moment, i need the exact format of how Vixen is transmitting, and somehow the online documentation did not show me that.
From what i understand from you, it is transmitted like this
>>NumLeds<<L0R L0G L0B L0W .... etc
So there is 2x '>' and 2x '<' separating
Anyway, maybe there is an easier way to solve this, let me just adapt what you provided to Adafruit_neopixel and to use RGBW as a a format. Just to make clear this sketch expects 4 bytes for every pixel transmitted and RGBW is the byte order.
//#include <FastLED.h>
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 105
#define DATA_PIN 6
//CRGB leds[NUM_LEDS];
Adafruit_NeoPixel pixels(NUM_LEDS, DATA_PIN, NEO_RGBW + NEO_KHZ800);
void setup() {
Serial.begin(115200);
pixels.begin();
}
void loop() {
int cnt;
unsigned int num_leds;
unsigned int d1, d2, d3;
for (;;) { // creates in infinte loop that gets exited after each continue;
cnt = 0;
while (!Serial.available()); // waits for Serial data
if (Serial.read() != '>') {
continue;
}
while (!Serial.available());
if (Serial.read() != '>') {
continue;
}
while (!Serial.available());
d1 = Serial.read();
while (!Serial.available());
d2 = Serial.read();
while (!Serial.available());
d3 = Serial.read();
while (!Serial.available());
if (Serial.read() != '<') {
continue;
}
while (!Serial.available());
if (Serial.read() != '<') {
continue;
}
num_leds = (d1 - '0') * 100 + (d2 - '0') * 10 + (d3 - '0');
if (num_leds > NUM_LEDS) {
continue;
}
//FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, num_leds); // doesn't belong right here anyway
pixels.clear(); // clear the buffer (optional)
do {
byte r, g, b, w;
while (!Serial.available());
r = Serial.read();
while (!Serial.available());
g = Serial.read();
while (!Serial.available());
b = Serial.read();
while (!Serial.available());
b = Serial.read();
pixels.setPixelColor(cnt++, pixels.Color(r, g, b, w));
}
while (--num_leds);
pixels.show();
}
}
There is almost no error checking, so if not sufficient data is received it may not work properly.
Also using a header and simply transmitting bytes is not a very reliable method (the '<' character is also a byte and it may be send as part of the byte stream)
But this compiles and should do the trick. Have a go.
I would have written the sketch in a much different way (even just using return; instead of continue and i would have checked for the terminating '>' before doing show() but this was what it was and you said it works)
Thank you! I will give it a go and post the results. You may have just saved Christmas for me and especially my wife! Thanks again!