From c53a530e472c7d1becd5a2de3c55d2ced3b6e310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Ortega?= Date: Wed, 23 Sep 2020 20:39:42 +0200 Subject: [PATCH] Revert "tiltTarget type" This reverts commit fdbd788514a6a46b471c78d1f03460ea47aacbb2. --- .gitignore | 1 - src/main/tracker/main.c | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a348f72..1b0c5c4 100755 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,3 @@ README.pdf /Release/ /Debug/ /makeall.sh -src/main/telemetry/mavlink_v1.zip diff --git a/src/main/tracker/main.c b/src/main/tracker/main.c index f06c08a..673bfa5 100755 --- a/src/main/tracker/main.c +++ b/src/main/tracker/main.c @@ -158,11 +158,12 @@ void servosInit(void); //EASING int16_t _lastTilt; +int16_t tilt; bool _servo_tilt_has_arrived = true; uint8_t _tilt_pos = 0; float _servo_tilt_must_move = -1; float easingout = 0.0f; -uint8_t tiltTarget = 0; +float tiltTarget; //TIMER/CALIB unsigned long time; @@ -497,7 +498,7 @@ void calcTilt(void) { targetPosition.distance = 1; } - tiltTarget = (uint8_t)toDeg(atan((float)(targetPosition.alt - trackerPosition.alt) / targetPosition.distance)); + tiltTarget = toDeg(atan((float)(targetPosition.alt - trackerPosition.alt) / targetPosition.distance)); if (tiltTarget < 0) tiltTarget = 0; @@ -508,13 +509,13 @@ void calcTilt(void) { if(feature(FEATURE_EASING)) { if(_servo_tilt_has_arrived){ - _servo_tilt_must_move = (float)tiltTarget; + _servo_tilt_must_move = tiltTarget; _servo_tilt_has_arrived = false; _tilt_pos = 0; } } else { - pwmTilt = (uint16_t) map((uint16_t)tiltTarget,0,90,masterConfig.tilt0, masterConfig.tilt90); + pwmTilt = (uint16_t) map(tiltTarget,0,90,masterConfig.tilt0, masterConfig.tilt90); pwmWriteServo(masterConfig.tilt_pin,pwmTilt); } } @@ -776,8 +777,11 @@ void updateServoTest(void){ _servo_tilt_must_move = SERVOTEST_TILT; _servo_tilt_has_arrived = false; } - pwmTilt = map((uint16_t)SERVOTEST_TILT, 0, 90, masterConfig.tilt0, masterConfig.tilt90); - pwmWriteServo(masterConfig.tilt_pin,pwmTilt); + else + { + tilt = map(SERVOTEST_TILT, 0, 90, masterConfig.tilt0, masterConfig.tilt90); + pwmWriteServo(masterConfig.tilt_pin,tilt); + } DISABLE_SERVO(SERVOTILT_MOVE); } }