Fumiya Fujisawa / ColorSensor

Dependents:   digtalcolorsensor

Fork of ColorSensor by Ryo Ogata

Files at this revision

API Documentation at this revision

Comitter:
ryuna
Date:
Thu Sep 19 05:30:08 2013 +0000
Parent:
0:c5bc72734cbf
Commit message:
colorsensor+a

Changed in this revision

ColorSensor.cpp Show annotated file Show diff for this revision Revisions of this file
ColorSensor.h Show annotated file Show diff for this revision Revisions of this file
--- a/ColorSensor.cpp	Thu Sep 12 12:06:29 2013 +0000
+++ b/ColorSensor.cpp	Thu Sep 19 05:30:08 2013 +0000
@@ -28,6 +28,9 @@
   B = RGB[2];
 }
 
+void ColorSensor::timenow(unsigned short times){
+    time = times ;
+}
 ColorSensor::ColorSensor(void) {
   unsigned short RGB[3];
   double R, G, B, r,g,b;
@@ -43,7 +46,7 @@
   time = 10;   // 10ms
   setWhite();
 }
-
+ 
 void ColorSensor::getRGB(unsigned short RGB[])
 {
     unsigned short i, j, coldata;
@@ -64,9 +67,9 @@
       RGB[i]=coldata;
     }
 }
-
+ 
 void ColorSensor::getRGB(
-  unsigned& R, unsigned& G, unsigned& B)
+  unsigned& R, unsigned& G, unsigned& B )
 {
     unsigned i, j, coldata;
 
@@ -89,12 +92,12 @@
         case 2: B=coldata; break;
       }
     }
-  }
+ }
 
 // 比率を%で返す
 //少し変更しました(2013/8)
-unsigned ColorSensor::checkRGB(
-  unsigned& R, unsigned& G, unsigned& B)
+unsigned ColorSensor::checkRGB(  
+    unsigned& R, unsigned& G, unsigned& B)
 {
      unsigned i, j, coldata;
      double I;
@@ -119,9 +122,9 @@
       }
     }
     I = R*0.65 + G + B*1.3;
-    R = R*0.65 *100/I;
+    R = R*0.65*100/I;
     G = G*100/I;
-    B = B*1.3 *100/I;
+    B = B*1.3*100/I;
     return I;
 }
 
--- a/ColorSensor.h	Thu Sep 12 12:06:29 2013 +0000
+++ b/ColorSensor.h	Thu Sep 19 05:30:08 2013 +0000
@@ -20,4 +20,5 @@
     unsigned checkRGB(unsigned& R, unsigned& G, unsigned& B);
     int judge();
     void setWhite();
+    void timenow(unsigned short times);
 };
\ No newline at end of file