Fix button directions
This commit is contained in:
parent
7db7859e71
commit
ed99ad9e63
10
buttons.c
10
buttons.c
|
@ -19,13 +19,13 @@ static uint32_t open_ticks = 0;
|
|||
static uint32_t close_ticks = 0;
|
||||
|
||||
void buttons_open(uint32_t ticks) {
|
||||
gpio_set(BUTTON_PORT, OPEN_BUTTON);
|
||||
gpio_clear(BUTTON_PORT, OPEN_BUTTON);
|
||||
printf("Open %lu", ticks);
|
||||
open_ticks = ticks;
|
||||
}
|
||||
|
||||
void buttons_close(uint32_t ticks) {
|
||||
gpio_set(BUTTON_PORT, CLOSE_BUTTON);
|
||||
gpio_clear(BUTTON_PORT, CLOSE_BUTTON);
|
||||
printf("Close %lu", ticks);
|
||||
close_ticks = ticks;
|
||||
}
|
||||
|
@ -33,14 +33,14 @@ void buttons_close(uint32_t ticks) {
|
|||
void buttons_release(void) {
|
||||
open_ticks = close_ticks = 0;
|
||||
printf("Release");
|
||||
gpio_clear(BUTTON_PORT, OPEN_BUTTON | CLOSE_BUTTON);
|
||||
gpio_set(BUTTON_PORT, OPEN_BUTTON | CLOSE_BUTTON);
|
||||
}
|
||||
|
||||
void buttons_tick(void) {
|
||||
if (open_ticks) {
|
||||
open_ticks--;
|
||||
if (!open_ticks) {
|
||||
gpio_clear(BUTTON_PORT, OPEN_BUTTON);
|
||||
gpio_set(BUTTON_PORT, OPEN_BUTTON);
|
||||
printf("Release open");
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ void buttons_tick(void) {
|
|||
close_ticks--;
|
||||
if (!close_ticks) {
|
||||
printf("Release close");
|
||||
gpio_clear(BUTTON_PORT, CLOSE_BUTTON);
|
||||
gpio_set(BUTTON_PORT, CLOSE_BUTTON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user