Reset the step count every day at midnight.

This commit is contained in:
Jean-François Milants
2021-04-02 17:33:49 +02:00
parent 52a90288fd
commit 1d7576de64
7 changed files with 45 additions and 8 deletions

View File

@@ -1,9 +1,14 @@
#include "DateTimeController.h"
#include <date/date.h>
#include <libraries/log/nrf_log.h>
#include <systemtask/SystemTask.h>
using namespace Pinetime::Controllers;
DateTime::DateTime(System::SystemTask& systemTask) : systemTask{systemTask} {
}
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) {
@@ -62,6 +67,14 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
hour = time.hours().count();
minute = time.minutes().count();
second = time.seconds().count();
// Notify new day to SystemTask
if(hour == 0 and not isMidnightAlreadyNotified) {
isMidnightAlreadyNotified = true;
systemTask.PushMessage(System::SystemTask::Messages::OnNewDay);
} else if (hour != 0) {
isMidnightAlreadyNotified = false;
}
}
const char *DateTime::MonthShortToString() {