Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support controlling WS2812(-like) LEDs / stripes #620

Open
1 of 2 tasks
orangecms opened this issue Jul 5, 2020 · 1 comment
Open
1 of 2 tasks

support controlling WS2812(-like) LEDs / stripes #620

orangecms opened this issue Jul 5, 2020 · 1 comment
Labels

Comments

@orangecms
Copy link
Collaborator

  • I'm submitting a ...

    • bug report
    • feature request
  • What is the current status?

This is not yet implemented afaik. There is a way to generate square waves, but that's about it so far.

  • What is the expected behavior?

We'd need to wire this up here in the app. A an API and the UI allowing to add a number of LEDs in a row plus their type would be the the minimum; later on, we can add effects like rainbow etc..

  • Other information ( Any research that you may have done which you think is the cause of problem )

The Python lib can already do this, on the SQ1 pin: I.WS2812B([[255,0,0]],'SQR1')

See also the NodeMCU firmware project providing a rich library for the ESP8266: https://github.com/nodemcu/nodemcu-firmware/blob/master/app/modules/ws2812.c

  • Would you like to work on it?
@orangecms
Copy link
Collaborator Author

orangecms commented Aug 27, 2020

This works:

from PSL import sciencelab
from time import sleep

pslab = sciencelab.connect(port = "/dev/ttyUSB0")

r = [255,0,0] # red
g = [0,255,0] # green
b = [0,0,255] # blue

y = [255,255,0] # yellow
m = [255,0,255] # magenta
c = [0,255,255] # cyan

w = [200,200,200] # white

lights = [r, g, b, y, m, c, w, r,
          g, b, y, m, c, w, r, g,
         ]
#          b, y, m, c, w, r, g, b,
#          y, m, c, w, r, g]

while True:
    pslab.WS2812B(lights,'SQR1')
    lights = lights[1:] + lights [:1]
    sleep(0.5)

The additional LEDs after the first 16 are intentionally commented out. When I tried, I got some errors like the following:

unpack requires a buffer of 1 bytes
unpack requires a buffer of 1 bytes

The green LED indicating MCU activing was blinking somehow. It could be a bug in pslab-firmware.

Addendum: I used a USB charger for power supply and thus a different USB serial adapter to protect my laptop's USB ports while drawing much current. These LEDs can take up to 50mA each, so 30 of them, which I have on a strip, could draw 1.5A, which is quite a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants