static C_RESULT ardrone_tool_configure() { if( configure_data[configure_index].var != NULL && configure_data[configure_index].value != NULL ) { ack_config.event = ACK_CONTROL_MODE; ack_config.num_retries = 20; ack_config.status = ARDRONE_CONTROL_EVENT_WAITING; ack_config.ardrone_control_event_start = NULL; ack_config.ardrone_control_event_end = ardrone_tool_end_configure; ack_config.ack_state = ACK_COMMAND_MASK_TRUE; ardrone_at_set_toy_configuration( configure_data[configure_index].var, configure_data[configure_index].value ); ardrone_at_send(); ardrone_control_send_event( (ardrone_control_event_t*)&ack_config ); } return C_OK; }
static void ardrone_tool_end_configure( struct _ardrone_control_event_t* event ) { if( event->status == ARDRONE_CONTROL_EVENT_FINISH_SUCCESS ) configure_index ++; if( configure_data[configure_index].var != NULL && configure_data[configure_index].value != NULL ) { ack_config.event = ACK_CONTROL_MODE; ack_config.num_retries = 20; ack_config.status = ARDRONE_CONTROL_EVENT_WAITING; ack_config.ardrone_control_event_start = NULL; ack_config.ardrone_control_event_end = ardrone_tool_end_configure; ack_config.ack_state = ACK_COMMAND_MASK_TRUE; ardrone_at_set_toy_configuration( configure_data[configure_index].var, configure_data[configure_index].value ); ardrone_at_send(); ardrone_control_send_event( (ardrone_control_event_t*)&ack_config ); } }
/*--------------------------------------------------------------------------------------------------------------------- Updates the AT command client by flushing pending commands. ---------------------------------------------------------------------------------------------------------------------*/ C_RESULT ardrone_tool_update() { int delta; C_RESULT res = C_OK; // Update subsystems & custom tool if( need_update ) { ardrone_timer_update(&ardrone_tool_timer); ardrone_tool_input_update(); res = ardrone_tool_update_custom(); if( send_com_watchdog == TRUE ) { ardrone_at_reset_com_watchdog(); send_com_watchdog = FALSE; } // Send all pushed messages ardrone_at_send(); need_update = FALSE; } delta = ardrone_timer_delta_ms(&ardrone_tool_timer); if( delta >= ArdroneToolRefreshTimeInMs) { // Render frame res = ardrone_tool_display_custom(); need_update = TRUE; } else { Sleep((ArdroneToolRefreshTimeInMs - delta)); } return res; }
C_RESULT ardrone_tool_update() { int delta; C_RESULT res = C_OK; //C_RESULT 是定义的宏 其对应的是int类型,C_OK也是,其对应的值是0 if( need_update ) { ardrone_timer_update(&ardrone_tool_timer);//更新时间,为什么要这么处理 ardrone_control(); res = ardrone_tool_update_custom(); if( send_com_watchdog == TRUE ) { ardrone_at_reset_com_watchdog(); send_com_watchdog = FALSE; }//watchdog看门狗防止程序出现死循环,不受控制 ardrone_at_send(); need_update = FALSE; } delta = ardrone_timer_delta_ms(&ardrone_tool_timer); if( delta >= ArdroneToolRefreshTimeInMs) { res = ardrone_tool_display_custom(); need_update = TRUE; } else { Sleep((ArdroneToolRefreshTimeInMs - delta)); } return res; }
C_RESULT ardrone_tool_update() { int delta; C_RESULT res = C_OK; delta = ardrone_timer_delta_us(&ardrone_tool_timer); if( delta >= ArdroneToolRefreshTimeInUs) { // Render frame ardrone_timer_update(&ardrone_tool_timer); if(!ardrone_tool_in_pause) { ardrone_tool_input_update(); res = ardrone_tool_update_custom(); } if( send_com_watchdog == TRUE ) { ardrone_at_reset_com_watchdog(); send_com_watchdog = FALSE; } // Send all pushed messages ardrone_at_send(); res = ardrone_tool_display_custom(); } else { usleep(ArdroneToolRefreshTimeInUs - delta); } return res; }