From 997cf54482256e37f11b9acfd5b79a5369493bd3 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Mon, 6 Feb 2023 17:27:54 +0100 Subject: [PATCH] flicker reduction in ntp demo --- ntp_simple_demo/ntp_demo_native.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ntp_simple_demo/ntp_demo_native.py b/ntp_simple_demo/ntp_demo_native.py index b44fbc7..f9a6ff1 100644 --- a/ntp_simple_demo/ntp_demo_native.py +++ b/ntp_simple_demo/ntp_demo_native.py @@ -64,6 +64,7 @@ def get_ntp_time(pool): # insert external display init if display: + display.auto_refresh = False group = displayio.Group() display.show(group) text_area = label.Label( @@ -78,14 +79,19 @@ def get_ntp_time(pool): text="Hello", ) group.append(text_area) + display.refresh() +previous_clock = "" while True: now = time.localtime() clock = "{hour:02d}:{min:02d}:{seconds:02d}".format( hour=now.tm_hour, min=now.tm_min, seconds=now.tm_sec ) - print(clock) - if display: - text_area.text = clock + if clock != previous_clock: + print(clock) + if display: + text_area.text = clock + display.refresh() + previous_clock = clock time.sleep(0.2)