📄 r08cnvlcdclk1.s
字号:
;
; Copy right Oriental Skill (Asia) Ltd
; October 24, 2003
;
; Created by Kwan for Testing
;
;
; Scratch Pad memory from 0H ~ 0FH (M0~MF)
; User RAM from 10H ~ 2FH (32 nibbles)
; Stack from 30H~4FH
; LCD RAM from 90H ~ AFH -- However A4H~AFH may be used
; as user RAM because S13~S19 segment are not used
; in this application.
;
; v02 03-12-4 14:14
; 1. after battery insert to the scale, the display time should be 12:00 a.m.
; 2. the scale can enter calibration moe at anytime during clock display
; 3. to avoid abnormal operarion, program EPSON IC so that it cann't turn on
; within 2s after the scale turn off.
; v03 03-12-9 12:24
; 1. add the function that if no key input within 30s program return to
; the view clock mode
SHOWLDIGITCMD EQU 2
SHOWSDIGITCMD EQU 3
SHOWICONCMD EQU 4
SHOWMSGCMD EQU 5
CLOCKMODE EQU 0
WEIGHTMODE EQU 1
CALIBRATEMODE EQU 2
KeyHoldTm EQU M0
KeyFlags EQU M1
RegKeyFlags EQU 1 ; same as KeyFlags
;CommCount EQU M2 ; bit count for comm
KeyHoldFlag EQU 1
NewKeyFlag EQU 2
DisFlashFlag EQU 4
TimeFormatFlag EQU 8 ; 0: 12 hour, 1: 24 hour
KeyCode EQU M3
RegKeyCode EQU 3
SendData EQU M4
RegSendData EQU 4
Tmr15s EQU M5
;CommFlag EQU M6
ComDigHBuf EQU M6
DigitHBuf EQU M7
Tmr1s EQU M8
Tmr2s EQU M9
;
RTCSec EQU 10H
RTCSecL EQU 10H
RTCSecH EQU 11H
RTCMin EQU 12H
RTCMinL EQU 12H
RTCMinH EQU 13H
RTCHour EQU 14H
RTCHourL EQU 14H
RTCHourH EQU 15H
;
RxStartBufL equ 20h ; start code
;RxCommand equ 21h
RxBuffer0 EQU 21H ; LSBL, ___1, decimal place
RxBuffer1 EQU 22H ; LSBH
RxBuffer2 EQU 23H ; xxx1
RxBuffer3 EQU 24H
RxBuffer4 EQU 25H ; xx1x
RxBuffer5 EQU 26H
RxBuffer6 EQU 27H ; x1xx
RxBuffer7 EQU 28H
RxIcon0 EQU 29h
RxIcon1 EQU 2ah
RxIcon2 EQU 2bH
RxIcon3 EQU 2cH
RxSBuffer EQU 2dH ; SDIGIT
RxBuffer8 equ 2eh
RxBuffer9 equ 2fh
SumNumRxNibble equ 30h ;
;
ModeOpt equ 31h ; 0: Clock Mode, 1: weighting Mode, 2: Calibration Mode
DspHourBuf EQU 32H
DspHourLBuf EQU 32H
DspHourHBuf EQU 33H
LCDMapMem0 EQU 34H ; 1ST DIGIT
LCDMapMem0H EQU 35H
LCDMapMem1 EQU 36H ; 2ND DIGIT
LCDMapMem1H EQU 37H
LCDMapMem2 EQU 38H ; 3RD DIGIT
LCDMapMem2H EQU 39H
LCDMapMem3 EQU 3AH ; 4TH DIGIT
LCDMapMem3H EQU 3BH
LCDMapMem4 EQU 3CH ; 5,6th digit
LCDMapMem4H EQU 3DH
LCDMapMem5 EQU 3EH
LCDMapMem5H EQU 3FH
AppFlags EQU 16H
HalfSecFlag EQU 1
SecClickFlag EQU 2
ReqToSendFlag EQU 4 ; set when 4 bits has been sent in background
Rx4BitFlag EQU 8 ; set when 4 bits has been received in background
;b0 -- Half second (0->1 0.5 sec, 1->0 1 sec)
;b1 -- second click
;b2 -- RxReady
CommCount EQU 17H ; bit count for comm
TmpRTCMinute EQU 18H
TmpRTCMinuteL EQU 18H ; for the use of time adjustment
TmpRTCMinuteH EQU 19H
TmpRTCHour EQU 1AH
TmpRTCHourL EQU 1aH
TmpRTCHourH EQU 1bH
;
CommBufferL EQU 1cH ; Tx/Rx Buffer
;RxNibbleCnt equ 00h ;
RxNibbleCnt equ 1dh
KeyFlag EQU 1eH
;NewKey bit 1eh.0
;KeyHold bit 1eh.1
RTC1SecCnt equ 1fh
;
;
;===========================================================
; Registers
; IC: 6001
;KPort EQU 0E0H
;IO_Key_On EQU 1
;IO_Key_Off EQU 2
;IO_DClk EQU 4
;;
;Timer EQU 0E4H ; timer data register
;KPortMask EQU 0E8H ; interrupt mask for K-port
;TimerMask EQU 0EBH
;KIntFactor EQU 0EDH ; interrupt request flags for Kport
;TIntFactor EQU 0EFH ; interrupt request flags for Timer
;;
;RPort EQU 0F3H ; R0 data port
;IO_PowerCtl EQU 1
;IO_DataOut EQU 2
;;
;PPort EQU 0F6H ; P0 data port
;IO_Key_Kg EQU 1
;IO_Key_ml EQU 2
;IO_DataIn EQU 8
;;
;TimerCR EQU 0F9H
;;b2=1 to reset clock timer
;;
;HeavyLoad EQU 0FAH ; heavy load protection register
;;b3=1 if heavy load, b3=0 if normal load
;;
;LCDSwitch EQU 0FBH ;
;;b3=1 if static, b3=0 if dynamic
;;
;PPortDir EQU 0FCH ; P-port direction register
;;b0=1 if whole P-port as output, b0=0 if as inout
;;
;BuzzerFreq EQU 0FDH ; Buzzer freq
;===========================================================
; Registers
; IC: 60R08
KPort EQU 0E3H
;IO_Key_On EQU 1
;IO_Key_Off EQU 2
;IO_DClk EQU 4
IO_Key_On EQU 1
IO_Key_Kg EQU 2
IO_Key_ml EQU 4
IO_Key_Off EQU 8
Timer EQU 0E0H ; timer data register
KPortMask EQU 0E5H ; interrupt mask for K-port
TimerMask EQU 0E8H
KIntFactor EQU 0EAH ; interrupt request flags for Kport
TIntFactor EQU 0E9H ; interrupt request flags for Timer
RPort EQU 0EBH ; R0 data port
IO_PowerCtl EQU 1
IO_DataOut EQU 2
PPort EQU 0EDH ; P0 data port
;IO_Key_Kg EQU 1
;IO_Key_ml EQU 2
;IO_DataIn EQU 8
TimerCR EQU 0EEH
;b2=1 to reset clock timer
;
HeavyLoad EQU 0E6H ; heavy load protection register
;b3=1 if heavy load, b3=0 if normal load
;
LCDSwitch EQU 0E8H ;
;b3=1 if static, b3=0 if dynamic
;
PPortDir EQU 0EEH ; P-port direction register
;b0=1 if whole P-port as output, b0=0 if as inout
;
; constants defintion
;
Key_On EQU 0111b ; key code corr. to Samsung's code
Key_Off EQU 1110b
Key_Kg EQU 1101b
Key_ml EQU 1011b
Key_Nil EQU 0
; key code by hcy
;Key_On EQU 1110b ; key code corr. to Samsung's code
;Key_Off EQU 0111b
;Key_Kg EQU 1101b
;Key_ml EQU 1011b
;Key_Nil EQU 0
; define by hcy
Key_OnOff EQU 0110b
Key_OnKg EQU 0101b
;===========================================================
ORG 0
;-----------------------------------------------------------
;-----------------------------------------------------------
; Display routine
;-----------------------------------------------------------
;-----------------------------------------------------------
; hgfe dcba
; retd 3fh ; 0
; retd 06h ; 1
; retd 5bh ; 2
; retd 4fh ; 3
; retd 66h ; 4
; retd 6dh ; 5
; retd 7dh ; 6
; retd 27h ; 7
; retd 7fh ; 8
; retd 6fh ; 9
; retd 77h ; A
; retd 7ch ; b
; retd 39h ; C
; retd 5eh ; d
; retd 79h ; E
; retd 71h ; F
; retd 76h ; H
; retd 38h ; L
; retd 31h ; r
; retd 73h ; P
; retd 78h ; t
; retd 3eh ; U
; retd 40h ; -
; retd 00h ; ' '
; cgbh defa (h always 0)
retd 0afh ; 0
retd 0a0h ; 1
retd 6dh ; 2
retd 0e9h ; 3
retd 0e2h ; 4
retd 0cbh ; 5
retd 0cfh ; 6
retd 0a3h ; 7
retd 0efh ; 8
retd 0ebh ; 9
retd 0e7h ; A
retd 0ceh ; b
retd 0fh ; C
retd 0afh ; D
retd 4fh ; E
retd 47h ; F
retd 0e6h ; H
retd 0eh ; L
retd 44h ; r
retd 67h ; P
retd 4eh ; t
retd 0aeh ; U
retd 40h ; -
retd 00h ; ' '
; fraction table
retd 18h ;
retd 14h
retd 38h
retd 12h
retd 58h
retd 34h
retd 78h
retd 98h
; denominator(2,4,8) and numerator(1,3,5,7,9) pattern
retd 00h ; dummy
retd 00h ; 1(numerator)
retd 4Ah ; 2(denominator)
retd 30h ; 3(numerator)
retd 0C4h ; 4(denominator)
retd 31h ; 5(numerator)
retd 00h ; dummy
retd 11h ; 7(numerator)
retd 0CEh ; 8(denominator)
retd 31h ; 9(numerator)
DspPattern:
ld b,0
jpba
DspPattern1:
ld b,1
jpba
DspDenoNume:
ld b,2
jpba
;-------------------------------------
; Cate : Display
; By : Hcy
; Func : display the digit(0--9)
; Desc : DspDigit
; I/P : A(0--9),X(address of digit address)
; O/P : --
; Destroy: A,
; Note :
DspDigit:
push xl
calz DspPattern
DspDigE:
pop xl
DspCopy:
ld my,mx
inc x
inc y
ld my,mx
ret
DspDigit1:
push xl
calz DspPattern1
jp DspDigE
;-------------------------------------
; Cate : Display
; By : Hcy
; Func : display the digit(0--9)
; Desc : DspDigit
; I/P : A(0--9),X(address of digit address)
; O/P : --
; Destroy: A,
; Note :
DspDigitW:
push xl
calz DspPattern
DspDigEW:
pop xl
ld my,mx
inc x
inc y
ld a,ComDigHBuf
or a,mx
ld my,a
ret
DspDigit1W:
push xl
calz DspPattern1
jp DspDigE
; I: x(lcd ram address)
DspDigitSpa:
ld a,07h
calz DspPattern1
ret
;-------------------------------------
; Cate : Display
; By : loren
; Func : display the icon
; Desc : DspColonOn
; I/P : --
; O/P : --
; Destroy:
; Note :
DspColonOn:
ld y,LCDMapMem1H
ld a,my
or a,01h
ld y,044h
ld my,a
ret
;-------------------------------------
; Cate : Display
; By : loren
; Func : display off the icon
; Desc : DspColonOff
; I/P : --
; O/P : --
; Destroy:
; Note :
DspColonOff:
ld y,LCDMapMem1H
ld a,my
and a,1110b
ld y,044h
ld my,a
DspCO:
ret
;-------------------------------------
;-------------------------------------
; Cate :Dosplay
; By :Kwan
; Func :Flash the colon
; Desc :
; I/P :---
; O/P :
; Destroy:
; Note : turn on/off the colon according to
; HalfSecFlag
;
FlashColon:
ld y,ModeOpt
fan my,1111b
jp nz,DspCO ; jmp if not clock mode
ld y,AppFlags
FAN my,HalfSecFlag
Jp z,DspColonOff
jp DspColonOn
DspHourL:
ld x,LCDMapMem1
ld y,043h
calz DspPattern
ld x,LCDMapMem1
ld my,mx
inc x
inc y
ld a,mx
or a,0001b
ld my,a
ret
ClrAmPm:
ld x,040h
calz DspDigitSpa ; ' '
ld x,04ch
calz DspDigitSpa
ret
FlashHour:
ld x,AppFlags
FAN mx,HalfSecFlag
Jp z,DspHourOff
;-------------------------------------
; Cate : Display
; By : Hcy
; Func : Display the time
; Desc : DspTime
; I/P : y(ram address)
; O/P : --
; Destroy:
; Note :
DspTime:
DspHour:
; display hour xx
; ld x,RTCHourH
ld x,RegKeyFlags
fan mx,TimeFormatFlag
jp nz,DspH0 ; jmp if 24 hour format
call IsEquZero
jp c,NDspH00
call IsEqu12
jp c,DspH00 ; jmp if hour =12
call Sub12D
jp nc,DspH00 ; current time > 12
call CopyByte
NDspH00:
ld a,08h
ld x,040h
ld mx,a ; 'AM'
ld x,04ch
ld a,0
ld mx,a ; clr'pm'
jp DspH1
DspH00:
ld a,01h
ld x,04ch
ld mx,a ; 'PM'
ld a,0
ld x,040h
ld mx,a ; clr 'am'
jp DspH1
DspH0:
; ld x,090h
; calz DspDigitSpa ; ' '
; ld x,09ch
; calz DspDigitSpa
calz ClrAmPm
call CopyByte
jp NDspH0
DspH1:
; ld x,DspHourBuf
; calz IncByteD
NDspH0:
ld y,DspHourBuf
ld a,my
DspH2:
calz DspHourL
; ld x,LCDMapMem1
; ld y,093h
; calz DspPattern
; ld x,LCDMapMem1
; ld my,mx
; inc x
; inc y
; ld a,mx
; or a,0001b
; ld my,a
ld y,DspHourHBuf
ld a,my
fan a,1111b
jp nz,NewDspH2
jp NewDspH22
NewDspH2:
ld x,LCDMapMem0
ld y,041h
calz DspDigit
ret
DspHourOff:
; off minute xx
ld a,0
ld x,043h
ld mx,a
ld a,01h
ld x,044h
ld mx,a
NewDspH22:
ld x,041h
calz DspDigitSpa
ret
FlashMinute:
ld x,AppFlags
FAN mx,HalfSecFlag
Jp z,DspMinuteOff
DspMinute:
; display min xx
; ld x,RTCMinH
ld a,my
push yl
push yh
ld x,LCDMapMem3
ld y,047h
calz DspDigit
; ld x,RTCMinL
pop yh
pop yl
inc y
ld a,my
ld x,LCDMapMem2
ld y,045h
calz DspDigit
ret
DspMinuteOff:
; off minute xx
ld x,045h
calz DspDigitSpa
ld x,047h
calz DspDigitSpa
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
; ld y,RxBuffer8
; ld a,my
; ld x,098h
; calz DspPattern
; inc y
; ld a,my
; calz DspPattern
; ret
;DspF0:
; display nul/nul
; ld a,7
; ld x,098h
; calz DspPattern1 ; display ' ' in 5th digit
; calz DspPattern1 ; display ' ' in 6th digit
; 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,090h
; ld b,4
;DspW0:
; ld a,my
; push b
; ld b,a
; inc y
; fan my,0fh
; jp nz,DspW1
; ld a,b
; calz DspDigit
; jp DspW2
;DspW1:
; ld a,b
; calz DspDigit1
;DspW2:
; ld b,YL
; rcf
; sbc b,3 ; get next digit
; ld YL,b
; pop b
; ADD b,0FH ;
; jp nz,DspW0
; ret
;-------------------------------------
; Cate : Display
; By : Hcy
; Func : display the icons from the samsung
; Desc : DspIcons
; I/P : --
; O/P : --
; Destroy:
; Note :
;DspIcons:
; ld y,RxIcon0
; ld x,09ch
; ld b,4
;DspI0:
; ld mx,my
; inc y
; inc x
;; rcf
;; sbc b,1 ; get next digit
; ADD b,0FH ;
; jp nz,DspI0
; ret
;---------------------------------------
;---------------------------------------
; calculate the clock
;---------------------------------------
;---------------------------------------
;-------------------------------------
; Cate : Application
; By : Hcy
; Func : increase byte by decimal
; Desc : IncByteD
; I/P : X(address of buffer)
; O/P :
; Destroy:
; Note :
IncByteD:
; SET F,0100B
SDF
RCF
ADD MX,01h
inc x
ADC MX,00h
; RST F,1011B
RDF
RET
;-------------------------------------
; Cate : Clock
; By : Hcy
; Func : toggle the half sec flag
; Desc : ToggleHalfSecFlag
; I/P : --
; O/P : --
; Destroy:
; Note :
;ToggleHalfSecFlag:
; ld x,AppFlags
; xor mx,HalfSecFlag
; fan mx,HalfSecFlag
; jp nz,xToggleHalfS
; or mx,SecClickFlag ; set flag if from 1->0
;xToggleHalfS:
; ret
;-------------------------------------
; Cate : Clock
; By : Hcy
; Func : check if up to 1 minute
; Desc : IncSecond
; I/P : --
; O/P : --
; Destroy:
; Note : c=0 if not up to 1 minute, c=1 if up to 1 minute
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -