paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [4170] macros to functions


From: Felix Ruess
Subject: [paparazzi-commits] [4170] macros to functions
Date: Fri, 18 Sep 2009 11:57:01 +0000

Revision: 4170
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4170
Author:   flixr
Date:     2009-09-18 11:57:00 +0000 (Fri, 18 Sep 2009)
Log Message:
-----------
macros to functions

Modified Paths:
--------------
    paparazzi3/trunk/sw/airborne/booz/booz2_autopilot.c

Modified: paparazzi3/trunk/sw/airborne/booz/booz2_autopilot.c
===================================================================
--- paparazzi3/trunk/sw/airborne/booz/booz2_autopilot.c 2009-09-18 11:56:52 UTC 
(rev 4169)
+++ paparazzi3/trunk/sw/airborne/booz/booz2_autopilot.c 2009-09-18 11:57:00 UTC 
(rev 4170)
@@ -174,61 +174,61 @@
   (radio_control.values[RADIO_CONTROL_YAW] > BOOZ2_AUTOPILOT_YAW_TRESHOLD || \
    radio_control.values[RADIO_CONTROL_YAW] < -BOOZ2_AUTOPILOT_YAW_TRESHOLD)
 
-#define BOOZ2_AUTOPILOT_CHECK_IN_FLIGHT() {                            \
-    if (booz2_autopilot_in_flight) {                                   \
-      if (booz2_autopilot_in_flight_counter > 0) {                     \
-       if (THROTTLE_STICK_DOWN()) {                                    \
-         booz2_autopilot_in_flight_counter--;                          \
-         if (booz2_autopilot_in_flight_counter == 0) {                 \
-           booz2_autopilot_in_flight = FALSE;                          \
-         }                                                             \
-       }                                                               \
-       else {  /* !THROTTLE_STICK_DOWN */                              \
-         booz2_autopilot_in_flight_counter = BOOZ2_AUTOPILOT_IN_FLIGHT_TIME; \
-        }                                                              \
-      }                                                                        
\
-    }                                                                  \
-    else { /* not in flight */                                         \
-      if (booz2_autopilot_in_flight_counter < BOOZ2_AUTOPILOT_IN_FLIGHT_TIME 
&& \
-         booz2_autopilot_motors_on) {                                  \
-       if (!THROTTLE_STICK_DOWN()) {                                   \
-         booz2_autopilot_in_flight_counter++;                          \
-         if (booz2_autopilot_in_flight_counter == 
BOOZ2_AUTOPILOT_IN_FLIGHT_TIME) \
-           booz2_autopilot_in_flight = TRUE;                           \
-       }                                                               \
-       else { /*  THROTTLE_STICK_DOWN */                               \
-         booz2_autopilot_in_flight_counter = 0;                        \
-       }                                                               \
-      }                                                                        
\
-    }                                                                  \
+static inline void booz2_autopilot_check_in_flight() {                         
\
+  if (booz2_autopilot_in_flight) {
+    if (booz2_autopilot_in_flight_counter > 0) {
+      if (THROTTLE_STICK_DOWN()) {
+        booz2_autopilot_in_flight_counter--;
+        if (booz2_autopilot_in_flight_counter == 0) {
+          booz2_autopilot_in_flight = FALSE;
+        }
+      }
+      else {   /* !THROTTLE_STICK_DOWN */
+        booz2_autopilot_in_flight_counter = BOOZ2_AUTOPILOT_IN_FLIGHT_TIME;
+      }
+    }
   }
+  else { /* not in flight */
+    if (booz2_autopilot_in_flight_counter < BOOZ2_AUTOPILOT_IN_FLIGHT_TIME &&
+        booz2_autopilot_motors_on) {
+      if (!THROTTLE_STICK_DOWN()) {
+        booz2_autopilot_in_flight_counter++;
+        if (booz2_autopilot_in_flight_counter == 
BOOZ2_AUTOPILOT_IN_FLIGHT_TIME)
+          booz2_autopilot_in_flight = TRUE;
+      }
+      else { /*  THROTTLE_STICK_DOWN */
+        booz2_autopilot_in_flight_counter = 0;
+      }
+    }
+  }
+}
 
-#define BOOZ2_AUTOPILOT_CHECK_MOTORS_ON() {                            \
-    if (booz2_autopilot_motors_on) {                                   \
-      if (THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED()) {               \
-       if ( booz2_autopilot_motors_on_counter > 0) {                   \
-         booz2_autopilot_motors_on_counter--;                          \
-         if (booz2_autopilot_motors_on_counter == 0)                   \
-           booz2_autopilot_motors_on = FALSE;                          \
-       }                                                               \
-      }                                                                        
\
-      else { /* sticks not in the corner */                            \
-       booz2_autopilot_motors_on_counter = BOOZ2_AUTOPILOT_MOTOR_ON_TIME; \
-      }                                                                        
\
-    }                                                                  \
-    else { /* motors off */                                            \
-      if (THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED()) {               \
-       if ( booz2_autopilot_motors_on_counter <  
BOOZ2_AUTOPILOT_MOTOR_ON_TIME) { \
-         booz2_autopilot_motors_on_counter++;                          \
-         if (booz2_autopilot_motors_on_counter == 
BOOZ2_AUTOPILOT_MOTOR_ON_TIME) \
-           booz2_autopilot_motors_on = TRUE;                           \
-       }                                                               \
-      }                                                                        
\
-      else {                                                           \
-       booz2_autopilot_motors_on_counter = 0;                          \
-      }                                                                        
\
-    }                                                                  \
+static inline void booz2_autopilot_check_motors_on() {
+  if (booz2_autopilot_motors_on) {
+    if (THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED()) {
+      if ( booz2_autopilot_motors_on_counter > 0) {
+        booz2_autopilot_motors_on_counter--;
+        if (booz2_autopilot_motors_on_counter == 0)
+          booz2_autopilot_motors_on = FALSE;
+      }
+    }
+    else { /* sticks not in the corner */
+      booz2_autopilot_motors_on_counter = BOOZ2_AUTOPILOT_MOTOR_ON_TIME;
+    }
   }
+  else { /* motors off */
+    if (THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED()) {
+      if ( booz2_autopilot_motors_on_counter <  BOOZ2_AUTOPILOT_MOTOR_ON_TIME) 
{
+        booz2_autopilot_motors_on_counter++;
+        if (booz2_autopilot_motors_on_counter == BOOZ2_AUTOPILOT_MOTOR_ON_TIME)
+          booz2_autopilot_motors_on = TRUE;
+      }
+    }
+    else {
+      booz2_autopilot_motors_on_counter = 0;
+    }
+  }
+}
 
 
 
@@ -243,8 +243,8 @@
     booz2_autopilot_set_mode(BOOZ2_AP_MODE_KILL);
 #endif
 
-  BOOZ2_AUTOPILOT_CHECK_MOTORS_ON();
-  BOOZ2_AUTOPILOT_CHECK_IN_FLIGHT();
+  booz2_autopilot_check_motors_on();
+  booz2_autopilot_check_in_flight();
   kill_throttle = !booz2_autopilot_motors_on;
 
   if (booz2_autopilot_mode > BOOZ2_AP_MODE_FAILSAFE) {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]