Skip to content

Instantly share code, notes, and snippets.

@honnet
honnet / imu.py
Created August 29, 2023 16:49
Simple python script to get data from the magnetometer + accelerometer and display it in the terminal.
#!/usr/bin/python
import sys
import glob
import serial
import math
DEBUG_PRINT = 0
data_backup = [-1, 1,1,1, 1,1,1]
@honnet
honnet / generative_stm32_pcb.js
Last active February 14, 2023 20:23
An array of 1.4mm MCUs (STM32C011D6)
// visualization tool:
// https://leomcelroy.com/svg-pcb/?file=https://gist.githubusercontent.com/honnet/735785331add65ea58daa274873922e5/raw/generative_stm32_pcb.js
const STM32 = {"A2":{"pos":[-0.005964566929133858,0.0172244094488189],"shape":"M 0.004 0 L 0.003997563308076383 0.00013959798681000387 L 0.0039902562010392965 0.00027902589497650124 L 0.003978087581473094 0.0004181138530706139 L 0.003961072274966282 0.0005566924038402618 L 0.003939231012048832 0.0006945927106677213 L 0.003912590402935223 0.0008316467632710374 L 0.003881182905103986 0.0009676875823986709 L 0.003845046783753276 0.0011025494232679966 L 0.0038042260651806143 0.0012360679774997896 L 0.003758770483143634 0.001368080573302675 L 0.00370873541826715 0.0014984263736636482 L 0.0036541818305704035 0.001626946572303201 L 0.003595176185196668 0.0017534845871563097 L 0.003531790371435708 0.0018778862511435632 L 0.0034641016151377548 0.0019999999999999996 L 0.0033921923846257037 0.0021196770569328195 L 0.0033161502902201664 0.002236771613882987
@honnet
honnet / generative_serpentine_pcb_test.js
Last active March 15, 2022 19:00
Testing curvy PCB shapes
// visualization tool: https://leomcelroy.com/svg-pcb/
// source: https://gist.github.com/honnet/b411a1dbd15822b05d94e6c59652bcac
/* -- DECLARE_COMPONENTS -- */
const test_footprint = {
"VCC": {
"shape": "M -0.05 0.025L 0.05 0.025L 0.05 -0.025L -0.05 -0.025L -0.05 0.025",
"pos":[-0.1,0.05],
"layers":["F.Cu"]
},
@honnet
honnet / LED_strip_SK6805-EC15.js
Last active February 17, 2022 23:59
LED strip: SK6805-EC15
// https://leomcelroy.com/svg-pcb/?file=https://gist.githubusercontent.com/honnet/99db74cb50a125d0d0a9bc922703f8cf/raw/LED_strip_SK6805-EC15.js
//////////////////////////
const LED_num = 15;
const size_y = 0.1;
const is_pad_export = 0;
//////////////////////////
@honnet
honnet / attiny20_test.js
Last active October 21, 2021 01:00
Testing generative PCB with internal replication
// https://leomcelroy.com/svg-pcb/?file=https://gist.githubusercontent.com/honnet/55a3bd744e1ca6b1f4440f56299bd329/raw/395cfd3da69157746fa1be8f417188c5a02d24d7/attiny20_test.js
// temporary bug fix (pad diameter VS radius confusion):
const ATtiny20 = (() => { return kicadToObj(
`(module WLCSP-12_1.403x1.555mm_P0.4mm_Stagger (layer F.Cu) (tedit 5C18324B)
(descr "WLCSP-12, 6x4 raster staggered array, 1.403x1.555mm package, pitch 0.4mm; http://ww1.microchip.com/downloads/en/devicedoc/atmel-8235-8-bit-avr-microcontroller-attiny20_datasheet.pdf#page=208")
(tags "CSP 12 0.2x0.346333")
(attr smd)
(solder_mask_margin 0.0325)
(solder_paste_margin 0.000001)
@honnet
honnet / Nikon_D5300_ESP8266.ino
Created April 17, 2019 15:57
Code to trigger photos with arduino (ESP8266) and infrared to control a Nikon D5300.
// inspiration: https://www.christidis.info/index.php/personal-projects/arduino-nikon-infrared-command-code
const int LEDpin = D3;
const int delay_us = 13; // 38 KHz
int i;
void setup() {
pinMode(LEDpin, OUTPUT);
}
@honnet
honnet / capacitiveTouchToggle.ino
Created June 19, 2018 02:21
Capacitive Touch Toggle
#include <ADCTouch.h>
// ADCTouch can be installed in the library manager
// Procedure explained in https://www.arduino.cc/en/Guide/Libraries#toc3
int ref0; // reference values to remove offset
bool toggle = 0;
bool old_touch_state = 0;
void setup() {
Serial.begin(115200*2);
@honnet
honnet / controlled_blink.ino
Created November 9, 2017 15:35
blink X times for Y ms with X and Y sent over serial