semf
digitalinpolling.cpp
Go to the documentation of this file.
1
12
13namespace semf
14{
16: DigitalIn(gpio, inverted)
17{
18 m_state = DigitalIn::state();
19}
20
22: DigitalIn(gpio, inverted)
23{
24 timeBase.add(*this);
25 m_state = DigitalIn::state();
26}
27
29{
31 if (state() == app::DigitalIn::State::Low && newState == app::DigitalIn::State::High)
32 {
33 setState(State::High);
34 SEMF_INFO("changed to high");
36 }
37 else if (state() == State::High && newState == app::DigitalIn::State::Low)
38 {
39 setState(app::DigitalIn::State::Low);
40 SEMF_INFO("changed to low");
42 }
43}
44
46{
47 return m_state;
48}
49
51{
52 SEMF_INFO("set state to %s", state == State::High ? "high" : "low");
53 m_state = state;
54}
55} /* namespace semf */
Base class for having access to the level state of a digital input.
Definition: digitalin.h:23
State state() const override
Returns the level status of the hardware pin.
Definition: digitalin.cpp:32
State state() const override
Returns the level status of the hardware pin.
void setState(State state)
Sets the hardware pin status internally.
DigitalInPolling(Gpio &gpio, bool inverted=false)
Constructor.
Interface class for using a GPIO pin of the microcontroller.
Definition: gpio.h:23
A TimeBase is the bridge between e.g. a hardware timer (interrupt service routine) and TickReceiver o...
Definition: timebase.h:36
virtual void add(TickReceiver &tickReceiver)=0
Adds e.g. a timer to this timebase.
#define SEMF_INFO(...)
Definition: debug.h:41