Multi face support, analog clock, 12/24 config

This commit is contained in:
Joaquim
2021-02-24 19:40:24 +00:00
parent c18f4e5811
commit 8c53d0b70b
25 changed files with 1336 additions and 314 deletions

View File

@@ -64,3 +64,123 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
second = time.seconds().count();
}
const char *DateTime::MonthShortToString() {
return DateTime::MonthsString[(uint8_t)month];
}
const char *DateTime::MonthShortToStringLow() {
return DateTime::MonthsStringLow[(uint8_t)month];
}
const char *DateTime::MonthsToStringLow() {
return DateTime::MonthsLow[(uint8_t)month];
}
const char *DateTime::DayOfWeekToString() {
return DateTime::DaysString[(uint8_t)dayOfWeek];
}
const char *DateTime::DayOfWeekShortToString() {
return DateTime::DaysStringShort[(uint8_t)dayOfWeek];
}
const char *DateTime::DayOfWeekToStringLow() {
return DateTime::DaysStringLow[(uint8_t)dayOfWeek];
}
const char *DateTime::DayOfWeekShortToStringLow() {
return DateTime::DaysStringShortLow[(uint8_t)dayOfWeek];
}
char const *DateTime::DaysStringLow[] = {
"--",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};
char const *DateTime::DaysStringShortLow[] = {
"--",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun"
};
char const *DateTime::DaysStringShort[] = {
"--",
"MON",
"TUE",
"WED",
"THU",
"FRI",
"SAT",
"SUN"
};
char const *DateTime::DaysString[] = {
"--",
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY"
};
char const *DateTime::MonthsString[] = {
"--",
"JAN",
"FEB",
"MAR",
"APR",
"MAY",
"JUN",
"JUL",
"AUG",
"SEP",
"OCT",
"NOV",
"DEC"
};
char const *DateTime::MonthsStringLow[] = {
"--",
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};
char const *DateTime::MonthsLow[] = {
"--",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};

View File

@@ -20,6 +20,14 @@ namespace Pinetime {
uint8_t Minutes() const { return minute; }
uint8_t Seconds() const { return second; }
const char *MonthShortToString();
const char *MonthShortToStringLow();
const char *MonthsToStringLow();
const char *DayOfWeekToString();
const char *DayOfWeekShortToString();
const char *DayOfWeekToStringLow();
const char *DayOfWeekShortToStringLow();
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const { return currentDateTime; }
std::chrono::seconds Uptime() const { return uptime; }
private:
@@ -34,6 +42,15 @@ namespace Pinetime {
uint32_t previousSystickCounter = 0;
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> currentDateTime;
std::chrono::seconds uptime {0};
static char const *DaysString[];
static char const *DaysStringShort[];
static char const *DaysStringLow[];
static char const *DaysStringShortLow[];
static char const *MonthsString[];
static char const *MonthsStringLow[];
static char const *MonthsLow[];
};
}
}

View File

@@ -0,0 +1,18 @@
#include "Settings.h"
using namespace Pinetime::Controllers;
// TODO (team):
// Read and write the settings to Flash
//
void Settings::Init() {
// default Clock face
clockFace = 0;
clockType = ClockType::H24;
}

View File

@@ -0,0 +1,30 @@
#pragma once
#include <cstdint>
namespace Pinetime {
namespace Controllers {
class Settings {
public:
enum class ClockType {H24, H12};
void Init();
void SetClockFace( uint8_t face ) { clockFace = face; };
uint8_t GetClockFace() { return clockFace; };
void SetAppMenu( uint8_t menu ) { appMenu = menu; };
uint8_t GetAppMenu() { return appMenu; };
void SetClockType( ClockType clocktype ) { clockType = clocktype; };
ClockType GetClockType() { return clockType; };
private:
uint8_t clockFace = 0;
uint8_t appMenu = 0;
ClockType clockType = ClockType::H24;
};
}
}