<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=90.180.214.199</id>
	<title>Maemo Wiki Mirror - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=90.180.214.199"/>
	<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php/Special:Contributions/90.180.214.199"/>
	<updated>2026-04-21T23:08:28Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=N900_Hardware_LED&amp;diff=27761</id>
		<title>N900 Hardware LED</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=N900_Hardware_LED&amp;diff=27761"/>
		<updated>2014-01-07T09:43:14Z</updated>

		<summary type="html">&lt;p&gt;90.180.214.199: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Hardware==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N900|N900]] has LP5523 &amp;lt;ref name=&amp;quot;lp5523-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5523.html&amp;lt;/ref&amp;gt; &amp;lt;ref name=&amp;quot;leds-lp5523-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/leds/leds-lp5523.c&amp;lt;/ref&amp;gt;, which has 3 engines like LP5521 (compatible though augmented instruction set) but can drive 9 LEDs via a multiplexer which maps each LED to one of the 3 engines. A LED also can be unassigned to any engine, in which case you can control it by writing to the corresponding brightness sysnode) which handles the keyboard and notification LED. (not the [[N900 Hardware Flash Torch|flash LEDs]] and red indicator light next to those, and also not the Infrared-LED used for CIR)&lt;br /&gt;
&lt;br /&gt;
The controller can be programmed via &amp;quot;/sys/class/i2c-adapter/i2c-2/2-0032&amp;quot;. In that directory there are three files corresponding to the three channels: &amp;lt;code&amp;gt;engine1_mode&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;engine2_mode&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;engine3_mode&amp;lt;/code&amp;gt;. Each file &amp;quot;stores&amp;quot; one of &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;load&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (it seems that there is another mode &amp;quot;direct&amp;quot; but it doesn&#039;t work)(direct mode requires explicit writes to PWM, current and multiplexing registers, which may not be supported in the code...):&lt;br /&gt;
* &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt;: The program runs&lt;br /&gt;
* &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt;: The channel is disabled - not running&lt;br /&gt;
* &amp;lt;code&amp;gt;load&amp;lt;/code&amp;gt;: In that state, there are two more files in that directory: &lt;br /&gt;
** engine1_LEDs is in the form &amp;quot;0000bgr00&amp;quot; (9 digits, &amp;quot;1&amp;quot; or &amp;quot;0&amp;quot;), where rgb control which LEDs should participate. The 6 &amp;quot;0&amp;quot; in the above pattern correspond to the 6 kbd white LEDs controlled by MCE via engine3, so readout of engine3_leds gives 111100011 ;-)&lt;br /&gt;
** 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. (Supports 32-96 steps per engine, dynamically-assigned, alas the lp5523.ko driver is braindamaged and doesn&#039;t support more than 16 instructions per engine)&lt;br /&gt;
After that, when the state is changed to &amp;quot;run&amp;quot;, the program will be ran by the controller. &lt;br /&gt;
&lt;br /&gt;
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. Default values from kernel module init are suitable.&lt;br /&gt;
&lt;br /&gt;
Despite the line&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#define LP5523_DEFAULT_CURRENT          50 /* microAmps */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
suggesting different, the units in there are 0.1 mA (100 µA per step is correct). So the driver init default &amp;quot;50&amp;quot; for all LEDs is 5 mA, and mce seems to set current to 0.2 mA (value 2 in the led_current sysnode) for B and G, and either to 0.2 mA or 0.8 mA for R. Probably settings as high as 100 for 10 mA are safe for the RGB LED, higher values might destroy the LED. (yes, correct, the RGB could be damaged from heat if set to more than 10 mA on all 3 LEDs)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;BEWARE!&lt;br /&gt;
 register addr 0x3B: GPO&lt;br /&gt;
 LP5523 has one General Purpose Output pin (GPO).&lt;br /&gt;
 Status of the pin can be controlled with this register. Also,&lt;br /&gt;
 &#039;&#039;&#039;INT pin can be configured to function as a GPO&#039;&#039;&#039; by setting&lt;br /&gt;
 the bit INT_CONF. When INT is configured to function as&lt;br /&gt;
 a GPO, &#039;&#039;&#039;output level is defined by the VDD voltage&#039;&#039;&#039;.&lt;br /&gt;
 3B — Bit [2] INT_CONF&lt;br /&gt;
 0 = INT pin is set to function as an interrupt pin (default).&lt;br /&gt;
 1 = INT pin is configured to function as a GPO.&lt;br /&gt;
&lt;br /&gt;
INT is routed directly to a SOC GPIO that is not designed to take voltages &amp;gt;1.8V ! So setting 0x3B:2 to 1 may fry your CPU&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Software==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
also see [[LED_patterns]] of which this page is a &amp;quot;fork&amp;quot; without cleaning the original page, so now there are two versions with almost identical but slightly complementary info&lt;br /&gt;
&lt;br /&gt;
Since beginning of 2012 a datasheet for LP5523 is available from TI: http://www.ti.com/product/lp5523 Direct link: http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=snvs550d&amp;amp;fileType=pdf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:N900 Hardware]]&lt;/div&gt;</summary>
		<author><name>90.180.214.199</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14051</id>
		<title>LED patterns</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14051"/>
		<updated>2014-01-07T08:58:06Z</updated>

		<summary type="html">&lt;p&gt;90.180.214.199: /* Low Level */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== N800 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N800|N800]] has a single-colour (blue) LED behind the dpad.&lt;br /&gt;
&lt;br /&gt;
== N810 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N810|N810]] has an RGB LED.&lt;br /&gt;
&lt;br /&gt;
== N900 ==&lt;br /&gt;
&lt;br /&gt;
=== File Location ===&lt;br /&gt;
&lt;br /&gt;
The software on the device that controls the LED colors is [[N900 Software MCE|MCE]].&lt;br /&gt;
&lt;br /&gt;
The file defining patterns can be found in&lt;br /&gt;
 /etc/mce/mce.ini&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;mce.ini&amp;lt;/code&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Pattern Format ===&lt;br /&gt;
&lt;br /&gt;
The patterns are broken down as follows:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(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&#039;t support pattern&lt;br /&gt;
definitions for engine3. mce is closed source and thus this can&#039;t be fixed in any reasonable way. If mce were open, an alternative compatible format was possible:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern;Engine3Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where LEDsToMap was something like &amp;quot;000012300&amp;quot; to map the particular LED to either none, or Engine1..3 respectively. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==== Priority ====&lt;br /&gt;
&lt;br /&gt;
0-255, 0 is highest, 255 is lowest.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== ScreenOn ====&lt;br /&gt;
&lt;br /&gt;
* 0: only show pattern when the display is off&lt;br /&gt;
* 1: show pattern even when the display is on&lt;br /&gt;
* 2: only show pattern when the display is off, including acting dead&lt;br /&gt;
* 3: show pattern even when the display is on, including acting dead&lt;br /&gt;
* 4: only show pattern if the display is off, or if in acting dead&lt;br /&gt;
* 5: always show pattern, even if LED disabled&lt;br /&gt;
&lt;br /&gt;
==== TimeOut ====&lt;br /&gt;
&lt;br /&gt;
This is the time-out of the LED pattern in seconds. 0 for infinite, i.e. until the notification is dismissed.&lt;br /&gt;
&lt;br /&gt;
If this is set to 20, the pattern will display for 20 seconds, and then stop.&lt;br /&gt;
&lt;br /&gt;
==== LEDsToMap ====&lt;br /&gt;
&lt;br /&gt;
There are two engines that can be used to make custom LED patterns.&amp;lt;ref name=&amp;quot;engines&amp;quot;&amp;gt;Actually there are three, but the third engine is used exclusively for the keyboard LED.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
r, g, or b maps the corresponding colour channel to Engine 1.&lt;br /&gt;
&lt;br /&gt;
R, G, or B maps the corresponding colour channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;quot;rG&amp;quot; maps the red channel to Engine 1, and the green channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
You should avoid mapping the same channel to both engines, for example &amp;quot;rR&amp;quot;, &amp;quot;gG&amp;quot; or &amp;quot;bB&amp;quot; - it&#039;s not supported by the hardware, makes no sense anyway, and therefore probably never has been tested.&lt;br /&gt;
&lt;br /&gt;
==== Engine Pattern ====&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Lysti Format Engine Patterns and Commands ===&lt;br /&gt;
&lt;br /&gt;
The LED patterns are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d8040007f007f0040ff7f007f000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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)&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d80 4000 7f00 7f00 40ff 7f00 7f00 0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 9d80 - Refresh Engine Multiplexer ====&lt;br /&gt;
&lt;br /&gt;
This is to be used as the first command of every pattern. If this is excluded from the pattern, the led won&#039;t flash. (actually this command loads the first [and only] entry of a predefined [by kernel driver] multiplexer table in chip&#039;s RAM to the multiplexer register)&lt;br /&gt;
&lt;br /&gt;
==== 40xx - Set channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Where xx are two hexadecimal digits, e.g. 00 (for a brightness of 0) or ff (for a brightness of 255).&lt;br /&gt;
&lt;br /&gt;
==== xxyy - Adjust channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Increment or decrement the channel brightness over a period of time (xx) and a number of steps (yy).&lt;br /&gt;
&lt;br /&gt;
Where xx and yy are hexadecimal digits&lt;br /&gt;
&lt;br /&gt;
xx - Time (per step?)&lt;br /&gt;
&lt;br /&gt;
yy - Number of steps&lt;br /&gt;
&lt;br /&gt;
The following rules apply to these:&lt;br /&gt;
* If xx is even, the steps are increment steps and brightness will increase.&lt;br /&gt;
* If xx is odd, the steps are decrement steps and brightness will decrease.&lt;br /&gt;
* If xx is between 02 and 3f, a short step time is used (granularity 0.49ms)&lt;br /&gt;
* If xx is between 42 and 7f, a long step time is used (granularity 15.6ms)&lt;br /&gt;
* yy can be any value between 00 and ff (0 to 255)&lt;br /&gt;
* Pauses can be achieved by using 00 steps, e.g. 7f00 where, where the 7f is how long each step takes and 00 is how many increment steps to take.&lt;br /&gt;
&lt;br /&gt;
The mce.ini instructions (/etc/mce/mce.ini) also state that &lt;br /&gt;
:Two consecutive increment/decrement sequences are needed to cover the entire range from 0-255&lt;br /&gt;
However I believe this is a throwback to the older patterns, and the full range of 00 to ff is available in a single step for the number of steps, since whether these are increment or decrement steps are now handled through use of even or odd xx values.&lt;br /&gt;
&lt;br /&gt;
==== 0000 - Jump to start ====&lt;br /&gt;
&lt;br /&gt;
Jump to the start of the pattern for this channel. You will see this at the end of most repeating patterns.&lt;br /&gt;
&lt;br /&gt;
This command may not actually be needed to make the pattern repeat. If this is removed, the pattern will repeat anyway, although it&#039;s useful to have it there as an explicit command to repeat for clarity. If you wanted a pattern to run once and then terminate you would use the c000 command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== A000 .. BFFF - Branch (decrement and branch if non zero) ====&lt;br /&gt;
&lt;br /&gt;
101&amp;lt;llllll&amp;gt;&amp;lt;sssssss&amp;gt; : 16bit&lt;br /&gt;
&lt;br /&gt;
llllll : 6bit; Loop count, 0=infinite loop, or max 63 loops&lt;br /&gt;
&lt;br /&gt;
sssssss : 7 bit; Step number; Value to store to PC (0-95 actual progspace of LP5523 of 96 16bit commands. [Unclear if that&#039;s absolute address, or probably offset relative to start of program space assigned to the particular engine])&lt;br /&gt;
&lt;br /&gt;
You can build MUCH SMARTER loops with this! ;-D&lt;br /&gt;
&lt;br /&gt;
==== c000 - End pattern execution ====&lt;br /&gt;
&lt;br /&gt;
(also d000 = with hw INT; c800/d800 = with PC reset. INT might serve to signal end-of-pattern to main CPU -&amp;gt;*)&lt;br /&gt;
&lt;br /&gt;
The pattern is terminated without repeating. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;the following is about mce, not about how LP5523 chip works&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Sending and receiving engine triggers ====&lt;br /&gt;
&lt;br /&gt;
Further complexity in patterns can be added through use of triggers. This is especially useful if we want to synchronise the two engines in time, for example to wait until the LED has turned red before turning it immediately to green. Rather than waste time with steps doing nothing, we can simply wait for a trigger to be received from the other engine.&lt;br /&gt;
&lt;br /&gt;
The following pattern does exactly that:&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternTest=29;1;0;rG;9d80&#039;&#039;4000&#039;&#039;08ff&#039;&#039;&amp;lt;u&amp;gt;e004&amp;lt;/u&amp;gt;&#039;&#039;4000&#039;&#039;c000&#039;&#039;;9d80&#039;&#039;&amp;lt;u&amp;gt;e080&amp;lt;/u&amp;gt;&#039;&#039;40ff&#039;&#039;c000&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== e002, e004, e008 - Send engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e002 - Send trigger to engine 1&lt;br /&gt;
&lt;br /&gt;
e004 - Send trigger to engine 2&lt;br /&gt;
&lt;br /&gt;
e008 - Send trigger to engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
A signal is sent from the current engine to signal another engine.&lt;br /&gt;
&lt;br /&gt;
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&#039;t mess with LP5523 anymore - see below).&lt;br /&gt;
&lt;br /&gt;
===== e080, e100, e200 - Wait for engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e080 - Wait for trigger from engine 1&lt;br /&gt;
&lt;br /&gt;
e100 - Wait for trigger from engine 2&lt;br /&gt;
&lt;br /&gt;
e200 - Wait for trigger from engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
...and there&#039;s more. Engine can actually do sub/add arithmetics, branches, and select which leds it controls.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Default LED Patterns for Nokia N900 ===&lt;br /&gt;
&lt;br /&gt;
 PatternError=0;5;0;r;9d8040007f007f0040ff7f007f000000;9d800000&lt;br /&gt;
 PatternDeviceOn=254;0;0;rgb;9d804000422043207f100000;9d800000&lt;br /&gt;
 PatternDeviceSoftOff=253;0;0;rg;9d804000423f433f7f100000;9d800000&lt;br /&gt;
 PatternPowerOn=9;3;0;rgb;9d80400042ff02ffc000;9d800000&lt;br /&gt;
 PatternPowerOff=10;3;0;rgb;9d80400001ff43ff7f007f00c000;9d800000&lt;br /&gt;
 PatternCommunicationCall=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationIM=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationSMS=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommonNotification=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternWebcamActive=20;1;0;r;9d80400004ffc0000000;9d800000&lt;br /&gt;
 PatternBatteryCharging=50;4;0;rg;9d804000427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
 PatternBatteryFull=40;4;0;g;9d80407f0000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Community-Made Patterns ===&lt;br /&gt;
&#039;&#039;Please note that these patterns should each be on one line.&#039;&#039;&lt;br /&gt;
&#039;&#039;They can also be used for any notification by choosing the appropriately named &amp;quot;Pattern... for the start of the line.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A traffic-light battery charging pattern, courtesy of [http://talk.maemo.org/showthread.php?p=512430#post512430 blue_led]&lt;br /&gt;
 PatternBatteryCharging=50;4;0;Rg;9d80407f7f00e0047f0040007f007f007f00407f7f00e0047f007f000000;9d804000e080407fe0800000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=499305#post499305 mihapodb]. This pattern cuts quickly between blue and red.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8040ff7f00e00440007f000000;9d80e08040ff7f0040000000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=540959#post540959 villo]. This pattern fades between red and blue.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8004ff05ffe004e1000000;9d80e08004ff05ffe0020000&lt;br /&gt;
&lt;br /&gt;
Cehteh&#039;s patterns with some comments&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in cyan, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternDeviceOn=254;0;0;gb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in yellow, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryCharging=50;3;0;rg;9d804001427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in white, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryFull=40;3;0;rgb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
White, bright flashing (must be enabled in &#039;LEDPatterns=&#039; ?):&lt;br /&gt;
 PatternExample=42;1;30;rgb;9d8040007f007f0040ff42000000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Step by step instructions ===&lt;br /&gt;
{{ambox&lt;br /&gt;
|type=notice&lt;br /&gt;
|text=There&#039;s a command &lt;br /&gt;
IroN900:~# /usr/bin/mceledpattern --help&lt;br /&gt;
  Usage:&lt;br /&gt;
  mceledpattern add[_vibra] &amp;lt;pattern_name&amp;gt; &amp;lt;pattern&amp;gt;&lt;br /&gt;
  mceledpattern remove[_vibra] &amp;lt;pattern_name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  To replace existing pattern use add, to restore replaced pattern back to previous value use remove&lt;br /&gt;
Please check if it&#039;s default or came with one of my additional packages}}&lt;br /&gt;
* Open terminal&lt;br /&gt;
* Gain [[root access]]&lt;br /&gt;
* Make a backup (for your own convenience) from original mce.ini -file, for example:&amp;lt;pre&amp;gt;cp /etc/mce/mce.ini /etc/mce/mce.ini_old&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Open &amp;lt;code&amp;gt;/etc/mce/mce.ini&amp;lt;/code&amp;gt; with a text editor (nano, vim, leafpad...)&lt;br /&gt;
* Search for a line:&amp;lt;pre&amp;gt;[LEDPatternLystiRX51]&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Make your changes to the lines below&lt;br /&gt;
* Save&lt;br /&gt;
* Restart mce -process. Either reboot or type in terminal:&amp;lt;pre&amp;gt;initctl stop mce; sleep 2; initctl start mce&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note: restarting mce several times in 2 minutes will cause the system to think there is a problem with mce, and so won&#039;t start it. The initctl program will inform you of this. When it does, simply wait a while before trying again.&lt;br /&gt;
&lt;br /&gt;
Alternatively, mce is started using [[dsmetool]] which monitors and reboots the device on failure.&lt;br /&gt;
This monitoring can be adjusted for more convenient hacking.&lt;br /&gt;
&lt;br /&gt;
/etc/event.d/mce&lt;br /&gt;
&lt;br /&gt;
*         /usr/sbin/dsmetool -n -1 -t &amp;quot;/sbin/mce --force-syslog&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Replacing -t (start and restart) with -o (start once) eliminates this monitoring.&lt;br /&gt;
&lt;br /&gt;
Please be aware that errors in editing these files could cause a reboot loop, which could require a reflash to stop.&lt;br /&gt;
&lt;br /&gt;
=== Low Level ===&lt;br /&gt;
&#039;&#039;&#039;see also [[N900_Hardware_LED]] !&#039;&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Alas the LP5523 driver doesn&#039;t support any of those advanced features of LP5523, and uses one of those  engines for a kbd backlight ramp-up/down.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;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.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See [[N900_Hardware_LED]] for hardware programming details.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Also see [[N900_Hardware_LED]]! &lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:N900 Hardware]]&lt;br /&gt;
[[Category:Power users]]&lt;/div&gt;</summary>
		<author><name>90.180.214.199</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14052</id>
		<title>LED patterns</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14052"/>
		<updated>2014-01-07T08:56:45Z</updated>

		<summary type="html">&lt;p&gt;90.180.214.199: /* Low Level */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== N800 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N800|N800]] has a single-colour (blue) LED behind the dpad.&lt;br /&gt;
&lt;br /&gt;
== N810 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N810|N810]] has an RGB LED.&lt;br /&gt;
&lt;br /&gt;
== N900 ==&lt;br /&gt;
&lt;br /&gt;
=== File Location ===&lt;br /&gt;
&lt;br /&gt;
The software on the device that controls the LED colors is [[N900 Software MCE|MCE]].&lt;br /&gt;
&lt;br /&gt;
The file defining patterns can be found in&lt;br /&gt;
 /etc/mce/mce.ini&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;mce.ini&amp;lt;/code&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Pattern Format ===&lt;br /&gt;
&lt;br /&gt;
The patterns are broken down as follows:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(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&#039;t support pattern&lt;br /&gt;
definitions for engine3. mce is closed source and thus this can&#039;t be fixed in any reasonable way. If mce were open, an alternative compatible format was possible:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern;Engine3Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where LEDsToMap was something like &amp;quot;000012300&amp;quot; to map the particular LED to either none, or Engine1..3 respectively. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==== Priority ====&lt;br /&gt;
&lt;br /&gt;
0-255, 0 is highest, 255 is lowest.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== ScreenOn ====&lt;br /&gt;
&lt;br /&gt;
* 0: only show pattern when the display is off&lt;br /&gt;
* 1: show pattern even when the display is on&lt;br /&gt;
* 2: only show pattern when the display is off, including acting dead&lt;br /&gt;
* 3: show pattern even when the display is on, including acting dead&lt;br /&gt;
* 4: only show pattern if the display is off, or if in acting dead&lt;br /&gt;
* 5: always show pattern, even if LED disabled&lt;br /&gt;
&lt;br /&gt;
==== TimeOut ====&lt;br /&gt;
&lt;br /&gt;
This is the time-out of the LED pattern in seconds. 0 for infinite, i.e. until the notification is dismissed.&lt;br /&gt;
&lt;br /&gt;
If this is set to 20, the pattern will display for 20 seconds, and then stop.&lt;br /&gt;
&lt;br /&gt;
==== LEDsToMap ====&lt;br /&gt;
&lt;br /&gt;
There are two engines that can be used to make custom LED patterns.&amp;lt;ref name=&amp;quot;engines&amp;quot;&amp;gt;Actually there are three, but the third engine is used exclusively for the keyboard LED.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
r, g, or b maps the corresponding colour channel to Engine 1.&lt;br /&gt;
&lt;br /&gt;
R, G, or B maps the corresponding colour channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;quot;rG&amp;quot; maps the red channel to Engine 1, and the green channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
You should avoid mapping the same channel to both engines, for example &amp;quot;rR&amp;quot;, &amp;quot;gG&amp;quot; or &amp;quot;bB&amp;quot; - it&#039;s not supported by the hardware, makes no sense anyway, and therefore probably never has been tested.&lt;br /&gt;
&lt;br /&gt;
==== Engine Pattern ====&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Lysti Format Engine Patterns and Commands ===&lt;br /&gt;
&lt;br /&gt;
The LED patterns are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d8040007f007f0040ff7f007f000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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)&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d80 4000 7f00 7f00 40ff 7f00 7f00 0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 9d80 - Refresh Engine Multiplexer ====&lt;br /&gt;
&lt;br /&gt;
This is to be used as the first command of every pattern. If this is excluded from the pattern, the led won&#039;t flash. (actually this command loads the first [and only] entry of a predefined [by kernel driver] multiplexer table in chip&#039;s RAM to the multiplexer register)&lt;br /&gt;
&lt;br /&gt;
==== 40xx - Set channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Where xx are two hexadecimal digits, e.g. 00 (for a brightness of 0) or ff (for a brightness of 255).&lt;br /&gt;
&lt;br /&gt;
==== xxyy - Adjust channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Increment or decrement the channel brightness over a period of time (xx) and a number of steps (yy).&lt;br /&gt;
&lt;br /&gt;
Where xx and yy are hexadecimal digits&lt;br /&gt;
&lt;br /&gt;
xx - Time (per step?)&lt;br /&gt;
&lt;br /&gt;
yy - Number of steps&lt;br /&gt;
&lt;br /&gt;
The following rules apply to these:&lt;br /&gt;
* If xx is even, the steps are increment steps and brightness will increase.&lt;br /&gt;
* If xx is odd, the steps are decrement steps and brightness will decrease.&lt;br /&gt;
* If xx is between 02 and 3f, a short step time is used (granularity 0.49ms)&lt;br /&gt;
* If xx is between 42 and 7f, a long step time is used (granularity 15.6ms)&lt;br /&gt;
* yy can be any value between 00 and ff (0 to 255)&lt;br /&gt;
* Pauses can be achieved by using 00 steps, e.g. 7f00 where, where the 7f is how long each step takes and 00 is how many increment steps to take.&lt;br /&gt;
&lt;br /&gt;
The mce.ini instructions (/etc/mce/mce.ini) also state that &lt;br /&gt;
:Two consecutive increment/decrement sequences are needed to cover the entire range from 0-255&lt;br /&gt;
However I believe this is a throwback to the older patterns, and the full range of 00 to ff is available in a single step for the number of steps, since whether these are increment or decrement steps are now handled through use of even or odd xx values.&lt;br /&gt;
&lt;br /&gt;
==== 0000 - Jump to start ====&lt;br /&gt;
&lt;br /&gt;
Jump to the start of the pattern for this channel. You will see this at the end of most repeating patterns.&lt;br /&gt;
&lt;br /&gt;
This command may not actually be needed to make the pattern repeat. If this is removed, the pattern will repeat anyway, although it&#039;s useful to have it there as an explicit command to repeat for clarity. If you wanted a pattern to run once and then terminate you would use the c000 command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== A000 .. BFFF - Branch (decrement and branch if non zero) ====&lt;br /&gt;
&lt;br /&gt;
101&amp;lt;llllll&amp;gt;&amp;lt;sssssss&amp;gt; : 16bit&lt;br /&gt;
&lt;br /&gt;
llllll : 6bit; Loop count, 0=infinite loop, or max 63 loops&lt;br /&gt;
&lt;br /&gt;
sssssss : 7 bit; Step number; Value to store to PC (0-95 actual progspace of LP5523 of 96 16bit commands. [Unclear if that&#039;s absolute address, or probably offset relative to start of program space assigned to the particular engine])&lt;br /&gt;
&lt;br /&gt;
You can build MUCH SMARTER loops with this! ;-D&lt;br /&gt;
&lt;br /&gt;
==== c000 - End pattern execution ====&lt;br /&gt;
&lt;br /&gt;
(also d000 = with hw INT; c800/d800 = with PC reset. INT might serve to signal end-of-pattern to main CPU -&amp;gt;*)&lt;br /&gt;
&lt;br /&gt;
The pattern is terminated without repeating. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;the following is about mce, not about how LP5523 chip works&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Sending and receiving engine triggers ====&lt;br /&gt;
&lt;br /&gt;
Further complexity in patterns can be added through use of triggers. This is especially useful if we want to synchronise the two engines in time, for example to wait until the LED has turned red before turning it immediately to green. Rather than waste time with steps doing nothing, we can simply wait for a trigger to be received from the other engine.&lt;br /&gt;
&lt;br /&gt;
The following pattern does exactly that:&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternTest=29;1;0;rG;9d80&#039;&#039;4000&#039;&#039;08ff&#039;&#039;&amp;lt;u&amp;gt;e004&amp;lt;/u&amp;gt;&#039;&#039;4000&#039;&#039;c000&#039;&#039;;9d80&#039;&#039;&amp;lt;u&amp;gt;e080&amp;lt;/u&amp;gt;&#039;&#039;40ff&#039;&#039;c000&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== e002, e004, e008 - Send engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e002 - Send trigger to engine 1&lt;br /&gt;
&lt;br /&gt;
e004 - Send trigger to engine 2&lt;br /&gt;
&lt;br /&gt;
e008 - Send trigger to engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
A signal is sent from the current engine to signal another engine.&lt;br /&gt;
&lt;br /&gt;
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&#039;t mess with LP5523 anymore - see below).&lt;br /&gt;
&lt;br /&gt;
===== e080, e100, e200 - Wait for engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e080 - Wait for trigger from engine 1&lt;br /&gt;
&lt;br /&gt;
e100 - Wait for trigger from engine 2&lt;br /&gt;
&lt;br /&gt;
e200 - Wait for trigger from engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
...and there&#039;s more. Engine can actually do sub/add arithmetics, branches, and select which leds it controls.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Default LED Patterns for Nokia N900 ===&lt;br /&gt;
&lt;br /&gt;
 PatternError=0;5;0;r;9d8040007f007f0040ff7f007f000000;9d800000&lt;br /&gt;
 PatternDeviceOn=254;0;0;rgb;9d804000422043207f100000;9d800000&lt;br /&gt;
 PatternDeviceSoftOff=253;0;0;rg;9d804000423f433f7f100000;9d800000&lt;br /&gt;
 PatternPowerOn=9;3;0;rgb;9d80400042ff02ffc000;9d800000&lt;br /&gt;
 PatternPowerOff=10;3;0;rgb;9d80400001ff43ff7f007f00c000;9d800000&lt;br /&gt;
 PatternCommunicationCall=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationIM=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationSMS=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommonNotification=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternWebcamActive=20;1;0;r;9d80400004ffc0000000;9d800000&lt;br /&gt;
 PatternBatteryCharging=50;4;0;rg;9d804000427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
 PatternBatteryFull=40;4;0;g;9d80407f0000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Community-Made Patterns ===&lt;br /&gt;
&#039;&#039;Please note that these patterns should each be on one line.&#039;&#039;&lt;br /&gt;
&#039;&#039;They can also be used for any notification by choosing the appropriately named &amp;quot;Pattern... for the start of the line.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A traffic-light battery charging pattern, courtesy of [http://talk.maemo.org/showthread.php?p=512430#post512430 blue_led]&lt;br /&gt;
 PatternBatteryCharging=50;4;0;Rg;9d80407f7f00e0047f0040007f007f007f00407f7f00e0047f007f000000;9d804000e080407fe0800000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=499305#post499305 mihapodb]. This pattern cuts quickly between blue and red.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8040ff7f00e00440007f000000;9d80e08040ff7f0040000000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=540959#post540959 villo]. This pattern fades between red and blue.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8004ff05ffe004e1000000;9d80e08004ff05ffe0020000&lt;br /&gt;
&lt;br /&gt;
Cehteh&#039;s patterns with some comments&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in cyan, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternDeviceOn=254;0;0;gb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in yellow, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryCharging=50;3;0;rg;9d804001427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in white, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryFull=40;3;0;rgb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
White, bright flashing (must be enabled in &#039;LEDPatterns=&#039; ?):&lt;br /&gt;
 PatternExample=42;1;30;rgb;9d8040007f007f0040ff42000000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Step by step instructions ===&lt;br /&gt;
{{ambox&lt;br /&gt;
|type=notice&lt;br /&gt;
|text=There&#039;s a command &lt;br /&gt;
IroN900:~# /usr/bin/mceledpattern --help&lt;br /&gt;
  Usage:&lt;br /&gt;
  mceledpattern add[_vibra] &amp;lt;pattern_name&amp;gt; &amp;lt;pattern&amp;gt;&lt;br /&gt;
  mceledpattern remove[_vibra] &amp;lt;pattern_name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  To replace existing pattern use add, to restore replaced pattern back to previous value use remove&lt;br /&gt;
Please check if it&#039;s default or came with one of my additional packages}}&lt;br /&gt;
* Open terminal&lt;br /&gt;
* Gain [[root access]]&lt;br /&gt;
* Make a backup (for your own convenience) from original mce.ini -file, for example:&amp;lt;pre&amp;gt;cp /etc/mce/mce.ini /etc/mce/mce.ini_old&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Open &amp;lt;code&amp;gt;/etc/mce/mce.ini&amp;lt;/code&amp;gt; with a text editor (nano, vim, leafpad...)&lt;br /&gt;
* Search for a line:&amp;lt;pre&amp;gt;[LEDPatternLystiRX51]&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Make your changes to the lines below&lt;br /&gt;
* Save&lt;br /&gt;
* Restart mce -process. Either reboot or type in terminal:&amp;lt;pre&amp;gt;initctl stop mce; sleep 2; initctl start mce&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note: restarting mce several times in 2 minutes will cause the system to think there is a problem with mce, and so won&#039;t start it. The initctl program will inform you of this. When it does, simply wait a while before trying again.&lt;br /&gt;
&lt;br /&gt;
Alternatively, mce is started using [[dsmetool]] which monitors and reboots the device on failure.&lt;br /&gt;
This monitoring can be adjusted for more convenient hacking.&lt;br /&gt;
&lt;br /&gt;
/etc/event.d/mce&lt;br /&gt;
&lt;br /&gt;
*         /usr/sbin/dsmetool -n -1 -t &amp;quot;/sbin/mce --force-syslog&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Replacing -t (start and restart) with -o (start once) eliminates this monitoring.&lt;br /&gt;
&lt;br /&gt;
Please be aware that errors in editing these files could cause a reboot loop, which could require a reflash to stop.&lt;br /&gt;
&lt;br /&gt;
=== Low Level ===&lt;br /&gt;
&#039;&#039;&#039;see also [[N900_Hardware_LED]] !&#039;&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Alas the LP5523 driver doesn&#039;t support any of those advanced features of LP5523, and uses one of those  engines for a kbd backlight ramp-up/down.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;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.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See [[N900_Hardware_LED]] for hardware programming details.&lt;br /&gt;
&lt;br /&gt;
** engine1_leds is in the form &amp;quot;0000rgb00&amp;quot; (9 digits, &amp;quot;1&amp;quot; or &amp;quot;0&amp;quot;), where rgb control which leds should participate. The 6 &amp;quot;0&amp;quot; in the above pattern correspond to the 6 kbd white leds controlled by mce via engine3, so readout of engine3_leds gives 111100011 ;-)&lt;br /&gt;
** engine1_load accepts a string as specified above (e.g. 9d804000427f0d7f7f007f0042000000). Though LP5523 has an absolute storage of 96 steps a 16bits, which can dynamically partitioned between the three engines, the driver limits this to a fixed 16 words a 16bit per engine &lt;br /&gt;
&lt;br /&gt;
After that, when the state is changed to &amp;quot;run&amp;quot;, the program will be run by the controller. &lt;br /&gt;
&lt;br /&gt;
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]/&#039;&#039;&#039;led_current&#039;&#039;&#039; under the same directory. &#039;&#039;&#039;Don&#039;t mess with&#039;&#039;&#039; the default settings here that come with driver init, they are suitable and changing to higher values may and for certain values &#039;&#039;&#039;will kill your LEDS&#039;&#039;&#039;!.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Also see [[N900_Hardware_LED]]! &lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:N900 Hardware]]&lt;br /&gt;
[[Category:Power users]]&lt;/div&gt;</summary>
		<author><name>90.180.214.199</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14053</id>
		<title>LED patterns</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14053"/>
		<updated>2014-01-06T13:40:13Z</updated>

		<summary type="html">&lt;p&gt;90.180.214.199: /* e080, e100, e200 - Wait for engine trigger */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== N800 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N800|N800]] has a single-colour (blue) LED behind the dpad.&lt;br /&gt;
&lt;br /&gt;
== N810 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N810|N810]] has an RGB LED.&lt;br /&gt;
&lt;br /&gt;
== N900 ==&lt;br /&gt;
&lt;br /&gt;
=== File Location ===&lt;br /&gt;
&lt;br /&gt;
The software on the device that controls the LED colors is [[N900 Software MCE|MCE]].&lt;br /&gt;
&lt;br /&gt;
The file defining patterns can be found in&lt;br /&gt;
 /etc/mce/mce.ini&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;mce.ini&amp;lt;/code&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Pattern Format ===&lt;br /&gt;
