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

Method UpdateLEDs

Controllers/NanoleafController/NanoleafController.cpp:147–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147void NanoleafController::UpdateLEDs(std::vector<RGBColor>& colors)
148{
149 /*-------------------------------------------------------------*\
150 | Requires StartExternalControl() to have been called prior. |
151 \*-------------------------------------------------------------*/
152
153 if(model == NANOLEAF_LIGHT_PANELS_MODEL)
154 {
155 /*---------------------------------------------------------*\
156 | Protocol V1 - https://forum.nanoleaf.me/docs |
157 | |
158 | Size Description |
159 | --------------------------------------------------------- |
160 | 1 nPanels Number of panels |
161 | |
162 | 1 panelId ID of panel |
163 | 1 nFrames Number of frames (always 1) |
164 | 1 R Red channel |
165 | 1 G Green channel |
166 | 1 B Blue channel |
167 | 1 W White channel (ignored) |
168 | 1 transitionTime Transition time (x 100ms) |
169 \*---------------------------------------------------------*/
170 uint8_t size = panel_ids.size();
171
172 uint8_t* message = (uint8_t*)malloc((size * 7) + 1);
173
174 message[0] = (uint8_t)size; /* nPanels */
175
176 for(int i = 0; i < size; i++)
177 {
178 message[(7 * i) + 0 + 1] = (uint8_t)panel_ids[i]; /* panelId */
179 message[(7 * i) + 1 + 1] = (uint8_t)1; /* nFrames */
180 message[(7 * i) + 2 + 1] = (uint8_t)RGBGetRValue(colors[i]); /* R */
181 message[(7 * i) + 3 + 1] = (uint8_t)RGBGetGValue(colors[i]); /* G */
182 message[(7 * i) + 4 + 1] = (uint8_t)RGBGetBValue(colors[i]); /* B */
183 message[(7 * i) + 5 + 1] = (uint8_t)0; /* W */
184 message[(7 * i) + 6 + 1] = (uint8_t)0; /* transitionTime */
185 }
186
187 external_control_socket.udp_write((char*)message, (size * 7) + 1);
188
189 free(message);
190 }
191 else if((model == NANOLEAF_CANVAS_MODEL)
192 || (model == NANOLEAF_SHAPES_MODEL))
193 {
194 /*---------------------------------------------------------*\
195 | Protocol V2 - https://forum.nanoleaf.me/docs |
196 | |
197 | Size Description |
198 | --------------------------------------------------------- |
199 | 2 nPanels Number of panels |
200 | |
201 | 2 panelId ID of panel |
202 | 1 R Red channel |
203 | 1 G Green channel |
204 | 1 B Blue channel |

Callers 1

DeviceUpdateLEDsMethod · 0.45

Calls 2

udp_writeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected