From f691aa0cb0988810b930fef9eece42bdbc1ca33e Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Tue, 26 May 2020 23:26:42 +0300 Subject: [PATCH] stop channels when get --- build-flags/build_flags_due | 7 ++ lighthub/item.cpp | 18 +++- lighthub/item.h | 1 + lighthub/main.cpp | 116 +++++++++++++++++-------- lighthub/modules/in_ccs811_hdc1080.cpp | 1 + platformio.ini | 58 ++++++++++++- 6 files changed, 159 insertions(+), 42 deletions(-) create mode 100644 build-flags/build_flags_due diff --git a/build-flags/build_flags_due b/build-flags/build_flags_due new file mode 100644 index 0000000..5670e22 --- /dev/null +++ b/build-flags/build_flags_due @@ -0,0 +1,7 @@ +-DW5500_CS_PIN=53 +-DDMX_SMOOTH +#-DSYSLOG_ENABLE +-DMODBUS_DIMMER_PARAM=SERIAL_8E1 +#-DARTNET_ENABLE +-DOTA +#-DWiz5500 diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 29996dc..18c9948 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -200,6 +200,15 @@ if (driver) else return false; } +void Item::Stop() +{ +if (driver) + { + driver->Stop(); + } +return; +} + Item::~Item() { if (driver) @@ -459,7 +468,6 @@ return suffixCode; int Item::Ctrl(char * payload, char * subItem){ if (!payload) return 0; -bool send = isNotRetainingStatus() ; int suffixCode = 0; //int setCommand = CMD_SET; //default SET behavior now - not turn on channels @@ -715,12 +723,13 @@ bool send = isNotRetainingStatus() ; } break; case CMD_NUM: - if (itemType == CH_GROUP || n!=1) break; - + //if (itemType == CH_GROUP || n!=1) break; + if (n!=1) break; int cType=getChanType(); - if ( cType == CH_RGB || cType == CH_RGBW) + if ( cType == CH_RGB || cType == CH_RGBW || cType == CH_GROUP ) { st.aslong = getVal(); + st.hsv_flag=1; switch (suffixCode) { case S_SAT: @@ -742,6 +751,7 @@ bool send = isNotRetainingStatus() ; n=3; setVal(st.aslong); } + //if (itemType == CH_GROUP) break; } else // Non-color channel if (suffixCode == S_SAT || suffixCode == S_HUE) return -3; diff --git a/lighthub/item.h b/lighthub/item.h index 283e88d..f7b9725 100644 --- a/lighthub/item.h +++ b/lighthub/item.h @@ -178,6 +178,7 @@ class Item boolean isValid (); boolean Setup(); + void Stop(); int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL); int Ctrl(char * payload, char * subItem=NULL); diff --git a/lighthub/main.cpp b/lighthub/main.cpp index b1f6b6d..a229f8b 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -194,7 +194,20 @@ while (configLocked) inputLoop(); } -pollingItem = NULL;; +//Stoping the channels +aJsonObject * item = items->child; +while (items && item) + { + if (item->type == aJson_Array && aJson.getArraySize(item)>0) + { + Item it(item->name); + if (it.isValid()) it.Stop(); + + + } + item = item->next; + } +pollingItem = NULL; debugSerial< 0) - switch (Ethernet.maintain()) { + { + int etherStatus = Ethernet.maintain(); + + #ifdef ETHENET_GENERIC + if (Ethernet.linkStatus() == LinkOFF) etherStatus = NO_LINK; + #endif + switch (etherStatus) { case NO_LINK: debugSerial<begin(); #endif @@ -806,10 +844,9 @@ wifiManager.setTimeout(30); debugSerial<begin(); #endif @@ -1524,10 +1561,10 @@ void printFirmwareVersionAndBuildOptions() { #ifdef CONTROLLINO debugSerial< HAVE_IP_ADDRESS) { mqttClient.loop(); + + #if defined(OTA) + ArduinoOTA.poll(); + #endif + #ifdef _artnet if (artnet) artnet->read(); ///hung #endif diff --git a/lighthub/modules/in_ccs811_hdc1080.cpp b/lighthub/modules/in_ccs811_hdc1080.cpp index b479812..57f81db 100644 --- a/lighthub/modules/in_ccs811_hdc1080.cpp +++ b/lighthub/modules/in_ccs811_hdc1080.cpp @@ -30,6 +30,7 @@ int in_ccs811::Setup() Serial.println("CCS811 Init"); Wire.begin(); //Inialize I2C Harware +Wire.setClock(4000); //It is recommended to check return status on .begin(), but it is not //required. diff --git a/platformio.ini b/platformio.ini index 57cf7a6..d9c934d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -28,6 +28,8 @@ default_envs = ; Arduino DUE + Ethernet shield Wiznet 5100 ; due-5100 +; Generic DUE + due ; Arduino DUE + Ethernet shield Wiznet 5500 ; due-5500 @@ -209,11 +211,59 @@ lib_deps = Adafruit NeoPixel https://github.com/anklimov/ArduinoOTA -[env:due-5100] + + [env:due-5100] + platform = atmelsam + framework = arduino + board = due + build_flags = !python get_build_flags.py due-5100 + lib_ignore = + ;DS2482_OneWire //UNCOMMENT for software 1-wire driver + DHT sensor library for ESPx + ESP_EEPROM + DMXSerial + DmxSimple + httpClient + ESPDMX + ESP-Dmx + WifiManager + Ethernet3 + NRFFlashStorage + WebServer + UIPEthernet + EEPROM + M5Stack + ;ArduinoOTA + lib_deps = + https://github.com/sebnil/DueFlashStorage + https://github.com/anklimov/Arduino-Temperature-Control-Library.git + https://github.com/anklimov/DS2482_OneWire + https://github.com/anklimov/DmxDue + ArduinoHttpClient + https://github.com/anklimov/aJson + https://github.com/anklimov/CmdArduino + https://github.com/anklimov/ModbusMaster + https://github.com/anklimov/Ethernet + https://github.com/knolleary/pubsubclient.git + https://github.com/anklimov/Artnet.git + FastLED@3.3.2 + SD + SdFat + Adafruit Unified Sensor + DHT sensor library + https://github.com/arcao/Syslog.git + Streaming + ClosedCube HDC1080 + SparkFun CCS811 Arduino Library@~1.0.7 + Adafruit NeoPixel + https://github.com/anklimov/ArduinoOTA + + +[env:due] platform = atmelsam framework = arduino board = due -build_flags = !python get_build_flags.py due-5100 +build_flags = !python get_build_flags.py due lib_ignore = ;DS2482_OneWire //UNCOMMENT for software 1-wire driver DHT sensor library for ESPx @@ -225,6 +275,7 @@ lib_ignore = ESP-Dmx WifiManager Ethernet3 + Ethernet2 NRFFlashStorage WebServer UIPEthernet @@ -240,7 +291,8 @@ lib_deps = https://github.com/anklimov/aJson https://github.com/anklimov/CmdArduino https://github.com/anklimov/ModbusMaster - https://github.com/anklimov/Ethernet + https://github.com/arduino-libraries/Ethernet.git + ;https://github.com/anklimov/Ethernet2.git https://github.com/knolleary/pubsubclient.git https://github.com/anklimov/Artnet.git FastLED@3.3.2