Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
WeightedCharlieplex< N, helper > Class Template Reference

Variant of the Charlieplex class that allows intensity to be set for each individual pin. More...

#include <Charlieplex.hxx>

Public Member Functions

 WeightedCharlieplex (const Gpio *const pins[helper::num_bits()])
 Constructor.
 
void tick ()
 Switches to the next output configuration of the charlieplexing pins.
 
unsigned * payload ()
 
uint8_t * desired_intensity ()
 

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.
 
uint8_t desiredIntensity_ [helper::num_bits()]
 Partial lighting of each output.
 
uninitialized< Fixed16actualIntensity_ [helper::num_bits()]
 How much we actually lit a given pin.
 

Static Private Attributes

static constexpr Fixed16 EWMA_RATIO {0, 0xF000}
 
static constexpr Fixed16 EWMA_SUM {16, 0}
 

Detailed Description

template<unsigned N, class helper = CharlieplexHelper<N>>
class WeightedCharlieplex< N, helper >

Variant of the Charlieplex class that allows intensity to be set for each individual pin.

Definition at line 192 of file Charlieplex.hxx.

Constructor & Destructor Documentation

◆ WeightedCharlieplex()

template<unsigned N, class helper = CharlieplexHelper<N>>
WeightedCharlieplex< N, helper >::WeightedCharlieplex ( const Gpio *const  pins[helper::num_bits()])
inline

Constructor.

Parameters
pinsan array of Gpio object pointers defining the output pins to use. This array may be in flash (.rodata).

Definition at line 200 of file Charlieplex.hxx.

Member Function Documentation

◆ desired_intensity()

template<unsigned N, class helper = CharlieplexHelper<N>>
uint8_t * WeightedCharlieplex< N, helper >::desired_intensity ( )
inline
Returns
the storage where the desired intensity can be written for partial lighting.

Definition at line 262 of file Charlieplex.hxx.

◆ payload()

template<unsigned N, class helper = CharlieplexHelper<N>>
unsigned * WeightedCharlieplex< N, helper >::payload ( )
inline
Returns
the storage representing the state of the output bits. Bit 0 is LED0, bit 1 is LED1, etc.

Definition at line 255 of file Charlieplex.hxx.

◆ tick()

template<unsigned N, class helper = CharlieplexHelper<N>>
void WeightedCharlieplex< N, helper >::tick ( )
inline

Switches to the next output configuration of the charlieplexing pins.

Call this repeatedly, for example from a hardware timer interrupt.

Definition at line 218 of file Charlieplex.hxx.

Member Data Documentation

◆ actualIntensity_

template<unsigned N, class helper = CharlieplexHelper<N>>
uninitialized<Fixed16> WeightedCharlieplex< N, helper >::actualIntensity_[helper::num_bits()]
private

How much we actually lit a given pin.

Definition at line 275 of file Charlieplex.hxx.

◆ bits_

template<unsigned N, class helper = CharlieplexHelper<N>>
unsigned WeightedCharlieplex< N, helper >::bits_
private

Desired output state of LEDs.

Definition at line 273 of file Charlieplex.hxx.

◆ desiredIntensity_

template<unsigned N, class helper = CharlieplexHelper<N>>
uint8_t WeightedCharlieplex< N, helper >::desiredIntensity_[helper::num_bits()]
private

Partial lighting of each output.

Definition at line 274 of file Charlieplex.hxx.

◆ EWMA_RATIO

template<unsigned N, class helper = CharlieplexHelper<N>>
constexpr Fixed16 WeightedCharlieplex< N, helper >::EWMA_RATIO {0, 0xF000}
staticconstexprprivate

Definition at line 268 of file Charlieplex.hxx.

◆ EWMA_SUM

template<unsigned N, typename helper >
constexpr Fixed16 WeightedCharlieplex< N, helper >::EWMA_SUM {16, 0}
staticconstexprprivate

Definition at line 269 of file Charlieplex.hxx.

◆ nextBit_

template<unsigned N, class helper = CharlieplexHelper<N>>
unsigned WeightedCharlieplex< N, helper >::nextBit_
private

LED that comes next.

Definition at line 272 of file Charlieplex.hxx.

◆ pins_

template<unsigned N, class helper = CharlieplexHelper<N>>
const Gpio* const* WeightedCharlieplex< N, helper >::pins_
private

array of all GPIO pins to use

Definition at line 271 of file Charlieplex.hxx.


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