summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--decoders/ir_irmp/irmp_library.py2
-rw-r--r--decoders/ir_irmp/pd.py38
-rw-r--r--irmp/irmp-main-sharedlib.h1
3 files changed, 34 insertions, 7 deletions
diff --git a/decoders/ir_irmp/irmp_library.py b/decoders/ir_irmp/irmp_library.py
index 22a74b0..d542a1d 100644
--- a/decoders/ir_irmp/irmp_library.py
+++ b/decoders/ir_irmp/irmp_library.py
@@ -41,6 +41,7 @@ class IrmpLibrary:
]
FLAG_REPETITION = 1 << 0
+ FLAG_RELEASE = 1 << 1
def _library_filename(self):
'''
@@ -103,6 +104,7 @@ class IrmpLibrary:
'address': self._data.address,
'command': self._data.command,
'repeat': bool(self._data.flags & self.FLAG_REPETITION),
+ 'release': bool(self._data.flags & self.FLAG_RELEASE),
'start': self._data.start_sample,
'end': self._data.end_sample,
}
diff --git a/decoders/ir_irmp/pd.py b/decoders/ir_irmp/pd.py
index ef3da4d..cb69fd0 100644
--- a/decoders/ir_irmp/pd.py
+++ b/decoders/ir_irmp/pd.py
@@ -49,21 +49,45 @@ class Decoder(srd.Decoder):
)
def putframe(self, data):
+ '''Emit annotation for an IR frame.'''
+
+ # Cache result data fields in local variables. Get the ss/es
+ # timestamps, scaled to sample numbers.
nr = data['proto_nr']
name = data['proto_name']
addr = data['address']
cmd = data['command']
repeat = data['repeat']
- rep = ['repeat', 'rep', 'r'] if repeat else ['', '', '']
+ release = data['release']
ss = data['start'] * self.rate_factor
es = data['end'] * self.rate_factor
- self.put(ss, es, self.out_ann, [0, [
- 'Protocol: {nr} ({name}), Address 0x{addr:04x}, Command: 0x{cmd:04x} {rep[0]}'.format(**locals()),
- 'P: {name} ({nr}), Addr: 0x{addr:x}, Cmd: 0x{cmd:x} {rep[1]}'.format(**locals()),
- 'P: {nr} A: 0x{addr:x} C: 0x{cmd:x} {rep[1]}'.format(**locals()),
- 'C:{cmd:x} A:{addr:x} {rep[2]}'.format(**locals()),
+
+ # Prepare display texts for several zoom levels.
+ # Implementor's note: Keep list lengths for flags aligned during
+ # maintenance. Make sure there are as many flags text variants
+ # as are referenced by annotation text variants. Differing list
+ # lengths or dynamic refs will severely complicate the logic.
+ rep_txts = ['repeat', 'rep', 'r']
+ rel_txts = ['release', 'rel', 'R']
+ flag_txts = [None,] * len(rep_txts)
+ for zoom in range(len(flag_txts)):
+ flag_txts[zoom] = []
+ if repeat:
+ flag_txts[zoom].append(rep_txts[zoom])
+ if release:
+ flag_txts[zoom].append(rel_txts[zoom])
+ flag_txts = [' '.join(t) or '-' for t in flag_txts]
+ flg = flag_txts # Short name for .format() references.
+ txts = [
+ 'Protocol: {name} ({nr}), Address 0x{addr:04x}, Command: 0x{cmd:04x}, Flags: {flg[0]}'.format(**locals()),
+ 'P: {name} ({nr}), Addr: 0x{addr:x}, Cmd: 0x{cmd:x}, Flg: {flg[1]}'.format(**locals()),
+ 'P: {nr} A: 0x{addr:x} C: 0x{cmd:x} F: {flg[1]}'.format(**locals()),
+ 'C:{cmd:x} A:{addr:x} {flg[2]}'.format(**locals()),
'C:{cmd:x}'.format(**locals()),
- ]])
+ ]
+
+ # Emit the annotation from details which were constructed above.
+ self.put(ss, es, self.out_ann, [0, txts])
def __init__(self):
self.irmp = irmp_library.IrmpLibrary()
diff --git a/irmp/irmp-main-sharedlib.h b/irmp/irmp-main-sharedlib.h
index 05e7b53..94065f3 100644
--- a/irmp/irmp-main-sharedlib.h
+++ b/irmp/irmp-main-sharedlib.h
@@ -46,6 +46,7 @@ struct irmp_result_data {
};
#define IRMP_DATA_FLAG_REPETITION (1 << 0)
+#define IRMP_DATA_FLAG_RELEASE (1 << 1)
/**
* @brief Query the IRMP library's configured sample rate.