赛题
部分程序
m24c02_init();
LED_init();
KEY_init();
LCD_Init();
LCD_DisplayStringLine(Line2,LCD_Line2_buf);
HAL_TIM_Base_Start_IT(&htim2);
TASK_TIMES_init();
while (1)
{
scankey();
ADC_function();
Interface_function();
LED_function();
}
void Interface_function(void)
{
if(get_task_time(TASK_TIMES.Interface_TIME)==0)
{
TASK_TIMES.Interface_TIME=get_time()+Interface_time;
if(Interface==0)
{
LCD_Line4_buf[7]=ADC/100+48;LCD_Line4_buf[9]=ADC/10%10+48;
LCD_Line4_buf[10]=ADC%10+48;
if(flag_ADC_state==0)
{
LCD_Line5_buf[9]='L'; LCD_Line5_buf[10]='o';LCD_Line5_buf[11]='w';
LCD_Line5_buf[12]='e';LCD_Line5_buf[13]='r';LCD_Line5_buf[14]=' ';
}
else if(flag_ADC_state==1)
{
LCD_Line5_buf[9]='N'; LCD_Line5_buf[10]='o';LCD_Line5_buf[11]='r';
LCD_Line5_buf[12]='m';LCD_Line5_buf[13]='a';LCD_Line5_buf[14]='l';
}
else if(flag_ADC_state==2)
{
LCD_Line5_buf[9]='U'; LCD_Line5_buf[10]='p';LCD_Line5_buf[11]='p';
LCD_Line5_buf[12]='e';LCD_Line5_buf[13]='r';LCD_Line5_buf[14]=' ';
}
LCD_DisplayStringLine(Line4,LCD_Line4_buf);
LCD_DisplayStringLine(Line5,LCD_Line5_buf);
}
else if(Interface==1)
{
LCD_Line3_buf[11]=parameter_buf[0]/10+48;LCD_Line3_buf[13]=parameter_buf[0]%10+48;
LCD_Line4_buf[11]=parameter_buf[1]/10+48;LCD_Line4_buf[13]=parameter_buf[1]%10+48;
LCD_Line5_buf[10]=parameter_buf[2]+1+48;LCD_Line6_buf[10]=parameter_buf[3]+1+48;
if(Set_Line==0) {LCD_SetBackColor(Green);LCD_DisplayStringLine(Line3,LCD_Line3_buf);LCD_SetBackColor(White);}
else {LCD_DisplayStringLine(Line3,LCD_Line3_buf);}
if(Set_Line==1) {LCD_SetBackColor(Green);LCD_DisplayStringLine(Line4,LCD_Line4_buf);LCD_SetBackColor(White);}
else {LCD_DisplayStringLine(Line4,LCD_Line4_buf);}
if(Set_Line==2) {LCD_SetBackColor(Green);LCD_DisplayStringLine(Line5,LCD_Line5_buf);LCD_SetBackColor(White);}
else {LCD_DisplayStringLine(Line5,LCD_Line5_buf);}
if(Set_Line==3) {LCD_SetBackColor(Green);LCD_DisplayStringLine(Line6,LCD_Line6_buf);LCD_SetBackColor(White);}
else {LCD_DisplayStringLine(Line6,LCD_Line6_buf);}
}
}
}
void KEY_function(uint8_t key)
{
uint8_t a;
if(key==1)
{
if(++Interface==2) {Interface=0;}
if(Interface==0)
{
LCD_ClearLine(Line3);
LCD_ClearLine(Line6);
sprintf((char *)LCD_Line2_buf," Main ");
sprintf((char *)LCD_Line4_buf," Volt:0.00V ");
sprintf((char *)LCD_Line5_buf," Status:Upper ");
for(a=0;a<4;a++) X24c02_buf[a+1]=parameter_buf[a];
m24c02_write(X24c02_buf+1,DATA_ARR+1,4);
}
else if(Interface==1)
{
sprintf((char *)LCD_Line2_buf," Setting ");
sprintf((char *)LCD_Line4_buf," Min Volt:1.2V ");
sprintf((char *)LCD_Line5_buf," Upper:LD1 ");
}
LCD_DisplayStringLine(Line2,LCD_Line2_buf);
}
else if(key==2)
{
if(Interface==1)
{ if(++Set_Line==4) {Set_Line=0;} }
}
else if(key==3)
{
if(Interface==1)
{
if((Set_Line==0)||(Set_Line==1))
{
if(parameter_buf[Set_Line]+=3,parameter_buf[Set_Line]>33) {parameter_buf[Set_Line]=33;}
if(parameter_buf[0]<=parameter_buf[1]) {parameter_buf[Set_Line]-=3;}
}
else if((Set_Line==2)||(Set_Line==3))
{
if(++parameter_buf[Set_Line]>7) {parameter_buf[Set_Line]=0;}
if(parameter_buf[2]==parameter_buf[3]) {if(++parameter_buf[Set_Line]>7) {parameter_buf[Set_Line]=0;}}
}
}
}
else if(key==4)
{
if(Interface==1)
{
if((Set_Line==0)||(Set_Line==1))
{
if(parameter_buf[Set_Line]-=3,parameter_buf[Set_Line]>33) {parameter_buf[Set_Line]=0;}
if(parameter_buf[0]<=parameter_buf[1]) {parameter_buf[Set_Line]+=3;}
}
else if((Set_Line==2)||(Set_Line==3))
{
if(--parameter_buf[Set_Line]>7) {parameter_buf[Set_Line]=7;}
if(parameter_buf[2]==parameter_buf[3]) {if(--parameter_buf[Set_Line]>7) {parameter_buf[Set_Line]=7;}}
}
}
}
}
完整程序下载
下载链接: 链接:https://pan.baidu.com/s/1LMECSy3GuABduu42YUJdSQ 提取码:qy2o
|