ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / Examples / Linux / Protocol / app.c
diff --git a/mardrone/ARDrone_SDK_Version_1_8_20110726/Examples/Linux/Protocol/app.c b/mardrone/ARDrone_SDK_Version_1_8_20110726/Examples/Linux/Protocol/app.c
new file mode 100644 (file)
index 0000000..73b99da
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * AR Drone demo
+ *
+ * originally based on Android NDK "San Angeles" demo app
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <unistd.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/time.h>
+#include <time.h>
+
+#include "app.h"
+
+static int screen_width = 0;
+static int screen_height = 0;
+static int gAppAlive = 0;
+
+void appInit()
+{
+       int status;
+
+   //Run AT command process
+   at_run();
+   
+   //Run Navdata process
+   navdata_run();
+
+   //Run Stream process
+   stream_run();
+
+#ifdef BUILD_OGLES
+       // video rendering
+       video_init();
+#endif
+   gAppAlive = 1;
+}
+
+void appDeinit()
+{
+       INFO("shutting down application...\n");
+
+   gAppAlive = 0;
+
+#ifdef BUILD_OGLES
+       video_deinit();
+#endif
+       // all threads should implement a loop polling gAppAlive
+       navdata_stop();
+       stream_stop();
+   at_stop();
+
+       INFO("application was cleanly exited\n");
+}
+
+#ifdef BUILD_OGLES
+void appRender(long tick, int width, int height)
+{
+       if (!gAppAlive) {
+               return;
+       }
+   screen_width = width;
+   screen_height = height;
+       video_render(tick, screen_width, screen_height);
+}
+#endif
+
+void get_screen_dimensions(int *w, int *h)
+{
+       if (screen_width) {
+               *w = screen_width;
+               *h = screen_height;
+       }
+       else {
+               // dummy dimensions
+               *w = 480;
+               *h = 320;
+       }
+}
+