2021-12-19 19:54:31 +01:00
|
|
|
#include "taskmanagermenu.h"
|
|
|
|
|
|
|
|
|
|
// 3rdparty lib includes
|
|
|
|
|
#include <actions/dummyaction.h>
|
2022-12-25 03:22:28 +01:00
|
|
|
#include <actions/popscreenaction.h>
|
2021-12-19 20:32:37 +01:00
|
|
|
#include <fmt/core.h>
|
2022-12-25 03:22:28 +01:00
|
|
|
#include <schedulertask.h>
|
2021-12-19 19:54:31 +01:00
|
|
|
|
|
|
|
|
// local includes
|
2022-12-25 17:35:58 +01:00
|
|
|
#include "icons/back.h"
|
2021-12-19 19:54:31 +01:00
|
|
|
#include "taskmanager.h"
|
|
|
|
|
|
2022-12-25 03:22:28 +01:00
|
|
|
namespace bobby {
|
|
|
|
|
|
2021-12-19 19:54:31 +01:00
|
|
|
using namespace espgui;
|
2022-02-12 19:07:34 +01:00
|
|
|
using namespace std::chrono_literals;
|
2021-12-19 19:54:31 +01:00
|
|
|
|
2021-12-19 20:32:37 +01:00
|
|
|
namespace {
|
2021-12-30 03:17:30 +01:00
|
|
|
constexpr char TEXT_TASKMANAGER[] = "Taskmanager";
|
|
|
|
|
constexpr char TEXT_BACK[] = "Back";
|
2021-12-19 20:32:37 +01:00
|
|
|
|
|
|
|
|
class TaskText : public virtual espgui::TextInterface
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TaskText(const espcpputils::SchedulerTask &task) : m_task{task} {}
|
|
|
|
|
|
|
|
|
|
std::string text() const override
|
|
|
|
|
{
|
|
|
|
|
const std::string_view name{m_task.name()};
|
2022-02-12 19:07:34 +01:00
|
|
|
return fmt::format("{}{}&f &2{} &1{}ms", name.size() > 6 ? "&s" : "", name, m_task.callCount(), m_task.maxElapsed() / 1ms);
|
2021-12-19 20:32:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const espcpputils::SchedulerTask &m_task;
|
|
|
|
|
};
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2021-12-19 19:54:31 +01:00
|
|
|
TaskmanagerMenu::TaskmanagerMenu()
|
|
|
|
|
{
|
|
|
|
|
for (const auto &task : schedulerTasks)
|
2021-12-19 20:32:37 +01:00
|
|
|
constructMenuItem<makeComponentArgs<MenuItem, TaskText, DummyAction>>(task);
|
2022-12-25 17:35:58 +01:00
|
|
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&bobbyicons::back>>>();
|
2021-12-19 19:54:31 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-30 03:17:30 +01:00
|
|
|
std::string TaskmanagerMenu::text() const
|
|
|
|
|
{
|
|
|
|
|
return TEXT_TASKMANAGER;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-19 19:54:31 +01:00
|
|
|
void TaskmanagerMenu::back()
|
|
|
|
|
{
|
2022-03-05 22:26:57 +01:00
|
|
|
popScreen();
|
2021-12-19 19:54:31 +01:00
|
|
|
}
|
2022-12-25 03:22:28 +01:00
|
|
|
} // namespace bobby
|