display-epaper/run_darwin_arm64.go

47 lines
902 B
Go
Raw Normal View History

2024-09-15 09:01:13 +02:00
package main
import (
2024-09-15 10:46:07 +02:00
"context"
"fmt"
2024-09-15 12:00:36 +02:00
"github.com/Crocmagnon/display-epaper/fete"
"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"
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,
_ 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 {
return err
2024-09-15 09:01:13 +02:00
}
2024-09-15 21:18:06 +02:00
if err := draw2dimg.SaveToPngFile("out/black.png", img); err != nil {
return fmt.Errorf("saving img: %w", err)
2024-09-15 21:18:06 +02:00
}
2024-09-15 09:01:13 +02:00
return nil
}