Skip to content

Instantly share code, notes, and snippets.

@anecdata
Last active February 3, 2022 17:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anecdata/fdb33f1b3c5c3e36cff84d32e8e6f620 to your computer and use it in GitHub Desktop.
Save anecdata/fdb33f1b3c5c3e36cff84d32e8e6f620 to your computer and use it in GitHub Desktop.
RGB Matrix (is31fl3741) Wi-Fi Monitor
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
@anecdata
Copy link
Author

wifichan2.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment