Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* sevoclass.h
*
* Created on: 27. 6. 2014
* Author: martin.vitek
*/
#pragma once
#include <avr/io.h>
#include <math.h>
#include <stdint.h>
struct servo_data
{
//Min a max doba kontrolniho pulzu v us
uint16_t min_duration;
uint16_t max_duration;
//Parametry PWM
uint16_t ICR_value;
uint16_t pulse_duration;
};
class servo_class
{
//Promenne
private:
volatile uint8_t *ddr;
uint8_t bit;
volatile uint16_t *ocr;
volatile uint8_t current_angle;
servo_data &data;
uint8_t one_step;
uint8_t one_degree_pulse;
//Metody
public:
//Konstruktor
servo_class(volatile uint8_t *ddr, uint8_t bit, volatile uint16_t *ocr, servo_data &data);
//Destruktor
~servo_class();
//Metody
void set_angle(uint8_t angle);
uint8_t get_angle() { return current_angle; };
};