API Documentation v0.0.1
Loading...
Searching...
No Matches
Panel Class Reference
+ Inheritance diagram for Panel:

Public Member Functions

virtual int getStartIndex () const
 Gets the start index of this panel on the LED strip.
 
virtual int getLedCount () const
 Gets the number of LEDs in this panel.
 
virtual const LedgetLedTable () const
 Gets the LED table for this panel.
 
virtual CRGB * getLedStrip () const
 Gets the LED strip for this panel.
 

Protected Member Functions

 Panel ()
 Protected constructor to prevent direct instantiation.
 
void setInstrLights (uint16_t newValue, const CRGB &color=NVIS_GREEN_A)
 Set the color of all instrument backlight LEDs.
 
void setConsoleLights (uint16_t newValue, const CRGB &color=NVIS_GREEN_A)
 Sets the color of all console backlight LEDs.
 
void setIndicatorColor (LedRole role, const CRGB &color)
 Sets the color of LEDs with a specific role.
 
void setFloodlights (uint16_t newValue)
 Sets the brightness of floodlight LEDs.
 
void setAllLightsOff ()
 Turns off all lights in this panel, irrespective of their role, and resets brightness state.
 

Protected Attributes

int panelStartIndex
 
int ledCount
 
const LedledTable
 
CRGB * ledStrip
 
uint16_t current_backl_brightness
 
uint16_t current_console_brightness
 
uint16_t current_flood_brightness
 
PanelnextPanel
 

Friends

class Channel
 

Detailed Description

Definition at line 41 of file Panel.h.

Constructor & Destructor Documentation

◆ Panel()

Panel::Panel ( )
inlineprotected

Protected constructor to prevent direct instantiation.

See also
This method is called by derived panel classes

Definition at line 75 of file Panel.h.

75 {
76 current_backl_brightness = 0;
77 current_console_brightness = 0;
78 current_flood_brightness = 0;
79 nextPanel = nullptr; // Initialize next panel pointer
80 }

Member Function Documentation

◆ getStartIndex()

virtual int Panel::getStartIndex ( ) const
inlinevirtual

Gets the start index of this panel on the LED strip.

Returns
The start index

Definition at line 47 of file Panel.h.

47{ return panelStartIndex; }

Referenced by setAllLightsOff(), setConsoleLights(), setFloodlights(), setIndicatorColor(), and setInstrLights().

◆ getLedCount()

virtual int Panel::getLedCount ( ) const
inlinevirtual

Gets the number of LEDs in this panel.

Returns
The LED count

Reimplemented in LdgGearPanel, and SelectJettPanel.

Definition at line 53 of file Panel.h.

53{ return ledCount; }

Referenced by setAllLightsOff(), setConsoleLights(), setFloodlights(), setIndicatorColor(), and setInstrLights().

◆ getLedTable()

virtual const Led * Panel::getLedTable ( ) const
inlinevirtual

Gets the LED table for this panel.

Returns
Pointer to the LED table

Reimplemented in LdgGearPanel, and SelectJettPanel.

Definition at line 59 of file Panel.h.

59{ return ledTable; }

Referenced by setAllLightsOff(), setConsoleLights(), setFloodlights(), setIndicatorColor(), and setInstrLights().

◆ getLedStrip()

virtual CRGB * Panel::getLedStrip ( ) const
inlinevirtual

Gets the LED strip for this panel.

Returns
Pointer to the LED strip

Definition at line 65 of file Panel.h.

65{ return ledStrip; }

Referenced by setAllLightsOff(), setConsoleLights(), setFloodlights(), setIndicatorColor(), and setInstrLights().

◆ setInstrLights()

void Panel::setInstrLights ( uint16_t newValue,
const CRGB & color = NVIS_GREEN_A )
inlineprotected

Set the color of all instrument backlight LEDs.

Parameters
newValueThe new brightness value (0-65535)
colorThe color to set (defaults to NVIS_GREEN_A)
See also
This method is called by Channel::updateInstrLights()

Definition at line 99 of file Panel.h.

99 {
100 if (!getLedStrip() || !getLedTable()) return; // Safety checks
101 if (newValue == current_backl_brightness) return; // Exit if no brightness change
102 int scale = map(newValue, 0, 65535, 0, 255); // Map the brightness scale factor to a range of 0-255
103 CRGB target = color;
104 target.nscale8_video(scale); // Use FastLED's nscale8_video to apply the scale factor
105 CRGB target2 = NVIS_CGRB_GREEN_A; // For GRB LEDs (e.g. Radar Altimeter and Standby Instruments)
106 target2.nscale8_video(scale);
107 current_backl_brightness = newValue; // Update and save the current brightness value
108
109 int n = getLedCount();
110 for (int i = 0; i < n; i++) { // For each LED, read info from PROGMEM; if LED is BACKLIGHT, set color
111 Led led;
112 memcpy_P(&led, &getLedTable()[i], sizeof(Led)); // getLedTable() accesses the panel's LED table
113 uint16_t ledIndex = led.index + getStartIndex();
114 if (led.role == LED_INSTR_BL) {
115 getLedStrip()[ledIndex] = target;
116 }
117 if (led.role == LED_INSTR_BL_CGRB) {
118 getLedStrip()[ledIndex] = target2;
119 }
120 }
121 LedUpdateState::getInstance()->setUpdateFlag(true); // Inform that LEDs need to be updated
122 }
void setUpdateFlag(bool requireUpdate)
Sets the LED update flag in an atomic operation.
static LedUpdateState * getInstance()
Gets the singleton instance of the LedUpdateState class.
virtual const Led * getLedTable() const
Gets the LED table for this panel.
Definition Panel.h:59
virtual int getLedCount() const
Gets the number of LEDs in this panel.
Definition Panel.h:53
virtual CRGB * getLedStrip() const
Gets the LED strip for this panel.
Definition Panel.h:65
virtual int getStartIndex() const
Gets the start index of this panel on the LED strip.
Definition Panel.h:47

References LedUpdateState::getInstance(), getLedCount(), getLedStrip(), getLedTable(), getStartIndex(), and LedUpdateState::setUpdateFlag().

Referenced by Channel::updateInstrLights().

◆ setConsoleLights()

void Panel::setConsoleLights ( uint16_t newValue,
const CRGB & color = NVIS_GREEN_A )
inlineprotected

Sets the color of all console backlight LEDs.

Parameters
newValueThe new brightness value (0-65535)
colorThe color to set (defaults to NVIS_GREEN_A)
See also
This method is called by Channel::updateConsoleLights()

Definition at line 130 of file Panel.h.

130 { // Set the color of all LEDs with role LED_CONSOLE_BL
131 if (!getLedStrip() || !getLedTable()) return; // Safety checks
132 if (newValue == current_console_brightness) return; // Exit if no brightness change
133 int scale = map(newValue, 0, 65535, 0, 255); // Map the brightness scale factor to a range of 0-255
134 CRGB target = color;
135 target.nscale8_video(scale); // Use FastLED's nscale8_video to apply the scale factor
136 current_console_brightness = newValue; // Update and save the current brightness value
137
138 int n = getLedCount();
139 for (int i = 0; i < n; i++) { // For each LED, read info from PROGMEM; if LED is BACKLIGHT, set color
140 Led led;
141 memcpy_P(&led, &getLedTable()[i], sizeof(Led)); // getLedTable() accesses the panel's LED table
142 uint16_t ledIndex = led.index + getStartIndex();
143 if (led.role == LED_CONSOLE_BL) {
144 getLedStrip()[ledIndex] = target;
145 }
146 }
147 LedUpdateState::getInstance()->setUpdateFlag(true); // Inform that LEDs need to be updated
148 }

References LedUpdateState::getInstance(), getLedCount(), getLedStrip(), getLedTable(), getStartIndex(), and LedUpdateState::setUpdateFlag().

Referenced by Channel::updateConsoleLights().

◆ setIndicatorColor()

void Panel::setIndicatorColor ( LedRole role,
const CRGB & color )
inlineprotected

Sets the color of LEDs with a specific role.

Parameters
roleThe role of LEDs to update
colorThe color to set
See also
This method is called by derived panel classes to update indicator lights

Definition at line 156 of file Panel.h.

156 { // Set color of specific LEDs ("role" parameter)
157 if (!getLedStrip() || !getLedTable()) return;
158 int n = getLedCount();
159 for (int i = 0; i < n; i++) {
160 Led led;
161 memcpy_P(&led, &getLedTable()[i], sizeof(Led));
162 uint16_t ledIndex = led.index + getStartIndex();
163 if (led.role == role) {
164 getLedStrip()[ledIndex] = color;
165 }
166 }
167 LedUpdateState::getInstance()->setUpdateFlag(true); // Inform that LEDs need to be updated
168 }

References LedUpdateState::getInstance(), getLedCount(), getLedStrip(), getLedTable(), getStartIndex(), and LedUpdateState::setUpdateFlag().

◆ setFloodlights()

void Panel::setFloodlights ( uint16_t newValue)
inlineprotected

Sets the brightness of floodlight LEDs.

Parameters
newValueThe new brightness value (0-65535)
See also
This method is called by Channel::updateFloodLights()

Definition at line 175 of file Panel.h.

175 { // Set the brightness of LEDs with role LED_FLOOD
176 if (!getLedStrip() || !getLedTable()) return; // Same structure as setInstrLights()
177 if (newValue == current_flood_brightness) return;
178 current_flood_brightness = newValue;
179
180 uint8_t scale = map(newValue, 0, 65535, 0, 255);
181
182 CRGB target = NVIS_WHITE;
183 target.nscale8_video(scale);
184
185 int n = getLedCount();
186 for (int i = 0; i < n; i++) {
187 Led led;
188 memcpy_P(&led, &getLedTable()[i], sizeof(Led));
189 uint16_t ledIndex = led.index + getStartIndex();
190 if (led.role == LED_FLOOD) {
191 getLedStrip()[ledIndex] = target;
192 }
193 }
194 LedUpdateState::getInstance()->setUpdateFlag(true); // Inform that LEDs need to be updated
195 }

References LedUpdateState::getInstance(), getLedCount(), getLedStrip(), getLedTable(), getStartIndex(), and LedUpdateState::setUpdateFlag().

Referenced by Channel::updateFloodLights().

◆ setAllLightsOff()

void Panel::setAllLightsOff ( )
inlineprotected

Turns off all lights in this panel, irrespective of their role, and resets brightness state.

See also
This method is called by Channel::setAllLightsOff()

Definition at line 201 of file Panel.h.

201 { // Turn off all lights and reset brightness state
202 if (!getLedStrip() || !getLedTable()) return; // Safety checks
203
204 CRGB* ledArray = getLedStrip();
205 int startIndex = getStartIndex();
206 int panelLedCount = getLedCount();
207
208 for (int i = 0; i < panelLedCount; i++) {
209 ledArray[startIndex + i] = NVIS_BLACK;
210 }
211
212 // Reset all brightness variables to 0
213 current_backl_brightness = 0;
214 current_console_brightness = 0;
215 current_flood_brightness = 0;
216
217 LedUpdateState::getInstance()->setUpdateFlag(true); // Inform that LEDs need to be updated
218 }

References LedUpdateState::getInstance(), getLedCount(), getLedStrip(), getLedTable(), getStartIndex(), and LedUpdateState::setUpdateFlag().

Referenced by Channel::setAllLightsOff().

Friends And Related Symbol Documentation

◆ Channel

friend class Channel
friend

Definition at line 68 of file Panel.h.

Member Data Documentation

◆ panelStartIndex

int Panel::panelStartIndex
protected

Definition at line 83 of file Panel.h.

◆ ledCount

int Panel::ledCount
protected

Definition at line 84 of file Panel.h.

◆ ledTable

const Led* Panel::ledTable
protected

Definition at line 85 of file Panel.h.

◆ ledStrip

CRGB* Panel::ledStrip
protected

Definition at line 86 of file Panel.h.

◆ current_backl_brightness

uint16_t Panel::current_backl_brightness
protected

Definition at line 87 of file Panel.h.

◆ current_console_brightness

uint16_t Panel::current_console_brightness
protected

Definition at line 88 of file Panel.h.

◆ current_flood_brightness

uint16_t Panel::current_flood_brightness
protected

Definition at line 89 of file Panel.h.

◆ nextPanel

Panel* Panel::nextPanel
protected

Definition at line 90 of file Panel.h.


The documentation for this class was generated from the following file: