Fix button directions

main
Valentin Ochs 2021-02-19 21:30:47 +01:00
parent 7db7859e71
commit ed99ad9e63
1 changed files with 5 additions and 5 deletions

View File

@ -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);
}
}
}