diff --git a/src/components/ble/CurrentTimeClient.cpp b/src/components/ble/CurrentTimeClient.cpp index e535ae83..7df07106 100644 --- a/src/components/ble/CurrentTimeClient.cpp +++ b/src/components/ble/CurrentTimeClient.cpp @@ -1,5 +1,4 @@ #include "components/ble/CurrentTimeClient.h" -#include #include #include "components/datetime/DateTimeController.h" @@ -88,8 +87,7 @@ int CurrentTimeClient::OnCurrentTimeReadResult(uint16_t conn_handle, const ble_g uint16_t year = ((uint16_t) result.year_MSO << 8) + result.year_LSO; NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", year, result.month, result.dayofmonth, result.hour, result.minute, result.second); - dateTimeController - .SetTime(year, result.month, result.dayofmonth, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG)); + dateTimeController.SetTime(year, result.month, result.dayofmonth, result.hour, result.minute, result.second); } else { NRF_LOG_INFO("Error retrieving current time: %d", error->status); } diff --git a/src/components/ble/CurrentTimeService.cpp b/src/components/ble/CurrentTimeService.cpp index 856bc63a..012951cb 100644 --- a/src/components/ble/CurrentTimeService.cpp +++ b/src/components/ble/CurrentTimeService.cpp @@ -1,5 +1,4 @@ #include "components/ble/CurrentTimeService.h" -#include #include using namespace Pinetime::Controllers; @@ -50,8 +49,7 @@ int CurrentTimeService::OnCurrentTimeAccessed(struct ble_gatt_access_ctxt* ctxt) NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", year, result.month, result.dayofmonth, result.hour, result.minute, result.second); - m_dateTimeController - .SetTime(year, result.month, result.dayofmonth, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG)); + m_dateTimeController.SetTime(year, result.month, result.dayofmonth, result.hour, result.minute, result.second); } else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) { CtsCurrentTimeData currentDateTime; diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 912f5927..74c8f926 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -1,7 +1,6 @@ #include "components/ble/NimbleController.h" #include -#include #include #define min // workaround: nimble's min/max macros conflict with libstdc++ #define max diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index b744fbb2..7ebb7b19 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -20,7 +20,7 @@ void DateTime::SetCurrentTime(std::chrono::time_pointhour, this->minute, this->second); NRF_LOG_INFO("* %d %d %d ", this->day, this->month, this->year); @@ -63,7 +62,7 @@ void DateTime::UpdateTime(uint32_t systickCounter) { * 1000 ms = 1024 ticks */ auto correctedDelta = systickDelta / 1024; - auto rest = (systickDelta - (correctedDelta * 1024)); + auto rest = systickDelta % 1024; if (systickCounter >= rest) { previousSystickCounter = systickCounter - rest; } else { diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h index 74ccf4da..b68d18ef 100644 --- a/src/components/datetime/DateTimeController.h +++ b/src/components/datetime/DateTimeController.h @@ -31,7 +31,7 @@ namespace Pinetime { December }; - void SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter); + void SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second); /* * setter corresponding to the BLE Set Local Time characteristic. diff --git a/src/displayapp/screens/settings/SettingSetDate.cpp b/src/displayapp/screens/settings/SettingSetDate.cpp index 08add508..1c0c55a5 100644 --- a/src/displayapp/screens/settings/SettingSetDate.cpp +++ b/src/displayapp/screens/settings/SettingSetDate.cpp @@ -1,7 +1,6 @@ #include "displayapp/screens/settings/SettingSetDate.h" #include "displayapp/screens/settings/SettingSetDateTime.h" #include -#include #include #include "displayapp/DisplayApp.h" #include "displayapp/screens/Symbols.h" @@ -96,13 +95,8 @@ void SettingSetDate::HandleButtonPress() { const uint8_t monthValue = monthCounter.GetValue(); const uint8_t dayValue = dayCounter.GetValue(); NRF_LOG_INFO("Setting date (manually) to %04d-%02d-%02d", yearValue, monthValue, dayValue); - dateTimeController.SetTime(yearValue, - monthValue, - dayValue, - dateTimeController.Hours(), - dateTimeController.Minutes(), - dateTimeController.Seconds(), - nrf_rtc_counter_get(portNRF_RTC_REG)); + dateTimeController + .SetTime(yearValue, monthValue, dayValue, dateTimeController.Hours(), dateTimeController.Minutes(), dateTimeController.Seconds()); settingSetDateTime.Advance(); } diff --git a/src/displayapp/screens/settings/SettingSetTime.cpp b/src/displayapp/screens/settings/SettingSetTime.cpp index efb8578f..e5a6be2f 100644 --- a/src/displayapp/screens/settings/SettingSetTime.cpp +++ b/src/displayapp/screens/settings/SettingSetTime.cpp @@ -1,6 +1,5 @@ #include "displayapp/screens/settings/SettingSetTime.h" #include -#include #include #include "displayapp/DisplayApp.h" #include "displayapp/screens/Symbols.h" @@ -100,7 +99,6 @@ void SettingSetTime::SetTime() { dateTimeController.Day(), static_cast(hoursValue), static_cast(minutesValue), - 0, - nrf_rtc_counter_get(portNRF_RTC_REG)); + 0); settingSetDateTime.Quit(); } diff --git a/src/main.cpp b/src/main.cpp index 36fb49c4..74804214 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,4 @@ // nrf -#include #include #include #include