Input modularity deployed (see lighthub/modules)

CCS811 & HDC1080 almost developed as Input module
Inputs core refactored
This commit is contained in:
2019-03-25 02:04:48 +03:00
parent db29ee566c
commit b30b9346fb
11 changed files with 383 additions and 23 deletions

View File

@@ -135,6 +135,7 @@ uint32_t nextPollingCheck = 0;
uint32_t nextInputCheck = 0;
uint32_t nextLanCheckTime = 0;
uint32_t nextThermostatCheck = 0;
uint32_t nextSensorCheck =0;
aJsonObject *pollingItem = NULL;
@@ -806,7 +807,6 @@ void cmdFunctionReboot(int arg_cnt, char **args) {
void applyConfig() {
if (!root) return;
#ifdef _dmxin
int itemsCount;
dmxArr = aJson.getObjectItem(root, "dmxin");
@@ -878,6 +878,8 @@ void applyConfig() {
}
inputs = aJson.getObjectItem(root, "in");
mqttArr = aJson.getObjectItem(root, "mqtt");
inputSetup();
#ifdef SYSLOG_ENABLE
udpSyslogArr = aJson.getObjectItem(root, "syslog");
#endif
@@ -1571,17 +1573,45 @@ void modbusIdle(void) {
void inputLoop(void) {
if (!inputs) return;
if (millis() > nextInputCheck) {
aJsonObject *input = inputs->child;
while (input) {
if ((input->type == aJson_Object)) {
Input in(input);
in.poll();
in.poll(CHECK_INPUT);
}
input = input->next;
}
nextInputCheck = millis() + INTERVAL_CHECK_INPUT;
}
if (millis() > nextSensorCheck) {
aJsonObject *input = inputs->child;
while (input) {
if ((input->type == aJson_Object)) {
Input in(input);
in.poll(CHECK_SENSOR);
}
input = input->next;
}
nextSensorCheck = millis() + INTERVAL_CHECK_SENSOR;
}
}
void inputSetup(void) {
if (!inputs) return;
aJsonObject *input = inputs->child;
while (input) {
if ((input->type == aJson_Object)) {
Input in(input);
in.setup();
}
input = input->next;
}
}
#ifndef MODBUS_DISABLE