Skip to content

Commit 22d0675

Browse files
authored
Merge pull request #118 from Brandon502/mdev
2 parents 86b0eea + bff643f commit 22d0675

File tree

4 files changed

+1365
-1330
lines changed

4 files changed

+1365
-1330
lines changed

wled00/FX.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ typedef enum mapping1D2D {
354354
M12_pCorner = 3,
355355
M12_jMap = 4, //WLEDMM jMap
356356
M12_sCircle = 5, //WLEDMM Circle
357-
M12_sBlock = 6 //WLEDMM Block
357+
M12_sBlock = 6, //WLEDMM Block
358+
M12_sPinWheel = 7 //WLEDMM PinWheel
358359
} mapping1D2D_t;
359360

360361
// segment, 72 bytes

wled00/FX_fcn.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,9 @@ uint16_t Segment::virtualLength() const {
805805
else
806806
vLen = max(vW,vH) * 0.5; // get the longest dimension
807807
break;
808+
case M12_sPinWheel: //WLEDMM
809+
vLen = 360; // full circle
810+
break;
808811
}
809812
return vLen;
810813
}
@@ -932,6 +935,27 @@ void IRAM_ATTR_YN Segment::setPixelColor(int i, uint32_t col) //WLEDMM: IRAM_ATT
932935
}
933936
}
934937
break;
938+
case M12_sPinWheel: {
939+
// i = 0 through 359
940+
float centerX = (vW-1) / 2;
941+
float centerY = (vH-1) / 2;
942+
// int maxDistance = sqrt(centerX * centerX + centerY * centerY) + 1;
943+
944+
int distance = 0;
945+
float cosVal = cos(i * DEG_TO_RAD); // i = current angle
946+
float sinVal = sin(i * DEG_TO_RAD);
947+
while (true) {
948+
int x = round(centerX + distance * cosVal);
949+
int y = round(centerY + distance * sinVal);
950+
// Check bounds
951+
if (x < 0 || x >= vW || y < 0 || y >= vH) {
952+
break;
953+
}
954+
setPixelColorXY(x, y, col);
955+
distance++;
956+
}
957+
break;
958+
}
935959
}
936960
return;
937961
} else if (Segment::maxHeight!=1 && (width()==1 || height()==1)) {
@@ -1069,6 +1093,14 @@ uint32_t Segment::getPixelColor(int i)
10691093
else
10701094
return getPixelColorXY(vW / 2, vH / 2 - i - 1);
10711095
break;
1096+
case M12_sPinWheel: //WLEDMM
1097+
// not 100% accurate, returns outer edge of circle
1098+
int distance = min(vH, vW) / 2;
1099+
float centerX = (vW - 1) / 2;
1100+
float centerY = (vH - 1) / 2;
1101+
int x = round(centerX + distance * cos(i * DEG_TO_RAD));
1102+
int y = round(centerY + distance * sin(i * DEG_TO_RAD));
1103+
return getPixelColorXY(x, y);
10721104
}
10731105
return 0;
10741106
}

wled00/data/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ function populateSegments(s)
779779
`<option value="4" ${inst.m12==4?' selected':''}>jMap ☾</option>`+
780780
`<option value="5" ${inst.m12==5?' selected':''}>Circle ☾</option>`+
781781
`<option value="6" ${inst.m12==6?' selected':''}>Block ☾</option>`+
782+
`<option value="6" ${inst.m12==7?' selected':''}>PinWheel ☾</option>`+
782783
`</select></div>`+
783784
`</div>`;
784785
let sndSim = `<div data-snd="si" class="lbl-s hide">Sound sim<br>`+

0 commit comments

Comments
 (0)