Files
MuditaOS/module-apps/GuiTimer.cpp
Przemyslaw Brudny 230eb7c343 [EGD-5816] Device freeze after cancelling a call
Reverted changed proposed by PR [EGD-5598] GuiTimer
refreshWindow on Count and custom stop.

Signed-off-by: Przemyslaw Brudny <przemyslaw.brudny@mudita.com>
2021-02-19 12:57:30 +01:00

57 lines
1.5 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "GuiTimer.hpp"
#include "Item.hpp" // for Item
#include "Service/Timer.hpp" // for Timer, Timer::Type, Timer::Ty...
#include "module-apps/Application.hpp" // for Application
#include <memory> // for allocator
namespace app
{
namespace
{
constexpr auto toSysTimerType(gui::Timer::Type type) noexcept -> sys::Timer::Type
{
if (type == gui::Timer::Type::Single) {
return sys::Timer::Type::SingleShot;
}
return sys::Timer::Type::Periodic;
}
} // namespace
void GuiTimer::start()
{
sys::Timer::start();
}
void GuiTimer::stop()
{
sys::Timer::stop();
}
void GuiTimer::reset()
{
sys::Timer::start();
}
void GuiTimer::setInterval(gui::ms time)
{
sys::Timer::setInterval(time);
}
GuiTimer::GuiTimer(Application *parent) : GuiTimer("GUI", parent)
{}
GuiTimer::GuiTimer(const std::string &name, Application *parent, gui::ms timeout, gui::Timer::Type type)
: sys::Timer(name, parent, timeout, toSysTimerType(type)), sysapi{*this}
{}
void GuiTimer::Sysapi::connect(gui::Item *item)
{
if (item != nullptr) {
parent.connect([item, this](sys::Timer &timer) { item->onTimer(parent); });
}
}
} // namespace app