Accessing Led

From InCircuit
Revision as of 14:39, 19 December 2013 by Raik (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To access a given LED from Userspace, the Kernel's sysfs provides a suitable interface. This can be found within /sys/class/leds on a running Board. These LEDs must be configured in the corresponding kernel's board file.

accessing an LED

The following commands have to be executed within the interface-directory (or that must be preceeding every file). You may want to change there by entering

 $ cd /sys/class/leds

Within this file a directory for every LED exists. You can choose any and change here using cd.

Switching an LED manually

Each LED features a file brightness. This file contains or sets the current brightness of the led as a value from '0' (off) to '255' (full on). As most LEDs can't be dimmed, a value of '0' switches the LED off, any other value will switch the LED on. The following example will switch the LED off.

 $ echo 0 > brightness

Using a kernel trigger to switch the LED

The Kernel provides a set of automatic triggers. These can be accessed using the file trigger. The following example will read the available triggers first, and set the mmc0-trigger afterwards.

 $ cat trigger
 none nand-disk [heartbeat] backlight mmc0 mmc1
 $ echo mmc0 > trigger

The triggers are usally self-explaining, but will described here shortly:

  • none No trigger is currently activated, the led is switched manually only
  • nand-disk The led will light whenever the NAND-Flash is accessed.
  • heartbeat The led will pulse like a heart. The more load the system has, the faster will the pulse be.
  • backlight The led can be controlled bia the kernels backlight-interface.
  • default-on The led is switched on
  • mmc0 and mmc1 will light the led whenever the corresponding MMC-Slot is being accessed.

The trigger in square brackets marks the currently active trigger.

Personal tools