Editing LED patterns

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 25: Line 25:
:<tt>PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern</tt>
:<tt>PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern</tt>
-
 
-
(Though the LP5523 chip has 3 engines meant to control R, G, and B, the mce program exlusively uses engine3 for kbd backlight and so doesn't support pattern
 
-
definitions for engine3. mce is closed source and thus this can't be fixed in any reasonable way. If mce were open, an alternative compatible format was possible:
 
-
 
-
:<tt>PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern;Engine3Pattern</tt>
 
-
 
-
where LEDsToMap was something like "000012300" to map the particular LED to either none, or Engine1..3 respectively.
 
-
 
-
We could also fix mce to allow pattern definitions of arbitrary length up to the max RAM available, which is 96 commands with all RAM allocated to one engine - this would need a patch to support doing this in lp5523.ko driver as well.
 
-
)
 
==== Priority ====
==== Priority ====
Line 80: Line 70:
:<tt>9d8040007f007f0040ff7f007f000000</tt>
:<tt>9d8040007f007f0040ff7f007f000000</tt>
-
Breaking this down for ease of reading we get a list of 8 commands, each of which is four characters long. There may be up to 16 commands for a pattern (kernel driver limitation, the hardware could manage up to 96)
+
Breaking this down for ease of reading we get a list of 8 commands, each of which is four characters long.
:<tt>9d80 4000 7f00 7f00 40ff 7f00 7f00 0000</tt>
:<tt>9d80 4000 7f00 7f00 40ff 7f00 7f00 0000</tt>
-
==== 9d80 - Refresh Engine Multiplexer ====
+
==== 9d80 - Refresh Engine Multiplexor ====
-
This is to be used as the first command of every pattern. If this is excluded from the pattern, the led won't flash. (actually this command loads the first [and only] entry of a predefined [by kernel driver] multiplexer table in chip's RAM to the multiplexer register)
+
This is to be used as the first command of every pattern). If this is excluded from the pattern, the led won't flash.
==== 40xx - Set channel brightness ====
==== 40xx - Set channel brightness ====
Line 120: Line 110:
-
==== A000 .. BFFF - Branch (decrement and branch if non zero) ====
+
==== A000 .. BFFF - Branch ====
101<llllll><sssssss> : 16bit
101<llllll><sssssss> : 16bit
-
llllll : 6bit; Loop count, 0=infinite loop, or max 63 loops
+
llllll : 6bit; Loop count, 0=infinite loop, max 63 loops
-
sssssss : 7 bit; Step number; Value to store to PC (0-95 actual progspace of LP5523 of 96 16bit commands. [Unclear if that's absolute address, or probably offset relative to start of program space assigned to the particular engine])
+
sssssss : 7 bit; Step number; Value to store to PC (0-95 actual progspace of LP5523 of 96 16bit commands. [Unclear if that's absolute address, or probably offset to start of program space assigned to the particular engine])
-
 
+
-
You can build MUCH SMARTER loops with this! ;-D
+
==== c000 - End pattern execution ====
==== c000 - End pattern execution ====
Line 134: Line 122:
(also d000 = with hw INT; c800/d800 = with PC reset. INT might serve to signal end-of-pattern to main CPU ->*)
(also d000 = with hw INT; c800/d800 = with PC reset. INT might serve to signal end-of-pattern to main CPU ->*)
-
The pattern is terminated without repeating.  
+
The pattern is terminated without repeating. It is important to note here that although that pattern has stopped, it is still active *) until the Timeout time has passed. As a consequence of this any higher priority patterns (patterns with a lower priority value, since 0 is the highest and 255 is the lowest) will not be displayed until the pattern has fully expired. In the case that the timeout is 0, it will not display until the notification is dismissed.
-
 
+
-
''the following is about mce, not about how LP5523 chip works''
+
-
 
+
-
It is important to note here that although that pattern has stopped, it is still active *) until the Timeout time has passed. As a consequence of this any higher priority patterns (patterns with a lower priority value, since 0 is the highest and 255 is the lowest) will not be displayed until the pattern has fully expired. In the case that the timeout is 0, it will not display until the notification is dismissed.
+
==== Sending and receiving engine triggers ====
==== Sending and receiving engine triggers ====
Line 145: Line 129:
The following pattern does exactly that:
The following pattern does exactly that:
-
:<tt>PatternTest=29;1;0;rG;9d80''4000''08ff''<u>e004</u>''4000''c000'';9d80''<u>e080</u>''40ff''c000''</tt>
+
:<tt>PatternTest=29;1;0;rG;9d80400008ffe0044000c000;9d80e08040ffc000</tt>
===== e002, e004, e008 - Send engine trigger =====
===== e002, e004, e008 - Send engine trigger =====
Line 157: Line 141:
A signal is sent from the current engine to signal another engine.
A signal is sent from the current engine to signal another engine.
-
Although the trigger information for engine 3 is listed we have no control over the keyboard LED, so it has no effect. Attempting to add a pattern for engine 3 after the pattern for engine 2 causes the pattern to no longer function (unless you stop mce, so it doesn't mess with LP5523 anymore - see below).
+
Although the trigger information for engine 3 is listed we have no control over the keyboard LED, so it has no effect. Attempting to add a pattern for engine 3 after the pattern for engine 2 causes the pattern to no longer function.
===== e080, e100, e200 - Wait for engine trigger =====
===== e080, e100, e200 - Wait for engine trigger =====
Line 168: Line 152:
Although the trigger information for engine 3 is listed we have no control over the keyboard LED, so it has no effect. Attempting to add a pattern for engine 3 after the pattern for engine 2 causes the pattern to no longer function.
Although the trigger information for engine 3 is listed we have no control over the keyboard LED, so it has no effect. Attempting to add a pattern for engine 3 after the pattern for engine 2 causes the pattern to no longer function.
-
 
-
...and there's more. Engine can actually do sub/add arithmetics, branches, and select which leds it controls.
 
-
 
-
Pavel Machek created a simple compiler, it is at https://gitorious.org/tui/tui/source/5b3f5cacf8e208d3ea50d6066e549940d85e55be:maemo/notcc.py , and it can use more features of the chip than described here.
 
=== Default LED Patterns for Nokia N900 ===
=== Default LED Patterns for Nokia N900 ===
Line 190: Line 170:
=== Community-Made Patterns ===
=== Community-Made Patterns ===
-
''Please note that these patterns should each be on one line.''
+
''Please note that these patterns should all be on one line.''
-
''They can also be used for any notification by choosing the appropriately named "Pattern... for the start of the line.''
+
''They can also be used for any notification.''
A traffic-light battery charging pattern, courtesy of [http://talk.maemo.org/showthread.php?p=512430#post512430 blue_led]
A traffic-light battery charging pattern, courtesy of [http://talk.maemo.org/showthread.php?p=512430#post512430 blue_led]
Line 217: Line 197:
=== Step by step instructions ===
=== Step by step instructions ===
-
{{ambox
 
-
|type=notice
 
-
|text=There's a command
 
-
IroN900:~# /usr/bin/mceledpattern --help
 
-
  Usage:
 
-
  mceledpattern add[_vibra] <pattern_name> <pattern>
 
-
  mceledpattern remove[_vibra] <pattern_name>
 
-
  To replace existing pattern use add, to restore replaced pattern back to previous value use remove
 
-
Please check if it's default or came with one of my additional packages}}
 
* Open terminal
* Open terminal
* Gain [[root access]]
* Gain [[root access]]
-
* Make a backup (for your own convenience) from original mce.ini -file, for example:<pre>cp /etc/mce/mce.ini /etc/mce/mce.ini_old</pre>
+
* Make a backup (not necessary!) from original mce.ini -file, for example:<pre>cp /etc/mce/mce.ini /etc/mce/mce.ini_old</pre>
* Open <code>/etc/mce/mce.ini</code> with a text editor (nano, vim, leafpad...)
* Open <code>/etc/mce/mce.ini</code> with a text editor (nano, vim, leafpad...)
* Search for a line:<pre>[LEDPatternLystiRX51]</pre>
* Search for a line:<pre>[LEDPatternLystiRX51]</pre>
Line 250: Line 221:
=== Low Level ===
=== Low Level ===
-
'''see also [[N900_Hardware_LED]] !'''
 
-
 
-
Alas the LP5523 driver doesn't support any of those advanced features of LP5523, and uses one of those engines for a kbd backlight ramp-up/down.<br>
+
The N8x0 had a LP5521<ref name="lp5521-spec">http://www.national.com/pf/LP/LP5521.html</ref>  <ref name="lp5521-driver">http://mxr.maemo.org/fremantle/source/kernel/drivers/i2c/chips/lp5521.c</ref> programmable three channel controller LED Driver which handles the leds.
-
''This could as well get done in mce by a 25ms timer that writes 40 new brightness values to the master control of kbd LEDs during 1 second.''
+
(actually N900 has a LP5523 <ref name="lp5523-spec">http://www.national.com/pf/LP/LP5523.html</ref> <ref name="leds-lp5523-driver">http://mxr.maemo.org/fremantle/source/kernel/drivers/leds/leds-lp5523.c</ref>, which has 3 engines like LP5521 but can drive 9 LEDs via a multiplexer. This chip also has double the RAM size for 'programs', plus a true set of conditional branch and arithmetic commands. Alas the LP5523 driver doesn't support any of those features, and even abuses one of those extremely smart engines for a stupid occasional kbd backlight ramp-up/down. This could as well get done in mce by a 25ms timer that writes 40 new brightness values to the master control of kbd LEDs during 1 second. There's really no reason why you need to assign 1 of those 3 machines to this *occasional* short ramp function and break true rainbow 3 color effects on indicator LED)
 +
 
 +
The controller can be programmed via "/sys/class/i2c-adapter/i2c-2/2-0032" (FIXME: is this stable?). In that directory there are three files corresponding to the three channels: engine1_mode, engine2_mode and engine3_mode. Each file "stores" one of "run", "load", "disabled" (it seems that there is another mode "direct" but it doesn't work):
 +
* run: The program runs
 +
* disabled: The channel is disabled - not running
 +
* load: In that state, there are two more files in that directory:
 +
** engine1_leds is in the form "0000rgb00" (9 digits, "1" or "0"), where rgb control which leds should participate. The 6 "0" in the above pattern correspond to the 6 kbd white leds controlled by mce via engine3, so readout of engine3_leds gives 111100011 ;-)
 +
** engine1_load accepts a string as specified above (e.g. 9d804000427f0d7f7f007f0042000000). LP5523 has an absolute storage of 96 steps a 16bits, which can dynamically partitioned between the three engines. (ToDo: check if driver supports >16 instructions / machine)
 +
After that, when the state is changed to "run", the program will be ran by the controller.
 +
 
 +
In order for the leds to work, the led_current of the appropriate leds need to be set to non-zero values. This is accomplished by writing to files leds:lp5523:[bgr]/led_current under the same directory. Perhaps (?) not or values are suitable.
-
See [[N900_Hardware_LED]] for hardware programming details.
+
NOTE: There must be a delay (how much? The specs of LP5521 mentions it) between writes to sysfs files.
== References ==
== References ==
-
Also see [[N900_Hardware_LED]]!
 
<references />
<references />

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: