http://wiki.webos-internals.org/index.php?title=More_on_Leds&feed=atom&action=historyMore on Leds - Revision history2024-03-28T19:44:05ZRevision history for this page on the wikiMediaWiki 1.35.1http://wiki.webos-internals.org/index.php?title=More_on_Leds&diff=3238&oldid=prevHopspitfire at 05:59, 31 July 20092009-07-31T05:59:11Z<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 05:59, 31 July 2009</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>As mentioned in <del class="diffchange diffchange-inline">[</del>[[controlling-leds-from-the-shell|Controlling LEDs from the Shell<del class="diffchange diffchange-inline">]</del>]], there are some sysfs endpoints for controlling the LEDs. For a small example of a native program twiddling the LEDs using these endpoints, check out:</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>As mentioned in [[controlling-leds-from-the-shell|Controlling LEDs from the Shell]], there are some sysfs endpoints for controlling the LEDs. For a small example of a native program twiddling the LEDs using these endpoints, check out:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>http://www.jasonlebrun.info/files/leds_demo.gz</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>http://www.jasonlebrun.info/files/leds_demo.gz</div></td></tr>
</table>Hopspitfirehttp://wiki.webos-internals.org/index.php?title=More_on_Leds&diff=1445&oldid=prevHopspitfire: New page: As mentioned in Controlling LEDs from the Shell], there are some sysfs endpoints for controlling the LEDs. For a small example of a native program twid...2009-07-21T23:15:52Z<p>New page: As mentioned in [<a href="/index.php?title=Controlling-leds-from-the-shell&action=edit&redlink=1" class="new" title="Controlling-leds-from-the-shell (page does not exist)">Controlling LEDs from the Shell</a>], there are some sysfs endpoints for controlling the LEDs. For a small example of a native program twid...</p>
<p><b>New page</b></p><div>As mentioned in [[[controlling-leds-from-the-shell|Controlling LEDs from the Shell]]], there are some sysfs endpoints for controlling the LEDs. For a small example of a native program twiddling the LEDs using these endpoints, check out:<br />
<br />
http://www.jasonlebrun.info/files/leds_demo.gz<br />
<br />
Just copy the program to your Palm Pre, and then:<br />
<pre><nowiki><br />
gunzip leds_demo.gz<br />
chmod u+x leds_demo<br />
./leds_demo<br />
</nowiki></pre><br />
<br />
<br />
The LEDS are controlled by a low power special-purpose LED driver IC, the LP8501. It's controlled by the i2c bus. It allows preset programs to do things like fade-ins and fade-outs without requiring CPU intervention. I'm investigating it more, stay tuned.<br />
<br />
Since the source is short, I'll post it right here:<br />
<br />
<pre><nowiki><br />
#include "stdio.h"<br />
#include "math.h"<br />
<br />
int main(int argc, char** argv) {<br />
<br />
int i = 0, val = 0, phase1=120, phase2=240, s=1000;<br />
FILE *left_led, *right_led, *center_led; <br />
char buf[10];<br />
float PI = 3.14159;<br />
<br />
if(argc < 4) {<br />
puts("Usage: leds_demo delay(us) led2_offset led3_offset");<br />
puts("Phase is in degrees around a circle. 120, 240 for perfect spacing");<br />
puts("I.E.: leds_demo 1000 120 240");<br />
puts("This example will be run now");<br />
} else {<br />
s = atoi(argv[1]);<br />
phase1 = atoi(argv[2]);<br />
phase2 = atoi(argv[3]);<br />
}<br />
left_led = fopen("/sys/class/leds/core_navi_left/brightness", "w");<br />
right_led = fopen("/sys/class/leds/core_navi_right/brightness", "w");<br />
center_led = fopen("/sys/class/leds/core_navi_center/brightness", "w");<br />
while(1) {<br />
val = sin(i*2*PI/360.0)*32+32;<br />
sprintf(buf, "%d\n", val); <br />
fwrite(buf, strlen(buf), 1, left_led);<br />
rewind(left_led);<br />
<br />
val = sin((i+phase1)*2*PI/360.0)*32+32;<br />
sprintf(buf, "%d\n", val); <br />
fwrite(buf, strlen(buf), 1, center_led);<br />
rewind(right_led);<br />
<br />
val = sin((i+phase2)*2*PI/360.0)*32+32;<br />
sprintf(buf, "%d\n", val); <br />
fwrite(buf, strlen(buf), 1, right_led);<br />
rewind(center_led);<br />
<br />
i++;<br />
usleep(s);<br />
}<br />
<br />
<br />
}<br />
<br />
</nowiki></pre></div>Hopspitfire