File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed
Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 11const fs = require ( 'fs' )
2- const Serial = require ( './serial.js' )
3- let serial
2+ const serial = require ( './serial.js' ) . sharedInstance
43
54const {
65 openFolderDialog,
109} = require ( './helpers.js' )
1110
1211module . exports = function registerIPCHandlers ( win , ipcMain , app , dialog ) {
13- serial = new Serial ( win )
12+ serial . win = win // Required to send callback messages to renderer
1413
1514 ipcMain . handle ( 'open-folder' , async ( event ) => {
1615 console . log ( 'ipcMain' , 'open-folder' )
Original file line number Diff line number Diff line change 11const { app, Menu } = require ( 'electron' )
22const path = require ( 'path' )
3- const Serial = require ( './serial.js' )
3+ const serial = require ( './serial.js' ) . sharedInstance
44const openAboutWindow = require ( 'about-window' ) . default
55
66module . exports = function registerMenu ( win , state = { } ) {
@@ -92,7 +92,7 @@ module.exports = function registerMenu(win, state = {}) {
9292 accelerator : '' ,
9393 click : async ( ) => {
9494 try {
95- await Serial . disconnect ( )
95+ await serial . disconnect ( )
9696 win . reload ( )
9797 } catch ( e ) {
9898 console . error ( 'Reload from menu failed:' , e )
Original file line number Diff line number Diff line change 11const MicroPython = require ( 'micropython.js' )
22
33class Serial {
4- constructor ( win ) {
4+ constructor ( win = null ) {
55 this . win = win
66 this . board = new MicroPython ( )
77 this . board . chunk_size = 192
@@ -110,4 +110,6 @@ except OSError:
110110 }
111111}
112112
113- module . exports = Serial
113+ const sharedInstance = new Serial ( )
114+
115+ module . exports = { sharedInstance, Serial}
You can’t perform that action at this time.
0 commit comments