-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserInterface.js
More file actions
251 lines (183 loc) · 7.09 KB
/
UserInterface.js
File metadata and controls
251 lines (183 loc) · 7.09 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/// <reference path="Lib/knockout-3.1.0.js" />
function UserInterface(self) {
//Steam
self.SteamButtonDown = function () {
if (!self.OvenIsOn()) return;
self.SteamDown();
};
self.SteamButtonUp = function () {
if (!self.OvenIsOn()) return;
self.SteamUp();
};
self.LightOn_Steam = ko.computed(function () {
if (!self.OvenIsOn()) return false; //The oven is off
if (self.SteamButtonIsBlinking() && !self.MasterBlinkOn())
return false; //The blink is off
return self.MoistureModeOn() || self.DisplayingMoistureSetup() || self.SteamShooting();
});
//Program
self.ProgramButtonUp = function () {
if (!self.OvenIsOn()) return;
self.ProgramUp();
};
self.ProgramButtonDown = function () {
if (!self.OvenIsOn()) return;
self.ProgramDown();
};
self.LightOn_Program = ko.computed(function () {
if (!self.OvenIsOn()) return false; //The oven is off
if (self.ProgramButtonIsBlinking() && !self.MasterBlinkOn())
return false; //The blink is off
if (self.ProgrammingArea() >= 1)
return true;
else
return false;
});
//Temp
self.TempButtonUp = function () {
if (!self.OvenIsOn() || !self.TempButtonUpFunction()) return;
self.TempButtonUpFunction()();
};
self.LightOn_Temp = ko.computed(function () {
if (!self.OvenIsOn()) return false; //The oven is off
if (self.TempButtonIsBlinking() && !self.MasterBlinkOn())
return false; //The blink is off
if (self.DisplayingActualTemperature()) {
return self.DisplayingActualTemperature();
} else {
return self.IsHeating();
}
});
//LightPower
self.LightPowerButtonDown = function () {
self.LightPowerDown();
};
self.LightPowerButtonUp = function () {
self.LightPowerUp();
};
self.LightOn_LightPower = ko.computed(function () {
if (!self.OvenIsOn()) return false; //The oven is off
if (self.LightPowerButtonIsBlinking() && !self.MasterBlinkOn())
return false; //The blink is off
return self.LightIsOn();
});
//Fan
self.ButtonClickFan = function () {
if (!self.OvenIsOn()) return;
self.DisplayingProgramStage().ToggleFanValue();
};
self.LightOn_Fan = ko.computed(function () {
if (!self.OvenIsOn() || self.IsProgramming()) return false; //The oven is off
if (self.FanButtonIsBlinking() && !self.MasterBlinkOn())
return false; //The blink is off
return self.DisplayingProgramStage().IsFanLow();
});
//Timer
self.TimerButtonDown = function () {
if (!self.OvenIsOn() || !self.TimerButtonDownFunction()) return;
self.TimerButtonDownFunction()();
};
self.TimerButtonUp = function () {
if (!self.OvenIsOn() || !self.TimerButtonUpFunction()) return;
self.TimerButtonUpFunction()();
};
self.LightOn_Timer = ko.computed(function () {
if (!self.OvenIsOn()) return false; //The oven is off
if (self.TimerButtonIsBlinking() && !self.MasterBlinkOn())
return false; //The blink is off
if (self.LightOn_TimerFunction()) {
return self.LightOn_TimerFunction()();
}
else
return false;
});
//Dials - Start
//Temp Plus/Minus
self.btnTemp_MinusClick = function () {
if (!self.OvenIsOn() || !self.Temp_MinusClickFunction()) return;
self.Temp_MinusClickFunction()();
};
self.btnTemp_PlusClick = function () {
if (!self.OvenIsOn() || !self.Temp_PlusClickFunction()) return;
self.Temp_PlusClickFunction()();
};
//Timer Plus/Minus
self.btnTimer_MinusClick = function () {
if (!self.OvenIsOn() || !self.Timer_MinusClickFunction()) return;
self.Timer_MinusClickFunction()();
};
self.btnTimer_PlusClick = function () {
if (!self.OvenIsOn() || !self.Timer_PlusClickFunction()) return;
self.Timer_PlusClickFunction()();
};
//Dials - End
//Displays - Start
self.TopDisplay = ko.computed(function () {
if (!self.OvenIsOn() || (self.TopDisplayIsBlinking() && !self.MasterBlinkOn()))
return ''; //The oven or the blink is off
return self.TopDisplayFunction() ? self.TopDisplayFunction()() : '';
});
self.BottomDisplay = ko.computed(function () {
if (!self.OvenIsOn() || (self.BottomDisplayIsBlinking() && !self.MasterBlinkOn() && !self.OvenIsOn()))
return ''; //The oven or the blink is off
return self.BottomDisplayFunction() ? self.BottomDisplayFunction()() : '';
});
//Displays - End
//Computed - Start
self.ActualTemperatureRounded = ko.computed(function () {
//Round the value
return Math.round(self.ActualTemperature());
});
self.MoistureModeDisplay = ko.computed(function () {
return 'H-' + self.DisplayingProgramStage().CurrentMoistureMode();
});
//Computed - End
//Display Functions - Start
self.TargetTemperature = ko.computed(function () {
return self.DisplayingProgramStage().TargetTemperature();
});
self.TimerDisplayValue = function () {
if (self.TimerStarted()) {
return self.ConvertDurtaionToDisplay(self.DisplayingProgramStage().TimerCurrentValue());
} else {
if (self.DisplayingProgramStage().TimerStartValue() <= -2) {
return "CP";
} else if (self.DisplayingProgramStage().TimerStartValue() === -1) {
return "InF";
} else if (self.DisplayingProgramStage().TimerStartValue() === 0) {
return "---";
} else {
return self.DisplayingProgramStage().TimerStartValue();
}
}
};
self.TargetTemperatureDisplayValue = function () {
return self.DisplayingProgramStage().TargetTemperature();
};
self.CoreProbeDisplayValue = function () {
var coreProbeLabel = "CP";
if (self.DisplayingProgramStage().TargetCoreTemperatureSet()) {
if (self.TargetCoreTemperatureBlinkOn()) {
if (self.TargetCoreTemperatureAlternate()) {
if (self.DisplayingActualCoreTemperature())
return self.ActualCoreTemperature();
else
return self.DisplayingProgramStage().TargetCoreTemperature();
} else {
return coreProbeLabel;
}
}
else
return '';
} else {
return coreProbeLabel;
}
};
//Display Functions - End
//Utils
self.ConvertDurtaionToDisplay = function (duration) {
if (duration.minutes() > 10) { return duration.minutes(); }
//console.log(duration.minutes + ':' + (duration.seconds < 10 ? '0' : '') + duration.seconds);
return duration.minutes() + ':' + (duration.seconds() < 10 ? '0' : '') + duration.seconds();
};
}