mirror of
https://github.com/0x1abin/MultiButton.git
synced 2025-01-25 08:32:55 +08:00
examples: remove the break keyword after return
Signed-off-by: Junbo Zheng <3273070@qq.com>
This commit is contained in:
parent
fde6c72c32
commit
d652f3b018
@ -15,15 +15,10 @@ uint8_t read_button_GPIO(uint8_t button_id)
|
|||||||
{
|
{
|
||||||
case btn1_id:
|
case btn1_id:
|
||||||
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
|
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
|
||||||
break;
|
|
||||||
|
|
||||||
case btn2_id:
|
case btn2_id:
|
||||||
return HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin);
|
return HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,11 +10,8 @@ uint8_t read_button_GPIO(uint8_t button_id)
|
|||||||
{
|
{
|
||||||
case btn1_id:
|
case btn1_id:
|
||||||
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
|
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,19 +19,19 @@ uint8_t read_button_GPIO(uint8_t button_id)
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
static uint8_t btn1_event_val;
|
static uint8_t btn1_event_val;
|
||||||
|
|
||||||
button_init(&btn1, read_button_GPIO, 0, btn1_id);
|
button_init(&btn1, read_button_GPIO, 0, btn1_id);
|
||||||
button_start(&btn1);
|
button_start(&btn1);
|
||||||
|
|
||||||
//make the timer invoking the button_ticks() interval 5ms.
|
//make the timer invoking the button_ticks() interval 5ms.
|
||||||
//This function is implemented by yourself.
|
//This function is implemented by yourself.
|
||||||
__timer_start(button_ticks, 0, 5);
|
__timer_start(button_ticks, 0, 5);
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if(btn1_event_val != get_button_event(&btn1)) {
|
if(btn1_event_val != get_button_event(&btn1)) {
|
||||||
btn1_event_val = get_button_event(&btn1);
|
btn1_event_val = get_button_event(&btn1);
|
||||||
|
|
||||||
if(btn1_event_val == PRESS_DOWN) {
|
if(btn1_event_val == PRESS_DOWN) {
|
||||||
//do something
|
//do something
|
||||||
} else if(btn1_event_val == PRESS_UP) {
|
} else if(btn1_event_val == PRESS_UP) {
|
||||||
@ -45,4 +42,3 @@ int main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user