mirror of
https://github.com/Makuna/NeoPixelBus.git
synced 2025-08-08 05:14:26 +02:00
Created SevenSegDigit object API (markdown)
93
SevenSegDigit-object-API.md
Normal file
93
SevenSegDigit-object-API.md
Normal file
@@ -0,0 +1,93 @@
|
||||
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.
|
||||
|
||||
## Properties
|
||||
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,0,0 and white or full on would be 255,255,255. The index can be addressed by [LedSegment enum](https://github.com/Makuna/NeoPixelBus/wiki/LedSegment-enum)`.
|
||||
```
|
||||
uint8_t Segment[Count];
|
||||
```
|
||||
|
||||
There are also a few constant properties that are helpful to use. These are..
|
||||
#### Max
|
||||
The highest value for a single segment element.
|
||||
```
|
||||
const static uint16_t Max = 255;
|
||||
```
|
||||
#### Count
|
||||
The number of segment elements. Useful when accessing the elements using the [] operators.
|
||||
```
|
||||
const static size_t Count = 9;
|
||||
```
|
||||
## Constructors
|
||||
|
||||
### SevenSegDigit(uint8_t defaultBrightness)
|
||||
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
|
||||
|
||||
### SevenSegDigit(uint8_t bitmask, uint8_t brightness, uint8_t defaultBrightness = 0)
|
||||
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
|
||||
|
||||
### SevenSegDigit()
|
||||
Construct a SevenSegDigit that will have its values set in latter operations.
|
||||
CAUTION: The members are not initialized and may not be consistent.
|
||||
|
||||
## Methods
|
||||
### uint8_t CalculateBrightness();
|
||||
CalculateBrightness will calculate the overall brightness.
|
||||
NOTE: This is a simple linear brightness
|
||||
|
||||
### SevenSegDigit Dim(uint8_t ratio);
|
||||
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.
|
||||
|
||||
### SevenSegDigit Brighten(uint8_t ratio);
|
||||
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.
|
||||
|
||||
### void Darken(uint8_t delta);
|
||||
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.
|
||||
|
||||
### void Lighten(uint8_t delta);
|
||||
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.
|
||||
|
||||
### static SevenSegDigit LinearBlend(SevenSegDigit left, SevenSegDigit right, float progress);
|
||||
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);
|
||||
```
|
||||
|
||||
### static SevenSegDigit LinearBlend(SevenSegDigit left, SevenSegDigit right, uint8_t progress);
|
||||
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);
|
||||
```
|
||||
|
||||
## Operators
|
||||
### uint8_t operator[](size_t idx)
|
||||
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];
|
||||
```
|
Reference in New Issue
Block a user