2022-01-09 10:08:31 +01:00
|
|
|
#include "RotaryEncoderInterruptImpl1.h"
|
2022-01-11 16:02:55 +01:00
|
|
|
#include "InputBroker.h"
|
2022-01-09 10:08:31 +01:00
|
|
|
|
|
|
|
|
RotaryEncoderInterruptImpl1 *rotaryEncoderInterruptImpl1;
|
|
|
|
|
|
2022-05-07 20:31:21 +10:00
|
|
|
RotaryEncoderInterruptImpl1::RotaryEncoderInterruptImpl1() : RotaryEncoderInterruptBase("rotEnc1") {}
|
2022-01-11 13:12:04 +01:00
|
|
|
|
2023-09-23 23:45:35 -05:00
|
|
|
bool RotaryEncoderInterruptImpl1::init()
|
2022-01-11 13:12:04 +01:00
|
|
|
{
|
2022-05-22 13:27:56 +02:00
|
|
|
if (!moduleConfig.canned_message.rotary1_enabled) {
|
2022-01-12 09:26:42 +01:00
|
|
|
// Input device is disabled.
|
2022-12-29 16:26:25 -06:00
|
|
|
disable();
|
2023-09-23 23:45:35 -05:00
|
|
|
return false;
|
2022-01-12 09:26:42 +01:00
|
|
|
}
|
|
|
|
|
|
2022-05-22 13:27:56 +02:00
|
|
|
uint8_t pinA = moduleConfig.canned_message.inputbroker_pin_a;
|
|
|
|
|
uint8_t pinB = moduleConfig.canned_message.inputbroker_pin_b;
|
|
|
|
|
uint8_t pinPress = moduleConfig.canned_message.inputbroker_pin_press;
|
|
|
|
|
char eventCw = static_cast<char>(moduleConfig.canned_message.inputbroker_event_cw);
|
|
|
|
|
char eventCcw = static_cast<char>(moduleConfig.canned_message.inputbroker_event_ccw);
|
|
|
|
|
char eventPressed = static_cast<char>(moduleConfig.canned_message.inputbroker_event_press);
|
2022-01-12 09:26:42 +01:00
|
|
|
|
2022-05-22 13:27:56 +02:00
|
|
|
// moduleConfig.canned_message.ext_notification_module_output
|
2022-05-07 20:31:21 +10:00
|
|
|
RotaryEncoderInterruptBase::init(pinA, pinB, pinPress, eventCw, eventCcw, eventPressed,
|
|
|
|
|
RotaryEncoderInterruptImpl1::handleIntA, RotaryEncoderInterruptImpl1::handleIntB,
|
|
|
|
|
RotaryEncoderInterruptImpl1::handleIntPressed);
|
2022-01-13 14:06:10 +01:00
|
|
|
inputBroker->registerSource(this);
|
2023-09-23 23:45:35 -05:00
|
|
|
return true;
|
2022-01-09 10:08:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RotaryEncoderInterruptImpl1::handleIntA()
|
|
|
|
|
{
|
2022-01-09 21:14:23 +01:00
|
|
|
rotaryEncoderInterruptImpl1->intAHandler();
|
2022-01-09 10:08:31 +01:00
|
|
|
}
|
|
|
|
|
void RotaryEncoderInterruptImpl1::handleIntB()
|
|
|
|
|
{
|
2022-01-09 21:14:23 +01:00
|
|
|
rotaryEncoderInterruptImpl1->intBHandler();
|
2022-01-09 10:08:31 +01:00
|
|
|
}
|
|
|
|
|
void RotaryEncoderInterruptImpl1::handleIntPressed()
|
|
|
|
|
{
|
2022-01-09 21:14:23 +01:00
|
|
|
rotaryEncoderInterruptImpl1->intPressHandler();
|
2023-09-23 23:45:35 -05:00
|
|
|
}
|