You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
784 B
47 lines
784 B
#include <M5StickC.h>
|
|
#include "Kernel.h"
|
|
|
|
bool debounce_a = false;
|
|
bool debounce_b = false;
|
|
|
|
int UserInput(int pid, unsigned int signal)
|
|
{
|
|
if (signal & SIGNAL_START)
|
|
{
|
|
Kernel_signal_mask(pid, SIGNAL_START | SIGNAL_STOP | SIGNAL_TICK);
|
|
}
|
|
if (signal & SIGNAL_STOP)
|
|
{
|
|
return 255;
|
|
}
|
|
if (signal & SIGNAL_TICK)
|
|
{
|
|
if (Kernel_read_input(KERNEL_INPUT_BUTTON_A))
|
|
{
|
|
if (!debounce_a)
|
|
{
|
|
Kernel_signal(SIGNAL_INPUT_A);
|
|
debounce_a = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
debounce_a = false;
|
|
}
|
|
|
|
if (Kernel_read_input(KERNEL_INPUT_BUTTON_B))
|
|
{
|
|
if (!debounce_b)
|
|
{
|
|
Kernel_signal(SIGNAL_INPUT_B);
|
|
debounce_b = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
debounce_b = false;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|