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

TPro - Port of OpenTX function switches management #1694

Merged
merged 7 commits into from
Mar 21, 2022

Conversation

Batambatam
Copy link
Contributor

@Batambatam Batambatam commented Mar 15, 2022

Summary of changes:
Port of opentx/opentx#8847
Credits go to @elecpower and @3djc who did all the work for OpenTX.

Function switches of Jumper T-Pro can be setup and used in inputs, mixes, etc. and saved / loaded.

@pfeerick pfeerick added the companion Related to the companion software label Mar 15, 2022
@pfeerick pfeerick added this to the 2.7 milestone Mar 15, 2022
companion/src/modeledit/setup.cpp Outdated Show resolved Hide resolved
companion/src/firmwares/modeldata.cpp Outdated Show resolved Hide resolved
companion/src/firmwares/edgetx/yaml_rawsource.cpp Outdated Show resolved Hide resolved
@pfeerick
Copy link
Member

pfeerick commented Mar 16, 2022

My initial tests on TPro with this seem to have a few hiccups still...

  1. inactive and active are reversed - most noticeable if you have all but one switches inactive and then all but one them light up in your face at boot 😆 Actually, I'll retract that for now... I haven't been able to get it to happen a second time, so I won't rule out me stupidly setting it inverted myself...

  2. saving of name (and reading back from) yaml mangled... i.e.

functionSwitchNames:
  0: SL
  1: HOR
  2: AIR
  3: RTH
  4: PH
  5: BP

should be

switchNames: 
   0:
      val: "SL"
   1:
      val: "HOR"

Other than that, this seems to be working fine :)

@Batambatam
Copy link
Contributor Author

Batambatam commented Mar 16, 2022

Thanks a lot for this report, have some homework for this evening 😺

@pfeerick
Copy link
Member

I've retracted one issue, so it's a bit less now ;)

@Batambatam
Copy link
Contributor Author

Batambatam commented Mar 18, 2022

Hi, I've just pushed some corrections on YAML generation as per the recommendations (tested with jumper TPro radio).
@pfeerick there were an inversion with the active/inactive state, this confirms what you noticed first.

I also noted that radio does not display function switches the same way through model setup, inputs/mixes and logical/custom screens. Function switches names are only displayed on model setup screen. Other screens mix "SW1" to "SW6" for sources and "SE" to "SJ" for switches.

I am not comfortable with that part yet as the firmware handles function switches sometimes like normal switches and sometimes like function switches so I left it as is for now.

@pfeerick
Copy link
Member

Yeah, there are some oddites on the TPro function switches stuff still, i.e. #1488 ... so it will be a work in progress.

@pfeerick pfeerick changed the title TPro - Port of OpenTX function switches management (https://github.com/opentx/opentx/pull/8847) TPro - Port of OpenTX function switches management Mar 19, 2022
@pfeerick
Copy link
Member

pfeerick commented Mar 19, 2022

Much better! :) And I think I finally have a handle on what was bugging me before... it seems like functionSwitchLogicalState isn't being populated correctly? So basically, this config:

image

does not light up 1, 3 and 5 when that model is switched to (but curiously, it is if it is the active model and the radio is turned on).

i.e. this is what companion is writing

functionSwitchConfig: 2730
functionSwitchGroup: 1365
functionSwitchStartConfig: 1092
functionSwitchLogicalState: 0
switchNames:
  0:
    val: SL
  1:
    val: HOR
  2:
    val: AIR
  5:
    val: BEP

after changing a setting (i.e. I just changed a character in the model name so the firmware updated the file), this is what the radio changes it to the following, and now it correctly lights up when switching models.

functionSwitchConfig: 2730
functionSwitchGroup: 1365
functionSwitchStartConfig: 1092
functionSwitchLogicalState: 21
switchNames: 
   0:
      val: "SL"
   1:
      val: "HOR"
   2:
      val: "AIR"
   5:
      val: "BEP"

@pfeerick
Copy link
Member

I'm not going to hold it against this PR though, as I don't think it's completely it's fault, there is something rather strange going on with function switches generally, so it could also be something on the radio side still.

@elecpower
Copy link
Collaborator

Suggest you check the code from these has been ported:
opentx/opentx#8845
opentx/opentx#8837
opentx/opentx#8834
opentx/opentx#8832

@pfeerick
Copy link
Member

pfeerick commented Mar 20, 2022

Thanks for those Neil.

opentx/opentx#8832 and opentx/opentx#8834 were both imported via #1479, even though the first PR was effectively overwritten by the second. It also pulled in opentx/opentx#8837

opentx/opentx#8845 should be pulled in shortly via #1705

So still on the hunt 🕵️🐛

@Batambatam
Copy link
Contributor Author

Batambatam commented Mar 20, 2022

Much better! :) And I think I finally have a handle on what was bugging me before... it seems like functionSwitchLogicalState isn't being populated correctly? So basically, this config:

image

does not light up 1, 3 and 5 when that model is switched to (but curiously, it is if it is the active model and the radio is turned on).

i.e. this is what companion is writing

functionSwitchConfig: 2730
functionSwitchGroup: 1365
functionSwitchStartConfig: 1092
functionSwitchLogicalState: 0
switchNames:
  0:
    val: SL
  1:
    val: HOR
  2:
    val: AIR
  5:
    val: BEP

I checked on main branch and companion was already writing functionSwitchLogicalState: 0
By the way, I tested with a different config where it starts with 1 lit up and all 5 switches in the same group. When switching models back and forth, 1 turns off and stays.
As soon as I press any function switch from the group it seems to get back to a normal behavior when switching models.

@pfeerick
Copy link
Member

Yes, I'll have to read through and try to decode what JC is up to with the function switches to see what that setting is actually for, as it seems to change on the radio... Regardless, I think the current issues arrise from the firmware, not companion, so in this goes... merge conflicts in other PRs (I'm assuming)... here we go! 😆

@pfeerick pfeerick merged commit ab15a5a into EdgeTX:main Mar 21, 2022
eshifri pushed a commit to eshifri/edgetx that referenced this pull request Mar 28, 2022
…X#1694)

* TPro - Port of OpenTX function switches management (opentx/opentx#8847)

* cleanup

* Corrections

* Fix YAML generation and adjusted switches to match TPRO firmware

Co-authored-by: Batam <batam@macbook-pro.home>
@Batambatam Batambatam deleted the cpn-function-switches-port branch April 4, 2022 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
companion Related to the companion software
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants