Skip to content

Commit

Permalink
revised rpio imports, rm i2c-bus lib, updated tscconfig, ren interrup…
Browse files Browse the repository at this point in the history
…t-handler.ts,
  • Loading branch information
ros2jsguy committed Aug 23, 2021
1 parent 9d2f8e7 commit e826ff7
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 223 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ TypeScript example code:
```javascript
import { MPU6050} from "../mpu6050";
import { Utils } from "../utils";
import { InterruptMonitor } from "../interrupt-handler";
import { InterruptMonitor } from "../interrupt-monitor";

const GPIO_MPU6050_DATA_PIN = 18;

Expand Down
25 changes: 11 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"scripts": {
"build": "tsc",
"lint": "eslint --ext .ts --format=pretty .",
"calibrate": "sudo node dist/"
"calibrate": "node dist/calibrate.js"
},
"dependencies": {
"onoff": "^6.0.3",
Expand All @@ -38,7 +38,7 @@
"three-math-ts": "^0.127.1"
},
"devDependencies": {
"@types/i2c-bus": "^5.1.0",
"@tsconfig/node12": "^1.0.9",
"@types/node": "^12.20.7",
"@types/rpio": "^2.4.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",
Expand Down
2 changes: 1 addition & 1 deletion src/examples/dmp-example.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { performance } from "perf_hooks";
import { MPU6050} from "../mpu6050";
import { Utils } from "../utils";
import { InterruptMonitor } from "../interrupt-handler";
import { InterruptMonitor } from "../interrupt-monitor";

const GPIO_MPU6050_DATA_PIN = 18;

Expand Down
193 changes: 0 additions & 193 deletions src/i2c/i2c-bus-i2c-helper.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/interrupt-handler.ts → src/interrupt-monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import EventEmitter = require("events");

const { Gpio } = require('onoff').Gpio; // eslint-disable-line
import { Gpio } from 'onoff'; // eslint-disable-line

/**
* Monitor a GPIO pin and emit a 'data' event with the pin
Expand Down
2 changes: 1 addition & 1 deletion src/mpu6050.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import printf = require('printf');
import { Euler, Quaternion, Vector3 } from 'three-math-ts';
import {I2CHelper} from './i2c-helper';
import { RpioI2CHelper } from './i2c/rpio-i2c-helper';
import { RpioI2CHelper } from './rpio-i2c-helper';
import { Utils } from './utils';

export { Euler, Quaternion, Vector3 } from 'three-math-ts';
Expand Down
8 changes: 4 additions & 4 deletions src/i2c/rpio-i2c-helper.ts → src/rpio-i2c-helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as rpio from 'rpio';
import { I2CHelper } from '../i2c-helper';
import {Register} from '../mpu6050';
import rpio = require('rpio');
import { I2CHelper } from './i2c-helper';
import {Register} from './mpu6050';

const DEFAULT_REGBUF_SZ = 4;
const DEFAULT_DATABUF_SZ = 42;
Expand All @@ -22,6 +22,7 @@ export class RpioI2CHelper implements I2CHelper {
constructor(baudRate: number, regBufferSize = DEFAULT_REGBUF_SZ, dataBufferSize = DEFAULT_DATABUF_SZ) {
// configure RPIO
// TODO - i2c should be setup/shutdown externally as i2c may have multiple slave devices
console.log('rpio:', rpio, "\n", rpio.i2cBegin);
rpio.i2cBegin();
rpio.i2cSetBaudRate(baudRate);

Expand All @@ -34,7 +35,6 @@ export class RpioI2CHelper implements I2CHelper {
rpio.i2cEnd();
}


/** Read a single bit from an 8-bit device register.
* @param deviceAddr I2C slave device address
* @param regAddr Register regAddr to read from
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as rpio from 'rpio';
import rpio = require('rpio');
import {MathUtils} from 'three-math-ts'

export namespace Utils {
Expand Down
8 changes: 3 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{
"extends": "@tsconfig/node12/tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es2019",
"lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"rootDir": "./src"
},
"exclude": [
"**/dist/**",
"**/test/**"]
]
}

0 comments on commit e826ff7

Please sign in to comment.