diff options
author | Bert Vermeulen <bert@biot.com> | 2014-03-09 23:48:27 +0100 |
---|---|---|
committer | Bert Vermeulen <bert@biot.com> | 2014-03-10 00:47:30 +0100 |
commit | 84c1c0b52820af2418186ac3ecf93a5c6373a22e (patch) | |
tree | ae26f32b7c77646179369fcbe089b91e2c236665 /decoders | |
parent | cfe46204d1c91f02d0e2c6679a2d15ff92bb90c8 (diff) | |
download | libsigrokdecode-84c1c0b52820af2418186ac3ecf93a5c6373a22e.tar.gz libsigrokdecode-84c1c0b52820af2418186ac3ecf93a5c6373a22e.zip |
Change PD options to be a tuple of dictionaries.
Each option consists of a dictionary with the following keys:
id The option id, which is passed in when setting a value.
desc A description of the option, suitable for display.
def The default value for this option.
values (optional) If present, a tuple containing values the option
may take. They must be of the same type as the default.
Valid types for the options are UTF-8-encoded strings, integers, and
floating point values.
Diffstat (limited to 'decoders')
-rw-r--r-- | decoders/can/pd.py | 8 | ||||
-rw-r--r-- | decoders/i2c/pd.py | 7 | ||||
-rw-r--r-- | decoders/i2cfilter/pd.py | 10 | ||||
-rw-r--r-- | decoders/lm75/pd.py | 9 | ||||
-rw-r--r-- | decoders/onewire_link/pd.py | 41 | ||||
-rw-r--r-- | decoders/parallel/pd.py | 14 | ||||
-rw-r--r-- | decoders/spi/pd.py | 19 | ||||
-rw-r--r-- | decoders/uart/pd.py | 24 | ||||
-rw-r--r-- | decoders/usb_packet/pd.py | 6 | ||||
-rw-r--r-- | decoders/usb_signalling/pd.py | 7 |
10 files changed, 89 insertions, 56 deletions
diff --git a/decoders/can/pd.py b/decoders/can/pd.py index c394cf1..e2b55fa 100644 --- a/decoders/can/pd.py +++ b/decoders/can/pd.py @@ -33,10 +33,10 @@ class Decoder(srd.Decoder): {'id': 'can_rx', 'name': 'CAN RX', 'desc': 'CAN bus line'}, ] optional_probes = [] - options = { - 'bitrate': ['Bitrate', 1000000], # 1Mbit/s - 'sample_point': ['Sample point', 70], # 70% - } + options = ( + {'id': 'bitrate', 'desc': 'Bitrate', 'default': 1000000}, # 1Mbit/s + {'id': 'sample_point', 'desc': 'Sample point', 'default': 70}, # 70% + ) annotations = [ ['data', 'CAN payload data'], ['sof', 'Start of frame'], diff --git a/decoders/i2c/pd.py b/decoders/i2c/pd.py index 2db7d21..9cbdd53 100644 --- a/decoders/i2c/pd.py +++ b/decoders/i2c/pd.py @@ -77,9 +77,10 @@ class Decoder(srd.Decoder): {'id': 'sda', 'name': 'SDA', 'desc': 'Serial data line'}, ] optional_probes = [] - options = { - 'address_format': ['Displayed slave address format', 'shifted'], - } + options = ( + {'id': 'address_format', 'desc': 'Displayed slave address format', + 'default': 'shifted', 'values': ('shifted', 'unshifted')}, + ) annotations = [ ['start', 'Start condition'], ['repeat-start', 'Repeat start condition'], diff --git a/decoders/i2cfilter/pd.py b/decoders/i2cfilter/pd.py index 09c12f1..91269c0 100644 --- a/decoders/i2cfilter/pd.py +++ b/decoders/i2cfilter/pd.py @@ -33,10 +33,12 @@ class Decoder(srd.Decoder): outputs = ['i2c'] probes = [] optional_probes = [] - options = { - 'address': ['Address to filter out of the I²C stream', 0], - 'direction': ['Direction to filter (read/write/both)', 'both'] - } + options = ( + {'id': 'address', 'desc': 'Address to filter out of the I²C stream', + 'default': 0}, + {'id': 'direction', 'desc': 'Direction to filter', 'default': 'both', + 'values': ('read', 'write', 'both')} + ) annotations = [] def __init__(self, **kwargs): diff --git a/decoders/lm75/pd.py b/decoders/lm75/pd.py index 58c2c89..84cc26a 100644 --- a/decoders/lm75/pd.py +++ b/decoders/lm75/pd.py @@ -55,10 +55,11 @@ class Decoder(srd.Decoder): {'id': 'a1', 'name': 'A1', 'desc': 'I²C slave address input 1'}, {'id': 'a2', 'name': 'A2', 'desc': 'I²C slave address input 2'}, ] - options = { - 'sensor': ['Sensor type', 'lm75'], - 'resolution': ['Resolution', 9], # 9-12 bit, sensor/config dependent - } + options = ( + {'id': 'sensor', 'desc': 'Sensor type', 'default': 'lm75'}, + {'id': 'resolution', 'desc': 'Resolution', 'default': 9, + 'values': (9, 10, 11, 12)}, + ) annotations = [ ['celsius', 'Temperature in degrees Celsius'], ['kelvin', 'Temperature in Kelvin'], diff --git a/decoders/onewire_link/pd.py b/decoders/onewire_link/pd.py index 5b5ebd0..38ef8cc 100644 --- a/decoders/onewire_link/pd.py +++ b/decoders/onewire_link/pd.py @@ -35,19 +35,36 @@ class Decoder(srd.Decoder): optional_probes = [ {'id': 'pwr', 'name': 'PWR', 'desc': '1-Wire power supply pin'}, ] - options = { - 'overdrive': ['Overdrive mode', 'no'], + options = ( + {'id': 'overdrive', + 'desc': 'Overdrive mode', + 'default': 'no'}, # Time options (specified in microseconds): - 'cnt_normal_bit': ['Normal mode sample bit time (µs)', 15], - 'cnt_normal_slot': ['Normal mode data slot time (µs)', 60], - 'cnt_normal_presence': ['Normal mode sample presence time (µs)', 75], - 'cnt_normal_reset': ['Normal mode reset time (µs)', 480], - 'cnt_overdrive_bit': ['Overdrive mode sample bit time (µs)', 2], - # 'cnt_overdrive_slot': ['Overdrive mode data slot time (µs)', 7.3], - 'cnt_overdrive_slot': ['Overdrive mode data slot time (µs)', 7], - 'cnt_overdrive_presence': ['Overdrive mode sample presence time (µs)', 10], - 'cnt_overdrive_reset': ['Overdrive mode reset time (µs)', 48], - } + {'id': 'cnt_normal_bit', + 'desc': 'Normal mode sample bit time (μs)', + 'default': 15}, + {'id': 'cnt_normal_slot', + 'desc': 'Normal mode data slot time (μs)', + 'default': 60}, + {'id': 'cnt_normal_presence', + 'desc': 'Normal mode sample presence time (μs)', + 'default': 75}, + {'id': 'cnt_normal_reset', + 'desc': 'Normal mode reset time (μs)', + 'default': 480}, + {'id': 'cnt_overdrive_bit', + 'desc': 'Overdrive mode sample bit time (μs)', + 'default': 2}, + {'id': 'cnt_overdrive_slot', + 'desc': 'Overdrive mode data slot time (μs)', + 'default': 7.3}, + {'id': 'cnt_overdrive_presence', + 'desc': 'Overdrive mode sample presence time (μs)', + 'default': 10}, + {'id': 'cnt_overdrive_reset', + 'desc': 'Overdrive mode reset time (μs)', + 'default': 48}, + ) annotations = [ ['bit', 'Bit'], ['warnings', 'Warnings'], diff --git a/decoders/parallel/pd.py b/decoders/parallel/pd.py index b2903d2..8f2176c 100644 --- a/decoders/parallel/pd.py +++ b/decoders/parallel/pd.py @@ -72,12 +72,14 @@ class Decoder(srd.Decoder): outputs = ['parallel'] probes = [] optional_probes = probe_list(8) - options = { - 'clock_edge': ['Clock edge to sample on', 'rising'], - 'wordsize': ['Word size of the data', 1], - 'endianness': ['Endianness of the data', 'little'], - 'format': ['Data format', 'hex'], - } + options = ( + {'id': 'clock_edge', 'desc': 'Clock edge to sample on', + 'default': 'rising', 'values': ('rising', 'falling')}, + {'id': 'wordsize', 'desc': 'Word size of the data', + 'default': 1}, + {'id': 'endianness', 'desc': 'Endianness of the data', + 'default': 'little', 'values': ('little', 'big')}, + ) annotations = [ ['items', 'Items'], ['words', 'Words'], diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index 2cde8bc..6a2b5fa 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -77,14 +77,17 @@ class Decoder(srd.Decoder): {'id': 'mosi', 'name': 'MOSI', 'desc': 'Master out, slave in'}, {'id': 'cs', 'name': 'CS#', 'desc': 'Chip-select'}, ] - options = { - 'cs_polarity': ['CS# polarity', 'active-low'], - 'cpol': ['Clock polarity', 0], - 'cpha': ['Clock phase', 0], - 'bitorder': ['Bit order within the SPI data', 'msb-first'], - 'wordsize': ['Word size of SPI data', 8], # 1-64? - 'format': ['Data format', 'hex'], - } + options = ( + {'id': 'cs_polarity', 'desc': 'CS# polarity', 'default': 'active-low', + 'values': ('active-low', 'active-high')}, + {'id': 'cpol', 'desc': 'Clock polarity', 'default': 0, + 'values': (0, 1)}, + {'id': 'cpha', 'desc': 'Clock phase', 'default': 0, + 'values': (0, 1)}, + {'id': 'bitorder', 'desc': 'Bit order within the SPI data', + 'default': 'msb-first', 'values': ('msb-first', 'lsb-first')}, + {'id': 'wordsize', 'desc': 'Word size of SPI data', 'default': 8}, + ) annotations = [ ['miso-data', 'MISO data'], ['mosi-data', 'MOSI data'], diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index 8de84a4..f01cace 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -85,16 +85,22 @@ class Decoder(srd.Decoder): {'id': 'rx', 'name': 'RX', 'desc': 'UART receive line'}, {'id': 'tx', 'name': 'TX', 'desc': 'UART transmit line'}, ] - options = { - 'baudrate': ['Baud rate', 115200], - 'num_data_bits': ['Data bits', 8], # Valid: 5-9. - 'parity_type': ['Parity type', 'none'], - 'parity_check': ['Check parity?', 'yes'], # TODO: Bool supported? - 'num_stop_bits': ['Stop bit(s)', '1'], # String! 0, 0.5, 1, 1.5. - 'bit_order': ['Bit order', 'lsb-first'], - 'format': ['Data format', 'ascii'], # ascii/dec/hex/oct/bin + options = ( + {'id': 'baudrate', 'desc': 'Baud rate', 'default': 115200}, + {'id': 'num_data_bits', 'desc': 'Data bits', 'default': 8, + 'values': (5, 6, 7, 8, 9)}, + {'id': 'parity_type', 'desc': 'Parity type', 'default': 'none', + 'values': ('none', 'odd', 'even', 'zero', 'one')}, + {'id': 'parity_check', 'desc': 'Check parity?', 'default': 'yes', + 'values': ('yes', 'no')}, + {'id': 'num_stop_bits', 'desc': 'Stop bits', 'default': 1.0, + 'values': (0.0, 0.5, 1.0, 1.5)}, + {'id': 'bit_order', 'desc': 'Bit order', 'default': 'lsb-first', + 'values': ('lsb-first', 'msb-first')}, + {'id': 'format', 'desc': 'Data format', 'default': 'ascii', + 'values': ('ascii', 'dec', 'hex', 'oct', 'bin')}, # TODO: Options to invert the signal(s). - } + ) annotations = [ ['rx-data', 'RX data'], ['tx-data', 'TX data'], diff --git a/decoders/usb_packet/pd.py b/decoders/usb_packet/pd.py index 7524194..d45e3bd 100644 --- a/decoders/usb_packet/pd.py +++ b/decoders/usb_packet/pd.py @@ -153,9 +153,9 @@ class Decoder(srd.Decoder): outputs = ['usb_packet'] probes = [] optional_probes = [] - options = { - 'signalling': ['Signalling', 'full-speed'], - } + options = ( + {'id': 'signalling', 'desc': 'Signalling', 'default': 'full-speed'}, + ) annotations = [ ['sync-ok', 'SYNC'], ['sync-err', 'SYNC (error)'], diff --git a/decoders/usb_signalling/pd.py b/decoders/usb_signalling/pd.py index 543089e..6f3ceff 100644 --- a/decoders/usb_signalling/pd.py +++ b/decoders/usb_signalling/pd.py @@ -80,9 +80,10 @@ class Decoder(srd.Decoder): {'id': 'dm', 'name': 'D-', 'desc': 'USB D- signal'}, ] optional_probes = [] - options = { - 'signalling': ['Signalling', 'full-speed'], - } + options = ( + {'id': 'signalling', 'desc': 'Signalling', + 'default': 'full-speed', 'values': ('full-speed', 'low-speed')}, + ) annotations = [ ['sym', 'Symbol'], ['sop', 'Start of packet (SOP)'], |