-
-
Save hpyhacking/bfcead984e3fa363e22718752bfed7ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "main.h" | |
typedef void (*Func)(); | |
typedef struct s_double_press_description { | |
controller_digital_e_t button; | |
Func func; | |
} DoublePressDescription; | |
void double_press_task(void* _dp) { | |
struct s_double_press_description dp; | |
dp = (struct s_double_press_description *)_dp; | |
while(true) { | |
if (controller_get_digital(E_CONTROLLER_MASTER, dp.button)) { | |
dp.func(); | |
} | |
delay(20); | |
} | |
} | |
void controller_monitor_double_press(controller_digital_e_t button, void (*func)()) { | |
struct s_double_press_description dp; | |
dp.button = button; | |
dp.func = func; | |
task_t my_task = task_create(double_press_task, (void*)&dp, TASK_PRIORITY_DEFAULT, | |
TASK_STACK_DEPTH_DEFAULT, "DOUBLE PRESS TASK"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment