diff --git a/src/Adafruit_TCS34725.cpp b/src/Adafruit_TCS34725.cpp index 4438113f7965d434cdb2804f09efc4186cc3ae69..bb3a9e80695ed1119f7f52afe4467a1e73e5fe70 100644 --- a/src/Adafruit_TCS34725.cpp +++ b/src/Adafruit_TCS34725.cpp @@ -24,6 +24,10 @@ #define ARDUINO 200 +// allow to divide delay time by this factor. Put the number of sensor here. +// todo : make a better fix that don't use delay anymore. +#define INTEG_DIVIDER 2 + #include <math.h> #include <stdlib.h> @@ -285,25 +289,26 @@ void Adafruit_TCS34725::getRawData(uint16_t *r, uint16_t *g, uint16_t *b, *g = read16(TCS34725_GDATAL); *b = read16(TCS34725_BDATAL); + /* Set a delay for the integration time */ switch (_tcs34725IntegrationTime) { case TCS34725_INTEGRATIONTIME_2_4MS: - delay(3); + delay((3/INTEG_DIVIDER) + 1); break; case TCS34725_INTEGRATIONTIME_24MS: - delay(24); + delay((24/INTEG_DIVIDER) + 1); break; case TCS34725_INTEGRATIONTIME_50MS: - delay(50); + delay((50/INTEG_DIVIDER) + 1); break; case TCS34725_INTEGRATIONTIME_101MS: - delay(101); + delay((101/INTEG_DIVIDER) + 1); break; case TCS34725_INTEGRATIONTIME_154MS: - delay(154); + delay((154/INTEG_DIVIDER) + 1); break; case TCS34725_INTEGRATIONTIME_700MS: - delay(700); + delay((700/INTEG_DIVIDER) + 1); break; } } diff --git a/src/main.cpp b/src/main.cpp index 3815bf4f880a376fccbac16df92f7d072fbf6244..eec42ad058a58457e31d77f6524f50c2524eb610 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -339,6 +339,7 @@ void colorSensorsLoop(){ hsv_msg.z = v; color_sensor_right.publish( &hsv_msg ); + nh.spinOnce(); } void loop()