Skip to content

Instantly share code, notes, and snippets.

Phil Hazelden ChickenProp

Block or report user

Report or block ChickenProp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ChickenProp
ChickenProp / gist:3231712
Created Aug 2, 2012
Briefly: using an Adafruit LED Matrix with the Raspberry Pi
View gist:3231712

Adafruit sells an 8x8 LED matrix which you can control from a Raspberry Pi using I2C. Unfortunately they only provide Arduino code; I've only used I2C through the programs i2cset, i2cget, i2cdump and i2cdetect available from the i2c-tools package; and it wasn't immediately obvious how to use Adafruit's code to control the matrix from the Pi.

Fortunately, it turns out to be quite simple. i2c-tools seems to assume a register-based model of I2C devices, where the target device has up to 256 pointers which can be read and written. This doesn't seem to suit the HT16K33 chip (datasheet) that the matrix backpack uses. For example, when I ran i2cdump, which gets the value of each register, it started to blink a picture at me. At least I knew it was working.

Setting individual LEDs works much as you might expect. Every row has a single register, the eight bits of that register correspond to the eight LEDs on

@ChickenProp
ChickenProp / gist:3059628
Created Jul 6, 2012
Arch RPi miscellany
View gist:3059628

Some notes on getting Arch to work on the RPi.

Rebooting

At first, running shutdown -r now would cause the RPi to halt but not restart. A firmware upgrade fixed this. Install git, then clone and run rpi-update. (The script requires git to run, so you can't just copy it from the repository.)

Pacman and udev

pacman used to complain about being out of date, and ask if I wanted to upgrade; and it would complain about udev-oxnas and systemd-tools both wanting to own udev. (I no longer remember exactly what the errors were.)

@ChickenProp
ChickenProp / gist:2942612
Created Jun 16, 2012
Calculating e in Bash
View gist:2942612

The point of this post is an attempt to calculate e to given precision in bash, a challenge given in a job listing that I saw recently. I kind of got nerd sniped. I wrote this as I went along, so there may be inconsistencies.

###First attempt###

The obvious method to compute e is as the infinite sum of 1/n!, n from 0 to ∞. This converges quickly, but how far do we have to calculate to get the n'th digit of e? We can deal with that later.

We obviously need a factorial function.

fac() {
View keybase.md

Keybase proof

I hereby claim:

  • I am chickenprop on github.
  • I am philh (https://keybase.io/philh) on keybase.
  • I have a public key whose fingerprint is 84A5 6F31 7B32 3DBD 160C 37E8 6EAA 563A 7D8D E4A4

To claim this, I am signing this object:

You can’t perform that action at this time.