사용자 도구

사이트 도구

English

ct1820:sample_8_rtc_조정:index

SAMPLE 8: RTC 조정

본 프로그램을 이용하여, 내부 RTC 설정치를 조정할 수 있습니다.

이 소스에 사용된 화면은 CuCANVAS 로 제작된 것입니다.

#include "CT18XX"
Dim TX1 As Integer
Dim TY1 As Integer
Dim Va As Integer
Basic_FORM1
On Pad Gosub TouchOccur
'
'********************* 메인 do 루프 ************************
'
Do
 Locate 2,5
 Print "20",Hp(Rtcread(6),2,1)," ", Hp(Rtcread(5),2,1)," ",
 Hp(Rtcread(4),2,1)
 Locate 23,5
 Print Hp(Rtcread(2),2,1)," ", Hp(Rtcread(1),2,1)," ", Hp(Rtcread(0),2,1)
 Wait 1000
Loop
 
TouchOccur:
 TX1 = Sys(10)
 TY1 = Sys(11)
 If Menucheck(0,TX1,TY1) = 1 Then            ' Year
 EffectFlash 0
 VaIncr 6,99
 Elseif Menucheck(1,TX1,TY1) = 1 Then
 EffectFlash 1
 VaDecr 6,0
 Endif
 If Menucheck(2,TX1,TY1) = 1 Then            ' Month
 EffectFlash 2
 VaIncr 5,12
 Elseif Menucheck(3,TX1,TY1) = 1 Then
 EffectFlash 3
 VaDecr 5,1
 Endif
 If Menucheck(4,TX1,TY1) = 1 Then           ' Date
 EffectFlash 4
 VaIncr 4,31
 Elseif Menucheck(5,TX1,TY1) = 1 Then
 EffectFlash 5
 VaDecr 4,1
 Endif
 
 If Menucheck(6,TX1,TY1) = 1 Then            ' Hour
    EffectFlash 6
    VaIncr 2,23
 Elseif Menucheck(7,TX1,TY1) = 1 Then
    EffectFlash 7
    VaDecr 2,0
 Endif 
 
 If Menucheck(8,TX1,TY1) = 1 Then            ' Min
    EffectFlash 8
    VaIncr 1,59
 Elseif Menucheck(9,TX1,TY1) = 1 Then
    EffectFlash 9
    VaDecr 1,0
 Endif
 
 If Menucheck(10,TX1,TY1) = 1 Then           ' Sec
    EffectFlash 10
    VaIncr 0,59
 Elseif Menucheck(11,TX1,TY1) = 1 Then
    EffectFlash 11
    VaDecr 0,0
 Endif
 
 Return
 
End
 
Sub EffectFlash (IxM As Integer)
 Menureverse IxM
 Ct18beep 20
 Wait 200
 Menureverse IxM
End Sub
 
Sub VaIncr(AddrRTC As Integer, LimitThis As Integer)
 Dim Tm As Byte
 Dim Dtm As Byte
 Tm = Rtcread(AddrRTC)
 Dtm = Bcd2bin(Tm)
 Incr Dtm
 If Dtm > LimitThis Then Decr Dtm
 Tm = Bin2bcd(Dtm)
 Rtcwrite AddrRTC,Tm
End Sub
 
Sub VaDecr(AddrRTC As Integer, Limitunder As Integer)
 Dim Tm As Byte
 Dim Dtm As Byte
 Tm = Rtcread(AddrRTC)
 Dtm = Bcd2bin(Tm)
 If Dtm > Limitunder Then Decr Dtm
 Tm = Bin2bcd(Dtm)
 Rtcwrite AddrRTC,Tm
End Sub
 
Sub Basic_FORM1()
 Font 2,0 
 Style 0,0,0
 Menuset 0,2,15,40,45,60
 Menutitle 0,11,2,"+"
 Menuset 1,2,15,125,45,145
 Menutitle 1,11,2,"-"
 Menuset 2,2,65,40,95,60
 Menutitle 2,11,2,"+"
 Font 0,0
 Menuset 3,2,65,125,95,145
 Menutitle 3,11,2,"-"
 Font 3,0
 Menuset 4,2,115,40,145,60
 Menutitle 4,11,2,"+"
 Menuset 5,2,115,125,145,145
 Menutitle 5,11,2,"-"
 Menuset 6,2,175,40,205,60
 Menutitle 6,11,2,"+"
 Menuset 7,2,175,125,205,145
 Menutitle 7,11,2,"-"
 Menuset 8,2,225,40,255,60
 Menutitle 8,11,2,"+"
 Menuset 9,2,225,125,255,145
 Menutitle 9,11,2,"-"
 Font 2,0
 Menuset 10,2,275,40,305,60
 Menutitle 10,11,2,"+"
 Font 3,0
 Menuset 11,2,275,125,305,145
 Menutitle 11,11,2,"-"
 Linestyle 0
 Dotsize 0,0
 Color 1
 Box 5,20,155,165
 Box 165,20,315,165
 Font 0,1
 Glocate 15,175
 Gprint "Year Month Date "
 Glocate 175,175
 Gprint "Hour Min Sec"
 Font 6,1
 Glocate 90,195
 Gprint "RTC Setting"
 Font 4,0
End Sub 
ct1820/sample_8_rtc_조정/index.txt · 마지막으로 수정됨: 2016/04/19 03:20 저자 Comfile Technology