Updated dependencies, Removed bluebird, v2.0.0

parent 1eddd26b
Pipeline #345 failed with stage
in 27 seconds
......@@ -16,17 +16,13 @@ typescript-build:
paths:
- dist/
script:
- npm config set unsafe-perm true
- npm install @types/bluebird@^3.5.8
- npm install @types/i2c-bus@^1.0.9
- npm install @types/node@^12.0.0
- npm ci
- tsc
- tsc --noEmit --lib es6 examples/*.ts
publish-to-npm:
stage: deploy
script:
- npm config set unsafe-perm true
- npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
- npm publish
environment:
......
## v2.0.0
- Updated dependencies
- Removed bluebird
- Minimum Node.js version 6.0.0
## v1.0.1 2020-03-30
- Fixed calculate of negative shunt voltage
## v1.0.0 2017-07-17
- First release
......@@ -17,7 +17,7 @@ For more information about the INA226 please consult the [data sheet from Texas
## Installation
Make sure you are using Node.js v4.5.0 or higher.
Make sure you are using Node.js v6.0.0 or higher.
```
npm install ina226
......@@ -179,4 +179,4 @@ The register addresses are exported as constants.
Licensed under GPL Version 2
Copyright (c) 2017 Peter Müller <peter@crycode.de> (https://crycode.de/)
Copyright (c) 2017-2020 Peter Müller <peter@crycode.de> (https://crycode.de/)
{
"name": "ina226",
"version": "2.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/i2c-bus": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@types/i2c-bus/-/i2c-bus-5.1.0.tgz",
"integrity": "sha512-zBwBpfaFzKtYaS2j/sh+m/zKRcbXuG26/wWlJq3F9+oWXQ9DSxuJXOU+t1PMorj3DBZzpLO8LqbVTGRE1PUb3g==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/node": {
"version": "12.12.32",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.32.tgz",
"integrity": "sha512-44/reuCrwiQEsXud3I5X3sqI5jIXAmHB5xoiyKUw965olNHF3IWKjBLKK3F9LOSUZmK+oDt8jmyO637iX+hMgA==",
"dev": true
},
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
},
"i2c-bus": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/i2c-bus/-/i2c-bus-5.1.0.tgz",
"integrity": "sha512-u/q1fuZ5xrG77y3uo1rAANycboXsRNjneN+6jXRNMT2yRNpanVkbAP+IArwgsPRCHaY/zKxw7x5G8Y2fSPNseA==",
"requires": {
"bindings": "^1.5.0",
"nan": "^2.14.0"
}
},
"nan": {
"version": "2.14.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg=="
},
"typescript": {
"version": "3.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
"integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==",
"dev": true
}
}
}
{
"name": "ina226",
"version": "1.0.1",
"version": "2.0.0",
"description": "Node.js module to read values from the INA226 bi-directional current and power monitor.",
"main": "dist/ina226.js",
"typings": "dist/ina226.d.ts",
......@@ -9,7 +9,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"engines": {
"node": ">=4.5.0"
"node": ">=6.0.0"
},
"keywords": [
"ina226",
......@@ -27,13 +27,11 @@
"url": "https://git.cryhost.de/crycode/node-ina226/issues"
},
"devDependencies": {
"@types/bluebird": "^3.5.8",
"@types/i2c-bus": "^1.0.9",
"@types/node": "^8.0.12",
"typescript": "^2.4.1"
"@types/i2c-bus": "^5.1.0",
"@types/node": "^12.12.32",
"typescript": "^3.8.3"
},
"dependencies": {
"bluebird": "^3.5.0",
"i2c-bus": "^1.2.2"
"i2c-bus": "^5.1.0"
}
}
/*
* Node.js module ina226
*
* Copyright (c) 2017 Peter Müller <peter@crycode.de> (https://crycode.de/)
* Copyright (c) 2017-2020 Peter Müller <peter@crycode.de> (https://crycode.de/)
*
* Node.js module to read values from the INA226 bi-directional current and power monitor.
*/
/// <reference types="node" />
import * as Promise from 'bluebird';
import {I2cBus} from 'i2c-bus';
import { I2CBus } from 'i2c-bus';
/**
* Address of the Configuration Register.
......@@ -75,31 +74,31 @@ export class INA226 {
* Instance of the used i2c-bus object.
* @type {I2cBus}
*/
private _i2cBus:I2cBus;
private _i2cBus: I2CBus;
/**
* The address of the INA226 IC.
* @type {number}
*/
private _address:number;
private _address: number;
/**
* The shunt resistance value in Ohm.
* @type {number}
*/
private _rShunt:number;
private _rShunt: number;
/**
* Last read bus voltage.
* @type {number}
*/
private _busVoltage:number = 0;
private _busVoltage: number = 0;
/**
* Last read shunt voltage.
* @type {number}
*/
private _shuntVoltage:number = 0;
private _shuntVoltage: number = 0;
/**
* Constructor for the power monitor INA226.
......@@ -107,7 +106,7 @@ export class INA226 {
* @param {number} address The address of the INA226 IC.
* @param {number} rShunt The shunt resistance value. Defaults to 0.1 Ohm.
*/
constructor(i2cBus:I2cBus, address:number, rShunt:number=0.1){
constructor(i2cBus: I2CBus, address: number, rShunt: number = 0.1){
this._i2cBus = i2cBus;
this._address = address;
this._rShunt = rShunt;
......@@ -120,13 +119,13 @@ export class INA226 {
* @param {number} value The value. Should be 16bit integer.
* @return {Promise}
*/
public writeRegister(register:number, value:number):Promise<{}>{
public writeRegister(register: number, value: number): Promise<{}>{
let buf = Buffer.alloc(2);
buf[0] = (value >> 8) & 0xff;
buf[1] = value & 0xff;
return new Promise<number>((resolve:()=>void, reject:(err:Error)=>void)=>{
this._i2cBus.writeI2cBlock(this._address, register, 2, buf, (err:any, _bytesWritten:number, _buffer:Buffer)=>{
return new Promise<number>((resolve: ()=>void, reject: (err: Error)=>void)=>{
this._i2cBus.writeI2cBlock(this._address, register, 2, buf, (err: any, _bytesWritten: number, _buffer: Buffer)=>{
if(err){
reject(err);
}else{
......@@ -142,11 +141,11 @@ export class INA226 {
* @param {number} register The register address.
* @return {Promise<number>}
*/
public readRegister(register:number):Promise<number>{
public readRegister(register: number): Promise<number>{
let buf = Buffer.alloc(2);
return new Promise<number>((resolve:(bytesWritten:number)=>void, reject:(err:Error)=>void)=>{
this._i2cBus.readI2cBlock(this._address, register, 2, buf, (err:any, _bytesRead:number, buffer:Buffer)=>{
return new Promise<number>((resolve: (bytesWritten: number)=>void, reject: (err: Error)=>void)=>{
this._i2cBus.readI2cBlock(this._address, register, 2, buf, (err: any, _bytesRead: number, buffer: Buffer)=>{
if(err){
reject(err);
}else{
......@@ -162,9 +161,9 @@ export class INA226 {
* Returns a Promise which will be resolved with the bus voltage, or rejected in case of an error.
* @return {Promise<number>}
*/
public readBusVoltage():Promise<number>{
public readBusVoltage(): Promise<number>{
return this.readRegister(BUS_VOLTAGE_REGISTER)
.then<number>((busVoltage:number)=>{
.then<number>((busVoltage: number)=>{
this._busVoltage = busVoltage * BUS_VOLTAGE_LSB;
return this._busVoltage;
});
......@@ -175,9 +174,9 @@ export class INA226 {
* Returns a Promise which will be resolved with the shunt voltage, or rejected in case of an error.
* @return {Promise<number>}
*/
public readShuntVoltage():Promise<number>{
public readShuntVoltage(): Promise<number>{
return this.readRegister(SHUNT_VOLTAGE_REGISTER)
.then<number>((shuntVoltage:number)=>{
.then<number>((shuntVoltage: number)=>{
// Negative numbers are represented in two's complement format.
// Generate the two's complement of a negative number by complementing
// the absolute value binary number and adding 1.
......@@ -198,7 +197,7 @@ export class INA226 {
* @param {number} shuntVoltage Optional. The shunt voltage which is used for the calculation. Defaults to the last read shunt voltage.
* @return {number} The calculated current in Ampere.
*/
public calcCurrent(shuntVoltage:number = this._shuntVoltage):number{
public calcCurrent(shuntVoltage: number = this._shuntVoltage): number{
return shuntVoltage / this._rShunt;
}
......@@ -208,7 +207,7 @@ export class INA226 {
* @param {number} shuntVoltage Optional. The shunt voltage which is used for the calculation. Defaults to the last read shunt voltage.
* @return {number} The calculated power in Watt.
*/
public calcPower(busVoltage:number = this._busVoltage, shuntVoltage:number = this._shuntVoltage):number{
public calcPower(busVoltage: number = this._busVoltage, shuntVoltage: number = this._shuntVoltage): number{
return busVoltage * shuntVoltage / this._rShunt;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment