PicoLC Arduino Library Arduino library for PicoLC hardware |
IEC-style timer using the shared PicoLC scan timebase. More...
#include <PicoLCTimer.h>
Public Member Functions | |
| PicoLCTimer (PicoLC &plc, TimerMode mode, uint32_t preset) | |
| Constructs a timer. | |
| void | presetMillis (uint32_t ms) |
| Sets the timer preset. | |
| uint32_t | presetMillis () const |
| Returns the configured timer preset. | |
| bool | update (bool input) |
| Applies a timer input and returns the resulting output state. | |
| bool | read () |
| Returns the timer output state. | |
| void | write (bool input) |
| Applies the current logical input to the timer. | |
| bool | running () const |
| Reports whether the timer is currently accumulating time. | |
| uint32_t | elapsed () const |
| Returns the accumulated timer value. | |
| uint32_t | remaining () const |
| Returns the time remaining before the preset is reached. | |
| void | reset () |
| Stops and clears the current timer operation. | |
IEC-style timer using the shared PicoLC scan timebase.
PicoLCTimer supports standard TON, TOF, and TP behavior. Timer state is evaluated using the timestamp captured at the start of the most recent PicoLC::update().
A timer should normally be serviced once per PicoLC scan.
Definition at line 18 of file PicoLCTimer.h.
| PicoLCTimer::PicoLCTimer | ( | PicoLC & | plc, |
| TimerMode | mode, | ||
| uint32_t | preset ) |
Constructs a timer.
| plc | PicoLC instance that provides the shared scan timebase. |
| mode | Standard timer operating mode. |
| preset | Initial timer preset in milliseconds. |
Definition at line 5 of file PicoLCTimer.cpp.
| uint32_t PicoLCTimer::elapsed | ( | ) | const |
Returns the accumulated timer value.
Definition at line 100 of file PicoLCTimer.cpp.
| uint32_t PicoLCTimer::presetMillis | ( | ) | const |
Returns the configured timer preset.
Definition at line 15 of file PicoLCTimer.cpp.
| void PicoLCTimer::presetMillis | ( | uint32_t | ms | ) |
Sets the timer preset.
Changing the preset does not alter the accumulated timer value. The new preset is used by the next read(), write(), or update() call and may immediately change the timer output or running state.
| ms | Timer preset in milliseconds. |
Definition at line 11 of file PicoLCTimer.cpp.
| bool PicoLCTimer::read | ( | ) |
Returns the timer output state.
The returned value represents the timer Q state evaluated against the timestamp captured at the start of the most recent PicoLC::update(). The call may complete a time-dependent state transition that does not require a new input value.
Definition at line 19 of file PicoLCTimer.cpp.
| uint32_t PicoLCTimer::remaining | ( | ) | const |
Returns the time remaining before the preset is reached.
Definition at line 107 of file PicoLCTimer.cpp.
| void PicoLCTimer::reset | ( | ) |
Stops and clears the current timer operation.
After reset(), a subsequent read() returns the same output state as a timer of the configured mode that has never been started.
Definition at line 118 of file PicoLCTimer.cpp.
| bool PicoLCTimer::running | ( | ) | const |
Reports whether the timer is currently accumulating time.
This is independent of the current input and output states.
Definition at line 96 of file PicoLCTimer.cpp.
| bool PicoLCTimer::update | ( | bool | input | ) |
Applies a timer input and returns the resulting output state.
This is equivalent to calling write(input) followed by read().
| input | Current logical timer input. |
Definition at line 91 of file PicoLCTimer.cpp.
| void PicoLCTimer::write | ( | bool | input | ) |
Applies the current logical input to the timer.
The input is processed according to the configured standard TON, TOF, or TP behavior. This method should normally be called once per PicoLC scan.
| input | Current logical timer input. |
Definition at line 49 of file PicoLCTimer.cpp.