blob: 57c6769623fd4b00f3dbd01934d804d649cf2527 [file] [log] [blame]
Andrew Jefferye185efb2018-05-24 12:59:06 +09301/**
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 Liu45eba6f2021-05-18 14:32:20 +080018#include <filesystem>
Andrew Jefferye185efb2018-05-24 12:59:06 +093019
20namespace phosphor
21{
22namespace led
23{
24class SysfsLed
25{
26 public:
Patrick Williams1c4503e2023-05-10 07:50:54 -050027 explicit SysfsLed(std::filesystem::path&& root) : root(std::move(root)) {}
Andrew Jefferye185efb2018-05-24 12:59:06 +093028 SysfsLed() = delete;
29 SysfsLed(const SysfsLed& other) = delete;
Andrew Jeffery039885f2023-02-07 16:39:46 +103030 SysfsLed(const SysfsLed&& other) = delete;
31 SysfsLed& operator=(const SysfsLed& other) = delete;
32 SysfsLed&& operator=(const SysfsLed&& other) = delete;
Andrew Jefferye185efb2018-05-24 12:59:06 +093033
34 virtual ~SysfsLed() = default;
35
36 virtual unsigned long getBrightness();
Andrew Jefferyb0f538d2023-02-06 19:46:11 +103037 virtual void setBrightness(unsigned long brightness);
Andrew Jefferye185efb2018-05-24 12:59:06 +093038 virtual unsigned long getMaxBrightness();
39 virtual std::string getTrigger();
40 virtual void setTrigger(const std::string& trigger);
41 virtual unsigned long getDelayOn();
42 virtual void setDelayOn(unsigned long ms);
43 virtual unsigned long getDelayOff();
44 virtual void setDelayOff(unsigned long ms);
45
46 protected:
Andrew Jeffery8e852282023-02-06 19:29:43 +103047 static constexpr const char* attrBrightness = "brightness";
48 static constexpr const char* attrMaxBrightness = "max_brightness";
49 static constexpr const char* attrTrigger = "trigger";
50 static constexpr const char* attrDelayOn = "delay_on";
51 static constexpr const char* attrDelayOff = "delay_off";
Andrew Jefferye185efb2018-05-24 12:59:06 +093052
George Liu45eba6f2021-05-18 14:32:20 +080053 std::filesystem::path root;
Andrew Jefferye185efb2018-05-24 12:59:06 +093054};
55} // namespace led
56} // namespace phosphor