Beispiel #1
0
    def get_settings(self):
        top = RadioSettings()

        aprs = RadioSettingGroup("aprs", "APRS")
        top.append(aprs)

        myc = self._memobj.aprs_my_callsign
        rs = RadioSetting("aprs_my_callsign.call", "APRS My Callsign",
                          RadioSettingValueString(0, 6,
                                                  aprs_call_to_str(myc.call)))
        aprs.append(rs)

        rs = RadioSetting("aprs_my_callsign.ssid", "APRS My SSID",
                          RadioSettingValueInteger(0, 15, myc.ssid))
        aprs.append(rs)

        return top
Beispiel #2
0
    def _get_settings(self):
        _ani = self._memobj.ani
        _settings = self._memobj.settings
        _vfoa = self._memobj.vfoa
        _vfob = self._memobj.vfob
        _keymaps = self._memobj.keymaps

        basic = RadioSettingGroup("basic", "Basic Settings")
        advanced = RadioSettingGroup("advanced", "Advanced Settings")
        workmode = RadioSettingGroup("workmode", "Work Mode Settings")
        keymaps = RadioSettingGroup("keymaps", "KeyMaps")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")

        group = RadioSettings(basic, advanced, workmode, keymaps, dtmf)

        rs = RadioSetting("squelch", "Carrier Squelch Level",
                          RadioSettingValueInteger(0, 5, _settings.squelch))
        basic.append(rs)

        rs = RadioSetting("battery_saver", "Battery Save",
                          RadioSettingValueBoolean(_settings.battery_saver))
        advanced.append(rs)

        rs = RadioSetting(
            "vox", "VOX Sensitivity",
            RadioSettingValueList(VOX_LIST, VOX_LIST[_settings.vox]))
        basic.append(rs)

        rs = RadioSetting(
            "auto_bl", "Auto Backlight Timeout",
            RadioSettingValueList(AUTOBL_LIST, AUTOBL_LIST[_settings.auto_bl]))
        advanced.append(rs)

        rs = RadioSetting(
            "tot", "TX Timeout Timer",
            RadioSettingValueList(TOT_LIST, TOT_LIST[_settings.tot]))
        basic.append(rs)

        rs = RadioSetting("beep", "Beep",
                          RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)

        rs = RadioSetting("voice", "Voice",
                          RadioSettingValueBoolean(_settings.voice))
        advanced.append(rs)

        rs = RadioSetting(
            "language", "Language",
            RadioSettingValueList(LANGUAGE_LIST,
                                  LANGUAGE_LIST[_settings.language]))
        advanced.append(rs)

        rs = RadioSetting(
            "mdfa", "Display Mode (A)",
            RadioSettingValueList(MODE_LIST, MODE_LIST[_settings.mdfa]))
        basic.append(rs)

        rs = RadioSetting(
            "mdfb", "Display Mode (B)",
            RadioSettingValueList(MODE_LIST, MODE_LIST[_settings.mdfb]))
        basic.append(rs)

        rs = RadioSetting(
            "scan_mode", "Scan Mode",
            RadioSettingValueList(SCAN_MODE_LIST,
                                  SCAN_MODE_LIST[_settings.scan_mode]))
        basic.append(rs)

        rs = RadioSetting("bcl", "Busy Channel Lockout",
                          RadioSettingValueBoolean(_settings.bcl))
        advanced.append(rs)

        rs = RadioSetting("autolk", "Automatic Key Lock",
                          RadioSettingValueBoolean(_settings.autolk))
        advanced.append(rs)

        rs = RadioSetting(
            "almod", "Alarm Mode",
            RadioSettingValueList(ALMOD_LIST, ALMOD_LIST[_settings.almod]))
        advanced.append(rs)

        rs = RadioSetting("alsnd", "Alarm Sound",
                          RadioSettingValueBoolean(_settings.alsnd))
        advanced.append(rs)

        rs = RadioSetting("ste", "Squelch Tail Eliminate (HT to HT)",
                          RadioSettingValueBoolean(_settings.ste))
        advanced.append(rs)

        rs = RadioSetting(
            "rpste", "Squelch Tail Eliminate (repeater)",
            RadioSettingValueList(RPSTE_LIST, RPSTE_LIST[_settings.rpste]))
        advanced.append(rs)

        rs = RadioSetting(
            "rptrl", "STE Repeater Delay",
            RadioSettingValueList(STEDELAY_LIST,
                                  STEDELAY_LIST[_settings.rptrl]))
        advanced.append(rs)

        rs = RadioSetting("fmradio", "Disable Broadcast FM Radio",
                          RadioSettingValueBoolean(_settings.fmradio))
        advanced.append(rs)

        rs = RadioSetting("keylock", "Keypad Lock",
                          RadioSettingValueBoolean(_settings.keylock))
        advanced.append(rs)

        rs = RadioSetting(
            "voxdelay", "VOX Delay",
            RadioSettingValueList(VOX_DELAY_LIST,
                                  VOX_DELAY_LIST[_settings.voxdelay]))
        advanced.append(rs)

        rs = RadioSetting(
            "menu_timeout", "Menu Timeout",
            RadioSettingValueList(MENU_TIMEOUT_LIST,
                                  MENU_TIMEOUT_LIST[_settings.menu_timeout]))
        advanced.append(rs)

        rs = RadioSetting(
            "micgain", "Mic Gain",
            RadioSettingValueList(MICGAIN_LIST,
                                  MICGAIN_LIST[_settings.micgain]))
        advanced.append(rs)

        for entry in KEY_FUNCTIONS:
            if entry[1] == _keymaps.sidekey:
                rs = RadioSetting(
                    "keymaps.sidekey", "Side Key Short Press",
                    RadioSettingValueMap(KEY_FUNCTIONS, _keymaps.sidekey))
                keymaps.append(rs)

        for entry in KEY_FUNCTIONS:
            if entry[1] == _keymaps.sidekeyl:
                rs = RadioSetting(
                    "keymaps.sidekeyl", "Side Key Long Press",
                    RadioSettingValueMap(KEY_FUNCTIONS, _keymaps.sidekeyl))
                keymaps.append(rs)

        rs = RadioSetting(
            "workmodea", "Work Mode (A)",
            RadioSettingValueList(WORKMODE_LIST,
                                  WORKMODE_LIST[_settings.workmodea]))
        workmode.append(rs)

        rs = RadioSetting(
            "workmodeb", "Work Mode (B)",
            RadioSettingValueList(WORKMODE_LIST,
                                  WORKMODE_LIST[_settings.workmodeb]))
        workmode.append(rs)

        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)
            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 apply_freq(setting, obj):
            value = chirp_common.parse_freq(str(setting.value)) / 10
            obj.band = value >= 40000000
            for i in range(7, -1, -1):
                obj.freq[i] = value % 10
                value /= 10

        val1a = RadioSettingValueString(0, 10,
                                        convert_bytes_to_freq(_vfoa.freq))
        val1a.set_validate_callback(my_validate)
        rs = RadioSetting("vfoa.freq", "VFO A Frequency", val1a)
        rs.set_apply_callback(apply_freq, _vfoa)
        workmode.append(rs)

        val1b = RadioSettingValueString(0, 10,
                                        convert_bytes_to_freq(_vfob.freq))
        val1b.set_validate_callback(my_validate)
        rs = RadioSetting("vfob.freq", "VFO B Frequency", val1b)
        rs.set_apply_callback(apply_freq, _vfob)
        workmode.append(rs)

        rs = RadioSetting(
            "vfoa.sftd", "VFO A Shift",
            RadioSettingValueList(SHIFTD_LIST, SHIFTD_LIST[_vfoa.sftd]))
        workmode.append(rs)

        rs = RadioSetting(
            "vfob.sftd", "VFO B Shift",
            RadioSettingValueList(SHIFTD_LIST, SHIFTD_LIST[_vfob.sftd]))
        workmode.append(rs)

        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)

        def apply_offset(setting, obj):
            value = chirp_common.parse_freq(str(setting.value)) / 100
            for i in range(5, -1, -1):
                obj.offset[i] = value % 10
                value /= 10

        val1a = RadioSettingValueString(0, 10,
                                        convert_bytes_to_offset(_vfoa.offset))
        rs = RadioSetting("vfoa.offset", "VFO A Offset (0.0-999.999)", val1a)
        rs.set_apply_callback(apply_offset, _vfoa)
        workmode.append(rs)

        val1b = RadioSettingValueString(0, 10,
                                        convert_bytes_to_offset(_vfob.offset))
        rs = RadioSetting("vfob.offset", "VFO B Offset (0.0-999.999)", val1b)
        rs.set_apply_callback(apply_offset, _vfob)
        workmode.append(rs)

        rs = RadioSetting(
            "vfoa.txpower", "VFO A Power",
            RadioSettingValueList(TXPOWER_LIST, TXPOWER_LIST[_vfoa.txpower]))
        workmode.append(rs)

        rs = RadioSetting(
            "vfob.txpower", "VFO B Power",
            RadioSettingValueList(TXPOWER_LIST, TXPOWER_LIST[_vfob.txpower]))
        workmode.append(rs)

        rs = RadioSetting(
            "vfoa.widenarr", "VFO A Bandwidth",
            RadioSettingValueList(BANDWIDTH_LIST,
                                  BANDWIDTH_LIST[_vfoa.widenarr]))
        workmode.append(rs)

        rs = RadioSetting(
            "vfob.widenarr", "VFO B Bandwidth",
            RadioSettingValueList(BANDWIDTH_LIST,
                                  BANDWIDTH_LIST[_vfob.widenarr]))
        workmode.append(rs)

        rs = RadioSetting(
            "vfoa.scode", "VFO A PTT-ID",
            RadioSettingValueList(PTTIDCODE_LIST, PTTIDCODE_LIST[_vfoa.scode]))
        workmode.append(rs)

        rs = RadioSetting(
            "vfob.scode", "VFO B PTT-ID",
            RadioSettingValueList(PTTIDCODE_LIST, PTTIDCODE_LIST[_vfob.scode]))
        workmode.append(rs)

        rs = RadioSetting(
            "vfoa.step", "VFO A Tuning Step",
            RadioSettingValueList(STEP_LIST, STEP_LIST[_vfoa.step]))
        workmode.append(rs)
        rs = RadioSetting(
            "vfob.step", "VFO B Tuning Step",
            RadioSettingValueList(STEP_LIST, STEP_LIST[_vfob.step]))
        workmode.append(rs)

        dtmfchars = "0123456789 *#ABCD"

        for i in range(0, 15):
            _codeobj = self._memobj.pttid[i].code
            _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
            val = RadioSettingValueString(0, 5, _code, False)
            val.set_charset(dtmfchars)
            rs = RadioSetting("pttid/%i.code" % i, "PTT ID Code %i" % (i + 1),
                              val)

            def apply_code(setting, obj):
                code = []
                for j in range(0, 5):
                    try:
                        code.append(dtmfchars.index(str(setting.value)[j]))
                    except IndexError:
                        code.append(0xFF)
                obj.code = code

            rs.set_apply_callback(apply_code, self._memobj.pttid[i])
            dtmf.append(rs)

        rs = RadioSetting(
            "ani.aniid", "ANI ID",
            RadioSettingValueList(PTTID_LIST, PTTID_LIST[_ani.aniid]))
        dtmf.append(rs)

        _codeobj = self._memobj.ani.code
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 5, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("ani.code", "ANI Code", val)

        def apply_code(setting, obj):
            code = []
            for j in range(0, 5):
                try:
                    code.append(dtmfchars.index(str(setting.value)[j]))
                except IndexError:
                    code.append(0xFF)
            obj.code = code

        rs.set_apply_callback(apply_code, _ani)
        dtmf.append(rs)

        rs = RadioSetting(
            "dtmfst", "DTMF Sidetone",
            RadioSettingValueList(DTMFST_LIST, DTMFST_LIST[_settings.dtmfst]))
        dtmf.append(rs)

        if _ani.dtmfon > 0xC3:
            val = 0x00
        else:
            val = _ani.dtmfon
        rs = RadioSetting(
            "ani.dtmfon", "DTMF Speed (on)",
            RadioSettingValueList(DTMFSPEED_LIST, DTMFSPEED_LIST[val]))
        dtmf.append(rs)

        if _ani.dtmfoff > 0xC3:
            val = 0x00
        else:
            val = _ani.dtmfoff
        rs = RadioSetting(
            "ani.dtmfoff", "DTMF Speed (off)",
            RadioSettingValueList(DTMFSPEED_LIST, DTMFSPEED_LIST[val]))
        dtmf.append(rs)

        rs = RadioSetting(
            "pttlt", "PTT ID Delay",
            RadioSettingValueList(PTTLT_LIST, PTTLT_LIST[_settings.pttlt]))
        dtmf.append(rs)

        return group
Beispiel #3
0
    def get_settings(self):
        """Translate the bit in the mem_struct into settings in the UI"""
        _mem = self._memobj
        basic = RadioSettingGroup("basic", "Basic Settings")
        other = RadioSettingGroup("other", "Other Settings")
        work = RadioSettingGroup("work", "Work Mode Settings")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        top = RadioSettings(basic, other, work, dtmf)

        # Basic

        # Audio: A01-A04

        aftone = RadioSetting(
            "settings.aftone", "AF tone control",
            RadioSettingValueList(LIST_AFTONE,
                                  LIST_AFTONE[_mem.settings.aftone]))
        basic.append(aftone)

        spkr = RadioSetting(
            "settings.spkr", "Speaker",
            RadioSettingValueList(LIST_SPKR, LIST_SPKR[_mem.settings.spkr]))
        basic.append(spkr)

        audio = RadioSetting(
            "settings.audio", "Stereo/Mono",
            RadioSettingValueList(LIST_AUDIO, LIST_AUDIO[_mem.settings.audio]))
        basic.append(audio)

        sbmute = RadioSetting(
            "settings.sbmute", "Sub band mute",
            RadioSettingValueList(LIST_SBMUTE,
                                  LIST_SBMUTE[_mem.settings.sbmute]))
        basic.append(sbmute)

        # TX/RX: B01-B08

        mgain = RadioSetting(
            "settings.mgain", "Mic gain",
            RadioSettingValueList(LIST_MLNHM, LIST_MLNHM[_mem.settings.mgain]))
        basic.append(mgain)

        ptt = RadioSetting(
            "settings.ptt", "PTT mode",
            RadioSettingValueList(LIST_PTT, LIST_PTT[_mem.settings.ptt]))
        basic.append(ptt)

        # B03 (per channel)
        # B04 (per channel)

        rxexp = RadioSetting(
            "settings.rxexp", "RX expansion",
            RadioSettingValueList(LIST_RXEXP, LIST_RXEXP[_mem.settings.rxexp]))
        basic.append(rxexp)

        vox = RadioSetting(
            "settings.vox", "Vox",
            RadioSettingValueList(LIST_VOX, LIST_VOX[_mem.settings.vox]))
        basic.append(vox)

        voxs = RadioSetting(
            "settings.voxs", "Vox sensitivity",
            RadioSettingValueList(LIST_MLNHM, LIST_MLNHM[_mem.settings.voxs]))
        basic.append(voxs)

        # B08 (per channel)

        # Display: C01-C06

        display = RadioSetting(
            "settings.display", "Display select",
            RadioSettingValueList(LIST_DISPLAY,
                                  LIST_DISPLAY[_mem.settings.display]))
        basic.append(display)

        lcdb = RadioSetting(
            "settings.lcdb", "LCD brightness",
            RadioSettingValueList(LIST_MINMAX,
                                  LIST_MINMAX[_mem.settings.lcdb]))
        basic.append(lcdb)

        color = RadioSetting(
            "settings.color", "LCD color",
            RadioSettingValueList(LIST_COLOR, LIST_COLOR[_mem.settings.color]))
        basic.append(color)

        lcdc = RadioSetting(
            "settings.lcdc", "LCD contrast",
            RadioSettingValueList(LIST_MINMAX,
                                  LIST_MINMAX[_mem.settings.lcdc]))
        basic.append(lcdc)

        btime = RadioSetting(
            "settings.btime", "LCD backlight time",
            RadioSettingValueList(LIST_BTIME, LIST_BTIME[_mem.settings.btime]))
        basic.append(btime)

        keyb = RadioSetting(
            "settings.keyb", "Key brightness",
            RadioSettingValueList(LIST_MINMAX,
                                  LIST_MINMAX[_mem.settings.keyb]))
        basic.append(keyb)

        # Memory: D01-D04

        # D01 (per channel)
        # D02 (per channel)

        mrscan = RadioSetting(
            "settings.mrscan", "Memory scan type",
            RadioSettingValueList(LIST_MRSCAN,
                                  LIST_MRSCAN[_mem.settings.mrscan]))
        basic.append(mrscan)

        # D04 (per channel)

        # Scan: E01-E04

        dwstop = RadioSetting(
            "settings.dwstop", "Dual watch stop",
            RadioSettingValueList(LIST_DWSTOP,
                                  LIST_DWSTOP[_mem.settings.dwstop]))
        basic.append(dwstop)

        scand = RadioSetting(
            "settings.scand", "Scan direction",
            RadioSettingValueList(LIST_SCAND, LIST_SCAND[_mem.settings.scand]))
        basic.append(scand)

        scanr = RadioSetting(
            "settings.scanr", "Scan resume",
            RadioSettingValueList(LIST_SCANR, LIST_SCANR[_mem.settings.scanr]))
        basic.append(scanr)

        scansb = RadioSetting("settings.scansb", "Scan stop beep",
                              RadioSettingValueBoolean(_mem.settings.scansb))
        basic.append(scansb)

        # System: F01-F09

        apo = RadioSetting(
            "settings.apo", "Automatic power off [hours]",
            RadioSettingValueList(LIST_APO, LIST_APO[_mem.settings.apo]))
        basic.append(apo)

        ars = RadioSetting("settings.ars", "Automatic repeater shift",
                           RadioSettingValueBoolean(_mem.settings.ars))
        basic.append(ars)

        beep = RadioSetting(
            "settings.beep", "Beep volume",
            RadioSettingValueList(LIST_BEEP, LIST_BEEP[_mem.settings.beep]))
        basic.append(beep)

        fkey = RadioSetting(
            "settings.fkey", "F key",
            RadioSettingValueList(LIST_FKEY, LIST_FKEY[_mem.settings.fkey]))
        basic.append(fkey)

        pfkey1 = RadioSetting(
            "settings.pfkey1", "Mic P1 key",
            RadioSettingValueList(LIST_PFKEY,
                                  LIST_PFKEY[_mem.settings.pfkey1]))
        basic.append(pfkey1)

        pfkey2 = RadioSetting(
            "settings.pfkey2", "Mic P2 key",
            RadioSettingValueList(LIST_PFKEY,
                                  LIST_PFKEY[_mem.settings.pfkey2]))
        basic.append(pfkey2)

        pfkey3 = RadioSetting(
            "settings.pfkey3", "Mic P3 key",
            RadioSettingValueList(LIST_PFKEY,
                                  LIST_PFKEY[_mem.settings.pfkey3]))
        basic.append(pfkey3)

        pfkey4 = RadioSetting(
            "settings.pfkey4", "Mic P4 key",
            RadioSettingValueList(LIST_PFKEY,
                                  LIST_PFKEY[_mem.settings.pfkey4]))
        basic.append(pfkey4)

        omode = RadioSetting(
            "settings.omode", "Operation mode",
            RadioSettingValueList(LIST_AB, LIST_AB[_mem.settings.omode]))
        basic.append(omode)

        rxcoverm = RadioSetting(
            "settings.rxcoverm", "RX coverage - memory",
            RadioSettingValueList(LIST_COVERAGE,
                                  LIST_COVERAGE[_mem.settings.rxcoverm]))
        basic.append(rxcoverm)

        rxcoverv = RadioSetting(
            "settings.rxcoverv", "RX coverage - VFO",
            RadioSettingValueList(LIST_COVERAGE,
                                  LIST_COVERAGE[_mem.settings.rxcoverv]))
        basic.append(rxcoverv)

        tot = RadioSetting(
            "settings.tot", "Time out timer [min]",
            RadioSettingValueList(LIST_TOT, LIST_TOT[_mem.settings.tot]))
        basic.append(tot)

        # Timer/Clock: G01-G04

        # G01
        datefmt = RadioSetting(
            "settings.datefmt", "Date format",
            RadioSettingValueList(LIST_DATEFMT,
                                  LIST_DATEFMT[_mem.settings.datefmt]))
        basic.append(datefmt)

        timefmt = RadioSetting(
            "settings.timefmt", "Time format",
            RadioSettingValueList(LIST_TIMEFMT,
                                  LIST_TIMEFMT[_mem.settings.timefmt]))
        basic.append(timefmt)

        timesig = RadioSetting("settings.timesig", "Time signal",
                               RadioSettingValueBoolean(_mem.settings.timesig))
        basic.append(timesig)

        tz = RadioSetting(
            "settings.tz", "Time zone",
            RadioSettingValueList(LIST_TZ, LIST_TZ[_mem.settings.tz]))
        basic.append(tz)

        # Signaling: H01-H06

        bell = RadioSetting(
            "settings.bell", "Bell ringer",
            RadioSettingValueList(LIST_BELL, LIST_BELL[_mem.settings.bell]))
        basic.append(bell)

        # H02 (per channel)

        dtmfmodenc = RadioSetting(
            "settings.dtmfmodenc", "DTMF mode encode",
            RadioSettingValueBoolean(_mem.settings.dtmfmodenc))
        basic.append(dtmfmodenc)

        dtmfmoddec = RadioSetting(
            "settings.dtmfmoddec", "DTMF mode decode",
            RadioSettingValueBoolean(_mem.settings.dtmfmoddec))
        basic.append(dtmfmoddec)

        # H04 (per channel)

        decbandsel = RadioSetting(
            "settings.decbandsel", "DTMF band select",
            RadioSettingValueList(LIST_AB, LIST_AB[_mem.settings.decbandsel]))
        basic.append(decbandsel)

        sqlexp = RadioSetting("settings.sqlexp", "SQL expansion",
                              RadioSettingValueBoolean(_mem.settings.sqlexp))
        basic.append(sqlexp)

        # Pkt: I01-I03

        databnd = RadioSetting(
            "settings.databnd", "Packet data band",
            RadioSettingValueList(LIST_DATABND,
                                  LIST_DATABND[_mem.settings.databnd]))
        basic.append(databnd)

        dataspd = RadioSetting(
            "settings.dataspd", "Packet data speed",
            RadioSettingValueList(LIST_DATASPD,
                                  LIST_DATASPD[_mem.settings.dataspd]))
        basic.append(dataspd)

        datasql = RadioSetting(
            "settings.datasql", "Packet data squelch",
            RadioSettingValueList(LIST_DATASQL,
                                  LIST_DATASQL[_mem.settings.datasql]))
        basic.append(datasql)

        # Other

        dw = RadioSetting("settings.dw", "Dual watch",
                          RadioSettingValueBoolean(_mem.settings.dw))
        other.append(dw)

        cpuclk = RadioSetting(
            "settings.cpuclk", "CPU clock frequency",
            RadioSettingValueList(LIST_CPUCLK,
                                  LIST_CPUCLK[_mem.settings.cpuclk]))
        other.append(cpuclk)

        def _filter(name):
            filtered = ""
            for char in str(name):
                if char in VALID_CHARS:
                    filtered += char
                else:
                    filtered += " "
            return filtered

        line16 = RadioSetting(
            "poweron_msg.line16", "Power-on message",
            RadioSettingValueString(0, 16, _filter(_mem.poweron_msg.line16)))
        other.append(line16)

        line32 = RadioSetting(
            "embedded_msg.line32", "Embedded message",
            RadioSettingValueString(0, 32, _filter(_mem.embedded_msg.line32)))
        other.append(line32)

        # Work

        workmoda = RadioSetting(
            "settings.workmoda", "Work mode A",
            RadioSettingValueList(LIST_WORK,
                                  LIST_WORK[_mem.settings.workmoda]))
        work.append(workmoda)

        workmodb = RadioSetting(
            "settings.workmodb", "Work mode B",
            RadioSettingValueList(LIST_WORK,
                                  LIST_WORK[_mem.settings.workmodb]))
        work.append(workmodb)

        wbanda = RadioSetting(
            "settings.wbanda", "Work band A",
            RadioSettingValueList(LIST_WBANDA,
                                  LIST_WBANDA[(_mem.settings.wbanda) - 1]))
        work.append(wbanda)

        wbandb = RadioSetting(
            "settings.wbandb", "Work band B",
            RadioSettingValueList(LIST_WBANDB,
                                  LIST_WBANDB[(_mem.settings.wbandb) - 4]))
        work.append(wbandb)

        sqla = RadioSetting(
            "settings.sqla", "Squelch A",
            RadioSettingValueList(LIST_SQL, LIST_SQL[_mem.settings.sqla]))
        work.append(sqla)

        sqlb = RadioSetting(
            "settings.sqlb", "Squelch B",
            RadioSettingValueList(LIST_SQL, LIST_SQL[_mem.settings.sqlb]))
        work.append(sqlb)

        stepa = RadioSetting(
            "settings.stepa", "Auto step A",
            RadioSettingValueList(LIST_STEP, LIST_STEP[_mem.settings.stepa]))
        work.append(stepa)

        stepb = RadioSetting(
            "settings.stepb", "Auto step B",
            RadioSettingValueList(LIST_STEP, LIST_STEP[_mem.settings.stepb]))
        work.append(stepb)

        mrcha = RadioSetting(
            "settings.mrcha", "Current channel A",
            RadioSettingValueInteger(0, 499, _mem.settings.mrcha))
        work.append(mrcha)

        mrchb = RadioSetting(
            "settings.mrchb", "Current channel B",
            RadioSettingValueInteger(0, 499, _mem.settings.mrchb))
        work.append(mrchb)

        val = _mem.settings.offseta / 100.00
        offseta = RadioSetting("settings.offseta", "Offset A (0-37.95)",
                               RadioSettingValueFloat(0, 38.00, val, 0.05, 2))
        work.append(offseta)

        val = _mem.settings.offsetb / 100.00
        offsetb = RadioSetting("settings.offsetb", "Offset B (0-79.95)",
                               RadioSettingValueFloat(0, 80.00, val, 0.05, 2))
        work.append(offsetb)

        wpricha = RadioSetting(
            "settings.wpricha", "Priority channel A",
            RadioSettingValueInteger(0, 499, _mem.settings.wpricha))
        work.append(wpricha)

        wprichb = RadioSetting(
            "settings.wprichb", "Priority channel B",
            RadioSettingValueInteger(0, 499, _mem.settings.wprichb))
        work.append(wprichb)

        smode = RadioSetting(
            "settings.smode", "Smart function mode",
            RadioSettingValueList(LIST_SMODE, LIST_SMODE[_mem.settings.smode]))
        work.append(smode)

        # dtmf

        ttdkey = RadioSetting(
            "dtmf.ttdkey", "D key function",
            RadioSettingValueList(LIST_TTDKEY, LIST_TTDKEY[_mem.dtmf.ttdkey]))
        dtmf.append(ttdkey)

        ttdgt = RadioSetting(
            "dtmf.ttdgt", "Digit time",
            RadioSettingValueList(LIST_TT200,
                                  LIST_TT200[(_mem.dtmf.ttdgt) - 5]))
        dtmf.append(ttdgt)

        ttint = RadioSetting(
            "dtmf.ttint", "Interval time",
            RadioSettingValueList(LIST_TT200,
                                  LIST_TT200[(_mem.dtmf.ttint) - 5]))
        dtmf.append(ttint)

        tt1stdgt = RadioSetting(
            "dtmf.tt1stdgt", "1st digit time",
            RadioSettingValueList(LIST_TT200,
                                  LIST_TT200[(_mem.dtmf.tt1stdgt) - 5]))
        dtmf.append(tt1stdgt)

        tt1stdly = RadioSetting(
            "dtmf.tt1stdly", "1st digit delay time",
            RadioSettingValueList(LIST_TT1000,
                                  LIST_TT1000[(_mem.dtmf.tt1stdly) - 2]))
        dtmf.append(tt1stdly)

        ttdlyqt = RadioSetting(
            "dtmf.ttdlyqt", "Digit delay when use qt",
            RadioSettingValueList(LIST_TT1000,
                                  LIST_TT1000[(_mem.dtmf.ttdlyqt) - 2]))
        dtmf.append(ttdlyqt)

        ttsig = RadioSetting(
            "dtmf2.ttsig", "Signal",
            RadioSettingValueList(LIST_TTSIG, LIST_TTSIG[_mem.dtmf2.ttsig]))
        dtmf.append(ttsig)

        ttautorst = RadioSetting(
            "dtmf2.ttautorst", "Auto reset time",
            RadioSettingValueList(LIST_TTAUTORST,
                                  LIST_TTAUTORST[_mem.dtmf2.ttautorst]))
        dtmf.append(ttautorst)

        if _mem.dtmf2.ttgrpcode > 0x06:
            val = 0x00
        else:
            val = _mem.dtmf2.ttgrpcode
        ttgrpcode = RadioSetting(
            "dtmf2.ttgrpcode", "Group code",
            RadioSettingValueList(LIST_TTGRPCODE, LIST_TTGRPCODE[val]))
        dtmf.append(ttgrpcode)

        ttintcode = RadioSetting(
            "dtmf2.ttintcode", "Interval code",
            RadioSettingValueList(LIST_TTINTCODE,
                                  LIST_TTINTCODE[_mem.dtmf2.ttintcode]))
        dtmf.append(ttintcode)

        if _mem.dtmf2.ttalert > 0x04:
            val = 0x00
        else:
            val = _mem.dtmf2.ttalert
        ttalert = RadioSetting(
            "dtmf2.ttalert", "Alert tone/transpond",
            RadioSettingValueList(LIST_TTALERT, LIST_TTALERT[val]))
        dtmf.append(ttalert)

        ttautod = RadioSetting(
            "dtmf.ttautod", "Auto dial group",
            RadioSettingValueList(LIST_TTAUTOD,
                                  LIST_TTAUTOD[_mem.dtmf.ttautod]))
        dtmf.append(ttautod)

        # setup 9 dtmf autodial entries
        for i in map(str, range(1, 10)):
            objname = "code" + i
            strname = "Code " + str(i)
            dtmfsetting = getattr(_mem.dtmfcode, objname)
            dtmflen = getattr(_mem.dtmfcode, objname + "_len")
            dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
            code = RadioSettingValueString(0, 16, dtmfstr)
            code.set_charset(DTMF_CHARS + list(" "))
            rs = RadioSetting("dtmfcode." + objname, strname, code)
            dtmf.append(rs)
        return top
