Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM: Bump @johntalton/and-other-delights from 3.0.2 to 8.3.0 #239

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
@@ -5,7 +5,7 @@
"main": "src/ina219.js",
"dependencies": {},
"devDependencies": {
"@johntalton/and-other-delights": "^3.0.2",
"@johntalton/and-other-delights": "^8.3.0",
"csv-writer": "^1.0.0",
"eslint": "^8.30.0",
"eslint-plugin-fp": "^2.3.0",

Unchanged files with check annotations Beta

const Units = require('./units.js');

Check failure on line 1 in src/calibration.js

GitHub Actions / Build

This module could be parsed as a valid script

Check failure on line 1 in src/calibration.js

GitHub Actions / Build

Expected "import" instead of "require()"

Check failure on line 1 in src/calibration.js

GitHub Actions / Build

Unexpected use of file extension "js" for "./units.js"

Check failure on line 1 in src/calibration.js

GitHub Actions / Build

This module could be parsed as a valid script

Check failure on line 1 in src/calibration.js

GitHub Actions / Build

Expected "import" instead of "require()"

Check failure on line 1 in src/calibration.js

GitHub Actions / Build

Unexpected use of file extension "js" for "./units.js"
const Chip = require('./chip.js');

Check failure on line 2 in src/calibration.js

GitHub Actions / Build

Expected "import" instead of "require()"

Check failure on line 2 in src/calibration.js

GitHub Actions / Build

Unexpected use of file extension "js" for "./chip.js"

Check failure on line 2 in src/calibration.js

GitHub Actions / Build

Expected "import" instead of "require()"

Check failure on line 2 in src/calibration.js

GitHub Actions / Build

Unexpected use of file extension "js" for "./chip.js"
/**
*
**/
class Calibration {

Check warning on line 7 in src/calibration.js

GitHub Actions / Build

Unallowed use of `class`. Use functions instead

Check warning on line 7 in src/calibration.js

GitHub Actions / Build

Unallowed use of `class`. Use functions instead
// equation 1 from spec
static maxPossibleCurrent_A(brng, pg, rshuntOhm) {
const vshuntMax = Calibration.pgToGainVoltage(pg);
return vshuntMax.V / (rshuntOhm * 1.0);

Check failure on line 11 in src/calibration.js

GitHub Actions / Build

use `Number(rshuntOhm)` instead

Check warning on line 11 in src/calibration.js

GitHub Actions / Build

No magic number: 1.0

Check failure on line 11 in src/calibration.js

GitHub Actions / Build

use `Number(rshuntOhm)` instead

Check warning on line 11 in src/calibration.js

GitHub Actions / Build

No magic number: 1.0
}
// equation 2/3 from spec
static lsbMin_A(A) { return A / (Math.pow(2, 15) - 1); }

Check warning on line 15 in src/calibration.js

GitHub Actions / Build

No magic number: 2

Check warning on line 15 in src/calibration.js

GitHub Actions / Build

No magic number: 15

Check warning on line 15 in src/calibration.js

GitHub Actions / Build

No magic number: 1

Check warning on line 15 in src/calibration.js

GitHub Actions / Build

No magic number: 2

Check warning on line 15 in src/calibration.js

GitHub Actions / Build

No magic number: 15

Check warning on line 15 in src/calibration.js

GitHub Actions / Build

No magic number: 1
static lsbMax_A(A) { return A / Math.pow(2, 12); }

Check warning on line 16 in src/calibration.js

GitHub Actions / Build

No magic number: 2

Check warning on line 16 in src/calibration.js

GitHub Actions / Build

No magic number: 12

Check warning on line 16 in src/calibration.js

GitHub Actions / Build

No magic number: 2

Check warning on line 16 in src/calibration.js

GitHub Actions / Build

No magic number: 12
static lsbRange_A(A) {
return { min: Calibration.lsbMin_A(A), max: Calibration.lsbMax_A(A) };
}
// equation 6 - reverse equation 2
static maxAFromCurrentLSB_A(currentLSB_A) { return currentLSB_A * (Math.pow(2, 15) - 1); }

Check warning on line 22 in src/calibration.js

GitHub Actions / Build

This line has a length of 92. Maximum allowed is 80

Check warning on line 22 in src/calibration.js

GitHub Actions / Build

No magic number: 2

Check warning on line 22 in src/calibration.js

GitHub Actions / Build

No magic number: 15

Check warning on line 22 in src/calibration.js

GitHub Actions / Build

This line has a length of 92. Maximum allowed is 80

Check warning on line 22 in src/calibration.js

GitHub Actions / Build

No magic number: 2

Check warning on line 22 in src/calibration.js

GitHub Actions / Build

No magic number: 15
// equation 4 from spec
static fromCurrentLSB_A(currentLSB_A, rshunt_ohm) {
}
// helper
static pgToGainVoltage(pg) {

Check failure on line 42 in src/calibration.js

GitHub Actions / Build

Function must end with a return statement, so that it doesn't return `undefined`

Check failure on line 42 in src/calibration.js

GitHub Actions / Build

Function must end with a return statement, so that it doesn't return `undefined`
const stepmV = 40; // 40 mV
switch(pg) {
case Chip.PG.GAIN_1: return { gain: 1, mV: 1 * stepmV, V: Units.mVtoV(stepmV) };

Check failure on line 45 in src/calibration.js

GitHub Actions / Build

use `Number(stepmV)` instead

Check failure on line 45 in src/calibration.js

GitHub Actions / Build

use `Number(stepmV)` instead
case Chip.PG.GAIN_2: return { gain: 2, mV: 2 * stepmV, V: Units.mVtoV(2 * stepmV) };
case Chip.PG.GAIN_4: return { gain: 4, mV: 4 * stepmV, V: Units.mVtoV(4 * stepmV) };
case Chip.PG.GAIN_8: return { gain: 8, mV: 8 * stepmV, V: Units.mVtoV(8 * stepmV) };
}
// helper
static brngToVoltage(brng) {

Check failure on line 54 in src/calibration.js

GitHub Actions / Build

Function must end with a return statement, so that it doesn't return `undefined`

Check failure on line 54 in src/calibration.js

GitHub Actions / Build

Function must end with a return statement, so that it doesn't return `undefined`
switch(brng) {
case Chip.BRNG.BUS_32: return 32;
case Chip.BRNG.BUS_16: return 16;
static infoFrom(expected_A, brng, pg, rshunt_ohm) {
const cfg_device_max_A = Calibration.maxPossibleCurrent_A(brng, pg, rshunt_ohm);
const fullrange = Calibration.lsbRange_A(cfg_device_max_A);

Check failure on line 64 in src/calibration.js

GitHub Actions / Build

'fullrange' is assigned a value but never used

Check failure on line 64 in src/calibration.js

GitHub Actions / Build

'fullrange' is assigned a value but never used
const clipped_A = Math.min(expected_A, cfg_device_max_A);
const range = Calibration.lsbRange_A(clipped_A);