&lt;br /&gt;
The patterns are broken down as follows:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(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&#039;t support pattern&lt;br /&gt;
definitions for engine3. mce is closed source and thus this can&#039;t be fixed in any reasonable way. If mce were open, an alternative compatible format was possible:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern;Engine3Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where LEDsToMap was something like &amp;quot;000012300&amp;quot; to map the particular LED to either none, or Engine1..3 respectively. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==== Priority ====&lt;br /&gt;
&lt;br /&gt;
0-255, 0 is highest, 255 is lowest.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== ScreenOn ====&lt;br /&gt;
&lt;br /&gt;
* 0: only show pattern when the display is off&lt;br /&gt;
* 1: show pattern even when the display is on&lt;br /&gt;
* 2: only show pattern when the display is off, including acting dead&lt;br /&gt;
* 3: show pattern even when the display is on, including acting dead&lt;br /&gt;
* 4: only show pattern if the display is off, or if in acting dead&lt;br /&gt;
* 5: always show pattern, even if LED disabled&lt;br /&gt;
&lt;br /&gt;
==== TimeOut ====&lt;br /&gt;
&lt;br /&gt;
This is the time-out of the LED pattern in seconds. 0 for infinite, i.e. until the notification is dismissed.&lt;br /&gt;
&lt;br /&gt;
If this is set to 20, the pattern will display for 20 seconds, and then stop.&lt;br /&gt;
&lt;br /&gt;
==== LEDsToMap ====&lt;br /&gt;
&lt;br /&gt;
There are two engines that can be used to make custom LED patterns.&amp;lt;ref name=&amp;quot;engines&amp;quot;&amp;gt;Actually there are three, but the third engine is used exclusively for the keyboard LED.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
r, g, or b maps the corresponding colour channel to Engine 1.&lt;br /&gt;
&lt;br /&gt;
R, G, or B maps the corresponding colour channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;quot;rG&amp;quot; maps the red channel to Engine 1, and the green channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
You should avoid mapping the same channel to both engines, for example &amp;quot;rR&amp;quot;, &amp;quot;gG&amp;quot; or &amp;quot;bB&amp;quot; - it&#039;s not supported by the hardware, makes no sense anyway, and therefore probably never has been tested.&lt;br /&gt;
&lt;br /&gt;
==== Engine Pattern ====&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Lysti Format Engine Patterns and Commands ===&lt;br /&gt;
&lt;br /&gt;
The LED patterns are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d8040007f007f0040ff7f007f000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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)&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d80 4000 7f00 7f00 40ff 7f00 7f00 0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 9d80 - Refresh Engine Multiplexer ====&lt;br /&gt;
&lt;br /&gt;
This is to be used as the first command of every pattern. If this is excluded from the pattern, the led won&#039;t flash. (actually this command loads the first [and only] entry of a predefined [by kernel driver] multiplexer table in chip&#039;s RAM to the multiplexer register)&lt;br /&gt;
&lt;br /&gt;
==== 40xx - Set channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Where xx are two hexadecimal digits, e.g. 00 (for a brightness of 0) or ff (for a brightness of 255).&lt;br /&gt;
&lt;br /&gt;
==== xxyy - Adjust channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Increment or decrement the channel brightness over a period of time (xx) and a number of steps (yy).&lt;br /&gt;
&lt;br /&gt;
Where xx and yy are hexadecimal digits&lt;br /&gt;
&lt;br /&gt;
xx - Time (per step?)&lt;br /&gt;
&lt;br /&gt;
yy - Number of steps&lt;br /&gt;
&lt;br /&gt;
The following rules apply to these:&lt;br /&gt;
* If xx is even, the steps are increment steps and brightness will increase.&lt;br /&gt;
* If xx is odd, the steps are decrement steps and brightness will decrease.&lt;br /&gt;
* If xx is between 02 and 3f, a short step time is used (granularity 0.49ms)&lt;br /&gt;
* If xx is between 42 and 7f, a long step time is used (granularity 15.6ms)&lt;br /&gt;
* yy can be any value between 00 and ff (0 to 255)&lt;br /&gt;
* Pauses can be achieved by using 00 steps, e.g. 7f00 where, where the 7f is how long each step takes and 00 is how many increment steps to take.&lt;br /&gt;
&lt;br /&gt;
The mce.ini instructions (/etc/mce/mce.ini) also state that &lt;br /&gt;
:Two consecutive increment/decrement sequences are needed to cover the entire range from 0-255&lt;br /&gt;
However I believe this is a throwback to the older patterns, and the full range of 00 to ff is available in a single step for the number of steps, since whether these are increment or decrement steps are now handled through use of even or odd xx values.&lt;br /&gt;
&lt;br /&gt;
==== 0000 - Jump to start ====&lt;br /&gt;
&lt;br /&gt;
Jump to the start of the pattern for this channel. You will see this at the end of most repeating patterns.&lt;br /&gt;
&lt;br /&gt;
This command may not actually be needed to make the pattern repeat. If this is removed, the pattern will repeat anyway, although it&#039;s useful to have it there as an explicit command to repeat for clarity. If you wanted a pattern to run once and then terminate you would use the c000 command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== A000 .. BFFF - Branch (decrement and branch if non zero) ====&lt;br /&gt;
&lt;br /&gt;
101&amp;lt;llllll&amp;gt;&amp;lt;sssssss&amp;gt; : 16bit&lt;br /&gt;
&lt;br /&gt;
llllll : 6bit; Loop count, 0=infinite loop, or max 63 loops&lt;br /&gt;
&lt;br /&gt;
sssssss : 7 bit; Step number; Value to store to PC (0-95 actual progspace of LP5523 of 96 16bit commands. [Unclear if that&#039;s absolute address, or probably offset relative to start of program space assigned to the particular engine])&lt;br /&gt;
&lt;br /&gt;
You can build MUCH SMARTER loops with this! ;-D&lt;br /&gt;
&lt;br /&gt;
==== c000 - End pattern execution ====&lt;br /&gt;
&lt;br /&gt;
(also d000 = with hw INT; c800/d800 = with PC reset. INT might serve to signal end-of-pattern to main CPU -&amp;gt;*)&lt;br /&gt;
&lt;br /&gt;
The pattern is terminated without repeating. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;the following is about mce, not about how LP5523 chip works&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Sending and receiving engine triggers ====&lt;br /&gt;
&lt;br /&gt;
Further complexity in patterns can be added through use of triggers. This is especially useful if we want to synchronise the two engines in time, for example to wait until the LED has turned red before turning it immediately to green. Rather than waste time with steps doing nothing, we can simply wait for a trigger to be received from the other engine.&lt;br /&gt;
&lt;br /&gt;
The following pattern does exactly that:&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternTest=29;1;0;rG;9d80&#039;&#039;4000&#039;&#039;08ff&#039;&#039;&amp;lt;u&amp;gt;e004&amp;lt;/u&amp;gt;&#039;&#039;4000&#039;&#039;c000&#039;&#039;;9d80&#039;&#039;&amp;lt;u&amp;gt;e080&amp;lt;/u&amp;gt;&#039;&#039;40ff&#039;&#039;c000&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== e002, e004, e008 - Send engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e002 - Send trigger to engine 1&lt;br /&gt;
&lt;br /&gt;
e004 - Send trigger to engine 2&lt;br /&gt;
&lt;br /&gt;
e008 - Send trigger to engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
A signal is sent from the current engine to signal another engine.&lt;br /&gt;
&lt;br /&gt;
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&#039;t mess with LP5523 anymore - see below).&lt;br /&gt;
&lt;br /&gt;
===== e080, e100, e200 - Wait for engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e080 - Wait for trigger from engine 1&lt;br /&gt;
&lt;br /&gt;
e100 - Wait for trigger from engine 2&lt;br /&gt;
&lt;br /&gt;
e200 - Wait for trigger from engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
...and there&#039;s more. Engine can actually do sub/add arithmetics, branches, and select which leds it controls.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Default LED Patterns for Nokia N900 ===&lt;br /&gt;
&lt;br /&gt;
 PatternError=0;5;0;r;9d8040007f007f0040ff7f007f000000;9d800000&lt;br /&gt;
 PatternDeviceOn=254;0;0;rgb;9d804000422043207f100000;9d800000&lt;br /&gt;
 PatternDeviceSoftOff=253;0;0;rg;9d804000423f433f7f100000;9d800000&lt;br /&gt;
 PatternPowerOn=9;3;0;rgb;9d80400042ff02ffc000;9d800000&lt;br /&gt;
 PatternPowerOff=10;3;0;rgb;9d80400001ff43ff7f007f00c000;9d800000&lt;br /&gt;
 PatternCommunicationCall=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationIM=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationSMS=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommonNotification=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternWebcamActive=20;1;0;r;9d80400004ffc0000000;9d800000&lt;br /&gt;
 PatternBatteryCharging=50;4;0;rg;9d804000427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
 PatternBatteryFull=40;4;0;g;9d80407f0000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Community-Made Patterns ===&lt;br /&gt;
&#039;&#039;Please note that these patterns should each be on one line.&#039;&#039;&lt;br /&gt;
&#039;&#039;They can also be used for any notification by choosing the appropriately named &amp;quot;Pattern... for the start of the line.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A traffic-light battery charging pattern, courtesy of [http://talk.maemo.org/showthread.php?p=512430#post512430 blue_led]&lt;br /&gt;
 PatternBatteryCharging=50;4;0;Rg;9d80407f7f00e0047f0040007f007f007f00407f7f00e0047f007f000000;9d804000e080407fe0800000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=499305#post499305 mihapodb]. This pattern cuts quickly between blue and red.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8040ff7f00e00440007f000000;9d80e08040ff7f0040000000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=540959#post540959 villo]. This pattern fades between red and blue.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8004ff05ffe004e1000000;9d80e08004ff05ffe0020000&lt;br /&gt;
&lt;br /&gt;
Cehteh&#039;s patterns with some comments&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in cyan, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternDeviceOn=254;0;0;gb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in yellow, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryCharging=50;3;0;rg;9d804001427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in white, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryFull=40;3;0;rgb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
White, bright flashing (must be enabled in &#039;LEDPatterns=&#039; ?):&lt;br /&gt;
 PatternExample=42;1;30;rgb;9d8040007f007f0040ff42000000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Step by step instructions ===&lt;br /&gt;
{{ambox&lt;br /&gt;
|type=notice&lt;br /&gt;
|text=There&#039;s a command &lt;br /&gt;
IroN900:~# /usr/bin/mceledpattern --help&lt;br /&gt;
  Usage:&lt;br /&gt;
  mceledpattern add[_vibra] &amp;lt;pattern_name&amp;gt; &amp;lt;pattern&amp;gt;&lt;br /&gt;
  mceledpattern remove[_vibra] &amp;lt;pattern_name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  To replace existing pattern use add, to restore replaced pattern back to previous value use remove&lt;br /&gt;
Please check if it&#039;s default or came with one of my additional packages}}&lt;br /&gt;
* Open terminal&lt;br /&gt;
* Gain [[root access]]&lt;br /&gt;
* Make a backup (for your own convenience) from original mce.ini -file, for example:&amp;lt;pre&amp;gt;cp /etc/mce/mce.ini /etc/mce/mce.ini_old&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Open &amp;lt;code&amp;gt;/etc/mce/mce.ini&amp;lt;/code&amp;gt; with a text editor (nano, vim, leafpad...)&lt;br /&gt;
* Search for a line:&amp;lt;pre&amp;gt;[LEDPatternLystiRX51]&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Make your changes to the lines below&lt;br /&gt;
* Save&lt;br /&gt;
* Restart mce -process. Either reboot or type in terminal:&amp;lt;pre&amp;gt;initctl stop mce; sleep 2; initctl start mce&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note: restarting mce several times in 2 minutes will cause the system to think there is a problem with mce, and so won&#039;t start it. The initctl program will inform you of this. When it does, simply wait a while before trying again.&lt;br /&gt;
&lt;br /&gt;
Alternatively, mce is started using [[dsmetool]] which monitors and reboots the device on failure.&lt;br /&gt;
This monitoring can be adjusted for more convenient hacking.&lt;br /&gt;
&lt;br /&gt;
/etc/event.d/mce&lt;br /&gt;
&lt;br /&gt;
*         /usr/sbin/dsmetool -n -1 -t &amp;quot;/sbin/mce --force-syslog&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Replacing -t (start and restart) with -o (start once) eliminates this monitoring.&lt;br /&gt;
&lt;br /&gt;
Please be aware that errors in editing these files could cause a reboot loop, which could require a reflash to stop.&lt;br /&gt;
&lt;br /&gt;
=== Low Level ===&lt;br /&gt;
&#039;&#039;&#039;this section should get merged with [[N900_Hardware_LED]] !&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The N8x0 had a LP5521&amp;lt;ref name=&amp;quot;lp5521-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5521.html&amp;lt;/ref&amp;gt;  &amp;lt;ref name=&amp;quot;lp5521-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/i2c/chips/lp5521.c&amp;lt;/ref&amp;gt; programmable three channel controller LED Driver which handles the leds.&lt;br /&gt;
The N900 has a LP5523 &amp;lt;ref name=&amp;quot;lp5523-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5523.html&amp;lt;/ref&amp;gt; &amp;lt;ref name=&amp;quot;leds-lp5523-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/leds/leds-lp5523.c&amp;lt;/ref&amp;gt;, which has 3 engines like LP5521 but can drive 9 LEDs via a multiplexer. Actually the multiplexer is between the engine (CPU) and the 9 PWM blocks for the 9 LED outputs - each of those 9 PWM blocks has its own accessable registers for current and brightness, and they are exposed to sysfs. This chip also has double the RAM size for &#039;programs&#039;, plus 2 per-machine and one global register variable and a true set of conditional branch and arithmetic commands. &lt;br /&gt;
&lt;br /&gt;
Alas the LP5523 driver doesn&#039;t support any of those advanced features of LP5523, and uses one of those  engines for a kbd backlight ramp-up/down.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;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.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See [[N900_Hardware_LED]] for hardware programming details.&lt;br /&gt;
&lt;br /&gt;
** engine1_leds is in the form &amp;quot;0000rgb00&amp;quot; (9 digits, &amp;quot;1&amp;quot; or &amp;quot;0&amp;quot;), where rgb control which leds should participate. The 6 &amp;quot;0&amp;quot; in the above pattern correspond to the 6 kbd white leds controlled by mce via engine3, so readout of engine3_leds gives 111100011 ;-)&lt;br /&gt;
** engine1_load accepts a string as specified above (e.g. 9d804000427f0d7f7f007f0042000000). Though LP5523 has an absolute storage of 96 steps a 16bits, which can dynamically partitioned between the three engines, the driver limits this to a fixed 16 words a 16bit per engine &lt;br /&gt;
&lt;br /&gt;
After that, when the state is changed to &amp;quot;run&amp;quot;, the program will be run by the controller. &lt;br /&gt;
&lt;br /&gt;
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]/&#039;&#039;&#039;led_current&#039;&#039;&#039; under the same directory. &#039;&#039;&#039;Don&#039;t mess with&#039;&#039;&#039; the default settings here that come with driver init, they are suitable and changing to higher values may and for certain values &#039;&#039;&#039;will kill your LEDS&#039;&#039;&#039;!.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Also see [[N900_Hardware_LED]]! &lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:N900 Hardware]]&lt;br /&gt;
[[Category:Power users]]&lt;/div&gt;</summary>
		<author><name>90.180.214.199</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14054</id>
		<title>LED patterns</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14054"/>
		<updated>2014-01-06T13:37:55Z</updated>

		<summary type="html">&lt;p&gt;90.180.214.199: /* Low Level */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== N800 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N800|N800]] has a single-colour (blue) LED behind the dpad.&lt;br /&gt;
&lt;br /&gt;
== N810 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N810|N810]] has an RGB LED.&lt;br /&gt;
&lt;br /&gt;
== N900 ==&lt;br /&gt;
&lt;br /&gt;
=== File Location ===&lt;br /&gt;
&lt;br /&gt;
The software on the device that controls the LED colors is [[N900 Software MCE|MCE]].&lt;br /&gt;
&lt;br /&gt;
The file defining patterns can be found in&lt;br /&gt;
 /etc/mce/mce.ini&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;mce.ini&amp;lt;/code&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Pattern Format ===&lt;br /&gt;
