@@ -1484,16 +1484,8 @@ function web_editor(config) {
1484
1484
1485
1485
// Hide serial and disconnect if open
1486
1486
if ( $ ( "#repl" ) . css ( 'display' ) != 'none' ) {
1487
- $ ( "#repl" ) . hide ( ) ;
1488
- $ ( "#request-repl" ) . hide ( ) ;
1489
- $ ( "#request-serial" ) . hide ( ) ;
1490
- $ ( "#editor-container" ) . show ( ) ;
1487
+ closeSerial ( ) ;
1491
1488
}
1492
- $ ( "#command-serial" ) . attr ( "title" , config [ "translate" ] [ "static-strings" ] [ "buttons" ] [ "command-serial" ] [ "title" ] ) ;
1493
- $ ( "#command-serial > .roundlabel" ) . text ( config [ "translate" ] [ "static-strings" ] [ "buttons" ] [ "command-serial" ] [ "label" ] ) ;
1494
-
1495
- $ ( "#repl" ) . empty ( ) ;
1496
- REPL = null ;
1497
1489
1498
1490
// Change button to connect
1499
1491
$ ( "#command-disconnect" ) . hide ( ) ;
@@ -1509,15 +1501,13 @@ function web_editor(config) {
1509
1501
if ( usePartialFlashing ) {
1510
1502
if ( window . dapwrapper ) {
1511
1503
console . log ( "Disconnecting: Using Quick Flash" ) ;
1512
- p = p . then ( function ( ) { window . dapwrapper . daplink . stopSerialRead ( ) } )
1513
- . then ( function ( ) { window . dapwrapper . disconnectAsync ( ) } ) ;
1504
+ p = p . then ( function ( ) { window . dapwrapper . disconnectAsync ( ) } ) ;
1514
1505
}
1515
1506
}
1516
1507
else {
1517
1508
if ( window . daplink ) {
1518
1509
console . log ( "Disconnecting: Using Full Flash" ) ;
1519
- p = p . then ( function ( ) { window . daplink . stopSerialRead ( ) } )
1520
- . then ( function ( ) { window . daplink . disconnect ( ) } ) ;
1510
+ p = p . then ( function ( ) { window . daplink . disconnect ( ) } ) ;
1521
1511
}
1522
1512
}
1523
1513
@@ -1538,21 +1528,7 @@ function web_editor(config) {
1538
1528
1539
1529
// Hide serial and disconnect if open
1540
1530
if ( $ ( "#repl" ) . css ( 'display' ) != 'none' ) {
1541
- $ ( "#repl" ) . hide ( ) ;
1542
- $ ( "#request-repl" ) . hide ( ) ;
1543
- $ ( "#request-serial" ) . hide ( ) ;
1544
- $ ( "#editor-container" ) . show ( ) ;
1545
- $ ( "#command-serial" ) . attr ( "title" , config [ "translate" ] [ "static-strings" ] [ "buttons" ] [ "command-serial" ] [ "title" ] ) ;
1546
- $ ( "#command-serial > .roundlabel" ) . text ( config [ "translate" ] [ "static-strings" ] [ "buttons" ] [ "command-serial" ] [ "label" ] ) ;
1547
-
1548
- if ( usePartialFlashing ) {
1549
- if ( window . dapwrapper ) {
1550
- window . dapwrapper . daplink . stopSerialRead ( ) ;
1551
- }
1552
- }
1553
- else {
1554
- window . daplink . stopSerialRead ( ) ;
1555
- }
1531
+ closeSerial ( ) ;
1556
1532
}
1557
1533
1558
1534
// Get the hex to flash in bytes format, exit if there is an error
@@ -1580,9 +1556,6 @@ function web_editor(config) {
1580
1556
1581
1557
var p = Promise . resolve ( ) ;
1582
1558
if ( usePartialFlashing ) {
1583
- REPL = null ;
1584
- $ ( "#repl" ) . empty ( ) ;
1585
-
1586
1559
p = window . dapwrapper . disconnectAsync ( )
1587
1560
. then ( function ( ) {
1588
1561
return PartialFlashing . connectDapAsync ( ) ;
@@ -1640,25 +1613,29 @@ function web_editor(config) {
1640
1613
} ) ;
1641
1614
}
1642
1615
1616
+ function closeSerial ( keepSession ) {
1617
+ console . log ( "Closing Serial Terminal" ) ;
1618
+ $ ( "#repl" ) . empty ( ) ;
1619
+ $ ( "#repl" ) . hide ( ) ;
1620
+ $ ( "#request-repl" ) . hide ( ) ;
1621
+ $ ( "#request-serial" ) . hide ( ) ;
1622
+ $ ( "#editor-container" ) . show ( ) ;
1623
+
1624
+ var serialButton = config [ "translate" ] [ "static-strings" ] [ "buttons" ] [ "command-serial" ] ;
1625
+ $ ( "#command-serial" ) . attr ( "title" , serialButton [ "title" ] ) ;
1626
+ $ ( "#command-serial > .roundlabel" ) . text ( serialButton [ "label" ] ) ;
1627
+
1628
+ var daplink = usePartialFlashing ? window . dapwrapper . daplink : window . daplink ;
1629
+ daplink . stopSerialRead ( ) ;
1630
+ REPL = null ;
1631
+ }
1632
+
1643
1633
function doSerial ( ) {
1644
1634
console . log ( "Setting Up Serial Terminal" ) ;
1645
1635
// Hide terminal
1646
1636
var serialButton = config [ "translate" ] [ "static-strings" ] [ "buttons" ] [ "command-serial" ] ;
1647
1637
if ( $ ( "#repl" ) . css ( 'display' ) != 'none' ) {
1648
- $ ( "#repl" ) . hide ( ) ;
1649
- $ ( "#request-repl" ) . hide ( ) ;
1650
- $ ( "#request-serial" ) . hide ( ) ;
1651
- $ ( "#editor-container" ) . show ( ) ;
1652
- $ ( "#command-serial" ) . attr ( "title" , serialButton [ "label" ] ) ;
1653
- $ ( "#command-serial > .roundlabel" ) . text ( serialButton [ "label" ] ) ;
1654
- if ( usePartialFlashing ) {
1655
- if ( window . dapwrapper ) {
1656
- window . dapwrapper . daplink . stopSerialRead ( ) ;
1657
- }
1658
- }
1659
- else {
1660
- window . daplink . stopSerialRead ( ) ;
1661
- }
1638
+ closeSerial ( ) ;
1662
1639
return ;
1663
1640
}
1664
1641
0 commit comments