diff --git a/app/.gitignore b/app/.gitignore index 7ab50be..86134a4 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,2 +1,3 @@ +data/cfg.json node_modules/* logs/* \ No newline at end of file diff --git a/app/css/app.css b/app/css/app.css index a9c050d..64b3129 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -126,7 +126,7 @@ footer { color: #dcdcdc; } #actions { - padding: 20px; + padding: 20px 0 0 55px; } #seq_stats { width: 40%; diff --git a/app/cfg.json b/app/data/cfg.json.default similarity index 100% rename from app/cfg.json rename to app/data/cfg.json.default diff --git a/app/js/app.js b/app/js/app.js index f72aa06..179cef1 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -2446,7 +2446,7 @@ var remote = require('remote'), log = {}; //console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) ); -mcopy.cfg = JSON.parse(fs.readFileSync('./cfg.json'), 'utf8'); +mcopy.cfg = JSON.parse(fs.readFileSync('./data/cfg.json'), 'utf8'); /****** State shared by ALL interfaces @@ -2546,7 +2546,7 @@ gui.grid = {}; gui.grid.layout = function () { 'use strict'; gui.grid.refresh(); - mcopy.seq.stats(); + //mcopy.seq.stats(); }; gui.grid.state = function (i) { 'use strict'; @@ -2747,7 +2747,7 @@ nav.init = function () { $('#toolbar').w2toolbar({ name: 'toolbar', items: [ - { type: 'radio', id: 'sequence', group: '1', caption: 'Sequence', icon: 'fa fa-th', checked: true }, + { type: 'radio', id: 'sequencer', group: '1', caption: 'Sequencer', icon: 'fa fa-th', checked: true }, { type: 'radio', id: 'script', group: '1', caption: 'Script', icon: 'fa fa-code' }, { type: 'radio', id: 'controls', group: '1', caption: 'Controls', icon: 'fa fa-tasks' }, { type: 'radio', id: 'light', group: '1', caption: 'Light', icon: 'mcopy-light' }, diff --git a/app/main.js b/app/main.js index 50049f3..8583600 100644 --- a/app/main.js +++ b/app/main.js @@ -10,15 +10,30 @@ var electron = require('electron'), Q = require('q'), mcopy = {}; -mcopy.cfg = JSON.parse(fs.readFileSync('./cfg.json', 'utf8')); -mcopy.arduino = require('./lib/mcopy-arduino.js')(mcopy.cfg); +mcopy.cfg = {}; +mcopy.cfgFile = './data/cfg.json'; +mcopy.cfgInit = function () { + if (!fs.existsSync(mcopy.cfgFile)) { + console.log('Using default configuration...'); + fs.writeFileSync(mcopy.cfgFile, fs.readFileSync('./data/cfg.json.default')); + } + mcopy.cfg = JSON.parse(fs.readFileSync(mcopy.cfgFile, 'utf8')); +}; +mcopy.cfgStore = function () { + var data = JSON.stringify(mcopy.cfg); + fs.writeFileSync(mcopy.cfgFile, data, 'utf8'); +}; + +var arduino; var mainWindow; var init = function () { 'use strict'; + mcopy.cfgInit(); createWindow(); log.init(); + arduino = require('./lib/mcopy-arduino.js')(mcopy.cfg); setTimeout(function () { mcopy.arduino.init(function (err, device) { if (err) { @@ -75,11 +90,11 @@ light.set = function (rgb) { 'use strict'; var str = rgb.join(','), deferred = Q.defer(); - mcopy.arduino.send(mcopy.cfg.arduino.cmd.light, function () { + arduino.send(mcopy.cfg.arduino.cmd.light, function () { log.info('Light set to ' + str, 'LIGHT', true, true); return deferred.resolve(mcopy.cfg.arduino.cmd.light); }); - mcopy.arduino.string(str); + arduino.string(str); return deferred.promise; }; diff --git a/app/src/index.js b/app/src/index.js index de5faf5..2cd23c8 100644 --- a/app/src/index.js +++ b/app/src/index.js @@ -9,7 +9,7 @@ var remote = require('remote'), log = {}; //console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) ); -mcopy.cfg = JSON.parse(fs.readFileSync('./cfg.json'), 'utf8'); +mcopy.cfg = JSON.parse(fs.readFileSync('./data/cfg.json'), 'utf8'); /****** State shared by ALL interfaces @@ -109,7 +109,7 @@ gui.grid = {}; gui.grid.layout = function () { 'use strict'; gui.grid.refresh(); - mcopy.seq.stats(); + //mcopy.seq.stats(); }; gui.grid.state = function (i) { 'use strict'; @@ -310,7 +310,7 @@ nav.init = function () { $('#toolbar').w2toolbar({ name: 'toolbar', items: [ - { type: 'radio', id: 'sequence', group: '1', caption: 'Sequence', icon: 'fa fa-th', checked: true }, + { type: 'radio', id: 'sequencer', group: '1', caption: 'Sequencer', icon: 'fa fa-th', checked: true }, { type: 'radio', id: 'script', group: '1', caption: 'Script', icon: 'fa fa-code' }, { type: 'radio', id: 'controls', group: '1', caption: 'Controls', icon: 'fa fa-tasks' }, { type: 'radio', id: 'light', group: '1', caption: 'Light', icon: 'mcopy-light' },