From 6a4ce564cf14ebcc4e569ea09524ee12cb1a30a7 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 19 Dec 2017 10:03:44 -0800 Subject: [PATCH] Fix preallocaiton to not duplicate row references. --- adafruit_amg88xx.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/adafruit_amg88xx.py b/adafruit_amg88xx.py index fa990b6..3d2fac7 100644 --- a/adafruit_amg88xx.py +++ b/adafruit_amg88xx.py @@ -149,7 +149,7 @@ class AMG88XX: Temperatures are stored in a two dimensional list where the first index is the row and the second is the column. The first row is on the side closest to the writing on the sensor.""" - retbuf = [[0]*_PIXEL_ARRAY_WIDTH] * _PIXEL_ARRAY_HEIGHT + retbuf = [[0]*_PIXEL_ARRAY_WIDTH for _ in range(_PIXEL_ARRAY_HEIGHT)] buf = bytearray(3) with self.i2c_device as i2c: @@ -161,7 +161,6 @@ class AMG88XX: i2c.readinto(buf, start=1) raw = (buf[2] << 8) | buf[1] - converted = _signed_12bit_to_float(raw) * _PIXEL_TEMP_CONVERSION - retbuf.append(converted) + retbuf[row][col] = _signed_12bit_to_float(raw) * _PIXEL_TEMP_CONVERSION return retbuf