Viking Skull Lamp  V1.0.1
Loading...
Searching...
No Matches
lightControl.cpp File Reference
#include "lightControl.hpp"

Go to the source code of this file.

Functions

void lightInit ()
 Initialize the LEDs. More...
 
void lightOn ()
 Turn on the lighting. More...
 
void lightOff ()
 Turn off the lighting. More...
 
void lightToggle ()
 Toggle the lighting. More...
 
void lightUpdate ()
 Update function for the lighting. More...
 
void lightModeRainbowUpdate ()
 Update function for the rainbow mode. More...
 
void lightModeCandleUpdate ()
 Update function for the candle mode. More...
 
void lightModePulseUpdate ()
 Update function for the pulse mode. More...
 
void lightModeMusicUpdate ()
 Update function for the music mode. More...
 
void lightModeKomodoUpdate ()
 Update function for the komodo mode. More...
 
void lightModeColorUpdate ()
 Update function for the color mode. More...
 

Variables

CRGB stripLightBuffer [LIGHT_STRIP_SIZE]
 Pixel buffer for the LED strip. More...
 
CRGB skullLightBuffer [LIGHT_SKULL_SIZE]
 Pixel buffer for the LED disc. More...
 
unsigned long lightTimer = 0
 Stores the last system time when the last light update event happened. More...
 
unsigned long sampleTimer = 0
 Stores the last system time when the last sample update event happened. More...
 
int fadeDirection = 0
 Stores the direction and speed of the fading. More...
 
int fadedBrightness = 0
 The actual brightness of the strips are calculated to this variable. More...
 
bool lightStateOn = false
 This is a flag, that shows the actual state of the lighting. More...
 
bool prevPeak = false
 Flag for peak detection. It is used for the clap detection. More...
 
bool prevBeat = false
 Flag for beat detection. It is used for the music visualizer. More...
 
unsigned long peakTimes [4] = { 0 }
 This array is used for the clap detection. More...
 

Function Documentation

◆ lightInit()

void lightInit ( )

Initialize the LEDs.

Definition at line 67 of file lightControl.cpp.

Here is the caller graph for this function:

◆ lightModeCandleUpdate()

void lightModeCandleUpdate ( )

Update function for the candle mode.

Tis function handles the animations and lighting for the candle mode. It has to be called by the lightUpdate function when the candle mode is selected.

Note
This function uses the HSV color space.
I used it because it is much easier to animate, than the regular RGB color space.
See also
lightMode_t

Definition at line 304 of file lightControl.cpp.

Here is the caller graph for this function:

◆ lightModeColorUpdate()

void lightModeColorUpdate ( )

Update function for the color mode.

Tis function handles the animations and lighting for the color mode. It has to be called by the lightUpdate function when the color mode is selected.

See also
lightMode_t

Definition at line 600 of file lightControl.cpp.

Here is the caller graph for this function:

◆ lightModeKomodoUpdate()

void lightModeKomodoUpdate ( )

Update function for the komodo mode.

Tis function handles the animations and lighting for the komodo mode. It has to be called by the lightUpdate function when the komodo mode is selected. The name come from Malcolm in the Middle

See also
lightMode_t

Definition at line 580 of file lightControl.cpp.

Here is the caller graph for this function:

◆ lightModeMusicUpdate()

void lightModeMusicUpdate ( )

Update function for the music mode.

Tis function handles the animations and lighting for the music mode. It has to be called by the lightUpdate function when the music mode is selected.

See also
lightMode_t

Definition at line 449 of file lightControl.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lightModePulseUpdate()

void lightModePulseUpdate ( )

Update function for the pulse mode.

Tis function handles the animations and lighting for the pulse mode. It has to be called by the lightUpdate function when the pulse mode is selected.

Note
This function uses the HSV color space.
I used it because it is much easier to animate, than the regular RGB color space.
See also
lightMode_t

Definition at line 355 of file lightControl.cpp.

Here is the caller graph for this function:

◆ lightModeRainbowUpdate()

void lightModeRainbowUpdate ( )

Update function for the rainbow mode.

Tis function handles the animations and lighting for the rainbow mode. It has to be called by the lightUpdate function when the rainbow mode is selected.

Note
This function uses the HSV color space.
I used it because it is much easier to animate, than the regular RGB color space.
See also
lightMode_t

Definition at line 269 of file lightControl.cpp.

Here is the caller graph for this function:

◆ lightOff()

void lightOff ( )

Turn off the lighting.

If you want to turn off the lights, you have to call this function.

Definition at line 85 of file lightControl.cpp.

Here is the caller graph for this function:

◆ lightOn()

void lightOn ( )

Turn on the lighting.

If you want to turn on the lights, you have to call this function.

Definition at line 79 of file lightControl.cpp.

Here is the caller graph for this function:

◆ lightToggle()

void lightToggle ( )

Toggle the lighting.

If you want to toggle the lights, you have to call this function.

Definition at line 92 of file lightControl.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lightUpdate()

void lightUpdate ( )

Update function for the lighting.

This function handles all the animations and effects for the specific light modes. Also it tries to recognise the clap pattern for the clap switch.

Definition at line 108 of file lightControl.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ fadedBrightness

int fadedBrightness = 0

The actual brightness of the strips are calculated to this variable.

It is required because of the fading effets.

Definition at line 50 of file lightControl.cpp.

◆ fadeDirection

int fadeDirection = 0

Stores the direction and speed of the fading.

Definition at line 45 of file lightControl.cpp.

◆ lightStateOn

bool lightStateOn = false

This is a flag, that shows the actual state of the lighting.

Definition at line 53 of file lightControl.cpp.

◆ lightTimer

unsigned long lightTimer = 0

Stores the last system time when the last light update event happened.

Definition at line 39 of file lightControl.cpp.

◆ peakTimes

unsigned long peakTimes[4] = { 0 }

This array is used for the clap detection.

It is a circular buffer, that stores the previous four system time, when a peak is detected. The element 3 is the latest peak time, the element 0 is the oldest.

Definition at line 65 of file lightControl.cpp.

◆ prevBeat

bool prevBeat = false

Flag for beat detection. It is used for the music visualizer.

Definition at line 59 of file lightControl.cpp.

◆ prevPeak

bool prevPeak = false

Flag for peak detection. It is used for the clap detection.

Definition at line 56 of file lightControl.cpp.

◆ sampleTimer

unsigned long sampleTimer = 0

Stores the last system time when the last sample update event happened.

Definition at line 42 of file lightControl.cpp.

◆ skullLightBuffer

CRGB skullLightBuffer[LIGHT_SKULL_SIZE]

Pixel buffer for the LED disc.

Definition at line 36 of file lightControl.cpp.

◆ stripLightBuffer

CRGB stripLightBuffer[LIGHT_STRIP_SIZE]

Pixel buffer for the LED strip.

Definition at line 33 of file lightControl.cpp.