Files
MuditaOS/module-gui/gui/core/Timer.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

39 lines
992 B
C++

#pragma once
namespace gui
{
using ms = unsigned int;
/// gui::Timer helper class to be used as passed to gui::Item `onTimer` function
/// this interface should be connected to real timer build with system Timer
/// all gui timers should be `Coarse` timers
class Timer
{
public:
virtual ~Timer() = default;
enum Type
{
Single, /// single run timer
Continous /// free running timers
};
virtual void start() = 0;
virtual void stop() = 0;
virtual void reset() = 0;
virtual void setInterval(ms time) = 0;
[[nodiscard]] auto interval() const -> ms;
protected:
Type type = Single;
public:
[[nodiscard]] auto getType() const -> Type
{
return type;
}
virtual void setType(Type new_type)
{
type = new_type;
};
};
}; // namespace gui