direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Servo Class Reference

This class controls connected servos. More...

#include <servo.h>

Collaboration diagram for Servo:

List of all members.

Public Slots

void init (void)
bool moveServo (unsigned char servo, unsigned char position)
void setRobotState (bool state)

Signals

void message (QString text)

Public Member Functions

unsigned char getServoPosition (int servo, unsigned char type=SVCURRENT)
 Servo (InterfaceAvr *i, QMutex *m)
void setServoPosition (int servo, unsigned char type, unsigned char position)
 ~Servo ()

Private Attributes

QString className
InterfaceAvrinterface1
QMutex * mutex
 this will contain the name of this class at runtime.
bool robotState
int servoDefaultPosition [NUMBEROFSERVOS]
int servoEndPosition [NUMBEROFSERVOS]
int servoMaxPosition [NUMBEROFSERVOS]
int servoMinPosition [NUMBEROFSERVOS]
int servoPosition [NUMBEROFSERVOS]
int servoStartPosition [NUMBEROFSERVOS]

Static Private Attributes

static const unsigned char NUMBEROFSERVOS = 6
 defines the size of the servo[] arrays.
static const bool OFF = false
static const bool ON = true
 the current position of the servo!
static const unsigned char SERVO1 = 0
 the servo numbers
static const unsigned char SERVO2 = 1
static const unsigned char SERVO3 = 2
static const unsigned char SERVO4 = 3
static const unsigned char SERVO5 = 4
static const unsigned char SERVO6 = 5
static const unsigned char SET_SERVO1 = 42
 the command for the microcontroller
static const unsigned char SET_SERVO2 = 43
static const unsigned char SET_SERVO3 = 44
static const unsigned char SET_SERVO4 = 45
static const unsigned char SET_SERVO5 = 46
static const unsigned char SET_SERVO6 = 47
static const unsigned char SVCURRENT = 3
static const unsigned char SVDEFAULT = 2
static const unsigned char SVEND = 1
static const unsigned char SVMAX = 5
static const unsigned char SVMIN = 4
static const unsigned char SVSTART = 0
 the possible servo data
static const unsigned long THREADSLEEPTIME = 100

Detailed Description

This class controls connected servos.

Author:
Markus Knapp It has to be a thread because of communicating at the same time with the microcontroller via the class.
See also:
InterfaceAvr() !

Definition at line 38 of file servo.h.


Constructor & Destructor Documentation

Servo::Servo ( InterfaceAvr i,
QMutex *  m 
)

Definition at line 23 of file servo.cpp.

Servo::~Servo ( )

Definition at line 47 of file servo.cpp.


Member Function Documentation

unsigned char Servo::getServoPosition ( int  servo,
unsigned char  type = SVCURRENT 
)

Returns the servo start, end, default or current position.

Parameters:
servois the servo number.
typecan be SVMIN, SVMAX, SVSTART, SVEND, SVDEFAULT or SVCURRENT=default
Returns:
the servo position (0 - 255)

Definition at line 171 of file servo.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Servo::init ( void  )
slot

Moves all servos into their default positions.

Definition at line 158 of file servo.cpp.

Here is the call graph for this function:

void Servo::message ( QString  text)
signal

Emits a message to be displayed in the GUI or be used somewhere else (e.g. error message).

Here is the caller graph for this function:

bool Servo::moveServo ( unsigned char  servo,
unsigned char  position 
)
slot

Moves a servo.

Parameters:
servois the servo number.
positionis the position (0 - 255).
Returns:
true on success

Definition at line 52 of file servo.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Servo::setRobotState ( bool  state)
slot

This slots takes the robot (circuit) state, to know if the robot is ON or OFF. When the class knows this, unnecessary communication with the interface can be avoided.

Parameters:
statecan be ON or OFF

Definition at line 207 of file servo.cpp.

Here is the call graph for this function:

void Servo::setServoPosition ( int  servo,
unsigned char  type,
unsigned char  position 
)

