Exemple #1
0
    def _get_dtmf_settings(self):
        menu = RadioSettingGroup("dtmf_settings", "DTMF")
        dtmf = self._memobj.scan_settings

        val = RadioSettingValueList(
            self._DTMF_MODE,
            self._DTMF_MODE[dtmf.dtmf_mode])
        rs = RadioSetting("scan_settings.dtmf_mode", "DTMF Mode", val)
        menu.append(rs)

        val = RadioSettingValueList(
            self._DTMF_DELAY,
            self._DTMF_DELAY[dtmf.dtmf_delay])
        rs = RadioSetting(
            "scan_settings.dtmf_delay", "DTMF Delay", val)
        menu.append(rs)

        val = RadioSettingValueList(
            self._DTMF_SPEED,
            self._DTMF_SPEED[dtmf.dtmf_speed])
        rs = RadioSetting(
            "scan_settings.dtmf_speed", "DTMF Speed", val)
        menu.append(rs)

        for i in range(10):

            name = "dtmf_%02d" % (i + 1)
            if i == 9:
                name = "dtmf_%02d" % 0

            dtmfsetting = self._memobj.dtmf[i]
            dtmfstr = ""
            for c in dtmfsetting.memory:
                if c == 0xFF:
                    break
                if c < len(FT70_DTMF_CHARS):
                    dtmfstr += FT70_DTMF_CHARS[c]
            dtmfentry = RadioSettingValueString(0, 16, dtmfstr)
            dtmfentry.set_charset(
                FT70_DTMF_CHARS + list("abcdef "))  # Allow input in lowercase, space ? validation fails otherwise
            rs = RadioSetting(name, name.upper(), dtmfentry)
            rs.set_apply_callback(self.apply_dtmf, i)
            menu.append(rs)

        return menu
Exemple #2
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        dtmf = RadioSettingGroup("dtmf", "DTMF")
        arts = RadioSettingGroup("arts", "ARTS")
        prog = RadioSettingGroup("prog", "Programmable Buttons")

        top = RadioSettings(basic, dtmf, arts, prog)

        basic.append(RadioSetting(
                "priority_revert", "Priority Revert",
                RadioSettingValueBoolean(_settings.priority_revert)))

        basic.append(RadioSetting(
                "memory_only", "Memory Only mode",
                RadioSettingValueBoolean(_settings.memory_only)))

        opts = ["off"] + ["%0.1f" % (t / 60.0) for t in range(30, 750, 30)]
        basic.append(RadioSetting(
                "apo", "APO time (hrs)",
                RadioSettingValueList(opts, opts[_settings.apo])))

        basic.append(RadioSetting(
                "beep_scan", "Beep: Scan",
                RadioSettingValueBoolean(_settings.beep_scan)))

        basic.append(RadioSetting(
                "beep_edge", "Beep: Edge",
                RadioSettingValueBoolean(_settings.beep_edge)))

        basic.append(RadioSetting(
                "beep_key", "Beep: Key",
                RadioSettingValueBoolean(_settings.beep_key)))

        opts = ["T/RX Normal", "RX Reverse", "TX Reverse", "T/RX Reverse"]
        basic.append(RadioSetting(
                "dcs_polarity", "DCS polarity",
                RadioSettingValueList(opts, opts[_settings.dcs_polarity])))

        opts = ["off", "dim 1", "dim 2", "dim 3"]
        basic.append(RadioSetting(
                "dimmer", "Dimmer",
                RadioSettingValueList(opts, opts[_settings.dimmer])))

        opts = ["manual", "auto", "1-auto"]
        basic.append(RadioSetting(
                "hyper_write", "Hyper Write",
                RadioSettingValueList(opts, opts[_settings.hyper_write])))

        opts = ["", "key", "dial", "key+dial", "ptt",
                "ptt+key", "ptt+dial", "all"]
        basic.append(RadioSetting(
                "lock", "Lock mode",
                RadioSettingValueList(opts, opts[_settings.lock])))

        opts = ["MH-42", "MH-48"]
        basic.append(RadioSetting(
                "microphone_type", "Microphone Type",
                RadioSettingValueList(opts, opts[_settings.microphone_type])))

        opts = ["off"] + ["S-%d" % n for n in range(2, 10)] + ["S-Full"]
        basic.append(RadioSetting(
                "rf_sql", "RF Squelch",
                RadioSettingValueList(opts, opts[_settings.rf_sql])))

        opts = ["time", "hold", "busy"]
        basic.append(RadioSetting(
                "scan_resume", "Scan Resume",
                RadioSettingValueList(opts, opts[_settings.scan_resume])))

        opts = ["single", "continuous"]
        basic.append(RadioSetting(
                "smart_search", "Smart Search",
                RadioSettingValueList(opts, opts[_settings.smart_search])))

        opts = ["off"] + ["%d" % t for t in range(1, 31)]
        basic.append(RadioSetting(
                "tot", "Time-out timer (mins)",
                RadioSettingValueList(opts, opts[_settings.tot])))

        # dtmf tab

        opts = ["50", "100", "250", "450", "750", "1000"]
        dtmf.append(RadioSetting(
                "dtmf_delay", "DTMF delay (ms)",
                RadioSettingValueList(opts, opts[_settings.dtmf_delay])))

        opts = ["50", "75", "100"]
        dtmf.append(RadioSetting(
                "dtmf_speed", "DTMF speed (ms)",
                RadioSettingValueList(opts, opts[_settings.dtmf_speed])))

        for i in range(16):
            name = "dtmf%02d" % i
            dtmfsetting = self._memobj.dtmf[i]
            dtmfstr = ""
            for c in dtmfsetting.memory:
                if c == 0xFF:
                    break
                if c < len(DTMFCHARSET):
                    dtmfstr += DTMFCHARSET[c]
            LOG.debug(dtmfstr)
            dtmfentry = RadioSettingValueString(0, 16, dtmfstr)
            dtmfentry.set_charset(DTMFCHARSET + list(" "))
            rs = RadioSetting(name, name.upper(), dtmfentry)
            dtmf.append(rs)

        # arts tab

        opts = ["off", "in range", "always"]
        arts.append(RadioSetting(
                "arts_mode", "ARTS beep",
                RadioSettingValueList(opts, opts[_settings.arts_mode])))

        opts = ["15", "25"]
        arts.append(RadioSetting(
                "arts_interval", "ARTS interval",
                RadioSettingValueList(opts, opts[_settings.arts_interval])))

        arts.append(RadioSetting(
                "arts_cwid_enable", "CW ID",
                RadioSettingValueBoolean(_settings.arts_cwid_enable)))

        _arts_cwid = self._memobj.arts_cwid
        cwid = RadioSettingValueString(
                0, 16, self._decode_chars(_arts_cwid.get_value()))
        cwid.set_charset(CHARSET)
        arts.append(RadioSetting("arts_cwid", "CW ID", cwid))

        # prog buttons

        opts = ["WX", "Reverse", "Repeater", "SQL Off", "Lock", "Dimmer"]
        prog.append(RadioSetting(
                "prog_panel_acc", "Prog Panel - Low(ACC)",
                RadioSettingValueList(opts, opts[_settings.prog_panel_acc])))

        opts = ["Reverse", "Home"]
        prog.append(RadioSetting(
                "prog_tone_vm", "TONE | V/M",
                RadioSettingValueList(opts, opts[_settings.prog_tone_vm])))

        opts = ["" for n in range(26)] + \
            ["Priority", "Low", "Tone", "MHz", "Reverse", "Home", "Band",
             "VFO/MR", "Scan", "Sql Off", "TCall", "SSCH", "ARTS", "Tone Freq",
             "DCSC", "WX", "Repeater"]

        prog.append(RadioSetting(
                "prog_p1", "P1",
                RadioSettingValueList(opts, opts[_settings.prog_p1])))

        prog.append(RadioSetting(
                "prog_p2", "P2",
                RadioSettingValueList(opts, opts[_settings.prog_p2])))

        prog.append(RadioSetting(
                "prog_p3", "P3",
                RadioSettingValueList(opts, opts[_settings.prog_p3])))

        prog.append(RadioSetting(
                "prog_p4", "P4",
                RadioSettingValueList(opts, opts[_settings.prog_p4])))

        return top
Exemple #3
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        cw = RadioSettingGroup("cw", "CW")
        packet = RadioSettingGroup("packet", "Digital & packet")
        panel = RadioSettingGroup("panel", "Panel settings")
        extended = RadioSettingGroup("extended", "Extended")
        antenna = RadioSettingGroup("antenna", "Antenna selection")
        panelcontr = RadioSettingGroup("panelcontr", "Panel controls")
        top = RadioSettingGroup("top", "All Settings", basic, cw, packet,
                                panelcontr, panel, extended, antenna)

        rs = RadioSetting("ars_144", "144 ARS",
                          RadioSettingValueBoolean(_settings.ars_144))
        basic.append(rs)
        rs = RadioSetting("ars_430", "430 ARS",
                          RadioSettingValueBoolean(_settings.ars_430))
        basic.append(rs)
        rs = RadioSetting("pkt9600_mic", "Paket 9600 mic level",
                          RadioSettingValueInteger(0, 100, _settings.pkt9600_mic))
        packet.append(rs)
        options = ["enable", "disable"]
        rs = RadioSetting("disable_amfm_dial", "AM&FM Dial",
                          RadioSettingValueList(options,
                                        options[_settings.disable_amfm_dial]))
        panel.append(rs)
        rs = RadioSetting("am_mic", "AM mic level",
                          RadioSettingValueInteger(0, 100, _settings.am_mic))
        basic.append(rs)
        options = ["OFF", "1h", "2h", "3h", "4h", "5h", "6h"]
        rs = RadioSetting("apo_time", "APO time",
                          RadioSettingValueList(options,
                                        options[_settings.apo_time]))
        basic.append(rs)
        options = ["OFF", "Range", "All"]
        rs = RadioSetting("arts_beep", "ARTS beep",
                          RadioSettingValueList(options,
                                        options[_settings.arts_beep]))
        basic.append(rs)
        options = ["OFF", "ON", "Auto"]
        rs = RadioSetting("backlight", "Backlight",
                          RadioSettingValueList(options,
                                        options[_settings.backlight]))
        panel.append(rs)
        options = ["6h", "8h", "10h"]
        rs = RadioSetting("batt_chg", "Battery charge",
                          RadioSettingValueList(options,
                                        options[_settings.batt_chg]))
        basic.append(rs)
        options = ["440Hz", "880Hz"]
        rs = RadioSetting("beep_freq", "Beep frequency",
                          RadioSettingValueList(options,
                                        options[_settings.beep_freq]))
        panel.append(rs)
        rs = RadioSetting("beep_volume", "Beep volume",
                          RadioSettingValueInteger(0, 100, _settings.beep_volume))
        panel.append(rs)
        options = ["4800", "9600", "38400"]
        rs = RadioSetting("cat_rate", "CAT rate",
                          RadioSettingValueList(options,
                                        options[_settings.cat_rate]))
        basic.append(rs)
        options = ["Blue", "Amber", "Violet"]
        rs = RadioSetting("color", "Color",
                          RadioSettingValueList(options,
                                        options[_settings.color]))
        panel.append(rs)
        rs = RadioSetting("contrast", "Contrast",
                          RadioSettingValueInteger(1, 12,_settings.contrast-1))
        panel.append(rs)
        rs = RadioSetting("cw_delay", "CW delay (*10 ms)",
                          RadioSettingValueInteger(1, 250, _settings.cw_delay))
        cw.append(rs)
        rs = RadioSetting("cw_id", "CW id",
                          RadioSettingValueBoolean(_settings.cw_id))
        cw.append(rs)
        options = ["Normal", "Reverse"]
        rs = RadioSetting("cw_paddle", "CW paddle",
                          RadioSettingValueList(options,
                                        options[_settings.cw_paddle]))
        cw.append(rs)
        options = ["%i Hz" % i for i in range(300,1001,50)]
        rs = RadioSetting("cw_pitch", "CW pitch",
                          RadioSettingValueList(options,
                                        options[_settings.cw_pitch]))
        cw.append(rs)
        options = ["%i wpm" % i for i in range(4,61)]
        rs = RadioSetting("cw_speed", "CW speed",
                          RadioSettingValueList(options,
                                        options[_settings.cw_speed]))
        cw.append(rs)
        options = ["1:%1.1f" % (i/10) for i in range(25,46,1)]
        rs = RadioSetting("cw_weight", "CW weight",
                          RadioSettingValueList(options,
                                        options[_settings.cw_weight]))
        cw.append(rs)
        rs = RadioSetting("dig_disp", "Dig disp (*10 Hz)",
                          RadioSettingValueInteger(-300, 300, _settings.dig_disp))
        packet.append(rs)
        rs = RadioSetting("dig_mic", "Dig mic",
                          RadioSettingValueInteger(0, 100, _settings.dig_mic))
        packet.append(rs)
        options = ["RTTY", "PSK31-L", "PSK31-U", "USER-L", "USER-U"]
        rs = RadioSetting("dig_mode", "Dig mode",
                          RadioSettingValueList(options,
                                        options[_settings.dig_mode]))
        packet.append(rs)
        rs = RadioSetting("dig_shift", "Dig shift (*10 Hz)",
                          RadioSettingValueInteger(-300, 300, _settings.dig_shift))
        packet.append(rs)
        rs = RadioSetting("fm_mic", "FM mic",
                          RadioSettingValueInteger(0, 100, _settings.fm_mic))
        basic.append(rs)
        options = ["Dial", "Freq", "Panel"]
        rs = RadioSetting("lock_mode", "Lock mode",
                          RadioSettingValueList(options,
                                        options[_settings.lock_mode]))
        panel.append(rs)
        options = ["Fine", "Coarse"]
        rs = RadioSetting("main_step", "Main step",
                          RadioSettingValueList(options,
                                        options[_settings.main_step]))
        panel.append(rs)
        rs = RadioSetting("mem_group", "Mem group",
                          RadioSettingValueBoolean(_settings.mem_group))
        basic.append(rs)
        rs = RadioSetting("mic_key", "Mic key",
                          RadioSettingValueBoolean(_settings.mic_key))
        cw.append(rs)
        rs = RadioSetting("mic_scan", "Mic scan",
                          RadioSettingValueBoolean(_settings.mic_scan))
        basic.append(rs)
        options = ["Off", "SSB", "CW"]
        rs = RadioSetting("op_filter", "Optional filter",
                          RadioSettingValueList(options,
                                        options[_settings.op_filter]))
        basic.append(rs)
        rs = RadioSetting("pkt_mic", "Packet mic",
                          RadioSettingValueInteger(0, 100, _settings.pkt_mic))
        packet.append(rs)
        options = ["1200", "9600"]
        rs = RadioSetting("pkt_rate", "Packet rate",
                          RadioSettingValueList(options,
                                        options[_settings.pkt_rate]))
        packet.append(rs)
        options = ["Off", "3 sec", "5 sec", "10 sec"]
        rs = RadioSetting("resume_scan", "Resume scan",
                          RadioSettingValueList(options,
                                        options[_settings.resume_scan]))
        basic.append(rs)
        options = ["Cont", "Chk"]
        rs = RadioSetting("scope", "Scope",
                          RadioSettingValueList(options,
                                        options[_settings.scope]))
        basic.append(rs)
        rs = RadioSetting("sidetone", "Sidetone",
                          RadioSettingValueInteger(0, 100, _settings.sidetone))
        cw.append(rs)
        options = ["RF-Gain", "Squelch"]
        rs = RadioSetting("sql_rf_gain", "Squelch/RF-Gain",
                          RadioSettingValueList(options,
                                        options[_settings.sql_rf_gain]))
        panel.append(rs)
        rs = RadioSetting("ssb_mic", "SSB Mic",
                          RadioSettingValueInteger(0, 100, _settings.ssb_mic))
        basic.append(rs)
        options = ["%i" % i for i in range(0, 21)]
        options[0] = "Off"
        rs = RadioSetting("tot_time", "Time-out timer",
                          RadioSettingValueList(options,
                                        options[_settings.tot_time]))
        basic.append(rs)
        rs = RadioSetting("vox_delay", "VOX delay (*100 ms)",
                          RadioSettingValueInteger(1, 25, _settings.vox_delay))
        basic.append(rs)
        rs = RadioSetting("vox_gain", "VOX Gain",
                          RadioSettingValueInteger(0, 100, _settings.vox_gain))
        basic.append(rs)
        rs = RadioSetting("extended_menu", "Extended menu",
                          RadioSettingValueBoolean(_settings.extended_menu))
        extended.append(rs)
        options = ["Tn-Rn", "Tn-Riv", "Tiv-Rn", "Tiv-Riv"]
        rs = RadioSetting("dcs_inv", "DCS coding",
                          RadioSettingValueList(options,
                                        options[_settings.dcs_inv]))
        extended.append(rs)
        rs = RadioSetting("r_lsb_car", "LSB Rx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30, _settings.r_lsb_car))
        extended.append(rs)
        rs = RadioSetting("r_usb_car", "USB Rx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30, _settings.r_usb_car))
        extended.append(rs)
        rs = RadioSetting("t_lsb_car", "LSB Tx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30, _settings.t_lsb_car))
        extended.append(rs)
        rs = RadioSetting("t_usb_car", "USB Tx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30, _settings.t_usb_car))
        extended.append(rs)

        options = ["Hi", "L3", "L2", "L1"]
        rs = RadioSetting("tx_power", "TX power",
                          RadioSettingValueList(options,
                                        options[_settings.tx_power]))
        basic.append(rs)

        options = ["Front", "Rear"]
        rs = RadioSetting("hf_antenna", "HF",
                          RadioSettingValueList(options,
                                        options[_settings.hf_antenna]))
        antenna.append(rs)
        rs = RadioSetting("sixm_antenna", "6M",
                          RadioSettingValueList(options,
                                        options[_settings.sixm_antenna]))
        antenna.append(rs)
        rs = RadioSetting("bc_antenna", "Broadcasting",
                          RadioSettingValueList(options,
                                        options[_settings.bc_antenna]))
        antenna.append(rs)
        rs = RadioSetting("air_antenna", "Air band",
                          RadioSettingValueList(options,
                                        options[_settings.air_antenna]))
        antenna.append(rs)
        rs = RadioSetting("vhf_antenna", "VHF",
                          RadioSettingValueList(options,
                                        options[_settings.vhf_antenna]))
        antenna.append(rs)
        rs = RadioSetting("uhf_antenna", "UHF",
                          RadioSettingValueList(options,
                                        options[_settings.uhf_antenna]))
        antenna.append(rs)

        s = RadioSettingValueString(0, 7, 
                            ''.join([self._CALLSIGN_CHARSET[x] for x in 
                                        self._memobj.callsign]))
        s.set_charset(self._CALLSIGN_CHARSET)
        rs = RadioSetting("callsign", "Callsign", s)
        cw.append(rs)

        rs = RadioSetting("spl", "Split",
                          RadioSettingValueBoolean(_settings.spl))
        panelcontr.append(rs)
        options = ["None", "Up", "Down"]
        rs = RadioSetting("scn_mode", "Scan mode",
                          RadioSettingValueList(options,
                                        options[_settings.scn_mode]))
        panelcontr.append(rs)
        rs = RadioSetting("pri", "Priority",
                          RadioSettingValueBoolean(_settings.pri))
        panelcontr.append(rs)
        rs = RadioSetting("dw", "Dual watch",
                          RadioSettingValueBoolean(_settings.dw))
        panelcontr.append(rs)
        rs = RadioSetting("art", "Auto-range transponder",
                          RadioSettingValueBoolean(_settings.art))
        panelcontr.append(rs)
        rs = RadioSetting("nb", "Noise blanker",
                          RadioSettingValueBoolean(_settings.nb))
        panelcontr.append(rs)
        options = ["Auto", "Fast", "Slow", "Off"]
        rs = RadioSetting("agc", "AGC",
                          RadioSettingValueList(options,
                                        options[_settings.agc]))
        panelcontr.append(rs)
        options = ["PWR", "ALC", "SWR", "MOD"]
        rs = RadioSetting("pwr_meter_mode", "Power meter mode",
                          RadioSettingValueList(options,
                                        options[_settings.pwr_meter_mode]))
        panelcontr.append(rs)
        rs = RadioSetting("vox", "Vox",
                          RadioSettingValueBoolean(_settings.vox))
        panelcontr.append(rs)
        rs = RadioSetting("bk", "Semi break-in",
                          RadioSettingValueBoolean(_settings.bk))
        cw.append(rs)
        rs = RadioSetting("kyr", "Keyer",
                          RadioSettingValueBoolean(_settings.kyr))
        cw.append(rs)
        options = ["enabled", "disabled"]
        rs = RadioSetting("fst", "Fast",
                          RadioSettingValueList(options,
                                        options[_settings.fst]))
        panelcontr.append(rs)
        options = ["enabled", "disabled"]
        rs = RadioSetting("lock", "Lock",
                          RadioSettingValueList(options,
                                        options[_settings.lock]))
        panelcontr.append(rs)

        return top
Exemple #4
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        cw = RadioSettingGroup("cw", "CW")
        packet = RadioSettingGroup("packet", "Digital & packet")
        panel = RadioSettingGroup("panel", "Panel settings")
        extended = RadioSettingGroup("extended", "Extended")
        antenna = RadioSettingGroup("antenna", "Antenna selection")
        panelcontr = RadioSettingGroup("panelcontr", "Panel controls")

        top = RadioSettings(basic, cw, packet,
                            panelcontr, panel, extended, antenna)

        rs = RadioSetting("ars_144", "144 ARS",
                          RadioSettingValueBoolean(_settings.ars_144))
        basic.append(rs)
        rs = RadioSetting("ars_430", "430 ARS",
                          RadioSettingValueBoolean(_settings.ars_430))
        basic.append(rs)
        rs = RadioSetting("pkt9600_mic", "Paket 9600 mic level",
                          RadioSettingValueInteger(0, 100,
                                                   _settings.pkt9600_mic))
        packet.append(rs)
        options = ["enable", "disable"]
        rs = RadioSetting("disable_amfm_dial", "AM&FM Dial",
                          RadioSettingValueList(options,
                                                options[
                                                    _settings.disable_amfm_dial
                                                    ]))
        panel.append(rs)
        rs = RadioSetting("am_mic", "AM mic level",
                          RadioSettingValueInteger(0, 100, _settings.am_mic))
        basic.append(rs)
        options = ["OFF", "1h", "2h", "3h", "4h", "5h", "6h"]
        rs = RadioSetting("apo_time", "APO time",
                          RadioSettingValueList(options,
                                                options[_settings.apo_time]))
        basic.append(rs)
        options = ["OFF", "Range", "All"]
        rs = RadioSetting("arts_beep", "ARTS beep",
                          RadioSettingValueList(options,
                                                options[_settings.arts_beep]))
        basic.append(rs)
        options = ["OFF", "ON", "Auto"]
        rs = RadioSetting("backlight", "Backlight",
                          RadioSettingValueList(options,
                                                options[_settings.backlight]))
        panel.append(rs)
        options = ["6h", "8h", "10h"]
        rs = RadioSetting("batt_chg", "Battery charge",
                          RadioSettingValueList(options,
                                                options[_settings.batt_chg]))
        basic.append(rs)
        options = ["440Hz", "880Hz"]
        rs = RadioSetting("beep_freq", "Beep frequency",
                          RadioSettingValueList(options,
                                                options[_settings.beep_freq]))
        panel.append(rs)
        rs = RadioSetting("beep_volume", "Beep volume",
                          RadioSettingValueInteger(0, 100,
                                                   _settings.beep_volume))
        panel.append(rs)
        options = ["4800", "9600", "38400"]
        rs = RadioSetting("cat_rate", "CAT rate",
                          RadioSettingValueList(options,
                                                options[_settings.cat_rate]))
        basic.append(rs)
        options = ["Blue", "Amber", "Violet"]
        rs = RadioSetting("color", "Color",
                          RadioSettingValueList(options,
                                                options[_settings.color]))
        panel.append(rs)
        rs = RadioSetting("contrast", "Contrast",
                          RadioSettingValueInteger(1, 12,
                                                   _settings.contrast - 1))
        panel.append(rs)
        rs = RadioSetting("cw_delay", "CW delay (*10 ms)",
                          RadioSettingValueInteger(1, 250,
                                                   _settings.cw_delay))
        cw.append(rs)
        rs = RadioSetting("cw_id", "CW id",
                          RadioSettingValueBoolean(_settings.cw_id))
        cw.append(rs)
        options = ["Normal", "Reverse"]
        rs = RadioSetting("cw_paddle", "CW paddle",
                          RadioSettingValueList(options,
                                                options[_settings.cw_paddle]))
        cw.append(rs)
        options = ["%i Hz" % i for i in range(300, 1001, 50)]
        rs = RadioSetting("cw_pitch", "CW pitch",
                          RadioSettingValueList(options,
                                                options[_settings.cw_pitch]))
        cw.append(rs)
        options = ["%i wpm" % i for i in range(4, 61)]
        rs = RadioSetting("cw_speed", "CW speed",
                          RadioSettingValueList(options,
                                                options[_settings.cw_speed]))
        cw.append(rs)
        options = ["1:%1.1f" % (i / 10) for i in range(25, 46, 1)]
        rs = RadioSetting("cw_weight", "CW weight",
                          RadioSettingValueList(options,
                                                options[_settings.cw_weight]))
        cw.append(rs)
        rs = RadioSetting("dig_disp", "Dig disp (*10 Hz)",
                          RadioSettingValueInteger(-300, 300,
                                                   _settings.dig_disp))
        packet.append(rs)
        rs = RadioSetting("dig_mic", "Dig mic",
                          RadioSettingValueInteger(0, 100,
                                                   _settings.dig_mic))
        packet.append(rs)
        options = ["RTTY", "PSK31-L", "PSK31-U", "USER-L", "USER-U"]
        rs = RadioSetting("dig_mode", "Dig mode",
                          RadioSettingValueList(options,
                                                options[_settings.dig_mode]))
        packet.append(rs)
        rs = RadioSetting("dig_shift", "Dig shift (*10 Hz)",
                          RadioSettingValueInteger(-300, 300,
                                                   _settings.dig_shift))
        packet.append(rs)
        rs = RadioSetting("fm_mic", "FM mic",
                          RadioSettingValueInteger(0, 100,
                                                   _settings.fm_mic))
        basic.append(rs)
        options = ["Dial", "Freq", "Panel"]
        rs = RadioSetting("lock_mode", "Lock mode",
                          RadioSettingValueList(options,
                                                options[_settings.lock_mode]))
        panel.append(rs)
        options = ["Fine", "Coarse"]
        rs = RadioSetting("main_step", "Main step",
                          RadioSettingValueList(options,
                                                options[_settings.main_step]))
        panel.append(rs)
        rs = RadioSetting("mem_group", "Mem group",
                          RadioSettingValueBoolean(_settings.mem_group))
        basic.append(rs)
        rs = RadioSetting("mic_key", "Mic key",
                          RadioSettingValueBoolean(_settings.mic_key))
        cw.append(rs)
        rs = RadioSetting("mic_scan", "Mic scan",
                          RadioSettingValueBoolean(_settings.mic_scan))
        basic.append(rs)
        options = ["Off", "SSB", "CW"]
        rs = RadioSetting("op_filter", "Optional filter",
                          RadioSettingValueList(options,
                                                options[_settings.op_filter]))
        basic.append(rs)
        rs = RadioSetting("pkt_mic", "Packet mic",
                          RadioSettingValueInteger(0, 100, _settings.pkt_mic))
        packet.append(rs)
        options = ["1200", "9600"]
        rs = RadioSetting("pkt_rate", "Packet rate",
                          RadioSettingValueList(options,
                                                options[_settings.pkt_rate]))
        packet.append(rs)
        options = ["Off", "3 sec", "5 sec", "10 sec"]
        rs = RadioSetting("resume_scan", "Resume scan",
                          RadioSettingValueList(options,
                                                options[_settings.resume_scan])
                          )
        basic.append(rs)
        options = ["Cont", "Chk"]
        rs = RadioSetting("scope", "Scope",
                          RadioSettingValueList(options,
                                                options[_settings.scope]))
        basic.append(rs)
        rs = RadioSetting("sidetone", "Sidetone",
                          RadioSettingValueInteger(0, 100, _settings.sidetone))
        cw.append(rs)
        options = ["RF-Gain", "Squelch"]
        rs = RadioSetting("sql_rf_gain", "Squelch/RF-Gain",
                          RadioSettingValueList(options,
                                                options[_settings.sql_rf_gain])
                          )
        panel.append(rs)
        rs = RadioSetting("ssb_mic", "SSB Mic",
                          RadioSettingValueInteger(0, 100, _settings.ssb_mic))
        basic.append(rs)
        options = ["%i" % i for i in range(0, 21)]
        options[0] = "Off"
        rs = RadioSetting("tot_time", "Time-out timer",
                          RadioSettingValueList(options,
                                                options[_settings.tot_time]))
        basic.append(rs)
        rs = RadioSetting("vox_delay", "VOX delay (*100 ms)",
                          RadioSettingValueInteger(1, 25, _settings.vox_delay))
        basic.append(rs)
        rs = RadioSetting("vox_gain", "VOX Gain",
                          RadioSettingValueInteger(0, 100, _settings.vox_gain))
        basic.append(rs)
        rs = RadioSetting("extended_menu", "Extended menu",
                          RadioSettingValueBoolean(_settings.extended_menu))
        extended.append(rs)
        options = ["Tn-Rn", "Tn-Riv", "Tiv-Rn", "Tiv-Riv"]
        rs = RadioSetting("dcs_inv", "DCS coding",
                          RadioSettingValueList(options,
                                                options[_settings.dcs_inv]))
        extended.append(rs)
        rs = RadioSetting("r_lsb_car", "LSB Rx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30,
                                                   _settings.r_lsb_car))
        extended.append(rs)
        rs = RadioSetting("r_usb_car", "USB Rx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30,
                                                   _settings.r_usb_car))
        extended.append(rs)
        rs = RadioSetting("t_lsb_car", "LSB Tx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30,
                                                   _settings.t_lsb_car))
        extended.append(rs)
        rs = RadioSetting("t_usb_car", "USB Tx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30,
                                                   _settings.t_usb_car))
        extended.append(rs)

        options = ["Hi", "L3", "L2", "L1"]
        rs = RadioSetting("tx_power", "TX power",
                          RadioSettingValueList(options,
                                                options[_settings.tx_power]))
        basic.append(rs)

        options = ["Front", "Rear"]
        rs = RadioSetting("hf_antenna", "HF",
                          RadioSettingValueList(options,
                                                options[_settings.hf_antenna]))
        antenna.append(rs)
        rs = RadioSetting("sixm_antenna", "6M",
                          RadioSettingValueList(options,
                                                options[_settings.sixm_antenna]
                                                ))
        antenna.append(rs)
        rs = RadioSetting("bc_antenna", "Broadcasting",
                          RadioSettingValueList(options,
                                                options[_settings.bc_antenna]))
        antenna.append(rs)
        rs = RadioSetting("air_antenna", "Air band",
                          RadioSettingValueList(options,
                                                options[_settings.air_antenna])
                          )
        antenna.append(rs)
        rs = RadioSetting("vhf_antenna", "VHF",
                          RadioSettingValueList(options,
                                                options[_settings.vhf_antenna])
                          )
        antenna.append(rs)
        rs = RadioSetting("uhf_antenna", "UHF",
                          RadioSettingValueList(options,
                                                options[_settings.uhf_antenna])
                          )
        antenna.append(rs)

        st = RadioSettingValueString(0, 7, ''.join([self._CALLSIGN_CHARSET[x]
                                     for x in self._memobj.callsign]))
        st.set_charset(self._CALLSIGN_CHARSET)
        rs = RadioSetting("callsign", "Callsign", st)
        cw.append(rs)

        rs = RadioSetting("spl", "Split",
                          RadioSettingValueBoolean(_settings.spl))
        panelcontr.append(rs)
        options = ["None", "Up", "Down"]
        rs = RadioSetting("scn_mode", "Scan mode",
                          RadioSettingValueList(options,
                                                options[_settings.scn_mode]))
        panelcontr.append(rs)
        rs = RadioSetting("pri", "Priority",
                          RadioSettingValueBoolean(_settings.pri))
        panelcontr.append(rs)
        rs = RadioSetting("dw", "Dual watch",
                          RadioSettingValueBoolean(_settings.dw))
        panelcontr.append(rs)
        rs = RadioSetting("art", "Auto-range transponder",
                          RadioSettingValueBoolean(_settings.art))
        panelcontr.append(rs)
        rs = RadioSetting("nb", "Noise blanker",
                          RadioSettingValueBoolean(_settings.nb))
        panelcontr.append(rs)
        options = ["Auto", "Fast", "Slow", "Off"]
        rs = RadioSetting("agc", "AGC",
                          RadioSettingValueList(options, options[_settings.agc]
                                                ))
        panelcontr.append(rs)
        options = ["PWR", "ALC", "SWR", "MOD"]
        rs = RadioSetting("pwr_meter_mode", "Power meter mode",
                          RadioSettingValueList(options,
                                                options[
                                                    _settings.pwr_meter_mode
                                                        ]))
        panelcontr.append(rs)
        rs = RadioSetting("vox", "Vox",
                          RadioSettingValueBoolean(_settings.vox))
        panelcontr.append(rs)
        rs = RadioSetting("bk", "Semi break-in",
                          RadioSettingValueBoolean(_settings.bk))
        cw.append(rs)
        rs = RadioSetting("kyr", "Keyer",
                          RadioSettingValueBoolean(_settings.kyr))
        cw.append(rs)
        options = ["enabled", "disabled"]
        rs = RadioSetting("fst", "Fast",
                          RadioSettingValueList(options, options[_settings.fst]
                                                ))
        panelcontr.append(rs)
        options = ["enabled", "disabled"]
        rs = RadioSetting("lock", "Lock",
                          RadioSettingValueList(options,
                                                options[_settings.lock]))
        panelcontr.append(rs)

        return top
