Thanks for sharing! you're good in libs! Well done,
Some small remarks to think over
typedef struct
{
uint32_t value[RGB_SIZE]; // Raw data from the sensor
} color32;
typedef struct
{
uint8_t value[RGB_SIZE]; // the evaluated colour data (RGB value 0-255 or other)
} color8;
void setEnable(bool t); // enable the device (using OE or frequency)
=>
void enable();
void disable();
Choose better names for some variables,
keeps the code more readable / maintainable
and you can remove comments as code becomes self documenting
e.g.
uint8_t _OutputEnable;
uint8_t _FreqScaler0, _FreqScaler1;
color32 _DarkCalibration;
color32 _WhiteBalance;
color32 _currentRaw;
color8 _currectRGB;
also for the function prototypes
MD_TCS230(... uint8_t freqScaler0, uint8_t freqScaler1, uint8_t outputEnable);
Have a look at error handling and return values. It is only slightly more code and adds real value
bool MD_TCS230::setFilter(uint8_t f)
// set the sensor color filter
{
if ((_S2 == NO_PIN) || (_S3 == NO_PIN))
return false;
DUMPS("\nsetFilter ");
switch (f)
{
case TCS230_RGB_R: DUMPS("R"); digitalWrite(_S2, LOW); digitalWrite(_S3, LOW); break;
case TCS230_RGB_G: DUMPS("G"); digitalWrite(_S2, HIGH); digitalWrite(_S3, HIGH); break;
case TCS230_RGB_B: DUMPS("B"); digitalWrite(_S2, LOW); digitalWrite(_S3, HIGH); break;
case TCS230_RGB_X: DUMPS("X"); digitalWrite(_S2, HIGH); digitalWrite(_S3, LOW); break;
default: DUMPS("setFilter error"); Serial.println(f, DEC); return false; break;
}
return true;
}
or
bool MD_TCS230::setSampling(uint8_t t)
// set sampling rate divisor for frequency counter
{
if (t > 0)
{
_readDiv = t;
return true;
}
return false;
}
or
bool MD_TCS230::setDarkCal(sensorData *d)
// set dark calibration data for rgb calculations
{
if (d == NULL)
return false;
DUMPS("\nsetDarkCal");
for (uint8_t i=0; i<RGB_SIZE; i++)
{
DUMP(" ", d->value[i]);
_Fd.value[i] = d->value[i];
}
return true;
}
BTW I like your consequent debugging style!