Added V0.6 Tested oneled. Homie Limit to 2 leds for oneled

This commit is contained in:
Nicolas Bachschwell 2017-04-21 21:11:34 +02:00
parent ad4d1c0389
commit b98ca673ce

View File

@ -3,8 +3,7 @@
* Normally befor sending it to git, I am testing it. But I can't test it while in school...
* So the code here might work or not. But I should be able to garantee that it is working on a Node-MCU (ESP8266) when I tested it.
*
* Tested: NO (I did not test it yet)
* Not Tested funktion: oneled
* TESTED: YES
*/
#include <Arduino.h>
#include <Homie.h>
@ -38,7 +37,7 @@ int nextLed = 0;
bool onLedsShouldChange(String value){
char chars[value.length() + 1];
strcpy(chars, value.c_str()); //Transforming String into char array.
StaticJsonBuffer<200> jsonBuffer;
StaticJsonBuffer<400> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(chars); //Parsing JSON String
if(!root.success()){ //Parsing succeed?
Homie.setNodeProperty(stripNode, "last", "{\"state\":\"error\",\"id\":\"jsonParseError\",\"msg\":\"Failed to parse Data.\"}"); //Rückmeldung an den Broker das der String nicht geparsed werden konnte
@ -124,6 +123,7 @@ bool onLedsShouldChange(String value){
else if(actionToDo == "oneled"){
reset();
thingToDo = "oneLed";
Serial.println("Ha: " + String(root["leds"].size()));
for(int count = 0;count < root["leds"].size(); count++){
strip.setPixelColor((int)root["leds"][count]["id"], strip.Color((int)root["leds"][count]["red"], (int)root["leds"][count]["green"], (int)root["leds"][count]["blue"]));
}