&lt;br /&gt;
The patterns are broken down as follows:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(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&#039;t support pattern&lt;br /&gt;
definitions for engine3. mce is closed source and thus this can&#039;t be fixed in any reasonable way. If mce were open, an alternative compatible format was possible:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern;Engine3Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where LEDsToMap was something like &amp;quot;000012300&amp;quot; to map the particular LED to either none, or Engine1..3 respectively. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==== Priority ====&lt;br /&gt;
&lt;br /&gt;
0-255, 0 is highest, 255 is lowest.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== ScreenOn ====&lt;br /&gt;
&lt;br /&gt;
* 0: only show pattern when the display is off&lt;br /&gt;
* 1: show pattern even when the display is on&lt;br /&gt;
* 2: only show pattern when the display is off, including acting dead&lt;br /&gt;
* 3: show pattern even when the display is on, including acting dead&lt;br /&gt;
* 4: only show pattern if the display is off, or if in acting dead&lt;br /&gt;
* 5: always show pattern, even if LED disabled&lt;br /&gt;
&lt;br /&gt;
==== TimeOut ====&lt;br /&gt;
&lt;br /&gt;
This is the time-out of the LED pattern in seconds. 0 for infinite, i.e. until the notification is dismissed.&lt;br /&gt;
&lt;br /&gt;
If this is set to 20, the pattern will display for 20 seconds, and then stop.&lt;br /&gt;
&lt;br /&gt;
==== LEDsToMap ====&lt;br /&gt;
&lt;br /&gt;
There are two engines that can be used to make custom LED patterns.&amp;lt;ref name=&amp;quot;engines&amp;quot;&amp;gt;Actually there are three, but the third engine is used exclusively for the keyboard LED.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
r, g, or b maps the corresponding colour channel to Engine 1.&lt;br /&gt;
&lt;br /&gt;
R, G, or B maps the corresponding colour channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;quot;rG&amp;quot; maps the red channel to Engine 1, and the green channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
You should avoid mapping the same channel to both engines, for example &amp;quot;rR&amp;quot;, &amp;quot;gG&amp;quot; or &amp;quot;bB&amp;quot; - it&#039;s not supported by the hardware, makes no sense anyway, and therefore probably never has been tested.&lt;br /&gt;
&lt;br /&gt;
==== Engine Pattern ====&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Lysti Format Engine Patterns and Commands ===&lt;br /&gt;
&lt;br /&gt;
The LED patterns are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d8040007f007f0040ff7f007f000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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)&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d80 4000 7f00 7f00 40ff 7f00 7f00 0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 9d80 - Refresh Engine Multiplexer ====&lt;br /&gt;
&lt;br /&gt;
This is to be used as the first command of every pattern. If this is excluded from the pattern, the led won&#039;t flash. (actually this command loads the first [and only] entry of a predefined [by kernel driver] multiplexer table in chip&#039;s RAM to the multiplexer register)&lt;br /&gt;
&lt;br /&gt;
==== 40xx - Set channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Where xx are two hexadecimal digits, e.g. 00 (for a brightness of 0) or ff (for a brightness of 255).&lt;br /&gt;
&lt;br /&gt;
==== xxyy - Adjust channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Increment or decrement the channel brightness over a period of time (xx) and a number of steps (yy).&lt;br /&gt;
&lt;br /&gt;
Where xx and yy are hexadecimal digits&lt;br /&gt;
&lt;br /&gt;
xx - Time (per step?)&lt;br /&gt;
&lt;br /&gt;
yy - Number of steps&lt;br /&gt;
&lt;br /&gt;
The following rules apply to these:&lt;br /&gt;
* If xx is even, the steps are increment steps and brightness will increase.&lt;br /&gt;
* If xx is odd, the steps are decrement steps and brightness will decrease.&lt;br /&gt;
* If xx is between 02 and 3f, a short step time is used (granularity 0.49ms)&lt;br /&gt;
* If xx is between 42 and 7f, a long step time is used (granularity 15.6ms)&lt;br /&gt;
* yy can be any value between 00 and ff (0 to 255)&lt;br /&gt;
* Pauses can be achieved by using 00 steps, e.g. 7f00 where, where the 7f is how long each step takes and 00 is how many increment steps to take.&lt;br /&gt;
&lt;br /&gt;
The mce.ini instructions (/etc/mce/mce.ini) also state that &lt;br /&gt;
:Two consecutive increment/decrement sequences are needed to cover the entire range from 0-255&lt;br /&gt;
However I believe this is a throwback to the older patterns, and the full range of 00 to ff is available in a single step for the number of steps, since whether these are increment or decrement steps are now handled through use of even or odd xx values.&lt;br /&gt;
&lt;br /&gt;
==== 0000 - Jump to start ====&lt;br /&gt;
&lt;br /&gt;
Jump to the start of the pattern for this channel. You will see this at the end of most repeating patterns.&lt;br /&gt;
&lt;br /&gt;
This command may not actually be needed to make the pattern repeat. If this is removed, the pattern will repeat anyway, although it&#039;s useful to have it there as an explicit command to repeat for clarity. If you wanted a pattern to run once and then terminate you would use the c000 command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== A000 .. BFFF - Branch (decrement and branch if non zero) ====&lt;br /&gt;
&lt;br /&gt;
101&amp;lt;llllll&amp;gt;&amp;lt;sssssss&amp;gt; : 16bit&lt;br /&gt;
&lt;br /&gt;
llllll : 6bit; Loop count, 0=infinite loop, or max 63 loops&lt;br /&gt;
&lt;br /&gt;
sssssss : 7 bit; Step number; Value to store to PC (0-95 actual progspace of LP5523 of 96 16bit commands. [Unclear if that&#039;s absolute address, or probably offset relative to start of program space assigned to the particular engine])&lt;br /&gt;
&lt;br /&gt;
You can build MUCH SMARTER loops with this! ;-D&lt;br /&gt;
&lt;br /&gt;
==== c000 - End pattern execution ====&lt;br /&gt;
&lt;br /&gt;
(also d000 = with hw INT; c800/d800 = with PC reset. INT might serve to signal end-of-pattern to main CPU -&amp;gt;*)&lt;br /&gt;
&lt;br /&gt;
The pattern is terminated without repeating. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;the following is about mce, not about how LP5523 chip works&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Sending and receiving engine triggers ====&lt;br /&gt;
&lt;br /&gt;
Further complexity in patterns can be added through use of triggers. This is especially useful if we want to synchronise the two engines in time, for example to wait until the LED has turned red before turning it immediately to green. Rather than waste time with steps doing nothing, we can simply wait for a trigger to be received from the other engine.&lt;br /&gt;
&lt;br /&gt;
The following pattern does exactly that:&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternTest=29;1;0;rG;9d80&#039;&#039;4000&#039;&#039;08ff&#039;&#039;&amp;lt;u&amp;gt;e004&amp;lt;/u&amp;gt;&#039;&#039;4000&#039;&#039;c000&#039;&#039;;9d80&#039;&#039;&amp;lt;u&amp;gt;e080&amp;lt;/u&amp;gt;&#039;&#039;40ff&#039;&#039;c000&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== e002, e004, e008 - Send engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e002 - Send trigger to engine 1&lt;br /&gt;
&lt;br /&gt;
e004 - Send trigger to engine 2&lt;br /&gt;
&lt;br /&gt;
e008 - Send trigger to engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
A signal is sent from the current engine to signal another engine.&lt;br /&gt;
&lt;br /&gt;
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&#039;t mess with LP5523 anymore - see below).&lt;br /&gt;
&lt;br /&gt;
===== e080, e100, e200 - Wait for engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e080 - Wait for trigger from engine 1&lt;br /&gt;
&lt;br /&gt;
e100 - Wait for trigger from engine 2&lt;br /&gt;
&lt;br /&gt;
e200 - Wait for trigger from engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Default LED Patterns for Nokia N900 ===&lt;br /&gt;
&lt;br /&gt;
 PatternError=0;5;0;r;9d8040007f007f0040ff7f007f000000;9d800000&lt;br /&gt;
 PatternDeviceOn=254;0;0;rgb;9d804000422043207f100000;9d800000&lt;br /&gt;
 PatternDeviceSoftOff=253;0;0;rg;9d804000423f433f7f100000;9d800000&lt;br /&gt;
 PatternPowerOn=9;3;0;rgb;9d80400042ff02ffc000;9d800000&lt;br /&gt;
 PatternPowerOff=10;3;0;rgb;9d80400001ff43ff7f007f00c000;9d800000&lt;br /&gt;
 PatternCommunicationCall=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationIM=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationSMS=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommonNotification=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternWebcamActive=20;1;0;r;9d80400004ffc0000000;9d800000&lt;br /&gt;
 PatternBatteryCharging=50;4;0;rg;9d804000427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
 PatternBatteryFull=40;4;0;g;9d80407f0000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Community-Made Patterns ===&lt;br /&gt;
&#039;&#039;Please note that these patterns should each be on one line.&#039;&#039;&lt;br /&gt;
&#039;&#039;They can also be used for any notification by choosing the appropriately named &amp;quot;Pattern... for the start of the line.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A traffic-light battery charging pattern, courtesy of [http://talk.maemo.org/showthread.php?p=512430#post512430 blue_led]&lt;br /&gt;
 PatternBatteryCharging=50;4;0;Rg;9d80407f7f00e0047f0040007f007f007f00407f7f00e0047f007f000000;9d804000e080407fe0800000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=499305#post499305 mihapodb]. This pattern cuts quickly between blue and red.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8040ff7f00e00440007f000000;9d80e08040ff7f0040000000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=540959#post540959 villo]. This pattern fades between red and blue.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8004ff05ffe004e1000000;9d80e08004ff05ffe0020000&lt;br /&gt;
&lt;br /&gt;
Cehteh&#039;s patterns with some comments&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in cyan, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternDeviceOn=254;0;0;gb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in yellow, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryCharging=50;3;0;rg;9d804001427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in white, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryFull=40;3;0;rgb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
White, bright flashing (must be enabled in &#039;LEDPatterns=&#039; ?):&lt;br /&gt;
 PatternExample=42;1;30;rgb;9d8040007f007f0040ff42000000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Step by step instructions ===&lt;br /&gt;
{{ambox&lt;br /&gt;
|type=notice&lt;br /&gt;
|text=There&#039;s a command &lt;br /&gt;
IroN900:~# /usr/bin/mceledpattern --help&lt;br /&gt;
  Usage:&lt;br /&gt;
  mceledpattern add[_vibra] &amp;lt;pattern_name&amp;gt; &amp;lt;pattern&amp;gt;&lt;br /&gt;
  mceledpattern remove[_vibra] &amp;lt;pattern_name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  To replace existing pattern use add, to restore replaced pattern back to previous value use remove&lt;br /&gt;
Please check if it&#039;s default or came with one of my additional packages}}&lt;br /&gt;
* Open terminal&lt;br /&gt;
* Gain [[root access]]&lt;br /&gt;
* Make a backup (for your own convenience) from original mce.ini -file, for example:&amp;lt;pre&amp;gt;cp /etc/mce/mce.ini /etc/mce/mce.ini_old&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Open &amp;lt;code&amp;gt;/etc/mce/mce.ini&amp;lt;/code&amp;gt; with a text editor (nano, vim, leafpad...)&lt;br /&gt;
* Search for a line:&amp;lt;pre&amp;gt;[LEDPatternLystiRX51]&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Make your changes to the lines below&lt;br /&gt;
* Save&lt;br /&gt;
* Restart mce -process. Either reboot or type in terminal:&amp;lt;pre&amp;gt;initctl stop mce; sleep 2; initctl start mce&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note: restarting mce several times in 2 minutes will cause the system to think there is a problem with mce, and so won&#039;t start it. The initctl program will inform you of this. When it does, simply wait a while before trying again.&lt;br /&gt;
&lt;br /&gt;
Alternatively, mce is started using [[dsmetool]] which monitors and reboots the device on failure.&lt;br /&gt;
This monitoring can be adjusted for more convenient hacking.&lt;br /&gt;
&lt;br /&gt;
/etc/event.d/mce&lt;br /&gt;
&lt;br /&gt;
*         /usr/sbin/dsmetool -n -1 -t &amp;quot;/sbin/mce --force-syslog&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Replacing -t (start and restart) with -o (start once) eliminates this monitoring.&lt;br /&gt;
&lt;br /&gt;
Please be aware that errors in editing these files could cause a reboot loop, which could require a reflash to stop.&lt;br /&gt;
&lt;br /&gt;
=== Low Level ===&lt;br /&gt;
&#039;&#039;&#039;this section should get merged with [[N900_Hardware_LED]] !&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The N8x0 had a LP5521&amp;lt;ref name=&amp;quot;lp5521-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5521.html&amp;lt;/ref&amp;gt;  &amp;lt;ref name=&amp;quot;lp5521-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/i2c/chips/lp5521.c&amp;lt;/ref&amp;gt; programmable three channel controller LED Driver which handles the leds.&lt;br /&gt;
The N900 has a LP5523 &amp;lt;ref name=&amp;quot;lp5523-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5523.html&amp;lt;/ref&amp;gt; &amp;lt;ref name=&amp;quot;leds-lp5523-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/leds/leds-lp5523.c&amp;lt;/ref&amp;gt;, which has 3 engines like LP5521 but can drive 9 LEDs via a multiplexer. Actually the multiplexer is between the engine (CPU) and the 9 PWM blocks for the 9 LED outputs - each of those 9 PWM blocks has its own accessable registers for current and brightness, and they are exposed to sysfs. This chip also has double the RAM size for &#039;programs&#039;, plus 2 per-machine and one global register variable and a true set of conditional branch and arithmetic commands. &lt;br /&gt;
&lt;br /&gt;
Alas the LP5523 driver doesn&#039;t support any of those advanced features of LP5523, and uses one of those  engines for a kbd backlight ramp-up/down.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;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.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See [[N900_Hardware_LED]] for hardware programming details.&lt;br /&gt;
&lt;br /&gt;
** engine1_leds is in the form &amp;quot;0000rgb00&amp;quot; (9 digits, &amp;quot;1&amp;quot; or &amp;quot;0&amp;quot;), where rgb control which leds should participate. The 6 &amp;quot;0&amp;quot; in the above pattern correspond to the 6 kbd white leds controlled by mce via engine3, so readout of engine3_leds gives 111100011 ;-)&lt;br /&gt;
** engine1_load accepts a string as specified above (e.g. 9d804000427f0d7f7f007f0042000000). Though LP5523 has an absolute storage of 96 steps a 16bits, which can dynamically partitioned between the three engines, the driver limits this to a fixed 16 words a 16bit per engine &lt;br /&gt;
&lt;br /&gt;
After that, when the state is changed to &amp;quot;run&amp;quot;, the program will be run by the controller. &lt;br /&gt;
&lt;br /&gt;
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]/&#039;&#039;&#039;led_current&#039;&#039;&#039; under the same directory. &#039;&#039;&#039;Don&#039;t mess with&#039;&#039;&#039; the default settings here that come with driver init, they are suitable and changing to higher values may and for certain values &#039;&#039;&#039;will kill your LEDS&#039;&#039;&#039;!.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Also see [[N900_Hardware_LED]]! &lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:N900 Hardware]]&lt;br /&gt;
[[Category:Power users]]&lt;/div&gt;</summary>
		<author><name>90.180.214.199</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14055</id>
		<title>LED patterns</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14055"/>
		<updated>2014-01-06T13:36:57Z</updated>

		<summary type="html">&lt;p&gt;90.180.214.199: /* Low Level */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== N800 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N800|N800]] has a single-colour (blue) LED behind the dpad.&lt;br /&gt;
&lt;br /&gt;
== N810 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N810|N810]] has an RGB LED.&lt;br /&gt;
&lt;br /&gt;
== N900 ==&lt;br /&gt;
&lt;br /&gt;
=== File Location ===&lt;br /&gt;
&lt;br /&gt;
The software on the device that controls the LED colors is [[N900 Software MCE|MCE]].&lt;br /&gt;
&lt;br /&gt;
The file defining patterns can be found in&lt;br /&gt;
 /etc/mce/mce.ini&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;mce.ini&amp;lt;/code&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Pattern Format ===&lt;br /&gt;
