<div dir="ltr"><div>Oops. I forgot to add the comment that this patch is relative to #815.<br></div>Sorry :(<br>Jim<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 29, 2013 at 8:52 PM, Jim Unroe <span dir="ltr">&lt;<a href="mailto:rock.unroe@gmail.com" target="_blank">rock.unroe@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Jim Unroe &lt;<a href="mailto:rock.unroe@gmail.com">rock.unroe@gmail.com</a>&gt;<br>
# Date 1367282877 14400<br>
# Node ID dffed026a3f208a7b7e975f71cb8ee54d437ad5c<br>
# Parent  f08b832077574e7a40180fb33601d9613c5574cd<br>
[uvb5] Additional Settings<br>
add imports from chirp.settings<br>
add/update structures based on memory mapping<br>
add rf.has_settings = True<br>
add def get_settings(self):<br>
add def set_settings(self, settings):<br>
add Basic Settings group<br>
add settings equivalent to the Baofeng UV-B5 Software<br>
     Optional Features Menu<br>
- Scan Type<br>
- Time Out Timer<br>
- Frequency Mode<br>
- Radio Work Mode (A)<br>
- Radio Work Mode (B)<br>
- Display Format (F1)<br>
- Display Format (F2)<br>
- PTT-ID<br>
- PTT-ID Code<br>
- Squelch Level<br>
- VOX Level<br>
- FM Work Mode<br>
- Dual Standby TX Priority<br>
- Language<br>
- Dual Standby<br>
- Roger Beep<br>
- Backlight<br>
- Save Mode<br>
- FM Function<br>
- Beep Prompt<br>
- Voice Prompt<br>
- DTMF Side Tone<br>
<br>
diff -r f08b83207757 -r dffed026a3f2 chirp/uvb5.py<br>
--- a/chirp/uvb5.py     Mon Apr 22 09:52:39 2013 -0700<br>
+++ b/chirp/uvb5.py     Mon Apr 29 20:47:57 2013 -0400<br>
@@ -15,6 +15,9 @@<br>
<br>
 import struct<br>
 from chirp import chirp_common, directory, bitwise, memmap, errors, util<br>
