API Documentation v0.0.1
Loading...
Searching...
No Matches
1A4_L_EWI.h
1/**********************************************************************************************************************
2 * ____ _ _ _
3 * / __ \ | | | | | |
4 * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 * | |
9 * |_|
10 * ----------------------------------------------------------------------------------
11 *
12 * @file 1A4_L_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 Left EWI panel.
18 * It consists of two parts:
19 * - An array with the LEDs and their roles (LED_FIRE, LED_CAUTION, LED_GO, LED_NO_GO, ...)
20 * - A class that implements the panel's functionality
21 *********************************************************************************************************************/
22
23
24#ifndef __L_EWI_BL_H
25#define __L_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 L_EWI_LED_COUNT = 30; // Total number of LEDs in the panel
38const Led lEwiLedTable[L_EWI_LED_COUNT] PROGMEM = {
39 {0, LED_FIRE}, {1, LED_FIRE}, {2, LED_FIRE}, {3, LED_FIRE}, {4, LED_CAUTION},
40 {5, LED_CAUTION}, {6, LED_CAUTION}, {7, LED_CAUTION}, {8, LED_GO}, {9, LED_GO},
41 {10, LED_NO_GO}, {11, LED_NO_GO}, {12, LED_R_BLEED}, {13, LED_R_BLEED}, {14, LED_L_BLEED},
42 {15, LED_L_BLEED}, {16, LED_SPD_BRK}, {17, LED_SPD_BRK}, {18, LED_STBY}, {19, LED_STBY},
43 {20, LED_REC}, {21, LED_REC}, {22, LED_L_BAR1}, {23, LED_L_BAR1}, {24, LED_L_BAR2},
44 {25, LED_L_BAR2}, {26, LED_XMIT}, {27, LED_XMIT}, {28, LED_ASPJ_ON}, {29, LED_ASPJ_ON}
45};
46
47/********************************************************************************************************************
48 * @brief Left EWI Panel class
49 * @details Indicator controller for the Left EWI panel.
50 * Total LEDs: 30
51 * Indicator LEDs: 30 (FIRE: 0-3, CAUTION: 4-7, GO: 8-9, NO_GO: 10-11, R_BLEED: 12-13,
52 * L_BLEED: 14-15, SPD_BRK: 16-17, STBY: 18-19, REC: 20-21,
53 * L_BAR1: 22-23, L_BAR2: 24-25, XMIT: 26-27, ASPJ_ON: 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 EwiPanel : public Panel {
59public:
67 static EwiPanel* getInstance(int startIndex = 0, CRGB* ledStrip = nullptr) {
68 if (!instance) {
69 instance = new EwiPanel(startIndex, ledStrip);
70 }
71 return instance;
72 }
73
74private:
81 EwiPanel(int startIndex, CRGB* ledStrip) {
82 panelStartIndex = startIndex;
83 this->ledStrip = ledStrip;
84 ledCount = L_EWI_LED_COUNT;
85 ledTable = lEwiLedTable;
86 }
87
93 static void onFireLeftLtChange(unsigned int newValue) {
94 if (instance) instance->setIndicatorColor(LED_FIRE, newValue ? NVIS_RED : NVIS_BLACK);
95 }
96 DcsBios::IntegerBuffer fireLeftLtBuffer{FA_18C_hornet_FIRE_LEFT_LT, onFireLeftLtChange};
97
98 static void onMasterCautionLtChange(unsigned int newValue) {
99 if (instance) instance->setIndicatorColor(LED_CAUTION, newValue ? NVIS_YELLOW : NVIS_BLACK);
100 }
101 DcsBios::IntegerBuffer masterCautionLtBuffer{FA_18C_hornet_MASTER_CAUTION_LT, onMasterCautionLtChange};
102
103 static void onLhAdvAspjOhChange(unsigned int newValue) {
104 if (instance) instance->setIndicatorColor(LED_ASPJ_ON, newValue ? NVIS_YELLOW : NVIS_BLACK);
105 }
106 DcsBios::IntegerBuffer lhAdvAspjOhBuffer{FA_18C_hornet_LH_ADV_ASPJ_OH, onLhAdvAspjOhChange};
107
108 static void onLhAdvGoChange(unsigned int newValue) {
109 if (instance) instance->setIndicatorColor(LED_GO, newValue ? NVIS_GREEN_A : NVIS_BLACK);
110 }
111 DcsBios::IntegerBuffer lhAdvGoBuffer{FA_18C_hornet_LH_ADV_GO, onLhAdvGoChange};
112
113 static void onLhAdvLBarGreenChange(unsigned int newValue) {
114 if (instance) instance->setIndicatorColor(LED_L_BAR2, newValue ? NVIS_GREEN_A : NVIS_BLACK);
115 }
116 DcsBios::IntegerBuffer lhAdvLBarGreenBuffer{FA_18C_hornet_LH_ADV_L_BAR_GREEN, onLhAdvLBarGreenChange};
117
118 static void onLhAdvLBarRedChange(unsigned int newValue) {
119 if (instance) instance->setIndicatorColor(LED_L_BAR1, newValue ? NVIS_RED : NVIS_BLACK);
120 }
121 DcsBios::IntegerBuffer lhAdvLBarRedBuffer{FA_18C_hornet_LH_ADV_L_BAR_RED, onLhAdvLBarRedChange};
122
123 static void onLhAdvLBleedChange(unsigned int newValue) {
124 if (instance) instance->setIndicatorColor(LED_L_BLEED, newValue ? NVIS_RED : NVIS_BLACK);
125 }
126 DcsBios::IntegerBuffer lhAdvLBleedBuffer{FA_18C_hornet_LH_ADV_L_BLEED, onLhAdvLBleedChange};
127
128 static void onLhAdvNoGoChange(unsigned int newValue) {
129 if (instance) instance->setIndicatorColor(LED_NO_GO, newValue ? NVIS_YELLOW : NVIS_BLACK);
130 }
131 DcsBios::IntegerBuffer lhAdvNoGoBuffer{FA_18C_hornet_LH_ADV_NO_GO, onLhAdvNoGoChange};
132
133 static void onLhAdvRBleedChange(unsigned int newValue) {
134 if (instance) instance->setIndicatorColor(LED_R_BLEED, newValue ? NVIS_RED : NVIS_BLACK);
135 }
136 DcsBios::IntegerBuffer lhAdvRBleedBuffer{FA_18C_hornet_LH_ADV_R_BLEED, onLhAdvRBleedChange};
137
138 static void onLhAdvRecChange(unsigned int newValue) {
139 if (instance) instance->setIndicatorColor(LED_REC, newValue ? NVIS_GREEN_A : NVIS_BLACK);
140 }
141 DcsBios::IntegerBuffer lhAdvRecBuffer{FA_18C_hornet_LH_ADV_REC, onLhAdvRecChange};
142
143 static void onLhAdvSpdBrkChange(unsigned int newValue) {
144 if (instance) instance->setIndicatorColor(LED_SPD_BRK, newValue ? NVIS_GREEN_A : NVIS_BLACK);
145 }
146 DcsBios::IntegerBuffer lhAdvSpdBrkBuffer{FA_18C_hornet_LH_ADV_SPD_BRK, onLhAdvSpdBrkChange};
147
148 static void onLhAdvStbyChange(unsigned int newValue) {
149 if (instance) instance->setIndicatorColor(LED_STBY, newValue ? NVIS_GREEN_A : NVIS_BLACK);
150 }
151 DcsBios::IntegerBuffer lhAdvStbyBuffer{FA_18C_hornet_LH_ADV_STBY, onLhAdvStbyChange};
152
153 static void onLhAdvXmitChange(unsigned int newValue) {
154 if (instance) instance->setIndicatorColor(LED_XMIT, newValue ? NVIS_GREEN_A : NVIS_BLACK);
155 }
156 DcsBios::IntegerBuffer lhAdvXmitBuffer{FA_18C_hornet_LH_ADV_XMIT, onLhAdvXmitChange};
157
158 // Instance data
159 static EwiPanel* instance;
160};
161
162// Initialize static instance pointer
163EwiPanel* EwiPanel::instance = nullptr;
164
165#endif
static EwiPanel * getInstance(int startIndex=0, CRGB *ledStrip=nullptr)
Gets the singleton instance of the EwiPanel class.
Definition 1A4_L_EWI.h:67
Definition Panel.h:41
void setIndicatorColor(LedRole role, const CRGB &color)
Sets the color of LEDs with a specific role.
Definition Panel.h:156