From 54b23e3565d02730bdcc07ec0b18dd4b7bad3a4d Mon Sep 17 00:00:00 2001 From: Yurii Soldak Date: Wed, 13 Dec 2023 00:05:40 +0100 Subject: [PATCH] Fix wrong bluetooth address displayed --- src/display/display.go | 14 +++++++------- src/display/display_nano-33-ble.go | 6 ++---- src/display/display_xiao-ble.go | 6 ++---- src/main.go | 12 ++++++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/display/display.go b/src/display/display.go index 26f3853..3c521cc 100644 --- a/src/display/display.go +++ b/src/display/display.go @@ -28,7 +28,7 @@ type Display struct { func New() *Display { return &Display{ Paired: false, - Address: "B1:6B:00:B5:BA:BE", + Address: "Calibrating...", Channels: [3]uint16{1500, 1500, 1500}, } } @@ -49,19 +49,19 @@ func (d *Display) Configure() { } func (d *Display) Run() { + d.showVersion() d.showAddress() - clearVersion := true + clear := true for { if d.Stable { - if clearVersion { - d.showVersion(BLACK) - clearVersion = false + if clear { + d.device.ClearDisplay() + d.showAddress() + clear = false } for i := 0; i < 3; i++ { d.showValue(i) } - } else { - d.showVersion(WHITE) } if d.Bluetooth { d.showPaired() diff --git a/src/display/display_nano-33-ble.go b/src/display/display_nano-33-ble.go index 1345bd7..be92104 100644 --- a/src/display/display_nano-33-ble.go +++ b/src/display/display_nano-33-ble.go @@ -3,8 +3,6 @@ package display import ( - "image/color" - "tinygo.org/x/tinydraw" "tinygo.org/x/tinyfont" "tinygo.org/x/tinyfont/proggy" @@ -14,8 +12,8 @@ func (d *Display) showAddress() { tinyfont.WriteLineRotated(&d.device, &proggy.TinySZ8pt7b, 114, 0, d.Address, WHITE, tinyfont.ROTATION_180) } -func (d *Display) showVersion(color color.RGBA) { - tinyfont.WriteLineRotated(&d.device, &proggy.TinySZ8pt7b, 114, 18, d.Version, color, tinyfont.ROTATION_180) +func (d *Display) showVersion() { + tinyfont.WriteLineRotated(&d.device, &proggy.TinySZ8pt7b, 114, 18, d.Version, WHITE, tinyfont.ROTATION_180) } func (d *Display) showValue(idx int) { diff --git a/src/display/display_xiao-ble.go b/src/display/display_xiao-ble.go index 9f9cfce..e7b1486 100644 --- a/src/display/display_xiao-ble.go +++ b/src/display/display_xiao-ble.go @@ -3,8 +3,6 @@ package display import ( - "image/color" - "tinygo.org/x/tinydraw" "tinygo.org/x/tinyfont" "tinygo.org/x/tinyfont/proggy" @@ -14,8 +12,8 @@ func (d *Display) showAddress() { tinyfont.WriteLineRotated(&d.device, &proggy.TinySZ8pt7b, 14, 28, d.Address, WHITE, tinyfont.NO_ROTATION) } -func (d *Display) showVersion(color color.RGBA) { - tinyfont.WriteLineRotated(&d.device, &proggy.TinySZ8pt7b, 14, 12, d.Version, color, tinyfont.NO_ROTATION) +func (d *Display) showVersion() { + tinyfont.WriteLineRotated(&d.device, &proggy.TinySZ8pt7b, 14, 12, d.Version, WHITE, tinyfont.NO_ROTATION) } func (d *Display) showValue(idx int) { diff --git a/src/main.go b/src/main.go index da0528c..d975623 100644 --- a/src/main.go +++ b/src/main.go @@ -53,9 +53,7 @@ func init() { // Display d = display.New() - d.Address = t.Address() d.Version = Version - d.Bluetooth = pinSelectPPM.Get() // High means Bluetooth d.Configure() go d.Run() @@ -95,15 +93,21 @@ func main() { break } } - d.Stable = true - off(ledR) // calibrated + // indicate calibration is over + off(ledR) + // store calibration values flashStore() // enable trainer after flash operations (bluetooth conflicts with flash) t.Configure() go t.Run() + // switch display to normal mode + d.Address = t.Address() + d.Bluetooth = pinSelectPPM.Get() // high means Bluetooth + d.Stable = true + // main loop iter = 0 for {