- #include <STC12C56.H>
- #include <intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar mia,fen,shi,s1num,s;
- uchar dyshu,a3,b3,c3,f2,g2,js1,mc1,m1,count;
- uint dc1,DY,n,mc2;
- unsigned long zc1,zj,dj;
- bit flag,flag2,flag4,flg1;
- float sz[3];
- sbit si = P1^0;
- sbit scl = P1^1;
- sbit ao = P1^2;
- sbit res = P1^3;
- sbit SDA = P2^5;
- sbit SCL = P2^4;
- sbit s1 = P2^1;
- unsigned char code num[] = {
- 0x00,0xF0,0x08,0x04,0x04,0x04,0x08,0xF0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,/*"0",0*/
- 0x00,0x00,0x08,0x08,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,/*"1",1*/
- 0x00,0x30,0x08,0x04,0x04,0x04,0x88,0x70,0x00,0x30,0x28,0x24,0x22,0x21,0x20,0x20,/*"2",2*/
- 0x00,0x10,0x08,0x84,0x84,0x84,0x48,0x30,0x00,0x08,0x10,0x20,0x20,0x20,0x11,0x0E,/*"3",3*/
- 0x00,0x00,0x80,0x60,0x18,0x04,0xFC,0x00,0x00,0x06,0x05,0x04,0x04,0x04,0x3F,0x04,/*"4",4*/
- 0x00,0xFC,0x84,0x44,0x44,0x44,0x84,0x04,0x00,0x09,0x10,0x20,0x20,0x20,0x10,0x0F,/*"5",5*/
- 0x00,0xF0,0x88,0x44,0x44,0x44,0x88,0x10,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,/*"6",6*/
- 0x00,0x04,0x04,0x04,0x84,0x64,0x14,0x0C,0x00,0x00,0x00,0x3C,0x03,0x00,0x00,0x00,/*"7",7*/
- 0x00,0x30,0x48,0x84,0x84,0x84,0x48,0x30,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x0E,/*"8",8*/
- 0x00,0xF0,0x08,0x04,0x04,0x04,0x08,0xF0,0x00,0x08,0x11,0x22,0x22,0x22,0x11,0x0F,/*"9",9*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",10*/
- 0x00,0x00,0x80,0x40,0x40,0x40,0x80,0x00,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,/*"o",11*/
- 0x00,0xFC,0x00,0x00,0x80,0x40,0x20,0x00,0x00,0x3F,0x02,0x05,0x08,0x10,0x20,0x00,/*"k",12*/
- 0x00,0xC0,0x40,0x40,0x80,0x40,0x40,0x80,0x00,0x3F,0x00,0x00,0x3F,0x00,0x00,0x3F,/*"m",13*/
- 0x00,0x00,0x00,0x00,0xC0,0x30,0x0C,0x00,0x00,0x30,0x0C,0x03,0x00,0x00,0x00,0x00,/*"/",14*/
- 0x00,0xFC,0x80,0x40,0x40,0x40,0x80,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x3F,0x00,/*"h",15*/
- 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,/*":",16*/
- 0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x03,0x0C,0x30,0x0C,0x03,0x00,/*"v",17*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,/*".",18*/
- };
-
- unsigned char code num1[] = {
- 0x40,0x20,0xE2,0x04,0x00,0x40,0x20,0x9C,0x82,0x82,0xBE,0x20,0x20,0x00,0x00,0x00,
- 0x00,0x00,0x1F,0x08,0x24,0x20,0x11,0x0A,0x04,0x0A,0x11,0x30,0x20,0x20,0x20,0x00,/*"設(shè)",0*/
- 0x00,0x00,0x00,0x4C,0x54,0x54,0xFA,0xAA,0xAE,0xAA,0x2A,0x26,0x00,0x00,0x00,0x00,
- 0x00,0x20,0x20,0x20,0x20,0x3F,0x2A,0x2A,0x20,0x1F,0x10,0x10,0x10,0x10,0x00,0x00,/*"置",1*/
- 0x00,0xF8,0x48,0x44,0xFC,0x00,0xA0,0x20,0x20,0x20,0xFE,0x10,0x10,0x10,0x00,0x00,
- 0x00,0x0F,0x04,0x04,0x0F,0x00,0x00,0x01,0x10,0x20,0x3F,0x00,0x00,0x00,0x00,0x00,/*"時",2*/
- 0x00,0x00,0x80,0x40,0x20,0x18,0x02,0x82,0x84,0x88,0x10,0x20,0x60,0x40,0x40,0x00,
- 0x01,0x21,0x20,0x11,0x09,0x05,0x13,0x20,0x10,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,/*"分",3*/
- 0x00,0x00,0x00,0xFC,0x04,0xA4,0xA4,0x7A,0x52,0x52,0x42,0x02,0xFE,0x00,0x00,0x00,
- 0x40,0x20,0x18,0x07,0x00,0x06,0x0A,0x09,0x09,0x07,0x20,0x40,0x3F,0x00,0x00,0x00,/*"周",4*/
- 0x00,0x80,0x80,0x80,0x80,0xFE,0xA0,0x50,0x48,0x46,0x40,0x40,0x40,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x3F,0x10,0x09,0x02,0x04,0x08,0x18,0x10,0x10,0x00,0x00,/*"長",5*/
- 0x00,0x00,0xF8,0x24,0xFC,0x00,0x80,0x90,0x10,0xF9,0x82,0x40,0x30,0x00,0x00,0x00,
- 0x10,0x0C,0x03,0x09,0x1F,0x00,0x04,0x03,0x10,0x3F,0x00,0x01,0x02,0x04,0x04,0x00,/*"脈",6*/
- 0x00,0x00,0x08,0x90,0x40,0x00,0xE0,0x20,0x20,0xFF,0x90,0x90,0xD0,0x30,0x00,0x00,
- 0x00,0x04,0x06,0x01,0x00,0x00,0x00,0x01,0x01,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,/*"沖",7*/
- 0x00,0x00,0x10,0x08,0x04,0xF7,0xAC,0xAA,0x8A,0xFA,0x02,0x02,0x00,0x00,0x00,0x00,
- 0x00,0x10,0x10,0x48,0x44,0x27,0x2A,0x12,0x1A,0x26,0x20,0x60,0x40,0x40,0x40,0x00,/*"復(fù)",8*/
- 0x00,0x80,0x40,0xE0,0x1C,0x00,0x40,0x40,0x42,0x24,0xA0,0x20,0x20,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x3F,0x00,0x10,0x10,0x13,0x10,0x0C,0x0B,0x08,0x08,0x08,0x00,0x00,/*"位",9*/
- 0x00,0x00,0x00,0x70,0x92,0xAC,0xA8,0xF8,0xAC,0x8A,0x69,0x18,0x00,0x00,0x00,0x00,
- 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,/*"單",10*/
- 0x00,0x00,0x00,0x00,0xE2,0x24,0x10,0x98,0x94,0xD3,0x30,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x1C,0x00,0x00,0x0D,0x11,0x21,0x24,0x28,0x20,0x28,0x32,0x02,0x04,0x00,0x00,/*"總",11*/
- 0x40,0x40,0x20,0xE4,0x08,0x00,0x00,0xFC,0x2A,0xAA,0xB2,0x4E,0x20,0x00,0x00,0x00,
- 0x00,0x08,0x09,0x0E,0x08,0x08,0x10,0x17,0x12,0x22,0x20,0x21,0x22,0x20,0x20,0x00,/*"退",12*/
- 0x00,0x00,0x00,0xF0,0x80,0x80,0x80,0xFE,0x40,0x40,0x40,0xF0,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x1C,0x10,0x10,0x10,0x1F,0x08,0x08,0x08,0x3C,0x00,0x00,0x00,0x00,/*"出",13*/
- 0x00,0x00,0x98,0x48,0x28,0x48,0x95,0x46,0x24,0x14,0x84,0x24,0x4C,0x40,0x00,0x00,
- 0x00,0x04,0x04,0x04,0x7A,0x41,0x40,0x3D,0x21,0x21,0x21,0x79,0x00,0x00,0x00,0x00,/*"密",14*/
- 0x00,0x00,0x08,0xC8,0xB8,0x84,0x04,0x80,0x74,0x04,0xA2,0x9E,0x80,0x80,0x00,0x00,
- 0x04,0x02,0x01,0x07,0x02,0x03,0x04,0x05,0x05,0x05,0x02,0x12,0x20,0x1F,0x00,0x00,/*"碼",15*/
- //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- //0x40,0xC0,0x40,0x40,0x40,0x60,0x1C,0x03,0x1C,0x60,0x40,0x40,0x40,0xC0,0x40,0x00,
- //0x00,0x00,0x41,0x39,0x26,0x10,0x10,0x08,0x08,0x10,0x26,0x39,0x41,0x00,0x00,0x00,/*"☆",17*/
- };
- unsigned char code num2[] = {
- 0x00,0x00,0xC0,0xF0,0xF8,0x3C,0x1E,0x0E,0x0E,0x1C,0x7C,0xF8,0xE0,0x80,0x00,0x00,
- 0x00,0xFC,0xFF,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF0,0x00,
- 0x00,0x7F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0x1F,0x00,
- 0x00,0x00,0x07,0x1F,0x3F,0x78,0x70,0xE0,0xE0,0x70,0x7C,0x3F,0x0F,0x03,0x00,0x00,/*"0",0*/
- 0x00,0x00,0x00,0xC0,0xE0,0xE0,0xE0,0xF8,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,/*"1",1*/
- 0x00,0x00,0x80,0xF0,0xF8,0x3C,0x1E,0x0E,0x0E,0x1E,0x3C,0xF8,0xF0,0xC0,0x00,0x00,
- 0x00,0x00,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x80,0xE0,0xFF,0x7F,0x0F,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0x7C,0x3E,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,
- 0x00,0xE0,0xF8,0xFE,0xFF,0xE7,0xE1,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0x00,0x00,/*"2",2*/
- 0x00,0x00,0xC0,0xF0,0xF8,0x3C,0x0E,0x0E,0x0E,0x1E,0x3C,0xF8,0xF0,0x80,0x00,0x00,
- 0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x80,0xC0,0xC0,0xF0,0x7F,0x3F,0x07,0x00,0x00,
- 0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x03,0x07,0xFE,0xFC,0xF0,0x00,0x00,
- 0x00,0x01,0x0F,0x3F,0x7C,0x70,0xF0,0xE0,0xE0,0x70,0x78,0x3F,0x1F,0x07,0x00,0x00,/*"3",3*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xFE,0xFE,0xFE,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x80,0xE0,0xF8,0x3F,0x0F,0x01,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0xFC,0xFF,0xCF,0xC1,0xC0,0xC0,0xC0,0xFF,0xFF,0xFF,0xC0,0xC0,0xC0,0x00,
- 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0xFF,0x01,0x01,0x01,0x00,/*"4",4*/
- 0x00,0x00,0x00,0xFE,0xFE,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x00,0x00,
- 0x00,0x00,0xF0,0xFF,0xFF,0xE0,0x60,0x70,0x70,0x70,0xF0,0xE0,0xC0,0x00,0x00,0x00,
- 0x00,0x80,0x83,0x83,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,
- 0x00,0x01,0x0F,0x3F,0x7C,0x70,0xE0,0xE0,0xE0,0x70,0x7C,0x3F,0x0F,0x03,0x00,0x00,/*"5",5*/
- 0x00,0x00,0x00,0xC0,0xF0,0xF8,0x3C,0x1E,0x0E,0x0E,0x1E,0xFC,0xF8,0xE0,0x00,0x00,
- 0x00,0x00,0xFE,0xFF,0xFF,0xC1,0xE0,0x70,0x70,0x70,0xF0,0xE0,0xC0,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,
- 0x00,0x00,0x01,0x0F,0x3F,0x7C,0x70,0xE0,0xE0,0xE0,0x78,0x3F,0x1F,0x07,0x00,0x00,/*"6",6*/
- 0x00,0x00,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0xFE,0xFE,0x3E,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0x7F,0x07,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFE,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0xC0,0xFC,0xFF,0x1F,0x01,0x00,0x00,0x00,0x00,0x00,0x00,/*"7",7*/
- 0x00,0x00,0xC0,0xF0,0xF8,0x1C,0x0E,0x0E,0x0E,0x1E,0x3C,0xF8,0xF0,0x80,0x00,0x00,
- 0x00,0x00,0x1F,0x3F,0xFF,0xE0,0xC0,0x80,0x80,0xC0,0xE0,0x7F,0x3F,0x0F,0x00,0x00,
- 0x00,0xC0,0xF8,0xFE,0x1E,0x07,0x03,0x01,0x03,0x03,0x07,0xFE,0xFC,0xF8,0x00,0x00,
- 0x00,0x01,0x0F,0x3F,0x7E,0x70,0xE0,0xE0,0xE0,0xF0,0x78,0x7F,0x1F,0x0F,0x00,0x00,/*"8",8*/
- 0x00,0x00,0xC0,0xF0,0xF8,0x3C,0x0E,0x0E,0x0E,0x1C,0x7C,0xF8,0xE0,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFE,0x00,0x00,
- 0x00,0x00,0x03,0x07,0x1F,0x1E,0x1C,0x38,0x1C,0x1C,0x07,0xFF,0xFF,0x7F,0x00,0x00,
- 0x00,0x00,0x0E,0x3E,0x7E,0x70,0xE0,0xE0,0x70,0x78,0x3F,0x1F,0x07,0x00,0x00,0x00,/*"9",9*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
- unsigned char code num3[] = {
- 0xFE,0x02,0x13,0x3B,0x13,0x02,0x02,0x02,0x02,0x82,0xC2,0xE2,0x82,0x82,0x42,0x22,
- 0x02,0x02,0x02,0x13,0x13,0x13,0x02,0xFE,0x1F,0x10,0x10,0x10,0x10,0x10,0x10,0x12,
- 0x11,0x10,0x10,0x13,0x11,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,/*"未命名文件",0*/
- };
-
- unsigned char code num4[] = {
- 0x00,0xC0,0xF8,0x3C,0x0E,0x03,0x03,0x03,0x03,0x06,0x3C,0xF8,0xC0,0x00,
- 0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,
- 0x00,0x01,0x0F,0x1E,0x38,0x60,0x60,0x60,0x60,0x30,0x1E,0x0F,0x01,0x00,/*"0",0*/
- 0x00,0x00,0x00,0x30,0x30,0x38,0xFC,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,/*"1",1*/
- 0x00,0xF0,0xFC,0x0E,0x07,0x03,0x03,0x03,0x03,0x0E,0xFC,0xF8,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,0x1E,0x07,0x03,0x00,0x00,
- 0x00,0x70,0x7C,0x7E,0x6F,0x63,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,/*"2",2*/
- 0x00,0x70,0x7C,0x0E,0x07,0x03,0x03,0x03,0x03,0x06,0xFC,0xF8,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x1E,0x3F,0xF3,0xE1,0x00,0x00,
- 0x00,0x07,0x1F,0x38,0x70,0x60,0x60,0x60,0x70,0x38,0x1F,0x07,0x00,0x00,/*"3",3*/
- 0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0x3C,0x0F,0xFF,0xFF,0x00,0x00,0x00,
- 0x00,0xC0,0xF0,0xBC,0x8F,0x83,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x00,
- 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x7F,0x7F,0x01,0x01,0x00,/*"4",4*/
- 0x00,0x00,0xC0,0xFF,0x3F,0x83,0x83,0x83,0x83,0x03,0x03,0x03,0x00,0x00,
- 0x00,0x00,0x0F,0x0F,0x07,0x03,0x01,0x01,0x01,0x07,0xFE,0xF8,0x00,0x00,
- 0x00,0x0E,0x3E,0x70,0xE0,0xC0,0xC0,0xC0,0x60,0x78,0x1F,0x07,0x00,0x00,/*"5",5*/
- 0x00,0x00,0x80,0xF8,0x7C,0x0E,0x07,0x03,0x03,0x03,0x06,0x1E,0x18,0x00,
- 0x00,0x00,0xFF,0xFF,0x0C,0x06,0x03,0x03,0x03,0x07,0x0E,0xFC,0xF0,0x00,
- 0x00,0x00,0x01,0x0F,0x3C,0x30,0x60,0x60,0x60,0x70,0x38,0x1F,0x07,0x00,/*"6",6*/
- 0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0xF3,0xFF,0x0F,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0x1F,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x60,0x7E,0x1F,0x01,0x00,0x00,0x00,0x00,0x00,/*"7",7*/
- 0x00,0x00,0xF8,0xFE,0x06,0x03,0x03,0x03,0x06,0xFE,0xF8,0x00,0x00,0x00,
- 0x00,0xC0,0xF1,0x3B,0x1E,0x0C,0x0C,0x0C,0x1E,0x3B,0xF1,0xC0,0x00,0x00,
- 0x00,0x0F,0x1F,0x38,0x70,0x60,0x60,0x60,0x70,0x38,0x1F,0x0F,0x00,0x00,/*"8",8*/
- 0x00,0xF0,0xFC,0x0E,0x07,0x03,0x03,0x03,0x06,0x0E,0xF8,0xE0,0x00,0x00,
- 0x00,0x07,0x0F,0x1C,0x30,0x30,0x30,0x30,0x18,0x0C,0xFF,0xFF,0x00,0x00,
- 0x00,0x0C,0x3C,0x30,0x60,0x60,0x60,0x70,0x38,0x1F,0x0F,0x00,0x00,0x00,/*"9",9*/
- } ;
- ///////////////////////////////////////////////////////////////////////////
- void delay2(uint z)
- {
- uint y;
- for(z;z>0;z--)
- for(y=440;y>0;y--);
- }
- void Wait2us() //誤差 0us
- {
- uchar a;
- for(a=8;a>0;a--);
- }
- void Wait4us() //誤差 0us
- {
- Wait2us();
- Wait2us();
- }
- /////////////////////////////////////////////////////////////////////////// 液晶
- void write_com(uchar w_command)
- {
- uchar counter_8;
- ao=0; //指令
- for(counter_8=0;counter_8!=8;counter_8++)
- {
- scl=1;
- Wait2us();
- w_command<<=1; //取8次,溢出在CY
- si=CY;
- Wait2us();
- scl=0;
- }
- scl=1;
- Wait2us();
- si=1;
- }
-
- void write_date(uchar w_data) //2寫數(shù)據(jù)
- {
- uchar counter_8;
- ao=1;
- for(counter_8=0;counter_8!=8;counter_8++)
- {
- scl=1;
- Wait2us();
- w_data<<=1; //取8次,溢出 在CY
- si=CY;
- Wait2us();
- scl=0;
- }
- scl=1;
- Wait2us();
- si=1;
- }
- void LcmClear( void )
- {
- uchar i,j;
- for(i=0;i<8;i++)
- {
- write_com(0xB0|i); //Set Page Address as ComTable
- write_com(0x10); //Set Column Address = 0
- write_com(0x00); //Colum from 1 -> 129 auto add
- for(j=0;j<132;j++)
- write_date( 0 );
- }
- }
- void LcmPutChar(uchar col,uchar page,uchar p) //這里我不用x y做參數(shù),是更貼切一些,實際上就是列值(橫坐標)0-127,頁值(縱坐標)0-7
- {
- uchar i;
- uint x;
- x=p*16;
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address High Byte
- write_com( col&0x0F ); //Low Byte Colum from 1 -> 129auto add
- for(i=0;i<8;i++)
- {
- write_date( num[x] );
- x++;
- }
- page++; //下半字符page+1
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address HighByte
- write_com( col&0x0F ); //Low Byte Colum from 1 ->129 auto add
- for(i=0;i<8;i++)
- {
- write_date( num[x] );
- x++;
- }
- page--; //寫完一個字符page還原
- }
- void LcmPutChar1(uchar col,uchar page,uchar p) //這里我不用x y做參數(shù),是更貼切一些,實際上就是列值(橫坐標)0-127,頁值(縱坐標)0-7
- {
- uchar i;
- uint x;
- x=p*64;
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address High Byte
- write_com( col&0x0F ); //Low Byte Colum from 1 -> 129auto add
- for(i=0;i<16;i++)
- {
- write_date( num2[x] );
- x++;
- }
- page++; //下半字符page+1
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address HighByte
- write_com( col&0x0F ); //Low Byte Colum from 1 ->129 auto add
- for(i=0;i<16;i++)
- {
- write_date( num2[x] );
- x++;
- }
- page++; //下半字符page+1
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address HighByte
- write_com( col&0x0F ); //Low Byte Colum from 1 ->129 auto add
- for(i=0;i<16;i++)
- {
- write_date( num2[x] );
- x++;
- }
- page++; //下半字符page+1
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address HighByte
- write_com( col&0x0F ); //Low Byte Colum from 1 ->129 auto add
- for(i=0;i<16;i++)
- {
- write_date( num2[x] );
- x++;
- }
- page-=3; //寫完一個字符page還原
- }
- void LcmPutChar2(uchar col,uchar page,uchar p) //這里我不用x y做參數(shù),是更貼切一些,實際上就是列值(橫坐標)0-127,頁值(縱坐標)0-7
- {
- uchar i;
- uint x;
- x=p*32;
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address High Byte
- write_com( col&0x0F ); //Low Byte Colum from 1 -> 129auto add
- for(i=0;i<16;i++)
- {
- write_date( num1[x] );
- x++;
- }
- page++; //下半字符page+1
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address HighByte
- write_com( col&0x0F ); //Low Byte Colum from 1 ->129 auto add
- for(i=0;i<16;i++)
- {
- write_date( num1[x] );
- x++;
- }
- page--; //寫完一個字符page還原
- }
- void LcmPutChar3(uchar col,uchar page,uchar p) //這里我不用x y做參數(shù),是更貼切一些,實際上就是列值(橫坐標)0-127,頁值(縱坐標)0-7
- {
- uchar i;
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address High Byte
- write_com( col&0x0F ); //Low Byte Colum from 1 -> 129auto add
- for(i=0;i<24;i++)
- {
- write_date( num3[p] );
- p++;
- }
- page++; //下半字符page+1
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address HighByte
- write_com( col&0x0F ); //Low Byte Colum from 1 ->129 auto add
- for(i=0;i<24;i++)
- {
- write_date( num3[p] );
- p++;
- }
- page--; //寫完一個字符page還原
- }
- void LcmPutChar4(uchar col,uchar page,uchar p) //這里我不用x y做參數(shù),是更貼切一些,實際上就是列值(橫坐標)0-127,頁值(縱坐標)0-7
- {
- uchar i;
- uint x;
- x=p*42;
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address High Byte
- write_com( col&0x0F ); //Low Byte Colum from 1 -> 129auto add
- for(i=0;i<14;i++)
- {
- write_date( num4[x] );
- x++;
- }
- page++; //下半字符page+1
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address HighByte
- write_com( col&0x0F ); //Low Byte Colum from 1 ->129 auto add
- for(i=0;i<14;i++)
- {
- write_date( num4[x] );
- x++;
- }
- page++; //下半字符page+1
- write_com(page|0xB0); //Set Page Address
- write_com( (col>>4) | 0x10); //Set Column Address HighByte
- write_com( col&0x0F ); //Low Byte Colum from 1 ->129 auto add
- for(i=0;i<14;i++)
- {
- write_date( num4[x] );
- x++;
- }
- page-=2; //寫完一個字符page還原
- }
- ////////////////////////////////////////////////////////////////////////////// DS1307
- void I2C_start(void)
- {
- SDA=1;
- SCL=1;
- Wait4us();
- SDA=0;
- Wait4us();
- SCL=0;
- }
- void I2C_stop(void)
- {
- SDA=0;
- SCL=1;
- Wait4us();
- SDA=1;
- Wait4us();
- SCL=0;
- }
- void I2C_send_noack(void)
- {
- SDA=1;
- SCL=1;
- Wait4us();
- SCL=0;
- }
- unsigned char I2C_write_byte(unsigned char IIC_data)
- {
- unsigned char i;
- for(i=0;i<8;i++)
- {
- Wait4us();
- IIC_data=IIC_data<<1;
- F0=SDA=CY;
- SCL=1;
- if(F0!=SDA)
- {
- SCL=0; return 0;
- }
- Wait4us();
- SCL=0;
- }
- SDA=1;
- Wait4us();
- SCL=1;
- Wait4us();
- if(SDA==1)
- {
- SCL=0; return 0;
- }
- else
- {
- SCL=0; return 1;
- }
- }
- unsigned char I2C_read_byte(void)
- {
- unsigned char i,dat;
- dat=0;
- SDA=1;
- for (i=0;i<8;i++)
- {
- Wait4us();
- dat=dat<<1;
- SCL=1;
- Wait4us();
- if(SDA==1)
- dat++;
- SCL=0;
- }
- return (dat);
- }
- void Write1307(unsigned char add,unsigned char dat)
- {
- unsigned char temp;
- temp=dat/10;
- temp<<=4;
- temp=dat%10+temp;
- I2C_start();
- I2C_write_byte(0xd0);
- I2C_write_byte(add);
- I2C_write_byte(temp);
- I2C_stop();
- }
- /***********************************************************************/
- unsigned char Read1307(unsigned char add)
- {
- unsigned char temp,dat;
- I2C_start();
- I2C_write_byte(0xd0);
- I2C_write_byte(add);
- I2C_start();
- I2C_write_byte(0xd1);
- dat=I2C_read_byte();
- I2C_send_noack();
- I2C_stop();
- temp=dat/16;
- dat=dat%16;
- dat=dat+temp*10;
- return (dat);
- }
- uint get_AD(uchar channel) // AD轉(zhuǎn)換程序
- {
- ADC_DATA=0;
- channel&=0x07; //0000,0111 清0高5位
- delay2(1);
- ADC_CONTR=0xE0; //1110,0000 清 ADC_FLAG, ADC_START 位和低 3 位
- ADC_CONTR|=channel; //選擇 A/D 當前通道
- delay2(1); //使輸入電壓達到穩(wěn)定
- ADC_CONTR|=0x08; //0000,1000 令 ADCS = 1, 啟動A/D轉(zhuǎn)換,
- while (1) //等待A/D轉(zhuǎn)換結(jié)束
- {
- if (ADC_CONTR&0x10) //0001,0000 測試A/D轉(zhuǎn)換結(jié)束否
- break;
- }
- ADC_CONTR &= 0xE7; //1111,0111 清 ADC_FLAG 位, 關(guān)閉A/D轉(zhuǎn)換,
- return (ADC_DATA<<2|ADC_LOW2); //返回 A/D 10 位轉(zhuǎn)換結(jié)果
- }
- void key_scan()
- {
- bit flg;
- if(flg1==1)
- {
- if(s1num==0)
- {
- if(s1==0)
- {
- delay2(10);
- if(s1==0)
- {
- s1num++;
- while(!s1);
- }
- }
- }
- }
- /*************************************************/
- if(s1num==1)
- {
- fen=Read1307(0x01);
- LcmPutChar2(15,4,2);
- LcmPutChar2(32,4,3);
- LcmPutChar(68,4,fen/10);
- LcmPutChar(78,4,fen%10);
- if(s1==0)
- {
- delay2(10);
- if(s1==0)
- {
- m1=0;
- while(!s1)
- {
- if(m1>=20)
- {
- flg=1;
- while(!s1)
- {
- fen++;
- if(fen==60)
- fen=0;
- LcmPutChar(68,4,fen/10);
- LcmPutChar(78,4,fen%10);
- delay2(900);
- }
- }
- }
- if(flg==0)
- s1num++;
- }
- }
- if (flg==1)
- {
- flg=0;
- Write1307(0x00,0);//寫入秒
- Write1307(0x01,fen);//寫入分
- }
- }
- /*****************************************/
- if(s1num==2)
- {
- shi=Read1307(0x02);
- LcmPutChar2(15,4,2);
- LcmPutChar2(32,4,2);
- LcmPutChar(68,4,shi/10);
- LcmPutChar(78,4,shi%10);
- if(s1==0)
- {
- delay2(10);
- if(s1==0)
- {
- m1=0;
- while(!s1)
- {
- if(m1>=20)
- {
- flg=1;
- while(!s1)
- {
- shi++;
- if(shi==24)
- shi=0;
- LcmPutChar(68,4,shi/10);
- LcmPutChar(78,4,shi%10);
- delay2(900);
- }
- }
- }
- if(flg==0)
- s1num++;
- }
- }
- if (flg==1)
- {
- flg=0;
- Write1307(0x00,0);//寫入秒
- Write1307(0x02,shi);//寫入時
- }
- }
- /**********************************************/
- if(s1num==3)
- {
- a3=Read1307(0x08);
- b3=Read1307(0x09);
- c3=Read1307(0x0a);
- LcmPutChar2(15,4,4);
- LcmPutChar2(32,4,5);
- LcmPutChar(68,4,a3);
- LcmPutChar(78,4,b3);
- LcmPutChar(88,4,c3);
- js1=(a3*100)+(b3*10)+c3;
- if(s1==0)
- {
- delay2(10);
- if(s1==0)
- {
- m1=0;
- while(!s1)
- {
- if(m1>=20)
- {
- flg=1;
- while(!s1)
- {
- js1++;
- if(js1==151)
- js1=100;
- LcmPutChar(68,4,js1/100);
- LcmPutChar(78,4,js1%100/10);
- LcmPutChar(88,4,js1%10);
- delay2(900);
- }
- }
- }
- if(flg==0)
- s1num++;
- }
- }
- if (flg==1)
- {
- flg=0;
- Write1307(0x08,js1/100);
- Write1307(0x09,js1%100/10);
- Write1307(0x0a,js1%10);
- }
- }
- /*********************************************/
- if(s1num==4)
- {
- f2=Read1307(0x19);
- g2=Read1307(0x1a);
- LcmPutChar2(15,4,6);
- LcmPutChar2(32,4,7);
- LcmPutChar(88,4,10);
- LcmPutChar(68,4,f2);
- LcmPutChar(78,4,g2);
- mc1=(f2*10)+g2;
- if(s1==0)
- {
- delay2(10);
- if(s1==0)
- {
- m1=0;
- while(!s1)
- {
- if(m1>=20)
- {
- flg=1;
- while(!s1)
- {
- mc1++;
- if(mc1==41)
- mc1=15;
- LcmPutChar(68,4,mc1/10);
- LcmPutChar(78,4,mc1%10);
- delay2(900);
- }
- }
- }
- if(flg==0)
- s1num++;
- }
- }
- if (flg==1)
- {
- flg=0;
- Write1307(0x19,mc1/10);
- Write1307(0x1a,mc1%10);
- }
- }
- /*****************************************/
- if(s1num==5)
- {
- LcmPutChar2(15,4,8);
- LcmPutChar2(32,4,9);
- LcmPutChar(68,4,10);
- LcmPutChar(78,4,10);
- if(s1==0)
- {
- delay2(10);
- if(s1==0)
- {
- m1=0;
- while(!s1)
- {
- if(m1>=20)
- {
- flg=1;
- Write1307(0x00,0);//寫入秒
- Write1307(0x01,0);//寫入分
- Write1307(0x02,0);//寫入時
- Write1307(0x03,0);//寫入星期
- Write1307(0x04,0);//寫入日期
- Write1307(0x05,0);//寫入月
- Write1307(0x06,0);//寫入年
- Write1307(0x07,10);
- /*************************/
- Write1307(0x14,0);
- Write1307(0x15,0);
- Write1307(0x16,0);
- Write1307(0x17,0);
- /*************************/
- Write1307(0x0c,1);
- Write1307(0x0d,2);
- Write1307(0x0e,0);
- Write1307(0x0f,0);
- Write1307(0x10,0);
- Write1307(0x11,0);
- /*************************/
- Write1307(0x08,1);
- Write1307(0x09,3);
- Write1307(0x0a,0);
- /*************************/
- Write1307(0x19,2);
- Write1307(0x1a,8);
- LcmPutChar(68,4,11);
- LcmPutChar(78,4,12);
- while(!s1);
- }
- }
- if(flg==0)
- s1num++;
- }
- }
- flg=0;
- }
- /***************************************/
- if(s1num==6)
- {
- LcmPutChar2(15,4,12);
- LcmPutChar2(32,4,13);
- LcmPutChar(68,4,10);
- LcmPutChar(78,4,10);
- if(s1==0)
- {
- delay2(10);
- if(s1==0)
- {
- m1=0;
- while(!s1)
- {
- if(m1>=20)
- {
- flg=1;
- flag4=0;
- LcmPutChar(68,4,11);
- LcmPutChar(78,4,12);
- while(!s1);
- }
- }
- if(flg==0)
- {
- s1num=0;
- flg1=0;
- // LcmPutChar2(15,4,16);
- // LcmPutChar2(32,4,16);
- }
- }
- }
- }
- }
-
- void key1_scan()
- {
- if(s1==0)
- {
- delay2(10);
- if(s1==0)
- {
- flag4=1;
- LcmPutChar2(40,1,0);
- LcmPutChar2(70,1,1);
- LcmPutChar2(15,4,14);
- LcmPutChar2(32,4,15);
- while(!s1);
- }
- }
- while(flag4!=0)
- {
- if(flg1==0)
- {
- LcmPutChar2(15,4,14);
- LcmPutChar2(32,4,15);
- if(s1==0)
- {
- delay2(10);
- if(s1==0)
- {
- m1=0;
- while(!s1)
- {
- if(m1>=20)
- {
- flg1=1;
- LcmPutChar(68,4,11);
- LcmPutChar(78,4,12);
- while(!s1);
- }
- }
- if(flg1==0)
- {
- flg1=1;
- s1num=6;
- }
- }
- }
- }
- key_scan();
- }
- }
- void dc_clear()
- {
- if(s1==0)
- {
- delay2(20);
- if(s1==0)
- {
- m1=0;
- while(!s1)
- {
- if(m1>=20)
- {
- dc1=0;
- dj=0;
- delay2(1);
- Write1307(0x14,0);
- delay2(1);
- Write1307(0x15,0);
- delay2(1);
- Write1307(0x16,0);
- delay2(1);
- Write1307(0x17,0);
- delay2(1);
- break;
- }
- }
- }
- }
- }
- //////////////////////////////////////////////////////////////////////////
- void sys_init()
- {
-
- // P1M0=0x8f;
- // P1M1=0x8f;
- AUXR&=0xBF;
- TMOD=0X15;//設(shè)T0,T1為計數(shù)
- TL0=0xff;
- TH0=0xff;
- TH1=0x3c;
- TL1=0xb0;
- EA=1;
- TR0=1;
- TR1=1;
- ET0=1;
- ET1=1;
- }
- void lcd_init () //3初始化
- {
- res=0; //1復(fù)位
- delay2(100);
- res=1;
- delay2(300);
- write_com(0xe2); //復(fù)位指令 E2H
- delay2(100);
- write_com(0x40); // 顯示起始行設(shè)置 40H-7FH
- write_com(0xa0); // 列驅(qū)動方向設(shè)置 A0H/A1H
- write_com(0xc8); // 行驅(qū)動輸出順序設(shè)置 C0H/C8H
- write_com(0xa6); // 正/負向顯示設(shè)置 A6H/A7H
- write_com(0xa3); // LCD偏壓設(shè)置 A2H/A3H
- write_com(0x25); // V0 電壓電阻比率設(shè)置 20H~27H
- delay2(30);
- write_com(0x81); // 對比度設(shè)置
- write_com(0x05); // 對比度數(shù)值 (00H-3FH)
- write_com(0x2c); // 電源控制器設(shè)置 升壓電路啟動
- delay2(50);
- write_com(0x2e); //升壓電路啟動 電壓調(diào)節(jié)器啟動
- delay2(50);
- write_com(0x2f); //升壓電路啟動 電壓調(diào)節(jié)器啟動 電壓跟隨器啟動
- delay2(50);
-
- write_com(0xf8); // 倍壓電路設(shè)置 (00H/01H/03H)
- write_com(0x00); // 倍壓級2X、3X、4X
- write_com(0xa4); // 正常顯示
- write_com(0xaf); // 打開顯示開關(guān)
- }
-
- void xshi_init()
- {
- unsigned long b1,c1;
- uint d1,e1,b2,c2;
- uchar f1,g1,d2,e2;
- LcmPutChar(83,0,16); //時鐘標記
- LcmPutChar(104,0,16);
- // LcmPutChar(68,0,8);
- // LcmPutChar(76,0,8);
- // LcmPutChar(89,0,8);
- // LcmPutChar(97,0,8);
- // LcmPutChar(110,0,8);
- // LcmPutChar(118,0,8);
- ////////////////////////////////////////
- LcmPutChar3(8,3,0); //電池標記
- LcmPutChar(19,0,18);
- // LcmPutChar(2,0,2);
- // LcmPutChar(10,0,2);
- // LcmPutChar(23,0,9);
- LcmPutChar(35,0,17);
- ///////////////////////////////////////////
- LcmPutChar(94,4,12); //速度標記
- LcmPutChar(102,4,13);
- LcmPutChar(110,4,14);
- LcmPutChar(118,4,15);
- LcmPutChar(75,4,18);
- // LcmPutChar1(40,2,8); //改
- // LcmPutChar1(58,2,8); //改
- // LcmPutChar4(78,3,8);
- ////////////////////////////////////////////////////
- LcmPutChar(107,6,18);
- LcmPutChar2(75,6,10); //單程標記
- // LcmPutChar(90,6,0);
- // LcmPutChar(98,6,0);
- // LcmPutChar(111,6,0);
- // LcmPutChar(119,6,0);
- //////////////////////////////////////////////////////
- LcmPutChar(49,6,18);
- // LcmPutChar(16,6,0);
- // LcmPutChar(24,6,0); //總程標記
- // LcmPutChar(32,6,0);
- // LcmPutChar(40,6,0);
- LcmPutChar2(0,6,11);
- // LcmPutChar(53,6,0);
- // LcmPutChar(61,6,0);
- a3=Read1307(0x08);
- b3=Read1307(0x09);
- c3=Read1307(0x0a);
-
- b1=Read1307(0x0c);
- c1=Read1307(0x0d);
- d1=Read1307(0x0e);
- e1=Read1307(0x0f);
- f1=Read1307(0x10);
- g1=Read1307(0x11);
- b2=Read1307(0x14);
- c2=Read1307(0x15);
- d2=Read1307(0x16);
- e2=Read1307(0x17);
- f2=Read1307(0x19);
- g2=Read1307(0x1a);
- zc1=(b1*100000)+(c1*10000)+(d1*1000)+(e1*100)+(f1*10)+g1;
- dc1=(b2*1000)+(c2*100)+(d2*10)+e2;
- js1=(a3*100)+(b3*10)+c3;
- mc1=(f2*10)+g2;
- }
- void display1307()
- {
- mia=Read1307(0x00);
- fen=Read1307(0x01);
- shi=Read1307(0x02);
- if(shi/10)
- LcmPutChar(68,0,shi/10);
- else
- LcmPutChar(68,0,10);
- LcmPutChar(76,0,shi%10);
- LcmPutChar(89,0,fen/10);
- LcmPutChar(97,0,fen%10);
- LcmPutChar(110,0,mia/10);
- LcmPutChar(118,0,mia%10);
- }
- void display_LC()
- {
- unsigned long zc ;
- uchar b,c,d,e,f,g,b4,c4,d4,e4;
- uint dc;
- /**************************/
- if(zc>=1000000)
- zc=0;
- if(dc>=10000)
- dc=0;
- zc=zc1+(zj*(js1*0.001));
- b=zc/100000;
- c=zc%100000/10000;
- d=zc%10000/1000;
- e=zc%1000/100;
- f=zc%100/10;
- g=zc%10;
- /***********************/
-
- dc=dc1+(dj*(js1*0.001));
- b4=dc%10000/1000;
- c4=dc%1000/100;
- d4=dc%100/10;
- e4=dc%10;
- if((m1>=20)&&(n>=5))
- {
- m1=0;
- Write1307(0x0c,0);
- delay2(1);
- Write1307(0x0d,0);
- delay2(1);
- Write1307(0x0e,0);
- delay2(1);
- Write1307(0x0f,0);
- delay2(1);
- Write1307(0x10,0);
- delay2(1);
- Write1307(0x11,0);
- delay2(1);
- Write1307(0x0c,b);
- delay2(1);
- Write1307(0x0d,c);
- delay2(1);
- Write1307(0x0e,d);
- delay2(1);
- Write1307(0x0f,e);
- delay2(1);
- Write1307(0x10,f);
- delay2(1);
- Write1307(0x11,g);
- delay2(1);
- Write1307(0x14,0);
- delay2(1);
- Write1307(0x15,0);
- delay2(1);
- Write1307(0x16,0);
- delay2(1);
- Write1307(0x17,0);
- delay2(1);
- Write1307(0x14,b4);
- delay2(1);
- Write1307(0x15,c4);
- delay2(1);
- Write1307(0x16,d4);
- delay2(1);
- Write1307(0x17,e4);
- delay2(1);
- }
- if(b!=0)
- {
- LcmPutChar(16,6,b);
- LcmPutChar(24,6,c);
- LcmPutChar(32,6,d);
- LcmPutChar(40,6,e);
- LcmPutChar(53,6,f);
- LcmPutChar(61,6,g);
- }
- else
- {
- LcmPutChar(16,6,10);
-
- if(c!=0)
- {
- LcmPutChar(24,6,c);
- LcmPutChar(32,6,d);
- LcmPutChar(40,6,e);
- LcmPutChar(53,6,f);
- LcmPutChar(61,6,g);
- }
- else
- {
- LcmPutChar(24,6,10);
-
- if(d!=0)
- {
- LcmPutChar(32,6,d);
- LcmPutChar(40,6,e);
- LcmPutChar(53,6,f);
- LcmPutChar(61,6,g);
- }
- else
- LcmPutChar(32,6,10);
- LcmPutChar(40,6,e);
- LcmPutChar(53,6,f);
- LcmPutChar(61,6,g);
- }
- }
- if(b4!=0)
- LcmPutChar(90,6,b4);
- else
- LcmPutChar(90,6,10);
- LcmPutChar(98,6,c4);
- LcmPutChar(111,6,d4);
- LcmPutChar(119,6,e4);
- }
- void display_shudu()
- {
- float m;
- if(flag==1)
- {
- flag=0;
- // m=((js1*1.0)/mc1)*mc2*3.6/10;
- m=((js1*1.0)/mc1)*mc2*7.2/10;
- sz[s]=m;
- count=0;
- mc2=0;
- s++;
- }
- if(s>=3)
- {
- s=0;
- m=sz[0]+sz[1]+sz[2];
- m=m/3;
- n=(int)m;
- sz[0]=0;
- sz[1]=0;
- sz[2]=0;
- if(n/100)
- LcmPutChar1(40,2,n%1000/100);
- else
- LcmPutChar1(40,2,10);
- LcmPutChar1(58,2,n%100/10);
- LcmPutChar4(78,3,n%10);
- if(n>=5)
- flag2=1;
- if(n<=5)
- flag2=0;
- if(flag2==0)
- m=0;
- }
- }
- void display_DY()
- {
- DY=get_AD(7);
- if(dyshu>=40)
- {
- dyshu=0;
- LcmPutChar(2,0,DY/100);
- LcmPutChar(10,0,DY%100/10);
- LcmPutChar(23,0,DY%10);
- }
- dc_clear();
- }
- void main()
- {
-
- lcd_init();
- delay2(200);
- LcmClear();
- sys_init();
- key1_scan();
- LcmClear();
- xshi_init();
- while(1)
- {
- display1307();
- display_LC();
- display_shudu();
- display_DY();
- }
- }
-
- void T0_time()interrupt 1//總程中斷計數(shù)
- {
- uchar mc;
- TH0=0xff;
- TL0=0xff;
- mc++;
- mc2++;
- if(mc>=mc1)
- {
- mc=0;
- zj++;
- dj++;
- }
- }
- void timer0() interrupt 3
- {
- TH1=0x3c;
- TL1=0xb0;
- count++;
- if(count==10)
- flag=1;
- m1++;
- dyshu++;
- }
復(fù)制代碼 |