From 575e05cd843f033d7ccf8d86b863440e21cdb2e6 Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 1 May 2025 20:31:31 +0300 Subject: [PATCH] RE optional --- lighthub/inputs.cpp | 26 ++++++++++++++++++++------ lighthub/inputs.h | 7 +++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/lighthub/inputs.cpp b/lighthub/inputs.cpp index 2f2e9a2..dd9666e 100644 --- a/lighthub/inputs.cpp +++ b/lighthub/inputs.cpp @@ -151,8 +151,9 @@ void Input::Parse(aJsonObject * configObj) } void Input::stop() { + if (!inputObj || !root || inputObj->type != aJson_Object) return; +#ifdef ROTARYENCODER aJsonObject *itemBuffer; -if (!inputObj || !root || inputObj->type != aJson_Object) return; itemBuffer = aJson.getObjectItem(inputObj, "#"); if (inType == IN_RE && itemBuffer && itemBuffer->valuestring && itemBuffer->type == aJson_Array) { @@ -160,6 +161,7 @@ if (inType == IN_RE && itemBuffer && itemBuffer->valuestring && itemBuffer->type itemBuffer->valuestring = NULL; debugSerial<type == aJson_Object)) { void Input::setupRotaryEncoder() { +#ifdef ROTARYENCODER aJsonObject *itemBuffer; if (!inputObj || !root || inputObj->type != aJson_Object) return; itemBuffer = aJson.getObjectItem(inputObj, "#"); @@ -206,6 +209,7 @@ if (itemBuffer && !itemBuffer->valuestring && itemBuffer->type == aJson_Array) debugSerial<type == aJson_Object && itemBuffer && itemBuffer->type == aJson_Array && itemBuffer->valuestring) @@ -322,16 +327,19 @@ switch (cause) { ((RotaryEncoder *) itemBuffer->valuestring) ->tick(); contactPoll(cause, ((RotaryEncoder *) itemBuffer->valuestring)); } +#endif } break; +#ifdef ULTRASONIC case CHECK_ULTRASONIC: switch (inType) { case IN_ULTRASONIC: analogPoll(cause); contactPoll(cause); - } - break; + } + break; + #endif case CHECK_SENSOR: //Slow polling switch (inType) { @@ -811,8 +819,14 @@ if (newState!=store->state && cause!=CHECK_INTERRUPT) debugSerial<state) //Timer based transitions if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_IDLE,0xFFFF)) changeState(IS_IDLE, cause,currentInputObject); break; } //switch - +#ifdef ROTARYENCODER if (re) { aJsonObject * bufferItem; @@ -946,7 +960,7 @@ if (re) if (bufferItem=aJson.getObjectItem(currentInputObject, "-")) {checkInstructions(bufferItem);executeCommand(bufferItem,0);}; } } - +#endif } //if not INTERRUPT if (currentInputState != store->lastValue) // value changed { diff --git a/lighthub/inputs.h b/lighthub/inputs.h index 2130aff..a3432a7 100644 --- a/lighthub/inputs.h +++ b/lighthub/inputs.h @@ -21,7 +21,9 @@ e-mail anklimov@gmail.com #include #include "modules/in_ccs811_hdc1080.h" #include "itemCmd.h" +#ifdef ROTARYENCODER #include "RotaryEncoder.h" +#endif #define IN_ACTIVE_HIGH 2 // High level = PUSHED/ CLOSED/ ON othervise :Low Level. Use INPUT mode instead of INPUT_PULLUP for digital pin #define IN_ANALOG 64 // Analog input @@ -165,7 +167,12 @@ public: protected: void Parse(aJsonObject * configObj = NULL); + #ifdef ROTARYENCODER void contactPoll(short cause, RotaryEncoder * re = NULL); + #else + void contactPoll(short cause); + #endif + void analogPoll(short cause); void dht22Poll();