1
0
Fork 0
mirror of https://github.com/kou029w/megabit.git synced 2025-02-07 17:38:37 +00:00
megabit/src/veml6070.ts

22 lines
520 B
TypeScript
Raw Normal View History

2020-02-07 12:34:43 +09:00
import Device from "@chirimen/veml6070";
import { ReadableDevice } from "./Device";
2020-02-07 13:58:09 +09:00
import { I2C, i2c } from "./i2c";
2020-02-07 12:34:43 +09:00
/** @type UVA (μW/cm^2) */
type UVA = number;
/** slave addresses are 0x38 and 0x39 */
2020-02-07 13:58:09 +09:00
export function veml6070(bus: I2C = i2c()): ReadableDevice<number> {
2020-02-07 12:34:43 +09:00
const device = new Device(bus);
return {
async read(): Promise<UVA> {
if (device.i2cSlaveLSB == null || device.i2cSlaveMSB == null)
await device.init();
return device.read();
}
};
}
export default veml6070;