Skip to content

Instantly share code, notes, and snippets.

@cibomahto
cibomahto / saleae.py
Last active January 10, 2023 23:10
Press the 'start' button in the Saleae Logic 2 gui
# The Saleae Logic 2 GUI has a scripting API, but it's designed for full automation, and doesn't
# seem to have a method for telling the GUI to just start a capture. So forget it, let's just
# invoke the button ourselves...
#
# Tested with Windows 10 and Saleae Logic 2.4.3, you'll likely need to tweak this
def start_capture():
import pywinauto
app = pywinauto.application.Application(backend="uia").connect(title_re="Logic 2.*")
@cibomahto
cibomahto / puzzle.py
Last active January 8, 2023 19:40
Brute force solver for a cat themed 'scramble squares' puzzle
# Brute force solver for a cat themed 'scramble squares' puzzle. Attempts to find all
# possible solutions to the puzzle.
import math
def number_to_order(number, items):
# Create a unique ordering of the values in items, based on an integer number.
# This alows all possible combinations of the items to be calculated by looping
# through the numbers 0 - len(items)!
#
# Based on: https://github.com/uutzinger/C12880MA
import serial
import serial.tools.list_ports
import time
import matplotlib.pyplot as plt
import numpy as np
import scipy.signal as signal
def find_serial_device(vid=None,pid=None,product=None):

LIGHT FESTIVAL TICKET

Beste klant,

Je bestelling is succesvol afgerond. Activeer dit ticket op de dag dat je wil gaan wandelen (tussen 2 december 2021 en 23 januari 2022. De lichten staan aan van 7-9 uur en 15-22 uur).

Activeer de Routekaart

  1. Start bij 'Ghost Ship' (Oosterdokskade 135), of bij een ander kunstwerk.*
  2. Scan met de camera van je mobiel de QR-code bij het kunstwerk.
#include "soc/rtc.h"
#include "hal/gpio_hal.h"
#include "driver/i2s.h"
bool calc_apll_setting(const float f_target, int *sdm0, int *sdm1, int *sdm2, int *odiv)
{
const int f_xtal = rtc_clk_xtal_freq_get();
bool solved = false; // True if a valid solution could be found
float error_abs = 0; // Absolute error in frequency setting
@cibomahto
cibomahto / format.h
Last active September 21, 2021 15:04
Pattern file format
//! @brief Pattern file recorder/playback
//!
//! The purpose is to allow capure and playback of streamed pattern data. The
//! recorder is intended to capture raw data and sync packets directly from the
//! listener (ie, before mapping or color/brightness manipulation is applied).
//! During playback, the raw packets are sent to the mapper for processing.
//! This allows the mapping and output settings to be adjusted after recording.
//!
//! Packets are recorded with a time resolution of 1 ms.
//!
@cibomahto
cibomahto / top.v
Last active September 14, 2021 22:26
Live clock trimming on iCE40 UP5K
module top (
output P1_2
);
wire clk;
assign P1_2 = clk;
reg [9:0] trim;
// Configure the HFOSC
SB_HFOSC #(
@cibomahto
cibomahto / raspberry-router.dts
Created August 19, 2021 20:22
DTS file attemtping to init LAN7431 with ksz9477
/*
* Device tree file for Raspberry Router, adds support for the KSZ9897 switch
* using DSA
*
* Copyright (C) 2021 Blinkinlabs
* Author: Matt Mets <matt@blinkinlabs.com>
*/
/dts-v1/;
/plugin/;
@cibomahto
cibomahto / example.c
Created August 19, 2021 12:14
cJSON SPIRAM allocator
//! @brief For cjson: Memory allocator to use SPIRAM
//!
//! @param[in] sz Size of the memory to allocate
//! @return Pointer to the allocated memory if successful, or NULL if not successful
void* cjson_caps_malloc(size_t sz)
{
return heap_caps_malloc(sz, MALLOC_CAP_SPIRAM);
}
//! @brief For cjson: Memory allocator to use SPIRAM
import re
import numpy
import matplotlib.pyplot as plt
from PIL import Image, ImageDraw, ImageFont
#### Import gcode ###########################################
# Assume perfectly formatted gcode: 'g1x100.0y12.2'
def decode_command(val):
return [float(i) for i in re.split(r'[gxy]\s*', val)[1:]]