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.
Dependencies: mbed-rtos mbed QEI
Diff: Sensors/Colour/Colour.h
- Revision:
- 4:1be0f6c6ceae
- Parent:
- 3:717de74f6ebd
- Child:
- 5:56a5fdd373c9
--- a/Sensors/Colour/Colour.h Mon Apr 01 15:33:48 2013 +0000
+++ b/Sensors/Colour/Colour.h Wed Apr 03 17:54:53 2013 +0000
@@ -1,7 +1,6 @@
// Eurobot13 Colour.h
-
#include "mbed.h"
#include "Led.h"
#include "Phototransistor.h"
@@ -45,32 +44,7 @@
private:
void LedsOff(){blue.off(); red.off();}
- void ReadLed (Led &led, float &avg, float &stdev, const int measureNum = 25){
- LedsOff(); led.on();
- double x = 0, x2 = 0;
- for (int i = measureNum; i != 0; i--){
- float v = pt.read();
- x += v;
- x2+= v*v;
- }
- avg = x / measureNum;
- stdev = sqrt(x2 / measureNum - avg*avg);
- LedsOff();
-
- pc.printf("Phototransistor Analog is: %f\t%f\n\r", avg, stdev);
- }
+ void ReadLed (Led &led, float &avg, float &stdev, const int measureNum = 25); // Colour.cpp
+ bool isColour(Led &led, const float &avg, const float &stdev, const float numstddev = 2); // Colour.cpp
- bool isColour(Led &led, const float &avg, const float &stdev, const float numstddev = 2 ){
- float avg2, stdev2;
- ReadLed(led, avg2, stdev2);
-
- if (avg + numstddev*stdev < avg2 - numstddev*stdev2){
- return true;
- } else {
- return false;
- }
- }
-
-
-
};
\ No newline at end of file