Ambilight and other LEDs off the same Arduino?

As you might have read from the title, I’m trying to run an Adalight program for my Ambilight in parallel with my own software, that’s controlling the other individually adressable LEDs in my room. since I don’t really want the LEDs under my Bed to sync up with my screen, and rather want to control those effects over wifi, I will have to wait for Serial input at the same time, as I’m setting other LED colors.
I’m currently using the FastLED library, and this software in combination with Prismatik for the Ambilight:
/
Arduino interface for the use of WS2812 strip LEDs
Uses Adalight protocol and is compatible with Boblight, Prismatik etc…
“Magic Word” for synchronisation is ‘Ada’ followed by LED High, Low and Checksum
@author: Wifsimster wifsimster@gmail.com
@library: FastLED v3.001
@date: 11/22/2015
/
#include “FastLED.h”
#define NUM_LEDS 33
#define DATA_PIN 3
// Baudrate, higher rate allows faster refresh rate and more LEDs (defined in /etc/boblight.conf)
#define serialRate 115200
// Adalight sends a “Magic Word” (defined in /etc/boblight.conf) before sending the pixel data
uint8_t prefix = {‘A’, ‘d’, ‘a’}, hi, lo, chk, i;
uint8_t gHue = 0;
// Initialise LED-array
CRGB leds[NUM_LEDS];
void setup() {
// Use NEOPIXEL to keep true colors
FastLED.addLeds<WS2811, DATA_PIN, BRG>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
// Initial RGB flash
fill_rainbow(leds, NUM_LEDS, 0, 10);
FastLED.show();
delay(1500);
LEDS.showColor(CRGB(0, 0, 0));
Serial.begin(serialRate);
// Send “Magic Word” string to host
Serial.print(“Ada\n”);
}
for (;:wink: {
// Wait for first byte of Magic Word
for (i = 0; i < sizeof prefix; ++i) {
waitLoop: while (!Serial.available()) ;;
// Check next byte in Magic Word
if (prefix == Serial.read()) continue;
* // otherwise, start over*
* i = 0;
goto waitLoop;
}
// Hi, Lo, Checksum*
* while (!Serial.available()) ;;
hi = Serial.read();
while (!Serial.available()) ;;
lo = Serial.read();
while (!Serial.available()) ;;
chk = Serial.read();
// If checksum does not match go back to wait*
* if (chk != (hi ^ lo ^ 0x55)) {
i = 0;
goto waitLoop;
}
memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
// Read the transmission data and set LED values*
* for (uint8_t i = 0; i < NUM_LEDS; i++) {
byte r, g, b;
while (!Serial.available());
r = Serial.read();
while (!Serial.available());
g = Serial.read();
while (!Serial.available());
b = Serial.read();
_ leds
.r = r;
leds
.g = g;
leds.b = b;
}
// Shows new values*

* FastLED.show();
}[/sup]
this is what I came up with, but it’s not really working… at all :confused:
#include <FastLED.h>_

#define NUM_LEDSA 33 //ambilight
#define NUM_LEDSB 20 //bed
#define NUM_LEDST 50 //table
#define NUM_LEDS NUM_LEDST+NUM_LEDSA+NUM_LEDSB
#define DATA_PIN 3
_// Adalight sends a “Magic Word” (defined in /etc/boblight.conf) before sending the pixel data_
uint8_t prefix = {‘A’, ‘d’, ‘a’}, hi, lo, chk, i;
uint8_t gHue = 0;
_// Initialise LED-arrays_
CRGB ledsA[NUM_LEDSA];
CRGB ledsB[NUM_LEDSB];
CRGB ledsT[NUM_LEDST];
_void setup()
{
// ambilight comms & debug
Serial.begin(115200);
//Serial.println(“test”);_

FastLED.addLeds<WS2811, DATA_PIN, BRG>(ledsB, NUM_LEDS).setCorrection(TypicalLEDStrip);
_ LEDS.showColor(CRGB(0, 0, 0));
Serial.print(“Ada\n”);
}
for(;:wink:
{
updateAmbilight();
//doOtherStuff(); like updating my other Leds and reading the incoming Wifi signal
}
void updateAmbilight()
{
if (waiting) {
if (Serial.available() && prefixi < sizeof prefix)
{
if (prefix == Serial.read())
{
prefixi++;
}
else {
prefixi = 0;
}
}
while (!Serial.available()) ;;
hi = Serial.read();
while (!Serial.available()) ;;
lo = Serial.read();
while (!Serial.available()) ;;
chk = Serial.read();

if (chk != (hi ^ lo ^ 0x55)) {
prefixi = 0;
waiting = true;
}
else{
waiting = false;
}
}
//the initial prefix was successful, go update stuff*

* else {

if(true)//when done*

* {
waiting = true;
prefixi = 0;
while (!Serial.available()); //this delay is usually not long enough to make a real impact on the performance of the overall script*
* // setting the LED colors, but not even the first part is working properly, so…
}
}
}[/sup]*
I removed all the wifi stuff etc, since this is the only part I’m having trouble with…
Pls Halp meh :sob:_

Use code tags! (See the pinned "how to use this forum" thread if you're unclear on how to do that) The forum is parsing pieces of your code into smiley faces.

What is wrong with the behavior you're getting?