Skip to content

Add low battery shutoff support - #260

Open
subtervisor wants to merge 4 commits into
profi200:masterfrom
subtervisor:low_battery_shutoff
Open

subtervisor wants to merge 4 commits into
profi200:masterfrom
subtervisor:low_battery_shutoff

Conversation

@subtervisor

Copy link
Copy Markdown
Contributor

In order to fix #220, adds an occasional check that checks the battery level and charging status. If the battery level is below the minimum threshold (3% by default), it will abort the current game and shut down to ensure that any pending save data is properly flushed.

In order to fix profi200#220, adds an occasional check that checks the battery
level and charging status. If the battery level is below the minimum
threshold (3% by default), it will abort the current game and shut down
to ensure that any pending save data is properly flushed.
@profi200

Copy link
Copy Markdown
Owner

The MCU has interrupts to notify the SoC of low power. I would prefer using these instead of polling the MCU. The drawback is we can't configure them.

https://github.com/profi200/libn3ds/blob/ccbb6a94d60bea2e6a1901263251636b192bad3f/include/arm11/drivers/mcu_regmap.h#L126

@subtervisor

Copy link
Copy Markdown
Contributor Author

It looks to me like that requires overriding the way the IRQ driver works for ARM11, as it takes over the MCU interrupt ISR and doesn't have the low battery alarm in the mask?

@subtervisor

Copy link
Copy Markdown
Contributor Author

Alright, updated to use a different mechanism utilizing the low battery interrupt. This enables the interrupt and handles it by passing it along as an extra key, similar to the volume slider change and battery charge start/stop events.

The code is dependent on profi200/libn3ds#7

@subtervisor

Copy link
Copy Markdown
Contributor Author

I made it shut off at the 5 (or 6?) percent cutoff, but we may be able to get away with the 0% alarm? I'm just not sure if there would necessarily be enough time/battery to properly save flash in the 0% case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Game doesnt save when the battery discharges

2 participants