diff --git a/lighthub/inputs.cpp b/lighthub/inputs.cpp index 13abc70..de552f6 100644 --- a/lighthub/inputs.cpp +++ b/lighthub/inputs.cpp @@ -115,13 +115,16 @@ void Input::setup() if (!isValid() || (!root)) return; #ifndef CSSHDC_DISABLE - in_ccs811 ccs811(this); - in_hdc1080 hdc1080(this); - if (inType == IN_CCS811) + { + in_ccs811 ccs811(this); ccs811.Setup(pin); + } else if (inType == IN_HDC1080) + { + in_hdc1080 hdc1080(this); hdc1080.Setup(pin); + } // TODO rest types setup #endif diff --git a/lighthub/modules/in_ccs811_hdc1080.cpp b/lighthub/modules/in_ccs811_hdc1080.cpp index bfcdae6..2104c12 100644 --- a/lighthub/modules/in_ccs811_hdc1080.cpp +++ b/lighthub/modules/in_ccs811_hdc1080.cpp @@ -7,6 +7,9 @@ CCS811 ccs811(CCS811_ADDR); ClosedCube_HDC1080 hdc1080; long ccs811Baseline; +bool CCS811ready = false; +bool HDC1080ready = false; + int in_ccs811::Setup(int addr) { #ifdef WAK_PIN @@ -15,7 +18,7 @@ int in_ccs811::Setup(int addr) #endif Serial.println("CCS811 Init"); - +if (CCS811ready) return 0; Wire.begin(); //Inialize I2C Harware //It is recommended to check return status on .begin(), but it is not @@ -28,11 +31,13 @@ Wire.begin(); //Inialize I2C Harware return 0; } ccs811.setBaseline(62000); +CCS811ready = true; return 1; } int in_hdc1080::Setup(int addr) { +if (HDC1080ready) return 0; Serial.println("HDC1080 Init "); Wire.begin(); //Inialize I2C Harware // Default settings: @@ -44,6 +49,7 @@ Serial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instrum Serial.print("Device ID=0x"); Serial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device printSerialNumber(); +HDC1080ready = true; return 1; } @@ -60,7 +66,7 @@ int in_hdc1080::Poll() { float h,t; int reg; - +if (!HDC1080ready) return 0; Serial.print("HDC Status="); Serial.println(reg=hdc1080.readRegister().rawData,HEX); if (reg!=0xff) @@ -84,6 +90,7 @@ return 1; int in_ccs811::Poll() { + if (!CCS811ready) return 0; #ifdef WAK_PIN digitalWrite(WAK_PIN,LOW); #endif diff --git a/platformio.ini b/platformio.ini index d88de90..be6bf47 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,9 +16,9 @@ env_default = ; megaatmega2560-net ; due ; esp8266 -; esp32 +; esp32 ; megaatmega2560-5500 - due-5500 +; due-5500 ; controllino ; stm32 ; nrf52840 @@ -93,18 +93,15 @@ lib_ignore = Ethernet Ethernet2 Ethernet3 - HTTPClient - httpClient EEPROM Artnet - HTTPClient UIPEthernet ESP_EEPROM - EEPROM + HttpClient_ID66 + HttpClient lib_deps = https://github.com/ebenolson/WIFIMANAGER-ESP32.git https://github.com/zhouhan0126/WebServer-esp32.git - ArduinoHttpClient https://github.com/anklimov/aJson https://github.com/anklimov/CmdArduino https://github.com/knolleary/pubsubclient.git @@ -214,6 +211,8 @@ lib_ignore = SdFat httpClient HTTPClient + HttpClient_ID66 + HttpClient ArduinoHttpClient Ethernet3 Ethernet2