forked from upstream-mirrors/OpenTracks
Revision comments for rev 5bcaab17e76f addressed.
This commit is contained in:
@@ -48,13 +48,13 @@ public class StrideReadings {
|
|||||||
// TODO: Calibrate this using a reliable footpod / cadence sensor,
|
// TODO: Calibrate this using a reliable footpod / cadence sensor,
|
||||||
// otherwise use heartbeat timestamp for calculation.
|
// otherwise use heartbeat timestamp for calculation.
|
||||||
strideReadingsHistory.add(0, numStrides);
|
strideReadingsHistory.add(0, numStrides);
|
||||||
while(strideReadingsHistory.size() > NUM_READINGS_FOR_AVERAGE) {
|
while (strideReadingsHistory.size() > NUM_READINGS_FOR_AVERAGE) {
|
||||||
strideReadingsHistory.remove(strideReadingsHistory.size()-1);
|
strideReadingsHistory.remove(strideReadingsHistory.size()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCadence() {
|
public int getCadence() {
|
||||||
if(strideReadingsHistory.size() < MIN_READINGS_FOR_AVERAGE) {
|
if (strideReadingsHistory.size() < MIN_READINGS_FOR_AVERAGE) {
|
||||||
// Bail out if we cannot really get a meaningful average yet.
|
// Bail out if we cannot really get a meaningful average yet.
|
||||||
return CADENCE_NOT_AVAILABLE;
|
return CADENCE_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -76,8 +76,8 @@ public class ZephyrMessageParser implements MessageParser {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cadence
|
cadence
|
||||||
.setValue(SensorUtils.unsignedShortToIntLittleEndian(buffer, 56) / 16)
|
.setValue(SensorUtils.unsignedShortToIntLittleEndian(buffer, 56) / 16)
|
||||||
.setState(Sensor.SensorState.SENDING);
|
.setState(Sensor.SensorState.SENDING);
|
||||||
}
|
}
|
||||||
sds.setCadence(cadence);
|
sds.setCadence(cadence);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -30,7 +30,7 @@ public class StrideReadingsTest extends TestCase {
|
|||||||
public void testAverageCadenceAvailable() {
|
public void testAverageCadenceAvailable() {
|
||||||
StrideReadings strideReadings = new StrideReadings();
|
StrideReadings strideReadings = new StrideReadings();
|
||||||
// 2 steps / second => Cadence is 120 / minute
|
// 2 steps / second => Cadence is 120 / minute
|
||||||
for (int i=1;i<=30;i++) {
|
for (int i = 1; i <= 30; i++) {
|
||||||
strideReadings.updateStrideReading(i*2);
|
strideReadings.updateStrideReading(i*2);
|
||||||
if (i >= StrideReadings.MIN_READINGS_FOR_AVERAGE) {
|
if (i >= StrideReadings.MIN_READINGS_FOR_AVERAGE) {
|
||||||
assertEquals(120, strideReadings.getCadence());
|
assertEquals(120, strideReadings.getCadence());
|
||||||
@@ -51,7 +51,7 @@ public class StrideReadingsTest extends TestCase {
|
|||||||
// initialStrides set to a value below 128 to ensure rollover.
|
// initialStrides set to a value below 128 to ensure rollover.
|
||||||
int initialStrides = 128 - StrideReadings.NUM_READINGS_FOR_AVERAGE - 5;
|
int initialStrides = 128 - StrideReadings.NUM_READINGS_FOR_AVERAGE - 5;
|
||||||
|
|
||||||
for (int i=1;i<=StrideReadings.NUM_READINGS_FOR_AVERAGE+10;i++) {
|
for (int i = 1; i <= StrideReadings.NUM_READINGS_FOR_AVERAGE + 10; i++) {
|
||||||
strideReadings.updateStrideReading((initialStrides + i) % 128);
|
strideReadings.updateStrideReading((initialStrides + i) % 128);
|
||||||
if (i >= StrideReadings.MIN_READINGS_FOR_AVERAGE) {
|
if (i >= StrideReadings.MIN_READINGS_FOR_AVERAGE) {
|
||||||
assertEquals(60, strideReadings.getCadence());
|
assertEquals(60, strideReadings.getCadence());
|
||||||
|
|||||||
Reference in New Issue
Block a user