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