ssd1351

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: BSD-3-Clause Imports: 5 Imported by: 6

Documentation

Overview

Package ssd1351 implements a driver for the SSD1351 OLED color displays.

Datasheet: https://download.mikroe.com/documents/datasheets/ssd1351-revision-1.3.pdf

Index

Constants

View Source
const (
	SET_COLUMN_ADDRESS          = 0x15
	SET_ROW_ADDRESS             = 0x75
	WRITE_RAM                   = 0x5C
	READ_RAM                    = 0x5D
	SET_REMAP_COLORDEPTH        = 0xA0
	SET_DISPLAY_START_LINE      = 0xA1
	SET_DISPLAY_OFFSET          = 0xA2
	SET_DISPLAY_MODE_ALLOFF     = 0xA4
	SET_DISPLAY_MODE_ALLON      = 0xA5
	SET_DISPLAY_MODE_RESET      = 0xA6
	SET_DISPLAY_MODE_INVERT     = 0xA7
	FUNCTION_SELECTION          = 0xAB
	SLEEP_MODE_DISPLAY_OFF      = 0xAE
	SLEEP_MODE_DISPLAY_ON       = 0xAF
	SET_PHASE_PERIOD            = 0xB1
	ENHANCED_DRIVING_SCHEME     = 0xB2
	SET_FRONT_CLOCK_DIV         = 0xB3
	SET_SEGMENT_LOW_VOLTAGE     = 0xB4
	SET_GPIO                    = 0xB5
	SET_SECOND_PRECHARGE_PERIOD = 0xB6
	GRAY_SCALE_LOOKUP           = 0xB8
	LINEAR_LUT                  = 0xB9
	SET_PRECHARGE_VOLTAGE       = 0xBB
	SET_VCOMH_VOLTAGE           = 0xBE
	SET_CONTRAST                = 0xC1
	MASTER_CONTRAST             = 0xC7
	SET_MUX_RATIO               = 0xCA
	NOP0                        = 0xD1
	NOP1                        = 0xE3
	SET_COMMAND_LOCK            = 0xFD
	HORIZONTAL_SCROLL           = 0x96
	STOP_MOVING                 = 0x9E
	START_MOVING                = 0x9F
)

Commands

Variables

This section is empty.

Functions

func RGBATo565

func RGBATo565(c color.RGBA) uint16

RGBATo565 converts a color.RGBA to uint16 used in the display

Types

type Config

type Config struct {
	Width        int16
	Height       int16
	RowOffset    int16
	ColumnOffset int16
}

Config is the configuration for the display

type Device

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

Device wraps an SPI connection.

func New

func New(bus drivers.SPI, resetPin, dcPin, csPin, enPin, rwPin machine.Pin) Device

New creates a new SSD1351 connection. The SPI wire must already be configured.

func (*Device) Command

func (d *Device) Command(command uint8)

Command sends a command byte to the display

func (*Device) Configure

func (d *Device) Configure(cfg Config)

Configure initializes the display with default configuration

func (*Device) Data

func (d *Device) Data(data uint8)

Data sends a data byte to the display

func (*Device) Display

func (d *Device) Display() error

Display does nothing, there's no buffer as it might be too big for some boards

func (*Device) DrawFastHLine

func (d *Device) DrawFastHLine(x0, x1, y int16, c color.RGBA)

DrawFastHLine draws a horizontal line faster than using SetPixel

func (*Device) DrawFastVLine

func (d *Device) DrawFastVLine(x, y0, y1 int16, c color.RGBA)

DrawFastVLine draws a vertical line faster than using SetPixel

func (*Device) FillRectangle

func (d *Device) FillRectangle(x, y, width, height int16, c color.RGBA) error

FillRectangle fills a rectangle at given coordinates with a color

func (*Device) FillRectangleWithBuffer

func (d *Device) FillRectangleWithBuffer(x, y, width, height int16, buffer []color.RGBA) error

FillRectangleWithBuffer fills a rectangle at given coordinates with a buffer

func (*Device) FillScreen

func (d *Device) FillScreen(c color.RGBA)

FillScreen fills the screen with a given color

func (*Device) SetContrast

func (d *Device) SetContrast(contrastA, contrastB, contrastC uint8)

SetContrast sets the three contrast values (A, B & C)

func (*Device) SetPixel

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

SetPixel sets a pixel in the buffer

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

Jump to

Keyboard shortcuts

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