# HG changeset patch # User DanClemmensen # Date 1551378584 28800 # Thu Feb 28 10:29:44 2019 -0800 # Node ID 099b12bfd3d2be74a395eb8108909132702c1e9e # Parent b0ed770692e8e00ea9d3cec5bf9cf58c3f7367da [ft4] convert to using a singe tone mode table for all mappings [#4787] diff -r b0ed770692e8 -r 099b12bfd3d2 chirp/drivers/ft4.py --- a/chirp/drivers/ft4.py Tue Feb 26 11:42:19 2019 -0800 +++ b/chirp/drivers/ft4.py Thu Feb 28 10:29:44 2019 -0800 @@ -450,60 +450,51 @@ # on the US versions (FT-4XR) STEP_CODE = [0, 5.0, 6.25, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0] -# Yaesu sql_type field codes -SQL_TYPE = ["off", "R-TONE", "T-TONE", "TSQL", "REV-TN", "DCS", "PAGER"] -# map a CHIRP tone mode to a FT-4 sql and which if any code to set to 0. -# The keys are provided to RadioFeatures as a list, so these are the -# only values we expect to see in mem.tmode. This map as the identical -# structure as the one below to simplify the code. It permits stricter -# zeroing of the unused fields later if we find that it is needed, -# but the CHIRP unit tests want us to leave them alone. -MODES_TONE = { - "": ("off", None), - "Tone": ("T-TONE", None), # chirp means "xmit, not rcv" - "TSQL": ("TSQL", None), # chirp means "xmit and rcv, tx==rx" - "DTCS": ("DCS", None), # chirp means "xmt and rcv, tx==rx" - "TSQL-R": ("REV-TN", None), # chirp means reverse R-Tone - "Cross": () # not used in lookup, needed in list - } - -# Map a CHIRP Cross type if the CHIRP mem.tmode is "Cross". The keys -# are provided to RadioFeatures as a list, so these are the -# only values we expect to see in mem.cross. -MODES_CROSS = { - "DTCS->": ("DCS", "rx_dcs"), - "->DTCS": ("DCS", "tx_dcs"), - "DTCS->DTCS": ("DCS", None), - "->Tone": ("R-TONE", None), - "Tone->Tone": ("TSQL", None) - } - -# Map the radio image sql_type (0-6) back to the CHIRP mem values +# Map the radio image sql_type (0-6) to the CHIRP mem values. # Types "TSQL" and "DCS" each map to different CHIRP values depending # on the radio values on the tx and rx tone codes. +# The map from CHIRP UI to radio image types is also built from this table. RADIO_TMODES = [ - ("(None)", ["", ""]), # sql_type= 0. off - ("(None)", ["Cross", "->Tone"]), # sql_type= 1. R-TONE - ("(None)", ["Tone", ""]), # sql_type= 2. T-TONE - ("(None)", None, "tx_ctcss", "rx_ctcss", [ # sql_type= 3. TSQL - ["", None], # tx==0, rx==0 : not valid - ["TSQL", ""], # tx==0 - ["Tone", ""], # rx==0 - ["Cross", "Tone->Tone"], # tx!=rx - ["TSQL", ""] # tx==rx - ]), - ("(None)", ["TSQL-R", ""]), # sql_type= 4. REV TN - ("(None)", None, "tx_dcs", "rx_dcs", [ # sql_type= 5.DCS - ["", None], # tx==0, rx==0 : not valid - ["Cross", "->DTCS"], # tx==0 - ["Cross", "DTCS->"], # rx==0 - ["Cross", "DTCS->DTCS"], # tx!=rx - ["DTCS", ""] # tx==rx - ]), - ("PAGER", ["", None]) # sql_type= 6. handled as a CHIRP "extra" + ("(None)", [["", ""]]), # sql_type= 0. off + ("(None)", [["Cross", "->Tone"]]), # sql_type= 1. R-TONE + ("(None)", [["Tone", ""]]), # sql_type= 2. T-TONE + ("(None)", [ # sql_type= 3. TSQL + ["", ""], # tx==0, rx==0 : invalid + ["TSQL", ""], # tx==0 + ["Tone", ""], # rx==0 + ["Cross", "Tone->Tone"], # tx!=rx + ["TSQL", ""] # tx==rx + ], "tx_ctcss", "rx_ctcss"), # tx and rx fields to check + ("(None)", [["TSQL-R", ""]]), # sql_type= 4. REV TN + ("(None)", [ # sql_type= 5.DCS + ["", ""], # tx==0, rx==0 : invalid + ["Cross", "->DTCS","tx_dcs"], # tx==0. suppress tx + ["Cross", "DTCS->","rx_dcs"], # rx==0. suppress rx + ["Cross", "DTCS->DTCS"], # tx!=rx + ["DTCS", ""] # tx==rx + ] "tx_dcs", "rx_dcs"), #tx and rx fields to check + ("PAGER", [["", None]]) # sql_type= 6. CHIRP "extra" ] + +# lists of all legal values for the tmode and cross fields for the UI. +# we build dictionaries here and then pass the actual lists to CHIRP as lists +# we use the dictionaries to do the lookups when encoding. +def build_modelists: + modes = {} + cross = {} + for i in range(0,RADIO_TMODES.len()): + trow = RADIO_TMODES[i] + for drow in trow[1]: + suppress= None + if drow.len() == 3: + suppress = drow[3] + modes[drow[0]] = (i, suppress) + cross[drow[1]] = (i, suppress) + +MODES_TONE, MODES_CROSS = build_modelists() + DTMF_CHARS = "0123456789ABCD*#- " CW_ID_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ " PASSWD_CHARS = "0123456789" @@ -547,7 +538,7 @@ ] # The legal PAGER codes are exactly the same as the CTCSS codes, -# but we pass them to the UI as a lsit of strings to display. +# but we pass them to the UI as a list of strings to display. EPCS_CODES = [format(flt) for flt in [0] + TONE_MAP[1:]] @@ -839,14 +830,15 @@ CHIRP CSV values for tmode, cross_mode, and sql_override """ mode = RADIO_TMODES[chan.sql_type] + ndx = 0 chirpvals = mode[1] - if not chirpvals: + if chirpvals.len() > 1: x = getattr(chan, mode[2]) r = getattr(chan, mode[3]) ndx = self.LOOKUP.index([x == 0, r == 0]) if ndx == 3 and x == r: ndx = 4 - chirpvals = mode[4][ndx] + chirpvals = mode[1][ndx] mem.tmode, cross = chirpvals if cross: mem.cross_mode = cross @@ -884,16 +876,16 @@ (MODES_TONE, mem.tmode), (MODES_CROSS, mem.cross_mode) ][mem.tmode == "Cross"] - sql_type, suppress = tbl[ndx] - chan.sql_type = SQL_TYPE.index(sql_type) + chan.sql_type suppress = tbl[ndx] if suppress: setattr(chan, suppress, 0) for setting in mem.extra: if (setting.get_name() == 'sql_override'): value = str(setting.value) - if value != "(None)": - chan.sql_type = SQL_TYPE.index(value) + if value == "PAGER": + chan.sql_type = 6 return + # given a CHIRP memory ref, get the radio memobj for it. # A memref is either a number or the name of a special @@ -1087,4 +1079,4 @@ ] def __init__(self): - self.add_paramdesc("misc", ("compander", "Compander", ["ON", "OFF"])) + self.add_paramdesc("misc", ("compander", "Compander", ["OFF", "ON"]))