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:
committed by
JF
parent
f6d7f602f5
commit
63e0c4f4ef
@@ -7,50 +7,65 @@
|
||||
#include "portmacro_cmsis.h"
|
||||
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "displayapp/Apps.h"
|
||||
#include "displayapp/Controllers.h"
|
||||
#include "Symbols.h"
|
||||
|
||||
namespace Pinetime::Applications::Screens {
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
namespace Screens {
|
||||
|
||||
enum class States { Init, Running, Halted };
|
||||
enum class States { Init, Running, Halted };
|
||||
|
||||
struct TimeSeparated_t {
|
||||
int hours;
|
||||
int mins;
|
||||
int secs;
|
||||
int hundredths;
|
||||
};
|
||||
struct TimeSeparated_t {
|
||||
int hours;
|
||||
int mins;
|
||||
int secs;
|
||||
int hundredths;
|
||||
};
|
||||
|
||||
class StopWatch : public Screen {
|
||||
public:
|
||||
explicit StopWatch(System::SystemTask& systemTask);
|
||||
~StopWatch() override;
|
||||
void Refresh() override;
|
||||
class StopWatch : public Screen {
|
||||
public:
|
||||
explicit StopWatch(System::SystemTask& systemTask);
|
||||
~StopWatch() override;
|
||||
void Refresh() override;
|
||||
|
||||
void playPauseBtnEventHandler();
|
||||
void stopLapBtnEventHandler();
|
||||
bool OnButtonPushed() override;
|
||||
void playPauseBtnEventHandler();
|
||||
void stopLapBtnEventHandler();
|
||||
bool OnButtonPushed() override;
|
||||
|
||||
private:
|
||||
void SetInterfacePaused();
|
||||
void SetInterfaceRunning();
|
||||
void SetInterfaceStopped();
|
||||
private:
|
||||
void SetInterfacePaused();
|
||||
void SetInterfaceRunning();
|
||||
void SetInterfaceStopped();
|
||||
|
||||
void Reset();
|
||||
void Start();
|
||||
void Pause();
|
||||
void Reset();
|
||||
void Start();
|
||||
void Pause();
|
||||
|
||||
Pinetime::System::SystemTask& systemTask;
|
||||
States currentState = States::Init;
|
||||
TickType_t startTime;
|
||||
TickType_t oldTimeElapsed = 0;
|
||||
TickType_t blinkTime = 0;
|
||||
static constexpr int maxLapCount = 20;
|
||||
TickType_t laps[maxLapCount + 1];
|
||||
static constexpr int displayedLaps = 2;
|
||||
int lapsDone = 0;
|
||||
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
|
||||
lv_obj_t* lapText;
|
||||
bool isHoursLabelUpdated = false;
|
||||
Pinetime::System::SystemTask& systemTask;
|
||||
States currentState = States::Init;
|
||||
TickType_t startTime;
|
||||
TickType_t oldTimeElapsed = 0;
|
||||
TickType_t blinkTime = 0;
|
||||
static constexpr int maxLapCount = 20;
|
||||
TickType_t laps[maxLapCount + 1];
|
||||
static constexpr int displayedLaps = 2;
|
||||
int lapsDone = 0;
|
||||
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
|
||||
lv_obj_t* lapText;
|
||||
bool isHoursLabelUpdated = false;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
template <>
|
||||
struct AppTraits<Apps::StopWatch> {
|
||||
static constexpr Apps app = Apps::StopWatch;
|
||||
static constexpr const char* icon = Screens::Symbols::stopWatch;
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::StopWatch(*controllers.systemTask);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user