Merry Christmas everyone.I wanted to talk about a new aspect of 2.5 that enables coders to easily program missions through a simple API. The main idea is that many common events are sent to functions in the event.pde file to be handled by you in any way you see fit. You can do anything and access any variable in the system - within reason. The events.pde file can be swapped out with a different mission and uploaded to the the hardware.The first and most important event is the switch_event. This event is called when the 3-position switch on the radio has changed. The function set_mode(MODE) is called and the argument is one of the following flight modes:MANUAL - complete radio controlSTABILIZE - uses IR sensors to stabilize the aircraftFLY_BY_WIRE - allows the user to "steer" the aircraft using autopilot control loopsAUTO - exactly what you thinkRTL - Fly home nowLOITER - Circle around current location (set when aircraft arrives at home during RTL)An example of setting the current waypoint back to the index 1 is shown when the switch is in manual position.void switch_event(byte switchPosition){ switch(switchPosition) { case 1: // First position set_mode(MANUAL); // this is handy function to restart your mission: reset_waypoint_index(); break; case 2: // middle position set_mode(AUTO); break; case 3: // last position set_mode(STABILIZE); break; }}The next most important event is a waypoint event. There are a few basic events called (more will be added as necessary.) In the example below Loiter mode is turned on when we load WP 3. The variable elapsedTime is set to 0 ( elapsedTime is a user defined timer that increments in milliseconds.) If you want to stop Loitering after a set number of seconds, see the next example below.void waypoint_event(byte event){ switch(event) { case EVENT_WILL_REACH_WAYPOINT: // called just before wp_index is incemented Serial.print("Reached WP:"); Serial.println(wp_index,DEC); break; case EVENT_SET_NEW_WAYPOINT_INDEX: // called just after wp_index is incemented Serial.print("Now going to WP:"); Serial.println(wp_index,DEC); break; case EVENT_LOADED_WAYPOINT: // called just after wp is loaded from memory Serial.print("Loaded WP index: "); Serial.println(wp_index,DEC); print_current_waypoint(); // custom loitering code if (wp_index == 3){ set_mode(LOITER); elapsedTime = 0; } break; // called when the pattern to be flown is automatically restarted case EVENT_LOOP: Serial.println("Looped WP Index"); print_current_waypoint(); break; }}The mainLoop_event is called with every execution of the control loop. Here is a good place to check the elapsedTime variable to escape Loiter mode and continue on with the mission.// called AFTER every control loopvoid mainLoop_event(void){ if (control_mode == LOITER){ if (wp_index == 2 && elapsedTime > 120000 ){ // 2 minutes elapsedTime = 0; // our waypoints index is not altered during LOITER // All we need to do is reload the waypoint load_waypoint(); // and return to Autopilot mode! set_mode(AUTO); } }}Other events include:void gps_event(void)void low_battery_event(void)void failsafe_event()More will be added as necessary, and of course, you can add your own.JasonNext installment - The Mission Simulator