Comments (8)
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.
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.
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.
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.
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.
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.
Yes, that was my assumption, additional property is the way to go. Thanks!
from xkeys.
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)
- this.deviceType.banks 2 on console when setting backlightintensity HOT 2
- Console log statement becomes rather spammy HOT 2
- Handling of USB disconnect/reconnect HOT 6
- Support for XKE-64 JogT-bar HOT 2
- Log for XKE-128 HOT 1
- Discussion: Major updates to the library HOT 16
- XK-8 support HOT 15
- Feature: WebHID HOT 1
- Closing down neatly HOT 4
- Can XKeysWatcher handle existing connections? HOT 2
- Multiple devices HOT 6
- Backlight methods HOT 6
- Help with building HOT 8
- Any known problems with Raspberry Pi? HOT 2
- XKeys.listAllConnectedPanels is not a function HOT 9
- How to dispose of an xkeysPanel? HOT 10
- call a xkeys function out of the watcher HOT 4
- UnhandledPromiseRejectionWarning when watcher fails to open device HOT 1
- npm packages have a lot of 'junk' files HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xkeys.