Skip to content

Commit

Permalink
fix nextion connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Tibus committed Jul 10, 2017
1 parent 16eb0da commit 1fece90
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
1 change: 1 addition & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var ScreenManager = function () {
this.plugins = [];

this.registerPlugin("pushBullet");
this.registerPlugin("nextion");
}

_createClass(ScreenManager, [{
Expand Down
29 changes: 20 additions & 9 deletions bin/plugins/nextion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"url":"http://192.168.1.22",
"url":"http://localhost",
"plugins":{
"nextion":{
"port":"/dev/ttyAMA0"
},
"pushbullet":{
"apiKey":"o.a59EmgDvPbYR9qjn9yxp60KXtTFN11Pd"
"apiKey":null
}
}
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ScreenManager{
this.plugins = [];

this.registerPlugin("pushBullet");
this.registerPlugin("nextion");
}

async init(){
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/nextion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 1fece90

Please sign in to comment.