Skip to content

Commit cacc897

Browse files
Remove throttling from update_ui_threadsafe_if_foreground
This isn't used anywhere.
1 parent fb5672b commit cacc897

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

internal_filesystem/builtin/apps/com.micropythonos.settings/assets/calibrate_imu.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class CalibrationState:
2727
class CalibrateIMUActivity(Activity):
2828
"""Guide user through IMU calibration process."""
2929

30-
# State
3130
current_state = CalibrationState.READY
3231

3332
# Widgets

internal_filesystem/lib/mpos/app/activity.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
class Activity:
66

7-
throttle_async_call_counter = 0
8-
97
def __init__(self):
108
self.intent = None # Store the intent that launched this activity
119
self.result = None
@@ -19,7 +17,6 @@ def onStart(self, screen):
1917

2018
def onResume(self, screen): # app goes to foreground
2119
self._has_foreground = True
22-
mpos.ui.task_handler.add_event_cb(self.task_handler_callback, 1)
2320

2421
def onPause(self, screen): # app goes to background
2522
self._has_foreground = False
@@ -69,9 +66,6 @@ def finish(self):
6966
def has_foreground(self):
7067
return self._has_foreground
7168

72-
def task_handler_callback(self, a, b):
73-
self.throttle_async_call_counter = 0
74-
7569
# Execute a function if the Activity is in the foreground
7670
def if_foreground(self, func, *args, event=None, **kwargs):
7771
if self._has_foreground:
@@ -85,14 +79,10 @@ def if_foreground(self, func, *args, event=None, **kwargs):
8579
return None
8680

8781
# Update the UI in a threadsafe way if the Activity is in the foreground
88-
# The call may get throttled, unless important=True is added to it.
8982
# The order of these update_ui calls are not guaranteed, so a UI update might be overwritten by an "earlier" update.
9083
# To avoid this, use lv.timer_create() with .set_repeat_count(1) as examplified in osupdate.py
84+
# Or avoid using threads altogether, by using TaskManager (asyncio).
9185
def update_ui_threadsafe_if_foreground(self, func, *args, important=False, event=None, **kwargs):
92-
self.throttle_async_call_counter += 1
93-
if not important and self.throttle_async_call_counter > 100: # 250 seems to be okay, so 100 is on the safe side
94-
print(f"update_ui_threadsafe_if_foreground called more than 100 times for one UI frame, which can overflow - throttling!")
95-
return None
9686
# lv.async_call() is needed to update the UI from another thread than the main one (as LVGL is not thread safe)
9787
result = lv.async_call(lambda _: self.if_foreground(func, *args, event=event, **kwargs), None)
9888
return result

0 commit comments

Comments
 (0)