Skip to content

Commit

Permalink
[inky] Add Inky Impression 5.7" and 4" support (#55)
Browse files Browse the repository at this point in the history
It is a 7 colour ePaper/eInk HAT that comes with 5.7" (600 x 448 pixel) or 4" (640 x 400 pixel).

Refactors the existing 3 color Inky and adds additional fields to
auto-detect via EEPROM.

Tested with 5.7" version.
  • Loading branch information
caglar10ur authored Jan 16, 2023
1 parent ae32059 commit e271f7c
Show file tree
Hide file tree
Showing 7 changed files with 852 additions and 179 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ jobs:
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install golang.org/x/tools/cmd/stringer@latest
- name: 'go install necessary tools (ubuntu)'
if: always() && matrix.os == 'ubuntu-latest'
run: |
Expand Down
50 changes: 50 additions & 0 deletions inky/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"

"periph.io/x/conn/v3/gpio/gpioreg"
"periph.io/x/conn/v3/i2c/i2creg"
"periph.io/x/conn/v3/spi/spireg"
"periph.io/x/devices/v3/inky"
"periph.io/x/host/v3"
Expand Down Expand Up @@ -58,3 +59,52 @@ func Example() {
log.Fatal(err)
}
}

func ExampleNewImpression() {
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)
}
}
Loading

0 comments on commit e271f7c

Please sign in to comment.