Skip to content

Commit

Permalink
#8: replace busy polling with pthread_cond_wait
Browse files Browse the repository at this point in the history
Removed delays from PDA device on off
  • Loading branch information
ballle98 committed Jul 21, 2019
1 parent 2004f66 commit 4ab7911
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
9 changes: 4 additions & 5 deletions aq_programmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,10 @@ void *set_aqualink_SWG( void *ptr )

void *get_aqualink_aux_labels( void *ptr )
{
struct programmingThreadCtrl *threadCtrl;
threadCtrl = (struct programmingThreadCtrl *) ptr;
struct programmingThreadCtrl *threadCtrl =
(struct programmingThreadCtrl *) ptr;
struct aqualinkdata *aq_data = threadCtrl->aq_data;

waitForSingleThreadOrTerminate(threadCtrl, AQ_GET_AUX_LABELS);

if (pda_mode() == true) {
Expand Down Expand Up @@ -676,8 +676,7 @@ void *get_aqualink_aux_labels( void *ptr )

cleanAndTerminateThread(threadCtrl);

// just stop compiler error, ptr is not valid as it's just been freed
return ptr;
return NULL;
}

void *set_aqualink_light_colormode( void *ptr )
Expand Down
14 changes: 6 additions & 8 deletions pda_aq_programmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ bool goto_pda_menu(struct aqualinkdata *aq_data, pda_menu_type menu) {

while (pda_m_type() == PM_FW_VERSION || pda_m_type() == PM_BUILDING_HOME) {
//logMessage(LOG_DEBUG, "******************PDA Device programmer delay on firmware or building home menu\n");
// :TODO: remove this delay
delay(500);
}

Expand Down Expand Up @@ -329,15 +330,15 @@ void *set_aqualink_PDA_device_on_off( void *ptr )
if (device > TOTAL_BUTTONS) {
logMessage(LOG_ERR, "PDA Device On/Off :- bad device number '%d'\n",device);
cleanAndTerminateThread(threadCtrl);
return ptr;
return NULL;
}

logMessage(LOG_INFO, "PDA Device On/Off, device '%s', state %d\n",aq_data->aqbuttons[device].pda_label,state);

if (! goto_pda_menu(aq_data, PM_EQUIPTMENT_CONTROL)) {
logMessage(LOG_ERR, "PDA Device On/Off :- can't find main menu\n");
cleanAndTerminateThread(threadCtrl);
return ptr;
return NULL;
}

// If single config (Spa OR pool) rather than (Spa AND pool) heater is TEMP1 and TEMP2
Expand All @@ -352,24 +353,21 @@ void *set_aqualink_PDA_device_on_off( void *ptr )

if ( find_pda_menu_item(aq_data, device_name, 13) ) {
if (aq_data->aqbuttons[device].led->state != state) {
//printf("*** Select State ***\n");
logMessage(LOG_INFO, "PDA Device On/Off, found device '%s', changing state\n",aq_data->aqbuttons[device].pda_label,state);
send_cmd(KEY_PDA_SELECT);
while (get_aq_cmd_length() > 0) { delay(500); }
//while (get_aq_cmd_length() > 0) { delay(500); }
} else {
logMessage(LOG_INFO, "PDA Device On/Off, found device '%s', not changing state, is same\n",aq_data->aqbuttons[device].pda_label,state);
}
} else {
logMessage(LOG_ERR, "PDA Device On/Off, device '%s' not found\n",aq_data->aqbuttons[device].pda_label);
}

goto_pda_menu(aq_data, PM_HOME);
//while (_pgm_command != NUL) { delay(500); }
//goto_pda_menu(aq_data, PM_HOME);

cleanAndTerminateThread(threadCtrl);

// just stop compiler error, ptr is not valid as it's just been freed
return ptr;
return NULL;

}

Expand Down
1 change: 1 addition & 0 deletions pda_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ bool pda_m_clear()
logMessage(LOG_DEBUG, "PDA menu clear\n");

_hlightindex = -1;
//_pda_m_type = PM_UNKNOWN;
memset(_menu, 0, PDA_LINES * (AQ_MSGLEN+1));
return true;
}

0 comments on commit 4ab7911

Please sign in to comment.