omriharel / deej

Set app volumes with real sliders! deej is an Arduino & Go project to let you build your own hardware mixer for Windows and Linux
https://deej.rocks
MIT License
4.71k stars 433 forks source link

Added max value reducer to arduino script #106

Closed I3lackRacer closed 4 months ago

I3lackRacer commented 4 months ago

Closes #105

tanishqmanuja commented 4 months ago

REAL_MAX_VALUE would not change afterwards so it could be a const. or something like this would even save the extra division operation when not required,

// The max value received by the deej software should only be 1023, but some controllers like some esp32 are sending higher values like 4095. 
// If that is the case, set the max value sent by the board here so it will get lowered.
// Uncomment this line if your max value is not 1023.
#define REAL_MAX_VALUE 4095;

// Other stuff here ....

void updateSliderValues() {
  for (int i = 0; i < NUM_SLIDERS; i++) {
    #ifdef REAL_MAX_VALUE
    int rawValue = analogRead(analogInputs[i]);
    analogSliderValues[i] = (rawValue * 1023) / REAL_MAX_VALUE;
    #else
    analogSliderValues[i] = analogRead(analogInputs[i]);
    #endif
  }
}

EDIT: If you wanna do this logic on the deej app - https://github.com/tanishqmanuja/deej/commit/282f79d9855b3370c0c501a2806eff579f0538f2

omriharel commented 4 months ago

Hey there @I3lackRacer, thank you for your interest in contributing to deej.

As per the project's contribution guidelines, I'm currently not accepting PR submissions for deej's main fork. That being said, I encourage you to continue working on these changes to your heart's content in your own fork of the project.