Skip to content

Instantly share code, notes, and snippets.

View gfwilliams's full-sized avatar

Gordon Williams gfwilliams

View GitHub Profile
// Node.js
var bleno = require('bleno');
var MSG = {
LED_COLOR: 1,
MSG_NEXT: 2,
MSG_NOW: 3,
MSG_ALERT: 4,
MSG_INFO: 5
@gfwilliams
gfwilliams / koch.jscad
Created March 22, 2017 08:05
Koch snowflake vase for OpenJsCad
function circlify(v, opts) {
var d = Math.sqrt(v[0]*v[0] + v[1]*v[1]);
d = 1 + ((opts.radius-d)*opts.circle / d);
v[0] *= d;
v[1] *= d;
}
function kochs(a,b,opts) {
if (opts.d>=3) return [];
opts.d++;
@gfwilliams
gfwilliams / jimjs.js
Created May 15, 2016 19:32
Jim's LED
Hello
/* Copyright (c) 2015 Gordon Williams, Pur3 Ltd. See the file LICENSE for copying permission. */
/*
Module for the ADS1015 4 channel ADC, single ended or differential read
```
// single-ended ADC read - channel 0:
I2C1.setup({ scl : ..., sda: ...} );
var ads = new ADS1X15(I2C1);
ads.setGain(256); // +/- 0.256V
ads.getADC(0, function(val) {
// http://ece.uwaterloo.ca/~ece222/ARM/ARM7-TDMI-manual-pt3.pdf
function rlist_lr(value) {
var regs = value.split(",");
var vals = { r0:1,r1:2,r2:4,r3:8,r4:16,r5:32,r6:64,r7:128,lr:256 };
var bits = 0;
for (var i in regs) {
var reg = regs[i].trim();
if (!(reg in vals)) throw "Unknown register name "+reg;
bits |= vals[reg];
<html>
<body>Test</body>
</html>
/*OpenJsCad*/
// change me!
var holeDistance = 1;
var holeHeight = 0.5;
var bracket =
CSG.cube({ center: [0, 0, 0], radius : [1, 1, 0.1] }).union(
CSG.cube({ center: [0, 1, holeHeight/2 + 0.15], radius : [1, 0.1, holeHeight/2 + 0.25] }));
var holes =
CSG.cylinder({ start: [0, 0, -1], end: [0, 0, 1], radius: 0.4 }).union(