diff --git a/__init__.py b/__init__.py index 0506fcc..4f93ddd 100644 --- a/__init__.py +++ b/__init__.py @@ -17,7 +17,7 @@ class Configuration: self.strs: list = ['flow3r', '', 'noLang', '', ''] self.size: int = 75 self.font: int = 5 - self.colour: int = 0 # (0.5, 0.5, 0.5) # index or tuple + self.colour: int = (1.0, 1.0, 1.0) self.delay: int = 8 @classmethod @@ -43,22 +43,20 @@ class Configuration: res.size = data["size"] if "font" in data and type(data["font"]) == int: res.font = data["font"] - if "color" in data: - if type(data["color"]) == int: - res.colour = data["color"] - if type(data["color"]) == str and len(data["color"]) == 7 and data["color"][0] == '#': - res.colour = ( - int(data["color"][1:3], 16)/256.0, - int(data["color"][3:5], 16)/256.0, - int(data["color"][5:], 16)/256.0 - ) + if "color" in data and type(data["color"]) == str and len(data["color"]) == 7 and data["color"][0] == '#': + res.colour = ( + int(data["color"][1:3], 16)/256.0, + int(data["color"][3:5], 16)/256.0, + int(data["color"][5:], 16)/256.0 + ) return res def save(self, path: str) -> None: + colourstr: str = '#' + hex(int(255*self.colour[0]))[2:4] + hex(int(255*self.colour[1]))[2:4] + hex(int(255*self.colour[2]))[2:4] d = { "size": self.size, "font": self.font, - "color": self.colour if type(self.colour) == int else 0, + "color": colourstr, "delay": self.delay, } for i in range(len(self.hdrs)): @@ -85,12 +83,8 @@ class SensibleNickApp(Application): self._en_iter_pressed = False self._filename = "/flash/nick.json" self._config = Configuration.load(self._filename) - self._colours: list = [GO_GREEN, PUSH_RED, WHITE] - if type(self._config.colour) == int: - self._en_colour = self._config.colour - else: - self._colours[2] = self._config.colour - self._en_colour = 2 + self._colours: list = [GO_GREEN, PUSH_RED, self._config.colour] + self._en_colour = 2 self.varprint: list(str) = [str for str in self._config.strs if len(str) > 0] def draw(self, ctx: Context) -> None: diff --git a/flow3r.toml b/flow3r.toml index 1e05f67..c0f1fdd 100644 --- a/flow3r.toml +++ b/flow3r.toml @@ -10,4 +10,4 @@ author = "Anna_updn, Flow3r Badge Authors" license = "LGPL-3.0-only" url = "https://git.flow3r.garden/updn/sensiblenickapp" description = "A sensible nickname app using touch to show up to 5 strings with some quality of life features." -version = 1 +version = 2