refactor var names and improve docs
This commit is contained in:
@ -35,19 +35,19 @@ class AnalogInput {
|
||||
void Process() {
|
||||
old_read_ = read_;
|
||||
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.
|
||||
|
||||
void AdjustCalibrationLow(int val) { calibration_low_ += val; }
|
||||
void AdjustCalibrationOffset(int val) { calibration_offset_ += val; }
|
||||
void AdjustCalibrationHigh(int val) { calibration_high_ += val; }
|
||||
void AdjustCalibrationLow(int amount) { low_ += amount; }
|
||||
void AdjustCalibrationOffset(int amount) { offset_ += amount; }
|
||||
void AdjustCalibrationHigh(int amount) { high_ += amount; }
|
||||
|
||||
/**
|
||||
* @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_; }
|
||||
|
||||
@ -55,9 +55,10 @@ class AnalogInput {
|
||||
uint8_t pin_;
|
||||
int16_t read_;
|
||||
uint16_t old_read_;
|
||||
int calibration_offset_ = 0;
|
||||
int calibration_low_ = -512;
|
||||
int calibration_high_ = 512;
|
||||
// calibration values.
|
||||
int offset_ = 0;
|
||||
int low_ = -512;
|
||||
int high_ = 512;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user