Merge branch 'PersistantStorage' of git://github.com/geekbozu/InfiniTime into geekbozu-PersistantStorage
# Conflicts: # src/systemtask/SystemTask.cpp
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t) {
|
||||
this->currentDateTime = t;
|
||||
}
|
||||
|
||||
void DateTime::SetTime(
|
||||
uint16_t year, uint8_t month, uint8_t day, uint8_t dayOfWeek, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter) {
|
||||
std::tm tm = {
|
||||
@@ -67,7 +71,7 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
|
||||
// Notify new day to SystemTask
|
||||
if (hour == 0 and not isMidnightAlreadyNotified) {
|
||||
isMidnightAlreadyNotified = true;
|
||||
if(systemTask != nullptr)
|
||||
if (systemTask != nullptr)
|
||||
systemTask->PushMessage(System::Messages::OnNewDay);
|
||||
} else if (hour != 0) {
|
||||
isMidnightAlreadyNotified = false;
|
||||
|
@@ -74,6 +74,7 @@ namespace Pinetime {
|
||||
}
|
||||
|
||||
void Register(System::SystemTask* systemTask);
|
||||
void SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t);
|
||||
|
||||
private:
|
||||
uint16_t year = 0;
|
||||
|
20
src/main.cpp
20
src/main.cpp
@@ -115,7 +115,6 @@ Pinetime::Controllers::FS fs {spiNorFlash};
|
||||
Pinetime::Controllers::Settings settingsController {fs};
|
||||
Pinetime::Controllers::MotorController motorController {settingsController};
|
||||
|
||||
|
||||
Pinetime::Applications::DisplayApp displayApp(lcd,
|
||||
lvgl,
|
||||
touchPanel,
|
||||
@@ -156,6 +155,16 @@ Pinetime::System::SystemTask systemTask(spi,
|
||||
fs,
|
||||
touchHandler);
|
||||
|
||||
/* Variable Declarations for variables in noinit SRAM
|
||||
Increment NoInit_MagicValue upon adding variables to this area
|
||||
*/
|
||||
extern uint32_t __start_noinit_data;
|
||||
extern uint32_t __stop_noinit_data;
|
||||
static constexpr uint32_t NoInit_MagicValue = 0xDEAD0000;
|
||||
uint32_t NoInit_MagicWord __attribute__((section(".noinit")));
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoInit_BackUpTime __attribute__((section(".noinit")));
|
||||
|
||||
|
||||
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
|
||||
if (pin == Pinetime::PinMap::Cst816sIrq) {
|
||||
systemTask.OnTouchEvent();
|
||||
@@ -316,6 +325,15 @@ int main(void) {
|
||||
// retrieve version stored by bootloader
|
||||
Pinetime::BootloaderVersion::SetVersion(NRF_TIMER2->CC[0]);
|
||||
|
||||
|
||||
if (NoInit_MagicWord == NoInit_MagicValue) {
|
||||
dateTimeController.SetCurrentTime(NoInit_BackUpTime);
|
||||
} else {
|
||||
//Clear Memory to known state
|
||||
memset(&__start_noinit_data,0,(uintptr_t)&__stop_noinit_data-(uintptr_t)&__start_noinit_data);
|
||||
NoInit_MagicWord = NoInit_MagicValue;
|
||||
}
|
||||
|
||||
lvgl.Init();
|
||||
|
||||
systemTask.Start();
|
||||
|
@@ -376,6 +376,7 @@ void SystemTask::Work() {
|
||||
monitor.Process();
|
||||
uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG);
|
||||
dateTimeController.UpdateTime(systick_counter);
|
||||
NoInit_BackUpTime = dateTimeController.CurrentDateTime();
|
||||
if (!nrf_gpio_pin_read(PinMap::Button))
|
||||
watchdog.Kick();
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "drivers/Watchdog.h"
|
||||
#include "Messages.h"
|
||||
|
||||
extern std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoInit_BackUpTime;
|
||||
namespace Pinetime {
|
||||
namespace Drivers {
|
||||
class Cst816S;
|
||||
|
Reference in New Issue
Block a user