Noiasca Tool Kit
Several helper functions and classes to make life with Arduino easier
|
traffic light More...
#include <Noiasca_led.h>
Public Member Functions | |
Trafficlight (T &obj) | |
constructor for a traffic light More... | |
void | begin () |
start hardware More... | |
void | setInterval (uint16_t _on) |
set on times More... | |
int | setSequenceIndex (uint8_t index, uint8_t newState, uint16_t newInterval) |
set the sequence parameters More... | |
int | setSequenceMax (uint8_t newMax) |
set the number of sequences More... | |
void | setMode (Mode newMode) |
set the current Mode of the traffic light More... | |
void | setOnStateChange (Callback funcPtr) |
set the callback function onStateChange More... | |
void | setOnSequenceChange (Callback funcPtr) |
set the callback function onSequnceChange More... | |
void | setOnColor (uint16_t actual, uint32_t _on) |
set the color for a traffic light More... | |
void | setOffColor (uint32_t _off) |
set the color for a traffic light More... | |
void | setState (uint8_t newState) |
set the state of the traffic light More... | |
void | update (uint32_t currentMillis=millis()) |
check if update is necessary More... | |
traffic light
state // 0 OFF, 1 RED, 2 REDYELLOW, 3 GREEN, 4 YELLOW, 5 YELLOWBLINK, 6 GREENBLINK
mode // 0 manual // 1 automatic // 2 redgreenonly / 3 automaticAT
interval as array sequence (order, interval)
doesn't inherit from LedBase
|
inline |
constructor for a traffic light
obj | a object with 3 lamps |
|
inline |
start hardware
Will do the necessary steps to initialize the hardware pins. Call this function in your setup().
|
inline |
set on times
Set the on interval.
_on | the on interval |
|
inline |
set the sequence parameters
By default there are 4 predefined sequences - you can define up to 8. You can modify each entry including the durance of each interval (in ms). For example: in Austria or Ukraine you can add (insert) a green blinking light sequnce
index | the number of the sequnce. |
newState | the state (the face) of the sequence. |
newInterval | the interval (durance) of the sequence in ms. |
|
inline |
set the number of sequences
By default there are 4 predefined sequences - you can define up to 8.
newMax | the maximum number of sequences |
|
inline |
set the current Mode of the traffic light
default state is Trafficlight::Mode::AUTOMATIC, but you can change it to Trafficlight::Mode::AUTOMATIC
newMode | set to Trafficlight::Mode::AUTOMATIC or Trafficlight::Mode::Manual |
|
inline |
set the callback function onStateChange
a callback function receives state changes from the car traffic light
funcPtr | the callback function |
|
inline |
set the callback function onSequnceChange
a callback function receives changes of the sequence (faces). For example to keep another traffic light in sync, like a pedestrain trafficlight or the crossing line.
funcPtr | the callback function |
|
inline |
set the color for a traffic light
actual | 0 for red, 1 for yellow, 2 for green |
_on | the color code in HEX |
|
inline |
set the color for a traffic light
_off | the color code in HEX |
|
inline |
set the state of the traffic light
newState | the new state |
|
inline |
check if update is necessary
This is the "run" function. Call this function in loop() to make the effect visible.
currentMillis | you can handover a millis timestamp |