semf
|
The classes semf::DigitalInPolling, semf::DebouncedDigitalInPolling and semf::DigitalInInt handle and process the digital input signal from a normal semf::Gpio or an semf::ExternalInterrupt input. To configure an inverted input, call the setInverted()
function. Alternativly you can set the inverted
flag in the constructor. These classss dependend on a semf supplied interface class semf::Gpio which links the hardware input pin of the microcontroller and the semf library. All three implementations are based on the interface semf::app::DigitalIn.
The class triggers two signals after changing the digital input: changedToHigh
and changedToLow
. The hardware semf::Gpio pins can easily be configured either by using the vendors hardware configuration tool e.g. stm-cube or by calling the hardware functions for setting the pin.
To use a normal GPIO as input (without external interrupt handling) you can set up a semf::DigitalInPolling object. Take care, that the tick()
function is called periodically e.g. by a semf::app::TimeBase.
changedToHigh
and changedToLow
signals must be connected to their corresponding slots. Checking the state of the the digital pin can be done manually at any point in time.
Often digital inputs, e.g. buttons, have to be debounced for a certain time. This can easily be done by using a semf::DebouncedDigitalInPolling object. It can be used same as the base class semf::DigitalInPolling with the extra feature of setting a debounced low and high time for signal excecution.
The Usage is analog to semf::DigitalInPolling.
Take care that the external interrupt is configured correctly. For using a semf::Gpio as input triggered by an semf::ExternalInterrupt semf::DigitalInInt is the best choice. For external interrupt driven inputs no timer is neccessary.
The Usage is analog to semf::DigitalInPolling.