Make required_step find 10kHz before 5kHz

This makes our required_step() function find 10kHz as a suitable
tuning step before 5kHz because of one radio (ft90) that has a bug
related to 5kHz and thus does not support it.

This also makes us set the tuning_step of our test memory to the first
supported one, which may not be the default of 5kHz. The TS480 driver
does some monkeywork with the tuning_step that changes per mode, which
isn't really compatible with the tests or the UI, so this also
makes a change there to just keep things working. But, more attention
is needed there.
This commit is contained in:
Dan Smith 2023-02-22 19:45:19 -08:00 committed by Dan Smith
parent 7a5c76804d
commit ba88b54f4a
3 changed files with 13 additions and 4 deletions

View file

@ -1533,6 +1533,11 @@ def is_5_0(freq):
return (freq % 5000) == 0
def is_10_0(freq):
"""Returns True if @freq is reachable by a 10kHz step"""
return (freq % 10000) == 0
def is_12_5(freq):
"""Returns True if @freq is reachable by a 12.5kHz step"""
return (freq % 12500) == 0
@ -1555,7 +1560,9 @@ def is_8_33(freq):
def required_step(freq):
"""Returns the simplest tuning step that is required to reach @freq"""
if is_5_0(freq):
if is_10_0(freq):
return 10.0
elif is_5_0(freq):
return 5.0
elif is_12_5(freq):
return 12.5

View file

@ -504,7 +504,8 @@ class TS480_CRadio(chirp_common.CloneModeRadio):
rf.valid_duplexes = TS480_DUPLEX
rf.valid_modes = [x for x in TS480_MODES if x in chirp_common.MODES]
rf.valid_skips = TS480_SKIP
rf.valid_tuning_steps = TS480_TUNE_STEPS
rf.valid_tuning_steps = [x for x in TS480_TUNE_STEPS
if x in chirp_common.TUNING_STEPS]
rf.valid_tmodes = ["", "Tone", "TSQL"]
rf.valid_name_length = 8 # 8 character channel names
@ -617,7 +618,7 @@ class TS480_CRadio(chirp_common.CloneModeRadio):
# Tuning step depends on mode
options = [0.5, 1.0, 2.5, 5.0, 10.0] # SSB/CS/FSK
if _mem.xmode == 4 or _mem.xmode == 5: # AM/FM
options = TS480_TUNE_STEPS[3:]
options += TS480_TUNE_STEPS[3:]
mem.tuning_step = options[_mem.step]
return mem
@ -671,7 +672,7 @@ class TS480_CRadio(chirp_common.CloneModeRadio):
_mem.skip = 1
options = [0.5, 1.0, 2.5, 5.0, 10.0] # SSB/CS/FSK steps
if _mem.xmode == 4 or _mem.xmode == 5: # AM/FM
options = TS480_TUNE_STEPS[3:]
options += TS480_TUNE_STEPS[3:]
_mem.step = options.index(mem.tuning_step)
return

View file

@ -71,6 +71,7 @@ class DriverTest(unittest.TestCase):
# If we have valid tuning steps, go one step above the
# bottom of the band
m.freq += int(self.rf.valid_tuning_steps[0] * 1000)
m.tuning_step = self.rf.valid_tuning_steps[0]
elif m.freq + 1000000 < band_hi:
# Otherwise just pick 1MHz above the bottom, which has been
# our test basis for a long time, unless that extends past