Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Files at this revision

API Documentation at this revision

Comitter:
kyleliangus
Date:
Fri Apr 28 04:08:34 2017 +0000
Parent:
4:b5b7836ca2b0
Child:
6:3d68fedd6fd9
Commit message:
Fixed IR Class

Changed in this revision

irled.cpp Show annotated file Show diff for this revision Revisions of this file
irled.h Show annotated file Show diff for this revision Revisions of this file
--- a/irled.cpp	Fri Apr 28 02:13:24 2017 +0000
+++ b/irled.cpp	Fri Apr 28 04:08:34 2017 +0000
@@ -4,7 +4,7 @@
 void IrLed::calibrateSensor() {
 
     for (int i = 0; i < samplesToTake; ++i) 
-        sensorAvg += ir.read();
+        sensorAvg += recv.read();
         
     sensorAvg /= samplesToTake;
 }
@@ -12,16 +12,13 @@
 float IrLed::getSamples( int samples )
 {
     float z = 0;
+    ir.write( 1 );
     for( int i = 0; i < samples; ++i )
-        z += ir.read();
+        z += recv.read();
+    ir.write( 0 );
     return z / samples;
 }
 
-float IrLed::blinkLED( int i )
-{
-    return 0.0;
-}
-
 /*
 inline float IrLED::blinkLED( int i, int samples )
 {
--- a/irled.h	Fri Apr 28 02:13:24 2017 +0000
+++ b/irled.h	Fri Apr 28 04:08:34 2017 +0000
@@ -8,7 +8,7 @@
 class IrLed
 {
     public:
-        IrLed( PinName pin ) : ir( pin ) 
+        IrLed( PinName pin, PinName rec ) : ir( pin ), recv( rec )
         {
             calibrateSensor();
         }
@@ -20,6 +20,7 @@
         
         // internal values
         DigitalOut ir;
+        AnalogIn recv;
         float sensorAvg;
 };