Compare commits
2 commits
816d0e53d0
...
d12e39d6fa
Author | SHA1 | Date | |
---|---|---|---|
d12e39d6fa | |||
a2354d5187 |
BIN
contrib/icon-sources/01d.afdesign
Normal file
BIN
contrib/icon-sources/02d.afdesign
Normal file
BIN
contrib/icon-sources/03d.afdesign
Normal file
BIN
contrib/icon-sources/04d.afdesign
Normal file
BIN
contrib/icon-sources/09d.afdesign
Normal file
BIN
contrib/icon-sources/10d.afdesign
Normal file
BIN
contrib/icon-sources/11d.afdesign
Normal file
BIN
icons/01d.png
Before Width: | Height: | Size: 945 B After Width: | Height: | Size: 2.8 KiB |
BIN
icons/02d.png
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 3.2 KiB |
BIN
icons/03d.png
Before Width: | Height: | Size: 837 B After Width: | Height: | Size: 3 KiB |
BIN
icons/04d.png
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 3.2 KiB |
BIN
icons/09d.png
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.5 KiB |
BIN
icons/10d.png
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 3.7 KiB |
BIN
icons/11d.png
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.6 KiB |
33
img.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Crocmagnon/display-epaper/epd"
|
"github.com/Crocmagnon/display-epaper/epd"
|
||||||
"github.com/Crocmagnon/display-epaper/fete"
|
"github.com/Crocmagnon/display-epaper/fete"
|
||||||
|
"github.com/Crocmagnon/display-epaper/home_assistant"
|
||||||
"github.com/Crocmagnon/display-epaper/quotes"
|
"github.com/Crocmagnon/display-epaper/quotes"
|
||||||
"github.com/Crocmagnon/display-epaper/transports"
|
"github.com/Crocmagnon/display-epaper/transports"
|
||||||
"github.com/Crocmagnon/display-epaper/weather"
|
"github.com/Crocmagnon/display-epaper/weather"
|
||||||
|
@ -29,23 +30,18 @@ const (
|
||||||
rightX = 530
|
rightX = 530
|
||||||
)
|
)
|
||||||
|
|
||||||
func getImg(
|
func getImg(ctx context.Context, nowFunc func() time.Time, transportsClient *transports.Client, feteClient *fete.Client, weatherClient *weather.Client, hassClient *home_assistant.Client) (*image.RGBA, error) {
|
||||||
ctx context.Context,
|
|
||||||
nowFunc func() time.Time,
|
|
||||||
transportsClient *transports.Client,
|
|
||||||
feteClient *fete.Client,
|
|
||||||
weatherClient *weather.Client,
|
|
||||||
) (*image.RGBA, error) {
|
|
||||||
var (
|
var (
|
||||||
bus *transports.Passages
|
bus *transports.Passages
|
||||||
tram *transports.Passages
|
tram *transports.Passages
|
||||||
velovRoc *transports.Station
|
velovRoc *transports.Station
|
||||||
fetes *fete.Fete
|
fetes *fete.Fete
|
||||||
wthr *weather.Prevision
|
wthr *weather.Prevision
|
||||||
|
msg string
|
||||||
)
|
)
|
||||||
|
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
wg.Add(5)
|
wg.Add(6)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
@ -112,8 +108,19 @@ func getImg(
|
||||||
log.Println("error getting weather:", err)
|
log.Println("error getting weather:", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
quote := quotes.GetQuote(nowFunc())
|
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
msg, err = hassClient.GetState(ctx, "input_text.e_paper_message")
|
||||||
|
if err != nil {
|
||||||
|
log.Println("error getting hass message:", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
img := newWhite()
|
img := newWhite()
|
||||||
|
|
||||||
|
@ -125,18 +132,22 @@ func getImg(
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
if msg == "" {
|
||||||
|
msg = quotes.GetQuote(nowFunc())
|
||||||
|
}
|
||||||
|
|
||||||
drawTCL(gc, bus, 55)
|
drawTCL(gc, bus, 55)
|
||||||
drawTCL(gc, tram, 190)
|
drawTCL(gc, tram, 190)
|
||||||
drawVelov(gc, velovRoc, 350)
|
drawVelov(gc, velovRoc, 350)
|
||||||
drawDate(gc, nowFunc())
|
drawDate(gc, nowFunc())
|
||||||
drawFete(gc, fetes)
|
drawFete(gc, fetes)
|
||||||
drawWeather(gc, wthr)
|
drawWeather(gc, wthr)
|
||||||
drawQuote(gc, quote)
|
drawMsg(gc, msg)
|
||||||
|
|
||||||
return img, nil
|
return img, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func drawQuote(gc *draw2dimg.GraphicContext, quote string) {
|
func drawMsg(gc *draw2dimg.GraphicContext, quote string) {
|
||||||
text(gc, quote, 15, leftX, 450)
|
text(gc, quote, 15, leftX, 450)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ func run(
|
||||||
transportsClient *transports.Client,
|
transportsClient *transports.Client,
|
||||||
feteClient *fete.Client,
|
feteClient *fete.Client,
|
||||||
weatherClient *weather.Client,
|
weatherClient *weather.Client,
|
||||||
_ *home_assistant.Client,
|
hassClient *home_assistant.Client,
|
||||||
) error {
|
) error {
|
||||||
img, err := getImg(
|
img, err := getImg(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -32,6 +32,7 @@ func run(
|
||||||
transportsClient,
|
transportsClient,
|
||||||
feteClient,
|
feteClient,
|
||||||
weatherClient,
|
weatherClient,
|
||||||
|
hassClient,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -87,6 +87,7 @@ func loop(
|
||||||
transportsClient,
|
transportsClient,
|
||||||
feteClient,
|
feteClient,
|
||||||
weatherClient,
|
weatherClient,
|
||||||
|
hassClient,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("getting black: %w", err)
|
return nil, fmt.Errorf("getting black: %w", err)
|
||||||
|
|