0

Handling of samplerate as an uint8_t in TMP007 Library
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Handling of samplerate as an uint8_t in TMP007 Library

by JetNoiseRacing on Thu Dec 27, 2018 12:55 pm

I am using the TMP007 infrared temp sensor with an Arduino Mega. In the Adafruit_TMP007.h library file, I see that the sample rate is defined as seen below:

Code: Select all | TOGGLE FULL SIZE
#define TMP007_CFG_1SAMPLE  0x0000
#define TMP007_CFG_2SAMPLE  0x0200
#define TMP007_CFG_4SAMPLE  0x0400
#define TMP007_CFG_8SAMPLE  0x0600
#define TMP007_CFG_16SAMPLE 0x0800

However the "begin" function call takes an unsigned 8-bit integer, as also seen in Adafruit_TMP007.h

Code: Select all | TOGGLE FULL SIZE
boolean begin(uint8_t samplerate = TMP007_CFG_16SAMPLE);

tmp007.ino compiles and runs fine, but I have a question for my learning/understanding. It is my understanding that something like 0x0800 is too large to be expressed as an unsigned 8-bit integer (0xFF should be the max). Is this correct? If so, how does the compiler handle this? Does it truncate to 0x08?

I'm still coming up the learning curve, so thank you in advance for any teachings!
Attachments
tmp007.ino
(1.92 KiB) Downloaded 10 times
Adafruit_TMP007.h
(1.82 KiB) Downloaded 8 times
Adafruit_TMP007.cpp
(3.77 KiB) Downloaded 8 times

JetNoiseRacing
 
Posts: 2
Joined: Thu Dec 27, 2018 12:27 pm

Re: Handling of samplerate as an uint8_t in TMP007 Library

by adafruit_support_carter on Thu Dec 27, 2018 3:57 pm

Make sure you are using the latest version of the library. Appears to be 1.0.2.

That bug was noticed here:
https://github.com/adafruit/Adafruit_TM ... y/issues/4
and fixed here:
https://github.com/adafruit/Adafruit_TM ... dfb316386a
and was included in the 1.0.2 release:
https://github.com/adafruit/Adafruit_TM ... /tag/1.0.2

adafruit_support_carter
 
Posts: 12705
Joined: Tue Nov 29, 2016 2:45 pm

Re: Handling of samplerate as an uint8_t in TMP007 Library

by JetNoiseRacing on Thu Dec 27, 2018 5:00 pm

Success. Thank you for the guidance.

Is there a way I can mark this as solved/closed?

JetNoiseRacing
 
Posts: 2
Joined: Thu Dec 27, 2018 12:27 pm

Re: Handling of samplerate as an uint8_t in TMP007 Library

by adafruit_support_carter on Thu Dec 27, 2018 5:05 pm

Nah. These forums don't really have that feature. Just letting us know it worked is good. Thanks.

adafruit_support_carter
 
Posts: 12705
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.