From 7f2a1b33d064d558348b41da07ee7bf90132b6c2 Mon Sep 17 00:00:00 2001 From: Marat Fayzullin Date: Sat, 27 May 2023 13:11:00 -0400 Subject: [PATCH] Making sure the last used color is not immediately reused. --- owrx/multimon.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/owrx/multimon.py b/owrx/multimon.py index bb76fb67..1e82cdb3 100644 --- a/owrx/multimon.py +++ b/owrx/multimon.py @@ -195,15 +195,17 @@ class PageParser(MultimonParser): def getColor(self, capcode: str) -> str: if capcode in self.colorBuf: - return self.colorBuf[capcode] + # Sort entries in order of freshness + color = self.colorBuf.pop(capcode) + elif len(self.colorBuf) < len(self.colors): + # Assign each initial entry color based on its order + color = self.colors[len(self.colorBuf)] else: # If we run out of colors, reuse the oldest entry - if len(self.colorBuf) >= len(self.colors): - color = self.colorBuf.pop(next(iter(self.colorBuf))) - else: - color = self.colors[len(self.colorBuf)] - self.colorBuf[capcode] = color - return color + color = self.colorBuf.pop(next(iter(self.colorBuf))) + # Done + self.colorBuf[capcode] = color + return color def parsePocsag(self, msg: str): # No result yet