Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deej preventing computer from sleeping, could not get any solutions from google to work #142

Open
BolSadguy opened this issue Jan 25, 2025 · 2 comments

Comments

@BolSadguy
Copy link

BolSadguy commented Jan 25, 2025

So sorry to be making another post about this issue but I've tried disabling usb wake up in my device manager (the button to disable it just doesnt exist on my end for some reason) and I've also tried adjusting the arduino code based on #52 and I haven't been able to get my computer to remain in sleep while deej is running. Admittedly I don't know too much about programming arduinos so I'm not sure if I even inserted the new code in the correct way or into the correct spots. Here's what I have, please let me know what I'm doing wrong. Thanks in advance

const int NUM_SLIDERS = 9;
const int analogInputs[NUM_SLIDERS] = {A6, A7, A8, A9, A3, A2, A1, A0, A10};
String oldValues;

int analogSliderValues[NUM_SLIDERS];
int oldAnalogSliderValues[NUM_SLIDERS];
void setup() { 
  for (int i = 0; i < NUM_SLIDERS; i++) {
    pinMode(analogInputs[i], INPUT);
    oldAnalogSliderValues[i] = analogSliderValues[i] = analogRead(analogInputs[i]);
    if(abs(oldAnalogSliderValues[i] - analogSliderValues[i]) <= 2) analogSliderValues[i] = oldAnalogSliderValues[i];
    oldAnalogSliderValues[i] = analogSliderValues[i];
  }

  Serial.begin(9600);
}

void loop() {
  updateSliderValues();
  sendSliderValues(); // Actually send data (all the time)
  // printSliderValues(); // For debug
  delay(10);
}

void updateSliderValues() {
  for (int i = 0; i < NUM_SLIDERS; i++) {
     analogSliderValues[i] = analogRead(analogInputs[i]);
  }
}

void sendSliderValues() {
  String builtString = String("");

  for (int i = 0; i < NUM_SLIDERS; i++) {
    builtString += String((int)analogSliderValues[i]);

    if (i < NUM_SLIDERS - 1) {
      builtString += String("|");
    }
  }
  
  if(oldValues != builtString) Serial.println(builtString); oldValues = builtString;
}

void printSliderValues() {
  for (int i = 0; i < NUM_SLIDERS; i++) {
    String printedString = String("Slider #") + String(i + 1) + String(": ") + String(analogSliderValues[i]) + String(" mV");
    Serial.write(printedString.c_str());

    if (i < NUM_SLIDERS - 1) {
      Serial.write(" | ");
    } else {
      Serial.write("\n");
    }
  }
}
@natsnok
Copy link

natsnok commented Jan 25, 2025

Is it possible that the potentiometers being used fluctuate between values? Check with the debug function to see if there's a slight change in volume even when the potentiometers are not being used. You could implement a function in the code that only sends slider values when the change is significant enough (when the potentiometer is actually being adjusted).

However, please note that for the Deej program to function correctly, values must be sent continuously. Otherwise, it won't respond at all. In other words, if a potentiometer is not being used, always send a fixed value. Only update this fixed value when the change is significant enough to ensure that you are actually adjusting the potentiometer.

@BolSadguy
Copy link
Author

``

Is it possible that the potentiometers being used fluctuate between values? [...] You could implement a function in the code that only sends slider values when the change is significant enough (when the potentiometer is actually being adjusted).

[...] In other words, if a potentiometer is not being used, always send a fixed value. Only update this fixed value when the change is significant enough to ensure that you are actually adjusting the potentiometer.

I was under the impression that that's what the code adjustments in #52 were accomplishing.

Image

But again, I'm not sure if I added the code to the correct spots in the code I posted earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants