Gyro Example

  1. 5 years ago

    alanstones

    25 Jun 2018 User since 2018

    Is there an example on using the Gyro object somewhere? Mainly looking to get step count value at this stage.

  2. andrea

    25 Jun 2018 Administrator User since 2016
    Edited 5 years ago by andrea

    Hi @alanstones,
    please see the attached sample project.

    Steps:

    1. Add a Gyro object by dragging the Gyro class from the Objects panel to the Window1
    2. Add a Label to the Window1
    3. Click on the play button near the Gyro1 object in the Layout panel. Creo shows a new window with some simulated values for the Gyro sensor.
    4. Open a value and look for the desired value, in this case pedometerData and then numberOfSteps.
    5. Start dragging from the numberOfSteps cell and release into the Label1 in the Window1, this action will create a new Binding between from the numberOfSteps of the last value of the Gyro to the text value of the Label1

    Screen Shot 2018-06-25 at 11.36.16.png

    6. Run the project in the Creo simulator
    Screen Shot 2018-06-25 at 11.49.47.png

    Another way is to use the Gyro value programmatically, the new values are Map objects, please see the NewValue event of the Gyro object:

    var pedometerData = value["pedometerData"]
    var numberOfSteps = pedometerData["numberOfSteps"]
    Console.write("Numbero of Steps: \(numberOfSteps)")
  3. alanstones

    25 Jun 2018 User since 2018

    That's a great help, thanks.

or Sign Up to reply!