Skip to content

Commit 1b279a6

Browse files
committed
Removed LCD display from UI and replaced with displaying temperatures
1 parent df784f5 commit 1b279a6

File tree

5 files changed

+69
-81
lines changed

5 files changed

+69
-81
lines changed

beer-panel.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,14 @@
1717
*/
1818
?>
1919
<div id="top-bar" class="ui-widget ui-widget-header ui-corner-all">
20-
<div id="lcd" class="lcddisplay">
21-
<span class="lcd-text">
22-
<span class="lcd-line" id="lcd-line-0">Live LCD waiting</span>
23-
<span class="lcd-line" id="lcd-line-1">for update from</span>
24-
<span class="lcd-line" id="lcd-line-2">script...</span>
25-
<span class="lcd-line" id="lcd-line-3"></span>
26-
</span>
27-
</div>
2820
<div id="logo-container">
2921
<img src="brewpi_logo.png">
3022
<div id=beer-name-container>
3123
<span>Fermenting: </span><a href='#' id="beer-name"><?php echo urldecode($beerName);?></a>
3224
<span class="data-logging-state"></span>
3325
</div>
3426
</div>
27+
<div class="temperatures-container"></div>
3528
<button class="script-status ui-state-error"></button>
3629
<button id="maintenance" class="ui-state-default">Maintenance panel</button>
3730
</div>

css/style.css

+23-49
Original file line numberDiff line numberDiff line change
@@ -142,55 +142,31 @@ button#maintenance{
142142
margin: 5px;
143143
}
144144

145-
/* LCD display styling */
146-
@font-face {
147-
font-family: '5x8LCDHD44780UA02Regular';
148-
src: url('../font/5x8_lcd_hd44780u_a02-webfont.eot');
149-
src: url('../font/5x8_lcd_hd44780u_a02-webfont.eot?#iefix') format('embedded-opentype'),
150-
url('../font/5x8_lcd_hd44780u_a02-webfont.woff') format('woff'),
151-
url('../font/5x8_lcd_hd44780u_a02-webfont.ttf') format('truetype'),
152-
url('../font/5x8_lcd_hd44780u_a02-webfont.svg#5x8LCDHD44780UA02Regular') format('svg');
153-
font-weight: normal;
154-
font-style: normal;
145+
.temperatures-container{
146+
width: 400px;
147+
height: 90px;
148+
float: left;
149+
margin: 5px 10px;
150+
-moz-column-width: 180px;
151+
-webkit-column-width: 180px;
152+
column-width: 190px;
153+
}
154+
155+
.temperatures-container .temperature-name{
156+
width: 120px;
157+
float: left;
158+
clear: left;
159+
font-size: 14px;
160+
padding: 3px 0px;
161+
color: #333;
155162
}
156-
157-
158-
.lcddisplay {
159-
width: 280px;
160-
height: 90px;
163+
.temperatures-container .temperature-value{
164+
width: 40px;
165+
text-align: right;
161166
float: left;
162-
margin: 5px;
163-
background: #000000; /* Old browsers */
164-
background: -moz-linear-gradient(top, #000000 2%, #2b2b2b 11%, #212121 54%, #212121 92%, #000000 100%); /* FF3.6+ */
165-
background: -webkit-gradient(linear, left top, left bottom, color-stop(2%,#000000), color-stop(11%,#2b2b2b), color-stop(54%,#212121), color-stop(92%,#212121), color-stop(100%,#000000)); /* Chrome,Safari4+ */
166-
background: -webkit-linear-gradient(top, #000000 2%,#2b2b2b 11%,#212121 54%,#212121 92%,#000000 100%); /* Chrome10+,Safari5.1+ */
167-
background: -o-linear-gradient(top, #000000 2%,#2b2b2b 11%,#212121 54%,#212121 92%,#000000 100%); /* Opera11.10+ */
168-
background: -ms-linear-gradient(top, #000000 2%,#2b2b2b 11%,#212121 54%,#212121 92%,#000000 100%); /* IE10+ */
169-
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
170-
background: linear-gradient(top, #000000 2%,#2b2b2b 11%,#212121 54%,#212121 92%,#000000 100%); /* W3C */
171-
-webkit-box-shadow: inset 1px 1px 5px #333333;
172-
-moz-box-shadow: inset 1px 1px 5px #333333;
173-
box-shadow: inset 1px 1px 5px #333333;
174-
border: 2px solid #333;
175-
-webkit-border-radius: 2px;
176-
-moz-border-radius: 2px;
177-
border-radius: 2px;
178-
}
179-
180-
.lcddisplay .lcd-text{
181-
float:left;
182-
margin: 5px 16px;
183-
}
184-
185-
.lcd-line{
186-
float:left;
187-
clear:left;
167+
padding-top: 3px;
188168
font-size: 16px;
189-
font-weight: normal;
190-
font-style: normal;
191-
font-family: '5x8LCDHD44780UA02Regular', monospace;
192-
color: #FFFF00;
193-
white-space: pre;
169+
color: white;
194170
}
195171

196172
.ui-dialog,
@@ -604,11 +580,9 @@ button#maintenance{
604580

605581
#logo-container{
606582
float: left;
607-
clear: none;
608583
display: block;
609-
margin-left: 4px;
610584
margin-top: 10px;
611-
width: 450px;
585+
width: 300px;
612586
text-align: center;
613587
}
614588

js/beer-chart.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@ var STATES = [
6767
{ name: "STATE_OFF", color:colorIdle, text: "Off" },
6868
{ name: "DOOR_OPEN", color:"#eee", text: "Door Open", doorOpen:true },
6969
{ name: "HEATING", color:colorHeat, text: "Heating" },
70-
{ name: "COOLING", color:colorCool, text: "Cooling" },
71-
{ name: "WAITING_TO_COOL", color:colorWaitingCool, text: "Waiting to Cool", waiting:true },
72-
{ name: "WAITING_TO_HEAT", color:colorWaitingHeat, text: "Waiting to Heat", waiting:true },
73-
{ name: "WAITING_FOR_PEAK_DETECT", color:colorWaitingPeakDetect, text: "Waiting for Peak", waiting:true },
74-
{ name: "COOLING_MIN_TIME", color:colorCoolingMinTime, text: "Cooling Min Time", extending:true },
75-
{ name: "HEATING_MIN_TIME", color:colorHeatingMinTime, text: "Heating Min Time", extending:true }
70+
{ name: "COOLING", color:colorCool, text: "Cooling" }
7671
];
7772

7873

js/main.js

+44-13
Original file line numberDiff line numberDiff line change
@@ -172,33 +172,64 @@ function startScript(){
172172
$.get('start_script.php');
173173
}
174174

175-
function refreshLcd(){
175+
function refreshTemperatures(){
176176
"use strict";
177177
$.ajax({
178178
type: "POST",
179179
dataType:"json",
180180
cache: false,
181181
contentType:"application/x-www-form-urlencoded; charset=utf-8",
182182
url: 'socketmessage.php',
183-
data: {messageType: "lcd", message: ""}
183+
data: {messageType: "getTemperatures", message: ""}
184184
})
185-
.done( function(lcdText){
186-
var $lcdText = $('#lcd .lcd-text');
187-
for (var i = lcdText.length - 1; i >= 0; i--) {
188-
$lcdText.find('#lcd-line-' + i).html(lcdText[i]);
185+
.done( function(temperatures){
186+
$(".temperatures-container").empty();
187+
const displayOrder = ['BeerSet', 'BeerTemp', 'FridgeSet', 'FridgeTemp', 'Log1Temp', 'Log2Temp', 'Log3Temp', 'State']
188+
const stateNames = ["Idle", "Off", "Door Open", "Heating", "Cooling"];
189+
const displayName = {
190+
BeerSet: 'Beer Setting',
191+
BeerTemp: 'Beer Temp',
192+
FridgeSet: 'Fridge Setting',
193+
FridgeTemp: 'Fridge Temp',
194+
Log1Temp: 'Log 1 Temp',
195+
Log2Temp: 'Log 2 Temp',
196+
Log3Temp: 'Log 3 Temp',
197+
State: 'State'
189198
}
199+
for (var key of displayOrder) {
200+
console.log(key);
201+
if (temperatures.hasOwnProperty(key)) {
202+
var value = temperatures[key];
203+
console.log(value);
204+
205+
if(!isNaN(parseFloat(value))){
206+
var $temperatureName=$('<div />').text(displayName[key]);
207+
$temperatureName.addClass('temperature-name');
208+
//temperatureNameSpan.addClass(displayName[key]);
209+
var $temperatureValue=$('<div />')
210+
if(key === 'State'){
211+
$temperatureValue=$('<div />').text(stateNames[value]);
212+
} else{
213+
$temperatureValue.text(value.toFixed(2));
214+
}
215+
$temperatureValue.addClass('temperature-value');
216+
$temperatureValue.addClass('key');
217+
var $temperatureDiv = $("<div />");
218+
$temperatureDiv.append($temperatureName);
219+
$temperatureDiv.append($temperatureValue);
220+
$(".temperatures-container").append($temperatureDiv);
221+
}
222+
}
223+
}
224+
190225
updateScriptStatus(true);
191226
})
192227
.fail(function() {
193-
var $lcdText = $('#lcd .lcd-text');
194-
$lcdText.find('#lcd-line-0').html("Cannot receive");
195-
$lcdText.find('#lcd-line-1').html("LCD text from");
196-
$lcdText.find('#lcd-line-2').html("Python script");
197-
$lcdText.find('#lcd-line-3').html(" ");
228+
198229
updateScriptStatus(false);
199230
})
200231
.always(function() {
201-
window.setTimeout(refreshLcd,5000);
232+
window.setTimeout(refreshTemperatures,5000);
202233
}
203234
);
204235
}
@@ -422,6 +453,6 @@ $(document).ready(function(){
422453
receiveControlConstants();
423454
receiveControlSettings();
424455
receiveControlVariables();
425-
refreshLcd(); //will call refreshLcd and alternate between the two
456+
refreshTemperatures();
426457
});
427458

socketmessage.php

-5
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ function writeToSocket($sock, $msg){
9494
echo 0;
9595
}
9696
break;
97-
case "lcd":
98-
writeToSocket($sock, "lcd");
99-
$lcdText = readFromSocket($sock);
100-
echo str_replace(chr(0xB0), "&deg;", $lcdText); // replace degree sign with &Deg
101-
break;
10297
default:
10398
// just pass the command to the socket and read the answer if needed
10499
writeToSocket($sock, $messageType);

0 commit comments

Comments
 (0)