From f5781e50ee0a371b6198967a82630aabfd493d32 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 17 Jun 2015 16:46:03 +0200 Subject: Fix off-by-one in turret sequence calculation --- Venus_Skeleton/Venus_Skeleton.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Venus_Skeleton/Venus_Skeleton.ino b/Venus_Skeleton/Venus_Skeleton.ino index 6683a4b..0b366fc 100644 --- a/Venus_Skeleton/Venus_Skeleton.ino +++ b/Venus_Skeleton/Venus_Skeleton.ino @@ -185,13 +185,13 @@ long microsecondsToCentimeters(long microseconds) void initTurretSequence(int array[], int numOfPositions) { // for n=7, fill lower half of array with 0, 2, 4, 6 // for n=8, fill lower half of array with 0, 2, 4, 6 - for (int i = 0; i < numOfPositions / 2; i++) { + for (int i = 0; i < (numOfPositions + 1) / 2; i++) { array[i] = i * 2; } // for n=7, fill upper half of array with 5, 3, 1 // for n=8, fill upper half of array with 7, 5, 3, 1 int x = numOfPositions / 2 * 2 - 1; - for (int i = numOfPositions / 2 + 1; i < numOfPositions; i++) { + for (int i = (numOfPositions + 1) / 2; i < numOfPositions; i++) { array[i] = x; x -= 2; } -- cgit v1.2.1