This file contains hidden or 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
| //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; |
This file contains hidden or 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
| 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; | |
| } |
This file contains hidden or 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
| #!/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]) |
This file contains hidden or 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
| #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; |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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; |
NewerOlder