Exemple #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")
        service = RadioSettingGroup("service", "Service Settings")
        top = RadioSettings(basic, advanced, other, work, fm_preset, dtmfe,
                            service)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return top
Exemple #6
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        cw = RadioSettingGroup("cw", "CW")
        packet = RadioSettingGroup("packet", "Digital & packet")
        panel = RadioSettingGroup("panel", "Panel settings")
        extended = RadioSettingGroup("extended", "Extended")
        panelcontr = RadioSettingGroup("panelcontr", "Panel controls")
        top = RadioSettingGroup("top", "All Settings", basic, cw, packet,
                                panelcontr, panel, extended)

        rs = RadioSetting("extended_menu", "Extended menu",
                          RadioSettingValueBoolean(_settings.extended_menu))
        extended.append(rs)
        rs = RadioSetting("ars_144", "144MHz ARS",
                          RadioSettingValueBoolean(_settings.ars_144))
        basic.append(rs)
        rs = RadioSetting("ars_430", "430MHz ARS",
                          RadioSettingValueBoolean(_settings.ars_430))
        basic.append(rs)
        options = ["enable", "disable"]
        rs = RadioSetting(
            "disable_amfm_dial", "AM&FM Dial",
            RadioSettingValueList(options,
                                  options[_settings.disable_amfm_dial]))
        panel.append(rs)
        rs = RadioSetting("am_mic", "AM mic gain",
                          RadioSettingValueInteger(0, 100, _settings.am_mic))
        basic.append(rs)
        options = ["OFF", "1h", "2h", "3h", "4h", "5h", "6h"]
        rs = RadioSetting(
            "apo_time", "APO time",
            RadioSettingValueList(options, options[_settings.apo_time]))
        basic.append(rs)
        options = ["OFF", "Range", "All"]
        rs = RadioSetting(
            "arts_beep", "ARTS beep",
            RadioSettingValueList(options, options[_settings.arts_beep]))
        basic.append(rs)
        rs = RadioSetting("arts_id", "ARTS ID",
                          RadioSettingValueBoolean(_settings.arts_id))
        extended.append(rs)
        s = RadioSettingValueString(
            0, 10,
            ''.join([self._CALLSIGN_CHARSET[x]
                     for x in self._memobj.arts_idw]))
        s.set_charset(self._CALLSIGN_CHARSET)
        rs = RadioSetting("arts_idw", "ARTS IDW", s)
        extended.append(rs)
        s = RadioSettingValueString(
            0, 40, ''.join(
                [self._BEACON_CHARSET[x] for x in self._memobj.beacon_text1]))
        s.set_charset(self._BEACON_CHARSET)
        rs = RadioSetting("beacon_text1", "Beacon text1", s)
        extended.append(rs)
        s = RadioSettingValueString(
            0, 40, ''.join(
                [self._BEACON_CHARSET[x] for x in self._memobj.beacon_text2]))
        s.set_charset(self._BEACON_CHARSET)
        rs = RadioSetting("beacon_text2", "Beacon text2", s)
        extended.append(rs)
        s = RadioSettingValueString(
            0, 40, ''.join(
                [self._BEACON_CHARSET[x] for x in self._memobj.beacon_text3]))
        s.set_charset(self._BEACON_CHARSET)
        rs = RadioSetting("beacon_text3", "Beacon text3", s)
        extended.append(rs)
        options = ["OFF"] + ["%i sec" % i for i in range(1, 256)]
        rs = RadioSetting(
            "beacon_time", "Beacon time",
            RadioSettingValueList(options, options[_settings.beacon_time]))
        extended.append(rs)
        options = ["440Hz", "880Hz", "1760Hz"]
        rs = RadioSetting(
            "beep_tone", "Beep tone",
            RadioSettingValueList(options, options[_settings.beep_tone]))
        panel.append(rs)
        rs = RadioSetting("beep_vol", "Beep volume",
                          RadioSettingValueInteger(0, 100, _settings.beep_vol))
        panel.append(rs)
        rs = RadioSetting(
            "r_lsb_car", "LSB Rx carrier point (*10 Hz)",
            RadioSettingValueInteger(-30, 30, _settings.r_lsb_car))
        extended.append(rs)
        rs = RadioSetting(
            "r_usb_car", "USB Rx carrier point (*10 Hz)",
            RadioSettingValueInteger(-30, 30, _settings.r_usb_car))
        extended.append(rs)
        rs = RadioSetting(
            "t_lsb_car", "LSB Tx carrier point (*10 Hz)",
            RadioSettingValueInteger(-30, 30, _settings.t_lsb_car))
        extended.append(rs)
        rs = RadioSetting(
            "t_usb_car", "USB Tx carrier point (*10 Hz)",
            RadioSettingValueInteger(-30, 30, _settings.t_usb_car))
        extended.append(rs)
        options = ["4800", "9600", "38400"]
        rs = RadioSetting(
            "cat_rate", "CAT rate",
            RadioSettingValueList(options, options[_settings.cat_rate]))
        basic.append(rs)
        options = ["CAT", "Linear", "Tuner"]
        rs = RadioSetting(
            "cat_lin_tun", "CAT/LIN/TUN selection",
            RadioSettingValueList(options, options[_settings.cat_lin_tun]))
        extended.append(rs)
        options = ["MAIN", "VFO/MEM",
                   "CLAR"]  # TODO test the 3 options on non D radio
        # which have only SEL and MAIN
        rs = RadioSetting(
            "clar_dial_sel", "Clarifier dial selection",
            RadioSettingValueList(options, options[_settings.clar_dial_sel]))
        panel.append(rs)
        rs = RadioSetting("cw_auto_mode", "CW Automatic mode",
                          RadioSettingValueBoolean(_settings.cw_auto_mode))
        cw.append(rs)
        options = ["USB", "LSB", "AUTO"]
        rs = RadioSetting(
            "cw_bfo", "CW BFO",
            RadioSettingValueList(options, options[_settings.cw_bfo]))
        cw.append(rs)
        options = ["FULL"] + ["%i ms" % (i * 10) for i in range(3, 301)]
        val = (_settings.cw_delay + _settings.cw_delay_hi * 256) - 2
        rs = RadioSetting("cw_delay", "CW delay",
                          RadioSettingValueList(options, options[val]))
        cw.append(rs)
        options = ["Normal", "Reverse"]
        rs = RadioSetting(
            "cw_key_rev", "CW key reverse",
            RadioSettingValueList(options, options[_settings.cw_key_rev]))
        cw.append(rs)
        rs = RadioSetting("cw_paddle", "CW paddle",
                          RadioSettingValueBoolean(_settings.cw_paddle))
        cw.append(rs)
        options = ["%i Hz" % i for i in range(400, 801, 100)]
        rs = RadioSetting(
            "cw_pitch", "CW pitch",
            RadioSettingValueList(options, options[_settings.cw_pitch]))
        cw.append(rs)
        options = ["%i ms" % i for i in range(5, 31, 5)]
        rs = RadioSetting(
            "cw_qsk", "CW QSK",
            RadioSettingValueList(options, options[_settings.cw_qsk]))
        cw.append(rs)
        rs = RadioSetting(
            "cw_sidetone", "CW sidetone volume",
            RadioSettingValueInteger(0, 100, _settings.cw_sidetone))
        cw.append(rs)
        options = ["%i wpm" % i for i in range(4, 61)]
        rs = RadioSetting(
            "cw_speed", "CW speed",
            RadioSettingValueList(options, options[_settings.cw_speed]))
        cw.append(rs)
        options = ["Numeric", "Alphabet", "AlphaNumeric"]
        rs = RadioSetting(
            "cw_training", "CW trainig",
            RadioSettingValueList(options, options[_settings.cw_training]))
        cw.append(rs)
        options = ["1:%1.1f" % (i / 10) for i in range(25, 46, 1)]
        rs = RadioSetting(
            "cw_weight", "CW weight",
            RadioSettingValueList(options, options[_settings.cw_weight]))
        cw.append(rs)
        options = ["Tn-Rn", "Tn-Riv", "Tiv-Rn", "Tiv-Riv"]
        rs = RadioSetting(
            "dcs_inv", "DCS inv",
            RadioSettingValueList(options, options[_settings.dcs_inv]))
        extended.append(rs)
        options = ["Fine", "Coarse"]
        rs = RadioSetting(
            "dial_step", "Dial step",
            RadioSettingValueList(options, options[_settings.dial_step]))
        panel.append(rs)
        rs = RadioSetting(
            "dig_disp", "Dig disp (*10 Hz)",
            RadioSettingValueInteger(-300, 300, _settings.dig_disp))
        packet.append(rs)
        rs = RadioSetting("dig_mic", "Dig gain",
                          RadioSettingValueInteger(0, 100, _settings.dig_mic))
        packet.append(rs)
        options = ["RTTYL", "RTTYU", "PSK31-L", "PSK31-U", "USER-L", "USER-U"]
        rs = RadioSetting(
            "dig_mode", "Dig mode",
            RadioSettingValueList(options, options[_settings.dig_mode]))
        packet.append(rs)
        rs = RadioSetting(
            "dig_shift", "Dig shift (*10 Hz)",
            RadioSettingValueInteger(-300, 300, _settings.dig_shift))
        packet.append(rs)
        rs = RadioSetting("dig_vox", "Dig vox",
                          RadioSettingValueInteger(0, 100, _settings.dig_vox))
        packet.append(rs)
        options = ["ARTS", "BAND", "FIX", "MEMGRP", "MODE", "MTR", "VFO"]
        rs = RadioSetting(
            "disp_color", "Display color mode",
            RadioSettingValueList(options, options[_settings.disp_color]))
        panel.append(rs)
        rs = RadioSetting(
            "disp_color_arts", "Display color ARTS set",
            RadioSettingValueInteger(0, 1, _settings.disp_color_arts))
        panel.append(rs)
        rs = RadioSetting(
            "disp_color_band", "Display color band set",
            RadioSettingValueInteger(0, 1, _settings.disp_color_band))
        panel.append(rs)
        rs = RadioSetting(
            "disp_color_memgrp", "Display color memory group set",
            RadioSettingValueInteger(0, 1, _settings.disp_color_memgrp))
        panel.append(rs)
        rs = RadioSetting(
            "disp_color_mode", "Display color mode set",
            RadioSettingValueInteger(0, 1, _settings.disp_color_mode))
        panel.append(rs)
        rs = RadioSetting(
            "disp_color_mtr", "Display color meter set",
            RadioSettingValueInteger(0, 1, _settings.disp_color_mtr))
        panel.append(rs)
        rs = RadioSetting(
            "disp_color_vfo", "Display color VFO set",
            RadioSettingValueInteger(0, 1, _settings.disp_color_vfo))
        panel.append(rs)
        rs = RadioSetting(
            "disp_color_fix", "Display color fix set",
            RadioSettingValueInteger(1, 32, _settings.disp_color_fix + 1))
        panel.append(rs)
        rs = RadioSetting(
            "disp_contrast", "Contrast",
            RadioSettingValueInteger(3, 15, _settings.disp_contrast + 2))
        panel.append(rs)
        rs = RadioSetting(
            "disp_intensity", "Intensity",
            RadioSettingValueInteger(1, 3, _settings.disp_intensity))
        panel.append(rs)
        options = ["OFF", "Auto1", "Auto2", "ON"]
        rs = RadioSetting(
            "disp_mode", "Display backlight mode",
            RadioSettingValueList(options, options[_settings.disp_mode]))
        panel.append(rs)
        options = ["60Hz", "120Hz", "240Hz"]
        rs = RadioSetting(
            "dsp_bpf", "Dsp band pass filter",
            RadioSettingValueList(options, options[_settings.dsp_bpf]))
        cw.append(rs)
        options = [
            "100Hz", "160Hz", "220Hz", "280Hz", "340Hz", "400Hz", "460Hz",
            "520Hz", "580Hz", "640Hz", "720Hz", "760Hz", "820Hz", "880Hz",
            "940Hz", "1000Hz"
        ]
        rs = RadioSetting(
            "dsp_hpf", "Dsp hi pass filter cut off",
            RadioSettingValueList(options, options[_settings.dsp_hpf]))
        basic.append(rs)
        options = [
            "1000Hz", "1160Hz", "1320Hz", "1480Hz", "1650Hz", "1800Hz",
            "1970Hz", "2130Hz", "2290Hz", "2450Hz", "2610Hz", "2770Hz",
            "2940Hz", "3100Hz", "3260Hz", "3420Hz", "3580Hz", "3740Hz",
            "3900Hz", "4060Hz", "4230Hz", "4390Hz", "4550Hz", "4710Hz",
            "4870Hz", "5030Hz", "5190Hz", "5390Hz", "5520Hz", "5680Hz",
            "5840Hz", "6000Hz"
        ]
        rs = RadioSetting(
            "dsp_lpf", "Dsp low pass filter cut off",
            RadioSettingValueList(options, options[_settings.dsp_lpf]))
        basic.append(rs)
        options = ["OFF", "LPF", "HPF", "BOTH"]
        rs = RadioSetting(
            "dsp_mic_eq", "Dsp mic equalization",
            RadioSettingValueList(options, options[_settings.dsp_mic_eq]))
        basic.append(rs)
        rs = RadioSetting(
            "dsp_nr", "DSP noise reduction level",
            RadioSettingValueInteger(1, 16, _settings.dsp_nr + 1))
        basic.append(rs)
        # emergency only for US model
        rs = RadioSetting("fm_mic", "FM mic gain",
                          RadioSettingValueInteger(0, 100, _settings.fm_mic))
        basic.append(rs)
        rs = RadioSetting("home_vfo", "Enable HOME to VFO moving",
                          RadioSettingValueBoolean(_settings.home_vfo))
        panel.append(rs)
        options = ["Dial", "Freq", "Panel", "All"]
        rs = RadioSetting(
            "lock_mode", "Lock mode",
            RadioSettingValueList(options, options[_settings.lock_mode]))
        panel.append(rs)
        rs = RadioSetting("mem_group", "Mem group",
                          RadioSettingValueBoolean(_settings.mem_group))
        basic.append(rs)
        options = [
            "CW SIDETONE", "CW SPEED", "MHz/MEM GRP", "MIC GAIN", "NB LEVEL",
            "RF POWER", "STEP"
        ]
        rs = RadioSetting(
            "mem_vfo_dial_mode", "Mem/VFO dial mode",
            RadioSettingValueList(options,
                                  options[_settings.mem_vfo_dial_mode]))
        panel.append(rs)
        rs = RadioSetting("mic_scan", "Mic scan",
                          RadioSettingValueBoolean(_settings.mic_scan))
        basic.append(rs)
        options = ["NOR", "RMT", "CAT"]
        rs = RadioSetting(
            "mic_sel", "Mic selection",
            RadioSettingValueList(options, options[_settings.mic_sel]))
        extended.append(rs)
        options = ["SIG", "CTR", "VLT", "N/A", "FS", "OFF"]
        rs = RadioSetting(
            "mtr_arx_sel", "Meter receive selection",
            RadioSettingValueList(options, options[_settings.mtr_arx_sel]))
        extended.append(rs)
        options = ["PWR", "ALC", "MOD", "SWR", "VLT", "N/A", "OFF"]
        rs = RadioSetting(
            "mtr_atx_sel", "Meter transmit selection",
            RadioSettingValueList(options, options[_settings.mtr_atx_sel]))
        extended.append(rs)
        rs = RadioSetting("mtr_peak_hold", "Meter peak hold",
                          RadioSettingValueBoolean(_settings.mtr_peak_hold))
        extended.append(rs)
        rs = RadioSetting("nb_level", "Noise blanking level",
                          RadioSettingValueInteger(0, 100, _settings.nb_level))
        basic.append(rs)
        s = RadioSettingValueString(
            0, 4, ''.join([
                self._CALLSIGN_CHARSET[x] for x in self._memobj.op_filter1_name
            ]))
        s.set_charset(self._CALLSIGN_CHARSET)
        rs = RadioSetting("op_filter1_name", "Optional filter1 name", s)
        extended.append(rs)
        s = RadioSettingValueString(
            0, 4, ''.join([
                self._CALLSIGN_CHARSET[x] for x in self._memobj.op_filter2_name
            ]))
        s.set_charset(self._CALLSIGN_CHARSET)
        rs = RadioSetting("op_filter2_name", "Optional filter2 name", s)
        extended.append(rs)
        rs = RadioSetting(
            "pg_a", "Programmable key MFq:A",
            RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                  self.PROGRAMMABLEOPTIONS[_settings.pg_a]))
        extended.append(rs)
        rs = RadioSetting(
            "pg_b", "Programmable key MFq:B",
            RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                  self.PROGRAMMABLEOPTIONS[_settings.pg_b]))
        extended.append(rs)
        rs = RadioSetting(
            "pg_c", "Programmable key MFq:C",
            RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                  self.PROGRAMMABLEOPTIONS[_settings.pg_c]))
        extended.append(rs)
        rs = RadioSetting(
            "pg_acc", "Programmable mic key ACC",
            RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                  self.PROGRAMMABLEOPTIONS[_settings.pg_acc]))
        extended.append(rs)
        rs = RadioSetting(
            "pg_p1", "Programmable mic key P1",
            RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                  self.PROGRAMMABLEOPTIONS[_settings.pg_p1]))
        extended.append(rs)
        rs = RadioSetting(
            "pg_p2", "Programmable mic key P2",
            RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                  self.PROGRAMMABLEOPTIONS[_settings.pg_p2]))
        extended.append(rs)
        rs = RadioSetting("pkt1200", "Packet 1200 gain level",
                          RadioSettingValueInteger(0, 100, _settings.pkt1200))
        packet.append(rs)
        rs = RadioSetting("pkt9600", "Packet 9600 gain level",
                          RadioSettingValueInteger(0, 100, _settings.pkt9600))
        packet.append(rs)
        options = ["1200", "9600"]
        rs = RadioSetting(
            "pkt_rate", "Packet rate",
            RadioSettingValueList(options, options[_settings.pkt_rate]))
        packet.append(rs)
        rs = RadioSetting(
            "proc_level", "Proc level",
            RadioSettingValueInteger(0, 100, _settings.proc_level))
        basic.append(rs)
        rs = RadioSetting(
            "rf_power_hf", "Rf power set HF",
            RadioSettingValueInteger(5, 100, _settings.rf_power_hf))
        basic.append(rs)
        rs = RadioSetting(
            "rf_power_6m", "Rf power set 6m",
            RadioSettingValueInteger(5, 100, _settings.rf_power_6m))
        basic.append(rs)
        rs = RadioSetting(
            "rf_power_vhf", "Rf power set VHF",
            RadioSettingValueInteger(5, 50, _settings.rf_power_vhf))
        basic.append(rs)
        rs = RadioSetting(
            "rf_power_uhf", "Rf power set UHF",
            RadioSettingValueInteger(2, 20, _settings.rf_power_uhf))
        basic.append(rs)
        options = ["TIME", "BUSY", "STOP"]
        rs = RadioSetting(
            "scan_mode", "Scan mode",
            RadioSettingValueList(options, options[_settings.scan_mode]))
        basic.append(rs)
        rs = RadioSetting(
            "scan_resume", "Scan resume",
            RadioSettingValueInteger(1, 10, _settings.scan_resume))
        basic.append(rs)
        rs = RadioSetting("split_tone", "Split tone enable",
                          RadioSettingValueBoolean(_settings.split_tone))
        extended.append(rs)
        options = ["RF-Gain", "Squelch"]
        rs = RadioSetting(
            "sql_rf_gain", "Squelch/RF-Gain",
            RadioSettingValueList(options, options[_settings.sql_rf_gain]))
        panel.append(rs)
        rs = RadioSetting("ssb_mic", "SSB Mic gain",
                          RadioSettingValueInteger(0, 100, _settings.ssb_mic))
        basic.append(rs)
        options = ["Off"] + ["%i" % i for i in range(1, 21)]
        rs = RadioSetting(
            "tot_time", "Time-out timer",
            RadioSettingValueList(options, options[_settings.tot_time]))
        basic.append(rs)
        options = ["OFF", "ATAS(HF)", "ATAS(HF&50)", "ATAS(ALL)", "TUNER"]
        rs = RadioSetting(
            "tuner_atas", "Tuner/ATAS device",
            RadioSettingValueList(options, options[_settings.tuner_atas]))
        extended.append(rs)
        rs = RadioSetting(
            "tx_if_filter", "Transmit IF filter",
            RadioSettingValueList(self.FILTERS,
                                  self.FILTERS[_settings.tx_if_filter]))
        basic.append(rs)
        rs = RadioSetting("vox_delay", "VOX delay (*100 ms)",
                          RadioSettingValueInteger(1, 30, _settings.vox_delay))
        basic.append(rs)
        rs = RadioSetting("vox_gain", "VOX Gain",
                          RadioSettingValueInteger(1, 100, _settings.vox_gain))
        basic.append(rs)
        rs = RadioSetting(
            "xvtr_a", "Xvtr A displacement",
            RadioSettingValueInteger(
                -4294967295, 4294967295,
                self._memobj.xvtr_a_offset *
                (-1 if _settings.xvtr_a_negative else 1)))
        extended.append(rs)
        rs = RadioSetting(
            "xvtr_b", "Xvtr B displacement",
            RadioSettingValueInteger(
                -4294967295, 4294967295,
                self._memobj.xvtr_b_offset *
                (-1 if _settings.xvtr_b_negative else 1)))
        extended.append(rs)
        options = ["OFF", "XVTR A", "XVTR B"]
        rs = RadioSetting(
            "xvtr_sel", "Transverter function selection",
            RadioSettingValueList(options, options[_settings.xvtr_sel]))
        extended.append(rs)

        rs = RadioSetting("disp", "Display large",
                          RadioSettingValueBoolean(_settings.disp))
        panel.append(rs)
        rs = RadioSetting("nb", "Noise blanker",
                          RadioSettingValueBoolean(_settings.nb))
        panelcontr.append(rs)
        options = ["Auto", "Fast", "Slow", "Off"]
        rs = RadioSetting(
            "agc", "AGC", RadioSettingValueList(options,
                                                options[_settings.agc]))
        panelcontr.append(rs)
        options = ["PWR", "ALC", "SWR", "MOD"]
        rs = RadioSetting(
            "pwr_meter_mode", "Power meter mode",
            RadioSettingValueList(options, options[_settings.pwr_meter_mode]))
        panelcontr.append(rs)
        rs = RadioSetting("vox", "Vox",
                          RadioSettingValueBoolean(_settings.vox))
        panelcontr.append(rs)
        rs = RadioSetting("bk", "Semi break-in",
                          RadioSettingValueBoolean(_settings.bk))
        cw.append(rs)
        rs = RadioSetting("kyr", "Keyer",
                          RadioSettingValueBoolean(_settings.kyr))
        cw.append(rs)
        options = ["enabled", "disabled"]
        rs = RadioSetting(
            "fst", "Fast",
            RadioSettingValueList(options, options[_settings.fst]))
        panelcontr.append(rs)
        options = ["enabled", "disabled"]
        rs = RadioSetting(
            "lock", "Lock",
            RadioSettingValueList(options, options[_settings.lock]))
        panelcontr.append(rs)
        rs = RadioSetting("scope_peakhold", "Scope max hold",
                          RadioSettingValueBoolean(_settings.scope_peakhold))
        panelcontr.append(rs)
        options = ["21", "31", "127"]
        rs = RadioSetting(
            "scope_width", "Scope width (channels)",
            RadioSettingValueList(options, options[_settings.scope_width]))
        panelcontr.append(rs)
        rs = RadioSetting("proc", "Speech processor",
                          RadioSettingValueBoolean(_settings.proc))
        panelcontr.append(rs)

        return top
Exemple #7
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
Exemple #8
0
    def get_settings(self):
    #    """Translate the bit in the mem_struct into settings in the UI"""
        _mem = self._memobj
        basic = RadioSettingGroup("basic", "Basic Settings")
        advanced = RadioSettingGroup("advanced", "Advanced Settings")
        #other = RadioSettingGroup("other", "Other Settings")
        #work = RadioSettingGroup("work", "Work Mode Settings")
        #fm_preset = RadioSettingGroup("fm_preset", "FM Preset")
        #dtmfe = RadioSettingGroup("dtmfe", "DTMF Encode Settings")
        #dtmfd = RadioSettingGroup("dtmfd", "DTMF Decode Settings")
        #service = RadioSettingGroup("service", "Service Settings")
        #top = RadioSettings(basic, advanced, other, work, fm_preset, dtmfe,
        #                    dtmfd, service)
        top = RadioSettings(basic, advanced, )

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

        if _mem.settings.squelcha > 0x09:
            val = 0x00
        else:
            val = _mem.settings.squelcha
        rs = RadioSetting("squelcha", "Squelch Level A",
                          RadioSettingValueInteger(0, 9, _mem.settings.squelcha))
        basic.append(rs)


        if _mem.settings.squelchb > 0x09:
            val = 0x00
        else:
            val = _mem.settings.squelchb
        rs = RadioSetting("squelchb", "Squelch Level B",
                          RadioSettingValueInteger(0, 9, _mem.settings.squelchb))
        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)

        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)

        rs = RadioSetting("settings.autolk", "Automatic Key Lock",
                          RadioSettingValueBoolean(_mem.settings.autolk))
        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)

        if _mem.settings.toa > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.toa
        rs = RadioSetting("settings.toa", "Time-out Pre-Alert",
                          RadioSettingValueList(
                              LIST_OFF1TO10, LIST_OFF1TO10[val]))
        basic.append(rs)

        if _mem.settings.timeout > 0x28:
            val = 0x03
        else:
            val = _mem.settings.timeout
        rs = RadioSetting("settings.timeout", "Timeout Timer",
                          RadioSettingValueList(
                              LIST_TIMEOUT, LIST_TIMEOUT[val]))
        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)

        rs = RadioSetting("settings.roger", "Roger Beep",
                          RadioSettingValueList(LIST_ROGER, LIST_ROGER[
                              _mem.settings.roger]))
        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.pf1", "PF1 Key Assignment",
                          RadioSettingValueList(LIST_PF1, LIST_PF1[
                              _mem.settings.pf1]))
        basic.append(rs)

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

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

        if _mem.settings.pttdly > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.pttdly
        rs = RadioSetting("settings.pttdly", "PTT ID Delay",
                          RadioSettingValueList(
                              LIST_OFF1TO30, LIST_OFF1TO30[val]))
        basic.append(rs)

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

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

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

        rs = RadioSetting("settings.dw", "DW",
                          RadioSettingValueBoolean(_mem.settings.dw))
        basic.append(rs)

        # Advanced settings
        rs = RadioSetting("settings.prioritych", "Priority Channel",
                          RadioSettingValueList(LIST_PRIORITY, LIST_PRIORITY[
                              _mem.settings.prioritych]))
        advanced.append(rs)

        rs = RadioSetting("settings.vfomr", "Work Mode",
                          RadioSettingValueList(LIST_WORKMODE, LIST_WORKMODE[
                              _mem.settings.vfomr]))
        advanced.append(rs)

        dtmfchars = "0123456789"
        _codeobj = _mem.settings.code
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 3, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("settings.code", "PTT-ID Code", val)

        def apply_code(setting, obj):
            code = []
            for j in range(0, 3):
                try:
                    code.append(dtmfchars.index(str(setting.value)[j]))
                except IndexError:
                    code.append(0xFF)
            obj.code = code
        rs.set_apply_callback(apply_code, _mem.settings)
        advanced.append(rs)

        _codeobj = _mem.settings.password
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 6, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("settings.password", "Control Password", val)

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

        if _mem.settings.tdrab > 0x01:
            val = 0x00
        else:
            val = _mem.settings.tdrab
        rs = RadioSetting("settings.tdrab", "Dual Watch TX Priority",
                          RadioSettingValueList(
                              LIST_AB, LIST_AB[val]))
        advanced.append(rs)

        rs = RadioSetting("settings.keylk", "Key Lock",
                          RadioSettingValueBoolean(_mem.settings.keylk))
        advanced.append(rs)

        rs = RadioSetting("settings.control", "Control Code",
                          RadioSettingValueBoolean(_mem.settings.control))
        advanced.append(rs)

        return top



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

        # Basic

        # Audio: A01-A04

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

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

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

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

        # TX/RX: B01-B08

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

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

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

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

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

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

        # B08 (per channel)

        # Display: C01-C06

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

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

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

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

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

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

        # Memory: D01-D04

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

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

        # D04 (per channel)

        # Scan: E01-E04

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

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

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

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

        # System: F01-F09

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

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

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

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

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

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

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

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

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

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

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

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

        # Timer/Clock: G01-G04

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

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

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

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

        # Signaling: H01-H06

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

        # H02 (per channel)

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

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

        # H04 (per channel)

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

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

        # Pkt: I01-I03

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

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

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

        # Other

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

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

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

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

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

        # Work

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        # dtmf

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

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

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

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

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

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

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

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

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

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

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

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

        # setup 9 dtmf autodial entries
        for i in map(str, range(1, 10)):
            objname = "code" + i
            strname = "Code " + str(i)
            dtmfsetting = getattr(_mem.dtmfcode, objname)
            dtmflen = getattr(_mem.dtmfcode, objname + "_len")
            dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
            code = RadioSettingValueString(0, 16, dtmfstr)
            code.set_charset(DTMF_CHARS + list(" "))
            rs = RadioSetting("dtmfcode." + objname, strname, code)
            dtmf.append(rs)
        return top
