Skip to content

Commit

Permalink
Fix wrong bluetooth address displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
ysoldak committed Dec 12, 2023
1 parent a286da4 commit 54b23e3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/display/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}
}
Expand All @@ -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()
Expand Down
6 changes: 2 additions & 4 deletions src/display/display_nano-33-ble.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
package display

import (
"image/color"

"tinygo.org/x/tinydraw"
"tinygo.org/x/tinyfont"
"tinygo.org/x/tinyfont/proggy"
Expand All @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions src/display/display_xiao-ble.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
package display

import (
"image/color"

"tinygo.org/x/tinydraw"
"tinygo.org/x/tinyfont"
"tinygo.org/x/tinyfont/proggy"
Expand All @@ -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) {
Expand Down
12 changes: 8 additions & 4 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 54b23e3

Please sign in to comment.