Lixie-Labs / Emotiscope

Let your eyes enjoy the music too ✨ Extremely low-latency audio processing lets LEDs perfectly synchronize to your music's notation and tempo.
https://emotiscope.rocks/
GNU General Public License v3.0
27 stars 5 forks source link

Add noise calibration visual countdown and trigger when both "ears" covered by h... #64

Closed github-actions[bot] closed 1 month ago

github-actions[bot] commented 3 months ago

https://github.com/Lixie-Labs/Emotiscope/blob/23d7c5a9258e98cab21d18da452305c7386c3f54/src/touch.h#L166


                }
            }
        }

        // Print touch values (floats with 3 decimal points)
        //printf("TOUCH LEFT: %.3f | TOUCH CENTER: %.3f | TOUCH RIGHT: %.3f\n", touch_pins[0].touch_value, touch_pins[1].touch_value, touch_pins[2].touch_value);
    }

    if(touch_pins[TOUCH_LEFT].touch_active == true || touch_pins[TOUCH_CENTER].touch_active == true || touch_pins[TOUCH_RIGHT].touch_active == true){
        device_touch_active = true;
    }
    else{
        device_touch_active = false;
    }

    if(touch_pins[TOUCH_LEFT].hold_active == true && touch_pins[TOUCH_RIGHT].touch_active == false){ // Left hold active
        configuration.hue -= 0.0015;
        if(configuration.hue < 0.0){
            configuration.hue += 1.0;
        }

        save_config_delayed();
    }
    else if(touch_pins[TOUCH_RIGHT].hold_active == true && touch_pins[TOUCH_LEFT].touch_active == false){ // Right hold active
        configuration.hue += 0.0015;
        if(configuration.hue > 1.0){
            configuration.hue -= 1.0;
        }

        save_config_delayed();
    }
    else if(touch_pins[TOUCH_LEFT].hold_active == true && touch_pins[TOUCH_RIGHT].hold_active == true){ // both hands held
        printf("BOTH HANDS HELD\n");
        // TODO: Add noise calibration visual countdown and trigger when both "ears" covered by hands
    }
}

void render_touches(){
    static float touch_left_opacity = 0.0;
    static float touch_center_opacity = 0.0;
    static float touch_right_opacity = 0.0;

    float touch_left_opacity_target = 0.0;
    float touch_center_opacity_target = 0.0;
    float touch_right_opacity_target = 0.0;

    if(touch_pins[TOUCH_LEFT].touch_active == true){
        touch_left_opacity_target = 1.0;
    }
    if(touch_pins[TOUCH_CENTER].touch_active == true){
        touch_center_opacity_target = 1.0;
    }
    if(touch_pins[TOUCH_RIGHT].touch_active == true){
        touch_right_opacity_target = 1.0;
    }

    touch_left_opacity = touch_left_opacity * 0.95 + touch_left_opacity_target * 0.05;
    touch_center_opacity = touch_center_opacity * 0.95 + touch_center_opacity_target * 0.05;
    touch_right_opacity = touch_right_opacity * 0.95 + touch_right_opacity_target * 0.05;

    if(touch_left_opacity > 0.005){
        for(uint8_t i = 0; i < 32; i++){
            float progress = (float)i / 31.0;
            float brightness = (1.0-progress) * touch_left_opacity;
            CRGBF glow_col = hsv(0.870, 1.0, brightness*brightness*0.05);

            leds[i] = add(leds[i], glow_col);
        }
    }

    if(touch_right_opacity > 0.005){
        for(uint8_t i = 0; i < 32; i++){
            float progress = (float)i / 31.0;
            float brightness = (1.0-progress) * touch_right_opacity;
            CRGBF glow_col = hsv(0.870, 1.0, brightness*brightness*0.05);

            leds[(NUM_LEDS-1)-i] = add(leds[(NUM_LEDS-1)-i], glow_col);
        }
    }
}
connornishijima commented 1 month ago

Closed since manual audio calibration is no longer required