From 92be80cbb1c93849bea61460cfbe8f1acead5451 Mon Sep 17 00:00:00 2001 From: soif Date: Thu, 5 Oct 2017 16:24:34 +0200 Subject: [PATCH] Uses light_ir.ino lib methods when LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR is defined --- code/espurna/web.ino | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/code/espurna/web.ino b/code/espurna/web.ino index b02a640f..c30b9fdc 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -177,7 +177,27 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) { #endif #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE + #ifdef LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR + if (lightHasColor()) { + + if (action.equals("color_hsv") && root.containsKey("data")) { + JsonObject& data = root["data"]; + setLightColor(data["h"],data["s"],data["v"]); + lightUpdate(true, true); + } + + } + if (action.equals("anim_mode") && root.containsKey("data")) { + lightAnimMode(root["data"]); + lightUpdate(true, true); + } + if (action.equals("anim_speed") && root.containsKey("data")) { + lightAnimSpeed(root["data"]); + lightUpdate(true, true); + } + + #else if (lightHasColor()) { if (action.equals("color") && root.containsKey("data")) { @@ -199,8 +219,8 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) { lightUpdate(true, true); } } - - #endif + #endif //LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR + #endif //LIGHT_PROVIDER != LIGHT_PROVIDER_NONE }; @@ -490,8 +510,18 @@ void _wsStart(uint32_t client_id) { root["useWhite"] = getSetting("useWhite", LIGHT_USE_WHITE).toInt() == 1; root["useGamma"] = getSetting("useGamma", LIGHT_USE_GAMMA).toInt() == 1; if (lightHasColor()) { - root["color"] = lightColor(); - root["brightness"] = lightBrightness(); + + #ifdef LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR + root["anim_mode"] = lightAnimMode(); + root["anim_speed"] = lightAnimSpeed(); + JsonObject& color_hsv = root.createNestedObject("color_hsv"); + color_hsv["h"] = lightColorH(); + color_hsv["s"] = lightColorS(); + color_hsv["v"] = lightColorV(); + #else + root["color"] = lightColor(); + root["brightness"] = lightBrightness(); + #endif } JsonArray& channels = root.createNestedArray("channels"); for (unsigned char id=0; id < lightChannels(); id++) {