;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; File Name : sciban.asm
; Purpose : SciCal Application Banner State Manager
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;DO NOT MODIFY THE FOLLOWING SUBROUTINE DEFINITION;;;;;;;;;;;;;;;;;
IF @DEF('SUBROUTINE')
UNDEF SUBROUTINE
ENDIF
DEFINE SUBROUTINE "'sciban'"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GLOBAL sciwaBannerStateManager
sciwaBannerStateManager:
;first, do the normal stuff
CAR coreCommonBannerStateHandler
;then, show battery level
;WristApp: BATTERY CHECK
;================================================================================
;
;by Philip Hamer (Modified to give graphical display by Raymond Allen)
;Version: 0.1
;
;Description:
;------------
;This WristApp prints out the voltage level of your watch.
;
;Source code:
;------------
; Turn on 1/4 HZ sampling
ld HL, #SVDReg
and [HL], #~bSVDON
or [HL], #bSVDSP
; We need to wait 16 clock cycles for reading of battery power
; 1 bus cycle = 2 clock cycles
; nop = 2 bus cycles = 4 clock cycles
nop
nop
nop
nop
; Mask out top 4 bits to get voltage level
ld A, [HL]
and A, #(bSVD0|bSVD1|bSVD2|bSVD3)
; Turn off 1/4 HZ sampling
and [HL], #~bSVDSP
;LD A,#5 ;FORCE BATTERY LEVEL !!!! REMOVE ME !!!!!!!!!!
; Check voltage and draw battery
LD H,#03Eh ;battery full line
;LD IX,#0FA02h ;starting address for display on Line2
LD IX,#0FA08h ;display on Line2
DrawBatteryBottom:
LD [IX],H
INC IX
LD [IX],H
INC IX
;there are 15 possible levels, but I'll just consider 4..8 (8=3.0V)
;3.0 (8) will show as full, 2.33 (4) will show empty
LD L,#3 ;level 5=2.50V
CheckBatteryLoop:
INC L
LD B,L
CP A,B
JR GT,DrawBattery
LD H,#022h ;battery empty line
DrawBattery:
LD B,#4 ;draw 4 of same thing
DrawBatteryLoop:
LD [IX],H
INC IX
DJR NZ,DrawBatteryLoop
CP L,#7
JR LT,CheckBatteryLoop
;done
DrawBatteryTop:
LD H,#03Eh ;battery full line
LD [IX],H
INC IX
LD [IX],H
INC IX
LD H,#01Ch ;battery top
LD [IX],H
INC IX
LD [IX],H
BanReturn:
RET ;all done