Exemple #10
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")
        top = RadioSettings(
            basic,
            advanced,
        )

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

        if _mem.settings.squelcha > 0x09:
            val = 0x00
        else:
            val = _mem.settings.squelcha
        rs = RadioSetting(
            "squelcha", "Squelch Level A",
            RadioSettingValueInteger(0, 9, _mem.settings.squelcha))
        basic.append(rs)

        if _mem.settings.squelchb > 0x09:
            val = 0x00
        else:
            val = _mem.settings.squelchb
        rs = RadioSetting(
            "squelchb", "Squelch Level B",
            RadioSettingValueInteger(0, 9, _mem.settings.squelchb))
        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)

        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)

        rs = RadioSetting("settings.autolk", "Automatic Key Lock",
                          RadioSettingValueBoolean(_mem.settings.autolk))
        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)

        if _mem.settings.toa > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.toa
        rs = RadioSetting(
            "settings.toa", "Time-out Pre-Alert",
            RadioSettingValueList(LIST_OFF1TO10, LIST_OFF1TO10[val]))
        basic.append(rs)

        if _mem.settings.timeout > 0x28:
            val = 0x03
        else:
            val = _mem.settings.timeout
        rs = RadioSetting(
            "settings.timeout", "Timeout Timer",
            RadioSettingValueList(LIST_TIMEOUT, LIST_TIMEOUT[val]))
        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)

        rs = RadioSetting(
            "settings.roger", "Roger Beep",
            RadioSettingValueList(LIST_ROGER, LIST_ROGER[_mem.settings.roger]))
        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.pf1", "PF1 Key Assignment",
            RadioSettingValueList(LIST_PF1, LIST_PF1[_mem.settings.pf1]))
        basic.append(rs)

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

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

        if _mem.settings.pttdly > 0x0A:
            val = 0x00
        else:
            val = _mem.settings.pttdly
        rs = RadioSetting(
            "settings.pttdly", "PTT ID Delay",
            RadioSettingValueList(LIST_OFF1TO30, LIST_OFF1TO30[val]))
        basic.append(rs)

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

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

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

        rs = RadioSetting("settings.dw", "DW",
                          RadioSettingValueBoolean(_mem.settings.dw))
        basic.append(rs)

        # Advanced settings
        rs = RadioSetting(
            "settings.prioritych", "Priority Channel",
            RadioSettingValueList(LIST_PRIORITY,
                                  LIST_PRIORITY[_mem.settings.prioritych]))
        advanced.append(rs)

        rs = RadioSetting(
            "settings.vfomr", "Work Mode",
            RadioSettingValueList(LIST_WORKMODE,
                                  LIST_WORKMODE[_mem.settings.vfomr]))
        advanced.append(rs)

        dtmfchars = "0123456789"
        _codeobj = _mem.settings.code
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 3, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("settings.code", "PTT-ID Code", val)

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

        rs.set_apply_callback(apply_code, _mem.settings)
        advanced.append(rs)

        _codeobj = _mem.settings.password
        _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
        val = RadioSettingValueString(0, 6, _code, False)
        val.set_charset(dtmfchars)
        rs = RadioSetting("settings.password", "Control Password", val)

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

        rs.set_apply_callback(apply_code, _mem.settings)
        advanced.append(rs)

        if _mem.settings.tdrab > 0x01:
            val = 0x00
        else:
            val = _mem.settings.tdrab
        rs = RadioSetting("settings.tdrab", "Dual Watch TX Priority",
                          RadioSettingValueList(LIST_AB, LIST_AB[val]))
        advanced.append(rs)

        rs = RadioSetting("settings.keylk", "Key Lock",
                          RadioSettingValueBoolean(_mem.settings.keylk))
        advanced.append(rs)

        rs = RadioSetting("settings.control", "Control Code",
                          RadioSettingValueBoolean(_mem.settings.control))
        advanced.append(rs)

        return top
Exemple #11
0
    def get_settings(self):
        _settings = self._memobj.settings
        _dtmf_strings = self._memobj.dtmf_strings
        _passwd = self._memobj.passwd

        repeater = RadioSettingGroup("repeater", "Repeater Settings")
        ctcss = RadioSettingGroup("ctcss", "CTCSS/DCS/EPCS Settings")
        arts = RadioSettingGroup("arts", "ARTS Settings")
        mbls = RadioSettingGroup("banks", "Memory Settings")
        scan = RadioSettingGroup("scan", "Scan Settings")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        wires = RadioSettingGroup("wires", "WiRES(tm) Settings")
        switch = RadioSettingGroup("switch", "Switch/Knob Settings")
        disp = RadioSettingGroup("disp", "Display Settings")
        misc = RadioSettingGroup("misc", "Miscellaneous Settings")

        setmode = RadioSettings(repeater, ctcss, arts, mbls, scan,
                                dtmf, wires, switch, disp, misc)

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

        # 1 APO
        opts = ["Off", "30 Min", "1 Hour", "3 Hour", "5 Hour", "8 Hour"]
        misc.append(
            RadioSetting(
                "apo", "Automatic Power Off",
                RadioSettingValueList(opts, opts[_settings.apo])))

        # 2 AR.BEP
        opts = ["Off", "In Range", "Always"]
        arts.append(
            RadioSetting(
                "arts_beep", "ARTS Beep",
                RadioSettingValueList(opts, opts[_settings.arts_beep])))

        # 3 AR.INT
        opts = ["15 Sec", "25 Sec"]
        arts.append(
            RadioSetting(
                "arts_interval", "ARTS Polling Interval",
                RadioSettingValueList(opts, opts[_settings.arts_interval])))

        # 4 ARS
        opts = ["Off", "On"]
        repeater.append(
            RadioSetting(
                "ars", "Automatic Repeater Shift",
                RadioSettingValueList(opts, opts[_settings.ars])))

        # 5 BCLO
        opts = ["Off", "On"]
        misc.append(RadioSetting(
                "busy_lockout", "Busy Channel Lock-Out",
                RadioSettingValueList(opts, opts[_settings.busy_lockout])))

        # 6 BEEP
        opts = ["Off", "Key+Scan", "Key"]
        switch.append(RadioSetting(
                "beep", "Enable the Beeper",
                RadioSettingValueList(opts, opts[_settings.beep])))

        # 7 BELL
        opts = ["Off", "1", "3", "5", "8", "Continuous"]
        ctcss.append(RadioSetting("bell", "Bell Repetitions",
                     RadioSettingValueList(opts, opts[_settings.bell])))

        # 8 BNK.LNK
        for i in range(0, 8):
            opts = ["Off", "On"]
            mbs = (self._memobj.mbs >> i) & 1
            rs = RadioSetting("mbs%i" % i, "Bank %s Scan" % (i + 1),
                              RadioSettingValueList(opts, opts[mbs]))

            def apply_mbs(s, index):
                if int(s.value):
                    self._memobj.mbs |= (1 << index)
                else:
                    self._memobj.mbs &= ~(1 << index)
            rs.set_apply_callback(apply_mbs, i)
            mbls.append(rs)

        # 9 BNK.NM - A per-bank attribute, nothing to do here.

        # 10 CLK.SFT - A per-channel attribute, nothing to do here.

        # 11 CW.ID
        opts = ["Off", "On"]
        arts.append(RadioSetting("cw_id", "CW ID Enable",
                    RadioSettingValueList(opts, opts[_settings.cw_id])))

        cw_id_text = ""
        for i in _settings.cw_id_string:
            try:
                cw_id_text += CHARSET[i & 0x7F]
            except IndexError:
                if i != 0xff:
                    LOG.debug("unknown char index in cw id: %x " % (i))

        val = RadioSettingValueString(0, 16, cw_id_text, True)
        val.set_charset(CHARSET + "abcdefghijklmnopqrstuvwxyz")
        rs = RadioSetting("cw_id_string", "CW Identifier Text", val)

        def apply_cw_id(s):
            str = s.value.get_value().upper().rstrip()
            mval = ""
            mval = [chr(CHARSET.index(x)) for x in str]
            for x in range(len(mval), 16):
                mval.append(chr(0xff))
            for x in range(0, 16):
                _settings.cw_id_string[x] = ord(mval[x])
        rs.set_apply_callback(apply_cw_id)
        arts.append(rs)

        # 12 CWTRNG
        opts = ["Off", "4WPM", "5WPM", "6WPM", "7WPM", "8WPM", "9WPM",
                "10WPM", "11WPM", "12WPM", "13WPM", "15WPM", "17WPM",
                "20WPM", "24WPM", "30WPM", "40WPM"]
        misc.append(RadioSetting("cw_trng", "CW Training",
                    RadioSettingValueList(opts, opts[_settings.cw_trng])))

        # todo: make the setting of the units here affect the display
        # of the speed.  Not critical, but would be slick.
        opts = ["CPM", "WPM"]
        misc.append(RadioSetting("cw_trng_units", "CW Training Units",
                    RadioSettingValueList(opts,
                                          opts[_settings.cw_trng_units])))

        # 13 DC VLT - a read-only status, so nothing to do here

        # 14 DCS CD - A per-channel attribute, nothing to do here

        # 15 DCS.RV
        opts = ["Disabled", "Enabled"]
        ctcss.append(RadioSetting(
                     "inverted_dcs",
                     "\"Inverted\" DCS Code Decoding",
                     RadioSettingValueList(opts,
                                           opts[_settings.inverted_dcs])))

        # 16 DIMMER
        opts = ["Off"] + ["Level %d" % (x) for x in range(1, 11)]
        disp.append(RadioSetting("dimmer", "Dimmer",
                                 RadioSettingValueList(opts,
                                                       opts[_settings
                                                            .dimmer])))

        # 17 DT.A/M
        opts = ["Manual", "Auto"]
        dtmf.append(RadioSetting("dtmf_mode", "DTMF Autodialer",
                                 RadioSettingValueList(opts,
                                                       opts[_settings
                                                            .dtmf_mode])))

        # 18 DT.DLY
        opts = ["50 ms", "250 ms", "450 ms", "750 ms", "1000 ms"]
        dtmf.append(RadioSetting("dtmf_delay", "DTMF Autodialer Delay Time",
                                 RadioSettingValueList(opts,
                                                       opts[_settings
                                                            .dtmf_delay])))

        # 19 DT.SET
        for memslot in range(0, 10):
            dtmf_memory = ""
            for i in _dtmf_strings[memslot].dtmf_string:
                if i != 0xFF:
                    try:
                        dtmf_memory += CHARSET[i]
                    except IndexError:
                        LOG.debug("unknown char index in dtmf: %x " % (i))

            val = RadioSettingValueString(0, 16, dtmf_memory, True)
            val.set_charset(CHARSET + "abcdef")
            rs = RadioSetting("dtmf_string_%d" % memslot,
                              "DTMF Memory %d" % memslot, val)

            def apply_dtmf(s, i):
                LOG.debug("applying dtmf for %x\n" % i)
                str = s.value.get_value().upper().rstrip()
                LOG.debug("str is %s\n" % str)
                mval = ""
                mval = [chr(CHARSET.index(x)) for x in str]
                for x in range(len(mval), 16):
                    mval.append(chr(0xff))
                for x in range(0, 16):
                    _dtmf_strings[i].dtmf_string[x] = ord(mval[x])
            rs.set_apply_callback(apply_dtmf, memslot)
            dtmf.append(rs)

        # 20 DT.SPD
        opts = ["50 ms", "100 ms"]
        dtmf.append(RadioSetting("dtmf_speed",
                                 "DTMF Autodialer Sending Speed",
                                 RadioSettingValueList(opts,
                                                       opts[_settings.
                                                            dtmf_speed])))

        # 21 EDG.BEP
        opts = ["Off", "On"]
        mbls.append(RadioSetting("edge_beep", "Band Edge Beeper",
                                 RadioSettingValueList(opts,
                                                       opts[_settings.
                                                            edge_beep])))

        # 22 INT.CD
        opts = ["DTMF %X" % (x) for x in range(0, 16)]
        wires.append(RadioSetting("int_cd", "Access Number for WiRES(TM)",
                     RadioSettingValueList(opts, opts[_settings.int_cd])))

        # 23 ING MD
        opts = ["Sister Radio Group", "Friends Radio Group"]
        wires.append(RadioSetting("wires_mode",
                                  "Internet Link Connection Mode",
                                  RadioSettingValueList(opts,
                                                        opts[_settings.
                                                             wires_mode])))

        # 24 INT.A/M
        opts = ["Manual", "Auto"]
        wires.append(RadioSetting("wires_auto", "Internet Link Autodialer",
                                  RadioSettingValueList(opts,
                                                        opts[_settings
                                                             .wires_auto])))
        # 25 INT.SET
        opts = ["F%d" % (x) for x in range(0, 10)]

        wires.append(RadioSetting("int_set", "Memory Register for "
                                  "non-WiRES Internet",
                                  RadioSettingValueList(opts,
                                                        opts[_settings
                                                             .int_set])))

        # 26 LOCK
        opts = ["Key", "Dial", "Key + Dial", "PTT",
                "Key + PTT", "Dial + PTT", "All"]
        switch.append(RadioSetting("lock", "Control Locking",
                                   RadioSettingValueList(opts,
                                                         opts[_settings
                                                              .lock])))

        # 27 MCGAIN
        opts = ["Level %d" % (x) for x in range(1, 10)]
        misc.append(RadioSetting("mic_gain", "Microphone Gain",
                                 RadioSettingValueList(opts,
                                                       opts[_settings
                                                            .mic_gain])))

        # 28 MEM.SCN
        opts = ["Tag 1", "Tag 2", "All Channels"]
        rs = RadioSetting("scan_mode", "Memory Scan Mode",
                          RadioSettingValueList(opts,
                                                opts[_settings
                                                     .scan_mode - 1]))
        # this setting is unusual in that it starts at 1 instead of 0.
        # that is, index 1 corresponds to "Tag 1", and index 0 is invalid.
        # so we create a custom callback to handle this.

        def apply_scan_mode(s):
            myopts = ["Tag 1", "Tag 2", "All Channels"]
            _settings.scan_mode = myopts.index(s.value.get_value()) + 1
        rs.set_apply_callback(apply_scan_mode)
        mbls.append(rs)

        # 29 MW MD
        opts = ["Lower", "Next"]
        mbls.append(RadioSetting("mw_mode", "Memory Write Mode",
                                 RadioSettingValueList(opts,
                                                       opts[_settings
                                                            .mw_mode])))

        # 30 NM SET - This is per channel, so nothing to do here

        # 31 OPN.MSG
        opts = ["Off", "DC Supply Voltage", "Text Message"]
        disp.append(RadioSetting("open_msg", "Opening Message Type",
                                 RadioSettingValueList(opts,
                                                       opts[_settings.
                                                            open_msg])))

        openmsg = ""
        for i in _settings.openMsg_Text:
            try:
                openmsg += CHARSET[i & 0x7F]
            except IndexError:
                if i != 0xff:
                    LOG.debug("unknown char index in openmsg: %x " % (i))

        val = RadioSettingValueString(0, 6, openmsg, True)
        val.set_charset(CHARSET + "abcdefghijklmnopqrstuvwxyz")
        rs = RadioSetting("openMsg_Text", "Opening Message Text", val)

        def apply_openmsg(s):
            str = s.value.get_value().upper().rstrip()
            mval = ""
            mval = [chr(CHARSET.index(x)) for x in str]
            for x in range(len(mval), 6):
                mval.append(chr(0xff))
            for x in range(0, 6):
                _settings.openMsg_Text[x] = ord(mval[x])
        rs.set_apply_callback(apply_openmsg)
        disp.append(rs)

        # 32 PAGER - a per-channel attribute

        # 33 PAG.ABK
        opts = ["Off", "On"]
        ctcss.append(RadioSetting("pag_abk", "Paging Answer Back",
                                  RadioSettingValueList(opts,
                                                        opts[_settings
                                                             .pag_abk])))

        # 34 PAG.CDR
        opts = ["%2.2d" % (x) for x in range(1, 50)]
        ctcss.append(RadioSetting("pag_cdr_1", "Receive Page Code 1",
                                  RadioSettingValueList(opts,
                                                        opts[_settings
                                                             .pag_cdr_1])))

        ctcss.append(RadioSetting("pag_cdr_2", "Receive Page Code 2",
                                  RadioSettingValueList(opts,
                                                        opts[_settings
                                                             .pag_cdr_2])))

        # 35 PAG.CDT
        opts = ["%2.2d" % (x) for x in range(1, 50)]
        ctcss.append(RadioSetting("pag_cdt_1", "Transmit Page Code 1",
                                  RadioSettingValueList(opts,
                                                        opts[_settings
                                                             .pag_cdt_1])))

        ctcss.append(RadioSetting("pag_cdt_2", "Transmit Page Code 2",
                                  RadioSettingValueList(opts,
                                                        opts[_settings
                                                             .pag_cdt_2])))

        # Common Button Options
        button_opts = ["Squelch Off", "Weather", "Smart Search",
                       "Tone Scan", "Scan", "T Call", "ARTS"]

        # 36 PRG P1
        opts = button_opts + ["DC Volts"]
        switch.append(RadioSetting(
                "prog_p1", "P1 Button",
                RadioSettingValueList(opts, opts[_settings.prog_p1])))

        # 37 PRG P2
        opts = button_opts + ["Dimmer"]
        switch.append(RadioSetting(
                "prog_p2", "P2 Button",
                RadioSettingValueList(opts, opts[_settings.prog_p2])))

        # 38 PRG P3
        opts = button_opts + ["Mic Gain"]
        switch.append(RadioSetting(
                "prog_p3", "P3 Button",
                RadioSettingValueList(opts, opts[_settings.prog_p3])))

        # 39 PRG P4
        opts = button_opts + ["Skip"]
        switch.append(RadioSetting(
                "prog_p4", "P4 Button",
                RadioSettingValueList(opts, opts[_settings.prog_p4])))

        # 40 PSWD
        password = ""
        for i in _passwd:
            if i != 0xFF:
                try:
                    password += CHARSET[i]
                except IndexError:
                    LOG.debug("unknown char index in password: %x " % (i))

        val = RadioSettingValueString(0, 4, password, True)
        val.set_charset(CHARSET[0:15] + "abcdef ")
        rs = RadioSetting("passwd", "Password", val)

        def apply_password(s):
            str = s.value.get_value().upper().rstrip()
            mval = ""
            mval = [chr(CHARSET.index(x)) for x in str]
            for x in range(len(mval), 4):
                mval.append(chr(0xff))
            for x in range(0, 4):
                _passwd[x] = ord(mval[x])
        rs.set_apply_callback(apply_password)
        misc.append(rs)

        # 41 RESUME
        opts = ["3 Sec", "5 Sec", "10 Sec", "Busy", "Hold"]
        scan.append(RadioSetting("resume", "Scan Resume Mode",
                    RadioSettingValueList(opts, opts[_settings.resume])))

        # 42 RF.SQL
        opts = ["Off"] + ["S-%d" % (x) for x in range(1, 10)]
        misc.append(RadioSetting("rf_sql", "RF Squelch Threshold",
                    RadioSettingValueList(opts, opts[_settings.rf_sql])))

        # 43 RPT - per channel attribute, nothing to do here

        # 44 RVRT
        opts = ["Off", "On"]
        misc.append(RadioSetting("revert", "Priority Revert",
                    RadioSettingValueList(opts, opts[_settings.revert])))

        # 45 S.SRCH
        opts = ["Single", "Continuous"]
        misc.append(RadioSetting("s_search", "Smart Search Sweep Mode",
                    RadioSettingValueList(opts, opts[_settings.s_search])))

        # 46 SHIFT - per channel setting, nothing to do here

        # 47 SKIP = per channel setting, nothing to do here

        # 48 SPLIT - per channel attribute, nothing to do here

        # 49 SQL.TYP - per channel attribute, nothing to do here

        # 50 STEP - per channel attribute, nothing to do here

        # 51 TEMP - read-only status, nothing to do here

        # 52 TN FRQ - per channel attribute, nothing to do here

        # 53 TOT
        opts = ["Off", "1 Min", "3 Min", "5 Min", "10 Min"]
        misc.append(RadioSetting("tot", "Timeout Timer",
                                 RadioSettingValueList(opts,
                                                       opts[_settings.tot])))

        # 54 TS MUT
        opts = ["Off", "On"]
        ctcss.append(RadioSetting("ts_mut", "Tone Search Mute",
                                  RadioSettingValueList(opts,
                                                        opts[_settings
                                                             .ts_mut])))

        # 55 TS SPEED
        opts = ["Fast", "Slow"]
        ctcss.append(RadioSetting("ts_speed", "Tone Search Scanner Speed",
                                  RadioSettingValueList(opts,
                                                        opts[_settings
                                                             .ts_speed])))

        # 56 VFO.SCN
        opts = ["+/- 1MHz", "+/- 2MHz", "+/-5MHz", "All"]
        scan.append(RadioSetting("vfo_scan", "VFO Scanner Width",
                                 RadioSettingValueList(opts,
                                                       opts[_settings
                                                            .vfo_scan])))

        # 57 WX.ALT
        opts = ["Off", "On"]
        misc.append(RadioSetting("wx_alert", "Weather Alert Scan",
                    RadioSettingValueList(opts, opts[_settings.wx_alert])))

        # 58 WX.VOL
        opts = ["Normal", "Maximum"]
        misc.append(RadioSetting("wx_vol_max", "Weather Alert Volume",
                    RadioSettingValueList(opts, opts[_settings.wx_vol_max])))

        # 59 W/N DV - this is a per-channel attribute, nothing to do here

        return setmode
Exemple #12
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
Exemple #13
0
    def get_settings(self):
        _settings = self._memobj.settings
        _mem = self._memobj
        basic = RadioSettingGroup("basic", "Basic Settings")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        top = RadioSettings(basic, dtmf)

        if _settings.k1shortp > 5:
            val = 4
        else:
            val = _settings.k1shortp
        rs = RadioSetting("k1shortp", "Key 1 Short Press",
                          RadioSettingValueList(
                              LIST_SHORT_PRESS,
                              LIST_SHORT_PRESS[val]))
        basic.append(rs)

        if _settings.k1longp > 5:
            val = 5
        else:
            val = _settings.k1longp
        rs = RadioSetting("k1longp", "Key 1 Long Press",
                          RadioSettingValueList(
                              LIST_LONG_PRESS,
                              LIST_LONG_PRESS[val]))
        basic.append(rs)

        if _settings.k2shortp > 5:
            val = 1
        else:
            val = _settings.k2shortp
        rs = RadioSetting("k2shortp", "Key 2 Short Press",
                          RadioSettingValueList(
                              LIST_SHORT_PRESS,
                              LIST_SHORT_PRESS[val]))
        basic.append(rs)

        if _settings.k2longp > 5:
            val = 3
        else:
            val = _settings.k2longp
        rs = RadioSetting("k2longp", "Key 2 Long Press",
                          RadioSettingValueList(
                              LIST_LONG_PRESS,
                              LIST_LONG_PRESS[val]))
        basic.append(rs)

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

        if _settings.voxg > 8:
            val = 4
        else:
            val = _settings.voxg + 1
        rs = RadioSetting("voxg", "VOX Gain",
                          RadioSettingValueInteger(1, 9, val))
        basic.append(rs)

        rs = RadioSetting("voxd", "VOX Delay Time",
                          RadioSettingValueList(
                              LIST_VOXDELAY,
                              LIST_VOXDELAY[_settings.voxd]))
        basic.append(rs)

        rs = RadioSetting("voxi", "VOX Inhibit on Receive",
                          RadioSettingValueBoolean(_settings.voxi))
        basic.append(rs)

        if _settings.squelch > 9:
            val = 5
        else:
            val = _settings.squelch
        rs = RadioSetting("squelch", "Squelch Level",
                          RadioSettingValueInteger(0, 9, val))
        basic.append(rs)

        if _settings.voice == 3:
            val = 1
        else:
            val = _settings.voice
        rs = RadioSetting("voice", "Voice Prompts",
                          RadioSettingValueList(
                              LIST_VOICE,
                              LIST_VOICE[val]))
        basic.append(rs)

        rs = RadioSetting("tone", "Tone",
                          RadioSettingValueBoolean(_settings.tone))
        basic.append(rs)

        rs = RadioSetting("lovoltnotx", "TX Inhibit (when battery < 6 volts)",
                          RadioSettingValueBoolean(_settings.lovoltnotx))
        basic.append(rs)

        rs = RadioSetting("hivoltnotx", "TX Inhibit (when battery > 9 volts)",
                          RadioSettingValueBoolean(_settings.hivoltnotx))
        basic.append(rs)

        if _settings.tot > 0x28:
            val = 6
        else:
            val = _settings.tot
        rs = RadioSetting("tot", "Time-out Timer[s]",
                          RadioSettingValueList(
                              LIST_TIMEOUTTIMER,
                              LIST_TIMEOUTTIMER[val]))
        basic.append(rs)

        if _settings.save < 3:
            val = 0
        else:
            val = _settings.save - 3
        rs = RadioSetting("save", "Battery Saver",
                          RadioSettingValueList(
                              LIST_SAVE,
                              LIST_SAVE[val]))
        basic.append(rs)

        rs = RadioSetting("ssave", "Super Battery Saver[s]",
                          RadioSettingValueList(
                              LIST_SSAVE,
                              LIST_SSAVE[_settings.ssave]))
        basic.append(rs)

        rs = RadioSetting("fmradio", "Broadcast FM",
                          RadioSettingValueBoolean(_settings.fmradio))
        basic.append(rs)

        if _settings.scanspeed > 8:
            val = 4
        else:
            val = _settings.scanspeed
        rs = RadioSetting("scanspeed", "Scan Speed[ms]",
                          RadioSettingValueList(
                          LIST_SCANSPEED,
                          LIST_SCANSPEED[val]))
        basic.append(rs)

        if _settings.scandelay > 27:
            val = 12
        else:
            val = _settings.scandelay
        rs = RadioSetting("scandelay", "Scan Droupout Delay Time[s]",
                          RadioSettingValueList(
                              LIST_SCANDELAY,
                              LIST_SCANDELAY[val]))
        basic.append(rs)

        if _mem.dtmf.dtmfspd > 11:
            val = 2
        else:
            val = _mem.dtmf.dtmfspd + 4
        rs = RadioSetting("dtmf.dtmfspd", "DTMF Speed[digit/s]",
                          RadioSettingValueInteger(4, 15, val))
        dtmf.append(rs)

        if _mem.dtmf.digtime > 10:
            val = 0
        else:
            val = _mem.dtmf.digtime
        rs = RadioSetting("dtmf.digtime", "1st Digit Time[ms]",
                          RadioSettingValueList(
                              LIST_DIGTIME,
                              LIST_DIGTIME[val]))
        dtmf.append(rs)

        if _mem.dtmf.digdelay > 9:
            val = 0
        else:
            val = _mem.dtmf.digdelay
        rs = RadioSetting("dtmf.digdelay", "1st Digit Delay[ms]",
                          RadioSettingValueList(
                              LIST_DIGDELAY,
                              LIST_DIGDELAY[val]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.starhash", "* and # Time[ms]",
                          RadioSettingValueList(
                              LIST_STARHASH,
                              LIST_STARHASH[_mem.dtmf.starhash]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.codespace", "Code Space Time[ms]",
                          RadioSettingValueList(
                              LIST_CODESPACE,
                              LIST_CODESPACE[_mem.dtmf.codespace]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.sidetone", "DTMF Sidetone",
                          RadioSettingValueBoolean(_mem.dtmf.sidetone))
        dtmf.append(rs)

        # setup pttid entries
        for i in range(0, 2):
            objname = "code" + str(i + 1)
            names = ["PTT ID(BOT)", "PTT ID(EOT)"]
            strname = str(names[i])
            dtmfsetting = getattr(_mem.dtmf, objname)
            dtmflen = getattr(_mem.dtmf, objname + "_len")
            dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
            code = RadioSettingValueString(0, 16, dtmfstr)
            code.set_charset(DTMF_CHARSET + list(" "))
            rs = RadioSetting("dtmf." + objname, strname, code)
            dtmf.append(rs)

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

        # setup id code entry
        codesetting = getattr(_mem.dtmf, "idcode")
        codestr = self._bbcd2num(codesetting, 6)
        code = RadioSettingValueString(0, 6, _filter(codestr))
        code.set_charset(NUMERIC_CHARSET + list(" "))
        rs = RadioSetting("dtmf.idcode", "ID Code", code)
        dtmf.append(rs)

        if _mem.dtmf.groupcode > 6:
            val = 0
        else:
            val = _mem.dtmf.groupcode
        rs = RadioSetting("dtmf.groupcode", "Group Code",
                          RadioSettingValueList(
                              LIST_GROUPCODE,
                              LIST_GROUPCODE[val]))
        dtmf.append(rs)

        if _mem.dtmf.resettime > 60:
            val = 0
        else:
            val = _mem.dtmf.resettime
        rs = RadioSetting("dtmf.resettime", "Auto Reset Time[s]",
                          RadioSettingValueList(
                              LIST_RESETTIME,
                              LIST_RESETTIME[_mem.dtmf.resettime]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.txdecode", "TX Decode",
                          RadioSettingValueBoolean(_mem.dtmf.txdecode))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.decodeto", "Decode Time Out[ms]",
                          RadioSettingValueList(
                              LIST_DECODETO,
                              LIST_DECODETO[_mem.dtmf.decodeto]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.decodetone", "Decode Tone",
                          RadioSettingValueBoolean(_mem.dtmf.decodetone))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.resettone", "Reset Tone",
                          RadioSettingValueBoolean(_mem.dtmf.resettone))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.stuntype", "Stun Type",
                          RadioSettingValueList(
                              LIST_STUNTYPE,
                              LIST_STUNTYPE[_mem.dtmf.stuntype]))
        dtmf.append(rs)

        ## setup stun entry
        objname = "code3"
        strname = "Stun Code"
        dtmfsetting = getattr(_mem.dtmf, objname)
        dtmflen = getattr(_mem.dtmf, objname + "_len")
        dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
        code = RadioSettingValueString(0, 10, dtmfstr)
        code.set_charset(DTMF_CHARSET + list(" "))
        rs = RadioSetting("dtmf." + objname, strname, code)
        dtmf.append(rs)

        return top
Exemple #14
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        dtmf = RadioSettingGroup("dtmf", "DTMF")
        arts = RadioSettingGroup("arts", "ARTS")
        prog = RadioSettingGroup("prog", "Programmable Buttons")

        top = RadioSettings(basic, dtmf, arts, prog)

        basic.append(
            RadioSetting("priority_revert", "Priority Revert",
                         RadioSettingValueBoolean(_settings.priority_revert)))

        basic.append(
            RadioSetting("memory_only", "Memory Only mode",
                         RadioSettingValueBoolean(_settings.memory_only)))

        opts = ["off"] + ["%0.1f" % (t / 60.0) for t in range(30, 750, 30)]
        basic.append(
            RadioSetting("apo", "APO time (hrs)",
                         RadioSettingValueList(opts, opts[_settings.apo])))

        basic.append(
            RadioSetting("beep_scan", "Beep: Scan",
                         RadioSettingValueBoolean(_settings.beep_scan)))

        basic.append(
            RadioSetting("beep_edge", "Beep: Edge",
                         RadioSettingValueBoolean(_settings.beep_edge)))

        basic.append(
            RadioSetting("beep_key", "Beep: Key",
                         RadioSettingValueBoolean(_settings.beep_key)))

        opts = ["T/RX Normal", "RX Reverse", "TX Reverse", "T/RX Reverse"]
        basic.append(
            RadioSetting(
                "dcs_polarity", "DCS polarity",
                RadioSettingValueList(opts, opts[_settings.dcs_polarity])))

        opts = ["off", "dim 1", "dim 2", "dim 3"]
        basic.append(
            RadioSetting("dimmer", "Dimmer",
                         RadioSettingValueList(opts, opts[_settings.dimmer])))

        opts = ["manual", "auto", "1-auto"]
        basic.append(
            RadioSetting(
                "hyper_write", "Hyper Write",
                RadioSettingValueList(opts, opts[_settings.hyper_write])))

        opts = [
            "", "key", "dial", "key+dial", "ptt", "ptt+key", "ptt+dial", "all"
        ]
        basic.append(
            RadioSetting("lock", "Lock mode",
                         RadioSettingValueList(opts, opts[_settings.lock])))

        opts = ["MH-42", "MH-48"]
        basic.append(
            RadioSetting(
                "microphone_type", "Microphone Type",
                RadioSettingValueList(opts, opts[_settings.microphone_type])))

        opts = ["off"] + ["S-%d" % n for n in range(2, 10)] + ["S-Full"]
        basic.append(
            RadioSetting("rf_sql", "RF Squelch",
                         RadioSettingValueList(opts, opts[_settings.rf_sql])))

        opts = ["time", "hold", "busy"]
        basic.append(
            RadioSetting(
                "scan_resume", "Scan Resume",
                RadioSettingValueList(opts, opts[_settings.scan_resume])))

        opts = ["single", "continuous"]
        basic.append(
            RadioSetting(
                "smart_search", "Smart Search",
                RadioSettingValueList(opts, opts[_settings.smart_search])))

        opts = ["off"] + ["%d" % t for t in range(1, 31)]
        basic.append(
            RadioSetting("tot", "Time-out timer (mins)",
                         RadioSettingValueList(opts, opts[_settings.tot])))

        # dtmf tab

        opts = ["50", "100", "250", "450", "750", "1000"]
        dtmf.append(
            RadioSetting(
                "dtmf_delay", "DTMF delay (ms)",
                RadioSettingValueList(opts, opts[_settings.dtmf_delay])))

        opts = ["50", "75", "100"]
        dtmf.append(
            RadioSetting(
                "dtmf_speed", "DTMF speed (ms)",
                RadioSettingValueList(opts, opts[_settings.dtmf_speed])))

        for i in range(16):
            name = "dtmf%02d" % i
            dtmfsetting = self._memobj.dtmf[i]
            dtmfstr = ""
            for c in dtmfsetting.memory:
                if c == 0xFF:
                    break
                if c < len(DTMFCHARSET):
                    dtmfstr += DTMFCHARSET[c]
            LOG.debug(dtmfstr)
            dtmfentry = RadioSettingValueString(0, 16, dtmfstr)
            dtmfentry.set_charset(DTMFCHARSET + list(" "))
            rs = RadioSetting(name, name.upper(), dtmfentry)
            dtmf.append(rs)

        # arts tab

        opts = ["off", "in range", "always"]
        arts.append(
            RadioSetting(
                "arts_mode", "ARTS beep",
                RadioSettingValueList(opts, opts[_settings.arts_mode])))

        opts = ["15", "25"]
        arts.append(
            RadioSetting(
                "arts_interval", "ARTS interval",
                RadioSettingValueList(opts, opts[_settings.arts_interval])))

        arts.append(
            RadioSetting("arts_cwid_enable", "CW ID",
                         RadioSettingValueBoolean(_settings.arts_cwid_enable)))

        _arts_cwid = self._memobj.arts_cwid
        cwid = RadioSettingValueString(
            0, 16, self._decode_chars(_arts_cwid.get_value()))
        cwid.set_charset(CHARSET)
        arts.append(RadioSetting("arts_cwid", "CW ID", cwid))

        # prog buttons

        opts = ["WX", "Reverse", "Repeater", "SQL Off", "Lock", "Dimmer"]
        prog.append(
            RadioSetting(
                "prog_panel_acc", "Prog Panel - Low(ACC)",
                RadioSettingValueList(opts, opts[_settings.prog_panel_acc])))

        opts = ["Reverse", "Home"]
        prog.append(
            RadioSetting(
                "prog_tone_vm", "TONE | V/M",
                RadioSettingValueList(opts, opts[_settings.prog_tone_vm])))

        opts = ["" for n in range(26)] + \
            ["Priority", "Low", "Tone", "MHz", "Reverse", "Home", "Band",
             "VFO/MR", "Scan", "Sql Off", "TCall", "SSCH", "ARTS", "Tone Freq",
             "DCSC", "WX", "Repeater"]

        prog.append(
            RadioSetting("prog_p1", "P1",
                         RadioSettingValueList(opts, opts[_settings.prog_p1])))

        prog.append(
            RadioSetting("prog_p2", "P2",
                         RadioSettingValueList(opts, opts[_settings.prog_p2])))

        prog.append(
            RadioSetting("prog_p3", "P3",
                         RadioSettingValueList(opts, opts[_settings.prog_p3])))

        prog.append(
            RadioSetting("prog_p4", "P4",
                         RadioSettingValueList(opts, opts[_settings.prog_p4])))

        return top
Exemple #15
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        dtmf = RadioSettingGroup("dtmf", "DTMF Code & Paging")
        arts = RadioSettingGroup("arts", "ARTS")
        autodial = RadioSettingGroup("autodial", "AutoDial")
        top = RadioSettings(basic, autodial, arts, dtmf)

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

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

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

        options = ["off", "30m", "1h", "3h", "5h", "8h"]
        rs = RadioSetting(
                "apo", "APO time (hrs)",
                RadioSettingValueList(options, options[_settings.apo]))
        basic.append(rs)

        options = ["off", "1m", "2.5m", "5m", "10m"]
        rs = RadioSetting(
                "timeout", "Time Out Timer",
                RadioSettingValueList(options, options[_settings.timeout]))
        basic.append(rs)

        options = ["key", "dial", "key+dial", "ptt",
                   "key+ptt", "dial+ptt", "all"]
        rs = RadioSetting(
                "lock", "Lock mode",
                RadioSettingValueList(options, options[_settings.lock]))
        basic.append(rs)

        options = ["off", "0.2", "0.3", "0.5", "1.0", "2.0"]
        rs = RadioSetting(
                "rxsave", "RX Save (sec)",
                RadioSettingValueList(options, options[_settings.rxsave]))
        basic.append(rs)

        options = ["5sec", "key", "tgl"]
        rs = RadioSetting(
                "lamp", "Lamp mode",
                RadioSettingValueList(options, options[_settings.lamp]))
        basic.append(rs)

        options = ["off", "1", "3", "5", "8", "rpt"]
        rs = RadioSetting(
                "bell", "Bell Repetitions",
                RadioSettingValueList(options, options[_settings.bell]))
        basic.append(rs)

        rs = RadioSetting(
                "cwid_en", "CWID Enable",
                RadioSettingValueBoolean(_settings.cwid_en))
        arts.append(rs)

        cwid = RadioSettingValueString(
                0, 16, self._decode_cwid(_settings.cwid.get_value()))
        cwid.set_charset(CHARSET)
        rs = RadioSetting("cwid", "CWID", cwid)
        arts.append(rs)

        options = ["off", "rx", "tx", "trx"]
        rs = RadioSetting(
                "artsmode", "ARTS Mode",
                RadioSettingValueList(
                    options, options[_settings.artsmode]))
        arts.append(rs)

        options = ["off", "in range", "always"]
        rs = RadioSetting(
                "artsbeep", "ARTS Beep",
                RadioSettingValueList(options, options[_settings.artsbeep]))
        arts.append(rs)

        for i in range(0, 8):
            dialsettings = _settings.autodial[i]
            dialstr = ""
            for c in dialsettings.digits:
                if c < len(DTMFCHARSET):
                    dialstr += DTMFCHARSET[c]
            dialentry = RadioSettingValueString(0, 16, dialstr)
            dialentry.set_charset(DTMFCHARSET + list(" "))
            rs = RadioSetting("autodial" + str(i+1),
                              "AutoDial " + str(i+1), dialentry)
            autodial.append(rs)

        dialstr = ""
        for c in _settings.autodial9_ro.digits:
            if c < len(DTMFCHARSET):
                dialstr += DTMFCHARSET[c]
        dialentry = RadioSettingValueString(0, 32, dialstr)
        dialentry.set_mutable(False)
        rs = RadioSetting("autodial9_ro", "AutoDial 9 (read only)", dialentry)
        autodial.append(rs)

        options = ["50ms", "100ms"]
        rs = RadioSetting(
                "pagingspeed", "Paging Speed",
                RadioSettingValueList(options, options[_settings.pagingspeed]))
        dtmf.append(rs)

        options = ["250ms", "450ms", "750ms", "1000ms"]
        rs = RadioSetting(
                "pagingdelay", "Paging Delay",
                RadioSettingValueList(options, options[_settings.pagingdelay]))
        dtmf.append(rs)

        options = ["off", "1", "3", "5", "8", "rpt"]
        rs = RadioSetting(
                "pagingbell", "Paging Bell Repetitions",
                RadioSettingValueList(options, options[_settings.pagingbell]))
        dtmf.append(rs)

        options = ["off", "ans", "for"]
        rs = RadioSetting(
                "paginganswer", "Paging Answerback",
                RadioSettingValueList(options,
                                      options[_settings.paginganswer]))
        dtmf.append(rs)

        rs = RadioSetting(
                "code_dec_c_en", "Paging Code C Decode Enable",
                RadioSettingValueBoolean(_settings.code_dec_c_en))
        dtmf.append(rs)

        _str = str(bitwise.bcd_to_int(_settings.pagingcodec_ro))
        code = RadioSettingValueString(0, 3, _str)
        code.set_charset(NUMERIC_CHARSET + list(" "))
        code.set_mutable(False)
        rs = RadioSetting("pagingcodec_ro", "Paging Code C (read only)", code)
        dtmf.append(rs)

        rs = RadioSetting(
                "code_dec_p_en", "Paging Code P Decode Enable",
                RadioSettingValueBoolean(_settings.code_dec_p_en))
        dtmf.append(rs)

        _str = str(bitwise.bcd_to_int(_settings.pagingcodep))
        code = RadioSettingValueString(0, 3, _str)
        code.set_charset(NUMERIC_CHARSET + list(" "))
        rs = RadioSetting("pagingcodep", "Paging Code P", code)
        dtmf.append(rs)

        for i in range(0, 6):
            num = str(i+1)
            name = "code_dec_" + num + "_en"
            rs = RadioSetting(
                    name, "Paging Code " + num + " Decode Enable",
                    RadioSettingValueBoolean(getattr(_settings, name)))
            dtmf.append(rs)

            _str = str(bitwise.bcd_to_int(_settings.pagingcode[i].digits))
            code = RadioSettingValueString(0, 3, _str)
            code.set_charset(NUMERIC_CHARSET + list(" "))
            rs = RadioSetting("pagingcode" + num, "Paging Code " + num, code)
            dtmf.append(rs)

        return top
Exemple #16
0
    def get_settings(self):
        _settings = self._memobj.settings
        _mem = self._memobj
        basic = RadioSettingGroup("basic", "Basic Settings")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        top = RadioSettings(basic, dtmf)

        if _settings.k1shortp > 5:
            val = 4
        else:
            val = _settings.k1shortp
        rs = RadioSetting(
            "k1shortp", "Key 1 Short Press",
            RadioSettingValueList(LIST_SHORT_PRESS, LIST_SHORT_PRESS[val]))
        basic.append(rs)

        if _settings.k1longp > 5:
            val = 5
        else:
            val = _settings.k1longp
        rs = RadioSetting(
            "k1longp", "Key 1 Long Press",
            RadioSettingValueList(LIST_LONG_PRESS, LIST_LONG_PRESS[val]))
        basic.append(rs)

        if _settings.k2shortp > 5:
            val = 1
        else:
            val = _settings.k2shortp
        rs = RadioSetting(
            "k2shortp", "Key 2 Short Press",
            RadioSettingValueList(LIST_SHORT_PRESS, LIST_SHORT_PRESS[val]))
        basic.append(rs)

        if _settings.k2longp > 5:
            val = 3
        else:
            val = _settings.k2longp
        rs = RadioSetting(
            "k2longp", "Key 2 Long Press",
            RadioSettingValueList(LIST_LONG_PRESS, LIST_LONG_PRESS[val]))
        basic.append(rs)

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

        if _settings.voxg > 8:
            val = 4
        else:
            val = _settings.voxg + 1
        rs = RadioSetting("voxg", "VOX Gain",
                          RadioSettingValueInteger(1, 9, val))
        basic.append(rs)

        rs = RadioSetting(
            "voxd", "VOX Delay Time",
            RadioSettingValueList(LIST_VOXDELAY,
                                  LIST_VOXDELAY[_settings.voxd]))
        basic.append(rs)

        rs = RadioSetting("voxi", "VOX Inhibit on Receive",
                          RadioSettingValueBoolean(_settings.voxi))
        basic.append(rs)

        if _settings.squelch > 9:
            val = 5
        else:
            val = _settings.squelch
        rs = RadioSetting("squelch", "Squelch Level",
                          RadioSettingValueInteger(0, 9, val))
        basic.append(rs)

        if _settings.voice == 3:
            val = 1
        else:
            val = _settings.voice
        rs = RadioSetting("voice", "Voice Prompts",
                          RadioSettingValueList(LIST_VOICE, LIST_VOICE[val]))
        basic.append(rs)

        rs = RadioSetting("tone", "Tone",
                          RadioSettingValueBoolean(_settings.tone))
        basic.append(rs)

        rs = RadioSetting("lovoltnotx", "TX Inhibit (when battery < 6 volts)",
                          RadioSettingValueBoolean(_settings.lovoltnotx))
        basic.append(rs)

        rs = RadioSetting("hivoltnotx", "TX Inhibit (when battery > 9 volts)",
                          RadioSettingValueBoolean(_settings.hivoltnotx))
        basic.append(rs)

        if _settings.tot > 0x28:
            val = 6
        else:
            val = _settings.tot
        rs = RadioSetting(
            "tot", "Time-out Timer[s]",
            RadioSettingValueList(LIST_TIMEOUTTIMER, LIST_TIMEOUTTIMER[val]))
        basic.append(rs)

        if _settings.save < 3:
            val = 0
        else:
            val = _settings.save - 3
        rs = RadioSetting("save", "Battery Saver",
                          RadioSettingValueList(LIST_SAVE, LIST_SAVE[val]))
        basic.append(rs)

        rs = RadioSetting(
            "ssave", "Super Battery Saver[s]",
            RadioSettingValueList(LIST_SSAVE, LIST_SSAVE[_settings.ssave]))
        basic.append(rs)

        rs = RadioSetting("fmradio", "Broadcast FM",
                          RadioSettingValueBoolean(_settings.fmradio))
        basic.append(rs)

        if _settings.scanspeed > 8:
            val = 4
        else:
            val = _settings.scanspeed
        rs = RadioSetting(
            "scanspeed", "Scan Speed[ms]",
            RadioSettingValueList(LIST_SCANSPEED, LIST_SCANSPEED[val]))
        basic.append(rs)

        if _settings.scandelay > 27:
            val = 12
        else:
            val = _settings.scandelay
        rs = RadioSetting(
            "scandelay", "Scan Droupout Delay Time[s]",
            RadioSettingValueList(LIST_SCANDELAY, LIST_SCANDELAY[val]))
        basic.append(rs)

        if _mem.dtmf.dtmfspd > 11:
            val = 2
        else:
            val = _mem.dtmf.dtmfspd + 4
        rs = RadioSetting("dtmf.dtmfspd", "DTMF Speed[digit/s]",
                          RadioSettingValueInteger(4, 15, val))
        dtmf.append(rs)

        if _mem.dtmf.digtime > 10:
            val = 0
        else:
            val = _mem.dtmf.digtime
        rs = RadioSetting(
            "dtmf.digtime", "1st Digit Time[ms]",
            RadioSettingValueList(LIST_DIGTIME, LIST_DIGTIME[val]))
        dtmf.append(rs)

        if _mem.dtmf.digdelay > 9:
            val = 0
        else:
            val = _mem.dtmf.digdelay
        rs = RadioSetting(
            "dtmf.digdelay", "1st Digit Delay[ms]",
            RadioSettingValueList(LIST_DIGDELAY, LIST_DIGDELAY[val]))
        dtmf.append(rs)

        rs = RadioSetting(
            "dtmf.starhash", "* and # Time[ms]",
            RadioSettingValueList(LIST_STARHASH,
                                  LIST_STARHASH[_mem.dtmf.starhash]))
        dtmf.append(rs)

        rs = RadioSetting(
            "dtmf.codespace", "Code Space Time[ms]",
            RadioSettingValueList(LIST_CODESPACE,
                                  LIST_CODESPACE[_mem.dtmf.codespace]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.sidetone", "DTMF Sidetone",
                          RadioSettingValueBoolean(_mem.dtmf.sidetone))
        dtmf.append(rs)

        # setup pttid entries
        for i in range(0, 2):
            objname = "code" + str(i + 1)
            names = ["PTT ID(BOT)", "PTT ID(EOT)"]
            strname = str(names[i])
            dtmfsetting = getattr(_mem.dtmf, objname)
            dtmflen = getattr(_mem.dtmf, objname + "_len")
            dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
            code = RadioSettingValueString(0, 16, dtmfstr)
            code.set_charset(DTMF_CHARSET + list(" "))
            rs = RadioSetting("dtmf." + objname, strname, code)
            dtmf.append(rs)

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

        # setup id code entry
        codesetting = getattr(_mem.dtmf, "idcode")
        codestr = self._bbcd2num(codesetting, 6)
        code = RadioSettingValueString(0, 6, _filter(codestr))
        code.set_charset(NUMERIC_CHARSET + list(" "))
        rs = RadioSetting("dtmf.idcode", "ID Code", code)
        dtmf.append(rs)

        if _mem.dtmf.groupcode > 6:
            val = 0
        else:
            val = _mem.dtmf.groupcode
        rs = RadioSetting(
            "dtmf.groupcode", "Group Code",
            RadioSettingValueList(LIST_GROUPCODE, LIST_GROUPCODE[val]))
        dtmf.append(rs)

        if _mem.dtmf.resettime > 60:
            val = 0
        else:
            val = _mem.dtmf.resettime
        rs = RadioSetting(
            "dtmf.resettime", "Auto Reset Time[s]",
            RadioSettingValueList(LIST_RESETTIME,
                                  LIST_RESETTIME[_mem.dtmf.resettime]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.txdecode", "TX Decode",
                          RadioSettingValueBoolean(_mem.dtmf.txdecode))
        dtmf.append(rs)

        rs = RadioSetting(
            "dtmf.decodeto", "Decode Time Out[ms]",
            RadioSettingValueList(LIST_DECODETO,
                                  LIST_DECODETO[_mem.dtmf.decodeto]))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.decodetone", "Decode Tone",
                          RadioSettingValueBoolean(_mem.dtmf.decodetone))
        dtmf.append(rs)

        rs = RadioSetting("dtmf.resettone", "Reset Tone",
                          RadioSettingValueBoolean(_mem.dtmf.resettone))
        dtmf.append(rs)

        rs = RadioSetting(
            "dtmf.stuntype", "Stun Type",
            RadioSettingValueList(LIST_STUNTYPE,
                                  LIST_STUNTYPE[_mem.dtmf.stuntype]))
        dtmf.append(rs)

        ## setup stun entry
        objname = "code3"
        strname = "Stun Code"
        dtmfsetting = getattr(_mem.dtmf, objname)
        dtmflen = getattr(_mem.dtmf, objname + "_len")
        dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
        code = RadioSettingValueString(0, 10, dtmfstr)
        code.set_charset(DTMF_CHARSET + list(" "))
        rs = RadioSetting("dtmf." + objname, strname, code)
        dtmf.append(rs)

        return top
Exemple #17
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
Exemple #18
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        autodial = RadioSettingGroup("autodial", "AutoDial")
        keymaps = RadioSettingGroup("keymaps", "KeyMaps")

        top = RadioSettings(basic, keymaps, autodial)

        rs = RadioSetting(
                "beep", "Beep",
                RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)
        rs = RadioSetting(
                "lock", "Lock",
                RadioSettingValueBoolean(_settings.lock))
        basic.append(rs)
        rs = RadioSetting(
                "ars", "Auto Repeater Shift",
                RadioSettingValueBoolean(_settings.ars))
        basic.append(rs)
        rs = RadioSetting(
                "txpwrsave", "TX Power Save",
                RadioSettingValueBoolean(_settings.txpwrsave))
        basic.append(rs)
        rs = RadioSetting(
                "txnarrow", "TX Narrow",
                RadioSettingValueBoolean(_settings.txnarrow))
        basic.append(rs)
        options = ["Off", "S-3", "S-5", "S-Full"]
        rs = RadioSetting(
                "rfsqlvl", "RF Squelch Level",
                RadioSettingValueList(options, options[_settings.rfsqlvl]))
        basic.append(rs)
        options = ["Off", "Band A", "Band B", "Both"]
        rs = RadioSetting(
                "pttlock", "PTT Lock",
                RadioSettingValueList(options, options[_settings.pttlock]))
        basic.append(rs)

        rs = RadioSetting(
                "cwid_en", "CWID Enable",
                RadioSettingValueBoolean(_settings.cwid_en))
        basic.append(rs)

        cwid = RadioSettingValueString(0, 7, self._decode_cwid(_settings.cwid))
        cwid.set_charset(FT90_CWID_CHARS)
        rs = RadioSetting("cwid", "CWID", cwid)
        basic.append(rs)

        options = ["OFF"] + map(str, range(1, 12+1))
        rs = RadioSetting(
                "apo", "APO time (hrs)",
                RadioSettingValueList(options, options[_settings.apo]))
        basic.append(rs)

        options = ["Off"] + map(str, range(1, 60+1))
        rs = RadioSetting(
                "tot", "Time Out Timer (mins)",
                RadioSettingValueList(options, options[_settings.tot]))
        basic.append(rs)

        options = ["off", "Auto/TX", "Auto", "TX"]
        rs = RadioSetting(
                "fancontrol", "Fan Control",
                RadioSettingValueList(options, options[_settings.fancontrol]))
        basic.append(rs)

        keyopts = ["Scan Up", "Scan Down", "Repeater", "Reverse", "Tone Burst",
                   "Tx Power", "Home Ch", "VFO/MR", "Tone", "Priority"]
        rs = RadioSetting(
                "key_lt", "Left Key",
                RadioSettingValueList(keyopts, keyopts[_settings.key_lt]))
        keymaps.append(rs)
        rs = RadioSetting(
                "key_rt", "Right Key",
                RadioSettingValueList(keyopts, keyopts[_settings.key_rt]))
        keymaps.append(rs)
        rs = RadioSetting(
                "key_p1", "P1 Key",
                RadioSettingValueList(keyopts, keyopts[_settings.key_p1]))
        keymaps.append(rs)
        rs = RadioSetting(
                "key_p2", "P2 Key",
                RadioSettingValueList(keyopts, keyopts[_settings.key_p2]))
        keymaps.append(rs)
        rs = RadioSetting(
                "key_acc", "ACC Key",
                RadioSettingValueList(keyopts, keyopts[_settings.key_acc]))
        keymaps.append(rs)

        options = map(str, range(0, 12+1))
        rs = RadioSetting(
                "lcdcontrast", "LCD Contrast",
                RadioSettingValueList(options, options[_settings.lcdcontrast]))
        basic.append(rs)

        options = ["off", "d4", "d3", "d2", "d1"]
        rs = RadioSetting(
                "dimmer", "Dimmer",
                RadioSettingValueList(options, options[_settings.dimmer]))
        basic.append(rs)

        options = ["TRX Normal", "RX Reverse", "TX Reverse", "TRX Reverse"]
        rs = RadioSetting(
                "dcsmode", "DCS Mode",
                RadioSettingValueList(options, options[_settings.dcsmode]))
        basic.append(rs)

        options = ["50 ms", "100 ms"]
        rs = RadioSetting(
                "dtmfspeed", "DTMF Speed",
                RadioSettingValueList(options, options[_settings.dtmfspeed]))
        autodial.append(rs)

        options = ["50 ms", "250 ms", "450 ms", "750 ms", "1 sec"]
        rs = RadioSetting(
                "dtmftxdelay", "DTMF TX Delay",
                RadioSettingValueList(options, options[_settings.dtmftxdelay]))
        autodial.append(rs)

        options = map(str, range(1, 8 + 1))
        rs = RadioSetting(
                "dtmf_active", "DTMF Active",
                RadioSettingValueList(options, options[_settings.dtmf_active]))
        autodial.append(rs)

        # setup 8 dtmf autodial entries
        for i in map(str, range(1, 9)):
            objname = "dtmf" + i
            dtmfsetting = getattr(_settings, objname)
            dtmflen = getattr(_settings, objname + "_len")
            dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
            dtmf = RadioSettingValueString(0, 16, dtmfstr)
            dtmf.set_charset(FT90_DTMF_CHARS + list(" "))
            rs = RadioSetting(objname, objname.upper(), dtmf)
            autodial.append(rs)

        return top
Exemple #19
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        dtmf = RadioSettingGroup("dtmf", "DTMF")
        arts = RadioSettingGroup("arts", "ARTS")
        top = RadioSettingGroup("top", "All Settings", basic, arts, dtmf)

        options = [ "off", "30m", "1h", "3h", "5h", "8h" ]
        rs = RadioSetting("apo", "APO time (hrs)",
                          RadioSettingValueList(options,
                                        options[_settings.apo]))
        basic.append(rs)
        
        rs = RadioSetting("ars", "Auto Repeater Shift",
                        RadioSettingValueBoolean(_settings.ars))
        basic.append(rs)
        
        rs = RadioSetting("att", "Attenuation",
                        RadioSettingValueBoolean(_settings.att))
        basic.append(rs)
        
        rs = RadioSetting("bclo", "Busy Channel Lockout",
                        RadioSettingValueBoolean(_settings.bclo))
        basic.append(rs)
                          
        rs = RadioSetting("beep", "Beep",
                        RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)
        
        options = [ "off", "1", "3", "5", "8", "cont"]
        rs = RadioSetting("bell", "Bell",
                          RadioSettingValueList(options,
                                        options[_settings.bell]))
        basic.append(rs)                          
        
        rs = RadioSetting("busyled", "Busy LED",
                        RadioSettingValueBoolean(_settings.busyled))
        basic.append(rs)
        
        options = [ "5", "10", "50", "100" ]
        rs = RadioSetting("chcounter", "Channel Counter (MHz)",
                          RadioSettingValueList(options,
                                        options[_settings.chcounter]))
        basic.append(rs)
        
        rs = RadioSetting("dcsrev", "DCS Reverse",
                        RadioSettingValueBoolean(_settings.dcsrev))
        basic.append(rs)
        
        options = map(str, range(0,12+1))
        rs = RadioSetting("dimmer", "Dimmer",
                        RadioSettingValueList(options, options[_settings.dimmer]))
        basic.append(rs)
        
        rs = RadioSetting("edgebeep", "Edge Beep",
                        RadioSettingValueBoolean(_settings.edgebeep))
        basic.append(rs)
        
        options = [ "beep", "strobe", "bp+str", "beam", "bp+beam", "cw", "bp+cw" ]
        rs = RadioSetting("emergmode", "Emergency Mode",
                          RadioSettingValueList(options,
                                        options[_settings.emergmode]))
        basic.append(rs)
        
        options = ["Home", "Reverse"]
        rs = RadioSetting("hmrv", "HM/RV key",
                        RadioSettingValueList(options, options[_settings.hmrv]))
        basic.append(rs)
        
        options = ["My Menu", "Internet"]
        rs = RadioSetting("internet_key", "Internet key",
                        RadioSettingValueList(options, options[_settings.internet_key]))
        basic.append(rs)
        
        options = ["1 APO","2 AR BEP","3 AR INT","4 ARS","5 ATT","6 BCLO","7 BEEP","8 BELL",
            "9 BSYLED","10 CH CNT","11 CK SFT","12 CW ID","13 DC VLT","14 DCS CD","15 DCS RV",
            "16 DIMMER","17 DTMF","18 DTMF S","19 EDG BP","20 EMG S","21 HLFDEV","22 HM/RV",
            "23 INT MD","24 LAMP","25 LOCK","26 M/T-CL","27 MW MD","28 NAME","29 NM SET",
            "30 OPNMSG","31 RESUME","32 RF SQL","33 RPT","34 RX MD","35 RXSAVE","36 S SCH",
            "37 SCNLMP","38 SHIFT","39 SKIP","40 SPLIT","41 SQL","42 SQL TYP","43 STEP",
            "44 TN FRQ","45 TOT","46 TXSAVE","47 VFO MD", "48 TR SQL (JAPAN)", "48 WX ALT"]
        
        rs = RadioSetting("mymenu", "My Menu function",
                            RadioSettingValueList(options, options[_settings.mymenu - 9]))
        basic.append(rs)
        
        options = ["wires", "link"]
        rs = RadioSetting("internet_mode", "Internet mode",
                        RadioSettingValueList(options, options[_settings.internet_mode]))
        basic.append(rs)
        
        options = ["key", "cont", "off"]
        rs = RadioSetting("lamp", "Lamp mode",
                        RadioSettingValueList(options, options[_settings.lamp]))
        basic.append(rs)
        
        options = ["key", "dial", "key+dial", "ptt", "key+ptt", "dial+ptt", "all"]
        rs = RadioSetting("lock", "Lock mode",
                        RadioSettingValueList(options, options[_settings.lock]))
        basic.append(rs)
        
        options = ["monitor", "tone call"]
        rs = RadioSetting("moni_tcall", "MONI key",
                        RadioSettingValueList(options, options[_settings.moni_tcall]))
        basic.append(rs)
        
        options = ["lower", "next"]
        rs = RadioSetting("mwmode", "Memory write mode",
                        RadioSettingValueList(options, options[_settings.mwmode]))
        basic.append(rs)
        
        options = map(str, range(0,15+1))
        rs = RadioSetting("nfm_sql", "NFM Sql",
                        RadioSettingValueList(options, options[_settings.nfm_sql]))
        basic.append(rs)
        
        options = map(str, range(0,8+1))
        rs = RadioSetting("wfm_sql", "WFM Sql",
                        RadioSettingValueList(options, options[_settings.wfm_sql]))
        basic.append(rs)
        
        options = ["off", "dc", "msg"]
        rs = RadioSetting("openmsgmode", "Opening message",
                        RadioSettingValueList(options, options[_settings.openmsgmode]))
        basic.append(rs)
        
        openmsg = RadioSettingValueString(0, 6, self._decode_chars(_settings.openmsg.get_value()))
        openmsg.set_charset(CHARSET)
        rs = RadioSetting("openmsg", "Opening Message", openmsg)
        basic.append(rs)        
                
        options = ["3s","5s","10s","busy","hold"]
        rs = RadioSetting("resume", "Resume",
                        RadioSettingValueList(options, options[_settings.resume]))
        basic.append(rs)
        
        options = ["off"] + map(str,range(1,9+1))
        rs = RadioSetting("rfsql", "RF Sql",
                 RadioSettingValueList(options,options[_settings.rfsql]))
        basic.append(rs)
        
        options = ["off","200ms","300ms","500ms","1s","2s"]
        rs = RadioSetting("rxsave", "RX pwr save",
                        RadioSettingValueList(options, options[_settings.rxsave]))
        basic.append(rs) 
         
        options = ["single","cont"]
        rs = RadioSetting("smartsearch", "Smart search",
                        RadioSettingValueList(options, options[_settings.smartsearch]))
        basic.append(rs)
        
        rs = RadioSetting("scan_lamp", "Scan lamp",
                        RadioSettingValueBoolean(_settings.scan_lamp))
        basic.append(rs)
        
        rs = RadioSetting("split", "Split",
                        RadioSettingValueBoolean(_settings.split))
        basic.append(rs)
        
        options = ["off","1","3","5","10"]
        rs = RadioSetting("tot", "TOT (mins)",
                        RadioSettingValueList(options, options[_settings.tot]))
        basic.append(rs)
        
        rs = RadioSetting("txsave", "TX pwr save",
                        RadioSettingValueBoolean(_settings.txsave))
        basic.append(rs)
        
        options = ["all", "band"]
        rs = RadioSetting("vfomode", "VFO mode",
                        RadioSettingValueList(options, options[_settings.vfomode]))
        basic.append(rs)
        
        rs = RadioSetting("wx_alert", "WX Alert",
                        RadioSettingValueBoolean(_settings.wx_alert))
        basic.append(rs)
        
        #todo: priority channel
        
        #todo: handle WX ch labels
        
        # arts settings (ar beep, ar int, cwid en, cwid field)
        options = ["15s", "25s"]
        rs = RadioSetting("artsinterval", "ARTS Interval",
                        RadioSettingValueList(options, options[_settings.artsinterval]))
        arts.append(rs)
        
        options = ["off", "in range", "always"]
        rs = RadioSetting("artsbeep", "ARTS Beep",
                        RadioSettingValueList(options, options[_settings.artsbeep]))
        arts.append(rs)
        
        rs = RadioSetting("cwid_en", "CWID Enable",
                        RadioSettingValueBoolean(_settings.cwid_en))
        arts.append(rs)
        
        cwid = RadioSettingValueString(0, 16, self._decode_chars(_settings.cwid.get_value()))
        cwid.set_charset(CHARSET)
        rs = RadioSetting("cwid", "CWID", cwid)
        arts.append(rs)
        
        # setup dtmf
        options = ["manual", "auto"]
        rs = RadioSetting("dtmfmode", "DTMF mode",
                        RadioSettingValueList(options, options[_settings.dtmfmode]))
        dtmf.append(rs)
        
        for i in range(0,8+1):
            name = "dtmf" + str(i+1)
            dtmfsetting = self._memobj.dtmf[i]
            #dtmflen = getattr(_settings, objname + "_len")
            dtmfstr = ""
            for c in dtmfsetting.digits:
                if c < len(DTMFCHARSET):
                    dtmfstr += DTMFCHARSET[c]
            if CHIRP_DEBUG:
                print dtmfstr
            dtmfentry = RadioSettingValueString(0, 16, dtmfstr)
            dtmfentry.set_charset(DTMFCHARSET + list(" "))
            rs = RadioSetting(name, name.upper(), dtmfentry)
            dtmf.append(rs)            
        
        return top
Exemple #20
0
    def get_settings(self):
        _settings = self._memobj.settings

        repeater = RadioSettingGroup("repeater", "Repeater Settings")
        ctcss = RadioSettingGroup("ctcss", "CTCSS/DCS/DTMF Settings")
        arts = RadioSettingGroup("arts", "ARTS Settings")
        scan = RadioSettingGroup("scan", "Scan Settings")
        power = RadioSettingGroup("power", "Power Saver Settings")
        wires = RadioSettingGroup("wires", "WiRES(tm) Settings")
        eai = RadioSettingGroup("eai", "EAI/EPCS Settings")
        switch = RadioSettingGroup("switch", "Switch/Knob Settings")
        misc = RadioSettingGroup("misc", "Miscellaneous Settings")
        mbls = RadioSettingGroup("banks", "Memory Bank Link Scan")

        setmode = RadioSettings(repeater, ctcss, arts, scan, power,
                                wires, eai, switch, misc, mbls)

        # APO
        opts = ["OFF"] + ["%0.1f" % (x * 0.5) for x in range(1, 24 + 1)]
        misc.append(
            RadioSetting(
                "apo", "Automatic Power Off",
                RadioSettingValueList(opts, opts[_settings.apo])))

        # AR.BEP
        opts = ["OFF", "INRANG", "ALWAYS"]
        arts.append(
            RadioSetting(
                "ar_bep", "ARTS Beep",
                RadioSettingValueList(opts, opts[_settings.ar_bep])))

        # AR.INT
        opts = ["25 SEC", "15 SEC"]
        arts.append(
            RadioSetting(
                "ar_int", "ARTS Polling Interval",
                RadioSettingValueList(opts, opts[_settings.ar_int])))

        # ARS
        opts = ["OFF", "ON"]
        repeater.append(
            RadioSetting(
                "ars", "Automatic Repeater Shift",
                RadioSettingValueList(opts, opts[_settings.ars])))

        # BCLO
        opts = ["OFF", "ON"]
        misc.append(RadioSetting(
            "bclo", "Busy Channel Lock-Out",
            RadioSettingValueList(opts, opts[_settings.bclo])))

        # BEEP
        opts = ["OFF", "KEY", "KEY+SC"]
        rs = RadioSetting(
            "beep_key", "Enable the Beeper",
            RadioSettingValueList(
                opts, opts[_settings.beep_key + _settings.beep_sc]))

        def apply_beep(s, obj):
            setattr(obj, "beep_key",
                    (int(s.value) & 1) or ((int(s.value) >> 1) & 1))
            setattr(obj, "beep_sc", (int(s.value) >> 1) & 1)
        rs.set_apply_callback(apply_beep, self._memobj.settings)
        switch.append(rs)

        # BELL
        opts = ["OFF", "1T", "3T", "5T", "8T", "CONT"]
        ctcss.append(RadioSetting("bell", "Bell Repetitions",
                                  RadioSettingValueList(opts, opts[
                                                        _settings.bell])))

        # BSY.LED
        opts = ["ON", "OFF"]
        misc.append(RadioSetting("bsy_led", "Busy LED",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.bsy_led])))

        # DCS.NR
        opts = ["TR/X N", "RX R", "TX R", "T/RX R"]
        ctcss.append(RadioSetting("dcs_nr", "\"Inverted\" DCS Code Decoding",
                                  RadioSettingValueList(opts, opts[
                                                        _settings.dcs_nr])))

        # DT.DLY
        opts = ["50 MS", "100 MS", "250 MS", "450 MS", "750 MS", "1000 MS"]
        ctcss.append(RadioSetting("dt_dly", "DTMF Autodialer Delay Time",
                                  RadioSettingValueList(opts, opts[
                                                        _settings.dt_dly])))

        # DT.SPD
        opts = ["50 MS", "100 MS"]
        ctcss.append(RadioSetting("dt_spd", "DTMF Autodialer Sending Speed",
                                  RadioSettingValueList(opts, opts[
                                                        _settings.dt_spd])))

        # DT.WRT
        for i in range(0, 9):
            dtmf = self._memobj.dtmf[i]
            str = ""
            for c in dtmf.memory:
                if c == 0xFF:
                    break
                if c < len(DTMF_CHARS):
                    str += DTMF_CHARS[c]
            val = RadioSettingValueString(0, 16, str, False)
            val.set_charset(DTMF_CHARS + list("abcd"))
            rs = RadioSetting("dtmf_%i" % i,
                              "DTMF Autodialer Memory %i" % (i + 1), val)

            def apply_dtmf(s, obj):
                str = s.value.get_value().upper().rstrip()
                val = [DTMF_CHARS.index(x) for x in str]
                for x in range(len(val), 16):
                    val.append(0xFF)
                obj.memory = val
            rs.set_apply_callback(apply_dtmf, dtmf)
            ctcss.append(rs)

        # EDG.BEP
        opts = ["OFF", "ON"]
        misc.append(RadioSetting("edg_bep", "Band Edge Beeper",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.edg_bep])))

        # I.NET
        opts = ["OFF", "COD", "MEM"]
        rs = RadioSetting("inet", "Internet Link Connection",
                          RadioSettingValueList(
                              opts, opts[_settings.inet - 1]))

        def apply_inet(s, obj):
            setattr(obj, s.get_name(), int(s.value) + 1)
        rs.set_apply_callback(apply_inet, self._memobj.settings)
        wires.append(rs)

        # INT.CD
        opts = ["CODE 0", "CODE 1", "CODE 2", "CODE 3", "CODE 4",
                "CODE 5", "CODE 6", "CODE 7", "CODE 8", "CODE 9",
                "CODE A", "CODE B", "CODE C", "CODE D", "CODE E", "CODE F"]
        wires.append(RadioSetting("int_cd", "Access Number for WiRES(TM)",
                                  RadioSettingValueList(opts, opts[
                                                        _settings.int_cd])))

        # INT.MR
        opts = ["d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9"]
        wires.append(RadioSetting(
            "int_mr", "Access Number (DTMF) for Non-WiRES(TM)",
                     RadioSettingValueList(opts, opts[_settings.int_mr])))

        # LAMP
        opts = ["KEY", "5SEC", "TOGGLE"]
        switch.append(RadioSetting("lamp", "Lamp Mode",
                                   RadioSettingValueList(opts, opts[
                                                         _settings.lamp])))

        # LOCK
        opts = ["LK KEY", "LKDIAL", "LK K+D", "LK PTT",
                "LP P+K", "LK P+D", "LK ALL"]
        rs = RadioSetting("lock", "Control Locking",
                          RadioSettingValueList(
                              opts, opts[_settings.lock - 1]))

        def apply_lock(s, obj):
            setattr(obj, s.get_name(), int(s.value) + 1)
        rs.set_apply_callback(apply_lock, self._memobj.settings)
        switch.append(rs)

        # M/T-CL
        opts = ["MONI", "T-CALL"]
        switch.append(RadioSetting("mt_cl", "MONI Switch Function",
                                   RadioSettingValueList(opts, opts[
                                                         _settings.mt_cl])))

        # PAG.ABK
        opts = ["OFF", "ON"]
        eai.append(RadioSetting("pag_abk", "Paging Answer Back",
                                RadioSettingValueList(opts, opts[
                                                      _settings.pag_abk])))

        # RESUME
        opts = ["TIME", "HOLD", "BUSY"]
        scan.append(RadioSetting("resume", "Scan Resume Mode",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.resume])))

        # REV/HM
        opts = ["REV", "HOME"]
        switch.append(RadioSetting("rev_hm", "HM/RV Key Function",
                                   RadioSettingValueList(opts, opts[
                                                         _settings.rev_hm])))

        # RF.SQL
        opts = ["OFF", "S-1", "S-2", "S-3", "S-4", "S-5", "S-6",
                "S-7", "S-8", "S-FULL"]
        misc.append(RadioSetting("rf_sql", "RF Squelch Threshold",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.rf_sql])))

        # PRI.RVT
        opts = ["OFF", "ON"]
        scan.append(RadioSetting("pri_rvt", "Priority Revert",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.pri_rvt])))

        # RXSAVE
        opts = ["OFF", "200 MS", "300 MS", "500 MS", "1 S", "2 S"]
        power.append(RadioSetting(
            "rxsave", "Receive Mode Batery Savery Interval",
                     RadioSettingValueList(opts, opts[_settings.rxsave])))

        # S.SRCH
        opts = ["SINGLE", "CONT"]
        misc.append(RadioSetting("ssrch", "Smart Search Sweep Mode",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.ssrch])))

        # SCN.MD
        opts = ["MEM", "ONLY"]
        scan.append(RadioSetting(
                    "scn_md", "Memory Scan Channel Selection Mode",
                    RadioSettingValueList(opts, opts[_settings.scn_md])))

        # SCN.LMP
        opts = ["OFF", "ON"]
        scan.append(RadioSetting("scn_lmp", "Scan Lamp",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.scn_lmp])))

        # TOT
        opts = ["OFF"] + ["%dMIN" % (x) for x in range(1, 30 + 1)]
        misc.append(RadioSetting("tot", "Timeout Timer",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.tot])))

        # TX.LED
        opts = ["ON", "OFF"]
        misc.append(RadioSetting("tx_led", "TX LED",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.tx_led])))

        # TXSAVE
        opts = ["OFF", "ON"]
        power.append(RadioSetting("txsave", "Transmitter Battery Saver",
                                  RadioSettingValueList(opts, opts[
                                                        _settings.txsave])))

        # VFO.BND
        opts = ["BAND", "ALL"]
        misc.append(RadioSetting("vfo_bnd", "VFO Band Edge Limiting",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.vfo_bnd])))

        # WX.ALT
        opts = ["OFF", "ON"]
        scan.append(RadioSetting("wx_alt", "Weather Alert Scan",
                                 RadioSettingValueList(opts, opts[
                                                       _settings.wx_alt])))

        # MBS
        for i in range(0, 10):
            opts = ["OFF", "ON"]
            mbs = (self._memobj.mbs >> i) & 1
            rs = RadioSetting("mbs%i" % i, "Bank %s Scan" % (i + 1),
                              RadioSettingValueList(opts, opts[mbs]))

            def apply_mbs(s, index):
                if int(s.value):
                    self._memobj.mbs |= (1 << index)
                else:
                    self._memobj.mbs &= ~(1 << index)
            rs.set_apply_callback(apply_mbs, i)
            mbls.append(rs)

        return setmode
Exemple #21
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
Exemple #22
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        sound = RadioSettingGroup("sound", "Sound")
        dtmf = RadioSettingGroup("dtmf", "DTMF")
        arts = RadioSettingGroup("arts", "ARTS")
        eai = RadioSettingGroup("eai", "Emergency")
        msg = RadioSettingGroup("msg", "Messages")

        top = RadioSettings(basic, sound, arts, dtmf, eai, msg)

        basic.append(RadioSetting(
                "att_wx", "Attenuation WX",
                RadioSettingValueBoolean(_settings.att_wx)))

        basic.append(RadioSetting(
                "att_marine", "Attenuation Marine",
                RadioSettingValueBoolean(_settings.att_marine)))

        basic.append(RadioSetting(
                "att_broadcast", "Attenuation Broadcast",
                RadioSettingValueBoolean(_settings.att_broadcast)))

        basic.append(RadioSetting(
                "ars", "Auto Repeater Shift",
                RadioSettingValueBoolean(_settings.ars)))

        basic.append(RadioSetting(
                "home_vfo", "Home->VFO",
                RadioSettingValueBoolean(_settings.home_vfo)))

        basic.append(RadioSetting(
                "bclo", "Busy Channel Lockout",
                RadioSettingValueBoolean(_settings.bclo)))

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

        basic.append(RadioSetting(
                "fast_tone_search", "Fast Tone search",
                RadioSettingValueBoolean(_settings.fast_tone_search)))

        basic.append(RadioSetting(
                "priority_revert", "Priority Revert",
                RadioSettingValueBoolean(_settings.priority_revert)))

        basic.append(RadioSetting(
                "protect_memory", "Protect memory",
                RadioSettingValueBoolean(_settings.protect_memory)))

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

        basic.append(RadioSetting(
                "split_tone", "Split tone",
                RadioSettingValueBoolean(_settings.split_tone)))

        basic.append(RadioSetting(
                "tone_search_mute", "Tone search mute",
                RadioSettingValueBoolean(_settings.tone_search_mute)))

        basic.append(RadioSetting(
                "txsave", "TX save",
                RadioSettingValueBoolean(_settings.txsave)))

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

        opts = ["Bar Int", "Bar Ext"]
        basic.append(RadioSetting(
                "am_antenna", "AM antenna",
                RadioSettingValueList(opts, opts[_settings.am_antenna])))

        opts = ["Ext Ant", "Earphone"]
        basic.append(RadioSetting(
                "fm_antenna", "FM antenna",
                RadioSettingValueList(opts, opts[_settings.fm_antenna])))

        opts = ["off"] + ["%0.1f" % (t / 60.0) for t in range(30, 750, 30)]
        basic.append(RadioSetting(
                "apo", "APO time (hrs)",
                RadioSettingValueList(opts, opts[_settings.apo])))

        opts = ["+/- 5 MHZ", "+/- 10 MHZ", "+/- 50 MHZ", "+/- 100 MHZ"]
        basic.append(RadioSetting(
                "channel_counter", "Channel counter",
                RadioSettingValueList(opts, opts[_settings.channel_counter])))

        opts = ["0.3", "0.5", "0.7", "1.0", "1.5"]
        basic.append(RadioSetting(
                "fw_key_timer", "FW key timer (s)",
                RadioSettingValueList(opts, opts[_settings.fw_key_timer])))

        opts = ["Home", "Reverse"]
        basic.append(RadioSetting(
                "hm_rv", "HM/RV key",
                RadioSettingValueList(opts, opts[_settings.hm_rv])))

        opts = ["%d" % t for t in range(2, 11)] + ["continuous", "off"]
        basic.append(RadioSetting(
                "lamp", "Lamp Timer (s)",
                RadioSettingValueList(opts, opts[_settings.lamp])))

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

        opts = ["key", "ptt", "key+ptt"]
        basic.append(RadioSetting(
                "lock_mode", "Lock mode",
                RadioSettingValueList(opts, opts[_settings.lock_mode])))

        opts = ["10", "20", "50", "100"]
        basic.append(RadioSetting(
                "mem_ch_step", "Memory Chan step",
                RadioSettingValueList(opts, opts[_settings.mem_ch_step])))

        opts = ["lower", "next"]
        basic.append(RadioSetting(
                "mem_storage", "Memory storage mode",
                RadioSettingValueList(opts, opts[_settings.mem_storage])))

        opts = ["%d" % t for t in range(1, 10)]
        basic.append(RadioSetting(
                "mic_gain", "Mic gain",
                RadioSettingValueList(opts, opts[_settings.mic_gain])))

        opts = ["monitor", "tone call"]
        basic.append(RadioSetting(
                "moni_tcall", "Moni/TCall button",
                RadioSettingValueList(opts, opts[_settings.moni_tcall])))

        opts = ["off"] + \
               ["%02d:%02d" % (t / 60, t % 60) for t in range(10, 1450, 10)]
        basic.append(RadioSetting(
                "on_timer", "On Timer (hrs)",
                RadioSettingValueList(opts, opts[_settings.on_timer])))

        opts2 = ["off"] + \
                ["0.%d" % t for t in range(1, 10)] + \
                ["%1.1f" % (t / 10.0) for t in range(10, 105, 5)]
        basic.append(RadioSetting(
                "priority_time", "Priority time",
                RadioSettingValueList(opts2, opts2[_settings.priority_time])))

        opts = ["off", "20", "50", "100", "200"]
        basic.append(RadioSetting(
                "ptt_delay", "PTT delay (ms)",
                RadioSettingValueList(opts, opts[_settings.ptt_delay])))

        basic.append(RadioSetting(
                "rx_save", "RX save (s)",
                RadioSettingValueList(opts2, opts2[_settings.rx_save])))

        basic.append(RadioSetting(
                "scan_restart", "Scan restart (s)",
                RadioSettingValueList(opts2, opts2[_settings.scan_restart])))

        opts = ["%1.1f" % (t / 10.0) for t in range(20, 105, 5)] + \
               ["busy", "hold"]
        basic.append(RadioSetting(
                "scan_resume", "Scan resume (s)",
                RadioSettingValueList(opts, opts[_settings.scan_resume])))

        opts = ["single", "continuous"]
        basic.append(RadioSetting(
                "smart_search", "Smart search",
                RadioSettingValueList(opts, opts[_settings.smart_search])))

        opts = ["off"] + ["TRX %d" % t for t in range(1, 11)] + ["hold"] + \
               ["TX %d" % t for t in range(1, 11)]
        basic.append(RadioSetting(
                "sub_rx_timer", "Sub RX timer",
                RadioSettingValueList(opts, opts[_settings.sub_rx_timer])))

        opts = ["C", "F"]
        basic.append(RadioSetting(
                "temp_unit", "Temperature unit",
                RadioSettingValueList(opts, opts[_settings.temp_unit])))

        opts = ["off"] + ["%1.1f" % (t / 10.0) for t in range(5, 105, 5)]
        basic.append(RadioSetting(
                "tot", "Time-out timer (mins)",
                RadioSettingValueList(opts, opts[_settings.tot])))

        opts = ["all", "band"]
        basic.append(RadioSetting(
                "vfo_mode", "VFO mode",
                RadioSettingValueList(opts, opts[_settings.vfo_mode])))

        opts = ["off"] + ["%d" % t for t in range(5, 65, 5)] + ["EAI"]
        basic.append(RadioSetting(
                "wake_up", "Wake up (s)",
                RadioSettingValueList(opts, opts[_settings.wake_up])))

        opts = ["hold", "3 secs"]
        basic.append(RadioSetting(
                "vol_key_mode", "Volume key mode",
                RadioSettingValueList(opts, opts[_settings.vol_key_mode])))

        # subgroup programmable keys

        opts = ["INTNET", "INT MR", "Set Mode (my key)"]
        basic.append(RadioSetting(
                "internet_key", "Internet key",
                RadioSettingValueList(opts, opts[_settings.internet_key])))

        keys = ["Antenna AM", "Antenna FM", "Antenna Attenuator",
                "Auto Power Off", "Auto Repeater Shift", "ARTS Beep",
                "ARTS Interval", "Busy Channel Lockout", "Bell Ringer",
                "Bell Select", "Bank Name", "Band Edge Beep", "Beep Level",
                "Beep Select", "Beep User", "Busy LED", "Channel Counter",
                "Clock Shift", "CW ID", "CW Learning", "CW Pitch",
                "CW Training", "DC Voltage", "DCS Code", "DCS Reverse",
                "DTMF A/M", "DTMF Delay", "DTMF Set", "DTMF Speed",
                "EAI Timer", "Emergency Alarm", "Ext Menu", "FW Key",
                "Half Deviation", "Home/Reverse", "Home > VFO", "INT Code",
                "INT Conn Mode", "INT A/M", "INT Set", "INT Key", "INTNET",
                "Lamp", "LED Light", "Lock", "Moni/T-Call", "Mic Gain",
                "Memory Display", "Memory Write Mode", "Memory Channel Step",
                "Memory Name Write", "Memory Protect", "Memory Skip",
                "Message List", "Message Reg", "Message Set", "On Timer",
                "Open Message", "Pager Answer Back", "Pager Receive Code",
                "Pager Transmit Code", "Pager Frequency", "Priority Revert",
                "Priority Timer", "Password", "PTT Delay",
                "Repeater Shift Direction", "Repeater Shift", "Receive Mode",
                "Smart Search", "Save Rx", "Save Tx", "Scan Lamp",
                "Scan Resume", "Scan Restart", "Speaker Out",
                "Squelch Level", "Squelch Type", "Squelch S Meter",
                "Squelch Split Tone", "Step", "Stereo", "Sub Rx", "Temp",
                "Tone Frequency", "Time Out Timer", "Tone Search Mute",
                "Tone Search Speed", "VFO Band", "VFO Skip", "Volume Mode",
                "Wake Up", "Weather Alert"]
        rs = RadioSetting(
                "my_key", "My key",
                RadioSettingValueList(keys, keys[_settings.my_key - 16]))
        # TODO: fix keys list isnt exactly right order
        # leave disabled in settings for now
        # basic.append(rs)

        # sound tab

        sound.append(RadioSetting(
                "band_edge_beep", "Band edge beep",
                RadioSettingValueBoolean(_settings.band_edge_beep)))

        opts = ["off", "key+scan", "key"]
        sound.append(RadioSetting(
                "beep_mode", "Beep mode",
                RadioSettingValueList(opts, opts[_settings.beep_mode])))

        _volumes = self._memobj.volumes

        opts = map(str, range(0, 33))
        sound.append(RadioSetting(
                "speaker_vol", "Speaker volume",
                RadioSettingValueList(opts, opts[_volumes.speaker])))

        sound.append(RadioSetting(
                "earphone_vol", "Earphone volume",
                RadioSettingValueList(opts, opts[_volumes.earphone])))

        opts = ["auto", "speaker"]
        sound.append(RadioSetting(
                "fm_speaker_out", "FM Speaker out",
                RadioSettingValueList(opts, opts[_settings.fm_speaker_out])))

        opts = ["mono", "stereo"]
        sound.append(RadioSetting(
                "fm_broadcast_mode", "FM broadcast mode",
                RadioSettingValueList(
                    opts, opts[_settings.fm_broadcast_mode])))

        opts = map(str, range(16))
        sound.append(RadioSetting(
                "sql_fm", "Squelch level (FM)",
                RadioSettingValueList(opts, opts[_settings.sql_fm])))

        opts = map(str, range(9))
        sound.append(RadioSetting(
                "sql_wfm", "Squelch level (WFM)",
                RadioSettingValueList(opts, opts[_settings.sql_wfm])))

        opts = map(str, range(16))
        sound.append(RadioSetting(
                "radio_am_sql", "Squelch level (Broadcast Radio AM)",
                RadioSettingValueList(opts, opts[_settings.radio_am_sql])))

        opts = map(str, range(9))
        sound.append(RadioSetting(
                "radio_fm_sql", "Squelch level (Broadcast Radio FM)",
                RadioSettingValueList(opts, opts[_settings.radio_fm_sql])))

        # dtmf tab

        opts = ["manual", "auto"]
        dtmf.append(RadioSetting(
                "dtmf_autodialer", "DTMF autodialer mode",
                RadioSettingValueList(opts, opts[_settings.dtmf_autodialer])))

        opts = ["50", "250", "450", "750", "1000"]
        dtmf.append(RadioSetting(
                "dtmf_delay", "DTMF delay (ms)",
                RadioSettingValueList(opts, opts[_settings.dtmf_delay])))

        opts = ["50", "100"]
        dtmf.append(RadioSetting(
                "dtmf_speed", "DTMF speed (ms)",
                RadioSettingValueList(opts, opts[_settings.dtmf_speed])))

        opts = map(str, range(10))
        dtmf.append(RadioSetting(
                "dtmf_chan_active", "DTMF active",
                RadioSettingValueList(
                    opts, opts[_settings.dtmf_chan_active])))

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

        # arts tab
        arts.append(RadioSetting(
                "arts", "ARTS",
                RadioSettingValueBoolean(_settings.arts)))

        opts = ["off", "in range", "always"]
        arts.append(RadioSetting(
                "arts_beep", "ARTS beep",
                RadioSettingValueList(opts, opts[_settings.arts_beep])))

        opts = ["15", "25"]
        arts.append(RadioSetting(
                "arts_interval", "ARTS interval",
                RadioSettingValueList(opts, opts[_settings.arts_interval])))

        arts.append(RadioSetting(
                "arts_cwid_enable", "CW ID",
                RadioSettingValueBoolean(_settings.arts_cwid_enable)))

        cwid = RadioSettingValueString(
                0, 16, self._decode_chars(_settings.arts_cwid.get_value()))
        cwid.set_charset(CHARSET)
        arts.append(RadioSetting("arts_cwid", "CW ID", cwid))

        # EAI tab

        eai.append(RadioSetting(
                "emergency_eai", "EAI",
                RadioSettingValueBoolean(_settings.emergency_eai)))

        opts = ["interval %dm" % t for t in range(1, 10)] + \
               ["interval %dm" % t for t in range(10, 55, 5)] + \
               ["continuous %dm" % t for t in range(1, 10)] + \
               ["continuous %dm" % t for t in range(10, 55, 5)]

        eai.append(RadioSetting(
                "emergency_eai_time", "EAI time",
                RadioSettingValueList(
                    opts, opts[_settings.emergency_eai_time])))

        opts = ["beep", "strobe", "beep+strobe", "beam",
                "beep+beam", "cw", "beep+cw", "cwt"]
        eai.append(RadioSetting(
                "emergency_signal", "emergency signal",
                RadioSettingValueList(
                    opts, opts[_settings.emergency_signal])))

        # msg tab

        opts = ["off", "dc voltage", "message"]
        msg.append(RadioSetting(
                "openmsg_mode", "Opening message mode",
                RadioSettingValueList(opts, opts[_settings.openmsg_mode])))

        openmsg = RadioSettingValueString(
                0, 6, self._decode_chars(_settings.openmsg.get_value()))
        openmsg.set_charset(CHARSET)
        msg.append(RadioSetting("openmsg", "Opening Message", openmsg))

        return top
Exemple #23
0
    def get_settings(self):
        _settings = self._memobj.settings
        _dtmf_strings = self._memobj.dtmf_strings
        _passwd = self._memobj.passwd

        repeater = RadioSettingGroup("repeater", "Repeater Settings")
        ctcss = RadioSettingGroup("ctcss", "CTCSS/DCS/EPCS Settings")
        arts = RadioSettingGroup("arts", "ARTS Settings")
        mbls = RadioSettingGroup("banks", "Memory Settings")
        scan = RadioSettingGroup("scan", "Scan Settings")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        wires = RadioSettingGroup("wires", "WiRES(tm) Settings")
        switch = RadioSettingGroup("switch", "Switch/Knob Settings")
        disp = RadioSettingGroup("disp", "Display Settings")
        misc = RadioSettingGroup("misc", "Miscellaneous Settings")

        setmode = RadioSettings(repeater, ctcss, arts, mbls, scan, dtmf, wires,
                                switch, disp, misc)

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

        # 1 APO
        opts = ["Off", "30 Min", "1 Hour", "3 Hour", "5 Hour", "8 Hour"]
        misc.append(
            RadioSetting("apo", "Automatic Power Off",
                         RadioSettingValueList(opts, opts[_settings.apo])))

        # 2 AR.BEP
        opts = ["Off", "In Range", "Always"]
        arts.append(
            RadioSetting(
                "arts_beep", "ARTS Beep",
                RadioSettingValueList(opts, opts[_settings.arts_beep])))

        # 3 AR.INT
        opts = ["15 Sec", "25 Sec"]
        arts.append(
            RadioSetting(
                "arts_interval", "ARTS Polling Interval",
                RadioSettingValueList(opts, opts[_settings.arts_interval])))

        # 4 ARS
        opts = ["Off", "On"]
        repeater.append(
            RadioSetting("ars", "Automatic Repeater Shift",
                         RadioSettingValueList(opts, opts[_settings.ars])))

        # 5 BCLO
        opts = ["Off", "On"]
        misc.append(
            RadioSetting(
                "busy_lockout", "Busy Channel Lock-Out",
                RadioSettingValueList(opts, opts[_settings.busy_lockout])))

        # 6 BEEP
        opts = ["Off", "Key+Scan", "Key"]
        switch.append(
            RadioSetting("beep", "Enable the Beeper",
                         RadioSettingValueList(opts, opts[_settings.beep])))

        # 7 BELL
        opts = ["Off", "1", "3", "5", "8", "Continuous"]
        ctcss.append(
            RadioSetting("bell", "Bell Repetitions",
                         RadioSettingValueList(opts, opts[_settings.bell])))

        # 8 BNK.LNK
        for i in range(0, 8):
            opts = ["Off", "On"]
            mbs = (self._memobj.mbs >> i) & 1
            rs = RadioSetting("mbs%i" % i, "Bank %s Scan" % (i + 1),
                              RadioSettingValueList(opts, opts[mbs]))

            def apply_mbs(s, index):
                if int(s.value):
                    self._memobj.mbs |= (1 << index)
                else:
                    self._memobj.mbs &= ~(1 << index)

            rs.set_apply_callback(apply_mbs, i)
            mbls.append(rs)

        # 9 BNK.NM - A per-bank attribute, nothing to do here.

        # 10 CLK.SFT - A per-channel attribute, nothing to do here.

        # 11 CW.ID
        opts = ["Off", "On"]
        arts.append(
            RadioSetting("cw_id", "CW ID Enable",
                         RadioSettingValueList(opts, opts[_settings.cw_id])))

        cw_id_text = ""
        for i in _settings.cw_id_string:
            try:
                cw_id_text += CHARSET[i & 0x7F]
            except IndexError:
                if i != 0xff:
                    LOG.debug("unknown char index in cw id: %x " % (i))

        val = RadioSettingValueString(0, 16, cw_id_text, True)
        val.set_charset(CHARSET + "abcdefghijklmnopqrstuvwxyz")
        rs = RadioSetting("cw_id_string", "CW Identifier Text", val)

        def apply_cw_id(s):
            str = s.value.get_value().upper().rstrip()
            mval = ""
            mval = [chr(CHARSET.index(x)) for x in str]
            for x in range(len(mval), 16):
                mval.append(chr(0xff))
            for x in range(0, 16):
                _settings.cw_id_string[x] = ord(mval[x])

        rs.set_apply_callback(apply_cw_id)
        arts.append(rs)

        # 12 CWTRNG
        opts = [
            "Off", "4WPM", "5WPM", "6WPM", "7WPM", "8WPM", "9WPM", "10WPM",
            "11WPM", "12WPM", "13WPM", "15WPM", "17WPM", "20WPM", "24WPM",
            "30WPM", "40WPM"
        ]
        misc.append(
            RadioSetting("cw_trng", "CW Training",
                         RadioSettingValueList(opts, opts[_settings.cw_trng])))

        # todo: make the setting of the units here affect the display
        # of the speed.  Not critical, but would be slick.
        opts = ["CPM", "WPM"]
        misc.append(
            RadioSetting(
                "cw_trng_units", "CW Training Units",
                RadioSettingValueList(opts, opts[_settings.cw_trng_units])))

        # 13 DC VLT - a read-only status, so nothing to do here

        # 14 DCS CD - A per-channel attribute, nothing to do here

        # 15 DCS.RV
        opts = ["Disabled", "Enabled"]
        ctcss.append(
            RadioSetting(
                "inverted_dcs", "\"Inverted\" DCS Code Decoding",
                RadioSettingValueList(opts, opts[_settings.inverted_dcs])))

        # 16 DIMMER
        opts = ["Off"] + ["Level %d" % (x) for x in range(1, 11)]
        disp.append(
            RadioSetting("dimmer", "Dimmer",
                         RadioSettingValueList(opts, opts[_settings.dimmer])))

        # 17 DT.A/M
        opts = ["Manual", "Auto"]
        dtmf.append(
            RadioSetting(
                "dtmf_mode", "DTMF Autodialer",
                RadioSettingValueList(opts, opts[_settings.dtmf_mode])))

        # 18 DT.DLY
        opts = ["50 ms", "250 ms", "450 ms", "750 ms", "1000 ms"]
        dtmf.append(
            RadioSetting(
                "dtmf_delay", "DTMF Autodialer Delay Time",
                RadioSettingValueList(opts, opts[_settings.dtmf_delay])))

        # 19 DT.SET
        for memslot in range(0, 10):
            dtmf_memory = ""
            for i in _dtmf_strings[memslot].dtmf_string:
                if i != 0xFF:
                    try:
                        dtmf_memory += CHARSET[i]
                    except IndexError:
                        LOG.debug("unknown char index in dtmf: %x " % (i))

            val = RadioSettingValueString(0, 16, dtmf_memory, True)
            val.set_charset(CHARSET + "abcdef")
            rs = RadioSetting("dtmf_string_%d" % memslot,
                              "DTMF Memory %d" % memslot, val)

            def apply_dtmf(s, i):
                LOG.debug("applying dtmf for %x\n" % i)
                str = s.value.get_value().upper().rstrip()
                LOG.debug("str is %s\n" % str)
                mval = ""
                mval = [chr(CHARSET.index(x)) for x in str]
                for x in range(len(mval), 16):
                    mval.append(chr(0xff))
                for x in range(0, 16):
                    _dtmf_strings[i].dtmf_string[x] = ord(mval[x])

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

        # 20 DT.SPD
        opts = ["50 ms", "100 ms"]
        dtmf.append(
            RadioSetting(
                "dtmf_speed", "DTMF Autodialer Sending Speed",
                RadioSettingValueList(opts, opts[_settings.dtmf_speed])))

        # 21 EDG.BEP
        opts = ["Off", "On"]
        mbls.append(
            RadioSetting(
                "edge_beep", "Band Edge Beeper",
                RadioSettingValueList(opts, opts[_settings.edge_beep])))

        # 22 INT.CD
        opts = ["DTMF %X" % (x) for x in range(0, 16)]
        wires.append(
            RadioSetting("int_cd", "Access Number for WiRES(TM)",
                         RadioSettingValueList(opts, opts[_settings.int_cd])))

        # 23 ING MD
        opts = ["Sister Radio Group", "Friends Radio Group"]
        wires.append(
            RadioSetting(
                "wires_mode", "Internet Link Connection Mode",
                RadioSettingValueList(opts, opts[_settings.wires_mode])))

        # 24 INT.A/M
        opts = ["Manual", "Auto"]
        wires.append(
            RadioSetting(
                "wires_auto", "Internet Link Autodialer",
                RadioSettingValueList(opts, opts[_settings.wires_auto])))
        # 25 INT.SET
        opts = ["F%d" % (x) for x in range(0, 10)]

        wires.append(
            RadioSetting("int_set", "Memory Register for "
                         "non-WiRES Internet",
                         RadioSettingValueList(opts, opts[_settings.int_set])))

        # 26 LOCK
        opts = [
            "Key", "Dial", "Key + Dial", "PTT", "Key + PTT", "Dial + PTT",
            "All"
        ]
        switch.append(
            RadioSetting("lock", "Control Locking",
                         RadioSettingValueList(opts, opts[_settings.lock])))

        # 27 MCGAIN
        opts = ["Level %d" % (x) for x in range(1, 10)]
        misc.append(
            RadioSetting("mic_gain", "Microphone Gain",
                         RadioSettingValueList(opts,
                                               opts[_settings.mic_gain])))

        # 28 MEM.SCN
        opts = ["Tag 1", "Tag 2", "All Channels"]
        rs = RadioSetting(
            "scan_mode", "Memory Scan Mode",
            RadioSettingValueList(opts, opts[_settings.scan_mode - 1]))

        # this setting is unusual in that it starts at 1 instead of 0.
        # that is, index 1 corresponds to "Tag 1", and index 0 is invalid.
        # so we create a custom callback to handle this.

        def apply_scan_mode(s):
            myopts = ["Tag 1", "Tag 2", "All Channels"]
            _settings.scan_mode = myopts.index(s.value.get_value()) + 1

        rs.set_apply_callback(apply_scan_mode)
        mbls.append(rs)

        # 29 MW MD
        opts = ["Lower", "Next"]
        mbls.append(
            RadioSetting("mw_mode", "Memory Write Mode",
                         RadioSettingValueList(opts, opts[_settings.mw_mode])))

        # 30 NM SET - This is per channel, so nothing to do here

        # 31 OPN.MSG
        opts = ["Off", "DC Supply Voltage", "Text Message"]
        disp.append(
            RadioSetting("open_msg", "Opening Message Type",
                         RadioSettingValueList(opts,
                                               opts[_settings.open_msg])))

        openmsg = ""
        for i in _settings.openMsg_Text:
            try:
                openmsg += CHARSET[i & 0x7F]
            except IndexError:
                if i != 0xff:
                    LOG.debug("unknown char index in openmsg: %x " % (i))

        val = RadioSettingValueString(0, 6, openmsg, True)
        val.set_charset(CHARSET + "abcdefghijklmnopqrstuvwxyz")
        rs = RadioSetting("openMsg_Text", "Opening Message Text", val)

        def apply_openmsg(s):
            str = s.value.get_value().upper().rstrip()
            mval = ""
            mval = [chr(CHARSET.index(x)) for x in str]
            for x in range(len(mval), 6):
                mval.append(chr(0xff))
            for x in range(0, 6):
                _settings.openMsg_Text[x] = ord(mval[x])

        rs.set_apply_callback(apply_openmsg)
        disp.append(rs)

        # 32 PAGER - a per-channel attribute

        # 33 PAG.ABK
        opts = ["Off", "On"]
        ctcss.append(
            RadioSetting("pag_abk", "Paging Answer Back",
                         RadioSettingValueList(opts, opts[_settings.pag_abk])))

        # 34 PAG.CDR
        opts = ["%2.2d" % (x) for x in range(1, 50)]
        ctcss.append(
            RadioSetting(
                "pag_cdr_1", "Receive Page Code 1",
                RadioSettingValueList(opts, opts[_settings.pag_cdr_1])))

        ctcss.append(
            RadioSetting(
                "pag_cdr_2", "Receive Page Code 2",
                RadioSettingValueList(opts, opts[_settings.pag_cdr_2])))

        # 35 PAG.CDT
        opts = ["%2.2d" % (x) for x in range(1, 50)]
        ctcss.append(
            RadioSetting(
                "pag_cdt_1", "Transmit Page Code 1",
                RadioSettingValueList(opts, opts[_settings.pag_cdt_1])))

        ctcss.append(
            RadioSetting(
                "pag_cdt_2", "Transmit Page Code 2",
                RadioSettingValueList(opts, opts[_settings.pag_cdt_2])))

        # Common Button Options
        button_opts = [
            "Squelch Off", "Weather", "Smart Search", "Tone Scan", "Scan",
            "T Call", "ARTS"
        ]

        # 36 PRG P1
        opts = button_opts + ["DC Volts"]
        switch.append(
            RadioSetting("prog_p1", "P1 Button",
                         RadioSettingValueList(opts, opts[_settings.prog_p1])))

        # 37 PRG P2
        opts = button_opts + ["Dimmer"]
        switch.append(
            RadioSetting("prog_p2", "P2 Button",
                         RadioSettingValueList(opts, opts[_settings.prog_p2])))

        # 38 PRG P3
        opts = button_opts + ["Mic Gain"]
        switch.append(
            RadioSetting("prog_p3", "P3 Button",
                         RadioSettingValueList(opts, opts[_settings.prog_p3])))

        # 39 PRG P4
        opts = button_opts + ["Skip"]
        switch.append(
            RadioSetting("prog_p4", "P4 Button",
                         RadioSettingValueList(opts, opts[_settings.prog_p4])))

        # 40 PSWD
        password = ""
        for i in _passwd:
            if i != 0xFF:
                try:
                    password += CHARSET[i]
                except IndexError:
                    LOG.debug("unknown char index in password: %x " % (i))

        val = RadioSettingValueString(0, 4, password, True)
        val.set_charset(CHARSET[0:15] + "abcdef ")
        rs = RadioSetting("passwd", "Password", val)

        def apply_password(s):
            str = s.value.get_value().upper().rstrip()
            mval = ""
            mval = [chr(CHARSET.index(x)) for x in str]
            for x in range(len(mval), 4):
                mval.append(chr(0xff))
            for x in range(0, 4):
                _passwd[x] = ord(mval[x])

        rs.set_apply_callback(apply_password)
        misc.append(rs)

        # 41 RESUME
        opts = ["3 Sec", "5 Sec", "10 Sec", "Busy", "Hold"]
        scan.append(
            RadioSetting("resume", "Scan Resume Mode",
                         RadioSettingValueList(opts, opts[_settings.resume])))

        # 42 RF.SQL
        opts = ["Off"] + ["S-%d" % (x) for x in range(1, 10)]
        misc.append(
            RadioSetting("rf_sql", "RF Squelch Threshold",
                         RadioSettingValueList(opts, opts[_settings.rf_sql])))

        # 43 RPT - per channel attribute, nothing to do here

        # 44 RVRT
        opts = ["Off", "On"]
        misc.append(
            RadioSetting("revert", "Priority Revert",
                         RadioSettingValueList(opts, opts[_settings.revert])))

        # 45 S.SRCH
        opts = ["Single", "Continuous"]
        misc.append(
            RadioSetting("s_search", "Smart Search Sweep Mode",
                         RadioSettingValueList(opts,
                                               opts[_settings.s_search])))

        # 46 SHIFT - per channel setting, nothing to do here

        # 47 SKIP = per channel setting, nothing to do here

        # 48 SPLIT - per channel attribute, nothing to do here

        # 49 SQL.TYP - per channel attribute, nothing to do here

        # 50 STEP - per channel attribute, nothing to do here

        # 51 TEMP - read-only status, nothing to do here

        # 52 TN FRQ - per channel attribute, nothing to do here

        # 53 TOT
        opts = ["Off", "1 Min", "3 Min", "5 Min", "10 Min"]
        misc.append(
            RadioSetting("tot", "Timeout Timer",
                         RadioSettingValueList(opts, opts[_settings.tot])))

        # 54 TS MUT
        opts = ["Off", "On"]
        ctcss.append(
            RadioSetting("ts_mut", "Tone Search Mute",
                         RadioSettingValueList(opts, opts[_settings.ts_mut])))

        # 55 TS SPEED
        opts = ["Fast", "Slow"]
        ctcss.append(
            RadioSetting("ts_speed", "Tone Search Scanner Speed",
                         RadioSettingValueList(opts,
                                               opts[_settings.ts_speed])))

        # 56 VFO.SCN
        opts = ["+/- 1MHz", "+/- 2MHz", "+/-5MHz", "All"]
        scan.append(
            RadioSetting("vfo_scan", "VFO Scanner Width",
                         RadioSettingValueList(opts,
                                               opts[_settings.vfo_scan])))

        # 57 WX.ALT
        opts = ["Off", "On"]
        misc.append(
            RadioSetting("wx_alert", "Weather Alert Scan",
                         RadioSettingValueList(opts,
                                               opts[_settings.wx_alert])))

        # 58 WX.VOL
        opts = ["Normal", "Maximum"]
        misc.append(
            RadioSetting(
                "wx_vol_max", "Weather Alert Volume",
                RadioSettingValueList(opts, opts[_settings.wx_vol_max])))

        # 59 W/N DV - this is a per-channel attribute, nothing to do here

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

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

        #
        # Configuration Settings
        #
        rs = RadioSetting("channel_menu", "Menu available in channel mode",
                          RadioSettingValueBoolean(_settings.channel_menu))
        cfg_grp.append(rs)
        rs = RadioSetting("ponmsg", "Poweron message",
                          RadioSettingValueList(
                              PONMSG_LIST, PONMSG_LIST[_settings.ponmsg]))
        cfg_grp.append(rs)
        rs = RadioSetting("voice", "Voice Guide",
                          RadioSettingValueBoolean(_settings.voice))
        cfg_grp.append(rs)
        rs = RadioSetting("language", "Language",
                          RadioSettingValueList(LANGUAGE_LIST,
                                                LANGUAGE_LIST[_settings.
                                                              language]))
        cfg_grp.append(rs)
        rs = RadioSetting("timeout", "Timeout Timer",
                          RadioSettingValueList(
                              TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout]))
        cfg_grp.append(rs)
        rs = RadioSetting("toalarm", "Timeout Alarm",
                          RadioSettingValueInteger(0, 10, _settings.toalarm))
        cfg_grp.append(rs)
        rs = RadioSetting("roger_beep", "Roger Beep",
                          RadioSettingValueList(ROGER_LIST, 
                                                ROGER_LIST[_settings.roger_beep]))
        cfg_grp.append(rs)
        rs = RadioSetting("power_save", "Power save",
                          RadioSettingValueBoolean(_settings.power_save))
        cfg_grp.append(rs)
        rs = RadioSetting("autolock", "Autolock",
                          RadioSettingValueBoolean(_settings.autolock))
        cfg_grp.append(rs)
        rs = RadioSetting("keylock", "Keypad Lock",
                          RadioSettingValueBoolean(_settings.keylock))
        cfg_grp.append(rs)
        rs = RadioSetting("beep", "Keypad Beep",
                          RadioSettingValueBoolean(_settings.beep))
        cfg_grp.append(rs)
        rs = RadioSetting("stopwatch", "Stopwatch",
                          RadioSettingValueBoolean(_settings.stopwatch))
        cfg_grp.append(rs)
        rs = RadioSetting("backlight", "Backlight",
                          RadioSettingValueList(BACKLIGHT_LIST,
                                                BACKLIGHT_LIST[_settings.
                                                               backlight]))
        cfg_grp.append(rs)
        rs = RadioSetting("dtmf_st", "DTMF Sidetone",
                          RadioSettingValueList(DTMFST_LIST,
                                                DTMFST_LIST[_settings.
                                                            dtmf_st]))
        cfg_grp.append(rs)
        rs = RadioSetting("ani_sw", "ANI-ID Switch",
                          RadioSettingValueBoolean(_settings.ani_sw))
        cfg_grp.append(rs)
        rs = RadioSetting("ptt_id", "PTT-ID Delay",
                          RadioSettingValueList(PTTID_LIST,
                                                PTTID_LIST[_settings.ptt_id]))
        cfg_grp.append(rs)
        rs = RadioSetting("ring_time", "Ring Time",
                          RadioSettingValueList(LIST_10,
                                                LIST_10[_settings.ring_time]))
        cfg_grp.append(rs)
        rs = RadioSetting("scan_rev", "Scan Mode",
                          RadioSettingValueList(SCANMODE_LIST,
                                                SCANMODE_LIST[_settings.
                                                              scan_rev]))
        cfg_grp.append(rs)
        rs = RadioSetting("vox", "VOX",
                          RadioSettingValueList(LIST_10,
                                                LIST_10[_settings.vox]))
        cfg_grp.append(rs)
        rs = RadioSetting("prich_sw", "Priority Channel Switch",
                          RadioSettingValueBoolean(_settings.prich_sw))
        cfg_grp.append(rs)
        rs = RadioSetting("pri_ch", "Priority Channel",
                          RadioSettingValueInteger(1, 999, _settings.pri_ch))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_mode", "Radio Mode",
                          RadioSettingValueList(RPTMODE_LIST,
                                                RPTMODE_LIST[_settings.
                                                             rpt_mode]))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_set", "Repeater Setting",
                          RadioSettingValueList(RPTSET_LIST,
                                                RPTSET_LIST[_settings.
                                                            rpt_set]))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_spk", "Repeater Mode Speaker",
                          RadioSettingValueBoolean(_settings.rpt_spk))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_ptt", "Repeater PTT",
                          RadioSettingValueBoolean(_settings.rpt_ptt))
        cfg_grp.append(rs)
        rs = RadioSetting("dtmf_tx_time", "DTMF Tx Duration",
                          RadioSettingValueList(DTMF_TIMES,
                                                DTMF_TIMES[_settings.
                                                           dtmf_tx_time]))
        cfg_grp.append(rs)
        rs = RadioSetting("dtmf_interval", "DTMF Interval",
                          RadioSettingValueList(DTMF_TIMES,
                                                DTMF_TIMES[_settings.
                                                           dtmf_interval]))
        cfg_grp.append(rs)
        rs = RadioSetting("alert", "Alert Tone",
                          RadioSettingValueList(ALERTS_LIST,
                                                ALERTS_LIST[_settings.alert]))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_tone", "Repeater Tone",
                          RadioSettingValueBoolean(_settings.rpt_tone))
        cfg_grp.append(rs)
        rs = RadioSetting("rpt_hold", "Repeater Hold Time",
                          RadioSettingValueList(HOLD_TIMES,
                                                HOLD_TIMES[_settings.
                                                           rpt_hold]))
        cfg_grp.append(rs)
        rs = RadioSetting("scan_det", "Scan DET",
                          RadioSettingValueBoolean(_settings.scan_det))
        cfg_grp.append(rs)
        rs = RadioSetting("sc_qt", "SC-QT",
                          RadioSettingValueList(SCQT_LIST,
                                                SCQT_LIST[_settings.sc_qt]))
        cfg_grp.append(rs)
        rs = RadioSetting("smuteset", "SubFreq Mute",
                          RadioSettingValueList(SMUTESET_LIST,
                                                SMUTESET_LIST[_settings.
                                                              smuteset]))
        cfg_grp.append(rs)
        
		#
        # VFO A Settings
        #
        rs = RadioSetting("workmode_a", "VFO A Workmode",
                          RadioSettingValueList(WORKMODE_LIST, WORKMODE_LIST[_settings.workmode_a]))
        vfoa_grp.append(rs)
        rs = RadioSetting("work_cha", "VFO A Channel",
                          RadioSettingValueInteger(1, 999, _settings.work_cha))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.rxfreq", "VFO A Rx Frequency",
                          RadioSettingValueInteger(
                              134000000, 520000000, _vfoa.rxfreq * 10, 5000))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.txoffset", "VFO A Tx Offset",
                          RadioSettingValueInteger(
                              0, 520000000, _vfoa.txoffset * 10, 5000))
        vfoa_grp.append(rs)
        #   u16   rxtone;
        #   u16   txtone;
        rs = RadioSetting("vfoa.power", "VFO A Power",
                          RadioSettingValueList(
                              POWER_LIST, POWER_LIST[_vfoa.power]))
        vfoa_grp.append(rs)
        #         shift_dir:2
        rs = RadioSetting("vfoa.iswide", "VFO A NBFM",
                          RadioSettingValueList(
                              BANDWIDTH_LIST, BANDWIDTH_LIST[_vfoa.iswide]))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.mute_mode", "VFO A Mute",
                          RadioSettingValueList(
                              SPMUTE_LIST, SPMUTE_LIST[_vfoa.mute_mode]))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.step", "VFO A Step (kHz)",
                          RadioSettingValueList(
                              STEP_LIST, STEP_LIST[_vfoa.step]))
        vfoa_grp.append(rs)
        rs = RadioSetting("vfoa.squelch", "VFO A Squelch",
                          RadioSettingValueList(
                              LIST_10, LIST_10[_vfoa.squelch]))
        vfoa_grp.append(rs)
        rs = RadioSetting("bcl_a", "Busy Channel Lock-out A",
                          RadioSettingValueBoolean(_settings.bcl_a))
        vfoa_grp.append(rs)
        
		#
        # VFO B Settings
        #
        rs = RadioSetting("workmode_b", "VFO B Workmode",
                          RadioSettingValueList(WORKMODE_LIST, WORKMODE_LIST[_settings.workmode_b]))
        vfob_grp.append(rs)
        rs = RadioSetting("work_chb", "VFO B Channel",
                          RadioSettingValueInteger(1, 999, _settings.work_chb))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.rxfreq", "VFO B Rx Frequency",
                          RadioSettingValueInteger(
                              134000000, 520000000, _vfob.rxfreq * 10, 5000))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.txoffset", "VFO B Tx Offset",
                          RadioSettingValueInteger(
                              0, 520000000, _vfob.txoffset * 10, 5000))
        vfob_grp.append(rs)
        #   u16   rxtone;
        #   u16   txtone;
        rs = RadioSetting("vfob.power", "VFO B Power",
                          RadioSettingValueList(
                              POWER_LIST, POWER_LIST[_vfob.power]))
        vfob_grp.append(rs)
        #         shift_dir:2
        rs = RadioSetting("vfob.iswide", "VFO B NBFM",
                          RadioSettingValueList(
                              BANDWIDTH_LIST, BANDWIDTH_LIST[_vfob.iswide]))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.mute_mode", "VFO B Mute",
                          RadioSettingValueList(
                              SPMUTE_LIST, SPMUTE_LIST[_vfob.mute_mode]))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.step", "VFO B Step (kHz)",
                          RadioSettingValueList(
                              STEP_LIST, STEP_LIST[_vfob.step]))
        vfob_grp.append(rs)
        rs = RadioSetting("vfob.squelch", "VFO B Squelch",
                          RadioSettingValueList(
                              LIST_10, LIST_10[_vfob.squelch]))
        vfob_grp.append(rs)
        rs = RadioSetting("bcl_b", "Busy Channel Lock-out B",
                          RadioSettingValueBoolean(_settings.bcl_b))
        vfob_grp.append(rs)
        
		#
        # Key Settings
        #
        _msg = str(_settings.dispstr).split("\0")[0]
        val = RadioSettingValueString(0, 15, _msg)
        val.set_mutable(True)
        rs = RadioSetting("dispstr", "Display Message", val)
        key_grp.append(rs)

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

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

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

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

        def do_nothing(setting, obj):
            return

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

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

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

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

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

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

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

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

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

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

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

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

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

        def do_nothing(setting, obj):
            return

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

        return group
Exemple #26
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        autodial = RadioSettingGroup("autodial", "AutoDial")
        keymaps = RadioSettingGroup("keymaps", "KeyMaps")
        top = RadioSettingGroup("top", "All Settings", basic, keymaps,
                                autodial)

        rs = RadioSetting("beep", "Beep",
                          RadioSettingValueBoolean(_settings.beep))
        basic.append(rs)
        rs = RadioSetting("lock", "Lock",
                          RadioSettingValueBoolean(_settings.lock))
        basic.append(rs)
        rs = RadioSetting("ars", "Auto Repeater Shift",
                          RadioSettingValueBoolean(_settings.ars))
        basic.append(rs)
        rs = RadioSetting("txpwrsave", "TX Power Save",
                          RadioSettingValueBoolean(_settings.txpwrsave))
        basic.append(rs)
        rs = RadioSetting("txnarrow", "TX Narrow",
                          RadioSettingValueBoolean(_settings.txnarrow))
        basic.append(rs)
        options = ["Off", "S-3", "S-5", "S-Full"]
        rs = RadioSetting(
            "rfsqlvl", "RF Squelch Level",
            RadioSettingValueList(options, options[_settings.rfsqlvl]))
        basic.append(rs)
        options = ["Off", "Band A", "Band B", "Both"]
        rs = RadioSetting(
            "pttlock", "PTT Lock",
            RadioSettingValueList(options, options[_settings.pttlock]))
        basic.append(rs)

        rs = RadioSetting("cwid_en", "CWID Enable",
                          RadioSettingValueBoolean(_settings.cwid_en))
        basic.append(rs)

        cwid = RadioSettingValueString(0, 7, self._decode_cwid(_settings.cwid))
        cwid.set_charset(FT90_CWID_CHARS)
        rs = RadioSetting("cwid", "CWID", cwid)
        basic.append(rs)

        options = ["OFF"] + map(str, range(1, 12 + 1))
        rs = RadioSetting(
            "apo", "APO time (hrs)",
            RadioSettingValueList(options, options[_settings.apo]))
        basic.append(rs)

        options = ["Off"] + map(str, range(1, 60 + 1))
        rs = RadioSetting(
            "tot", "Time Out Timer (mins)",
            RadioSettingValueList(options, options[_settings.tot]))
        basic.append(rs)

        options = ["off", "Auto/TX", "Auto", "TX"]
        rs = RadioSetting(
            "fancontrol", "Fan Control",
            RadioSettingValueList(options, options[_settings.fancontrol]))
        basic.append(rs)

        keyopts = [
            "Scan Up", "Scan Down", "Repeater", "Reverse", "Tone Burst",
            "Tx Power", "Home Ch", "VFO/MR", "Tone", "Priority"
        ]
        rs = RadioSetting(
            "key_lt", "Left Key",
            RadioSettingValueList(keyopts, keyopts[_settings.key_lt]))
        keymaps.append(rs)
        rs = RadioSetting(
            "key_rt", "Right Key",
            RadioSettingValueList(keyopts, keyopts[_settings.key_rt]))
        keymaps.append(rs)
        rs = RadioSetting(
            "key_p1", "P1 Key",
            RadioSettingValueList(keyopts, keyopts[_settings.key_p1]))
        keymaps.append(rs)
        rs = RadioSetting(
            "key_p2", "P2 Key",
            RadioSettingValueList(keyopts, keyopts[_settings.key_p2]))
        keymaps.append(rs)
        rs = RadioSetting(
            "key_acc", "ACC Key",
            RadioSettingValueList(keyopts, keyopts[_settings.key_acc]))
        keymaps.append(rs)

        options = map(str, range(0, 12 + 1))
        rs = RadioSetting(
            "lcdcontrast", "LCD Contrast",
            RadioSettingValueList(options, options[_settings.lcdcontrast]))
        basic.append(rs)

        options = ["off", "d4", "d3", "d2", "d1"]
        rs = RadioSetting(
            "dimmer", "Dimmer",
            RadioSettingValueList(options, options[_settings.dimmer]))
        basic.append(rs)

        options = ["TRX Normal", "RX Reverse", "TX Reverse", "TRX Reverse"]
        rs = RadioSetting(
            "dcsmode", "DCS Mode",
            RadioSettingValueList(options, options[_settings.dcsmode]))
        basic.append(rs)

        options = ["50 ms", "100 ms"]
        rs = RadioSetting(
            "dtmfspeed", "DTMF Speed",
            RadioSettingValueList(options, options[_settings.dtmfspeed]))
        autodial.append(rs)

        options = ["50 ms", "250 ms", "450 ms", "750 ms", "1 sec"]
        rs = RadioSetting(
            "dtmftxdelay", "DTMF TX Delay",
            RadioSettingValueList(options, options[_settings.dtmftxdelay]))
        autodial.append(rs)

        options = map(str, range(1, 8 + 1))
        rs = RadioSetting(
            "dtmf_active", "DTMF Active",
            RadioSettingValueList(options, options[_settings.dtmf_active]))
        autodial.append(rs)

        # setup 8 dtmf autodial entries
        for i in map(str, range(1, 9)):
            objname = "dtmf" + i
            dtmfsetting = getattr(_settings, objname)
            dtmflen = getattr(_settings, objname + "_len")
            dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
            dtmf = RadioSettingValueString(0, 16, dtmfstr)
            dtmf.set_charset(FT90_DTMF_CHARS + list(" "))
            rs = RadioSetting(objname, objname.upper(), dtmf)
            autodial.append(rs)

        return top
Exemple #27
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")

        group = RadioSettings(basic)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return group
Exemple #28
0
    def get_settings(self):
        _settings = self._memobj.settings

        repeater = RadioSettingGroup("repeater", "Repeater Settings")
        ctcss = RadioSettingGroup("ctcss", "CTCSS/DCS/DTMF Settings")
        arts = RadioSettingGroup("arts", "ARTS Settings")
        scan = RadioSettingGroup("scan", "Scan Settings")
        power = RadioSettingGroup("power", "Power Saver Settings")
        wires = RadioSettingGroup("wires", "WiRES(tm) Settings")
        eai = RadioSettingGroup("eai", "EAI/EPCS Settings")
        switch = RadioSettingGroup("switch", "Switch/Knob Settings")
        misc = RadioSettingGroup("misc", "Miscellaneous Settings")
        mbls = RadioSettingGroup("banks", "Memory Bank Link Scan")

        setmode = RadioSettings(repeater, ctcss, arts, scan, power,
                                wires, eai, switch, misc, mbls)

        # APO
        opts = ["OFF"] + ["%0.1f" % (x * 0.5) for x in range(1, 24+1)]
        misc.append(
            RadioSetting(
                "apo", "Automatic Power Off",
                RadioSettingValueList(opts, opts[_settings.apo])))

        # AR.BEP
        opts = ["OFF", "INRANG", "ALWAYS"]
        arts.append(
            RadioSetting(
                "ar_bep", "ARTS Beep",
                RadioSettingValueList(opts, opts[_settings.ar_bep])))

        # AR.INT
        opts = ["25 SEC", "15 SEC"]
        arts.append(
            RadioSetting(
                "ar_int", "ARTS Polling Interval",
                RadioSettingValueList(opts, opts[_settings.ar_int])))

        # ARS
        opts = ["OFF", "ON"]
        repeater.append(
            RadioSetting(
                "ars", "Automatic Repeater Shift",
                RadioSettingValueList(opts, opts[_settings.ars])))

        # BCLO
        opts = ["OFF", "ON"]
        misc.append(RadioSetting(
                "bclo", "Busy Channel Lock-Out",
                RadioSettingValueList(opts, opts[_settings.bclo])))

        # BEEP
        opts = ["OFF", "KEY", "KEY+SC"]
        rs = RadioSetting(
                "beep_key", "Enable the Beeper",
                RadioSettingValueList(
                    opts, opts[_settings.beep_key + _settings.beep_sc]))

        def apply_beep(s, obj):
            setattr(obj, "beep_key",
                    (int(s.value) & 1) or ((int(s.value) >> 1) & 1))
            setattr(obj, "beep_sc", (int(s.value) >> 1) & 1)
        rs.set_apply_callback(apply_beep, self._memobj.settings)
        switch.append(rs)

        # BELL
        opts = ["OFF", "1T", "3T", "5T", "8T", "CONT"]
        ctcss.append(RadioSetting("bell", "Bell Repetitions",
                     RadioSettingValueList(opts, opts[_settings.bell])))

        # BSY.LED
        opts = ["ON", "OFF"]
        misc.append(RadioSetting("bsy_led", "Busy LED",
                    RadioSettingValueList(opts, opts[_settings.bsy_led])))

        # DCS.NR
        opts = ["TR/X N", "RX R", "TX R", "T/RX R"]
        ctcss.append(RadioSetting("dcs_nr", "\"Inverted\" DCS Code Decoding",
                     RadioSettingValueList(opts, opts[_settings.dcs_nr])))

        # DT.DLY
        opts = ["50 MS", "100 MS", "250 MS", "450 MS", "750 MS", "1000 MS"]
        ctcss.append(RadioSetting("dt_dly", "DTMF Autodialer Delay Time",
                     RadioSettingValueList(opts, opts[_settings.dt_dly])))

        # DT.SPD
        opts = ["50 MS", "100 MS"]
        ctcss.append(RadioSetting("dt_spd", "DTMF Autodialer Sending Speed",
                     RadioSettingValueList(opts, opts[_settings.dt_spd])))

        # DT.WRT
        for i in range(0, 9):
            dtmf = self._memobj.dtmf[i]
            str = ""
            for c in dtmf.memory:
                if c == 0xFF:
                    break
                if c < len(DTMF_CHARS):
                    str += DTMF_CHARS[c]
            val = RadioSettingValueString(0, 16, str, False)
            val.set_charset(DTMF_CHARS + list("abcd"))
            rs = RadioSetting("dtmf_%i" % i, 
                        "DTMF Autodialer Memory %i" % (i + 1), val)
            def apply_dtmf(s, obj):
                str = s.value.get_value().upper().rstrip()
                val = [DTMF_CHARS.index(x) for x in str]
                for x in range(len(val), 16):
                    val.append(0xFF)
                obj.memory = val
            rs.set_apply_callback(apply_dtmf, dtmf)
            ctcss.append(rs)

        # EDG.BEP
        opts = ["OFF", "ON"]
        misc.append(RadioSetting("edg_bep", "Band Edge Beeper",
                    RadioSettingValueList(opts, opts[_settings.edg_bep])))

        # I.NET
        opts = ["OFF", "COD", "MEM"]
        rs = RadioSetting("inet", "Internet Link Connection",
                          RadioSettingValueList(
                              opts, opts[_settings.inet - 1]))

        def apply_inet(s, obj):
            setattr(obj, s.get_name(), int(s.value) + 1)
        rs.set_apply_callback(apply_inet, self._memobj.settings)
        wires.append(rs)

        # INT.CD
        opts = ["CODE 0", "CODE 1", "CODE 2", "CODE 3", "CODE 4",
                "CODE 5", "CODE 6", "CODE 7", "CODE 8", "CODE 9",
                "CODE A", "CODE B", "CODE C", "CODE D", "CODE E", "CODE F"]
        wires.append(RadioSetting("int_cd", "Access Number for WiRES(TM)",
                     RadioSettingValueList(opts, opts[_settings.int_cd])))

        # INT.MR
        opts = ["d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9"]
        wires.append(RadioSetting(
                    "int_mr", "Access Number (DTMF) for Non-WiRES(TM)",
                     RadioSettingValueList(opts, opts[_settings.int_mr])))

        # LAMP
        opts = ["KEY", "5SEC", "TOGGLE"]
        switch.append(RadioSetting("lamp", "Lamp Mode",
                      RadioSettingValueList(opts, opts[_settings.lamp])))

        # LOCK
        opts = ["LK KEY", "LKDIAL", "LK K+D", "LK PTT",
                "LP P+K", "LK P+D", "LK ALL"]
        rs = RadioSetting("lock", "Control Locking",
                          RadioSettingValueList(
                              opts, opts[_settings.lock - 1]))

        def apply_lock(s, obj):
            setattr(obj, s.get_name(), int(s.value) + 1)
        rs.set_apply_callback(apply_lock, self._memobj.settings)
        switch.append(rs)

        # M/T-CL
        opts = ["MONI", "T-CALL"]
        switch.append(RadioSetting("mt_cl", "MONI Switch Function",
                      RadioSettingValueList(opts, opts[_settings.mt_cl])))

        # PAG.ABK
        opts = ["OFF", "ON"]
        eai.append(RadioSetting("pag_abk", "Paging Answer Back",
                   RadioSettingValueList(opts, opts[_settings.pag_abk])))

        # RESUME
        opts = ["TIME", "HOLD", "BUSY"]
        scan.append(RadioSetting("resume", "Scan Resume Mode",
                    RadioSettingValueList(opts, opts[_settings.resume])))

        # REV/HM
        opts = ["REV", "HOME"]
        switch.append(RadioSetting("rev_hm", "HM/RV Key Function",
                      RadioSettingValueList(opts, opts[_settings.rev_hm])))

        # RF.SQL
        opts = ["OFF", "S-1", "S-2", "S-3", "S-4", "S-5", "S-6",
                "S-7", "S-8", "S-FULL"]
        misc.append(RadioSetting("rf_sql", "RF Squelch Threshold",
                    RadioSettingValueList(opts, opts[_settings.rf_sql])))

        # PRI.RVT
        opts = ["OFF", "ON"]
        scan.append(RadioSetting("pri_rvt", "Priority Revert",
                    RadioSettingValueList(opts, opts[_settings.pri_rvt])))

        # RXSAVE
        opts = ["OFF", "200 MS", "300 MS", "500 MS", "1 S", "2 S"]
        power.append(RadioSetting(
                    "rxsave", "Receive Mode Batery Savery Interval",
                     RadioSettingValueList(opts, opts[_settings.rxsave])))

        # S.SRCH
        opts = ["SINGLE", "CONT"]
        misc.append(RadioSetting("ssrch", "Smart Search Sweep Mode",
                    RadioSettingValueList(opts, opts[_settings.ssrch])))

        # SCN.MD
        opts = ["MEM", "ONLY"]
        scan.append(RadioSetting(
                    "scn_md", "Memory Scan Channel Selection Mode",
                    RadioSettingValueList(opts, opts[_settings.scn_md])))

        # SCN.LMP
        opts = ["OFF", "ON"]
        scan.append(RadioSetting("scn_lmp", "Scan Lamp",
                    RadioSettingValueList(opts, opts[_settings.scn_lmp])))

        # TOT
        opts = ["OFF"] + ["%dMIN" % (x) for x in range(1, 30+1)]
        misc.append(RadioSetting("tot", "Timeout Timer",
                    RadioSettingValueList(opts, opts[_settings.tot])))

        # TX.LED
        opts = ["ON", "OFF"]
        misc.append(RadioSetting("tx_led", "TX LED",
                    RadioSettingValueList(opts, opts[_settings.tx_led])))

        # TXSAVE
        opts = ["OFF", "ON"]
        power.append(RadioSetting("txsave", "Transmitter Battery Saver",
                     RadioSettingValueList(opts, opts[_settings.txsave])))

        # VFO.BND
        opts = ["BAND", "ALL"]
        misc.append(RadioSetting("vfo_bnd", "VFO Band Edge Limiting",
                    RadioSettingValueList(opts, opts[_settings.vfo_bnd])))

        # WX.ALT
        opts = ["OFF", "ON"]
        scan.append(RadioSetting("wx_alt", "Weather Alert Scan",
                    RadioSettingValueList(opts, opts[_settings.wx_alt])))

        # MBS
        for i in range(0, 10):
            opts = ["OFF", "ON"]
            mbs = (self._memobj.mbs >> i) & 1
            rs = RadioSetting("mbs%i" % i, "Bank %s Scan" % (i + 1),
                              RadioSettingValueList(opts, opts[mbs]))

            def apply_mbs(s, index):
                if int(s.value):
                    self._memobj.mbs |= (1 << index)
                else:
                    self._memobj.mbs &= ~(1 << index)
            rs.set_apply_callback(apply_mbs, i)
            mbls.append(rs)

        return setmode
Exemple #29
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
Exemple #30
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        cw = RadioSettingGroup("cw", "CW")
        packet = RadioSettingGroup("packet", "Digital & packet")
        panel = RadioSettingGroup("panel", "Panel settings")
        extended = RadioSettingGroup("extended", "Extended")
        panelcontr = RadioSettingGroup("panelcontr", "Panel controls")
        top = RadioSettingGroup("top", "All Settings", basic, cw, packet,
                                panelcontr, panel, extended)

        rs = RadioSetting("extended_menu", "Extended menu",
                          RadioSettingValueBoolean(_settings.extended_menu))
        extended.append(rs)
        rs = RadioSetting("ars_144", "144MHz ARS",
                          RadioSettingValueBoolean(_settings.ars_144))
        basic.append(rs)
        rs = RadioSetting("ars_430", "430MHz ARS",
                          RadioSettingValueBoolean(_settings.ars_430))
        basic.append(rs)
        options = ["enable", "disable"]
        rs = RadioSetting("disable_amfm_dial", "AM&FM Dial",
                          RadioSettingValueList(options,
                                        options[_settings.disable_amfm_dial]))
        panel.append(rs)
        rs = RadioSetting("am_mic", "AM mic gain",
                          RadioSettingValueInteger(0, 100, _settings.am_mic))
        basic.append(rs)
        options = ["OFF", "1h", "2h", "3h", "4h", "5h", "6h"]
        rs = RadioSetting("apo_time", "APO time",
                          RadioSettingValueList(options,
                                        options[_settings.apo_time]))
        basic.append(rs)
        options = ["OFF", "Range", "All"]
        rs = RadioSetting("arts_beep", "ARTS beep",
                          RadioSettingValueList(options,
                                        options[_settings.arts_beep]))
        basic.append(rs)
        rs = RadioSetting("arts_id", "ARTS ID",
                          RadioSettingValueBoolean(_settings.arts_id))
        extended.append(rs)
        s = RadioSettingValueString(0, 10, 
                            ''.join([self._CALLSIGN_CHARSET[x] for x in 
                                        self._memobj.arts_idw]))
        s.set_charset(self._CALLSIGN_CHARSET)
        rs = RadioSetting("arts_idw", "ARTS IDW", s)
        extended.append(rs)
        s = RadioSettingValueString(0, 40, 
                            ''.join([self._BEACON_CHARSET[x] for x in 
                                        self._memobj.beacon_text1]))
        s.set_charset(self._BEACON_CHARSET)
        rs = RadioSetting("beacon_text1", "Beacon text1", s)
        extended.append(rs)
        s = RadioSettingValueString(0, 40, 
                            ''.join([self._BEACON_CHARSET[x] for x in 
                                        self._memobj.beacon_text2]))
        s.set_charset(self._BEACON_CHARSET)
        rs = RadioSetting("beacon_text2", "Beacon text2", s)
        extended.append(rs)
        s = RadioSettingValueString(0, 40, 
                            ''.join([self._BEACON_CHARSET[x] for x in 
                                        self._memobj.beacon_text3]))
        s.set_charset(self._BEACON_CHARSET)
        rs = RadioSetting("beacon_text3", "Beacon text3", s)
        extended.append(rs)
        options = ["OFF"]+["%i sec" % i for i in range(1,256)]
        rs = RadioSetting("beacon_time", "Beacon time",
                          RadioSettingValueList(options,
                                        options[_settings.beacon_time]))
        extended.append(rs)
        options = ["440Hz", "880Hz", "1760Hz"]
        rs = RadioSetting("beep_tone", "Beep tone",
                          RadioSettingValueList(options,
                                        options[_settings.beep_tone]))
        panel.append(rs)
        rs = RadioSetting("beep_vol", "Beep volume",
                          RadioSettingValueInteger(0, 100, _settings.beep_vol))
        panel.append(rs)
        rs = RadioSetting("r_lsb_car", "LSB Rx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30, _settings.r_lsb_car))
        extended.append(rs)
        rs = RadioSetting("r_usb_car", "USB Rx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30, _settings.r_usb_car))
        extended.append(rs)
        rs = RadioSetting("t_lsb_car", "LSB Tx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30, _settings.t_lsb_car))
        extended.append(rs)
        rs = RadioSetting("t_usb_car", "USB Tx carrier point (*10 Hz)",
                          RadioSettingValueInteger(-30, 30, _settings.t_usb_car))
        extended.append(rs)
        options = ["4800", "9600", "38400"]
        rs = RadioSetting("cat_rate", "CAT rate",
                          RadioSettingValueList(options,
                                        options[_settings.cat_rate]))
        basic.append(rs)
        options = ["CAT", "Linear", "Tuner"]
        rs = RadioSetting("cat_lin_tun", "CAT/LIN/TUN selection",
                          RadioSettingValueList(options,
                                        options[_settings.cat_lin_tun]))
        extended.append(rs)
        options = ["MAIN", "VFO/MEM", "CLAR"]   # TODO test the 3 options on non D radio
                                                # which have only SEL and MAIN
        rs = RadioSetting("clar_dial_sel", "Clarifier dial selection",
                          RadioSettingValueList(options,
                                        options[_settings.clar_dial_sel]))
        panel.append(rs)
        rs = RadioSetting("cw_auto_mode", "CW Automatic mode",
                          RadioSettingValueBoolean(_settings.cw_auto_mode))
        cw.append(rs)
        options = ["USB", "LSB", "AUTO"]
        rs = RadioSetting("cw_bfo", "CW BFO",
                          RadioSettingValueList(options,
                                        options[_settings.cw_bfo]))
        cw.append(rs)
        options = ["FULL"]+["%i ms" % (i*10) for i in range(3,301)]
        val = (_settings.cw_delay + _settings.cw_delay_hi * 256) - 2
        rs = RadioSetting("cw_delay", "CW delay",
                          RadioSettingValueList(options,
                                        options[val]))
        cw.append(rs)
        options = ["Normal", "Reverse"]
        rs = RadioSetting("cw_key_rev", "CW key reverse",
                          RadioSettingValueList(options,
                                        options[_settings.cw_key_rev]))
        cw.append(rs)
        rs = RadioSetting("cw_paddle", "CW paddle",
                          RadioSettingValueBoolean(_settings.cw_paddle))
        cw.append(rs)
        options = ["%i Hz" % i for i in range(400,801,100)]
        rs = RadioSetting("cw_pitch", "CW pitch",
                          RadioSettingValueList(options,
                                        options[_settings.cw_pitch]))
        cw.append(rs)
        options = ["%i ms" % i for i in range(5,31,5)]
        rs = RadioSetting("cw_qsk", "CW QSK",
                          RadioSettingValueList(options,
                                        options[_settings.cw_qsk]))
        cw.append(rs)
        rs = RadioSetting("cw_sidetone", "CW sidetone volume",
                          RadioSettingValueInteger(0, 100, _settings.cw_sidetone))
        cw.append(rs)
        options = ["%i wpm" % i for i in range(4,61)]
        rs = RadioSetting("cw_speed", "CW speed",
                          RadioSettingValueList(options,
                                        options[_settings.cw_speed]))
        cw.append(rs)
        options = ["Numeric", "Alphabet", "AlphaNumeric"]
        rs = RadioSetting("cw_training", "CW trainig",
                          RadioSettingValueList(options,
                                        options[_settings.cw_training]))
        cw.append(rs)
        options = ["1:%1.1f" % (i/10) for i in range(25,46,1)]
        rs = RadioSetting("cw_weight", "CW weight",
                          RadioSettingValueList(options,
                                        options[_settings.cw_weight]))
        cw.append(rs)
        options = ["Tn-Rn", "Tn-Riv", "Tiv-Rn", "Tiv-Riv"]
        rs = RadioSetting("dcs_inv", "DCS inv",
                          RadioSettingValueList(options,
                                        options[_settings.dcs_inv]))
        extended.append(rs)
        options = ["Fine", "Coarse"]
        rs = RadioSetting("dial_step", "Dial step",
                          RadioSettingValueList(options,
                                        options[_settings.dial_step]))
        panel.append(rs)
        rs = RadioSetting("dig_disp", "Dig disp (*10 Hz)",
                          RadioSettingValueInteger(-300, 300, _settings.dig_disp))
        packet.append(rs)
        rs = RadioSetting("dig_mic", "Dig gain",
                          RadioSettingValueInteger(0, 100, _settings.dig_mic))
        packet.append(rs)
        options = ["RTTYL", "RTTYU", "PSK31-L", "PSK31-U", "USER-L", "USER-U"]
        rs = RadioSetting("dig_mode", "Dig mode",
                          RadioSettingValueList(options,
                                        options[_settings.dig_mode]))
        packet.append(rs)
        rs = RadioSetting("dig_shift", "Dig shift (*10 Hz)",
                          RadioSettingValueInteger(-300, 300, _settings.dig_shift))
        packet.append(rs)
        rs = RadioSetting("dig_vox", "Dig vox",
                          RadioSettingValueInteger(0, 100, _settings.dig_vox))
        packet.append(rs)
        options = ["ARTS", "BAND", "FIX", "MEMGRP", "MODE", "MTR", "VFO"]
        rs = RadioSetting("disp_color", "Display color mode",
                          RadioSettingValueList(options,
                                        options[_settings.disp_color]))
        panel.append(rs)
        rs = RadioSetting("disp_color_arts", "Display color ARTS set",
                          RadioSettingValueInteger(0, 1,_settings.disp_color_arts))
        panel.append(rs)
        rs = RadioSetting("disp_color_band", "Display color band set",
                          RadioSettingValueInteger(0, 1,_settings.disp_color_band))
        panel.append(rs)
        rs = RadioSetting("disp_color_memgrp", "Display color memory group set",
                          RadioSettingValueInteger(0, 1,_settings.disp_color_memgrp))
        panel.append(rs)
        rs = RadioSetting("disp_color_mode", "Display color mode set",
                          RadioSettingValueInteger(0, 1,_settings.disp_color_mode))
        panel.append(rs)
        rs = RadioSetting("disp_color_mtr", "Display color meter set",
                          RadioSettingValueInteger(0, 1,_settings.disp_color_mtr))
        panel.append(rs)
        rs = RadioSetting("disp_color_vfo", "Display color VFO set",
                          RadioSettingValueInteger(0, 1,_settings.disp_color_vfo))
        panel.append(rs)
        rs = RadioSetting("disp_color_fix", "Display color fix set",
                          RadioSettingValueInteger(1, 32,_settings.disp_color_fix+1)) 
        panel.append(rs)
        rs = RadioSetting("disp_contrast", "Contrast",
                          RadioSettingValueInteger(3, 15,_settings.disp_contrast+2))
        panel.append(rs)
        rs = RadioSetting("disp_intensity", "Intensity",
                          RadioSettingValueInteger(1, 3,_settings.disp_intensity))
        panel.append(rs)
        options = ["OFF", "Auto1", "Auto2", "ON"]
        rs = RadioSetting("disp_mode", "Display backlight mode",
                          RadioSettingValueList(options,
                                        options[_settings.disp_mode]))
        panel.append(rs)
        options = ["60Hz", "120Hz", "240Hz"]
        rs = RadioSetting("dsp_bpf", "Dsp band pass filter",
                          RadioSettingValueList(options,
                                        options[_settings.dsp_bpf]))
        cw.append(rs)
        options = ["100Hz", "160Hz", "220Hz", "280Hz", "340Hz", "400Hz", "460Hz", "520Hz",
            "580Hz", "640Hz", "720Hz", "760Hz", "820Hz", "880Hz", "940Hz", "1000Hz"]
        rs = RadioSetting("dsp_hpf", "Dsp hi pass filter cut off",
                          RadioSettingValueList(options,
                                        options[_settings.dsp_hpf]))
        basic.append(rs)
        options = ["1000Hz", "1160Hz", "1320Hz", "1480Hz", "1650Hz", "1800Hz", "1970Hz", "2130Hz",
            "2290Hz", "2450Hz", "2610Hz", "2770Hz", "2940Hz", "3100Hz", "3260Hz", "3420Hz",
            "3580Hz", "3740Hz", "3900Hz", "4060Hz", "4230Hz", "4390Hz", "4550Hz", "4710Hz",
            "4870Hz", "5030Hz", "5190Hz", "5390Hz", "5520Hz", "5680Hz", "5840Hz", "6000Hz"]
        rs = RadioSetting("dsp_lpf", "Dsp low pass filter cut off",
                          RadioSettingValueList(options,
                                        options[_settings.dsp_lpf]))
        basic.append(rs)
        options = ["OFF", "LPF", "HPF", "BOTH"]
        rs = RadioSetting("dsp_mic_eq", "Dsp mic equalization",
                          RadioSettingValueList(options,
                                        options[_settings.dsp_mic_eq]))
        basic.append(rs)
        rs = RadioSetting("dsp_nr", "DSP noise reduction level",
                          RadioSettingValueInteger(1, 16, _settings.dsp_nr+1))
        basic.append(rs)
        # emergency only for US model
        rs = RadioSetting("fm_mic", "FM mic gain",
                          RadioSettingValueInteger(0, 100, _settings.fm_mic))
        basic.append(rs)
        rs = RadioSetting("home_vfo", "Enable HOME to VFO moving",
                          RadioSettingValueBoolean(_settings.home_vfo))
        panel.append(rs)
        options = ["Dial", "Freq", "Panel", "All"]
        rs = RadioSetting("lock_mode", "Lock mode",
                          RadioSettingValueList(options,
                                        options[_settings.lock_mode]))
        panel.append(rs)
        rs = RadioSetting("mem_group", "Mem group",
                          RadioSettingValueBoolean(_settings.mem_group))
        basic.append(rs)
        options = ["CW SIDETONE", "CW SPEED", "MHz/MEM GRP", "MIC GAIN",
            "NB LEVEL", "RF POWER", "STEP"]
        rs = RadioSetting("mem_vfo_dial_mode", "Mem/VFO dial mode",
                          RadioSettingValueList(options,
                                        options[_settings.mem_vfo_dial_mode]))
        panel.append(rs)
        rs = RadioSetting("mic_scan", "Mic scan",
                          RadioSettingValueBoolean(_settings.mic_scan))
        basic.append(rs)
        options = ["NOR", "RMT", "CAT"]
        rs = RadioSetting("mic_sel", "Mic selection",
                          RadioSettingValueList(options,
                                        options[_settings.mic_sel]))
        extended.append(rs)
        options = ["SIG", "CTR", "VLT", "N/A", "FS",  "OFF"]
        rs = RadioSetting("mtr_arx_sel", "Meter receive selection",
                          RadioSettingValueList(options,
                                        options[_settings.mtr_arx_sel]))
        extended.append(rs)
        options = ["PWR", "ALC", "MOD", "SWR", "VLT", "N/A", "OFF"]
        rs = RadioSetting("mtr_atx_sel", "Meter transmit selection",
                          RadioSettingValueList(options,
                                        options[_settings.mtr_atx_sel]))
        extended.append(rs)
        rs = RadioSetting("mtr_peak_hold", "Meter peak hold",
                          RadioSettingValueBoolean(_settings.mtr_peak_hold))
        extended.append(rs)
        rs = RadioSetting("nb_level", "Noise blanking level",
                          RadioSettingValueInteger(0, 100, _settings.nb_level))
        basic.append(rs)
        s = RadioSettingValueString(0, 4, 
                            ''.join([self._CALLSIGN_CHARSET[x] for x in 
                                        self._memobj.op_filter1_name]))
        s.set_charset(self._CALLSIGN_CHARSET)
        rs = RadioSetting("op_filter1_name", "Optional filter1 name", s)
        extended.append(rs)
        s = RadioSettingValueString(0, 4, 
                            ''.join([self._CALLSIGN_CHARSET[x] for x in 
                                        self._memobj.op_filter2_name]))
        s.set_charset(self._CALLSIGN_CHARSET)
        rs = RadioSetting("op_filter2_name", "Optional filter2 name", s)
        extended.append(rs)
        rs = RadioSetting("pg_a", "Programmable key MFq:A",
                          RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                        self.PROGRAMMABLEOPTIONS[_settings.pg_a]))
        extended.append(rs)
        rs = RadioSetting("pg_b", "Programmable key MFq:B",
                          RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                        self.PROGRAMMABLEOPTIONS[_settings.pg_b]))
        extended.append(rs)
        rs = RadioSetting("pg_c", "Programmable key MFq:C",
                          RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                        self.PROGRAMMABLEOPTIONS[_settings.pg_c]))
        extended.append(rs)
        rs = RadioSetting("pg_acc", "Programmable mic key ACC",
                          RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                        self.PROGRAMMABLEOPTIONS[_settings.pg_acc]))
        extended.append(rs)
        rs = RadioSetting("pg_p1", "Programmable mic key P1",
                          RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                        self.PROGRAMMABLEOPTIONS[_settings.pg_p1]))
        extended.append(rs)
        rs = RadioSetting("pg_p2", "Programmable mic key P2",
                          RadioSettingValueList(self.PROGRAMMABLEOPTIONS,
                                        self.PROGRAMMABLEOPTIONS[_settings.pg_p2]))
        extended.append(rs)
        rs = RadioSetting("pkt1200", "Packet 1200 gain level",
                          RadioSettingValueInteger(0, 100, _settings.pkt1200))
        packet.append(rs)
        rs = RadioSetting("pkt9600", "Packet 9600 gain level",
                          RadioSettingValueInteger(0, 100, _settings.pkt9600))
        packet.append(rs)
        options = ["1200", "9600"]
        rs = RadioSetting("pkt_rate", "Packet rate",
                          RadioSettingValueList(options,
                                        options[_settings.pkt_rate]))
        packet.append(rs)
        rs = RadioSetting("proc_level", "Proc level",
                          RadioSettingValueInteger(0, 100, _settings.proc_level))
        basic.append(rs)
        rs = RadioSetting("rf_power_hf", "Rf power set HF",
                          RadioSettingValueInteger(5, 100, _settings.rf_power_hf))
        basic.append(rs)
        rs = RadioSetting("rf_power_6m", "Rf power set 6m",
                          RadioSettingValueInteger(5, 100, _settings.rf_power_6m))
        basic.append(rs)
        rs = RadioSetting("rf_power_vhf", "Rf power set VHF",
                          RadioSettingValueInteger(5, 50, _settings.rf_power_vhf))
        basic.append(rs)
        rs = RadioSetting("rf_power_uhf", "Rf power set UHF",
                          RadioSettingValueInteger(2, 20, _settings.rf_power_uhf))
        basic.append(rs)
        options = ["TIME", "BUSY", "STOP"]
        rs = RadioSetting("scan_mode", "Scan mode",
                          RadioSettingValueList(options,
                                        options[_settings.scan_mode]))
        basic.append(rs)
        rs = RadioSetting("scan_resume", "Scan resume",
                          RadioSettingValueInteger(1, 10, _settings.scan_resume))
        basic.append(rs)
        rs = RadioSetting("split_tone", "Split tone enable",
                          RadioSettingValueBoolean(_settings.split_tone))
        extended.append(rs)
        options = ["RF-Gain", "Squelch"]
        rs = RadioSetting("sql_rf_gain", "Squelch/RF-Gain",
                          RadioSettingValueList(options,
                                        options[_settings.sql_rf_gain]))
        panel.append(rs)
        rs = RadioSetting("ssb_mic", "SSB Mic gain",
                          RadioSettingValueInteger(0, 100, _settings.ssb_mic))
        basic.append(rs)
        options = ["Off"]+["%i" % i for i in range(1, 21)]
        rs = RadioSetting("tot_time", "Time-out timer",
                          RadioSettingValueList(options,
                                        options[_settings.tot_time]))
        basic.append(rs)
        options = ["OFF", "ATAS(HF)", "ATAS(HF&50)", "ATAS(ALL)", "TUNER"]
        rs = RadioSetting("tuner_atas", "Tuner/ATAS device",
                          RadioSettingValueList(options,
                                        options[_settings.tuner_atas]))
        extended.append(rs)
        rs = RadioSetting("tx_if_filter", "Transmit IF filter",
                          RadioSettingValueList(self.FILTERS,
                                        self.FILTERS[_settings.tx_if_filter]))
        basic.append(rs)
        rs = RadioSetting("vox_delay", "VOX delay (*100 ms)",
                          RadioSettingValueInteger(1, 30, _settings.vox_delay))
        basic.append(rs)
        rs = RadioSetting("vox_gain", "VOX Gain",
                          RadioSettingValueInteger(1, 100, _settings.vox_gain))
        basic.append(rs)
        rs = RadioSetting("xvtr_a", "Xvtr A displacement",
                          RadioSettingValueInteger(-4294967295, 4294967295, self._memobj.xvtr_a_offset * (-1 if _settings.xvtr_a_negative else 1)))
        extended.append(rs)
        rs = RadioSetting("xvtr_b", "Xvtr B displacement",
                          RadioSettingValueInteger(-4294967295, 4294967295, self._memobj.xvtr_b_offset * (-1 if _settings.xvtr_b_negative else 1)))
        extended.append(rs)
        options = ["OFF", "XVTR A", "XVTR B"]
        rs = RadioSetting("xvtr_sel", "Transverter function selection",
                          RadioSettingValueList(options,
                                        options[_settings.xvtr_sel]))
        extended.append(rs)
        
        rs = RadioSetting("disp", "Display large",
                          RadioSettingValueBoolean(_settings.disp))
        panel.append(rs)
        rs = RadioSetting("nb", "Noise blanker",
                          RadioSettingValueBoolean(_settings.nb))
        panelcontr.append(rs)
        options = ["Auto", "Fast", "Slow", "Off"]
        rs = RadioSetting("agc", "AGC",
                          RadioSettingValueList(options,
                                        options[_settings.agc]))
        panelcontr.append(rs)
        options = ["PWR", "ALC", "SWR", "MOD"]
        rs = RadioSetting("pwr_meter_mode", "Power meter mode",
                          RadioSettingValueList(options,
                                        options[_settings.pwr_meter_mode]))
        panelcontr.append(rs)
        rs = RadioSetting("vox", "Vox",
                          RadioSettingValueBoolean(_settings.vox))
        panelcontr.append(rs)
        rs = RadioSetting("bk", "Semi break-in",
                          RadioSettingValueBoolean(_settings.bk))
        cw.append(rs)
        rs = RadioSetting("kyr", "Keyer",
                          RadioSettingValueBoolean(_settings.kyr))
        cw.append(rs)
        options = ["enabled", "disabled"]
        rs = RadioSetting("fst", "Fast",
                          RadioSettingValueList(options,
                                        options[_settings.fst]))
        panelcontr.append(rs)
        options = ["enabled", "disabled"]
        rs = RadioSetting("lock", "Lock",
                          RadioSettingValueList(options,
                                        options[_settings.lock]))
        panelcontr.append(rs)
        rs = RadioSetting("scope_peakhold", "Scope max hold",
                          RadioSettingValueBoolean(_settings.scope_peakhold))
        panelcontr.append(rs)
        options = ["21", "31", "127"]
        rs = RadioSetting("scope_width", "Scope width (channels)",
                          RadioSettingValueList(options,
                                        options[_settings.scope_width]))
        panelcontr.append(rs)
        rs = RadioSetting("proc", "Speech processor",
                          RadioSettingValueBoolean(_settings.proc))
        panelcontr.append(rs)
        
        return top
