claws / BH1750

An Arduino library for the digital light sensor breakout boards containing the BH1750FVI IC
MIT License
248 stars 107 forks source link

Lower bits of MTreg #57

Closed kenjif70 closed 4 years ago

kenjif70 commented 5 years ago

https://github.com/claws/BH1750/blob/a49b08550a8f46d3c7672a3774103cd01dc8186b/BH1750.cpp#L156

Shouldn't we keep 5 bits rather than 3 bits?

claws commented 4 years ago

I think you are correct. Do you want to submit a pull request?

kenjif70 commented 4 years ago

Thanks for the comment. Yup, I can do that if you prefer. But I've not set up the repo/branch yet, so I'm perfectly fine/happy if you could make the change on behalf of me.

claws commented 4 years ago

Do you have a use case that can test the change? If so can you test the change in the merge request (#58) branch I just raised to apply the fix?

kenjif70 commented 4 years ago

Cool! I just confirmed that, with the fix, readLightLevel gives a consistent value regardless of the sensitivity. Before the fix, MTreg=39 and MTreg=63 give very different numbers, for example.

By the way, another thing I realized while testing is that readLightLevel returns an inconsistent number if it's called right after calling setMTreg with the mode = ONESHOT. setMTreg has _delayms when the mode is CONTINUOUS but not ONESHOT, and this inconsistent behavior doesn't happen in CONTINUOUS_ modes.

claws commented 4 years ago

Thanks for catching this issue. I've merged #58 which provides the fix and raised another issue (#59) to capture the last issue you observed.