Thread: OK ROM comes
View Single Post
Member: pEEf
at: 06:11 PM 06/17/2009
Originally Posted by 3l33t33n:
I've found some more info on the vibrate function, it is actually quite simple to implement, as soon as I get my pre (getting it on friday, woot!) I will implement the vibrate function into the messages/notifications as has been requested by many users.

to use the vibrate function you must include the "vibrate.js" file which can be found in '/usr/palm/applications/com.palm.app.deviceinfo/app/models/vibrate.js'

from there you can call Vibrate.vibrate() anywhere in the application. It can also take a 'length' argument which sets how long you want it to vibrate (default is 300 ms), so for example if you wanted it to vibrate for 500ms (1/2 sec) then you would call Vibrate.vibrate(500) or if you wanted it to vibrate for 5 seconds you would call Vibrate.vibrate(5000).

It's as simple as that! If you want to call the vibrate directly (through the mojo/luna sys mgr) you can look inside the Vibrate.vibrate function declaration for the method to call to initiate it directly through crotest.
I think this is a better way to do it:

[CODE] this.serviceRequest = new Mojo.Service.Request("palm://com.palm.vibrate", {
method: 'vibrate', parameters: { 'period': 0,'duration': 250 }
});
[/CODE]

This produces one quarter-second vibrate. (250ms)

You can use this to also make pulsed vibrates, setting period to 250 and duration to 2000 will make 4 short vibrates over a 2 second span. The Period param is a "no vibrate" period, so setting it to zero makes it continuous. Duration is the length of the cycle.

The crotest is some kind of a test mode I think, and not intended for normal use (so it may break in the future).