PicoLC Arduino Library
Arduino library for PicoLC hardware
Loading...
Searching...
No Matches
PicoLCTimer Class Reference

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ PicoLCTimer()

PicoLCTimer::PicoLCTimer(PicoLC &plc,
TimerModemode,
uint32_tpreset )

Constructs a timer.

Parameters
plcPicoLC instance that provides the shared scan timebase.
modeStandard timer operating mode.
presetInitial timer preset in milliseconds.

Definition at line 5 of file PicoLCTimer.cpp.

Member Function Documentation

◆ elapsed()

uint32_t PicoLCTimer::elapsed()const

Returns the accumulated timer value.

Returns
Elapsed timer value in milliseconds.

Definition at line 100 of file PicoLCTimer.cpp.

◆ presetMillis() [1/2]

uint32_t PicoLCTimer::presetMillis()const

Returns the configured timer preset.

Returns
Timer preset in milliseconds.

Definition at line 15 of file PicoLCTimer.cpp.

◆ presetMillis() [2/2]

void PicoLCTimer::presetMillis(uint32_tms)

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.

Parameters
msTimer preset in milliseconds.

Definition at line 11 of file PicoLCTimer.cpp.

◆ read()

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.

Returns
Current timer Q state.

Definition at line 19 of file PicoLCTimer.cpp.

◆ remaining()

uint32_t PicoLCTimer::remaining()const

Returns the time remaining before the preset is reached.

Returns
Remaining timer value in milliseconds.

Definition at line 107 of file PicoLCTimer.cpp.

◆ reset()

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.

◆ running()

bool PicoLCTimer::running()const

Reports whether the timer is currently accumulating time.

This is independent of the current input and output states.

Returns
true while the timer is accumulating elapsed time.

Definition at line 96 of file PicoLCTimer.cpp.

◆ update()

bool PicoLCTimer::update(boolinput)

Applies a timer input and returns the resulting output state.

This is equivalent to calling write(input) followed by read().

Parameters
inputCurrent logical timer input.
Returns
Timer Q state.

Definition at line 91 of file PicoLCTimer.cpp.

◆ write()

void PicoLCTimer::write(boolinput)

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.

Parameters
inputCurrent logical timer input.

Definition at line 49 of file PicoLCTimer.cpp.


The documentation for this class was generated from the following files: