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

Allow higher-resolution SoC in live view header #1197

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

ranma
Copy link

@ranma ranma commented Aug 25, 2024

Commit accc70d added the battery SoC to the live view header. But due to getSoC returning an int the precision is currently limited.

This changes getSoC to return float so when a source with higher precision is available the full precision is shown.

Commit accc70d added the battery SoC to
the live view header. But due to getSoC returning an int the precision
is currently limited.

This changes getSoC to return float so when a source with higher
precision is available the full precision is shown.
@AndreasBoehm
Copy link
Member

Good catch!
@schlimmchen do you know anyone with a Victron SmartShunt, which is the only source which provides decimals for SoC, that could test this?

@schlimmchen
Copy link
Member

I guess @ranma can show us a respective screenshot and then we'll believe that it works. However, I think we need to use %.1f as the format specifier when printing the SoC, afaik otherwise the float will print with way too many decimals?

@ranma
Copy link
Author

ranma commented Aug 28, 2024

I guess @ranma can show us a respective screenshot and then we'll believe that it works.

Not until I've set up an emulation test rig. I had to switch the battery back to victron protocol for the time being and I don't have remote access to the console.

However, I think we need to use %.1f as the format specifier when printing the SoC, afaik otherwise the float will print with way too many decimals?

Yeah, that's probably not a bad idea. For some files like PylontechCanReceiver.cpp it may even make more sense to store the integer temporary and keep the format as %d :)

@ranma
Copy link
Author

ranma commented Aug 31, 2024

Screenshot from replaying Victron BMV702 logs I found on https://github.com/karioja/vedirect/blob/master/test/bvm702.dump:
image

$ stty raw 19200 < /dev/ttyUSB0 
$ cat /tmp/bvm702.dump  > /dev/ttyUSB0

@ranma
Copy link
Author

ranma commented Aug 31, 2024

However, I think we need to use %.1f as the format specifier when printing the SoC, afaik otherwise the float will print with way too many decimals?

Well, looking again the existing log printfs for voltage (which is already float with 2 decimals after the point) also uses just %f, so it should be fine as-is.

@schlimmchen schlimmchen merged commit a87f9fa into hoylabs:development Sep 2, 2024
8 checks passed
@ranma ranma deleted the soc-resolution branch September 9, 2024 09:09
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants