BrianPeek/legoev3

Make the brick sleep for X milliseconds?

Opened this issue · 1 comments

PAK90 commented

(Win7, WPF application in VS2015).
I have a button that, when clicked, makes a motor turn for a bit. However, I want it to pause, then turn the motor backwards. Right now I have this:

private async void Load_Card_Click(object sender, RoutedEventArgs e)
        {
            await _brick.DirectCommand.TurnMotorAtPowerForTimeAsync(OutputPort.D, 100, 450, false);
            System.Threading.Thread.Sleep(500);
            await _brick.DirectCommand.TurnMotorAtPowerForTimeAsync(OutputPort.D, -50, 450, true);
        }

It 'works', but this is inconsistent; sometimes the first or second DirectCommand isn't sent and the motor doesn't end up doing what I want. I checked the method list of DirectCommand and BatchCommand, and I didn't see a sleep or wait method. Is there a better method than what I've already tried?

I observed a similar behaviour. For me using "OutputReadyAsync()" helped, before sending teh next command.