Skip to content

Instantly share code, notes, and snippets.

@anecdata
anecdata / code.py
Created November 14, 2023 16:22
CircuitPython asyncio w/ Requests iter_content()
import random
import board
import wifi
import socketpool
import ssl
import neopixel
import asyncio
import adafruit_requests
# Choose your own URL adventure...
@anecdata
anecdata / code.py
Created November 5, 2023 01:31
CAN Bus Sender & Receiver test code
import struct
import time
import board
import busio
import digitalio
try:
import canio
NATIVE = True
except ImportError:
NATIVE = False
@anecdata
anecdata / reset.py
Last active October 30, 2023 20:22
CircuitPython reset to RunMode from REPL (interactive)
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT
import microcontroller
import sys
mode = {"0": microcontroller.RunMode.NORMAL,
"1": microcontroller.RunMode.SAFE_MODE,
"2": microcontroller.RunMode.UF2,
@anecdata
anecdata / repl.py
Last active November 14, 2023 04:14
repl.py
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: Unlicense
import time
import supervisor
import microcontroller
import os
import sys
@anecdata
anecdata / espnow_receiver.py
Last active February 11, 2024 22:56
CircuitPython example for Espressif ESP-NOW protocol
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT
import time
import traceback
import supervisor
import os
import rtc
import espnow
@anecdata
anecdata / safemode.py
Last active April 16, 2024 19:44
CircuitPython 8 safemode.py
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT
import json
import microcontroller
import supervisor
from ⚙️ import *
@anecdata
anecdata / reliability.md
Last active November 14, 2023 04:00
Developing for Reliability in CircuitPython
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT

try / except all the things (even the main loop)

with all the things (where available and appropriate)

manage volatile memory:

@anecdata
anecdata / color_terminal.py
Last active October 2, 2023 02:58
terminalio.Terminal with color
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: Unlicense
# terminalio.FONT.bitmap is 2-color
# changing a palette color changes every use of that palette
# but there's got to be a better way...
import time
import random
@anecdata
anecdata / 13x9_scrolling_text.py
Last active October 2, 2023 02:56
13x9 is31fl3741 scrolling bitmap text
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: Unlicense
import time
import board
import busio
from displayio import Bitmap
import adafruit_is31fl3741
from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
@anecdata
anecdata / ouroboros.py
Last active October 2, 2023 02:53
PicoW + WIZnet UDP Ouroboros
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT
import time, gc, random, board, busio, digitalio
from secrets import secrets
# for PicoW server:
import wifi, socketpool, ipaddress
# for WIZnet client:
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K