Exemple #31
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")

        group = RadioSettings(basic)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return group
Exemple #32
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
Exemple #33
0
    def get_settings(self):
        """Translate the bit in the mem_struct into settings in the UI"""
        _mem = self._memobj
        basic = RadioSettingGroup("basic", "Basic Settings")
        other = RadioSettingGroup("other", "Other Settings")
        work = RadioSettingGroup("work", "Work Mode Settings")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        top = RadioSettings(basic, other, work, dtmf)

        # Basic

        # Audio: A01-A04

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

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

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

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

        # TX/RX: B01-B08

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

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

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

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

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

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

        # B08 (per channel)

        # Display: C01-C06

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

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

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

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

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

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

        # Memory: D01-D04

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

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

        # D04 (per channel)

        # Scan: E01-E04

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

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

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

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

        # System: F01-F09

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

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

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

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

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

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

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

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

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

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

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

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

        # Timer/Clock: G01-G04

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

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

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

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

        # Signaling: H01-H06

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

        # H02 (per channel)

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

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

        # H04 (per channel)

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

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

        # Pkt: I01-I03

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

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

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

        # Other

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

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

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

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

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

        # Work

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        # dtmf

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

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

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

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

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

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

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

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

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

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

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

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

        # setup 9 dtmf autodial entries
        for i in map(str, range(1, 10)):
            objname = "code" + i
            strname = "Code " + str(i)
            dtmfsetting = getattr(_mem.dtmfcode, objname)
            dtmflen = getattr(_mem.dtmfcode, objname + "_len")
            dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
            code = RadioSettingValueString(0, 16, dtmfstr)
            code.set_charset(DTMF_CHARS + list(" "))
            rs = RadioSetting("dtmfcode." + objname, strname, code)
            dtmf.append(rs)
        return top
Exemple #34
0
Fichier : vx3.py Projet : v0l/chirp
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        sound = RadioSettingGroup("sound", "Sound")
        dtmf = RadioSettingGroup("dtmf", "DTMF")
        arts = RadioSettingGroup("arts", "ARTS")
        eai = RadioSettingGroup("eai", "Emergency")
        msg = RadioSettingGroup("msg", "Messages")

        top = RadioSettings(basic, sound, arts, dtmf, eai, msg)

        basic.append(RadioSetting(
                "att_wx", "Attenuation WX",
                RadioSettingValueBoolean(_settings.att_wx)))

        basic.append(RadioSetting(
                "att_marine", "Attenuation Marine",
                RadioSettingValueBoolean(_settings.att_marine)))

        basic.append(RadioSetting(
                "att_broadcast", "Attenuation Broadcast",
                RadioSettingValueBoolean(_settings.att_broadcast)))

        basic.append(RadioSetting(
                "ars", "Auto Repeater Shift",
                RadioSettingValueBoolean(_settings.ars)))

        basic.append(RadioSetting(
                "home_vfo", "Home->VFO",
                RadioSettingValueBoolean(_settings.home_vfo)))

        basic.append(RadioSetting(
                "bclo", "Busy Channel Lockout",
                RadioSettingValueBoolean(_settings.bclo)))

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

        basic.append(RadioSetting(
                "fast_tone_search", "Fast Tone search",
                RadioSettingValueBoolean(_settings.fast_tone_search)))

        basic.append(RadioSetting(
                "priority_revert", "Priority Revert",
                RadioSettingValueBoolean(_settings.priority_revert)))

        basic.append(RadioSetting(
                "protect_memory", "Protect memory",
                RadioSettingValueBoolean(_settings.protect_memory)))

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

        basic.append(RadioSetting(
                "split_tone", "Split tone",
                RadioSettingValueBoolean(_settings.split_tone)))

        basic.append(RadioSetting(
                "tone_search_mute", "Tone search mute",
                RadioSettingValueBoolean(_settings.tone_search_mute)))

        basic.append(RadioSetting(
                "txsave", "TX save",
                RadioSettingValueBoolean(_settings.txsave)))

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

        opts = ["Bar Int", "Bar Ext"]
        basic.append(RadioSetting(
                "am_antenna", "AM antenna",
                RadioSettingValueList(opts, opts[_settings.am_antenna])))

        opts = ["Ext Ant", "Earphone"]
        basic.append(RadioSetting(
                "fm_antenna", "FM antenna",
                RadioSettingValueList(opts, opts[_settings.fm_antenna])))

        opts = ["off"] + ["%0.1f" % (t / 60.0) for t in range(30, 750, 30)]
        basic.append(RadioSetting(
                "apo", "APO time (hrs)",
                RadioSettingValueList(opts, opts[_settings.apo])))

        opts = ["+/- 5 MHZ", "+/- 10 MHZ", "+/- 50 MHZ", "+/- 100 MHZ"]
        basic.append(RadioSetting(
                "channel_counter", "Channel counter",
                RadioSettingValueList(opts, opts[_settings.channel_counter])))

        opts = ["0.3", "0.5", "0.7", "1.0", "1.5"]
        basic.append(RadioSetting(
                "fw_key_timer", "FW key timer (s)",
                RadioSettingValueList(opts, opts[_settings.fw_key_timer])))

        opts = ["Home", "Reverse"]
        basic.append(RadioSetting(
                "hm_rv", "HM/RV key",
                RadioSettingValueList(opts, opts[_settings.hm_rv])))

        opts = ["%d" % t for t in range(2, 11)] + ["continuous", "off"]
        basic.append(RadioSetting(
                "lamp", "Lamp Timer (s)",
                RadioSettingValueList(opts, opts[_settings.lamp])))

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

        opts = ["key", "ptt", "key+ptt"]
        basic.append(RadioSetting(
                "lock_mode", "Lock mode",
                RadioSettingValueList(opts, opts[_settings.lock_mode])))

        opts = ["10", "20", "50", "100"]
        basic.append(RadioSetting(
                "mem_ch_step", "Memory Chan step",
                RadioSettingValueList(opts, opts[_settings.mem_ch_step])))

        opts = ["lower", "next"]
        basic.append(RadioSetting(
                "mem_storage", "Memory storage mode",
                RadioSettingValueList(opts, opts[_settings.mem_storage])))

        opts = ["%d" % t for t in range(1, 10)]
        basic.append(RadioSetting(
                "mic_gain", "Mic gain",
                RadioSettingValueList(opts, opts[_settings.mic_gain])))

        opts = ["monitor", "tone call"]
        basic.append(RadioSetting(
                "moni_tcall", "Moni/TCall button",
                RadioSettingValueList(opts, opts[_settings.moni_tcall])))

        opts = ["off"] + \
               ["%02d:%02d" % (t / 60, t % 60) for t in range(10, 1450, 10)]
        basic.append(RadioSetting(
                "on_timer", "On Timer (hrs)",
                RadioSettingValueList(opts, opts[_settings.on_timer])))

        opts2 = ["off"] + \
                ["0.%d" % t for t in range(1, 10)] + \
                ["%1.1f" % (t / 10.0) for t in range(10, 105, 5)]
        basic.append(RadioSetting(
                "priority_time", "Priority time",
                RadioSettingValueList(opts2, opts2[_settings.priority_time])))

        opts = ["off", "20", "50", "100", "200"]
        basic.append(RadioSetting(
                "ptt_delay", "PTT delay (ms)",
                RadioSettingValueList(opts, opts[_settings.ptt_delay])))

        basic.append(RadioSetting(
                "rx_save", "RX save (s)",
                RadioSettingValueList(opts2, opts2[_settings.rx_save])))

        basic.append(RadioSetting(
                "scan_restart", "Scan restart (s)",
                RadioSettingValueList(opts2, opts2[_settings.scan_restart])))

        opts = ["%1.1f" % (t / 10.0) for t in range(20, 105, 5)] + \
               ["busy", "hold"]
        basic.append(RadioSetting(
                "scan_resume", "Scan resume (s)",
                RadioSettingValueList(opts, opts[_settings.scan_resume])))

        opts = ["single", "continuous"]
        basic.append(RadioSetting(
                "smart_search", "Smart search",
                RadioSettingValueList(opts, opts[_settings.smart_search])))

        opts = ["off"] + ["TRX %d" % t for t in range(1, 11)] + ["hold"] + \
               ["TX %d" % t for t in range(1, 11)]
        basic.append(RadioSetting(
                "sub_rx_timer", "Sub RX timer",
                RadioSettingValueList(opts, opts[_settings.sub_rx_timer])))

        opts = ["C", "F"]
        basic.append(RadioSetting(
                "temp_unit", "Temperature unit",
                RadioSettingValueList(opts, opts[_settings.temp_unit])))

        opts = ["off"] + ["%1.1f" % (t / 10.0) for t in range(5, 105, 5)]
        basic.append(RadioSetting(
                "tot", "Time-out timer (mins)",
                RadioSettingValueList(opts, opts[_settings.tot])))

        opts = ["all", "band"]
        basic.append(RadioSetting(
                "vfo_mode", "VFO mode",
                RadioSettingValueList(opts, opts[_settings.vfo_mode])))

        opts = ["off"] + ["%d" % t for t in range(5, 65, 5)] + ["EAI"]
        basic.append(RadioSetting(
                "wake_up", "Wake up (s)",
                RadioSettingValueList(opts, opts[_settings.wake_up])))

        opts = ["hold", "3 secs"]
        basic.append(RadioSetting(
                "vol_key_mode", "Volume key mode",
                RadioSettingValueList(opts, opts[_settings.vol_key_mode])))

        # subgroup programmable keys

        opts = ["INTNET", "INT MR", "Set Mode (my key)"]
        basic.append(RadioSetting(
                "internet_key", "Internet key",
                RadioSettingValueList(opts, opts[_settings.internet_key])))

        keys = ["Antenna AM", "Antenna FM", "Antenna Attenuator",
                "Auto Power Off", "Auto Repeater Shift", "ARTS Beep",
                "ARTS Interval", "Busy Channel Lockout", "Bell Ringer",
                "Bell Select", "Bank Name", "Band Edge Beep", "Beep Level",
                "Beep Select", "Beep User", "Busy LED", "Channel Counter",
                "Clock Shift", "CW ID", "CW Learning", "CW Pitch",
                "CW Training", "DC Voltage", "DCS Code", "DCS Reverse",
                "DTMF A/M", "DTMF Delay", "DTMF Set", "DTMF Speed",
                "EAI Timer", "Emergency Alarm", "Ext Menu", "FW Key",
                "Half Deviation", "Home/Reverse", "Home > VFO", "INT Code",
                "INT Conn Mode", "INT A/M", "INT Set", "INT Key", "INTNET",
                "Lamp", "LED Light", "Lock", "Moni/T-Call", "Mic Gain",
                "Memory Display", "Memory Write Mode", "Memory Channel Step",
                "Memory Name Write", "Memory Protect", "Memory Skip",
                "Message List", "Message Reg", "Message Set", "On Timer",
                "Open Message", "Pager Answer Back", "Pager Receive Code",
                "Pager Transmit Code", "Pager Frequency", "Priority Revert",
                "Priority Timer", "Password", "PTT Delay",
                "Repeater Shift Direction", "Repeater Shift", "Receive Mode",
                "Smart Search", "Save Rx", "Save Tx", "Scan Lamp",
                "Scan Resume", "Scan Restart", "Speaker Out",
                "Squelch Level", "Squelch Type", "Squelch S Meter",
                "Squelch Split Tone", "Step", "Stereo", "Sub Rx", "Temp",
                "Tone Frequency", "Time Out Timer", "Tone Search Mute",
                "Tone Search Speed", "VFO Band", "VFO Skip", "Volume Mode",
                "Wake Up", "Weather Alert"]
        rs = RadioSetting(
                "my_key", "My key",
                RadioSettingValueList(keys, keys[_settings.my_key - 16]))
        # TODO: fix keys list isnt exactly right order
        # leave disabled in settings for now
        # basic.append(rs)

        # sound tab

        sound.append(RadioSetting(
                "band_edge_beep", "Band edge beep",
                RadioSettingValueBoolean(_settings.band_edge_beep)))

        opts = ["off", "key+scan", "key"]
        sound.append(RadioSetting(
                "beep_mode", "Beep mode",
                RadioSettingValueList(opts, opts[_settings.beep_mode])))

        _volumes = self._memobj.volumes

        opts = map(str, range(0, 33))
        sound.append(RadioSetting(
                "speaker_vol", "Speaker volume",
                RadioSettingValueList(opts, opts[_volumes.speaker])))

        sound.append(RadioSetting(
                "earphone_vol", "Earphone volume",
                RadioSettingValueList(opts, opts[_volumes.earphone])))

        opts = ["auto", "speaker"]
        sound.append(RadioSetting(
                "fm_speaker_out", "FM Speaker out",
                RadioSettingValueList(opts, opts[_settings.fm_speaker_out])))

        opts = ["mono", "stereo"]
        sound.append(RadioSetting(
                "fm_broadcast_mode", "FM broadcast mode",
                RadioSettingValueList(
                    opts, opts[_settings.fm_broadcast_mode])))

        opts = map(str, range(16))
        sound.append(RadioSetting(
                "sql_fm", "Squelch level (FM)",
                RadioSettingValueList(opts, opts[_settings.sql_fm])))

        opts = map(str, range(9))
        sound.append(RadioSetting(
                "sql_wfm", "Squelch level (WFM)",
                RadioSettingValueList(opts, opts[_settings.sql_wfm])))

        opts = map(str, range(16))
        sound.append(RadioSetting(
                "radio_am_sql", "Squelch level (Broadcast Radio AM)",
                RadioSettingValueList(opts, opts[_settings.radio_am_sql])))

        opts = map(str, range(9))
        sound.append(RadioSetting(
                "radio_fm_sql", "Squelch level (Broadcast Radio FM)",
                RadioSettingValueList(opts, opts[_settings.radio_fm_sql])))

        # dtmf tab

        opts = ["manual", "auto"]
        dtmf.append(RadioSetting(
                "dtmf_autodialer", "DTMF autodialer mode",
                RadioSettingValueList(opts, opts[_settings.dtmf_autodialer])))

        opts = ["50", "250", "450", "750", "1000"]
        dtmf.append(RadioSetting(
                "dtmf_delay", "DTMF delay (ms)",
                RadioSettingValueList(opts, opts[_settings.dtmf_delay])))

        opts = ["50", "100"]
        dtmf.append(RadioSetting(
                "dtmf_speed", "DTMF speed (ms)",
                RadioSettingValueList(opts, opts[_settings.dtmf_speed])))

        opts = map(str, range(10))
        dtmf.append(RadioSetting(
                "dtmf_chan_active", "DTMF active",
                RadioSettingValueList(
                    opts, opts[_settings.dtmf_chan_active])))

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

        # arts tab
        arts.append(RadioSetting(
                "arts", "ARTS",
                RadioSettingValueBoolean(_settings.arts)))

        opts = ["off", "in range", "always"]
        arts.append(RadioSetting(
                "arts_beep", "ARTS beep",
                RadioSettingValueList(opts, opts[_settings.arts_beep])))

        opts = ["15", "25"]
        arts.append(RadioSetting(
                "arts_interval", "ARTS interval",
                RadioSettingValueList(opts, opts[_settings.arts_interval])))

        arts.append(RadioSetting(
                "arts_cwid_enable", "CW ID",
                RadioSettingValueBoolean(_settings.arts_cwid_enable)))

        cwid = RadioSettingValueString(
                0, 16, self._decode_chars(_settings.arts_cwid.get_value()))
        cwid.set_charset(CHARSET)
        arts.append(RadioSetting("arts_cwid", "CW ID", cwid))

        # EAI tab

        eai.append(RadioSetting(
                "emergency_eai", "EAI",
                RadioSettingValueBoolean(_settings.emergency_eai)))

        opts = ["interval %dm" % t for t in range(1, 10)] + \
               ["interval %dm" % t for t in range(10, 55, 5)] + \
               ["continuous %dm" % t for t in range(1, 10)] + \
               ["continuous %dm" % t for t in range(10, 55, 5)]

        eai.append(RadioSetting(
                "emergency_eai_time", "EAI time",
                RadioSettingValueList(
                    opts, opts[_settings.emergency_eai_time])))

        opts = ["beep", "strobe", "beep+strobe", "beam",
                "beep+beam", "cw", "beep+cw", "cwt"]
        eai.append(RadioSetting(
                "emergency_signal", "emergency signal",
                RadioSettingValueList(
                    opts, opts[_settings.emergency_signal])))

        # msg tab

        opts = ["off", "dc voltage", "message"]
        msg.append(RadioSetting(
                "openmsg_mode", "Opening message mode",
                RadioSettingValueList(opts, opts[_settings.openmsg_mode])))

        openmsg = RadioSettingValueString(
                0, 6, self._decode_chars(_settings.openmsg.get_value()))
        openmsg.set_charset(CHARSET)
        msg.append(RadioSetting("openmsg", "Opening Message", openmsg))

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

        _overlay = self._memobj.overlay

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return setmode
Exemple #36
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic")
        dtmf = RadioSettingGroup("dtmf", "DTMF Code & Paging")
        arts = RadioSettingGroup("arts", "ARTS")
        autodial = RadioSettingGroup("autodial", "AutoDial")
        top = RadioSettings(basic, autodial, arts, dtmf)

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

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

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

        options = ["off", "30m", "1h", "3h", "5h", "8h"]
        rs = RadioSetting(
            "apo", "APO time (hrs)",
            RadioSettingValueList(options, options[_settings.apo]))
        basic.append(rs)

        options = ["off", "1m", "2.5m", "5m", "10m"]
        rs = RadioSetting(
            "timeout", "Time Out Timer",
            RadioSettingValueList(options, options[_settings.timeout]))
        basic.append(rs)

        options = [
            "key", "dial", "key+dial", "ptt", "key+ptt", "dial+ptt", "all"
        ]
        rs = RadioSetting(
            "lock", "Lock mode",
            RadioSettingValueList(options, options[_settings.lock]))
        basic.append(rs)

        options = ["off", "0.2", "0.3", "0.5", "1.0", "2.0"]
        rs = RadioSetting(
            "rxsave", "RX Save (sec)",
            RadioSettingValueList(options, options[_settings.rxsave]))
        basic.append(rs)

        options = ["5sec", "key", "tgl"]
        rs = RadioSetting(
            "lamp", "Lamp mode",
            RadioSettingValueList(options, options[_settings.lamp]))
        basic.append(rs)

        options = ["off", "1", "3", "5", "8", "rpt"]
        rs = RadioSetting(
            "bell", "Bell Repetitions",
            RadioSettingValueList(options, options[_settings.bell]))
        basic.append(rs)

        rs = RadioSetting("cwid_en", "CWID Enable",
                          RadioSettingValueBoolean(_settings.cwid_en))
        arts.append(rs)

        cwid = RadioSettingValueString(
            0, 16, self._decode_cwid(_settings.cwid.get_value()))
        cwid.set_charset(CHARSET)
        rs = RadioSetting("cwid", "CWID", cwid)
        arts.append(rs)

        options = ["off", "rx", "tx", "trx"]
        rs = RadioSetting(
            "artsmode", "ARTS Mode",
            RadioSettingValueList(options, options[_settings.artsmode]))
        arts.append(rs)

        options = ["off", "in range", "always"]
        rs = RadioSetting(
            "artsbeep", "ARTS Beep",
            RadioSettingValueList(options, options[_settings.artsbeep]))
        arts.append(rs)

        for i in range(0, 8):
            dialsettings = _settings.autodial[i]
            dialstr = ""
            for c in dialsettings.digits:
                if c < len(DTMFCHARSET):
                    dialstr += DTMFCHARSET[c]
            dialentry = RadioSettingValueString(0, 16, dialstr)
            dialentry.set_charset(DTMFCHARSET + list(" "))
            rs = RadioSetting("autodial" + str(i + 1),
                              "AutoDial " + str(i + 1), dialentry)
            autodial.append(rs)

        dialstr = ""
        for c in _settings.autodial9_ro.digits:
            if c < len(DTMFCHARSET):
                dialstr += DTMFCHARSET[c]
        dialentry = RadioSettingValueString(0, 32, dialstr)
        dialentry.set_mutable(False)
        rs = RadioSetting("autodial9_ro", "AutoDial 9 (read only)", dialentry)
        autodial.append(rs)

        options = ["50ms", "100ms"]
        rs = RadioSetting(
            "pagingspeed", "Paging Speed",
            RadioSettingValueList(options, options[_settings.pagingspeed]))
        dtmf.append(rs)

        options = ["250ms", "450ms", "750ms", "1000ms"]
        rs = RadioSetting(
            "pagingdelay", "Paging Delay",
            RadioSettingValueList(options, options[_settings.pagingdelay]))
        dtmf.append(rs)

        options = ["off", "1", "3", "5", "8", "rpt"]
        rs = RadioSetting(
            "pagingbell", "Paging Bell Repetitions",
            RadioSettingValueList(options, options[_settings.pagingbell]))
        dtmf.append(rs)

        options = ["off", "ans", "for"]
        rs = RadioSetting(
            "paginganswer", "Paging Answerback",
            RadioSettingValueList(options, options[_settings.paginganswer]))
        dtmf.append(rs)

        rs = RadioSetting("code_dec_c_en", "Paging Code C Decode Enable",
                          RadioSettingValueBoolean(_settings.code_dec_c_en))
        dtmf.append(rs)

        _str = str(bitwise.bcd_to_int(_settings.pagingcodec_ro))
        code = RadioSettingValueString(0, 3, _str)
        code.set_charset(NUMERIC_CHARSET + list(" "))
        code.set_mutable(False)
        rs = RadioSetting("pagingcodec_ro", "Paging Code C (read only)", code)
        dtmf.append(rs)

        rs = RadioSetting("code_dec_p_en", "Paging Code P Decode Enable",
                          RadioSettingValueBoolean(_settings.code_dec_p_en))
        dtmf.append(rs)

        _str = str(bitwise.bcd_to_int(_settings.pagingcodep))
        code = RadioSettingValueString(0, 3, _str)
        code.set_charset(NUMERIC_CHARSET + list(" "))
        rs = RadioSetting("pagingcodep", "Paging Code P", code)
        dtmf.append(rs)

        for i in range(0, 6):
            num = str(i + 1)
            name = "code_dec_" + num + "_en"
            rs = RadioSetting(
                name, "Paging Code " + num + " Decode Enable",
                RadioSettingValueBoolean(getattr(_settings, name)))
            dtmf.append(rs)

            _str = str(bitwise.bcd_to_int(_settings.pagingcode[i].digits))
            code = RadioSettingValueString(0, 3, _str)
            code.set_charset(NUMERIC_CHARSET + list(" "))
            rs = RadioSetting("pagingcode" + num, "Paging Code " + num, code)
            dtmf.append(rs)

        return top