152#define TCS3200_COLOR_RED 0x00
153#define TCS3200_COLOR_GREEN 0x01
154#define TCS3200_COLOR_BLUE 0x02
155#define TCS3200_COLOR_CLEAR 0x03
157#define TCS3200_PWR_DOWN 0x00
158#define TCS3200_OFREQ_2P 0x01
159#define TCS3200_OFREQ_20P 0x02
160#define TCS3200_OFREQ_100P 0x03
232 TCS3200(uint8_t s0_pin, uint8_t s1_pin, uint8_t s2_pin, uint8_t s3_pin, uint8_t out_pin);
514 template <
typename T>
519 uint16_t min_dist = 0xffff;
521 for(
int i = 0; i < size; i++) {
522 uint16_t dist = abs(readings.
red - color_values[i].
red) +
524 abs(readings.
blue - color_values[i].
blue);
526 if(dist < min_dist) {
528 nearest = color_labels[i];
536 uint8_t _s0_pin, _s1_pin, _s2_pin, _s3_pin, _out_pin;
537 uint8_t max_r, max_g, max_b;
538 uint8_t min_r, min_g, min_b;
540 unsigned int _integration_time;
541 int _frequency_scaling;
544 void (*upper_bound_interrupt_callback)();
545 void (*lower_bound_interrupt_callback)();
547 RGBColor white_balance_rgb, ub_threshold, lb_threshold;
549 void select_filter(uint8_t filter);
struct _CMYKColor CMYKColor
Structure to represent CMYK color values.
struct _CIE1931 CIE1931Color
Structure to represent CIE 1931 XYZ color values.
struct _HSVColor HSVColor
Structure to represent HSV color values.
struct _RGBColor RGBColor
Structure to represent RGB color values.
Class representing the TCS3200 color sensor.
Definition TCS3200.h:219
void calibrate_light()
Perform light calibration for white balancing.
void calibrate()
Perform definition of the sensor as calibrated.
void integration_time(unsigned int time)
Set the integration time for color sensing.
uint8_t get_rgb_dominant_color()
Get the dominant RGB color channel.
uint8_t read_red()
Read the intensity of the red color channel.
uint8_t read_blue()
Read the intensity of the blue color channel.
void lower_bound_interrupt(RGBColor threshold, void(*callback)())
Enable a lower bound interrupt with a given threshold.
HSVColor read_hsv()
Read the HSV color values from the sensor.
T nearest_color(T *color_labels, RGBColor *color_values, int size)
Find the nearest color label based on the current sensor readings.
Definition TCS3200.h:515
uint8_t read_clear()
Read the intensity of the clear (ambient) color channel.
CIE1931Color read_cie1931()
Read the CIE 1931 XYZ color values from the sensor.
void frequency_scaling(int scaling)
Set the frequency scaling for color sensing.
void loop()
Continuously monitor color intensity values and trigger callbacks for interrupt conditions.
unsigned int integration_time()
Get the current integration time setting.
TCS3200(uint8_t s0_pin, uint8_t s1_pin, uint8_t s2_pin, uint8_t s3_pin, uint8_t out_pin)
Constructor for TCS3200 class.
void clear_lower_bound_interrupt()
Clear the lower bound interrupt.
CMYKColor read_cmyk()
Read the CMYK color values from the sensor.
uint8_t read_green()
Read the intensity of the green color channel.
void white_balance(RGBColor white_balance_rgb)
Set the white balance RGB values.
float get_chroma()
Calculate the chroma of the current color readings.
RGBColor white_balance()
Get the current white balance RGB values.
int frequency_scaling()
Get the current frequency scaling setting.
RGBColor read_rgb_color()
Read the RGB color values from the sensor.
void clear_upper_bound_interrupt()
Clear the upper bound interrupt.
void upper_bound_interrupt(RGBColor threshold, void(*callback)())
Enable an upper bound interrupt with a given threshold.
void begin()
Initialize the TCS3200 sensor and configure pins.
void calibrate_dark()
Perform dark calibration for white balancing.
Structure to represent CIE 1931 XYZ color values.
Definition TCS3200.h:201
float y
Y value.
Definition TCS3200.h:203
float x
X value.
Definition TCS3200.h:202
float z
Z value.
Definition TCS3200.h:204
Structure to represent CMYK color values.
Definition TCS3200.h:189
float black
Black (Key) color intensity (0-1)
Definition TCS3200.h:193
float yellow
Yellow color intensity (0-1)
Definition TCS3200.h:192
float cyan
Cyan color intensity (0-1)
Definition TCS3200.h:190
float magenta
Magenta color intensity (0-1)
Definition TCS3200.h:191
Structure to represent HSV color values.
Definition TCS3200.h:178
float hue
Hue value in degrees (0-360)
Definition TCS3200.h:179
float value
Value (brightness) value (0-1)
Definition TCS3200.h:181
float saturation
Saturation value (0-1)
Definition TCS3200.h:180
Structure to represent RGB color values.
Definition TCS3200.h:167
uint8_t red
Red color intensity (0-255)
Definition TCS3200.h:168
uint8_t blue
Blue color intensity (0-255)
Definition TCS3200.h:170
uint8_t green
Green color intensity (0-255)
Definition TCS3200.h:169