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