Weird Dice Part 3: Non Transitive Grime Dice
Weird Dice Part 2: Go First Dice
Weird Dice Part 1: Platonic Solids
Soldering a DSO138 Oscilloscope – Part 3
Soldering a DSO138 Oscilloscope – Part 2
Soldering a DSO138 Oscilloscope – Part 1
RGB LED Matrix with the Raspberry Pi
Here I show how to attach a WS2812 based LED strip or matrix to the Raspberry Pi.
Short introduction on how to actually install the rpi_ws218x library on the Pi:
-
- Install build essentials:
sudo apt-get update && sudo apt-get install build-essential python-dev git scons swig
- Clone the repository and build the library:
git clone https://github.com/jgarff/rpi_ws281x.git cd rpi_ws281x scons
- Compile and install the Python library:
cd python sudo python setup.py install
- Install build essentials:
Also, I have written this small example program, large parts were taken from the supplied example programs in the repository:
#!/usr/bin/env python import time import math import colorsys from neopixel import * # LED strip configuration: LED_COUNT = 64 # Number of LED pixels. LED_PIN = 18 # GPIO pin connected to the pixels (must support PWM!). LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz) LED_DMA = 10 # DMA channel to use for generating signal (try 10) LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest # True to invert the signal (when using NPN transistor level shift) LED_INVERT = False def plasma (w, h, t): out = [ Color( 0, 0, 0 ) for x in range( w * h ) ] for x in range( w ): for y in range( h ): hue = 4.0 + math.sin( t + x ) + math.sin( t + y / 4.5 ) \ + math.sin( x + y + t ) + math.sin( math.sqrt( ( x + t ) ** 2.0 + ( y + 1.5 * t ) ** 2.0 ) / 4.0 ) hsv = colorsys.hsv_to_rgb( hue / 8.0, 1, 1 ) out[ x + y * w ] = Color( *[ int( round( c * 10.0 ) ) for c in hsv ] ) return out # Main program logic follows: if __name__ == '__main__': # Create NeoPixel object with appropriate configuration. strip = Adafruit_NeoPixel( LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS ) # Intialize the library (must be called once before other functions). strip.begin() t = 0.0 # time dt = 0.1 # speed of time for i in range( 0, strip.numPixels(), 1): # iterate over all LEDs strip.setPixelColor( i, Color( 0, 0, 0 ) ) # set LED to black (off) while True: t = t + dt # increment time pic = plasma( 8, 8, t ) # render plasma of size 8x8 at time t for i in range( 0, strip.numPixels(), 1 ): # iterate over all LEDs strip.setPixelColor( # set pixel to color in picture i, pic[ i ] ) strip.show() # update LEDs time.sleep(0.001) # white a short while before loop
Assembling a DIY solder blinking LED circuit
Parsing compiler or grep output for emacsclient
This short bash snippet allows you to copy and paste any grep or compiler output of the form some/file.java:12:34
to emacsclient
to jump to the specified file, line and column in Emacs:
function emacsClient() { local IFS=":" set $1 if [ $# -eq 3 ] then emacsclient -n +"$2:$3" "$1" elif [ $# -eq 2 ] then emacsclient -n +"$2:1" "$1" else emacsclient -n "$1" fi } alias ec=emacsClient
Example call:
$ grep -nH custom init.el init.el:93: (setq custom-file (expand-file-name "custom.el" (or (file-name-directory user-init-file) default-directory))) init.el:94: (load custom-file) init.el:95: (global-set-key (kbd "") '(lambda () (interactive) (load custom-file))) $ ec init.el:95: $
Update: I forgot to make the IFS variable local to the function. This would break things like git-bash-prompt, if the IFS is suddenly set to something else.