Class Timer

Inheritance Relationships

Derived Type

Class Documentation

class Timer

Subclassed by PixelMaestro::AnimationTimer

Public Functions

Timer(uint16_t interval = 1000)

Constructor. Sets the speed interval.

Parameters
  • interval: Amount of time (in milliseconds) between events.

uint16_t get_interval() const

Returns the interval between events.

Return

Interval.

uint32_t get_last_time() const

Returns the last update time.

Return

Last update time.

bool get_running() const

Returns whether the Timer is currently running.

Return

true if running.

void set_interval(uint16_t interval)

Sets the amount of time between events.

Parameters
  • interval: Amount of time (in milliseconds) between events.

void set_last_time(uint32_t last_time = 0)

Sets the last time the timer ran.

Parameters
  • last_time: Time (in milliseconds) that the timer last ran.

void start()

Starts the timer.

void stop()

Stops the timer.

bool update(const uint32_t &current_time)

Checks if the timer has gone off.

Return

If the runtime exceeds the interval, return true.

Parameters
  • current_time: Current program runtime.

Protected Attributes

uint32_t last_time_ = 0

The amount of time (in milliseconds) since the last event.

uint16_t interval_ = 1000

The amount of time (in milliseconds) between events.

bool running_ = true

Whether the timer is currently running.