- An air-hockey game implemented on STM32L475 and Raspberry Pi.
- Two versions are available: BLE & Wifi
- The Wifi version has better performance
- Prerequisites:
bluepy
(for ble) andpygame
(ble and wifi)
$ pip3 install bluepy
$ pip3 install pygame
- See
RPi/README.md
for more information
- Download Mbed Studio: https://os.mbed.com/studio/
- Add sensor library to project (link: http://developer.mbed.org/teams/ST/code/BSP_B-L475E-IOT01/#bfe8272ced90)
-
Clone ble-HearRate example: https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-HeartRate/
-
Copy(replace) the files in
mbed-os
directory intombed-os-example-ble-HeartRate/mbed-os/features/FEATURE_BLE/
-
Move
main.cpp
andMyService.h
into project (same directory asmbed-os/
) -
Compile and write into two boards. Remember to assign two boards different
PLAYER
values (0 or 1)! (inmain.cpp:27
) -
See
STM32L475VG/ble/README.md
for more information
- Move
main.cpp
into project (same directory asmbed-os/
) - Substitute ssid and password in code below and copy it to
mbed_app.json
under project
{
"config": {
"wifi-ssid": {
"help": "WiFi SSID",
"value": "\"WIFI-SSID\""
},
"wifi-password": {
"help": "WiFi Password",
"value": "\"WIFI-PASSWORD\""
}
},
"target_overrides": {
"*": {
"platform.stdio-convert-newlines": true
}
}
}
-
Change
IP_ADDR
inmain.cpp:26-27
to the IP address of RPi -
Compile and write into two boards. Remember to give two boards different
PLAYER
values (0 or 1)! (inmain.cpp:30
) -
See
STM32L475VG/wifi/README.md
, for more information
cd RPi/src/
sudo python3 main.py
cd RPi/src/
sudo python3 main-socket.py
Nothing has to be done! If the striker does not react or behaves strangely, press the blue button to reconnect and recalibrate.
After the commands are executed, you may enter the starting menu.
Enter 1
, 3
, or 5
to start the game (for 1, 3, or 5 minutes respectively).
Press Esc
to exit the game.
- Starting menu
- In game
- Player scores
- Demo video: https://drive.google.com/file/d/1DMVhMzvl215tsdMatFl2ZeyUQp4JkgY9/view?usp=sharing
- ARM-MBED documents (sensors)
https://os.mbed.com/teams/ST/code/DISCO_L475VG_IOT01-Sensors-BSP/file/986c1f5db128/main.cpp/ - airhockey
https://github.com/ross85/airhockey - UDP Socket
https://os.mbed.com/docs/mbed-os/v5.9/reference/udpsocket.html https://www.itread01.com/p/432886.html
For more information, see report for detailed implementation.