Documentation ¶
Overview ¶
Package epd7in5bhd is for the Waveshare 7.5 inch HD (B/C) e-Paper display.
Index ¶
- Constants
- Variables
- func Encode(dstBlack, dstRed io.Writer, img image.Image)
- type Color
- type Display
- func (d *Display) Clear()
- func (d *Display) Draw(img image.Image)
- func (d *Display) DrawAndRefresh(img image.Image)
- func (d *Display) DrawAndRefreshImages(black, redyellow image.Image)
- func (d *Display) Init()
- func (d *Display) Refresh()
- func (d *Display) Reset()
- func (d *Display) Sleep()
- func (d *Display) Upload(blackImg, redImg []byte)
- type Image
- type Pins
Constants ¶
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 ¶
var ( White = Color{0} Black = Color{1} Highlight = Color{2} Model = color.ModelFunc(model) )
var DefaultPins = Pins{
Busy: "P1_18",
CS: "P1_24",
DC: "P1_22",
RST: "P1_11",
}
var DefaultWait = 25 * time.Second
DefaultSleep is the default time to wait for a screen refresh. The official documented refresh time is 22 seconds.
var (
DisplayBounds = image.Rect(0, 0, DisplayWidth, DisplayHeight)
)
Functions ¶
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 ¶
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) Draw ¶
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 ¶
DrawAndRefresh is a convenience method for Draw and Refresh.
func (*Display) DrawAndRefreshImages ¶
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) 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 ¶
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 }