mirror of
https://github.com/Crocmagnon/display-epaper.git
synced 2024-11-23 22:48:03 +01:00
45 lines
906 B
Go
45 lines
906 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"github.com/Crocmagnon/display-epaper/fete"
|
|
"github.com/Crocmagnon/display-epaper/home_assistant"
|
|
"github.com/Crocmagnon/display-epaper/transports"
|
|
"github.com/Crocmagnon/display-epaper/weather"
|
|
"github.com/llgcode/draw2d/draw2dimg"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func run(
|
|
ctx context.Context,
|
|
_ time.Duration,
|
|
_ time.Duration,
|
|
transportsClient *transports.Client,
|
|
feteClient *fete.Client,
|
|
weatherClient *weather.Client,
|
|
hassClient *home_assistant.Client,
|
|
) error {
|
|
img, err := getImg(
|
|
ctx,
|
|
func() time.Time {
|
|
t, err := time.Parse(time.DateOnly, "2024-08-01zzz")
|
|
if err != nil {
|
|
return time.Now()
|
|
}
|
|
return t
|
|
},
|
|
transportsClient,
|
|
feteClient,
|
|
weatherClient,
|
|
hassClient,
|
|
)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
if err := draw2dimg.SaveToPngFile("out/black.png", img); err != nil {
|
|
log.Fatalf("error saving image: %v", err)
|
|
}
|
|
|
|
return nil
|
|
}
|