Apply clang-format to all C++ files

This commit is contained in:
Finlay Davidson 2022-05-09 17:16:08 +02:00 committed by Riku Isokoski
parent 718fbdab98
commit 7f45538eb5
68 changed files with 477 additions and 381 deletions

View file

@ -8,9 +8,9 @@ AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
@ -83,6 +83,8 @@ IndentGotoLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 2
IndentWrappedFunctionNames: false
# Requires Clang >= 15, could also cause incorrect code formatting:
# InsertBraces: true
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true

View file

@ -31,6 +31,10 @@ const bool BootloaderVersion::IsValid() {
void BootloaderVersion::SetVersion(uint32_t v) {
BootloaderVersion::version = v;
snprintf(BootloaderVersion::versionString, BootloaderVersion::VERSION_STR_LEN, "%ld.%ld.%ld",
BootloaderVersion::Major(), BootloaderVersion::Minor(), BootloaderVersion::Patch());
snprintf(BootloaderVersion::versionString,
BootloaderVersion::VERSION_STR_LEN,
"%ld.%ld.%ld",
BootloaderVersion::Major(),
BootloaderVersion::Minor(),
BootloaderVersion::Patch());
}

View file

@ -12,6 +12,7 @@ namespace Pinetime {
static const char* VersionString();
static const bool IsValid();
static void SetVersion(uint32_t v);
private:
static uint32_t version;
static constexpr size_t VERSION_STR_LEN = 12;

View file

@ -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

View file

@ -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);
}

View file

@ -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};

View file

@ -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);
}

View file

@ -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;

View file

@ -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);

View file

@ -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)
@ -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,7 +91,8 @@ 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()};
auto* om = ble_hs_mbuf_from_flat(buffer, 3 * sizeof(int16_t));

View file

@ -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};
}
@ -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;
}

View file

@ -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[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[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};

View file

@ -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 {};

View file

@ -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,

View file

@ -145,7 +145,6 @@ namespace Pinetime {
settings.shakeWakeThreshold = thresh;
settingsChanged = true;
}
}
int16_t GetShakeThreshold() const {

View file

@ -5,23 +5,41 @@ using namespace Pinetime::Controllers;
lv_color_t Pinetime::Applications::Convert(Pinetime::Controllers::Settings::Colors color) {
switch (color) {
case Pinetime::Controllers::Settings::Colors::White: return LV_COLOR_WHITE;
case Pinetime::Controllers::Settings::Colors::Silver: return LV_COLOR_SILVER;
case Pinetime::Controllers::Settings::Colors::Gray: return LV_COLOR_GRAY;
case Pinetime::Controllers::Settings::Colors::Black: return LV_COLOR_BLACK;
case Pinetime::Controllers::Settings::Colors::Red: return LV_COLOR_RED;
case Pinetime::Controllers::Settings::Colors::Maroon: return LV_COLOR_MAKE(0xb0, 0x0, 0x0);
case Pinetime::Controllers::Settings::Colors::Yellow: return LV_COLOR_YELLOW;
case Pinetime::Controllers::Settings::Colors::Olive: return LV_COLOR_MAKE(0xb0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Lime: return LV_COLOR_LIME;
case Pinetime::Controllers::Settings::Colors::Green: return LV_COLOR_MAKE(0x0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Cyan: return LV_COLOR_CYAN;
case Pinetime::Controllers::Settings::Colors::Teal: return LV_COLOR_MAKE(0x0, 0xb0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Blue: return LV_COLOR_BLUE;
case Pinetime::Controllers::Settings::Colors::Navy: return LV_COLOR_MAKE(0x0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Magenta: return LV_COLOR_MAGENTA;
case Pinetime::Controllers::Settings::Colors::Purple: return LV_COLOR_MAKE(0xb0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Orange: return LV_COLOR_ORANGE;
default: return LV_COLOR_WHITE;
case Pinetime::Controllers::Settings::Colors::White:
return LV_COLOR_WHITE;
case Pinetime::Controllers::Settings::Colors::Silver:
return LV_COLOR_SILVER;
case Pinetime::Controllers::Settings::Colors::Gray:
return LV_COLOR_GRAY;
case Pinetime::Controllers::Settings::Colors::Black:
return LV_COLOR_BLACK;
case Pinetime::Controllers::Settings::Colors::Red:
return LV_COLOR_RED;
case Pinetime::Controllers::Settings::Colors::Maroon:
return LV_COLOR_MAKE(0xb0, 0x0, 0x0);
case Pinetime::Controllers::Settings::Colors::Yellow:
return LV_COLOR_YELLOW;
case Pinetime::Controllers::Settings::Colors::Olive:
return LV_COLOR_MAKE(0xb0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Lime:
return LV_COLOR_LIME;
case Pinetime::Controllers::Settings::Colors::Green:
return LV_COLOR_MAKE(0x0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Cyan:
return LV_COLOR_CYAN;
case Pinetime::Controllers::Settings::Colors::Teal:
return LV_COLOR_MAKE(0x0, 0xb0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Blue:
return LV_COLOR_BLUE;
case Pinetime::Controllers::Settings::Colors::Navy:
return LV_COLOR_MAKE(0x0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Magenta:
return LV_COLOR_MAGENTA;
case Pinetime::Controllers::Settings::Colors::Purple:
return LV_COLOR_MAKE(0xb0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Orange:
return LV_COLOR_ORANGE;
default:
return LV_COLOR_WHITE;
}
}

View file

@ -348,13 +348,21 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
break;
case Apps::Notifications:
currentScreen = std::make_unique<Screens::Notifications>(
this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Normal);
currentScreen = std::make_unique<Screens::Notifications>(this,
notificationManager,
systemTask->nimble().alertService(),
motorController,
*systemTask,
Screens::Notifications::Modes::Normal);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::NotificationsPreview:
currentScreen = std::make_unique<Screens::Notifications>(
this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Preview);
currentScreen = std::make_unique<Screens::Notifications>(this,
notificationManager,
systemTask->nimble().alertService(),
motorController,
*systemTask,
Screens::Notifications::Modes::Preview);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::Timer:
@ -366,8 +374,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
// Settings
case Apps::QuickSettings:
currentScreen = std::make_unique<Screens::QuickSettings>(
this, batteryController, dateTimeController, brightnessController, motorController, settingsController);
currentScreen = std::make_unique<Screens::QuickSettings>(this,
batteryController,
dateTimeController,
brightnessController,
motorController,
settingsController);
ReturnApp(Apps::Clock, FullRefreshDirections::LeftAnim, TouchEvents::SwipeLeft);
break;
case Apps::Settings:
@ -419,8 +431,14 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
case Apps::SysInfo:
currentScreen = std::make_unique<Screens::SystemInfo>(
this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController, touchPanel);
currentScreen = std::make_unique<Screens::SystemInfo>(this,
dateTimeController,
batteryController,
brightnessController,
bleController,
watchdog,
motionController,
touchPanel);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
case Apps::FlashLight:

View file

@ -26,7 +26,6 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler)
: lcd {lcd}, bleController {bleController} {
}
void DisplayApp::Start() {
@ -121,5 +120,4 @@ void DisplayApp::PushMessage(Display::Messages msg) {
}
void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
}

View file

@ -61,7 +61,9 @@ namespace Pinetime {
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler);
void Start();
void Start(Pinetime::System::BootErrors){ Start(); };
void Start(Pinetime::System::BootErrors) {
Start();
};
void PushMessage(Pinetime::Applications::Display::Messages msg);
void Register(Pinetime::System::SystemTask* systemTask);

View file

@ -20,7 +20,6 @@ namespace Pinetime {
LittleVgl& operator=(LittleVgl&&) = delete;
void Init() {
}
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
@ -33,7 +32,6 @@ namespace Pinetime {
void SetNewTapEvent(uint16_t x, uint16_t y) {
}
void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) {
}
};
}

View file

@ -195,8 +195,13 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
void LittleVgl::InitTheme() {
lv_theme_t* th = lv_pinetime_theme_init(
LV_COLOR_WHITE, LV_COLOR_SILVER, 0, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20);
lv_theme_t* th = lv_pinetime_theme_init(LV_COLOR_WHITE,
LV_COLOR_SILVER,
0,
&jetbrains_mono_bold_20,
&jetbrains_mono_bold_20,
&jetbrains_mono_bold_20,
&jetbrains_mono_bold_20);
lv_theme_set_act(th);
}

View file

@ -300,8 +300,12 @@ void Alarm::ShowInfo() {
auto minToAlarm = (timeToAlarm % 3600) / 60;
auto secToAlarm = timeToAlarm % 60;
lv_label_set_text_fmt(
txtMessage, "Time to\nalarm:\n%2lu Days\n%2lu Hours\n%2lu Minutes\n%2lu Seconds", daysToAlarm, hrsToAlarm, minToAlarm, secToAlarm);
lv_label_set_text_fmt(txtMessage,
"Time to\nalarm:\n%2lu Days\n%2lu Hours\n%2lu Minutes\n%2lu Seconds",
daysToAlarm,
hrsToAlarm,
minToAlarm,
secToAlarm);
} else {
lv_label_set_text_static(txtMessage, "Alarm\nis not\nset.");
}

View file

@ -45,8 +45,8 @@ namespace Pinetime {
Controllers::Settings& settingsController;
System::SystemTask& systemTask;
lv_obj_t *time, *lblampm, *btnStop, *txtStop, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp,
*txtMinDown, *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo, *enableSwitch;
lv_obj_t *time, *lblampm, *btnStop, *txtStop, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp, *txtMinDown,
*txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo, *enableSwitch;
lv_obj_t* txtMessage = nullptr;
lv_obj_t* btnMessage = nullptr;
lv_task_t* taskStopAlarm = nullptr;

View file

@ -15,6 +15,7 @@ namespace Pinetime {
static const char* GetUnknownIcon();
static const char* GetPlugIcon(bool isCharging);
private:
lv_obj_t* batteryImg;
lv_obj_t* batteryJuice;

View file

@ -75,13 +75,22 @@ std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
}
std::unique_ptr<Screen> Clock::WatchFaceAnalogScreen() {
return std::make_unique<Screens::WatchFaceAnalog>(
app, dateTimeController, batteryController, bleController, notificatioManager, settingsController);
return std::make_unique<Screens::WatchFaceAnalog>(app,
dateTimeController,
batteryController,
bleController,
notificatioManager,
settingsController);
}
std::unique_ptr<Screen> Clock::WatchFacePineTimeStyleScreen() {
return std::make_unique<Screens::WatchFacePineTimeStyle>(
app, dateTimeController, batteryController, bleController, notificatioManager, settingsController, motionController);
return std::make_unique<Screens::WatchFacePineTimeStyle>(app,
dateTimeController,
batteryController,
bleController,
notificatioManager,
settingsController,
motionController);
}
std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() {

View file

@ -9,8 +9,7 @@ namespace {
}
}
Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error)
: Screen(app) {
Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error) : Screen(app) {
lv_obj_t* warningLabel = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(warningLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);

View file

@ -13,6 +13,7 @@ namespace Pinetime {
~Error() override;
void ButtonEventHandler();
private:
lv_obj_t* btnOk;
};

View file

@ -34,7 +34,8 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
if (validator.IsValidated())
lv_label_set_text_static(labelIsValidated, "You have already\n#00ff00 validated# this firmware#");
else {
lv_label_set_text_static(labelIsValidated, "Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
lv_label_set_text_static(labelIsValidated,
"Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
buttonValidate = lv_btn_create(lv_scr_act(), nullptr);
buttonValidate->user_data = this;

View file

@ -14,4 +14,3 @@ PassKey::PassKey(Pinetime::Applications::DisplayApp* app, uint32_t key) : Screen
PassKey::~PassKey() {
lv_obj_clean(lv_scr_act());
}

View file

@ -17,8 +17,12 @@ namespace Pinetime {
uint8_t initScreen,
const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
ScreenListModes mode)
: Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, screenIndex{initScreen}, current {this->screens[initScreen]()} {
: Screen(app),
initScreen {initScreen},
screens {std::move(screens)},
mode {mode},
screenIndex {initScreen},
current {this->screens[initScreen]()} {
}
ScreenList(const ScreenList&) = delete;

View file

@ -166,8 +166,12 @@ void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
lapBuffer.addLaps(currentTimeSeparated);
lapNr++;
if (lapBuffer[1]) {
lv_label_set_text_fmt(
lapOneText, "#%2d %2d:%02d.%02d", (lapNr - 1), lapBuffer[1]->mins, lapBuffer[1]->secs, lapBuffer[1]->hundredths);
lv_label_set_text_fmt(lapOneText,
"#%2d %2d:%02d.%02d",
(lapNr - 1),
lapBuffer[1]->mins,
lapBuffer[1]->secs,
lapBuffer[1]->hundredths);
}
if (lapBuffer[0]) {
lv_label_set_text_fmt(lapTwoText, "#%2d %2d:%02d.%02d", lapNr, lapBuffer[0]->mins, lapBuffer[0]->secs, lapBuffer[0]->hundredths);

View file

@ -120,7 +120,8 @@ void Tile::UpdateScreen() {
}
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
if(obj != btnm1) return;
if (obj != btnm1)
return;
app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
running = false;

View file

@ -36,10 +36,8 @@ int16_t CoordinateYRelocate(int16_t y) {
}
lv_point_t CoordinateRelocate(int16_t radius, int16_t angle) {
return lv_point_t{
.x = CoordinateXRelocate(radius * static_cast<int32_t>(Sine(angle)) / LV_TRIG_SCALE),
.y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)
};
return lv_point_t {.x = CoordinateXRelocate(radius * static_cast<int32_t>(Sine(angle)) / LV_TRIG_SCALE),
.y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)};
}
}

View file

@ -160,11 +160,19 @@ void WatchFaceDigital::Refresh() {
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
lv_label_set_text_fmt(
label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
lv_label_set_text_fmt(label_date,
"%s %d %s %d",
dateTimeController.DayOfWeekShortToString(),
day,
dateTimeController.MonthShortToString(),
year);
} else {
lv_label_set_text_fmt(
label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
lv_label_set_text_fmt(label_date,
"%s %s %d %d",
dateTimeController.DayOfWeekShortToString(),
dateTimeController.MonthShortToString(),
day,
year);
}
lv_obj_realign(label_date);

View file

@ -90,4 +90,3 @@ void SettingBluetooth::OnBluetoothEnabled(lv_obj_t* object, lv_event_t event) {
settingsController.SetBleRadioEnabled(true);
}
}

View file

@ -21,9 +21,8 @@ namespace {
}
}
SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::DateTime &dateTimeController) :
Screen(app),
dateTimeController {dateTimeController} {
SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::DateTime& dateTimeController)
: Screen(app), dateTimeController {dateTimeController} {
lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(title, "Set current date");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
@ -194,5 +193,6 @@ void SettingSetDate::CheckDay() {
void SettingSetDate::UpdateMonthLabel() {
lv_label_set_text_static(
lblMonth, Pinetime::Controllers::DateTime::MonthShortToStringLow(static_cast<Pinetime::Controllers::DateTime::Months>(monthValue)));
lblMonth,
Pinetime::Controllers::DateTime::MonthShortToStringLow(static_cast<Pinetime::Controllers::DateTime::Months>(monthValue)));
}

View file

@ -12,11 +12,8 @@ namespace {
}
}
SettingSteps::SettingSteps(
Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) :
Screen(app),
settingsController{settingsController}
{
SettingSteps::SettingSteps(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), settingsController {settingsController} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
@ -61,7 +58,6 @@ SettingSteps::SettingSteps(
lv_obj_set_event_cb(btnMinus, event_handler);
lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80);
lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
}
SettingSteps::~SettingSteps() {
@ -88,5 +84,4 @@ void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10);
}
}
}

View file

@ -13,7 +13,8 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller
settingsController {settingsController},
screens {app,
settingsController.GetSettingsMenu(),
{[this]() -> std::unique_ptr<Screen> {
{
[this]() -> std::unique_ptr<Screen> {
return CreateScreen1();
},
[this]() -> std::unique_ptr<Screen> {
@ -53,7 +54,8 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
{Symbols::shoe, "Steps", Apps::SettingSteps},
{Symbols::clock, "Set date", Apps::SettingSetDate},
{Symbols::clock, "Set time", Apps::SettingSetTime},
{Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}};
{Symbols::batteryHalf, "Battery", Apps::BatteryInfo},
}};
return std::make_unique<Screens::List>(1, 4, app, settingsController, applications);
}
@ -64,7 +66,7 @@ std::unique_ptr<Screen> Settings::CreateScreen3() {
{Symbols::clock, "Chimes", Apps::SettingChimes},
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
{Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}
{Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth},
}};
return std::make_unique<Screens::List>(2, 4, app, settingsController, applications);
@ -76,7 +78,7 @@ std::unique_ptr<Screen> Settings::CreateScreen4() {
{Symbols::list, "About", Apps::SysInfo},
{Symbols::none, "None", Apps::None},
{Symbols::none, "None", Apps::None},
{Symbols::none, "None", Apps::None}
{Symbols::none, "None", Apps::None},
}};
return std::make_unique<Screens::List>(3, 4, app, settingsController, applications);

View file

@ -43,9 +43,15 @@ void Bma421::Init() {
return;
switch (bma.chip_id) {
case BMA423_CHIP_ID: deviceType = DeviceTypes::BMA421; break;
case BMA425_CHIP_ID: deviceType = DeviceTypes::BMA425; break;
default: deviceType = DeviceTypes::Unknown; break;
case BMA423_CHIP_ID:
deviceType = DeviceTypes::BMA421;
break;
case BMA425_CHIP_ID:
deviceType = DeviceTypes::BMA425;
break;
default:
deviceType = DeviceTypes::Unknown;
break;
}
ret = bma423_write_config_file(&bma);

View file

@ -6,11 +6,7 @@ namespace Pinetime {
class TwiMaster;
class Bma421 {
public:
enum class DeviceTypes : uint8_t {
Unknown,
BMA421,
BMA425
};
enum class DeviceTypes : uint8_t { Unknown, BMA421, BMA425 };
struct Values {
uint32_t steps;
int16_t x;

View file

@ -81,13 +81,8 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() {
// Validity check
if (x >= maxX || y >= maxY ||
(gesture != Gestures::None &&
gesture != Gestures::SlideDown &&
gesture != Gestures::SlideUp &&
gesture != Gestures::SlideLeft &&
gesture != Gestures::SlideRight &&
gesture != Gestures::SingleTap &&
gesture != Gestures::DoubleTap &&
(gesture != Gestures::None && gesture != Gestures::SlideDown && gesture != Gestures::SlideUp && gesture != Gestures::SlideLeft &&
gesture != Gestures::SlideRight && gesture != Gestures::SingleTap && gesture != Gestures::DoubleTap &&
gesture != Gestures::LongPress)) {
info.isValid = false;
return info;

View file

@ -44,6 +44,7 @@ namespace Pinetime {
uint8_t GetFwVersion() const {
return fwVersion;
}
private:
bool CheckDeviceIds();

View file

@ -13,18 +13,12 @@ TwiMaster::TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda,
}
void TwiMaster::ConfigurePins() const {
NRF_GPIO->PIN_CNF[pinScl] =
(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) |
(GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
(GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
NRF_GPIO->PIN_CNF[pinScl] = (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
NRF_GPIO->PIN_CNF[pinSda] =
(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) |
(GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
(GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
NRF_GPIO->PIN_CNF[pinSda] = (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
}

View file

@ -168,7 +168,6 @@ static constexpr uint32_t NoInit_MagicValue = 0xDEAD0000;
uint32_t NoInit_MagicWord __attribute__((section(".noinit")));
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoInit_BackUpTime __attribute__((section(".noinit")));
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
if (pin == Pinetime::PinMap::Cst816sIrq) {
systemTask.OnTouchEvent();
@ -327,7 +326,6 @@ int main(void) {
// retrieve version stored by bootloader
Pinetime::BootloaderVersion::SetVersion(NRF_TIMER2->CC[0]);
if (NoInit_MagicWord == NoInit_MagicValue) {
dateTimeController.SetCurrentTime(NoInit_BackUpTime);
} else {

View file

@ -28,7 +28,6 @@ Pinetime::Logging::NrfLogger logger;
Pinetime::Logging::DummyLogger logger;
#endif
static constexpr uint8_t displayWidth = 240;
static constexpr uint8_t displayHeight = 240;
static constexpr uint8_t bytesPerPixel = 2;

View file

@ -22,5 +22,6 @@ void Pinetime::System::SystemMonitor::Process() {
}
#else
// DummyMonitor
void Pinetime::System::SystemMonitor::Process() {}
void Pinetime::System::SystemMonitor::Process() {
}
#endif

View file

@ -27,8 +27,8 @@ namespace Pinetime {
return info.y;
}
Pinetime::Applications::TouchEvents GestureGet();
private:
private:
Pinetime::Drivers::Cst816S::TouchInfos info;
Pinetime::Drivers::Cst816S& touchPanel;
Pinetime::Components::LittleVgl& lvgl;