--- /dev/null
+##
+## This file is part of the libsigrokdecode project.
+##
+## Copyright (C) 2014 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+# Addresses/devices. Items that are not listed are reserved/unknown.
+address = {
+ 0x40: 'Matsui TV',
+}
+
+digits = {
+ 0: ['0', '0'],
+ 1: ['1', '1'],
+ 2: ['2', '2'],
+ 3: ['3', '3'],
+ 4: ['4', '4'],
+ 5: ['5', '5'],
+ 6: ['6', '6'],
+ 7: ['7', '7'],
+ 8: ['8', '8'],
+ 9: ['9', '9'],
+}
+
+# Commands. Items that are not listed are reserved/unknown.
+command = {
+ 0x40: dict(list(digits.items()) + list({
+ 11: ['-/--', '-/--'],
+ 16: ['Mute', 'M'],
+ 18: ['Standby', 'StBy'],
+ 26: ['Volume up', 'Vol+'],
+ 27: ['Program up', 'P+'],
+ 30: ['Volume down', 'Vol-'],
+ 31: ['Program down', 'P-'],
+ 68: ['AV', 'AV'],
+ }.items())),
+}
+
##
import sigrokdecode as srd
+from .lists import *
class Decoder(srd.Decoder):
api_version = 1
['cmd', 'Command'],
['cmd-inv', 'Command#'],
['repeat-code', 'Repeat code'],
+ ['remote', 'Remote'],
['warnings', 'Warnings'],
]
annotation_rows = (
('bits', 'Bits', (0, 1, 2, 3, 4)),
('fields', 'Fields', (5, 6, 7, 8, 9, 10)),
- ('warnings', 'Warnings', (11,)),
+ ('remote', 'Remote', (11,)),
+ ('warnings', 'Warnings', (12,)),
)
def putx(self, data):
self.put(self.ss_other_edge, self.samplenum, self.out_ann,
[idx, [p + ' pause', '%s-pause' % p[0], '%sP' % p[0], 'P']])
+ def putremote(self):
+ dev = address.get(self.addr, 'Unknown device')
+ buttons = command.get(self.addr, None)
+ if buttons is None:
+ btn = ['Unknown', 'Unk']
+ else:
+ btn = buttons.get(self.cmd, ['Unknown', 'Unk'])
+ self.put(self.ss_remote, self.ss_bit + self.stop, self.out_ann,
+ [11, ['%s: %s' % (dev, btn[0]), '%s: %s' % (dev, btn[1]),
+ '%s' % btn[1]]])
+
def __init__(self, **kwargs):
self.state = 'IDLE'
- self.ss_bit = self.ss_start = self.ss_other_edge = 0
+ self.ss_bit = self.ss_start = self.ss_other_edge = self.ss_remote = 0
self.data = self.count = self.active = self.old_ir = None
+ self.addr = self.cmd = None
def start(self):
# self.out_python = self.register(srd.OUTPUT_PYTHON)
def data_ok(self):
ret, name = (self.data >> 8) & (self.data & 0xff), self.state.title()
if self.count == 8:
+ if self.state == 'ADDRESS':
+ self.addr = self.data
+ if self.state == 'COMMAND':
+ self.cmd = self.data
self.putd(self.data)
self.ss_start = self.samplenum
return True
if ret == 0:
self.putd(self.data >> 8)
else:
- self.putx([11, ['%s error: 0x%04X' % (name, self.data)]])
+ self.putx([12, ['%s error: 0x%04X' % (name, self.data)]])
self.data = self.count = 0
self.ss_bit = self.ss_start = self.samplenum
return ret == 0
if b in range(self.lc - self.margin, self.lc + self.margin):
self.putpause('Long')
self.putx([5, ['Leader code', 'Leader', 'LC', 'L']])
+ self.ss_remote = self.ss_start
self.data = self.count = 0
self.state = 'ADDRESS'
elif b in range(self.rc - self.margin, self.rc + self.margin):
self.state = 'STOP' if self.data_ok() else 'IDLE'
elif self.state == 'STOP':
self.putstop(self.ss_bit)
+ self.putremote()
self.ss_bit = self.ss_start = self.samplenum
self.state = 'IDLE'
else: