API Documentation v0.0.1
Loading...
Searching...
No Matches
Channel Class Reference

Public Member Functions

 Channel (uint8_t p, const char *pcb, CRGB *ledArray, uint16_t count)
 Constructor for the Channel class.
 
void initialize ()
 Initializes the LED strip with FastLED.
 
template<typename PanelType >
void addPanel ()
 Adds a panel to the channel's linked list.
 
uint8_t getPin () const
 Gets the pin number for this channel.
 
const char * getPcbName () const
 Gets the PCB name for this channel.
 
uint16_t getLedCount () const
 Gets the number of LEDs in this channel.
 
CRGB * getLeds () const
 Gets the LED array for this channel.
 
PanelgetFirstPanel () const
 Gets the first panel in the channel's linked list.
 
uint8_t getPanelCount () const
 Gets the number of panels in this channel.
 
void updateInstrLights (uint16_t brightness, const CRGB &color=NVIS_GREEN_A)
 Updates backlights for all panels in this channel.
 
void updateConsoleLights (uint16_t brightness, const CRGB &color=NVIS_GREEN_A)
 Updates console lights for all panels in this channel.
 
void updateFloodLights (uint16_t brightness)
 Updates flood lights for all panels in this channel.
 
void setAllLightsOff ()
 Turns off all lights in all panels of this channel and resets brightness state.
 

Detailed Description

Definition at line 35 of file Channel.h.

Constructor & Destructor Documentation

◆ Channel()

Channel::Channel ( uint8_t p,
const char * pcb,
CRGB * ledArray,
uint16_t count )
inline

Constructor for the Channel class.

Parameters
pPin number for the LED strip
pcbName of the PCB this channel is connected to
ledArrayPointer to the LED array
countNumber of LEDs in the strip

Definition at line 54 of file Channel.h.

54 {
55 pin = p;
56 pcbName = pcb;
57 leds = ledArray; // Store pointer to the static array
58 ledCount = count;
59 currentIndex = 0; // Initialize currentIndex to 0
60 firstPanel = nullptr; // Initialize first panel pointer
61 panelCount = 0; // Initialize panel count
62 }

Member Function Documentation

◆ initialize()

void Channel::initialize ( )
inline

Initializes the LED strip with FastLED.

See also
This method is called during setup in 2A13-BACKLIGHT_CONTROLLER.ino

Definition at line 68 of file Channel.h.

68 {
69 // Use a switch statement to overcome strange behaviour of FastLED to have a pin number at compile time
70 switch(pin) {
71 case 4: FastLED.addLeds<WS2812B, 4, GRB>(leds, ledCount); break;
72 case 5: FastLED.addLeds<WS2812B, 5, GRB>(leds, ledCount); break;
73 case 6: FastLED.addLeds<WS2812B, 6, GRB>(leds, ledCount); break;
74 case 7: FastLED.addLeds<WS2812B, 7, GRB>(leds, ledCount); break;
75 case 8: FastLED.addLeds<WS2812B, 8, GRB>(leds, ledCount); break;
76 case 9: FastLED.addLeds<WS2812B, 9, GRB>(leds, ledCount); break;
77 case 10: FastLED.addLeds<WS2812B, 10, GRB>(leds, ledCount); break;
78 case 11: FastLED.addLeds<WS2812B, 11, GRB>(leds, ledCount); break;
79 case 12: FastLED.addLeds<WS2812B, 12, GRB>(leds, ledCount); break;
80 case 13: FastLED.addLeds<WS2812B, 13, GRB>(leds, ledCount); break;
81 default: break; // Handle invalid pin
82 }
83
84 fill_solid(leds, ledCount, NVIS_BLACK);
85 }

◆ addPanel()

template<typename PanelType >
void Channel::addPanel ( )
inline

Adds a panel to the channel's linked list.

Template Parameters
PanelTypeThe type of panel to add
See also
This method is called by setup() in 2A13-BACKLIGHT_CONTROLLER.ino

Definition at line 93 of file Channel.h.

93 {
94 PanelType* panel = PanelType::getInstance(currentIndex, leds);
95
96 // Safety check: Ensure we don't exceed the channel's LED capacity
97 if (currentIndex + panel->getLedCount() > ledCount) {
98 // Halt execution and indicate error with LED pattern
99 while(1) {
100 digitalWrite(LED_BUILTIN, HIGH);
101 delay(100);
102 digitalWrite(LED_BUILTIN, LOW);
103 delay(100);
104 }
105 }
106
107 // Add panel to linked list
108 if (firstPanel == nullptr) {
109 firstPanel = panel; // First panel in the channel
110 } else {
111 // Find the last panel
112 Panel* currentPanel = firstPanel;
113 while (currentPanel->nextPanel != nullptr) {
114 currentPanel = currentPanel->nextPanel;
115 }
116 currentPanel->nextPanel = panel; // Add new panel at the end
117 }
118
119 panelCount++;
120 currentIndex += panel->getLedCount();
121 }
Definition Panel.h:41

◆ getPin()

uint8_t Channel::getPin ( ) const
inline

Gets the pin number for this channel.

Returns
The pin number

Definition at line 128 of file Channel.h.

128{ return pin; }

◆ getPcbName()

const char * Channel::getPcbName ( ) const
inline

Gets the PCB name for this channel.

Returns
The PCB name

Definition at line 134 of file Channel.h.

134{ return pcbName; }

◆ getLedCount()

uint16_t Channel::getLedCount ( ) const
inline

Gets the number of LEDs in this channel.

Returns
The LED count

Definition at line 140 of file Channel.h.

140{ return ledCount; }

◆ getLeds()

CRGB * Channel::getLeds ( ) const
inline

Gets the LED array for this channel.

Returns
Pointer to the LED array

Definition at line 146 of file Channel.h.

146{ return leds; }

◆ getFirstPanel()

Panel * Channel::getFirstPanel ( ) const
inline

Gets the first panel in the channel's linked list.

Returns
Pointer to the first panel

Definition at line 152 of file Channel.h.

152{ return firstPanel; }

◆ getPanelCount()

uint8_t Channel::getPanelCount ( ) const
inline

Gets the number of panels in this channel.

Returns
The panel count

Definition at line 158 of file Channel.h.

158{ return panelCount; }

◆ updateInstrLights()

void Channel::updateInstrLights ( uint16_t brightness,
const CRGB & color = NVIS_GREEN_A )
inline

Updates backlights for all panels in this channel.

Parameters
brightnessThe brightness value to set
colorThe color to set (defaults to NVIS_GREEN_A)
See also
This method is called by Board::fillSolid() and Board::updateInstrumentLights()

Definition at line 166 of file Channel.h.

166 {
167 Panel* current = firstPanel;
168 while (current != nullptr) {
169 current->setInstrLights(brightness, color);
170 current = current->nextPanel;
171 }
172 }
void setInstrLights(uint16_t newValue, const CRGB &color=NVIS_GREEN_A)
Set the color of all instrument backlight LEDs.
Definition Panel.h:99

References Panel::setInstrLights().

Referenced by Board::fillSolid(), Board::processMode(), and Board::updateInstrumentLights().

◆ updateConsoleLights()

void Channel::updateConsoleLights ( uint16_t brightness,
const CRGB & color = NVIS_GREEN_A )
inline

Updates console lights for all panels in this channel.

Parameters
brightnessThe brightness value to set
colorThe color to set (defaults to NVIS_GREEN_A)
See also
This method is called by Board::updateConsoleLights()

Definition at line 180 of file Channel.h.

180 {
181 Panel* current = firstPanel;
182 while (current != nullptr) {
183 current->setConsoleLights(brightness, color);
184 current = current->nextPanel;
185 }
186 }
void setConsoleLights(uint16_t newValue, const CRGB &color=NVIS_GREEN_A)
Sets the color of all console backlight LEDs.
Definition Panel.h:130

References Panel::setConsoleLights().

Referenced by Board::fillSolid(), Board::processMode(), and Board::updateConsoleLights().

◆ updateFloodLights()

void Channel::updateFloodLights ( uint16_t brightness)
inline

Updates flood lights for all panels in this channel.

Parameters
brightnessThe brightness value to set
See also
This method is called by Board::updateFloodLights()

Definition at line 193 of file Channel.h.

193 {
194 Panel* current = firstPanel;
195 while (current != nullptr) {
196 current->setFloodlights(brightness);
197 current = current->nextPanel;
198 }
199 }
void setFloodlights(uint16_t newValue)
Sets the brightness of floodlight LEDs.
Definition Panel.h:175

References Panel::setFloodlights().

Referenced by Board::processMode(), and Board::updateFloodLights().

◆ setAllLightsOff()

void Channel::setAllLightsOff ( )
inline

Turns off all lights in all panels of this channel and resets brightness state.

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

Definition at line 205 of file Channel.h.

205 {
206 // Clear all LEDs in the entire channel array (not just panel-tracked ones)
207 fill_solid(leds, ledCount, NVIS_BLACK);
208
209 // Also clear panel-tracked LEDs and reset brightness state
210 Panel* current = firstPanel;
211 while (current != nullptr) {
212 current->setAllLightsOff();
213 current = current->nextPanel;
214 }
215 }
void setAllLightsOff()
Turns off all lights in this panel, irrespective of their role, and resets brightness state.
Definition Panel.h:201

References Panel::setAllLightsOff().

Referenced by Board::setAllLightsOff().


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