AceSegment
0.3.0
An adjustable, configurable, and extensible framework for rendering seven segment LED displays.
|
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... | |
StyledPattern & | getStyledPattern (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... | |
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.
|
inlineexplicit |
Constructor.
Definition at line 58 of file Renderer.h.
|
inlinevirtual |
Destructor.
Definition at line 75 of file Renderer.h.
void ace_segment::Renderer::clear | ( | ) |
Clear all digits, preserving the styles at each digit.
Definition at line 98 of file Renderer.cpp.
|
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.
|
inline |
|
inline |
Return the fields per second.
Definition at line 92 of file Renderer.h.
|
inline |
Return the frames per second.
Definition at line 89 of file Renderer.h.
|
inline |
Get the number of digits.
Definition at line 86 of file Renderer.h.
|
inline |
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.
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.
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.
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().
Definition at line 104 of file Renderer.cpp.
|
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.
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.
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.
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.
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.
|
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.