def set_memory(self, mem): LOG.debug("Setting %i(%s)" % (mem.number, mem.extd_number)) _mem = self._memobj.channels[mem.number - 1] _nam = self._memobj.names[mem.number - 1] bitpos = (1 << ((mem.number - 1) % 8)) bytepos = ((mem.number - 1) / 8) _scn = self._memobj.scanflags[bytepos] _usd = self._memobj.usedflags[bytepos] if mem.empty: _mem.set_raw("\xFF" * 16) _nam.name = ("\xFF" * 7) _usd &= ~bitpos _scn &= ~bitpos return else: _usd |= bitpos if _mem.get_raw() == ("\xFF" * 16): LOG.debug("Initializing empty memory") _mem.set_raw("\x00" * 16) _scn |= bitpos _mem.rxfreq = mem.freq / 10 if mem.duplex == "off": for i in range(0, 4): _mem.txfreq[i].set_raw("\xFF") elif mem.duplex == "split": _mem.txfreq = mem.offset / 10 elif mem.duplex == "+": _mem.txfreq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.txfreq = (mem.freq - mem.offset) / 10 else: _mem.txfreq = mem.freq / 10 _namelength = self.get_features().valid_name_length for i in range(_namelength): try: _nam.name[i] = mem.name[i] except IndexError: _nam.name[i] = "\xFF" _mem.scan = mem.skip != "S" if mem.skip == "S": _scn &= ~bitpos else: _scn |= bitpos _mem.isnarrow = mem.mode == "NFM" ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \ chirp_common.split_tone_encode(mem) self.encode_tone(_mem.txtone, txmode, txtone, txpol) self.encode_tone(_mem.rxtone, rxmode, rxtone, rxpol) _mem.highpower = mem.power == RT23_POWER_LEVELS[1] for setting in mem.extra: setattr(_mem, setting.get_name(), setting.value)
def set_memory(self, mem): _mem, _name = self._get_memobjs(mem.number) if mem.empty: _mem.set_raw('\xFF' * 16) _name.set_raw('\xFF' * 7) return _mem.set_raw('\x00' * 16) _mem.rx_freq = mem.freq / 10 if mem.duplex == '-': mult = -1 elif not mem.duplex: mult = 0 else: mult = 1 _mem.tx_freq = (mem.freq + (mem.offset * mult)) / 10 (txmode, txval, txpol), (rxmode, rxval, rxpol) = \ chirp_common.split_tone_encode(mem) self._encode_tone(_mem.tx_tone, txmode, txval, txpol) self._encode_tone(_mem.rx_tone, rxmode, rxval, rxpol) _mem.narrow = mem.mode == 'NFM' _mem.scanadd = mem.skip != 'S' _mem.highpower = POWER_LEVELS.index(mem.power) if mem.power else 1 _name.name = mem.name.rstrip(' ').ljust(7, '\xFF')
def set_memory(self, mem): # Get a low-level memory object mapped to the image _mem = self._memobj.memory[mem.number - 1] if mem.empty: _mem.set_raw("\xFF" * (_mem.size() / 8)) return _mem.rxfreq = mem.freq / 10 if mem.duplex == "off": for i in range(0, 4): _mem.txfreq[i].set_raw("\xFF") elif mem.duplex == "split": _mem.txfreq = mem.offset / 10 elif mem.duplex == "+": _mem.txfreq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.txfreq = (mem.freq - mem.offset) / 10 else: _mem.txfreq = mem.freq / 10 txtone, rxtone = chirp_common.split_tone_encode(mem) self._encode_tone(_mem.txtone, *txtone) self._encode_tone(_mem.rxtone, *rxtone) _mem.narrow = 'N' in mem.mode _mem.highpower = mem.power == H777_POWER_LEVELS[1] _mem.skip = mem.skip == "S" for setting in mem.extra: # NOTE: Only two settings right now, both are inverted setattr(_mem, setting.get_name(), not int(setting.value))
def set_memory(self, mem): # Get a low-level memory object mapped to the image _mem = self._memobj.memory[mem.number - 1] if mem.empty: _mem.set_raw("\xFF" * (_mem.size() / 8)) return _mem.rxfreq = mem.freq / 10 if mem.duplex == "off": for i in range(0, 4): _mem.txfreq[i].set_raw("\xFF") elif mem.duplex == "split": _mem.txfreq = mem.offset / 10 elif mem.duplex == "+": _mem.txfreq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.txfreq = (mem.freq - mem.offset) / 10 else: _mem.txfreq = mem.freq / 10 txtone, rxtone = chirp_common.split_tone_encode(mem) self._encode_tone(_mem.txtone, *txtone) self._encode_tone(_mem.rxtone, *rxtone) _mem.narrow = 'N' in mem.mode _mem.highpower = mem.power == H777_POWER_LEVELS[1] _mem.skip = mem.skip == "S" for setting in mem.extra: # NOTE: Only two settings right now, both are inverted setattr(_mem, setting.get_name(), not setting.value)
def set_memory(self, mem): _mem = self._memobj.memory[mem.number - 1] if mem.empty: _mem.set_raw("\xFF" * (_mem.size() / 8)) return _mem.rxfreq = mem.freq / 10 if mem.duplex == "off": for i in range(0, 4): _mem.txfreq[i].set_raw("\xFF") elif mem.duplex == "split": _mem.txfreq = mem.offset / 10 elif mem.duplex == "+": _mem.txfreq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.txfreq = (mem.freq - mem.offset) / 10 else: _mem.txfreq = mem.freq / 10 _mem.wide = mem.mode == "FM" ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \ chirp_common.split_tone_encode(mem) self.encode_tone(_mem.txtone, txmode, txtone, txpol) self.encode_tone(_mem.rxtone, rxmode, rxtone, rxpol) _mem.highpower = mem.power == RT1_POWER_LEVELS[1] _mem.skip = mem.skip == "S" for setting in mem.extra: setattr(_mem, setting.get_name(), not int(setting.value))
def set_memory(self, mem): """Set the memory data in the eeprom img from the UI not ready yet, so it will return as is""" # Get a low-level memory object mapped to the image _mem = self._memobj.memory[mem.number - 1] # Empty memory if mem.empty: _mem.set_raw("\xFF" * 16) self.set_active(mem.number - 1, False) return # freq rx _mem.rxfreq = mem.freq / 10 # rx enabled if valid channel, # set tx to on, we decide if off after duplex = off _mem.rxen = 0 _mem.txen = 0 # freq tx if mem.duplex == "+": _mem.txfreq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.txfreq = (mem.freq - mem.offset) / 10 elif mem.duplex == "off": # set tx freq on the memap to xff for i in range(0, 4): _mem.txfreq[i].set_raw("\xFF") # erase the txen flag _mem.txen = 255 else: _mem.txfreq = mem.freq / 10 # tone data ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \ chirp_common.split_tone_encode(mem) self.encode_tone(_mem.tx_tone, txmode, txtone, txpol) self.encode_tone(_mem.rx_tone, rxmode, rxtone, rxpol) # power, default power is high, as the low is configurable via a key if mem.power is None: mem.power = POWER_LEVELS[1] _mem.power = POWER_LEVELS.index(mem.power) # skip self.set_scan(mem.number - 1, mem.skip) # set as active self.set_active(mem.number - 1, True) # extra settings for setting in mem.extra: setattr(_mem, setting.get_name(), setting.value) return mem
def set_memory(self, mem): """Set the memory data in the eeprom img from the UI not ready yet, so it will return as is""" # Get a low-level memory object mapped to the image _mem = self._memobj.memory[mem.number - 1] _tone = self._memobj.tone[mem.number - 1] _ch = self._memobj.ch_settings[mem.number - 1] # Empty memory if mem.empty: _mem.set_raw("\xFF" * 8) # empty the active bit self.set_active(mem.number - 1, False) return # freq rx _mem.rxfreq = mem.freq / 10 # freq tx if mem.duplex == "+": _mem.txfreq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.txfreq = (mem.freq - mem.offset) / 10 elif mem.duplex == "off": for byte in _mem.txfreq: byte.set_raw("\xFF") else: _mem.txfreq = mem.freq / 10 # tone data ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \ chirp_common.split_tone_encode(mem) self.encode_tone(_tone.tx_tone, txmode, txtone, txpol) self.encode_tone(_tone.rx_tone, rxmode, rxtone, rxpol) # power, default power is low if mem.power is None: mem.power = POWER_LEVELS[0] _ch.power = POWER_LEVELS.index(mem.power) # wide/marrow _ch.wide = MODES.index(mem.mode) # skip self.set_scan(mem.number - 1, mem.skip) # extra settings for setting in mem.extra: setattr(_mem, setting.get_name(), setting.value) # set the mem a active in the _memmap self.set_active(mem.number - 1) return mem
def set_memory(self, mem): # Get a low-level memory object mapped to the image _mem = self._memobj.memory[mem.number] cbyte = mem.number / 8 cbit = 7 - (mem.number % 8) if mem.empty: self._memobj.csetflag[cbyte].c[cbit] = 1 self._memobj.cskipflag[cbyte].c[cbit] = 1 return self._memobj.csetflag[cbyte].c[cbit] = 0 self._memobj.cskipflag[cbyte].c[cbit] = 1 if (mem.skip == "S") else 0 _mem.set_raw("\x00" * 32) _mem.freq = mem.freq / 100 # Convert to low-level frequency _mem.offset = mem.offset / 100 # Convert to low-level frequency _mem.name = mem.name.ljust(7)[:7] # Store the alpha tag _mem.duplex = DUPLEXES.index(mem.duplex) try: _mem.channel_width = MODES.index(mem.mode) except ValueError: _mem.channel_width = 0 ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = chirp_common.split_tone_encode(mem) _mem.txtmode = TMODES.index(txmode) _mem.rxtmode = TMODES.index(rxmode) if txmode == "Tone": _mem.txtone = TONES.index(txtone) elif txmode == "DTCS": self._set_dcs_index(_mem,'tx',chirp_common.ALL_DTCS_CODES.index(txtone)) if rxmode == "Tone": _mem.rxtone = TONES.index(rxtone) elif rxmode == "DTCS": self._set_dcs_index(_mem, 'rx', chirp_common.ALL_DTCS_CODES.index(rxtone)) _mem.txinv = txpol == "R" _mem.rxinv = rxpol == "R" if mem.power: _mem.power = POWER_LEVELS.index(mem.power) else: _mem.power = 0
def set_memory(self, mem): """Set the memory data in the eeprom img from the UI""" # get the eprom representation of this channel _mem = self._get_special(mem.number) # if empty memmory if mem.empty: # the channel itself _mem.set_raw("\xFF" * 16) # return it return mem # frequency _mem.rxfreq = mem.freq / 10 # duplex/ offset Offset is an absolute value _mem.txoffset = mem.offset / 10 # must work out the polarity if mem.duplex == "": _mem.offplus = 0 _mem.offminus = 0 elif mem.duplex == "+": _mem.offplus = 1 _mem.offminus = 0 elif mem.duplex == "-": _mem.offplus = 0 _mem.offminus = 1 elif mem.duplex == "split": if mem.freq > mem.offset: _mem.offplus = 0 _mem.offminus = 1 _mem.txoffset = (mem.freq - mem.offset) / 10 else: _mem.offplus = 1 _mem.offminus = 0 _mem.txoffset = (mem.offset - mem.freq) / 10 # wide/narrow _mem.wide = MODES.index(mem.mode) # skip _mem.noskip = SKIP_VALUES.index(mem.skip) # tone data ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \ chirp_common.split_tone_encode(mem) self._encode_tone(_mem.txtone, _mem.ttondinv, txmode, txtone, txpol) self._encode_tone(_mem.rxtone, _mem.rtondinv, rxmode, rxtone, rxpol) return mem
def _set_tone(self, mem, _mem): ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = chirp_common.split_tone_encode(mem) _mem.tx_tmode = TMODES.index(txmode) _mem.rx_tmode = TMODES.index(rxmode) if txmode == "Tone": _mem.tx_tone = TONES.index(txtone) + 1 elif txmode == "DTCS": _mem.tx_tmode = txpol == "R" and 0x03 or 0x02 _mem.tx_tone = DTCS_CODES.index(txtone) + 1 if rxmode == "Tone": _mem.rx_tone = TONES.index(rxtone) + 1 elif rxmode == "DTCS": _mem.rx_tmode = rxpol == "R" and 0x03 or 0x02 _mem.rx_tone = DTCS_CODES.index(rxtone) + 1
def set_memory(self, mem): bitpos = (1 << ((mem.number - 1) % 8)) bytepos = ((mem.number - 1) / 8) LOG.debug("bitpos %s" % bitpos) LOG.debug("bytepos %s" % bytepos) # Get a low-level memory object mapped to the image _mem = self._memobj.memory[mem.number - 1] if mem.empty: LOG.debug("initializing memory channel %d" % mem.number) _mem.set_raw(BLANK_MEMORY) if mem.empty: return _mem.rx_freq = mem.freq / 10 if mem.duplex == "off": for i in range(0, 4): _mem.tx_freq[i].set_raw("\xFF") elif mem.duplex == "+": _mem.tx_freq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.tx_freq = (mem.freq - mem.offset) / 10 else: _mem.tx_freq = mem.freq / 10 # power, default power is low if mem.power: _mem.power = POWER_LEVELS.index(mem.power) else: _mem.power = 0 # low # tone data ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \ chirp_common.split_tone_encode(mem) self.encode_tone(_mem.tx_tone, txmode, txtone, txpol) self.encode_tone(_mem.rx_tone, rxmode, rxtone, rxpol) _mem.mode = MODE_LIST.index(mem.mode) # extra settings are unfortunately inverted for setting in mem.extra: LOG.debug("@set_mem:", setting.get_name(), setting.value) setattr(_mem, setting.get_name(), not setting.value)
def set_memory(self, mem): _mem, _flg = self._get_memobjs(mem.number) if mem.empty: _flg.set() return _flg.clear() _mem.set_raw("\x00" * 32) _mem.freq = mem.freq / 100 _mem.offset = mem.offset / 100 _mem.name = mem.name.ljust(7) _mem.is_am = mem.mode == "AM" _mem.duplex = DUPLEXES.index(mem.duplex) try: _mem.channel_width = MODES.index(mem.mode) except ValueError: _mem.channel_width = 0 ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = chirp_common.split_tone_encode(mem) _mem.txtmode = TMODES.index(txmode) _mem.rxtmode = TMODES.index(rxmode) if txmode == "Tone": _mem.txtone = TONES.index(txtone) elif txmode == "DTCS": self._set_dcs_index(_mem, 'tx', chirp_common.ALL_DTCS_CODES.index(txtone)) if rxmode == "Tone": _mem.rxtone = TONES.index(rxtone) elif rxmode == "DTCS": self._set_dcs_index(_mem, 'rx', chirp_common.ALL_DTCS_CODES.index(rxtone)) _mem.txinv = txpol == "R" _mem.rxinv = rxpol == "R" _flg.set_skip(mem.skip == "S") _flg.set_pskip(mem.skip == "P") if mem.power: _mem.power = POWER_LEVELS.index(mem.power) else: _mem.power = 0
def set_memory(self, mem): _mem, _name = self._get_memobjs(mem.number) e = self._memobj.enable[(mem.number - 1) / 8] s = self._memobj.skip[(mem.number - 1) / 8] if mem.empty: _mem.set_raw("\xFF" * 32) e.flags[7 - ((mem.number - 1) % 8)] = False s.flags[7 - ((mem.number - 1) % 8)] = False return else: e.flags[7 - ((mem.number - 1) % 8)] = True if _mem.get_raw() == ("\xFF" * 32): LOG.debug("Initializing empty memory") _mem.set_raw("\x00" * 32) _mem.rx_freq = mem.freq / 10 if mem.duplex == "-": _mem.tx_freq = (mem.freq - mem.offset) / 10 elif mem.duplex == "+": _mem.tx_freq = (mem.freq + mem.offset) / 10 else: _mem.tx_freq = mem.freq / 10 _mem.duplex = THUVF8D_DUPLEX.index(mem.duplex) _mem.offset = mem.offset / 10 (txmode, txval, txpol), (rxmode, rxval, rxpol) = \ chirp_common.split_tone_encode(mem) self._encode_tone(_mem.tx_tone, txmode, txval, txpol) self._encode_tone(_mem.rx_tone, rxmode, rxval, rxpol) _mem.name = mem.name.rstrip(' ').ljust(7, "\xFF") flag_index = 7 - ((mem.number - 1) % 8) s.flags[flag_index] = (mem.skip == "") _mem.wideband = mem.mode == "FM" _mem.ishighpower = mem.power == POWER_LEVELS[0] for element in mem.extra: setattr(_mem, element.get_name(), element.value)
def set_memory(self, mem): _mem = self._memobj.memories[mem.number] _nam = self._memobj.names[mem.number] if mem.empty: _mem.set_raw(b'\xff' * 16) _nam.set_raw(b'\xff' * 16) return if int(_mem.rxfreq) == 166666665: LOG.debug('Initializing new memory %i' % mem.number) _mem.set_raw(b'\x00' * 16) _nam.name = mem.name.ljust(10) _mem.rxfreq = mem.freq // 10 if mem.duplex == '': _mem.txfreq = mem.freq // 10 elif mem.duplex == 'split': _mem.txfreq = mem.offset // 10 elif mem.duplex == 'off': _mem.txfreq.set_raw(b'\xff\xff\xff\xff') elif mem.duplex == '-': _mem.txfreq = (mem.freq - mem.offset) // 10 elif mem.duplex == '+': _mem.txfreq = (mem.freq + mem.offset) // 10 else: raise errors.RadioError('Unsupported duplex mode %r' % mem.duplex) txtone, rxtone = chirp_common.split_tone_encode(mem) LOG.debug('tx tone is %s' % repr(txtone)) LOG.debug('rx tone is %s' % repr(rxtone)) _mem.txtone = self._encode_tone(*txtone) _mem.rxtone = self._encode_tone(*rxtone) try: _mem.power = POWER_LEVELS.index(mem.power) except ValueError: _mem.power = 0 _mem.narrow = mem.mode == 'NFM' _mem.scan = mem.skip != 'S' if mem.extra: self._set_extra(_mem, mem)
def set_memory(self, mem): _mem, _nam = self._get_memobjs(mem.number) if mem.empty: if _nam is None: raise errors.InvalidValueError("VFO channels can not be empty") _mem.set_raw("\xFF" * 16) return if _mem.get_raw() == ("\xFF" * 16): _mem.set_raw("\x00" * 13 + "\xFF" * 3) _mem.freq = mem.freq / 10 if mem.duplex == "off": _mem.duplex = DUPLEX.index("-") _mem.offset = _mem.freq elif mem.duplex == "split": diff = mem.offset - mem.freq _mem.duplex = DUPLEX.index("-") if diff < 0 else DUPLEX.index("+") _mem.offset = abs(diff) / 10 else: _mem.offset = mem.offset / 10 _mem.duplex = DUPLEX.index(mem.duplex) tx, rx = chirp_common.split_tone_encode(mem) self._encode_tone(_mem, 'tx', *tx) self._encode_tone(_mem, 'rx', *rx) _mem.isnarrow = mem.mode == "NFM" _mem.scanadd = mem.skip == "" _mem.highpower = mem.power == POWER_LEVELS[1] if _nam: for i in range(0, 5): try: _nam[i] = CHARSET.index(mem.name[i]) except IndexError: _nam[i] = 0xFF for setting in mem.extra: setattr(_mem, setting.get_name(), setting.value)
def set_memory(self, mem): # Get a low-level memory object mapped to the image _mem = self._memobj.memory[mem.number - 1] if mem.empty: _mem.set_raw("\xFF" * (_mem.size() / 8)) return _mem.rxfreq = mem.freq / 10 if mem.duplex == "off": for i in range(0, 4): _mem.txfreq[i].set_raw("\xFF") elif mem.duplex == "split": _mem.txfreq = mem.offset / 10 elif mem.duplex == "+": _mem.txfreq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.txfreq = (mem.freq - mem.offset) / 10 else: _mem.txfreq = mem.freq / 10 txtone, rxtone = chirp_common.split_tone_encode(mem) self._encode_tone(_mem.txtone, *txtone) self._encode_tone(_mem.rxtone, *rxtone) _mem.narrow = 'N' in mem.mode _mem.highpower = mem.power == H777_POWER_LEVELS[1] _mem.skip = mem.skip == "S" for setting in mem.extra: # NOTE: Only two settings right now, both are inverted setattr(_mem, setting.get_name(), not int(setting.value)) # When set to one, official programming software (BF-480) shows always # "WFM", even if we choose "NFM". Therefore, for compatibility # purposes, we will set these to zero. _mem.unknown1 = 0 _mem.unknown2 = 0 _mem.unknown3 = 0
def set_memory(self, mem): _mem = self._memobj.memory[mem.number - 1] if mem.empty: _mem.set_raw("\xFF" * 16) return if _mem.get_raw() == ("\xFF" * 16): print "Initializing empty memory" _mem.set_raw("\x00" * 16) _mem.rx_freq = mem.freq / 10 if mem.duplex == "off": for i in range(0, 4): _mem.tx_freq[i].set_raw("\xFF") elif mem.duplex == "split": _mem.tx_freq = mem.offset / 10 elif mem.duplex == "-": _mem.tx_freq = (mem.freq - mem.offset) / 10 elif mem.duplex == "+": _mem.tx_freq = (mem.freq + mem.offset) / 10 else: _mem.tx_freq = mem.freq / 10 (txmode, txval, txpol), (rxmode, rxval, rxpol) = \ chirp_common.split_tone_encode(mem) self._encode_tone(_mem.tx_tone, txmode, txval, txpol) self._encode_tone(_mem.rx_tone, rxmode, rxval, rxpol) self._memobj.names[mem.number - 1].name = mem.name.ljust(7, "\xFF") _mem.scan = mem.skip == "" _mem.isnarrow = mem.mode == "NFM" _mem.ishighpower = mem.power == POWER_LEVELS[0] for element in mem.extra: setattr(_mem, element.get_name(), element.value)
def set_memory(self, memory): """Set the memory object @memory""" rmem = self._memobj.memory[memory.number - 1] if memory.empty: rmem.set_raw('\xFF' * (rmem.size() // 8)) return rmem.rxfreq = memory.freq / 10 set_txtone = True if memory.duplex == 'off': for i in range(0, 4): rmem.txfreq[i].set_raw('\xFF') # If recieve only then txtone value should be none self._encode_tone(rmem.txtone, mode='', value=None, pol=None) set_txtone = False elif memory.duplex == 'split': rmem.txfreq = memory.offset / 10 elif memory.duplex == '+': rmem.txfreq = (memory.freq + memory.offset) / 10 elif memory.duplex == '-': rmem.txfreq = (memory.freq - memory.offset) / 10 else: rmem.txfreq = memory.freq / 10 txtone, rxtone = chirp_common.split_tone_encode(memory) if set_txtone: self._encode_tone(rmem.txtone, *txtone) self._encode_tone(rmem.rxtone, *rxtone) rmem.narrow = 'N' in memory.mode rmem.skip = memory.skip == 'S' for setting in memory.extra: # NOTE: Only three settings right now, all are inverted setattr(rmem, setting.get_name(), not int(setting.value))
def set_memory(self, mem): _mem = self._memobj.memory[mem.number - 1] if mem.empty: _mem.set_raw("\xFF" * 16) return if _mem.get_raw() == ("\xFF" * 16): LOG.debug("Initializing empty memory") _mem.set_raw("\x00" * 16) _mem.rx_freq = mem.freq / 10 if mem.duplex == "off": for i in range(0, 4): _mem.tx_freq[i].set_raw("\xFF") elif mem.duplex == "split": _mem.tx_freq = mem.offset / 10 elif mem.duplex == "-": _mem.tx_freq = (mem.freq - mem.offset) / 10 elif mem.duplex == "+": _mem.tx_freq = (mem.freq + mem.offset) / 10 else: _mem.tx_freq = mem.freq / 10 (txmode, txval, txpol), (rxmode, rxval, rxpol) = \ chirp_common.split_tone_encode(mem) self._encode_tone(_mem.tx_tone, txmode, txval, txpol) self._encode_tone(_mem.rx_tone, rxmode, rxval, rxpol) self._memobj.names[mem.number - 1].name = mem.name.ljust(7, "\xFF") _mem.scan = mem.skip == "" _mem.isnarrow = mem.mode == "NFM" _mem.ishighpower = mem.power == POWER_LEVELS[0] for element in mem.extra: setattr(_mem, element.get_name(), element.value)
def set_memory(self, memory): """Set the memory object @memory""" rmem = self._memobj.memory[memory.number - 1] if memory.empty: rmem.set_raw('\xFF' * (rmem.size() / 8)) return rmem.rxfreq = memory.freq / 10 set_txtone = True if memory.duplex == 'off': for i in range(0, 4): rmem.txfreq[i].set_raw('\xFF') # If recieve only then txtone value should be none self._encode_tone(rmem.txtone, mode='', value=None, pol=None) set_txtone = False elif memory.duplex == 'split': rmem.txfreq = memory.offset / 10 elif memory.duplex == '+': rmem.txfreq = (memory.freq + memory.offset) / 10 elif memory.duplex == '-': rmem.txfreq = (memory.freq - memory.offset) / 10 else: rmem.txfreq = memory.freq / 10 txtone, rxtone = chirp_common.split_tone_encode(memory) if set_txtone: self._encode_tone(rmem.txtone, *txtone) self._encode_tone(rmem.rxtone, *rxtone) rmem.narrow = 'N' in memory.mode rmem.skip = memory.skip == 'S' for setting in memory.extra: # NOTE: Only three settings right now, all are inverted setattr(rmem, setting.get_name(), not int(setting.value))
def set_memory(self, mem): """Store details about a high-level memory to the memory map This is called when a user edits a memory in the UI""" # Get a low-level memory object mapped to the image _mem = self._memobj.memory[mem.number - 1] # Empty memory if mem.empty: _mem.set_raw("\xFF" * 16) return # freq rx _mem.rx_freq = mem.freq / 10 # freq tx if mem.duplex == "+": _mem.tx_freq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.tx_freq = (mem.freq - mem.offset) / 10 elif mem.duplex == "off": for i in range(0, 4): _mem.tx_freq[i].set_raw("\xFF") else: _mem.tx_freq = mem.freq / 10 # tone data ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \ chirp_common.split_tone_encode(mem) self._encode_tone(_mem.tx_tone, txmode, txtone, txpol) self._encode_tone(_mem.rx_tone, rxmode, rxtone, rxpol) # extra settings for setting in mem.extra: setattr(_mem, setting.get_name(), setting.value) return mem
def set_memory(self, mem): _mem, _flg = self._get_memobjs(mem.number) if mem.empty: _flg.set() return _flg.clear() _mem.set_raw("\x00" * 32) _mem.freq = mem.freq / 100 _mem.offset = mem.offset / 100 _mem.name = mem.name.ljust(7) _mem.is_am = mem.mode == "AM" _mem.tune_step = TUNING_STEPS.index(mem.tuning_step) if mem.duplex == "off": _mem.duplex = DUPLEXES.index("") _mem.txoff = 1 else: _mem.duplex = DUPLEXES.index(mem.duplex) _mem.txoff = 0 try: _mem.channel_width = MODES.index(mem.mode) except ValueError: _mem.channel_width = 0 ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = chirp_common.split_tone_encode(mem) _mem.txtmode = TMODES.index(txmode) _mem.rxtmode = TMODES.index(rxmode) if rxmode != '': _mem.sqlMode = SQL_MODES.index("CTCSS/DCS") else: _mem.sqlMode = SQL_MODES.index("Carrier") if txmode == "Tone": _mem.txtone = TONES.index(txtone) elif txmode == "DTCS": self._set_dcs_index(_mem, 'tx', chirp_common.ALL_DTCS_CODES.index(txtone)) if rxmode == "Tone": _mem.rxtone = TONES.index(rxtone) elif rxmode == "DTCS": self._set_dcs_index(_mem, 'rx', chirp_common.ALL_DTCS_CODES.index(rxtone)) _mem.txinv = txpol == "R" _mem.rxinv = rxpol == "R" _flg.set_skip(mem.skip == "S") _flg.set_pskip(mem.skip == "P") if mem.power: _mem.power = POWER_LEVELS.index(mem.power) else: _mem.power = 0 for setting in mem.extra: if setting.get_name() == "ignore": LOG.debug("*** ignore: %s" % str(setting.value)) # Future: elif setting.get_name() == "custtone": Future: # setattr(_mem, "custtone", setting.value.get_value() * # 10) elif setting.get_name() == "OPTSIGSQL": if str(setting.value) != "Off": _mem.sqlMode = SQL_MODES.index(str(setting.value)) elif setting.get_name() == "CUSTTONETX": if setting.value: _mem.txtone = len(TONES) elif setting.get_name() == "CUSTTONERX": if setting.value: _mem.rxtone = len(TONES) else: setattr(_mem, setting.get_name(), setting.value) return mem
def set_memory(self, mem): bitpos = (1 << (mem.number % 8)) bytepos = (mem.number / 8) _mem = self._memobj.memory[mem.number] _skp = self._memobj.skip_flags[bytepos] _usd = self._memobj.used_flags[bytepos] if mem.empty: _usd |= bitpos _skp |= bitpos _mem.set_raw("\xFF" * 32) return _usd &= ~bitpos if _mem.get_raw() == ("\xFF" * 32): LOG.debug("Initializing empty memory") _mem.set_raw("\x00" * 32) _mem.squelch = 3 _mem.freq = mem.freq / 100 if mem.duplex == "off": _mem.duplex = DUPLEXES.index("") _mem.offset = 0 _mem.tx_off = True elif mem.duplex == "split": diff = mem.offset - mem.freq _mem.duplex = DUPLEXES.index("-") if diff < 0 \ else DUPLEXES.index("+") _mem.offset = abs(diff) / 100 else: _mem.offset = mem.offset / 100 _mem.duplex = DUPLEXES.index(mem.duplex) _mem.name = mem.name.ljust(6) try: _mem.channel_width = MODES.index(mem.mode) except ValueError: _mem.channel_width = 0 ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = chirp_common.split_tone_encode(mem) _mem.txtmode = TMODES.index(txmode) _mem.rxtmode = TMODES.index(rxmode) if txmode == "Tone": _mem.txtone = TONES.index(txtone) elif txmode == "DTCS": self._set_dcs_index(_mem, 'tx', chirp_common.ALL_DTCS_CODES.index(txtone)) if rxmode == "Tone": _mem.sqlmode = 1 _mem.rxtone = TONES.index(rxtone) elif rxmode == "DTCS": _mem.sqlmode = 1 self._set_dcs_index(_mem, 'rx', chirp_common.ALL_DTCS_CODES.index(rxtone)) else: _mem.sqlmode = 0 _mem.txinv = txpol == "R" _mem.rxinv = rxpol == "R" if mem.skip: _skp |= bitpos else: _skp &= ~bitpos if mem.power: _mem.power = POWER_LEVELS.index(mem.power) else: _mem.power = 0 for setting in mem.extra: setattr(_mem, setting.get_name(), setting.value)
def set_memory(self, mem): _mem = self._get_raw_memory(mem.number) if _mem is None: LOG.debug('Need to expand zone %i' % self._zone) # Calculate the new zone sizes and remap memory new_zones = [x[1] for x in self._parent._zones] new_zones[self._zone] = new_zones[self._zone] + 1 self._parent.expand_mmap(new_zones) # Assign the new memory (at the end) to the desired # number _mem = self.raw_memories[self.raw_zoneinfo.count - 1] _mem.number = mem.number # Sort the memory into place self.shuffle_zone() # Now find it in the right spot _mem = self._get_raw_memory(mem.number) if _mem is None: raise errors.RadioError('Internal error after ' 'memory allocation') # Default values for unknown things _mem.unknown1[0] = 0x36 _mem.unknown1[1] = 0x36 _mem.unknown2 = [0xFF for i in range(0, 19)] _mem.unknown3_1 = 0xF _mem.unknown3_2 = 0x1 _mem.unknown3_3 = 0x0 _mem.unknown4 = 0xFF if mem.empty: LOG.debug('Need to shrink zone %i' % self._zone) # Make the memory sort to the end, and sort the zone _mem.number = 0xFF self.shuffle_zone() # Calculate the new zone sizes and remap memory new_zones = [x[1] for x in self._parent._zones] new_zones[self._zone] = new_zones[self._zone] - 1 self._parent.expand_mmap(new_zones) return _mem.name = mem.name[:12].encode().rstrip().ljust(12, b'\x00') _mem.rx_freq = mem.freq // 10 txtone, rxtone = chirp_common.split_tone_encode(mem) _mem.tx_tone = self._encode_tone(*txtone) _mem.rx_tone = self._encode_tone(*rxtone) _mem.wide = mem.mode == 'FM' _mem.highpower = mem.power == POWER_LEVELS[1] if mem.duplex == '': _mem.tx_freq = mem.freq // 10 elif mem.duplex == 'split': _mem.tx_freq = mem.offset // 10 elif mem.duplex == 'off': _mem.tx_freq.set_raw(b'\xff\xff\xff\xff') elif mem.duplex == '-': _mem.tx_freq = (mem.freq - mem.offset) // 10 elif mem.duplex == '+': _mem.tx_freq = (mem.freq + mem.offset) // 10 else: raise errors.RadioError('Unsupported duplex mode %r' % mem.duplex) skipbyte = self._memobj.skipflags[(mem.number - 1) // 8] if mem.skip == 'S': skipbyte |= (1 << (mem.number - 1) % 8) else: skipbyte &= ~(1 << (mem.number - 1) % 8)
def set_memory(self, mem): """Set the memory data in the eeprom img from the UI""" bitpos = (1 << (mem.number % 8)) bytepos = (mem.number / 8) _mem = self._memory_obj()[mem.number] _names = self._name_obj()[mem.number] _scn = self._scan_obj()[bytepos] _usd = self._used_obj()[bytepos] if mem.empty: _usd &= ~bitpos _scn &= ~bitpos _mem.set_raw("\xFF" * 16) _names.name = ("\xFF" * 6) return else: _usd |= bitpos # frequency _mem.rxfreq = mem.freq / 10 # duplex if mem.duplex == "+": _mem.txfreq = (mem.freq + mem.offset) / 10 elif mem.duplex == "-": _mem.txfreq = (mem.freq - mem.offset) / 10 elif mem.duplex == "off": for i in _mem.txfreq: i.set_raw("\xFF") elif mem.duplex == "split": _mem.txfreq = mem.offset / 10 else: _mem.txfreq = mem.freq / 10 # tone data ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \ chirp_common.split_tone_encode(mem) self.encode_tone(_mem.txtone, txmode, txtone, txpol) self.encode_tone(_mem.rxtone, rxmode, rxtone, rxpol) # name TAG of the channel _names.name = mem.name.ljust(6, "\xFF") # power level, # default power level is low _mem.txp = 0 if mem.power is None else POWER_LEVELS.index(mem.power) # wide/narrow _mem.wn = MODES.index(mem.mode) if mem.skip == "S": _scn &= ~bitpos else: _scn |= bitpos # autoset display to display name if filled if mem.extra: # mem.extra only seems to be populated when called from edit panel dname = mem.extra["dname"] else: dname = None if mem.name: _mem.dname = True if dname and not dname.changed(): dname.value = True else: _mem.dname = False if dname and not dname.changed(): dname.value = False # reseting unknowns, this has to be set by hand _mem.unknown0 = 0 _mem.unknown1 = 0 _mem.unknown2 = 0 _mem.unknown3 = 0 # extra settings if len(mem.extra) > 0: # there are setting, parse for setting in mem.extra: setattr(_mem, setting.get_name(), setting.value) else: # there are no extra settings, load defaults _mem.bcl = 0 _mem.revert = 0 _mem.dname = 1
def _set_mem(self, **vals): mem = chirp_common.Memory() for key, value in vals.items(): setattr(mem, key, value) return chirp_common.split_tone_encode(mem)