-
Notifications
You must be signed in to change notification settings - Fork 0
/
MobaBus_ServoPCA.h
85 lines (54 loc) · 2.1 KB
/
MobaBus_ServoPCA.h
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
/**
MobaBus Servo PCA9685
© 2021, Markus Mair. All rights reserved.
This file is part of the MobaBus Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MOBA_SERVO_PCA__
#define __MOBA_SERVO_PCA__
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include "MobaBus.h"
#include "MobaBus_Module.h"
#define SERVOMIN 100 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 550 // this is the 'maximum' pulse length count (out of 4096)575
class MobaBus_ServoPCA : public MobaBus_Module {
private:
Adafruit_PWMServoDriver servoBoard;
uint8_t angles[2];
uint8_t actualAngle[16];
uint8_t targetAngle[16];
bool active[16];
int16_t remainingTime[16];
uint32_t lastMove;
uint8_t moveSpeed;
uint16_t autoPowerOff;
public:
/**
* Constructor for Turnouts with one PCA9685 module
* initialized with standard Address 0x40
*/
MobaBus_ServoPCA(uint8_t angle0, uint8_t angle1, uint8_t speed, uint16_t autoPowerOff);
/**
* Constructor for Turnouts with one or multiple PCA9685 modules
* @param addr of the module (standard = 0x40)
*/
MobaBus_ServoPCA(uint16_t addr, uint8_t angle0, uint8_t angle1, uint8_t speed, uint16_t autoPowerOff);
bool begin();
void loop();
int loadConf(uint16_t eepromAddress) override;
int storeConf(uint16_t eepromAddress) override;
void processPkg(MobaBus_Packet *pkg);
void setTurnout(uint8_t pin, uint8_t dir, bool power = true);
};
#endif