From ca67b47f0a5121fbe92a2cb7bb9880d559b1cdfe Mon Sep 17 00:00:00 2001 From: nex Date: Mon, 8 May 2023 00:56:28 +0100 Subject: [PATCH 1/2] more reliable fan fanning --- cogs/info.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/cogs/info.py b/cogs/info.py index c676024..07bcc89 100644 --- a/cogs/info.py +++ b/cogs/info.py @@ -11,13 +11,6 @@ import psutil from functools import partial from discord.ext import commands from pathlib import Path -try: - import fanshim - import apa102 - import RPi.GPIO as GPIO -except ImportError as e: - # print("Raspberry Pi libraries not found.", e, file=sys.stderr) - fanshim = GPIO = apa102 = None class InfoCog(commands.Cog): @@ -145,16 +138,9 @@ class InfoCog(commands.Cog): value="\n".join(f"{s.label}: {s.current:.2f} RPM" for s in fans), inline=True, ) - if fanshim: - # PiMoroni's fanshim by default uses pin 18 for control - GPIO.setmode(GPIO.BCM) - GPIO.setup(18, GPIO.IN) - fan_active = bool(GPIO.input(18)) - # LED = apa102.APA102(1, 15, 14, None) - # Get LED colour as a tuple of (r, g, b) - # LED_colour = LED.get_pixel_colour(0) - # Convert to hex - # LED_colour = "%02x%02x%02x" % LED_colour + if Path("/tmp/fanstate").exists(): + with open("/tmp/fanstate", "r") as f: + fan_active = f.read().strip() == "1" LED_colour = "unknown" fan_state = f"{self.EMOJIS['OFF']} Inactive" if fan_active: From fdb6101c3f8e9a293a99b5e9bee4b20c7e59543a Mon Sep 17 00:00:00 2001 From: nex Date: Mon, 8 May 2023 00:57:46 +0100 Subject: [PATCH 2/2] make what? more strict --- cogs/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/events.py b/cogs/events.py index 2e03651..0a03a97 100644 --- a/cogs/events.py +++ b/cogs/events.py @@ -431,7 +431,7 @@ class Events(commands.Cog): "check": (assets / "smeg").exists } }, - r"(what|huh)(\?|!)*": { + r"(what|huh)(\?|!)*$": { "func": send_what, "meta": { "check": lambda: message.reference is not None