[Q] MortScript Backlight Status - Windows Mobile Software Development

How to use the mortscript to get the backlight status or sleep mode?
I had wrote a alarm script to announce the time with file.wav
I used the ToggleDisplay(ON) to wake up the phone to Start the program and ToggleDisplay(OFF) to end the program.
If the phone is at sleep mode, it work fine. but if the user is using the phone, my script also turn off the screen after alarm announce.. i wanna... to keep the original staus of phone while my alarm is running,, any idea to catch the status of backlight or sleep mode?

Here is some hint...courtesy xda_uc
Code:
# ReadBacklight TimeOut values and Disable Backlight TimeOut
############################################################
BattSuspendTimeout = RegRead ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","BattSuspendTimeout")
ACSuspendTimeout = RegRead ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","ACSuspendTimeout")
BatteryTimeout = RegRead ("HKCU", "ControlPanel\Backlight", "BatteryTimeout")
ACTimeout = RegRead ("HKCU", "ControlPanel\Backlight", "ACTimeout")
Brightness = RegRead ("HKCU", "ControlPanel\Backlight", "Brightness")
ACBrightness = RegRead ("HKCU", "ControlPanel\Backlight", "ACBrightness")
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","BattSuspendTimeout",0)
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","ACSuspendTimeout",0)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "BatteryTimeout", 0)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACTimeout", 0)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "Brightness", 10)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACBrightness", 10)

I don't want to Disable Backlight TimeOut , ijust want to get the status of screen on or off.
Thank Your Reply , I still have no idea about the registry which you point out.... Is it the value will be change at screen on or off status...

edwinho said:
I don't want to Disable Backlight TimeOut , ijust want to get the status of screen on or off.
Thank Your Reply , I still have no idea about the registry which you point out.... Is it the value will be change at screen on or off status...
Click to expand...
Click to collapse
Do you want to keep the script running all the time?
did you consider to use notifications?
it was long time I touched mort but you might get some ideas about reading backlight status and do notifications from "paplight" there is kaiser and rhodium versions.
as I remember it they didnt even turn light on, but not always get triggered too.
well thats all the trouble about different standby modes in winmo.
try it and come back with results.

Thank your suggestion!!!
Yes I want to keep the voice announcer at every 15 or 30 or 60 min something like that "Now is 11:30. AM" , My porgram is work through all the status of Phone, Sleeping or Using Status ... ..But have some bugs on phone screen on...I found no way or command can detect the screen on status with mortscript. I don't want to install another program to act as part of my script..... so i will try your suggestion... and find the way through notifications..
Thank!!

You first need to understand what registry does to your backlight...the answer you are looking for is in the code that i gave you. Good luck.

edwinho said:
How to use the mortscript to get the backlight status or sleep mode?
Click to expand...
Click to collapse
Simply impossible!
But you always can ask the MortScript professionals:
http://forum.xda-developers.com/showthread.php?t=289197

ok, with another thought I may have a solution. read below.
in an answer to:
ai6908 said:
You first need to understand what registry does to your backlight...the answer you are looking for is in the code that i gave you. Good luck.
Click to expand...
Click to collapse
i see you want to be helpfull, but actually those reg values you posted will not help him at all with what he need.
they read timeout values, not status. there might, and probably is a value in registry which can be used to detect standby thought.
I guess you can't avoid using notifications as you can't have the code running all the time. I would freeze uppon standby, or keep pda awake. but winmo standby is behaving strengly, it depends if you have flight mode, wifi, gprs on in standby...
safe way is to use notifications. even they sometimes didn't trigger on one of my winmo in flight mode.
first try if the light goes ON when running your script with notif. it might be that light would stay off.
if not... this is the trick..
make another script, which run nonstop and get started on system startup. just simple few lines:
while 1=1 {
- check the entry - "yourapp/lasttick" If lasttick older then one minute (60 sec) then write reg. "yourapp/standby=1" else "yourapp/standby=0"
- write reg. entry "yourapp/tick= actual time in unix format"
- sleep 60 ( or whatever, but this is needed otherwise you freeze your phone)
}
we assume this script will freeze on standby and will not "tick"
your main announce script then will check on your reg value you using in the first script.
you cant read standby value of it of course as it always would be 0 on start of main script until another tick of secondary script. you need to do both:
if time minus 60 > "yourapp/tick" OR "yourapp/standby = 0"
the second part would cover us in case tick would come right after start of notification and main script.
remember this would not cover all situations.. its just to show you what I meant to do.
runaway situation: user will press power to use the phone and notification will come during first 60 secs following it.

