Skip to content

Instantly share code, notes, and snippets.

View buhii's full-sized avatar

Takahiro Kamatani buhii

View GitHub Profile
@buhii
buhii / cube_wireframe.py
Created August 14, 2011 01:14
cube graphics in nodeBox
"""
classes for vertex, rectangle
"""
class Vertex(object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __add__(self, other):
@buhii
buhii / cube_hsr1.py
Created August 14, 2011 01:27
cube graphics in nodebox with hidden surface removal
"""
classes for vertex, rectangle
"""
class Vertex(object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __add__(self, other):
@buhii
buhii / wave.py
Created September 26, 2011 10:05
Waveform example with NodeBox
GRID = (40, 40)
BUS_STRIPE = 10
class Wave(object):
@classmethod
def clk(cls, num):
ret = []
for i in range(num):
ret.append((i + 1) % 2)
return ret
@buhii
buhii / drw_analyzer.py
Created January 10, 2012 18:57
drw_analyzer.py - smaller layout
GRID = (24, 16)
BUS_STRIPE = 3
class Wave(object):
@classmethod
def clk(cls, num):
ret = []
for i in range(num):
ret.append((i + 1) % 2)
return ret
@buhii
buhii / conv.py
Created January 11, 2012 04:29
verilog file's correct tool
import re
import sys
re_v = re.compile('(\s+)(reg|wire)(\s+)(\w+)\s*(\[\d+:0\]);')
for line in sys.stdin:
line = line[:-1] # to remove new line
result = re_v.search(line)
if result:
g = result.groups()
@buhii
buhii / dft1.py
Created January 19, 2012 00:53
simple dft example with NodeBox
from cmath import exp, sin, cos, pi
N = 512
PADDING = 16
global old_x, old_y
old_x, old_y = 0, N
def circle(x, y, r):
hr = r / 2
oval(x - hr, y - hr, r, r)
@buhii
buhii / get_rssi_map.py
Created June 18, 2012 07:20
get_rssi_map.py
import time
import sys
import curses
import serial
from collections import defaultdict
from pickle import dump, load
from xbee import ZigBee as XBee
XBEES = { # series 1
@buhii
buhii / lsm.py
Created July 22, 2012 19:05
LSM303DLH
from struct import unpack
import time
import serial
v = serial.Serial('COM14', parity=serial.PARITY_NONE, baudrate=9600)
sax, say, saz, count = 0, 0, 0, 0
cax, cay, caz = 198, -129, 16974
c = 0
@buhii
buhii / nearest_xbee.py
Created August 17, 2012 15:22
Get nearest xbee beacon (visualization in NodeBox)
import csv
from collections import Counter
speed(60)
width = 400
size(width, width)
SAMPLE = True
class RingBuffer(object):
"""
@buhii
buhii / kondo.py
Created August 19, 2012 09:06
in progress
# -*- coding: utf-8 -*-
from struct import pack
class RCB_4HV(object):
def __init__(self):
pass
def uni_servo(self, ics, speed, position):
# uni servo control