diff --git a/escher/Makefile b/escher/Makefile index 218944271..abf898b91 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -21,6 +21,7 @@ objs += $(addprefix escher/src/,\ highlight_cell.o\ image_view.o\ invocation.o\ + invocation_timer.o\ input_view_controller.o\ key_view.o\ list_view_data_source.o\ diff --git a/escher/include/escher.h b/escher/include/escher.h index 21ae28b2e..7237981af 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,7 @@ #include #include #include +#include #include #include #include diff --git a/escher/include/escher/container.h b/escher/include/escher/container.h index a60a642b7..42328d545 100644 --- a/escher/include/escher/container.h +++ b/escher/include/escher/container.h @@ -15,7 +15,7 @@ #include #include -class Container : private RunLoop { +class Container : public RunLoop { public: Container(); void run(); diff --git a/escher/include/escher/invocation_timer.h b/escher/include/escher/invocation_timer.h new file mode 100644 index 000000000..366d0c69f --- /dev/null +++ b/escher/include/escher/invocation_timer.h @@ -0,0 +1,15 @@ +#ifndef ESCHER_INVOCATION_TIMER_H +#define ESCHER_INVOCATION_TIMER_H + +#include +#include + +class InvocationTimer : public Timer { +public: + InvocationTimer(Invocation invocation, uint32_t period); +private: + void fire() override; + Invocation m_invocation; +}; + +#endif diff --git a/escher/include/escher/timer.h b/escher/include/escher/timer.h index 6dbb1dc79..df2140d88 100644 --- a/escher/include/escher/timer.h +++ b/escher/include/escher/timer.h @@ -1,7 +1,6 @@ #ifndef ESCHER_TIMER_H #define ESCHER_TIMER_H -#include #include /* Timers we'll need @@ -16,12 +15,12 @@ class Timer { public: static constexpr int TickDuration = 100; // In Miliseconds - Timer(Invocation invocation, uint32_t period); // Period is in ticks + Timer(uint32_t period); // Period is in ticks void tick(); void reset(); +protected: + virtual void fire() = 0; private: - void fire(); - Invocation m_invocation; uint32_t m_period; uint32_t m_numberOfTicksBeforeFire; }; diff --git a/escher/src/invocation_timer.cpp b/escher/src/invocation_timer.cpp new file mode 100644 index 000000000..37ca92df0 --- /dev/null +++ b/escher/src/invocation_timer.cpp @@ -0,0 +1,11 @@ +#include + +InvocationTimer::InvocationTimer(Invocation invocation, uint32_t period) : + Timer(period), + m_invocation(invocation) +{ +} + +void InvocationTimer::fire() { + m_invocation.perform(this); +} diff --git a/escher/src/timer.cpp b/escher/src/timer.cpp index 7c79f94bf..564cdb51a 100644 --- a/escher/src/timer.cpp +++ b/escher/src/timer.cpp @@ -1,7 +1,6 @@ #include -Timer::Timer(Invocation invocation, uint32_t period) : - m_invocation(invocation), +Timer::Timer(uint32_t period) : m_period(period), m_numberOfTicksBeforeFire(period) { @@ -18,7 +17,3 @@ void Timer::tick() { void Timer::reset() { m_numberOfTicksBeforeFire = m_period; } - -void Timer::fire() { - m_invocation.perform(this); -}