mirror of
https://github.com/0x1abin/MultiButton.git
synced 2025-01-25 08:32:55 +08:00
update the examples
This commit is contained in:
parent
0814636e8d
commit
ec68abde16
@ -72,7 +72,7 @@ int read_button_pin()
|
||||
int main()
|
||||
{
|
||||
button_init(&button1, read_button_pin, 0);
|
||||
button_attach(&button1, SINGLE_CLICK, BTN1_SINGLE_CLICK_Handler);
|
||||
button_attach(&button1, PRESSED, BTN1_PRESSED_Handler);
|
||||
button_attach(&button1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler);
|
||||
button_attach(&button1, LONG_RRESS_START, BTN1_LONG_RRESS_START_Handler);
|
||||
button_attach(&button1, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler);
|
||||
@ -88,7 +88,7 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
void BTN1_SINGLE_CLICK_Handler()
|
||||
void BTN1_PRESSED_Handler()
|
||||
{
|
||||
//do something..
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ struct Button btn3;
|
||||
void main()
|
||||
{
|
||||
button_init(&btn1, read_K1_pin, 0);
|
||||
button_attach(&btn1, SINGLE_CLICK, BTN1_Click_Handler);
|
||||
button_attach(&btn1, PRESSED, BTN1_PRESSED_Handler);
|
||||
button_attach(&btn1, CLICK, BTN1_Click_Handler);
|
||||
button_attach(&btn1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler);
|
||||
button_attach(&btn1, LONG_RRESS_START, BTN1_LONG_RRESS_START_Handler);
|
||||
button_attach(&btn1, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler);
|
||||
@ -15,7 +16,8 @@ void main()
|
||||
button_start(&btn1);
|
||||
|
||||
button_init(&btn2, read_K2_pin, 0);
|
||||
button_attach(&btn2, SINGLE_CLICK, BTN2_Click_Handler);
|
||||
button_attach(&btn2, PRESSED, BTN2_PRESSED_Handler);
|
||||
button_attach(&btn2, CLICK, BTN2_Click_Handler);
|
||||
button_attach(&btn2, DOUBLE_CLICK, BTN2_DOUBLE_Click_Handler);
|
||||
button_attach(&btn2, LONG_RRESS_START, BTN2_LONG_RRESS_START_Handler);
|
||||
button_attach(&btn2, LONG_PRESS_HOLD, BTN2_LONG_PRESS_HOLD_Handler);
|
||||
@ -23,7 +25,8 @@ void main()
|
||||
button_start(&btn2);
|
||||
|
||||
button_init(&btn3, read_K3_pin, 0);
|
||||
button_attach(&btn3, SINGLE_CLICK, BTN3_Click_Handler);
|
||||
button_attach(&btn3, PRESSED, BTN3_PRESSED_Handler);
|
||||
button_attach(&btn3, CLICK, BTN3_Click_Handler);
|
||||
button_attach(&btn3, DOUBLE_CLICK, BTN3_DOUBLE_Click_Handler);
|
||||
button_attach(&btn3, LONG_RRESS_START, BTN3_LONG_RRESS_START_Handler);
|
||||
button_attach(&btn3, LONG_PRESS_HOLD, BTN3_LONG_PRESS_HOLD_Handler);
|
||||
@ -31,14 +34,8 @@ void main()
|
||||
button_start(&btn3);
|
||||
|
||||
//make the timer invoking the button_ticks() interval 5ms.
|
||||
timer_start(button_ticks, 0, 5);
|
||||
__timer_start(button_ticks, 0, 5); //This function is implemented by yourself.
|
||||
|
||||
while(1)
|
||||
{
|
||||
//you loop
|
||||
}
|
||||
|
||||
button_stop(&btn1);
|
||||
button_stop(&btn2);
|
||||
button_stop(&btn3);
|
||||
while(1)
|
||||
{}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user