From 6206898fb127a464aa191baf67075cf819f546f5 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 16 Sep 2024 00:35:45 +0200 Subject: [PATCH] change temp display --- go.mod | 1 - go.sum | 2 -- img.go | 15 +++++++-------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 26ae5a0..4d408f7 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ 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 diff --git a/go.sum b/go.sum index cf3a985..3df8a82 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,6 @@ 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= diff --git a/img.go b/img.go index 3cb74df..0a09352 100644 --- a/img.go +++ b/img.go @@ -11,8 +11,6 @@ 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" @@ -100,10 +98,11 @@ func drawWeather(gc *draw2dimg.GraphicContext, wthr *weather.Prevision) { log.Println("Failed to draw weather icon:", err) } - 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) + text(gc, formatTemp(wthr.Current.Temp), 23, leftX, 120) + + text(gc, "max "+formatTemp(daily.Temp.Max), 18, 120, 45) + text(gc, fmt.Sprintf("pluie %v%%", int(math.Round(daily.Pop*100))), 18, 120, 80) + text(gc, dailyWeather.Description, 18, 120, 115) } func drawWeatherIcon(gc *draw2dimg.GraphicContext, dailyWeather weather.Weather) error { @@ -123,8 +122,8 @@ func drawWeatherIcon(gc *draw2dimg.GraphicContext, dailyWeather weather.Weather) return nil } -func formatTemp(name string, temp float64) string { - return fmt.Sprintf("%v : %v°C", name, int(math.Round(temp))) +func formatTemp(temp float64) string { + return fmt.Sprintf("%v°C", int(math.Round(temp))) } func drawVelov(gc *draw2dimg.GraphicContext, station *transports.Station, yOffset float64) {