Make date string configurable
This commit is contained in:
parent
14cf97ac33
commit
543c554456
@ -65,9 +65,9 @@ void def_overlay::update() {
|
||||
_last_update = std::chrono::high_resolution_clock::now();
|
||||
|
||||
//get current date and time
|
||||
std::time_t curr_time = std::chrono::system_clock::to_time_t(
|
||||
std::chrono::system_clock::now());
|
||||
date_time = std::ctime(&curr_time);
|
||||
std::time_t curr_time = std::time(nullptr);
|
||||
std::strftime(date_time, sizeof(date_time),
|
||||
DEF_OVERLAY_DATE_STRING, std::localtime(&curr_time));
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
@ -114,12 +114,12 @@ void def_overlay::update_texture() {
|
||||
|
||||
//show the date and time
|
||||
TTF_SizeText(board::getFont({ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }),
|
||||
date_time.c_str(),
|
||||
date_time,
|
||||
&tgt.w, &tgt.h);
|
||||
tgt.x = SCREEN_WIDTH - tgt.w + 25;
|
||||
tgt.x = SCREEN_WIDTH - tgt.w - 5;
|
||||
tgt.y = -5;
|
||||
SDL_RenderCopy(board::getRenderer(),
|
||||
board::getString(date_time.c_str(),
|
||||
board::getString(std::string(date_time),
|
||||
{ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt);
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace dashboard::panel {
|
||||
void update_texture();
|
||||
void initTexture();
|
||||
|
||||
std::string date_time;
|
||||
char date_time [100];
|
||||
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> _last_update;
|
||||
std::chrono::milliseconds _update_interval;
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
namespace dashboard::panel {
|
||||
//How long should we wait between updates? in ms
|
||||
//Default 10 s
|
||||
constexpr size_t DEF_OVERLAY_UPDATE_INTERVAL = 500;
|
||||
//Default 1s
|
||||
constexpr size_t DEF_OVERLAY_UPDATE_INTERVAL = 1000;
|
||||
|
||||
//Height of the bar on the top and bottom, in pixels
|
||||
constexpr size_t DEF_OVERLAY_BAR_HEIGHT = 60;
|
||||
@ -26,4 +26,8 @@ namespace dashboard::panel {
|
||||
constexpr uint8_t DEF_OVERLAY_BAR_GREEN = 0xD3;
|
||||
constexpr uint8_t DEF_OVERLAY_BAR_BLUE = 0xD3;
|
||||
constexpr uint8_t DEF_OVERLAY_BAR_ALPHA = 0x7F;
|
||||
|
||||
//for more on how this string format works, refer to
|
||||
//https://en.cppreference.com/w/cpp/chrono/c/strftime
|
||||
constexpr char DEF_OVERLAY_DATE_STRING[] = "%a %R %p";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user