Beispiel #4
0
    def get_settings(self):
        """Translate the MEM_FORMAT structs into settings in the UI"""
        # Define mem struct write-back shortcuts
        _sets = self._memobj.settings
        _asf = self._memobj.asf
        _ssf = self._memobj.ssf
        _mex = self._memobj.exset
        _chm = self._memobj.ch_mem
        basic = RadioSettingGroup("basic", "Basic Settings")
        pvfo = RadioSettingGroup("pvfo", "VFO Band Edges")
        mena = RadioSettingGroup("mena", "Menu A")
        menb = RadioSettingGroup("menb", "Menu B")
        amode = RadioSettingGroup("amode", "Auto Mode")
        ssc = RadioSettingGroup("ssc", "Slow Scan")
        group = RadioSettings(basic, pvfo, mena, menb, amode, ssc)

        mhz1 = 1000000.

        # Callback functions
        def _my_readonly(setting, obj, atrb):
            """NOP callback, prevents writing the setting"""
            vx = 0
            return

        def my_adjraw(setting, obj, atrb, fix=0, ndx=-1):
            """Callback for Integer add or subtract fix from value."""
            vx = int(str(setting.value))
            value = vx + int(fix)
            if value < 0:
                value = 0
            if ndx < 0:
                setattr(obj, atrb, value)
            else:
                setattr(obj[ndx], atrb, value)
            return

        def my_mhz_val(setting, obj, atrb, ndx=-1):
            """ Callback to set freq back to Htz"""
            vx = float(str(setting.value))
            vx = int(vx * mhz1)
            if ndx < 0:
                setattr(obj, atrb, vx)
            else:
                setattr(obj[ndx], atrb, vx)
            return

        def my_bool(setting, obj, atrb, ndx=-1):
            """ Callback to properly set boolean """
            # set_settings is not setting [indexed] booleans???
            vx = 0
            if str(setting.value) == "True":
                vx = 1
            if ndx < 0:
                setattr(obj, atrb, vx)
            else:
                setattr(obj[ndx], atrb, vx)
            return

        def my_asf_mode(setting, obj, nx=0):
            """ Callback to extract mode and create asmode, asdata """
            v1 = TS480_MODES.index(str(setting.value))
            v2 = 0  # asdata
            vx = v1 + 1  # stored as CAT values, same as xmode
            if v1 == 7:
                vx = 9
            if v1 > 7:  # a Data mode
                v2 = 1
                if v1 == 8:
                    vx = 1  # LSB
                elif v1 == 9:
                    vx = 2  # USB
                elif v1 == 10:
                    vx = 4  # FM
            setattr(obj[nx], "asdata", v2)
            setattr(obj[nx], "asmode", vx)
            return

        def my_fnctns(setting, obj, ndx, atrb):
            """ Filter only valid key function assignments """
            vx = int(str(setting.value))
            if vx > 79:
                vx = 99  # Off
            setattr(obj[ndx], atrb, vx)
            return

        def my_labels(kx):
            lbl = "%03i:" % kx  # SG EX number
            lbl += self.EX_LBL[kx]  # and the label to match
            return lbl

        # ===== BASIC GROUP =====

        options = [
            "TS-480HX (200W)", "TS-480SAT (100W + AT)", "Japanese 50W type",
            "Japanese 20W type"
        ]
        rx = RadioSettingValueString(14, 22, options[_sets.ty])
        rset = RadioSetting("settings.ty", "FirmwareVersion", rx)
        rset.set_apply_callback(_my_readonly, _sets, "ty")
        basic.append(rset)

        rx = RadioSettingValueInteger(0, 255, _sets.ag)
        rset = RadioSetting("settings.ag", "AF Gain", rx)
        #  rset.set_apply_callback(my_adjraw, _sets, "ag", -1)
        basic.append(rset)

        rx = RadioSettingValueInteger(0, 100, _sets.rg)
        rset = RadioSetting("settings.rg", "RF Gain", rx)
        #   rset.set_apply_callback(my_adjraw, _sets, "rg", -1)
        basic.append(rset)

        options = ["ANT1", "ANT2"]
        # CAUTION: an has value of 1 or 2
        rx = RadioSettingValueList(options, options[_sets.an - 1])
        rset = RadioSetting("settings.an", "Antenna Selected", rx)
        # Add 1 to the changed value. S/b 1/2
        rset.set_apply_callback(my_val_list, options, _sets, "an", 1)
        basic.append(rset)

        rx = RadioSettingValueInteger(0, 100, _sets.mg)
        rset = RadioSetting("settings.mg", "Microphone gain", rx)
        basic.append(rset)

        nx = 5  # Coarse step
        if bool(_mex[0].ex021):  # Power Fine enabled in menu A
            nx = 1
        vx = _sets.pc  # Trap invalid values from run_tests.py
        if vx < 5:
            vx = 5
        options = [200, 100, 50, 20]  # subject to firmware
        rx = RadioSettingValueInteger(5, options[_sets.ty], vx, nx)
        sx = "TX Output power (Watts)"
        rset = RadioSetting("settings.pc", sx, rx)
        basic.append(rset)

        val = _sets.fa / mhz1  # valid range is for receiver
        rx = RadioSettingValueFloat(0.05, 60.0, val, 0.001, 3)
        sx = "VFO-A Frequency (MHz)"
        rset = RadioSetting("settings.fa", sx, rx)
        rset.set_apply_callback(my_mhz_val, _sets, "fa")
        basic.append(rset)

        val = _sets.fb / mhz1
        rx = RadioSettingValueFloat(0.05, 60.0, val, 0.001, 3)
        sx = "VFO-B Frequency (MHz)"
        rset = RadioSetting("settings.fb", sx, rx)
        rset.set_apply_callback(my_mhz_val, _sets, "fb")
        basic.append(rset)

        options = ["Menu A", "Menu B"]
        rx = RadioSettingValueList(options, options[_sets.mf])
        sx = "Menu Selected"
        rset = RadioSetting("settings.mf", sx, rx)
        rset.set_apply_callback(my_val_list, options, _sets, "mf")
        basic.append(rset)

        # ==== VFO Edges Group ================

        for mx in range(100, 110):
            val = _chm[mx].rxfreq / mhz1
            if val < 1.8:  # Many operators never use this
                val = 1.8  # So default is 0.0
            rx = RadioSettingValueFloat(1.8, 54.0, val, 0.001, 3)
            sx = "VFO-Band %i lower limit (MHz)" % (mx - 100)
            rset = RadioSetting("ch_mem.rxfreq/%d" % mx, sx, rx)
            rset.set_apply_callback(my_mhz_val, _chm, "rxfreq", mx)
            pvfo.append(rset)

            val = _chm[mx].txfreq / mhz1
            if val < 1.8:
                val = 54.0
            rx = RadioSettingValueFloat(1.8, 54.0, val, 0.001, 3)
            sx = "    VFO-Band %i upper limit (MHz)" % (mx - 100)
            rset = RadioSetting("ch_mem.txfreq/%d" % mx, sx, rx)
            rset.set_apply_callback(my_mhz_val, _chm, "txfreq", mx)
            pvfo.append(rset)

            kx = _chm[mx].xmode
            options = [
                "None", "LSB", "USB", "CW", "FM", "AM", "FSK", "CW-R", "N/A",
                "FSK-R"
            ]
            rx = RadioSettingValueList(options, options[kx])
            sx = "    VFO-Band %i Tx/Rx Mode" % (mx - 100)
            rset = RadioSetting("ch_mem.xmode/%d" % mx, sx, rx)
            rset.set_apply_callback(my_val_list, options, _chm, "xmode", 0, mx)
            pvfo.append(rset)

        # ==== Menu A/B Group =================

        for mx in range(2):  # A/B index
            sx = my_labels(0)
            rx = RadioSettingValueInteger(0, 4, _mex[mx].ex000)
            rset = RadioSetting("exset.ex000", sx, rx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueInteger(0, 9, _mex[mx].ex012)
            sx = my_labels(12)
            rset = RadioSetting("exset.ex012", sx, rx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            sx = my_labels(13)
            rx = RadioSettingValueInteger(0, 9, _mex[mx].ex013)
            rset = RadioSetting("exset.ex013", sx, rx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            sx = my_labels(14)
            rx = RadioSettingValueInteger(0, 9, _mex[mx].ex014)
            rset = RadioSetting("exset.ex014", sx, rx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            options = ["250", "500", "1000"]
            rx = RadioSettingValueList(options, options[_mex[mx].ex003])
            sx = my_labels(3)
            rset = RadioSetting("exset.ex003/%d" % mx, sx, rx)
            rset.set_apply_callback(my_val_list, options, _mex, "ex003", 0, mx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueBoolean(bool(_mex[mx].ex007))
            sx = my_labels(7)
            rset = RadioSetting("exset.ex007/%d" % mx, sx, rx)
            rset.set_apply_callback(my_bool, _mex, "ex007", mx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueBoolean(bool(_mex[mx].ex008))
            sx = my_labels(8)
            rset = RadioSetting("exset.ex008/%d" % mx, sx, rx)
            rset.set_apply_callback(my_bool, _mex, "ex008", mx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            options = ["100", "200", "300", "400", "500"]
            rx = RadioSettingValueList(options, options[_mex[mx].ex009])
            sx = my_labels(9)
            rset = RadioSetting("exset.ex009/%d" % mx, sx, rx)
            rset.set_apply_callback(my_val_list, options, _mex, "ex009", 0, mx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueBoolean(bool(_mex[mx].ex010))
            sx = my_labels(10)
            rset = RadioSetting("exset.ex010/%d" % mx, sx, rx)
            rset.set_apply_callback(my_bool, _mex, "ex010", mx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            options = ["TO", "CO"]
            rx = RadioSettingValueList(options, options[_mex[mx].ex011])
            sx = my_labels(11)
            rset = RadioSetting("exset.ex011/%d" % mx, sx, rx)
            rset.set_apply_callback(my_val_list, options, _mex, "ex011", 0, mx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueBoolean(bool(_mex[mx].ex021))
            sx = my_labels(21)
            rset = RadioSetting("exset.ex021/%d" % mx, sx, rx)
            rset.set_apply_callback(my_bool, _mex, "ex021", mx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            options = ["Off", "3", "5", "10", "20", "30"]
            rx = RadioSettingValueList(options, options[_mex[mx].ex022])
            sx = my_labels(22)
            rset = RadioSetting("exset.ex022/%d" % mx, sx, rx)
            rset.set_apply_callback(my_val_list, options, _mex, "ex022", 0, mx)
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueInteger(0, 99, _mex[mx].ex048)
            sx = my_labels(48)
            rset = RadioSetting("exset.ex048/%d" % mx, sx, rx)
            rset.set_apply_callback(my_fnctns, _mex, mx, "ex048")
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueInteger(0, 99, _mex[mx].ex049)
            sx = my_labels(49)
            rset = RadioSetting("exset.ex049/%d" % mx, sx, rx)
            rset.set_apply_callback(my_fnctns, _mex, mx, "ex049")
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueInteger(0, 99, _mex[mx].ex050)
            sx = my_labels(50)
            rset = RadioSetting("exset.ex050/%d" % mx, sx, rx)
            rset.set_apply_callback(my_fnctns, _mex, mx, "ex050")
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueInteger(0, 99, _mex[mx].ex051)
            sx = my_labels(51)
            rset = RadioSetting("exset.ex051/%d" % mx, sx, rx)
            rset.set_apply_callback(my_fnctns, _mex, mx, "ex051")
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)

            rx = RadioSettingValueInteger(0, 99, _mex[mx].ex052)
            sx = my_labels(52)
            rset = RadioSetting("exset.ex052/%d" % mx, sx, rx)
            rset.set_apply_callback(my_fnctns, _mex, mx, "ex052")
            if mx == 0:
                mena.append(rset)
            else:
                menb.append(rset)
        # End of for mx loop

        # ==== Auto Scan Params (amode) ==============
        for ix in range(32):
            val = _asf[ix].asfreq / mhz1
            rx = RadioSettingValueFloat(0.03, 60.0, val, 0.001, 3)
            rset = RadioSetting("asf.asfreq/%d" % ix,
                                "Scan %02i Freq (MHz)" % ix, rx)
            rset.set_apply_callback(my_mhz_val, _asf, "asfreq", ix)
            amode.append(rset)

            mx = _asf[ix].asmode - 1  # Same logic as xmode
            if _asf[ix].asmode == 9:
                mx = 7
            rx = RadioSettingValueList(TS480_MODES, TS480_MODES[mx])
            rset = RadioSetting("asf.asmode/%d" % ix, "   Mode", rx)
            rset.set_apply_callback(my_asf_mode, _asf, ix)
            amode.append(rset)

        # ==== Slow Scan Settings ===
        for ix in range(10):  # Chans
            for nx in range(5):  # spots
                px = ((ix * 5) + nx)
                val = _ssf[px].ssfreq / mhz1
                stx = "      -   -   -    Slot %02i Freq (MHz)" % nx
                if nx == 0:
                    stx = "Slow Scan %02i, Slot 0 Freq (MHz" % ix
                rx = RadioSettingValueFloat(0, 54.0, val, 0.001, 3)
                rset = RadioSetting("ssf.ssfreq/%d" % px, stx, rx)
                rset.set_apply_callback(my_mhz_val, _ssf, "ssfreq", px)
                ssc.append(rset)

        return group  # END get_settings()
Beispiel #5
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")

        group = RadioSettings(basic)

        options = ["Time", "Carrier", "Search"]
        rs = RadioSetting(
            "scantype", "Scan Type",
            RadioSettingValueList(options, options[_settings.scantype]))
        basic.append(rs)

        options = ["Off"] + ["%s min" % x for x in range(1, 8)]
        rs = RadioSetting(
            "timeout", "Time Out Timer",
            RadioSettingValueList(options, options[_settings.timeout]))
        basic.append(rs)

        options = ["A", "B"]
        rs = RadioSetting(
            "freqmode_ab", "Frequency Mode",
            RadioSettingValueList(options, options[_settings.freqmode_ab]))
        basic.append(rs)

        options = ["Frequency Mode", "Channel Mode"]
        rs = RadioSetting(
            "workmode_a", "Radio Work Mode(A)",
            RadioSettingValueList(options, options[_settings.workmode_a]))
        basic.append(rs)

        rs = RadioSetting(
            "workmode_b", "Radio Work Mode(B)",
            RadioSettingValueList(options, options[_settings.workmode_b]))
        basic.append(rs)

        options = ["Frequency", "Name", "Channel"]
        rs = RadioSetting(
            "mdf_a", "Display Format(F1)",
            RadioSettingValueList(options, options[_settings.mdf_a]))
        basic.append(rs)

        rs = RadioSetting(
            "mdf_b", "Display Format(F2)",
            RadioSettingValueList(options, options[_settings.mdf_b]))
        basic.append(rs)

        rs = RadioSetting(
            "mem_chan_a", "Mem Channel (A)",
            RadioSettingValueInteger(1, 99, _settings.mem_chan_a))
        basic.append(rs)

        rs = RadioSetting(
            "mem_chan_b", "Mem Channel (B)",
            RadioSettingValueInteger(1, 99, _settings.mem_chan_b))
        basic.append(rs)

        options = ["Off", "BOT", "EOT", "Both"]
        rs = RadioSetting(
            "pttid", "PTT-ID",
            RadioSettingValueList(options, options[_settings.pttid]))
        basic.append(rs)

        dtmfchars = "0123456789ABCD*#"
        _codeobj = self._memobj.pttid.code
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 6, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("pttid.code", "PTT-ID Code", val)

        def apply_code(setting, obj):
            code = []
            for j in range(0, 6):
                try:
                    code.append(dtmfchars.index(str(setting.value)[j]))
                except IndexError:
                    code.append(0xFF)
            obj.code = code

        rs.set_apply_callback(apply_code, self._memobj.pttid)
        basic.append(rs)

        rs = RadioSetting("squelch", "Squelch Level",
                          RadioSettingValueInteger(0, 9, _settings.squelch))
        basic.append(rs)

        rs = RadioSetting("vox", "VOX Level",
                          RadioSettingValueInteger(0, 9, _settings.vox))
        basic.append(rs)

        options = ["Frequency Mode", "Channel Mode"]
        rs = RadioSetting(
            "workmode_fm", "FM Work Mode",
            RadioSettingValueList(options, options[_settings.workmode_fm]))
        basic.append(rs)

        options = ["Current Frequency", "F1 Frequency", "F2 Frequency"]
        rs = RadioSetting(
            "txtdr", "Dual Standby TX Priority",
            RadioSettingValueList(options, options[_settings.txtdr]))
        basic.append(rs)

        options = ["English", "Chinese"]
        rs = RadioSetting(
            "language", "Language",
            RadioSettingValueList(options, options[_settings.language]))
        basic.append(rs)

        rs = RadioSetting("tdr", "Dual Standby",
                          RadioSettingValueBoolean(_settings.tdr))
        basic.append(rs)

        rs = RadioSetting("roger", "Roger Beep",
                          RadioSettingValueBoolean(_settings.roger))
        basic.append(rs)

        rs = RadioSetting("backlight", "Backlight",
                          RadioSettingValueBoolean(_settings.backlight))
        basic.append(rs)

        rs = RadioSetting("save_funct", "Save Mode",
                          RadioSettingValueBoolean(_settings.save_funct))
        basic.append(rs)

        rs = RadioSetting("fm", "FM Function",
                          RadioSettingValueBoolean(_settings.fm))
        basic.append(rs)

        rs = RadioSetting(
            "beep_tone_disabled", "Beep Prompt",
            RadioSettingValueBoolean(not _settings.beep_tone_disabled))
        basic.append(rs)

        rs = RadioSetting("voice_prompt", "Voice Prompt",
                          RadioSettingValueBoolean(_settings.voice_prompt))
        basic.append(rs)

        rs = RadioSetting("sidetone", "DTMF Side Tone",
                          RadioSettingValueBoolean(_settings.sidetone))
        basic.append(rs)

        rs = RadioSetting("ste_disabled", "Squelch Tail Eliminate",
                          RadioSettingValueBoolean(not _settings.ste_disabled))
        basic.append(rs)

        _limit = int(self._memobj.limits.lower_vhf) / 10
        rs = RadioSetting("limits.lower_vhf", "VHF Lower Limit (MHz)",
                          RadioSettingValueInteger(128, 270, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.lower_vhf = value

        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        _limit = int(self._memobj.limits.upper_vhf) / 10
        rs = RadioSetting("limits.upper_vhf", "VHF Upper Limit (MHz)",
                          RadioSettingValueInteger(128, 270, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.upper_vhf = value

        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        _limit = int(self._memobj.limits.lower_uhf) / 10
        rs = RadioSetting("limits.lower_uhf", "UHF Lower Limit (MHz)",
                          RadioSettingValueInteger(400, 520, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.lower_uhf = value

        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        _limit = int(self._memobj.limits.upper_uhf) / 10
        rs = RadioSetting("limits.upper_uhf", "UHF Upper Limit (MHz)",
                          RadioSettingValueInteger(400, 520, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.upper_uhf = value

        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        fm_preset = RadioSettingGroup("fm_preset", "FM Radio Presets")
        group.append(fm_preset)

        for i in range(0, 16):
            if self._memobj.fm_presets[i] < 0x01AF:
                used = True
                preset = self._memobj.fm_presets[i] / 10.0 + 65
            else:
                used = False
                preset = 65
            rs = RadioSetting("fm_presets_%1i" % i, "FM Preset %i" % (i + 1),
                              RadioSettingValueBoolean(used),
                              RadioSettingValueFloat(65, 108, preset, 0.1, 1))
            fm_preset.append(rs)

        testmode = RadioSettingGroup("testmode", "Test Mode Settings")
        group.append(testmode)

        vhfdata = [
            "136-139", "140-144", "145-149", "150-154", "155-159", "160-164",
            "165-169", "170-174"
        ]
        uhfdata = [
            "400-409", "410-419", "420-429", "430-439", "440-449", "450-459",
            "460-469", "470-479"
        ]
        powernamedata = ["Hi", "Lo"]
        powerkeydata = ["hipwr", "lopwr"]

        for power in range(0, 2):
            for index in range(0, 8):
                key = "test.vhf%s%i" % (powerkeydata[power], index)
                name = "%s Mhz %s Power" % (vhfdata[index],
                                            powernamedata[power])
                rs = RadioSetting(
                    key, name,
                    RadioSettingValueInteger(
                        0, 255,
                        getattr(self._memobj.test,
                                "vhf%s%i" % (powerkeydata[power], index))))
                testmode.append(rs)

        for power in range(0, 2):
            for index in range(0, 8):
                key = "test.uhf%s%i" % (powerkeydata[power], index)
                name = "%s Mhz %s Power" % (uhfdata[index],
                                            powernamedata[power])
                rs = RadioSetting(
                    key, name,
                    RadioSettingValueInteger(
                        0, 255,
                        getattr(self._memobj.test,
                                "uhf%s%i" % (powerkeydata[power], index))))
                testmode.append(rs)

        for band in ["vhf", "uhf"]:
            for index in range(0, 10):
                key = "test.%ssquelch%i" % (band, index)
                name = "%s Squelch %i" % (band.upper(), index)
                rs = RadioSetting(
                    key, name,
                    RadioSettingValueInteger(
                        0, 255,
                        getattr(self._memobj.test,
                                "%ssquelch%i" % (band, index))))
                testmode.append(rs)

        return group
Beispiel #6
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")

        group = RadioSettings(basic)

        options = ["Time", "Carrier", "Search"]
        rs = RadioSetting("scantype", "Scan Type",
                          RadioSettingValueList(options,
                                                options[_settings.scantype]))
        basic.append(rs)

        options = ["Off"] + ["%s min" % x for x in range(1, 8)]
        rs = RadioSetting("timeout", "Time Out Timer",
                          RadioSettingValueList(
                              options, options[_settings.timeout]))
        basic.append(rs)

        options = ["A", "B"]
        rs = RadioSetting("freqmode_ab", "Frequency Mode",
                          RadioSettingValueList(
                              options, options[_settings.freqmode_ab]))
        basic.append(rs)

        options = ["Frequency Mode", "Channel Mode"]
        rs = RadioSetting("workmode_a", "Radio Work Mode(A)",
                          RadioSettingValueList(
                              options, options[_settings.workmode_a]))
        basic.append(rs)

        rs = RadioSetting("workmode_b", "Radio Work Mode(B)",
                          RadioSettingValueList(
                              options, options[_settings.workmode_b]))
        basic.append(rs)

        options = ["Frequency", "Name", "Channel"]
        rs = RadioSetting("mdf_a", "Display Format(F1)",
                          RadioSettingValueList(
                              options, options[_settings.mdf_a]))
        basic.append(rs)

        rs = RadioSetting("mdf_b", "Display Format(F2)",
                          RadioSettingValueList(
                              options, options[_settings.mdf_b]))
        basic.append(rs)

        rs = RadioSetting("mem_chan_a", "Mem Channel (A)",
                          RadioSettingValueInteger(
                              1, 99, _settings.mem_chan_a))
        basic.append(rs)

        rs = RadioSetting("mem_chan_b", "Mem Channel (B)",
                          RadioSettingValueInteger(
                              1, 99, _settings.mem_chan_b))
        basic.append(rs)

        options = ["Off", "BOT", "EOT", "Both"]
        rs = RadioSetting("pttid", "PTT-ID",
                          RadioSettingValueList(
                              options, options[_settings.pttid]))
        basic.append(rs)

        dtmfchars = "0123456789ABCD*#"
        _codeobj = self._memobj.pttid.code
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 6, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("pttid.code", "PTT-ID Code", val)

        def apply_code(setting, obj):
            code = []
            for j in range(0, 6):
                try:
                    code.append(dtmfchars.index(str(setting.value)[j]))
                except IndexError:
                    code.append(0xFF)
            obj.code = code
        rs.set_apply_callback(apply_code, self._memobj.pttid)
        basic.append(rs)

        rs = RadioSetting("squelch", "Squelch Level",
                          RadioSettingValueInteger(0, 9, _settings.squelch))
        basic.append(rs)

        rs = RadioSetting("vox", "VOX Level",
                          RadioSettingValueInteger(0, 9, _settings.vox))
        basic.append(rs)

        options = ["Frequency Mode", "Channel Mode"]
        rs = RadioSetting("workmode_fm", "FM Work Mode",
                          RadioSettingValueList(
                              options, options[_settings.workmode_fm]))
        basic.append(rs)

        options = ["Current Frequency", "F1 Frequency", "F2 Frequency"]
        rs = RadioSetting("txtdr", "Dual Standby TX Priority",
                          RadioSettingValueList(options,
                                                options[_settings.txtdr]))
        basic.append(rs)

        options = ["English", "Chinese"]
        rs = RadioSetting("language", "Language",
                          RadioSettingValueList(options,
                                                options[_settings.language]))
        basic.append(rs)

        rs = RadioSetting("tdr", "Dual Standby",
                          RadioSettingValueBoolean(_settings.tdr))
        basic.append(rs)

        rs = RadioSetting("roger", "Roger Beep",
                          RadioSettingValueBoolean(_settings.roger))
        basic.append(rs)

        rs = RadioSetting("backlight", "Backlight",
                          RadioSettingValueBoolean(_settings.backlight))
        basic.append(rs)

        rs = RadioSetting("save_funct", "Save Mode",
                          RadioSettingValueBoolean(_settings.save_funct))
        basic.append(rs)

        rs = RadioSetting("fm", "FM Function",
                          RadioSettingValueBoolean(_settings.fm))
        basic.append(rs)

        rs = RadioSetting("beep_tone_disabled", "Beep Prompt",
                          RadioSettingValueBoolean(
                              not _settings.beep_tone_disabled))
        basic.append(rs)

        rs = RadioSetting("voice_prompt", "Voice Prompt",
                          RadioSettingValueBoolean(_settings.voice_prompt))
        basic.append(rs)

        rs = RadioSetting("sidetone", "DTMF Side Tone",
                          RadioSettingValueBoolean(_settings.sidetone))
        basic.append(rs)

        rs = RadioSetting("ste_disabled", "Squelch Tail Eliminate",
                          RadioSettingValueBoolean(not _settings.ste_disabled))
        basic.append(rs)

        _limit = int(self._memobj.limits.lower_vhf) / 10
        rs = RadioSetting("limits.lower_vhf", "VHF Lower Limit (MHz)",
                          RadioSettingValueInteger(128, 270, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.lower_vhf = value
        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        _limit = int(self._memobj.limits.upper_vhf) / 10
        rs = RadioSetting("limits.upper_vhf", "VHF Upper Limit (MHz)",
                          RadioSettingValueInteger(128, 270, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.upper_vhf = value
        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        _limit = int(self._memobj.limits.lower_uhf) / 10
        rs = RadioSetting("limits.lower_uhf", "UHF Lower Limit (MHz)",
                          RadioSettingValueInteger(400, 520, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.lower_uhf = value
        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        _limit = int(self._memobj.limits.upper_uhf) / 10
        rs = RadioSetting("limits.upper_uhf", "UHF Upper Limit (MHz)",
                          RadioSettingValueInteger(400, 520, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.upper_uhf = value
        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        fm_preset = RadioSettingGroup("fm_preset", "FM Radio Presets")
        group.append(fm_preset)

        for i in range(0, 16):
            if self._memobj.fm_presets[i] < 0x01AF:
                used = True
                preset = self._memobj.fm_presets[i] / 10.0 + 65
            else:
                used = False
                preset = 65
            rs = RadioSetting("fm_presets_%1i" % i, "FM Preset %i" % (i + 1),
                              RadioSettingValueBoolean(used),
                              RadioSettingValueFloat(65, 108, preset, 0.1, 1))
            fm_preset.append(rs)

        testmode = RadioSettingGroup("testmode", "Test Mode Settings")
        group.append(testmode)

        vhfdata = ["136-139", "140-144", "145-149", "150-154",
                   "155-159", "160-164", "165-169", "170-174"]
        uhfdata = ["400-409", "410-419", "420-429", "430-439",
                   "440-449", "450-459", "460-469", "470-479"]
        powernamedata = ["Hi", "Lo"]
        powerkeydata = ["hipwr", "lopwr"]

        for power in range(0, 2):
            for index in range(0, 8):
                key = "test.vhf%s%i" % (powerkeydata[power], index)
                name = "%s Mhz %s Power" % (vhfdata[index],
                                            powernamedata[power])
                rs = RadioSetting(
                        key, name, RadioSettingValueInteger(
                            0, 255, getattr(
                                self._memobj.test,
                                "vhf%s%i" % (powerkeydata[power], index))))
                testmode.append(rs)

        for power in range(0, 2):
            for index in range(0, 8):
                key = "test.uhf%s%i" % (powerkeydata[power], index)
                name = "%s Mhz %s Power" % (uhfdata[index],
                                            powernamedata[power])
                rs = RadioSetting(
                        key, name, RadioSettingValueInteger(
                            0, 255, getattr(
                                self._memobj.test,
                                "uhf%s%i" % (powerkeydata[power], index))))
                testmode.append(rs)

        for band in ["vhf", "uhf"]:
            for index in range(0, 10):
                key = "test.%ssquelch%i" % (band, index)
                name = "%s Squelch %i" % (band.upper(), index)
                rs = RadioSetting(
                        key, name, RadioSettingValueInteger(
                            0, 255, getattr(
                                self._memobj.test,
                                "%ssquelch%i" % (band, index))))
                testmode.append(rs)

        return group
Beispiel #7
0
    def _get_settings(self):
        _settings = self._memobj.settings
        _vfoa = self._memobj.vfoa
        _vfob = self._memobj.vfob
        cfg_grp = RadioSettingGroup("cfg_grp", "Configuration")
        vfoa_grp = RadioSettingGroup("vfoa_grp", "VFO A Settings")
        vfob_grp = RadioSettingGroup("vfob_grp", "VFO B Settings")
        key_grp = RadioSettingGroup("key_grp", "Key Settings")
        lmt_grp = RadioSettingGroup("lmt_grp", "Frequency Limits")
        uhf_lmt_grp = RadioSettingGroup("uhf_lmt_grp", "UHF")
        vhf_lmt_grp = RadioSettingGroup("vhf_lmt_grp", "VHF")
        vhf1_lmt_grp = RadioSettingGroup("vhf1_lmt_grp", "VHF1")
        oem_grp = RadioSettingGroup("oem_grp", "OEM Info")

        lmt_grp.append(vhf_lmt_grp);
        lmt_grp.append(vhf1_lmt_grp);
        lmt_grp.append(uhf_lmt_grp);
        group = RadioSettings(cfg_grp, vfoa_grp, vfob_grp,
                              key_grp, lmt_grp, oem_grp)

        #
        # Configuration Settings
        #
        rs = RadioSetting("channel_menu", "Menu available in channel mode",
                          RadioSettingValueBoolean(_settings.channel_menu))
        cfg_grp.append(rs)
        rs = RadioSetting("ponmsg", "Poweron message",
                          RadioSettingValueList(
                              PONMSG_LIST, PONMSG_LIST[_settings.ponmsg]))
        cfg_grp.append(rs)
        rs = RadioSetting("voice", "Voice Guide",
                          RadioSettingValueBoolean(_settings.voice))
        cfg_grp.append(rs)
        rs = RadioSetting("language", "Language",
                          RadioSettingValueList(LANGUAGE_LIST,
                                                LANGUAGE_LIST[_settings.
                                                              language]))
        cfg_grp.append(rs)
        rs = RadioSetting("timeout", "Timeout Timer",
                          RadioSettingValueList(
                              TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout]))
        cfg_grp.append(rs)
        rs = RadioSetting("toalarm", "Timeout Alarm",
                          RadioSettingValueInteger(0, 10, _settings.toalarm))
        cfg_grp.append(rs)
        rs = RadioSetting("roger_beep", "Roger Beep",
                          RadioSettingValueList(ROGER_LIST,
                                                ROGER_LIST[_settings.roger_beep]))
        cfg_grp.append(rs)
        rs = RadioSetting("power_save", "Power save",
                          RadioSettingValueBoolean(_settings.power_save))
        cfg_grp.append(rs)
        rs = RadioSetting("autolock", "Autolock",
                          RadioSettingValueBoolean(_settings.autolock))
        cfg_grp.append(rs)
        rs = RadioSetting("keylock", "Keypad Lock",
                          RadioSettingValueBoolean(_settings.keylock))
        cfg_grp.append(rs)
        rs = RadioSetting("beep", "Keypad Beep",
                          RadioSettingValueBoolean(_settings.beep))
        cfg_grp.append(rs)
        rs = RadioSetting("stopwatch", "Stopwatch",
                          RadioSettingValueBoolean(_settings.stopwatch))
        cfg_grp.append(rs)
        rs = RadioSetting("backlight", "Backlight",
                          RadioSettingValueList(BACKLIGHT_LIST,
                                                BACKLIGHT_LIST[_settings.
                                                               backlight]))
        cfg_grp.append(rs)
        rs = RadioSetting("dtmf_st", "DTMF Sidetone",
                          RadioSettingValueList(DTMFST_LIST,
                                                DTMFST_LIST[_settings.
                                                            dtmf_st]))
        cfg_grp.append(rs)
        rs = RadioSetting("ani_sw", "ANI-ID Switch",
                          RadioSettingValueBoolean(_settings.ani_sw))
        cfg_grp.append(rs)
        rs = RadioSetting("ptt_id", "PTT-ID Delay",
                          RadioSettingValueList(PTTID_LIST,
                                                PTTID_LIST[_settings.ptt_id]))
        cfg_grp.append(rs)
        rs = RadioSetting("ring_time", "Ring Time",
                          RadioSettingValueList(LIST_10,
                                                LIST_10[_settings.ring_time]))
        cfg_grp.append(rs)
        rs = RadioSetting("scan_rev", "Scan Mode",
                          RadioSettingValueList(SCANMODE_LIST,
                                                SCANMODE_LIST[_settings.
                                                              scan_rev]))
        cfg_grp.append(rs)
        rs = RadioSetting("vox", "VOX",
                          RadioSettingValueList(LIST_10,
                                                LIST_10[_settings.vox]))
        cfg_grp.append(rs)
        rs = RadioSetting("prich_sw", "Priority Channel Switch",
                          RadioSettingValueBoolean(_settings.prich_sw))
        cfg_grp.append(rs)
        rs = RadioSetting("pri_ch", "Priority Channel",
                          RadioSettingValueInteger(1, 999, _settings.pri_ch))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_mode", "Radio Mode",
                          RadioSettingValueList(RPTMODE_LIST,
                                                RPTMODE_LIST[_settings.
                                                             rpt_mode]))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_set", "Repeater Setting",
                          RadioSettingValueList(RPTSET_LIST,
                                                RPTSET_LIST[_settings.
                                                            rpt_set]))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_spk", "Repeater Mode Speaker",
                          RadioSettingValueBoolean(_settings.rpt_spk))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_ptt", "Repeater PTT",
                          RadioSettingValueBoolean(_settings.rpt_ptt))
        cfg_grp.append(rs)
        rs = RadioSetting("dtmf_tx_time", "DTMF Tx Duration",
                          RadioSettingValueList(DTMF_TIMES,
                                                DTMF_TIMES[_settings.
                                                           dtmf_tx_time]))
        cfg_grp.append(rs)
        rs = RadioSetting("dtmf_interval", "DTMF Interval",
                          RadioSettingValueList(DTMF_TIMES,
                                                DTMF_TIMES[_settings.
                                                           dtmf_interval]))
        cfg_grp.append(rs)
        rs = RadioSetting("alert", "Alert Tone",
                          RadioSettingValueList(ALERTS_LIST,
                                                ALERTS_LIST[_settings.alert]))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_tone", "Repeater Tone",
                          RadioSettingValueBoolean(_settings.rpt_tone))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_hold", "Repeater Hold Time",
                          RadioSettingValueList(HOLD_TIMES,
                                                HOLD_TIMES[_settings.
                                                           rpt_hold]))
        cfg_grp.append(rs)
        rs = RadioSetting("scan_det", "Scan DET",
                          RadioSettingValueBoolean(_settings.scan_det))
        cfg_grp.append(rs)
        rs = RadioSetting("sc_qt", "SC-QT",
                          RadioSettingValueList(SCQT_LIST,
                                                SCQT_LIST[_settings.sc_qt]))
        cfg_grp.append(rs)
        rs = RadioSetting("smuteset", "SubFreq Mute",
                          RadioSettingValueList(SMUTESET_LIST,
                                                SMUTESET_LIST[_settings.
                                                              smuteset]))
        cfg_grp.append(rs)

                #
        # VFO A Settings
        #
        rs = RadioSetting("workmode_a", "VFO A Workmode",
                          RadioSettingValueList(WORKMODE_LIST, WORKMODE_LIST[_settings.workmode_a]))
        vfoa_grp.append(rs)
        rs = RadioSetting("work_cha", "VFO A Channel",
                          RadioSettingValueInteger(1, 999, _settings.work_cha))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.rxfreq", "VFO A Rx Frequency",
                          RadioSettingValueInteger(
                              134000000, 520000000, _vfoa.rxfreq * 10, 5000))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.txoffset", "VFO A Tx Offset",
                          RadioSettingValueInteger(
                              0, 520000000, _vfoa.txoffset * 10, 5000))
        vfoa_grp.append(rs)
        #   u16   rxtone;
        #   u16   txtone;
        rs = RadioSetting("vfoa.power", "VFO A Power",
                          RadioSettingValueList(
                              POWER_LIST, POWER_LIST[_vfoa.power]))
        vfoa_grp.append(rs)
        #         shift_dir:2
        rs = RadioSetting("vfoa.iswide", "VFO A NBFM",
                          RadioSettingValueList(
                              BANDWIDTH_LIST, BANDWIDTH_LIST[_vfoa.iswide]))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.mute_mode", "VFO A Mute",
                          RadioSettingValueList(
                              SPMUTE_LIST, SPMUTE_LIST[_vfoa.mute_mode]))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.step", "VFO A Step (kHz)",
                          RadioSettingValueList(
                              STEP_LIST, STEP_LIST[_vfoa.step]))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.squelch", "VFO A Squelch",
                          RadioSettingValueList(
                              LIST_10, LIST_10[_vfoa.squelch]))
        vfoa_grp.append(rs)
        rs = RadioSetting("bcl_a", "Busy Channel Lock-out A",
                          RadioSettingValueBoolean(_settings.bcl_a))
        vfoa_grp.append(rs)

                #
        # VFO B Settings
        #
        rs = RadioSetting("workmode_b", "VFO B Workmode",
                          RadioSettingValueList(WORKMODE_LIST, WORKMODE_LIST[_settings.workmode_b]))
        vfob_grp.append(rs)
        rs = RadioSetting("work_chb", "VFO B Channel",
                          RadioSettingValueInteger(1, 999, _settings.work_chb))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.rxfreq", "VFO B Rx Frequency",
                          RadioSettingValueInteger(
                              134000000, 520000000, _vfob.rxfreq * 10, 5000))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.txoffset", "VFO B Tx Offset",
                          RadioSettingValueInteger(
                              0, 520000000, _vfob.txoffset * 10, 5000))
        vfob_grp.append(rs)
        #   u16   rxtone;
        #   u16   txtone;
        rs = RadioSetting("vfob.power", "VFO B Power",
                          RadioSettingValueList(
                              POWER_LIST, POWER_LIST[_vfob.power]))
        vfob_grp.append(rs)
        #         shift_dir:2
        rs = RadioSetting("vfob.iswide", "VFO B NBFM",
                          RadioSettingValueList(
                              BANDWIDTH_LIST, BANDWIDTH_LIST[_vfob.iswide]))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.mute_mode", "VFO B Mute",
                          RadioSettingValueList(
                              SPMUTE_LIST, SPMUTE_LIST[_vfob.mute_mode]))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.step", "VFO B Step (kHz)",
                          RadioSettingValueList(
                              STEP_LIST, STEP_LIST[_vfob.step]))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.squelch", "VFO B Squelch",
                          RadioSettingValueList(
                              LIST_10, LIST_10[_vfob.squelch]))
        vfob_grp.append(rs)
        rs = RadioSetting("bcl_b", "Busy Channel Lock-out B",
                          RadioSettingValueBoolean(_settings.bcl_b))
        vfob_grp.append(rs)

                #
        # Key Settings
        #
        _msg = str(_settings.dispstr).split("\0")[0]
        val = RadioSettingValueString(0, 15, _msg)
        val.set_mutable(True)
        rs = RadioSetting("dispstr", "Display Message", val)
        key_grp.append(rs)

        dtmfchars = "0123456789"
        _codeobj = _settings.ani_code
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x0A])
        val = RadioSettingValueString(3, 6, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("ani_code", "ANI Code", val)
        def apply_ani_id(setting, obj):
            value = []
            for j in range(0, 6):
                try:
                    value.append(dtmfchars.index(str(setting.value)[j]))
                except IndexError:
                    value.append(0xFF)
            obj.ani_code = value
        rs.set_apply_callback(apply_ani_id, _settings)
        key_grp.append(rs)

        rs = RadioSetting("pf1_func", "PF1 Key function",
                          RadioSettingValueList(
                              PF1KEY_LIST,
                              PF1KEY_LIST[_settings.pf1_func]))
        key_grp.append(rs)
        rs = RadioSetting("pf3_func", "PF3 Key function",
                          RadioSettingValueList(
                              PF3KEY_LIST,
                              PF3KEY_LIST[_settings.pf3_func]))
        key_grp.append(rs)

        #
        # Limits settings
        #
        rs = RadioSetting("vhf_limits.rx_start", "VHF RX Lower Limit",
                          RadioSettingValueInteger(
                              134000000, 174997500,
                              self._memobj.vhf_limits.rx_start * 10, 5000))
        vhf_lmt_grp.append(rs)
        rs = RadioSetting("vhf_limits.rx_stop", "VHF RX Upper Limit",
                          RadioSettingValueInteger(
                              134000000, 174997500,
                              self._memobj.vhf_limits.rx_stop * 10, 5000))
        vhf_lmt_grp.append(rs)
        rs = RadioSetting("vhf_limits.tx_start", "VHF TX Lower Limit",
                          RadioSettingValueInteger(
                              134000000, 174997500,
                              self._memobj.vhf_limits.tx_start * 10, 5000))
        vhf_lmt_grp.append(rs)
        rs = RadioSetting("vhf_limits.tx_stop", "VHF TX Upper Limit",
                          RadioSettingValueInteger(
                              134000000, 174997500,
                              self._memobj.vhf_limits.tx_stop * 10, 5000))
        vhf_lmt_grp.append(rs)

        rs = RadioSetting("vhf1_limits.rx_start", "VHF1 RX Lower Limit",
                          RadioSettingValueInteger(
                              220000000, 265000000,
                              self._memobj.vhf1_limits.rx_start * 10, 5000))
        vhf1_lmt_grp.append(rs)
        rs = RadioSetting("vhf1_limits.rx_stop", "VHF1 RX Upper Limit",
                          RadioSettingValueInteger(
                              220000000, 265000000,
                              self._memobj.vhf1_limits.rx_stop * 10, 5000))
        vhf1_lmt_grp.append(rs)
        rs = RadioSetting("vhf1_limits.tx_start", "VHF1 TX Lower Limit",
                          RadioSettingValueInteger(
                              220000000, 265000000,
                              self._memobj.vhf1_limits.tx_start * 10, 5000))
        vhf1_lmt_grp.append(rs)
        rs = RadioSetting("vhf1_limits.tx_stop", "VHF1 TX Upper Limit",
                          RadioSettingValueInteger(
                              220000000, 265000000,
                              self._memobj.vhf1_limits.tx_stop * 10, 5000))
        vhf1_lmt_grp.append(rs)

        rs = RadioSetting("uhf_limits.rx_start", "UHF RX Lower Limit",
                          RadioSettingValueInteger(
                              400000000, 520000000,
                              self._memobj.uhf_limits.rx_start * 10, 5000))
        uhf_lmt_grp.append(rs)
        rs = RadioSetting("uhf_limits.rx_stop", "UHF RX Upper Limit",
                          RadioSettingValueInteger(
                              400000000, 520000000,
                              self._memobj.uhf_limits.rx_stop * 10, 5000))
        uhf_lmt_grp.append(rs)
        rs = RadioSetting("uhf_limits.tx_start", "UHF TX Lower Limit",
                          RadioSettingValueInteger(
                              400000000, 520000000,
                              self._memobj.uhf_limits.tx_start * 10, 5000))
        uhf_lmt_grp.append(rs)
        rs = RadioSetting("uhf_limits.tx_stop", "UHF TX Upper Limit",
                          RadioSettingValueInteger(
                              400000000, 520000000,
                              self._memobj.uhf_limits.tx_stop * 10, 5000))
        uhf_lmt_grp.append(rs)

        #
        # OEM info
        #
        def _decode(lst):
            _str = ''.join([chr(c) for c in lst
                            if chr(c) in chirp_common.CHARSET_ASCII])
            return _str

        def do_nothing(setting, obj):
            return

        _str = _decode(self._memobj.oem_info.model)
        val = RadioSettingValueString(0, 15, _str)
        val.set_mutable(False)
        rs = RadioSetting("oem_info.model", "Model", val)
        rs.set_apply_callback(do_nothing, _settings)
        oem_grp.append(rs)
        _str = _decode(self._memobj.oem_info.oem1)
        val = RadioSettingValueString(0, 15, _str)
        val.set_mutable(False)
        rs = RadioSetting("oem_info.oem1", "OEM String 1", val)
        rs.set_apply_callback(do_nothing, _settings)
        oem_grp.append(rs)
        _str = _decode(self._memobj.oem_info.oem2)
        val = RadioSettingValueString(0, 15, _str)
        val.set_mutable(False)
        rs = RadioSetting("oem_info.oem2", "OEM String 2", val)
        rs.set_apply_callback(do_nothing, _settings)
        oem_grp.append(rs)
        _str = _decode(self._memobj.oem_info.version)
        val = RadioSettingValueString(0, 15, _str)
        val.set_mutable(False)
        rs = RadioSetting("oem_info.version", "Software Version", val)
        rs.set_apply_callback(do_nothing, _settings)
        oem_grp.append(rs)
        _str = _decode(self._memobj.oem_info.date)
        val = RadioSettingValueString(0, 15, _str)
        val.set_mutable(False)
        rs = RadioSetting("oem_info.date", "OEM Date", val)
        rs.set_apply_callback(do_nothing, _settings)
        oem_grp.append(rs)

        return group
Beispiel #8
0
    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")
        fm_preset = RadioSettingGroup("fm_preset", "FM Preset")
        dtmfe = RadioSettingGroup("dtmfe", "DTMF Encode Settings")
        service = RadioSettingGroup("service", "Service Settings")
        top = RadioSettings(basic, advanced, other, work, fm_preset, dtmfe,
                            service)

        # Basic settings
        if _mem.settings.squelch > 0x09:
            val = 0x00
        else:
            val = _mem.settings.squelch
        rs = RadioSetting(
            "settings.squelch", "Squelch",
            RadioSettingValueList(LIST_OFF1TO9, LIST_OFF1TO9[val]))
        basic.append(rs)

        if _mem.settings.save > 0x04:
            val = 0x00
        else:
            val = _mem.settings.save
        rs = RadioSetting("settings.save", "Battery Saver",
                          RadioSettingValueList(LIST_SAVE, LIST_SAVE[val]))
        basic.append(rs)

        if _mem.settings.vox > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.vox
        rs = RadioSetting(
            "settings.vox", "Vox",
            RadioSettingValueList(LIST_OFF1TO10, LIST_OFF1TO10[val]))
        basic.append(rs)

        if _mem.settings.abr > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.abr
        rs = RadioSetting(
            "settings.abr", "Backlight Timeout",
            RadioSettingValueList(LIST_OFF1TO10, LIST_OFF1TO10[val]))
        basic.append(rs)

        rs = RadioSetting("settings.tdr", "Dual Watch",
                          RadioSettingValueBoolean(_mem.settings.tdr))
        basic.append(rs)

        rs = RadioSetting("settings.beep", "Beep",
                          RadioSettingValueBoolean(_mem.settings.beep))
        basic.append(rs)

        if _mem.settings.timeout > 0x27:
            val = 0x03
        else:
            val = _mem.settings.timeout
        rs = RadioSetting(
            "settings.timeout", "Timeout Timer",
            RadioSettingValueList(LIST_TIMEOUT, LIST_TIMEOUT[val]))
        basic.append(rs)

        if _mem.settings.voice > 0x02:
            val = 0x01
        else:
            val = _mem.settings.voice
        rs = RadioSetting("settings.voice", "Voice Prompt",
                          RadioSettingValueList(LIST_VOICE, LIST_VOICE[val]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.dtmfst", "DTMF Sidetone",
            RadioSettingValueList(LIST_DTMFST,
                                  LIST_DTMFST[_mem.settings.dtmfst]))
        basic.append(rs)

        if _mem.settings.screv > 0x02:
            val = 0x01
        else:
            val = _mem.settings.screv
        rs = RadioSetting("settings.screv", "Scan Resume",
                          RadioSettingValueList(LIST_RESUME, LIST_RESUME[val]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.pttid", "When to send PTT ID",
            RadioSettingValueList(LIST_PTTID, LIST_PTTID[_mem.settings.pttid]))
        basic.append(rs)

        if _mem.settings.pttlt > 0x1E:
            val = 0x05
        else:
            val = _mem.settings.pttlt
        rs = RadioSetting("pttlt", "PTT ID Delay",
                          RadioSettingValueInteger(0, 50, val))
        basic.append(rs)

        rs = RadioSetting(
            "settings.mdfa", "Display Mode (A)",
            RadioSettingValueList(LIST_MODE, LIST_MODE[_mem.settings.mdfa]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.mdfb", "Display Mode (B)",
            RadioSettingValueList(LIST_MODE, LIST_MODE[_mem.settings.mdfb]))
        basic.append(rs)

        rs = RadioSetting("settings.sync", "Sync A & B",
                          RadioSettingValueBoolean(_mem.settings.sync))
        basic.append(rs)

        rs = RadioSetting(
            "settings.wtled", "Standby LED Color",
            RadioSettingValueList(LIST_COLOR, LIST_COLOR[_mem.settings.wtled]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.rxled", "RX LED Color",
            RadioSettingValueList(LIST_COLOR, LIST_COLOR[_mem.settings.rxled]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.txled", "TX LED Color",
            RadioSettingValueList(LIST_COLOR, LIST_COLOR[_mem.settings.txled]))
        basic.append(rs)

        val = _mem.settings.almod
        rs = RadioSetting("settings.almod", "Alarm Mode",
                          RadioSettingValueList(LIST_ALMOD, LIST_ALMOD[val]))
        basic.append(rs)

        rs = RadioSetting("settings.dbptt", "Double PTT",
                          RadioSettingValueBoolean(_mem.settings.dbptt))
        basic.append(rs)

        rs = RadioSetting("settings.ste", "Squelch Tail Eliminate (HT to HT)",
                          RadioSettingValueBoolean(_mem.settings.ste))
        basic.append(rs)

        rs = RadioSetting(
            "settings.ponmsg", "Power-On Message",
            RadioSettingValueList(LIST_PONMSG,
                                  LIST_PONMSG[_mem.settings.ponmsg]))
        basic.append(rs)

        rs = RadioSetting("settings.roger", "Roger Beep",
                          RadioSettingValueBoolean(_mem.settings.roger))
        basic.append(rs)

        rs = RadioSetting(
            "settings.rtone", "Tone Burst Frequency",
            RadioSettingValueList(LIST_RTONE, LIST_RTONE[_mem.settings.rtone]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.rogerrx", "Roger Beep (RX)",
            RadioSettingValueList(LIST_OFFAB,
                                  LIST_OFFAB[_mem.settings.rogerrx]))
        basic.append(rs)

        # Advanced settings
        rs = RadioSetting("settings.reset", "RESET Menu",
                          RadioSettingValueBoolean(_mem.settings.reset))
        advanced.append(rs)

        rs = RadioSetting("settings.menu", "All Menus",
                          RadioSettingValueBoolean(_mem.settings.menu))
        advanced.append(rs)

        rs = RadioSetting("settings.fmradio", "Broadcast FM Radio",
                          RadioSettingValueBoolean(_mem.settings.fmradio))
        advanced.append(rs)

        rs = RadioSetting("settings.alarm", "Alarm Sound",
                          RadioSettingValueBoolean(_mem.settings.alarm))
        advanced.append(rs)

        # Other settings
        def _filter(name):
            filtered = ""
            for char in str(name):
                if char in chirp_common.CHARSET_ASCII:
                    filtered += char
                else:
                    filtered += " "
            return filtered

        _msg = _mem.firmware_msg
        val = RadioSettingValueString(0, 7, _filter(_msg.line1))
        val.set_mutable(False)
        rs = RadioSetting("firmware_msg.line1", "Firmware Message 1", val)
        other.append(rs)

        val = RadioSettingValueString(0, 7, _filter(_msg.line2))
        val.set_mutable(False)
        rs = RadioSetting("firmware_msg.line2", "Firmware Message 2", val)
        other.append(rs)

        _msg = _mem.sixpoweron_msg
        val = RadioSettingValueString(0, 7, _filter(_msg.line1))
        val.set_mutable(False)
        rs = RadioSetting("sixpoweron_msg.line1", "6+Power-On Message 1", val)
        other.append(rs)
        val = RadioSettingValueString(0, 7, _filter(_msg.line2))
        val.set_mutable(False)
        rs = RadioSetting("sixpoweron_msg.line2", "6+Power-On Message 2", val)
        other.append(rs)

        _msg = _mem.poweron_msg
        rs = RadioSetting("poweron_msg.line1", "Power-On Message 1",
                          RadioSettingValueString(0, 7, _filter(_msg.line1)))
        other.append(rs)
        rs = RadioSetting("poweron_msg.line2", "Power-On Message 2",
                          RadioSettingValueString(0, 7, _filter(_msg.line2)))
        other.append(rs)

        # Work mode settings
        rs = RadioSetting(
            "settings.displayab", "Display",
            RadioSettingValueList(LIST_AB, LIST_AB[_mem.settings.displayab]))
        work.append(rs)

        rs = RadioSetting("settings.keylock", "Keypad Lock",
                          RadioSettingValueBoolean(_mem.settings.keylock))
        work.append(rs)

        rs = RadioSetting(
            "wmchannel.mrcha", "MR A Channel",
            RadioSettingValueInteger(1, 15, _mem.wmchannel.mrcha))
        work.append(rs)

        rs = RadioSetting(
            "wmchannel.mrchb", "MR B Channel",
            RadioSettingValueInteger(1, 15, _mem.wmchannel.mrchb))
        work.append(rs)

        # broadcast FM settings
        _fm_presets = self._memobj.fm_presets
        if _fm_presets <= 108.0 * 10 - 650:
            preset = _fm_presets / 10.0 + 65
        elif _fm_presets >= 65.0 * 10 and _fm_presets <= 108.0 * 10:
            preset = _fm_presets / 10.0
        else:
            preset = 76.0
        rs = RadioSetting("fm_presets", "FM Preset(MHz)",
                          RadioSettingValueFloat(65, 108.0, preset, 0.1, 1))
        fm_preset.append(rs)

        # DTMF settings
        def apply_code(setting, obj, length):
            code = []
            for j in range(0, length):
                try:
                    code.append(DTMF_CHARS.index(str(setting.value)[j]))
                except IndexError:
                    code.append(0xFF)
            obj.code = code

        for i in range(0, 15):
            _codeobj = self._memobj.pttid[i].code
            _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
            val = RadioSettingValueString(0, 5, _code, False)
            val.set_charset(DTMF_CHARS)
            pttid = RadioSetting("pttid/%i.code" % i,
                                 "Signal Code %i" % (i + 1), val)
            pttid.set_apply_callback(apply_code, self._memobj.pttid[i], 5)
            dtmfe.append(pttid)

        if _mem.ani.dtmfon > 0xC3:
            val = 0x03
        else:
            val = _mem.ani.dtmfon
        rs = RadioSetting(
            "ani.dtmfon", "DTMF Speed (on)",
            RadioSettingValueList(LIST_DTMFSPEED, LIST_DTMFSPEED[val]))
        dtmfe.append(rs)

        if _mem.ani.dtmfoff > 0xC3:
            val = 0x03
        else:
            val = _mem.ani.dtmfoff
        rs = RadioSetting(
            "ani.dtmfoff", "DTMF Speed (off)",
            RadioSettingValueList(LIST_DTMFSPEED, LIST_DTMFSPEED[val]))
        dtmfe.append(rs)

        _codeobj = self._memobj.ani.code
        _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 5, _code, False)
        val.set_charset(DTMF_CHARS)
        rs = RadioSetting("ani.code", "ANI Code", val)
        rs.set_apply_callback(apply_code, self._memobj.ani, 5)
        dtmfe.append(rs)

        rs = RadioSetting(
            "ani.aniid", "When to send ANI ID",
            RadioSettingValueList(LIST_PTTID, LIST_PTTID[_mem.ani.aniid]))
        dtmfe.append(rs)

        # Service settings
        for index in range(0, 10):
            key = "squelch.vhf.sql%i" % (index)
            _obj = self._memobj.squelch.vhf
            val = RadioSettingValueInteger(0, 123,
                                           getattr(_obj, "sql%i" % (index)))
            if index == 0:
                val.set_mutable(False)
            name = "Squelch %i" % (index)
            rs = RadioSetting(key, name, val)
            service.append(rs)

        return top
Beispiel #9
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")
        fm = RadioSettingGroup("fm", "FM Radio")
        adv = RadioSettingGroup("adv", "Advanced Settings")
        group = RadioSettings(basic, fm, adv)

        # ## Basic Settings
        rs = RadioSetting("tx_pwr", "TX Power",
                          RadioSettingValueList(
                            POWER_LIST, POWER_LIST[_settings.tx_pwr]))
        basic.append(rs)

        rs = RadioSetting("channel", "Active Channel",
                          RadioSettingValueInteger(1, 20, _settings.channel))
        basic.append(rs)

        rs = RadioSetting("squelch", "Squelch Level",
                          RadioSettingValueInteger(0, 9, _settings.squelch))
        basic.append(rs)

        rs = RadioSetting("vox", "VOX Level",
                          RadioSettingValueInteger(0, 9, _settings.vox))
        basic.append(rs)

        # volume validation, as the OEM software set 0xFF on write
        _volume = _settings.volume
        if _volume > 7:
            _volume = 7
        rs = RadioSetting("volume", "Volume Level",
                          RadioSettingValueInteger(0, 7, _volume))
        basic.append(rs)

        rs = RadioSetting("scantype", "Scan Type",
                          RadioSettingValueList(SCAN_TYPE_LIST, SCAN_TYPE_LIST[
                              _settings.scantype]))
        basic.append(rs)

        rs = RadioSetting("timeout", "Time Out Timer (seconds)",
                          RadioSettingValueList(
                            TOT_LIST, TOT_LIST[_settings.timeout]))
        basic.append(rs)

        rs = RadioSetting("voice", "Voice Prompt",
                          RadioSettingValueList(
                            LANGUAGE_LIST, LANGUAGE_LIST[_settings.voice]))
        basic.append(rs)

        rs = RadioSetting("alarm", "Alarm Time",
                          RadioSettingValueList(
                            TIMER_LIST, TIMER_LIST[_settings.alarm]))
        basic.append(rs)

        rs = RadioSetting("backlight", "Backlight",
                          RadioSettingValueList(
                            BACKLIGHT_LIST,
                            BACKLIGHT_LIST[_settings.backlight]))
        basic.append(rs)

        rs = RadioSetting("blo", "Busy Lockout",
                          RadioSettingValueBoolean(_settings.blo))
        basic.append(rs)

        rs = RadioSetting("ste", "Squelch Tail Eliminate",
                          RadioSettingValueBoolean(_settings.ste))
        basic.append(rs)

        rs = RadioSetting("batsave", "Battery Save",
                          RadioSettingValueBoolean(_settings.batsave))
        basic.append(rs)

        rs = RadioSetting("lock", "Key Lock",
                          RadioSettingValueBoolean(_settings.lock))
        basic.append(rs)

        rs = RadioSetting("beep", "Key Beep",
                          RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)

        # ## FM Settings
        rs = RadioSetting("fm_funct", "FM Function",
                          RadioSettingValueBoolean(_settings.fm_funct))
        fm.append(rs)

        rs = RadioSetting("fmrange", "FM Range",
                          RadioSettingValueList(
                            FM_RANGE_LIST, FM_RANGE_LIST[_settings.fmrange]))
        fm.append(rs)

        # callbacks for the FM VFO
        def apply_fm_freq(setting, obj):
            setattr(obj, setting.get_name(), int(setting.value.
                get_value() * 10) - 650)

        _fm_vfo = int(_settings.fm_vfo) * 0.1 + 65
        rs = RadioSetting("fm_vfo", "FM Station",
                          RadioSettingValueFloat(65, 108, _fm_vfo))
        rs.set_apply_callback(apply_fm_freq, _settings)
        fm.append(rs)

        # ## Advanced
        def apply_limit(setting, obj):
            setattr(obj, setting.get_name(), int(setting.value) * 10)

        rs = RadioSetting("vhfl", "VHF Low Limit",
                          RadioSettingValueInteger(130, 174, int(
                              _settings.vhfl) / 10))
        rs.set_apply_callback(apply_limit, _settings)
        adv.append(rs)

        rs = RadioSetting("vhfh", "VHF High Limit",
                          RadioSettingValueInteger(130, 174, int(
                              _settings.vhfh) / 10))
        rs.set_apply_callback(apply_limit, _settings)
        adv.append(rs)

        rs = RadioSetting("uhfl", "UHF Low Limit",
                          RadioSettingValueInteger(400, 520, int(
                              _settings.uhfl) / 10))
        rs.set_apply_callback(apply_limit, _settings)
        adv.append(rs)

        rs = RadioSetting("uhfh", "UHF High Limit",
                          RadioSettingValueInteger(400, 520, int(
                              _settings.uhfh) / 10))
        rs.set_apply_callback(apply_limit, _settings)
        adv.append(rs)

        rs = RadioSetting("relaym", "Relay Mode",
                          RadioSettingValueList(RELAY_MODE_LIST,
                              RELAY_MODE_LIST[_settings.relaym]))
        adv.append(rs)

        return group
Beispiel #10
0
    def get_settings(self):
        _settings = self._memobj.settings

        group = RadioSettingGroup("basic", "Basic")
        top = RadioSettings(group)

        group.append(
            RadioSetting(
                "mode", "Mode",
                RadioSettingValueList(MODE_LIST, MODE_LIST[_settings.mode])))

        group.append(
            RadioSetting(
                "ab_switch", "A/B",
                RadioSettingValueList(AB_LIST, AB_LIST[_settings.ab_switch])))

        group.append(
            RadioSetting(
                "a_channel", "A Selected Memory",
                RadioSettingValueInteger(1, 128, _settings.a_channel + 1)))

        group.append(
            RadioSetting(
                "b_channel", "B Selected Memory",
                RadioSettingValueInteger(1, 128, _settings.b_channel + 1)))

        group.append(
            RadioSetting(
                "a_display", "A Channel Display",
                RadioSettingValueList(DISPLAY_LIST,
                                      DISPLAY_LIST[_settings.a_display])))
        group.append(
            RadioSetting(
                "b_display", "B Channel Display",
                RadioSettingValueList(DISPLAY_LIST,
                                      DISPLAY_LIST[_settings.b_display])))
        group.append(
            RadioSetting(
                "tx_sel", "Priority Transmit",
                RadioSettingValueList(TXSEL_LIST,
                                      TXSEL_LIST[_settings.tx_sel])))
        group.append(
            RadioSetting(
                "vox_level", "VOX Level",
                RadioSettingValueList(VOX_LIST,
                                      VOX_LIST[_settings.vox_level])))

        group.append(
            RadioSetting("squelch", "Squelch Level",
                         RadioSettingValueInteger(0, 9, _settings.squelch)))

        group.append(
            RadioSetting("dwait", "Dual Wait",
                         RadioSettingValueBoolean(_settings.dwait)))

        group.append(
            RadioSetting(
                "led", "LED Mode",
                RadioSettingValueList(LED_LIST, LED_LIST[_settings.led])))

        group.append(
            RadioSetting(
                "light", "Light Color",
                RadioSettingValueList(LIGHT_LIST,
                                      LIGHT_LIST[_settings.light])))

        group.append(
            RadioSetting("beep", "Beep",
                         RadioSettingValueBoolean(_settings.beep)))

        group.append(
            RadioSetting("ani", "ANI",
                         RadioSettingValueBoolean(_settings.ani)))

        group.append(
            RadioSetting(
                "tot", "Timeout Timer",
                RadioSettingValueList(TOT_LIST, TOT_LIST[_settings.tot])))

        group.append(
            RadioSetting("roger", "Roger Beep",
                         RadioSettingValueBoolean(_settings.roger)))

        group.append(
            RadioSetting("dw", "Dual Watch",
                         RadioSettingValueBoolean(_settings.dw)))

        group.append(
            RadioSetting("rxsave", "RX Save",
                         RadioSettingValueBoolean(_settings.rxsave)))

        def _filter(name):
            return str(name).rstrip("\xFF").rstrip()

        group.append(
            RadioSetting(
                "ponmsg", "Power-On Message",
                RadioSettingValueString(0, 7, _filter(_settings.ponmsg))))

        group.append(
            RadioSetting(
                "scan_mode", "Scan Mode",
                RadioSettingValueList(SCAN_MODE_LIST,
                                      SCAN_MODE_LIST[_settings.scan_mode])))

        group.append(
            RadioSetting("autolk", "Auto Lock",
                         RadioSettingValueBoolean(_settings.autolk)))

        group.append(
            RadioSetting(
                "lock_mode", "Keypad Lock Mode",
                RadioSettingValueList(LOCK_MODE_LIST,
                                      LOCK_MODE_LIST[_settings.lock_mode])))

        group.append(
            RadioSetting("voice", "Voice Prompt",
                         RadioSettingValueBoolean(_settings.voice)))

        group.append(
            RadioSetting(
                "opnmsg", "Opening Message",
                RadioSettingValueList(OPNMSG_LIST,
                                      OPNMSG_LIST[_settings.opnmsg])))

        group.append(
            RadioSetting(
                "tuning_step", "Tuning Step",
                RadioSettingValueList(
                    TUNING_STEPS_LIST,
                    TUNING_STEPS_LIST[_settings.tuning_step])))

        group.append(
            RadioSetting(
                "lamp_t", "Backlight Timeout",
                RadioSettingValueList(
                    BACKLIGHT_TIMEOUT_LIST,
                    BACKLIGHT_TIMEOUT_LIST[_settings.lamp_t])))

        group.append(
            RadioSetting(
                "a_work_area", "A Work Area",
                RadioSettingValueList(AB_LIST,
                                      AB_LIST[_settings.a_work_area])))

        group.append(
            RadioSetting(
                "b_work_area", "B Work Area",
                RadioSettingValueList(AB_LIST,
                                      AB_LIST[_settings.b_work_area])))

        return top

        group.append(
            RadioSetting("disnm", "Display Name",
                         RadioSettingValueBoolean(_settings.disnm)))

        return group
Beispiel #11
0
    def get_settings(self):
        _msg = self._memobj.welcome_msg
        _oem = self._memobj.oem_info
        _settings = self._memobj.settings
        cfg_grp = RadioSettingGroup("cfg_grp", "Function Setup")
        oem_grp = RadioSettingGroup("oem_grp", "OEM Info")

        group = RadioSettings(cfg_grp, oem_grp)

        def _filter(name):
            filtered = ""
            for char in str(name):
                if char in chirp_common.CHARSET_ASCII:
                    filtered += char
                else:
                    filtered += " "
            return filtered

        #
        # Function Setup
        #

        rs = RadioSetting("welcome_msg.line1", "Welcome Message 1",
                          RadioSettingValueString(0, 6, _filter(_msg.line1)))
        cfg_grp.append(rs)

        rs = RadioSetting("welcome_msg.line2", "Welcome Message 2",
                          RadioSettingValueString(0, 6, _filter(_msg.line2)))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "display", "Display Mode",
            RadioSettingValueList(DISPLAY, DISPLAY[_settings.display]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "upvfomr", "Up VFO/MR",
            RadioSettingValueList(VFOMR, VFOMR[_settings.upvfomr]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "dnvfomr", "Down VFO/MR",
            RadioSettingValueList(VFOMR, VFOMR[_settings.dnvfomr]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "upwork", "Up Work Mode",
            RadioSettingValueList(WORKMODE, WORKMODE[_settings.upwork]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "upmrbank", "Up MR Bank",
            RadioSettingValueList(MRBANK, MRBANK[_settings.upmrbank]))
        cfg_grp.append(rs)

        rs = RadioSetting("upmrch", "Up MR Channel",
                          RadioSettingValueInteger(0, 200, _settings.upmrch))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "dnwork", "Down Work Mode",
            RadioSettingValueList(WORKMODE, WORKMODE[_settings.dnwork]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "dnmrbank", "Down MR Bank",
            RadioSettingValueList(MRBANK, MRBANK[_settings.dnmrbank]))
        cfg_grp.append(rs)

        rs = RadioSetting("dnmrch", "Down MR Channel",
                          RadioSettingValueInteger(0, 200, _settings.dnmrch))
        cfg_grp.append(rs)

        rs = RadioSetting("main", "Main",
                          RadioSettingValueList(MAIN, MAIN[_settings.main]))
        cfg_grp.append(rs)

        rs = RadioSetting("pause", "Scan Pause Time",
                          RadioSettingValueList(PAUSE, PAUSE[_settings.pause]))
        cfg_grp.append(rs)

        rs = RadioSetting("stop", "Function Keys Stop Time",
                          RadioSettingValueList(STOP, STOP[_settings.stop]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "backlight", "Backlight",
            RadioSettingValueList(BACKLIGHT, BACKLIGHT[_settings.backlight]))
        cfg_grp.append(rs)

        rs = RadioSetting("color", "Backlight Color",
                          RadioSettingValueList(COLOR, COLOR[_settings.color]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "vdisplay", "Vice-Machine Display",
            RadioSettingValueList(VDISPLAY, VDISPLAY[_settings.vdisplay]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "voxlevel", "Vox Level",
            RadioSettingValueList(VOXLEVEL, VOXLEVEL[_settings.voxlevel]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "voxdelay", "Vox Delay",
            RadioSettingValueList(VOXDELAY, VOXDELAY[_settings.voxdelay]))
        cfg_grp.append(rs)

        rs = RadioSetting("tot", "Time Out Timer",
                          RadioSettingValueList(TOT, TOT[_settings.tot]))
        cfg_grp.append(rs)

        rs = RadioSetting("tbst", "Tone Burst",
                          RadioSettingValueList(TBST, TBST[_settings.tbst]))
        cfg_grp.append(rs)

        rs = RadioSetting("monikey", "MONI Key Function",
                          RadioSettingValueList(MONI, MONI[_settings.monikey]))
        cfg_grp.append(rs)

        if self.MODEL == "TERMN-8R":
            rs = RadioSetting(
                "pf1key", "PF1 Key Function",
                RadioSettingValueList(PFKEYT, PFKEYT[_settings.pf1key]))
            cfg_grp.append(rs)

            rs = RadioSetting(
                "pf2key", "PF2 Key Function",
                RadioSettingValueList(PFKEYT, PFKEYT[_settings.pf2key]))
            cfg_grp.append(rs)

        if self.MODEL == "OBLTR-8R":
            rs = RadioSetting(
                "pf1key", "PF1 Key Function",
                RadioSettingValueList(PFKEYO, PFKEYO[_settings.pf1key]))
            cfg_grp.append(rs)

            rs = RadioSetting(
                "fmam", "PF2 Key Function",
                RadioSettingValueList(PFKEYO, PFKEYO[_settings.fmam]))
            cfg_grp.append(rs)

        rs = RadioSetting("apo", "Automatic Power Off",
                          RadioSettingValueList(APO, APO[_settings.apo]))
        cfg_grp.append(rs)

        rs = RadioSetting("save", "Power Save",
                          RadioSettingValueList(SAVE, SAVE[_settings.save]))
        cfg_grp.append(rs)

        rs = RadioSetting("tail", "Tail Eliminator Type",
                          RadioSettingValueList(TAIL, TAIL[_settings.tail]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "fmvfomr", "FM VFO/MR",
            RadioSettingValueList(VFOMR, VFOMR[_settings.fmvfomr]))
        cfg_grp.append(rs)

        rs = RadioSetting("fmmrch", "FM MR Channel",
                          RadioSettingValueInteger(0, 100, _settings.fmmrch))
        cfg_grp.append(rs)

        rs = RadioSetting("noaa", "NOAA",
                          RadioSettingValueList(NOAA, NOAA[_settings.noaa]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "noaach", "NOAA Channel",
            RadioSettingValueList(NOAACH, NOAACH[_settings.noaach]))
        cfg_grp.append(rs)

        rs = RadioSetting(
            "part95", "PART95",
            RadioSettingValueList(PART95, PART95[_settings.part95]))
        cfg_grp.append(rs)

        rs = RadioSetting("gmrs", "GMRS",
                          RadioSettingValueList(GMRS, GMRS[_settings.gmrs]))
        cfg_grp.append(rs)

        rs = RadioSetting("murs", "MURS",
                          RadioSettingValueList(MURS, MURS[_settings.murs]))
        cfg_grp.append(rs)

        for i in range(0, 9):
            val = self._memobj.banklink[i].bank
            rs = RadioSetting("banklink/%i.bank" % i, "Bank Link %i" % (i + 1),
                              RadioSettingValueBoolean(val))
            cfg_grp.append(rs)

        val = self._memobj.banklink[9].bank
        rs = RadioSetting("banklink/9.bank", "Bank Link 0",
                          RadioSettingValueBoolean(val))
        cfg_grp.append(rs)

        rs = RadioSetting("allband", "All Band",
                          RadioSettingValueBoolean(_settings.allband))
        cfg_grp.append(rs)

        rs = RadioSetting("alarmoff", "Alarm Function Off",
                          RadioSettingValueBoolean(_settings.alarmoff))
        cfg_grp.append(rs)

        rs = RadioSetting("beep", "Beep",
                          RadioSettingValueBoolean(_settings.beep))
        cfg_grp.append(rs)

        rs = RadioSetting("radio", "Radio",
                          RadioSettingValueBoolean(_settings.radio))
        cfg_grp.append(rs)

        if self.MODEL == "TERMN-8R":
            rs = RadioSetting("keylock", "Keylock",
                              RadioSettingValueBoolean(_settings.keylock))
            cfg_grp.append(rs)

            rs = RadioSetting("fastscan", "Fast Scan",
                              RadioSettingValueBoolean(_settings.fastscan))
            cfg_grp.append(rs)

        if self.MODEL == "OBLTR-8R":
            # "pf2key" is used for OBLTR-8R "keylock"
            rs = RadioSetting("pf2key", "Keylock",
                              RadioSettingValueBoolean(_settings.pf2key))
            cfg_grp.append(rs)

            rs = RadioSetting("fastscano", "Fast Scan",
                              RadioSettingValueBoolean(_settings.fastscano))
            cfg_grp.append(rs)

        rs = RadioSetting("uplink", "Up Bank Link Select",
                          RadioSettingValueBoolean(_settings.uplink))
        cfg_grp.append(rs)

        rs = RadioSetting("downlink", "Down Bank Link Select",
                          RadioSettingValueBoolean(_settings.downlink))
        cfg_grp.append(rs)

        #
        # OEM info
        #

        val = RadioSettingValueString(0, 7, _filter(_oem.model))
        val.set_mutable(False)
        rs = RadioSetting("oem_info.model", "Model", val)
        oem_grp.append(rs)

        val = RadioSettingValueString(0, 9, _filter(_oem.date))
        val.set_mutable(False)
        rs = RadioSetting("oem_info.date", "Date", val)
        oem_grp.append(rs)

        val = RadioSettingValueString(0, 16, _filter(_oem.dealer))
        val.set_mutable(False)
        rs = RadioSetting("oem_info.dealer", "Dealer Code", val)
        oem_grp.append(rs)

        val = RadioSettingValueString(0, 9, _filter(_oem.stockdate))
        val.set_mutable(False)
        rs = RadioSetting("oem_info.stockdate", "Stock Date", val)
        oem_grp.append(rs)

        val = RadioSettingValueString(0, 9, _filter(_oem.selldate))
        val.set_mutable(False)
        rs = RadioSetting("oem_info.selldate", "Sell Date", val)
        oem_grp.append(rs)

        return group
Beispiel #12
0
    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")
        fm_preset = RadioSettingGroup("fm_preset", "FM Preset")
        dtmfe = RadioSettingGroup("dtmfe", "DTMF Encode Settings")
        service = RadioSettingGroup("service", "Service Settings")
        top = RadioSettings(basic, advanced, other, work, fm_preset, dtmfe,
                            service)

        # Basic settings
        if _mem.settings.squelch > 0x09:
            val = 0x00
        else:
            val = _mem.settings.squelch
        rs = RadioSetting(
            "settings.squelch", "Squelch",
            RadioSettingValueList(LIST_OFF1TO9, LIST_OFF1TO9[val]))
        basic.append(rs)

        if _mem.settings.save > 0x04:
            val = 0x00
        else:
            val = _mem.settings.save
        rs = RadioSetting("settings.save", "Battery Saver",
                          RadioSettingValueList(LIST_SAVE, LIST_SAVE[val]))
        basic.append(rs)

        if _mem.settings.vox > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.vox
        rs = RadioSetting(
            "settings.vox", "Vox",
            RadioSettingValueList(LIST_OFF1TO10, LIST_OFF1TO10[val]))
        basic.append(rs)

        if _mem.settings.abr > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.abr
        rs = RadioSetting(
            "settings.abr", "Backlight Timeout",
            RadioSettingValueList(LIST_OFF1TO10, LIST_OFF1TO10[val]))
        basic.append(rs)

        rs = RadioSetting("settings.tdr", "Dual Watch",
                          RadioSettingValueBoolean(_mem.settings.tdr))
        basic.append(rs)

        rs = RadioSetting("settings.beep", "Beep",
                          RadioSettingValueBoolean(_mem.settings.beep))
        basic.append(rs)

        if _mem.settings.timeout > 0x27:
            val = 0x03
        else:
            val = _mem.settings.timeout
        rs = RadioSetting(
            "settings.timeout", "Timeout Timer",
            RadioSettingValueList(LIST_TIMEOUT, LIST_TIMEOUT[val]))
        basic.append(rs)

        if _mem.settings.voice > 0x02:
            val = 0x01
        else:
            val = _mem.settings.voice
        rs = RadioSetting("settings.voice", "Voice Prompt",
                          RadioSettingValueList(LIST_VOICE, LIST_VOICE[val]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.dtmfst", "DTMF Sidetone",
            RadioSettingValueList(LIST_DTMFST,
                                  LIST_DTMFST[_mem.settings.dtmfst]))
        basic.append(rs)

        if _mem.settings.screv > 0x02:
            val = 0x01
        else:
            val = _mem.settings.screv
        rs = RadioSetting("settings.screv", "Scan Resume",
                          RadioSettingValueList(LIST_RESUME, LIST_RESUME[val]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.pttid", "When to send PTT ID",
            RadioSettingValueList(LIST_PTTID, LIST_PTTID[_mem.settings.pttid]))
        basic.append(rs)

        if _mem.settings.pttlt > 0x1E:
            val = 0x05
        else:
            val = _mem.settings.pttlt
        rs = RadioSetting("pttlt", "PTT ID Delay",
                          RadioSettingValueInteger(0, 50, val))
        basic.append(rs)

        rs = RadioSetting(
            "settings.mdfa", "Display Mode (A)",
            RadioSettingValueList(LIST_MODE, LIST_MODE[_mem.settings.mdfa]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.mdfb", "Display Mode (B)",
            RadioSettingValueList(LIST_MODE, LIST_MODE[_mem.settings.mdfb]))
        basic.append(rs)

        rs = RadioSetting("settings.autolk", "Auto Lock Keypad",
                          RadioSettingValueBoolean(_mem.settings.autolk))
        basic.append(rs)

        rs = RadioSetting(
            "settings.wtled", "Standby LED Color",
            RadioSettingValueList(LIST_COLOR, LIST_COLOR[_mem.settings.wtled]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.rxled", "RX LED Color",
            RadioSettingValueList(LIST_COLOR, LIST_COLOR[_mem.settings.rxled]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.txled", "TX LED Color",
            RadioSettingValueList(LIST_COLOR, LIST_COLOR[_mem.settings.txled]))
        basic.append(rs)

        if _mem.settings.almod > 0x02:
            val = 0x00
        else:
            val = _mem.settings.almod
        rs = RadioSetting("settings.almod", "Alarm Mode",
                          RadioSettingValueList(LIST_ALMOD, LIST_ALMOD[val]))
        basic.append(rs)

        if _mem.settings.tcall > 0x05:
            val = 0x00
        else:
            val = _mem.settings.tcall
        rs = RadioSetting("settings.tcall", "Tone Burst Frequency",
                          RadioSettingValueList(LIST_TCALL, LIST_TCALL[val]))
        basic.append(rs)

        rs = RadioSetting("settings.ste", "Squelch Tail Eliminate (HT to HT)",
                          RadioSettingValueBoolean(_mem.settings.ste))
        basic.append(rs)

        if _mem.settings.rpste > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.rpste
        rs = RadioSetting("settings.rpste",
                          "Squelch Tail Eliminate (repeater)",
                          RadioSettingValueList(LIST_RPSTE, LIST_RPSTE[val]))
        basic.append(rs)

        if _mem.settings.rptrl > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.rptrl
        rs = RadioSetting(
            "settings.rptrl", "STE Repeater Delay",
            RadioSettingValueList(LIST_STEDELAY, LIST_STEDELAY[val]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.ponmsg", "Power-On Message",
            RadioSettingValueList(LIST_PONMSG,
                                  LIST_PONMSG[_mem.settings.ponmsg]))
        basic.append(rs)

        rs = RadioSetting("settings.roger", "Roger Beep",
                          RadioSettingValueBoolean(_mem.settings.roger))
        basic.append(rs)

        # Advanced settings
        rs = RadioSetting("settings.reset", "RESET Menu",
                          RadioSettingValueBoolean(_mem.settings.reset))
        advanced.append(rs)

        rs = RadioSetting("settings.menu", "All Menus",
                          RadioSettingValueBoolean(_mem.settings.menu))
        advanced.append(rs)

        rs = RadioSetting("settings.fmradio", "Broadcast FM Radio",
                          RadioSettingValueBoolean(_mem.settings.fmradio))
        advanced.append(rs)

        rs = RadioSetting("settings.alarm", "Alarm Sound",
                          RadioSettingValueBoolean(_mem.settings.alarm))
        advanced.append(rs)

        # Other settings
        def _filter(name):
            filtered = ""
            for char in str(name):
                if char in chirp_common.CHARSET_ASCII:
                    filtered += char
                else:
                    filtered += " "
            return filtered

        _msg = _mem.firmware_msg
        val = RadioSettingValueString(0, 8, _filter(_msg.line1))
        val.set_mutable(False)
        rs = RadioSetting("firmware_msg.line1", "Firmware Message 1", val)
        other.append(rs)

        val = RadioSettingValueString(0, 8, _filter(_msg.line2))
        val.set_mutable(False)
        rs = RadioSetting("firmware_msg.line2", "Firmware Message 2", val)
        other.append(rs)

        _msg = _mem.sixpoweron_msg
        val = RadioSettingValueString(0, 8, _filter(_msg.line1))
        val.set_mutable(False)
        rs = RadioSetting("sixpoweron_msg.line1", "6+Power-On Message 1", val)
        other.append(rs)
        val = RadioSettingValueString(0, 8, _filter(_msg.line2))
        val.set_mutable(False)
        rs = RadioSetting("sixpoweron_msg.line2", "6+Power-On Message 2", val)
        other.append(rs)

        _msg = _mem.poweron_msg
        rs = RadioSetting("poweron_msg.line1", "Power-On Message 1",
                          RadioSettingValueString(0, 7, _filter(_msg.line1)))
        other.append(rs)
        rs = RadioSetting("poweron_msg.line2", "Power-On Message 2",
                          RadioSettingValueString(0, 7, _filter(_msg.line2)))
        other.append(rs)

        lower = 136
        upper = 174
        rs = RadioSetting(
            "limits.vhf.lower", "VHF Lower Limit (MHz)",
            RadioSettingValueInteger(lower, upper, _mem.limits.vhf.lower))
        other.append(rs)

        rs = RadioSetting(
            "limits.vhf.upper", "VHF Upper Limit (MHz)",
            RadioSettingValueInteger(lower, upper, _mem.limits.vhf.upper))
        other.append(rs)

        lower = 400
        upper = 520
        rs = RadioSetting(
            "limits.uhf.lower", "UHF Lower Limit (MHz)",
            RadioSettingValueInteger(lower, upper, _mem.limits.uhf.lower))
        other.append(rs)

        rs = RadioSetting(
            "limits.uhf.upper", "UHF Upper Limit (MHz)",
            RadioSettingValueInteger(lower, upper, _mem.limits.uhf.upper))
        other.append(rs)

        # Work mode settings
        rs = RadioSetting(
            "settings.displayab", "Display",
            RadioSettingValueList(LIST_AB, LIST_AB[_mem.settings.displayab]))
        work.append(rs)

        rs = RadioSetting(
            "settings.workmode", "VFO/MR Mode",
            RadioSettingValueList(LIST_WORKMODE,
                                  LIST_WORKMODE[_mem.settings.workmode]))
        work.append(rs)

        rs = RadioSetting("settings.keylock", "Keypad Lock",
                          RadioSettingValueBoolean(_mem.settings.keylock))
        work.append(rs)

        rs = RadioSetting(
            "wmchannel.mrcha", "MR A Channel",
            RadioSettingValueInteger(0, 127, _mem.wmchannel.mrcha))
        work.append(rs)

        rs = RadioSetting(
            "wmchannel.mrchb", "MR B Channel",
            RadioSettingValueInteger(0, 127, _mem.wmchannel.mrchb))
        work.append(rs)

        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):
            _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 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)
        rs = RadioSetting("vfo.a.freq", "VFO A Frequency", val1a)
        rs.set_apply_callback(apply_freq, _mem.vfo.a)
        work.append(rs)

        val1b = RadioSettingValueString(0, 10,
                                        convert_bytes_to_freq(_mem.vfo.b.freq))
        val1b.set_validate_callback(my_validate)
        rs = RadioSetting("vfo.b.freq", "VFO B Frequency", val1b)
        rs.set_apply_callback(apply_freq, _mem.vfo.b)
        work.append(rs)

        rs = RadioSetting(
            "vfo.a.sftd", "VFO A Shift",
            RadioSettingValueList(LIST_SHIFTD, LIST_SHIFTD[_mem.vfo.a.sftd]))
        work.append(rs)

        rs = RadioSetting(
            "vfo.b.sftd", "VFO B Shift",
            RadioSettingValueList(LIST_SHIFTD, LIST_SHIFTD[_mem.vfo.b.sftd]))
        work.append(rs)

        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 * 1000)

        def apply_offset(setting, obj):
            value = chirp_common.parse_freq(str(setting.value)) / 1000
            for i in range(5, -1, -1):
                obj.offset[i] = value % 10
                value /= 10

        val1a = RadioSettingValueString(
            0, 10, convert_bytes_to_offset(_mem.vfo.a.offset))
        rs = RadioSetting("vfo.a.offset", "VFO A Offset", val1a)
        rs.set_apply_callback(apply_offset, _mem.vfo.a)
        work.append(rs)

        val1b = RadioSettingValueString(
            0, 10, convert_bytes_to_offset(_mem.vfo.b.offset))
        rs = RadioSetting("vfo.b.offset", "VFO B Offset", val1b)
        rs.set_apply_callback(apply_offset, _mem.vfo.b)
        work.append(rs)

        rs = RadioSetting(
            "vfo.a.txpower", "VFO A Power",
            RadioSettingValueList(LIST_TXPOWER,
                                  LIST_TXPOWER[_mem.vfo.a.txpower]))
        work.append(rs)

        rs = RadioSetting(
            "vfo.b.txpower", "VFO B Power",
            RadioSettingValueList(LIST_TXPOWER,
                                  LIST_TXPOWER[_mem.vfo.b.txpower]))
        work.append(rs)

        rs = RadioSetting(
            "vfo.a.widenarr", "VFO A Bandwidth",
            RadioSettingValueList(LIST_BANDWIDTH,
                                  LIST_BANDWIDTH[_mem.vfo.a.widenarr]))
        work.append(rs)

        rs = RadioSetting(
            "vfo.b.widenarr", "VFO B Bandwidth",
            RadioSettingValueList(LIST_BANDWIDTH,
                                  LIST_BANDWIDTH[_mem.vfo.b.widenarr]))
        work.append(rs)

        rs = RadioSetting(
            "vfo.a.scode", "VFO A S-CODE",
            RadioSettingValueList(LIST_SCODE, LIST_SCODE[_mem.vfo.a.scode]))
        work.append(rs)

        rs = RadioSetting(
            "vfo.b.scode", "VFO B S-CODE",
            RadioSettingValueList(LIST_SCODE, LIST_SCODE[_mem.vfo.b.scode]))
        work.append(rs)

        rs = RadioSetting(
            "vfo.a.step", "VFO A Tuning Step",
            RadioSettingValueList(LIST_STEP, LIST_STEP[_mem.vfo.a.step]))
        work.append(rs)
        rs = RadioSetting(
            "vfo.b.step", "VFO B Tuning Step",
            RadioSettingValueList(LIST_STEP, LIST_STEP[_mem.vfo.b.step]))
        work.append(rs)

        # broadcast FM settings
        _fm_presets = self._memobj.fm_presets
        if _fm_presets <= 108.0 * 10 - 650:
            preset = _fm_presets / 10.0 + 65
        elif _fm_presets >= 65.0 * 10 and _fm_presets <= 108.0 * 10:
            preset = _fm_presets / 10.0
        else:
            preset = 76.0
        rs = RadioSetting("fm_presets", "FM Preset(MHz)",
                          RadioSettingValueFloat(65, 108.0, preset, 0.1, 1))
        fm_preset.append(rs)

        # DTMF settings
        def apply_code(setting, obj, length):
            code = []
            for j in range(0, length):
                try:
                    code.append(DTMF_CHARS.index(str(setting.value)[j]))
                except IndexError:
                    code.append(0xFF)
            obj.code = code

        for i in range(0, 15):
            _codeobj = self._memobj.pttid[i].code
            _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
            val = RadioSettingValueString(0, 5, _code, False)
            val.set_charset(DTMF_CHARS)
            pttid = RadioSetting("pttid/%i.code" % i,
                                 "Signal Code %i" % (i + 1), val)
            pttid.set_apply_callback(apply_code, self._memobj.pttid[i], 5)
            dtmfe.append(pttid)

        if _mem.ani.dtmfon > 0xC3:
            val = 0x03
        else:
            val = _mem.ani.dtmfon
        rs = RadioSetting(
            "ani.dtmfon", "DTMF Speed (on)",
            RadioSettingValueList(LIST_DTMFSPEED, LIST_DTMFSPEED[val]))
        dtmfe.append(rs)

        if _mem.ani.dtmfoff > 0xC3:
            val = 0x03
        else:
            val = _mem.ani.dtmfoff
        rs = RadioSetting(
            "ani.dtmfoff", "DTMF Speed (off)",
            RadioSettingValueList(LIST_DTMFSPEED, LIST_DTMFSPEED[val]))
        dtmfe.append(rs)

        _codeobj = self._memobj.ani.code
        _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 5, _code, False)
        val.set_charset(DTMF_CHARS)
        rs = RadioSetting("ani.code", "ANI Code", val)
        rs.set_apply_callback(apply_code, self._memobj.ani, 5)
        dtmfe.append(rs)

        rs = RadioSetting(
            "ani.aniid", "When to send ANI ID",
            RadioSettingValueList(LIST_PTTID, LIST_PTTID[_mem.ani.aniid]))
        dtmfe.append(rs)

        # Service settings
        for index in range(0, 10):
            key = "squelch.sql%i" % (index)
            _obj = self._memobj.squelch
            val = RadioSettingValueInteger(0, 123,
                                           getattr(_obj, "sql%i" % (index)))
            if index == 0:
                val.set_mutable(False)
            name = "Squelch %i" % (index)
            rs = RadioSetting(key, name, val)
            service.append(rs)

        return top
Beispiel #13
0
    def _get_settings(self):
        _settings = self._memobj.settings
        _service = self._memobj.service
        _msg = self._memobj.messages
        cfg_grp = RadioSettingGroup("cfg_grp", "Basic Settings")
        adv_grp = RadioSettingGroup("adv_grp", "Advanced Settings")
        key_grp = RadioSettingGroup("key_grp", "Key Assignment")
        group = RadioSettings(cfg_grp, adv_grp, key_grp)

        #
        # Basic Settings
        #
        rs = RadioSetting(
            "apo", "Auto Power Off",
            RadioSettingValueList(APO_LIST, APO_LIST[_settings.apo]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "sql", "Squelch Level",
            RadioSettingValueList(SQL_LIST, SQL_LIST[_settings.sql]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "scanm", "Scan Mode",
            RadioSettingValueList(SCANM_LIST, SCANM_LIST[_settings.scanm]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "tot", "Time Out Timer",
            RadioSettingValueList(TOT_LIST, TOT_LIST[_settings.tot]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "step", "Step",
            RadioSettingValueList(STEP_LIST, STEP_LIST[_settings.step]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "monitor", "Monitor",
            RadioSettingValueList(MONITOR_LIST,
                                  MONITOR_LIST[_settings.monitor]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "vfomr", "VFO/MR",
            RadioSettingValueList(VFOMR_LIST, VFOMR_LIST[_settings.vfomr]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "mrcha", "MR/CHA",
            RadioSettingValueList(MRCHA_LIST, MRCHA_LIST[_settings.mrcha]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "vol", "Volume",
            RadioSettingValueList(VOL_LIST, VOL_LIST[_settings.vol]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "opendis", "Open Display",
            RadioSettingValueList(OPENDIS_LIST,
                                  OPENDIS_LIST[_settings.opendis]))
        cfg_grp.append(rs)

        def _filter(name):
            filtered = ""
            for char in str(name):
                if char in chirp_common.CHARSET_ASCII:
                    filtered += char
                else:
                    filtered += " "
            LOG.debug("Filtered: %s" % filtered)
            return filtered

        rs = RadioSetting("messages.user1", "User-defined Message 1",
                          RadioSettingValueString(0, 7, _filter(_msg.user1)))
        cfg_grp.append(rs)
        rs = RadioSetting("messages.user2", "User-defined Message 2",
                          RadioSettingValueString(0, 7, _filter(_msg.user2)))
        cfg_grp.append(rs)

        val = RadioSettingValueString(0, 7, _filter(_msg.system))
        val.set_mutable(False)
        rs = RadioSetting("messages.system", "System Message", val)
        cfg_grp.append(rs)

        rs = RadioSetting(
            "lamp", "Backlight",
            RadioSettingValueList(LAMP_LIST, LAMP_LIST[_settings.lamp]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "keylockm", "Key Lock Mode",
            RadioSettingValueList(KEYLOCKM_LIST,
                                  KEYLOCKM_LIST[_settings.keylockm]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "absel", "A/B Select",
            RadioSettingValueList(ABSEL_LIST, ABSEL_LIST[_settings.absel]))
        cfg_grp.append(rs)

        rs = RadioSetting("obeep", "Open Beep",
                          RadioSettingValueBoolean(_settings.obeep))
        cfg_grp.append(rs)
        rs = RadioSetting("rbeep", "Roger Beep",
                          RadioSettingValueBoolean(_settings.rbeep))
        cfg_grp.append(rs)
        rs = RadioSetting("keylock_off", "Key Lock",
                          RadioSettingValueBoolean(not _settings.keylock_off))
        cfg_grp.append(rs)
        rs = RadioSetting("ctdcsb", "CT/DCS Busy Lock",
                          RadioSettingValueBoolean(_settings.ctdcsb))
        cfg_grp.append(rs)
        rs = RadioSetting("alarm", "Alarm Key",
                          RadioSettingValueBoolean(_settings.alarm))
        cfg_grp.append(rs)
        rs = RadioSetting("save", "Battery Save",
                          RadioSettingValueBoolean(_settings.save))
        cfg_grp.append(rs)
        rs = RadioSetting("kbeep", "Key Beep",
                          RadioSettingValueBoolean(_settings.kbeep))
        cfg_grp.append(rs)
        rs = RadioSetting("reset", "Reset Enable",
                          RadioSettingValueBoolean(_settings.reset))
        cfg_grp.append(rs)
        rs = RadioSetting("smfont_off", "Small Font",
                          RadioSettingValueBoolean(not _settings.smfont_off))
        cfg_grp.append(rs)
        rs = RadioSetting("aliasen_off", "Alias Enable",
                          RadioSettingValueBoolean(not _settings.aliasen_off))
        cfg_grp.append(rs)
        rs = RadioSetting("txstop_off", "TX Stop",
                          RadioSettingValueBoolean(not _settings.txstop_off))
        cfg_grp.append(rs)
        rs = RadioSetting("dw_off", "Dual Watch",
                          RadioSettingValueBoolean(not _settings.dw_off))
        cfg_grp.append(rs)
        rs = RadioSetting("fmen_off", "FM Enable",
                          RadioSettingValueBoolean(not _settings.fmen_off))
        cfg_grp.append(rs)
        rs = RadioSetting("fmdw", "FM Dual Watch",
                          RadioSettingValueBoolean(_settings.fmdw))
        cfg_grp.append(rs)
        rs = RadioSetting("fmscan_off", "FM Scan",
                          RadioSettingValueBoolean(not _settings.fmscan_off))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "keypadmic_off", "Keypad MIC",
            RadioSettingValueBoolean(not _settings.keypadmic_off))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "voxgain", "VOX Gain",
            RadioSettingValueList(VOXGAIN_LIST,
                                  VOXGAIN_LIST[_settings.voxgain]))
        cfg_grp.append(rs)
        rs = RadioSetting(
            "voxdt", "VOX Delay Time",
            RadioSettingValueList(VOXDT_LIST, VOXDT_LIST[_settings.voxdt]))
        cfg_grp.append(rs)
        rs = RadioSetting("vir", "VOX Inhibit on Receive",
                          RadioSettingValueBoolean(_settings.vir))
        cfg_grp.append(rs)

        #
        # Advanced Settings
        #
        val = (_settings.dtmftime) - 5
        rs = RadioSetting(
            "dtmftime", "DTMF Digit Time",
            RadioSettingValueList(DTMFTIME_LIST, DTMFTIME_LIST[val]))
        adv_grp.append(rs)
        val = (_settings.dtmfspace) - 5
        rs = RadioSetting(
            "dtmfspace", "DTMF Digit Space Time",
            RadioSettingValueList(DTMFTIME_LIST, DTMFTIME_LIST[val]))
        adv_grp.append(rs)
        val = (_settings.dtmfdelay) / 5
        rs = RadioSetting(
            "dtmfdelay", "DTMF 1st Digit Delay",
            RadioSettingValueList(DTMFDELAY_LIST, DTMFDELAY_LIST[val]))
        adv_grp.append(rs)
        val = (_settings.dtmfpretime) / 10 - 1
        rs = RadioSetting(
            "dtmfpretime", "DTMF Pretime",
            RadioSettingValueList(DTMFPRETIME_LIST, DTMFPRETIME_LIST[val]))
        adv_grp.append(rs)
        val = (_settings.dtmfdelay2) / 5
        rs = RadioSetting(
            "dtmfdelay2", "DTMF * and # Digit Delay",
            RadioSettingValueList(DTMFDELAY2_LIST, DTMFDELAY2_LIST[val]))
        adv_grp.append(rs)
        rs = RadioSetting("ackdecode", "ACK Decode",
                          RadioSettingValueBoolean(_settings.ackdecode))
        adv_grp.append(rs)
        rs = RadioSetting("dtmfst", "DTMF Sidetone",
                          RadioSettingValueBoolean(_settings.dtmfst))
        adv_grp.append(rs)

        rs = RadioSetting("service.rssi400", "Squelch Base Level (UHF)",
                          RadioSettingValueInteger(0, 255, _service.rssi400))
        adv_grp.append(rs)
        rs = RadioSetting("service.rssi136", "Squelch Base Level (VHF)",
                          RadioSettingValueInteger(0, 255, _service.rssi136))
        adv_grp.append(rs)

        #
        # Key Settings
        #
        val = (_settings.lptime) - 5
        rs = RadioSetting("lptime", "Long Press Time",
                          RadioSettingValueList(LPTIME_LIST, LPTIME_LIST[val]))
        key_grp.append(rs)
        rs = RadioSetting(
            "keyp1long", "P1 Long Key",
            RadioSettingValueList(PFKEYLONG_LIST,
                                  PFKEYLONG_LIST[_settings.keyp1long]))
        key_grp.append(rs)
        rs = RadioSetting(
            "keyp1short", "P1 Short Key",
            RadioSettingValueList(PFKEYSHORT_LIST,
                                  PFKEYSHORT_LIST[_settings.keyp1short]))
        key_grp.append(rs)
        rs = RadioSetting(
            "keyp2long", "P2 Long Key",
            RadioSettingValueList(PFKEYLONG_LIST,
                                  PFKEYLONG_LIST[_settings.keyp2long]))
        key_grp.append(rs)
        rs = RadioSetting(
            "keyp2short", "P2 Short Key",
            RadioSettingValueList(PFKEYSHORT_LIST,
                                  PFKEYSHORT_LIST[_settings.keyp2short]))
        key_grp.append(rs)
        rs = RadioSetting(
            "keyp3long", "P3 Long Key",
            RadioSettingValueList(PFKEYLONG_LIST,
                                  PFKEYLONG_LIST[_settings.keyp3long]))
        key_grp.append(rs)
        rs = RadioSetting(
            "keyp3short", "P3 Short Key",
            RadioSettingValueList(PFKEYSHORT_LIST,
                                  PFKEYSHORT_LIST[_settings.keyp3short]))
        key_grp.append(rs)

        val = RadioSettingValueList(PFKEYSHORT_LIST,
                                    PFKEYSHORT_LIST[_settings.keymshort])
        val.set_mutable(_settings.menuen == 0)
        rs = RadioSetting("keymshort", "M Short Key", val)
        key_grp.append(rs)
        val = RadioSettingValueBoolean(_settings.menuen)
        rs = RadioSetting("menuen", "Menu Enable", val)
        key_grp.append(rs)

        return group
Beispiel #14
0
    def get_settings(self):
        """Translate the MEM_FORMAT structs into settings in the UI"""
        # Define mem struct write-back shortcuts
        _sets = self._memobj.settings
        _cmnt = self._memobj.comment
        _wxch = self._memobj.abwx
        _dtm = self._memobj.dtmfcode
        _pses = self._memobj.pgmscanedge
        _bklk = self._memobj.banklink

        basic = RadioSettingGroup("basic", "Basic Settings")
        mickey = RadioSettingGroup("mickey", "Microphone Keys")
        bluet = RadioSettingGroup("bluet", "Bluetooth")
        disp = RadioSettingGroup("disp", "Display")
        sound = RadioSettingGroup("sound", "Sounds")
        dtmf = RadioSettingGroup("dtmf", "DTMF Codes")
        abset = RadioSettingGroup("abset", "A/B Band Settings")
        edges = RadioSettingGroup("edges", "Program Scan Edges")
        pslnk = RadioSettingGroup("pslnk", "Program Scan Links")
        other = RadioSettingGroup("other", "Other Settings")

        group = RadioSettings(basic, disp, sound, mickey, dtmf, abset, bluet,
                              edges, pslnk, other)

        def mic_keys(setting, obj, atrb):
            """ Callback to set subset of mic key options """
            stx = str(setting.value)
            value = MICKEYOPTS.index(stx)
            setattr(obj, atrb, value)
            return

        def hex_val(setting, obj, atrb):
            """ Callback to store string as hex values """
            value = int(str(setting.value), 16)
            setattr(obj, atrb, value)
            return

        def unpack_str(codestr):
            """Convert u8 DTMF array to a string: NOT a callback."""
            stx = ""
            for i in range(0, 24):  # unpack up to ff
                if codestr[i] != 0xff:  # Issue  8159 fix
                    if codestr[i] == 0x0E:
                        stx += "*"
                    elif codestr[i] == 0x0F:
                        stx += "#"
                    else:
                        stx += format(int(codestr[i]), '0X')
            return stx

        def pack_chars(setting, obj, atrb, ndx):
            """Callback to build 0-9,A-D,*# nibble array from string"""
            # String will be f padded to 24 bytes
            # Chars are stored as hex values
            ary = []
            stx = str(setting.value).upper()
            stx = stx.strip()  # trim spaces
            # Remove illegal characters first
            sty = ""
            for j in range(0, len(stx)):
                if stx[j] in MDTMF_CHARS:
                    sty += stx[j]
            for j in range(0, 24):
                if j < len(sty):  # Issue 8159 fix
                    if sty[j] == "*":
                        chrv = 0xE
                    elif sty[j] == "#":
                        chrv = 0xF
                    else:
                        chrv = int(sty[j], 16)
                else:  # pad to 24 bytes
                    chrv = 0xFF
                ary.append(chrv)  # append byte
            setattr(obj[ndx], atrb, ary)
            return

        def myset_comment(setting, obj, atrb, knt):
            """ Callback to create space-padded char array"""
            stx = str(setting.value)
            for i in range(0, knt):
                if i > len(stx):
                    str.append(0x20)
            setattr(obj, atrb, stx)
            return

        def myset_psnam(setting, obj, ndx, atrb, knt):
            """ Callback to generate space-padded, uppercase char array """
            # This sub also is specific to object arrays
            stx = str(setting.value).upper()
            for i in range(0, knt):
                if i > len(stx):
                    str.append(0x20)
            setattr(obj[ndx], atrb, stx)
            return

        def myset_frqflgs(setting, obj, ndx, flg, frq):
            """ Callback to gen flag/freq pairs """
            vfrq = float(str(setting.value))
            vfrq = int(vfrq * 1000000)
            vflg = 0x10
            if vfrq % 6250 == 0:
                vflg = 0x08
                vfrq = int(vfrq / 6250)
            elif vfrq % 5000 == 0:
                vflg = 0
                vfrq = int(vfrq / 5000)
            else:
                vfrq = int(vfrq / 8333)
            setattr(obj[ndx], flg, vflg)
            setattr(obj[ndx], frq, vfrq)
            return

        def banklink(ary):
            """ Sub to generate A-J string from 2-byte bit pattern """
            stx = ""
            for kx in range(0, 10):
                if kx < 8:
                    val = ary[0]
                    msk = 1 << kx
                else:
                    val = ary[1]
                    msk = 1 << (kx - 8)
                if val & msk:
                    stx += chr(kx + 65)
                else:
                    stx += "_"
            return stx

        def myset_banklink(setting, obj, atrb):
            """Callback to create 10-bit, u8[2] array from 10 char string"""
            stx = str(setting.value).upper()
            ary = [0, 0]
            for kx in range(0, 10):
                if stx[kx] == chr(kx + 65):
                    if kx < 8:
                        ary[0] = ary[0] + (1 << kx)
                    else:
                        ary[1] = ary[1] + (1 << (kx - 8))
            setattr(obj, atrb, ary)
            return

        def myset_tsopt(setting, obj, ndx, atrb, bx):
            """ Callback to set scan Edge tstep """
            stx = str(setting.value)
            flg = 0
            if stx == "-":
                val = 0xff
            else:
                if bx == 1:  # Air band
                    if stx == "Auto":
                        val = 0xe
                    elif stx == "25k":
                        val = 8
                    elif stx == "8.33k":
                        val = 2
                else:  # VHF or UHF
                    optx = [
                        "-", "5k", "6.25k", "10k", "12.5k", "15k", "20k",
                        "25k", "30k", "50k"
                    ]
                    val = optx.index(stx) + 1
            setattr(obj[ndx], atrb, val)
            # and set flag
            setattr(obj[ndx], "flag", flg)
            return

        def myset_mdopt(setting, obj, ndx, atrb, bx):
            """ Callback to set Scan Edge mode """
            stx = str(setting.value)
            if stx == "-":
                val = 0xf
            elif stx == "FM":
                val = 0
            else:
                val = 1
            setattr(obj[ndx], atrb, val)
            return

        def myset_bitmask(setting, obj, ndx, atrb, knt):
            """ Callback to gnerate byte-array bitmask from string"""
            # knt is BIT count to process
            lsx = str(setting.value).strip().split(",")
            for kx in range(0, len(lsx)):
                try:
                    lsx[kx] = int(lsx[kx])
                except Exception:
                    lsx[kx] = -99  # will nop
            ary = [0, 0, 0, 0xfe]
            for kx in range(0, knt):
                if kx < 8:
                    if kx in lsx:
                        ary[0] += 1 << kx
                elif kx >= 8 and kx < 16:
                    if kx in lsx:
                        ary[1] += 1 << (kx - 8)
                elif kx >= 16 and kx < 24:
                    if kx in lsx:
                        ary[2] += 1 << (kx - 16)
                else:
                    if kx in lsx:  # only bit 25
                        ary[3] += 1
            setattr(obj[ndx], atrb, ary)
            return

        # --- Basic
        options = ["Off", "S-Meter Squelch", "ATT"]
        rx = RadioSettingValueList(options, options[_sets.sqlatt])
        rset = RadioSetting("settings.sqlatt", "Squelch/ATT", rx)
        basic.append(rset)

        options = ["Short", "Long"]
        rx = RadioSettingValueList(options, options[_sets.sqldly])
        rset = RadioSetting("settings.sqldly", "Squelch Delay", rx)
        basic.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.pttlock))
        rset = RadioSetting("settings.pttlock", "PTT Lockout", rx)
        basic.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.bcl))
        rset = RadioSetting("settings.bcl", "Busy Channel Lockout", rx)
        basic.append(rset)

        options = ["Off", "1m", "3m", "5m", "10m", "15m", "30m"]
        rx = RadioSettingValueList(options, options[_sets.tot])
        rset = RadioSetting("settings.tot", "Tx Timeout", rx)
        basic.append(rset)

        val = int(_sets.vfohome)
        if val == 0xffff:
            val = 0
        val = val / 1000000.0
        rx = RadioSettingValueFloat(0.0, 550.0, val, 0.005, 4)
        rx.set_mutable(False)
        rset = RadioSetting("settings.vfohome", "Home VFO (Read-Only)", rx)
        basic.append(rset)

        val = _sets.homech
        if val == 0xffff:
            val = -1
        rx = RadioSettingValueInteger(-1, 999, val)
        rx.set_mutable(False)
        rset = RadioSetting("settings.homech", "Home Channel (Read-Only)", rx)
        basic.append(rset)

        options = ["1", "2", "3", "4"]
        rx = RadioSettingValueList(options, options[_sets.micgain])
        rset = RadioSetting("settings.micgain", "Microphone Gain", rx)
        basic.append(rset)

        _bmem = self._memobj.initmem
        rx = RadioSettingValueInteger(0, 999, _bmem.left_memory)
        rset = RadioSetting("initmem.left_memory",
                            "Left Bank Initial Mem Chan", rx)
        basic.append(rset)

        rx = RadioSettingValueInteger(0, 999, _bmem.right_memory)
        rset = RadioSetting("initmem.right_memory",
                            "Right Bank Initial Mem Chan", rx)
        basic.append(rset)

        stx = ""
        for i in range(0, 16):
            stx += chr(_cmnt.com[i])
        stx = stx.rstrip()
        rx = RadioSettingValueString(0, 16, stx)
        rset = RadioSetting("comment.com", "Comment (16 chars)", rx)
        rset.set_apply_callback(myset_comment, _cmnt, "com", 16)
        basic.append(rset)

        # --- Other
        rset = RadioSetting("drv_clone_speed", "Use Hi-Speed Clone",
                            RadioSettingValueBoolean(self._can_hispeed))
        other.append(rset)

        options = ["Single", "All", "Ham"]
        rx = RadioSettingValueList(options, options[_sets.actband])
        rset = RadioSetting("settings.actband", "Active Band", rx)
        other.append(rset)

        options = ["Slow", "Mid", "Fast", "Auto"]
        rx = RadioSettingValueList(options, options[_sets.fanspeed])
        rset = RadioSetting("settings.fanspeed", "Fan Speed", rx)
        other.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.dialspdup))
        rset = RadioSetting("settings.dialspdup", "Dial Speed-Up", rx)
        other.append(rset)

        options = ["Off", "On(Dup)", "On(Dup+Tone)"]
        rx = RadioSettingValueList(options, options[_sets.autorptr])
        rset = RadioSetting("settings.autorptr", "Auto Repeater", rx)
        other.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.rmtmic))
        rset = RadioSetting("settings.rmtmic", "One-Touch PTT (Remote Mic)",
                            rx)
        other.append(rset)

        options = ["Low", "Mid", "High"]
        rx = RadioSettingValueList(options, options[_sets.vhfpower])
        rset = RadioSetting("settings.vhfpower", "VHF Power Default", rx)
        other.append(rset)

        rx = RadioSettingValueList(options, options[_sets.uhfpower])
        rset = RadioSetting("settings.uhfpower", "UHF Power Default", rx)
        other.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.toneburst))
        rset = RadioSetting("settings.toneburst", "1750 Htz Tone Burst", rx)
        other.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.ifxchg))
        rset = RadioSetting("settings.ifxchg", "IF Exchange", rx)
        other.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.rpthangup))
        rset = RadioSetting("settings.rpthangup", "Repeater Hang up Timeout",
                            rx)
        other.append(rset)

        stx = str(_sets.civaddr)[2:]  # Hex value
        rx = RadioSettingValueString(1, 2, stx)
        rset = RadioSetting("settings.civaddr", "CI-V Address (90)", rx)
        rset.set_apply_callback(hex_val, _sets, "civaddr")
        other.append(rset)

        options = ["1200", "2400", "4800", "9600", "19200", "Auto"]
        rx = RadioSettingValueList(options, options[_sets.civbaud])
        rset = RadioSetting("settings.civbaud", "CI-V Baud Rate (bps)", rx)
        other.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.civtcvr))
        rset = RadioSetting("settings.civtcvr", "CI-V Transceive", rx)
        other.append(rset)

        # A/B Band Settings
        options = ["Off", "On", "Bell"]
        rx = RadioSettingValueList(options, options[_sets.aprichn])
        rset = RadioSetting("settings.aprichn",
                            "A Band: VFO Priority Watch Mode", rx)
        abset.append(rset)

        options = [
            "2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "Hold"
        ]
        rx = RadioSettingValueList(options, options[_sets.ascanpause])
        rset = RadioSetting("settings.ascanpause",
                            "-- A Band: Scan Pause Time (Secs)", rx)
        abset.append(rset)

        options = ["0", "1", "2", "3", "4", "5", "Hold"]
        rx = RadioSettingValueList(options, options[_sets.ascanresume])
        rset = RadioSetting("settings.ascanresume",
                            "-- A Band: Scan Resume Time (Secs)", rx)
        abset.append(rset)

        options = ["5", "10", "15"]
        rx = RadioSettingValueList(options, options[_sets.atmpskiptym])
        rset = RadioSetting("settings.atmpskiptym",
                            "-- A Band: Temp Skip Time (Secs)", rx)
        abset.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.aprgskpscn))
        rset = RadioSetting("settings.aprgskpscn",
                            "-- A Band: Program Skip Scan", rx)
        abset.append(rset)

        rx = RadioSettingValueString(10, 10, banklink(_bklk.alnk))
        rset = RadioSetting("banklink.alnk",
                            "-- A Band Banklink (use _ to skip)", rx)
        rset.set_apply_callback(myset_banklink, _bklk, "alnk")
        abset.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.awxalert))
        rset = RadioSetting("settings.awxalert", "-- A Band: Weather Alert",
                            rx)
        abset.append(rset)

        # Use list for Wx chans since chan 1 = index 0
        options = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
        rx = RadioSettingValueList(options, options[_wxch.awxchan])
        rset = RadioSetting("abwx.awxchan", "-- A Band: Weather Channel", rx)
        abset.append(rset)

        options = ["Off", "On", "Bell"]
        rx = RadioSettingValueList(options, options[_sets.bprichn])
        rset = RadioSetting("settings.bprichn",
                            "B Band: VFO Priority Watch Mode", rx)
        abset.append(rset)

        options = [
            "2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "Hold"
        ]
        rx = RadioSettingValueList(options, options[_sets.bscanpause])
        rset = RadioSetting("settings.bscanpause",
                            "-- B Band: Scan Pause Time (Secs)", rx)
        abset.append(rset)

        options = ["0", "1", "2", "3", "4", "5", "Hold"]
        rx = RadioSettingValueList(options, options[_sets.bscanresume])
        rset = RadioSetting("settings.bscanresume",
                            "-- B Band: Scan Resume Time (Secs)", rx)
        abset.append(rset)

        options = ["5", "10", "15"]
        rx = RadioSettingValueList(options, options[_sets.btmpskiptym])
        rset = RadioSetting("settings.btmpskiptym",
                            "-- B Band: Temp Skip Time (Secs)", rx)
        abset.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.bprgskpscn))
        rset = RadioSetting("settings.bprgskpscn",
                            "-- B Band: Program Skip Scan", rx)
        abset.append(rset)

        rx = RadioSettingValueString(10, 10, banklink(_bklk.blnk))
        rset = RadioSetting("banklink.blnk",
                            "-- B Band Banklink (use _ to skip)", rx)
        rset.set_apply_callback(myset_banklink, _bklk, "blnk")
        abset.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.bwxalert))
        rset = RadioSetting("settings.bwxalert", "-- B Band: Weather Alert",
                            rx)
        abset.append(rset)

        options = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
        rx = RadioSettingValueList(options, options[_wxch.bwxchan])
        rset = RadioSetting("abwx.bwxchan", "-- B Band: Weather Channel", rx)
        abset.append(rset)

        # --- Microphone Keys
        # The Mic keys get wierd: stored values are indecis to the full
        # options list, but only a subset is valid...
        shortopts = [
            "Off", "Monitor", "MR (Ch 0)", "MR (Ch 1)", "Band/Bank", "Scan",
            "Temp Skip", "Mode", "Low", "Dup", "Priority", "Tone", "MW",
            "Mute", "DTMF Direct", "T-Call"
        ]
        ptr = shortopts.index(MICKEYOPTS[_sets.mickyrxf1])
        rx = RadioSettingValueList(shortopts, shortopts[ptr])
        rset = RadioSetting("settings.mickyrxf1", "During Rx/Standby [F-1]",
                            rx)
        rset.set_apply_callback(mic_keys, _sets, "mickyrxf1")
        mickey.append(rset)

        ptr = shortopts.index(MICKEYOPTS[_sets.mickyrxf2])
        rx = RadioSettingValueList(shortopts, shortopts[ptr])
        rset = RadioSetting("settings.mickyrxf2", "During Rx/Standby [F-2]",
                            rx)
        rset.set_apply_callback(mic_keys, _sets, "mickyrxf2")
        mickey.append(rset)

        options = ["Off", "Low", "T-Call"]  # NOT a subset of MICKEYOPTS
        rx = RadioSettingValueList(options, options[_sets.mickytxf1])
        rset = RadioSetting("settings.mickytxf1", "During Tx [F-1]", rx)
        mickey.append(rset)

        rx = RadioSettingValueList(options, options[_sets.mickytxf2])
        rset = RadioSetting("settings.mickytxf2", "During Tx [F-2]", rx)
        mickey.append(rset)

        # These next two get the full options list
        rx = RadioSettingValueList(MICKEYOPTS, MICKEYOPTS[_sets.mickyrxup])
        rset = RadioSetting("settings.mickyrxup", "During Rx/Standby [Up]", rx)
        mickey.append(rset)

        rx = RadioSettingValueList(MICKEYOPTS, MICKEYOPTS[_sets.mickyrxdn])
        rset = RadioSetting("settings.mickyrxdn", "During Rx/Standby [Down]",
                            rx)
        mickey.append(rset)

        options = ["Off", "Low", "T-Call"]
        rx = RadioSettingValueList(options, options[_sets.mickytxup])
        rset = RadioSetting("settings.mickytxup", "During Tx [Up]", rx)
        mickey.append(rset)

        rx = RadioSettingValueList(options, options[_sets.mickytxdn])
        rset = RadioSetting("settings.mickytxdn", "During Tx [Down]", rx)
        mickey.append(rset)

        # --- Bluetooth
        rx = RadioSettingValueBoolean(bool(_sets.btoothon))
        rset = RadioSetting("settings.btoothon", "Bluetooth", rx)
        bluet.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.btoothauto))
        rset = RadioSetting("settings.btoothauto", "Auto Connect", rx)
        bluet.append(rset)

        options = ["Headset Only", "Headset & Speaker"]
        rx = RadioSettingValueList(options, options[_sets.bthdset])
        rset = RadioSetting("settings.bthdset", "Headset Audio", rx)
        bluet.append(rset)

        options = [
            "Normal", "Microphone", "PTT (Audio:Main)", "PTT(Audio:Controller)"
        ]
        rx = RadioSettingValueList(options, options[_sets.bthfctn])
        rset = RadioSetting("settings.bthfctn", "Headset Function", rx)
        bluet.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.bthvox))
        rset = RadioSetting("settings.bthvox", "Vox", rx)
        bluet.append(rset)

        options = ["Off", "1.0", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
        rx = RadioSettingValueList(options, options[_sets.bthvoxlvl])
        rset = RadioSetting("settings.bthvoxlvl", "Vox Level", rx)
        bluet.append(rset)

        options = ["0.5", "1.0", "1.5", "2.0", "2.5", "3.0"]
        rx = RadioSettingValueList(options, options[_sets.bthvoxdly])
        rset = RadioSetting("settings.bthvoxdly", "Vox Delay (Secs)", rx)
        bluet.append(rset)

        options = ["Off", "1", "2", "3", "4", "5", "10", "15"]
        rx = RadioSettingValueList(options, options[_sets.bthvoxtot])
        rset = RadioSetting("settings.bthvoxtot", "Vox Time-Out (Mins)", rx)
        bluet.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.bthhdpsav))
        rset = RadioSetting("settings.bthhdpsav", "ICOM Headset Power-Save",
                            rx)
        bluet.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.bth1ptt))
        rset = RadioSetting("settings.bth1ptt", "ICOM Headset One-Touch PTT",
                            rx)
        bluet.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.bthpttbeep))
        rset = RadioSetting("settings.bthpttbeep", "ICOM Headset PTT Beep", rx)
        bluet.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.bthcustbeep))
        rset = RadioSetting("settings.bthcustbeep",
                            "ICOM Headset Custom Key Beep", rx)
        bluet.append(rset)

        rx = RadioSettingValueList(MICKEYOPTS, MICKEYOPTS[_sets.bthplaykey])
        rset = RadioSetting("settings.bthplaykey",
                            "ICOM Headset Custom Key [Play]", rx)
        bluet.append(rset)

        rx = RadioSettingValueList(MICKEYOPTS, MICKEYOPTS[_sets.bthfwdkey])
        rset = RadioSetting("settings.bthfwdkey",
                            "ICOM Headset Custom Key [Fwd]", rx)
        bluet.append(rset)

        rx = RadioSettingValueList(MICKEYOPTS, MICKEYOPTS[_sets.bthrwdkey])
        rset = RadioSetting("settings.bthrwdkey",
                            "ICOM Headset Custom Key [Rwd]", rx)
        bluet.append(rset)

        # ---- Display
        options = ["1: Dark", "2", "3", "4: Bright"]
        rx = RadioSettingValueList(options, options[_sets.backlight])
        rset = RadioSetting("settings.backlight", "Backlight Level", rx)
        disp.append(rset)

        options = ["Off", "Auto-Off", "Auto-1", "Auto-2", "Auto-3"]
        rx = RadioSettingValueList(options, options[_sets.autodim])
        rset = RadioSetting("settings.autodim", "Auto Dimmer", rx)
        disp.append(rset)

        options = ["5", "10"]
        rx = RadioSettingValueList(options, options[_sets.autodimtot])
        rset = RadioSetting("settings.autodimtot",
                            "Auto-Dimmer Timeout (Secs)", rx)
        disp.append(rset)

        options = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
        rx = RadioSettingValueList(options, options[_sets.contrast])
        rset = RadioSetting("settings.contrast", "LCD Contrast", rx)
        disp.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.openmsg))
        rset = RadioSetting("settings.openmsg", "Opening Message", rx)
        disp.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.memname))
        rset = RadioSetting("settings.memname", "Memory Names", rx)
        disp.append(rset)

        options = ["CH ID", "Frequency"]
        rx = RadioSettingValueList(options, options[_sets.airbandch])
        rset = RadioSetting("settings.airbandch", "Air Band Display", rx)
        disp.append(rset)

        # -- Sounds
        rx = RadioSettingValueInteger(0, 9, _sets.beeplvl)
        rset = RadioSetting("settings.beeplvl", "Beep Level", rx)
        sound.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.homebeep))
        rset = RadioSetting("settings.homebeep", "Home Chan Beep", rx)
        sound.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.keybeep))
        rset = RadioSetting("settings.keybeep", "Key Touch Beep", rx)
        sound.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.bandedgbeep))
        rset = RadioSetting("settings.bandedgbeep", "Band Edge Beep", rx)
        sound.append(rset)

        rx = RadioSettingValueBoolean(bool(_sets.scanstpbeep))
        rset = RadioSetting("settings.scanstpbeep", "Scan Stop Beep", rx)
        sound.append(rset)

        options = ["Off", "Mute", "Beep", "Mute & Beep"]
        rx = RadioSettingValueList(options, options[_sets.subandmute])
        rset = RadioSetting("settings.subandmute", "Sub Band Mute", rx)
        sound.append(rset)

        # --- DTMF Codes
        options = ["100", "200", "300", "500"]
        rx = RadioSettingValueList(options, options[_sets.dtmfspd])
        rset = RadioSetting("settings.dtmfspd", "DTMF Speed (mSecs)", rx)
        dtmf.append(rset)

        for kx in range(0, 16):
            stx = unpack_str(_dtm[kx].codes)
            rx = RadioSettingValueString(0, 24, stx)
            # NOTE the / to indicate indexed array
            rset = RadioSetting("dtmfcode/%d.codes" % kx, "DTMF Code %X" % kx,
                                rx)
            rset.set_apply_callback(pack_chars, _dtm, "codes", kx)
            dtmf.append(rset)

        # --- Program Scan Edges
        for kx in range(0, 25):
            stx = ""
            for i in range(0, 6):
                stx += chr(_pses[kx].name[i])
            stx = stx.rstrip()
            rx = RadioSettingValueString(0, 6, stx)
            rset = RadioSetting("pgmscanedge/%d.name" % kx,
                                "Program Scan %d Name" % kx, rx)
            rset.set_apply_callback(myset_psnam, _pses, kx, "name", 6)
            edges.append(rset)

            # Freq's use the multiplier flags
            fmult = 5000.0
            if _pses[kx].loflags == 0x10:
                fmult = 8333
            if _pses[kx].loflags == 0x08:
                fmult = 6250.0
            flow = (int(_pses[kx].lofreq) * fmult) / 1000000.0
            flow = round(flow, 4)

            fmult = 5000.0
            if _pses[kx].hiflags == 0x10:
                fmult = 8333
            if _pses[kx].hiflags == 0x08:
                fmult = 6250.0
            fhigh = (int(_pses[kx].hifreq) * fmult) / 1000000.0
            fhigh = round(fhigh, 4)
            if (flow > 0) and (flow >= fhigh):  # reverse em
                val = flow
                flow = fhigh
                fhigh = val
            rx = RadioSettingValueFloat(0, 550.0, flow, 0.010, 3)
            rset = RadioSetting("pgmscanedge/%d.lofreq" % kx,
                                "-- Scan %d Low Limit" % kx, rx)
            rset.set_apply_callback(myset_frqflgs, _pses, kx, "loflags",
                                    "lofreq")
            edges.append(rset)

            rx = RadioSettingValueFloat(0, 550.0, fhigh, 0.010, 3)
            rset = RadioSetting("pgmscanedge/%d.hifreq" % kx,
                                "-- Scan %d High Limit" % kx, rx)
            rset.set_apply_callback(myset_frqflgs, _pses, kx, "hiflags",
                                    "hifreq")
            edges.append(rset)

            # Tstep and Mode depend on the bands
            ndxt = 0
            ndxm = 0
            bxnd = 0
            tsopt = [
                "-", "5k", "6.25k", "10k", "12.5k", "15k", "20k", "25k", "30k",
                "50k"
            ]
            mdopt = ["-", "FM", "FM-N"]
            if fhigh > 0:
                if fhigh < 135.0:  # Air band
                    bxnd = 1
                    tsopt = ["-", "8.33k", "25k", "Auto"]
                    ndxt = _pses[kx].tstp
                    if ndxt == 0xe:  # Auto
                        ndxt = 3
                    elif ndxt == 8:  # 25k
                        ndxt = 2
                    elif ndxt == 2:  # 8.33k
                        ndxt = 1
                    else:
                        ndxt = 0
                    mdopt = ["-"]
                elif (flow >= 137.0) and (fhigh <= 174.0):  # VHF
                    ndxt = _pses[kx].tstp - 1
                    ndxm = _pses[kx].mode + 1
                    bxnd = 2
                elif (flow >= 375.0) and (fhigh <= 550.0):  # UHF
                    ndxt = _pses[kx].tstp - 1
                    ndxm = _pses[kx].mode + 1
                    bxnd = 3
                else:  # Mixed, ndx's = 0 default
                    tsopt = ["-"]
                    mdopt = ["-"]
                    bxnd = 4
                if (ndxt > 9) or (ndxt < 0):
                    ndxt = 0  # trap ff
                if ndxm > 2:
                    ndxm = 0
            # end if fhigh > 0
            rx = RadioSettingValueList(tsopt, tsopt[ndxt])
            rset = RadioSetting("pgmscanedge/%d.tstp" % kx,
                                "-- Scan %d Freq Step" % kx, rx)
            rset.set_apply_callback(myset_tsopt, _pses, kx, "tstp", bxnd)
            edges.append(rset)

            rx = RadioSettingValueList(mdopt, mdopt[ndxm])
            rset = RadioSetting("pgmscanedge/%d.mode" % kx,
                                "-- Scan %d Mode" % kx, rx)
            rset.set_apply_callback(myset_mdopt, _pses, kx, "mode", bxnd)
            edges.append(rset)
        # End for kx

        # --- Program Scan Links
        _psln = self._memobj.pslnam
        _pslg = self._memobj.pslgrps
        for kx in range(0, 10):
            stx = ""
            for i in range(0, 6):
                stx += chr(_psln[kx].nam[i])
            stx = stx.rstrip()
            rx = RadioSettingValueString(0, 6, stx)
            rset = RadioSetting("pslnam/%d.nam" % kx,
                                "Program Scan Link %d Name" % kx, rx)
            rset.set_apply_callback(myset_psnam, _psln, kx, "nam", 6)
            pslnk.append(rset)

            for px in range(0, 25):
                # Generate string numeric representation of 4-byte bitmask
                stx = ""
                for nx in range(0, 25):
                    if nx < 8:
                        if (_pslg[kx].msk[0] & (1 << nx)):
                            stx += "%0d, " % nx
                    elif (nx >= 8) and (nx < 16):
                        if (_pslg[kx].msk[1] & (1 << (nx - 8))):
                            sstx += "%0d, " % nx
                    elif (nx >= 16) and (nx < 24):
                        if (_pslg[kx].msk[2] & (1 << (nx - 16))):
                            stx += "%0d, " % nx
                    elif (nx >= 24):
                        if (_pslg[kx].msk[3] & (1 << (nx - 24))):
                            stx += "%0d, " % nx
            rx = RadioSettingValueString(0, 80, stx)
            rset = RadioSetting("pslgrps/%d.msk" % kx,
                                "--- Scan Link %d Scans" % kx, rx)
            rset.set_apply_callback(myset_bitmask, _pslg, kx, "msk", 25)
            pslnk.append(rset)
            # end for px
        # End for kx
        return group  # END get_settings()
