Skip to content

Instantly share code, notes, and snippets.

@seth10
seth10 / clcp_sd540c.sh
Last active May 12, 2017 13:36
bash brace expansion is fun
admin@roboRIO-1086-FRC:~$ clcp_sd540c scan
{"scan":[10,12,13,15,16,17,18]}
admin@roboRIO-1086-FRC:~$ for id in 1{0,2,3,{5..8}}; do clcp_sd540c $id name; done
status: 0
{"name":"GreenTen"}
status: 0
{"name":"YellowTw"}
status: 0
{"name":"GreenThi"}
status: 0
class A:
def __init__(self, param1):
print "Class A recieved a param1 of", param1
class B(A):
def __init__(self, param1, param2):
super().__init__()
print "Class B for param1", param1, "param2", param2
#a = A(111)
@seth10
seth10 / slyt277.py
Last active May 12, 2017 13:35
Calibration based on TI's paper, www.ti.com/lit/SLYT277
import numpy as np
from PiStorms import PiStorms
def calibrate(psm):
def generateA(X,Y):
for (x,y) in zip(X,Y):
psm.screen.fillRect(x,y, 1,1, (255,0,0))
while psm.isKeyPressed(): pass # wait until the button is released from a possible previous press
while not psm.isKeyPressed(): pass # wait until the key is pressed down again
tsX = int(psm.screen.RAW_X()) # mindsensors_i2c.readInteger should really already return an integer
@seth10
seth10 / motorRunSeconds_example.ino
Created January 25, 2017 14:57
go_comeback.ino example modified to just show motorRunSeconds
#include <Wire.h>
#include <EVShield.h>
// setup for this example:
// attach external power to EVShield.
// attach 2 motors to motor ports on Bank A
EVShield evshield(0x34,0x36);
void
@seth10
seth10 / codestyle.c
Last active January 7, 2017 20:10
No this isn't serious
p(x,y,c){(*(4<<24)&16?6<<24:0x600A<<12)+x%120+y*80=x%2==0?c+(((*(4<<24)&0x10?6<<24:0x600A<12)+x%120+y*80)&0xFF00):(u8)((*(4<<24)&0x10?6<<24:0x600A<<12)+x%120+y*80)+(c<<8);}
r(x,y,w,h,c){for(i=x/2-1;++i<(x+w+1)/2;)for(j=y-1;++j<y+h;)i*2==x-1?p(i+1,j,c):i*2==x+w-1?p(i,j,c):(*(4<<24)&16?6<<24:0x600A<<12)+i%120+j*80=c+(c<<8);}
@seth10
seth10 / gfx.c
Created January 7, 2017 17:22
A different idea for helper drawing method in GBA graphics mode 4 that won't work
void drawPixel_mode4(int x, int y, u8 color)
{
u16 *here = (REG_DISPCNT & BACKBUFFER ? VideoBuffer : BackBuffer) + x%(SCREEN_WIDTH/2) + y*(SCREEN_WIDTH/2);
*here = color + (*here & 0xFF00);
}
void drawRect_mode4(int x, int y, int w, int h, u8 c)
{
u16 *currentBackBuffer = REG_DISPCNT & BACKBUFFER ? VideoBuffer : BackBuffer;
int ix, iy;
@seth10
seth10 / main.c
Created January 4, 2017 03:30
Reorganized all code to wait for VBlank, this is before simplifying with VCount
/*
* Main written by Seth Tenembaum beginning Jan 2, 2017
*
* The purpose of this document is to come to a better understanding of the fundamentals of game developmeny by building a simple platformer from scratch at a low level (but not quite down to assembly at the moment).
*
* TODO
* - fix issue when holding left and right (actually not possible on physical hardware...)
* - subpixel positioning and detach movement speed from frame rate
* - add a single platform
* - implement a global coordinate system, array of platform positions and sizes, and a camera
@seth10
seth10 / gba.h
Last active January 3, 2017 04:14
Minimal GBA platformer... with just a floor
// gba.h by eloist
#ifndef GBA_HEADER
#define GBA_HEADER
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
typedef signed char s8;
# you have
x1 = 3309
y1 = 2406
x2 = 3386
y2 = 506
x3 = 347
y3 = 426
x4 = 311
y4 = 2199
# and must assign the following to s.ts_cal: {'x1':3309, 'y1':2406, 'x2':3386, 'y2':506, 'x3':347, 'y3':426, 'x4':311, 'y4':2199}
@seth10
seth10 / alexa_lambda_2.js
Created November 26, 2016 13:51
It really should be this simple, but the lambda function returns before the request callback is executed
'use strict';
var Alexa = require('alexa-sdk');
var APP_ID = 'amzn1.ask.skill.5f3759df-5f37-59df-5f3759df5f37';
var request = require('request');
exports.handler = function(event, context, callback) {
var alexa = Alexa.handler(event, context);
alexa.APP_ID = APP_ID;
alexa.registerHandlers(handlers);