@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) • 871 B
JavaScript
// V@ts-check <- has problems with 'this' in the init method for some reason
/**
* @class Power
*
* @summary
* Power Actions
*
* @description
* Actions for the Power register on the INA219
*/
import PowerModel from "../../Domain/Power/Model/index.js";
import PowerService from "../../Domain/Power/Service/index.js";
class Power {
constructor() { };
getPower = async function (powerLSB) {
let readResult = await PowerService.readRegister();
if (readResult.success === true) {
PowerModel.hydrate(readResult.data, "en", true, {
powerLSB: powerLSB
});
return {
success: true,
msg: "Power",
data: PowerModel.getCurrentValues()
}
} else {
return readResult;
}
}
}
export default new Power();