Skip to content
This repository has been archived by the owner on Apr 5, 2020. It is now read-only.

Make the brick sleep for X milliseconds? #20

Open
PAK90 opened this issue Jun 10, 2016 · 1 comment
Open

Make the brick sleep for X milliseconds? #20

PAK90 opened this issue Jun 10, 2016 · 1 comment

Comments

@PAK90
Copy link

PAK90 commented Jun 10, 2016

(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?

@chrisgabr
Copy link

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

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

No branches or pull requests

2 participants