From a160605fc1440dd913d5596f240e3649bcaba8c2 Mon Sep 17 00:00:00 2001 From: Florian Thienel Date: Sun, 26 May 2024 14:39:21 +0200 Subject: [PATCH] clear the entry fields if the frequency is changed by more than 250 Hz --- core/entry/entry.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/entry/entry.go b/core/entry/entry.go index e653b98..1559d72 100644 --- a/core/entry/entry.go +++ b/core/entry/entry.go @@ -3,6 +3,7 @@ package entry import ( "fmt" "log" + "math" "strconv" "strings" @@ -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) @@ -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) {