I have a strip I want to use as a fill light, I’ve tried adapting a basic test script as im not a coder, and I can’t get it to work. I’ve tried using the strip fill animation, but I can’t get it to just tell the strip to light up x number of pixels x color and just… Not animate anything.
So I guess I just need advice on how to tell bibliopixel to light up a strip withouot an animation.
There’s a fill
animation: https://github.com/ManiacalLabs/BiblioPixel/blob/master/bibliopixel/animation/fill.py
Please provide whatever script or project file you have tried so far.
NUMBEROFPIXELS = 140
import time
import bibliopixel
import bibliopixel.colors as colors
bibliopixel.log.setLogLevel(bibliopixel.log.DEBUG)
from bibliopixel.drivers.serial import *
driver = Serial(num = NUMBEROFPIXELS, ledtype = LEDTYPE.WS2812B, device_id = 0)
from bibliopixel.layout import *
led = Strip(driver)
try:
led.set_brightness(50)
for i in range(0,NUMBEROFPIXELS):
led.set(i,colors.White)
led.update()
time.sleep(0.01)
led.all_off()
led.update()
except KeyboardInterrupt:
led.all_off()
led.update()
And I know that gives me a sequential test updating the pixels white.
I tried inserting the fill animation lines instead of the last lines in this, but I just get syntax errors, which i’m not really sure how to correct.
Can you please show what those syntax errors are?
You can also just use led.fill(colors.White)
to fill everything the same color.
driver = Serial(num = NUMBEROFPIXELS, ledtype = LEDTYPE.WS2812B, device_id = 0)
from bibliopixel.layout import *
led = Strip(driver)
try:
led.set_brightness(50)
for i in range(0,NUMBEROFPIXELS):
led.fill(colors.Red) )
Right sorry, that seems kind of obvious. I feel like this is probably an obvious coding thing, without the 2nd bracket I get an EOF error, so I thought the 2nd bracket closes the whole thing but its syntax is wrong
I’m honestly not sure what you are getting at with the syntax error. If you see any errors please provide them here. Granted, I see that you have an extra )
on the led.fill
line but it looks like you didn’t include all of your code here. You have a try
directive but no except
which would end that block. If this is, in fact, your entire code then yes, there’s a definite syntax issue as it’s missing the rest of that try
block.
Also, you don’t need the for
loop anymore because led.fill
handles that. Just do like below:
led.set_brightness(50)
led.fill(colors.Red)
led.update()
Sorry I can’t be more specific but it’s a little hard to tell what’s up given what’s provided. A couple hints for posting code issues:
-
Always post code in a preformatted text block. There is a button in the Discourse editor that looks like
</>
- just paste in your code, select all of it, then hit that button. Another option is that discourse supports Markdown syntax. So you can just wrap any code in a block of triple “back-tick” marks. That’s the one under the~
(assuming a US keyboard). More here: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code - Always include the full text of all errors that you see. To you it may just be a random syntax error, but it would be really helpful to me
right, the try might be inappropriate, I am just copying code from the original code in my first reply that does a sequential.
NUMBEROFPIXELS = 140
import time
import bibliopixel
import bibliopixel.colors as colors
bibliopixel.log.setLogLevel(bibliopixel.log.DEBUG)
from bibliopixel.drivers.serial import *
driver = Serial(num = NUMBEROFPIXELS, ledtype = LEDTYPE.WS2812B, device_id = 0)
from bibliopixel.layout import *
led = Strip(driver)
try:
led.set_brightness(50)
led.fill(colors.Red)
except KeyboardInterrupt:
led.all_off()
led.update()
And that’s the code I just tried, it returns
WARNING - deprecated - util.setLogLevel
INFO - devices - Using COM Port: /dev/ttyACM0, Device ID: 0, Device Ver: 0
which usually turns up when it starts and asks the allpixel to reboot, but i have my strip connected and nothing happened.
you have to use led.update()
after led.fill()
otherwise you won’t see anything.
awesome, working great thanks
sorry i made it more difficult, but I know for next time I need to copy all the errors and code.
No worries at all! Discussing code in forums is not the most obvious thing unless you are used to it.
Glad it’s working now
actually I am getting the wrong colour though, I know it’s GRB so I tried this
i mport time
import bibliopixel
import bibliopixel.colors as colors
bibliopixel.log.setLogLevel(bibliopixel.log.DEBUG)
from bibliopixel.drivers.serial import *
driver = Serial(num = NUMBEROFPIXELS, ledtype = LEDTYPE.WS2812B, c_order = ChannelOrder.GRB, device_id = 0)
from bibliopixel.layout import *
led = Strip(driver)
try:
led.set_brightness(75)
led.fill(colors.Green)
led.update()
except KeyboardInterrupt:
led.all_off()
led.update()
but that gives me the error that channelorder is not defined.
I tried finding it on these pages, but when it comes to the actual names to reference for specific order, they seem to reference each other.
Also i thought white should come up the same whatever the order, but I’m getting this amber/skin tone kind of colour.
Should just need to add from bibliopixel import ChannelOrder