Sets the servos maximum start, end and its default position.

Parameters:
servois the servo number.
typecan be SVMIN, SVMAX, SVSTART, SVEND, SVDEFAULT or SVCURRENT
positionis the position (0 - 255).

Definition at line 112 of file servo.cpp.

Here is the caller graph for this function:


Member Data Documentation

QString Servo::className
private

Definition at line 93 of file servo.h.

InterfaceAvr* Servo::interface1
private

Definition at line 95 of file servo.h.

QMutex* Servo::mutex
mutableprivate

this will contain the name of this class at runtime.

See also:
takeCommandAnswer()

Definition at line 94 of file servo.h.

const unsigned char Servo::NUMBEROFSERVOS = 6
staticprivate

defines the size of the servo[] arrays.

Definition at line 103 of file servo.h.

const bool Servo::OFF = false
staticprivate

For motor or robot "ON"

Definition at line 113 of file servo.h.

const bool Servo::ON = true
staticprivate

the current position of the servo!

Definition at line 112 of file servo.h.

bool Servo::robotState
private

Definition at line 96 of file servo.h.

const unsigned char Servo::SERVO1 = 0
staticprivate

the servo numbers

Definition at line 124 of file servo.h.

const unsigned char Servo::SERVO2 = 1
staticprivate

Definition at line 125 of file servo.h.

const unsigned char Servo::SERVO3 = 2
staticprivate

Definition at line 126 of file servo.h.

const unsigned char Servo::SERVO4 = 3
staticprivate

Definition at line 127 of file servo.h.

const unsigned char Servo::SERVO5 = 4
staticprivate

Definition at line 128 of file servo.h.

const unsigned char Servo::SERVO6 = 5
staticprivate

Definition at line 129 of file servo.h.

int Servo::servoDefaultPosition[NUMBEROFSERVOS]
private

Definition at line 108 of file servo.h.

int Servo::servoEndPosition[NUMBEROFSERVOS]
private

Definition at line 105 of file servo.h.

int Servo::servoMaxPosition[NUMBEROFSERVOS]
private

Definition at line 107 of file servo.h.

int Servo::servoMinPosition[NUMBEROFSERVOS]
private

Definition at line 106 of file servo.h.

int Servo::servoPosition[NUMBEROFSERVOS]
private

Definition at line 109 of file servo.h.

int Servo::servoStartPosition[NUMBEROFSERVOS]
private
Todo:
also defined in direcs.h !!!

Definition at line 104 of file servo.h.

const unsigned char Servo::SET_SERVO1 = 42
staticprivate

the command for the microcontroller

Definition at line 132 of file servo.h.

const unsigned char Servo::SET_SERVO2 = 43
staticprivate

Definition at line 133 of file servo.h.

const unsigned char Servo::SET_SERVO3 = 44
staticprivate

Definition at line 134 of file servo.h.

const unsigned char Servo::SET_SERVO4 = 45
staticprivate

Definition at line 135 of file servo.h.

const unsigned char Servo::SET_SERVO5 = 46
staticprivate

Definition at line 136 of file servo.h.

const unsigned char Servo::SET_SERVO6 = 47
staticprivate

Definition at line 137 of file servo.h.

const unsigned char Servo::SVCURRENT = 3
staticprivate

Definition at line 119 of file servo.h.

const unsigned char Servo::SVDEFAULT = 2
staticprivate

Definition at line 118 of file servo.h.

const unsigned char Servo::SVEND = 1
staticprivate

Definition at line 117 of file servo.h.

const unsigned char Servo::SVMAX = 5
staticprivate

Definition at line 121 of file servo.h.

const unsigned char Servo::SVMIN = 4
staticprivate

Definition at line 120 of file servo.h.

const unsigned char Servo::SVSTART = 0
staticprivate

the possible servo data

For motor or robot "OFF"

Definition at line 116 of file servo.h.

const unsigned long Servo::THREADSLEEPTIME = 100
staticprivate

Definition at line 100 of file servo.h.


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