-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from dtex/TMP36
Add Thermistor tests
- Loading branch information
Showing
6 changed files
with
144 additions
and
0 deletions.
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,38 @@ | ||
import LM335 from "j5e/lm335"; | ||
import LED from "j5e/led"; | ||
import { timer } from "j5e/fn"; | ||
|
||
let last = 0; | ||
let myTimer; | ||
|
||
const thermometer = await new LM335({ | ||
pin: 14, | ||
threshold: 4 | ||
}); | ||
|
||
const led = await new LED({ | ||
pin: 12, | ||
pwm: true | ||
}); | ||
|
||
thermometer.on("change", function(data) { | ||
|
||
trace(`${data.F}° Fahrenheit\n`); | ||
if (last > data.raw) { | ||
led.blink(100); | ||
last = data.raw; | ||
} | ||
|
||
if (last < data.raw) { | ||
led.stop().on(); | ||
last = data.raw; | ||
} | ||
|
||
if (typeof myTimer !== "undefined" && myTimer !== null) timer.clearTimeout(myTimer); | ||
|
||
myTimer = timer.setTimeout(function() { | ||
myTimer = null; | ||
led.stop().off(); | ||
}, 1000); | ||
|
||
}); |
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 @@ | ||
{ | ||
"include": [ | ||
"$(MODDABLE)/modules/io/manifest.json", | ||
"$(j5e)/lib/thermometer/lm335/manifest.json", | ||
"$(j5e)/lib/led/manifest.json" | ||
], | ||
"modules": { | ||
"*": "./main" | ||
} | ||
} |
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 @@ | ||
import LM35 from "j5e/lm35"; | ||
import LED from "j5e/led"; | ||
import { timer } from "j5e/fn"; | ||
|
||
let last = 0; | ||
let myTimer; | ||
|
||
const thermometer = await new LM35({ | ||
pin: 14, | ||
threshold: 4 | ||
}); | ||
|
||
const led = await new LED({ | ||
pin: 12, | ||
pwm: true | ||
}); | ||
|
||
thermometer.on("change", function(data) { | ||
|
||
trace(`${data.F}° Fahrenheit\n`); | ||
if (last > data.raw) { | ||
led.blink(100); | ||
last = data.raw; | ||
} | ||
|
||
if (last < data.raw) { | ||
led.stop().on(); | ||
last = data.raw; | ||
} | ||
|
||
if (typeof myTimer !== "undefined" && myTimer !== null) timer.clearTimeout(myTimer); | ||
|
||
myTimer = timer.setTimeout(function() { | ||
myTimer = null; | ||
led.stop().off(); | ||
}, 1000); | ||
|
||
}); |
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 @@ | ||
{ | ||
"include": [ | ||
"$(MODDABLE)/modules/io/manifest.json", | ||
"$(j5e)/lib/thermometer/lm35/manifest.json", | ||
"$(j5e)/lib/led/manifest.json" | ||
], | ||
"modules": { | ||
"*": "./main" | ||
} | ||
} |
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 @@ | ||
import MF52A103J3470 from "j5e/mf52a103j3470"; | ||
import LED from "j5e/led"; | ||
import { timer } from "j5e/fn"; | ||
|
||
let last = 0; | ||
let myTimer; | ||
|
||
const thermometer = await new MF52A103J3470({ | ||
pin: 14, | ||
threshold: 4 | ||
}); | ||
|
||
const led = await new LED({ | ||
pin: 12, | ||
pwm: true | ||
}); | ||
|
||
thermometer.on("change", function(data) { | ||
|
||
trace(`${data.F}° Fahrenheit\n`); | ||
if (last > data.raw) { | ||
led.blink(100); | ||
last = data.raw; | ||
} | ||
|
||
if (last < data.raw) { | ||
led.stop().on(); | ||
last = data.raw; | ||
} | ||
|
||
if (typeof myTimer !== "undefined" && myTimer !== null) timer.clearTimeout(myTimer); | ||
|
||
myTimer = timer.setTimeout(function() { | ||
myTimer = null; | ||
led.stop().off(); | ||
}, 1000); | ||
|
||
}); |
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 @@ | ||
{ | ||
"include": [ | ||
"$(MODDABLE)/modules/io/manifest.json", | ||
"$(j5e)/lib/thermometer/mf52a103j3470/manifest.json", | ||
"$(j5e)/lib/led/manifest.json" | ||
], | ||
"modules": { | ||
"*": "./main" | ||
} | ||
} |