reorganize & resize

This commit is contained in:
Gabriel Augendre 2024-09-15 23:38:24 +02:00
parent 567f7517f9
commit 73d35661c0
4 changed files with 13 additions and 7 deletions

1
contrib/weather.json Normal file

File diff suppressed because one or more lines are too long

1
go.mod
View file

@ -14,6 +14,7 @@ require (
require (
github.com/carlmjohnson/requests v0.24.2
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
golang.org/x/text v0.18.0
)
require golang.org/x/net v0.27.0 // indirect

2
go.sum
View file

@ -12,6 +12,8 @@ golang.org/x/image v0.20.0 h1:7cVCUjQwfL18gyBJOmYvptfSHS8Fb3YUDtfLIZ7Nbpw=
golang.org/x/image v0.20.0/go.mod h1:0a88To4CYVBAHp5FXJm8o7QbUl37Vd85ply1vyD8auM=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
periph.io/x/conn/v3 v3.7.0 h1:f1EXLn4pkf7AEWwkol2gilCNZ0ElY+bxS4WE2PQXfrA=
periph.io/x/conn/v3 v3.7.0/go.mod h1:ypY7UVxgDbP9PJGwFSVelRRagxyXYfttVh7hJZUHEhg=
periph.io/x/host/v3 v3.8.2 h1:ayKUDzgUCN0g8+/xM9GTkWaOBhSLVcVHGTfjAOi8OsQ=

16
img.go
View file

@ -10,6 +10,8 @@ import (
"github.com/Crocmagnon/display-epaper/weather"
"github.com/llgcode/draw2d"
"github.com/llgcode/draw2d/draw2dimg"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"image"
"image/color"
"log"
@ -84,10 +86,10 @@ func drawWeather(gc *draw2dimg.GraphicContext, wthr *weather.Prevision) {
log.Println("Failed to draw weather icon:", err)
}
text(gc, formatTemp("Act", wthr.Current.Temp), 18, 100, 45)
text(gc, formatTemp("Max", daily.Temp.Max), 18, 220, 45)
text(gc, fmt.Sprintf("Pluie : %v%%", int(math.Round(daily.Pop))), 18, 100, 75)
text(gc, dailyWeather.Description, 18, leftX, 110)
text(gc, formatTemp("Act", wthr.Current.Temp), 18, 120, 45)
text(gc, formatTemp("Max", daily.Temp.Max), 18, 240, 45)
text(gc, fmt.Sprintf("Pluie : %v%%", int(math.Round(daily.Pop))), 18, 120, 80)
text(gc, cases.Title(language.French).String(dailyWeather.Description), 18, 120, 115)
}
func drawWeatherIcon(gc *draw2dimg.GraphicContext, dailyWeather weather.Weather) error {
@ -121,8 +123,8 @@ func drawVelov(gc *draw2dimg.GraphicContext, station *transports.Station, yOffse
}
func drawDate(gc *draw2dimg.GraphicContext, now time.Time) {
text(gc, now.Format("15:04"), 60, leftX, 240)
text(gc, getDate(now), 30, leftX, 285)
text(gc, now.Format("15:04"), 110, leftX, 300)
text(gc, getDate(now), 30, leftX, 345)
}
func drawFete(gc *draw2dimg.GraphicContext, fetes *fete.Fete) {
@ -130,7 +132,7 @@ func drawFete(gc *draw2dimg.GraphicContext, fetes *fete.Fete) {
return
}
text(gc, fmt.Sprintf("On fête les %s", fetes.Name), 18, leftX, 400)
text(gc, fmt.Sprintf("On fête les %s", fetes.Name), 18, leftX, 380)
}
func drawTCL(gc *draw2dimg.GraphicContext, passages *transports.Passages, yoffset float64) {