-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.h
117 lines (85 loc) · 2.54 KB
/
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
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
#pragma once
#include "gps.h"
#include "pins.h"
#include "fstring.h"
#include "EEPROM.h"
/******* HARDWARE CONFIG *******/
typedef IOPin<GPIOD, 6> PinARM;
typedef IOPin<GPIOB, 0> PinLED;
typedef IOPin<GPIOD, 7> PinBuzzer;
const int adcChanBattery = 3;
const int adcChanTempExt = 6;
const int adcChanTempInt = 7;
/******* SOFTWARE CONFIG *******/
const uint16_t kTimeSlots = 4;
const uint16_t fskBaudrate = 300; // FSK transmitter baudrate
const uint16_t kFixTimeout = 180; // Maximum allowed time (sec) to GPS fix before error
const uint16_t kAltitudeThreshold = 1000; // Beep below this altitude (meters)
const uint16_t kBuzzerPattern1 = 0b0000000101001111; // Retrieval
const uint16_t kBuzzerPattern2 = 0b0000111100001111; // Indicates GPS fix problems
const uint16_t kLEDPattern1 = 0b0000000011111111; // Normal 50% flashing
const uint16_t kLEDPattern2 = 0b1001000000000000; // Retrieval flashing
const char txTestString[] = "AAAAA";
const char txTestStringLength = sizeof(txTestString) / sizeof(char);
enum {
kStatusNoGPSLock = 0,
kStatusAfterReset = 1,
kStatusCameraOff = 2
};
enum DebugMode {
DbgConsole,
DbgNMEA,
DbgUKHAS
};
struct ResetState {
uint16_t resetCount;
uint16_t sentenceID;
GPSInfo gpsInfo;
bool ascentComplete;
ResetState() {
}
void clear() {
ascentComplete = false;
sentenceID = 1;
resetCount = 0;
gpsInfo.clear();
}
};
struct Config {
uint16_t blockId;
FString<6> payloadName;
uint8_t enableTX : 1;
uint8_t enableLastFix : 1;
DebugMode debugMode; // Debug console mode
static void defaults() {
Serial.println("No EEPROM data found, configuring default settings");
config.blockId = 0;
config.payloadName.assign("ZGND");
config.enableTX = 1;
config.enableLastFix = 1;
config.debugMode = DbgConsole;
}
static void save() {
eeprom_update_block((void *)&config, &nvConfig, sizeof(config));
}
static void restore() {
eeprom_read_block((void *)&config, &nvConfig, sizeof(config));
//Serial.print("EEPROM block id: ");
//Serial.println(config.blockId);
if (config.blockId == 0xFFFF) defaults();
config.blockId++;
}
static uint8_t getMyID() {
char myId = Config::config.payloadName[-1]; // Get the last character of payload name
if (myId >= '0' && myId <= '9') {
myId -= '0';
return myId;
}
return 0;
}
static uint8_t getTimeSlots() {
return kTimeSlots;
}
static Config EEMEM nvConfig;
static Config config;
};