Ian Krase / PolyServo

Dependents:   Quadrapod

Files at this revision

API Documentation at this revision

Comitter:
ikrase
Date:
Thu Jul 02 08:53:32 2015 +0000
Parent:
5:92fc8f455565
Child:
7:f9e1e813fa24
Commit message:
Started work on template wrapper, far from 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
SpecifiedTimeout.cpp Show diff for this revision Revisions of this file
SpecifiedTimeout.h Show diff for this revision Revisions of this file
--- a/PolyServo.cpp	Sat Jun 27 08:19:19 2015 +0000
+++ b/PolyServo.cpp	Thu Jul 02 08:53:32 2015 +0000
@@ -15,6 +15,7 @@
         servo_timers.push_back(t);
         positions.push_back(SERVO_DISABLED);
         servos[i]->write(0);
+        ResetWrapper<void(*)(int), Polyservo::servo_set> rwrapper(i);
                
     }
     
--- a/PolyServo.h	Sat Jun 27 08:19:19 2015 +0000
+++ b/PolyServo.h	Thu Jul 02 08:53:32 2015 +0000
@@ -4,7 +4,7 @@
 #include "mbed.h"
 #include "FPointer.h"
 #include <vector>
-#include "SpecifiedTimeout.h"
+//#include "SpecifiedTimeout.h"
 
 
 #define SERVO_DISABLED -1       // This is going to take raw servo microsecond entries. 
@@ -33,10 +33,23 @@
     std::vector<Timeout *> servo_timers;
     //Timeout * servo_times; 
     
-    uint32_t servo_set(uint32_t);
+    void servo_set(int id);
     
     void servos_reset(void);
     
+    template <typename Func, Func func>
+    
+    struct ResetWrapper {
+        ResetWrapper(int id): id_(id) { }
+        void servo_set() {func(id_);}
+        int id_; 
+        };
+        
+    //std::vector<ResetWrapper *> resetws;
+
+        
+        
+    
     
     
     
--- a/SpecifiedTimeout.cpp	Sat Jun 27 08:19:19 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-#include "mbed.h"
-#include "FPointer.h"
-#include "SpecifiedTimeout.h"
-
-
-void SpecifiedTimeout::handler() {
-    _function.call(val);
-}
-
-void SpecifiedTimeout::set_refnum(uint32_t refnum){
-    
-    
-    val = refnum;
-    
-}
\ No newline at end of file
--- a/SpecifiedTimeout.h	Sat Jun 27 08:19:19 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-#ifndef SPECTIMEOUT_H
-#define SPECTIMEOUT_H
-
-#include "mbed.h"
-#include "FPointer.h"
-//namespace mbed{
-
-class SpecifiedTimeout : public Timeout {
-    
-public:
-   uint32_t val;   /*
-    void attach_us(uint32_t (*fptr)(uint32_t) , timestamp_t t, uint32_t val);
-    template<class T>
-    void attach_us(T* tptr, uint32_t(T::*mptr)(uint32_t) , timestamp_t t, uint32_t val); */
-    void set_refnum(uint32_t refnum); 
-protected:
-    virtual void handler();
-    FPointer _function;
-
-private:
-    
-    
-
-
-    
-    
-    
-};
-//namespace mbed{
-
-
-//}
-
-#endif
\ No newline at end of file