Normally the code I wrote is working. But I want to write with a more regular and more professional language. Aim of code is after buzzer first ringing, buzzer every 2 seconds ringing at the same time button checked by processor. Code like this;
timer = HAL_GetTick();
timer++;
if(timer==1000){
playTone=1;
}
if(timer==3000){
playTone=1;
}
if(timer==5000){
playTone=1;
}
if(timer==7000){
playTone=1;
}
if(2000> timer && timer > 0 && (HAL_GPIO_ReadPin(But_Prog_GPIO_Port,But_Prog_Pin)== 1)){
//Do something_1
__HAL_GPIO_EXTI_CLEAR_FLAG(But_Prog_Pin);
}
else if( 4000> prog_button_timer && prog_button_timer >= 2000&& (HAL_GPIO_ReadPin(But_Prog_GPIO_Port,But_Prog_Pin)== 1)){
//Do something_2
__HAL_GPIO_EXTI_CLEAR_FLAG(But_Prog_Pin);
}
else if( 6000>prog_button_timer && prog_button_timer > 4000&& (HAL_GPIO_ReadPin(But_Prog_GPIO_Port,But_Prog_Pin)== 1)){
//Do something_3
__HAL_GPIO_EXTI_CLEAR_FLAG(But_Prog_Pin);
}
else if( 8000>prog_button_timer && prog_button_timer > 6000&& (HAL_GPIO_ReadPin(But_Prog_GPIO_Port,But_Prog_Pin)== 1)){
//Do something_3
__HAL_GPIO_EXTI_CLEAR_FLAG(But_Prog_Pin);
}
else
//Do something
Aucun commentaire:
Enregistrer un commentaire