added teensy code for gradients