Skip to content

[plugin] batteryCare: Tune charge characteristics#8934

Closed
ghost wants to merge 10 commits into
masterfrom
unknown repository
Closed

[plugin] batteryCare: Tune charge characteristics#8934
ghost wants to merge 10 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Mar 21, 2022

Copy link
Copy Markdown

Not connected to any power-saving strategies, but can improve lifetime of batteries.

Currently, quite common sense for Lithium (anything) is, that for battery health it is important not to overcharge and not to undercharge it.

A sane strategy is not to charge it to 100% and not to suck it out (0%). On Laptops and electric vehicles this should be done by the intelligent charger.

On our devices, we don't really know what the vendor has implemented.

This PR allows to set a start_charging_threshold and a stop_charging_threshold for the battery (on a Sage with power cover the batteries).


This change is Reviewable

@ghost ghost changed the title Battery care: Tune charge characteristics [plugin] batteryCare: Tune charge characteristics Apr 4, 2022
@ghost ghost added the Plugin label May 29, 2022
@ghost

ghost commented Jun 14, 2022

Copy link
Copy Markdown
Author

Working now (as expected). Now some long time tests have to follow.

@ghost

ghost commented Jun 24, 2022

Copy link
Copy Markdown
Author

We are coming to an end, hopefully.

@ghost ghost marked this pull request as ready for review June 26, 2022 20:16
@ghost ghost requested review from Frenzie, NiLuJe, pazos and poire-z as code owners June 26, 2022 20:16
@NiLuJe

NiLuJe commented Jun 26, 2022

Copy link
Copy Markdown
Member

Random query: what does the sunxi otg flag do that benefits the use-case here?

Comment thread frontend/device/sdl/device.lua Outdated
startTextInput = SDL.startTextInput,
stopTextInput = SDL.stopTextInput,
canOpenLink = getLinkOpener,
canControlCharge = yes, -- development of batteryCare

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please make it a property of the Emulator, not a property of a generic SDL device.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't this redundant with hasBattery btw?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@Frenzie: It is not redundant, as hasBattery tells us there is a battery and canControlCharge tells us we can turn charging on/off programmatically.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then it definitely doesn't belong here.

@ghost

ghost commented Jun 27, 2022

Copy link
Copy Markdown
Author

Random query: what does the sunxi otg flag do that benefits the use-case here?

IIRC (I will check that later today): The otg flag is needed, because you can not toggle batt and aux_batt independently. It took me quite some time to get this working as expected. There are quite some states and transistions in the state machine (bat(on/off/x), aux_bat(on/off/x), is_charger_present(yes/no)).

@ghost

ghost commented Jun 28, 2022

Copy link
Copy Markdown
Author

Now works when using a data cable for charging, too.

@ghost

ghost commented Jul 3, 2022

Copy link
Copy Markdown
Author

I have forgot to mention, that with this PR the battery and aux battery are charged both at the same time (and not one after the other).

@ghost

ghost commented Jul 11, 2022

Copy link
Copy Markdown
Author

This is also ready from my side

@ghost ghost marked this pull request as draft July 27, 2022 21:27
@ghost

ghost commented Jul 27, 2022

Copy link
Copy Markdown
Author

One last quirk exists.
When the device is sleeping (30s after sleep) and I want to charge it, only the internal battery charges, the aux batt does not charge :/

If I plug the device in, out and in again (within a few seconds) then everything works as expected.

@NiLuJe

NiLuJe commented Jul 27, 2022

Copy link
Copy Markdown
Member

I'm seeing wonky charging behavior (and charger detection, for that matters) if I boot the device while plugged in to a wall charger, FWIW ;).

(This is... not a new issue. Kindles have had a long history of weird shit happening when you boot them plugged in ;p).

@ghost

ghost commented Aug 7, 2022

Copy link
Copy Markdown
Author

Pushing my last developer version for reference, maybe I will try it on a newer FW again.

Normal reading works, but if it comes to suspend ...

Most times it works, but then suddenly either charging of the power cover or the internal battery can not be turned on.

There are quite some incomprehensible quirks when turning charging on and off with the power cover during suspend.

Plugging the device into a charger seems to solve this problem, but I did not find a proper way for this programmatically. (Even Nickel can't do that, only a restart or plug in solves it.) It seems that the cilix FSM has some quirks, but I can not confirm this.

@ghost ghost closed this Aug 7, 2022
@NiLuJe

NiLuJe commented Aug 7, 2022

Copy link
Copy Markdown
Member

Yeah, the PowerCover behavior is, quite frankly, hilariously broken :/.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants