Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set settings over serial interface and save them #57

Open
AndunHH opened this issue Sep 10, 2024 · 5 comments
Open

Set settings over serial interface and save them #57

AndunHH opened this issue Sep 10, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@AndunHH
Copy link
Owner

AndunHH commented Sep 10, 2024

@raulpetru created a fork with a python programm to send the sensitivity values over the serial interface. See
https://github.com/raulpetru/SpacemouseProfiles

With this feature request we want the following features:

  • implement a serial interface to accept different sensitivity values. (Check if other values are also useful)
  • command to output all active settings over the serial to save them on the PC
  • possibility to save the values into the eeprom, so the stay saved even with power down
  • possibility to set sensitivities for different profiles, which can be toggled with a button or serial command
@AndunHH AndunHH added the enhancement New feature or request label Sep 10, 2024
@raulpetru
Copy link

raulpetru commented Sep 10, 2024

  • 1. implement a serial interface to accept different sensitivity values. (Check if other values are also useful)
  • 2. command to output all active settings over the serial to save them on the PC
  • 3. possibility to save the values into the eeprom, so the stay saved even with power down
  • 4. possibility to set sensitivities for different profiles, which can be toggled with a button or serial command
  1. Right now I commented out the following variables from config.h, declared them as float in spacemouse-keys.ino and added if statements in loop() to receive new values on serial (you can check my repo). These variables can be changed right now from the user interface:
TRANSX_SENSITIVITY
TRANSY_SENSITIVITY
POS_TRANSZ_SENSITIVITY
NEG_TRANSZ_SENSITIVITY
GATE_NEG_TRANSZ
GATE_ROTX
GATE_ROTY
GATE_ROTZ
ROTX_SENSITIVITY
ROTY_SENSITIVITY
ROTZ_SENSITIVITY
  1. and 4. The app automatically detects on which window the user is focused so the user can modify the variables and "save" them. Saving them actually does 2 things: it will create and apply a profile which will be saved to a "profiles.json" file that is loaded each time when you open the Spacemouse Profiles app. Switching to different apps will cause the Spacemouse Profiles to switch profiles automatically (if they are available), so the user doesn't need to explicitly toggle a profile change (this is how the 3DConnection software also works, when you switch apps, it will detect and apply a different profile).

  2. Right now the app doesn't offer this feature because Spacemouse Profiles app needs to be running in order to change profiles, if you close the app, the last loaded profile will remain active. If you reboot the spacemouse without opening the Spacemouse Profiles app, it will use the default values written in the firmware.
    But it is possible to make "slots" where to save profiles, and trigger them by button (if you want to use the Spacemouse without extra software, or if you want to use it on a machine where you can't install Spacemouse Profiles)

The app is written in Python using the Textualize TUI (Text-based user interface/Terminal user interface) library and I written it specifically for Windows(also Windows Terminal is recommended since CMD is old and the UI looks broken while the app still functions normally). The app is not that easy to distribute (you have to install python, make a virtual environment, install dependencies, run the app), this can be a limiting factor for not-so-technical users (but I guess most of us are technical since we talk about a DIY mouse). The installing process can also be further automated.
Depending on what we want to add to this app, I might consider at some point on switching to other UI library, a native one that doesn't run in a terminal (which will also allow more customization, easier distribution and also the possibility to minimize the app to system tray).

I'm waiting for some feedback from users that use the Spacemouse more since I don't own one myself (yet), but I still have access to one occasionally.

@raulpetru
Copy link

raulpetru commented Sep 11, 2024

I forked your repo and implemented the changes more cleaner than in my repo (see: raulpetru@2a6cab5).
I haven't tested this exact changes yet, but should work, I will test them tomorrow.

It's not the best implementation. Also I might have disabled serial debugging since I commented the initial if (Serial.available()) statement.

I want to write a function on Arduino that returns through serial the variables that we want to be included in the UI, then my app will pick this and build the UI. This way I don't have to hardcode the variables in my app, the app will request the variables from Spacemouse and will add them in the UI. This way we can use the same app with different firmwares.

@AndunHH
Copy link
Owner Author

AndunHH commented Sep 19, 2024

I forked your repo and implemented the changes more cleaner than in my repo (see: raulpetru@2a6cab5). I haven't tested this exact changes yet, but should work, I will test them tomorrow.

Great! So we can have a look at your approach!

It's not the best implementation. Also I might have disabled serial debugging since I commented the initial if (Serial.available()) statement.

We need to find a way to enable both use cases. Now, the input is waiting for only 2 ms and is trying to parse the input as a number. I suggest we add a little input queue, which evaluates the input, when it finds a line feed (new line key \n"). Then: If just a number is entered, we have the actual debug behavior. If e.g. "set transx 15 \n" ist transmitted the sensitivtiy for translation X is changed. (I suggest that we find shorter variable names...)

I want to write a function on Arduino that returns through serial the variables that we want to be included in the UI, then my app will pick this and build the UI. This way I don't have to hardcode the variables in my app, the app will request the variables from Spacemouse and will add them in the UI. This way we can use the same app with different firmwares.

Yes, this is very good suggestion!

@raulpetru
Copy link

raulpetru commented Nov 10, 2024

I'm back with a new application, take a look when you find time (DIY SpaceMouse Profiles).
We can use this with different firmwares, as long as they implement a few functions to communicate with the UI application.

I can do later a fork (maybe this week or the next one) of your firmware and apply the changes to make it compatible with the UI application. I haven't documented the process, but if you want to do it yourself you can compare the firmware from my repo with the original from @ChromeBee to see the changes.

Edit: For some reason all one-file executables made with Pyinstaller give a false positive and are flagged as malware on Windows. I will commit some changes today to package the app in a directory instead of a single file to avoid false positives (fixed it in v1.0.1)

@AndunHH
Copy link
Owner Author

AndunHH commented Nov 11, 2024

Great to hear from you again!

At the moment I don't have time to code it myself, but I'm looking forward to review and integrate you suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants