Added auto Recalibration

This commit is contained in:
2022-05-15 18:40:55 +02:00
parent e9c962b4b7
commit 1249ccafec

View File

@@ -261,7 +261,10 @@ void joystickButtonPress(){
} }
void Autoplay(){ void Autoplay(){
if(autoplayLoop+1 >= sizeof(autoplayPos)/sizeof(autoplayPos[0])) autoplayLoop = 0; if(autoplayLoop+1 >= sizeof(autoplayPos)/sizeof(autoplayPos[0])) {
autoplayLoop = 0;
calibrateMiddle();
}
if(autoplayStart) { if(autoplayStart) {
autoplayStart = false; autoplayStart = false;
@@ -308,8 +311,14 @@ void loop(){
if(joystick_LX == 0 && joystick_LY == 0 && joystick_RX == 0 && joystick_RY == 0){ if(joystick_LX == 0 && joystick_LY == 0 && joystick_RX == 0 && joystick_RY == 0){
noTone(BuzzerPin); noTone(BuzzerPin);
if (TimeToAutoplay > offtime)
offtime++; if (TimeToAutoplay > offtime) offtime++;
if(offtime >= TimeToAutoplay) {
Autoplay();
} else if(offtime == TimeToDetach){
detachAttach(true);
}
} }
else{ else{
offtime = 0; offtime = 0;
@@ -365,13 +374,6 @@ void loop(){
servoWrite(); servoWrite();
} }
if(offtime >= TimeToAutoplay){
Autoplay();
}
else if(offtime >= TimeToDetach){
detachAttach(true);
}
if(digitalRead(joystick_button_Pin) == LOW){ if(digitalRead(joystick_button_Pin) == LOW){
detachAttach(true); detachAttach(true);
joystickButtonPress(); joystickButtonPress();