Can't turn on leds rigth after boot

info about ReSpeaker series products

Moderators: lily.li, violet, seth.welday

Post Reply
frederic.bost
Pre-kindergarten
Pre-kindergarten
Posts: 10
Joined: Fri Mar 23, 2018 10:22 am

Can't turn on leds rigth after boot

Post by frederic.bost » Wed Aug 15, 2018 9:22 pm

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()

-----------------------

bill.yu
Junior-7
Junior-7
Posts: 735
Joined: Mon Apr 02, 2018 11:05 am

Re: Can't turn on leds rigth after boot

Post by bill.yu » Thu Aug 16, 2018 12:02 pm

HI,for the 1 second delay, because the gpio is not operated by normal user. so we open the access in udev. it takes a while to enable the function for normal user to operate the gpio. so that's why we need 1 second for normal user and for root, there is no need for the 1 second.

for the first question, we still debug and try to figure out the solution. keep you posted. thanks.

Bill

seeed techsupport team
Staff
Staff
Posts: 44
Joined: Mon Mar 19, 2018 11:40 am

Re: Can't turn on leds rigth after boot

Post by seeed techsupport team » Thu Aug 16, 2018 3:29 pm

Hi there,

for the first question, which firmware do you use? is it 2018.8.01 version? thanks.

Bill

frederic.bost
Pre-kindergarten
Pre-kindergarten
Posts: 10
Joined: Fri Mar 23, 2018 10:22 am

Re: Can't turn on leds rigth after boot

Post by frederic.bost » Thu Aug 16, 2018 8:29 pm

Hi Bill,

Yes it is firmware version 2018.8.01

Thanks
Frederic

bill.yu
Junior-7
Junior-7
Posts: 735
Joined: Mon Apr 02, 2018 11:05 am

Re: Can't turn on leds rigth after boot

Post by bill.yu » Fri Aug 17, 2018 11:00 am

Hi there,

I use the firmware version 2018.8.01, add delay before device.show and it turns on the leds after boot as first time. We suspect it may related with the gpio operation as well. thanks.


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

time.sleep(2)
device.show()

Bill

Post Reply