def populate_list(self): start, end = self.src_radio.get_features().memory_bounds for i in range(start, end + 1): if end > 50 and i % (end / 50) == 0: self.ww.set(float(i) / end) try: mem = self.src_radio.get_memory(i) except errors.InvalidMemoryLocation as e: continue except Exception as e: self.__store.append(row=( False, i, i, "ERROR", chirp_common.format_freq(0), "", False, str(e), )) self.record_use_of(i) continue if mem.empty: continue self.ww.set(float(i) / end) try: msgs = self.dst_radio.validate_memory( import_logic.import_mem(self.dst_radio, self.src_radio.get_features(), mem)) except import_logic.DestNotCompatible: msgs = self.dst_radio.validate_memory(mem) errs = [ x for x in msgs if isinstance(x, chirp_common.ValidationError) ] if errs: msg = _("Cannot be imported because") + ":\r\n" msg += ",".join(errs) else: errs = [] msg = "Memory can be imported into target" self.__store.append(row=(not bool(msgs), mem.number, mem.number, mem.name, chirp_common.format_freq(mem.freq), mem.comment, not bool(errs), msg)) self.record_use_of(mem.number)
def my_validate(value): value = chirp_common.parse_freq(value) msg = ("Can't be less than %i.0000") if value > 99000000 and value < 130 * 1000000: raise InvalidValueError(msg % (130)) msg = ("Can't be between %i.9975-%i.0000") if (179 + 1) * 1000000 <= value and value < 400 * 1000000: raise InvalidValueError(msg % (179, 400)) msg = ("Can't be greater than %i.9975") if value > 99000000 and value > (520 + 1) * 1000000: raise InvalidValueError(msg % (520)) return chirp_common.format_freq(value)
def got_mem(memory, mappings, indexes): iter = self._store.get_iter(self._number_to_path(memory.number)) row = [self.C_FILLED, not memory.empty, self.C_LOC, memory.number, self.C_FREQ, chirp_common.format_freq(memory.freq), self.C_NAME, memory.name, # Hack for only one index right now self.C_INDEX, indexes and indexes[0] or 0, ] for i in range(0, len(self.mappings)): row.append(i + len(self._cols)) row.append(self.mappings[i][0] in mappings) self._store.set(iter, *tuple(row))
def my_validate(value): _vhf_lower = int(_mem.limits.vhf.lower) _vhf_upper = int(_mem.limits.vhf.upper) _uhf_lower = int(_mem.limits.uhf.lower) _uhf_upper = int(_mem.limits.uhf.upper) value = chirp_common.parse_freq(value) msg = ("Can't be less than %i.0000") if value > 99000000 and value < _vhf_lower * 1000000: raise InvalidValueError(msg % _vhf_lower) msg = ("Can't be between %i.9975-%i.0000") if _vhf_upper * 1000000 <= value and value < _uhf_lower * 1000000: raise InvalidValueError(msg % (_vhf_upper - 1, _uhf_lower)) msg = ("Can't be greater than %i.9975") if value > 99000000 and value >= _uhf_upper * 1000000: raise InvalidValueError(msg % (_uhf_upper - 1)) return chirp_common.format_freq(value)
def got_mem(memory, mappings, indexes): iter = self._store.get_iter(self._number_to_path(memory.number)) row = [self.C_FILLED, not memory.empty, self.C_LOC, memory.number, self.C_FREQ, chirp_common.format_freq(memory.freq), self.C_NAME, memory.name, # Hack for only one index right now self.C_INDEX, indexes and indexes[0] or 0, ] for i in range(0, len(self.mappings)): row.append(i + len(self._cols)) row.append(self.mappings[i][0] in mappings) self._store.set(iter, *tuple(row)) if memory.number == self._rf.memory_bounds[1] - 1: print "Got all %s info in %s" % (self._type, (time.time() - self._start))
def got_mem(memory, mappings, indexes): iter = self._store.get_iter(self._number_to_path(memory.number)) row = [ self.C_FILLED, not memory.empty, self.C_LOC, memory.number, self.C_FREQ, chirp_common.format_freq(memory.freq), self.C_NAME, memory.name, # Hack for only one index right now self.C_INDEX, indexes and indexes[0] or 0, ] for i in range(0, len(self.mappings)): row.append(i + len(self._cols)) row.append(self.mappings[i][0] in mappings) self._store.set(iter, *tuple(row)) if memory.number == self._rf.memory_bounds[1] - 1: print "Got all %s info in %s" % (self._type, (time.time() - self._start))
def convert_bytes_to_freq(bytes): real_freq = 0 real_freq = bytes return chirp_common.format_freq(real_freq * 10)
def get_settings(self): """Translate the bit in the mem_struct into settings in the UI""" _mem = self._memobj basic = RadioSettingGroup("basic", "Basic") work = RadioSettingGroup("work", "Work Mode Settings") top = RadioSettings(basic, work) # Basic sql = RadioSetting("settings.sql", "Squelch Level", RadioSettingValueList(LIST_SQL, LIST_SQL[ _mem.settings.sql])) basic.append(sql) tot = RadioSetting("settings.tot", "Time out timer", RadioSettingValueList(LIST_TOT, LIST_TOT[ _mem.settings.tot])) basic.append(tot) power = RadioSetting("settings.power", "Actual Power", RadioSettingValueList(POWER_LEVELS, POWER_LEVELS[_mem.settings.power])) basic.append(power) key_lock = RadioSetting("settings.key", "Keyboard Lock", RadioSettingValueList(KEY_LOCK, KEY_LOCK[_mem.settings.key])) basic.append(key_lock) bw = RadioSetting("settings.bw", "Bandwidth", RadioSettingValueList(BW, BW[_mem.settings.bw])) basic.append(bw) powerrank = RadioSetting("settings.powerrank", "Power output adjust", RadioSettingValueList(POWER_RANK, POWER_RANK[_mem.settings.powerrank])) basic.append(powerrank) lamp = RadioSetting("settings.lamp", "LCD Lamp", RadioSettingValueBoolean(_mem.settings.lamp)) basic.append(lamp) lamp_auto = RadioSetting("settings.lamp_auto", "LCD Lamp auto on/off", RadioSettingValueBoolean( _mem.settings.lamp_auto)) basic.append(lamp_auto) bs = RadioSetting("settings.bs", "Battery Save", RadioSettingValueBoolean(_mem.settings.bs)) basic.append(bs) warning = RadioSetting("settings.warning", "Warning Alerts", RadioSettingValueBoolean(_mem.settings.warning)) basic.append(warning) monitor = RadioSetting("settings.monitor", "Monitor key", RadioSettingValueBoolean(_mem.settings.monitor)) basic.append(monitor) # Work mode settings wmset = RadioSetting("settings.wmem", "VFO/MR Mode", RadioSettingValueList( W_MODE, W_MODE[_mem.settings.wmem])) work.append(wmset) active_ch = RadioSetting("settings.active_ch", "Work Channel", RadioSettingValueList(ACTIVE_CH, ACTIVE_CH[_mem.settings.active_ch])) work.append(active_ch) # vfo rx validation if _mem.vfo.vrx_freq.get_raw()[0] == "\xFF": # if the vfo is not set, the UI cares about the # length of the field, so set a default LOG.debug("VFO freq not set, setting it to default %s" % self._VFO_DEFAULT) vfo = self._VFO_DEFAULT else: vfo = int(_mem.vfo.vrx_freq) * 10 vf_freq = RadioSetting("vfo.vrx_freq", "VFO frequency", RadioSettingValueString(0, 10, chirp_common.format_freq(vfo))) work.append(vf_freq) # shift works # VSHIFT = ["None", "-", "+"] sset = 0 if bool(_mem.vfo.shift_minus) is True: sset = 1 elif bool(_mem.vfo.shift_plus) is True: sset = 2 shift = RadioSetting("shift", "VFO Shift", RadioSettingValueList(VSHIFT, VSHIFT[sset])) work.append(shift) # vfo shift validation if none set it to ZERO if _mem.settings.vfo_shift.get_raw()[0] == "\xFF": # if the shift is not set, the UI cares about the # length of the field, so set to zero LOG.debug("VFO shift not set, setting it to zero") vfo_shift = 0 else: vfo_shift = int(_mem.settings.vfo_shift) * 10 offset = RadioSetting("settings.vfo_shift", "VFO Offset", RadioSettingValueString(0, 9, chirp_common.format_freq(vfo_shift))) work.append(offset) step = RadioSetting("settings.step", "VFO step", RadioSettingValueList(STEPF, STEPF[_mem.settings.step])) work.append(step) # at least for FD-268A/B it doesn't work as stated, so disabled # by now #scamble = RadioSetting("vfo.scramble", "Scramble", #RadioSettingValueList(ONOFF, #ONOFF[int(_mem.vfo.scramble)])) #work.append(scamble) #busy_lock = RadioSetting("vfo.busy_lock", "Busy Lock out", #RadioSettingValueList(ONOFF, #ONOFF[int(_mem.vfo.busy_lock)])) #work.append(busy_lock) # FD-288 Family ANI settings if "FD-288" in self.MODEL: ani_mode = RadioSetting("settings.ani_mode", "ANI ID", RadioSettingValueList(ANI, ANI[_mem.settings.ani_mode])) work.append(ani_mode) # it can't be \xFF ani_value = str(_mem.settings.ani) if ani_value == "\xFF\xFF\xFF": ani_value = "200" ani_value = "".join(x for x in ani_value if (int(x) >= 2 and int(x) <= 9)) ani = RadioSetting("settings.ani", "ANI (200-999)", RadioSettingValueString(0, 3, ani_value)) work.append(ani) return top
def test_format_freq(self): self.assertEqual(chirp_common.format_freq(146520000), "146.520000") self.assertEqual(chirp_common.format_freq(54000000), "54.000000") self.assertEqual(chirp_common.format_freq(1800000), "1.800000") self.assertEqual(chirp_common.format_freq(1), "0.000001") self.assertEqual(chirp_common.format_freq(1250000000), "1250.000000")
def _mem_value(self): return chirp_common.format_freq(StringEditor._mem_value(self))
def my_validate(value): value = chirp_common.parse_freq(value) if 17400000 <= value and value < 40000000: msg = ("Can't be between 174.00000-400.00000") raise InvalidValueError(msg) return chirp_common.format_freq(value)
def get_memory(self, number): _mem, _flg = self._get_memobjs(number) mem = chirp_common.Memory() mem.number = number if _flg.get() == 0x0F: mem.empty = True return mem mem.freq = int(_mem.freq) * 100 # compensate for 6.25 and 12.5 kHz tuning steps, add 500 Hz if needed lastdigit = int(_mem.freq) % 10 if (lastdigit == 2 or lastdigit == 7): mem.freq += 50 mem.offset = int(_mem.offset) * 100 mem.name = str(_mem.name).rstrip() mem.duplex = DUPLEXES[_mem.duplex] mem.mode = _mem.is_am and "AM" or MODES[_mem.channel_width] mem.tuning_step = TUNING_STEPS[_mem.tune_step] if _mem.txoff: mem.duplex = DUPLEXES[3] rxtone = txtone = None rxmode = TMODES[_mem.rxtmode] if (_mem.sqlMode == SQL_MODES.index("Carrier") or _mem.sqlMode == SQL_MODES.index("Opt Sig Only")): rxmode = TMODES.index('') txmode = TMODES[_mem.txtmode] if txmode == "Tone": # If custom tone is being used, show as 88.5 (and set # checkbox in extras) Future: Improve chirp_common, so I # can add "CUSTOM" into TONES if _mem.txtone == len(TONES): txtone = 88.5 else: txtone = TONES[_mem.txtone] elif txmode == "DTCS": txtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index( _mem, 'tx')] if rxmode == "Tone": # If custom tone is being used, show as 88.5 (and set # checkbox in extras) Future: Improve chirp_common, so I # can add "CUSTOM" into TONES if _mem.rxtone == len(TONES): rxtone = 88.5 else: rxtone = TONES[_mem.rxtone] elif rxmode == "DTCS": rxtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index( _mem, 'rx')] rxpol = _mem.rxinv and "R" or "N" txpol = _mem.txinv and "R" or "N" chirp_common.split_tone_decode(mem, (txmode, txtone, txpol), (rxmode, rxtone, rxpol)) mem.skip = _flg.get_skip() and "S" or _flg.get_pskip() and "P" or "" mem.power = POWER_LEVELS[_mem.power] mem.extra = RadioSettingGroup("Extra", "extra") rs = RadioSetting("rev", "Reverse", RadioSettingValueBoolean(_mem.rev)) mem.extra.append(rs) rs = RadioSetting("compander", "Compander", RadioSettingValueBoolean(_mem.compander)) mem.extra.append(rs) rs = RadioSetting("talkaround", "Talkaround", RadioSettingValueBoolean(_mem.talkaround)) mem.extra.append(rs) rs = RadioSetting("pttid", "PTT ID", RadioSettingValueList(PTT_IDS, PTT_IDS[_mem.pttid])) mem.extra.append(rs) rs = RadioSetting("bclo", "Busy Channel Lockout", RadioSettingValueList(BCLO, BCLO[_mem.bclo])) mem.extra.append(rs) rs = RadioSetting( "optsig", "Optional Signaling", RadioSettingValueList(OPT_SIGS, OPT_SIGS[_mem.optsig])) mem.extra.append(rs) rs = RadioSetting( "OPTSIGSQL", "Squelch w/Opt Signaling", RadioSettingValueList( OPT_SIG_SQL, SQL_MODES[_mem.sqlMode] if SQL_MODES[_mem.sqlMode] in OPT_SIG_SQL else "Off")) mem.extra.append(rs) rs = RadioSetting( "dtmfSlotNum", "DTMF", RadioSettingValueList(DTMF_SLOTS, DTMF_SLOTS[_mem.dtmfSlotNum])) mem.extra.append(rs) rs = RadioSetting( "twotone", "2-Tone", RadioSettingValueList(TONE2_SLOTS, TONE2_SLOTS[_mem.twotone])) mem.extra.append(rs) rs = RadioSetting( "fivetone", "5-Tone", RadioSettingValueList(TONE5_SLOTS, TONE5_SLOTS[_mem.fivetone])) mem.extra.append(rs) # Chose not to expose scramble rs = RadioSetting("scramble", # "Scrambler Switch", RadioSettingValueList(SCRAMBLE_CODES, # SCRAMBLE_CODES[_mem.scramble])) mem.extra.append(rs) # Memory properties dialog is only capable of Boolean and List # RadioSettingValue classes, so cannot configure it rs = # RadioSetting("custtone", "Custom CTCSS", # RadioSettingValueFloat(min(TONES), max(TONES), _mem.custtone # and _mem.custtone / 10 or 151.1, 0.1, 1)) # mem.extra.append(rs) custToneStr = chirp_common.format_freq(_mem.custtone) rs = RadioSetting("CUSTTONETX", "Use Custom CTCSS (%s) for Tx" % custToneStr, RadioSettingValueBoolean(_mem.txtone == len(TONES))) mem.extra.append(rs) rs = RadioSetting("CUSTTONERX", "Use Custom CTCSS (%s) for Rx" % custToneStr, RadioSettingValueBoolean(_mem.rxtone == len(TONES))) mem.extra.append(rs) return mem
def my_validate(value): value = chirp_common.parse_freq(value) if 17400000 <= value and value < 40000000: raise InvalidValueError("Can't be between 174.00000-400.00000") return chirp_common.format_freq(value)
def get_settings(self): _settings = self._memobj.settings _info = self._memobj.info _bandlimits = self._memobj.bandlimits basic = RadioSettingGroup("basic", "Basic") info = RadioSettingGroup("info", "Model Info") top = RadioSettings(basic, info) basic.append(RadioSetting( "beep", "Beep", RadioSettingValueBoolean(_settings.beep))) basic.append(RadioSetting( "beep_vol", "Beep Volume", RadioSettingValueInteger(0, 15, _settings.beep_vol))) basic.append(RadioSetting( "keylock", "Key Lock", RadioSettingValueBoolean(_settings.keylock))) basic.append(RadioSetting( "ani_display", "ANI Display", RadioSettingValueBoolean(_settings.ani_display))) basic.append(RadioSetting( "auto_xfer", "Auto Transfer", RadioSettingValueBoolean(_settings.auto_xfer))) basic.append(RadioSetting( "auto_contact", "Auto Contact Always Remind", RadioSettingValueBoolean(_settings.auto_contact))) basic.append(RadioSetting( "auto_am", "Auto AM", RadioSettingValueBoolean(_settings.auto_am))) basic.append(RadioSetting( "left_sql", "Left Squelch", RadioSettingValueList( SQLPRESET, SQLPRESET[_settings.left_sql]))) basic.append(RadioSetting( "right_sql", "Right Squelch", RadioSettingValueList( SQLPRESET, SQLPRESET[_settings.right_sql]))) # basic.append(RadioSetting("apo", "Auto Power off (0.1h)", # RadioSettingValueInteger(0, 20, _settings.apo))) opts = ["Off"] + ["%0.1f" % (t / 10.0) for t in range(1, 21, 1)] basic.append(RadioSetting( "apo", "Auto Power off (Hours)", RadioSettingValueList(opts, opts[_settings.apo]))) opts = ["Off", "1", "2", "3", "Full"] basic.append(RadioSetting( "backlight", "Display Backlight", RadioSettingValueList(opts, opts[_settings.backlight]))) opts = ["Off", "Right", "Left", "Both"] basic.append(RadioSetting( "pttlock", "PTT Lock", RadioSettingValueList(opts, opts[_settings.pttlock]))) opts = ["Manual", "Auto"] basic.append(RadioSetting( "hyper_chan", "Hyper Channel", RadioSettingValueList(opts, opts[_settings.hyper_chan]))) opts = ["Key 1", "Key 2"] basic.append(RadioSetting( "right_func_key", "Right Function Key", RadioSettingValueList(opts, opts[_settings.right_func_key]))) opts = ["1000Hz", "1450Hz", "1750Hz", "2100Hz"] basic.append(RadioSetting( "tbst_freq", "Tone Burst Frequency", RadioSettingValueList(opts, opts[_settings.tbst_freq]))) opts = ["Off", "TX", "RX", "TX RX"] basic.append(RadioSetting( "mute_mode", "Mute Mode", RadioSettingValueList(opts, opts[_settings.mute_mode]))) opts = ["MEM", "MSM"] scanmode = RadioSetting( "scan_mode", "Scan Mode", RadioSettingValueList(opts, opts[_settings.scan_mode])) scanmode.set_doc("MEM = Normal scan, bypass channels marked skip. " " MSM = Scan only channels marked priority.") basic.append(scanmode) opts = ["TO", "CO"] basic.append(RadioSetting( "scan_resume", "Scan Resume", RadioSettingValueList(opts, opts[_settings.scan_resume]))) opts = ["%0.1f" % (t / 10.0) for t in range(0, 51, 1)] basic.append(RadioSetting( "exit_delay", "Span Transit Exit Delay", RadioSettingValueList(opts, opts[_settings.exit_delay]))) basic.append(RadioSetting( "tot", "Time Out Timer (minutes)", RadioSettingValueInteger(0, 30, _settings.tot))) basic.append(RadioSetting( "tot_alert", "Time Out Timer Pre Alert(seconds)", RadioSettingValueInteger(0, 15, _settings.tot_alert))) basic.append(RadioSetting( "tot_rekey", "Time Out Rekey (seconds)", RadioSettingValueInteger(0, 15, _settings.tot_rekey))) basic.append(RadioSetting( "tot_reset", "Time Out Reset(seconds)", RadioSettingValueInteger(0, 15, _settings.tot_reset))) basic.append(RadioSetting( "p1", "P1 Function", RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p1]))) basic.append(RadioSetting( "p2", "P2 Function", RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p2]))) basic.append(RadioSetting( "p3", "P3 Function", RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p3]))) basic.append(RadioSetting( "p4", "P4 Function", RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p4]))) # opts = ["0", "1"] # basic.append(RadioSetting("x", "Desc", # RadioSettingValueList(opts, opts[_settings.x]))) def _filter(name): filtered = "" for char in str(name): if char in chirp_common.CHARSET_ASCII: filtered += char else: filtered += " " return filtered rsvs = RadioSettingValueString(0, 8, _filter(_info.sn)) rsvs.set_mutable(False) rs = RadioSetting("sn", "Serial Number", rsvs) info.append(rs) rsvs = RadioSettingValueString(0, 8, _filter(_info.model)) rsvs.set_mutable(False) rs = RadioSetting("model", "Model Name", rsvs) info.append(rs) rsvs = RadioSettingValueString(0, 16, _filter(_info.code)) rsvs.set_mutable(False) rs = RadioSetting("code", "Model Code", rsvs) info.append(rs) progdate = "%d/%d/%d" % (_info.prog_mon, _info.prog_day, _info.prog_yr) rsvs = RadioSettingValueString(0, 10, progdate) rsvs.set_mutable(False) rs = RadioSetting("progdate", "Last Program Date", rsvs) info.append(rs) # 9 band limits for i in range(0, 9): objname = BANDS[i] + "lorx" objnamepp = BANDS[i] + " Rx Start" # rsv = RadioSettingValueInteger(0, 100000000, # int(_bandlimits[i].lorx)) rsv = RadioSettingValueString( 0, 10, format_freq(int(_bandlimits[i].lorx)*10)) rsv.set_mutable(False) rs = RadioSetting(objname, objnamepp, rsv) info.append(rs) objname = BANDS[i] + "hirx" objnamepp = BANDS[i] + " Rx end" rsv = RadioSettingValueString( 0, 10, format_freq(int(_bandlimits[i].hirx)*10)) rsv.set_mutable(False) rs = RadioSetting(objname, objnamepp, rsv) info.append(rs) objname = BANDS[i] + "lotx" objnamepp = BANDS[i] + " Tx Start" rsv = RadioSettingValueString( 0, 10, format_freq(int(_bandlimits[i].lotx)*10)) rsv.set_mutable(False) rs = RadioSetting(objname, objnamepp, rsv) info.append(rs) objname = BANDS[i] + "hitx" objnamepp = BANDS[i] + " Tx end" rsv = RadioSettingValueString( 0, 10, format_freq(int(_bandlimits[i].hitx)*10)) rsv.set_mutable(False) rs = RadioSetting(objname, objnamepp, rsv) info.append(rs) return top
def convert_bytes_to_offset(bytes): real_offset = 0 real_offset = bytes return chirp_common.format_freq(real_offset * 10000)
def set_memory(doc, mem): """Set @mem in @doc""" ctx = doc.xpathNewContext() base = "//radio/memories/memory[@location=%i]" % mem.number fields = ctx.xpathEval(base) if len(fields) > 1: raise errors.RadioError("%i memories claiming to be %i" % (len(fields), mem.number)) elif len(fields) == 1: fields[0].unlinkNode() radio = ctx.xpathEval("//radio/memories")[0] memnode = radio.newChild(None, "memory", None) memnode.newProp("location", "%i" % mem.number) sname_filter = "[^A-Z0-9/ >-]" sname = memnode.newChild(None, "shortName", None) sname.addContent(re.sub(sname_filter, "", mem.name.upper()[:6])) lname_filter = "[^.A-Za-z0-9/ >-]" lname = memnode.newChild(None, "longName", None) lname.addContent(re.sub(lname_filter, "", mem.name[:16])) freq = memnode.newChild(None, "frequency", None) freq.newProp("units", "MHz") freq.addContent(chirp_common.format_freq(mem.freq)) rtone = memnode.newChild(None, "squelch", None) rtone.newProp("id", "rtone") rtone.newProp("type", "repeater") tone = rtone.newChild(None, "tone", None) tone.addContent("%.1f" % mem.rtone) ctone = memnode.newChild(None, "squelch", None) ctone.newProp("id", "ctone") ctone.newProp("type", "ctcss") tone = ctone.newChild(None, "tone", None) tone.addContent("%.1f" % mem.ctone) dtcs = memnode.newChild(None, "squelch", None) dtcs.newProp("id", "dtcs") dtcs.newProp("type", "dtcs") code = dtcs.newChild(None, "code", None) code.addContent("%03i" % mem.dtcs) polr = dtcs.newChild(None, "polarity", None) polr.addContent(mem.dtcs_polarity) sset = memnode.newChild(None, "squelchSetting", None) if mem.tmode == "Tone": sset.addContent("rtone") elif mem.tmode == "TSQL": sset.addContent("ctone") elif mem.tmode == "DTCS": sset.addContent("dtcs") dmap = {"+": "positive", "-": "negative", "": "none"} dupx = memnode.newChild(None, "duplex", None) dupx.addContent(dmap[mem.duplex]) oset = memnode.newChild(None, "offset", None) oset.newProp("units", "MHz") oset.addContent(chirp_common.format_freq(mem.offset)) mode = memnode.newChild(None, "mode", None) mode.addContent(mem.mode) step = memnode.newChild(None, "tuningStep", None) step.newProp("units", "kHz") step.addContent("%.5f" % mem.tuning_step) if mem.skip: skip = memnode.newChild(None, "skip", None) skip.addContent(mem.skip) # FIXME: .chirp bank support needs to be redone # if mem.bank is not None: # bank = memnode.newChild(None, "bank", None) # bank.newProp("bankId", str(int(mem.bank))) # if mem.bank_index >= 0: # bank.newProp("bankIndex", str(int(mem.bank_index))) if isinstance(mem, chirp_common.DVMemory): dv = memnode.newChild(None, "dv", None) ur = dv.newChild(None, "urcall", None) ur.addContent(mem.dv_urcall) r1 = dv.newChild(None, "rpt1call", None) if mem.dv_rpt1call and mem.dv_rpt1call != "*NOTUSE*": r1.addContent(mem.dv_rpt1call) r2 = dv.newChild(None, "rpt2call", None) if mem.dv_rpt2call and mem.dv_rpt2call != "*NOTUSE*": r2.addContent(mem.dv_rpt2call) dc = dv.newChild(None, "digitalCode", None) dc.addContent(str(mem.dv_code))
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 get_settings(self): _settings = self._memobj.settings _info = self._memobj.info _bandlimits = self._memobj.bandlimits basic = RadioSettingGroup("basic", "Basic") info = RadioSettingGroup("info", "Model Info") top = RadioSettings(basic, info) add_radio_bool(basic, "beep", "Beep", _settings.beep) add_radio_bool(basic, "ars", "Auto Repeater Shift", _settings.ars) add_radio_setting(basic, "keylock", "Key Lock", zero_indexed_seq_map(["Manual", "Auto"]), _settings.keylock) add_radio_bool(basic, "auto_am", "Auto AM", _settings.auto_am) add_radio_setting(basic, "left_sql", "Left Squelch", zero_indexed_seq_map(SQLPRESET), _settings.left_sql) add_radio_setting(basic, "right_sql", "Right Squelch", zero_indexed_seq_map(SQLPRESET), _settings.right_sql) add_radio_setting(basic, "apo", "Auto Power off (Hours)", [("Off", 0), ("0.5", 5), ("1.0", 10), ("1.5", 15), ("2.0", 20)], _settings.apo) add_radio_setting(basic, "backlight", "Display Backlight", zero_indexed_seq_map(["Off", "1", "2", "3", "Full"]), _settings.backlight) add_radio_setting(basic, "pttlock", "PTT Lock", zero_indexed_seq_map(["Off", "Right", "Left", "Both"]), _settings.pttlock) add_radio_setting(basic, "hyper_chan", "Hyper Channel", zero_indexed_seq_map(["Manual", "Auto"]), _settings.hyper_chan) add_radio_setting(basic, "right_func_key", "Right Function Key", zero_indexed_seq_map(["Key 1", "Key 2"]), _settings.right_func_key) add_radio_setting(basic, "mute_mode", "Mute Mode", zero_indexed_seq_map(["Off", "TX", "RX", "TX RX"]), _settings.mute_mode) add_radio_setting(basic, "scan_mode", "Scan Mode", zero_indexed_seq_map(["MEM", "MSM"]), _settings.scan_mode, doc="MEM = Normal scan, bypass channels marked " "skip. MSM = Scan only channels marked priority.") add_radio_setting(basic, "scan_resume", "Scan Resume", zero_indexed_seq_map(["Time", "Busy"]), _settings.scan_resume) basic.append(RadioSetting( "tot", "Time Out Timer (minutes)", RadioSettingValueInteger(0, 30, _settings.tot))) add_radio_setting(basic, "p1", "P1 Function", zero_indexed_seq_map(MICKEYFUNC), _settings.p1) add_radio_setting(basic, "p2", "P2 Function", zero_indexed_seq_map(MICKEYFUNC), _settings.p2) add_radio_setting(basic, "p3", "P3 Function", zero_indexed_seq_map(MICKEYFUNC), _settings.p3) add_radio_setting(basic, "p4", "P4 Function", zero_indexed_seq_map(MICKEYFUNC), _settings.p4) def _filter(name): filtered = "" for char in str(name): if char in chirp_common.CHARSET_ASCII: filtered += char else: filtered += " " return filtered rsvs = RadioSettingValueString(0, 8, _filter(_info.sn)) rsvs.set_mutable(False) rs = RadioSetting("sn", "Serial Number", rsvs) info.append(rs) rsvs = RadioSettingValueString(0, 8, _filter(_info.model)) rsvs.set_mutable(False) rs = RadioSetting("model", "Model Name", rsvs) info.append(rs) rsvs = RadioSettingValueString(0, 16, _filter(_info.code)) rsvs.set_mutable(False) rs = RadioSetting("code", "Model Code", rsvs) info.append(rs) progdate = "%d/%d/%d" % (_info.prog_mon, _info.prog_day, _info.prog_yr) rsvs = RadioSettingValueString(0, 10, progdate) rsvs.set_mutable(False) rs = RadioSetting("progdate", "Last Program Date", rsvs) info.append(rs) # Band Limits for i in range(0, len(BANDS)): rx_start = int(_bandlimits[i].lorx) * 10 if not rx_start == 0: objname = BANDS[i] + "lorx" objnamepp = BANDS[i] + " Rx Start" rsv = RadioSettingValueString(0, 10, format_freq(rx_start)) rsv.set_mutable(False) rs = RadioSetting(objname, objnamepp, rsv) info.append(rs) rx_end = int(_bandlimits[i].hirx) * 10 objname = BANDS[i] + "hirx" objnamepp = BANDS[i] + " Rx end" rsv = RadioSettingValueString(0, 10, format_freq(rx_end)) rsv.set_mutable(False) rs = RadioSetting(objname, objnamepp, rsv) info.append(rs) tx_start = int(_bandlimits[i].lotx) * 10 if not tx_start == 0: objname = BANDS[i] + "lotx" objnamepp = BANDS[i] + " Tx Start" rsv = RadioSettingValueString(0, 10, format_freq(tx_start)) rsv.set_mutable(False) rs = RadioSetting(objname, objnamepp, rsv) info.append(rs) tx_end = int(_bandlimits[i].hitx) * 10 objname = BANDS[i] + "hitx" objnamepp = BANDS[i] + " Tx end" rsv = RadioSettingValueString(0, 10, format_freq(tx_end)) rsv.set_mutable(False) rs = RadioSetting(objname, objnamepp, rsv) info.append(rs) return top
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 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 * 100)