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