Documentation
¶
Overview ¶
Package waveshare2in13v3 controls Waveshare 2.13 v3 e-paper displays.
Datasheet: https://files.waveshare.com/upload/5/59/2.13inch_e-Paper_V3_Specificition.pdf
Product page: 2.13 inch version 4: https://www.waveshare.com/wiki/2.13inch_e-Paper_HAT_Manual#Resources This display is an Active Matrix Electrophoretic Display (AM EPD), with interface and a reference system design. The display is capable to display imagesat 1-bit white, black full display capabilities. The 2.13inch active area contains 250×122 pixels. The module is a TFT-array driving electrophoresis display, withintegrated circuits including gate driver, source driver, MCU interface, timingcontroller, oscillator, DC-DC, SRAM, LUT, VCOM. Module can be used in portableelectronic devices, such as Electronic Shelf Label (ESL) System. v4 is fully compatible with version 3 however v4 features fast refresh capabilities v3 doesn't
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 := waveshare2in13v4.NewHat(b, &waveshare2in13v4.EPD2in13v4) // Display config and size
if err != nil {
log.Fatalf("Failed to initialize driver: %v", err)
}
err = dev.Init()
if err != nil {
log.Fatalf("Failed to initialize display: %v", err)
}
// Draw on it. Black text on a white background.
img := image1bit.NewVerticalLSB(dev.Bounds())
draw.Draw(img, img.Bounds(), &image.Uniform{image1bit.On}, image.Point{}, draw.Src)
f := basicfont.Face7x13
drawer := font.Drawer{
Dst: img,
Src: &image.Uniform{image1bit.Off},
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)
}
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 := waveshare2in13v4.NewHat(b, &waveshare2in13v4.EPD2in13v4) // Display config and size
if err != nil {
log.Fatalf("Failed to initialize driver: %v", err)
}
err = dev.Init()
if err != nil {
log.Fatalf("Failed to initialize display: %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)
}
Index ¶
- Variables
- type Corner
- type Dev
- func (d *Dev) Bounds() image.Rectangle
- func (d *Dev) Clear(color color.Color) error
- func (d *Dev) ColorModel() color.Model
- func (d *Dev) Draw(dstRect image.Rectangle, src image.Image, srcPts image.Point) error
- func (d *Dev) DrawPartial(dstRect image.Rectangle, src image.Image, srcPts image.Point) errordeprecated
- func (d *Dev) Halt() error
- func (d *Dev) Init() error
- func (d *Dev) Reset() error
- func (d *Dev) Sleep() error
- func (d *Dev) String() string
- type FastDisplay
- type LUT
- type Opts
- type PartialUpdate
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var EPD2in13v4 = Opts{
Width: 122,
Height: 250,
}
EPD2in13v4 cointains display configuration for the Waveshare 2in13v2.
Functions ¶
This section is empty.
Types ¶
type Corner ¶
type Corner uint8
Corner describes a corner on the physical device and is used to define the origin for drawing operations.
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev defines the handler which is used to access the display.
func NewHat ¶
NewHat creates new handler which is used to access the display. Default Waveshare Hat configuration is used.
func (*Dev) ColorModel ¶
ColorModel returns a 1Bit color model.
func (*Dev) Draw ¶
Draw draws the given image to the display. Only the destination area is uploaded. Depending on the update mode the whole display or the destination area is refreshed.
type FastDisplay ¶
type FastDisplay bool
FastDisplay defines if the display can display in fast mode.
type PartialUpdate ¶
type PartialUpdate bool
PartialUpdate defines if the display should do a full update or just a partial update.
const ( // Full should update the complete display. Full PartialUpdate = false // Partial should update only partial parts of the display. Partial PartialUpdate = true )
const ( // Updates the display fast. Fast PartialUpdate = true // Updates the display at normal speed. Normal PartialUpdate = false )