Files at this revision

API Documentation at this revision

Comitter:
inst
Date:
Wed Oct 14 03:52:28 2015 +0000
Parent:
0:d660b49b71e0
Commit message:

Changed in this revision

Shooter.cpp Show annotated file Show diff for this revision Revisions of this file
Shooter.h Show annotated file Show diff for this revision Revisions of this file
diff -r d660b49b71e0 -r 215e05be641b Shooter.cpp
--- a/Shooter.cpp	Fri Aug 21 04:52:35 2015 +0000
+++ b/Shooter.cpp	Wed Oct 14 03:52:28 2015 +0000
@@ -2,17 +2,19 @@
 #include "I2CDevice.h"
 
 Shooter::Shooter( char address ) : I2CDevice( address ){
-    
+    mActionType = STOP;
+    mLaunchType = WORKING_8V;
 }
 
-void Shooter::write(){
-    
+void Shooter::launch(){
+    setActionType( mLaunchType );
 }
 
 void Shooter::stop(){
-    
+    setActionType( STOP );
 }
 
-void Shooter::launch(){
-    
+int Shooter::write(){
+    char buf = mActionType;
+    return I2CDevice::write( &buf, 1 );
 }
diff -r d660b49b71e0 -r 215e05be641b Shooter.h
--- a/Shooter.h	Fri Aug 21 04:52:35 2015 +0000
+++ b/Shooter.h	Wed Oct 14 03:52:28 2015 +0000
@@ -5,15 +5,45 @@
 
 class Shooter : public I2CDevice{
 public:
+    enum ActionType{
+        STOP        = 0x00, // 0000(2)
+        WORKING_8V  = 0x01, // 0001(2)
+        WORKING_12V = 0x03, // 0011(2)
+        WORKING_16V = 0x07, // 0111(2)
+        WORKING_20V = 0x0F  // 1111(2)
+    };
+    
     Shooter( char address );
+    
+    void setVoltage( ActionType action ){
+        setLaunchType( action );
+        
+        if ( mActionType != STOP ){
+            setActionType( mLaunchType );
+        }
+    }
+    void setActionType( ActionType action ){
+        mActionType = action;
+    }
+    void setLaunchType( ActionType action ){
+        mLaunchType = action;
+    }
     void launch();
     void stop();
+    bool isWorking(){
+        return ( mActionType != STOP );
+    }
+    
+    ActionType getVoltage(){
+        return mActionType;
+    }
     
 protected:
-    virtual void write();
-    virtual void read(){}
+    virtual int write();
 
 private:
+    ActionType mActionType;
+    ActionType mLaunchType;
 };
 
 #endif