home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PSION / UTILS / SHELL3A / SRC.ZIP / OPL / BATTERY.OPL next >
Encoding:
Text File  |  1996-09-03  |  2.0 KB  |  81 lines

  1. Rem ****************************************
  2. Rem * Shell3a external command - battery.opl
  3. Rem * ╕ Nick Murray May 1996
  4. Rem *
  5. Rem * battery - display information on the
  6. Rem *           battery usage and status
  7. Rem ****************************************
  8. PROC battery%:(n%)
  9. LOCAL yr%,mo%,dy%,hr%,mn%,sc%,yrday%,buf$(24),i%,hours
  10. LOCAL Stat$(5),Insert&,Batt&,Extern&,Ticks&
  11.     ONERR ErrTrap::
  12.     CALL($228E,ADDR(Stat$))    Rem HwSupplyInfo system call
  13. Rem writes 22 bytes - Stat$ to Ticks&
  14. Rem for details see the Psionics "syscalls.3" file
  15.     i%=PEEKB(ADDR(Stat$))
  16.     PRINT "Main batteries:     ",
  17.     IF i%=1
  18.         PRINT "VERY LOW"
  19.     ELSEIF i%=2
  20.         PRINT "LOW"
  21.     ELSEIF i%=3
  22.         PRINT "GOOD"
  23.     ENDIF
  24.     PRINT "Backup battery:     ",
  25.     IF PEEKB(UADD(ADDR(Stat$),2))
  26.         PRINT "GOOD"
  27.     ELSE
  28.         PRINT "REPLACE"
  29.     ENDIF
  30.     PRINT "Batteries inserted: ",
  31.     SECSTODATE Insert&,yr%,mo%,dy%,hr%,mn%,sc%,yrday%
  32.     buf$=DAYNAME$(DOW(dy%,mo%,yr%))
  33.     buf$=buf$+" "+NUM$(dy%,-2)+" "+MONTH$(mo%)+" "+NUM$(yr%,-4)
  34.     buf$=buf$+" "+NUM$(hr%,-2)+":"+CHR$(mn%/10+48)+CHR$(mn%-(mn%/10)*10+48)
  35.     PRINT buf$
  36.     Batt&=Batt&/32    Rem convert to seconds
  37.     dy%=Batt&/86400
  38.     hours=dy%*24
  39.     Batt&=Batt&-dy%*86400
  40.     hr%=Batt&/3600
  41.     hours=hours+hr%
  42.     Batt&=Batt&-hr%*3600.0
  43.     mn%=Batt&/60.0
  44.     hours=hours+mn%/60.0
  45.     PRINT "Time on batteries:  ", dy%,"days",hr%;"h",mn%;"m"
  46.     Extern&=Extern&/32    Rem convert to seconds
  47.     dy%=Extern&/86400
  48.     Extern&=Extern&-dy%*86400
  49.     hr%=Extern&/3600
  50.     Extern&=Extern&-hr%*3600.0
  51.     mn%=Extern&/60.0
  52.     PRINT "Time on mains:      ", dy%,"days",hr%;"h",mn%;"m"
  53.     PRINT "Power used:         ",Ticks&/115200;"mAh"
  54.     IF hours
  55.         PRINT "Average:            ",NUM$(Ticks&/(115200*hours),3);"mA"
  56.     ENDIF
  57.     i%=PEEKW(UADD(ADDR(Stat$),4))
  58.     PRINT "Sound:",
  59.     IF i% AND $1
  60.         PRINT "DISABLED",
  61.     ELSE
  62.         PRINT "OK",
  63.     ENDIF
  64.     PRINT "   Flash:",
  65.     IF i% AND $2
  66.         PRINT "DISABLED",
  67.     ELSE
  68.         PRINT "OK",
  69.     ENDIF
  70.     PRINT "   Mains:",
  71.     IF PEEKB(UADD(ADDR(Stat$),3))
  72.         PRINT "ON"
  73.     ELSE
  74.         PRINT "OFF"
  75.     ENDIF
  76.     RETURN
  77. ErrTrap::
  78.     ONERR off
  79.     PRINT err$:(ERR)
  80. ENDP
  81.