screens: Remove displayapp parameter from screen

The DisplayApp class isn't used in the Screen base class and most
screens, so requiring it is pointless.

In this commit, DisplayApp pointers were added to screens which use it
and the explicit Screen constructor was removed in those screens.
This commit is contained in:
Riku Isokoski 2023-02-22 22:05:37 +02:00
parent e2d4084701
commit 7c7a8602c4
30 changed files with 44 additions and 29 deletions

View file

@ -23,7 +23,7 @@ ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp* app,
const Pinetime::Controllers::Battery& batteryController, const Pinetime::Controllers::Battery& batteryController,
const Pinetime::Controllers::Ble& bleController, const Pinetime::Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController) Controllers::DateTime& dateTimeController)
: Screen(app), : app {app},
settingsController {settingsController}, settingsController {settingsController},
batteryController {batteryController}, batteryController {batteryController},
bleController {bleController}, bleController {bleController},

View file

@ -25,6 +25,7 @@ namespace Pinetime {
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
private: private:
DisplayApp* app;
auto CreateScreenList() const; auto CreateScreenList() const;
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const; std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;

View file

@ -26,7 +26,7 @@ Clock::Clock(DisplayApp* app,
Controllers::HeartRateController& heartRateController, Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController, Controllers::MotionController& motionController,
Controllers::FS& filesystem) Controllers::FS& filesystem)
: Screen(app), : app {app},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
batteryController {batteryController}, batteryController {batteryController},
bleController {bleController}, bleController {bleController},

View file

@ -36,6 +36,7 @@ namespace Pinetime {
bool OnButtonPushed() override; bool OnButtonPushed() override;
private: private:
DisplayApp* app;
Controllers::DateTime& dateTimeController; Controllers::DateTime& dateTimeController;
const Controllers::Battery& batteryController; const Controllers::Battery& batteryController;
const Controllers::Ble& bleController; const Controllers::Ble& bleController;

View file

@ -2,8 +2,8 @@
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::DisplayApp* app, lv_obj_t* labelText) Label::Label(uint8_t screenID, uint8_t numScreens, lv_obj_t* labelText)
: Screen(app), labelText {labelText}, pageIndicator(screenID, numScreens) { : labelText {labelText}, pageIndicator(screenID, numScreens) {
pageIndicator.Create(); pageIndicator.Create();
} }

View file

@ -10,7 +10,7 @@ namespace Pinetime {
class Label : public Screen { class Label : public Screen {
public: public:
Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText); Label(uint8_t screenID, uint8_t numScreens, lv_obj_t* labelText);
~Label() override; ~Label() override;
private: private:

View file

@ -17,7 +17,7 @@ List::List(uint8_t screenID,
DisplayApp* app, DisplayApp* app,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
std::array<Applications, MAXLISTITEMS>& applications) std::array<Applications, MAXLISTITEMS>& applications)
: Screen(app), settingsController {settingsController}, pageIndicator(screenID, numScreens) { : app {app}, settingsController {settingsController}, pageIndicator(screenID, numScreens) {
// Set the background to Black // Set the background to Black
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(0, 0, 0)); lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(0, 0, 0));

View file

@ -31,6 +31,7 @@ namespace Pinetime {
void OnButtonEvent(lv_obj_t* object, lv_event_t event); void OnButtonEvent(lv_obj_t* object, lv_event_t event);
private: private:
DisplayApp* app;
Controllers::Settings& settingsController; Controllers::Settings& settingsController;
Pinetime::Applications::Apps apps[MAXLISTITEMS]; Pinetime::Applications::Apps apps[MAXLISTITEMS];

View file

@ -16,7 +16,7 @@ Notifications::Notifications(DisplayApp* app,
Pinetime::Controllers::MotorController& motorController, Pinetime::Controllers::MotorController& motorController,
System::SystemTask& systemTask, System::SystemTask& systemTask,
Modes mode) Modes mode)
: Screen(app), : app {app},
notificationManager {notificationManager}, notificationManager {notificationManager},
alertNotificationService {alertNotificationService}, alertNotificationService {alertNotificationService},
motorController {motorController}, motorController {motorController},

View file

@ -69,6 +69,7 @@ namespace Pinetime {
}; };
private: private:
DisplayApp* app;
Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Pinetime::Controllers::MotorController& motorController; Pinetime::Controllers::MotorController& motorController;

View file

@ -50,9 +50,11 @@ namespace Pinetime {
} }
public: public:
explicit Screen(DisplayApp* app) : app {app} { explicit Screen(DisplayApp* app) {
} }
explicit Screen() = default;
virtual ~Screen() = default; virtual ~Screen() = default;
static void RefreshTaskCallback(lv_task_t* task); static void RefreshTaskCallback(lv_task_t* task);
@ -77,7 +79,6 @@ namespace Pinetime {
} }
protected: protected:
DisplayApp* app;
bool running = true; bool running = true;
}; };
} }

View file

