void sleep_and_pump_messages( U32 seconds ) { const U32 CYCLES_PER_SECOND = 10; U32 cycles = seconds * CYCLES_PER_SECOND; while( cycles-- ) { update_messages(); ms_sleep(1000 / CYCLES_PER_SECOND); } }
void loop(void) { if((millis()-timer)>=20) // Main loop runs at 50Hz { if(loop_counter++ > 50) { loop_counter = 0; //Serial.println(millis() - timer); } updateTime(); update_messages(); update_motors(); update_inertial_sensors(); update_control(); } }
// What we wish to do here: Check for an active Send Message dialog // that contains the callsign of interest. If one doesn't exist, // create one and pop it up. We don't want to do this for duplicate // message lines or duplicate acks for any particular QSO. To do so // would cause the Send Message dialog to pop up on every such // received message, which is VERY annoying (that was the default in // Xastir for years, and nobody liked it!). // int check_popup_window(char *from_call_sign, int group) { int i,found,j,ret; char temp1[MAX_CALLSIGN+1]; char *temp_ptr; //fprintf(stderr,"\tcheck_popup_window()\n"); ret = -1; found = -1; begin_critical_section(&send_message_dialog_lock, "messages.c:check_popup_window" ); // Check for an already-created dialog for talking to this // particular call_sign. // for (i = 0; i < MAX_MESSAGE_WINDOWS; i++) { if (mw[i].send_message_dialog != NULL) { // If dialog created temp_ptr = XmTextFieldGetString(mw[i].send_message_call_data); xastir_snprintf(temp1, sizeof(temp1), "%s", temp_ptr); XtFree(temp_ptr); /*fprintf(stderr,"Looking at call <%s> for <%s>\n",temp1,from_call_sign);*/ if (strcasecmp(temp1, from_call_sign) == 0) { // Found a call_sign match in a Send Message dialog! //fprintf(stderr,"\tFound a Send_message dialog match\n"); found = i; break; } } } end_critical_section(&send_message_dialog_lock, "messages.c:check_popup_window" ); // If found == -1 at this point, we haven't found a Send Message // dialog that contains the call_sign of interest. // if (found == -1 && (group == 2 || group_active(from_call_sign))) { /* no window found Open one! */ //fprintf(stderr,"\tNo Send Message dialog found, creating one\n"); begin_critical_section(&send_message_dialog_lock, "messages.c:check_popup_window2" ); i= -1; for (j=0; j<MAX_MESSAGE_WINDOWS; j++) { if (!mw[j].send_message_dialog) { i=j; break; } } end_critical_section(&send_message_dialog_lock, "messages.c:check_popup_window2" ); if (i!= -1) { if (group == 1) { temp1[0] = '*'; temp1[1] = '\0'; } else { temp1[0] = '\0'; } strncat(temp1, from_call_sign, sizeof(temp1) - 1 - strlen(temp1)); if (!disable_all_popups) { Send_message(appshell, temp1, NULL); } update_messages(1); ret=i; } else { fprintf(stderr,"No open windows!\n"); } } else { /* window open! */ // Pop it up ret=found; } if (found != -1) { // Already have a window XtPopup(mw[i].send_message_dialog,XtGrabNone); } return(ret); }