From e39656686e69594ff336d158f60fc8ad63a03de5 Mon Sep 17 00:00:00 2001 From: Erik Stambaugh Date: Thu, 28 Mar 2024 19:57:25 -0700 Subject: [PATCH] Add stubbed HASS mode --- inkybot.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/inkybot.py b/inkybot.py index 4a1a907..13db14a 100755 --- a/inkybot.py +++ b/inkybot.py @@ -59,7 +59,7 @@ class Inkybot: # Extract the outer 1-pixel perimeter outer_perimeter_pixels = [] for x in range(width): - outer_perimeter_pixels.append(image.getpixel((x, 0))) # Top row + outer_perimeter_pixels.append(image.getpixel((x, 0))) # Top row outer_perimeter_pixels.append(image.getpixel((x, height - 1))) # Bottom row for y in range(1, height - 1): outer_perimeter_pixels.append(image.getpixel((0, y))) # Left column @@ -161,6 +161,10 @@ class Inkybot: def button_d(self): print("Button D") + # same applies to the loop + def loop(self): + pass + def set_image(self, image): draw = ImageDraw.Draw(image) @@ -193,6 +197,7 @@ class Inkybot: return decorator def change_state(self, state): + print(f"Changing state to: {state}") if self.state: self.state.exit() self.state = self.states[state] @@ -227,6 +232,9 @@ class PictureMode(inkybot.StateClass): self.imagelist = [] self.next_img = True self.time_target = 0.0 + + def button_b(self): + self.change_state('hass') def button_d(self): print("changing image...") @@ -260,6 +268,24 @@ class PictureMode(inkybot.StateClass): self.set_image(resizedimage) +@inkybot.State('hass') +class HassMode(inkybot.StateClass): + button_text = [ + " ", + "", + " ", + " " + ] + + def button_b(self): + self.change_state('picture') + + def enter(self): + image = Image.new("RGB", self.parent.inky.resolution, (255,0,0)) + self.set_image(image) + + + if __name__ == "__main__": inkybot.start('picture')