summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2012-01-26 23:48:11 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2012-01-27 00:50:00 +0100
commitbc1385a6d999c0011050b1cbd275879a928f4252 (patch)
tree284d6702004b9d118c2a096a223a4641ca286033
parent7a1712c4fd07f64222079acd5ec3fa3348a5cb15 (diff)
downloadlibsigrokdecode-bc1385a6d999c0011050b1cbd275879a928f4252.tar.gz
libsigrokdecode-bc1385a6d999c0011050b1cbd275879a928f4252.zip
srd: Melexis MLX90614 Infrared Thermometer decoder.
-rw-r--r--configure.ac1
-rw-r--r--decoders/Makefile.am1
-rw-r--r--decoders/mlx90614/Makefile.am26
-rw-r--r--decoders/mlx90614/__init__.py22
-rw-r--r--decoders/mlx90614/mlx90614.py88
5 files changed, 138 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index c80294a..fa6b97c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,6 +155,7 @@ AC_CONFIG_FILES([Makefile
decoders/ebr30a_i2c_demux/Makefile
decoders/i2c/Makefile
decoders/i2cdemux/Makefile
+ decoders/mlx90614/Makefile
decoders/mx25lxx05d/Makefile
decoders/nunchuk/Makefile
decoders/pan1321/Makefile
diff --git a/decoders/Makefile.am b/decoders/Makefile.am
index 0798fb0..c53436b 100644
--- a/decoders/Makefile.am
+++ b/decoders/Makefile.am
@@ -25,6 +25,7 @@ SUBDIRS = \
ebr30a_i2c_demux \
i2c \
i2cdemux \
+ mlx90614 \
mx25lxx05d \
nunchuk \
pan1321 \
diff --git a/decoders/mlx90614/Makefile.am b/decoders/mlx90614/Makefile.am
new file mode 100644
index 0000000..f14874f
--- /dev/null
+++ b/decoders/mlx90614/Makefile.am
@@ -0,0 +1,26 @@
+##
+## This file is part of the sigrok project.
+##
+## Copyright (C) 2012 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
+##
+
+pkgdatadir = $(DECODERS_DIR)/mlx90614
+
+dist_pkgdata_DATA = __init__.py mlx90614.py
+
+CLEANFILES = *.pyc
+
diff --git a/decoders/mlx90614/__init__.py b/decoders/mlx90614/__init__.py
new file mode 100644
index 0000000..fd62251
--- /dev/null
+++ b/decoders/mlx90614/__init__.py
@@ -0,0 +1,22 @@
+##
+## This file is part of the sigrok project.
+##
+## Copyright (C) 2012 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
+##
+
+from .mlx90614 import *
+
diff --git a/decoders/mlx90614/mlx90614.py b/decoders/mlx90614/mlx90614.py
new file mode 100644
index 0000000..fa1621c
--- /dev/null
+++ b/decoders/mlx90614/mlx90614.py
@@ -0,0 +1,88 @@
+##
+## This file is part of the sigrok project.
+##
+## Copyright (C) 2012 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
+##
+
+#
+# Melexis MLX90614 Infrared Thermometer protocol decoder
+#
+
+import sigrokdecode as srd
+
+class Decoder(srd.Decoder):
+ api_version = 1
+ id = 'mlx90614'
+ name = 'MLX90614'
+ longname = 'Melexis MLX90614'
+ desc = 'TODO.'
+ longdesc = 'TODO.'
+ license = 'gplv2+'
+ inputs = ['i2c']
+ outputs = ['mlx90614']
+ probes = []
+ extra_probes = []
+ options = {}
+ annotations = [
+ ['Celsius', 'Temperature in degrees Celsius'],
+ ['Kelvin', 'Temperature in degrees Kelvin'],
+ ]
+
+ def __init__(self, **kwargs):
+ self.state = 'IGNORE START REPEAT'
+ self.data = []
+
+ def start(self, metadata):
+ # self.out_proto = self.add(srd.OUTPUT_PROTO, 'mlx90614')
+ self.out_ann = self.add(srd.OUTPUT_ANN, 'mlx90614')
+
+ def report(self):
+ pass
+
+ def putx(self, data):
+ self.put(self.ss, self.es, self.out_ann, data)
+
+ # Quick hack implementation! This needs to be improved a lot!
+ def decode(self, ss, es, data):
+ cmd, databyte, ack = data
+
+ # State machine.
+ if self.state == 'IGNORE START REPEAT':
+ if cmd != 'START REPEAT':
+ return
+ self.state = 'IGNORE ADDRESS WRITE'
+ elif self.state == 'IGNORE ADDRESS WRITE':
+ if cmd != 'ADDRESS WRITE':
+ return
+ self.state = 'GET TEMPERATURE'
+ elif self.state == 'GET TEMPERATURE':
+ if len(self.data) == 0:
+ self.data += [databyte]
+ self.ss = ss
+ elif len(self.data) == 1:
+ self.data += [databyte]
+ self.es = es
+ else:
+ kelvin = (self.data[0] | (self.data[1] << 8)) * 0.02
+ celsius = kelvin - 273.15
+ self.putx([0, ['Temperature: %d °C' % celsius]])
+ self.putx([1, ['Temperature: %d °K' % kelvin]])
+ self.state = 'IGNORE START REPEAT'
+ self.data = []
+ else:
+ raise Exception('Invalid state: %d' % self.state)
+