Skip to content

Instantly share code, notes, and snippets.

View stefandz's full-sized avatar

stefandz

View GitHub Profile
@stefandz
stefandz / offset_sinewave.ino
Created November 7, 2017 15:55
Offset sinewave generation for testing PWM open drain circuitry
const int num_pwm_pins = 4;
const int pwm_pins[ num_pwm_pins ] = { 9, 10, 11, 13 };
uint8_t tick_count = 0;
void setup() {
for( uint8_t i=0; i<num_pwm_pins; i++ ){
pinMode( pwm_pins[ i ], OUTPUT );
}
}
@stefandz
stefandz / mate_gui.sh
Created June 15, 2017 12:50
Enable or disable the Ubuntu Mate GUI
#!/bin/bash
if [[ "$1" == 'enable' || "$1" == 'disable' ]]; then
if [ "$1" == 'disable' ]; then
systemctl set-default multi-user.target --force
fi
systemctl $1 lightdm.service --force
systemctl $1 graphical.target --force
systemctl $1 plymouth.service --force
@stefandz
stefandz / Touch_MP3_no_trigger_while_playing
Last active May 23, 2016 17:38
Touch_MP3 but without the ability to trigger another track while one is currently playing
/*******************************************************************************
Bare Conductive Touch MP3 player
------------------------------
Touch_MP3.ino - touch triggered MP3 playback
You need twelve MP3 files named TRACK000.mp3 to TRACK011.mp3 in the root of the
microSD card.
When you touch electrode E0, TRACK000.mp3 will play. When you touch electrode
E1, TRACK001.mp3 will play, and so on.
@stefandz
stefandz / Touch_MP3_hold_to_play.ino
Created April 18, 2016 11:58
Touch_MP3 with push-and-hold-to-play behaviour
/*******************************************************************************
Bare Conductive Touch MP3 player
------------------------------
Touch_MP3.ino - touch triggered MP3 playback
You need twelve MP3 files named TRACK000.mp3 to TRACK011.mp3 in the root of the
microSD card.
@stefandz
stefandz / factorSquare.pde
Last active November 1, 2016 09:56
Factor square drawer
final boolean monochrome = true; // in this mode, primes are black, non-primes are white
// otherwise darker colours have fewer factors, lighter colours have more
final int windowWidth= 640;
final int windowHeight= 320;
final int plotWidth = 3;
final int plotHeight = 5;
void settings() {
size(windowWidth, windowHeight);
@stefandz
stefandz / bash_tricks
Last active February 28, 2020 14:44
Prompt config for iTerm
alias show_files='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hide_files='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
alias hide_shadows='defaults write com.apple.screencapture disable-shadow -bool TRUE; killall SystemUIServer'
alias show_shadows='defaults write com.apple.screencapture disable-shadow -bool FALSE; killall SystemUIServer'
alias cls='clear'
alias tracert='traceroute'
alias lsusb='system_profiler SPUSBDataType'
alias √='echo $?'
@stefandz
stefandz / findArduinoSketchbook.js
Last active August 29, 2015 14:20
Locates the user's Arduino 1.5.X or earlier sketchbook folder
// locates the user's Arduino 1.5.X or earlier sketchbook folder
// 1.5.X folders are returned via STDOUT with a return code of 0
// if only a pre 1.5.X folder can be found, it is also returned via STDOUT, but with a return code of 2
// if no folder can be found, a return code of 1 is returned and STDOUT lets you know that no folder can be found
// tested and known working on:
// OSX 10.9.5
// Windows 7 Ultimate SP1 (build 7601)
@stefandz
stefandz / Compiler_Errors.h
Created April 20, 2015 11:38
Bare Conductive Touch MP3 code with repeated play (as opposed to touch-again-to-stop) behaviour
/*******************************************************************************
Bare Conductive Compiler Error Handler
--------------------------------------
Compiler_Errors.h - avoids incorrect builds due to wrong environment
Bare Conductive code written by Stefan Dzisiewski-Smith and Peter Krige.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0
@stefandz
stefandz / LED_Proximity.ino
Created April 15, 2015 17:04
Bare Conductive Proximity to LED intensity demo
// maps intensity of the onboard D13 LED on the Touch Board
// to the proximity of a hand to a 85mmx85mm electrode
// connected to electrode 0 on the board
#include <MPR121.h>
#include <Wire.h>
#define LOW_DIFF 0
#define HIGH_DIFF 50
#define filterWeight 0.3f
@stefandz
stefandz / Touch_LEDs.ino
Created February 19, 2015 11:12
Bare Conductive LED controller
/*******************************************************************************
Bare Conductive LED controller
------------------------------
Touch_LEDs.ino - touch triggered LED control - maps each electrode to a digital
output and toggles it on and off.
Based on code by Jim Lindblom and plenty of inspiration from the Freescale