Some notes based on questions I've gotten - test your sensor, mine's marked for pitch & roll, but be sure you know which is which before you mount it. The output is Actual Roll, Deviation from starting Roll, Actual Pitch, Deviation from starting pitch… as I have it in the code above. There are lots of other outputs you can enable, just by removing the comments for them. The ones I'm displaying are the kalman angles. For testing, especially with a different sensor, I'd enable more of the output.
maxDev is defined as 10... and not currently used. You can see I've commented out the bits for it in the output section, but that's where you could set it so that if the angle is more than 10 degrees from the start angle, send a hard stop / pause / warning or whatever to your printer.