📄 01lcdclk.s
字号:
JP z,GetKey_ml
CP A,Key_Off
JP z,GetKey_Off
JP ProgStartLp
;
GetKey_On:
; for testing
LD X,RegKeyFlags
FAN MX,KeyHoldFlag
JP nz,ProgStartLp ; still key hold
AND MX,0fh-NewKeyFlag ; process the key & clr the flag
ld x,ModeOpt
fan mx,0fh
jp nz,GetK0 ; jmp if not clock mode
ld a,Tmr2s
fan a,1111b
jp nz,ProgStartLp
LD Y,RPort
; 03-11-22 14:04 HCY
LD MY,0011b ; Power on, CLK_IN default high
; 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 b,KeyCode
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
ld my,0000b ; turn off power_control ,clk_in is low
; add it by hcy 03-12-4 14:13
ld a,4
ld Tmr2s,a ;
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
call ClrKeyHoldTm
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 KeyHoldTm,a
ld X,RegKeyFlags
AND MX,0fh-DisFlashFlag ; clr the key
ld x,RTCMinL
ld y,TmpRTCMinuteL
call Copy2Byte
calz DspColonOn
ld a,Key_Nil
ld KeyCode,a ; clr key code
ld KeyHoldTm,a
; ld a,0fh
; ld Tmr15s,a
call ReloadTmr2Min
TimeSet:
ld X,RegKeyFlags
FAN MX,DisFlashFlag
jp nz,TimeSett0
ld y,TmpRTCHourL
calz FlashHour
TimeSett0:
call ChkTimer
ld a,Tmr2Min
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
call ReloadTmr2Min
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
ld a,KeyHold2Sec
cp a,01h
jp nz,HTimeSet
ld a,0
ld KeyHold2Sec,a
jp TimeSet
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,01h
ld KeyHold2Sec,a
ld a,0dh
ld KeyHoldTm,a ;
jp HTimeSet
; call IncSetHour ;
; jp TimeSet
ORG 300H
UTimeSet0:
; ld a,15
; ld Tmr15s,a
call ReloadTmr2Min
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,Tmr2Min
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
call ReloadTmr2Min
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
ld a,KeyHold2Sec
cp a,01h
jp nz,HTimeSet0
ld a,0
ld KeyHold2Sec,a
jp TimeSet0
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,01h
ld KeyHold2Sec,a
ld a,0dh
ld KeyHoldTm,a ;
jp HTimeSet0
MTimeSet0:
; ld a,15
; ld Tmr15s,a
call ReloadTmr2Min
call ClrKeyVar
ld a,7
ld x,0a1h
calz DspPattern1 ; ' '
; ORG 300H
TimeSet4:
calz FlashTimeFormat
call ChkTimer
ld a,Tmr2Min
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
call ReloadTmr2Min
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
call ReloadTmr2Min
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
; add by hcy 03-12-22 17:19
ld b,0
ld KeyHoldTm,b
SZF ; return with Z-1 if new key MbB
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
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
; modify the 'off' to 'ml/fl.oz'
; fan mx,IO_Key_Off
fan mx,IO_Key_ml
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
NCalKey0:
call TurnOnLCD
call Dly125ms
ld x,KPort
fan mx,IO_Key_On
jp nz,NCalKey0 ; 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,90h
LCDClrf:
ldpx mx,0fh
cp xh,0bh ; LCD ram from 90 to AFH
jp nz, LCDClrf
ret
;-------------------------------------
; Cate : clock
; By :
; Func :
; Desc :
; I/P :
; O/P :
; Destroy:
; Note :
ReloadTmr2Min:
ld x,RTCSec
call ClrByte
ld a,02h
ld Tmr2Min,a
ret
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -