DateTimeController: Remove SetTime tick parameter

The systick doesn't need to be updated when setting time.

Also removed unused nrf_rtc.h includes.
This commit is contained in:
Riku Isokoski
2023-02-24 07:38:16 +02:00
parent eccea5ab9f
commit b63bb798ac
8 changed files with 9 additions and 24 deletions

View File

@@ -20,7 +20,7 @@ void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock,
UpdateTime(previousSystickCounter); // Update internal state without updating the time
}
void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter) {
void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) {
std::tm tm = {
/* .tm_sec = */ second,
/* .tm_min = */ minute,
@@ -35,9 +35,8 @@ void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour,
NRF_LOG_INFO("%d %d %d ", day, month, year);
NRF_LOG_INFO("%d %d %d ", hour, minute, second);
previousSystickCounter = systickCounter;
UpdateTime(systickCounter);
UpdateTime(previousSystickCounter);
NRF_LOG_INFO("* %d %d %d ", this->hour, 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 {

View File

@@ -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.