Beispiel #15
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")
        top = RadioSettings(basic)

        # TODO: Check that all these settings actually do what they
        # say they do.

        rs = RadioSetting("voiceprompt", "Voice prompt",
                          RadioSettingValueBoolean(_settings.voiceprompt))
        basic.append(rs)

        rs = RadioSetting(
            "voicelanguage", "Voice language",
            RadioSettingValueList(VOICE_LIST,
                                  VOICE_LIST[_settings.voicelanguage]))
        basic.append(rs)

        rs = RadioSetting("scan", "Scan",
                          RadioSettingValueBoolean(_settings.scan))
        basic.append(rs)

        rs = RadioSetting(
            "settings2.scanmode", "Scan mode",
            RadioSettingValueList(
                SCANMODE_LIST, SCANMODE_LIST[self._memobj.settings2.scanmode]))
        basic.append(rs)

        rs = RadioSetting("vox", "VOX",
                          RadioSettingValueBoolean(_settings.vox))
        basic.append(rs)

        rs = RadioSetting(
            "voxlevel", "VOX level",
            RadioSettingValueInteger(1, 5, _settings.voxlevel + 1))
        basic.append(rs)

        rs = RadioSetting("voxinhibitonrx", "Inhibit VOX on receive",
                          RadioSettingValueBoolean(_settings.voxinhibitonrx))
        basic.append(rs)

        rs = RadioSetting("lowvolinhibittx", "Low voltage inhibit transmit",
                          RadioSettingValueBoolean(_settings.lowvolinhibittx))
        basic.append(rs)

        rs = RadioSetting("highvolinhibittx", "High voltage inhibit transmit",
                          RadioSettingValueBoolean(_settings.highvolinhibittx))
        basic.append(rs)

        rs = RadioSetting("alarm", "Alarm",
                          RadioSettingValueBoolean(_settings.alarm))
        basic.append(rs)

        # TODO: This should probably be called “FM Broadcast Band Radio”
        # or something. I'm not sure if the model actually has one though.
        rs = RadioSetting("fmradio", "FM function",
                          RadioSettingValueBoolean(_settings.fmradio))
        basic.append(rs)

        rs = RadioSetting(
            "settings2.beep", "Beep",
            RadioSettingValueBoolean(self._memobj.settings2.beep))
        basic.append(rs)

        rs = RadioSetting(
            "settings2.batterysaver", "Battery saver",
            RadioSettingValueBoolean(self._memobj.settings2.batterysaver))
        basic.append(rs)

        rs = RadioSetting(
            "settings2.squelchlevel", "Squelch level",
            RadioSettingValueInteger(0, 9,
                                     self._memobj.settings2.squelchlevel))
        basic.append(rs)

        rs = RadioSetting(
            "settings2.sidekeyfunction", "Side key function",
            RadioSettingValueList(
                SIDEKEYFUNCTION_LIST,
                SIDEKEYFUNCTION_LIST[self._memobj.settings2.sidekeyfunction]))
        basic.append(rs)

        rs = RadioSetting(
            "settings2.timeouttimer", "Timeout timer",
            RadioSettingValueList(
                TIMEOUTTIMER_LIST,
                TIMEOUTTIMER_LIST[self._memobj.settings2.timeouttimer]))
        basic.append(rs)

        return top
