MCPcopy Create free account
hub / github.com/JChristensen/JC_Button / begin

Method begin

src/JC_Button.cpp:9–17  ·  view source on GitHub ↗

initialize a Button object

Source from the content-addressed store, hash-verified

7
8// initialize a Button object
9void Button::begin()
10{
11 pinMode(m_pin, m_puEnable ? INPUT_PULLUP : INPUT);
12 m_state = static_cast<bool>(digitalRead(m_pin)) ^ m_invert;
13 m_time = millis();
14 m_lastState = m_state;
15 m_changed = false;
16 m_lastChange = m_time;
17}
18
19// returns the state of the button, true if pressed, false if released.
20// does debouncing, captures and maintains times, previous state, etc.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected