Application selection at build time

A list of "user applications" is built at compile time. It contains all the info needed to create the application at runtime (ptr to a create() function) and to display the app in the application menu. All applications declare a TypeTrait with these information.
When a new app must be loaded, DisplayApp first check if this app is a System app (in which case it creates it like it did before). If it's not a System app, it looks for the app in the list of User applications and creates it if it found it.
Those changes allow to more easily add new app and to select which app must be built into the firmware.
Switch to C++20 (and fix a few issues in SpiMaster.cpp and Watchdog.cpp.
This commit is contained in:
Jean-François Milants
2023-10-23 20:12:34 +02:00
committed by JF
parent f6d7f602f5
commit 63e0c4f4ef
29 changed files with 431 additions and 176 deletions

View File

@@ -8,38 +8,48 @@
#include <lvgl/lvgl.h>
#include "components/timer/Timer.h"
#include "Symbols.h"
namespace Pinetime::Applications::Screens {
class Timer : public Screen {
public:
Timer(Controllers::Timer& timerController);
~Timer() override;
void Refresh() override;
void Reset();
void ToggleRunning();
void ButtonPressed();
void MaskReset();
namespace Pinetime::Applications{
namespace Screens {
class Timer : public Screen {
public:
Timer(Controllers::Timer& timerController);
~Timer() override;
void Refresh() override;
void Reset();
void ToggleRunning();
void ButtonPressed();
void MaskReset();
private:
void SetTimerRunning();
void SetTimerStopped();
void UpdateMask();
Controllers::Timer& timer;
private:
void SetTimerRunning();
void SetTimerStopped();
void UpdateMask();
Pinetime::Controllers::Timer& timer;
lv_obj_t* btnPlayPause;
lv_obj_t* txtPlayPause;
lv_obj_t* btnPlayPause;
lv_obj_t* txtPlayPause;
lv_obj_t* btnObjectMask;
lv_obj_t* highlightObjectMask;
lv_objmask_mask_t* btnMask;
lv_objmask_mask_t* highlightMask;
lv_obj_t* btnObjectMask;
lv_obj_t* highlightObjectMask;
lv_objmask_mask_t* btnMask;
lv_objmask_mask_t* highlightMask;
lv_task_t* taskRefresh;
Widgets::Counter minuteCounter = Widgets::Counter(0, 59, jetbrains_mono_76);
Widgets::Counter secondCounter = Widgets::Counter(0, 59, jetbrains_mono_76);
lv_task_t* taskRefresh;
Widgets::Counter minuteCounter = Widgets::Counter(0, 59, jetbrains_mono_76);
Widgets::Counter secondCounter = Widgets::Counter(0, 59, jetbrains_mono_76);
bool buttonPressing = false;
lv_coord_t maskPosition = 0;
TickType_t pressTime = 0;
bool buttonPressing = false;
lv_coord_t maskPosition = 0;
TickType_t pressTime = 0;
};
}
template<>
struct AppTraits<Apps::Timer> {
static constexpr Apps app = Apps::Timer;
static constexpr const char* icon = Screens::Symbols::hourGlass;
static Screens::Screen *Create(AppControllers& controllers) { return new Screens::Timer(controllers.timer); };
};
}