Skip to content

Update to new build process and turn on lint. #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 19, 2017

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Dec 8, 2017

I haven't tested these changes on device yet. Please only merge you test it or I follow up later to say its tested.

For adafruit/circuitpython#475

@tannewt tannewt requested a review from deanm1278 December 8, 2017 03:25
Copy link
Contributor

@jerryneedell jerryneedell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 161 of adafruit _amg88xx.py still uses I2c.read_into instead of i2c.readinto

I haven't tested these changes on device yet. Please only merge you test it or I follow up later to say its tested.

For adafruit/circuitpython#475
@tannewt
Copy link
Member Author

tannewt commented Dec 18, 2017

Just rebased.

Copy link
Contributor

@kattni kattni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Library and test code not functional at the moment. Questions/quick-fix-change listed in-line.

for row in amg.pixels:
#pad to 1 decimal place
print(['{0:.1f}'.format(temp) for temp in row])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently fails on this line with TypeError: 'float' object not iterable. Was able to resolve with changes to adafruit_amg88xx.py - change and explanation are listed with that file.

As-is, for row in amg.pixels: is returning a float instead of a list of floats.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked with @caternuson to change this section to an option that worked. Looks like this:

        retbuf = []
        buf = bytearray(3)

        with self.i2c_device as i2c:
            for row in range(0, _PIXEL_ARRAY_HEIGHT):
                rowbuf = []
                for col in range(0, _PIXEL_ARRAY_WIDTH):
                    i = row * _PIXEL_ARRAY_HEIGHT + col
                    buf[0] = _PIXEL_OFFSET + (i << 1)
                    i2c.write(buf, end=1, stop=False)
                    i2c.readinto(buf, start=1)

                    raw = (buf[2] << 8) | buf[1]
                    converted = _signed_12bit_to_float(raw) * _PIXEL_TEMP_CONVERSION
                    rowbuf.append(converted)
                retbuf.append(rowbuf)

        return retbuf

This was a quick-fix to test it and can probably be written better.

Couple of questions: The init to all zeros - what was the thought behind this? Since you pre-allocated the buffer, did you intend to directly index things instead of using .append? such as retbuf[row][col] = converted or something like that. Essentially we were trying to figure out what you're wanting to do with your changes. Could you please clarify?

Thanks much!

@tannewt
Copy link
Member Author

tannewt commented Dec 19, 2017

Great catch! I did intend on directly indexing. I wanted to pre-allocate to minimize the heap churn. With append we end up growing our allocation every few additions. The multiply can be smarter.

Should be fixed now but I didn't test it.

@kattni
Copy link
Contributor

kattni commented Dec 19, 2017

Tested successfully. Good work!

@kattni kattni merged commit da9ac67 into adafruit:master Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants