ballle98/AqualinkD#81: Add support for boost and freeze protect to equiptment_update_cycle

pull/249/head
Lee Ballard 2023-07-27 21:59:13 -05:00
parent 636892e494
commit 79cf3e8c94
3 changed files with 51 additions and 16 deletions

View File

@ -75,4 +75,9 @@ int PANEL_SIZE();
void initButtons_RS16(struct aqualinkdata *aqdata);
#endif
// Used in equiptment_update_cycle() for additional items on EQUIPMENT STATUS
// TOTAL_BUTTONS is at most 20 so bits 21-31 should be available
#define BOOST_INDEX 21
#define FREEZE_PROTECT_INDEX 22
#endif

50
pda.c
View File

@ -133,18 +133,21 @@ void set_pda_led(struct aqualinkled *led, char state)
}
}
// :TODO: Test what happens if there are more devices on than can fit on the status page
// :TODO: If web page is up PDA will not sleep therefore there is no wake and seeing
// the equipment page. Need to add support for determining filter pump on/off based on home
void equiptment_update_cycle(int eqID) {
// If you have a -1, it's a reset to clear / update information.
// TOTAL_BUTTONS is 20 so bits 21-31 available for BOOST, FREEZE PROTECT, etc.
int i;
// :TODO: need to add freeze protect and boost support to bitmask, perhaps sercive_mode
// TOTAL_BUTTONS is 20 so bits 21-31 should be available
static uint32_t update_equiptment_bitmask = 0;
if (eqID == -1) {
LOG(PDA_LOG,LOG_DEBUG, "Start new equipment cycle\n");
LOG(PDA_LOG,LOG_DEBUG, "Start new equipment cycle bitmask 0x%04x\n",
update_equiptment_bitmask);
for (i=0; i < _aqualink_data->total_buttons - 2 ; i++) { // total_buttons - 2 because we don't get heaters in this cycle
if ((update_equiptment_bitmask & (1 << (i+1))) != (1 << (i+1))) {
if ((update_equiptment_bitmask & (1 << (i))) != (1 << (i))) {
if (_aqualink_data->aqbuttons[i].led->state != OFF) {
_aqualink_data->aqbuttons[i].led->state = OFF;
_aqualink_data->updated = true;
@ -152,18 +155,35 @@ void equiptment_update_cycle(int eqID) {
}
}
}
// :TODO: This needs to go into the equipment status processing to turn FP off
// if (_aqualink_data->frz_protect_state == ON) {
// _aqualink_data->frz_protect_state = ENABLE;
// }
// :TODO: This needs to go into the equipment status processing to turn boost off
// if (_aqualink_data->boost) {
// setSWGboost(_aqualink_data, false);
// }
if ((_aqualink_data->frz_protect_state == ON) &&
(! (update_equiptment_bitmask & (1 << FREEZE_PROTECT_INDEX)))) {
LOG(PDA_LOG,LOG_DEBUG, "Turn off freeze protect not seen in last cycle\n");
_aqualink_data->frz_protect_state = ENABLE;
}
if ((_aqualink_data->boost) &&
(! (update_equiptment_bitmask & (1 << BOOST_INDEX)))) {
LOG(PDA_LOG,LOG_DEBUG, "Turn off BOOST not seen in last cycle\n");
setSWGboost(_aqualink_data, false);
}
update_equiptment_bitmask = 0;
} else if ((eqID >= 0) && (eqID < 32)) {
update_equiptment_bitmask |= (1 << (eqID));
char *eqName = NULL;
if (eqID < _aqualink_data->total_buttons) {
eqName = _aqualink_data->aqbuttons[eqID].name;
} else if (eqID == FREEZE_PROTECT_INDEX) {
eqName = "FREEZE PROTECT";
} else if (eqID == BOOST_INDEX) {
eqName = "BOOST";
} else {
eqName = "UNKNOWN";
}
LOG(PDA_LOG,LOG_DEBUG, "Added equipment id %d %s to updated cycle bitmask 0x%04x\n",
eqID, eqName, update_equiptment_bitmask);
} else {
update_equiptment_bitmask |= (1 << (eqID+1));
LOG(PDA_LOG,LOG_DEBUG, "Added equiptment id %d %s to updated cycle\n", eqID, _aqualink_data->aqbuttons[eqID].name);
LOG(PDA_LOG,LOG_ERR, "equiptment_update_cycle(%d) - Invalid eqID\n", eqID);
}
}
@ -648,11 +668,13 @@ void process_pda_packet_msg_long_equiptment_status(const char *msg_line, int lin
else if ((index = rsm_strncasestr(msg, "FREEZE PROTECT", AQ_MSGLEN)) != NULL)
{
_aqualink_data->frz_protect_state = ON;
equiptment_update_cycle(FREEZE_PROTECT_INDEX);
LOG(PDA_LOG,LOG_DEBUG, "Freeze Protect is on\n");
}
else if ((index = rsm_strncasestr(msg, "BOOST", AQ_MSGLEN)) != NULL)
{
setSWGboost(_aqualink_data, true);
equiptment_update_cycle(BOOST_INDEX);
}
else if ((_aqualink_data->boost) && ((index = rsm_strncasestr(msg, "REMAIN", AQ_MSGLEN)) != NULL))
{

View File

@ -238,7 +238,12 @@ bool process_pda_menu_packet(unsigned char* packet, int length, bool force_print
strncpy(_menu[index], (char*)packet+PKT_DATA+1, AQ_MSGLEN);
_menu[index][AQ_MSGLEN] = '\0';
}
if (getLogLevel(PDA_LOG) >= LOG_DEBUG && force_print_menu ){print_menu();}
if ((getLogLevel(PDA_LOG) >= LOG_DEBUG) && force_print_menu ){
print_menu();
printed_page = true;
} else {
printed_page = false;
}
break;
case CMD_PDA_HIGHLIGHT:
// when switching from hlight to hlightchars index 255 is sent to turn off hlight
@ -252,7 +257,10 @@ bool process_pda_menu_packet(unsigned char* packet, int length, bool force_print
_hlightcharindexstop = -1;
}
//if (getLogLevel(PDA_LOG) >= LOG_DEBUG){print_menu();}
if (getLogLevel(PDA_LOG) >= LOG_DEBUG && force_print_menu ){print_menu();}
if (getLogLevel(PDA_LOG) >= LOG_DEBUG && force_print_menu ){
print_menu();
printed_page = true;
}
break;
case CMD_PDA_HIGHLIGHTCHARS:
// pkt[4] = line, pkt[5] = startchar, pkt[6] = endchar, pkt[7] = clr/inv