Skip to content

Instantly share code, notes, and snippets.

View Wollw's full-sized avatar

David E. Shere Wollw

View GitHub Profile
@Wollw
Wollw / deque.c
Created April 6, 2012 08:53
Deque in C
#include <stdlib.h>
#include <assert.h>
#include "deque.h"
struct node_struct {
struct node_struct *next;
struct node_struct *prev;
deque_val_type val;
};
@Wollw
Wollw / m328p_fastpwm.c
Last active July 2, 2023 08:35
ATmega328P PWM Example
/**
* A PWM example for the ATmega328P using the 8-Bit Fast PWM mode.
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdbool.h>
#include <util/delay.h>
int main (void) {
@Wollw
Wollw / pcint_example.c
Created May 5, 2012 00:48
ATMega328P PCINT example
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/atomic.h>
#include <util/delay.h>
#include <stdbool.h>
/*
* A global flag used to communicate between the Interrupt Service Routine
* and the main program. It has to be declared volatile or the compiler
* might optimize it out.
@Wollw
Wollw / gamepad.c.diff
Last active June 19, 2022 17:39
Diff to add support to xone for the 8BitDo Ultimate Wired Controller for XBox's Share button.
17a18,21
> /* vendor/product ID for 8BitDo Ultimate Wired Xbox */
> #define GIP_GP_VID_8BITDO 0x2dc8
> #define GIP_GP_PID_8BITDO_ULTIMATE_WIRED_XBOX 0x2002
>
258c262,268
< input_report_key(dev, KEY_RECORD, !!pkt_xs->share_button);
---
> u8 share_button;
> if (client->hardware.vendor == GIP_GP_VID_8BITDO &&
@Wollw
Wollw / 74HC595_example.c
Created April 19, 2012 06:29
ATMega328P 74HC595 Example
#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include <stdint.h>
typedef uint8_t bits_type;
#define CFG_SHIFT_DDR DDRB
#define CFG_SHIFT_PORT PORTB
#define CFG_SHIFT_SRCLK PB1
#define CFG_SHIFT_RCLK PB2
@Wollw
Wollw / adc_example.c
Created April 16, 2012 06:00
ATmega328P ADC conversion example
/* A simple ADC example that checks the analog reading on ADC0 and turns
* an LED on if the reading is higher than a threshold value and turns if
* off if it is under that value. */
#include <avr/io.h>
#include <stdint.h>
/* Which analog pin we want to read from. The pins are labeled "ADC0"
* "ADC1" etc on the pinout in the data sheet. In this case ADC_PIN
* being 0 means we want to use ADC0. On the ATmega328P this is also
* the same as pin PC0 */
@Wollw
Wollw / main.c
Created February 18, 2013 04:03
#include <stdio.h>
#include "serial.h"
#include <avr/pgmspace.h>
int main(void) {
serial_init(19200);
int i;
char buffer[8];
@Wollw
Wollw / livestream.sh
Created September 23, 2012 03:37
LiveStream with FFMPEG
CHANNEL="YOURCHANNEL"
USER="YOURUSERNAME"
PASSWD="YOURPASSWORD"
W_RATIO=16
H_RATIO=9
AUDIO="-f mp3 -i http://localhost:8000"
ffmpeg \
$AUDIO \
@Wollw
Wollw / interrupt_example.c
Created April 14, 2012 00:17
AVR Timer Interrupt Examples
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdbool.h>
/*
* A global flag used to communicate between the Interrupt Service Routine
* and the main program. It has to be declared volatile or the compiler
* might optimize it out.
*/
volatile bool update = false;
@Wollw
Wollw / scale-video.pl
Created October 24, 2012 04:33
A Perl script using ffmpeg and ffprobe to slow or speed a video so it lasts a particular duration of time.
#!/usr/bin/perl
#####
#
# This script scales an input video to be the duration provided.
#
# usage:
# scale-video.pl [-a audiofile] [-b bitrate] -d hh:mm:ss infile outfile
#
# The bitrate should be in kbps