psieg / Lightpack

Lightpack and Prismatik open repository
GNU General Public License v3.0
1.57k stars 188 forks source link

lightning when using ambilight #284

Closed sblantipodi closed 7 months ago

sblantipodi commented 4 years ago

Hi, I'm experiencing some occasional lightning during the use in the "ambilight mode".

When playing videos or even when the image is still, sometimes I see some lightning that lasts some microseconds...

Am I the only one with this problem?

zalerapraxis commented 4 years ago

If you're getting it with Ambilight mode but not, say, solid mood lamp, it sounds like your baud rate might be too high.

I use an Arduino Nano with an LED strip of SK6812s. If I set the baud rate too high, I would get those occasional flashes randomly across my strip. Setting it to 250,000 (by editing %userprofile%/Prismatik/main.conf) fixed this without causing any noticeable delay.

If you're using a similar setup and you're getting the flashing issues while in mood lamp mode, for example, you may want to run some test scripts directly on your controller device, to see if the issue is with Prismatik and not something further down the line.

sblantipodi commented 4 years ago

If you're getting it with Ambilight mode but not, say, solid mood lamp, it sounds like your baud rate might be too high.

I use an Arduino Nano with an LED strip of SK6812s. If I set the baud rate too high, I would get those occasional flashes randomly across my strip. Setting it to 250,000 (by editing %userprofile%/Prismatik/main.conf) fixed this without causing any noticeable delay.

If you're using a similar setup and you're getting the flashing issues while in mood lamp mode, for example, you may want to run some test scripts directly on your controller device, to see if the issue is with Prismatik and not something further down the line.

I had 115200 as baudrate. is this the problem?

using adalight with a ws2812B strip

zalerapraxis commented 4 years ago

Sorry for the slow response. I can't tell you if that's your issue - I personally didn't notice flickering issues at lower baud rates, but instead noticed lag between the colors of my screen and the colors of the LEDs. Bumping my baud rate up to 256000 fixed that issue but then caused an issue similar to what you're experiencing.

Your baud rate seems low enough that it shouldn't cause an issue like what I had.

Try loading some of the FastLED demo scripts (this one in particular: https://github.com/FastLED/FastLED/blob/master/examples/DemoReel100/DemoReel100.ino) and see if your lights flicker. One of the patterns on that script will intentionally cause your lights to flicker - if you want, on line 42, remove 'rainbowWithGlitter' and it'll get rid of the intentional flickering segment.

If the issue persists, it may be hardware related.

sblantipodi commented 4 years ago

with that demo it doesn't happen. still investigating the problem but thanks for the answer. I will update the issue if I discover something soon. thanks

dmadison commented 4 years ago

What firmware are you using on the Arduino?

Try this: https://github.com/dmadison/Adalight-FastLED

sblantipodi commented 4 years ago

@dmadison Espressif 8266 that bundles the Arduino core 2.6.3

dmadison commented 4 years ago

No, I mean what code are you using to read the ambilight data and send it to the LEDs?

sblantipodi commented 4 years ago

No, I mean what code are you using to read the ambilight data and send it to the LEDs?

sorry for the late reply.

I use prismatik windows software using this code on an ESP8266EX https://github.com/sblantipodi/pc_ambilight/blob/master/AmbilightFinal.ino

dmadison commented 4 years ago

I'd recommend trying the code I linked. Even as a test, that will tell you whether you have a software or a hardware problem.

One thing I noticed in your code is that you're not flushing the serial buffer between frames. If both the Prismatik update rate and the serial baud rate are high enough you'll buffer the header bytes but lose the color data when interrupts are disabled, which will cause flashing.

sblantipodi commented 4 years ago

I'd recommend trying the code I linked. Even as a test, that will tell you whether you have a software or a hardware problem.

One thing I noticed in your code is that you're not flushing the serial buffer between frames. If both the Prismatik update rate and the serial baud rate are high enough you'll buffer the header bytes but lose the color data when interrupts are disabled, which will cause flashing.

With the code you posted I have no flashes.

How can I flash the serial buffer? Thanks I really appreciate the help.

dmadison commented 4 years ago

Before you read the next frame of serial data, just read bytes out of the buffer until it's empty:


while(Serial.available() > 0) {
    Serial.read();
}
sblantipodi commented 4 years ago

Before you read the next frame of serial data, just read bytes out of the buffer until it's empty:

while(Serial.available() > 0) {
    Serial.read();
}

Can I do it after line 643 of my code after the Fastled.show() ??? Thanks

dmadison commented 4 years ago

Yes.

sblantipodi commented 4 years ago

same problem.

jebbett commented 4 years ago

I was having the same problem, add the below at the very top of the script, this fixes the flashing issue on FASTLED:

define FASTLED_ALLOW_INTERRUPTS 0