Controlling Status LEDs

The RevPi Flat has six LEDs as status indicators.
The LED 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 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:

Via the status byte RevPiLED the LEDs can be controlled as shown in the table.
How to calculate status bytes in general is explained in the section “How to Use Status Bytes“.

Bit

LED

Signal when the bit is set to 1

0

A1

green

1

red

2

A2

green

3

red

4

A3

green

5

red

6

A4

green

7

red

8

A5

green

9

red

Example:

Enter the value 16 at RevPiLED (i.e. binary 0001 0000) to switch LED A3 green .

piTest -w RevPiLED,16

Please note that only the desired bit in the byte RevPiLED should be changed. If, for example, LED A3 is switched green with piTest -w RevPiLED,16, this simultaneously turns off the other LEDs. You have to read the current value, change the desired bit and then write back the whole byte.