Use up-to-date fashion for segment dmx control
This commit is contained in:
parent
043947fdcb
commit
87fa14b281
@ -178,12 +178,12 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
case DMX_MODE_EFFECT_SEGMENT_W: // 13 Channels per segment; max[#] = floor[512/(13+DMXSegmentSpacing)] = 39,36,34,32, ..
|
||||
{
|
||||
if (uni != e131Universe) return;
|
||||
bool segmentUpdated = false;
|
||||
bool isSegmentMode = DMXMode == DMX_MODE_EFFECT_SEGMENT || DMXMode == DMX_MODE_EFFECT_SEGMENT_W;
|
||||
uint8_t dmxEffectChannels = (DMXMode == DMX_MODE_EFFECT || DMXMode == DMX_MODE_EFFECT_SEGMENT) ? 11 : 13;
|
||||
for (uint8_t seg = 0; seg < strip.getSegmentsNum(); seg++) {
|
||||
for (uint8_t id = 0; id < strip.getSegmentsNum(); id++) {
|
||||
Segment& seg = strip.getSegment(id);
|
||||
if (isSegmentMode)
|
||||
dataOffset = DMXAddress + seg * (dmxEffectChannels + DMXSegmentSpacing);
|
||||
dataOffset = DMXAddress + id * (dmxEffectChannels + DMXSegmentSpacing);
|
||||
else
|
||||
dataOffset = DMXAddress;
|
||||
// Modify address for Art-Net data
|
||||
@ -194,35 +194,36 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
return;
|
||||
|
||||
if (e131_data[dataOffset+1] < strip.getModeCount())
|
||||
effectCurrent = e131_data[dataOffset+ 1];
|
||||
effectSpeed = e131_data[dataOffset+ 2]; // flickers
|
||||
effectIntensity = e131_data[dataOffset+ 3];
|
||||
effectPalette = e131_data[dataOffset+ 4];
|
||||
col[0] = e131_data[dataOffset+ 5];
|
||||
col[1] = e131_data[dataOffset+ 6];
|
||||
col[2] = e131_data[dataOffset+ 7];
|
||||
colSec[0] = e131_data[dataOffset+ 8];
|
||||
colSec[1] = e131_data[dataOffset+ 9];
|
||||
colSec[2] = e131_data[dataOffset+10];
|
||||
if (e131_data[dataOffset+1] != seg.mode) {strip.setMode(id, e131_data[dataOffset+1]); stateChanged = true;}
|
||||
if (e131_data[dataOffset+2] != seg.speed) {seg.speed = e131_data[dataOffset+2]; stateChanged = true;}
|
||||
if (e131_data[dataOffset+3] != seg.intensity) {seg.intensity = e131_data[dataOffset+3]; stateChanged = true;}
|
||||
if (e131_data[dataOffset+4] != seg.palette) {seg.palette = e131_data[dataOffset+4]; stateChanged = true;}
|
||||
|
||||
uint32_t colors[2];
|
||||
byte whites[2] = {0,0};
|
||||
if (dmxEffectChannels == 13) {
|
||||
col[3] = e131_data[dataOffset+11]; // white
|
||||
colSec[3] = e131_data[dataOffset+12];
|
||||
whites[0] = e131_data[dataOffset+11];
|
||||
whites[1] = e131_data[dataOffset+12];
|
||||
}
|
||||
colors[0] = RGBW32(e131_data[dataOffset+5], e131_data[dataOffset+6], e131_data[dataOffset+ 7], whites[0]);
|
||||
colors[1] = RGBW32(e131_data[dataOffset+8], e131_data[dataOffset+9], e131_data[dataOffset+10], whites[1]);
|
||||
if (colors[0] != seg.colors[0]) {seg.setColor(0, colors[0]); stateChanged = true;}
|
||||
if (colors[1] != seg.colors[1]) {seg.setColor(1, colors[1]); stateChanged = true;}
|
||||
|
||||
// Set segment opacity or global brightness
|
||||
if (isSegmentMode) {
|
||||
opacity = e131_data[dataOffset+ 0];
|
||||
segmentUpdated |= applyValuesToSegment(seg);
|
||||
} else {
|
||||
if (bri != e131_data[dataOffset+0])
|
||||
bri = e131_data[dataOffset+0];
|
||||
transitionDelayTemp = 0; // act fast
|
||||
colorUpdated(CALL_MODE_NOTIFICATION); // don't send UDP
|
||||
return; // don't activate realtime live mode
|
||||
if (e131_data[dataOffset] != seg.opacity) {seg.opacity = e131_data[dataOffset]; stateChanged = true;}
|
||||
} else if ( id == strip.getSegmentsNum()-1 ) {
|
||||
if (bri != e131_data[dataOffset]) {
|
||||
bri = e131_data[dataOffset];
|
||||
strip.setBrightness(bri, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (segmentUpdated) {
|
||||
transitionDelayTemp = 0;
|
||||
stateUpdated(CALL_MODE_NOTIFICATION);
|
||||
return;
|
||||
if (stateChanged) {
|
||||
transitionDelayTemp = 0; // act fast
|
||||
stateUpdated(CALL_MODE_NOTIFICATION); // don't send UDP
|
||||
return; // don't activate realtime live mode
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -153,7 +153,6 @@ void toggleOnOff();
|
||||
void applyBri();
|
||||
void applyFinalBri();
|
||||
void applyValuesToSelectedSegs();
|
||||
bool applyValuesToSegment(uint8_t i);
|
||||
void colorUpdated(byte callMode);
|
||||
void stateUpdated(byte callMode);
|
||||
void updateInterfaces(uint8_t callMode);
|
||||
|
@ -46,22 +46,6 @@ void applyValuesToSelectedSegs()
|
||||
}
|
||||
}
|
||||
|
||||
// applies global legacy values to segment i (opacity, col, colSec, effectCurrent...)
|
||||
bool applyValuesToSegment(uint8_t i)
|
||||
{
|
||||
if (i >= strip.getSegmentsNum()) {return false;}
|
||||
Segment& seg = strip.getSegment(i);
|
||||
if (opacity != seg.opacity) {seg.setOpacity(opacity); stateChanged = true;}
|
||||
if (effectSpeed != seg.speed) {seg.speed = effectSpeed; stateChanged = true;}
|
||||
if (effectIntensity != seg.intensity) {seg.intensity = effectIntensity; stateChanged = true;}
|
||||
if (effectPalette != seg.palette) {seg.palette = effectPalette; stateChanged = true;}
|
||||
if (effectCurrent != seg.mode) {strip.setMode(i, effectCurrent); stateChanged = true;}
|
||||
uint32_t col0 = RGBW32( col[0], col[1], col[2], col[3]);
|
||||
uint32_t col1 = RGBW32(colSec[0], colSec[1], colSec[2], colSec[3]);
|
||||
if (col0 != seg.colors[0]) {seg.setColor(0, col0); stateChanged = true;}
|
||||
if (col1 != seg.colors[1]) {seg.setColor(1, col1); stateChanged = true;}
|
||||
return stateChanged;
|
||||
}
|
||||
|
||||
void resetTimebase()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user