brintos

brintos / linux-shallow public Read only

0
0
Text · 3.0 KiB · c57b98b Raw
87 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3====================================4Multicolor LED handling under Linux5====================================6 7Description8===========9The multicolor class groups monochrome LEDs and allows controlling two10aspects of the final combined color: hue and lightness. The former is11controlled via the multi_intensity array file and the latter is controlled12via brightness file.13 14Multicolor Class Control15========================16The multicolor class presents files that groups the colors as indexes in an17array.  These files are children under the LED parent node created by the18led_class framework.  The led_class framework is documented in led-class.rst19within this documentation directory.20 21Each colored LED will be indexed under the multi_* files. The order of the22colors will be arbitrary. The multi_index file can be read to determine the23color name to indexed value.24 25The multi_index file is an array that contains the string list of the colors as26they are defined in each multi_* array file.27 28The multi_intensity is an array that can be read or written to for the29individual color intensities.  All elements within this array must be written in30order for the color LED intensities to be updated.31 32Directory Layout Example33========================34root:/sys/class/leds/multicolor:status# ls -lR35-rw-r--r--    1 root     root          4096 Oct 19 16:16 brightness36-r--r--r--    1 root     root          4096 Oct 19 16:16 max_brightness37-r--r--r--    1 root     root          4096 Oct 19 16:16 multi_index38-rw-r--r--    1 root     root          4096 Oct 19 16:16 multi_intensity39 40Multicolor Class Brightness Control41===================================42The brightness level for each LED is calculated based on the color LED43intensity setting divided by the global max_brightness setting multiplied by44the requested brightness.45 46led_brightness = brightness * multi_intensity/max_brightness47 48Example:49A user first writes the multi_intensity file with the brightness levels50for each LED that are necessary to achieve a certain color output from a51multicolor LED group.52 53cat /sys/class/leds/multicolor:status/multi_index54green blue red55 56echo 43 226 138 > /sys/class/leds/multicolor:status/multi_intensity57 58red -59	intensity = 13860	max_brightness = 25561green -62	intensity = 4363	max_brightness = 25564blue -65	intensity = 22666	max_brightness = 25567 68The user can control the brightness of that multicolor LED group by writing the69global 'brightness' control.  Assuming a max_brightness of 255 the user70may want to dim the LED color group to half.  The user would write a value of71128 to the global brightness file then the values written to each LED will be72adjusted base on this value.73 74cat /sys/class/leds/multicolor:status/max_brightness7525576echo 128 > /sys/class/leds/multicolor:status/brightness77 78adjusted_red_value = 128 * 138/255 = 6979adjusted_green_value = 128 * 43/255 = 2180adjusted_blue_value = 128 * 226/255 = 11381 82Reading the global brightness file will return the current brightness value of83the color LED group.84 85cat /sys/class/leds/multicolor:status/brightness8612887