-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0188971
commit 6c9534a
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import app | ||
from app_components.tokens import clear_background | ||
|
||
from app_components.dialog import YesNoDialog | ||
|
||
|
||
class PowerOff(app.App): | ||
async def run(self, render_update): | ||
# Render initial state | ||
await render_update() | ||
|
||
# Create a yes/no dialogue, add it to the overlays | ||
dialog = YesNoDialog("Power off?", self) | ||
self.overlays = [dialog] | ||
|
||
# Wait for an answer from the dialogue, and if it was yes, randomise colour | ||
if await dialog.run(render_update): | ||
import machine | ||
import bq25895 | ||
|
||
bq25895.bq25895(machine.I2C(7)).disconnect_battery() | ||
|
||
# Remove the dialogue and re-render | ||
self.overlays = [] | ||
|
||
while True: | ||
await render_update() | ||
|
||
def draw(self, ctx): | ||
ctx.save() | ||
clear_background(ctx) | ||
ctx.restore() | ||
|
||
self.draw_overlays(ctx) |