Skip to content

Commit

Permalink
#65: SWG percentage setting not working for PDA
Browse files Browse the repository at this point in the history
  • Loading branch information
ballle98 committed May 31, 2022
1 parent 12e537e commit 8c9ab10
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 132 deletions.
8 changes: 4 additions & 4 deletions aq_programmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ void aq_programmer(program_type r_type, char *args, struct aqualinkdata *aq_data
LOG(PROG_LOG, LOG_ERR, "could not create thread\n");
return;
}
break;
#endif
#ifdef AQ_PDA
case AQ_PDA_INIT:
Expand Down Expand Up @@ -1202,10 +1203,9 @@ void *set_aqualink_SWG( void *ptr )

#ifdef AQ_PDA
if (isPDA_PANEL) {
if (set_PDA_aqualink_SWG_setpoint(aq_data, val))
setSWGpercent(aq_data, val); // Don't use chageSWGpercent as we are in programming mode.
cleanAndTerminateThread(threadCtrl);
return ptr;
set_PDA_aqualink_SWG_setpoint(aq_data, val);
cleanAndTerminateThread(threadCtrl);
return ptr;
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion aqualinkd.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ void action_delayed_request()
{
//LOG(AQUA_LOG,LOG_NOTICE, "SWG BOST to %d\n", _aqualink_data.unactioned.value);
//if (_aqualink_data.ar_swg_status == SWG_STATUS_OFF) {
if (_aqualink_data.swg_led_state == OFF) {
if ((_aqualink_data.swg_led_state == OFF) && (_aqualink_data.boost == false)) {
LOG(AQUA_LOG,LOG_ERR, "SWG is off, can't Boost pool\n");
} else if (_aqualink_data.unactioned.value == _aqualink_data.boost ) {
LOG(AQUA_LOG,LOG_ERR, "Request to turn Boost %s ignored, Boost is already %s\n",_aqualink_data.unactioned.value?"On":"Off", _aqualink_data.boost?"On":"Off");
Expand Down
3 changes: 2 additions & 1 deletion devices_jandy.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ bool setSWGboost(struct aqualinkdata *aqdata, bool on) {
} else {
aqdata->boost = true;
aqdata->swg_percent = 101;
aqdata->swg_led_state = ON;
}

return true;
Expand Down Expand Up @@ -401,4 +402,4 @@ Debug: To ePump: Jandy Packet | HEX: 0x10|0x02|0x78|0x44|0x00|0x58|0x1b|0x
Debug: To ePump: Jandy Packet | HEX: 0x10|0x02|0x78|0x45|0x00|0x05|0xd4|0x10|0x03|
Debug: To ePump: Jandy Packet | HEX: 0x10|0x02|0x78|0x46|0x00|0x00|0x03|0xd3|0x10|0x03|
Debug: To ePump: Jandy Packet | HEX: 0x10|0x02|0x78|0x46|0x00|0x04|0x00|0xd4|0x10|0x03|
*/
*/
72 changes: 46 additions & 26 deletions pda.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ void pass_pda_equiptment_status_item(char *msg)
// RPM: 1700
// Watts: 367
//
// EQUIPMENT STATUS
//
//
//
//
// BOOST
// 23:59 REMAIN
// SALT 25500 PPM
// FILTER PUMP

// Check message for status of device
// Loop through all buttons and match the PDA text.
Expand All @@ -173,6 +175,14 @@ void pass_pda_equiptment_status_item(char *msg)
{
_aqualink_data->frz_protect_state = ON;
}
else if ((index = strcasestr(msg, "BOOST")) != NULL)
{
setSWGboost(_aqualink_data, true);
}
else if ((_aqualink_data->boost) && ((index = strcasestr(msg, "REMAIN")) != NULL))
{
snprintf(_aqualink_data->boost_msg, sizeof(_aqualink_data->boost_msg), "%s", msg+2);
}
else if ((index = strcasestr(msg, MSG_SWG_PCT)) != NULL)
{
changeSWGpercent(_aqualink_data, atoi(index + strlen(MSG_SWG_PCT)));
Expand Down Expand Up @@ -323,14 +333,13 @@ void process_pda_packet_msg_long_equipment_control(const char *msg)
{
LOG(PDA_LOG,LOG_DEBUG, "*** Found EQ CTL Status for %s = '%.*s'\n", _aqualink_data->aqbuttons[i].label, AQ_MSGLEN, msg);
set_pda_led(_aqualink_data->aqbuttons[i].led, msg[AQ_MSGLEN - 1]);
// Force SWG off if pump is off.
if ((i==0) && (_aqualink_data->aqbuttons[0].led->state == OFF )) {
setSWGoff(_aqualink_data);
}
}
}

// Force SWG off if pump is off.
if (_aqualink_data->aqbuttons[0].led->state == OFF )
setSWGoff(_aqualink_data);
//_aqualink_data->ar_swg_status = SWG_STATUS_OFF;

// NSF I think we need to check TEMP1 and TEMP2 and set Pool HEater and Spa heater directly, to support single device.
if (isSINGLE_DEV_PANEL){
if (strcasecmp(stripwhitespace(labelBuff), "TEMP1") == 0)
Expand Down Expand Up @@ -471,27 +480,33 @@ void process_pda_packet_msg_long_freeze_protect(const char *msg)

void process_pda_packet_msg_long_SWG(const char *msg)
{
//PDA Line 0 = SET AquaPure
//PDA Line 1 =
//PDA Line 2 =
//PDA Line 3 = SET POOL TO: 45%
//PDA Line 4 = SET SPA TO: 0%
// Single Setpoint
// PDA Line 0 = SET AquaPure
// PDA Line 1 =
// PDA Line 2 =
// PDA Line 3 = SET TO 100%

// Dual Setpoint
// PDA Line 0 = SET AquaPure
// PDA Line 1 =
// PDA Line 2 =
// PDA Line 3 = SET POOL TO: 45%
// PDA Line 4 = SET SPA TO: 0%

// If spa is on, read SWG for spa, if not set SWG for pool
if (_aqualink_data->aqbuttons[SPA_INDEX].led->state != OFF) {
if (strncasecmp(msg, "SET SPA TO:", 11) == 0)
{
if (strncasecmp(msg+3, "SET TO", 6) == 0) {
setSWGpercent(_aqualink_data, atoi(msg + 10));
LOG(PDA_LOG,LOG_DEBUG, "swg_percent = %d\n", _aqualink_data->swg_percent);
} else if (_aqualink_data->aqbuttons[SPA_INDEX].led->state != OFF) {
if (strncasecmp(msg+1, "SET SPA TO:", 11) == 0) {
//_aqualink_data->swg_percent = atoi(msg + 13);
setSWGpercent(_aqualink_data, atoi(msg + 13));
setSWGpercent(_aqualink_data, atoi(msg + 12));
LOG(PDA_LOG,LOG_DEBUG, "SPA swg_percent = %d\n", _aqualink_data->swg_percent);
}
} else {
if (strncasecmp(msg, "SET POOL TO:", 12) == 0)
{
} else if (strncasecmp(msg, "SET POOL TO:", 12) == 0) {
//_aqualink_data->swg_percent = atoi(msg + 13);
setSWGpercent(_aqualink_data, atoi(msg + 13));
setSWGpercent(_aqualink_data, atoi(msg + 12));
LOG(PDA_LOG,LOG_DEBUG, "POOL swg_percent = %d\n", _aqualink_data->swg_percent);
}
}
}

Expand Down Expand Up @@ -660,15 +675,20 @@ bool process_pda_packet(unsigned char *packet, int length)
// Note: if the last line of the status menu is present it may be cut off
if (pda_m_type() == PM_EQUIPTMENT_STATUS)
{
if (_aqualink_data->frz_protect_state == ON)
if (_aqualink_data->frz_protect_state == ON) {
_aqualink_data->frz_protect_state = ENABLE;

}
//if (_aqualink_data->ar_swg_status == SWG_STATUS_ON)
// _aqualink_data->ar_swg_status = SWG_STATUS_OFF;

if (_aqualink_data->swg_led_state == ON)
if (_aqualink_data->swg_led_state == ON) {
setSWGenabled(_aqualink_data);

}

if (_aqualink_data->boost) {
setSWGboost(_aqualink_data, false);
}

if (pda_m_line(PDA_LINES - 1)[0] == '\0')
{
for (i = 0; i < _aqualink_data->total_buttons; i++)
Expand Down
Loading

0 comments on commit 8c9ab10

Please sign in to comment.