diff --git a/lighthub/inputs.cpp b/lighthub/inputs.cpp index fdde59f..2f2e9a2 100644 --- a/lighthub/inputs.cpp +++ b/lighthub/inputs.cpp @@ -147,16 +147,6 @@ void Input::Parse(aJsonObject * configObj) store = (inStore *) &inputObj->valueint; } - /* - // Persistant storage - itemBuffer = aJson.getObjectItem(inputObj, "@S"); - if (!itemBuffer) { - debugSerial<valueint; - */ } void Input::stop() @@ -604,17 +594,24 @@ debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") << // To Be Refactored - move to Execute after class Input inheritation on abstract chan bool Input::checkInstructions(aJsonObject * obj) { - aJsonObject *gotoObj = aJson.getObjectItem(obj, "goto"); + aJsonObject *gotoObj = aJson.getObjectItem(obj, "activate"); if (gotoObj) switch (gotoObj->type) - { - case aJson_Int: - debugSerial<valueint <valueint); + { case aJson_Array: + { + char * name = getStringFromJson(gotoObj,0); + if (name) + { + Input in (name); + debugSerial<<"IN: "<valuestring <valuestring); + return setCurrentInput(gotoObj); + break; } return false; } @@ -628,12 +625,27 @@ debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") << return inputObj; } + bool Input::setCurrentInput(aJsonObject * obj) + { + if (!obj) return false; + switch (obj->type) + { + case aJson_Int: + debugSerial<valueint <valueint); + break; + case aJson_String: + debugSerial<valuestring <valuestring); + } + } + bool Input::setCurrentInput(int n) { if (!inputObj) return false; aJsonObject * curInput = NULL; aJsonObject *act = aJson.getObjectItem(inputObj, "act"); - if (act && act->type == aJson_Array) + if (act && (act->type == aJson_Array || act->type ==aJson_Object)) { if (n) curInput = aJson.getArrayItem(act,n-1); diff --git a/lighthub/inputs.h b/lighthub/inputs.h index a2838fc..2130aff 100644 --- a/lighthub/inputs.h +++ b/lighthub/inputs.h @@ -188,6 +188,8 @@ protected: void setupRotaryEncoder(); aJsonObject * getCurrentInput(); + + bool setCurrentInput(aJsonObject * obj); bool setCurrentInput(int n); bool setCurrentInput(char * name); bool checkInstructions(aJsonObject * obj);