📄 123.c
字号:
#include <reg52.h>
#include "define.h"
#include "asc_zimo.h"
#include "Hz_zimo.h"
#include "lcd.c"
#include "touch.c"
#include "liu.c"
#include "t18b20.c"
uint T_x = 3;
uint T_y = 4;
static unsigned char time[7]={0x00,0x55,0x13,0x07,0x05,0x3,0x08};
void set_time(unsigned char *time)
{
static unsigned char i=0,j,time_s[12];
static unsigned int color[12];
while(!touch_INT);//有触摸touch_INT=0;
while(1)
{
if(touch_INT==0)
{
touch_GetAdXY(&T_x, &T_y);
if((T_x<900)&&(T_x>400)&&(T_y<1120)&&(T_y>260))
{
time[0] = time_s[0]|(time_s[1]<<4);
time[1] = time_s[2]|(time_s[3]<<4);
time[2] = time_s[4]|(time_s[5]<<4);
time[3] = time_s[6]|(time_s[7]<<4);
time[4] = time_s[8]|(time_s[9]<<4);
time[6] = time_s[10]|(time_s[11]<<4);
Set1302(time);
return;
}
if((T_x<900)&&(T_x>400)&&(T_y<2500)&&(T_y>1500))
i++;
if((T_x<900)&&(T_x>400)&&(T_y<3700)&&(T_y>2800))
time_s[i]++;
if(i>=12)
i = 0;
if(time_s[i]>=10)
time_s[i] = 0;
}
for(j=0;j<12;j++)
{
color[j] = 0x333333;
color[i] = 0xff;
}
DisNum(220, 230, time_s[0], color[0]);//秒,个位
DisNum(212, 230, time_s[1], color[1]);//秒,十位
DisNum(196,230,time_s[2], color[2]); //分,个位
DisNum(188,230,time_s[3], color[3]); //分,十位
DisNum(172,230,time_s[4], color[4]); //小时,个位
DisNum(164,230,time_s[5], color[5]); //小时,十位
DisNum(220,210,time_s[6], color[6]); //日,个位
DisNum(212,210,time_s[7], color[7]); //日,十位
DisNum(196,210,time_s[8], color[8]); //月,个位
DisNum(188,210,time_s[9], color[9]); //月,十位
DisNum(172,210,time_s[10], color[10]); //年,个位
DisNum(164,210,time_s[11], color[11]); //年,十位
}
}
main()
{
uchar temp;
uchar R_data=0;
uchar G_data=0;
uchar B_data=0;
uchar temper;
uint i,j,k=0;
res=0; //低电平复位
DelayNS(1000);
res=1;
send_command(0x00);
i=rece_data();
DelayNS(10000);//等待电源恢复正常
lcd_init();
touch_Init();
PWM=1;//电机初始化,停止转动
DispClear();
DispOneColor(0x333333);
Set_ramaddr(0,0);
send_command(0x22);
for(j=0;j<50;j++)
for(i=0;i<240;i++)
send_data(GREEN);
DrawString(0, 150, "现", WHITE, 0x333333, NORMAL);
DrawString(16, 150, "在", WHITE, 0x333333, NORMAL);
DrawString(32, 150, "气", WHITE, 0x333333, NORMAL);
DrawString(48, 150, "温", WHITE, 0x333333, NORMAL);
DrawString(64, 150, ":", WHITE, 0x333333, NORMAL);
DrawString(88, 143, ".", WHITE, 0x333333, NORMAL);
DrawString(96, 150, "C", WHITE, 0x333333, NORMAL);
for(j=270;j<310;j++)
{
Set_ramaddr(10,j);
send_command(0x22);
for(i=10;i<70;i++)
send_data(RED);
}
DrawString(24, 282, "设", WHITE, RED, NORMAL);
DrawString(40, 282, "定", WHITE, RED, NORMAL);
for(j=270;j<310;j++)
{
Set_ramaddr(90,j);
send_command(0x22);
for(i=90;i<150;i++)
send_data(RED);
}
DrawString(104, 282, "左", WHITE, RED, NORMAL);
DrawString(120, 282, "移", WHITE, RED, NORMAL);
for(j=270;j<310;j++)
{
Set_ramaddr(170,j);
send_command(0x22);
for(i=170;i<230;i++)
send_data(RED);
}
DrawString(184, 282, "调", WHITE, RED, NORMAL);
DrawString(200, 282, "整", WHITE, RED, NORMAL);
Set1302(time);
while(1)
{
Get1302(time);
DispNum(148,210,2);
DispNum(156,210,0);
temp = time[6]>>4;
DispNum(164,210,temp);
temp = time[6]&0x0f;
DispNum(172,210,temp); //年
DrawString(180,210,"-",WHITE,0x333333,NORMAL);
temp = time[4]>>4;
DispNum(188,210,temp); //月,十位
temp = time[4]&0x0f;
DispNum(196,210,temp); //月,个位
DrawString(204,210,"-",WHITE,0x333333,NORMAL);
temp = time[3]>>4;
DispNum(212,210,temp); //日,十位
temp = time[3]&0x0f;
DispNum(220,210,temp); //日,个位
temp = time[2]>>4;
DispNum(164,230,temp); //小时,十位
temp = time[2]&0x0f;
DispNum(172,230,temp); //小时,个位
DrawString(180,230,":",WHITE,0x333333,NORMAL);
temp = time[1]>>4;
DispNum(188,230,temp); //分,十位
temp = time[1]&0x0f;
DispNum(196,230,temp); //分,个位
DrawString(204,230,":",WHITE,0x333333,NORMAL);
temp = time[0]>>4;
DispNum(212, 230, temp);//秒,十位
temp = time[0]&0x0f;
DispNum(220, 230, temp);//秒,个位
temper = ReadTemperature();
DispNum(72,150,temper/10);
DispNum(80,150,temper%10);
if (touch_INT==0)
{
touch_GetAdXY(&T_x, &T_y);
if((T_x<900)&&(T_x>400)&&(T_y<1200)&&(T_y>300))
set_time(time);
}
if (temper>=25)//直流电机
PWM=0;
else
PWM=~PWM;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -