Skip to content

Commit

Permalink
Quick PoC of reflecting grid LED state in Rack lights, for mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Dewb committed Oct 6, 2023
1 parent 48d8ebf commit ff8d0c6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/virtualgrid/VirtualGridModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ VirtualGridModule::VirtualGridModule(unsigned w, unsigned h)
assert(0);
}

config(w * h * 2, 0, 0, 0);
config(w * h * 2, 0, 0, w * h);

for (unsigned j = 0; j < h; j++)
{
Expand All @@ -104,6 +104,8 @@ VirtualGridModule::VirtualGridModule(unsigned w, unsigned h)
param->resetEnabled = false;
param->smoothEnabled = false;
param->randomizeEnabled = false;

configLight(i+j*w, rack::string::f("(%d,%d)", i, j));
}
}

Expand Down Expand Up @@ -174,6 +176,16 @@ void VirtualGridModule::process(const ProcessArgs& args)
std::for_each(presses.begin(), presses.end(), [=](std::tuple<int, int> c) {
GridConnectionManager::get().dispatchButtonMessage(&this->device, std::get<0>(c), std::get<1>(c), true);
});

// keep Rack light values in sync with LED buffer
// TODO: only do this in update functions, not in process()
for (int x = 0; x < 8; x++)
{
for (int y = 0; y < 8; y++)
{
lights[y * 8 + x].setBrightness(ledBuffer[y * 16 + x] / 15.0f);
}
}
}

json_t* VirtualGridModule::dataToJson()
Expand Down

0 comments on commit ff8d0c6

Please sign in to comment.