Skip to content

Instantly share code, notes, and snippets.

View soundanalogous's full-sized avatar

Jeff Hoefs soundanalogous

  • San Francisco, CA
View GitHub Profile
// BIND FIX FOR OLDER BROWSERS
if( Function.prototype.bind ) {
} else {
/** safari, why you no bind!? */
Function.prototype.bind = function (bind) {
var self = this;
return function () {
var args = Array.prototype.slice.call(arguments);
return self.apply(bind || null, args);
};
@soundanalogous
soundanalogous / jquery.ba-tinypubsub.js
Created October 1, 2012 21:15 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Hello World</title>
</head>
<body>
<button id="ledToggle">Toggle LED</button>
<p id="btnStatus"></p>
<script src="../../dist/Breakout.js"></script>
// treat the scope as read-only in views
// treat the scope as write-only in controllers
/**
* use attrs to read from scope
*/
<div my-attribute="propName">
app.directive('myDirective', function () {
@soundanalogous
soundanalogous / AccelerometerBMA250
Last active August 29, 2015 13:57
Experimental BMA250 module for Breakout.js
/**
* Copyright (c) 2011-2014 Jeff Hoefs <[email protected]>
* Released under the MIT license. See LICENSE file for details.
*/
JSUTILS.namespace('BO.io.AccelerometerBMA250');
/**
* @namespace BO.io
*/
@soundanalogous
soundanalogous / bma250
Created March 29, 2014 19:33
BMA250 example
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style type="text/css">
body {
margin: 15px;
font-family: sans-serif;
@soundanalogous
soundanalogous / StandardFirmataMemCheck.ino
Last active November 27, 2016 00:11
StandardFirmata with memory reporting
/*
* Dependencies:
* - This code depends on the ArduinUnit library. Get it here:
* https://github.com/mmurdoch/arduinounit and copy it to your
* Arduino libraries folder.
* - You must use a Firmata client library that has the STRING_DATA
* message implemented (node-firmata, johnny-five, BreakoutJS)
*
* Copy this into a new Arduino file, compile and upload.
* It will report the available memory approximately every 10 seconds.

Building an ultrasonic sensor backpack

Note: This is a bit of a scratch to see what's involved in getting the ping sensor to work as an I2C backpack.

Dependencies.

I did this on a Trinket as that's what I had to hand to make programming a bit faster. If you use a trinket you will need the custom arduino. Check out the Adafruit Trinket info https://learn.adafruit.com/introducing-trinket/introduction

You also need a custom form of the TinyWireS library that manages sending multiple registers on one read request (the

@soundanalogous
soundanalogous / NetworkFirmata.ino
Last active August 29, 2015 14:15
StandardFirmata features + Stepper motor + Ethernet
/*
* Firmata is a generic protocol for communicating with microcontrollers
* from software on a host computer. It is intended to work with
* any host computer software package.
*/
/*
Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved.
Copyright (C) 2010-2011 Paul Stoffregen. All rights reserved.
Copyright (C) 2009 Shigeru Kobayashi. All rights reserved.
@soundanalogous
soundanalogous / FirmataSerialTest.ino
Last active April 2, 2020 18:53
Firmata Serial protocol device emulator
/*
* Emulate a simple serial device in order to test the Firmata Serial protocol.
* Connect the rxPin to the TX pin of the configured port of the board running StandardFirmata
* Connect the txPin to the RX pin of the configured port of the board running StandardFirmata
*
* Use Serial to read and write to the board running StandardFirmata
* Use SoftwareSerial to write data to a console to test SERIAL_WRITE
*/
#include <SoftwareSerial.h>