xnux.eu - site map - news

PinePhone LEDs

PinePhone has 3 indicator LEDs (RGB) on the front, and 1 high intensity white flash LED on the back, and LCD backlight.

Indicator LEDs (RGB)

Indicator LEDs are not covered with a material that would diffuse the light, so it's not really possible to ‚mix‘ the colors. If you turn on multiple LEDs you'll see multiple individual colors close together, but still appearing as multiple colors.

By default none of the LEDs are turned on. It's possible to turn them on during boot via a custom code in U-Boot. I have a patch available. Or via gpio command like this. Otherwise if boot takes multiple seconds, the user will not have any feedback that pressing the power button resulted in something.

In Linux, LEDs will be turned off during probe time. It is not possible to regulate LEDs brightness via hardware PWM controller, because LEDs are not connected to one. Indicator LEDs can be either on or off. It may be possible to implement PWM in software, but it would load the CPU quite a bit, because PWM period should be low to avoid flicker. For comparison, switching frequency for the LCD backlight PWM is 20kHz. You don't want to do that with a CPU.

In Linux you can tell the kernel to assign functions to individual LEDs (called LED triggers). You can list the available LED trigger sources by:

cat '/sys/class/leds/pinephone:blue:user/trigger'

You can assign the particular trigger to the led by:

echo trigger-name > '/sys/class/leds/pinephone:blue:user/trigger'

# red indicator for battery charger
echo axp20x-battery-charging-blink-full-solid > '/sys/class/leds/pinephone:red:user/trigger'
# green indicator for both phone being (slow blinking) on and CPU being loaded (fast blinking)
echo activity > '/sys/class/leds/pinephone:green:user/trigger'
# blue indicator for wifi activity
echo mmc1 > '/sys/class/leds/pinephone:blue:user/trigger'
# or blue indicator for eMMC activity
echo mmc2 > '/sys/class/leds/pinephone:blue:user/trigger'

It would be nice to have a LED trigger for battery getting low.

You can also control the leds manually by setting the trigger to none and writing values to the brightness file like so:

# blink a green led for 1 sec
echo 1 > /sys/class/leds/pinephone:green:user/brightness
sleep 1
echo 0 > /sys/class/leds/pinephone:green:user/brightness