adapnex::core::ClockGenerator

A pulse generator that creates cyclic pulses at a defined interval.

Synopsis

Declared in <adapnex/core/timer.h>

class ClockGenerator;

Description

When enabled (EN is true), output CLK becomes true for exactly one cycle every time the duration PT elapses.

Clock Generator Timing Diagram

Parameter Type Direction Description

EN

bool

Input

Enables cyclic pulse generation when true.

PT

Duration

Input

The preset time duration between generated pulses.

CLK

bool

Output

Becomes true for exactly one execution cycle every time PT elapses.

Common Use Case

Triggering periodic events, such as logging data or blinking a status indicator.

Example: Periodic Logging

class LoggerTask : public Task {
public:
    bool enable_logging = true;

private:
    ClockGenerator log_clock;

    void Update() override {
        // Trigger a log entry every 1 minute.
        log_clock(enable_logging, 1min);

        if (log_clock.CLK) {
            // Perform logging operation here.
        }
    }
};

Generators maintain internal state across cycles and must be instantiated as member variables of a task rather than local variables within Update().

Member Functions

Name

Description

operator()

Function call operators

Data Members

Name

Description

CLK

Output that becomes true for one invocation every time the duration PT has passed.

EN

Input that enables the pulse generation when true.

PT

Input defining the duration between the generated pulses.

Created with MrDocs