diff options
| author | Tim Keller <geekboy1011@gmail.com> | 2021-08-17 23:53:57 (GMT) |
|---|---|---|
| committer | Tim Keller <geekboy1011@gmail.com> | 2021-08-17 23:53:57 (GMT) |
| commit | 55f8908769aab970413b249cb26acdaf22c79ada (patch) | |
| tree | 21d0e06dd2ca20ac99abbcfe06661fff5a6c2e64 /src/main.cpp | |
| parent | ee44b6ff4998d6f4d0672c05c1f65c0a9692dc0d (diff) | |
Make Clock Persistant.
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index d301be6..9c384a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -124,7 +124,6 @@ Pinetime::Controllers::FS fs {spiNorFlash}; Pinetime::Controllers::Settings settingsController {fs}; Pinetime::Controllers::MotorController motorController {settingsController}; - Pinetime::Applications::DisplayApp displayApp(lcd, lvgl, touchPanel, @@ -161,6 +160,9 @@ Pinetime::System::SystemTask systemTask(spi, heartRateApp, fs); +uint32_t MAGIC_RAM __attribute__((section(".noinit"))); +std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> BackUpTime __attribute__((section(".noinit"))); + void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { if (pin == pinTouchIrq) { systemTask.OnTouchEvent(); @@ -321,6 +323,13 @@ int main(void) { // retrieve version stored by bootloader Pinetime::BootloaderVersion::SetVersion(NRF_TIMER2->CC[0]); + // Check Magic Ram and reset lost variables + if (MAGIC_RAM == 0xDEADBEEF) { + dateTimeController.SetCurrentTime(BackUpTime); + } else { + MAGIC_RAM = 0xDEADBEEF; + } + lvgl.Init(); systemTask.Start(); |
