Public Types |
| enum | Type { pull_up_internal,
pull_up,
pull_down
} |
| | Types of switches. More...
|
Public Member Functions |
| | SwitchInput (int pin, unsigned long debounce=DEFAULT_DEBOUNCE, Type type=pull_up_internal) |
| | Constructor.
|
|
virtual | ~SwitchInput () |
| | Destructor.
|
| bool | is_closed () const |
| | Checks to see if the switch is closed.
|
| bool | is_open () const |
| | Checks to see if the switch is open.
|
|
virtual void | on_close () |
| | Called once when the switch closes.
|
|
virtual void | on_open () |
| | Called once when the switch opens.
|
| unsigned long | time_closed () const |
| | Checks the length of time the switch has been closed.
|
| unsigned long | time_open () const |
| | Checks the length of time the switch has been open.
|
Protected Member Functions |
| bool | loop () |
| | Main loop.
|
Private Attributes |
|
unsigned long | debounce |
| | The debounce time (in milliseconds).
|
|
unsigned long | last_change |
| | The time of the last change (in millisecnods, ignoring debounce).
|
|
unsigned long | last_debounce |
| | The time of the last change (in milliseconds, after debounce filtering).
|
|
int | current_value |
| | The switch's current value (after debounce filtering).
|
|
int | last_value |
| | The switch's value on the last read (ignoring debounce).
|
|
int | pin |
| | The pin the switch is connected to.
|
|
Type | type |
| | The type of switch connected.
|
Handler for a switch input.