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 battery status and optimize and fix status pull #3397

Merged
merged 5 commits into from
Apr 9, 2023

Conversation

haslinghuis
Copy link
Member

@haslinghuis haslinghuis commented Mar 30, 2023

LiveStatusUpdate stops intermittent. This PR fixes the update and removes duplicate status pulls optimizing (serial) communication.

  • FC.ANALOG was wrongly assigned with FC.INITIAL_CONFIG
  • Update date.now to performance.now
  • Increase timer for status polling from 100 to 250ms
  • Use setInterval instead of restarting GUI.timeout_add() which failed intermittent
  • Cleanup of status polls as it's running consistent in serial backend now

@haslinghuis haslinghuis added this to the 10.10.0 milestone Mar 30, 2023
@haslinghuis haslinghuis self-assigned this Mar 30, 2023
@github-actions

This comment has been minimized.

@blckmn
Copy link
Member

blckmn commented Mar 31, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> FAIL
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> FAIL
  • assigned to an approver -> PASS
  • approver count at least three -> FAIL

@haslinghuis haslinghuis changed the title Fix status Fix battery status Mar 31, 2023
@@ -311,7 +311,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
FC.ANALOG.rssi = data.readU16(); // 0-1023
FC.ANALOG.amperage = data.read16() / 100; // A
FC.ANALOG.voltage = data.readU16() / 100;
FC.ANALOG.last_received_timestamp = Date.now();
FC.ANALOG.last_received_timestamp = performance.now();
Copy link
Member

Choose a reason for hiding this comment

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

I think performance.now() is relative to the page load, while Date.now() to the UNIX epoch. To be used by a timestamp is good to use the performance one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Double checked, both work, but performance.now() seems to be preferred.

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced the GUI.timeout_add() - now the liveDataRefreshTimer keeps running 🎉

Copy link
Member Author

Choose a reason for hiding this comment

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

Also now it runs perfectly all the time we can remove pulling from some tabs to optimize serial communication

@github-actions

This comment has been minimized.

@haslinghuis haslinghuis force-pushed the fix-status branch 2 times, most recently from b2f5e52 to 79031f5 Compare April 5, 2023 22:31
@haslinghuis haslinghuis changed the title Fix battery status Fix battery status and optimize and fix status pull Apr 5, 2023
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@haslinghuis
Copy link
Member Author

Rebased on master

@github-actions

This comment has been minimized.

@sonarcloud
Copy link

sonarcloud bot commented Apr 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2023

Do you want to test this code? Here you have an automated build:
Betaflight-Configurator-Android
Betaflight-Configurator-Linux
Betaflight-Configurator-macOS
Betaflight-Configurator-Windows
WARNING: It may be unstable and result in corrupted configurations or data loss. Use only for testing!

@haslinghuis haslinghuis requested a review from blckmn April 9, 2023 01:12
@haslinghuis haslinghuis merged commit 5344781 into betaflight:master Apr 9, 2023
9 checks passed
@haslinghuis haslinghuis deleted the fix-status branch April 9, 2023 23:42
@HThuren
Copy link
Member

HThuren commented Apr 10, 2023

@haslinghuis Great update, I really experience faster execution, well done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

None yet

5 participants