Sylvie
June 18, 2020, 4:20am
#1
I’m trying to make a countdown timer on the controller with a rumble, and I’m running into some issues.
The code is here
master.clear();
delay(250);
master.print(0, 0, "PRESS START");
while (master.get_digital(DIGITAL_POWER) == 0) {}
master.clear();
delay(50);
master.rumble(".");
delay(50);
master.print(0, 0, "3");
delay(950);
master.rumble(".");
delay(50);
master.print(0, 0, "2");
delay(950);
master.rumble(".");
delay(50);
master.print(0, 0, "1");
delay(950);
master.rumble(".");
delay(50);
master.print(0, 0, "GO");
It plays the rumble while setting the number to 3, it skips the rumble but sets the number to 2, then it plays the rumble with 1. It then skips over the rumble before GO.
If I set all of the delays to 2000ms, all of the numbers and rumbles play just fine.
Does anyone know the issue?
And before anyone asks, no, DIGITAL_POWER is not the issue, it's a custom thing that I've done with Jame's help, so that's not the issue.
the rumbler will play through 8 bytes of rumble code even if you dont have 8 bytes input. In fact, if you rumble a few dashes and then do a call to rumble a dot, you can tell thst it overwrote the old thing, but not completely.
4 Likes
Sylvie
June 18, 2020, 4:15pm
#3
So, how do I make my code work correctly?
yes, there’s a long standing bug in the controller related to rumble commands. It is fixed in the next vexos release.
13 Likes
Sylvie
June 18, 2020, 8:39pm
#5
Any idea on when 10.0 will be released?
The next release of vexos is 1.0.11
sometime in the near future, we don’t have an exact date yet.
9 Likes
Connor
June 18, 2020, 11:52pm
#7
I have never really had a problem with rumble, because I was aware beforehand that it in itself is unstable. So what I do is run the rumble command once:
controller.rumble(". . .");
master.print(0, 0, "3");
delay(1000);
master.print(0, 0, "2");
delay(1000);
master.print(0, 0, "1");
delay(1000);
master.print(0, 0, "GO");
If you need added time for a pause, add another space. This should work. If not, then you will have to execute the rumble as an event.
2 Likes
Connor
June 19, 2020, 12:50am
#9
An event is something that runs a function to run lines of code independantly without needing to yield to other lines.
Not sure if events exist in Vexcode: https://stackoverflow.com/questions/9711414/what-is-the-proper-way-of-doing-event-handling-in-c
But what I am certain of is that if controller.rumble is a yielding function, you can run the line as a task:
int runRumble(){
controller.rumble(". . . .");
}
void usercontrol(void){
vex::task rumblePls(runRumble);
master.print(0, 0, "3");
delay(1000);
master.print(0, 0, "2");
delay(1000);
master.print(0, 0, "1");
delay(1000);
master.print(0, 0, "GO");
}
For the time being, this should work
5 Likes
This isn’t necessary, as I don’t think rumble
is blocking.
This should be good enough:
void usercontrol(void) {
controller.rumble(". . . .");
master.print(0, 0, "3");
delay(1000);
master.print(0, 0, "2");
delay(1000);
master.print(0, 0, "1");
delay(1000);
master.print(0, 0, "GO");
}
5 Likes
Connor
June 20, 2020, 9:10pm
#11
@theol0403 I already covered it in a post before what I had:
Connor:
I have never really had a problem with rumble, because I was aware beforehand that it in itself is unstable. So what I do is run the rumble command once:
controller.rumble(". . .");
master.print(0, 0, "3");
delay(1000);
master.print(0, 0, "2");
delay(1000);
master.print(0, 0, "1");
delay(1000);
master.print(0, 0, "GO");
If you need added time for a pause, add another space. This should work. If not, then you will have to execute the rumble as an event.
Connor:
But what I am certain of is that if controller.rumble is a yielding function, you can run the line as a task:
int runRumble(){
controller.rumble(". . . .");
}
void usercontrol(void){
vex::task rumblePls(runRumble);
master.print(0, 0, "3");
delay(1000);
master.print(0, 0, "2");
delay(1000);
master.print(0, 0, "1");
delay(1000);
master.print(0, 0, "GO");
}
For the time being, this should work
I have included two solutions: One where rumble is not a yielding(or blocking) function, and another based upon if rumble is.
6 Likes