Skip to content

Commit

Permalink
Add missing poweroff app
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewWilkes committed May 26, 2024
1 parent 0188971 commit 6c9534a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions modules/firmware_apps/poweroff.py
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)

0 comments on commit 6c9534a

Please sign in to comment.