conversion du rgb string -> hex
This commit is contained in:
parent
5ab39d80fb
commit
fac537f5be
@ -120,11 +120,11 @@ void callbackMQTT(char* topic, byte* payload, unsigned int length)
|
|||||||
client.publish(MQTT_LED_BRIGHTNESS_STATE, message_buff, true);
|
client.publish(MQTT_LED_BRIGHTNESS_STATE, message_buff, true);
|
||||||
} else if (stopic == MQTT_LED_COLOR_COMMAND) {
|
} else if (stopic == MQTT_LED_COLOR_COMMAND) {
|
||||||
// Sample : 134,168,255
|
// Sample : 134,168,255
|
||||||
color = CRGB(
|
int red = msgString.substring(0, msgString.indexOf(',')).toInt();
|
||||||
msgString.substring(0,3).toInt(),
|
int green = msgString.substring(msgString.indexOf(',') + 1, msgString.lastIndexOf(',')).toInt();
|
||||||
msgString.substring(4,7).toInt(),
|
int blue = msgString.substring(msgString.lastIndexOf(',') + 1).toInt();
|
||||||
msgString.substring(8,11).toInt()
|
|
||||||
);
|
color=((red <<16)|(green <<8)|blue);
|
||||||
client.publish(MQTT_LED_COLOR_STATE, message_buff, true);
|
client.publish(MQTT_LED_COLOR_STATE, message_buff, true);
|
||||||
} else if (stopic == MQTT_LED_SPEED_COMMAND) {
|
} else if (stopic == MQTT_LED_SPEED_COMMAND) {
|
||||||
speed = msgString.toInt();
|
speed = msgString.toInt();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user