Skip to content

Commit

Permalink
Added mi property to APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aircoookie committed Aug 6, 2020
1 parent b50e798 commit c1cab30
Showing 5 changed files with 23 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

### Development versions after 0.10.0 release

#### Build 2008070

- Added segment mirroring (`mi` property) (#1017)
- Fixed DMX settings page not displayed (#1070)
- Fixed ArtNet multi universe and improve code style (#1076)
- Renamed global var `local` to `localTime` (#1078)

#### Build 2007190

- Fixed hostname containing illegal characters (#1035)
5 changes: 2 additions & 3 deletions wled00/FX.h
Original file line number Diff line number Diff line change
@@ -267,10 +267,9 @@ class WS2812FX {
uint16_t virtualLength()
{
uint16_t groupLen = groupLength();
uint16_t vLength;
vLength = (length() + groupLen - 1) / groupLen;
uint16_t vLength = (length() + groupLen - 1) / groupLen;
if (options & MIRROR)
vLength /= 2; // divide by 2 if mirror; leaves a blank LED in the middle if length is odd
vLength = (vLength + 1) /2; // divide by 2 if mirror, leave at least a signle LED
return vLength;
}
} segment;
8 changes: 5 additions & 3 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
@@ -180,9 +180,11 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
#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 (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);
}
}
} else { //live data, etc.
if (reverseMode) i = _length - 1 - i;
8 changes: 5 additions & 3 deletions wled00/json.cpp
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ void deserializeSegment(JsonObject elem, byte it)
//if (pal != seg.palette && pal < strip.getPaletteCount()) strip.setPalette(pal);
seg.setOption(SEG_OPTION_SELECTED, elem["sel"] | seg.getOption(SEG_OPTION_SELECTED));
seg.setOption(SEG_OPTION_REVERSED, elem["rev"] | seg.getOption(SEG_OPTION_REVERSED));
seg.setOption(SEG_OPTION_MIRROR , elem["mi"] | seg.getOption(SEG_OPTION_MIRROR ));

//temporary, strip object gets updated via colorUpdated()
if (id == strip.getMainSegmentId()) {
@@ -215,12 +216,13 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id)
}
}

root["fx"] = seg.mode;
root["sx"] = seg.speed;
root["ix"] = seg.intensity;
root["fx"] = seg.mode;
root["sx"] = seg.speed;
root["ix"] = seg.intensity;
root["pal"] = seg.palette;
root["sel"] = seg.isSelected();
root["rev"] = seg.getOption(SEG_OPTION_REVERSED);
root["mi"] = seg.getOption(SEG_OPTION_MIRROR);
}


4 changes: 4 additions & 0 deletions wled00/set.cpp
Original file line number Diff line number Diff line change
@@ -647,6 +647,10 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
pos = req.indexOf("RV=");
if (pos > 0) strip.getSegment(main).setOption(SEG_OPTION_REVERSED, req.charAt(pos+3) != '0');

//Segment reverse
pos = req.indexOf("MI=");
if (pos > 0) strip.getSegment(main).setOption(SEG_OPTION_MIRROR, req.charAt(pos+3) != '0');

//Segment brightness/opacity
pos = req.indexOf("SB=");
if (pos > 0) {

0 comments on commit c1cab30

Please sign in to comment.