mirror of
https://github.com/anklimov/lighthub
synced 2025-12-11 14:19:50 +03:00
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:
@@ -32,6 +32,11 @@ e-mail anklimov@gmail.com
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MCP23017
|
||||
#include "Adafruit_MCP23017.h"
|
||||
Adafruit_MCP23017 mcp;
|
||||
#endif
|
||||
|
||||
extern PubSubClient mqttClient;
|
||||
extern aJsonObject *root;
|
||||
extern int8_t ethernetIdleCount;
|
||||
@@ -89,7 +94,7 @@ Input::Input(int pin)
|
||||
|
||||
boolean Input::isValid ()
|
||||
{
|
||||
return (pin && store);
|
||||
return (store);
|
||||
}
|
||||
|
||||
void Input::Parse()
|
||||
@@ -115,21 +120,7 @@ void Input::Parse()
|
||||
void Input::setup()
|
||||
{
|
||||
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;
|
||||
uint8_t inputPinMode = INPUT; //if IN_ACTIVE_HIGH
|
||||
switch (inType)
|
||||
@@ -145,6 +136,24 @@ switch (inType)
|
||||
store->state=IS_IDLE;
|
||||
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:
|
||||
inputPinMode = INPUT_PULLUP;
|
||||
|
||||
@@ -194,6 +203,10 @@ switch (cause) {
|
||||
case IN_PUSH_ON | IN_ACTIVE_HIGH:
|
||||
case IN_PUSH_TOGGLE :
|
||||
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);
|
||||
break;
|
||||
case IN_ANALOG:
|
||||
@@ -667,8 +680,12 @@ void Input::contactPoll(short cause) {
|
||||
else inputOnLevel = LOW;
|
||||
|
||||
|
||||
#ifdef MCP23017
|
||||
if (inType & IN_I2C)
|
||||
currentInputState = (mcp.digitalRead(pin) == inputOnLevel);
|
||||
else
|
||||
#endif
|
||||
currentInputState = (digitalRead(pin) == inputOnLevel);
|
||||
|
||||
switch (store->state) //Timer based transitions
|
||||
{
|
||||
case IS_PRESSED:
|
||||
|
||||
@@ -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_ANALOG 64 // Analog input
|
||||
#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_TOGGLE 1 // Used for push buttons. Every physicall push toggle logical switch on/off. Toggle on leading edge
|
||||
|
||||
@@ -1457,7 +1457,7 @@ bool send = isNotRetainingStatus() ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _modbus
|
||||
#ifndef MODBUS_DISABLE
|
||||
case CH_MODBUS:
|
||||
modbusDimmerSet(Par[0]);
|
||||
break;
|
||||
@@ -1540,7 +1540,7 @@ bool send = isNotRetainingStatus() ;
|
||||
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
|
||||
break;
|
||||
}
|
||||
#ifdef _modbus
|
||||
#ifndef MODBUS_DISABLE
|
||||
case CH_VC:
|
||||
VacomSetFan(Par[0], cmd);
|
||||
break;
|
||||
@@ -1703,7 +1703,7 @@ POLL 2101x10
|
||||
[22:27:29] => poll: 0A 03 08 34 00 0A 87 18
|
||||
|
||||
*/
|
||||
#ifdef _modbus
|
||||
#ifndef MODBUS_DISABLE
|
||||
int Item::modbusDimmerSet(uint16_t value)
|
||||
{
|
||||
switch (getCmd())
|
||||
|
||||
@@ -67,55 +67,45 @@ PWM Out
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#ifdef WIFI_ENABLE
|
||||
WiFiClient ethClient;
|
||||
|
||||
#if not defined(WIFI_MANAGER_DISABLE)
|
||||
WiFiManager wifiManager;
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include <Dhcp.h>
|
||||
EthernetClient ethClient;
|
||||
#endif
|
||||
|
||||
#if defined(OTA)
|
||||
#include <ArduinoOTA.h>
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
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
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
WiFiClient ethClient;
|
||||
NRFFlashStorage EEPROM;
|
||||
|
||||
#if not defined(WIFI_MANAGER_DISABLE)
|
||||
WiFiManager wifiManager;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_STM32
|
||||
EthernetClient ethClient;
|
||||
NRFFlashStorage EEPROM;
|
||||
#endif
|
||||
|
||||
#ifdef NRF5
|
||||
NRFFlashStorage EEPROM;
|
||||
EthernetClient ethClient;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SYSLOG_ENABLE
|
||||
#include <Syslog.h>
|
||||
EthernetUDP udpSyslogClient;
|
||||
#ifndef WIFI_ENABLE
|
||||
EthernetUDP udpSyslogClient;
|
||||
#else
|
||||
WiFiUDP udpSyslogClient;
|
||||
#endif
|
||||
Syslog udpSyslog(udpSyslogClient, SYSLOG_PROTO_BSD);
|
||||
unsigned long nextSyslogPingTime;
|
||||
static char syslogDeviceHostname[16];
|
||||
@@ -149,7 +139,7 @@ aJsonObject *items = NULL;
|
||||
aJsonObject *inputs = NULL;
|
||||
|
||||
aJsonObject *mqttArr = NULL;
|
||||
#ifndef MODBUS_DISABLE
|
||||
#ifdef _modbus
|
||||
aJsonObject *modbusObj = NULL;
|
||||
#endif
|
||||
#ifdef _owire
|
||||
@@ -176,7 +166,7 @@ bool configLoaded = false;
|
||||
int8_t ethernetIdleCount =0;
|
||||
int8_t configLocked = 0;
|
||||
|
||||
#ifdef _modbus
|
||||
#if defined (_modbus)
|
||||
ModbusMaster node;
|
||||
#endif
|
||||
|
||||
@@ -239,7 +229,7 @@ debugSerial<<F("Deleting conf. RAM was:")<<freeRam();
|
||||
#ifdef _owire
|
||||
owArr = NULL;
|
||||
#endif
|
||||
#ifndef MODBUS_DISABLE
|
||||
#ifdef _modbus
|
||||
modbusObj = NULL;
|
||||
#endif
|
||||
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)
|
||||
{
|
||||
wifiInitialized=false;
|
||||
@@ -731,7 +721,7 @@ void setupOTA(void)
|
||||
|
||||
|
||||
void onInitialStateInitLAN() {
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#if defined(WIFI_ENABLE)
|
||||
#if defined(WIFI_MANAGER_DISABLE)
|
||||
if(WiFi.status() != WL_CONNECTED) {
|
||||
WiFi.mode(WIFI_STA); // ESP 32 - WiFi.disconnect(); instead
|
||||
@@ -782,7 +772,7 @@ wifiManager.setTimeout(30);
|
||||
#endif
|
||||
*/
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||
#if defined(WIFI_ENABLE)
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
|
||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||
@@ -1073,7 +1063,7 @@ void printConfigSummary() {
|
||||
printBool(items);
|
||||
infoSerial<<F("\ninputs ");
|
||||
printBool(inputs);
|
||||
#ifndef MODBUS_DISABLE
|
||||
#ifdef _modbus
|
||||
infoSerial<<F("\nmodbus ");
|
||||
printBool(modbusObj);
|
||||
#endif
|
||||
@@ -1397,7 +1387,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
||||
}
|
||||
#endif
|
||||
#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;
|
||||
#else
|
||||
EthernetClient configEthClient;
|
||||
@@ -1561,7 +1551,7 @@ void setup_main() {
|
||||
ArtnetSetup();
|
||||
#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.setTimeout(180);
|
||||
|
||||
@@ -1612,7 +1602,7 @@ void printFirmwareVersionAndBuildOptions() {
|
||||
infoSerial<<F("\n(-)DMX");
|
||||
#endif
|
||||
|
||||
#ifndef MODBUS_DISABLE
|
||||
#ifdef _modbus
|
||||
infoSerial<<F("\n(+)MODBUS");
|
||||
#else
|
||||
infoSerial<<F("\n(-)MODBUS");
|
||||
@@ -1748,7 +1738,7 @@ if (!isMacValid) {
|
||||
mac[0]&=0xFE;
|
||||
mac[0]|=2;
|
||||
|
||||
#elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||
#elif defined(WIFI_ENABLE)
|
||||
//Using original MPU MAC
|
||||
WiFi.begin();
|
||||
WiFi.macAddress(mac);
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
//#include "SPIFFS.h"
|
||||
#include <ESP_EEPROM.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
//#include <ESP8266HTTPClient.h>
|
||||
//#include <ArduinoHttpClient.h>
|
||||
//#include "HttpClient.h"
|
||||
#include <WiFiManager.h>
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
//#include <WiFiManager.h>
|
||||
//#include <DNSServer.h>
|
||||
//#include <ESP8266WebServer.h>
|
||||
//#include <ESP8266WiFi.h>
|
||||
#include <user_interface.h>
|
||||
#define Ethernet WiFi
|
||||
//#define Ethernet WiFi
|
||||
#endif
|
||||
|
||||
#if defined ARDUINO_ARCH_ESP32
|
||||
@@ -41,15 +41,15 @@
|
||||
#include <NRFFlashStorage.h>
|
||||
//#include "HttpClient.h"
|
||||
//#include <ArduinoHttpClient.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
#include <WebServer.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <DNSServer.h>
|
||||
//#include <HTTPClient.h>
|
||||
//#include <WiFi.h>
|
||||
//#include <WiFiClient.h>
|
||||
//#include <WiFiClientSecure.h>
|
||||
//#include <WebServer.h>
|
||||
//#include <WiFiManager.h>
|
||||
//include <DNSServer.h>
|
||||
|
||||
#define Ethernet WiFi
|
||||
//#define Ethernet WiFi
|
||||
#endif
|
||||
|
||||
#ifdef NRF5
|
||||
@@ -122,7 +122,7 @@ extern Streamlog debugSerial;
|
||||
#include "DallasTemperature.h"
|
||||
#endif
|
||||
|
||||
#ifndef MODBUS_DISABLE
|
||||
#ifdef _modbus
|
||||
#include <ModbusMaster.h>
|
||||
#endif
|
||||
|
||||
@@ -138,13 +138,29 @@ extern Streamlog debugSerial;
|
||||
#include "dmx.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIFI_ENABLE
|
||||
|
||||
#ifdef Wiz5500
|
||||
#include <Ethernet2.h>
|
||||
#else
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(NRF5)
|
||||
#include <Ethernet.h>
|
||||
#endif
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#include <WiFi.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
#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
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "item.h"
|
||||
#include <ModbusMaster.h>
|
||||
#include "main.h"
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
extern aJsonObject *modbusObj;
|
||||
extern ModbusMaster node;
|
||||
@@ -52,22 +53,22 @@ const reg_t regSize_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 },
|
||||
{ "8N1", SERIAL_8N1},
|
||||
{ "8E2", SERIAL_8E2},
|
||||
{ "8N2", SERIAL_8N2},
|
||||
{ "8O1", SERIAL_8O1},
|
||||
{ "8O2", SERIAL_8O2},
|
||||
{ "8M1", SERIAL_8M1},
|
||||
{ "8S1", SERIAL_8S1},
|
||||
{ "7E1", SERIAL_7E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN },
|
||||
{ "7N1", SERIAL_7N1},
|
||||
{ "7E2", SERIAL_7E2},
|
||||
{ "7N2", SERIAL_7N2},
|
||||
{ "7O1", SERIAL_7O1},
|
||||
{ "7O2", SERIAL_7O2},
|
||||
{ "7M1", SERIAL_7M1},
|
||||
{ "7S1", SERIAL_7S1}
|
||||
{ "8E1", (uint16_t) SERIAL_8E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN },
|
||||
{ "8N1", (uint16_t) SERIAL_8N1},
|
||||
{ "8E2", (uint16_t) SERIAL_8E2},
|
||||
{ "8N2", (uint16_t) SERIAL_8N2},
|
||||
{ "8O1", (uint16_t) SERIAL_8O1},
|
||||
{ "8O2", (uint16_t) SERIAL_8O2},
|
||||
// { "8M1", SERIAL_8M1},
|
||||
// { "8S1", SERIAL_8S1},
|
||||
{ "7E1", (uint16_t) SERIAL_7E1},//(uint16_t) US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_EVEN },
|
||||
{ "7N1", (uint16_t) SERIAL_7N1},
|
||||
{ "7E2", (uint16_t) SERIAL_7E2},
|
||||
{ "7N2", (uint16_t) SERIAL_7N2},
|
||||
{ "7O1", (uint16_t) SERIAL_7O1},
|
||||
{ "7O2", (uint16_t) SERIAL_7O2}
|
||||
// { "7M1", SERIAL_7M1},
|
||||
// { "7S1", SERIAL_7S1}
|
||||
} ;
|
||||
|
||||
#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;
|
||||
modbusBusy=1;
|
||||
//store->serialParam=(USARTClass::USARTModes) SERIAL_8N1;
|
||||
#if defined (__SAM3X8E__)
|
||||
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;
|
||||
node.begin(item->getArg(0), modbusSerial);
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
#define _owire
|
||||
#endif
|
||||
|
||||
#ifndef MODBUS_DISABLE
|
||||
#if !(defined (MODBUS_DISABLE) && defined (MBUS_DISABLE))
|
||||
#define _modbus
|
||||
#endif
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#undef _dmxin
|
||||
#undef _modbus
|
||||
//#undef _modbus
|
||||
|
||||
#ifndef DMX_DISABLE
|
||||
#define _espdmx
|
||||
@@ -183,13 +183,14 @@
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#undef _dmxin
|
||||
#undef _modbus
|
||||
//#undef _modbus
|
||||
|
||||
#ifndef DMX_DISABLE
|
||||
#define _espdmx
|
||||
#endif
|
||||
//#undef _dmxout
|
||||
#undef modbusSerial
|
||||
//#undef modbusSerial
|
||||
#define modbusSerial Serial2
|
||||
#endif
|
||||
|
||||
#ifndef _dmxout
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
#include "streamlog.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;
|
||||
severity=_severity;
|
||||
syslog=_syslog;
|
||||
}
|
||||
#else
|
||||
Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity)
|
||||
{
|
||||
serialPort=_serialPort;
|
||||
severity=_severity;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Streamlog::begin(unsigned long speed)
|
||||
{
|
||||
|
||||
@@ -1,28 +1,32 @@
|
||||
#include <Print.h>
|
||||
#include <UARTClass.h>
|
||||
#include <Syslog.h>
|
||||
#include <HardwareSerial.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define LOG_DEBUG 7
|
||||
#define LOG_INFO 6
|
||||
#define LOG_ERROR 3
|
||||
|
||||
#ifndef LOGBUFFER_SIZE
|
||||
#define LOGBUFFER_SIZE 80
|
||||
#endif
|
||||
|
||||
static uint8_t serialDebugLevel = 7;
|
||||
static uint8_t udpDebugLevel =7;
|
||||
|
||||
#ifdef SYSLOG_ENABLE
|
||||
#include <Syslog.h>
|
||||
static char logBuffer[LOGBUFFER_SIZE];
|
||||
static int logBufferPos=0;
|
||||
#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
|
||||
{
|
||||
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; }
|
||||
void begin(unsigned long speed);
|
||||
void end() ;
|
||||
@@ -36,6 +40,8 @@ class Streamlog : public Print
|
||||
operator bool() {return true;};
|
||||
private:
|
||||
uint16_t severity;
|
||||
UARTClass *serialPort;
|
||||
HardwareSerial *serialPort;
|
||||
#ifdef SYSLOG_ENABLE
|
||||
Syslog * syslog;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -632,22 +632,27 @@ itemCmd mapInt(int32_t arg, aJsonObject* map)
|
||||
|
||||
statusLED::statusLED(uint8_t pattern)
|
||||
{
|
||||
#if defined (STATUSLED)
|
||||
pinMode(pinRED, OUTPUT);
|
||||
pinMode(pinGREEN, OUTPUT);
|
||||
pinMode(pinBLUE, OUTPUT);
|
||||
set(pattern);
|
||||
timestamp=0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void statusLED::show (uint8_t pattern)
|
||||
{
|
||||
#if defined (STATUSLED)
|
||||
digitalWrite(pinRED,(pattern & ledRED)?HIGH:LOW );
|
||||
digitalWrite(pinGREEN,(pattern & ledGREEN)?HIGH:LOW);
|
||||
digitalWrite(pinBLUE,(pattern & ledBLUE)?HIGH:LOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
void statusLED::set (uint8_t pattern)
|
||||
{
|
||||
#if defined (STATUSLED)
|
||||
short newStat = pattern & ledParams;
|
||||
|
||||
if (newStat!=(curStat & ledParams))
|
||||
@@ -656,17 +661,20 @@ void statusLED::set (uint8_t pattern)
|
||||
show(pattern);
|
||||
curStat=newStat | (curStat & ~ledParams);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void statusLED::flash(uint8_t pattern)
|
||||
{
|
||||
#if defined (STATUSLED)
|
||||
show(pattern);
|
||||
curStat|=ledFlash;
|
||||
#endif
|
||||
}
|
||||
|
||||
void statusLED::poll()
|
||||
|
||||
{
|
||||
#if defined (STATUSLED)
|
||||
if (curStat & ledFlash)
|
||||
{
|
||||
curStat&=~ledFlash;
|
||||
@@ -686,7 +694,7 @@ if (millis()>timestamp)
|
||||
else show(curStat);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user