7 Commits

Author SHA1 Message Date
7ab78ab2ae binaries 2023-11-23 17:05:50 +03:00
4d909dd449 DMX IN integration with items 2023-11-20 20:55:37 +03:00
Климов Андрей Николаевич
b3db766b1a post-refactoring fix (Mercury) 2023-11-20 14:58:56 +03:00
080cdd4e22 LOG cleaning 2023-11-20 13:50:14 +03:00
91d5acf619 pre-release bins 2023-11-20 01:23:58 +03:00
454b88fbbf DMX IN fix (rollback to 2021) 2023-11-20 01:13:25 +03:00
6e283e32db decrease Timer0 int priority 2023-11-19 13:47:48 +03:00
27 changed files with 51410 additions and 51270 deletions

View File

@@ -40,3 +40,4 @@
-D REDIRECTION_URL=\"http://lazyhome.ru/pwa\" -D REDIRECTION_URL=\"http://lazyhome.ru/pwa\"
-D MERCURY_ENABLE -D MERCURY_ENABLE
#-D IPMODBUS #-D IPMODBUS
-D CONFIG_CLEAN_PIN=2

File diff suppressed because it is too large Load Diff

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.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,7 @@
#define CST_UNKNOWN 0 #define CST_UNKNOWN 0
#define CST_FAILED 1 #define CST_FAILED 1
#define CST_INITIALIZED 2 #define CST_INITIALIZED 2
#define CST_USER 3
class abstractCh { class abstractCh {
public: public:

View File

@@ -47,6 +47,7 @@ volatile uint32_t checkTimestamp=0L;
#if defined(_dmxin) #if defined(_dmxin)
volatile uint32_t D_State=0; volatile uint32_t D_State=0;
volatile unsigned long D_checkT=0; volatile unsigned long D_checkT=0;
uint8_t DMXINChannels=0;
#endif #endif
#ifdef _artnet #ifdef _artnet
@@ -61,6 +62,61 @@ extern aJsonObject *items;
extern aJsonObject *dmxArr; extern aJsonObject *dmxArr;
itemCmd rgb2hsv(itemCmd in)
{
itemCmd out;
out.setArgType(ST_HSV255);
double min, max, delta;
double inr=in.param.r/255;
double ing=in.param.g/255;
double inb=in.param.b/255;
double inw=in.param.w/255;
min = inr < ing ? inr : ing;
min = min < inb ? min : inb;
max = inr > ing ? inr : ing;
max = max > inb ? max : inb;
max = max > inw ? max : inw;
out.param.v = max*255; // v
delta = max - min;
if (delta < 0.00001)
{
out.param.s = 0;
out.param.h = 0; // undefined, maybe nan?
return out;
}
if( max > 0.0 ) { // NOTE: if Max is == 0, this divide would cause a crash
out.param.s = (delta / max)*100; // s
} else {
// if max is 0, then r = g = b = 0
// s = 0, h is undefined
out.param.s = 0;
out.param.h = 0; // its now undefined
return out;
}
double outh;
if( inr >= max ) // > is bogus, just keeps compilor happy
outh = ( ing - inb ) / delta; // between yellow & magenta
else
if( ing >= max )
outh = 2.0 + ( inb - inr ) / delta; // between cyan & yellow
else
outh = 4.0 + ( inr - ing ) / delta; // between magenta & cyan
outh *= 60.0; // degrees
if( outh < 0.0 )
outh += 360.0;
out.param.h=outh;
return out;
}
int itemCtrl2(char* name,int r,int g, int b, int w) int itemCtrl2(char* name,int r,int g, int b, int w)
{ {
if (!items) return 0; if (!items) return 0;
@@ -68,7 +124,6 @@ int itemCtrl2(char* name,int r,int g, int b, int w)
if (itemArr && (itemArr->type==aJson_Array)) if (itemArr && (itemArr->type==aJson_Array))
{ {
short itemtype = aJson.getArrayItem(itemArr,0)->valueint; short itemtype = aJson.getArrayItem(itemArr,0)->valueint;
short itemaddr = aJson.getArrayItem(itemArr,1)->valueint; short itemaddr = aJson.getArrayItem(itemArr,1)->valueint;
switch (itemtype){ switch (itemtype){
@@ -84,7 +139,6 @@ int itemCtrl2(char* name,int r,int g, int b, int w)
case CH_RGB: // RGB case CH_RGB: // RGB
{ {
DmxWrite(itemaddr, r); DmxWrite(itemaddr, r);
DmxWrite(itemaddr+1, g); DmxWrite(itemaddr+1, g);
DmxWrite(itemaddr+2, b); DmxWrite(itemaddr+2, b);
@@ -96,7 +150,7 @@ int itemCtrl2(char* name,int r,int g, int b, int w)
if (groupArr && (groupArr->type==aJson_Array)) if (groupArr && (groupArr->type==aJson_Array))
{ aJsonObject *i =groupArr->child; { aJsonObject *i =groupArr->child;
while (i) while (i)
{ //Serial.println(i->valuestring); {
if (i->type == aJson_String) itemCtrl2(i->valuestring,r,g,b,w); if (i->type == aJson_String) itemCtrl2(i->valuestring,r,g,b,w);
i=i->next;} i=i->next;}
} }
@@ -119,9 +173,34 @@ void DMXImmediateUpdate(short tch,short r, short g, short b, short w) {
} }
} }
void DMXSemiImmediateUpdate(short tch,short trh, int val) void DMXSemiImmediateUpdate(short tch,short r, short g, short b, short w)
{ {
//Here any code for passthrow between DMX IN and DMX OUT in idle state //Here any code for passthrow between DMX IN and DMX OUT in idle state
if (dmxArr && (dmxArr->type==aJson_Array))
{
aJsonObject *DMXch = aJson.getArrayItem(dmxArr,tch);
char* itemname = NULL;
if (DMXch->type == aJson_String) itemname=DMXch->valuestring;
if (itemname)
{
Item it(itemname);
if (!r && !g && !b && !w) it.Ctrl(itemCmd().Cmd(CMD_OFF).setSuffix(S_CMD));
else
{
/*
CRGB rgb;
rgb.r = r;
rgb.g = g;
rgb.b = b;
CHSV hsv = rgb2hsv_approximate(rgb);
it.Ctrl(itemCmd().HSV255(hsv.h,hsv.s,hsv.v).setSuffix(S_SET)); */
it.Ctrl(itemCmd().RGBW(r,g,b,w).setSuffix(S_SET));
//it.Ctrl(rgb2hsv(itemCmd().RGBW(r,g,b,w)).setSuffix(S_SET));
it.Ctrl(itemCmd().Cmd(CMD_ON).setSuffix(S_CMD));
}
}
}
} }
void DMXput(void) void DMXput(void)
@@ -132,6 +211,7 @@ for (short tch=0; tch<=3 ; tch++)
short base = tch*4; short base = tch*4;
DMXImmediateUpdate(tch,DMXin[base],DMXin[base+1],DMXin[base+2],DMXin[base+3]); DMXImmediateUpdate(tch,DMXin[base],DMXin[base+1],DMXin[base+2],DMXin[base+3]);
} }
}; };
extern volatile uint8_t timerHandlerBusy; extern volatile uint8_t timerHandlerBusy;
@@ -140,81 +220,62 @@ extern volatile uint8_t timerHandlerBusy;
volatile int DMXinDoublecheck=0; volatile int DMXinDoublecheck=0;
#endif #endif
// INVOKED BY INTERRUPTS - MUST BE SAFE CODE
void DMXUpdate(void) void DMXUpdate(void)
{ {
#if defined(_dmxin) #if defined(_dmxin)
int t;
if(!DMXin) return; if(!DMXin) return;
#if defined(__SAM3X8E__) #if defined(__SAM3X8E__)
if (dmxin.getRxLength()<16) return; if (dmxin.getRxLength()<DMXINChannels) return;
#endif #endif
for (short tch=0; tch<=3 ; tch++)
uint8_t RGBWChannels=DMXINChannels >> 2;
for (short tch=0; tch<RGBWChannels ; tch++)
{ {
short base = tch*4; short base = tch*4;
bool updated = 0; bool updated = false;
bool confirmed = 0; int t;
for (short trh=0; trh<4 ; trh++) for (short trh=0; trh<4 ; trh++)
if (((t=dmxin.read(base+trh+1)) != DMXin[base+trh])) if ((t=dmxin.read(base+trh+1)) != DMXin[base+trh])
{ {
D_State |= (1<<tch);
updated=1; updated=1;
if (DMXinDoublecheck>2) DMXin[base+trh]=t;
{
D_State |= (1<<tch);
DMXin[base+trh]=t;
confirmed = 1;
}
} }
if (updated)
if (updated) DMXinDoublecheck++; else DMXinDoublecheck=0;
if (confirmed)
{ {
DMXImmediateUpdate(tch,DMXin[base],DMXin[base+1],DMXin[base+2],DMXin[base+3]); DMXImmediateUpdate(tch,DMXin[base],DMXin[base+1],DMXin[base+2],DMXin[base+3]);
//for (int i=1; i<17; i++) {debugSerial.print(dmxin.read(i));debugSerial.print("-");};debugSerial.print("|");
D_checkT=millisNZ(); D_checkT=millisNZ();
} }
} }
//Serial.print(D_State,BIN);Serial.println();
#endif #endif
} }
// INVOKED in safe loop
void DMXCheck(void) void DMXCheck(void)
{ {
// CHSV hsv;
// CRGB rgb;
DMXOUT_propagate(); DMXOUT_propagate();
#if defined(_dmxin) #if defined(_dmxin)
if ( (!D_checkT) || (!isTimeOver(D_checkT,millis(),D_CHECKT))) return;
short t,tch;
//Here code for semi-immediate update
for (t=1,tch=0; t<=8 ; t<<=1,tch++)
if (D_State & t)
{
// Serial.print(D_State,BIN);Serial.print(":");
D_State &= ~t;
for (short trh=0; trh<4 ; trh++)
DMXSemiImmediateUpdate(tch,trh,DMXin[tch*4+trh]);
}
//if ((millis()<D_checkT) || (D_checkT==0)) return;
if ( (!D_checkT) || (!isTimeOver(D_checkT,millis(),D_CHECKT))) return;
D_checkT=0; D_checkT=0;
uint8_t RGBWChannels=DMXINChannels >> 2;
for (short rgbwChan=0; rgbwChan < RGBWChannels; rgbwChan++)
{
short base = rgbwChan*4;
short bitMask = 1 << rgbwChan;
if (D_State & bitMask)
{
D_State &= ~bitMask;
DMXSemiImmediateUpdate(rgbwChan,DMXin[base],DMXin[base+1],DMXin[base+2],DMXin[base+3]);
break;
}
}
// Here code for network update //#ifdef _dmxout
//int ch = 0; //for (int i=1; i<17; i++) {debugSerial.print(dmxin.read(i));debugSerial.print(";");}
//debugSerial.println();
DMXput(); //#endif
#ifdef _dmxout
for (int i=1; i<17; i++) {debugSerial.print(dmxin.read(i));debugSerial.print(";");}
debugSerial.println();
#endif
#endif #endif
} }
@@ -238,7 +299,9 @@ void DMXinSetup(int channels)
//DmxSimple.maxChannel(channels); //DmxSimple.maxChannel(channels);
#if defined(_dmxin) #if defined(_dmxin)
if (channels>(32*4)) channels = 32*4;
DMXin = new uint8_t [channels]; DMXin = new uint8_t [channels];
DMXINChannels=channels;
#if defined(ARDUINO_ARCH_AVR) #if defined(ARDUINO_ARCH_AVR)
DMXSerial.init(DMXReceiver,0,channels); DMXSerial.init(DMXReceiver,0,channels);
if (DMXSerial.getBuffer()) {debugSerial.print(F("Init in ch:"));debugSerial.println(channels);} else debugSerial.println(F("DMXin Buffer alloc err")); if (DMXSerial.getBuffer()) {debugSerial.print(F("Init in ch:"));debugSerial.println(channels);} else debugSerial.println(F("DMXin Buffer alloc err"));

View File

@@ -2003,6 +2003,10 @@ int16_t attachTimer(double microseconds, timerCallback callback, const char* Tim
dueTimerInterrupt.attachInterruptInterval(microseconds, callback); dueTimerInterrupt.attachInterruptInterval(microseconds, callback);
timerNumber = dueTimerInterrupt.getTimerNumber(); timerNumber = dueTimerInterrupt.getTimerNumber();
debugSerial<<TimerName<<F(" attached to Timer(")<<timerNumber<<F(")")<<endl; debugSerial<<TimerName<<F(" attached to Timer(")<<timerNumber<<F(")")<<endl;
//DueTimer.Timers[timerNumber].irq
NVIC_SetPriority(TC0_IRQn,2);
debugSerial << "USART0 prio:" << NVIC_GetPriority (USART0_IRQn)<< " TC0 prio:" << NVIC_GetPriority (TC0_IRQn)<<endl;
return timerNumber; return timerNumber;
} }
#endif #endif
@@ -2493,6 +2497,11 @@ infoSerial<<F("\nNOSERIAL");
infoSerial<<F("\n(+)ELEVATOR"); infoSerial<<F("\n(+)ELEVATOR");
#endif #endif
#ifdef MERCURY_ENABLE
infoSerial<<F("\n(+)MERCURY");
#else
infoSerial<<F("\n(-)MERCURY");
#endif
//#ifdef IPMODBUS //#ifdef IPMODBUS
//infoSerial<<F("\n(+)IPMODBUS"); //infoSerial<<F("\n(+)IPMODBUS");
//#endif //#endif
@@ -2832,6 +2841,7 @@ configLocked--;
void inputSetup(void) { void inputSetup(void) {
infoSerial<<F("Initializing Inputs")<<endl;
if (!inputs) return; if (!inputs) return;
configLocked++; configLocked++;
aJsonObject *input = inputs->child; aJsonObject *input = inputs->child;

View File

@@ -22,14 +22,14 @@ static bool CCS811ready = false;
int in_ccs811::Setup() int in_ccs811::Setup()
{ {
if (CCS811ready) {errorSerial<<F("ccs811 is already initialized")<<endl; return 0;} if (CCS811ready) {errorSerial<<F("CCS811: Already initialized")<<endl; return 0;}
#ifdef WAK_PIN #ifdef WAK_PIN
pinMode(WAK_PIN,OUTPUT); pinMode(WAK_PIN,OUTPUT);
digitalWrite(WAK_PIN,LOW); digitalWrite(WAK_PIN,LOW);
#endif #endif
infoSerial.println("CCS811 Init"); infoSerial.println(F("CCS811: Init"));
#if defined (TWI_SCL) && defined (TWI_SDA) #if defined (TWI_SCL) && defined (TWI_SDA)
Wire.begin(TWI_SDA,TWI_SCL); //Inialize I2C Harware Wire.begin(TWI_SDA,TWI_SCL); //Inialize I2C Harware
@@ -37,7 +37,9 @@ Wire.begin(TWI_SDA,TWI_SCL); //Inialize I2C Harware
Wire.begin(); //Inialize I2C Harware Wire.begin(); //Inialize I2C Harware
#endif #endif
Wire.setClock(4000); #ifdef I2C_CLOCK
Wire.setClock(I2C_CLOCK);
#endif
//It is recommended to check return status on .begin(), but it is not //It is recommended to check return status on .begin(), but it is not
//required. //required.
@@ -46,8 +48,7 @@ Wire.setClock(4000);
if (returnCode != CCS811Core::SENSOR_SUCCESS) if (returnCode != CCS811Core::SENSOR_SUCCESS)
//if (returnCode != CCS811Core::CCS811_Stat_SUCCESS) //if (returnCode != CCS811Core::CCS811_Stat_SUCCESS)
{ {
errorSerial.print("CCS811 Init error "); errorSerial.print(F("CCS811: Init error "));
//debugSerial.println(ccs811.statusString(returnCode));
printDriverError(returnCode); printDriverError(returnCode);
return 0; return 0;
} }
@@ -68,16 +69,16 @@ return 1;
int in_hdc1080::Setup() int in_hdc1080::Setup()
{ {
//i2cReset(); //i2cReset();
if (HDC1080ready) {debugSerial<<F("hdc1080 is already initialized")<<endl; return 0;} if (HDC1080ready) {debugSerial<<F("HDC1080: Already initialized")<<endl; return 0;}
debugSerial.println("HDC1080 Init "); debugSerial.print(F("HDC1080: Init. "));
Wire.begin(); //Inialize I2C Harware Wire.begin(); //Inialize I2C Harware
// Default settings: // Default settings:
// - Heater off // - Heater off
// - 14 bit Temperature and Humidity Measurement Resolutions // - 14 bit Temperature and Humidity Measurement Resolutions
hdc1080.begin(0x40); hdc1080.begin(0x40);
debugSerial.print("Manufacturer ID=0x"); debugSerial.print(F("Manufacturer ID=0x"));
debugSerial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments debugSerial.print(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
debugSerial.print("Device ID=0x"); debugSerial.print(F(" Device ID=0x"));
debugSerial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device debugSerial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device
printSerialNumber(); printSerialNumber();
HDC1080ready = true; HDC1080ready = true;
@@ -91,14 +92,14 @@ int in_hdc1080::Poll(short cause)
float h,t; float h,t;
int reg; int reg;
if (cause!=POLLING_SLOW) return 0; if (cause!=POLLING_SLOW) return 0;
if (!HDC1080ready) {debugSerial<<F("HDC1080 not initialized")<<endl; return 0;} if (!HDC1080ready) {errorSerial<<F("HDC1080: Not initialized")<<endl; return 0;}
debugSerial.print("HDC Status="); debugSerial.print(F("HDC1080: Status="));
debugSerial.println(reg=hdc1080.readRegister().rawData,HEX); debugSerial.print(reg=hdc1080.readRegister().rawData,HEX);
if (reg!=0xff) if (reg!=0xff)
{ {
debugSerial.print(" T="); debugSerial.print(" T=");
debugSerial.print(t=hdc1080.readTemperature()); debugSerial.print(t=hdc1080.readTemperature());
debugSerial.print("C, RH="); debugSerial.print(F("C, RH="));
debugSerial.print(h=hdc1080.readHumidity()); debugSerial.print(h=hdc1080.readHumidity());
debugSerial.println("%"); debugSerial.println("%");
@@ -126,6 +127,7 @@ if (reg!=0xff)
} }
else //ESP I2C glitch else //ESP I2C glitch
{ {
debugSerial.println();
i2cReset(); i2cReset();
} }
return INTERVAL_SLOW_POLLING; return INTERVAL_SLOW_POLLING;
@@ -147,14 +149,14 @@ int in_ccs811::Poll(short cause)
CCS811Core::status returnCode = ccs811.readAlgorithmResults(); CCS811Core::status returnCode = ccs811.readAlgorithmResults();
printDriverError(returnCode); printDriverError(returnCode);
float co2,tvoc; float co2,tvoc;
debugSerial.print(" CO2["); debugSerial.print(F(" CO2["));
//Returns calculated CO2 reading //Returns calculated CO2 reading
debugSerial.print(co2 = ccs811.getCO2()); debugSerial.print(co2 = ccs811.getCO2());
debugSerial.print("] tVOC["); debugSerial.print(F("] tVOC["));
//Returns calculated TVOC reading //Returns calculated TVOC reading
debugSerial.print(tvoc = ccs811.getTVOC()); debugSerial.print(tvoc = ccs811.getTVOC());
debugSerial.print("] baseline["); debugSerial.print(F("] baseline["));
debugSerial.print(ccs811Baseline = ccs811.getBaseline()); debugSerial.print(ccs811Baseline = ccs811.getBaseline());
#ifdef M5STACK #ifdef M5STACK
@@ -192,11 +194,11 @@ int in_ccs811::Poll(short cause)
} }
void in_hdc1080::printSerialNumber() { void in_hdc1080::printSerialNumber() {
debugSerial.print("Device Serial Number="); infoSerial.print(F("Device Serial Number="));
HDC1080_SerialNumber sernum = hdc1080.readSerialNumber(); HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
char format[16]; char format[16];
sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast); sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast);
debugSerial.println(format); infoSerial.println(format);
} }
//printDriverError decodes the CCS811Core::status type and prints the //printDriverError decodes the CCS811Core::status type and prints the
@@ -206,25 +208,26 @@ debugSerial.println(format);
//to this function to see what the output was. //to this function to see what the output was.
void in_ccs811::printDriverError( CCS811Core::status errorCode ) void in_ccs811::printDriverError( CCS811Core::status errorCode )
{ {
debugSerial.print(F("CCS811: "));
switch ( errorCode ) switch ( errorCode )
{ {
case CCS811Core::SENSOR_SUCCESS: case CCS811Core::SENSOR_SUCCESS:
debugSerial.print("SUCCESS"); debugSerial.print(F("SUCCESS"));
break; break;
case CCS811Core::SENSOR_ID_ERROR: case CCS811Core::SENSOR_ID_ERROR:
debugSerial.print("ID_ERROR"); debugSerial.print(F("ID_ERROR"));
break; break;
case CCS811Core::SENSOR_I2C_ERROR: case CCS811Core::SENSOR_I2C_ERROR:
debugSerial.print("I2C_ERROR"); debugSerial.print(F("I2C_ERROR"));
break; break;
case CCS811Core::SENSOR_INTERNAL_ERROR: case CCS811Core::SENSOR_INTERNAL_ERROR:
debugSerial.print("INTERNAL_ERROR"); debugSerial.print(F("INTERNAL_ERROR"));
break; break;
case CCS811Core::SENSOR_GENERIC_ERROR: case CCS811Core::SENSOR_GENERIC_ERROR:
debugSerial.print("GENERIC_ERROR"); debugSerial.print(F("GENERIC_ERROR"));
break; break;
default: default:
debugSerial.print("Unspecified error."); debugSerial.print(F("Unspecified error."));
} }
} }
@@ -236,18 +239,18 @@ void in_ccs811::printSensorError()
if ( error == 0xFF ) //comm error if ( error == 0xFF ) //comm error
{ {
debugSerial.println("Failed to get ERROR_ID register."); errorSerial.println(F("CCS811: Failed to get ERROR_ID register."));
} }
else else
{ {
//debugSerial.print(""); if (error) errorSerial.print(F("CCS811: Error "));
if (error & 1 << 5) debugSerial.print("Error: HeaterSupply"); if (error & 1 << 5) errorSerial.print(F("HeaterSupply"));
if (error & 1 << 4) debugSerial.print("Error: HeaterFault"); if (error & 1 << 4) errorSerial.print(F("HeaterFault"));
if (error & 1 << 3) debugSerial.print("Error: MaxResistance"); if (error & 1 << 3) errorSerial.print(F("MaxResistance"));
if (error & 1 << 2) debugSerial.print("Error: MeasModeInvalid"); if (error & 1 << 2) errorSerial.print(F("MeasModeInvalid"));
if (error & 1 << 1) debugSerial.print("Error: ReadRegInvalid"); if (error & 1 << 1) errorSerial.print(F("ReadRegInvalid"));
if (error & 1 << 0) debugSerial.print("Error: MsgInvalid"); if (error & 1 << 0) errorSerial.print(F("MsgInvalid"));
debugSerial.println(); if (error) errorSerial.println();
} }
} }
#endif #endif

View File

@@ -7,6 +7,10 @@
#include "ClosedCube_HDC1080.h" #include "ClosedCube_HDC1080.h"
#include "SparkFunCCS811.h" //Click here to get the library: http://librarymanager/All#SparkFun_CCS811 #include "SparkFunCCS811.h" //Click here to get the library: http://librarymanager/All#SparkFun_CCS811
//#ifndef I2C_CLOCK
//#define I2C_CLOCK 4000
//#endif
//#define CCS811_ADDR 0x5B //Default I2C Address //#define CCS811_ADDR 0x5B //Default I2C Address
#define CCS811_ADDR 0x5A //Alternate I2C Address #define CCS811_ADDR 0x5A //Alternate I2C Address
@@ -28,13 +32,7 @@
#endif #endif
/*
#if defined (__SAM3X8E__)
#define SCL_LOW() digitalWrite(21,LOW)
#define SCL_HIGH() digitalWrite(21,HIGH)
#define SCL_RESET
#endif
*/
#if defined (ARDUINO_ARCH_ESP32) #if defined (ARDUINO_ARCH_ESP32)
#undef WAK_PIN #undef WAK_PIN

View File

@@ -21,8 +21,8 @@ extern bool disableCMD;
#define AC_FAILED CST_FAILED #define AC_FAILED CST_FAILED
#define AC_UNKNOWN CST_UNKNOWN #define AC_UNKNOWN CST_UNKNOWN
#define AC_IDLE CST_INITIALIZED #define AC_IDLE CST_INITIALIZED
#define AC_SENDING 3 #define AC_SENDING CST_USER
//byte inCheck = 0; //byte inCheck = 0;
byte qstn[] = {255,255,10,0,0,0,0,0,1,1,77,1,90}; // Команда опроса byte qstn[] = {255,255,10,0,0,0,0,0,1,1,77,1,90}; // Команда опроса

View File

@@ -97,6 +97,7 @@ debugSerial.println("Mercury: De-Init");
disconnectMercury(); disconnectMercury();
delete store; delete store;
item->setPersistent(NULL); item->setPersistent(NULL);
setStatus(CST_UNKNOWN);
store = NULL; store = NULL;
return 1; return 1;
} }

