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 1: Line 1:
== N800 ==
== N800 ==
-
The [[Nokia N800|N800]] has a single-colour (blue) LED behind the dpad.
+
The N800 has a single-colour (blue) LED behind the dpad.
== N810 ==
== N810 ==
-
The [[Nokia N810|N810]] has an RGB LED.
+
The N810 has an RGB LED.
== N900 ==
== N900 ==
Line 16: Line 16:
  /etc/mce/mce.ini
  /etc/mce/mce.ini
-
An application ([http://talk.maemo.org/showthread.php?t=27818 mcedit]) for modifying LED patterns was written for the N8x0, but this will not work with the [[Nokia N900|N900]] due to the new <code>mce.ini</code> format.
+
An application ([http://talk.maemo.org/showthread.php?t=27818 mcedit]) for modifying LED patterns was written for the n8x0, but this will not work with the n900 due to the new mce.ini format.
-
An app to edit LED patterns on the N900 is available in the [[extras]] repository ([http://maemo.org/downloads/product/Maemo5/led-pattern-editor Downloads Page]), [[LED Pattern Editor]]. This adds a way to edit LED patterns in the settings application.
+
An app to edit LED patterns on the N900 is available in the [[Extras-testing|Extras Testing]] repository for unstable software, [[LED Pattern Editor]]. This adds a way to edit LED patterns in the settings application.
=== Pattern Format ===
=== Pattern Format ===
-
 
The patterns are broken down as follows:
The patterns are broken down as follows:
:<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 42: Line 31:
Since currently only a single pattern at a time can be displayed, this is used to assign importance to the LED patterns. Although only a single LED pattern can be displayed at any time, multiple patterns may be active, the pattern with the highest priority being displayed.
Since currently only a single pattern at a time can be displayed, this is used to assign importance to the LED patterns. Although only a single LED pattern can be displayed at any time, multiple patterns may be active, the pattern with the highest priority being displayed.
-
A common example of this is where the N900 is on charge, the battery is full (starting PatternBatteryFull with a priority of 40), and an SMS message is received (PatternCommunicationSMS with a priority of 30). On receipt of the SMS, the LED begins to display the flashing blue led of an SMS. Once that SMS has been dismissed, the green LED of the full battery notification is again displayed.
+
A common example of this is where the n900 is on charge, the battery is full (starting PatternBatteryFull with a priority of 40), and an SMS message is received (PatternCommunicationSMS with a priority of 30). On receipt of the SMS, the LED begins to display the flashing blue led of an SMS. Once that SMS has been dismissed, the green LED of the full battery notification is again displayed.
==== ScreenOn ====
==== ScreenOn ====
Line 69: Line 58:
For example, "rG" maps the red channel to Engine 1, and the green channel to Engine 2.
For example, "rG" maps the red channel to Engine 1, and the green channel to Engine 2.
-
You should avoid mapping the same channel to both engines, for example "rR", "gG" or "bB" - it's not supported by the hardware, makes no sense anyway, and therefore probably never has been tested.
+
You should avoid mapping the same channel to both engines, for example "rR", "gG" or "bB"
==== Engine Pattern ====
==== Engine Pattern ====
-
This is a series of text that describes the speed and intensity of changes in the LED(s) being managed by that particular engine. See below for a breakdown of the patterns. Each can be at most 16 commands long.
+
This is a series of text that describes the speed and intensity of changes in the LED(s) beign managed by that particular engine. See below for a breakdown of the patterns. Each can be at most 16 commands long.
=== Lysti Format Engine Patterns and Commands ===
=== Lysti Format Engine Patterns and Commands ===
Line 80: Line 69:
:<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 109:
-
==== A000 .. BFFF - Branch (decrement and branch if non zero) ====
 
-
101<llllll><sssssss> : 16bit
+
==== A000 .. BFFF - Branch ====
-
llllll : 6bit; Loop count, 0=infinite loop, or max 63 loops
+
101<llllll><sssssss> : 16bit
-
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])
+
llllll : 6bit; Loop count, 0=infinite loop, max 63 loops
-
You can build MUCH SMARTER loops with this! ;-D
+
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])
==== 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:
-
* Open <code>/etc/mce/mce.ini</code> with a text editor (nano, vim, leafpad...)
+
cp /etc/mce/mce.ini /etc/mce/mce.ini_old
-
* Search for a line:<pre>[LEDPatternLystiRX51]</pre>
+
* Open /etc/mce/mce.ini with a text editor (nano, vim, leafpad...)
 +
* Search for a line:
 +
[LEDPatternLystiRX51]
* Make your changes to the lines below
* Make your changes to the lines below
* Save
* Save
-
* Restart mce -process. Either reboot or type in terminal:<pre>initctl stop mce; sleep 2; initctl start mce</pre>
+
* Restart mce -process. Either reboot or type in terminal:
 +
initctl stop mce; sleep 2; initctl start mce
Please note: restarting mce several times in 2 minutes will cause the system to think there is a problem with mce, and so won't start it. The initctl program will inform you of this. When it does, simply wait a while before trying again.
Please note: restarting mce several times in 2 minutes will cause the system to think there is a problem with mce, and so won't start it. The initctl program will inform you of this. When it does, simply wait a while before trying again.
-
Alternatively, mce is started using [[dsmetool]] which monitors and reboots the device on failure.
+
Alternatively, mce is started using [[dsmetooll]] which monitors and reboots the device on failure.
This monitoring can be adjusted for more convenient hacking.
This monitoring can be adjusted for more convenient hacking.
Line 247: Line 221:
Replacing -t (start and restart) with -o (start once) eliminates this monitoring.
Replacing -t (start and restart) with -o (start once) eliminates this monitoring.
-
Please be aware that errors in editing these files could cause a reboot loop, which could require a reflash to stop.
+
Please be aware that errors in editing these files will cause a reboot loop meaning your device needs reflashed.
=== 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 N900 has 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 it has a LP5523 it seems <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)
 +
 
 +
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: