tweaked detection to use photoresistor through an opamp

Dependents:   rgb_sensor_buffer

Fork of rgb_sensor by Milosch Meriac

Revision:
0:576e43bd193d
Child:
1:204db97d10c9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rgb_sensor.h	Wed Jun 25 14:55:45 2014 +0000
@@ -0,0 +1,45 @@
+#ifndef __RGB_SENSOR_H__
+#define __RGB_SENSOR_H__
+
+#ifndef RGB_OVERSAMPLING
+#define RGB_OVERSAMPLING 128
+#endif/*RGB_OVERSAMPLING*/
+
+#ifndef RGB_MAX_ADC_CLK
+#define RGB_MAX_ADC_CLK 12400000UL
+#endif/*RGB_MAX_ADC_CLK*/
+
+#define RGB_CHANNELS 4
+
+typedef struct
+{
+    int red,green,blue;
+} TRGB_Channel;
+
+typedef union
+{
+    TRGB_Channel ch;
+    int data[3];
+} TRGB;
+
+class RGB_Sensor
+{
+    public:
+      RGB_Sensor(PinName red, PinName green, PinName blue, PinName adc);
+      ~RGB_Sensor(void);
+      bool capture(TRGB &rgb);
+      bool capture(void);
+      bool wait(TRGB &rgb);
+    protected:
+      bool m_done;
+      uint8_t m_adc_channel, m_rgb_channel;
+      DigitalOut m_red, m_green, m_blue;
+      int m_adc_aggregation[RGB_CHANNELS], m_adc_count;
+      bool wait(void);
+    private:
+      static void __adc_irq(void);
+      void adc_irq(void);
+      static RGB_Sensor *m_global;
+};
+
+#endif/*__RGB_SENSOR_H__*/
\ No newline at end of file