Vibrator

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(topsort)
 
(5 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
== Vibrator ==
 
== Vibrator ==
  
This is in reference to the vibrator in the Neo Freerunner, however it is likely identical to the Neo 1973, as best I can tell.
+
This is in reference to the vibrator in the Neo FreeRunner, however it is likely identical to the Neo 1973, as best I can tell.
  
 
=== Controlling ===
 
=== Controlling ===
Line 7: Line 7:
 
   /sys/class/leds/neo1973\:vibrator/brightness
 
   /sys/class/leds/neo1973\:vibrator/brightness
 
When off, it will read 0.  Valid ranges appear to be 0-255, with 255 being the fastest.
 
When off, it will read 0.  Valid ranges appear to be 0-255, with 255 being the fastest.
 +
 +
=== Vibrate only on Ring ===
 +
 +
*OM2007.2
 +
The general means of configuring the ringtone is done in the file /etc/pulse/session:
 +
load-sample ringtone /usr/share/openmoko/sounds/ringtone_class.wav
 +
Without that file, the phone will be silent, but still continue to vibrate on ring. A convenient way is to gzip the ringtone file:
 +
gzip /usr/share/openmoko/sounds/ringtone_class.wav
 +
The pulseaudio daemon (or the phone) will need to be restarted:
 +
/etc/init.d/pulseaudio restart
  
 
=== Python Script For Playing Beats ===
 
=== Python Script For Playing Beats ===
Line 12: Line 22:
 
   
 
   
 
File format is human readable text, consisting of a simple sequence of integer pairs.  The first number in the pair representing the intensity of the vibration from 0 to 255.  The second number represents the duration in milliseconds to hold that intensity.  Any non digit characters in the file count as a separators between numbers, but are otherwise ignored.
 
File format is human readable text, consisting of a simple sequence of integer pairs.  The first number in the pair representing the intensity of the vibration from 0 to 255.  The second number represents the duration in milliseconds to hold that intensity.  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
 
  #!/usr/bin/python
Line 69: Line 81:
 
  250 600
 
  250 600
 
  0 400
 
  0 400
 +
 +
=== vibrating with pulses ===
 +
The way to turn it off is:
 +
 +
echo none > /sys/class/leds/neo1973:vibrator/trigger
 +
 +
For reference, the way to turn it on, is:
 +
 +
echo timer > /sys/class/leds/neo1973:vibrator/trigger
 +
echo 300 > /sys/class/leds/neo1973:vibrator/delay_on
 +
echo 700 > /sys/class/leds/neo1973:vibrator/delay_off
 
   
 
   
[[Category: Hardware]]
+
[[Category:Vibrator| ]]
[[Category: Vibrator]]
+

Latest revision as of 11:53, 19 July 2009

Contents

[edit] Vibrator

This is in reference to the vibrator in the Neo FreeRunner, however it is likely identical to the Neo 1973, as best I can tell.

[edit] Controlling

The vibrator is controlled through:

 /sys/class/leds/neo1973\:vibrator/brightness

When off, it will read 0. Valid ranges appear to be 0-255, with 255 being the fastest.

[edit] Vibrate only on Ring

  • OM2007.2

The general means of configuring the ringtone is done in the file /etc/pulse/session:

load-sample ringtone /usr/share/openmoko/sounds/ringtone_class.wav

Without that file, the phone will be silent, but still continue to vibrate on ring. A convenient way is to gzip the ringtone file:

gzip /usr/share/openmoko/sounds/ringtone_class.wav

The pulseaudio daemon (or the phone) will need to be restarted:

/etc/init.d/pulseaudio restart

[edit] Python Script For Playing Beats

Reads beats from a file and plays them on the openmoko vibrator.

File format is human readable text, consisting of a simple sequence of integer pairs. The first number in the pair representing the intensity of the vibration from 0 to 255. The second number represents the duration in milliseconds to hold that intensity. 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
"""Vibrator Beat Player

Usage: python beatplay.py [filename]
"""
import sys
import time
import re

def loadFromTextFile(filename):
    infile = open(filename)
    contents = infile.read()
    return re.findall("(\d+)\D*(\d+)", contents)

def playNote(frequency, duration):
    outfile.write(str(frequency) + "\n")
    time.sleep(float(duration) / 1000.0)

def playNotes(notes):
    for frequency, duration in notes:
        #print frequency + ", " + duration
        playNote(frequency, duration)

def playFile(filename):
    global outfile
    notes = loadFromTextFile(filename)
    outfile = open("/sys/class/leds/neo1973:vibrator/brightness", "w", 1)
    playNotes(notes)
    playNote(0, 0)
    outfile.close()

if __name__ == "__main__":
    playFile(sys.argv[1])

[edit] Example Beat

The following is an example "song" file that can be used to test the beat player.

125 400
0 200
250 600
0 400

125 400
0 200
250 600
0 400

125 400
0 200
250 600
0 400

125 400
0 200
250 600
0 400

[edit] vibrating with pulses

The way to turn it off is:

echo none > /sys/class/leds/neo1973:vibrator/trigger

For reference, the way to turn it on, is:

echo timer > /sys/class/leds/neo1973:vibrator/trigger
echo 300 > /sys/class/leds/neo1973:vibrator/delay_on
echo 700 > /sys/class/leds/neo1973:vibrator/delay_off
Personal tools

Vibrator

This is in reference to the vibrator in the Neo Freerunner, however it is likely identical to the Neo 1973, as best I can tell.

Controlling

The vibrator is controlled through:

 /sys/class/leds/neo1973\:vibrator/brightness

When off, it will read 0. Valid ranges appear to be 0-255, with 255 being the fastest.

Python Script For Playing Beats

Reads beats from a file and plays them on the openmoko vibrator.

File format is human readable text, consisting of a simple sequence of integer pairs. The first number in the pair representing the intensity of the vibration from 0 to 255. The second number represents the duration in milliseconds to hold that intensity. Any non digit characters in the file count as a separators between numbers, but are otherwise ignored.

#!/usr/bin/python
"""Vibrator Beat Player

Usage: python beatplay.py [filename]
"""
import sys
import time
import re

def loadFromTextFile(filename):
    infile = open(filename)
    contents = infile.read()
    return re.findall("(\d+)\D*(\d+)", contents)

def playNote(frequency, duration):
    outfile.write(str(frequency) + "\n")
    time.sleep(float(duration) / 1000.0)

def playNotes(notes):
    for frequency, duration in notes:
        #print frequency + ", " + duration
        playNote(frequency, duration)

def playFile(filename):
    global outfile
    notes = loadFromTextFile(filename)
    outfile = open("/sys/class/leds/neo1973:vibrator/brightness", "w", 1)
    playNotes(notes)
    playNote(0, 0)
    outfile.close()

if __name__ == "__main__":
    playFile(sys.argv[1])

Example Beat

The following is an example "song" file that can be used to test the beat player.

125 400
0 200
250 600
0 400

125 400
0 200
250 600
0 400

125 400
0 200
250 600
0 400

125 400
0 200
250 600
0 400