📄 kclkr08.ms
字号:
.stabn 1667, LineInfo
or my,0b0011 ; if '0010b' 0--> r00,
.stabn 1669, LineInfo
ld y,(0x17) ; dec count
.stabn 1670, LineInfo
ADD my,0x0F ;
.stabn 1671, LineInfo
jp nz,ProgStartLp ; don't chk key until end of a nibble
.stabn 1673, LineInfo
CALl ToRecBuffer
.stabn 1674, LineInfo
call ReloadCommVar
.stabn 1675, LineInfo
ld x,(0x1d)
.stabn 1676, LineInfo
add mx,1
.stabn 1678, LineInfo
ld x,(0x1d)
.stabn 1679, LineInfo
cp mx,1
.stabn 1680, LineInfo
jp nz,Prog3 ; jmp if not finish receiving start code
.stabn 1681, LineInfo
call IsEquStartCode
.stabn 1682, LineInfo
jp nc,xProgStartComm ; jmp if equ start code
; error case
.stabn 1685, LineInfo
jp CommE ; give up this communication
Prog3:
; remark by hcy 03-11-20 10:34
; cp mx,2
; jp nz,Prog4 ; jmp if not or already finish receiving command
; calz IsRightCmd
; jp nc,xProgStartComm
; error case
; jp CommE ; give up this communication
Prog4:
; jp c,xProgStartComm ; jmp if not finish receiving command
.stabn 1697, LineInfo
ld x,(0x31)
.stabn 1698, LineInfo
add mx,0x0f ; -1
.stabn 1699, LineInfo
jp nz,xProgStartComm ; jmp if not receive all data
; completely received a command
.stabn 1701, LineInfo
ld x,(0x31)
.stabn 1702, LineInfo
ld mx,0x0d ; total receive 13 nibble data
; ld a,0
; ld CommFlag,a ; 0--> commflag when finish receiving
.stabn 1707, LineInfo
LD X,(0x16)
.stabn 1708, LineInfo
FAN MX,(4)
.stabn 1709, LineInfo
JP z,Prog5 ; br if no send request
; LD X,RPort
; LD MX,0001b ; D_out low
Comm_Tx:
; Send the data after receiving a command
; CALL SendKey
; LD X,AppFlags
; AND MX,0fh-ReqToSendFlag ; clear the flag after sending
.stabn 1720, LineInfo
call SendKeyData
;
Prog5:
.stabn 1723, LineInfo
calz DspWeight
.stabn 1724, LineInfo
call DspIcons
.stabn 1725, LineInfo
calz DspFraction
CommE:
.stabn 1727, LineInfo
ld x,(0x1d)
.stabn 1728, LineInfo
ld mx,0
.stabn 1729, LineInfo
JP xProgStartComm
;----------------------------------------
xProgStartComm:
;
; here for checking the keyboard
;
.stabn 1735, LineInfo
CALZ KeyScan
.stabn 1736, LineInfo
LD X,(1)
.stabn 1737, LineInfo
FAN MX,(2)
.stabn 1738, LineInfo
jp z,ProgStartLp ; br if no key pressed before
;
.stabn 1740, LineInfo
JP Main_KeyHandle ; br if key press-hold and release
;
; Flash the colon per 0.5 second
;
UpdateSecond:
.stabn 1746, LineInfo
call ToggleHalfSecFlag
.stabn 1748, LineInfo
calz FlashColon
;
.stabn 1750, LineInfo
ld x,(0x16)
.stabn 1751, LineInfo
fan mx,(2)
.stabn 1752, LineInfo
jp z,ProgStartComm ; br if just 0.5 sec
;
.stabn 1754, LineInfo
and mx,0x0f-(2) ; clear the bit
; update the clock per 1 min
;
.stabn 1757, LineInfo
calz IncSecond
.stabn 1758, LineInfo
jp nc,ProgStartComm ; No display update if change in second only
.stabn 1759, LineInfo
calz IncMinute
.stabn 1760, LineInfo
jp nc,xUpdateClk
.stabn 1761, LineInfo
calz IncHour
xUpdateClk:
;
; depends on which mode to show the time
;
; remark by hcy 03-11-20 19:41
.stabn 1767, LineInfo
jp ProgStart
; add by hcy 03-11-20 19:41
; jp ProgStartLp
;
;;======================================
; Key handling from here after
;
; Press and hold Kg > 2 seconds to enter the clock setting mode
; the Hour digits will be firstly flashed and use the ekys
; 1. Key_ml to toggle 12/24 mode
; 2. Key_kg to select hour-adjusting
; 3. press the Key_ml to increment the hour
; 4. Press the Key_Kg to confirm the hour and select minute-adjusting
; 5. Press the Key_ml to increment the minute
; 6. Press the Key_Kg to complete the time setting.
;
; Remark: turn off the ADC power in Clock/Clock setting mode
; no colon/second counting during clock setting mode
; clear the second register after setting
;
Main_KeyHandle:
.stabn 1788, LineInfo
LD A,(M3)
.stabn 1789, LineInfo
CP A,(0b0111)
.stabn 1790, LineInfo
JP z,GetKey_On
.stabn 1791, LineInfo
CP A,(0b1101)
.stabn 1792, LineInfo
JP z,GetKey_Kg
.stabn 1793, LineInfo
CP A,(0b1011)
.stabn 1794, LineInfo
JP z,GetKey_ml
.stabn 1795, LineInfo
CP A,(0b1110)
.stabn 1796, LineInfo
JP z,GetKey_Off
.stabn 1797, LineInfo
JP ProgStartLp
;
GetKey_On:
; for testing
.stabn 1802, LineInfo
LD X,(1)
.stabn 1803, LineInfo
FAN MX,(1)
.stabn 1804, LineInfo
JP nz,ProgStartLp ; still key hold
.stabn 1805, LineInfo
AND MX,0x0f-(2) ; process the key & clr the flag
;
.stabn 1807, LineInfo
ld x,(0x33)
.stabn 1808, LineInfo
fan mx,0x0f
.stabn 1809, LineInfo
jp nz,GetK0 ; jmp if not clock mode
.stabn 1811, LineInfo
ld y,(0x2EB) ; set D_Out Hi after sending
.stabn 1812, LineInfo
or my,0b0011 ; turn on power to samsung clk_in default high
.stabn 1813, LineInfo
add mx,1
.stabn 1814, LineInfo
CALl LCDClr
.stabn 1815, LineInfo
call Dly125ms
.stabn 1816, LineInfo
call Dly125ms
.stabn 1817, LineInfo
jp ProgStart ; to show Clock
GetK0:
.stabn 1820, LineInfo
LD (M4),B ;
.stabn 1821, LineInfo
LD X,(0x16)
.stabn 1822, LineInfo
OR MX,(4)
.stabn 1823, LineInfo
jp ProgStartLp
GetKey_ml:
.stabn 1828, LineInfo
LD X,(1)
.stabn 1829, LineInfo
FAN MX,(1)
.stabn 1830, LineInfo
JP nz,ProgStartLp ; still key hold
.stabn 1831, LineInfo
AND MX,0x0f-(2) ; process the key & clr the flag
;
; process the ml key here after
; LD SendData,B ;
; LD X,AppFlags
; OR MX,ReqToSendFlag
; JP ProgStartLp
.stabn 1840, LineInfo
jp GetK0
;
; process the Off key here after
GetKey_Off:
; LD SendData,B ;
; LD X,AppFlags
; OR MX,ReqToSendFlag
.stabn 1848, LineInfo
ld a,0
.stabn 1849, LineInfo
ld (M3),a
.stabn 1850, LineInfo
ld x,(0x33)
.stabn 1851, LineInfo
ld mx,(0) ; Reset modeOpt if not valid
.stabn 1852, LineInfo
CALl LCDClr
.stabn 1853, LineInfo
ld y,(0x2EB) ; set D_Out Hi after sending
.stabn 1854, LineInfo
and my,0b0010 ; turn off POWER_CONTROL
.stabn 1855, LineInfo
jp ProgStart
;
GetKey_Kg:
.stabn 1859, LineInfo
LD Y,(0x33)
.stabn 1860, LineInfo
CP MY,(0)
; JP nz,WeigthKey_Kg ; br if not clock mode
.stabn 1862, LineInfo
jp nz,GetKey_ml ; br if not clock mode
.stabn 1864, LineInfo
ld X,(1)
.stabn 1865, LineInfo
fan MX,(1)
.stabn 1866, LineInfo
jp nz,GetKey_Kg0 ; br to check the hold time
.stabn 1868, LineInfo
AND MX,0x0f-(2) ; ignor the key
.stabn 1869, LineInfo
LD a,0
.stabn 1870, LineInfo
ld (M0),a ; reset timer
.stabn 1871, LineInfo
jp ProgStartLp
;
; starting from here if the key hold time > 2 seconds
;
GetKey_Kg0:
.stabn 1876, LineInfo
ld a,(M0)
.stabn 1877, LineInfo
cp a,0x0f ; tolerance -1/8 sec
.stabn 1878, LineInfo
jp nz,ProgStartLp ; br if Hold time < 2 seconds
.stabn 1879, LineInfo
ld x,(1)
.stabn 1880, LineInfo
and mx,0x0f-(2) ; clear the flag
;
; Time setting mode from here on
.stabn 1884, LineInfo
ld a,(0)
.stabn 1885, LineInfo
ld (M3),a ; clr key code
.stabn 1886, LineInfo
ld X,(1)
.stabn 1887, LineInfo
AND MX,0x0f-(4) ; clr the key
.stabn 1888, LineInfo
ld x,(0x12)
.stabn 1889, LineInfo
ld y,(0x18)
.stabn 1890, LineInfo
call Copy2Byte
.stabn 1891, LineInfo
calz DspColonOn
TimeSet:
.stabn 1894, LineInfo
ld X,(1)
.stabn 1895, LineInfo
FAN MX,(4)
.stabn 1896, LineInfo
jp nz,TimeSett0
.stabn 1897, LineInfo
ld y,(0x1a)
.stabn 1898, LineInfo
calz FlashHour
TimeSett0:
.stabn 1900, LineInfo
call ChkTimer
.stabn 1902, LineInfo
LD A,(M3)
.stabn 1903, LineInfo
CP A,(0b1101)
.stabn 1904, LineInfo
JP z,UTimeSet0 ;; jmp to setting minute
.stabn 1905, LineInfo
CP A,(0b1011)
.stabn 1906, LineInfo
jp z,TimeSet1 ; jmp to setting increase hour
.stabn 1907, LineInfo
jp TimeSet
TimeSet1:
.stabn 1910, LineInfo
ld X,(1)
; OR MX,DisFlashFlag
.stabn 1912, LineInfo
fan MX,(1)
.stabn 1913, LineInfo
jp nz,TimeSet2 ; br to check the hold time
.stabn 1915, LineInfo
AND MX,0x0f-(2) ; clr the key
.stabn 1916, LineInfo
AND MX,0x0f-(4) ; clr the key
.stabn 1917, LineInfo
LD a,0
.stabn 1918, LineInfo
ld (M0),a ; reset timer
.stabn 1919, LineInfo
ld (M3),a ; clr the key code
HTimeSet:
.stabn 1921, LineInfo
call IncSetHour
.stabn 1922, LineInfo
jp TimeSet
TimeSet2:
;
; starting from here if the key hold time > 2 seconds
;
.stabn 1927, LineInfo
OR MX,(4)
.stabn 1928, LineInfo
ld a,(M0)
.stabn 1929, LineInfo
cp a,0x0f ; tolerance -1/8 sec
.stabn 1930, LineInfo
jp nz,TimeSet ; br if Hold time < 2 seconds
.stabn 1931, LineInfo
ld a,0x0d
.stabn 1932, LineInfo
ld (M0),a ;
.stabn 1933, LineInfo
jp HTimeSet
; call IncSetHour ;
; jp TimeSet
UTimeSet0:
.stabn 1937, LineInfo
ld X,(1)
.stabn 1938, LineInfo
AND MX,0x0f-(4) ; clr the key
.stabn 1939, LineInfo
ld a,(0)
.stabn 1940, LineInfo
ld (M3),a ; clr key code
TimeSet0:
.stabn 1942, LineInfo
ld y,(0x1a)
.stabn 1943, LineInfo
calz DspHour
.stabn 1944, LineInfo
calz DspColonOn
.stabn 1945, LineInfo
ld X,(1)
.stabn 1946, LineInfo
FAN MX,(4)
.stabn 1947, LineInfo
jp nz,MTime0
.stabn 1949, LineInfo
ld y,(0x18)
.stabn 1950, LineInfo
calz FlashMinute
MTime0:
.stabn 1952, LineInfo
call ChkTimer
.stabn 1954, LineInfo
LD A,(M3)
.stabn 1955, LineInfo
CP A,(0b1101)
.stabn 1956, LineInfo
JP z,MTimeSet0 ;; jmp to setting minute
.stabn 1957, LineInfo
CP A,(0b1011)
.stabn 1958, LineInfo
jp z,MTimeSet1 ; jmp to setting increase hour
.stabn 1959, LineInfo
jp TimeSet0
MTimeSet1:
.stabn 1962, LineInfo
ld X,(1)
; OR MX,DisFlashFlag
.stabn 1964, LineInfo
fan MX,(1)
.stabn 1965, LineInfo
jp nz,MTimeSet2 ; br to check the hold time
.stabn 1967, LineInfo
AND MX,0x0f-(2) ; clr the key
.stabn 1968, LineInfo
AND MX,0x0f-(4) ; clr the key
.stabn 1969, LineInfo
LD a,0
.stabn 1970, LineInfo
ld (M0),a ; reset timer
.stabn 1971, LineInfo
ld (M3),a ; clr the key code
HTimeSet0:
.stabn 1973, LineInfo
call IncSetMinute
.stabn 1974, LineInfo
jp TimeSet0
MTimeSet2:
;
; starting from here if the key hold time > 2 seconds
;
.stabn 1980, LineInfo
OR MX,(4)
.stabn 1981, LineInfo
ld a,(M0)
.stabn 1982, LineInfo
cp a,0x0f ; tolerance -1/8 sec
.stabn 1983, LineInfo
jp nz,TimeSet0 ; br if Hold time < 2 seconds
.stabn 1984, LineInfo
ld a,0x0d
.stabn 1985, LineInfo
ld (M0),a ;
.stabn 1986, LineInfo
jp HTimeSet0
; call IncSetMinute ;
; jp TimeSet0
MTimeSet0:
; ld X,RegKeyFlags
; and mx,0fh-TimeFormatFlag ; default is 12 hour
.stabn 1992, LineInfo
ld a,(0)
.stabn 1993, LineInfo
ld (M3),a ; clr key code
TimeSet4:
.stabn 1995, LineInfo
calz FlashTimeFormat
.stabn 1996, LineInfo
call ChkTimer
.stabn 1998, LineInfo
LD A,(M3)
.stabn 1999, LineInfo
CP A,(0b1101)
.stabn 2000, LineInfo
JP z,TTimeSet0 ;; jmp to exit setting
.stabn 2001, LineInfo
CP A,(0b1011)
.stabn 2002, LineInfo
jp z,TTimeSet1 ; jmp to toggle time format
.stabn 2003, LineInfo
jp TimeSet4
TTimeSet1:
.stabn 2006, LineInfo
ld X,(1)
.stabn 2007, LineInfo
fan MX,(1)
.stabn 2008, LineInfo
jp nz,TimeSet4 ; br to check the hold time
.stabn 2010, LineInfo
AND MX,0x0f-(2) ; clr the key
.stabn 2011, LineInfo
ld a,0
.stabn 2012, LineInfo
ld (M3),a
.stabn 2013, LineInfo
ld x,(1)
.stabn 2014, LineInfo
xor mx,(8)
.stabn 2015, LineInfo
calz DspTimeFormat
.stabn 2016, LineInfo
jp TimeSet4
.org 0x300
TTimeSet0:
.stabn 2022, LineInfo
ld x,(0x18)
.stabn 2023, LineInfo
ld y,(0x12)
.stabn 2024, LineInfo
call Copy2Byte ;
.stabn 2025, LineInfo
ld x,(0x10)
.stabn 2026, LineInfo
call ClrByte
.stabn 2027, LineInfo
ld y,(0x14)
.stabn 2028, LineInfo
calz DspHour
.stabn 2029, LineInfo
ld y,(0x12)
.stabn 2030, LineInfo
calz DspMinute
.stabn 2031, LineInfo
ld a,0
.stabn 2032, LineInfo
ld (M0),a
.stabn 2033, LineInfo
ld X,(1)
.stabn 2034, LineInfo
AND MX,0x0f-(2) ; clr the key
.stabn 2035, LineInfo
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 0x320
;
;-------------------------------------
; 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
.stabn 2071, LineInfo
LD A,0x0a
.stabn 2072, LineInfo
CALL Send4Bit
; Check the time out if neccessary
.stabn 2074, LineInfo
LD X,(3)
.stabn 2075, LineInfo
LD A,MX
.stabn 2076, LineInfo
CALL Send4Bit
;
.stabn 2078, LineInfo
ld y,(0x2EB) ; set D_Out Hi after sending
; or my,0010b
.stabn 2080, LineInfo
or my,0b0011
; Check the time out if neccessary
.stabn 2082, LineInfo
RET
;
;-------------------------------------
; Cate : communication
; By : Hcy
; Func : send 4 data bits (LSB first)
; Desc : Send4Bit
; I/P :
; O/P :
; Destroy:
; Note :
Send4Bit:
.stabn 2094, LineInfo
LD X,(0x17)
.stabn 2095, LineInfo
LD MX,4 ; 4 bits
Send4BitLp1:
.stabn 2097, LineInfo
LD Y,(0x2E3)
Send4BitLp0:
.stabn 2099, LineInfo
FAN MY,0b0100 ; wait for D_Clk Hi
.stabn 2100, LineInfo
JP z,Send4BitLp0
;
.stabn 2102, LineInfo
ld y,(0x2EB)
.stabn 2103, LineInfo
RRC A
.stabn 2104, LineInfo
JP C,Send4BitHi
.stabn 2105, LineInfo
and my,0b0001
.stabn 2106, LineInfo
jp Send4Bit0
Send4BitHi:
; OR my,0010b
.stabn 2109, LineInfo
or my,0b0011
Send4Bit0:
.stabn 2112, LineInfo
LD Y,(0x2E3)
Send4BitLp2:
.stabn 2114, LineInfo
FAN MY,0b0100 ; wait for D_Clk Lo
.stabn 2115, LineInfo
JP nz,Send4BitLp2
.stabn 2117, LineInfo
Add mx,0x0f ; dec commcount
.stabn 2118, LineInfo
JP nz,Send4BitLp1
;
xSend4Bit:
.stabn 2121, LineInfo
ret
;-------------------------------------
; Cate : communication
; By : Hcy
; Func : send synchronize bit(high level)
; Desc : SendSynBit
; I/P :
; O/P :
; Destroy:
; Note :
;SendSynBit:
; LD Y,KPort
;SendSyn0:
; FAN MY,0100b ; check D_Clk Hi
; JP z,SendSyn0 ; wait until D_CLK= Hi
;;
;; Samsung get the acknowledge
; NOP5
; ld x,RPort ; D_clk=Lo
; or my,0010b
;;
;SendSyn1:
; FAN MY,0100b ;
; JP nz,SendSyn0 ; wait until D_CLK= Hi
; ret
; end
;
;
;
;
.stabn 0, FileEnd
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -