-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.cpp
63 lines (47 loc) · 1.19 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
#include "Test.h"
void testSevenSegSpi() {
SevenSeg seg(SPI_MODE);
_testSevenSeg(seg);
}
void testSevenSegUart() {
SevenSeg seg(UART_MODE);
_testSevenSeg(seg);
}
void _testSevenSeg(SevenSeg seg) {
seg.clear();
int index = 0;
while(1) {
seg.write('A' + (index % 4), 0);
seg.write('A' + ((index + 1) % 4), 1);
seg.write('A' + ((index + 2) % 4), 2);
seg.write('A' + ((index + 3) % 4), 3);
seg.dot(index % 2, 0);
seg.dot(!(index % 2), 1);
seg.dot(index % 2, 2);
seg.dot(!(index % 2), 3);
seg.dot(index % 2, 4);
seg.dot(!(index % 2), 5);
index = (index + 1) % 4;
wait(0.5);
}
}
void testAccel() {
Accel acc(0x1D);
while(1) {
acc.update();
printf("A %0.2f -- X %0.2f -- Y %0.2f -- Z %0.2f\n",
acc.a(),
acc.x(),
acc.y(),
acc.z()
);
wait(0.3);
}
}
void testCommand(){
Proto proto;
printf("DOT1_OFF == %d got %d\n", DOT1_OFF, proto.getCommand(0b1000001));
printf("DOT2_OFF == %d got %d\n", DOT2_OFF, proto.getCommand(0b1000111));
printf("ERROR == %d got %d\n", ERROR, proto.getCommand(0b1001001));
printf("DOT4_OFF == %d got %d\n", DOT4_OFF, proto.getCommand(0b1001101));
}