8000 Added new expand1D effect PinWheel by Brandon502 · Pull Request #118 · MoonModules/WLED-MM · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added new expand1D effect PinWheel #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ typedef enum mapping1D2D {
M12_pCorner = 3,
M12_jMap = 4, //WLEDMM jMap
M12_sCircle = 5, //WLEDMM Circle
M12_sBlock = 6 //WLEDMM Block
M12_sBlock = 6, //WLEDMM Block
M12_sPinWheel = 7 //WLEDMM PinWheel
} mapping1D2D_t;

// segment, 72 bytes
Expand Down
32 changes: 32 additions & 0 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,9 @@ uint16_t Segment::virtualLength() const {
else
vLen = max(vW,vH) * 0.5; // get the longest dimension
break;
case M12_sPinWheel: //WLEDMM
vLen = 360; // full circle
break;
}
return vLen;
}
Expand Down Expand Up @@ -932,6 +935,27 @@ void IRAM_ATTR_YN Segment::setPixelColor(int i, uint32_t col) //WLEDMM: IRAM_ATT
}
}
break;
case M12_sPinWheel: {
// i = 0 through 359
float centerX = (vW-1) / 2;
float centerY = (vH-1) / 2;
// int maxDistance = sqrt(centerX * centerX + centerY * centerY) + 1;

int distance = 0;
float cosVal = cos(i * DEG_TO_RAD); // i = current angle
float sinVal = sin(i * DEG_TO_RAD);
while (true) {
int x = round(centerX + distance * cosVal);
int y = round(centerY + distance * sinVal);
// Check bounds
if (x < 0 || x >= vW || y < 0 || y >= vH) {
break;
}
setPixelColorXY(x, y, col);
distance++;
}
break;
}
}
return;
} else if (Segment::maxHeight!=1 && (width()==1 || height()==1)) {
Expand Down Expand Up @@ -1069,6 +1093,14 @@ uint32_t Segment::getPixelColor(int i)
else
return getPixelColorXY(vW / 2, vH / 2 - i - 1);
break;
case M12_sPinWheel: //WLEDMM
// not 100% accurate, returns outer edge of circle
int distance = min(vH, vW) / 2;
float centerX = (vW - 1) / 2;
float centerY = (vH - 1) / 2;
int x = round(centerX + distance * cos(i * DEG_TO_RAD));
int y = round(centerY + distance * sin(i * DEG_TO_RAD));
return getPixelColorXY(x, y);
}
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions wled00/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ function populateSegments(s)
`<option value="4" ${inst.m12==4?' selected':''}>jMap ☾</option>`+
`<option value="5" ${inst.m12==5?' selected':''}>Circle ☾</option>`+
`<option value="6" ${inst.m12==6?' selected':''}>Block ☾</option>`+
`<option value="6" ${inst.m12==7?' selected':''}>PinWheel ☾</option>`+
`</select></div>`+
`</div>`;
let sndSim = `<div data-snd="si" class="lbl-s hide">Sound sim<br>`+
Expand Down
Loading
0