Ejemplo n.º 1
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
Ejemplo n.º 2
0
    def _get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")
        advanced = RadioSettingGroup("advanced", "Advanced Settings")
        group = RadioSettingGroup("top", "All Settings", 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(uv5r.STEP291_LIST,
                          uv5r.STEP291_LIST[self._memobj.vfoa.step]))
        workmode.append(rs)
        rs = RadioSetting("vfob.step", "VFO B Tuning Step",
                          RadioSettingValueList(uv5r.STEP291_LIST,
                          uv5r.STEP291_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
Ejemplo n.º 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")
        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", "Automatic Key Lock",
                          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)

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

        if _mem.settings.tdrab > 0x02:
            val = 0x00
        else:
            val = _mem.settings.tdrab
        rs = RadioSetting("settings.tdrab", "Dual Watch TX Priority",
                          RadioSettingValueList(
                              LIST_OFFAB, LIST_OFFAB[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, 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)

        lower = 130
        upper = 179
        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):
            value = chirp_common.parse_freq(value)
            msg = ("Can't be less than %i.0000")
            if value > 99000000 and value < 130 * 1000000:
                raise InvalidValueError(msg % (130))
            msg = ("Can't be between %i.9975-%i.0000")
            if (179 + 1) * 1000000 <= value and value < 400 * 1000000:
                raise InvalidValueError(msg % (179, 400))
            msg = ("Can't be greater than %i.9975")
            if value > 99000000 and value > (520 + 1) * 1000000:
                raise InvalidValueError(msg % (520))
            return chirp_common.format_freq(value)

        def 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.txpower3", "VFO A Power",
                          RadioSettingValueList(
                              LIST_TXPOWER,
                              LIST_TXPOWER[_mem.vfo.a.txpower3]))
        work.append(rs)

        rs = RadioSetting("vfo.b.txpower3", "VFO B Power",
                          RadioSettingValueList(
                              LIST_TXPOWER,
                              LIST_TXPOWER[_mem.vfo.b.txpower3]))
        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 band in ["vhf", "uhf"]:
            for index in range(0, 10):
                key = "squelch.%s.sql%i" % (band, index)
                if band == "vhf":
                    _obj = self._memobj.squelch.vhf
                elif band == "uhf":
                    _obj = self._memobj.squelch.uhf
                val = RadioSettingValueInteger(0, 123,
                          getattr(_obj, "sql%i" % (index)))
                if index == 0:
                    val.set_mutable(False)
                name = "%s Squelch %i" % (band.upper(), index)
                rs = RadioSetting(key, name, val)
                service.append(rs)

        return top
Ejemplo n.º 4
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
Ejemplo n.º 5
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")
        dtmfd = RadioSettingGroup("dtmfd", "DTMF Decode Settings")
        service = RadioSettingGroup("service", "Service Settings")
        top = RadioSettings(basic, advanced, other, work, fm_preset, dtmfe,
                            dtmfd, 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)

        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.tdrab > 0x02:
            val = 0x00
        else:
            val = _mem.settings.tdrab
        rs = RadioSetting("settings.tdrab", "Dual Watch TX Priority",
                          RadioSettingValueList(LIST_OFFAB, LIST_OFFAB[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)

        rs = RadioSetting("settings.dani", "Decode ANI",
                          RadioSettingValueBoolean(_mem.settings.dani))
        basic.append(rs)

        if _mem.settings.dtmfg > 0x3C:
            val = 0x14
        else:
            val = _mem.settings.dtmfg
        rs = RadioSetting("settings.dtmfg", "DTMF Gain",
                          RadioSettingValueInteger(0, 60, val))
        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)

        if str(_mem.firmware_msg.line1) == "UVVG302":
            lower = 136
            upper = 174
        else:
            lower = 130
            upper = 179
        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)

        if str(_mem.firmware_msg.line1) == "UVVG302":
            lower = 200
            upper = 230
        else:
            lower = 220
            upper = 225
        rs = RadioSetting(
            "limits.vhf2.lower", "VHF2 Lower Limit (MHz)",
            RadioSettingValueInteger(lower, upper, _mem.limits.vhf2.lower))
        other.append(rs)

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

        if str(_mem.firmware_msg.line1) == "UVVG302":
            lower = 400
            upper = 480
        else:
            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)
            _vhf2_lower = int(_mem.limits.vhf2.lower)
            _vhf2_upper = int(_mem.limits.vhf2.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 + 1) * 1000000 <= value and \
                value < _vhf2_lower * 1000000:
                raise InvalidValueError(msg % (_vhf_upper, _vhf2_lower))
            if (_vhf2_upper + 1) * 1000000 <= value and \
                value < _uhf_lower * 1000000:
                raise InvalidValueError(msg % (_vhf2_upper, _uhf_lower))
            msg = ("Can't be greater than %i.9975")
            if value > 99000000 and value >= (_uhf_upper + 1) * 1000000:
                raise InvalidValueError(msg % (_uhf_upper))
            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 encode settings
        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, 16, _code, False)
            val.set_charset(DTMF_CHARS)
            rs = RadioSetting("pttid/%i.code" % i, "Signal Code %i" % (i + 1),
                              val)

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

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

        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, 7, _code, False)
        val.set_charset(DTMF_CHARS)
        rs = RadioSetting("ani.code", "ANI Code", val)

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

        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmfe.append(rs)

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

        # DTMF decode settings
        rs = RadioSetting("ani.mastervice", "Master and Vice ID",
                          RadioSettingValueBoolean(_mem.ani.mastervice))
        dtmfd.append(rs)

        _codeobj = _mem.ani.masterid
        _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.masterid", "Master Control ID", val)

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

        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmfd.append(rs)

        rs = RadioSetting("ani.minspection", "Master Inspection",
                          RadioSettingValueBoolean(_mem.ani.minspection))
        dtmfd.append(rs)

        rs = RadioSetting("ani.mmonitor", "Master Monitor",
                          RadioSettingValueBoolean(_mem.ani.mmonitor))
        dtmfd.append(rs)

        rs = RadioSetting("ani.mstun", "Master Stun",
                          RadioSettingValueBoolean(_mem.ani.mstun))
        dtmfd.append(rs)

        rs = RadioSetting("ani.mkill", "Master Kill",
                          RadioSettingValueBoolean(_mem.ani.mkill))
        dtmfd.append(rs)

        rs = RadioSetting("ani.mrevive", "Master Revive",
                          RadioSettingValueBoolean(_mem.ani.mrevive))
        dtmfd.append(rs)

        _codeobj = _mem.ani.viceid
        _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.viceid", "Vice Control ID", val)

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

        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmfd.append(rs)

        rs = RadioSetting("ani.vinspection", "Vice Inspection",
                          RadioSettingValueBoolean(_mem.ani.vinspection))
        dtmfd.append(rs)

        rs = RadioSetting("ani.vmonitor", "Vice Monitor",
                          RadioSettingValueBoolean(_mem.ani.vmonitor))
        dtmfd.append(rs)

        rs = RadioSetting("ani.vstun", "Vice Stun",
                          RadioSettingValueBoolean(_mem.ani.vstun))
        dtmfd.append(rs)

        rs = RadioSetting("ani.vkill", "Vice Kill",
                          RadioSettingValueBoolean(_mem.ani.vkill))
        dtmfd.append(rs)

        rs = RadioSetting("ani.vrevive", "Vice Revive",
                          RadioSettingValueBoolean(_mem.ani.vrevive))
        dtmfd.append(rs)

        _codeobj = _mem.ani.inspection
        _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 8, _code, False)
        val.set_charset(DTMF_CHARS)
        rs = RadioSetting("ani.inspection", "Inspection Code", val)

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

        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmfd.append(rs)

        _codeobj = _mem.ani.monitor
        _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 8, _code, False)
        val.set_charset(DTMF_CHARS)
        rs = RadioSetting("ani.monitor", "Monitor Code", val)

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

        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmfd.append(rs)

        _codeobj = _mem.ani.alarmcode
        _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 8, _code, False)
        val.set_charset(DTMF_CHARS)
        rs = RadioSetting("ani.alarm", "Alarm Code", val)

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

        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmfd.append(rs)

        _codeobj = _mem.ani.stun
        _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 8, _code, False)
        val.set_charset(DTMF_CHARS)
        rs = RadioSetting("ani.stun", "Stun Code", val)

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

        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmfd.append(rs)

        _codeobj = _mem.ani.kill
        _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 8, _code, False)
        val.set_charset(DTMF_CHARS)
        rs = RadioSetting("ani.kill", "Kill Code", val)

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

        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmfd.append(rs)

        _codeobj = _mem.ani.revive
        _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 8, _code, False)
        val.set_charset(DTMF_CHARS)
        rs = RadioSetting("ani.revive", "Revive Code", val)

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

        rs.set_apply_callback(apply_code, self._memobj.ani)
        dtmfd.append(rs)

        def apply_dmtf_listvalue(setting, obj):
            LOG.debug("Setting value: " + str(setting.value) + " from list")
            val = str(setting.value)
            index = LIST_DTMF_SPECIAL_DIGITS.index(val)
            val = LIST_DTMF_SPECIAL_VALUES[index]
            obj.set_value(val)

        if _mem.ani.groupcode in LIST_DTMF_SPECIAL_VALUES:
            idx = LIST_DTMF_SPECIAL_VALUES.index(_mem.ani.groupcode)
        else:
            idx = LIST_DTMF_SPECIAL_VALUES.index(0x0B)
        rs = RadioSetting(
            "ani.groupcode", "Group Code",
            RadioSettingValueList(LIST_DTMF_SPECIAL_DIGITS,
                                  LIST_DTMF_SPECIAL_DIGITS[idx]))
        rs.set_apply_callback(apply_dmtf_listvalue, _mem.ani.groupcode)
        dtmfd.append(rs)

        if _mem.ani.spacecode in LIST_DTMF_SPECIAL_VALUES:
            idx = LIST_DTMF_SPECIAL_VALUES.index(_mem.ani.spacecode)
        else:
            idx = LIST_DTMF_SPECIAL_VALUES.index(0x0C)
        rs = RadioSetting(
            "ani.spacecode", "Space Code",
            RadioSettingValueList(LIST_DTMF_SPECIAL_DIGITS,
                                  LIST_DTMF_SPECIAL_DIGITS[idx]))
        rs.set_apply_callback(apply_dmtf_listvalue, _mem.ani.spacecode)
        dtmfd.append(rs)

        if _mem.ani.resettime > 0x9F:
            val = 0x4F
        else:
            val = _mem.ani.resettime
        rs = RadioSetting(
            "ani.resettime", "Reset Time",
            RadioSettingValueList(LIST_RESETTIME, LIST_RESETTIME[val]))
        dtmfd.append(rs)

        if _mem.ani.delayproctime > 0x27:
            val = 0x04
        else:
            val = _mem.ani.delayproctime
        rs = RadioSetting(
            "ani.delayproctime", "Delay Processing Time",
            RadioSettingValueList(LIST_DELAYPROCTIME, LIST_DELAYPROCTIME[val]))
        dtmfd.append(rs)

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

        return top
Ejemplo n.º 6
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