Skip to content

Commit c03422e

Browse files
committed
Push variants
1 parent 1975c9c commit c03422e

File tree

4 files changed

+113
-34
lines changed

4 files changed

+113
-34
lines changed

wled00/FX.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,18 +325,22 @@
325325
#define BLEND_STYLE_FAIRY_DUST 1
326326
#define BLEND_STYLE_SWIPE_RIGHT 2
327327
#define BLEND_STYLE_SWIPE_LEFT 3
328-
#define BLEND_STYLE_PINCH_OUT 4
329-
#define BLEND_STYLE_INSIDE_OUT 5
330-
#define BLEND_STYLE_SWIPE_UP 6
331-
#define BLEND_STYLE_SWIPE_DOWN 7
332-
#define BLEND_STYLE_OPEN_H 8
333-
#define BLEND_STYLE_OPEN_V 9
334-
#define BLEND_STYLE_PUSH_TL 10
335-
#define BLEND_STYLE_PUSH_TR 11
336-
#define BLEND_STYLE_PUSH_BR 12
337-
#define BLEND_STYLE_PUSH_BL 13
338-
339-
#define BLEND_STYLE_COUNT 14
328+
#define BLEND_STYLE_PUSH_RIGHT 4
329+
#define BLEND_STYLE_PUSH_LEFT 5
330+
#define BLEND_STYLE_PINCH_OUT 6
331+
#define BLEND_STYLE_INSIDE_OUT 7
332+
#define BLEND_STYLE_SWIPE_UP 8
333+
#define BLEND_STYLE_SWIPE_DOWN 9
334+
#define BLEND_STYLE_OPEN_H 10
335+
#define BLEND_STYLE_OPEN_V 11
336+
#define BLEND_STYLE_PUSH_UP 12
337+
#define BLEND_STYLE_PUSH_DOWN 13
338+
#define BLEND_STYLE_PUSH_TL 14
339+
#define BLEND_STYLE_PUSH_TR 15
340+
#define BLEND_STYLE_PUSH_BR 16
341+
#define BLEND_STYLE_PUSH_BL 17
342+
343+
#define BLEND_STYLE_COUNT 18
340344

341345

