-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServo.hpp
50 lines (41 loc) · 1.29 KB
/
Servo.hpp
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
/*
* MIT License
*/
/*
* File: Servo.hpp
* Author: josh - JKI757
*
* Created on May 24, 2020, 12:21 AM
*/
#pragma once
#include <JetsonGPIO.h>
#include <memory>
#include <cmath>
#include <iostream>
#include <string>
class Servo_Jetson {
public:
Servo_Jetson();
Servo_Jetson(const Servo_Jetson& orig);
virtual ~Servo_Jetson();
Servo_Jetson(int pin);
Servo_Jetson(std::shared_ptr<GPIO::PWM> steer, bool setup);
Servo_Jetson(int pin, const unsigned short minUs, const unsigned short maxUs);
Servo_Jetson(int pin, const unsigned short minUs, const unsigned short maxUs, const unsigned short mapMin, const unsigned short mapMax);
Servo_Jetson(std::shared_ptr<GPIO::PWM> steer, const unsigned short minUs, const unsigned short maxUs, const unsigned short mapMin, const unsigned short mapMax, bool setup);
unsigned short mapAngle(const short val);
void writeAngle(const unsigned short angle);
void writeUs(const unsigned short microseconds);
void writeMappedValue(const short val);
private:
int pin;
unsigned short angle;
unsigned short microseconds;
unsigned short minUs;
unsigned short maxUs;
short mapMin;
short mapMax;
std::shared_ptr<GPIO::PWM> Steer_PWM;
unsigned short map(const short val);
bool setup;
};