From 7b31061b3b5778346a4788a437fee47fead90d9b Mon Sep 17 00:00:00 2001 From: Shy Date: Tue, 14 Mar 2017 17:15:16 +0100 Subject: [PATCH] Kitchenlight/text-mode: enforce maximum string length --- c4ctrl.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/c4ctrl.py b/c4ctrl.py index da313ff..ad9a253 100755 --- a/c4ctrl.py +++ b/c4ctrl.py @@ -488,6 +488,9 @@ class Kitchenlight: def text(self, text="Hello World", delay=250): """Set to mode "text".""" text = text.encode("ascii", "ignore") + if len(text) > 256: # Maximum text length + print("Warning: text length must not exceed 256 characters!") + text = text[:256] d = bytearray(8 + len(text) + 1) v = memoryview(d) # Screen 8