mirror of
https://github.com/kou029w/megabit.git
synced 2025-02-07 17:38:37 +00:00
22 lines
528 B
TypeScript
22 lines
528 B
TypeScript
|
import Device from "@chirimen/veml6070";
|
||
|
import { ReadableDevice } from "./Device";
|
||
|
import { I2CPort, i2c } from "./i2c";
|
||
|
|
||
|
/** @type UVA (μW/cm^2) */
|
||
|
type UVA = number;
|
||
|
|
||
|
/** slave addresses are 0x38 and 0x39 */
|
||
|
export function veml6070(bus: I2CPort = i2c()): ReadableDevice<number> {
|
||
|
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;
|