diff --git a/css/style.css b/css/style.css
index 1e27acd..3f8b2db 100644
--- a/css/style.css
+++ b/css/style.css
@@ -249,6 +249,20 @@ button#refresh-beer-chart span.ui-icon{
padding: 10px;
}
+#maintenance-panel .device-list-container .header button{
+ float: right;
+}
+
+#maintenance-panel .refresh-options-container{
+ float: right;
+ display: block;
+}
+
+#maintenance-panel .refresh-options-container refresh-option{
+ float: right;
+ display: block;
+}
+
#maintenance-panel #beer-selector{
margin-bottom: 20px;
diff --git a/index.php b/index.php
index cf6e166..a9ca3e3 100644
--- a/index.php
+++ b/index.php
@@ -49,6 +49,7 @@
window.beerName = ;
+
diff --git a/js/device-config.js b/js/device-config.js
new file mode 100644
index 0000000..1907c5c
--- /dev/null
+++ b/js/device-config.js
@@ -0,0 +1,220 @@
+
+function initDeviceConfiguration(){
+ "use strict";
+ $(".refresh-device-list").button({icons: {primary: "ui-icon-refresh" } })
+ .click(refreshDeviceList);
+ $(".get-device-list").button({icons: {primary: "ui-icon-arrowthickstop-1-s" } })
+ .click(getDeviceList);
+}
+
+function getDeviceList(){
+ "use strict";
+ $.post('socketmessage.php', {messageType: "getDeviceList", message: ""}, function(response){
+ try
+ {
+ response = response.replace(/\s/g, ''); //strip all whitespace, including newline.
+ var deviceList = JSON.parse(response);
+ $("#device-console span").html(parseDeviceList(deviceList));
+ }
+ catch(e)
+ {
+ $("#device-console span").html("Cannot parse JSON:" + e);
+ }
+ });
+}
+
+function refreshDeviceList(){
+ "use strict";
+ var parameters = "";
+ if ($('#read-values').is(":checked")){
+ parameters += "v:1";
+ }
+ if ($('#only-unassigned').is(":checked")){
+ parameters += "u:1";
+ }
+
+ $.post('socketmessage.php', {messageType: "refreshDeviceList", message: parameters});
+}
+
+
+function parseDeviceList(deviceList){
+ "use strict";
+ // output is just for testing now
+ var output = "";
+
+ for (var i = 0; i < deviceList.length; i++) {
+ var device = deviceList[i];
+ device.nr = i;
+ output += "Parsing device: ";
+ output += JSON.stringify(device);
+ output += '
';
+ addDeviceToDeviceList(device);
+ }
+ return output;
+}
+
+function addDeviceToDeviceList(device){
+ "use strict";
+ var $newDevice = $("
");
+ $newDevice.append("Device " + device.nr.toString() +"");
+ /*$newDevice.append(" Function "+ device.f.toString() + "
");*/
+ $newDevice.append(generateSelect(getDeviceChamberList(), device.c));
+ $newDevice.append(generateSelect(getDeviceBeerList(), device.b));
+ $newDevice.append(generateSelect(getDeviceSlotList(), device.i));
+ $newDevice.append(generateSelect(getDeviceFunctionList(), device.f));
+ $newDevice.append(generateSelect(getDeviceHwTypeList(), device.h));
+ $newDevice.append(generateSelect(getDeviceTypeList(), device.t));
+ $newDevice.append(generateSelect(getDevicePinList(), device.p));
+ $newDevice.append(generateSelect([{ val: 0, text: 'not inverted'}, {val: 1, text: 'inverted'}], device.x));
+ if((typeof device.a !== "undefined") ){
+ $newDevice.append("" + device.a + "");
+ }
+ if((typeof device.n !== "undefined") ){
+ $newDevice.append(generateSelect([{ val: 0, text: 'pin 0'}, {val: 1, text: 'pin 1'}], device.x));
+ }
+ if((typeof device.v !== "undefined") ){
+ $newDevice.append("" + device.v + "");
+ }
+ // add the device to the device list div
+ $newDevice.appendTo(".device-list");
+}
+
+function getDeviceFunctionList(){
+ "use strict";
+ // currently unsupported/unused devices commented out
+ var list = [
+ {val : 0, text: 'None'},
+ {val : 1, text: 'Chamber Door'},
+ {val : 2, text: 'Chamber Heater'},
+ {val : 3, text: 'Chamber Cooler'},
+ {val : 4, text: 'Chamber Light'},
+ {val : 5, text: 'Chamber Temp'},
+ {val : 6, text: 'Ambient Temp'},
+ {val : 7, text: 'Chamber Fan'},
+ /*{val : 8, text: 'Chamber Reserved 1'},*/
+ {val : 9, text: 'Beer Temp'}/*,
+ {val : 10, text: 'Beer Temperature 2'},
+ {val : 11, text: 'Beer Heater'},
+ {val : 12, text: 'Beer Cooler'},
+ {val : 13, text: 'Beer S.G.'},
+ {val : 14, text: 'Beer Reserved 1'},
+ {val : 15, text: 'Beer Reserved 2'} */
+ ];
+ return list;
+}
+
+function getDeviceHwTypeList(){
+ "use strict";
+ // currently unsupported/unused devices commented out
+ var list = [
+ {val : 0, text: 'None'},
+ {val : 1, text: 'Digital Pin'},
+ {val : 2, text: 'Temp Sensor'},
+ {val : 3, text: 'DS2413'}
+ ];
+ return list;
+}
+
+function getDeviceTypeList(){
+ "use strict";
+ // currently unsupported/unused devices commented out
+ var list = [
+ {val : 0, text: 'None'},
+ {val : 1, text: 'Temp Sensor'},
+ {val : 2, text: 'Switch Sensor'},
+ {val : 3, text: 'Switch Actuator'}
+ ];
+ return list;
+}
+
+function getDevicePinList(){
+ "use strict";
+ // currently unsupported/unused devices commented out
+ var list = [
+ {val : 0, text: '0'},
+ {val : 1, text: '1'},
+ {val : 2, text: '2'},
+ {val : 3, text: '3'},
+ {val : 4, text: '4'},
+ {val : 5, text: '5'},
+ {val : 6, text: '6'},
+ {val : 7, text: '7'},
+ {val : 8, text: '8'},
+ {val : 9, text: '9'},
+ {val : 10, text: '10'},
+ {val : 11, text: '11'},
+ {val : 12, text: '12'},
+ {val : 13, text: '13'},
+ // Analog pins for leonardo
+ {val: 18, text: 'A0'},
+ {val: 19, text: 'A1'},
+ {val: 20, text: 'A2'},
+ {val: 21, text: 'A3'},
+ {val: 22, text: 'A4'},
+ {val: 23, text: 'A5'}
+
+ /* Standard TODO: automatically switch
+ {val: 14 text: 'A0'},
+ {val: 15 text: 'A1'},
+ {val: 16 text: 'A2'},
+ {val: 17 text: 'A3'},
+ {val: 18 text: 'A4'},
+ {val: 19 text: 'A5'},
+ {val: 20 text: 'A6'},
+ {val: 21 text: 'A7'} */
+
+ ];
+ return list;
+}
+
+function getDeviceSlotList(){
+ "use strict";
+ var maxDevices = 15;
+ var list = [ {val: -1, text: 'Unassigned'}];
+ for(var i = 0; i <= maxDevices; i++){
+ list.push({val: i, text: i.toString()});
+ }
+ return list;
+}
+
+function getDeviceChamberList(){
+ "use strict";
+ var maxChambers = 1;
+ var list = [ {val: 0, text: 'Unassigned'}];
+ for(var i = 1; i <= maxChambers; i++){
+ list.push({val: i, text: i.toString()});
+ }
+ return list;
+}
+
+function getDeviceBeerList(){
+ "use strict";
+ var maxBeers = 1;
+ var list = [ {val: 0, text: 'Chamber device'}];
+ for(var i = 1; i <= maxBeers; i++){
+ list.push({val: i, text: i.toString()});
+ }
+ return list;
+}
+
+function getDeviceCalibrateList(){
+ "use strict";
+ var minCalibrate = 1;
+ var list = [ {val: 0, text: 'Chamber device'}];
+ for(var i = 1; i <= maxBeers; i++){
+ list.push({val: i, text: i.toString()});
+ }
+ return list;
+}
+
+function generateSelect(list, selected){
+ "use strict";
+ var sel = $('