-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathifx007t.cpp
More file actions
94 lines (87 loc) · 1.88 KB
/
ifx007t.cpp
File metadata and controls
94 lines (87 loc) · 1.88 KB
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
86
87
88
89
90
91
92
93
94
#include <Arduino.h>
#include "ifx007t.h"
//----------------------------------------------------public Functions----------------------------------------------------
//Please use these functions in your sketch
/*-----------------------------
constructor for class, not needed by Arduino but for complete class. does not do anything.
*/
Ifx007t::Ifx007t()
{
}
/*-----------------------------
destructor for class, not needed by Arduino but for complete class. Calls Arduino end function
*/
Ifx007t::~Ifx007t()
{
end();
}
/*-----------------------------
Arduino begin function. Forward data to initialize function
*/
void Ifx007t::begin(byte bp_pwm1, byte bp_pwm2, byte bp_inh)
{
Ifx007t::p_pwm1=bp_pwm1;
Ifx007t::p_pwm2=bp_pwm2;
Ifx007t::p_inh=bp_inh;
pinMode(p_pwm1, OUTPUT);
pinMode(p_pwm2, OUTPUT);
pinMode(p_inh, OUTPUT);
}
/*-----------------------------
Arduino end function. stop SPI if enabled
*/
void Ifx007t::end()
{
}
void Ifx007t::disable()
{
digitalWrite(p_pwm1,LOW);
digitalWrite(p_pwm2,LOW);
digitalWrite(p_inh,LOW);
}
void Ifx007t::stop()
{
analogWrite(p_pwm1,0);
analogWrite(p_pwm2,0);
digitalWrite(p_pwm1,LOW);
digitalWrite(p_pwm2,LOW);
digitalWrite(p_inh,HIGH);
}
void Ifx007t::fullforward()
{
digitalWrite(p_pwm1,HIGH);
digitalWrite(p_pwm2,LOW);
digitalWrite(p_inh,HIGH);
}
void Ifx007t::fullbackward()
{
digitalWrite(p_pwm1,LOW);
digitalWrite(p_pwm2,HIGH);
digitalWrite(p_inh,HIGH);
}
void Ifx007t::pwm(int pwm)
{
digitalWrite(p_inh,HIGH);
if(pwm==0)
{
analogWrite(p_pwm1,0);
analogWrite(p_pwm2,0);
digitalWrite(p_pwm1,LOW);
digitalWrite(p_pwm2,LOW);
}
else if(pwm>0)
{
if(pwm>255) pwm=255;
analogWrite(p_pwm1,pwm);
analogWrite(p_pwm2,0);
digitalWrite(p_pwm2,LOW);
}
else
{
pwm=-pwm;
if(pwm>255) pwm=255;
analogWrite(p_pwm2,pwm);
analogWrite(p_pwm1,0);
digitalWrite(p_pwm1,LOW);
}
}