1*5fd752b6SBaolin WangWhat: /sys/class/leds/<led>/pattern 2*5fd752b6SBaolin WangDate: September 2018 3*5fd752b6SBaolin WangKernelVersion: 4.20 4*5fd752b6SBaolin WangDescription: 5*5fd752b6SBaolin Wang Specify a software pattern for the LED, that supports altering 6*5fd752b6SBaolin Wang the brightness for the specified duration with one software 7*5fd752b6SBaolin Wang timer. It can do gradual dimming and step change of brightness. 8*5fd752b6SBaolin Wang 9*5fd752b6SBaolin Wang The pattern is given by a series of tuples, of brightness and 10*5fd752b6SBaolin Wang duration (ms). The LED is expected to traverse the series and 11*5fd752b6SBaolin Wang each brightness value for the specified duration. Duration of 12*5fd752b6SBaolin Wang 0 means brightness should immediately change to new value, and 13*5fd752b6SBaolin Wang writing malformed pattern deactivates any active one. 14*5fd752b6SBaolin Wang 15*5fd752b6SBaolin Wang 1. For gradual dimming, the dimming interval now is set as 50 16*5fd752b6SBaolin Wang milliseconds. So the tuple with duration less than dimming 17*5fd752b6SBaolin Wang interval (50ms) is treated as a step change of brightness, 18*5fd752b6SBaolin Wang i.e. the subsequent brightness will be applied without adding 19*5fd752b6SBaolin Wang intervening dimming intervals. 20*5fd752b6SBaolin Wang 21*5fd752b6SBaolin Wang The gradual dimming format of the software pattern values should be: 22*5fd752b6SBaolin Wang "brightness_1 duration_1 brightness_2 duration_2 brightness_3 23*5fd752b6SBaolin Wang duration_3 ...". For example: 24*5fd752b6SBaolin Wang 25*5fd752b6SBaolin Wang echo 0 1000 255 2000 > pattern 26*5fd752b6SBaolin Wang 27*5fd752b6SBaolin Wang It will make the LED go gradually from zero-intensity to max (255) 28*5fd752b6SBaolin Wang intensity in 1000 milliseconds, then back to zero intensity in 2000 29*5fd752b6SBaolin Wang milliseconds: 30*5fd752b6SBaolin Wang 31*5fd752b6SBaolin Wang LED brightness 32*5fd752b6SBaolin Wang ^ 33*5fd752b6SBaolin Wang 255-| / \ / \ / 34*5fd752b6SBaolin Wang | / \ / \ / 35*5fd752b6SBaolin Wang | / \ / \ / 36*5fd752b6SBaolin Wang | / \ / \ / 37*5fd752b6SBaolin Wang 0-| / \/ \/ 38*5fd752b6SBaolin Wang +---0----1----2----3----4----5----6------------> time (s) 39*5fd752b6SBaolin Wang 40*5fd752b6SBaolin Wang 2. To make the LED go instantly from one brigntess value to another, 41*5fd752b6SBaolin Wang we should use use zero-time lengths (the brightness must be same as 42*5fd752b6SBaolin Wang the previous tuple's). So the format should be: 43*5fd752b6SBaolin Wang "brightness_1 duration_1 brightness_1 0 brightness_2 duration_2 44*5fd752b6SBaolin Wang brightness_2 0 ...". For example: 45*5fd752b6SBaolin Wang 46*5fd752b6SBaolin Wang echo 0 1000 0 0 255 2000 255 0 > pattern 47*5fd752b6SBaolin Wang 48*5fd752b6SBaolin Wang It will make the LED stay off for one second, then stay at max brightness 49*5fd752b6SBaolin Wang for two seconds: 50*5fd752b6SBaolin Wang 51*5fd752b6SBaolin Wang LED brightness 52*5fd752b6SBaolin Wang ^ 53*5fd752b6SBaolin Wang 255-| +---------+ +---------+ 54*5fd752b6SBaolin Wang | | | | | 55*5fd752b6SBaolin Wang | | | | | 56*5fd752b6SBaolin Wang | | | | | 57*5fd752b6SBaolin Wang 0-| -----+ +----+ +---- 58*5fd752b6SBaolin Wang +---0----1----2----3----4----5----6------------> time (s) 59*5fd752b6SBaolin Wang 60*5fd752b6SBaolin WangWhat: /sys/class/leds/<led>/hw_pattern 61*5fd752b6SBaolin WangDate: September 2018 62*5fd752b6SBaolin WangKernelVersion: 4.20 63*5fd752b6SBaolin WangDescription: 64*5fd752b6SBaolin Wang Specify a hardware pattern for the LED, for LED hardware that 65*5fd752b6SBaolin Wang supports autonomously controlling brightness over time, according 66*5fd752b6SBaolin Wang to some preprogrammed hardware patterns. It deactivates any active 67*5fd752b6SBaolin Wang software pattern. 68*5fd752b6SBaolin Wang 69*5fd752b6SBaolin Wang Since different LED hardware can have different semantics of 70*5fd752b6SBaolin Wang hardware patterns, each driver is expected to provide its own 71*5fd752b6SBaolin Wang description for the hardware patterns in their ABI documentation 72*5fd752b6SBaolin Wang file. 73*5fd752b6SBaolin Wang 74*5fd752b6SBaolin WangWhat: /sys/class/leds/<led>/repeat 75*5fd752b6SBaolin WangDate: September 2018 76*5fd752b6SBaolin WangKernelVersion: 4.20 77*5fd752b6SBaolin WangDescription: 78*5fd752b6SBaolin Wang Specify a pattern repeat number. -1 means repeat indefinitely, 79*5fd752b6SBaolin Wang other negative numbers and number 0 are invalid. 80*5fd752b6SBaolin Wang 81*5fd752b6SBaolin Wang This file will always return the originally written repeat 82*5fd752b6SBaolin Wang number. 83