Closed Fleker closed 4 years ago
uint16_t BH1750FVI::readLightIntensity() {
uint8_t datum;
uint16_t value;
_wire->beginTransmission(DEVICE_ADDRESS);
//_wire->write(REGISTER_LIGHTINTENSITY);
if (_wire->endTransmission(false) != 0) {
return -1;
}
if (_wire->requestFrom(DEVICE_ADDRESS, 2) != 2) {
return 0;
}
datum = _wire->read();
value = value << 8 | datum;
datum = _wire->read();
value = value << 8 | datum;
return value;
}
Add a commandOnly
to register? To i2c? Commands top-level?
i2c.commandOnly: true
Then, turn the BH1750FVI registers into fields.
That doesn't result in clean code as now the field logic will need to handle 0-bits. And I do like the existing writeX()
code output. Appending it for a single register for reading is probably the best solution here for now.
In the case of the BH1750FVI light sensor, you cannot read from a register address as it's data-only. This means that you cannot do a standard read on the light intensity. Rather we need a way to read data arbitrarily off the bus (or somehow without sending the register?)