Add segment mirror option
* Add segment mirror option (#1010)
* Update new pull with playlist and palette changes
* Revert "Update new pull with playlist and palette changes"
This reverts commit 9802a7c4e2
.
This commit is contained in:
parent
230e3ef842
commit
b50e798d55
11
wled00/FX.h
11
wled00/FX.h
@ -84,16 +84,19 @@
|
||||
|
||||
// options
|
||||
// bit 7: segment is in transition mode
|
||||
// bits 3-6: TBD
|
||||
// bits 4-6: TBD
|
||||
// bit 3: mirror effect within segment
|
||||
// bit 2: segment is on
|
||||
// bit 1: reverse segment
|
||||
// bit 0: segment is selected
|
||||
#define NO_OPTIONS (uint8_t)0x00
|
||||
#define TRANSITIONAL (uint8_t)0x80
|
||||
#define MIRROR (uint8_t)0x08
|
||||
#define SEGMENT_ON (uint8_t)0x04
|
||||
#define REVERSE (uint8_t)0x02
|
||||
#define SELECTED (uint8_t)0x01
|
||||
#define IS_TRANSITIONAL ((SEGMENT.options & TRANSITIONAL) == TRANSITIONAL)
|
||||
#define IS_MIRROR ((SEGMENT.options & MIRROR ) == MIRROR )
|
||||
#define IS_SEGMENT_ON ((SEGMENT.options & SEGMENT_ON ) == SEGMENT_ON )
|
||||
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
|
||||
#define IS_SELECTED ((SEGMENT.options & SELECTED ) == SELECTED )
|
||||
@ -264,7 +267,11 @@ class WS2812FX {
|
||||
uint16_t virtualLength()
|
||||
{
|
||||
uint16_t groupLen = groupLength();
|
||||
return (length() + groupLen -1) / groupLen;
|
||||
uint16_t vLength;
|
||||
vLength = (length() + groupLen - 1) / groupLen;
|
||||
if (options & MIRROR)
|
||||
vLength /= 2; // divide by 2 if mirror; leaves a blank LED in the middle if length is odd
|
||||
return vLength;
|
||||
}
|
||||
} segment;
|
||||
|
||||
|
@ -111,7 +111,11 @@ uint16_t WS2812FX::realPixelIndex(uint16_t i) {
|
||||
|
||||
/* reverse just an individual segment */
|
||||
int16_t realIndex = iGroup;
|
||||
if (IS_REVERSE) realIndex = SEGMENT.length() -iGroup -1;
|
||||
if (IS_REVERSE)
|
||||
if (IS_MIRROR)
|
||||
realIndex = SEGMENT.length() / 2 - iGroup - 1; //only need to index half the pixels
|
||||
else
|
||||
realIndex = SEGMENT.length() - iGroup - 1;
|
||||
|
||||
realIndex += SEGMENT.start;
|
||||
/* Reverse the whole string */
|
||||
@ -177,6 +181,8 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
||||
if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet];
|
||||
#endif
|
||||
if (indexSetRev >= SEGMENT.start && indexSetRev < SEGMENT.stop) bus->SetPixelColor(indexSet + skip, col);
|
||||
if (IS_MIRROR) //set the corresponding mirrored pixel
|
||||
bus->SetPixelColor(SEGMENT.stop - (indexSet + skip) + SEGMENT.start - 1, col);
|
||||
}
|
||||
} else { //live data, etc.
|
||||
if (reverseMode) i = _length - 1 - i;
|
||||
|
@ -99,7 +99,7 @@
|
||||
#define SEG_OPTION_SELECTED 0
|
||||
#define SEG_OPTION_REVERSED 1
|
||||
#define SEG_OPTION_ON 2
|
||||
#define SEG_OPTION_PAUSED 3 //unused
|
||||
#define SEG_OPTION_MIRROR 3 //Indicates that the effect will be mirrored within the segment
|
||||
#define SEG_OPTION_NONUNITY 4 //Indicates that the effect does not use FRAMETIME or needs getPixelColor
|
||||
#define SEG_OPTION_TRANSITIONAL 7
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user