Skip to content

Commit

Permalink
Update CustomEncoder.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
gfvalvo authored Dec 25, 2020
1 parent ea1c5e8 commit 68483a8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/CustomEncoder/CustomEncoder.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,23 @@ class CustomEncoder : public NewEncoder {
CustomEncoder(uint8_t aPin, uint8_t bPin, int16_t initalValue, uint8_t type = FULL_PULSE) :
NewEncoder(aPin, bPin, INT16_MIN, INT16_MAX, initalValue, type) {}
virtual ~CustomEncoder() {}
virtual void configure(uint8_t aPin, uint8_t bPin, int16_t minValue, int16_t maxValue, int16_t initalValue, uint8_t type = FULL_PULSE);
void configure(uint8_t aPin, uint8_t bPin, int16_t initalValue, uint8_t type = FULL_PULSE);

protected:
virtual void updateValue(uint8_t updatedState);
};

void CustomEncoder::configure(uint8_t aPin, uint8_t bPin, int16_t minValue, int16_t maxValue, int16_t initalValue, uint8_t type) {
(void) minValue;
(void) maxValue;
configure(aPin, bPin, initalValue, type);
}

void CustomEncoder::configure(uint8_t aPin, uint8_t bPin, int16_t initalValue, uint8_t type) {
NewEncoder::configure(aPin, bPin, INT16_MIN, INT16_MAX, initalValue, type);
}

void CustomEncoder::updateValue(uint8_t updatedState) {
if ((updatedState & DELTA_MASK) == INCREMENT_DELTA) {
_currentValue += 3;
Expand Down

0 comments on commit 68483a8

Please sign in to comment.