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 default value for discharge current limit #1294

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

ranma
Copy link

@ranma ranma commented Sep 28, 2024

If the default type is an int, setting to a fractional value is not possible.

Presumably this is because in
target.DischargeCurrentLimit = source["discharge_current_limit"] | BATTERY_DISCHARGE_CURRENT_LIMIT; the JSON library uses the default to force the expected type and on type mismatch the default is used.

As per https://arduinojson.org/v7/api/jsonvariant/or/: defaultValue: the value to return if the JsonVariant is null or incompatible with the requested type.

@schlimmchen
Copy link
Member

@AndreasBoehm I suggest the "rebase and merge" strategy here.

ranma added 2 commits October 10, 2024 18:05
If the default type is an int, setting to a fractional value is not possible.

Presumably this is because in
`target.DischargeCurrentLimit = source["discharge_current_limit"] | BATTERY_DISCHARGE_CURRENT_LIMIT;`
the JSON library uses the default to force the expected type and on type mismatch the default is used.

As per https://arduinojson.org/v7/api/jsonvariant/or/:
`defaultValue: the value to return if the JsonVariant is null or incompatible with the requested type.`
When the limit is valid, use the actual configured limit, not the bool value :)
@AndreasBoehm AndreasBoehm force-pushed the discharge-limit-default-float branch from be23665 to 878d1fd Compare October 10, 2024 16:05
@AndreasBoehm
Copy link
Member

Thank you for finding and fixing those issues @ranma

@AndreasBoehm AndreasBoehm merged commit 28c0c9d into hoylabs:development Oct 10, 2024
8 checks passed
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 Nov 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