Code for visualization of Color Commons light blades interaction. See the visualization at http://bl.ocks.org/pingswept/4999632 (click "open in a new window").
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define RX_STATUS_PIN 13 | |
#define RX_ENABLE_PIN 2 | |
#define TX_ENABLE_PIN 3 | |
volatile uint8_t DmxRxField[8]; //array of DMX vals (raw) | |
volatile uint16_t DmxAddress; //start address | |
enum {IDLE, BREAK, STARTB, STARTADR}; //DMX states |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@public.route('/speed/<channel>/<pulse_in_ms>') | |
def set_motor_speed(channel, pulse_in_ms): | |
pytronics.serialWrite(chr(0xAA), speed=9600) | |
if (channel == 'right'): | |
side = chr(0x01) | |
else: | |
side = chr(0x02) | |
rough_speed = (int(pulse_in_ms) >> 7) & 0x7F # grab bits 7-13 | |
fine_speed = int(pulse_in_ms) & 0x7F # wipe out all but bits 0-6 | |
pytronics.serialWrite(chr(0x84) + side + chr(fine_speed) + chr(rough_speed), speed=9600) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* simple.c | |
Simple libftdi usage example | |
This program is distributed under the GPL, version 2 | |
*/ | |
#include <ftdi.h> | |
#include <stdio.h> | |
#include <string.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import datetime | |
sql_live = """SELECT | |
strftime('%Y-%m-%d %H:%M GMT', logdate) AS logdate, | |
avg({0}) AS {0} | |
FROM log | |
WHERE logdate >= datetime('now', '-180 minutes') | |
GROUP BY strftime('%Y-%m-%d %H:%M', logdate) | |
ORDER BY 1;""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* weather_usb.cpp | |
Weather station client using libftdi | |
compile: g++ -l ftdi -o weather_usb weather_usb.cpp | |
This program is distributed under the BSD license | |
*/ | |
#include <ftdi.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, request | |
from uwsgidecorators import * | |
import pytronics | |
import os, time | |
public = Flask(__name__) | |
public.config['PROPAGATE_EXCEPTIONS'] = True | |
# Include "no-cache" header in all POST responses | |
@public.after_request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
program = int(d[color[0:25].lower()]) | |
except KeyError: | |
print 'color {0} not found'.format(color) | |
program = int(d['red']) | |
command = 'X04%(number)2.2X' % {"number": program} | |
print 'Translated {0} to {1}'.format(color, command) | |
if (command in allowed_commands): | |
pytronics.serialWrite(command, speed=9600) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytronics, webcolors | |
from math import pi, radians, sin | |
def clear_lcd(): # also moves cursor to 0,0 | |
pytronics.serialWrite(chr(0xFF) + chr(0xCD), 9600) | |
def put_string(data): | |
pytronics.serialWrite(chr(0x00) + chr(0x18) + data + chr(0x00), 9600) | |
def draw_filled_rectangle(x1, y1, x2, y2, color): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2014, Brandon Stafford, brandon@rascalmicro.com | |
// Redistribution and use in source and binary forms, with or without | |
// modification, are permitted provided that the following conditions | |
// are met: | |
// 1. Redistributions of source code must retain the above copyright | |
// notice, this list of conditions and the following disclaimer. | |
// 2. Redistributions in binary form must reproduce the above copyright | |
// notice, this list of conditions and the following disclaimer in the |