#include #include #include #include #include #define SEC 0x00#define MIN 0x01#define giờ 0x02#define ngày 0x03#define ngày 0x04#define tháng 0x05#define năm 0x06 Các cơ sở dữ liệu cho các idata unsigned char [100]; Cơ sở dữ liệu để hiển thị văn bản ở dưới cùngunsigned char idata temp_data [7]; Cơ sở dữ liệu tạm thời được sử dụng để hiển thị các ký tự sau khi chỉnh sửasố lượng int, sec, s, s1, s2, s3, min, m, m1, m2, m3, giờ, h, h1, h2, h3, h4, thời gian, keypressed, chế độ,TH0_value, TL0_value, ngày, editkey, ngày, d, d1, d2, tháng, mo, mo1, mo2, năm, y, y1, y2, vị trí, pos, editpoint,outring, count1, di chuyển, ký tự, starttext, automode, m3compare;vô hiệu delay(unsigned int i){ while(i--) { unsigned char j = 121; while(j--) {} }}//********************************************làm mất hiệu lực key_press() { int tôi, i1, i2, kết quả; Nếu (P3_3 == 0) //Change chế độ hiển thị { Nếu (starttext == 0) //Edit chế độ là kích hoạt sau khi Starttext kết thúc di chuyển { keypressed = 1; Nếu (tính > 20) { số lượng = 0; keypressed = 0; chế độ ++; Nếu (chế độ == 3) //clear old tất cả cơ sở dữ liệu khi chế độ 3 là actived / / / { cho (i = 0; tôi < 100; i ++) cơ sở dữ liệu [i] = 255; } Nếu (chế độ == 5) //come trở lại chế độ 0 { chế độ = 0; } EEprom_write(0,mode); lưu chế độ vào Eprom với địa chỉ 0 editkey = 0; Đặt lại Editkey } } } Nếu ((P3_4 == 0 & chế độ == 1) | ()P3_4 == 0 & chế độ == 2)) //Change editkey (phím là giờ, phút, giây...) { keypressed = 1; Nếu (tính > 20) { số lượng = 0; keypressed = 0; editkey ++; Nếu (editkey == 5) { editkey = 0; } } } if(Mode==0) //Every điều trong chế độ 0 { Nếu (P3_4 == 0) { keypressed = 1; Nếu (tính > 20) { số lượng = 0; keypressed = 0; outring++; //ON and OF outside Rings P3_6=1; if (outring==2) { outring=0; P3_6=0; } EEprom_write(1,outring); //save mode into Eprom with address is 1 } } if(P3_5==0) { keypressed=1; if (count>20) { count=0; keypressed=0; if(automode==0) automode=1; else automode=0; if(outring==0) { P3_6=1; delay(200); P3_6=0; } if(outring==1) { P3_6=0; delay(200); P3_6=1; } } } } if (mode==1) //Every thing in Mode 1 { if (editkey==1) //Edit Hour { if (P3_5==0) { i=h2*10+h1; keypressed=1; if (count>5) { count=0; keypressed=0; i++; if(i==24) { i=0; } i1=i/10; i1=i1<<4; i2=i%10; result=i1|i2; DS1307_write(HOUR,result); } } editpoint=41; } if (editkey==2) //Edit Minute { if (P3_5==0) { i=m3; keypressed=1; if (count>5) { count=0; keypressed=0; i++; if(i==60) { i=0; } i1=i/10; i1=i1<<4; i2=i%10; result=i1|i2; DS1307_write(MIN,result); } } editpoint=26; } if (editkey==3) //Edit Second { if (P3_5==0) { i=s3; keypressed=1; if (count>5) { count=0; keypressed=0; i++; if(i==60) { i=0; } i1=i/10; i1=i1<<4; i2=i%10; result=i1|i2; DS1307_write(SEC,result); } } editpoint=10; } } if ((mode==1 & editkey==4)|(mode==2 & editkey==4)) //Edit Day in Mode 1 and Mode 2 { if (P3_5==0) { i=day; keypressed=1; if (count>5) { count=0; keypressed=0; i++; if(i==8) { i=1; } i1=i/10; i1=i1<<4; i2=i%10; result=i1|i2; DS1307_write(DAY,result); } } editpoint=76; } if (mode==2) //Every thing in Mode 2 { Nếu (editkey == 1) //Edit ngày { if(P3_5==0) { tôi = ngày; keypressed = 1; Nếu (tính > 5) { số lượng = 0; keypressed = 0; i ++; if(i==32) { tôi = 1; } I1 = i / 10; I1 = i1 << 4; I2 = tôi % 10; kết quả = i1|i2; DS1307_write(date,result); } } editpoint = 41; } Nếu (editkey == 2) //Edit tháng { if(P3_5==0) { tôi = tháng; keypressed = 1; Nếu (tính > 5) { số lượng = 0; keypressed = 0; i ++; if(i==13) { tôi = 1; } I1 = i / 10; I1 = i1 << 4; I2 = tôi % 10; kết quả = i1|i2; DS1307_write(month,result); } } editpoint = 26; } Nếu (editkey == 3) //Edit năm { if(P3_5==0) { Tôi = năm; keypressed = 1; Nếu (tính > 5) { số lượng = 0; keypressed = 0; i ++; if(i==99) { tôi = 1; } I1 = i / 10; I1 = i1 << 4; I2 = tôi % 10; kết quả = i1|i2; DS1307_write(year,result); } } editpoint = 10; } } if(Mode==3) //Every điều trong chế độ 3 { Nếu (P3_4 == 0 & starttext == 0) //Process cho chỉnh sửa vị trí khóa { keypressed = 1; Bắt đầu đếm sự quay Nếu (tính > 20) { số lượng = 0; keypressed = 0; editpoint = 76; cho (i = 0; tôi < 7; i ++) //copy hiện nay nhân vật để tạm thời dữ liệu và lưu nó vào EEprom temp_data [i] = bảng chữ cái [ký tự] [i]; Nếu (editkey > 0) { cho)
đang được dịch, vui lòng đợi..
