Segment Offset
This commit is contained in:
parent
a58c5cce78
commit
7233c55428
@ -245,9 +245,10 @@ class WS2812FX {
|
||||
|
||||
// segment parameters
|
||||
public:
|
||||
typedef struct Segment { // 24 bytes
|
||||
typedef struct Segment { // 25 (28 in memory?) bytes
|
||||
uint16_t start;
|
||||
uint16_t stop; //segment invalid if stop == 0
|
||||
uint16_t offset;
|
||||
uint8_t speed;
|
||||
uint8_t intensity;
|
||||
uint8_t palette;
|
||||
@ -863,8 +864,8 @@ class WS2812FX {
|
||||
uint8_t _segment_index = 0;
|
||||
uint8_t _segment_index_palette_last = 99;
|
||||
segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 24 bytes per element
|
||||
// start, stop, speed, intensity, palette, mode, options, grouping, spacing, opacity (unused), color[]
|
||||
{ 0, 7, DEFAULT_SPEED, 128, 0, DEFAULT_MODE, NO_OPTIONS, 1, 0, 255, {DEFAULT_COLOR}}
|
||||
// start, stop, offset, speed, intensity, palette, mode, options, grouping, spacing, opacity (unused), color[]
|
||||
{0, 7, 0, DEFAULT_SPEED, 128, 0, DEFAULT_MODE, NO_OPTIONS, 1, 0, 255, {DEFAULT_COLOR}}
|
||||
};
|
||||
segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 28 bytes per element
|
||||
friend class Segment_runtime;
|
||||
|
@ -237,15 +237,24 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
||||
|
||||
bool reversed = IS_REVERSE;
|
||||
uint16_t realIndex = realPixelIndex(i);
|
||||
uint16_t len = SEGMENT.length();
|
||||
|
||||
for (uint16_t j = 0; j < SEGMENT.grouping; j++) {
|
||||
int indexSet = realIndex + (reversed ? -j : j);
|
||||
if (indexSet >= SEGMENT.start && indexSet < SEGMENT.stop) {
|
||||
if (IS_MIRROR) { //set the corresponding mirrored pixel
|
||||
uint16_t indexMir = SEGMENT.stop - indexSet + SEGMENT.start - 1;
|
||||
/* offset/phase */
|
||||
indexMir += SEGMENT.offset;
|
||||
if (indexMir >= SEGMENT.stop) indexMir -= len;
|
||||
|
||||
if (indexMir < customMappingSize) indexMir = customMappingTable[indexMir];
|
||||
busses.setPixelColor(indexMir, col);
|
||||
}
|
||||
/* offset/phase */
|
||||
indexSet += SEGMENT.offset;
|
||||
if (indexSet >= SEGMENT.stop) indexSet -= len;
|
||||
|
||||
if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet];
|
||||
busses.setPixelColor(indexSet, col);
|
||||
}
|
||||
@ -526,9 +535,13 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
|
||||
{
|
||||
i = realPixelIndex(i);
|
||||
|
||||
if (i < customMappingSize) i = customMappingTable[i];
|
||||
if (SEGLEN) {
|
||||
/* offset/phase */
|
||||
i += SEGMENT.offset;
|
||||
if (i >= SEGMENT.stop) i -= SEGMENT.length();
|
||||
}
|
||||
|
||||
if (i >= _length) return 0;
|
||||
if (i < customMappingSize) i = customMappingTable[i];
|
||||
|
||||
return busses.getPixelColor(i);
|
||||
}
|
||||
|
@ -183,7 +183,6 @@
|
||||
gId('ledwarning').style.color = (sLC > maxPB || maxLC > maxPB || bquot > 100) ? 'red':'orange';
|
||||
gId('wreason').innerHTML = (bquot > 80) ? "80% of max. LED memory" +(bquot>100 ? ` (<b>WARNING: Using over ${maxM}B!</b>)` : "") : "800 LEDs per pin";
|
||||
|
||||
//var val = Math.ceil((100 + d.Sf.LC.value * laprev)/500)/2;
|
||||
var val = Math.ceil((100 + sLC * laprev)/500)/2;
|
||||
val = (val > 5) ? Math.ceil(val) : val;
|
||||
var s = "";
|
||||
@ -209,6 +208,8 @@
|
||||
function lastEnd(i) {
|
||||
if (i<1) return 0;
|
||||
v = parseInt(d.getElementsByName("LS"+(i-1))[0].value) + parseInt(d.getElementsByName("LC"+(i-1))[0].value);
|
||||
var type = parseInt(d.getElementsByName("LT"+(i-1))[0].value);
|
||||
if (type > 31 && type < 48) v = 1; //PWM busses
|
||||
if (isNaN(v)) return 0;
|
||||
return v;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -22,6 +22,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
uint16_t grp = elem[F("grp")] | seg.grouping;
|
||||
uint16_t spc = elem[F("spc")] | seg.spacing;
|
||||
strip.setSegment(id, start, stop, grp, spc);
|
||||
seg.offset = elem[F("of")] | seg.offset;
|
||||
if (stop > start && seg.offset > stop - start -1) seg.offset = stop - start -1;
|
||||
|
||||
int segbri = elem["bri"] | -1;
|
||||
if (segbri == 0) {
|
||||
@ -324,6 +326,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool fo
|
||||
if (!forPreset) root[F("len")] = seg.stop - seg.start;
|
||||
root[F("grp")] = seg.grouping;
|
||||
root[F("spc")] = seg.spacing;
|
||||
root[F("of")] = seg.offset;
|
||||
root["on"] = seg.getOption(SEG_OPTION_ON);
|
||||
byte segbri = seg.opacity;
|
||||
root["bri"] = (segbri) ? segbri : 255;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2106250
|
||||
#define VERSION 2106290
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
@ -206,8 +206,7 @@ WLED_GLOBAL char versionString[] _INIT(TOSTRING(WLED_VERSION));
|
||||
WLED_GLOBAL char apPass[65] _INIT(DEFAULT_AP_PASS);
|
||||
WLED_GLOBAL char otaPass[33] _INIT(DEFAULT_OTA_PASS);
|
||||
|
||||
// Hardware CONFIG (only changeble HERE, not at runtime)
|
||||
// LED strip pin, button pin and IR pin changeable in NpbWrapper.h!
|
||||
// Hardware and pin config
|
||||
#ifndef BTNPIN
|
||||
WLED_GLOBAL int8_t btnPin[WLED_MAX_BUTTONS] _INIT({0});
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user