-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGyro.cpp
73 lines (63 loc) · 1015 Bytes
/
Gyro.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
#include "Gyro.h"
#include <sstream>
/*
Ctor.
Input:
x - x value
y - y value
z - z value
Output:
none
*/
Gyro::Gyro(int x, int y, int z) :_x(x), _y(y), _z(z)
{
}
/*
Dtor.
Input:
none
Output:
none
*/
Gyro::~Gyro()
{
}
/*
Set the three values from string.
Input: x y z
str - Contains the three values of the Gyro. [4 digits|4 digits|4 digits], eg "-012+098-000"
Output:
none
*/
void Gyro::setValues(string str)
{
this->_x = atoi(str.substr(0, 3).c_str());
this->_y = atoi(str.substr(3, 3).c_str());
this->_z = atoi(str.substr(6, 3).c_str());
}
/*
Set the three values from string.
Input:
none
Output:
string - Contains the three values "x - [x] \n .. "
*/
string Gyro::getValues()
{
ostringstream str;
str << "X - " << this->_x << "\nY - " << this->_y << "\nZ - " << this->_z << "\n";
return str.str();
}
/*
Get the three values in array.
Input:
none
Output:
int*- x,y and z
*/
void Gyro::getVal(int vals[3])
{
vals[0] = this->_x;
vals[1] = this->_y;
vals[2] = this->_z;
}