Merge pull request #737 from dguzek/quiet-udev

reduce udev logging of PIUIO LightState changes
This commit is contained in:
Colby Klein
2015-08-04 11:16:47 -07:00
2 changed files with 26 additions and 4 deletions
@@ -85,6 +85,13 @@ void LightsDriver_Linux_PIUIO_Leds::Set( const LightsState *ls )
{ {
FOREACH_CabinetLight(light) 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])) if (!SetLight(cabinet_leds[light], ls->m_bCabinetLights[light]))
{ {
LOG->Warn("Error setting cabinet light %s", LOG->Warn("Error setting cabinet light %s",
@@ -101,6 +108,11 @@ void LightsDriver_Linux_PIUIO_Leds::Set( const LightsState *ls )
{ {
FOREACH_GameButton_Custom(gb) 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])) if (!SetLight(dance_leds[c][gb], ls->m_bGameButtonLights[c][gb]))
{ {
LOG->Warn("Error setting button light %s", LOG->Warn("Error setting button light %s",
@@ -116,6 +128,11 @@ void LightsDriver_Linux_PIUIO_Leds::Set( const LightsState *ls )
{ {
FOREACH_GameButton_Custom(gb) 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])) if (!SetLight(pump_leds[c][gb], ls->m_bGameButtonLights[c][gb]))
{ {
LOG->Warn("Error setting button light %s", LOG->Warn("Error setting button light %s",
@@ -129,6 +146,8 @@ void LightsDriver_Linux_PIUIO_Leds::Set( const LightsState *ls )
{ {
return; return;
} }
previousLS = *ls;
} }
/* /*
@@ -7,6 +7,9 @@
class LightsDriver_Linux_PIUIO_Leds : public LightsDriver class LightsDriver_Linux_PIUIO_Leds : public LightsDriver
{ {
private:
LightsState previousLS;
public: public:
LightsDriver_Linux_PIUIO_Leds(); LightsDriver_Linux_PIUIO_Leds();
virtual ~LightsDriver_Linux_PIUIO_Leds(); virtual ~LightsDriver_Linux_PIUIO_Leds();