check id reg

This commit is contained in:
Kevin Baluha 2019-02-07 03:40:44 -07:00
parent a1ef7b254e
commit 58c7fac140
1 changed files with 5 additions and 2 deletions

View File

@ -64,11 +64,14 @@ bool Tsl2561Read(void)
void Tsl2561Detect(void) void Tsl2561Detect(void)
{ {
if (tsl2561_type) { return; } if (tsl2561_type) { return; }
uint8_t id;
if ((I2cDevice(0x29) || I2cDevice(0x39) || I2cDevice(0x49))&&Tsl.begin()) { if (I2cDevice(0x29) || I2cDevice(0x39) || I2cDevice(0x49)) {
if (!Tsl.id(&id)) return;
Tsl.begin();
if (Tsl.on()) { if (Tsl.on()) {
tsl2561_type = 1; tsl2561_type = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, tsl2561_types, Tsl.address()); snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, tsl2561_types, Tsl.address(), id);
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
} }
} }