Author: Finlay Davidson <finlay.davidson@coderclass.nl>
Format header files In my PR updating clang-format, I forgot to also format the headers.
src/components/alarm/AlarmController.h | 6 +++++ src/components/battery/BatteryController.h | 1 src/components/ble/AlertNotificationService.h | 1 src/components/ble/BatteryInformationService.h | 2 + src/components/ble/BleController.h | 8 ++++++ src/components/ble/CurrentTimeClient.h | 3 ++ src/components/ble/DfuService.h | 4 +++ src/components/ble/FSService.h | 6 +++++ src/components/ble/HeartRateService.h | 2 + src/components/ble/ImmediateAlertService.h | 2 + src/components/ble/MotionService.h | 2 + src/components/ble/MusicService.h | 1 src/components/ble/NavigationService.h | 1 src/components/ble/NimbleController.h | 3 ++ src/components/ble/NotificationManager.h | 2 + src/components/ble/weather/WeatherService.h | 1 src/components/datetime/DateTimeController.h | 10 ++++++++ src/components/fs/FS.h | 1 src/components/gfx/Gfx.h | 3 ++ src/components/heartrate/HeartRateController.h | 4 +++ src/components/motion/MotionController.h | 5 ++++ src/components/settings/Settings.h | 13 +++++++++++ src/components/timer/TimerController.h | 1 src/displayapp/DisplayApp.h | 2 + src/displayapp/DisplayAppRecovery.h | 3 ++ src/displayapp/DummyLittleVgl.h | 5 ++++ src/displayapp/LittleVgl.h | 2 + src/displayapp/Messages.h | 1 src/displayapp/screens/CheckboxList.h | 1 src/displayapp/screens/FirmwareUpdate.h | 1 src/displayapp/screens/HeartRate.h | 1 src/displayapp/screens/InfiniPaint.h | 1 src/displayapp/screens/Notifications.h | 3 ++ src/displayapp/screens/Paddle.h | 1 src/displayapp/screens/Screen.h | 7 +++++ src/displayapp/screens/ScreenList.h | 1 src/displayapp/screens/Twos.h | 1 src/displayapp/screens/WatchFaceAnalog.h | 1 src/displayapp/screens/WatchFaceInfineat.h | 1 src/displayapp/screens/settings/SettingChimes.h | 1 src/displayapp/screens/settings/SettingShakeThreshold.h | 1 src/displayapp/screens/settings/SettingTimeFormat.h | 1 src/displayapp/screens/settings/SettingWakeUp.h | 1 src/displayapp/widgets/StatusIcons.h | 2 + src/drivers/Bma421.h | 3 ++ src/drivers/Cst816s.h | 3 ++ src/drivers/SpiMaster.h | 1 src/drivers/SpiNorFlash.h | 1 src/drivers/St7789.h | 1 src/drivers/Watchdog.h | 3 ++ src/heartratetask/HeartRateTask.h | 2 + src/logging/DummyLogger.h | 1 src/systemtask/Messages.h | 1 src/systemtask/SystemTask.h | 3 ++ src/touchhandler/TouchHandler.h | 5 ++++
diff --git a/src/components/alarm/AlarmController.h b/src/components/alarm/AlarmController.h index 91f60f5ab241d54f524d8c7421c6db7f491f9096..8ac0de9af1776aee242ddb0257c50adb86ef15de 100644 --- a/src/components/alarm/AlarmController.h +++ b/src/components/alarm/AlarmController.h @@ -26,6 +26,7 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class AlarmController { public: @@ -40,18 +41,23 @@ uint32_t SecondsToAlarm() const; void StopAlerting(); enum class AlarmState { Not_Set, Set, Alerting }; enum class RecurType { None, Daily, Weekdays }; + uint8_t Hours() const { return hours; } + uint8_t Minutes() const { return minutes; } + AlarmState State() const { return state; } + RecurType Recurrence() const { return recurrence; } + void SetRecurrence(RecurType recurType) { recurrence = recurType; } diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index 627ca7d41da417144dd9368b9bb7fe18da0b64f1..b47b77cce977dd8a4667b5354612976809c45c90 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -17,6 +17,7 @@ uint8_t PercentRemaining() const { return percentRemaining; } + bool BatteryIsLow() const { return percentRemaining <= lowBatteryThreshold; } diff --git a/src/components/ble/AlertNotificationService.h b/src/components/ble/AlertNotificationService.h index 5c7d428ceccb3eba3a38e572927fdbfc74c56ffb..7f5273ac49614a9407b04a28c56dfaec98b64aff 100644 --- a/src/components/ble/AlertNotificationService.h +++ b/src/components/ble/AlertNotificationService.h @@ -16,6 +16,7 @@ namespace System { class SystemTask; } + namespace Controllers { class NotificationManager; diff --git a/src/components/ble/BatteryInformationService.h b/src/components/ble/BatteryInformationService.h index c6fc52e4fe8135b5d97312ba2e987c6cd78462ed..cc4d260482974332a300a1f80027dc8097626150 100644 --- a/src/components/ble/BatteryInformationService.h +++ b/src/components/ble/BatteryInformationService.h @@ -9,8 +9,10 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class Battery; + class BatteryInformationService { public: BatteryInformationService(Controllers::Battery& batteryController); diff --git a/src/components/ble/BleController.h b/src/components/ble/BleController.h index 675ede2d63b53d2a8a3f6a5ec4c01112c26cbc93..de0a1bc2e2354e36ea3acd735b02722e2ef0ba9f 100644 --- a/src/components/ble/BleController.h +++ b/src/components/ble/BleController.h @@ -24,6 +24,7 @@ void StartFirmwareUpdate(); void StopFirmwareUpdate(); void FirmwareUpdateTotalBytes(uint32_t totalBytes); void FirmwareUpdateCurrentBytes(uint32_t currentBytes); + void State(FirmwareUpdateStates state) { firmwareUpdateState = state; } @@ -31,12 +32,15 @@ bool IsFirmwareUpdating() const { return isFirmwareUpdating; } + uint32_t FirmwareUpdateTotalBytes() const { return firmwareUpdateTotalBytes; } + uint32_t FirmwareUpdateCurrentBytes() const { return firmwareUpdateCurrentBytes; } + FirmwareUpdateStates State() const { return firmwareUpdateState; } @@ -44,15 +48,19 @@ void Address(BleAddress&& addr) { address = addr; } + const BleAddress& Address() const { return address; } + void AddressType(AddressTypes t) { addressType = t; } + void SetPairingKey(uint32_t k) { pairingKey = k; } + uint32_t GetPairingKey() const { return pairingKey; } diff --git a/src/components/ble/CurrentTimeClient.h b/src/components/ble/CurrentTimeClient.h index c718d2d9d49bc47650c10ab08983f6447904a8b8..0a3a8735dc47d69170b3699f993d467db5b16078 100644 --- a/src/components/ble/CurrentTimeClient.h +++ b/src/components/ble/CurrentTimeClient.h @@ -19,12 +19,15 @@ void Reset(); bool OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error* error, const ble_gatt_svc* service); int OnCharacteristicDiscoveryEvent(uint16_t conn_handle, const ble_gatt_error* error, const ble_gatt_chr* characteristic); int OnCurrentTimeReadResult(uint16_t conn_handle, const ble_gatt_error* error, const ble_gatt_attr* attribute); + static constexpr const ble_uuid16_t* Uuid() { return &CurrentTimeClient::ctsServiceUuid; } + static constexpr const ble_uuid16_t* CurrentTimeCharacteristicUuid() { return &CurrentTimeClient::currentTimeCharacteristicUuid; } + void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) override; private: diff --git a/src/components/ble/DfuService.h b/src/components/ble/DfuService.h index 4708a4a607e5af55b0167a380b4a6469f6ec0cc7..b56911b905b37f3f7996295cee66424a13fc7b98 100644 --- a/src/components/ble/DfuService.h +++ b/src/components/ble/DfuService.h @@ -13,9 +13,11 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Drivers { class SpiNorFlash; } + namespace Controllers { class Ble; @@ -46,10 +48,12 @@ public: void OnNotificationTimer(); void Reset(); }; + class DfuImage { public: DfuImage(Pinetime::Drivers::SpiNorFlash& spiNorFlash) : spiNorFlash {spiNorFlash} { } + void Init(size_t chunkSize, size_t totalSize, uint16_t expectedCrc); void Erase(); void Append(uint8_t* data, size_t size); diff --git a/src/components/ble/FSService.h b/src/components/ble/FSService.h index 828925a86f3f1cdafcfa1f302e62c8c2af2daad1..b2299623a72fdb2b22549f154e6443479a5b1a55 100644 --- a/src/components/ble/FSService.h +++ b/src/components/ble/FSService.h @@ -11,8 +11,10 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class Ble; + class FSService { public: FSService(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::FS& fs); @@ -71,6 +73,7 @@ }; FSState state; char filepath[maxpathlen]; // TODO ..ugh fixed filepath len int fileSize; + using ReadHeader = struct __attribute__((packed)) { commands command; uint8_t padding; @@ -89,6 +92,7 @@ uint32_t totallen; uint32_t chunklen; uint8_t chunk[]; }; + using ReadPacing = struct __attribute__((packed)) { commands command; uint8_t status; @@ -124,6 +128,7 @@ uint32_t offset; uint32_t dataSize; uint8_t data[]; }; + using ListDirHeader = struct __attribute__((packed)) { commands command; uint8_t padding; @@ -171,6 +176,7 @@ using DelResponse = struct __attribute__((packed)) { commands command; uint8_t status; }; + using MoveHeader = struct __attribute__((packed)) { commands command; uint8_t padding; diff --git a/src/components/ble/HeartRateService.h b/src/components/ble/HeartRateService.h index 4e4a5a424bafb4277ce30d0de1504c6bf1ecc31a..a60c12f672d79ba3ba142af87d462fbbadb04cf8 100644 --- a/src/components/ble/HeartRateService.h +++ b/src/components/ble/HeartRateService.h @@ -10,8 +10,10 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class HeartRateController; + class HeartRateService { public: HeartRateService(Pinetime::System::SystemTask& system, Controllers::HeartRateController& heartRateController); diff --git a/src/components/ble/ImmediateAlertService.h b/src/components/ble/ImmediateAlertService.h index 1f778acd06325ccd88f53dc1f19c4fa22f089cfc..c54b63ec3c1484a0122c5ca1de751b1a0dd1894e 100644 --- a/src/components/ble/ImmediateAlertService.h +++ b/src/components/ble/ImmediateAlertService.h @@ -9,8 +9,10 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class NotificationManager; + class ImmediateAlertService { public: enum class Levels : uint8_t { NoAlert = 0, MildAlert = 1, HighAlert = 2 }; diff --git a/src/components/ble/MotionService.h b/src/components/ble/MotionService.h index 1b4ac0a37e86e680b9b6653edb4bc8a9abba34db..c9483766f23f9f3e586011bc1c237f64c6bb373e 100644 --- a/src/components/ble/MotionService.h +++ b/src/components/ble/MotionService.h @@ -10,8 +10,10 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class MotionController; + class MotionService { public: MotionService(Pinetime::System::SystemTask& system, Controllers::MotionController& motionController); diff --git a/src/components/ble/MusicService.h b/src/components/ble/MusicService.h index 047d0d262ec6de7b15af1106b528411de3079e5b..9f1042cc09ecb0f4b088c6b4f49a2a9c601c3a33 100644 --- a/src/components/ble/MusicService.h +++ b/src/components/ble/MusicService.h @@ -30,6 +30,7 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class MusicService { public: diff --git a/src/components/ble/NavigationService.h b/src/components/ble/NavigationService.h index c0c77f35e3483a73ea436d1e0dac5de5e4874fd9..78e7b888d7df90d487866fed8d7c76dd284093ce 100644 --- a/src/components/ble/NavigationService.h +++ b/src/components/ble/NavigationService.h @@ -30,6 +30,7 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class NavigationService { diff --git a/src/components/ble/NimbleController.h b/src/components/ble/NimbleController.h index 000231fe71149f1a2238ac1456efc06f0088af04..8f1dfed7cda83e8ad6e6de5f62c4addf81857b77 100644 --- a/src/components/ble/NimbleController.h +++ b/src/components/ble/NimbleController.h @@ -58,12 +58,15 @@ Pinetime::Controllers::MusicService& music() { return musicService; }; + Pinetime::Controllers::NavigationService& navigation() { return navService; }; + Pinetime::Controllers::AlertNotificationService& alertService() { return anService; }; + Pinetime::Controllers::WeatherService& weather() { return weatherService; }; diff --git a/src/components/ble/NotificationManager.h b/src/components/ble/NotificationManager.h index 4c199dbf50931f95938df49519b0c2b8f2dbb8cd..09b5a5610edc67ad9bbf67f00a8e51884c4375d1 100644 --- a/src/components/ble/NotificationManager.h +++ b/src/components/ble/NotificationManager.h @@ -51,9 +51,11 @@ static constexpr size_t MaximumMessageSize() { return MessageSize; }; + bool IsEmpty() const { return size == 0; } + size_t NbNotifications() const; private: diff --git a/src/components/ble/weather/WeatherService.h b/src/components/ble/weather/WeatherService.h index e37417da972b1d3b4953bce3aa9677e142a350c0..786cad89997c281b09577dcaece46a116f2b83ab 100644 --- a/src/components/ble/weather/WeatherService.h +++ b/src/components/ble/weather/WeatherService.h @@ -39,6 +39,7 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class WeatherService { diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h index 24a3ed4087ceefc40c3d39542009764763d02498..57ee35101177debfe746fd39e99c7b47fcb48e4f 100644 --- a/src/components/datetime/DateTimeController.h +++ b/src/components/datetime/DateTimeController.h @@ -9,6 +9,7 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class DateTime { public: @@ -51,24 +52,31 @@ */ void SetTimeZone(int8_t timezone, int8_t dst); void UpdateTime(uint32_t systickCounter); + uint16_t Year() const { return year; } + Months Month() const { return month; } + uint8_t Day() const { return day; } + Days DayOfWeek() const { return dayOfWeek; } + uint8_t Hours() const { return hour; } + uint8_t Minutes() const { return minute; } + uint8_t Seconds() const { return second; } @@ -117,9 +125,11 @@ std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const { return currentDateTime; } + std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> UTCDateTime() const { return currentDateTime - std::chrono::seconds((tzOffset + dstOffset) * 15 * 60); } + std::chrono::seconds Uptime() const { return uptime; } diff --git a/src/components/fs/FS.h b/src/components/fs/FS.h index 87fcdc23f44d7d8eb165542e484cd77b6973de30..9730e4749275ddb522df5dcdfcae0ff1eef7a57f 100644 --- a/src/components/fs/FS.h +++ b/src/components/fs/FS.h @@ -35,6 +35,7 @@ static size_t getSize() { return size; } + static size_t getBlockSize() { return blockSize; } diff --git a/src/components/gfx/Gfx.h b/src/components/gfx/Gfx.h index 54c4a8b7788b78debe51c52fb5f01571cc9e855e..17c248f7366963dcdef08d3a24089d0990f907f6 100644 --- a/src/components/gfx/Gfx.h +++ b/src/components/gfx/Gfx.h @@ -10,6 +10,7 @@ namespace Pinetime { namespace Drivers { class St7789; } + namespace Components { class Gfx : public Pinetime::Drivers::BufferProvider { public: @@ -33,9 +34,11 @@ static constexpr uint8_t width = 240; static constexpr uint8_t height = 240; enum class Action { None, FillRectangle, DrawChar }; + struct State { State() : busy {false}, action {Action::None}, remainingIterations {0}, currentIteration {0} { } + volatile bool busy; volatile Action action; volatile uint16_t remainingIterations; diff --git a/src/components/heartrate/HeartRateController.h b/src/components/heartrate/HeartRateController.h index a63f1a70c3d601f3864befe796003e351fb413b9..f66c79f8304b26cfe6846aa5cddadee986b81d04 100644 --- a/src/components/heartrate/HeartRateController.h +++ b/src/components/heartrate/HeartRateController.h @@ -7,9 +7,11 @@ namespace Pinetime { namespace Applications { class HeartRateTask; } + namespace System { class SystemTask; } + namespace Controllers { class HeartRateController { public: @@ -21,9 +23,11 @@ void Stop(); void Update(States newState, uint8_t heartRate); void SetHeartRateTask(Applications::HeartRateTask* task); + States State() const { return state; } + uint8_t HeartRate() const { return heartRate; } diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index f80b11b99406d7f7b9e07aaf9d5c176c3ea9889f..857bd45af7052c334b62d57ad9c048c82cf2a245 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -19,12 +19,15 @@ int16_t X() const { return x; } + int16_t Y() const { return y; } + int16_t Z() const { return z; } + uint32_t NbSteps() const { return nbSteps; } @@ -32,6 +35,7 @@ void ResetTrip() { currentTripSteps = 0; } + uint32_t GetTripSteps() const { return currentTripSteps; } @@ -40,6 +44,7 @@ bool Should_ShakeWake(uint16_t thresh); bool Should_RaiseWake(bool isSleeping); int32_t currentShakeSpeed(); void IsSensorOk(bool isOk); + bool IsSensorOk() const { return isSensorOk; } diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 93f861f3818a43241ecf2460fe0709cfcbf3a6c6..d1e71656c962e66660554d15422d0ab9760bb819 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -45,6 +45,7 @@ Colors ColorBar = Colors::Teal; Colors ColorBG = Colors::Black; PTSGaugeStyle gaugeStyle = PTSGaugeStyle::Full; }; + struct WatchFaceInfineat { bool showSideCover = true; int colorIndex = 0; @@ -66,6 +67,7 @@ settingsChanged = true; } settings.clockFace = face; }; + uint8_t GetClockFace() const { return settings.clockFace; }; @@ -76,6 +78,7 @@ settingsChanged = true; } settings.chimesOption = chimeOption; }; + ChimesOption GetChimeOption() const { return settings.chimesOption; }; @@ -85,6 +88,7 @@ if (colorTime != settings.PTS.ColorTime) settingsChanged = true; settings.PTS.ColorTime = colorTime; }; + Colors GetPTSColorTime() const { return settings.PTS.ColorTime; }; @@ -94,6 +98,7 @@ if (colorBar != settings.PTS.ColorBar) settingsChanged = true; settings.PTS.ColorBar = colorBar; }; + Colors GetPTSColorBar() const { return settings.PTS.ColorBar; }; @@ -103,6 +108,7 @@ if (colorBG != settings.PTS.ColorBG) settingsChanged = true; settings.PTS.ColorBG = colorBG; }; + Colors GetPTSColorBG() const { return settings.PTS.ColorBG; }; @@ -113,6 +119,7 @@ settings.watchFaceInfineat.showSideCover = show; settingsChanged = true; } }; + bool GetInfineatShowSideCover() const { return settings.watchFaceInfineat.showSideCover; }; @@ -123,6 +130,7 @@ settings.watchFaceInfineat.colorIndex = index; settingsChanged = true; } }; + int GetInfineatColorIndex() const { return settings.watchFaceInfineat.colorIndex; }; @@ -132,6 +140,7 @@ if (gaugeStyle != settings.PTS.gaugeStyle) settingsChanged = true; settings.PTS.gaugeStyle = gaugeStyle; }; + PTSGaugeStyle GetPTSGaugeStyle() const { return settings.PTS.gaugeStyle; }; @@ -147,6 +156,7 @@ void SetSettingsMenu(uint8_t menu) { settingsMenu = menu; }; + uint8_t GetSettingsMenu() const { return settingsMenu; }; @@ -157,6 +167,7 @@ settingsChanged = true; } settings.clockType = clocktype; }; + ClockType GetClockType() const { return settings.clockType; }; @@ -167,6 +178,7 @@ settingsChanged = true; } settings.notificationStatus = status; }; + Notification GetNotificationStatus() const { return settings.notificationStatus; }; @@ -255,6 +267,7 @@ private: Pinetime::Controllers::FS& fs; static constexpr uint32_t settingsVersion = 0x0004; + struct SettingsData { uint32_t version = settingsVersion; uint32_t stepsGoal = 10000; diff --git a/src/components/timer/TimerController.h b/src/components/timer/TimerController.h index 93d8afc6085059ed44d0185741ca3a98aa5302e0..20f07e82105c49848f0fd22afe1d51ad1ae2f322 100644 --- a/src/components/timer/TimerController.h +++ b/src/components/timer/TimerController.h @@ -7,6 +7,7 @@ namespace Pinetime { namespace System { class SystemTask; } + namespace Controllers { class TimerController { diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 3c1829d5185a5b0b1aca2aabaea9500b3873b95e..c1d04cc94c62eb9a9162ff0c5d73408f35bd29c3 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -29,6 +29,7 @@ class St7789; class Cst816S; class WatchdogView; } + namespace Controllers { class Settings; class Battery; @@ -43,6 +44,7 @@ namespace System { class SystemTask; }; + namespace Applications { class DisplayApp { public: diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h index 7d4f0fd0c02ecc6587d5aaf51042741248f0fdf8..97aaca8812d236112772a47a178fb0f07f87a91b 100644 --- a/src/displayapp/DisplayAppRecovery.h +++ b/src/displayapp/DisplayAppRecovery.h @@ -22,6 +22,7 @@ class St7789; class Cst816S; class WatchdogView; } + namespace Controllers { class Settings; class Battery; @@ -63,9 +64,11 @@ Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::TouchHandler& touchHandler, Pinetime::Controllers::FS& filesystem); void Start(); + void Start(Pinetime::System::BootErrors) { Start(); }; + void PushMessage(Pinetime::Applications::Display::Messages msg); void Register(Pinetime::System::SystemTask* systemTask); diff --git a/src/displayapp/DummyLittleVgl.h b/src/displayapp/DummyLittleVgl.h index 05355a973084117774693f58d43faf245236672b..7a8ae99984b806bd3fa3ca79cf66c6194f0e69cb 100644 --- a/src/displayapp/DummyLittleVgl.h +++ b/src/displayapp/DummyLittleVgl.h @@ -11,6 +11,7 @@ namespace Components { class LittleVgl { public: enum class FullRefreshDirections { None, Up, Down }; + LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel) { } @@ -24,13 +25,17 @@ } void FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { } + bool GetTouchPadInfo(lv_indev_data_t* ptr) { return false; } + void SetFullRefresh(FullRefreshDirections direction) { } + void SetNewTapEvent(uint16_t x, uint16_t y) { } + void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) { } }; diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 45826165339edf687912c9d8ec5cbcd70abb6b86..aedb69d8ccb57e24509347cda4ad2e1813f2d6a2 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -52,9 +52,11 @@ bool fullRefresh = false; static constexpr uint8_t nbWriteLines = 4; static constexpr uint16_t totalNbLines = 320; static constexpr uint16_t visibleNbLines = 240; + static constexpr uint8_t MaxScrollOffset() { return LV_VER_RES_MAX - nbWriteLines; } + FullRefreshDirections scrollDirection = FullRefreshDirections::None; uint16_t writeOffset = 0; uint16_t scrollOffset = 0; diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h index 58df45565e3dae131b46e0983cc72993c1f77592..afa7709a9d1e7b1831bb53513f68841fc4adde66 100644 --- a/src/displayapp/Messages.h +++ b/src/displayapp/Messages.h @@ -1,5 +1,6 @@ #pragma once #include <cstdint> + namespace Pinetime { namespace Applications { namespace Display { diff --git a/src/displayapp/screens/CheckboxList.h b/src/displayapp/screens/CheckboxList.h index 48125d4b319e478c241b5480fba2d55544f28fcc..359b835e1dbd9a4dafeb7d1272a3e429fb0e842e 100644 --- a/src/displayapp/screens/CheckboxList.h +++ b/src/displayapp/screens/CheckboxList.h @@ -15,6 +15,7 @@ namespace Screens { class CheckboxList : public Screen { public: static constexpr size_t MaxItems = 4; + struct Item { const char* name; bool enabled; diff --git a/src/displayapp/screens/FirmwareUpdate.h b/src/displayapp/screens/FirmwareUpdate.h index 5156b7eab41fa9b40db55d7f01768e5717af70fd..cc3b09b22aa447b1095fba9a6efd162a51cf5ac7 100644 --- a/src/displayapp/screens/FirmwareUpdate.h +++ b/src/displayapp/screens/FirmwareUpdate.h @@ -8,6 +8,7 @@ namespace Pinetime { namespace Controllers { class Ble; } + namespace Applications { namespace Screens { diff --git a/src/displayapp/screens/HeartRate.h b/src/displayapp/screens/HeartRate.h index 2ad003517b7bf6e82a53949db99cb2e3d66a2c2a..d68133adc3bfa0b182e8e8a821d6069a1dd65c9f 100644 --- a/src/displayapp/screens/HeartRate.h +++ b/src/displayapp/screens/HeartRate.h @@ -11,6 +11,7 @@ namespace Pinetime { namespace Controllers { class HeartRateController; } + namespace Applications { namespace Screens { diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h index 8c427402b08b40f930a35fcafc4dac68dee5345b..a6b6eb1863d7304b4ede39d0ae619698ac274f07 100644 --- a/src/displayapp/screens/InfiniPaint.h +++ b/src/displayapp/screens/InfiniPaint.h @@ -10,6 +10,7 @@ namespace Pinetime { namespace Components { class LittleVgl; } + namespace Applications { namespace Screens { diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index bdaac7bb14b73b1ca8ffd2c0337cb23ca5156b88..a4d2709b50f40863e396d323e3b02ab56f000152 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -13,6 +13,7 @@ namespace Pinetime { namespace Controllers { class AlertNotificationService; } + namespace Applications { namespace Screens { @@ -45,9 +46,11 @@ uint8_t notifNb, Pinetime::Controllers::AlertNotificationService& alertNotificationService, Pinetime::Controllers::MotorController& motorController); ~NotificationItem(); + bool IsRunning() const { return running; } + void OnCallButtonEvent(lv_obj_t*, lv_event_t event); private: diff --git a/src/displayapp/screens/Paddle.h b/src/displayapp/screens/Paddle.h index 3a30eee60e515d8dc88fe07b092fd1cc0fca745a..d62550c4ba061d72c216215258d87efea7cf8ba5 100644 --- a/src/displayapp/screens/Paddle.h +++ b/src/displayapp/screens/Paddle.h @@ -8,6 +8,7 @@ namespace Pinetime { namespace Components { class LittleVgl; } + namespace Applications { namespace Screens { diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h index e72a2368fbddcfec2c83158b1eb7732be72b6848..a2452da5e18254598033900ba9fbd7e733120aba 100644 --- a/src/displayapp/screens/Screen.h +++ b/src/displayapp/screens/Screen.h @@ -7,13 +7,16 @@ namespace Pinetime { namespace Applications { class DisplayApp; + namespace Screens { template <class T> class DirtyValue { public: DirtyValue() = default; // Use NSDMI + explicit DirtyValue(T const& v) : value {v} { } // Use MIL and const-lvalue-ref + bool IsUpdated() { if (this->isUpdated) { this->isUpdated = false; @@ -21,10 +24,12 @@ return true; } return false; } + T const& Get() { this->isUpdated = false; return value; } // never expose a non-const lvalue-ref + DirtyValue& operator=(const T& other) { if (this->value != other) { this->value = other; @@ -46,6 +51,7 @@ public: explicit Screen(DisplayApp* app) : app {app} { } + virtual ~Screen() = default; static void RefreshTaskCallback(lv_task_t* task); @@ -64,6 +70,7 @@ // Returning true will cancel lvgl tap virtual bool OnTouchEvent(TouchEvents event) { return false; } + virtual bool OnTouchEvent(uint16_t x, uint16_t y) { return false; } diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h index ad882948de5465c17ac29f59e2c7903183397c53..6c9a221872906ef033b84f5c306905671591437b 100644 --- a/src/displayapp/screens/ScreenList.h +++ b/src/displayapp/screens/ScreenList.h @@ -11,6 +11,7 @@ namespace Applications { namespace Screens { enum class ScreenListModes { UpDown, RightLeft, LongPress }; + template <size_t N> class ScreenList : public Screen { public: ScreenList(DisplayApp* app, diff --git a/src/displayapp/screens/Twos.h b/src/displayapp/screens/Twos.h index da935724e5d9e98a9487f8b8d62835bb4b9f9e73..150175818428452d34728158b3492328e75c052c 100644 --- a/src/displayapp/screens/Twos.h +++ b/src/displayapp/screens/Twos.h @@ -9,6 +9,7 @@ struct TwosTile { bool merged = false; unsigned int value = 0; }; + namespace Screens { class Twos : public Screen { public: diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index 04d9e7117ce4b1ac6522eacaa53b39afda674207..6e4e88a3967fcf86986c909972779e26402b8f10 100644 --- a/src/displayapp/screens/WatchFaceAnalog.h +++ b/src/displayapp/screens/WatchFaceAnalog.h @@ -18,6 +18,7 @@ class Battery; class Ble; class NotificationManager; } + namespace Applications { namespace Screens { diff --git a/src/displayapp/screens/WatchFaceInfineat.h b/src/displayapp/screens/WatchFaceInfineat.h index 6c3c30bace8bd4ab01d81a6009de84c8f0b68056..2dbb0ab3423da26d330640fbaa42b2f4d446aeae 100644 --- a/src/displayapp/screens/WatchFaceInfineat.h +++ b/src/displayapp/screens/WatchFaceInfineat.h @@ -118,6 +118,7 @@ lv_obj_t* lblToggle; static constexpr int nLines = 9; static constexpr int nColors = 7; // must match number of colors in InfineatColors + struct InfineatColors { int orange[nLines] = {0xfd872b, 0xdb3316, 0x6f1000, 0xfd7a0a, 0xffffff, 0xffffff, 0xffffff, 0xe85102, 0xea1c00}; int blue[nLines] = {0xe7f8ff, 0x2232d0, 0x182a8b, 0xe7f8ff, 0xffffff, 0xffffff, 0xffffff, 0x5991ff, 0x1636ff}; diff --git a/src/displayapp/screens/settings/SettingChimes.h b/src/displayapp/screens/settings/SettingChimes.h index 3054d06b724f91f1a5e5262f22499dc817e29782..3146503b186dfb421344bf994498d18cb1bb6ef3 100644 --- a/src/displayapp/screens/settings/SettingChimes.h +++ b/src/displayapp/screens/settings/SettingChimes.h @@ -23,6 +23,7 @@ struct Option { Controllers::Settings::ChimesOption chimesOption; const char* name; }; + static constexpr std::array<Option, 3> options = {{{Controllers::Settings::ChimesOption::None, "Off"}, {Controllers::Settings::ChimesOption::Hours, "Every hour"}, {Controllers::Settings::ChimesOption::HalfHours, "Every 30 mins"}}}; diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.h b/src/displayapp/screens/settings/SettingShakeThreshold.h index 43319468b74c58941e4b4e2cd0be9df8d5904562..d0979fa69825dd4de83a10dab3190dcbed5c50bf 100644 --- a/src/displayapp/screens/settings/SettingShakeThreshold.h +++ b/src/displayapp/screens/settings/SettingShakeThreshold.h @@ -6,6 +6,7 @@ #include "components/settings/Settings.h" #include "displayapp/screens/Screen.h" #include <components/motion/MotionController.h> #include "systemtask/SystemTask.h" + namespace Pinetime { namespace Applications { diff --git a/src/displayapp/screens/settings/SettingTimeFormat.h b/src/displayapp/screens/settings/SettingTimeFormat.h index dc0413ec2ce8235471b652cc68a46a4507f1b95f..426dc1974b25eb8b9c417449bb6f1646e29bd4c4 100644 --- a/src/displayapp/screens/settings/SettingTimeFormat.h +++ b/src/displayapp/screens/settings/SettingTimeFormat.h @@ -24,6 +24,7 @@ struct Option { Controllers::Settings::ClockType clockType; const char* name; }; + static constexpr std::array<Option, 2> options = {{ {Controllers::Settings::ClockType::H12, "12-hour"}, {Controllers::Settings::ClockType::H24, "24-hour"}, diff --git a/src/displayapp/screens/settings/SettingWakeUp.h b/src/displayapp/screens/settings/SettingWakeUp.h index 54282f5da250f8340591231b87d2abbff2184d33..2a4e7509a5afad8474055ffa421adcc0e4f9224a 100644 --- a/src/displayapp/screens/settings/SettingWakeUp.h +++ b/src/displayapp/screens/settings/SettingWakeUp.h @@ -23,6 +23,7 @@ struct Option { Controllers::Settings::WakeUpMode wakeUpMode; const char* name; }; + Controllers::Settings& settingsController; static constexpr std::array<Option, 4> options = {{ {Controllers::Settings::WakeUpMode::SingleTap, "Single Tap"}, diff --git a/src/displayapp/widgets/StatusIcons.h b/src/displayapp/widgets/StatusIcons.h index f4a30a800cc96bab2ed53dcd9d309392475a44be..7d9e3ae379264cc07dded8476611f20fd0cb4121 100644 --- a/src/displayapp/widgets/StatusIcons.h +++ b/src/displayapp/widgets/StatusIcons.h @@ -15,9 +15,11 @@ public: StatusIcons(Controllers::Battery& batteryController, Controllers::Ble& bleController); void Align(); void Create(); + lv_obj_t* GetObject() { return container; } + void Update(); private: diff --git a/src/drivers/Bma421.h b/src/drivers/Bma421.h index ac5c707ffc9e3a8762be5fcaa2e6ef3bee800f94..fb83251449c8c0293db939b13fb4912b4cc28ada 100644 --- a/src/drivers/Bma421.h +++ b/src/drivers/Bma421.h @@ -4,15 +4,18 @@ namespace Pinetime { namespace Drivers { class TwiMaster; + class Bma421 { public: enum class DeviceTypes : uint8_t { Unknown, BMA421, BMA425 }; + struct Values { uint32_t steps; int16_t x; int16_t y; int16_t z; }; + Bma421(TwiMaster& twiMaster, uint8_t twiAddress); Bma421(const Bma421&) = delete; Bma421& operator=(const Bma421&) = delete; diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 9d426c9db9de9e9d85e802e0742237298cad3a24..c50bb7337288abe5f0e545819f59b29d45af7f23 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -16,6 +16,7 @@ SingleTap = 0x05, DoubleTap = 0x0B, LongPress = 0x0C }; + struct TouchInfos { uint16_t x = 0; uint16_t y = 0; @@ -38,9 +39,11 @@ uint8_t GetChipId() const { return chipId; } + uint8_t GetVendorId() const { return vendorId; } + uint8_t GetFwVersion() const { return fwVersion; } diff --git a/src/drivers/SpiMaster.h b/src/drivers/SpiMaster.h index 5ea624f2553070e6378d4830089b3167e57e3d73..cba140a681f621c3c2219cdd2162ed74c755f699 100644 --- a/src/drivers/SpiMaster.h +++ b/src/drivers/SpiMaster.h @@ -14,6 +14,7 @@ enum class SpiModule : uint8_t { SPI0, SPI1 }; enum class BitOrder : uint8_t { Msb_Lsb, Lsb_Msb }; enum class Modes : uint8_t { Mode0, Mode1, Mode2, Mode3 }; enum class Frequencies : uint8_t { Freq8Mhz }; + struct Parameters { BitOrder bitOrder; Modes mode; diff --git a/src/drivers/SpiNorFlash.h b/src/drivers/SpiNorFlash.h index ad4d0907560f0ddf800540e16f444a56ec37f4dd..8a063fea73bbf0fe18917525f9672ad78d40476b 100644 --- a/src/drivers/SpiNorFlash.h +++ b/src/drivers/SpiNorFlash.h @@ -5,6 +5,7 @@ namespace Pinetime { namespace Drivers { class Spi; + class SpiNorFlash { public: explicit SpiNorFlash(Spi& spi); diff --git a/src/drivers/St7789.h b/src/drivers/St7789.h index 8c2ac0936d766b8d7144d8e52e3f0b958e13af8f..8a1bdfca98231b5e3db7b761e41d981dfb8aba3e 100644 --- a/src/drivers/St7789.h +++ b/src/drivers/St7789.h @@ -5,6 +5,7 @@ namespace Pinetime { namespace Drivers { class Spi; + class St7789 { public: explicit St7789(Spi& spi, uint8_t pinDataCommand); diff --git a/src/drivers/Watchdog.h b/src/drivers/Watchdog.h index 03807d61b21670ebd8fbd93036e87e91f5618317..22aa9df63027afa56fa58d6a23c1b827bc05d64f 100644 --- a/src/drivers/Watchdog.h +++ b/src/drivers/Watchdog.h @@ -9,9 +9,11 @@ enum class ResetReasons { ResetPin, Watchdog, SoftReset, CpuLockup, SystemOff, LpComp, DebugInterface, NFC, HardReset }; void Setup(uint8_t timeoutSeconds); void Start(); void Kick(); + ResetReasons ResetReason() const { return resetReason; } + static const char* ResetReasonToString(ResetReasons reason); private: @@ -23,6 +25,7 @@ class WatchdogView { public: WatchdogView(const Watchdog& watchdog) : watchdog {watchdog} { } + Watchdog::ResetReasons ResetReason() const { return watchdog.ResetReason(); } diff --git a/src/heartratetask/HeartRateTask.h b/src/heartratetask/HeartRateTask.h index 0796dc74dded29edc51847f27a038876a92387f4..5bbfb9fb3e7b3ab87a8f69d650f07e91bcc6a7fa 100644 --- a/src/heartratetask/HeartRateTask.h +++ b/src/heartratetask/HeartRateTask.h @@ -8,9 +8,11 @@ namespace Pinetime { namespace Drivers { class Hrs3300; } + namespace Controllers { class HeartRateController; } + namespace Applications { class HeartRateTask { public: diff --git a/src/logging/DummyLogger.h b/src/logging/DummyLogger.h index 1b050b3782029d16282bbf7823c731769cdd6391..53590b6faa3c3dd232a2bdb822a18346b466b58c 100644 --- a/src/logging/DummyLogger.h +++ b/src/logging/DummyLogger.h @@ -7,6 +7,7 @@ class DummyLogger : public Logger { public: void Init() override { } + void Resume() override { } }; diff --git a/src/systemtask/Messages.h b/src/systemtask/Messages.h index 1883c396c1409a0df5ef6f0f355c747d7184a824..b7fee8a52c8068624f65e2d9b9f804b4bc4c63e8 100644 --- a/src/systemtask/Messages.h +++ b/src/systemtask/Messages.h @@ -1,5 +1,6 @@ #pragma once #include <cstdint> + namespace Pinetime { namespace System { enum class Messages : uint8_t { diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index d1e4a004f9278bb6e70aa964dea64642eaffc855..9c43b9b22256e81ec64d7a364e3de600862920fd 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -36,6 +36,7 @@ #include "drivers/Watchdog.h" #include "systemtask/Messages.h" extern std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoInit_BackUpTime; + namespace Pinetime { namespace Drivers { class Cst816S; @@ -45,11 +46,13 @@ class St7789; class TwiMaster; class Hrs3300; } + namespace Controllers { class Battery; class TouchHandler; class ButtonHandler; } + namespace System { class SystemTask { public: diff --git a/src/touchhandler/TouchHandler.h b/src/touchhandler/TouchHandler.h index 332041e5a47b89b1443a501619edd672b52f65a0..afce2844238a3c04f3939737d986d494fe9080b2 100644 --- a/src/touchhandler/TouchHandler.h +++ b/src/touchhandler/TouchHandler.h @@ -6,9 +6,11 @@ namespace Pinetime { namespace Components { class LittleVgl; } + namespace Drivers { class Cst816S; } + namespace Controllers { class TouchHandler { public: @@ -20,12 +22,15 @@ bool IsTouching() const { return info.touching; } + uint8_t GetX() const { return info.x; } + uint8_t GetY() const { return info.y; } + Pinetime::Applications::TouchEvents GestureGet(); private: