adafruit / Adafruit_AS7341

Other
29 stars 18 forks source link

Channel Enum Fix #16

Closed dylanlytle closed 2 years ago

dylanlytle commented 3 years ago

Channel indexing gets thrown off past 515 because there is the initial clear and nir capture that gets populated in the array. Currently if you get_channel(AS7341_CHANNEL_555_F5) you will actually be reading the first CLEAR capture. Another option for solving this issue could be: typedef enum { AS7341_CHANNEL_415nm_F1 = 0, AS7341_CHANNEL_445nm_F2 = 1, AS7341_CHANNEL_480nm_F3 = 2, AS7341_CHANNEL_515nm_F4 = 3, AS7341_CHANNEL_555nm_F5 = 6, AS7341_CHANNEL_590nm_F6 = 7, AS7341_CHANNEL_630nm_F7 = 8, AS7341_CHANNEL_680nm_F8 = 9, AS7341_CHANNEL_CLEAR = 10, AS7341_CHANNEL_NIR = 11, } as7341_color_channel_t;

caternuson commented 2 years ago

Thanks. This looks OK.

Just to sanity check where that typedef gets used:

$ grep -r as7341_color_channel_t
Adafruit_AS7341.h:} as7341_color_channel_t;
Adafruit_AS7341.h:  uint16_t getChannel(as7341_color_channel_t channel);
Adafruit_AS7341.cpp:uint16_t Adafruit_AS7341::getChannel(as7341_color_channel_t channel) {

Only used as an input parameter for getChannel. So this change won't affect anything else.

Those new entries can be like secret access to the fist reads of CLEAR and NIR :)