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];
|
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) {
|
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) {
|
||||||
if (brainPin == GPIO_UNASSIGNED)
|
if (brainPin == GPIO_UNASSIGNED)
|
||||||
return EFI_ERROR_CODE;
|
return EFI_ERROR_CODE;
|
||||||
|
|
|
@ -36,12 +36,18 @@ static int joyD = 0;
|
||||||
static Logging *sharedLogger;
|
static Logging *sharedLogger;
|
||||||
static efitick_t lastEventTime = 0;
|
static efitick_t lastEventTime = 0;
|
||||||
|
|
||||||
static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
static bool isJitter() {
|
||||||
UNUSED(extp);
|
|
||||||
efitick_t now = getTimeNowNt();
|
efitick_t now = getTimeNowNt();
|
||||||
if (now - lastEventTime < NT_EVENT_GAP)
|
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;
|
lastEventTime = now;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
||||||
|
UNUSED(extp);
|
||||||
|
if (isJitter())
|
||||||
|
return;
|
||||||
joyTotal++;
|
joyTotal++;
|
||||||
joystick_button_e button;
|
joystick_button_e button;
|
||||||
// todo: I guess it's time to reduce code duplication and start working with an array
|
// 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)) {
|
} else if (channel == getHwPin("joy", boardConfiguration->joystickAPin)) {
|
||||||
joyA++;
|
joyA++;
|
||||||
button = JB_BUTTON_A;
|
button = JB_BUTTON_A;
|
||||||
|
/* not used so far
|
||||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickBPin)) {
|
} else if (channel == getHwPin("joy", boardConfiguration->joystickBPin)) {
|
||||||
joyB++;
|
joyB++;
|
||||||
button = JB_BUTTON_C;
|
button = JB_BUTTON_B;
|
||||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickCPin)) {
|
} else if (channel == getHwPin("joy", boardConfiguration->joystickCPin)) {
|
||||||
joyC++;
|
joyC++;
|
||||||
button = JB_BUTTON_B;
|
button = JB_BUTTON_C;
|
||||||
|
*/
|
||||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickDPin)) {
|
} else if (channel == getHwPin("joy", boardConfiguration->joystickDPin)) {
|
||||||
joyD++;
|
joyD++;
|
||||||
button = JB_BUTTON_D;
|
button = JB_BUTTON_D;
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
typedef enum {
|
typedef enum {
|
||||||
JB_CENTER = 0,
|
JB_CENTER = 0,
|
||||||
JB_BUTTON_A = 1,
|
JB_BUTTON_A = 1,
|
||||||
JB_BUTTON_B = 2,
|
// not used so far JB_BUTTON_B = 2,
|
||||||
JB_BUTTON_C = 3,
|
// not used so far JB_BUTTON_C = 3,
|
||||||
JB_BUTTON_D = 4,
|
JB_BUTTON_D = 4,
|
||||||
} joystick_button_e;
|
} joystick_button_e;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue