Example #1
0
    def get_settings(self):
        _mem = self._memobj
        basic = RadioSettingGroup("basic", "Basic")
        top = RadioSettings(basic)

        def _f(val):
            string = ""
            for char in str(val):
                if char == "\xFF":
                    break
                string += char
            return string

        line1 = RadioSetting(
            "messages.line1", "Message Line 1",
            RadioSettingValueString(0,
                                    32,
                                    _f(_mem.messages.line1),
                                    autopad=False))
        basic.append(line1)

        line2 = RadioSetting(
            "messages.line2", "Message Line 2",
            RadioSettingValueString(0,
                                    32,
                                    _f(_mem.messages.line2),
                                    autopad=False))
        basic.append(line2)

        return top
Example #2
0
    def _get_display_settings(self):
        menu = RadioSettingGroup("display", "Display")
        display_settings = self._memobj.settings

        val = RadioSettingValueString(
            0, 8,
            str(display_settings.power_on_msg).rstrip("\xFF"))
        rs = RadioSetting("display.power_on_msg", "Power on message", val)
        rs.set_apply_callback(self.apply_power_on_msg, display_settings)
        menu.append(rs)

        val = RadioSettingValueList(
            self._LCD_CONTRAST,
            self._LCD_CONTRAST[display_settings.contrast - 1])
        rs = RadioSetting("display.contrast", "LCD Contrast", val)
        rs.set_apply_callback(self.apply_lcd_contrast, display_settings)
        menu.append(rs)

        val = RadioSettingValueList(
            self._LAMP_CONTROL,
            self._LAMP_CONTROL[display_settings.lamp_control])
        rs = RadioSetting("display.lamp_control", "Lamp Control", val)
        rs.set_apply_callback(self.apply_lamp_control, display_settings)
        menu.append(rs)

        val = RadioSettingValueList(
            self._LAMP_TIMER,
            self._LAMP_TIMER[display_settings.lamp_timer - 2])
        rs = RadioSetting("display.lamp_timer", "Lamp Timer", val)
        rs.set_apply_callback(self.apply_lamp_timer, display_settings)
        menu.append(rs)

        return menu
Example #3
0
    def get_memory(self, number):
        _mem = self._memobj.memory[number - 1]
        _nam = self._memobj.chan_names[number - 1]

        def _is_empty():
            for i in range(0, 4):
                if _mem.rx_freq[i].get_raw() != "\xFF":
                    return False
            return True

        mem = chirp_common.Memory()
        mem.number = number

        if _is_empty():
            mem.empty = True
            return mem

        mem.freq = int(_mem.rx_freq) * 10

        if int(_mem.rx_freq) == int(_mem.tx_freq):
            mem.duplex = ""
            mem.offset = 0
        else:
            mem.duplex = int(_mem.rx_freq) > int(_mem.tx_freq) and "-" or "+"
            mem.offset = abs(int(_mem.rx_freq) - int(_mem.tx_freq)) * 10

        mem.mode = _mem.w_n and "FM" or "NFM"
        self._get_tone(_mem, mem)
        mem.power = POWER_LEVELS[_mem.power]

        mem.extra = RadioSettingGroup("Extra", "extra")
        rs = RadioSetting(
            "lout", "Lock out",
            RadioSettingValueList(OFF_ON_LIST, OFF_ON_LIST[_mem.lout]))
        mem.extra.append(rs)

        rs = RadioSetting(
            "busy_loc", "Busy lock",
            RadioSettingValueList(BUSYLOCK_LIST, BUSYLOCK_LIST[_mem.busy_loc]))
        mem.extra.append(rs)

        rs = RadioSetting(
            "scan_add", "Scan add",
            RadioSettingValueList(NO_YES_LIST, NO_YES_LIST[_mem.scan_add]))
        mem.extra.append(rs)
        #TODO: Show name channel
        ##        count = 0
        ##        for i in _nam.chan_name:
        ##            if i == 0xFF:
        ##                break
        ##            try:
        ##                mem.name += IP620_CHARSET[i]
        ##            except Exception:
        ##                LOG.error("Unknown name char %i: 0x%02x (mem %i)" %
        ##                          (count, i, number - 1))
        ##                mem.name += " "
        ##            count += 1
        ##        mem.name = mem.name.rstrip()

        return mem
Example #4
0
    def get_memory(self, number):
        _mem = self._memobj.memory[number - 1]
        mem = chirp_common.Memory()
        mem.number = number
        if _mem.get_raw().startswith("\xFF\xFF\xFF\xFF"):
            mem.empty = True
            return mem

        mem.freq = int(_mem.rx_freq) * 10

        txfreq = int(_mem.tx_freq) * 10
        if self._is_txinh(_mem):
            mem.duplex = "off"
            mem.offset = 0
        elif txfreq == mem.freq:
            mem.duplex = ""
        elif abs(txfreq - mem.freq) > 70000000:
            mem.duplex = "split"
            mem.offset = txfreq
        elif txfreq < mem.freq:
            mem.duplex = "-"
            mem.offset = mem.freq - txfreq
        elif txfreq > mem.freq:
            mem.duplex = "+"
            mem.offset = txfreq - mem.freq

        txmode, txval, txpol = self._decode_tone(_mem.tx_tone)
        rxmode, rxval, rxpol = self._decode_tone(_mem.rx_tone)

        chirp_common.split_tone_decode(mem, (txmode, txval, txpol),
                                       (rxmode, rxval, rxpol))

        mem.name = str(self._memobj.names[number - 1].name)
        mem.name = mem.name.replace("\xFF", " ").rstrip()

        mem.skip = not _mem.scan and "S" or ""
        mem.mode = _mem.isnarrow and "NFM" or "FM"
        mem.power = POWER_LEVELS[1 - _mem.ishighpower]

        mem.extra = RadioSettingGroup("extra", "Extra Settings")

        rs = RadioSetting(
            "pttid", "PTT ID",
            RadioSettingValueList(PTTID_LIST, PTTID_LIST[_mem.pttid]))
        mem.extra.append(rs)

        rs = RadioSetting("vox", "VOX", RadioSettingValueBoolean(_mem.vox))
        mem.extra.append(rs)

        rs = RadioSetting("bcl", "Busy Channel Lockout",
                          RadioSettingValueList(BCL_LIST, BCL_LIST[_mem.bcl]))
        mem.extra.append(rs)

        rs = RadioSetting(
            "scramble_code", "Scramble Code",
            RadioSettingValueList(CODES_LIST, CODES_LIST[_mem.scramble_code]))
        mem.extra.append(rs)

        return mem
Example #5
0
    def get_memory(self, number):
        bitpos = (1 << ((number - 1) % 8))
        bytepos = ((number - 1) / 8)
        LOG.debug("bitpos %s" % bitpos)
        LOG.debug("bytepos %s" % bytepos)

        _mem = self._memobj.memory[number - 1]
        _skp = self._memobj.skipflags[bytepos]

        mem = chirp_common.Memory()

        mem.number = number
        mem.freq = int(_mem.rxfreq) * 10

        # We'll consider any blank (i.e. 0MHz frequency) to be empty
        if mem.freq == 0:
            mem.empty = True
            return mem

        if _mem.rxfreq.get_raw() == "\xFF\xFF\xFF\xFF":
            mem.freq = 0
            mem.empty = True
            return mem

        if _mem.get_raw() == ("\xFF" * 16):
            LOG.debug("Initializing empty memory")
            _mem.set_raw("\x00" * 13 + "\x30\x8F\xF8")

        if int(_mem.rxfreq) == int(_mem.txfreq):
            mem.duplex = ""
            mem.offset = 0
        else:
            mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
            mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10

        mem.mode = _mem.wide and "FM" or "NFM"

        self._get_tone(_mem, mem)

        mem.power = RT21_POWER_LEVELS[_mem.highpower]

        mem.skip = "" if (_skp & bitpos) else "S"
        LOG.debug("mem.skip %s" % mem.skip)

        mem.extra = RadioSettingGroup("Extra", "extra")

        rs = RadioSetting("bcl", "Busy Channel Lockout",
                          RadioSettingValueList(BCL_LIST, BCL_LIST[_mem.bcl]))
        mem.extra.append(rs)

        rs = RadioSetting(
            "scramble_type", "Scramble Type",
            RadioSettingValueList(SCRAMBLE_LIST,
                                  SCRAMBLE_LIST[_mem.scramble_type - 8]))
        mem.extra.append(rs)

        return mem
Example #6
0
    def get_memory(self, number):
        _mem, _nam = self._get_memobjs(number)
        mem = chirp_common.Memory()
        if isinstance(number, str):
            mem.number = SPECIALS[number]
            mem.extd_number = number
        else:
            mem.number = number

        if _mem.freq.get_raw()[0] == "\xFF":
            mem.empty = True
            return mem

        mem.freq = int(_mem.freq) * 10
        mem.offset = int(_mem.offset) * 10

        chirp_common.split_tone_decode(
            mem, self._decode_tone(_mem.txtone, _mem.txpol),
            self._decode_tone(_mem.rxtone, _mem.rxpol))

        if _mem.step > 0x05:
            _mem.step = 0x00
        mem.duplex = DUPLEX[_mem.duplex]
        mem.mode = _mem.isnarrow and "NFM" or "FM"
        mem.skip = "" if _mem.scanadd else "S"
        mem.power = POWER_LEVELS[_mem.highpower]

        if mem.freq == mem.offset and mem.duplex == "-":
            mem.duplex = "off"
            mem.offset = 0

        if _nam:
            for char in _nam:
                try:
                    mem.name += CHARSET[char]
                except IndexError:
                    break
            mem.name = mem.name.rstrip()

        mem.extra = RadioSettingGroup("Extra", "extra")

        rs = RadioSetting("bcl", "BCL", RadioSettingValueBoolean(_mem.bcl))
        mem.extra.append(rs)

        rs = RadioSetting("revfreq", "Reverse Duplex",
                          RadioSettingValueBoolean(_mem.revfreq))
        mem.extra.append(rs)

        rs = RadioSetting("pttid", "PTT ID",
                          RadioSettingValueBoolean(_mem.pttid))
        mem.extra.append(rs)

        rs = RadioSetting("compander", "Compander",
                          RadioSettingValueBoolean(_mem.compander))
        mem.extra.append(rs)

        return mem
Example #7
0
    def get_memory(self, number):
        _mem = self._memobj.memory[number - 1]

        mem = chirp_common.Memory()

        mem.number = number
        mem.freq = int(_mem.rxfreq) * 10

        # We'll consider any blank (i.e. 0MHz frequency) to be empty
        if mem.freq == 0:
            mem.empty = True
            return mem

        if _mem.rxfreq.get_raw() == "\xFF\xFF\xFF\xFF":
            mem.freq = 0
            mem.empty = True
            return mem

        if int(_mem.rxfreq) == int(_mem.txfreq):
            mem.duplex = ""
            mem.offset = 0
        else:
            mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
            mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10

        mem.mode = _mem.wide and "FM" or "NFM"

        rxtone = txtone = None
        txtone = self.decode_tone(_mem.txtone)
        rxtone = self.decode_tone(_mem.rxtone)
        chirp_common.split_tone_decode(mem, txtone, rxtone)

        mem.power = RT1_POWER_LEVELS[_mem.highpower]

        if _mem.skip:
            mem.skip = "S"

        mem.extra = RadioSettingGroup("Extra", "extra")

        rs = RadioSetting("bcl", "BCL",
                          RadioSettingValueBoolean(not _mem.bcl))
        mem.extra.append(rs)

        rs = RadioSetting("epilogue", "Epilogue(STE)",
                          RadioSettingValueBoolean(not _mem.epilogue))
        mem.extra.append(rs)

        rs = RadioSetting("compander", "Compander",
                          RadioSettingValueBoolean(not _mem.compander))
        mem.extra.append(rs)

        rs = RadioSetting("scramble", "Scramble",
                          RadioSettingValueBoolean(not _mem.scramble))
        mem.extra.append(rs)

        return mem
Example #8
0
    def get_memory(self, number):
        _mem = self._memobj.memory[number - 1]
        mem = chirp_common.Memory()
        mem.number = number

        bit = 1 << ((number - 1) % 8)
        byte = (number - 1) / 8

        if self._memobj.emptyflags[byte] & bit:
            mem.empty = True
            return mem

        mem.freq = _mem.rx_freq * 10
        mem.offset = abs(_mem.rx_freq - _mem.tx_freq) * 10
        if _mem.tx_freq == _mem.rx_freq:
            mem.duplex = ""
        elif _mem.tx_freq < _mem.rx_freq:
            mem.duplex = "-"
        elif _mem.tx_freq > _mem.rx_freq:
            mem.duplex = "+"

        mem.mode = _mem.iswide and "FM" or "NFM"
        self._decode_tone(mem, _mem)
        mem.skip = (self._memobj.skipflags[byte] & bit) and "S" or ""

        for char in _mem.name:
            try:
                c = THUV3R_CHARSET[char]
            except:
                c = ""
            mem.name += c
        mem.name = mem.name.rstrip()

        mem.power = self.POWER_LEVELS[not _mem.power_high]

        mem.extra = RadioSettingGroup("extra", "Extra Settings")

        rs = RadioSetting("bclo_n", "Busy Channel Lockout",
                          RadioSettingValueBoolean(not _mem.bclo_n))
        mem.extra.append(rs)

        rs = RadioSetting("vox_n", "VOX",
                          RadioSettingValueBoolean(not _mem.vox_n))
        mem.extra.append(rs)

        rs = RadioSetting("tail", "Squelch Tail Elimination",
                          RadioSettingValueBoolean(_mem.tail))
        mem.extra.append(rs)

        rs = RadioSetting(
            "voice_mode", "Voice Mode",
            RadioSettingValueList(VOICE_MODE_LIST,
                                  VOICE_MODE_LIST[_mem.voice_mode - 1]))
        mem.extra.append(rs)

        return mem
Example #9
0
    def get_memory(self, number):
        """Return a Memory object for the memory at location @number"""
        try:
            rmem = self._memobj.memory[number - 1]
        except KeyError:
            raise errors.InvalidMemoryLocation('Unknown channel %s' % number)

        if number < 1 or number > self.CHANNELS:
            raise errors.InvalidMemoryLocation(
                'Channel number must be 1 and %s' % self.CHANNELS)

        mem = chirp_common.Memory()
        mem.number = number
        mem.freq = int(rmem.rxfreq) * 10

        # A blank (0MHz) or 0xFFFFFFFF frequency is considered empty
        if mem.freq == 0 or rmem.rxfreq.get_raw() == '\xFF\xFF\xFF\xFF':
            LOG.debug('empty channel %d', number)
            mem.freq = 0
            mem.empty = True
            return mem

        if rmem.txfreq.get_raw() == '\xFF\xFF\xFF\xFF':
            mem.duplex = 'off'
            mem.offset = 0
        elif int(rmem.rxfreq) == int(rmem.txfreq):
            mem.duplex = ''
            mem.offset = 0
        else:
            mem.duplex = '-' if int(rmem.rxfreq) > int(rmem.txfreq) else '+'
            mem.offset = abs(int(rmem.rxfreq) - int(rmem.txfreq)) * 10

        mem.mode = 'NFM' if rmem.narrow else 'FM'
        mem.skip = 'S' if rmem.skip else ''
        mem.power = self.X3P_POWER_LEVELS[rmem.highpower]

        txtone = self._decode_tone(rmem.txtone)
        rxtone = self._decode_tone(rmem.rxtone)
        chirp_common.split_tone_decode(mem, txtone, rxtone)

        mem.extra = RadioSettingGroup('Extra', 'extra')
        mem.extra.append(
            RadioSetting('bcl', 'Busy Channel Lockout',
                         RadioSettingValueBoolean(current=(not rmem.bcl))))
        mem.extra.append(
            RadioSetting(
                'scramble', 'Scramble',
                RadioSettingValueBoolean(current=(not rmem.scramble))))
        mem.extra.append(
            RadioSetting(
                'compander', 'Compander',
                RadioSettingValueBoolean(current=(not rmem.compander))))

        return mem
Example #10
0
    def _get_memory(self, number):
        bit = 1 << (number % 8)
        byte = int(number / 8)

        mem = chirp_common.Memory()
        mem.number = number

        _mem = self._memobj.memory[number]

        if number < 200:
            _usd = self._memobj.used[byte]
            _skp = self._memobj.skips[byte]
        else:
            mem.extd_number = SPECIAL_REV[number]
            mem.immutable = ["name", "number", "extd_number", "skip"]
            _usd = self._memobj.used[byte] if (number <= 206) else None
            _skp = None

        if _usd is not None and (_usd & bit):
            mem.empty = True
            return mem

        mem.freq = _mem.freq
        mem.offset = int(_mem.offset)
        if number < 200:
            mem.name = str(_mem.name).rstrip()
        mem.rtone = chirp_common.TONES[_mem.rtone]
        mem.ctone = chirp_common.TONES[_mem.ctone]
        mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs]
        mem.tuning_step = TUNING_STEPS[_mem.tuning_step]
        mem.mode = MODES[_mem.mode]
        mem.duplex = DUPLEXES[_mem.duplex]
        mem.dtcs_polarity = DTCS_POLARITY[_mem.dtcs_polarity]
        mem.tmode = TMODES[_mem.tmode]
        mem.power = POWER_LEVELS[_mem.power]

        # Extras
        mem.extra = RadioSettingGroup("extra", "Extra")
        rev = RadioSetting("rev", "Reverse duplex",
                           RadioSettingValueBoolean(bool(_mem.rev)))
        rev.set_doc("Reverse duplex")
        mem.extra.append(rev)

        tx = RadioSetting("tx", "Tx permission",
                          RadioSettingValueBoolean(bool(_mem.tx)))
        tx.set_doc("Tx permission")
        mem.extra.append(tx)

        if _skp is not None:
            mem.skip = (_skp & bit) and "S" or ""

        return mem
Example #11
0
    def _get_ost(self, parent):
        tones = chirp_common.TONES[:]

        def apply_tone(setting, index, which):
            if str(setting.value) == 'Off':
                val = 0xFFFF
            else:
                val = int(float(str(setting.value)) * 10)
            setattr(self._memobj.ost_tones[index], '%stone' % which, val)

        def _tones():
            return ['Off'] + [str(x) for x in tones]

        for i in range(0, 40):
            _ost = self._memobj.ost_tones[i]
            ost = RadioSettingGroup('ost%i' % i,
                                    'OST %i' % (i + 1))

            cur = str(_ost.name).rstrip('\x00')
            name = RadioSetting('name%i' % i, 'Name',
                                RadioSettingValueString(0, 12, cur))
            ost.append(name)

            if _ost.rxtone == 0xFFFF:
                cur = 'Off'
            else:
                cur = round(int(_ost.rxtone) / 10.0, 1)
                if cur not in tones:
                    LOG.debug('Non-standard OST rx tone %i %s' % (i, cur))
                    tones.append(cur)
                    tones.sort()
            rx = RadioSetting('rxtone%i' % i, 'RX Tone',
                              RadioSettingValueList(_tones(),
                                                    str(cur)))
            rx.set_apply_callback(apply_tone, i, 'rx')
            ost.append(rx)

            if _ost.txtone == 0xFFFF:
                cur = 'Off'
            else:
                cur = round(int(_ost.txtone) / 10.0, 1)
                if cur not in tones:
                    LOG.debug('Non-standard OST tx tone %i %s' % (i, cur))
                    tones.append(cur)
                    tones.sort()
            tx = RadioSetting('txtone%i' % i, 'TX Tone',
                              RadioSettingValueList(_tones(),
                                                    str(cur)))
            tx.set_apply_callback(apply_tone, i, 'tx')
            ost.append(tx)

            parent.append(ost)
Example #12
0
    def get_memory(self, number):
        """Extract a high-level memory object from the low-level
        memory map, This is called to populate a memory in the UI"""
        # Get a low-level memory object mapped to the image
        _mem = self._memobj.memory[number - 1]
        # Create a high-level memory object to return to the UI
        mem = chirp_common.Memory()
        # number
        mem.number = number

        # empty
        if _mem.get_raw()[0] == "\xFF":
            mem.empty = True
            return mem

        # rx freq
        mem.freq = int(_mem.rx_freq) * 10

        # checking if tx freq is empty, this is "possible" on the
        # original soft after a warning, and radio is happy with it
        if _mem.tx_freq.get_raw() == "\xFF\xFF\xFF\xFF":
            mem.duplex = "off"
            mem.offset = 0
        else:
            rx = int(_mem.rx_freq) * 10
            tx = int(_mem.tx_freq) * 10
            if tx == rx:
                mem.offset = 0
                mem.duplex = ""
            else:
                mem.duplex = rx > tx and "-" or "+"
                mem.offset = abs(tx - rx)

        # tone data
        txtone = self._decode_tone(_mem.tx_tone)
        rxtone = self._decode_tone(_mem.rx_tone)
        chirp_common.split_tone_decode(mem, txtone, rxtone)

        # Extra setting group, FD-268 don't uset it at all
        # FD-288's & others do it?
        mem.extra = RadioSettingGroup("extra", "Extra")
        busy = RadioSetting("Busy", "Busy Channel Lockout",
                            RadioSettingValueBoolean(
                                bool(_mem.busy_lock)))
        mem.extra.append(busy)
        scramble = RadioSetting("Scrambler", "Scrambler Option",
                                RadioSettingValueBoolean(
                                    bool(_mem.scrambler)))
        mem.extra.append(scramble)

        # return mem
        return mem
Example #13
0
    def _get_memory(self, mem, _mem):
        mem.freq = int(_mem.freq) * 10
        mem.offset = int(_mem.offset) * 10
        self._get_duplex(mem, _mem)
        mem.mode = self.MODES[_mem.mode]
        if mem.mode == "FM":
            if _mem.is_fm_narrow == 1:
                mem.mode = "NFM"
            mem.tuning_step = self.STEPSFM[_mem.fm_step]
        elif mem.mode == "AM":
            mem.tuning_step = self.STEPSAM[_mem.am_step]
        elif mem.mode == "CW" or mem.mode == "CWR":
            if _mem.is_cwdig_narrow == 1:
                mem.mode = "N" + mem.mode
            mem.tuning_step = self.STEPSSSB[_mem.ssb_step]
        else:
            try:
                mem.tuning_step = self.STEPSSSB[_mem.ssb_step]
            except IndexError:
                pass
        mem.skip = _mem.skip and "S" or ""
        self._get_tmode(mem, _mem)

        if _mem.tag_on_off == 1:
            for i in _mem.name:
                if i == 0xFF:
                    break
                if chr(i) in self.CHARSET:
                    mem.name += chr(i)
                else:
                    # radio have some graphical chars that are not supported
                    # we replace those with a *
                    print "Replacing char %x with *" % i
                    mem.name += "*"
            mem.name = mem.name.rstrip()
        else:
            mem.name = ""

        mem.extra = RadioSettingGroup("extra", "Extra")
        ipo = RadioSetting("ipo", "IPO",
                           RadioSettingValueBoolean(bool(_mem.ipo)))
        ipo.set_doc("Bypass preamp")
        mem.extra.append(ipo)
        
        att = RadioSetting("att", "ATT",
                           RadioSettingValueBoolean(bool(_mem.att)))
        att.set_doc("10dB front end attenuator")
        mem.extra.append(att)

        return mem
Example #14
0
    def get_memory(self, number):
        _mem = self._memobj.memory[number - 1]

        mem = chirp_common.Memory()
        mem.number = number

        if _mem.get_raw()[:4] == "\xFF\xFF\xFF\xFF":
            mem.empty = True
            return mem

        mem.freq = int(_mem.rx_freq) * 10
        offset = (int(_mem.tx_freq) * 10) - mem.freq
        if offset < 0:
            mem.offset = abs(offset)
            mem.duplex = "-"
        elif offset > 0:
            mem.offset = offset
            mem.duplex = "+"
        else:
            mem.offset = 0

        self._get_tone(_mem, mem)
        mem.power = POWER_LEVELS[_mem.highpower]
        mem.mode = MODES[_mem.wide]
        mem.skip = not _mem.scan and "S" or ""

        mem.extra = RadioSettingGroup("all", "All Settings")

        bcl = RadioSetting("bcl", "Busy Channel Lockout",
                           RadioSettingValueBoolean(bool(_mem.bcl)))
        mem.extra.append(bcl)

        beat = RadioSetting("beatshift", "Beat Shift",
                            RadioSettingValueBoolean(bool(_mem.beatshift)))
        mem.extra.append(beat)

        pttid = RadioSetting("pttid", "PTT ID",
                             RadioSettingValueList(PTTID,
                                                   PTTID[_mem.pttid]))
        mem.extra.append(pttid)

        signal = RadioSetting("signaling", "Signaling",
                              RadioSettingValueList(SIGNAL,
                                                    SIGNAL[
                                                      _mem.signaling & 0x01]))
        mem.extra.append(signal)

        return mem
Example #15
0
    def get_memory(self, number):
        _mem = self._memobj.memory[number - 1]

        mem = chirp_common.Memory()

        mem.number = number
        mem.freq = int(_mem.rxfreq) * 10

        # We'll consider any blank (i.e. 0MHz frequency) to be empty
        if mem.freq == 0:
            mem.empty = True
            return mem

        if _mem.rxfreq.get_raw() == "\xFF\xFF\xFF\xFF":
            mem.freq = 0
            mem.empty = True
            return mem

        if _mem.txfreq.get_raw() == "\xFF\xFF\xFF\xFF":
            mem.duplex = "off"
            mem.offset = 0
        elif int(_mem.rxfreq) == int(_mem.txfreq):
            mem.duplex = ""
            mem.offset = 0
        else:
            mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
            mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10

        mem.mode = not _mem.narrow and "FM" or "NFM"

        mem.skip = _mem.skip and "S" or ""

        txtone = self._decode_tone(_mem.txtone)
        rxtone = self._decode_tone(_mem.rxtone)
        chirp_common.split_tone_decode(mem, txtone, rxtone)

        mem.extra = RadioSettingGroup("Extra", "extra")
        rs = RadioSetting("bcl", "Busy Channel Lockout",
                          RadioSettingValueBoolean(not _mem.bcl))
        mem.extra.append(rs)
        rs = RadioSetting("scramble", "Scramble",
                          RadioSettingValueBoolean(not _mem.scramble))
        mem.extra.append(rs)
        rs = RadioSetting("compander", "Compander",
                          RadioSettingValueBoolean(not _mem.compander))
        mem.extra.append(rs)

        return mem
Example #16
0
 def decode_sql(self, mem, chan):
     """
     examine the radio channel fields and determine the correct
     CHIRP CSV values for tmode, cross_mode, and sql_override
     """
     mem.extra = RadioSettingGroup("Extra", "extra")
     extra_modes = ["(None)", "PAGER"]
     value = extra_modes[chan.sql_type == 6]
     valuelist = RadioSettingValueList(extra_modes, value)
     rs = RadioSetting("sql_override", "Squelch override", valuelist)
     mem.extra.append(rs)
     if chan.sql_type == 6:
         return
     sql_map = RADIO_TMODES[chan.sql_type]
     ndx = 0
     if len(sql_map[0]) > 1:
         # the sql_type is TSQL or DCS, so there are multiple UI mappings
         x = getattr(chan, sql_map[1])
         r = getattr(chan, sql_map[2])
         ndx = self.LOOKUP.index([x == 0, r == 0])
         if ndx == 3 and x == r:
             ndx = 4
     mem.tmode = sql_map[0][ndx][0]
     cross = sql_map[0][ndx][1]
     if cross:
         mem.cross_mode = cross
     if chan.rx_ctcss:
         mem.ctone = TONE_MAP[chan.rx_ctcss]
     if chan.tx_ctcss:
         mem.rtone = TONE_MAP[chan.tx_ctcss]
     if chan.tx_dcs:
         mem.dtcs = DTCS_MAP[chan.tx_dcs]
     if chan.rx_dcs:
         mem.rx_dtcs = DTCS_MAP[chan.rx_dcs]
Example #17
0
 def get_settings(self):
     top = FT817Radio.get_settings(self)
     basic = top["basic"]
     rs = RadioSetting("emergency", "Emergency",
                       RadioSettingValueBoolean(self._memobj.settings.emergency))
     basic.append(rs)
     return top
Example #18
0
    def get_memory(self, number):
        if not self._repeaters:
            self.do_fetch()

        repeater = self._repeaters[number]

        mem = chirp_common.Memory()
        mem.number = number

        mem.name = repeater.get('city')
        mem.freq = chirp_common.parse_freq(repeater.get('frequency'))
        offset = chirp_common.parse_freq(repeater.get('offset', '0'))
        if offset > 0:
            mem.duplex = "+"
        elif offset < 0:
            mem.duplex = "-"
        else:
            mem.duplex = ""
        mem.offset = abs(offset)
        mem.mode = 'DMR'
        mem.comment = repeater.get('map_info')

        mem.extra = RadioSettingGroup("Extra", "extra")

        rs = RadioSetting(
            "color_code", "Color Code", RadioSettingValueList(
                range(16), int(repeater.get('color_code', 0))))
        mem.extra.append(rs)

        return mem
