|
1 | 1 | #include "BuzzScreen.h"
|
2 | 2 | #include "CarouselScreen.h"
|
3 |
| -#include "OptimaLTStd22pt7b.h" |
| 3 | +#include "GetLocation.h" |
4 | 4 | #include "GetWeatherScreen.h"
|
5 | 5 | #include "IconScreen.h"
|
6 | 6 | #include "ImageScreen.h"
|
7 | 7 | #include "MenuScreen.h"
|
| 8 | +#include "OptimaLTStd22pt7b.h" |
8 | 9 | #include "SetLocationScreen.h"
|
9 | 10 | #include "SetTimeScreen.h"
|
10 | 11 | #include "SetupWifiScreen.h"
|
|
13 | 14 | #include "ShowOrientationScreen.h"
|
14 | 15 | #include "ShowStepsScreen.h"
|
15 | 16 | #include "ShowWifiScreen.h"
|
| 17 | +#include "SyncTime.h" |
16 | 18 | #include "SyncTimeScreen.h"
|
17 | 19 | #include "TimeScreen.h"
|
18 | 20 | #include "UpdateFWScreen.h"
|
19 | 21 | #include "Watchy.h"
|
| 22 | +#include "WatchyErrors.h" |
20 | 23 | #include "WeatherScreen.h"
|
21 | 24 | #include "icons.h"
|
22 | 25 |
|
| 26 | +#include <time.h> |
| 27 | + |
23 | 28 | SetTimeScreen setTimeScreen;
|
24 | 29 | SetupWifiScreen setupWifiScreen;
|
25 | 30 | UpdateFWScreen updateFWScreen;
|
@@ -66,10 +71,20 @@ CarouselScreen carousel(carouselItems,
|
66 | 71 | sizeof(carouselItems) / sizeof(carouselItems[0]));
|
67 | 72 |
|
68 | 73 | void setup() {
|
69 |
| -#ifdef DEBUG |
70 |
| - Serial.begin(115200); |
71 |
| -#endif |
72 | 74 | LOGD(); // fail if debugging macros not defined
|
| 75 | + |
| 76 | + // initializing time and location can be a little tricky, because the |
| 77 | + // calls can fail for a number of reasons, but you don't want to just |
| 78 | + // keep trying because you can't know if the error is transient or |
| 79 | + // persistent. So whenever we wake up, try to sync the time and location |
| 80 | + // if they haven't ever been synced. If there is a persistent failure |
| 81 | + // this can drain your battery... |
| 82 | + if (Watchy_SyncTime::lastSyncTimeTS == 0) { |
| 83 | + Watchy_SyncTime::syncTime(Watchy_GetLocation::currentLocation.timezone); |
| 84 | + } |
| 85 | + if (Watchy_GetLocation::lastGetLocationTS == 0) { |
| 86 | + Watchy_GetLocation::getLocation(); |
| 87 | + } |
73 | 88 | if (Watchy::screen == nullptr) { Watchy::screen = &carousel; }
|
74 | 89 | Watchy::init();
|
75 | 90 | }
|
|
0 commit comments