Rotation sensor, largely based on API example