openi2c
Version:
This library is a set of cross platform drivers for common I2C devices.
113 lines (112 loc) • 6.76 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AVAIL_SENSOR_REPORTS = exports.RAW_REPORTS = exports.Q_POINT_4_SCALAR = exports.Q_POINT_8_SCALAR = exports.Q_POINT_9_SCALAR = exports.Q_POINT_12_SCALAR = exports.Q_POINT_14_SCALAR = exports.ME_GET_CAL = exports.ME_CAL_CONFIG = exports.ME_CALIBRATE = exports.SAVE_DCD = exports.QUAT_Q_POINT = exports.BNO08X_CMD_RESET = exports.DEFAULT_TIMEOUT = exports.FEATURE_ENABLE_TIMEOUT = exports.PACKET_READ_TIMEOUT = exports.QUAT_READ_TIMEOUT = exports.DEFAULT_REPORT_INTERVAL = exports.COMMAND_RESPONSE = exports.COMMAND_REQUEST = exports.TIMESTAMP_REBASE = exports.BASE_TIMESTAMP = exports.GET_FEATURE_RESPONSE = exports.SET_FEATURE_COMMAND = exports.GET_FEATURE_REQUEST = exports.SHTP_REPORT_PRODUCT_ID_REQUEST = exports.SHTP_REPORT_PRODUCT_ID_RESPONSE = exports.BNO_REPORT_GYRO_INTEGRATED_ROTATION_VECTOR = exports.BNO_REPORT_ACTIVITY_CLASSIFIER = exports.BNO_REPORT_STABILITY_CLASSIFIER = exports.BNO_REPORT_SHAKE_DETECTOR = exports.BNO_REPORT_RAW_MAGNETOMETER = exports.BNO_REPORT_RAW_GYROSCOPE = exports.BNO_REPORT_RAW_ACCELEROMETER = exports.BNO_REPORT_STEP_COUNTER = exports.BNO_REPORT_GEOMAGNETIC_ROTATION_VECTOR = exports.BNO_REPORT_GAME_ROTATION_VECTOR = exports.BNO_REPORT_GRAVITY = exports.BNO_REPORT_ROTATION_VECTOR = exports.BNO_REPORT_LINEAR_ACCELERATION = exports.BNO_REPORT_MAGNETOMETER = exports.BNO_REPORT_GYROSCOPE = exports.BNO_REPORT_ACCELEROMETER = exports.BNO_HEADER_LEN = exports.BNO_CHANNEL_GYRO_ROTATION_VECTOR = exports.BNO_CHANNEL_WAKE_INPUT_SENSOR_REPORTS = exports.BNO_CHANNEL_INPUT_SENSOR_REPORTS = exports.BNO_CHANNEL_CONTROL = exports.BNO_CHANNEL_EXE = exports.BNO_CHANNEL_SHTP_COMMAND = void 0;
exports.ENABLED_ACTIVITIES = exports.INITIAL_REPORTS = exports.REPORT_LENGTHS = void 0;
exports.BNO_CHANNEL_SHTP_COMMAND = 0;
exports.BNO_CHANNEL_EXE = 1;
exports.BNO_CHANNEL_CONTROL = 2;
exports.BNO_CHANNEL_INPUT_SENSOR_REPORTS = 3;
exports.BNO_CHANNEL_WAKE_INPUT_SENSOR_REPORTS = 4;
exports.BNO_CHANNEL_GYRO_ROTATION_VECTOR = 5;
exports.BNO_HEADER_LEN = 4;
// Calibrated Acceleration (m/s2)
exports.BNO_REPORT_ACCELEROMETER = 0x01;
// Calibrated gyroscope (rad/s).
exports.BNO_REPORT_GYROSCOPE = 0x02;
// Magnetic field calibrated (in µTesla). The fully calibrated magnetic field measurement.
exports.BNO_REPORT_MAGNETOMETER = 0x03;
// Linear acceleration (m/s2). Acceleration of the device with gravity removed
exports.BNO_REPORT_LINEAR_ACCELERATION = 0x04;
// Rotation Vector
exports.BNO_REPORT_ROTATION_VECTOR = 0x05;
// Gravity Vector (m/s2). Vector direction of gravity
exports.BNO_REPORT_GRAVITY = 0x06;
// Game Rotation Vector
exports.BNO_REPORT_GAME_ROTATION_VECTOR = 0x08;
exports.BNO_REPORT_GEOMAGNETIC_ROTATION_VECTOR = 0x09;
exports.BNO_REPORT_STEP_COUNTER = 0x11;
exports.BNO_REPORT_RAW_ACCELEROMETER = 0x14;
exports.BNO_REPORT_RAW_GYROSCOPE = 0x15;
exports.BNO_REPORT_RAW_MAGNETOMETER = 0x16;
exports.BNO_REPORT_SHAKE_DETECTOR = 0x19;
exports.BNO_REPORT_STABILITY_CLASSIFIER = 0x13;
exports.BNO_REPORT_ACTIVITY_CLASSIFIER = 0x1E;
exports.BNO_REPORT_GYRO_INTEGRATED_ROTATION_VECTOR = 0x2A; // TODO Should this be added to the list of available reports?
exports.SHTP_REPORT_PRODUCT_ID_RESPONSE = 0xF8;
exports.SHTP_REPORT_PRODUCT_ID_REQUEST = 0xF9;
exports.GET_FEATURE_REQUEST = 0xFE;
exports.SET_FEATURE_COMMAND = 0xFD;
exports.GET_FEATURE_RESPONSE = 0xFC;
exports.BASE_TIMESTAMP = 0xFB;
exports.TIMESTAMP_REBASE = 0xFA;
exports.COMMAND_REQUEST = 0xF2;
exports.COMMAND_RESPONSE = 0xF1;
exports.DEFAULT_REPORT_INTERVAL = 50000; // in microseconds = 50ms
exports.QUAT_READ_TIMEOUT = 500; // timeout in ms
exports.PACKET_READ_TIMEOUT = 2000; // timeout in ms
exports.FEATURE_ENABLE_TIMEOUT = 2000; // timeout in ms
exports.DEFAULT_TIMEOUT = 2.0;
exports.BNO08X_CMD_RESET = 0x01;
exports.QUAT_Q_POINT = 14;
// DCD/ ME Calibration commands and sub-commands
exports.SAVE_DCD = 0x6;
exports.ME_CALIBRATE = 0x7;
exports.ME_CAL_CONFIG = 0x00;
exports.ME_GET_CAL = 0x01;
exports.Q_POINT_14_SCALAR = 2 ** (14 * -1);
exports.Q_POINT_12_SCALAR = 2 ** (12 * -1);
//export const Q_POINT_10_SCALAR = 2 ** (10 * -1)
exports.Q_POINT_9_SCALAR = 2 ** (9 * -1);
exports.Q_POINT_8_SCALAR = 2 ** (8 * -1);
exports.Q_POINT_4_SCALAR = 2 ** (4 * -1);
// these raw reports require their counterpart to be enabled
exports.RAW_REPORTS = {
[]: exports.BNO_REPORT_ACCELEROMETER,
[]: exports.BNO_REPORT_GYROSCOPE,
[]: exports.BNO_REPORT_MAGNETOMETER,
};
exports.AVAIL_SENSOR_REPORTS = {
[]: [exports.Q_POINT_8_SCALAR, 3, 10],
[]: [exports.Q_POINT_8_SCALAR, 3, 10],
[]: [exports.Q_POINT_9_SCALAR, 3, 10],
[]: [exports.Q_POINT_4_SCALAR, 3, 10],
[]: [exports.Q_POINT_8_SCALAR, 3, 10],
[]: [exports.Q_POINT_14_SCALAR, 4, 14],
[]: [exports.Q_POINT_12_SCALAR, 4, 14],
[]: [exports.Q_POINT_14_SCALAR, 4, 12],
[]: [1, 1, 12],
[]: [1, 1, 6],
[]: [1, 1, 6],
[]: [1, 1, 16],
[]: [1, 3, 16],
[]: [1, 3, 16],
[]: [1, 3, 16],
};
exports.REPORT_LENGTHS = {
[]: 16,
// [SHTP_REPORT_PRODUCT_ID_REQUEST]: 16, // This wasn't here in the original code, but it seems like it should be because the origional duplicate SHTP_REPORT_PRODUCT_ID_RESPONSE, not sure if the value is correct.
[]: 17,
[]: 16,
[]: 5,
[]: 5,
};
exports.INITIAL_REPORTS = {
[]: {
"Tilting": -1,
"most_likely": "Unknown",
"OnStairs": -1,
"On-Foot": -1,
"Other": -1,
"On-Bicycle": -1,
"Still": -1,
"Walking": -1,
"Unknown": -1,
"Running": -1,
"In-Vehicle": -1,
},
[]: "Unknown",
[]: [0.0, 0.0, 0.0, 0.0],
[]: [0.0, 0.0, 0.0, 0.0],
[]: [0.0, 0.0, 0.0, 0.0],
};
exports.ENABLED_ACTIVITIES = 0x1FF; // All activities; 1 bit set for each of 8 activities, + Unknown