- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact.ino
More file actions
Latest commit
116 lines (92 loc) · 2.23 KB
/
Copy pathreact.ino
File metadata and controls
116 lines (92 loc) · 2.23 KB
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
// react
// Includes
#include<M5StickC.h>
#include"env.h"
extern"C" {
#include"react.h"
}
// Exported functions and variables
blc_bool buttonPressed = false;
blc_nat32 blc_react_makeRandomNat32 (const blc_nat32 blc_fromIncl, const blc_nat32 blc_toExcl)
{
returnrandom(blc_fromIncl, blc_toExcl);
}
voidblc_react_dimScreen (const blc_nat8 blc_percentage)
{
M5.Axp.ScreenBreath(blc_percentage * 12 / 100);
}
voidblc_react_displayCountDownScreen (const blc_nat8 blc_i)
{
M5.Lcd.fillScreen(WHITE);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setCursor(35, 75, 4);
M5.Lcd.printf("%d", (int)blc_i);
}
voidblc_react_displaySplashScreen (void)
{
M5.Lcd.fillScreen(BLUE);
}
voidblc_react_displayStartScreen ()
{
M5.Lcd.fillScreen(WHITE);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setCursor(0, 0, 2);
M5.Lcd.println("REACT\n");
M5.Lcd.println("1x click:");
M5.Lcd.println("\t Start\n");
M5.Lcd.println("2x click:");
M5.Lcd.println("\t Help");
}
voidblc_react_displayHelpScreen (void)
{
M5.Lcd.fillScreen(YELLOW);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setCursor(0, 0, 2);
M5.Lcd.println("HELP\n");
M5.Lcd.println("Click as fast as possible when blue screen appears.");
}
voidblc_react_displayPlayStartScreen (void)
{
M5.Lcd.fillScreen(BLACK);
}
voidblc_react_displayPlaySignalScreen (void)
{
M5.Lcd.fillScreen(BLUE);
}
voidblc_react_displayResultIsValidScreen (conststructblc_react_Score *const blc_score)
{
M5.Lcd.fillScreen(GREEN);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setCursor(0, 0, 2);
M5.Lcd.println("OK\n\n");
M5.Lcd.println("Time:");
M5.Lcd.printf("\t%dms", blc_score->reactionTime);
}
voidblc_react_displayResultTooEarlyScreen (void)
{
M5.Lcd.fillScreen(RED);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setCursor(0, 75, 2);
M5.Lcd.println("TOO EARLY!");
}
voidblc_react_displayResultTooLateScreen (void)
{
M5.Lcd.fillScreen(RED);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setCursor(0, 75, 2);
M5.Lcd.println("Too late!");
}
// Arduino hooks
voidsetup()
{
M5.begin();
M5.Lcd.setRotation(0);
blc_blech_react_init();
}
voidloop()
{
M5.update();
buttonPressed = M5.BtnA.wasPressed();
blc_blech_react_tick();
delay(MILLIS_PER_TICK);
}