譯文 張 / Mbed 2 deprecated BX-car

Dependencies:   mbed

Fork of BX-car by Clark Lin

Files at this revision

API Documentation at this revision

Comitter:
backman
Date:
Sun May 25 12:41:59 2014 +0000
Child:
1:82bc25a7b68b
Commit message:
camera

Changed in this revision

camera_api.cpp Show annotated file Show diff for this revision Revisions of this file
camera_api.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
motor_api.cpp Show annotated file Show diff for this revision Revisions of this file
servo_api.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/camera_api.h	Sun May 25 12:41:59 2014 +0000
@@ -0,0 +1,42 @@
+
+
+
+class BX_camera{
+    
+    
+    
+    public:
+    
+    
+    
+    private:
+    
+    
+    DigitalOut *line_CLK;
+
+    DigitalOut *si;
+
+
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    };
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun May 25 12:41:59 2014 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+
+BX_servo servo;
+
+
+
+
+
+int main() {
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun May 25 12:41:59 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motor_api.cpp	Sun May 25 12:41:59 2014 +0000
@@ -0,0 +1,120 @@
+#include "mbed.h"
+#include "motor_api.h"
+
+#define init_v 10  // period in 1.35 ~170ms
+
+
+
+
+
+
+
+
+ BX_motor::BX_motor(char type){
+    
+    
+ 
+ 
+  
+   //need N level????
+  engine_enable = new DigitalOut(PTE21);  
+  
+   *engine_enable=1;
+    
+    Type=type;
+    switch (type){
+     
+        case 'A':
+          forward_A = new PwmOut(PTC3);
+          backward_A = new   PwmOut(PTC4);
+         
+         forward_A->period_ms(init_v);
+         backward_A->period_ms(init_v);
+         *forward_A=0.5f;
+         *backward_A=0.5f;
+        
+        break;
+        
+        
+       case 'B':     
+         
+         forward_B = new PwmOut(PTC1);
+         backward_B = new PwmOut(PTC2);
+         forward_B->period_ms(init_v);
+         backward_B->period_ms(init_v);
+         *forward_B=0.5f;
+         *backward_B=0.5f;
+       break;
+     
+     
+     
+  }
+     
+    }
+
+
+// level: -1.0 ~1.0
+void BX_motor::rotate(float level){
+       
+       Level=level;
+    
+       if(level >0){
+         
+         switch(Type){
+         
+         case 'A':
+              *forward_A=level;
+              *backward_A=0;
+         break;
+         case 'B':
+              *forward_B=level;
+              *backward_B=0;
+         break;  
+         }
+           
+       }else if(level <0){
+           
+            level=-1.0*level;
+           
+         switch(Type){
+         
+         case 'A':
+             *forward_A=0;
+              *backward_A=level;
+         break;
+         case 'B':
+            *forward_B=0;
+              *backward_B=level;
+         break;  
+         }
+           
+      }
+       else{
+         switch(Type){
+         
+            case 'A':
+              *forward_A=1.0f;
+              *backward_A=1.0f;
+                
+            break;
+            case 'B':
+               *forward_B=1.0f;
+              *backward_B=1.0f;
+            break;  
+         }
+           
+           
+           }
+       
+       
+    
+    
+    
+    
+    
+    
+    
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/servo_api.h	Sun May 25 12:41:59 2014 +0000
@@ -0,0 +1,31 @@
+
+
+
+#include "mbed.h"
+
+
+
+class BX_servo{
+    
+    
+    public:
+        int set_angle(int a);
+    
+        BX_servo(void);
+    
+    
+    
+    
+    
+    
+    
+    private:
+    
+        //-90~0~90
+        int angle ;
+    
+        PwmOut* servo_in;
+         //0~36  // 18 mid  
+        float angle_level[37];
+    
+    };
\ No newline at end of file