Skip to content

Instantly share code, notes, and snippets.

🔒
busy

Dario Longobardi kashimAstro

🔒
busy
Block or report user

Report or block kashimAstro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kashimAstro
kashimAstro / kalman_filter.h
Created Mar 1, 2016
kalman filter IMU / MPU6050
View kalman_filter.h
//https://en.wikipedia.org/wiki/Kalman_filter#Example_application.2C_technical
class Kalman {
public:
Kalman() {
Q_angle = 0.001;
Q_bias = 0.003;
R_measure = 0.03;
angle = 0;
bias = 0;
@kashimAstro
kashimAstro / NoiseDithering.glsl
Last active Mar 4, 2016
Generated Noise pattern for dithering
View NoiseDithering.glsl
vec2 rand(vec2 coord, vec2 uv, float noiseamount, bool noise) {
float noiseX = ((fract(1.0-coord.s*(uv.x/2.0))*0.25)+(fract(coord.t*(uv.y/2.0))*0.75))*2.0-1.0;
float noiseY = ((fract(1.0-coord.s*(uv.x/2.0))*0.75)+(fract(coord.t*(uv.y/2.0))*0.25))*2.0-1.0;
if (noise) {
noiseX = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233))) * 43758.5453),0.0,1.0)*2.0-1.0;
noiseY = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233)*2.0)) * 43758.5453),0.0,1.0)*2.0-1.0;
}
return vec2(noiseX,noiseY)*noiseamount;
}
@kashimAstro
kashimAstro / i2cUDPMPU6050.py
Last active Feb 20, 2016
i2c UDP Demon Read MPU6050 data and write socket [ USAGE: python i2cUDPMPU6050.py '127.0.0.1' 5005 1 'N' ]
View i2cUDPMPU6050.py
#!/usr/bin/python
import smbus
import math
import socket
import sys
import time
if len(sys.argv) < 4:
sys.exit('Usage: %s IPADDRESS PORT ID_BUS_I2C' % sys.argv[0])
@kashimAstro
kashimAstro / i2cRaspberryGPIO.h
Last active Sep 24, 2018
i2c Multiple Byte read and write c++
View i2cRaspberryGPIO.h
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/i2c-dev.h>
class i2cReadWrite {
public:
int file_i2c;
unsigned char buffer[60];
int length=2;
@kashimAstro
kashimAstro / pseudocode
Created Feb 19, 2016
pseudocode floyd steinberg
View pseudocode
per ogni y dall'alto in basso
per ogni x da sinistra a destra
vecchio_pixel := pixel[x][y]
nuovo_pixel := trova_il_colore_della_tavolozza_più_vicino(vecchio_pixel)
pixel[x][y] := nuovo_pixel
quant_errore := vecchio_pixel - nuovo_pixel
pixel[x+1][y] := pixel[x+1][y] + 7/16 * quant_errore
pixel[x-1][y+1] := pixel[x-1][y+1] + 3/16 * quant_errore
pixel[x][y+1] := pixel[x][y+1] + 5/16 * quant_errore
pixel[x+1][y+1] := pixel[x+1][y+1] + 1/16 * quant_errore
@kashimAstro
kashimAstro / floydSteinberg.h
Created Feb 19, 2016
C++ Floyd-Steinberg 24bit RGB color
View floydSteinberg.h
unsigned char * floydSteinberg(unsigned char * source, int w, int h){
unsigned char * newSource;
for(int i=0; i<(h*3); i++){
for(int j=0; j<w; j++) {
int ci = i*w+j;
int cc = source[ci];
int rc = (cc<128?0:255);
int err = cc-rc;
source[ci] = rc;
if(j+1<w) source[ci+1] += (err*7)>>4;
You can’t perform that action at this time.