This is mobile system programming with a smart tablet device board.
It uses custom hardware on the right-hand side of the board (FPGA board)
To reduce development time, I forked SnakeGame-Android and did work on it.
I focused hardware control part than software.
I used JNI to call C/C++ function to control fpga devices.
The snake's length is synchronized with the number of led turned on.
Since snake's default length is 3, the number of led turned on is determined on length - 3
.
7-segment LEDs display current score.
The number of dip switch on is synchronized with the number of barrier blocks. (But when you enter setting page, it is automatically set to two of multiple. That's why the number of barrier blocks 4 mismatches the number of dip switch on 5 in the picture. Anyway, it's not a big deal.)
The keypad is the main controller of snake. The other keys is not recognized by device driver(-), or its behavior is undefined(x).
-
It becomes red whenever the snake eats red food.
-
It becomes yellow whenever the snake eats yellow food.
It displays the user's high score if all following conditions are true:
- Previous highscore is less than current score. That is, the user recorded new high score.
- Game over.
Serial port connection is not necessary for app development! Just connect only power supply and USB OTG cable on your PC and type adb shell
in cmd to access shell of the device.
The most common error I've seen in running app process in Android Studio is INSTALL_FAILED_INSUFFICIENT_STORAGE
. This is because /data
directory has insufficient storage. You can check how free space is left by command df -h
in adb shell. I took a plenty of time to solve this. stackoverflow was not helpful. I also tried remount file system to exchange between /data
and /cache
because file system mounted on /cache
has more storage. It did not work as I expected, well.
SD card has enough storage. You can set install location to SD card by type adb shell pm set-install-location 2
. (If you are already in the shell, just type pm set-install-location 2
.) I got this information from stackoverflow.
If you set install location to SD card, you may see INSTALL_FAILED_DEXOPT
error. stackoverflow says that "The most common cause of the problem is dex limits on android". I interpreted this sentence as "There must be only one application at time". Before installing the app, you can type adb uninstall <your package name>
to avoid DEXOPT error. For example, in this project, I typed adb uninstall com.yangdai.snakegame
before every installation. It is a little pain.
When you call FLEDControl method in FLED class, you should resize the RGB value to make it belongs to interval [0, 100]. That means, you should multiply each arguments with 100 / 255
. For example, if yellow's RGB value is (255, 242, 0), you should pass arguments as (100, 94, 0). Honestly, I do not know that this logic is true way to pass arguments, but this logic is applied and seemed working well, at least in this project.
I also tried to control OLED and TextLCD devices, because I wanted to cover as much as possible devices. It seems that OLED is broken or source code has a bug. And TextLCD does not work properly even though I referenced source code in the book. I don't know why.
- Hanback Electronics SM5 S4210 M3
- Android 4.1 ("Jelly Bean") | arm
- API: 16
- Type: Physical