Beispiel #16
0
    def get_settings(self):
        common = RadioSettingGroup("common", "Common Settings")
        band = RadioSettingGroup("band", "Band dependent Settings")
        arts = RadioSettingGroup("arts",
                                 "Auto Range Transponder System (ARTS)")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        mic_button = RadioSettingGroup("mic_button", "Microphone Buttons")
        setmode = RadioSettings(common, band, arts, dtmf, mic_button)

        _overlay = self._memobj.overlay

        # numbers and names of settings refer to the way they're
        # presented in the set menu, as well as the list starting on
        # page 49 of the manual

        # 1 Automatic Power Off
        opts = [
            "Off",
            "30 Min",
            "1 Hour",
            "1.5 Hours",
            "2 Hours",
            "2.5 Hours",
            "3 Hours",
            "3.5 Hours",
            "4 Hours",
            "4.5 Hours",
            "5 Hours",
            "5.5 Hours",
            "6 Hours",
            "6.5 Hours",
            "7 Hours",
            "7.5 Hours",
            "8 Hours",
            "8.5 Hours",
            "9 Hours",
            "9.5 Hours",
            "10 Hours",
            "10.5 Hours",
            "11 Hours",
            "11.5 Hours",
            "12 Hours",
        ]
        common.append(
            RadioSetting("apo", "Automatic Power Off",
                         RadioSettingValueList(opts, opts[_overlay.apo])))

        # 2 Automatic Repeater Shift function
        opts = ["Off", "On"]
        band.append(
            RadioSetting("ars_vhf", "Automatic Repeater Shift VHF",
                         RadioSettingValueList(opts, opts[_overlay.ars_vhf])))
        band.append(
            RadioSetting("ars_uhf", "Automatic Repeater Shift UHF",
                         RadioSettingValueList(opts, opts[_overlay.ars_uhf])))

        # 3  Selects the ARTS mode.
        # -> Only useful to set it on the radio directly

        # 4 Enables/disables the key/button beeper.
        opts = ["Off", "On"]
        common.append(
            RadioSetting("beep", "Key/Button Beep",
                         RadioSettingValueList(opts, opts[_overlay.beep])))

        # 5 Enables/disables the CW IDer during ARTS operation.
        opts = ["Off", "On"]
        arts.append(
            RadioSetting("cwid", "Enables/Disables the CW ID",
                         RadioSettingValueList(opts, opts[_overlay.cwid])))

        # 6  Callsign during ARTS operation.
        cwidw = _overlay.cwidw.get_raw()
        cwidw = cwidw.rstrip('\x00')
        val = RadioSettingValueString(0, 6, cwidw)
        val.set_charset(CHARSET)
        rs = RadioSetting("cwidw", "CW Identifier Callsign", val)

        def apply_cwid(setting):
            value_string = setting.value.get_value()
            _overlay.cwidw.set_value(value_string)

        rs.set_apply_callback(apply_cwid)
        arts.append(rs)

        # 7 Front panel display's illumination level.
        opts = ["0: Off", "1: Max", "2", "3", "4", "5", "6", "7: Min"]
        common.append(
            RadioSetting("dim", "Display Illumination",
                         RadioSettingValueList(opts, opts[_overlay.dim])))

        # 8 Setting the DCS code number.
        #   Note: This Menu item can be set independently for each band,
        #         and independently in each memory.

        # 9 Activates the DCS Code Search
        # -> Only useful if set on radio itself

        # 10 Selects 'Normal' or 'Inverted' DCS coding.
        opts = ["TRX Normal", "RX Reversed", "TX Reversed", "TRX Reversed"]
        band.append(
            RadioSetting("dcsnr_vhf", "DCS coding VHF",
                         RadioSettingValueList(opts,
                                               opts[_overlay.dcsnr_vhf])))
        band.append(
            RadioSetting("dcsnr_uhf", "DCS coding UHF",
                         RadioSettingValueList(opts,
                                               opts[_overlay.dcsnr_uhf])))

        # 11 Selects the 'sub' band display format
        opts = [
            "Frequency", "Off / Sub Band disabled", "DC Input Voltage", "CW ID"
        ]
        common.append(
            RadioSetting("disp", "Sub Band Display Format",
                         RadioSettingValueList(opts, opts[_overlay.disp])))

        # 12 Setting the DTMF Autodialer delay time
        opts = ["50 ms", "250 ms", "450 ms", "750 ms", "1 s"]
        dtmf.append(
            RadioSetting("dtmfd", "Autodialer delay time",
                         RadioSettingValueList(opts, opts[_overlay.dtmfd])))

        # 13 Setting the DTMF Autodialer sending speed
        opts = ["50 ms", "75 ms", "100 ms"]
        dtmf.append(
            RadioSetting("dtmfs", "Autodialer sending speed",
                         RadioSettingValueList(opts, opts[_overlay.dtmfs])))

        # 14 Current DTMF Autodialer memory
        rs = RadioSetting("dtmfw", "Current Autodialer memory",
                          RadioSettingValueInteger(1, 16, _overlay.dtmfw + 1))

        def apply_dtmfw(setting):
            _overlay.dtmfw = setting.value.get_value() - 1

        rs.set_apply_callback(apply_dtmfw)
        dtmf.append(rs)

        # DTMF Memory
        for i in range(16):
            dtmf_string = ""
            for j in range(16):
                dtmf_char = ''
                dtmf_int = int(self._memobj.dtmf_mem[i].dtmf[j])
                if dtmf_int < 10:
                    dtmf_char = str(dtmf_int)
                elif dtmf_int == 14:
                    dtmf_char = '*'
                elif dtmf_int == 15:
                    dtmf_char = '#'
                elif dtmf_int == 255:
                    break
                dtmf_string += dtmf_char
            radio_setting_value_string = RadioSettingValueString(
                0, 16, dtmf_string)
            radio_setting_value_string.set_charset(DTMF_CHARSET)
            rs = RadioSetting("dtmf_{0:02d}".format(i),
                              "DTMF Mem " + str(i + 1),
                              radio_setting_value_string)

            def apply_dtmf(setting, index):
                radio_setting_value_string = setting.value.get_value().rstrip()
                j = 0
                for dtmf_char in radio_setting_value_string:
                    dtmf_int = 255
                    if dtmf_char in "0123456789":
                        dtmf_int = int(dtmf_char)
                    elif dtmf_char == '*':
                        dtmf_int = 14
                    elif dtmf_char == '#':
                        dtmf_int = 15
                    if dtmf_int < 255:
                        self._memobj.dtmf_mem[index].dtmf[j] = dtmf_int
                        j += 1
                if j < 16:
                    self._memobj.dtmf_mem[index].dtmf[j] = 255

            rs.set_apply_callback(apply_dtmf, i)
            dtmf.append(rs)

        # 16 Enables/disables the PTT switch lock
        opts = ["Off", "Band A", "Band B", "Both"]
        common.append(
            RadioSetting("lockt", "PTT switch lock",
                         RadioSettingValueList(opts, opts[_overlay.lockt])))

        # 17 Selects the Microphone type to be used
        opts = ["MH-42", "MH-48"]
        common.append(
            RadioSetting("mic", "Microphone type",
                         RadioSettingValueList(opts, opts[_overlay.mic])))

        # 18 Reduces the audio level on the sub receiver when the
        #    main receiver is active
        opts = ["Off", "On"]
        common.append(
            RadioSetting("mute", "Mute Sub Receiver",
                         RadioSettingValueList(opts, opts[_overlay.mute])))

        # 20 - 23 Programming the microphones button assignment
        buttons = [
            "ACC / P1",
            "P / P2",
            "P1 / P3",
            "P2 / P4",
        ]
        opts_button = [
            "Low", "Tone", "MHz", "Rev", "Home", "Band", "VFO / Memory",
            "Sql Off", "1750 Hz Tone Call", "Repeater", "Priority"
        ]
        for i, button in enumerate(buttons):
            rs = RadioSetting(
                "button" + str(i), button,
                RadioSettingValueList(opts_button,
                                      opts_button[_overlay.button[i]]))

            def apply_button(setting, index):
                value_string = setting.value.get_value()
                value_int = opts_button.index(value_string)
                _overlay.button[index] = value_int

            rs.set_apply_callback(apply_button, i)
            mic_button.append(rs)

        # 24 Adjusts the RF SQL threshold level
        opts = ["Off", "S-1", "S-5", "S-9", "S-FULL"]
        band.append(
            RadioSetting(
                "rf_sql_vhf", "RF Sql VHF",
                RadioSettingValueList(opts, opts[_overlay.rf_sql_vhf])))
        band.append(
            RadioSetting(
                "rf_sql_uhf", "RF Sql UHF",
                RadioSettingValueList(opts, opts[_overlay.rf_sql_uhf])))

        # 25 Selects the Scan-Resume mode
        opts = ["Busy", "Time"]
        band.append(
            RadioSetting("scan_vhf", "Scan-Resume VHF",
                         RadioSettingValueList(opts, opts[_overlay.scan_vhf])))
        band.append(
            RadioSetting("scan_uhf", "Scan-Resume UHF",
                         RadioSettingValueList(opts, opts[_overlay.scan_uhf])))

        # 28 Defining the audio path to the external speaker
        opts = ["Off", "Band A", "Band B", "Both"]
        common.append(
            RadioSetting(
                "speaker_cnt", "External Speaker",
                RadioSettingValueList(opts, opts[_overlay.speaker_cnt])))

        # 31 Sets the Time-Out Timer
        opts = ["Off", "Band A", "Band B", "Both"]
        common.append(
            RadioSetting("tot", "TX Time-Out [Min.] (0 = Off)",
                         RadioSettingValueInteger(0, 30, _overlay.tot)))

        # 32 Reducing the MIC Gain (and Deviation)
        opts = ["Off", "On"]
        band.append(
            RadioSetting("txnar_vhf", "TX Narrowband VHF",
                         RadioSettingValueList(opts,
                                               opts[_overlay.txnar_vhf])))
        band.append(
            RadioSetting("txnar_uhf", "TX Narrowband UHF",
                         RadioSettingValueList(opts,
                                               opts[_overlay.txnar_uhf])))

        # 33 Enables/disables the VFO Tracking feature
        opts = ["Off", "On"]
        common.append(
            RadioSetting("vfotr", "VFO Tracking",
                         RadioSettingValueList(opts, opts[_overlay.vfotr])))

        # 34 Selects the receiving mode on the VHF band
        opts = ["Inhibit (only FM)", "AM", "Auto"]
        common.append(
            RadioSetting("am", "AM Mode",
                         RadioSettingValueList(opts, opts[_overlay.am])))

        # Current Band
        opts = ["VHF", "UHF"]
        common.append(
            RadioSetting(
                "current_band", "Current Band",
                RadioSettingValueList(opts, opts[_overlay.current_band])))

        # Show number of VHF and UHF channels
        val = RadioSettingValueString(0, 7,
                                      str(int(self._memobj.nb_mem_used_vhf)))
        val.set_mutable(False)
        rs = RadioSetting("num_chan_vhf", "Number of VHF channels", val)
        common.append(rs)
        val = RadioSettingValueString(0, 7,
                                      str(int(self._memobj.nb_mem_used_uhf)))
        val.set_mutable(False)
        rs = RadioSetting("num_chan_uhf", "Number of UHF channels", val)
        common.append(rs)

        return setmode
