Add easy segment mirroring (closes #1010)

This commit is contained in:
cschwinne 2020-08-20 00:04:02 +02:00
parent b1c9dbd0a5
commit 39a80f8dc7
6 changed files with 1871 additions and 1865 deletions

View File

@ -2,6 +2,11 @@
### Development versions after 0.10.0 release
#### Build 2008200
- Added segment mirroring to web UI
- Fixed segment mirroring when in reverse mode
#### Build 2008140
- Removed verbose live mode info from `<ds>` in HTTP API response

View File

@ -269,7 +269,7 @@ class WS2812FX {
uint16_t groupLen = groupLength();
uint16_t vLength = (length() + groupLen - 1) / groupLen;
if (options & MIRROR)
vLength = (vLength + 1) /2; // divide by 2 if mirror, leave at least a signle LED
vLength = (vLength + 1) /2; // divide by 2 if mirror, leave at least a single LED
return vLength;
}
} segment;
@ -450,7 +450,7 @@ class WS2812FX {
setRgbwPwm(void);
bool
reverseMode = false,
reverseMode = false, //is the entire LED strip reversed?
gammaCorrectBri = false,
gammaCorrectCol = true,
applyToAllSelected = true,

View File

@ -106,20 +106,25 @@ void WS2812FX::setPixelColor(uint16_t n, uint32_t c) {
setPixelColor(n, r, g, b, w);
}
#define REV(i) (_length - 1 - (i))
//used to map from segment index to physical pixel, taking into account grouping, offsets, reverse and mirroring
uint16_t WS2812FX::realPixelIndex(uint16_t i) {
int16_t iGroup = i * SEGMENT.groupLength();
/* reverse just an individual segment */
int16_t realIndex = iGroup;
if (IS_REVERSE)
if (IS_MIRROR)
realIndex = SEGMENT.length() / 2 - iGroup - 1; //only need to index half the pixels
else
if (IS_REVERSE) {
if (IS_MIRROR) {
realIndex = (SEGMENT.length() -1) / 2 - iGroup; //only need to index half the pixels
} else {
realIndex = SEGMENT.length() - iGroup - 1;
}
}
realIndex += SEGMENT.start;
/* Reverse the whole string */
if (reverseMode) realIndex = _length - 1 - realIndex;
if (reverseMode) realIndex = REV(realIndex);
return realIndex;
}
@ -176,18 +181,23 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
for (uint16_t j = 0; j < SEGMENT.grouping; j++) {
int16_t indexSet = realIndex + (reversed ? -j : j);
int16_t indexSetRev = indexSet;
if (reverseMode) indexSetRev = _length - 1 - indexSet;
if (reverseMode) indexSetRev = REV(indexSet);
#ifdef WLED_CUSTOM_LED_MAPPING
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);
if (IS_MIRROR) { //set the corresponding mirrored pixel
if (reverseMode) {
bus->SetPixelColor(REV(SEGMENT.start) - indexSet + skip + REV(SEGMENT.stop) + 1, col);
} else {
bus->SetPixelColor(SEGMENT.stop - indexSet + skip + SEGMENT.start - 1, col);
}
}
}
}
} else { //live data, etc.
if (reverseMode) i = _length - 1 - i;
if (reverseMode) i = REV(i);
#ifdef WLED_CUSTOM_LED_MAPPING
if (i < customMappingSize) i = customMappingTable[i];
#endif

View File

@ -478,26 +478,6 @@ input[type=range]::-moz-range-thumb {
background: var(--c-f);
transform: translateY(7px);
}
input[type=range]::-ms-track {
width: 100%;
height: 30px;
background: transparent;
border-color: transparent;
color: transparent;
}
input[type=range]::-ms-fill-lower {
background: transparent;
}
input[type=range]::-ms-fill-upper {
background: transparent;
}
input[type=range]::-ms-thumb {
height: 16px;
width: 16px;
border-radius: 16px;
background: var(--c-f);
margin-top: -12px;
}
#wwrap {
display: none;
@ -1422,6 +1402,11 @@ function populateSegments(s)
<input type="checkbox" id="seg${i}rev" onchange="setRev(${i})" ${inst.rev ? "checked":""}>
<span class="checkmark schk"></span>
</label>
<label class="check revchkl">
Mirror effect
<input type="checkbox" id="seg${i}mi" onchange="setMi(${i})" ${inst.mi ? "checked":""}>
<span class="checkmark schk"></span>
</label>
</div>
</div><br>`;
}
@ -1783,6 +1768,12 @@ function setRev(s){
requestJson(obj, false);
}
function setMi(s){
var mi = d.getElementById(`seg${s}mi`).checked;
var obj = {"seg": {"id": s, "mi": mi}};
requestJson(obj, false);
}
function setSegPwr(s){
var obj = {"seg": {"id": s, "on": !powered[s]}};
requestJson(obj);

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2008100
#define VERSION 2008200
// ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS).