Skip to content

Instantly share code, notes, and snippets.

View cnlohr's full-sized avatar

cnlohr cnlohr

View GitHub Profile
@cnlohr
cnlohr / inductive_measure.c
Last active May 20, 2026 14:33
Inductance measurement on ch32v003
// Assume setup from touch control
// Connect 20 turns of ~2" wide 28AWG wire between PA2 and GND.
void RunTest()__attribute__((noinline, section(".srodata")));
void DelaySysTick_RAM( uint32_t n ) __attribute__((noinline, section(".srodata")));
void DelaySysTick_RAM( uint32_t n )
{
#if defined(CH32V003) || defined(CH32V00x)
uint32_t targend = SysTick->CNT + n;
@cnlohr
cnlohr / arbitrary_function_tracer.shader
Created March 30, 2026 10:33
Fixed-step object tracer in Unity Shader code
Shader "cnlohr/StepShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_TANoiseTex ("TANoise", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
@cnlohr
cnlohr / .vimrc
Last active March 5, 2026 22:26
cnlohr's .vimrc file
set nocompatible
set number
set ruler
syntax on
@cnlohr
cnlohr / quest_geometry_shaders_in_multiview.glsl
Created February 6, 2026 09:50
Example geometry shader running in Unity on Quest.
Shader "Unlit/QuestGEO"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
@cnlohr
cnlohr / dependagen.c
Last active November 24, 2025 06:16
Unity .net assembly visualizer
// Execute with
// gcc -g dependagen.c -o dependagen && ./dependagen > test.dot
// dot -Tpng < test.dot > test.png
#include <stdint.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
@cnlohr
cnlohr / phasortest.c
Last active October 5, 2025 09:03
Phasor test, power-of-two circles
#include <stdint.h>
#include <stdio.h>
int main()
{
int i;
int a = 0;
int b = 1073741823; // 2^30-1
@cnlohr
cnlohr / testsecret.yml
Created February 5, 2025 04:02
workflow with manual dispatch and secret in environment - needs to be run manually - only works after committed to default branch
# So you don't pull your hair out, workflow dispatches must be in the default branch.
name: Secret Test
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
@cnlohr
cnlohr / fix_fft.h
Created October 31, 2024 22:24
Fixed point floating point header-only library
#ifndef FIX_FFT_H
#define FIX_FFT_H
int fix_fftr(short*, int, int);
int fix_fft(short fr[], short fi[], short m, short inverse);
#endif
#ifdef FIX_FFT_IMPLEMENTATION
@cnlohr
cnlohr / test.json
Last active August 19, 2023 19:31
test
{"schemaVersion":1,"label":"Exe Size","message":"21672\nminiosctest","color":"orange"}
@cnlohr
cnlohr / goertzels_dft_comparison.c
Created January 14, 2023 19:29
Comparison of Goertzel's and DFT algorithms.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define CNFG_IMPLEMENTATION
#include "rawdraw_sf.h"
void HandleKey( int keycode, int bDown ) { }
void HandleButton( int x, int y, int button, int bDown ) { }