Many thanks for sharing the package. I have further modified them to make the DAEMON running continuously. The scripts will now perform as follows:
Ask the user whether they want to activate this Auto Power On feature.
If yes
The device goes to Sleep when no external power applies; and
The DAEMON will keep searching until external power detected and
Wake up the device
p.s. to exit from the loop, I use the Power Button to turn off and restart the device.
Code:
# ON_AC_POWER_MENU.mscr
# Implemented on MortScript (
[Please Register or Login to download file] )
# 2009-12-07
# Karako
# GNU General Public License (GPL), Version 2, June 1991
ErrorLevel("off")
Local()
Set ON_AC_POWER_DAEMON, "\SDMMC\ON_AC_POWER\ON_AC_POWER_DAEMON.exe"
Set RUN_APP, "\SDMMC\igo8\igo8.exe"
Set LOOP_SECS, 11
options[1] = "Skip Auto On/Off"
options[2] = " "
options[3] = "Engage Auto On/Off"
Sleep 100
SetChoiceEntryFormat(20, 16, "Verdana")
Choice("Auto_On_Off_Option", \
"^NL^AC Power Auto On/Off^NL^Choose whether you want the GPS device to be^NL^automatically fired up when External Power is supplied^NL^^NL^", \
options)
Case( 1 )
# do nothing
#
Case( 2 )
# do nothing
#
Case( 3 )
# kill old notification(s) to prevent overlap
RemoveNotifications( %ON_AC_POWER_DAEMON% )
Sleep 100
# run application
Run( %RUN_APP% )
# Wait for APP finish loading
Sleep 45000
ReRun = TimeStamp() + %LOOP_SECS%
RunAt( ReRun, %ON_AC_POWER_DAEMON% )
Sleep 100
Exit
EndChoice
# kill old notification(s) to disable this function
RemoveNotifications( %ON_AC_POWER_DAEMON% )
Sleep 100
Run( %RUN_APP% )
Exit
# ON_AC_POWER_DAEMON.mscr
# Implemented on MortScript (
[Please Register or Login to download file] )
# based on the script from jwoegerbauer 09/04/2009
# GNU General Public License (GPL), Version 2, June 1991
# modified by Karako 2009-12-07
ErrorLevel("off")
Local()
# adjust to your needs (must > 10 seconds !!!!)
Set LOOP_SECS, 11
Set ON_AC_POWER_DAEMON, "\SDMMC\ON_AC_POWER\ON_AC_POWER_DAEMON.exe"
Set ON_AC_POWER_RESUME, "\SDMMC\ON_AC_POWER\ON_AC_POWER_RESUME.exe"
Set TURN_OFF, "\SDMMC\ON_AC_POWER\Sleep.exe"
Sleep 300
# kill old notification(s) to prevent overlap
RemoveNotifications( %ON_AC_POWER_DAEMON% )
Sleep 500
# check AC power line state
If( NOT ExternalPowered() )
# set new notification queue
ReRun = TimeStamp() + %LOOP_SECS%
RunAt( ReRun, %ON_AC_POWER_DAEMON% )
Sleep 100
# turn device again into standby
Run( %TURN_OFF% )
Else
# call resume script
RunWait( %ON_AC_POWER_RESUME% )
Sleep 1500
EndIf
Exit
# ON_AC_POWER_RESUME.mscr
# Implemented on MortScript (
[Please Register or Login to download file] )
# based on the script from jwoegerbauer 09/04/2009
# GNU General Public License (GPL), Version 2, June 1991
# modified by Karako 2009-12-07
ErrorLevel("off")
Local()
# adjust to your needs ( must > 10 secs)
Set LOOP_SECS, 11
Set ON_AC_POWER_DAEMON, "\SDMMC\ON_AC_POWER\ON_AC_POWER_DAEMON.exe"
Set PLAY_SOUND, 0
Set WAV_FILE, "\SDMMC\ON_AC_POWER\notify.wav"
Sleep 100
If (ExternalPowered())
If (%PLAY_SOUND% )
PlaySound( %WAV_FILE% )
EndIf
# set new notification queue
ReRun = TimeStamp() + %LOOP_SECS%
RunAt( ReRun, %ON_AC_POWER_DAEMON% )
Sleep 100
#
EndIf
Exit
[/spoiler]
However, I experienced the same problem that the display will turn on and off itself for about 1 to 2 seconds in every cycle (about 10 seconds in my settings) when external power is not attached.
Is it possible to do a Registry tweak to force the display off when the device just wakes up by the Daemon to check for external power please?
I am thinking Registry keys like
HKLM\SYSTEM\CurrentControlSet\Control\Power\State\ BacklightOff
or
HKLM\SYSTEM\CurrentControlSet\Control\Power\State\ ScreenOff
Since I seldom work with Registry, really appreciate for anybody's guidance and hints.