342346
typedef enum mapping1D2D {

wled00/FX_2Dfcn.cpp

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,39 @@ bool IRAM_ATTR Segment::isPixelXYClipped(int x, int y) {
202202
void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
203203
{
204204
if (!isActive()) return; // not active
205-
if (x >= virtualWidth() || y >= virtualHeight() || x < 0 || y < 0 || isPixelXYClipped(x,y)) return; // if pixel would fall out of virtual segment just exit
205+
206+
int vW = virtualWidth();
207+
int vH = virtualHeight();
208+
209+
#ifndef WLED_DISABLE_MODE_BLEND
210+
if (!_modeBlend &&
211+
(blendingStyle == BLEND_STYLE_PUSH_RIGHT ||
212+
blendingStyle == BLEND_STYLE_PUSH_LEFT ||
213+
blendingStyle == BLEND_STYLE_PUSH_UP ||
214+
blendingStyle == BLEND_STYLE_PUSH_DOWN ||
215+
blendingStyle == BLEND_STYLE_PUSH_TL ||
216+
blendingStyle == BLEND_STYLE_PUSH_TR ||
217+
blendingStyle == BLEND_STYLE_PUSH_BR ||
218+
blendingStyle == BLEND_STYLE_PUSH_BL)) {
219+
unsigned prog = 0xFFFF - progress();
220+
unsigned dX = (blendingStyle == BLEND_STYLE_PUSH_UP || blendingStyle == BLEND_STYLE_PUSH_DOWN) ? 0 : prog * vW / 0xFFFF;
221+
unsigned dY = (blendingStyle == BLEND_STYLE_PUSH_LEFT || blendingStyle == BLEND_STYLE_PUSH_RIGHT) ? 0 : prog * vH / 0xFFFF;
222+
if (blendingStyle == BLEND_STYLE_PUSH_LEFT || blendingStyle == BLEND_STYLE_PUSH_TL || blendingStyle == BLEND_STYLE_PUSH_BL) x -= dX;
223+
else x += dX;
224+
if (blendingStyle == BLEND_STYLE_PUSH_DOWN || blendingStyle == BLEND_STYLE_PUSH_TL || blendingStyle == BLEND_STYLE_PUSH_TR) y -= dY;
225+
else y += dY;
226+
}
227+
#endif
228+
229+
if (x >= vW || y >= vH || x < 0 || y < 0 || isPixelXYClipped(x,y)) return; // if pixel would fall out of virtual segment just exit
206230

207231
uint8_t _bri_t = currentBri();
208232
if (_bri_t < 255) {
209233
col = color_fade(col, _bri_t);
210234
}
211235

212-
if (reverse ) x = virtualWidth() - x - 1;
213-
if (reverse_y) y = virtualHeight() - y - 1;
236+
if (reverse ) x = vW - x - 1;
237+
if (reverse_y) y = vH - y - 1;
214238
if (transpose) { unsigned t = x; x = y; y = t; } // swap X & Y if segment transposed
215239

216240
x *= groupLength(); // expand to physical pixels
@@ -294,9 +318,34 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa)
294318
// returns RGBW values of pixel
295319
uint32_t IRAM_ATTR Segment::getPixelColorXY(int x, int y) {
296320
if (!isActive()) return 0; // not active
297-
if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0 || isPixelXYClipped(x,y)) return 0; // if pixel would fall out of virtual segment just exit
298-
if (reverse ) x = virtualWidth() - x - 1;
299-
if (reverse_y) y = virtualHeight() - y - 1;
321+
322+
int vW = virtualWidth();
323+
int vH = virtualHeight();
324+
325+
#ifndef WLED_DISABLE_MODE_BLEND
326+
if (!_modeBlend &&
327+
(blendingStyle == BLEND_STYLE_PUSH_RIGHT ||
328+
blendingStyle == BLEND_STYLE_PUSH_LEFT ||
329+
blendingStyle == BLEND_STYLE_PUSH_UP ||
330+
blendingStyle == BLEND_STYLE_PUSH_DOWN ||
331+
blendingStyle == BLEND_STYLE_PUSH_TL ||
332+
blendingStyle == BLEND_STYLE_PUSH_TR ||
333+
blendingStyle == BLEND_STYLE_PUSH_BR ||
334+
blendingStyle == BLEND_STYLE_PUSH_BL)) {
335+
unsigned prog = 0xFFFF - progress();
336+
unsigned dX = (blendingStyle == BLEND_STYLE_PUSH_UP || blendingStyle == BLEND_STYLE_PUSH_DOWN) ? 0 : prog * vW / 0xFFFF;
337+
unsigned dY = (blendingStyle == BLEND_STYLE_PUSH_LEFT || blendingStyle == BLEND_STYLE_PUSH_RIGHT) ? 0 : prog * vH / 0xFFFF;
338+
if (blendingStyle == BLEND_STYLE_PUSH_LEFT || blendingStyle == BLEND_STYLE_PUSH_TL || blendingStyle == BLEND_STYLE_PUSH_BL) x -= dX;
339+
else x += dX;
340+
if (blendingStyle == BLEND_STYLE_PUSH_DOWN || blendingStyle == BLEND_STYLE_PUSH_TL || blendingStyle == BLEND_STYLE_PUSH_TR) y -= dY;
341+
else y += dY;
342+
}
343+
#endif
344+
345+
if (x >= vW || y >= vH || x<0 || y<0 || isPixelXYClipped(x,y)) return 0; // if pixel would fall out of virtual segment just exit
346+
347+
if (reverse ) x = vW - x - 1;
348+
if (reverse_y) y = vH - y - 1;
300349
if (transpose) { unsigned t = x; x = y; y = t; } // swap X & Y if segment transposed
301350
x *= groupLength(); // expand to physical pixels
302351
y *= groupLength(); // expand to physical pixels

wled00/FX_fcn.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,8 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
782782
#endif
783783
i &= 0xFFFF;
784784

785-
if (i >= virtualLength() || i<0) return; // if pixel would fall out of segment just exit
785+
int vL = virtualLength();
786+
if (i >= vL || i < 0) return; // if pixel would fall out of segment just exit
786787

787788
#ifndef WLED_DISABLE_2D
788789
if (is2D()) {
@@ -890,7 +891,16 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
890891
}
891892
#endif
892893

893-
if (isPixelClipped(i)) return; // handle clipping on 1D
894+
#ifndef WLED_DISABLE_MODE_BLEND
895+
if (!_modeBlend && (blendingStyle == BLEND_STYLE_PUSH_RIGHT || blendingStyle == BLEND_STYLE_PUSH_LEFT)) {
896+
unsigned prog = 0xFFFF - progress();
897+
unsigned dI = prog * vL / 0xFFFF;
898+
if (blendingStyle == BLEND_STYLE_PUSH_RIGHT) i -= dI;
899+
else i += dI;
900+
}
901+
#endif
902+
903+
if (i >= vL || i < 0 || isPixelClipped(i)) return; // handle clipping on 1D
894904

895905
unsigned len = length();
896906
uint8_t _bri_t = currentBri();
@@ -978,6 +988,9 @@ uint32_t IRAM_ATTR Segment::getPixelColor(int i)
978988
#endif
979989
i &= 0xFFFF;
980990

991+
int vL = virtualLength();
992+
if (i >= vL || i < 0) return 0;
993+
981994
#ifndef WLED_DISABLE_2D
982995
if (is2D()) {
983996
unsigned vH = virtualHeight(); // segment height in logical pixels
@@ -1029,9 +1042,18 @@ uint32_t IRAM_ATTR Segment::getPixelColor(int i)
10291042
}
10301043
#endif
10311044

1032-
if (isPixelClipped(i)) return 0; // handle clipping on 1D
1045+
#ifndef WLED_DISABLE_MODE_BLEND
1046+
if (!_modeBlend && (blendingStyle == BLEND_STYLE_PUSH_RIGHT || blendingStyle == BLEND_STYLE_PUSH_LEFT)) {
1047+
unsigned prog = 0xFFFF - progress();
1048+
unsigned dI = prog * vL / 0xFFFF;
1049+
if (blendingStyle == BLEND_STYLE_PUSH_RIGHT) i -= dI;
1050+
else i += dI;
1051+
}
1052+
#endif
1053+
1054+
if (i >= vL || i < 0 || isPixelClipped(i)) return 0; // handle clipping on 1D
10331055

1034-
if (reverse) i = virtualLength() - i - 1;
1056+
if (reverse) i = vL - i - 1;
10351057
i *= groupLength();
10361058
i += start;
10371059
/* offset/phase */

wled00/data/index.htm

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,22 @@
271271
<select id="bs" class="sel-sg" onchange="requestJson({'bs':parseInt(this.value)})">
272272
<option value="0">Fade</option>
273273
<option value="1">Fairy Dust</option>
274-
<option value="2">Swipe left</option>
275-
<option value="3">Swipe right</option>
276-
<option value="4">Pinch-out</option>
277-
<option value="5">Inside-out</option>
278-
<option value="6" data-type="2D">Swipe up</option>
279-
<option value="7" data-type="2D">Swipe down</option>
280-
<option value="8" data-type="2D">Open V</option>
281-
<option value="9" data-type="2D">Open H</option>
282-
<option value="10" data-type="2D">Push TL</option>
283-
<option value="11" data-type="2D">Push TR</option>
284-
<option value="12" data-type="2D">Push BR</option>
285-
<option value="13" data-type="2D">Push BL</option>
274+
<option value="2">Swipe right</option>
275+
<option value="3">Swipe left</option>
276+
<option value="4">Push right</option>
277+
<option value="5">Push left</option>
278+
<option value="6">Pinch-out</option>
279+
<option value="7">Inside-out</option>
280+
<option value="8" data-type="2D">Swipe up</option>
281+
<option value="9" data-type="2D">Swipe down</option>
282+
<option value="10" data-type="2D">Open V</option>
283+
<option value="11" data-type="2D">Open H</option>
284+
<option value="12" data-type="2D">Push up</option>
285+
<option value="13" data-type="2D">Push down</option>
286+
<option value="14" data-type="2D">Push TL</option>
287+
<option value="15" data-type="2D">Push TR</option>
288+
<option value="16" data-type="2D">Push BR</option>
289+
<option value="17" data-type="2D">Push BL</option>
286290
</select>
287291
</p>
288292
<p id="ledmap" class="hide"></p>

0 commit comments

Comments
 (0)