I have to run two conditions one at a time, so I am using if/else but in one condition I have to use switch/case to run different screens and loop should run in while.
The code is below:
void app_main()
{
uint8_t scrn = 0, cntr = 0;
while(1)
{
if (ble_con_sta)
{
display_app_acess();
}
else
{
switch(scrn)
{
case 0:
scrn_time();
break;
case 1:
scrn_temp_humid();
break;
case 2:
scrn_dose();
break;
}
cntr++;
if(cntr>200)
{
cntr=0;
scrn++;
if(scrn>2)
{scrn=0;}
Clear_Screen(0);
}
}
}
}
But is not working as required, the code is stuck in scrn_time();
But if i am doing likw below then its working
{
switch(scrn)
{
case 0:
get_FP_ID();
if (ble_con_sta)
{display_app_acess();}
else
{scrn_time();}
break;
case 1:
if (ble_con_sta)
{display_app_acess();}
else
{scrn_temp_humid();}
break;
case 2:
if (ble_con_sta)
{display_app_acess();}
else
{scrn_dose();}
break;
}
cntr++;
if(cntr>200)
{
cntr=0;
scrn++;
if(scrn>2)
{scrn=0;}
Clear_Screen(0);
}
}
I have tested the code in both ways and also by running only switch case, all the functions are working fine.
Aucun commentaire:
Enregistrer un commentaire