@ -19,7 +19,7 @@ namespace Pinetime {
uint8_t initScreen, uint8_t initScreen,
const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens, const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
ScreenListModes mode) ScreenListModes mode)
: Screen(app), : app {app},
initScreen {initScreen}, initScreen {initScreen},
screens {std::move(screens)}, screens {std::move(screens)},
mode {mode}, mode {mode},
@ -102,6 +102,7 @@ namespace Pinetime {
} }
private: private:
DisplayApp* app;
uint8_t initScreen = 0; uint8_t initScreen = 0;
const std::array<std::function<std::unique_ptr<Screen>()>, N> screens; const std::array<std::function<std::unique_ptr<Screen>()>, N> screens;
ScreenListModes mode = ScreenListModes::UpDown; ScreenListModes mode = ScreenListModes::UpDown;

View file

@ -38,7 +38,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
Pinetime::Drivers::WatchdogView& watchdog, Pinetime::Drivers::WatchdogView& watchdog,
Pinetime::Controllers::MotionController& motionController, Pinetime::Controllers::MotionController& motionController,
const Pinetime::Drivers::Cst816S& touchPanel) const Pinetime::Drivers::Cst816S& touchPanel)
: Screen(app), : app {app},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
batteryController {batteryController}, batteryController {batteryController},
brightnessController {brightnessController}, brightnessController {brightnessController},
@ -94,7 +94,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
BootloaderVersion::VersionString()); BootloaderVersion::VersionString());
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(0, 5, app, label); return std::make_unique<Screens::Label>(0, 5, label);
} }
std::unique_ptr<Screen> SystemInfo::CreateScreen2() { std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
@ -173,7 +173,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
touchPanel.GetFwVersion(), touchPanel.GetFwVersion(),
TARGET_DEVICE_NAME); TARGET_DEVICE_NAME);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(1, 5, app, label); return std::make_unique<Screens::Label>(1, 5, label);
} }
std::unique_ptr<Screen> SystemInfo::CreateScreen3() { std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
@ -204,7 +204,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
mon.frag_pct, mon.frag_pct,
static_cast<int>(mon.free_biggest_size)); static_cast<int>(mon.free_biggest_size));
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(2, 5, app, label); return std::make_unique<Screens::Label>(2, 5, label);
} }
bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) { bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
@ -265,7 +265,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
} }
lv_table_set_cell_value(infoTask, i + 1, 3, buffer); lv_table_set_cell_value(infoTask, i + 1, 3, buffer);
} }
return std::make_unique<Screens::Label>(3, 5, app, infoTask); return std::make_unique<Screens::Label>(3, 5, infoTask);
} }
std::unique_ptr<Screen> SystemInfo::CreateScreen5() { std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
@ -282,5 +282,5 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
"#FFFF00 InfiniTime#"); "#FFFF00 InfiniTime#");
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(4, 5, app, label); return std::make_unique<Screens::Label>(4, 5, label);
} }

View file

@ -34,6 +34,7 @@ namespace Pinetime {
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
private: private:
DisplayApp* app;
Pinetime::Controllers::DateTime& dateTimeController; Pinetime::Controllers::DateTime& dateTimeController;
const Pinetime::Controllers::Battery& batteryController; const Pinetime::Controllers::Battery& batteryController;
Pinetime::Controllers::BrightnessController& brightnessController; Pinetime::Controllers::BrightnessController& brightnessController;

View file

@ -32,7 +32,7 @@ Tile::Tile(uint8_t screenID,
const Controllers::Ble& bleController, const Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController, Controllers::DateTime& dateTimeController,
std::array<Applications, 6>& applications) std::array<Applications, 6>& applications)
: Screen(app), : app {app},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
pageIndicator(screenID, numScreens), pageIndicator(screenID, numScreens),
statusIcons(batteryController, bleController) { statusIcons(batteryController, bleController) {

View file

@ -36,6 +36,7 @@ namespace Pinetime {
void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId); void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId);
private: private:
DisplayApp* app;
Controllers::DateTime& dateTimeController; Controllers::DateTime& dateTimeController;
lv_task_t* taskUpdate; lv_task_t* taskUpdate;

View file

@ -26,7 +26,7 @@
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
Weather::Weather(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::WeatherService& weather) Weather::Weather(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::WeatherService& weather)
: Screen(app), : app {app},
weatherService(weather), weatherService(weather),
screens {app, screens {app,
0, 0,
@ -97,7 +97,7 @@ std::unique_ptr<Screen> Weather::CreateScreenTemperature() {
} }
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label)); return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
} }
std::unique_ptr<Screen> Weather::CreateScreenAir() { std::unique_ptr<Screen> Weather::CreateScreenAir() {
@ -130,7 +130,7 @@ std::unique_ptr<Screen> Weather::CreateScreenAir() {
} }
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label)); return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
} }
std::unique_ptr<Screen> Weather::CreateScreenClouds() { std::unique_ptr<Screen> Weather::CreateScreenClouds() {
@ -159,7 +159,7 @@ std::unique_ptr<Screen> Weather::CreateScreenClouds() {
} }
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label)); return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
} }
std::unique_ptr<Screen> Weather::CreateScreenPrecipitation() { std::unique_ptr<Screen> Weather::CreateScreenPrecipitation() {
@ -188,7 +188,7 @@ std::unique_ptr<Screen> Weather::CreateScreenPrecipitation() {
} }
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label)); return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
} }
std::unique_ptr<Screen> Weather::CreateScreenHumidity() { std::unique_ptr<Screen> Weather::CreateScreenHumidity() {
@ -217,5 +217,5 @@ std::unique_ptr<Screen> Weather::CreateScreenHumidity() {
} }
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label)); return std::unique_ptr<Screen>(new Screens::Label(0, 5, label));
} }

