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

Method SetColor

Controllers/LIFXController/LIFXController.cpp:59–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void LIFXController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
60{
61 RGBColor color = ToRGBColor(red, green, blue);
62 hsv_t hsv;
63 rgb2hsv(color, &hsv);
64
65 data = data_buf;
66 memset( data, 0, 49 );
67
68 source = 2;
69 sequence = 1;
70
71 unsigned char target[8] = {0};
72
73 FrameHeader( 49, true, false, 0, source );
74 FrameAddress( target, false, false, sequence );
75 ProtocolAddress( 102 );
76
77 unsigned char * set_color = &data[36];
78
79 unsigned short hue = hsv.hue * (65536/360);
80 unsigned short saturation = hsv.saturation * (65536/256);
81 unsigned short brightness = hsv.value * (65536/256);
82 unsigned short kelvin = 3500;
83 unsigned int duration = 0;
84
85 memcpy(&set_color[LIFX_SET_COLOR_OFFSET_HUE], &hue, sizeof(unsigned short));
86 memcpy(&set_color[LIFX_SET_COLOR_OFFSET_SATURATION], &saturation, sizeof(unsigned short));
87 memcpy(&set_color[LIFX_SET_COLOR_OFFSET_BRIGHTNESS], &brightness, sizeof(unsigned short));
88 memcpy(&set_color[LIFX_SET_COLOR_OFFSET_KELVIN], &kelvin, sizeof(unsigned short));
89 memcpy(&set_color[LIFX_SET_COLOR_OFFSET_DURATION], &duration, sizeof(unsigned int));
90
91 port.udp_write((char *)data, 49);
92}
93
94void LIFXController::FrameHeader
95 (

Callers 1

DeviceUpdateLEDsMethod · 0.45

Calls 2

rgb2hsvFunction · 0.85
udp_writeMethod · 0.80

Tested by

no test coverage detected