-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.c
68 lines (63 loc) · 1.23 KB
/
main.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
#include "hw_driver.h"
#include "stc15f2k60s2.h"
#include "types.h"
int8 cur_x;
int8 cur_y;
int8 cur_v;
void MySleep() {
Delay(100);
while(WasButtonPressed(kDownBtn)) { // Down
if (cur_y == 7) {
// Nothingness.
} else {
SetPixelValue(cur_y, cur_x, cur_v);
cur_y = cur_y + 1;
cur_v = GetPixelValue(cur_y, cur_x);
}
}
while (WasButtonPressed(kUpBtn) > 0) {
if (cur_y == 0) {
// Nothing again.
} else {
SetPixelValue(cur_y, cur_x, cur_v);
cur_y = cur_y - 1;
cur_v = GetPixelValue(cur_y, cur_x);
}
}
while (WasButtonPressed(kRightBtn) > 0) {
if (cur_x == 7) {
// Do nothing.
} else {
SetPixelValue(cur_y, cur_x, cur_v);
cur_x = cur_x + 1;
cur_v = GetPixelValue(cur_y, cur_x);
}
}
while (WasButtonPressed(kLeftBtn) > 0) {
if (cur_x == 0) {
// Nothing!
} else {
SetPixelValue(cur_y, cur_x, cur_v);
cur_x = cur_x - 1;
cur_v = GetPixelValue(cur_y, cur_x);
}
}
while (WasButtonPressed(kOkBtn) > 0) {
cur_v = 1;
}
while (WasButtonPressed(kRstBtn) > 0) {
cur_v = 0;
}
}
void main(void) {
InitHw();
cur_x = 0;
cur_y = 0;
cur_v = 0;
while (1) {
SetPixel(cur_y, cur_x);
MySleep();
ClearPixel(cur_y, cur_x);
MySleep();
}
}