From 2d3b25e2852b363fe2acc0dc20335e67cf97f126 Mon Sep 17 00:00:00 2001 From: shaoziyang Date: Wed, 20 Jun 2018 14:20:18 +0800 Subject: [PATCH] use Math.idiv instead of / --- main.ts | 10 +++++----- pxt.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main.ts b/main.ts index f6c3f6d..352d320 100644 --- a/main.ts +++ b/main.ts @@ -214,11 +214,11 @@ namespace APDS9930 { export function getALS(): number { let Ch0 = getCH0() let Ch1 = getCH1() - let ALSIT = 87 * (256 - getReg(APDS9930_ATIME)) / 32 - let IAC = Math.max(Ch0 - B * Ch1 / 1000, (C * Ch0 - D * Ch1) / 1000) + let ALSIT = 87 * (256 - getReg(APDS9930_ATIME)) >> 5 + let IAC = Math.max(Ch0 - Math.idiv(B * Ch1, 1000), Math.idiv(C * Ch0 - D * Ch1, 1000)) IAC = Math.max(IAC, 0) - let LPC = GA * DF / ALSIT - return IAC * LPC / _AGAIN + let LPC = Math.idiv(GA * DF, ALSIT) + return Math.idiv(IAC * LPC, _AGAIN) } /** @@ -227,7 +227,7 @@ namespace APDS9930 { //% blockId="APDS9930_GET_Proximity" block="get Proximity" //% weight=200 blockGap=8 export function getProximity(): number { - return get2Reg(APDS9930_PDATAL) / _PGAIN + return Math.idiv(get2Reg(APDS9930_PDATAL), _PGAIN) } /** diff --git a/pxt.json b/pxt.json index fe551e7..8d8d8da 100644 --- a/pxt.json +++ b/pxt.json @@ -1,6 +1,6 @@ { "name": "APDS9930", - "version": "1.0.0", + "version": "1.1.0", "description": "makecode APDS9930 Digital Proximity and Ambient Light Sensor package", "license": "MIT", "dependencies": {