[chirp_devel] [PATCH] [th9800] fix skip scan/priority issues #2247
# HG changeset patch # User Jens Jensen af5mi@yahoo.com # Date 1422131048 21600 # Sat Jan 24 14:24:08 2015 -0600 # Node ID 4d094ce0a504d719fe4cd84ae3baef5ba48dd92e # Parent b533ae13e0a964d48851e1148d88ad8564e4538f [th9800] fix skip scan/priority issues #2247
Skip/priority settings were not taking effect. Channel fields were for display only. There are special channel banks controlling scan enable and priority. This fix manipulates both channel fields and bank flags.
diff -r b533ae13e0a9 -r 4d094ce0a504 chirp/th9800.py --- a/chirp/th9800.py Sat Jan 24 12:28:25 2015 -0600 +++ b/chirp/th9800.py Sat Jan 24 14:24:08 2015 -0600 @@ -126,8 +126,9 @@ } settings;
#seekto 0x%04X; -u8 chan_active_a[128]; -u8 chan_active_b[128]; +u8 chan_active[128]; +u8 scan_enable[128]; +u8 priority[128];
#seekto 0x%04X; struct { @@ -201,35 +202,28 @@ (self._mmap_offset, self._scanlimits_offset, self._settings_offset, self._chan_active_offset, self._info_offset), self._mmap)
- def get_chan_active(self, num): + def get_active(self, banktype, num): + """get active flag for channel active, scan enable, or priority banks""" + bank = getattr(self._memobj, banktype) index = (num - 1) / 8 bitpos = (num - 1) % 8 mask = 2**bitpos - enabled = self._memobj.chan_active_a[index] & mask - if CHIRP_DEBUG: - print "gca:", num, index, bitpos, self._memobj.chan_active_a[index], - enabled + enabled = bank[index] & mask if enabled: return True else: return False
- def set_chan_active(self, num, enable): + def set_active(self, banktype, num, enable = True): + """set active flag for channel active, scan enable, or priority banks""" + bank = getattr(self._memobj, banktype) index = (num - 1) / 8 bitpos = (num - 1) % 8 mask = 2**bitpos - if CHIRP_DEBUG: - print "setting to:", enable, mask - print "before:", self._memobj.chan_active_a[index] if enable: - self._memobj.chan_active_a[index] |= mask - self._memobj.chan_active_b[index] |= mask + bank[index] |= mask else: - self._memobj.chan_active_a[index] &= ~mask - self._memobj.chan_active_b[index] &= ~mask - if CHIRP_DEBUG: - print "sca:", num, index, bitpos - print "after:", self._memobj.chan_active_a[index] + bank[index] &= ~mask
def get_raw_memory(self, number): return repr(self._memobj.memory[number - 1]) @@ -239,11 +233,7 @@ mem = chirp_common.Memory() mem.number = number
- #if not _mem.get_raw().startswith("\xFF\xFF\xFF\xFF"): - # mem.empty = True - # return mem - - mem.empty = not self.get_chan_active(number) + mem.empty = not self.get_active("chan_active", number) if mem.empty: return mem
@@ -274,7 +264,13 @@ mem.name = str(_mem.name) mem.name = mem.name.rstrip("\xFF")
- mem.skip = SCAN_MODES[int(_mem.scan)] + if not self.get_active("scan_enable", number): + mem.skip = "S" + elif self.get_active("priority", number): + mem.skip = "P" + else: + mem.skip = "" + mem.mode = _mem.am and "AM" or MODES[int(_mem.fmdev)]
mem.power = POWER_LEVELS[_mem.power] @@ -329,13 +325,13 @@ def set_memory(self, mem): _mem = self._memobj.memory[mem.number - 1]
- _prev_active = self.get_chan_active(mem.number) - self.set_chan_active(mem.number, not mem.empty) + _prev_active = self.get_active("chan_active", mem.number) + self.set_active("chan_active", mem.number, not mem.empty) if mem.empty or not _prev_active: if CHIRP_DEBUG: print "initializing memory channel %d" % mem.number _mem.set_raw(BLANK_MEMORY) - + if mem.empty: return
@@ -375,6 +371,15 @@ display.value = "Frequency"
_mem.scan = SCAN_MODES.index(mem.skip) + if mem.skip == "P": + self.set_active("priority", mem.number, True) + self.set_active("scan_enable", mem.number, True) + elif mem.skip == "S": + self.set_active("priority", mem.number, False) + self.set_active("scan_enable", mem.number, False) + elif mem.skip == "": + self.set_active("priority", mem.number, False) + self.set_active("scan_enable", mem.number, True)
if mem.mode == "AM": _mem.am = True @@ -444,8 +449,11 @@ basic.append( RadioSetting("mute_mode", "Mute Mode", RadioSettingValueList(opts, opts[_settings.mute_mode]))) opts = ["MEM", "MSM"] - basic.append( RadioSetting("scan_mode", "Scan Mode", - RadioSettingValueList(opts, opts[_settings.scan_mode]))) + scanmode = RadioSetting("scan_mode", "Scan Mode", + RadioSettingValueList(opts, opts[_settings.scan_mode])) + scanmode.set_doc("MEM = Normal scan, bypass channels marked skip. " \ + " MSM = Scan only channels marked priority.") + basic.append(scanmode) opts = ["TO", "CO"] basic.append( RadioSetting("scan_resume", "Scan Resume", RadioSettingValueList(opts, opts[_settings.scan_resume])))
participants (1)
-
Jens Jensen