&lt;br /&gt;
The patterns are broken down as follows:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(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&#039;t support pattern&lt;br /&gt;
definitions for engine3. mce is closed source and thus this can&#039;t be fixed in any reasonable way. If mce were open, an alternative compatible format was possible:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern;Engine3Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where LEDsToMap was something like &amp;quot;000012300&amp;quot; to map the particular LED to either none, or Engine1..3 respectively. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==== Priority ====&lt;br /&gt;
&lt;br /&gt;
0-255, 0 is highest, 255 is lowest.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== ScreenOn ====&lt;br /&gt;
&lt;br /&gt;
* 0: only show pattern when the display is off&lt;br /&gt;
* 1: show pattern even when the display is on&lt;br /&gt;
* 2: only show pattern when the display is off, including acting dead&lt;br /&gt;
* 3: show pattern even when the display is on, including acting dead&lt;br /&gt;
* 4: only show pattern if the display is off, or if in acting dead&lt;br /&gt;
* 5: always show pattern, even if LED disabled&lt;br /&gt;
&lt;br /&gt;
==== TimeOut ====&lt;br /&gt;
&lt;br /&gt;
This is the time-out of the LED pattern in seconds. 0 for infinite, i.e. until the notification is dismissed.&lt;br /&gt;
&lt;br /&gt;
If this is set to 20, the pattern will display for 20 seconds, and then stop.&lt;br /&gt;
&lt;br /&gt;
==== LEDsToMap ====&lt;br /&gt;
&lt;br /&gt;
There are two engines that can be used to make custom LED patterns.&amp;lt;ref name=&amp;quot;engines&amp;quot;&amp;gt;Actually there are three, but the third engine is used exclusively for the keyboard LED.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
r, g, or b maps the corresponding colour channel to Engine 1.&lt;br /&gt;
&lt;br /&gt;
R, G, or B maps the corresponding colour channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;quot;rG&amp;quot; maps the red channel to Engine 1, and the green channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
You should avoid mapping the same channel to both engines, for example &amp;quot;rR&amp;quot;, &amp;quot;gG&amp;quot; or &amp;quot;bB&amp;quot; - it&#039;s not supported by the hardware, makes no sense anyway, and therefore probably never has been tested.&lt;br /&gt;
&lt;br /&gt;
==== Engine Pattern ====&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Lysti Format Engine Patterns and Commands ===&lt;br /&gt;
&lt;br /&gt;
The LED patterns are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d8040007f007f0040ff7f007f000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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)&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d80 4000 7f00 7f00 40ff 7f00 7f00 0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 9d80 - Refresh Engine Multiplexer ====&lt;br /&gt;
&lt;br /&gt;
This is to be used as the first command of every pattern. If this is excluded from the pattern, the led won&#039;t flash. (actually this command loads the first [and only] entry of a predefined [by kernel driver] multiplexer table in chip&#039;s RAM to the multiplexer register)&lt;br /&gt;
&lt;br /&gt;
==== 40xx - Set channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Where xx are two hexadecimal digits, e.g. 00 (for a brightness of 0) or ff (for a brightness of 255).&lt;br /&gt;
&lt;br /&gt;
==== xxyy - Adjust channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Increment or decrement the channel brightness over a period of time (xx) and a number of steps (yy).&lt;br /&gt;
&lt;br /&gt;
Where xx and yy are hexadecimal digits&lt;br /&gt;
&lt;br /&gt;
xx - Time (per step?)&lt;br /&gt;
&lt;br /&gt;
yy - Number of steps&lt;br /&gt;
&lt;br /&gt;
The following rules apply to these:&lt;br /&gt;
* If xx is even, the steps are increment steps and brightness will increase.&lt;br /&gt;
* If xx is odd, the steps are decrement steps and brightness will decrease.&lt;br /&gt;
* If xx is between 02 and 3f, a short step time is used (granularity 0.49ms)&lt;br /&gt;
* If xx is between 42 and 7f, a long step time is used (granularity 15.6ms)&lt;br /&gt;
* yy can be any value between 00 and ff (0 to 255)&lt;br /&gt;
* Pauses can be achieved by using 00 steps, e.g. 7f00 where, where the 7f is how long each step takes and 00 is how many increment steps to take.&lt;br /&gt;
&lt;br /&gt;
The mce.ini instructions (/etc/mce/mce.ini) also state that &lt;br /&gt;
:Two consecutive increment/decrement sequences are needed to cover the entire range from 0-255&lt;br /&gt;
However I believe this is a throwback to the older patterns, and the full range of 00 to ff is available in a single step for the number of steps, since whether these are increment or decrement steps are now handled through use of even or odd xx values.&lt;br /&gt;
&lt;br /&gt;
==== 0000 - Jump to start ====&lt;br /&gt;
&lt;br /&gt;
Jump to the start of the pattern for this channel. You will see this at the end of most repeating patterns.&lt;br /&gt;
&lt;br /&gt;
This command may not actually be needed to make the pattern repeat. If this is removed, the pattern will repeat anyway, although it&#039;s useful to have it there as an explicit command to repeat for clarity. If you wanted a pattern to run once and then terminate you would use the c000 command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== A000 .. BFFF - Branch (decrement and branch if non zero) ====&lt;br /&gt;
&lt;br /&gt;
101&amp;lt;llllll&amp;gt;&amp;lt;sssssss&amp;gt; : 16bit&lt;br /&gt;
&lt;br /&gt;
llllll : 6bit; Loop count, 0=infinite loop, or max 63 loops&lt;br /&gt;
&lt;br /&gt;
sssssss : 7 bit; Step number; Value to store to PC (0-95 actual progspace of LP5523 of 96 16bit commands. [Unclear if that&#039;s absolute address, or probably offset relative to start of program space assigned to the particular engine])&lt;br /&gt;
&lt;br /&gt;
You can build MUCH SMARTER loops with this! ;-D&lt;br /&gt;
&lt;br /&gt;
==== c000 - End pattern execution ====&lt;br /&gt;
&lt;br /&gt;
(also d000 = with hw INT; c800/d800 = with PC reset. INT might serve to signal end-of-pattern to main CPU -&amp;gt;*)&lt;br /&gt;
&lt;br /&gt;
The pattern is terminated without repeating. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;the following is about mce, not about how LP5523 chip works&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Sending and receiving engine triggers ====&lt;br /&gt;
&lt;br /&gt;
Further complexity in patterns can be added through use of triggers. This is especially useful if we want to synchronise the two engines in time, for example to wait until the LED has turned red before turning it immediately to green. Rather than waste time with steps doing nothing, we can simply wait for a trigger to be received from the other engine.&lt;br /&gt;
&lt;br /&gt;
The following pattern does exactly that:&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternTest=29;1;0;rG;9d80&#039;&#039;4000&#039;&#039;08ff&#039;&#039;&amp;lt;u&amp;gt;e004&amp;lt;/u&amp;gt;&#039;&#039;4000&#039;&#039;c000&#039;&#039;;9d80&#039;&#039;&amp;lt;u&amp;gt;e080&amp;lt;/u&amp;gt;&#039;&#039;40ff&#039;&#039;c000&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== e002, e004, e008 - Send engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e002 - Send trigger to engine 1&lt;br /&gt;
&lt;br /&gt;
e004 - Send trigger to engine 2&lt;br /&gt;
&lt;br /&gt;
e008 - Send trigger to engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
A signal is sent from the current engine to signal another engine.&lt;br /&gt;
&lt;br /&gt;
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&#039;t mess with LP5523 anymore - see below).&lt;br /&gt;
&lt;br /&gt;
===== e080, e100, e200 - Wait for engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e080 - Wait for trigger from engine 1&lt;br /&gt;
&lt;br /&gt;
e100 - Wait for trigger from engine 2&lt;br /&gt;
&lt;br /&gt;
e200 - Wait for trigger from engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Default LED Patterns for Nokia N900 ===&lt;br /&gt;
&lt;br /&gt;
 PatternError=0;5;0;r;9d8040007f007f0040ff7f007f000000;9d800000&lt;br /&gt;
 PatternDeviceOn=254;0;0;rgb;9d804000422043207f100000;9d800000&lt;br /&gt;
 PatternDeviceSoftOff=253;0;0;rg;9d804000423f433f7f100000;9d800000&lt;br /&gt;
 PatternPowerOn=9;3;0;rgb;9d80400042ff02ffc000;9d800000&lt;br /&gt;
 PatternPowerOff=10;3;0;rgb;9d80400001ff43ff7f007f00c000;9d800000&lt;br /&gt;
 PatternCommunicationCall=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationIM=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationSMS=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommonNotification=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternWebcamActive=20;1;0;r;9d80400004ffc0000000;9d800000&lt;br /&gt;
 PatternBatteryCharging=50;4;0;rg;9d804000427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
 PatternBatteryFull=40;4;0;g;9d80407f0000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Community-Made Patterns ===&lt;br /&gt;
&#039;&#039;Please note that these patterns should each be on one line.&#039;&#039;&lt;br /&gt;
&#039;&#039;They can also be used for any notification by choosing the appropriately named &amp;quot;Pattern... for the start of the line.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A traffic-light battery charging pattern, courtesy of [http://talk.maemo.org/showthread.php?p=512430#post512430 blue_led]&lt;br /&gt;
 PatternBatteryCharging=50;4;0;Rg;9d80407f7f00e0047f0040007f007f007f00407f7f00e0047f007f000000;9d804000e080407fe0800000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=499305#post499305 mihapodb]. This pattern cuts quickly between blue and red.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8040ff7f00e00440007f000000;9d80e08040ff7f0040000000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=540959#post540959 villo]. This pattern fades between red and blue.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8004ff05ffe004e1000000;9d80e08004ff05ffe0020000&lt;br /&gt;
&lt;br /&gt;
Cehteh&#039;s patterns with some comments&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in cyan, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternDeviceOn=254;0;0;gb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in yellow, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryCharging=50;3;0;rg;9d804001427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in white, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryFull=40;3;0;rgb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
White, bright flashing (must be enabled in &#039;LEDPatterns=&#039; ?):&lt;br /&gt;
 PatternExample=42;1;30;rgb;9d8040007f007f0040ff42000000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Step by step instructions ===&lt;br /&gt;
{{ambox&lt;br /&gt;
|type=notice&lt;br /&gt;
|text=There&#039;s a command &lt;br /&gt;
IroN900:~# /usr/bin/mceledpattern --help&lt;br /&gt;
  Usage:&lt;br /&gt;
  mceledpattern add[_vibra] &amp;lt;pattern_name&amp;gt; &amp;lt;pattern&amp;gt;&lt;br /&gt;
  mceledpattern remove[_vibra] &amp;lt;pattern_name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  To replace existing pattern use add, to restore replaced pattern back to previous value use remove&lt;br /&gt;
Please check if it&#039;s default or came with one of my additional packages}}&lt;br /&gt;
* Open terminal&lt;br /&gt;
* Gain [[root access]]&lt;br /&gt;
* Make a backup (for your own convenience) from original mce.ini -file, for example:&amp;lt;pre&amp;gt;cp /etc/mce/mce.ini /etc/mce/mce.ini_old&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Open &amp;lt;code&amp;gt;/etc/mce/mce.ini&amp;lt;/code&amp;gt; with a text editor (nano, vim, leafpad...)&lt;br /&gt;
* Search for a line:&amp;lt;pre&amp;gt;[LEDPatternLystiRX51]&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Make your changes to the lines below&lt;br /&gt;
* Save&lt;br /&gt;
* Restart mce -process. Either reboot or type in terminal:&amp;lt;pre&amp;gt;initctl stop mce; sleep 2; initctl start mce&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note: restarting mce several times in 2 minutes will cause the system to think there is a problem with mce, and so won&#039;t start it. The initctl program will inform you of this. When it does, simply wait a while before trying again.&lt;br /&gt;
&lt;br /&gt;
Alternatively, mce is started using [[dsmetool]] which monitors and reboots the device on failure.&lt;br /&gt;
This monitoring can be adjusted for more convenient hacking.&lt;br /&gt;
&lt;br /&gt;
/etc/event.d/mce&lt;br /&gt;
&lt;br /&gt;
*         /usr/sbin/dsmetool -n -1 -t &amp;quot;/sbin/mce --force-syslog&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Replacing -t (start and restart) with -o (start once) eliminates this monitoring.&lt;br /&gt;
&lt;br /&gt;
Please be aware that errors in editing these files could cause a reboot loop, which could require a reflash to stop.&lt;br /&gt;
&lt;br /&gt;
=== Low Level ===&lt;br /&gt;
&#039;&#039;&#039;this section should get merged with [[N900_Hardware_LED]] !&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The N8x0 had a LP5521&amp;lt;ref name=&amp;quot;lp5521-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5521.html&amp;lt;/ref&amp;gt;  &amp;lt;ref name=&amp;quot;lp5521-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/i2c/chips/lp5521.c&amp;lt;/ref&amp;gt; programmable three channel controller LED Driver which handles the leds.&lt;br /&gt;
The N900 has a LP5523 &amp;lt;ref name=&amp;quot;lp5523-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5523.html&amp;lt;/ref&amp;gt; &amp;lt;ref name=&amp;quot;leds-lp5523-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/leds/leds-lp5523.c&amp;lt;/ref&amp;gt;, which has 3 engines like LP5521 but can drive 9 LEDs via a multiplexer. Actually the multiplexer is between the engine (CPU) and the 9 PWM blocks for the 9 LED outputs - each of those 9 PWM blocks has its own accessable registers for current and brightness, and they are exposed to sysfs. This chip also has double the RAM size for &#039;programs&#039;, plus 2 per-machine and one global register variable and a true set of conditional branch and arithmetic commands. &lt;br /&gt;
&lt;br /&gt;
Alas the LP5523 driver doesn&#039;t support any of those advanced features of LP5523, and uses one of those  engines for a kbd backlight ramp-up/down.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;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.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See [[N900_Hardware_LED]] for hardware programming details.&lt;br /&gt;
&lt;br /&gt;
** engine1_leds is in the form &amp;quot;0000rgb00&amp;quot; (9 digits, &amp;quot;1&amp;quot; or &amp;quot;0&amp;quot;), where rgb control which leds should participate. The 6 &amp;quot;0&amp;quot; in the above pattern correspond to the 6 kbd white leds controlled by mce via engine3, so readout of engine3_leds gives 111100011 ;-)&lt;br /&gt;
** engine1_load accepts a string as specified above (e.g. 9d804000427f0d7f7f007f0042000000). Though LP5523 has an absolute storage of 96 steps a 16bits, which can dynamically partitioned between the three engines, the driver is retarded and limits this to a fixed 16 words a 16bit per engine (&amp;lt;s&amp;gt;ToDo: check if driver supports &amp;gt;16 instructions / machine&amp;lt;/s&amp;gt; no it doesn&#039;t :-/)&lt;br /&gt;
After that, when the state is changed to &amp;quot;run&amp;quot;, the program will be run by the controller. &lt;br /&gt;
&lt;br /&gt;
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]/&#039;&#039;&#039;led_current&#039;&#039;&#039; under the same directory. &#039;&#039;&#039;Don&#039;t mess with&#039;&#039;&#039; the default settings here that come with driver init, they are suitable and changing to higher values may and for certain values &#039;&#039;&#039;will kill your LEDS&#039;&#039;&#039;!.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Also see [[N900_Hardware_LED]]! &lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:N900 Hardware]]&lt;br /&gt;
[[Category:Power users]]&lt;/div&gt;</summary>
		<author><name>90.180.214.199</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14056</id>
		<title>LED patterns</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=LED_patterns&amp;diff=14056"/>
		<updated>2014-01-06T13:33:25Z</updated>

		<summary type="html">&lt;p&gt;90.180.214.199: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== N800 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N800|N800]] has a single-colour (blue) LED behind the dpad.&lt;br /&gt;
&lt;br /&gt;
== N810 ==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N810|N810]] has an RGB LED.&lt;br /&gt;
&lt;br /&gt;
== N900 ==&lt;br /&gt;
&lt;br /&gt;
=== File Location ===&lt;br /&gt;
&lt;br /&gt;
The software on the device that controls the LED colors is [[N900 Software MCE|MCE]].&lt;br /&gt;
&lt;br /&gt;
The file defining patterns can be found in&lt;br /&gt;
 /etc/mce/mce.ini&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;mce.ini&amp;lt;/code&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Pattern Format ===&lt;br /&gt;
