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 | { |
| 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 | }; |
| 24 | |
| 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; |
Vishwanatha Subbanna | 8a50a50 | 2017-01-20 18:42:21 +0530 | [diff] [blame] | 32 | uint8_t dutyOn; |
| 33 | uint16_t period; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 34 | Action priority; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 35 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [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 |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 39 | bool operator<(const LedAction& right) const |
| 40 | { |
| 41 | if (name == right.name) |
| 42 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 43 | if (action == right.action) |
| 44 | { |
| 45 | return false; |
| 46 | } |
| 47 | else if (action == priority) |
| 48 | { |
| 49 | return true; |
| 50 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 51 | } |
| 52 | return name < right.name; |
| 53 | } |
| 54 | }; |
| 55 | } // namespace Layout |
| 56 | } // namespace led |
| 57 | } // namespace phosphor |