edwinho said:
ijust want to get the status of screen on or off.
Click to expand...
Click to collapse
This is an excerpt of a script I am using to turn off the screen, might help you to get an idea how to determine whether screen is off and/or on.
Code:
#
# adjust to your needs
Set STEP_WIDTH, "20"
Set SCREEN_OFF_EXE, "ScreenOff.exe"
Set FULLFILEPATHNAME_SCREEN_OFF_EXE, "\My Flash Disk\SystemProgs\" & SCREEN_OFF_EXE
Sleep 300
#
# initially set to false
turnOff = 0
#
black = RGB ( 0, 0, 0 )
# get screen dimensions
wdth = ScreenWidth()
hght = ScreenHeight()
#
# test each xth pixel per row and column
For w = 1 To (wdth - %STEP_WIDTH%) Step %STEP_WIDTH%
For h = 1 To (hght - %STEP_WIDTH%) Step %STEP_WIDTH%
#
# get pixel's color
clr = ColorAt( w, h )
#
# if pixel's color isn't black,
# set to true
If (clr <> black)
turnOff = 1
EndIf
Sleep 50
#
Next
Sleep 50
Next
#
#

check screen on/off status
Hi all,
i'm also interested in checking whether the screen is on or off and I had the same idea to check the color of pixels and "deduce" the screen status that way.
What I'm experiencing that ColorAt() function always returns the wallpaper color even if the phone is in stand by... and therefore that method seems not to work.
Don't know whether I do something wrong or if someone has experienced the same.
Waiting for news.
Thanks in advance

Related

BB 4.0 Backlight Issue

Okay first of all Tom thanks for a great ROM, when I get a paypal account donation twill be enroute to thou
Anyhow, this morning whilst my Orbit was sitting in my brodit powered cradle the backlight went off, I checked all the backlight settings for not switching off while on external power supply etc and all where unticked.
Basically what is happening is when connected to an external power source weither it be a USB Cable or External Power supply the backlight won't stay on.
I have done several soft resets to no avail, anyone got any idea's before I reinstall the rom, which I rather not do as I have it the way I want.
Thanks
Robbie
just to make sure:
you have disbaled the checkbox in the "external power" tab of ->settings/backlight?
seems to work fine for me (B&B4)
Yep tis already done, seen this before on 3.5 but upgraded to 4.0.
I hope a reinstall is not on the cards, anyone know the reg entries for the backlight or what they should be.
with always-on backlight in AC mode i have following registry settings:
Code:
HKEY_CURRENT_USER/ControlPanel/BackLight
ACTimeout = 0 (DWORD decimal)
ACTimeoutUnchecked = 60 (DWORD decimal)
to compare the battery seetings (checkbox enabled and set to 30s):
Code:
HKEY_CURRENT_USER/ControlPanel/BackLight
BatteryTimeout = 30 (DWORD decimal)
BatteryTimeoutUnchecked = 0 (DWORD decimal)
(there are other values)
hope that helps. maybe you have some other software installed that is interfering with these settings?
Cheers set AC's to 0 solved the problem thanks for the help guys

GPS and Suspend

