Skip to content

Instantly share code, notes, and snippets.

@hpyhacking
Last active November 15, 2023 16:34
Show Gist options
  • Save hpyhacking/bfcead984e3fa363e22718752bfed7ae to your computer and use it in GitHub Desktop.
Save hpyhacking/bfcead984e3fa363e22718752bfed7ae to your computer and use it in GitHub Desktop.
#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