-
Notifications
You must be signed in to change notification settings - Fork 0
/
uni_config.h
72 lines (59 loc) · 1.56 KB
/
uni_config.h
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
#ifndef UNI_CONFIG_H
#define UNI_CONFIG_H
#include <Arduino.h>
// NOTE: Adjustments to this structure MUST ALSO
// be reflected in the readConfig and writeConfig methods
// or else the config won't persist/parse properly
#define FILENAME_MAX_LENGTH 100
typedef struct {
// filename parts
bool start; //[T, F]
uint8_t difficulty; // [B, A, E]
bool up; // [T, F]
uint8_t race_number; // [0..9]
// filename whole
char filename[FILENAME_MAX_LENGTH];
// Racer bib number
uint8_t bib_number_length;
// Start line modes
bool start_line_countdown;
// Finish line spacing
uint16_t finish_line_spacing;
// Resume the race mode stored
int mode;
} Config;
class UniConfig
{
public:
UniConfig();
void setup();
bool loadedFromDefault();
void toggle_start();
void increase_difficulty();
void toggle_up();
void increment_race_number();
bool get_start();
int get_difficulty();
bool get_up();
int get_race_number();
void toggle_bib_number_length();
int get_bib_number_length();
// start_line_countdown
void toggle_start_line_countdown();
bool get_start_line_countdown();
// finish_line_spacing
void reset_finish_line_spacing();
void increment_finish_line_spacing(int ms);
int get_finish_line_spacing();
char *filename();
int mode();
void setMode(int mode);
bool writeConfig();
private:
bool readConfig();
bool _loadedFromDefault;
bool prefix(const char *str, const char *prefix);
char *value(const char *str, const char *prefix);
Config _config;
};
#endif