@name-industry/ni-ina219
Version:
Module for using the WaveShare UPS Raspberry Pi Hat that has an embedded Texas Instruments INA219 sensor.
36 lines (31 loc) • 903 B
JavaScript
// V@ts-check <- has problems with 'this' in the init method for some reason
/**
* @class Current
*
* @summary
* Current Actions
*
* @description
* Actions for the Current register on the INA219
*/
import CurrentModel from "../../Domain/Current/Model/index.js";
import CurrentService from "../../Domain/Current/Service/index.js";
class Current {
constructor() { };
getCurrent = async function (currentLSB) {
let readResult = await CurrentService.readRegister();
if (readResult.success === true) {
CurrentModel.hydrate(readResult.data, "en", true, {
currentLSB: currentLSB
});
return {
success: true,
msg: "Power",
data: CurrentModel.getCurrentValues()
}
} else {
return readResult;
}
}
}
export default new Current();