This commit is contained in:
Peli de Halleux 2016-08-15 22:56:07 -07:00
Родитель 5490832860
Коммит 9e72e4bd11
7 изменённых файлов: 107 добавлений и 1 удалений

7
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,7 @@
built
node_modules
yotta_modules
yotta_targets
pxt_modules
*.db
*.tgz

11
.vscode/settings.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,11 @@
{
"editor.formatOnType": true,
"files.autoSave": "afterDelay",
"search.exclude": {
"**/built": true,
"**/node_modules": true,
"**/yotta_modules": true,
"**/yotta_targets": true,
"**/pxt_modules": true
}
}

30
.vscode/tasks.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,30 @@
// A task runner that calls the PXT compiler and
{
"version": "0.1.0",
// The command is pxt. Assumes that PXT has been installed using npm install -g pxt
"command": "pxt",
// The command is a shell script
"isShellCommand": true,
// Show the output window always.
"showOutput": "always",
"tasks": [{
"taskName": "deploy",
"isBuildCommand": true,
"problemMatcher": "$tsc",
"args": ["deploy"]
}, {
"taskName": "build",
"isTestCommand": true,
"problemMatcher": "$tsc",
"args": ["build"]
}, {
"taskName": "publish",
"problemMatcher": "$tsc",
"args": ["publish"]
}]
}

Просмотреть файл

@ -1,2 +1,9 @@
# pxt-max6675 # pxt-max6675
A package for the MAX6675 component in PXT A package to use temperature probes using the MAX6675
## License
MIT
## Supported targets
* for PXT/microbit
(The metadata above is needed for package search.)

27
main.ts Normal file
Просмотреть файл

@ -0,0 +1,27 @@
/**
* Functions to read temperature probe data
*/
//% color=#A80000
namespace max6675 {
/**
* Returns the temperate measured in C provided by the MAX6675 connected to a temperature probe.
*/
//% blockId=max6675_temperature block="max6675 temperature|%pin"
export function temperature(pin: DigitalPin): number {
pins.setPull(pin, PinPullMode.PullNone);
pins.digitalWritePin(pin, 0);
basic.pause(1);
let highByte = pins.spiWrite(0);
let lowByte = pins.spiWrite(0);
pins.digitalWritePin(pin, 1);
let temp = 0;
if (lowByte & (1 << 2)) {
temp = -1000;
} else {
let value = (highByte << 5 | lowByte >> 3);
temp = (value / 4);
}
return temp;
}
}

16
pxt.json Normal file
Просмотреть файл

@ -0,0 +1,16 @@
{
"name": "pxt-max6675",
"version": "0.1.0",
"description": "A package to use temperature probes using the MAX6675",
"license": "MIT",
"dependencies": {
"microbit": "*",
"microbit-radio": "*"
},
"files": [
"README.md",
"main.ts"
],
"testFiles": [],
"public": true
}

8
tsconfig.json Normal file
Просмотреть файл

@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"outDir": "built",
"rootDir": "."
}
}