MCPcopy Create free account
hub / github.com/OpenEarable/open-earable / _read_state

Method _read_state

src/button_service/Button.cpp:28–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28void Button::_read_state() {
29 bool reading = digitalRead(_pin);
30
31 //if (_inverted) reading = !reading;
32 reading = _inverted ^ reading;
33
34 unsigned long now = millis();
35
36 if (!reading) {
37 if (_buttonState != RELEASED) {
38 button_service.write_state(RELEASED);
39 }
40 _buttonState = RELEASED;
41 _lastDebounceTime = now;
42 _pressStartTime = now;
43 return;
44 }
45
46 if (now - _lastDebounceTime < _debounceDelay) return;
47 _buttonState = PRESSED;
48 button_service.write_state(_buttonState);
49}
50
51ButtonState Button::getState() const {
52 return _buttonState;

Callers 1

Calls 1

write_stateMethod · 0.80

Tested by

no test coverage detected