Skip to content

Instantly share code, notes, and snippets.

/* (Not so) simple synth based on Mozzi library and a bunch of pots.
*
* This code is derived from the public domain example of an 8 potentiometer
* synth from e-licktronic (https://www.youtube.com/watch?v=wH-xWqpa9P8).
*
* Severely edited for clarity and configurability, adjusted to run with modern
* versions of Mozzi, extended for polyphony by Thomas Friedrichsmeier. Also,
* this sketch will auto-generate fake MIDI events and random parameters, so
* you can start listening without connecting anything other than your
* headphones or amplifier. (Remove the FAKE_POTS and FAKE_MIDI defines, once
@tfry-git
tfry-git / Rotary_encoder_software_debounced.h
Last active November 6, 2023 06:34
Reliable, portable, and efficient reading form a cheap rotary encoder, without hardware debouncing.
/* Reading from a rotary encoder, with software debouncing.
* Works even on cheap quadrature encoders without any hardware debouncing, _reliably_. */
#define ENCODER_PIN_A PA1 // Input pins. NOTE That these _must_ support intterupts, _and_ interrupts must not interfere with other pins
#define ENCODER_PIN_B PA2 // // (e.g. on STM32F103C8T6, PAx will interfere with PBx)
#define BOUNCE_TIMEOUT 2 // ms
#define USER_INPUT_HIGHER_RES 0 // You probably want this: Gives lower granularity at higher values
volatile uint16_t pin_a_change_time;
volatile uint16_t pin_b_change_time;
@tfry-git
tfry-git / Demo.html
Last active June 15, 2024 12:55
**Fast** javascript pixel accurate collision detection
<html>
<body>
<p>
The actual canvas, where drawing happens. Mouse over to move the green open circle object.
</p>
<canvas id="canvas" width=200 height=200></canvas>
<p id="result">
</p>
<p id="timing">