| 28 | // ============================================================================ |
| 29 | |
| 30 | Potentiometer::Potentiometer(int pin, u16 hysteresis) |
| 31 | : mPot(pin), mListener(this), mHysteresis(hysteresis) { |
| 32 | // Initialize calibration range to full ADC range |
| 33 | mMinValue = 0; |
| 34 | mMaxValue = getAdcMaxValue(); |
| 35 | |
| 36 | // Read initial value |
| 37 | mCurrentValue = mPot.read(); |
| 38 | mLastValue = mCurrentValue; |
| 39 | |
| 40 | // Auto-calculate hysteresis if not specified (1% of calibrated range) |
| 41 | if (mHysteresis == 0) { |
| 42 | mHysteresis = calculateDefaultHysteresis(); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | float Potentiometer::normalized() const { |
| 47 | // Handle invalid range |