I'm working on my code to keep GPS alive (today screen plugin, dunno if anyone ever posted it here but it's over at ppcgeeks). Turns out the qualcomm driver for the GPS in the Mogul crashes if the device goes to sleep when there is an open handle to the GPS device.
I did some quick hacking with SetPowerRequirement and it turns out the driver ignores power requirements.
At this point, my conclusions lead me to be pretty upset with HTC for once again passing ****ty drivers on to us. So I go to my last resort option, using RequestPowerNotifications. Spent a few hours debugging and getting the message loop working correctly, only to find out the PBT_TRANSITION message for suspension doesn't always come through before the device goes down.
Does anyone have any ideas on how to handle GPS and Sleep? I'd hate to do something to totally change the functioning of the device (like holding the whole device alive), but I can't really think of anything else to do.
Hi, did you already found solution ?
Hi Baffles, I haven't documented this yet, I will soon...
In GpsGate v2.6.0.308, they added an "WM GPS" option for the "Input" source. When this is done then GpsGate primes the GPS on the Titan. Also when used in conjunction with the "Close input when idle" option in the "Advanced" section of the "Input" tab in GpsGate, then GpsGate only turns on the GPS when a GPS application request GPS data from the GpsGate output port. This behavior seems to survive suspend/wakeup just fine too. Maybe you can study how they handle it as a clue for your application.
Hi
I am having exactly the same problem myself, especially with the TyTnII, have you had any luck?
Thanks
Dan
It took me a while, but on the end I got it to work...
Point is that you have to use Unattended mode
here is what you have to do:
1) call PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE)
this will tell to PowerManager that your application wants to do something before device go to sleep - will activate Unattended mode
2) SetPowerRequirement(L"GPS0:", D0, POWER_NAME|POWER_FORCE, NULL, NULL);
not sure if this is needed, but because we need GPS to stay alive it is ok to call it (if you use GPS over COM port, instead of GPS0: should be COMx
3) use RequestPowerNotifications(m_hMsgQueue, PBT_TRANSITION)
and create MessageQueue to get info when mode is changed... (look e.g. POWER_BROADCAST structure for more info).
4) you have to have one WaitForSingle/MultipleObjects with timeout, where you will wait for handle on MessageQueue you created for PBT_TRANSITION
5) when PBT_TRANSITION comes, and if device is changed in Unattended mode (simple string comparing POWER_BROADCAST.SystemPowerState=="unattended") you are responsible to keep device alive.. which mean you have to call periodically SystemIdleTimerReset() - if you do not do that, your device will go to sleep mode
do not call SystemIdleTimerReset() if you are not in unattended mode, because that will prevent device to switch off backlight and screen.
6) in case of timeout on WaitForXXObjects you can read GPS port and process your data
.. in general Unattended mode needs more power then sleep mode, but that is only way (at least on my HTC Artemis).
From documentation point of view simple call SetPowerRequirement(L"GPS0:", D0, POWER_NAME|POWER_FORCE, NULL, NULL) should be enough, but it is not so
I hope that will help you... my application works fine now and I'm happy
regards,
Igor
Thanks for that Igor, that all works for me as well. Tested on HTC P3300 and HTC P3600. I have also tried this on the HTC TyTnII but that deviceas always doesn't want to play nicely, as Baffles pointed out it does indeed seem to ignore calls to SetPowerRequirement.
If anyone has come across a way getting round the problems of the TyTnII, it would be great to hear it.
Thanks
Dan
Unfortunately, I'm not able to keep the GPS signal alive on my HTC P3600 (Orange SPV M700). Unattended mode works; a timer remains active and a simpel counters counts through. However, the GPS signal disappears after pressing the power button.
I call PowerPolicyNotify and SystemIdleTimerReset on each timer tick. Then, I read all data from the serial port (COM9). This works fine. After I press the power button, there is no more data to read from the serial port.
I also tried the code Igor mentiones about the power notification. I had to use platform invokes because I'm using the .NET Compact Framework. This works; I receive a signal and I can read a message from the message queue. However, I don't see the entire point of creating a message queue en registering for power notifications. Is there anything you need to do on the transition event besides calling SystemIdleTimerReset periodically?
Please help me out!
same problem on P3650
Hi there,
I have the same problem on the HTC Polaris (P3650). I want to run my application in unattended mode with an open gps connection.... and I haven'T found a solution yet.
Could anyone who managed to do that pleas post a code example for that.
Thanks a lot.
Patrick
negerzoen said:
Unfortunately, I'm not able to keep the GPS signal alive on my HTC P3600 (Orange SPV M700). Unattended mode works; a timer remains active and a simpel counters counts through. However, the GPS signal disappears after pressing the power button.
I call PowerPolicyNotify and SystemIdleTimerReset on each timer tick. Then, I read all data from the serial port (COM9). This works fine. After I press the power button, there is no more data to read from the serial port.
I also tried the code Igor mentiones about the power notification. I had to use platform invokes because I'm using the .NET Compact Framework. This works; I receive a signal and I can read a message from the message queue. However, I don't see the entire point of creating a message queue en registering for power notifications. Is there anything you need to do on the transition event besides calling SystemIdleTimerReset periodically?
Please help me out!
Click to expand...
Click to collapse
Hi, sorry for late answer....
In transition event you just need SystemIdleTimerReset.. basically that is what unattended mode is:
In Unattended mode.. you get transition event PBT_TRANSITION, where SystemPowerState is "unattended", and application can decide if will allow device to go to sleep or to call SystemIdleTimerReset...
I'm not sure how long "unattended" PowerState stays... but if you call often SysteIdleTimerReset, your app could work without MessageQueue (anyway I use message queue for monitoring power state, and if power is to low, I switch off GPS device).
here is my code snippet - it is not guaranteed that is compilable, because I took parts from my application.... but should be enough to get overview what you have to do to make it to work.
About managed code.. I didn't try it.. somehow for me is still easier to write C++ code
Code:
static const DWORD maxMsgQueueMsgSize = sizeof(POWER_BROADCAST_POWER_INFO) + sizeof(POWER_BROADCAST) + MAX_PATH;
// create stop event
HANDLE hStopEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
// create event for GPS change
HANDLE hDeviceStateChanged = CreateEvent(NULL, FALSE, FALSE, NULL);
// Create message queue
MSGQUEUEOPTIONS msgQueueOptions;
ZeroMemory(&msgQueueOptions, sizeof(msgQueueOptions));
msgQueueOptions.dwSize = sizeof(msgQueueOptions);
msgQueueOptions.dwFlags = MSGQUEUE_NOPRECOMMIT ;
msgQueueOptions.cbMaxMessage = maxMsgQueueMsgSize;
msgQueueOptions.bReadAccess = TRUE;
HANDLE hMsgQueue = ::CreateMsgQueue(NULL, &msgQueueOptions);
HANDLE hPowerNotification = ::RequestPowerNotifications(hMsgQueue, PBT_POWERINFOCHANGE | PBT_TRANSITION);
// opening GPS device
HANDLE hGPSDevice = ::GPSOpenDevice( 0, hDeviceStateChanged, NULL, 0);
bool bRun = true; // run loop
bool bHasSignal = false;
// change power requirement for GPS device and SD card
HANDLE hGPSPowerReq = ::SetPowerRequirement(L"GPS0:", D0, POWER_NAME|POWER_FORCE, NULL, NULL);
HANDLE hPowerReq = ::SetPowerRequirement(L"DSK1:", D0, POWER_NAME|POWER_FORCE, NULL, NULL);
// change to Unattended mode
::PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE);
// LOOOP
HANDLE events[3] = {hDeviceStateChanged, hStopEvent, hMsgQueue} ;
while (bRun)
{
DWORD dwWaitRes = ::WaitForMultipleObjects(3, events, FALSE, 1000 ); // read every 1. sec.
switch (dwWaitRes)
{
case WAIT_OBJECT_0:
// device status changed
{
GPS_DEVICE dev;
ZeroMemory(&dev, sizeof(dev));
dev.dwVersion = GPS_VERSION_1;
if (ERROR_SUCCESS == ::GPSGetDeviceState(&dev))
{
// do something...
}
}
break;
case WAIT_OBJECT_0+1:
// exit requested from exit event.. this is done from other thread by calling SetEvent(hExitEvent)
bRun = false;
break;
case WAIT_OBJECT_0+2:
// if we are on low power, stop monitoring
{
// there is a message in EventQueue.. read queue
BYTE buffer[maxMsgQueueMsgSize];
DWORD NumberOfBytesRead = 0;
ZeroMemory(buffer, maxMsgQueueMsgSize);
DWORD dwFlags;
if (::ReadMsgQueue(m_hMsgQueue, buffer, maxMsgQueueMsgSize,&NumberOfBytesRead, 0, &dwFlags ) && NumberOfBytesRead>=sizeof(POWER_BROADCAST))
{
POWER_BROADCAST* pPwrBrodcast = (POWER_BROADCAST*)(buffer);
switch(pPwrBrodcast->Message)
{
case PBT_POWERINFOCHANGE:
{
// if battery level is to low, finish with GPS reading
POWER_BROADCAST_POWER_INFO* pPowerInfo = (POWER_BROADCAST_POWER_INFO*)pPwrBrodcast->SystemPowerState;
if ((pPowerInfo->bBatteryFlag==2 || pPowerInfo->bBatteryFlag==4) && (pPowerInfo->bACLineStatus==0))
bRun = false;
}
break;
case PBT_TRANSITION:
{
std::wstring powerState = pPwrBrodcast->SystemPowerState;
// handle power states
if (powerState==L"resuming")
::PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE); // basicaly should never happen, because we do not allow to go in
if (powerState==L"unattended")
SystemIdleTimerReset();
}
break;
default:
ASSERT(!"Unknown message");
}
}
break;
case WAIT_TIMEOUT:
// new location
break;
}
// DO SOMETHING... e.g. Read position from GPS PORT
}
// ENDLOOP
::PowerPolicyNotify(PPN_UNATTENDEDMODE, FALSE); // Leave unattended mode
::ReleasePowerRequirement(hGPSPowerReq); // allow GPS device to go in sleep
::ReleasePowerRequirement(hPowerReq);
::GPSCloseDevice(hGPSDevice); // close GPS device
StopPowerNotifications(hPowerNotification);
CloseMsgQueue(hMsgQueue);
CloseHandle(hPowerNotification);
CloseHandle(hMsgQueue);
negerzoen said:
Unfortunately, I'm not able to keep the GPS signal alive on my HTC P3600 (Orange SPV M700). Unattended mode works; a timer remains active and a simpel counters counts through. However, the GPS signal disappears after pressing the power button.
I call PowerPolicyNotify and SystemIdleTimerReset on each timer tick. Then, I read all data from the serial port (COM9). This works fine. After I press the power button, there is no more data to read from the serial port.
I also tried the code Igor mentiones about the power notification. I had to use platform invokes because I'm using the .NET Compact Framework. This works; I receive a signal and I can read a message from the message queue. However, I don't see the entire point of creating a message queue en registering for power notifications. Is there anything you need to do on the transition event besides calling SystemIdleTimerReset periodically?
Please help me out!
Click to expand...
Click to collapse
Just one more thing (or two)...
you read from COM9.. maybe you should try to call
SetPowerRequirement(L"COM9:", D0, POWER_NAME|POWER_FORCE, NULL, NULL);
in case that you press Power button.. device is going immediately into Unattended mode, and there is chance to miss that mode in case that you do not have MessageQueue, or maybe there is some kind of Windows optimization that if no applications are registered for PBT_TRANSITION, Unattended mode is skipped and device going immediately into Sleep.
You wrote that "there are no more data to read from COM port".. are you sure that your code is running?
in case that your code is still running, then you prevented Sleep mode, and you have to find correct call to SetPowerRequrement. But; if your code is stopped, then your device is sleeping, and you have missed Unattended mode.
I hope that will help a bit....
for those of us that don't know anything about code, is this something that can be cabbed?
fredcatsmommy said:
for those of us that don't know anything about code, is this something that can be cabbed?
Click to expand...
Click to collapse
not really.. except that you want to have application which prevents your device to go into sleep mode...
Unfortunately I have not so much time to finish my application, but when that is finished.. I will post here link (and .cab) for sure...
Hi, been a member for a while and don't remember if i posted yet or not, I was coming up against this problem when developing a GPS application on a HTC TYTN2,
I wanted to constanty record the gps position, but not keep the screen on all the time,
I got around the sleep function of the device by not letting it into the suspend mode and keeping it in the unattended mode. this was done by calling:
PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE)
This put the lowest state the PPc could go into is the unattended mode but when it went into this mode the gps still turened off,
From reading an article on the code Project, : http://www.codeproject.com/KB/mobile/WiMoPower1.aspx i seen that different power levels ( i mean suspend etc here cant remember the poper term), turn off different applications and these are controlled via registry entries found here for the unatteneded mode :
HKEY_LOCAL_MACHINE\System\\CurrentControlSet\\Control\\Power\\State\\Unattended
the values that controls the GPS Intermediate Driver is "gpd0:" you change this to a 0 to keep GPS on in unatteneded mode, and 4 for it to be off in unattended mode,
I change it when my application starts and change it back when it finishes,
The GPS is kept alive using the "gpd0:" name, not "gps0:".
So, when your application starts call (C#):
public const int PPN_UNATTENDEDMODE = 0x0003;
public const int POWER_NAME = 0x00000001;
public const int POWER_FORCE = 0x00001000;
PowerPolicyNotify( PPN_UNATTENDEDMODE, 1 ); // For app.
IntPtr GpsPowerHandle = SetPowerRequirement( "gpd0:", PowerState.FULL /* 0 */, POWER_NAME | POWER_FORCE, IntPtr.Zero, 0 ); // For GPS.
When your application stops call:
ReleasePowerRequirement( GpsPowerHandle );
PowerPolicyNotify( PPN_UNATTENDEDMODE, 0 );
Nothing else is necessary. Works on my Polaris.
In the attached app, you need to set "MainForm.KeepGpsAlive = true"and "MainForm.LogGps = true" to see this logged in "\Application Data\GpsLoc".
(You can use the compiled exe but without keep alive and logging. It can be used to send the position through SMS and sync the time.)
George
This is an update of the code. The previous one was crashing sometimes because the GPS reported a (cached) solution but there were no satellites in the solution.
(The GPS stays alive so long as the application is running.)
it is possible that GPD0: works better then GPS0:
GPD is basically GPSID (GPS Intermediate Driver) - the one that use virtual COM port to connect to GPS driver and allow multiple applications to use GPS signal.
Also GPSOpenDevice open GPD not GPS, therefor it make sense to keep that driver alive, and it will (probably) keep real GPS driver ON.
Maybe that is a reason why my application didn't work 100% on my HTC diamond.... I'm going to try that
mligor said:
it is possible that GPD0: works better then GPS0:
Click to expand...
Click to collapse
CamerAware Buddy uses GPD0 and works 100% on FUZE.
I use D1(one) state to keep power-drain at lowest possible. I don't use SystemIdleTimerReset(), yet.
For lowest possible power drain, it's best to go with a SiRFIII (or MK) chip-based external bluetooth puck. The Qualcomm GPSone is a huge, inefficient, power-drainer compared to BT+SiRFIII.
I have tried and using GPSID works great.
basically to keep GPS signal alive there are two possibilities (depends what you need):
1) in case that you want to keep LCD ON
- inform OS that you need always D0 state for GPD0: (SetPowerRequirement)
- inform OS that your application needs Unattended mode (PowerPolicyNotify)
- register for PowerState notifications (RequestPowerNotifications)
- call SystemIdleTimerReset() often enough that LCD will not go OFF and/or device to go to sleep.
in this case when user Press Power button, your will get notification that device is going in Unattended mode, and you have to keep device alive with SystemIdleTimerReset() and to prevent never going in Sleep mode.
in this case user will be able to "switch off" device, but your application will continue running. You can also optimize application that in Unattended mode, nothing is updated on the screen, and less CPU to use (to save a bit battery)
2) in case that you do not want to keep LCD On all the time
- inform OS that you need always D0 state for GPD0: (SetPowerRequirement)
- inform OS that your application needs Unattended mode (PowerPolicyNotify)
- register for PowerState notifications (RequestPowerNotifications)
- but DO NOT call SystemIdleTimerReset() unless device is in Unattended mode
when user press Power button or device automatically switch off LCD after timeout, you will get notification about it and THEN call SystemIdleTimerReset to keep device alive. When device is again in ON mode, SystemIdleTimerReset should not be called.
This will ensure your application to work transparent, and it is perfect for some kind of GPS logger etc...
---
all this is very nice, and my GPS logger works perfect, BUT (arghhh!!) when I keep GPSID alive, power consumption is going to be very high (~150mA), and that is for my 900mAh battery a lot of power (max 6h)
What are your experience about power consumption of GPS? Can be that something else on my phone eat so much power or that is GPS chip?
GpsLoc has been updated into a full application.
See "Astrolabe - SMS your GPS position" at http://forum.xda-developers.com/showthread.php?p=4037827
Tests showed that in auto power saving mode the battery (of a HTC Polaris, 1350 mAh) would be depleted in about 16 hours, if no GPS signal is available; if there is a GPS signal, the autonomy should be greatly increased (an informal test indicates more than twice the autonomy). Without power saving, the battery would be depleted in about 6 hours.
(Using GPS0 didn't keep the GPS on when my PDA was in standby mode. GPD0 did.)

TP2 set to wake up automatically

Is there any way to set TP2 wake up automatically when a new message arrives? As far as I noticed, assuming that the phone is already in sleep mode, you simply hear the notification sound and essentially need to press POWER button in order to read the message.
Try edit the registry and reboot
Navigate to:
HKLM\Drivers\BuiltIn\RIL\
DisableSMSWakeUpEvent = 0 (default 1)
am i missing something? mine automatically wakes up for any type of message

Console Apps for Silent, Vibrate & Normal Profiles. Profile Switch utility.

Could not find this kind of simple app on xda so I wrote 3 quick apps. No screens or user interaction just execute them to set sound profile to Silent, Vibrate or Normal. SHould work with WM6.1 and up with or without Touchflo. You do need CF3.5
3/12/2010: Added PFSwitch utitlity which has the follwing switches:
Run with no switch:
Read current phone setting and move to the next profile. This toggles between Normal, Vibrate & Silent.
Run with 1 switch:
onoroff = toggle between on and silent only
onorvibe = toggle between on and vibrate only
normal = go to normal mode
vibe = go to vibrate mode
silent = go to silent mode
Run with 3 switches:
normal x y = go to normal and set system volume to x and ring volume to y (note x & y can be 0,20,40,60,80,100)
Run with 5 switches:
normal x y run runparms = same as 3 switches but when exiting run program 'run' and send params 'runparams'
Some examples:
PFSwitch silent = set phone to silent profile
PFSwitch normal 60 100 = set phone to normal sound with system sound at 60% and ring volume at 100%
PFSwitch normal 100 100 "\windows\iexplore.exe" "www.xda-develpoers.com" = set sound to normal both system and ring at 100% and when done launch internet explorer to go to xda website
PFSwitch silent 0 0 "\Windows\ctlpnl.exe" "cplmain.cpl,11,0" = set phone to silent and when exiting run Control Panel and open to tab 11 ident 0 (Menu Items I think)
Note: to run a program you must have the complete path since win mo does not allow relative paths.
PFSwitch V2.0
Added 9 new switches which are optional.
Switch 6 = ACTimeout
Switch 7 = ACTimeoutUnchecked
Switch 8 = BatteryTimeout
Switch 9 = BatteryTimeoutUnchecked
Switch 10 = Brightness
Switch 11 = ACSuspendTimeout
Switch 12 = BattSuspendTimeout
Switch 13 = ACSuspendTimeoutSave
Switch 14 = BattSuspendTimeoutSave
Example:
PFSwitch "" "" "" "" "" "" "" 30 0 3 "" "" "" "" would set backlight timeout on and at 30 seconds and brightness to 3
thanks
Thanks for this ebernazz2.
Been looking for ages for something just like this.
niccccccceee...
These sort of apps are always usefull. I just wish there was an app like this to toggle between USB and ActiveSync...
You placed 3 copies of the same file in each cab Instead you should have just placed the exe in a folder inside %CE1% ("Program Files" folder according with OS language) and the shortcut in %CE11% ("Start Menu/Programs" files folder according with OS language)
Would you be willing to make a version that toggles normal->vibe->mute each time the app is launched and with command line support (so we can create shortcuts with the command to select which profile to set)?
Sure I will make a single app that goes from normal to vibrate to silent if no command line argument is passed and if an argument is passed then it will go to that one.
Eric
Here you go. I don't have my phone with me to test this so please let me know if it does not work.
PFSwitch will toggle between normal, vibe and silent if run without any command line input. If you prefer to have a command line input to get to a specific profile then simply run it with one of the following switches:
normal
vibe
silent
Eric
Thank you! Already tested in my device and both toggle and command functions are working
I don;t understand what you mean by an app from USB to activesync. I don;t ever connect my phone to my PC so is tat what you are asking for?
Eric
Recent phones (like the Samsung Omina) have the ability to either connect to a PC by means of ActiveSync (RNDIS) or real USB connection (Mass Storage mode for memory cards or internal storage).
The advantage of the Mass Storage mode is that it's much faster and can be used in a Win PC without ActiveSync or other OSes.
I currently have a link in my today screen to a dirty MortScript I wrote (but most likely it's written in a device specific way and only works in the Omnia):
Code:
usb = RegRead ( "HKLM", "Drivers\USB\FunctionDrivers", "DefaultClientDriver" )
If ( usb eq "RNDIS" )
Run ( "\Windows\USBSetting.exe" )
Sleep ( 200 )
SendSpecial ( "Down" )
Sleep ( 50 )
SendSpecial ( "CR" )
Sleep ( 50 )
SendOK
ElseIf ( usb eq "Mass_Storage_Class" )
Run ( "\Windows\USBSetting.exe" )
Sleep ( 200 )
SendSpecial ( "Up" )
Sleep ( 50 )
SendSpecial ( "CR" )
Sleep ( 50 )
SendOK
EndIf
See my PM ans see if that helps. If not let me know.
Eric
I get you now. Let me see if it is just a registry update or do I have to call a function in core.dll.
Eric
I think that just changing the registry won't work (or at least I wasn't able to do a MortScript to do so... though I'm really not a coder).
frmariam said:
I think that just changing the registry won't work (or at least I wasn't able to do a MortScript to do so... though I'm really not a coder).
Click to expand...
Click to collapse
You are correct. The problem comes from the necessary events that winmo needs. In essence the app you used is loading the appropriate drivers that are specific to the hardware manufacturer. That needs to happen through ActivateDeviceEX function which is why simple setting of the registry won't help (it actually will assign the a new number in the registry HKLM\Drivers\active). I see no easy way around that coupled with the problem that the driver is manufacturer dependent.
Eric
Sounds like a big hassle for such an apparently small function...
I really hate how so much stuff in WinMo is device specific though it just seems like a side effect to the fact that Microsoft leaves all these things up to the device manufacturers... Maybe this will change in WinMo7 (not that it'll be available for my device anyway...). I really wish that the mobile OSes were in many aspects more like the PC OSes (like the fact you can install the OS if your device has the specs to run it rather than your manufacturer choosing if you are "allowed" to update it).
ebernazz2 said:
Could not find this kind of simple app on xda so I wrote 3 quick apps. No screens or user interaction just execute them to set sound profile to Silent, Vibrate or Normal. SHould work with WM6.1 and up with or without Touchflo. You do need CF3.5
Click to expand...
Click to collapse
Hi, I am using action screen to build a phone profile switcher: night, gps, car, outdoor, home, internet, mute...The code controls succesfully the system volume but I do not seem to update with success the ringer volume. Would it be possible to add a functionality to your app to define mode (mute, silent, normal) and at the sametime setup the volume for both ringer and system? Or could you help me understand if it is something that can be controlled writing to the registry? it is device specific? the scripts I found so far do not work in my polaris
Not sure what you mean.... I have an app that rotates from silent to vibrate to ring or you can set a switch to go directly to a profile. If you want to control sound or profile I can give you code but it would be Visual Studio code. What is Action Screen? IF you are asking if the system and ringer volume require 2 methods to set the answer is yes. You have to set both if you want both to change. Do you want to see the difference between setting the system sound vs ringer sound?
Eric
OK, actionscreen is an old htc program used to launch new sms, new mms and so on. It is just a popup menu (fullscreen) that gets away if not used after a couple of seconds. It is simply an app that has shortcuts written to the registry and launches them.
In my case I have not been able to start using visual studio, so I usually work with mortscript to launch scripts. In combination with any popupmenu like actionscreen I launch mosrtscript files that change the profile: eg my car profile will set bt discoverable, wifi off, full brightness, etc. my night profile with mute the system sound but keep the ringer volume in case someone calls for something important. My internet profile will open wifi, disable bt, etc. Using mortscipt I am able to change the icon so when I choose a profile the wifi icon gets red if activated and the profile icon gets the image of the active profile.
So basically I want an exe or mortscript file that can do two things at the same time: switch or set the mode (mute, silent, vibrate) and define the volume for the ringer and for the system. I do not know if it is more clear what I am looking for ?¿!!'¡'¿?!
thanks
I get you now.
I could write a .net app that takes 3 parameters. Lets say I call it SetSound2.
You would then use SetSound2 x y z where x would be mute, vibe or normal - and y would be the system volume level (20,40,60,80,100 percent) - and z would be the ringer volume (same numbers as y).
Would that help you?
Eric
ebernazz2 said:
I get you now.
I could write a .net app that takes 3 parameters. Lets say I call it SetSound2.
You would then use SetSound2 x y z where x would be mute, vibe or normal - and y would be the system volume level (20,40,60,80,100 percent) - and z would be the ringer volume (same numbers as y).
Would that help you?
Eric
Click to expand...
Click to collapse
That's just how I imagined it !!! Would you do that ??
Thanks Eric
Sure. I will write that tonight after work and post it for you as long as you test it out and let me know if is doing what you desire.
Eric

EvC++ and power management(running apps during standby)

Hi guys.
I am looking for a solution,that can enable me to use some time-dependent procedures in my software,while the device is in standby mode.
The typical example is the alarm clock.
I want to develop for me a chime application,that will play the sound each hour,even tough the device "sleeps".
Can I achieve it in Embedded Visual C++ and can anyone show me the way,how to?
Thanks.
I think you should check out CeRunAppAtTime and CeSetUserNotificationEx APIs. What about telling them to launch some sort of notification application (sending a message), trigger a named event ol play your sound?
When I wrote RockClock I used the SmartDeviceFramework (OpenNetCF).
It has RunAppAtTime to run the app and wake the device and also the LargeTimerInterval which tricks the phone into thinking there's an incomming call and wakes it up from almost any state.
The largetimerinterval timer also continues to run when the device is in standby whilst normal timers are suspended until the device wakes up from standby.
Used with SetSystemPowerState it all works well.
Well,thank you for your suggestion.
Can you please provide me some working example code?
There's this one that will power on the device completly (C#):
Code:
[DllImport("coredll.dll")]
protected extern static UInt32 SetSystemPowerState(String pwsSystemState, UInt32 StateFlags, UInt32 Options);
protected static readonly UInt32 POWER_STATE_ON = 0x00010000;
protected static readonly UInt32 POWER_FORCE = 0x00001000;
SetSystemPowerState(null, POWER_STATE_ON, POWER_FORCE);
How to get system power state names: http://peterfoot.net/HowToGetSystemPowerStateNameAndFlags.aspx
CeRunAppAtTime information @ Pinvoke: http://www.pinvoke.net/default.aspx/coredll.cerunappattime
SetDevicePower information @ Pinvoke: http://www.pinvoke.net/default.aspx/coredll/SetDevicePower.html
SetSystemPowerState info @ Pinvoke: http://www.pinvoke.net/default.aspx/coredll/SetSystemPowerState.html#
Info on waking the device using notifications: http://objectmix.com/dotnet/98395-waking-up-device-specific-time-vb-net.html# - using this you can play a sound at a specific time too
Manipulating the backlight (lcd): http://blog.opennetcf.com/ctacke/2009/06/17/PreventingTheBacklightFromTurningOffInCE60.aspx
If you need to convert C# to VB.NET or viceversa then this is a handy link:
http://blog.opennetcf.com/ctacke/2009/06/17/PreventingTheBacklightFromTurningOffInCE60.aspx
Hope you find these useful...let us know how you get on. I'm knew nothing of .NET before January and learnt a lot of things used in my alarm clock from
the pages listed above.
Hello.
I remembered about this question,but I found following:
Maybe I can use this function to power device on,but my software doesn't know,when that should be powered on.
I cannot use timer,because standby mode disables timer in my app,so I cannot monitor the time (each second).
Any solution for this please?

Categories

Resources