📄 r08cnvlcdclk1.s
字号:
FAN MX,DisFlashFlag
jp nz,TimeSett0
ld y,TmpRTCHourL
calz FlashHour
TimeSett0:
call ChkTimer
ld a,Tmr15s
fan a,1111b
jp z,NewE
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 a,15
ld Tmr15s,a
ld X,RegKeyFlags
fan MX,KeyHoldFlag
jp nz,TimeSet2 ; br to check the hold time
AND MX,0fh-NewKeyFlag ; clr the key
; remark by hcy 03-11-29 11:44
; AND MX,0fh-DisFlashFlag ; clr the key
; LD a,0
; ld KeyHoldTm,a ; reset timer
; ld KeyCode,a ; clr the key code
call ClrKeyVar
HTimeSet:
call IncSetHour
; add by hcy 03-11-29 11:33
call SetTmr1s
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
ORG 300H
UTimeSet0:
ld a,15
ld Tmr15s,a
ld X,RegKeyFlags
AND MX,0fh-DisFlashFlag ; clr the key
; ld a,Key_Nil
; ld KeyCode,a ; clr key code
; ld KeyHoldTm,a
ld y,TmpRTCHourL
calz DspHour
calz DspColonOn
; ld a,Key_Nil
; ld KeyCode,a ; clr key code
; ld KeyHoldTm,a
call ClrKeyVar
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,Tmr15s
fan a,1111b
jp z,NewE
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 a,15
ld Tmr15s,a
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
; remark by hcy 03-11-29 11:44
; AND MX,0fh-DisFlashFlag ; clr the key
; LD a,0
; ld KeyHoldTm,a ; reset timer
; ld KeyCode,a ; clr the key code
call ClrKeyVar
HTimeSet0:
call IncSetMinute
; add by hcy 03-11-29 11:40
call SetTmr1s
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
MTimeSet0:
ld a,15
ld Tmr15s,a
call ClrKeyVar
calz ClrAmPm
; ORG 300H
TimeSet4:
calz FlashTimeFormat
call ChkTimer
ld a,Tmr15s
fan a,1111b
jp z,NewE
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 a,15
ld Tmr15s,a
ld X,RegKeyFlags
fan MX,KeyHoldFlag
jp nz,TimeSet4 ; br to check the hold time
AND MX,0fh-NewKeyFlag ; clr the key
call ClrKeyVar
ld x,RegKeyFlags
xor mx,TimeFormatFlag
calz DspTimeFormat
jp TimeSet4
TTimeSet0:
ld a,15
ld Tmr15s,a
ld x,TmpRTCMinuteL
ld y,RTCMinL
call Copy2Byte ;
ld x,RTCSec
call ClrByte
ld y,RTCHourL
calz DspHour
ld y,RTCMinL
calz DspMinute
ld X,RegKeyFlags
AND MX,0fh-NewKeyFlag ; clr the key
call ClrKeyVar
jp ProgStartLp
NewE:
ld x,RegKeyFlags
and mx,0fh-NewKeyFlag
call ClrKeyVar
jp ProgStart
;
; 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,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 :
;-------------------------------------
; 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:
;REMARK BY HCY FOR NEWKEYBOARD
; LD Y,KPort
LD Y,PPort
Send4BitLp0:
;remark by hcy for new keyboard
; FAN MY,0100b ; wait for D_Clk Hi
fan my,0001b ; 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:
; remark by hcy for new keyboard
; LD Y,KPort
LD Y,PPort
Send4BitLp2:
; remark by hcy for new keyboard
; FAN MY,0100b ; wait for D_Clk Lo
fan my,0001b
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 x,KPort
; cp mx,1111b
; jp nz,KeyS1 ; jmp if have key pressed
;KeyS2:
; LD X,RegKeyFlags
; AND MX, 0fh-KeyHoldFlag
;NotNewKey:
; RZF ; return with Z=0
; RET
;KeyS1:
; call Dly17ms
; ld x,KPort
; cp mx,1111b
; jp z,KeyS2
; ld b,mx
;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
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
; ld x,KPort
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
;-------------------------------------
; Cate : Display
; By : Hcy
; Func :
; Desc : ConvertLCDAdr
; I/P : b(display data)
; O/P : a
; Destroy: y,a
; Note :
ConvertLCDAdr:
ld a,04h
ld yh,a
ld a,xl
rcf
sbc a,03h
ld yl,a
ld a,b
ret
org 400h
;-------------------------------------
; Cate : Display
; By : Hcy
; Func : display the weight from the samsung
; Desc : DspWeight
; I/P : --
; O/P : --
; Destroy:
; Note :
DspWeight:
; call LCDClr
ld x,RxIcon1
ld a,mx
call GetIcons
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 DspDigitW
jp DspW2
DspW1:
push yh
push yl
call ConvertLCDAdr
calz DspDigit1W
DspW2:
pop yl
pop yh
ld b,YL
rcf
sbc b,3 ; get next digit
ld YL,b
inc x
ld a,DigitHBuf
call GetIcons
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,0111b
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
; org 400h
;-------------------------------------
; 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
SetTmr1s:
ld x,RegKeyFlags
or mx,DisFlashFlag ; disable flash
ld a,2
ld Tmr1s,a
ret
;-------------------------------------
; Cate : Common
; By : Hcy
; Func : copy 2-byte to other memory, (buffer1) --> (buffer2)
; Desc : Copy2Byte
; I/P : x(buffer 1 low address), y(buffer 2 low address)
; O/P :
; Destroy:
; Note :
Copy2Byte:
ld a,4
Copy0:
ld my,mx
inc x
inc y
add a,0fh ; dec a
jp nz,Copy0
ret
ChkCalibrateMode:
ld x,KPort
fan mx,IO_Key_On
jp z,Calib0 ; jmp if key_on is not pressed
ld B,Key_OnOff
fan mx,IO_Key_Off
jp nz,CalKey0 ; br if Key_off is preseed
;
ld b,Key_OnKg
; remark for new keyboard
; ld x,PPort
fan mx,IO_Key_Kg
jp z,Calib0 ; br if Key_Kg is not preseed
CalKey0:
call LCDClr
call TurnOnLCD
call Dly125ms
ld x,KPort
fan mx,IO_Key_On
jp nz,CalKey0 ; jmp if key_on is hold
LD Y,RPort
; 03-11-22 14:04 HCY
LD MY,0011b ; Power on, CLK_IN default high
call Dly125ms
call Dly125ms
call ReloadCommVar
ld x,SumNumRxNibble
ld mx,0dh
ld x,RxNibbleCnt
ld mx,0
ld x,ModeOpt
ld mx,CALIBRATEMODE
WaitSend0:
; remark for new keyboard
; ld x,KPort
; fan mx,0100b
; add for new keyboard
ld x,PPort
fan mx,0001b
jp nz,WaitSend0 ; BR IF D_CLK is high
LD KeyCode,B
call SendCalKey
; remark by hcy 03-11-26 10:22
; turn on all segment
call TurnOnLCD
call Dly250
call LCDClr
rcf
ret
Calib0:
scf
ret
TurnOnLCD:
LD x,40h
LCDClrf:
ldpx mx,0fh
cp xh,07h ; LCD ram from 90 to AFH
jp nz, LCDClrf
ret
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -