M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 11,6 11,7 @@
* Added greetings in all languages
* Added fade in and fade out to relaxation songs
* Added time sync endpoint to be used by Mudita Center
+* Added bedside lamp settings
### Changed / Improved
M image/system_a/data/lang/Deutsch.json => image/system_a/data/lang/Deutsch.json +5 -2
@@ 140,8 140,9 @@
"app_bell_settings_alarm_settings_sounds": "T\u00f6ne",
"app_bell_settings_alarm_settings_title": "Alarmeinstellungen",
"app_bell_settings_alarm_settings_volume": "Alarmlautst\u00e4rke",
- "app_bell_settings_relaxation_fade": "Entspannung",
- "app_bell_settings_relaxation_fade_message": "Erh\u00f6ht allm\u00e4hlich Erholungslautst\u00e4rke",
+ "app_bell_settings_bedside_lamp": "Nachttischlampe",
+ "app_bell_settings_bedside_lamp_intensity": "Nachttischlampenst\u00e4rke",
+ "app_bell_settings_bedside_lamp_time": "Nachttischlampenzeit",
"app_bell_settings_bedtime_chime": "Schlafenszeit",
"app_bell_settings_bedtime_settings_tone": "Schlafenszeitton",
"app_bell_settings_bedtime_settings_volume": "Schlafenszeit Lautst\u00e4rke",
@@ 156,6 157,8 @@
"app_bell_settings_frontlight_top_message": "Lichtst\u00e4rke des Frontlichts",
"app_bell_settings_language": "Sprache",
"app_bell_settings_layout": "Zifferblatt",
+ "app_bell_settings_relaxation_fade": "Entspannung",
+ "app_bell_settings_relaxation_fade_message": "Erh\u00f6ht allm\u00e4hlich Erholungslautst\u00e4rke",
"app_bell_settings_shortcuts": "Verkn\u00fcpfungen",
"app_bell_settings_temp_scale": "Temperaturskala",
"app_bell_settings_time_units": "Zeit",
M image/system_a/data/lang/English.json => image/system_a/data/lang/English.json +5 -2
@@ 142,8 142,9 @@
"app_bell_settings_alarm_settings_sounds": "Sounds",
"app_bell_settings_alarm_settings_title": "Alarm settings",
"app_bell_settings_alarm_settings_volume": "Main alarm volume",
- "app_bell_settings_relaxation_fade": "Relaxation",
- "app_bell_settings_relaxation_fade_message": "Gradually raise the relaxation volume",
+ "app_bell_settings_bedside_lamp": "Bedside lamp",
+ "app_bell_settings_bedside_lamp_intensity": "Bedside lamp intensity",
+ "app_bell_settings_bedside_lamp_time": "Bedside lamp time",
"app_bell_settings_bedtime_chime": "Bedtime",
"app_bell_settings_bedtime_settings_tone": "Bedtime chime",
"app_bell_settings_bedtime_settings_volume": "Bedtime volume",
@@ 158,6 159,8 @@
"app_bell_settings_frontlight_top_message": "Frontlight intensity",
"app_bell_settings_language": "Language",
"app_bell_settings_layout": "Clock face",
+ "app_bell_settings_relaxation_fade": "Relaxation",
+ "app_bell_settings_relaxation_fade_message": "Gradually raise the relaxation volume",
"app_bell_settings_shortcuts": "Shortcuts",
"app_bell_settings_temp_scale": "Temperature scale",
"app_bell_settings_time_units": "Time",
M image/system_a/data/lang/Espanol.json => image/system_a/data/lang/Espanol.json +5 -2
@@ 139,8 139,9 @@
"app_bell_settings_alarm_settings_sounds": "Sonidos",
"app_bell_settings_alarm_settings_title": "Ajustes de alarma",
"app_bell_settings_alarm_settings_volume": "Volumen de alarma",
- "app_bell_settings_relaxation_fade": "Relajaci\u00f3n",
- "app_bell_settings_relaxation_fade_message": "Aumentar la relajaci\u00f3n gradualmente",
+ "app_bell_settings_bedside_lamp": "L\u00e1mpara de mesa",
+ "app_bell_settings_bedside_lamp_intensity": "Intensidad de luz",
+ "app_bell_settings_bedside_lamp_time": "Tiempo de l\u00e1mpara",
"app_bell_settings_bedtime_chime": "Hora de dormir",
"app_bell_settings_bedtime_settings_tone": "Alarma de dormir",
"app_bell_settings_bedtime_settings_volume": "Volumen para la hora de dormir",
@@ 155,6 156,8 @@
"app_bell_settings_frontlight_top_message": "Intensidad de luz frontal",
"app_bell_settings_language": "Idioma",
"app_bell_settings_layout": "Esfera del reloj",
+ "app_bell_settings_relaxation_fade": "Relajaci\u00f3n",
+ "app_bell_settings_relaxation_fade_message": "Aumentar la relajaci\u00f3n gradualmente",
"app_bell_settings_shortcuts": "Atajos",
"app_bell_settings_temp_scale": "Escala de temperatura",
"app_bell_settings_time_units": "Hora",
M image/system_a/data/lang/Francais.json => image/system_a/data/lang/Francais.json +5 -2
@@ 141,8 141,9 @@
"app_bell_settings_alarm_settings_sounds": "Sons",
"app_bell_settings_alarm_settings_title": "Alarme",
"app_bell_settings_alarm_settings_volume": "Volume",
- "app_bell_settings_relaxation_fade": "Bruits de fond",
- "app_bell_settings_relaxation_fade_message": "Hausse graduelle du vol. de d\u00e9tente",
+ "app_bell_settings_bedside_lamp": "Lampe de chevet",
+ "app_bell_settings_bedside_lamp_intensity": "Intensit\u00e9 de la lampe",
+ "app_bell_settings_bedside_lamp_time": "Heure de la lampe",
"app_bell_settings_bedtime_chime": "Heure du coucher",
"app_bell_settings_bedtime_settings_tone": "Son pr\u00e9-sommeil",
"app_bell_settings_bedtime_settings_volume": "Volume de l'heure du coucher",
@@ 157,6 158,8 @@
"app_bell_settings_frontlight_top_message": "Intensit\u00e9",
"app_bell_settings_language": "Langue",
"app_bell_settings_layout": "Cadran",
+ "app_bell_settings_relaxation_fade": "Bruits de fond",
+ "app_bell_settings_relaxation_fade_message": "Hausse graduelle du vol. de d\u00e9tente",
"app_bell_settings_shortcuts": "Raccourcis",
"app_bell_settings_temp_scale": "\u00c9chelle de temp\u00e9rature",
"app_bell_settings_time_units": "Temps",
M image/system_a/data/lang/Polski.json => image/system_a/data/lang/Polski.json +5 -2
@@ 140,8 140,9 @@
"app_bell_settings_alarm_settings_sounds": "D\u017awi\u0119ki",
"app_bell_settings_alarm_settings_title": "Ustawienia alarmu",
"app_bell_settings_alarm_settings_volume": "G\u0142o\u015bno\u015b\u0107 alarmu",
- "app_bell_settings_relaxation_fade": "Relaks",
- "app_bell_settings_relaxation_fade_message": "Powoli podno\u015b g\u0142o\u015bno\u015b\u0107 relaksacji",
+ "app_bell_settings_bedside_lamp": "Lampka nocna",
+ "app_bell_settings_bedside_lamp_intensity": "Intensywno\u015b\u0107 lampki",
+ "app_bell_settings_bedside_lamp_time": "Czas \u015bwiecenia lampki",
"app_bell_settings_bedtime_chime": "Pora snu",
"app_bell_settings_bedtime_settings_tone": "D\u017awi\u0119k pory snu",
"app_bell_settings_bedtime_settings_volume": "G\u0142o\u015bno\u015b\u0107 pory snu",
@@ 156,6 157,8 @@
"app_bell_settings_frontlight_top_message": "Intensywno\u015b\u0107 pod\u015bwietlenia",
"app_bell_settings_language": "J\u0119zyk",
"app_bell_settings_layout": "Tarcza zegara",
+ "app_bell_settings_relaxation_fade": "Relaks",
+ "app_bell_settings_relaxation_fade_message": "Powoli podno\u015b g\u0142o\u015bno\u015b\u0107 relaksacji",
"app_bell_settings_shortcuts": "Skr\u00f3ty",
"app_bell_settings_temp_scale": "Skala temperatury",
"app_bell_settings_time_units": "Czas",
M module-services/service-db/agents/settings/Settings.cpp => module-services/service-db/agents/settings/Settings.cpp +2 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <service-db/Settings.hpp>
@@ 112,9 112,9 @@ namespace settings
{
return SettingsCache::getInstance();
}
+
Settings::Settings(const service::ServiceProxy &interface)
{
init(interface);
}
-
} // namespace settings
M module-services/service-db/agents/settings/SystemSettings.hpp => module-services/service-db/agents/settings/SystemSettings.hpp +52 -48
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 7,89 7,93 @@ namespace settings
{
namespace SystemProperties
{
- constexpr inline auto activeSim = "gs_active_sim";
- constexpr inline auto lockPassHash = "gs_lock_pass_hash";
- constexpr inline auto lockScreenPasscodeIsOn = "gs_lock_screen_passcode_is_on";
- constexpr inline auto autoLockTimeInSec = "gs_auto_lock_time";
- constexpr inline auto unlockLockTime = "gs_unlock_lock_time";
- constexpr inline auto unlockAttemptLockTime = "gs_unlock_attempt_lock_time";
- constexpr inline auto noLockTimeAttemptsLeft = "gs_no_lock_time_attempts_left";
- constexpr inline auto displayLanguage = "gs_display_language";
- constexpr inline auto inputLanguage = "gs_input_language";
- constexpr inline auto automaticDateAndTimeIsOn = "gs_automatic_date_and_time_is_on";
- constexpr inline auto timeFormat = "gs_time_format";
- constexpr inline auto dateFormat = "gs_date_format";
- constexpr inline auto onboardingDone = "gs_onboarding_done";
- constexpr inline auto eulaAccepted = "gs_eula_accepted";
- constexpr inline auto osCurrentVersion = "gs_os_current_version";
- constexpr inline auto osUpdateVersion = "gs_os_update_version";
- constexpr inline auto currentTimezoneName = "gs_current_timezone_name";
- constexpr inline auto currentTimezoneRules = "gs_current_timezone_rules";
+ inline constexpr auto activeSim = "gs_active_sim";
+ inline constexpr auto lockPassHash = "gs_lock_pass_hash";
+ inline constexpr auto lockScreenPasscodeIsOn = "gs_lock_screen_passcode_is_on";
+ inline constexpr auto autoLockTimeInSec = "gs_auto_lock_time";
+ inline constexpr auto unlockLockTime = "gs_unlock_lock_time";
+ inline constexpr auto unlockAttemptLockTime = "gs_unlock_attempt_lock_time";
+ inline constexpr auto noLockTimeAttemptsLeft = "gs_no_lock_time_attempts_left";
+ inline constexpr auto displayLanguage = "gs_display_language";
+ inline constexpr auto inputLanguage = "gs_input_language";
+ inline constexpr auto automaticDateAndTimeIsOn = "gs_automatic_date_and_time_is_on";
+ inline constexpr auto timeFormat = "gs_time_format";
+ inline constexpr auto dateFormat = "gs_date_format";
+ inline constexpr auto onboardingDone = "gs_onboarding_done";
+ inline constexpr auto eulaAccepted = "gs_eula_accepted";
+ inline constexpr auto osCurrentVersion = "gs_os_current_version";
+ inline constexpr auto osUpdateVersion = "gs_os_update_version";
+ inline constexpr auto currentTimezoneName = "gs_current_timezone_name";
+ inline constexpr auto currentTimezoneRules = "gs_current_timezone_rules";
} // namespace SystemProperties
+
namespace Bluetooth
{
- constexpr inline auto state = "bt_state";
- constexpr inline auto deviceVisibility = "bt_device_visibility";
- constexpr inline auto deviceName = "bt_device_name";
- constexpr inline auto bondedDevices = "bt_bonded_devices";
- constexpr inline auto btKeys = "bt_keys";
- constexpr inline auto connectedDevice = "connected_device";
+ inline constexpr auto state = "bt_state";
+ inline constexpr auto deviceVisibility = "bt_device_visibility";
+ inline constexpr auto deviceName = "bt_device_name";
+ inline constexpr auto bondedDevices = "bt_bonded_devices";
+ inline constexpr auto btKeys = "bt_keys";
+ inline constexpr auto connectedDevice = "connected_device";
} // namespace Bluetooth
+
namespace Brightness
{
- constexpr inline auto state = "br_state";
- constexpr inline auto brightnessLevel = "br_level";
- constexpr inline auto gammaFactor = "br_gamma_Factor";
- constexpr inline auto autoMode = "br_auto_mode";
+ inline constexpr auto state = "br_state";
+ inline constexpr auto brightnessLevel = "br_level";
+ inline constexpr auto bedsideBrightnessLevel = "br_bedside_level";
+ inline constexpr auto bedsideTime = "br_bedside_time";
+ inline constexpr auto gammaFactor = "br_gamma_Factor";
+ inline constexpr auto autoMode = "br_auto_mode";
} // namespace Brightness
namespace Cellular
{
- constexpr inline auto apn_list = "cl_apn_list";
- constexpr inline auto offlineMode = "cl_offline_mode";
- constexpr inline auto currentUID = "cl_current_uid";
- constexpr inline auto volteEnabled = "cl_volte_enabled";
+ inline constexpr auto apn_list = "cl_apn_list";
+ inline constexpr auto offlineMode = "cl_offline_mode";
+ inline constexpr auto currentUID = "cl_current_uid";
+ inline constexpr auto volteEnabled = "cl_volte_enabled";
} // namespace Cellular
namespace Battery
{
- constexpr inline auto batteryCriticalLevel = "battery_critical_level";
+ inline constexpr auto batteryCriticalLevel = "battery_critical_level";
} // namespace Battery
namespace Offline
{
- constexpr inline auto connectionFrequency = "msg_only_mode_connection_frequency";
- constexpr inline auto notificationsWhenLocked = "off_notifications_when_locked";
- constexpr inline auto callsFromFavorites = "off_calls_from_favorites";
+ inline constexpr auto connectionFrequency = "msg_only_mode_connection_frequency";
+ inline constexpr auto notificationsWhenLocked = "off_notifications_when_locked";
+ inline constexpr auto callsFromFavorites = "off_calls_from_favorites";
} // namespace Offline
namespace KeypadLight
{
- constexpr inline auto state = "keypad_light_state";
+ inline constexpr auto state = "keypad_light_state";
} // namespace KeypadLight
namespace Wallpaper
{
- constexpr inline auto option = "wallpaper_option";
+ inline constexpr auto option = "wallpaper_option";
} // namespace Wallpaper
namespace Quotes
{
- constexpr inline auto randomQuotesList = "quotes_random_list";
- constexpr inline auto randomQuoteIDUpdateTime = "quotes_random_id_update_time";
+ inline constexpr auto randomQuotesList = "quotes_random_list";
+ inline constexpr auto randomQuoteIDUpdateTime = "quotes_random_id_update_time";
} // namespace Quotes
namespace Display
{
- constexpr inline auto invertedMode = "display_inverted_mode";
- constexpr inline auto lockScreenDeepRefreshRate = "display_lock_screen_deep_refresh_rate";
+ inline constexpr auto invertedMode = "display_inverted_mode";
+ inline constexpr auto lockScreenDeepRefreshRate = "display_lock_screen_deep_refresh_rate";
} // namespace Display
namespace Meditation
{
- constexpr inline auto duration = "meditation_duration";
- constexpr inline auto intervalChime = "meditation_interval_chime";
- constexpr inline auto preparationTime = "meditation_preparation_time";
- constexpr inline auto showCounter = "meditation_show_counter";
+ inline constexpr auto duration = "meditation_duration";
+ inline constexpr auto intervalChime = "meditation_interval_chime";
+ inline constexpr auto preparationTime = "meditation_preparation_time";
+ inline constexpr auto showCounter = "meditation_show_counter";
} // namespace Meditation
-}; // namespace settings
+} // namespace settings
M module-services/service-evtmgr/backlight-handler/BacklightHandlerCommon.cpp => module-services/service-evtmgr/backlight-handler/BacklightHandlerCommon.cpp +3 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "backlight-handler/BacklightHandlerCommon.hpp"
@@ 29,12 29,12 @@ namespace backlight
auto HandlerCommon::getValue(const std::string &path) const -> std::string
{
- return settings->getValue(path);
+ return settings->getValue(path, settings::SettingsScope::Global);
}
void HandlerCommon::setValue(const std::string &path, const std::string &value)
{
- settings->setValue(path, value);
+ settings->setValue(path, value, settings::SettingsScope::Global);
}
void HandlerCommon::startScreenLightTimer()
M module-services/service-evtmgr/screen-light-control/ScreenLightControl.hpp => module-services/service-evtmgr/screen-light-control/ScreenLightControl.hpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 6,6 6,7 @@
#include "ScreenLightControlParameters.hpp"
#include <memory>
#include <Timers/TimerHandle.hpp>
+
namespace settings
{
class Settings;
M products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp => products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp +17 -0
@@ 8,6 8,7 @@
#include "models/AboutYourBellModel.hpp"
#include "models/AudioErrorModel.hpp"
#include "models/RelaxationListItemProvider.hpp"
+#include "models/BedsideListItemProvider.hpp"
#include "models/alarm_settings/AlarmSettingsListItemProvider.hpp"
#include "models/alarm_settings/PrewakeUpListItemProvider.hpp"
#include "models/alarm_settings/BedtimeSettingsListItemProvider.hpp"
@@ 21,6 22,7 @@
#include "presenter/FrontlightPresenter.hpp"
#include "presenter/ShortcutsWindowPresenter.hpp"
#include "presenter/UpdateInstructionWindowPresenter.hpp"
+#include "presenter/BedsidePresenter.hpp"
#include "windows/AboutYourBellWindow.hpp"
#include "windows/BellSettingsLanguageWindow.hpp"
#include "windows/BellSettingsLayoutWindow.hpp"
@@ 35,11 37,13 @@
#include "windows/BellSettingsHomeViewWindow.hpp"
#include "windows/BellSettingsTimeUnitsWindow.hpp"
#include "windows/BellSettingsWindow.hpp"
+#include "windows/BellSettingsBedsideWindow.hpp"
#include <Paths.hpp>
#include <apps-common/windows/Dialog.hpp>
#include <common/BellPowerOffPresenter.hpp>
#include <common/models/BedtimeModel.hpp>
+#include <common/models/BedsideModel.hpp>
#include <common/models/LayoutModel.hpp>
#include <common/models/RelaxationFadeModel.hpp>
#include <common/windows/BellFinishedWindow.hpp>
@@ 126,6 130,19 @@ namespace app
return std::make_unique<gui::BellSettingsFrontlightWindow>(app, std::move(presenter));
});
+ windowsFactory.attach(
+ gui::BellSettingsBedsideWindow::name, [](ApplicationCommon *app, const std::string &name) {
+ auto frontlightModel = std::make_unique<bell_settings::FrontlightModel>(app);
+ auto brightnessModel = std::make_unique<bell_settings::BedsideBrightnessModel>(app);
+ auto timeModel = std::make_unique<bell_settings::BedsideTimeModel>(app);
+ auto bedsideModel =
+ std::make_unique<bell_settings::BedsideModel>(std::move(brightnessModel), std::move(timeModel));
+ auto provider = std::make_shared<bell_settings::BedsideListItemProvider>(std::move(bedsideModel),
+ std::move(frontlightModel));
+ auto presenter = std::make_unique<bell_settings::BedsidePresenter>(std::move(provider));
+ return std::make_unique<gui::BellSettingsBedsideWindow>(app, std::move(presenter));
+ });
+
windowsFactory.attach(gui::window::bell_finished::defaultName,
[](ApplicationCommon *app, const std::string &name) {
return std::make_unique<gui::BellFinishedWindow>(app, name);
M products/BellHybrid/apps/application-bell-settings/CMakeLists.txt => products/BellHybrid/apps/application-bell-settings/CMakeLists.txt +9 -2
@@ 1,4 1,4 @@
-# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+# Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
add_library(application-bell-settings STATIC)
@@ 27,7 27,10 @@ target_sources(application-bell-settings
models/AboutYourBellModel.cpp
models/FrontlightListItemProvider.cpp
models/FrontlightModel.cpp
+ models/BedsideListItemProvider.cpp
+ models/BedsideModel.cpp
models/AudioErrorModel.cpp
+ models/LayoutModel.cpp
models/RelaxationListItemProvider.cpp
models/alarm_settings/AlarmSettingsListItemProvider.cpp
models/alarm_settings/AlarmSettingsModel.cpp
@@ 37,11 40,11 @@ target_sources(application-bell-settings
models/alarm_settings/SnoozeListItemProvider.cpp
models/alarm_settings/SnoozeSettingsModel.cpp
models/alarm_settings/SettingsListItemProvider.cpp
- models/LayoutModel.cpp
presenter/BedtimeSettingsPresenter.cpp
presenter/TimeUnitsPresenter.cpp
presenter/FrontlightPresenter.cpp
+ presenter/BedsidePresenter.cpp
presenter/AboutYourBellWindowPresenter.cpp
presenter/LanguageWindowPresenter.cpp
presenter/LayoutWindowPresenter.cpp
@@ 70,6 73,7 @@ target_sources(application-bell-settings
windows/BellSettingsFrontlightWindow.cpp
windows/BellSettingsFactoryResetWindow.cpp
windows/BellSettingsRelaxationWindow.cpp
+ windows/BellSettingsBedsideWindow.cpp
windows/alarm_settings/BellSettingsAlarmSettingsSnoozeWindow.cpp
windows/alarm_settings/BellSettingsAlarmSettingsMenuWindow.cpp
windows/alarm_settings/BellSettingsAlarmSettingsWindow.cpp
@@ 77,6 81,7 @@ target_sources(application-bell-settings
models/AboutYourBellModel.hpp
models/FrontlightListItemProvider.hpp
+ models/BedsideListItemProvider.hpp
models/alarm_settings/AbstractPrewakeUpSettingsModel.hpp
models/alarm_settings/AbstractSnoozeSettingsModel.hpp
models/alarm_settings/AbstractAlarmSettingsModel.hpp
@@ 91,6 96,7 @@ target_sources(application-bell-settings
presenter/BedtimeSettingsPresenter.hpp
presenter/FrontlightPresenter.hpp
+ presenter/BedsidePresenter.hpp
presenter/AboutYourBellWindowPresenter.hpp
presenter/LanguageWindowPresenter.hpp
presenter/LayoutWindowPresenter.hpp
@@ 116,6 122,7 @@ target_sources(application-bell-settings
windows/BellSettingsLanguageWindow.hpp
windows/BellSettingsLayoutWindow.hpp
windows/BellSettingsFrontlightWindow.hpp
+ windows/BellSettingsBedsideWindow.hpp
windows/alarm_settings/BellSettingsAlarmSettingsSnoozeWindow.hpp
windows/alarm_settings/BellSettingsAlarmSettingsMenuWindow.hpp
windows/alarm_settings/BellSettingsAlarmSettingsWindow.hpp
A products/BellHybrid/apps/application-bell-settings/models/BedsideListItemProvider.cpp => products/BellHybrid/apps/application-bell-settings/models/BedsideListItemProvider.cpp +98 -0
@@ 0,0 1,98 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "BedsideListItemProvider.hpp"
+#include <common/models/BedsideModel.hpp>
+#include <common/models/FrontlightModel.hpp>
+#include <gui/widgets/ListViewEngine.hpp>
+#include <common/widgets/list_items/Numeric.hpp>
+#include <LanguageUtils.hpp>
+#include <i18n/i18n.hpp>
+
+namespace app::bell_settings
+{
+ using namespace gui;
+
+ BedsideListItemProvider::BedsideListItemProvider(std::unique_ptr<AbstractBedsideModel> &&bedsideModel,
+ std::unique_ptr<AbstractFrontlightModel> &&frontlightModel)
+ : bedsideModel{std::move(bedsideModel)}, frontlightModel{std::move(frontlightModel)}
+ {
+ buildListItems();
+ }
+
+ auto BedsideListItemProvider::getListItems() -> std::vector<BellSideListItemWithCallbacks *>
+ {
+ return internalData;
+ }
+
+ auto BedsideListItemProvider::requestRecords(std::uint32_t offset, std::uint32_t limit) -> void
+ {
+ setupModel(offset, limit);
+ list->onProviderDataUpdate();
+ }
+
+ auto BedsideListItemProvider::getItem(Order order) -> ListItem *
+ {
+ return getRecord(order);
+ }
+
+ auto BedsideListItemProvider::requestRecordsCount() -> unsigned
+ {
+ return internalData.size();
+ }
+
+ auto BedsideListItemProvider::getMinimalItemSpaceRequired() const -> unsigned
+ {
+ return style::sidelistview::list_item::w;
+ }
+
+ auto BedsideListItemProvider::buildListItems() -> void
+ {
+ constexpr auto itemCount = 2U;
+ internalData.reserve(itemCount);
+
+ constexpr auto bedsideTimeStep = 1U;
+ constexpr auto bedsideTimeMin = 1U;
+ constexpr auto bedsideTimeMax = 60U;
+ auto bedsideTimeSpinner = new list_items::Numeric(
+ list_items::Numeric::spinner_type::range{bedsideTimeMin, bedsideTimeMax, bedsideTimeStep},
+ bedsideModel->getTimeModel(),
+ utils::translate("app_bell_settings_bedside_lamp_time"),
+ utils::language::getCorrectMinutesNumeralForm(bedsideModel->getTimeModel().getValue()));
+ bedsideTimeSpinner->set_on_value_change_cb([bedsideTimeSpinner](const auto &val) {
+ bedsideTimeSpinner->setBottomDescriptionText(utils::language::getCorrectMinutesNumeralForm(val));
+ });
+ internalData.emplace_back(bedsideTimeSpinner);
+
+ constexpr auto bedsideBrightnessStep = 1U;
+ constexpr auto bedsideBrightnessMin = 1U;
+ constexpr auto bedsideBrightnessMax = 10U;
+ auto bedsideBrightnessSpinner = new list_items::Numeric(
+ list_items::Numeric::spinner_type::range{bedsideBrightnessMin, bedsideBrightnessMax, bedsideBrightnessStep},
+ bedsideModel->getBrightnessModel(),
+ utils::translate("app_bell_settings_bedside_lamp_intensity"));
+ bedsideBrightnessSpinner->set_on_value_change_cb([this](const auto &val) {
+ this->frontlightModel->setBacklight(BacklightState::On);
+ this->frontlightModel->setBrightness(val);
+ });
+ bedsideBrightnessSpinner->onEnter = [this, bedsideBrightnessSpinner]() {
+ this->frontlightModel->setBacklight(BacklightState::On);
+ this->frontlightModel->setBrightness(bedsideBrightnessSpinner->value());
+ };
+ bedsideBrightnessSpinner->onExit = [this]() {
+ this->frontlightModel->revertConfig();
+ this->frontlightModel->setBacklight(BacklightState::On);
+ };
+ internalData.emplace_back(bedsideBrightnessSpinner);
+
+ for (auto item : internalData) {
+ item->deleteByList = false;
+ }
+ }
+
+ auto BedsideListItemProvider::clearData() -> void
+ {
+ list->reset();
+ eraseInternalData();
+ }
+} // namespace app::bell_settings
A products/BellHybrid/apps/application-bell-settings/models/BedsideListItemProvider.hpp => products/BellHybrid/apps/application-bell-settings/models/BedsideListItemProvider.hpp +34 -0
@@ 0,0 1,34 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <common/widgets/BellSideListItemWithCallbacks.hpp>
+#include <apps-common/InternalModel.hpp>
+
+namespace app::bell_settings
+{
+ class AbstractFrontlightModel;
+ class AbstractBedsideModel;
+
+ class BedsideListItemProvider : public app::InternalModel<gui::BellSideListItemWithCallbacks *>,
+ public gui::ListItemProvider
+ {
+ public:
+ BedsideListItemProvider(std::unique_ptr<AbstractBedsideModel> &&bedsideModel,
+ std::unique_ptr<AbstractFrontlightModel> &&frontlightModel);
+
+ auto getListItems() -> std::vector<gui::BellSideListItemWithCallbacks *>;
+ auto requestRecords(std::uint32_t offset, std::uint32_t limit) -> void override;
+ [[nodiscard]] auto getItem(gui::Order order) -> gui::ListItem * override;
+ [[nodiscard]] auto requestRecordsCount() -> unsigned override;
+ [[nodiscard]] auto getMinimalItemSpaceRequired() const -> unsigned override;
+ auto clearData() -> void;
+
+ private:
+ auto buildListItems() -> void;
+
+ std::unique_ptr<AbstractBedsideModel> bedsideModel;
+ std::unique_ptr<AbstractFrontlightModel> frontlightModel;
+ };
+} // namespace app::bell_settings
A products/BellHybrid/apps/application-bell-settings/models/BedsideModel.cpp => products/BellHybrid/apps/application-bell-settings/models/BedsideModel.cpp +34 -0
@@ 0,0 1,34 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <common/models/BedsideModel.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
+#include <Utils.hpp>
+
+namespace app::bell_settings
+{
+ auto BedsideBrightnessModel::setValue(frontlight_utils::Brightness value) -> void
+ {
+ const auto str = std::to_string(frontlight_utils::fixedValToPercentage(value));
+ settings.setValue(settings::Brightness::bedsideBrightnessLevel, str, settings::SettingsScope::Global);
+ }
+
+ auto BedsideBrightnessModel::getValue() const -> frontlight_utils::Brightness
+ {
+ const auto str =
+ settings.getValue(settings::Brightness::bedsideBrightnessLevel, settings::SettingsScope::Global);
+ return frontlight_utils::percentageToFixedVal(static_cast<float>(utils::toNumeric(str)));
+ }
+
+ auto BedsideTimeModel::setValue(std::uint8_t value) -> void
+ {
+ const auto str = std::to_string(value);
+ settings.setValue(settings::Brightness::bedsideTime, str, settings::SettingsScope::Global);
+ }
+
+ auto BedsideTimeModel::getValue() const -> std::uint8_t
+ {
+ const auto str = settings.getValue(settings::Brightness::bedsideTime, settings::SettingsScope::Global);
+ return utils::toNumeric(str);
+ }
+} // namespace app::bell_settings
A products/BellHybrid/apps/application-bell-settings/presenter/BedsidePresenter.cpp => products/BellHybrid/apps/application-bell-settings/presenter/BedsidePresenter.cpp +39 -0
@@ 0,0 1,39 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "BedsidePresenter.hpp"
+#include "BedsideListItemProvider.hpp"
+
+namespace app::bell_settings
+{
+ BedsidePresenter::BedsidePresenter(std::shared_ptr<BedsideListItemProvider> &&provider)
+ : provider{std::move(provider)}
+ {}
+
+ auto BedsidePresenter::saveData() -> void
+ {
+ for (auto item : provider->getListItems()) {
+ item->getValue();
+ }
+ }
+
+ auto BedsidePresenter::loadData() -> void
+ {
+ for (auto item : provider->getListItems()) {
+ item->setValue();
+ }
+ }
+
+ auto BedsidePresenter::getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider>
+ {
+ return provider;
+ }
+
+ auto BedsidePresenter::eraseProviderData() -> void
+ {
+ provider->clearData();
+ }
+
+ auto BedsidePresenter::exitWithoutSave() -> void
+ {}
+} // namespace app::bell_settings
A products/BellHybrid/apps/application-bell-settings/presenter/BedsidePresenter.hpp => products/BellHybrid/apps/application-bell-settings/presenter/BedsidePresenter.hpp +55 -0
@@ 0,0 1,55 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <apps-common/BasePresenter.hpp>
+#include <common/models/BedsideModel.hpp>
+#include <ApplicationCommon.hpp>
+#include <memory>
+
+namespace gui
+{
+ class ListItemProvider;
+} // namespace gui
+
+namespace app::bell_settings
+{
+ class BedsideListItemProvider;
+
+ namespace BedsideWindowContract
+ {
+ class View
+ {
+ public:
+ virtual ~View() noexcept = default;
+ virtual auto exit() -> void = 0;
+ };
+
+ class Presenter : public BasePresenter<View>
+ {
+ public:
+ virtual ~Presenter() noexcept = default;
+
+ [[nodiscard]] virtual auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> = 0;
+ virtual auto saveData() -> void = 0;
+ virtual auto loadData() -> void = 0;
+ virtual auto eraseProviderData() -> void = 0;
+ virtual auto exitWithoutSave() -> void = 0;
+ };
+ } // namespace BedsideWindowContract
+
+ class BedsidePresenter : public BedsideWindowContract::Presenter
+ {
+ public:
+ BedsidePresenter(std::shared_ptr<BedsideListItemProvider> &&provider);
+ [[nodiscard]] auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> override;
+ auto saveData() -> void override;
+ auto loadData() -> void override;
+ auto eraseProviderData() -> void override;
+ auto exitWithoutSave() -> void override;
+
+ private:
+ std::shared_ptr<BedsideListItemProvider> provider;
+ };
+} // namespace app::bell_settings
M products/BellHybrid/apps/application-bell-settings/presenter/FrontlightPresenter.hpp => products/BellHybrid/apps/application-bell-settings/presenter/FrontlightPresenter.hpp +5 -5
@@ 1,5 1,5 @@
-// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 24,13 24,13 @@ namespace app::bell_settings
virtual ~View() noexcept = default;
virtual void exit() = 0;
};
- }; // namespace FrontlightWindowContract
+ } // namespace FrontlightWindowContract
class AbstractFrontlightPresenter : public BasePresenter<FrontlightWindowContract::View>
{
public:
virtual ~AbstractFrontlightPresenter() = default;
- virtual auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> = 0;
+ [[nodiscard]] virtual auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> = 0;
virtual void eraseProviderData() = 0;
virtual void saveConfig() = 0;
virtual void setBacklight() = 0;
@@ 43,9 43,9 @@ namespace app::bell_settings
public:
FrontlightPresenter(std::shared_ptr<FrontlightListItemProvider> &&provider,
std::unique_ptr<AbstractFrontlightModel> &&frontlightModel);
- ~FrontlightPresenter();
+ ~FrontlightPresenter() override;
- auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> override;
+ [[nodiscard]] auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> override;
void eraseProviderData() override;
void saveConfig() override;
void setBacklight() override;
A products/BellHybrid/apps/application-bell-settings/windows/BellSettingsBedsideWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsBedsideWindow.cpp +77 -0
@@ 0,0 1,77 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "BellSettingsBedsideWindow.hpp"
+#include "application-bell-settings/ApplicationBellSettings.hpp"
+#include <common/windows/BellFinishedWindow.hpp>
+#include <widgets/SideListView.hpp>
+
+namespace gui
+{
+ BellSettingsBedsideWindow::BellSettingsBedsideWindow(
+ app::ApplicationCommon *app, std::unique_ptr<app::bell_settings::BedsidePresenter> &&presenter)
+ : AppWindow(app, name), presenter{std::move(presenter)}
+ {
+ this->presenter->attach(this);
+ buildInterface();
+ }
+
+ auto BellSettingsBedsideWindow::buildInterface() -> void
+ {
+ AppWindow::buildInterface();
+ statusBar->setVisible(false);
+ header->setTitleVisibility(false);
+ navBar->setVisible(false);
+
+ listView =
+ new SideListView(this, 0U, 0U, getWidth(), getHeight(), presenter->getPagesProvider(), PageBarType::None);
+ listView->setEdges(RectangleEdge::None);
+
+ listView->rebuildList(listview::RebuildType::Full);
+
+ presenter->loadData();
+ }
+
+ auto BellSettingsBedsideWindow::onBeforeShow([[maybe_unused]] gui::ShowMode mode,
+ [[maybe_unused]] gui::SwitchData *data) -> void
+ {
+ setFocusItem(listView);
+ }
+
+ auto BellSettingsBedsideWindow::onInput(const InputEvent &inputEvent) -> bool
+ {
+ if (listView->onInput(inputEvent)) {
+ return true;
+ }
+ if (inputEvent.isShortRelease(KeyCode::KEY_ENTER)) {
+ exit();
+ return false;
+ }
+ if (inputEvent.isShortRelease(KeyCode::KEY_RF)) {
+ presenter->exitWithoutSave();
+ }
+
+ return AppWindow::onInput(inputEvent);
+ }
+
+ auto BellSettingsBedsideWindow::onClose(CloseReason reason) -> void
+ {
+ if (reason != CloseReason::Popup) {
+ presenter->eraseProviderData();
+ }
+ }
+
+ auto BellSettingsBedsideWindow::rebuild() -> void
+ {
+ erase();
+ buildInterface();
+ }
+
+ auto BellSettingsBedsideWindow::exit() -> void
+ {
+ presenter->saveData();
+ application->switchWindow(
+ window::bell_finished::defaultName,
+ BellFinishedWindowData::Factory::create("circle_success_big", window::name::bellSettings));
+ }
+} // namespace gui
A products/BellHybrid/apps/application-bell-settings/windows/BellSettingsBedsideWindow.hpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsBedsideWindow.hpp +32 -0
@@ 0,0 1,32 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "presenter/BedsidePresenter.hpp"
+#include <apps-common/windows/AppWindow.hpp>
+
+namespace gui
+{
+ class SideListView;
+
+ class BellSettingsBedsideWindow : public AppWindow, public app::bell_settings::BedsideWindowContract::View
+ {
+ public:
+ static constexpr auto name = "BellSettingsBedside";
+
+ BellSettingsBedsideWindow(app::ApplicationCommon *app,
+ std::unique_ptr<app::bell_settings::BedsidePresenter> &&presenter);
+
+ auto buildInterface() -> void override;
+ auto onBeforeShow(gui::ShowMode mode, gui::SwitchData *data) -> void override;
+ auto onInput(const InputEvent &inputEvent) -> bool override;
+ auto onClose(CloseReason reason) -> void override;
+ auto rebuild() -> void override;
+ auto exit() -> void override;
+
+ private:
+ SideListView *listView{nullptr};
+ std::unique_ptr<app::bell_settings::BedsidePresenter> presenter;
+ };
+} // namespace gui
M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlightWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlightWindow.cpp +2 -0
@@ 62,6 62,7 @@ namespace gui
return AppWindow::onInput(inputEvent);
}
+
void BellSettingsFrontlightWindow::exit()
{
presenter->saveConfig();
@@ 69,6 70,7 @@ namespace gui
window::bell_finished::defaultName,
BellFinishedWindowData::Factory::create("circle_success_big", window::name::bellSettings));
}
+
void BellSettingsFrontlightWindow::onClose(Window::CloseReason reason)
{
if (reason != CloseReason::Popup) {
M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlightWindow.hpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlightWindow.hpp +3 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 15,6 15,7 @@ namespace gui
{
public:
static constexpr auto name = "BellSettingsFrontlight";
+
explicit BellSettingsFrontlightWindow(
app::ApplicationCommon *app, std::unique_ptr<app::bell_settings::FrontlightPresenter> &&windowPresenter);
@@ 26,7 27,7 @@ namespace gui
void exit() override;
private:
- SideListView *listView{};
+ SideListView *listView{nullptr};
std::unique_ptr<app::bell_settings::FrontlightPresenter> presenter;
};
} /* namespace gui */
M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsWindow.cpp +3 -0
@@ 3,6 3,7 @@
#include "AboutYourBellWindow.hpp"
#include "BellSettingsFrontlightWindow.hpp"
+#include "BellSettingsBedsideWindow.hpp"
#include "BellSettingsFactoryResetWindow.hpp"
#include "BellSettingsWindow.hpp"
#include "alarm_settings/BellSettingsAlarmSettingsMenuWindow.hpp"
@@ 70,6 71,8 @@ namespace gui
addWinSettings(
utils::translate("app_bell_settings_frontlight"), gui::BellSettingsFrontlightWindow::name, defaultCallback);
addWinSettings(
+ utils::translate("app_bell_settings_bedside_lamp"), gui::BellSettingsBedsideWindow::name, defaultCallback);
+ addWinSettings(
utils::translate("app_bell_settings_shortcuts"), window::name::bellSettingsShortcuts, defaultCallback);
addWinSettings(utils::translate("app_bell_update_instruction_title"),
window::name::bellSettingsUpdateInstruction,
A products/BellHybrid/apps/common/include/common/models/BedsideModel.hpp => products/BellHybrid/apps/common/include/common/models/BedsideModel.hpp +64 -0
@@ 0,0 1,64 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <common/data/FrontlightUtils.hpp>
+#include <common/models/SettingsModel.hpp>
+#include <chrono>
+
+namespace app::bell_settings
+{
+ class AbstractBedsideModel
+ {
+ public:
+ AbstractBedsideModel(
+ std::unique_ptr<gui::AbstractSettingsModel<frontlight_utils::Brightness>> &&brightnessModel,
+ std::unique_ptr<gui::AbstractSettingsModel<std::uint8_t>> &&timeModel)
+ : brightnessModel{std::move(brightnessModel)}, timeModel{std::move(timeModel)}
+ {}
+
+ virtual ~AbstractBedsideModel() = default;
+
+ auto getBrightnessModel() -> gui::AbstractSettingsModel<frontlight_utils::Brightness> &
+ {
+ return *brightnessModel;
+ }
+
+ auto getTimeModel() -> gui::AbstractSettingsModel<std::uint8_t> &
+ {
+ return *timeModel;
+ }
+
+ private:
+ std::unique_ptr<gui::AbstractSettingsModel<frontlight_utils::Brightness>> brightnessModel;
+ std::unique_ptr<gui::AbstractSettingsModel<std::uint8_t>> timeModel;
+ };
+
+ class BedsideBrightnessModel : public gui::SettingsModel<frontlight_utils::Brightness>
+ {
+ public:
+ using SettingsModel::SettingsModel;
+
+ auto setValue(frontlight_utils::Brightness value) -> void override;
+ auto getValue() const -> frontlight_utils::Brightness override;
+ };
+
+ class BedsideTimeModel : public gui::SettingsModel<std::uint8_t>
+ {
+ public:
+ using SettingsModel::SettingsModel;
+
+ auto setValue(std::uint8_t value) -> void override;
+ auto getValue() const -> std::uint8_t override;
+ };
+
+ class BedsideModel : public AbstractBedsideModel
+ {
+ public:
+ BedsideModel(std::unique_ptr<BedsideBrightnessModel> &&brightnessModel,
+ std::unique_ptr<BedsideTimeModel> &&timeModel)
+ : AbstractBedsideModel{std::move(brightnessModel), std::move(timeModel)}
+ {}
+ };
+} // namespace app::bell_settings
M products/BellHybrid/apps/common/include/common/models/FrontlightModel.hpp => products/BellHybrid/apps/common/include/common/models/FrontlightModel.hpp +2 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 62,7 62,7 @@ namespace app::bell_settings
{
currentValue = val;
}
- void setValue(ValueT) override
+ void setValue([[maybe_unused]] ValueT value) override
{}
ValueT getValue() const override
{
A products/BellHybrid/services/db/databases/migration/settings_bell/current/90970372_Add_bedside_lamp_parameters/.meta => products/BellHybrid/services/db/databases/migration/settings_bell/current/90970372_Add_bedside_lamp_parameters/.meta +6 -0
@@ 0,0 1,6 @@
+{
+ "id": "90970372-6151-4de3-91dd-f1c8684bc6f4",
+ "date": "2024-08-08 13:56:09",
+ "message": "Add bedside lamp parameters",
+ "parent": 0
+}<
\ No newline at end of file
A products/BellHybrid/services/db/databases/migration/settings_bell/current/90970372_Add_bedside_lamp_parameters/devel.sql => products/BellHybrid/services/db/databases/migration/settings_bell/current/90970372_Add_bedside_lamp_parameters/devel.sql +6 -0
@@ 0,0 1,6 @@
+-- Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+-- For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+-- Message: Add bedside lamp parameters
+-- Revision: 90970372-6151-4de3-91dd-f1c8684bc6f4
+-- Create Date: 2024-08-08 13:56:09
A products/BellHybrid/services/db/databases/migration/settings_bell/current/90970372_Add_bedside_lamp_parameters/down.sql => products/BellHybrid/services/db/databases/migration/settings_bell/current/90970372_Add_bedside_lamp_parameters/down.sql +21 -0
@@ 0,0 1,21 @@
+-- Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+-- For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+-- Message: Add bedside lamp parameters
+-- Revision: 90970372-6151-4de3-91dd-f1c8684bc6f4
+-- Create Date: 2024-08-08 13:56:09
+
+DELETE FROM settings_tab WHERE path = 'br_bedside_level';
+DELETE FROM settings_tab WHERE path = 'br_bedside_time';
+
+UPDATE OR IGNORE settings_tab
+SET path = '\EventManager\\br_state'
+WHERE path = 'br_state';
+
+UPDATE OR IGNORE settings_tab
+SET path = '\EventManager\\br_auto_mode'
+WHERE path = 'br_auto_mode';
+
+UPDATE OR IGNORE settings_tab
+SET path = '\EventManager\\br_level'
+WHERE path = 'br_level';
A products/BellHybrid/services/db/databases/migration/settings_bell/current/90970372_Add_bedside_lamp_parameters/up.sql => products/BellHybrid/services/db/databases/migration/settings_bell/current/90970372_Add_bedside_lamp_parameters/up.sql +22 -0
@@ 0,0 1,22 @@
+-- Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+-- For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+-- Message: Add bedside lamp parameters
+-- Revision: 90970372-6151-4de3-91dd-f1c8684bc6f4
+-- Create Date: 2024-08-08 13:56:09
+
+UPDATE OR IGNORE settings_tab
+SET path = 'br_state'
+WHERE path = '\EventManager\\br_state';
+
+UPDATE OR IGNORE settings_tab
+SET path = 'br_auto_mode'
+WHERE path = '\EventManager\\br_auto_mode';
+
+UPDATE OR IGNORE settings_tab
+SET path = 'br_level'
+WHERE path = '\EventManager\\br_level';
+
+INSERT OR IGNORE INTO settings_tab (path, value) VALUES
+ ('br_bedside_level', '58.0f'),
+ ('br_bedside_time', '10');
M products/BellHybrid/services/evtmgr/backlight-handler/BacklightHandler.cpp => products/BellHybrid/services/evtmgr/backlight-handler/BacklightHandler.cpp +41 -21
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <evtmgr/backlight-handler/BacklightHandler.hpp>
@@ 17,7 17,6 @@ namespace backlight
{
constexpr auto screenLightTimerTimeout = std::chrono::seconds{5};
constexpr auto screenLightTimerHoldTimeout = std::chrono::seconds{10};
- constexpr auto screenLightBedsideLampTimeout = std::chrono::minutes{10};
} // namespace timers
Handler::Handler(std::shared_ptr<settings::Settings> settings, sys::Service *parent)
@@ 32,9 31,10 @@ namespace backlight
})
{}
- void Handler::init()
+ auto Handler::init() -> void
{
using namespace screen_light_control;
+
settings->registerValueChange(settings::Brightness::brightnessLevel, [&](const std::string &value) {
const ConstLinearProgressModeParameters params{utils::getNumericValue<float>(value)};
screenLightController->processRequest(Action::setAutomaticModeParameters, Parameters(params));
@@ 45,17 45,17 @@ namespace backlight
});
}
- void Handler::handleKeyPressed([[maybe_unused]] int key)
+ auto Handler::handleKeyPressed([[maybe_unused]] int key) -> void
{
if (!ignoreKeypress) {
handleScreenLightRefresh(key);
}
}
- void Handler::handleScreenLightRefresh([[maybe_unused]] int key)
+ auto Handler::handleScreenLightRefresh([[maybe_unused]] int key) -> void
{
- auto controller = getScreenLightControl();
- auto timer = getScreenLightTimer();
+ const auto controller = getScreenLightControl();
+ const auto timer = getScreenLightTimer();
if (key != static_cast<int>(KeyMap::Frontlight) && backlightType != Type::BedsideLamp) {
if (controller->isLightOn()) {
@@ 69,12 69,13 @@ namespace backlight
}
}
- void Handler::handleScreenLight(Type type)
+ auto Handler::handleScreenLight(Type type) -> void
{
const auto controller = getScreenLightControl();
const auto timer = getScreenLightTimer();
auto lightTime = std::chrono::seconds(0);
+ auto lightParams = screen_light_control::Parameters{};
switch (type) {
case Type::Frontlight:
@@ 86,26 87,27 @@ namespace backlight
}
break;
case Type::BedsideLamp:
- lightTime = timers::screenLightBedsideLampTimeout;
+ lightTime = getBedsideModeLightTime();
+ lightParams = getBedsideModeLightParams();
break;
}
if (controller->isLightOn() && type == Type::Frontlight) {
setKeyPressedModeFrontlightOff();
- controller->processRequest(screen_light_control::Action::turnOff);
+ controller->processRequest(screen_light_control::Action::turnOff, lightParams);
timer->stop();
}
else if (!controller->isLightOn()) {
setKeyPressedModeFrontlightOn();
- controller->processRequest(screen_light_control::Action::turnOn);
+ controller->processRequest(screen_light_control::Action::turnOn, lightParams);
timer->restart(lightTime);
}
backlightType = type;
}
- void Handler::processRequest(screen_light_control::Action action,
+ auto Handler::processRequest(screen_light_control::Action action,
const screen_light_control::Parameters ¶ms,
- screen_light_control::Sender sender)
+ screen_light_control::Sender sender) -> void
{
switch (sender) {
case screen_light_control::Sender::AlarmPrewakeup:
@@ 126,15 128,15 @@ namespace backlight
}
}
- void Handler::processScreenRequest(screen_light_control::Action action,
- const screen_light_control::Parameters ¶ms)
+ auto Handler::processScreenRequest(screen_light_control::Action action,
+ const screen_light_control::Parameters ¶ms) -> void
{
handleScreenLightSettings(action, params);
getScreenLightControl()->processRequest(action, params);
}
- void Handler::handleScreenLightSettings(screen_light_control::Action action,
- const screen_light_control::Parameters ¶ms)
+ auto Handler::handleScreenLightSettings(screen_light_control::Action action,
+ const screen_light_control::Parameters ¶ms) -> void
{
switch (action) {
case screen_light_control::Action::turnOn:
@@ 173,25 175,43 @@ namespace backlight
HandlerCommon::handleScreenLightSettings(action, params);
}
- void Handler::onScreenLightTurnedOn()
+ auto Handler::onScreenLightTurnedOn() -> void
{
if (backlightMode == BacklightMode::WithTimer && backlightType != Type::BedsideLamp) {
startScreenLightTimer();
}
}
- void Handler::setKeyPressedModeFrontlightOn()
+ auto Handler::setKeyPressedModeFrontlightOn() -> void
{
using namespace screen_light_control;
- auto brightnessLevel = utils::getNumericValue<float>(getValue(settings::Brightness::brightnessLevel));
+
+ const auto brightnessLevel = utils::getNumericValue<float>(getValue(settings::Brightness::brightnessLevel));
const ConstLinearProgressModeParameters params{brightnessLevel};
screenLightController->processRequest(Action::setAutomaticModeParameters, Parameters(params));
}
- void Handler::setKeyPressedModeFrontlightOff()
+ auto Handler::setKeyPressedModeFrontlightOff() -> void
{
using namespace screen_light_control;
+
screenLightController->processRequest(Action::setAutomaticModeParameters,
Parameters(screen_light_control::ConstLinearProgressModeParameters{0}));
}
+
+ auto Handler::getBedsideModeLightTime() const -> std::chrono::seconds
+ {
+ const auto bedsideTime = utils::toNumeric(getValue(settings::Brightness::bedsideTime));
+ return std::chrono::minutes{bedsideTime};
+ }
+
+ auto Handler::getBedsideModeLightParams() const -> screen_light_control::Parameters
+ {
+ using namespace screen_light_control;
+
+ const auto bedsideBrightness =
+ utils::getNumericValue<float>(getValue(settings::Brightness::bedsideBrightnessLevel));
+ const auto manualParams = ManualModeParameters{bedsideBrightness};
+ return Parameters{manualParams};
+ }
} // namespace backlight
M products/BellHybrid/services/evtmgr/include/evtmgr/backlight-handler/BacklightHandler.hpp => products/BellHybrid/services/evtmgr/include/evtmgr/backlight-handler/BacklightHandler.hpp +18 -14
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 27,35 27,39 @@ namespace backlight
WithTimer,
WithoutTimer
};
+
/// @brief Backlight events handler
class Handler : public HandlerCommon
{
public:
Handler(std::shared_ptr<settings::Settings> settings, sys::Service *parent);
- void handleKeyPressed(int key = 0);
+ auto handleKeyPressed(int key = 0) -> void;
- void handleScreenLight(Type type);
+ auto handleScreenLight(Type type) -> void;
- void processRequest(screen_light_control::Action action,
+ auto processRequest(screen_light_control::Action action,
const screen_light_control::Parameters ¶ms,
- screen_light_control::Sender sender);
+ screen_light_control::Sender sender) -> void;
- void init() override;
+ auto init() -> void override;
- void processScreenRequest(screen_light_control::Action action,
- const screen_light_control::Parameters ¶ms) override;
+ auto processScreenRequest(screen_light_control::Action action, const screen_light_control::Parameters ¶ms)
+ -> void override;
- void handleScreenLightSettings(screen_light_control::Action action,
- const screen_light_control::Parameters ¶ms) override;
+ auto handleScreenLightSettings(screen_light_control::Action action,
+ const screen_light_control::Parameters ¶ms) -> void override;
private:
- void handleScreenLightRefresh(int key = 0);
+ auto handleScreenLightRefresh(int key = 0) -> void;
+
+ auto onScreenLightTurnedOn() -> void override;
- void onScreenLightTurnedOn() override;
+ auto setKeyPressedModeFrontlightOn() -> void;
+ auto setKeyPressedModeFrontlightOff() -> void;
- void setKeyPressedModeFrontlightOn();
- void setKeyPressedModeFrontlightOff();
+ [[nodiscard]] auto getBedsideModeLightTime() const -> std::chrono::seconds;
+ [[nodiscard]] auto getBedsideModeLightParams() const -> screen_light_control::Parameters;
bool ignoreKeypress = false;
bool onDemandModeOn = true;