Add Segment functions hasRGB() and hasWhite()
Makes code cleaner.
This commit is contained in:
parent
3ca7006e3a
commit
1ca4348ca0
@ -496,6 +496,9 @@ typedef struct Segment {
|
|||||||
inline bool isSelected(void) const { return selected; }
|
inline bool isSelected(void) const { return selected; }
|
||||||
inline bool isActive(void) const { return stop > start; }
|
inline bool isActive(void) const { return stop > start; }
|
||||||
inline bool is2D(void) const { return (width()>1 && height()>1); }
|
inline bool is2D(void) const { return (width()>1 && height()>1); }
|
||||||
|
inline bool hasRGB(void) const { return _isRGB; }
|
||||||
|
inline bool hasWhite(void) const { return _hasW; }
|
||||||
|
inline bool isCCT(void) const { return _isCCT; }
|
||||||
inline uint16_t width(void) const { return stop - start; } // segment width in physical pixels (length if 1D)
|
inline uint16_t width(void) const { return stop - start; } // segment width in physical pixels (length if 1D)
|
||||||
inline uint16_t height(void) const { return stopY - startY; } // segment height (if 2D) in physical pixels
|
inline uint16_t height(void) const { return stopY - startY; } // segment height (if 2D) in physical pixels
|
||||||
inline uint16_t length(void) const { return width() * height(); } // segment length (count) in physical pixels
|
inline uint16_t length(void) const { return width() * height(); } // segment length (count) in physical pixels
|
||||||
|
@ -125,7 +125,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
JsonArray colarr = elem["col"];
|
JsonArray colarr = elem["col"];
|
||||||
if (!colarr.isNull())
|
if (!colarr.isNull())
|
||||||
{
|
{
|
||||||
if (seg.getLightCapabilities() & 3) {
|
if (seg.hasRGB() || seg.hasWhite()) {
|
||||||
// segment has RGB or White
|
// segment has RGB or White
|
||||||
for (size_t i = 0; i < 3; i++)
|
for (size_t i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
@ -204,7 +204,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
getVal(elem["ix"], &seg.intensity);
|
getVal(elem["ix"], &seg.intensity);
|
||||||
|
|
||||||
uint8_t pal = seg.palette;
|
uint8_t pal = seg.palette;
|
||||||
if (seg.getLightCapabilities() & 1) { // ignore palette for White and On/Off segments
|
if (seg.hasRGB()) { // ignore palette for White and On/Off segments
|
||||||
if (getVal(elem["pal"], &pal)) seg.setPalette(pal);
|
if (getVal(elem["pal"], &pal)) seg.setPalette(pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user