@@ -23,6 +23,11 @@ export namespace SerialPlotterContribution {
23
23
label : 'Serial Plotter' ,
24
24
category : 'Arduino' ,
25
25
} ;
26
+ export const RESET : Command = {
27
+ id : 'serial-plotter-reset' ,
28
+ label : 'Reset Serial Plotter' ,
29
+ category : 'Arduino' ,
30
+ } ;
26
31
}
27
32
}
28
33
@@ -59,6 +64,9 @@ export class PlotterFrontendContribution extends Contribution {
59
64
registry . registerCommand ( SerialPlotterContribution . Commands . OPEN , {
60
65
execute : this . startPlotter . bind ( this ) ,
61
66
} ) ;
67
+ registry . registerCommand ( SerialPlotterContribution . Commands . RESET , {
68
+ execute : ( ) => this . reset ( ) ,
69
+ } ) ;
62
70
}
63
71
64
72
registerMenus ( menus : MenuModelRegistry ) : void {
@@ -96,28 +104,9 @@ export class PlotterFrontendContribution extends Contribution {
96
104
}
97
105
98
106
protected async open ( wsPort : number ) : Promise < void > {
99
- const board = this . boardsServiceProvider . boardsConfig . selectedBoard ;
100
- const port = this . boardsServiceProvider . boardsConfig . selectedPort ;
101
- let baudrates : number [ ] = [ ] ;
102
- let currentBaudrate = - 1 ;
103
- if ( board && port ) {
104
- const { pluggableMonitorSettings } =
105
- await this . monitorManagerProxy . getCurrentSettings ( board , port ) ;
106
- if ( pluggableMonitorSettings && 'baudrate' in pluggableMonitorSettings ) {
107
- // Convert from string to numbers
108
- baudrates = pluggableMonitorSettings [ 'baudrate' ] . values . map ( ( b ) => + b ) ;
109
- currentBaudrate = + pluggableMonitorSettings [ 'baudrate' ] . selectedValue ;
110
- }
111
- }
112
-
113
107
const initConfig : Partial < SerialPlotter . Config > = {
114
- baudrates,
115
- currentBaudrate,
116
- currentLineEnding : this . model . lineEnding ,
117
108
darkTheme : this . themeService . getCurrentTheme ( ) . type === 'dark' ,
118
109
wsPort,
119
- interpolate : this . model . interpolate ,
120
- connected : this . model . connected ,
121
110
serialPort : this . model . serialPort ,
122
111
} ;
123
112
const urlWithParams = queryString . stringifyUrl (
@@ -129,4 +118,11 @@ export class PlotterFrontendContribution extends Contribution {
129
118
) ;
130
119
this . window = window . open ( urlWithParams , 'serialPlotter' ) ;
131
120
}
121
+
122
+ protected async reset ( ) : Promise < void > {
123
+ if ( ! ! this . window ) {
124
+ this . window . close ( ) ;
125
+ await this . startPlotter ( ) ;
126
+ }
127
+ }
132
128
}
0 commit comments