MobiFlight / MobiFlight-Connector

MobiFlight is an open source project that allows you to create your own home cockpit for your favorite flight simulator in a flexible, affordable and extremely user-friendly way.
https://mobiflight.com
MIT License
231 stars 102 forks source link

Easy direction change for Encoders and Steppers #1250

Open DocMoebiuz opened 1 year ago

DocMoebiuz commented 1 year ago

Is your feature request related to a problem? Please describe. Many times I found that after connecting a device, e.g., encoder - it turned out I had the pins wrong which resulted in a wrong direction when twisting.

A similar thing applies to a Stepper. Depending on how many gears it has, you might find the needle it drives will travel in the wrong direction. You can take care of it on config level too, but it might be more intuitive if the stepper simply turned the opposite direction. For a 4 pin stepper changing the pins is not 100% clear to the user.

Describe the solution you'd like A button that says: change direction.

Describe alternatives you've considered For encoder and stepper there is the current workaorund to assign the pins manually. This has to be improved too. #573

Additional context

573

JaimeLeon2 commented 1 year ago

Do we really need another level of indirection? For stepper and encoders we have many layers where the direction can be changed:

  1. The wiring layer: inverting the cables
  2. Device configuration: inverting the assigned pins
  3. Input configuration: inverting the assigned events
  4. Inverting the encoder or stepper scale via Transform
  5. Changing the direction with custom RPN code

IMO, if you really want to have a one button invert direction function, have this function explicitly change the pins assigned automatically, instead of working behind the scenes to change the direction. I think working behind the scenes would be an unnecessary complication and more confusing to us trying to figure out why something happens.

tigert commented 1 year ago

Potentiometer is yet another case where this would be useful. And you cannot swap the pins in analog input configuration, because there is just one pin. However the order of GND and VCC connection to the other pins determines the direction, but it is not immediately obvious from the pot itself as to which way around it should be connected unless I guess you measure it with multimeter.

My initial reaction is this:

Input

Reversal

For INPUTS, it would be good to have the device level configuration for reversal so that the data that comes from the Arduino -> Connector is already the correct direction, so that your log entries show useful values. Having the logs backwards and your config reversed makes the log values harder to read and map to your use case. And for potentiometers it is not intuitively obvious which way it should be connected. I got several wrong on PCBs :-)

Device range mapping

For input the log entries should be useful, so calibration and reversal should be in device config.

I also think Connector should use floating point percentage 0.00 to 100.00 % range for both precision and more intuitive representation - so 50% is halfway of your movement etc. I suggest we do this also for joystick devices so that each device, when selected, has the same range, which helps you write presets and share input configs that just work with any analog input / joustick range. We can do this internally with more precision, to take advantage of 16 bit joystick axis etc, but I think percentage with two decimals for example is fine for the log, and also helps in the user interface level for consistency.

Output to simulator

Here we encounter different ranges that are needed for the simulator (MSFS2020, X-plane, also FSUIPC ranges)

I think we could have a selector to select what range the configuration item sends to the simulator - map the input device to the most common ranges in the simulator input: Most stuff in msfs are 0 to 100%, some are -16383 to 16383 etc - ideally build the Jaime pot tool into this, let the user choose:

Transform lets you do further stuff, but I think these are quite common. Or maybe we should do it at preset level?

Outputs

For outputs I would think it is more flexible to be able to set the direction at config item level, because this lets you configure everything in the same place. I kind of think this is two-fold:

Device config:

Output config:

Thoughts?