AceSegment  0.3.0
An adjustable, configurable, and extensible framework for rendering seven segment LED displays.
Public Member Functions | Static Public Attributes | List of all members
ace_segment::Renderer Class Reference

A class that knows how to translate an array of led segement bit patterns with style attributes to a displayable frame for the Driver class. More...

#include <Renderer.h>

Public Member Functions

 Renderer (Hardware *hardware, Driver *driver, StyledPattern *styledPatterns, uint8_t numDigits, uint8_t framesPerSecond, uint16_t statsResetInterval, Styler **stylers)
 Constructor. More...
 
virtual ~Renderer ()
 Destructor. More...
 
virtual void configure ()
 Configure the driver with the parameters given by in the constructor. More...
 
uint8_t getNumDigits ()
 Get the number of digits. More...
 
uint16_t getFramesPerSecond ()
 Return the frames per second. More...
 
uint16_t getFieldsPerSecond ()
 Return the fields per second. More...
 
void writeBrightness (uint8_t brightness)
 Set brightness expressed as a fraction of 256. More...
 
void writePatternAt (uint8_t digit, uint8_t pattern, uint8_t style)
 Write the pattern and style for a given digit. More...
 
void writePatternAt (uint8_t digit, uint8_t pattern)
 Write the pattern for a given digit, leaving style unchanged. More...
 
void writeStyleAt (uint8_t digit, uint8_t style)
 Write the style for a given digit, leaving pattern unchanged. More...
 
void writeDecimalPointAt (uint8_t digit, bool state=true)
 Write the decimal point for the digit. More...
 
void clear ()
 Clear all digits, preserving the styles at each digit. More...
 
bool renderFieldWhenReady ()
 Display one field of a frame when the time is right. More...
 
void renderField ()
 Render the current field immediately. More...
 
TimingStats getTimingStats ()
 Return stats. More...
 
StyledPatterngetStyledPattern (uint8_t i)
 Return a reference the styled digit. More...
 
bool isStylerSupported (Styler *styler)
 Return true if the given Styler is supported by the current Driver. More...
 
uint8_t * getActiveStyles ()
 Retrieve the array of active styles. More...
 

Static Public Attributes

static const uint8_t kNumStyles = 6
 Maximum number of styles. More...
 

Detailed Description

A class that knows how to translate an array of led segement bit patterns with style attributes to a displayable frame for the Driver class.

The supported style for each digit are (blinkSlow, blinkFast, pulseSlow, pulseFast).

A frame is divided into fields, which is a partial rendering of a frame. The renderField() (or renderFieldWhenReady()) method should be called to successively render each field of a frame.

Definition at line 48 of file Renderer.h.

Constructor & Destructor Documentation

◆ Renderer()

ace_segment::Renderer::Renderer ( Hardware hardware,
Driver driver,
StyledPattern styledPatterns,
uint8_t  numDigits,
uint8_t  framesPerSecond,
uint16_t  statsResetInterval,
Styler **  stylers 
)
inlineexplicit

Constructor.

Definition at line 58 of file Renderer.h.

◆ ~Renderer()

virtual ace_segment::Renderer::~Renderer ( )
inlinevirtual

Destructor.

Definition at line 75 of file Renderer.h.

Member Function Documentation

◆ clear()

void ace_segment::Renderer::clear ( )

Clear all digits, preserving the styles at each digit.

Definition at line 98 of file Renderer.cpp.

◆ configure()

void ace_segment::Renderer::configure ( )
virtual

Configure the driver with the parameters given by in the constructor.

Normally, this should be called only once after construction. Unit tests will sometimes change a parameter of FakeDriver and call this a second time.

Definition at line 34 of file Renderer.cpp.

◆ getActiveStyles()

uint8_t* ace_segment::Renderer::getActiveStyles ( )
inline

Retrieve the array of active styles.

VisibleForTesting.

Definition at line 168 of file Renderer.h.

◆ getFieldsPerSecond()

uint16_t ace_segment::Renderer::getFieldsPerSecond ( )
inline

Return the fields per second.

Definition at line 92 of file Renderer.h.

◆ getFramesPerSecond()

uint16_t ace_segment::Renderer::getFramesPerSecond ( )
inline

Return the frames per second.

Definition at line 89 of file Renderer.h.

◆ getNumDigits()

uint8_t ace_segment::Renderer::getNumDigits ( )
inline

Get the number of digits.

Definition at line 86 of file Renderer.h.

◆ getStyledPattern()

StyledPattern& ace_segment::Renderer::getStyledPattern ( uint8_t  i)
inline

Return a reference the styled digit.

VisibleForTesting.

Definition at line 157 of file Renderer.h.

◆ getTimingStats()

TimingStats ace_segment::Renderer::getTimingStats ( )

Return stats.

For debugging only. TimingStats is returned by 'value' to be safe from interrupts.

Definition at line 156 of file Renderer.cpp.

◆ isStylerSupported()

bool ace_segment::Renderer::isStylerSupported ( Styler styler)

Return true if the given Styler is supported by the current Driver.

VisibleForTesting.

Definition at line 150 of file Renderer.cpp.

◆ renderField()

void ace_segment::Renderer::renderField ( )

Render the current field immediately.

Designed to be called from a timer interrupt handler.

Definition at line 116 of file Renderer.cpp.

◆ renderFieldWhenReady()

bool ace_segment::Renderer::renderFieldWhenReady ( )

Display one field of a frame when the time is right.

This is a polling method, so call this slightly more frequently than getFieldsPerSecond().

Returns
Returns true if renderField() was called and the field was rendered. The flag can be used to optimize the polling of getTimingStats(). If the return value is false, there's no need to call getTimingStats() again, since it will not have changed.

Definition at line 104 of file Renderer.cpp.

◆ writeBrightness()

void ace_segment::Renderer::writeBrightness ( uint8_t  brightness)
inline

Set brightness expressed as a fraction of 256.

In other words, 255 is brightest (default); 1 is 1/256 of full brightness. Requires the support of useModulatingDriver() option in DriverBuilder. If the driver doesn't support brightness, then anything above 0 is full brightness and 0 turns off the digit.

Definition at line 103 of file Renderer.h.

◆ writeDecimalPointAt()

void ace_segment::Renderer::writeDecimalPointAt ( uint8_t  digit,
bool  state = true 
)

Write the decimal point for the digit.

Definition at line 89 of file Renderer.cpp.

◆ writePatternAt() [1/2]

void ace_segment::Renderer::writePatternAt ( uint8_t  digit,
uint8_t  pattern,
uint8_t  style 
)

Write the pattern and style for a given digit.

If the digit is out of bounds, the method does nothing. If the style is out of bounds or not registered, the method does nothing.

Definition at line 56 of file Renderer.cpp.

◆ writePatternAt() [2/2]

void ace_segment::Renderer::writePatternAt ( uint8_t  digit,
uint8_t  pattern 
)

Write the pattern for a given digit, leaving style unchanged.

If the digit is out of bounds, the method does nothing.

Definition at line 70 of file Renderer.cpp.

◆ writeStyleAt()

void ace_segment::Renderer::writeStyleAt ( uint8_t  digit,
uint8_t  style 
)

Write the style for a given digit, leaving pattern unchanged.

If the style is out of bounds or not registered, the method does nothing.

Definition at line 76 of file Renderer.cpp.

Member Data Documentation

◆ kNumStyles

const uint8_t ace_segment::Renderer::kNumStyles = 6
static

Maximum number of styles.

Valid style indexes are [0, kNumStyles-1]. Style 0 is reserved for "no-style" and cannot be changed by the user, so the number of user-accessible styles is (kNumStyles - 1).

Definition at line 55 of file Renderer.h.


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