epd7in5bhd

package
v0.0.0-...-b8a07c1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

README

7.5 inch HD (B/C) e-Paper display

This is a pure-go package for the Waveshare 7.5 inch HD b/c (red or yellow) e-Paper display.

All hardware documentation is available at: https://www.waveshare.com/wiki/7.5inch_HD_e-Paper_HAT_(B)

Documentation

Overview

Package commands contains constants representing different commands to send to the device.

Package epd7in5bhd is for the Waveshare 7.5 inch HD (B/C) e-Paper display.

Index

Constants

View Source
const (
	// Device width in pixels.
	DisplayWidth = 880
	// Device width in bytes.
	DisplayWidthBytes = 880 / 8
	// Device height in pixels.
	DisplayHeight = 528
	// Full buffer size in bytes.
	BufSize = DisplayWidthBytes * DisplayHeight
)

Variables

View Source
var DefaultPins = Pins{
	Busy: "P1_18",
	CS:   "P1_24",
	DC:   "P1_22",
	RST:  "P1_11",
}
View Source
var DefaultWait = 25 * time.Second

DefaultSleep is the default time to wait for a screen refresh. The official documented refresh time is 22 seconds.

Functions

This section is empty.

Types

type Display

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

Display is a client for the e-Paper display.

Standard pin locations are as follows:

Busy - Busy      - Pin 18 (GPIO 24)
CLK  - SPI0 SCLK - Pin 23 (GPIO 11)
CS   - SPI0 CE0  - Pin 24 (GPIO 8)
DC   - Data/Cmd  - Pin 22 (GPIO 25)
DIN  - SPI0 MOSI - Pin 19 (GPIO 10)
RST  - Reset     - Pin 11 (GPIO 17)

func New

func New(p Pins) (*Display, error)

New creates a Display configured for use.

dcPin, csPin, rstPin, and busyPin all expect valid gpioreg.ByName() values, such as P1_22.

d, err := epd7in5bhd.New("P1_22", "P1_24", "P1_11", "P1_18")
if err != nil {
  // Handle error.
}

func (*Display) Clear

func (d *Display) Clear()

Clear clears the screen.

func (*Display) Init

func (d *Display) Init()

Init initializes the display config. It should be used if the device is asleep and needs reinitialization.

func (*Display) Render

func (d *Display) Render(blackImg, redImg []byte)

Render updates the screen from the provided io.ByteReaders.

The epd7in5bhd does not support partial refreshes. If the provided buffer is smaller than the image, then the rest will be filled with white.

The epd7in5bhd expects a bit per pixel for each color.

For blackImg, 0b1 is a black pixel, and 0b0 is a white pixel. For redImg, 0b1 is a red pixel, and 0b0 is a not-red pixel (no change will occur).

Black will always be drawn on the screen before red.

func (*Display) RenderImages

func (d *Display) RenderImages(black, redyellow image.Image)

RenderImages renders a black image and a red/yellow image on the display.

func (*Display) RenderPaletted

func (d *Display) RenderPaletted(img image.Image)

RenderPaletted renders an image in 3 colors (black, white and red/yellow).

If img is a *image.Paletted with exactly 3 colors, each color will be assigned to its nearest by euclidean distance. Otherwise, colors will be assigned by a per-pixel calculation.

func (*Display) Reset

func (d *Display) Reset()

Reset can be also used to awaken the device.

func (*Display) Sleep

func (d *Display) Sleep()

Sleep tells the Display to enter deepSleepMode.

The display can be reawakened with Reset(), and re-initialized with Init().

type Pins

type Pins struct {
	// Busy pin name, typically "P1_18"
	Busy string
	// CS pin name, typically "P1_24"
	CS string
	// DC pin name, typically "P1_22"
	DC string
	// RST pin name, typicaly "P1_11"
	RST string
}

Jump to

Keyboard shortcuts

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