[chirp_devel] [PATCH] Fix UV-5R PTT-ID to support A-D and *, # characters

Jim Unroe
Mon Apr 1 20:18:12 PDT 2013


# HG changeset patch
# User Dan Smith <dsmith at danplanet.com>
# Date 1364870963 25200
# Node ID 1df4e02f14806204c2822fb25e87a77227fa469d
# Parent  ca76c7af25c76fc784273343c201f42c42bf09f3
Fix UV-5R PTT-ID to support A-D and *, # characters

diff -r ca76c7af25c7 -r 1df4e02f1480 chirp/uv5r.py
--- a/chirp/uv5r.py	Thu Mar 14 16:55:57 2013 -0700
+++ b/chirp/uv5r.py	Mon Apr 01 19:49:23 2013 -0700
@@ -1055,18 +1055,19 @@
 
         dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
         group.append(dtmf)
+        dtmfchars = "0123456789 *#ABCD"
 
         for i in range(0, 15):
             _codeobj = self._memobj.pttid[i].code
-            _code = "".join(["%x" % x for x in _codeobj if int(x) != 0xFF])
+            _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
             val = RadioSettingValueString(0, 5, _code, False)
-            val.set_charset("0123456789")
+            val.set_charset(dtmfchars)
             rs = RadioSetting("pttid/%i.code" % i, "PTT ID Code %i" % (i + 1), val)
             def apply_code(setting, obj):
                 code = []
                 for j in range(0, 5):
                     try:
-                        code.append(int(str(setting.value)[j]))
+                        code.append(dtmfchars.index(str(setting.value)[j]))
                     except IndexError:
                         code.append(0xFF)
                 obj.code = code
@@ -1074,15 +1075,15 @@
             dtmf.append(rs)
 
         _codeobj = self._memobj.ani.code
-        _code = "".join(["%x" % x for x in _codeobj if int(x) != 0xFF])
+        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
         val = RadioSettingValueString(0, 5, _code, False)
-        val.set_charset("0123456789")
+        val.set_charset(dtmfchars)
         rs = RadioSetting("ani.code", "ANI Code", val)
         def apply_code(setting, obj):
             code = []
             for j in range(0, 5):
                 try:
-                    code.append(int(str(setting.value)[j]))
+                    code.append(dtmfchars.index(str(setting.value)[j]))
                 except IndexError:
                     code.append(0xFF)
             obj.code = code
@@ -1096,15 +1097,15 @@
         dtmf.append(rs)
 
         _codeobj = self._memobj.ani.alarmcode
-        _code = "".join(["%x" % x for x in _codeobj if int(x) != 0xFF])
+        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
         val = RadioSettingValueString(0, 3, _code, False)
-        val.set_charset("0123456789")
+        val.set_charset(dtmfchars)
         rs = RadioSetting("ani.alarmcode", "Alarm Code", val)
         def apply_code(setting, obj):
             alarmcode = []
             for j in range(0, 3):
                 try:
-                    alarmcode.append(int(str(setting.value)[j]))
+                    alarmcode.append(dtmfchars.index(str(setting.value)[j]))
                 except IndexError:
                     alarmcode.append(0xFF)
             obj.alarmcode = alarmcode



More information about the chirp_devel mailing list