[chirp_devel] [PATCH] [tg_uv2p] Dont set a priority channel if empty or Broadcast-FM. Fixes fifth issue in #9939

Ran Katz
Wed Aug 3 09:10:20 PDT 2022


# HG changeset patch
# User Ran Katz <rankatz at gmail.com>
# Date 1659543001 -10800
#      Wed Aug 03 19:10:01 2022 +0300
# Node ID 383f6b57480c62cadff74664a25931470c00bfb7
# Parent  7c1a4c8b1c8dd4e97f2f31b89ed1e158adafb6d9
[tg_uv2p] Dont set a priority channel if empty or Broadcast-FM. Fixes fifth issue in #9939
The radio doesnt set a priority channel if it is empty or an FM broadcast channel, now chirp behaves the same.
Also added a comment in the setting description.

diff --git a/chirp/drivers/tg_uv2p.py b/chirp/drivers/tg_uv2p.py
--- a/chirp/drivers/tg_uv2p.py
+++ b/chirp/drivers/tg_uv2p.py
@@ -213,6 +213,7 @@
     _memsize = 0x2000
 
     RxModeKeyUnLock_FLAG = False
+    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()
+
         _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
 
-        rs = RadioSetting("priority_channel", "Priority Channel",
+        rs = RadioSetting("priority_channel", "Priority Channel:\n" +
+                          "Note: An empty or\n" +
+                          "Broadcast-FM channel\n" +
+                          "will not be set",
                           RadioSettingValueMap(options_map,
-                                               _settings.priority_channel))
+                                               _priority_channel))
         cfg_grp.append(rs)
 
         # Step
@@ -726,6 +751,13 @@
                             self.RxModeKeyUnLock_FLAG = False
                         LOG.debug("Setting %s = %s" % (setting, element.value))
                         setattr(obj, setting, element.value)
+                    elif setting == "priority_channel":
+                        if not (int(element.value) in self.PriorityList):
+                            _val = 0xFF
+                        else:
+                            _val = element.value
+                        LOG.debug("Setting %s = %s" % (setting, _val))
+                        setattr(obj, setting, _val)
                     elif element.value.get_mutable():
                         LOG.debug("Setting %s = %s" % (setting, element.value))
                         setattr(obj, setting, element.value)




More information about the chirp_devel mailing list