Skip to content

Commit

Permalink
use Math.idiv instead of /
Browse files Browse the repository at this point in the history
  • Loading branch information
shaoziyang committed Jun 20, 2018
1 parent 3622f82 commit 2d3b25e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand All @@ -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)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pxt.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 2d3b25e

Please sign in to comment.