summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-11-10 19:32:36 (GMT)
committerJF <jf@codingfield.com>2020-11-10 19:32:36 (GMT)
commit04abc91f157f5925ffa404728291a69893acf8cf (patch)
tree5c887c6d22ba8d901022ebae395a7b6c165d9dc0 /src
parent65ecb65b57bd55582c1aa1a5babd4d76df89e621 (diff)
parentf0e1f98823e41bfc2d9743fa8de70c882f26f93b (diff)
Merge branch 'develop' into master
Diffstat (limited to 'src')
-rw-r--r--src/BootloaderVersion.cpp26
-rw-r--r--src/BootloaderVersion.h12
-rw-r--r--src/CMakeLists.txt914
-rw-r--r--src/Components/Ble/AlertNotificationClient.cpp145
-rw-r--r--src/Components/Ble/CurrentTimeClient.cpp77
-rw-r--r--src/Components/Ble/MusicService.cpp129
-rw-r--r--src/Components/Ble/MusicService.h92
-rw-r--r--src/Components/Ble/NotificationManager.cpp30
-rw-r--r--src/Components/Ble/NotificationManager.h29
-rw-r--r--src/DisplayApp/Screens/InfiniPaint.h35
-rw-r--r--src/DisplayApp/Screens/Music.cpp125
-rw-r--r--src/DisplayApp/Screens/Music.h49
-rw-r--r--src/DisplayApp/Screens/Screen.h30
-rw-r--r--src/components/battery/BatteryController.cpp (renamed from src/Components/Battery/BatteryController.cpp)5
-rw-r--r--src/components/battery/BatteryController.h (renamed from src/Components/Battery/BatteryController.h)0
-rw-r--r--src/components/ble/AlertNotificationClient.cpp194
-rw-r--r--src/components/ble/AlertNotificationClient.h (renamed from src/Components/Ble/AlertNotificationClient.h)35
-rw-r--r--src/components/ble/AlertNotificationService.cpp (renamed from src/Components/Ble/AlertNotificationService.cpp)37
-rw-r--r--src/components/ble/AlertNotificationService.h (renamed from src/Components/Ble/AlertNotificationService.h)4
-rw-r--r--src/components/ble/BatteryInformationService.cpp62
-rw-r--r--src/components/ble/BatteryInformationService.h40
-rw-r--r--src/components/ble/BleClient.h12
-rw-r--r--src/components/ble/BleController.cpp (renamed from src/Components/Ble/BleController.cpp)0
-rw-r--r--src/components/ble/BleController.h (renamed from src/Components/Ble/BleController.h)0
-rw-r--r--src/components/ble/CurrentTimeClient.cpp111
-rw-r--r--src/components/ble/CurrentTimeClient.h (renamed from src/Components/Ble/CurrentTimeClient.h)20
-rw-r--r--src/components/ble/CurrentTimeService.cpp (renamed from src/Components/Ble/CurrentTimeService.cpp)0
-rw-r--r--src/components/ble/CurrentTimeService.h (renamed from src/Components/Ble/CurrentTimeService.h)3
-rw-r--r--src/components/ble/DeviceInformationService.cpp (renamed from src/Components/Ble/DeviceInformationService.cpp)0
-rw-r--r--src/components/ble/DeviceInformationService.h (renamed from src/Components/Ble/DeviceInformationService.h)0
-rw-r--r--src/components/ble/DfuService.cpp (renamed from src/Components/Ble/DfuService.cpp)5
-rw-r--r--src/components/ble/DfuService.h (renamed from src/Components/Ble/DfuService.h)0
-rw-r--r--src/components/ble/ImmediateAlertService.cpp82
-rw-r--r--src/components/ble/ImmediateAlertService.h46
-rw-r--r--src/components/ble/MusicService.cpp225
-rw-r--r--src/components/ble/MusicService.h166
-rw-r--r--src/components/ble/NimbleController.cpp (renamed from src/Components/Ble/NimbleController.cpp)125
-rw-r--r--src/components/ble/NimbleController.h (renamed from src/Components/Ble/NimbleController.h)10
-rw-r--r--src/components/ble/NotificationManager.cpp81
-rw-r--r--src/components/ble/NotificationManager.h43
-rw-r--r--src/components/ble/ServiceDiscovery.cpp31
-rw-r--r--src/components/ble/ServiceDiscovery.h24
-rw-r--r--src/components/brightness/BrightnessController.cpp (renamed from src/Components/Brightness/BrightnessController.cpp)0
-rw-r--r--src/components/brightness/BrightnessController.h (renamed from src/Components/Brightness/BrightnessController.h)0
-rw-r--r--src/components/datetime/DateTimeController.cpp (renamed from src/Components/DateTime/DateTimeController.cpp)0
-rw-r--r--src/components/datetime/DateTimeController.h (renamed from src/Components/DateTime/DateTimeController.h)0
-rw-r--r--src/components/firmwarevalidator/FirmwareValidator.cpp (renamed from src/Components/FirmwareValidator/FirmwareValidator.cpp)0
-rw-r--r--src/components/firmwarevalidator/FirmwareValidator.h (renamed from src/Components/FirmwareValidator/FirmwareValidator.h)0
-rw-r--r--src/components/gfx/Gfx.cpp (renamed from src/Components/Gfx/Gfx.cpp)0
-rw-r--r--src/components/gfx/Gfx.h (renamed from src/Components/Gfx/Gfx.h)0
-rw-r--r--src/displayapp/Apps.h (renamed from src/DisplayApp/Apps.h)2
-rw-r--r--src/displayapp/DisplayApp.cpp (renamed from src/DisplayApp/DisplayApp.cpp)49
-rw-r--r--src/displayapp/DisplayApp.h (renamed from src/DisplayApp/DisplayApp.h)20
-rw-r--r--src/displayapp/LittleVgl.cpp (renamed from src/DisplayApp/LittleVgl.cpp)0
-rw-r--r--src/displayapp/LittleVgl.h (renamed from src/DisplayApp/LittleVgl.h)0
-rw-r--r--src/displayapp/TouchEvents.h (renamed from src/DisplayApp/TouchEvents.h)0
-rw-r--r--src/displayapp/fonts/Readme.md (renamed from src/DisplayApp/Fonts/Readme.md)0
-rw-r--r--src/displayapp/fonts/jetbrains_mono_bold_20.c (renamed from src/DisplayApp/Fonts/jetbrains_mono_bold_20.c)0
-rw-r--r--src/displayapp/fonts/jetbrains_mono_extrabold_compressed.c (renamed from src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_005.c (renamed from src/DisplayApp/Icons/battery/os_battery_005.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_005.png (renamed from src/DisplayApp/Icons/battery/os_battery_005.png)bin1540 -> 1540 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_010.c (renamed from src/DisplayApp/Icons/battery/os_battery_010.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_010.png (renamed from src/DisplayApp/Icons/battery/os_battery_010.png)bin1859 -> 1859 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_020.c (renamed from src/DisplayApp/Icons/battery/os_battery_020.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_020.png (renamed from src/DisplayApp/Icons/battery/os_battery_020.png)bin1558 -> 1558 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_030.c (renamed from src/DisplayApp/Icons/battery/os_battery_030.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_030.png (renamed from src/DisplayApp/Icons/battery/os_battery_030.png)bin1553 -> 1553 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_040.c (renamed from src/DisplayApp/Icons/battery/os_battery_040.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_040.png (renamed from src/DisplayApp/Icons/battery/os_battery_040.png)bin1542 -> 1542 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_050.c (renamed from src/DisplayApp/Icons/battery/os_battery_050.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_050.png (renamed from src/DisplayApp/Icons/battery/os_battery_050.png)bin1539 -> 1539 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_060.c (renamed from src/DisplayApp/Icons/battery/os_battery_060.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_060.png (renamed from src/DisplayApp/Icons/battery/os_battery_060.png)bin1543 -> 1543 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_070.c (renamed from src/DisplayApp/Icons/battery/os_battery_070.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_070.png (renamed from src/DisplayApp/Icons/battery/os_battery_070.png)bin1545 -> 1545 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_080.c (renamed from src/DisplayApp/Icons/battery/os_battery_080.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_080.png (renamed from src/DisplayApp/Icons/battery/os_battery_080.png)bin1549 -> 1549 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_090.c (renamed from src/DisplayApp/Icons/battery/os_battery_090.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_090.png (renamed from src/DisplayApp/Icons/battery/os_battery_090.png)bin1554 -> 1554 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_100.c (renamed from src/DisplayApp/Icons/battery/os_battery_100.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_100.png (renamed from src/DisplayApp/Icons/battery/os_battery_100.png)bin1574 -> 1574 bytes
-rw-r--r--src/displayapp/icons/battery/os_battery_error.c (renamed from src/DisplayApp/Icons/battery/os_battery_error.c)0
-rw-r--r--src/displayapp/icons/battery/os_battery_error.png (renamed from src/DisplayApp/Icons/battery/os_battery_error.png)bin2128 -> 2128 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_005.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_005.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_005.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_005.png)bin1952 -> 1952 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_010.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_010.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_010.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_010.png)bin1983 -> 1983 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_020.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_020.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_020.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_020.png)bin1982 -> 1982 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_030.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_030.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_030.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_030.png)bin1997 -> 1997 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_040.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_040.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_040.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_040.png)bin1993 -> 1993 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_050.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_050.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_050.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_050.png)bin2036 -> 2036 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_060.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_060.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_060.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_060.png)bin2035 -> 2035 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_070.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_070.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_070.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_070.png)bin2035 -> 2035 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_080.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_080.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_080.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_080.png)bin2087 -> 2087 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_090.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_090.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_090.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_090.png)bin2100 -> 2100 bytes
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_100.c (renamed from src/DisplayApp/Icons/battery/os_batterycharging_100.c)0
-rw-r--r--src/displayapp/icons/battery/os_batterycharging_100.png (renamed from src/DisplayApp/Icons/battery/os_batterycharging_100.png)bin1919 -> 1919 bytes
-rw-r--r--src/displayapp/icons/bluetooth/ck_os_bt_connected.png (renamed from src/DisplayApp/Icons/bluetooth/ck_os_bt_connected.png)bin2237 -> 2237 bytes
-rw-r--r--src/displayapp/icons/bluetooth/ck_os_bt_disconnected.png (renamed from src/DisplayApp/Icons/bluetooth/ck_os_bt_disconnected.png)bin2441 -> 2441 bytes
-rw-r--r--src/displayapp/icons/bluetooth/os_bt_connected.c (renamed from src/DisplayApp/Icons/bluetooth/os_bt_connected.c)0
-rw-r--r--src/displayapp/icons/bluetooth/os_bt_connected.png (renamed from src/DisplayApp/Icons/bluetooth/os_bt_connected.png)bin2237 -> 2237 bytes
-rw-r--r--src/displayapp/icons/bluetooth/os_bt_disconnected.c (renamed from src/DisplayApp/Icons/bluetooth/os_bt_disconnected.c)0
-rw-r--r--src/displayapp/icons/bluetooth/os_bt_disconnected.png (renamed from src/DisplayApp/Icons/bluetooth/os_bt_disconnected.png)bin2441 -> 2441 bytes
-rw-r--r--src/displayapp/icons/music/disc.cpp110
-rw-r--r--src/displayapp/icons/music/disc.pngbin0 -> 516 bytes
-rw-r--r--src/displayapp/icons/music/disc_f_1.cpp79
-rw-r--r--src/displayapp/icons/music/disc_f_1.pngbin0 -> 200 bytes
-rw-r--r--src/displayapp/icons/music/disc_f_2.cpp79
-rw-r--r--src/displayapp/icons/music/disc_f_2.pngbin0 -> 197 bytes
-rw-r--r--src/displayapp/screens/ApplicationList.cpp (renamed from src/DisplayApp/Screens/ApplicationList.cpp)8
-rw-r--r--src/displayapp/screens/ApplicationList.h (renamed from src/DisplayApp/Screens/ApplicationList.h)5
-rw-r--r--src/displayapp/screens/BatteryIcon.cpp (renamed from src/DisplayApp/Screens/BatteryIcon.cpp)0
-rw-r--r--src/displayapp/screens/BatteryIcon.h (renamed from src/DisplayApp/Screens/BatteryIcon.h)0
-rw-r--r--src/displayapp/screens/BleIcon.cpp (renamed from src/DisplayApp/Screens/BleIcon.cpp)0
-rw-r--r--src/displayapp/screens/BleIcon.h (renamed from src/DisplayApp/Screens/BleIcon.h)0
-rw-r--r--src/displayapp/screens/Brightness.cpp (renamed from src/DisplayApp/Screens/Brightness.cpp)6
-rw-r--r--src/displayapp/screens/Brightness.h (renamed from src/DisplayApp/Screens/Brightness.h)2
-rw-r--r--src/displayapp/screens/Clock.cpp (renamed from src/DisplayApp/Screens/Clock.cpp)45
-rw-r--r--src/displayapp/screens/Clock.h (renamed from src/DisplayApp/Screens/Clock.h)17
-rw-r--r--src/displayapp/screens/DropDownDemo.cpp (renamed from src/DisplayApp/Screens/DropDownDemo.cpp)4
-rw-r--r--src/displayapp/screens/DropDownDemo.h (renamed from src/DisplayApp/Screens/DropDownDemo.h)0
-rw-r--r--src/displayapp/screens/FirmwareUpdate.cpp (renamed from src/DisplayApp/Screens/FirmwareUpdate.cpp)10
-rw-r--r--src/displayapp/screens/FirmwareUpdate.h (renamed from src/DisplayApp/Screens/FirmwareUpdate.h)3
-rw-r--r--src/displayapp/screens/FirmwareValidation.cpp (renamed from src/DisplayApp/Screens/FirmwareValidation.cpp)22
-rw-r--r--src/displayapp/screens/FirmwareValidation.h (renamed from src/DisplayApp/Screens/FirmwareValidation.h)0
-rw-r--r--src/displayapp/screens/Gauge.cpp (renamed from src/DisplayApp/Screens/Gauge.cpp)4
-rw-r--r--src/displayapp/screens/Gauge.h (renamed from src/DisplayApp/Screens/Gauge.h)0
-rw-r--r--src/displayapp/screens/InfiniPaint.cpp (renamed from src/DisplayApp/Screens/InfiniPaint.cpp)12
-rw-r--r--src/displayapp/screens/InfiniPaint.h39
-rw-r--r--src/displayapp/screens/Label.cpp (renamed from src/DisplayApp/Screens/Label.cpp)2
-rw-r--r--src/displayapp/screens/Label.h (renamed from src/DisplayApp/Screens/Label.h)0
-rw-r--r--src/displayapp/screens/Meter.cpp (renamed from src/DisplayApp/Screens/Meter.cpp)4
-rw-r--r--src/displayapp/screens/Meter.h (renamed from src/DisplayApp/Screens/Meter.h)0
-rw-r--r--src/displayapp/screens/Modal.cpp (renamed from src/DisplayApp/Screens/Modal.cpp)6
-rw-r--r--src/displayapp/screens/Modal.h (renamed from src/DisplayApp/Screens/Modal.h)0
-rw-r--r--src/displayapp/screens/Music.cpp292
-rw-r--r--src/displayapp/screens/Music.h96
-rw-r--r--src/displayapp/screens/NotificationIcon.cpp8
-rw-r--r--src/displayapp/screens/NotificationIcon.h12
-rw-r--r--src/displayapp/screens/Notifications.cpp174
-rw-r--r--src/displayapp/screens/Notifications.h61
-rw-r--r--src/displayapp/screens/Screen.cpp (renamed from src/DisplayApp/Screens/Screen.cpp)0
-rw-r--r--src/displayapp/screens/Screen.h42
-rw-r--r--src/displayapp/screens/ScreenList.h (renamed from src/DisplayApp/Screens/ScreenList.h)2
-rw-r--r--src/displayapp/screens/Symbols.h (renamed from src/DisplayApp/Screens/Symbols.h)0
-rw-r--r--src/displayapp/screens/SystemInfo.cpp (renamed from src/DisplayApp/Screens/SystemInfo.cpp)6
-rw-r--r--src/displayapp/screens/SystemInfo.h (renamed from src/DisplayApp/Screens/SystemInfo.h)5
-rw-r--r--src/displayapp/screens/Tab.cpp (renamed from src/DisplayApp/Screens/Tab.cpp)4
-rw-r--r--src/displayapp/screens/Tab.h (renamed from src/DisplayApp/Screens/Tab.h)0
-rw-r--r--src/displayapp/screens/Tile.cpp (renamed from src/DisplayApp/Screens/Tile.cpp)5
-rw-r--r--src/displayapp/screens/Tile.h (renamed from src/DisplayApp/Screens/Tile.h)2
-rw-r--r--src/drivers/Cst816s.cpp4
-rw-r--r--src/drivers/Cst816s.h14
-rw-r--r--src/drivers/SpiNorFlash.cpp6
-rw-r--r--src/drivers/TwiMaster.cpp95
-rw-r--r--src/drivers/TwiMaster.h16
-rw-r--r--src/graphics.cpp8
-rw-r--r--src/libs/lvgl/src/lv_core/lv_obj.c2
-rw-r--r--src/logging/DummyLogger.h (renamed from src/Logging/DummyLogger.h)0
-rw-r--r--src/logging/Logger.h (renamed from src/Logging/Logger.h)0
-rw-r--r--src/logging/NrfLogger.cpp (renamed from src/Logging/NrfLogger.cpp)5
-rw-r--r--src/logging/NrfLogger.h (renamed from src/Logging/NrfLogger.h)0
-rw-r--r--src/main.cpp26
-rw-r--r--src/systemtask/SystemMonitor.h (renamed from src/SystemTask/SystemMonitor.h)2
-rw-r--r--src/systemtask/SystemTask.cpp (renamed from src/SystemTask/SystemTask.cpp)40
-rw-r--r--src/systemtask/SystemTask.h (renamed from src/SystemTask/SystemTask.h)11
174 files changed, 3005 insertions, 1515 deletions
diff --git a/src/BootloaderVersion.cpp b/src/BootloaderVersion.cpp
new file mode 100644
index 0000000..8555593
--- /dev/null
+++ b/src/BootloaderVersion.cpp
@@ -0,0 +1,26 @@
+#include <cstdint>
+#include "BootloaderVersion.h"
+
+using namespace Pinetime;
+
+// NOTE : current bootloader does not export its version to the application firmware.
+
+uint32_t BootloaderVersion::Major() {
+ return 0;
+}
+
+uint32_t BootloaderVersion::Minor() {
+ return 0;
+}
+
+uint32_t BootloaderVersion::Patch() {
+ return 0;
+}
+
+const char *BootloaderVersion::VersionString() {
+ return "0.0.0";
+}
+
+bool BootloaderVersion::IsValid() {
+ return false;
+}
diff --git a/src/BootloaderVersion.h b/src/BootloaderVersion.h
new file mode 100644
index 0000000..c7fcbd9
--- /dev/null
+++ b/src/BootloaderVersion.h
@@ -0,0 +1,12 @@
+#pragma once
+
+namespace Pinetime {
+ class BootloaderVersion {
+ public:
+ static uint32_t Major();
+ static uint32_t Minor();
+ static uint32_t Patch();
+ static const char* VersionString();
+ static bool IsValid();
+ };
+} \ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4032d7e..6c9ce24 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,20 +10,20 @@ set(NRF_BOARD pca10040)
if (NOT NRF5_SDK_PATH)
message(FATAL_ERROR "The path to the nRF5 SDK (NRF5_SDK_PATH) must be set.")
endif ()
-if(DEFINED ARM_NONE_EABI_TOOLCHAIN_PATH)
+if (DEFINED ARM_NONE_EABI_TOOLCHAIN_PATH)
set(ARM_NONE_EABI_TOOLCHAIN_BIN_PATH ${ARM_NONE_EABI_TOOLCHAIN_PATH}/bin)
-endif()
+endif ()
if (NOT NRF_TARGET MATCHES "nrf52")
message(FATAL_ERROR "Only rRF52 boards are supported right now")
-endif()
+endif ()
# Setup toolchain
include(${CMAKE_SOURCE_DIR}/cmake-nRF5x/arm-gcc-toolchain.cmake)
-if(NOT DEFINED ARM_GCC_TOOLCHAIN)
+if (NOT DEFINED ARM_GCC_TOOLCHAIN)
message(FATAL_ERROR "The toolchain must be set up before calling this macro")
-endif()
+endif ()
set(CMAKE_OSX_SYSROOT "/")
set(CMAKE_OSX_DEPLOYMENT_TARGET "")
@@ -84,395 +84,410 @@ set(SDK_SOURCE_FILES
# GPIOTE
"${NRF5_SDK_PATH}/components/libraries/gpiote/app_gpiote.c"
-)
+ )
set(TINYCRYPT_SRC
- libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c
- libs/mynewt-nimble/ext/tinycrypt/src/utils.c
- )
+ libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c
+ libs/mynewt-nimble/ext/tinycrypt/src/utils.c
+ )
set(NIMBLE_SRC
- libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c
- libs/mynewt-nimble/porting/npl/freertos/src/npl_os_freertos.c
- libs/mynewt-nimble/nimble/host/src/ble_hs.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_hci_evt.c
- libs/mynewt-nimble/nimble/host/src/ble_l2cap_sig_cmd.c
- libs/mynewt-nimble/nimble/host/src/ble_l2cap_sig.c
- libs/mynewt-nimble/nimble/host/src/ble_l2cap.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_mbuf.c
- libs/mynewt-nimble/nimble/host/src/ble_sm.c
- libs/mynewt-nimble/nimble/host/src/ble_gap.c
- libs/mynewt-nimble/nimble/host/src/ble_gatts.c
- libs/mynewt-nimble/nimble/host/src/ble_gattc.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_conn.c
- libs/mynewt-nimble/nimble/host/src/ble_att_svr.c
- libs/mynewt-nimble/nimble/host/src/ble_store.c
- libs/mynewt-nimble/nimble/host/src/ble_store_util.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_pvcy.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_hci.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_log.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_hci_util.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_hci_cmd.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_cfg.c
- libs/mynewt-nimble/nimble/host/src/ble_uuid.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_id.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_misc.c
- libs/mynewt-nimble/nimble/host/src/ble_att.c
- libs/mynewt-nimble/nimble/host/src/ble_att_clt.c
- libs/mynewt-nimble/nimble/host/src/ble_att_svr.c
- libs/mynewt-nimble/nimble/host/src/ble_att_cmd.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_atomic.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_adv.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_flow.c
- libs/mynewt-nimble/nimble/host/src/ble_sm.c
- libs/mynewt-nimble/nimble/host/src/ble_sm_cmd.c
- libs/mynewt-nimble/nimble/host/src/ble_sm_lgcy.c
- libs/mynewt-nimble/nimble/host/src/ble_sm_alg.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_mqueue.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_stop.c
- libs/mynewt-nimble/nimble/host/src/ble_hs_startup.c
- libs/mynewt-nimble/nimble/host/store/ram/src/ble_store_ram.c
- libs/mynewt-nimble/nimble/host/src/ble_monitor.c
- libs/mynewt-nimble/nimble/transport/ram/src/ble_hci_ram.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_rand.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_conn.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_ctrl.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_hci.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_conn_hci.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_utils.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_scan.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_whitelist.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_adv.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_sched.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_supp_cmd.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_hci_ev.c
- libs/mynewt-nimble/nimble/controller/src/ble_ll_rfmgmt.c
- libs/mynewt-nimble/porting/nimble/src/os_cputime.c
- libs/mynewt-nimble/porting/nimble/src/os_cputime_pwr2.c
- libs/mynewt-nimble/porting/nimble/src/os_mbuf.c
- libs/mynewt-nimble/porting/nimble/src/os_mempool.c
- libs/mynewt-nimble/porting/nimble/src/hal_timer.c
- libs/mynewt-nimble/porting/nimble/src/mem.c
- libs/mynewt-nimble/porting/nimble/src/endian.c
- libs/mynewt-nimble/porting/nimble/src/os_msys_init.c
- libs/mynewt-nimble/nimble/drivers/nrf52/src/ble_hw.c
- libs/mynewt-nimble/nimble/drivers/nrf52/src/ble_phy.c
- libs/mynewt-nimble/nimble/host/services/gap/src/ble_svc_gap.c
- libs/mynewt-nimble/nimble/host/services/gatt/src/ble_svc_gatt.c
- libs/mynewt-nimble/nimble/host/util/src/addr.c
- )
+ libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c
+ libs/mynewt-nimble/porting/npl/freertos/src/npl_os_freertos.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_hci_evt.c
+ libs/mynewt-nimble/nimble/host/src/ble_l2cap_sig_cmd.c
+ libs/mynewt-nimble/nimble/host/src/ble_l2cap_sig.c
+ libs/mynewt-nimble/nimble/host/src/ble_l2cap.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_mbuf.c
+ libs/mynewt-nimble/nimble/host/src/ble_sm.c
+ libs/mynewt-nimble/nimble/host/src/ble_gap.c
+ libs/mynewt-nimble/nimble/host/src/ble_gatts.c
+ libs/mynewt-nimble/nimble/host/src/ble_gattc.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_conn.c
+ libs/mynewt-nimble/nimble/host/src/ble_att_svr.c
+ libs/mynewt-nimble/nimble/host/src/ble_store.c
+ libs/mynewt-nimble/nimble/host/src/ble_store_util.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_pvcy.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_hci.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_log.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_hci_util.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_hci_cmd.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_cfg.c
+ libs/mynewt-nimble/nimble/host/src/ble_uuid.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_id.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_misc.c
+ libs/mynewt-nimble/nimble/host/src/ble_att.c
+ libs/mynewt-nimble/nimble/host/src/ble_att_clt.c
+ libs/mynewt-nimble/nimble/host/src/ble_att_svr.c
+ libs/mynewt-nimble/nimble/host/src/ble_att_cmd.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_atomic.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_adv.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_flow.c
+ libs/mynewt-nimble/nimble/host/src/ble_sm.c
+ libs/mynewt-nimble/nimble/host/src/ble_sm_cmd.c
+ libs/mynewt-nimble/nimble/host/src/ble_sm_lgcy.c
+ libs/mynewt-nimble/nimble/host/src/ble_sm_alg.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_mqueue.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_stop.c
+ libs/mynewt-nimble/nimble/host/src/ble_hs_startup.c
+ libs/mynewt-nimble/nimble/host/store/ram/src/ble_store_ram.c
+ libs/mynewt-nimble/nimble/host/src/ble_monitor.c
+ libs/mynewt-nimble/nimble/transport/ram/src/ble_hci_ram.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_rand.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_conn.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_ctrl.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_hci.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_conn_hci.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_utils.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_scan.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_whitelist.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_adv.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_sched.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_supp_cmd.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_hci_ev.c
+ libs/mynewt-nimble/nimble/controller/src/ble_ll_rfmgmt.c
+ libs/mynewt-nimble/porting/nimble/src/os_cputime.c
+ libs/mynewt-nimble/porting/nimble/src/os_cputime_pwr2.c
+ libs/mynewt-nimble/porting/nimble/src/os_mbuf.c
+ libs/mynewt-nimble/porting/nimble/src/os_mempool.c
+ libs/mynewt-nimble/porting/nimble/src/hal_timer.c
+ libs/mynewt-nimble/porting/nimble/src/mem.c
+ libs/mynewt-nimble/porting/nimble/src/endian.c
+ libs/mynewt-nimble/porting/nimble/src/os_msys_init.c
+ libs/mynewt-nimble/nimble/drivers/nrf52/src/ble_hw.c
+ libs/mynewt-nimble/nimble/drivers/nrf52/src/ble_phy.c
+ libs/mynewt-nimble/nimble/host/services/gap/src/ble_svc_gap.c
+ libs/mynewt-nimble/nimble/host/services/gatt/src/ble_svc_gatt.c
+ libs/mynewt-nimble/nimble/host/util/src/addr.c
+ )
set(LVGL_SRC
- libs/lv_conf.h
- libs/lvgl/lvgl.h
- libs/lvgl/src/lv_core/lv_obj.c
- libs/lvgl/src/lv_core/lv_obj.h
- libs/lvgl/src/lv_core/lv_group.c
- libs/lvgl/src/lv_core/lv_group.h
- libs/lvgl/src/lv_core/lv_disp.c
- libs/lvgl/src/lv_core/lv_disp.h
- libs/lvgl/src/lv_core/lv_debug.h
- libs/lvgl/src/lv_core/lv_debug.c
- libs/lvgl/src/lv_core/lv_indev.c
- libs/lvgl/src/lv_core/lv_indev.h
- libs/lvgl/src/lv_core/lv_refr.c
- libs/lvgl/src/lv_core/lv_refr.h
- libs/lvgl/src/lv_core/lv_style.c
- libs/lvgl/src/lv_core/lv_style.h
- libs/lvgl/src/lv_misc/lv_anim.c
- libs/lvgl/src/lv_misc/lv_anim.h
- libs/lvgl/src/lv_misc/lv_async.h
- libs/lvgl/src/lv_misc/lv_async.c
- libs/lvgl/src/lv_misc/lv_fs.c
- libs/lvgl/src/lv_misc/lv_fs.h
- libs/lvgl/src/lv_misc/lv_task.c
- libs/lvgl/src/lv_misc/lv_task.h
- libs/lvgl/src/lv_misc/lv_area.c
- libs/lvgl/src/lv_misc/lv_area.h
- libs/lvgl/src/lv_misc/lv_bidi.c
- libs/lvgl/src/lv_misc/lv_bidi.h
- libs/lvgl/src/lv_misc/lv_circ.c
- libs/lvgl/src/lv_misc/lv_circ.h
- libs/lvgl/src/lv_misc/lv_color.c
- libs/lvgl/src/lv_misc/lv_color.h
- libs/lvgl/src/lv_misc/lv_fs.c
- libs/lvgl/src/lv_misc/lv_fs.h
- libs/lvgl/src/lv_misc/lv_gc.c
- libs/lvgl/src/lv_misc/lv_gc.h
- libs/lvgl/src/lv_misc/lv_ll.c
- libs/lvgl/src/lv_misc/lv_ll.h
- libs/lvgl/src/lv_misc/lv_log.c
- libs/lvgl/src/lv_misc/lv_log.h
- libs/lvgl/src/lv_misc/lv_math.c
- libs/lvgl/src/lv_misc/lv_math.h
- libs/lvgl/src/lv_misc/lv_mem.c
- libs/lvgl/src/lv_misc/lv_mem.h
- libs/lvgl/src/lv_misc/lv_printf.c
- libs/lvgl/src/lv_misc/lv_printf.h
- libs/lvgl/src/lv_misc/lv_task.c
- libs/lvgl/src/lv_misc/lv_task.h
- libs/lvgl/src/lv_misc/lv_templ.c
- libs/lvgl/src/lv_misc/lv_templ.h
- libs/lvgl/src/lv_misc/lv_txt.c
- libs/lvgl/src/lv_misc/lv_txt.h
- libs/lvgl/src/lv_misc/lv_types.h
- libs/lvgl/src/lv_misc/lv_utils.c
- libs/lvgl/src/lv_misc/lv_utils.h
- libs/lvgl/src/lv_draw/lv_draw.c
- libs/lvgl/src/lv_draw/lv_draw.h
- libs/lvgl/src/lv_draw/lv_draw_arc.c
- libs/lvgl/src/lv_draw/lv_draw_arc.h
- libs/lvgl/src/lv_draw/lv_draw_basic.c
- libs/lvgl/src/lv_draw/lv_draw_basic.h
- libs/lvgl/src/lv_draw/lv_draw_img.c
- libs/lvgl/src/lv_draw/lv_draw_img.h
- libs/lvgl/src/lv_draw/lv_draw_label.c
- libs/lvgl/src/lv_draw/lv_draw_label.h
- libs/lvgl/src/lv_draw/lv_draw_line.c
- libs/lvgl/src/lv_draw/lv_draw_line.h
- libs/lvgl/src/lv_draw/lv_draw_rect.c
- libs/lvgl/src/lv_draw/lv_draw_rect.h
- libs/lvgl/src/lv_draw/lv_draw_triangle.c
- libs/lvgl/src/lv_draw/lv_draw_triangle.h
- libs/lvgl/src/lv_draw/lv_img_cache.c
- libs/lvgl/src/lv_draw/lv_img_cache.h
- libs/lvgl/src/lv_draw/lv_img_decoder.c
- libs/lvgl/src/lv_draw/lv_img_decoder.h
- libs/lvgl/src/lv_hal/lv_hal.h
- libs/lvgl/src/lv_hal/lv_hal_disp.c
- libs/lvgl/src/lv_hal/lv_hal_disp.h
- libs/lvgl/src/lv_hal/lv_hal_indev.c
- libs/lvgl/src/lv_hal/lv_hal_indev.h
- libs/lvgl/src/lv_hal/lv_hal_tick.c
- libs/lvgl/src/lv_hal/lv_hal_tick.h
- libs/lvgl/src/lv_font/lv_font.c
- libs/lvgl/src/lv_font/lv_font.h
- libs/lvgl/src/lv_font/lv_font_fmt_txt.c
- libs/lvgl/src/lv_font/lv_font_fmt_txt.h
- libs/lvgl/src/lv_font/lv_symbol_def.h
- libs/lvgl/src/lv_themes/lv_theme.c
- libs/lvgl/src/lv_themes/lv_theme.h
- libs/lvgl/src/lv_objx/lv_btn.h
- libs/lvgl/src/lv_objx/lv_btn.c
- libs/lvgl/src/lv_objx/lv_cont.h
- libs/lvgl/src/lv_objx/lv_cont.c
- libs/lvgl/src/lv_objx/lv_label.h
- libs/lvgl/src/lv_objx/lv_label.c
- libs/lvgl/src/lv_themes/lv_theme.c
- libs/lvgl/src/lv_themes/lv_theme.h
- libs/lvgl/src/lv_themes/lv_theme_night.h
- libs/lvgl/src/lv_themes/lv_theme_night.c
- libs/lvgl/src/lv_objx/lv_list.c
- libs/lvgl/src/lv_objx/lv_list.h
- libs/lvgl/src/lv_objx/lv_tileview.c
- libs/lvgl/src/lv_objx/lv_tileview.h
- libs/lvgl/src/lv_objx/lv_tabview.c
- libs/lvgl/src/lv_objx/lv_tabview.h
- libs/lvgl/src/lv_objx/lv_btnm.c
- libs/lvgl/src/lv_objx/lv_btnm.h
- libs/lvgl/src/lv_objx/lv_page.c
- libs/lvgl/src/lv_objx/lv_page.h
- libs/lvgl/src/lv_objx/lv_img.c
- libs/lvgl/src/lv_objx/lv_img.h
- libs/lvgl/src/lv_objx/lv_lmeter.c
- libs/lvgl/src/lv_objx/lv_lmeter.h
- libs/lvgl/src/lv_objx/lv_arc.c
- libs/lvgl/src/lv_objx/lv_arc.h
- libs/lvgl/src/lv_objx/lv_gauge.c
- libs/lvgl/src/lv_objx/lv_gauge.h
- libs/lvgl/src/lv_objx/lv_mbox.c
- libs/lvgl/src/lv_objx/lv_mbox.h
- libs/lvgl/src/lv_objx/lv_bar.c
- libs/lvgl/src/lv_objx/lv_bar.h
- libs/lvgl/src/lv_objx/lv_slider.h
- libs/lvgl/src/lv_objx/lv_slider.c
- libs/lvgl/src/lv_objx/lv_ddlist.c
- libs/lvgl/src/lv_objx/lv_ddlist.h
- )
+ libs/lv_conf.h
+ libs/lvgl/lvgl.h
+ libs/lvgl/src/lv_core/lv_obj.c
+ libs/lvgl/src/lv_core/lv_obj.h
+ libs/lvgl/src/lv_core/lv_group.c
+ libs/lvgl/src/lv_core/lv_group.h
+ libs/lvgl/src/lv_core/lv_disp.c
+ libs/lvgl/src/lv_core/lv_disp.h
+ libs/lvgl/src/lv_core/lv_debug.h
+ libs/lvgl/src/lv_core/lv_debug.c
+ libs/lvgl/src/lv_core/lv_indev.c
+ libs/lvgl/src/lv_core/lv_indev.h
+ libs/lvgl/src/lv_core/lv_refr.c
+ libs/lvgl/src/lv_core/lv_refr.h
+ libs/lvgl/src/lv_core/lv_style.c
+ libs/lvgl/src/lv_core/lv_style.h
+ libs/lvgl/src/lv_misc/lv_anim.c
+ libs/lvgl/src/lv_misc/lv_anim.h
+ libs/lvgl/src/lv_misc/lv_async.h
+ libs/lvgl/src/lv_misc/lv_async.c
+ libs/lvgl/src/lv_misc/lv_fs.c
+ libs/lvgl/src/lv_misc/lv_fs.h
+ libs/lvgl/src/lv_misc/lv_task.c
+ libs/lvgl/src/lv_misc/lv_task.h
+ libs/lvgl/src/lv_misc/lv_area.c
+ libs/lvgl/src/lv_misc/lv_area.h
+ libs/lvgl/src/lv_misc/lv_bidi.c
+ libs/lvgl/src/lv_misc/lv_bidi.h
+ libs/lvgl/src/lv_misc/lv_circ.c
+ libs/lvgl/src/lv_misc/lv_circ.h
+ libs/lvgl/src/lv_misc/lv_color.c
+ libs/lvgl/src/lv_misc/lv_color.h
+ libs/lvgl/src/lv_misc/lv_fs.c
+ libs/lvgl/src/lv_misc/lv_fs.h
+ libs/lvgl/src/lv_misc/lv_gc.c
+ libs/lvgl/src/lv_misc/lv_gc.h
+ libs/lvgl/src/lv_misc/lv_ll.c
+ libs/lvgl/src/lv_misc/lv_ll.h
+ libs/lvgl/src/lv_misc/lv_log.c
+ libs/lvgl/src/lv_misc/lv_log.h
+ libs/lvgl/src/lv_misc/lv_math.c
+ libs/lvgl/src/lv_misc/lv_math.h
+ libs/lvgl/src/lv_misc/lv_mem.c
+ libs/lvgl/src/lv_misc/lv_mem.h
+ libs/lvgl/src/lv_misc/lv_printf.c
+ libs/lvgl/src/lv_misc/lv_printf.h
+ libs/lvgl/src/lv_misc/lv_task.c
+ libs/lvgl/src/lv_misc/lv_task.h
+ libs/lvgl/src/lv_misc/lv_templ.c
+ libs/lvgl/src/lv_misc/lv_templ.h
+ libs/lvgl/src/lv_misc/lv_txt.c
+ libs/lvgl/src/lv_misc/lv_txt.h
+ libs/lvgl/src/lv_misc/lv_types.h
+ libs/lvgl/src/lv_misc/lv_utils.c
+ libs/lvgl/src/lv_misc/lv_utils.h
+ libs/lvgl/src/lv_draw/lv_draw.c
+ libs/lvgl/src/lv_draw/lv_draw.h
+ libs/lvgl/src/lv_draw/lv_draw_arc.c
+ libs/lvgl/src/lv_draw/lv_draw_arc.h
+ libs/lvgl/src/lv_draw/lv_draw_basic.c
+ libs/lvgl/src/lv_draw/lv_draw_basic.h
+ libs/lvgl/src/lv_draw/lv_draw_img.c
+ libs/lvgl/src/lv_draw/lv_draw_img.h
+ libs/lvgl/src/lv_draw/lv_draw_label.c
+ libs/lvgl/src/lv_draw/lv_draw_label.h
+ libs/lvgl/src/lv_draw/lv_draw_line.c
+ libs/lvgl/src/lv_draw/lv_draw_line.h
+ libs/lvgl/src/lv_draw/lv_draw_rect.c
+ libs/lvgl/src/lv_draw/lv_draw_rect.h
+ libs/lvgl/src/lv_draw/lv_draw_triangle.c
+ libs/lvgl/src/lv_draw/lv_draw_triangle.h
+ libs/lvgl/src/lv_draw/lv_img_cache.c
+ libs/lvgl/src/lv_draw/lv_img_cache.h
+ libs/lvgl/src/lv_draw/lv_img_decoder.c
+ libs/lvgl/src/lv_draw/lv_img_decoder.h
+ libs/lvgl/src/lv_hal/lv_hal.h
+ libs/lvgl/src/lv_hal/lv_hal_disp.c
+ libs/lvgl/src/lv_hal/lv_hal_disp.h
+ libs/lvgl/src/lv_hal/lv_hal_indev.c
+ libs/lvgl/src/lv_hal/lv_hal_indev.h
+ libs/lvgl/src/lv_hal/lv_hal_tick.c
+ libs/lvgl/src/lv_hal/lv_hal_tick.h
+ libs/lvgl/src/lv_font/lv_font.c
+ libs/lvgl/src/lv_font/lv_font.h
+ libs/lvgl/src/lv_font/lv_font_fmt_txt.c
+ libs/lvgl/src/lv_font/lv_font_fmt_txt.h
+ libs/lvgl/src/lv_font/lv_symbol_def.h
+ libs/lvgl/src/lv_themes/lv_theme.c
+ libs/lvgl/src/lv_themes/lv_theme.h
+ libs/lvgl/src/lv_objx/lv_btn.h
+ libs/lvgl/src/lv_objx/lv_btn.c
+ libs/lvgl/src/lv_objx/lv_cont.h
+ libs/lvgl/src/lv_objx/lv_cont.c
+ libs/lvgl/src/lv_objx/lv_label.h
+ libs/lvgl/src/lv_objx/lv_label.c
+ libs/lvgl/src/lv_themes/lv_theme.c
+ libs/lvgl/src/lv_themes/lv_theme.h
+ libs/lvgl/src/lv_themes/lv_theme_night.h
+ libs/lvgl/src/lv_themes/lv_theme_night.c
+ libs/lvgl/src/lv_objx/lv_list.c
+ libs/lvgl/src/lv_objx/lv_list.h
+ libs/lvgl/src/lv_objx/lv_tileview.c
+ libs/lvgl/src/lv_objx/lv_tileview.h
+ libs/lvgl/src/lv_objx/lv_tabview.c
+ libs/lvgl/src/lv_objx/lv_tabview.h
+ libs/lvgl/src/lv_objx/lv_btnm.c
+ libs/lvgl/src/lv_objx/lv_btnm.h
+ libs/lvgl/src/lv_objx/lv_page.c
+ libs/lvgl/src/lv_objx/lv_page.h
+ libs/lvgl/src/lv_objx/lv_img.c
+ libs/lvgl/src/lv_objx/lv_img.h
+ libs/lvgl/src/lv_objx/lv_lmeter.c
+ libs/lvgl/src/lv_objx/lv_lmeter.h
+ libs/lvgl/src/lv_objx/lv_arc.c
+ libs/lvgl/src/lv_objx/lv_arc.h
+ libs/lvgl/src/lv_objx/lv_gauge.c
+ libs/lvgl/src/lv_objx/lv_gauge.h
+ libs/lvgl/src/lv_objx/lv_mbox.c
+ libs/lvgl/src/lv_objx/lv_mbox.h
+ libs/lvgl/src/lv_objx/lv_bar.c
+ libs/lvgl/src/lv_objx/lv_bar.h
+ libs/lvgl/src/lv_objx/lv_slider.h
+ libs/lvgl/src/lv_objx/lv_slider.c
+ libs/lvgl/src/lv_objx/lv_ddlist.c
+ libs/lvgl/src/lv_objx/lv_ddlist.h
+ libs/lvgl/src/lv_objx/lv_line.c
+ libs/lvgl/src/lv_objx/lv_line.h
+ )
list(APPEND IMAGE_FILES
- DisplayApp/Icons/battery/os_battery_error.c
- DisplayApp/Icons/battery/os_battery_100.c
- DisplayApp/Icons/battery/os_battery_090.c
- DisplayApp/Icons/battery/os_battery_080.c
- DisplayApp/Icons/battery/os_battery_070.c
- DisplayApp/Icons/battery/os_battery_060.c
- DisplayApp/Icons/battery/os_battery_050.c
- DisplayApp/Icons/battery/os_battery_040.c
- DisplayApp/Icons/battery/os_battery_030.c
- DisplayApp/Icons/battery/os_battery_020.c
- DisplayApp/Icons/battery/os_battery_010.c
- DisplayApp/Icons/battery/os_battery_005.c
-
- DisplayApp/Icons/battery/os_batterycharging_100.c
- DisplayApp/Icons/battery/os_batterycharging_090.c
- DisplayApp/Icons/battery/os_batterycharging_080.c
- DisplayApp/Icons/battery/os_batterycharging_070.c
- DisplayApp/Icons/battery/os_batterycharging_060.c
- DisplayApp/Icons/battery/os_batterycharging_050.c
- DisplayApp/Icons/battery/os_batterycharging_040.c
- DisplayApp/Icons/battery/os_batterycharging_030.c
- DisplayApp/Icons/battery/os_batterycharging_020.c
- DisplayApp/Icons/battery/os_batterycharging_010.c
- DisplayApp/Icons/battery/os_batterycharging_005.c
-
- DisplayApp/Icons/bluetooth/os_bt_connected.c
- DisplayApp/Icons/bluetooth/os_bt_disconnected.c
- )
+ displayapp/icons/battery/os_battery_error.c
+ displayapp/icons/battery/os_battery_100.c
+ displayapp/icons/battery/os_battery_090.c
+ displayapp/icons/battery/os_battery_080.c
+ displayapp/icons/battery/os_battery_070.c
+ displayapp/icons/battery/os_battery_060.c
+ displayapp/icons/battery/os_battery_050.c
+ displayapp/icons/battery/os_battery_040.c
+ displayapp/icons/battery/os_battery_030.c
+ displayapp/icons/battery/os_battery_020.c
+ displayapp/icons/battery/os_battery_010.c
+ displayapp/icons/battery/os_battery_005.c
+
+ displayapp/icons/battery/os_batterycharging_100.c
+ displayapp/icons/battery/os_batterycharging_090.c
+ displayapp/icons/battery/os_batterycharging_080.c
+ displayapp/icons/battery/os_batterycharging_070.c
+ displayapp/icons/battery/os_batterycharging_060.c
+ displayapp/icons/battery/os_batterycharging_050.c
+ displayapp/icons/battery/os_batterycharging_040.c
+ displayapp/icons/battery/os_batterycharging_030.c
+ displayapp/icons/battery/os_batterycharging_020.c
+ displayapp/icons/battery/os_batterycharging_010.c
+ displayapp/icons/battery/os_batterycharging_005.c
+
+ displayapp/icons/bluetooth/os_bt_connected.c
+ displayapp/icons/bluetooth/os_bt_disconnected.c
+ )
list(APPEND SOURCE_FILES
- Logging/NrfLogger.cpp
- DisplayApp/DisplayApp.cpp
- DisplayApp/Screens/Screen.cpp
- DisplayApp/Screens/Clock.cpp
- DisplayApp/Screens/Tile.cpp
- DisplayApp/Screens/Meter.cpp
- DisplayApp/Screens/Gauge.cpp
- DisplayApp/Screens/InfiniPaint.cpp
- DisplayApp/Screens/DropDownDemo.cpp
- DisplayApp/Screens/Modal.cpp
- DisplayApp/Screens/BatteryIcon.cpp
- DisplayApp/Screens/BleIcon.cpp
- DisplayApp/Screens/Brightness.cpp
- DisplayApp/Screens/SystemInfo.cpp
- DisplayApp/Screens/Label.cpp
- DisplayApp/Screens/FirmwareUpdate.cpp
- DisplayApp/Screens/Music.cpp
- DisplayApp/Screens/FirmwareValidation.cpp
- DisplayApp/Screens/ApplicationList.cpp
- main.cpp
- drivers/St7789.cpp
- drivers/SpiNorFlash.cpp
- drivers/SpiMaster.cpp
- drivers/Spi.cpp
- drivers/Watchdog.cpp
- drivers/DebugPins.cpp
- drivers/InternalFlash.cpp
- Components/Battery/BatteryController.cpp
- Components/Ble/BleController.cpp
- Components/Ble/NotificationManager.cpp
- Components/DateTime/DateTimeController.cpp
- Components/Brightness/BrightnessController.cpp
- Components/Ble/NimbleController.cpp
- Components/Ble/DeviceInformationService.cpp
- Components/Ble/CurrentTimeClient.cpp
- Components/Ble/AlertNotificationClient.cpp
- Components/Ble/DfuService.cpp
- Components/Ble/CurrentTimeService.cpp
- Components/Ble/AlertNotificationService.cpp
- Components/Ble/MusicService.cpp
- Components/FirmwareValidator/FirmwareValidator.cpp
- drivers/Cst816s.cpp
- FreeRTOS/port.c
- FreeRTOS/port_cmsis_systick.c
- FreeRTOS/port_cmsis.c
-
- DisplayApp/LittleVgl.cpp
- DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c
- DisplayApp/Fonts/jetbrains_mono_bold_20.c
-
- SystemTask/SystemTask.cpp
- drivers/TwiMaster.cpp
-)
+ BootloaderVersion.cpp
+ logging/NrfLogger.cpp
+ displayapp/DisplayApp.cpp
+ displayapp/screens/Screen.cpp
+ displayapp/screens/Clock.cpp
+ displayapp/screens/Tile.cpp
+ displayapp/screens/Meter.cpp
+ displayapp/screens/Gauge.cpp
+ displayapp/screens/InfiniPaint.cpp
+ displayapp/screens/DropDownDemo.cpp
+ displayapp/screens/Modal.cpp
+ displayapp/screens/BatteryIcon.cpp
+ displayapp/screens/BleIcon.cpp
+ displayapp/screens/NotificationIcon.cpp
+ displayapp/screens/Brightness.cpp
+ displayapp/screens/SystemInfo.cpp
+ displayapp/screens/Label.cpp
+ displayapp/screens/FirmwareUpdate.cpp
+ displayapp/screens/Music.cpp
+ displayapp/screens/FirmwareValidation.cpp
+ displayapp/screens/ApplicationList.cpp
+ displayapp/screens/Notifications.cpp
+ main.cpp
+ drivers/St7789.cpp
+ drivers/SpiNorFlash.cpp
+ drivers/SpiMaster.cpp
+ drivers/Spi.cpp
+ drivers/Watchdog.cpp
+ drivers/DebugPins.cpp
+ drivers/InternalFlash.cpp
+ components/battery/BatteryController.cpp
+ components/ble/BleController.cpp
+ components/ble/NotificationManager.cpp
+ components/datetime/DateTimeController.cpp
+ components/brightness/BrightnessController.cpp
+ components/ble/NimbleController.cpp
+ components/ble/DeviceInformationService.cpp
+ components/ble/CurrentTimeClient.cpp
+ components/ble/AlertNotificationClient.cpp
+ components/ble/DfuService.cpp
+ components/ble/CurrentTimeService.cpp
+ components/ble/AlertNotificationService.cpp
+ components/ble/MusicService.cpp
+ components/ble/BatteryInformationService.cpp
+ components/ble/ImmediateAlertService.cpp
+ components/ble/ServiceDiscovery.cpp
+ components/firmwarevalidator/FirmwareValidator.cpp
+ drivers/Cst816s.cpp
+ FreeRTOS/port.c
+ FreeRTOS/port_cmsis_systick.c
+ FreeRTOS/port_cmsis.c
+
+ displayapp/LittleVgl.cpp
+ displayapp/fonts/jetbrains_mono_extrabold_compressed.c
+ displayapp/fonts/jetbrains_mono_bold_20.c
+
+ systemtask/SystemTask.cpp
+ drivers/TwiMaster.cpp
+ )
list(APPEND GRAPHICS_SOURCE_FILES
- # FreeRTOS
- FreeRTOS/port.c
- FreeRTOS/port_cmsis_systick.c
- FreeRTOS/port_cmsis.c
+ # FreeRTOS
+ FreeRTOS/port.c
+ FreeRTOS/port_cmsis_systick.c
+ FreeRTOS/port_cmsis.c
- drivers/SpiNorFlash.cpp
- drivers/SpiMaster.cpp
- drivers/Spi.cpp
- Logging/NrfLogger.cpp
+ drivers/SpiNorFlash.cpp
+ drivers/SpiMaster.cpp
+ drivers/Spi.cpp
+ logging/NrfLogger.cpp
- Components/Gfx/Gfx.cpp
- drivers/St7789.cpp
- Components/Brightness/BrightnessController.cpp
+ components/gfx/Gfx.cpp
+ drivers/St7789.cpp
+ components/brightness/BrightnessController.cpp
- graphics.cpp
-)
+ graphics.cpp
+ )
set(INCLUDE_FILES
- Logging/Logger.h
- Logging/NrfLogger.h
- DisplayApp/DisplayApp.h
- DisplayApp/TouchEvents.h
- DisplayApp/Screens/Screen.h
- DisplayApp/Screens/Clock.h
- DisplayApp/Screens/Tile.h
- DisplayApp/Screens/Meter.h
- DisplayApp/Screens/Gauge.h
- DisplayApp/Screens/InfiniPaint.h
- DisplayApp/Screens/DropDownDemo.h
- DisplayApp/Screens/Modal.h
- DisplayApp/Screens/BatteryIcon.h
- DisplayApp/Screens/BleIcon.cpp
- DisplayApp/Screens/Brightness.h
- DisplayApp/Screens/SystemInfo.h
- DisplayApp/Screens/ScreenList.h
- DisplayApp/Screens/Label.h
- DisplayApp/Screens/FirmwareUpdate.h
- DisplayApp/Screens/FirmwareValidation.h
- DisplayApp/Screens/ApplicationList.h
- DisplayApp/Apps.h
- drivers/St7789.h
- drivers/SpiNorFlash.h
- drivers/SpiMaster.h
- drivers/Spi.h
- drivers/Watchdog.h
- drivers/DebugPins.h
- drivers/InternalFlash.h
- Components/Battery/BatteryController.h
- Components/Ble/BleController.h
- Components/Ble/NotificationManager.h
- Components/DateTime/DateTimeController.h
- Components/Brightness/BrightnessController.h
- Components/Ble/NimbleController.h
- Components/Ble/DeviceInformationService.h
- Components/Ble/CurrentTimeClient.h
- Components/Ble/AlertNotificationClient.h
- Components/Ble/DfuService.h
- Components/FirmwareValidator/FirmwareValidator.h
- drivers/Cst816s.h
- FreeRTOS/portmacro.h
- FreeRTOS/portmacro_cmsis.h
- libs/date/includes/date/tz.h
- libs/date/includes/date/chrono_io.h
- libs/date/includes/date/date.h
- libs/date/includes/date/islamic.h
- libs/date/includes/date/iso_week.h
- libs/date/includes/date/julian.h
- libs/date/includes/date/ptz.h
- libs/date/includes/date/tz_private.h
- DisplayApp/LittleVgl.h
- SystemTask/SystemTask.h
- SystemTask/SystemMonitor.h
- DisplayApp/Screens/Symbols.h
- drivers/TwiMaster.h
-)
+ BootloaderVersion.h
+ logging/Logger.h
+ logging/NrfLogger.h
+ displayapp/DisplayApp.h
+ displayapp/TouchEvents.h
+ displayapp/screens/Screen.h
+ displayapp/screens/Clock.h
+ displayapp/screens/Tile.h
+ displayapp/screens/Meter.h
+ displayapp/screens/Gauge.h
+ displayapp/screens/InfiniPaint.h
+ displayapp/screens/DropDownDemo.h
+ displayapp/screens/Modal.h
+ displayapp/screens/BatteryIcon.h
+ displayapp/screens/BleIcon.h
+ displayapp/screens/NotificationIcon.h
+ displayapp/screens/Brightness.h
+ displayapp/screens/SystemInfo.h
+ displayapp/screens/ScreenList.h
+ displayapp/screens/Label.h
+ displayapp/screens/FirmwareUpdate.h
+ displayapp/screens/FirmwareValidation.h
+ displayapp/screens/ApplicationList.h
+ displayapp/Apps.h
+ displayapp/screens/Notifications.h
+ drivers/St7789.h
+ drivers/SpiNorFlash.h
+ drivers/SpiMaster.h
+ drivers/Spi.h
+ drivers/Watchdog.h
+ drivers/DebugPins.h
+ drivers/InternalFlash.h
+ components/battery/BatteryController.h
+ components/ble/BleController.h
+ components/ble/NotificationManager.h
+ components/datetime/DateTimeController.h
+ components/brightness/BrightnessController.h
+ components/ble/NimbleController.h
+ components/ble/DeviceInformationService.h
+ components/ble/CurrentTimeClient.h
+ components/ble/AlertNotificationClient.h
+ components/ble/DfuService.h
+ components/firmwarevalidator/FirmwareValidator.h
+ components/ble/BatteryInformationService.h
+ components/ble/ImmediateAlertService.h
+ components/ble/ServiceDiscovery.h
+ components/ble/BleClient.h
+ drivers/Cst816s.h
+ FreeRTOS/portmacro.h
+ FreeRTOS/portmacro_cmsis.h
+ libs/date/includes/date/tz.h
+ libs/date/includes/date/chrono_io.h
+ libs/date/includes/date/date.h
+ libs/date/includes/date/islamic.h
+ libs/date/includes/date/iso_week.h
+ libs/date/includes/date/julian.h
+ libs/date/includes/date/ptz.h
+ libs/date/includes/date/tz_private.h
+ displayapp/LittleVgl.h
+ systemtask/SystemTask.h
+ systemtask/SystemMonitor.h
+ displayapp/screens/Symbols.h
+ drivers/TwiMaster.h
+ )
include_directories(
- .
- ../
- libs/
- FreeRTOS/
- libs/date/includes
- libs/mynewt-nimble/porting/npl/freertos/include
- libs/mynewt-nimble/nimble/include
- libs/mynewt-nimble/porting/nimble/include
- libs/mynewt-nimble/nimble/host/include
- libs/mynewt-nimble/nimble/controller/include
- libs/mynewt-nimble/nimble/transport/ram/include
- libs/mynewt-nimble/nimble/drivers/nrf52/include
- libs/mynewt-nimble/ext/tinycrypt/include
- libs/mynewt-nimble/nimble/host/services/gap/include
- libs/mynewt-nimble/nimble/host/services/gatt/include
- libs/mynewt-nimble/nimble/host/util/include
- libs/mynewt-nimble/nimble/host/store/ram/include
-
- "${NRF5_SDK_PATH}/components/drivers_nrf/nrf_soc_nosd"
+ .
+ ../
+ libs/
+ FreeRTOS/
+ libs/date/includes
+ libs/mynewt-nimble/porting/npl/freertos/include
+ libs/mynewt-nimble/nimble/include
+ libs/mynewt-nimble/porting/nimble/include
+ libs/mynewt-nimble/nimble/host/include
+ libs/mynewt-nimble/nimble/controller/include
+ libs/mynewt-nimble/nimble/transport/ram/include
+ libs/mynewt-nimble/nimble/drivers/nrf52/include
+ libs/mynewt-nimble/ext/tinycrypt/include
+ libs/mynewt-nimble/nimble/host/services/gap/include
+ libs/mynewt-nimble/nimble/host/services/gatt/include
+ libs/mynewt-nimble/nimble/host/util/include
+ libs/mynewt-nimble/nimble/host/store/ram/include
+
+ "${NRF5_SDK_PATH}/components/drivers_nrf/nrf_soc_nosd"
"${NRF5_SDK_PATH}/components"
"${NRF5_SDK_PATH}/components/boards"
"${NRF5_SDK_PATH}/components/softdevice/common"
@@ -544,11 +559,11 @@ include_directories(
)
link_directories(
- ../
+ ../
)
-set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type)
+set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wno-unknown-pragmas -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type)
add_definitions(-DCONFIG_GPIO_AS_PINRESET)
add_definitions(-DDEBUG)
add_definitions(-DNIMBLE_CFG_CONTROLLER)
@@ -559,52 +574,52 @@ add_definitions(-DDEBUG_NRF_USER)
add_definitions(-D__STACK_SIZE=8192)
add_definitions(-D__HEAP_SIZE=8192)
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "Release")
-endif()
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Release")
+endif ()
# NRF SDK
add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES})
target_include_directories(nrf-sdk SYSTEM PUBLIC . ../)
target_include_directories(nrf-sdk SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
target_compile_options(nrf-sdk PRIVATE
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
- )
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
+ )
# NimBLE
add_library(nimble STATIC ${NIMBLE_SRC} ${TINYCRYPT_SRC})
target_include_directories(nimble SYSTEM PUBLIC . ../)
target_include_directories(nimble SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
target_compile_options(nimble PRIVATE
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
- $<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
- )
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
+ $<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
+ )
# lvgl
add_library(lvgl STATIC ${LVGL_SRC})
target_include_directories(lvgl SYSTEM PUBLIC . ../)
target_include_directories(lvgl SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
target_compile_options(lvgl PRIVATE
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
- )
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
+ )
# Build autonomous binary (without support for bootloader)
set(EXECUTABLE_NAME "pinetime-app")
set(EXECUTABLE_FILE_NAME ${EXECUTABLE_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld")
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})
-set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME})
+set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME})
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl)
target_compile_options(${EXECUTABLE_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
@@ -612,7 +627,7 @@ target_compile_options(${EXECUTABLE_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
-)
+ )
set_target_properties(${EXECUTABLE_NAME} PROPERTIES
SUFFIX ".out"
@@ -637,7 +652,7 @@ set(DFU_FILE_NAME dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pine
set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld")
add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES})
target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl)
-set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME})
+set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME})
target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
@@ -659,39 +674,39 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.bin"
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.hex"
COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_FILE_NAME}"
-)
+ )
# Build binary that writes the graphic assets for the bootloader
set(EXECUTABLE_GRAPHICS_NAME "pinetime-graphics")
set(EXECUTABLE_GRAPHICS_FILE_NAME ${EXECUTABLE_GRAPHICS_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
add_executable(${EXECUTABLE_GRAPHICS_NAME} ${GRAPHICS_SOURCE_FILES})
target_link_libraries(${EXECUTABLE_GRAPHICS_NAME} nrf-sdk)
-set_target_properties(${EXECUTABLE_GRAPHICS_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_GRAPHICS_FILE_NAME})
+set_target_properties(${EXECUTABLE_GRAPHICS_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_GRAPHICS_FILE_NAME})
target_compile_options(${EXECUTABLE_GRAPHICS_NAME} PUBLIC
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
- )
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
+ )
set_target_properties(${EXECUTABLE_GRAPHICS_NAME} PROPERTIES
- SUFFIX ".out"
- LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map"
- CXX_STANDARD 11
- C_STANDARD 99
- )
+ SUFFIX ".out"
+ LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map"
+ CXX_STANDARD 11
+ C_STANDARD 99
+ )
add_custom_command(TARGET ${EXECUTABLE_GRAPHICS_NAME}
- POST_BUILD
- COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_GRAPHICS_FILE_NAME}.out
- COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_GRAPHICS_FILE_NAME}.out "${EXECUTABLE_GRAPHICS_FILE_NAME}.bin"
- COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_GRAPHICS_FILE_NAME}.out "${EXECUTABLE_GRAPHICS_FILE_NAME}.hex"
- COMMENT "post build steps for ${EXECUTABLE_GRAPHICS_FILE_NAME}"
- )
+ POST_BUILD
+ COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_GRAPHICS_FILE_NAME}.out
+ COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_GRAPHICS_FILE_NAME}.out "${EXECUTABLE_GRAPHICS_FILE_NAME}.bin"
+ COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_GRAPHICS_FILE_NAME}.out "${EXECUTABLE_GRAPHICS_FILE_NAME}.hex"
+ COMMENT "post build steps for ${EXECUTABLE_GRAPHICS_FILE_NAME}"
+ )
# FLASH
-if(USE_JLINK)
+if (USE_JLINK)
add_custom_target(FLASH_ERASE
COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
COMMENT "erasing flashing"
@@ -704,26 +719,53 @@ if(USE_JLINK)
COMMENT "flashing ${EXECUTABLE_NAME}.hex"
)
-elseif(USE_GDB_CLIENT)
+elseif (USE_GDB_CLIENT)
add_custom_target(FLASH_ERASE
COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'mon erase_mass'
COMMENT "erasing flashing"
)
add_custom_target("FLASH_${EXECUTABLE_NAME}"
DEPENDS ${EXECUTABLE_NAME}
- COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${EXECUTABLE_NAME}.hex
- COMMENT "flashing ${EXECUTABLE_NAME}.hex"
- )
-elseif(USE_OPENOCD)
- add_custom_target(FLASH_ERASE
- COMMAND ${OPENOCD_BIN_PATH} -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c init -c halt -c 'nrf5 mass_erase' -c reset -c shutdown
- COMMENT "erasing flashing"
- )
- add_custom_target("FLASH_${EXECUTABLE_NAME}"
- DEPENDS ${EXECUTABLE_NAME}
- COMMAND ${OPENOCD_BIN_PATH} -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c "program \"${EXECUTABLE_NAME}.hex\"" -c reset -c shutdown
+ COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${EXECUTABLE_NAME}.hex
COMMENT "flashing ${EXECUTABLE_NAME}.hex"
)
-
-endif()
-
+elseif (USE_OPENOCD)
+ if (USE_CMSIS_DAP)
+ add_custom_target(FLASH_ERASE
+ COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface/cmsis-dap.cfg]' -c 'transport select swd'
+ -c 'source [find target/nrf52.cfg]'
+ -c 'init'
+ -c 'halt'
+ -c 'nrf5 mass_erase'
+ -c 'halt'
+ -c 'reset'
+ -c 'exit'
+ COMMENT "erasing flashing"
+ )
+ add_custom_target("FLASH_${EXECUTABLE_NAME}"
+ DEPENDS ${EXECUTABLE_NAME}
+ COMMAND ${OPENOCD_BIN_PATH}
+ -c 'tcl_port disabled'
+ -c 'gdb_port 3333'
+ -c 'telnet_port 4444'
+ -c 'source [find interface/cmsis-dap.cfg]'
+ -c 'transport select swd'
+ -c 'source [find target/nrf52.cfg]'
+ -c 'halt'
+ -c "program \"${EXECUTABLE_NAME}.hex\""
+ -c 'reset'
+ -c 'shutdown'
+ COMMENT "flashing ${EXECUTABLE_NAME}.hex"
+ )
+ else ()
+ add_custom_target(FLASH_ERASE
+ COMMAND ${OPENOCD_BIN_PATH} -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c init -c halt -c 'nrf5 mass_erase' -c reset -c shutdown
+ COMMENT "erasing flashing"
+ )
+ add_custom_target("FLASH_${EXECUTABLE_NAME}"
+ DEPENDS ${EXECUTABLE_NAME}
+ COMMAND ${OPENOCD_BIN_PATH} -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c "program \"${EXECUTABLE_NAME}.hex\"" -c reset -c shutdown
+ COMMENT "flashing ${EXECUTABLE_NAME}.hex"
+ )
+ endif ()
+endif ()
diff --git a/src/Components/Ble/AlertNotificationClient.cpp b/src/Components/Ble/AlertNotificationClient.cpp
deleted file mode 100644
index 3e4b495..0000000
--- a/src/Components/Ble/AlertNotificationClient.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#include <SystemTask/SystemTask.h>
-#include "NotificationManager.h"
-
-#include "AlertNotificationClient.h"
-
-
-using namespace Pinetime::Controllers;
-constexpr ble_uuid16_t AlertNotificationClient::ansServiceUuid;
-
-constexpr ble_uuid16_t AlertNotificationClient::supportedNewAlertCategoryUuid;
-constexpr ble_uuid16_t AlertNotificationClient::supportedUnreadAlertCategoryUuid ;
-constexpr ble_uuid16_t AlertNotificationClient::newAlertUuid;
-constexpr ble_uuid16_t AlertNotificationClient::unreadAlertStatusUuid;
-constexpr ble_uuid16_t AlertNotificationClient::controlPointUuid;
-
-int Pinetime::Controllers::NewAlertSubcribeCallback(uint16_t conn_handle,
- const struct ble_gatt_error *error,
- struct ble_gatt_attr *attr,
- void *arg) {
- auto client = static_cast<AlertNotificationClient*>(arg);
- return client->OnNewAlertSubcribe(conn_handle, error, attr);
-}
-
-AlertNotificationClient::AlertNotificationClient(Pinetime::System::SystemTask& systemTask,
- Pinetime::Controllers::NotificationManager& notificationManager) :
- systemTask{systemTask}, notificationManager{notificationManager}{
-
-}
-
-bool AlertNotificationClient::OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error, const ble_gatt_svc *service) {
- if(service == nullptr && error->status == BLE_HS_EDONE) {
- NRF_LOG_INFO("ANS Discovery complete");
- return true;
- }
-
- if(service != nullptr && ble_uuid_cmp(((ble_uuid_t*)&ansServiceUuid), &service->uuid.u) == 0) {
- NRF_LOG_INFO("ANS discovered : 0x%x", service->start_handle);
- ansStartHandle = service->start_handle;
- ansEndHandle = service->end_handle;
- isDiscovered = true;
- }
- return false;
-}
-
-int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
- const ble_gatt_chr *characteristic) {
- if(error->status != 0 && error->status != BLE_HS_EDONE) {
- NRF_LOG_INFO("ANS Characteristic discovery ERROR");
- return 0;
- }
-
- if(characteristic == nullptr && error->status == BLE_HS_EDONE) {
- NRF_LOG_INFO("ANS Characteristic discovery complete");
- } else {
- if(characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*)&supportedNewAlertCategoryUuid), &characteristic->uuid.u) == 0) {
- NRF_LOG_INFO("ANS Characteristic discovered : supportedNewAlertCategoryUuid");
- supportedNewAlertCategoryHandle = characteristic->val_handle;
- } else if(characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*)&supportedUnreadAlertCategoryUuid), &characteristic->uuid.u) == 0) {
- NRF_LOG_INFO("ANS Characteristic discovered : supportedUnreadAlertCategoryUuid");
- supportedUnreadAlertCategoryHandle = characteristic->val_handle;
- } else if(characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*)&newAlertUuid), &characteristic->uuid.u) == 0) {
- NRF_LOG_INFO("ANS Characteristic discovered : newAlertUuid");
- newAlertHandle = characteristic->val_handle;
- newAlertDefHandle = characteristic->def_handle;
- } else if(characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*)&unreadAlertStatusUuid), &characteristic->uuid.u) == 0) {
- NRF_LOG_INFO("ANS Characteristic discovered : unreadAlertStatusUuid");
- unreadAlertStatusHandle = characteristic->val_handle;
- } else if(characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*)&controlPointUuid), &characteristic->uuid.u) == 0) {
- NRF_LOG_INFO("ANS Characteristic discovered : controlPointUuid");
- controlPointHandle = characteristic->val_handle;
- }else
- NRF_LOG_INFO("ANS Characteristic discovered : 0x%x", characteristic->val_handle);
- }
- return 0;
-}
-
-int AlertNotificationClient::OnNewAlertSubcribe(uint16_t connectionHandle, const ble_gatt_error *error,
- ble_gatt_attr *attribute) {
- if(error->status == 0) {
- NRF_LOG_INFO("ANS New alert subscribe OK");
- } else {
- NRF_LOG_INFO("ANS New alert subscribe ERROR");
- }
-
- return 0;
-}
-
-int AlertNotificationClient::OnDescriptorDiscoveryEventCallback(uint16_t connectionHandle, const ble_gatt_error *error,
- uint16_t characteristicValueHandle,
- const ble_gatt_dsc *descriptor) {
- if(error->status == 0) {
- if(characteristicValueHandle == newAlertHandle && ble_uuid_cmp(((ble_uuid_t*)&newAlertUuid), &descriptor->uuid.u)) {
- if(newAlertDescriptorHandle == 0) {
- NRF_LOG_INFO("ANS Descriptor discovered : %d", descriptor->handle);
- newAlertDescriptorHandle = descriptor->handle;
- uint8_t value[2];
- value[0] = 1;
- value[1] = 0;
- ble_gattc_write_flat(connectionHandle, newAlertDescriptorHandle, value, sizeof(value), NewAlertSubcribeCallback, this);
- }
- }
- }
- return 0;
-}
-
-void AlertNotificationClient::OnNotification(ble_gap_event *event) {
- if(event->notify_rx.attr_handle == newAlertHandle) {
- // TODO implement this with more memory safety (and constexpr)
- static const size_t maxBufferSize{21};
- static const size_t maxMessageSize{18};
- size_t bufferSize = min(OS_MBUF_PKTLEN(event->notify_rx.om), maxBufferSize);
-
- uint8_t data[bufferSize];
- os_mbuf_copydata(event->notify_rx.om, 0, bufferSize, data);
-
- char *s = (char *) &data[3];
- auto messageSize = min(maxMessageSize, (bufferSize-3));
-
- for (uint i = 0; i < messageSize-1; i++) {
- if (s[i] == 0x00) {
- s[i] = 0x0A;
- }
- }
- s[messageSize-1] = '\0';
-
- notificationManager.Push(Pinetime::Controllers::NotificationManager::Categories::SimpleAlert, s, messageSize);
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
- }
-}
-
-bool AlertNotificationClient::IsDiscovered() const {
- return isDiscovered;
-}
-
-uint16_t AlertNotificationClient::StartHandle() const {
- return ansStartHandle;
-}
-
-uint16_t AlertNotificationClient::EndHandle() const {
- return ansEndHandle;
-}
-
-uint16_t AlertNotificationClient::NewAlerthandle() const {
- return newAlertHandle;
-}
diff --git a/src/Components/Ble/CurrentTimeClient.cpp b/src/Components/Ble/CurrentTimeClient.cpp
deleted file mode 100644
index 7a225f4..0000000
--- a/src/Components/Ble/CurrentTimeClient.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <hal/nrf_rtc.h>
-#include "CurrentTimeClient.h"
-
-using namespace Pinetime::Controllers;
-
-constexpr ble_uuid16_t CurrentTimeClient::ctsServiceUuid;
-constexpr ble_uuid16_t CurrentTimeClient::currentTimeCharacteristicUuid;
-
-CurrentTimeClient::CurrentTimeClient(DateTime& dateTimeController) : dateTimeController{dateTimeController} {
-
-}
-
-void CurrentTimeClient::Init() {
-
-}
-
-bool CurrentTimeClient::OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error, const ble_gatt_svc *service) {
- if(service == nullptr && error->status == BLE_HS_EDONE) {
- NRF_LOG_INFO("CTS Discovery complete");
- return true;
- }
-
- if(service != nullptr && ble_uuid_cmp(((ble_uuid_t*)&ctsServiceUuid), &service->uuid.u) == 0) {
- NRF_LOG_INFO("CTS discovered : 0x%x", service->start_handle);
- isDiscovered = true;
- ctsStartHandle = service->start_handle;
- ctsEndHandle = service->end_handle;
- return false;
- }
- return false;
-}
-
-int CurrentTimeClient::OnCharacteristicDiscoveryEvent(uint16_t conn_handle, const ble_gatt_error *error,
- const ble_gatt_chr *characteristic) {
- if(characteristic == nullptr && error->status == BLE_HS_EDONE) {
- NRF_LOG_INFO("CTS Characteristic discovery complete");
- return 0;
- }
-
- if(characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*)&currentTimeCharacteristicUuid), &characteristic->uuid.u) == 0) {
- NRF_LOG_INFO("CTS Characteristic discovered : 0x%x", characteristic->val_handle);
- currentTimeHandle = characteristic->val_handle;
- }
- return 0;
-}
-
-int CurrentTimeClient::OnCurrentTimeReadResult(uint16_t conn_handle, const ble_gatt_error *error, const ble_gatt_attr *attribute) {
- if(error->status == 0) {
- // TODO check that attribute->handle equals the handle discovered in OnCharacteristicDiscoveryEvent
- CtsData result;
- os_mbuf_copydata(attribute->om, 0, sizeof(CtsData), &result);
- NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", result.year,
- result.month, result.dayofmonth,
- result.hour, result.minute, result.second);
- dateTimeController.SetTime(result.year, result.month, result.dayofmonth,
- 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG));
- } else {
- NRF_LOG_INFO("Error retrieving current time: %d", error->status);
- }
- return 0;
-}
-
-bool CurrentTimeClient::IsDiscovered() const {
- return isDiscovered;
-}
-
-uint16_t CurrentTimeClient::StartHandle() const {
- return ctsStartHandle;
-}
-
-uint16_t CurrentTimeClient::EndHandle() const {
- return ctsEndHandle;
-}
-
-uint16_t CurrentTimeClient::CurrentTimeHandle() const {
- return currentTimeHandle;
-} \ No newline at end of file
diff --git a/src/Components/Ble/MusicService.cpp b/src/Components/Ble/MusicService.cpp
deleted file mode 100644
index b5fa535..0000000
--- a/src/Components/Ble/MusicService.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-#include <SystemTask/SystemTask.h>
-#include "MusicService.h"
-
-int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
- auto musicService = static_cast<Pinetime::Controllers::MusicService*>(arg);
- return musicService->OnCommand(conn_handle, attr_handle, ctxt);
-}
-
-Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask &system) : m_system(system)
-{
- msUuid.value[11] = msId[0];
- msUuid.value[12] = msId[1];
- msEventCharUuid.value[11] = msEventCharId[0];
- msEventCharUuid.value[12] = msEventCharId[1];
- msStatusCharUuid.value[11] = msStatusCharId[0];
- msStatusCharUuid.value[12] = msStatusCharId[1];
- msTrackCharUuid.value[11] = msTrackCharId[0];
- msTrackCharUuid.value[12] = msTrackCharId[1];
- msArtistCharUuid.value[11] = msArtistCharId[0];
- msArtistCharUuid.value[12] = msArtistCharId[1];
- msAlbumCharUuid.value[11] = msAlbumCharId[0];
- msAlbumCharUuid.value[12] = msAlbumCharId[1];
-
- characteristicDefinition[0] = { .uuid = (ble_uuid_t*)(&msEventCharUuid),
- .access_cb = MSCallback,
- .arg = this,
- .flags = BLE_GATT_CHR_F_NOTIFY,
- .val_handle = &m_eventHandle
- };
- characteristicDefinition[1] = { .uuid = (ble_uuid_t*)(&msStatusCharUuid),
- .access_cb = MSCallback,
- .arg = this,
- .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
- };
- characteristicDefinition[2] = { .uuid = (ble_uuid_t*)(&msTrackCharUuid),
- .access_cb = MSCallback,
- .arg = this,
- .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
- };
- characteristicDefinition[3] = { .uuid = (ble_uuid_t*)(&msArtistCharUuid),
- .access_cb = MSCallback,
- .arg = this,
- .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
- };
- characteristicDefinition[4] = { .uuid = (ble_uuid_t*)(&msAlbumCharUuid),
- .access_cb = MSCallback,
- .arg = this,
- .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
- };
- characteristicDefinition[5] = {0};
-
- serviceDefinition[0] = {
- .type = BLE_GATT_SVC_TYPE_PRIMARY,
- .uuid = (ble_uuid_t *) &msUuid,
- .characteristics = characteristicDefinition
- };
- serviceDefinition[1] = {0};
-
- m_artist = "Waiting for";
- m_album = "";
- m_track = "track information...";
-}
-
-void Pinetime::Controllers::MusicService::Init()
-{
- int res = 0;
- res = ble_gatts_count_cfg(serviceDefinition);
- ASSERT(res == 0);
-
- res = ble_gatts_add_svcs(serviceDefinition);
- ASSERT(res == 0);
-}
-
-int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle,
- struct ble_gatt_access_ctxt *ctxt) {
-
- if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
- size_t notifSize = OS_MBUF_PKTLEN(ctxt->om);
- uint8_t data[notifSize + 1];
- data[notifSize] = '\0';
- os_mbuf_copydata(ctxt->om, 0, notifSize, data);
- char *s = (char *) &data[0];
- NRF_LOG_INFO("DATA : %s", s);
- if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msArtistCharUuid) == 0) {
- m_artist = s;
- } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msTrackCharUuid) == 0) {
- m_track = s;
- } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msAlbumCharUuid) == 0) {
- m_album = s;
- } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msStatusCharUuid) == 0) {
- m_status = s[0];
- }
- }
- return 0;
-}
-
-std::string Pinetime::Controllers::MusicService::album()
-{
- return m_album;
-}
-
-std::string Pinetime::Controllers::MusicService::artist()
-{
- return m_artist;
-}
-
-std::string Pinetime::Controllers::MusicService::track()
-{
- return m_track;
-}
-
-unsigned char Pinetime::Controllers::MusicService::status()
-{
- return m_status;
-}
-
-void Pinetime::Controllers::MusicService::event(char event)
-{
- auto *om = ble_hs_mbuf_from_flat(&event, 1);
-
- uint16_t connectionHandle = m_system.nimble().connHandle();
-
- if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
- return;
- }
-
- ble_gattc_notify_custom(connectionHandle, m_eventHandle, om);
-}
-
diff --git a/src/Components/Ble/MusicService.h b/src/Components/Ble/MusicService.h
deleted file mode 100644
index ab6db57..0000000
--- a/src/Components/Ble/MusicService.h
+++ /dev/null
@@ -1,92 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include <array>
-#include <host/ble_gap.h>
-#include <host/ble_uuid.h>
-#include <string>
-
-//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}
-
-namespace Pinetime {
- namespace System {
- class SystemTask;
- }
- namespace Controllers {
-
- class MusicService {
- public:
- MusicService(Pinetime::System::SystemTask &system);
- void Init();
- int OnCommand(uint16_t conn_handle, uint16_t attr_handle,
- struct ble_gatt_access_ctxt *ctxt);
-
- std::string artist();
- std::string track();
- std::string album();
- unsigned char status();
-
- void event(char event);
-
- static const char EVENT_MUSIC_OPEN = 0xe0;
- static const char EVENT_MUSIC_PLAY = 0x00;
- static const char EVENT_MUSIC_PAUSE = 0x01;
- static const char EVENT_MUSIC_NEXT = 0x03;
- static const char EVENT_MUSIC_PREV = 0x04;
- static const char EVENT_MUSIC_VOLUP = 0x05;
- static const char EVENT_MUSIC_VOLDOWN = 0x06;
- static const char STATUS_MUSIC_PAUSED = 0x00;
- static const char STATUS_MUSIC_PLAYING = 0x01;
-
- private:
- static constexpr uint8_t msId[2] = {0x00, 0x01};
- static constexpr uint8_t msEventCharId[2] = {0x00, 0x02};
- static constexpr uint8_t msStatusCharId[2] = {0x00, 0x03};
- static constexpr uint8_t msArtistCharId[2] = {0x00, 0x04};
- static constexpr uint8_t msTrackCharId[2] = {0x00, 0x05};
- static constexpr uint8_t msAlbumCharId[2] = {0x00, 0x06};
-
- ble_uuid128_t msUuid {
- .u = { .type = BLE_UUID_TYPE_128 },
- .value = MUSIC_SERVICE_UUID_BASE
- };
-
- ble_uuid128_t msEventCharUuid {
- .u = { .type = BLE_UUID_TYPE_128 },
- .value = MUSIC_SERVICE_UUID_BASE
- };
- ble_uuid128_t msStatusCharUuid {
- .u = { .type = BLE_UUID_TYPE_128 },
- .value = MUSIC_SERVICE_UUID_BASE
- };
- ble_uuid128_t msArtistCharUuid {
- .u = { .type = BLE_UUID_TYPE_128 },
- .value = MUSIC_SERVICE_UUID_BASE
- };
- ble_uuid128_t msTrackCharUuid {
- .u = { .type = BLE_UUID_TYPE_128 },
- .value = MUSIC_SERVICE_UUID_BASE
- };
- ble_uuid128_t msAlbumCharUuid {
- .u = { .type = BLE_UUID_TYPE_128 },
- .value = MUSIC_SERVICE_UUID_BASE
- };
-
- struct ble_gatt_chr_def characteristicDefinition[6];
- struct ble_gatt_svc_def serviceDefinition[2];
-
- uint16_t m_eventHandle;
-
- std::string m_artist;
- std::string m_album;
- std::string m_track;
-
- unsigned char m_status;
-
- Pinetime::System::SystemTask& m_system;
-
- };
- }
-}
-
diff --git a/src/Components/Ble/NotificationManager.cpp b/src/Components/Ble/NotificationManager.cpp
deleted file mode 100644
index 0aea069..0000000
--- a/src/Components/Ble/NotificationManager.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <cstring>
-#include "NotificationManager.h"
-
-using namespace Pinetime::Controllers;
-
-void NotificationManager::Push(Pinetime::Controllers::NotificationManager::Categories category,
- const char *message, uint8_t currentMessageSize) {
- // TODO handle edge cases on read/write index
- auto checkedSize = std::min(currentMessageSize, uint8_t{18});
- auto& notif = notifications[writeIndex];
- std::memcpy(notif.message.data(), message, checkedSize);
- notif.message[checkedSize] = '\0';
- notif.category = category;
-
- writeIndex = (writeIndex + 1 < TotalNbNotifications) ? writeIndex + 1 : 0;
- if(!empty && writeIndex == readIndex)
- readIndex = writeIndex + 1;
-}
-
-NotificationManager::Notification Pinetime::Controllers::NotificationManager::Pop() {
-// TODO handle edge cases on read/write index
- NotificationManager::Notification notification = notifications[readIndex];
-
- if(readIndex != writeIndex) {
- readIndex = (readIndex + 1 < TotalNbNotifications) ? readIndex + 1 : 0;
- }
-
- // TODO Check move optimization on return
- return notification;
-}
diff --git a/src/Components/Ble/NotificationManager.h b/src/Components/Ble/NotificationManager.h
deleted file mode 100644
index daa1571..0000000
--- a/src/Components/Ble/NotificationManager.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-
-#include <array>
-
-namespace Pinetime {
- namespace Controllers {
- class NotificationManager {
- public:
- enum class Categories {Unknown, SimpleAlert, Email, News, IncomingCall, MissedCall, Sms, VoiceMail, Schedule, HighProriotyAlert, InstantMessage };
- static constexpr uint8_t MessageSize{18};
-
- struct Notification {
- std::array<char, MessageSize+1> message;
- Categories category = Categories::Unknown;
- };
-
- void Push(Categories category, const char* message, uint8_t messageSize);
- Notification Pop();
-
-
- private:
- static constexpr uint8_t TotalNbNotifications = 5;
- std::array<Notification, TotalNbNotifications> notifications;
- uint8_t readIndex = 0;
- uint8_t writeIndex = 0;
- bool empty = true;
- };
- }
-} \ No newline at end of file
diff --git a/src/DisplayApp/Screens/InfiniPaint.h b/src/DisplayApp/Screens/InfiniPaint.h
deleted file mode 100644
index a1592f9..0000000
--- a/src/DisplayApp/Screens/InfiniPaint.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include <drivers/St7789.h>
-#include <DisplayApp/LittleVgl.h>
-
-namespace Pinetime {
- namespace Applications {
- namespace Screens {
-
- class InfiniPaint : public Screen{
- public:
- InfiniPaint(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
- ~InfiniPaint() override;
-
- bool Refresh() override;
- bool OnButtonPushed() override;
- bool OnTouchEvent(TouchEvents event) override;
- bool OnTouchEvent(uint16_t x, uint16_t y) override;
-
- private:
- Pinetime::Components::LittleVgl& lvgl;
- static constexpr uint16_t width = 10;
- static constexpr uint16_t height = 10;
- static constexpr uint16_t bufferSize = width*height;
- lv_color_t b[bufferSize];
- bool running = true;
- };
- }
- }
-}
diff --git a/src/DisplayApp/Screens/Music.cpp b/src/DisplayApp/Screens/Music.cpp
deleted file mode 100644
index 9b7d198..0000000
--- a/src/DisplayApp/Screens/Music.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <libs/lvgl/lvgl.h>
-#include "Music.h"
-
-using namespace Pinetime::Applications::Screens;
-extern lv_font_t jetbrains_mono_extrabold_compressed;
-extern lv_font_t jetbrains_mono_bold_20;
-
-static void event_handler(lv_obj_t * obj, lv_event_t event)
-{
- Music* screen = static_cast<Music *>(obj->user_data);
- screen->OnObjectEvent(obj, event);
-}
-
-Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::MusicService &music) : Screen(app), musicService(music) {
- lv_obj_t * label;
-
- btnVolDown = lv_btn_create(lv_scr_act(), NULL);
- btnVolDown->user_data = this;
- lv_obj_set_event_cb(btnVolDown, event_handler);
- lv_obj_align(btnVolDown, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 10);
- label = lv_label_create(btnVolDown, NULL);
- lv_label_set_text(label, "v-");
-
- btnVolUp = lv_btn_create(lv_scr_act(), NULL);
- btnVolUp->user_data = this;
- lv_obj_set_event_cb(btnVolUp, event_handler);
- lv_obj_align(btnVolUp, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, 10);
- label = lv_label_create(btnVolUp, NULL);
- lv_label_set_text(label, "v+");
-
- btnPrev = lv_btn_create(lv_scr_act(), NULL);
- btnPrev->user_data = this;
- lv_obj_set_event_cb(btnPrev, event_handler);
- lv_obj_set_size(btnPrev, LV_HOR_RES / 4, LV_VER_RES / 4);
- lv_obj_align(btnPrev, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 10,-10);
- label = lv_label_create(btnPrev, NULL);
- lv_label_set_text(label, "<<");
-
- btnPlayPause = lv_btn_create(lv_scr_act(), NULL);
- btnPlayPause->user_data = this;
- lv_obj_set_event_cb(btnPlayPause, event_handler);
- lv_obj_set_size(btnPlayPause, LV_HOR_RES / 4, LV_VER_RES / 4);
- lv_obj_align(btnPlayPause, NULL, LV_ALIGN_IN_BOTTOM_MID, 0,-10);
- txtPlayPause = lv_label_create(btnPlayPause, NULL);
- lv_label_set_text(txtPlayPause, ">");
-
- btnNext = lv_btn_create(lv_scr_act(), NULL);
- btnNext->user_data = this;
- lv_obj_set_event_cb(btnNext, event_handler);
- lv_obj_set_size(btnNext, LV_HOR_RES / 4, LV_VER_RES / 4);
- lv_obj_align(btnNext, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, -10,-10);
- label = lv_label_create(btnNext, NULL);
- lv_label_set_text(label, ">>");
-
- txtArtist = lv_label_create(lv_scr_act(), NULL);
- lv_label_set_long_mode(txtArtist, LV_LABEL_LONG_SROLL);
- lv_obj_align(txtArtist, NULL, LV_ALIGN_IN_LEFT_MID, 0,-20);
- lv_label_set_text(txtArtist, "Artist Name");
- lv_label_set_align(txtArtist, LV_LABEL_ALIGN_CENTER);
- lv_obj_set_width(txtArtist, LV_HOR_RES);
-
- txtTrack = lv_label_create(lv_scr_act(), NULL);
- lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_DOT);
- lv_obj_align(txtTrack, NULL, LV_ALIGN_IN_LEFT_MID, 0,20);
- lv_label_set_text(txtTrack, "This is a very long track name");
- lv_label_set_align(txtTrack, LV_LABEL_ALIGN_CENTER);
- lv_obj_set_width(txtTrack, LV_HOR_RES);
-
- musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
-}
-
-Music::~Music() {
- lv_obj_clean(lv_scr_act());
-}
-
-bool Music::OnButtonPushed() {
- running = false;
- return true;
-}
-
-bool Music::Refresh() {
-
- if (m_artist != musicService.artist()) {
- m_artist = musicService.artist();
- lv_label_set_text(txtArtist, m_artist.data());
- }
- if (m_track != musicService.track()) {
- m_track = musicService.track();
- lv_label_set_text(txtTrack, m_track.data());
- }
- if (m_album != musicService.album()) {
- m_album = musicService.album();
- }
- if (m_status != musicService.status()) {
- m_status = musicService.status();
- }
- if (m_status == Pinetime::Controllers::MusicService::STATUS_MUSIC_PLAYING) {
- lv_label_set_text(txtPlayPause, "||");
- } else {
- lv_label_set_text(txtPlayPause, ">");
- }
-
- return running;
-}
-
-void Music::OnObjectEvent(lv_obj_t* obj, lv_event_t event)
-{
- if (event == LV_EVENT_CLICKED) {
- if (obj == btnVolDown) {
- musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLDOWN);
- } else if (obj == btnVolUp) {
- musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLUP);
- } else if (obj == btnPrev) {
- musicService.event(Controllers::MusicService::EVENT_MUSIC_PREV);
- } else if (obj == btnPlayPause) {
- if (m_status == Pinetime::Controllers::MusicService::STATUS_MUSIC_PLAYING) {
- musicService.event(Controllers::MusicService::EVENT_MUSIC_PAUSE);
- } else {
- musicService.event(Controllers::MusicService::EVENT_MUSIC_PLAY);
- }
- } else if (obj == btnNext) {
- musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
- }
- }
-}
diff --git a/src/DisplayApp/Screens/Music.h b/src/DisplayApp/Screens/Music.h
deleted file mode 100644
index 95cac0f..0000000
--- a/src/DisplayApp/Screens/Music.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include <chrono>
-#include <Components/Gfx/Gfx.h>
-#include "Screen.h"
-#include <bits/unique_ptr.h>
-#include <libs/lvgl/src/lv_core/lv_style.h>
-#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include <Components/Battery/BatteryController.h>
-#include <Components/Ble/BleController.h>
-#include "../../Version.h"
-#include <Components/Ble/MusicService.h>
-#include <string>
-
-namespace Pinetime {
- namespace Applications {
- namespace Screens {
-
- class Music : public Screen{
- public:
- Music(DisplayApp* app, Pinetime::Controllers::MusicService &music);
- ~Music() override;
-
- bool Refresh() override;
- bool OnButtonPushed() override;
-
- void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
-
- private:
- lv_obj_t * btnPrev;
- lv_obj_t * btnPlayPause;
- lv_obj_t * btnNext;
- lv_obj_t * btnVolDown;
- lv_obj_t * btnVolUp;
- lv_obj_t * txtArtist;
- lv_obj_t * txtTrack;
- lv_obj_t * txtPlayPause;
-
- bool running = true;
- Pinetime::Controllers::MusicService &musicService;
- std::string m_artist;
- std::string m_album;
- std::string m_track;
- unsigned char m_status;
- };
- }
- }
-}
diff --git a/src/DisplayApp/Screens/Screen.h b/src/DisplayApp/Screens/Screen.h
deleted file mode 100644
index dbf81a4..0000000
--- a/src/DisplayApp/Screens/Screen.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include "../TouchEvents.h"
-
-namespace Pinetime {
- namespace Applications {
- class DisplayApp;
- namespace Screens {
- class Screen {
- public:
- Screen(DisplayApp* app) : app{app} {}
- virtual ~Screen() = default;
-
- // Return false if the app can be closed, true if it must continue to run
- virtual bool Refresh() = 0;
-
- // Return false if the button hasn't been handled by the app, true if it has been handled
- virtual bool OnButtonPushed() { return false; }
-
- // Return false if the event hasn't been handled by the app, true if it has been handled
- virtual bool OnTouchEvent(TouchEvents event) { return false; }
- virtual bool OnTouchEvent(uint16_t x, uint16_t y) { return false; }
-
- protected:
- DisplayApp* app;
- };
- }
- }
-}
diff --git a/src/Components/Battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index 198ce5a..571efae 100644
--- a/src/Components/Battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -1,6 +1,7 @@
#include <drivers/include/nrfx_saadc.h>
#include <hal/nrf_gpio.h>
#include <libraries/log/nrf_log.h>
+#include <algorithm>
#include "BatteryController.h"
using namespace Pinetime::Controllers;
@@ -34,7 +35,9 @@ void Battery::Update() {
// see https://forum.pine64.org/showthread.php?tid=8147
voltage = (value * 2.0f) / (1024/3.0f);
- percentRemaining = ((voltage - 3.55)*100)*3.9;
+ percentRemaining = ((voltage - 3.55f)*100.0f)*3.9f;
+ percentRemaining = std::max(percentRemaining, 0.0f);
+ percentRemaining = std::min(percentRemaining, 100.0f);
// NRF_LOG_INFO("BATTERY " NRF_LOG_FLOAT_MARKER " %% - " NRF_LOG_FLOAT_MARKER " v", NRF_LOG_FLOAT(percentRemaining), NRF_LOG_FLOAT(voltage));
// NRF_LOG_INFO("POWER Charging : %d - Power : %d", isCharging, isPowerPresent);
diff --git a/src/Components/Battery/BatteryController.h b/src/components/battery/BatteryController.h
index f07648a..f07648a 100644
--- a/src/Components/Battery/BatteryController.h
+++ b/src/components/battery/BatteryController.h
diff --git a/src/components/ble/AlertNotificationClient.cpp b/src/components/ble/AlertNotificationClient.cpp
new file mode 100644
index 0000000..abe4109
--- /dev/null
+++ b/src/components/ble/AlertNotificationClient.cpp
@@ -0,0 +1,194 @@
+#include <systemtask/SystemTask.h>
+#include "NotificationManager.h"
+
+#include "AlertNotificationClient.h"
+
+using namespace Pinetime::Controllers;
+constexpr ble_uuid16_t AlertNotificationClient::ansServiceUuid;
+constexpr ble_uuid16_t AlertNotificationClient::supportedNewAlertCategoryUuid;
+constexpr ble_uuid16_t AlertNotificationClient::supportedUnreadAlertCategoryUuid;
+constexpr ble_uuid16_t AlertNotificationClient::newAlertUuid;
+constexpr ble_uuid16_t AlertNotificationClient::unreadAlertStatusUuid;
+constexpr ble_uuid16_t AlertNotificationClient::controlPointUuid;
+
+namespace {
+ int
+ OnDiscoveryEventCallback(uint16_t conn_handle, const struct ble_gatt_error *error, const struct ble_gatt_svc *service,
+ void *arg) {
+ auto client = static_cast<AlertNotificationClient *>(arg);
+ return client->OnDiscoveryEvent(conn_handle, error, service);
+ }
+
+ int OnAlertNotificationCharacteristicDiscoveredCallback(uint16_t conn_handle, const struct ble_gatt_error *error,
+ const struct ble_gatt_chr *chr, void *arg) {
+ auto client = static_cast<AlertNotificationClient *>(arg);
+ return client->OnCharacteristicsDiscoveryEvent(conn_handle, error, chr);
+ }
+
+ int OnAlertNotificationDescriptorDiscoveryEventCallback(uint16_t conn_handle,
+ const struct ble_gatt_error *error,
+ uint16_t chr_val_handle,
+ const struct ble_gatt_dsc *dsc,
+ void *arg) {
+ auto client = static_cast<AlertNotificationClient *>(arg);
+ return client->OnDescriptorDiscoveryEventCallback(conn_handle, error, chr_val_handle, dsc);
+ }
+
+ int NewAlertSubcribeCallback(uint16_t conn_handle,
+ const struct ble_gatt_error *error,
+ struct ble_gatt_attr *attr,
+ void *arg) {
+ auto client = static_cast<AlertNotificationClient *>(arg);
+ return client->OnNewAlertSubcribe(conn_handle, error, attr);
+ }
+}
+
+AlertNotificationClient::AlertNotificationClient(Pinetime::System::SystemTask &systemTask,
+ Pinetime::Controllers::NotificationManager &notificationManager) :
+ systemTask{systemTask}, notificationManager{notificationManager} {
+}
+
+bool AlertNotificationClient::OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
+ const ble_gatt_svc *service) {
+ if (service == nullptr && error->status == BLE_HS_EDONE) {
+ if (isDiscovered) {
+ NRF_LOG_INFO("ANS Discovery found, starting characteristics discovery");
+
+ ble_gattc_disc_all_chrs(connectionHandle, ansStartHandle, ansEndHandle,
+ OnAlertNotificationCharacteristicDiscoveredCallback, this);
+ } else {
+ NRF_LOG_INFO("ANS not found");
+ onServiceDiscovered(connectionHandle);
+ }
+ return true;
+ }
+
+ if (service != nullptr && ble_uuid_cmp(((ble_uuid_t *) &ansServiceUuid), &service->uuid.u) == 0) {
+ NRF_LOG_INFO("ANS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
+ ansStartHandle = service->start_handle;
+ ansEndHandle = service->end_handle;
+ isDiscovered = true;
+ }
+ return false;
+}
+
+int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
+ const ble_gatt_chr *characteristic) {
+ if (error->status != 0 && error->status != BLE_HS_EDONE) {
+ NRF_LOG_INFO("ANS Characteristic discovery ERROR");
+ onServiceDiscovered(connectionHandle);
+ return 0;
+ }
+
+ if (characteristic == nullptr && error->status == BLE_HS_EDONE) {
+ NRF_LOG_INFO("ANS Characteristic discovery complete");
+ if (isCharacteristicDiscovered) {
+ ble_gattc_disc_all_dscs(connectionHandle,
+ newAlertHandle, ansEndHandle,
+ OnAlertNotificationDescriptorDiscoveryEventCallback, this);
+ } else
+ onServiceDiscovered(connectionHandle);
+ } else {
+ if (characteristic != nullptr &&
+ ble_uuid_cmp(((ble_uuid_t *) &supportedNewAlertCategoryUuid), &characteristic->uuid.u) == 0) {
+ NRF_LOG_INFO("ANS Characteristic discovered : supportedNewAlertCategoryUuid");
+ supportedNewAlertCategoryHandle = characteristic->val_handle;
+ } else if (characteristic != nullptr &&
+ ble_uuid_cmp(((ble_uuid_t *) &supportedUnreadAlertCategoryUuid), &characteristic->uuid.u) == 0) {
+ NRF_LOG_INFO("ANS Characteristic discovered : supportedUnreadAlertCategoryUuid");
+ supportedUnreadAlertCategoryHandle = characteristic->val_handle;
+ } else if (characteristic != nullptr &&
+ ble_uuid_cmp(((ble_uuid_t *) &newAlertUuid), &characteristic->uuid.u) == 0) {
+ NRF_LOG_INFO("ANS Characteristic discovered : newAlertUuid");
+ newAlertHandle = characteristic->val_handle;
+ newAlertDefHandle = characteristic->def_handle;
+ isCharacteristicDiscovered = true;
+ } else if (characteristic != nullptr &&
+ ble_uuid_cmp(((ble_uuid_t *) &unreadAlertStatusUuid), &characteristic->uuid.u) == 0) {
+ NRF_LOG_INFO("ANS Characteristic discovered : unreadAlertStatusUuid");
+ unreadAlertStatusHandle = characteristic->val_handle;
+ } else if (characteristic != nullptr &&
+ ble_uuid_cmp(((ble_uuid_t *) &controlPointUuid), &characteristic->uuid.u) == 0) {
+ NRF_LOG_INFO("ANS Characteristic discovered : controlPointUuid");
+ controlPointHandle = characteristic->val_handle;
+ } else NRF_LOG_INFO("ANS Characteristic discovered : 0x%x", characteristic->val_handle);
+ }
+ return 0;
+}
+
+int AlertNotificationClient::OnNewAlertSubcribe(uint16_t connectionHandle, const ble_gatt_error *error,
+ ble_gatt_attr *attribute) {
+ if (error->status == 0) {
+ NRF_LOG_INFO("ANS New alert subscribe OK");
+ } else {
+ NRF_LOG_INFO("ANS New alert subscribe ERROR");
+ }
+ onServiceDiscovered(connectionHandle);
+
+ return 0;
+}
+
+int AlertNotificationClient::OnDescriptorDiscoveryEventCallback(uint16_t connectionHandle, const ble_gatt_error *error,
+ uint16_t characteristicValueHandle,
+ const ble_gatt_dsc *descriptor) {
+ if (error->status == 0) {
+ if (characteristicValueHandle == newAlertHandle &&
+ ble_uuid_cmp(((ble_uuid_t *) &newAlertUuid), &descriptor->uuid.u)) {
+ if (newAlertDescriptorHandle == 0) {
+ NRF_LOG_INFO("ANS Descriptor discovered : %d", descriptor->handle);
+ newAlertDescriptorHandle = descriptor->handle;
+ isDescriptorFound = true;
+ uint8_t value[2];
+ value[0] = 1;
+ value[1] = 0;
+ ble_gattc_write_flat(connectionHandle, newAlertDescriptorHandle, value, sizeof(value), NewAlertSubcribeCallback, this);
+ }
+ }
+ } else {
+ if (!isDescriptorFound)
+ onServiceDiscovered(connectionHandle);
+ }
+ return 0;
+}
+
+void AlertNotificationClient::OnNotification(ble_gap_event *event) {
+ if (event->notify_rx.attr_handle == newAlertHandle) {
+ constexpr size_t stringTerminatorSize = 1; // end of string '\0'
+ constexpr size_t headerSize = 3;
+ const auto maxMessageSize{NotificationManager::MaximumMessageSize()};
+ 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));
+
+ NotificationManager::Notification notif;
+ os_mbuf_copydata(event->notify_rx.om, headerSize, messageSize - 1, notif.message.data());
+ notif.message[messageSize - 1] = '\0';
+ notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
+ notificationManager.Push(std::move(notif));
+
+ systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
+ }
+}
+
+void AlertNotificationClient::Reset() {
+ ansStartHandle = 0;
+ ansEndHandle = 0;
+ supportedNewAlertCategoryHandle = 0;
+ supportedUnreadAlertCategoryHandle = 0;
+ newAlertHandle = 0;
+ newAlertDescriptorHandle = 0;
+ newAlertDefHandle = 0;
+ unreadAlertStatusHandle = 0;
+ controlPointHandle = 0;
+ isDiscovered = false;
+ isCharacteristicDiscovered = false;
+ isDescriptorFound = false;
+}
+
+void AlertNotificationClient::Discover(uint16_t connectionHandle, std::function<void(uint16_t)> onServiceDiscovered) {
+ NRF_LOG_INFO("[ANS] Starting discovery");
+ this->onServiceDiscovered = onServiceDiscovered;
+ ble_gattc_disc_svc_by_uuid(connectionHandle, &ansServiceUuid.u, OnDiscoveryEventCallback, this);
+}
diff --git a/src/Components/Ble/AlertNotificationClient.h b/src/components/ble/AlertNotificationClient.h
index ca4f4e9..bc0df51 100644
--- a/src/Components/Ble/AlertNotificationClient.h
+++ b/src/components/ble/AlertNotificationClient.h
@@ -3,16 +3,12 @@
#include <cstdint>
#include <array>
#include <host/ble_gap.h>
+#include "BleClient.h"
namespace Pinetime {
namespace Controllers {
- int NewAlertSubcribeCallback(uint16_t conn_handle,
- const struct ble_gatt_error *error,
- struct ble_gatt_attr *attr,
- void *arg);
-
- class AlertNotificationClient {
+ class AlertNotificationClient : public BleClient {
public:
explicit AlertNotificationClient(Pinetime::System::SystemTask &systemTask,
Pinetime::Controllers::NotificationManager &notificationManager);
@@ -24,13 +20,9 @@ namespace Pinetime {
int OnDescriptorDiscoveryEventCallback(uint16_t connectionHandle, const ble_gatt_error *error,
uint16_t characteristicValueHandle, const ble_gatt_dsc *descriptor);
void OnNotification(ble_gap_event *event);
- bool IsDiscovered() const;
- uint16_t StartHandle() const;
- uint16_t EndHandle() const;
-
- static constexpr const ble_uuid16_t &Uuid() { return ansServiceUuid; }
+ void Reset();
+ void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) override;
- uint16_t NewAlerthandle() const;
private:
static constexpr uint16_t ansServiceId{0x1811};
static constexpr uint16_t supportedNewAlertCategoryId = 0x2a47;
@@ -64,18 +56,21 @@ namespace Pinetime {
.value = controlPointId
};
- uint16_t ansStartHandle;
- uint16_t ansEndHandle;
- uint16_t supportedNewAlertCategoryHandle;
- uint16_t supportedUnreadAlertCategoryHandle;
- uint16_t newAlertHandle;
+ uint16_t ansStartHandle = 0;
+ uint16_t ansEndHandle = 0;
+ uint16_t supportedNewAlertCategoryHandle = 0;
+ uint16_t supportedUnreadAlertCategoryHandle = 0;
+ uint16_t newAlertHandle = 0;
uint16_t newAlertDescriptorHandle = 0;
- uint16_t newAlertDefHandle;
- uint16_t unreadAlertStatusHandle;
- uint16_t controlPointHandle;
+ uint16_t newAlertDefHandle = 0;
+ uint16_t unreadAlertStatusHandle = 0;
+ uint16_t controlPointHandle = 0;
bool isDiscovered = false;
Pinetime::System::SystemTask &systemTask;
Pinetime::Controllers::NotificationManager &notificationManager;
+ std::function<void(uint16_t)> onServiceDiscovered;
+ bool isCharacteristicDiscovered = false;
+ bool isDescriptorFound = false;
};
}
} \ No newline at end of file
diff --git a/src/Components/Ble/AlertNotificationService.cpp b/src/components/ble/AlertNotificationService.cpp
index ce2f7dd..32711b9 100644
--- a/src/Components/Ble/AlertNotificationService.cpp
+++ b/src/components/ble/AlertNotificationService.cpp
@@ -1,7 +1,7 @@
#include <hal/nrf_rtc.h>
#include "NotificationManager.h"
-#include <SystemTask/SystemTask.h>
+#include <systemtask/SystemTask.h>
#include "AlertNotificationService.h"
#include <cstring>
@@ -38,7 +38,7 @@ AlertNotificationService::AlertNotificationService ( System::SystemTask& systemT
0
}
},
- serviceDefinition{
+ serviceDefinition{
{
/* Device Information Service */
.type = BLE_GATT_SVC_TYPE_PRIMARY,
@@ -48,33 +48,28 @@ AlertNotificationService::AlertNotificationService ( System::SystemTask& systemT
{
0
},
- }, m_systemTask{systemTask}, m_notificationManager{notificationManager} {
+ }, systemTask{systemTask}, notificationManager{notificationManager} {
}
int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle,
struct ble_gatt_access_ctxt *ctxt) {
-
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
- // TODO implement this with more memory safety (and constexpr)
- static const size_t maxBufferSize{21};
- static const size_t maxMessageSize{18};
- size_t bufferSize = min(OS_MBUF_PKTLEN(ctxt->om), maxBufferSize);
-
- uint8_t data[bufferSize];
- os_mbuf_copydata(ctxt->om, 0, bufferSize, data);
+ constexpr size_t stringTerminatorSize = 1; // end of string '\0'
+ constexpr size_t headerSize = 3;
+ const auto maxMessageSize {NotificationManager::MaximumMessageSize()};
+ const auto maxBufferSize{maxMessageSize + headerSize};
- char *s = (char *) &data[3];
- auto messageSize = min(maxMessageSize, (bufferSize-3));
+ const auto dbgPacketLen = OS_MBUF_PKTLEN(ctxt->om);
+ size_t bufferSize = min(dbgPacketLen + stringTerminatorSize, maxBufferSize);
+ auto messageSize = min(maxMessageSize, (bufferSize-headerSize));
- for (uint i = 0; i < messageSize-1; i++) {
- if (s[i] == 0x00) {
- s[i] = 0x0A;
- }
- }
- s[messageSize-1] = '\0';
+ NotificationManager::Notification notif;
+ os_mbuf_copydata(ctxt->om, headerSize, messageSize-1, notif.message.data());
+ notif.message[messageSize-1] = '\0';
+ notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
+ notificationManager.Push(std::move(notif));
- m_notificationManager.Push(Pinetime::Controllers::NotificationManager::Categories::SimpleAlert, s, messageSize);
- m_systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
+ systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
}
return 0;
}
diff --git a/src/Components/Ble/AlertNotificationService.h b/src/components/ble/AlertNotificationService.h
index 53cb44c..1b8c498 100644
--- a/src/Components/Ble/AlertNotificationService.h
+++ b/src/components/ble/AlertNotificationService.h
@@ -32,8 +32,8 @@ namespace Pinetime {
struct ble_gatt_chr_def characteristicDefinition[2];
struct ble_gatt_svc_def serviceDefinition[2];
- Pinetime::System::SystemTask &m_systemTask;
- NotificationManager &m_notificationManager;
+ Pinetime::System::SystemTask &systemTask;
+ NotificationManager &notificationManager;
};
}
}
diff --git a/src/components/ble/BatteryInformationService.cpp b/src/components/ble/BatteryInformationService.cpp
new file mode 100644
index 0000000..f7d895c
--- /dev/null
+++ b/src/components/ble/BatteryInformationService.cpp
@@ -0,0 +1,62 @@
+#include "BatteryInformationService.h"
+#include "components/battery/BatteryController.h"
+
+using namespace Pinetime::Controllers;
+
+constexpr ble_uuid16_t BatteryInformationService::batteryInformationServiceUuid;
+constexpr ble_uuid16_t BatteryInformationService::batteryLevelUuid;
+
+
+
+int BatteryInformationServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
+ auto* batteryInformationService = static_cast<BatteryInformationService*>(arg);
+ return batteryInformationService->OnBatteryServiceRequested(conn_handle, attr_handle, ctxt);
+}
+
+BatteryInformationService::BatteryInformationService(Controllers::Battery& batteryController) :
+ batteryController{batteryController},
+ characteristicDefinition{
+ {
+ .uuid = (ble_uuid_t *) &batteryLevelUuid,
+ .access_cb = BatteryInformationServiceCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_READ,
+ .val_handle = &batteryLevelHandle
+ },
+ {
+ 0
+ }
+ },
+ serviceDefinition{
+ {
+ /* Device Information Service */
+ .type = BLE_GATT_SVC_TYPE_PRIMARY,
+ .uuid = (ble_uuid_t *) &batteryInformationServiceUuid,
+ .characteristics = characteristicDefinition
+ },
+ {
+ 0
+ },
+ }{
+
+}
+
+void BatteryInformationService::Init() {
+ int res = 0;
+ res = ble_gatts_count_cfg(serviceDefinition);
+ ASSERT(res == 0);
+
+ res = ble_gatts_add_svcs(serviceDefinition);
+ ASSERT(res == 0);
+}
+
+int BatteryInformationService::OnBatteryServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle,
+ ble_gatt_access_ctxt *context) {
+ if(attributeHandle == batteryLevelHandle) {
+ NRF_LOG_INFO("BATTERY : handle = %d", batteryLevelHandle);
+ static uint8_t batteryValue = batteryController.PercentRemaining();
+ int res = os_mbuf_append(context->om, &batteryValue, 1);
+ return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
+ }
+ return 0;
+} \ No newline at end of file
diff --git a/src/components/ble/BatteryInformationService.h b/src/components/ble/BatteryInformationService.h
new file mode 100644
index 0000000..74b2222
--- /dev/null
+++ b/src/components/ble/BatteryInformationService.h
@@ -0,0 +1,40 @@
+#pragma once
+#include <host/ble_gap.h>
+
+namespace Pinetime {
+ namespace System {
+ class SystemTask;
+ }
+ namespace Controllers {
+ class Battery;
+ class BatteryInformationService {
+ public:
+ BatteryInformationService(Controllers::Battery& batteryController);
+ void Init();
+
+ int
+ OnBatteryServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context);
+
+ private:
+ Controllers::Battery& batteryController;
+ static constexpr uint16_t batteryInformationServiceId {0x180F};
+ static constexpr uint16_t batteryLevelId {0x2A19};
+
+ static constexpr ble_uuid16_t batteryInformationServiceUuid {
+ .u {.type = BLE_UUID_TYPE_16},
+ .value = batteryInformationServiceId
+ };
+
+ static constexpr ble_uuid16_t batteryLevelUuid {
+ .u {.type = BLE_UUID_TYPE_16},
+ .value = batteryLevelId
+ };
+
+ struct ble_gatt_chr_def characteristicDefinition[3];
+ struct ble_gatt_svc_def serviceDefinition[2];
+
+ uint16_t batteryLevelHandle;
+
+ };
+ }
+}
diff --git a/src/components/ble/BleClient.h b/src/components/ble/BleClient.h
new file mode 100644
index 0000000..559f6c8
--- /dev/null
+++ b/src/components/ble/BleClient.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include <functional>
+
+namespace Pinetime {
+ namespace Controllers{
+ class BleClient {
+ public:
+ virtual void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) = 0;
+ };
+ }
+} \ No newline at end of file
diff --git a/src/Components/Ble/BleController.cpp b/src/components/ble/BleController.cpp
index 2b396e1..2b396e1 100644
--- a/src/Components/Ble/BleController.cpp
+++ b/src/components/ble/BleController.cpp
diff --git a/src/Components/Ble/BleController.h b/src/components/ble/BleController.h
index 3f52ea2..3f52ea2 100644
--- a/src/Components/Ble/BleController.h
+++ b/src/components/ble/BleController.h
diff --git a/src/components/ble/CurrentTimeClient.cpp b/src/components/ble/CurrentTimeClient.cpp
new file mode 100644
index 0000000..92f9374
--- /dev/null
+++ b/src/components/ble/CurrentTimeClient.cpp
@@ -0,0 +1,111 @@
+#include <hal/nrf_rtc.h>
+#include "CurrentTimeClient.h"
+
+using namespace Pinetime::Controllers;
+
+constexpr ble_uuid16_t CurrentTimeClient::ctsServiceUuid;
+constexpr ble_uuid16_t CurrentTimeClient::currentTimeCharacteristicUuid;
+
+namespace {
+ int OnDiscoveryEventCallback(uint16_t conn_handle, const struct ble_gatt_error *error, const struct ble_gatt_svc *service, void *arg) {
+ auto client = static_cast<CurrentTimeClient *>(arg);
+ return client->OnDiscoveryEvent(conn_handle, error, service);
+ }
+
+ int OnCurrentTimeCharacteristicDiscoveredCallback(uint16_t conn_handle, const struct ble_gatt_error *error,
+ const struct ble_gatt_chr *chr, void *arg) {
+ auto client = static_cast<CurrentTimeClient *>(arg);
+ return client->OnCharacteristicDiscoveryEvent(conn_handle, error, chr);
+ }
+
+ int CurrentTimeReadCallback(uint16_t conn_handle, const struct ble_gatt_error *error, struct ble_gatt_attr *attr, void *arg) {
+ auto client = static_cast<CurrentTimeClient *>(arg);
+ return client->OnCurrentTimeReadResult(conn_handle, error, attr);
+ }
+}
+
+CurrentTimeClient::CurrentTimeClient(DateTime &dateTimeController) : dateTimeController{dateTimeController} {
+
+}
+
+void CurrentTimeClient::Init() {
+
+}
+
+bool CurrentTimeClient::OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
+ const ble_gatt_svc *service) {
+ if (service == nullptr && error->status == BLE_HS_EDONE) {
+ if (isDiscovered) {
+ NRF_LOG_INFO("CTS found, starting characteristics discovery");
+
+ ble_gattc_disc_all_chrs(connectionHandle, ctsStartHandle, ctsEndHandle,
+ OnCurrentTimeCharacteristicDiscoveredCallback, this);
+ } else {
+ NRF_LOG_INFO("CTS not found");
+ onServiceDiscovered(connectionHandle);
+ }
+ return true;
+ }
+
+ if (service != nullptr && ble_uuid_cmp(((ble_uuid_t *) &ctsServiceUuid), &service->uuid.u) == 0) {
+ NRF_LOG_INFO("CTS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
+ isDiscovered = true;
+ ctsStartHandle = service->start_handle;
+ ctsEndHandle = service->end_handle;
+ return false;
+ }
+ return false;
+}
+
+int CurrentTimeClient::OnCharacteristicDiscoveryEvent(uint16_t conn_handle, const ble_gatt_error *error,
+ const ble_gatt_chr *characteristic) {
+ if (characteristic == nullptr && error->status == BLE_HS_EDONE) {
+ if (isCharacteristicDiscovered) {
+ NRF_LOG_INFO("CTS Characteristic discovery complete, fetching time");
+ ble_gattc_read(conn_handle, currentTimeHandle, CurrentTimeReadCallback, this);
+ } else {
+ NRF_LOG_INFO("CTS Characteristic discovery unsuccessful");
+ onServiceDiscovered(conn_handle);
+ }
+
+ return 0;
+ }
+
+ if (characteristic != nullptr &&
+ ble_uuid_cmp(((ble_uuid_t *) &currentTimeCharacteristicUuid), &characteristic->uuid.u) == 0) {
+ NRF_LOG_INFO("CTS Characteristic discovered : 0x%x", characteristic->val_handle);
+ isCharacteristicDiscovered = true;
+ currentTimeHandle = characteristic->val_handle;
+ }
+ return 0;
+}
+
+int CurrentTimeClient::OnCurrentTimeReadResult(uint16_t conn_handle, const ble_gatt_error *error,
+ const ble_gatt_attr *attribute) {
+ if (error->status == 0) {
+ // TODO check that attribute->handle equals the handle discovered in OnCharacteristicDiscoveryEvent
+ CtsData result;
+ os_mbuf_copydata(attribute->om, 0, sizeof(CtsData), &result);
+ NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", result.year,
+ result.month, result.dayofmonth,
+ result.hour, result.minute, result.second);
+ dateTimeController.SetTime(result.year, result.month, result.dayofmonth,
+ 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG));
+ } else {
+ NRF_LOG_INFO("Error retrieving current time: %d", error->status);
+ }
+
+ onServiceDiscovered(conn_handle);
+ return 0;
+}
+
+void CurrentTimeClient::Reset() {
+ isDiscovered = false;
+ isCharacteristicDiscovered = false;
+}
+
+void CurrentTimeClient::Discover(uint16_t connectionHandle, std::function<void(uint16_t)> onServiceDiscovered) {
+ NRF_LOG_INFO("[CTS] Starting discovery");
+ this->onServiceDiscovered = onServiceDiscovered;
+ ble_gattc_disc_svc_by_uuid(connectionHandle, &ctsServiceUuid.u, OnDiscoveryEventCallback, this);
+}
diff --git a/src/Components/Ble/CurrentTimeClient.h b/src/components/ble/CurrentTimeClient.h
index fabcdac..9313939 100644
--- a/src/Components/Ble/CurrentTimeClient.h
+++ b/src/components/ble/CurrentTimeClient.h
@@ -1,27 +1,28 @@
#pragma once
#include <cstdint>
#include <array>
-#include <Components/DateTime/DateTimeController.h>
+
+#include "components/datetime/DateTimeController.h"
+#include "BleClient.h"
#include <host/ble_gap.h>
namespace Pinetime {
namespace Controllers {
- class CurrentTimeClient {
+ class CurrentTimeClient : public BleClient {
public:
explicit CurrentTimeClient(DateTime& dateTimeController);
void Init();
+ 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);
- bool IsDiscovered() const;
- uint16_t StartHandle() const;
- uint16_t EndHandle() const;
- uint16_t CurrentTimeHandle() const;
static constexpr const ble_uuid16_t* Uuid() { return &CurrentTimeClient::ctsServiceUuid; }
static constexpr const ble_uuid16_t* CurrentTimeCharacteristicUuid() { return &CurrentTimeClient::currentTimeCharacteristicUuid; }
- private:
+ void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) override;
+
+ private:
typedef struct __attribute__((packed)) {
uint16_t year;
uint8_t month;
@@ -45,11 +46,14 @@ namespace Pinetime {
.value = currentTimeCharacteristicId
};
- uint16_t currentTimeHandle;
DateTime& dateTimeController;
bool isDiscovered = false;
uint16_t ctsStartHandle;
uint16_t ctsEndHandle;
+
+ bool isCharacteristicDiscovered = false;
+ uint16_t currentTimeHandle;
+ std::function<void(uint16_t)> onServiceDiscovered;
};
}
} \ No newline at end of file
diff --git a/src/Components/Ble/CurrentTimeService.cpp b/src/components/ble/CurrentTimeService.cpp
index 3a6264e..3a6264e 100644
--- a/src/Components/Ble/CurrentTimeService.cpp
+++ b/src/components/ble/CurrentTimeService.cpp
diff --git a/src/Components/Ble/CurrentTimeService.h b/src/components/ble/CurrentTimeService.h
index 58bc5ba..a6be964 100644
--- a/src/Components/Ble/CurrentTimeService.h
+++ b/src/components/ble/CurrentTimeService.h
@@ -1,7 +1,8 @@
#pragma once
#include <cstdint>
#include <array>
-#include <Components/DateTime/DateTimeController.h>
+
+#include "components/datetime/DateTimeController.h"
#include <host/ble_gap.h>
namespace Pinetime {
diff --git a/src/Components/Ble/DeviceInformationService.cpp b/src/components/ble/DeviceInformationService.cpp
index 406db1c..406db1c 100644
--- a/src/Components/Ble/DeviceInformationService.cpp
+++ b/src/components/ble/DeviceInformationService.cpp
diff --git a/src/Components/Ble/DeviceInformationService.h b/src/components/ble/DeviceInformationService.h
index 25ab840..25ab840 100644
--- a/src/Components/Ble/DeviceInformationService.h
+++ b/src/components/ble/DeviceInformationService.h
diff --git a/src/Components/Ble/DfuService.cpp b/src/components/ble/DfuService.cpp
index fcbefdd..4dec514 100644
--- a/src/Components/Ble/DfuService.cpp
+++ b/src/components/ble/DfuService.cpp
@@ -1,6 +1,7 @@
-#include <Components/Ble/BleController.h>
-#include <SystemTask/SystemTask.h>
#include <cstring>
+
+#include "components/ble/BleController.h"
+#include "systemtask/SystemTask.h"
#include "DfuService.h"
using namespace Pinetime::Controllers;
diff --git a/src/Components/Ble/DfuService.h b/src/components/ble/DfuService.h
index d7ba460..d7ba460 100644
--- a/src/Components/Ble/DfuService.h
+++ b/src/components/ble/DfuService.h
diff --git a/src/components/ble/ImmediateAlertService.cpp b/src/components/ble/ImmediateAlertService.cpp
new file mode 100644
index 0000000..e2cee30
--- /dev/null
+++ b/src/components/ble/ImmediateAlertService.cpp
@@ -0,0 +1,82 @@
+#include <systemtask/SystemTask.h>
+#include <cstring>
+#include "ImmediateAlertService.h"
+#include "AlertNotificationService.h"
+
+using namespace Pinetime::Controllers;
+
+constexpr ble_uuid16_t ImmediateAlertService::immediateAlertServiceUuid;
+constexpr ble_uuid16_t ImmediateAlertService::alertLevelUuid;
+
+namespace {
+ int AlertLevelCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
+ auto *immediateAlertService = static_cast<ImmediateAlertService *>(arg);
+ return immediateAlertService->OnAlertLevelChanged(conn_handle, attr_handle, ctxt);
+ }
+
+ const char* ToString(ImmediateAlertService::Levels level) {
+ switch (level) {
+ case ImmediateAlertService::Levels::NoAlert: return "Alert : None";
+ case ImmediateAlertService::Levels::HighAlert: return "Alert : High";
+ case ImmediateAlertService::Levels::MildAlert: return "Alert : Mild";
+ default: return "";
+ }
+ }
+}
+
+ImmediateAlertService::ImmediateAlertService(Pinetime::System::SystemTask &systemTask,
+ Pinetime::Controllers::NotificationManager &notificationManager) :
+ systemTask{systemTask},
+ notificationManager{notificationManager},
+ characteristicDefinition{
+ {
+ .uuid = (ble_uuid_t *) &alertLevelUuid,
+ .access_cb = AlertLevelCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
+ .val_handle = &alertLevelHandle
+ },
+ {
+ 0
+ }
+ },
+ serviceDefinition{
+ {
+ /* Device Information Service */
+ .type = BLE_GATT_SVC_TYPE_PRIMARY,
+ .uuid = (ble_uuid_t *) &immediateAlertServiceUuid,
+ .characteristics = characteristicDefinition
+ },
+ {
+ 0
+ },
+ }{
+
+}
+
+void ImmediateAlertService::Init() {
+ int res = 0;
+ res = ble_gatts_count_cfg(serviceDefinition);
+ ASSERT(res == 0);
+
+ res = ble_gatts_add_svcs(serviceDefinition);
+ ASSERT(res == 0);
+}
+
+int ImmediateAlertService::OnAlertLevelChanged(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context) {
+ if(attributeHandle == alertLevelHandle) {
+ if(context->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+ auto alertLevel = static_cast<Levels>(context->om->om_data[0]);
+ auto* alertString = ToString(alertLevel);
+
+ NotificationManager::Notification notif;
+ std::memcpy(notif.message.data(), alertString, strlen(alertString));
+ notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
+ notificationManager.Push(std::move(notif));
+
+ systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
+ }
+ }
+
+ return 0;
+} \ No newline at end of file
diff --git a/src/components/ble/ImmediateAlertService.h b/src/components/ble/ImmediateAlertService.h
new file mode 100644
index 0000000..c42846c
--- /dev/null
+++ b/src/components/ble/ImmediateAlertService.h
@@ -0,0 +1,46 @@
+#pragma once
+#include <host/ble_gap.h>
+
+namespace Pinetime {
+ namespace System {
+ class SystemTask;
+ }
+ namespace Controllers {
+ class NotificationManager;
+ class ImmediateAlertService {
+ public:
+ enum class Levels : uint8_t {
+ NoAlert = 0,
+ MildAlert = 1,
+ HighAlert = 2
+ };
+
+ ImmediateAlertService(Pinetime::System::SystemTask &systemTask,
+ Pinetime::Controllers::NotificationManager &notificationManager);
+ void Init();
+ int OnAlertLevelChanged(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context);
+
+ private:
+ Pinetime::System::SystemTask& systemTask;
+ NotificationManager& notificationManager;
+
+ static constexpr uint16_t immediateAlertServiceId {0x1802};
+ static constexpr uint16_t alertLevelId {0x2A06};
+
+ static constexpr ble_uuid16_t immediateAlertServiceUuid {
+ .u {.type = BLE_UUID_TYPE_16},
+ .value = immediateAlertServiceId
+ };
+
+ static constexpr ble_uuid16_t alertLevelUuid {
+ .u {.type = BLE_UUID_TYPE_16},
+ .value = alertLevelId
+ };
+
+ struct ble_gatt_chr_def characteristicDefinition[3];
+ struct ble_gatt_svc_def serviceDefinition[2];
+
+ uint16_t alertLevelHandle;
+ };
+ }
+}
diff --git a/src/components/ble/MusicService.cpp b/src/components/ble/MusicService.cpp
new file mode 100644
index 0000000..84f2972
--- /dev/null
+++ b/src/components/ble/MusicService.cpp
@@ -0,0 +1,225 @@
+/* Copyright (C) 2020 JF, Adam Pigg, Avamander
+
+ This file is part of InfiniTime.
+
+ InfiniTime is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ InfiniTime is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#include <systemtask/SystemTask.h>
+#include "MusicService.h"
+
+int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
+ auto musicService = static_cast<Pinetime::Controllers::MusicService *>(arg);
+ return musicService->OnCommand(conn_handle, attr_handle, ctxt);
+}
+
+Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask &system) : m_system(system) {
+ msUuid.value[11] = msId[0];
+ msUuid.value[12] = msId[1];
+ msEventCharUuid.value[11] = msEventCharId[0];
+ msEventCharUuid.value[12] = msEventCharId[1];
+ msStatusCharUuid.value[11] = msStatusCharId[0];
+ msStatusCharUuid.value[12] = msStatusCharId[1];
+ msTrackCharUuid.value[11] = msTrackCharId[0];
+ msTrackCharUuid.value[12] = msTrackCharId[1];
+ msArtistCharUuid.value[11] = msArtistCharId[0];
+ msArtistCharUuid.value[12] = msArtistCharId[1];
+ msAlbumCharUuid.value[11] = msAlbumCharId[0];
+ msAlbumCharUuid.value[12] = msAlbumCharId[1];
+ msPositionCharUuid.value[11] = msPositionCharId[0];
+ msPositionCharUuid.value[12] = msPositionCharId[1];
+ msTotalLengthCharUuid.value[11] = msTotalLengthCharId[0];
+ msTotalLengthCharUuid.value[12] = msTotalLengthCharId[1];
+ msTrackNumberCharUuid.value[11] = msTrackNumberCharId[0];
+ msTrackNumberCharUuid.value[12] = msTrackNumberCharId[1];
+ msTrackTotalCharUuid.value[11] = msTrackTotalCharId[0];
+ msTrackTotalCharUuid.value[12] = msTrackTotalCharId[1];
+ msPlaybackSpeedCharUuid.value[11] = msPlaybackSpeedCharId[0];
+ msPlaybackSpeedCharUuid.value[12] = msPlaybackSpeedCharId[1];
+ msRepeatCharUuid.value[11] = msRepeatCharId[0];
+ msRepeatCharUuid.value[12] = msRepeatCharId[1];
+ msShuffleCharUuid.value[11] = msShuffleCharId[0];
+ msShuffleCharUuid.value[12] = msShuffleCharId[1];
+
+ characteristicDefinition[0] = {.uuid = (ble_uuid_t *) (&msEventCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_NOTIFY,
+ .val_handle = &eventHandle
+ };
+ characteristicDefinition[1] = {.uuid = (ble_uuid_t *) (&msStatusCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[2] = {.uuid = (ble_uuid_t *) (&msTrackCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[3] = {.uuid = (ble_uuid_t *) (&msArtistCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[4] = {.uuid = (ble_uuid_t *) (&msAlbumCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[5] = {.uuid = (ble_uuid_t *) (&msPositionCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[6] = {.uuid = (ble_uuid_t *) (&msTotalLengthCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[7] = {.uuid = (ble_uuid_t *) (&msTotalLengthCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[8] = {.uuid = (ble_uuid_t *) (&msTrackNumberCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[9] = {.uuid = (ble_uuid_t *) (&msTrackTotalCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[10] = {.uuid = (ble_uuid_t *) (&msPlaybackSpeedCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[11] = {.uuid = (ble_uuid_t *) (&msRepeatCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[12] = {.uuid = (ble_uuid_t *) (&msShuffleCharUuid),
+ .access_cb = MSCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
+ };
+ characteristicDefinition[13] = {0};
+
+ serviceDefinition[0] = {
+ .type = BLE_GATT_SVC_TYPE_PRIMARY,
+ .uuid = (ble_uuid_t *) &msUuid,
+ .characteristics = characteristicDefinition
+ };
+ serviceDefinition[1] = {0};
+
+ artistName = "Waiting for";
+ albumName = "";
+ trackName = "track information...";
+ playing = false;
+ repeat = false;
+ shuffle = false;
+ playbackSpeed = 1.0f;
+ trackProgress = 0;
+ trackLength = 0;
+}
+
+void Pinetime::Controllers::MusicService::Init() {
+ int res = 0;
+ res = ble_gatts_count_cfg(serviceDefinition);
+ ASSERT(res == 0);
+
+ res = ble_gatts_add_svcs(serviceDefinition);
+ ASSERT(res == 0);
+}
+
+int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle,
+ struct ble_gatt_access_ctxt *ctxt) {
+
+ if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
+ size_t notifSize = OS_MBUF_PKTLEN(ctxt->om);
+ uint8_t data[notifSize + 1];
+ data[notifSize] = '\0';
+ os_mbuf_copydata(ctxt->om, 0, notifSize, data);
+ char *s = (char *) &data[0];
+ NRF_LOG_INFO("DATA : %s", s);
+ if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msArtistCharUuid) == 0) {
+ artistName = s;
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msTrackCharUuid) == 0) {
+ trackName = s;
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msAlbumCharUuid) == 0) {
+ albumName = s;
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msStatusCharUuid) == 0) {
+ playing = s[0];
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msRepeatCharUuid) == 0) {
+ repeat = s[0];
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msShuffleCharUuid) == 0) {
+ shuffle = s[0];
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msPositionCharUuid) == 0) {
+ trackProgress = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msTotalLengthCharUuid) == 0) {
+ trackLength = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msTrackNumberCharUuid) == 0) {
+ trackNumber = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msTrackTotalCharUuid) == 0) {
+ tracksTotal = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
+ } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msPlaybackSpeedCharUuid) == 0) {
+ playbackSpeed = static_cast<float>(((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3])) / 100.0f;
+ }
+ }
+ return 0;
+}
+
+std::string Pinetime::Controllers::MusicService::getAlbum() {
+ return albumName;
+}
+
+std::string Pinetime::Controllers::MusicService::getArtist() {
+ return artistName;
+}
+
+std::string Pinetime::Controllers::MusicService::getTrack() {
+ return trackName;
+}
+
+bool Pinetime::Controllers::MusicService::isPlaying() {
+ return playing;
+}
+
+float Pinetime::Controllers::MusicService::getPlaybackSpeed() {
+ return playbackSpeed;
+}
+
+void Pinetime::Controllers::MusicService::event(char event) {
+ auto *om = ble_hs_mbuf_from_flat(&event, 1);
+
+ uint16_t connectionHandle = m_system.nimble().connHandle();
+
+ if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
+ return;
+ }
+
+ ble_gattc_notify_custom(connectionHandle, eventHandle, om);
+}
+
+int Pinetime::Controllers::MusicService::getProgress() {
+ return trackProgress;
+}
+
+int Pinetime::Controllers::MusicService::getTrackLength() {
+ return trackLength;
+}
+
diff --git a/src/components/ble/MusicService.h b/src/components/ble/MusicService.h
new file mode 100644
index 0000000..b365909
--- /dev/null
+++ b/src/components/ble/MusicService.h
@@ -0,0 +1,166 @@
+/* Copyright (C) 2020 JF, Adam Pigg, Avamander
+
+ This file is part of InfiniTime.
+
+ InfiniTime is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ InfiniTime is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#pragma once
+
+#include <cstdint>
+#include <array>
+#include <host/ble_gap.h>
+#include <host/ble_uuid.h>
+#include <string>
+
+//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}
+
+namespace Pinetime {
+ namespace System {
+ class SystemTask;
+ }
+ namespace Controllers {
+
+ class MusicService {
+ public:
+ explicit MusicService(Pinetime::System::SystemTask &system);
+
+ void Init();
+
+ int OnCommand(uint16_t conn_handle, uint16_t attr_handle,
+ struct ble_gatt_access_ctxt *ctxt);
+
+ void event(char event);
+
+ std::string getArtist();
+
+ std::string getTrack();
+
+ std::string getAlbum();
+
+ int getProgress();
+
+ int getTrackLength();
+
+ float getPlaybackSpeed();
+
+ bool isPlaying();
+
+ static const char EVENT_MUSIC_OPEN = 0xe0;
+ static const char EVENT_MUSIC_PLAY = 0x00;
+ static const char EVENT_MUSIC_PAUSE = 0x01;
+ static const char EVENT_MUSIC_NEXT = 0x03;
+ static const char EVENT_MUSIC_PREV = 0x04;
+ static const char EVENT_MUSIC_VOLUP = 0x05;
+ static const char EVENT_MUSIC_VOLDOWN = 0x06;
+
+ enum MusicStatus {
+ NotPlaying = 0x00,
+ Playing = 0x01
+ };
+ private:
+ static constexpr uint8_t msId[2] = {0x00, 0x01};
+ static constexpr uint8_t msEventCharId[2] = {0x00, 0x02};
+ static constexpr uint8_t msStatusCharId[2] = {0x00, 0x03};
+ static constexpr uint8_t msArtistCharId[2] = {0x00, 0x04};
+ static constexpr uint8_t msTrackCharId[2] = {0x00, 0x05};
+ static constexpr uint8_t msAlbumCharId[2] = {0x00, 0x06};
+ static constexpr uint8_t msPositionCharId[2] = {0x00, 0x07};
+ static constexpr uint8_t msTotalLengthCharId[2] = {0x00, 0x08};
+ static constexpr uint8_t msTrackNumberCharId[2] = {0x00, 0x09};
+ static constexpr uint8_t msTrackTotalCharId[2] = {0x00, 0x0a};
+ static constexpr uint8_t msPlaybackSpeedCharId[2] = {0x00, 0x0b};
+ static constexpr uint8_t msRepeatCharId[2] = {0x00, 0x0c};
+ static constexpr uint8_t msShuffleCharId[2] = {0x00, 0x0d};
+
+ ble_uuid128_t msUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+
+ ble_uuid128_t msEventCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msStatusCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msArtistCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msTrackCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msAlbumCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msPositionCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msTotalLengthCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msTrackNumberCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msTrackTotalCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msPlaybackSpeedCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msRepeatCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+ ble_uuid128_t msShuffleCharUuid{
+ .u = {.type = BLE_UUID_TYPE_128},
+ .value = MUSIC_SERVICE_UUID_BASE
+ };
+
+ struct ble_gatt_chr_def characteristicDefinition[14];
+ struct ble_gatt_svc_def serviceDefinition[2];
+
+ uint16_t eventHandle;
+
+ std::string artistName;
+ std::string albumName;
+ std::string trackName;
+
+ bool playing;
+
+ int trackProgress;
+ int trackLength;
+ int trackNumber;
+ int tracksTotal;
+
+ float playbackSpeed;
+
+ bool repeat;
+ bool shuffle;
+
+ Pinetime::System::SystemTask &m_system;
+ };
+ }
+}
+
diff --git a/src/Components/Ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index 7dde9d0..af7f402 100644
--- a/src/Components/Ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -1,10 +1,7 @@
-
-#include <Components/DateTime/DateTimeController.h>
-
-#include <SystemTask/SystemTask.h>
-#include <Components/Ble/NotificationManager.h>
+#include "components/datetime/DateTimeController.h"
+#include <systemtask/SystemTask.h>
+#include "components/ble/NotificationManager.h"
#include <hal/nrf_rtc.h>
-
#include "NimbleController.h"
#include "MusicService.h"
#include <services/gatt/ble_svc_gatt.h>
@@ -14,18 +11,13 @@
#include <host/ble_hs.h>
#include <host/ble_gap.h>
-
-
using namespace Pinetime::Controllers;
-// TODO I'm not satisfied by how this code looks like (AlertNotificationClient and CurrentTimeClient must
-// expose too much data, too many callbacks -> NimbleController -> CTS/ANS client.
-// Let's try to improve this code (and keep it working!)
-
NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
Pinetime::Controllers::Ble& bleController,
DateTime& dateTimeController,
Pinetime::Controllers::NotificationManager& notificationManager,
+ Controllers::Battery& batteryController,
Pinetime::Drivers::SpiNorFlash& spiNorFlash) :
systemTask{systemTask},
bleController{bleController},
@@ -37,8 +29,10 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
anService{systemTask, notificationManager},
alertNotificationClient{systemTask, notificationManager},
currentTimeService{dateTimeController},
- musicService{systemTask} {
-
+ musicService{systemTask},
+ batteryInformationService{batteryController},
+ immediateAlertService{systemTask, notificationManager},
+ serviceDiscovery({&currentTimeClient, &alertNotificationClient}) {
}
int GAPEventCallback(struct ble_gap_event *event, void *arg) {
@@ -46,33 +40,6 @@ int GAPEventCallback(struct ble_gap_event *event, void *arg) {
return nimbleController->OnGAPEvent(event);
}
-int CurrentTimeCharacteristicDiscoveredCallback(uint16_t conn_handle, const struct ble_gatt_error *error,
- const struct ble_gatt_chr *chr, void *arg) {
- auto client = static_cast<NimbleController*>(arg);
- return client->OnCTSCharacteristicDiscoveryEvent(conn_handle, error, chr);
-}
-
-int AlertNotificationCharacteristicDiscoveredCallback(uint16_t conn_handle, const struct ble_gatt_error *error,
- const struct ble_gatt_chr *chr, void *arg) {
- auto client = static_cast<NimbleController*>(arg);
- return client->OnANSCharacteristicDiscoveryEvent(conn_handle, error, chr);
-}
-
-int CurrentTimeReadCallback(uint16_t conn_handle, const struct ble_gatt_error *error,
- struct ble_gatt_attr *attr, void *arg) {
- auto client = static_cast<NimbleController*>(arg);
- return client->OnCurrentTimeReadResult(conn_handle, error, attr);
-}
-
-int AlertNotificationDescriptorDiscoveryEventCallback(uint16_t conn_handle,
- const struct ble_gatt_error *error,
- uint16_t chr_val_handle,
- const struct ble_gatt_dsc *dsc,
- void *arg) {
- auto client = static_cast<NimbleController*>(arg);
- return client->OnANSDescriptorDiscoveryEventCallback(conn_handle, error, chr_val_handle, dsc);
-}
-
void NimbleController::Init() {
while (!ble_hs_synced()) {}
@@ -83,10 +50,10 @@ void NimbleController::Init() {
currentTimeClient.Init();
currentTimeService.Init();
musicService.Init();
-
anService.Init();
-
dfuService.Init();
+ batteryInformationService.Init();
+ immediateAlertService.Init();
int res;
res = ble_hs_util_ensure_addr(0);
ASSERT(res == 0);
@@ -105,7 +72,7 @@ void NimbleController::Init() {
}
void NimbleController::StartAdvertising() {
- if(ble_gap_adv_active()) return;
+ if(bleController.IsConnected() || ble_gap_conn_active() || ble_gap_adv_active()) return;
ble_svc_gap_device_name_set(deviceName);
@@ -155,15 +122,6 @@ void NimbleController::StartAdvertising() {
// the application has been woken up, for example.
}
-int OnAllSvrDisco(uint16_t conn_handle,
- const struct ble_gatt_error *error,
- const struct ble_gatt_svc *service,
- void *arg) {
- auto nimbleController = static_cast<NimbleController*>(arg);
- return nimbleController->OnDiscoveryEvent(conn_handle, error, service);
- return 0;
-}
-
int NimbleController::OnGAPEvent(ble_gap_event *event) {
switch (event->type) {
case BLE_GAP_EVENT_ADV_COMPLETE:
@@ -194,6 +152,8 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) {
NRF_LOG_INFO("disconnect; reason=%d", event->disconnect.reason);
/* Connection terminated; resume advertising. */
+ currentTimeClient.Reset();
+ alertNotificationClient.Reset();
connectionHandle = BLE_HS_CONN_HANDLE_NONE;
bleController.Disconnect();
StartAdvertising();
@@ -266,65 +226,8 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) {
return 0;
}
-int NimbleController::OnDiscoveryEvent(uint16_t i, const ble_gatt_error *error, const ble_gatt_svc *service) {
- if(service == nullptr && error->status == BLE_HS_EDONE) {
- NRF_LOG_INFO("Service Discovery complete");
- if(currentTimeClient.IsDiscovered()) {
- ble_gattc_disc_all_chrs(connectionHandle, currentTimeClient.StartHandle(), currentTimeClient.EndHandle(),
- CurrentTimeCharacteristicDiscoveredCallback, this);
-
- } else if(alertNotificationClient.IsDiscovered()) {
- ble_gattc_disc_all_chrs(connectionHandle, alertNotificationClient.StartHandle(), alertNotificationClient.EndHandle(),
- AlertNotificationCharacteristicDiscoveredCallback, this);
- }
- }
-
- alertNotificationClient.OnDiscoveryEvent(i, error, service);
- currentTimeClient.OnDiscoveryEvent(i, error, service);
- return 0;
-}
-
-int NimbleController::OnCTSCharacteristicDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
- const ble_gatt_chr *characteristic) {
- if(characteristic == nullptr && error->status == BLE_HS_EDONE) {
- NRF_LOG_INFO("CTS characteristic Discovery complete");
- ble_gattc_read(connectionHandle, currentTimeClient.CurrentTimeHandle(), CurrentTimeReadCallback, this);
- return 0;
- }
- return currentTimeClient.OnCharacteristicDiscoveryEvent(connectionHandle, error, characteristic);
-}
-
-int NimbleController::OnANSCharacteristicDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
- const ble_gatt_chr *characteristic) {
- if(characteristic == nullptr && error->status == BLE_HS_EDONE) {
- NRF_LOG_INFO("ANS characteristic Discovery complete");
- ble_gattc_disc_all_dscs(connectionHandle,
- alertNotificationClient.NewAlerthandle(), alertNotificationClient.EndHandle(),
- AlertNotificationDescriptorDiscoveryEventCallback, this);
- return 0;
- }
- return alertNotificationClient.OnCharacteristicsDiscoveryEvent(connectionHandle, error, characteristic);
-}
-
-int NimbleController::OnCurrentTimeReadResult(uint16_t connectionHandle, const ble_gatt_error *error, ble_gatt_attr *attribute) {
- currentTimeClient.OnCurrentTimeReadResult(connectionHandle, error, attribute);
-
- if (alertNotificationClient.IsDiscovered()) {
- ble_gattc_disc_all_chrs(connectionHandle, alertNotificationClient.StartHandle(),
- alertNotificationClient.EndHandle(),
- AlertNotificationCharacteristicDiscoveredCallback, this);
- }
- return 0;
-}
-
-int NimbleController::OnANSDescriptorDiscoveryEventCallback(uint16_t connectionHandle, const ble_gatt_error *error,
- uint16_t characteristicValueHandle,
- const ble_gatt_dsc *descriptor) {
- return alertNotificationClient.OnDescriptorDiscoveryEventCallback(connectionHandle, error, characteristicValueHandle, descriptor);
-}
-
void NimbleController::StartDiscovery() {
- ble_gattc_disc_all_svcs(connectionHandle, OnAllSvrDisco, this);
+ serviceDiscovery.StartDiscovery(connectionHandle);
}
diff --git a/src/Components/Ble/NimbleController.h b/src/components/ble/NimbleController.h
index 50b8b0b..8ddec1f 100644
--- a/src/Components/Ble/NimbleController.h
+++ b/src/components/ble/NimbleController.h
@@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
+
#include "AlertNotificationService.h"
#include "AlertNotificationClient.h"
#include "DeviceInformationService.h"
@@ -8,6 +9,9 @@
#include "DfuService.h"
#include "CurrentTimeService.h"
#include "MusicService.h"
+#include "BatteryInformationService.h"
+#include "ImmediateAlertService.h"
+#include "ServiceDiscovery.h"
#include <host/ble_gap.h>
namespace Pinetime {
@@ -22,7 +26,7 @@ namespace Pinetime {
public:
NimbleController(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::Ble& bleController,
DateTime& dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager,
- Pinetime::Drivers::SpiNorFlash& spiNorFlash);
+ Controllers::Battery& batteryController, Pinetime::Drivers::SpiNorFlash& spiNorFlash);
void Init();
void StartAdvertising();
int OnGAPEvent(ble_gap_event *event);
@@ -57,6 +61,8 @@ namespace Pinetime {
AlertNotificationClient alertNotificationClient;
CurrentTimeService currentTimeService;
MusicService musicService;
+ BatteryInformationService batteryInformationService;
+ ImmediateAlertService immediateAlertService;
uint8_t addrType; // 1 = Random, 0 = PUBLIC
uint16_t connectionHandle = 0;
@@ -66,6 +72,8 @@ namespace Pinetime {
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15,
0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}
};
+
+ ServiceDiscovery serviceDiscovery;
};
}
}
diff --git a/src/components/ble/NotificationManager.cpp b/src/components/ble/NotificationManager.cpp
new file mode 100644
index 0000000..6771172
--- /dev/null
+++ b/src/components/ble/NotificationManager.cpp
@@ -0,0 +1,81 @@
+#include <cstring>
+#include <algorithm>
+#include "NotificationManager.h"
+
+using namespace Pinetime::Controllers;
+
+constexpr uint8_t NotificationManager::MessageSize;
+
+
+void NotificationManager::Push(NotificationManager::Notification &&notif) {
+ notif.id = GetNextId();
+ notif.valid = true;
+ notifications[writeIndex] = std::move(notif);
+ writeIndex = (writeIndex + 1 < TotalNbNotifications) ? writeIndex + 1 : 0;
+ if(!empty)
+ readIndex = (readIndex + 1 < TotalNbNotifications) ? readIndex + 1 : 0;
+ else empty = false;
+
+ newNotification = true;
+}
+
+NotificationManager::Notification NotificationManager::GetLastNotification() {
+ NotificationManager::Notification notification = notifications[readIndex];
+ notification.index = 1;
+ return notification;
+}
+
+NotificationManager::Notification::Id NotificationManager::GetNextId() {
+ return nextId++;
+}
+
+NotificationManager::Notification NotificationManager::GetNext(NotificationManager::Notification::Id id) {
+ auto currentIterator = std::find_if(notifications.begin(), notifications.end(), [id](const Notification& n){return n.valid && n.id == id;});
+ if(currentIterator == notifications.end() || currentIterator->id != id) return Notification{};
+
+ auto& lastNotification = notifications[readIndex];
+
+ NotificationManager::Notification result;
+
+ if(currentIterator == (notifications.end()-1))
+ result = *(notifications.begin());
+ else
+ result = *(currentIterator+1);
+
+ if(result.id <= id) return {};
+
+ result.index = (lastNotification.id - result.id)+1;
+ return result;
+}
+
+NotificationManager::Notification NotificationManager::GetPrevious(NotificationManager::Notification::Id id) {
+ auto currentIterator = std::find_if(notifications.begin(), notifications.end(), [id](const Notification& n){return n.valid && n.id == id;});
+ if(currentIterator == notifications.end() || currentIterator->id != id) return Notification{};
+
+ auto& lastNotification = notifications[readIndex];
+
+ NotificationManager::Notification result;
+
+ if(currentIterator == notifications.begin())
+ result = *(notifications.end()-1);
+ else
+ result = *(currentIterator-1);
+
+ if(result.id >= id) return {};
+
+ result.index = (lastNotification.id - result.id)+1;
+ return result;
+}
+
+bool NotificationManager::AreNewNotificationsAvailable() {
+ return newNotification;
+}
+
+bool NotificationManager::ClearNewNotificationFlag() {
+ return newNotification.exchange(false);
+}
+
+size_t NotificationManager::NbNotifications() const {
+ return std::count_if(notifications.begin(), notifications.end(), [](const Notification& n){ return n.valid;});
+}
+
diff --git a/src/components/ble/NotificationManager.h b/src/components/ble/NotificationManager.h
new file mode 100644
index 0000000..49fe830
--- /dev/null
+++ b/src/components/ble/NotificationManager.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include <array>
+#include <atomic>
+
+namespace Pinetime {
+ namespace Controllers {
+ class NotificationManager {
+ public:
+ enum class Categories {Unknown, SimpleAlert, Email, News, IncomingCall, MissedCall, Sms, VoiceMail, Schedule, HighProriotyAlert, InstantMessage };
+ static constexpr uint8_t MessageSize{100};
+
+ struct Notification {
+ using Id = uint8_t;
+ Id id;
+ bool valid = false;
+ uint8_t index;
+ std::array<char, MessageSize+1> message;
+ Categories category = Categories::Unknown;
+ };
+ Notification::Id nextId {0};
+
+ void Push(Notification&& notif);
+ Notification GetLastNotification();
+ Notification GetNext(Notification::Id id);
+ Notification GetPrevious(Notification::Id id);
+ bool ClearNewNotificationFlag();
+ bool AreNewNotificationsAvailable();
+
+ static constexpr uint8_t MaximumMessageSize() { return MessageSize; };
+ size_t NbNotifications() const;
+
+ private:
+ Notification::Id GetNextId();
+ static constexpr uint8_t TotalNbNotifications = 5;
+ std::array<Notification, TotalNbNotifications> notifications;
+ uint8_t readIndex = 0;
+ uint8_t writeIndex = 0;
+ bool empty = true;
+ std::atomic<bool> newNotification{false};
+ };
+ }
+} \ No newline at end of file
diff --git a/src/components/ble/ServiceDiscovery.cpp b/src/components/ble/ServiceDiscovery.cpp
new file mode 100644
index 0000000..4b29d89
--- /dev/null
+++ b/src/components/ble/ServiceDiscovery.cpp
@@ -0,0 +1,31 @@
+#include <libraries/log/nrf_log.h>
+#include "ServiceDiscovery.h"
+using namespace Pinetime::Controllers;
+
+ServiceDiscovery::ServiceDiscovery(std::array<BleClient*, 2>&& clients) : clients{clients} {
+
+}
+
+void ServiceDiscovery::StartDiscovery(uint16_t connectionHandle) {
+ NRF_LOG_INFO("[Discovery] Starting discovery");
+ clientIterator = clients.begin();
+ DiscoverNextService(connectionHandle);
+}
+
+void ServiceDiscovery::OnServiceDiscovered(uint16_t connectionHandle) {
+ clientIterator++;
+ if(clientIterator != clients.end()) {
+ DiscoverNextService(connectionHandle);
+ } else {
+ NRF_LOG_INFO("End of service discovery");
+ }
+}
+
+void ServiceDiscovery::DiscoverNextService(uint16_t connectionHandle) {
+ NRF_LOG_INFO("[Discovery] Discover next service");
+
+ auto discoverNextService = [this](uint16_t connectionHandle){
+ this->OnServiceDiscovered(connectionHandle);
+ };
+ (*clientIterator)->Discover(connectionHandle, discoverNextService);
+} \ No newline at end of file
diff --git a/src/components/ble/ServiceDiscovery.h b/src/components/ble/ServiceDiscovery.h
new file mode 100644
index 0000000..c86fc4e
--- /dev/null
+++ b/src/components/ble/ServiceDiscovery.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <array>
+#include <functional>
+#include <memory>
+#include "BleClient.h"
+
+namespace Pinetime {
+ namespace Controllers {
+ class ServiceDiscovery {
+ public:
+ ServiceDiscovery(std::array<BleClient*, 2>&& bleClients);
+
+ void StartDiscovery(uint16_t connectionHandle);
+
+
+ private:
+ BleClient** clientIterator;
+ std::array<BleClient*, 2> clients;
+ void OnServiceDiscovered(uint16_t connectionHandle);
+ void DiscoverNextService(uint16_t connectionHandle);
+ };
+ }
+}
diff --git a/src/Components/Brightness/BrightnessController.cpp b/src/components/brightness/BrightnessController.cpp
index c8825d6..c8825d6 100644
--- a/src/Components/Brightness/BrightnessController.cpp
+++ b/src/components/brightness/BrightnessController.cpp
diff --git a/src/Components/Brightness/BrightnessController.h b/src/components/brightness/BrightnessController.h
index b8354ec..b8354ec 100644
--- a/src/Components/Brightness/BrightnessController.h
+++ b/src/components/brightness/BrightnessController.h
diff --git a/src/Components/DateTime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp
index 30d9c13..30d9c13 100644
--- a/src/Components/DateTime/DateTimeController.cpp
+++ b/src/components/datetime/DateTimeController.cpp
diff --git a/src/Components/DateTime/DateTimeController.h b/src/components/datetime/DateTimeController.h
index d602074..d602074 100644
--- a/src/Components/DateTime/DateTimeController.h
+++ b/src/components/datetime/DateTimeController.h
diff --git a/src/Components/FirmwareValidator/FirmwareValidator.cpp b/src/components/firmwarevalidator/FirmwareValidator.cpp
index 244d5c0..244d5c0 100644
--- a/src/Components/FirmwareValidator/FirmwareValidator.cpp
+++ b/src/components/firmwarevalidator/FirmwareValidator.cpp
diff --git a/src/Components/FirmwareValidator/FirmwareValidator.h b/src/components/firmwarevalidator/FirmwareValidator.h
index aa576d8..aa576d8 100644
--- a/src/Components/FirmwareValidator/FirmwareValidator.h
+++ b/src/components/firmwarevalidator/FirmwareValidator.h
diff --git a/src/Components/Gfx/Gfx.cpp b/src/components/gfx/Gfx.cpp
index 3c5dbfb..3c5dbfb 100644
--- a/src/Components/Gfx/Gfx.cpp
+++ b/src/components/gfx/Gfx.cpp
diff --git a/src/Components/Gfx/Gfx.h b/src/components/gfx/Gfx.h
index 091f06f..091f06f 100644
--- a/src/Components/Gfx/Gfx.h
+++ b/src/components/gfx/Gfx.h
diff --git a/src/DisplayApp/Apps.h b/src/displayapp/Apps.h
index 3842e4e..bfa799b 100644
--- a/src/DisplayApp/Apps.h
+++ b/src/displayapp/Apps.h
@@ -2,6 +2,6 @@
namespace Pinetime {
namespace Applications {
- enum class Apps {None, Launcher, Clock, SysInfo, Meter, Gauge, Brightness, Music, FirmwareValidation, Paint};
+ enum class Apps {None, Launcher, Clock, SysInfo, Meter, Gauge, Brightness, Music, FirmwareValidation, Paint, Notifications};
}
} \ No newline at end of file
diff --git a/src/DisplayApp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index f6138ec..d4d4133 100644
--- a/src/DisplayApp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -1,24 +1,26 @@
+#include <string>
+
#include "DisplayApp.h"
#include <FreeRTOS.h>
#include <task.h>
#include <libraries/log/nrf_log.h>
#include <nrf_font.h>
#include <queue.h>
-#include <Components/DateTime/DateTimeController.h>
+#include "components/datetime/DateTimeController.h"
#include <drivers/Cst816s.h>
-#include <string>
-#include <DisplayApp/Screens/Tile.h>
-#include <DisplayApp/Screens/Meter.h>
-#include <DisplayApp/Screens/Gauge.h>
-#include <DisplayApp/Screens/Brightness.h>
-#include <DisplayApp/Screens/SystemInfo.h>
-#include <DisplayApp/Screens/Music.h>
-#include <Components/Ble/NotificationManager.h>
-#include <DisplayApp/Screens/FirmwareUpdate.h>
-#include <DisplayApp/Screens/ApplicationList.h>
-#include <DisplayApp/Screens/FirmwareValidation.h>
-#include <DisplayApp/Screens/InfiniPaint.h>
-#include "../SystemTask/SystemTask.h"
+#include "displayapp/screens/Notifications.h"
+#include "displayapp/screens/Tile.h"
+#include "displayapp/screens/Meter.h"
+#include "displayapp/screens/Gauge.h"
+#include "displayapp/screens/Brightness.h"
+#include "displayapp/screens/SystemInfo.h"
+#include "displayapp/screens/Music.h"
+#include "components/ble/NotificationManager.h"
+#include "displayapp/screens/FirmwareUpdate.h"
+#include "displayapp/screens/ApplicationList.h"
+#include "displayapp/screens/FirmwareValidation.h"
+#include "displayapp/screens/InfiniPaint.h"
+#include "systemtask/SystemTask.h"
using namespace Pinetime::Applications;
@@ -34,7 +36,7 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver
dateTimeController{dateTimeController},
watchdog{watchdog},
touchPanel{touchPanel},
- currentScreen{new Screens::Clock(this, dateTimeController, batteryController, bleController) },
+ currentScreen{new Screens::Clock(this, dateTimeController, batteryController, bleController, notificationManager) },
systemTask{systemTask},
notificationManager{notificationManager} {
msgQueue = xQueueCreate(queueSize, itemSize);
@@ -43,13 +45,13 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver
}
void DisplayApp::Start() {
- if (pdPASS != xTaskCreate(DisplayApp::Process, "DisplayApp", 512, this, 0, &taskHandle))
+ if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 512, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
void DisplayApp::Process(void *instance) {
auto *app = static_cast<DisplayApp *>(instance);
- NRF_LOG_INFO("DisplayApp task started!");
+ NRF_LOG_INFO("displayapp task started!");
app->InitHw();
// Send a dummy notification to unlock the lvgl display driver for the first iteration
@@ -113,8 +115,12 @@ void DisplayApp::Refresh() {
// clockScreen.SetBatteryPercentRemaining(batteryController.PercentRemaining());
break;
case Messages::NewNotification: {
- auto notification = notificationManager.Pop();
- modal->Show(notification.message.data());
+ if(onClockApp) {
+ currentScreen.reset(nullptr);
+ lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Up);
+ onClockApp = false;
+ currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Preview));
+ }
}
break;
case Messages::TouchEvent: {
@@ -148,7 +154,7 @@ void DisplayApp::Refresh() {
}
}
-// lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Down);
+// lvgl.SetFullRefresh(components::LittleVgl::FullRefreshDirections::Down);
// currentScreen.reset(nullptr);
// if(toggle) {
// currentScreen.reset(new Screens::Tile(this));
@@ -190,7 +196,7 @@ void DisplayApp::RunningState() {
case Apps::None:
case Apps::Launcher: currentScreen.reset(new Screens::ApplicationList(this)); break;
case Apps::Clock:
- currentScreen.reset(new Screens::Clock(this, dateTimeController, batteryController, bleController));
+ currentScreen.reset(new Screens::Clock(this, dateTimeController, batteryController, bleController, notificationManager));
onClockApp = true;
break;
// case Apps::Test: currentScreen.reset(new Screens::Message(this)); break;
@@ -201,6 +207,7 @@ void DisplayApp::RunningState() {
case Apps::Brightness : currentScreen.reset(new Screens::Brightness(this, brightnessController)); break;
case Apps::Music : currentScreen.reset(new Screens::Music(this, systemTask.nimble().music())); break;
case Apps::FirmwareValidation: currentScreen.reset(new Screens::FirmwareValidation(this, validator)); break;
+ case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Normal)); break;
}
nextApp = Apps::None;
}
diff --git a/src/DisplayApp/DisplayApp.h b/src/displayapp/DisplayApp.h
index 345e06d..2a0efde 100644
--- a/src/DisplayApp/DisplayApp.h
+++ b/src/displayapp/DisplayApp.h
@@ -3,21 +3,21 @@
#include <task.h>
#include <drivers/St7789.h>
#include <drivers/SpiMaster.h>
-#include <Components/Gfx/Gfx.h>
#include <bits/unique_ptr.h>
#include <queue.h>
-#include <Components/Battery/BatteryController.h>
-#include <Components/Brightness/BrightnessController.h>
-#include <Components/Ble/BleController.h>
-#include <Components/DateTime/DateTimeController.h>
-#include "../drivers/Cst816s.h"
+#include "components/gfx/Gfx.h"
+#include "components/battery/BatteryController.h"
+#include "components/brightness/BrightnessController.h"
+#include "components/ble/BleController.h"
+#include "components/datetime/DateTimeController.h"
+#include "components/ble/NotificationManager.h"
+#include "components/firmwarevalidator/FirmwareValidator.h"
+#include "drivers/Cst816s.h"
#include "LittleVgl.h"
#include <date/date.h>
-#include <DisplayApp/Screens/Clock.h>
+#include "displayapp/screens/Clock.h"
+#include "displayapp/screens/Modal.h"
#include <drivers/Watchdog.h>
-#include <DisplayApp/Screens/Modal.h>
-#include <Components/Ble/NotificationManager.h>
-#include <Components/FirmwareValidator/FirmwareValidator.h>
#include "TouchEvents.h"
#include "Apps.h"
diff --git a/src/DisplayApp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp
index 3483f8e..3483f8e 100644
--- a/src/DisplayApp/LittleVgl.cpp
+++ b/src/displayapp/LittleVgl.cpp
diff --git a/src/DisplayApp/LittleVgl.h b/src/displayapp/LittleVgl.h
index 5c1c443..5c1c443 100644
--- a/src/DisplayApp/LittleVgl.h
+++ b/src/displayapp/LittleVgl.h
diff --git a/src/DisplayApp/TouchEvents.h b/src/displayapp/TouchEvents.h
index cf2f88d..cf2f88d 100644
--- a/src/DisplayApp/TouchEvents.h
+++ b/src/displayapp/TouchEvents.h
diff --git a/src/DisplayApp/Fonts/Readme.md b/src/displayapp/fonts/Readme.md
index 7ebf2e2..7ebf2e2 100644
--- a/src/DisplayApp/Fonts/Readme.md
+++ b/src/displayapp/fonts/Readme.md
diff --git a/src/DisplayApp/Fonts/jetbrains_mono_bold_20.c b/src/displayapp/fonts/jetbrains_mono_bold_20.c
index 27ad005..27ad005 100644
--- a/src/DisplayApp/Fonts/jetbrains_mono_bold_20.c
+++ b/src/displayapp/fonts/jetbrains_mono_bold_20.c
diff --git a/src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c b/src/displayapp/fonts/jetbrains_mono_extrabold_compressed.c
index c9917e4..c9917e4 100644
--- a/src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c
+++ b/src/displayapp/fonts/jetbrains_mono_extrabold_compressed.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_005.c b/src/displayapp/icons/battery/os_battery_005.c
index 64832b5..64832b5 100644
--- a/src/DisplayApp/Icons/battery/os_battery_005.c
+++ b/src/displayapp/icons/battery/os_battery_005.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_005.png b/src/displayapp/icons/battery/os_battery_005.png
index 963767b..963767b 100644
--- a/src/DisplayApp/Icons/battery/os_battery_005.png
+++ b/src/displayapp/icons/battery/os_battery_005.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_010.c b/src/displayapp/icons/battery/os_battery_010.c
index f36b684..f36b684 100644
--- a/src/DisplayApp/Icons/battery/os_battery_010.c
+++ b/src/displayapp/icons/battery/os_battery_010.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_010.png b/src/displayapp/icons/battery/os_battery_010.png
index 68a9f40..68a9f40 100644
--- a/src/DisplayApp/Icons/battery/os_battery_010.png
+++ b/src/displayapp/icons/battery/os_battery_010.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_020.c b/src/displayapp/icons/battery/os_battery_020.c
index 3f648fb..3f648fb 100644
--- a/src/DisplayApp/Icons/battery/os_battery_020.c
+++ b/src/displayapp/icons/battery/os_battery_020.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_020.png b/src/displayapp/icons/battery/os_battery_020.png
index 32eca65..32eca65 100644
--- a/src/DisplayApp/Icons/battery/os_battery_020.png
+++ b/src/displayapp/icons/battery/os_battery_020.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_030.c b/src/displayapp/icons/battery/os_battery_030.c
index 4d5719b..4d5719b 100644
--- a/src/DisplayApp/Icons/battery/os_battery_030.c
+++ b/src/displayapp/icons/battery/os_battery_030.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_030.png b/src/displayapp/icons/battery/os_battery_030.png
index aeb5eb1..aeb5eb1 100644
--- a/src/DisplayApp/Icons/battery/os_battery_030.png
+++ b/src/displayapp/icons/battery/os_battery_030.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_040.c b/src/displayapp/icons/battery/os_battery_040.c
index 0606fc3..0606fc3 100644
--- a/src/DisplayApp/Icons/battery/os_battery_040.c
+++ b/src/displayapp/icons/battery/os_battery_040.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_040.png b/src/displayapp/icons/battery/os_battery_040.png
index d84fda4..d84fda4 100644
--- a/src/DisplayApp/Icons/battery/os_battery_040.png
+++ b/src/displayapp/icons/battery/os_battery_040.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_050.c b/src/displayapp/icons/battery/os_battery_050.c
index 8732dc7..8732dc7 100644
--- a/src/DisplayApp/Icons/battery/os_battery_050.c
+++ b/src/displayapp/icons/battery/os_battery_050.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_050.png b/src/displayapp/icons/battery/os_battery_050.png
index 224d38d..224d38d 100644
--- a/src/DisplayApp/Icons/battery/os_battery_050.png
+++ b/src/displayapp/icons/battery/os_battery_050.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_060.c b/src/displayapp/icons/battery/os_battery_060.c
index a65936b..a65936b 100644
--- a/src/DisplayApp/Icons/battery/os_battery_060.c
+++ b/src/displayapp/icons/battery/os_battery_060.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_060.png b/src/displayapp/icons/battery/os_battery_060.png
index e5e00ed..e5e00ed 100644
--- a/src/DisplayApp/Icons/battery/os_battery_060.png
+++ b/src/displayapp/icons/battery/os_battery_060.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_070.c b/src/displayapp/icons/battery/os_battery_070.c
index 949c0b8..949c0b8 100644
--- a/src/DisplayApp/Icons/battery/os_battery_070.c
+++ b/src/displayapp/icons/battery/os_battery_070.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_070.png b/src/displayapp/icons/battery/os_battery_070.png
index dee969b..dee969b 100644
--- a/src/DisplayApp/Icons/battery/os_battery_070.png
+++ b/src/displayapp/icons/battery/os_battery_070.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_080.c b/src/displayapp/icons/battery/os_battery_080.c
index f447370..f447370 100644
--- a/src/DisplayApp/Icons/battery/os_battery_080.c
+++ b/src/displayapp/icons/battery/os_battery_080.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_080.png b/src/displayapp/icons/battery/os_battery_080.png
index 3b13fbb..3b13fbb 100644
--- a/src/DisplayApp/Icons/battery/os_battery_080.png
+++ b/src/displayapp/icons/battery/os_battery_080.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_090.c b/src/displayapp/icons/battery/os_battery_090.c
index 6fa41b2..6fa41b2 100644
--- a/src/DisplayApp/Icons/battery/os_battery_090.c
+++ b/src/displayapp/icons/battery/os_battery_090.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_090.png b/src/displayapp/icons/battery/os_battery_090.png
index d79f396..d79f396 100644
--- a/src/DisplayApp/Icons/battery/os_battery_090.png
+++ b/src/displayapp/icons/battery/os_battery_090.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_100.c b/src/displayapp/icons/battery/os_battery_100.c
index 92cf9a4..92cf9a4 100644
--- a/src/DisplayApp/Icons/battery/os_battery_100.c
+++ b/src/displayapp/icons/battery/os_battery_100.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_100.png b/src/displayapp/icons/battery/os_battery_100.png
index dd0d306..dd0d306 100644
--- a/src/DisplayApp/Icons/battery/os_battery_100.png
+++ b/src/displayapp/icons/battery/os_battery_100.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_battery_error.c b/src/displayapp/icons/battery/os_battery_error.c
index af6aba5..af6aba5 100644
--- a/src/DisplayApp/Icons/battery/os_battery_error.c
+++ b/src/displayapp/icons/battery/os_battery_error.c
diff --git a/src/DisplayApp/Icons/battery/os_battery_error.png b/src/displayapp/icons/battery/os_battery_error.png
index 4c7632f..4c7632f 100644
--- a/src/DisplayApp/Icons/battery/os_battery_error.png
+++ b/src/displayapp/icons/battery/os_battery_error.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_005.c b/src/displayapp/icons/battery/os_batterycharging_005.c
index 1b0c71d..1b0c71d 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_005.c
+++ b/src/displayapp/icons/battery/os_batterycharging_005.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_005.png b/src/displayapp/icons/battery/os_batterycharging_005.png
index f9545bc..f9545bc 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_005.png
+++ b/src/displayapp/icons/battery/os_batterycharging_005.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_010.c b/src/displayapp/icons/battery/os_batterycharging_010.c
index 304c018..304c018 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_010.c
+++ b/src/displayapp/icons/battery/os_batterycharging_010.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_010.png b/src/displayapp/icons/battery/os_batterycharging_010.png
index 04d5f82..04d5f82 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_010.png
+++ b/src/displayapp/icons/battery/os_batterycharging_010.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_020.c b/src/displayapp/icons/battery/os_batterycharging_020.c
index 1721be1..1721be1 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_020.c
+++ b/src/displayapp/icons/battery/os_batterycharging_020.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_020.png b/src/displayapp/icons/battery/os_batterycharging_020.png
index 6416e1e..6416e1e 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_020.png
+++ b/src/displayapp/icons/battery/os_batterycharging_020.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_030.c b/src/displayapp/icons/battery/os_batterycharging_030.c
index 83101fd..83101fd 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_030.c
+++ b/src/displayapp/icons/battery/os_batterycharging_030.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_030.png b/src/displayapp/icons/battery/os_batterycharging_030.png
index 96b44d2..96b44d2 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_030.png
+++ b/src/displayapp/icons/battery/os_batterycharging_030.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_040.c b/src/displayapp/icons/battery/os_batterycharging_040.c
index 02af00e..02af00e 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_040.c
+++ b/src/displayapp/icons/battery/os_batterycharging_040.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_040.png b/src/displayapp/icons/battery/os_batterycharging_040.png
index 5a42caf..5a42caf 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_040.png
+++ b/src/displayapp/icons/battery/os_batterycharging_040.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_050.c b/src/displayapp/icons/battery/os_batterycharging_050.c
index d2eea82..d2eea82 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_050.c
+++ b/src/displayapp/icons/battery/os_batterycharging_050.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_050.png b/src/displayapp/icons/battery/os_batterycharging_050.png
index ca0e04d..ca0e04d 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_050.png
+++ b/src/displayapp/icons/battery/os_batterycharging_050.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_060.c b/src/displayapp/icons/battery/os_batterycharging_060.c
index 05f8b97..05f8b97 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_060.c
+++ b/src/displayapp/icons/battery/os_batterycharging_060.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_060.png b/src/displayapp/icons/battery/os_batterycharging_060.png
index 2930068..2930068 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_060.png
+++ b/src/displayapp/icons/battery/os_batterycharging_060.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_070.c b/src/displayapp/icons/battery/os_batterycharging_070.c
index ac3e319..ac3e319 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_070.c
+++ b/src/displayapp/icons/battery/os_batterycharging_070.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_070.png b/src/displayapp/icons/battery/os_batterycharging_070.png
index 7d5f55d..7d5f55d 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_070.png
+++ b/src/displayapp/icons/battery/os_batterycharging_070.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_080.c b/src/displayapp/icons/battery/os_batterycharging_080.c
index cc1c1d2..cc1c1d2 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_080.c
+++ b/src/displayapp/icons/battery/os_batterycharging_080.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_080.png b/src/displayapp/icons/battery/os_batterycharging_080.png
index cce5052..cce5052 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_080.png
+++ b/src/displayapp/icons/battery/os_batterycharging_080.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_090.c b/src/displayapp/icons/battery/os_batterycharging_090.c
index 85e1c26..85e1c26 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_090.c
+++ b/src/displayapp/icons/battery/os_batterycharging_090.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_090.png b/src/displayapp/icons/battery/os_batterycharging_090.png
index fc7b443..fc7b443 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_090.png
+++ b/src/displayapp/icons/battery/os_batterycharging_090.png
Binary files differ
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_100.c b/src/displayapp/icons/battery/os_batterycharging_100.c
index 8dec0cb..8dec0cb 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_100.c
+++ b/src/displayapp/icons/battery/os_batterycharging_100.c
diff --git a/src/DisplayApp/Icons/battery/os_batterycharging_100.png b/src/displayapp/icons/battery/os_batterycharging_100.png
index 7c8ce0c..7c8ce0c 100644
--- a/src/DisplayApp/Icons/battery/os_batterycharging_100.png
+++ b/src/displayapp/icons/battery/os_batterycharging_100.png
Binary files differ
diff --git a/src/DisplayApp/Icons/bluetooth/ck_os_bt_connected.png b/src/displayapp/icons/bluetooth/ck_os_bt_connected.png
index 5371611..5371611 100644
--- a/src/DisplayApp/Icons/bluetooth/ck_os_bt_connected.png
+++ b/src/displayapp/icons/bluetooth/ck_os_bt_connected.png
Binary files differ
diff --git a/src/DisplayApp/Icons/bluetooth/ck_os_bt_disconnected.png b/src/displayapp/icons/bluetooth/ck_os_bt_disconnected.png
index 3275895..3275895 100644
--- a/src/DisplayApp/Icons/bluetooth/ck_os_bt_disconnected.png
+++ b/src/displayapp/icons/bluetooth/ck_os_bt_disconnected.png
Binary files differ
diff --git a/src/DisplayApp/Icons/bluetooth/os_bt_connected.c b/src/displayapp/icons/bluetooth/os_bt_connected.c
index d30dc9d..d30dc9d 100644
--- a/src/DisplayApp/Icons/bluetooth/os_bt_connected.c
+++ b/src/displayapp/icons/bluetooth/os_bt_connected.c
diff --git a/src/DisplayApp/Icons/bluetooth/os_bt_connected.png b/src/displayapp/icons/bluetooth/os_bt_connected.png
index 5371611..5371611 100644
--- a/src/DisplayApp/Icons/bluetooth/os_bt_connected.png
+++ b/src/displayapp/icons/bluetooth/os_bt_connected.png
Binary files differ
diff --git a/src/DisplayApp/Icons/bluetooth/os_bt_disconnected.c b/src/displayapp/icons/bluetooth/os_bt_disconnected.c
index 930179b..930179b 100644
--- a/src/DisplayApp/Icons/bluetooth/os_bt_disconnected.c
+++ b/src/displayapp/icons/bluetooth/os_bt_disconnected.c
diff --git a/src/DisplayApp/Icons/bluetooth/os_bt_disconnected.png b/src/displayapp/icons/bluetooth/os_bt_disconnected.png
index 3275895..3275895 100644
--- a/src/DisplayApp/Icons/bluetooth/os_bt_disconnected.png
+++ b/src/displayapp/icons/bluetooth/os_bt_disconnected.png
Binary files differ
diff --git a/src/displayapp/icons/music/disc.cpp b/src/displayapp/icons/music/disc.cpp
new file mode 100644
index 0000000..0957873
--- /dev/null
+++ b/src/displayapp/icons/music/disc.cpp
@@ -0,0 +1,110 @@
+/* Copyright (C) 2020 Avamander
+
+ This file is part of InfiniTime.
+
+ InfiniTime is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ InfiniTime is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#pragma once
+
+#include "lvgl/lvgl.h"
+
+#ifndef LV_ATTRIBUTE_MEM_ALIGN
+#define LV_ATTRIBUTE_MEM_ALIGN
+#endif
+
+#ifndef LV_ATTRIBUTE_IMG_DISC
+#define LV_ATTRIBUTE_IMG_DISC
+#endif
+
+const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_DISC uint8_t disc_map[] = {
+ 0xbd, 0xc1, 0xbe, 0xff, /* Color of index 0: foreground */
+ 0x00, 0x00, 0x00, 0x00, /* Color of index 1: background */
+
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xfc, 0x00, 0x00, 0x1f, 0xff, 0xff,
+ 0xff, 0xff, 0xf0, 0x0f, 0xf8, 0x07, 0xff, 0xff,
+ 0xff, 0xff, 0xc0, 0xff, 0xff, 0x81, 0xff, 0xff,
+ 0xff, 0xff, 0x07, 0xff, 0xff, 0xf0, 0x7f, 0xff,
+ 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xfc, 0x1f, 0xff,
+ 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0x0f, 0xff,
+ 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x87, 0xff,
+ 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff,
+ 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff,
+ 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff,
+ 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f,
+ 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f,
+ 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f,
+ 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf,
+ 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7,
+ 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7,
+ 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3,
+ 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3,
+ 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1,
+ 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1,
+ 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9,
+ 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9,
+ 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
+ 0x8f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf8,
+ 0x9f, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xfc,
+ 0x9f, 0xff, 0xff, 0xe3, 0xe3, 0xff, 0xff, 0xfc,
+ 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
+ 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
+ 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
+ 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
+ 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
+ 0x9f, 0xff, 0xff, 0xe3, 0xe3, 0xff, 0xff, 0xfc,
+ 0x9f, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xfc,
+ 0x8f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf8,
+ 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
+ 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9,
+ 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9,
+ 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1,
+ 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1,
+ 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3,
+ 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3,
+ 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7,
+ 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7,
+ 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf,
+ 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f,
+ 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f,
+ 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f,
+ 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff,
+ 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff,
+ 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff,
+ 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x87, 0xff,
+ 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0x0f, 0xff,
+ 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xfc, 0x1f, 0xff,
+ 0xff, 0xff, 0x07, 0xff, 0xff, 0xf0, 0x7f, 0xff,
+ 0xff, 0xff, 0xc0, 0xff, 0xff, 0x81, 0xff, 0xff,
+ 0xff, 0xff, 0xf0, 0x0f, 0xf8, 0x07, 0xff, 0xff,
+ 0xff, 0xff, 0xfc, 0x00, 0x00, 0x1f, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xff,
+};
+
+const lv_img_dsc_t disc = {
+ {
+ LV_IMG_CF_INDEXED_1BIT,
+ 0,
+ 0,
+ 64,
+ 64
+ },
+ 520,
+ disc_map
+}; \ No newline at end of file
diff --git a/src/displayapp/icons/music/disc.png b/src/displayapp/icons/music/disc.png
new file mode 100644
index 0000000..699734f
--- /dev/null
+++ b/src/displayapp/icons/music/disc.png
Binary files differ
diff --git a/src/displayapp/icons/music/disc_f_1.cpp b/src/displayapp/icons/music/disc_f_1.cpp
new file mode 100644
index 0000000..9b6b741
--- /dev/null
+++ b/src/displayapp/icons/music/disc_f_1.cpp
@@ -0,0 +1,79 @@
+/* Copyright (C) 2020 Avamander
+
+ This file is part of InfiniTime.
+
+ InfiniTime is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ InfiniTime is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#pragma once
+
+#include "lvgl/lvgl.h"
+
+#ifndef LV_ATTRIBUTE_MEM_ALIGN
+#define LV_ATTRIBUTE_MEM_ALIGN
+#endif
+
+#ifndef LV_ATTRIBUTE_IMG_DISC_F_1
+#define LV_ATTRIBUTE_IMG_DISC_F_1
+#endif
+
+const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_DISC_F_1 uint8_t disc_f_1_map[] = {
+ 0xbd, 0xc1, 0xbe, 0xff, /* Color of index 0: foreground */
+ 0x00, 0x00, 0x00, 0x00, /* Color of index 1: background */
+
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xc0,
+ 0xff, 0xff, 0xfc, 0x00,
+ 0xff, 0xff, 0xf0, 0x0f,
+ 0xff, 0xff, 0xc0, 0xff,
+ 0xff, 0xff, 0x07, 0xff,
+ 0xff, 0xfc, 0x1f, 0xff,
+ 0xff, 0xf8, 0x7f, 0xff,
+ 0xff, 0xf0, 0xff, 0xff,
+ 0xff, 0xe3, 0xff, 0xff,
+ 0xff, 0xc7, 0xf3, 0xff,
+ 0xff, 0x8f, 0xc3, 0xff,
+ 0xff, 0x1f, 0x87, 0xff,
+ 0xfe, 0x3f, 0x0f, 0xff,
+ 0xfc, 0x7e, 0x1f, 0xff,
+ 0xfc, 0x7c, 0x3f, 0xff,
+ 0xf8, 0xfc, 0x7f, 0xff,
+ 0xf9, 0xfc, 0xff, 0xff,
+ 0xf1, 0xff, 0xff, 0xff,
+ 0xf3, 0xff, 0xff, 0xff,
+ 0xe3, 0xff, 0xff, 0xff,
+ 0xe7, 0xff, 0xff, 0xff,
+ 0xc7, 0xff, 0xff, 0xff,
+ 0xc7, 0xff, 0xff, 0xff,
+ 0xcf, 0xff, 0xff, 0xff,
+ 0xcf, 0xff, 0xff, 0xff,
+ 0x8f, 0xff, 0xff, 0xff,
+ 0x8f, 0xff, 0xff, 0xf8,
+ 0x9f, 0xff, 0xff, 0xf0,
+ 0x9f, 0xff, 0xff, 0xe3,
+ 0x9f, 0xff, 0xff, 0xe7,
+ 0x9f, 0xff, 0xff, 0xe7,
+};
+
+const lv_img_dsc_t disc_f_1 = {
+ {
+ LV_IMG_CF_INDEXED_1BIT,
+ 0,
+ 0,
+ 32,
+ 32
+ },
+ 136,
+ disc_f_1_map
+};
+
diff --git a/src/displayapp/icons/music/disc_f_1.png b/src/displayapp/icons/music/disc_f_1.png
new file mode 100644
index 0000000..9465773
--- /dev/null
+++ b/src/displayapp/icons/music/disc_f_1.png
Binary files differ
diff --git a/src/displayapp/icons/music/disc_f_2.cpp b/src/displayapp/icons/music/disc_f_2.cpp
new file mode 100644
index 0000000..3d2331d
--- /dev/null
+++ b/src/displayapp/icons/music/disc_f_2.cpp
@@ -0,0 +1,79 @@
+/* Copyright (C) 2020 Avamander
+
+ This file is part of InfiniTime.
+
+ InfiniTime is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ InfiniTime is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#pragma once
+
+#include "lvgl/lvgl.h"
+
+#ifndef LV_ATTRIBUTE_MEM_ALIGN
+#define LV_ATTRIBUTE_MEM_ALIGN
+#endif
+
+#ifndef LV_ATTRIBUTE_IMG_DISC_F_2
+#define LV_ATTRIBUTE_IMG_DISC_F_2
+#endif
+
+const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_DISC_F_2 uint8_t disc_f_2_map[] = {
+ 0xbd, 0xc1, 0xbe, 0xff, /* Color of index 0: foreground */
+ 0x00, 0x00, 0x00, 0x00, /* Color of index 1: background */
+
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xc0,
+ 0xff, 0xff, 0xfc, 0x00,
+ 0xff, 0xff, 0xf0, 0x0f,
+ 0xff, 0xff, 0xc0, 0xff,
+ 0xff, 0xff, 0x07, 0xff,
+ 0xff, 0xfc, 0x1f, 0xff,
+ 0xff, 0xf8, 0x7f, 0xf1,
+ 0xff, 0xf0, 0xff, 0x00,
+ 0xff, 0xe3, 0xfc, 0x03,
+ 0xff, 0xc7, 0xf0, 0x3f,
+ 0xff, 0x8f, 0xf0, 0xff,
+ 0xff, 0x1f, 0xf3, 0xff,
+ 0xfe, 0x3f, 0xff, 0xff,
+ 0xfc, 0x7f, 0xff, 0xff,
+ 0xfc, 0x7f, 0xff, 0xff,
+ 0xf8, 0xff, 0xff, 0xff,
+ 0xf9, 0xff, 0xff, 0xff,
+ 0xf1, 0xff, 0xff, 0xff,
+ 0xf3, 0xff, 0xff, 0xff,
+ 0xe3, 0xff, 0xff, 0xff,
+ 0xe7, 0xff, 0xff, 0xff,
+ 0xc7, 0xff, 0xff, 0xff,
+ 0xc7, 0xff, 0xff, 0xff,
+ 0xcf, 0xff, 0xff, 0xff,
+ 0xcf, 0xff, 0xff, 0xff,
+ 0x8f, 0xff, 0xff, 0xff,
+ 0x8f, 0xff, 0xff, 0xf8,
+ 0x9f, 0xff, 0xff, 0xf0,
+ 0x9f, 0xff, 0xff, 0xe3,
+ 0x9f, 0xff, 0xff, 0xe7,
+ 0x9f, 0xff, 0xff, 0xe7,
+};
+
+const lv_img_dsc_t disc_f_2 = {
+ {
+ LV_IMG_CF_INDEXED_1BIT,
+ 0,
+ 0,
+ 32,
+ 32
+ },
+ 136,
+ disc_f_2_map
+};
+
diff --git a/src/displayapp/icons/music/disc_f_2.png b/src/displayapp/icons/music/disc_f_2.png
new file mode 100644
index 0000000..4d9a4a3
--- /dev/null
+++ b/src/displayapp/icons/music/disc_f_2.png
Binary files differ
diff --git a/src/DisplayApp/Screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp
index eb85be4..7eb9718 100644
--- a/src/DisplayApp/Screens/ApplicationList.cpp
+++ b/src/displayapp/screens/ApplicationList.cpp
@@ -1,5 +1,5 @@
#include <libs/lvgl/lvgl.h>
-#include <DisplayApp/DisplayApp.h>
+#include <displayapp/DisplayApp.h>
#include <functional>
#include "ApplicationList.h"
#include "Tile.h"
@@ -58,9 +58,9 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
{{Symbols::tachometer, Apps::Gauge},
{Symbols::asterisk, Apps::Meter},
{Symbols::paintbrush, Apps::Paint},
- {Symbols::none, Apps::None},
- {Symbols::none, Apps::None},
- {Symbols::none, Apps::None}
+ {Symbols::info, Apps::Notifications},
+ {Symbols::none, Apps::None},
+ {Symbols::none, Apps::None}
}
};
diff --git a/src/DisplayApp/Screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h
index a1e6811..9c95acb 100644
--- a/src/DisplayApp/Screens/ApplicationList.h
+++ b/src/displayapp/screens/ApplicationList.h
@@ -1,13 +1,14 @@
#pragma once
+#include <functional>
#include <vector>
-#include <Components/Ble/NimbleController.h>
+
+#include "components/ble/NimbleController.h"
#include "Screen.h"
#include "Label.h"
#include "ScreenList.h"
#include "Gauge.h"
#include "Meter.h"
-#include <functional>
namespace Pinetime {
namespace Applications {
diff --git a/src/DisplayApp/Screens/BatteryIcon.cpp b/src/displayapp/screens/BatteryIcon.cpp
index 26939d1..26939d1 100644
--- a/src/DisplayApp/Screens/BatteryIcon.cpp
+++ b/src/displayapp/screens/BatteryIcon.cpp
diff --git a/src/DisplayApp/Screens/BatteryIcon.h b/src/displayapp/screens/BatteryIcon.h
index 58f04a8..58f04a8 100644
--- a/src/DisplayApp/Screens/BatteryIcon.h
+++ b/src/displayapp/screens/BatteryIcon.h
diff --git a/src/DisplayApp/Screens/BleIcon.cpp b/src/displayapp/screens/BleIcon.cpp
index 1bbbd05..1bbbd05 100644
--- a/src/DisplayApp/Screens/BleIcon.cpp
+++ b/src/displayapp/screens/BleIcon.cpp
diff --git a/src/DisplayApp/Screens/BleIcon.h b/src/displayapp/screens/BleIcon.h
index c1398d2..c1398d2 100644
--- a/src/DisplayApp/Screens/BleIcon.h
+++ b/src/displayapp/screens/BleIcon.h
diff --git a/src/DisplayApp/Screens/Brightness.cpp b/src/displayapp/screens/Brightness.cpp
index 9e3416c..8ea9a77 100644
--- a/src/DisplayApp/Screens/Brightness.cpp
+++ b/src/displayapp/screens/Brightness.cpp
@@ -11,15 +11,15 @@ void slider_event_cb(lv_obj_t * slider, lv_event_t event) {
}
Brightness::Brightness(Pinetime::Applications::DisplayApp *app, Controllers::BrightnessController& brightness) : Screen(app), brightness{brightness} {
- slider = lv_slider_create(lv_scr_act(), NULL);
+ slider = lv_slider_create(lv_scr_act(), nullptr);
lv_obj_set_user_data(slider, this);
lv_obj_set_width(slider, LV_DPI * 2);
- lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
+ lv_obj_align(slider, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_event_cb(slider, slider_event_cb);
lv_slider_set_range(slider, 0, 2);
lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF);
- slider_label = lv_label_create(lv_scr_act(), NULL);
+ slider_label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(slider_label, LevelToString(brightness.Level()));
lv_obj_set_auto_realign(slider_label, true);
lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
diff --git a/src/DisplayApp/Screens/Brightness.h b/src/displayapp/screens/Brightness.h
index 37cbcd7..7d599ac 100644
--- a/src/DisplayApp/Screens/Brightness.h
+++ b/src/displayapp/screens/Brightness.h
@@ -1,7 +1,7 @@
#pragma once
#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include <Components/Brightness/BrightnessController.h>
+#include "components/brightness/BrightnessController.h"
#include "Screen.h"
namespace Pinetime {
diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 06fab9a..977321c1 100644
--- a/src/DisplayApp/Screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -1,12 +1,16 @@
#include <cstdio>
+
#include <libs/date/includes/date/date.h>
-#include <Components/DateTime/DateTimeController.h>
+#include "components/datetime/DateTimeController.h"
#include <libs/lvgl/lvgl.h>
#include "Clock.h"
#include "../DisplayApp.h"
#include "BatteryIcon.h"
#include "BleIcon.h"
#include "Symbols.h"
+#include "components/ble/NotificationManager.h"
+#include "NotificationIcon.h"
+
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
@@ -20,36 +24,41 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
Clock::Clock(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
- Controllers::Ble& bleController) : Screen(app), currentDateTime{{}},
- dateTimeController{dateTimeController}, batteryController{batteryController}, bleController{bleController} {
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager) : Screen(app), currentDateTime{{}},
+ dateTimeController{dateTimeController}, batteryController{batteryController},
+ bleController{bleController}, notificatioManager{notificatioManager} {
displayedChar[0] = 0;
displayedChar[1] = 0;
displayedChar[2] = 0;
displayedChar[3] = 0;
displayedChar[4] = 0;
- batteryIcon = lv_label_create(lv_scr_act(), NULL);
+ batteryIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(batteryIcon, Symbols::batteryFull);
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, -5, 2);
- batteryPlug = lv_label_create(lv_scr_act(), NULL);
+ batteryPlug = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(batteryPlug, Symbols::plug);
lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
- bleIcon = lv_label_create(lv_scr_act(), NULL);
+ bleIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(bleIcon, Symbols::bluetooth);
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ notificationIcon = lv_label_create(lv_scr_act(), NULL);
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 10, 0);
- label_date = lv_label_create(lv_scr_act(), NULL);
+ label_date = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
- label_time = lv_label_create(lv_scr_act(), NULL);
+ label_time = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_style(label_time, LV_LABEL_STYLE_MAIN, LabelBigStyle);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
- backgroundLabel = lv_label_create(lv_scr_act(), NULL);
+ backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
backgroundLabel->user_data = this;
lv_obj_set_click(backgroundLabel, true);
lv_obj_set_event_cb(backgroundLabel, event_handler);
@@ -59,23 +68,23 @@ Clock::Clock(DisplayApp* app,
lv_label_set_text(backgroundLabel, "");
- heartbeatIcon = lv_label_create(lv_scr_act(), NULL);
+ heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(heartbeatIcon, Symbols::heartBeat);
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2);
- heartbeatValue = lv_label_create(lv_scr_act(), NULL);
+ heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(heartbeatValue, "0");
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
- heartbeatBpm = lv_label_create(lv_scr_act(), NULL);
+ heartbeatBpm = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(heartbeatBpm, "BPM");
lv_obj_align(heartbeatBpm, heartbeatValue, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
- stepValue = lv_label_create(lv_scr_act(), NULL);
+ stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(stepValue, "0");
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2);
- stepIcon = lv_label_create(lv_scr_act(), NULL);
+ stepIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
}
@@ -105,6 +114,14 @@ bool Clock::Refresh() {
lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ notificationState = notificatioManager.AreNewNotificationsAvailable();
+ if(notificationState.IsUpdated()) {
+ if(notificationState.Get() == true)
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true));
+ else
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ }
+
currentDateTime = dateTimeController.CurrentDateTime();
if(currentDateTime.IsUpdated()) {
diff --git a/src/DisplayApp/Screens/Clock.h b/src/displayapp/screens/Clock.h
index 7363fda..58149a7 100644
--- a/src/DisplayApp/Screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -2,12 +2,14 @@
#include <cstdint>
#include <chrono>
+
#include "Screen.h"
#include <bits/unique_ptr.h>
#include <libs/lvgl/src/lv_core/lv_style.h>
#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include <Components/Battery/BatteryController.h>
-#include <Components/Ble/BleController.h>
+#include "components/ble/NotificationManager.h"
+#include "components/battery/BatteryController.h"
+#include "components/ble/BleController.h"
namespace Pinetime {
namespace Applications {
@@ -37,7 +39,8 @@ namespace Pinetime {
Clock(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
- Controllers::Ble& bleController);
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager);
~Clock() override;
bool Refresh() override;
@@ -62,23 +65,25 @@ namespace Pinetime {
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
DirtyValue<uint32_t> stepCount {0};
DirtyValue<uint8_t> heartbeat {0};
-
+ DirtyValue<bool> notificationState {false};
lv_obj_t* label_time;
lv_obj_t* label_date;
lv_obj_t* backgroundLabel;
- lv_obj_t * batteryIcon;
- lv_obj_t * bleIcon;
+ lv_obj_t* batteryIcon;
+ lv_obj_t* bleIcon;
lv_obj_t* batteryPlug;
lv_obj_t* heartbeatIcon;
lv_obj_t* heartbeatValue;
lv_obj_t* heartbeatBpm;
lv_obj_t* stepIcon;
lv_obj_t* stepValue;
+ lv_obj_t* notificationIcon;
Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
Controllers::Ble& bleController;
+ Controllers::NotificationManager& notificatioManager;
bool running = true;
diff --git a/src/DisplayApp/Screens/DropDownDemo.cpp b/src/displayapp/screens/DropDownDemo.cpp
index 735a0cc..ce3acd5 100644
--- a/src/DisplayApp/Screens/DropDownDemo.cpp
+++ b/src/displayapp/screens/DropDownDemo.cpp
@@ -9,7 +9,7 @@ extern lv_font_t jetbrains_mono_bold_20;
DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp *app) : Screen(app) {
// Create the dropdown object, with many item, and fix its height
- ddlist = lv_ddlist_create(lv_scr_act(), NULL);
+ ddlist = lv_ddlist_create(lv_scr_act(), nullptr);
lv_ddlist_set_options(ddlist, "Apple\n"
"Banana\n"
"Orange\n"
@@ -24,7 +24,7 @@ DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp *app) : Screen(app
lv_ddlist_set_fix_width(ddlist, 150);
lv_ddlist_set_draw_arrow(ddlist, true);
lv_ddlist_set_fix_height(ddlist, 150);
- lv_obj_align(ddlist, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);
+ lv_obj_align(ddlist, nullptr, LV_ALIGN_IN_TOP_MID, 0, 20);
}
DropDownDemo::~DropDownDemo() {
diff --git a/src/DisplayApp/Screens/DropDownDemo.h b/src/displayapp/screens/DropDownDemo.h
index 7c75efc..7c75efc 100644
--- a/src/DisplayApp/Screens/DropDownDemo.h
+++ b/src/displayapp/screens/DropDownDemo.h
diff --git a/src/DisplayApp/Screens/FirmwareUpdate.cpp b/src/displayapp/screens/FirmwareUpdate.cpp
index e831114..778409e 100644
--- a/src/DisplayApp/Screens/FirmwareUpdate.cpp
+++ b/src/displayapp/screens/FirmwareUpdate.cpp
@@ -10,19 +10,19 @@ extern lv_font_t jetbrains_mono_bold_20;
FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Ble& bleController) :
Screen(app), bleController{bleController} {
- titleLabel = lv_label_create(lv_scr_act(), NULL);
+ titleLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(titleLabel, "Firmware update");
lv_obj_set_auto_realign(titleLabel, true);
- lv_obj_align(titleLabel, NULL, LV_ALIGN_IN_TOP_MID, 0, 50);
+ lv_obj_align(titleLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 50);
- bar1 = lv_bar_create(lv_scr_act(), NULL);
+ bar1 = lv_bar_create(lv_scr_act(), nullptr);
lv_obj_set_size(bar1, 200, 30);
- lv_obj_align(bar1, NULL, LV_ALIGN_CENTER, 0, 0);
+ lv_obj_align(bar1, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_bar_set_anim_time(bar1, 10);
lv_bar_set_range(bar1, 0, 100);
lv_bar_set_value(bar1, 0, LV_ANIM_OFF);
- percentLabel = lv_label_create(lv_scr_act(), NULL);
+ percentLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(percentLabel, "");
lv_obj_set_auto_realign(percentLabel, true);
lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60);
diff --git a/src/DisplayApp/Screens/FirmwareUpdate.h b/src/displayapp/screens/FirmwareUpdate.h
index faaf395..893fe68 100644
--- a/src/DisplayApp/Screens/FirmwareUpdate.h
+++ b/src/displayapp/screens/FirmwareUpdate.h
@@ -2,11 +2,12 @@
#include <cstdint>
#include <chrono>
+
#include "Screen.h"
#include <bits/unique_ptr.h>
#include <libs/lvgl/src/lv_core/lv_style.h>
#include <libs/lvgl/src/lv_core/lv_obj.h>
-#include <Components/Ble/BleController.h>
+#include "components/ble/BleController.h"
namespace Pinetime {
namespace Applications {
diff --git a/src/DisplayApp/Screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp
index fb2dd95..4ac399f 100644
--- a/src/DisplayApp/Screens/FirmwareValidation.cpp
+++ b/src/displayapp/screens/FirmwareValidation.cpp
@@ -2,7 +2,7 @@
#include "FirmwareValidation.h"
#include "../DisplayApp.h"
#include "../../Version.h"
-#include "../../Components/FirmwareValidator/FirmwareValidator.h"
+#include "components/firmwarevalidator/FirmwareValidator.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
@@ -20,20 +20,20 @@ namespace {
FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp *app,
Pinetime::Controllers::FirmwareValidator &validator)
: Screen{app}, validator{validator} {
- labelVersionInfo = lv_label_create(lv_scr_act(), NULL);
- lv_obj_align(labelVersionInfo, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
+ labelVersionInfo = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(labelVersionInfo, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
lv_label_set_text(labelVersionInfo, "Version : ");
lv_label_set_align(labelVersionInfo, LV_LABEL_ALIGN_LEFT);
- labelVersionValue = lv_label_create(lv_scr_act(), NULL);
+ labelVersionValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(labelVersionValue, labelVersionInfo, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
lv_label_set_recolor(labelVersionValue, true);
sprintf(version, "%ld.%ld.%ld", Version::Major(), Version::Minor(), Version::Patch());
lv_label_set_text(labelVersionValue, version);
- labelIsValidated = lv_label_create(lv_scr_act(), NULL);
- lv_obj_align(labelIsValidated, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 50);
+ labelIsValidated = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(labelIsValidated, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 50);
lv_label_set_recolor(labelIsValidated, true);
lv_label_set_long_mode(labelIsValidated, LV_LABEL_LONG_BREAK);
lv_obj_set_width(labelIsValidated, 240);
@@ -44,21 +44,21 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp *app,
lv_label_set_text(labelIsValidated,
"Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
- buttonValidate = lv_btn_create(lv_scr_act(), NULL);
+ buttonValidate = lv_btn_create(lv_scr_act(), nullptr);
lv_obj_align(buttonValidate, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
buttonValidate->user_data = this;
lv_obj_set_event_cb(buttonValidate, ButtonEventHandler);
- labelButtonValidate = lv_label_create(buttonValidate, NULL);
+ labelButtonValidate = lv_label_create(buttonValidate, nullptr);
lv_label_set_recolor(labelButtonValidate, true);
lv_label_set_text(labelButtonValidate, "#00ff00 Validate#");
- buttonReset = lv_btn_create(lv_scr_act(), NULL);
+ buttonReset = lv_btn_create(lv_scr_act(), nullptr);
buttonReset->user_data = this;
- lv_obj_align(buttonReset, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
+ lv_obj_align(buttonReset, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_set_event_cb(buttonReset, ButtonEventHandler);
- labelButtonReset = lv_label_create(buttonReset, NULL);
+ labelButtonReset = lv_label_create(buttonReset, nullptr);
lv_label_set_recolor(labelButtonReset, true);
lv_label_set_text(labelButtonReset, "#ff0000 Reset#");
}
diff --git a/src/DisplayApp/Screens/FirmwareValidation.h b/src/displayapp/screens/FirmwareValidation.h
index 947f557..947f557 100644
--- a/src/DisplayApp/Screens/FirmwareValidation.h
+++ b/src/displayapp/screens/FirmwareValidation.h
diff --git a/src/DisplayApp/Screens/Gauge.cpp b/src/displayapp/screens/Gauge.cpp
index fd90523..81c283c 100644
--- a/src/DisplayApp/Screens/Gauge.cpp
+++ b/src/displayapp/screens/Gauge.cpp
@@ -25,11 +25,11 @@ Gauge::Gauge(Pinetime::Applications::DisplayApp *app) : Screen(app) {
needle_colors[0] = LV_COLOR_ORANGE;
/*Create a gauge*/
- gauge1 = lv_gauge_create(lv_scr_act(), NULL);
+ gauge1 = lv_gauge_create(lv_scr_act(), nullptr);
lv_gauge_set_style(gauge1, LV_GAUGE_STYLE_MAIN, &style);
lv_gauge_set_needle_count(gauge1, 1, needle_colors);
lv_obj_set_size(gauge1, 180, 180);
- lv_obj_align(gauge1, NULL, LV_ALIGN_CENTER, 0, 0);
+ lv_obj_align(gauge1, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_gauge_set_scale(gauge1, 360, 60, 0);
lv_gauge_set_range(gauge1, 0, 59);
diff --git a/src/DisplayApp/Screens/Gauge.h b/src/displayapp/screens/Gauge.h
index 03c06be..03c06be 100644
--- a/src/DisplayApp/Screens/Gauge.h
+++ b/src/displayapp/screens/Gauge.h
diff --git a/src/DisplayApp/Screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp
index b340f5d..3ea75e9 100644
--- a/src/DisplayApp/Screens/InfiniPaint.cpp
+++ b/src/displayapp/screens/InfiniPaint.cpp
@@ -7,9 +7,9 @@ using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
-InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp *app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl{lvgl} {
+InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl{lvgl} {
app->SetTouchMode(DisplayApp::TouchModes::Polling);
- std::fill(b, b+bufferSize, LV_COLOR_WHITE);
+ std::fill(b, b + bufferSize, LV_COLOR_WHITE);
}
InfiniPaint::~InfiniPaint() {
@@ -33,10 +33,10 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
bool InfiniPaint::OnTouchEvent(uint16_t x, uint16_t y) {
lv_area_t area;
- area.x1 = x-(width/2);
- area.y1 = y-(height/2);
- area.x2 = x+(width/2)-1;
- area.y2 = y+(height/2)-1;
+ area.x1 = x - (width / 2);
+ area.y1 = y - (height / 2);
+ area.x2 = x + (width / 2) - 1;
+ area.y2 = y + (height / 2) - 1;
lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None);
lvgl.FlushDisplay(&area, b);
return true;
diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h
new file mode 100644
index 0000000..f29135d
--- /dev/null
+++ b/src/displayapp/screens/InfiniPaint.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <cstdint>
+#include "Screen.h"
+#include <bits/unique_ptr.h>
+#include <libs/lvgl/src/lv_core/lv_style.h>
+#include <libs/lvgl/src/lv_core/lv_obj.h>
+#include <drivers/St7789.h>
+#include "displayapp/LittleVgl.h"
+
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
+
+ class InfiniPaint : public Screen {
+ public:
+ InfiniPaint(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
+
+ ~InfiniPaint() override;
+
+ bool Refresh() override;
+
+ bool OnButtonPushed() override;
+
+ bool OnTouchEvent(TouchEvents event) override;
+
+ bool OnTouchEvent(uint16_t x, uint16_t y) override;
+
+ private:
+ Pinetime::Components::LittleVgl& lvgl;
+ static constexpr uint16_t width = 10;
+ static constexpr uint16_t height = 10;
+ static constexpr uint16_t bufferSize = width * height;
+ lv_color_t b[bufferSize];
+ bool running = true;
+ };
+ }
+ }
+}
diff --git a/src/DisplayApp/Screens/Label.cpp b/src/displayapp/screens/Label.cpp
index 780ee88..540776c 100644
--- a/src/DisplayApp/Screens/Label.cpp
+++ b/src/displayapp/screens/Label.cpp
@@ -4,7 +4,7 @@
using namespace Pinetime::Applications::Screens;
Label::Label(Pinetime::Applications::DisplayApp *app, const char *text) : Screen(app), text{text} {
- label = lv_label_create(lv_scr_act(), NULL);
+ label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_align(label, LV_LABEL_ALIGN_LEFT);
lv_obj_set_size(label, 240, 240);
lv_label_set_text(label, text);
diff --git a/src/DisplayApp/Screens/Label.h b/src/displayapp/screens/Label.h
index 3e7b379..3e7b379 100644
--- a/src/DisplayApp/Screens/Label.h
+++ b/src/displayapp/screens/Label.h
diff --git a/src/DisplayApp/Screens/Meter.cpp b/src/displayapp/screens/Meter.cpp
index c74b8bd..273e111 100644
--- a/src/DisplayApp/Screens/Meter.cpp
+++ b/src/displayapp/screens/Meter.cpp
@@ -17,14 +17,14 @@ Meter::Meter(Pinetime::Applications::DisplayApp *app) : Screen(app) {
style_lmeter.body.padding.left = 16; /*Line length*/
/*Create a line meter */
- lmeter = lv_lmeter_create(lv_scr_act(), NULL);
+ lmeter = lv_lmeter_create(lv_scr_act(), nullptr);
lv_lmeter_set_range(lmeter, 0, 60); /*Set the range*/
lv_lmeter_set_value(lmeter, value); /*Set the current value*/
lv_lmeter_set_angle_offset(lmeter, 180);
lv_lmeter_set_scale(lmeter, 360, 60); /*Set the angle and number of lines*/
lv_lmeter_set_style(lmeter, LV_LMETER_STYLE_MAIN, &style_lmeter); /*Apply the new style*/
lv_obj_set_size(lmeter, 150, 150);
- lv_obj_align(lmeter, NULL, LV_ALIGN_CENTER, 0, 0);
+ lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
}
diff --git a/src/DisplayApp/Screens/Meter.h b/src/displayapp/screens/Meter.h
index ddf8be8..ddf8be8 100644
--- a/src/DisplayApp/Screens/Meter.h
+++ b/src/displayapp/screens/Meter.h
diff --git a/src/DisplayApp/Screens/Modal.cpp b/src/displayapp/screens/Modal.cpp
index 63ae70c..29f7bfa 100644
--- a/src/DisplayApp/Screens/Modal.cpp
+++ b/src/displayapp/screens/Modal.cpp
@@ -54,7 +54,7 @@ void Modal::Show(const char* msg) {
modal_style.body.main_color = modal_style.body.grad_color = LV_COLOR_BLACK;
modal_style.body.opa = LV_OPA_50;
- obj = lv_obj_create(lv_scr_act(), NULL);
+ obj = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style(obj, &modal_style);
lv_obj_set_pos(obj, 0, 0);
lv_obj_set_size(obj, LV_HOR_RES, LV_VER_RES);
@@ -63,10 +63,10 @@ void Modal::Show(const char* msg) {
static const char * btns2[] = {"Ok", ""};
/* Create the message box as a child of the modal background */
- mbox = lv_mbox_create(obj, NULL);
+ mbox = lv_mbox_create(obj, nullptr);
lv_mbox_add_btns(mbox, btns2);
lv_mbox_set_text(mbox, msg);
- lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
+ lv_obj_align(mbox, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_event_cb(mbox, Modal::mbox_event_cb);
mbox->user_data = this;
diff --git a/src/DisplayApp/Screens/Modal.h b/src/displayapp/screens/Modal.h
index c616c29..c616c29 100644
--- a/src/DisplayApp/Screens/Modal.h
+++ b/src/displayapp/screens/Modal.h
diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp
new file mode 100644
index 0000000..225a15a
--- /dev/null
+++ b/src/displayapp/screens/Music.cpp
@@ -0,0 +1,292 @@
+/* Copyright (C) 2020 JF, Adam Pigg, Avamander
+
+ This file is part of InfiniTime.
+
+ InfiniTime is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ InfiniTime is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#include <libs/lvgl/lvgl.h>
+
+#include "Music.h"
+
+using namespace Pinetime::Applications::Screens;
+
+extern lv_font_t jetbrains_mono_extrabold_compressed;
+extern lv_font_t jetbrains_mono_bold_20;
+
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
+ Music *screen = static_cast<Music *>(obj->user_data);
+ screen->OnObjectEvent(obj, event);
+}
+
+/**
+ * Set the pixel array to display by the image
+ * This just calls lv_img_set_src but adds type safety
+ *
+ * @param img pointer to an image object
+ * @param data the image array
+ */
+inline void lv_img_set_src_arr(lv_obj_t *img, const lv_img_dsc_t *src_img) {
+ lv_img_set_src(img, src_img);
+}
+
+/**
+ * Music control watchapp
+ *
+ * TODO: Investigate Apple Media Service and AVRCPv1.6 support for seamless integration
+ */
+Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::MusicService &music) : Screen(app), musicService(music) {
+ lv_obj_t *label;
+
+ btnVolDown = lv_btn_create(lv_scr_act(), nullptr);
+ btnVolDown->user_data = this;
+ lv_obj_set_event_cb(btnVolDown, event_handler);
+ lv_obj_set_size(btnVolDown, LV_HOR_RES / 3, 80);
+ lv_obj_align(btnVolDown, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
+ label = lv_label_create(btnVolDown, nullptr);
+ lv_label_set_text(label, "V-");
+ lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
+
+ btnVolUp = lv_btn_create(lv_scr_act(), nullptr);
+ btnVolUp->user_data = this;
+ lv_obj_set_event_cb(btnVolUp, event_handler);
+ lv_obj_set_size(btnVolUp, LV_HOR_RES / 3, 80);
+ lv_obj_align(btnVolUp, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
+ label = lv_label_create(btnVolUp, nullptr);
+ lv_label_set_text(label, "V+");
+ lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
+
+ btnPrev = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrev->user_data = this;
+ lv_obj_set_event_cb(btnPrev, event_handler);
+ lv_obj_set_size(btnPrev, LV_HOR_RES / 3, 80);
+ lv_obj_align(btnPrev, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
+ label = lv_label_create(btnPrev, nullptr);
+ lv_label_set_text(label, "<<");
+
+ btnNext = lv_btn_create(lv_scr_act(), nullptr);
+ btnNext->user_data = this;
+ lv_obj_set_event_cb(btnNext, event_handler);
+ lv_obj_set_size(btnNext, LV_HOR_RES / 3, 80);
+ lv_obj_align(btnNext, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
+ label = lv_label_create(btnNext, nullptr);
+ lv_label_set_text(label, ">>");
+
+ btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
+ btnPlayPause->user_data = this;
+ lv_obj_set_event_cb(btnPlayPause, event_handler);
+ lv_obj_set_size(btnPlayPause, LV_HOR_RES / 3, 80);
+ lv_obj_align(btnPlayPause, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ txtPlayPause = lv_label_create(btnPlayPause, nullptr);
+ lv_label_set_text(txtPlayPause, ">");
+
+ txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
+ lv_obj_align(txtTrackDuration, nullptr, LV_ALIGN_IN_TOP_LEFT, 12, 20);
+ lv_label_set_text(txtTrackDuration, "--:--/--:--");
+ lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_LEFT_MID);
+ lv_obj_set_width(txtTrackDuration, LV_HOR_RES);
+
+ constexpr uint8_t FONT_HEIGHT = 12;
+ constexpr uint8_t LINE_PAD = 15;
+ constexpr int8_t MIDDLE_OFFSET = -25;
+ txtArtist = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_long_mode(txtArtist, LV_LABEL_LONG_SROLL);
+ lv_obj_align(txtArtist, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT);
+ lv_label_set_text(txtArtist, "Artist Name");
+ lv_label_set_align(txtArtist, LV_ALIGN_IN_LEFT_MID);
+ lv_obj_set_width(txtArtist, LV_HOR_RES);
+
+ txtTrack = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SROLL);
+ lv_obj_align(txtTrack, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 2 * FONT_HEIGHT + LINE_PAD);
+ lv_label_set_text(txtTrack, "This is a very long getTrack name");
+ lv_label_set_align(txtTrack, LV_ALIGN_IN_LEFT_MID);
+ lv_obj_set_width(txtTrack, LV_HOR_RES);
+
+ /** Init animation */
+ imgDisc = lv_img_create(lv_scr_act(), nullptr);
+ lv_img_set_src_arr(imgDisc, &disc);
+ lv_obj_align(imgDisc, nullptr, LV_ALIGN_IN_TOP_RIGHT, -15, 15);
+
+ imgDiscAnim = lv_img_create(lv_scr_act(), nullptr);
+ lv_img_set_src_arr(imgDiscAnim, &disc_f_1);
+ lv_obj_align(imgDiscAnim, nullptr, LV_ALIGN_IN_TOP_RIGHT, -15 - 32, 15);
+
+ frameB = false;
+
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
+}
+
+Music::~Music() {
+ lv_obj_clean(lv_scr_act());
+}
+
+bool Music::OnButtonPushed() {
+ running = false;
+ return true;
+}
+
+bool Music::Refresh() {
+ if (artist != musicService.getArtist()) {
+ artist = musicService.getArtist();
+ currentLength = 0;
+ lv_label_set_text(txtArtist, artist.data());
+ }
+
+ if (track != musicService.getTrack()) {
+ track = musicService.getTrack();
+ currentLength = 0;
+ lv_label_set_text(txtTrack, track.data());
+ }
+
+ if (album != musicService.getAlbum()) {
+ album = musicService.getAlbum();
+ currentLength = 0;
+ }
+
+ if (playing != musicService.isPlaying()) {
+ playing = musicService.isPlaying();
+ }
+
+ // Because we increment this ourselves,
+ // we can't compare with the old data directly
+ // have to update it when there's actually new data
+ // just to avoid unnecessary draws that make UI choppy
+ if (lastLength != musicService.getProgress()) {
+ currentLength = musicService.getProgress();
+ lastLength = currentLength;
+ UpdateLength();
+ }
+
+ if (totalLength != musicService.getTrackLength()) {
+ totalLength = musicService.getTrackLength();
+ UpdateLength();
+ }
+
+ if (playing == Pinetime::Controllers::MusicService::MusicStatus::Playing) {
+ lv_label_set_text(txtPlayPause, "||");
+ if (xTaskGetTickCount() - 1024 >= lastIncrement) {
+
+ if (frameB) {
+ lv_img_set_src(imgDiscAnim, &disc_f_1);
+ } else {
+ lv_img_set_src(imgDiscAnim, &disc_f_2);
+ }
+ frameB = !frameB;
+
+ if (currentLength < totalLength) {
+ currentLength += static_cast<int>((static_cast<float>(xTaskGetTickCount() - lastIncrement) / 1024.0f) *
+ musicService.getPlaybackSpeed());
+ } else {
+ // Let's assume the getTrack finished, paused when the timer ends
+ // and there's no new getTrack being sent to us
+ // TODO: ideally this would be configurable
+ playing = false;
+ }
+ lastIncrement = xTaskGetTickCount();
+
+ UpdateLength();
+ }
+ } else {
+ lv_label_set_text(txtPlayPause, ">");
+ }
+
+ return running;
+}
+
+void Music::UpdateLength() {
+ if (totalLength > (99 * 60 * 60)) {
+ lv_label_set_text(txtTrackDuration, "Inf/Inf");
+ } else if (totalLength > (99 * 60)) {
+ char timer[12];
+ sprintf(timer, "%02d:%02d/%02d:%02d",
+ (currentLength / (60 * 60)) % 100,
+ ((currentLength % (60 * 60)) / 60) % 100,
+ (totalLength / (60 * 60)) % 100,
+ ((totalLength % (60 * 60)) / 60) % 100
+ );
+ lv_label_set_text(txtTrackDuration, timer);
+ } else {
+ char timer[12];
+ sprintf(timer, "%02d:%02d/%02d:%02d",
+ (currentLength / 60) % 100,
+ (currentLength % 60) % 100,
+ (totalLength / 60) % 100,
+ (totalLength % 60) % 100
+ );
+ lv_label_set_text(txtTrackDuration, timer);
+ }
+}
+
+void Music::OnObjectEvent(lv_obj_t *obj, lv_event_t event) {
+ if (event == LV_EVENT_CLICKED) {
+ if (obj == btnVolDown) {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLDOWN);
+ } else if (obj == btnVolUp) {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLUP);
+ } else if (obj == btnPrev) {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_PREV);
+ } else if (obj == btnPlayPause) {
+ if (playing == Pinetime::Controllers::MusicService::MusicStatus::Playing) {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_PAUSE);
+
+ // Let's assume it stops playing instantly
+ playing = Controllers::MusicService::NotPlaying;
+ } else {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_PLAY);
+
+ // Let's assume it starts playing instantly
+ // TODO: In the future should check for BT connection for better UX
+ playing = Controllers::MusicService::Playing;
+ }
+ } else if (obj == btnNext) {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
+ }
+ }
+}
+
+
+bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+ switch (event) {
+ case TouchEvents::SwipeUp: {
+ displayVolumeButtons = true;
+ lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
+ lv_obj_set_hidden(btnVolUp, !displayVolumeButtons);
+
+ lv_obj_set_hidden(btnNext, displayVolumeButtons);
+ lv_obj_set_hidden(btnPrev, displayVolumeButtons);
+ return true;
+ }
+ case TouchEvents::SwipeDown: {
+ displayVolumeButtons = false;
+ lv_obj_set_hidden(btnNext, displayVolumeButtons);
+ lv_obj_set_hidden(btnPrev, displayVolumeButtons);
+
+ lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
+ lv_obj_set_hidden(btnVolUp, !displayVolumeButtons);
+ return true;
+ }
+ case TouchEvents::SwipeLeft: {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
+ return true;
+ }
+ case TouchEvents::SwipeRight: {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_PREV);
+ return true;
+ }
+ default: {
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h
new file mode 100644
index 0000000..81ba793
--- /dev/null
+++ b/src/displayapp/screens/Music.h
@@ -0,0 +1,96 @@
+/* Copyright (C) 2020 JF, Adam Pigg, Avamander
+
+ This file is part of InfiniTime.
+
+ InfiniTime is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ InfiniTime is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#pragma once
+
+#include <cstdint>
+#include <chrono>
+#include <string>
+
+#include "components/gfx/Gfx.h"
+#include "components/battery/BatteryController.h"
+#include "components/ble/BleController.h"
+#include "components/ble/MusicService.h"
+#include "Screen.h"
+#include <bits/unique_ptr.h>
+#include <libs/lvgl/src/lv_core/lv_style.h>
+#include <libs/lvgl/src/lv_core/lv_obj.h>
+#include "../../Version.h"
+#include "displayapp/icons/music/disc.cpp"
+#include "displayapp/icons/music/disc_f_1.cpp"
+#include "displayapp/icons/music/disc_f_2.cpp"
+
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
+ class Music : public Screen {
+ public:
+ Music(DisplayApp *app, Pinetime::Controllers::MusicService &music);
+
+ ~Music() override;
+
+ bool Refresh() override;
+
+ bool OnButtonPushed() override;
+
+ void OnObjectEvent(lv_obj_t *obj, lv_event_t event);
+
+ private:
+ bool OnTouchEvent(TouchEvents event);
+
+ void UpdateLength();
+
+ lv_obj_t *btnPrev;
+ lv_obj_t *btnPlayPause;
+ lv_obj_t *btnNext;
+ lv_obj_t *btnVolDown;
+ lv_obj_t *btnVolUp;
+ lv_obj_t *txtArtist;
+ lv_obj_t *txtTrack;
+ lv_obj_t *txtPlayPause;
+
+ lv_obj_t *imgDisc;
+ lv_obj_t *imgDiscAnim;
+ lv_obj_t *txtTrackDuration;
+
+ /** For the spinning disc animation */
+ bool frameB;
+
+ bool displayVolumeButtons = false;
+ Pinetime::Controllers::MusicService &musicService;
+
+ std::string artist;
+ std::string album;
+ std::string track;
+
+ /** Total length in seconds */
+ int totalLength;
+ /** Current length in seconds */
+ int currentLength;
+ /** Last length */
+ int lastLength;
+ /** Last time an animation update or timer was incremented */
+ TickType_t lastIncrement;
+
+ bool playing;
+
+ /** Watchapp */
+ bool running = true;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/NotificationIcon.cpp b/src/displayapp/screens/NotificationIcon.cpp
new file mode 100644
index 0000000..64898c2
--- /dev/null
+++ b/src/displayapp/screens/NotificationIcon.cpp
@@ -0,0 +1,8 @@
+#include "NotificationIcon.h"
+#include "Symbols.h"
+using namespace Pinetime::Applications::Screens;
+
+const char* NotificationIcon::GetIcon(bool newNotificationAvailable) {
+ if(newNotificationAvailable) return Symbols::info;
+ else return "";
+} \ No newline at end of file
diff --git a/src/displayapp/screens/NotificationIcon.h b/src/displayapp/screens/NotificationIcon.h
new file mode 100644
index 0000000..dc34c3f
--- /dev/null
+++ b/src/displayapp/screens/NotificationIcon.h
@@ -0,0 +1,12 @@
+#pragma once
+
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
+ class NotificationIcon {
+ public:
+ static const char* GetIcon(bool newNotificationAvailable);
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
new file mode 100644
index 0000000..85848b2
--- /dev/null
+++ b/src/displayapp/screens/Notifications.cpp
@@ -0,0 +1,174 @@
+#include <libs/lvgl/lvgl.h>
+#include <displayapp/DisplayApp.h>
+#include <functional>
+#include "Notifications.h"
+
+using namespace Pinetime::Applications::Screens;
+
+Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::NotificationManager &notificationManager, Modes mode) :
+ Screen(app), notificationManager{notificationManager}, mode{mode} {
+ notificationManager.ClearNewNotificationFlag();
+ auto notification = notificationManager.GetLastNotification();
+ if(notification.valid) {
+ currentId = notification.id;
+ currentItem.reset(new NotificationItem("\nNotification", notification.message.data(), notification.index, notificationManager.NbNotifications(), mode));
+ validDisplay = true;
+ } else {
+ currentItem.reset(new NotificationItem("\nNotification", "No notification to display", 0, notificationManager.NbNotifications(), Modes::Preview));
+ }
+
+ if(mode == Modes::Preview) {
+ static lv_style_t style_line;
+ lv_style_copy(&style_line, &lv_style_plain);
+ style_line.line.color = LV_COLOR_WHITE;
+ style_line.line.width = 3;
+ style_line.line.rounded = 0;
+
+
+ timeoutLine = lv_line_create(lv_scr_act(), nullptr);
+ lv_line_set_style(timeoutLine, LV_LINE_STYLE_MAIN, &style_line);
+ lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+ timeoutTickCountStart = xTaskGetTickCount();
+ timeoutTickCountEnd = timeoutTickCountStart + (5*1024);
+ }
+}
+
+Notifications::~Notifications() {
+ lv_obj_clean(lv_scr_act());
+}
+
+bool Notifications::Refresh() {
+ if (mode == Modes::Preview) {
+ auto tick = xTaskGetTickCount();
+ int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
+ if (pos < 0)
+ running = false;
+
+ timeoutLinePoints[1].x = pos;
+ lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+
+ if (!running) {
+ // Start clock app when exiting this one
+ app->StartApp(Apps::Clock);
+ }
+ }
+
+ return running;
+}
+
+bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+ switch (event) {
+ case Pinetime::Applications::TouchEvents::SwipeUp: {
+ Controllers::NotificationManager::Notification previousNotification;
+ if(validDisplay)
+ previousNotification = notificationManager.GetPrevious(currentId);
+ else
+ previousNotification = notificationManager.GetLastNotification();
+
+ if (!previousNotification.valid) return true;
+
+ validDisplay = true;
+ currentId = previousNotification.id;
+ currentItem.reset(nullptr);
+ app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
+ currentItem.reset(new NotificationItem("\nNotification", previousNotification.message.data(), previousNotification.index, notificationManager.NbNotifications(), mode));
+ }
+ return true;
+ case Pinetime::Applications::TouchEvents::SwipeDown: {
+ Controllers::NotificationManager::Notification nextNotification;
+ if(validDisplay)
+ nextNotification = notificationManager.GetNext(currentId);
+ else
+ nextNotification = notificationManager.GetLastNotification();
+
+ if (!nextNotification.valid) return true;
+
+ validDisplay = true;
+ currentId = nextNotification.id;
+ currentItem.reset(nullptr);
+ app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
+ currentItem.reset(new NotificationItem("\nNotification", nextNotification.message.data(), nextNotification.index, notificationManager.NbNotifications(), mode));
+ }
+ return true;
+ default:
+ return false;
+ }
+}
+
+
+bool Notifications::OnButtonPushed() {
+ running = false;
+ return true;
+}
+
+
+Notifications::NotificationItem::NotificationItem(const char *title, const char *msg, uint8_t notifNr, uint8_t notifNb, Modes mode)
+ : notifNr{notifNr}, notifNb{notifNb}, mode{mode} {
+ container1 = lv_cont_create(lv_scr_act(), nullptr);
+ static lv_style_t contStyle;
+ lv_style_copy(&contStyle, lv_cont_get_style(container1, LV_CONT_STYLE_MAIN));
+ contStyle.body.padding.inner = 20;
+ lv_cont_set_style(container1, LV_CONT_STYLE_MAIN, &contStyle);
+ lv_obj_set_width(container1, LV_HOR_RES);
+ lv_obj_set_height(container1, LV_VER_RES);
+ lv_obj_set_pos(container1, 0, 0);
+ lv_cont_set_layout(container1, LV_LAYOUT_OFF);
+ lv_cont_set_fit2(container1, LV_FIT_FLOOD, LV_FIT_FLOOD);
+
+ t1 = lv_label_create(container1, nullptr);
+ static lv_style_t titleStyle;
+ static lv_style_t textStyle;
+ static lv_style_t bottomStyle;
+ lv_style_copy(&titleStyle, lv_label_get_style(t1, LV_LABEL_STYLE_MAIN));
+ lv_style_copy(&textStyle, lv_label_get_style(t1, LV_LABEL_STYLE_MAIN));
+ lv_style_copy(&bottomStyle, lv_label_get_style(t1, LV_LABEL_STYLE_MAIN));
+ titleStyle.body.padding.inner = 5;
+ titleStyle.body.grad_color = LV_COLOR_GRAY;
+ titleStyle.body.main_color = LV_COLOR_GRAY;
+ titleStyle.body.radius = 20;
+ textStyle.body.border.part = LV_BORDER_NONE;
+ textStyle.body.padding.inner = 5;
+
+ bottomStyle.body.main_color = LV_COLOR_GREEN;
+ bottomStyle.body.grad_color = LV_COLOR_GREEN;
+ bottomStyle.body.border.part = LV_BORDER_TOP;
+ bottomStyle.body.border.color = LV_COLOR_RED;
+
+ lv_label_set_style(t1, LV_LABEL_STYLE_MAIN, &titleStyle);
+ lv_label_set_long_mode(t1, LV_LABEL_LONG_BREAK);
+ lv_label_set_body_draw(t1, true);
+ lv_obj_set_width(t1, LV_HOR_RES - (titleStyle.body.padding.left + titleStyle.body.padding.right));
+ lv_label_set_text(t1, title);
+ static constexpr int16_t offscreenOffset = -20 ;
+ lv_obj_set_pos(t1, titleStyle.body.padding.left, offscreenOffset);
+
+ auto titleHeight = lv_obj_get_height(t1);
+
+ l1 = lv_label_create(container1, nullptr);
+ lv_label_set_style(l1, LV_LABEL_STYLE_MAIN, &textStyle);
+ lv_obj_set_pos(l1, textStyle.body.padding.left,
+ titleHeight + offscreenOffset + textStyle.body.padding.bottom +
+ textStyle.body.padding.top);
+
+ lv_label_set_long_mode(l1, LV_LABEL_LONG_BREAK);
+ lv_label_set_body_draw(l1, true);
+ lv_obj_set_width(l1, LV_HOR_RES - (textStyle.body.padding.left + textStyle.body.padding.right));
+ lv_label_set_text(l1, msg);
+
+ if(mode == Modes::Normal) {
+ if(notifNr < notifNb) {
+ bottomPlaceholder = lv_label_create(container1, nullptr);
+ lv_label_set_style(bottomPlaceholder, LV_LABEL_STYLE_MAIN, &titleStyle);
+ lv_label_set_long_mode(bottomPlaceholder, LV_LABEL_LONG_BREAK);
+ lv_label_set_body_draw(bottomPlaceholder, true);
+ lv_obj_set_width(bottomPlaceholder, LV_HOR_RES - (titleStyle.body.padding.left + titleStyle.body.padding.right));
+ lv_label_set_text(bottomPlaceholder, " ");
+ lv_obj_set_pos(bottomPlaceholder, titleStyle.body.padding.left, LV_VER_RES - 5);
+ }
+ }
+}
+
+
+Notifications::NotificationItem::~NotificationItem() {
+ lv_obj_clean(lv_scr_act());
+}
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
new file mode 100644
index 0000000..fb4e1ef
--- /dev/null
+++ b/src/displayapp/screens/Notifications.h
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <functional>
+#include <vector>
+
+#include "Screen.h"
+#include "ScreenList.h"
+
+
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
+ class Notifications : public Screen {
+ public:
+ enum class Modes {Normal, Preview};
+ explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Modes mode);
+ ~Notifications() override;
+
+ bool Refresh() override;
+ bool OnButtonPushed() override;
+ bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
+
+ private:
+ bool running = true;
+
+ class NotificationItem {
+ public:
+ NotificationItem(const char* title, const char* msg, uint8_t notifNr, uint8_t notifNb, Modes mode);
+ ~NotificationItem();
+ bool Refresh() {return false;}
+
+ private:
+ uint8_t notifNr = 0;
+ uint8_t notifNb = 0;
+ char pageText[4];
+
+ lv_obj_t* container1;
+ lv_obj_t* t1;
+ lv_obj_t* l1;
+ lv_obj_t* bottomPlaceholder;
+ Modes mode;
+ };
+
+ struct NotificationData {
+ const char* title;
+ const char* text;
+ };
+ Pinetime::Controllers::NotificationManager& notificationManager;
+ Modes mode = Modes::Normal;
+ std::unique_ptr<NotificationItem> currentItem;
+ Controllers::NotificationManager::Notification::Id currentId;
+ bool validDisplay = false;
+
+ lv_point_t timeoutLinePoints[2] { {0, 237}, {239, 237} };
+ lv_obj_t* timeoutLine;
+ uint32_t timeoutTickCountStart;
+ uint32_t timeoutTickCountEnd;
+ };
+ }
+ }
+}
diff --git a/src/DisplayApp/Screens/Screen.cpp b/src/displayapp/screens/Screen.cpp
index 1467df3..1467df3 100644
--- a/src/DisplayApp/Screens/Screen.cpp
+++ b/src/displayapp/screens/Screen.cpp
diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h
new file mode 100644
index 0000000..6b1d0ee
--- /dev/null
+++ b/src/displayapp/screens/Screen.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <cstdint>
+#include "../TouchEvents.h"
+
+namespace Pinetime {
+ namespace Applications {
+ class DisplayApp;
+ namespace Screens {
+ class Screen {
+ public:
+ explicit Screen(DisplayApp* app) : app{app} {}
+ virtual ~Screen() = default;
+
+ /**
+ * Most of the time, apps only react to events (touch events, for example).
+ * In this case you don't need to do anything in this method.
+ *
+ * For example, InfiniPaint does nothing in Refresh().
+ * But, if you want to update your display periodically, draw an animation...
+ * you cannot do it in a touch event handler because these handlers are not
+ * called if the user does not touch the screen.
+ *
+ * That's why Refresh() is there: update the display periodically.
+ *
+ * @return false if the app can be closed, true if it must continue to run
+ **/
+ virtual bool Refresh() = 0;
+
+ /** @return false if the button hasn't been handled by the app, true if it has been handled */
+ virtual bool OnButtonPushed() { return false; }
+
+ /** @return false if the event hasn't been handled by the app, true if it has been handled */
+ virtual bool OnTouchEvent(TouchEvents event) { return false; }
+ virtual bool OnTouchEvent(uint16_t x, uint16_t y) { return false; }
+
+ protected:
+ DisplayApp* app;
+ };
+ }
+ }
+}
diff --git a/src/DisplayApp/Screens/ScreenList.h b/src/displayapp/screens/ScreenList.h
index d873336..b198634 100644
--- a/src/DisplayApp/Screens/ScreenList.h
+++ b/src/displayapp/screens/ScreenList.h
@@ -1,8 +1,8 @@
#pragma once
#include <vector>
-#include <Components/Ble/NimbleController.h>
#include <functional>
+#include "components/ble/NimbleController.h"
#include "Screen.h"
#include "Label.h"
diff --git a/src/DisplayApp/Screens/Symbols.h b/src/displayapp/screens/Symbols.h
index aeea324..aeea324 100644
--- a/src/DisplayApp/Screens/Symbols.h
+++ b/src/displayapp/screens/Symbols.h
diff --git a/src/DisplayApp/Screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index fcafcf7..867fdae 100644
--- a/src/DisplayApp/Screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -1,5 +1,5 @@
#include <libs/lvgl/lvgl.h>
-#include <DisplayApp/DisplayApp.h>
+#include <displayapp/DisplayApp.h>
#include <functional>
#include "SystemInfo.h"
#include "../../Version.h"
@@ -105,12 +105,12 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
auto& bleAddr = bleController.Address();
- sprintf(t2, "BLE MAC: \n %2x:%2x:%2x:%2x:%2x:%2x",
+ sprintf(t2, "BLE MAC: \n %02x:%02x:%02x:%02x:%02x:%02x",
bleAddr[5], bleAddr[4], bleAddr[3], bleAddr[2], bleAddr[1], bleAddr[0]);
return std::unique_ptr<Screen>(new Screens::Label(app, t2));
}
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
- strncpy(t3, "Hello from\nthe developper!", 27);
+ strncpy(t3, "Hello from\nthe developer!", 27);
return std::unique_ptr<Screen>(new Screens::Label(app, t3));
}
diff --git a/src/DisplayApp/Screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h
index ac8abae..987a584 100644
--- a/src/DisplayApp/Screens/SystemInfo.h
+++ b/src/displayapp/screens/SystemInfo.h
@@ -1,13 +1,14 @@
#pragma once
+#include <functional>
#include <vector>
-#include <Components/Ble/NimbleController.h>
+
+#include "components/ble/NimbleController.h"
#include "Screen.h"
#include "Label.h"
#include "ScreenList.h"
#include "Gauge.h"
#include "Meter.h"
-#include <functional>
namespace Pinetime {
namespace Applications {
diff --git a/src/DisplayApp/Screens/Tab.cpp b/src/displayapp/screens/Tab.cpp
index adc3257..44b806c 100644
--- a/src/DisplayApp/Screens/Tab.cpp
+++ b/src/displayapp/screens/Tab.cpp
@@ -1,13 +1,13 @@
#include <cstdio>
#include <libs/date/includes/date/date.h>
-#include <Components/DateTime/DateTimeController.h>
+#include "components/datetime/DateTimeController.h"
#include <Version.h>
#include <libs/lvgl/src/lv_core/lv_obj.h>
#include <libs/lvgl/src/lv_font/lv_font.h>
#include <libs/lvgl/lvgl.h>
#include <libraries/log/nrf_log.h>
#include "Tab.h"
-#include <DisplayApp/DisplayApp.h>
+#include "displayapp/DisplayApp.h"
using namespace Pinetime::Applications::Screens;
diff --git a/src/DisplayApp/Screens/Tab.h b/src/displayapp/screens/Tab.h
index e16dbb9..e16dbb9 100644
--- a/src/DisplayApp/Screens/Tab.h
+++ b/src/displayapp/screens/Tab.h
diff --git a/src/DisplayApp/Screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index 1447d78..75fa6ef 100644
--- a/src/DisplayApp/Screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -1,8 +1,9 @@
#include <libs/lvgl/src/lv_core/lv_obj.h>
#include <libs/lvgl/src/lv_font/lv_font.h>
#include <libs/lvgl/lvgl.h>
+
#include "Tile.h"
-#include <DisplayApp/DisplayApp.h>
+#include "displayapp/DisplayApp.h"
#include "Symbols.h"
#include "../../Version.h"
@@ -29,7 +30,7 @@ Tile::Tile(DisplayApp* app, std::array<Applications, 6>& applications) : Screen(
}
modal.reset(new Modal(app));
- btnm1 = lv_btnm_create(lv_scr_act(), NULL);
+ btnm1 = lv_btnm_create(lv_scr_act(), nullptr);
lv_btnm_set_map(btnm1, btnm_map1);
lv_obj_set_size(btnm1, LV_HOR_RES, LV_VER_RES);
diff --git a/src/DisplayApp/Screens/Tile.h b/src/displayapp/screens/Tile.h
index 3136d89..cf5fcf1 100644
--- a/src/DisplayApp/Screens/Tile.h
+++ b/src/displayapp/screens/Tile.h
@@ -5,7 +5,7 @@
#include <bits/unique_ptr.h>
#include "Modal.h"
#include <lvgl/src/lv_core/lv_style.h>
-#include <DisplayApp/Apps.h>
+#include <displayapp/Apps.h>
namespace Pinetime {
namespace Applications {
diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp
index f681654..94db3b3 100644
--- a/src/drivers/Cst816s.cpp
+++ b/src/drivers/Cst816s.cpp
@@ -37,7 +37,9 @@ void Cst816S::Init() {
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
Cst816S::TouchInfos info;
- twiMaster.Read(twiAddress, 0, touchData, 63);
+ auto ret = twiMaster.Read(twiAddress, 0, touchData, 63);
+ if(ret != TwiMaster::ErrorCodes::NoError) return {};
+
auto nbTouchPoints = touchData[2] & 0x0f;
// uint8_t i = 0;
diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h
index b115a68..4569e82 100644
--- a/src/drivers/Cst816s.h
+++ b/src/drivers/Cst816s.h
@@ -18,13 +18,13 @@ namespace Pinetime {
LongPress = 0x0C
};
struct TouchInfos {
- uint16_t x;
- uint16_t y;
- uint8_t action;
- uint8_t finger;
- uint8_t pressure;
- uint8_t area;
- Gestures gesture;
+ uint16_t x = 0;
+ uint16_t y = 0;
+ uint8_t action = 0;
+ uint8_t finger = 0;
+ uint8_t pressure = 0;
+ uint8_t area = 0;
+ Gestures gesture = Gestures::None;
bool isTouch = false;
};
diff --git a/src/drivers/SpiNorFlash.cpp b/src/drivers/SpiNorFlash.cpp
index 351a9df..bd24834 100644
--- a/src/drivers/SpiNorFlash.cpp
+++ b/src/drivers/SpiNorFlash.cpp
@@ -12,7 +12,7 @@ SpiNorFlash::SpiNorFlash(Spi& spi) : spi{spi} {
void SpiNorFlash::Init() {
device_id = ReadIdentificaion();
- NRF_LOG_INFO("[SPI FLASH] Manufacturer : %d, Memory type : %d, memory density : %d", device_id.manufacturer, device_id.type, device_id.density);
+ NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d", device_id.manufacturer, device_id.type, device_id.density);
}
void SpiNorFlash::Uninit() {
@@ -22,7 +22,7 @@ void SpiNorFlash::Uninit() {
void SpiNorFlash::Sleep() {
auto cmd = static_cast<uint8_t>(Commands::DeepPowerDown);
spi.Write(&cmd, sizeof(uint8_t));
- NRF_LOG_INFO("[FLASH] Sleep")
+ NRF_LOG_INFO("[SpiNorFlash] Sleep")
}
void SpiNorFlash::Wakeup() {
@@ -38,7 +38,7 @@ void SpiNorFlash::Wakeup() {
else {
NRF_LOG_INFO("[SpiNorFlash] ID on Wakeup: %d", id);
}
- NRF_LOG_INFO("[FLASH] Wakeup")
+ NRF_LOG_INFO("[SpiNorFlash] Wakeup")
}
SpiNorFlash::Identification SpiNorFlash::ReadIdentificaion() {
diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp
index a9eb5d0..3ff8a95 100644
--- a/src/drivers/TwiMaster.cpp
+++ b/src/drivers/TwiMaster.cpp
@@ -60,24 +60,53 @@ void TwiMaster::Init() {
}
-void TwiMaster::Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t *data, size_t size) {
+TwiMaster::ErrorCodes TwiMaster::Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t *data, size_t size) {
xSemaphoreTake(mutex, portMAX_DELAY);
- Write(deviceAddress, &registerAddress, 1, false);
- Read(deviceAddress, data, size, true);
+ auto ret = ReadWithRetry(deviceAddress, registerAddress, data, size);
xSemaphoreGive(mutex);
+
+ return ret;
}
-void TwiMaster::Write(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t *data, size_t size) {
+TwiMaster::ErrorCodes TwiMaster::Write(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t *data, size_t size) {
ASSERT(size <= maxDataSize);
xSemaphoreTake(mutex, portMAX_DELAY);
+
+ auto ret = WriteWithRetry(deviceAddress, registerAddress, data, size);
+ xSemaphoreGive(mutex);
+ return ret;
+}
+
+/* Execute a read transaction (composed of a write and a read operation). If one of these opeartion fails,
+ * it's retried once. If it fails again, an error is returned */
+TwiMaster::ErrorCodes TwiMaster::ReadWithRetry(uint8_t deviceAddress, uint8_t registerAddress, uint8_t *data, size_t size) {
+ TwiMaster::ErrorCodes ret;
+ ret = Write(deviceAddress, &registerAddress, 1, false);
+ if(ret != ErrorCodes::NoError)
+ ret = Write(deviceAddress, &registerAddress, 1, false);
+
+ if(ret != ErrorCodes::NoError) return ret;
+
+ ret = Read(deviceAddress, data, size, true);
+ if(ret != ErrorCodes::NoError)
+ ret = Read(deviceAddress, data, size, true);
+
+ return ret;
+}
+
+/* Execute a write transaction. If it fails, it is retried once. If it fails again, an error is returned. */
+TwiMaster::ErrorCodes TwiMaster::WriteWithRetry(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t *data, size_t size) {
internalBuffer[0] = registerAddress;
std::memcpy(internalBuffer+1, data, size);
- Write(deviceAddress, internalBuffer, size+1, true);
- xSemaphoreGive(mutex);
+ auto ret = Write(deviceAddress, internalBuffer, size+1, true);
+ if(ret != ErrorCodes::NoError)
+ ret = Write(deviceAddress, internalBuffer, size+1, true);
+
+ return ret;
}
-void TwiMaster::Read(uint8_t deviceAddress, uint8_t *buffer, size_t size, bool stop) {
+TwiMaster::ErrorCodes TwiMaster::Read(uint8_t deviceAddress, uint8_t *buffer, size_t size, bool stop) {
twiBaseAddress->ADDRESS = deviceAddress;
twiBaseAddress->TASKS_RESUME = 0x1UL;
twiBaseAddress->RXD.PTR = (uint32_t)buffer;
@@ -88,7 +117,15 @@ void TwiMaster::Read(uint8_t deviceAddress, uint8_t *buffer, size_t size, bool s
while(!twiBaseAddress->EVENTS_RXSTARTED && !twiBaseAddress->EVENTS_ERROR);
twiBaseAddress->EVENTS_RXSTARTED = 0x0UL;
- while(!twiBaseAddress->EVENTS_LASTRX && !twiBaseAddress->EVENTS_ERROR);
+ txStartedCycleCount = DWT->CYCCNT;
+ uint32_t currentCycleCount;
+ while(!twiBaseAddress->EVENTS_LASTRX && !twiBaseAddress->EVENTS_ERROR) {
+ currentCycleCount = DWT->CYCCNT;
+ if ((currentCycleCount-txStartedCycleCount) > HwFreezedDelay) {
+ FixHwFreezed();
+ return ErrorCodes::TransactionFailed;
+ }
+ }
twiBaseAddress->EVENTS_LASTRX = 0x0UL;
if (stop || twiBaseAddress->EVENTS_ERROR) {
@@ -105,9 +142,10 @@ void TwiMaster::Read(uint8_t deviceAddress, uint8_t *buffer, size_t size, bool s
if (twiBaseAddress->EVENTS_ERROR) {
twiBaseAddress->EVENTS_ERROR = 0x0UL;
}
+ return ErrorCodes::NoError;
}
-void TwiMaster::Write(uint8_t deviceAddress, const uint8_t *data, size_t size, bool stop) {
+TwiMaster::ErrorCodes TwiMaster::Write(uint8_t deviceAddress, const uint8_t *data, size_t size, bool stop) {
twiBaseAddress->ADDRESS = deviceAddress;
twiBaseAddress->TASKS_RESUME = 0x1UL;
twiBaseAddress->TXD.PTR = (uint32_t)data;
@@ -118,7 +156,15 @@ void TwiMaster::Write(uint8_t deviceAddress, const uint8_t *data, size_t size, b
while(!twiBaseAddress->EVENTS_TXSTARTED && !twiBaseAddress->EVENTS_ERROR);
twiBaseAddress->EVENTS_TXSTARTED = 0x0UL;
- while(!twiBaseAddress->EVENTS_LASTTX && !twiBaseAddress->EVENTS_ERROR);
+ txStartedCycleCount = DWT->CYCCNT;
+ uint32_t currentCycleCount;
+ while(!twiBaseAddress->EVENTS_LASTTX && !twiBaseAddress->EVENTS_ERROR) {
+ currentCycleCount = DWT->CYCCNT;
+ if ((currentCycleCount-txStartedCycleCount) > HwFreezedDelay) {
+ FixHwFreezed();
+ return ErrorCodes::TransactionFailed;
+ }
+ }
twiBaseAddress->EVENTS_LASTTX = 0x0UL;
if (stop || twiBaseAddress->EVENTS_ERROR) {
@@ -137,6 +183,8 @@ void TwiMaster::Write(uint8_t deviceAddress, const uint8_t *data, size_t size, b
uint32_t error = twiBaseAddress->ERRORSRC;
twiBaseAddress->ERRORSRC = error;
}
+
+ return ErrorCodes::NoError;
}
void TwiMaster::Sleep() {
@@ -152,3 +200,30 @@ void TwiMaster::Wakeup() {
Init();
NRF_LOG_INFO("[TWIMASTER] Wakeup");
}
+
+/* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX.
+ * This method disable and re-enable the peripheral so that it works again.
+ * This is just a workaround, and it would be better if we could find a way to prevent
+ * this issue from happening.
+ * */
+void TwiMaster::FixHwFreezed() {
+ NRF_LOG_INFO("I2C device frozen, reinitializing it!");
+ // Disable I²C
+ uint32_t twi_state = NRF_TWI1->ENABLE;
+ twiBaseAddress->ENABLE = TWIM_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos;
+
+ NRF_GPIO->PIN_CNF[params.pinScl] = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
+ | ((uint32_t)GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+ | ((uint32_t)GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos)
+ | ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+ | ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
+
+ NRF_GPIO->PIN_CNF[params.pinSda] = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
+ | ((uint32_t)GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+ | ((uint32_t)GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos)
+ | ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+ | ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
+
+ // Re-enable I²C
+ twiBaseAddress->ENABLE = twi_state;
+}
diff --git a/src/drivers/TwiMaster.h b/src/drivers/TwiMaster.h
index 9b6b507..52e3909 100644
--- a/src/drivers/TwiMaster.h
+++ b/src/drivers/TwiMaster.h
@@ -10,6 +10,7 @@ namespace Pinetime {
public:
enum class Modules { TWIM1 };
enum class Frequencies {Khz100, Khz250, Khz400};
+ enum class ErrorCodes {NoError, TransactionFailed};
struct Parameters {
uint32_t frequency;
uint8_t pinSda;
@@ -19,15 +20,19 @@ namespace Pinetime {
TwiMaster(const Modules module, const Parameters& params);
void Init();
- void Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, size_t size);
- void Write(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t* data, size_t size);
+ ErrorCodes Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, size_t size);
+ ErrorCodes Write(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t* data, size_t size);
void Sleep();
void Wakeup();
private:
- void Read(uint8_t deviceAddress, uint8_t* buffer, size_t size, bool stop);
- void Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop);
+ ErrorCodes ReadWithRetry(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, size_t size);
+ ErrorCodes WriteWithRetry(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t* data, size_t size);
+
+ ErrorCodes Read(uint8_t deviceAddress, uint8_t* buffer, size_t size, bool stop);
+ ErrorCodes Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop);
+ void FixHwFreezed();
NRF_TWIM_Type* twiBaseAddress;
SemaphoreHandle_t mutex;
const Modules module;
@@ -35,7 +40,8 @@ namespace Pinetime {
static constexpr uint8_t maxDataSize{8};
static constexpr uint8_t registerSize{1};
uint8_t internalBuffer[maxDataSize + registerSize];
-
+ uint32_t txStartedCycleCount = 0;
+ static constexpr uint32_t HwFreezedDelay{161000};
};
}
} \ No newline at end of file
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 9373a9b..288b5e9 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -11,15 +11,15 @@
#include <libraries/gpiote/app_gpiote.h>
#include <hal/nrf_wdt.h>
#include <cstring>
-#include <Components/Gfx/Gfx.h>
+#include <components/gfx/Gfx.h>
#include <drivers/St7789.h>
-#include <Components/Brightness/BrightnessController.h>
+#include <components/brightness/BrightnessController.h>
#if NRF_LOG_ENABLED
-#include "Logging/NrfLogger.h"
+#include "logging/NrfLogger.h"
Pinetime::Logging::NrfLogger logger;
#else
-#include "Logging/DummyLogger.h"
+#include "logging/DummyLogger.h"
Pinetime::Logging::DummyLogger logger;
#endif
diff --git a/src/libs/lvgl/src/lv_core/lv_obj.c b/src/libs/lvgl/src/lv_core/lv_obj.c
index 510a870..511e72d 100644
--- a/src/libs/lvgl/src/lv_core/lv_obj.c
+++ b/src/libs/lvgl/src/lv_core/lv_obj.c
@@ -163,7 +163,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
LV_ASSERT_MEM(new_obj);
if(new_obj == NULL) return NULL;
- new_obj->par = NULL; /*Screens has no a parent*/
+ new_obj->par = NULL; /*screens has no a parent*/
lv_ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
/*Set the callbacks*/
diff --git a/src/Logging/DummyLogger.h b/src/logging/DummyLogger.h
index 0aa7288..0aa7288 100644
--- a/src/Logging/DummyLogger.h
+++ b/src/logging/DummyLogger.h
diff --git a/src/Logging/Logger.h b/src/logging/Logger.h
index 95d21dc..95d21dc 100644
--- a/src/Logging/Logger.h
+++ b/src/logging/Logger.h
diff --git a/src/Logging/NrfLogger.cpp b/src/logging/NrfLogger.cpp
index 7ccacc8..0d95c06 100644
--- a/src/Logging/NrfLogger.cpp
+++ b/src/logging/NrfLogger.cpp
@@ -19,10 +19,15 @@ void NrfLogger::Init() {
void NrfLogger::Process(void*) {
NRF_LOG_INFO("Logger task started!");
+ // Suppress endless loop diagnostic
+ #pragma clang diagnostic push
+ #pragma ide diagnostic ignored "EndlessLoop"
while (1) {
NRF_LOG_FLUSH();
vTaskDelay(100); // Not good for power consumption, it will wake up every 100ms...
}
+ // Clear diagnostic suppression
+ #pragma clang diagnostic pop
}
void NrfLogger::Resume() {
diff --git a/src/Logging/NrfLogger.h b/src/logging/NrfLogger.h
index cb7089f..cb7089f 100644
--- a/src/Logging/NrfLogger.h
+++ b/src/logging/NrfLogger.h
diff --git a/src/main.cpp b/src/main.cpp
index fe41358..45aac6d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,38 +1,38 @@
#include <FreeRTOS.h>
#include <task.h>
+#include <timers.h>
#include <legacy/nrf_drv_clock.h>
+#include <hal/nrf_rtc.h>
+#include <hal/nrf_wdt.h>
+#include <os/os_cputime.h>
#include <libraries/timer/app_timer.h>
#include <libraries/gpiote/app_gpiote.h>
-#include <DisplayApp/DisplayApp.h>
+#include "displayapp/DisplayApp.h"
#include <softdevice/common/nrf_sdh.h>
-#include <hal/nrf_rtc.h>
-#include <timers.h>
-#include <Components/DateTime/DateTimeController.h>
-#include "Components/Battery/BatteryController.h"
-#include "Components/Ble/BleController.h"
+#include "components/datetime/DateTimeController.h"
+#include "components/battery/BatteryController.h"
+#include "components/ble/BleController.h"
+#include "components/ble/NotificationManager.h"
#include <drivers/St7789.h>
#include <drivers/SpiMaster.h>
#include <drivers/Spi.h>
-#include <DisplayApp/LittleVgl.h>
-#include <SystemTask/SystemTask.h>
-#include <Components/Ble/NotificationManager.h>
+#include "displayapp/LittleVgl.h"
+#include <systemtask/SystemTask.h>
#include <nimble/nimble_port_freertos.h>
#include <nimble/npl_freertos.h>
#include <nimble/nimble_port.h>
#include <host/ble_hs.h>
#include <controller/ble_ll.h>
-#include <os/os_cputime.h>
#include <transport/ram/ble_hci_ram.h>
-#include <hal/nrf_wdt.h>
#include <host/util/util.h>
#include <services/gap/ble_svc_gap.h>
#if NRF_LOG_ENABLED
-#include "Logging/NrfLogger.h"
+#include "logging/NrfLogger.h"
Pinetime::Logging::NrfLogger logger;
#else
-#include "Logging/DummyLogger.h"
+#include "logging/DummyLogger.h"
Pinetime::Logging::DummyLogger logger;
#endif
diff --git a/src/SystemTask/SystemMonitor.h b/src/systemtask/SystemMonitor.h
index ec1fd81..029a136 100644
--- a/src/SystemTask/SystemMonitor.h
+++ b/src/systemtask/SystemMonitor.h
@@ -27,7 +27,7 @@ namespace Pinetime {
void Process() const {
if(xTaskGetTickCount() - lastTick > 10000) {
NRF_LOG_INFO("---------------------------------------\nFree heap : %d", xPortGetFreeHeapSize());
- auto nb = uxTaskGetSystemState(tasksStatus, 10, NULL);
+ auto nb = uxTaskGetSystemState(tasksStatus, 10, nullptr);
for (uint32_t i = 0; i < nb; i++) {
NRF_LOG_INFO("Task [%s] - %d", tasksStatus[i].pcTaskName, tasksStatus[i].usStackHighWaterMark);
if (tasksStatus[i].usStackHighWaterMark < 20)
diff --git a/src/SystemTask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index a4e6356..dac4ce2 100644
--- a/src/SystemTask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -1,9 +1,9 @@
#include <libraries/log/nrf_log.h>
#include <libraries/gpiote/app_gpiote.h>
#include <drivers/Cst816s.h>
-#include <DisplayApp/LittleVgl.h>
+#include "displayapp/LittleVgl.h"
#include <hal/nrf_rtc.h>
-#include <Components/Ble/NotificationManager.h>
+#include "components/ble/NotificationManager.h"
#include <host/ble_gatt.h>
#include <host/ble_hs_adv.h>
#include "SystemTask.h"
@@ -11,8 +11,9 @@
#include <host/ble_gap.h>
#include <host/util/util.h>
#include <drivers/InternalFlash.h>
-#include "../main.h"
-#include "Components/Ble/NimbleController.h"
+#include "main.h"
+#include "components/ble/NimbleController.h"
+#include "../BootloaderVersion.h"
using namespace Pinetime::System;
@@ -35,8 +36,8 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd,
twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController},
bleController{bleController}, dateTimeController{dateTimeController},
watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager},
- nimbleController(*this, bleController,dateTimeController, notificationManager, spiNorFlash) {
- systemTaksMsgQueue = xQueueCreate(10, 1);
+ nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash) {
+ systemTasksMsgQueue = xQueueCreate(10, 1);
}
void SystemTask::Start() {
@@ -46,7 +47,7 @@ void SystemTask::Start() {
void SystemTask::Process(void *instance) {
auto *app = static_cast<SystemTask *>(instance);
- NRF_LOG_INFO("SystemTask task started!");
+ NRF_LOG_INFO("systemtask task started!");
app->Work();
}
@@ -100,9 +101,12 @@ void SystemTask::Work() {
idleTimer = xTimerCreate ("idleTimer", idleTime, pdFALSE, this, IdleTimerCallback);
xTimerStart(idleTimer, 0);
+ // Suppress endless loop diagnostic
+ #pragma clang diagnostic push
+ #pragma ide diagnostic ignored "EndlessLoop"
while(true) {
uint8_t msg;
- if (xQueueReceive(systemTaksMsgQueue, &msg, isSleeping?2500 : 1000)) {
+ if (xQueueReceive(systemTasksMsgQueue, &msg, isSleeping ? 2500 : 1000)) {
Messages message = static_cast<Messages >(msg);
switch(message) {
case Messages::GoToRunning:
@@ -123,7 +127,7 @@ void SystemTask::Work() {
break;
case Messages::GoToSleep:
isGoingToSleep = true;
- NRF_LOG_INFO("[SystemTask] Going to sleep");
+ NRF_LOG_INFO("[systemtask] Going to sleep");
xTimerStop(idleTimer, 0);
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::GoToSleep);
break;
@@ -158,7 +162,11 @@ void SystemTask::Work() {
ReloadIdleTimer();
break;
case Messages::OnDisplayTaskSleeping:
- spiNorFlash.Sleep();
+ if(BootloaderVersion::IsValid()) {
+ // First versions of the bootloader do not expose their version and cannot initialize the SPI NOR FLASH
+ // if it's in sleep mode. Avoid bricked device by disabling sleep mode on these versions.
+ spiNorFlash.Sleep();
+ }
lcd.Sleep();
touchPanel.Sleep();
@@ -191,18 +199,20 @@ void SystemTask::Work() {
if(!nrf_gpio_pin_read(pinButton))
watchdog.Kick();
}
+ // Clear diagnostic suppression
+ #pragma clang diagnostic pop
}
void SystemTask::OnButtonPushed() {
if(isGoingToSleep) return;
if(!isSleeping) {
- NRF_LOG_INFO("[SystemTask] Button pushed");
+ NRF_LOG_INFO("[systemtask] Button pushed");
PushMessage(Messages::OnButtonEvent);
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::ButtonPushed);
}
else {
if(!isWakingUp) {
- NRF_LOG_INFO("[SystemTask] Button pushed, waking up");
+ NRF_LOG_INFO("[systemtask] Button pushed, waking up");
GoToRunning();
}
}
@@ -215,7 +225,7 @@ void SystemTask::GoToRunning() {
void SystemTask::OnTouchEvent() {
if(isGoingToSleep) return ;
- NRF_LOG_INFO("[SystemTask] Touch event");
+ NRF_LOG_INFO("[systemtask] Touch event");
if(!isSleeping) {
PushMessage(Messages::OnTouchEvent);
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::TouchEvent);
@@ -228,10 +238,10 @@ void SystemTask::PushMessage(SystemTask::Messages msg) {
}
BaseType_t xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
- xQueueSendFromISR(systemTaksMsgQueue, &msg, &xHigherPriorityTaskWoken);
+ xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken) {
/* Actual macro used here is port specific. */
- // TODO : should I do something here?
+ // TODO: should I do something here?
}
}
diff --git a/src/SystemTask/SystemTask.h b/src/systemtask/SystemTask.h
index 40277cf..6ef0cfb 100644
--- a/src/SystemTask/SystemTask.h
+++ b/src/systemtask/SystemTask.h
@@ -1,16 +1,17 @@
#pragma once
+#include <memory>
+
#include <FreeRTOS.h>
#include <task.h>
-#include <memory>
#include <drivers/SpiMaster.h>
#include <drivers/St7789.h>
-#include <Components/Battery/BatteryController.h>
-#include <DisplayApp/DisplayApp.h>
+#include "components/battery/BatteryController.h"
+#include "displayapp/DisplayApp.h"
#include <drivers/Watchdog.h>
#include <drivers/SpiNorFlash.h>
#include "SystemMonitor.h"
-#include "Components/Ble/NimbleController.h"
+#include "components/ble/NimbleController.h"
#include "timers.h"
namespace Pinetime {
@@ -53,7 +54,7 @@ namespace Pinetime {
std::unique_ptr<Pinetime::Applications::DisplayApp> displayApp;
Pinetime::Controllers::Ble& bleController;
Pinetime::Controllers::DateTime& dateTimeController;
- QueueHandle_t systemTaksMsgQueue;
+ QueueHandle_t systemTasksMsgQueue;
std::atomic<bool> isSleeping{false};
std::atomic<bool> isGoingToSleep{false};
std::atomic<bool> isWakingUp{false};