conversion du rgb string -> hex

This commit is contained in:
Julien Cabillot 2017-03-09 20:17:28 +01:00 committed by Cabillot Julien
parent 5ab39d80fb
commit fac537f5be

View File

@ -120,11 +120,11 @@ void callbackMQTT(char* topic, byte* payload, unsigned int length)
client.publish(MQTT_LED_BRIGHTNESS_STATE, message_buff, true);
} else if (stopic == MQTT_LED_COLOR_COMMAND) {
// Sample : 134,168,255
color = CRGB(
msgString.substring(0,3).toInt(),
msgString.substring(4,7).toInt(),
msgString.substring(8,11).toInt()
);
int red = msgString.substring(0, msgString.indexOf(',')).toInt();
int green = msgString.substring(msgString.indexOf(',') + 1, msgString.lastIndexOf(',')).toInt();
int blue = msgString.substring(msgString.lastIndexOf(',') + 1).toInt();
color=((red <<16)|(green <<8)|blue);
client.publish(MQTT_LED_COLOR_STATE, message_buff, true);
} else if (stopic == MQTT_LED_SPEED_COMMAND) {
speed = msgString.toInt();