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
|
|
|
|
2021-07-24 23:36:22 +09:00
|
|
|
/** UVA (μW/cm^2) */
|
|
|
|
export type UVA = number;
|
2020-02-07 12:34:43 +09:00
|
|
|
|
|
|
|
/** 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();
|
2021-07-24 23:28:23 +09:00
|
|
|
},
|
2020-02-07 12:34:43 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default veml6070;
|