Skip to content

Allow services to execute a special draw function just before sleeping #181

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

Merged
merged 1 commit into from
Aug 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions esp32/modules/splash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# File: splash.py
# Version: 5
# Version: 6
# Description: Homescreen for SHA2017 badge
# License: MIT
# Authors: Renze Nicolai <renze@rnplus.nl>
Expand Down Expand Up @@ -109,7 +109,7 @@ def splash_input_init():

def onSleep(idleTime):
draw(False, True)
services.force_draw()
services.force_draw(True)
draw(True, True)

### PROGRAM
Expand Down
21 changes: 13 additions & 8 deletions esp32/modules/tasks/services.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# File: services.py
# Version: 4
# Version: 5
# API version: 2
# Description: Background services for SHA2017 badge
# License: MIT
Expand Down Expand Up @@ -111,10 +111,7 @@ def setup(drawCb=None):
print("[SERVICES] Loop requested but not defined in service "+app)

if drawEnabled and drawCb:
try:
drawCallbacks.append(srv.draw)
except:
print("[SERVICES] Draw requested but not defined in service "+app)
drawCallbacks.append(srv)

# Add the script to the global service list
services.append(srv)
Expand All @@ -137,9 +134,9 @@ def draw_task():
deleted = []

for i in range(0, len(drawCallbacks)):
cb = drawCallbacks[i]
rqi = 0
try:
cb = drawCallbacks[i].draw
[rqi, space_used] = cb(y)
y = y - space_used
except BaseException as e:
Expand All @@ -155,6 +152,7 @@ def draw_task():
deleted.append(cb)

for i in range(0,len(deleted)):
dcb = deleted[i]
print("[DEBUG] Deleted draw callback: ",dcb)
drawCallbacks = list(dcb for dcb in drawCallbacks if dcb!=deleted[i])

Expand All @@ -177,12 +175,19 @@ def draw_task():
drawCallback(True) # Complete draw
return retVal

def force_draw():
def force_draw(goingToSleep=False):
global drawCallbacks
if len(drawCallbacks)>0:
y = ugfx.height()
for cb in drawCallbacks:
for srv in drawCallbacks:
try:
if not goingToSleep:
cb = srv.draw
else:
try:
cb = srv.draw_going_to_sleep
except:
cb = srv.draw
[rqi, space_used] = cb(y)
y = y - space_used
except BaseException as e:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy