-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathL298N_Jetson.hpp
59 lines (44 loc) · 1.16 KB
/
L298N_Jetson.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
49
50
51
52
53
54
55
56
57
/*
* nMIT License
*
* */
/*
* File: L298N_Jetson.h
* Author: josh -- JKI757
*
* Created on May 23, 2020, 12:58 AM
*/
#pragma once
#include <JetsonGPIO.h>
#include <memory>
#include <cmath>
#include "definitions.h"
#include <iostream>
class L298N_Jetson {
public:
L298N_Jetson();
~L298N_Jetson();
L298N_Jetson(const int EnablePin, const int IN1, const int IN2);
L298N_Jetson(const int IN1, const int IN2);
L298N_Jetson(std::shared_ptr<GPIO::PWM> drive, const int IN1, const int IN2,
const bool setup, const unsigned short minInput, const unsigned short maxInput);
void setSpeed(const unsigned short pwmVal);
const unsigned short getSpeed();
void forward();
void backward();
void run();
void stop();
void reset();
private:
int Enable;
int IN1;
int IN2;
unsigned short pwmVal;
const unsigned short maxSpeed = 100;
const unsigned short minSpeed = 0;
unsigned short minInput;
unsigned short maxInput;
std::shared_ptr<GPIO::PWM> Drive_PWM;
bool setup; //controls whether or not we control the PWM object. False if we don't.
unsigned short map(const unsigned short val);
};