From fa97a1bbef7726cf108b8b974c34b222abbc5187 Mon Sep 17 00:00:00 2001
From: Sebastian Krzyszkowiak <dos@dosowisko.net>
Date: Sat, 21 Oct 2023 04:20:52 +0200
Subject: [PATCH] lower latency

---
 python_payload/st3m/reactor.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/python_payload/st3m/reactor.py b/python_payload/st3m/reactor.py
index 3b4190fe3e..46bb5a744f 100644
--- a/python_payload/st3m/reactor.py
+++ b/python_payload/st3m/reactor.py
@@ -147,20 +147,19 @@ class Reactor:
         self._top.think(hr, delta)
 
         # Draw!
-        if self._ctx is None and sys_display.pipe_available():
-            self._ctx = sys_display.ctx(0)
-            if self._ctx is not None:
+        if sys_display.pipe_available() and not sys_display.pipe_full():
+            ctx = sys_display.ctx(0)
+            if ctx is not None:
                 if self._last_ctx_get is not None:
                     diff = start - self._last_ctx_get
                     self.stats.record_render_time(diff)
                 self._last_ctx_get = start
 
-                self._ctx.save()
-                self._top.draw(self._ctx)
-                self._ctx.restore()
-        if self._ctx is not None and not sys_display.pipe_full():
-            sys_display.update(self._ctx)
-            self._ctx = None
+                ctx.save()
+                self._top.draw(ctx)
+                ctx.restore()
+
+                sys_display.update(ctx)
 
         # Share!
         if ftop.run(delta):
-- 
GitLab