-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoboGarntMotor.h
73 lines (63 loc) · 1.92 KB
/
RoboGarntMotor.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
//
// Created by grant on 8/3/16.
//
// #define MOTOR_PIN 0
// #define MOTOR_REVERSE_MIN 900
// #define MOTOR_NEUTRAL 1500
// #define MOTOR_DEADBAND 25
// #define MOTOR_FORWARD_MAX 2100
//
// #define MOTOR_PIN 0
// #define MOTOR_REVERSE_MIN 900
// #define MOTOR_NEUTRAL 1495
// #define MOTOR_DEADBAND 25
// #define MOTOR_FORWARD_MAX 2090
// #define THROTTLE_GAIN 3.7 // calibrated to stop when one sensor hits min
#ifndef ROBOPI_GARNT_CPP_ROBOGARNTMOTOR_H
#define ROBOPI_GARNT_CPP_ROBOGARNTMOTOR_H
class RoboGarntMotor {
public:
static constexpr double THROTTLE_GAIN = 3.7;
RoboGarntMotor (int, int, int, int, int);
int LimitCheck (int);
int get_pin() const { return pin_; }
int get_reverse() const { return reverse_; }
int get_min() const { return min_; }
int get_neutral() const { return neutral_; }
int get_deadband() const { return deadband_; }
int get_forwards() const { return forwards_; }
int get_max() const { return max_; }
void set_pin (int pin) { pin_ = pin; }
void set_reverse (int reverse) { reverse_ = reverse; }
void set_min (int min) { min_ = min; }
void set_neutral (int neutral) { neutral_ = neutral; }
void set_deadband (int deadband) { deadband_ = deadband; }
void set_forwards (int forwards) { forwards_ = forwards; }
void set_max (int max) { max_ = max; }
private:
int pin_;
int reverse_;
int min_;
int neutral_;
int deadband_;
int forwards_;
int max_;
};
RoboGarntMotor::RoboGarntMotor(int pin, int reverse_min, int neutral,
int deadband, int forwards_max) {
pin_ = pin;
reverse_ = reverse_min;
min_ = reverse_min;
neutral_ = neutral;
deadband_ = deadband;
forwards_ = forwards_max;
max_ = forwards_max;
}
int RoboGarntMotor::LimitCheck(int motor_setting) {
if (motor_setting > max_)
motor_setting = max_;
if (motor_setting < min_)
motor_setting = min_;
return motor_setting;
}
#endif //ROBOPI_GARNT_CPP_ROBOGARNTMOTOR_H