openi2c
Version:
This library is a set of cross platform drivers for common I2C devices.
34 lines (33 loc) • 1.53 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const MPU9250_1 = require("./MPU9250");
function main() {
return __awaiter(this, void 0, void 0, function* () {
const mpu = new MPU9250_1.mpu9250({
DEBUG: true,
// scaleValues: true,
UpMagneto: true,
DLPF_CFG: MPU9250_1.MPU9250.DLPF_CFG_3600HZ,
// Set Accel DLPF Value
A_DLPF_CFG: MPU9250_1.MPU9250.A_DLPF_CFG_460HZ,
SAMPLE_RATE: 8000,
});
yield mpu.initialize();
setInterval(() => __awaiter(this, void 0, void 0, function* () {
const motion = yield mpu.getMotion9();
const roll = mpu.getRoll(motion);
const pitch = mpu.getPitch(motion);
console.log(roll, pitch);
}), 1000);
});
}
main();