Skip to content

Commit

Permalink
Hype and touch tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
connornishijima committed May 13, 2024
1 parent c9bf98f commit 5a2025e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/gpu_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ void run_gpu() {

apply_brightness();

render_touches(); // (touch.h)

if( EMOTISCOPE_ACTIVE == false ){
run_standby();
}

render_touches(); // (touch.h)

// This value decays itself non linearly toward zero all the time,
// *really* slowing down the LPF when it's set to 1.0.
Expand Down
14 changes: 7 additions & 7 deletions src/light_modes/active/hype.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ void draw_hype() {

float beat_color_odd = beat_sum_odd;
float beat_color_even = beat_sum_even;
beat_sum_odd = sqrt(beat_color_odd);
beat_sum_even = sqrt(beat_color_even);
beat_sum_odd = sqrt(sqrt(beat_color_odd));
beat_sum_even = sqrt(sqrt(beat_color_even));

float strength = sqrt(sqrt(tempo_confidence));
float strength = sqrt(tempo_confidence);

CRGBF dot_color_odd = hsv(
get_color_range_hue(beat_color_odd),
Expand All @@ -41,11 +41,11 @@ void draw_hype() {
beat_sum_even *= 0.5;
}

draw_dot(leds, NUM_RESERVED_DOTS + 0, dot_color_odd, 1.0-beat_sum_odd, 0.1 + 0.9*strength);
draw_dot(leds, NUM_RESERVED_DOTS + 1, dot_color_even, 1.0-beat_sum_even, 0.1 + 0.9*strength);
draw_dot(leds, NUM_RESERVED_DOTS + 0, dot_color_odd, 1.0-beat_sum_odd, 0.1 + 0.8*strength);
draw_dot(leds, NUM_RESERVED_DOTS + 1, dot_color_even, 1.0-beat_sum_even, 0.1 + 0.8*strength);

if(configuration.mirror_mode == true){
draw_dot(leds, NUM_RESERVED_DOTS + 2, dot_color_odd, beat_sum_odd, 0.1 + 0.9*strength);
draw_dot(leds, NUM_RESERVED_DOTS + 3, dot_color_even, beat_sum_even, 0.1 + 0.9*strength);
draw_dot(leds, NUM_RESERVED_DOTS + 2, dot_color_odd, beat_sum_odd, 0.1 + 0.8*strength);
draw_dot(leds, NUM_RESERVED_DOTS + 3, dot_color_even, beat_sum_even, 0.1 + 0.8*strength);
}
}
2 changes: 2 additions & 0 deletions src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void init_system() {
extern void init_touch();
extern void init_noise_samples();
extern void init_floating_point_lookups();
extern void init_vu();

init_hardware_version_pins(); // (hardware_version.h)
init_serial(921600); // (system.h)
Expand All @@ -106,6 +107,7 @@ void init_system() {
init_noise_samples(); // (utilities.h)
init_floating_point_lookups(); // (utilities.h)
init_boot_button(); // (system.h)
init_vu(); // (vu.h)

// Load sliders
load_sliders_relevant_to_mode(configuration.current_mode);
Expand Down
19 changes: 8 additions & 11 deletions src/touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ void read_touch(){
touch_readings[t] = touch_readings[t] * 0.9 + raw_touch_value * 0.1; // Smooth the input
}

if(t_now_ms < 5000){
if(t_now_ms < 2500){
for(uint8_t t = 0; t < 3; t++){
for(uint8_t i = 0; i < 50; i++){
touch_pins[t].touch_history[i] = touch_readings[t];
}
}
}

if (t_now_ms - last_touch_read_time >= 100) {
if (t_now_ms - last_touch_read_time >= 50) {
for(uint8_t t = 0; t < 3; t++){
if(touch_pins[t].touch_active == false){
touch_pins[t].touch_history[touch_history_index] = touch_readings[t];
Expand Down Expand Up @@ -205,15 +205,12 @@ void read_touch(){
save_config_delayed();
}
else if(touch_pins[TOUCH_LEFT].touch_active == true && touch_pins[TOUCH_RIGHT].touch_active == true){ // both hands held
//printf("BOTH HANDS HELD\n");
/*
configuration.mirror_mode = !configuration.mirror_mode;
touch_pins[TOUCH_LEFT].hold_active = true;
touch_pins[TOUCH_RIGHT].hold_active = true;
touch_pins[TOUCH_LEFT].touch_active = false;
touch_pins[TOUCH_RIGHT].touch_active = false;
*/
static uint32_t last_mirror_mode_toggle = 0;
if(t_now_ms - last_mirror_mode_toggle >= 1000){
configuration.mirror_mode = !configuration.mirror_mode;
save_config_delayed();
last_mirror_mode_toggle = t_now_ms;
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/vu.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ volatile float vu_floor = 0.0;

uint32_t last_vu_log = 0;

void init_vu(){
for(uint8_t i = 0; i < NUM_VU_LOG_SAMPLES; i++){
vu_log[i] = 0.0;
}
for(uint8_t i = 0; i < NUM_VU_SMOOTH_SAMPLES; i++){
vu_smooth[i] = 0.0;
}
}

void run_vu(){
profile_function([&]() {
// CALCULATE AMPLITUDE ------------------------------------------------
Expand Down

0 comments on commit 5a2025e

Please sign in to comment.