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