# HG changeset patch # User Jim Unroe rock.unroe@gmail.com # Date 1555769090 14400 # Node ID 9ba00d6aadb6e8f923a634470d93770d999f6619 # Parent 3252700cd985992b99c3fb7dd23301f4581c3c3a Driver Cleanup: btech.py
1. add btech.py to PEP8 manifest 2. make ptech.py compliant with PEP8
related to #6733
diff -r 3252700cd985 -r 9ba00d6aadb6 chirp/drivers/btech.py --- a/chirp/drivers/btech.py Thu Apr 11 10:34:31 2019 -0700 +++ b/chirp/drivers/btech.py Sat Apr 20 10:04:50 2019 -0400 @@ -19,8 +19,6 @@ import struct import logging
-LOG = logging.getLogger(__name__) - from time import sleep from chirp import chirp_common, directory, memmap from chirp import bitwise, errors, util @@ -30,6 +28,8 @@ RadioSettingValueFloat, RadioSettings, InvalidValueError from textwrap import dedent
+LOG = logging.getLogger(__name__) + # A note about the memmory in these radios # # The real memory of these radios extends to 0x4000 @@ -109,9 +109,9 @@ LIST_DTMF_DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "#", "*"] LIST_DTMF_VALUES = [0x0A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, - 0x0D, 0x0E, 0x0F, 0x00, 0x0C, 0x0B ] -LIST_DTMF_SPECIAL_DIGITS = [ "*", "#", "A", "B", "C", "D"] -LIST_DTMF_SPECIAL_VALUES = [ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00] + 0x0D, 0x0E, 0x0F, 0x00, 0x0C, 0x0B] +LIST_DTMF_SPECIAL_DIGITS = ["*", "#", "A", "B", "C", "D"] +LIST_DTMF_SPECIAL_VALUES = [0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00] LIST_DTMF_DELAY = ["%s ms" % x for x in range(100, 4100, 100)] CHARSET_DTMF_DIGITS = "0123456789AaBbCcDd#*" LIST_2TONE_DEC = ["A-B", "A-C", "A-D", @@ -133,7 +133,7 @@ "`{|}!"#$%&'()*+,-./:;<=>?@[]^_"
-##### ID strings ##################################################### +# #### ID strings #####################################################
# BTECH UV2501 pre-production units UV2501pp_fp = "M2C294" @@ -230,7 +230,7 @@ LT588UV_fp1 = "V2G214"
-#### MAGICS +# ### MAGICS # for the Waccom Mini-8900 MSTRING_MINI8900 = "\x55\xA5\xB5\x45\x55\x45\x4d\x02" # for the B-TECH UV-2501+220 (including pre production ones) @@ -314,7 +314,7 @@ # hits some models more than others. # # To cope with that we introduce a delay on the writes. - # Many option have been tested (delaying only after error occures, + # Many option have been tested (delaying only after error occures, # after short reads, only for linux, ...) # Finally, a static delay was chosen as simplest of all solutions # (Michael Wagner, OE4AMW) @@ -471,7 +471,7 @@
if not flag2: LOG.debug("Full *BAD* extra ID on the %s is: \n%s" % - (radio.MODEL, util.hexprint(id2))) + (radio.MODEL, util.hexprint(id2))) raise errors.RadioError("The extra ID is wrong, aborting.")
# this radios need a extra request/answer here on the upload @@ -606,10 +606,10 @@ if len(ack) != 1: raise errors.RadioError("No ACK when writing block 0x%04x" % addr)
- if not ack in "\x06\x05": + if ack not in "\x06\x05": raise errors.RadioError("Bad ACK writing block 0x%04x:" % addr)
- # UI Update + # UI Update status.cur = addr / TX_BLOCK_SIZE status.msg = "Cloning to radio..." radio.status_fn(status) @@ -846,7 +846,8 @@ # TX freq set offset = (int(_mem.txfreq) * 10) - mem.freq if offset != 0: - if _split(self.get_features(), mem.freq, int(_mem.txfreq) * 10): + if _split(self.get_features(), mem.freq, int( + _mem.txfreq) * 10): mem.duplex = "split" mem.offset = int(_mem.txfreq) * 10 elif offset < 0: @@ -880,7 +881,7 @@ mem.extra = RadioSettingGroup("extra", "Extra")
if not self.COLOR_LCD or \ - (self.COLOR_LCD and not self.VENDOR == "BTECH"): + (self.COLOR_LCD and not self.VENDOR == "BTECH"): scramble = RadioSetting("scramble", "Scramble", RadioSettingValueBoolean(bool( _mem.scramble))) @@ -929,7 +930,7 @@ if _mem.get_raw()[0] == "\xFF": LOG.debug("This mem was empty before") mem_was_empty = True - + # if empty memmory if mem.empty: # the channel itself @@ -1064,7 +1065,7 @@ else: toa = RadioSetting("settings.apo", "Time out alert timer", RadioSettingValueList( - LIST_OFF1TO10, + LIST_OFF1TO10, LIST_OFF1TO10[_mem.settings.apo])) basic.append(toa)
@@ -1092,7 +1093,7 @@
prich = RadioSetting("settings.prich", "Priority channel", RadioSettingValueInteger(0, 199, - _mem.settings.prich)) + _mem.settings.prich)) basic.append(prich)
screv = RadioSetting("settings.screv", "Scan resume method", @@ -1103,7 +1104,7 @@
pttlt = RadioSetting("settings.pttlt", "PTT transmit delay", RadioSettingValueInteger(0, 30, - _mem.settings.pttlt)) + _mem.settings.pttlt)) basic.append(pttlt)
if self.VENDOR == "BTECH" and self.COLOR_LCD: @@ -1121,7 +1122,7 @@
emcch = RadioSetting("settings.emcch", "Alarm channel", RadioSettingValueInteger(0, 199, - _mem.settings.emcch)) + _mem.settings.emcch)) basic.append(emcch)
if self.COLOR_LCD: @@ -1196,18 +1197,18 @@ basic.append(ponmsg)
if self.COLOR_LCD: - mainfc = RadioSetting("settings.mainfc", + mainfc = RadioSetting("settings.mainfc", "Main LCD foreground color", - RadioSettingValueList( - LIST_COLOR8, - LIST_COLOR8[_mem.settings.mainfc])) + RadioSettingValueList( + LIST_COLOR8, + LIST_COLOR8[_mem.settings.mainfc])) basic.append(mainfc)
mainbc = RadioSetting("settings.mainbc", "Main LCD background color", - RadioSettingValueList( - LIST_COLOR8, - LIST_COLOR8[_mem.settings.mainbc])) + RadioSettingValueList( + LIST_COLOR8, + LIST_COLOR8[_mem.settings.mainbc])) basic.append(mainbc)
menufc = RadioSetting("settings.menufc", "Menu foreground color", @@ -1224,30 +1225,30 @@
stafc = RadioSetting("settings.stafc", "Top status foreground color", - RadioSettingValueList( - LIST_COLOR8, - LIST_COLOR8[_mem.settings.stafc])) + RadioSettingValueList( + LIST_COLOR8, + LIST_COLOR8[_mem.settings.stafc])) basic.append(stafc)
stabc = RadioSetting("settings.stabc", "Top status background color", - RadioSettingValueList( - LIST_COLOR8, - LIST_COLOR8[_mem.settings.stabc])) + RadioSettingValueList( + LIST_COLOR8, + LIST_COLOR8[_mem.settings.stabc])) basic.append(stabc)
sigfc = RadioSetting("settings.sigfc", "Bottom status foreground color", - RadioSettingValueList( - LIST_COLOR8, - LIST_COLOR8[_mem.settings.sigfc])) + RadioSettingValueList( + LIST_COLOR8, + LIST_COLOR8[_mem.settings.sigfc])) basic.append(sigfc)
sigbc = RadioSetting("settings.sigbc", "Bottom status background color", - RadioSettingValueList( - LIST_COLOR8, - LIST_COLOR8[_mem.settings.sigbc])) + RadioSettingValueList( + LIST_COLOR8, + LIST_COLOR8[_mem.settings.sigbc])) basic.append(sigbc)
rxfc = RadioSetting("settings.rxfc", "Receiving character color", @@ -1258,16 +1259,16 @@
txfc = RadioSetting("settings.txfc", "Transmitting character color", - RadioSettingValueList( - LIST_COLOR8, - LIST_COLOR8[_mem.settings.txfc])) + RadioSettingValueList( + LIST_COLOR8, + LIST_COLOR8[_mem.settings.txfc])) basic.append(txfc)
txdisp = RadioSetting("settings.txdisp", "Transmitting status display", - RadioSettingValueList( - LIST_TXDISP, - LIST_TXDISP[_mem.settings.txdisp])) + RadioSettingValueList( + LIST_TXDISP, + LIST_TXDISP[_mem.settings.txdisp])) basic.append(txdisp) else: wtled = RadioSetting("settings.wtled", "Standby backlight Color", @@ -1316,7 +1317,7 @@ else: tdrab = RadioSetting("settings.tdrab", "TDR return time", RadioSettingValueList( - LIST_OFF1TO50, + LIST_OFF1TO50, LIST_OFF1TO50[_mem.settings.tdrab])) basic.append(tdrab)
@@ -1339,19 +1340,19 @@ if str(_mem.fingerprint.fp) in BTECH3: mgain = RadioSetting("settings.mgain", "Mic gain", RadioSettingValueInteger(0, 120, - _mem.settings.mgain)) + _mem.settings.mgain)) basic.append(mgain)
if str(_mem.fingerprint.fp) in BTECH3 or self.COLOR_LCD: dtmfg = RadioSetting("settings.dtmfg", "DTMF gain", RadioSettingValueInteger(0, 60, - _mem.settings.dtmfg)) + _mem.settings.dtmfg)) basic.append(dtmfg)
if self.VENDOR == "BTECH" and self.COLOR_LCD: mgain = RadioSetting("settings.mgain", "Mic gain", RadioSettingValueInteger(0, 120, - _mem.settings.mgain)) + _mem.settings.mgain)) basic.append(mgain)
skiptx = RadioSetting("settings.skiptx", "Skip TX", @@ -1380,53 +1381,53 @@ if self.COLOR_LCD: line1 = RadioSetting("poweron_msg.line1", "Power-on message line 1", - RadioSettingValueString(0, 8, _filter( - _msg.line1))) + RadioSettingValueString(0, 8, _filter( + _msg.line1))) advanced.append(line1) line2 = RadioSetting("poweron_msg.line2", "Power-on message line 2", - RadioSettingValueString(0, 8, _filter( - _msg.line2))) + RadioSettingValueString(0, 8, _filter( + _msg.line2))) advanced.append(line2) line3 = RadioSetting("poweron_msg.line3", "Power-on message line 3", - RadioSettingValueString(0, 8, _filter( - _msg.line3))) + RadioSettingValueString(0, 8, _filter( + _msg.line3))) advanced.append(line3) line4 = RadioSetting("poweron_msg.line4", "Power-on message line 4", - RadioSettingValueString(0, 8, _filter( - _msg.line4))) + RadioSettingValueString(0, 8, _filter( + _msg.line4))) advanced.append(line4) line5 = RadioSetting("poweron_msg.line5", "Power-on message line 5", - RadioSettingValueString(0, 8, _filter( - _msg.line5))) + RadioSettingValueString(0, 8, _filter( + _msg.line5))) advanced.append(line5) line6 = RadioSetting("poweron_msg.line6", "Power-on message line 6", - RadioSettingValueString(0, 8, _filter( - _msg.line6))) + RadioSettingValueString(0, 8, _filter( + _msg.line6))) advanced.append(line6) line7 = RadioSetting("poweron_msg.line7", "Power-on message line 7", - RadioSettingValueString(0, 8, _filter( - _msg.line7))) + RadioSettingValueString(0, 8, _filter( + _msg.line7))) advanced.append(line7) line8 = RadioSetting("poweron_msg.line8", "Static message", RadioSettingValueString(0, 8, _filter( - _msg.line8))) + _msg.line8))) advanced.append(line8) else: line1 = RadioSetting("poweron_msg.line1", "Power-on message line 1", - RadioSettingValueString(0, 6, _filter( - _msg.line1))) + RadioSettingValueString(0, 6, _filter( + _msg.line1))) advanced.append(line1) line2 = RadioSetting("poweron_msg.line2", "Power-on message line 2", - RadioSettingValueString(0, 6, _filter( - _msg.line2))) + RadioSettingValueString(0, 6, _filter( + _msg.line2))) advanced.append(line2)
if self.MODEL in ("UV-2501", "UV-5001"): @@ -1517,7 +1518,6 @@ fp = RadioSetting("fingerprint.fp", "Fingerprint", val) other.append(fp)
- # Work if self.COLOR_LCD: dispab = RadioSetting("settings2.dispab", "Display", @@ -1563,30 +1563,30 @@ LIST_VFOMR[_mem.settings2.vfomr])) work.append(vfomr)
- keylock = RadioSetting("settings2.keylock", "Keypad lock", - RadioSettingValueBoolean(_mem.settings2.keylock)) + RadioSettingValueBoolean( + _mem.settings2.keylock)) work.append(keylock)
mrcha = RadioSetting("settings2.mrcha", "MR A channel", RadioSettingValueInteger(0, 199, - _mem.settings2.mrcha)) + _mem.settings2.mrcha)) work.append(mrcha)
mrchb = RadioSetting("settings2.mrchb", "MR B channel", RadioSettingValueInteger(0, 199, - _mem.settings2.mrchb)) + _mem.settings2.mrchb)) work.append(mrchb)
if self.COLOR_LCD: mrchc = RadioSetting("settings2.mrchc", "MR C channel", - RadioSettingValueInteger(0, 199, - _mem.settings2.mrchc)) + RadioSettingValueInteger( + 0, 199, _mem.settings2.mrchc)) work.append(mrchc)
mrchd = RadioSetting("settings2.mrchd", "MR D channel", - RadioSettingValueInteger(0, 199, - _mem.settings2.mrchd)) + RadioSettingValueInteger( + 0, 199, _mem.settings2.mrchd)) work.append(mrchd)
def convert_bytes_to_freq(bytes): @@ -1614,24 +1614,24 @@ msg = ("Can't be betweeb %i.9975-%i.0000") if self.BANDS == 2: if (_vhf_upper + 1) * 1000000 <= value and \ - value < _uhf_lower * 1000000: + value < _uhf_lower * 1000000: raise InvalidValueError(msg % (_vhf_upper, _uhf_lower)) if self.BANDS == 3: if (_vhf_upper + 1) * 1000000 <= value and \ - value < _vhf2_lower * 1000000: + value < _vhf2_lower * 1000000: raise InvalidValueError(msg % (_vhf_upper, _vhf2_lower)) if (_vhf2_upper + 1) * 1000000 <= value and \ - value < _uhf_lower * 1000000: + value < _uhf_lower * 1000000: raise InvalidValueError(msg % (_vhf2_upper, _uhf_lower)) if self.BANDS == 4: if (_vhf_upper + 1) * 1000000 <= value and \ - value < _vhf2_lower * 1000000: + value < _vhf2_lower * 1000000: raise InvalidValueError(msg % (_vhf_upper, _vhf2_lower)) if (_vhf2_upper + 1) * 1000000 <= value and \ - value < _uhf2_lower * 1000000: + value < _uhf2_lower * 1000000: raise InvalidValueError(msg % (_vhf2_upper, _uhf2_lower)) if (_uhf2_upper + 1) * 1000000 <= value and \ - value < _uhf_lower * 1000000: + value < _uhf_lower * 1000000: raise InvalidValueError(msg % (_uhf2_upper, _uhf_lower)) msg = ("Can't be greater then %i.9975") if value > 99000000 and value >= _uhf_upper * 1000000: @@ -1753,7 +1753,6 @@ vfoboffset.set_apply_callback(apply_offset, _mem.vfo.b) work.append(vfoboffset)
- vfoatxp = RadioSetting("vfo.a.power", "VFO A power", RadioSettingValueList( LIST_TXP, @@ -1880,7 +1879,7 @@ work.append(vfodspmute)
if not self.COLOR_LCD or \ - (self.COLOR_LCD and not self.VENDOR == "BTECH"): + (self.COLOR_LCD and not self.VENDOR == "BTECH"): vfoascr = RadioSetting("vfo.a.scramble", "VFO A scramble", RadioSettingValueBoolean( _mem.vfo.a.scramble)) @@ -1934,7 +1933,7 @@ work.append(pttid)
if not self.COLOR_LCD: - #FM presets + # FM presets fm_presets = RadioSettingGroup("fm_presets", "FM Presets") top.append(fm_presets)
@@ -1942,13 +1941,14 @@ if value == 0: return chirp_common.format_freq(value) if not (87.5 <= value and value <= 108.0): # 87.5-108MHz - msg = ("FM-Preset-Frequency: Must be between 87.5 and 108 MHz") + msg = ("FM-Preset-Frequency: " + + "Must be between 87.5 and 108 MHz") raise InvalidValueError(msg) return value
def apply_fm_preset_name(setting, obj): - valstring = str (setting.value) - for i in range(0,6): + valstring = str(setting.value) + for i in range(0, 6): if valstring[i] in VALID_CHARS: obj[i] = valstring[i] else: @@ -1959,43 +1959,43 @@ for i in range(7, -1, -1): obj.freq[i] = value % 10 value /= 10 - + _presets = self._memobj.fm_radio_preset i = 1 for preset in _presets: - line = RadioSetting("fm_presets_"+ str(i), + line = RadioSetting("fm_presets_" + str(i), "Station name " + str(i), - RadioSettingValueString(0, 6, _filter( - preset.broadcast_station_name))) - line.set_apply_callback(apply_fm_preset_name, + RadioSettingValueString(0, 6, _filter( + preset.broadcast_station_name))) + line.set_apply_callback(apply_fm_preset_name, preset.broadcast_station_name) - + val = RadioSettingValueFloat(0, 108, convert_bytes_to_freq( preset.freq)) - fmfreq = RadioSetting("fm_presets_"+ str(i) + "_freq", - "Frequency "+ str(i), val) + fmfreq = RadioSetting("fm_presets_" + str(i) + "_freq", + "Frequency " + str(i), val) val.set_validate_callback(fm_validate) fmfreq.set_apply_callback(apply_fm_freq, preset) fm_presets.append(line) fm_presets.append(fmfreq) - + i = i + 1
- # DTMF-Setting - dtmf_enc_settings = RadioSettingGroup ("dtmf_enc_settings", - "DTMF Encoding Settings") - dtmf_dec_settings = RadioSettingGroup ("dtmf_dec_settings", - "DTMF Decoding Settings") + # DTMF-Setting + dtmf_enc_settings = RadioSettingGroup("dtmf_enc_settings", + "DTMF Encoding Settings") + dtmf_dec_settings = RadioSettingGroup("dtmf_dec_settings", + "DTMF Decoding Settings") top.append(dtmf_enc_settings) top.append(dtmf_dec_settings) - txdisable = RadioSetting("dtmf_settings.txdisable", + txdisable = RadioSetting("dtmf_settings.txdisable", "TX-Disable", RadioSettingValueBoolean( _mem.dtmf_settings.txdisable)) dtmf_enc_settings.append(txdisable)
- rxdisable = RadioSetting("dtmf_settings.rxdisable", + rxdisable = RadioSetting("dtmf_settings.rxdisable", "RX-Disable", RadioSettingValueBoolean( _mem.dtmf_settings.rxdisable)) @@ -2026,22 +2026,22 @@ return dtmf_string
def apply_dmtf_frame(setting, obj): - LOG.debug("Setting DTMF-Code: " + str(setting.value) ) + LOG.debug("Setting DTMF-Code: " + str(setting.value)) val_string = str(setting.value) - for i in range(0,16): + for i in range(0, 16): obj[i] = 255 i = 0 for current_char in val_string: current_char = current_char.upper() index = LIST_DTMF_DIGITS.index(current_char) - obj[i] = LIST_DTMF_VALUES[ index ] + obj[i] = LIST_DTMF_VALUES[index] i = i + 1
codes = self._memobj.dtmf_codes i = 1 for dtmfcode in codes: - val = RadioSettingValueString(0, 16, - memory2string(dtmfcode.code), + val = RadioSettingValueString(0, 16, memory2string( + dtmfcode.code), False, CHARSET_DTMF_DIGITS) line = RadioSetting("dtmf_code_" + str(i) + "_code", "DMTF Code " + str(i), val) @@ -2049,146 +2049,138 @@ dtmf_enc_settings.append(line) i = i + 1
- line = RadioSetting("dtmf_settings.mastervice", + line = RadioSetting("dtmf_settings.mastervice", "Master and Vice ID", RadioSettingValueBoolean( _mem.dtmf_settings.mastervice)) dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16, - memory2string( + val = RadioSettingValueString(0, 16, memory2string( _mem.dtmf_settings.masterid), - False, CHARSET_DTMF_DIGITS) + False, CHARSET_DTMF_DIGITS) line = RadioSetting("dtmf_settings.masterid", "Master Control ID ", val) line.set_apply_callback(apply_dmtf_frame, _mem.dtmf_settings.masterid) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.minspection", + line = RadioSetting("dtmf_settings.minspection", "Master Inspection", RadioSettingValueBoolean( _mem.dtmf_settings.minspection)) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.mmonitor", + line = RadioSetting("dtmf_settings.mmonitor", "Master Monitor", RadioSettingValueBoolean( _mem.dtmf_settings.mmonitor)) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.mstun", + line = RadioSetting("dtmf_settings.mstun", "Master Stun", RadioSettingValueBoolean( _mem.dtmf_settings.mstun)) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.mkill", + line = RadioSetting("dtmf_settings.mkill", "Master Kill", RadioSettingValueBoolean( _mem.dtmf_settings.mkill)) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.mrevive", + line = RadioSetting("dtmf_settings.mrevive", "Master Revive", RadioSettingValueBoolean( _mem.dtmf_settings.mrevive)) dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16, - memory2string( + val = RadioSettingValueString(0, 16, memory2string( _mem.dtmf_settings.viceid), - False, CHARSET_DTMF_DIGITS) + False, CHARSET_DTMF_DIGITS) line = RadioSetting("dtmf_settings.viceid", "Vice Control ID ", val) line.set_apply_callback(apply_dmtf_frame, _mem.dtmf_settings.viceid) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vinspection", + line = RadioSetting("dtmf_settings.vinspection", "Vice Inspection", RadioSettingValueBoolean( _mem.dtmf_settings.vinspection)) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vmonitor", + line = RadioSetting("dtmf_settings.vmonitor", "Vice Monitor", RadioSettingValueBoolean( _mem.dtmf_settings.vmonitor)) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vstun", + line = RadioSetting("dtmf_settings.vstun", "Vice Stun", RadioSettingValueBoolean( _mem.dtmf_settings.vstun)) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vkill", + line = RadioSetting("dtmf_settings.vkill", "Vice Kill", RadioSettingValueBoolean( _mem.dtmf_settings.vkill)) dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vrevive", + line = RadioSetting("dtmf_settings.vrevive", "Vice Revive", RadioSettingValueBoolean( _mem.dtmf_settings.vrevive)) dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16, - memory2string( + val = RadioSettingValueString(0, 16, memory2string( _mem.dtmf_settings.inspection), - False, CHARSET_DTMF_DIGITS) + False, CHARSET_DTMF_DIGITS) line = RadioSetting("dtmf_settings.inspection", "Inspection", val) line.set_apply_callback(apply_dmtf_frame, _mem.dtmf_settings.inspection) dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16, - memory2string( + val = RadioSettingValueString(0, 16, memory2string( _mem.dtmf_settings.alarmcode), - False, CHARSET_DTMF_DIGITS) + False, CHARSET_DTMF_DIGITS) line = RadioSetting("dtmf_settings.alarmcode", "Alarm", val) line.set_apply_callback(apply_dmtf_frame, _mem.dtmf_settings.alarmcode) dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16, - memory2string( + val = RadioSettingValueString(0, 16, memory2string( _mem.dtmf_settings.kill), - False, CHARSET_DTMF_DIGITS) + False, CHARSET_DTMF_DIGITS) line = RadioSetting("dtmf_settings.kill", "Kill", val) line.set_apply_callback(apply_dmtf_frame, _mem.dtmf_settings.kill) dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16, - memory2string( + val = RadioSettingValueString(0, 16, memory2string( _mem.dtmf_settings.monitor), - False, CHARSET_DTMF_DIGITS) + False, CHARSET_DTMF_DIGITS) line = RadioSetting("dtmf_settings.monitor", "Monitor", val) line.set_apply_callback(apply_dmtf_frame, _mem.dtmf_settings.monitor) dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16, - memory2string( + val = RadioSettingValueString(0, 16, memory2string( _mem.dtmf_settings.stun), - False, CHARSET_DTMF_DIGITS) + False, CHARSET_DTMF_DIGITS) line = RadioSetting("dtmf_settings.stun", "Stun", val) line.set_apply_callback(apply_dmtf_frame, _mem.dtmf_settings.stun) dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16, - memory2string( + val = RadioSettingValueString(0, 16, memory2string( _mem.dtmf_settings.revive), - False, CHARSET_DTMF_DIGITS) + False, CHARSET_DTMF_DIGITS) line = RadioSetting("dtmf_settings.revive", "Revive", val) line.set_apply_callback(apply_dmtf_frame, @@ -2196,7 +2188,7 @@ dtmf_dec_settings.append(line)
def apply_dmtf_listvalue(setting, obj): - LOG.debug("Setting value: "+ str(setting.value) + " from list") + 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] @@ -2247,12 +2239,11 @@ _mem.dtmf_settings.delayproctime])) dtmf_dec_settings.append(line)
- # 5 Tone Settings - stds_5tone = RadioSettingGroup ("stds_5tone", "Standards") - codes_5tone = RadioSettingGroup ("codes_5tone", "Codes") - - group_5tone = RadioSettingGroup ("group_5tone", "5 Tone Settings") + stds_5tone = RadioSettingGroup("stds_5tone", "Standards") + codes_5tone = RadioSettingGroup("codes_5tone", "Codes") + + group_5tone = RadioSettingGroup("group_5tone", "5 Tone Settings") group_5tone.append(stds_5tone) group_5tone.append(codes_5tone)
@@ -2260,22 +2251,22 @@
def apply_list_value(setting, obj): options = setting.value.get_options() - obj.set_value ( options.index(str(setting.value)) ) + obj.set_value(options.index(str(setting.value)))
_5tone_standards = self._memobj._5tone_std_settings i = 0 for standard in _5tone_standards: - std_5tone = RadioSettingGroup ("std_5tone_" + str(i), - LIST_5TONE_STANDARDS[i]) + std_5tone = RadioSettingGroup("std_5tone_" + str(i), + LIST_5TONE_STANDARDS[i]) stds_5tone.append(std_5tone) - + period = standard.period if period == 255: - LOG.debug("Period for " + LIST_5TONE_STANDARDS[i] + + LOG.debug("Period for " + LIST_5TONE_STANDARDS[i] + " is not yet configured. Setting to 70ms.") period = 5
- if period <= len( LIST_5TONE_STANDARD_PERIODS ): + if period <= len(LIST_5TONE_STANDARD_PERIODS): line = RadioSetting( "_5tone_std_settings_" + str(i) + "_period", "Period (ms)", RadioSettingValueList @@ -2292,7 +2283,7 @@ " is not yet configured. Setting to A.") group_tone = 10
- if group_tone <= len( LIST_5TONE_DIGITS ): + if group_tone <= len(LIST_5TONE_DIGITS): line = RadioSetting( "_5tone_std_settings_" + str(i) + "_grouptone", "Group Tone", @@ -2307,11 +2298,11 @@
repeat_tone = standard.repeat_tone if repeat_tone == 255: - LOG.debug("Repeat-Tone for " + LIST_5TONE_STANDARDS[i] + + LOG.debug("Repeat-Tone for " + LIST_5TONE_STANDARDS[i] + " is not yet configured. Setting to E.") repeat_tone = 14
- if repeat_tone <= len( LIST_5TONE_DIGITS ): + if repeat_tone <= len(LIST_5TONE_DIGITS): line = RadioSetting( "_5tone_std_settings_" + str(i) + "_repttone", "Repeat Tone", @@ -2329,18 +2320,18 @@ if LIST_5TONE_STANDARDS.index(str(setting.value)) == 15: obj.set_value(0xFF) else: - obj.set_value( LIST_5TONE_STANDARDS. - index(str(setting.value)) ) + obj.set_value(LIST_5TONE_STANDARDS. + index(str(setting.value)))
def apply_5tone_frame(setting, obj): - LOG.debug("Setting 5 Tone: " + str(setting.value) ) + LOG.debug("Setting 5 Tone: " + str(setting.value)) valstring = str(setting.value) if len(valstring) == 0: - for i in range(0,5): + for i in range(0, 5): obj[i] = 255 else: validFrame = True - for i in range(0,5): + for i in range(0, 5): currentChar = valstring[i].upper() if currentChar in LIST_5TONE_DIGITS: obj[i] = LIST_5TONE_DIGITS.index(currentChar) @@ -2348,12 +2339,12 @@ validFrame = False LOG.debug("invalid char: " + str(currentChar)) if not validFrame: - LOG.debug("setting whole frame to FF" ) - for i in range(0,5): + LOG.debug("setting whole frame to FF") + for i in range(0, 5): obj[i] = 255
def validate_5tone_frame(value): - if (len(str(value)) != 5) and (len(str(value)) != 0) : + if (len(str(value)) != 5) and (len(str(value)) != 0): msg = ("5 Tone must have 5 digits or 0 digits") raise InvalidValueError(msg) for digit in str(value): @@ -2372,25 +2363,25 @@ _5tone_codes = self._memobj._5tone_codes i = 1 for code in _5tone_codes: - code_5tone = RadioSettingGroup ("code_5tone_" + str(i), - "5 Tone code " + str(i)) + code_5tone = RadioSettingGroup("code_5tone_" + str(i), + "5 Tone code " + str(i)) codes_5tone.append(code_5tone) - if (code.standard == 255 ): + if (code.standard == 255): currentVal = 15 else: currentVal = code.standard - line = RadioSetting("_5tone_code_" + str(i) + "_std", + line = RadioSetting("_5tone_code_" + str(i) + "_std", " Standard", RadioSettingValueList(LIST_5TONE_STANDARDS, LIST_5TONE_STANDARDS[ - currentVal]) ) + currentVal])) line.set_apply_callback(my_apply_5tonestdlist_value, code.standard) code_5tone.append(line)
val = RadioSettingValueString(0, 6, frame2string(code.frame1), False) - line = RadioSetting("_5tone_code_" + str(i) + "_frame1", + line = RadioSetting("_5tone_code_" + str(i) + "_frame1", " Frame 1", val) val.set_validate_callback(validate_5tone_frame) line.set_apply_callback(apply_5tone_frame, code.frame1) @@ -2458,8 +2449,8 @@ decode_standard = _mem._5tone_settings.decode_standard if decode_standard == 255: decode_standard = 0 - if decode_standard <= len (LIST_5TONE_STANDARDS_without_none) : - line = RadioSetting("_5tone_settings.decode_standard", + if decode_standard <= len(LIST_5TONE_STANDARDS_without_none): + line = RadioSetting("_5tone_settings.decode_standard", "5 Tone-decode Standard", RadioSettingValueList( LIST_5TONE_STANDARDS_without_none, @@ -2468,13 +2459,13 @@ group_5tone.append(line) else: LOG.debug("Invalid decode std...") - + _5tone_delay1 = _mem._5tone_settings._5tone_delay1 if _5tone_delay1 == 255: _5tone_delay1 = 20
- if _5tone_delay1 <= len( LIST_5TONE_DELAY ): - list = RadioSettingValueList(LIST_5TONE_DELAY, + if _5tone_delay1 <= len(LIST_5TONE_DELAY): + list = RadioSettingValueList(LIST_5TONE_DELAY, LIST_5TONE_DELAY[ _5tone_delay1]) line = RadioSetting("_5tone_settings._5tone_delay1", @@ -2488,7 +2479,7 @@ _5tone_delay2 = 20 LOG.debug("5 Tone delay unconfigured! Resetting to 200ms.")
- if _5tone_delay2 <= len( LIST_5TONE_DELAY ): + if _5tone_delay2 <= len(LIST_5TONE_DELAY): list = RadioSettingValueList(LIST_5TONE_DELAY, LIST_5TONE_DELAY[ _5tone_delay2]) @@ -2503,12 +2494,12 @@ _5tone_delay3 = 20 LOG.debug("5 Tone delay unconfigured! Resetting to 200ms.")
- if _5tone_delay3 <= len( LIST_5TONE_DELAY ): + if _5tone_delay3 <= len(LIST_5TONE_DELAY): list = RadioSettingValueList(LIST_5TONE_DELAY, LIST_5TONE_DELAY[ _5tone_delay3]) line = RadioSetting("_5tone_settings._5tone_delay3", - "5 Tone Delay Frame 3", list ) + "5 Tone Delay Frame 3", list) group_5tone.append(line) else: LOG.debug("Invalid value for 5tone delay (frame3)! Disabling.") @@ -2518,10 +2509,9 @@ ext_length = 0 LOG.debug("1st Tone ext lenght unconfigured! Resetting to 0")
- if ext_length <= len( - LIST_5TONE_DELAY ): + if ext_length <= len(LIST_5TONE_DELAY): list = RadioSettingValueList( - LIST_5TONE_DELAY, + LIST_5TONE_DELAY, LIST_5TONE_DELAY[ ext_length]) line = RadioSetting( @@ -2547,8 +2537,8 @@ LOG.debug("Invalid value decode reset time! Disabling.")
# 2 Tone - encode_2tone = RadioSettingGroup ("encode_2tone", "2 Tone Encode") - decode_2tone = RadioSettingGroup ("decode_2tone", "2 Code Decode") + encode_2tone = RadioSettingGroup("encode_2tone", "2 Tone Encode") + decode_2tone = RadioSettingGroup("decode_2tone", "2 Code Decode")
top.append(encode_2tone) top.append(decode_2tone) @@ -2559,8 +2549,8 @@ "configured. Setting to 600ms") duration_1st_tone = 60
- if duration_1st_tone <= len( LIST_5TONE_DELAY ): - line = RadioSetting("_2tone.duration_1st_tone", + if duration_1st_tone <= len(LIST_5TONE_DELAY): + line = RadioSetting("_2tone.duration_1st_tone", "Duration 1st Tone", RadioSettingValueList(LIST_5TONE_DELAY, LIST_5TONE_DELAY[ @@ -2573,8 +2563,8 @@ "configured. Setting to 600ms") duration_2nd_tone = 60
- if duration_2nd_tone <= len( LIST_5TONE_DELAY ): - line = RadioSetting("_2tone.duration_2nd_tone", + if duration_2nd_tone <= len(LIST_5TONE_DELAY): + line = RadioSetting("_2tone.duration_2nd_tone", "Duration 2nd Tone", RadioSettingValueList(LIST_5TONE_DELAY, LIST_5TONE_DELAY[ @@ -2587,7 +2577,7 @@ "configured. Setting to 300ms") duration_gap = 30
- if duration_gap <= len( LIST_5TONE_DELAY ): + if duration_gap <= len(LIST_5TONE_DELAY): line = RadioSetting("_2tone.duration_gap", "Duration of gap", RadioSettingValueList(LIST_5TONE_DELAY, LIST_5TONE_DELAY[ @@ -2612,8 +2602,8 @@ obj.set_value(val)
i = 1 - for code in self._memobj._2tone._2tone_encode: - code_2tone = RadioSettingGroup ("code_2tone_" + str(i), + for code in self._memobj._2tone._2tone_encode: + code_2tone = RadioSettingGroup("code_2tone_" + str(i), "Encode Code " + str(i)) encode_2tone.append(code_2tone)
@@ -2621,7 +2611,7 @@ if tmp == 65535: tmp = 0 val1 = RadioSettingValueInteger(0, 65535, tmp) - freq1 = RadioSetting("2tone_code_"+ str(i) + "_freq1", + freq1 = RadioSetting("2tone_code_" + str(i) + "_freq1", "Frequency 1", val1) val1.set_validate_callback(_2tone_validate) freq1.set_apply_callback(apply_2tone_freq, code.freq1) @@ -2631,7 +2621,7 @@ if tmp == 65535: tmp = 0 val2 = RadioSettingValueInteger(0, 65535, tmp) - freq2 = RadioSetting("2tone_code_"+ str(i) + "_freq2", + freq2 = RadioSetting("2tone_code_" + str(i) + "_freq2", "Frequency 2", val2) val2.set_validate_callback(_2tone_validate) freq2.set_apply_callback(apply_2tone_freq, code.freq2) @@ -2666,27 +2656,27 @@ else: derived_val = int(round(2304000.0/val))
- obj[frqname].set_value( val ) - obj[derivedname].set_value( derived_val ) - - LOG.debug("Apply " + frqname + ": " + str(val) + " | " - + derivedname + ": " + str(derived_val)) + obj[frqname].set_value(val) + obj[derivedname].set_value(derived_val) + + LOG.debug("Apply " + frqname + ": " + str(val) + " | " + + derivedname + ": " + str(derived_val))
i = 1 - for decode_code in self._memobj._2tone._2tone_decode: - _2tone_dec_code = RadioSettingGroup ("code_2tone_" + str(i), - "Decode Code " + str(i)) + for decode_code in self._memobj._2tone._2tone_decode: + _2tone_dec_code = RadioSettingGroup("code_2tone_" + str(i), + "Decode Code " + str(i)) decode_2tone.append(_2tone_dec_code)
j = 1 for dec in decode_code.decs: val = dec.dec if val == 255: - LOG.debug("Dec for Code " + str(i) + " Dec " + str(j) + + LOG.debug("Dec for Code " + str(i) + " Dec " + str(j) + " is not yet configured. Setting to 0.") val = 0
- if val <= len( LIST_2TONE_DEC ): + if val <= len(LIST_2TONE_DEC): line = RadioSetting( "_2tone_dec_settings_" + str(i) + "_dec_" + str(j), "Dec " + str(j), RadioSettingValueList @@ -2699,11 +2689,11 @@
val = dec.response if val == 255: - LOG.debug("Response for Code " + str(i) + " Dec " + str(j)+ - " is not yet configured. Setting to 0.") + LOG.debug("Response for Code " + str(i) + " Dec " + + str(j) + " is not yet configured. Setting to 0.") val = 0
- if val <= len( LIST_2TONE_RESPONSE ): + if val <= len(LIST_2TONE_RESPONSE): line = RadioSetting( "_2tone_dec_settings_" + str(i) + "_resp_" + str(j), "Response " + str(j), RadioSettingValueList @@ -2716,11 +2706,11 @@
val = dec.alert if val == 255: - LOG.debug("Alert for Code " + str(i) + " Dec " + str(j) + + LOG.debug("Alert for Code " + str(i) + " Dec " + str(j) + " is not yet configured. Setting to 0.") val = 0
- if val <= len( PTTIDCODE_LIST ): + if val <= len(PTTIDCODE_LIST): line = RadioSetting( "_2tone_dec_settings_" + str(i) + "_alert_" + str(j), "Alert " + str(j), RadioSettingValueList @@ -2743,13 +2733,13 @@ expected = int(round(2304000.0/tmp)) from_mem = freq["derived_from_" + setting_name] if expected != from_mem: - LOG.error("Expected " + str(expected) + - " but read " + str(from_mem ) + + LOG.error("Expected " + str(expected) + + " but read " + str(from_mem) + ". Disabling 2Tone Decode Freqs!") break val = RadioSettingValueInteger(0, 65535, tmp) - frq = RadioSetting("2tone_dec_"+ str(i) + "_freq" + str(char), - ("Decode Frequency " +str(char)), val) + frq = RadioSetting("2tone_dec_" + str(i) + "_freq" + str(char), + ("Decode Frequency " + str(char)), val) val.set_validate_callback(_2tone_validate) frq.set_apply_callback(apply_2tone_freq_pair, freq) _2tone_dec_code.append(frq) @@ -3235,6 +3225,8 @@
# Please note that there is a version of this radios that is a clone of the # Waccom Mini8900, maybe an early version? + + @directory.register class KT9800(BTech): """QYT KT8900""" @@ -3314,44 +3306,44 @@ #seekto 0x0E00; struct { u8 tmr; - u8 unknown1; - u8 sql; - u8 unknown2[2]; - u8 tot; - u8 apo; - u8 unknown3; - u8 abr; - u8 beep; - u8 unknown4[4]; - u8 dtmfst; - u8 unknown5[2]; - u8 screv; + u8 unknown1; + u8 sql; + u8 unknown2[2]; + u8 tot; + u8 apo; + u8 unknown3; + u8 abr; + u8 beep; + u8 unknown4[4]; + u8 dtmfst; + u8 unknown5[2]; + u8 screv; u8 unknown6[2]; u8 pttid; u8 pttlt; u8 unknown7; - u8 emctp; - u8 emcch; - u8 sigbp; + u8 emctp; + u8 emcch; + u8 sigbp; u8 unknown8; - u8 camdf; - u8 cbmdf; - u8 ccmdf; - u8 cdmdf; + u8 camdf; + u8 cbmdf; + u8 ccmdf; + u8 cdmdf; u8 langua; u8 sync; // BTech radios use this as the display sync // setting, other radios use this as the auto // keypad lock setting u8 mainfc; - u8 mainbc; - u8 menufc; - u8 menubc; - u8 stafc; - u8 stabc; - u8 sigfc; - u8 sigbc; - u8 rxfc; - u8 txfc; + u8 mainbc; + u8 menufc; + u8 menubc; + u8 stafc; + u8 stabc; + u8 sigfc; + u8 sigbc; + u8 rxfc; + u8 txfc; u8 txdisp; u8 unknown9[5]; u8 anil; @@ -3379,17 +3371,17 @@ reseten:1, menuen:1; u8 unknown5[11]; - u8 dispab; - u8 unknown6[2]; - u8 menu; - u8 unknown7[7]; - u8 vfomra; - u8 vfomrb; - u8 vfomrc; - u8 vfomrd; - u8 mrcha; - u8 mrchb; - u8 mrchc; + u8 dispab; + u8 unknown6[2]; + u8 menu; + u8 unknown7[7]; + u8 vfomra; + u8 vfomrb; + u8 vfomrc; + u8 vfomrd; + u8 mrcha; + u8 mrchb; + u8 mrchc; u8 mrchd; } settings2;
@@ -3630,7 +3622,7 @@ # set the class with the real data self._vhf_range = vhf self._uhf_range = uhf - +
# Declaring Aliases (Clones of the real radios) class SKT8900D(chirp_common.Alias): diff -r 3252700cd985 -r 9ba00d6aadb6 tools/cpep8.manifest --- a/tools/cpep8.manifest Thu Apr 11 10:34:31 2019 -0700 +++ b/tools/cpep8.manifest Sat Apr 20 10:04:50 2019 -0400 @@ -16,6 +16,7 @@ ./chirp/drivers/ap510.py ./chirp/drivers/baofeng_uv3r.py ./chirp/drivers/bjuv55.py +./chirp/drivers/btech.py ./chirp/drivers/ft1802.py ./chirp/drivers/ft1d.py ./chirp/drivers/ft2800.py