Calibrate S300 tail RPM decode
This commit is contained in:
parent
ba578a0b69
commit
c2f92db217
@ -45,8 +45,9 @@ SensorState parseS300(Uint8List frame, {bool validateChecksum = true}) {
|
||||
final bool hasTailPayload = _hasS300TailPayload(frame);
|
||||
final int rpmRaw =
|
||||
hasTailPayload ? _readUint16LE(frame, 82) : _readUint16BE(frame, 2);
|
||||
final double rpm =
|
||||
(hasTailPayload ? rpmRaw : rpmRaw - 256).clamp(0, 12000).toDouble();
|
||||
final double rpm = (hasTailPayload ? rpmRaw - 1089 : rpmRaw - 256)
|
||||
.clamp(0, 12000)
|
||||
.toDouble();
|
||||
|
||||
// VSS: bytes 5..6 little-endian pulse period.
|
||||
final int vssRaw = _readUint16LE(frame, 5);
|
||||
|
||||
@ -190,7 +190,8 @@ void main() {
|
||||
expect(isS300PlaceholderFrame(frame), isTrue);
|
||||
});
|
||||
|
||||
test('uses tail payload RPM for S300 Bluetooth prefix frames', () {
|
||||
test('uses calibrated tail payload RPM for S300 Bluetooth prefix frames',
|
||||
() {
|
||||
final frame = Uint8List(128);
|
||||
final prefix = [
|
||||
0x1B,
|
||||
@ -219,7 +220,7 @@ void main() {
|
||||
frame[127] = calculateNeg8(frame.sublist(0, 127));
|
||||
|
||||
final state = parseS300(frame);
|
||||
expect(state.rpm, equals(3122.0));
|
||||
expect(state.rpm, equals(2033.0));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user