'這是PortB上的按鈕
Ddrb = Ddrb And Pinb_mask_compl 'DDRB: 0=INPUT 1=OUTPUT
Portb = Portb Or Pinb_mask '1 =激活輸入的內(nèi)部上拉電阻
Key_port Alias Pinb
Dim Key_state As Byte '0/1按鈕的反轉(zhuǎn)狀態(tài)(1 =按下)
Dim Key_press As Byte '觸發(fā)按鍵
Dim Key_rep As Byte '自動(dòng)重復(fù)計(jì)數(shù)器
Dim Key_ct0 As Byte , Key_ct1 As Byte '2 位計(jì)數(shù)器用于反跳
'********* 一般的 ***************************************************
Dim I As Byte , J As Byte , K As Byte , L As Byte
Dim q As Byte
Dim Setdatetime_index As Byte
Setdatetime_index = 2 '日期數(shù)組的第一個(gè)索引為1,2 = _min
Dim Date_array(6) As Byte At _sec Overlay '秒/分鐘/小時(shí)/天/月/年的數(shù)組指定在內(nèi)存中覆蓋變量。
'********* 主循環(huán) ***************************************************
Do
Disable Interrupts '禁用中斷
I = Key_press '讀取鍵
Key_press = 0
L = Lookup(setdatetime_index , Date_max)
If Setdatetime_index = 4 Then
L = Lookup(_month , Date_month)
K = _year And 3
If _month = 2 Then If K = 0 Then Incr L
End If
K = Lookup(setdatetime_index , Date_min)
J = Date_array(setdatetime_index)
If I = Key_plus Then
If J < L Then Incr J Else J = K
End If
If I = Key_minus Then
If J > K Then Decr J Else J = L
End If
Date_array(setdatetime_index) = J
Enable Interrupts '啟用中斷
If I = Key_enter Then
If Setdatetime_index < 6 Then Incr Setdatetime_index Else Setdatetime_index = 1
End If