Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
PolyServo.h@6:bad5554bb890, 2015-07-02 (annotated)
- Committer:
- ikrase
- Date:
- Thu Jul 02 08:53:32 2015 +0000
- Revision:
- 6:bad5554bb890
- Parent:
- 3:1d16a22386a8
- Child:
- 7:f9e1e813fa24
Started work on template wrapper, far from done.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ikrase | 0:6105cf98b610 | 1 | #ifndef POLYSERVO_H |
| ikrase | 0:6105cf98b610 | 2 | #define POLYSERVO_H |
| ikrase | 0:6105cf98b610 | 3 | |
| ikrase | 0:6105cf98b610 | 4 | #include "mbed.h" |
| ikrase | 1:1135f0b1566e | 5 | #include "FPointer.h" |
| ikrase | 0:6105cf98b610 | 6 | #include <vector> |
| ikrase | 6:bad5554bb890 | 7 | //#include "SpecifiedTimeout.h" |
| ikrase | 0:6105cf98b610 | 8 | |
| ikrase | 0:6105cf98b610 | 9 | |
| ikrase | 0:6105cf98b610 | 10 | #define SERVO_DISABLED -1 // This is going to take raw servo microsecond entries. |
| ikrase | 2:f982504e6e84 | 11 | #define PPM_PERIOD 20000 // In microseconds |
| ikrase | 0:6105cf98b610 | 12 | |
| ikrase | 0:6105cf98b610 | 13 | class Polyservo { |
| ikrase | 0:6105cf98b610 | 14 | public: |
| ikrase | 0:6105cf98b610 | 15 | |
| ikrase | 0:6105cf98b610 | 16 | std::vector<DigitalOut *> servos; |
| ikrase | 0:6105cf98b610 | 17 | //DigitalOut * servos; |
| ikrase | 0:6105cf98b610 | 18 | |
| ikrase | 0:6105cf98b610 | 19 | bool global_enable; |
| ikrase | 1:1135f0b1566e | 20 | std::vector<int> positions; |
| ikrase | 0:6105cf98b610 | 21 | int numservos; |
| ikrase | 0:6105cf98b610 | 22 | |
| ikrase | 0:6105cf98b610 | 23 | Polyservo(DigitalOut servo_pins[], int num_pins); |
| ikrase | 1:1135f0b1566e | 24 | void set_position(int s, int pos); |
| ikrase | 0:6105cf98b610 | 25 | |
| ikrase | 0:6105cf98b610 | 26 | |
| ikrase | 0:6105cf98b610 | 27 | |
| ikrase | 0:6105cf98b610 | 28 | |
| ikrase | 0:6105cf98b610 | 29 | |
| ikrase | 0:6105cf98b610 | 30 | private: |
| ikrase | 0:6105cf98b610 | 31 | |
| ikrase | 0:6105cf98b610 | 32 | Ticker period_tick; |
| ikrase | 1:1135f0b1566e | 33 | std::vector<Timeout *> servo_timers; |
| ikrase | 0:6105cf98b610 | 34 | //Timeout * servo_times; |
| ikrase | 0:6105cf98b610 | 35 | |
| ikrase | 6:bad5554bb890 | 36 | void servo_set(int id); |
| ikrase | 1:1135f0b1566e | 37 | |
| ikrase | 1:1135f0b1566e | 38 | void servos_reset(void); |
| ikrase | 1:1135f0b1566e | 39 | |
| ikrase | 6:bad5554bb890 | 40 | template <typename Func, Func func> |
| ikrase | 6:bad5554bb890 | 41 | |
| ikrase | 6:bad5554bb890 | 42 | struct ResetWrapper { |
| ikrase | 6:bad5554bb890 | 43 | ResetWrapper(int id): id_(id) { } |
| ikrase | 6:bad5554bb890 | 44 | void servo_set() {func(id_);} |
| ikrase | 6:bad5554bb890 | 45 | int id_; |
| ikrase | 6:bad5554bb890 | 46 | }; |
| ikrase | 6:bad5554bb890 | 47 | |
| ikrase | 6:bad5554bb890 | 48 | //std::vector<ResetWrapper *> resetws; |
| ikrase | 6:bad5554bb890 | 49 | |
| ikrase | 6:bad5554bb890 | 50 | |
| ikrase | 6:bad5554bb890 | 51 | |
| ikrase | 6:bad5554bb890 | 52 | |
| ikrase | 0:6105cf98b610 | 53 | |
| ikrase | 0:6105cf98b610 | 54 | |
| ikrase | 0:6105cf98b610 | 55 | |
| ikrase | 0:6105cf98b610 | 56 | |
| ikrase | 0:6105cf98b610 | 57 | |
| ikrase | 0:6105cf98b610 | 58 | |
| ikrase | 0:6105cf98b610 | 59 | |
| ikrase | 0:6105cf98b610 | 60 | }; |
| ikrase | 0:6105cf98b610 | 61 | |
| ikrase | 0:6105cf98b610 | 62 | |
| ikrase | 0:6105cf98b610 | 63 | |
| ikrase | 0:6105cf98b610 | 64 | #endif |