have udev only log PIUIO LightState upon change
Previously, the PIUIO_Leds code logged every LightState of every PIUIO_Led light with every call of Set() This commit adds checks to see if each of the PIUIO_Leds have changed LightState since the last Set() and skips logging the current LightState if there is no change. Each set of lights was already being looped through; the new code here just issues a continue to skip logging where possible. This helps reduce CPU usage when PIUIO_Leds are in use as the LightsDriver.
This commit is contained in:
@@ -85,6 +85,13 @@ void LightsDriver_Linux_PIUIO_Leds::Set( const LightsState *ls )
|
||||
{
|
||||
FOREACH_CabinetLight(light)
|
||||
{
|
||||
// Only SetLight if LightsState has changed since previous iteration.
|
||||
// This reduces unncessary strain on udev. -dguzek
|
||||
if (ls->m_bCabinetLights[light] == previousLS.m_bCabinetLights[light] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!SetLight(cabinet_leds[light], ls->m_bCabinetLights[light]))
|
||||
{
|
||||
LOG->Warn("Error setting cabinet light %s",
|
||||
@@ -101,6 +108,11 @@ void LightsDriver_Linux_PIUIO_Leds::Set( const LightsState *ls )
|
||||
{
|
||||
FOREACH_GameButton_Custom(gb)
|
||||
{
|
||||
if (ls->m_bGameButtonLights[c][gb] == previousLS.m_bGameButtonLights[c][gb])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!SetLight(dance_leds[c][gb], ls->m_bGameButtonLights[c][gb]))
|
||||
{
|
||||
LOG->Warn("Error setting button light %s",
|
||||
@@ -116,6 +128,11 @@ void LightsDriver_Linux_PIUIO_Leds::Set( const LightsState *ls )
|
||||
{
|
||||
FOREACH_GameButton_Custom(gb)
|
||||
{
|
||||
if (ls->m_bGameButtonLights[c][gb] == previousLS.m_bGameButtonLights[c][gb])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!SetLight(pump_leds[c][gb], ls->m_bGameButtonLights[c][gb]))
|
||||
{
|
||||
LOG->Warn("Error setting button light %s",
|
||||
@@ -129,6 +146,8 @@ void LightsDriver_Linux_PIUIO_Leds::Set( const LightsState *ls )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
previousLS = *ls;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
class LightsDriver_Linux_PIUIO_Leds : public LightsDriver
|
||||
{
|
||||
private:
|
||||
LightsState previousLS;
|
||||
|
||||
public:
|
||||
LightsDriver_Linux_PIUIO_Leds();
|
||||
virtual ~LightsDriver_Linux_PIUIO_Leds();
|
||||
|
||||
Reference in New Issue
Block a user