-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmode4.cpp
129 lines (114 loc) · 2.55 KB
/
mode4.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
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
#include "uni_keypad.h"
#include "uni_display.h"
#include "uni_config.h"
#include "modes.h"
#include "recording.h"
extern UniKeypad keypad;
extern UniDisplay display;
extern UniConfig config;
void displayFileConfig();
void filename_config(char key);
void racer_digits_config(char key);
void start_line_config(char key);
void finish_line_config(char key);
//### Mode 4.1 - Race Setup
//
//- If you press A, toggle between 5/F on digit 1
//- If you press B, toggle between b/A/E on digit 2
//- If you press C, toggle between U/d on digit 3
//- If you press D, toggle between 1..9 on digit 4.
//
char last_key4 = NO_KEY;
void mode4_setup() {
}
int config_mode = 1;
void mode4_loop() {
char key = keypad.readChar();
if (key != NO_KEY) {
if (key != last_key4) {
// New Keypress
switch(key) {
case '1':
config_mode = 1;
break;
case '2':
config_mode = 2;
break;
case '3':
config_mode = 3;
break;
case '4':
config_mode = 4;
break;
}
switch(config_mode) {
case 1:
filename_config(key);
break;
case 2:
racer_digits_config(key);
break;
case 3:
start_line_config(key);
break;
case 4:
finish_line_config(key);
break;
}
}
}
last_key4 = key;
}
void mode4_teardown() {
config.writeConfig();
}
void racer_digits_config(char key) {
switch(key) {
case 'A':
config.toggle_bib_number_length();
break;
}
display.showNumber(config.get_bib_number_length());
}
void start_line_config(char key) {
switch(key) {
case 'A':
config.toggle_start_line_countdown();
break;
}
display.showNumber(config.get_start_line_countdown() ? 1 : 2);
}
void finish_line_config(char key) {
switch(key) {
case 'A':
config.reset_finish_line_spacing();
break;
case 'B':
config.increment_finish_line_spacing(10);
break;
case 'C':
config.increment_finish_line_spacing(100);
break;
}
display.showNumber(config.get_finish_line_spacing());
}
void filename_config(char key) {
switch(key) {
case 'A':
config.toggle_start();
break;
case 'B':
config.increase_difficulty();
break;
case 'C':
config.toggle_up();
break;
case 'D':
config.increment_race_number();
break;
}
displayFileConfig();
}
void displayFileConfig() {
display.showConfiguration(config.get_start(), config.get_difficulty(), config.get_up(), config.get_race_number());
}