Skip to content

Commit

Permalink
Send current LED state to mirrored grid immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
Dewb committed Sep 18, 2023
1 parent e59a386 commit 8d522c9
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/virtualgrid/VirtualGridModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,32 @@ struct MirrorModeGridConsumer : GridConsumerBase
void gridConnected(Grid* newConnection) override
{
if (newConnection == module)
{ // don't mirror self
{
// don't mirror self
return;
}

GridConsumerBase::gridConnected(newConnection);

if (module && newConnection)
{
// update initial LED state
uint8_t leds[64];
for (int x_offset = 0; x_offset < 16; x_offset += 8)
{
for (int y_offset = 0; y_offset < 16; y_offset += 8)
{
for (int x = 0; x < 8; x++)
{
for (int y = 0; y < 8; y++)
{
leds[y * 8 + x] = module->ledBuffer[(y_offset + y) * 16 + x_offset + x];
}
}
newConnection->updateQuadrant(x_offset, y_offset, leds);
}
}
}
}

void gridButtonEvent(int x, int y, bool state) override
Expand Down

0 comments on commit 8d522c9

Please sign in to comment.