Skip to content

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

@BolSadguy

Description

@BolSadguy

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");
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions