mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 19:59:50 +03:00
sync
This commit is contained in:
@@ -146,7 +146,8 @@ if (input->type == aJson_Object) {
|
||||
else
|
||||
{
|
||||
Input in(input);
|
||||
in.Poll(CHECK_INPUT);
|
||||
in.store->aslong = 0;
|
||||
//in.Poll(CHECK_INPUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -524,7 +525,7 @@ bool Input::changeState(uint8_t newState, short cause)
|
||||
if (!inputObj || !store) return false;
|
||||
|
||||
if (newState == IS_REQSTATE)
|
||||
if (store->delayedState && cause != CHECK_INTERRUPT)
|
||||
if (store->delayedState && (cause != CHECK_INTERRUPT))
|
||||
{
|
||||
// Requested delayed change State and safe moment
|
||||
newState=store->reqState; //Retrieve requested state
|
||||
|
||||
@@ -105,7 +105,7 @@ extern aJsonObject *inputs;
|
||||
|
||||
|
||||
typedef union {
|
||||
long int aslong;
|
||||
uint32_t aslong;
|
||||
uint32_t timestamp;
|
||||
// Analog input structure
|
||||
struct {
|
||||
|
||||
@@ -468,6 +468,7 @@ int out_AC::Ctrl(itemCmd cmd, char* subItem , bool toExecute, bool authorized)
|
||||
|
||||
case S_CMD:
|
||||
// s_mode[0]='\0';
|
||||
store->inCheck=0;
|
||||
switch (cmd.getCmd())
|
||||
{
|
||||
case CMD_ON:
|
||||
@@ -549,9 +550,42 @@ int out_AC::Ctrl(itemCmd cmd, char* subItem , bool toExecute, bool authorized)
|
||||
store->data[B_FAN_SPD] = 2;
|
||||
strcpy_P(s_speed,LOW_P);
|
||||
break;
|
||||
case CMD_OFF:
|
||||
store->inCheck=0;
|
||||
store->data[B_POWER] = store->power;
|
||||
store->data[B_POWER] &= ~1;
|
||||
SendData(off, sizeof(off)/sizeof(byte));
|
||||
return 1;
|
||||
default:
|
||||
//if (n) data[B_FAN_SPD] = Parameters[0];
|
||||
store->data[B_FAN_SPD] = cmd.getInt();
|
||||
{
|
||||
uint8_t speed = 0;
|
||||
if (cmd.getInt()) speed = map(cmd.getInt(),1,255,1,3);
|
||||
store->inCheck=0;
|
||||
switch (speed) {
|
||||
case 0:
|
||||
store->data[B_POWER] = store->power;
|
||||
store->data[B_POWER] &= ~1;
|
||||
SendData(off, sizeof(off)/sizeof(byte));
|
||||
return 1;
|
||||
case 1:
|
||||
store->data[B_FAN_SPD] = 2;
|
||||
strcpy_P(s_speed,LOW_P);
|
||||
store->data[B_POWER] = store->power;
|
||||
store->data[B_POWER] |= 1;
|
||||
break;
|
||||
case 2:
|
||||
store->data[B_FAN_SPD] = 1;
|
||||
strcpy_P(s_speed,MED_P);
|
||||
store->data[B_POWER] = store->power;
|
||||
store->data[B_POWER] |= 1;
|
||||
break;
|
||||
case 3:
|
||||
store->data[B_FAN_SPD] = 0;
|
||||
strcpy_P(s_speed,HIGH_P);
|
||||
store->data[B_POWER] = store->power;
|
||||
store->data[B_POWER] |= 1;
|
||||
}
|
||||
}
|
||||
//TODO - mapping digits to speed
|
||||
}
|
||||
publishTopic(item->itemArr->name,s_speed,"/fan");
|
||||
|
||||
@@ -44,19 +44,19 @@ if (gatesObj /*&& aJson.getArraySize(item->itemArg)>=2*/)
|
||||
}
|
||||
i=i->next;
|
||||
}
|
||||
debugSerial << F ("MultiVent init")<< endl;
|
||||
debugSerial << F ("VENT: init")<< endl;
|
||||
setStatus(CST_INITIALIZED);
|
||||
return 1;
|
||||
}
|
||||
|
||||
debugSerial << F ("MultiVent config failed")<< endl;
|
||||
debugSerial << F ("VENT: config failed")<< endl;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int out_Multivent::Stop()
|
||||
{
|
||||
debugSerial << F ("Multivent De-Init") << endl;
|
||||
debugSerial << F ("VENT: De-Init") << endl;
|
||||
setStatus(CST_UNKNOWN);
|
||||
return 1;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ while (i)
|
||||
|
||||
if (cmdObj->valueint == CMD_OFF || cmdObj->valueint == -1)
|
||||
{
|
||||
debugSerial<<"Turning ON"<<endl;
|
||||
debugSerial<<"VENT: Turning ON"<<endl;
|
||||
cmdObj->valueint = CMD_ON;
|
||||
cmd.Cmd(CMD_ON);
|
||||
//if (isNotRetainingStatus()) item->SendStatusImmediate(itemCmd().Cmd(CMD_ON),FLAG_COMMAND,i->name);
|
||||
@@ -162,7 +162,7 @@ while (i)
|
||||
else
|
||||
{
|
||||
if (cmdObj->valueint != CMD_OFF && cmdObj->valueint != -1)
|
||||
{ debugSerial<<"Turning OFF"<<endl;
|
||||
{ debugSerial<<"VENT: Turning OFF"<<endl;
|
||||
cmdObj->valueint = CMD_OFF;
|
||||
cmd.Cmd(CMD_OFF);
|
||||
//if (isNotRetainingStatus()) item->SendStatusImmediate(itemCmd().Cmd(CMD_OFF),FLAG_COMMAND,i->name);
|
||||
@@ -204,10 +204,13 @@ while (i)
|
||||
if (!totalV) return 0;
|
||||
|
||||
int fanV=activeV/totalV;
|
||||
debugSerial << F("Total V:")<<totalV<<F(" active V:")<<activeV/255<< F(" fan%:")<<fanV<< F(" Max request:")<<maxRequestedV/255 <<F(" from ")<<maxV<<F(" m3")<< endl;
|
||||
|
||||
executeCommand(aJson.getObjectItem(gatesObj, ""),-1,itemCmd().Percents255(fanV).Cmd((fanV)?CMD_ON:CMD_OFF));
|
||||
debugSerial << F("VENT: Total V:")<<totalV<<F(" active V:")<<activeV/255<< F(" fan%:")<<fanV<< F(" Max req:")<<maxRequestedV/255 <<F(" from ")<<maxV<<F(" m3")<< endl;
|
||||
|
||||
//executeCommand(aJson.getObjectItem(gatesObj, ""),-1,itemCmd().Percents255(fanV).Cmd((fanV)?CMD_ON:CMD_OFF));
|
||||
if (fanV)
|
||||
executeCommand(aJson.getObjectItem(gatesObj, ""),-1,itemCmd().Percents255(fanV).Cmd(CMD_ON));
|
||||
else
|
||||
executeCommand(aJson.getObjectItem(gatesObj, ""),-1,itemCmd().Percents255(fanV));
|
||||
//Move gates only if fan is actually on
|
||||
if (!fanV) return 1;
|
||||
|
||||
@@ -229,7 +232,7 @@ while (i)
|
||||
{
|
||||
int requestedV=V*setObj->valueint;
|
||||
out = (( long)requestedV*255L)/(( long)V)*( long)maxV/( long)maxRequestedV;
|
||||
debugSerial<<i->name<<(" Req:")<<requestedV/255<<F(" Out:")<<out<<endl;
|
||||
debugSerial<<F("VENT: ")<<i->name<<F(" Req:")<<requestedV/255<<F(" Out:")<<out<<endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#define MAXFLASHSTR 32
|
||||
#define PWDFLASHSTR 16
|
||||
#define EEPROM_SIGNATURE "LHC1"
|
||||
#define EEPROM_SIGNATURE "LHC2"
|
||||
#define EEPROM_SIGNATURE_LENGTH 4
|
||||
|
||||
//#define EEPROM_offsetJSON IFLASH_PAGE_SIZE
|
||||
@@ -23,12 +23,12 @@ const char EEPROM_signature[] = EEPROM_SIGNATURE;
|
||||
uint32_t configFlags32bit;
|
||||
struct
|
||||
{
|
||||
uint8_t serialDebugLevel:3;
|
||||
uint8_t serialDebugLevel:4;
|
||||
uint8_t notGetConfigFromHTTP:1;
|
||||
uint8_t udpDebugLevel:3;
|
||||
uint8_t notSaveSuccedConfig:1;
|
||||
uint8_t dhcpFallback:1;
|
||||
uint8_t spare2:7;
|
||||
uint8_t spare2:6;
|
||||
uint16_t sysConfigHash;
|
||||
};
|
||||
} systemConfigFlags;
|
||||
|
||||
Reference in New Issue
Block a user