[FE training-materials-updates] Add a new version of mlbini.c, able to take user input
Alexandre Belloni
alexandre.belloni at free-electrons.com
Wed Jun 12 14:01:42 CEST 2013
Repository : git://git.free-electrons.com/training-materials.git
On branch : master
Link : http://git.free-electrons.com/training-materials/commit/?id=6b5c87eb0c8a9f847b3b7988715a0f8db072ed3e
>---------------------------------------------------------------
commit 6b5c87eb0c8a9f847b3b7988715a0f8db072ed3e
Author: Alexandre Belloni <alexandre.belloni at free-electrons.com>
Date: Wed Jun 12 14:00:50 2013 +0200
Add a new version of mlbini.c, able to take user input
>---------------------------------------------------------------
6b5c87eb0c8a9f847b3b7988715a0f8db072ed3e
lab-data/android/native-app/mlbin.c | 48 +++++++++++++++++-------
labs/android-native-app/android-native-app.tex | 13 ++++++-
2 files changed, 46 insertions(+), 15 deletions(-)
diff --git a/lab-data/android/native-app/mlbin.c b/lab-data/android/native-app/mlbin.c
index 1938f0f..f5133ba 100644
--- a/lab-data/android/native-app/mlbin.c
+++ b/lab-data/android/native-app/mlbin.c
@@ -148,22 +148,42 @@ int mlbin_stop(void)
int main(void)
{
+ int ret;
+ char dir;
+ int time;
+
mlbin_init_usb();
- mlbin_move_down();
- sleep(5);
- mlbin_stop();
- mlbin_move_left();
- sleep(5);
- mlbin_stop();
- mlbin_fire();
- sleep(5);
- mlbin_stop();
- mlbin_move_up();
- sleep(5);
- mlbin_stop();
- mlbin_move_right();
- sleep(5);
mlbin_stop();
+
+ do {
+ ret = scanf("%c %d", &dir, &time);
+ if (ret != 2)
+ continue;
+
+ printf("%c for %d\n", dir, time);
+ switch(dir) {
+ case 'L':
+ mlbin_move_left();
+ break;
+ case 'R':
+ mlbin_move_right();
+ break;
+ case 'U':
+ mlbin_move_up();
+ break;
+ case 'D':
+ mlbin_move_down();
+ break;
+ case 'F':
+ mlbin_fire();
+ break;
+ default:
+ break;
+ }
+ sleep(time);
+ mlbin_stop();
+ } while(ret != EOF);
+
mlbin_free_usb();
return 0;
diff --git a/labs/android-native-app/android-native-app.tex b/labs/android-native-app/android-native-app.tex
index 271afac..ff87428 100644
--- a/labs/android-native-app/android-native-app.tex
+++ b/labs/android-native-app/android-native-app.tex
@@ -12,6 +12,7 @@ Copy the \code{mlbin.c} file from the
\code{$HOME/felabs/android/native-app} directory and put it into a new
folder in your device folder called \code{bin}.
+
Just as for \code{libusb}, you now need to make an \code{Android.mk} file
giving all the details needed by the build system to compile. But
unlike \code{libusb}, this binary is an executable and depends on another
@@ -19,7 +20,17 @@ piece of software.
Make it compile and be integrated in the generated images. Once you
have the images, boot the board, plug a missile launcher and test the
-application. You should see the launcher move.
+application. You can then use commands to move the missile launcher:
+\begin{itemize}
+ \item L - go left
+ \item R - go right
+ \item U - go up
+ \item D - go down
+ \item F - actionnate trigger
+\end{itemize}
+
+For example, use \code{L 1 U 1 F 5} will turn left for one second, up
+for one second and fire a missile.
\section{Fix the Problems}
More information about the training-materials-updates
mailing list