MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / SetPower

Method SetPower

Controllers/YeelightController/YeelightController.cpp:159–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159void YeelightController::SetPower()
160{
161 json command;
162
163 /*-----------------------------------------------------------------*\
164 | Fill in the set_rgb command with RGB information. |
165 | The bulb will not respond to 0, 0, 0, so if all channels are zero,|
166 | set the state to off. Otherwise, set it to on. |
167 \*-----------------------------------------------------------------*/
168 command["id"] = 1;
169 command["method"] = "set_power";
170 command["params"][0] = "on";
171 command["params"][1] = "sudden";
172 command["params"][2] = 0;
173 command["params"][3] = 2;
174
175 /*-----------------------------------------------------------------*\
176 | Convert the JSON object to a string and write it |
177 \*-----------------------------------------------------------------*/
178 std::string command_str = command.dump().append("\r\n");
179
180 port.tcp_client_connect();
181 port.tcp_client_write((char *)command_str.c_str(), command_str.length() + 1);
182 port.tcp_close();
183}
184
185void YeelightController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
186{

Callers

nothing calls this directly

Calls 5

tcp_client_connectMethod · 0.80
tcp_client_writeMethod · 0.80
tcp_closeMethod · 0.80
appendMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected