Skip to content

Instantly share code, notes, and snippets.

@anecdata
anecdata / code.py
Last active July 18, 2020 19:42
CircuitPython vectorio circles
import board
import displayio
from vectorio import Rectangle, Circle, Polygon, VectorShape
import time
import random
import gc
# Make the display context
SPLASHMAX = 2000
splash = displayio.Group(max_size=SPLASHMAX)
@anecdata
anecdata / code.py
Created August 10, 2020 06:09
SD Card read >- 1024 characters
# variation on https://github.com/gmeader/pyportal/blob/master/bug_demo.py
import adafruit_sdcard
import busio
import digitalio
import board
import storage
import os
# Connect to the card and mount the filesystem.
@anecdata
anecdata / code.py
Last active September 1, 2020 22:11
SHTC3 I2C Test
import time
import board
import adafruit_lps35hw
import adafruit_dps310
import adafruit_shtc3
"""
run, then ^C^D or re-save file to CIRCUITPY,
and line 42 (`sht =`) will fail:
@anecdata
anecdata / code.py
Last active November 2, 2020 23:40
ESP32-S2 Pins
# ESP32S2 pins:
# strapping pins*
#
# 0* wpu
# 2 amber LED on Cucumber
# 8 antitipated I2C SDA on production UMFeatherS2
# 9 antitipated I2C SCL on production UMFeatherS2
# 13 blue LED on UMFeatherS2
# 14 LED on Bast
# 15 I2C SDA on Bast
@anecdata
anecdata / code.py
Created December 16, 2020 18:27
ESP32-S2 Wi-Fi set-up
if 'ESP32S2' in os.uname().machine:
print("MAC", ":".join('%x' % x for x in wifi.radio.mac_address))
# don't proceed w/o any Wi-Fi APs
print("Scanning WiFi...")
while True:
try:
for network in wifi.radio.start_scanning_networks():
print("{0:02X}:{1:02X}:{2:02X}:{3:02X}:{4:02X}:{5:02X}".format(*network.bssid),
network.channel,
@anecdata
anecdata / ESP32SPI power
Last active January 10, 2021 16:25
ItsyBitsy M4 + ESP32 power configurations
(1) USB power to ItsyBitsy M4 + ESP32 Breakout
typical output:
Retrying ESP32 connection
Error response to command
...
Retrying ESP32 connection
Timed out waiting for SPI char
...
@anecdata
anecdata / code.py
Last active March 20, 2021 21:48
NTP ESP32-S2
import wifi
import socketpool
import struct
import time
import sys
from secrets import secrets
NTP_TO_UNIX_EPOCH = 2208988800 # 1970-01-01 00:00:00
packet = bytearray(48)
@anecdata
anecdata / code.py
Last active March 20, 2021 21:48
TCP Client ESP32SPI
# server code:
# https://github.com/adafruit/circuitpython/blob/main/tests/circuitpython-manual/socketpool/client/host-server.py
import board
from digitalio import DigitalInOut
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
import adafruit_requests as requests
from secrets import secrets
@anecdata
anecdata / esp32spi.txt
Last active March 20, 2021 21:53
TEMPORARY Some raw ESP32SPI test data
re: https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/issues/11#issuecomment-483268050
@anecdata
anecdata / scrollMatrixString.ino
Last active March 20, 2021 21:54
Arduino function to scroll a String on an Adafruit 8x16 LED Matrix FeatherWing
// 8x16 LED Matrix I2C FeatherWing
#define MATRIX_ADDR 0x70 // default; 0x71-0x77 with jumper changes
Adafruit_8x16minimatrix matrixDisplay = Adafruit_8x16minimatrix();
setup() {
matrixDisplay.begin(MATRIX_ADDR); // void
}
void scrollMatrixString(String tString, int scrollDelay, int bright, int rot, int tSize, boolean tWrap, int tColor) {
int tLength = tString.length();