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
42const registerMenu = require ( './menu.js' )
3+ const serial = require ( './serial.js' ) . sharedInstance
54
65const {
76 openFolderDialog,
@@ -11,7 +10,7 @@ const {
1110} = require ( './helpers.js' )
1211
1312module . exports = function registerIPCHandlers ( win , ipcMain , app , dialog ) {
14- serial = new Serial ( win )
13+ serial . win = win // Required to send callback messages to renderer
1514
1615 ipcMain . handle ( 'open-folder' , async ( event ) => {
1716 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
55const shortcuts = require ( './shortcuts.js' )
66const { type } = require ( 'os' )
@@ -128,7 +128,7 @@ module.exports = function registerMenu(win, state = {}) {
128128 accelerator : '' ,
129129 click : async ( ) => {
130130 try {
131- await Serial . disconnect ( )
131+ await serial . disconnect ( )
132132 win . reload ( )
133133 } catch ( e ) {
134134 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