2 #include "DiscretePot.h" 15 _threshold = threshold;
22 if (DoEvery(_delay, _lastUpdate)) {
23 int8_t valueNow = _value();
24 if (valueNow != _state) {
26 if (_counter > _threshold) {
29 }
else if (_counter > 0) {
40 int8_t DiscretePot::_value()
43 int raw = analogRead(_pin);
44 int stepsize = 1023/(_max - _min);
46 return _max-(raw/stepsize);
48 return (raw/stepsize)+_min;
52 void DiscretePot::setState(int8_t newState)
54 _lastStateChange = Millis();
DiscretePot(const uint8_t pin)
void begin(int8_t min=0, int8_t max=11, bool reversed=false, uint8_t threshold=AbstractDebouncedButton::DefaultThreshold, uint8_t delay=AbstractDebouncedButton::DefaultButtonDelay)