|
1 | 1 | import { GoldenLayout, LayoutConfig } from "../golden-layout/bundle/esm/golden-layout.js"; |
| 2 | +import { configNonBeta } from './nonbetaConfig.js'; |
| 3 | + |
2 | 4 |
|
3 | 5 |
|
4 | 6 | /* |
5 | 7 | VERSION NUMBERS |
6 | 8 | */ |
7 | 9 |
|
8 | | -const showChangelogVersion = "1.1.0"; //update all instances of ?version= in the index file to match the version. This is needed for local cache busting |
9 | | -window.latestMicroPythonVersion = [1, 23, 0]; |
| 10 | +const showChangelogVersion = "1.2.1"; //update all instances of ?version= in the index file to match the version. This is needed for local cache busting |
| 11 | +window.latestMicroPythonVersion = [1, 25, 0]; |
10 | 12 | window.xrpID = ""; |
11 | 13 |
|
12 | 14 |
|
@@ -678,7 +680,56 @@ function registerShell(_container, state){ |
678 | 680 | document.getElementById('IDXRPName').innerHTML = "XRP-" + window.xrpID.slice(-5); |
679 | 681 | document.getElementById('IDXRPName').style.display = "block"; |
680 | 682 | } |
| 683 | + } |
| 684 | + |
| 685 | + REPL.pluginCheck = async () =>{ |
| 686 | + //check if this is a beta or nonbeta board |
| 687 | + // set the localstorage for this type |
| 688 | + // Add to Blockly if this is a nonbeta board |
| 689 | + // refresh the editors. |
| 690 | + |
| 691 | + var needsUpdate = false; |
| 692 | + xrpConfig = localStorage.getItem("xrpconfig"); |
| 693 | + if(REPL.PROCESSOR == 2350){ |
| 694 | + if(xrpConfig == null || xrpConfig === "beta"){ |
| 695 | + //we need to set things up |
| 696 | + localStorage.setItem("xrpconfig", "nonbeta"); |
| 697 | + await configNonBeta(); |
| 698 | + needsUpdate = true; |
| 699 | + } |
| 700 | + } |
| 701 | + else{ |
| 702 | + if(xrpConfig != null && xrpConfig === "nonbeta"){ |
| 703 | + //we need to go back to beta |
| 704 | + localStorage.setItem("xrpconfig", "beta"); |
| 705 | + blocklyToolbox = baseToolbox; |
| 706 | + servoNames = [["1", "1"], ["2", "2"]]; |
| 707 | + needsUpdate = true; |
| 708 | + } |
681 | 709 |
|
| 710 | + } |
| 711 | + if(needsUpdate){ |
| 712 | + for( var editor in EDITORS){ |
| 713 | + if(EDITORS[editor].isBlockly){ |
| 714 | + var ed = EDITORS[editor]; |
| 715 | + ed.BLOCKLY_WORKSPACE.updateToolbox(blocklyToolbox); |
| 716 | + |
| 717 | + //make sure the editor is pointing to blockly div incase there was an error before. |
| 718 | + ed.EDITOR_DIV.replaceChild(ed.BLOCKLY_DIV, ed.EDITOR_DIV.childNodes[0]); |
| 719 | + |
| 720 | + ed.BLOCKLY_WORKSPACE.clear(); |
| 721 | + //ed.BLOCKLY_DIV.innerHTML = ""; |
| 722 | + var data = localStorage.getItem("EditorValue" + editor) |
| 723 | + try{ |
| 724 | + Blockly.serialization.workspaces.load(JSON.parse(data), ed.BLOCKLY_WORKSPACE); |
| 725 | + } |
| 726 | + catch(e){ |
| 727 | + ed.EDITOR_DIV.replaceChild(ed.ERROR_DIV, ed.EDITOR_DIV.childNodes[0]); |
| 728 | + //console.log(e); |
| 729 | + } |
| 730 | + } |
| 731 | + } |
| 732 | + } |
682 | 733 | } |
683 | 734 | REPL.onFSData = (jsonStrData, fsSizeData) => { |
684 | 735 | FS.updateTree(jsonStrData); |
@@ -709,7 +760,11 @@ function registerShell(_container, state){ |
709 | 760 | message += "<br>Would you like to update now? If so, click OK to proceed with the update." |
710 | 761 | let answer = await confirmMessage(message); |
711 | 762 | if(answer){ |
712 | | - await alertMessage("When the <b>Select Folder</b> window comes up, select the <b>RPI-RP2</b> drive when it appears.<br>Next, click on 'Edit Files' and wait for the XRP to connect.<br> This process may take a few seconds."); |
| 763 | + let drive = "RPI-RP2" |
| 764 | + if(REPL.PROCESSOR == 2350){ |
| 765 | + drive = "RP2350" |
| 766 | + } |
| 767 | + await alertMessage("When the <b><i>Select Folder</i></b> window comes up, select the <b><i>" + drive +"</i></b> drive when it appears.<br>Next, click on <b><i>Edit Files</i></b> and wait for the XRP to reconnect.<br> This process may take a few seconds."); |
713 | 768 | REPL.updateMicroPython(); |
714 | 769 | } |
715 | 770 |
|
@@ -889,23 +944,28 @@ function registerEditor(_container, state) { |
889 | 944 | //if Cable attached check to see that the power switch is on. |
890 | 945 | // if BLE make sure the voltage is high enough |
891 | 946 | const voltage = await REPL.batteryVoltage(); |
| 947 | + var image = '/images/XRP_Controller-Power.jpg' |
| 948 | + if(REPL.PROCESSOR == 2350){ |
| 949 | + image = '/images/XRP-nonbeta-controller-power.jpg' |
| 950 | + } |
| 951 | + |
892 | 952 | if(REPL.BLE_DEVICE == undefined){ |
893 | | - if(voltage < 0.4) { |
| 953 | + if(voltage < 0.45) { |
894 | 954 | if(! await window.confirmMessage("The power switch on the XRP is not on. Motors and Servos will not work.<br>Turn on the switch before continuing." + |
895 | | - "<br><img src='/images/XRP_Controller-Power.jpg' width=300>")) { |
| 955 | + "<br><img src=" + image + " width=300>")) { |
896 | 956 | return; |
897 | 957 | } |
898 | 958 | } |
899 | 959 | }else{ |
900 | | - if(voltage < 0.4) { //the device must be connected to a USB power with the power switch turned off. |
| 960 | + if(voltage < 0.45) { //the device must be connected to a USB power with the power switch turned off. |
901 | 961 | if(! await window.confirmMessage("The power switch on the XRP is not on. Motors and Servos will not work.<br>Turn on the switch before continuing." + |
902 | | - "<br><img src='/images/XRP_Controller-Power.jpg' width=300>")) { |
| 962 | + "<br><img src==" + image + " width=300>")) { |
903 | 963 | return; |
904 | 964 | } |
905 | 965 |
|
906 | 966 | }else if(voltage < 5.0) { |
907 | 967 | if(await window.confirmMessage("<h1 style='text-align:center'>Low Battery Power! - Please Replace the Batteries</h1>" + |
908 | | - "<br><div style='text-align:center'> <img src='/images/sad-battery.png' width=200></div>")) { |
| 968 | + "<br><div style='text-align:center'> <img src='/images/sad-battery.jpg' width=200></div>")) { |
909 | 969 | return; |
910 | 970 | } |
911 | 971 | } |
@@ -1009,6 +1069,13 @@ function registerEditor(_container, state) { |
1009 | 1069 | EDITORS[editor.ID] = editor; |
1010 | 1070 | } |
1011 | 1071 |
|
| 1072 | +// determine the last XRP configuration (Beta or Non-Beta) and setup the Blockly editor appropriately |
| 1073 | +// This check is re-done when an actual XRP is attached. |
| 1074 | +var xrpConfig = localStorage.getItem("xrpconfig"); |
| 1075 | +if (xrpConfig != null && xrpConfig === "nonbeta"){ |
| 1076 | + //add non-beta blocks |
| 1077 | + await configNonBeta(); |
| 1078 | +} |
1012 | 1079 |
|
1013 | 1080 | // Register Golden layout panels |
1014 | 1081 | myLayout.registerComponentConstructor("Filesystem", registerFilesystem); |
|
0 commit comments