API Documentation v0.0.1
Loading...
Searching...
No Matches
2A2A1A1_Jett_Station_Panel.h
1/**********************************************************************************************************************
2 * ____ _ _ _
3 * / __ \ | | | | | |
4 * | | | |_ __ ___ _ __ | |__| | ___ _ __ _ __ ___| |_
5 * | | | | '_ \ / _ \ '_ \| __ |/ _ \| '__| '_ \ / _ \ __|
6 * | |__| | |_) | __/ | | | | | | (_) | | | | | | __/ |_
7 * \____/| .__/ \___|_| |_|_| |_|\___/|_| |_| |_|\___|\__|
8 * | |
9 * |_|
10 * ----------------------------------------------------------------------------------
11 *
12 * @file 2A2A1A1_Jett_Station_Panel.h
13 * @author Ulukaii
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 indicators for the Jett Station panel.
18 * It consists of two parts:
19 * - An array with the LEDs and their roles (LED_JETT_RO_1, LED_JETT_RI_1, LED_JETT_CTR_1, ...)
20 * - A class that implements the panel's functionality
21 *********************************************************************************************************************/
22
23
24#ifndef __JETT_STATION_PANEL_H
25#define __JETT_STATION_PANEL_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 JETT_STATION_LED_COUNT = 32; // Total number of LEDs in the panel
38const Led jettStationLedTable[JETT_STATION_LED_COUNT] PROGMEM = {
39 // RO (Right Outer) Station LEDs
40 {0, LED_JETT_RO_1}, {3, LED_JETT_RO_1}, {1, LED_JETT_RO_2}, {2, LED_JETT_RO_2},
41 // RI (Right Inner) Station LEDs
42 {4, LED_JETT_RI_1}, {7, LED_JETT_RI_1}, {5, LED_JETT_RI_2}, {6, LED_JETT_RI_2},
43 // CTR (Center) Station LEDs
44 {11, LED_JETT_CTR_1}, {8, LED_JETT_CTR_1}, {10, LED_JETT_CTR_2}, {9, LED_JETT_CTR_2},
45 // LI (Left Inner) Station LEDs
46 {14, LED_JETT_LI_1}, {13, LED_JETT_LI_1}, {12, LED_JETT_LI_2}, {15, LED_JETT_LI_2},
47 // LO (Left Outer) Station LEDs
48 {18, LED_JETT_LO_1}, {17, LED_JETT_LO_1}, {16, LED_JETT_LO_2}, {19, LED_JETT_LO_2},
49 // Nose Station LED
50 {20, LED_JETT_NOSE}, {31, LED_JETT_NOSE},
51 // Left/Right Station LEDs
52 {23, LED_JETT_LEFT}, {24, LED_JETT_LEFT}, {21, LED_JETT_RIGHT}, {22, LED_JETT_RIGHT},
53 // Half/Full Station LEDs
54 {25, LED_JETT_HALF}, {26, LED_JETT_HALF}, {27, LED_JETT_FULL}, {28, LED_JETT_FULL},
55 // Flaps Station LEDs
56 {29, LED_JETT_FLAPS}, {30, LED_JETT_FLAPS}
57};
58
59/********************************************************************************************************************
60 * @brief Jett Station Panel class
61 * @details Indicator controller for the Jett Station panel.
62 * Total LEDs: 32
63 * Indicator LEDs: 32 (various jettison station indicators)
64 * @remark This class inherits from the "basic" Panel class in panels/Panel.h
65 * It also enforces a singleton pattern; this is required to use DCS-BIOS callbacks in class methods.
66 * @see Panel.h for the base class implementation
67 ********************************************************************************************************************/
68class JettStationPanel : public Panel {
69public:
77 static JettStationPanel* getInstance(int startIndex = 0, CRGB* ledStrip = nullptr) {
78 if (!instance) {
79 instance = new JettStationPanel(startIndex, ledStrip);
80 }
81 return instance;
82 }
83
84private:
91 JettStationPanel(int startIndex, CRGB* ledStrip) {
92 panelStartIndex = startIndex;
93 this->ledStrip = ledStrip;
94 ledCount = JETT_STATION_LED_COUNT;
95 ledTable = jettStationLedTable;
96 }
97
98 // Static callback functions for DCS-BIOS
99
100 // STATION JETTISON SELECT panel indicators
101 static void onSjRoLtChange(unsigned int newValue) {
102 if (instance) instance->setIndicatorColor(LED_JETT_RO_1, newValue ? NVIS_WHITE : NVIS_BLACK);
103 }
104 DcsBios::IntegerBuffer sjRoLtBuffer{FA_18C_hornet_SJ_RO_LT, onSjRoLtChange};
105
106 static void onSjRiLtChange(unsigned int newValue) {
107 if (instance) instance->setIndicatorColor(LED_JETT_RI_1, newValue ? NVIS_WHITE : NVIS_BLACK);
108 }
109 DcsBios::IntegerBuffer sjRiLtBuffer{FA_18C_hornet_SJ_RI_LT, onSjRiLtChange};
110
111 static void onSjCtrLtChange(unsigned int newValue) {
112 if (instance) instance->setIndicatorColor(LED_JETT_CTR_1, newValue ? NVIS_WHITE : NVIS_BLACK);
113 }
114 DcsBios::IntegerBuffer sjCtrLtBuffer{FA_18C_hornet_SJ_CTR_LT, onSjCtrLtChange};
115
116 static void onSjLiLtChange(unsigned int newValue) {
117 if (instance) instance->setIndicatorColor(LED_JETT_LI_1, newValue ? NVIS_WHITE : NVIS_BLACK);
118 }
119 DcsBios::IntegerBuffer sjLiLtBuffer{FA_18C_hornet_SJ_LI_LT, onSjLiLtChange};
120
121 static void onSjLoLtChange(unsigned int newValue) {
122 if (instance) instance->setIndicatorColor(LED_JETT_LO_1, newValue ? NVIS_WHITE : NVIS_BLACK);
123 }
124 DcsBios::IntegerBuffer sjLoLtBuffer{FA_18C_hornet_SJ_LO_LT, onSjLoLtChange};
125
126 // STORES INDICATOR panel
127 static void onFlpLgNoseGearLtChange(unsigned int newValue) {
128 if (instance) instance->setIndicatorColor(LED_JETT_NOSE, newValue ? NVIS_GREEN_A : NVIS_BLACK);
129 }
130 DcsBios::IntegerBuffer flpLgNoseGearLtBuffer{FA_18C_hornet_FLP_LG_NOSE_GEAR_LT, onFlpLgNoseGearLtChange};
131
132 static void onFlpLgRightGearLtChange(unsigned int newValue) {
133 if (instance) instance->setIndicatorColor(LED_JETT_RIGHT, newValue ? NVIS_GREEN_A : NVIS_BLACK);
134 }
135 DcsBios::IntegerBuffer flpLgRightGearLtBuffer{FA_18C_hornet_FLP_LG_RIGHT_GEAR_LT, onFlpLgRightGearLtChange};
136
137 static void onFlpLgLeftGearLtChange(unsigned int newValue) {
138 if (instance) instance->setIndicatorColor(LED_JETT_LEFT, newValue ? NVIS_GREEN_A : NVIS_BLACK);
139 }
140 DcsBios::IntegerBuffer flpLgLeftGearLtBuffer{FA_18C_hornet_FLP_LG_LEFT_GEAR_LT, onFlpLgLeftGearLtChange};
141
142 static void onFlpLgHalfFlapsLtChange(unsigned int newValue) {
143 if (instance) instance->setIndicatorColor(LED_JETT_HALF, newValue ? NVIS_GREEN_A : NVIS_BLACK);
144 }
145 DcsBios::IntegerBuffer flpLgHalfFlapsLtBuffer{FA_18C_hornet_FLP_LG_HALF_FLAPS_LT, onFlpLgHalfFlapsLtChange};
146
147 static void onFlpLgFullFlapsLtChange(unsigned int newValue) {
148 if (instance) instance->setIndicatorColor(LED_JETT_FULL, newValue ? NVIS_GREEN_A : NVIS_BLACK);
149 }
150 DcsBios::IntegerBuffer flpLgFullFlapsLtBuffer{FA_18C_hornet_FLP_LG_FULL_FLAPS_LT, onFlpLgFullFlapsLtChange};
151
152 static void onFlpLgFlapsLtChange(unsigned int newValue) {
153 if (instance) instance->setIndicatorColor(LED_JETT_FLAPS, newValue ? NVIS_YELLOW : NVIS_BLACK);
154 }
155 DcsBios::IntegerBuffer flpLgFlapsLtBuffer{FA_18C_hornet_FLP_LG_FLAPS_LT, onFlpLgFlapsLtChange};
156
157
158 // Member variables to track state
159 unsigned int cockpitLightMode = 0; // 0=NVG, 1=NITE, 2=DAY
160 bool instrIntLtActive = false; // Whether instrument lights are on
161
162 // Helper method to update LEDs based on both cockpit mode and instrument light state
163 void updateJettStationLeds() {
164 if (!instance) return;
165
166 // Determine color based on cockpit light mode
167 // 2 = NVG, 1 = NITE -> NVIS_GREEN_A
168 // 0 = DAY -> NVIS_WHITE
169 CRGB activeColor = (cockpitLightMode >= 1) ? NVIS_GREEN_A : NVIS_WHITE;
170 CRGB targetColor = instrIntLtActive ? activeColor : NVIS_BLACK;
171
172 instance->setIndicatorColor(LED_JETT_RO_2, targetColor);
173 instance->setIndicatorColor(LED_JETT_RI_2, targetColor);
174 instance->setIndicatorColor(LED_JETT_CTR_2, targetColor);
175 instance->setIndicatorColor(LED_JETT_LI_2, targetColor);
176 instance->setIndicatorColor(LED_JETT_LO_2, targetColor);
177 }
178
179 // Controlling the upper LEDs (RO_2, RI_2, CTR_2, LI_2, LO_2)
180 // These are controlled by backlight brightness value from DCS BIOS
181 // and the cockpit light mode (NVG/NITE vs DAY)
182 static void onInstrIntLtChange(unsigned int newValue) {
183 if (instance) {
184 instance->instrIntLtActive = (newValue > 0);
185 instance->updateJettStationLeds();
186 }
187 }
188 DcsBios::IntegerBuffer instrIntLtBuffer{FA_18C_hornet_INSTR_INT_LT, onInstrIntLtChange};
189
190 static void onCockkpitLightModeSwChange(unsigned int newValue) {
191 if (instance) {
192 instance->cockpitLightMode = newValue;
193 instance->updateJettStationLeds();
194 }
195 }
196 DcsBios::IntegerBuffer cockkpitLightModeSwBuffer{FA_18C_hornet_COCKKPIT_LIGHT_MODE_SW, onCockkpitLightModeSwChange};
197
198 // Instance data
199 static JettStationPanel* instance;
200};
201
202// Initialize static instance pointer
203JettStationPanel* JettStationPanel::instance = nullptr;
204
205#endif
static JettStationPanel * getInstance(int startIndex=0, CRGB *ledStrip=nullptr)
Gets the singleton instance of the JettStationPanel class.
Definition Panel.h:41
void setIndicatorColor(LedRole role, const CRGB &color)
Sets the color of LEDs with a specific role.
Definition Panel.h:156