-
-
Notifications
You must be signed in to change notification settings - Fork 257
SevenSegDigit object API
SevenSegDigit represents a color object that is represented by A, B, C, D, E, F, G, decimal, and special component values; which represent the names of the segments of a seven segment display.
There is one property that represent the component values of the segments. The values in each location range from 0 to 255. Black or off would 0 and white or full on would be 255. The index can be addressed by the enum LedSegment.
uint8_t Segment[Count];
There are also a few constant properties that are helpful to use. These are..
The highest value for a single segment element.
const static uint16_t Max = 255;
The number of segment elements. Useful when accessing the elements using the [] operators.
const static size_t Count = 9;
Construct a SevenSegDigit with all segments set to the provided brightness.
- defaultBrightness - the brightness applied to all segments; where (0) = off, (128) = dim, (255) = full bright
Construct a SevenSegDigit with a segment bitmask that brightness is applied to 1s and defaultBrightness is applied to the 0s.
- bitmask - a bit mask of segments to set, in order from left to right (.gfedcba).
- brightness - brightness level to apply to segments with a 1 in bit from bitmask.
- defaultBrightness - brightness level to apply to segments with a 0 in bit from bitmask.
SevenSegDigit(char letter, uint8_t brightness, uint8_t defaultBrightness = 0, bool maintainCase = false)
Construct a SevenSegDigit using the provided char mapped to segments.
- letter - ASCI char that gets mapped to segments to represent it
- brightness - brightness level to apply to char segments
- defaultBrightness - brightness level to apply to background segments
- maintainCase - should the mapping maintain the case of the given char, true - honor given case, false - force to capital
Construct a SevenSegDigit that will have its values set in latter operations.
CAUTION: The members are not initialized and may not be consistent.
CalculateBrightness will calculate the overall brightness.
NOTE: This is a simple linear brightness
Dim will return a new SevenSegDigit that is blended to off with the given ratio.
NOTE: This is a simple linear change.
- ratio - (0-255) where 255 will return the original color and 0 will return off.
Brighten will return a new SevenSegDigit that is blended to full on with the given ratio.
NOTE: This is a simple linear change.
- ratio - (0-255) where 255 will return the original color and 0 will return full on.
Darken will adjust the SevenSegDigit by the given delta toward off.
NOTE: This is a simple linear change.
- delta - (0-255) the amount to dim the SevenSegDigit by.
Lighten will adjust the SevenSegDigit by the given delta toward full on.
NOTE: This is a simple linear change.
- delta - (0-255) the amount to lighten the SevenSegDigit by.
This will blend between two SevenSegDigits by the amount defined by the progress variable.
- left - the SevenSegDigit to start the blend at.
- right - the SevenSegDigit to end the blend at.
- progress - (0.0f - 1.0f) value where 0.0f will return left and 1.0f will return right and a value between will blend the brightness of each segment weighted linearly between them.
This is a static function, which means you need to call it scoped to the object class and not an instance like...
SevenSegDigit results = SevenSegDigit::LinearBlend(SevenSegDigit('0', 255), SevenSegDigit('1', 255), 0.33f);
This will blend between two SevenSegDigits by the amount defined by the progress variable.
- left - the SevenSegDigit to start the blend at.
- right - the SevenSegDigit to end the blend at.
- progress - (0 - 255) value where 0 will return left and 255 will return right and a value between will blend the the brightness of each segment weighted linearly between them.
This is a static function, which means you need to call it scoped to the object class and not an instance like...
SevenSegDigit results = SevenSegDigit::LinearBlend(SevenSegDigit('0', 255), SevenSegDigit('1', 255), 85);
The index operator allows accessing the segments with an index directly on the object. There are both read only and read write versions.
uint8_t decimalBrightness = digit[LedSegment_Decimal];