Skip to content

Commit

Permalink
Added mirror_pix_freq pattern
Browse files Browse the repository at this point in the history
Updated pattern array, added function in patterns.c and patterns.h
  • Loading branch information
ndruwi committed Dec 11, 2023
1 parent 784cfcb commit 47363f0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ Pattern mainPatterns[]{
{33, "Classical", true, classical},
{34, "Basic Bands", true, basic_bands},
{35, "Advanced Bands", true, advanced_bands},
{36, "Formant Band", true, formant_band}
{36, "Formant Band", true, formant_band},
{37, "Mirrored Pixel Frequency", true, mirror_pix_freq}
};
int NUM_PATTERNS = 37; // MAKE SURE TO UPDATE THIS WITH THE ACTUAL NUMBER OF PATTERNS
int NUM_PATTERNS = 38; // MAKE SURE TO UPDATE THIS WITH THE ACTUAL NUMBER OF PATTERNS (+1 last array pos)

SimplePatternList gPatterns_layer = {blank, spring_mass_1};

Expand Down
26 changes: 26 additions & 0 deletions main/patterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,32 @@ void pix_freq() {
leds[current_history.pix_pos] = current_history.pix_pos < virtual_led_count ? CHSV(current_history.tempHue, 255, 255):CRGB(0, 0, 0);
}

// A mirroed version of the pix_freq, splittion it on two sides starting from the middle
void mirror_pix_freq() {
fadeToBlackBy(leds, virtual_led_count, 50);

if (volume > 125) {
current_history.pix_pos = (virtual_led_count / 2) + map(peak, MIN_FREQUENCY, MAX_FREQUENCY, -virtual_led_count/2 , virtual_led_count / 2);
current_history.tempHue = fHue;

} else {
current_history.pix_pos--;
current_history.vol_pos--;
}
if (vol_show) {
if (volume > 75) {
current_history.vol_pos = (virtual_led_count / 2) + map(volume, MIN_VOLUME, MAX_VOLUME, virtual_led_count/2 , virtual_led_count / 2);
current_history.tempHue = fHue;
} else {
current_history.vol_pos--;
}
leds[virtual_led_count / 2 - 1 - current_history.vol_pos] = current_history.vol_pos < virtual_led_count/2 ? CRGB(255, 255, 255):CRGB(0, 0, 0);
leds[virtual_led_count / 2 + 1 + current_history.vol_pos] = current_history.vol_pos < virtual_led_count/2 ? CRGB(255, 255, 255):CRGB(0, 0, 0);
}
leds[virtual_led_count/2 - 1 - current_history.pix_pos] = current_history.pix_pos < virtual_led_count/2 ? CHSV(current_history.tempHue, 255, 255):CRGB(0, 0, 0);
leds[virtual_led_count/2 + 1 + current_history.pix_pos] = current_history.pix_pos < virtual_led_count/2 ? CHSV(current_history.tempHue, 255, 255):CRGB(0, 0, 0);
}

// Utility function for sending a wave with sine for the math rock function
void send_wave() {
double change_by = vbrightness;
Expand Down
2 changes: 2 additions & 0 deletions main/patterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void classical();

void pix_freq();

void mirror_pix_freq();

void send_wave();

void math();
Expand Down

0 comments on commit 47363f0

Please sign in to comment.