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.7k stars 641 forks source link

MORE LEDS!! #200

Closed lpearl closed 5 years ago

lpearl commented 5 years ago

Hi,

Anyone have any ideas on how to connect 1200 LEDs. I seem to be maxing out at 300 on both the pi method and esp8266. Im sure a solution would be to get a esp8266 for each led strip but I would rather not. Any Ideas?

Thanks,

lpearl

noppelmax commented 5 years ago

See PR #201 . I made a setup with multiple ESP. This is working fine. The limitation to 255 LEDs remains.

ChasonDeshotel commented 5 years ago

@lpearl @noppelmax

Bypassing the 255 LED limit was pretty simple actually. I'd make a pull request but it looks like this project is no longer maintained and I'm not even using it so meh. Probably why there's so many forks. Anyway here's your fix:

That limitation exists due to the conversion to bytes (line 81 in led.py)

bytes(m) gives ValueError: bytes must be in range(0, 256) when your pixel index is over 256

I got around this by sending an extra byte for the 100s place

led.py, line 80:

m.append( int( i / 100 ) )
m.append( int( i % 100 ) )
m.append( p[0][i] )
m.append( p[1][i] )
m.append( p[2][i] )

That will give you a byte for the 100s place, a byte for the remainder, and then your RGB

So pixel 315 white would be "3, 15, 255, 255, 255"

That'll give you umm 25599 pixels

Now for the arduino code, we have to update the loop increment value, and then compute the pixel index

// this used to be i+=4, but we have an extra value so now we're moving by sets of 5
for(int i = 0; i < len; i+=5) {
            packetBuffer[len] = 0;

            // first bit is the number of hundreds
            N = ((uint8_t)packetBuffer[i] * 100) + (uint8_t)packetBuffer[i+1]; 
BenoitAnastay commented 4 years ago

@ChasonDeshotel Actually there is a better way, check this out https://github.com/scottlawsonbc/audio-reactive-led-strip/pull/254/commits/4ac417a8f82022d71b257f41f9bac477addb72a6 https://github.com/scottlawsonbc/audio-reactive-led-strip/pull/254 (bit shifting)

+            N = ((packetBuffer[i] << 8) + packetBuffer[i + 1]);
+            RgbColor pixel((uint8_t)packetBuffer[i+2], (uint8_t)packetBuffer[i+3], (uint8_t)packetBuffer[i+4]);
             ledstrip.SetPixelColor(N, pixel);
+                m.append(i >> 8)  # Index of pixel to change
+                m.append(i & 0xff)
ChasonDeshotel commented 4 years ago

Oh, yeah. Took a second for it to click but that's fantastic. Nicely done, @BenoitAnastay