-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.cpp
64 lines (50 loc) · 1.08 KB
/
test.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
#include <iostream>
#include <string>
#include <iomanip>
#include "PelcoD.hpp"
using namespace std;
void print(const string& text, const PelcoD& pelco)
{
cout << text << ": ";
for(int i = 0; i < 7; ++i)
{
cout << setfill('0') << setw(2) << hex << (int)pelco.data[i] << " ";
}
cout << endl;
}
int main()
{
PelcoD pelco;
pelco.clear();
pelco.setAddr(1);
pelco.moveLeft(0x3F);
pelco.calcChecksum();
print("move left, speed=3f", pelco);
pelco.clear();
pelco.setAddr(1);
pelco.moveLeft(0x3F);
pelco.moveUp(0x3F);
pelco.calcChecksum();
print("move left up, speed=3f", pelco);
pelco.clear();
pelco.setAddr(1);
pelco.moveRight(0x20);
pelco.calcChecksum();
print("move right, speed=20", pelco);
pelco.clear();
pelco.setAddr(1);
pelco.moveUp(0xAF);
pelco.calcChecksum();
print("move up, speed=3f", pelco); //speed is clamped
pelco.clear();
pelco.setAddr(1);
pelco.moveDown(0x05);
pelco.calcChecksum();
print("move down, speed=04", pelco);
pelco.clear();
pelco.setAddr(1);
pelco.setPreset(12);
pelco.calcChecksum();
print("set preset, no=12", pelco);
return 0;
}