Open celik75 opened 1 year ago
i managd to fix it, for someone else who want to use it.
`#include
WiFiMulti wifiMulti;
ESP8266WiFiMulti wifiMulti;
const char ssid = "xx"; const char password = "xx"; const char AmbilightSource = "http://192.168.2.xx:1925/6/ambilight/processed"; const char WLEDSourceLeft = "http://192.168.2.xx/json";
int l_0_rgb[3] = {0}; int l_1_rgb[3] = {0}; int l_2_rgb[3] = {0};
void setup() {
USE_SERIAL.begin(115200);
for (uint8_t t = 4; t > 0; t--) { USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); USE_SERIAL.flush(); delay(1000); }
wifiMulti.addAP(ssid, password);
}
void loop() { // wait for WiFi connection if ((wifiMulti.run() == WL_CONNECTED)) { HTTPClient httpAmbilight; httpAmbilight.begin(AmbilightSource); //HTTP int httpCode = httpAmbilight.GET();
if (httpCode > 0) {
if (httpCode == HTTP_CODE_OK) {
String payload = httpAmbilight.getString();
DynamicJsonDocument doc(1024);
deserializeJson(doc, payload);
JsonObject layer1 = doc["layer1"];
JsonObject layer1_l = layer1["left"];
JsonObject layer1_l_0 = layer1_l["0"];
JsonObject layer1_l_1 = layer1_l["1"];
JsonObject layer1_l_2 = layer1_l["2"];
l_0_rgb[0] = layer1_l_0["r"], l_0_rgb[1] = layer1_l_0["g"], l_0_rgb[2] = layer1_l_0["b"];
l_1_rgb[0] = layer1_l_1["r"], l_1_rgb[1] = layer1_l_1["g"], l_1_rgb[2] = layer1_l_1["b"];
l_2_rgb[0] = layer1_l_2["r"], l_2_rgb[1] = layer1_l_2["g"], l_2_rgb[2] = layer1_l_2["b"];
HTTPClient httpWLED;
httpWLED.begin(WLEDSourceLeft);
httpWLED.addHeader("Content-Type", "application/json");
int httpResponseCode = httpWLED.POST("{ \"on\": true, \"bri\": 25, \"transition\": 10, \"mainseg\": 0, \"seg\": [{ \"id\": 0, \"start\": 0, \"stop\": 26, \"grp\": 1, \"spc\": 0, \"on\": true, \"bri\": 255, \"col\": [ [" + String(l_0_rgb[0]) + ", " + String(l_0_rgb[1]) + ", " + String(l_0_rgb[2]) + "], [0, 0, 0], [0, 0, 0] ], \"fx\": 0, \"sx\": 64, \"ix\": 50, \"pal\": 0, \"sel\": false, \"rev\": false, \"mi\": false }, { \"id\": 1, \"start\": 26, \"stop\": 52, \"grp\": 1, \"spc\": 0, \"on\": true, \"bri\": 255, \"col\": [ [" + String(l_1_rgb[0]) + ", " + String(l_1_rgb[1]) + ", " + String(l_1_rgb[2]) + "], [0, 0, 0], [0, 0, 0] ], \"fx\": 0, \"sx\": 64, \"ix\": 50, \"pal\": 0, \"sel\": false, \"rev\": false, \"mi\": false }, { \"id\": 2, \"start\": 52, \"stop\": 78, \"grp\": 1, \"spc\": 0, \"on\": true, \"bri\": 255, \"col\": [ [" + String(l_2_rgb[0]) + ", " + String(l_2_rgb[1]) + ", " + String(l_2_rgb[2]) + "], [0, 0, 0], [0, 0, 0] ], \"fx\": 0, \"sx\": 64, \"ix\": 50, \"pal\": 0, \"sel\": false, \"rev\": false, \"mi\": false } ] }");
httpWLED.end();
}
}
else {
USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", httpAmbilight.errorToString(httpCode).c_str());
}
httpAmbilight.end();
} delay(200); }`
i have 2 led strips(gradient), i want to use it for left and right of my tv as a floor lamp vertical.
If i want to use for example the left side of my tv, do i need to delete this snippet of the code or change any other code?
` JsonObject layer1_top = layer1["top"];