Beispiel #17
0
    def get_settings(self):
        _settings = self._memobj.settings

        group = RadioSettingGroup("basic", "Basic")
        top = RadioSettings(group)

        group.append(
            RadioSetting(
                "led", "LED Mode",
                RadioSettingValueList(LED_LIST, LED_LIST[_settings.led])))
        group.append(
            RadioSetting(
                "light", "Light Color",
                RadioSettingValueList(LIGHT_LIST,
                                      LIGHT_LIST[_settings.light])))

        group.append(
            RadioSetting("squelch", "Squelch Level",
                         RadioSettingValueInteger(0, 9, _settings.squelch)))

        group.append(
            RadioSetting(
                "vox_level", "VOX Level",
                RadioSettingValueList(VOX_LIST,
                                      VOX_LIST[_settings.vox_level])))

        group.append(
            RadioSetting("beep", "Beep",
                         RadioSettingValueBoolean(_settings.beep)))

        group.append(
            RadioSetting("ani", "ANI",
                         RadioSettingValueBoolean(_settings.ani)))

        group.append(
            RadioSetting("dwait", "D.WAIT",
                         RadioSettingValueBoolean(_settings.dwait)))

        group.append(
            RadioSetting(
                "tot", "Timeout Timer",
                RadioSettingValueList(TOT_LIST, TOT_LIST[_settings.tot])))

        group.append(
            RadioSetting("roger", "Roger Beep",
                         RadioSettingValueBoolean(_settings.roger)))

        group.append(
            RadioSetting("dw", "Dual Watch",
                         RadioSettingValueBoolean(_settings.dw)))

        group.append(
            RadioSetting("rxsave", "RX Save",
                         RadioSettingValueBoolean(_settings.rxsave)))

        group.append(
            RadioSetting(
                "scans", "Scans",
                RadioSettingValueList(SCANS_LIST,
                                      SCANS_LIST[_settings.scans])))

        group.append(
            RadioSetting("autolk", "Auto Lock",
                         RadioSettingValueBoolean(_settings.autolk)))

        group.append(
            RadioSetting("voice", "Voice",
                         RadioSettingValueBoolean(_settings.voice)))

        group.append(
            RadioSetting(
                "opnmsg", "Opening Message",
                RadioSettingValueList(OPNMSG_LIST,
                                      OPNMSG_LIST[_settings.opnmsg])))

        group.append(
            RadioSetting("disnm", "Display Name",
                         RadioSettingValueBoolean(_settings.disnm)))

        def _filter(name):
            LOG.debug(repr(str(name)))
            return str(name).rstrip("\xFF").rstrip()

        group.append(
            RadioSetting(
                "ponmsg", "Power-On Message",
                RadioSettingValueString(0, 6, _filter(_settings.ponmsg))))

        return top
