[chirp_devel] [PATCH] [tg_uv2p] Dont set a priority channel if empty or Broadcast-FM. Fixes fifth issue in #9939
Dan Smith
Sun Aug 7 09:55:15 PDT 2022
> + PriorityList = []
>
> @classmethod
> def get_prompts(cls):
> @@ -341,10 +342,19 @@
> else:
> mem.number = number
>
> + try:
> + self.PriorityList.remove(mem.number)
> + except:
> + None
> +
> if (_mem.freq.get_raw()[0] == "\xFF") or (_bf.band == "\x0F"):
> mem.empty = True
> return mem
>
> + if _bf.band > 0:
> + self.PriorityList.append(mem.number)
> + self.PriorityList.sort()
> +
> mem.freq = int(_mem.freq) * 10
>
> if _mem.offset.get_raw()[0] == "\xFF":
> @@ -390,6 +400,11 @@
>
> _bf.set_raw("\xFF")
>
> + try:
> + self.PriorityList.remove(mem.number)
> + except:
> + None
> +
> if mem.empty:
> _mem.set_raw("\xFF" * 16)
> return
> @@ -402,6 +417,10 @@
> if mem.freq >= ele[0] and mem.freq <= ele[1]:
> _bf.band = idx
>
> + if _bf.band > 0:
> + self.PriorityList.append(mem.number)
> + self.PriorityList.sort()
> +
I have the same core argument here: you're depending on get or set memory to have run before settings such that we've built this information, which won't always be the case. If set_settings() needs to look at the state of all the memories to determine the proper behavior, then that's what should happen. It's good to try to cache the stuff during single-memory operations like you do, but I think it's not necessary for performance and definitely shouldn't sacrifice correctness.
> _mem.freq = mem.freq / 10
> _mem.offset = mem.offset / 10
>
> @@ -511,10 +530,16 @@
> mem_vals.insert(0, 0xFF)
> user_options.insert(0, "Not Set")
> options_map = zip(user_options, mem_vals)
> + _priority_channel = _settings.priority_channel
> + if not (_priority_channel in self.PriorityList):
> + _priority_channel = 0xFF
Instead of depending on self.PriorityList, just have a routine you call to scan the bands of the memories in the memory object to help you make your determination.
--Dan
More information about the chirp_devel
mailing list