mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
dht_counter_disable
with_domoticz printex removed because of compilation errors
This commit is contained in:
@@ -151,9 +151,8 @@ platformio device monitor -b 115200
|
|||||||
* ESP_WIFI_AP=MYAP // esp wifi access point name
|
* ESP_WIFI_AP=MYAP // esp wifi access point name
|
||||||
* ESP_WIFI_PWD=MYPWD // esp wifi access point password
|
* ESP_WIFI_PWD=MYPWD // esp wifi access point password
|
||||||
* WIFI_MANAGER_DISABLE //Disable wifi manager for esp8266
|
* WIFI_MANAGER_DISABLE //Disable wifi manager for esp8266
|
||||||
* DHT_DISABLE //disable DHT Input support
|
* DHT_COUNTER_DISABLE //disable DHT, Counter, Uptime input support (for RAM savings on mega2560)
|
||||||
* RESTART_LAN_ON_MQTT_ERRORS //reinit LAN if many mqtt errors occured
|
* RESTART_LAN_ON_MQTT_ERRORS //reinit LAN if many mqtt errors occured
|
||||||
* WITH_STREAMING_LIB use streaming libriary for serial debug output otherwise use PrintEx library
|
|
||||||
* DEVICE_NAME short handy device name which is used instead of mac for download config http://{MY_CONFIG_SERVER}/{DEVICE_NAME}_config.json
|
* DEVICE_NAME short handy device name which is used instead of mac for download config http://{MY_CONFIG_SERVER}/{DEVICE_NAME}_config.json
|
||||||
* SYSLOG_ENABLE enable UDP SYSLOG support feature(under DEVELOPMENT) that must be configured through config file
|
* SYSLOG_ENABLE enable UDP SYSLOG support feature(under DEVELOPMENT) that must be configured through config file
|
||||||
|
|
||||||
@@ -176,10 +175,9 @@ platformio device monitor -b 115200
|
|||||||
* Defailt MQTT input topic: /myhome/in
|
* Defailt MQTT input topic: /myhome/in
|
||||||
* Default MQTT topic to publish device status: /myhome/s_out
|
* Default MQTT topic to publish device status: /myhome/s_out
|
||||||
* Default Alarm output topic /alarm
|
* Default Alarm output topic /alarm
|
||||||
* DHT support enabled
|
* DHT, Counter, Uptime support enabled
|
||||||
* Wifi manager for esp8266 enabled
|
* Wifi manager for esp8266 enabled
|
||||||
* RESTART_LAN_ON_MQTT_ERRORS disabled
|
* RESTART_LAN_ON_MQTT_ERRORS disabled
|
||||||
* WITH_STREAMING_LIB disabled
|
|
||||||
* DEVICE_NAME disabled
|
* DEVICE_NAME disabled
|
||||||
* SYSLOG_ENABLE disabled
|
* SYSLOG_ENABLE disabled
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,12 @@
|
|||||||
# export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
# export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
||||||
# export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
# export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
||||||
# export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
# export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
||||||
# export FLAGS="$FLAGS -DDHT_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DRESET_PIN=5"
|
# export FLAGS="$FLAGS -DRESET_PIN=5"
|
||||||
# export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
# export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
||||||
# export FLAGS="$FLAGS -DRESTART_LAN_ON_MQTT_ERRORS"
|
# export FLAGS="$FLAGS -DRESTART_LAN_ON_MQTT_ERRORS"
|
||||||
# export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
# export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
||||||
#export FLAGS="$FLAGS -DSYSLOG_ENABLE"
|
#export FLAGS="$FLAGS -DSYSLOG_ENABLE"
|
||||||
#export FLAGS="$FLAGS -DDEVICE_NAME=MYDEVICE"
|
#export FLAGS="$FLAGS -DDEVICE_NAME=MYDEVICE"
|
||||||
|
#export FLAGS="$FLAGS -DDHT_COUNTER_DISABLE"
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||||
echo $FLAGS
|
echo $FLAGS
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ e-mail anklimov@gmail.com
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
|
|
||||||
#ifndef DHT_DISABLE
|
#ifndef DHT_COUNTER_DISABLE
|
||||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||||
#include <DHTesp.h>
|
#include <DHTesp.h>
|
||||||
|
|
||||||
@@ -34,9 +34,9 @@ e-mail anklimov@gmail.com
|
|||||||
|
|
||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
|
|
||||||
|
#ifndef DHT_COUNTER_DISABLE
|
||||||
static volatile unsigned long nextPollMillisValue[5];
|
static volatile unsigned long nextPollMillisValue[5];
|
||||||
static volatile int nextPollMillisPin[5] = {0,0,0,0,0};
|
static volatile int nextPollMillisPin[5] = {0,0,0,0,0};
|
||||||
|
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
static volatile long counter_value[6];
|
static volatile long counter_value[6];
|
||||||
#endif
|
#endif
|
||||||
@@ -54,6 +54,9 @@ static short counter_irq_map[54];
|
|||||||
static long counter_value[54];
|
static long counter_value[54];
|
||||||
static int counters_count;
|
static int counters_count;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Input::Input(char * name) //Constructor
|
Input::Input(char * name) //Constructor
|
||||||
{
|
{
|
||||||
if (name)
|
if (name)
|
||||||
@@ -88,31 +91,24 @@ void Input::Parse()
|
|||||||
store = NULL;
|
store = NULL;
|
||||||
inType = 0;
|
inType = 0;
|
||||||
pin = 0;
|
pin = 0;
|
||||||
|
|
||||||
if (inputObj && (inputObj->type == aJson_Object)) {
|
if (inputObj && (inputObj->type == aJson_Object)) {
|
||||||
aJsonObject *s;
|
aJsonObject *s;
|
||||||
|
|
||||||
s = aJson.getObjectItem(inputObj, "T");
|
s = aJson.getObjectItem(inputObj, "T");
|
||||||
if (s) inType = static_cast<uint8_t>(s->valueint);
|
if (s) inType = static_cast<uint8_t>(s->valueint);
|
||||||
|
|
||||||
pin = static_cast<uint8_t>(atoi(inputObj->name));
|
pin = static_cast<uint8_t>(atoi(inputObj->name));
|
||||||
|
|
||||||
s = aJson.getObjectItem(inputObj, "S");
|
s = aJson.getObjectItem(inputObj, "S");
|
||||||
if (!s) {
|
if (!s) {
|
||||||
Serial.print(F("In: "));
|
debugSerial<<F("In: ")<<pin<<F("/")<<inType<<endl;
|
||||||
Serial.print(pin);
|
|
||||||
Serial.print(F("/"));
|
|
||||||
Serial.println(inType);
|
|
||||||
aJson.addNumberToObject(inputObj, "S", 0);
|
aJson.addNumberToObject(inputObj, "S", 0);
|
||||||
s = aJson.getObjectItem(inputObj, "S");
|
s = aJson.getObjectItem(inputObj, "S");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s) store = (inStore *) &s->valueint;
|
if (s) store = (inStore *) &s->valueint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Input::poll() {
|
int Input::poll() {
|
||||||
if (!isValid()) return -1;
|
if (!isValid()) return -1;
|
||||||
|
#ifndef DHT_COUNTER_DISABLE
|
||||||
if (inType & IN_DHT22)
|
if (inType & IN_DHT22)
|
||||||
dht22Poll();
|
dht22Poll();
|
||||||
else if (inType & IN_COUNTER)
|
else if (inType & IN_COUNTER)
|
||||||
@@ -122,8 +118,11 @@ int Input::poll() {
|
|||||||
else
|
else
|
||||||
contactPoll();
|
contactPoll();
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
|
contactPoll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DHT_COUNTER_DISABLE
|
||||||
void Input::counterPoll() {
|
void Input::counterPoll() {
|
||||||
if(nextPollTime()>millis())
|
if(nextPollTime()>millis())
|
||||||
return;
|
return;
|
||||||
@@ -166,7 +165,9 @@ void Input::counterPoll() {
|
|||||||
else
|
else
|
||||||
debugSerial<<F(" No emit data!");
|
debugSerial<<F(" No emit data!");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DHT_COUNTER_DISABLE
|
||||||
void Input::attachInterruptPinIrq(int realPin, int irq) {
|
void Input::attachInterruptPinIrq(int realPin, int irq) {
|
||||||
pinMode(realPin, INPUT);
|
pinMode(realPin, INPUT);
|
||||||
int real_irq;
|
int real_irq;
|
||||||
@@ -201,15 +202,15 @@ void Input::attachInterruptPinIrq(int realPin, int irq) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Input::dht22Poll() {
|
void Input::dht22Poll() {
|
||||||
#ifndef DHT_DISABLE
|
if (nextPollTime() > millis())
|
||||||
if(nextPollTime()>millis())
|
|
||||||
return;
|
return;
|
||||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||||
DHTesp dhtSensor;
|
DHTesp dhtSensor;
|
||||||
dhtSensor.setup(pin, DHTesp::DHT22);
|
dhtSensor.setup(pin, DHTesp::DHT22);
|
||||||
TempAndHumidity dhtSensorData = dhtSensor.getTempAndHumidity();
|
TempAndHumidity dhtSensorData = dhtSensor.getTempAndHumidity();
|
||||||
float temp = roundf(dhtSensorData.temperature*10)/10;
|
float temp = roundf(dhtSensorData.temperature * 10) / 10;
|
||||||
float humidity = roundf(dhtSensorData.humidity);
|
float humidity = roundf(dhtSensorData.humidity);
|
||||||
#else
|
#else
|
||||||
DHT dht(pin, DHT22);
|
DHT dht(pin, DHT22);
|
||||||
@@ -217,33 +218,35 @@ void Input::dht22Poll() {
|
|||||||
float humidity = dht.readHumidity();
|
float humidity = dht.readHumidity();
|
||||||
#endif
|
#endif
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
aJsonObject *idx = aJson.getObjectItem(inputObj, "idx");
|
debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") << humidity << F("%");
|
||||||
debugSerial<<F("IN:")<<pin<<F(" DHT22 type. T=")<<temp<<F("°C H=")<<humidity<<F("%");
|
|
||||||
if (emit && temp && humidity && temp == temp && humidity == humidity) {
|
if (emit && temp && humidity && temp == temp && humidity == humidity) {
|
||||||
char addrstr[100] = "";
|
char addrstr[100] = "";
|
||||||
if(idx&&idx->valuestring){//DOMOTICZ json format support
|
#ifdef WITH_DOMOTICZ
|
||||||
debugSerial<<endl<<idx->valuestring<<F(" Domoticz valstr:");
|
aJsonObject *idx = aJson.getObjectItem(inputObj, "idx");
|
||||||
char valstr[80];
|
if (idx && idx->valuestring) {//DOMOTICZ json format support
|
||||||
sprintf( valstr,"{\"command\":\"udevice\",\"idx\":%s,\"svalue\":\"%.1f;%.0f;0\"}",idx->valuestring,temp,humidity);
|
debugSerial << endl << idx->valuestring << F(" Domoticz valstr:");
|
||||||
debugSerial<<valstr;
|
char valstr[50];
|
||||||
|
sprintf(valstr, "{\"idx\":%s,\"svalue\":\"%.1f;%.0f;0\"}", idx->valuestring, temp, humidity);
|
||||||
|
debugSerial << valstr;
|
||||||
mqttClient.publish(emit->valuestring, valstr);
|
mqttClient.publish(emit->valuestring, valstr);
|
||||||
|
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||||
|
debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
char valstr[10];
|
char valstr[10];
|
||||||
strcat(addrstr, emit->valuestring);
|
strcat(addrstr, emit->valuestring);
|
||||||
strcat(addrstr, "T");
|
strcat(addrstr, "T");
|
||||||
printFloatValueToStr(temp, valstr);
|
printFloatValueToStr(temp, valstr);
|
||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
addrstr[strlen(addrstr) - 1] = 'H';
|
addrstr[strlen(addrstr) - 1] = 'H';
|
||||||
printFloatValueToStr(humidity, valstr);
|
printFloatValueToStr(humidity, valstr);
|
||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
}
|
|
||||||
|
|
||||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||||
debugSerial<<" NextPollMillis="<<nextPollTime()<<endl;
|
debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
||||||
} else
|
} else
|
||||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT / 3);
|
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT / 3);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long Input::nextPollTime() const {
|
unsigned long Input::nextPollTime() const {
|
||||||
@@ -258,6 +261,7 @@ unsigned long Input::nextPollTime() const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Input::setNextPollTime(unsigned long pollTime) {
|
void Input::setNextPollTime(unsigned long pollTime) {
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
if (nextPollMillisPin[i] == pin) {
|
if (nextPollMillisPin[i] == pin) {
|
||||||
@@ -271,6 +275,50 @@ void Input::setNextPollTime(unsigned long pollTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Input::uptimePoll() {
|
||||||
|
if(nextPollTime()>millis())
|
||||||
|
return;
|
||||||
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
|
if (emit) {
|
||||||
|
char valstr[11];
|
||||||
|
// printUlongValueToStr(valstr,millis());
|
||||||
|
printUlongValueToStr(valstr,millis());
|
||||||
|
mqttClient.publish(emit->valuestring, valstr);
|
||||||
|
}
|
||||||
|
setNextPollTime(millis() +UPTIME_POLL_DELAY_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::onCounterChanged(int i) {
|
||||||
|
#if defined(__SAM3X8E__)
|
||||||
|
counter_value[counter_irq_map[i]]++;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__AVR__)
|
||||||
|
counter_value[i]++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::onCounterChanged0() {
|
||||||
|
onCounterChanged(0);
|
||||||
|
}
|
||||||
|
void Input::onCounterChanged1() {
|
||||||
|
onCounterChanged(1);
|
||||||
|
}
|
||||||
|
void Input::onCounterChanged2() {
|
||||||
|
onCounterChanged(2);
|
||||||
|
}
|
||||||
|
void Input::onCounterChanged3() {
|
||||||
|
onCounterChanged(3);
|
||||||
|
}
|
||||||
|
void Input::onCounterChanged4() {
|
||||||
|
onCounterChanged(4);
|
||||||
|
}
|
||||||
|
void Input::onCounterChanged5() {
|
||||||
|
onCounterChanged(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Input::contactPoll() {
|
void Input::contactPoll() {
|
||||||
@@ -312,85 +360,54 @@ void Input::contactPoll() {
|
|||||||
store->bounce = SAME_STATE_ATTEMPTS;
|
store->bounce = SAME_STATE_ATTEMPTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::uptimePoll() {
|
|
||||||
if(nextPollTime()>millis())
|
|
||||||
return;
|
void Input::onContactChanged(int newValue) {
|
||||||
|
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
||||||
|
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||||
|
aJsonObject *scmd = aJson.getObjectItem(inputObj, "scmd");
|
||||||
|
aJsonObject *rcmd = aJson.getObjectItem(inputObj, "rcmd");
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
if (emit) {
|
if (emit) {
|
||||||
char valstr[11];
|
#ifdef WITH_DOMOTICZ
|
||||||
// printUlongValueToStr(valstr,millis());
|
aJsonObject *idx = aJson.getObjectItem(inputObj, "idx");
|
||||||
printUlongValueToStr(valstr,millis());
|
if (idx->valuestring) {
|
||||||
mqttClient.publish(emit->valuestring, valstr);
|
debugSerial << endl << idx->valuestring << F(" Domoticz valstr:");
|
||||||
|
char valstr[80];
|
||||||
|
char *switchCmd;
|
||||||
|
(newValue)? sprintf(valstr, "{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"On\"}", idx->valuestring)
|
||||||
|
: sprintf(valstr,"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",idx->valuestring);
|
||||||
|
debugSerial << valstr;
|
||||||
|
mqttClient.publish(emit->valuestring, valstr);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
if (newValue) { //send set command
|
||||||
|
if (!scmd) mqttClient.publish(emit->valuestring, "ON", true);
|
||||||
|
else if (strlen(scmd->valuestring))
|
||||||
|
mqttClient.publish(emit->valuestring, scmd->valuestring, true);
|
||||||
|
} else { //send reset command
|
||||||
|
if (!rcmd) mqttClient.publish(emit->valuestring, "OFF", true);
|
||||||
|
else if (strlen(rcmd->valuestring))mqttClient.publish(emit->valuestring, rcmd->valuestring, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setNextPollTime(millis() +UPTIME_POLL_DELAY_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Input::onContactChanged(int val)
|
if (item) {
|
||||||
{
|
Item it(item->valuestring);
|
||||||
Serial.print(F("IN:")); Serial.print(pin);Serial.print(F("="));Serial.println(val);
|
if (it.isValid()) {
|
||||||
aJsonObject * item = aJson.getObjectItem(inputObj,"item");
|
if (newValue) { //send set command
|
||||||
aJsonObject * scmd = aJson.getObjectItem(inputObj,"scmd");
|
if (!scmd) it.Ctrl(CMD_ON, 0, NULL, true);
|
||||||
aJsonObject * rcmd = aJson.getObjectItem(inputObj,"rcmd");
|
else if (strlen(scmd->valuestring))
|
||||||
aJsonObject * emit = aJson.getObjectItem(inputObj,"emit");
|
it.Ctrl(scmd->valuestring, true);
|
||||||
|
} else { //send reset command
|
||||||
if (emit)
|
if (!rcmd) it.Ctrl(CMD_OFF, 0, NULL, true);
|
||||||
{
|
else if (strlen(rcmd->valuestring))
|
||||||
|
it.Ctrl(rcmd->valuestring, true);
|
||||||
if (val)
|
|
||||||
{ //send set command
|
|
||||||
if (!scmd) mqttClient.publish(emit->valuestring,"ON",true); else if (strlen(scmd->valuestring)) mqttClient.publish(emit->valuestring,scmd->valuestring,true);
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{ //send reset command
|
}
|
||||||
if (!rcmd) mqttClient.publish(emit->valuestring,"OFF",true); else if (strlen(rcmd->valuestring)) mqttClient.publish(emit->valuestring,rcmd->valuestring,true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item)
|
|
||||||
{
|
|
||||||
Item it(item->valuestring);
|
|
||||||
if (it.isValid())
|
|
||||||
{
|
|
||||||
if (val)
|
|
||||||
{ //send set command
|
|
||||||
if (!scmd) it.Ctrl(CMD_ON,0,NULL,true); else if (strlen(scmd->valuestring)) it.Ctrl(scmd->valuestring,true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ //send reset command
|
|
||||||
if (!rcmd) it.Ctrl(CMD_OFF,0,NULL,true); else if (strlen(rcmd->valuestring)) it.Ctrl(rcmd->valuestring,true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::onCounterChanged(int i) {
|
|
||||||
#if defined(__SAM3X8E__)
|
|
||||||
counter_value[counter_irq_map[i]]++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__AVR__)
|
|
||||||
counter_value[i]++;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Input::onCounterChanged0() {
|
|
||||||
onCounterChanged(0);
|
|
||||||
}
|
|
||||||
void Input::onCounterChanged1() {
|
|
||||||
onCounterChanged(1);
|
|
||||||
}
|
|
||||||
void Input::onCounterChanged2() {
|
|
||||||
onCounterChanged(2);
|
|
||||||
}
|
|
||||||
void Input::onCounterChanged3() {
|
|
||||||
onCounterChanged(3);
|
|
||||||
}
|
|
||||||
void Input::onCounterChanged4() {
|
|
||||||
onCounterChanged(4);
|
|
||||||
}
|
|
||||||
void Input::onCounterChanged5() {
|
|
||||||
onCounterChanged(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Input::printUlongValueToStr(char *valstr, unsigned long value) {
|
void Input::printUlongValueToStr(char *valstr, unsigned long value) {
|
||||||
char buf[11];
|
char buf[11];
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
boolean isValid();
|
boolean isValid();
|
||||||
|
|
||||||
void onContactChanged(int val);
|
void onContactChanged(int newValue);
|
||||||
|
|
||||||
int poll();
|
int poll();
|
||||||
|
|
||||||
|
|||||||
@@ -204,21 +204,13 @@ void mqttCallback(char *topic, byte *payload, unsigned int length) {
|
|||||||
|
|
||||||
void printIPAddress(IPAddress ipAddress) {
|
void printIPAddress(IPAddress ipAddress) {
|
||||||
for (byte i = 0; i < 4; i++)
|
for (byte i = 0; i < 4; i++)
|
||||||
#ifdef WITH_STREAMING_LIB
|
|
||||||
(i < 3) ? debugSerial << _DEC(ipAddress[i]) << F(".") : debugSerial << _DEC(ipAddress[i]) << F(", ");
|
(i < 3) ? debugSerial << _DEC(ipAddress[i]) << F(".") : debugSerial << _DEC(ipAddress[i]) << F(", ");
|
||||||
#else
|
|
||||||
(i < 3) ? debugSerial << (ipAddress[i]) << F(".") : debugSerial << (ipAddress[i])<<F(", ");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printMACAddress() {
|
void printMACAddress() {
|
||||||
debugSerial<<F("Configured MAC:");
|
debugSerial<<F("Configured MAC:");
|
||||||
for (byte i = 0; i < 6; i++)
|
for (byte i = 0; i < 6; i++)
|
||||||
#ifdef WITH_STREAMING_LIB
|
|
||||||
(i < 5) ?debugSerial<<_HEX(mac[i])<<F(":"):debugSerial<<_HEX(mac[i])<<endl;
|
(i < 5) ?debugSerial<<_HEX(mac[i])<<F(":"):debugSerial<<_HEX(mac[i])<<endl;
|
||||||
#else
|
|
||||||
(i < 5) ?debugSerial<<hex <<(mac[i])<<F(":"):debugSerial<<hex<<(mac[i])<<endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreState() {
|
void restoreState() {
|
||||||
@@ -440,17 +432,14 @@ void onInitialStateInitLAN() {
|
|||||||
if(!wifiInitialized) {
|
if(!wifiInitialized) {
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
debugSerial<<F("WIFI AP/Password:"));
|
debugSerial<<F("WIFI AP/Password:")<<QUOTE(ESP_WIFI_AP)<<F("/")<<QUOTE(ESP_WIFI_PWD);
|
||||||
debugSerial<<QUOTE(ESP_WIFI_AP));
|
|
||||||
debugSerial<<F("/"));
|
|
||||||
debugSerial<<QUOTE(ESP_WIFI_PWD));
|
|
||||||
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
||||||
|
|
||||||
int wifi_connection_wait = 10000;
|
int wifi_connection_wait = 10000;
|
||||||
while (WiFi.status() != WL_CONNECTED && wifi_connection_wait > 0) {
|
while (WiFi.status() != WL_CONNECTED && wifi_connection_wait > 0) {
|
||||||
delay(500);
|
delay(500);
|
||||||
wifi_connection_wait -= 500;
|
wifi_connection_wait -= 500;
|
||||||
debugSerial<<".");
|
debugSerial<<".";
|
||||||
}
|
}
|
||||||
wifiInitialized = true;
|
wifiInitialized = true;
|
||||||
}
|
}
|
||||||
@@ -458,12 +447,10 @@ void onInitialStateInitLAN() {
|
|||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
debugSerial<<F("WiFi connected. IP address: ");
|
debugSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP();
|
||||||
debugSerial<<WiFi.localIP();
|
|
||||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
|
||||||
debugSerial<<F("Problem with WiFi!");
|
debugSerial<<F("Problem with WiFi!");
|
||||||
nextLanCheckTime = millis() + DHCP_RETRY_INTERVAL/5;
|
nextLanCheckTime = millis() + DHCP_RETRY_INTERVAL/5;
|
||||||
}
|
}
|
||||||
@@ -1166,10 +1153,10 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
#else
|
#else
|
||||||
debugSerial<<F("\n(+)OWIRE");
|
debugSerial<<F("\n(+)OWIRE");
|
||||||
#endif
|
#endif
|
||||||
#ifndef DHT_DISABLE
|
#ifndef DHT_COUNTER_DISABLE
|
||||||
debugSerial<<F("\n(+)DHT");
|
debugSerial<<F("\n(+)DHT COUNTER");
|
||||||
#else
|
#else
|
||||||
debugSerial<<F("\n(-)DHT");
|
debugSerial<<F("\n(-)DHT COUNTER");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SD_CARD_INSERTED
|
#ifdef SD_CARD_INSERTED
|
||||||
|
|||||||
@@ -115,7 +115,6 @@
|
|||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
#undef _dmxin
|
#undef _dmxin
|
||||||
#undef _modbus
|
#undef _modbus
|
||||||
#define WITH_STREAMING_LIB
|
|
||||||
|
|
||||||
#ifndef DMX_DISABLE
|
#ifndef DMX_DISABLE
|
||||||
#define _espdmx
|
#define _espdmx
|
||||||
@@ -123,6 +122,9 @@
|
|||||||
#define modbusSerial Serial1
|
#define modbusSerial Serial1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _dmxout
|
#ifndef _dmxout
|
||||||
#undef _artnet
|
#undef _artnet
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,12 +24,8 @@ e-mail anklimov@gmail.com
|
|||||||
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)
|
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#ifdef WITH_STREAMING_LIB
|
#include "options.h"
|
||||||
#include "Streaming.h"
|
#include "Streaming.h"
|
||||||
#else
|
|
||||||
#include "PrintEx.h"
|
|
||||||
using namespace ios;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void PrintBytes(uint8_t* addr, uint8_t count, bool newline);
|
void PrintBytes(uint8_t* addr, uint8_t count, bool newline);
|
||||||
void SetBytes(uint8_t* addr, uint8_t count, char * out);
|
void SetBytes(uint8_t* addr, uint8_t count, char * out);
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
[platformio]
|
[platformio]
|
||||||
src_dir = lighthub
|
src_dir = lighthub
|
||||||
env_default =
|
env_default =
|
||||||
; megaatmega2560
|
megaatmega2560
|
||||||
; megaatmega2560-net
|
; megaatmega2560-net
|
||||||
; due
|
; due
|
||||||
esp8266
|
; esp8266
|
||||||
; esp32
|
; esp32
|
||||||
; megaatmega2560-5500
|
; megaatmega2560-5500
|
||||||
; due-5500
|
; due-5500
|
||||||
@@ -22,6 +22,8 @@ env_default =
|
|||||||
|
|
||||||
;build_dir = !sh pioenvs.sh ${platformio.env_default}
|
;build_dir = !sh pioenvs.sh ${platformio.env_default}
|
||||||
;libdeps_dir = !sh piolibdeps.sh ${platformio.env_default}
|
;libdeps_dir = !sh piolibdeps.sh ${platformio.env_default}
|
||||||
|
;build_dir = /tmp/pioenvs
|
||||||
|
;libdeps_dir = /tmp/piolibdeps
|
||||||
|
|
||||||
[env:esp32]
|
[env:esp32]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
@@ -44,7 +46,6 @@ lib_deps =
|
|||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
DHT sensor library
|
DHT sensor library
|
||||||
Streaming
|
Streaming
|
||||||
https://github.com/Chris--A/PrintEx.git
|
|
||||||
|
|
||||||
[env:stm32]
|
[env:stm32]
|
||||||
platform = ststm32
|
platform = ststm32
|
||||||
@@ -145,7 +146,6 @@ lib_deps =
|
|||||||
DHT sensor library
|
DHT sensor library
|
||||||
WifiManager
|
WifiManager
|
||||||
https://github.com/arcao/Syslog.git
|
https://github.com/arcao/Syslog.git
|
||||||
https://github.com/livello/PrintEx.git#is-select-redecl
|
|
||||||
Streaming
|
Streaming
|
||||||
|
|
||||||
[env:megaatmega2560-net]
|
[env:megaatmega2560-net]
|
||||||
@@ -201,8 +201,6 @@ lib_deps =
|
|||||||
DHT sensor library
|
DHT sensor library
|
||||||
https://github.com/arcao/Syslog.git
|
https://github.com/arcao/Syslog.git
|
||||||
Streaming
|
Streaming
|
||||||
; PrintEx
|
|
||||||
https://github.com/livello/PrintEx.git#is-select-redecl
|
|
||||||
|
|
||||||
[env:controllino]
|
[env:controllino]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
@@ -228,3 +226,4 @@ lib_deps =
|
|||||||
EEPROM
|
EEPROM
|
||||||
Adafruit Unified Sensor
|
Adafruit Unified Sensor
|
||||||
DHT sensor library
|
DHT sensor library
|
||||||
|
Streaming
|
||||||
|
|||||||
Reference in New Issue
Block a user