#include "Zowi.h" #include void Zowi::init(int YL, int YR, int RL, int RR, bool load_calibration) { servo[0].attach(YL); servo[1].attach(YR); servo[2].attach(RL); servo[3].attach(RR); if (load_calibration) { for (int i = 0; i < 4; i++) { int servo_trim = EEPROM.read(i); if (servo_trim > 128) servo_trim -= 256; servo[i].SetTrim(servo_trim); } } Serial.begin(115200); Serial.println(" test"); for (int i = 0; i < 4; i++) servo_position[i] = 90; } void Zowi::setTrims(int YL, int YR, int RL, int RR) { servo[0].SetTrim(YL); servo[1].SetTrim(YR); servo[2].SetTrim(RL); servo[3].SetTrim(RR); } void Zowi::saveTrimsOnEEPROM() { for (int i = 0; i < 4; i++) EEPROM.write(i, servo[i].getTrim()); } void Zowi::moveServos(int time, int servo_target[]) { if(time>10){ for (int i = 0; i < 4; i++) increment[i] = ((servo_target[i]) - servo_position[i]) / (time / 10.0); final_time = millis() + time; for (int iteration = 1; millis() < final_time; iteration++) { partial_time = millis() + 10; for (int i = 0; i < 4; i++) servo[i].SetPosition(servo_position[i] + (iteration * increment[i])); while (millis() < partial_time); //pause } } else{ for (int i = 0; i < 4; i++) servo[i].SetPosition(servo_target[i]); } for (int i = 0; i < 4; i++) servo_position[i] = servo_target[i]; } void Zowi::oscillateServos(int A[4], int O[4], int T, double phase_diff[4], float cycle=1){ for (int i=0; i<4; i++) { servo[i].SetO(O[i]); servo[i].SetA(A[i]); servo[i].SetT(T); servo[i].SetPh(phase_diff[i]); } double ref=millis(); for (double x=ref; x= 1) for(int i=0;i= 1) for(int i=0;i= 1) for(int i=0;i= 1) for(int i=0;i