mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
ENABLE & DISABLE to separate topic and XON timer
This commit is contained in:
@@ -31,11 +31,13 @@ e-mail anklimov@gmail.com
|
|||||||
#define S_RGB 6
|
#define S_RGB 6
|
||||||
#define S_FAN 7
|
#define S_FAN 7
|
||||||
#define S_MODE 8
|
#define S_MODE 8
|
||||||
#define S_HUE 9
|
#define S_CTRL 9
|
||||||
#define S_SAT 10
|
#define S_HUE 10
|
||||||
#define S_TEMP 11
|
#define S_SAT 11
|
||||||
#define S_RAW 12
|
#define S_TEMP 12
|
||||||
#define S_ADDITIONAL 12
|
#define S_RAW 13
|
||||||
|
|
||||||
|
#define S_ADDITIONAL 13
|
||||||
|
|
||||||
#define CH_DIMMER 0 //DMX 1-4 ch
|
#define CH_DIMMER 0 //DMX 1-4 ch
|
||||||
#define CH_RGBW 1 //DMX 4 ch
|
#define CH_RGBW 1 //DMX 4 ch
|
||||||
@@ -146,6 +148,8 @@ class Item
|
|||||||
inline int On (){return Ctrl(itemCmd(ST_VOID,CMD_ON));};
|
inline int On (){return Ctrl(itemCmd(ST_VOID,CMD_ON));};
|
||||||
inline int Off(){return Ctrl(itemCmd(ST_VOID,CMD_OFF));};
|
inline int Off(){return Ctrl(itemCmd(ST_VOID,CMD_OFF));};
|
||||||
inline int Toggle(){return Ctrl(itemCmd(ST_VOID,CMD_TOGGLE));};
|
inline int Toggle(){return Ctrl(itemCmd(ST_VOID,CMD_TOGGLE));};
|
||||||
|
int scheduleCommand(itemCmd cmd);
|
||||||
|
int isScheduled();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
long int limitSetValue();
|
long int limitSetValue();
|
||||||
|
|||||||
@@ -1049,6 +1049,10 @@ bool itemCmd::loadItem(Item * item, uint16_t optionsFlag)
|
|||||||
short subtype =item->getSubtype();
|
short subtype =item->getSubtype();
|
||||||
if (optionsFlag & FLAG_COMMAND) cmd.cmdCode = item->getCmd();
|
if (optionsFlag & FLAG_COMMAND) cmd.cmdCode = item->getCmd();
|
||||||
|
|
||||||
|
//if (optionsFlag & FLAG_FLAGS)
|
||||||
|
// if (item->getFlag(FLAG_DISABLED))
|
||||||
|
// cmd.cmdCode = CMD_DISABLE;
|
||||||
|
|
||||||
if (subtype)
|
if (subtype)
|
||||||
{
|
{
|
||||||
cmd.itemArgType= subtype;
|
cmd.itemArgType= subtype;
|
||||||
@@ -1101,7 +1105,27 @@ bool itemCmd::saveItem(Item * item, uint16_t optionsFlag)
|
|||||||
{
|
{
|
||||||
if (item && item->isValid())
|
if (item && item->isValid())
|
||||||
{
|
{
|
||||||
if (optionsFlag & FLAG_COMMAND) item->setCmd(cmd.cmdCode);
|
|
||||||
|
if (optionsFlag & FLAG_FLAGS)
|
||||||
|
switch (cmd.cmdCode)
|
||||||
|
{
|
||||||
|
case CMD_DISABLE:
|
||||||
|
item->setFlag(FLAG_DISABLED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_ENABLE:
|
||||||
|
item->clearFlag(FLAG_DISABLED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (optionsFlag & FLAG_COMMAND)
|
||||||
|
switch (cmd.cmdCode)
|
||||||
|
{
|
||||||
|
case CMD_DISABLE:
|
||||||
|
case CMD_ENABLE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
item->setCmd(cmd.cmdCode);
|
||||||
|
}
|
||||||
if (optionsFlag & FLAG_PARAMETERS)
|
if (optionsFlag & FLAG_PARAMETERS)
|
||||||
switch (cmd.itemArgType)
|
switch (cmd.itemArgType)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ const cmdstr commands_P[] PROGMEM =
|
|||||||
#define CMD_FAN 0xd /// AC set to Fan-only mode
|
#define CMD_FAN 0xd /// AC set to Fan-only mode
|
||||||
#define CMD_DRY 0xe /// AC set to Dry mode
|
#define CMD_DRY 0xe /// AC set to Dry mode
|
||||||
#define CMD_STOP 0xf /// stop dimming (for further use)
|
#define CMD_STOP 0xf /// stop dimming (for further use)
|
||||||
|
|
||||||
#define CMD_HIGH 0x10 /// AC/Vent fan level HIGH
|
#define CMD_HIGH 0x10 /// AC/Vent fan level HIGH
|
||||||
#define CMD_MED 0x11 /// AC/Vent fan level MEDIUM
|
#define CMD_MED 0x11 /// AC/Vent fan level MEDIUM
|
||||||
#define CMD_LOW 0x12 /// AC/Vent fan level LOW
|
#define CMD_LOW 0x12 /// AC/Vent fan level LOW
|
||||||
@@ -57,8 +58,8 @@ const cmdstr commands_P[] PROGMEM =
|
|||||||
#define CMD_RGB 0x17
|
#define CMD_RGB 0x17
|
||||||
#define CMD_HSV 0x18
|
#define CMD_HSV 0x18
|
||||||
|
|
||||||
#define CMD_MASK 0xff
|
#define CMD_MASK 0xffUL
|
||||||
#define FLAG_MASK 0xffff00
|
#define FLAG_MASK 0x00ffff00UL
|
||||||
//#define STATE_MASK 0xff0000
|
//#define STATE_MASK 0xff0000
|
||||||
|
|
||||||
#define CMD_VOID 0
|
#define CMD_VOID 0
|
||||||
@@ -66,19 +67,20 @@ const cmdstr commands_P[] PROGMEM =
|
|||||||
#define CMD_JSON -2
|
#define CMD_JSON -2
|
||||||
|
|
||||||
//FLAGS
|
//FLAGS
|
||||||
#define FLAG_SEND_IMMEDIATE 0x1
|
#define FLAG_SEND_IMMEDIATE 0x1UL
|
||||||
#define FLAG_COMMAND 0x100
|
#define FLAG_COMMAND 0x100UL
|
||||||
#define FLAG_PARAMETERS 0x200
|
#define FLAG_PARAMETERS 0x200UL
|
||||||
#define FLAG_SEND_RETRY 0x400
|
#define FLAG_FLAGS 0x400UL
|
||||||
#define FLAG_SEND_DEFFERED 0x800
|
#define FLAG_SEND_RETRY 0x800UL
|
||||||
#define FLAG_SEND_DELAYED 0x1000
|
#define FLAG_SEND_DEFFERED 0x1000UL
|
||||||
#define FLAG_ACTION_NEEDED 0x2000
|
#define FLAG_SEND_DELAYED 0x2000UL
|
||||||
#define FLAG_ACTION_IN_PROCESS 0x4000
|
#define FLAG_ACTION_NEEDED 0x4000UL
|
||||||
|
#define FLAG_ACTION_IN_PROCESS 0x8000UL
|
||||||
|
|
||||||
#define FLAG_DISABLED 0x10000
|
#define FLAG_DISABLED 0x10000UL
|
||||||
#define FLAG_DISABLED_ALL 0x20000
|
#define FLAG_DISABLED_ALL 0x20000UL
|
||||||
#define FLAG_HALTED 0x40000
|
#define FLAG_HALTED 0x40000UL
|
||||||
#define FLAG__XON 0x80000
|
#define FLAG_XON 0x80000UL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ if (store && store->pid && (Status() == CST_INITIALIZED) && item && (item->getCm
|
|||||||
//itemCmd st;
|
//itemCmd st;
|
||||||
//st.loadItem(item);
|
//st.loadItem(item);
|
||||||
//short cmd = st.getCmd();
|
//short cmd = st.getCmd();
|
||||||
if (item->getCmd() != CMD_OFF && item->getCmd() != CMD_DISABLE)
|
if (item->getCmd() != CMD_OFF && /* item->getCmd() != CMD_DISABLE*/ ! item->getFlag(FLAG_DISABLED))
|
||||||
{
|
{
|
||||||
if(store->pid->Compute() )
|
if(store->pid->Compute() )
|
||||||
{
|
{
|
||||||
@@ -326,6 +326,7 @@ return 1;
|
|||||||
//break;
|
//break;
|
||||||
|
|
||||||
case S_CMD:
|
case S_CMD:
|
||||||
|
case S_CTRL:
|
||||||
{
|
{
|
||||||
aJsonObject * oCmd = aJson.getArrayItem(item->itemArg, 1);
|
aJsonObject * oCmd = aJson.getArrayItem(item->itemArg, 1);
|
||||||
short command = cmd.getCmd();
|
short command = cmd.getCmd();
|
||||||
@@ -347,15 +348,15 @@ case S_CMD:
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case CMD_ENABLE:
|
case CMD_ENABLE:
|
||||||
item->setCmd(CMD_ENABLE);
|
//item->setCmd(CMD_ENABLE);
|
||||||
item->SendStatus(FLAG_COMMAND);
|
//item->SendStatus(FLAG_COMMAND);
|
||||||
executeCommand(oCmd,-1,value);
|
executeCommand(oCmd,-1,value);
|
||||||
store->prevOut=-2.0;
|
store->prevOut=-2.0;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case CMD_DISABLE:
|
case CMD_DISABLE:
|
||||||
item->setCmd(CMD_DISABLE);
|
//item->setCmd(CMD_DISABLE);
|
||||||
item->SendStatus(FLAG_COMMAND);
|
//item->SendStatus(FLAG_COMMAND);
|
||||||
executeCommand(oCmd,-1,value);
|
executeCommand(oCmd,-1,value);
|
||||||
return 1;
|
return 1;
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ const char RGB_P[] PROGMEM = "RGB";
|
|||||||
const char VAL_P[] PROGMEM = "val";
|
const char VAL_P[] PROGMEM = "val";
|
||||||
const char DEL_P[] PROGMEM = "del";
|
const char DEL_P[] PROGMEM = "del";
|
||||||
const char _RAW_P[] PROGMEM = "raw";
|
const char _RAW_P[] PROGMEM = "raw";
|
||||||
|
const char CTRL_P[] PROGMEM = "ctrl";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
const char RPM_P[] PROGMEM = "rpm";
|
const char RPM_P[] PROGMEM = "rpm";
|
||||||
|
|||||||
Reference in New Issue
Block a user