2024-09-15 09:01:13 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-09-15 10:46:07 +02:00
|
|
|
"context"
|
2024-09-15 12:00:36 +02:00
|
|
|
"github.com/Crocmagnon/display-epaper/fete"
|
2024-09-18 02:09:25 +02:00
|
|
|
"github.com/Crocmagnon/display-epaper/home_assistant"
|
2024-09-15 10:46:07 +02:00
|
|
|
"github.com/Crocmagnon/display-epaper/transports"
|
2024-09-15 23:25:17 +02:00
|
|
|
"github.com/Crocmagnon/display-epaper/weather"
|
2024-09-15 09:01:13 +02:00
|
|
|
"github.com/llgcode/draw2d/draw2dimg"
|
|
|
|
"log"
|
2024-09-15 12:00:36 +02:00
|
|
|
"time"
|
2024-09-15 09:01:13 +02:00
|
|
|
)
|
|
|
|
|
2024-09-15 23:25:17 +02:00
|
|
|
func run(
|
|
|
|
ctx context.Context,
|
2024-09-16 14:12:51 +02:00
|
|
|
_ time.Duration,
|
2024-09-16 18:15:42 +02:00
|
|
|
_ time.Duration,
|
2024-09-15 23:25:17 +02:00
|
|
|
transportsClient *transports.Client,
|
|
|
|
feteClient *fete.Client,
|
|
|
|
weatherClient *weather.Client,
|
2024-09-18 22:26:40 +02:00
|
|
|
hassClient *home_assistant.Client,
|
2024-09-15 23:25:17 +02:00
|
|
|
) error {
|
2024-09-16 18:09:00 +02:00
|
|
|
img, err := getImg(
|
2024-09-15 23:55:31 +02:00
|
|
|
ctx,
|
|
|
|
func() time.Time {
|
|
|
|
t, err := time.Parse(time.DateOnly, "2024-08-01zzz")
|
|
|
|
if err != nil {
|
|
|
|
return time.Now()
|
|
|
|
}
|
|
|
|
return t
|
|
|
|
},
|
|
|
|
transportsClient,
|
|
|
|
feteClient,
|
|
|
|
weatherClient,
|
2024-09-18 22:26:40 +02:00
|
|
|
hassClient,
|
2024-09-15 23:55:31 +02:00
|
|
|
)
|
2024-09-15 09:01:13 +02:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2024-09-15 21:18:06 +02:00
|
|
|
if err := draw2dimg.SaveToPngFile("out/black.png", img); err != nil {
|
|
|
|
log.Fatalf("error saving image: %v", err)
|
|
|
|
}
|
2024-09-15 09:01:13 +02:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|