Documentation ¶
Overview ¶
Package inky drives an Inky pHAT, pHAT v2 or wHAT E ink display.
Datasheet ¶
Inky lacks a true datasheet, so the code here is derived from the reference implementation by Pimoroni: https://github.com/pimoroni/inky
The display seems to use a SSD1675 controller: https://www.china-epaper.com/uploads/soft/DEPG0420R01V3.0.pdf
Example ¶
path := flag.String("image", "", "Path to image file (212x104) to display") flag.Parse() f, err := os.Open(*path) if err != nil { log.Fatal(err) } defer f.Close() img, err := png.Decode(f) if err != nil { log.Fatal(err) } if _, err = host.Init(); err != nil { log.Fatal(err) } b, err := spireg.Open("SPI0.0") if err != nil { log.Fatal(err) } dc := gpioreg.ByName("22") reset := gpioreg.ByName("27") busy := gpioreg.ByName("17") dev, err := inky.New(b, dc, reset, busy, &inky.Opts{ Model: inky.PHAT, ModelColor: inky.Red, BorderColor: inky.Black, }) if err != nil { log.Fatal(err) } if err := dev.Draw(img.Bounds(), img, image.Point{}); err != nil { log.Fatal(err) }
Output:
Index ¶
- type Color
- type Dev
- func (d *Dev) Bounds() image.Rectangle
- func (d *Dev) ColorModel() color.Model
- func (d *Dev) Draw(dstRect image.Rectangle, src image.Image, srcPtrs image.Point) error
- func (d *Dev) DrawAll(src image.Image) error
- func (d *Dev) Halt() error
- func (d *Dev) Height() int
- func (d *Dev) SetBorder(c Color)
- func (d *Dev) SetFlipHorizontally(f bool)
- func (d *Dev) SetFlipVertically(f bool)
- func (d *Dev) SetModelColor(c Color) error
- func (d *Dev) String() string
- func (d *Dev) Width() int
- type DevImpression
- func (d *DevImpression) At(x, y int) color.Color
- func (d *DevImpression) ColorModel() color.Model
- func (d *DevImpression) Draw(r image.Rectangle, src image.Image, sp image.Point) error
- func (d *DevImpression) DrawAll(src image.Image) error
- func (d *DevImpression) Render() error
- func (d *DevImpression) Saturation() uint
- func (d *DevImpression) Set(x, y int, c color.Color)
- func (d *DevImpression) SetBorder(c ImpressionColor)
- func (d *DevImpression) SetSaturation(level uint) error
- type ImpressionColor
- type Model
- type Opts
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color int
Color is used to define which model of inky is being used, and also for setting the border color.
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev is a handle to an Inky.
func (*Dev) ColorModel ¶
ColorModel implements display.Drawer Maps white to white, black to black and anything else as red. Red is used as a placeholder for the display's third color, i.e., red or yellow.
func (*Dev) SetBorder ¶
SetBorder changes the border color. This will not take effect until the next Draw().
func (*Dev) SetFlipHorizontally ¶ added in v3.7.1
SetFlipHorizontally flips the image horizontally.
func (*Dev) SetFlipVertically ¶ added in v3.7.1
SetFlipVertically flips the image horizontally.
func (*Dev) SetModelColor ¶
SetModelColor changes the model color. This will not take effect until the next Draw(). Useful if you want to switch between two-color and three-color drawing.
type DevImpression ¶ added in v3.7.1
type DevImpression struct { *Dev // Color Palette used to convert images to the 7 color. Palette color.Palette // Representation of the pixels. Pix []uint8 // contains filtered or unexported fields }
DevImpression is a handle to an Inky Impression.
func NewImpression ¶ added in v3.7.1
func NewImpression(p spi.Port, dc gpio.PinOut, reset gpio.PinOut, busy gpio.PinIn, o *Opts) (*DevImpression, error)
NewImpression opens a handle to an Inky Impression.
Example ¶
path := flag.String("image", "", "Path to image file (600x448) to display") flag.Parse() f, err := os.Open(*path) if err != nil { log.Fatal(err) } defer f.Close() m, _, err := image.Decode(f) if err != nil { log.Fatal(err) } if _, err = host.Init(); err != nil { log.Fatal(err) } b, err := spireg.Open("SPI0.0") if err != nil { log.Fatal(err) } dc := gpioreg.ByName("22") reset := gpioreg.ByName("27") busy := gpioreg.ByName("17") eeprom, err := i2creg.Open("") if err != nil { log.Fatal(err) } defer eeprom.Close() o, err := inky.DetectOpts(eeprom) if err != nil { log.Fatal(err) } dev, err := inky.NewImpression(b, dc, reset, busy, o) if err != nil { log.Fatal(err) } if err := dev.Draw(m.Bounds(), m, image.Point{}); err != nil { log.Fatal(err) }
Output:
func (*DevImpression) At ¶ added in v3.7.1
func (d *DevImpression) At(x, y int) color.Color
At returns the color of the pixel at (x, y).
func (*DevImpression) ColorModel ¶ added in v3.7.1
func (d *DevImpression) ColorModel() color.Model
ColorModel returns the device native color model.
func (*DevImpression) DrawAll ¶ added in v3.7.1
func (d *DevImpression) DrawAll(src image.Image) error
DrawAll redraws the whole display.
func (*DevImpression) Render ¶ added in v3.7.1
func (d *DevImpression) Render() error
Render renders the content of the Pix to the screen.
func (*DevImpression) Saturation ¶ added in v3.7.1
func (d *DevImpression) Saturation() uint
Saturation returns the current saturation level.
func (*DevImpression) Set ¶ added in v3.7.1
func (d *DevImpression) Set(x, y int, c color.Color)
Set sets the pixel at (x, y) to the given color. This will not take effect until the next Draw().
func (*DevImpression) SetBorder ¶ added in v3.7.1
func (d *DevImpression) SetBorder(c ImpressionColor)
SetBorder changes the border color. This will not take effect until the next Draw().
func (*DevImpression) SetSaturation ¶ added in v3.7.1
func (d *DevImpression) SetSaturation(level uint) error
SetSaturaton changes the saturation level. This will not take effect until the next Draw().
type ImpressionColor ¶ added in v3.7.1
type ImpressionColor uint8
ImpressionColor is used to define colors used by Inky Impression models.
const ( BlackImpression ImpressionColor = iota WhiteImpression GreenImpression BlueImpression RedImpression YellowImpression OrangeImpression CleanImpression )
func (*ImpressionColor) Set ¶ added in v3.7.1
func (c *ImpressionColor) Set(s string) error
Set sets the ImpressionColor to a value represented by the string s. Set implements the flag.Value interface.
func (ImpressionColor) String ¶ added in v3.7.1
func (i ImpressionColor) String() string
type Model ¶
type Model int
Model lists the supported e-ink display models.
type Opts ¶
type Opts struct { // Boards's width and height. Width int Height int // Model being used. Model Model // Model color. ModelColor Color // Initial border color. Will be set on the first Draw(). BorderColor Color // Board information. PCBVariant uint DisplayVariant uint }
Opts is the options to specify which device is being controlled and its default settings.