Skip to content

Instantly share code, notes, and snippets.

@dglaude
dglaude / simple_test.py
Created Jul 24, 2021
keypad simple test by @FoamyGuy found on adafruit Discord 23/07/2021
View simple_test.py
from keypad import Keys
import board
import time
pins = [board.BUTTON_A, board.BUTTON_B]
keys = Keys(pins, value_when_pressed=False, pull=True)
while True:
if keys.events.overflowed:
keys.events.clear()
@dglaude
dglaude / emojiclock
Created Jun 14, 2021
Tentative dynamic emoji in Discord (edit previous post and change by a different emoji every second)
View emojiclock
# CircuitPython Discord rotating clock emoji (spam).
# Type an emoji in Discord... do nothing else, with your ItsiBitsy nrF.
# Press the button to replace that emoji by another one every second.
import time
import board
import usb_hid
from digitalio import DigitalInOut, Direction
from adafruit_hid.keyboard import Keyboard
@dglaude
dglaude / Dual_mouse_bug.py
Created Jun 14, 2021
Code.py found on "Adafruit CircuitPython 6.2.0 on 2021-04-05; Adafruit ItsyBitsy nRF52840 Express with nRF52840" date 2020/04/14
View Dual_mouse_bug.py
###
# Dual BLE mouse jiggling:
# Advertise a first mouse as "CircuitPython HID1"
# Once we have a first connection
# Advertise a second mouse as "CircuitPython HID2"
#
# Once the first mouse is connected the jiggling start.
# Mouse1 should do Left-Right movement
# Mouse2 (once connected) should do Up-Down movement
#
@dglaude
dglaude / code.py
Created May 16, 2021
Hidden Mouse Jiggler
View code.py
import time
import board
import digitalio
import storage
import usb_hid
from adafruit_hid.mouse import Mouse
import usb_cdc
#usb_hid.enable(devices=(usb_hid.MOUSE,)) ###AttributeError: 'module' object has no attribute 'MOUSE'
@dglaude
dglaude / code.py
Created May 10, 2021
Thermal camera mono-source multiple platform
View code.py
### Thermal camera mono-source multiple platform:
###
### On a FeatherWing Keyboard:
### 'FeatherS2 with ESP32S2'
### 'Adafruit Feather RP2040 with rp2040'
###
### With build in screen:
### 'Adafruit CLUE nRF52840 Express with nRF52840'
### 'Adafruit Matrix Portal M4 with samd51j19' + 32x64 Matrix
### If a 64x64 matrix (or two time 32x64) then the following
@dglaude
dglaude / code.py
Last active May 10, 2021
MLX90640 + FeatherWing Keyboard bilinear upscalling and displayio pixel stretching with Feather RP2040 and Feather S2
View code.py
### MLX90640 + FeatherWing Keyboard bilinear upscalling and displayio pixel stretching
### Feather RP2040: Reach 4x bilinear x2 pixel doubling
### Feather S2: Reach x5 bilinear x2 pixel doubling
### Detect what Feather is in use and adapt
# Input is 32x24
# Make use of ulab for fast math operation on matrix
# Split ulab operations to minimise memory consumption by temporary variable
#from bbq10keyboard import BBQ10Keyboard, STATE_PRESS, STATE_RELEASE, STATE_LONG_PRESS
@dglaude
dglaude / scale_x5_x2.py
Last active May 10, 2021
WIP: Thermal Camera++ FeatherS2 + FeatherWing Keyboard + MLX90640 + ulab x5 bilinear scaling + x2 displayio scaling
View scale_x5_x2.py
from bbq10keyboard import BBQ10Keyboard, STATE_PRESS, STATE_RELEASE, STATE_LONG_PRESS
from adafruit_stmpe610 import Adafruit_STMPE610_SPI
import adafruit_ili9341
import adafruit_sdcard
import digitalio
import displayio
import neopixel
import storage
import board
import time
@dglaude
dglaude / scale_x4_x2.py
Created May 2, 2021
WIP: Thermal Camera++ FeatherS2 + FeatherWing Keyboard + MLX90640 + ulab x4 bilinear scaling + x2 displayio scaling
View scale_x4_x2.py
from bbq10keyboard import BBQ10Keyboard, STATE_PRESS, STATE_RELEASE, STATE_LONG_PRESS
from adafruit_stmpe610 import Adafruit_STMPE610_SPI
import adafruit_ili9341
import adafruit_sdcard
import digitalio
import displayio
import neopixel
import storage
import board
import time
@dglaude
dglaude / alternative_64_colours.py
Last active May 10, 2021
mlx90640 thermal camera on CLUE with x2 bilinear scaler using ulab + x3 with displayio scale
View alternative_64_colours.py
### mlx90640_scalex2_clue.py + 64
### same as mlx90640_scalex2_clue.py but with 64 colours rather than 32 => need one optimisation on memory size.
import time
import board
import busio
import adafruit_mlx90640
import displayio
import terminalio
@dglaude
dglaude / code_2x.py
Last active Apr 28, 2021
ulab 2x, 3x image upscaling in CircuitPython
View code_2x.py
# Double size upscaling of an array by @v923z
import ulab
n = 4 # input size, the thermal sensor is 8x8
b = ulab.array(range(n * n)).reshape((n, n)) # dummy data for testing
a = ulab.zeros((2*n-1, 2*n-1)) # the upscaled image
# Some magic by @v923z
a[::2,::2] = b
a[1::2,::2] = 0.5 * (b[:-1,:] + b[1:, :])