Guide to gyro and accelerometer with Arduino including Kalman filtering

Okay, it is simple then.
In line 97, is says:

  accZval++;//1g in horizontal position

That should just be changed to:

  accZval--;//-1g when facing down