<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TastyCode devblog &#187; LED</title>
	<atom:link href="http://blog.tastycode.pl/tag/led/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tastycode.pl</link>
	<description>Just another devblog...</description>
	<lastBuildDate>Fri, 04 Jun 2010 15:52:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using LED on N810 Tablets in Python</title>
		<link>http://blog.tastycode.pl/2009/11/21/using-led-on-n810-tablets-in-python/</link>
		<comments>http://blog.tastycode.pl/2009/11/21/using-led-on-n810-tablets-in-python/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 17:46:49 +0000</pubDate>
		<dc:creator>Informatic</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programowanie]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[Maemo]]></category>
		<category><![CDATA[N810]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.tastycode.pl/?p=45</guid>
		<description><![CDATA[I think that in Poland we don't have much NIT developers, and... Here we go - first post in English 
I was looking for an API in Python for manipulating color (and brightness ofc  ) of builtin LED on my N810. I drilled through some sites, and i found that FlipClock (which is written [...]]]></description>
			<content:encoded><![CDATA[<p>I think that in Poland we don't have much NIT developers, and... Here we go - first post in English <img src='http://blog.tastycode.pl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
I was looking for an API in Python for manipulating color (and brightness ofc <img src='http://blog.tastycode.pl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) of builtin LED on my N810. I drilled through some sites, and i found that FlipClock (which is written in Python) uses LED in some cases. I downloaded it, and found that you can set color of LED with these two simple functions.<br />
Manipulating LEDs rely on writing to virtual files in /sys/ directory.</p>
<pre class="brush: python;">import time

# This function changes color of LED
def setLED(r,g,b):
 val = &quot;%X:%X:%X&quot; % (r, g, b)
 f = open('/sys/devices/platform/i2c_omap.2/i2c-0/0-0032/color', 'w')
 f.write(val)
 f.close()
# This functions sets LED mode (&quot;run&quot; - default mode. &quot;direct&quot; - in this mode you can change color of LED)
def setLEDMode(mode):
 f = open('/sys/devices/platform/i2c_omap.2/i2c-0/0-0032/', 'w')
 f.write(mode)
 f.close()

# using:
# 1. First we need to set mode to &quot;direct&quot;
setLEDMode('direct')
# 2. Now set color of LED
setLED(255, 255, 255) # no, it won't be really white, blue led is too strong, so it will be like lightblue =)

# Let it sleep for a while
time.sleep(5)

# 3. Set everything to 0, so next time we won't see ugly &quot;blink&quot; of last color.
setLED(0, 0, 0)
# 4. Return to &quot;default mode&quot; (run)
setLEDMode('run')
</pre>
<p>Let's do some fireworks on your N810! <img src='http://blog.tastycode.pl/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
I'm really sure, that it should work also on N800 and family (770 have led? <img src='http://blog.tastycode.pl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>
<p>PS. I have just found out strange thing - when I close keyboard while LED is on it automagicaly turns off <img src='http://blog.tastycode.pl/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  I must try it <img src='http://blog.tastycode.pl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
PS2. And also when i lock keypad... It's not a big deal, when you are just blinking LED, but when you must turn it on for a long time, you can set color and sleep for 0.5sec in loop instead of setting color and waiting Xsec. <img src='http://blog.tastycode.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><b>Edit!</b><br />
Today I found out this post on some forum: http://forum.mobile-review.com/showpost.php?s=936a897dcf4ba22136a9fb1fc0904dd9&#038;p=2120483&#038;postcount=441<br />
So on N900 (Maemo 5) LED is controlled in similar way, expect thing, that path pattern is like this:<br />
<b>/sys/class/led/[some unique/unknown ID]/brightness</b><br />
I don't have N900, so i can't try it (and i don't know if my mother and GTranslate translated this post correctly <img src='http://blog.tastycode.pl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )<br />
I think that it should work <img src='http://blog.tastycode.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tastycode.pl/2009/11/21/using-led-on-n810-tablets-in-python/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
