Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
Heartbeat Class Reference

#include <Heartbeat.h>

Classes

struct  Times
 

Public Types

enum  Mode {
  Normal =0, Quick, Quicker, Slow,
  Slower, Off, On, Custom
}
 

Public Member Functions

 Heartbeat (const uint8_t pin, const bool invertedLogic=false)
 
void begin ()
 
Mode mode ()
 
void setMode (Mode mode)
 
void setMode (Times times)
 
void setCustomMode (uint16_t onTime, uint16_t offTime)
 
void update ()
 
void setEnabled (bool on=true)
 
Times times ()
 

Static Public Attributes

static const uint16_t NormalOnMs = 50
 
static const uint16_t NormalOffMs = 450
 
static const uint16_t QuickOnMs = 25
 
static const uint16_t QuickOffMs = 125
 
static const uint16_t QuickerOnMs = 25
 
static const uint16_t QuickerOffMs = 25
 
static const uint16_t SlowOnMs = 50
 
static const uint16_t SlowOffMs = 950
 
static const uint16_t SlowerOnMs = 50
 
static const uint16_t SlowerOffMs = 1950
 

Detailed Description

LED flashing status indicator.

The Heartbeat class flashes an LED periodically to indicate the state of the system. A Heartbeat can be set to one of several modes, which changes the rate of flashing to indicate different firmware states.

Definition at line 12 of file Heartbeat.h.


Class Documentation

◆ Heartbeat::Times

struct Heartbeat::Times

Definition at line 38 of file Heartbeat.h.

Class Members
Mode mode
uint16_t offTime
uint16_t onTime

Member Enumeration Documentation

◆ Mode

Flashing mode

Enumerator
Normal 

blinks every 500ms

Quick 

blinks every 150ms

Quicker 

blinks every 50ms

Slow 

blinks every 1000ms

Slower 

blinks every 2000ms

Off 

LED constant off.

On 

LED constant on.

Custom 

Indicates custom on/off times (set with setCustomMode)

Definition at line 27 of file Heartbeat.h.

Constructor & Destructor Documentation

◆ Heartbeat()

Heartbeat::Heartbeat ( const uint8_t  pin,
const bool  invertedLogic = false 
)

Constructor.

Parameters
pinthe pin connected to the indicator LED, often 13 for built-in LED.
invertedLogicinvert the logic of the pin (useful for using D0 on the ESP8266, which has inverted logic).

Definition at line 6 of file Heartbeat.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ begin()

void Heartbeat::begin ( )

Initialization.

Should be called from setup() - sets the pin mode.

Definition at line 23 of file Heartbeat.cpp.

◆ mode()

Heartbeat::Mode Heartbeat::mode ( )

Get current flashing mode.

Definition at line 28 of file Heartbeat.cpp.

Here is the caller graph for this function:

◆ setCustomMode()

void Heartbeat::setCustomMode ( uint16_t  onTime,
uint16_t  offTime 
)

Set custom flashing timing.

Parameters
onTimehow long the LED stays on in ms.
offTimehow long the LED stays off in ms.

Definition at line 79 of file Heartbeat.cpp.

Here is the caller graph for this function:

◆ setEnabled()

void Heartbeat::setEnabled ( bool  on = true)

Turn on/off the heartbeat.

Note: over-rides setMode()

Definition at line 123 of file Heartbeat.cpp.

◆ setMode() [1/2]

void Heartbeat::setMode ( Mode  mode)

Set flashing mode.

Parameters
modethe new mode to use.

Definition at line 33 of file Heartbeat.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMode() [2/2]

void Heartbeat::setMode ( Heartbeat::Times  times)

Set flashing mode.

Parameters
timesretrieved from the times() call.

If mode is not Custom, setMode(Mode) will be used to set the on and off times, else setCustomMode() will be called with the values from times().

Definition at line 71 of file Heartbeat.cpp.

Here is the call graph for this function:

◆ times()

Heartbeat::Times Heartbeat::times ( )

Get current on and off times.

Definition at line 114 of file Heartbeat.cpp.

Here is the caller graph for this function:

◆ update()

void Heartbeat::update ( )

Timeslice allocation.

Should be called frequently - usually from the loop() function in your sketch.

Definition at line 86 of file Heartbeat.cpp.


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