~aleteoryx/muditaos

ref: f2381600d5ade802e6de3b75d21a3c308e42a534 muditaos/module-services/service-evtmgr/backlight-handler/BacklightHandlerCommon.hpp -rw-r--r-- 2.3 KiB
f2381600 — Pawel Olejniczak [EGD-7697] Change deafult bt device name to Mudita Pure 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 &params);

        [[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 &params);
        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