Rayvert64 / ToInfiniTimeAndBeyond

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS. The goal here is to modernize the C++ used and try to stay bleeding edge on the libraries(like LVGL, the SDK used and more) **I will probably fork this to make my own watch OS. But will probably push the LVGL update I am working on to InfiniTime, then change the RTOS used.**
GNU General Public License v3.0
0 stars 0 forks source link

Change controller references to use smart pointers #2

Open Rayvert64 opened 5 months ago

Rayvert64 commented 5 months ago

Verification

Introduce the issue

Here's an example in Tile.h of the DateTime controller, the last line. It seems that every file uses a raw reference to a singleton. Not catastrophic, but I thought we should check this out after #1 is done working on.

class Tile : public Screen {
      public:
        struct Applications {
          const char* icon;
          Pinetime::Applications::Apps application;
          bool enabled;
        };

        explicit Tile(uint8_t screenID,
                      uint8_t numScreens,
                      DisplayApp* app,
                      Controllers::Settings& settingsController,
                      const Controllers::Battery& batteryController,
                      const Controllers::Ble& bleController,
                      Controllers::DateTime& dateTimeController,
                      std::array<Applications, 6>& applications);

        ~Tile() override;

        void UpdateScreen();
        void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId);

      private:
        DisplayApp* app;
        Controllers::DateTime& dateTimeController;

Preferred solution

Use shared_ptr or some other implementation of a smart pointer.

That is all.

Good Night.

Version

No response