From 1516573df46239ea76b7a8b142a6b719668cb26d Mon Sep 17 00:00:00 2001 From: okaestne Date: Sun, 15 Nov 2020 15:05:51 +0100 Subject: [PATCH] Include cleanup: components --- src/components/battery/BatteryController.cpp | 3 +- src/components/battery/BatteryController.h | 2 +- .../ble/AlertNotificationClient.cpp | 10 ++-- src/components/ble/AlertNotificationClient.h | 14 ++++- .../ble/AlertNotificationService.cpp | 13 ++--- src/components/ble/AlertNotificationService.h | 10 ++++ .../ble/BatteryInformationService.h | 4 ++ src/components/ble/BleController.cpp | 2 - src/components/ble/BleController.h | 3 +- src/components/ble/CurrentTimeClient.cpp | 3 +- src/components/ble/CurrentTimeClient.h | 12 ++-- src/components/ble/CurrentTimeService.h | 4 ++ src/components/ble/DeviceInformationService.h | 9 +-- src/components/ble/DfuService.cpp | 8 +-- src/components/ble/DfuService.h | 4 ++ src/components/ble/ImmediateAlertService.cpp | 6 +- src/components/ble/ImmediateAlertService.h | 4 ++ src/components/ble/MusicService.cpp | 2 +- src/components/ble/MusicService.h | 7 ++- src/components/ble/NimbleController.cpp | 24 ++++---- src/components/ble/NimbleController.h | 31 ++++++---- src/components/ble/NotificationManager.cpp | 2 +- src/components/ble/NotificationManager.h | 4 +- src/components/ble/ServiceDiscovery.cpp | 4 +- src/components/ble/ServiceDiscovery.h | 6 +- .../brightness/BrightnessController.cpp | 2 +- .../firmwarevalidator/FirmwareValidator.cpp | 6 +- src/components/gfx/Gfx.cpp | 5 +- src/components/gfx/Gfx.h | 8 +-- src/logging/NrfLogger.cpp | 7 +-- src/logging/NrfLogger.h | 3 + src/main.cpp | 56 +++++++++++-------- src/main.h | 1 + src/systemtask/SystemTask.cpp | 32 +++++++---- src/systemtask/SystemTask.h | 20 ++++--- 35 files changed, 207 insertions(+), 124 deletions(-) diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index 571efae6..3e3d65b4 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -1,8 +1,7 @@ -#include +#include "BatteryController.h" #include #include #include -#include "BatteryController.h" using namespace Pinetime::Controllers; diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index f07648a9..7cc964e4 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -1,7 +1,7 @@ #pragma once +#include #include - namespace Pinetime { namespace Controllers { class Battery { diff --git a/src/components/ble/AlertNotificationClient.cpp b/src/components/ble/AlertNotificationClient.cpp index abe41099..e7a18626 100644 --- a/src/components/ble/AlertNotificationClient.cpp +++ b/src/components/ble/AlertNotificationClient.cpp @@ -1,7 +1,7 @@ -#include -#include "NotificationManager.h" - #include "AlertNotificationClient.h" +#include +#include "NotificationManager.h" +#include "systemtask/SystemTask.h" using namespace Pinetime::Controllers; constexpr ble_uuid16_t AlertNotificationClient::ansServiceUuid; @@ -159,8 +159,8 @@ void AlertNotificationClient::OnNotification(ble_gap_event *event) { const auto maxBufferSize{maxMessageSize + headerSize}; const auto dbgPacketLen = OS_MBUF_PKTLEN(event->notify_rx.om); - size_t bufferSize = min(dbgPacketLen + stringTerminatorSize, maxBufferSize); - auto messageSize = min(maxMessageSize, (bufferSize - headerSize)); + size_t bufferSize = std::min(dbgPacketLen + stringTerminatorSize, maxBufferSize); + auto messageSize = std::min(maxMessageSize, (bufferSize - headerSize)); NotificationManager::Notification notif; os_mbuf_copydata(event->notify_rx.om, headerSize, messageSize - 1, notif.message.data()); diff --git a/src/components/ble/AlertNotificationClient.h b/src/components/ble/AlertNotificationClient.h index bc0df51e..fa10456c 100644 --- a/src/components/ble/AlertNotificationClient.h +++ b/src/components/ble/AlertNotificationClient.h @@ -1,13 +1,23 @@ #pragma once #include -#include +#include +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include +#undef max +#undef min #include "BleClient.h" - namespace Pinetime { + + namespace System { + class SystemTask; + } + namespace Controllers { + class NotificationManager; + class AlertNotificationClient : public BleClient { public: explicit AlertNotificationClient(Pinetime::System::SystemTask &systemTask, diff --git a/src/components/ble/AlertNotificationService.cpp b/src/components/ble/AlertNotificationService.cpp index 32711b92..3156470c 100644 --- a/src/components/ble/AlertNotificationService.cpp +++ b/src/components/ble/AlertNotificationService.cpp @@ -1,10 +1,9 @@ - -#include -#include "NotificationManager.h" -#include - #include "AlertNotificationService.h" +#include #include +#include +#include "NotificationManager.h" +#include "systemtask/SystemTask.h" using namespace Pinetime::Controllers; @@ -60,8 +59,8 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle const auto maxBufferSize{maxMessageSize + headerSize}; const auto dbgPacketLen = OS_MBUF_PKTLEN(ctxt->om); - size_t bufferSize = min(dbgPacketLen + stringTerminatorSize, maxBufferSize); - auto messageSize = min(maxMessageSize, (bufferSize-headerSize)); + size_t bufferSize = std::min(dbgPacketLen + stringTerminatorSize, maxBufferSize); + auto messageSize = std::min(maxMessageSize, (bufferSize-headerSize)); NotificationManager::Notification notif; os_mbuf_copydata(ctxt->om, headerSize, messageSize-1, notif.message.data()); diff --git a/src/components/ble/AlertNotificationService.h b/src/components/ble/AlertNotificationService.h index 1b8c4989..120312d2 100644 --- a/src/components/ble/AlertNotificationService.h +++ b/src/components/ble/AlertNotificationService.h @@ -1,10 +1,20 @@ #pragma once #include #include +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include +#undef max +#undef min namespace Pinetime { + + namespace System { + class SystemTask; + } namespace Controllers { + class NotificationManager; + class AlertNotificationService { public: AlertNotificationService(Pinetime::System::SystemTask &systemTask, diff --git a/src/components/ble/BatteryInformationService.h b/src/components/ble/BatteryInformationService.h index 74b2222c..b00000a4 100644 --- a/src/components/ble/BatteryInformationService.h +++ b/src/components/ble/BatteryInformationService.h @@ -1,5 +1,9 @@ #pragma once +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include +#undef max +#undef min namespace Pinetime { namespace System { diff --git a/src/components/ble/BleController.cpp b/src/components/ble/BleController.cpp index 2b396e12..650ec79f 100644 --- a/src/components/ble/BleController.cpp +++ b/src/components/ble/BleController.cpp @@ -1,5 +1,3 @@ -#include -#include #include "BleController.h" using namespace Pinetime::Controllers; diff --git a/src/components/ble/BleController.h b/src/components/ble/BleController.h index 3f52ea25..0570c8d0 100644 --- a/src/components/ble/BleController.h +++ b/src/components/ble/BleController.h @@ -1,8 +1,7 @@ #pragma once -#include -#include #include +#include namespace Pinetime { namespace Controllers { diff --git a/src/components/ble/CurrentTimeClient.cpp b/src/components/ble/CurrentTimeClient.cpp index 92f9374b..be50fede 100644 --- a/src/components/ble/CurrentTimeClient.cpp +++ b/src/components/ble/CurrentTimeClient.cpp @@ -1,5 +1,6 @@ -#include #include "CurrentTimeClient.h" +#include +#include "components/datetime/DateTimeController.h" using namespace Pinetime::Controllers; diff --git a/src/components/ble/CurrentTimeClient.h b/src/components/ble/CurrentTimeClient.h index 93139399..1b2e018c 100644 --- a/src/components/ble/CurrentTimeClient.h +++ b/src/components/ble/CurrentTimeClient.h @@ -1,13 +1,15 @@ #pragma once -#include -#include - -#include "components/datetime/DateTimeController.h" -#include "BleClient.h" +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include +#undef max +#undef min +#include +#include "BleClient.h" namespace Pinetime { namespace Controllers { + class DateTime; class CurrentTimeClient : public BleClient { public: diff --git a/src/components/ble/CurrentTimeService.h b/src/components/ble/CurrentTimeService.h index a6be9647..23956283 100644 --- a/src/components/ble/CurrentTimeService.h +++ b/src/components/ble/CurrentTimeService.h @@ -3,7 +3,11 @@ #include #include "components/datetime/DateTimeController.h" +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include +#undef max +#undef min namespace Pinetime { namespace Controllers { diff --git a/src/components/ble/DeviceInformationService.h b/src/components/ble/DeviceInformationService.h index 25ab8402..94ca7bbf 100644 --- a/src/components/ble/DeviceInformationService.h +++ b/src/components/ble/DeviceInformationService.h @@ -1,9 +1,10 @@ #pragma once -#include -#include - +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include -#include +#undef max +#undef min +#include "Version.h" namespace Pinetime { namespace Controllers { diff --git a/src/components/ble/DfuService.cpp b/src/components/ble/DfuService.cpp index 4dec5141..90795b49 100644 --- a/src/components/ble/DfuService.cpp +++ b/src/components/ble/DfuService.cpp @@ -1,8 +1,8 @@ -#include - -#include "components/ble/BleController.h" -#include "systemtask/SystemTask.h" #include "DfuService.h" +#include +#include "components/ble/BleController.h" +#include "drivers/SpiNorFlash.h" +#include "systemtask/SystemTask.h" using namespace Pinetime::Controllers; diff --git a/src/components/ble/DfuService.h b/src/components/ble/DfuService.h index d7ba460c..096bd99a 100644 --- a/src/components/ble/DfuService.h +++ b/src/components/ble/DfuService.h @@ -3,7 +3,11 @@ #include #include +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include +#undef max +#undef min namespace Pinetime { namespace System { diff --git a/src/components/ble/ImmediateAlertService.cpp b/src/components/ble/ImmediateAlertService.cpp index e2cee308..0f6bf6cf 100644 --- a/src/components/ble/ImmediateAlertService.cpp +++ b/src/components/ble/ImmediateAlertService.cpp @@ -1,7 +1,7 @@ -#include -#include #include "ImmediateAlertService.h" -#include "AlertNotificationService.h" +#include +#include "NotificationManager.h" +#include "systemtask/SystemTask.h" using namespace Pinetime::Controllers; diff --git a/src/components/ble/ImmediateAlertService.h b/src/components/ble/ImmediateAlertService.h index c42846c4..2bc9cba5 100644 --- a/src/components/ble/ImmediateAlertService.h +++ b/src/components/ble/ImmediateAlertService.h @@ -1,5 +1,9 @@ #pragma once +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include +#undef max +#undef min namespace Pinetime { namespace System { diff --git a/src/components/ble/MusicService.cpp b/src/components/ble/MusicService.cpp index 84f2972b..fdecb6b3 100644 --- a/src/components/ble/MusicService.cpp +++ b/src/components/ble/MusicService.cpp @@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include #include "MusicService.h" +#include "systemtask/SystemTask.h" int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { auto musicService = static_cast(arg); diff --git a/src/components/ble/MusicService.h b/src/components/ble/MusicService.h index b365909b..ee3628b0 100644 --- a/src/components/ble/MusicService.h +++ b/src/components/ble/MusicService.h @@ -18,10 +18,13 @@ #pragma once #include -#include +#include +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include #include -#include +#undef max +#undef min //c7e50000-78fc-48fe-8e23-43b37a1942d0 #define MUSIC_SERVICE_UUID_BASE {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x00, 0x00, 0xe5, 0xc7} diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index af7f4029..a6f3cc39 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -1,15 +1,19 @@ -#include "components/datetime/DateTimeController.h" -#include -#include "components/ble/NotificationManager.h" -#include #include "NimbleController.h" -#include "MusicService.h" -#include -#include -#include -#include -#include +#include +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include +#include +#include +#include +#undef max +#undef min +#include +#include +#include "components/ble/BleController.h" +#include "components/ble/NotificationManager.h" +#include "components/datetime/DateTimeController.h" +#include "systemtask/SystemTask.h" using namespace Pinetime::Controllers; diff --git a/src/components/ble/NimbleController.h b/src/components/ble/NimbleController.h index 8ddec1f9..914f11e6 100644 --- a/src/components/ble/NimbleController.h +++ b/src/components/ble/NimbleController.h @@ -2,24 +2,35 @@ #include -#include "AlertNotificationService.h" -#include "AlertNotificationClient.h" -#include "DeviceInformationService.h" -#include "CurrentTimeClient.h" -#include "DfuService.h" -#include "CurrentTimeService.h" -#include "MusicService.h" -#include "BatteryInformationService.h" -#include "ImmediateAlertService.h" -#include "ServiceDiscovery.h" +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max #include +#undef max +#undef min +#include "AlertNotificationClient.h" +#include "AlertNotificationService.h" +#include "BatteryInformationService.h" +#include "CurrentTimeClient.h" +#include "CurrentTimeService.h" +#include "DeviceInformationService.h" +#include "DfuService.h" +#include "ImmediateAlertService.h" +#include "MusicService.h" +#include "ServiceDiscovery.h" namespace Pinetime { namespace Drivers { class SpiNorFlash; } + + namespace System { + class SystemTask; + } + namespace Controllers { + class Ble; class DateTime; + class NotificationManager; class NimbleController { diff --git a/src/components/ble/NotificationManager.cpp b/src/components/ble/NotificationManager.cpp index 67711723..dabcb4ba 100644 --- a/src/components/ble/NotificationManager.cpp +++ b/src/components/ble/NotificationManager.cpp @@ -1,6 +1,6 @@ +#include "NotificationManager.h" #include #include -#include "NotificationManager.h" using namespace Pinetime::Controllers; diff --git a/src/components/ble/NotificationManager.h b/src/components/ble/NotificationManager.h index 49fe8306..036d2ed9 100644 --- a/src/components/ble/NotificationManager.h +++ b/src/components/ble/NotificationManager.h @@ -2,6 +2,8 @@ #include #include +#include +#include namespace Pinetime { namespace Controllers { @@ -27,7 +29,7 @@ namespace Pinetime { bool ClearNewNotificationFlag(); bool AreNewNotificationsAvailable(); - static constexpr uint8_t MaximumMessageSize() { return MessageSize; }; + static constexpr size_t MaximumMessageSize() { return MessageSize; }; size_t NbNotifications() const; private: diff --git a/src/components/ble/ServiceDiscovery.cpp b/src/components/ble/ServiceDiscovery.cpp index 4b29d89c..4d37b8bd 100644 --- a/src/components/ble/ServiceDiscovery.cpp +++ b/src/components/ble/ServiceDiscovery.cpp @@ -1,5 +1,7 @@ -#include #include "ServiceDiscovery.h" +#include +#include "BleClient.h" + using namespace Pinetime::Controllers; ServiceDiscovery::ServiceDiscovery(std::array&& clients) : clients{clients} { diff --git a/src/components/ble/ServiceDiscovery.h b/src/components/ble/ServiceDiscovery.h index c86fc4ec..0b26bd1d 100644 --- a/src/components/ble/ServiceDiscovery.h +++ b/src/components/ble/ServiceDiscovery.h @@ -1,12 +1,12 @@ #pragma once #include -#include -#include -#include "BleClient.h" +#include namespace Pinetime { namespace Controllers { + class BleClient; + class ServiceDiscovery { public: ServiceDiscovery(std::array&& bleClients); diff --git a/src/components/brightness/BrightnessController.cpp b/src/components/brightness/BrightnessController.cpp index c8825d68..78c461d7 100644 --- a/src/components/brightness/BrightnessController.cpp +++ b/src/components/brightness/BrightnessController.cpp @@ -1,5 +1,5 @@ -#include #include "BrightnessController.h" +#include using namespace Pinetime::Controllers; diff --git a/src/components/firmwarevalidator/FirmwareValidator.cpp b/src/components/firmwarevalidator/FirmwareValidator.cpp index 244d5c06..48f98550 100644 --- a/src/components/firmwarevalidator/FirmwareValidator.cpp +++ b/src/components/firmwarevalidator/FirmwareValidator.cpp @@ -1,8 +1,8 @@ -#include -#include - #include "FirmwareValidator.h" +#include +#include "drivers/InternalFlash.h" + using namespace Pinetime::Controllers; bool FirmwareValidator::IsValidated() const { diff --git a/src/components/gfx/Gfx.cpp b/src/components/gfx/Gfx.cpp index 3c5dbfb7..b9b94013 100644 --- a/src/components/gfx/Gfx.cpp +++ b/src/components/gfx/Gfx.cpp @@ -1,8 +1,5 @@ -#include -#include -#include #include "Gfx.h" -#include "../../drivers/St7789.h" +#include "drivers/St7789.h" using namespace Pinetime::Components; Gfx::Gfx(Pinetime::Drivers::St7789 &lcd) : lcd{lcd} { diff --git a/src/components/gfx/Gfx.h b/src/components/gfx/Gfx.h index 091f06f5..35341e01 100644 --- a/src/components/gfx/Gfx.h +++ b/src/components/gfx/Gfx.h @@ -1,10 +1,10 @@ #pragma once -#include -#include -#include #include +#include #include - +#include +#include +#include "drivers/BufferProvider.h" namespace Pinetime { namespace Drivers { diff --git a/src/logging/NrfLogger.cpp b/src/logging/NrfLogger.cpp index 0d95c06a..9f7624be 100644 --- a/src/logging/NrfLogger.cpp +++ b/src/logging/NrfLogger.cpp @@ -1,9 +1,8 @@ +#include "NrfLogger.h" + +#include #include #include -#include -#include -#include -#include "NrfLogger.h" using namespace Pinetime::Logging; diff --git a/src/logging/NrfLogger.h b/src/logging/NrfLogger.h index cb7089f2..fb68b919 100644 --- a/src/logging/NrfLogger.h +++ b/src/logging/NrfLogger.h @@ -1,6 +1,9 @@ #pragma once #include "Logger.h" +#include +#include + namespace Pinetime { namespace Logging{ class NrfLogger : public Logger { diff --git a/src/main.cpp b/src/main.cpp index 45aac6de..35057045 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,32 +1,44 @@ +// nrf +#include +#include +#include +#include +#include +#include + +// nimble +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max +#include +#include +#include +#include +#include +#include +#include +#include +#include +#undef max +#undef min + +// FreeRTOS #include #include #include -#include -#include -#include -#include -#include -#include -#include "displayapp/DisplayApp.h" -#include -#include "components/datetime/DateTimeController.h" + #include "components/battery/BatteryController.h" #include "components/ble/BleController.h" #include "components/ble/NotificationManager.h" -#include -#include -#include +#include "components/datetime/DateTimeController.h" +#include "displayapp/DisplayApp.h" #include "displayapp/LittleVgl.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include "drivers/Spi.h" +#include "drivers/SpiMaster.h" +#include "drivers/SpiNorFlash.h" +#include "drivers/St7789.h" +#include "drivers/TwiMaster.h" +#include "drivers/Cst816s.h" +#include "systemtask/SystemTask.h" #if NRF_LOG_ENABLED #include "logging/NrfLogger.h" diff --git a/src/main.h b/src/main.h index b0a8a57e..2ff32b8f 100644 --- a/src/main.h +++ b/src/main.h @@ -2,6 +2,7 @@ #include #include +#include void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action); void DebounceTimerCallback(TimerHandle_t xTimer); \ No newline at end of file diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index dac4ce29..81e7323a 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -1,19 +1,27 @@ -#include -#include -#include -#include "displayapp/LittleVgl.h" -#include -#include "components/ble/NotificationManager.h" +#include "SystemTask.h" +#define min // workaround: nimble's min/max macros conflict with libstdc++ +#define max +#include #include #include -#include "SystemTask.h" -#include -#include #include -#include +#include +#undef max +#undef min +#include +#include +#include + +#include "BootloaderVersion.h" +#include "components/ble/BleController.h" +#include "displayapp/LittleVgl.h" +#include "drivers/Cst816s.h" +#include "drivers/St7789.h" +#include "drivers/InternalFlash.h" +#include "drivers/SpiMaster.h" +#include "drivers/SpiNorFlash.h" +#include "drivers/TwiMaster.h" #include "main.h" -#include "components/ble/NimbleController.h" -#include "../BootloaderVersion.h" using namespace Pinetime::System; diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index 6ef0cfbf..fe6e7cbe 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -4,17 +4,23 @@ #include #include -#include -#include -#include "components/battery/BatteryController.h" -#include "displayapp/DisplayApp.h" -#include -#include +#include + #include "SystemMonitor.h" +#include "components/battery/BatteryController.h" #include "components/ble/NimbleController.h" -#include "timers.h" +#include "components/ble/NotificationManager.h" +#include "displayapp/DisplayApp.h" +#include "drivers/Watchdog.h" namespace Pinetime { + namespace Drivers { + class Cst816S; + class SpiMaster; + class SpiNorFlash; + class St7789; + class TwiMaster; + } namespace System { class SystemTask { public: