From 6baf1013d071da9e754cc896d8b89e75a5ad1424 Mon Sep 17 00:00:00 2001 From: CinePlays Date: Sun, 20 Mar 2022 02:58:10 +0100 Subject: [PATCH 1/2] added typings --- bme280.d.ts | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 61 insertions(+) create mode 100644 bme280.d.ts diff --git a/bme280.d.ts b/bme280.d.ts new file mode 100644 index 0000000..95cf5da --- /dev/null +++ b/bme280.d.ts @@ -0,0 +1,60 @@ +export type options = { + i2cBusNumber?: number, + i2cAddress?: number, + humidityOversampling?: OVERSAMPLE, + pressureOversampling?: OVERSAMPLE, + temperatureOversampling?: OVERSAMPLE, + filterCoefficient?: FILTER, + standby?: STANDBY, + forcedMode?: boolean +} + +export type data = { + temperature: number, + pressure: number, + humidity: number +} + +export enum OVERSAMPLE { + SKIPPED = 0, + X1 = 1, + X2 = 2, + X4 = 3, + X8 = 4, + X16 = 5 +} + +export enum FILTER { + OFF = 0, + F2 = 1, + F4 = 2, + F8 = 3, + F16 = 4 +} + +export enum STANDBY { + MS_0_5 = 0, + MS_62_5 = 1, + MS_125 = 2, + MS_250 = 3, + MS_500 = 4, + MS_1000 = 5, + MS_10 = 6, + MS_20 = 7 +} + +export function open(options: options): Promise; + +export class Bme280 { + constructor(bme280I2c: any); + + public read(): Promise; + + public triggerForcedMeasurement(): Promise; + + public typicalMeasurementTime(): number; + + public maximumMeasurementTime(): number; + + public close(): Promise; +} \ No newline at end of file diff --git a/package.json b/package.json index bdc8e4c..d3dbb26 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "2.1.1", "description": "I2C Driver for the BME280 humidity, pressure and temperature sensor", "main": "bme280.js", + "typings": "bme280.d.ts", "scripts": { "lint": "jshint *.js examples/*.js test/*.js", "test": "cd test && ./run-tests && cd .." From 049e40a0280d37f1c3fd271d260c523d8cf918fc Mon Sep 17 00:00:00 2001 From: CinePlays Date: Sun, 20 Mar 2022 03:04:01 +0100 Subject: [PATCH 2/2] missing '?' --- bme280.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bme280.d.ts b/bme280.d.ts index 95cf5da..99595c8 100644 --- a/bme280.d.ts +++ b/bme280.d.ts @@ -43,7 +43,7 @@ export enum STANDBY { MS_20 = 7 } -export function open(options: options): Promise; +export function open(options?: options): Promise; export class Bme280 { constructor(bme280I2c: any);