Skip to content

Commit

Permalink
better shutdown sequence when still streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
benkuper committed Jun 30, 2024
1 parent dec6ab9 commit d79cfd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ void LedStreamReceiverComponent::updateInternal()
{
lastReceiveTime = curTime;
int r = -1;
while(r != 0)
while (r != 0)
{
r = artnet.read();
}
}
}
}

Expand Down Expand Up @@ -108,6 +108,14 @@ void LedStreamReceiverComponent::onDmxFrame(uint16_t universe, uint16_t length,
{
// DBG("Received Artnet "+String(universe));

float multiplier = 1.0f;
if (RootComponent::instance->isShuttingDown())
{
float relT = (millis() - RootComponent::instance->timeAtShutdown) / 1000.0f;
const float animTime = 1.0f;
multiplier = max(1 - relT * 2 / animTime, 0.f);
}

for (auto &layer : instance->layers)
{
int numUniverses = std::ceil(layer->strip->count * 1.0f / 170); // 170 leds per universe
Expand All @@ -118,12 +126,12 @@ void LedStreamReceiverComponent::onDmxFrame(uint16_t universe, uint16_t length,

int start = (universe - layer->universe) * 170;

//DBG("Received Artnet " + String(universe) + ", start = " + String(start));
for (int i = 0; i < layer->strip->count && i < 170 && (i*3) < length; i++)
// DBG("Received Artnet " + String(universe) + ", start = " + String(start));
for (int i = 0; i < layer->strip->count && i < 170 && (i * 3) < length; i++)
{
layer->colors[i+start] = Color(data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
layer->colors[i + start] = Color(data[i * 3] * multiplier, data[i * 3 + 1] * multiplier, data[i * 3 + 2] * multiplier);
}

layer->lastReceiveTime = millis() / 1000.0f;
layer->hasCleared = false;
// memcpy((uint8_t *)layer->colors, streamBuffer + 1, byteIndex - 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ void LedStripComponent::clearInternal()

delete dotStarStrip;
dotStarStrip = NULL;

}

void LedStripComponent::setBrightness(float val)
Expand Down

0 comments on commit d79cfd5

Please sign in to comment.