Skip to content

Instantly share code, notes, and snippets.

@usedbytes
usedbytes / find_red_blob.c
Last active January 25, 2022 19:52
Simple routine to find the middle of the reddest blob in a YUV422 image
const uint8_t threshold = 10;
// Search for the furthest left and furthest right pixels in 'row'
// which are at least as bright as 'maxval - threshold', starting at 'start_idx'
static void search_row(uint8_t *row, int len, int start_idx, uint8_t maxval,
int *left_out, int *right_out)
{
int i;
int left = start_idx;
@usedbytes
usedbytes / hub75_fm6126A.diff
Created February 11, 2021 20:45
Quick hack to get the https://github.com/raspberrypi/pico-examples/tree/master/pio/hub75 example working with panels using FM6126A drivers
diff --git a/pio/hub75/hub75.c b/pio/hub75/hub75.c
index 1d04b6c..2f2dd45 100644
--- a/pio/hub75/hub75.c
+++ b/pio/hub75/hub75.c
@@ -41,6 +41,96 @@ int main() {
uint sm_data = 0;
uint sm_row = 1;
+ {
+ // Quick and dirty FM6126A initialisation.
@usedbytes
usedbytes / hub.scad
Last active May 6, 2020 19:12
Wheel hub for Pimoroni moon buggy wheels with captive nut for grub screw
$fn = 64;
// ===========================================================================
// Helpers and utility for calculating the d-shaft polygon
function arc_points(centre = [0, 0], start = 0, angle = 180, radius = 5) =
let(
points = [
for (theta = [ start : sign(angle) * 360 / $fn : start + angle])
centre + [radius * cos(theta), radius * sin(theta)],
@usedbytes
usedbytes / VCSM sharing
Last active September 18, 2018 21:47
Sharing VCSM buffers cross-process
Build the two apps:
```
gcc -L/opt/vc/lib -I/opt/vc/include -o p1 -l vcsm p1.c
gcc -L/opt/vc/lib -I/opt/vc/include -o p2 -l vcsm p2.c
```
Run p1, then run p2 in another shell
SteamVR System Report created Fri Oct 20 23:33:13 2017
<Report>
SteamVR Version: 1508466289
SteamVR Date: 2017-10-20
Steam: Public
Steam Branch: beta
Steam AppID: 250820
Tracking: lighthouse
OS: Linux version 4.13.7-1-ARCH (builduser@tobias) (gcc version 7.2.0 (GCC)) #1 SMP PREEMPT Sat Oct 14 20:13:26 CEST 2017
@usedbytes
usedbytes / stupid_strcat.c
Created March 25, 2015 18:26
A stupid string concatenation routine.
/* C equivalent of the "slow in-memory" Java code from this "paper":
* http://arxiv.org/pdf/1503.02678v1.pdf
* Apparently it takes 274 seconds on Java6!
*
* $ time ./a.out
*
* real 0m42.023s
* user 0m31.880s
* sys 0m10.137s
*/