Hello,
I have this problem with leds on the respeaker core v2 (debian 9 iot sd image) that I can’t solve.
I created the small python script below based on your provided example.
The very first time I run it after boot, it doesn’t do anything.
If I re-run it though, it works as well as all the following runs.
How can I get the very first time to works too?
And it’s a bit annoying to add 1 second latency before changing the led.
Is there any way to skip the time.sleep(1) when not running it as root, at least for the following call after the pin has been powered?
Thanks for your help
-------------------------
sampleLeds.py:
--------------------------
from apa102 import APA102
import sys, time, os
enable led power
import mraa
en = mraa.Gpio(12)
if os.geteuid() != 0 :
time.sleep(1)
en.dir(mraa.DIR_OUT)
en.write(0)
device = APA102(12)
i = 0
while i < 12:
if sys.argv[1] == ‘blue’:
device.set_pixel(i,0,0,3,100)
elif sys.argv[1] == ‘green’:
device.set_pixel(i,0,3,0,100)
elif sys.argv[1] == ‘red’:
device.set_pixel(i,3,0,0,100)
i+=1
device.show()
-----------------------