In this repository you will find the code for the overall operation of the Stair Challenge, a project by Basalt - Smartlab and designed to allow rehabilitation patients to practice climbing stairs in a fun and interactive way. Made by klaasnicolaas.
For this project you need at least a Raspberry Pi 4 with at least 4GB of RAM. All services are able to run in Docker containers, we are talking about an MQTT Broker from EMQX, MySQL database and the Flask application itself.
You must set a fixed frequency on the Raspberry Pi, to avoid the idle CPU scaling changing the SPI frequency and breaking the ws281x timings:
Do this by adding the following lines to /boot/config.txt
and reboot:
core_freq=500
core_freq_min=500
SPI requires you to be in the gpio
group if you wish to control your LEDs without root.
To start the services, you can use the docker-compose.yml
file in the root of the project. This file contains all the services needed to run the application.
docker-compose up -d
This Python project is fully managed using the Poetry dependency manager.
You need at least:
- Python 3.11+
- Poetry
- Create an
.env
and make an symbolik link
cp ./app/.env.example ./app/.env
ln -s app/.env .env
- Fillout the database credentials (if needed) in the
.env
file - Install all packages, including all development requirements:
poetry install
Poetry creates by default an virtual environment where it installs all necessary pip packages, to enter or exit the venv run the following commands:
poetry shell
exit
Setup the pre-commit check, you must run this inside the virtual environment:
pre-commit install
Now you're all set to get started!
As this repository uses the pre-commit framework, all changes are linted and tested with each commit. You can run all checks and tests manually, using the following command:
poetry run pre-commit run --all-files
docker-compose build flask
To start the application in development mode, you can use the default Flask CLI command:
flask run
If you want to run Flask CLI commands within a docker container, you should use the following format:
docker exec stair_challenge_dashboard flask init_db
Or attach to the shell of the container (in VSCode) and run the command:
flask init_db
CLI commands:
init_db
- Initialize the databasecreate_admin
- Create an admin user (only works when attached to shell)seed_workouts
- Seed the workouts table with some default workouts
socket.gaierror: [Errno -3] Temporary failure in name resolution
This error may indicate that the IP address of your MQTT server is incorrect.