Can't turn on leds rigth after boot

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



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

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

Hi there,



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



Bill

Hi Bill,



Yes it is firmware version 2018.8.01



Thanks

Frederic

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