Refactor implementation and add new settings to save state.
This commit is contained in:
@ -19,6 +19,8 @@ const int CALIBRATED_HIGH = 512;
|
||||
|
||||
class AnalogInput {
|
||||
public:
|
||||
static const int GATE_THRESHOLD = 0;
|
||||
|
||||
AnalogInput() {}
|
||||
~AnalogInput() {}
|
||||
|
||||
@ -74,6 +76,18 @@ class AnalogInput {
|
||||
*/
|
||||
inline float Voltage() { return ((read_ / 512.0) * 5.0); }
|
||||
|
||||
/**
|
||||
* Checks for a rising edge transition across a threshold.
|
||||
*
|
||||
* @param threshold The value that the input must cross.
|
||||
* @return True if the value just crossed the threshold from below, false otherwise.
|
||||
*/
|
||||
inline bool IsRisingEdge(int16_t threshold) const {
|
||||
bool was_high = old_read_ > threshold;
|
||||
bool is_high = read_ > threshold;
|
||||
return is_high && !was_high;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t pin_;
|
||||
int16_t read_;
|
||||
|
||||
@ -82,7 +82,6 @@ class DigitalOutput {
|
||||
unsigned long last_triggered_;
|
||||
uint8_t trigger_duration_;
|
||||
uint8_t cv_pin_;
|
||||
uint8_t led_pin_;
|
||||
bool on_;
|
||||
|
||||
void update(uint8_t state) {
|
||||
|
||||
Reference in New Issue
Block a user