📄 r08clk.s.bak
字号:
ld x,ModeOpt
fan mx,0fh
jp nz,GetK0 ; jmp if not clock mode
ld y,RPort ; set D_Out Hi after sending
or my,0011b ; turn on power to samsung clk_in default high
add mx,1
CALl LCDClr
LD X,AppFlags
AND MX,0fh-ReqToSendFlag ; clear the flag after sending
call Dly125ms
call Dly125ms
call ReloadCommVar
ld x,SumNumRxNibble
ld mx,0dh
ld x,RxNibbleCnt
ld mx,0
jp ProgStart ; to show Clock
GetK0:
LD SendData,B ;
LD X,AppFlags
OR MX,ReqToSendFlag
jp ProgStartLp
GetKey_ml:
LD X,RegKeyFlags
FAN MX,KeyHoldFlag
JP nz,ProgStartLp ; still key hold
AND MX,0fh-NewKeyFlag ; process the key & clr the flag
;
; process the ml key here after
; LD SendData,B ;
; LD X,AppFlags
; OR MX,ReqToSendFlag
; JP ProgStartLp
jp GetK0
;
; process the Off key here after
GetKey_Off:
; LD SendData,B ;
; LD X,AppFlags
; OR MX,ReqToSendFlag
ld x,ModeOpt
cp mx,CLOCKMODE
jp z,ProgStartLp
TurnOffPwr:
ld a,0
ld KeyCode,a
ld x,ModeOpt
ld mx,CLOCKMODE ; Reset modeOpt if not valid
CALl LCDClr
ld y,RPort ; set D_Out Hi after sending
and my,0010b ; turn off POWER_CONTROL
jp ProgStart
;
GetKey_Kg:
LD Y,ModeOpt
CP MY,CLOCKMODE
; JP nz,WeigthKey_Kg ; br if not clock mode
jp nz,GetKey_ml ; br if not clock mode
ld X,RegKeyFlags
fan MX,KeyHoldFlag
jp nz,GetKey_Kg0 ; br to check the hold time
AND MX,0fh-NewKeyFlag ; ignor the key
LD a,0
ld KeyHoldTm,a ; reset timer
jp ProgStartLp
;
; starting from here if the key hold time > 2 seconds
;
GetKey_Kg0:
ld a,KeyHoldTm
cp a,0fh ; tolerance -1/8 sec
jp nz,ProgStartLp ; br if Hold time < 2 seconds
ld x,RegKeyFlags
and mx,0fh-NewKeyFlag ; clear the flag
;
; Time setting mode from here on
ld a,Key_Nil
ld KeyCode,a ; clr key code
ld X,RegKeyFlags
AND MX,0fh-DisFlashFlag ; clr the key
ld x,RTCMinL
ld y,TmpRTCMinuteL
call Copy2Byte
calz DspColonOn
TimeSet:
ld X,RegKeyFlags
FAN MX,DisFlashFlag
jp nz,TimeSett0
ld y,TmpRTCHourL
calz FlashHour
TimeSett0:
call ChkTimer
LD A,KeyCode
CP A,Key_Kg
JP z,UTimeSet0 ;; jmp to setting minute
CP A,Key_ml
jp z,TimeSet1 ; jmp to setting increase hour
jp TimeSet
TimeSet1:
ld X,RegKeyFlags
; OR MX,DisFlashFlag
fan MX,KeyHoldFlag
jp nz,TimeSet2 ; br to check the hold time
AND MX,0fh-NewKeyFlag ; clr the key
AND MX,0fh-DisFlashFlag ; clr the key
LD a,0
ld KeyHoldTm,a ; reset timer
ld KeyCode,a ; clr the key code
HTimeSet:
call IncSetHour
jp TimeSet
TimeSet2:
;
; starting from here if the key hold time > 2 seconds
;
OR MX,DisFlashFlag
ld a,KeyHoldTm
cp a,0fh ; tolerance -1/8 sec
jp nz,TimeSet ; br if Hold time < 2 seconds
ld a,0dh
ld KeyHoldTm,a ;
jp HTimeSet
; call IncSetHour ;
; jp TimeSet
UTimeSet0:
ld X,RegKeyFlags
AND MX,0fh-DisFlashFlag ; clr the key
ld a,Key_Nil
ld KeyCode,a ; clr key code
ld y,TmpRTCHourL
calz DspHour
calz DspColonOn
TimeSet0:
; ld y,TmpRTCHourL
; calz DspHour
; calz DspColonOn
ld X,RegKeyFlags
FAN MX,DisFlashFlag
jp nz,MTime0
ld y,TmpRTCMinuteL
calz FlashMinute
MTime0:
call ChkTimer
LD A,KeyCode
CP A,Key_Kg
JP z,MTimeSet0 ;; jmp to setting minute
CP A,Key_ml
jp z,MTimeSet1 ; jmp to setting increase hour
jp TimeSet0
MTimeSet1:
ld X,RegKeyFlags
; OR MX,DisFlashFlag
fan MX,KeyHoldFlag
jp nz,MTimeSet2 ; br to check the hold time
AND MX,0fh-NewKeyFlag ; clr the key
AND MX,0fh-DisFlashFlag ; clr the key
LD a,0
ld KeyHoldTm,a ; reset timer
ld KeyCode,a ; clr the key code
HTimeSet0:
call IncSetMinute
jp TimeSet0
MTimeSet2:
;
; starting from here if the key hold time > 2 seconds
;
OR MX,DisFlashFlag
ld a,KeyHoldTm
cp a,0fh ; tolerance -1/8 sec
jp nz,TimeSet0 ; br if Hold time < 2 seconds
ld a,0dh
ld KeyHoldTm,a ;
jp HTimeSet0
; call IncSetMinute ;
; jp TimeSet0
MTimeSet0:
; ld X,RegKeyFlags
; and mx,0fh-TimeFormatFlag ; default is 12 hour
ld a,Key_Nil
ld KeyCode,a ; clr key code
ORG 300H
TimeSet4:
calz FlashTimeFormat
call ChkTimer
LD A,KeyCode
CP A,Key_Kg
JP z,TTimeSet0 ;; jmp to exit setting
CP A,Key_ml
jp z,TTimeSet1 ; jmp to toggle time format
jp TimeSet4
TTimeSet1:
ld X,RegKeyFlags
fan MX,KeyHoldFlag
jp nz,TimeSet4 ; br to check the hold time
AND MX,0fh-NewKeyFlag ; clr the key
ld a,0
ld KeyCode,a
ld x,RegKeyFlags
xor mx,TimeFormatFlag
calz DspTimeFormat
jp TimeSet4
; ORG 320H
TTimeSet0:
ld x,TmpRTCMinuteL
ld y,RTCMinL
call Copy2Byte ;
ld x,RTCSec
call ClrByte
ld y,RTCHourL
calz DspHour
ld y,RTCMinL
calz DspMinute
ld a,0
ld KeyHoldTm,a
ld X,RegKeyFlags
AND MX,0fh-NewKeyFlag ; clr the key
jp ProgStartLp
;
; ORG 300h
;WeigthKey_Kg:
; LD X,RegKeyFlags
; FAN MX,KeyHoldFlag
; JP nz,ProgStartLp ; still key hold
; AND MX,0fh-NewKeyFlag ; process the key & clr the flag
;;
;; process the Kg key here after
; LD SendData,B ;
; LD X,AppFlags
; OR MX,ReqToSendFlag
; JP ProgStartLp
; org 340h
;
;-------------------------------------
; Cate : Communication
; By : Kwan
; Func : SendKey
; Desc : Send the key code to Samsung
; I/P :
; O/P :
; Destroy:
; Note : 1. Wait for the D_Clk=low to place the
; data bit to D_Out
; 2. Wait for the D_Clk = hi again
; 3. Wait the D_Clk=low to place the data
; to D_Out until all 4 bit send
; 4. the sync nibble (0AH) will be sent
; first and followed by the keycode
; 5. syn-nibble (=A) will be sent first and
; followed by a 4 bit data --> total 8 bits
SendKey:
; call SendSynBit
LD A,0ah
CALL Send4Bit
; Check the time out if neccessary
LD X,RegKeyCode
LD A,MX
CALL Send4Bit
;
ld y,RPort ; set D_Out Hi after sending
; or my,0010b
or my,0011b
; Check the time out if neccessary
RET
;
;-------------------------------------
; Cate : communication
; By : Hcy
; Func : send 4 data bits (LSB first)
; Desc : Send4Bit
; I/P :
; O/P :
; Destroy:
; Note :
Send4Bit:
LD X,CommCount
LD MX,4 ; 4 bits
Send4BitLp1:
LD Y,KPort
Send4BitLp0:
FAN MY,0100b ; wait for D_Clk Hi
JP z,Send4BitLp0
;
ld y,RPort
RRC A
JP C,Send4BitHi
and my,0001b
jp Send4Bit0
Send4BitHi:
; OR my,0010b
or my,0011b
Send4Bit0:
LD Y,KPort
Send4BitLp2:
FAN MY,0100b ; wait for D_Clk Lo
JP nz,Send4BitLp2
Add mx,0fh ; dec commcount
JP nz,Send4BitLp1
;
xSend4Bit:
ret
;-------------------------------------
; Cate : Delay
; By : Hcy
; Func : delay 20 ms
; Desc : Dly20ms
; I/P : 32*17*0.03125 = 17ms
; O/P : --
; Destroy: y
; Note :
;Dly17ms:
; ld y,0
;Dlym1:
; inc y
; cp yh,02h
; jp nz,Dlym1
; ret
;;-------------------------------------
; Cate : KeyBoard
; By : Kwan
; Func : Key board scan, set NewKey flag if new key found
; set keyhold flag if the new key is still in-held
; Desc :
; I/P :
; O/P :
; Destroy:
; Note : After calling subr, the newkey flag should be
; checked.
; For MaB key, the Keyholdkey should be cleared before
; activating the corresponding function
; For MbB key, no need to check the KeyHoldFlag before
; activating the corr. function
; For MaH, the hold time must be checked to be 255 before
; activating the corr. function.
;
KeyScan:
ld b,Key_On
ld x,KPort
fan mx,IO_Key_On
jp z,KeyFound0 ; br if Key_on is preseed (=1)
call Dly17ms
fan mx,IO_Key_On
jp nz,KeyFound
KeyFound0:
ld b,Key_Off
fan mx,IO_Key_Off
jp z,KeyFound1 ; br if Key_off is preseed
call Dly17ms
fan mx,IO_Key_Off
jp nz,KeyFound
;
KeyFound1:
ld b,Key_Kg
ld x,PPort
fan mx,IO_Key_Kg
jp z,KeyFound2 ; br if Key_Kg is preseed
call Dly17ms
fan mx,IO_Key_Kg
jp nz,KeyFound
;
KeyFound2:
ld b,Key_ml
fan mx,IO_Key_ml
jp z,KeyFound3 ; br if Key_ml is preseed
call Dly17ms
fan mx,IO_Key_ml
jp nz,KeyFound
;
KeyFound3:
LD X,RegKeyFlags
AND MX, 0fh-KeyHoldFlag
NotNewKey:
RZF ; return with Z=0
RET
KeyFound:
LD X,RegKeyFlags
FAN MX,KeyHoldFlag
JP nz,NotNewKey ; br if not new Key
OR MX,NewKeyFlag+KeyHoldFlag ; set key flag
LD KeyCode,B
SZF ; return with Z-1 if new key MbB
RET
ConvertLCDAdr:
ld a,04h
ld yh,a
ld a,xl
rcf
sbc a,03h
ld yl,a
ld a,b
ret
;-------------------------------------
; Cate : Display
; By : Hcy
; Func : display the weight from the samsung
; Desc : DspWeight
; I/P : --
; O/P : --
; Destroy:
; Note :
DspWeight:
ld y,RxBuffer6
ld x,LCDMapMem0
ld b,4
DspW0:
ld a,my
push b
ld b,a
inc y
fan my,0fh
jp nz,DspW1
push yh
push yl
call ConvertLCDAdr
calz DspDigit
jp DspW2
DspW1:
push yh
push yl
call ConvertLCDAdr
calz DspDigit1
DspW2:
pop yl
pop yh
ld b,YL
rcf
sbc b,3 ; get next digit
ld YL,b
inc x
pop b
ADD b,0FH ;
jp nz,DspW0
ret
;-------------------------------------
; Cate : Display
; By : Hcy
; Func : dislay the fraction
; Desc : DspFraction
; I/P : RxSBuffer(0--9) --> nul,1/8,1/4,3/8,1/2,5/8,3/4,7/8,9/8,nul
; O/P : --
; Destroy:
; Note :
DspFraction:
ld y,RxSBuffer
cp my,0
jp z,DspF0
cp my,9
jp z,DspF0
ld a,my
add a,07h ; a+7
ld x,RxBuffer8
calz DspPattern1
;display /?(denominator)
ld y,RxBuffer8
ld a,my
ld x,LCDMapMem4
calz DspDenoNume ;
ld x,LCDMapMem4
ld y,049h
calz DspCopy ; (lcdmapmem4) --> (099h,09ah)
; display ?/(numerator)
ld y,RxBuffer9
cp my,05h
jp z,DspF1
ld x,LCDMapMem5
ld a,mx
or a,0011b
ld x,04bh
ld mx,a ; light' 6b,6c'
jp DspF2
DspF1:
ld x,LCDMapMem5
ld a,mx
or a,0010b
ld x,04bh
ld mx,a ; light'6b'
DspF2:
ld a,my
ld x,RxBuffer0 ; tempory memory
calz DspDenoNume ;
ld x,RxBuffer0
ld y,LCDMapMem4
ld a,mx
or a,my
ld x,049h
ld mx,a
ld x,RxBuffer1
inc y
ld a,mx
or a,my
ld x,04ah
ld mx,a
ret
DspF0:
; display nul/nul
ld x,049h
calz DspDigitSpa ; display ' '
ld x,LCDMapMem5
ld a,mx
and a,1100b ; clr '6b,6c'
ld x,04bh
ld mx,a
ret
;-------------------------------------
; Cate : Display
; By : Hcy
; Func : display the icons from the samsung
; Desc : DspIcons
; I/P : --
; O/P : --
; Destroy:
; Note :
DspIcons:
; am w kg lb
ld y,RxIcon0
ld a,my
and a,1110b
ld x,040h
ld mx,a ; - w kg lb
; oz g col p1
inc y
ld a,my
ld b,0
rrc a
ld x,LCDMapMem0H
ld y,042h
DspIc0:
push a
ld a,0
rlc a
or a,mx
ld my,a
inc x
inc x
inc y
inc y
add b,01h
cp b,05h
pop a
rrc a
jp nz,DspIc0
; ml fl - -
ld y,RxIcon2
ld a,my
and a,1100b
ld x,LCDMapMem5H
ld y,04ch
ld mx,a
ld my,a
; - - 0bc tare p3
ld x,LCDMapMem5
ld mx,0
ld y,RxIcon3
ld a,my
and a,1110b ; take away 'pm'
rrc a ; p3
push a
ld a,0
rrc a
ld mx,a
pop a
rrc a ; tare
push a
ld a,0
rrc a
rrc a
or mx,a
ld y,04bh
ld my,mx
pop a
rrc a ; ; 0bc
ld a,0
rlc a
rlc a
ld x,LCDMapMem5H
or a,mx
ld x,04ch
ld mx,a
ret
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -