Skip to content

Instantly share code, notes, and snippets.

View gamblor21's full-sized avatar

Mark gamblor21

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)
Steps:
1. Start JlinkRemoteServer on windows
1a. If any issues check firewall rules that WSL can access it
2. In WSL run: JLinkGDBServerCLExe -device ATSAMD51G19A -if SWD -ip 172.30.240.1
2a. IP may change that is windows machine IP (find with ip route command in WSL)
3. arm-none-eabi-gdb build/firmware.elf
3a. target extended-remote :2331
Ensure JTab RST is hooked to Reset (or enable on ItsyBitsy M4 worked)
@gamblor21
gamblor21 / neopixel_text_scroll.py
Last active November 11, 2022 16:39
Quick demo scrolling text across a grid (20x15) of neopixels
import board
import neopixel
from adafruit_pixel_framebuf import PixelFramebuffer, VERTICAL
import time
from random import randint, uniform
import random
pixel_pin = board.D5
pixel_width = 8
pixel_height = 4
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS)
#include <Adafruit_GC9A01A.h>
//#define TWO_DISPLAYS
#if defined(GLOBAL_VAR)
SPIClass SPI1(&sercom3, 6, 13, 12, SPI_PAD_0_SCK_1, SERCOM_RX_PAD_2);
#else
extern SPIClass SPI1;
#endif
@gamblor21
gamblor21 / Explaination.txt
Created June 17, 2022 03:34
CircuitPython GPS Async testing
There are two main files here to give GPS asyncio ability.
UART_asyncio - wrap the core busio.UART read and readline methods with methods that will not block.
I am not sure how many core classes this type of wrapping would work for. But for UART seemed fine.
Things could be expanded more (write only writes X bytes before letting something else go). CPython's
serial_asyncio is somewhat close to what I'm doing, though CPython has Transport and Protocols with asyncoio
that CP does not have.
gps_asyncio - Right now a subclass of the adafruit_gps.GPS class but as someone suggested may be better as a
fork project as a lot of code had to be copied so not really OO. In theory could refactor the GPS class too
so the non-async methods all have their own functions and you can override just the async ones. But not even sure
@gamblor21
gamblor21 / Makefile
Created February 18, 2022 14:44
CircuitPython Natmod test
# Location of top-level MicroPython directory
MPY_DIR = ..
# Name of module
MOD = ahrs
# Source files (.c or .py)
SRC = madgwick.c ../lib/libm/ef_sqrt.c ../lib/libm/atan2f.c ../lib/libm/asinfacosf.c ../lib/libm/atanf.c
#SRC = factorial.c