Control library for the Sparkfun Entertainment Trackballer breakout board.

Revision:
6:c0ebd0f8f873
Parent:
5:0abcaea1fb07
Child:
7:229fc175e05e
--- a/trackballer.cpp	Sat Feb 19 19:57:07 2011 +0000
+++ b/trackballer.cpp	Sat Feb 19 20:31:43 2011 +0000
@@ -4,9 +4,11 @@
 
 
 
-trackballer::trackballer(PinName button, PinName right, PinName down, PinName left, PinName up, PinName red, PinName green, PinName blue, PinName white)
+trackballer::trackballer(PinName button, PinName right, PinName down, PinName left, PinName up, PinName red, PinName green, PinName blue, PinName white, char limits)
 {
     
+    _limits = limits;
+    
     _buttonPin = new DigitalIn(button);
     _rightPin = new DigitalIn(right);
     _downPin = new DigitalIn(down);
@@ -99,9 +101,12 @@
             // if the current state is 1 then the button
             // went from off to on:
             _yPosition-=TRACK_INC;
-            if (_yPosition < 0.0) 
+            if(_limits)
             {
-                _yPosition = 0.0;
+                if (_yPosition < 0.0) 
+                {
+                    _yPosition = 0.0;
+                }
             }
         }
     }
@@ -119,9 +124,12 @@
             // if the current state is 1 then the button
             // went from off to on:
             _yPosition+=TRACK_INC;
-            if (_yPosition > 1.0) 
+            if(_limits)
             {
-                _yPosition = 1.0;
+                if (_yPosition > 1.0) 
+                {
+                    _yPosition = 1.0;
+                }
             }
         }
     }
@@ -139,9 +147,12 @@
             // if the current state is 1 then the button
             // went from off to on:
             _xPosition-=TRACK_INC;
-            if (_xPosition < 0.0) 
+            if(_limits)
             {
-                _xPosition = 0.0;
+                if (_xPosition < 0.0) 
+                {
+                    _xPosition = 0.0;
+                }
             }
         }
     }
@@ -158,9 +169,12 @@
             // if the current state is 1 then the button
             // went from off to on:
             _xPosition+=TRACK_INC;
-            if (_xPosition > 1.0) 
+            if(_limits)
             {
-                _xPosition = 1.0;
+                if (_xPosition > 1.0) 
+                {
+                    _xPosition = 1.0;
+                }
             }
         }
     }
@@ -173,9 +187,13 @@
     yPosition = _yPosition;
 
 
+
+    #if DEBUG_POSITION
     int ixPosition = _xPosition * 95;
     int iyPosition = _yPosition * 63;
     
+    
+    
     if (_outputTimer.read_ms() > 1000) 
     {
         printf("Position:  (x%i, y%i)\n", ixPosition, iyPosition);
@@ -183,5 +201,6 @@
         _outputTimer.reset();
 
     }
+    #endif
 
 }
\ No newline at end of file