Skip to content

Commit

Permalink
Fix RGB until it is globally reworked
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulh committed Jan 22, 2024
1 parent 496284b commit 200ff3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
13 changes: 6 additions & 7 deletions src/bin/calaos_server/IO/Mqtt/MqttOutputLightRGB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ MqttOutputLightRGB::MqttOutputLightRGB(Params &p):
OutputLightRGB(p)
{
// We use real state for this IO: only emit change when the value really changes
useRealState = true;
//useRealState = true;

// Define IO documentation
ioDoc->friendlyNameSet("MqttOutputLightRGB");
Expand Down Expand Up @@ -58,12 +58,11 @@ void MqttOutputLightRGB::readValue()
bool err;
auto c = ctrl->getValueColor(get_params(), err);

if (!err)
{
color = c;
EmitSignalIO();
emitChange();
}
//TODO: it does not work for now. We need to refactor the way it handle color+state in all
//RGB class and also add better state/color/brightness control in calaos

//if (!err)
//stateUpdated(c, c != ColorValue(0, 0, 0));
}

void MqttOutputLightRGB::setColorReal(const ColorValue &c, bool _state)
Expand Down
9 changes: 7 additions & 2 deletions src/bin/calaos_server/IO/OutputLightRGB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,17 @@ void OutputLightRGB::TimerAutoChange()

void OutputLightRGB::stateUpdated(const ColorValue &c, bool s)
{
color = c;
bool hasChanged = false;
if (s != state || c != color)
hasChanged = true;

state = s;
color = c;
cmd_state = "set " + get_value_string();

EmitSignalIO();
emitChange();
if (hasChanged)
emitChange();
}

bool OutputLightRGB::check_condition_value(std::string cvalue, bool equal)
Expand Down
2 changes: 1 addition & 1 deletion src/bin/calaos_server/IO/Wago/WODaliRVB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void WODaliRVB::checkReadState()
double(green) * 255. / 100.,
double(blue) * 255. / 1000.);

stateUpdated(c, red != 0 || green != 0 || blue != 0);
stateUpdated(c, red != 0 && green != 0 && blue != 0);
}

void WODaliRVB::WagoUDPCommand_cb(bool status, string command, string)
Expand Down

0 comments on commit 200ff3d

Please sign in to comment.