&lt;br /&gt;
The patterns are broken down as follows:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(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&#039;t support pattern&lt;br /&gt;
definitions for engine3. mce is closed source and thus this can&#039;t be fixed in any reasonable way. If mce were open, an alternative compatible format was possible:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternName=Priority;ScreenOn;Timeout;LEDsToMap;Engine1Pattern;Engine2Pattern;Engine3Pattern&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where LEDsToMap was something like &amp;quot;000012300&amp;quot; to map the particular LED to either none, or Engine1..3 respectively. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==== Priority ====&lt;br /&gt;
&lt;br /&gt;
0-255, 0 is highest, 255 is lowest.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== ScreenOn ====&lt;br /&gt;
&lt;br /&gt;
* 0: only show pattern when the display is off&lt;br /&gt;
* 1: show pattern even when the display is on&lt;br /&gt;
* 2: only show pattern when the display is off, including acting dead&lt;br /&gt;
* 3: show pattern even when the display is on, including acting dead&lt;br /&gt;
* 4: only show pattern if the display is off, or if in acting dead&lt;br /&gt;
* 5: always show pattern, even if LED disabled&lt;br /&gt;
&lt;br /&gt;
==== TimeOut ====&lt;br /&gt;
&lt;br /&gt;
This is the time-out of the LED pattern in seconds. 0 for infinite, i.e. until the notification is dismissed.&lt;br /&gt;
&lt;br /&gt;
If this is set to 20, the pattern will display for 20 seconds, and then stop.&lt;br /&gt;
&lt;br /&gt;
==== LEDsToMap ====&lt;br /&gt;
&lt;br /&gt;
There are two engines that can be used to make custom LED patterns.&amp;lt;ref name=&amp;quot;engines&amp;quot;&amp;gt;Actually there are three, but the third engine is used exclusively for the keyboard LED.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
r, g, or b maps the corresponding colour channel to Engine 1.&lt;br /&gt;
&lt;br /&gt;
R, G, or B maps the corresponding colour channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;quot;rG&amp;quot; maps the red channel to Engine 1, and the green channel to Engine 2.&lt;br /&gt;
&lt;br /&gt;
You should avoid mapping the same channel to both engines, for example &amp;quot;rR&amp;quot;, &amp;quot;gG&amp;quot; or &amp;quot;bB&amp;quot; - it&#039;s not supported by the hardware, makes no sense anyway, and therefore probably never has been tested.&lt;br /&gt;
&lt;br /&gt;
==== Engine Pattern ====&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Lysti Format Engine Patterns and Commands ===&lt;br /&gt;
&lt;br /&gt;
The LED patterns are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d8040007f007f0040ff7f007f000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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)&lt;br /&gt;
:&amp;lt;tt&amp;gt;9d80 4000 7f00 7f00 40ff 7f00 7f00 0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 9d80 - Refresh Engine Multiplexer ====&lt;br /&gt;
&lt;br /&gt;
This is to be used as the first command of every pattern. If this is excluded from the pattern, the led won&#039;t flash. (actually this command loads the first [and only] entry of a predefined [by kernel driver] multiplexer table in chip&#039;s RAM to the multiplexer register)&lt;br /&gt;
&lt;br /&gt;
==== 40xx - Set channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Where xx are two hexadecimal digits, e.g. 00 (for a brightness of 0) or ff (for a brightness of 255).&lt;br /&gt;
&lt;br /&gt;
==== xxyy - Adjust channel brightness ====&lt;br /&gt;
&lt;br /&gt;
Increment or decrement the channel brightness over a period of time (xx) and a number of steps (yy).&lt;br /&gt;
&lt;br /&gt;
Where xx and yy are hexadecimal digits&lt;br /&gt;
&lt;br /&gt;
xx - Time (per step?)&lt;br /&gt;
&lt;br /&gt;
yy - Number of steps&lt;br /&gt;
&lt;br /&gt;
The following rules apply to these:&lt;br /&gt;
* If xx is even, the steps are increment steps and brightness will increase.&lt;br /&gt;
* If xx is odd, the steps are decrement steps and brightness will decrease.&lt;br /&gt;
* If xx is between 02 and 3f, a short step time is used (granularity 0.49ms)&lt;br /&gt;
* If xx is between 42 and 7f, a long step time is used (granularity 15.6ms)&lt;br /&gt;
* yy can be any value between 00 and ff (0 to 255)&lt;br /&gt;
* Pauses can be achieved by using 00 steps, e.g. 7f00 where, where the 7f is how long each step takes and 00 is how many increment steps to take.&lt;br /&gt;
&lt;br /&gt;
The mce.ini instructions (/etc/mce/mce.ini) also state that &lt;br /&gt;
:Two consecutive increment/decrement sequences are needed to cover the entire range from 0-255&lt;br /&gt;
However I believe this is a throwback to the older patterns, and the full range of 00 to ff is available in a single step for the number of steps, since whether these are increment or decrement steps are now handled through use of even or odd xx values.&lt;br /&gt;
&lt;br /&gt;
==== 0000 - Jump to start ====&lt;br /&gt;
&lt;br /&gt;
Jump to the start of the pattern for this channel. You will see this at the end of most repeating patterns.&lt;br /&gt;
&lt;br /&gt;
This command may not actually be needed to make the pattern repeat. If this is removed, the pattern will repeat anyway, although it&#039;s useful to have it there as an explicit command to repeat for clarity. If you wanted a pattern to run once and then terminate you would use the c000 command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== A000 .. BFFF - Branch (decrement and branch if non zero) ====&lt;br /&gt;
&lt;br /&gt;
101&amp;lt;llllll&amp;gt;&amp;lt;sssssss&amp;gt; : 16bit&lt;br /&gt;
&lt;br /&gt;
llllll : 6bit; Loop count, 0=infinite loop, or max 63 loops&lt;br /&gt;
&lt;br /&gt;
sssssss : 7 bit; Step number; Value to store to PC (0-95 actual progspace of LP5523 of 96 16bit commands. [Unclear if that&#039;s absolute address, or probably offset relative to start of program space assigned to the particular engine])&lt;br /&gt;
&lt;br /&gt;
You can build MUCH SMARTER loops with this! ;-D&lt;br /&gt;
&lt;br /&gt;
==== c000 - End pattern execution ====&lt;br /&gt;
&lt;br /&gt;
(also d000 = with hw INT; c800/d800 = with PC reset. INT might serve to signal end-of-pattern to main CPU -&amp;gt;*)&lt;br /&gt;
&lt;br /&gt;
The pattern is terminated without repeating. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;the following is about mce, not about how LP5523 chip works&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Sending and receiving engine triggers ====&lt;br /&gt;
&lt;br /&gt;
Further complexity in patterns can be added through use of triggers. This is especially useful if we want to synchronise the two engines in time, for example to wait until the LED has turned red before turning it immediately to green. Rather than waste time with steps doing nothing, we can simply wait for a trigger to be received from the other engine.&lt;br /&gt;
&lt;br /&gt;
The following pattern does exactly that:&lt;br /&gt;
:&amp;lt;tt&amp;gt;PatternTest=29;1;0;rG;9d80&#039;&#039;4000&#039;&#039;08ff&#039;&#039;&amp;lt;u&amp;gt;e004&amp;lt;/u&amp;gt;&#039;&#039;4000&#039;&#039;c000&#039;&#039;;9d80&#039;&#039;&amp;lt;u&amp;gt;e080&amp;lt;/u&amp;gt;&#039;&#039;40ff&#039;&#039;c000&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== e002, e004, e008 - Send engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e002 - Send trigger to engine 1&lt;br /&gt;
&lt;br /&gt;
e004 - Send trigger to engine 2&lt;br /&gt;
&lt;br /&gt;
e008 - Send trigger to engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
A signal is sent from the current engine to signal another engine.&lt;br /&gt;
&lt;br /&gt;
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&#039;t mess with LP5523 anymore - see below).&lt;br /&gt;
&lt;br /&gt;
===== e080, e100, e200 - Wait for engine trigger =====&lt;br /&gt;
&lt;br /&gt;
e080 - Wait for trigger from engine 1&lt;br /&gt;
&lt;br /&gt;
e100 - Wait for trigger from engine 2&lt;br /&gt;
&lt;br /&gt;
e200 - Wait for trigger from engine 3 (used by keyboard backlight)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Default LED Patterns for Nokia N900 ===&lt;br /&gt;
&lt;br /&gt;
 PatternError=0;5;0;r;9d8040007f007f0040ff7f007f000000;9d800000&lt;br /&gt;
 PatternDeviceOn=254;0;0;rgb;9d804000422043207f100000;9d800000&lt;br /&gt;
 PatternDeviceSoftOff=253;0;0;rg;9d804000423f433f7f100000;9d800000&lt;br /&gt;
 PatternPowerOn=9;3;0;rgb;9d80400042ff02ffc000;9d800000&lt;br /&gt;
 PatternPowerOff=10;3;0;rgb;9d80400001ff43ff7f007f00c000;9d800000&lt;br /&gt;
 PatternCommunicationCall=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationIM=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationSMS=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternCommonNotification=30;1;0;b;9d80400002ff03ff02ff03ff71080000;9d800000&lt;br /&gt;
 PatternWebcamActive=20;1;0;r;9d80400004ffc0000000;9d800000&lt;br /&gt;
 PatternBatteryCharging=50;4;0;rg;9d804000427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
 PatternBatteryFull=40;4;0;g;9d80407f0000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Community-Made Patterns ===&lt;br /&gt;
&#039;&#039;Please note that these patterns should each be on one line.&#039;&#039;&lt;br /&gt;
&#039;&#039;They can also be used for any notification by choosing the appropriately named &amp;quot;Pattern... for the start of the line.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A traffic-light battery charging pattern, courtesy of [http://talk.maemo.org/showthread.php?p=512430#post512430 blue_led]&lt;br /&gt;
 PatternBatteryCharging=50;4;0;Rg;9d80407f7f00e0047f0040007f007f007f00407f7f00e0047f007f000000;9d804000e080407fe0800000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=499305#post499305 mihapodb]. This pattern cuts quickly between blue and red.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8040ff7f00e00440007f000000;9d80e08040ff7f0040000000&lt;br /&gt;
&lt;br /&gt;
A police-siren style pattern, idea by [http://talk.maemo.org/showthread.php?p=540959#post540959 villo]. This pattern fades between red and blue.&lt;br /&gt;
 PatternCommunicationEmail=30;1;0;rB;9d8004ff05ffe004e1000000;9d80e08004ff05ffe0020000&lt;br /&gt;
&lt;br /&gt;
Cehteh&#039;s patterns with some comments&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in cyan, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternDeviceOn=254;0;0;gb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in yellow, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryCharging=50;3;0;rg;9d804001427f0d7f7f007f0042000000;9d800000&lt;br /&gt;
&lt;br /&gt;
Slow dark glowing in white, never goes fully off, so you can locate the device in the dark:&lt;br /&gt;
 PatternBatteryFull=40;3;0;rgb;9d804001620863087f007f007f007f007f007f007f007f007f007f007f000000;9d800000&lt;br /&gt;
&lt;br /&gt;
White, bright flashing (must be enabled in &#039;LEDPatterns=&#039; ?):&lt;br /&gt;
 PatternExample=42;1;30;rgb;9d8040007f007f0040ff42000000;9d800000&lt;br /&gt;
&lt;br /&gt;
=== Step by step instructions ===&lt;br /&gt;
{{ambox&lt;br /&gt;
|type=notice&lt;br /&gt;
|text=There&#039;s a command &lt;br /&gt;
IroN900:~# /usr/bin/mceledpattern --help&lt;br /&gt;
  Usage:&lt;br /&gt;
  mceledpattern add[_vibra] &amp;lt;pattern_name&amp;gt; &amp;lt;pattern&amp;gt;&lt;br /&gt;
  mceledpattern remove[_vibra] &amp;lt;pattern_name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  To replace existing pattern use add, to restore replaced pattern back to previous value use remove&lt;br /&gt;
Please check if it&#039;s default or came with one of my additional packages}}&lt;br /&gt;
* Open terminal&lt;br /&gt;
* Gain [[root access]]&lt;br /&gt;
* Make a backup (for your own convenience) from original mce.ini -file, for example:&amp;lt;pre&amp;gt;cp /etc/mce/mce.ini /etc/mce/mce.ini_old&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Open &amp;lt;code&amp;gt;/etc/mce/mce.ini&amp;lt;/code&amp;gt; with a text editor (nano, vim, leafpad...)&lt;br /&gt;
* Search for a line:&amp;lt;pre&amp;gt;[LEDPatternLystiRX51]&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Make your changes to the lines below&lt;br /&gt;
* Save&lt;br /&gt;
* Restart mce -process. Either reboot or type in terminal:&amp;lt;pre&amp;gt;initctl stop mce; sleep 2; initctl start mce&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note: restarting mce several times in 2 minutes will cause the system to think there is a problem with mce, and so won&#039;t start it. The initctl program will inform you of this. When it does, simply wait a while before trying again.&lt;br /&gt;
&lt;br /&gt;
Alternatively, mce is started using [[dsmetool]] which monitors and reboots the device on failure.&lt;br /&gt;
This monitoring can be adjusted for more convenient hacking.&lt;br /&gt;
&lt;br /&gt;
/etc/event.d/mce&lt;br /&gt;
&lt;br /&gt;
*         /usr/sbin/dsmetool -n -1 -t &amp;quot;/sbin/mce --force-syslog&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Replacing -t (start and restart) with -o (start once) eliminates this monitoring.&lt;br /&gt;
&lt;br /&gt;
Please be aware that errors in editing these files could cause a reboot loop, which could require a reflash to stop.&lt;br /&gt;
&lt;br /&gt;
=== Low Level ===&lt;br /&gt;
&#039;&#039;&#039;this section should get merged with [[N900_Hardware_LED]] !&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The N8x0 had a LP5521&amp;lt;ref name=&amp;quot;lp5521-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5521.html&amp;lt;/ref&amp;gt;  &amp;lt;ref name=&amp;quot;lp5521-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/i2c/chips/lp5521.c&amp;lt;/ref&amp;gt; programmable three channel controller LED Driver which handles the leds.&lt;br /&gt;
The N900 has a LP5523 &amp;lt;ref name=&amp;quot;lp5523-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5523.html&amp;lt;/ref&amp;gt; &amp;lt;ref name=&amp;quot;leds-lp5523-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/leds/leds-lp5523.c&amp;lt;/ref&amp;gt;, which has 3 engines like LP5521 but can drive 9 LEDs via a multiplexer. Actually the multiplexer is between the engine (CPU) and the 9 PWM blocks for the 9 LED outputs - each of those 9 PWM blocks has its own accessable registers for current and brightness, and they are exposed to sysfs. This chip also has double the RAM size for &#039;programs&#039;, plus 2 per-machine and one global register variable and a true set of conditional branch and arithmetic commands. &lt;br /&gt;
&lt;br /&gt;
Alas the LP5523 driver doesn&#039;t support any of those advanced features of LP5523, and even abuses one of those extremely smart engines for a stupid occasional kbd backlight ramp-up/down.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;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&#039;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. Sound rationale: while kbd bl ramp the &#039;&#039;CPU is awake anyway&#039;&#039;. No obvious benefit in offloading the task to a LP5532 engine [except from saving 50 lines of code in mce]!)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The controller can be programmed via &amp;quot;/sys/class/i2c-adapter/i2c-2/2-0032&amp;quot; (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 &amp;quot;stores&amp;quot; one of &amp;quot;run&amp;quot;, &amp;quot;load&amp;quot;, &amp;quot;disabled&amp;quot; (it seems that there is another mode &amp;quot;direct&amp;quot; but it doesn&#039;t work):&lt;br /&gt;
* run: The program runs&lt;br /&gt;
* disabled: The channel is disabled - not running&lt;br /&gt;
* load: In that state, there are two more files in that directory: &lt;br /&gt;
** engine1_leds is in the form &amp;quot;0000rgb00&amp;quot; (9 digits, &amp;quot;1&amp;quot; or &amp;quot;0&amp;quot;), where rgb control which leds should participate. The 6 &amp;quot;0&amp;quot; in the above pattern correspond to the 6 kbd white leds controlled by mce via engine3, so readout of engine3_leds gives 111100011 ;-)&lt;br /&gt;
** engine1_load accepts a string as specified above (e.g. 9d804000427f0d7f7f007f0042000000). Though LP5523 has an absolute storage of 96 steps a 16bits, which can dynamically partitioned between the three engines, the driver is retarded and limits this to a fixed 16 words a 16bit per engine (&amp;lt;s&amp;gt;ToDo: check if driver supports &amp;gt;16 instructions / machine&amp;lt;/s&amp;gt; no it doesn&#039;t :-/)&lt;br /&gt;
After that, when the state is changed to &amp;quot;run&amp;quot;, the program will be run by the controller. &lt;br /&gt;
&lt;br /&gt;
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]/&#039;&#039;&#039;led_current&#039;&#039;&#039; under the same directory. &#039;&#039;&#039;Don&#039;t mess with&#039;&#039;&#039; the default settings here that come with driver init, they are suitable and changing to higher values may and for certain values &#039;&#039;&#039;will kill your LEDS&#039;&#039;&#039;!.&lt;br /&gt;
&lt;br /&gt;
NOTE: There must be a delay (how much? The specs of LP5521 mentions it) between writes to sysfs files.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Also see [[N900_Hardware_LED]]! &lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:N900 Hardware]]&lt;br /&gt;
[[Category:Power users]]&lt;/div&gt;</summary>
		<author><name>90.180.214.199</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=N900_Hardware_LED&amp;diff=27762</id>
		<title>N900 Hardware LED</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=N900_Hardware_LED&amp;diff=27762"/>
		<updated>2014-01-06T13:32:49Z</updated>

		<summary type="html">&lt;p&gt;90.180.214.199: Yes, sysfs is stable, no, you do not need to wait between accessing /sys. Driver takes care of delays.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Hardware==&lt;br /&gt;
&lt;br /&gt;
The [[Nokia N900|N900]] has LP5523 &amp;lt;ref name=&amp;quot;lp5523-spec&amp;quot;&amp;gt;http://www.national.com/pf/LP/LP5523.html&amp;lt;/ref&amp;gt; &amp;lt;ref name=&amp;quot;leds-lp5523-driver&amp;quot;&amp;gt;http://mxr.maemo.org/fremantle/source/kernel/drivers/leds/leds-lp5523.c&amp;lt;/ref&amp;gt;, which has 3 engines like LP5521 (compatible though augmented instruction set) but can drive 9 LEDs via a multiplexer which maps each LED to one of the 3 engines. A LED also can be unassigned to any engine, in which case you can control it by writing to the corresponding brightness sysnode) which handles the keyboard and notification LED. (not the [[N900 Hardware Flash Torch|flash LEDs]] and red indicator light next to those, and also not the Infrared-LED used for CIR)&lt;br /&gt;
&lt;br /&gt;
The controller can be programmed via &amp;quot;/sys/class/i2c-adapter/i2c-2/2-0032&amp;quot;. In that directory there are three files corresponding to the three channels: &amp;lt;code&amp;gt;engine1_mode&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;engine2_mode&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;engine3_mode&amp;lt;/code&amp;gt;. Each file &amp;quot;stores&amp;quot; one of &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;load&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (it seems that there is another mode &amp;quot;direct&amp;quot; but it doesn&#039;t work)(direct mode requires explicit writes to PWM, current and multiplexing registers, which may not be supported in the code...):&lt;br /&gt;
* &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt;: The program runs&lt;br /&gt;
* &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt;: The channel is disabled - not running&lt;br /&gt;
* &amp;lt;code&amp;gt;load&amp;lt;/code&amp;gt;: In that state, there are two more files in that directory: &lt;br /&gt;
** engine1_LEDs is in the form &amp;quot;0000rgb00&amp;quot; (9 digits, &amp;quot;1&amp;quot; or &amp;quot;0&amp;quot;), where rgb control which LEDs should participate. The 6 &amp;quot;0&amp;quot; in the above pattern correspond to the 6 kbd white LEDs controlled by MCE via engine3, so readout of engine3_leds gives 111100011 ;-)&lt;br /&gt;
** 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. (Supports 32-96 steps per engine, dynamically-assigned, alas the lp5523.ko driver is braindamaged and doesn&#039;t support more than 16 instructions per engine)&lt;br /&gt;
After that, when the state is changed to &amp;quot;run&amp;quot;, the program will be ran by the controller. &lt;br /&gt;
&lt;br /&gt;
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. Default values from kernel module init are suitable.&lt;br /&gt;
&lt;br /&gt;
Despite the line&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#define LP5523_DEFAULT_CURRENT          50 /* microAmps */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
suggesting different, the units in there are 0.1 mA (100 µA per step is correct). So the driver init default &amp;quot;50&amp;quot; for all LEDs is 5 mA, and mce seems to set current to 0.2 mA (value 2 in the led_current sysnode) for B and G, and either to 0.2 mA or 0.8 mA for R. Probably settings as high as 100 for 10 mA are safe for the RGB LED, higher values might destroy the LED. (yes, correct, the RGB could be damaged from heat if set to more than 10 mA on all 3 LEDs)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;BEWARE!&lt;br /&gt;
 register addr 0x3B: GPO&lt;br /&gt;
 LP5523 has one General Purpose Output pin (GPO).&lt;br /&gt;
 Status of the pin can be controlled with this register. Also,&lt;br /&gt;
 &#039;&#039;&#039;INT pin can be configured to function as a GPO&#039;&#039;&#039; by setting&lt;br /&gt;
 the bit INT_CONF. When INT is configured to function as&lt;br /&gt;
 a GPO, &#039;&#039;&#039;output level is defined by the VDD voltage&#039;&#039;&#039;.&lt;br /&gt;
 3B — Bit [2] INT_CONF&lt;br /&gt;
 0 = INT pin is set to function as an interrupt pin (default).&lt;br /&gt;
 1 = INT pin is configured to function as a GPO.&lt;br /&gt;
&lt;br /&gt;
INT is routed directly to a SOC GPIO that is not designed to take voltages &amp;gt;1.8V ! So setting 0x3B:2 to 1 may fry your CPU&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Software==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
also see [[LED_patterns]] of which this page is a &amp;quot;fork&amp;quot; without cleaning the original page, so now there are two versions with almost identical but slightly complementary info&lt;br /&gt;
&lt;br /&gt;
Since beginning of 2012 a datasheet for LP5523 is available from TI: http://www.ti.com/product/lp5523 Direct link: http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=snvs550d&amp;amp;fileType=pdf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:N900 Hardware]]&lt;/div&gt;</summary>
		<author><name>90.180.214.199</name></author>
	</entry>
</feed>