Accessories
Arduino for motors and lights library.
PortServo.hpp
1 //-------------------------------------------------------------------
2 #ifndef __PortServo_H__
3 #define __PortServo_H__
4 //-------------------------------------------------------------------
5 
6 #ifndef NO_SERVO
7 #include "Servo.h"
8 #include "Accessories.h"
9 
13 class PortServo : public Port
14 {
15  protected:
17  int pin;
19  Servo servo;
20 
21  public:
23  PortServo();
24 
28  void begin(int inPin);
32  void beginByAccessory(int inStartingPosition);
33 
37  inline bool IsActive() const { return this->pin > -1; }
41  inline int GetPin() const { return this->pin; }
45  inline GPIO_pin_t GetDIOPin() const { return Arduino_to_GPIO_pin(this->pin); }
46 
51  void MovePosition(unsigned long inDuration, int inEndPosition);
54  inline void MoveStop() { this->servo.detach(); }
58  int GetPosition();
59 #ifdef ACCESSORIES_PRINT_ACCESSORIES
60 
63  void printPort();
64 #endif
65 };
66 #endif
67 
68 //-------------------------------------------------------------------
69 #endif
70 //-------------------------------------------------------------------
void printPort()
Definition: PortServo.cpp:67
int GetPosition()
Definition: PortServo.cpp:59
void MovePosition(unsigned long inDuration, int inEndPosition)
Definition: PortServo.cpp:39
GPIO_pin_t GetDIOPin() const
Definition: PortServo.hpp:45
bool IsActive() const
Definition: PortServo.hpp:37
void beginByAccessory(int inStartingPosition)
Definition: PortServo.cpp:23
virtual void begin()
Definition: Port.hpp:117
int GetPin() const
Definition: PortServo.hpp:41
Servo servo
Definition: PortServo.hpp:19
Definition: Port.hpp:60
void MoveStop()
Definition: PortServo.hpp:54