SSD1306 Display Tool

A command-line tool for displaying text on SSD1306 OLED displays via I²C interface. This tool supports multi-line text display, persistent buffering, and line-specific text placement.

Features

  • Display text on SSD1306 OLED displays (128x64)
  • Multi-line text support (up to 5 lines)
  • Persistent display buffer with file-based state management
  • Line-specific text placement
  • Clear display functionality
  • Input from command line arguments or stdin

Requirements

  • Go 1.23.4 or later
  • SSD1306 OLED display connected via I²C
  • I²C interface enabled on your system

Installation

go mod download
go build -o display main.go

Usage

./display [OPTIONS] [TEXT]

Command Line Options

Flag Short Description Default
--device -d Path to I²C device /dev/i2c-1
--line -l Line number to start printing (1-based, max 5) 1
--buffer -b Path to buffer file for persistent display state (none)
--clear -k Clear the display and buffer false

Examples

Display simple text:

./display "Hello, World!"

Display text on a specific line:

./display --line 3 "This is line 3"

Use persistent buffer:

./display --buffer /tmp/display.txt --line 1 "Line 1"
./display --buffer /tmp/display.txt --line 2 "Line 2"

Clear the display:

./display --clear --buffer /tmp/display.txt

Read from stdin:

echo -e "Line 1\nLine 2\nLine 3" | ./display --buffer /tmp/display.txt

Buffer File Management

When using the --buffer option, the tool maintains a persistent state of the display content:

  • Text is stored line by line in the buffer file
  • New text updates specific lines without affecting others
  • The --clear option removes the buffer file and clears the display
  • Buffer files are plain text with newline-separated content