diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-03-25 16:43:27 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-03-25 16:44:46 (GMT) |
| commit | 30c319831ab15e6abaf97e4fa8f58a8eaeb8ba4a (patch) | |
| tree | a3231e8a294d6214e6c549d0d9ca4d23b1eb523f | |
| parent | 196b8325544174f571e6394259d11c56eaad8cb4 (diff) | |
sans airplane mode and related support code
| -rw-r--r-- | src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/components/ble/BleController.cpp | 12 | ||||
| -rw-r--r-- | src/components/ble/BleController.h | 5 | ||||
| -rw-r--r-- | src/components/ble/NimbleController.cpp | 18 | ||||
| -rw-r--r-- | src/components/ble/NimbleController.h | 3 | ||||
| -rw-r--r-- | src/components/settings/Settings.h | 12 | ||||
| -rw-r--r-- | src/displayapp/Apps.h | 1 | ||||
| -rw-r--r-- | src/displayapp/DisplayApp.cpp | 8 | ||||
| -rw-r--r-- | src/displayapp/Messages.h | 1 | ||||
| -rw-r--r-- | src/displayapp/screens/BleIcon.cpp | 5 | ||||
| -rw-r--r-- | src/displayapp/screens/BleIcon.h | 2 | ||||
| -rw-r--r-- | src/displayapp/screens/WatchFaceDigital.cpp | 5 | ||||
| -rw-r--r-- | src/displayapp/screens/WatchFaceDigital.h | 1 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/SettingAirplaneMode.cpp | 93 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/SettingAirplaneMode.h | 31 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/Settings.cpp | 2 | ||||
| -rw-r--r-- | src/systemtask/Messages.h | 3 | ||||
| -rw-r--r-- | src/systemtask/SystemTask.cpp | 9 |
18 files changed, 8 insertions, 204 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 622b7e0..290668a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -422,7 +422,6 @@ list(APPEND SOURCE_FILES displayapp/screens/settings/SettingDisplay.cpp displayapp/screens/settings/SettingSteps.cpp displayapp/screens/settings/SettingShakeThreshold.cpp - displayapp/screens/settings/SettingAirplaneMode.cpp ## Watch faces displayapp/screens/WatchFaceDigital.cpp diff --git a/src/components/ble/BleController.cpp b/src/components/ble/BleController.cpp index b6b7383..548466f 100644 --- a/src/components/ble/BleController.cpp +++ b/src/components/ble/BleController.cpp @@ -14,18 +14,6 @@ void Ble::Disconnect() { isConnected = false; } -bool Ble::IsRadioEnabled() const { - return isRadioEnabled; -} - -void Ble::EnableRadio() { - isRadioEnabled = true; -} - -void Ble::DisableRadio() { - isRadioEnabled = false; -} - void Ble::StartFirmwareUpdate() { isFirmwareUpdating = true; } diff --git a/src/components/ble/BleController.h b/src/components/ble/BleController.h index 05112dc..6625df2 100644 --- a/src/components/ble/BleController.h +++ b/src/components/ble/BleController.h @@ -16,10 +16,6 @@ namespace Pinetime { void Connect(); void Disconnect(); - bool IsRadioEnabled() const; - void EnableRadio(); - void DisableRadio(); - void StartFirmwareUpdate(); void StopFirmwareUpdate(); void FirmwareUpdateTotalBytes(uint32_t totalBytes); @@ -59,7 +55,6 @@ namespace Pinetime { private: bool isConnected = false; - bool isRadioEnabled = true; bool isFirmwareUpdating = false; uint32_t firmwareUpdateTotalBytes = 0; uint32_t firmwareUpdateCurrentBytes = 0; diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 79880e9..a1597e2 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -163,7 +163,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { case BLE_GAP_EVENT_ADV_COMPLETE: NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_ADV_COMPLETE"); NRF_LOG_INFO("reason=%d; status=%0X", event->adv_complete.reason, event->connect.status); - if (bleController.IsRadioEnabled() && !bleController.IsConnected()) { + if (!bleController.IsConnected()) { StartAdvertising(); } break; @@ -332,20 +332,4 @@ void NimbleController::NotifyBatteryLevel(uint8_t level) { } } -void NimbleController::EnableRadio() { - bleController.EnableRadio(); - bleController.Disconnect(); - fastAdvCount = 0; - StartAdvertising(); -} - -void NimbleController::DisableRadio() { - bleController.DisableRadio(); - if (bleController.IsConnected()) { - ble_gap_terminate(connectionHandle, BLE_ERR_REM_USER_CONN_TERM); - bleController.Disconnect(); - } else { - ble_gap_adv_stop(); - } -} diff --git a/src/components/ble/NimbleController.h b/src/components/ble/NimbleController.h index 176848d..dfa42f7 100644 --- a/src/components/ble/NimbleController.h +++ b/src/components/ble/NimbleController.h @@ -63,9 +63,6 @@ namespace Pinetime { fastAdvCount = 0; }; - void EnableRadio(); - void DisableRadio(); - private: static constexpr const char* deviceName = "InfiniTime"; Pinetime::System::SystemTask& systemTask; diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 086aafd..3b26d69 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -159,14 +159,6 @@ namespace Pinetime { return settings.stepsGoal; }; - void SetBleRadioEnabled(bool enabled) { - bleRadioEnabled = enabled; - }; - - bool GetBleRadioEnabled() const { - return bleRadioEnabled; - }; - private: Pinetime::Controllers::FS& fs; @@ -191,10 +183,6 @@ namespace Pinetime { uint8_t appMenu = 0; uint8_t settingsMenu = 0; - /* airplaneMode is intentionally not saved with the other watch settings and initialized - * to off (false) on every boot because we always want ble to be enabled on startup - */ - bool bleRadioEnabled = true; void LoadSettingsFromFile(); void SaveSettingsToFile(); diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index d8b36c9..8d93cf7 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -21,7 +21,6 @@ namespace Pinetime { SettingWakeUp, SettingSteps, SettingShakeThreshold, - SettingAirplaneMode, Error }; } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 03de120..904b461 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -33,7 +33,6 @@ #include "displayapp/screens/settings/SettingDisplay.h" #include "displayapp/screens/settings/SettingSteps.h" #include "displayapp/screens/settings/SettingShakeThreshold.h" -#include "displayapp/screens/settings/SettingAirplaneMode.h" #include "libs/lv_conf.h" @@ -264,9 +263,6 @@ void DisplayApp::Refresh() { case Messages::BleFirmwareUpdateStarted: LoadApp(Apps::FirmwareUpdate, DisplayApp::FullRefreshDirections::Down); break; - case Messages::BleRadioEnableToggle: - PushMessageToSystemTask(System::Messages::BleRadioEnableToggle); - break; case Messages::UpdateDateTime: // Added to remove warning // What should happen here? @@ -380,10 +376,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique<Screens::SettingShakeThreshold>(this, settingsController, motionController, *systemTask); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; - case Apps::SettingAirplaneMode: - currentScreen = std::make_unique<Screens::SettingAirplaneMode>(this, settingsController); - ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); - break; case Apps::HeartRate: currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, *systemTask); break; diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h index d6929ff..2891d90 100644 --- a/src/displayapp/Messages.h +++ b/src/displayapp/Messages.h @@ -20,7 +20,6 @@ namespace Pinetime { RestoreBrightness, AlarmTriggered, Clock, - BleRadioEnableToggle }; } } diff --git a/src/displayapp/screens/BleIcon.cpp b/src/displayapp/screens/BleIcon.cpp index 019f803..6de688d 100644 --- a/src/displayapp/screens/BleIcon.cpp +++ b/src/displayapp/screens/BleIcon.cpp @@ -2,10 +2,7 @@ #include "displayapp/screens/Symbols.h" using namespace Pinetime::Applications::Screens; -const char* BleIcon::GetIcon(bool isRadioEnabled, bool isConnected) { - if(!isRadioEnabled) { - return Symbols::airplane; - } +const char* BleIcon::GetIcon(bool isConnected) { if (isConnected) { return Symbols::bluetooth; diff --git a/src/displayapp/screens/BleIcon.h b/src/displayapp/screens/BleIcon.h index d32dfad..d9a4654 100644 --- a/src/displayapp/screens/BleIcon.h +++ b/src/displayapp/screens/BleIcon.h @@ -7,7 +7,7 @@ namespace Pinetime { namespace Screens { class BleIcon { public: - static const char* GetIcon(bool isRadioEnabled, bool isConnected); + static const char* GetIcon(bool isConnected); }; } } diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 59bde83..4440ab6 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -119,9 +119,8 @@ void WatchFaceDigital::Refresh() { } bleState = bleController.IsConnected(); - bleRadioEnabled = bleController.IsRadioEnabled(); - if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { - lv_label_set_text(bleIcon, BleIcon::GetIcon(bleRadioEnabled.Get(), bleState.Get())); + if (bleState.IsUpdated()) { + lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get())); } lv_obj_realign(batteryIcon); lv_obj_realign(batteryPlug); diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index d33434c..3b436c3 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -47,7 +47,6 @@ namespace Pinetime { DirtyValue<uint8_t> batteryPercentRemaining {}; DirtyValue<bool> powerPresent {}; DirtyValue<bool> bleState {}; - DirtyValue<bool> bleRadioEnabled {}; DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {}; DirtyValue<bool> motionSensorOk {}; DirtyValue<uint32_t> stepCount {}; diff --git a/src/displayapp/screens/settings/SettingAirplaneMode.cpp b/src/displayapp/screens/settings/SettingAirplaneMode.cpp deleted file mode 100644 index 8517278..0000000 --- a/src/displayapp/screens/settings/SettingAirplaneMode.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "displayapp/screens/settings/SettingAirplaneMode.h" -#include <lvgl/lvgl.h> -#include "displayapp/DisplayApp.h" -#include "displayapp/Messages.h" -#include "displayapp/screens/Styles.h" -#include "displayapp/screens/Screen.h" -#include "displayapp/screens/Symbols.h" - -using namespace Pinetime::Applications::Screens; - -namespace { - static void OnAirplaneModeEnabledEvent(lv_obj_t* obj, lv_event_t event) { - auto* screen = static_cast<SettingAirplaneMode*>(obj->user_data); - screen->OnAirplaneModeEnabled(obj, event); - } - - static void OnAirplaneModeDisabledEvent(lv_obj_t* obj, lv_event_t event) { - auto* screen = static_cast<SettingAirplaneMode*>(obj->user_data); - screen->OnAirplaneModeDisabled(obj, event); - } -} - -SettingAirplaneMode::SettingAirplaneMode(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) - : Screen(app), settingsController {settingsController} { - - lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); - - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); - - lv_obj_set_pos(container1, 10, 60); - lv_obj_set_width(container1, LV_HOR_RES - 20); - lv_obj_set_height(container1, LV_VER_RES - 50); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); - - lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text_static(title, "Airplane mode"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); - - lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); - lv_label_set_text_static(icon, Symbols::airplane); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); - - cbEnabled = lv_checkbox_create(container1, nullptr); - lv_checkbox_set_text(cbEnabled, " Enable"); - cbEnabled->user_data = this; - lv_obj_set_event_cb(cbEnabled, OnAirplaneModeEnabledEvent); - SetRadioButtonStyle(cbEnabled); - - cbDisabled = lv_checkbox_create(container1, nullptr); - lv_checkbox_set_text(cbDisabled, " Disable"); - cbDisabled->user_data = this; - lv_obj_set_event_cb(cbDisabled, OnAirplaneModeDisabledEvent); - SetRadioButtonStyle(cbDisabled); - - if (settingsController.GetBleRadioEnabled()) { - lv_checkbox_set_checked(cbDisabled, true); - priorMode = true; - } else { - lv_checkbox_set_checked(cbEnabled, true); - priorMode = false; - } -} - -SettingAirplaneMode::~SettingAirplaneMode() { - lv_obj_clean(lv_scr_act()); - // Do not call SaveSettings - see src/components/settings/Settings.h - if (priorMode != settingsController.GetBleRadioEnabled()) { - app->PushMessage(Pinetime::Applications::Display::Messages::BleRadioEnableToggle); - } -} - -void SettingAirplaneMode::OnAirplaneModeEnabled(lv_obj_t* object, lv_event_t event) { - if (event == LV_EVENT_VALUE_CHANGED) { - lv_checkbox_set_checked(cbEnabled, true); - lv_checkbox_set_checked(cbDisabled, false); - settingsController.SetBleRadioEnabled(false); - } -} - -void SettingAirplaneMode::OnAirplaneModeDisabled(lv_obj_t* object, lv_event_t event) { - if (event == LV_EVENT_VALUE_CHANGED) { - lv_checkbox_set_checked(cbEnabled, false); - lv_checkbox_set_checked(cbDisabled, true); - settingsController.SetBleRadioEnabled(true); - } -} - diff --git a/src/displayapp/screens/settings/SettingAirplaneMode.h b/src/displayapp/screens/settings/SettingAirplaneMode.h deleted file mode 100644 index b3478c6..0000000 --- a/src/displayapp/screens/settings/SettingAirplaneMode.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include <array> -#include <cstdint> -#include <lvgl/lvgl.h> - -#include "components/settings/Settings.h" -#include "displayapp/screens/Screen.h" - -namespace Pinetime { - - namespace Applications { - namespace Screens { - - class SettingAirplaneMode : public Screen { - public: - SettingAirplaneMode(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); - ~SettingAirplaneMode() override; - - void OnAirplaneModeEnabled(lv_obj_t* object, lv_event_t event); - void OnAirplaneModeDisabled(lv_obj_t* object, lv_event_t event); - - private: - Controllers::Settings& settingsController; - lv_obj_t* cbEnabled; - lv_obj_t* cbDisabled; - bool priorMode; - }; - } - } -} diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index ba80869..d2475f8 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -47,7 +47,7 @@ std::unique_ptr<Screen> Settings::CreateScreen2() { std::array<Screens::List::Applications, 4> applications {{ {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold}, {Symbols::check, "Firmware", Apps::FirmwareValidation}, - {Symbols::airplane, "Airplane mode", Apps::SettingAirplaneMode}, + {Symbols::none, "None", Apps::None}, {Symbols::none, "None", Apps::None} }}; diff --git a/src/systemtask/Messages.h b/src/systemtask/Messages.h index 10b17ba..20af7d3 100644 --- a/src/systemtask/Messages.h +++ b/src/systemtask/Messages.h @@ -28,8 +28,7 @@ namespace Pinetime { MeasureBatteryTimerExpired, BatteryPercentageUpdated, StartFileTransfer, - StopFileTransfer, - BleRadioEnableToggle + StopFileTransfer }; } } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 8d5a133..a81950d 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -248,7 +248,7 @@ void SystemTask::Work() { displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToRunning); heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp); - if (bleController.IsRadioEnabled() && !bleController.IsConnected()) { + if (!bleController.IsConnected()) { nimbleController.RestartFastAdv(); } @@ -406,13 +406,6 @@ void SystemTask::Work() { case Messages::BatteryPercentageUpdated: nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining()); break; - case Messages::BleRadioEnableToggle: - if(settingsController.GetBleRadioEnabled()) { - nimbleController.EnableRadio(); - } else { - nimbleController.DisableRadio(); - } - break; default: break; } |
