Last active
October 24, 2024 02:34
-
-
Save anecdata/fdb33f1b3c5c3e36cff84d32e8e6f620 to your computer and use it in GitHub Desktop.
RGB Matrix (is31fl3741) Wi-Fi Monitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import time | |
import board | |
import busio | |
import wifi | |
import adafruit_is31fl3741 | |
from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT | |
QUEUELEN = 128 # ESP32-S2 (ESP32-S3 can be much longer) | |
try: # QT Py ESP32-S2 Stemma QT | |
i2c = busio.I2C(board.SCL1, board.SDA1, frequency=1000000) | |
except: | |
i2c = busio.I2C(board.SCL, board.SDA, frequency=1000000) | |
is31 = Adafruit_RGBMatrixQT(i2c, allocate=adafruit_is31fl3741.PREFER_BUFFER) | |
is31.set_led_scaling(0xFF) | |
is31.global_current = 0xFF | |
is31.enable = True | |
monitor = wifi.Monitor(channel=1, queue=QUEUELEN) | |
while True: | |
received = monitor.packet() | |
if received: | |
channel = received[wifi.Packet.CH] | |
x = channel - 1 | |
c = round((1 - abs(received[wifi.Packet.RSSI] / 100)) * 0x0000FF) | |
subt = (received[wifi.Packet.RAW][0] & 0b11110000) >> 4 | |
if subt == 8: # Beacons (blue) | |
pass # Blue | |
elif subt == 4: # Probe Requests (green) | |
c = c << 8 | |
else: # other management frame subtypes (red) | |
c = c << 16 | |
scaled_rssi = round(7 * (1 - abs(received[wifi.Packet.RSSI] / 100))) | |
for _ in range(9, 9 - (2 + scaled_rssi), -1): | |
is31.pixel(x, _, c) | |
if monitor.queued(): | |
is31.pixel(x, 1, 0x888844) | |
if monitor.lost(): | |
is31.pixel(x, 0, 0xFF0000) | |
is31.show() | |
for _ in range(0, 9): | |
is31.pixel(x, _, 0x000000) | |
is31.show() | |
monitor.channel = (monitor.channel + 1) % 14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wifichan2.mov