DirectionControl.h 1003 Bytes
Newer Older
Manuel Pitz's avatar
Manuel Pitz committed
1
2
3
4
/////////////////////////////////////////////////////////
///// This file does not need any modification, /////////
///// if needed it can be extended //////////////////////
///////////////////////////////////////////////////////// 
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once

#include "PID.h"
#include <Servo.h>

struct directionParameterSet{
  int maxPos, minPos, centerPos;
};

class DirectionControl{
  public:
    DirectionControl(int,directionParameterSet,pidParameterSet);
    ~DirectionControl();

    int getDirection();
Manuel Pitz's avatar
Manuel Pitz committed
20
    
21
22
    void updateDirection();
    void updateController(double);
Manuel Pitz's avatar
Manuel Pitz committed
23
24
25
26
27
28
29
    double getControllerP();
    double getControllerI();
    double getControllerD();
    void setControllerP(double parameterP);
    void setControllerI(double parameterI);
    void setControllerD(double parameterD);
    
30
31
    void testServo();
    void setup();
Manuel Pitz's avatar
Manuel Pitz committed
32
    Servo directionServo;
33
34
35
36
37
38
39
40
41
42
43
  private:
    PID controller;
    
    int servoPin;
    int centerPos;
    int maxPos;
    int minPos;

    unsigned int currentDirection;
};