Skip to content

Instantly share code, notes, and snippets.

View todbot's full-sized avatar
💭
doing the blink1

Tod Kurt todbot

💭
doing the blink1
View GitHub Profile
@gamblor21
gamblor21 / drums.py
Created May 31, 2023 23:53
Drums for Circuitpython synthio
import ulab.numpy as np
import random
import synthio
SAMPLE_SIZE = 200
sinwave1 = np.array(np.sin(np.linspace(0, 2*np.pi, SAMPLE_SIZE, endpoint=False)) * 32767, dtype=np.int16)
sinwave2 = np.array(np.sin(np.linspace(np.pi/2, 2.5*np.pi, SAMPLE_SIZE, endpoint=False)) * 32767, dtype=np.int16)
downwave = np.linspace(32767, -32767, num=3, dtype=np.int16)
noisewave = np.array([random.randint(-32767, 32767) for i in range(SAMPLE_SIZE)], dtype=np.int16)
@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
@joshka
joshka / Readme.md
Last active October 14, 2022 19:32
8/Any pin PIO based UART TX code for a Raspberry Pi Pico

Raspberry Pi Pico PIO 8 Pin UART TX

This code creates a UART TX on 8 sequential pins of the Raspberry Pi Pico. The main use case being MIDI splitter devices

The second 16 port implementation should work for any number of pins, but just acts as a pure copy to those pins instead of having individual control over every pin of every byte. Hence while less flexible, the controlling software is simpler (just send a uart byte and it's copied to every pin).

Only tested in the simulator so far. https://wokwi.com/projects/344345628967436882

Used https://wokwi.com/tools/pioasm to go from uart_tx.pio.h to uart_tx.h

@anecdata
anecdata / code.py
Last active March 30, 2023 18:39
Rough Monitor Dumper
import gc
import time
import board
import digitalio
import supervisor
import random
import wifi
import espidf
import ipaddress
import time
import board
import rotaryio
import touchio
import digitalio
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode
from adafruit_hid.consumer_control import ConsumerControl
@dglaude
dglaude / qtpy-knob-midi.py
Created February 28, 2021 00:00
Gt-Py Knob midi control
# qtpy-knob-midi.py -- Mount a rotary encoder directly to an Adafruit QT Py,
# use it for midi CC message
#
# 2020 @todbot / Tod Kurt
# 2021 @David.Glaude / David Glaude
import time
import board
from digitalio import DigitalInOut, Direction, Pull
import rotaryio
@Neradoc
Neradoc / picopico_safe_mode_boot.py
Last active July 12, 2023 07:49
boot.py implementing waiting to start into safe mode on Raspberry pico
import board
import time
from digitalio import DigitalInOut,Pull
led = DigitalInOut(board.LED)
led.switch_to_output()
safe = DigitalInOut(board.GP14) # <----- choose your pin with a button on it
safe.switch_to_input(Pull.UP)
@todbot
todbot / wifi-preferred-network.py
Last active December 5, 2020 06:18
Given a list of preferred networks, connect to the one with the strongest signal, for CircuitPython ESP32S2
#
# wifi-preferred-network.py -- Given a list of preferred networks,
# connect to the one with the strongest signal
# for CircuitPython ESP32S2 Metro / MagTag
# 2020 @todbot / todbot.com/blog
import time
import wifi
from secrets import secrets
@citruz
citruz / QEMU_ON_M1.md
Last active May 4, 2024 07:50
Create Ubuntu and Windows VMs with QEMU on Apple Silicon

Running Linux and Windows on M1 with QEMU

30.11.2020: Updated with the new patchseries and instructions for Windows

02.12.2020: Added tweaks

08.12.2020: Updated with patchseries v4

31.01.2020: Updated with patchseries v6

@todbot
todbot / FastLEDTinyFireSim.ino
Last active April 13, 2021 18:16
Tiny fire simulation for QT Py or any FastLED-supporting board
// modeled after https://github.com/todbot/qtpy-tricks#fire-simulation-on-external-neopixel-strip
// must use latest FastLED checkout from https://github.com/FastLED/FastLED
// as FastLED 3.3.3 doesn't have QT Py support
#include "FastLED.h"
#define LED_PIN 0
#define NUM_LEDS 8
CRGB leds[NUM_LEDS];
void setup() {