Mercurial > tote
changeset 197:1a9747e0e2d7 veverak/servosino-edited-no-need-for-minmax-magi-1450691089896
servos.ino edited, no need for min/max magic with constrain :)
| author | Jan Koniarik <squirrelcze@gmail.com> |
|---|---|
| date | Mon, 21 Dec 2015 09:44:51 +0000 |
| parents | e70d0fba0fc9 |
| children | ebcabf0863dc |
| files | i2cslave/servos.ino |
| diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/i2cslave/servos.ino Sat Nov 21 16:54:40 2015 +0100 +++ b/i2cslave/servos.ino Mon Dec 21 09:44:51 2015 +0000 @@ -65,9 +65,9 @@ } int freq = (SERVO_FREQ_MAX - SERVO_FREQ_MIN) * rads / PI + SERVO_FREQ_MIN; - freq = min(SERVO_FREQ_MAX, - max(SERVO_FREQ_MIN, - freq + SERVO_TRIM[servo] * 10)); + freq = constrain(freq + SERVO_TRIM[servo]*10, SERVO_FREQ_MIN, + SERVO_FREQ_MAX); + servos[servo].writeMicroseconds(freq); }
