First of all, great work. It's a thrill when things work.

I wonder. The "dt" in your sourcecode(where i persume your dt=delta time which is basically the sampling time, or deravative time if you will) is expressed :

dt = ((float)delta) / 1000.0;

and you have a "if":

if( delta >= mydt) { // sample every dt ms -> 1000/dt hz.

which I cant seem to understand why you have implemented.

I'm not sure I understand why you have done that at all.

It seems you have chosen a deltatime insted of having a deltatime which size depends on the cycletime of the program.

if you could explain this, it would be great. if not, I'm just gonna have to "learn" the kalman filter from scratch. again