epd7in5bhd

package
v0.0.0-...-e654b88 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: BSD-3-Clause Imports: 17 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 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 (
	White     = Color{0}
	Black     = Color{1}
	Highlight = Color{2}

	Model = color.ModelFunc(model)
)
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.

View Source
var (
	DisplayBounds = image.Rect(0, 0, DisplayWidth, DisplayHeight)
)

Functions

func Encode

func Encode(dstBlack, dstRed io.Writer, img image.Image)

Encode encodes an image to the display's wire format.

Types

type Color

type Color struct {
	// 0 white, 1 black, 2 highlight
	C uint8
}

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

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) Draw

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

DrawAndRefresh draws an image to the display buffer 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) DrawAndRefresh

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

DrawAndRefresh is a convenience method for Draw and Refresh.

func (*Display) DrawAndRefreshImages

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

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

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) Refresh

func (d *Display) Refresh()

Refresh uploads the buffer to the display.

func (*Display) Reset

func (d *Display) Reset()

Reset clears all variables set on the Display.

Reset can be also used to awaken the device after a call to Sleep.

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().

func (*Display) Upload

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

Upload 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.

type Image

type Image struct {
	// This display represents black pixels as 0, white as 1, and a highlight in a separate buffer.
	// Images are stored as a bit per pixel.
	Black []byte
	// Highlights are represented as 0 white, 1 highlight.
	// Images are stored as a bit per pixel.
	Highlight []byte
	Rect      image.Rectangle
	Palette   color.Palette
	// contains filtered or unexported fields
}

func NewImage

func NewImage(r image.Rectangle) *Image

func (*Image) At

func (i *Image) At(x, y int) color.Color

func (*Image) Bounds

func (i *Image) Bounds() image.Rectangle

func (*Image) ColorModel

func (i *Image) ColorModel() color.Model

func (*Image) Reset

func (i *Image) Reset()

func (*Image) Set

func (i *Image) Set(x, y int, c color.Color)

func (*Image) SetColorIndex

func (i *Image) SetColorIndex(x, y int, index uint8)

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