Skip to content

Commit

Permalink
clear the entry fields if the frequency is changed by more than 250 Hz
Browse files Browse the repository at this point in the history
  • Loading branch information
ftl committed May 26, 2024
1 parent 0dfd5ca commit a160605
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/entry/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package entry
import (
"fmt"
"log"
"math"
"strconv"
"strings"

Expand All @@ -13,6 +14,10 @@ import (
"github.com/ftl/hellocontest/core/ticker"
)

const (
jumpThreshold core.Frequency = 250 // Hz
)

// View represents the visual part of the QSO data entry.
type View interface {
SetUTC(string)
Expand Down Expand Up @@ -430,8 +435,17 @@ func (c *Controller) VFOFrequencyChanged(frequency core.Frequency) {
if c.selectedFrequency == frequency {
return
}
jump := math.Abs(float64(c.selectedFrequency-frequency)) > float64(jumpThreshold)
c.selectedFrequency = frequency
c.view.SetFrequency(c.selectedFrequency)

if jump {
c.asyncRunner(func() {
c.Clear()
c.activeField = core.CallsignField
c.view.SetActiveField(c.activeField)
})
}
}

func (c *Controller) bandSelected(s string) {
Expand Down

0 comments on commit a160605

Please sign in to comment.