-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
all: deploy | ||
|
||
build: | ||
pxt build | ||
|
||
deploy: | ||
pxt deploy | ||
|
||
test: | ||
pxt test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
# pxt-mlx90615 | ||
# pxt-mlx90615 | ||
|
||
## License | ||
|
||
MIT | ||
|
||
## Supported targets | ||
|
||
* for PXT/microbit | ||
|
||
(The metadata above is needed for package search.) | ||
|
||
```package | ||
MLX90615=github:brucelyc/pxt-mlx90615 | ||
``` | ||
## Reference | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"MLX90615|block": "MLX90615", | ||
"MLX90615.temperature|block": "Temperature|%loc", | ||
"MLX90615.TemperatureLocation.Object|block": "Object", | ||
"MLX90615.TemperatureLocation.Ambiant|block": "Ambiant" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"MLX90615|block": "紅外線溫測", | ||
"MLX90615.temperature|block": "%loc 的溫度值", | ||
"MLX90615.TemperatureLocation.Object|block": "目標物", | ||
"MLX90615.TemperatureLocation.Ambiant|block": "周圍" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//%color=#FF8533 icon="\uf2cb" block="MLX90614" | ||
namespace MLX90614 { | ||
const addr = 0x5B | ||
const obTempAddr = 0x27 | ||
const amTempAddr = 0x26 | ||
|
||
export enum TemperatureLocation { | ||
//% blockId="Object" block="Object" | ||
Object = 0, | ||
//% blockId="Ambiant" block="Ambiant" | ||
Ambiant = 1 | ||
} | ||
|
||
function read16(reg: NumberFormat.UInt8BE): number { | ||
pins.i2cWriteNumber(addr, reg, NumberFormat.UInt8BE, true); | ||
let ret = pins.i2cReadNumber(addr, NumberFormat.UInt16LE, true); | ||
return ret | ||
} | ||
|
||
function readTemp(reg: NumberFormat.UInt8BE): number { | ||
let temp = read16(reg) | ||
temp *= .02 | ||
temp -= 273.15 | ||
return Math.round(temp *100)/100 | ||
} | ||
|
||
//% blockId="temperature" block="Temperature %loc" | ||
export function temperature(loc: TemperatureLocation): number{ | ||
switch (loc){ | ||
case 0: | ||
return readTemp(obTempAddr); | ||
case 1: | ||
return readTemp(amTempAddr); | ||
default: | ||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "pxt-mlx90615", | ||
"version": "0.0.1", | ||
"description": "MLX90615 extension for Micro:bit", | ||
"dependencies": { | ||
"core": "*" | ||
}, | ||
"files": [ | ||
"README.md", | ||
"mlx90615.ts", | ||
"_locales/zh/mlx90615-strings.json" | ||
], | ||
"testFiles": [ | ||
"test.ts" | ||
], | ||
"public": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
basic.forever(function () { | ||
serial.writeLine("O:" + MLX90615.temperature(TemperatureLocation.Object)) | ||
serial.writeLine("A:" + MLX90615.temperature(TemperatureLocation.Ambiant)) | ||
serial.writeLine("") | ||
basic.pause(500) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"noImplicitAny": true, | ||
"outDir": "built", | ||
"rootDir": "." | ||
} | ||
} |