diff --git a/bin/index.js b/bin/index.js index 27716e5..90574f0 100644 --- a/bin/index.js +++ b/bin/index.js @@ -29,6 +29,7 @@ var ScreenManager = function () { this.plugins = []; this.registerPlugin("pushBullet"); + this.registerPlugin("nextion"); } _createClass(ScreenManager, [{ diff --git a/bin/plugins/nextion.js b/bin/plugins/nextion.js index 1e5ba1e..8d491b4 100644 --- a/bin/plugins/nextion.js +++ b/bin/plugins/nextion.js @@ -58,18 +58,20 @@ var Confirm = function (_abstract) { this.isPrinting = null; this.currentPageId = null; - _context.next = 4; + console.log("connect to port " + this.config.plugins.nextion.port); + + _context.next = 5; return this.nextion.connect(); - case 4: + case 5: console.log("connected"); - this.update().catch(function (e) { + this.update(this.status, this.log).catch(function (e) { return console.error(e); }); - case 6: + case 7: case "end": return _context.stop(); } @@ -91,29 +93,38 @@ var Confirm = function (_abstract) { while (1) { switch (_context2.prev = _context2.next) { case 0: + if (status) { + _context2.next = 2; + break; + } + + return _context2.abrupt("return"); + + case 2: + this.status = status; this.log = log; clearTimeout(this.updateTimeOut); if (!(status.Printing !== this.isPrinting)) { - _context2.next = 7; + _context2.next = 9; break; } this.isPrinting = status.Printing; - _context2.next = 7; + _context2.next = 9; return this.setPage("home"); - case 7: + case 9: this.isPrinting = status.Printing; - _context2.next = 10; + _context2.next = 12; return this.currentPage.update(status, log).catch(function (e) { return console.error(e); }); - case 10: + case 12: case "end": return _context2.stop(); } diff --git a/config.json b/config.json index 4f48666..0b431ec 100644 --- a/config.json +++ b/config.json @@ -1,11 +1,11 @@ { - "url":"http://192.168.1.22", + "url":"http://localhost", "plugins":{ "nextion":{ "port":"/dev/ttyAMA0" }, "pushbullet":{ - "apiKey":"o.a59EmgDvPbYR9qjn9yxp60KXtTFN11Pd" + "apiKey":null } } } diff --git a/src/index.js b/src/index.js index 8462ed0..4053eed 100644 --- a/src/index.js +++ b/src/index.js @@ -14,6 +14,7 @@ class ScreenManager{ this.plugins = []; this.registerPlugin("pushBullet"); + this.registerPlugin("nextion"); } async init(){ diff --git a/src/plugins/nextion.js b/src/plugins/nextion.js index be83139..ecc5b51 100644 --- a/src/plugins/nextion.js +++ b/src/plugins/nextion.js @@ -19,15 +19,20 @@ export default class Confirm extends abstract{ async init(){ this.isPrinting = null; this.currentPageId = null; - + + console.log("connect to port "+this.config.plugins.nextion.port); + await this.nextion.connect(); console.log("connected"); - this.update().catch(e=>console.error(e)); + this.update(this.status, this.log).catch(e=>console.error(e)); } async update(status, log){ + if(!status) + return + this.status = status; this.log = log;