Sequal32 / simconnect-rust

SimConnect bindings for rust.
MIT License
32 stars 13 forks source link

Exposing the data definition epsilon variable plus fix example #10

Closed BitsAndDroids closed 8 months ago

BitsAndDroids commented 8 months ago

Example code fix

Fixed the example code to work with the latest Rust version regarding packed structs. The old example code couldn't compile anymore.

Epsilon

When the epsilon of all variables in a data definition is set to 0.0, the sim will return an abundance of data when data is flagged as on change. For example, every mm change of altitude is seen as a change in the variable, while in reality, you most likely only need changes per foot. Exposing the epsilon as a function parameter enables cleaner outputs. This also simplifies our ability to use the data changed flag to send data to microprocessors (without flooding them with unused data).


conn.add_data_definition(0, "PLANE LATITUDE", "Degrees", simconnect::SIMCONNECT_DATATYPE_SIMCONNECT_DATATYPE_FLOAT64, u32::MAX, 0.0); // this will trigger an update every minor change < 1.0 degree
conn.add_data_definition(0, "PLANE LONGITUDE", "Degrees", simconnect::SIMCONNECT_DATATYPE_SIMCONNECT_DATATYPE_FLOAT64, u32::MAX, 1.0); // this will only trigger an update every 1.0 degree change```
BitsAndDroids commented 8 months ago

Added an extra example to explain how to utilize the epsilon variable and put both examples in the example folder

BitsAndDroids commented 8 months ago

@Sequal32 Whoops, I just started using RustRover and haven't configured my spellchecker yet. I've amended the spelling errors (and found some more). Over time, I will add some extra examples, such as communication with in-game WASM modules.

PS. Happy holidays

Sequal32 commented 8 months ago

Awesome, the comments look great. I ran cargo clippy over the whole project and fixed those warnings (and added print statements for the Open and Quit events as well). Thanks so much for your contribution and happy holidays!

MrMinimal commented 5 months ago

I updated to the latest version and saw all these changes. Superb contribution, the examples will be amazing for new devs getting into this. Thank you!