Skip to content

Instantly share code, notes, and snippets.

View rsbohn's full-sized avatar

Randall Bohn rsbohn

  • Rando Media
  • Orem Utah USA
View GitHub Profile
# SPDX-FileCopyrightText: Copyright (c) 2022 Randall Bohn (dexter)
#
# SPDX-License-Identifier: MIT
#
# View random products from Adafruit on the PyPortal
from random import randrange
from adafruit_pyportal import PyPortal
base_url = "https://adafruit.com/api/product/"
portal = PyPortal(
@rsbohn
rsbohn / visible_pin.py
Created January 17, 2022 20:01
Visible state of digital input pins.
# SPDX-FileCopyrightText: Copyright (c) 2022 Randall Bohn (dexter)
#
# SPDX-License-Identifier: MIT
# A little fun in the Funhouse
import time
import board
import digitalio
import displayio
import vectorio
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
Connect UART and SPI0 between to Pi devices.
[3v3] :: [5v]
GPIO2 [CTS] :: [5v]
GPIO3 [RTS] :: [Gnd]
GPIO4 [TXD?] :: GPIO14 [TXD*]
[Gnd] :: GPIO15 [RXD*]
GPIO17 [RTS] :: GPIO18
GPIO27 :: [Gnd]
@rsbohn
rsbohn / roller.py
Last active January 15, 2022 17:36
# SPDX-FileCopyrightText: Copyright (c) 2022 Randall Bohn (dexter)
#
# SPDX-License-Identifier: MIT
#
# Dice Roller
# Runs on Feather Bluefruit Sense nRF52840
# faces: a 336x48 sprite sheet
import board
import time
import displayio
Wired to the SPI headers (plus D5)
fram metro_m4 color
Vin 5v red
...
Gnd Gnd black
SCK SCK white
MISO MISO brown
MOSI MOSI orange
CS D5 blue (socket-pin)
...
@rsbohn
rsbohn / dtmf.py
Created January 15, 2022 15:33
phone tones
# SPDX-FileCopyrightText: Copyright (c) 2021 Randall Bohn (dexter)
#
# SPDX-License-Identifier: MIT
#
# https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling
import array
import math
from audiocore import RawSample
tone_row = [697, 770, 852, 942]
@rsbohn
rsbohn / CircuitPython2022.txt
Created January 5, 2022 00:58
Looking forward
#CircuitPython2022
For the Broadcom ports I would really like to have an onboard editor.
Something simple that would allow for stand-alone coding beyond what you can do on the REPL.
I would also like to explore the possibilities and limitations of MIDI on CircuitPython.
Dexter Starboard 2022-01-04
@rsbohn
rsbohn / crystal.py
Created December 26, 2021 22:04
Put a simulated text LCD on your displayio screen.
# SPDX-FileCopyrightText: Copyright (c) 2021 Randall Bohn (dexter)
#
# SPDX-License-Identifier: MIT
"""LCD Widget"""
import time
import displayio
import terminalio
CHARS = 1
ROWS = 1
@rsbohn
rsbohn / singularity.py
Created December 18, 2021 22:06
singularity animation for bubbles.py
# just add this to bubbles.py
# then call it instead of herd()
def singularity(group):
cx = display.width//2
cy = display.height//2
for shape in group:
dx = max(1, int(math.sqrt(abs(cx-shape.x))))
if shape.x > cx: shape.x -= dx
else: shape.x += dx
@rsbohn
rsbohn / snowflakes.py
Created December 6, 2021 22:14
another displayio demo
# SPDX-FileCopyrightText: Copyright (c) 2021 Randall Bohn (dexter)
#
# SPDX-License-Identifier: MIT
"""snowflakes"""
# like bubbles but they fall from they sky
# circup install adafruit_display_shapes
# circup install adafruit_fancyled
import random
import time
import displayio