Skip to content
This repository was archived by the owner on Oct 28, 2023. It is now read-only.

Commit 9f6c61f

Browse files
committed
Removed all the pops
1 parent 106fac8 commit 9f6c61f

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

esp32/modules/badge_event_reminder.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ def exit(p):
55
appglue.home()
66

77
ugfx.clear(ugfx.WHITE)
8-
ugfx.string(0, 0, "Message here!", "PermanentMarker22", ugfx.BLACK)
9-
ugfx.string(0, 25, "Hello wolrd", "Roboto_Regular12", ugfx.BLACK)
10-
ugfx.string(0, 25+13, "Nothing here yet!", "Roboto_Regular12", ugfx.BLACK)
8+
ugfx.string(0, 0, "SHA2017 Badge", "PermanentMarker22", ugfx.BLACK)
9+
ugfx.string(0, 25, "Please join us for a short talk on how the", "Roboto_Regular12", ugfx.BLACK)
10+
ugfx.string(0, 25+13, "official SHA2017 badge was designed,", "Roboto_Regular12", ugfx.BLACK)
11+
ugfx.string(0, 25+13*2, "some nice numbers and an overview of what all", "Roboto_Regular12", ugfx.BLACK)
12+
ugfx.string(0, 25+13*3, "of you are doing with it.", "Roboto_Regular12", ugfx.BLACK)
1113

14+
ugfx.string(0, 25+13*5, "The events starts now, in room 'No'!", "Roboto_Regular12", ugfx.BLACK)
1215
ugfx.string(0, ugfx.height()-13, "Press any key to close reminder.", "Roboto_Regular12", ugfx.BLACK)
1316
ugfx.set_lut(ugfx.LUT_FULL)
1417
ugfx.flush()

esp32/modules/tasks/services.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ def draw_task():
134134

135135
drawCallback(False) # Prepare draw
136136

137-
newDrawCallbacks = []
138-
for cbs in drawCallbacks:
139-
newDrawCallbacks.append(cbs)
137+
deleted = []
138+
140139
for i in range(0, len(drawCallbacks)):
141140
cb = drawCallbacks[i]
142141
rqi = 0
@@ -146,16 +145,18 @@ def draw_task():
146145
except BaseException as e:
147146
print("[SERVICES] Exception in service draw:")
148147
sys.print_exception(e)
149-
newDrawCallbacks.pop(i)
148+
deleted.append(cb)
150149
continue
151150
if rqi>0 and rqi<requestedInterval:
152151
# Service wants to loop again in rqi ms
153152
requestedInterval = rqi
154153
elif rqi<=0:
155154
# Service doesn't want to draw again until next wakeup
156-
newDrawCallbacks.pop(i)
157-
drawCallbacks = newDrawCallbacks
158-
del(newDrawCallbacks)
155+
deleted.append(cb)
156+
157+
for i in range(0,len(deleted)):
158+
print("[DEBUG] Deleted draw callback: ",dcb)
159+
drawCallbacks = tuple(dcb for dcb in drawCallbacks if dcb!=deleted[i])
159160

160161
badge.eink_busy_wait()
161162

esp32/modules/virtualtimers.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,15 @@ def pm_time():
5353

5454
def delete(callback):
5555
global scheduler
56-
newScheduler = []
57-
for task in scheduler:
58-
newScheduler.append(task)
56+
5957
found = False
6058
for i in range(0, len(scheduler)):
6159
if (scheduler[i]["cb"]==callback):
62-
newScheduler.pop(i)
6360
found = True
6461
break
65-
scheduler = newScheduler
62+
63+
scheduler = tuple(task for task in scheduler if task['cb']!=callback)
64+
6665
return found
6766

6867
def update(target, callback):
@@ -86,14 +85,10 @@ def activate(p):
8685
def stop():
8786
global timer
8887
timer.deinit()
89-
88+
9089
def timer_callback(tmr):
9190
global scheduler
92-
global period
93-
newScheduler = []
94-
for task in scheduler:
95-
newScheduler.append(task)
96-
91+
global period
9792
s = len(scheduler)
9893
for i in range(0, len(scheduler)):
9994
scheduler[i]["pos"] += period
@@ -105,11 +100,10 @@ def timer_callback(tmr):
105100
sys.print_exception(e)
106101
newTarget = -1
107102
if newTarget > 0:
108-
newScheduler[i]["pos"] = 0
109-
newScheduler[i]["target"] = newTarget
103+
scheduler[i]["pos"] = 0
104+
scheduler[i]["target"] = newTarget
110105
else:
111-
try:
112-
newScheduler.pop(i)
113-
except:
114-
print("CAN NOT REMOVE TASK ?!?!")
115-
scheduler = newScheduler
106+
scheduler[i]["pos"] = -1
107+
scheduler[i]["target"] = -1
108+
109+
scheduler = tuple(task for task in scheduler if task["pos"]>=0)

0 commit comments

Comments
 (0)
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