Closed christakahashi closed 1 year ago
I just encountered the same issue. It's easy to observe this effect in the provided examples.
Thanks for pointing this out! I was pulling my hair out trying to figure out what I was doing wrong. Your suggested fix (#16) worked for me!
Just adding more info.
The AMS7341 has 6 channel ADC. To read all the channels, two readings must done, changing SMUX settings between. The app note (AN_AS7341_SMUX_configuration_1V1.pdf) on how to setup the SMUX is buried in the demo code zips that can be downloaded from: https://ams.com/as7341#tab/tools
In this Arduino library code, the following functions configure the SMUX.
setup_F1F4_Clear_NIR()
configures the SMUX to be:
ADC CHAN
--- ----
0 F1
1 F2
2 F3
3 F4
4 CLR
5 NIR
setup_F5F8_Clear_NIR()
configures the SMUX to be:
ADC CHAN
--- ----
0 F5
1 F6
2 F7
3 F8
4 CLR
5 NIR
These are each called from readAllChannels()
and the end result is that the internal data buffer _channel_readings
has the following layout:
F1
F2
F3
F4
CLR
NIR
F5
F6
F7
F8
CLR
NIR
It's the redundant CLR
and NIR
values from the first reading that throw off the as7341_color_channel_t
enum.
Please try the 1.3.2 release when it becomes available: https://github.com/adafruit/Adafruit_AS7341/releases/tag/1.3.2
Closing. Should be fixed by #16.
Arduino board: any
Arduino IDE version (found in Arduino -> About Arduino menu): any that works with the library
List the steps to reproduce the problem below (if possible attach a sketch or copy the sketch code in too):
should store data for f5 in
f5dat
but stores clear channel data instead.getChannel
assumes a different data layout readAllChannels.NOTE: It should be more explicit in the documentation for readAllChannels what the ordering is. It should also say it requires a buffer size of 12 not 10.