mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-18 12:04:03 -04:00
* 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
39 lines
992 B
C++
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
|