Status message logger for embedded systems equipped with a small OLED display.
Project description
oled-status
Status message logger for embedded systems equipped with a small OLED display.
OLED Status has two parts: the server module that drives the display and the client library that pushes data to the display. The server is meant to be run as a module and requires the following Setup procedure. The client is designed to be embedded in other apps running on the device to show relevant information on an otherwise embedded app.
Setup
OLED Status requires both hardware and software setup to work properly. This setup is required to use OLED Status on a display attached to the device.
Hardware
A Single Board Computer running Linux with I2C support connected to a 0.91" 128x32 OLED Display driven by a SSD1306. OLED Status was developed and has only been tested on a Raspberry Pi 4 with a Treedix Display Module.
- Displays
- Single Board Computer
For wiring instructions, see Adafruit's Python Wiring Guide.
Software
Adafruit's Circuit Python compatability layer, Blinka, drives the OLED display and can be a bit tricky to install. OLED was developed and testes only on Ubuntu 20.04 but should be fully compatiable with any Blinka supported OS.
Ubuntu
- Update Ubuntu and it's packages:
sudo apt update
sudo apt upgrade
- Ubuntu doesn't ship with a compatiable version of Python, install Python 3.9+ and it's dependencies:
sudo apt install python3.9 python3.9-venv python3.9-dev
- Ubuntu resticts access to the I2C bus to root users by default. Create a udev rule to allow all users access automatically at boot by writing the following file at
/etc/udev/rules.d/i2c.rules
:
ACTION=="add", KERNEL=="i2c-[0-1]*", MODE="0666"
- Learn more from this StackExchange Answer
- Reboot for the udev rule to take effect:
sudo reboot
- Optionally setup a virtual environment:
python3.9 -m venv ./venv
. venv/bin/activate
The remainder of the setup will be handled by pip
when OLED Status is installed.
Raspberry Pi OS
See Adafruit's Circuit Python Installation Guide and then setup a virtual environment if desired.
Installation
OLED Status is distributed via Github Releases and PyPI.
Server
The server should be installed and set to autorun once, multiple client libraries and processes can connect to a single server instance.
- Install the OLED Status Server from PyPI:
pip install oled-status[server]
- Note this also installs the relevant Circuit Python dependecies to communicate with the display. If it fails to install, try again after running
pip install wheel
to add support forbdist_wheel
.
At this point the server can be started with python -m oled_status.server
and the OLED Display will be initialized. It's likly preferable that the server be automatically started at bootup, in which case continue:
- Create a service to automatically start the OLED Status Server, this varies depending on if a virtual environemnt (recommended) is in use. These are the instructions for using a virtual environment:
- Create a
start-oled-status-server.sh
script which activates the virtual environment and then starts the OLED Status Server:
#!/bin/bash cd <directory> . venv/bin/activate python -m oled_status.server
- Modify the script so it is executable:
sudo chmod x+ start-oled-status-server.sh
- Create a service the run the script at startup by writing the following file at
/etc/systemd/system/oled-status.service
:
[Unit] Description=OLED Status Server StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 User=<username> ExecStart=/path/to/start-oled-status-server.sh [Install] WantedBy=multi-user.target
- Enable the startup service:
systemctl enable oled-status
- Reboot
- Create a
Client
The client libary is to be used by any locally running application that wishes to display data on the OLED Display.
pip install oled-status
Use
The OLED Status provides a single Status
Class which when intantiated allows for messages to be added to, modified on, and removed from the OLED Display. The client communicates with the server over local port 6533
on seperate threads to prevent status updates from blocking execution.
When there are multiple messages to be displayed on the OLED Display, they are automatically cycled through, each showing for 5 seconds in the order they were recieved. Messages that are updated retain their original position in the cycle. As a result of the cycle, messages are not instantly displayed.
from oled_status import Status
# Publish a new message
message = Status('Heading', 'Message Contents')
# Update a message
message.update('Updated Message')
# Clear a message
message.clear()
Note The OLED Display is tiny, messages that are longer than about 14 uppercase letters will be truncated.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file oled-status-0.0.3.tar.gz
.
File metadata
- Download URL: oled-status-0.0.3.tar.gz
- Upload date:
- Size: 237.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15b7d3bd8b3e983eb72bff2ed0a3d5c95872ecd182f037f43effbfa310c3f146 |
|
MD5 | 65f660936c15cf0ab73e0633bc97502a |
|
BLAKE2b-256 | a8b1f27ebf76fe0342dd32f15929820135398a627c5166e18c7d5ca4ec7f9787 |
File details
Details for the file oled_status-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: oled_status-0.0.3-py3-none-any.whl
- Upload date:
- Size: 236.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 625f032741bb890d0318de818b623d6cc23747043383f23cf783599d0957c708 |
|
MD5 | c87b77cedd6143713a30329e6e7cecf1 |
|
BLAKE2b-256 | e987afd949bd8b4d329dc884a3f6c99dbf2312397707f80ce4735ece8582042a |