From 5a14879593d0c72586fae218ae8bf77bc57d4ce7 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Sun, 16 Jan 2022 13:43:40 +0100 Subject: [PATCH] waveshare2in13v2: List width first in String() result The convention is to write dimensions with the width first. --- waveshare2in13v2/waveshare213v2.go | 4 +++- waveshare2in13v2/waveshare213v2_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/waveshare2in13v2/waveshare213v2.go b/waveshare2in13v2/waveshare213v2.go index 5d1849e..4bc988a 100644 --- a/waveshare2in13v2/waveshare213v2.go +++ b/waveshare2in13v2/waveshare213v2.go @@ -281,7 +281,9 @@ func (d *Dev) Halt() error { // String returns a string containing configuration information. func (d *Dev) String() string { - return fmt.Sprintf("epd.Dev{%s, %s, Height: %d, Width: %d}", d.c, d.dc, d.opts.Height, d.opts.Width) + bounds := d.Bounds() + + return fmt.Sprintf("epd.Dev{%s, %s, Width: %d, Height: %d}", d.c, d.dc, bounds.Dx(), bounds.Dy()) } // Sleep makes the controller enter deep sleep mode. It can be woken up by diff --git a/waveshare2in13v2/waveshare213v2_test.go b/waveshare2in13v2/waveshare213v2_test.go index 54749c1..2a5782d 100644 --- a/waveshare2in13v2/waveshare213v2_test.go +++ b/waveshare2in13v2/waveshare213v2_test.go @@ -25,14 +25,14 @@ func TestNew(t *testing.T) { }{ { name: "empty", - wantString: "epd.Dev{playback, (0), Height: 0, Width: 0}", + wantString: "epd.Dev{playback, (0), Width: 0, Height: 0}", }, { name: "EPD2in13v2", opts: EPD2in13v2, wantBounds: image.Rect(0, 0, 122, 250), wantBufferBounds: image.Rect(0, 0, 128, 250), - wantString: "epd.Dev{playback, (0), Height: 250, Width: 122}", + wantString: "epd.Dev{playback, (0), Width: 122, Height: 250}", }, } { t.Run(tc.name, func(t *testing.T) {