Skip to content

Commit

Permalink
lazy start of ppuc update loops
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Nov 21, 2023
1 parent a7ce221 commit ca3047e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/ppuc/examples/t2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,17 @@ switches:
-
description: Shooter
number: 78
board: 2
port: 16
board: 1
port: 10
ledStripes:
-
description: Inserts
board: 4
port: 29
ledType: WS2812_RGBW
amount: 63
lightUp: 0
afterGlow: 0
lightUp: 100
afterGlow: 1200
lamps:
-
description: 'Multiplier 2X'
Expand Down
12 changes: 9 additions & 3 deletions src/ppuc/ppuc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,8 @@ int main(int argc, char *argv[])
int poll_trigger = poll_interval_ms * 1000 / sleep_us;
int index_recv = 0;

ppuc->StartUpdates();

while (true)
{
std::this_thread::sleep_for(std::chrono::microseconds(sleep_us));
Expand All @@ -778,6 +780,10 @@ int main(int argc, char *argv[])
PPUCSwitchState *switchState;
while ((switchState = ppuc->GetNextSwitchState()) != nullptr)
{
if (opt_debug)
{
printf("Switch updated: #%d, %d\n", switchState->number, switchState->state);
}
PinmameSetSwitch(switchState->number, switchState->state);
};
}
Expand All @@ -789,9 +795,9 @@ int main(int argc, char *argv[])
uint8_t lampState = changedLampStates[c].state == 0 ? 0 : 1;

if (opt_debug)
printf("Lamp updated: lampNo=%d, lampState=%d\n",
lampNo,
lampState);
{
printf("Lamp updated: #%d, %d\n", lampNo, lampState);
}

ppuc->SetLampState(lampNo, lampState);
}
Expand Down

0 comments on commit ca3047e

Please sign in to comment.