View File

@@ -20,16 +20,16 @@ public:
#define MB_SEND_ERROR 4 #define MB_SEND_ERROR 4
#define MB_SEND_ATTEMPTS 3 #define MB_SEND_ATTEMPTS 3
#define M_CONNECTING 10 #define M_CONNECTING CST_USER+0
#define M_CONNECTED 11 #define M_CONNECTED CST_USER+1
#define M_POLLING1 12 #define M_POLLING1 CST_USER+2
#define M_POLLING2 13 #define M_POLLING2 CST_USER+3
#define M_POLLING3 14 #define M_POLLING3 CST_USER+4
#define M_POLLING4 15 #define M_POLLING4 CST_USER+5
#define M_POLLING5 16 #define M_POLLING5 CST_USER+6
#define M_POLLING6 17 #define M_POLLING6 CST_USER+7
#define M_POLLING7 18 #define M_POLLING7 CST_USER+8
#define M_POLLING8 19 #define M_POLLING8 CST_USER+9
#define RET_SUCCESS 0 #define RET_SUCCESS 0
#define RET_INVALID_PARAM 1 #define RET_INVALID_PARAM 1

View File

@@ -26,10 +26,9 @@ e-mail anklimov@gmail.com
#include "options.h" #include "options.h"
#include "main.h" #include "main.h"
#include "aJSON.h" #include "aJSON.h"
//#include "twi.h"
extern aJsonObject *owArr; extern aJsonObject *owArr;
extern uint32_t timerCtr; //extern uint32_t timerCtr;
aJsonObject *dev2Check = NULL; aJsonObject *dev2Check = NULL;
OneWire *oneWire = NULL; OneWire *oneWire = NULL;
@@ -62,7 +61,7 @@ char * getReadableNote(aJsonObject * owObj)
void processTemp(aJsonObject * owObj, float currentTemp) { void processTemp(aJsonObject * owObj, float currentTemp) {
if (!owObj || !owArr) return; if (!owObj || !owArr) return;
char* note = getReadableNote(owObj); char* note = getReadableNote(owObj);
debugSerial<<endl<<F("1WT:")<<currentTemp<<F(" <")<<owObj->name<<F("> "); debugSerial <<F("1WT:")<<currentTemp<<F(" <")<<owObj->name<<F("> ");
if ((currentTemp != -127.0) && (currentTemp != 85.0) && (currentTemp != 0.0)) if ((currentTemp != -127.0) && (currentTemp != 85.0) && (currentTemp != 0.0))
{ {
if (note) debugSerial<<note; if (note) debugSerial<<note;