Mercurial > ukubik
changeset 72:6be60d8eb0a2
Do reversing on arduino side
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Wed, 10 Sep 2014 21:00:25 +0200 |
| parents | d4356df0be42 |
| children | d944b23935e4 |
| files | servo/servo.ino |
| diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/servo/servo.ino Wed Sep 10 20:37:27 2014 +0200 +++ b/servo/servo.ino Wed Sep 10 21:00:25 2014 +0200 @@ -40,13 +40,13 @@ {1, -50}, // front right {-1, 0}, // front left {1, -50}, // hind left - {-1, 50}, // hind right + {-1, -50}, // hind right // knees {1, -70}, - {-1, -50}, + {-1, 50}, {1, 30}, - {-1, -50}, + {-1, 50}, // hips {-1, 0}, @@ -90,8 +90,10 @@ } void servo_write(int servo, int us) { - int trim = joints[servo][1]; - int pos = min(max(us + trim, SERVO_FREQ_MIN), SERVO_FREQ_MAX); + int pos = min(max(us + joints[servo][1], SERVO_FREQ_MIN), SERVO_FREQ_MAX); + if (joints[servo][0] < 0) { + pos = SERVO_FREQ_MAX + SERVO_FREQ_MIN - pos; + } servos[servo].writeMicroseconds(pos); }