Beispiel #18
0
    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
Beispiel #19
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")
        top = RadioSettings(basic)

        if self.MODEL == "RT21" or self.MODEL == "RB17A":
            _keys = self._memobj.keys

            rs = RadioSettingValueList(TIMEOUTTIMER_LIST,
                                       TIMEOUTTIMER_LIST[_settings.tot - 1])
            rset = RadioSetting("tot", "Time-out timer", rs)
            basic.append(rset)

            rs = RadioSettingValueList(TOTALERT_LIST,
                                       TOTALERT_LIST[_settings.totalert])
            rset = RadioSetting("totalert", "TOT Pre-alert", rs)
            basic.append(rset)

            rs = RadioSettingValueInteger(0, 9, _settings.squelch)
            rset = RadioSetting("squelch", "Squelch Level", rs)
            basic.append(rset)

            rs = RadioSettingValueList(VOICE_LIST, VOICE_LIST[_settings.voice])
            rset = RadioSetting("voice", "Voice Annumciation", rs)
            basic.append(rset)

            if self.MODEL == "RB17A":
                rs = RadioSettingValueList(ALARM_LIST,
                                           ALARM_LIST[_settings.alarm])
                rset = RadioSetting("alarm", "Alarm Type", rs)
                basic.append(rset)

            rs = RadioSettingValueBoolean(_settings.save)
            rset = RadioSetting("save", "Battery Saver", rs)
            basic.append(rset)

            rs = RadioSettingValueBoolean(_settings.use_scramble)
            rset = RadioSetting("use_scramble", "Scramble", rs)
            basic.append(rset)

            rs = RadioSettingValueBoolean(_settings.use_vox)
            rset = RadioSetting("use_vox", "VOX", rs)
            basic.append(rset)

            rs = RadioSettingValueList(VOX_LIST, VOX_LIST[_settings.vox])
            rset = RadioSetting("vox", "VOX Gain", rs)
            basic.append(rset)

            def apply_pf1_listvalue(setting, obj):
                LOG.debug("Setting value: " + str(
                          setting.value) + " from list")
                val = str(setting.value)
                index = PF1_CHOICES.index(val)
                val = PF1_VALUES[index]
                obj.set_value(val)

            if _keys.pf1 in PF1_VALUES:
                idx = PF1_VALUES.index(_keys.pf1)
            else:
                idx = LIST_DTMF_SPECIAL_VALUES.index(0x04)
            rs = RadioSettingValueList(PF1_CHOICES, PF1_CHOICES[idx])
            rset = RadioSetting("keys.pf1", "PF1 Key Function", rs)
            rset.set_apply_callback(apply_pf1_listvalue, _keys.pf1)
            basic.append(rset)

            def apply_topkey_listvalue(setting, obj):
                LOG.debug("Setting value: " + str(setting.value) +
                          " from list")
                val = str(setting.value)
                index = TOPKEY_CHOICES.index(val)
                val = TOPKEY_VALUES[index]
                obj.set_value(val)

            if self.MODEL == "RB17A":
                if _keys.topkey in TOPKEY_VALUES:
                    idx = TOPKEY_VALUES.index(_keys.topkey)
                else:
                    idx = TOPKEY_VALUES.index(0x0C)
                rs = RadioSettingValueList(TOPKEY_CHOICES, TOPKEY_CHOICES[idx])
                rset = RadioSetting("keys.topkey", "Top Key Function", rs)
                rset.set_apply_callback(apply_topkey_listvalue, _keys.topkey)
                basic.append(rset)

        if self.MODEL == "RB26" or self.MODEL == "RT76":
            if self.MODEL == "RB26":
                _settings2 = self._memobj.settings2
                _settings3 = self._memobj.settings3

            rs = RadioSettingValueInteger(0, 9, _settings.squelch)
            rset = RadioSetting("squelch", "Squelch Level", rs)
            basic.append(rset)

            rs = RadioSettingValueList(TIMEOUTTIMER_LIST,
                                       TIMEOUTTIMER_LIST[_settings.tot - 1])
            rset = RadioSetting("tot", "Time-out timer", rs)
            basic.append(rset)

            if self.MODEL == "RT76":
                rs = RadioSettingValueList(VOICE_LIST3,
                                           VOICE_LIST3[_settings.voice])
                rset = RadioSetting("voice", "Voice Annumciation", rs)
                basic.append(rset)

            if self.MODEL == "RB26":
                rs = RadioSettingValueList(VOICE_LIST2,
                                           VOICE_LIST2[_settings.voice])
                rset = RadioSetting("voice", "Voice Annumciation", rs)
                basic.append(rset)

                rs = RadioSettingValueBoolean(not _settings.chnumberd)
                rset = RadioSetting("chnumberd", "Channel Number Enable", rs)
                basic.append(rset)

            rs = RadioSettingValueBoolean(_settings.save)
            rset = RadioSetting("save", "Battery Save", rs)
            basic.append(rset)

            rs = RadioSettingValueBoolean(_settings.beep)
            rset = RadioSetting("beep", "Beep", rs)
            basic.append(rset)

            if self.MODEL == "RB26":
                rs = RadioSettingValueBoolean(not _settings.tail)
                rset = RadioSetting("tail", "QT/DQT Tail", rs)
                basic.append(rset)

            rs = RadioSettingValueList(SAVE_LIST, SAVE_LIST[_settings.savem])
            rset = RadioSetting("savem", "Battery Save Mode", rs)
            basic.append(rset)

            rs = RadioSettingValueList(GAIN_LIST, GAIN_LIST[_settings.gain])
            rset = RadioSetting("gain", "MIC Gain", rs)
            basic.append(rset)

            rs = RadioSettingValueList(WARN_LIST, WARN_LIST[_settings.warn])
            rset = RadioSetting("warn", "Warn Mode", rs)
            basic.append(rset)

            if self.MODEL == "RB26":
                rs = RadioSettingValueBoolean(_settings3.vox)
                rset = RadioSetting("settings3.vox", "Vox Function", rs)
                basic.append(rset)

                rs = RadioSettingValueList(VOXL_LIST,
                                           VOXL_LIST[_settings3.voxl])
                rset = RadioSetting("settings3.voxl", "Vox Level", rs)
                basic.append(rset)

                rs = RadioSettingValueList(VOXD_LIST,
                                           VOXD_LIST[_settings3.voxd])
                rset = RadioSetting("settings3.voxd", "Vox Delay", rs)
                basic.append(rset)

                rs = RadioSettingValueList(PFKEY_LIST,
                                           PFKEY_LIST[_settings.pf1])
                rset = RadioSetting("pf1", "PF1 Key Set", rs)
                basic.append(rset)

                rs = RadioSettingValueList(PFKEY_LIST,
                                           PFKEY_LIST[_settings.pf2])
                rset = RadioSetting("pf2", "PF2 Key Set", rs)
                basic.append(rset)

                rs = RadioSettingValueInteger(1, 30, _settings2.chnumber + 1)
                rset = RadioSetting("settings2.chnumber", "Channel Number", rs)
                basic.append(rset)

            if self.MODEL == "RT76":
                rs = RadioSettingValueBoolean(_settings.vox)
                rset = RadioSetting("vox", "Vox Function", rs)
                basic.append(rset)

                rs = RadioSettingValueList(VOXL_LIST,
                                           VOXL_LIST[_settings.voxl])
                rset = RadioSetting("voxl", "Vox Level", rs)
                basic.append(rset)

                rs = RadioSettingValueList(VOXD_LIST,
                                           VOXD_LIST[_settings.voxd])
                rset = RadioSetting("voxd", "Vox Delay", rs)
                basic.append(rset)

                rs = RadioSettingValueInteger(1, 30, _settings.chnumber + 1)
                rset = RadioSetting("chnumber", "Channel Number", rs)
                basic.append(rset)

        return top
Beispiel #20
0
    def get_settings(self):
        try:
            _squelch = 1
            basic = RadioSettingGroup("basic", "Basic")
            expand_1 = RadioSettingGroup("expand_1", "Expand 1")
            expand_2 = RadioSettingGroup("expand_2", "Expand 2")
            dtmf_autodial = RadioSettingGroup("dtmf_autodial", "DTMF autodial")
            group = RadioSettings(basic, expand_1, expand_2, dtmf_autodial)

            # basic
            basic.append(
                RadioSetting(
                    "mem_channel", "Current memory channel",
                    RadioSettingValueInteger(0, MEM_NUM - 1,
                                             self.memobj.mem_channel)))
            basic.append(
                RadioSetting(
                    "squelch_level", "Squelch level",
                    RadioSettingValueList(
                        SQUELCH_LEVEL,
                        SQUELCH_LEVEL[self.memobj.squelch_level])))
            basic.append(
                RadioSetting(
                    "scan_resume", "Scan resume",
                    RadioSettingValueList(
                        SCAN_RESUME, SCAN_RESUME[self.memobj.scan_resume])))
            basic.append(
                RadioSetting(
                    "scan_pause", "Scan pause",
                    RadioSettingValueList(SCAN_PAUSE,
                                          SCAN_PAUSE[self.memobj.scan_pause])))
            basic.append(
                RadioSetting(
                    "beep_volume", "Beep audio",
                    RadioSettingValueList(
                        BEEP_VOLUME, BEEP_VOLUME[self.memobj.beep_volume])))
            basic.append(
                RadioSetting("beep", "Operation beep",
                             RadioSettingValueBoolean(self.memobj.beep)))
            basic.append(
                RadioSetting(
                    "backlight", "LCD backlight",
                    RadioSettingValueList(BACKLIGHT,
                                          BACKLIGHT[self.memobj.backlight])))
            basic.append(
                RadioSetting("busy_led", "Busy LED",
                             RadioSettingValueBoolean(self.memobj.busy_led)))
            basic.append(
                RadioSetting(
                    "auto_power_off", "Auto power off",
                    RadioSettingValueList(
                        AUTO_POWER_OFF,
                        AUTO_POWER_OFF[self.memobj.auto_power_off])))
            basic.append(
                RadioSetting(
                    "power_save", "Power save",
                    RadioSettingValueList(POWER_SAVE,
                                          POWER_SAVE[self.memobj.power_save])))
            basic.append(
                RadioSetting(
                    "monitor", "Monitor",
                    RadioSettingValueList(MONITOR,
                                          MONITOR[self.memobj.monitor])))
            basic.append(
                RadioSetting(
                    "dial_speedup", "Dial speedup",
                    RadioSettingValueBoolean(self.memobj.dial_speedup)))
            basic.append(
                RadioSetting(
                    "auto_repeater", "Auto repeater",
                    RadioSettingValueList(
                        AUTO_REPEATER,
                        AUTO_REPEATER[self.memobj.auto_repeater])))
            basic.append(
                RadioSetting(
                    "hm_75a_function", "HM-75A function",
                    RadioSettingValueList(
                        HM_75A_FUNCTION,
                        HM_75A_FUNCTION[self.memobj.hm_75a_function])))
            basic.append(
                RadioSetting("wx_alert", "WX alert",
                             RadioSettingValueBoolean(self.memobj.wx_alert)))
            basic.append(
                RadioSetting(
                    "wx_channel", "Current WX channel",
                    RadioSettingValueList(WX_CHANNEL,
                                          WX_CHANNEL[self.memobj.wx_channel])))
            basic.append(
                RadioSetting(
                    "comment", "Comment",
                    RadioSettingValueString(0,
                                            COMMENT_LEN,
                                            str(self.memobj.comment),
                                            autopad=True)))
            basic.append(
                RadioSetting(
                    "tune_step", "Current tune step",
                    RadioSettingValueList(
                        TUNE_STEP_STR, TUNE_STEP_STR[self.memobj.tune_step])))
            basic.append(
                RadioSetting(
                    "band_selected", "Selected band",
                    RadioSettingValueInteger(0, BANDS - 1,
                                             self.memobj.band_selected)))
            basic.append(
                RadioSetting(
                    "memory_display", "Memory display",
                    RadioSettingValueList(
                        MEMORY_DISPLAY,
                        MEMORY_DISPLAY[self.memobj.memory_display])))
            basic.append(
                RadioSetting("memory_name", "Memory name",
                             RadioSettingValueBoolean(
                                 self.memobj.memory_name)))
            basic.append(
                RadioSetting(
                    "dial_select", "Dial select",
                    RadioSettingValueList(
                        DIAL_SELECT, DIAL_SELECT[self.memobj.dial_select])))
            basic.append(
                RadioSetting(
                    "power", "RF power",
                    RadioSettingValueList(POWER, POWER[self.memobj.power])))
            basic.append(
                RadioSetting("vfo", "Current VFO",
                             RadioSettingValueList(VFO, VFO[self.memobj.vfo])))
            basic.append(
                RadioSetting("attenuator", "RF attenuator",
                             RadioSettingValueBoolean(self.memobj.attenuator)))
            basic.append(
                RadioSetting("skip_scan", "Skip scan",
                             RadioSettingValueBoolean(self.memobj.skip_scan)))
            # TODO: this needs to be reverse engineered, because the following commented
            # code does not seem correct
            #            basic.append(RadioSetting("mode", "Current mode",
            #                         RadioSettingValueList(OPERATION_MODE,
            #                         OPERATION_MODE[self.memobj.mode])))
            basic.append(
                RadioSetting(
                    "vfo_scan", "VFO scan",
                    RadioSettingValueList(VFO_SCAN,
                                          VFO_SCAN[self.memobj.vfo_scan])))
            basic.append(
                RadioSetting(
                    "memory_scan", "Memory scan",
                    RadioSettingValueList(
                        MEMORY_SCAN, MEMORY_SCAN[self.memobj.memory_scan])))
            basic.append(
                RadioSetting(
                    "tv_channel", "Current TV channel",
                    RadioSettingValueInteger(0, TV_CHANNELS - 1,
                                             self.memobj.tv_channel)))

            # DTMF auto dial
            dtmf_autodial.append(
                RadioSetting(
                    "autodial", "Autodial",
                    RadioSettingValueList(AUTODIAL,
                                          AUTODIAL[self.memobj.autodial])))
            dtmf_autodial.append(
                RadioSetting(
                    "dtmf_speed", "Speed",
                    RadioSettingValueList(DTMF_SPEED,
                                          DTMF_SPEED[self.memobj.dtmf_speed])))
            for x in range(DTMF_AUTODIAL_NUM):
                rs = RadioSetting(
                    "dtmf_codes[%d].dtmf_digits" % x, "DTMF autodial: %d" % x,
                    RadioSettingValueString(
                        0,
                        DTMF_DIGITS_NUM,
                        self.dtmf_icom2chirp(
                            self.memobj.dtmf_codes[x].dtmf_digits),
                        autopad=True,
                        charset="0123456789ABCD*#abcd "))
                rs.set_apply_callback(self.apply_dtmf_autodial,
                                      self.memobj.dtmf_codes[x].dtmf_digits)
                dtmf_autodial.append(rs)

            # expand 1
            expand_1.append(
                RadioSetting("expand_1", "Expand 1",
                             RadioSettingValueBoolean(self.memobj.expand_1)))
            expand_1.append(
                RadioSetting(
                    "scan_stop_beep", "Scan stop beep",
                    RadioSettingValueBoolean(self.memobj.scan_stop_beep)))
            expand_1.append(
                RadioSetting(
                    "scan_stop_light", "Scan stop light",
                    RadioSettingValueBoolean(self.memobj.scan_stop_light)))
            expand_1.append(
                RadioSetting(
                    "light_postion", "Light position",
                    RadioSettingValueList(
                        LIGHT_POSITION,
                        LIGHT_POSITION[self.memobj.light_position])))
            expand_1.append(
                RadioSetting(
                    "light_color", "Light color",
                    RadioSettingValueList(
                        LIGHT_COLOR, LIGHT_COLOR[self.memobj.light_color])))
            expand_1.append(
                RadioSetting(
                    "band_edge_beep", "Band edge beep",
                    RadioSettingValueBoolean(self.memobj.band_edge_beep)))
            expand_1.append(
                RadioSetting(
                    "auto_power_on", "Auto power on",
                    RadioSettingValueList(
                        AUTO_POWER_ON,
                        AUTO_POWER_ON[self.memobj.auto_power_on])))
            expand_1.append(
                RadioSetting(
                    "key_lock", "Key lock",
                    RadioSettingValueList(KEY_LOCK,
                                          KEY_LOCK[self.memobj.key_lock])))
            expand_1.append(
                RadioSetting("ptt_lock", "PTT lock",
                             RadioSettingValueBoolean(self.memobj.ptt_lock)))
            expand_1.append(
                RadioSetting(
                    "lcd_contrast", "LCD contrast",
                    RadioSettingValueList(
                        LCD_CONTRAST, LCD_CONTRAST[self.memobj.lcd_contrast])))
            expand_1.append(
                RadioSetting(
                    "opening_message", "Opening message",
                    RadioSettingValueBoolean(self.memobj.opening_message)))
            expand_1.append(
                RadioSetting(
                    "opening_message_text", "Opening message",
                    RadioSettingValueString(
                        0,
                        OPENING_MESSAGE_LEN,
                        str(self.memobj.opening_message_text),
                        autopad=True,
                        charset=CHARSET)))

            # expand 2
            expand_2.append(
                RadioSetting("expand_2", "Expand 2",
                             RadioSettingValueBoolean(self.memobj.expand_2)))
            expand_2.append(
                RadioSetting(
                    "busy_lockout", "Busy lock out",
                    RadioSettingValueBoolean(self.memobj.busy_lockout)))
            expand_2.append(
                RadioSetting(
                    "timeout_timer", "Timeout timer",
                    RadioSettingValueList(
                        TIMEOUT_TIMER,
                        TIMEOUT_TIMER[self.memobj.timeout_timer])))
            expand_2.append(
                RadioSetting(
                    "active_band", "Active band",
                    RadioSettingValueList(
                        ACTIVE_BAND, ACTIVE_BAND[self.memobj.active_band])))
            expand_2.append(
                RadioSetting("fm_narrow", "FM narrow",
                             RadioSettingValueBoolean(self.memobj.fm_narrow)))
            expand_2.append(
                RadioSetting("split", "Split",
                             RadioSettingValueBoolean(self.memobj.split)))
            expand_2.append(
                RadioSetting(
                    "morse_code_enable", "Morse code synthesizer",
                    RadioSettingValueBoolean(self.memobj.morse_code_enable)))
            expand_2.append(
                RadioSetting(
                    "morse_code_speed", "Morse code speed",
                    RadioSettingValueList(
                        MORSE_CODE_SPEED,
                        MORSE_CODE_SPEED[self.memobj.morse_code_speed])))

            return group
        except:
            import traceback
            LOG.error("Failed to parse settings: %s", traceback.format_exc())
            return None
