Skip to content

Commit fc9a4bc

Browse files
cputest: simplify
1 parent 5c059b5 commit fc9a4bc

File tree

1 file changed

+2
-10
lines changed
  • internal_filesystem/apps/com.example.cputest/assets

1 file changed

+2
-10
lines changed

internal_filesystem/apps/com.example.cputest/assets/cputest.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import _thread
1717

1818
keeprunning = True
19+
summary = "Running 3 CPU tests...\n\n"
1920

2021
# Configuration
2122
TEST_DURATION = 5000 # Duration of each test (ms)
@@ -53,7 +54,6 @@ def stress_test_thread():
5354
#
5455
time.sleep_ms(TEST_SPACING)
5556
print("\nStarting SHA-256 stress test (1KB data)...")
56-
global summary
5757
summary += "Busy loop with SHA-256 (1KB): "
5858
iterations = 0
5959
start_time = time.ticks_ms()
@@ -68,10 +68,6 @@ def stress_test_thread():
6868
summary += "\nAll tests completed."
6969

7070

71-
def update_status_cb(timer):
72-
status.set_text(summary)
73-
74-
7571
def janitor_cb(timer):
7672
global keeprunning
7773
if lv.screen_active() != appscreen:
@@ -82,15 +78,11 @@ def janitor_cb(timer):
8278

8379
appscreen = lv.screen_active()
8480
janitor = lv.timer_create(janitor_cb, 500, None)
85-
update_status_timer = lv.timer_create(update_status_cb, 200, None)
81+
update_status_timer = lv.timer_create(lambda timer: status.set_text(summary), 200, None)
8682

8783
status = lv.label(appscreen)
8884
status.align(lv.ALIGN.TOP_LEFT, 5, 10)
89-
status.set_style_text_color(lv.color_hex(0xFFFFFF), 0)
90-
91-
summary = "Running 3 CPU tests...\n\n"
9285
status.set_text(summary)
9386

9487
_thread.stack_size(12*1024)
9588
_thread.start_new_thread(stress_test_thread, ())
96-

0 commit comments

Comments
 (0)