refactor var names and improve docs

This commit is contained in:
2025-05-24 00:30:59 -07:00
parent 392f4fffc7
commit db8c894927

View File

@ -35,19 +35,19 @@ class AnalogInput {
void Process() { void Process() {
old_read_ = read_; old_read_ = read_;
int raw = analogRead(pin_); int raw = analogRead(pin_);
read_ = map(raw, calibration_offset_, MAX_INPUT, calibration_low_, calibration_high_); read_ = map(raw, offset_, MAX_INPUT, low_, high_);
} }
// Set calibration values. // Set calibration values.
void AdjustCalibrationLow(int val) { calibration_low_ += val; } void AdjustCalibrationLow(int amount) { low_ += amount; }
void AdjustCalibrationOffset(int val) { calibration_offset_ += val; } void AdjustCalibrationOffset(int amount) { offset_ += amount; }
void AdjustCalibrationHigh(int val) { calibration_high_ += val; } void AdjustCalibrationHigh(int amount) { high_ += amount; }
/** /**
* @brief Get the current value of the analog input within a range of +/-512. * @brief Get the current value of the analog input within a range of +/-512.
* *
* @return InputState * @return read value within a range of +/-512.
*/ */
inline int16_t Read() { return read_; } inline int16_t Read() { return read_; }
@ -55,9 +55,10 @@ class AnalogInput {
uint8_t pin_; uint8_t pin_;
int16_t read_; int16_t read_;
uint16_t old_read_; uint16_t old_read_;
int calibration_offset_ = 0; // calibration values.
int calibration_low_ = -512; int offset_ = 0;
int calibration_high_ = 512; int low_ = -512;
int high_ = 512;
}; };
#endif #endif