-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Labels
Description
please add support for reactive callbacks, i.e.:
class RotaryReactor: public Rotary {
private:
static void noop() {
}
void (*reactorPositive)() = &noop;
void (*reactorNegative)() = &noop;
public:
RotaryReactor(char pinA, char pinB) :
Rotary(pinA, pinB) {
}
void attachReactorPositive(void (*reactor)()) {
reactorPositive = reactor;
}
void attachReactorNegative(void (*reactor)()) {
reactorNegative = reactor;
}
void react() {
unsigned char result = this->process();
if (result == DIR_CW) {
reactorPositive();
} else if (result == DIR_CCW) {
reactorNegative();
}
}
};