View file

@ -23,6 +23,7 @@ namespace Pinetime {
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
private: private:
DisplayApp* app;
bool running = true; bool running = true;
Controllers::WeatherService& weatherService; Controllers::WeatherService& weatherService;

View file

@ -34,7 +34,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
Controllers::MotorController& motorController, Controllers::MotorController& motorController,
Pinetime::Controllers::Settings& settingsController, Pinetime::Controllers::Settings& settingsController,
const Controllers::Ble& bleController) const Controllers::Ble& bleController)
: Screen(app), : app {app},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
brightness {brightness}, brightness {brightness},
motorController {motorController}, motorController {motorController},

View file

@ -32,6 +32,7 @@ namespace Pinetime {
void UpdateScreen(); void UpdateScreen();
private: private:
DisplayApp* app;
Controllers::DateTime& dateTimeController; Controllers::DateTime& dateTimeController;
Controllers::BrightnessController& brightness; Controllers::BrightnessController& brightness;
Controllers::MotorController& motorController; Controllers::MotorController& motorController;

View file

@ -35,7 +35,7 @@ namespace {
} }
SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), : app {app},
checkboxList( checkboxList(
0, 0,
1, 1,

View file

@ -19,6 +19,7 @@ namespace Pinetime {
~SettingBluetooth() override; ~SettingBluetooth() override;
private: private:
DisplayApp* app;
CheckboxList checkboxList; CheckboxList checkboxList;
}; };
} }

View file

@ -18,7 +18,7 @@ namespace {
constexpr std::array<uint16_t, 6> SettingDisplay::options; constexpr std::array<uint16_t, 6> SettingDisplay::options;
SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), settingsController {settingsController} { : app {app}, settingsController {settingsController} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);

View file

@ -20,6 +20,7 @@ namespace Pinetime {
void UpdateSelected(lv_obj_t* object, lv_event_t event); void UpdateSelected(lv_obj_t* object, lv_event_t event);
private: private:
DisplayApp* app;
static constexpr std::array<uint16_t, 6> options = {5000, 7000, 10000, 15000, 20000, 30000}; static constexpr std::array<uint16_t, 6> options = {5000, 7000, 10000, 15000, 20000, 30000};
Controllers::Settings& settingsController; Controllers::Settings& settingsController;

View file

@ -15,7 +15,7 @@ bool SettingSetDateTime::OnTouchEvent(Pinetime::Applications::TouchEvents event)
SettingSetDateTime::SettingSetDateTime(Pinetime::Applications::DisplayApp* app, SettingSetDateTime::SettingSetDateTime(Pinetime::Applications::DisplayApp* app,
Pinetime::Controllers::DateTime& dateTimeController, Pinetime::Controllers::DateTime& dateTimeController,
Pinetime::Controllers::Settings& settingsController) Pinetime::Controllers::Settings& settingsController)
: Screen(app), : app {app},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
settingsController {settingsController}, settingsController {settingsController},
screens {app, screens {app,

View file

@ -20,6 +20,7 @@ namespace Pinetime {
void Quit(); void Quit();
private: private:
DisplayApp* app;
Controllers::DateTime& dateTimeController; Controllers::DateTime& dateTimeController;
Controllers::Settings& settingsController; Controllers::Settings& settingsController;

View file

@ -22,7 +22,7 @@ auto SettingWatchFace::CreateScreenList() const {
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app,
Pinetime::Controllers::Settings& settingsController, Pinetime::Controllers::Settings& settingsController,
Pinetime::Controllers::FS& filesystem) Pinetime::Controllers::FS& filesystem)
: Screen(app), : app {app},
settingsController {settingsController}, settingsController {settingsController},
filesystem {filesystem}, filesystem {filesystem},
screens {app, 0, CreateScreenList(), Screens::ScreenListModes::UpDown} { screens {app, 0, CreateScreenList(), Screens::ScreenListModes::UpDown} {

View file

@ -25,6 +25,7 @@ namespace Pinetime {
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
private: private:
DisplayApp* app;
auto CreateScreenList() const; auto CreateScreenList() const;
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const; std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;

View file

@ -19,7 +19,7 @@ auto Settings::CreateScreenList() const {
} }
Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), : app {app},
settingsController {settingsController}, settingsController {settingsController},
screens {app, settingsController.GetSettingsMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} { screens {app, settingsController.GetSettingsMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} {
} }

View file

@ -20,6 +20,7 @@ namespace Pinetime {
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
private: private:
DisplayApp* app;
auto CreateScreenList() const; auto CreateScreenList() const;
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const; std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;