diff options
| author | Iain R. Learmonth <irl@debian.org> | 2016-04-15 16:00:00 +0100 |
|---|---|---|
| committer | Iain R. Learmonth <irl@debian.org> | 2016-04-15 16:00:00 +0100 |
| commit | 5fe7ea0f5ef41f738666aaecb905eb89413973df (patch) | |
| tree | d0b6b5132104137dbd8009c7a52b91d49d228b9a | |
| parent | 4d45d6099769e8b066547196128fce26e76f7f6b (diff) | |
Imported Upstream version 20160415
| -rw-r--r-- | PKG-INFO | 2 | ||||
| -rw-r--r-- | chirp/__init__.py | 2 | ||||
| -rw-r--r-- | chirp/drivers/btech.py | 606 |
3 files changed, 601 insertions, 9 deletions
@@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: chirp -Version: daily-20160402 +Version: daily-20160415 Summary: UNKNOWN Home-page: UNKNOWN Author: UNKNOWN diff --git a/chirp/__init__.py b/chirp/__init__.py index 181425a..c9d93c9 100644 --- a/chirp/__init__.py +++ b/chirp/__init__.py @@ -17,7 +17,7 @@ import os import sys from glob import glob -CHIRP_VERSION="daily-20160402" +CHIRP_VERSION="daily-20160415" module_dir = os.path.dirname(sys.modules["chirp"].__file__) __all__ = [] diff --git a/chirp/drivers/btech.py b/chirp/drivers/btech.py index 67ed1f3..26c3c0e 100644 --- a/chirp/drivers/btech.py +++ b/chirp/drivers/btech.py @@ -26,7 +26,7 @@ from chirp import bitwise, errors, util from chirp.settings import RadioSettingGroup, RadioSetting, \ RadioSettingValueBoolean, RadioSettingValueList, \ RadioSettingValueString, RadioSettingValueInteger, \ - RadioSettings + RadioSettings, InvalidValueError from textwrap import dedent MEM_FORMAT = """ @@ -54,6 +54,98 @@ struct { pttid:2; } memory[200]; +#seekto 0x0E00; +struct { + u8 tdr; + u8 unknown1; + u8 sql; + u8 unknown2[2]; + u8 tot; + u8 apo; // BTech radios use this as the Auto Power Off time + // other radios use this as pre-Time Out Alert + u8 unknown3; + u8 abr; + u8 beep; + u8 unknown4[4]; + u8 dtmfst; + u8 unknown5[2]; + u8 prisc; + u8 prich; + u8 screv; + u8 unknown6[2]; + u8 pttid; + u8 pttlt; + u8 unknown7; + u8 emctp; + u8 emcch; + u8 ringt; + u8 unknown8; + u8 camdf; + u8 cbmdf; + u8 sync; // BTech radios use this as the display sync setting + // other radios use this as the auto keypad lock setting + u8 ponmsg; + u8 wtled; + u8 rxled; + u8 txled; + u8 unknown9[5]; + u8 anil; + u8 reps; + u8 repm; + u8 tdrab; + u8 ste; + u8 rpste; + u8 rptdl; +} settings; + +#seekto 0x0E80; +struct { + u8 unknown1; + u8 vfomr; + u8 keylock; + u8 unknown2; + u8 unknown3:4, + vfomren:1, + unknown4:1, + reseten:1, + menuen:1; + u8 unknown5[11]; + u8 dispab; + u8 mrcha; + u8 mrchb; + u8 menu; +} settings2; + +#seekto 0x0EC0; +struct { + char line1[6]; + char line2[6]; +} poweron_msg; + +struct settings_vfo { + u8 freq[8]; + u8 unknown1; + u8 offset[4]; + u8 unknown2[3]; + ul16 rxtone; + ul16 txtone; + u8 scode; + u8 spmute; + u8 optsig; + u8 scramble; + u8 wide; + u8 power; + u8 shiftd; + u8 step; + u8 unknown3[4]; +}; + +#seekto 0x0F00; +struct { + struct settings_vfo a; + struct settings_vfo b; +} vfo; + #seekto 0x1000; struct { char name[6]; @@ -84,6 +176,11 @@ struct { u8 uhf_high[3]; } ranges220; +#seekto 0x3F70; +struct { + char fp[6]; +} fingerprint; + """ # A note about the memmory in these radios @@ -106,6 +203,30 @@ NAME_LENGTH = 6 PTTID_LIST = ["OFF", "BOT", "EOT", "BOTH"] PTTIDCODE_LIST = ["%s" % x for x in range(1, 16)] OPTSIG_LIST = ["OFF", "DTMF", "2TONE", "5TONE"] +SPMUTE_LIST = ["Tone/DTCS", "Tone/DTCS and Optsig", "Tone/DTCS or Optsig"] + +LIST_TOT = ["%s sec" % x for x in range(15, 615, 15)] +LIST_TOA = ["Off"] + ["%s seconds" % x for x in range(1, 11)] +LIST_APO = ["Off"] + ["%s minutes" % x for x in range(30, 330, 30)] +LIST_ABR = ["Off"] + ["%s seconds" % x for x in range(1, 51)] +LIST_DTMFST = ["OFF", "Keyboard", "ANI", "Keyboad + ANI"] +LIST_SCREV = ["TO (timeout)", "CO (carrier operated)", "SE (search)"] +LIST_EMCTP = ["TX alarm sound", "TX ANI", "Both"] +LIST_RINGT = ["Off"] + ["%s seconds" % x for x in range(1, 10)] +LIST_MDF = ["Frequency", "Channel", "Name"] +LIST_PONMSG = ["Full", "Message", "Battery voltage"] +LIST_COLOR = ["Off", "Blue", "Orange", "Purple"] +LIST_REPS = ["1000 Hz", "1450 Hz", "1750 Hz", "2100Hz"] +LIST_REPM = ["Off", "Carrier", "CTCSS or DCS", "Tone", "DTMF"] +LIST_RPTDL = ["Off"] + ["%s ms" % x for x in range(1, 10)] +LIST_ANIL = ["3", "4", "5"] +LIST_AB = ["A", "B"] +LIST_VFOMR = ["Frequency", "Channel"] +LIST_SHIFT = ["Off", "+", "-"] +LIST_TXP = ["High", "Low"] +LIST_WIDE = ["Wide", "Narrow"] +STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0] +LIST_STEP = [str(x) for x in STEPS] # This is a general serial timeout for all serial read functions. # Practice has show that about 0.7 sec will be enough to cover all radios. @@ -364,6 +485,9 @@ def _do_ident(radio, status, upload=False): # some radios needs a extra read and check for a code on it, this ones # has the check value in the _id2 var, others simply False if radio._id2 is not False: + # lower the timeout here as this radios are reseting due to timeout + radio.pipe.setTimeout(0.05) + # query & receive the extra ID _send(radio, _make_frame("S", 0x3DF0, 16)) id2 = _rawrecv(radio, 21) @@ -400,7 +524,6 @@ def _do_ident(radio, status, upload=False): # # we just check for a response and last byte being a ACK, that is # the common stone for all radios (3 so far) - radio.pipe.setTimeout(0.1) ack = _rawrecv(radio, 2) # checking @@ -610,7 +733,7 @@ class BTech(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio): global POWER_LEVELS rf = chirp_common.RadioFeatures() - rf.has_settings = False + rf.has_settings = True rf.has_bank = False rf.has_tuning_step = False rf.can_odd_split = True @@ -818,10 +941,6 @@ class BTech(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio): # Extra mem.extra = RadioSettingGroup("extra", "Extra") - spmute = RadioSetting("spmute", "Speaker mute", - RadioSettingValueBoolean(bool(_mem.spmute))) - mem.extra.append(spmute) - scramble = RadioSetting("scramble", "Scramble", RadioSettingValueBoolean(bool(_mem.scramble))) mem.extra.append(scramble) @@ -849,6 +968,12 @@ class BTech(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio): OPTSIG_LIST[_mem.optsig])) mem.extra.append(optsig) + spmute = RadioSetting("spmute", "Speaker mute", + RadioSettingValueList( + SPMUTE_LIST, + SPMUTE_LIST[_mem.spmute])) + mem.extra.append(spmute) + return mem def set_memory(self, mem): @@ -927,6 +1052,473 @@ class BTech(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio): return mem + def get_settings(self): + """Translate the bit in the mem_struct into settings in the UI""" + _mem = self._memobj + basic = RadioSettingGroup("basic", "Basic Settings") + advanced = RadioSettingGroup("advanced", "Advanced Settings") + other = RadioSettingGroup("other", "Other Settings") + work = RadioSettingGroup("work", "Work Mode Settings") + top = RadioSettings(basic, advanced, other, work) + + # Basic + tdr = RadioSetting("settings.tdr", "Transceiver dual receive", + RadioSettingValueBoolean(_mem.settings.tdr)) + basic.append(tdr) + + sql = RadioSetting("settings.sql", "Squelch level", + RadioSettingValueInteger(0, 9, _mem.settings.sql)) + basic.append(sql) + + tot = RadioSetting("settings.tot", "Time out timer", + RadioSettingValueList(LIST_TOT, LIST_TOT[ + _mem.settings.tot])) + basic.append(tot) + + if self.MODEL in ("UV-2501", "UV-2501+220", "UV-5001"): + apo = RadioSetting("settings.apo", "Auto power off timer", + RadioSettingValueList(LIST_APO, LIST_APO[ + _mem.settings.apo])) + basic.append(apo) + else: + toa = RadioSetting("settings.apo", "Time out alert timer", + RadioSettingValueList(LIST_TOA, LIST_TOA[ + _mem.settings.apo])) + basic.append(toa) + + abr = RadioSetting("settings.abr", "Backlight timer", + RadioSettingValueList(LIST_ABR, LIST_ABR[ + _mem.settings.abr])) + basic.append(abr) + + beep = RadioSetting("settings.beep", "Key beep", + RadioSettingValueBoolean(_mem.settings.beep)) + basic.append(beep) + + dtmfst = RadioSetting("settings.dtmfst", "DTMF side tone", + RadioSettingValueList(LIST_DTMFST, LIST_DTMFST[ + _mem.settings.dtmfst])) + basic.append(dtmfst) + + prisc = RadioSetting("settings.prisc", "Priority scan", + RadioSettingValueBoolean(_mem.settings.prisc)) + basic.append(prisc) + + prich = RadioSetting("settings.prich", "Priority channel", + RadioSettingValueInteger(0, 199, + _mem.settings.prich)) + basic.append(prich) + + screv = RadioSetting("settings.screv", "Scan resume method", + RadioSettingValueList(LIST_SCREV, LIST_SCREV[ + _mem.settings.screv])) + basic.append(screv) + + pttlt = RadioSetting("settings.pttlt", "PTT transmit delay", + RadioSettingValueInteger(0, 30, + _mem.settings.pttlt)) + basic.append(pttlt) + + emctp = RadioSetting("settings.emctp", "Alarm mode", + RadioSettingValueList(LIST_EMCTP, LIST_EMCTP[ + _mem.settings.emctp])) + basic.append(emctp) + + emcch = RadioSetting("settings.emcch", "Alarm channel", + RadioSettingValueInteger(0, 199, + _mem.settings.emcch)) + basic.append(emcch) + + ringt = RadioSetting("settings.ringt", "Ring time", + RadioSettingValueList(LIST_RINGT, LIST_RINGT[ + _mem.settings.ringt])) + basic.append(ringt) + + camdf = RadioSetting("settings.camdf", "Display mode A", + RadioSettingValueList(LIST_MDF, LIST_MDF[ + _mem.settings.camdf])) + basic.append(camdf) + + cbmdf = RadioSetting("settings.cbmdf", "Display mode B", + RadioSettingValueList(LIST_MDF, LIST_MDF[ + _mem.settings.cbmdf])) + basic.append(cbmdf) + + if self.MODEL in ("UV-2501", "UV-2501+220", "UV-5001"): + sync = RadioSetting("settings.sync", "A/B channel sync", + RadioSettingValueBoolean(_mem.settings.sync)) + basic.append(sync) + else: + autolk = RadioSetting("settings.sync", "Auto keylock", + RadioSettingValueBoolean(_mem.settings.sync)) + basic.append(autolk) + + ponmsg = RadioSetting("settings.ponmsg", "Power-on message", + RadioSettingValueList(LIST_PONMSG, LIST_PONMSG[ + _mem.settings.ponmsg])) + basic.append(ponmsg) + + wtled = RadioSetting("settings.wtled", "Standby backlight Color", + RadioSettingValueList(LIST_COLOR, LIST_COLOR[ + _mem.settings.wtled])) + basic.append(wtled) + + rxled = RadioSetting("settings.rxled", "RX backlight Color", + RadioSettingValueList(LIST_COLOR, LIST_COLOR[ + _mem.settings.rxled])) + basic.append(rxled) + + txled = RadioSetting("settings.txled", "TX backlight Color", + RadioSettingValueList(LIST_COLOR, LIST_COLOR[ + _mem.settings.txled])) + basic.append(txled) + + anil = RadioSetting("settings.anil", "ANI length", + RadioSettingValueList(LIST_ANIL, LIST_ANIL[ + _mem.settings.anil])) + basic.append(anil) + + reps = RadioSetting("settings.reps", "Relay signal (tone burst)", + RadioSettingValueList(LIST_REPS, LIST_REPS[ + _mem.settings.reps])) + basic.append(reps) + + repm = RadioSetting("settings.repm", "Relay condition", + RadioSettingValueList(LIST_REPM, LIST_REPM[ + _mem.settings.repm])) + basic.append(repm) + + if self.MODEL in ("UV-2501", "UV-2501+220", "UV-5001"): + tdrab = RadioSetting("settings.tdrab", "TDR return time", + RadioSettingValueList(LIST_ABR, LIST_ABR[ + _mem.settings.tdrab])) + basic.append(tdrab) + + ste = RadioSetting("settings.ste", "Squelch tail eliminate", + RadioSettingValueBoolean(_mem.settings.ste)) + basic.append(ste) + + rpste = RadioSetting("settings.rpste", "Repeater STE", + RadioSettingValueList(LIST_RINGT, LIST_RINGT[ + _mem.settings.rpste])) + basic.append(rpste) + + rptdl = RadioSetting("settings.rptdl", "Repeater STE delay", + RadioSettingValueList(LIST_RPTDL, LIST_RPTDL[ + _mem.settings.rptdl])) + basic.append(rptdl) + + # Advanced + def _filter(name): + filtered = "" + for char in str(name): + if char in VALID_CHARS: + filtered += char + else: + filtered += " " + return filtered + + _msg = self._memobj.poweron_msg + line1 = RadioSetting("poweron_msg.line1", "Power-on message line 1", + RadioSettingValueString(0, 6, _filter( + _msg.line1))) + advanced.append(line1) + line2 = RadioSetting("poweron_msg.line2", "Power-on message line 2", + RadioSettingValueString(0, 6, _filter( + _msg.line2))) + advanced.append(line2) + + if self.MODEL in ("UV-2501", "UV-5001"): + vfomren = RadioSetting("settings2.vfomren", "VFO/MR switching", + RadioSettingValueBoolean( + not _mem.settings2.vfomren)) + advanced.append(vfomren) + + reseten = RadioSetting("settings2.reseten", "RESET", + RadioSettingValueBoolean( + _mem.settings2.reseten)) + advanced.append(reseten) + + menuen = RadioSetting("settings2.menuen", "Menu", + RadioSettingValueBoolean( + _mem.settings2.menuen)) + advanced.append(menuen) + + # Other + def convert_bytes_to_limit(bytes): + limit = "" + for byte in bytes: + if byte < 10: + limit += chr(byte + 0x30) + else: + break + return limit + + if "+220" in self.MODEL: + _ranges = self._memobj.ranges220 + ranges = "ranges220" + else: + _ranges = self._memobj.ranges + ranges = "ranges" + + _limit = convert_bytes_to_limit(_ranges.vhf_low) + val = RadioSettingValueString(0, 3, _limit) + val.set_mutable(False) + vhf_low = RadioSetting("%s.vhf_low" % ranges, "VHF low", val) + other.append(vhf_low) + + _limit = convert_bytes_to_limit(_ranges.vhf_high) + val = RadioSettingValueString(0, 3, _limit) + val.set_mutable(False) + vhf_high = RadioSetting("%s.vhf_high" % ranges, "VHF high", val) + other.append(vhf_high) + + if "+220" in self.MODEL: + _limit = convert_bytes_to_limit(_ranges.vhf2_low) + val = RadioSettingValueString(0, 3, _limit) + val.set_mutable(False) + vhf2_low = RadioSetting("%s.vhf2_low" % ranges, "VHF2 low", val) + other.append(vhf2_low) + + _limit = convert_bytes_to_limit(_ranges.vhf2_high) + val = RadioSettingValueString(0, 3, _limit) + val.set_mutable(False) + vhf2_high = RadioSetting("%s.vhf2_high" % ranges, "VHF2 high", val) + other.append(vhf2_high) + + _limit = convert_bytes_to_limit(_ranges.uhf_low) + val = RadioSettingValueString(0, 3, _limit) + val.set_mutable(False) + uhf_low = RadioSetting("%s.uhf_low" % ranges, "UHF low", val) + other.append(uhf_low) + + _limit = convert_bytes_to_limit(_ranges.uhf_high) + val = RadioSettingValueString(0, 3, _limit) + val.set_mutable(False) + uhf_high = RadioSetting("%s.uhf_high" % ranges, "UHF high", val) + other.append(uhf_high) + + val = RadioSettingValueString(0, 6, _filter(_mem.fingerprint.fp)) + val.set_mutable(False) + fp = RadioSetting("fingerprint.fp", "Fingerprint", val) + other.append(fp) + + # Work + dispab = RadioSetting("settings2.dispab", "Display", + RadioSettingValueList(LIST_AB,LIST_AB[ + _mem.settings2.dispab])) + work.append(dispab) + + vfomr = RadioSetting("settings2.vfomr", "VFO/MR mode", + RadioSettingValueList(LIST_VFOMR,LIST_VFOMR[ + _mem.settings2.vfomr])) + work.append(vfomr) + + keylock = RadioSetting("settings2.keylock", "Keypad lock", + RadioSettingValueBoolean(_mem.settings2.keylock)) + work.append(keylock) + + mrcha = RadioSetting("settings2.mrcha", "MR A channel", + RadioSettingValueInteger(0, 199, + _mem.settings2.mrcha)) + work.append(mrcha) + + mrchb = RadioSetting("settings2.mrchb", "MR B channel", + RadioSettingValueInteger(0, 199, + _mem.settings2.mrchb)) + work.append(mrchb) + + def convert_bytes_to_freq(bytes): + real_freq = 0 + for byte in bytes: + real_freq = (real_freq * 10) + byte + return chirp_common.format_freq(real_freq * 10) + + def my_validate(value): + value = chirp_common.parse_freq(value) + print value + if 180000000 <= value and value < 210000000: + msg = ("Can't be between 180.00000-210.00000") + raise InvalidValueError(msg) + elif 231000000 <= value and value < 400000000: + msg = ("Can't be between 231.00000-400.00000") + raise InvalidValueError(msg) + elif 210000000 <= value and value < 231000000 \ + and "+220" not in self.MODEL: + msg = ("Can't be between 180.00000-400.00000") + raise InvalidValueError(msg) + return chirp_common.format_freq(value) + + def apply_freq(setting, obj): + value = chirp_common.parse_freq(str(setting.value)) / 10 + for i in range(7, -1, -1): + obj.freq[i] = value % 10 + value /= 10 + + val1a = RadioSettingValueString(0, 10, convert_bytes_to_freq( + _mem.vfo.a.freq)) + val1a.set_validate_callback(my_validate) + vfoafreq = RadioSetting("vfo.a.freq", "VFO A frequency", val1a) + vfoafreq.set_apply_callback(apply_freq, _mem.vfo.a) + work.append(vfoafreq) + + val1b = RadioSettingValueString(0, 10, convert_bytes_to_freq( + _mem.vfo.b.freq)) + val1b.set_validate_callback(my_validate) + vfobfreq = RadioSetting("vfo.b.freq", "VFO B frequency", val1b) + vfobfreq.set_apply_callback(apply_freq, _mem.vfo.b) + work.append(vfobfreq) + + vfoashiftd = RadioSetting("vfo.a.shiftd", "VFO A shift", + RadioSettingValueList(LIST_SHIFT, LIST_SHIFT[ + _mem.vfo.a.shiftd])) + work.append(vfoashiftd) + + vfobshiftd = RadioSetting("vfo.b.shiftd", "VFO B shift", + RadioSettingValueList(LIST_SHIFT, LIST_SHIFT[ + _mem.vfo.b.shiftd])) + work.append(vfobshiftd) + + def convert_bytes_to_offset(bytes): + real_offset = 0 + for byte in bytes: + real_offset = (real_offset * 10) + byte + return chirp_common.format_freq(real_offset * 10000) + + def apply_offset(setting, obj): + value = chirp_common.parse_freq(str(setting.value)) / 10000 + for i in range(3, -1, -1): + obj.offset[i] = value % 10 + value /= 10 + + val1a = RadioSettingValueString(0, 10, convert_bytes_to_offset( + _mem.vfo.a.offset)) + vfoaoffset = RadioSetting("vfo.a.offset", + "VFO A offset (0.00-99.95)", val1a) + vfoaoffset.set_apply_callback(apply_offset, _mem.vfo.a) + work.append(vfoaoffset) + + val1b = RadioSettingValueString(0, 10, convert_bytes_to_offset( + _mem.vfo.b.offset)) + vfoboffset = RadioSetting("vfo.b.offset", + "VFO B offset (0.00-99.95)", val1b) + vfoboffset.set_apply_callback(apply_offset, _mem.vfo.b) + work.append(vfoboffset) + + vfoatxp = RadioSetting("vfo.a.power", "VFO A power", + RadioSettingValueList(LIST_TXP,LIST_TXP[ + _mem.vfo.a.power])) + work.append(vfoatxp) + + vfobtxp = RadioSetting("vfo.b.power", "VFO B power", + RadioSettingValueList(LIST_TXP,LIST_TXP[ + _mem.vfo.b.power])) + work.append(vfobtxp) + + vfoawide = RadioSetting("vfo.a.wide", "VFO A bandwidth", + RadioSettingValueList(LIST_WIDE,LIST_WIDE[ + _mem.vfo.a.wide])) + work.append(vfoawide) + + vfobwide = RadioSetting("vfo.b.wide", "VFO B bandwidth", + RadioSettingValueList(LIST_WIDE,LIST_WIDE[ + _mem.vfo.b.wide])) + work.append(vfobwide) + + vfoastep = RadioSetting("vfo.a.step", "VFO A step", + RadioSettingValueList(LIST_STEP,LIST_STEP[ + _mem.vfo.a.step])) + work.append(vfoastep) + + vfobstep = RadioSetting("vfo.b.step", "VFO B step", + RadioSettingValueList(LIST_STEP,LIST_STEP[ + _mem.vfo.b.step])) + work.append(vfobstep) + + vfoaoptsig = RadioSetting("vfo.a.optsig", "VFO A optional signal", + RadioSettingValueList(OPTSIG_LIST, + OPTSIG_LIST[_mem.vfo.a.optsig])) + work.append(vfoaoptsig) + + vfoboptsig = RadioSetting("vfo.b.optsig", "VFO B optional signal", + RadioSettingValueList(OPTSIG_LIST, + OPTSIG_LIST[_mem.vfo.b.optsig])) + work.append(vfoboptsig) + + vfoaspmute = RadioSetting("vfo.a.spmute", "VFO A speaker mute", + RadioSettingValueList(SPMUTE_LIST, + SPMUTE_LIST[_mem.vfo.a.spmute])) + work.append(vfoaspmute) + + vfobspmute = RadioSetting("vfo.b.spmute", "VFO B speaker mute", + RadioSettingValueList(SPMUTE_LIST, + SPMUTE_LIST[_mem.vfo.b.spmute])) + work.append(vfobspmute) + + vfoascr = RadioSetting("vfo.a.scramble", "VFO A scramble", + RadioSettingValueBoolean(_mem.vfo.a.scramble)) + work.append(vfoascr) + + vfobscr = RadioSetting("vfo.b.scramble", "VFO B scramble", + RadioSettingValueBoolean(_mem.vfo.b.scramble)) + work.append(vfobscr) + + vfoascode = RadioSetting("vfo.a.scode", "VFO A PTT-ID", + RadioSettingValueList(PTTIDCODE_LIST, + PTTIDCODE_LIST[_mem.vfo.a.scode])) + work.append(vfoascode) + + vfobscode = RadioSetting("vfo.b.scode", "VFO B PTT-ID", + RadioSettingValueList(PTTIDCODE_LIST, + PTTIDCODE_LIST[_mem.vfo.b.scode])) + work.append(vfobscode) + + pttid = RadioSetting("settings.pttid", "PTT ID", + RadioSettingValueList(PTTID_LIST, + PTTID_LIST[_mem.settings.pttid])) + work.append(pttid) + + return top + + def set_settings(self, settings): + _settings = self._memobj.settings + for element in settings: + if not isinstance(element, RadioSetting): + if element.get_name() == "fm_preset": + self._set_fm_preset(element) + else: + self.set_settings(element) + continue + else: + try: + name = element.get_name() + if "." in name: + bits = name.split(".") + obj = self._memobj + for bit in bits[:-1]: + if "/" in bit: + bit, index = bit.split("/", 1) + index = int(index) + obj = getattr(obj, bit)[index] + else: + obj = getattr(obj, bit) + setting = bits[-1] + else: + obj = _settings + setting = element.get_name() + + if element.has_apply_callback(): + LOG.debug("Using apply callback") + element.run_apply_callback() + elif setting == "vfomren": + setattr(obj, setting, not int(element.value)) + elif element.value.get_mutable(): + LOG.debug("Setting %s = %s" % (setting, element.value)) + setattr(obj, setting, element.value) + except Exception, e: + LOG.debug(element.get_name()) + raise + @classmethod def match_model(cls, filedata, filename): match_size = False |
