17#include "ksApplication.h"
23#define KSF_IMPLEMENT_APP_ROTATOR(...) \
24 ksf::ksAppRotator<__VA_ARGS__> appRotator; \
25 void setup() { KSF_FRAMEWORK_INIT() } \
26 void loop() { appRotator.loop(1); }
33#define KSF_IMPLEMENT_APP_ROTATOR_INTERVAL(delayBetweenLoops, ...) \
34 ksf::ksAppRotator<__VA_ARGS__> appRotator; \
35 void setup() { KSF_FRAMEWORK_INIT() } \
36 void loop() { appRotator.loop(delayBetweenLoops); }
44 template <
class... AppTypes>
49 std::unique_ptr<ksApplication> currentApplication{
nullptr};
50 typedef std::unique_ptr<ksApplication> (*TSpawnerFunc)();
57 template <
class TApplicationType>
58 static std::unique_ptr<ksApplication> spawnApp()
60 return std::make_unique<TApplicationType>();
63 static constexpr std::array<TSpawnerFunc,
sizeof...(AppTypes)> appSpawners{spawnApp<AppTypes>...};
72 if (currentApplication)
75 if (!currentApplication->loop())
76 currentApplication.reset();
83 currentApplication = appSpawners[appIndex]();
86 if (!currentApplication->init())
87 currentApplication.reset();
90 if (++appIndex >= appSpawners.size())
98 void loop(
unsigned long milliseconds)
Application rotator component.
Definition ksAppRotator.h:46
void loopNoDelay()
Runs the application loop.
Definition ksAppRotator.h:69
void loop(unsigned long milliseconds)
Runs application loop with a delay between loops.
Definition ksAppRotator.h:98