Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of rgb_sensor by
Revision 8:88acb970df76, committed 2014-07-03
- Comitter:
- meriac
- Date:
- Thu Jul 03 16:52:12 2014 +0000
- Parent:
- 7:0d35392230be
- Child:
- 9:7bd80f4a965e
- Commit message:
- Positive ADC reading, adjusted speed to 732/s
Changed in this revision
| rgb_sensor.cpp | Show annotated file Show diff for this revision Revisions of this file |
| rgb_sensor.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/rgb_sensor.cpp Thu Jul 03 09:30:13 2014 +0000
+++ b/rgb_sensor.cpp Thu Jul 03 16:52:12 2014 +0000
@@ -229,12 +229,16 @@
void RGB_Sensor::convert(TRGB &rgb)
{
+ int i, sample;
+
/* correct "DC" offset by subdstracting
* environment light
*/
- rgb.ch.red = m_adc_aggregation[1] - m_adc_aggregation[0];
- rgb.ch.green = m_adc_aggregation[2] - m_adc_aggregation[0];
- rgb.ch.blue = m_adc_aggregation[3] - m_adc_aggregation[0];
+ for(i=0; i<3; i++)
+ {
+ sample = m_adc_aggregation[0] - m_adc_aggregation[i+1];
+ rgb.data[i] = (sample<0) ? 0 : sample;
+ }
}
bool RGB_Sensor::capture(TRGB &rgb)
--- a/rgb_sensor.h Thu Jul 03 09:30:13 2014 +0000 +++ b/rgb_sensor.h Thu Jul 03 16:52:12 2014 +0000 @@ -19,7 +19,7 @@ * limitations under the License. */ - #ifndef __RGB_SENSOR_H__ +#ifndef __RGB_SENSOR_H__ #define __RGB_SENSOR_H__ #ifndef RGB_LED_ON @@ -27,11 +27,11 @@ #endif/*RGB_LED_ON*/ #ifndef RGB_OVERSAMPLING -#define RGB_OVERSAMPLING 128 +#define RGB_OVERSAMPLING 32 #endif/*RGB_OVERSAMPLING*/ #ifndef RGB_MAX_ADC_CLK -#define RGB_MAX_ADC_CLK 1000000UL +#define RGB_MAX_ADC_CLK 6000000UL #endif/*RGB_MAX_ADC_CLK*/ #define RGB_CHANNELS 4
