
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.
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "displayapp/Apps.h"
|
|
#include "displayapp/screens/Screen.h"
|
|
#include "displayapp/Controllers.h"
|
|
|
|
namespace Pinetime {
|
|
namespace Applications {
|
|
struct TwosTile {
|
|
bool merged = false;
|
|
unsigned int value = 0;
|
|
};
|
|
|
|
namespace Screens {
|
|
class Twos : public Screen {
|
|
public:
|
|
Twos();
|
|
~Twos() override;
|
|
|
|
bool OnTouchEvent(TouchEvents event) override;
|
|
|
|
private:
|
|
static constexpr int nColors = 5;
|
|
lv_style_t cellStyles[nColors];
|
|
|
|
lv_obj_t* scoreText;
|
|
lv_obj_t* gridDisplay;
|
|
static constexpr int nCols = 4;
|
|
static constexpr int nRows = 4;
|
|
static constexpr int nCells = nCols * nRows;
|
|
TwosTile grid[nRows][nCols];
|
|
unsigned int score = 0;
|
|
void updateGridDisplay();
|
|
bool tryMerge(int newRow, int newCol, int oldRow, int oldCol);
|
|
bool tryMove(int newRow, int newCol, int oldRow, int oldCol);
|
|
bool placeNewTile();
|
|
};
|
|
}
|
|
template<>
|
|
struct AppTraits<Apps::Twos> {
|
|
static constexpr Apps app = Apps::Twos;
|
|
static constexpr const char* icon = "2";
|
|
static Screens::Screen *Create(AppControllers& /*controllers*/) { return new Screens::Twos(); };
|
|
};
|
|
}
|
|
}
|