fix ant+ DataPage51 grade field min and max values

- they were set to 0 and 400, which are the values after offset of 200 is
  applied,
- this resulted in grages encoding correctly only in the range 0,200,
- they are now -200 and 200,
This commit is contained in:
dvmarinoff
2022-09-09 10:00:50 +03:00
parent 505db53ce9
commit a5f956763f
2 changed files with 11 additions and 1 deletions

View File

@@ -171,7 +171,7 @@ function DataPage51(args = {}) {
const definitions = {
grade: {
resolution: 0.01, unit: '%', min: 0, max: 400, invalid: 0xFFFF, default: 0, offset: 200
resolution: 0.01, unit: '%', min: -200, max: 200, invalid: 0xFFFF, default: 0, offset: 200
},
crr: {
resolution: 0.00005, unit: '', min: 0, max: 0.0127, invalid: 0xFF, default: 0.004

View File

@@ -137,6 +137,16 @@ describe('Data Page 51 - Track Resistance', () => {
expect(dataviewToArray(msg)).toEqual([51, 0,0,0,0, 176,79, 80]);
});
test('grade 200', () => {
const msg = fec.dataPage51.encode({grade: 200});
expect(dataviewToArray(msg)).toEqual([51, 0,0,0,0, 64,156, 80]);
});
test('grade -200', () => {
const msg = fec.dataPage51.encode({grade: -200});
expect(dataviewToArray(msg)).toEqual([51, 0,0,0,0, 0,0, 80]);
});
test('crr', () => {
const msg = fec.dataPage51.encode({crr: 0.00321});
expect(dataviewToArray(msg)).toEqual([51, 0,0,0,0, 32,78, 64]);