-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDiveComputer.ino
53 lines (45 loc) · 1.31 KB
/
DiveComputer.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
// Include application, user and local libraries
#include "DiveComputer.h"
void ResetWatchdog() {
ESP.wdtFeed();
}
void setup() {
// Disable wifi
WiFi.forceSleepBegin();
// Configure startup CS pins
pinMode(TFT_CS, OUTPUT);
pinMode(RTC_CS, OUTPUT);
pinMode(TFT_LED, OUTPUT); // Override LED because PWM is software and we ain't got the time
digitalWrite(TFT_CS, HIGH);
digitalWrite(RTC_CS, HIGH);
digitalWrite(TFT_LED, HIGH);
Tft.begin();
Tft.clear();
Tft.setOrientation(3);
Serial.begin(9600);
// Register buttons
Serial.println("Start self test");
bool pass = SelfTest();
delay(2000); // Let some Time for the user to look at the self test
if (!pass) {
Serial.println("FAIL self test!");
//Tft.setDisplay(false);
//ESP.restart();
//MenuItem dummyItem;
//TurnOffCallback(dummyItem); // Shutdown
}
Serial.println("Pass self test");
}
void loop() {
PollButtons();
UIData data = CollectData();
UpdateUI(data);
if (CurrUIState.Mode == DIVE) {
UpdateDiveManager(data);
} else if (CurrUIState.Mode == SURFACE &&
data.Depth > SURFACE_DIVE_THRESHOLD) // Automatically start dive if deeper than 1m
{
MenuItem dummyItem;
StartDiveCallback(dummyItem);
}
}