[chirp_devel] [PATCH 2 of 3] FIXME

Dan Smith
Fri Apr 6 12:12:50 PDT 2012


# HG changeset patch
# User Dan Smith <dsmith at danplanet.com>
# Date 1333739557 25200
# Node ID 0dd1b82210090092fd77336db3f65f406c4c5b0e
# Parent  21a443c222d1cfdb043b07f858a7b58d5fcc26d6
FIXME
#93

diff -r 21a443c222d1 -r 0dd1b8221009 chirp/settings.py
--- a/chirp/settings.py	Fri Apr 06 12:12:35 2012 -0700
+++ b/chirp/settings.py	Fri Apr 06 12:12:37 2012 -0700
@@ -156,8 +156,8 @@
         return s
 
 class RadioSetting(RadioSettingGroup):
-    def __init__(self, name, value):
-        self._name = name
+    def __init__(self, name, shortname, value):
+        RadioSettingGroup.__init__(self, name, shortname)
         self._value = value
 
         if not isinstance(value, RadioSettingValue):
diff -r 21a443c222d1 -r 0dd1b8221009 chirp/uv5r.py
--- a/chirp/uv5r.py	Fri Apr 06 12:12:35 2012 -0700
+++ b/chirp/uv5r.py	Fri Apr 06 12:12:37 2012 -0700
@@ -15,8 +15,9 @@
 
 import struct
 
-from chirp import chirp_common, errors, util, directory, memmap
+from chirp import chirp_common, errors, util, directory, memmap, settings
 from chirp import bitwise
+from chirp.settings import *
 
 mem_format = """
 #seekto 0x0008;
@@ -35,6 +36,44 @@
      unknown5:2;
 } memory[128];
 
+#seekto 0x0E28;
+struct {
+  u8 squelch;
+  u8 step;
+  u8 unknown1;
+  u8 save;
+  u8 vox;
+  u8 unknown2;
+  u8 abr;
+  u8 tdr;
+  u8 beep;
+  u8 timeout;
+  u8 unknown3[4];
+  u8 voice;
+  u8 unknown4;
+  u8 dtmfst;
+  u8 unknown5;
+  u8 screv;
+  u8 pttid;
+  u8 pttlt;
+  u8 mdfa;
+  u8 mdfb;
+  u8 bcl;
+  u8 autolk;
+  u8 sftd;
+  u8 unknown6[3];
+  u8 wtled;
+  u8 rxled;
+  u8 txled;
+  u8 almod;
+  u8 tdrab;
+  u8 ste;
+  u8 rpste;
+  u8 rptrl;
+  u8 ponmsg;
+  u8 roger;
+} settings[2];
+
 #seekto 0x1000;
 struct {
   u8 unknown1[8];
@@ -43,6 +82,24 @@
 } names[128];
 """
 
+STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0]
+step_list = [str(x) for x in STEPS]
+timeout_list = ["%s sec" % x for x in range(15, 615, 15)]
+resume_list = ["TO", "CO", "SE"]
+mode_list = ["Channel", "Name", "Frequency"]
+color_list = ["Off", "Blue", "Orange", "Purple"]
+
+SETTING_LISTS = {
+    "step" : step_list,
+    "timeout" : timeout_list,
+    "screv" : resume_list,
+    "mdfa" : mode_list,
+    "mdfb" : mode_list,
+    "wtled" : color_list,
+    "rxled" : color_list,
+    "txled" : color_list,
+}
+
 def do_status(radio, block):
     s = chirp_common.Status()
     s.msg = "Cloning"
@@ -152,6 +209,7 @@
 
     def process_mmap(self):
         self._memobj = bitwise.parse(mem_format, self._mmap)
+        print self.get_settings()
 
     def sync_in(self):
         try:
@@ -318,3 +376,96 @@
         _mem.scan = mem.skip != "S"
         _mem.wide = mem.mode == "FM"
         _mem.lowpower = mem.power == UV5R_POWER_LEVELS[0]
+
+    def get_settings(self):
+        _settings = self._memobj.settings[0]
+        group = RadioSettingGroup("top", "All Settings")
+
+        s = RadioSetting("squelch", "Carrier Squelch Level",
+                         RadioSettingValueInteger(0, 9, _settings.squelch))
+        group.add_element(s)
+
+        s = RadioSetting("step", "Tuning Step",
+                         RadioSettingValueList(step_list,
+                                               step_list[_settings.step]))
+        group.add_element(s)
+
+        s = RadioSetting("save", "Battery Saver",
+                         RadioSettingValueInteger(0, 4, _settings.save))
+        group.add_element(s)
+
+        s = RadioSetting("vox", "VOX Sensitivity",
+                         RadioSettingValueInteger(0, 10, _settings.vox))
+        group.add_element(s)
+
+        s = RadioSetting("abr", "Backlight Timeout",
+                         RadioSettingValueInteger(0, 5, _settings.abr))
+        group.add_element(s)
+
+        s = RadioSetting("tdr", "Dual Watch",
+                         RadioSettingValueBoolean(_settings.tdr))
+        group.add_element(s)
+
+        s = RadioSetting("beep", "Beep",
+                         RadioSettingValueBoolean(_settings.beep))
+        group.add_element(s)
+
+        s = RadioSetting("timeout", "Timeout Timer",
+                         RadioSettingValueList(timeout_list,
+                                               timeout_list[_settings.tdr]))
+        group.add_element(s)
+
+        s = RadioSetting("voice", "Voice",
+                         RadioSettingValueBoolean(_settings.voice))
+        group.add_element(s)
+        
+        s = RadioSetting("screv", "Scan Resume",
+                         RadioSettingValueList(resume_list,
+                                               resume_list[_settings.screv]))
+        group.add_element(s)
+
+        s = RadioSetting("mdfa", "Display Mode (A)",
+                         RadioSettingValueList(mode_list,
+                                               mode_list[_settings.mdfa]))
+        group.add_element(s)
+
+        s = RadioSetting("mdfb", "Display Mode (B)",
+                         RadioSettingValueList(mode_list,
+                                               mode_list[_settings.mdfb]))
+        group.add_element(s)
+
+        s = RadioSetting("bcl", "Busy Channel Lockout",
+                         RadioSettingValueBoolean(_settings.bcl))
+        group.add_element(s)
+
+        s = RadioSetting("autolk", "Automatic Key Lock",
+                         RadioSettingValueBoolean(_settings.autolk))
+        group.add_element(s)
+
+        s = RadioSetting("wtled", "Standby LED Color",
+                         RadioSettingValueList(color_list,
+                                               color_list[_settings.wtled]))
+        group.add_element(s)
+
+        s = RadioSetting("rxled", "RX LED Color",
+                         RadioSettingValueList(color_list,
+                                               color_list[_settings.rxled]))
+        group.add_element(s)
+
+        s = RadioSetting("txled", "TX LED Color",
+                         RadioSettingValueList(color_list,
+                                               color_list[_settings.txled]))
+        group.add_element(s)
+
+        return group
+
+    def set_settings(self, settings):
+        _settings = self._memobj.settings[0]
+        for element in settings.get_elements():
+            value = element.get_value().get_value()
+            if element.get_name() in SETTING_LISTS.keys():
+                value = SETTING_LISTS[element.get_name()].index(value)
+            try:
+                setattr(_settings, element.get_name(), value)
+            except Exception, e:
+                raise Exception("%s: %s" % (element.get_name(), e))



More information about the chirp_devel mailing list