summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/alarm/AlarmController.cpp3
-rw-r--r--src/components/ble/AlertNotificationClient.cpp7
-rw-r--r--src/components/ble/BatteryInformationService.h1
-rw-r--r--src/components/ble/CurrentTimeClient.cpp19
-rw-r--r--src/components/ble/CurrentTimeService.cpp19
-rw-r--r--src/components/ble/HeartRateService.cpp7
-rw-r--r--src/components/ble/MotionService.cpp32
-rw-r--r--src/components/ble/MusicService.cpp21
-rw-r--r--src/components/ble/NavigationService.cpp26
-rw-r--r--src/components/ble/NimbleController.cpp2
-rw-r--r--src/components/ble/weather/WeatherService.h3
-rw-r--r--src/components/datetime/DateTimeController.cpp30
-rw-r--r--src/components/fs/FS.cpp4
-rw-r--r--src/components/fs/FS.h2
-rw-r--r--src/components/settings/Settings.cpp6
-rw-r--r--src/components/settings/Settings.h27
16 files changed, 122 insertions, 87 deletions
diff --git a/src/components/alarm/AlarmController.cpp b/src/components/alarm/AlarmController.cpp
index 11d96e7..d412273 100644
--- a/src/components/alarm/AlarmController.cpp
+++ b/src/components/alarm/AlarmController.cpp
@@ -54,8 +54,7 @@ void AlarmController::ScheduleAlarm() {
auto now = dateTimeController.CurrentDateTime();
alarmTime = now;
- time_t ttAlarmTime = std::chrono::system_clock::to_time_t(
- std::chrono::time_point_cast<std::chrono::system_clock::duration>(alarmTime));
+ time_t ttAlarmTime = std::chrono::system_clock::to_time_t(std::chrono::time_point_cast<std::chrono::system_clock::duration>(alarmTime));
tm* tmAlarmTime = std::localtime(&ttAlarmTime);
// If the time being set has already passed today,the alarm should be set for tomorrow
diff --git a/src/components/ble/AlertNotificationClient.cpp b/src/components/ble/AlertNotificationClient.cpp
index 335845e..095fdef 100644
--- a/src/components/ble/AlertNotificationClient.cpp
+++ b/src/components/ble/AlertNotificationClient.cpp
@@ -26,8 +26,11 @@ namespace {
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) {
+ 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);
}
diff --git a/src/components/ble/BatteryInformationService.h b/src/components/ble/BatteryInformationService.h
index 1303fd6..c6fc52e 100644
--- a/src/components/ble/BatteryInformationService.h
+++ b/src/components/ble/BatteryInformationService.h
@@ -18,6 +18,7 @@ namespace Pinetime {
int OnBatteryServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context);
void NotifyBatteryLevel(uint16_t connectionHandle, uint8_t level);
+
private:
Controllers::Battery& batteryController;
static constexpr uint16_t batteryInformationServiceId {0x180F};
diff --git a/src/components/ble/CurrentTimeClient.cpp b/src/components/ble/CurrentTimeClient.cpp
index dd8171b..53e98cb 100644
--- a/src/components/ble/CurrentTimeClient.cpp
+++ b/src/components/ble/CurrentTimeClient.cpp
@@ -85,10 +85,21 @@ int CurrentTimeClient::OnCurrentTimeReadResult(uint16_t conn_handle, const ble_g
// 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));
+ 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);
}
diff --git a/src/components/ble/CurrentTimeService.cpp b/src/components/ble/CurrentTimeService.cpp
index e509aea..8430d1b 100644
--- a/src/components/ble/CurrentTimeService.cpp
+++ b/src/components/ble/CurrentTimeService.cpp
@@ -29,11 +29,22 @@ int CurrentTimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handl
CtsData result;
os_mbuf_copydata(ctxt->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);
+ NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d",
+ result.year,
+ result.month,
+ result.dayofmonth,
+ result.hour,
+ result.minute,
+ result.second);
- m_dateTimeController.SetTime(
- result.year, result.month, result.dayofmonth, 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG));
+ m_dateTimeController.SetTime(result.year,
+ result.month,
+ result.dayofmonth,
+ 0,
+ result.hour,
+ result.minute,
+ result.second,
+ nrf_rtc_counter_get(portNRF_RTC_REG));
} else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) {
CtsData currentDateTime;
diff --git a/src/components/ble/HeartRateService.cpp b/src/components/ble/HeartRateService.cpp
index 4824a6b..d49a02c 100644
--- a/src/components/ble/HeartRateService.cpp
+++ b/src/components/ble/HeartRateService.cpp
@@ -57,7 +57,8 @@ int HeartRateService::OnHeartRateRequested(uint16_t connectionHandle, uint16_t a
}
void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) {
- if(!heartRateMeasurementNotificationEnable) return;
+ if (!heartRateMeasurementNotificationEnable)
+ return;
uint8_t buffer[2] = {0, heartRateController.HeartRate()}; // [0] = flags, [1] = hr value
auto* om = ble_hs_mbuf_from_flat(buffer, 2);
@@ -72,11 +73,11 @@ void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) {
}
void HeartRateService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
- if(attributeHandle == heartRateMeasurementHandle)
+ if (attributeHandle == heartRateMeasurementHandle)
heartRateMeasurementNotificationEnable = true;
}
void HeartRateService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
- if(attributeHandle == heartRateMeasurementHandle)
+ if (attributeHandle == heartRateMeasurementHandle)
heartRateMeasurementNotificationEnable = false;
} \ No newline at end of file
diff --git a/src/components/ble/MotionService.cpp b/src/components/ble/MotionService.cpp
index 87923c2..121ad3b 100644
--- a/src/components/ble/MotionService.cpp
+++ b/src/components/ble/MotionService.cpp
@@ -8,10 +8,8 @@ using namespace Pinetime::Controllers;
namespace {
// 0003yyxx-78fc-48fe-8e23-433b3a1942d0
constexpr ble_uuid128_t CharUuid(uint8_t x, uint8_t y) {
- return ble_uuid128_t{
- .u = {.type = BLE_UUID_TYPE_128},
- .value = { 0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x03, 0x00 }
- };
+ return ble_uuid128_t {.u = {.type = BLE_UUID_TYPE_128},
+ .value = {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x03, 0x00}};
}
// 00030000-78fc-48fe-8e23-433b3a1942d0
@@ -45,11 +43,7 @@ MotionService::MotionService(Pinetime::System::SystemTask& system, Controllers::
.val_handle = &motionValuesHandle},
{0}},
serviceDefinition {
- {
- .type = BLE_GATT_SVC_TYPE_PRIMARY,
- .uuid = &motionServiceUuid.u,
- .characteristics = characteristicDefinition
- },
+ {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &motionServiceUuid.u, .characteristics = characteristicDefinition},
{0},
} {
// TODO refactor to prevent this loop dependency (service depends on controller and controller depends on service)
@@ -72,8 +66,8 @@ int MotionService::OnStepCountRequested(uint16_t connectionHandle, uint16_t attr
int res = os_mbuf_append(context->om, &buffer, 4);
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
- } else if(attributeHandle == motionValuesHandle) {
- int16_t buffer[3] = { motionController.X(), motionController.Y(), motionController.Z() };
+ } else if (attributeHandle == motionValuesHandle) {
+ int16_t buffer[3] = {motionController.X(), motionController.Y(), motionController.Z()};
int res = os_mbuf_append(context->om, buffer, 3 * sizeof(int16_t));
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
@@ -82,7 +76,8 @@ int MotionService::OnStepCountRequested(uint16_t connectionHandle, uint16_t attr
}
void MotionService::OnNewStepCountValue(uint32_t stepCount) {
- if(!stepCountNoficationEnabled) return;
+ if (!stepCountNoficationEnabled)
+ return;
uint32_t buffer = stepCount;
auto* om = ble_hs_mbuf_from_flat(&buffer, 4);
@@ -96,9 +91,10 @@ void MotionService::OnNewStepCountValue(uint32_t stepCount) {
ble_gattc_notify_custom(connectionHandle, stepCountHandle, om);
}
void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
- if(!motionValuesNoficationEnabled) return;
+ if (!motionValuesNoficationEnabled)
+ return;
- int16_t buffer[3] = { motionController.X(), motionController.Y(), motionController.Z() };
+ int16_t buffer[3] = {motionController.X(), motionController.Y(), motionController.Z()};
auto* om = ble_hs_mbuf_from_flat(buffer, 3 * sizeof(int16_t));
uint16_t connectionHandle = system.nimble().connHandle();
@@ -111,15 +107,15 @@ void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
}
void MotionService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
- if(attributeHandle == stepCountHandle)
+ if (attributeHandle == stepCountHandle)
stepCountNoficationEnabled = true;
- else if(attributeHandle == motionValuesHandle)
+ else if (attributeHandle == motionValuesHandle)
motionValuesNoficationEnabled = true;
}
void MotionService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
- if(attributeHandle == stepCountHandle)
+ if (attributeHandle == stepCountHandle)
stepCountNoficationEnabled = false;
- else if(attributeHandle == motionValuesHandle)
+ else if (attributeHandle == motionValuesHandle)
motionValuesNoficationEnabled = false;
}
diff --git a/src/components/ble/MusicService.cpp b/src/components/ble/MusicService.cpp
index 60747e9..fc7cef0 100644
--- a/src/components/ble/MusicService.cpp
+++ b/src/components/ble/MusicService.cpp
@@ -22,10 +22,8 @@
namespace {
// 0000yyxx-78fc-48fe-8e23-433b3a1942d0
constexpr ble_uuid128_t CharUuid(uint8_t x, uint8_t y) {
- return ble_uuid128_t{
- .u = {.type = BLE_UUID_TYPE_128},
- .value = { 0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x00, 0x00 }
- };
+ return ble_uuid128_t {.u = {.type = BLE_UUID_TYPE_128},
+ .value = {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x00, 0x00}};
}
// 00000000-78fc-48fe-8e23-433b3a1942d0
@@ -111,8 +109,7 @@ Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask&
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[13] = {0};
- serviceDefinition[0] = {
- .type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &msUuid.u, .characteristics = characteristicDefinition};
+ serviceDefinition[0] = {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &msUuid.u, .characteristics = characteristicDefinition};
serviceDefinition[1] = {0};
}
@@ -137,9 +134,9 @@ int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_
os_mbuf_copydata(ctxt->om, 0, bufferSize, data);
if (notifSize > bufferSize) {
- data[bufferSize-1] = '.';
- data[bufferSize-2] = '.';
- data[bufferSize-3] = '.';
+ data[bufferSize - 1] = '.';
+ data[bufferSize - 2] = '.';
+ data[bufferSize - 3] = '.';
}
data[bufferSize] = '\0';
@@ -157,7 +154,8 @@ int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_
if (playing) {
trackProgressUpdateTime = xTaskGetTickCount();
} else {
- trackProgress += static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed());
+ trackProgress +=
+ static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed());
}
} else if (ble_uuid_cmp(ctxt->chr->uuid, &msRepeatCharUuid.u) == 0) {
repeat = s[0];
@@ -201,7 +199,8 @@ float Pinetime::Controllers::MusicService::getPlaybackSpeed() const {
int Pinetime::Controllers::MusicService::getProgress() const {
if (isPlaying()) {
- return trackProgress + static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed());
+ return trackProgress +
+ static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed());
}
return trackProgress;
}
diff --git a/src/components/ble/NavigationService.cpp b/src/components/ble/NavigationService.cpp
index 5418b9e..7614368 100644
--- a/src/components/ble/NavigationService.cpp
+++ b/src/components/ble/NavigationService.cpp
@@ -46,15 +46,23 @@ namespace {
} // namespace
Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::SystemTask& system) : m_system(system) {
- characteristicDefinition[0] = {
- .uuid = &navFlagCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
-
- characteristicDefinition[1] = {
- .uuid = &navNarrativeCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
- characteristicDefinition[2] = {
- .uuid = &navManDistCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
- characteristicDefinition[3] = {
- .uuid = &navProgressCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
+ characteristicDefinition[0] = {.uuid = &navFlagCharUuid.u,
+ .access_cb = NAVCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
+
+ characteristicDefinition[1] = {.uuid = &navNarrativeCharUuid.u,
+ .access_cb = NAVCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
+ characteristicDefinition[2] = {.uuid = &navManDistCharUuid.u,
+ .access_cb = NAVCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
+ characteristicDefinition[3] = {.uuid = &navProgressCharUuid.u,
+ .access_cb = NAVCallback,
+ .arg = this,
+ .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[4] = {0};
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index d2d6dc0..52f4e4c 100644
--- a/src/components/ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -223,7 +223,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
currentTimeClient.Reset();
alertNotificationClient.Reset();
connectionHandle = BLE_HS_CONN_HANDLE_NONE;
- if(bleController.IsConnected()) {
+ if (bleController.IsConnected()) {
bleController.Disconnect();
fastAdvCount = 0;
StartAdvertising();
diff --git a/src/components/ble/weather/WeatherService.h b/src/components/ble/weather/WeatherService.h
index eca70cb..e37417d 100644
--- a/src/components/ble/weather/WeatherService.h
+++ b/src/components/ble/weather/WeatherService.h
@@ -127,7 +127,8 @@ namespace Pinetime {
{.uuid = &weatherControlCharUuid.u, .access_cb = WeatherCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ},
{nullptr}};
const struct ble_gatt_svc_def serviceDefinition[2] = {
- {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &weatherUuid.u, .characteristics = characteristicDefinition}, {0}};
+ {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &weatherUuid.u, .characteristics = characteristicDefinition},
+ {0}};
uint16_t eventHandle {};
diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp
index 3bfbdc7..ba04705 100644
--- a/src/components/datetime/DateTimeController.cpp
+++ b/src/components/datetime/DateTimeController.cpp
@@ -19,8 +19,14 @@ void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock,
UpdateTime(previousSystickCounter); // Update internal state without updating the time
}
-void DateTime::SetTime(
- uint16_t year, uint8_t month, uint8_t day, uint8_t dayOfWeek, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter) {
+void DateTime::SetTime(uint16_t year,
+ uint8_t month,
+ uint8_t day,
+ uint8_t dayOfWeek,
+ uint8_t hour,
+ uint8_t minute,
+ uint8_t second,
+ uint32_t systickCounter) {
std::tm tm = {
/* .tm_sec = */ second,
/* .tm_min = */ minute,
@@ -129,16 +135,16 @@ std::string DateTime::FormattedTime() {
// Return time as a string in 12- or 24-hour format
char buff[9];
if (settingsController.GetClockType() == ClockType::H12) {
- uint8_t hour12;
- const char* amPmStr;
- if (hour < 12) {
- hour12 = (hour == 0) ? 12 : hour;
- amPmStr = "AM";
- } else {
- hour12 = (hour == 12) ? 12 : hour - 12;
- amPmStr = "PM";
- }
- sprintf(buff, "%i:%02i %s", hour12, minute, amPmStr);
+ uint8_t hour12;
+ const char* amPmStr;
+ if (hour < 12) {
+ hour12 = (hour == 0) ? 12 : hour;
+ amPmStr = "AM";
+ } else {
+ hour12 = (hour == 12) ? 12 : hour - 12;
+ amPmStr = "PM";
+ }
+ sprintf(buff, "%i:%02i %s", hour12, minute, amPmStr);
} else {
sprintf(buff, "%02i:%02i", hour, minute);
}
diff --git a/src/components/fs/FS.cpp b/src/components/fs/FS.cpp
index 8c98ae3..14b0552 100644
--- a/src/components/fs/FS.cpp
+++ b/src/components/fs/FS.cpp
@@ -95,8 +95,8 @@ int FS::DirRewind(lfs_dir_t* dir) {
int FS::DirCreate(const char* path) {
return lfs_mkdir(&lfs, path);
}
-int FS::Rename(const char* oldPath, const char* newPath){
- return lfs_rename(&lfs,oldPath,newPath);
+int FS::Rename(const char* oldPath, const char* newPath) {
+ return lfs_rename(&lfs, oldPath, newPath);
}
int FS::Stat(const char* path, lfs_info* info) {
return lfs_stat(&lfs, path, info);
diff --git a/src/components/fs/FS.h b/src/components/fs/FS.h
index 2b27ae5..87fcdc2 100644
--- a/src/components/fs/FS.h
+++ b/src/components/fs/FS.h
@@ -26,7 +26,7 @@ namespace Pinetime {
int DirRead(lfs_dir_t* dir, lfs_info* info);
int DirRewind(lfs_dir_t* dir);
int DirCreate(const char* path);
-
+
lfs_ssize_t GetFSSize();
int Rename(const char* oldPath, const char* newPath);
int Stat(const char* path, lfs_info* info);
diff --git a/src/components/settings/Settings.cpp b/src/components/settings/Settings.cpp
index fee62da..1ae00a2 100644
--- a/src/components/settings/Settings.cpp
+++ b/src/components/settings/Settings.cpp
@@ -26,12 +26,12 @@ void Settings::LoadSettingsFromFile() {
SettingsData bufferSettings;
lfs_file_t settingsFile;
- if ( fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_RDONLY) != LFS_ERR_OK) {
+ if (fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_RDONLY) != LFS_ERR_OK) {
return;
}
fs.FileRead(&settingsFile, reinterpret_cast<uint8_t*>(&bufferSettings), sizeof(settings));
fs.FileClose(&settingsFile);
- if ( bufferSettings.version == settingsVersion ) {
+ if (bufferSettings.version == settingsVersion) {
settings = bufferSettings;
}
}
@@ -39,7 +39,7 @@ void Settings::LoadSettingsFromFile() {
void Settings::SaveSettingsToFile() {
lfs_file_t settingsFile;
- if ( fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_WRONLY | LFS_O_CREAT) != LFS_ERR_OK) {
+ if (fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_WRONLY | LFS_O_CREAT) != LFS_ERR_OK) {
return;
}
fs.FileWrite(&settingsFile, reinterpret_cast<uint8_t*>(&settings), sizeof(settings));
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index 44a1a85..3b113ea 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -140,15 +140,14 @@ namespace Pinetime {
return settings.screenTimeOut;
};
- void SetShakeThreshold(uint16_t thresh){
- if(settings.shakeWakeThreshold != thresh){
- settings.shakeWakeThreshold = thresh;
- settingsChanged = true;
+ void SetShakeThreshold(uint16_t thresh) {
+ if (settings.shakeWakeThreshold != thresh) {
+ settings.shakeWakeThreshold = thresh;
+ settingsChanged = true;
}
-
}
- int16_t GetShakeThreshold() const{
+ int16_t GetShakeThreshold() const {
return settings.shakeWakeThreshold;
}
@@ -195,20 +194,20 @@ namespace Pinetime {
if (goal != settings.stepsGoal) {
settingsChanged = true;
}
- settings.stepsGoal = goal;
+ settings.stepsGoal = goal;
};
-
+
uint32_t GetStepsGoal() const {
return settings.stepsGoal;
};
- void SetBleRadioEnabled(bool enabled) {
- bleRadioEnabled = enabled;
- };
+ void SetBleRadioEnabled(bool enabled) {
+ bleRadioEnabled = enabled;
+ };
- bool GetBleRadioEnabled() const {
- return bleRadioEnabled;
- };
+ bool GetBleRadioEnabled() const {
+ return bleRadioEnabled;
+ };
private:
Pinetime::Controllers::FS& fs;