semf
digitalin.cpp
Go to the documentation of this file.
1
12
13namespace semf
14{
15DigitalIn::DigitalIn(Gpio& gpio, bool inverted)
16: m_gpio(&gpio),
17 m_inverted(inverted)
18{
19}
20
22{
23 return m_inverted;
24}
25
26void DigitalIn::setInverted(bool inverted)
27{
28 SEMF_INFO("set inverted: %d", inverted);
29 m_inverted = inverted;
30}
31
33{
34 if (!m_inverted)
35 return static_cast<State>(m_gpio->state());
36 else
37 return static_cast<State>(!m_gpio->state());
38}
39
41{
42 return *m_gpio;
43}
44} /* namespace semf */
bool isInverted() const override
Returns of the pin level logic is inverted.
Definition: digitalin.cpp:21
Gpio & gpio() const
Returns the pointer to the GPIO to check the status from.
Definition: digitalin.cpp:40
void setInverted(bool inverted) override
Configures the inversion of the input reading.
Definition: digitalin.cpp:26
DigitalIn(Gpio &gpio, bool inverted=false)
Constructor.
Definition: digitalin.cpp:15
State state() const override
Returns the level status of the hardware pin.
Definition: digitalin.cpp:32
Interface class for using a GPIO pin of the microcontroller.
Definition: gpio.h:23
virtual bool state() const =0
Returns the current state of the pin.
#define SEMF_INFO(...)
Definition: debug.h:41