@@ -145,8 +145,6 @@ void WS2812FX::setPixelColor(uint16_t n, uint32_t c) {
145145 setPixelColor (n, r, g, b, w);
146146}
147147
148- #define REV (i ) (_length - 1 - (i))
149-
150148// used to map from segment index to physical pixel, taking into account grouping, offsets, reverse and mirroring
151149uint16_t WS2812FX::realPixelIndex (uint16_t i) {
152150 int16_t iGroup = i * SEGMENT.groupLength ();
@@ -162,8 +160,6 @@ uint16_t WS2812FX::realPixelIndex(uint16_t i) {
162160 }
163161
164162 realIndex += SEGMENT.start ;
165- /* Reverse the whole string */
166- if (reverseMode) realIndex = REV (realIndex);
167163
168164 return realIndex;
169165}
@@ -197,27 +193,22 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
197193 uint32_t col = ((w << 24 ) | (r << 16 ) | (g << 8 ) | (b));
198194
199195 /* Set all the pixels in the group, ensuring _skipFirstMode is honored */
200- bool reversed = reverseMode ^ IS_REVERSE;
196+ bool reversed = IS_REVERSE;
201197 uint16_t realIndex = realPixelIndex (i);
202198
203199 for (uint16_t j = 0 ; j < SEGMENT.grouping ; j++) {
204200 int16_t indexSet = realIndex + (reversed ? -j : j);
205- int16_t indexSetRev = indexSet;
206- if (reverseMode) indexSetRev = REV (indexSet);
207201 if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet];
208- if (indexSetRev >= SEGMENT.start && indexSetRev < SEGMENT.stop ) {
202+ if (indexSet >= SEGMENT.start && indexSet < SEGMENT.stop ) {
209203 busses.setPixelColor (indexSet + skip, col);
210204 if (IS_MIRROR) { // set the corresponding mirrored pixel
211- if (reverseMode) {
212- busses.setPixelColor (REV (SEGMENT.start ) - indexSet + skip + REV (SEGMENT.stop ) + 1 , col);
213- } else {
214- busses.setPixelColor (SEGMENT.stop - indexSet + skip + SEGMENT.start - 1 , col);
215- }
205+ uint16_t indexMir = SEGMENT.stop - indexSet + SEGMENT.start - 1 ;
206+ if (indexMir < customMappingSize) indexMir = customMappingTable[indexMir];
207+ busses.setPixelColor (indexMir + skip, col);
216208 }
217209 }
218210 }
219211 } else { // live data, etc.
220- if (reverseMode) i = REV (i);
221212 if (i < customMappingSize) i = customMappingTable[i];
222213
223214 uint32_t col = ((w << 24 ) | (r << 16 ) | (g << 8 ) | (b));
0 commit comments