![TGCM@Z4CIKEA7561200P2.png
这个问题如何解决
void sys_data_show(void)
{
while(1)
{
if(sys_ctrl.find==0)
{
if(sys_ctrl.set_alarm_mode==0)
{
lcd1602_show_nums(6,0,sys_ctrl.hour,2,0x80);
lcd1602_show_nums(9,0,sys_ctrl.min,2,0x80);
lcd1602_show_nums(12,0,sys_ctrl.sec,2,0x80);
lcd1602_show_nums(3,1,sys_ctrl.heart,3,0);
lcd1602_show_nums(12,1,sys_ctrl.oxygen,3,0);
switch(sys_ctrl.set_time_mode)
{
case 1:
lcd1602_show_string(6,0," ");
delay_ms(50);
lcd1602_show_nums(6,0,sys_ctrl.hour,2,0x80);
break;
case 2:
lcd1602_show_string(9,0," ");
delay_ms(50);
lcd1602_show_nums(9,0,sys_ctrl.min,2,0x80);
break;
case 3:
lcd1602_show_string(12,0," ");
delay_ms(50);
lcd1602_show_nums(12,0,sys_ctrl.sec,2,0x80);
break;
}
}
else
{
lcd1602_show_nums(7,0,sys_ctrl.alarm_time[0][0],2,0x80);
lcd1602_show_nums(10,0,sys_ctrl.alarm_time[0][1],2,0x80);
lcd1602_show_nums(7,1,sys_ctrl.alarm_time[1][0],2,0x80);
lcd1602_show_nums(10,1,sys_ctrl.alarm_time[1][1],2,0x80);
switch(sys_ctrl.set_alarm_mode)
{
case 1:
lcd1602_show_string(7,0," ");
delay_ms(50);
lcd1602_show_nums(7,0,sys_ctrl.alarm_time[0][0],2,0x80);
break;
case 2:
lcd1602_show_string(10,0," ");
delay_ms(50);
lcd1602_show_nums(10,0,sys_ctrl.alarm_time[0][1],2,0x80);
break;
case 3:
lcd1602_show_string(7,1," ");
delay_ms(50);
lcd1602_show_nums(7,1,sys_ctrl.alarm_time[1][0],2,0x80);
break;
case 4:
lcd1602_show_string(10,1," ");
delay_ms(50);
lcd1602_show_nums(10,1,sys_ctrl.alarm_time[1][1],2,0x80);
break;
}
}
}
else
{
lcd1602_show_nums(8,0,sys_ctrl.heart_lh[0],3,0x80);
lcd1602_show_nums(12,0,sys_ctrl.heart_lh[1],3,0x80);
lcd1602_show_nums(8,1,sys_ctrl.oxygen_lh[0],3,0x80);
lcd1602_show_nums(12,1,sys_ctrl.oxygen_lh[1],3,0x80);
}
break;
}
}
void sys_data_set(void)
{
u8 key=0;
static u8 oneflag=0;
key=key_scan(0);
if(key==KEY3_PRESS)
{
if(sys_ctrl.set_alarm_mode==0)
{
TR1=0;
sys_ctrl.set_time_mode++;
if(sys_ctrl.set_time_mode>=4)sys_ctrl.set_time_mode=1;
}
else
{
oneflag=0;
sys_ctrl.set_alarm_mode=0;
sys_open_show();
TR1=1;
}
}
else if(key==KEY1_PRESS)
{
switch(sys_ctrl.set_time_mode)
{
case 1:
sys_ctrl.hour++;
if(sys_ctrl.hour>23)sys_ctrl.hour=0;
break;
case 2:
sys_ctrl.min++;
if(sys_ctrl.min>59)sys_ctrl.min=0;
break;
case 3:
sys_ctrl.sec++;
if(sys_ctrl.sec>59)sys_ctrl.sec=0;
break;
}
switch(sys_ctrl.set_alarm_mode)
{
case 1:
sys_ctrl.alarm_time[0][0]++;
if(sys_ctrl.alarm_time[0][0]>23)sys_ctrl.alarm_time[0][0]=0;
break;
case 2:
sys_ctrl.alarm_time[0][1]++;
if(sys_ctrl.alarm_time[0][1]>59)sys_ctrl.alarm_time[0][1]=0;
break;
case 3:
sys_ctrl.alarm_time[1][0]++;
if(sys_ctrl.alarm_time[1][0]>23)sys_ctrl.alarm_time[1][0]=0;
break;
case 4:
sys_ctrl.alarm_time[1][1]++;
if(sys_ctrl.alarm_time[1][1]>59)sys_ctrl.alarm_time[1][1]=0;
break;
}
if(sys_ctrl.set_time_mode==0 && sys_ctrl.set_alarm_mode==0)
{
sys_ctrl.find=!sys_ctrl.find;
if(sys_ctrl.find==1)
{
lcd1602_clear();
lcd1602_show_string(0,0," Heart->000-000");
lcd1602_show_string(0,1,"Oxygen->000-000");
}
else
{
sys_open_show();
}
}
}
else if(key==KEY2_PRESS)
{
switch(sys_ctrl.set_time_mode)
{
case 1:
sys_ctrl.hour--;
if(sys_ctrl.hour<0)sys_ctrl.hour=23;
break;
case 2:
sys_ctrl.min--;
if(sys_ctrl.min<0)sys_ctrl.min=59;
break;
case 3:
sys_ctrl.sec--;
if(sys_ctrl.sec<0)sys_ctrl.sec=59;
break;
}
switch(sys_ctrl.set_alarm_mode)
{
case 1:
sys_ctrl.alarm_time[0][0]--;
if(sys_ctrl.alarm_time[0][0]<0)sys_ctrl.alarm_time[0][0]=23;
break;
case 2:
sys_ctrl.alarm_time[0][1]--;
if(sys_ctrl.alarm_time[0][1]<0)sys_ctrl.alarm_time[0][1]=59;
break;
case 3:
sys_ctrl.alarm_time[1][0]--;
if(sys_ctrl.alarm_time[1][0]<0)sys_ctrl.alarm_time[1][0]=23;
break;
case 4:
sys_ctrl.alarm_time[1][1]--;
if(sys_ctrl.alarm_time[1][1]<0)sys_ctrl.alarm_time[1][1]=59;
break;
}
sys_ctrl.alarm_flag=0;
}
else if(key==KEY4_PRESS)
{
if(sys_ctrl.set_time_mode!=0)
{
sys_ctrl.set_time_mode=0;
TR1=1;
}
else
{
TR1=0;
if(oneflag==0)
{
oneflag=1;
lcd1602_clear();
lcd1602_show_string(0,0,"Sleep->00:00");
lcd1602_show_string(0,1,"Alarm->00:00");
}
sys_ctrl.set_alarm_mode++;
if(sys_ctrl.set_alarm_mode>=5)sys_ctrl.set_alarm_mode=1;
}
}
}
void appdemo_show(void)
{
u8 i=5;
sys_parm_init();
lcd1602_init();
time1_init();
while(i--)
{
sys_ctrl.heart=pcf8591_read_adcvalue(1);
sys_ctrl.heart=cal_map(sys_ctrl.heart,0,255,0,200);
sys_ctrl.heart_lh[0]=sys_ctrl.heart;
sys_ctrl.heart_lh[1]=sys_ctrl.heart;
sys_ctrl.oxygen=pcf8591_read_adcvalue(0);
sys_ctrl.oxygen=cal_map(sys_ctrl.oxygen,0,255,0,200);
sys_ctrl.oxygen_lh[0]=sys_ctrl.oxygen;
sys_ctrl.oxygen_lh[1]=sys_ctrl.oxygen;
delay_ms(100);
}
sys_open_show();
TR1=1;
while(1)
{
sys_data_get();
sys_data_show();
sys_data_set();
sys_fun_ctrl();
}
}
void time1(void) interrupt 3
{
static u8 i=0;
TH1=0XDC;
TL1=0X00;
i++;
if(i>=100)
{
i=0;
sys_ctrl.sec++;
if(sys_ctrl.sec>=60)
{
sys_ctrl.sec=0;
sys_ctrl.min++;
if(sys_ctrl.min>=60)
{
sys_ctrl.min=0;
sys_ctrl.hour++;
if(sys_ctrl.hour>=24)sys_ctrl.hour=0;
}
}
}
}