API Documentation v0.0.1
Loading...
Searching...
No Matches
1A5_R_EWI.h
1/**********************************************************************************************************************
2 * ____ _ _ _
3 * / __ \ | | | | | |
4 * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 * | |
9 * |_|
10 * ----------------------------------------------------------------------------------
11 *
12 * @file 1A5_R_EWI_BL.h
13 * @author Ulukaii, Arribe, Higgins
14 * @date 24.05.2025
15 * @version t 0.3.2
16 * @copyright Copyright 2016-2025 OpenHornet. See 2A13-BACKLIGHT_CONTROLLER.ino for details.
17 * @brief Implements backlighting for the Right EWI panel.
18 * It consists of two parts:
19 * - An array with the LEDs and their roles (LED_R_FIRE, LED_APU_FIRE, LED_DISP, ...)
20 * - A class that implements the panel's functionality
21 *********************************************************************************************************************/
22
23
24#ifndef __R_EWI_BL_H
25#define __R_EWI_BL_H
26
27#include "DcsBios.h"
28#include "../helpers/Panel.h"
29
30
31/********************************************************************************************************************
32 * @brief This table defines the panel's LEDs.
33 * @details "Role" in this context refers to the LED role enum in the LedRole.h file (enum used for memory efficiency).
34 * @remark This table is stored in PROGMEM for memory efficiency.
35 * @see LedRole.h for the list of LED roles and LedStruct.h for the Led structure.
36 ********************************************************************************************************************/
37const int R_EWI_LED_COUNT = 30; // Total number of LEDs in the panel
38const Led rEwiLedTable[R_EWI_LED_COUNT] PROGMEM = {
39 {0, LED_R_FIRE}, {1, LED_R_FIRE}, {2, LED_R_FIRE}, {3, LED_R_FIRE}, {4, LED_APU_FIRE},
40 {5, LED_APU_FIRE}, {6, LED_APU_FIRE}, {7, LED_APU_FIRE}, {8, LED_DISP}, {9, LED_DISP},
41 {10, LED_RCDRON}, {11, LED_RCDRON}, {12, LED_SPARE1}, {13, LED_SPARE1}, {14, LED_SPARE2},
42 {15, LED_SPARE2}, {16, LED_SPARE3}, {17, LED_SPARE3}, {18, LED_SPARE4}, {19, LED_SPARE4},
43 {20, LED_SPARE5}, {21, LED_SPARE5}, {22, LED_SAM}, {23, LED_SAM}, {24, LED_AAA},
44 {25, LED_AAA}, {26, LED_AI}, {27, LED_AI}, {28, LED_CW}, {29, LED_CW}
45};
46
47/********************************************************************************************************************
48 * @brief Right EWI Panel class
49 * @details Backlighting and indicator controller for the Right EWI panel.
50 * Total LEDs: 30
51 * Indicator LEDs: 30 (FIRE: 0-3, APU FIRE: 4-7, DISP: 8-9, RCDRON ON: 10-11, L BLANK: 12-13,
52 * R BLANK: 14-15, R BLANK2: 16-17, L BLANK2: 18-19, L BLANK3: 20-21,
53 * SAM: 22-23, AAA: 24-25, AI: 26-27, CW: 28-29)
54 * @remark This class inherits from the "basic" Panel class in panels/Panel.h
55 * It also enforces a singleton pattern; this is required to use DCS-BIOS callbacks in class methods.
56 * @see Panel.h for the base class implementation
57 ********************************************************************************************************************/
58class REwiPanel : public Panel {
59public:
67 static REwiPanel* getInstance(int startIndex = 0, CRGB* ledStrip = nullptr) {
68 if (!instance) {
69 instance = new REwiPanel(startIndex, ledStrip);
70 }
71 return instance;
72 }
73
74private:
81 REwiPanel(int startIndex, CRGB* ledStrip) {
82 panelStartIndex = startIndex;
83 this->ledStrip = ledStrip;
84 ledCount = R_EWI_LED_COUNT;
85 ledTable = rEwiLedTable;
86 }
87
93 static void onFireRightLtChange(unsigned int newValue) {
94 if (instance) instance->setIndicatorColor(LED_R_FIRE, newValue ? NVIS_RED : NVIS_BLACK);
95 }
96 DcsBios::IntegerBuffer fireRightLtBuffer{FA_18C_hornet_FIRE_RIGHT_LT, onFireRightLtChange};
97
98 static void onFireApuLtChange(unsigned int newValue) {
99 if (instance) instance->setIndicatorColor(LED_APU_FIRE, newValue ? NVIS_RED : NVIS_BLACK);
100 }
101 DcsBios::IntegerBuffer fireApuLtBuffer{FA_18C_hornet_FIRE_APU_LT, onFireApuLtChange};
102
103 static void onRhAdvAaaChange(unsigned int newValue) {
104 if (instance) instance->setIndicatorColor(LED_AAA, newValue ? NVIS_GREEN_A : NVIS_BLACK);
105 }
106 DcsBios::IntegerBuffer rhAdvAaaBuffer{FA_18C_hornet_RH_ADV_AAA, onRhAdvAaaChange};
107
108 static void onRhAdvAiChange(unsigned int newValue) {
109 if (instance) instance->setIndicatorColor(LED_AI, newValue ? NVIS_GREEN_A : NVIS_BLACK);
110 }
111 DcsBios::IntegerBuffer rhAdvAiBuffer{FA_18C_hornet_RH_ADV_AI, onRhAdvAiChange};
112
113 static void onRhAdvCwChange(unsigned int newValue) {
114 if (instance) instance->setIndicatorColor(LED_CW, newValue ? NVIS_GREEN_A : NVIS_BLACK);
115 }
116 DcsBios::IntegerBuffer rhAdvCwBuffer{FA_18C_hornet_RH_ADV_CW, onRhAdvCwChange};
117
118 static void onRhAdvDispChange(unsigned int newValue) {
119 if (instance) instance->setIndicatorColor(LED_DISP, newValue ? NVIS_GREEN_A : NVIS_BLACK);
120 }
121 DcsBios::IntegerBuffer rhAdvDispBuffer{FA_18C_hornet_RH_ADV_DISP, onRhAdvDispChange};
122
123 static void onRhAdvRcdrOnChange(unsigned int newValue) {
124 if (instance) instance->setIndicatorColor(LED_RCDRON, newValue ? NVIS_GREEN_A : NVIS_BLACK);
125 }
126 DcsBios::IntegerBuffer rhAdvRcdrOnBuffer{FA_18C_hornet_RH_ADV_RCDR_ON, onRhAdvRcdrOnChange};
127
128 static void onRhAdvSamChange(unsigned int newValue) {
129 if (instance) instance->setIndicatorColor(LED_SAM, newValue ? NVIS_GREEN_A : NVIS_BLACK);
130 }
131 DcsBios::IntegerBuffer rhAdvSamBuffer{FA_18C_hornet_RH_ADV_SAM, onRhAdvSamChange};
132
133 static void onRhAdvSpareRh1Change(unsigned int newValue) {
134 if (instance) instance->setIndicatorColor(LED_SPARE1, newValue ? NVIS_GREEN_A : NVIS_BLACK);
135 }
136 DcsBios::IntegerBuffer rhAdvSpareRh1Buffer{FA_18C_hornet_RH_ADV_SPARE_RH1, onRhAdvSpareRh1Change};
137
138 static void onRhAdvSpareRh2Change(unsigned int newValue) {
139 if (instance) instance->setIndicatorColor(LED_SPARE2, newValue ? NVIS_GREEN_A : NVIS_BLACK);
140 }
141 DcsBios::IntegerBuffer rhAdvSpareRh2Buffer{FA_18C_hornet_RH_ADV_SPARE_RH2, onRhAdvSpareRh2Change};
142
143 static void onRhAdvSpareRh3Change(unsigned int newValue) {
144 if (instance) instance->setIndicatorColor(LED_SPARE3, newValue ? NVIS_GREEN_A : NVIS_BLACK);
145 }
146 DcsBios::IntegerBuffer rhAdvSpareRh3Buffer{FA_18C_hornet_RH_ADV_SPARE_RH3, onRhAdvSpareRh3Change};
147
148 static void onRhAdvSpareRh4Change(unsigned int newValue) {
149 if (instance) instance->setIndicatorColor(LED_SPARE4, newValue ? NVIS_GREEN_A : NVIS_BLACK);
150 }
151 DcsBios::IntegerBuffer rhAdvSpareRh4Buffer{FA_18C_hornet_RH_ADV_SPARE_RH4, onRhAdvSpareRh4Change};
152
153 static void onRhAdvSpareRh5Change(unsigned int newValue) {
154 if (instance) instance->setIndicatorColor(LED_SPARE5, newValue ? NVIS_GREEN_A : NVIS_BLACK);
155 }
156 DcsBios::IntegerBuffer rhAdvSpareRh5Buffer{FA_18C_hornet_RH_ADV_SPARE_RH5, onRhAdvSpareRh5Change};
157
158 // Instance data
159 static REwiPanel* instance;
160};
161
162// Initialize static instance pointer
163REwiPanel* REwiPanel::instance = nullptr;
164
165#endif
Definition Panel.h:41
void setIndicatorColor(LedRole role, const CRGB &color)
Sets the color of LEDs with a specific role.
Definition Panel.h:156
static REwiPanel * getInstance(int startIndex=0, CRGB *ledStrip=nullptr)
Gets the singleton instance of the REwiPanel class.
Definition 1A5_R_EWI.h:67