Ian Krase / PolyServo

Dependents:   Quadrapod

Files at this revision

API Documentation at this revision

Comitter:
ikrase
Date:
Fri Jun 26 08:23:05 2015 +0000
Child:
1:1135f0b1566e
Commit message:
First library-specific commit. Constructor mostly done.

Changed in this revision

PolyServo.cpp Show annotated file Show diff for this revision Revisions of this file
PolyServo.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PolyServo.cpp	Fri Jun 26 08:23:05 2015 +0000
@@ -0,0 +1,22 @@
+
+#include "PolyServo.h"
+#include "mbed.h"
+#include <vector>
+
+
+Polyservo::Polyservo(DigitalOut servo_pins[], int num_pins): numservos(num_pins) {
+    servos.reserve(numservos); servo_times.reserve(numservos); 
+    //numservos = num_pins; 
+    for(int i = 0; i < numservos; i++){
+        Timeout* t = new Timeout(); 
+        servos.push_back(&servo_pins[i]);
+        servo_times.push_back(t);
+               
+    }
+    
+    
+    servos[2]->is_connected();
+    servo_times[2]->detach();
+    
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PolyServo.h	Fri Jun 26 08:23:05 2015 +0000
@@ -0,0 +1,45 @@
+#ifndef POLYSERVO_H
+#define POLYSERVO_H
+
+#include "mbed.h"
+#include <vector>
+
+
+#define SERVO_DISABLED -1       // This is going to take raw servo microsecond entries. 
+#define SERVO_PPM_PERIOD 20000  // In microseconds
+
+class Polyservo {
+public:
+    
+    std::vector<DigitalOut *> servos;
+    //DigitalOut * servos; 
+    
+    bool global_enable; 
+    int position[]; 
+    int numservos; 
+    
+    Polyservo(DigitalOut servo_pins[], int num_pins);
+    void set_position(int pos);
+    
+    
+    
+    
+    
+private: 
+    
+    Ticker period_tick; 
+    std::vector<Timeout *> servo_times;
+    //Timeout * servo_times; 
+    
+    
+    
+    
+    
+    
+
+
+};
+
+
+
+#endif
\ No newline at end of file