<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"><<a href="mailto:rock.unroe@gmail.com" target="_blank">rock.unroe@gmail.com</a>></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 <<a href="mailto:rock.unroe@gmail.com">rock.unroe@gmail.com</a>><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 = """<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>
"""<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 = ["", "Tone", "TSQL", "DTCS", "Cross"]<br>
rf.valid_duplexes = DUPLEX<br>
rf.valid_skips = ["", "S"]<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("Extra", "extra")<br>
+<br>
+ rs = RadioSetting("bcl", "BCL",<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("basic", "Basic Settings")<br>
+ group = RadioSettingGroup("top", "All Settings", basic)<br>
+<br>
+ options = ["Time", "Carrier", "Search"]<br>
+ rs = RadioSetting("scantype", "Scan Type",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.scantype]))<br>
+ basic.append(rs)<br>
+<br>
+ options = ["%s min" % x for x in range(1, 8)]<br>
+ options.insert(0, "Off")<br>
+ rs = RadioSetting("timeout", "Time Out Timer",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.timeout]))<br>
+ basic.append(rs)<br>
+<br>
+ options = ["A", "B"]<br>
+ rs = RadioSetting("freqmode_ab", "Frequency Mode",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.freqmode_ab]))<br>
+ basic.append(rs)<br>
+<br>
+ options = ["Frequency Mode", "Channel Mode"]<br>
+ rs = RadioSetting("workmode_a", "Radio Work Mode(A)",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.workmode_a]))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("workmode_b", "Radio Work Mode(B)",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.workmode_b]))<br>
+ basic.append(rs)<br>
+<br>
+ options = ["Frequency", "Name", "Channel"]<br>
+ rs = RadioSetting("mdf_a", "Display Format(F1)",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.mdf_a]))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("mdf_b", "Display Format(F2)",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.mdf_b]))<br>
+ basic.append(rs)<br>
+<br>
+ options = ["Off", "BOT", "EOT", "Both"]<br>
+ rs = RadioSetting("pttid", "PTT-ID",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.pttid]))<br>
+ basic.append(rs)<br>
+<br>
+ dtmfchars = "0123456789ABCD"<br>
+ _codeobj = self._memobj.pttid.code<br>
+ _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])<br>
+ val = RadioSettingValueString(0, 6, _code, False)<br>
+ val.set_charset(dtmfchars)<br>
+ rs = RadioSetting("pttid.code", "PTT-ID Code", 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("squelch", "Squelch Level",<br>
+ RadioSettingValueInteger(0, 9, self._memobj.settings.squelch))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("vox", "VOX Level",<br>
+ RadioSettingValueInteger(0, 9, self._memobj.settings.vox))<br>
+ basic.append(rs)<br>
+<br>
+ options = ["Frequency Mode", "Channel Mode"]<br>
+ rs = RadioSetting("workmode_fm", "FM Work Mode",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.workmode_fm]))<br>
+ basic.append(rs)<br>
+<br>
+ options = ["Current Frequency", "F1 Frequency", "F2 Frequency"]<br>
+ rs = RadioSetting("txtdr", "Dual Standby TX Priority",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.txtdr]))<br>
+ basic.append(rs)<br>
+<br>
+ options = ["English", "Chinese"]<br>
+ rs = RadioSetting("language", "Language",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.language]))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("tdr", "Dual Standby",<br>
+ RadioSettingValueBoolean(self._memobj.settings.tdr))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("roger", "Roger Beep",<br>
+ RadioSettingValueBoolean(self._memobj.settings.roger))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("backlight", "Backlight",<br>
+ RadioSettingValueBoolean(self._memobj.settings.backlight))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("save_funct", "Save Mode",<br>
+ RadioSettingValueBoolean(self._memobj.settings.save_funct))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("fm", "FM Function",<br>
+ RadioSettingValueBoolean(self._<a href="http://memobj.settings.fm" target="_blank">memobj.settings.fm</a>))<br>
+ basic.append(rs)<br>
+<br>
+ options = ["Enabled", "Disabled"]<br>
+ rs = RadioSetting("beep_tone", "Beep Prompt",<br>
+ RadioSettingValueList(options,<br>
+ options[self._memobj.settings.beep_tone]))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("voice_prompt", "Voice Prompt",<br>
+ RadioSettingValueBoolean(self._memobj.settings.voice_prompt))<br>
+ basic.append(rs)<br>
+<br>
+ rs = RadioSetting("sidetone", "DTMF Side Tone",<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 "." in name:<br>
+ bits = name.split(".")<br>
+ obj = self._memobj<br>
+ for bit in bits[:-1]:<br>
+ if "/" in bit:<br>
+ bit, index = bit.split("/", 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 "Using apply callback"<br>
+ element.run_apply_callback()<br>
+ else:<br>
+ print "Setting %s = %s" % (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("KT511 Radio Program data") and<br>
</blockquote></div><br></div>