PDA

View Full Version : Programmatical Vibrate phone


Andrew Beery
10-25-2007, 04:17 AM
As I was researching a Problem entering FlightMode (still working on that one) I came up with the following which while unrelated may be of interest to some people... this allows you to flash the LED and vibrate your phone if supported by your device... I use it to provide tactile feedback to button presses in my SereneScreen Phone application... enjoy

#declare NLedGetDeviceInfo coredll NLedGetDeviceInfo 2 1
#declare NLedSetDevice coredll NLedSetDevice 2 1
#define NLED_SETTINGS_INFO_ID 2
#define NLED_SETTINGS_INFO ["LedNum", "OffOnBlink", "TotalCycleTime", "OnTime", "OffTime", "MetaCycleOn", "MetaCycleOff"]
proc SetLedStatus(wLed$, wStatus$)
struct(nsi$, NLED_SETTINGS_INFO);
nsi.LedNum$=wLed$;
nsi.OffOnBlink$=wStatus$;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &nsi$);
end;
proc pulse(milsec$)
try
SetLedStatus(1, 1); //Vibrate
SetLedStatus(0, 1) //Flash LED
sleep(milsec$); //100
SetLedStatus(1, 0); //extinguish
SetLedStatus(0, 0) //extinguish
except
end;
end;

NOTE: Replace [ and ] with curly brackets (use shift key)... for some reason I can't post those letters to the forum