libkovan  1
The kovan standard library
Servo Class Reference

Encapsulates the concept of a servo motor. More...

#include <servo.hpp>

Public Types

typedef unsigned int ticks_t
 

Public Member Functions

 Servo (port_t port)
 
void setPosition (ticks_t position)
 
ticks_t position () const
 
void disable ()
 
void enable ()
 
void setEnabled (const bool &enabled)
 
bool isEnabled () const
 

Detailed Description

Encapsulates the concept of a servo motor.

Member Typedef Documentation

typedef unsigned int Servo::ticks_t

Constructor & Destructor Documentation

Servo::Servo ( port_t  port)

Create a new servo object.

Parameters
portThe associated physical servo port

Member Function Documentation

void Servo::disable ( )
void Servo::enable ( )
bool Servo::isEnabled ( ) const
ticks_t Servo::position ( ) const
Returns
The servo's position as a 10 bit integer
Note
Thie method will return the last sent position, not the currently set position.
For example, imagine the following:
  1. myServo.setPosition(700);
  2. ... Some time passes ...
  3. myServo.setPosition(300);
  4. myServo.position();
position() will return 700 rather than 300, because 300 hasn't been sent to the servo yet.
void Servo::setEnabled ( const bool &  enabled)
void Servo::setPosition ( ticks_t  position)
Parameters
positionThe new servo position, between 0 and 1024
Note
Even though the servos have a theoretical range between 0 and 1023, the actual range is often less. Setting the servo to a position that it cannot physically reach will cause the servo to audibly strain and will consume battery very quickly.

The documentation for this class was generated from the following file: