1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT license.
3
- import * as constants from "../common/constants" ;
4
- import { getSerialMonitorApi , LineEnding , Parity , Port , SerialMonitorApi , StopBits , Version } from "@microsoft/vscode-serial-monitor-api" ;
3
+ import { getSerialMonitorApi , LineEnding , Parity , Port , SerialMonitorApi , StopBits , Version } from "@microsoft/vscode-serial-monitor-api" ;
5
4
import * as vscode from "vscode" ;
6
- import { SerialPortCtrl } from "./serialportctrl " ;
5
+ import * as constants from "../common/constants " ;
7
6
import { DeviceContext } from "../deviceContext" ;
7
+ import { SerialPortCtrl } from "./serialportctrl" ;
8
8
9
9
export interface ISerialPortDetail {
10
10
port : string ;
@@ -15,6 +15,8 @@ export interface ISerialPortDetail {
15
15
}
16
16
17
17
export class SerialMonitor implements vscode . Disposable {
18
+ public static DEFAULT_TIMESTAMP_FORMAT : string = "" ;
19
+
18
20
public static listBaudRates ( ) : number [ ] {
19
21
return [ 300 , 1200 , 2400 , 4800 , 9600 , 19200 , 38400 , 57600 , 74880 , 115200 , 230400 , 250000 , 500000 , 1000000 , 2000000 ] ;
20
22
}
@@ -26,8 +28,6 @@ export class SerialMonitor implements vscode.Disposable {
26
28
return SerialMonitor . _serialMonitor ;
27
29
}
28
30
29
- public static DEFAULT_TIMESTAMP_FORMAT : string = "" ;
30
-
31
31
private static _serialMonitor : SerialMonitor = null ;
32
32
33
33
private serialMonitorApi : SerialMonitorApi | undefined ;
@@ -42,7 +42,7 @@ export class SerialMonitor implements vscode.Disposable {
42
42
43
43
public async initialize ( extensionContext : vscode . ExtensionContext ) {
44
44
this . extensionContext = extensionContext ;
45
-
45
+
46
46
this . portsStatusBar = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right , constants . statusBarPriority . PORT ) ;
47
47
this . portsStatusBar . command = "arduino.selectSerialPort" ;
48
48
this . portsStatusBar . tooltip = "Select Serial Port" ;
@@ -67,7 +67,7 @@ export class SerialMonitor implements vscode.Disposable {
67
67
dc . onChangePort ( ( ) => {
68
68
this . updatePortListStatus ( ) ;
69
69
} ) ;
70
-
70
+
71
71
this . serialMonitorApi = await getSerialMonitorApi ( Version . latest , extensionContext ) ;
72
72
}
73
73
@@ -100,34 +100,6 @@ export class SerialMonitor implements vscode.Disposable {
100
100
return undefined ;
101
101
}
102
102
103
- private updatePortListStatus ( port ?: string ) {
104
- const dc = DeviceContext . getInstance ( ) ;
105
- if ( port ) {
106
- dc . port = port ;
107
- }
108
- this . currentPort = dc . port ;
109
-
110
- if ( dc . port ) {
111
- this . portsStatusBar . text = dc . port ;
112
- } else {
113
- this . portsStatusBar . text = "<Select Serial Port>" ;
114
- }
115
- }
116
-
117
- private updatePortStatus ( isOpened : boolean ) {
118
- if ( isOpened ) {
119
- this . openPortStatusBar . command = "arduino.closeSerialMonitor" ;
120
- this . openPortStatusBar . text = `$(x)` ;
121
- this . openPortStatusBar . tooltip = "Close Serial Monitor" ;
122
- this . timestampFormatStatusBar . show ( ) ;
123
- } else {
124
- this . openPortStatusBar . command = "arduino.openSerialMonitor" ;
125
- this . openPortStatusBar . text = `$(plug)` ;
126
- this . openPortStatusBar . tooltip = "Open Serial Monitor" ;
127
- this . timestampFormatStatusBar . hide ( ) ;
128
- }
129
- }
130
-
131
103
public async changeTimestampFormat ( ) : Promise < void > {
132
104
await vscode . commands . executeCommand ( "workbench.action.openSettings" , "vscode-serial-monitor.timestampFormat" ) ;
133
105
}
@@ -196,4 +168,32 @@ export class SerialMonitor implements vscode.Disposable {
196
168
public dispose ( ) {
197
169
this . serialMonitorApi . dispose ( ) ;
198
170
}
171
+
172
+ private updatePortListStatus ( port ?: string ) {
173
+ const dc = DeviceContext . getInstance ( ) ;
174
+ if ( port ) {
175
+ dc . port = port ;
176
+ }
177
+ this . currentPort = dc . port ;
178
+
179
+ if ( dc . port ) {
180
+ this . portsStatusBar . text = dc . port ;
181
+ } else {
182
+ this . portsStatusBar . text = "<Select Serial Port>" ;
183
+ }
184
+ }
185
+
186
+ private updatePortStatus ( isOpened : boolean ) {
187
+ if ( isOpened ) {
188
+ this . openPortStatusBar . command = "arduino.closeSerialMonitor" ;
189
+ this . openPortStatusBar . text = `$(x)` ;
190
+ this . openPortStatusBar . tooltip = "Close Serial Monitor" ;
191
+ this . timestampFormatStatusBar . show ( ) ;
192
+ } else {
193
+ this . openPortStatusBar . command = "arduino.openSerialMonitor" ;
194
+ this . openPortStatusBar . text = `$(plug)` ;
195
+ this . openPortStatusBar . tooltip = "Open Serial Monitor" ;
196
+ this . timestampFormatStatusBar . hide ( ) ;
197
+ }
198
+ }
199
199
}
0 commit comments