Skip to content

Instantly share code, notes, and snippets.

@OrganicIrradiation
OrganicIrradiation / gist:f2754cffb04d07bab929
Created November 18, 2014 08:54
Arduino FastLED WS2812B red tail light sequence
#include "FastLED.h"
// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN
#define LED_PIN 11
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define NUM_LEDS 72
@OrganicIrradiation
OrganicIrradiation / hb_batchconvertvideos.py
Created February 8, 2015 13:48
hb_batchconvertvideos
import os
import time
import subprocess
import sys
fileList = []
rootdir = raw_input("Root Dir: ")
for root, subFolders, files in os.walk(rootdir):
for file in files:
theFile = os.path.join(root,file)
@OrganicIrradiation
OrganicIrradiation / bSplineResizeWidth.m
Created February 8, 2015 13:54
GoPro SuperView-like adaptive aspect ratio
function [outImage, SAFEZONE] = bSplineResizeWidth(theSize, inImage, SAFEZONE, DEBUG)
if nargin < 4 || isempty(DEBUG)
DEBUG = 0; % Number of "safe zones"
end
if nargin < 3 || isempty(SAFEZONE)
SAFEZONE = [37.5,62.5]; % Percent of image width
end
INTERPMETHOD = 'spline';
%% Deal with input and output image sizes
@OrganicIrradiation
OrganicIrradiation / WiFlyTimeWithConsole.pde
Created February 8, 2015 13:59
WiFi-Enabled Arduino Fio using the WiFly RN-XV (RN171XV)
/*
WiFlyTimeWithConsole.pde
http://www.semifluid.com
Based upon httpclient.ino from:
https://github.com/harlequin-tech/WiFlyHQ/blob/master/examples/httpclient/httpclient.ino
and Console.pde from:
================
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
@OrganicIrradiation
OrganicIrradiation / ProcessHDRVideo.m
Created February 8, 2015 14:04
Magic Lantern HDR video to tonemapped video with MATLAB scripts
% Prerequisites (tested on Mac OS X 10.8.5):
% exiftool (tested with 9.37)
% http://www.sno.phy.queensu.ca/~phil/exiftool/
% Luminance HDR (tested with 2.3.1)
% http://qtpfsgui.sourceforge.net/
function ProcessHDRVideo(MOVIENAME,EVDIFF)
% Include the audio
% [y,Fs] = audioread(moviename);
% filename = fullfile(workingDir,'images','audioTrack.wav');
@OrganicIrradiation
OrganicIrradiation / new_functions.ino
Created March 23, 2015 09:37
Arduino FIO Graphical LCD Console
// Print character arrays to console
void u8g_print(char* theString) {
char ch;
byte i = 0;
while ((ch = theString[i++]) != '\0') {
read_line(ch);
}
}
// Print character arrays with a new line at the end
void u8g_println(char* theString) {
@OrganicIrradiation
OrganicIrradiation / increasing_compression.m
Created March 23, 2015 09:41
Effect of repeated JPEG compression on image quality and content
% Load the 'original image', rescale to 1920 width, crop to 1080 height
originalImage = imread('YOURPHOTOHERE.JPG');
scaledImage = imresize(originalImage, [NaN 1920]);
scaledImage = imcrop(scaledImage,[0, size(scaledImage,1)/2-1080/2,...
size(scaledImage,2), size(scaledImage,1)/2+1080/2-1]);
% Create a data output folder
[currentPath, ~, ~]= fileparts(mfilename('fullpath'));
mkdir(fullfile(currentPath,'data')) % Create the data directory
@OrganicIrradiation
OrganicIrradiation / U8glib_Oscilloscope2D.ino
Created March 23, 2015 09:56
Arduino FIO 2 Channel LCD Oscilloscope
#include "U8glib.h"
#include <EEPROM.h>
// Variables you might want to play with
unsigned int timePeriod = 65; // 0-65535, us or ms per measurement (max 0.065s or 65.535s)
byte voltageRange = 1; // 1 = 0-3.3V, 2 = 0-1.65V, 3 = 0-0.825V
byte ledBacklight = 100;
boolean linesNotDots = true; // Draw lines between data points
@OrganicIrradiation
OrganicIrradiation / U8glib_Hello_World.ino
Last active August 29, 2015 14:17
Arduino FIO LCD Oscilloscope
#include "U8glib.h"
const byte lcdLED = 6; // LED Backlight
const byte lcdA0 = 7; // Data and command selections. L: command H : data
const byte lcdRESET = 8; // Low reset
const byte lcdCS = 9; // SPI Chip Select (internally pulled up), active low
const byte lcdMOSI = 11; // SPI Data transmission
const byte lcdSCK = 13; // SPI Serial Clock
// SW SPI:
@OrganicIrradiation
OrganicIrradiation / demo_ico.m
Created March 23, 2015 10:06
3D “Potato” Generation using Sinusoidal Pertubations
nRecurse = 0;
FV = sphere_tri('ico',nRecurse,[],0);
lighting phong;
shading interp;
figure;
patch('vertices', FV.vertices,'faces', FV.faces, 'facecolor', [0.5 0.5 0.5], 'edgecolor', [.2 .2 .2]);
axis square;
axis off;
camlight infinite;
camproj('orthographic');