Skip to content

Commit

Permalink
Renamed "lightshow modes" to "light modes"
Browse files Browse the repository at this point in the history
  • Loading branch information
connornishijima committed May 7, 2024
1 parent 1438aa6 commit 219ac17
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 48 deletions.
29 changes: 17 additions & 12 deletions src/EMOTISCOPE_FIRMWARE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,45 @@
// Released under the GPLv3 License
//
// ############################################################################
// ## GETTING STARTED #########################################################
// ## FOREWORD ################################################################
//
// Welcome to the Emotiscope Engine. This is firmware which:
//
// - Logs raw audio data from the microphone into buffers
// - Detects frequencies in the audio using the Goertzel algorithm
// - Detects frequencies in the audio using many Goertzel filters
// - Detects the BPM of music
// - Syncronizes to the beats of said music
// - Checks the touch sensors for input
// - Hosts an HTTP server for a web app
// - Talks to that web app over a high speed ws:// connection
// - Stores settings in flash memory
// - Draws custom light show modes to the LEDs in real-time
// - Drives those 128 LEDs with a custom RMT driver at high frame rates
// - Supports over-the-air firmware updates
// - Draws custom light show modes to the LEDs which react to music
// in real-time with a variety of effects
// - Runs the indicator light
// - Runs the screensaver
// - Applies a blue-light filter to the LEDs
// - Applies gamma correction to the LEDs
// - Applies error-diffusion temporal dithering to the LEDs
// - Drives those 128 LEDs with a custom RMT driver at high frame rates
// - Supports over-the-air firmware updates
// - And much more
//
// It's quite a large project, and it's all running on a dual core
// ESP32-S3. (240 MHz CPU with 520 KB of RAM)
//
// This is main file everything else branches from, and it's where the
// two cores are started. The first core runs the graphics (Core 0) and
// the second core runs the audio and web server (Core 1).
// This is the main file everything else branches from, and it's where
// the two cores are started. The first core runs the graphics (Core 0)
// and the second core runs the audio and web server (Core 1).
//
// If you enjoy this product or code, please consider supporting me on
// GitHub. I'm a solo developer and I put a lot of time and effort into
// making Emotiscope the best that it can be. Your support helps me
// continue to develop and improve the Emotiscope Engine.
//
// DONATE:
// https://github.com/sponsors/connornishijima

// DONATE:
// https://github.com/sponsors/connornishijima
//
// - Connor Nishijima, @lixielabs

// ############################################################################
// ## SOFTWARE VERSION ########################################################
Expand Down Expand Up @@ -93,7 +98,7 @@
#include "audio_debug.h" // ........ Print audio data over UART
#include "screensaver.h" // ........ Colorful dots play on screen when no audio is present
#include "standby.h" // ............ Handles sleep/wake + animations
#include "lightshow_modes.h" // .... Definition and handling of lightshow modes
#include "light_modes.h" // ........ Definition and handling of light modes
#include "commands.h" // ........... Queuing and parsing of commands recieved
#include "wireless.h" // ........... Communication with your network and the web-app
#include "ota.h" // ................ Over-the-air firmware updates
Expand Down
8 changes: 4 additions & 4 deletions src/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void parse_command(uint32_t t_now_ms, command com) {
// Get mode name
fetch_substring(com.command, '|', 2);

int16_t mode_index = set_lightshow_mode_by_name(substring);
int16_t mode_index = set_light_mode_by_name(substring);
if(mode_index == -1){
unrecognized_command_error(substring);
}
Expand Down Expand Up @@ -239,12 +239,12 @@ void parse_command(uint32_t t_now_ms, command com) {
else if (fastcmp(substring, "modes")) {
transmit_to_client_in_slot("clear_modes", com.origin_client_slot);

uint16_t num_modes = sizeof(lightshow_modes) / sizeof(lightshow_mode);
uint16_t num_modes = sizeof(light_modes) / sizeof(light_mode);
for(uint16_t mode_index = 0; mode_index < num_modes; mode_index++){
char command_string[128];
uint8_t mode_type = (uint8_t)lightshow_modes[mode_index].type;
uint8_t mode_type = (uint8_t)light_modes[mode_index].type;

snprintf(command_string, 128, "new_mode|%d|%d|%.64s", mode_index, mode_type, lightshow_modes[mode_index].name);
snprintf(command_string, 128, "new_mode|%d|%d|%.64s", mode_index, mode_type, light_modes[mode_index].name);
transmit_to_client_in_slot(command_string, com.origin_client_slot);
}

Expand Down
2 changes: 1 addition & 1 deletion src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Preferences preferences; // NVS storage for configuration

extern lightshow_mode lightshow_modes[];
extern light_mode light_modes[];
extern PsychicWebSocketHandler websocket_handler;

volatile bool wifi_config_mode = false;
Expand Down
2 changes: 1 addition & 1 deletion src/gpu_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void run_gpu() {
// ------------------------------------------------------------

clear_display();
lightshow_modes[configuration.current_mode].draw();
light_modes[configuration.current_mode].draw();

// If silence is detected, show a blue debug LED
// leds[NUM_LEDS - 1] = add(leds[NUM_LEDS - 1], {0.0, 0.0, silence_level});
Expand Down
2 changes: 1 addition & 1 deletion src/leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void draw_dot(CRGBF* layer, uint16_t fx_dots_slot, CRGBF color, float position,
}

void update_auto_color(){
if(lightshow_modes[configuration.current_mode].type != LIGHTSHOW_TYPE_ACTIVE){ return; }
if(light_modes[configuration.current_mode].type != LIGHT_MODE_TYPE_ACTIVE){ return; }

static float color_momentum = 0.0;
if(configuration.auto_color_cycle == true){
Expand Down
56 changes: 28 additions & 28 deletions src/lightshow_modes.h → src/light_modes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,52 @@ Functions for outputting computed data in beautiful fashion to the LEDs based on
// The individual drawing functions for each mode are defined in these files:

// ACTIVE MODES
#include "lightshow_modes/spectrum.h"
#include "lightshow_modes/octave.h"
#include "lightshow_modes/metronome.h"
#include "lightshow_modes/spectronome.h"
#include "lightshow_modes/hype.h"
#include "lightshow_modes/plot.h"
#include "lightshow_modes/bloom.h"
#include "lightshow_modes/analog.h"
#include "lightshow_modes/waveform.h"
#include "light_modes/spectrum.h"
#include "light_modes/octave.h"
#include "light_modes/metronome.h"
#include "light_modes/spectronome.h"
#include "light_modes/hype.h"
#include "light_modes/plot.h"
#include "light_modes/bloom.h"
#include "light_modes/analog.h"
#include "light_modes/waveform.h"

// INACTIVE MODES
#include "lightshow_modes/neutral.h"
#include "light_modes/neutral.h"

// SYSTEM MODES
#include "lightshow_modes/debug.h"
#include "lightshow_modes/presets.h"
#include "light_modes/debug.h"
#include "light_modes/presets.h"

lightshow_mode lightshow_modes[] = {
{ "Analog", LIGHTSHOW_TYPE_ACTIVE, &draw_analog },
{ "Spectrum", LIGHTSHOW_TYPE_ACTIVE, &draw_spectrum },
{ "Octave", LIGHTSHOW_TYPE_ACTIVE, &draw_octave },
{ "Metronome", LIGHTSHOW_TYPE_ACTIVE, &draw_metronome },
{ "Spectronome", LIGHTSHOW_TYPE_ACTIVE, &draw_spectronome },
{ "Hype", LIGHTSHOW_TYPE_ACTIVE, &draw_hype },
{ "Bloom", LIGHTSHOW_TYPE_ACTIVE, &draw_bloom },
light_mode light_modes[] = {
{ "Analog", LIGHT_MODE_TYPE_ACTIVE, &draw_analog },
{ "Spectrum", LIGHT_MODE_TYPE_ACTIVE, &draw_spectrum },
{ "Octave", LIGHT_MODE_TYPE_ACTIVE, &draw_octave },
{ "Metronome", LIGHT_MODE_TYPE_ACTIVE, &draw_metronome },
{ "Spectronome", LIGHT_MODE_TYPE_ACTIVE, &draw_spectronome },
{ "Hype", LIGHT_MODE_TYPE_ACTIVE, &draw_hype },
{ "Bloom", LIGHT_MODE_TYPE_ACTIVE, &draw_bloom },

{ "Neutral", LIGHTSHOW_TYPE_NEUTRAL, &draw_neutral },
{ "Neutral", LIGHT_MODE_TYPE_INACTIVE, &draw_neutral },

//{ "debug", &draw_debug }, // 8
//{ "presets", &draw_presets }, // 9
};

const uint16_t NUM_LIGHTSHOW_MODES = sizeof(lightshow_modes) / sizeof(lightshow_mode);
const uint16_t NUM_LIGHT_MODES = sizeof(light_modes) / sizeof(light_mode);

extern float lpf_drag; // Used for fade transition

// Lightshow Modes can be summoned by their string name shown in the UI
// This string is compared to the lightshow_modes[] table to derive a
// Light Modes can be summoned by their string name shown in the UI
// This string is compared to the light_modes[] table to derive a
// pointer to that mode's drawing function. Then, transition_to_new_mode()
// handles the switch
int16_t set_lightshow_mode_by_name(char* name){
int16_t set_light_mode_by_name(char* name){
int16_t mode_index = -1;

uint16_t num_modes = sizeof(lightshow_modes) / sizeof(lightshow_mode);
uint16_t num_modes = sizeof(light_modes) / sizeof(light_mode);
for(uint16_t i = 0; i < num_modes; i++){
if( strcmp(name, lightshow_modes[i].name) == 0 ){
if( strcmp(name, light_modes[i].name) == 0 ){

// Found a matching mode
configuration.current_mode = i;
Expand All @@ -76,7 +76,7 @@ int16_t set_lightshow_mode_by_name(char* name){

void increment_mode(){
int16_t new_mode = configuration.current_mode + 1;
configuration.current_mode = new_mode % NUM_LIGHTSHOW_MODES;
configuration.current_mode = new_mode % NUM_LIGHT_MODES;
lpf_drag = 1.0; // Causes slow fade using low pass filtered image
save_config_delayed();
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/screensaver.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bool inactive = false;

void run_screensaver(){
if(configuration.screensaver == false){ return; }
if(lightshow_modes[configuration.current_mode].type != LIGHTSHOW_TYPE_ACTIVE){ return; }
if(light_modes[configuration.current_mode].type != LIGHT_MODE_TYPE_ACTIVE){ return; }

float mag_sum = 0;
for(uint16_t i = 0; i < NUM_FREQS; i++){
Expand Down

0 comments on commit 219ac17

Please sign in to comment.