ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / Examples / Linux / Protocol / app.h
1 /*
2  * AR Drone demo
3  *
4  * code originally nased on:"San Angeles" Android demo app
5  */
6
7 #ifndef APP_H_INCLUDED
8 #define APP_H_INCLUDED
9
10 #include <stdint.h>
11 #include <sys/types.h>
12 #include <unistd.h>
13 #include <pthread.h>
14
15 /* native video stream dimensions */
16 #define VIDEO_WIDTH   176
17 #define VIDEO_HEIGHT  144
18
19 #ifdef BUILD_OGLES
20 extern uint16_t default_image[VIDEO_WIDTH*VIDEO_HEIGHT];
21 #endif
22
23 extern int num_picture_decoded;
24 extern uint16_t picture_buf[];
25
26 extern void appInit();
27 extern void appDeinit();
28 extern void appRender(long tick, int width, int height);
29
30 extern void video_init(void);
31 extern void video_deinit(void);
32 extern void video_render(long tick, int width, int height);
33
34 void get_screen_dimensions(int *w, int *h);
35 void set_screen_dimensions(int w, int h);
36
37 /* Value is non-zero when application is alive, and 0 when it is closing.
38  * Defined by the application framework.
39  */
40 #define INFO(_fmt_, args...)   \
41 printf(_fmt_, ##args)                                        \
42
43 /*#define INFO(_fmt_, args...)                                        \
44     __android_log_print(ANDROID_LOG_INFO, "ARDrone", _fmt_, ##args)
45 */
46 #define GETPROP(_name_,_val_) __system_property_get((_name_),(_val_))
47
48 #ifndef TRUE
49 #define TRUE 1
50 #endif
51 #ifndef FALSE
52 #define FALSE 0
53 #endif
54
55 typedef float float32_t;
56 #define bool_t  int32_t
57
58 #define MYKONOS_REFRESH_MS        28
59 #define WIFI_MYKONOS_IP           "192.168.1.1"
60
61 extern uint32_t mykonos_state;
62
63 enum {
64   NO_CONTROL_MODE = 0,          // Doing nothing
65   MYKONOS_UPDATE_CONTROL_MODE,  // Mykonos software update reception (update is done next run)
66                                 // After event completion, card should power off
67   PIC_UPDATE_CONTROL_MODE,      // Mykonos pic software update reception (update is done next run)
68                                 // After event completion, card should power off
69   LOGS_GET_CONTROL_MODE,        // Send previous run's logs
70   CFG_GET_CONTROL_MODE,         // Send activ configuration
71   ACK_CONTROL_MODE              // Reset command mask in navdata
72 };
73
74 enum {
75   MYKONOS_FLY_MASK            = 1 << 0, /*!< FLY MASK : (0) mykonos is landed, (1) mykonos is flying */
76   MYKONOS_VIDEO_MASK          = 1 << 1, /*!< VIDEO MASK : (0) video disable, (1) video enable */
77   MYKONOS_VISION_MASK         = 1 << 2, /*!< VISION MASK : (0) vision disable, (1) vision enable */
78   MYKONOS_CONTROL_MASK        = 1 << 3, /*!< CONTROL ALGO : (0) euler angles control, (1) angular speed control */
79   MYKONOS_ALTITUDE_MASK       = 1 << 4, /*!< ALTITUDE CONTROL ALGO : (0) altitude control inactive (1) altitude control active */
80   MYKONOS_USER_FEEDBACK_START = 1 << 5, /*!< USER feedback : Start button state */
81   MYKONOS_COMMAND_MASK        = 1 << 6, /*!< Control command ACK : (0) None, (1) one received */
82   MYKONOS_TRIM_COMMAND_MASK   = 1 << 7, /*!< Trim command ACK : (0) None, (1) one received */
83   MYKONOS_TRIM_RUNNING_MASK   = 1 << 8, /*!< Trim running : (0) none, (1) running */
84   MYKONOS_TRIM_RESULT_MASK    = 1 << 9, /*!< Trim result : (0) failed, (1) succeeded */
85   MYKONOS_NAVDATA_DEMO_MASK   = 1 << 10, /*!< Navdata demo : (0) All navdata, (1) only navdata demo */
86   MYKONOS_NAVDATA_BOOTSTRAP   = 1 << 11, /*!< Navdata bootstrap : (0) options sent in all or demo mode, (1) no navdata options sent */
87   MYKONOS_MOTORS_BRUSHED      = 1 << 12, /*!< Motors brushed : (0) brushless, (1) brushed */
88   MYKONOS_COM_LOST_MASK   = 1 << 13, /*!< Communication Lost : (1) com problem, (0) Com is ok */
89   MYKONOS_GYROS_ZERO          = 1 << 14, /*!< Bit means that there's an hardware problem with gyrometers */
90   MYKONOS_VBAT_LOW            = 1 << 15, /*!< VBat low : (1) too low, (0) Ok */
91   MYKONOS_VBAT_HIGH           = 1 << 16, /*!< VBat high (US mad) : (1) too high, (0) Ok */
92   MYKONOS_TIMER_ELAPSED       = 1 << 17, /*!< Timer elapsed : (1) elapsed, (0) not elapsed */
93   MYKONOS_NOT_ENOUGH_POWER    = 1 << 18, /*!< Power : (0) Ok, (1) not enough to fly */
94   MYKONOS_ANGLES_OUT_OF_RANGE = 1 << 19, /*!< Angles : (0) Ok, (1) out of range */
95   MYKONOS_WIND_MASK           = 1 << 20, /*!< Wind : (0) Ok, (1) too much to fly */
96   MYKONOS_ULTRASOUND_MASK     = 1 << 21, /*!< Ultrasonic sensor : (0) Ok, (1) deaf */
97   MYKONOS_CUTOUT_MASK         = 1 << 22, /*!< Cutout system detection : (0) Not detected, (1) detected */
98   MYKONOS_PIC_VERSION_MASK    = 1 << 23, /*!< PIC Version number OK : (0) a bad version number, (1) version number is OK */
99   MYKONOS_ATCODEC_THREAD_ON   = 1 << 24, /*!< ATCodec thread ON : (0) thread OFF (1) thread ON */
100   MYKONOS_NAVDATA_THREAD_ON   = 1 << 25, /*!< Navdata thread ON : (0) thread OFF (1) thread ON */
101   MYKONOS_VIDEO_THREAD_ON     = 1 << 26, /*!< Video thread ON : (0) thread OFF (1) thread ON */
102   MYKONOS_ACQ_THREAD_ON       = 1 << 27, /*!< Acquisition thread ON : (0) thread OFF (1) thread ON */
103   MYKONOS_CTRL_WATCHDOG_MASK  = 1 << 28, /*!< CTRL watchdog : (1) delay in control execution (> 5ms), (0) control is well scheduled */
104   MYKONOS_ADC_WATCHDOG_MASK   = 1 << 29, /*!< ADC Watchdog : (1) delay in uart2 dsr (> 5ms), (0) uart2 is good */
105   MYKONOS_COM_WATCHDOG_MASK   = 1 << 30, /*!< Communication Watchdog : (1) com problem, (0) Com is ok */
106   MYKONOS_EMERGENCY_MASK      = 1 << 31  /*!< Emergency landing : (0) no emergency, (1) emergency */
107 };
108
109 /* Navdata functions  */
110 void navdata_run( void );
111 void navdata_stop( void );
112
113 /* Stream functions  */
114 void stream_run( void );
115 void stream_stop( void );
116
117 /* AT cmds functions  */
118 void at_stop( void );
119 void at_run( void );
120 void at_set_flat_trim( void );
121 void at_set_iphone_acceleros( int enable, float32_t fax, float32_t fay, float32_t faz );
122 void at_set_radiogp_input( int32_t pitch, int32_t roll, int32_t gaz, int32_t yaw );
123 void at_ui_pad_start_pressed( void );
124 void at_write (int8_t *buffer, int32_t len);
125
126 #endif // !APP_H_INCLUDED