home *** CD-ROM | disk | FTP | other *** search
EPOC OPL Source | 1999-02-28 | 3.3 KB | 156 lines |
-
-
- rem PowerManagement Plugin for Start5 v0.2
- rem ©1998 A. Pemsel
-
- include "system.oxh"
- include "systinfo.oxh"
- include "date.oxh"
-
- const KPlugInUpdateRateNever%=0
- const KPlugInUpdateRateNormal%=1
- const KPlugInUpdateRateHigh%=2
- const KPlugInHeight%=22
-
- proc Power_Load:
- endp
-
- proc Power_Width%:
- return 22
- endp
-
- proc Power_UpdateRate%:
- return KPlugInUpdateRateNormal%
- endp
-
- proc Power_Draw:(wid%)
- Power_Update:(wid%)
- endp
-
- proc Power_Update:(wid%)
- local widb%,s%,cur&,total&,inuse&,exttime&,extpower&,dtime&
- s%=MainBatteryStatus&:
- dtime&=DTNow&:
- SIBatteryCurrent:(cur&, total&, inuse&, exttime&, extpower&, dtime&)
- if PlugInGlobal&(PlugInID%:("Power"))=16*extpower&+s%
- DTDeleteDateTime:(dtime&)
- return
- else
- PlugInGlobal&(PlugInID%:("Power"))=16*extpower&+s%
- endif
- s%=3-s%
- if extpower&
- s%=3
- endif
- widb%=gloadbit(MyDir$+"Plugins\Power.mbm",0,s%)
- guse wid%
- gat 1,1
- gcopy widb%,0,0,20,20,3
- gclose widb%
- DTDeleteDateTime:(dtime&)
- endp
-
- proc Power_Unload:
- endp
-
- proc Power_Tapped:
- local wid%,mainVolt&, mainMaxVolt&, backVolt&, backMaxVolt&
- local mainStat$(20),backStat$(20),s%,etr%
- local cur&, total&, inuse&, exttime&, extpower&, dtime&
- wid%=gcreate(70,30,500,180,0,$211)
- SetPointerCapture:(wid%,&01)
- gupdate off
- guse wid%
- gxborder 2,$94
- gfont 268435957
- ggmode 0
- gat 2,24
- gcolor $aa,$aa,$aa
- glineby 494,0
- gat 3,3
- gcolor $dd,$dd,$dd
- gfill 494,21,0
- gat 10,19
- gcolor 0,0,0
- gprint "PowerManagement PlugIn v1.1"
- gvisible on
-
- if evstat%<>-49 and ev&(1)=&408 and ev&(4)=0
- NextEvent:
- endif
-
- do
- ioyield
- if evstat%<>-46
- if evstat%<0 :raise evstat% :endif
- if (ev&(1) AND &400) = 0 rem Key
- break
- elseif ev&(1)=&408 rem Pen
- if ev&(4)=0
- break
- endif
- else
- if ev&(1)=&402 rem moved to background
- CapKeyHnd&=CaptureKey&:(ShowBarKey&,&2080,ShowBarMod&)
- break
- endif
- endif
- NextEvent:
- endif
- dtime&=DTNow&:
- SIBatteryVolts:(mainVolt&, mainMaxVolt&, backVolt&, backMaxVolt&)
- SIBatteryCurrent:(cur&, total&, inuse&, exttime&, extpower&, dtime&)
- s%=MainBatteryStatus&:
- if s%=0
- mainStat$="not present"
- elseif s%=1
- mainStat$="very low"
- elseif s%=2
- mainStat$="low"
- elseif s%=3
- mainStat$="good"
- endif
- s%=BackupBatteryStatus&:
- if s%=0
- backStat$="not present"
- elseif s%=1
- backStat$="very low"
- elseif s%=2
- backStat$="low"
- elseif s%=3
- backStat$="good"
- endif
- gat 10,30
- gBar:("Main Batteries "+mainStat$+" at "+num$(mainVolt&,5)+"mV",480,flt(mainVolt&-1.8)/(mainMaxVolt&-1.8)*100.0)
- gat 10,55
- gBar:("Backup Battery "+backStat$+" at "+num$(backVolt&,5)+"mV",480,flt(backVolt&-1.8)/(backMaxVolt&-1.8)*100.0)
- gat 10,95
- gprintb "Battery current: "+num$(cur&,4)+"mA",230,2,2
- gat 250,95
- gprintb "Total consumption: "+num$(total&/3600.0,7)+"mAH",234,2,2
- gat 10,110
- gprintb "Hours in use: "+num$(flt(inuse&/3600.0),5),230,2,2
- gat 10,160
- gprintb "Tap or press key to quit",480,3,2
- DTDeleteDateTime:(dtime&)
- gupdate
- pause 10
- until 0
- gclose wid%
- endp
-
- proc gBar:(caption$,w%,f)
- gcolor 0,0,0
- gfill w%,20,1
- gbox w%,20
- gmove 1,1
- gcolor $aa,$aa,$aa
- gfill flt((w%-2)/100.0*f+1.0),18,0
- gmove 9,14
- gfont 268435957
- gcolor 0,0,0
- gprint caption$
- endp
-
-
-