Skip to content

Instantly share code, notes, and snippets.

View Hermann-SW's full-sized avatar

Hermann Stamm-Wilbrandt Hermann-SW

View GitHub Profile
@Hermann-SW
Hermann-SW / long_exposure
Created October 19, 2020 16:23
Shell script to capture arbitrary long exposures with Raspberry HQ camera, no 239 second limit
#!/bin/bash
if [ ! -f /var/run/pigpio.pid ]; then sudo pigpiod -s 1; sleep 0.5; fi
pigs hp 18 80 3
raspivid -md 4 -w 1012 -h 760 -fps 80 -o tst.h264 -pts tst.pts -p 500,22,506,380 -t $(($1*1000 + 3000)) &
pid=$!
sleep 2
pigs w 18 0
sleep $1
sudo ./nanopulse 39 1 9
@Hermann-SW
Hermann-SW / dra.c
Created October 25, 2020 23:52
Direct register access, propagate GPIO18 to GPIO17
//
// How to access GPIO registers from C-code on the Raspberry-Pi
// Example program
// 15-January-2012
// Dom and Gert
// Revised: 15-Feb-2013
// gcc -O6 -I/opt/vc/include -L/opt/vc/lib -lbcm_host dra.c -o dra
// Access from ARM Running Linux
@Hermann-SW
Hermann-SW / blink.c
Created October 28, 2020 13:44
high frequency GPIO17 square wave
@Hermann-SW
Hermann-SW / build_devmem
Created October 30, 2020 21:51
Create root owned /usr/local/bin/devmem with sticky bit set (from busybox)
#!/bin/bash
cd /tmp
git clone https://git.busybox.net/busybox
cd busybox/miscutils
cat << EOF > libbb.h
#ifndef _libbbb_h
#define _libbbb_h
@Hermann-SW
Hermann-SW / poke.c
Last active November 2, 2020 10:45
peek / poke / peek_l / poke_l (for Raspberry Pi register manipulation)
/*
gcc -Wall -pedantic -Wextra poke.c -o poke
ln -s poke peek && ln -s poke peek_l && ln -s poke poke_l
ln -s poke peek_s && ln -s poke peek_sl
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#include <arm-linux-gnueabihf/bits/stdint-uintn.h>
@Hermann-SW
Hermann-SW / gpio_base.c
Created November 11, 2020 09:44
Determine GPIO base address for the Raspberry Pi running this command
/*
gcc -O6 -I/opt/vc/include -L/opt/vc/lib -lbcm_host gpio_base.c -o gpio_base
*/
#include <stdio.h>
#include <bcm_host.h>
void main() { printf("%08x\n", bcm_host_get_peripheral_address() + 0x200000); }
@Hermann-SW
Hermann-SW / sketch_nov15.ino
Created November 15, 2020 16:19
4x4 keypad control of telescope focusing stepper motor
#include <Stepper.h>
#define STEPS 200
Stepper stepper(STEPS, 8, 10, 9, 11);
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
@Hermann-SW
Hermann-SW / reboot
Created November 24, 2020 17:05
Replacement for /sbin/reboot after having moved /sbin/reboot to /bin/reboot
#!/bin/bash
date +%s > /home/pi/last_reboot
/bin/reboot
@Hermann-SW
Hermann-SW / pclkf.c
Last active November 30, 2020 20:42
Send 48MB test data over 24 GPIOs from Pi0 to Pi400, with handshakes
/*
gcc -O6 -Wall -pedantic -Wextra pclkf.c -o pclkf
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
//#include <arm-linux-gnueabihf/bits/stdint-uintn.h>
#include <fcntl.h>
#include <sys/mman.h>
@Hermann-SW
Hermann-SW / rcvf.c
Last active November 30, 2020 20:46
Receive 48MB test data over 24 GPIOs from on Pi400 from Pi0, with handshakes
/*
gcc -O6 -Wall -pedantic -Wextra rcvf.c -o rcvf
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
//#include <arm-linux-gnueabihf/bits/stdint-uintn.h>
#include <fcntl.h>
#include <sys/mman.h>