Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
|
#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 () |
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.
struct Heartbeat::Times |
Definition at line 38 of file Heartbeat.h.
Class Members | ||
---|---|---|
Mode | mode | |
uint16_t | offTime | |
uint16_t | onTime |
enum Heartbeat::Mode |
Flashing mode
Definition at line 27 of file Heartbeat.h.
Heartbeat::Heartbeat | ( | const uint8_t | pin, |
const bool | invertedLogic = false |
||
) |
Constructor.
pin | the pin connected to the indicator LED, often 13 for built-in LED. |
invertedLogic | invert the logic of the pin (useful for using D0 on the ESP8266, which has inverted logic). |
Definition at line 6 of file Heartbeat.cpp.
void Heartbeat::begin | ( | ) |
Initialization.
Should be called from setup() - sets the pin mode.
Definition at line 23 of file Heartbeat.cpp.
Heartbeat::Mode Heartbeat::mode | ( | ) |
Get current flashing mode.
Definition at line 28 of file Heartbeat.cpp.
void Heartbeat::setCustomMode | ( | uint16_t | onTime, |
uint16_t | offTime | ||
) |
Set custom flashing timing.
onTime | how long the LED stays on in ms. |
offTime | how long the LED stays off in ms. |
Definition at line 79 of file Heartbeat.cpp.
void Heartbeat::setEnabled | ( | bool | on = true | ) |
void Heartbeat::setMode | ( | Mode | mode | ) |
Set flashing mode.
mode | the new mode to use. |
Definition at line 33 of file Heartbeat.cpp.
void Heartbeat::setMode | ( | Heartbeat::Times | times | ) |
Set flashing mode.
times | retrieved 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.
Heartbeat::Times Heartbeat::times | ( | ) |
Get current on and off times.
Definition at line 114 of file Heartbeat.cpp.
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.