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

fix(AFHDS3): Sync UI with Flysky AFHDS3 module stored settings #3501

Merged
merged 15 commits into from
Jun 19, 2023

Conversation

richardclli
Copy link
Collaborator

@richardclli richardclli commented Apr 21, 2023

Fixes #3491, fixes #3477 (reworked), fixes #3682

Summary of changes:

  • UI change receiverID -> TX get config -> refresh UI
  • UI change options -> TX set config
  • model load -> TX get config -> refresh UI
  • receiver connected -> options that is only changeable in bind will be disabled for edit

@richardclli richardclli marked this pull request as draft April 21, 2023 02:33
@philmoz
Copy link
Collaborator

philmoz commented Apr 21, 2023

It would need some way to reset the flag otherwise the UI will keep updating.

It think it would be better to just store the get_tmr10ms() when a change is made to the module that needs a UI update.
Then the UI code can use this to see if a refresh is needed, and no reset is needed (the UI code just compares the last refresh time to the last module changed time).

@richardclli richardclli self-assigned this Apr 21, 2023
@richardclli richardclli added this to the 2.9 milestone Apr 21, 2023
@philmoz
Copy link
Collaborator

philmoz commented Apr 21, 2023

PR #3502 has code to update the module window if the module refresh time changes. You should be able to merge that PR into your branch.

Note: I have no way to test this so I can't guarantee it will work.

Also, to avoid unnecessary updates, the module code should take care to only update the 'lastModuleUpdatedTime' value when the underlying module data has actually changed.

@pfeerick pfeerick added bug 🪲 Something isn't working enhancement ✨ New feature or request labels Apr 21, 2023
@richardclli
Copy link
Collaborator Author

Thank you, I will check and see later when I have access to my radios.

@pfeerick
Copy link
Member

This appears to be working for EL18 - changing receiver ID now triggers a UI refresh when different receivers have different settings, which also means the RF mode (Fast 8Ch, Routine 18Ch etc) is updating to correctly reflect different receiver profiles.

@richardclli
Copy link
Collaborator Author

This appears to be working for EL18 - changing receiver ID now triggers a UI refresh when different receivers have different settings, which also means the RF mode (Fast 8Ch, Routine 18Ch etc) is updating to correctly reflect different receiver profiles.

Nice, now need to check how the change of options can update a connected receiver.

@pfeerick
Copy link
Member

Nice, now need to check how the change of options can update a connected receiver.

If it truely is runtime, and you refer to the options like servo frequency, purpose of the NP# ports, etc, that update action could perhaps be triggered as you exit the screen - which I think is similar to how R9M Access, ISRM, etc do it.

@richardclli
Copy link
Collaborator Author

Nice, now need to check how the change of options can update a connected receiver.

If it truely is runtime, and you refer to the options like servo frequency, purpose of the NP# ports, etc, that update action could perhaps be triggered as you exit the screen - which I think is similar to how R9M Access, ISRM, etc do it.

I think I will try to add hooks to the UI that will mark the config as dirty and update the config during normal operation cycles.

@richardclli richardclli force-pushed the fix-3491 branch 2 times, most recently from 3baf692 to 3980f6a Compare April 24, 2023 09:15
@richardclli
Copy link
Collaborator Author

@philmoz seems the refreahing logic will stop other modules from refreshing properly, e.g. MPM

@philmoz
Copy link
Collaborator

philmoz commented Apr 24, 2023

seems the refreahing logic will stop other modules from refreshing properly, e.g. MPM

I don't understand - can you provide more details on what is happening.

@richardclli
Copy link
Collaborator Author

seems the refreahing logic will stop other modules from refreshing properly, e.g. MPM

I don't understand - can you provide more details on what is happening.

The MPM status is not refreshed with this change i.e. MPM version no. is not shown, just white.

I found that MPM has timestamp to control the refresh.

https://github.com/EdgeTX/edgetx/blob/main/radio/src/telemetry/multi.cpp#L254-L257

Let me check the code of other modules first. I think we need a unified mechanism to control options refresh in UI.

@richardclli richardclli changed the title Added flags to indicate module data is dirty for UI to refresh. Sync UI with Flysky AFHDS3 settings that stored in module Apr 26, 2023
@richardclli
Copy link
Collaborator Author

@philmoz I finally got it right. Overriding checkEvents need to call super class method otherwise there will be something missing for the children.

void FlySkySettings::checkEvents() {
if (afhds3::getConfig(moduleIdx)->others.lastUpdated > lastRefresh) {
update();
}
FormGroup::checkEvents();
}

Thanks for your code that enlighten me.

@richardclli richardclli force-pushed the fix-3491 branch 3 times, most recently from 81d08db to bd6acd9 Compare May 9, 2023 05:10
@richardclli richardclli force-pushed the fix-3491 branch 2 times, most recently from 137cfca to f94559b Compare May 23, 2023 01:44
@richardclli
Copy link
Collaborator Author

Now the settings can change online. Need some time for people to test. Flysky will help to test as well.

@richardclli
Copy link
Collaborator Author

@raphaelcoeffic I have change some state flow in the AFHDS3 state machine, please help me to review to see if there maybe any loop holes.

@richardclli richardclli marked this pull request as ready for review June 8, 2023 07:39
@richardclli
Copy link
Collaborator Author

@raphaelcoeffic @philmoz Any more reviews and comments?

BTW, I have delivered firmware with this PR for users in China. Up to now, it seems the changes works well and stable.

@philmoz
Copy link
Collaborator

philmoz commented Jun 18, 2023

Nothing obvious leaps out at me.

@pfeerick
Copy link
Member

pfeerick commented Jun 19, 2023

It seems like I did something right there 😁 Before Companion, and after Companion

image

@pfeerick pfeerick changed the title Sync UI with Flysky AFHDS3 settings that stored in module fix(AFHDS3): Sync UI with Flysky AFHDS3 module stored settings Jun 19, 2023
@pfeerick pfeerick added the color Related generally to color LCD radios label Jun 19, 2023
Copy link
Member

@pfeerick pfeerick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is more work to be done for AFHDS2/3, but this PR seems to do what it says on the tin ;) Settings saved to file now also survive a read/write pass through Companion. They cannot be fully configured with Companion yet, as it seems we need to purge FRM302 related entries before we can fully match the FRM303 in Companion... but one problem at a time.

@richardclli richardclli merged commit cb533f4 into main Jun 19, 2023
@pfeerick pfeerick deleted the fix-3491 branch June 19, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working color Related generally to color LCD radios enhancement ✨ New feature or request
Projects
None yet
4 participants