Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
brucelyc authored Mar 12, 2020
1 parent d9a3bc1 commit e20274e
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 1 deletion.
21 changes: 21 additions & 0 deletions LICENSE
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.
10 changes: 10 additions & 0 deletions Makefile
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
19 changes: 18 additions & 1 deletion README.md
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


6 changes: 6 additions & 0 deletions _locales/mlx90615-strings.json
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"
}
6 changes: 6 additions & 0 deletions _locales/zh/mlx90615-strings.json
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": "周圍"
}
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions mlx90615.ts
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;
}
}
}
17 changes: 17 additions & 0 deletions pxt.json
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
}
6 changes: 6 additions & 0 deletions test.ts
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)
})
8 changes: 8 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"outDir": "built",
"rootDir": "."
}
}

0 comments on commit e20274e

Please sign in to comment.