M module-services/service-evtmgr/CMakeLists.txt => module-services/service-evtmgr/CMakeLists.txt +1 -1
@@ 5,10 5,10 @@ set(SOURCES
WorkerEventCommon.cpp
api/EventManagerServiceAPI.cpp
api/torch.cpp
+ backlight-handler/BacklightHandlerCommon.cpp
battery/BatteryController.cpp
battery/BatteryController.hpp
battery-level-check/BatteryLevelCheck.cpp
- backlight-handler/BacklightHandler.cpp
battery-brownout-detector/BatteryBrownoutDetector.cpp
screen-light-control/ControlFunctions.cpp
screen-light-control/ScreenLightControlParameters.cpp
A module-services/service-evtmgr/backlight-handler/BacklightHandlerCommon.cpp => module-services/service-evtmgr/backlight-handler/BacklightHandlerCommon.cpp +137 -0
@@ 0,0 1,137 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "backlight-handler/BacklightHandlerCommon.hpp"
+#include <service-db/agents/settings/SystemSettings.hpp>
+#include <service-db/Settings.hpp>
+#include <Timers/TimerFactory.hpp>
+#include <Utils.hpp>
+
+namespace backlight
+{
+ namespace timers
+ {
+ constexpr auto screenLightTimerName = "ScreenLightTimer";
+ constexpr auto screenLightTimerTimeout = std::chrono::seconds(5);
+ } // namespace timers
+
+ HandlerCommon::HandlerCommon(std::shared_ptr<settings::Settings> settings, sys::Service *parent)
+ : settings{std::move(settings)}, screenLightControl{std::make_shared<screen_light_control::ScreenLightControl>(
+ parent)},
+ screenLightTimer{std::make_shared<sys::TimerHandle>(sys::TimerFactory::createSingleShotTimer(
+ parent, timers::screenLightTimerName, timers::screenLightTimerTimeout, [this](sys::Timer &t) {
+ if (getScreenAutoModeState() == screen_light_control::ScreenLightMode::Automatic &&
+ screenLightControl->isLightOn()) {
+ screenLightControl->processRequest(screen_light_control::Action::turnOff);
+ }
+ }))}
+
+ {}
+
+ void HandlerCommon::init()
+ {
+ using namespace screen_light_control;
+ settings->registerValueChange(settings::Brightness::brightnessLevel, [&](const std::string &value) {
+ ManualModeParameters params{utils::getNumericValue<float>(value)};
+ screenLightControl->processRequest(Action::setManualModeBrightness, Parameters(params));
+ });
+
+ settings->registerValueChange(settings::Brightness::autoMode, [&]([[maybe_unused]] const std::string &value) {
+ const auto action = getScreenAutoModeState() == ScreenLightMode::Automatic ? Action::enableAutomaticMode
+ : Action::disableAutomaticMode;
+ screenLightControl->processRequest(action);
+ });
+
+ settings->registerValueChange(settings::Brightness::state, [&]([[maybe_unused]] const std::string &value) {
+ const auto action = getScreenLightState() ? Action::turnOn : Action::turnOff;
+ if (action == Action::turnOn) {
+ screenLightTimer->start();
+ }
+ screenLightControl->processRequest(action);
+ });
+ }
+
+ void HandlerCommon::processScreenRequest(screen_light_control::Action action,
+ const screen_light_control::Parameters ¶ms)
+ {
+ if (action == screen_light_control::Action::enableAutomaticMode) {
+ startScreenLightTimer();
+ }
+ handleScreenLightSettings(action, params);
+ screenLightControl->processRequest(action, params);
+ }
+
+ auto HandlerCommon::getValue(const std::string &path) const -> std::string
+ {
+ return settings->getValue(path);
+ }
+
+ void HandlerCommon::setValue(const std::string &path, const std::string &value)
+ {
+ settings->setValue(path, value);
+ }
+
+ void HandlerCommon::startScreenLightTimer()
+ {
+ screenLightTimer->start();
+ }
+
+ auto HandlerCommon::getScreenLightState() const noexcept -> bool
+ {
+ return utils::getNumericValue<bool>(getValue(settings::Brightness::state));
+ }
+
+ auto HandlerCommon::getScreenAutoModeState() const noexcept -> screen_light_control::ScreenLightMode
+ {
+ auto mode = utils::getNumericValue<int>(getValue(settings::Brightness::autoMode));
+ return static_cast<screen_light_control::ScreenLightMode>(mode);
+ }
+
+ auto HandlerCommon::getScreenBrightnessValue() const noexcept -> bsp::eink_frontlight::BrightnessPercentage
+ {
+ return utils::getNumericValue<float>(getValue(settings::Brightness::brightnessLevel));
+ }
+
+ void HandlerCommon::handleScreenLightRefresh()
+ {
+ if (getScreenLightState() && getScreenAutoModeState() == screen_light_control::ScreenLightMode::Automatic) {
+ if (!screenLightControl->isLightOn()) {
+ screenLightControl->processRequest(screen_light_control::Action::turnOn);
+ }
+ startScreenLightTimer();
+ }
+ }
+
+ void HandlerCommon::handleScreenLightSettings(screen_light_control::Action action,
+ const screen_light_control::Parameters ¶ms)
+ {
+ switch (action) {
+ case screen_light_control::Action::enableAutomaticMode:
+ setValue(settings::Brightness::autoMode,
+ utils::to_string(static_cast<int>(screen_light_control::ScreenLightMode::Automatic)));
+ break;
+ case screen_light_control::Action::disableAutomaticMode:
+ setValue(settings::Brightness::autoMode,
+ utils::to_string(static_cast<int>(screen_light_control::ScreenLightMode::Manual)));
+ break;
+ case screen_light_control::Action::turnOff:
+ setValue(settings::Brightness::state, utils::to_string(false));
+ break;
+ case screen_light_control::Action::turnOn:
+ setValue(settings::Brightness::state, utils::to_string(true));
+ screenLightTimer->start();
+ break;
+ case screen_light_control::Action::setManualModeBrightness:
+ if (params.hasManualModeParams()) {
+ setValue(settings::Brightness::brightnessLevel,
+ utils::to_string(params.getManualModeParams().manualModeBrightness));
+ }
+ else {
+ LOG_ERROR("Missing ManualModeBrightness value, change request ignored");
+ }
+ break;
+ default:
+ break;
+ }
+ }
+} // namespace backlight
A module-services/service-evtmgr/backlight-handler/BacklightHandlerCommon.hpp => module-services/service-evtmgr/backlight-handler/BacklightHandlerCommon.hpp +62 -0
@@ 0,0 1,62 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <bsp/keypad_backlight/keypad_backlight.hpp>
+#include <service-evtmgr/screen-light-control/ScreenLightControl.hpp>
+#include <Timers/TimerHandle.hpp>
+#include <Service/ServiceProxy.hpp>
+
+namespace settings
+{
+ class Settings;
+} // namespace settings
+
+namespace backlight
+{
+ /// @brief Backlight events handler
+ class HandlerCommon
+ {
+ public:
+ HandlerCommon(std::shared_ptr<settings::Settings> settings, sys::Service *parent);
+
+ /// initialise in InitHandler when Service is ready
+ void init();
+
+ /// Process request of the screen light control
+ /// @screen_light_control::Action an action to perform
+ /// @screen_light_control::Parameters parameters being set
+ void processScreenRequest(screen_light_control::Action action, const screen_light_control::Parameters ¶ms);
+
+ [[nodiscard]] auto getScreenLightState() const noexcept -> bool;
+ [[nodiscard]] auto getScreenAutoModeState() const noexcept -> screen_light_control::ScreenLightMode;
+ [[nodiscard]] auto getScreenBrightnessValue() const noexcept -> bsp::eink_frontlight::BrightnessPercentage;
+
+ private:
+ std::shared_ptr<settings::Settings> settings;
+ std::shared_ptr<screen_light_control::ScreenLightControl> screenLightControl;
+
+ public:
+ auto getScreenLightTimer() noexcept -> std::shared_ptr<sys::TimerHandle>
+ {
+ return screenLightTimer;
+ }
+ auto getScreenLightControl() noexcept -> std::shared_ptr<screen_light_control::ScreenLightControl>
+ {
+ return screenLightControl;
+ }
+ void handleScreenLightSettings(screen_light_control::Action action,
+ const screen_light_control::Parameters ¶ms);
+ void handleScreenLightRefresh();
+
+ protected:
+ [[nodiscard]] auto getValue(const std::string &path) const -> std::string;
+ void setValue(const std::string &path, const std::string &value);
+
+ /// Timer that keeps screen backlight on for a certain time if there was key pressed
+ std::shared_ptr<sys::TimerHandle> screenLightTimer;
+
+ void startScreenLightTimer();
+ };
+} // namespace backlight
M module-services/service-evtmgr/screen-light-control/ControlFunctions.cpp => module-services/service-evtmgr/screen-light-control/ControlFunctions.cpp +5 -0
@@ 95,4 95,9 @@ namespace screen_light_control::functions
}
}
+ void setRampTarget(bsp::eink_frontlight::BrightnessPercentage value)
+ {
+ rampTarget = value;
+ }
+
} // namespace screen_light_control::functions
M module-services/service-evtmgr/screen-light-control/ControlFunctions.hpp => module-services/service-evtmgr/screen-light-control/ControlFunctions.hpp +2 -0
@@ 23,4 23,6 @@ namespace screen_light_control::functions
void setFunctionFromPoints(const BrightnessFunction &points);
+ void setRampTarget(bsp::eink_frontlight::BrightnessPercentage value);
+
} // namespace screen_light_control::functions
M products/BellHybrid/services/evtmgr/CMakeLists.txt => products/BellHybrid/services/evtmgr/CMakeLists.txt +1 -0
@@ 11,6 11,7 @@ target_sources(evtmgr
internal/StaticData.hpp
screen-light-control/ScreenLightControl.cpp
+ backlight-handler/BacklightHandler.cpp
PUBLIC
include/evtmgr/EventManager.hpp
include/evtmgr/api/TemperatureApi.hpp
M products/BellHybrid/services/evtmgr/EventManager.cpp => products/BellHybrid/services/evtmgr/EventManager.cpp +7 -0
@@ 59,6 59,10 @@ void EventManager::handleKeyEvent(sys::Message *msg)
service::name::system_manager);
}
}
+
+ if (kbdMessage->key.state == RawKey::State::Pressed) {
+ backlightHandler.handleKeyPressed(static_cast<int>(key));
+ }
}
auto EventManager::createEventWorker() -> std::unique_ptr<WorkerEventCommon>
@@ 94,6 98,9 @@ void EventManager::initProductEvents()
backlightHandler.getScreenLightState(), backlightHandler.getScreenAutoModeState(), params);
return msg;
});
+
+ backlightHandler.processScreenRequest(screen_light_control::Action::enableAutomaticMode,
+ screen_light_control::Parameters());
}
sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp)
A products/BellHybrid/services/evtmgr/backlight-handler/BacklightHandler.cpp => products/BellHybrid/services/evtmgr/backlight-handler/BacklightHandler.cpp +45 -0
@@ 0,0 1,45 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <evtmgr/BacklightHandler.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
+#include <service-db/Settings.hpp>
+#include <Timers/TimerFactory.hpp>
+#include <Utils.hpp>
+#include <keymap/KeyMap.hpp>
+
+namespace backlight
+{
+ namespace timers
+ {
+ constexpr auto screenLightTimerTimeout = std::chrono::seconds(5);
+ constexpr auto screenLightTimerHoldTimeout = std::chrono::seconds(10);
+ } // namespace timers
+
+ Handler::Handler(std::shared_ptr<settings::Settings> settings, sys::Service *parent)
+ : HandlerCommon(settings, parent), screenLightControl{getScreenLightControl()}, screenLightTimer{
+ getScreenLightTimer()}
+ {}
+
+ void Handler::handleKeyPressed([[maybe_unused]] const int key)
+ {
+ handleScreenLightRefresh(key);
+ }
+
+ void Handler::handleScreenLightRefresh([[maybe_unused]] const int key)
+ {
+ if (getScreenAutoModeState() == screen_light_control::ScreenLightMode::Automatic) {
+ if (!screenLightControl->isLightOn() && (key == static_cast<int>(KeyMap::Frontlight))) {
+ screenLightControl->processRequest(screen_light_control::Action::turnOn);
+ screenLightTimer->restart(timers::screenLightTimerTimeout);
+ }
+ else if (screenLightControl->isLightOn() && (key != static_cast<int>(KeyMap::Frontlight))) {
+ screenLightTimer->restart(timers::screenLightTimerHoldTimeout);
+ }
+ else if (key == static_cast<int>(KeyMap::Frontlight)) {
+ screenLightControl->processRequest(screen_light_control::Action::turnOff);
+ screenLightTimer->stop();
+ }
+ }
+ }
+} // namespace backlight
A products/BellHybrid/services/evtmgr/backlight-handler/BacklightHandler.hpp => products/BellHybrid/services/evtmgr/backlight-handler/BacklightHandler.hpp +37 -0
@@ 0,0 1,37 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <bsp/keypad_backlight/keypad_backlight.hpp>
+#include <service-evtmgr/screen-light-control/ScreenLightControl.hpp>
+#include <Timers/TimerHandle.hpp>
+#include <Service/ServiceProxy.hpp>
+#include <backlight-handler/BacklightHandlerCommon.hpp>
+
+namespace settings
+{
+ class Settings;
+} // namespace settings
+
+namespace backlight
+{
+ /// @brief Backlight events handler
+ class HandlerBell : public Handler
+ {
+ public:
+ HandlerBell(std::shared_ptr<settings::Settings> settings, sys::Service *parent);
+
+ void handleKeyPressed(const int key = 0);
+
+ private:
+ std::shared_ptr<settings::Settings> settings;
+ std::unique_ptr<screen_light_control::ScreenLightControl> screenLightControl;
+ /// Timer that keeps screen backlight on for a certain time if there was key pressed
+ sys::TimerHandle screenLightTimer;
+ void startScreenLightTimer();
+ void handleScreenLightRefresh(const int key = 0);
+ void handleScreenLightSettings(screen_light_control::Action action,
+ const screen_light_control::Parameters ¶ms);
+ };
+} // namespace backlight
A products/BellHybrid/services/evtmgr/include/evtmgr/BacklightHandler.hpp => products/BellHybrid/services/evtmgr/include/evtmgr/BacklightHandler.hpp +33 -0
@@ 0,0 1,33 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <bsp/keypad_backlight/keypad_backlight.hpp>
+#include <service-evtmgr/screen-light-control/ScreenLightControl.hpp>
+#include <Timers/TimerHandle.hpp>
+#include <Service/ServiceProxy.hpp>
+#include <backlight-handler/BacklightHandlerCommon.hpp>
+
+namespace settings
+{
+ class Settings;
+} // namespace settings
+
+namespace backlight
+{
+ /// @brief Backlight events handler
+ class Handler : public HandlerCommon
+ {
+ public:
+ Handler(std::shared_ptr<settings::Settings> settings, sys::Service *parent);
+
+ void handleKeyPressed([[maybe_unused]] const int key = 0);
+
+ private:
+ std::shared_ptr<screen_light_control::ScreenLightControl> screenLightControl;
+ /// Timer that keeps screen backlight on for a certain time if there was key pressed
+ std::shared_ptr<sys::TimerHandle> screenLightTimer;
+ void handleScreenLightRefresh([[maybe_unused]] const int key = 0);
+ };
+} // namespace backlight
M products/BellHybrid/services/evtmgr/include/evtmgr/EventManager.hpp => products/BellHybrid/services/evtmgr/include/evtmgr/EventManager.hpp +1 -1
@@ 5,7 5,7 @@
#include <service-evtmgr/EventManagerCommon.hpp>
-#include <backlight-handler/BacklightHandler.hpp>
+#include "BacklightHandler.hpp"
namespace hal::temperature
{
M products/BellHybrid/services/evtmgr/screen-light-control/ScreenLightControl.cpp => products/BellHybrid/services/evtmgr/screen-light-control/ScreenLightControl.cpp +2 -1
@@ 66,7 66,7 @@ namespace screen_light_control
void ScreenLightControl::readoutTimerCallback()
{
- functions::calculateBrightness(brightnessValue);
+ // functions::calculateBrightness(brightnessValue);
}
auto ScreenLightControl::getAutoModeState() const noexcept -> ScreenLightMode
@@ 114,6 114,7 @@ namespace screen_light_control
void ScreenLightControl::setParameters(ManualModeParameters params)
{
brightnessValue = params.manualModeBrightness;
+ functions::setRampTarget(brightnessValue);
setManualBrightnessLevel();
}
M products/PurePhone/services/evtmgr/CMakeLists.txt => products/PurePhone/services/evtmgr/CMakeLists.txt +1 -0
@@ 6,6 6,7 @@ target_sources(evtmgr
WorkerEvent.cpp
WorkerEvent.hpp
screen-light-control/ScreenLightControl.cpp
+ backlight-handler/BacklightHandler.cpp
PUBLIC
include/evtmgr/EVMessages.hpp
include/evtmgr/EventManager.hpp
R module-services/service-evtmgr/backlight-handler/BacklightHandler.cpp => products/PurePhone/services/evtmgr/backlight-handler/BacklightHandler.cpp +8 -116
@@ 1,7 1,7 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "BacklightHandler.hpp"
+#include <evtmgr/BacklightHandler.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>
#include <service-db/Settings.hpp>
#include <Timers/TimerFactory.hpp>
@@ 12,63 12,19 @@ namespace backlight
namespace timers
{
constexpr auto keypadLightTimerName = "KeypadLightTimer";
- constexpr auto screenLightTimerName = "ScreenLightTimer";
constexpr auto keypadLightTimerTimeout = std::chrono::seconds(5);
- constexpr auto screenLightTimerTimeout = std::chrono::seconds(5);
} // namespace timers
Handler::Handler(std::shared_ptr<settings::Settings> settings, sys::Service *parent)
- : settings{std::move(settings)}, screenLightControl{std::make_unique<screen_light_control::ScreenLightControl>(
- parent)},
- keypadLightTimer{
- sys::TimerFactory::createSingleShotTimer(parent,
- timers::keypadLightTimerName,
- timers::keypadLightTimerTimeout,
- [this](sys::Timer &) { bsp::keypad_backlight::shutdown(); })},
- screenLightTimer{sys::TimerFactory::createSingleShotTimer(
- parent, timers::screenLightTimerName, timers::keypadLightTimerTimeout, [this](sys::Timer &t) {
- if (getScreenLightState() &&
- getScreenAutoModeState() == screen_light_control::ScreenLightMode::Automatic &&
- screenLightControl->isLightOn()) {
- screenLightControl->processRequest(screen_light_control::Action::turnOff);
- }
- })}
+ : HandlerCommon(settings, parent), screenLightControl{getScreenLightControl()},
+ screenLightTimer{getScreenLightTimer()},
+ keypadLightTimer{sys::TimerFactory::createSingleShotTimer(
+ parent, timers::keypadLightTimerName, timers::keypadLightTimerTimeout, [this](sys::Timer &) {
+ bsp::keypad_backlight::shutdown();
+ })}
{}
- void Handler::init()
- {
- using namespace screen_light_control;
- settings->registerValueChange(settings::Brightness::brightnessLevel, [&](const std::string &value) {
- ManualModeParameters params{utils::getNumericValue<float>(value)};
- screenLightControl->processRequest(Action::setManualModeBrightness, Parameters(params));
- });
-
- settings->registerValueChange(settings::Brightness::autoMode, [&]([[maybe_unused]] const std::string &value) {
- const auto action = getScreenAutoModeState() == ScreenLightMode::Automatic ? Action::enableAutomaticMode
- : Action::disableAutomaticMode;
- screenLightControl->processRequest(action);
- });
-
- settings->registerValueChange(settings::Brightness::state, [&]([[maybe_unused]] const std::string &value) {
- const auto action = getScreenLightState() ? Action::turnOn : Action::turnOff;
- if (action == Action::turnOn) {
- screenLightTimer.start();
- }
- screenLightControl->processRequest(action);
- });
- }
-
- void Handler::processScreenRequest(screen_light_control::Action action,
- const screen_light_control::Parameters ¶ms)
- {
- if (action == screen_light_control::Action::enableAutomaticMode) {
- startScreenLightTimer();
- }
- handleScreenLightSettings(action, params);
- screenLightControl->processRequest(action, params);
- }
-
void Handler::handleKeyPressed()
{
handleKeypadLightRefresh();
@@ 144,42 100,11 @@ namespace backlight
}
}
- auto Handler::getValue(const std::string &path) const -> std::string
- {
- return settings->getValue(path);
- }
-
- void Handler::setValue(const std::string &path, const std::string &value)
- {
- settings->setValue(path, value);
- }
-
void Handler::startKeypadLightTimer()
{
keypadLightTimer.start();
}
- void Handler::startScreenLightTimer()
- {
- screenLightTimer.start();
- }
-
- auto Handler::getScreenLightState() const noexcept -> bool
- {
- return utils::getNumericValue<bool>(getValue(settings::Brightness::state));
- }
-
- auto Handler::getScreenAutoModeState() const noexcept -> screen_light_control::ScreenLightMode
- {
- auto mode = utils::getNumericValue<int>(getValue(settings::Brightness::autoMode));
- return static_cast<screen_light_control::ScreenLightMode>(mode);
- }
-
- auto Handler::getScreenBrightnessValue() const noexcept -> bsp::eink_frontlight::BrightnessPercentage
- {
- return utils::getNumericValue<float>(getValue(settings::Brightness::brightnessLevel));
- }
-
void Handler::handleKeypadLightRefresh()
{
if (keypadLightState == bsp::keypad_backlight::State::activeMode && !isKeypadLightInCallMode) {
@@ 188,7 113,7 @@ namespace backlight
}
}
- void Handler::handleScreenLightRefresh()
+ void Handler::handleScreenLightRefresh([[maybe_unused]] const int key)
{
if (getScreenLightState() && getScreenAutoModeState() == screen_light_control::ScreenLightMode::Automatic) {
if (!screenLightControl->isLightOn()) {
@@ 197,37 122,4 @@ namespace backlight
startScreenLightTimer();
}
}
-
- void Handler::handleScreenLightSettings(screen_light_control::Action action,
- const screen_light_control::Parameters ¶ms)
- {
- switch (action) {
- case screen_light_control::Action::enableAutomaticMode:
- setValue(settings::Brightness::autoMode,
- utils::to_string(static_cast<int>(screen_light_control::ScreenLightMode::Automatic)));
- break;
- case screen_light_control::Action::disableAutomaticMode:
- setValue(settings::Brightness::autoMode,
- utils::to_string(static_cast<int>(screen_light_control::ScreenLightMode::Manual)));
- break;
- case screen_light_control::Action::turnOff:
- setValue(settings::Brightness::state, utils::to_string(false));
- break;
- case screen_light_control::Action::turnOn:
- setValue(settings::Brightness::state, utils::to_string(true));
- screenLightTimer.start();
- break;
- case screen_light_control::Action::setManualModeBrightness:
- if (params.hasManualModeParams()) {
- setValue(settings::Brightness::brightnessLevel,
- utils::to_string(params.getManualModeParams().manualModeBrightness));
- }
- else {
- LOG_ERROR("Missing ManualModeBrightness value, change request ignored");
- }
- break;
- default:
- break;
- }
- }
} // namespace backlight
R module-services/service-evtmgr/backlight-handler/BacklightHandler.hpp => products/PurePhone/services/evtmgr/backlight-handler/BacklightHandler.hpp +2 -2
@@ 29,7 29,7 @@ namespace backlight
/// @screen_light_control::Parameters parameters being set
void processScreenRequest(screen_light_control::Action action, const screen_light_control::Parameters ¶ms);
- void handleKeyPressed();
+ void handleKeyPressed(const int key = 0);
/// Process request of the keypad light control
/// @keypad_backlight::action an action to perform
/// @return True if request was processed successfully, false otherwise
@@ 60,7 60,7 @@ namespace backlight
void setKeypadLightState(bsp::keypad_backlight::State value) noexcept;
void restoreKeypadLightState();
void handleKeypadLightRefresh();
- void handleScreenLightRefresh();
+ void handleScreenLightRefresh(const int key = 0);
void handleScreenLightSettings(screen_light_control::Action action,
const screen_light_control::Parameters ¶ms);
};
A products/PurePhone/services/evtmgr/include/evtmgr/BacklightHandler.hpp => products/PurePhone/services/evtmgr/include/evtmgr/BacklightHandler.hpp +51 -0
@@ 0,0 1,51 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <bsp/keypad_backlight/keypad_backlight.hpp>
+#include <service-evtmgr/screen-light-control/ScreenLightControl.hpp>
+#include <Timers/TimerHandle.hpp>
+#include <Service/ServiceProxy.hpp>
+#include <backlight-handler/BacklightHandlerCommon.hpp>
+
+namespace settings
+{
+ class Settings;
+} // namespace settings
+
+namespace backlight
+{
+ /// @brief Backlight events handler
+ class Handler : public HandlerCommon
+ {
+ public:
+ Handler(std::shared_ptr<settings::Settings> settings, sys::Service *parent);
+
+ void handleKeyPressed();
+ /// Process request of the keypad light control
+ /// @keypad_backlight::action an action to perform
+ /// @return True if request was processed successfully, false otherwise
+ auto processKeypadRequest(bsp::keypad_backlight::Action action) -> bool;
+
+ private:
+ std::shared_ptr<screen_light_control::ScreenLightControl> screenLightControl;
+ /// Timer that keeps screen backlight on for a certain time if there was key pressed
+ std::shared_ptr<sys::TimerHandle> screenLightTimer;
+ /// Timer that keeps key backlight on for a certain time if there was key pressed
+ sys::TimerHandle keypadLightTimer;
+
+ bsp::keypad_backlight::State keypadLightState = bsp::keypad_backlight::State::off;
+ bool isKeypadLightInCallMode = false;
+
+ void startKeypadLightTimer();
+ void stopKeypadTimer();
+ void setKeypadLightInCallMode(bool value) noexcept;
+ void setKeypadLightState(bsp::keypad_backlight::State value) noexcept;
+ void restoreKeypadLightState();
+ void handleKeypadLightRefresh();
+ void handleScreenLightRefresh([[maybe_unused]] const int key = 0);
+ void handleScreenLightSettings(screen_light_control::Action action,
+ const screen_light_control::Parameters ¶ms);
+ };
+} // namespace backlight
M products/PurePhone/services/evtmgr/include/evtmgr/EventManager.hpp => products/PurePhone/services/evtmgr/include/evtmgr/EventManager.hpp +1 -1
@@ 5,7 5,7 @@
#include <service-evtmgr/EventManagerCommon.hpp>
-#include <backlight-handler/BacklightHandler.hpp>
+#include "BacklightHandler.hpp"
#include <bsp/vibrator/vibrator.hpp>
#include <vibra/Vibra.hpp>