MCP23017 inputs

STATUSLED
Compilation for all platforms
WIFI_ENABLE option to allow wired connection for ESP
Modbus, Syslog for ESP
This commit is contained in:
2020-07-12 21:56:05 +03:00
parent 3c38e151e1
commit 832b469103
34 changed files with 27945 additions and 26281 deletions

View File

@@ -4,3 +4,4 @@
-DMODBUS_DIMMER_PARAM=SERIAL_8E1 -DMODBUS_DIMMER_PARAM=SERIAL_8E1
-DARTNET_ENABLE -DARTNET_ENABLE
-DOTA -DOTA
-DSTATUSLED

View File

@@ -1 +1,3 @@
#NO special flags #NO special flags
-DSTATUSLED
-DSYSLOG_ENABLE

View File

@@ -1,3 +1,5 @@
-DWiz5500 -DWiz5500
-DARTNET_ENABLE -DARTNET_ENABLE
-DDMX_SMOOTH -DDMX_SMOOTH
-DSTATUSLED
-DSYSLOG_ENABLE

View File

@@ -1,3 +1,4 @@
-DWIFI_ENABLE
-DDMX_DISABLE -DDMX_DISABLE
-DMODBUS_DISABLE -DMODBUS_DISABLE
#-DOWIRE_DISABLE #-DOWIRE_DISABLE
@@ -7,3 +8,4 @@
-DAC_DISABLE -DAC_DISABLE
#-DM5STACK #-DM5STACK
-DOTA -DOTA
-DSYSLOG_ENABLE

View File

@@ -1,4 +1,6 @@
-DWIFI_ENABLE
-DMODBUS_DISABLE -DMODBUS_DISABLE
#-DCOUNTER_DISABLE #-DCOUNTER_DISABLE
-DOTA -DOTA
-std=gnu++11 -std=gnu++11
-DSYSLOG_ENABLE

View File

@@ -6,3 +6,5 @@
-DOTA -DOTA
-DSYSLOG_ENABLE -DSYSLOG_ENABLE
-DWiz5500 -DWiz5500
-DSTATUSLED
-DMCP23017

View File

@@ -1,3 +1,4 @@
-DWIFI_ENABLE
-DDMX_DISABLE -DDMX_DISABLE
-DMODBUS_DISABLE -DMODBUS_DISABLE
-DOWIRE_DISABLE -DOWIRE_DISABLE
@@ -6,3 +7,4 @@
-DSPILED_DISABLE -DSPILED_DISABLE
-DAC_DISABLE -DAC_DISABLE
-DM5STACK -DM5STACK
-DSYSLOG_ENABLE

View File

@@ -1,2 +1,3 @@
-DMODBUS_DIMMER_PARAM=SERIAL_8E1 -DMODBUS_DIMMER_PARAM=SERIAL_8E1
-DAVR_DMXOUT_PIN=18 -DAVR_DMXOUT_PIN=18
-DSYSLOG_ENABLE

View File

@@ -1,3 +1,4 @@
-DWiz5500 -DWiz5500
-DMODBUS_DIMMER_PARAM=SERIAL_8E1 -DMODBUS_DIMMER_PARAM=SERIAL_8E1
-DAVR_DMXOUT_PIN=18 -DAVR_DMXOUT_PIN=18
-DSYSLOG_ENABLE

View File

@@ -9,3 +9,5 @@
-DCSSHDC_DISABLE -DCSSHDC_DISABLE
-DSPILED_DISABLE -DSPILED_DISABLE
-DAC_DISABLE -DAC_DISABLE
-DSYSLOG_ENABLE
-DMBUS_DISABLE

View File

@@ -1,5 +1,6 @@
-DDMX_DISABLE -DDMX_DISABLE
-DMODBUS_DISABLE -DMODBUS_DISABLE
-DMBUS_DISABLE
-DOWIRE_DISABLE -DOWIRE_DISABLE
-DDHT_DISABLE -DDHT_DISABLE
-DCOUNTER_DISABLE -DCOUNTER_DISABLE

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -32,6 +32,11 @@ e-mail anklimov@gmail.com
#endif #endif
#endif #endif
#ifdef MCP23017
#include "Adafruit_MCP23017.h"
Adafruit_MCP23017 mcp;
#endif
extern PubSubClient mqttClient; extern PubSubClient mqttClient;
extern aJsonObject *root; extern aJsonObject *root;
extern int8_t ethernetIdleCount; extern int8_t ethernetIdleCount;
@@ -89,7 +94,7 @@ Input::Input(int pin)
boolean Input::isValid () boolean Input::isValid ()
{ {
return (pin && store); return (store);
} }
void Input::Parse() void Input::Parse()
@@ -115,21 +120,7 @@ void Input::Parse()
void Input::setup() void Input::setup()
{ {
if (!isValid() || (!root)) return; if (!isValid() || (!root)) return;
/*
#ifndef CSSHDC_DISABLE
if (inType == IN_CCS811)
{
in_ccs811 ccs811(this);
ccs811.Setup();
}
else if (inType == IN_HDC1080)
{
in_hdc1080 hdc1080(this);
hdc1080.Setup();
}
// TODO rest types setup
#endif
*/
store->aslong=0; store->aslong=0;
uint8_t inputPinMode = INPUT; //if IN_ACTIVE_HIGH uint8_t inputPinMode = INPUT; //if IN_ACTIVE_HIGH
switch (inType) switch (inType)
@@ -145,6 +136,24 @@ switch (inType)
store->state=IS_IDLE; store->state=IS_IDLE;
break; break;
#ifdef MCP23017
case IN_I2C | IN_PUSH_ON:
case IN_I2C | IN_PUSH_TOGGLE :
inputPinMode = INPUT_PULLUP;
case IN_I2C | IN_PUSH_ON | IN_ACTIVE_HIGH:
case IN_I2C | IN_PUSH_TOGGLE | IN_ACTIVE_HIGH:
mcp.begin();
mcp.pinMode(pin, INPUT);
if (inputPinMode == INPUT_PULLUP) mcp.pullUp(0, HIGH); // turn on a 100K pullup internally
store->state=IS_IDLE;
break;
#endif
case IN_ANALOG: case IN_ANALOG:
inputPinMode = INPUT_PULLUP; inputPinMode = INPUT_PULLUP;
@@ -194,6 +203,10 @@ switch (cause) {
case IN_PUSH_ON | IN_ACTIVE_HIGH: case IN_PUSH_ON | IN_ACTIVE_HIGH:
case IN_PUSH_TOGGLE : case IN_PUSH_TOGGLE :
case IN_PUSH_TOGGLE | IN_ACTIVE_HIGH: case IN_PUSH_TOGGLE | IN_ACTIVE_HIGH:
case IN_I2C | IN_PUSH_ON:
case IN_I2C | IN_PUSH_ON | IN_ACTIVE_HIGH:
case IN_I2C | IN_PUSH_TOGGLE :
case IN_I2C | IN_PUSH_TOGGLE | IN_ACTIVE_HIGH:
contactPoll(cause); contactPoll(cause);
break; break;
case IN_ANALOG: case IN_ANALOG:
@@ -667,8 +680,12 @@ void Input::contactPoll(short cause) {
else inputOnLevel = LOW; else inputOnLevel = LOW;
#ifdef MCP23017
if (inType & IN_I2C)
currentInputState = (mcp.digitalRead(pin) == inputOnLevel);
else
#endif
currentInputState = (digitalRead(pin) == inputOnLevel); currentInputState = (digitalRead(pin) == inputOnLevel);
switch (store->state) //Timer based transitions switch (store->state) //Timer based transitions
{ {
case IS_PRESSED: case IS_PRESSED:

View File

@@ -24,6 +24,7 @@ e-mail anklimov@gmail.com
#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_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 #define IN_ANALOG 64 // Analog input
#define IN_RE 32 // Rotary Encoder (for further use) #define IN_RE 32 // Rotary Encoder (for further use)
#define IN_I2C 128 // MCP23017
#define IN_PUSH_ON 0 // PUSH - ON, Release - OFF (ovverrided by pcmd/rcmd) - DEFAULT #define IN_PUSH_ON 0 // PUSH - ON, Release - OFF (ovverrided by pcmd/rcmd) - DEFAULT
#define IN_PUSH_TOGGLE 1 // Used for push buttons. Every physicall push toggle logical switch on/off. Toggle on leading edge #define IN_PUSH_TOGGLE 1 // Used for push buttons. Every physicall push toggle logical switch on/off. Toggle on leading edge

View File

@@ -1457,7 +1457,7 @@ bool send = isNotRetainingStatus() ;
} }
#endif #endif
#ifdef _modbus #ifndef MODBUS_DISABLE
case CH_MODBUS: case CH_MODBUS:
modbusDimmerSet(Par[0]); modbusDimmerSet(Par[0]);
break; break;
@@ -1540,7 +1540,7 @@ bool send = isNotRetainingStatus() ;
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl; debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
break; break;
} }
#ifdef _modbus #ifndef MODBUS_DISABLE
case CH_VC: case CH_VC:
VacomSetFan(Par[0], cmd); VacomSetFan(Par[0], cmd);
break; break;
@@ -1703,7 +1703,7 @@ POLL 2101x10
[22:27:29] => poll: 0A 03 08 34 00 0A 87 18 [22:27:29] => poll: 0A 03 08 34 00 0A 87 18
*/ */
#ifdef _modbus #ifndef MODBUS_DISABLE
int Item::modbusDimmerSet(uint16_t value) int Item::modbusDimmerSet(uint16_t value)
{ {
switch (getCmd()) switch (getCmd())

View File

@@ -67,55 +67,45 @@ PWM Out
#include "main.h" #include "main.h"
#ifdef WIFI_ENABLE
WiFiClient ethClient;
#if not defined(WIFI_MANAGER_DISABLE)
WiFiManager wifiManager;
#endif
#else
#include <Dhcp.h> #include <Dhcp.h>
EthernetClient ethClient;
#endif
#if defined(OTA) #if defined(OTA)
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
#endif #endif
#if defined(__SAM3X8E__) #if defined(__SAM3X8E__)
DueFlashStorage EEPROM; DueFlashStorage EEPROM;
EthernetClient ethClient;
#endif
#if defined(ARDUINO_ARCH_AVR)
EthernetClient ethClient;
#endif
#ifdef ARDUINO_ARCH_ESP8266
WiFiClient ethClient;
#if not defined(WIFI_MANAGER_DISABLE)
WiFiManager wifiManager;
#endif
#endif #endif
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
WiFiClient ethClient;
NRFFlashStorage EEPROM; NRFFlashStorage EEPROM;
#if not defined(WIFI_MANAGER_DISABLE)
WiFiManager wifiManager;
#endif
#endif #endif
#ifdef ARDUINO_ARCH_STM32 #ifdef ARDUINO_ARCH_STM32
EthernetClient ethClient;
NRFFlashStorage EEPROM; NRFFlashStorage EEPROM;
#endif #endif
#ifdef NRF5 #ifdef NRF5
NRFFlashStorage EEPROM; NRFFlashStorage EEPROM;
EthernetClient ethClient;
#endif #endif
#ifdef SYSLOG_ENABLE #ifdef SYSLOG_ENABLE
#include <Syslog.h> #include <Syslog.h>
EthernetUDP udpSyslogClient; #ifndef WIFI_ENABLE
EthernetUDP udpSyslogClient;
#else
WiFiUDP udpSyslogClient;
#endif
Syslog udpSyslog(udpSyslogClient, SYSLOG_PROTO_BSD); Syslog udpSyslog(udpSyslogClient, SYSLOG_PROTO_BSD);
unsigned long nextSyslogPingTime; unsigned long nextSyslogPingTime;
static char syslogDeviceHostname[16]; static char syslogDeviceHostname[16];
@@ -149,7 +139,7 @@ aJsonObject *items = NULL;
aJsonObject *inputs = NULL; aJsonObject *inputs = NULL;
aJsonObject *mqttArr = NULL; aJsonObject *mqttArr = NULL;
#ifndef MODBUS_DISABLE #ifdef _modbus
aJsonObject *modbusObj = NULL; aJsonObject *modbusObj = NULL;
#endif #endif
#ifdef _owire #ifdef _owire
@@ -176,7 +166,7 @@ bool configLoaded = false;
int8_t ethernetIdleCount =0; int8_t ethernetIdleCount =0;
int8_t configLocked = 0; int8_t configLocked = 0;
#ifdef _modbus #if defined (_modbus)
ModbusMaster node; ModbusMaster node;
#endif #endif
@@ -239,7 +229,7 @@ debugSerial<<F("Deleting conf. RAM was:")<<freeRam();
#ifdef _owire #ifdef _owire
owArr = NULL; owArr = NULL;
#endif #endif
#ifndef MODBUS_DISABLE #ifdef _modbus
modbusObj = NULL; modbusObj = NULL;
#endif #endif
debugSerial<<F(" is ")<<freeRam()<<endl; debugSerial<<F(" is ")<<freeRam()<<endl;
@@ -417,7 +407,7 @@ lan_status lanLoop() {
{ {
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) #if defined(WIFI_ENABLE)
if (WiFi.status() != WL_CONNECTED) if (WiFi.status() != WL_CONNECTED)
{ {
wifiInitialized=false; wifiInitialized=false;
@@ -731,7 +721,7 @@ void setupOTA(void)
void onInitialStateInitLAN() { void onInitialStateInitLAN() {
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) #if defined(WIFI_ENABLE)
#if defined(WIFI_MANAGER_DISABLE) #if defined(WIFI_MANAGER_DISABLE)
if(WiFi.status() != WL_CONNECTED) { if(WiFi.status() != WL_CONNECTED) {
WiFi.mode(WIFI_STA); // ESP 32 - WiFi.disconnect(); instead WiFi.mode(WIFI_STA); // ESP 32 - WiFi.disconnect(); instead
@@ -782,7 +772,7 @@ wifiManager.setTimeout(30);
#endif #endif
*/ */
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) #if defined(WIFI_ENABLE)
if (WiFi.status() == WL_CONNECTED) { if (WiFi.status() == WL_CONNECTED) {
infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl; infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
lanStatus = HAVE_IP_ADDRESS;//1; lanStatus = HAVE_IP_ADDRESS;//1;
@@ -1073,7 +1063,7 @@ void printConfigSummary() {
printBool(items); printBool(items);
infoSerial<<F("\ninputs "); infoSerial<<F("\ninputs ");
printBool(inputs); printBool(inputs);
#ifndef MODBUS_DISABLE #ifdef _modbus
infoSerial<<F("\nmodbus "); infoSerial<<F("\nmodbus ");
printBool(modbusObj); printBool(modbusObj);
#endif #endif
@@ -1397,7 +1387,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
} }
#endif #endif
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32) || defined (NRF5) //|| defined(ARDUINO_ARCH_ESP32) //|| defined(ARDUINO_ARCH_ESP8266) #if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32) || defined (NRF5) //|| defined(ARDUINO_ARCH_ESP32) //|| defined(ARDUINO_ARCH_ESP8266)
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) #if defined(WIFI_ENABLE)
WiFiClient configEthClient; WiFiClient configEthClient;
#else #else
EthernetClient configEthClient; EthernetClient configEthClient;
@@ -1561,7 +1551,7 @@ void setup_main() {
ArtnetSetup(); ArtnetSetup();
#endif #endif
#if (defined(ARDUINO_ARCH_ESP8266) or defined(ARDUINO_ARCH_ESP32)) and not defined(WIFI_MANAGER_DISABLE) #if defined(WIFI_ENABLE) and not defined(WIFI_MANAGER_DISABLE)
// WiFiManager wifiManager; // WiFiManager wifiManager;
wifiManager.setTimeout(180); wifiManager.setTimeout(180);
@@ -1612,7 +1602,7 @@ void printFirmwareVersionAndBuildOptions() {
infoSerial<<F("\n(-)DMX"); infoSerial<<F("\n(-)DMX");
#endif #endif
#ifndef MODBUS_DISABLE #ifdef _modbus
infoSerial<<F("\n(+)MODBUS"); infoSerial<<F("\n(+)MODBUS");
#else #else
infoSerial<<F("\n(-)MODBUS"); infoSerial<<F("\n(-)MODBUS");
@@ -1748,7 +1738,7 @@ if (!isMacValid) {
mac[0]&=0xFE; mac[0]&=0xFE;
mac[0]|=2; mac[0]|=2;
#elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) #elif defined(WIFI_ENABLE)
//Using original MPU MAC //Using original MPU MAC
WiFi.begin(); WiFi.begin();
WiFi.macAddress(mac); WiFi.macAddress(mac);

View File

@@ -23,15 +23,15 @@
#include <FS.h> //this needs to be first, or it all crashes and burns... #include <FS.h> //this needs to be first, or it all crashes and burns...
//#include "SPIFFS.h" //#include "SPIFFS.h"
#include <ESP_EEPROM.h> #include <ESP_EEPROM.h>
#include <ESP8266HTTPClient.h> //#include <ESP8266HTTPClient.h>
//#include <ArduinoHttpClient.h> //#include <ArduinoHttpClient.h>
//#include "HttpClient.h" //#include "HttpClient.h"
#include <WiFiManager.h> //#include <WiFiManager.h>
#include <DNSServer.h> //#include <DNSServer.h>
#include <ESP8266WebServer.h> //#include <ESP8266WebServer.h>
#include <ESP8266WiFi.h> //#include <ESP8266WiFi.h>
#include <user_interface.h> #include <user_interface.h>
#define Ethernet WiFi //#define Ethernet WiFi
#endif #endif
#if defined ARDUINO_ARCH_ESP32 #if defined ARDUINO_ARCH_ESP32
@@ -41,15 +41,15 @@
#include <NRFFlashStorage.h> #include <NRFFlashStorage.h>
//#include "HttpClient.h" //#include "HttpClient.h"
//#include <ArduinoHttpClient.h> //#include <ArduinoHttpClient.h>
#include <HTTPClient.h> //#include <HTTPClient.h>
#include <WiFi.h> //#include <WiFi.h>
#include <WiFiClient.h> //#include <WiFiClient.h>
#include <WiFiClientSecure.h> //#include <WiFiClientSecure.h>
#include <WebServer.h> //#include <WebServer.h>
#include <WiFiManager.h> //#include <WiFiManager.h>
#include <DNSServer.h> //include <DNSServer.h>
#define Ethernet WiFi //#define Ethernet WiFi
#endif #endif
#ifdef NRF5 #ifdef NRF5
@@ -122,7 +122,7 @@ extern Streamlog debugSerial;
#include "DallasTemperature.h" #include "DallasTemperature.h"
#endif #endif
#ifndef MODBUS_DISABLE #ifdef _modbus
#include <ModbusMaster.h> #include <ModbusMaster.h>
#endif #endif
@@ -138,13 +138,29 @@ extern Streamlog debugSerial;
#include "dmx.h" #include "dmx.h"
#endif #endif
#ifdef WIFI_ENABLE
#ifdef Wiz5500 #if defined(ARDUINO_ARCH_ESP32)
#include <Ethernet2.h> #include <WiFi.h>
#else #include <HTTPClient.h>
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(NRF5) #include <WiFiClient.h>
#include <Ethernet.h> #include <WiFiClientSecure.h>
#endif #include <WiFiManager.h>
#include <WebServer.h>
#else
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiManager.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#endif
#define Ethernet WiFi
#else //Wired connection
#ifdef Wiz5500
#include <Ethernet2.h>
#else
#include <Ethernet.h>
#endif
#endif #endif

View File

@@ -9,6 +9,7 @@
#include "item.h" #include "item.h"
#include <ModbusMaster.h> #include <ModbusMaster.h>
#include "main.h" #include "main.h"
#include <HardwareSerial.h>
extern aJsonObject *modbusObj; extern aJsonObject *modbusObj;
extern ModbusMaster node; extern ModbusMaster node;
@@ -52,22 +53,22 @@ const reg_t regSize_P[] PROGMEM =
const serial_t serialModes_P[] PROGMEM = const serial_t serialModes_P[] PROGMEM =
{ {
{ "8E1", SERIAL_8E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN }, { "8E1", (uint16_t) SERIAL_8E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN },
{ "8N1", SERIAL_8N1}, { "8N1", (uint16_t) SERIAL_8N1},
{ "8E2", SERIAL_8E2}, { "8E2", (uint16_t) SERIAL_8E2},
{ "8N2", SERIAL_8N2}, { "8N2", (uint16_t) SERIAL_8N2},
{ "8O1", SERIAL_8O1}, { "8O1", (uint16_t) SERIAL_8O1},
{ "8O2", SERIAL_8O2}, { "8O2", (uint16_t) SERIAL_8O2},
{ "8M1", SERIAL_8M1}, // { "8M1", SERIAL_8M1},
{ "8S1", SERIAL_8S1}, // { "8S1", SERIAL_8S1},
{ "7E1", SERIAL_7E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN }, { "7E1", (uint16_t) SERIAL_7E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN },
{ "7N1", SERIAL_7N1}, { "7N1", (uint16_t) SERIAL_7N1},
{ "7E2", SERIAL_7E2}, { "7E2", (uint16_t) SERIAL_7E2},
{ "7N2", SERIAL_7N2}, { "7N2", (uint16_t) SERIAL_7N2},
{ "7O1", SERIAL_7O1}, { "7O1", (uint16_t) SERIAL_7O1},
{ "7O2", SERIAL_7O2}, { "7O2", (uint16_t) SERIAL_7O2}
{ "7M1", SERIAL_7M1}, // { "7M1", SERIAL_7M1},
{ "7S1", SERIAL_7S1} // { "7S1", SERIAL_7S1}
} ; } ;
#define serialModesNum sizeof(serialModes_P)/sizeof(serial_t) #define serialModesNum sizeof(serialModes_P)/sizeof(serial_t)
@@ -261,7 +262,13 @@ if (store->pollingRegisters && !modbusBusy && (Status() == CST_INITIALIZED) && i
debugSerial<<F("Poll ")<< item->itemArr->name << endl; debugSerial<<F("Poll ")<< item->itemArr->name << endl;
modbusBusy=1; modbusBusy=1;
//store->serialParam=(USARTClass::USARTModes) SERIAL_8N1; //store->serialParam=(USARTClass::USARTModes) SERIAL_8N1;
#if defined (__SAM3X8E__)
modbusSerial.begin(store->baud, static_cast <USARTClass::USARTModes> (store->serialParam)); modbusSerial.begin(store->baud, static_cast <USARTClass::USARTModes> (store->serialParam));
#elif defined (ARDUINO_ARCH_ESP8266)
modbusSerial.begin(store->baud, static_cast <SerialConfig>(store->serialParam));
#else
modbusSerial.begin(store->baud, (store->serialParam));
#endif
debugSerial<< store->baud << F("---")<< store->serialParam<<endl; debugSerial<< store->baud << F("---")<< store->serialParam<<endl;
node.begin(item->getArg(0), modbusSerial); node.begin(item->getArg(0), modbusSerial);

View File

@@ -128,7 +128,7 @@
#define _owire #define _owire
#endif #endif
#ifndef MODBUS_DISABLE #if !(defined (MODBUS_DISABLE) && defined (MBUS_DISABLE))
#define _modbus #define _modbus
#endif #endif
@@ -171,7 +171,7 @@
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
#undef _dmxin #undef _dmxin
#undef _modbus //#undef _modbus
#ifndef DMX_DISABLE #ifndef DMX_DISABLE
#define _espdmx #define _espdmx
@@ -183,13 +183,14 @@
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#undef _dmxin #undef _dmxin
#undef _modbus //#undef _modbus
#ifndef DMX_DISABLE #ifndef DMX_DISABLE
#define _espdmx #define _espdmx
#endif #endif
//#undef _dmxout //#undef _dmxout
#undef modbusSerial //#undef modbusSerial
#define modbusSerial Serial2
#endif #endif
#ifndef _dmxout #ifndef _dmxout

View File

@@ -1,12 +1,20 @@
#include "streamlog.h" #include "streamlog.h"
#include <Arduino.h> #include <Arduino.h>
Streamlog::Streamlog (UARTClass * _serialPort, int _severity , Syslog * _syslog ) #ifdef SYSLOG_ENABLE
Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity , Syslog * _syslog )
{ {
serialPort=_serialPort; serialPort=_serialPort;
severity=_severity; severity=_severity;
syslog=_syslog; syslog=_syslog;
} }
#else
Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity)
{
serialPort=_serialPort;
severity=_severity;
}
#endif
void Streamlog::begin(unsigned long speed) void Streamlog::begin(unsigned long speed)
{ {

View File

@@ -1,28 +1,32 @@
#include <Print.h> #include <Print.h>
#include <UARTClass.h> #include <HardwareSerial.h>
#include <Syslog.h>
#include <inttypes.h> #include <inttypes.h>
#define LOG_DEBUG 7
#define LOG_INFO 6
#define LOG_ERROR 3
#ifndef LOGBUFFER_SIZE #ifndef LOGBUFFER_SIZE
#define LOGBUFFER_SIZE 80 #define LOGBUFFER_SIZE 80
#endif #endif
static uint8_t serialDebugLevel = 7;
static uint8_t udpDebugLevel =7;
#ifdef SYSLOG_ENABLE #ifdef SYSLOG_ENABLE
#include <Syslog.h>
static char logBuffer[LOGBUFFER_SIZE]; static char logBuffer[LOGBUFFER_SIZE];
static int logBufferPos=0; static int logBufferPos=0;
#endif #endif
#define LOG_DEBUG 7
#define LOG_INFO 6
#define LOG_ERROR 3
static uint8_t serialDebugLevel = 7;
static uint8_t udpDebugLevel =7;
class Streamlog : public Print class Streamlog : public Print
{ {
public: public:
Streamlog (UARTClass * _serialPort, int _severity = LOG_DEBUG, Syslog * _syslog = NULL); #ifdef SYSLOG_ENABLE
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG, Syslog * _syslog = NULL);
#else
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG);
#endif
// {serialPort=_serialPort;severity=_severity; syslog=_syslog; } // {serialPort=_serialPort;severity=_severity; syslog=_syslog; }
void begin(unsigned long speed); void begin(unsigned long speed);
void end() ; void end() ;
@@ -36,6 +40,8 @@ class Streamlog : public Print
operator bool() {return true;}; operator bool() {return true;};
private: private:
uint16_t severity; uint16_t severity;
UARTClass *serialPort; HardwareSerial *serialPort;
#ifdef SYSLOG_ENABLE
Syslog * syslog; Syslog * syslog;
#endif
}; };

View File

@@ -632,22 +632,27 @@ itemCmd mapInt(int32_t arg, aJsonObject* map)
statusLED::statusLED(uint8_t pattern) statusLED::statusLED(uint8_t pattern)
{ {
#if defined (STATUSLED)
pinMode(pinRED, OUTPUT); pinMode(pinRED, OUTPUT);
pinMode(pinGREEN, OUTPUT); pinMode(pinGREEN, OUTPUT);
pinMode(pinBLUE, OUTPUT); pinMode(pinBLUE, OUTPUT);
set(pattern); set(pattern);
timestamp=0; timestamp=0;
#endif
} }
void statusLED::show (uint8_t pattern) void statusLED::show (uint8_t pattern)
{ {
#if defined (STATUSLED)
digitalWrite(pinRED,(pattern & ledRED)?HIGH:LOW ); digitalWrite(pinRED,(pattern & ledRED)?HIGH:LOW );
digitalWrite(pinGREEN,(pattern & ledGREEN)?HIGH:LOW); digitalWrite(pinGREEN,(pattern & ledGREEN)?HIGH:LOW);
digitalWrite(pinBLUE,(pattern & ledBLUE)?HIGH:LOW); digitalWrite(pinBLUE,(pattern & ledBLUE)?HIGH:LOW);
#endif
} }
void statusLED::set (uint8_t pattern) void statusLED::set (uint8_t pattern)
{ {
#if defined (STATUSLED)
short newStat = pattern & ledParams; short newStat = pattern & ledParams;
if (newStat!=(curStat & ledParams)) if (newStat!=(curStat & ledParams))
@@ -656,17 +661,20 @@ void statusLED::set (uint8_t pattern)
show(pattern); show(pattern);
curStat=newStat | (curStat & ~ledParams); curStat=newStat | (curStat & ~ledParams);
} }
#endif
} }
void statusLED::flash(uint8_t pattern) void statusLED::flash(uint8_t pattern)
{ {
#if defined (STATUSLED)
show(pattern); show(pattern);
curStat|=ledFlash; curStat|=ledFlash;
#endif
} }
void statusLED::poll() void statusLED::poll()
{ {
#if defined (STATUSLED)
if (curStat & ledFlash) if (curStat & ledFlash)
{ {
curStat&=~ledFlash; curStat&=~ledFlash;
@@ -686,7 +694,7 @@ if (millis()>timestamp)
else show(curStat); else show(curStat);
} }
} }
#endif
} }

View File

@@ -23,7 +23,7 @@ default_envs =
; mega2560-5500 ; mega2560-5500
; LightHub controller HW revision 2.1 and above (Wiznet 5500 CS on pin 53) ; LightHub controller HW revision 2.1 and above (Wiznet 5500 CS on pin 53)
lighthub21 ; lighthub21
; Arduino DUE + Ethernet shield Wiznet 5100 ; Arduino DUE + Ethernet shield Wiznet 5100
; due-5100 ; due-5100
@@ -73,6 +73,7 @@ lib_ignore =
WifiManager WifiManager
Ethernet Ethernet
Ethernet3 Ethernet3
Ethernet5100
httpClient httpClient
FastLED FastLED
ESPDMX ESPDMX
@@ -108,7 +109,9 @@ lib_deps =
https://github.com/anklimov/NRFFlashStorage https://github.com/anklimov/NRFFlashStorage
https://github.com/adafruit/Adafruit_NeoPixel.git https://github.com/adafruit/Adafruit_NeoPixel.git
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
; https://github.com/livello/PrintEx#is-select-redecl https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
https://github.com/arcao/Syslog.git
@@ -129,6 +132,7 @@ lib_ignore =
Ethernet Ethernet
Ethernet2 Ethernet2
Ethernet3 Ethernet3
Ethernet5100
EEPROM EEPROM
Artnet Artnet
UIPEthernet UIPEthernet
@@ -160,6 +164,8 @@ lib_deps =
M5Stack M5Stack
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
https://github.com/arcao/Syslog.git
[env:esp32-wifi] [env:esp32-wifi]
platform = espressif32 platform = espressif32
@@ -179,6 +185,7 @@ lib_ignore =
Ethernet Ethernet
Ethernet2 Ethernet2
Ethernet3 Ethernet3
Ethernet5100
EEPROM EEPROM
Artnet Artnet
UIPEthernet UIPEthernet
@@ -210,14 +217,16 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
https://github.com/arcao/Syslog.git
[env:due-5100] [env:due-5100]
platform = atmelsam platform = atmelsam
framework = arduino framework = arduino
board = due board = due
build_flags = !python get_build_flags.py due-5100 build_flags = !python get_build_flags.py due-5100
lib_ignore = lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver ;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DHT sensor library for ESPx DHT sensor library for ESPx
ESP_EEPROM ESP_EEPROM
@@ -234,7 +243,7 @@ lib_deps =
EEPROM EEPROM
M5Stack M5Stack
;ArduinoOTA ;ArduinoOTA
lib_deps = lib_deps =
https://github.com/sebnil/DueFlashStorage https://github.com/sebnil/DueFlashStorage
https://github.com/anklimov/Arduino-Temperature-Control-Library.git https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire https://github.com/anklimov/DS2482_OneWire
@@ -243,7 +252,7 @@ lib_deps =
https://github.com/anklimov/aJson https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/Ethernet https://github.com/anklimov/Ethernet5100
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git https://github.com/anklimov/Artnet.git
FastLED@3.3.2 FastLED@3.3.2
@@ -257,9 +266,11 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
[env:due] [env:due]
;Experimental target with universal Ethernet Library
platform = atmelsam platform = atmelsam
framework = arduino framework = arduino
board = due board = due
@@ -281,6 +292,7 @@ lib_ignore =
WifiManager WifiManager
Ethernet3 Ethernet3
Ethernet2 Ethernet2
Ethernet5100
NRFFlashStorage NRFFlashStorage
WebServer WebServer
UIPEthernet UIPEthernet
@@ -311,6 +323,7 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
[env:mega2560slim-5100] [env:mega2560slim-5100]
platform = atmelavr platform = atmelavr
@@ -325,6 +338,7 @@ lib_ignore =
DueFlashStorage DueFlashStorage
WifiManager WifiManager
Ethernet3 Ethernet3
Ethernet
HTTPClient HTTPClient
NRFFlashStorage NRFFlashStorage
WebServer WebServer
@@ -340,7 +354,7 @@ lib_deps =
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet https://github.com/anklimov/Ethernet5100
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git https://github.com/anklimov/Artnet.git
FastLED@3.3.2 FastLED@3.3.2
@@ -353,6 +367,7 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
[env:mega2560-5500] [env:mega2560-5500]
platform = atmelavr platform = atmelavr
@@ -367,6 +382,7 @@ lib_ignore =
WifiManager WifiManager
Ethernet Ethernet
Ethernet3 Ethernet3
Ethernet5100
HTTPClient HTTPClient
NRFFlashStorage NRFFlashStorage
WebServer WebServer
@@ -394,6 +410,7 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
[env:esp8266-wifi] [env:esp8266-wifi]
@@ -424,6 +441,7 @@ lib_ignore =
ArduinoHttpClient ArduinoHttpClient
Ethernet3 Ethernet3
Ethernet2 Ethernet2
Ethernet5100
Ethernet Ethernet
NRFFlashStorage NRFFlashStorage
UIPEthernet UIPEthernet
@@ -451,6 +469,7 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA.git https://github.com/anklimov/ArduinoOTA.git
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
@@ -470,6 +489,7 @@ lib_ignore =
WifiManager WifiManager
Ethernet3 Ethernet3
Ethernet2 Ethernet2
Ethernet
NRFFlashStorage NRFFlashStorage
WebServer WebServer
UIPEthernet UIPEthernet
@@ -484,7 +504,7 @@ lib_deps =
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet https://github.com/anklimov/Ethernet5100
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git https://github.com/anklimov/Artnet.git
FastLED@3.3.2 FastLED@3.3.2
@@ -496,6 +516,7 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
[env:due-5500] [env:due-5500]
platform = atmelsam platform = atmelsam
@@ -514,6 +535,7 @@ lib_ignore =
httpClient httpClient
Ethernet Ethernet
Ethernet3 Ethernet3
Ethernet5100
NRFFlashStorage NRFFlashStorage
WebServer WebServer
UIPEthernet UIPEthernet
@@ -545,6 +567,7 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
[env:lighthub21] [env:lighthub21]
platform = atmelsam platform = atmelsam
@@ -565,6 +588,7 @@ lib_ignore =
httpClient httpClient
Ethernet Ethernet
Ethernet3 Ethernet3
Ethernet5100
NRFFlashStorage NRFFlashStorage
WebServer WebServer
UIPEthernet UIPEthernet
@@ -596,6 +620,7 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
[env:controllino] [env:controllino]
@@ -627,7 +652,7 @@ lib_deps =
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet https://github.com/anklimov/Ethernet5100
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git https://github.com/anklimov/Artnet.git
FastLED@3.3.2 FastLED@3.3.2
@@ -640,6 +665,8 @@ lib_deps =
SparkFun CCS811 Arduino Library@~1.0.7 SparkFun CCS811 Arduino Library@~1.0.7
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/anklimov/ArduinoOTA https://github.com/anklimov/ArduinoOTA
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
https://github.com/arcao/Syslog.git
[env:stm32-enc2860] [env:stm32-enc2860]
platform = ststm32 platform = ststm32
@@ -688,3 +715,4 @@ lib_deps =
UIPEthernet UIPEthernet
https://github.com/anklimov/NRFFlashStorage https://github.com/anklimov/NRFFlashStorage
Adafruit NeoPixel Adafruit NeoPixel
https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library