ssd1306

package
v0.0.0-...-3bb5b45 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: BSD-3-Clause Imports: 4 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
}

Config is the configuration for the display

type Device

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

Device wraps an SPI connection.

func NewI2C

func NewI2C(bus machine.I2C) Device

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

func NewSPI

func NewSPI(bus machine.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) 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)

Tx sends data to the display

type I2CBus

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

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