Controlling Status LEDs

The RevPi Flat has six LEDs as status indicators. The LED at the upper left with the power icon indicates whether the power supply is connected. All remaining LEDs can be assigned freely to your projects.

 

Color Palette

All status indicators are two-color LEDs that can be switched to green and red. If the freely assignable LEDs A1 – A5 are switched on simultaneously in red and green, they light up orange.

The Power LED is different: it lights green during normal operation and can also be switched to red like the other LEDs. You can thus use it to display any kind of error, for example. When the red Power LED is switched on, the green LED is automatically switched off. This means that this LED cannot light up orange.

Switching the light on and off

The LEDs are exported to the sysfs directory “/sys/class/leds/”, meaning that you can control the LEDs using the files under these directories. There are eleven subdirectories under “sysfs”: a1_green, a1_red, a2_green, a2_red, …, a5_green, a5_red and power_red. According to the marking of the LEDs on the housing, the following assignment of the directories applies:

Marking on Housing

sysfs subdirectories (/sys/class/leds/)

Power icon

power_red

A1

a1_green
a1_red

A2

a2_green
a2_red

A3

a3_green
a3_red

A4

a4_green
a4_red

A5

a5_green
a5_red

Direct Control:

You switch the LEDs on or off by setting the value between 0 and 255 in the file “brightness” under the corresponding subfolder.

Example: enter the following commands to switch LED A1 to green:

echo 255 | sudo tee /sys/class/leds/a1_green/brightness
echo 0 | sudo tee /sys/class/leds/a1_red/brightness

Example: enter the following commands to switch LED A1 to red:

echo 0 | sudo tee /sys/class/leds/a1_green/brightness
echo 255 | sudo tee /sys/class/leds/a1_red/brightness

Please do not let this lead you to believe that the LEDs can be dimmed, however. Any value > = 1 simply switches the LED on.

To make an LED light up orange, you must switch on both the red and the green LED accordingly.

Enter the following commands, e.g. for LED A1:

echo 255 | sudo tee /sys/class/leds/a1_green/brightness echo 255 | sudo tee /sys/class/leds/a1_red/brightness

Control with piTest:

The following table shows the values of the RevPiLED variables with which you control the respective LED via piTest.

LED

RevPiLED GREEN

RevPiLED RED

A1

0x0001

0x0002

A2

0x0004

0x0008

A3

0x0010

0x0020

A4

0x0040

0x0080

A5

0x0100

0x0200

Example:

Enter the value 16 (i.e. 0x0010 in hex) at RevPiLED to turn LED A3 green.

piTest -w RevPiLED,16