Skip to content

Commit

Permalink
[修改] 格式化文件, 将文件的Tab转换为4空格
Browse files Browse the repository at this point in the history
  • Loading branch information
liu2guang committed Nov 30, 2017
1 parent 3f108ce commit 425b647
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 203 deletions.
68 changes: 34 additions & 34 deletions examples/event_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,56 @@
struct Button btn1;
struct Button btn2;

int read_button1_GPIO()
int read_button1_GPIO()
{
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
}

int read_button2_GPIO()
int read_button2_GPIO()
{
return HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin);
return HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin);
}

int main()
{
button_init(&btn1, read_button1_GPIO, 0);
button_init(&btn2, read_button2_GPIO, 0);
button_attach(&btn1, PRESS_DOWN, BTN1_PRESS_DOWN_Handler);
button_attach(&btn1, PRESS_UP, BTN1_PRESS_UP_Handler);
button_attach(&btn1, PRESS_REPEAT, BTN1_PRESS_REPEAT_Handler);
button_attach(&btn1, SINGLE_CLICK, BTN1_SINGLE_Click_Handler);
button_attach(&btn1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler);
button_attach(&btn1, LONG_RRESS_START, BTN1_LONG_RRESS_START_Handler);
button_attach(&btn2, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler);
button_attach(&btn2, PRESS_DOWN, BTN2_PRESS_DOWN_Handler);
button_attach(&btn2, PRESS_UP, BTN2_PRESS_UP_Handler);
button_attach(&btn2, PRESS_REPEAT, BTN2_PRESS_REPEAT_Handler);
button_attach(&btn2, SINGLE_CLICK, BTN2_SINGLE_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);
button_start(&btn1);
button_start(&btn2);
//make the timer invoking the button_ticks() interval 5ms.
//This function is implemented by yourself.
__timer_start(button_ticks, 0, 5);
while(1)
{}
button_init(&btn1, read_button1_GPIO, 0);
button_init(&btn2, read_button2_GPIO, 0);

button_attach(&btn1, PRESS_DOWN, BTN1_PRESS_DOWN_Handler);
button_attach(&btn1, PRESS_UP, BTN1_PRESS_UP_Handler);
button_attach(&btn1, PRESS_REPEAT, BTN1_PRESS_REPEAT_Handler);
button_attach(&btn1, SINGLE_CLICK, BTN1_SINGLE_Click_Handler);
button_attach(&btn1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler);
button_attach(&btn1, LONG_RRESS_START, BTN1_LONG_RRESS_START_Handler);
button_attach(&btn2, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler);

button_attach(&btn2, PRESS_DOWN, BTN2_PRESS_DOWN_Handler);
button_attach(&btn2, PRESS_UP, BTN2_PRESS_UP_Handler);
button_attach(&btn2, PRESS_REPEAT, BTN2_PRESS_REPEAT_Handler);
button_attach(&btn2, SINGLE_CLICK, BTN2_SINGLE_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);

button_start(&btn1);
button_start(&btn2);

//make the timer invoking the button_ticks() interval 5ms.
//This function is implemented by yourself.
__timer_start(button_ticks, 0, 5);

while(1)
{}
}

void BTN1_PRESS_DOWN_Handler(void* btn)
{
//do something...
//do something...
}

void BTN1_PRESS_UP_Handler(void* btn)
{
//do something...
//do something...
}

...
50 changes: 25 additions & 25 deletions examples/event_inquire.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@

struct Button btn1;

int read_button1_GPIO()
int read_button1_GPIO()
{
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
}


int main()
{
static uint8_t btn1_event_val;
button_init(&btn1, read_button1_GPIO, 0);
button_start(&btn1);
//make the timer invoking the button_ticks() interval 5ms.
//This function is implemented by yourself.
__timer_start(button_ticks, 0, 5);
while(1)
{
if(btn1_event_val != get_button_event(&btn1)) {
btn1_event_val = get_button_event(&btn1);
if(btn1_event_val == PRESS_DOWN) {
//do something
} else if(btn1_event_val == PRESS_UP) {
//do something
} else if(btn1_event_val == LONG_PRESS_HOLD) {
//do something
}
}
}
static uint8_t btn1_event_val;

button_init(&btn1, read_button1_GPIO, 0);
button_start(&btn1);

//make the timer invoking the button_ticks() interval 5ms.
//This function is implemented by yourself.
__timer_start(button_ticks, 0, 5);

while(1)
{
if(btn1_event_val != get_button_event(&btn1)) {
btn1_event_val = get_button_event(&btn1);

if(btn1_event_val == PRESS_DOWN) {
//do something
} else if(btn1_event_val == PRESS_UP) {
//do something
} else if(btn1_event_val == LONG_PRESS_HOLD) {
//do something
}
}
}
}

Loading

0 comments on commit 425b647

Please sign in to comment.