Improved calibration function for Teensy 3.1 compatibility

Fixed some integer type defs to avoid spurrious results.