Skip to content

support reactive callbacks #8

@Andrei-Pozolotin

Description

@Andrei-Pozolotin

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();
        }
    }
};

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions