Skip to main content

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.

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

  1. Update Ubuntu and it's packages:
sudo apt update
sudo apt upgrade
  1. 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
  1. 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"
  1. Reboot for the udev rule to take effect:
sudo reboot
  1. 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.

  1. 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 for bdist_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:

  1. 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:
    1. 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
    
    1. Modify the script so it is executable: sudo chmod x+ start-oled-status-server.sh
    2. 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
    
    1. Enable the startup service: systemctl enable oled-status
    2. Reboot

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oled-status-0.0.3.tar.gz (237.3 kB view details)

Uploaded Source

Built Distribution

oled_status-0.0.3-py3-none-any.whl (236.6 kB view details)

Uploaded Python 3

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

Hashes for oled-status-0.0.3.tar.gz
Algorithm Hash digest
SHA256 15b7d3bd8b3e983eb72bff2ed0a3d5c95872ecd182f037f43effbfa310c3f146
MD5 65f660936c15cf0ab73e0633bc97502a
BLAKE2b-256 a8b1f27ebf76fe0342dd32f15929820135398a627c5166e18c7d5ca4ec7f9787

See more details on using hashes here.

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

Hashes for oled_status-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 625f032741bb890d0318de818b623d6cc23747043383f23cf783599d0957c708
MD5 c87b77cedd6143713a30329e6e7cecf1
BLAKE2b-256 e987afd949bd8b4d329dc884a3f6c99dbf2312397707f80ce4735ece8582042a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page