-
Notifications
You must be signed in to change notification settings - Fork 2
/
GBcoffeeFCT.js~
129 lines (114 loc) · 3.61 KB
/
GBcoffeeFCT.js~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// start the oven at a 190F Convect Bake before running this code.
var greenBean = require("green-bean");
var PROFILE1 = [
{ temp: 200, duration: 60000 },
{ temp: 210, duration: 30000 },
{ temp: 220, duration: 30000 },
{ temp: 230, duration: 30000 },
{ temp: 240, duration: 30000 },
{ temp: 250, duration: 30000 },
{ temp: 260, duration: 30000 },
{ temp: 270, duration: 30000 },
{ temp: 280, duration: 30000 },
{ temp: 290, duration: 30000 },
{ temp: 300, duration: 30000 },
{ temp: 310, duration: 30000 },
{ temp: 320, duration: 30000 },
{ temp: 330, duration: 30000 },
{ temp: 340, duration: 10000 },
{ temp: 342, duration: 10000 },
{ temp: 344, duration: 10000 },
{ temp: 346, duration: 10000 },
{ temp: 348, duration: 10000 },
{ temp: 350, duration: 10000 },
{ temp: 352, duration: 10000 },
{ temp: 354, duration: 10000 },
{ temp: 356, duration: 10000 },
{ temp: 358, duration: 10000 },
{ temp: 360, duration: 10000 },
{ temp: 362, duration: 10000 },
{ temp: 364, duration: 10000 },
{ temp: 366, duration: 10000 },
{ temp: 368, duration: 10000 },
{ temp: 370, duration: 10000 },
{ temp: 372, duration: 10000 },
{ temp: 374, duration: 10000 },
{ temp: 376, duration: 10000 },
{ temp: 378, duration: 10000 },
{ temp: 380, duration: 10000 },
{ temp: 382, duration: 10000 },
{ temp: 384, duration: 10000 },
{ temp: 386, duration: 10000 },
{ temp: 388, duration: 10000 },
{ temp: 390, duration: 10000 },
{ temp: 392, duration: 10000 },
{ temp: 394, duration: 10000 },
{ temp: 396, duration: 10000 },
{ temp: 398, duration: 10000 },
{ temp: 400, duration: 10000 },
{ temp: 402, duration: 10000 },
{ temp: 404, duration: 10000 },
{ temp: 406, duration: 10000 },
{ temp: 408, duration: 10000 },
{ temp: 410, duration: 10000 },
{ temp: 412, duration: 10000 },
{ temp: 414, duration: 10000 },
{ temp: 416, duration: 10000 },
{ temp: 418, duration: 10000 },
{ temp: 420, duration: 10000 },
{ temp: 422, duration: 10000 },
{ temp: 424, duration: 12000 },
{ temp: 425, duration: 12000 },
{ temp: 426, duration: 12000 },
{ temp: 427, duration: 12000 },
{ temp: 428, duration: 12000 },
{ temp: 429, duration: 12000 },
{ temp: 430, duration: 12000 },
{ temp: 431, duration: 12000 },
{ temp: 432, duration: 12000 },
{ temp: 433, duration: 12000 },
{ temp: 434, duration: 12000 },
];
function startCooking(range, profile, callback, step) {
var index = step || 0;
var setpoint = profile[index];
var hysteresis = 1;
var tempNow = 0;
if (setpoint) {
console.log('setting temp to ' + setpoint.temp);
range.analogInputs.read(function(value) {
console.log("analog input are:", value);
tempNow = value;
});
if(tempNow < setpoint.temp - hysteresis) {
range.elementStatus.write({
upperOvenElementStatus: 0,
lowerOvenElementStatus: 16
});
} else if (tempNow > setpoint.temp) {
range.elementStatus.write({
upperOvenElementStatus: 0,
lowerOvenElementStatus: 0
});
setTimeout(startCooking.bind(this, range, profile, callback, index + 1),
setpoint.duration);
}
else {
range.elementStatus.write({
upperOvenElementStatus: 0,
lowerOvenElementStatus: 0
});
callback(null);
}
}
greenBean.connect("range", function(range) {
range.fctMode.write(1); // enter fct mode
setInterval(function() {
range.fctMode.write(1); // stay in fct mode
}, 15000);
//Now we start the ramping profile after placing the beans in the oven.
startCooking(range, PROFILE1, function(err) {
if (err) console.error(err);
else console.log('cool beans');
});
});