summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-17 16:46:03 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-06-17 16:46:33 +0200
commitf5781e50ee0a371b6198967a82630aabfd493d32 (patch)
tree0f0ed1fa967714cd53650b021ad266d98f7721af
parent7b9502e3f41dc2d3f42a85ce65205080227efe12 (diff)
downloadcode-f5781e50ee0a371b6198967a82630aabfd493d32.tar.gz
Fix off-by-one in turret sequence calculationHEADmaster
-rw-r--r--Venus_Skeleton/Venus_Skeleton.ino4
1 files 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;
}