blob: f12e0b504e73ad057c3f5b50b3dfc9d6c13c3d9c [file] [log] [blame]
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301#pragma once
2
3#include <map>
4#include <set>
Andrew Geisslerd02c3cb2020-05-16 10:28:02 -05005#include <string>
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05306
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05307namespace phosphor
8{
9namespace led
10{
11/** @namespace Layout
12 * @brief Depicts the LED and their mappings and group actions
13 */
14namespace Layout
15{
Patrick Venture91ac8d32018-11-01 17:03:22 -070016/** @brief Define possible actions on a given LED.
17 * For the BLINK operation, follow 50-50 duty cycle
18 */
19enum Action
20{
21 Off,
22 On,
23 Blink,
24};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053025
Patrick Venture91ac8d32018-11-01 17:03:22 -070026/** @brief Name of the LED and it's proposed action.
27 * This structure is supplied as configuration at build time
28 */
29struct LedAction
30{
31 std::string name;
32 Action action;
33 uint8_t dutyOn;
34 uint16_t period;
35 Action priority;
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053036
Patrick Venture91ac8d32018-11-01 17:03:22 -070037 // Order LEDs such that same LEDs are grouped next to
38 // each other and the same LEDs are in priority order
39 // with the highest priority coming first
40 bool operator<(const LedAction& right) const
41 {
42 if (name == right.name)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053043 {
Patrick Venture91ac8d32018-11-01 17:03:22 -070044 if (action == right.action)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053045 {
Patrick Venture91ac8d32018-11-01 17:03:22 -070046 return false;
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053047 }
Patrick Venture91ac8d32018-11-01 17:03:22 -070048 else if (action == priority)
49 {
50 return true;
51 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053052 }
Patrick Venture91ac8d32018-11-01 17:03:22 -070053 return name < right.name;
54 }
55};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053056} // namespace Layout
57} // namespace led
58} // namespace phosphor