1595d5899Sopenharmony_ci/* 2595d5899Sopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3595d5899Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4595d5899Sopenharmony_ci * you may not use this file except in compliance with the License. 5595d5899Sopenharmony_ci * You may obtain a copy of the License at 6595d5899Sopenharmony_ci * 7595d5899Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8595d5899Sopenharmony_ci * 9595d5899Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10595d5899Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11595d5899Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12595d5899Sopenharmony_ci * See the License for the specific language governing permissions and 13595d5899Sopenharmony_ci * limitations under the License. 14595d5899Sopenharmony_ci */ 15595d5899Sopenharmony_ci 16595d5899Sopenharmony_ci#ifndef LIGHT_LUX_MANAGER_H 17595d5899Sopenharmony_ci#define LIGHT_LUX_MANAGER_H 18595d5899Sopenharmony_ci 19595d5899Sopenharmony_ci#include <vector> 20595d5899Sopenharmony_ci 21595d5899Sopenharmony_ci#include "config_parser.h" 22595d5899Sopenharmony_ci#include "ilight_lux_manager.h" 23595d5899Sopenharmony_ci#include "light_lux_buffer.h" 24595d5899Sopenharmony_ci 25595d5899Sopenharmony_cinamespace OHOS { 26595d5899Sopenharmony_cinamespace DisplayPowerMgr { 27595d5899Sopenharmony_ciclass LightLuxManager : public ILightLuxManager { 28595d5899Sopenharmony_cipublic: 29595d5899Sopenharmony_ci LightLuxManager() = default; 30595d5899Sopenharmony_ci ~LightLuxManager() override = default; 31595d5899Sopenharmony_ci 32595d5899Sopenharmony_ci LightLuxManager(const LightLuxManager&) = delete; 33595d5899Sopenharmony_ci LightLuxManager& operator=(const LightLuxManager&) = delete; 34595d5899Sopenharmony_ci LightLuxManager(LightLuxManager&&) = delete; 35595d5899Sopenharmony_ci LightLuxManager& operator=(LightLuxManager&&) = delete; 36595d5899Sopenharmony_ci 37595d5899Sopenharmony_ci void InitParameters() override; 38595d5899Sopenharmony_ci void SetSceneMode(BrightnessSceneMode mode) override; 39595d5899Sopenharmony_ci float GetFilteredLux() const override; 40595d5899Sopenharmony_ci float GetSmoothedLux() const override; 41595d5899Sopenharmony_ci void ClearLuxData() override; 42595d5899Sopenharmony_ci void UpdateSmoothedLux(float lux); 43595d5899Sopenharmony_ci bool IsNeedUpdateBrightness(float lux) override; 44595d5899Sopenharmony_ci 45595d5899Sopenharmony_ci float GetLux() const override; 46595d5899Sopenharmony_ci void SetLux(const float lux) override; 47595d5899Sopenharmony_ci bool GetIsFirstLux(); 48595d5899Sopenharmony_ci 49595d5899Sopenharmony_ciprivate: 50595d5899Sopenharmony_ci void UpdateLuxBuffer(int64_t timestamp, float lux); 51595d5899Sopenharmony_ci bool IsUpdateLuxSuccess(int64_t timestamp); 52595d5899Sopenharmony_ci float CalcSmoothLux() const; 53595d5899Sopenharmony_ci int64_t GetNextBrightenTime(int64_t timestamp) const; 54595d5899Sopenharmony_ci int64_t GetNextDarkenTime(int64_t timestamp) const; 55595d5899Sopenharmony_ci void UpdateParam(float lux); 56595d5899Sopenharmony_ci float CalcDelta(const std::vector<PointXy>& pointList) const; 57595d5899Sopenharmony_ci float GetValidLux(float lux) const; 58595d5899Sopenharmony_ci int GetDarkenResponseTime() const; 59595d5899Sopenharmony_ci int GetBrightenResponseTime() const; 60595d5899Sopenharmony_ci const LuxThresholdConfig::Mode& GetCurrentModeData() const; 61595d5899Sopenharmony_ci std::vector<PointXy> GetBrightenLuxList(); 62595d5899Sopenharmony_ci std::vector<PointXy> GetDarkenLuxList(); 63595d5899Sopenharmony_ci int GetFilterNum(); 64595d5899Sopenharmony_ci int GetNoFilterNum(); 65595d5899Sopenharmony_ci void PrintCurrentLuxLog(int64_t timestamp); 66595d5899Sopenharmony_ci 67595d5899Sopenharmony_ci LightLuxBuffer mLuxBuffer{}; 68595d5899Sopenharmony_ci LightLuxBuffer mLuxBufferFilter{}; 69595d5899Sopenharmony_ci float mLux{0.0f}; 70595d5899Sopenharmony_ci float mFilteredLux{0.0f}; 71595d5899Sopenharmony_ci bool mIsFirstLux{false}; 72595d5899Sopenharmony_ci float mSmoothedButNotStabledLux{0.0f}; 73595d5899Sopenharmony_ci float mBrightenDelta{120.0f}; 74595d5899Sopenharmony_ci float mDarkenDelta{110.0f}; 75595d5899Sopenharmony_ci int64_t mPrintLogTime{0}; 76595d5899Sopenharmony_ci BrightnessFilterMode mCurrentFilter{static_cast<int>(BrightnessFilterMode::MEAN_FILTER)}; 77595d5899Sopenharmony_ci BrightnessSceneMode mCurrentSceneMode{static_cast<int>(BrightnessSceneMode::MODE_DEFAULT)}; 78595d5899Sopenharmony_ci Config mBrightnessConfigData{}; 79595d5899Sopenharmony_ci}; 80595d5899Sopenharmony_ci} // namespace BrightnessPowerMgr 81595d5899Sopenharmony_ci} // namespace OHOS 82595d5899Sopenharmony_ci#endif // LIGHT_LUX_MANAGER_H