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

Method SetColor

Controllers/PhilipsWizController/PhilipsWizController.cpp:80–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void PhilipsWizController::SetColor(unsigned char red, unsigned char green, unsigned char blue, unsigned char brightness)
81{
82 json command;
83
84 /*-----------------------------------------------------------------*\
85 | Fill in the setPilot command with RGB and brightness information. |
86 | The bulb will not respond to 0, 0, 0, so if all channels are zero,|
87 | set the state to off. Otherwise, set it to on. As we're also |
88 | running direct the bulb needs to be set back to max brightness. |
89 \*-----------------------------------------------------------------*/
90 command["method"] = "setPilot";
91 command["params"]["r"] = red;
92 command["params"]["g"] = green;
93 command["params"]["b"] = blue;
94 command["params"]["dimming"] = brightness;
95 command["params"]["state"] = !((red == 0) && (green == 0) && (blue == 0));
96
97 /*-----------------------------------------------------------------*\
98 | The official Wiz app also sends a warm white level with its |
99 | custom colours. Until we can figure out a way to account for it |
100 | correctly, set the cool white level to the average of RGB to |
101 | improve its apparent brightness. |
102 \*-----------------------------------------------------------------*/
103 if(use_warm_white)
104 {
105 command["params"]["w"] = (red + green + blue) / 3;
106 }
107 else
108 {
109 command["params"]["w"] = 0;
110 }
111
112 if(use_cool_white)
113 {
114 command["params"]["c"] = (red + green + blue) / 3;
115 }
116 else
117 {
118 command["params"]["c"] = 0;
119 }
120
121 /*-----------------------------------------------------------------*\
122 | Convert the JSON object to a string and write it |
123 \*-----------------------------------------------------------------*/
124 std::string command_str = command.dump();
125
126 port.udp_write((char *)command_str.c_str(), command_str.length() + 1);
127}
128
129void PhilipsWizController::SetScene(int scene, unsigned char brightness)
130{

Callers 1

DeviceUpdateLEDsMethod · 0.45

Calls 2

udp_writeMethod · 0.80
dumpMethod · 0.45

Tested by

no test coverage detected