Code Monkey home page Code Monkey logo

Comments (8)

michaelhatPIengineering avatar michaelhatPIengineering commented on July 25, 2024

Jonathan,
Thanks for keeping me honest, you are correct about the joystick.
We are making major changes in the "Develop" branch.

I noticed the same as you and my first fix was almost 100% the same as yours.

We then went a bit further to generalize things for our other joystick products and even multiple sticks

this.product.hasJoystick?.forEach((joystick, index) => {
const x = data.readUInt8(joystick.joyXbyte) // Joystick X
const y = data.readUInt8(joystick.joyYbyte) // Joystick Y
const z = data.readUInt8(joystick.joyZbyte) // Joystick Z (twist of joystick)

			analogStates.joystick[index] = {
				x: x < 128 ? x : x - 256, // -127 to 127
				y: y < 128 ? -y : -(y - 256), // -127 to 127
				z: z, // joystick z is a continuous value that rolls over to 0 after 255
			}
		})

Take a look at xkeys.ts and products.ts in the develop branch an let us know what you think.

Michael

from xkeys.

jonwyett avatar jonwyett commented on July 25, 2024

Ha! Well there you have it! I guess I should have checked the develop branch before posting...

I'm excited to see all the changes that are coming, particularly the inclusion of the UID, as I'm developing a library for working with multiple panels that requires knowing the Unit ID to identify them. It also has some convenience features that abstract-away some of the low-level functions in this library. For example the joystick Z-axis is returned as a delta +- value instead of the looping 0-255, things like that. I was using my own modifications to get the UID but now that it's included that's terrific!

-Jonathan

from xkeys.

nytamin avatar nytamin commented on July 25, 2024

The joystick delta-z value is a great idea, I'll very likely look into adding that into the upcoming version as well!
If you have any other ideas or suggestions later on , PR:s are very welcome!

from xkeys.

michaelhatPIengineering avatar michaelhatPIengineering commented on July 25, 2024

Just added delta-Z to xkeytest1 example.
It is a bit of code we usually uses to determine direction and magnitude of the z twist.

the joystick was originally designed for a precision microscope, used to test the silicon wafer before it is cut. The wanted a knob like the traditional focus of a microscope.
The z axis was used for the focus.
It is not return to zero and almost all others are.
It is absolute, even during a reboot. Meaning if you put a dot on the handle the analog value will tell where that dot is ever after.

However, the position is only 1 byte so it rolls over at 255, which makes it annoying if you just subtract the new value from the old value. Around 0 it is a bit tricky. Look at the example where we & with 255 to solve this bump problem.

Michael

from xkeys.

jonwyett avatar jonwyett commented on July 25, 2024

If I did submit a patch for joystick delta would you prefer it completely override the current joystick_z 0-255 value with the delta or should that be a new property like joystick_z_delta ? (or the current joystick_z could become joystick_z_abs perhaps)

from xkeys.

michaelhatPIengineering avatar michaelhatPIengineering commented on July 25, 2024

The x,y,z are actual positions at any one state. So that data should be maintained as is.
Z delta is a change of state. it is derived from the position, it could be an additional property but should not replace or hide the actual position.
It is really position.z just like positon.x or position.y it just seems different because it does not return to 0

from xkeys.

jonwyett avatar jonwyett commented on July 25, 2024

Yes, that was my assumption, additional property is the way to go. Thanks!

from xkeys.

nytamin avatar nytamin commented on July 25, 2024

I've added the deltaZ property for the joystick event in the develop branch, which is about to be released in a few days.
You can try it out now by

npm install xkeys@nightly

Feel free to reopen this issue if there are any lingering issues.

from xkeys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.