Open-Smartwatch / open-smartwatch-os

The Open-Smartwatch Operating System.
https://open-smartwatch.github.io
GNU General Public License v3.0
967 stars 155 forks source link

OswAppV2 (new osw app class) #354

Closed simonmicro closed 11 months ago

simonmicro commented 1 year ago

The primary motivation is to only render the screen when needed (needed to port to Watchy / E-Ink displays). Turns out, when we start providing more features in the app-class (like callbacks, metadata, "events") we can even add more unified features (button-handling, animations, overlay-menus)!

Here a simple draft of the new app-class:

class OswHal;
class OswAppV2 {
  public:
    virtual const char* getAppId() = 0;
    virtual const char* getAppName() = 0;
    virtual ???& getAppIcon() = 0;

    // TODO all those ↓ must update hal-reference
    virtual void onStart();
    virtual void onLoop();
    virtual void onDraw();
    virtual void onStop();

    virtual void onButton(void id, bool down, bool shortPress, bool longPress);
#ifdef OSW_EMULATOR
    virtual void onLoopDebug() {}; // By default no debug loop (GUI) is implemented
#endif

  protected:
    OswHal* hal = nullptr; // You guys are needing that anyways (but you often cache incorrectly), so it is now given to you <3
    bool needsRedraw = false;
};

More stuff: