Archive for July, 2010

Using the Accelerometer in Android

To help a buddy (r4sh44t) I’ve compiled some code pieces of how using the orientation (accelerometer) in Android. Just in case someone finds it useful.

Global variables that will be useful:

//Justo despues de la declaracion del activity (public class MICLASE extends Activity{ ) podemos declarar estas variables globales
//Just after the declaration of the activity (public class MYCLASS extends Activity{ ) we can declare these global variables
private SensorManager myManager;
private List sensors;
private Sensor oriSensor;
private float oldA;
private float oldP;
private float oldR;

Capturing the sensor:

//Capturar sensor de orientacion (en el onCreate!)
//Capture orientation sensor (in the onCreate!)
myManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
sensors = myManager.getSensorList(Sensor.TYPE_ORIENTATION);
if(sensors.size() > 0)
{
oriSensor = sensors.get(0);
Toast.makeText(getApplicationContext(), "Sensor OK",
2).show();
}
else Toast.makeText(getApplicationContext(), "No Sensor", 2).show();
myManager.registerListener(mySensorListener, oriSensor,
SensorManager.SENSOR_DELAY_GAME);

Reading from the sensor:

//Leer del sensor
//Reading from the sensor
private final SensorEventListener mySensorListener = new SensorEventListener()
{
public void onSensorChanged(SensorEvent event)
{

//Aqui la funcion que usara los datos del sensor
//Here the function that will use the sensor data
yourFunctionThatUsesTheData(event.values[0],
event.values[1],
event.values[2]);;
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
};

Using the data:

//Ejemplo de una funcion que use los datos, solo teniendo en cuenta el cambio desde la ultima vez que se leyó
//Example of a function that uses the data only using the difference of movement from the last read
private void yourFunctionThatUsesTheData (float a, float p, float r){
float thisA = a - oldA * 10;
float thisP = p - oldP * 10;
float thisR = r - oldR * 10;
oldA = a;
oldP = p;
oldR = r;

//Hacer cosas con estas variables
//Do stuff with these variables
}

And to understand what a p & r mean here you have a graphic:

Tags: , , , , , , , , , ,

Recover Touchpad Ubuntu

Today I upgraded the ubuntu of my netbook and I found out that when I came back to the OS my Touchpad didnt work anymore. After trying to fix it with the man of xorg.conf and failing googling i found the solution:

You need to login as root (sudo does not work) and execute the following command.

echo options psmouse proto=exps > /etc/modprobe.d/psmouse.modprobe

And after that reboot.

PS: If you don’t have an external mouse to plug in, hitting control+alt+F2 you can find a console.

Via: danilogurovich

Tags: , , , , , ,

Sorry, but this post is not available in English

Sorry, but this post is not available in English

Tags: , ,

Lost an eye? The perfect excuse to get a camera implant!

Video after the jump, it autoplays.
Read the rest of this entry »

Tags: , , , , ,

New freak shirts!

I’ve updated my online shirt shop* with some new designs (click to get to them in the shop):

Read the rest of this entry »

Tags: , , , , ,

The Cloud Song!

A funny flash about Cloud of Final Fantasy! (Click on the image to watch the animation, as it starts playing by itself).

Autor: SpookyDoom @ Deviantart, original here.

Tags: , , , , ,

How to change the MTU over Windows Vista/7

To do this we’ll need to open a terminal, to do this I recommend to hit WindowsKey+R and write cmd and hit intro.

After this trivial step we’ll need to see our interfaces and their MTU:
netsh interface ipv4 show subinterfaces

To know the max size we can assign to our MTU we can try with:
ping www.REFERENCEWEB.com -f -l SIZE

And finally to set the MTU that we need we can execute:
netsh interface ipv4 set subinterface "YOUR INTERFACE NAME" mtu=SIZE store=persistent

Discovered via http://www.richard-slater.co.uk/archives/2009/10/23/change-your-mtu-under-vista-or-windows-7/

Tags: , , ,