Files
MuditaOS/module-apps/GuiTimer.cpp
Adam f5f27d642f EGD-2955 EGD-3588 Timers fully refactored & updated (#721)
* Timers now are Application thread safe
* Timers now have consistent API independend of Application (no more c style timers)
* Timers can have either: callback or override onTimer() method - this
  way we can create more complicated timers or just use existing ones
* gui::Timer added via adapter class GuiTimer to decouple sys::Timer
  with gui::Timer
* Fixed race in wrapper
* Updated docs
* fixed using std and cpp_freertos and DataReceivedHandler hidden in Application.hpp
2020-10-02 14:04:57 +02:00

47 lines
1.2 KiB
C++

#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
{
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)
: GuiTimer(name, parent, sys::Timer::timeout_infinite)
{}
GuiTimer::GuiTimer(const std::string &name, Application *parent, gui::ms timeout)
: sys::Timer(name, parent, timeout, sys::Timer::Type::SingleShot), sysapi(*this)
{}
void GuiTimer::Sysapi::connect(gui::Item *item)
{
if (item != nullptr) {
parent.connect([item, this](sys::Timer &timer) { item->onTimer(parent); });
}
}
} // namespace app