2016-04-12 03:05:05 +00:00
|
|
|
var electron = require('electron'),
|
2016-04-11 14:49:57 +00:00
|
|
|
fs = require('fs'),
|
|
|
|
Menu = require('menu'),
|
|
|
|
ipcMain = require('electron').ipcMain,
|
|
|
|
app = electron.app,
|
|
|
|
BrowserWindow = electron.BrowserWindow,
|
|
|
|
uuid = require('node-uuid'),
|
|
|
|
mcopy = {};
|
2016-04-11 06:01:26 +00:00
|
|
|
|
2016-04-12 03:05:05 +00:00
|
|
|
mcopy.cfg = JSON.parse(fs.readFileSync('./cfg.json', 'utf8'));
|
|
|
|
mcopy.arduino = require('./lib/mcopy-arduino.js')(mcopy.cfg);
|
|
|
|
|
|
|
|
var mainWindow;
|
2016-04-11 06:01:26 +00:00
|
|
|
|
2016-04-11 14:49:57 +00:00
|
|
|
var init = function () {
|
|
|
|
createWindow();
|
2016-04-11 21:26:32 +00:00
|
|
|
mcopy.arduino.init(function (success) {
|
2016-04-12 17:57:59 +00:00
|
|
|
if (success) {
|
|
|
|
mcopy.arduino.connect(function () {
|
|
|
|
//
|
|
|
|
});
|
|
|
|
}
|
2016-04-11 21:26:32 +00:00
|
|
|
});
|
2016-04-11 14:49:57 +00:00
|
|
|
};
|
2016-04-11 06:01:26 +00:00
|
|
|
|
2016-04-11 14:49:57 +00:00
|
|
|
var createMenu = function () {
|
2016-04-11 06:01:26 +00:00
|
|
|
|
2016-04-11 14:49:57 +00:00
|
|
|
};
|
2016-04-11 06:01:26 +00:00
|
|
|
|
2016-04-11 14:49:57 +00:00
|
|
|
var createWindow = function () {
|
|
|
|
mainWindow = new BrowserWindow({width: 800, height: 600});
|
|
|
|
mainWindow.loadURL('file://' + __dirname + '/index.html');
|
2016-04-12 17:57:59 +00:00
|
|
|
//mainWindow.webContents.openDevTools();
|
2016-04-11 14:49:57 +00:00
|
|
|
mainWindow.on('closed', function() {
|
|
|
|
mainWindow = null;
|
|
|
|
});
|
2016-04-11 06:01:26 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 14:49:57 +00:00
|
|
|
app.on('ready', init);
|
2016-04-11 06:01:26 +00:00
|
|
|
|
|
|
|
app.on('window-all-closed', function () {
|
2016-04-11 14:49:57 +00:00
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit();
|
|
|
|
}
|
2016-04-11 06:01:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
app.on('activate', function () {
|
2016-04-11 14:49:57 +00:00
|
|
|
if (mainWindow === null) {
|
|
|
|
createWindow();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ipcMain.on('light', function(event, arg) {
|
|
|
|
//
|
|
|
|
event.returnValue = true;
|
|
|
|
});
|