exti clean-up
This commit is contained in:
parent
c6a25f7286
commit
28d58c41eb
|
@ -43,6 +43,9 @@ ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) {
|
|||
return PORTS[brainPin / PORT_SIZE];
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns the numeric part of pin name. For instance, for PC13 this would return '13'
|
||||
*/
|
||||
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) {
|
||||
if (brainPin == GPIO_UNASSIGNED)
|
||||
return EFI_ERROR_CODE;
|
||||
|
|
|
@ -36,12 +36,18 @@ static int joyD = 0;
|
|||
static Logging *sharedLogger;
|
||||
static efitick_t lastEventTime = 0;
|
||||
|
||||
static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
||||
UNUSED(extp);
|
||||
static bool isJitter() {
|
||||
efitick_t now = getTimeNowNt();
|
||||
if (now - lastEventTime < NT_EVENT_GAP)
|
||||
return; // two consecutive events are probably just jitter
|
||||
return true; // two consecutive events are probably just jitter
|
||||
lastEventTime = now;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
||||
UNUSED(extp);
|
||||
if (isJitter())
|
||||
return;
|
||||
joyTotal++;
|
||||
joystick_button_e button;
|
||||
// todo: I guess it's time to reduce code duplication and start working with an array
|
||||
|
@ -51,12 +57,14 @@ static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
|||
} else if (channel == getHwPin("joy", boardConfiguration->joystickAPin)) {
|
||||
joyA++;
|
||||
button = JB_BUTTON_A;
|
||||
/* not used so far
|
||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickBPin)) {
|
||||
joyB++;
|
||||
button = JB_BUTTON_C;
|
||||
button = JB_BUTTON_B;
|
||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickCPin)) {
|
||||
joyC++;
|
||||
button = JB_BUTTON_B;
|
||||
button = JB_BUTTON_C;
|
||||
*/
|
||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickDPin)) {
|
||||
joyD++;
|
||||
button = JB_BUTTON_D;
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
typedef enum {
|
||||
JB_CENTER = 0,
|
||||
JB_BUTTON_A = 1,
|
||||
JB_BUTTON_B = 2,
|
||||
JB_BUTTON_C = 3,
|
||||
// not used so far JB_BUTTON_B = 2,
|
||||
// not used so far JB_BUTTON_C = 3,
|
||||
JB_BUTTON_D = 4,
|
||||
} joystick_button_e;
|
||||
|
||||
|
|
Loading…
Reference in New Issue