+from chirp.settings import RadioSetting, RadioSettingGroup, \<br>
+                RadioSettingValueBoolean, RadioSettingValueList, \<br>
+                RadioSettingValueInteger, RadioSettingValueString<br>
<br>
 mem_format = &quot;&quot;&quot;<br>
 struct memory {<br>
@@ -29,7 +32,7 @@<br>
   u8 unknown3:1,<br>
      scanadd:1,<br>
      isnarrow:1,<br>
-     unknown4:1,<br>
+     bcl:1,<br>
      highpower:1,<br>
      unknown5:1,<br>
      duplex:2;<br>
@@ -48,6 +51,37 @@<br>
 struct {<br>
   u8 name[5];<br>
 } names[128];<br>
+<br>
+#seekto 0x0D30;<br>
+struct {<br>
+  u8 squelch;<br>
+  u8 freqmode_ab:1,<br>
+     save_funct:1,<br>
+     backlight:1,<br>
+     beep_tone:1,<br>
+     roger:1,<br>
+     tdr:1,<br>
+     scantype:2;<br>
+  u8 language:1,<br>
+     workmode_b:1,<br>
+     workmode_a:1,<br>
+     workmode_fm:1,<br>
+     voice_prompt:1,<br>
+     fm:1,<br>
+     pttid:2;<br>
+  u8 timeout;<br>
+  u8 mdf_b:2,<br>
+     mdf_a:2,<br>
+     unknown_1:2,<br>
+     txtdr:2;<br>
+  u8 sidetone;<br>
+  u8 vox;<br>
+} settings;<br>
+<br>
+#seekto 0x0D50;<br>
+struct {<br>
+  u8 code[6];<br>
+} pttid;<br>
 &quot;&quot;&quot;<br>
<br>
 def do_ident(radio):<br>
@@ -127,6 +161,7 @@<br>
<br>
     def get_features(self):<br>
         rf = chirp_common.RadioFeatures()<br>
+        rf.has_settings = True<br>
         rf.valid_tmodes = [&quot;&quot;, &quot;Tone&quot;, &quot;TSQL&quot;, &quot;DTCS&quot;, &quot;Cross&quot;]<br>
         rf.valid_duplexes = DUPLEX<br>
         rf.valid_skips = [&quot;&quot;, &quot;S&quot;]<br>
@@ -238,6 +273,12 @@<br>
                     break<br>
             <a href="http://mem.name" target="_blank">mem.name</a> = mem.name.rstrip()<br>
<br>
+        mem.extra = RadioSettingGroup(&quot;Extra&quot;, &quot;extra&quot;)<br>
+<br>
+        rs = RadioSetting(&quot;bcl&quot;, &quot;BCL&quot;,<br>
+                          RadioSettingValueBoolean(_mem.bcl))<br>
+        mem.extra.append(rs)<br>
+<br>
         return mem<br>
<br>
     def set_memory(self, mem):<br>
@@ -268,6 +309,173 @@<br>
                 except IndexError:<br>
                     _nam[i] = 0xFF<br>
<br>
+        for setting in mem.extra:<br>
+            setattr(_mem, setting.get_name(), setting.value)<br>
+<br>
+    def get_settings(self):<br>
+        basic = RadioSettingGroup(&quot;basic&quot;, &quot;Basic Settings&quot;)<br>
+        group = RadioSettingGroup(&quot;top&quot;, &quot;All Settings&quot;, basic)<br>
+<br>
+        options = [&quot;Time&quot;, &quot;Carrier&quot;, &quot;Search&quot;]<br>
+        rs = RadioSetting(&quot;scantype&quot;, &quot;Scan Type&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.scantype]))<br>
+        basic.append(rs)<br>
+<br>
+        options = [&quot;%s min&quot; % x for x in range(1, 8)]<br>
+        options.insert(0, &quot;Off&quot;)<br>
+        rs = RadioSetting(&quot;timeout&quot;, &quot;Time Out Timer&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.timeout]))<br>
+        basic.append(rs)<br>
+<br>
+        options = [&quot;A&quot;, &quot;B&quot;]<br>
+        rs = RadioSetting(&quot;freqmode_ab&quot;, &quot;Frequency Mode&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.freqmode_ab]))<br>
+        basic.append(rs)<br>
+<br>
+        options = [&quot;Frequency Mode&quot;, &quot;Channel Mode&quot;]<br>
+        rs = RadioSetting(&quot;workmode_a&quot;, &quot;Radio Work Mode(A)&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.workmode_a]))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;workmode_b&quot;, &quot;Radio Work Mode(B)&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.workmode_b]))<br>
+        basic.append(rs)<br>
+<br>
+        options = [&quot;Frequency&quot;, &quot;Name&quot;, &quot;Channel&quot;]<br>
+        rs = RadioSetting(&quot;mdf_a&quot;, &quot;Display Format(F1)&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.mdf_a]))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;mdf_b&quot;, &quot;Display Format(F2)&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.mdf_b]))<br>
+        basic.append(rs)<br>
+<br>
+        options = [&quot;Off&quot;, &quot;BOT&quot;, &quot;EOT&quot;, &quot;Both&quot;]<br>
+        rs = RadioSetting(&quot;pttid&quot;, &quot;PTT-ID&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.pttid]))<br>
+        basic.append(rs)<br>
+<br>
+        dtmfchars = &quot;0123456789ABCD&quot;<br>
+        _codeobj = self._memobj.pttid.code<br>
+        _code = &quot;&quot;.join([dtmfchars[x] for x in _codeobj if int(x) &lt; 0x1F])<br>
+        val = RadioSettingValueString(0, 6, _code, False)<br>
+        val.set_charset(dtmfchars)<br>
+        rs = RadioSetting(&quot;pttid.code&quot;, &quot;PTT-ID Code&quot;, val)<br>
+        def apply_code(setting, obj):<br>
+            code = []<br>
+            for j in range(0, 6):<br>
+                try:<br>
+                    code.append(dtmfchars.index(str(setting.value)[j]))<br>
+                except IndexError:<br>
+                    code.append(0xFF)<br>
+            obj.code = code<br>
+        rs.set_apply_callback(apply_code, self._memobj.pttid)<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;squelch&quot;, &quot;Squelch Level&quot;,<br>
+                          RadioSettingValueInteger(0, 9, self._memobj.settings.squelch))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;vox&quot;, &quot;VOX Level&quot;,<br>
+                          RadioSettingValueInteger(0, 9, self._memobj.settings.vox))<br>
+        basic.append(rs)<br>
+<br>
+        options = [&quot;Frequency Mode&quot;, &quot;Channel Mode&quot;]<br>
+        rs = RadioSetting(&quot;workmode_fm&quot;, &quot;FM Work Mode&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.workmode_fm]))<br>
+        basic.append(rs)<br>
+<br>
+        options = [&quot;Current Frequency&quot;, &quot;F1 Frequency&quot;, &quot;F2 Frequency&quot;]<br>
+        rs = RadioSetting(&quot;txtdr&quot;, &quot;Dual Standby TX Priority&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.txtdr]))<br>
+        basic.append(rs)<br>
+<br>
+        options = [&quot;English&quot;, &quot;Chinese&quot;]<br>
+        rs = RadioSetting(&quot;language&quot;, &quot;Language&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.language]))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;tdr&quot;, &quot;Dual Standby&quot;,<br>
+                          RadioSettingValueBoolean(self._memobj.settings.tdr))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;roger&quot;, &quot;Roger Beep&quot;,<br>
+                          RadioSettingValueBoolean(self._memobj.settings.roger))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;backlight&quot;, &quot;Backlight&quot;,<br>
+                          RadioSettingValueBoolean(self._memobj.settings.backlight))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;save_funct&quot;, &quot;Save Mode&quot;,<br>
+                          RadioSettingValueBoolean(self._memobj.settings.save_funct))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;fm&quot;, &quot;FM Function&quot;,<br>
+                          RadioSettingValueBoolean(self._<a href="http://memobj.settings.fm" target="_blank">memobj.settings.fm</a>))<br>
+        basic.append(rs)<br>
+<br>
+        options = [&quot;Enabled&quot;, &quot;Disabled&quot;]<br>
+        rs = RadioSetting(&quot;beep_tone&quot;, &quot;Beep Prompt&quot;,<br>
+                          RadioSettingValueList(options,<br>
+                                        options[self._memobj.settings.beep_tone]))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;voice_prompt&quot;, &quot;Voice Prompt&quot;,<br>
+                          RadioSettingValueBoolean(self._memobj.settings.voice_prompt))<br>
+        basic.append(rs)<br>
+<br>
+        rs = RadioSetting(&quot;sidetone&quot;, &quot;DTMF Side Tone&quot;,<br>
+                          RadioSettingValueBoolean(self._memobj.settings.sidetone))<br>
+        basic.append(rs)<br>
+<br>
+        return group<br>
+<br>
+    def set_settings(self, settings):<br>
+        _settings = self._memobj.settings<br>
+        for element in settings:<br>
+            if not isinstance(element, RadioSetting):<br>
+                self.set_settings(element)<br>
+                continue<br>
+            try:<br>
+                name = element.get_name()<br>
+                if &quot;.&quot; in name:<br>
+                    bits = name.split(&quot;.&quot;)<br>
+                    obj = self._memobj<br>
+                    for bit in bits[:-1]:<br>
+                        if &quot;/&quot; in bit:<br>
+                            bit, index = bit.split(&quot;/&quot;, 1)<br>
+                            index = int(index)<br>
+                            obj = getattr(obj, bit)[index]<br>
+                        else:<br>
+                            obj = getattr(obj, bit)<br>
+                    setting = bits[-1]<br>
+                else:<br>
+                    obj = _settings<br>
+                    setting = element.get_name()<br>
+<br>
+                if element.has_apply_callback():<br>
+                    print &quot;Using apply callback&quot;<br>
+                    element.run_apply_callback()<br>
+                else:<br>
+                    print &quot;Setting %s = %s&quot; % (setting, element.value)<br>
+                    setattr(obj, setting, element.value)<br>
+            except Exception, e:<br>
+                print element.get_name()<br>
+                raise<br>
+<br>
+<br>
     @classmethod<br>
     def match_model(cls, filedata, filename):<br>
         return (filedata.startswith(&quot;KT511 Radio Program data&quot;) and<br>
</blockquote></div><br></div>