Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <map> |
| 4 | #include <set> |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 5 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 6 | namespace phosphor |
| 7 | { |
| 8 | namespace led |
| 9 | { |
| 10 | /** @namespace Layout |
| 11 | * @brief Depicts the LED and their mappings and group actions |
| 12 | */ |
| 13 | namespace Layout |
| 14 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 15 | /** @brief Define possible actions on a given LED. |
| 16 | * For the BLINK operation, follow 50-50 duty cycle |
| 17 | */ |
| 18 | enum Action |
| 19 | { |
| 20 | Off, |
| 21 | On, |
| 22 | Blink, |
| 23 | }; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 24 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 25 | /** @brief Name of the LED and it's proposed action. |
| 26 | * This structure is supplied as configuration at build time |
| 27 | */ |
| 28 | struct LedAction |
| 29 | { |
| 30 | std::string name; |
| 31 | Action action; |
| 32 | uint8_t dutyOn; |
| 33 | uint16_t period; |
| 34 | Action priority; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 35 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 36 | // 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 Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 42 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 43 | if (action == right.action) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 44 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 45 | return false; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 46 | } |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 47 | else if (action == priority) |
| 48 | { |
| 49 | return true; |
| 50 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 51 | } |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 52 | return name < right.name; |
| 53 | } |
| 54 | }; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 55 | } // namespace Layout |
| 56 | } // namespace led |
| 57 | } // namespace phosphor |