Library to handle SpaceBall, SpaceMouse and SpaceOrb on serial port. Gets access to 3D rotation and translation vector as well as button status. (USB is not supported)

Dependents:   SpaceBall_Example

Library to handle SpaceBall, SpaceMouse and SpaceOrb on serial port. Gets access to 3D rotation and translation vector as well as button status. (USB is not supported)

All handling and decoding is done in the RX interrupt and the vector values can be read out asynchronously with different coordinate mappings.

Example:

#include "mbed.h"
#include "SpaceBall.h"
 
PwmOut led[] = {(LED1), (LED2), (LED3), (LED4) };
SpaceBall SBall(p9, p10);   // tx, rx, bSOrb
 
int main() {
    SBall.Init();
    
    while(1) {
 
        led[0] = abs( SBall[TX] ) + abs( SBall[TY] ) + abs( SBall[TZ] );
        led[1] = abs( SBall[RX] );
        led[2] = abs( SBall[RY] );
        led[3] = abs( SBall[RZ] );
        
        wait_us(500);
    }
}

In this exaple the 4 LEDs are powered dependent on force at the Spaceball. LED1 shows the sum of all translation forces. LED2 to LED4 shows the rotation forces.

For more information about SpaceBall devices see manufactorers page http://www.3dconnexion.com

For connecting a SpaceBall (or SpaceMouse or SpaceOrb) to mbed see page wiki/Serial-Connection

Example: SpaceBall 4000

/media/uploads/jocis/spaceball1.jpg

Revision:
1:e6282b645d9b
Parent:
0:f67a8fffd94a
Child:
2:a7c0fcd157f7
--- a/SpaceBall.h	Sat Dec 01 05:30:34 2012 +0000
+++ b/SpaceBall.h	Sat Dec 01 18:23:50 2012 +0000
@@ -34,6 +34,8 @@
 #define SBALL_MODE_LEFTY     0x8000   /* bit 15 */
 
 
+#define SPACEBALL_MAX_LENGTH    128
+
 enum eSpaceBallAxis { 
     TX=0, TY, TZ, 
     Right=0, Forward, Up, 
@@ -117,9 +119,17 @@
     int m_leftymode4000; /* if set, Spaceball 4000 in "lefty" orientation */
     int m_timer;         /* time since last packet was received */
 
-    void InitSB() {};
-    void InitSO() {};
+    bool _escape;
+    int _idx;
+    char _data[SPACEBALL_MAX_LENGTH];
+    
+    void InitSB();
+    void InitSO();
 
     void ProcessSB ( char c );
     void ProcessSO ( char c );
+    
+    void ProcessPacketSB ( void );
+    void ProcessPacketSO ( void );
+
 };
\ No newline at end of file