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 1717
1818 let currentReceiverLine ;
1919
20- function appendLine ( linesId , text ) {
20+ function appendLines ( linesId , text ) {
21+ const lines = text . split ( '\r' ) ;
2122 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+ }
2327 } else {
24- currentReceiverLine = addLine ( linesId , text ) ;
28+ for ( let i = 0 ; i < lines . length ; i ++ ) {
29+ currentReceiverLine = addLine ( linesId , lines [ i ] ) ;
30+ }
2531 }
2632 }
2733
3642 if ( data . getInt8 ( ) === 13 ) {
3743 currentReceiverLine = null ;
3844 } else {
39- appendLine ( 'receiver_lines' , textDecoder . decode ( data ) ) ;
45+ appendLines ( 'receiver_lines' , textDecoder . decode ( data ) ) ;
4046 }
4147 } ;
4248 port . onReceiveError = error => {
Original file line number Diff line number Diff line change @@ -30,4 +30,4 @@ <h1>TinyUSB - WebUSB Serial Example</h1>
3030 </ div >
3131 </ div >
3232 </ body >
33- </ html >
33+ </ html >
You can’t perform that action at this time.
0 commit comments