mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
Fine tuning & bugfixing (Forced white, short-off)
This commit is contained in:
@@ -551,7 +551,7 @@ else if (store->delayedState)
|
|||||||
|
|
||||||
aJsonObject *cmd = NULL;
|
aJsonObject *cmd = NULL;
|
||||||
int8_t toggle=0;
|
int8_t toggle=0;
|
||||||
|
if (newState!=store->state) debugSerial<<F("#")<<pin<<F(" ")<<store->state<<F("->") <<newState<<endl;
|
||||||
switch (newState)
|
switch (newState)
|
||||||
{
|
{
|
||||||
case IS_IDLE:
|
case IS_IDLE:
|
||||||
@@ -612,7 +612,7 @@ int8_t toggle=0;
|
|||||||
toggle=store->toggle2;
|
toggle=store->toggle2;
|
||||||
break;
|
break;
|
||||||
case IS_REPEAT2: //rpcmd2
|
case IS_REPEAT2: //rpcmd2
|
||||||
cmd = aJson.getObjectItem(inputObj, "rpcmd2");
|
cmd = aJson.getObjectItem(inputObj, "rpcmd2");
|
||||||
toggle=store->toggle2;
|
toggle=store->toggle2;
|
||||||
break;
|
break;
|
||||||
case IS_LONG3: //lcmd3
|
case IS_LONG3: //lcmd3
|
||||||
@@ -758,11 +758,13 @@ switch (store->state) //Timer based transitions
|
|||||||
{
|
{
|
||||||
case IS_IDLE:
|
case IS_IDLE:
|
||||||
res = changeState(IS_PRESSED, cause);
|
res = changeState(IS_PRESSED, cause);
|
||||||
|
if (!aJson.getObjectItem(inputObj, "lcmd") && !aJson.getObjectItem(inputObj, "rpcmd")) changeState(IS_WAITRELEASE, cause);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IS_RELEASED:
|
case IS_RELEASED:
|
||||||
case IS_WAITPRESS:
|
case IS_WAITPRESS:
|
||||||
res = changeState(IS_PRESSED2, cause);
|
res = changeState(IS_PRESSED2, cause);
|
||||||
|
if (!aJson.getObjectItem(inputObj, "lcmd2") && !aJson.getObjectItem(inputObj, "rpcmd2")) changeState(IS_WAITRELEASE, cause);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IS_RELEASED2:
|
case IS_RELEASED2:
|
||||||
@@ -774,6 +776,7 @@ switch (store->state) //Timer based transitions
|
|||||||
switch (store->state) //Button released state transitions
|
switch (store->state) //Button released state transitions
|
||||||
{
|
{
|
||||||
case IS_PRESSED:
|
case IS_PRESSED:
|
||||||
|
case IS_WAITRELEASE:
|
||||||
res = changeState(IS_RELEASED, cause);
|
res = changeState(IS_RELEASED, cause);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ e-mail anklimov@gmail.com
|
|||||||
#define IS_PRESSED3 10u
|
#define IS_PRESSED3 10u
|
||||||
#define IS_LONG3 11u
|
#define IS_LONG3 11u
|
||||||
#define IS_REPEAT3 12u
|
#define IS_REPEAT3 12u
|
||||||
|
#define IS_WAITRELEASE 13u
|
||||||
#define IS_REQSTATE 0xFF
|
#define IS_REQSTATE 0xFF
|
||||||
|
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ e-mail anklimov@gmail.com
|
|||||||
|
|
||||||
|
|
||||||
#define T_LONG 1000
|
#define T_LONG 1000
|
||||||
#define T_IDLE 700
|
#define T_IDLE 600
|
||||||
#define T_RPT 300
|
#define T_RPT 300
|
||||||
#define T_RPT_PULSE 150
|
#define T_RPT_PULSE 150
|
||||||
|
|
||||||
|
|||||||
@@ -520,6 +520,29 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
|
|||||||
CHstore st;
|
CHstore st;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
int t;
|
int t;
|
||||||
|
case CMD_ON:
|
||||||
|
if (getChanType()==CH_RGBW && getCmd() == CMD_ON && send && (chActive>0)) {
|
||||||
|
debugSerial<<F("Force White\n");
|
||||||
|
st.aslong = getVal();
|
||||||
|
//itemType = CH_WHITE;
|
||||||
|
Par[0] = st.h;
|
||||||
|
Par[1] = 0; //Zero saturation
|
||||||
|
Par[2] = 100; //Full power
|
||||||
|
n=3;
|
||||||
|
cmd=CMD_NUM;
|
||||||
|
// Store
|
||||||
|
/*
|
||||||
|
st.h = Par[0];
|
||||||
|
st.s = Par[1];
|
||||||
|
st.v = Par[2];
|
||||||
|
setVal(st.aslong);
|
||||||
|
setCmd(cmd);
|
||||||
|
//Send to OH
|
||||||
|
if (send) SendStatus(SEND_COMMAND | SEND_PARAMETERS ); */
|
||||||
|
} // if forcewhite
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case CMD_TOGGLE:
|
case CMD_TOGGLE:
|
||||||
if (chActive>0) cmd = CMD_OFF;
|
if (chActive>0) cmd = CMD_OFF;
|
||||||
else cmd = CMD_ON;
|
else cmd = CMD_ON;
|
||||||
@@ -618,21 +641,28 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
|
|||||||
break;
|
break;
|
||||||
case CMD_NUM:
|
case CMD_NUM:
|
||||||
if (itemType == CH_GROUP || n!=1) break;
|
if (itemType == CH_GROUP || n!=1) break;
|
||||||
st.aslong = getVal();
|
|
||||||
switch (suffixCode)
|
|
||||||
{
|
|
||||||
case S_SAT:
|
|
||||||
Par[1] = Par[0];
|
|
||||||
Par[0] = st.h;
|
|
||||||
Par[2] = st.v;
|
|
||||||
n=3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case S_HUE:
|
int cType=getChanType();
|
||||||
Par[1] = st.s;
|
if ( cType == CH_RGB || cType == CH_RGBW)
|
||||||
Par[2] = st.v;
|
{
|
||||||
n=3;
|
st.aslong = getVal();
|
||||||
}
|
switch (suffixCode)
|
||||||
|
{
|
||||||
|
case S_SAT:
|
||||||
|
Par[1] = Par[0];
|
||||||
|
Par[0] = st.h;
|
||||||
|
Par[2] = st.v;
|
||||||
|
n=3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_HUE:
|
||||||
|
Par[1] = st.s;
|
||||||
|
Par[2] = st.v;
|
||||||
|
n=3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Non-color channel
|
||||||
|
if (suffixCode == S_SAT || suffixCode == S_HUE) return -3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,6 +727,7 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
|
|||||||
case 0: // No command - set params
|
case 0: // No command - set params
|
||||||
|
|
||||||
if (!suffixCode) toExecute= true;
|
if (!suffixCode) toExecute= true;
|
||||||
|
if (suffixCode == S_HUE || suffixCode == S_SAT) break;
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
|
|
||||||
case CH_RGBW: //only if configured VAL array
|
case CH_RGBW: //only if configured VAL array
|
||||||
@@ -733,10 +764,15 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
|
|||||||
if (!suffixCode)
|
if (!suffixCode)
|
||||||
{ //
|
{ //
|
||||||
if (chActive>0 && !st.v) setCmd(CMD_OFF);
|
if (chActive>0 && !st.v) setCmd(CMD_OFF);
|
||||||
if (chActive==0 && st.v) setCmd(CMD_ON);
|
else if (chActive==0 && st.v) setCmd(CMD_ON);
|
||||||
|
else setCmd(0);
|
||||||
SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
|
SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
|
||||||
}
|
}
|
||||||
else SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
|
else
|
||||||
|
{
|
||||||
|
setCmd(0);
|
||||||
|
SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CH_PWM:
|
case CH_PWM:
|
||||||
case CH_VC:
|
case CH_VC:
|
||||||
@@ -773,25 +809,7 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
|
|||||||
debugSerial<<F("Already Active\n");
|
debugSerial<<F("Already Active\n");
|
||||||
if (itemType != CH_GROUP) return -3;
|
if (itemType != CH_GROUP) return -3;
|
||||||
}
|
}
|
||||||
case CMD_ON:
|
case CMD_ON:
|
||||||
|
|
||||||
|
|
||||||
if (itemType==CH_RGBW && getCmd() == CMD_ON && send && (chActive>0)/*&& getEnableCMD(500) */) {
|
|
||||||
debugSerial<<F("Force White\n");
|
|
||||||
itemType = CH_WHITE;
|
|
||||||
Par[1] = 0; //Zero saturation
|
|
||||||
Par[2] = 100; //Full power
|
|
||||||
// Store
|
|
||||||
st.h = Par[0];
|
|
||||||
st.s = Par[1];
|
|
||||||
st.v = Par[2];
|
|
||||||
setVal(st.aslong);
|
|
||||||
setCmd(cmd);
|
|
||||||
//Send to OH
|
|
||||||
if (send) SendStatus(SEND_COMMAND | SEND_PARAMETERS );
|
|
||||||
break;
|
|
||||||
} // if forcewhite
|
|
||||||
|
|
||||||
case CMD_COOL:
|
case CMD_COOL:
|
||||||
case CMD_AUTO:
|
case CMD_AUTO:
|
||||||
case CMD_HEAT:
|
case CMD_HEAT:
|
||||||
@@ -890,28 +908,7 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
|
|||||||
for (short i = 0; i < params; i++) {
|
for (short i = 0; i < params; i++) {
|
||||||
debugSerial<<F("Restored: ")<<i<<F("=")<<Par[i]<<endl;
|
debugSerial<<F("Restored: ")<<i<<F("=")<<Par[i]<<endl;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
} else { //Double ON - apply special preset - clean white full power
|
|
||||||
if (getEnableCMD(500)) switch (itemType) {
|
|
||||||
case CH_RGBW:
|
|
||||||
debugSerial<<F("Force White"));
|
|
||||||
itemType = CH_WHITE;
|
|
||||||
Par[1] = 0; //Zero saturation
|
|
||||||
Par[2] = 100; //Full power
|
|
||||||
|
|
||||||
// Store
|
|
||||||
st.h = Par[0];
|
|
||||||
st.s = Par[1];
|
|
||||||
st.v = Par[2];
|
|
||||||
setVal(st.aslong);
|
|
||||||
|
|
||||||
//Send to OH
|
|
||||||
if (send) SendStatus(0, 3, Par);
|
|
||||||
break;
|
|
||||||
} //itemtype
|
|
||||||
} //else
|
|
||||||
*/
|
|
||||||
//debugSerial<<"Sa:");debugSerial<<Par[1]);
|
|
||||||
if ((itemType == CH_RGBW) && (Par[1] == 0)) itemType = CH_WHITE;
|
if ((itemType == CH_RGBW) && (Par[1] == 0)) itemType = CH_WHITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#define FM_OVERHEAT_CELSIUS 40.
|
#define FM_OVERHEAT_CELSIUS 40.
|
||||||
|
|
||||||
#define MIN_VOLUME 25
|
#define MIN_VOLUME 25
|
||||||
#define INIT_VOLUME 50
|
#define INIT_VOLUME 40
|
||||||
|
|
||||||
#define MAXFLASHSTR 32
|
#define MAXFLASHSTR 32
|
||||||
#define PWDFLASHSTR 16
|
#define PWDFLASHSTR 16
|
||||||
|
|||||||
Reference in New Issue
Block a user