├── photo.jpg ├── hardware.jpg ├── tjc ├── hmi │ ├── 5.HMI │ ├── 2.4.HMI │ ├── 2.8.HMI │ ├── 3.2.HMI │ └── 3.5.HMI └── tft │ ├── 5.tft │ ├── 2.4.tft │ ├── 2.8.tft │ ├── 3.2.tft │ └── 3.5.tft ├── nextion ├── hmi │ ├── 2.4.HMI │ ├── 2.8.HMI │ ├── 3.2.HMI │ ├── 3.5.HMI │ └── 5.HMI ├── tft │ ├── 2.4.tft │ ├── 2.8.tft │ ├── 3.2.tft │ ├── 3.5.tft │ ├── 5.tft │ ├── 5_enhanced.tft │ ├── 2.4_enhanced.tft │ ├── 2.8_enhanced.tft │ ├── 3.2_enhanced.tft │ └── 3.5_enhanced.tft ├── images │ ├── no.png │ ├── home.png │ ├── homes.jpg │ ├── next.png │ ├── nexts.jpg │ ├── nos.png │ ├── prev.png │ ├── prevs.jpg │ ├── trash.png │ ├── yes.png │ ├── yess.png │ ├── zaxis.png │ ├── create.png │ ├── creates.jpg │ ├── printer.png │ ├── reboot.png │ ├── trashs.jpg │ ├── treboot.png │ ├── tzaxis.png │ ├── tzaxiss.png │ ├── printcnt.png │ ├── printcnts.jpg │ ├── printers.jpg │ ├── projector.png │ ├── settings.png │ ├── settingss.jpg │ ├── shutdown.png │ ├── timeline.png │ ├── timelines.jpg │ ├── tprojector.png │ ├── treboots.png │ ├── tsettings.png │ ├── tsettingss.png │ ├── tshutdown.png │ ├── tshutdowns.png │ ├── tview_list.png │ ├── view_list.png │ ├── view_lists.jpg │ ├── visibility.png │ ├── tprojectors.png │ ├── tview_lists.png │ ├── treboot_240x320.png │ ├── tzaxis_240x320.png │ ├── tzaxiss_240x320.png │ ├── treboots_240x320.png │ ├── tsettings_240x320.png │ ├── tshutdown_240x320.png │ ├── tprojector_240x320.png │ ├── tprojectors_240x320.png │ ├── tsettingss_240x320.png │ ├── tshutdowns_240x320.png │ ├── tview_list_240x320.png │ └── tview_lists_240x320.png └── fonts │ ├── arial.zi │ ├── arialBold.zi │ └── arialHeaders24.zi ├── setup.sh ├── src ├── plugins │ ├── abstract.js │ ├── nextion │ │ ├── pages │ │ │ ├── ipqr.js │ │ │ ├── confirm.js │ │ │ ├── stats.js │ │ │ ├── settings.js │ │ │ ├── abstract.js │ │ │ ├── projector.js │ │ │ ├── home.js │ │ │ ├── printingHome.js │ │ │ ├── plates.js │ │ │ ├── plate.js │ │ │ ├── printSettings.js │ │ │ ├── zAxis.js │ │ │ └── addPlate.js │ │ └── nextionService.js │ ├── pushBullet.js │ └── nextion.js ├── index.js └── services │ ├── utils │ ├── stl2png.js │ └── threejs-extras │ │ └── STLLoader.js │ └── nanoDlpService.js ├── config.json ├── LICENSE ├── gulpfile.js ├── package.json ├── README.md └── bin ├── plugins ├── abstract.js ├── nextion │ └── pages │ │ ├── ipqr.js │ │ ├── confirm.js │ │ ├── stats.js │ │ ├── settings.js │ │ ├── projector.js │ │ ├── plates.js │ │ ├── home.js │ │ ├── abstract.js │ │ ├── printingHome.js │ │ ├── plate.js │ │ ├── printSettings.js │ │ └── zAxis.js ├── pushBullet.js └── nextion.js ├── index.js └── services └── utils ├── stl2png.js └── threejs-extras └── STLLoader.js /photo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/photo.jpg -------------------------------------------------------------------------------- /hardware.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/hardware.jpg -------------------------------------------------------------------------------- /tjc/hmi/5.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/hmi/5.HMI -------------------------------------------------------------------------------- /tjc/tft/5.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/tft/5.tft -------------------------------------------------------------------------------- /tjc/hmi/2.4.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/hmi/2.4.HMI -------------------------------------------------------------------------------- /tjc/hmi/2.8.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/hmi/2.8.HMI -------------------------------------------------------------------------------- /tjc/hmi/3.2.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/hmi/3.2.HMI -------------------------------------------------------------------------------- /tjc/hmi/3.5.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/hmi/3.5.HMI -------------------------------------------------------------------------------- /tjc/tft/2.4.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/tft/2.4.tft -------------------------------------------------------------------------------- /tjc/tft/2.8.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/tft/2.8.tft -------------------------------------------------------------------------------- /tjc/tft/3.2.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/tft/3.2.tft -------------------------------------------------------------------------------- /tjc/tft/3.5.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/tjc/tft/3.5.tft -------------------------------------------------------------------------------- /nextion/hmi/2.4.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/hmi/2.4.HMI -------------------------------------------------------------------------------- /nextion/hmi/2.8.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/hmi/2.8.HMI -------------------------------------------------------------------------------- /nextion/hmi/3.2.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/hmi/3.2.HMI -------------------------------------------------------------------------------- /nextion/hmi/3.5.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/hmi/3.5.HMI -------------------------------------------------------------------------------- /nextion/hmi/5.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/hmi/5.HMI -------------------------------------------------------------------------------- /nextion/tft/2.4.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/2.4.tft -------------------------------------------------------------------------------- /nextion/tft/2.8.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/2.8.tft -------------------------------------------------------------------------------- /nextion/tft/3.2.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/3.2.tft -------------------------------------------------------------------------------- /nextion/tft/3.5.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/3.5.tft -------------------------------------------------------------------------------- /nextion/tft/5.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/5.tft -------------------------------------------------------------------------------- /nextion/images/no.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/no.png -------------------------------------------------------------------------------- /nextion/fonts/arial.zi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/fonts/arial.zi -------------------------------------------------------------------------------- /nextion/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/home.png -------------------------------------------------------------------------------- /nextion/images/homes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/homes.jpg -------------------------------------------------------------------------------- /nextion/images/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/next.png -------------------------------------------------------------------------------- /nextion/images/nexts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/nexts.jpg -------------------------------------------------------------------------------- /nextion/images/nos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/nos.png -------------------------------------------------------------------------------- /nextion/images/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/prev.png -------------------------------------------------------------------------------- /nextion/images/prevs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/prevs.jpg -------------------------------------------------------------------------------- /nextion/images/trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/trash.png -------------------------------------------------------------------------------- /nextion/images/yes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/yes.png -------------------------------------------------------------------------------- /nextion/images/yess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/yess.png -------------------------------------------------------------------------------- /nextion/images/zaxis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/zaxis.png -------------------------------------------------------------------------------- /nextion/fonts/arialBold.zi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/fonts/arialBold.zi -------------------------------------------------------------------------------- /nextion/images/create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/create.png -------------------------------------------------------------------------------- /nextion/images/creates.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/creates.jpg -------------------------------------------------------------------------------- /nextion/images/printer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/printer.png -------------------------------------------------------------------------------- /nextion/images/reboot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/reboot.png -------------------------------------------------------------------------------- /nextion/images/trashs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/trashs.jpg -------------------------------------------------------------------------------- /nextion/images/treboot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/treboot.png -------------------------------------------------------------------------------- /nextion/images/tzaxis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tzaxis.png -------------------------------------------------------------------------------- /nextion/images/tzaxiss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tzaxiss.png -------------------------------------------------------------------------------- /nextion/tft/5_enhanced.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/5_enhanced.tft -------------------------------------------------------------------------------- /nextion/images/printcnt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/printcnt.png -------------------------------------------------------------------------------- /nextion/images/printcnts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/printcnts.jpg -------------------------------------------------------------------------------- /nextion/images/printers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/printers.jpg -------------------------------------------------------------------------------- /nextion/images/projector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/projector.png -------------------------------------------------------------------------------- /nextion/images/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/settings.png -------------------------------------------------------------------------------- /nextion/images/settingss.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/settingss.jpg -------------------------------------------------------------------------------- /nextion/images/shutdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/shutdown.png -------------------------------------------------------------------------------- /nextion/images/timeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/timeline.png -------------------------------------------------------------------------------- /nextion/images/timelines.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/timelines.jpg -------------------------------------------------------------------------------- /nextion/images/tprojector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tprojector.png -------------------------------------------------------------------------------- /nextion/images/treboots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/treboots.png -------------------------------------------------------------------------------- /nextion/images/tsettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tsettings.png -------------------------------------------------------------------------------- /nextion/images/tsettingss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tsettingss.png -------------------------------------------------------------------------------- /nextion/images/tshutdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tshutdown.png -------------------------------------------------------------------------------- /nextion/images/tshutdowns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tshutdowns.png -------------------------------------------------------------------------------- /nextion/images/tview_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tview_list.png -------------------------------------------------------------------------------- /nextion/images/view_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/view_list.png -------------------------------------------------------------------------------- /nextion/images/view_lists.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/view_lists.jpg -------------------------------------------------------------------------------- /nextion/images/visibility.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/visibility.png -------------------------------------------------------------------------------- /nextion/tft/2.4_enhanced.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/2.4_enhanced.tft -------------------------------------------------------------------------------- /nextion/tft/2.8_enhanced.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/2.8_enhanced.tft -------------------------------------------------------------------------------- /nextion/tft/3.2_enhanced.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/3.2_enhanced.tft -------------------------------------------------------------------------------- /nextion/tft/3.5_enhanced.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/tft/3.5_enhanced.tft -------------------------------------------------------------------------------- /nextion/fonts/arialHeaders24.zi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/fonts/arialHeaders24.zi -------------------------------------------------------------------------------- /nextion/images/tprojectors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tprojectors.png -------------------------------------------------------------------------------- /nextion/images/tview_lists.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tview_lists.png -------------------------------------------------------------------------------- /nextion/images/treboot_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/treboot_240x320.png -------------------------------------------------------------------------------- /nextion/images/tzaxis_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tzaxis_240x320.png -------------------------------------------------------------------------------- /nextion/images/tzaxiss_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tzaxiss_240x320.png -------------------------------------------------------------------------------- /nextion/images/treboots_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/treboots_240x320.png -------------------------------------------------------------------------------- /nextion/images/tsettings_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tsettings_240x320.png -------------------------------------------------------------------------------- /nextion/images/tshutdown_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tshutdown_240x320.png -------------------------------------------------------------------------------- /nextion/images/tprojector_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tprojector_240x320.png -------------------------------------------------------------------------------- /nextion/images/tprojectors_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tprojectors_240x320.png -------------------------------------------------------------------------------- /nextion/images/tsettingss_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tsettingss_240x320.png -------------------------------------------------------------------------------- /nextion/images/tshutdowns_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tshutdowns_240x320.png -------------------------------------------------------------------------------- /nextion/images/tview_list_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tview_list_240x320.png -------------------------------------------------------------------------------- /nextion/images/tview_lists_240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tibus/TouchScreen-For-NanoDLP/HEAD/nextion/images/tview_lists_240x320.png -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | wget -O - https://raw.githubusercontent.com/sdesalas/node-pi-zero/master/install-node-v6.4.0.sh | bash 2 | sudo sed -i.bak "1i#\!/bin/sh \-e\nnode /home/pi/nextion/bin/index.js 2> /home/pi/nextion/errorOutput.log > /home/pi/nextion/output.log &" /etc/rc.local 3 | npm install -G babel-polyfill pngjs pushbullet request-promise-native serialport sharp three debug 4 | -------------------------------------------------------------------------------- /src/plugins/abstract.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | import config from "../../config.json"; 3 | 4 | export default class AbstractPlugin{ 5 | 6 | constructor(manager){ 7 | this.manager = manager; 8 | this.nanoDLP = manager.nanoDLP; 9 | this.config = config; 10 | } 11 | 12 | async init(){ 13 | 14 | } 15 | 16 | async update(status){ 17 | 18 | } 19 | 20 | dispose(){ 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "url":"http://localhost", 3 | "auth":{ 4 | "enable":"false", 5 | "user":"admin", 6 | "pass":"pass" 7 | }, 8 | "plugins":{ 9 | "nextion":{ 10 | "port":"/dev/ttyAMA0", 11 | "sleep": 65535 12 | }, 13 | "plates":{ 14 | "fileExt":"stl|slc|svg|zip", 15 | "showAll":"false", 16 | "autoFetch":"true" 17 | }, 18 | "pushbullet":{ 19 | "apiKey":null 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/ipqr.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | import abstract from "./abstract.js"; 3 | 4 | export default class Confirm extends abstract{ 5 | 6 | constructor(screenManager){ 7 | super(screenManager); 8 | } 9 | 10 | async init(options){ 11 | await this.setScreen("ipQR"); 12 | await this.setText("t1", options.text); 13 | await this.setText("qr2", options.text); 14 | 15 | this.addListener("click_b3", (e)=>{ 16 | this.changePage("home"); 17 | }); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/confirm.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | import abstract from "./abstract.js"; 3 | 4 | export default class Confirm extends abstract{ 5 | 6 | constructor(screenManager){ 7 | super(screenManager); 8 | } 9 | 10 | async init(options){ 11 | await this.setScreen("confirm"); 12 | await this.setText("t0", options.text); 13 | 14 | this.addListener("click_b1", (e)=>{ 15 | this.changePage(options.returnPage, {confirmType:options.confirmType, confirmResult:true, data0:options.data0, data1:options.data1, data2:options.data2}); 16 | }); 17 | 18 | this.addListener("click_b2", (e)=>{ 19 | this.changePage(options.returnPage, {confirmType:options.confirmType, confirmResult:false, data0:options.data0, data1:options.data1, data2:options.data2}); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/stats.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | 3 | import PNG from "png-js"; 4 | import abstract from "./abstract.js"; 5 | 6 | export default class Stats extends abstract{ 7 | 8 | constructor(screenManager){ 9 | super(screenManager) 10 | } 11 | 12 | async init(){ 13 | await this.setScreen("stats"); 14 | 15 | this.addListener("click_b11", (e)=>{ 16 | this.changePage("home"); 17 | }); 18 | } 19 | 20 | async update(status){ 21 | this.setText("t1", status.proc); 22 | this.setText("t2", status.mem); 23 | this.setText("t5", Math.ceil(parseInt(status.temp))+"°C"); 24 | 25 | this.nextion.addToWaveForm(3, 0, parseInt(status.proc)); 26 | this.nextion.addToWaveForm(5, 0, parseInt(status.mem)); 27 | this.nextion.addToWaveForm(6, 0, Math.ceil(parseInt(status.temp))); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/settings.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | 3 | import abstract from "./abstract.js"; 4 | 5 | export default class Settings extends abstract{ 6 | 7 | constructor(screenManager){ 8 | super(screenManager); 9 | } 10 | 11 | async init(){ 12 | await this.setScreen("settings"); 13 | 14 | this.addListener("click_b4", (e)=>{ 15 | this.changePage("home"); 16 | }); 17 | 18 | this.addListener("click_b2", (e)=>{ 19 | this.changePage("zAxis"); 20 | }); 21 | 22 | this.addListener("click_b3", (e)=>{ 23 | this.changePage("projector"); 24 | }); 25 | } 26 | 27 | async update(status){ 28 | this.setText("t1", status.proc); 29 | this.setText("t2", status.mem); 30 | this.setText("t5", Math.ceil(parseInt(status.temp))+"°C"); 31 | 32 | this.nextion.addToWaveForm(13, 0, parseInt(status.proc)); 33 | this.nextion.addToWaveForm(12, 0, parseInt(status.mem)); 34 | this.nextion.addToWaveForm(11, 0, Math.ceil(parseInt(status.temp))); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Julien Delnatte 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/plugins/pushBullet.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | import abstract from "./abstract.js"; 3 | import pushBullet from "pushbullet"; 4 | 5 | export default class PushBulletClass extends abstract{ 6 | 7 | constructor(screenManager){ 8 | super(screenManager); 9 | 10 | let PushBullet = require('pushbullet'); 11 | console.log(this.config.plugins, this.config.plugins.pushbullet); 12 | if(this.config.plugins.pushbullet && this.config.plugins.pushbullet.apiKey != null){ 13 | this.pusher = new PushBullet(this.config.plugins.pushbullet.apiKey); 14 | }else{ 15 | console.error("missing API key for pushbullet"); 16 | } 17 | 18 | this.isPrinting = null; 19 | } 20 | 21 | async update(status, log){ 22 | if(this.pusher == null) 23 | return; 24 | 25 | if(this.isPrinting == null) 26 | this.isPrinting = status.Printing; 27 | 28 | if(this.isPrinting != status.Printing){ 29 | console.log(this.isPrinting, status.Printing); 30 | let title = status.Printing?"print started":"print finished"; 31 | this.pusher.note({}, title, title, function(error, response) { 32 | 33 | }); 34 | 35 | this.isPrinting = status.Printing; 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require("gulp"); 2 | var plumber = require("gulp-plumber"); 3 | var gutil = require("gulp-util"); 4 | var babel = require("gulp-babel"); 5 | var del = require('del'); 6 | 7 | gulp.task('clean', function(cb) { 8 | return del('bin/**', cb); 9 | }); 10 | 11 | gulp.task( "build-compile", function(){ 12 | gulp.src( "src/**/*.js" ) 13 | .pipe(plumber()) 14 | .pipe( babel( { 15 | "presets": [ "es2015" ], 16 | "plugins": [ "array-includes", "transform-async-to-generator", "syntax-flow", 17 | "transform-decorators-legacy", 18 | "transform-flow-strip-types" ] 19 | } ) ) 20 | .on('error', (err) => { 21 | gutil.log(gutil.colors.red('[Compilation Error]')); 22 | gutil.log(gutil.colors.red(err.message)); 23 | }) 24 | .pipe( gulp.dest( "bin" ) ); 25 | }); 26 | 27 | gulp.task( "build-copy", function(){ 28 | gulp.src( "src/**/*.json" ) 29 | .pipe( gulp.dest( "bin" ) ); 30 | }); 31 | 32 | 33 | gulp.task( "build", ["build-compile", "build-copy"]); 34 | 35 | //gulp.task( "docs", task( "apidoc" ) ); 36 | 37 | gulp.task( "watch", function() { 38 | gulp.watch( "src/**/*.js", [ "build" ] ); 39 | gulp.watch( "src/**/*.json", [ "build" ] ); 40 | } ); 41 | 42 | gulp.task( "default", [ "build" ] ); 43 | gulp.task( "work", [ "build", "watch" ] ); 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "screen", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "DEBUG=nanodlp,nextion,serialport node bin/index.js", 8 | "start": "node bin/index.js" 9 | }, 10 | "devDependencies": { 11 | "babel-core": "^6.26.0", 12 | "babel-plugin-array-includes": "^2.0.3", 13 | "babel-plugin-syntax-flow": "^6.18.0", 14 | "babel-plugin-transform-decorators-legacy": "^1.3.4", 15 | "babel-plugin-transform-flow-strip-types": "^6.22.0", 16 | "babel-preset-es2015": "^6.24.1", 17 | "babel-preset-es2016": "^6.24.1", 18 | "del": "^2.2.2", 19 | "gulp": "^3.9.1", 20 | "gulp-babel": "^6.1.3", 21 | "gulp-cli": "^2.0.1", 22 | "gulp-load-plugins": "^1.2.4", 23 | "gulp-plumber": "^1.1.0", 24 | "gulp-util": "^3.0.7" 25 | }, 26 | "author": "", 27 | "license": "ISC", 28 | "dependencies": { 29 | "babel-polyfill": "^6.23.0", 30 | "babel-preset-es2017": "^6.24.1", 31 | "get-pixels": "^3.3.0", 32 | "imagemagick": "^0.1.3", 33 | "png-js": "^0.1.1", 34 | "pushbullet": "^2.0.0", 35 | "request-promise-native": "^1.0.4", 36 | "reqwest": "^2.0.5", 37 | "serialport": "^4.0.7", 38 | "sharp": "^0.18.1", 39 | "three": "^0.86.0", 40 | "xhr2": "^0.1.4", 41 | "ip": "^1.1.5", 42 | "drivelist": "^6.1.5", 43 | "child_process": "^1.0.2" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/abstract.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | 3 | export default class Abstract{ 4 | 5 | constructor(manager){ 6 | this.manager = manager; 7 | this.nextion = manager.nextion; 8 | this.nanoDLP = manager.nanoDLP; 9 | this.listener = []; 10 | this.history = {}; 11 | this.enabled = true; 12 | } 13 | 14 | addListener(event, callback){ 15 | this.listener.push({btn:event, callback:callback}); 16 | this.nextion.on(event, callback); 17 | } 18 | 19 | async setScreen(val){ 20 | await this.nextion.setPage(val); 21 | this.history = {}; 22 | } 23 | 24 | async changePage(val, options){ 25 | await this.manager.setPage(val, options); 26 | } 27 | 28 | async setText(txt, val){ 29 | if(this.history[txt] == val) 30 | return; 31 | this.history[txt] = val; 32 | await this.nextion.setText(txt, val); 33 | } 34 | 35 | async setValue(txt, val){ 36 | if(this.history[txt] == val) 37 | return; 38 | this.history[txt] = val; 39 | await this.nextion.setValue(txt, val); 40 | } 41 | 42 | async getValue(txt) { 43 | return await this.nextion.getValue(txt); 44 | } 45 | 46 | async update(status){ 47 | 48 | } 49 | 50 | dispose(){ 51 | this.enabled = false; 52 | 53 | for(let i = 0; i{ 15 | this.changePage("home"); 16 | }); 17 | 18 | this.addListener("click_b4", () => this.nanoDLP.command("/shutter/open")); 19 | this.addListener("click_b8", () => this.nanoDLP.command("/shutter/close")); 20 | 21 | this.addListener("click_b3", () => this.nanoDLP.command("/button/press/1")); 22 | this.addListener("click_b9", () => this.nanoDLP.command("/button/press/0")); 23 | 24 | this.addListener("click_b5", () => { 25 | if(this.status.Projecting) 26 | this.nanoDLP.command("/projector/blank"); 27 | else 28 | this.nanoDLP.command("/projector/generate/calibration"); 29 | }); 30 | 31 | this.addListener("click_b6", () => { 32 | if(this.status.Projecting) 33 | this.nanoDLP.command("/projector/blank"); 34 | else 35 | this.nanoDLP.command("/projector/generate/white"); 36 | }); 37 | 38 | this.addListener("click_b7", () => { 39 | if(this.status.Projecting) 40 | this.nanoDLP.command("/projector/blank"); 41 | else 42 | this.nanoDLP.command("/projector/generate/boundaries"); 43 | }); 44 | } 45 | 46 | async update(status){ 47 | this.status = status; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require("babel-polyfill"); 4 | 5 | import NanoDLPService from "./services/nanoDlpService.js"; 6 | import config from "../config.json"; 7 | 8 | global.SERVER_URL = config.url; 9 | const nanoDLPService = new NanoDLPService(config.auth); 10 | 11 | class ScreenManager{ 12 | constructor(){ 13 | this.nanoDLP = nanoDLPService; 14 | this.plugins = []; 15 | 16 | this.registerPlugin("pushBullet"); 17 | this.registerPlugin("nextion"); 18 | } 19 | 20 | async init(){ 21 | for (var i = 0; i < this.plugins.length; i++) { 22 | await this.plugins[i].init(); 23 | } 24 | 25 | this.update().catch(e=>console.error(e)); 26 | } 27 | 28 | async update(){ 29 | clearTimeout(this.updateTimeOut); 30 | 31 | let status = await this.nanoDLP.getStatus().catch((e) => {}); 32 | let log = await this.nanoDLP.getCurrentLog().catch((e) => {}); 33 | if(!status || !log){ 34 | await new Promise((resolve) => setTimeout(resolve, 2000)); 35 | return await this.update(); 36 | } 37 | 38 | for (var i = 0; i < this.plugins.length; i++) { 39 | this.plugins[i].update(status, log).catch((e) => {console.error(e);}); 40 | } 41 | 42 | clearTimeout(this.updateTimeOut); 43 | this.updateTimeOut = setTimeout(()=> this.update(), 1000); 44 | } 45 | 46 | registerPlugin(pluginName){ 47 | let plugin = new (require('./plugins/'+pluginName).default)(this); 48 | this.plugins.push(plugin); 49 | } 50 | } 51 | 52 | new ScreenManager().init().catch((e)=>{ 53 | console.error(e); 54 | }); 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NanoDLP-TouchScreen by Mango3D 2 | Nextion Screen => NodeJS => NanoDLP 3 | ![photo.jpg](photo.jpg) 4 | 5 | ## Require 6 | 7 | - NanoDLP installed on a raspbery pi (2, 3, zero,...) 8 | - A Nextion screen (Enhanced or not, 2.4", 3.2", 3.5", 5" or an other size, but you'll have to update the HMI file for now) 9 | 10 | 11 | ## Hardware installation 12 | - Connect the raspberry pi to the nextion screen through the Serial GPIO's : 13 | 14 | ![hardware.jpg](hardware.jpg) 15 | 16 | - put the corresponding .tft file on a micro sd card, and plug it in the nextion screen. Power the raspberry pi and the Nextion screen'll automatically update its firmware with the good one (the screen'll go blank with status updating in red). You can then remove the micro sd card from the Nextion Screen (you can use the raspberry pi sd card!) 17 | 18 | ## MANDATORY : Enable /dev/ttyAMA0 For Raspberry Pi Zero and Raspberry Pi 3 19 | sudo raspi-config 20 | 21 | => Interfacing Option 22 | 23 | => Serial 24 | 25 | => NO 26 | 27 | => YES 28 | 29 | sudo nano /boot/config.txt 30 | 31 | => add this line : 32 | 33 | dtoverlay=pi3-disable-bt 34 | 35 | => then 36 | 37 | sudo reboot 38 | sudo nano /boot/cmdline.txt 39 | 40 | => remove the word phase "console=serial0,115200" or "console=ttyAMA0,115200" 41 | 42 | sudo reboot 43 | 44 | 45 | ## Simple installation 46 | 47 | On Raspberry pi zero, run : 48 | 49 | mkdir /home/pi/nextion;(wget https://github.com/Tibus/TouchScreen-For-NanoDLP/releases/download/V0.3/pizero.tar.gz --no-check-certificate -O - | tar -C /home/pi/nextion -xz);cd /home/pi/nextion; sudo ./setup.sh 50 | 51 | On Raspberry pi 2-3, run : 52 | 53 | mkdir /home/pi/nextion;(wget https://github.com/Tibus/TouchScreen-For-NanoDLP/releases/download/V0.3/pi2_3.tar.gz --no-check-certificate -O - | tar -C /home/pi/nextion -xz);cd /home/pi/nextion; sudo ./setup.sh 54 | 55 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/home.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | import abstract from "./abstract.js"; 3 | 4 | export default class Home extends abstract{ 5 | 6 | 7 | constructor(screenManager){ 8 | super(screenManager); 9 | } 10 | 11 | async init(options){ 12 | await this.setScreen("home"); 13 | await this.setText("t0", "Not Printing"); 14 | var ip = require("ip"); 15 | await this.setText("b6", ip.address()); 16 | 17 | if(options) { 18 | console.log("options", options); 19 | if (options.confirmResult) { 20 | if (options.confirmType === "shutdown") { 21 | var exec = require('child_process').exec; 22 | this.setScreen("progress"); 23 | this.setText("t0", "Shutdown in progress..."); 24 | exec('shutdown now', function(error, stdout, stderr){}); 25 | return _context.stop(); 26 | } 27 | } 28 | if (options.confirmResult) { 29 | if (options.confirmType === "reboot") { 30 | var exec = require('child_process').exec; 31 | this.setScreen("progress"); 32 | this.setText("t0", "Reboot in progress..."); 33 | exec('shutdown -r now', function(error, stdout, stderr){}); 34 | return _context.stop(); 35 | } 36 | } 37 | } 38 | 39 | this.addListener("click_b3", (e)=>{ 40 | this.changePage("settings"); 41 | }); 42 | 43 | this.addListener("click_b1", (e)=>{ 44 | this.changePage("plates"); 45 | }); 46 | 47 | this.addListener("click_b4", (e)=>{ 48 | this.changePage("confirm", { 49 | text: "Are you sure you want to shutdown?", 50 | confirmType: "shutdown", 51 | returnPage: "home" 52 | }); 53 | }); 54 | 55 | this.addListener("click_b5", (e)=>{ 56 | this.changePage("confirm", { 57 | text: "Are you sure you want to reboot?", 58 | confirmType: "reboot", 59 | returnPage: "home" 60 | }); 61 | }); 62 | 63 | this.addListener("click_b6", (e)=>{ 64 | this.changePage("ipqr", { 65 | text: "http://" + ip.address() 66 | }); 67 | }); 68 | 69 | } 70 | 71 | async update(status, log){ 72 | if(status.Printing){ 73 | return this.changePage("home"); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/printingHome.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | 3 | import abstract from "./abstract.js"; 4 | 5 | export default class PrintingHome extends abstract{ 6 | 7 | 8 | constructor(screenManager){ 9 | super(screenManager); 10 | 11 | this.layerID = -1; 12 | this.isPause = null; 13 | } 14 | 15 | async init(){ 16 | 17 | this.addListener("click_b10", (e)=>{ 18 | console.log("printSettings"); 19 | this.changePage("printSettings"); 20 | }); 21 | 22 | this.addListener("click_b11", (e)=>{ 23 | console.log("stats"); 24 | this.changePage("stats"); 25 | }); 26 | 27 | this.addListener("click_b9", (e)=>{ 28 | this.manager.nanoDLP.unpause(); 29 | }); 30 | } 31 | 32 | async update(status, log){ 33 | if(!status.Printing){ 34 | return this.changePage("home"); 35 | } 36 | 37 | if(this.isPause == null || this.isPause !== status.Pause){ 38 | this.isPause = status.Pause; 39 | if(this.isPause) 40 | await this.setScreen("printingPause"); 41 | else 42 | await this.setScreen("printing"); 43 | 44 | this.imageX = await this.nextion.getValue("t12.x"); 45 | this.imageY = await this.nextion.getValue("t12.y"); 46 | this.imageWidth = await this.nextion.getValue("t12.w"); 47 | } 48 | 49 | await this.setText("t6", this.isPause?"Pause":"Printing"); 50 | 51 | var remaining_time = Math.round((status.LayersCount-status.LayerID)*status.LayerTime/1000000000/60); 52 | var total_time = Math.round(status.LayersCount*status.LayerTime/1000000000/60); 53 | 54 | await this.setText("t0", status.LayerID+"/"+status.LayersCount); 55 | await this.setValue("j0", Math.floor((status.LayerID/status.LayersCount)*100)); 56 | await this.setText("t1", remaining_time+" of "+total_time+"min"); 57 | await this.setText("t2", log.msg); 58 | await this.setText("t7", status.Path) 59 | 60 | if(this.history.layer != status.LayerID){ 61 | this.history.layer = status.LayerID; 62 | console.log("setImage", this.history.layer); 63 | let image = await this.nanoDLP.getCurrentPlateLayer(status.PlateID, status.LayerID) 64 | if(this.enabled) 65 | await this.nextion.displayBlackWhiteImage(image, this.imageX, this.imageY, this.imageWidth).catch(e => console.error(e)); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/plates.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | import abstract from "./abstract.js"; 3 | 4 | export default class Plates extends abstract{ 5 | 6 | 7 | constructor(screenManager){ 8 | super(screenManager); 9 | } 10 | 11 | async init(options){ 12 | await this.setScreen("plates"); 13 | 14 | if (options && options.confirmResult) { 15 | if (options.confirmType === "deleteplate" && options.data0) { 16 | await this.nanoDLP.command("/plate/delete/"+options.data0); 17 | } 18 | } 19 | 20 | this.plates = await this.nanoDLP.getPlates(); 21 | 22 | this.addListener("click_b2", (e)=>{ 23 | this.changePage("home"); 24 | }); 25 | 26 | this.addListener("click_b9", (e)=>{ 27 | this.changePage("addPlate"); 28 | }); 29 | 30 | this.addListener("click_b4", (e)=>{ 31 | if ((this.currentIndex+0){ 34 | if ((this.currentIndex+1){ 37 | if ((this.currentIndex+2){ 40 | if ((this.currentIndex+3){ 43 | if ((this.currentIndex+4){ 49 | scroll = Math.floor((100-scroll)/gap); 50 | if(scroll<=this.plates.length-5) 51 | this.updateList(scroll); 52 | }); 53 | 54 | this.updateList(0); 55 | } 56 | 57 | async updateList(index){ 58 | this.currentIndex = index; 59 | this.setText("b4", (index+1) + ". " + this.plates[index].Path); 60 | this.setText("b5", (index+2) + ". " + this.plates[index+1].Path); 61 | this.setText("b6", (index+3) + ". " + this.plates[index+2].Path); 62 | this.setText("b7", (index+4) + ". " + this.plates[index+3].Path); 63 | this.setText("b8", (index+5) + ". " + this.plates[index+4].Path); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/plugins/nextion.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | import abstract from "./abstract.js"; 3 | 4 | import NextionService from "./nextion/nextionService.js"; 5 | 6 | export default class Confirm extends abstract{ 7 | constructor(manager){ 8 | super(manager); 9 | 10 | this.isPrinting = null; 11 | 12 | this.nextion = new NextionService(this.config.plugins.nextion); 13 | 14 | this.nextion.on("disconnect", ()=>{ 15 | this.init().catch(e=>console.error(e)); 16 | }); 17 | } 18 | 19 | async init(){ 20 | this.isPrinting = null; 21 | this.currentPageId = null; 22 | 23 | console.log("connect to port "+this.config.plugins.nextion.port); 24 | 25 | await this.nextion.connect(); 26 | 27 | console.log("connected"); 28 | 29 | this.update(this.status, this.log).catch(e=>console.error(e)); 30 | } 31 | 32 | async update(status, log){ 33 | if(!status) 34 | return 35 | 36 | this.status = status; 37 | this.log = log; 38 | 39 | clearTimeout(this.updateTimeOut); 40 | 41 | if(status.Printing !== this.isPrinting){ 42 | this.isPrinting = status.Printing; 43 | await this.setPage("home"); 44 | } 45 | this.isPrinting = status.Printing; 46 | 47 | await this.currentPage.update(status, log).catch((e) => console.error(e)); 48 | } 49 | 50 | async setPage(page, options){ 51 | 52 | switch (page) { 53 | case "home": 54 | if(this.isPrinting){ 55 | page = "printingHome"; 56 | }else{ 57 | page = "home"; 58 | } 59 | break; 60 | } 61 | 62 | if(this.currentPageId == page) 63 | return; 64 | 65 | console.log("setPage", page, `./nextion/pages/${page}.js`); 66 | try { 67 | var PageClass = require(`./nextion/pages/${page}.js`).default; 68 | } catch (e) { 69 | console.log(`page ./nextion/pages/${page}.js do not exist`); 70 | return; 71 | } 72 | 73 | if(this.currentPage){ 74 | try { 75 | this.currentPage.dispose(); 76 | } catch (e) { 77 | console.error(e); 78 | } 79 | } 80 | 81 | this.currentPageId = page; 82 | this.currentPage = new PageClass(this); 83 | 84 | await new Promise((resolve) => setTimeout(resolve, 100)); 85 | this.currentPage.init(options).catch(e=>console.error(e)); 86 | 87 | await this.update(this.status, this.log); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/plate.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | import abstract from "./abstract.js"; 3 | import lodash from "lodash"; 4 | 5 | export default class Plate extends abstract{ 6 | 7 | 8 | constructor(screenManager){ 9 | super(screenManager); 10 | 11 | this.currentViewID = 0; 12 | } 13 | 14 | async init(plate){ 15 | await this.setScreen("plate"); 16 | 17 | this.plate = plate; 18 | this.profiles = await this.nanoDLP.getProfiles(); 19 | this.profile = this.profiles[lodash.findIndex(this.profiles, {ProfileID:this.plate.ProfileID})] 20 | 21 | this.imageX = await this.getValue("t12.x"); 22 | this.imageY = await this.getValue("t12.y"); 23 | this.imageWidth = await this.getValue("t12.w"); 24 | 25 | this.setText("t0", this.plate.Path); 26 | this.setText("t1", `${this.profile.Title} (${this.profile.Depth}um)`); 27 | this.setText("t3", `${this.plate.TotalSolidArea}ml`); 28 | this.setText("t7", `${this.plate.LayersCount} layers`); 29 | 30 | this.addListener("click_b2", (e)=>{ 31 | this.changePage("plates"); 32 | }); 33 | 34 | this.addListener("click_b9", async () => { 35 | await this.nanoDLP.command("/printer/start/"+this.plate.PlateID); 36 | this.changePage("home"); 37 | }); 38 | 39 | this.addListener("click_b15", async () => { 40 | this.changePage("confirm", { 41 | text: "Are you sure you want to delete\rthe following plate:\r\r"+this.plate.Path, 42 | confirmType: "deleteplate", 43 | data0: this.plate.PlateID, 44 | returnPage: "plates" 45 | }); 46 | }); 47 | 48 | /* 49 | this.addListener("click_b12", (e)=>{ 50 | this.set3DView(++this.currentViewID); 51 | }); 52 | */ 53 | 54 | this.gap = 100/(this.plate.LayersCount); 55 | 56 | this.addListener("number", (index)=>{ 57 | index = Math.floor((index)/this.gap); 58 | this.setLayer(index); 59 | }); 60 | 61 | await this.setLayer(1); 62 | } 63 | 64 | /* 65 | async set3DView(index){ 66 | await this.setText("t12", "Loading "); 67 | var image = await this.manager.nanoDLP.getCurrentPlate3DView(this.plate.PlateID, this.currentViewID%4); 68 | if(this.enabled) 69 | await this.nextion.displayBlackWhiteImage(image, this.imageX, this.imageY, this.imageWidth).catch(e => console.error(e)); 70 | }*/ 71 | 72 | async setLayer(index){ 73 | this.index = index==0?1:index; 74 | 75 | await this.setText("t12", `Loading ${this.index}/${this.plate.LayersCount}`); 76 | this.setText("t9", "layer "+this.index+"/"+this.plate.LayersCount); 77 | let image = await this.nanoDLP.getCurrentPlateLayer(this.plate.PlateID, this.index) 78 | if(this.enabled) 79 | await this.nextion.displayBlackWhiteImage(image, this.imageX, this.imageY, this.imageWidth).catch(e => console.error(e)); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /bin/plugins/abstract.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = undefined; 7 | 8 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 | 10 | var _config = require("../../config.json"); 11 | 12 | var _config2 = _interopRequireDefault(_config); 13 | 14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 15 | 16 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 17 | 18 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 19 | 20 | require("babel-polyfill"); 21 | 22 | var AbstractPlugin = function () { 23 | function AbstractPlugin(manager) { 24 | _classCallCheck(this, AbstractPlugin); 25 | 26 | this.manager = manager; 27 | this.nanoDLP = manager.nanoDLP; 28 | this.config = _config2.default; 29 | } 30 | 31 | _createClass(AbstractPlugin, [{ 32 | key: "init", 33 | value: function () { 34 | var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { 35 | return regeneratorRuntime.wrap(function _callee$(_context) { 36 | while (1) { 37 | switch (_context.prev = _context.next) { 38 | case 0: 39 | case "end": 40 | return _context.stop(); 41 | } 42 | } 43 | }, _callee, this); 44 | })); 45 | 46 | function init() { 47 | return _ref.apply(this, arguments); 48 | } 49 | 50 | return init; 51 | }() 52 | }, { 53 | key: "update", 54 | value: function () { 55 | var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(status) { 56 | return regeneratorRuntime.wrap(function _callee2$(_context2) { 57 | while (1) { 58 | switch (_context2.prev = _context2.next) { 59 | case 0: 60 | case "end": 61 | return _context2.stop(); 62 | } 63 | } 64 | }, _callee2, this); 65 | })); 66 | 67 | function update(_x) { 68 | return _ref2.apply(this, arguments); 69 | } 70 | 71 | return update; 72 | }() 73 | }, { 74 | key: "dispose", 75 | value: function dispose() {} 76 | }]); 77 | 78 | return AbstractPlugin; 79 | }(); 80 | 81 | exports.default = AbstractPlugin; -------------------------------------------------------------------------------- /src/plugins/nextion/pages/printSettings.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | 3 | import abstract from "./abstract.js"; 4 | import lodash from "lodash"; 5 | 6 | export default class PrintSettings extends abstract{ 7 | constructor(screenManager){ 8 | super(screenManager); 9 | } 10 | 11 | async init(options){ 12 | await this.setScreen("prtSettings"); 13 | 14 | try { 15 | if(options && options.confirmResult && options.confirmResult){ 16 | switch (options.confirmType) { 17 | case "pause": 18 | console.log("pause") 19 | this.nanoDLP.pause(); 20 | this.changePage("home"); 21 | break; 22 | 23 | case "stop": 24 | this.nanoDLP.stop(); 25 | this.changePage("home"); 26 | break; 27 | } 28 | } 29 | } catch (e) { 30 | console.log("error", e); 31 | } 32 | 33 | this.addListener("click_b4", (e)=>{ 34 | this.changePage("home"); 35 | }); 36 | 37 | 38 | this.addListener("click_b5", (e)=>{ 39 | this.changePage("confirm", { 40 | text:"Are you sure you want to debug\rprinting?\rIt will move 25mm to the top after\rthe current layer completed and\rcontinue to print." 41 | , confirmType: "debug" 42 | , returnPage: "printSettings" 43 | }) 44 | }); 45 | 46 | this.addListener("click_b3", (e)=>{ 47 | console.log("click_b3"); 48 | this.changePage("confirm", { 49 | text:"Are you sure you want to pause\r printing?\rIt will pause after the current\rlayer completed." 50 | , confirmType: "pause" 51 | , returnPage: "printSettings" 52 | }) 53 | }); 54 | 55 | this.addListener("click_b2", (e)=>{ 56 | this.changePage("confirm", { 57 | text:"Are you sure you want to stop\r printing?\rIt will stop after the current\rlayer completed." 58 | , confirmType: "stop" 59 | , returnPage: "printSettings" 60 | }); 61 | }); 62 | 63 | this.addListener("string", async (string)=>{ 64 | this.history = {}; 65 | 66 | if(string != "cancel"){ 67 | console.log("edit string :", string); 68 | this.profile.CureTime = Number(string); 69 | this.nanoDLP.setCureTime(this.profile.ProfileID, this.profile); 70 | this.changePage("home"); 71 | } 72 | }); 73 | 74 | this.setCureTime = false; 75 | } 76 | 77 | async update(status){ 78 | this.status = status; 79 | 80 | if(this.setCureTime == false){ 81 | this.setCureTime = true; 82 | this.plates = await this.nanoDLP.getPlates(); 83 | this.plate = this.plates[lodash.findIndex(this.plates, {PlateID:this.status.PlateID})] 84 | 85 | this.profiles = await this.nanoDLP.getProfiles(); 86 | this.profile = this.profiles[lodash.findIndex(this.profiles, {ProfileID:this.plate.ProfileID})] 87 | 88 | await this.setText("t7", this.profile.CureTime); 89 | } 90 | 91 | var remaining_time = Math.round((status.LayersCount-status.LayerID)*status.LayerTime/1000000000/60); 92 | var total_time = Math.round(status.LayersCount*status.LayerTime/1000000000/60); 93 | 94 | await this.setText("t11", status.LayerID+"/"+status.LayersCount); 95 | await this.setText("t10", remaining_time+" of "+total_time+"min"); 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/plugins/nextion/pages/zAxis.js: -------------------------------------------------------------------------------- 1 | require("babel-polyfill"); 2 | import abstract from "./abstract.js"; 3 | 4 | export default class ZAxis extends abstract{ 5 | 6 | 7 | constructor(screenManager){ 8 | super(screenManager); 9 | 10 | this.currentButton = 8; 11 | } 12 | 13 | async init(options){ 14 | await this.setScreen("zAxis"); 15 | 16 | this.addListener("click_b16", (e)=>{ 17 | this.changePage("home"); 18 | }); 19 | 20 | this.addListener("click_b12", (e)=>{ 21 | this.up(); 22 | }); 23 | 24 | this.addListener("click_b13", (e)=>{ 25 | this.down(); 26 | }); 27 | 28 | this.addListener("click_b11", () => this.setBtn(11)); 29 | this.addListener("click_b10", () => this.setBtn(10)); 30 | this.addListener("click_b9", () => this.setBtn(9)); 31 | this.addListener("click_b8", () => this.setBtn(8)); 32 | this.addListener("click_b7", () => this.setBtn(7)); 33 | this.addListener("click_b6", () => this.setBtn(6)); 34 | this.addListener("click_b5", () => this.setBtn(5)); 35 | this.addListener("click_b2", () => this.setBtn(2)); 36 | 37 | this.addListener("click_b3", () => this.nanoDLP.command("/z-axis/top")); 38 | this.addListener("click_b4", () => this.nanoDLP.command("/z-axis/bottom")); 39 | this.addListener("click_b14", () => this.nanoDLP.command("/z-axis/touch-limit")); 40 | this.addListener("click_b15", () => this.nanoDLP.command("/z-axis/calibrate")); 41 | 42 | this.setBtn(10); 43 | } 44 | 45 | async up(){ 46 | this.move("up"); 47 | } 48 | 49 | async down(){ 50 | this.move("down"); 51 | } 52 | 53 | async move(direction){ 54 | switch(this.currentButton){ 55 | case 11: 56 | await this.nanoDLP.command(`/z-axis/move/${direction}/micron/100000`); 57 | break; 58 | case 10: 59 | await this.nanoDLP.command(`/z-axis/move/${direction}/micron/10000`); 60 | break; 61 | case 9: 62 | await this.nanoDLP.command(`/z-axis/move/${direction}/micron/1000`); 63 | break; 64 | case 8: 65 | await this.nanoDLP.command(`/z-axis/move/${direction}/micron/500`); 66 | break; 67 | case 7: 68 | await this.nanoDLP.command(`/z-axis/move/${direction}/micron/100`); 69 | break; 70 | case 6: 71 | await this.nanoDLP.command(`/z-axis/move/${direction}/pulse/100`); 72 | break; 73 | case 5: 74 | await this.nanoDLP.command(`/z-axis/move/${direction}/pulse/10`); 75 | break; 76 | case 2: 77 | await this.nanoDLP.command(`/z-axis/move/${direction}/pulse/1`); 78 | break; 79 | } 80 | } 81 | 82 | async setBtn(id){ 83 | await this.nextion.setValue(`bt${this.currentButton}`, 0); 84 | this.currentButton = id; 85 | await this.nextion.setValue(`bt${this.currentButton}`, 1); 86 | } 87 | 88 | 89 | async update(status){ 90 | if(!this.setup){ 91 | this.setup = await this.nanoDLP.getSetup(); 92 | } 93 | 94 | let currentMm = status.CurrentHeight/((360/this.setup.MotorDegree*this.setup.MicroStep)/this.setup.LeadscrewPitch); 95 | let total = this.setup.ZAxisHeight/((360/this.setup.MotorDegree*this.setup.MicroStep)/this.setup.LeadscrewPitch); 96 | 97 | await this.setText("t1", currentMm+"mm"); 98 | await this.setText("t2", total+"mm"); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/services/utils/stl2png.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author jonaskello / https://github.com/jonaskello 3 | * Simple example that renders a scene with a cube to a PNG image file. 4 | */ 5 | 'use strict'; 6 | require("babel-polyfill"); 7 | 8 | const THREE = require("three"); 9 | global.THREE = THREE; 10 | 11 | require("./threejs-extras/STLLoader.js"); 12 | const SoftwareRenderer = require("./3D/software-renderer"); 13 | const PNG = require("pngjs").PNG; 14 | const fs = require("fs"); 15 | 16 | // Build scene with cube 17 | const width = 200; 18 | const height = 200; 19 | 20 | 21 | export default class STL2PNG { 22 | constructor() { 23 | 24 | } 25 | 26 | 27 | async getPNG(stl, name, orientation){ 28 | var date = new Date().getTime(); 29 | 30 | return new Promise(function(resolve, reject) { 31 | const scene = new THREE.Scene(); 32 | const material = new THREE.MeshBasicMaterial({color: 0xffffff}); 33 | const camera = new THREE.PerspectiveCamera(30, width / height, 1, 1000); 34 | switch (orientation) { 35 | case 0: 36 | camera.position.x = 10; 37 | break; 38 | case 1: 39 | camera.position.y = -10; 40 | break; 41 | case 2: 42 | camera.position.z = 10; 43 | break; 44 | case 3: 45 | camera.position.x = 10; 46 | camera.position.y = -10; 47 | break; 48 | default: 49 | 50 | } 51 | camera.lookAt(scene.position); 52 | 53 | var loader = new THREE.STLLoader(), 54 | geometry = loader.parse(stl); 55 | 56 | geometry.computeVertexNormals(); 57 | geometry.computeBoundingSphere(); 58 | geometry.computeBoundingBox(); 59 | geometry.center(); 60 | 61 | var mesh = new THREE.Mesh( geometry, material ); 62 | 63 | scene.add( mesh ); 64 | 65 | var fov = camera.fov * ( Math.PI / 180 ); 66 | var distance = Math.abs( geometry.boundingSphere.radius / Math.sin( fov / 2 ) ); 67 | var newPosition = camera.position.clone().normalize().multiplyScalar(distance); 68 | camera.position.set(newPosition.x,newPosition.y,newPosition.z); 69 | camera.needsUpdate = true; 70 | camera.updateProjectionMatrix(); 71 | switch (orientation) { 72 | case 0: 73 | camera.rotation.x = 90 * Math.PI / 180 74 | break; 75 | case 1: 76 | break; 77 | case 2: 78 | break; 79 | case 3: 80 | camera.rotation.z = 0; 81 | break; 82 | default: 83 | } 84 | 85 | const renderer = new SoftwareRenderer(); 86 | renderer.setSize(width, height); 87 | var imagedata = renderer.render(scene, camera); 88 | 89 | // Create a PNG from the pixels array (RGBA) 90 | const png = new PNG({ 91 | width: width, 92 | height: height, 93 | filterType: -1 94 | }); 95 | 96 | for(var i=0;i{ 54 | this.changePage("plates"); 55 | }); 56 | 57 | this.addListener("click_b4", (e)=>{ 58 | idxP = Math.abs((idxP - 1) % this.profiles.length); 59 | this.setText("t3", this.profiles[idxP].ProfileID + ": " + this.profiles[idxP].Title); 60 | }); 61 | 62 | this.addListener("click_b5", (e)=>{ 63 | idxP = (idxP + 1) % this.profiles.length; 64 | this.setText("t3", this.profiles[idxP].ProfileID + ": " + this.profiles[idxP].Title); 65 | }); 66 | 67 | var pth = []; 68 | var lbl = []; 69 | var fin = []; 70 | var fs = require('fs'); 71 | 72 | const drivelist = require('drivelist'); 73 | await drivelist.list((error, drives) => { 74 | if (error) { throw error; } 75 | drives.forEach((drive) => { 76 | console.log(drive); 77 | pth.push(drive.mountpoints[0].path); 78 | lbl.push(drive.description + " | " + drive.mountpoints[0].path); 79 | }); 80 | 81 | idxD=-1; 82 | do { 83 | idxD++; 84 | fin = fs.readdirSync(pth[idxD]); 85 | fin = fin.filter(this.cbFile,this); 86 | } while (this.config.autoFetch==="true" && this.config.showAll==="false" && fin.length==0 && idxD{ 93 | idxD = Math.abs((idxD - 1) % lbl.length); 94 | this.setText("t6", lbl[idxD]); 95 | fin = fs.readdirSync(pth[idxD]); 96 | fin = fin.filter(this.cbFile,this); 97 | idxF=0; 98 | this.list(idxF,fin); 99 | }); 100 | 101 | this.addListener("click_b8", (e)=>{ 102 | idxD = (idxD + 1) % lbl.length; 103 | this.setText("t6", lbl[idxD]); 104 | fin = fs.readdirSync(pth[idxD]); 105 | fin = fin.filter(this.cbFile,this); 106 | idxF=0; 107 | this.list(idxF,fin); 108 | }); 109 | 110 | this.addListener("number", (scroll)=>{ 111 | idxF = Math.floor((100-scroll)/(100/(fin.length-3)) ); 112 | if(idxF<=fin.length-4) this.list(idxF,fin); 113 | }); 114 | 115 | this.addListener("click_b9", (e)=>{ 116 | if ((idxF+0){ 127 | if ((idxF+1){ 138 | if ((idxF+2){ 149 | if ((idxF+3)0){ 163 | this.setText("b9", fin[index+0]); 164 | } else { 165 | this.setText("b9", ""); 166 | } 167 | if (fin.length>1){ 168 | this.setText("b10", fin[index+1]); 169 | } else { 170 | this.setText("b10", ""); 171 | } 172 | if (fin.length>2){ 173 | this.setText("b11", fin[index+2]); 174 | } else { 175 | this.setText("b11", ""); 176 | } 177 | if (fin.length>3){ 178 | this.setText("b12", fin[index+3]); 179 | } else { 180 | this.setText("b12", ""); 181 | } 182 | } 183 | 184 | evalFile(filename) { 185 | var exts = this.config.fileExt.split("|"); 186 | var res = false; 187 | for (var i=0; i< exts.length && res==0; i++) { 188 | if (filename.substr(filename.length-exts[i].length-1,exts[i].length+1).toLowerCase() == ("."+exts[i]).toLowerCase() ){ res = true;} 189 | } 190 | return res; 191 | } 192 | 193 | listFile(filename) { 194 | return ((this.evalFile(filename)) || this.config.showAll==="true"); 195 | } 196 | 197 | cbFile(value, index, ar) { 198 | return this.listFile(value); 199 | } 200 | 201 | } 202 | -------------------------------------------------------------------------------- /bin/plugins/nextion/pages/plates.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = undefined; 7 | 8 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 | 10 | var _abstract2 = require("./abstract.js"); 11 | 12 | var _abstract3 = _interopRequireDefault(_abstract2); 13 | 14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 15 | 16 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 17 | 18 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 19 | 20 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 21 | 22 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 23 | 24 | require("babel-polyfill"); 25 | 26 | var Plates = function (_abstract) { 27 | _inherits(Plates, _abstract); 28 | 29 | function Plates(screenManager) { 30 | _classCallCheck(this, Plates); 31 | 32 | return _possibleConstructorReturn(this, (Plates.__proto__ || Object.getPrototypeOf(Plates)).call(this, screenManager)); 33 | } 34 | 35 | _createClass(Plates, [{ 36 | key: "init", 37 | value: function () { 38 | var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(options) { 39 | var _this2 = this; 40 | 41 | var gap; 42 | return regeneratorRuntime.wrap(function _callee$(_context) { 43 | while (1) { 44 | switch (_context.prev = _context.next) { 45 | case 0: 46 | _context.next = 2; 47 | return this.setScreen("plates"); 48 | 49 | case 2: 50 | if (!(options && options.confirmResult)) { 51 | _context.next = 6; 52 | break; 53 | } 54 | 55 | if (!(options.confirmType === "deleteplate" && options.data0)) { 56 | _context.next = 6; 57 | break; 58 | } 59 | 60 | _context.next = 6; 61 | return this.nanoDLP.command("/plate/delete/" + options.data0); 62 | 63 | case 6: 64 | _context.next = 8; 65 | return this.nanoDLP.getPlates(); 66 | 67 | case 8: 68 | this.plates = _context.sent; 69 | 70 | 71 | this.addListener("click_b2", function (e) { 72 | _this2.changePage("home"); 73 | }); 74 | 75 | this.addListener("click_b9", function (e) { 76 | _this2.changePage("addPlate"); 77 | }); 78 | 79 | this.addListener("click_b4", function (e) { 80 | if (_this2.currentIndex + 0 < _this2.plates.length) _this2.changePage("plate", _this2.plates[_this2.currentIndex]); 81 | }); 82 | this.addListener("click_b5", function (e) { 83 | if (_this2.currentIndex + 1 < _this2.plates.length) _this2.changePage("plate", _this2.plates[_this2.currentIndex + 1]); 84 | }); 85 | this.addListener("click_b6", function (e) { 86 | if (_this2.currentIndex + 2 < _this2.plates.length) _this2.changePage("plate", _this2.plates[_this2.currentIndex + 2]); 87 | }); 88 | this.addListener("click_b7", function (e) { 89 | if (_this2.currentIndex + 3 < _this2.plates.length) _this2.changePage("plate", _this2.plates[_this2.currentIndex + 3]); 90 | }); 91 | this.addListener("click_b8", function (e) { 92 | if (_this2.currentIndex + 4 < _this2.plates.length) _this2.changePage("plate", _this2.plates[_this2.currentIndex + 4]); 93 | }); 94 | 95 | gap = 100 / (this.plates.length - 4); 96 | 97 | 98 | this.addListener("number", function (scroll) { 99 | scroll = Math.floor((100 - scroll) / gap); 100 | if (scroll <= _this2.plates.length - 5) _this2.updateList(scroll); 101 | }); 102 | 103 | this.updateList(0); 104 | 105 | case 19: 106 | case "end": 107 | return _context.stop(); 108 | } 109 | } 110 | }, _callee, this); 111 | })); 112 | 113 | function init(_x) { 114 | return _ref.apply(this, arguments); 115 | } 116 | 117 | return init; 118 | }() 119 | }, { 120 | key: "updateList", 121 | value: function () { 122 | var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(index) { 123 | return regeneratorRuntime.wrap(function _callee2$(_context2) { 124 | while (1) { 125 | switch (_context2.prev = _context2.next) { 126 | case 0: 127 | this.currentIndex = index; 128 | this.setText("b4", index + 1 + ". " + this.plates[index].Path); 129 | this.setText("b5", index + 2 + ". " + this.plates[index + 1].Path); 130 | this.setText("b6", index + 3 + ". " + this.plates[index + 2].Path); 131 | this.setText("b7", index + 4 + ". " + this.plates[index + 3].Path); 132 | this.setText("b8", index + 5 + ". " + this.plates[index + 4].Path); 133 | 134 | case 6: 135 | case "end": 136 | return _context2.stop(); 137 | } 138 | } 139 | }, _callee2, this); 140 | })); 141 | 142 | function updateList(_x2) { 143 | return _ref2.apply(this, arguments); 144 | } 145 | 146 | return updateList; 147 | }() 148 | }]); 149 | 150 | return Plates; 151 | }(_abstract3.default); 152 | 153 | exports.default = Plates; -------------------------------------------------------------------------------- /bin/plugins/nextion/pages/home.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = undefined; 7 | 8 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 | 10 | var _abstract2 = require("./abstract.js"); 11 | 12 | var _abstract3 = _interopRequireDefault(_abstract2); 13 | 14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 15 | 16 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 17 | 18 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 19 | 20 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 21 | 22 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 23 | 24 | require("babel-polyfill"); 25 | 26 | var Home = function (_abstract) { 27 | _inherits(Home, _abstract); 28 | 29 | function Home(screenManager) { 30 | _classCallCheck(this, Home); 31 | 32 | return _possibleConstructorReturn(this, (Home.__proto__ || Object.getPrototypeOf(Home)).call(this, screenManager)); 33 | } 34 | 35 | _createClass(Home, [{ 36 | key: "init", 37 | value: function () { 38 | var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(options) { 39 | var _this2 = this; 40 | 41 | var ip, exec; 42 | return regeneratorRuntime.wrap(function _callee$(_context2) { 43 | while (1) { 44 | switch (_context2.prev = _context2.next) { 45 | case 0: 46 | _context2.next = 2; 47 | return this.setScreen("home"); 48 | 49 | case 2: 50 | _context2.next = 4; 51 | return this.setText("t0", "Not Printing"); 52 | 53 | case 4: 54 | ip = require("ip"); 55 | _context2.next = 7; 56 | return this.setText("b6", ip.address()); 57 | 58 | case 7: 59 | if (!options) { 60 | _context2.next = 23; 61 | break; 62 | } 63 | 64 | console.log("options", options); 65 | 66 | if (!options.confirmResult) { 67 | _context2.next = 16; 68 | break; 69 | } 70 | 71 | if (!(options.confirmType === "shutdown")) { 72 | _context2.next = 16; 73 | break; 74 | } 75 | 76 | exec = require('child_process').exec; 77 | 78 | this.setScreen("progress"); 79 | this.setText("t0", "Shutdown in progress..."); 80 | exec('shutdown now', function (error, stdout, stderr) {}); 81 | return _context2.abrupt("return", _context.stop()); 82 | 83 | case 16: 84 | if (!options.confirmResult) { 85 | _context2.next = 23; 86 | break; 87 | } 88 | 89 | if (!(options.confirmType === "reboot")) { 90 | _context2.next = 23; 91 | break; 92 | } 93 | 94 | exec = require('child_process').exec; 95 | 96 | this.setScreen("progress"); 97 | this.setText("t0", "Reboot in progress..."); 98 | exec('shutdown -r now', function (error, stdout, stderr) {}); 99 | return _context2.abrupt("return", _context.stop()); 100 | 101 | case 23: 102 | 103 | this.addListener("click_b3", function (e) { 104 | _this2.changePage("settings"); 105 | }); 106 | 107 | this.addListener("click_b1", function (e) { 108 | _this2.changePage("plates"); 109 | }); 110 | 111 | this.addListener("click_b4", function (e) { 112 | _this2.changePage("confirm", { 113 | text: "Are you sure you want to shutdown?", 114 | confirmType: "shutdown", 115 | returnPage: "home" 116 | }); 117 | }); 118 | 119 | this.addListener("click_b5", function (e) { 120 | _this2.changePage("confirm", { 121 | text: "Are you sure you want to reboot?", 122 | confirmType: "reboot", 123 | returnPage: "home" 124 | }); 125 | }); 126 | 127 | this.addListener("click_b6", function (e) { 128 | _this2.changePage("ipqr", { 129 | text: "http://" + ip.address() 130 | }); 131 | }); 132 | 133 | case 28: 134 | case "end": 135 | return _context2.stop(); 136 | } 137 | } 138 | }, _callee, this); 139 | })); 140 | 141 | function init(_x) { 142 | return _ref.apply(this, arguments); 143 | } 144 | 145 | return init; 146 | }() 147 | }, { 148 | key: "update", 149 | value: function () { 150 | var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(status, log) { 151 | return regeneratorRuntime.wrap(function _callee2$(_context3) { 152 | while (1) { 153 | switch (_context3.prev = _context3.next) { 154 | case 0: 155 | if (!status.Printing) { 156 | _context3.next = 2; 157 | break; 158 | } 159 | 160 | return _context3.abrupt("return", this.changePage("home")); 161 | 162 | case 2: 163 | case "end": 164 | return _context3.stop(); 165 | } 166 | } 167 | }, _callee2, this); 168 | })); 169 | 170 | function update(_x2, _x3) { 171 | return _ref2.apply(this, arguments); 172 | } 173 | 174 | return update; 175 | }() 176 | }]); 177 | 178 | return Home; 179 | }(_abstract3.default); 180 | 181 | exports.default = Home; -------------------------------------------------------------------------------- /bin/plugins/nextion/pages/abstract.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 8 | 9 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 10 | 11 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 12 | 13 | require("babel-polyfill"); 14 | 15 | var Abstract = function () { 16 | function Abstract(manager) { 17 | _classCallCheck(this, Abstract); 18 | 19 | this.manager = manager; 20 | this.nextion = manager.nextion; 21 | this.nanoDLP = manager.nanoDLP; 22 | this.listener = []; 23 | this.history = {}; 24 | this.enabled = true; 25 | } 26 | 27 | _createClass(Abstract, [{ 28 | key: "addListener", 29 | value: function addListener(event, callback) { 30 | this.listener.push({ btn: event, callback: callback }); 31 | this.nextion.on(event, callback); 32 | } 33 | }, { 34 | key: "setScreen", 35 | value: function () { 36 | var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(val) { 37 | return regeneratorRuntime.wrap(function _callee$(_context) { 38 | while (1) { 39 | switch (_context.prev = _context.next) { 40 | case 0: 41 | _context.next = 2; 42 | return this.nextion.setPage(val); 43 | 44 | case 2: 45 | this.history = {}; 46 | 47 | case 3: 48 | case "end": 49 | return _context.stop(); 50 | } 51 | } 52 | }, _callee, this); 53 | })); 54 | 55 | function setScreen(_x) { 56 | return _ref.apply(this, arguments); 57 | } 58 | 59 | return setScreen; 60 | }() 61 | }, { 62 | key: "changePage", 63 | value: function () { 64 | var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(val, options) { 65 | return regeneratorRuntime.wrap(function _callee2$(_context2) { 66 | while (1) { 67 | switch (_context2.prev = _context2.next) { 68 | case 0: 69 | _context2.next = 2; 70 | return this.manager.setPage(val, options); 71 | 72 | case 2: 73 | case "end": 74 | return _context2.stop(); 75 | } 76 | } 77 | }, _callee2, this); 78 | })); 79 | 80 | function changePage(_x2, _x3) { 81 | return _ref2.apply(this, arguments); 82 | } 83 | 84 | return changePage; 85 | }() 86 | }, { 87 | key: "setText", 88 | value: function () { 89 | var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(txt, val) { 90 | return regeneratorRuntime.wrap(function _callee3$(_context3) { 91 | while (1) { 92 | switch (_context3.prev = _context3.next) { 93 | case 0: 94 | if (!(this.history[txt] == val)) { 95 | _context3.next = 2; 96 | break; 97 | } 98 | 99 | return _context3.abrupt("return"); 100 | 101 | case 2: 102 | this.history[txt] = val; 103 | _context3.next = 5; 104 | return this.nextion.setText(txt, val); 105 | 106 | case 5: 107 | case "end": 108 | return _context3.stop(); 109 | } 110 | } 111 | }, _callee3, this); 112 | })); 113 | 114 | function setText(_x4, _x5) { 115 | return _ref3.apply(this, arguments); 116 | } 117 | 118 | return setText; 119 | }() 120 | }, { 121 | key: "setValue", 122 | value: function () { 123 | var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(txt, val) { 124 | return regeneratorRuntime.wrap(function _callee4$(_context4) { 125 | while (1) { 126 | switch (_context4.prev = _context4.next) { 127 | case 0: 128 | if (!(this.history[txt] == val)) { 129 | _context4.next = 2; 130 | break; 131 | } 132 | 133 | return _context4.abrupt("return"); 134 | 135 | case 2: 136 | this.history[txt] = val; 137 | _context4.next = 5; 138 | return this.nextion.setValue(txt, val); 139 | 140 | case 5: 141 | case "end": 142 | return _context4.stop(); 143 | } 144 | } 145 | }, _callee4, this); 146 | })); 147 | 148 | function setValue(_x6, _x7) { 149 | return _ref4.apply(this, arguments); 150 | } 151 | 152 | return setValue; 153 | }() 154 | }, { 155 | key: "getValue", 156 | value: function () { 157 | var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(txt) { 158 | return regeneratorRuntime.wrap(function _callee5$(_context5) { 159 | while (1) { 160 | switch (_context5.prev = _context5.next) { 161 | case 0: 162 | _context5.next = 2; 163 | return this.nextion.getValue(txt); 164 | 165 | case 2: 166 | return _context5.abrupt("return", _context5.sent); 167 | 168 | case 3: 169 | case "end": 170 | return _context5.stop(); 171 | } 172 | } 173 | }, _callee5, this); 174 | })); 175 | 176 | function getValue(_x8) { 177 | return _ref5.apply(this, arguments); 178 | } 179 | 180 | return getValue; 181 | }() 182 | }, { 183 | key: "update", 184 | value: function () { 185 | var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(status) { 186 | return regeneratorRuntime.wrap(function _callee6$(_context6) { 187 | while (1) { 188 | switch (_context6.prev = _context6.next) { 189 | case 0: 190 | case "end": 191 | return _context6.stop(); 192 | } 193 | } 194 | }, _callee6, this); 195 | })); 196 | 197 | function update(_x9) { 198 | return _ref6.apply(this, arguments); 199 | } 200 | 201 | return update; 202 | }() 203 | }, { 204 | key: "dispose", 205 | value: function dispose() { 206 | this.enabled = false; 207 | 208 | for (var i = 0; i < this.listener.length; i++) { 209 | this.nextion.removeListener(this.listener[i].btn, this.listener[i].callback); 210 | } 211 | } 212 | }]); 213 | 214 | return Abstract; 215 | }(); 216 | 217 | exports.default = Abstract; -------------------------------------------------------------------------------- /bin/services/utils/threejs-extras/STLLoader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * @author aleeper / http://adamleeper.com/ 5 | * @author mrdoob / http://mrdoob.com/ 6 | * @author gero3 / https://github.com/gero3 7 | * @author Mugen87 / https://github.com/Mugen87 8 | * 9 | * Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs. 10 | * 11 | * Supports both binary and ASCII encoded files, with automatic detection of type. 12 | * 13 | * The loader returns a non-indexed buffer geometry. 14 | * 15 | * Limitations: 16 | * Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL). 17 | * There is perhaps some question as to how valid it is to always assume little-endian-ness. 18 | * ASCII decoding assumes file is UTF-8. 19 | * 20 | * Usage: 21 | * var loader = new THREE.STLLoader(); 22 | * loader.load( './models/stl/slotted_disk.stl', function ( geometry ) { 23 | * scene.add( new THREE.Mesh( geometry ) ); 24 | * }); 25 | * 26 | * For binary STLs geometry might contain colors for vertices. To use it: 27 | * // use the same code to load STL as above 28 | * if (geometry.hasColors) { 29 | * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors }); 30 | * } else { .... } 31 | * var mesh = new THREE.Mesh( geometry, material ); 32 | */ 33 | 34 | THREE.STLLoader = function (manager) { 35 | 36 | this.manager = manager !== undefined ? manager : THREE.DefaultLoadingManager; 37 | }; 38 | 39 | THREE.STLLoader.prototype = { 40 | 41 | constructor: THREE.STLLoader, 42 | 43 | load: function load(url, onLoad, onProgress, onError) { 44 | 45 | var scope = this; 46 | 47 | var loader = new THREE.FileLoader(scope.manager); 48 | loader.setResponseType('arraybuffer'); 49 | loader.load(url, function (text) { 50 | 51 | onLoad(scope.parse(text)); 52 | }, onProgress, onError); 53 | }, 54 | 55 | parse: function parse(data) { 56 | 57 | var isBinary = function isBinary() { 58 | 59 | var expect, face_size, n_faces, reader; 60 | reader = new DataView(binData); 61 | face_size = 32 / 8 * 3 + 32 / 8 * 3 * 3 + 16 / 8; 62 | n_faces = reader.getUint32(80, true); 63 | expect = 80 + 32 / 8 + n_faces * face_size; 64 | 65 | if (expect === reader.byteLength) { 66 | 67 | return true; 68 | } 69 | 70 | // some binary files will have different size from expected, 71 | // checking characters higher than ASCII to confirm is binary 72 | var fileLength = reader.byteLength; 73 | for (var index = 0; index < fileLength; index++) { 74 | 75 | if (reader.getUint8(index, false) > 127) { 76 | 77 | return true; 78 | } 79 | } 80 | 81 | return false; 82 | }; 83 | 84 | var binData = this.ensureBinary(data); 85 | 86 | return isBinary() ? this.parseBinary(binData) : this.parseASCII(this.ensureString(data)); 87 | }, 88 | 89 | parseBinary: function parseBinary(data) { 90 | 91 | var reader = new DataView(data); 92 | var faces = reader.getUint32(80, true); 93 | 94 | var r, 95 | g, 96 | b, 97 | hasColors = false, 98 | colors; 99 | var defaultR, defaultG, defaultB, alpha; 100 | 101 | // process STL header 102 | // check for default color in header ("COLOR=rgba" sequence). 103 | 104 | for (var index = 0; index < 80 - 10; index++) { 105 | 106 | if (reader.getUint32(index, false) == 0x434F4C4F /*COLO*/ && reader.getUint8(index + 4) == 0x52 /*'R'*/ && reader.getUint8(index + 5) == 0x3D /*'='*/) { 107 | 108 | hasColors = true; 109 | colors = []; 110 | 111 | defaultR = reader.getUint8(index + 6) / 255; 112 | defaultG = reader.getUint8(index + 7) / 255; 113 | defaultB = reader.getUint8(index + 8) / 255; 114 | alpha = reader.getUint8(index + 9) / 255; 115 | } 116 | } 117 | 118 | var dataOffset = 84; 119 | var faceLength = 12 * 4 + 2; 120 | 121 | var geometry = new THREE.BufferGeometry(); 122 | 123 | var vertices = []; 124 | var normals = []; 125 | for (var face = 0; face < faces; face++) { 126 | var start = dataOffset + face * faceLength; 127 | var normalX = reader.getFloat32(start, true); 128 | var normalY = reader.getFloat32(start + 4, true); 129 | var normalZ = reader.getFloat32(start + 8, true); 130 | 131 | if (hasColors) { 132 | 133 | var packedColor = reader.getUint16(start + 48, true); 134 | 135 | if ((packedColor & 0x8000) === 0) { 136 | 137 | // facet has its own unique color 138 | 139 | r = (packedColor & 0x1F) / 31; 140 | g = (packedColor >> 5 & 0x1F) / 31; 141 | b = (packedColor >> 10 & 0x1F) / 31; 142 | } else { 143 | 144 | r = defaultR; 145 | g = defaultG; 146 | b = defaultB; 147 | } 148 | } 149 | 150 | for (var i = 1; i <= 3; i++) { 151 | 152 | var vertexstart = start + i * 12; 153 | 154 | vertices.push(reader.getFloat32(vertexstart, true)); 155 | vertices.push(reader.getFloat32(vertexstart + 4, true)); 156 | vertices.push(reader.getFloat32(vertexstart + 8, true)); 157 | 158 | normals.push(normalX, normalY, normalZ); 159 | 160 | if (hasColors) { 161 | 162 | colors.push(r, g, b); 163 | } 164 | } 165 | } 166 | 167 | geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(vertices), 3)); 168 | geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(normals), 3)); 169 | 170 | if (hasColors) { 171 | 172 | geometry.addAttribute('color', new THREE.BufferAttribute(new Float32Array(colors), 3)); 173 | geometry.hasColors = true; 174 | geometry.alpha = alpha; 175 | } 176 | 177 | return geometry; 178 | }, 179 | 180 | parseASCII: function parseASCII(data) { 181 | 182 | var geometry, length, patternFace, patternNormal, patternVertex, result, text; 183 | geometry = new THREE.BufferGeometry(); 184 | patternFace = /facet([\s\S]*?)endfacet/g; 185 | 186 | var vertices = []; 187 | var normals = []; 188 | 189 | var normal = new THREE.Vector3(); 190 | 191 | while ((result = patternFace.exec(data)) !== null) { 192 | 193 | text = result[0]; 194 | patternNormal = /normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g; 195 | 196 | while ((result = patternNormal.exec(text)) !== null) { 197 | 198 | normal.x = parseFloat(result[1]); 199 | normal.y = parseFloat(result[3]); 200 | normal.z = parseFloat(result[5]); 201 | } 202 | 203 | patternVertex = /vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g; 204 | 205 | while ((result = patternVertex.exec(text)) !== null) { 206 | 207 | vertices.push(parseFloat(result[1]), parseFloat(result[3]), parseFloat(result[5])); 208 | normals.push(normal.x, normal.y, normal.z); 209 | } 210 | } 211 | 212 | geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(vertices), 3)); 213 | geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(normals), 3)); 214 | 215 | return geometry; 216 | }, 217 | 218 | ensureString: function ensureString(buf) { 219 | 220 | if (typeof buf !== "string") { 221 | 222 | var array_buffer = new Uint8Array(buf); 223 | var strArray = []; 224 | for (var i = 0; i < buf.byteLength; i++) { 225 | 226 | strArray.push(String.fromCharCode(array_buffer[i])); // implicitly assumes little-endian 227 | } 228 | return strArray.join(''); 229 | } else { 230 | 231 | return buf; 232 | } 233 | }, 234 | 235 | ensureBinary: function ensureBinary(buf) { 236 | return new Uint8Array(buf).buffer; 237 | 238 | // return buf; 239 | // if ( typeof buf === "string" ) { 240 | 241 | // var array_buffer = new Uint8Array( buf.length ); 242 | // for ( var i = 0; i < buf.length; i ++ ) { 243 | 244 | // array_buffer[ i ] = buf.charCodeAt( i ) & 0xff; // implicitly assumes little-endian 245 | 246 | // } 247 | // return array_buffer.buffer || array_buffer; 248 | 249 | // } else { 250 | 251 | // return buf; 252 | 253 | // } 254 | } 255 | 256 | }; -------------------------------------------------------------------------------- /src/services/utils/threejs-extras/STLLoader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author aleeper / http://adamleeper.com/ 3 | * @author mrdoob / http://mrdoob.com/ 4 | * @author gero3 / https://github.com/gero3 5 | * @author Mugen87 / https://github.com/Mugen87 6 | * 7 | * Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs. 8 | * 9 | * Supports both binary and ASCII encoded files, with automatic detection of type. 10 | * 11 | * The loader returns a non-indexed buffer geometry. 12 | * 13 | * Limitations: 14 | * Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL). 15 | * There is perhaps some question as to how valid it is to always assume little-endian-ness. 16 | * ASCII decoding assumes file is UTF-8. 17 | * 18 | * Usage: 19 | * var loader = new THREE.STLLoader(); 20 | * loader.load( './models/stl/slotted_disk.stl', function ( geometry ) { 21 | * scene.add( new THREE.Mesh( geometry ) ); 22 | * }); 23 | * 24 | * For binary STLs geometry might contain colors for vertices. To use it: 25 | * // use the same code to load STL as above 26 | * if (geometry.hasColors) { 27 | * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors }); 28 | * } else { .... } 29 | * var mesh = new THREE.Mesh( geometry, material ); 30 | */ 31 | 32 | 33 | THREE.STLLoader = function ( manager ) { 34 | 35 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; 36 | 37 | }; 38 | 39 | THREE.STLLoader.prototype = { 40 | 41 | constructor: THREE.STLLoader, 42 | 43 | load: function ( url, onLoad, onProgress, onError ) { 44 | 45 | var scope = this; 46 | 47 | var loader = new THREE.FileLoader( scope.manager ); 48 | loader.setResponseType( 'arraybuffer' ); 49 | loader.load( url, function ( text ) { 50 | 51 | onLoad( scope.parse( text ) ); 52 | 53 | }, onProgress, onError ); 54 | 55 | }, 56 | 57 | parse: function ( data ) { 58 | 59 | var isBinary = function () { 60 | 61 | var expect, face_size, n_faces, reader; 62 | reader = new DataView( binData ); 63 | face_size = ( 32 / 8 * 3 ) + ( ( 32 / 8 * 3 ) * 3 ) + ( 16 / 8 ); 64 | n_faces = reader.getUint32( 80, true ); 65 | expect = 80 + ( 32 / 8 ) + ( n_faces * face_size ); 66 | 67 | if ( expect === reader.byteLength ) { 68 | 69 | return true; 70 | 71 | } 72 | 73 | // some binary files will have different size from expected, 74 | // checking characters higher than ASCII to confirm is binary 75 | var fileLength = reader.byteLength; 76 | for ( var index = 0; index < fileLength; index ++ ) { 77 | 78 | if ( reader.getUint8( index, false ) > 127 ) { 79 | 80 | return true; 81 | 82 | } 83 | 84 | } 85 | 86 | return false; 87 | 88 | }; 89 | 90 | var binData = this.ensureBinary( data ); 91 | 92 | return isBinary() ? this.parseBinary( binData ) : this.parseASCII( this.ensureString( data ) ); 93 | 94 | }, 95 | 96 | parseBinary: function ( data ) { 97 | 98 | var reader = new DataView( data ); 99 | var faces = reader.getUint32( 80, true ); 100 | 101 | var r, g, b, hasColors = false, colors; 102 | var defaultR, defaultG, defaultB, alpha; 103 | 104 | // process STL header 105 | // check for default color in header ("COLOR=rgba" sequence). 106 | 107 | for ( var index = 0; index < 80 - 10; index ++ ) { 108 | 109 | if ( ( reader.getUint32( index, false ) == 0x434F4C4F /*COLO*/ ) && 110 | ( reader.getUint8( index + 4 ) == 0x52 /*'R'*/ ) && 111 | ( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) { 112 | 113 | hasColors = true; 114 | colors = []; 115 | 116 | defaultR = reader.getUint8( index + 6 ) / 255; 117 | defaultG = reader.getUint8( index + 7 ) / 255; 118 | defaultB = reader.getUint8( index + 8 ) / 255; 119 | alpha = reader.getUint8( index + 9 ) / 255; 120 | 121 | } 122 | 123 | } 124 | 125 | var dataOffset = 84; 126 | var faceLength = 12 * 4 + 2; 127 | 128 | var geometry = new THREE.BufferGeometry(); 129 | 130 | var vertices = []; 131 | var normals = []; 132 | for ( var face = 0; face < faces; face ++ ) { 133 | var start = dataOffset + face * faceLength; 134 | var normalX = reader.getFloat32( start, true ); 135 | var normalY = reader.getFloat32( start + 4, true ); 136 | var normalZ = reader.getFloat32( start + 8, true ); 137 | 138 | if ( hasColors ) { 139 | 140 | var packedColor = reader.getUint16( start + 48, true ); 141 | 142 | if ( ( packedColor & 0x8000 ) === 0 ) { 143 | 144 | // facet has its own unique color 145 | 146 | r = ( packedColor & 0x1F ) / 31; 147 | g = ( ( packedColor >> 5 ) & 0x1F ) / 31; 148 | b = ( ( packedColor >> 10 ) & 0x1F ) / 31; 149 | 150 | } else { 151 | 152 | r = defaultR; 153 | g = defaultG; 154 | b = defaultB; 155 | 156 | } 157 | 158 | } 159 | 160 | for ( var i = 1; i <= 3; i ++ ) { 161 | 162 | var vertexstart = start + i * 12; 163 | 164 | vertices.push( reader.getFloat32( vertexstart, true ) ); 165 | vertices.push( reader.getFloat32( vertexstart + 4, true ) ); 166 | vertices.push( reader.getFloat32( vertexstart + 8, true ) ); 167 | 168 | normals.push( normalX, normalY, normalZ ); 169 | 170 | if ( hasColors ) { 171 | 172 | colors.push( r, g, b ); 173 | 174 | } 175 | 176 | } 177 | } 178 | 179 | geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertices ), 3 ) ); 180 | geometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( normals ), 3 ) ); 181 | 182 | if ( hasColors ) { 183 | 184 | geometry.addAttribute( 'color', new THREE.BufferAttribute( new Float32Array( colors ), 3 ) ); 185 | geometry.hasColors = true; 186 | geometry.alpha = alpha; 187 | 188 | } 189 | 190 | return geometry; 191 | 192 | }, 193 | 194 | parseASCII: function ( data ) { 195 | 196 | var geometry, length, patternFace, patternNormal, patternVertex, result, text; 197 | geometry = new THREE.BufferGeometry(); 198 | patternFace = /facet([\s\S]*?)endfacet/g; 199 | 200 | var vertices = []; 201 | var normals = []; 202 | 203 | var normal = new THREE.Vector3(); 204 | 205 | while ( ( result = patternFace.exec( data ) ) !== null ) { 206 | 207 | text = result[ 0 ]; 208 | patternNormal = /normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g; 209 | 210 | while ( ( result = patternNormal.exec( text ) ) !== null ) { 211 | 212 | normal.x = parseFloat( result[ 1 ] ); 213 | normal.y = parseFloat( result[ 3 ] ); 214 | normal.z = parseFloat( result[ 5 ] ); 215 | 216 | } 217 | 218 | patternVertex = /vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g; 219 | 220 | while ( ( result = patternVertex.exec( text ) ) !== null ) { 221 | 222 | vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 3 ] ), parseFloat( result[ 5 ] ) ); 223 | normals.push( normal.x, normal.y, normal.z ); 224 | 225 | } 226 | 227 | } 228 | 229 | geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertices ), 3 ) ); 230 | geometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( normals ), 3 ) ); 231 | 232 | return geometry; 233 | 234 | }, 235 | 236 | ensureString: function ( buf ) { 237 | 238 | if ( typeof buf !== "string" ) { 239 | 240 | var array_buffer = new Uint8Array( buf ); 241 | var strArray = []; 242 | for ( var i = 0; i < buf.byteLength; i ++ ) { 243 | 244 | strArray.push(String.fromCharCode( array_buffer[ i ] )); // implicitly assumes little-endian 245 | 246 | } 247 | return strArray.join(''); 248 | 249 | } else { 250 | 251 | return buf; 252 | 253 | } 254 | 255 | }, 256 | 257 | ensureBinary: function ( buf ) { 258 | return new Uint8Array(buf).buffer; 259 | 260 | // return buf; 261 | // if ( typeof buf === "string" ) { 262 | 263 | // var array_buffer = new Uint8Array( buf.length ); 264 | // for ( var i = 0; i < buf.length; i ++ ) { 265 | 266 | // array_buffer[ i ] = buf.charCodeAt( i ) & 0xff; // implicitly assumes little-endian 267 | 268 | // } 269 | // return array_buffer.buffer || array_buffer; 270 | 271 | // } else { 272 | 273 | // return buf; 274 | 275 | // } 276 | 277 | } 278 | 279 | }; 280 | -------------------------------------------------------------------------------- /bin/plugins/nextion/pages/printingHome.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = undefined; 7 | 8 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 | 10 | var _abstract2 = require("./abstract.js"); 11 | 12 | var _abstract3 = _interopRequireDefault(_abstract2); 13 | 14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 15 | 16 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 17 | 18 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 19 | 20 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 21 | 22 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 23 | 24 | require("babel-polyfill"); 25 | 26 | var PrintingHome = function (_abstract) { 27 | _inherits(PrintingHome, _abstract); 28 | 29 | function PrintingHome(screenManager) { 30 | _classCallCheck(this, PrintingHome); 31 | 32 | var _this = _possibleConstructorReturn(this, (PrintingHome.__proto__ || Object.getPrototypeOf(PrintingHome)).call(this, screenManager)); 33 | 34 | _this.layerID = -1; 35 | _this.isPause = null; 36 | return _this; 37 | } 38 | 39 | _createClass(PrintingHome, [{ 40 | key: "init", 41 | value: function () { 42 | var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { 43 | var _this2 = this; 44 | 45 | return regeneratorRuntime.wrap(function _callee$(_context) { 46 | while (1) { 47 | switch (_context.prev = _context.next) { 48 | case 0: 49 | 50 | this.addListener("click_b10", function (e) { 51 | console.log("printSettings"); 52 | _this2.changePage("printSettings"); 53 | }); 54 | 55 | this.addListener("click_b11", function (e) { 56 | console.log("stats"); 57 | _this2.changePage("stats"); 58 | }); 59 | 60 | this.addListener("click_b9", function (e) { 61 | _this2.manager.nanoDLP.unpause(); 62 | }); 63 | 64 | case 3: 65 | case "end": 66 | return _context.stop(); 67 | } 68 | } 69 | }, _callee, this); 70 | })); 71 | 72 | function init() { 73 | return _ref.apply(this, arguments); 74 | } 75 | 76 | return init; 77 | }() 78 | }, { 79 | key: "update", 80 | value: function () { 81 | var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(status, log) { 82 | var remaining_time, total_time, image; 83 | return regeneratorRuntime.wrap(function _callee2$(_context2) { 84 | while (1) { 85 | switch (_context2.prev = _context2.next) { 86 | case 0: 87 | if (status.Printing) { 88 | _context2.next = 2; 89 | break; 90 | } 91 | 92 | return _context2.abrupt("return", this.changePage("home")); 93 | 94 | case 2: 95 | if (!(this.isPause == null || this.isPause !== status.Pause)) { 96 | _context2.next = 20; 97 | break; 98 | } 99 | 100 | this.isPause = status.Pause; 101 | 102 | if (!this.isPause) { 103 | _context2.next = 9; 104 | break; 105 | } 106 | 107 | _context2.next = 7; 108 | return this.setScreen("printingPause"); 109 | 110 | case 7: 111 | _context2.next = 11; 112 | break; 113 | 114 | case 9: 115 | _context2.next = 11; 116 | return this.setScreen("printing"); 117 | 118 | case 11: 119 | _context2.next = 13; 120 | return this.nextion.getValue("t12.x"); 121 | 122 | case 13: 123 | this.imageX = _context2.sent; 124 | _context2.next = 16; 125 | return this.nextion.getValue("t12.y"); 126 | 127 | case 16: 128 | this.imageY = _context2.sent; 129 | _context2.next = 19; 130 | return this.nextion.getValue("t12.w"); 131 | 132 | case 19: 133 | this.imageWidth = _context2.sent; 134 | 135 | case 20: 136 | _context2.next = 22; 137 | return this.setText("t6", this.isPause ? "Pause" : "Printing"); 138 | 139 | case 22: 140 | remaining_time = Math.round((status.LayersCount - status.LayerID) * status.LayerTime / 1000000000 / 60); 141 | total_time = Math.round(status.LayersCount * status.LayerTime / 1000000000 / 60); 142 | _context2.next = 26; 143 | return this.setText("t0", status.LayerID + "/" + status.LayersCount); 144 | 145 | case 26: 146 | _context2.next = 28; 147 | return this.setValue("j0", Math.floor(status.LayerID / status.LayersCount * 100)); 148 | 149 | case 28: 150 | _context2.next = 30; 151 | return this.setText("t1", remaining_time + " of " + total_time + "min"); 152 | 153 | case 30: 154 | _context2.next = 32; 155 | return this.setText("t2", log.msg); 156 | 157 | case 32: 158 | _context2.next = 34; 159 | return this.setText("t7", status.Path); 160 | 161 | case 34: 162 | if (!(this.history.layer != status.LayerID)) { 163 | _context2.next = 43; 164 | break; 165 | } 166 | 167 | this.history.layer = status.LayerID; 168 | console.log("setImage", this.history.layer); 169 | _context2.next = 39; 170 | return this.nanoDLP.getCurrentPlateLayer(status.PlateID, status.LayerID); 171 | 172 | case 39: 173 | image = _context2.sent; 174 | 175 | if (!this.enabled) { 176 | _context2.next = 43; 177 | break; 178 | } 179 | 180 | _context2.next = 43; 181 | return this.nextion.displayBlackWhiteImage(image, this.imageX, this.imageY, this.imageWidth).catch(function (e) { 182 | return console.error(e); 183 | }); 184 | 185 | case 43: 186 | case "end": 187 | return _context2.stop(); 188 | } 189 | } 190 | }, _callee2, this); 191 | })); 192 | 193 | function update(_x, _x2) { 194 | return _ref2.apply(this, arguments); 195 | } 196 | 197 | return update; 198 | }() 199 | }]); 200 | 201 | return PrintingHome; 202 | }(_abstract3.default); 203 | 204 | exports.default = PrintingHome; -------------------------------------------------------------------------------- /bin/plugins/nextion.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = undefined; 7 | 8 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 | 10 | var _abstract2 = require("./abstract.js"); 11 | 12 | var _abstract3 = _interopRequireDefault(_abstract2); 13 | 14 | var _nextionService = require("./nextion/nextionService.js"); 15 | 16 | var _nextionService2 = _interopRequireDefault(_nextionService); 17 | 18 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 19 | 20 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 21 | 22 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 23 | 24 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 25 | 26 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 27 | 28 | require("babel-polyfill"); 29 | 30 | var Confirm = function (_abstract) { 31 | _inherits(Confirm, _abstract); 32 | 33 | function Confirm(manager) { 34 | _classCallCheck(this, Confirm); 35 | 36 | var _this = _possibleConstructorReturn(this, (Confirm.__proto__ || Object.getPrototypeOf(Confirm)).call(this, manager)); 37 | 38 | _this.isPrinting = null; 39 | 40 | _this.nextion = new _nextionService2.default(_this.config.plugins.nextion); 41 | 42 | _this.nextion.on("disconnect", function () { 43 | _this.init().catch(function (e) { 44 | return console.error(e); 45 | }); 46 | }); 47 | return _this; 48 | } 49 | 50 | _createClass(Confirm, [{ 51 | key: "init", 52 | value: function () { 53 | var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { 54 | return regeneratorRuntime.wrap(function _callee$(_context) { 55 | while (1) { 56 | switch (_context.prev = _context.next) { 57 | case 0: 58 | this.isPrinting = null; 59 | this.currentPageId = null; 60 | 61 | console.log("connect to port " + this.config.plugins.nextion.port); 62 | 63 | _context.next = 5; 64 | return this.nextion.connect(); 65 | 66 | case 5: 67 | 68 | console.log("connected"); 69 | 70 | this.update(this.status, this.log).catch(function (e) { 71 | return console.error(e); 72 | }); 73 | 74 | case 7: 75 | case "end": 76 | return _context.stop(); 77 | } 78 | } 79 | }, _callee, this); 80 | })); 81 | 82 | function init() { 83 | return _ref.apply(this, arguments); 84 | } 85 | 86 | return init; 87 | }() 88 | }, { 89 | key: "update", 90 | value: function () { 91 | var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(status, log) { 92 | return regeneratorRuntime.wrap(function _callee2$(_context2) { 93 | while (1) { 94 | switch (_context2.prev = _context2.next) { 95 | case 0: 96 | if (status) { 97 | _context2.next = 2; 98 | break; 99 | } 100 | 101 | return _context2.abrupt("return"); 102 | 103 | case 2: 104 | 105 | this.status = status; 106 | this.log = log; 107 | 108 | clearTimeout(this.updateTimeOut); 109 | 110 | if (!(status.Printing !== this.isPrinting)) { 111 | _context2.next = 9; 112 | break; 113 | } 114 | 115 | this.isPrinting = status.Printing; 116 | _context2.next = 9; 117 | return this.setPage("home"); 118 | 119 | case 9: 120 | this.isPrinting = status.Printing; 121 | 122 | _context2.next = 12; 123 | return this.currentPage.update(status, log).catch(function (e) { 124 | return console.error(e); 125 | }); 126 | 127 | case 12: 128 | case "end": 129 | return _context2.stop(); 130 | } 131 | } 132 | }, _callee2, this); 133 | })); 134 | 135 | function update(_x, _x2) { 136 | return _ref2.apply(this, arguments); 137 | } 138 | 139 | return update; 140 | }() 141 | }, { 142 | key: "setPage", 143 | value: function () { 144 | var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(page, options) { 145 | var PageClass; 146 | return regeneratorRuntime.wrap(function _callee3$(_context3) { 147 | while (1) { 148 | switch (_context3.prev = _context3.next) { 149 | case 0: 150 | _context3.t0 = page; 151 | _context3.next = _context3.t0 === "home" ? 3 : 5; 152 | break; 153 | 154 | case 3: 155 | if (this.isPrinting) { 156 | page = "printingHome"; 157 | } else { 158 | page = "home"; 159 | } 160 | return _context3.abrupt("break", 5); 161 | 162 | case 5: 163 | if (!(this.currentPageId == page)) { 164 | _context3.next = 7; 165 | break; 166 | } 167 | 168 | return _context3.abrupt("return"); 169 | 170 | case 7: 171 | 172 | console.log("setPage", page, "./nextion/pages/" + page + ".js"); 173 | _context3.prev = 8; 174 | PageClass = require("./nextion/pages/" + page + ".js").default; 175 | _context3.next = 16; 176 | break; 177 | 178 | case 12: 179 | _context3.prev = 12; 180 | _context3.t1 = _context3["catch"](8); 181 | 182 | console.log("page ./nextion/pages/" + page + ".js do not exist"); 183 | return _context3.abrupt("return"); 184 | 185 | case 16: 186 | 187 | if (this.currentPage) { 188 | try { 189 | this.currentPage.dispose(); 190 | } catch (e) { 191 | console.error(e); 192 | } 193 | } 194 | 195 | this.currentPageId = page; 196 | this.currentPage = new PageClass(this); 197 | 198 | _context3.next = 21; 199 | return new Promise(function (resolve) { 200 | return setTimeout(resolve, 100); 201 | }); 202 | 203 | case 21: 204 | this.currentPage.init(options).catch(function (e) { 205 | return console.error(e); 206 | }); 207 | 208 | _context3.next = 24; 209 | return this.update(this.status, this.log); 210 | 211 | case 24: 212 | case "end": 213 | return _context3.stop(); 214 | } 215 | } 216 | }, _callee3, this, [[8, 12]]); 217 | })); 218 | 219 | function setPage(_x3, _x4) { 220 | return _ref3.apply(this, arguments); 221 | } 222 | 223 | return setPage; 224 | }() 225 | }]); 226 | 227 | return Confirm; 228 | }(_abstract3.default); 229 | 230 | exports.default = Confirm; -------------------------------------------------------------------------------- /src/plugins/nextion/nextionService.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import debug_ from 'debug'; 4 | 5 | require("babel-polyfill"); 6 | 7 | import SerialPort from 'serialport'; 8 | import {EventEmitter} from 'events'; 9 | import sharp from 'sharp'; 10 | 11 | const NextionEvent = { 12 | 0x00: 'invalidInstruction', 13 | 0x01: 'success', 14 | 0x02: 'invalidComponentID', 15 | 0x03: 'invalidPageID', 16 | 0x04: 'invalidPictureID', 17 | 0x05: 'invalidFontID', 18 | 0x11: 'invalidBaudRate', 19 | 0x12: 'invalidCurveControl', 20 | 0x1a: 'invalidVariableName', 21 | 0x1b: 'invalidVariableOperation', 22 | 0x1c: 'assignmentFailure', 23 | 0x1d: 'eepromFailure', 24 | 0x1e: 'invalidParameterQuantity', 25 | 0x1f: 'ioOperationFailure', 26 | 0x20: 'undefinedEscapeCharacter', 27 | 0x23: 'variableNameTooLong', 28 | 0x70: 'stringData', 29 | 0x71: 'numericData', 30 | 0x65: 'touchEvent', 31 | 0x66: 'pageId', 32 | 0x67: 'touchCoordinate', 33 | 0x68: 'touchCoordinateOnWake', 34 | 0x86: 'autoSleep', 35 | 0x87: 'autoWake', 36 | 0x88: 'startup', 37 | 0x89: 'cardUpgrade', 38 | 0xfd: 'transmitFinished', 39 | 0xfe: 'transmitReady' 40 | } 41 | 42 | const debug = debug_('nextion'); 43 | 44 | export default class NextionService extends EventEmitter{ 45 | 46 | _buffer; 47 | 48 | constructor(config) { 49 | super(); 50 | 51 | this._buffer = new Buffer([]); 52 | this.config = config; 53 | } 54 | 55 | async connect(){ 56 | 57 | debug("serialport open"); 58 | 59 | let open = false; 60 | while (open == false) { 61 | try { 62 | await new Promise(function(resolve, reject) { 63 | SerialPort.list((err, ports)=>{ 64 | console.log("list", ports); 65 | resolve(); 66 | }); 67 | }); 68 | 69 | this.port = new SerialPort(this.config.port, { 70 | autoOpen: false, baudRate:115200}); 71 | await new Promise((resolve, reject) => this.port.open(resolve)); 72 | await new Promise((r)=> setTimeout(r, 1000)); 73 | await this._initScreen(); 74 | open = true; 75 | } catch (e) { 76 | await new Promise((r)=> setTimeout(r, 1000)); 77 | console.log("error opening port ", this.config.port, "retry in 2 seconds"); 78 | } 79 | } 80 | 81 | process.on('SIGINT', () => { 82 | this.setPage("connection"); 83 | process.exit(); 84 | }); 85 | } 86 | 87 | async setPage(num){ 88 | await this._writeUart('page '+num); 89 | } 90 | 91 | async setText(cmp, txt){ 92 | let text = txt.toString().split("\r").join('"+"\\r"+"'); 93 | await this._writeUart(cmp+'.txt="'+text+'"'); 94 | } 95 | 96 | async setValue(cmp, txt){ 97 | await this._writeUart(cmp+'.val='+txt+''); 98 | } 99 | 100 | async addToWaveForm(cmp, channel, value){ 101 | // console.log(`add ${cmp},${channel},${value.toInt()}`); 102 | await this._writeUart(`add ${cmp},${channel},${value}`); 103 | } 104 | 105 | async setVis(cmp, value){ 106 | var val = value ? "1":"0"; 107 | await this._writeUart('vis '+cmp+','+val); 108 | } 109 | 110 | async setLine(x, y, x2, y2, color){ 111 | await this._writeUart(`line ${x},${y},${x2},${y2},${color}`, false); 112 | } 113 | 114 | async setFill(x, y, width, height, color){ 115 | await this._writeUart(`fill ${x},${y},${width},${height},${color}`, false); 116 | } 117 | 118 | async stopRefresh(cmp, bco){ 119 | await this._writeUart("ref_stop"); 120 | } 121 | 122 | async startRefresh(cmp, bco){ 123 | await this._writeUart("ref_star"); 124 | } 125 | 126 | async setColor(cmp, bco){ 127 | await this._writeUart(cmp + ".bco=" + bco); 128 | await this._writeUart("ref " + cmp); 129 | } 130 | 131 | async getPage(){ 132 | var page = await this._writeUart('sendme'); 133 | return page[0]; 134 | } 135 | 136 | async getValue(cmp){ 137 | var result = await this._writeUart('get '+cmp); 138 | return (result[1] * 256 + result[0]); 139 | } 140 | 141 | async displayBlackWhiteImage(buffer, positionX, positionY, width){ 142 | //debug(url); 143 | const image = sharp(buffer); 144 | 145 | image.metadata() 146 | .then((metadata) => { 147 | image 148 | .rotate((metadata.width>=metadata.height)?0:90) 149 | .resize(width) 150 | .extractChannel(1) 151 | //.toFile(__dirname+"/../1.min.png"); 152 | .raw() 153 | .toBuffer(async (err, data, info)=> { 154 | debug(err); 155 | debug(data.length); 156 | debug(data); 157 | debug(info); 158 | 159 | //debug("fill", info.width, info.height, "0"); 160 | this.setFill(positionX, positionY, info.width, info.height, 0); 161 | 162 | let index = 0; 163 | let numLine = 0; 164 | for (let i = 0; i < info.height; i++) { 165 | //debug("line ", i); 166 | var x = -1; 167 | var currentXColor = -1; 168 | let j = 0; 169 | for (j = 0; j < info.width; j++) { 170 | var currentColor = data[index] <= 50 ? 0 : 1; 171 | //debug(data[index]); 172 | if (j == 0) { 173 | currentXColor = currentColor; 174 | } else if (currentColor != currentXColor) { 175 | if (currentXColor == 1) { 176 | this.setLine(x + positionX, i + positionY, j - 1 + positionX, i + positionY, 0xFFFFFF); 177 | debug("setLine", ++numLine, "y", i, "from", x, "to", j - 1, "color", currentXColor); 178 | } 179 | x = j - 1; 180 | currentXColor = currentColor; 181 | } 182 | index++; 183 | } 184 | if (x == 0 && currentXColor != 0) { 185 | this.setLine(x+positionX, i+positionY, j-1+positionX, i+positionY, 0xFFFFFF); 186 | debug("setLine", ++numLine, "y", i, "from", x, "to", j - 1, "color", currentXColor); 187 | } 188 | } 189 | debug("time = ", new Date().getTime() - date); 190 | }); 191 | }); 192 | } 193 | 194 | 195 | //private 196 | 197 | async _initScreen(){ 198 | //await new Promise((resolve) => setTimeout(resolve, 1000)); 199 | this.port.on("close", ()=>{ 200 | this.emit("disconnect"); 201 | }); 202 | 203 | this.port.on('data', (byte) => { 204 | this._buffer = Buffer.concat([this._buffer, byte]); 205 | this._readBuffer(); 206 | }); 207 | 208 | this._writeUart('sleep=0'); 209 | 210 | await this._writeUart('bkcmd=3'); 211 | 212 | await this._writeUart('thup=1'); 213 | 214 | if (this.config.hasOwnProperty("sleep")) 215 | await this._writeUart('thsp=' + this.config.sleep); 216 | 217 | //await this._writeUart('bauds=115200'); 218 | 219 | debug("screenInitialized"); 220 | } 221 | 222 | _readBuffer(){ 223 | let index = this._buffer.indexOf(delimiterBuffer); 224 | if (index>=0) { 225 | let result = this._parseData(this._buffer.slice(0, index)); 226 | this.emit("data", result); 227 | debug("event", NextionEvent[result.event], ":", result.event.toString(16), result.data); 228 | switch (NextionEvent[result.event]) { 229 | case "touchEvent": 230 | debug("emit : ", "click_b"+result.data[1].toString()); 231 | this.emit("click_b"+result.data[1].toString()); 232 | break; 233 | 234 | case "numericData": 235 | debug("emit : ", "number"); 236 | this.emit("number", result.data[0]); 237 | break; 238 | 239 | case "stringData": 240 | debug("emit : ", "string", result.data.toString()); 241 | this.emit("string", result.data.toString()); 242 | break; 243 | 244 | default: 245 | this.emit(NextionEvent[result.event], result.data); 246 | } 247 | 248 | this._buffer = this._buffer.slice(index+3); 249 | this._readBuffer(); 250 | } 251 | } 252 | 253 | _parseData(buffer){ 254 | let result = {}; 255 | result.event = buffer[0]; 256 | result.data = buffer.slice(1); 257 | return result; 258 | } 259 | 260 | 261 | async _writeUart(cmd, wait = true){ 262 | debug("send command : "+cmd); 263 | this.port.write(this.hex(cmd)); 264 | if(wait) 265 | return await this._waitForResult(); 266 | } 267 | 268 | async _waitForResult(){ 269 | return await new Promise((resolve, reject) => { 270 | this.once("data", (data)=>{ 271 | debug("receiveResult", data); 272 | if(NextionEvent[data.event] !== null){ 273 | return resolve(data.data); 274 | } 275 | 276 | return reject(data.data); 277 | }) 278 | }); 279 | 280 | } 281 | 282 | hex(str) { 283 | var arr = []; 284 | for (var i = 0, l = str.length; i < l; i ++) { 285 | var ascii = str.charCodeAt(i); 286 | arr.push(ascii); 287 | } 288 | arr.push(255); 289 | arr.push(255); 290 | arr.push(255); 291 | return new Buffer(arr); 292 | } 293 | } 294 | 295 | export const delimiter = [ 296 | 0xff, 297 | 0xff, 298 | 0xff 299 | ]; 300 | 301 | export const delimiterBuffer = Buffer.from(delimiter); -------------------------------------------------------------------------------- /bin/plugins/nextion/pages/plate.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = undefined; 7 | 8 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 | 10 | var _abstract2 = require("./abstract.js"); 11 | 12 | var _abstract3 = _interopRequireDefault(_abstract2); 13 | 14 | var _lodash = require("lodash"); 15 | 16 | var _lodash2 = _interopRequireDefault(_lodash); 17 | 18 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 19 | 20 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 21 | 22 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 23 | 24 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 25 | 26 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 27 | 28 | require("babel-polyfill"); 29 | 30 | var Plate = function (_abstract) { 31 | _inherits(Plate, _abstract); 32 | 33 | function Plate(screenManager) { 34 | _classCallCheck(this, Plate); 35 | 36 | var _this = _possibleConstructorReturn(this, (Plate.__proto__ || Object.getPrototypeOf(Plate)).call(this, screenManager)); 37 | 38 | _this.currentViewID = 0; 39 | return _this; 40 | } 41 | 42 | _createClass(Plate, [{ 43 | key: "init", 44 | value: function () { 45 | var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(plate) { 46 | var _this2 = this; 47 | 48 | return regeneratorRuntime.wrap(function _callee3$(_context3) { 49 | while (1) { 50 | switch (_context3.prev = _context3.next) { 51 | case 0: 52 | _context3.next = 2; 53 | return this.setScreen("plate"); 54 | 55 | case 2: 56 | 57 | this.plate = plate; 58 | _context3.next = 5; 59 | return this.nanoDLP.getProfiles(); 60 | 61 | case 5: 62 | this.profiles = _context3.sent; 63 | 64 | this.profile = this.profiles[_lodash2.default.findIndex(this.profiles, { ProfileID: this.plate.ProfileID })]; 65 | 66 | _context3.next = 9; 67 | return this.getValue("t12.x"); 68 | 69 | case 9: 70 | this.imageX = _context3.sent; 71 | _context3.next = 12; 72 | return this.getValue("t12.y"); 73 | 74 | case 12: 75 | this.imageY = _context3.sent; 76 | _context3.next = 15; 77 | return this.getValue("t12.w"); 78 | 79 | case 15: 80 | this.imageWidth = _context3.sent; 81 | 82 | 83 | this.setText("t0", this.plate.Path); 84 | this.setText("t1", this.profile.Title + " (" + this.profile.Depth + "um)"); 85 | this.setText("t3", this.plate.TotalSolidArea + "ml"); 86 | this.setText("t7", this.plate.LayersCount + " layers"); 87 | 88 | this.addListener("click_b2", function (e) { 89 | _this2.changePage("plates"); 90 | }); 91 | 92 | this.addListener("click_b9", _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { 93 | return regeneratorRuntime.wrap(function _callee$(_context) { 94 | while (1) { 95 | switch (_context.prev = _context.next) { 96 | case 0: 97 | _context.next = 2; 98 | return _this2.nanoDLP.command("/printer/start/" + _this2.plate.PlateID); 99 | 100 | case 2: 101 | _this2.changePage("home"); 102 | 103 | case 3: 104 | case "end": 105 | return _context.stop(); 106 | } 107 | } 108 | }, _callee, _this2); 109 | }))); 110 | 111 | this.addListener("click_b15", _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { 112 | return regeneratorRuntime.wrap(function _callee2$(_context2) { 113 | while (1) { 114 | switch (_context2.prev = _context2.next) { 115 | case 0: 116 | _this2.changePage("confirm", { 117 | text: "Are you sure you want to delete\rthe following plate:\r\r" + _this2.plate.Path, 118 | confirmType: "deleteplate", 119 | data0: _this2.plate.PlateID, 120 | returnPage: "plates" 121 | }); 122 | 123 | case 1: 124 | case "end": 125 | return _context2.stop(); 126 | } 127 | } 128 | }, _callee2, _this2); 129 | }))); 130 | 131 | /* 132 | this.addListener("click_b12", (e)=>{ 133 | this.set3DView(++this.currentViewID); 134 | }); 135 | */ 136 | 137 | this.gap = 100 / this.plate.LayersCount; 138 | 139 | this.addListener("number", function (index) { 140 | index = Math.floor(index / _this2.gap); 141 | _this2.setLayer(index); 142 | }); 143 | 144 | _context3.next = 27; 145 | return this.setLayer(1); 146 | 147 | case 27: 148 | case "end": 149 | return _context3.stop(); 150 | } 151 | } 152 | }, _callee3, this); 153 | })); 154 | 155 | function init(_x) { 156 | return _ref.apply(this, arguments); 157 | } 158 | 159 | return init; 160 | }() 161 | 162 | /* 163 | async set3DView(index){ 164 | await this.setText("t12", "Loading "); 165 | var image = await this.manager.nanoDLP.getCurrentPlate3DView(this.plate.PlateID, this.currentViewID%4); 166 | if(this.enabled) 167 | await this.nextion.displayBlackWhiteImage(image, this.imageX, this.imageY, this.imageWidth).catch(e => console.error(e)); 168 | }*/ 169 | 170 | }, { 171 | key: "setLayer", 172 | value: function () { 173 | var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(index) { 174 | var image; 175 | return regeneratorRuntime.wrap(function _callee4$(_context4) { 176 | while (1) { 177 | switch (_context4.prev = _context4.next) { 178 | case 0: 179 | this.index = index == 0 ? 1 : index; 180 | 181 | _context4.next = 3; 182 | return this.setText("t12", "Loading " + this.index + "/" + this.plate.LayersCount); 183 | 184 | case 3: 185 | this.setText("t9", "layer " + this.index + "/" + this.plate.LayersCount); 186 | _context4.next = 6; 187 | return this.nanoDLP.getCurrentPlateLayer(this.plate.PlateID, this.index); 188 | 189 | case 6: 190 | image = _context4.sent; 191 | 192 | if (!this.enabled) { 193 | _context4.next = 10; 194 | break; 195 | } 196 | 197 | _context4.next = 10; 198 | return this.nextion.displayBlackWhiteImage(image, this.imageX, this.imageY, this.imageWidth).catch(function (e) { 199 | return console.error(e); 200 | }); 201 | 202 | case 10: 203 | case "end": 204 | return _context4.stop(); 205 | } 206 | } 207 | }, _callee4, this); 208 | })); 209 | 210 | function setLayer(_x2) { 211 | return _ref4.apply(this, arguments); 212 | } 213 | 214 | return setLayer; 215 | }() 216 | }]); 217 | 218 | return Plate; 219 | }(_abstract3.default); 220 | 221 | exports.default = Plate; -------------------------------------------------------------------------------- /bin/plugins/nextion/pages/printSettings.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = undefined; 7 | 8 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 | 10 | var _abstract2 = require("./abstract.js"); 11 | 12 | var _abstract3 = _interopRequireDefault(_abstract2); 13 | 14 | var _lodash = require("lodash"); 15 | 16 | var _lodash2 = _interopRequireDefault(_lodash); 17 | 18 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 19 | 20 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 21 | 22 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 23 | 24 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 25 | 26 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 27 | 28 | require("babel-polyfill"); 29 | 30 | var PrintSettings = function (_abstract) { 31 | _inherits(PrintSettings, _abstract); 32 | 33 | function PrintSettings(screenManager) { 34 | _classCallCheck(this, PrintSettings); 35 | 36 | return _possibleConstructorReturn(this, (PrintSettings.__proto__ || Object.getPrototypeOf(PrintSettings)).call(this, screenManager)); 37 | } 38 | 39 | _createClass(PrintSettings, [{ 40 | key: "init", 41 | value: function () { 42 | var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(options) { 43 | var _this2 = this; 44 | 45 | return regeneratorRuntime.wrap(function _callee2$(_context2) { 46 | while (1) { 47 | switch (_context2.prev = _context2.next) { 48 | case 0: 49 | _context2.next = 2; 50 | return this.setScreen("prtSettings"); 51 | 52 | case 2: 53 | _context2.prev = 2; 54 | 55 | if (!(options && options.confirmResult && options.confirmResult)) { 56 | _context2.next = 14; 57 | break; 58 | } 59 | 60 | _context2.t0 = options.confirmType; 61 | _context2.next = _context2.t0 === "pause" ? 7 : _context2.t0 === "stop" ? 11 : 14; 62 | break; 63 | 64 | case 7: 65 | console.log("pause"); 66 | this.nanoDLP.pause(); 67 | this.changePage("home"); 68 | return _context2.abrupt("break", 14); 69 | 70 | case 11: 71 | this.nanoDLP.stop(); 72 | this.changePage("home"); 73 | return _context2.abrupt("break", 14); 74 | 75 | case 14: 76 | _context2.next = 19; 77 | break; 78 | 79 | case 16: 80 | _context2.prev = 16; 81 | _context2.t1 = _context2["catch"](2); 82 | 83 | console.log("error", _context2.t1); 84 | 85 | case 19: 86 | 87 | this.addListener("click_b4", function (e) { 88 | _this2.changePage("home"); 89 | }); 90 | 91 | this.addListener("click_b5", function (e) { 92 | _this2.changePage("confirm", { 93 | text: "Are you sure you want to debug\rprinting?\rIt will move 25mm to the top after\rthe current layer completed and\rcontinue to print.", 94 | confirmType: "debug", 95 | returnPage: "printSettings" 96 | }); 97 | }); 98 | 99 | this.addListener("click_b3", function (e) { 100 | console.log("click_b3"); 101 | _this2.changePage("confirm", { 102 | text: "Are you sure you want to pause\r printing?\rIt will pause after the current\rlayer completed.", 103 | confirmType: "pause", 104 | returnPage: "printSettings" 105 | }); 106 | }); 107 | 108 | this.addListener("click_b2", function (e) { 109 | _this2.changePage("confirm", { 110 | text: "Are you sure you want to stop\r printing?\rIt will stop after the current\rlayer completed.", 111 | confirmType: "stop", 112 | returnPage: "printSettings" 113 | }); 114 | }); 115 | 116 | this.addListener("string", function () { 117 | var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(string) { 118 | return regeneratorRuntime.wrap(function _callee$(_context) { 119 | while (1) { 120 | switch (_context.prev = _context.next) { 121 | case 0: 122 | _this2.history = {}; 123 | 124 | if (string != "cancel") { 125 | console.log("edit string :", string); 126 | _this2.profile.CureTime = Number(string); 127 | _this2.nanoDLP.setCureTime(_this2.profile.ProfileID, _this2.profile); 128 | _this2.changePage("home"); 129 | } 130 | 131 | case 2: 132 | case "end": 133 | return _context.stop(); 134 | } 135 | } 136 | }, _callee, _this2); 137 | })); 138 | 139 | return function (_x2) { 140 | return _ref2.apply(this, arguments); 141 | }; 142 | }()); 143 | 144 | this.setCureTime = false; 145 | 146 | case 25: 147 | case "end": 148 | return _context2.stop(); 149 | } 150 | } 151 | }, _callee2, this, [[2, 16]]); 152 | })); 153 | 154 | function init(_x) { 155 | return _ref.apply(this, arguments); 156 | } 157 | 158 | return init; 159 | }() 160 | }, { 161 | key: "update", 162 | value: function () { 163 | var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(status) { 164 | var remaining_time, total_time; 165 | return regeneratorRuntime.wrap(function _callee3$(_context3) { 166 | while (1) { 167 | switch (_context3.prev = _context3.next) { 168 | case 0: 169 | this.status = status; 170 | 171 | if (!(this.setCureTime == false)) { 172 | _context3.next = 13; 173 | break; 174 | } 175 | 176 | this.setCureTime = true; 177 | _context3.next = 5; 178 | return this.nanoDLP.getPlates(); 179 | 180 | case 5: 181 | this.plates = _context3.sent; 182 | 183 | this.plate = this.plates[_lodash2.default.findIndex(this.plates, { PlateID: this.status.PlateID })]; 184 | 185 | _context3.next = 9; 186 | return this.nanoDLP.getProfiles(); 187 | 188 | case 9: 189 | this.profiles = _context3.sent; 190 | 191 | this.profile = this.profiles[_lodash2.default.findIndex(this.profiles, { ProfileID: this.plate.ProfileID })]; 192 | 193 | _context3.next = 13; 194 | return this.setText("t7", this.profile.CureTime); 195 | 196 | case 13: 197 | remaining_time = Math.round((status.LayersCount - status.LayerID) * status.LayerTime / 1000000000 / 60); 198 | total_time = Math.round(status.LayersCount * status.LayerTime / 1000000000 / 60); 199 | _context3.next = 17; 200 | return this.setText("t11", status.LayerID + "/" + status.LayersCount); 201 | 202 | case 17: 203 | _context3.next = 19; 204 | return this.setText("t10", remaining_time + " of " + total_time + "min"); 205 | 206 | case 19: 207 | case "end": 208 | return _context3.stop(); 209 | } 210 | } 211 | }, _callee3, this); 212 | })); 213 | 214 | function update(_x3) { 215 | return _ref3.apply(this, arguments); 216 | } 217 | 218 | return update; 219 | }() 220 | }]); 221 | 222 | return PrintSettings; 223 | }(_abstract3.default); 224 | 225 | exports.default = PrintSettings; -------------------------------------------------------------------------------- /bin/plugins/nextion/pages/zAxis.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = undefined; 7 | 8 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 | 10 | var _abstract2 = require("./abstract.js"); 11 | 12 | var _abstract3 = _interopRequireDefault(_abstract2); 13 | 14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 15 | 16 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 17 | 18 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 19 | 20 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 21 | 22 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 23 | 24 | require("babel-polyfill"); 25 | 26 | var ZAxis = function (_abstract) { 27 | _inherits(ZAxis, _abstract); 28 | 29 | function ZAxis(screenManager) { 30 | _classCallCheck(this, ZAxis); 31 | 32 | var _this = _possibleConstructorReturn(this, (ZAxis.__proto__ || Object.getPrototypeOf(ZAxis)).call(this, screenManager)); 33 | 34 | _this.currentButton = 8; 35 | return _this; 36 | } 37 | 38 | _createClass(ZAxis, [{ 39 | key: "init", 40 | value: function () { 41 | var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(options) { 42 | var _this2 = this; 43 | 44 | return regeneratorRuntime.wrap(function _callee$(_context) { 45 | while (1) { 46 | switch (_context.prev = _context.next) { 47 | case 0: 48 | _context.next = 2; 49 | return this.setScreen("zAxis"); 50 | 51 | case 2: 52 | 53 | this.addListener("click_b16", function (e) { 54 | _this2.changePage("home"); 55 | }); 56 | 57 | this.addListener("click_b12", function (e) { 58 | _this2.up(); 59 | }); 60 | 61 | this.addListener("click_b13", function (e) { 62 | _this2.down(); 63 | }); 64 | 65 | this.addListener("click_b11", function () { 66 | return _this2.setBtn(11); 67 | }); 68 | this.addListener("click_b10", function () { 69 | return _this2.setBtn(10); 70 | }); 71 | this.addListener("click_b9", function () { 72 | return _this2.setBtn(9); 73 | }); 74 | this.addListener("click_b8", function () { 75 | return _this2.setBtn(8); 76 | }); 77 | this.addListener("click_b7", function () { 78 | return _this2.setBtn(7); 79 | }); 80 | this.addListener("click_b6", function () { 81 | return _this2.setBtn(6); 82 | }); 83 | this.addListener("click_b5", function () { 84 | return _this2.setBtn(5); 85 | }); 86 | this.addListener("click_b2", function () { 87 | return _this2.setBtn(2); 88 | }); 89 | 90 | this.addListener("click_b3", function () { 91 | return _this2.nanoDLP.command("/z-axis/top"); 92 | }); 93 | this.addListener("click_b4", function () { 94 | return _this2.nanoDLP.command("/z-axis/bottom"); 95 | }); 96 | this.addListener("click_b14", function () { 97 | return _this2.nanoDLP.command("/z-axis/touch-limit"); 98 | }); 99 | this.addListener("click_b15", function () { 100 | return _this2.nanoDLP.command("/z-axis/calibrate"); 101 | }); 102 | 103 | this.setBtn(10); 104 | 105 | case 18: 106 | case "end": 107 | return _context.stop(); 108 | } 109 | } 110 | }, _callee, this); 111 | })); 112 | 113 | function init(_x) { 114 | return _ref.apply(this, arguments); 115 | } 116 | 117 | return init; 118 | }() 119 | }, { 120 | key: "up", 121 | value: function () { 122 | var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { 123 | return regeneratorRuntime.wrap(function _callee2$(_context2) { 124 | while (1) { 125 | switch (_context2.prev = _context2.next) { 126 | case 0: 127 | this.move("up"); 128 | 129 | case 1: 130 | case "end": 131 | return _context2.stop(); 132 | } 133 | } 134 | }, _callee2, this); 135 | })); 136 | 137 | function up() { 138 | return _ref2.apply(this, arguments); 139 | } 140 | 141 | return up; 142 | }() 143 | }, { 144 | key: "down", 145 | value: function () { 146 | var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { 147 | return regeneratorRuntime.wrap(function _callee3$(_context3) { 148 | while (1) { 149 | switch (_context3.prev = _context3.next) { 150 | case 0: 151 | this.move("down"); 152 | 153 | case 1: 154 | case "end": 155 | return _context3.stop(); 156 | } 157 | } 158 | }, _callee3, this); 159 | })); 160 | 161 | function down() { 162 | return _ref3.apply(this, arguments); 163 | } 164 | 165 | return down; 166 | }() 167 | }, { 168 | key: "move", 169 | value: function () { 170 | var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(direction) { 171 | return regeneratorRuntime.wrap(function _callee4$(_context4) { 172 | while (1) { 173 | switch (_context4.prev = _context4.next) { 174 | case 0: 175 | _context4.t0 = this.currentButton; 176 | _context4.next = _context4.t0 === 11 ? 3 : _context4.t0 === 10 ? 6 : _context4.t0 === 9 ? 9 : _context4.t0 === 8 ? 12 : _context4.t0 === 7 ? 15 : _context4.t0 === 6 ? 18 : _context4.t0 === 5 ? 21 : _context4.t0 === 2 ? 24 : 27; 177 | break; 178 | 179 | case 3: 180 | _context4.next = 5; 181 | return this.nanoDLP.command("/z-axis/move/" + direction + "/micron/100000"); 182 | 183 | case 5: 184 | return _context4.abrupt("break", 27); 185 | 186 | case 6: 187 | _context4.next = 8; 188 | return this.nanoDLP.command("/z-axis/move/" + direction + "/micron/10000"); 189 | 190 | case 8: 191 | return _context4.abrupt("break", 27); 192 | 193 | case 9: 194 | _context4.next = 11; 195 | return this.nanoDLP.command("/z-axis/move/" + direction + "/micron/1000"); 196 | 197 | case 11: 198 | return _context4.abrupt("break", 27); 199 | 200 | case 12: 201 | _context4.next = 14; 202 | return this.nanoDLP.command("/z-axis/move/" + direction + "/micron/500"); 203 | 204 | case 14: 205 | return _context4.abrupt("break", 27); 206 | 207 | case 15: 208 | _context4.next = 17; 209 | return this.nanoDLP.command("/z-axis/move/" + direction + "/micron/100"); 210 | 211 | case 17: 212 | return _context4.abrupt("break", 27); 213 | 214 | case 18: 215 | _context4.next = 20; 216 | return this.nanoDLP.command("/z-axis/move/" + direction + "/pulse/100"); 217 | 218 | case 20: 219 | return _context4.abrupt("break", 27); 220 | 221 | case 21: 222 | _context4.next = 23; 223 | return this.nanoDLP.command("/z-axis/move/" + direction + "/pulse/10"); 224 | 225 | case 23: 226 | return _context4.abrupt("break", 27); 227 | 228 | case 24: 229 | _context4.next = 26; 230 | return this.nanoDLP.command("/z-axis/move/" + direction + "/pulse/1"); 231 | 232 | case 26: 233 | return _context4.abrupt("break", 27); 234 | 235 | case 27: 236 | case "end": 237 | return _context4.stop(); 238 | } 239 | } 240 | }, _callee4, this); 241 | })); 242 | 243 | function move(_x2) { 244 | return _ref4.apply(this, arguments); 245 | } 246 | 247 | return move; 248 | }() 249 | }, { 250 | key: "setBtn", 251 | value: function () { 252 | var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(id) { 253 | return regeneratorRuntime.wrap(function _callee5$(_context5) { 254 | while (1) { 255 | switch (_context5.prev = _context5.next) { 256 | case 0: 257 | _context5.next = 2; 258 | return this.nextion.setValue("bt" + this.currentButton, 0); 259 | 260 | case 2: 261 | this.currentButton = id; 262 | _context5.next = 5; 263 | return this.nextion.setValue("bt" + this.currentButton, 1); 264 | 265 | case 5: 266 | case "end": 267 | return _context5.stop(); 268 | } 269 | } 270 | }, _callee5, this); 271 | })); 272 | 273 | function setBtn(_x3) { 274 | return _ref5.apply(this, arguments); 275 | } 276 | 277 | return setBtn; 278 | }() 279 | }, { 280 | key: "update", 281 | value: function () { 282 | var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(status) { 283 | var currentMm, total; 284 | return regeneratorRuntime.wrap(function _callee6$(_context6) { 285 | while (1) { 286 | switch (_context6.prev = _context6.next) { 287 | case 0: 288 | if (this.setup) { 289 | _context6.next = 4; 290 | break; 291 | } 292 | 293 | _context6.next = 3; 294 | return this.nanoDLP.getSetup(); 295 | 296 | case 3: 297 | this.setup = _context6.sent; 298 | 299 | case 4: 300 | currentMm = status.CurrentHeight / (360 / this.setup.MotorDegree * this.setup.MicroStep / this.setup.LeadscrewPitch); 301 | total = this.setup.ZAxisHeight / (360 / this.setup.MotorDegree * this.setup.MicroStep / this.setup.LeadscrewPitch); 302 | _context6.next = 8; 303 | return this.setText("t1", currentMm + "mm"); 304 | 305 | case 8: 306 | _context6.next = 10; 307 | return this.setText("t2", total + "mm"); 308 | 309 | case 10: 310 | case "end": 311 | return _context6.stop(); 312 | } 313 | } 314 | }, _callee6, this); 315 | })); 316 | 317 | function update(_x4) { 318 | return _ref6.apply(this, arguments); 319 | } 320 | 321 | return update; 322 | }() 323 | }]); 324 | 325 | return ZAxis; 326 | }(_abstract3.default); 327 | 328 | exports.default = ZAxis; --------------------------------------------------------------------------------