Difference between revisions of "Rock/LED"
(→python) |
|||
(8 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{rock_header}} | |
+ | {{Languages| rock/LED}} | ||
+ | The Radxa Rock has 3 LEDs on board. | ||
+ | {| class="wikitable" style="width:25%; white-space:nowrap; text-align:center" | ||
+ | ! scope="col" | LED | ||
+ | ! scope="col" | GPIO ref. | ||
+ | ! scope="col" | GPIO number | ||
+ | |- | ||
+ | ! scope="row" | <span style="color: green;">Green</span> | ||
+ | | GPIO0_B4 || 172 | ||
+ | |- | ||
+ | ! scope="row" | <span style="color: blue;">Blue</span> | ||
+ | | GPIO0_B6 || 174 | ||
+ | |- | ||
+ | ! scope="row" | <span style="color: red;">Red</span> | ||
+ | | GPIO0_B7 || 175 | ||
+ | |} | ||
− | + | All are programmable using either LEDs class devices or GPIOs. | |
__TOC__ | __TOC__ | ||
− | == | + | == LEDs as class devices == |
− | + | ||
− | + | On the latest kernel images (Ubuntu 14.04 server/desktop), the 3 LEDs are configured as LED class devices. | |
− | + | You can control them via '''/sys/class/leds/''' | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | Read the documentation for more information: https://www.kernel.org/doc/Documentation/leds/leds-class.txt | |
− | + | The default status of the three on board leds are: | |
− | + | * <span style="color: red;">Red</span>: On when there is power | |
− | + | * <span style="color: green;">Green</span>: Flash twice per second after the kernel booting, it's called heartbeat. | |
− | + | * <span style="color: blue;">Blue</span>: Flash when the uSD card is reading/writing. | |
− | + | ||
− | + | ||
− | + | ||
− | + | You can change the behaviour of each LED by using the '''echo''' command on their '''trigger''' property. | |
− | + | root@radxa:~ # echo none > /sys/class/leds/red/trigger | |
− | + | root@radxa:~ # echo default-on > /sys/class/leds/red/trigger | |
− | + | root@radxa:~ # echo timer > /sys/class/leds/red/trigger | |
− | + | root@radxa:~ # echo heartbeat > /sys/class/leds/red/trigger | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | You can use '''cat''' on the '''trigger''' property to list all the available values. | |
− | + | root@radxa:~ # cat /sys/class/leds/red/trigger | |
− | + | none test_ac-online test_battery-charging-or-full test_battery-charging test_battery-full test_battery-charging-blink-full-solid mmc0 mmc1 timer [heartbeat] backlight gpio default-on sleep rfkill0 | |
− | + | Here is the list of current triggers: | |
+ | * none | ||
+ | * test_ac-online | ||
+ | * test_battery-charging-or-full | ||
+ | * test_battery-charging | ||
+ | * test_battery-full | ||
+ | * test_battery-charging-blink-full-solid | ||
+ | * mmc0 | ||
+ | * mmc1 | ||
+ | * timer | ||
+ | * heartbeat | ||
+ | * backlight | ||
+ | * gpio | ||
+ | * default-on | ||
+ | * sleep | ||
+ | * rfkill0 | ||
− | + | '''The GPIO control external LEDs is moved to [[rock/GPIO|GPIO]] page.''' | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | == turn off LEDs == | |
− | + | ||
− | + | use "none" trigger for triggered LEDs or just turn off for non-triggered LEDs. | |
− | + | ||
− | + | ||
− | + | ||
− | + | e.g. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | echo none > /sys/class/leds/blue/trigger | |
− | + | echo none > /sys/class/leds/green/trigger | |
+ | echo 0 > /sys/class/leds/red/brightness | ||
− | + | you can modify [https://github.com/radxa/linux-rockchip/blob/889bc07b6e62705a8ea04b021db3cc73a786c2d4/arch/arm/mach-rk3188/board-rk3188-box.c#L1330 kernel] to change default state at boot. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Latest revision as of 05:23, 6 January 2015
The Radxa Rock has 3 LEDs on board.
LED | GPIO ref. | GPIO number |
---|---|---|
Green | GPIO0_B4 | 172 |
Blue | GPIO0_B6 | 174 |
Red | GPIO0_B7 | 175 |
All are programmable using either LEDs class devices or GPIOs.
Contents
LEDs as class devices
On the latest kernel images (Ubuntu 14.04 server/desktop), the 3 LEDs are configured as LED class devices.
You can control them via /sys/class/leds/
Read the documentation for more information: https://www.kernel.org/doc/Documentation/leds/leds-class.txt
The default status of the three on board leds are:
- Red: On when there is power
- Green: Flash twice per second after the kernel booting, it's called heartbeat.
- Blue: Flash when the uSD card is reading/writing.
You can change the behaviour of each LED by using the echo command on their trigger property.
root@radxa:~ # echo none > /sys/class/leds/red/trigger root@radxa:~ # echo default-on > /sys/class/leds/red/trigger root@radxa:~ # echo timer > /sys/class/leds/red/trigger root@radxa:~ # echo heartbeat > /sys/class/leds/red/trigger
You can use cat on the trigger property to list all the available values.
root@radxa:~ # cat /sys/class/leds/red/trigger none test_ac-online test_battery-charging-or-full test_battery-charging test_battery-full test_battery-charging-blink-full-solid mmc0 mmc1 timer [heartbeat] backlight gpio default-on sleep rfkill0
Here is the list of current triggers:
- none
- test_ac-online
- test_battery-charging-or-full
- test_battery-charging
- test_battery-full
- test_battery-charging-blink-full-solid
- mmc0
- mmc1
- timer
- heartbeat
- backlight
- gpio
- default-on
- sleep
- rfkill0
The GPIO control external LEDs is moved to GPIO page.
turn off LEDs
use "none" trigger for triggered LEDs or just turn off for non-triggered LEDs.
e.g.
echo none > /sys/class/leds/blue/trigger echo none > /sys/class/leds/green/trigger echo 0 > /sys/class/leds/red/brightness
you can modify kernel to change default state at boot.