Andrew Jeffery | e185efb | 2018-05-24 12:59:06 +0930 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2019 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
George Liu | 45eba6f | 2021-05-18 14:32:20 +0800 | [diff] [blame] | 18 | #include <filesystem> |
Andrew Jeffery | e185efb | 2018-05-24 12:59:06 +0930 | [diff] [blame] | 19 | |
| 20 | namespace phosphor |
| 21 | { |
| 22 | namespace led |
| 23 | { |
| 24 | class SysfsLed |
| 25 | { |
| 26 | public: |
George Liu | 1f2b932 | 2021-12-28 10:32:49 +0800 | [diff] [blame] | 27 | explicit SysfsLed(std::filesystem::path&& root) : root(std::move(root)) |
George Liu | 61b9063 | 2020-06-22 10:55:13 +0800 | [diff] [blame] | 28 | {} |
Andrew Jeffery | e185efb | 2018-05-24 12:59:06 +0930 | [diff] [blame] | 29 | SysfsLed() = delete; |
| 30 | SysfsLed(const SysfsLed& other) = delete; |
Andrew Jeffery | 039885f | 2023-02-07 16:39:46 +1030 | [diff] [blame] | 31 | SysfsLed(const SysfsLed&& other) = delete; |
| 32 | SysfsLed& operator=(const SysfsLed& other) = delete; |
| 33 | SysfsLed&& operator=(const SysfsLed&& other) = delete; |
Andrew Jeffery | e185efb | 2018-05-24 12:59:06 +0930 | [diff] [blame] | 34 | |
| 35 | virtual ~SysfsLed() = default; |
| 36 | |
| 37 | virtual unsigned long getBrightness(); |
Andrew Jeffery | b0f538d | 2023-02-06 19:46:11 +1030 | [diff] [blame] | 38 | virtual void setBrightness(unsigned long brightness); |
Andrew Jeffery | e185efb | 2018-05-24 12:59:06 +0930 | [diff] [blame] | 39 | virtual unsigned long getMaxBrightness(); |
| 40 | virtual std::string getTrigger(); |
| 41 | virtual void setTrigger(const std::string& trigger); |
| 42 | virtual unsigned long getDelayOn(); |
| 43 | virtual void setDelayOn(unsigned long ms); |
| 44 | virtual unsigned long getDelayOff(); |
| 45 | virtual void setDelayOff(unsigned long ms); |
| 46 | |
| 47 | protected: |
Andrew Jeffery | 8e85228 | 2023-02-06 19:29:43 +1030 | [diff] [blame] | 48 | static constexpr const char* attrBrightness = "brightness"; |
| 49 | static constexpr const char* attrMaxBrightness = "max_brightness"; |
| 50 | static constexpr const char* attrTrigger = "trigger"; |
| 51 | static constexpr const char* attrDelayOn = "delay_on"; |
| 52 | static constexpr const char* attrDelayOff = "delay_off"; |
Andrew Jeffery | e185efb | 2018-05-24 12:59:06 +0930 | [diff] [blame] | 53 | |
George Liu | 45eba6f | 2021-05-18 14:32:20 +0800 | [diff] [blame] | 54 | std::filesystem::path root; |
Andrew Jeffery | e185efb | 2018-05-24 12:59:06 +0930 | [diff] [blame] | 55 | }; |
| 56 | } // namespace led |
| 57 | } // namespace phosphor |