Files
MuditaOS/module-apps/GuiTimer.hpp
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

55 lines
1.4 KiB
C++

#pragma once
#include "Service/Timer.hpp" // for Timer
#include "Timer.hpp" // for ms, Timer
#include <string> // for string
namespace app
{
class Application;
} // namespace app
namespace gui
{
class Item;
} // namespace gui
namespace app
{
class Application;
/// proxies system Timer capabilities to gui::Timer and disconnects dependencies
/// by default one time run
class GuiTimer : public gui::Timer, protected sys::Timer
{
public:
/// gui timer default named GUI, infinite timeout on start
GuiTimer(Application *parent);
/// gui timer with user name, infinite timeout on start
GuiTimer(const std::string &name, Application *parent);
/// gui timer with user name, variable timeout
GuiTimer(const std::string &name, Application *parent, gui::ms timeout);
/// there is no valid reason to create timer without app
GuiTimer() = delete;
/// @defgroup interface
/// @ {
void start() override;
void stop() override;
void reset() override;
void setInterval(gui::ms time) override;
/// @ }
/// interface to trigger timing callback
class Sysapi
{
friend Application;
GuiTimer &parent;
void connect(gui::Item *item);
public:
Sysapi(GuiTimer &parent) : parent(parent)
{}
} sysapi;
};
}; // namespace app