Example #19
0
 def get_prog(i, val_list, valndx, sname, longname, f_apply):
     k = str(i + 1)
     val = val_list[valndx]
     valuelist = RadioSettingValueList(val_list, val)
     rs = RadioSetting(sname + k, longname + k, valuelist)
     rs.set_apply_callback(f_apply, i, self._memobj)
     group.append(rs)
Example #20
0
def add_radio_setting(radio_setting_group, mem_field, ui_name, option_map,
                      current, doc=None):
    setting = RadioSetting(mem_field, ui_name,
                           RadioSettingValueMap(option_map, current))
    if doc is not None:
        setting.set_doc(doc)
    radio_setting_group.append(setting)
Example #21
0
    def get_settings(self):
        top = RadioSettings()

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

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

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

        return top
Example #22
0
    def _get_audio_settings(self):
        menu = RadioSettingGroup("audio", "Audio")
        audio_settings = self._memobj.settings

        val = RadioSettingValueList(
            self._AUDIO_BALANCE, self._AUDIO_BALANCE[audio_settings.balance])
        rs = RadioSetting("audio.balance", "Balance", val)
        rs.set_apply_callback(self.apply_balance, audio_settings)
        menu.append(rs)

        val = RadioSettingValueList(self._KEY_BEEP,
                                    self._KEY_BEEP[audio_settings.key_beep])
        rs = RadioSetting("audio.key_beep", "Key Beep", val)
        rs.set_apply_callback(self.apply_key_beep, audio_settings)
        menu.append(rs)

        return menu
Example #23
0
def make_speed_switch_setting(radio):
    if not radio.__class__._can_hispeed:
        return []
    drvopts = RadioSettingGroup("drvopts", "Driver Options")
    rs = RadioSetting("drv_clone_speed", "Use Hi-Speed Clone",
                      RadioSettingValueBoolean(radio._can_hispeed))
    drvopts.append(rs)
    return drvopts
Example #24
0
    def _get_battery_settings(self):
        menu = RadioSettingGroup("battery", "Battery")
        battery_settings = self._memobj.settings

        val = RadioSettingValueList(
            self._BATTERY_SAVER,
            self._BATTERY_SAVER[battery_settings.battery_saver])
        rs = RadioSetting("battery.battery_saver", "Battery Saver", val)
        rs.set_apply_callback(self.apply_battery_saver, battery_settings)
        menu.append(rs)

        val = RadioSettingValueList(self._APO, self._APO[battery_settings.APO])
        rs = RadioSetting("battery.APO", "Auto Power Off", val)
        rs.set_apply_callback(self.apply_APO, battery_settings)
        menu.append(rs)

        return menu
Example #25
0
    def get_settings(self):
        _settings = self._memobj.settings
        basic = RadioSettingGroup("basic", "Basic Settings")
        top = RadioSettings(basic)

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

        rs = RadioSetting(
            "settings.timeout", "Timeout Timer",
            RadioSettingValueList(TIMEOUT_LIST,
                                  TIMEOUT_LIST[_settings.timeout]))

        basic.append(rs)

        rs = RadioSetting(
            "settings.scanmode", "Scan Mode",
            RadioSettingValueList(SCANMODE_LIST,
                                  SCANMODE_LIST[_settings.scanmode]))
        basic.append(rs)

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

        rs = RadioSetting(
            "settings.voxgain", "VOX Level",
            RadioSettingValueList(VOX_LIST, VOX_LIST[_settings.voxgain]))
        basic.append(rs)

        rs = RadioSetting(
            "settings.voxdelay", "VOX Delay Time",
            RadioSettingValueList(VOXDELAY_LIST,
                                  VOXDELAY_LIST[_settings.voxdelay]))
        basic.append(rs)

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

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

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

        return top
Example #26
0
    def get_memory(self, number):
        _mem = self._memobj.memory[number]
        _flag = self._memobj.flags[number]
        mem = chirp_common.Memory()
        mem.number = number
        if _flag.empty:
            mem.empty = True
            return mem
        mult = int(TUNING_STEPS[_mem.tuning_step] * 1000)
        mem.freq = (_mem.frequency * mult)
        mem.offset = (_mem.offset * mult)
        mem.name = str(_mem.name).rstrip()
        mem.rtone = chirp_common.TONES[_mem.repeater_tone]
        mem.ctone = chirp_common.TONES[_mem.ctcss_tone]
        mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs_code]
        mem.tuning_step = TUNING_STEPS[_mem.tuning_step]
        mem.tmode = TONE_MODES[_mem.tone_mode]
        mem.mode = "NFM" if _mem.mode_narrow else "FM"
        mem.dtcs_polarity = DTCS_POLARITY[_mem.dtcs_polarity]
        mem.duplex = DUPLEX[_mem.duplex]
        mem.skip = "S" if _flag.skip else ""
        mem.power = POWER_LEVELS[_mem.power]

        # Reverse duplex
        mem.extra = RadioSettingGroup("extra", "Extra")
        rev = RadioSetting("reverse_duplex", "Reverse duplex",
                           RadioSettingValueBoolean(bool(_mem.reverse_duplex)))
        rev.set_doc("Reverse duplex")
        mem.extra.append(rev)

        # Tx inhibit
        tx_inhibit = RadioSetting(
            "tx_inhibit", "TX inhibit",
            RadioSettingValueBoolean(bool(_mem.tx_inhibit)))
        tx_inhibit.set_doc("TX inhibit")
        mem.extra.append(tx_inhibit)

        # Memory display style
        opt = ["Frequency", "Label"]
        dsp = RadioSetting("display_style", "Display style",
                           RadioSettingValueList(opt, opt[_mem.display_style]))
        dsp.set_doc("Memory display style")
        mem.extra.append(dsp)

        return mem
Example #27
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
Example #28
0
 def get_string_setting(self, obj, valid_chars, desc1, desc2, group):
     content = ''
     maxlen = len(obj)
     for x in range(0, maxlen):
         content += chr(obj[x])
     val = RadioSettingValueString(0, maxlen, content, True, valid_chars)
     rs = RadioSetting(desc1, desc2, val)
     rs.set_apply_callback(self.apply_str_to_bytearray, obj)
     group.append(rs)
Example #29
0
    def _get_aprs_smartbeacon(self):
        menu = RadioSettingGroup("aprs_smartbeacon", "APRS SmartBeacon")
        aprs = self._memobj.aprs

        val = RadioSettingValueList(
            self._SMARTBEACON_PROFILE,
            self._SMARTBEACON_PROFILE[aprs.active_smartbeaconing])
        rs = RadioSetting("aprs.active_smartbeaconing", "SmartBeacon profile",
                          val)
        menu.append(rs)

        for profile in range(3):
            pfx = "type%d" % (profile + 1)
            path = "aprs.smartbeaconing_profile[%d]" % profile
            prof = aprs.smartbeaconing_profile[profile]

            low_val = RadioSettingValueInteger(2, 30, prof.low_speed_mph)
            high_val = RadioSettingValueInteger(3, 70, prof.high_speed_mph)
            low_val.get_max = lambda: min(30, int(high_val.get_value()) - 1)

            rs = RadioSetting("%s.low_speed_mph" % path,
                              "%s Low Speed (mph)" % pfx, low_val)
            menu.append(rs)

            rs = RadioSetting("%s.high_speed_mph" % path,
                              "%s High Speed (mph)" % pfx, high_val)
            menu.append(rs)

            val = RadioSettingValueInteger(1, 100, prof.slow_rate_min)
            rs = RadioSetting("%s.slow_rate_min" % path,
                              "%s Slow rate (minutes)" % pfx, val)
            menu.append(rs)

            val = RadioSettingValueInteger(10, 180, prof.fast_rate_sec)
            rs = RadioSetting("%s.fast_rate_sec" % path,
                              "%s Fast rate (seconds)" % pfx, val)
            menu.append(rs)

            val = RadioSettingValueInteger(5, 90, prof.turn_angle)
            rs = RadioSetting("%s.turn_angle" % path,
                              "%s Turn angle (degrees)" % pfx, val)
            menu.append(rs)

            val = RadioSettingValueInteger(1, 255, prof.turn_slop)
            rs = RadioSetting("%s.turn_slop" % path, "%s Turn slop" % pfx, val)
            menu.append(rs)

            val = RadioSettingValueInteger(5, 180, prof.turn_time_sec)
            rs = RadioSetting("%s.turn_time_sec" % path,
                              "%s Turn time (seconds)" % pfx, val)
            menu.append(rs)

        return menu
Example #30
0
    def get_settings(self):
        _general = self._memobj.general
        _info = self._memobj.info

        basic = RadioSettingGroup("basic", "Basic")
        info = RadioSettingGroup("info", "Model Info")
        general = RadioSettingGroup("general", "General Settings")

        # top = RadioSettings(identity, basic)
        top = RadioSettings(general)
        general.append(RadioSetting(
            "dmrid", "DMR Radio ID",
            RadioSettingValueInteger(0, 100000000, _general.dmrid)))
        general.append(RadioSetting(
            "line1", "Startup Line 1",
            RadioSettingValueString(0, 10, utftoasc(str(_general.line1)))))
        general.append(RadioSetting(
            "line2", "Startup Line 2",
            RadioSettingValueString(0, 10, utftoasc(str(_general.line2)))))
        return top