49days issue fixed, thermostates, RGB/HSV mixes

This commit is contained in:
2021-03-07 00:13:35 +03:00
parent cecb64fbc6
commit e7f606d16c
36 changed files with 1119 additions and 124 deletions

View File

@@ -122,7 +122,7 @@ else //ESP I2C glitch
Serial.println("I2C Reset");
i2cReset();
}
return INTERVAL_POLLING;
return INTERVAL_SLOW_POLLING;
}
int in_ccs811::Poll(short cause)

View File

@@ -158,7 +158,7 @@ void out_AC::InsertData(byte data[], size_t size){
publishTopic(item->itemArr->name, s_mode,"/cmd");
else publishTopic(item->itemArr->name, "OFF","/cmd");
/*
String raw_str;
char raw[75];
for (int i=0; i < 37; i++){
@@ -173,7 +173,7 @@ void out_AC::InsertData(byte data[], size_t size){
raw_str.toCharArray(raw,75);
publishTopic(item->itemArr->name, raw,"/raw");
Serial.println(raw);
*/
///////////////////////////////////
}
@@ -241,9 +241,10 @@ int out_AC::Poll(short cause)
{
if (cause!=POLLING_SLOW) return 0;
long now = millis();
if (now - prevPolling > INTERVAL_AC_POLLING) {
prevPolling = now;
//long now = millis();
//if (now - prevPolling > INTERVAL_AC_POLLING) {
if (isTimeOver(prevPolling,millis(),INTERVAL_AC_POLLING)) {
prevPolling = millisNZ();
Serial.println ("Polling");
SendData(qstn, sizeof(qstn)/sizeof(byte)); //Опрос кондиционера
}
@@ -259,7 +260,7 @@ delay(100);
InsertData(data, 37);
}
}
return INTERVAL_POLLING;
return INTERVAL_SLOW_POLLING;
};
//int out_AC::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* subItem)

View File

@@ -68,14 +68,18 @@ if (!item || !show) return 0;
short cType=getChanType();
uint8_t storageType;
/*
switch (cmd.getCmd()){
case CMD_OFF:
cmd.Percents(0);
break;
}
*/
debugSerial<<F("DMX ctrl: "); cmd.debugOut();
if (cType==CH_DIMMER) //Single channel
{
DmxWrite(iaddr, cmd.getPercents255());
@@ -95,8 +99,8 @@ if (cType==CH_DIMMER) //Single channel
}
itemCmd st(storageType,CMD_VOID);
st.assignFrom(cmd);
debugSerial<<F("Assigned:");st.debugOut();
switch (cType)
{

View File

@@ -144,7 +144,7 @@ if (!store)
{ errorSerial<<F("MBUS: Out of memory")<<endl;
return 0;}
store->timestamp=millis();
store->timestamp=millisNZ();
if (getConfig())
{
//item->clearFlag(ACTION_NEEDED);
@@ -354,7 +354,7 @@ if (store->pollingRegisters && !modbusBusy && (Status() == CST_INITIALIZED) && i
reg = reg->next;
}
store->timestamp=millis();
store->timestamp=millisNZ();
debugSerial<<F("endPoll ")<< item->itemArr->name << endl;
//Non blocking waiting to release line

View File

@@ -132,7 +132,8 @@ if (curPos<0) curPos=0;
if (curPos>100) curPos=100;
}
if (motorOfftime && motorOfftime<millis()) //Time over
//if (motorOfftime && motorOfftime<millis()) //Time over
if (motorOfftime && isTimeOver(motorOfftime,millis(),maxOnTime))
{dif = 0; debugSerial<<F("Motor timeout")<<endl;}
else if (curPos>=0)
dif=targetPos-curPos;
@@ -145,7 +146,7 @@ if (dif<-POS_ERR)
{
digitalWrite(pinDown,INACTIVE);
if (!item->getExt())item->setExt(millis()+maxOnTime);
if (!item->getExt())item->setExt(millisNZ());
//
//PINS_COUNT
@@ -193,7 +194,7 @@ if (dif>POS_ERR)
{
digitalWrite(pinUp,INACTIVE);
if (!item->getExt()) item->setExt(millis()+maxOnTime);
if (!item->getExt()) item->setExt(millisNZ());
#ifndef ESP32
if (digitalPinHasPWM(pinDown))
{
@@ -269,7 +270,7 @@ debugSerial<<F("Forced execution");
case S_SET:
if (!cmd.isValue()) return 0;
// item->setVal(cmd.getPercents());
if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
if (item->getExt()) item->setExt(millisNZ()); //Extend motor time
/*
st.assignFrom(cmd);
//Store
@@ -279,7 +280,7 @@ case S_SET:
if (chActive>0 && !st.getPercents()) item->setCmd(CMD_OFF);
if (chActive==0 && st.getPercents()) item->setCmd(CMD_ON);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
if (item->getExt()) item->setExt(millisNZ()); //Extend motor time
}
else item->SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
*/
@@ -315,12 +316,12 @@ case S_CMD:
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS );
}
*/
if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
if (item->getExt()) item->setExt(millisNZ()); //Extend motor time
return 1;
case CMD_OFF:
////item->SendStatus(SEND_COMMAND);
if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
if (item->getExt()) item->setExt(millisNZ()); //Extend motor time
return 1;
} //switch cmd

View File

@@ -119,7 +119,7 @@ int out_pid::Poll(short cause)
if ((Status() == CST_INITIALIZED) && isTimeOver(store->timestamp,millis(),store->pollingInterval))
{
store->timestamp=millis();
store->timestamp=millisNZ();
debugSerial<<F("endPoll ")<< item->itemArr->name << endl;
}

View File

@@ -125,12 +125,13 @@ bool inverse = (item->getArg()<0);
short cType = getChanType();
uint8_t storageType;
/*
switch (cmd.getCmd()){
case CMD_OFF:
cmd.Percents(0);
break;
}
*/
switch (cType)
{