Set light from UI

This commit is contained in:
Matt 2016-04-13 00:06:19 -04:00
parent 3fea43d0ea
commit 680bd4ea3f
6 changed files with 98 additions and 40 deletions

View File

@ -6,11 +6,9 @@
} }
#log { #log {
position: fixed; position: fixed;
width: 600px; width: 100%;
height: 150px; height: 150px;
} }
#status { .screen {
position: fixed; display: none;
width: 100px;
right: 0;
} }

View File

@ -1,5 +1,3 @@
#footer{ #footer{
position: fixed; position: fixed;
bottom: 0; bottom: 0;
@ -9,12 +7,10 @@
#log{ #log{
position: fixed; position: fixed;
width: 600px; width: 100%;
height: 150px; height: 150px;
} }
#status{ .screen{
position: fixed; display: none;
width: 100px;
right: 0;
} }

View File

@ -12,11 +12,13 @@
<body onload="init();"> <body onload="init();">
<nav id="toolbar"></nav> <nav id="toolbar"></nav>
<div id="screens"> <div id="screens">
<div id="controls" class="screen">
</div>
<div id="light">
<div id="colors"></div>
<div id="colors-content"><div>
</div>
</div> </div>
<footer id="footer">
<div id="log"></div>
</div id="status"></div>
</footer>
<script src="./js/app.js"></script> <script src="./js/app.js"></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@ -18,6 +18,7 @@ var init = function () {
'use strict'; 'use strict';
createWindow(); createWindow();
log.init(); log.init();
setTimeout(function () {
mcopy.arduino.init(function (err, device) { mcopy.arduino.init(function (err, device) {
if (err) { if (err) {
log.info(err, 'SERIAL', false, true); log.info(err, 'SERIAL', false, true);
@ -28,6 +29,7 @@ var init = function () {
}); });
} }
}); });
}, 1000);
}; };
var createMenu = function () { var createMenu = function () {
@ -59,10 +61,20 @@ app.on('activate', function () {
}); });
ipcMain.on('light', function(event, arg) { ipcMain.on('light', function(event, arg) {
// light.set(arg);
event.returnValue = true; event.returnValue = true;
}); });
var light = {};
light.set = function (color) {
'use strict';
var str = color.join(',');
mcopy.arduino.send(mcopy.cfg.arduino.cmd.light, function () {
log.info('Light set to ' + str, 'LIGHT', true, true);
});
mcopy.arduino.string(str);
};
var log = {}; var log = {};
log.time = 'MM/DD/YY-HH:mm:ss'; log.time = 'MM/DD/YY-HH:mm:ss';
log.transport = new (winston.Logger)({ log.transport = new (winston.Logger)({
@ -77,7 +89,7 @@ log.init = function () {
}; };
log.display = function (obj) { log.display = function (obj) {
'use strict'; 'use strict';
ipcMain.sendSync('log', obj); mainWindow.webContents.send('log', obj);
}; };
log.listen = function () { log.listen = function () {
'use strict'; 'use strict';

View File

@ -1,4 +1,5 @@
var ipcRenderer = require('electron').ipcRenderer, var remote = require('remote'),
ipcRenderer = require('electron').ipcRenderer,
light = {}, light = {},
log = {}; log = {};
//console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) ); //console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) );
@ -19,12 +20,13 @@ log.init = function () {
}); });
//{ recid: 1, time: moment().format(log.time), action: 'Started app', service: 'MAIN', status: true } //{ recid: 1, time: moment().format(log.time), action: 'Started app', service: 'MAIN', status: true }
log.info('Started app', 'MAIN', true); log.info('Started app', 'MAIN', true);
log.listen();
}; };
log.listen = function () { log.listen = function () {
ipcRender.on('log', function (event, arg) { 'use strict';
console.log(arg); ipcRenderer.on('log', function (event, arg) {
//log.display(arg.action, arg.service, arg.status, arg.time); log.display(arg.action, arg.service, arg.status, arg.time);
return event.returnValue = true; return event.returnValue = true;
}); });
}; };
@ -42,7 +44,11 @@ log.display = function (action, service, status, time) {
obj.time = moment().format(log.time); obj.time = moment().format(log.time);
} }
w2ui['log'].add(obj); w2ui['log'].add(obj);
$('#log').animate({ scrollTop: $('#log').prop('scrollHeight')}, 100); setTimeout(function () {
$('#grid_log_table').animate({
scrollTop: $('#grid_log_table').prop('scrollHeight')
}, 0);
}, 1);
return obj; return obj;
}; };
@ -58,6 +64,21 @@ log.info = function (action, service, status, time) {
console.log(obj); console.log(obj);
}; };
light.init = function () {
$('#colors').w2tabs({
name: 'colors',
active: 'rgb',
tabs: [
{ id: 'rgb', caption: 'RGB' },
{ id: 'cmy', caption: 'CMY'},
{ id: 'kelvin', caption: 'Kelvin'}
],
onClick: function (event) {
$('#colors-content').html('Tab: ' + event.target);
}
});
};
//color = [0,0,0] //color = [0,0,0]
light.set = function (color) { light.set = function (color) {
'use strict'; 'use strict';
@ -77,7 +98,11 @@ var init = function () {
{ type: 'radio', id: 'item4', group: '1', caption: 'Light', icon: 'fa-star-empty' }, { type: 'radio', id: 'item4', group: '1', caption: 'Light', icon: 'fa-star-empty' },
{ type: 'spacer' }, { type: 'spacer' },
{ type: 'button', id: 'item5', group: '1', caption: 'Settings', icon: 'fa-home' } { type: 'button', id: 'item5', group: '1', caption: 'Settings', icon: 'fa-home' }
] ],
onClick : function (event) {
}
}); });
log.init(); log.init();
light.init();
}; };