Skip to content

Instantly share code, notes, and snippets.

View Gadgetoid's full-sized avatar
🚼
+1 Baby

Philip Howard Gadgetoid

🚼
+1 Baby
View GitHub Profile
@Gadgetoid
Gadgetoid / dabblet.css
Created July 5, 2013 09:22 — forked from anonymous/dabblet.css
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
.avg-navigation {
margin:0;padding:0;list-style:none;
background:#171922;
display:block;
width:830px;
height:130px;
position:relative;
@Gadgetoid
Gadgetoid / WiringPi2-Python PiGlow Tests
Created August 16, 2013 10:20
Various patterns, cross fades, fades and helpful functions for PiGlow. Hopefully to be implemented into WiringPi2-Python.
import wiringpi2 as wiringpi
from math import floor
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
wiringpi.piGlowSetup(1)
def toggleAll(led,intensity):
wiringpi.piGlowLeg(0,intensity)
wiringpi.piGlowLeg(1,intensity)
wiringpi.piGlowLeg(2,intensity)
gadgetoid@superdupercomputer > ./generate-defines.py explorer-hat-pro wiringpi c
// Pin definitions for Explorer HAT Pro
// Using the wiringpi pin numbering scheme
#define EXPLORER_HAT_PRO_ADDR_ANALOG_INPUT 0x48
#define EXPLORER_HAT_PRO_ADDR_CAP_TOUCH 0x28
#define EXPLORER_HAT_PRO_CE0 10
#define EXPLORER_HAT_PRO_MISO 13
#define EXPLORER_HAT_PRO_INPUT_4 6
#define EXPLORER_HAT_PRO_SCKL 14
#define EXPLORER_HAT_PRO_LED_4 21
@Gadgetoid
Gadgetoid / touch-to-output.py
Created June 5, 2015 11:49
Toggle Explorer HAT's LEDs and outputs using the cap touch buttons
import explorerhat
import signal
def toggle_output(channel, event):
print("Got {} on channel {}".format(event, channel))
if channel < 5:
explorerhat.light[channel-1].write(event=='press')
explorerhat.output[channel-1].write(event=='press')
explorerhat.touch.pressed(toggle_output)
@Gadgetoid
Gadgetoid / ExplorerHat.md
Last active May 31, 2018 22:45
Explorer HAT, Motors, Steppers and Servos

#Explorer HAT Pro, Motors, Servos and Steppers

Find this Gist at: tiny.cc/explorerhat

The Motor driver on Explorer HAT Pro can not only drive motors, but a stepper motor too. And just like the Pibrella the outputs can also drive a motor or four, or another stepper.

Explorer HATs outputs sink to ground, meaning that you need to connect whatever you're driving between 5V and the output

#MOTORS

import explorerhat
import time
steps = [0 for x in range(16)]
G_FORWARDS = 2
G_BACKWARDS = 3
G_LEFT = 1
G_RIGHT = 4
G_PLAY = 5
@Gadgetoid
Gadgetoid / gist:319ecf8e3c5d3660e298
Created December 26, 2015 11:39
Static IP raspbian jessie USB gadget
# In /etc/network/interfaces
iface usb0 inet static
dns-nameservers 8.8.8.8 8.8.4.4
address 10.0.16.16
netmask 255.255.0.0
gateway 10.0.16.32
# In /etc/dhcpcd.conf
@Gadgetoid
Gadgetoid / stsmakey.py
Created January 30, 2016 11:42
Makey Makey, Explorer HAT Pro and STS-Pi together in perfect harmony
#!/usr/bin/env python
"""
You will need:
* Explorer HAT Pro
* Makey Makey
* STS-Pi
* A USB battery
Note: You will probably need to grab the latest pyusb from GitHub to make this work:
@Gadgetoid
Gadgetoid / pyruby.pb
Last active March 12, 2016 23:10
Absurdly fudgetastic method of including Python and Ruby in the same file. Will certainly break!
#!/usr/bin/env ruby
x=x\
=begin = 1
print("Hello World, I'm Python!")
'''
=end
@Gadgetoid
Gadgetoid / parse-date-time-or-datetime.py
Last active September 16, 2017 09:28
Comprehensive Python example to count down to a date, time or datetime
import argparse
import datetime
import time
import sys
import os
console_rows, console_columns = [int(x) for x in os.popen('stty size', 'r').read().split()]
output_method = None