-
Notifications
You must be signed in to change notification settings - Fork 1
/
9_2_update.ino
110 lines (94 loc) · 2.99 KB
/
9_2_update.ino
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
void setSelection( u8 selection ){
cube.lastSelection = cube.selection;
cube.selection = selection;
};
float timer = 0.0;
void update( float timeDiff ) {
input.update( timeDiff );
timer += timeDiff;
if( optionsMenu.visible ){
optionsMenu.update();
if( timer > 1/30 ) {
timer = 0.0;
optionsMenu.draw();
}
} else {
if( input.get( buttons::a ) ) {
cube.rotate( cube.selection, directions::clockWise );
} else if( input.get( buttons::b ) ) {
cube.rotate( cube.selection, directions::counterClockWise );
}
if( cube.selection == faces::left || cube.selection == faces::front || cube.selection == faces::right || cube.selection == faces::back ) {
// selected face: (-> ... means repeat sequence)
// up/down
// center -> top -> bottom -> ...
if( input.get( buttons::up ) ) {
setSelection( faces::top );
} else if( input.get( buttons::down ) ) {
setSelection( faces::bottom );
}
// right/left
// top -> ... (ignore)
// left -> front -> right -> back -> ...
// bottom -> ... (ignore)
else if( cube.selection == faces::front ) {
if( input.get( buttons::right ) ) {
setSelection( faces::right );
} else if( input.get( buttons::left ) ) {
setSelection( faces::left );
}
}
else if( cube.selection == faces::right ) {
if( input.get( buttons::right ) ) {
setSelection( faces::back );
} else if( input.get( buttons::left ) ) {
setSelection( faces::front );
}
}
else if( cube.selection == faces::back ) {
if( input.get( buttons::right ) ) {
setSelection( faces::left );
} else if( input.get( buttons::left ) ) {
setSelection( faces::right );
}
}
else if( cube.selection == faces::left ) {
if( input.get( buttons::right ) ) {
setSelection( faces::front );
} else if( input.get( buttons::left ) ) {
setSelection( faces::back );
}
}
}
else if( cube.selection == faces::top ) {
if( input.get( buttons::up ) ) {
setSelection( faces::bottom );
} else if( input.get( buttons::down ) ) {
setSelection( faces::front );
}
if( input.get( buttons::right ) ) {
setSelection( faces::right );
} else if( input.get( buttons::left ) ) {
setSelection( faces::left );
}
}
else if( cube.selection == faces::bottom ) {
if( input.get( buttons::up ) ) {
setSelection( faces::front );
} else if( input.get( buttons::down ) ) {
setSelection( faces::top );
}
if( input.get( buttons::right ) ) {
setSelection( faces::right );
} else if( input.get( buttons::left ) ) {
setSelection( faces::left );
}
}
if( timer > 1/30 ) {
cube.draw();
}
if( optionsMenu.showBattery ){
drawBatteryStatus();
}
}
};