Skip to content

Commit 5a3d358

Browse files
authored
Update demo (#12)
1 parent 905e306 commit 5a3d358

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
periph.io/x/conn/v3 v3.7.2
1212
periph.io/x/d2xx v0.1.1
1313
periph.io/x/devices/v3 v3.7.4
14-
periph.io/x/host/v3 v3.8.3
14+
periph.io/x/host/v3 v3.8.5
1515
)
1616

1717
require github.com/jonboulle/clockwork v0.5.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ periph.io/x/d2xx v0.1.1 h1:LHp+u+qAWLB5THrTT/AzyjdvfUhllvDF5wBJP7uvn+U=
88
periph.io/x/d2xx v0.1.1/go.mod h1:rLM321G11Fc14Pp088khBkmXb70Pxx/kCPaIK7uRUBc=
99
periph.io/x/devices/v3 v3.7.4 h1:g9CGKTtiXS9iyDFDba4sr9pYde4dy+ZCKRPuKpKJdKo=
1010
periph.io/x/devices/v3 v3.7.4/go.mod h1:FqFG9RotW2aCkfIlAes3qxziwgjRTncTMS5cSOcizNg=
11-
periph.io/x/host/v3 v3.8.3 h1:v90ozCFDWgEyfNElZ+JnOvq0jAdW0vmgjCUy8dYXDds=
12-
periph.io/x/host/v3 v3.8.3/go.mod h1:uKrIpfXjELwHkwGBNe6aos//XiQ/3uxDa1P2BmLV6Ok=
11+
periph.io/x/host/v3 v3.8.5 h1:g4g5xE1XZtDiGl1UAJaUur1aT7uNiFLMkyMEiZ7IHII=
12+
periph.io/x/host/v3 v3.8.5/go.mod h1:hPq8dISZIc+UNfWoRj+bPH3XEBQqJPdFdx218W92mdc=

inky/main.go

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ import (
2222
func mainImpl() error {
2323
spiPort := flag.String("spi", "SPI0.0", "Name or number of SPI port to open")
2424
path := flag.String("image", "", "Path to a png file to display on the inky")
25-
dcPin := flag.String("dc", "22", "Inky DC Pin")
26-
resetPin := flag.String("reset", "27", "Inky Reset Pin")
27-
busyPin := flag.String("busy", "17", "Inky Busy Pin")
28-
model := inky.PHAT
29-
flag.Var(&model, "model", "Inky model (PHAT or WHAT)")
30-
modelColor := inky.Red
31-
flag.Var(&modelColor, "model-color", "Inky model color (black, red or yellow)")
32-
borderColor := inky.Black
33-
flag.Var(&borderColor, "border-color", "Border color (black, white, red or yellow)")
25+
dcPin := flag.String("dc", "GPIO22", "Inky DC Pin")
26+
resetPin := flag.String("reset", "GPIO27", "Inky Reset Pin")
27+
busyPin := flag.String("busy", "GPIO17", "Inky Busy Pin")
28+
model := inky.IMPRESSION73
29+
flag.Var(&model, "model", "Inky model (PHAT, PHAT2, WHAT, IMPRESSION4, IMPRESSION57, or IMPRESSION73)")
30+
modelColor := inky.Multi
31+
flag.Var(&modelColor, "model-color", "Inky model color (multi, black, red or yellow)")
32+
borderColor := inky.Red
33+
flag.Var(&borderColor, "border-color", "Border color (multi, black, white, red or yellow)")
3434
flag.Parse()
3535

3636
// Open and decode the image.
@@ -73,16 +73,26 @@ func mainImpl() error {
7373
}
7474

7575
log.Printf("Creating inky...")
76-
dev, err := inky.New(b, dc, reset, busy, &inky.Opts{
76+
opts := &inky.Opts{
7777
Model: model,
7878
ModelColor: modelColor,
7979
BorderColor: borderColor,
80-
})
81-
if err != nil {
82-
return err
8380
}
8481

8582
log.Printf("Drawing image...")
83+
84+
if model <= inky.PHAT2 {
85+
dev, eInky := inky.New(b, dc, reset, busy, opts)
86+
if eInky != nil {
87+
return eInky
88+
}
89+
return dev.Draw(img.Bounds(), img, image.Point{})
90+
}
91+
92+
dev, err := inky.NewImpression(b, dc, reset, busy, opts)
93+
if err != nil {
94+
return err
95+
}
8696
return dev.Draw(img.Bounds(), img, image.Point{})
8797
}
8898

0 commit comments

Comments
 (0)