forked from mindsensors/EVShield
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EVShieldAGS.cpp
76 lines (66 loc) · 1.93 KB
/
EVShieldAGS.cpp
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
/*
12/18/2014 Nitin Patil -- modified to work with EVshield
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "EVShieldAGS.h"
EVShieldAGS::EVShieldAGS()
{
mp_shield = NULL;
}
EVShieldAGS::EVShieldAGS(EVShield * shield, SH_BankPort bp)
{
mp_shield = shield;
m_bp = bp;
}
bool EVShieldAGS::setType(uint8_t type)
{
if ( mp_shield == NULL) return false;
switch (m_bp) {
case SH_BAS1:
return mp_shield->bank_a.sensorSetType(SH_S1, type);
break;
case SH_BAS2:
return mp_shield->bank_a.sensorSetType(SH_S2, type);
break;
case SH_BBS1:
return mp_shield->bank_b.sensorSetType(SH_S1, type);
break;
case SH_BBS2:
return mp_shield->bank_b.sensorSetType(SH_S2, type);
break;
}
}
int EVShieldAGS::readRaw()
{
if ( mp_shield == NULL) return -1;
switch (m_bp) {
case SH_BAS1:
return mp_shield->bank_a.sensorReadRaw(SH_S1);
break;
case SH_BAS2:
return mp_shield->bank_a.sensorReadRaw(SH_S2);
break;
case SH_BBS1:
return mp_shield->bank_b.sensorReadRaw(SH_S1);
break;
case SH_BBS2:
return mp_shield->bank_b.sensorReadRaw(SH_S2);
break;
}
}
bool EVShieldAGS::init(EVShield * shield, SH_BankPort bp)
{
mp_shield = shield;
m_bp = bp;
return true;
}