Moved time to special menudisplay

This commit is contained in:
CommanderRedYT
2021-12-14 20:32:26 +01:00
parent 4a2254df0b
commit 4f109d4d08
5 changed files with 40 additions and 19 deletions

View File

@ -199,6 +199,7 @@ set(headers
webserver_settings.h
webserver_stringsettings.h
widgets/doubleprogressbar.h
widgets/menudisplaywithtime.h
wifi_bobbycar.h
wifitexthelpers.h
)
@ -405,6 +406,7 @@ set(sources
webserver_settings.cpp
webserver_stringsettings.cpp
widgets/doubleprogressbar.cpp
widgets/menudisplaywithtime.cpp
wifi_bobbycar.cpp
wifitexthelpers.cpp
)

View File

@ -110,16 +110,3 @@ void MainMenu::back()
{
switchScreen<StatusDisplay>();
}
void MainMenu::start()
{
Base::start();
m_label_currentTime.start();
}
void MainMenu::redraw()
{
Base::redraw();
tft.setTextFont(2);
m_label_currentTime.redraw(fmt::format("&7Time: {}", local_clock_string()));
}

View File

@ -1,11 +1,11 @@
#pragma once
// 3rdparty lib includes
#include "menudisplay.h"
#include "menuitem.h"
// local includes
#include "texts.h"
#include "widgets/menudisplaywithtime.h"
#ifdef MAINMENU_PLUGIN
#include MAINMENU_PLUGIN
#endif
@ -22,15 +22,11 @@ namespace {
} // namespace
class MainMenu :
public espgui::MenuDisplay,
public bobbygui::MenuDisplayWithTime,
public espgui::StaticText<TEXT_MAINMENU>
{
using Base = espgui::MenuDisplay;
public:
MainMenu();
void back() override;
void start() override;
void redraw() override;
espgui::Label m_label_currentTime{145, 6};
};

View File

@ -0,0 +1,21 @@
#include "menudisplaywithtime.h"
#include "tftinstance.h"
#include "utils.h"
using namespace espgui;
namespace bobbygui {
void MenuDisplayWithTime::start()
{
Base::start();
m_label_currentTime.start();
}
void MenuDisplayWithTime::redraw()
{
Base::redraw();
tft.setTextFont(2);
m_label_currentTime.redraw(fmt::format("&7Time: {}", local_clock_string()));
}
} // namespace

View File

@ -0,0 +1,15 @@
#pragma once
#include <menudisplay.h>
namespace bobbygui {
class MenuDisplayWithTime :
public espgui::MenuDisplay
{
using Base = espgui::MenuDisplay;
public:
void start() override;
void redraw() override;
espgui::Label m_label_currentTime{145, 6};
};
} // namespace