scottlawsonbc / audio-reactive-led-strip

:musical_note: :rainbow: Real-time LED strip music visualization using Python and the ESP8266 or Raspberry Pi
MIT License
2.68k stars 644 forks source link

RGBW Query #243

Open NickSutton opened 4 years ago

NickSutton commented 4 years ago

Hi, just testing out the LED’s now I’ve got the full strip working but not seeing much white... Does this line ((https://github.com/scottlawsonbc/audio-reactive-led-strip/blob/e6964c27f025708df3d0d903f54b14539391cce2/python/led.py#L101)) require modifying to send a white value?

Thanks

joeybab3 commented 4 years ago

Yes, I don't know where it was lost on me that you aren't using an Arduino and are in fact using an RPI but at the minimum, you would have to pass in a fourth parameter to set the white led to off and probably a few other tweaks to the code.

NickSutton commented 4 years ago

Thanks Joey, I think I can muddle through the code and add a fourth parameter where appropriate, but I’m a bit confused by the way the variables are nested in the line above.

Would the following be acceptable: rgb = np.bitwise_or(np.bitwise_or(np.bitwise_or(r, g), b), w)

NickSutton commented 4 years ago

OK, I’ve not made any progress with this, but suspect the answer lies in the following lines of code:

# Encode 24-bit LED values in 32 bit integers r = np.left_shift(p[0][:].astype(int), 8) g = np.left_shift(p[1][:].astype(int), 16) b = p[2][:].astype(int) rgb = np.bitwise_or(np.bitwise_or(r, g), b) # Update the pixels

I think rgb = np.bitwise_or(np.bitwise_or(r, g), b)) needs to become rgbw = np.bitwise_or(np.bitwise_or(np.bitwise_or(r, g), b), w) but unsure how to construct a string to define ‘w’ ... Any pointers?

joeybab3 commented 4 years ago

Unfortunately, I don't know much about the algorithm, so I wouldn't be too helpful in this regard. I can suggest trying to just duplicate one of the other color channels and sending that to white?

ex:

# Encode 24-bit LED values in 32 bit integers
r = np.left_shift(p[0][:].astype(int), 8)
g = np.left_shift(p[1][:].astype(int), 16)
b = p[2][:].astype(int)
w = p[2][:].astype(int)
rgbw = np.bitwise_or(np.bitwise_or(np.bitwise_or(r, g), b), w)
# Update the pixels

Though that might just screw everything up.

You could also just apply some scalar/add some value to the red/green/blue channel and use that as the white and do that?