ssd1306

package
v0.0.0-...-2e22e3b Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package ssd1306 implements a driver for the SSD1306 led matrix controller, it comes in various colors and screen sizes.

Datasheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf

Index

Constants

View Source
const (
	Address        = 0x3D
	Address_128_32 = 0x3C

	SETCONTRAST                          = 0x81
	DISPLAYALLON_RESUME                  = 0xA4
	DISPLAYALLON                         = 0xA5
	NORMALDISPLAY                        = 0xA6
	INVERTDISPLAY                        = 0xA7
	DISPLAYOFF                           = 0xAE
	DISPLAYON                            = 0xAF
	SETDISPLAYOFFSET                     = 0xD3
	SETCOMPINS                           = 0xDA
	SETVCOMDETECT                        = 0xDB
	SETDISPLAYCLOCKDIV                   = 0xD5
	SETPRECHARGE                         = 0xD9
	SETMULTIPLEX                         = 0xA8
	SETLOWCOLUMN                         = 0x00
	SETHIGHCOLUMN                        = 0x10
	SETSTARTLINE                         = 0x40
	MEMORYMODE                           = 0x20
	COLUMNADDR                           = 0x21
	PAGEADDR                             = 0x22
	COMSCANINC                           = 0xC0
	COMSCANDEC                           = 0xC8
	SEGREMAP                             = 0xA0
	CHARGEPUMP                           = 0x8D
	ACTIVATE_SCROLL                      = 0x2F
	DEACTIVATE_SCROLL                    = 0x2E
	SET_VERTICAL_SCROLL_AREA             = 0xA3
	RIGHT_HORIZONTAL_SCROLL              = 0x26
	LEFT_HORIZONTAL_SCROLL               = 0x27
	VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL = 0x29
	VERTICAL_AND_LEFT_HORIZONTAL_SCROLL  = 0x2A

	EXTERNALVCC  VccMode = 0x1
	SWITCHCAPVCC VccMode = 0x2
)

Registers

Variables

This section is empty.

Functions

This section is empty.

Types

type Buser

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

type Config

type Config struct {
	Width    int16
	Height   int16
	VccState VccMode
	Address  uint16
	// ResetCol and ResetPage are used to reset the screen to 0x0
	// This is useful for some screens that have a different size than 128x64
	// For example, the Thumby's screen is 72x40
	// The default values are normally set automatically based on the size.
	// If you're using a different size, you might need to set these values manually.
	ResetCol  ResetValue
	ResetPage ResetValue
}

Config is the configuration for the display

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device wraps I2C or SPI connection.

func NewI2C

func NewI2C(bus drivers.I2C) Device

NewI2C creates a new SSD1306 connection. The I2C wire must already be configured.

func NewSPI

func NewSPI(bus drivers.SPI, dcPin, resetPin, csPin machine.Pin) Device

NewSPI creates a new SSD1306 connection. The SPI wire must already be configured.

func (*Device) ClearBuffer

func (d *Device) ClearBuffer()

ClearBuffer clears the image buffer

func (*Device) ClearDisplay

func (d *Device) ClearDisplay()

ClearDisplay clears the image buffer and clear the display

func (*Device) Command

func (d *Device) Command(command uint8)

Command sends a command to the display

func (*Device) Configure

func (d *Device) Configure(cfg Config)

Configure initializes the display with default configuration

func (*Device) Display

func (d *Device) Display() error

Display sends the whole buffer to the screen

func (*Device) GetBuffer

func (d *Device) GetBuffer() []byte

GetBuffer returns the whole buffer

func (*Device) GetPixel

func (d *Device) GetPixel(x int16, y int16) bool

GetPixel returns if the specified pixel is on (true) or off (false)

func (*Device) SetBuffer

func (d *Device) SetBuffer(buffer []byte) error

SetBuffer changes the whole buffer at once

func (*Device) SetPixel

func (d *Device) SetPixel(x int16, y int16, c color.RGBA)

SetPixel enables or disables a pixel in the buffer color.RGBA{0, 0, 0, 255} is consider transparent, anything else with enable a pixel on the screen

func (*Device) Size

func (d *Device) Size() (w, h int16)

Size returns the current size of the display.

func (*Device) Tx

func (d *Device) Tx(data []byte, isCommand bool) error

Tx sends data to the display

type I2CBus

type I2CBus struct {
	Address uint16
	// contains filtered or unexported fields
}

type ResetValue

type ResetValue [2]byte

type SPIBus

type SPIBus struct {
	// contains filtered or unexported fields
}

type VccMode

type VccMode uint8

Jump to

Keyboard shortcuts

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