-
Notifications
You must be signed in to change notification settings - Fork 0
/
L298NX2.h
82 lines (72 loc) · 2.39 KB
/
L298NX2.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
#ifndef L298NX2_h
#define L298NX2_h
#include "Arduino.h"
#include "L298N.h"
typedef void (*CallBackFunction)();
class L298NX2
{
public:
L298NX2(
uint8_t pinEnable_A,
uint8_t pinIN1_A,
uint8_t pinIN2_A,
uint8_t pinEnable_B,
uint8_t pinIN1_B,
uint8_t pinIN2_B);
L298NX2(uint8_t pinIN1_A,
uint8_t pinIN2_A,
uint8_t pinIN1_B,
uint8_t pinIN2_B);
//MOTOR A
void setSpeedA(unsigned short pwmVal_A);
unsigned short getSpeedA();
void forwardA();
void forwardForA(unsigned long delay_A, CallBackFunction callback_A);
void forwardForA(unsigned long delay_A);
void backwardA();
void backwardForA(unsigned long delay_A, CallBackFunction callback_A);
void backwardForA(unsigned long delay_A);
void runA(L298N::Direction direction_A);
void runForA(unsigned long delay_A, L298N::Direction direction_A);
void runForA(unsigned long delay_A, L298N::Direction direction_A, CallBackFunction callback_A);
void stopA();
void resetA();
boolean isMovingA();
L298N::Direction getDirectionA();
//MOTOR B
void setSpeedB(unsigned short pwmVal_B);
unsigned short getSpeedB();
void forwardB();
void forwardForB(unsigned long delay_B, CallBackFunction callback_B);
void forwardForB(unsigned long delay_B);
void backwardB();
void backwardForB(unsigned long delay_B, CallBackFunction callback_B);
void backwardForB(unsigned long delay_B);
void runB(L298N::Direction direction_B);
void runForB(unsigned long delay_B, L298N::Direction direction_B);
void runForB(unsigned long delay_B, L298N::Direction direction_B, CallBackFunction callback_B);
void stopB();
void resetB();
boolean isMovingB();
L298N::Direction getDirectionB();
//BOTH
void setSpeed(unsigned short pwmVal);
void forward();
void forwardFor(unsigned long delay, CallBackFunction callback);
void forwardFor(unsigned long delay);
void backward();
void backwardFor(unsigned long delay, CallBackFunction callback);
void backwardFor(unsigned long delay);
void run(uint8_t direction);
void runFor(unsigned long delay, L298N::Direction direction);
void runFor(unsigned long delay, L298N::Direction direction, CallBackFunction callback);
void stop();
void reset();
private:
L298N _motorA;
L298N _motorB;
unsigned long _lastMs;
boolean _canMove;
static void fakeCallback();
};
#endif