User Tools

Site Tools


How to control LED diodes

The rainbow utility serves to control the state, intensity and color of the led diodes. The configuration of basic functions can be found in the UCI file /etc/config/rainbow.

Versions of Turris OS 1.2 and higher have the option of setting the colors through the LuCI interface.

Setting the color

LuCI interface

Log into LuCI.

Open System / Rainbow.

The section Color and status of all LEDs lets you either select one of the predefined colors by picking an option from the drop-down menu next to Color. Alternatively you can write down a hexa color code of your choosing under –custom–. We recommend to read the note about available colors. The item Status lets you set the diode to:

  • On
  • Off
  • Auto (leaves the control of the LED diodes to the HW – blinking during data transfer and so on.)

You can also define a color and set the state for a group of diodes or each diode individually. To do this, click on the button Add under the label of the given part and continue as was described in section Color and status of all LEDs.

Finally confirm your changes by clicking Save and apply at the bottom of the page.

Via the console

First of all it is necessary to log into the console through root.

A permanent change of color (which will survive a reboot) can be set in the UCI configuration file /etc/config/rainbow.

For setting a color, which will be same for all diodes, you can write the following code into the configuration:

/etc/config/rainbow
config led 'all'
        option color 'red'
        option status 'auto'

It's also possible to set a different color for each set of diodes. That can look for example like this:

/etc/config/rainbow
config led 'pwr'
        option color 'red'
        option status 'auto'
 
config led 'wifi'
        option color blue''
        option status 'auto'
 
config led 'lan'
        option color 'green'
        option status 'auto'
 
config led 'wan'
        option color 'FFFFFF'
        option status 'auto'
 

The example shows that different colors can be set for the WAN port, the power the state of WiFi and all the LAN port diodes.

In order for the changes to the configuration to take place, restart the rainbow service via the command /etc/init.d/rainbow restart.

Available colors

You can configure the color via three hexadecimal numbers, which represent individual RGB components. For every component there is one byte, without spaces and without the initial 0x. There are also a few predefined abbreviations: red = FF0000, green = 00FF00, blue = 0000FF, white FFFFFF and black = 000000 - “off state”.

It should be added that the color, which the diodes have, doesn't directly correspond to the given hexadecimal number. The HW is not able to fully represent the linear scale and the color doesn't change roughly from the middle of the interval (0-255). For example white color (FFFFFF) has a bluish tone to it, but we have tested that 33FF33 is distinctly white. That is why it's necessary to experiment a little in order to find the right color tone.

Setting the intensity

You can set 8 degrees of LED diode shine intensity - 7 degrees and off.

The main means to set this is the button, which (on the Omnia model) is located on the front side of the router, on the very right. Pressing it decreases the intensity of shine until that reaches it's minimum (off) and then starts at highest intensity again. The SW detects the change and remembers it – that's why the setting restores itself after reboot.

If you want to change shine intensity via SW and not using the button, then you can use rainbow – for technical reasons, intensity does not have a settings option in the configuration. By running the command rainbow intensity 0, the intensity value is set to the maximum.

Value 0 represents maximum and 7 minimum (off).

Automatic overnight dimming

If you want to see the state of individual devices during day, but don't want to be dazzled by LED diodes in the night, it is not necessary to change the intensity manually every day. You can regulate the light intensity automatically.

For setting this, you can use the so called cronjob – a planned task. That can be achieved by creating a text file in the directory /etc/cron.d, where every file contains a definition of one or more planned tasks, one task for every line.

We will have a look at the possible configuration illustrated by this file (/etc/cron.d/rainbow_night):

/etc/cron.d/rainbow_night
MAILTO=""
0	23	*	*	*	root	rainbow intensity 5
0	7	*	*	*	root	rainbow intensity 0

The command MAILTO forbids automatic logging of the output (because it is superfluous). The next two lines code the planned tasks in the following format:

  1. Minute
  2. Hour
  3. Day
  4. Month
  5. Day of the week
  6. The user, who runs this command.
  7. Command

As you can see, the example file codes that the light intensity goes down to the second lowest degree every day at 11 pm and goes back to maximum every day at 7 am.

Rainbow allows you to perform a wide range of settings to the LED diodes. In addition to changing the colors, you can set the status of each diode individually. The setting are disable (off), enable (on) or auto (leaves the control of the LED diodes to the HW – blinking during data transfer and so on.). The complete set of functions of this service can be obtained via the command rainbow -h.