File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
docs/examples/webusb-serial Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 17
17
18
18
let currentReceiverLine ;
19
19
20
- function appendLine ( linesId , text ) {
20
+ function appendLines ( linesId , text ) {
21
+ const lines = text . split ( '\r' ) ;
21
22
if ( currentReceiverLine ) {
22
- currentReceiverLine . innerHTML = currentReceiverLine . innerHTML + text ;
23
+ currentReceiverLine . innerHTML = currentReceiverLine . innerHTML + lines [ 0 ] ;
24
+ for ( let i = 1 ; i < lines . length ; i ++ ) {
25
+ currentReceiverLine = addLine ( linesId , lines [ i ] ) ;
26
+ }
23
27
} else {
24
- currentReceiverLine = addLine ( linesId , text ) ;
28
+ for ( let i = 0 ; i < lines . length ; i ++ ) {
29
+ currentReceiverLine = addLine ( linesId , lines [ i ] ) ;
30
+ }
25
31
}
26
32
}
27
33
36
42
if ( data . getInt8 ( ) === 13 ) {
37
43
currentReceiverLine = null ;
38
44
} else {
39
- appendLine ( 'receiver_lines' , textDecoder . decode ( data ) ) ;
45
+ appendLines ( 'receiver_lines' , textDecoder . decode ( data ) ) ;
40
46
}
41
47
} ;
42
48
port . onReceiveError = error => {
Original file line number Diff line number Diff line change @@ -30,4 +30,4 @@ <h1>TinyUSB - WebUSB Serial Example</h1>
30
30
</ div >
31
31
</ div >
32
32
</ body >
33
- </ html >
33
+ </ html >
You can’t perform that action at this time.
0 commit comments