Simple command-line interface based games for embedded devices. Inspired by asweigart/PythonStdioGames repository. It is a good way to learn python and good practice to implement the same in C. It was tested on STM32F103 Nucleo board.
Provided example is for STM32 microcontroller.
Copy source and header files into your project then include the provided header file.
// Game main loops
#include "dna.h"
#include "chonan.h"
// Utility function
#include "syscalls.h"
Initialize system calls with UART port that is connected to a UART <-> USB adapter. In case of STM32 Nucleo boards it is already available.
syscallsInit(&huart2);
In main()
call one of the game loop functions
int main(void)
{
while(1)
{
chohanGame();
// or
dnaGame();
}
}
- List all the connected devices with
ls /dev/cu.*
command then look forusbserial
orusbmodem
. - Open a serial connection:
screen /dev/cu.usbmodem111203 115200
.
- Install tio (using brew on MacOS).
- List all available devices with
tio --list-devices
then look forusbserial
orusbmodem
. - Open serial connection with default options:
tio /dev/cu.usbmodem111203
ortio /dev/cu.usbmodem153403 9600
if you want to specify the baudrate other than the default 115200.