View source for FreeRunner/Buttons and LEDs
From Openmoko
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page:
Template used on this page:
Return to FreeRunner/Buttons and LEDs.
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page:
Template used on this page:
Return to FreeRunner/Buttons and LEDs.
This is the Software specification for the Openmoko Neo FreeRunner Button and LEDs.
In progress: This article or section documents one or more features whose implementation are in progress. |
/sys/devices/platform/gta02-led.0/leds/gta02-aux:red/ /sys/devices/platform/gta02-led.0/leds/gta02-power:blue/ /sys/devices/platform/gta02-led.0/leds/gta02-power:orange/
Those are all userspace directories for controlling the LEDs. echo 0 > brightness will turn the LED off. echo 1 > brightness will turn it on. trigger currently does nothing.
EVENT | red | behind AUX button |
HEARTBEAT | orange | behind POWER button |
WIRELESS / BLUETOOTH | blue | behind POWER button |
MIXING TWO LEDS | purple | behind POWER button if turning on the blue and the orang buttons together |
This is grouped by mode:
LEDs are very useful in broadcasting valuable basic status information to the user in a way that the user does not have to unlock the device, enable the screen or turning the screen saver off and subsequently search the screen for basic status information.
This is grouped by mode:
Same as ON, with the exception of
A C implementation of these rules has been done by smurfy - phil and is available at http://www.smurfy.de/files/neo/openmoko-led-v1.tar.gz
Reads beats from a file and blinks FreeRunners leds.
File format is human readable text, consisting of a simple sequence of integer quartet (4 numbers). The first number representing status of blue power-led, second means status of orange power-led and third means status of red aux-led. 0=OFF, 1=ON. (If blue=1 and orange=1 then power=lila. This has nothing to do with this python script or this file format.) The last number represents the duration in milliseconds to hold that situation of leds. Any non digit characters in the file count as a separators between numbers, but are otherwise ignored.
It requires packages python-core and python-re from opkg.
#!/usr/bin/python """Led Blinker Player Usage: python leds.py [filename] """ import sys import time import re def loadFromTextFile(filename): infile = open(filename) contents = infile.read() return re.findall("(\d+)\D*(\d+)\D*(\d+)\D*(\d+)", contents) def playNote(blue_value, orange_value, red_value, duration): blue.write(str(blue_value) + "\n") orange.write(str(orange_value) + "\n") red.write(str(red_value) + "\n") time.sleep(float(duration) / 1000.0) def playFile(filename): global blue, orange, red notes = loadFromTextFile(filename) blue = open("/sys/class/leds/gta02-power:blue/brightness", "w", 1) orange = open("/sys/class/leds/gta02-power:orange/brightness", "w", 1) red = open("/sys/class/leds/gta02-aux:red/brightness", "w", 1) for first,second,third, duration in notes: playNote(first,second,third,duration) playNote(0, 0, 0, 0) blue.close() orange.close() red.close() if __name__ == "__main__": playFile(sys.argv[1])
The following is an example "fireworks"-file that can be used to test the led blinker.
1 0 0 100 1 0 1 100 1 1 0 100 0 1 0 100 0 1 1 100 0 0 1 100 1 1 1 100 1 0 0 100 1 0 1 100 1 1 0 100 0 1 0 100 0 1 1 100 0 0 1 100 1 1 1 100 1 0 0 100 1 0 1 100 1 1 0 100 0 1 0 100 0 1 1 100 0 0 1 100 1 1 1 100
Use the blue and orange LED's under the power button to show battery power status. Install perl using "opkg install perl" to use this script. The script will indicate high battery with blue, medium battery by purple (blue + orange), and low battery by orange. Adjust values for your needs.
You can have it autostart by saving the script as /etc/init.d/lights.pl
then creating a shell script /etc/init.d/startlights.sh with just one line:
/etc/init.d/lights.pl &
and then create a symlink to it to auto start by running
ln -s /etc/init.d/startlights.sh /etc/rc5.d/S15startlights
lights.pl:
#!/usr/bin/perl my $high_thresh = 75; my $low_thresh = 30; while(1) { my $command = `apm`; if ($command =~ m/battery .*: (\d*)%/) { print("Value: " . $1 . "\n"); } if($1 < $low_thresh) { print("Low Battery\n"); $command = `echo 1 > /sys/devices/platform/gta02-led.0/leds/gta02-power:orange/brightness`; $command = `echo 0 > /sys/devices/platform/gta02-led.0/leds/gta02-power:blue/brightness`; } if($1 > $high_thresh) { print("High Battery\n"); $command = `echo 1 > /sys/devices/platform/gta02-led.0/leds/gta02-power:blue/brightness`; $command = `echo 0 > /sys/devices/platform/gta02-led.0/leds/gta02-power:orange/brightness`; } if(($1 <= $high_thresh) && ($1 >= $low_thresh)){ print("Mid Battery\n"); $command = `echo 1 > /sys/devices/platform/gta02-led.0/leds/gta02-power:blue/brightness`; $command = `echo 1 > /sys/devices/platform/gta02-led.0/leds/gta02-power:orange/brightness`; } sleep(15); }
-nvanfossen