happycodelucky / rocket-nuimo-node

Nuimo Control device discovery, connection manager, and interface control for Node.js
MIT License
12 stars 4 forks source link

Infinite Rotation #10

Closed oschade closed 3 years ago

oschade commented 3 years ago

I don't know if this is the default behavior of the nuimo: Is it possible to get infinite rotation delta values? Right now it, no more rotation events triggered after the nuimo reach the rotationMaximum / rotationMinimum.

happycodelucky commented 3 years ago

This is something I could add, I would need to think about the design. The code does clamp the rotation. Honestly I never liked the implementation I added for these reasons.

happycodelucky commented 3 years ago

For the interim you can set min to -1 and max to 1, and on each rotation event reset the rotation value. This ensures you would get positive and negative rotations.

happycodelucky commented 3 years ago

Alright, I've implemented new behavior quickly. As not to break backwards compatibility I've introduced a new property rotationMode.

Check out the example https://github.com/happycodelucky/rocket-nuimo-node/blob/main/examples/05-rotate-events/example-rotate-events.ts#L15. You can now set the mode to Continuous, and remove the call to setRotationRange as this will error out when in continuous mode.

Note, as rotation cannot really be determined it always returns 0 in continuous mode. You have to rely on the rotation delta (relative to a single rotation).