adafruit / Adafruit_AS7341

Other
29 stars 18 forks source link

Setting and resetting of register banks #5

Open stephenf7072 opened 4 years ago

stephenf7072 commented 4 years ago

The library functions all just assume that the AS7341 is set to the correct (default) register bank. LED and GPIO functions are the key functions which use uncommon registers 0x60-0x74, accessed by calling setBank(true). I've added setBank(false) calls at the end of the LED functions as an interim measure to revert the bank to the default, in pull request #3.

The GPIO functions almost certainly need a setBank(true) to be added at the start and a setBank(false) at the end, but I haven't delved into them. If a function to return the integration time (addresses 0x63,0x64,0x65) was added (ie. for timeout/error recovery), this would also need careful bank management, as would any other registers accessed in this bank.

I'm mildly uncomfortable with just assuming the AS7341 is set to the correct bank, so perhaps all functions could verify the correct bank is selected, either by reading the register or by keeping track of a private variable. The potential methodologies seemed a bit too multi-pronged for a pull request.

craziks-creator commented 4 years ago

Are you going to read wavelength or only want to check color???

stephenf7072 commented 4 years ago

I'm not sure what you are asking. Have a look at the AS7341 datasheet - there are various colour channels that can be read and output.

craziks-creator commented 4 years ago

I mean, is it possible to read wavelength of projected light on AS7341.?

stephenf7072 commented 4 years ago

No - the channels are fixed by the filters applied to the photodiodes (all inside the chip). This pull request is not a good place to be having this discussion. If you still have questions, start an issue or post on a forum.

(edit: apologies, I got confused, this isn't a pull request)