Skip to content

Commit

Permalink
Merge pull request #79 from dtex/TMP36
Browse files Browse the repository at this point in the history
Add Thermistor tests
  • Loading branch information
dtex committed Jul 21, 2020
2 parents f5d3428 + cbc94b7 commit f7aba22
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
38 changes: 38 additions & 0 deletions examples/thermometer-lm335/main.js
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);

});
10 changes: 10 additions & 0 deletions examples/thermometer-lm335/manifest.json
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"
}
}
38 changes: 38 additions & 0 deletions examples/thermometer-lm35/main.js
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);

});
10 changes: 10 additions & 0 deletions examples/thermometer-lm35/manifest.json
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"
}
}
38 changes: 38 additions & 0 deletions examples/thermometer-mf52a103j3470/main.js
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);

});
10 changes: 10 additions & 0 deletions examples/thermometer-mf52a103j3470/manifest.json
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"
}
}

0 comments on commit f7aba22

Please sign in to comment.