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 {
position: fixed;
width: 600px;
width: 100%;
height: 150px;
}
#status {
position: fixed;
width: 100px;
right: 0;
.screen {
display: none;
}

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

@ -1,4 +1,5 @@
var ipcRenderer = require('electron').ipcRenderer,
var remote = require('remote'),
ipcRenderer = require('electron').ipcRenderer,
light = {},
log = {};
//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 }
log.info('Started app', 'MAIN', true);
log.listen();
};
log.listen = function () {
ipcRender.on('log', function (event, arg) {
console.log(arg);
//log.display(arg.action, arg.service, arg.status, arg.time);
'use strict';
ipcRenderer.on('log', function (event, arg) {
log.display(arg.action, arg.service, arg.status, arg.time);
return event.returnValue = true;
});
};
@ -42,7 +44,11 @@ log.display = function (action, service, status, time) {
obj.time = moment().format(log.time);
}
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;
};
@ -58,6 +64,21 @@ log.info = function (action, service, status, time) {
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]
light.set = function (color) {
'use strict';
@ -77,7 +98,11 @@ var init = function () {
{ type: 'radio', id: 'item4', group: '1', caption: 'Light', icon: 'fa-star-empty' },
{ type: 'spacer' },
{ type: 'button', id: 'item5', group: '1', caption: 'Settings', icon: 'fa-home' }
]
],
onClick : function (event) {
}
});
log.init();
light.init();
};