diff --git a/.gitignore b/.gitignore index 7b05f121..e17ba71f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ core .idea/ .DS_Store *.swp +__pycache__ +src/web/current +src/oled_monitor/current diff --git a/src/oled_monitor/rascsi_oled_monitor.py b/src/oled_monitor/rascsi_oled_monitor.py index 35dad3db..38048815 100755 --- a/src/oled_monitor/rascsi_oled_monitor.py +++ b/src/oled_monitor/rascsi_oled_monitor.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # RaSCSI Updates: # Updates to output rascsi status to an OLED display diff --git a/src/oled_monitor/requirements.txt b/src/oled_monitor/requirements.txt new file mode 100644 index 00000000..eebfd0cd --- /dev/null +++ b/src/oled_monitor/requirements.txt @@ -0,0 +1,14 @@ +Adafruit-Blinka==6.3.2 +adafruit-circuitpython-busdevice==5.0.6 +adafruit-circuitpython-framebuf==1.4.6 +adafruit-circuitpython-ssd1306==2.11.1 +Adafruit-PlatformDetect==3.2.0 +Adafruit-PureIO==1.1.8 +Pillow==8.1.2 +pkg-resources==0.0.0 +pyftdi==0.52.9 +pyserial==3.5 +pyusb==1.1.1 +rpi-ws281x==4.2.5 +RPi.GPIO==0.7.0 +sysv-ipc==1.1.0 diff --git a/src/oled_monitor/start.sh b/src/oled_monitor/start.sh new file mode 100755 index 00000000..f0a37013 --- /dev/null +++ b/src/oled_monitor/start.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +set -e +# set -x # Uncomment to Debug + +cd $(dirname $0) +# verify packages installed +ERROR=0 +if ! command -v dpkg -l i2c-tools &> /dev/null ; then + echo "i2c-tools could not be found" + echo "Run 'sudo apt install i2c-tools' to fix." + ERROR=1 +fi +if ! command -v python3 &> /dev/null ; then + echo "python3 could not be found" + echo "Run 'sudo apt install python3' to fix." + ERROR=1 +fi +# Dep to build Pillow +if ! dpkg -l python3-dev &> /dev/null; then + echo "python3-dev could not be found" + echo "Run 'sudo apt install python3-dev' to fix." + ERROR=1 +fi +if ! dpkg -l libjpeg-dev &> /dev/null; then + echo "libjpeg-dev could not be found" + echo "Run 'sudo apt install libjpeg-dev' to fix." + ERROR=1 +fi +if ! dpkg -l libpng-dev &> /dev/null; then + echo "libpng-dev could not be found" + echo "Run 'sudo apt install libpng-dev' to fix." + ERROR=1 +fi +# Dep to build Pollow +if ! python3 -m venv --help &> /dev/null ; then + echo "venv could not be found" + echo "Run 'sudo apt install python3-venv' to fix." + ERROR=1 +fi +if [ $ERROR = 1 ] ; then + echo + echo "Fix errors and re-run ./start.sh" + exit 1 +fi + +if ! i2cdetect -y 1 &> /dev/null ; then + echo "i2cdetect -y 1 did not find a screen." + exit 2 +fi +if ! test -e venv; then + echo "Creating python venv for OLED Screen" + python3 -m venv venv + echo "Activating venv" + source venv/bin/activate + echo "Installing requirements.txt" + pip install -r requirements.txt + git rev-parse HEAD > current +fi + +source venv/bin/activate + +# Detect if someone updates - we need to re-run pip install. +if ! test -e current; then + git rev-parse > current +else + if [ "$(cat current)" != "$(git rev-parse HEAD)" ]; then + echo "New version detected, updating requirements.txt" + echo " This may take some time..." + pip install wheel + pip install -r requirements.txt + git rev-parse HEAD > current + fi +fi + +echo "Starting OLED Screen..." +python3 rascsi_oled_monitor.py