-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
executable file
·171 lines (156 loc) · 4.09 KB
/
test.c
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "button.h"
#include "color_utils.h"
#include "graphic_equalizer.h"
#include "msgeq7.h"
#include <board.h>
#include <fsl_debug_console.h>
// Makes a bar
void barTest(void) {
GraphicEq_t state;
initGraphicEq(&state);
beginGraphicEq(&state);
MatrixColor_t purple;
createColor(127, 0, 127, &purple);
setBarHeight(&state, 0, 5, &purple);
while (1)
;
}
// Tests a pixel
void pixelTest(void) {
MatrixState_t state;
initMatrixState(&state);
beginMatrix(&state);
MatrixColor_t purple;
createColor(255, 0, 255, &purple);
setPixel(&state, 0, 0, &purple);
setPixel(&state, 15, 31, &purple);
while (1)
;
}
// Makes rectangles
void rectTest(void) {
MatrixState_t state;
initMatrixState(&state);
beginMatrix(&state);
MatrixColor_t purple;
createColor(255, 0, 255, &purple);
setRect(&state, 0, 10, 10, 20, &purple);
createColor(127, 0, 127, &purple);
setRect(&state, 0, 0, 10, 10, &purple);
while (1)
;
}
// Tries shading
void shadingTest(void) {
MatrixState_t state;
initMatrixState(&state);
beginMatrix(&state);
MatrixColor_t purple;
createColor(255, 0, 255, &purple);
setRect(&state, 0, 0, 10, 8, &purple);
createColor(191, 0, 191, &purple);
setRect(&state, 0, 7, 10, 15, &purple);
createColor(127, 0, 127, &purple);
setRect(&state, 0, 15, 10, 23, &purple);
createColor(63, 0, 63, &purple);
setRect(&state, 0, 23, 10, 31, &purple);
while (1)
;
}
// Displays nothing
void nothingTest(void) {
MatrixState_t state;
initMatrixState(&state);
beginMatrix(&state);
while (1)
;
}
// Tests the frequency chip
void audioTest(void) {
MSGEQ7_t chipState;
initMSGEQ7(&chipState);
beginMSGEQ7(&chipState);
while (1)
;
}
// Makes lots of bars
void bigBarTest(void) {
GraphicEq_t state;
initGraphicEq(&state);
beginGraphicEq(&state);
MatrixColor_t purple;
createColor(255, 0, 255, &purple);
setBarHeight(&state, 0, 5, &purple);
createColor(255, 0, 127, &purple);
setBarHeight(&state, 1, 10, &purple);
createColor(0, 0, 255, &purple);
setBarHeight(&state, 2, 7, &purple);
createColor(255, 0, 0, &purple);
setBarHeight(&state, 3, 15, &purple);
createColor(0, 255, 255, &purple);
setBarHeight(&state, 4, 9, &purple);
createColor(0, 255, 0, &purple);
setBarHeight(&state, 5, 3, &purple);
createColor(0, 127, 0, &purple);
setBarHeight(&state, 6, 6, &purple);
while (1)
;
}
// Adjusts the heights of lots of bars
void bigBarChangeTest(void) {
GraphicEq_t state;
initGraphicEq(&state);
beginGraphicEq(&state);
MatrixColor_t purple;
int offset = 0;
int dir = 1;
while (1) {
createColor(255, 0, 255, &purple);
setBarHeight(&state, 0, 5 + offset, &purple);
createColor(255, 0, 127, &purple);
setBarHeight(&state, 1, 10 + offset, &purple);
createColor(0, 0, 255, &purple);
setBarHeight(&state, 2, 7 + offset, &purple);
createColor(255, 0, 0, &purple);
setBarHeight(&state, 3, 15 + offset, &purple);
createColor(0, 255, 255, &purple);
setBarHeight(&state, 4, 9 + offset, &purple);
createColor(0, 255, 0, &purple);
setBarHeight(&state, 5, 3 + offset, &purple);
createColor(0, 127, 0, &purple);
setBarHeight(&state, 6, 6 + offset, &purple);
for (int x = 0; x < 1000000; x++)
;
offset += dir;
if (offset == 10) {
dir = -1;
}
if (offset == 0) {
dir = 1;
}
}
}
// Tests the button by setting (0, 0) to white when the button is pushed
MatrixState_t *test_state = NULL;
void buttonTestCallback(void) {
MatrixColor_t white;
createColor(255, 255, 255, &white);
setPixel(test_state, 0, 0, &white);
}
void buttonTest(void) {
debug_printf("Starting Test...");
MatrixState_t state;
initMatrixState(&state);
beginMatrix(&state);
test_state = &state;
ButtonState_t button;
initButtonState(&button);
setButtonCallback(&button, &buttonTestCallback);
beginButton(&button);
while (1)
;
}
int main(int argc, char **argv) {
shadingTest();
return 0;
}