Skip to content

Basalt-Revalidatie/stair-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Project Stage Project Maintenance

Build Status Code Coverage

Stair Challenge

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.

Get Started

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.

Prerequisites

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.

Starting the services

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

Development

This Python project is fully managed using the Poetry dependency manager.

You need at least:

  1. Create an .env and make an symbolik link
cp ./app/.env.example ./app/.env
ln -s app/.env .env
  1. Fillout the database credentials (if needed) in the .env file
  2. 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

Building an Docker image

docker-compose build flask

Starting the application

To start the application in development mode, you can use the default Flask CLI command:

flask run

Run Flask CLI commands

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 database
  • create_admin - Create an admin user (only works when attached to shell)
  • seed_workouts - Seed the workouts table with some default workouts

FAQ

Temporary failure in name resolution

socket.gaierror: [Errno -3] Temporary failure in name resolution

This error may indicate that the IP address of your MQTT server is incorrect.