Colour binning for Nespresso capsules using rgb_sensor (RGB LED & Photo Diode) - to detect flavour based on colour
Dependencies: rgb_sensor_buffer
Dependents: coffee_capsule_detection
Diff: detection.h
- Revision:
- 1:a6c13143b151
- Parent:
- 0:8a18ceffce1b
- Child:
- 3:4eefc032a319
--- a/detection.h Thu Jul 03 08:07:46 2014 +0000 +++ b/detection.h Thu Jul 03 09:32:09 2014 +0000 @@ -1,8 +1,37 @@ #ifndef __DETECTION_H_ #define __DETECTION_H__ -#include "rgb_sensor.h" +#include <rgb_sensor.h> + +#define DETECTION_VALUES (15) + +struct Capsule { + const char* name; + double r, g, b; +}; + +class RGB_Detection { + public: + RGB_Detection(PinName red, PinName green, PinName blue, PinName adc); + ~RGB_Detection(void); + const char *run(void); + + protected: + int match_sample_to_capsule(TRGB& rgb_sample); + const Capsule *read_capsule(void); + + RGB_Sensor m_rgb; + Capsule const *m_last_capsule; + + uint32_t m_buffer_pos; + TRGB m_buffer[DETECTION_VALUES]; + + private: + static bool __callback(const TRGB &color); + bool callback(const TRGB &color); + static RGB_Detection *m_global; +}; const char* do_detection(); #endif // __DETECTION_H__