-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservo.h
More file actions
110 lines (94 loc) · 2.5 KB
/
servo.h
File metadata and controls
110 lines (94 loc) · 2.5 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* @file servo.h
* @brief Functions for working with the servos
*/
#ifndef SERVO_H_
#define SERVO_H_
#include <Arduino.h>
/**
* @brief Struct for Input settings
*/
struct input_t {
bool enabled;
uint8_t pin;
uint16_t min;
uint16_t max;
uint16_t value;
};
/**
* @brief Struct for Servo settings
*/
struct servo_t {
bool enabled;
uint8_t pin;
uint16_t min;
uint16_t max;
uint16_t value;
uint8_t filter;
input_t input;
bool invert;
};
/**
* @brief Setup the servo output (Note: This is required)
*/
void setupServos(void);
/**
* @brief Load input data from the config file to an array
*/
void processInputs(void);
/**
* @brief Get the total number of inputs from the config file
*
* @return Returns the total number of inputs, 0 ... 15
*/
uint8_t getInputCount(void);
/**
* @brief Load servo data from the config file to an array
*/
void processServos(void);
/**
* @brief Get the total number of servos from the config file
*
* @return Returns the total number of servos, 0 ... 15
*/
uint8_t getServoCount(void);
/**
* @brief Move all enabled servos to the center position
*/
void centerServos(void);
/**
* @brief Read a given servo input and update its position
*
* @param number Servo number to update, 0 ... 15
*/
void updateServo(uint8_t number);
/**
* @brief Configure servo Min/Max
*
* @param pin Input pin to read, 0 ... 15
* @param servo Servo pin to write, 0 ... 15
* @return Returns the servo position as uint16_t, 150 ... 600
*/
uint16_t minmaxServo(uint8_t pin, uint8_t servo);
/**
* @brief Read a given servo input, save it to the show file and update its position
*
* @param number Servo number to record, 0 ... 15
*/
void recordServo(uint8_t number);
/**
* @brief Read a given servo from the show file and update its position
*
* @param number Servo number to play, 0 ... 15
*/
void playServo(uint8_t number);
/**
* @brief Filter servo value for smoothing
*
* @param servoValue @Todo
* @param inputValue @Todo
* @param filter @Todo
* @return Returns filtered servo value
*/
float filter(float servoValue, float inputValue, uint8_t filter);
#endif // SERVO_H_