Segment Offset
This commit is contained in:
parent
a58c5cce78
commit
7233c55428
@ -245,9 +245,10 @@ class WS2812FX {
|
|||||||
|
|
||||||
// segment parameters
|
// segment parameters
|
||||||
public:
|
public:
|
||||||
typedef struct Segment { // 24 bytes
|
typedef struct Segment { // 25 (28 in memory?) bytes
|
||||||
uint16_t start;
|
uint16_t start;
|
||||||
uint16_t stop; //segment invalid if stop == 0
|
uint16_t stop; //segment invalid if stop == 0
|
||||||
|
uint16_t offset;
|
||||||
uint8_t speed;
|
uint8_t speed;
|
||||||
uint8_t intensity;
|
uint8_t intensity;
|
||||||
uint8_t palette;
|
uint8_t palette;
|
||||||
@ -863,8 +864,8 @@ class WS2812FX {
|
|||||||
uint8_t _segment_index = 0;
|
uint8_t _segment_index = 0;
|
||||||
uint8_t _segment_index_palette_last = 99;
|
uint8_t _segment_index_palette_last = 99;
|
||||||
segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 24 bytes per element
|
segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 24 bytes per element
|
||||||
// start, stop, speed, intensity, palette, mode, options, grouping, spacing, opacity (unused), color[]
|
// start, stop, offset, 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}}
|
{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
|
segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 28 bytes per element
|
||||||
friend class Segment_runtime;
|
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;
|
bool reversed = IS_REVERSE;
|
||||||
uint16_t realIndex = realPixelIndex(i);
|
uint16_t realIndex = realPixelIndex(i);
|
||||||
|
uint16_t len = SEGMENT.length();
|
||||||
|
|
||||||
for (uint16_t j = 0; j < SEGMENT.grouping; j++) {
|
for (uint16_t j = 0; j < SEGMENT.grouping; j++) {
|
||||||
int indexSet = realIndex + (reversed ? -j : j);
|
int indexSet = realIndex + (reversed ? -j : j);
|
||||||
if (indexSet >= SEGMENT.start && indexSet < SEGMENT.stop) {
|
if (indexSet >= SEGMENT.start && indexSet < SEGMENT.stop) {
|
||||||
if (IS_MIRROR) { //set the corresponding mirrored pixel
|
if (IS_MIRROR) { //set the corresponding mirrored pixel
|
||||||
uint16_t indexMir = SEGMENT.stop - indexSet + SEGMENT.start - 1;
|
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];
|
if (indexMir < customMappingSize) indexMir = customMappingTable[indexMir];
|
||||||
busses.setPixelColor(indexMir, col);
|
busses.setPixelColor(indexMir, col);
|
||||||
}
|
}
|
||||||
|
/* offset/phase */
|
||||||
|
indexSet += SEGMENT.offset;
|
||||||
|
if (indexSet >= SEGMENT.stop) indexSet -= len;
|
||||||
|
|
||||||
if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet];
|
if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet];
|
||||||
busses.setPixelColor(indexSet, col);
|
busses.setPixelColor(indexSet, col);
|
||||||
}
|
}
|
||||||
@ -525,11 +534,15 @@ uint32_t WS2812FX::getColor(void) {
|
|||||||
uint32_t WS2812FX::getPixelColor(uint16_t i)
|
uint32_t WS2812FX::getPixelColor(uint16_t i)
|
||||||
{
|
{
|
||||||
i = realPixelIndex(i);
|
i = realPixelIndex(i);
|
||||||
|
|
||||||
|
if (SEGLEN) {
|
||||||
|
/* offset/phase */
|
||||||
|
i += SEGMENT.offset;
|
||||||
|
if (i >= SEGMENT.stop) i -= SEGMENT.length();
|
||||||
|
}
|
||||||
|
|
||||||
if (i < customMappingSize) i = customMappingTable[i];
|
if (i < customMappingSize) i = customMappingTable[i];
|
||||||
|
|
||||||
if (i >= _length) return 0;
|
|
||||||
|
|
||||||
return busses.getPixelColor(i);
|
return busses.getPixelColor(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,6 @@
|
|||||||
gId('ledwarning').style.color = (sLC > maxPB || maxLC > maxPB || bquot > 100) ? 'red':'orange';
|
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";
|
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;
|
var val = Math.ceil((100 + sLC * laprev)/500)/2;
|
||||||
val = (val > 5) ? Math.ceil(val) : val;
|
val = (val > 5) ? Math.ceil(val) : val;
|
||||||
var s = "";
|
var s = "";
|
||||||
@ -209,6 +208,8 @@
|
|||||||
function lastEnd(i) {
|
function lastEnd(i) {
|
||||||
if (i<1) return 0;
|
if (i<1) return 0;
|
||||||
v = parseInt(d.getElementsByName("LS"+(i-1))[0].value) + parseInt(d.getElementsByName("LC"+(i-1))[0].value);
|
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;
|
if (isNaN(v)) return 0;
|
||||||
return v;
|
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 grp = elem[F("grp")] | seg.grouping;
|
||||||
uint16_t spc = elem[F("spc")] | seg.spacing;
|
uint16_t spc = elem[F("spc")] | seg.spacing;
|
||||||
strip.setSegment(id, start, stop, grp, spc);
|
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;
|
int segbri = elem["bri"] | -1;
|
||||||
if (segbri == 0) {
|
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;
|
if (!forPreset) root[F("len")] = seg.stop - seg.start;
|
||||||
root[F("grp")] = seg.grouping;
|
root[F("grp")] = seg.grouping;
|
||||||
root[F("spc")] = seg.spacing;
|
root[F("spc")] = seg.spacing;
|
||||||
|
root[F("of")] = seg.offset;
|
||||||
root["on"] = seg.getOption(SEG_OPTION_ON);
|
root["on"] = seg.getOption(SEG_OPTION_ON);
|
||||||
byte segbri = seg.opacity;
|
byte segbri = seg.opacity;
|
||||||
root["bri"] = (segbri) ? segbri : 255;
|
root["bri"] = (segbri) ? segbri : 255;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// 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
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#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 apPass[65] _INIT(DEFAULT_AP_PASS);
|
||||||
WLED_GLOBAL char otaPass[33] _INIT(DEFAULT_OTA_PASS);
|
WLED_GLOBAL char otaPass[33] _INIT(DEFAULT_OTA_PASS);
|
||||||
|
|
||||||
// Hardware CONFIG (only changeble HERE, not at runtime)
|
// Hardware and pin config
|
||||||
// LED strip pin, button pin and IR pin changeable in NpbWrapper.h!
|
|
||||||
#ifndef BTNPIN
|
#ifndef BTNPIN
|
||||||
WLED_GLOBAL int8_t btnPin[WLED_MAX_BUTTONS] _INIT({0});
|
WLED_GLOBAL int8_t btnPin[WLED_MAX_BUTTONS] _INIT({0});
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user