|
@ -58,12 +58,13 @@ bool _curtain_initial_position_set = false; //Flag to detect if we manage to se |
|
|
bool _curtain_moving = true; |
|
|
bool _curtain_moving = true; |
|
|
|
|
|
|
|
|
//Enable more traces, true as a default and stopped when curtain is setup.
|
|
|
//Enable more traces, true as a default and stopped when curtain is setup.
|
|
|
bool _debug_flag = true; |
|
|
|
|
|
|
|
|
bool _curtain_debug_flag = true; |
|
|
|
|
|
|
|
|
#if WEB_SUPPORT
|
|
|
#if WEB_SUPPORT
|
|
|
bool _curtain_report_ws = true; //This will init curtain control and flag the web ui update
|
|
|
bool _curtain_report_ws = true; //This will init curtain control and flag the web ui update
|
|
|
#endif // WEB_SUPPORT
|
|
|
#endif // WEB_SUPPORT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
//------------------------------------------------------------------------------
|
|
|
void curtainUpdateUI() { |
|
|
void curtainUpdateUI() { |
|
|
#if WEB_SUPPORT
|
|
|
#if WEB_SUPPORT
|
|
@ -110,7 +111,7 @@ void _KACurtainSend(const char * tx_buffer) { |
|
|
KINGART_CURTAIN_PORT.print(tx_buffer); |
|
|
KINGART_CURTAIN_PORT.print(tx_buffer); |
|
|
KINGART_CURTAIN_PORT.print(KINGART_CURTAIN_TERMINATION); |
|
|
KINGART_CURTAIN_PORT.print(KINGART_CURTAIN_TERMINATION); |
|
|
KINGART_CURTAIN_PORT.flush(); |
|
|
KINGART_CURTAIN_PORT.flush(); |
|
|
if(_debug_flag) DEBUG_MSG_P(PSTR("[KAUART] Send : %s\n"), tx_buffer); |
|
|
|
|
|
|
|
|
if(_curtain_debug_flag) DEBUG_MSG_P(PSTR("[KAUART] Send : %s\n"), tx_buffer); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
//------------------------------------------------------------------------------
|
|
@ -173,7 +174,7 @@ void _KAStopMoving() { |
|
|
DEBUG_MSG_P(PSTR("[CURTAIN] No need to update bootup position\n")); |
|
|
DEBUG_MSG_P(PSTR("[CURTAIN] No need to update bootup position\n")); |
|
|
} |
|
|
} |
|
|
_curtain_initial_position_set = true; |
|
|
_curtain_initial_position_set = true; |
|
|
_debug_flag = false; //Disable debug - user has could ask for it
|
|
|
|
|
|
|
|
|
_curtain_debug_flag = false; //Disable debug - user has could ask for it
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -193,7 +194,7 @@ bool _KACurtainReceiveUART() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if(_KACurtainNewData) { |
|
|
if(_KACurtainNewData) { |
|
|
if(_debug_flag) DEBUG_MSG_P(PSTR("[KAUART] Received : %s\n"), _KACurtainBuffer); |
|
|
|
|
|
|
|
|
if(_curtain_debug_flag) DEBUG_MSG_P(PSTR("[KAUART] Received : %s\n"), _KACurtainBuffer); |
|
|
_KACurtainNewData = false; |
|
|
_KACurtainNewData = false; |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -379,6 +380,7 @@ void _curtainMQTTCallback(unsigned int type, const char * topic, char * payload) |
|
|
void _curtainWebSocketOnConnected(JsonObject& root) { |
|
|
void _curtainWebSocketOnConnected(JsonObject& root) { |
|
|
root["curtainType"] = getSetting("curtainType", "0"); |
|
|
root["curtainType"] = getSetting("curtainType", "0"); |
|
|
root["curtainInitialBehaviour"] = getSetting("curtainInitialBehaviour", "0"); |
|
|
root["curtainInitialBehaviour"] = getSetting("curtainInitialBehaviour", "0"); |
|
|
|
|
|
root["curtainConfig"] = 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
//------------------------------------------------------------------------------
|
|
@ -418,7 +420,7 @@ void _curtainWebSocketOnAction(uint32_t client_id, const char * action, JsonObje |
|
|
} |
|
|
} |
|
|
} else if (strcmp(action, "dbgcmd") == 0) { //Directly send our buffer to the KA serial
|
|
|
} else if (strcmp(action, "dbgcmd") == 0) { //Directly send our buffer to the KA serial
|
|
|
if(data["command"] == "debug") { |
|
|
if(data["command"] == "debug") { |
|
|
_debug_flag = true; |
|
|
|
|
|
|
|
|
_curtain_debug_flag = true; |
|
|
} else |
|
|
} else |
|
|
_KACurtainSend(data["command"]); |
|
|
_KACurtainSend(data["command"]); |
|
|
} |
|
|
} |
|
@ -456,6 +458,10 @@ void _KACurtainLoop() { |
|
|
#endif
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
// Public
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
//------------------------------------------------------------------------------
|
|
|
void kingartCurtainSetup() { |
|
|
void kingartCurtainSetup() { |
|
|
|
|
|
|
|
@ -482,5 +488,16 @@ void kingartCurtainSetup() { |
|
|
espurnaRegisterLoop(_KACurtainLoop); |
|
|
espurnaRegisterLoop(_KACurtainLoop); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
void curtainSetPosition(unsigned char id, long value) { |
|
|
|
|
|
if (id > 1) return; |
|
|
|
|
|
_KACurtainSet(CURTAIN_BUTTON_UNKNOWN, constrain(value, 0, 100)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unsigned char curtainCount() { |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // KINGART_CURTAIN_SUPPORT
|
|
|
#endif // KINGART_CURTAIN_SUPPORT
|