Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@garmin/fitsdk",
"version": "21.169.0",
"version": "21.170.0",
"description": "FIT JavaScript SDK",
"main": "src/index.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions src/accumulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.169.0Release
// Tag = production/release/21.169.0-0-g7105132
// Profile Version = 21.170.0Release
// Tag = production/release/21.170.0-0-g5991e72
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/bit-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.169.0Release
// Tag = production/release/21.169.0-0-g7105132
// Profile Version = 21.170.0Release
// Tag = production/release/21.170.0-0-g5991e72
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/crc-calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.169.0Release
// Tag = production/release/21.169.0-0-g7105132
// Profile Version = 21.170.0Release
// Tag = production/release/21.170.0-0-g5991e72
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.169.0Release
// Tag = production/release/21.169.0-0-g7105132
// Profile Version = 21.170.0Release
// Tag = production/release/21.170.0-0-g5991e72
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
20 changes: 15 additions & 5 deletions src/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.169.0Release
// Tag = production/release/21.169.0-0-g7105132
// Profile Version = 21.170.0Release
// Tag = production/release/21.170.0-0-g5991e72
/////////////////////////////////////////////////////////////////////////////////////////////


Expand All @@ -20,6 +20,9 @@ import Utils from "./utils.js";
const HEADER_WITH_CRC_SIZE = 14;
const HEADER_WITHOUT_CRC_SIZE = 12;

const FIELD_DEFAULT_SCALE = 1;
const FIELD_DEFAULT_OFFSET = 0;

/**
* A class for encoding FIT files.
* @class
Expand Down Expand Up @@ -212,10 +215,17 @@ class Encoder {
throw new Error();
}

const scale = fieldDefinition.components.length > 1 ? 1 : fieldDefinition.scale;
const offset = fieldDefinition.components.length > 1 ? 0 : fieldDefinition.offset;
const scale = fieldDefinition.components.length > 1 ? FIELD_DEFAULT_SCALE : fieldDefinition.scale;
const offset = fieldDefinition.components.length > 1 ? FIELD_DEFAULT_OFFSET : fieldDefinition.offset;
const hasScaleOrOffset = (scale != FIELD_DEFAULT_SCALE || offset != FIELD_DEFAULT_OFFSET);

if (hasScaleOrOffset) {
const scaledValue = (value + offset) * scale;

return (value + offset) * scale;
return FIT.FloatingPointFieldTypes.includes(fieldDefinition.type) ? scaledValue : Math.round(scaledValue);
}

return value;
}

// Is this a date_time field?
Expand Down
13 changes: 11 additions & 2 deletions src/fit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.169.0Release
// Tag = production/release/21.169.0-0-g7105132
// Profile Version = 21.170.0Release
// Tag = production/release/21.170.0-0-g5991e72
/////////////////////////////////////////////////////////////////////////////////////////////


/**
* FIT Base Type enum
*/
const BaseType = {
ENUM: 0x00,
SINT8: 0x01,
Expand Down Expand Up @@ -68,6 +71,11 @@ const NumericFieldTypes = [
"uint64z"
];

const FloatingPointFieldTypes = [
"float32",
"float64",
];

const FieldTypeToBaseType = {
"enum": BaseType.UINT8,
"sint8": BaseType.SINT8,
Expand Down Expand Up @@ -152,6 +160,7 @@ export default {
BaseType,
BaseTypeDefinitions,
NumericFieldTypes,
FloatingPointFieldTypes,
FieldTypeToBaseType,
BaseTypeToFieldType,
isNullOrUndefined,
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.169.0Release
// Tag = production/release/21.169.0-0-g7105132
// Profile Version = 21.170.0Release
// Tag = production/release/21.170.0-0-g5991e72
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
6 changes: 3 additions & 3 deletions src/mesg-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.169.0Release
// Tag = production/release/21.169.0-0-g7105132
// Profile Version = 21.170.0Release
// Tag = production/release/21.170.0-0-g5991e72
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -147,7 +147,7 @@ class MesgDefinition {
}

equals(other) {
if (this.globalMesgNumber !== other.globalMesgNumber
if (this.globalMessageNumber !== other.globalMessageNumber
|| this.fieldDefinitions.length !== other.fieldDefinitions.length
|| this.developerFieldDefinitions.length !== other.developerFieldDefinitions.length) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/output-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.169.0Release
// Tag = production/release/21.169.0-0-g7105132
// Profile Version = 21.170.0Release
// Tag = production/release/21.170.0-0-g5991e72
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
Loading