Author: Jean-François Milants <jf@codingfield.com>
Fix code formatting
src/components/gfx/Gfx.cpp | 2 src/displayapp/Apps.h | 3 + src/displayapp/Controllers.h | 5 ++++ src/displayapp/DisplayApp.cpp | 26 +++++++++++++++++------ src/displayapp/DisplayAppRecovery.h | 1 src/displayapp/UserApps.h | 2 src/displayapp/screens/Alarm.h | 10 ++++++-- src/displayapp/screens/ApplicationList.cpp | 10 ++++---- src/displayapp/screens/ApplicationList.h | 2 src/displayapp/screens/HeartRate.h | 2 + src/displayapp/screens/InfiniPaint.h | 2 + src/displayapp/screens/Metronome.h | 2 + src/displayapp/screens/Motion.h | 2 + src/displayapp/screens/Music.h | 2 + src/displayapp/screens/Navigation.h | 2 + src/displayapp/screens/Paddle.h | 2 + src/displayapp/screens/Steps.h | 2 + src/displayapp/screens/StopWatch.h | 2 + src/displayapp/screens/Timer.h | 9 +++++-- src/displayapp/screens/Twos.h | 8 +++++- src/displayapp/screens/Weather.h | 2 +
diff --git a/src/components/gfx/Gfx.cpp b/src/components/gfx/Gfx.cpp index d3ef3d087ac0f0a74b81bfad142a8a2ee5aeb345..baa6486a4a11b6dd5bd2e0d825df935e1a95c64f 100644 --- a/src/components/gfx/Gfx.cpp +++ b/src/components/gfx/Gfx.cpp @@ -141,7 +141,7 @@ bool Gfx::GetNextBuffer(uint8_t** data, size_t& size) { if (!state.busy) return false; - state.remainingIterations = state.remainingIterations-1; + state.remainingIterations = state.remainingIterations - 1; if (state.remainingIterations == 0) { state.busy = false; NotifyEndOfTransfer(state.taskToNotify); diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index d96e6ea72105e0e2f3bff9e6f839940c0e7c3462..0dd8157e2d5754bfa2502f41cfe58959c191932b 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -40,10 +40,11 @@ SettingBluetooth, Error, Weather }; + template <Apps> struct AppTraits {}; - template<Apps ...As> + template <Apps... As> struct TypeList { static constexpr size_t Count = sizeof...(As); }; diff --git a/src/displayapp/Controllers.h b/src/displayapp/Controllers.h index a2f8238880a10fce077297b2eabe68669d850108..df6b2284b4cc81e14d53105e571853641a345be3 100644 --- a/src/displayapp/Controllers.h +++ b/src/displayapp/Controllers.h @@ -1,11 +1,14 @@ #pragma once + namespace Pinetime { namespace Applications { class DisplayApp; } + namespace Components { class LittleVgl; } + namespace Controllers { class Battery; class Ble; @@ -23,9 +26,11 @@ class Timer; class MusicService; class NavigationService; } + namespace System { class SystemTask; } + namespace Applications { struct AppControllers { const Pinetime::Controllers::Battery& batteryController; diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index a195361ddb2b5ac939b34b53af0b1986ec5f6cf1..98be6324a9d21f49aab388190ee17eccdf3c6b03 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -98,11 +98,24 @@ touchHandler {touchHandler}, filesystem {filesystem}, lvgl {lcd, filesystem}, timer(this, TimerCallback), - controllers{ - batteryController, bleController, dateTimeController, notificationManager, heartRateController, - settingsController, motorController, motionController, alarmController, brightnessController, - nullptr, filesystem, timer, nullptr, this, lvgl, nullptr, nullptr} - { + controllers {batteryController, + bleController, + dateTimeController, + notificationManager, + heartRateController, + settingsController, + motorController, + motionController, + alarmController, + brightnessController, + nullptr, + filesystem, + timer, + nullptr, + this, + lvgl, + nullptr, + nullptr} { } void DisplayApp::Start(System::BootErrors error) { @@ -421,8 +434,7 @@ bleController, dateTimeController, filesystem, std::move(apps)); - } - break; + } break; case Apps::Clock: currentScreen = std::make_unique<Screens::Clock>(dateTimeController, batteryController, diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h index a42d3e2fb1f363b25a7c6bb1c08fb46cd9d83add..41aedb179373dd0986f8bb59c189469cb3c64523 100644 --- a/src/displayapp/DisplayAppRecovery.h +++ b/src/displayapp/DisplayAppRecovery.h @@ -73,7 +73,6 @@ void Register(Pinetime::Controllers::WeatherService* weatherService); void Register(Pinetime::Controllers::MusicService* musicService); void Register(Pinetime::Controllers::NavigationService* NavigationService); - private: TaskHandle_t taskHandle; static void Process(void* instance); diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index d0165cf9defb83d7449403bc13a3ba630596c38b..0ed9d602940b195b5419d1663e4e8c4982e4c609 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -26,7 +26,7 @@ consteval AppDescription CreateAppDescription() { return {AppTraits<t>::app, AppTraits<t>::icon, &AppTraits<t>::Create}; } - template <template<Apps...> typename T, Apps ...ts> + template <template <Apps...> typename T, Apps... ts> consteval std::array<AppDescription, sizeof...(ts)> CreateAppDescriptions(T<ts...>) { return {CreateAppDescription<ts>()...}; } diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h index efa38eb74fce2f25bb0965b3f0f68473f23c9fc4..d8ed9668dc471f2011ef2fa63e3fe5de097bed1f 100644 --- a/src/displayapp/screens/Alarm.h +++ b/src/displayapp/screens/Alarm.h @@ -65,14 +65,18 @@ Widgets::Counter hourCounter = Widgets::Counter(0, 23, jetbrains_mono_76); Widgets::Counter minuteCounter = Widgets::Counter(0, 59, jetbrains_mono_76); }; } - template<> + + template <> struct AppTraits<Apps::Alarm> { static constexpr Apps app = Apps::Alarm; static constexpr const char* icon = Screens::Symbols::clock; - static Screens::Screen *Create(AppControllers& controllers) { return new Screens::Alarm(controllers.alarmController, + + static Screens::Screen* Create(AppControllers& controllers) { + return new Screens::Alarm(controllers.alarmController, controllers.settingsController.GetClockType(), *controllers.systemTask, - controllers.motorController); }; + controllers.motorController); + }; }; } } diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index e5e26098d8053ed1f69e3da73bde12aa2fd11dc3..41735349da8322d27b248cdb59ae1ecb7b0193c3 100644 --- a/src/displayapp/screens/ApplicationList.cpp +++ b/src/displayapp/screens/ApplicationList.cpp @@ -2,7 +2,7 @@ #include "displayapp/screens/ApplicationList.h" #include "displayapp/screens/Tile.h" #include <lvgl/lvgl.h> #include <functional> -#include <algorithm> +#include <algorithm> #include "components/settings/Settings.h" using namespace Pinetime::Applications::Screens; @@ -29,8 +29,8 @@ settingsController {settingsController}, batteryController {batteryController}, bleController {bleController}, dateTimeController {dateTimeController}, - filesystem{filesystem}, - apps{std::move(apps)}, + filesystem {filesystem}, + apps {std::move(apps)}, screens {app, settingsController.GetAppMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} { } @@ -45,8 +45,8 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen(unsigned int screenNum) const { std::array<Tile::Applications, appsPerScreen> pageApps; - for(int i = 0; i < appsPerScreen; i++) { - if(i+(screenNum * appsPerScreen) >= apps.size()) { + for (int i = 0; i < appsPerScreen; i++) { + if (i + (screenNum * appsPerScreen) >= apps.size()) { pageApps[i] = {"", Pinetime::Applications::Apps::None, false}; } else { pageApps[i] = apps[i + (screenNum * appsPerScreen)]; diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h index 2ad9c7c7174c3fd02303946fb2ee1aa0240f9799..f8a6be66eea79819eed9b1f4f682610ab7c8771c 100644 --- a/src/displayapp/screens/ApplicationList.h +++ b/src/displayapp/screens/ApplicationList.h @@ -39,7 +39,7 @@ static constexpr int appsPerScreen = 6; // Increment this when more space is needed - static constexpr int nScreens = (UserAppTypes::Count/appsPerScreen)+1; + static constexpr int nScreens = (UserAppTypes::Count / appsPerScreen) + 1; ScreenList<nScreens> screens; }; diff --git a/src/displayapp/screens/HeartRate.h b/src/displayapp/screens/HeartRate.h index 85da8dee31c1c5d37775f8fce347785c15a5c0f3..bf39209a4f9dbf81ae363de45fa0ee814726e9a5 100644 --- a/src/displayapp/screens/HeartRate.h +++ b/src/displayapp/screens/HeartRate.h @@ -38,10 +38,12 @@ lv_task_t* taskRefresh; }; } + template <> struct AppTraits<Apps::HeartRate> { static constexpr Apps app = Apps::HeartRate; static constexpr const char* icon = Screens::Symbols::heartBeat; + static Screens::Screen* Create(AppControllers& controllers) { return new Screens::HeartRate(controllers.heartRateController, *controllers.systemTask); }; diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h index a25ace55a2db7c94f939bf7bcae561cf3c19a949..f7d6de535eee63edaa6647fd5f0edca908de84e6 100644 --- a/src/displayapp/screens/InfiniPaint.h +++ b/src/displayapp/screens/InfiniPaint.h @@ -38,10 +38,12 @@ lv_color_t selectColor = LV_COLOR_WHITE; uint8_t color = 2; }; } + template <> struct AppTraits<Apps::Paint> { static constexpr Apps app = Apps::Paint; static constexpr const char* icon = Screens::Symbols::paintbrush; + static Screens::Screen* Create(AppControllers& controllers) { return new Screens::InfiniPaint(controllers.lvgl, controllers.motorController); }; diff --git a/src/displayapp/screens/Metronome.h b/src/displayapp/screens/Metronome.h index 8820962dca2ed447d13c1c9e9615ec3696630dd5..c498048ebcf3b77f0cdbad3ff38013e0facc7a0a 100644 --- a/src/displayapp/screens/Metronome.h +++ b/src/displayapp/screens/Metronome.h @@ -37,10 +37,12 @@ lv_task_t* taskRefresh; }; } + template <> struct AppTraits<Apps::Metronome> { static constexpr Apps app = Apps::Metronome; static constexpr const char* icon = Screens::Symbols::drum; + static Screens::Screen* Create(AppControllers& controllers) { return new Screens::Metronome(controllers.motorController, *controllers.systemTask); }; diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h index 3ef570d6751d766e2e99db2fca0250370727c39b..9cd126f440a56fc9d0584b6f44322b24621d3de9 100644 --- a/src/displayapp/screens/Motion.h +++ b/src/displayapp/screens/Motion.h @@ -32,10 +32,12 @@ lv_obj_t* labelStep; lv_task_t* taskRefresh; }; } + template <> struct AppTraits<Apps::Motion> { static constexpr Apps app = Apps::Motion; static constexpr const char* icon = "M"; + static Screens::Screen* Create(AppControllers& controllers) { return new Screens::Motion(controllers.motionController); }; diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h index acbb63120d8fed50b8cc5b1490c57bd14f20dc86..062bd968aff7f5bd0d23dc1e1a0c63de46bce2f6 100644 --- a/src/displayapp/screens/Music.h +++ b/src/displayapp/screens/Music.h @@ -85,10 +85,12 @@ /** Watchapp */ }; } + template <> struct AppTraits<Apps::Music> { static constexpr Apps app = Apps::Music; static constexpr const char* icon = Screens::Symbols::music; + static Screens::Screen* Create(AppControllers& controllers) { return new Screens::Music(*controllers.musicService); }; diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h index d54df13ce369af1b7aee69d79454d871f3386c74..e62745b2ca661fa6a46bd06686a682d52170c35d 100644 --- a/src/displayapp/screens/Navigation.h +++ b/src/displayapp/screens/Navigation.h @@ -58,10 +58,12 @@ lv_task_t* taskRefresh; }; } + template <> struct AppTraits<Apps::Navigation> { static constexpr Apps app = Apps::Navigation; static constexpr const char* icon = Screens::Symbols::map; + static Screens::Screen* Create(AppControllers& controllers) { return new Screens::Navigation(*controllers.navigationService); }; diff --git a/src/displayapp/screens/Paddle.h b/src/displayapp/screens/Paddle.h index 0670e5b1f19f1848667a02dde03bf72677112f83..1ea25158817cd921d18e4f472ca116a9af6b1338 100644 --- a/src/displayapp/screens/Paddle.h +++ b/src/displayapp/screens/Paddle.h @@ -48,10 +48,12 @@ lv_task_t* taskRefresh; }; } + template <> struct AppTraits<Apps::Paddle> { static constexpr Apps app = Apps::Paddle; static constexpr const char* icon = Screens::Symbols::paddle; + static Screens::Screen* Create(AppControllers& controllers) { return new Screens::Paddle(controllers.lvgl); }; diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h index 5299d67f9f37a78411685fc423843551f5b3bb9d..428e4b298045aed9a6d2ee398bb9d5bfaecf9105 100644 --- a/src/displayapp/screens/Steps.h +++ b/src/displayapp/screens/Steps.h @@ -42,10 +42,12 @@ lv_task_t* taskRefresh; }; } + template <> struct AppTraits<Apps::Steps> { static constexpr Apps app = Apps::Steps; static constexpr const char* icon = Screens::Symbols::shoe; + static Screens::Screen* Create(AppControllers& controllers) { return new Screens::Steps(controllers.motionController, controllers.settingsController); }; diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h index c3550fc41d7fe1473c75e5f8c21f7f74855b5840..b3bbba8744bdf9626cb82384096d20cf14c2b678 100644 --- a/src/displayapp/screens/StopWatch.h +++ b/src/displayapp/screens/StopWatch.h @@ -59,10 +59,12 @@ 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); }; diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h index f8e337c2ec761706326e9629d567a163e58a885d..409cae1cd488e15896d0a0c180bcf96835a36e21 100644 --- a/src/displayapp/screens/Timer.h +++ b/src/displayapp/screens/Timer.h @@ -10,7 +10,7 @@ #include "components/timer/Timer.h" #include "Symbols.h" -namespace Pinetime::Applications{ +namespace Pinetime::Applications { namespace Screens { class Timer : public Screen { public: @@ -46,10 +46,13 @@ TickType_t pressTime = 0; }; } - template<> + template <> struct AppTraits<Apps::Timer> { static constexpr Apps app = Apps::Timer; static constexpr const char* icon = Screens::Symbols::hourGlass; - static Screens::Screen *Create(AppControllers& controllers) { return new Screens::Timer(controllers.timer); }; + + static Screens::Screen* Create(AppControllers& controllers) { + return new Screens::Timer(controllers.timer); + }; }; } diff --git a/src/displayapp/screens/Twos.h b/src/displayapp/screens/Twos.h index 4e6980f53a72b41dc3b988fe8c59c6878f93fb55..d983d13640af243ae7b033c2eae5e42e0a3aee82 100644 --- a/src/displayapp/screens/Twos.h +++ b/src/displayapp/screens/Twos.h @@ -36,11 +36,15 @@ bool tryMove(int newRow, int newCol, int oldRow, int oldCol); bool placeNewTile(); }; } - template<> + + 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(); }; + + static Screens::Screen* Create(AppControllers& /*controllers*/) { + return new Screens::Twos(); + }; }; } } diff --git a/src/displayapp/screens/Weather.h b/src/displayapp/screens/Weather.h index 888dc257cf1e0bb31295cfb46986a954dcf6feb6..84177ea6fd37b74813ad73b3fce01041f7d1de4a 100644 --- a/src/displayapp/screens/Weather.h +++ b/src/displayapp/screens/Weather.h @@ -44,10 +44,12 @@ std::unique_ptr<Screen> CreateScreenHumidity(); }; } + template <> struct AppTraits<Apps::Weather> { static constexpr Apps app = Apps::Weather; static constexpr const char* icon = Screens::Symbols::sun; + static Screens::Screen* Create(AppControllers& controllers) { return new Screens::Weather(controllers.displayApp, *controllers.weatherController); };