Controller Rumble

Currently, I am testing out the controller rumble function, and it seems that once the controller is told to rumble, it keeps rumbling for the duration of the user control. Is there a way to stop it from rumbling forever?

Would you mind sharing your code so that we can help identify the problem?

Something like

master.rumble("-  -");

Could you share your entire user control loop. I cant entirely identify the problem, but at the moment i have a feeling it has something to do with loops. If you are not comfortable releasing your code to everyone you could just pm me.

If you are putting it into a while loop, I would suggest putting it in a switch where it would only run once when a conidition is detected to be true:


bool enabledBefore = false;

while(true){

 if(provided condition is true && enabledBefore == false){
  enabledBefore = true;
  master.rumble("-  -");
 }
 else if(provided condition is false){
  enabledBefore = false;
 }

}

If you continuously call a rumble, it would queue all of the times you’ve called it and would go through the entire queue until the queue is empty (if that makes sense). By making it only run once, you will prevent multiple rumble queued requests.

3 Likes

Would something like this work then?

if(master.get_battery_level() < 11) {
  master.rumble("-  -");
}

If your code is within a while loop, apply the code as I have it above:

bool enabledBefore = false; // This would be located above the while loop to initialize an initial value.

while(true){

 if(master.get_battery_level() < 11 && enabledBefore == false){
  enabledBefore = true;
  master.rumble("-  -");
 }
 else if(master.get_battery_level() >= 11){
  enabledBefore = false;
 }

}
2 Likes