|
Open Model Railroad Network (OpenMRN)
|
Class that implements a Charlieplexing LED driver, operating N choose 2 output LEDs from N GPIO pins. More...
#include <Charlieplex.hxx>
Public Member Functions | |
| Charlieplex (const Gpio *const pins[N]) | |
| Constructor. | |
| void | tick () |
| Switches to the next output configuration of the charlieplexing pins. | |
| unsigned * | payload () |
Private Attributes | |
| const Gpio *const * | pins_ |
| array of all GPIO pins to use | |
| unsigned | nextBit_ |
| LED that comes next. | |
| unsigned | bits_ |
| Desired output state of LEDs. | |
Class that implements a Charlieplexing LED driver, operating N choose 2 output LEDs from N GPIO pins.
Usage:
Specify the iteration over the pairs of pins like above if you have more than 3 pins.
Create the Charlieplex instance with supplying the Gpio object pointers. The object pointers could point to flash.
Set the desired values for the individual LEDs through payload(). Bit 0 in the pointed object will be the output led 0.
From a hardware timer interrupt repeatedly call the tick() function. A rate of 100 Hz * number of LEDs is advised. It is important that the time between different calls of tick() be somewhat homogenous or else an equal intensity of the individual LEDs that are turned on cannot be guaranteed.
Definition at line 135 of file Charlieplex.hxx.
|
inline |
Constructor.
| pins | an array of Gpio object pointers defining the output pins to use. This array may be in flash (.rodata). |
Definition at line 143 of file Charlieplex.hxx.
|
inline |
Definition at line 179 of file Charlieplex.hxx.
|
inline |
Switches to the next output configuration of the charlieplexing pins.
Call this repeatedly, for example from a hardware timer interrupt.
Definition at line 157 of file Charlieplex.hxx.
|
private |
Desired output state of LEDs.
Definition at line 187 of file Charlieplex.hxx.
|
private |
LED that comes next.
Definition at line 186 of file Charlieplex.hxx.
|
private |
array of all GPIO pins to use
Definition at line 185 of file Charlieplex.hxx.