oled

package
v0.0.0-...-48e7947 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 8 Imported by: 1

README

samarkin/screen-server/oled

A simple go library to work with an SH1106 128x64 OLED screen.

Includes a custom 5x7 font.

Usage

  1. Ensure the display is properly connected over I2C.

  2. Import the module:

import "github.com/samarkin/screen-server/oled"
  1. Profit:
scr, err := oled.Open(&oled.I2cOpener{})
if err != nil {
    log.Fatalf("Failed to open screen: %v", err)
}
defer scr.Close()
scr.Print(0, 0, "Hello, world!")

Documentation

Index

Constants

View Source
const (
	// ErrorScreenClosed means an attempt to communicate with a closed OLED screen
	ErrorScreenClosed = oledError("Screen is closed")
)

Variables

View Source
var SignalLevels int

SignalLevels holds the number of supported signal levels

Functions

This section is empty.

Types

type I2cOpener

type I2cOpener struct {
}

I2cOpener allows to open a real I2C screen

type MockOpener

type MockOpener struct {
}

MockOpener allows to open a screen object that does not perform any real connection Can be used for testing

type Opener

type Opener interface {
	// contains filtered or unexported methods
}

Opener opens a connection to the screen

type Screen

type Screen interface {
	// Print displays a string in the specified position of the screen
	Print(line int, offset int, message string) error
	// DisplaySignalLevel displays signal level icon in the specified position of the screen
	DisplaySignalLevel(line int, offset int, level int) error
	// DisplayImageFile loads image from the specified file and displays it on the screen
	DisplayImageFile(filepath string) error
	// DisplayImage loads image from the provided reader and displays it on the screen
	DisplayImage(reader io.Reader) error
	// Clear erases screen RAM contents
	Clear() error
	// Close releases all the resources allocated by this instance of Screen
	Close() error
}

Screen contains resources required to work with the OLED screen

func Open

func Open(o Opener) (Screen, error)

Open is the entry point to start working with an OLED screen

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL