Skip to content

Commit aaa7612

Browse files
committed
Fixed i2c issue for some arduino compatible architectures
The library did not compile for ESP32 and AVR archtiacture due to Wire.requestFrom. I fixed it by casting the values to uint_8 (byte). Now the library compiles without warinings or errors.
1 parent fe96c9c commit aaa7612

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

examples/simple_test/simple_test.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void setup() {
2929
Serial.begin(115200);
3030

3131
/* The default setup is :
32-
* Conversion mode = CONTINUOUS ---> continuoss
32+
* Conversion mode = CONTINUOUS ---> continuous
3333
* Conversion time = C125mS -|
3434
* Averaging mode = AVE8 -|-> new data every 125mS
3535
* Alert mode = data ---> alert pin states that new data is available

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=TMP117-Arduino
2-
version=1.0.1
2+
version=1.0.2
33
author=Nils Minor <[email protected]>
44
maintainer=Nils Minor <[email protected]>
55
sentence=Full-featured Arduino compatible TMP117 driver

src/TMP117.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,15 @@ void TMP117::setTargetTemperature ( double target ) {
167167
@return uint16_t read value of the configuration regsiter
168168
*/
169169
uint16_t TMP117::readConfig (void) {
170-
uint16_t reg_value = i2cRead2B ( TMP117_REG_CONFIGURATION );
171-
bool high_alert = reg_value >> 15 & 1UL;
172-
bool low_alert = reg_value >> 14 & 1UL;
170+
uint16_t reg_value = i2cRead2B ( TMP117_REG_CONFIGURATION );
173171
bool data_ready = reg_value >> 13 & 1UL;
174-
bool eeprom_busy = reg_value >> 12 & 1UL;
172+
173+
// following bits are a comment in order to not create compiler warnings
174+
// but might be used in the future for some purpose
175+
// bool eeprom_busy = reg_value >> 12 & 1UL;
176+
// bool high_alert = reg_value >> 15 & 1UL;
177+
// bool low_alert = reg_value >> 14 & 1UL;
178+
175179

176180
if (data_ready && newDataCallback != NULL)
177181
newDataCallback ();
@@ -324,7 +328,7 @@ uint16_t TMP117::i2cRead2B (uint8_t reg) {
324328
Wire.beginTransmission(address);
325329
Wire.write(reg);
326330
Wire.endTransmission();
327-
Wire.requestFrom(address, 2);
331+
Wire.requestFrom((uint8_t)address, (uint8_t)2);
328332
if(Wire.available() <= 2){
329333
data[0] = Wire.read();
330334
data[1] = Wire.read();

0 commit comments

Comments
 (0)