Documentation ¶
Overview ¶
Package epd controls Waveshare e-paper series displays.
More details ¶
Datasheets ¶
https://www.waveshare.com/w/upload/e/e6/2.13inch_e-Paper_Datasheet.pdf
Product page:
2.13 Inch version: https://www.waveshare.com/wiki/2.13inch_e-Paper_HAT
1.54 inch version: https://www.waveshare.com/wiki/1.54inch_e-Paper_Module
Example ¶
// Make sure periph is initialized. if _, err := host.Init(); err != nil { log.Fatal(err) } // Use spireg SPI bus registry to find the first available SPI bus. b, err := spireg.Open("") if err != nil { log.Fatal(err) } defer b.Close() dev, err := epd.NewSPIHat(b, &epd.EPD2in13) // Display config and size if err != nil { log.Fatalf("failed to initialize epd: %v", err) } // Draw on it. img := image1bit.NewVerticalLSB(dev.Bounds()) // Note: this code is commented out so periph does not depend on: // "golang.org/x/image/font" // "golang.org/x/image/font/basicfont" // "golang.org/x/image/math/fixed" // // f := basicfont.Face7x13 // drawer := font.Drawer{ // Dst: img, // Src: &image.Uniform{image1bit.On}, // Face: f, // Dot: fixed.P(0, img.Bounds().Dy()-1-f.Descent), // } // drawer.DrawString("Hello from periph!") if err := dev.Draw(dev.Bounds(), img, image.Point{}); err != nil { log.Fatal(err) } dev.DisplayFrame() // After drawing on the display, you have to show the frame
Output:
Example (Other) ¶
// Make sure periph is initialized. if _, err := host.Init(); err != nil { log.Fatal(err) } // Use spireg SPI bus registry to find the first available SPI bus. b, err := spireg.Open("") if err != nil { log.Fatal(err) } defer b.Close() dev, err := epd.NewSPIHat(b, &epd.EPD2in13) // Display config and size if err != nil { log.Fatalf("failed to initialize epd: %v", err) } var img image.Image // Note: this code is commented out so periph does not depend on: // "github.com/fogleman/gg" // "github.com/golang/freetype/truetype" // "golang.org/x/image/font/gofont/goregular" // // bounds := dev.Bounds() // w := bounds.Dx() // h := bounds.Dy() // dc := gg.NewContext(w, h) // im, err := gg.LoadPNG("gopher.png") // if err != nil { // panic(err) // } // dc.SetRGB(1, 1, 1) // dc.Clear() // dc.SetRGB(0, 0, 0) // dc.Rotate(gg.Radians(90)) // dc.Translate(0.0, -float64(h/2)) // font, err := truetype.Parse(goregular.TTF) // if err != nil { // panic(err) // } // face := truetype.NewFace(font, &truetype.Options{ // Size: 16, // }) // dc.SetFontFace(face) // text := "Hello from periph!" // tw, th := dc.MeasureString(text) // dc.DrawImage(im, 120, 30) // padding := 8.0 // dc.DrawRoundedRectangle(padding*2, padding*2, tw+padding*2, th+padding, 10) // dc.Stroke() // dc.DrawString(text, padding*3, padding*2+th) // for i := 0; i < 10; i++ { // dc.DrawCircle(float64(30+(10*i)), 100, 5) // } // for i := 0; i < 10; i++ { // dc.DrawRectangle(float64(30+(10*i)), 80, 5, 5) // } // dc.Fill() // img = dc.Image() if err := dev.Draw(dev.Bounds(), img, image.Point{}); err != nil { log.Fatal(err) } dev.DisplayFrame() // After drawing on the display, you have to show the frame
Output:
Index ¶
- Variables
- type Dev
- func (d *Dev) Bounds() image.Rectangle
- func (d *Dev) ClearFrameMemory(color byte) error
- func (d *Dev) ColorModel() color.Model
- func (d *Dev) DisplayFrame() error
- func (d *Dev) Draw(r image.Rectangle, src image.Image, sp image.Point) error
- func (d *Dev) Halt() error
- func (d *Dev) Init() error
- func (d *Dev) Reset()
- func (d *Dev) Sleep() error
- func (d *Dev) String() string
- type LUT
- type Opts
- type PartialUpdate
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var EPD1in54 = Opts{ W: 200, H: 200, FullUpdate: LUT{ 0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00, }, PartialUpdate: LUT{ 0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, }
EPD1in54 is the config for the 1.54 inch display.
var EPD2in13 = Opts{ W: 128, H: 250, FullUpdate: LUT{ 0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, }, PartialUpdate: LUT{ 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, }
EPD2in13 is the config for the 2.13 inch display.
var EPD2in13v2 = Opts{ W: 128, H: 250, FullUpdate: LUT{ 0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x02, 0x09, 0x09, 0x00, 0x00, 0x02, 0x03, 0x03, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x41, 0xA8, 0x32, 0x30, 0x0A, }, PartialUpdate: LUT{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x41, 0xA8, 0x32, 0x30, 0x0A, }, }
EPD2in13v2 is the config for the 2.13 inch v2 display.
Functions ¶
This section is empty.
Types ¶
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev is an open handle to the display controller.
func NewSPI ¶
NewSPI returns a Dev object that communicates over SPI to a E-Paper display controller.
func NewSPIHat ¶
NewSPIHat returns a Dev object that communicates over SPI and have the default config for the e-paper hat for raspberry pi
func (*Dev) ClearFrameMemory ¶
ClearFrameMemory clear the frame memory with the specified color. this won't update the display.
func (*Dev) ColorModel ¶
ColorModel implements display.Drawer. It is a one bit color model, as implemented by image1bit.Bit.
func (*Dev) DisplayFrame ¶
DisplayFrame update the display.
There are 2 memory areas embedded in the e-paper display but once this function is called, the next action of SetFrameMemory or ClearFrame will set the other memory area.
func (*Dev) Init ¶
Init initialize the display config. This method is already called when creating a device using NewSPI and NewSPIHat methods.
It should be only used when you put the device to sleep and need to re-init the device.
type LUT ¶
type LUT []byte
LUT contains the display specific waveform for the pixel programming of the display.
type PartialUpdate ¶
type PartialUpdate bool
PartialUpdate represents if updates to the display should be full or partial.
const ( // Full LUT config to update all the display Full PartialUpdate = false // Partial LUT config only a part of the display Partial PartialUpdate = true )