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 / img_type_size.py
Created January 25, 2020 15:07
pipeable "file" command replacement for gif/jpeg/png (https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=262967)
#!/usr/bin/env python3
'''
Pipeable "file" command replacement for gif/jpeg/png images.
Outputs three lines (type, width, height), followed by copy of input.
'''
import struct
import sys
def get_image_type_size(fhandle):
@Hermann-SW
Hermann-SW / test.txt
Last active January 26, 2020 16:28
learn about revisions
foo
Aa (Orchidaceae)
Aaronsohnia (Compositae)
Abacopteris (Thelypteridaceae)
Abarema (Leguminosae)
Abatia (Salicaceae)
Abdominea (Orchidaceae)
Abdulmajidia (Lecythidaceae)
Abelia (Caprifoliaceae)
Abeliophyllum (Oleaceae)
@Hermann-SW
Hermann-SW / rgb2fb.c
Last active February 6, 2020 11:02
High framerate drawing stream of RGB frames on Raspberry framebuffer (https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=264109)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
@Hermann-SW
Hermann-SW / yuvrgbfb
Created February 5, 2020 14:37
profiling bash script for work with rgba2fb.c (https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=264109)
#!/bin/bash
if [[ rgb2fb.c -nt rgb2fb ]]; then
echo "compiling rgb2fb.c"; gcc -O6 -Wall -pedantic -Wextra rgb2fb.c -o rgb2fb
fi
if [[ "$#" > 0 ]]; then t=$1; else t=600000; fi
raspividyuv -fps 90 -rgb -o - -pts $0.pts \
-md 7 -w 640 -h 480 -n -t $t -awb greyworld | \
./rgb2fb 640 480 F 2> $0.txt
@Hermann-SW
Hermann-SW / yuvrgbfb0
Created February 6, 2020 11:08
profiling bash script for work with rgba2fb.c (https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=264109)
#!/bin/bash
if [[ rgb2fb.c -nt rgb2fb ]]; then
echo "compiling rgb2fb.c"; gcc -O6 -Wall -pedantic -Wextra rgb2fb.c -o rgb2fb
fi
if [[ "$#" > 0 ]]; then t=$1; else t=600000; fi
raspividyuv -fps 135 -rgb -o - -pts $0.pts \
-md 7 -w 640 -h 480 -n -t $t -awb greyworld | \
./rgb2fb 640 480 0 2> $0.txt
@Hermann-SW
Hermann-SW / toggle.c
Created March 12, 2020 19:00
toggle GPIO17 camera schedule every Nth frame, triggeded by Raspberry hardware camera sync pulses on GPIO18 (https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=267761)
/*
$ gcc -O6 -Wall -pedantic -Wextra -o toggle toggle.c -lpigpio -lrt -lpthread
$
Usage:
$ sudo killall pigpiod
$ sudo ./toggle 30 &
$ raspivid -md 1 -w 1920 -h 1080 -p 22,50,960,540 -o tst.h264 -fps 30 -t 8000 -pts tst.pts
$ ./ptsanalyze tst.pts 0
$ # https://github.com/Hermann-SW/userland/blob/master/tools/ptsanalyze
@Hermann-SW
Hermann-SW / dead-man_button.c
Created March 28, 2020 14:44
Raspberry Pi code for raspcatbot control by Wifi joystick (https://esp32.com/viewtopic.php?f=19&t=14803&p=57338#p57338)
/*
$ gcc -O6 -Wall -pedantic -Wextra -o dead-man_button dead-man_button.c -lpigpio -lrt -lpthread
$
Usage:
$ sudo killall pigpiod
$ sudo ./dead-man_button
$
*/
#include <stdio.h>
#!/bin/bash
while true
do
fin_wait2=`netstat 2>/dev/null | grep 1337`
if [[ "$fin_wait2" = "" ]]
then
sudo ./dead-man_button
else
sudo ./dead-man_button 1338
fi
#include <Wire.h>
#include "SSD1306Wire.h"
SSD1306Wire display(0x3c, 5, 4);
#include "WiFi.h"
#include <WiFiMulti.h>
WiFiMulti WiFiMulti;
WiFiClient client;
@Hermann-SW
Hermann-SW / arduino_compile
Last active April 27, 2020 07:57
Simple Raspberry pigpio based Arduino sketch compiler
#!/bin/bash
if [[ "$1" == "" || ${1: -4} != ".ino" ]]; then
echo -e "Usage:\n"`basename $0`" file.ino\nsudo ./file"
exit
fi
wrapper=`cat << EndOfWrapper
#include <time.h>
#include <unistd.h>