Beispiel #21
0
    def _get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        arts = RadioSettingGroup("arts", "ARTS")
        dtmf = RadioSettingGroup("dtmf", "DTMF")
        wires = RadioSettingGroup("wires", "WIRES")
        misc = RadioSettingGroup("misc", "Misc")
        top = RadioSettings(basic, arts, dtmf, wires, misc)

        # BASIC

        val = RadioSettingValueList(
            self._APO, self._APO[_settings.auto_power_off])
        rs = RadioSetting("auto_power_off", "Auto Power Off", val)
        basic.append(rs)

        val = RadioSettingValueList(
            self._BEEP_LEVEL, self._BEEP_LEVEL[_settings.beep_level])
        rs = RadioSetting("beep_level", "Beep Level", val)
        basic.append(rs)

        val = RadioSettingValueList(
            self._DIM_LEVEL, self._DIM_LEVEL[_settings.lcd_dimmer])
        rs = RadioSetting("lcd_dimmer", "Dimmer Level", val)
        basic.append(rs)

        val = RadioSettingValueList(
            self._LAMP, self._LAMP[_settings.lamp])
        rs = RadioSetting("lamp", "Keypad Lamp", val)
        basic.append(rs)

        val = RadioSettingValueList(
            self._LOCK, self._LOCK[_settings.lock])
        rs = RadioSetting("lock", "Lock", val)
        basic.append(rs)

        val = RadioSettingValueList(
            self._NUM_1_9, self._NUM_1_9[_settings.mic_gain])
        rs = RadioSetting("mic_gain", "Mic Gain", val)
        basic.append(rs)

        val = RadioSettingValueList(
            self._OPEN_MSG, self._OPEN_MSG[_settings.open_message_mode])
        rs = RadioSetting("open_message_mode",
                          "Open Message Mode", val)
        basic.append(rs)

        val = RadioSettingValueString(0, 6,
                                      self._decode_chars(
                                          _settings.open_message))
        val.set_charset(CHARSET)
        rs = RadioSetting("open_message", "Opening Message", val)
        basic.append(rs)

        passstr = ""
        for c in _settings.password:
            if c < len(PASS_CHARSET):
                passstr += PASS_CHARSET[c]
        val = RadioSettingValueString(0, 4, passstr)
        val.set_charset(PASS_CHARSET)
        rs = RadioSetting("password", "Password", val)
        basic.append(rs)

        val = RadioSettingValueList(
            self._RESUME, self._RESUME[_settings.resume])
        rs = RadioSetting("resume", "Scan Resume", val)
        basic.append(rs)

        val = RadioSettingValueList(
            self._MONI_TCALL, self._MONI_TCALL[_settings.moni_tcall])
        rs = RadioSetting("moni_tcall", "MONI/T-CALL switch", val)
        basic.append(rs)

        rs = RadioSetting("scan_lamp", "Scan Lamp",
                          RadioSettingValueBoolean(_settings.scan_lamp))
        basic.append(rs)

        rs = RadioSetting("beep", "Keypad Beep",
                          RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)

        rs = RadioSetting("busy_led", "Busy LED",
                          RadioSettingValueBoolean(_settings.busy_led))
        basic.append(rs)

        rs = RadioSetting("bclo", "Busy Channel Lock-Out",
                          RadioSettingValueBoolean(_settings.bclo))
        basic.append(rs)

        rs = RadioSetting("wx_alert", "WX Alert",
                          RadioSettingValueBoolean(_settings.wx_alert))
        basic.append(rs)

        rs = RadioSetting("att", "Attenuator",
                          RadioSettingValueBoolean(_settings.att))
        basic.append(rs)

        # ARTS

        val = RadioSettingValueList(
            self._ARTS_INT, self._ARTS_INT[_settings.arts_interval])
        rs = RadioSetting("arts_interval", "ARTS Interval", val)
        arts.append(rs)

        val = RadioSettingValueList(
            self._ARTSBEEP, self._ARTSBEEP[_settings.arts_beep])
        rs = RadioSetting("arts_beep", "ARTS Beep", val)
        arts.append(rs)

        rs = RadioSetting("arts_cwid", "ARTS Send CWID",
                          RadioSettingValueBoolean(_settings.arts_cwid))
        arts.append(rs)

        val = RadioSettingValueString(0, 16,
                                      self._decode_chars(
                                          _settings.arts_cwid_alpha))
        val.set_charset(CHARSET)
        rs = RadioSetting("arts_cwid_alpha", "ARTS CW ID", val)
        arts.append(rs)

        # DTMF

        val = RadioSettingValueList(
            self._MAN_AUTO, self._MAN_AUTO[_settings.dtmf_autodial])
        rs = RadioSetting("dtmf_autodial", "DTMF Autodial", val)
        dtmf.append(rs)

        val = RadioSettingValueList(
            self._NUM_0_9, self._NUM_0_9[_settings.last_dtmf])
        rs = RadioSetting("last_dtmf", "Last DTMF Memory Set", val)
        dtmf.append(rs)

        for i in range(10):
            name = "dtmf_" + str(i)
            dtmfsetting = self._memobj.dtmf[i]
            dtmfstr = ""
            for c in dtmfsetting.memory:
                if c < len(DTMFCHARSET):
                    dtmfstr += DTMFCHARSET[c]
            dtmfentry = RadioSettingValueString(0, 16, dtmfstr)
            rs = RadioSetting(name, name.upper(), dtmfentry)
            dtmf.append(rs)

        # WIRES

        val = RadioSettingValueList(
            self._INT_CD, self._INT_CD[_settings.internet_code])
        rs = RadioSetting("internet_code", "Internet Code", val)
        wires.append(rs)

        val = RadioSettingValueList(
            self._INT_MD, self._INT_MD[_settings.internet_mode])
        rs = RadioSetting("internet_mode",
                          "Internet Link Connection mode", val)
        wires.append(rs)

        val = RadioSettingValueList(
            self._MAN_AUTO, self._MAN_AUTO[_settings.int_autodial])
        rs = RadioSetting("int_autodial", "Internet Autodial", val)
        wires.append(rs)

        val = RadioSettingValueList(
            self._NUM_0_63, self._NUM_0_63[_settings.last_internet_dtmf])
        rs = RadioSetting("last_internet_dtmf",
                          "Last Internet DTMF Memory Set", val)
        wires.append(rs)

        for i in range(64):
            name = "wires_dtmf_" + str(i)
            dtmfsetting = self._memobj.internet_dtmf[i]
            dtmfstr = ""
            for c in dtmfsetting.memory:
                if c < len(DTMFCHARSET):
                    dtmfstr += DTMFCHARSET[c]
            dtmfentry = RadioSettingValueString(0, 8, dtmfstr)
            rs = RadioSetting(name, name.upper(), dtmfentry)
            wires.append(rs)

        # MISC

        val = RadioSettingValueList(
            self._BELL, self._BELL[_settings.bell])
        rs = RadioSetting("bell", "CTCSS/DCS Bell", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._CH_CNT, self._CH_CNT[_settings.channel_counter_width])
        rs = RadioSetting("channel_counter_width",
                          "Channel Counter Search Width", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._EMERGENCY, self._EMERGENCY[_settings.emergency])
        rs = RadioSetting("emergency", "Emergency alarm", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._ON_TIMER, self._ON_TIMER[_settings.on_timer])
        rs = RadioSetting("on_timer", "On Timer", val)
        misc.append(rs)

        rs = RadioSetting("pager_answer_back", "Pager Answer Back",
                          RadioSettingValueBoolean(
                              _settings.pager_answer_back))
        misc.append(rs)

        val = RadioSettingValueList(
            self._NUM_1_50, self._NUM_1_50[_settings.pager_rx_tone1])
        rs = RadioSetting("pager_rx_tone1", "Pager RX Tone 1", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._NUM_1_50, self._NUM_1_50[_settings.pager_rx_tone2])
        rs = RadioSetting("pager_rx_tone2", "Pager RX Tone 2", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._NUM_1_50, self._NUM_1_50[_settings.pager_tx_tone1])
        rs = RadioSetting("pager_tx_tone1", "Pager TX Tone 1", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._NUM_1_50, self._NUM_1_50[_settings.pager_tx_tone2])
        rs = RadioSetting("pager_tx_tone2", "Pager TX Tone 2", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._PTT_DELAY, self._PTT_DELAY[_settings.ptt_delay])
        rs = RadioSetting("ptt_delay", "PTT Delay", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._RF_SQL, self._RF_SQL[_settings.rf_squelch])
        rs = RadioSetting("rf_squelch", "RF Squelch", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._RX_SAVE, self._RX_SAVE[_settings.rx_save])
        rs = RadioSetting("rx_save", "RX Save", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._TOT, self._TOT[_settings.tx_timeout])
        rs = RadioSetting("tx_timeout", "TOT", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._WAKEUP, self._WAKEUP[_settings.wakeup])
        rs = RadioSetting("wakeup", "Wakeup", val)
        misc.append(rs)

        rs = RadioSetting("edge_beep", "Band-Edge Beep",
                          RadioSettingValueBoolean(_settings.edge_beep))
        misc.append(rs)

        val = RadioSettingValueList(
            self._VFO_MODE, self._VFO_MODE[_settings.vfo_mode])
        rs = RadioSetting("vfo_mode", "VFO Band Edge Limiting", val)
        misc.append(rs)

        rs = RadioSetting("tone_search_mute", "Tone Search Mute",
                          RadioSettingValueBoolean(_settings.tone_search_mute))
        misc.append(rs)

        val = RadioSettingValueList(
            self._TS_SPEED, self._TS_SPEED[_settings.ts_speed])
        rs = RadioSetting("ts_speed", "Tone Search Speed", val)
        misc.append(rs)

        rs = RadioSetting("dmr_wrt", "Direct Memory Recall Overwrite",
                          RadioSettingValueBoolean(_settings.dmr_wrt))
        misc.append(rs)

        rs = RadioSetting("tx_saver", "TX Battery Saver",
                          RadioSettingValueBoolean(_settings.tx_saver))
        misc.append(rs)

        val = RadioSettingValueList(
            self._SMART_SEARCH, self._SMART_SEARCH[_settings.smart_search])
        rs = RadioSetting("smart_search", "Smart Search", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._HOME_REV, self._HOME_REV[_settings.home_rev])
        rs = RadioSetting("home_rev", "HM/RV(EMG)R/H key", val)
        misc.append(rs)

        val = RadioSettingValueList(
            self._MEM_W_MD, self._MEM_W_MD[_settings.memory_method])
        rs = RadioSetting("memory_method", "Memory Write Method", val)
        misc.append(rs)

        return top
    def get_settings(self):
        _settings = self._memobj.settings
        _vfo = self._memobj.vfo
        basic = RadioSettingGroup("basic", "Basic Settings")
        group = RadioSettings(basic)

        rs = RadioSetting("squelch", "Squelch Level",
                          RadioSettingValueInteger(0, 9, _settings.squelch))
        basic.append(rs)

        rs = RadioSetting("backlight", "LCD Back Light",
                          RadioSettingValueList(
                              BACKLIGHT_LIST,
                              BACKLIGHT_LIST[_settings.backlight]))
        basic.append(rs)

        rs = RadioSetting("beep", "Keypad Beep",
                          RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)

        rs = RadioSetting("vox", "VOX Level (0=OFF)",
                          RadioSettingValueInteger(0, 9, _settings.vox))
        basic.append(rs)

        rs = RadioSetting("dw", "Dual Watch",
                          RadioSettingValueBoolean(_settings.dw))
        basic.append(rs)

        rs = RadioSetting("ste", "Squelch Tail Eliminate",
                          RadioSettingValueList(
                              STE_LIST, STE_LIST[_settings.ste]))
        basic.append(rs)

        rs = RadioSetting("save", "Battery Saver",
                          RadioSettingValueBoolean(_settings.save))
        basic.append(rs)

        rs = RadioSetting("timeout", "Time Out Timer",
                          RadioSettingValueList(
                              TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout]))
        basic.append(rs)

        rs = RadioSetting("scanm", "Scan Mode",
                          RadioSettingValueList(
                              SCANM_LIST, SCANM_LIST[_settings.scanm]))
        basic.append(rs)

        rs = RadioSetting("relaym", "Repeater Sound Response",
                          RadioSettingValueBoolean(_settings.relaym))
        basic.append(rs)

        rs = RadioSetting("bclo", "Busy Channel Lock Out",
                          RadioSettingValueBoolean(_settings.bclo))
        basic.append(rs)

        rs = RadioSetting("pri", "Priority Channel Scanning",
                          RadioSettingValueBoolean(_settings.pri))
        basic.append(rs)

        rs = RadioSetting("pri_ch", "Priority Channel",
                          RadioSettingValueList(
                              PRI_CH_LIST, PRI_CH_LIST[_settings.pri_ch]))
        basic.append(rs)

        rs = RadioSetting("ch_flag", "Display Mode",
                          RadioSettingValueList(
                              CH_FLAG_LIST, CH_FLAG_LIST[_settings.ch_flag]))
        basic.append(rs)

        _limit = int(self._memobj.limits.lower_vhf) / 10
        if _limit < 115 or _limit > 239:
            _limit = 144
        rs = RadioSetting("limits.lower_vhf", "VHF Lower Limit (115-239 MHz)",
                          RadioSettingValueInteger(115, 235, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.lower_vhf = value
        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        _limit = int(self._memobj.limits.upper_vhf) / 10
        if _limit < 115 or _limit > 239:
            _limit = 146
        rs = RadioSetting("limits.upper_vhf", "VHF Upper Limit (115-239 MHz)",
                          RadioSettingValueInteger(115, 235, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.upper_vhf = value
        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        _limit = int(self._memobj.limits.lower_uhf) / 10
        if _limit < 200 or _limit > 529:
            _limit = 420
        rs = RadioSetting("limits.lower_uhf", "UHF Lower Limit (200-529 MHz)",
                          RadioSettingValueInteger(200, 529, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.lower_uhf = value
        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        _limit = int(self._memobj.limits.upper_uhf) / 10
        if _limit < 200 or _limit > 529:
            _limit = 450
        rs = RadioSetting("limits.upper_uhf", "UHF Upper Limit (200-529 MHz)",
                          RadioSettingValueInteger(200, 529, _limit))

        def apply_limit(setting, obj):
            value = int(setting.value) * 10
            obj.upper_uhf = value
        rs.set_apply_callback(apply_limit, self._memobj.limits)
        basic.append(rs)

        vfo_preset = RadioSettingGroup("vfo_preset", "VFO Presets")
        group.append(vfo_preset)

        def convert_bytes_to_freq(bytes):
            real_freq = 0
            real_freq = bytes
            return chirp_common.format_freq(real_freq * 10)

        def apply_vhf_freq(setting, obj):
            value = chirp_common.parse_freq(str(setting.value)) / 10
            obj.vhf.freq = value

        val = RadioSettingValueString(
                0, 10, convert_bytes_to_freq(int(_vfo.vhf.freq)))
        rs = RadioSetting("vfo.vhf.freq",
                          "VHF RX Frequency (115.00000-236.00000)", val)
        rs.set_apply_callback(apply_vhf_freq, _vfo)
        vfo_preset.append(rs)

        rs = RadioSetting("vfo.vhf.duplex", "Shift Direction",
                          RadioSettingValueList(
                              DUPLEX_LIST, DUPLEX_LIST[_vfo.vhf.duplex]))
        vfo_preset.append(rs)

        def convert_bytes_to_offset(bytes):
            real_offset = 0
            real_offset = bytes
            return chirp_common.format_freq(real_offset * 10000)

        def apply_vhf_offset(setting, obj):
            value = chirp_common.parse_freq(str(setting.value)) / 10000
            obj.vhf.offset = value

        val = RadioSettingValueString(
                0, 10, convert_bytes_to_offset(int(_vfo.vhf.offset)))
        rs = RadioSetting("vfo.vhf.offset", "Offset (0.00-37.995)", val)
        rs.set_apply_callback(apply_vhf_offset, _vfo)
        vfo_preset.append(rs)

        rs = RadioSetting("vfo.vhf.power", "Power Level",
                          RadioSettingValueList(
                              POWER_LIST, POWER_LIST[_vfo.vhf.power]))
        vfo_preset.append(rs)

        rs = RadioSetting("vfo.vhf.bandwidth", "Bandwidth",
                          RadioSettingValueList(
                              BANDWIDTH_LIST,
                              BANDWIDTH_LIST[_vfo.vhf.bandwidth]))
        vfo_preset.append(rs)

        rs = RadioSetting("vfo.vhf.step", "Step",
                          RadioSettingValueList(
                              STEP_LIST, STEP_LIST[_vfo.vhf.step]))
        vfo_preset.append(rs)

        def apply_uhf_freq(setting, obj):
            value = chirp_common.parse_freq(str(setting.value)) / 10
            obj.uhf.freq = value

        val = RadioSettingValueString(
                0, 10, convert_bytes_to_freq(int(_vfo.uhf.freq)))
        rs = RadioSetting("vfo.uhf.freq",
                          "UHF RX Frequency (200.00000-529.00000)", val)
        rs.set_apply_callback(apply_uhf_freq, _vfo)
        vfo_preset.append(rs)

        rs = RadioSetting("vfo.uhf.duplex", "Shift Direction",
                          RadioSettingValueList(
                              DUPLEX_LIST, DUPLEX_LIST[_vfo.uhf.duplex]))
        vfo_preset.append(rs)

        def apply_uhf_offset(setting, obj):
            value = chirp_common.parse_freq(str(setting.value)) / 10000
            obj.uhf.offset = value

        val = RadioSettingValueString(
                0, 10, convert_bytes_to_offset(int(_vfo.uhf.offset)))
        rs = RadioSetting("vfo.uhf.offset", "Offset (0.00-69.995)", val)
        rs.set_apply_callback(apply_uhf_offset, _vfo)
        vfo_preset.append(rs)

        rs = RadioSetting("vfo.uhf.power", "Power Level",
                          RadioSettingValueList(
                              POWER_LIST, POWER_LIST[_vfo.uhf.power]))
        vfo_preset.append(rs)

        rs = RadioSetting("vfo.uhf.bandwidth", "Bandwidth",
                          RadioSettingValueList(
                              BANDWIDTH_LIST,
                              BANDWIDTH_LIST[_vfo.uhf.bandwidth]))
        vfo_preset.append(rs)

        rs = RadioSetting("vfo.uhf.step", "Step",
                          RadioSettingValueList(
                              STEP_LIST, STEP_LIST[_vfo.uhf.step]))
        vfo_preset.append(rs)

        fm_preset = RadioSettingGroup("fm_preset", "FM Radio Presets")
        group.append(fm_preset)

        for i in range(0, 16):
            if self._memobj.fm_presets[i] < 0x01AF:
                used = True
                preset = self._memobj.fm_presets[i] / 10.0 + 65
            else:
                used = False
                preset = 65
            rs = RadioSetting("fm_presets_%1i" % i, "FM Preset %i" % (i + 1),
                              RadioSettingValueBoolean(used),
                              RadioSettingValueFloat(65, 108, preset, 0.1, 1))
            fm_preset.append(rs)

        return group
Beispiel #23
0
 def _get_settings(self):
     top = RadioSettings(self._get_display_settings(),
                         self._get_audio_settings(),
                         self._get_battery_settings())
     return top
Beispiel #24
0
    def get_settings(self):
        _keys = self._memobj.keys
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")
        top = RadioSettings(basic)

        rs = RadioSetting(
            "tot", "Time-out timer",
            RadioSettingValueList(TIMEOUTTIMER_LIST,
                                  TIMEOUTTIMER_LIST[_settings.tot - 1]))
        basic.append(rs)

        rs = RadioSetting(
            "totalert", "TOT Pre-alert",
            RadioSettingValueList(TOTALERT_LIST,
                                  TOTALERT_LIST[_settings.totalert]))
        basic.append(rs)

        rs = RadioSetting("squelch", "Squelch Level",
                          RadioSettingValueInteger(0, 9, _settings.squelch))
        basic.append(rs)

        rs = RadioSetting(
            "voice", "Voice Annumciation",
            RadioSettingValueList(VOICE_LIST, VOICE_LIST[_settings.voice]))
        basic.append(rs)

        rs = RadioSetting("save", "Battery Saver",
                          RadioSettingValueBoolean(_settings.save))
        basic.append(rs)

        rs = RadioSetting("use_scramble", "Scramble",
                          RadioSettingValueBoolean(_settings.use_scramble))
        basic.append(rs)

        rs = RadioSetting("use_vox", "VOX",
                          RadioSettingValueBoolean(_settings.use_vox))
        basic.append(rs)

        rs = RadioSetting(
            "vox", "VOX Gain",
            RadioSettingValueList(VOX_LIST, VOX_LIST[_settings.vox]))
        basic.append(rs)

        def apply_pf1_listvalue(setting, obj):
            LOG.debug("Setting value: " + str(setting.value) + " from list")
            val = str(setting.value)
            index = PF1_CHOICES.index(val)
            val = PF1_VALUES[index]
            obj.set_value(val)

        if _keys.pf1 in PF1_VALUES:
            idx = PF1_VALUES.index(_keys.pf1)
        else:
            idx = LIST_DTMF_SPECIAL_VALUES.index(0x04)
        rs = RadioSetting("keys.pf1", "PF1 Key Function",
                          RadioSettingValueList(PF1_CHOICES, PF1_CHOICES[idx]))
        rs.set_apply_callback(apply_pf1_listvalue, _keys.pf1)
        basic.append(rs)

        return top
Beispiel #25
0
    def get_settings(self):
        _settings = self._memobj.settings
        _mem = self._memobj
        basic = RadioSettingGroup("basic", "Basic Settings")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        top = RadioSettings(basic, dtmf)

        if _settings.k1shortp > 5:
            val = 4
        else:
            val = _settings.k1shortp
        rs = RadioSetting(
            "k1shortp", "Key 1 Short Press",
            RadioSettingValueList(LIST_SHORT_PRESS, LIST_SHORT_PRESS[val]))
        basic.append(rs)

        if _settings.k1longp > 5:
            val = 5
        else:
            val = _settings.k1longp
        rs = RadioSetting(
            "k1longp", "Key 1 Long Press",
            RadioSettingValueList(LIST_LONG_PRESS, LIST_LONG_PRESS[val]))
        basic.append(rs)

        if _settings.k2shortp > 5:
            val = 1
        else:
            val = _settings.k2shortp
        rs = RadioSetting(
            "k2shortp", "Key 2 Short Press",
            RadioSettingValueList(LIST_SHORT_PRESS, LIST_SHORT_PRESS[val]))
        basic.append(rs)

        if _settings.k2longp > 5:
            val = 3
        else:
            val = _settings.k2longp
        rs = RadioSetting(
            "k2longp", "Key 2 Long Press",
            RadioSettingValueList(LIST_LONG_PRESS, LIST_LONG_PRESS[val]))
        basic.append(rs)

        rs = RadioSetting("vox", "VOX",
                          RadioSettingValueBoolean(not _settings.vox))
        basic.append(rs)

        if _settings.voxg > 8:
            val = 4
        else:
            val = _settings.voxg + 1
        rs = RadioSetting("voxg", "VOX Gain",
                          RadioSettingValueInteger(1, 9, val))
        basic.append(rs)

        rs = RadioSetting(
            "voxd", "VOX Delay Time",
            RadioSettingValueList(LIST_VOXDELAY,
                                  LIST_VOXDELAY[_settings.voxd]))
        basic.append(rs)

        rs = RadioSetting("voxi", "VOX Inhibit on Receive",
                          RadioSettingValueBoolean(_settings.voxi))
        basic.append(rs)

        if _settings.squelch > 9:
            val = 5
        else:
            val = _settings.squelch
        rs = RadioSetting("squelch", "Squelch Level",
                          RadioSettingValueInteger(0, 9, val))
        basic.append(rs)

        if _settings.voice == 3:
            val = 1
        else:
            val = _settings.voice
        rs = RadioSetting("voice", "Voice Prompts",
                          RadioSettingValueList(LIST_VOICE, LIST_VOICE[val]))
        basic.append(rs)

        rs = RadioSetting("tone", "Tone",
                          RadioSettingValueBoolean(_settings.tone))
        basic.append(rs)

        rs = RadioSetting("lovoltnotx", "TX Inhibit (when battery < 6 volts)",
                          RadioSettingValueBoolean(_settings.lovoltnotx))
        basic.append(rs)

        rs = RadioSetting("hivoltnotx", "TX Inhibit (when battery > 9 volts)",
                          RadioSettingValueBoolean(_settings.hivoltnotx))
        basic.append(rs)

        if _settings.tot > 0x28:
            val = 6
        else:
            val = _settings.tot
        rs = RadioSetting(
            "tot", "Time-out Timer[s]",
            RadioSettingValueList(LIST_TIMEOUTTIMER, LIST_TIMEOUTTIMER[val]))
        basic.append(rs)

        if _settings.save < 3:
            val = 0
        else:
            val = _settings.save - 3
        rs = RadioSetting("save", "Battery Saver",
                          RadioSettingValueList(LIST_SAVE, LIST_SAVE[val]))
        basic.append(rs)

        rs = RadioSetting(
            "ssave", "Super Battery Saver[s]",
            RadioSettingValueList(LIST_SSAVE, LIST_SSAVE[_settings.ssave]))
        basic.append(rs)

        rs = RadioSetting("fmradio", "Broadcast FM",
                          RadioSettingValueBoolean(_settings.fmradio))
        basic.append(rs)

        if _settings.scanspeed > 8:
            val = 4
        else:
            val = _settings.scanspeed
        rs = RadioSetting(
            "scanspeed", "Scan Speed[ms]",
            RadioSettingValueList(LIST_SCANSPEED, LIST_SCANSPEED[val]))
        basic.append(rs)

        if _settings.scandelay > 27:
            val = 12
        else:
            val = _settings.scandelay
        rs = RadioSetting(
            "scandelay", "Scan Droupout Delay Time[s]",
            RadioSettingValueList(LIST_SCANDELAY, LIST_SCANDELAY[val]))
        basic.append(rs)

        if _mem.dtmf.dtmfspd > 11:
            val = 2
        else:
            val = _mem.dtmf.dtmfspd + 4
        rs = RadioSetting("dtmf.dtmfspd", "DTMF Speed[digit/s]",
                          RadioSettingValueInteger(4, 15, val))
        dtmf.append(rs)

        if _mem.dtmf.digtime > 10:
            val = 0
        else:
            val = _mem.dtmf.digtime
        rs = RadioSetting(
            "dtmf.digtime", "1st Digit Time[ms]",
            RadioSettingValueList(LIST_DIGTIME, LIST_DIGTIME[val]))
        dtmf.append(rs)

        if _mem.dtmf.digdelay > 9:
            val = 0
        else:
            val = _mem.dtmf.digdelay
        rs = RadioSetting(
            "dtmf.digdelay", "1st Digit Delay[ms]",
            RadioSettingValueList(LIST_DIGDELAY, LIST_DIGDELAY[val]))
        dtmf.append(rs)

        rs = RadioSetting(
            "dtmf.starhash", "* and # Time[ms]",
            RadioSettingValueList(LIST_STARHASH,
                                  LIST_STARHASH[_mem.dtmf.starhash]))
        dtmf.append(rs)

        rs = RadioSetting(
            "dtmf.codespace", "Code Space Time[ms]",
            RadioSettingValueList(LIST_CODESPACE,
                                  LIST_CODESPACE[_mem.dtmf.codespace]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.sidetone", "DTMF Sidetone",
                          RadioSettingValueBoolean(_mem.dtmf.sidetone))
        dtmf.append(rs)

        # setup pttid entries
        for i in range(0, 2):
            objname = "code" + str(i + 1)
            names = ["PTT ID(BOT)", "PTT ID(EOT)"]
            strname = str(names[i])
            dtmfsetting = getattr(_mem.dtmf, objname)
            dtmflen = getattr(_mem.dtmf, objname + "_len")
            dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
            code = RadioSettingValueString(0, 16, dtmfstr)
            code.set_charset(DTMF_CHARSET + list(" "))
            rs = RadioSetting("dtmf." + objname, strname, code)
            dtmf.append(rs)

        def _filter(name):
            filtered = ""
            for char in str(name):
                if char in NUMERIC_CHARSET:
                    filtered += char
                else:
                    filtered += " "
            return filtered

        # setup id code entry
        codesetting = getattr(_mem.dtmf, "idcode")
        codestr = self._bbcd2num(codesetting, 6)
        code = RadioSettingValueString(0, 6, _filter(codestr))
        code.set_charset(NUMERIC_CHARSET + list(" "))
        rs = RadioSetting("dtmf.idcode", "ID Code", code)
        dtmf.append(rs)

        if _mem.dtmf.groupcode > 6:
            val = 0
        else:
            val = _mem.dtmf.groupcode
        rs = RadioSetting(
            "dtmf.groupcode", "Group Code",
            RadioSettingValueList(LIST_GROUPCODE, LIST_GROUPCODE[val]))
        dtmf.append(rs)

        if _mem.dtmf.resettime > 60:
            val = 0
        else:
            val = _mem.dtmf.resettime
        rs = RadioSetting(
            "dtmf.resettime", "Auto Reset Time[s]",
            RadioSettingValueList(LIST_RESETTIME,
                                  LIST_RESETTIME[_mem.dtmf.resettime]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.txdecode", "TX Decode",
                          RadioSettingValueBoolean(_mem.dtmf.txdecode))
        dtmf.append(rs)

        rs = RadioSetting(
            "dtmf.decodeto", "Decode Time Out[ms]",
            RadioSettingValueList(LIST_DECODETO,
                                  LIST_DECODETO[_mem.dtmf.decodeto]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.decodetone", "Decode Tone",
                          RadioSettingValueBoolean(_mem.dtmf.decodetone))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.resettone", "Reset Tone",
                          RadioSettingValueBoolean(_mem.dtmf.resettone))
        dtmf.append(rs)

        rs = RadioSetting(
            "dtmf.stuntype", "Stun Type",
            RadioSettingValueList(LIST_STUNTYPE,
                                  LIST_STUNTYPE[_mem.dtmf.stuntype]))
        dtmf.append(rs)

        ## setup stun entry
        objname = "code3"
        strname = "Stun Code"
        dtmfsetting = getattr(_mem.dtmf, objname)
        dtmflen = getattr(_mem.dtmf, objname + "_len")
        dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
        code = RadioSettingValueString(0, 10, dtmfstr)
        code.set_charset(DTMF_CHARSET + list(" "))
        rs = RadioSetting("dtmf." + objname, strname, code)
        dtmf.append(rs)

        return top
Beispiel #26
0
    def get_settings(self):
        china = RadioSettingGroup("china", "China Map Fix")
        smartbeacon = RadioSettingGroup("smartbeacon", "Smartbeacon")

        aprs = RadioSettingGroup("aprs", "APRS", china, smartbeacon)
        digipeat = RadioSettingGroup("digipeat", "Digipeat")
        system = RadioSettingGroup("system", "System")
        settings = RadioSettings(aprs, digipeat, system)

        aprs.append(
            RadioSetting(
                "callsign", "Callsign",
                RadioSettingValueString(0, 6, self._mmap.callsign[:6])))
        aprs.append(
            RadioSetting(
                "ssid", "SSID",
                RadioSettingValueInteger(0, 15,
                                         ord(self._mmap.callsign[6]) - 0x30)))
        pttdelay = PTT_DELAY[int(self._mmap.pttdelay) - 1]
        aprs.append(
            RadioSetting("pttdelay", "PTT Delay",
                         RadioSettingValueList(PTT_DELAY, pttdelay)))
        output = OUTPUT[int(self._mmap.output) - 1]
        aprs.append(
            RadioSetting("output", "Output",
                         RadioSettingValueList(OUTPUT, output)))
        aprs.append(
            RadioSetting("mice", "Mic-E",
                         RadioSettingValueBoolean(strbool(self._mmap.mice))))
        try:
            mice_msg = MICE_MESSAGE[int(self._mmap.multiple['mice_message'])]
            aprs.append(
                RadioSetting("mice_message", "Mic-E Message",
                             RadioSettingValueList(MICE_MESSAGE, mice_msg)))
        except NotImplementedError:
            pass
        try:
            aprs.append(
                RadioSetting(
                    "path1", "Path 1",
                    RadioSettingValueString(0,
                                            6,
                                            self._mmap.path1[:6],
                                            autopad=True,
                                            charset=CHARSET)))
            ssid1 = ord(self._mmap.path1[6]) - 0x30
            aprs.append(
                RadioSetting("ssid1", "SSID 1",
                             RadioSettingValueInteger(0, 7, ssid1)))
            aprs.append(
                RadioSetting(
                    "path2", "Path 2",
                    RadioSettingValueString(0,
                                            6,
                                            self._mmap.path2[:6],
                                            autopad=True,
                                            charset=CHARSET)))
            ssid2 = ord(self._mmap.path2[6]) - 0x30
            aprs.append(
                RadioSetting("ssid2", "SSID 2",
                             RadioSettingValueInteger(0, 7, ssid2)))
            aprs.append(
                RadioSetting(
                    "path3", "Path 3",
                    RadioSettingValueString(0,
                                            6,
                                            self._mmap.path3[:6],
                                            autopad=True,
                                            charset=CHARSET)))
            ssid3 = ord(self._mmap.path3[6]) - 0x30
            aprs.append(
                RadioSetting("ssid3", "SSID 3",
                             RadioSettingValueInteger(0, 7, ssid3)))
        except NotImplementedError:
            aprs.append(
                RadioSetting(
                    "path", "Path",
                    RadioSettingValueList(PATH, PATH[int(self._mmap.path)])))
        aprs.append(
            RadioSetting("table", "Table or Overlay",
                         RadioSettingValueList(TABLE, self._mmap.symbol[1])))
        aprs.append(
            RadioSetting("symbol", "Symbol",
                         RadioSettingValueList(SYMBOL, self._mmap.symbol[0])))
        aprs.append(
            RadioSetting(
                "beacon", "Beacon Mode",
                RadioSettingValueList(BEACON,
                                      BEACON[int(self._mmap.beacon) - 1])))
        aprs.append(
            RadioSetting("rate", "Beacon Rate (seconds)",
                         RadioSettingValueInteger(10, 9999, self._mmap.rate)))
        aprs.append(
            RadioSetting(
                "comment", "Comment",
                RadioSettingValueString(0,
                                        34,
                                        self._mmap.comment,
                                        autopad=False,
                                        charset=CHARSET)))
        try:
            voltage = self._mmap.multiple['voltage']
            aprs.append(
                RadioSetting("voltage", "Voltage in comment",
                             RadioSettingValueBoolean(voltage)))
            temperature = self._mmap.multiple['temperature']
            aprs.append(
                RadioSetting("temperature", "Temperature in comment",
                             RadioSettingValueBoolean(temperature)))
        except NotImplementedError:
            pass
        aprs.append(
            RadioSetting(
                "status", "Status",
                RadioSettingValueString(0,
                                        34,
                                        self._mmap.status,
                                        autopad=False,
                                        charset=CHARSET)))
        try:
            telemetry = self._mmap.multiple['telemetry']
            aprs.append(
                RadioSetting("telemetry", "Telemetry",
                             RadioSettingValueBoolean(telemetry)))
            telemetry_every = self._mmap.multiple['telemetry_every']
            aprs.append(
                RadioSetting("telemetry_every", "Telemetry every",
                             RadioSettingValueInteger(1, 99, telemetry_every)))
            timeslot_enable = self._mmap.multiple['telemetry']
            aprs.append(
                RadioSetting("timeslot_enable", "Timeslot",
                             RadioSettingValueBoolean(timeslot_enable)))
            timeslot = self._mmap.multiple['timeslot']
            aprs.append(
                RadioSetting("timeslot", "Timeslot (second of minute)",
                             RadioSettingValueInteger(0, 59, timeslot)))
        except NotImplementedError:
            pass

        fields = [
            ("chinamapfix", "China map fix",
             RadioSettingValueBoolean(strbool(self._mmap.chinamapfix[0]))),
            ("chinalat", "Lat",
             RadioSettingValueInteger(-45, 45,
                                      ord(self._mmap.chinamapfix[2]) - 80)),
            ("chinalon", "Lon",
             RadioSettingValueInteger(-45, 45,
                                      ord(self._mmap.chinamapfix[1]) - 80)),
        ]
        for field in fields:
            china.append(RadioSetting(*field))

        try:
            # Sometimes when digipeat is disabled, alias is 0xFF
            alias = ALIAS[int(self._mmap.digipeat[1]) - 1]
        except ValueError:
            alias = ALIAS[0]
        fields = [
            ("digipeat", "Digipeat",
             RadioSettingValueBoolean(strbool(self._mmap.digipeat[0]))),
            ("alias", "Digipeat Alias", RadioSettingValueList(ALIAS, alias)),
            ("virtualgps", "Static Position",
             RadioSettingValueBoolean(strbool(self._mmap.virtualgps[0]))),
            ("btext", "Static Position BTEXT",
             RadioSettingValueString(0,
                                     27,
                                     self._mmap.virtualgps[1:],
                                     autopad=False,
                                     charset=CHARSET)),
        ]
        for field in fields:
            digipeat.append(RadioSetting(*field))

        sb = self._mmap.smartbeacon
        fields = [
            ("lowspeed", "Low Speed"),
            ("highspeed", "High Speed"),
            ("slowrate", "Slow Rate (seconds)"),
            ("fastrate", "Fast Rate (seconds)"),
            ("turnslope", "Turn Slope"),
            ("turnangle", "Turn Angle"),
            ("turntime", "Turn Time (seconds)"),
        ]
        for field in fields:
            smartbeacon.append(
                RadioSetting(field[0], field[1],
                             RadioSettingValueInteger(0, 9999, sb[field[0]])))

        system.append(
            RadioSetting("version", "Version (read-only)",
                         RadioSettingValueString(0, 14, self._mmap.version)))
        system.append(
            RadioSetting("autooff", "Auto off (after 90 minutes)",
                         RadioSettingValueBoolean(strbool(
                             self._mmap.autooff))))
        system.append(
            RadioSetting("beep", "Beep on transmit",
                         RadioSettingValueBoolean(strbool(self._mmap.beep))))
        system.append(
            RadioSetting(
                "highaltitude", "High Altitude",
                RadioSettingValueBoolean(strbool(self._mmap.highaltitude))))
        system.append(
            RadioSetting(
                "busywait", "Wait for clear channel before transmit",
                RadioSettingValueBoolean(strbool(self._mmap.busywait))))
        try:
            system.append(
                RadioSetting(
                    "tx_volume", "Transmit volume",
                    RadioSettingValueList(map(str, range(1, 7)),
                                          self._mmap.tx_volume)))
            system.append(
                RadioSetting(
                    "rx_volume", "Receive volume",
                    RadioSettingValueList(map(str, range(1, 10)),
                                          self._mmap.rx_volume)))
            system.append(
                RadioSetting(
                    "squelch", "Squelch",
                    RadioSettingValueList(map(str, range(
                        0, 9)), str(self._mmap.multiple['squelch']))))
            system.append(
                RadioSetting(
                    "tx_serial_ui_out", "Tx serial UI out",
                    RadioSettingValueBoolean(
                        strbool(self._mmap.tx_serial_ui_out))))
            system.append(
                RadioSetting(
                    "auto_on", "Auto-on with 5V input",
                    RadioSettingValueBoolean(strbool(self._mmap.auto_on[0]))))
            system.append(
                RadioSetting(
                    "auto_on_delay", "Auto-off delay after 5V lost (seconds)",
                    RadioSettingValueInteger(0, 9999,
                                             int(self._mmap.auto_on[1:]))))
            system.append(
                RadioSetting(
                    "tfx", "TF/X",
                    RadioSettingValueBoolean(self._mmap.multiple['tfx'])))
            system.append(
                RadioSetting(
                    "blueled", "Light blue LED on GPS lock",
                    RadioSettingValueBoolean(self._mmap.multiple['blueled'])))
            system.append(
                RadioSetting(
                    "dcd", "Blue LED shows software DCD",
                    RadioSettingValueBoolean(self._mmap.multiple['dcd'])))
            system.append(
                RadioSetting(
                    "tf_card", "TF card format",
                    RadioSettingValueList(
                        TF_CARD,
                        TF_CARD[int(self._mmap.multiple['tf_card'])])))
        except NotImplementedError:
            pass

        return settings
Beispiel #27
0
 def _get_settings(self):
     # TODO
     top = RadioSettings()
     return top
Beispiel #28
0
    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
Beispiel #29
0
    def get_settings(self):
        _settings = self._memobj.settings
        _settings_misc = self._memobj.settings_misc
        basic = RadioSettingGroup("basic", "Basic Settings")
        top = RadioSettings(basic)

        rs = RadioSetting(
            "rf_sql", "Squelch level (SQL)",
            RadioSettingValueList(RFSQL_LIST, RFSQL_LIST[_settings.rf_sql]))
        basic.append(rs)

        rs = RadioSetting(
            "step_freq", "Step frequency KHz (STP)",
            RadioSettingValueList(STEP_LIST, STEP_LIST[_settings.step_freq]))
        basic.append(rs)

        rs = RadioSetting(
            "fm_radio", "FM radio (DW)",
            RadioSettingValueList(OFF_ON_LIST,
                                  OFF_ON_LIST[_settings_misc.fm_radio]))
        basic.append(rs)

        rs = RadioSetting(
            "call_tone", "Call tone (CK)",
            RadioSettingValueList(CALLTONE_LIST,
                                  CALLTONE_LIST[_settings.call_tone]))
        basic.append(rs)

        rs = RadioSetting(
            "tot", "Time-out timer (TOT)",
            RadioSettingValueList(TIMEOUT_LIST, TIMEOUT_LIST[_settings.tot]))
        basic.append(rs)

        rs = RadioSetting(
            "chan_disp_way", "Channel display way",
            RadioSettingValueList(CH_FLAG_LIST,
                                  CH_FLAG_LIST[_settings.chan_disp_way]))
        basic.append(rs)

        rs = RadioSetting(
            "vox", "VOX Gain (VOX)",
            RadioSettingValueList(VOX_LIST, VOX_LIST[_settings.vox]))
        basic.append(rs)

        rs = RadioSetting(
            "vox_dly", "VOX Delay",
            RadioSettingValueList(VOXDELAY_LIST,
                                  VOXDELAY_LIST[_settings.vox_dly]))
        basic.append(rs)

        rs = RadioSetting(
            "beep", "Beep (BP)",
            RadioSettingValueList(OFF_ON_LIST, OFF_ON_LIST[_settings.beep]))
        basic.append(rs)

        rs = RadioSetting(
            "auto_lock", "Auto lock (KY)",
            RadioSettingValueList(NO_YES_LIST,
                                  NO_YES_LIST[_settings_misc.auto_lock]))
        basic.append(rs)

        rs = RadioSetting(
            "bat_save", "Battery Saver (SAV)",
            RadioSettingValueList(BAT_SAVE_LIST,
                                  BAT_SAVE_LIST[_settings.bat_save]))
        basic.append(rs)

        rs = RadioSetting(
            "chan_pri", "Channel PRI (PRI)",
            RadioSettingValueList(OFF_ON_LIST,
                                  OFF_ON_LIST[_settings.chan_pri]))
        basic.append(rs)

        rs = RadioSetting(
            "chan_pri_num", "Channel PRI time Sec (PRI)",
            RadioSettingValueList(PRI_NUM_LIST,
                                  PRI_NUM_LIST[_settings.chan_pri_num]))
        basic.append(rs)

        rs = RadioSetting(
            "end_beep", "End beep (ET)",
            RadioSettingValueList(ENDBEEP_LIST,
                                  ENDBEEP_LIST[_settings.end_beep]))
        basic.append(rs)

        rs = RadioSetting(
            "ch_mode", "CH mode",
            RadioSettingValueList(ON_OFF_LIST, ON_OFF_LIST[_settings.ch_mode]))
        basic.append(rs)

        rs = RadioSetting(
            "scan_rev", "Scan rev (SCAN)",
            RadioSettingValueList(SCANM_LIST, SCANM_LIST[_settings.scan_rev]))
        basic.append(rs)

        rs = RadioSetting(
            "enc", "Frequency lock (ENC)",
            RadioSettingValueList(OFF_ON_LIST, OFF_ON_LIST[_settings.enc]))
        basic.append(rs)

        rs = RadioSetting(
            "wait_back_light", "Wait back light (LED)",
            RadioSettingValueList(BACKLIGHT_LIST,
                                  BACKLIGHT_LIST[_settings.wait_back_light]))
        basic.append(rs)

        return top
Beispiel #30
0
    def get_settings(self):
        _settings = self._memobj.settings
        _message = self._memobj.embedded_msg
        basic = RadioSettingGroup("basic", "Basic Settings")
        top = RadioSettings(basic)

        rs = RadioSetting("squelch", "Squelch Level",
                          RadioSettingValueInteger(0, 9, _settings.squelch))
        basic.append(rs)

        rs = RadioSetting("tot", "Time-out timer",
                          RadioSettingValueList(
                              TIMEOUTTIMER_LIST,
                              TIMEOUTTIMER_LIST[_settings.tot]))
        basic.append(rs)

        rs = RadioSetting("voice", "Voice Prompts",
                          RadioSettingValueList(
                              VOICE_LIST, VOICE_LIST[_settings.voice]))
        basic.append(rs)

        rs = RadioSetting("pf2key", "PF2 Key",
                          RadioSettingValueList(
                              PF2KEY_LIST, PF2KEY_LIST[_settings.pf2key]))
        basic.append(rs)

        rs = RadioSetting("vox", "Vox",
                          RadioSettingValueBoolean(_settings.vox))
        basic.append(rs)

        rs = RadioSetting("voxgain", "VOX Level",
                          RadioSettingValueList(
                              VOX_LIST, VOX_LIST[_settings.voxgain]))
        basic.append(rs)

        rs = RadioSetting("voxdelay", "VOX Delay Time",
                          RadioSettingValueList(
                              VOXDELAY_LIST,
                              VOXDELAY_LIST[_settings.voxdelay]))
        basic.append(rs)

        rs = RadioSetting("save", "Battery Save",
                          RadioSettingValueBoolean(_settings.save))
        basic.append(rs)

        rs = RadioSetting("beep", "Beep",
                          RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)

        def _filter(name):
            filtered = ""
            for char in str(name):
                if char in VALID_CHARS:
                    filtered += char
                else:
                    filtered += " "
            return filtered

        rs = RadioSetting("embedded_msg.line1", "Embedded Message 1",
                          RadioSettingValueString(0, 32, _filter(
                              _message.line1)))
        basic.append(rs)

        rs = RadioSetting("embedded_msg.line2", "Embedded Message 2",
                          RadioSettingValueString(0, 32, _filter(
                              _message.line2)))
        basic.append(rs)

        return top
Beispiel #31
0
    def _get_settings(self):
        _settings = self._memobj.settings
        _freqrange = self._memobj.freqrange
        _slabel = self._memobj.slabel

        basic = RadioSettingGroup("basic","Global Settings")
        freqrange = RadioSettingGroup("freqrange","Frequency Ranges")
        top = RadioSettingGroup("top","All Settings",basic,freqrange)
        settings = RadioSettings(top)

        def _filter(name):
            filtered = ""
            for char in str(name):
                if char in chirp_common.CHARSET_ASCII:
                    filtered += char
                else:
                    filtered += ""
            return filtered
                   
        val = RadioSettingValueString(0,7,_filter(_slabel.startname))
        rs = RadioSetting("startname","Startup Label",val)
        basic.append(rs)

        rs = RadioSetting("bg_color","LCD Color",
                           RadioSettingValueList(BGCOLOR_LIST, BGCOLOR_LIST[_settings.bg_color]))
        basic.append(rs)

        rs = RadioSetting("bg_brightness","LCD Brightness",
                           RadioSettingValueList(BGBRIGHT_LIST, BGBRIGHT_LIST[_settings.bg_brightness]))
        basic.append(rs)

        rs = RadioSetting("squelch","Squelch Level",
                           RadioSettingValueList(SQUELCH_LIST, SQUELCH_LIST[_settings.squelch]))
        basic.append(rs)

        rs = RadioSetting("timeout_timer","Timeout Timer (TOT)",
                           RadioSettingValueList(TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout_timer]))
        basic.append(rs)

        rs = RadioSetting("auto_power_off","Auto Power Off (APO)",
                           RadioSettingValueList(APO_LIST, APO_LIST[_settings.auto_power_off]))
        basic.append(rs)

        rs = RadioSetting("voice_prompt","Beep Prompt",
                           RadioSettingValueList(BEEP_LIST, BEEP_LIST[_settings.voice_prompt]))
        basic.append(rs)

        rs = RadioSetting("tbst_freq","Tone Burst Frequency",
                           RadioSettingValueList(TBSTFREQ_LIST, TBSTFREQ_LIST[_settings.tbst_freq]))
        basic.append(rs)

        rs = RadioSetting("choose_tx_power","Max Level of TX Power",
                           RadioSettingValueList(TXPWR_LIST, TXPWR_LIST[_settings.choose_tx_power]))
        basic.append(rs)

        (flow,fhigh)  = self.valid_freq[0]
        flow  /= 1000
        fhigh /= 1000
        fmidrange = (fhigh- flow)/2

        rs = RadioSetting("txrangelow","TX Freq, Lower Limit (khz)", RadioSettingValueInteger(flow,
            flow + fmidrange,
            int(_freqrange.txrangelow)/10))
        freqrange.append(rs)

        rs = RadioSetting("txrangehi","TX Freq, Upper Limit (khz)", RadioSettingValueInteger(fhigh-fmidrange,
            fhigh,
            int(_freqrange.txrangehi)/10))
        freqrange.append(rs)

        rs = RadioSetting("rxrangelow","RX Freq, Lower Limit (khz)", RadioSettingValueInteger(flow,
            flow+fmidrange,
            int(_freqrange.rxrangelow)/10))
        freqrange.append(rs)

        rs = RadioSetting("rxrangehi","RX Freq, Upper Limit (khz)", RadioSettingValueInteger(fhigh-fmidrange,
            fhigh,
            int(_freqrange.rxrangehi)/10))
        freqrange.append(rs)

        return settings
Beispiel #32
0
    def get_settings(self):
        _settings = self._memobj.settings
        _dtmf_strings = self._memobj.dtmf_strings
        _passwd = self._memobj.passwd

        repeater = RadioSettingGroup("repeater", "Repeater Settings")
        ctcss = RadioSettingGroup("ctcss", "CTCSS/DCS/EPCS Settings")
        arts = RadioSettingGroup("arts", "ARTS Settings")
        mbls = RadioSettingGroup("banks", "Memory Settings")
        scan = RadioSettingGroup("scan", "Scan Settings")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        wires = RadioSettingGroup("wires", "WiRES(tm) Settings")
        switch = RadioSettingGroup("switch", "Switch/Knob Settings")
        disp = RadioSettingGroup("disp", "Display Settings")
        misc = RadioSettingGroup("misc", "Miscellaneous Settings")

        setmode = RadioSettings(repeater, ctcss, arts, mbls, scan, dtmf, wires,
                                switch, disp, misc)

        # numbers and names of settings refer to the way they're
        # presented in the set menu, as well as the list starting on
        # page 74 of the manual

        # 1 APO
        opts = ["Off", "30 Min", "1 Hour", "3 Hour", "5 Hour", "8 Hour"]
        misc.append(
            RadioSetting("apo", "Automatic Power Off",
                         RadioSettingValueList(opts, opts[_settings.apo])))

        # 2 AR.BEP
        opts = ["Off", "In Range", "Always"]
        arts.append(
            RadioSetting(
                "arts_beep", "ARTS Beep",
                RadioSettingValueList(opts, opts[_settings.arts_beep])))

        # 3 AR.INT
        opts = ["15 Sec", "25 Sec"]
        arts.append(
            RadioSetting(
                "arts_interval", "ARTS Polling Interval",
                RadioSettingValueList(opts, opts[_settings.arts_interval])))

        # 4 ARS
        opts = ["Off", "On"]
        repeater.append(
            RadioSetting("ars", "Automatic Repeater Shift",
                         RadioSettingValueList(opts, opts[_settings.ars])))

        # 5 BCLO
        opts = ["Off", "On"]
        misc.append(
            RadioSetting(
                "busy_lockout", "Busy Channel Lock-Out",
                RadioSettingValueList(opts, opts[_settings.busy_lockout])))

        # 6 BEEP
        opts = ["Off", "Key+Scan", "Key"]
        switch.append(
            RadioSetting("beep", "Enable the Beeper",
                         RadioSettingValueList(opts, opts[_settings.beep])))

        # 7 BELL
        opts = ["Off", "1", "3", "5", "8", "Continuous"]
        ctcss.append(
            RadioSetting("bell", "Bell Repetitions",
                         RadioSettingValueList(opts, opts[_settings.bell])))

        # 8 BNK.LNK
        for i in range(0, 8):
            opts = ["Off", "On"]
            mbs = (self._memobj.mbs >> i) & 1
            rs = RadioSetting("mbs%i" % i, "Bank %s Scan" % (i + 1),
                              RadioSettingValueList(opts, opts[mbs]))

            def apply_mbs(s, index):
                if int(s.value):
                    self._memobj.mbs |= (1 << index)
                else:
                    self._memobj.mbs &= ~(1 << index)

            rs.set_apply_callback(apply_mbs, i)
            mbls.append(rs)

        # 9 BNK.NM - A per-bank attribute, nothing to do here.

        # 10 CLK.SFT - A per-channel attribute, nothing to do here.

        # 11 CW.ID
        opts = ["Off", "On"]
        arts.append(
            RadioSetting("cw_id", "CW ID Enable",
                         RadioSettingValueList(opts, opts[_settings.cw_id])))

        cw_id_text = ""
        for i in _settings.cw_id_string:
            try:
                cw_id_text += CHARSET[i & 0x7F]
            except IndexError:
                if i != 0xff:
                    LOG.debug("unknown char index in cw id: %x " % (i))

        val = RadioSettingValueString(0, 16, cw_id_text, True)
        val.set_charset(CHARSET + "abcdefghijklmnopqrstuvwxyz")
        rs = RadioSetting("cw_id_string", "CW Identifier Text", val)

        def apply_cw_id(s):
            str = s.value.get_value().upper().rstrip()
            mval = ""
            mval = [chr(CHARSET.index(x)) for x in str]
            for x in range(len(mval), 16):
                mval.append(chr(0xff))
            for x in range(0, 16):
                _settings.cw_id_string[x] = ord(mval[x])

        rs.set_apply_callback(apply_cw_id)
        arts.append(rs)

        # 12 CWTRNG
        opts = [
            "Off", "4WPM", "5WPM", "6WPM", "7WPM", "8WPM", "9WPM", "10WPM",
            "11WPM", "12WPM", "13WPM", "15WPM", "17WPM", "20WPM", "24WPM",
            "30WPM", "40WPM"
        ]
        misc.append(
            RadioSetting("cw_trng", "CW Training",
                         RadioSettingValueList(opts, opts[_settings.cw_trng])))

        # todo: make the setting of the units here affect the display
        # of the speed.  Not critical, but would be slick.
        opts = ["CPM", "WPM"]
        misc.append(
            RadioSetting(
                "cw_trng_units", "CW Training Units",
                RadioSettingValueList(opts, opts[_settings.cw_trng_units])))

        # 13 DC VLT - a read-only status, so nothing to do here

        # 14 DCS CD - A per-channel attribute, nothing to do here

        # 15 DCS.RV
        opts = ["Disabled", "Enabled"]
        ctcss.append(
            RadioSetting(
                "inverted_dcs", "\"Inverted\" DCS Code Decoding",
                RadioSettingValueList(opts, opts[_settings.inverted_dcs])))

        # 16 DIMMER
        opts = ["Off"] + ["Level %d" % (x) for x in range(1, 11)]
        disp.append(
            RadioSetting("dimmer", "Dimmer",
                         RadioSettingValueList(opts, opts[_settings.dimmer])))

        # 17 DT.A/M
        opts = ["Manual", "Auto"]
        dtmf.append(
            RadioSetting(
                "dtmf_mode", "DTMF Autodialer",
                RadioSettingValueList(opts, opts[_settings.dtmf_mode])))

        # 18 DT.DLY
        opts = ["50 ms", "250 ms", "450 ms", "750 ms", "1000 ms"]
        dtmf.append(
            RadioSetting(
                "dtmf_delay", "DTMF Autodialer Delay Time",
                RadioSettingValueList(opts, opts[_settings.dtmf_delay])))

        # 19 DT.SET
        for memslot in range(0, 10):
            dtmf_memory = ""
            for i in _dtmf_strings[memslot].dtmf_string:
                if i != 0xFF:
                    try:
                        dtmf_memory += CHARSET[i]
                    except IndexError:
                        LOG.debug("unknown char index in dtmf: %x " % (i))

            val = RadioSettingValueString(0, 16, dtmf_memory, True)
            val.set_charset(CHARSET + "abcdef")
            rs = RadioSetting("dtmf_string_%d" % memslot,
                              "DTMF Memory %d" % memslot, val)

            def apply_dtmf(s, i):
                LOG.debug("applying dtmf for %x\n" % i)
                str = s.value.get_value().upper().rstrip()
                LOG.debug("str is %s\n" % str)
                mval = ""
                mval = [chr(CHARSET.index(x)) for x in str]
                for x in range(len(mval), 16):
                    mval.append(chr(0xff))
                for x in range(0, 16):
                    _dtmf_strings[i].dtmf_string[x] = ord(mval[x])

            rs.set_apply_callback(apply_dtmf, memslot)
            dtmf.append(rs)

        # 20 DT.SPD
        opts = ["50 ms", "100 ms"]
        dtmf.append(
            RadioSetting(
                "dtmf_speed", "DTMF Autodialer Sending Speed",
                RadioSettingValueList(opts, opts[_settings.dtmf_speed])))

        # 21 EDG.BEP
        opts = ["Off", "On"]
        mbls.append(
            RadioSetting(
                "edge_beep", "Band Edge Beeper",
                RadioSettingValueList(opts, opts[_settings.edge_beep])))

        # 22 INT.CD
        opts = ["DTMF %X" % (x) for x in range(0, 16)]
        wires.append(
            RadioSetting("int_cd", "Access Number for WiRES(TM)",
                         RadioSettingValueList(opts, opts[_settings.int_cd])))

        # 23 ING MD
        opts = ["Sister Radio Group", "Friends Radio Group"]
        wires.append(
            RadioSetting(
                "wires_mode", "Internet Link Connection Mode",
                RadioSettingValueList(opts, opts[_settings.wires_mode])))

        # 24 INT.A/M
        opts = ["Manual", "Auto"]
        wires.append(
            RadioSetting(
                "wires_auto", "Internet Link Autodialer",
                RadioSettingValueList(opts, opts[_settings.wires_auto])))
        # 25 INT.SET
        opts = ["F%d" % (x) for x in range(0, 10)]

        wires.append(
            RadioSetting("int_set", "Memory Register for "
                         "non-WiRES Internet",
                         RadioSettingValueList(opts, opts[_settings.int_set])))

        # 26 LOCK
        opts = [
            "Key", "Dial", "Key + Dial", "PTT", "Key + PTT", "Dial + PTT",
            "All"
        ]
        switch.append(
            RadioSetting("lock", "Control Locking",
                         RadioSettingValueList(opts, opts[_settings.lock])))

        # 27 MCGAIN
        opts = ["Level %d" % (x) for x in range(1, 10)]
        misc.append(
            RadioSetting("mic_gain", "Microphone Gain",
                         RadioSettingValueList(opts,
                                               opts[_settings.mic_gain])))

        # 28 MEM.SCN
        opts = ["Tag 1", "Tag 2", "All Channels"]
        rs = RadioSetting(
            "scan_mode", "Memory Scan Mode",
            RadioSettingValueList(opts, opts[_settings.scan_mode - 1]))

        # this setting is unusual in that it starts at 1 instead of 0.
        # that is, index 1 corresponds to "Tag 1", and index 0 is invalid.
        # so we create a custom callback to handle this.

        def apply_scan_mode(s):
            myopts = ["Tag 1", "Tag 2", "All Channels"]
            _settings.scan_mode = myopts.index(s.value.get_value()) + 1

        rs.set_apply_callback(apply_scan_mode)
        mbls.append(rs)

        # 29 MW MD
        opts = ["Lower", "Next"]
        mbls.append(
            RadioSetting("mw_mode", "Memory Write Mode",
                         RadioSettingValueList(opts, opts[_settings.mw_mode])))

        # 30 NM SET - This is per channel, so nothing to do here

        # 31 OPN.MSG
        opts = ["Off", "DC Supply Voltage", "Text Message"]
        disp.append(
            RadioSetting("open_msg", "Opening Message Type",
                         RadioSettingValueList(opts,
                                               opts[_settings.open_msg])))

        openmsg = ""
        for i in _settings.openMsg_Text:
            try:
                openmsg += CHARSET[i & 0x7F]
            except IndexError:
                if i != 0xff:
                    LOG.debug("unknown char index in openmsg: %x " % (i))

        val = RadioSettingValueString(0, 6, openmsg, True)
        val.set_charset(CHARSET + "abcdefghijklmnopqrstuvwxyz")
        rs = RadioSetting("openMsg_Text", "Opening Message Text", val)

        def apply_openmsg(s):
            str = s.value.get_value().upper().rstrip()
            mval = ""
            mval = [chr(CHARSET.index(x)) for x in str]
            for x in range(len(mval), 6):
                mval.append(chr(0xff))
            for x in range(0, 6):
                _settings.openMsg_Text[x] = ord(mval[x])

        rs.set_apply_callback(apply_openmsg)
        disp.append(rs)

        # 32 PAGER - a per-channel attribute

        # 33 PAG.ABK
        opts = ["Off", "On"]
        ctcss.append(
            RadioSetting("pag_abk", "Paging Answer Back",
                         RadioSettingValueList(opts, opts[_settings.pag_abk])))

        # 34 PAG.CDR
        opts = ["%2.2d" % (x) for x in range(1, 50)]
        ctcss.append(
            RadioSetting(
                "pag_cdr_1", "Receive Page Code 1",
                RadioSettingValueList(opts, opts[_settings.pag_cdr_1])))

        ctcss.append(
            RadioSetting(
                "pag_cdr_2", "Receive Page Code 2",
                RadioSettingValueList(opts, opts[_settings.pag_cdr_2])))

        # 35 PAG.CDT
        opts = ["%2.2d" % (x) for x in range(1, 50)]
        ctcss.append(
            RadioSetting(
                "pag_cdt_1", "Transmit Page Code 1",
                RadioSettingValueList(opts, opts[_settings.pag_cdt_1])))

        ctcss.append(
            RadioSetting(
                "pag_cdt_2", "Transmit Page Code 2",
                RadioSettingValueList(opts, opts[_settings.pag_cdt_2])))

        # Common Button Options
        button_opts = [
            "Squelch Off", "Weather", "Smart Search", "Tone Scan", "Scan",
            "T Call", "ARTS"
        ]

        # 36 PRG P1
        opts = button_opts + ["DC Volts"]
        switch.append(
            RadioSetting("prog_p1", "P1 Button",
                         RadioSettingValueList(opts, opts[_settings.prog_p1])))

        # 37 PRG P2
        opts = button_opts + ["Dimmer"]
        switch.append(
            RadioSetting("prog_p2", "P2 Button",
                         RadioSettingValueList(opts, opts[_settings.prog_p2])))

        # 38 PRG P3
        opts = button_opts + ["Mic Gain"]
        switch.append(
            RadioSetting("prog_p3", "P3 Button",
                         RadioSettingValueList(opts, opts[_settings.prog_p3])))

        # 39 PRG P4
        opts = button_opts + ["Skip"]
        switch.append(
            RadioSetting("prog_p4", "P4 Button",
                         RadioSettingValueList(opts, opts[_settings.prog_p4])))

        # 40 PSWD
        password = ""
        for i in _passwd:
            if i != 0xFF:
                try:
                    password += CHARSET[i]
                except IndexError:
                    LOG.debug("unknown char index in password: %x " % (i))

        val = RadioSettingValueString(0, 4, password, True)
        val.set_charset(CHARSET[0:15] + "abcdef ")
        rs = RadioSetting("passwd", "Password", val)

        def apply_password(s):
            str = s.value.get_value().upper().rstrip()
            mval = ""
            mval = [chr(CHARSET.index(x)) for x in str]
            for x in range(len(mval), 4):
                mval.append(chr(0xff))
            for x in range(0, 4):
                _passwd[x] = ord(mval[x])

        rs.set_apply_callback(apply_password)
        misc.append(rs)

        # 41 RESUME
        opts = ["3 Sec", "5 Sec", "10 Sec", "Busy", "Hold"]
        scan.append(
            RadioSetting("resume", "Scan Resume Mode",
                         RadioSettingValueList(opts, opts[_settings.resume])))

        # 42 RF.SQL
        opts = ["Off"] + ["S-%d" % (x) for x in range(1, 10)]
        misc.append(
            RadioSetting("rf_sql", "RF Squelch Threshold",
                         RadioSettingValueList(opts, opts[_settings.rf_sql])))

        # 43 RPT - per channel attribute, nothing to do here

        # 44 RVRT
        opts = ["Off", "On"]
        misc.append(
            RadioSetting("revert", "Priority Revert",
                         RadioSettingValueList(opts, opts[_settings.revert])))

        # 45 S.SRCH
        opts = ["Single", "Continuous"]
        misc.append(
            RadioSetting("s_search", "Smart Search Sweep Mode",
                         RadioSettingValueList(opts,
                                               opts[_settings.s_search])))

        # 46 SHIFT - per channel setting, nothing to do here

        # 47 SKIP = per channel setting, nothing to do here

        # 48 SPLIT - per channel attribute, nothing to do here

        # 49 SQL.TYP - per channel attribute, nothing to do here

        # 50 STEP - per channel attribute, nothing to do here

        # 51 TEMP - read-only status, nothing to do here

        # 52 TN FRQ - per channel attribute, nothing to do here

        # 53 TOT
        opts = ["Off", "1 Min", "3 Min", "5 Min", "10 Min"]
        misc.append(
            RadioSetting("tot", "Timeout Timer",
                         RadioSettingValueList(opts, opts[_settings.tot])))

        # 54 TS MUT
        opts = ["Off", "On"]
        ctcss.append(
            RadioSetting("ts_mut", "Tone Search Mute",
                         RadioSettingValueList(opts, opts[_settings.ts_mut])))

        # 55 TS SPEED
        opts = ["Fast", "Slow"]
        ctcss.append(
            RadioSetting("ts_speed", "Tone Search Scanner Speed",
                         RadioSettingValueList(opts,
                                               opts[_settings.ts_speed])))

        # 56 VFO.SCN
        opts = ["+/- 1MHz", "+/- 2MHz", "+/-5MHz", "All"]
        scan.append(
            RadioSetting("vfo_scan", "VFO Scanner Width",
                         RadioSettingValueList(opts,
                                               opts[_settings.vfo_scan])))

        # 57 WX.ALT
        opts = ["Off", "On"]
        misc.append(
            RadioSetting("wx_alert", "Weather Alert Scan",
                         RadioSettingValueList(opts,
                                               opts[_settings.wx_alert])))

        # 58 WX.VOL
        opts = ["Normal", "Maximum"]
        misc.append(
            RadioSetting(
                "wx_vol_max", "Weather Alert Volume",
                RadioSettingValueList(opts, opts[_settings.wx_vol_max])))

        # 59 W/N DV - this is a per-channel attribute, nothing to do here

        return setmode
Beispiel #33
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")
        group = RadioSettings(basic)

        rs = RadioSetting("ch", "Channel Indication Mode",
                          RadioSettingValueBoolean(_settings.ch))
        basic.append(rs)

        rs = RadioSetting("expand", "Expanded Settings Mode",
                          RadioSettingValueBoolean(_settings.expand))
        basic.append(rs)

        rs = RadioSetting("beep", "Beep Tones",
                          RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)

        rs = RadioSetting(
            "autorp", "Auto Repeater Function",
            RadioSettingValueList(AUTORP_LIST, AUTORP_LIST[_settings.autorp]))
        basic.append(rs)

        rs = RadioSetting("ritfunct", "RIT Runction",
                          RadioSettingValueBoolean(_settings.ritfunct))
        basic.append(rs)

        rs = RadioSetting("rit", "RIT Shift (KHz)",
                          RadioSettingValueInteger(-7, 7, _settings.rit))
        basic.append(rs)

        rs = RadioSetting("lock", "Lock",
                          RadioSettingValueBoolean(_settings.lock))
        basic.append(rs)

        rs = RadioSetting(
            "lockgroup", "Lock Group",
            RadioSettingValueList(LOCKGROUP_LIST,
                                  LOCKGROUP_LIST[_settings.lockgroup]))
        basic.append(rs)

        rs = RadioSetting(
            "squelch", "Squelch",
            RadioSettingValueList(SQUELCH_LIST,
                                  SQUELCH_LIST[_settings.squelch]))
        basic.append(rs)

        rs = RadioSetting(
            "monitor", "Monitor Switch Function",
            RadioSettingValueList(MONITOR_LIST,
                                  MONITOR_LIST[_settings.monitor]))
        basic.append(rs)

        rs = RadioSetting(
            "light", "Display Backlighting",
            RadioSettingValueList(LIGHT_LIST, LIGHT_LIST[_settings.light]))
        basic.append(rs)

        rs = RadioSetting(
            "priority", "Priority Watch Operation",
            RadioSettingValueList(PRIORITY_LIST,
                                  PRIORITY_LIST[_settings.priority]))
        basic.append(rs)

        rs = RadioSetting("p_scan", "Frequency Skip Function",
                          RadioSettingValueBoolean(_settings.p_scan))
        basic.append(rs)

        rs = RadioSetting(
            "bnk_scan", "Memory Bank Scan Selection",
            RadioSettingValueList(BANKSCAN_LIST,
                                  BANKSCAN_LIST[_settings.bnk_scan]))
        basic.append(rs)

        rs = RadioSetting(
            "edge", "Band Edge Scan Selection",
            RadioSettingValueList(EDGE_LIST, EDGE_LIST[_settings.edge]))
        basic.append(rs)

        rs = RadioSetting(
            "pause", "Scan Pause Time",
            RadioSettingValueList(PAUSE_LIST, PAUSE_LIST[_settings.pause]))
        basic.append(rs)

        rs = RadioSetting(
            "resume", "Scan Resume Time",
            RadioSettingValueList(RESUME_LIST, RESUME_LIST[_settings.resume]))
        basic.append(rs)

        rs = RadioSetting("p_save", "Power Saver",
                          RadioSettingValueBoolean(_settings.p_save))
        basic.append(rs)

        rs = RadioSetting(
            "ap_off", "Auto Power-off Function",
            RadioSettingValueList(APOFF_LIST, APOFF_LIST[_settings.ap_off]))
        basic.append(rs)

        rs = RadioSetting("speed", "Dial Speed Acceleration",
                          RadioSettingValueBoolean(_settings.speed))
        basic.append(rs)

        rs = RadioSetting(
            "d_sel", "Dial Select Step",
            RadioSettingValueList(D_SEL_LIST, D_SEL_LIST[_settings.d_sel]))
        basic.append(rs)

        return group
Beispiel #34
0
    def _get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")
        advanced = RadioSettingGroup("advanced", "Advanced Settings")
        group = RadioSettings(basic, advanced)

        rs = RadioSetting("squelch", "Carrier Squelch Level",
                          RadioSettingValueInteger(0, 9, _settings.squelch))
        basic.append(rs)

        rs = RadioSetting("save", "Battery Saver",
                          RadioSettingValueInteger(0, 4, _settings.save))
        basic.append(rs)

        rs = RadioSetting("abr", "Backlight",
                          RadioSettingValueBoolean(_settings.abr))
        basic.append(rs)

        rs = RadioSetting("tdr", "Dual Watch (BDR)",
                          RadioSettingValueBoolean(_settings.tdr))
        advanced.append(rs)

        rs = RadioSetting("tdrab", "Dual Watch TX Priority",
                          RadioSettingValueList(
                              uv5r.TDRAB_LIST,
                              uv5r.TDRAB_LIST[_settings.tdrab]))
        advanced.append(rs)

        rs = RadioSetting("alarm", "Alarm",
                          RadioSettingValueBoolean(_settings.alarm))
        advanced.append(rs)

        rs = RadioSetting("beep", "Beep",
                          RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)

        rs = RadioSetting("timeout", "Timeout Timer",
                          RadioSettingValueList(
                              uv5r.TIMEOUT_LIST,
                              uv5r.TIMEOUT_LIST[_settings.timeout]))
        basic.append(rs)

        rs = RadioSetting("screv", "Scan Resume",
                          RadioSettingValueList(
                              uv5r.RESUME_LIST,
                              uv5r.RESUME_LIST[_settings.screv]))
        advanced.append(rs)

        rs = RadioSetting("mdfa", "Display Mode (A)",
                          RadioSettingValueList(
                              uv5r.MODE_LIST, uv5r.MODE_LIST[_settings.mdfa]))
        basic.append(rs)

        rs = RadioSetting("mdfb", "Display Mode (B)",
                          RadioSettingValueList(
                              uv5r.MODE_LIST, uv5r.MODE_LIST[_settings.mdfb]))
        basic.append(rs)

        rs = RadioSetting("bcl", "Busy Channel Lockout",
                          RadioSettingValueBoolean(_settings.bcl))
        advanced.append(rs)

        rs = RadioSetting("autolk", "Automatic Key Lock",
                          RadioSettingValueBoolean(_settings.autolk))
        advanced.append(rs)

        rs = RadioSetting("fmradio", "Broadcast FM Radio",
                          RadioSettingValueBoolean(_settings.fmradio))
        advanced.append(rs)

        rs = RadioSetting("wtled", "Standby LED Color",
                          RadioSettingValueList(
                              COLOR_LIST, COLOR_LIST[_settings.wtled]))
        basic.append(rs)

        rs = RadioSetting("rxled", "RX LED Color",
                          RadioSettingValueList(
                              COLOR_LIST, COLOR_LIST[_settings.rxled]))
        basic.append(rs)

        rs = RadioSetting("txled", "TX LED Color",
                          RadioSettingValueList(
                              COLOR_LIST, COLOR_LIST[_settings.txled]))
        basic.append(rs)

        rs = RadioSetting("reset", "RESET Menu",
                          RadioSettingValueBoolean(_settings.reset))
        advanced.append(rs)

        rs = RadioSetting("menu", "All Menus",
                          RadioSettingValueBoolean(_settings.menu))
        advanced.append(rs)

        if len(self._mmap.get_packed()) == 0x1808:
            # Old image, without aux block
            return group

        other = RadioSettingGroup("other", "Other Settings")
        group.append(other)

        def _filter(name):
            filtered = ""
            for char in str(name):
                if char in chirp_common.CHARSET_ASCII:
                    filtered += char
                else:
                    filtered += " "
            return filtered

        _msg = self._memobj.poweron_msg
        rs = RadioSetting("poweron_msg.line1", "Power-On Message 1",
                          RadioSettingValueString(0, 7, _filter(_msg.line1)))
        other.append(rs)
        rs = RadioSetting("poweron_msg.line2", "Power-On Message 2",
                          RadioSettingValueString(0, 7, _filter(_msg.line2)))
        other.append(rs)

        limit = "limits"
        vhf_limit = getattr(self._memobj, limit).vhf
        rs = RadioSetting("%s.vhf.lower" % limit, "VHF Lower Limit (MHz)",
                          RadioSettingValueInteger(
                              1, 1000, vhf_limit.lower))
        other.append(rs)

        rs = RadioSetting("%s.vhf.upper" % limit, "VHF Upper Limit (MHz)",
                          RadioSettingValueInteger(
                              1, 1000, vhf_limit.upper))
        other.append(rs)

        rs = RadioSetting("%s.vhf.enable" % limit, "VHF TX Enabled",
                          RadioSettingValueBoolean(vhf_limit.enable))
        other.append(rs)

        uhf_limit = getattr(self._memobj, limit).uhf
        rs = RadioSetting("%s.uhf.lower" % limit, "UHF Lower Limit (MHz)",
                          RadioSettingValueInteger(
                              1, 1000, uhf_limit.lower))
        other.append(rs)
        rs = RadioSetting("%s.uhf.upper" % limit, "UHF Upper Limit (MHz)",
                          RadioSettingValueInteger(
                              1, 1000, uhf_limit.upper))
        other.append(rs)
        rs = RadioSetting("%s.uhf.enable" % limit, "UHF TX Enabled",
                          RadioSettingValueBoolean(uhf_limit.enable))
        other.append(rs)

        workmode = RadioSettingGroup("workmode", "Work Mode Settings")
        group.append(workmode)

        options = ["A", "B"]
        rs = RadioSetting("displayab", "Display Selected",
                          RadioSettingValueList(
                              options, options[_settings.displayab]))
        workmode.append(rs)

        options = ["Frequency", "Channel"]
        rs = RadioSetting("workmode", "VFO/MR Mode",
                          RadioSettingValueList(
                              options, options[_settings.workmode]))
        workmode.append(rs)

        rs = RadioSetting("keylock", "Keypad Lock",
                          RadioSettingValueBoolean(_settings.keylock))
        workmode.append(rs)

        _mrcna = self._memobj.wmchannel.mrcha
        rs = RadioSetting("wmchannel.mrcha", "MR A Channel",
                          RadioSettingValueInteger(0, 127, _mrcna))
        workmode.append(rs)

        _mrcnb = self._memobj.wmchannel.mrchb
        rs = RadioSetting("wmchannel.mrchb", "MR B Channel",
                          RadioSettingValueInteger(0, 127, _mrcnb))
        workmode.append(rs)

        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)
            if 17400000 <= value and value < 40000000:
                raise InvalidValueError("Can't be between 174.00000-400.00000")
            return chirp_common.format_freq(value)

        def apply_freq(setting, obj):
            value = chirp_common.parse_freq(str(setting.value)) / 10
            obj.band = value >= 40000000
            for i in range(7, -1, -1):
                obj.freq[i] = value % 10
                value /= 10

        val1a = RadioSettingValueString(
                0, 10, convert_bytes_to_freq(self._memobj.vfoa.freq))
        val1a.set_validate_callback(my_validate)
        rs = RadioSetting("vfoa.freq", "VFO A Frequency", val1a)
        rs.set_apply_callback(apply_freq, self._memobj.vfoa)
        workmode.append(rs)

        val1b = RadioSettingValueString(
                0, 10, convert_bytes_to_freq(self._memobj.vfob.freq))
        val1b.set_validate_callback(my_validate)
        rs = RadioSetting("vfob.freq", "VFO B Frequency", val1b)
        rs.set_apply_callback(apply_freq, self._memobj.vfob)
        workmode.append(rs)

        options = ["Off", "+", "-"]
        rs = RadioSetting("vfoa.sftd", "VFO A Shift",
                          RadioSettingValueList(
                              options, options[self._memobj.vfoa.sftd]))
        workmode.append(rs)

        rs = RadioSetting("vfob.sftd", "VFO B Shift",
                          RadioSettingValueList(
                              options, options[self._memobj.vfob.sftd]))
        workmode.append(rs)

        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(self._memobj.vfoa.offset))
        rs = RadioSetting("vfoa.offset", "VFO A Offset (0.00-69.95)", val1a)
        rs.set_apply_callback(apply_offset, self._memobj.vfoa)
        workmode.append(rs)

        val1b = RadioSettingValueString(
                0, 10, convert_bytes_to_offset(self._memobj.vfob.offset))
        rs = RadioSetting("vfob.offset", "VFO B Offset (0.00-69.95)", val1b)
        rs.set_apply_callback(apply_offset, self._memobj.vfob)
        workmode.append(rs)

        options = ["High", "Low"]
        rs = RadioSetting("vfoa.txpower", "VFO A Power",
                          RadioSettingValueList(
                              options, options[self._memobj.vfoa.txpower]))
        workmode.append(rs)

        rs = RadioSetting("vfob.txpower", "VFO B Power",
                          RadioSettingValueList(
                              options, options[self._memobj.vfob.txpower]))
        workmode.append(rs)

        options = ["Wide", "Narrow"]
        rs = RadioSetting("vfoa.widenarr", "VFO A Bandwidth",
                          RadioSettingValueList(
                              options, options[self._memobj.vfoa.widenarr]))
        workmode.append(rs)

        rs = RadioSetting("vfob.widenarr", "VFO B Bandwidth",
                          RadioSettingValueList(
                              options, options[self._memobj.vfob.widenarr]))
        workmode.append(rs)

        options = ["%s" % x for x in range(1, 16)]
        rs = RadioSetting("vfoa.scode", "VFO A PTT-ID",
                          RadioSettingValueList(
                              options, options[self._memobj.vfoa.scode]))
        workmode.append(rs)

        rs = RadioSetting("vfob.scode", "VFO B PTT-ID",
                          RadioSettingValueList(
                              options, options[self._memobj.vfob.scode]))
        workmode.append(rs)

        rs = RadioSetting("vfoa.step", "VFO A Tuning Step",
                          RadioSettingValueList(
                              STEP_LIST, STEP_LIST[self._memobj.vfoa.step]))
        workmode.append(rs)
        rs = RadioSetting("vfob.step", "VFO B Tuning Step",
                          RadioSettingValueList(
                              STEP_LIST, STEP_LIST[self._memobj.vfob.step]))
        workmode.append(rs)

        fm_preset = RadioSettingGroup("fm_preset", "FM Radio Preset")
        group.append(fm_preset)

        preset = self._memobj.fm_preset / 10.0 + 87
        rs = RadioSetting("fm_preset", "FM Preset(MHz)",
                          RadioSettingValueFloat(87, 107.5, preset, 0.1, 1))
        fm_preset.append(rs)

        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        group.append(dtmf)
        dtmfchars = "0123456789 *#ABCD"

        for i in range(0, 15):
            _codeobj = self._memobj.pttid[i].code
            _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
            val = RadioSettingValueString(0, 5, _code, False)
            val.set_charset(dtmfchars)
            rs = RadioSetting("pttid/%i.code" % i,
                              "PTT ID Code %i" % (i + 1), val)

            def apply_code(setting, obj):
                code = []
                for j in range(0, 5):
                    try:
                        code.append(dtmfchars.index(str(setting.value)[j]))
                    except IndexError:
                        code.append(0xFF)
                obj.code = code
            rs.set_apply_callback(apply_code, self._memobj.pttid[i])
            dtmf.append(rs)

        _codeobj = self._memobj.ani.code
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 5, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("ani.code", "ANI Code", val)

        def apply_code(setting, obj):
            code = []
            for j in range(0, 5):
                try:
                    code.append(dtmfchars.index(str(setting.value)[j]))
                except IndexError:
                    code.append(0xFF)
            obj.code = code
        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmf.append(rs)

        options = ["Off", "BOT", "EOT", "Both"]
        rs = RadioSetting("ani.aniid", "ANI ID",
                          RadioSettingValueList(
                              options, options[self._memobj.ani.aniid]))
        dtmf.append(rs)

        _codeobj = self._memobj.ani.alarmcode
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 5, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("ani.alarmcode", "Alarm Code", val)

        def apply_code(setting, obj):
            alarmcode = []
            for j in range(5):
                try:
                    alarmcode.append(dtmfchars.index(str(setting.value)[j]))
                except IndexError:
                    alarmcode.append(0xFF)
            obj.alarmcode = alarmcode
        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmf.append(rs)

        rs = RadioSetting("dtmfst", "DTMF Sidetone",
                          RadioSettingValueList(
                              uv5r.DTMFST_LIST,
                              uv5r.DTMFST_LIST[_settings.dtmfst]))
        dtmf.append(rs)

        rs = RadioSetting("ani.dtmfon", "DTMF Speed (on)",
                          RadioSettingValueList(
                              uv5r.DTMFSPEED_LIST,
                              uv5r.DTMFSPEED_LIST[self._memobj.ani.dtmfon]))
        dtmf.append(rs)

        rs = RadioSetting("ani.dtmfoff", "DTMF Speed (off)",
                          RadioSettingValueList(
                              uv5r.DTMFSPEED_LIST,
                              uv5r.DTMFSPEED_LIST[self._memobj.ani.dtmfoff]))
        dtmf.append(rs)

        return group