blob: 90b333ce9076f340252291cbd1bbd3ee7e226cd6 [file] [log] [blame]
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301#pragma once
2
3#include <map>
4#include <set>
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05305
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05306namespace phosphor
7{
8namespace led
9{
10/** @namespace Layout
11 * @brief Depicts the LED and their mappings and group actions
12 */
13namespace Layout
14{
Patrick Venture91ac8d32018-11-01 17:03:22 -070015/** @brief Define possible actions on a given LED.
16 * For the BLINK operation, follow 50-50 duty cycle
17 */
18enum Action
19{
20 Off,
21 On,
22 Blink,
23};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053024
Patrick Venture91ac8d32018-11-01 17:03:22 -070025/** @brief Name of the LED and it's proposed action.
26 * This structure is supplied as configuration at build time
27 */
28struct LedAction
29{
30 std::string name;
31 Action action;
32 uint8_t dutyOn;
33 uint16_t period;
34 Action priority;
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053035
Patrick Venture91ac8d32018-11-01 17:03:22 -070036 // Order LEDs such that same LEDs are grouped next to
37 // each other and the same LEDs are in priority order
38 // with the highest priority coming first
39 bool operator<(const LedAction& right) const
40 {
41 if (name == right.name)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053042 {
Patrick Venture91ac8d32018-11-01 17:03:22 -070043 if (action == right.action)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053044 {
Patrick Venture91ac8d32018-11-01 17:03:22 -070045 return false;
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053046 }
Patrick Venture91ac8d32018-11-01 17:03:22 -070047 else if (action == priority)
48 {
49 return true;
50 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053051 }
Patrick Venture91ac8d32018-11-01 17:03:22 -070052 return name < right.name;
53 }
54};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053055} // namespace Layout
56} // namespace led
57} // namespace phosphor