* [PATCH v4l-utils 1/2] lircd2toml: honour pre_data for rc-mm remote definitions
@ 2019-03-13 16:00 Sean Young
2019-03-13 16:00 ` [PATCH v4l-utils 2/2] lircd2toml: detect NEC if bit 0 and 1 are inverted Sean Young
0 siblings, 1 reply; 2+ messages in thread
From: Sean Young @ 2019-03-13 16:00 UTC (permalink / raw)
To: linux-media
Signed-off-by: Sean Young <sean@mess.org>
---
contrib/lircd2toml.py | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/contrib/lircd2toml.py b/contrib/lircd2toml.py
index 72ee50e3..f2f7cdd3 100755
--- a/contrib/lircd2toml.py
+++ b/contrib/lircd2toml.py
@@ -349,7 +349,7 @@ class Converter:
def convert_rcmm(self):
res = {
- 'protocol': 'rc_mm',
+ 'protocol': 'rc-mm',
'params': {},
'map': {}
}
@@ -368,16 +368,24 @@ class Converter:
if 'toggle_bit' in self.remote:
toggle_bit = bits - int(self.remote['toggle_bit'][0])
- if toggle_bit > 0 and toggle_bit < bits:
- res['params']['toggle_bit'] = toggle_bit
-
- res['params']['bits'] = bits
-
if 'codes' not in self.remote or len(self.remote['codes']) == 0:
self.error("missing codes section")
return None
- res['map'] = self.remote['codes']
+ if 'pre_data_bits' in self.remote:
+ pre_data_bits = int(self.remote['pre_data_bits'][0])
+ pre_data = int(self.remote['pre_data'][0]) << bits
+ bits += pre_data_bits
+ for s in self.remote['codes']:
+ res['map'][s|pre_data] = self.remote['codes'][s]
+ else:
+ res['map'] = self.remote['codes']
+
+ res['params']['bits'] = bits
+ res['params']['variant'] = "'rc-mm-" + str(bits) + "'"
+
+ if toggle_bit > 0 and toggle_bit < bits:
+ res['params']['toggle_bit'] = toggle_bit
return res
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v4l-utils 2/2] lircd2toml: detect NEC if bit 0 and 1 are inverted
2019-03-13 16:00 [PATCH v4l-utils 1/2] lircd2toml: honour pre_data for rc-mm remote definitions Sean Young
@ 2019-03-13 16:00 ` Sean Young
0 siblings, 0 replies; 2+ messages in thread
From: Sean Young @ 2019-03-13 16:00 UTC (permalink / raw)
To: linux-media
This fixes conversion of:
http://lirc.sourceforge.net/remotes/goldstar/VCR
Signed-off-by: Sean Young <sean@mess.org>
---
contrib/lircd2toml.py | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/contrib/lircd2toml.py b/contrib/lircd2toml.py
index f2f7cdd3..b1aa2403 100755
--- a/contrib/lircd2toml.py
+++ b/contrib/lircd2toml.py
@@ -340,6 +340,42 @@ class Converter:
if variant:
res['params']['variant'] = "'" + variant + "'"
+ elif ('header_pulse' in res['params'] and
+ 'header_space' in res['params'] and
+ 'reverse' not in res['params'] and
+ 'trailer_pulse' in res['params'] and
+ 'header_optional' not in res['params'] and
+ 'pulse_distance' == res['protocol'] and
+ eq_margin(res['params']['header_pulse'], 9000, 1000) and
+ eq_margin(res['params']['header_space'], 4500, 1000) and
+ eq_margin(res['params']['bit_pulse'], 560, 300) and
+ eq_margin(res['params']['bit_1_space'], 560, 300) and
+ eq_margin(res['params']['bit_0_space'], 1680, 300) and
+ eq_margin(res['params']['trailer_pulse'], 560, 300) and
+ res['params']['bits'] == 32 and
+ ('repeat_pulse' not in res['params'] or
+ (eq_margin(res['params']['repeat_pulse'], 9000, 1000) and
+ eq_margin(res['params']['repeat_space'], 2250, 1000)))):
+ self.warning('remote looks exactly like NEC, converting')
+ res['protocol'] = 'nec'
+ res['params'] = {}
+ # bit_0_space and bit_1_space have been swapped, scancode
+ # will need to be inverted
+
+ variant = None
+
+ for s in self.remote['codes']:
+ p = (s<<post_data_bits)|pre_data
+ v, n = decode_nec_scancode(~p)
+ if variant == None:
+ variant = v
+ elif v != variant:
+ variant = ""
+
+ res['map'][n] = self.remote['codes'][s]
+
+ if variant:
+ res['params']['variant'] = "'" + variant + "'"
else:
for s in self.remote['codes']:
p = (s<<post_data_bits)|pre_data
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-13 16:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 16:00 [PATCH v4l-utils 1/2] lircd2toml: honour pre_data for rc-mm remote definitions Sean Young
2019-03-13 16:00 ` [PATCH v4l-utils 2/2] lircd2toml: detect NEC if bit 0 and 1 are inverted Sean Young
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).